@lobu/runtime-server 24.6.0 → 24.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component.json +1 -1
- package/dist/owletto/dist/assets/_-CZgmjLR9.js +2 -0
- package/dist/owletto/dist/assets/_-Cm5OgtYD.js +3 -0
- package/dist/owletto/dist/assets/_agentId-Cci6NFc1.js +2 -0
- package/dist/owletto/dist/assets/_agentId-GhWTlPO2.js +2 -0
- package/dist/owletto/dist/assets/_automationId-KUlxSTK2.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-Zpy7Hvml.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-CYDRp9UX.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-NNqDdije.js +2 -0
- package/dist/owletto/dist/assets/_eventId-0BSX6VHj.js +2 -0
- package/dist/owletto/dist/assets/_owner-C-CD22NB.js +3 -0
- package/dist/owletto/dist/assets/_shape-CvXp4omb.js +2 -0
- package/dist/owletto/dist/assets/_slug-DgK7zpKA.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-cH54P0zY.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-m0B5j7L9.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-CQZQ0wwC.js → accept-invitation-CX7Egv-p.js} +2 -2
- package/dist/owletto/dist/assets/activity-link-rXNpmppV.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-B0m7_g9q.js +2 -0
- package/dist/owletto/dist/assets/{agent-client-setup-list-CpUTAjXf.js → agent-client-setup-list-BmD3-_Ox.js} +2 -2
- package/dist/owletto/dist/assets/{agent-connect-pages-Br_ycC0z.js → agent-connect-pages-BtOTCsTU.js} +2 -2
- package/dist/owletto/dist/assets/agent-editor-form-CirqCpcM.js +2 -0
- package/dist/owletto/dist/assets/agent-list-row-SyACVYX7.js +2 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-_18OREnx.js → agent-loading-shells-DHvKiEUB.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-Dsc26dyW.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-1DBn7Xc_.js → agent-skill-context-DF5q0Dfr.js} +2 -2
- package/dist/owletto/dist/assets/agent-subpage-shell-Pi5cECga.js +2 -0
- package/dist/owletto/dist/assets/{agent-thread-FyEO-y44.js → agent-thread-B1ZepGZc.js} +4 -4
- package/dist/owletto/dist/assets/agents-D1FHZ0jR.js +2 -0
- package/dist/owletto/dist/assets/app._appId-01I0CJal.js +2 -0
- package/dist/owletto/dist/assets/{assist-composer-Mn9EfX4X.js → assist-composer-BD9msDk3.js} +2 -2
- package/dist/owletto/dist/assets/automation-detail-content-BFv1TglZ.js +2 -0
- package/dist/owletto/dist/assets/automation-row-CmTpAD4r.js +2 -0
- package/dist/owletto/dist/assets/{automation-source-list-Dhucq1sI.js → automation-source-list-D8ZSavQU.js} +2 -2
- package/dist/owletto/dist/assets/automations-D1FHZ0jR.js +2 -0
- package/dist/owletto/dist/assets/{callback-9xSHyA12.js → callback-Ckrxv0eo.js} +2 -2
- package/dist/owletto/dist/assets/{card-g4yxo4Hr.js → card-DT9mSjSp.js} +2 -2
- package/dist/owletto/dist/assets/{change-summary-DeuXQEpb.js → change-summary-CGrKEJ04.js} +2 -2
- package/dist/owletto/dist/assets/{claim-B98IhDra.js → claim-Bzby28tT.js} +2 -2
- package/dist/owletto/dist/assets/{client-activity-scopes-BD2HBo-_.js → client-activity-scopes-DoIErdUy.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows-x_CxeWkP.js → client-rows-BbVQy5Ti.js} +2 -2
- package/dist/owletto/dist/assets/{clients-Cmp0LmOp.js → clients-6aJvabvS.js} +2 -2
- package/dist/owletto/dist/assets/connect-BmDziBzI.js +2 -0
- package/dist/owletto/dist/assets/{connect-menu-CezOH3s7.js → connect-menu-Bs8mxsga.js} +2 -2
- package/dist/owletto/dist/assets/connect._clientId-t5aKu3aa.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-DswMAw8l.js +2 -0
- package/dist/owletto/dist/assets/{connection-B6fM2KHN.js → connection-BOaMa324.js} +2 -2
- package/dist/owletto/dist/assets/connection-feed-detail-BLCjhP-H.js +2 -0
- package/dist/owletto/dist/assets/connector-boxes-BAP_f77M.js +2 -0
- package/dist/owletto/dist/assets/{connector-page-shell-Di6XzkVo.js → connector-page-shell-ClOmVPJr.js} +2 -2
- package/dist/owletto/dist/assets/{connector-provenance-BrnasBW4.js → connector-provenance-wmYu5jwO.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-DnOUxX_U.js → connectors-D5F5rHxX.js} +2 -2
- package/dist/owletto/dist/assets/{consent-Byli4yMs.js → consent-RqHNkmm8.js} +2 -2
- package/dist/owletto/dist/assets/{copy-button-Ddf7lBjZ.js → copy-button-D6zpsZLi.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-BsXtvNoI.js → core.esm-BIE97rfo.js} +3 -3
- package/dist/owletto/dist/assets/create-BPxsKwk7.js +2 -0
- package/dist/owletto/dist/assets/{create-YdAnh3ml.js → create-GT8_yF0R.js} +2 -2
- package/dist/owletto/dist/assets/create-Yx2qBMBy.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-B12yTrmj.js +3 -0
- package/dist/owletto/dist/assets/create._connectorKey-CzXqSkuI.js +2 -0
- package/dist/owletto/dist/assets/custom-guardrail-edits-B9plaLBN.js +2 -0
- package/dist/owletto/dist/assets/{definition-comparison-B5WgZILB.js → definition-comparison-C3k6Wa9B.js} +2 -2
- package/dist/owletto/dist/assets/detail-page-skeleton-I5_7FkKx.js +2 -0
- package/dist/owletto/dist/assets/{device-DdCoCj-Q.js → device-CadaiNF4.js} +2 -2
- package/dist/owletto/dist/assets/device-automation-Dp3faMvp.js +2 -0
- package/dist/owletto/dist/assets/device-pin-tombstone-U7Bx05P6.js +2 -0
- package/dist/owletto/dist/assets/device._deviceId-DTZqj1HS.js +2 -0
- package/dist/owletto/dist/assets/dynamic-schema-form-DyT_9iVE.js +2 -0
- package/dist/owletto/dist/assets/entity-options-CGTjLlcS.js +2 -0
- package/dist/owletto/dist/assets/entity-page-DHHMmA8V.js +2 -0
- package/dist/owletto/dist/assets/entity-pages-eYbG2FDT.js +2 -0
- package/dist/owletto/dist/assets/{entity-type-page-D0ghgRgq.js → entity-type-page-CjFqxSdL.js} +2 -2
- package/dist/owletto/dist/assets/event-card-BtTUuf2q.js +2 -0
- package/dist/owletto/dist/assets/event-detail-8xHiplt_.js +2 -0
- package/dist/owletto/dist/assets/events-feed-zFnTSE27.js +2 -0
- package/dist/owletto/dist/assets/filter-editors-Dd5R2Etd.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-B5xXnKtV.js → full-page-spinner-CCU4PkRv.js} +2 -2
- package/dist/owletto/dist/assets/home-stream-IVsNEkwp.js +2 -0
- package/dist/owletto/dist/assets/index-2oaMOFKe.js +2 -0
- package/dist/owletto/dist/assets/index-B-Ab8srM.js +7899 -0
- package/dist/owletto/dist/assets/index-B4RZgvvI.js +2 -0
- package/dist/owletto/dist/assets/{index-BDl1_w6U.js → index-B72KYdN1.js} +2 -2
- package/dist/owletto/dist/assets/index-BBZM53p8.js +2 -0
- package/dist/owletto/dist/assets/index-BOb0a5f9.js +2 -0
- package/dist/owletto/dist/assets/{index-BdNR51Ua.js → index-BYFDMIQC.js} +2 -2
- package/dist/owletto/dist/assets/index-BwnFQcMe.js +2 -0
- package/dist/owletto/dist/assets/index-CvYsWYlF.js +2 -0
- package/dist/owletto/dist/assets/{index-CkiyxW4w.js → index-DIXIvtnM.js} +2 -2
- package/dist/owletto/dist/assets/index-DLwokXHW.js +2 -0
- package/dist/owletto/dist/assets/index-_nlPHus1.js +2 -0
- package/dist/owletto/dist/assets/index-cwOgj4-i.js +2 -0
- package/dist/owletto/dist/assets/{index-TkPy_P_u.js → index-pmr1WUoG.js} +2 -2
- package/dist/owletto/dist/assets/index-pp4qmhkA.js +2 -0
- package/dist/owletto/dist/assets/index-tTbno-PX.css +1 -0
- package/dist/owletto/dist/assets/{json-diff-DtZtra_g.js → json-diff-B-1Swv_y.js} +2 -2
- package/dist/owletto/dist/assets/list-skeleton-BAqT0vxo.js +2 -0
- package/dist/owletto/dist/assets/{login-TWR0vF4_.js → login-D5bIjMtf.js} +2 -2
- package/dist/owletto/dist/assets/{logout-BA5kojS0.js → logout-JYZvxz8v.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-BQiRAqtx.js → member-scope-gate-Lj9m4RL2.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-rAKfVdQ_.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-B2cjCn0V.js → model-selector-onvGA9Ww.js} +2 -2
- package/dist/owletto/dist/assets/{new-Dc5Bbotb.js → new-B-Jd-vBl.js} +2 -2
- package/dist/owletto/dist/assets/new-BmehH1uR.js +2 -0
- package/dist/owletto/dist/assets/new-KDi15LWZ.js +2 -0
- package/dist/owletto/dist/assets/{organization-B9U1L-56.js → organization-B9bh20Xo.js} +2 -2
- package/dist/owletto/dist/assets/peek-pane-content-Bqus80Mq.js +2 -0
- package/dist/owletto/dist/assets/{pending-seed-BP3xHM2d.js → pending-seed-CoFPQ835.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-BED-DO9C.js → proposal-review-shell-CnACXCUg.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-Dlh-eWz0.js +2 -0
- package/dist/owletto/dist/assets/record-activity-6CfR95Ul.js +2 -0
- package/dist/owletto/dist/assets/{record-session-DOFgdd43.js → record-session-Bpx4_LGk.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-CHPS-1vD.js → renderer-CgaQKMoG.js} +26 -26
- package/dist/owletto/dist/assets/{reset-password-BmNM-apc.js → reset-password-C-4Jnuqk.js} +2 -2
- package/dist/owletto/dist/assets/run-initiator-BvruBM5H.js +2 -0
- package/dist/owletto/dist/assets/{runs-BntGAKQG.js → runs-BMzp7j7j.js} +2 -2
- package/dist/owletto/dist/assets/runs-list-DVhrTr3v.js +2 -0
- package/dist/owletto/dist/assets/{schema-type-editor-panel-v3nR2Oa2.js → schema-type-editor-panel-Bdeumkux.js} +2 -2
- package/dist/owletto/dist/assets/{schema-value-BFb7jCBo.js → schema-value-BUgC0Ro8.js} +2 -2
- package/dist/owletto/dist/assets/{settings-DubSpJfg.js → settings-DYYvrrZ4.js} +2 -2
- package/dist/owletto/dist/assets/skill-route-key-sF006xiz.js +2 -0
- package/dist/owletto/dist/assets/source-record-panels-CBV9tsR3.js +2 -0
- package/dist/owletto/dist/assets/status-variants-DT61YfsU.js +2 -0
- package/dist/owletto/dist/assets/{table-DALHuXPE.js → table-B6yimlsZ.js} +2 -2
- package/dist/owletto/dist/assets/{use-automations-D9hKpufo.js → use-automations-II_YJWtN.js} +2 -2
- package/dist/owletto/dist/assets/{use-login-redirect-ciwfc-7A.js → use-login-redirect-BqtEilid.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-CJGCatFS.js → use-mention-search-Bxlpd6Dp.js} +3 -3
- package/dist/owletto/dist/assets/view-param-filters-DYlqBocg.js +2 -0
- package/dist/owletto/dist/assets/{views-access-required-CZ1fvAks.js → views-access-required-BVtMfgLh.js} +2 -2
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +84 -5
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/package.json +1 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-DT3E3BmS.js +0 -3
- package/dist/owletto/dist/assets/_-c1xy7bLu.js +0 -2
- package/dist/owletto/dist/assets/_agentId-CTfoi0-7.js +0 -2
- package/dist/owletto/dist/assets/_agentId-DV8utajn.js +0 -2
- package/dist/owletto/dist/assets/_automationId-DvP3qyYL.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-CL5SivCn.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-tnMwC67b.js +0 -2
- package/dist/owletto/dist/assets/_conversationId-DXN_8m88.js +0 -2
- package/dist/owletto/dist/assets/_eventId-SdpFT7jB.js +0 -2
- package/dist/owletto/dist/assets/_name-CM1AMywz.js +0 -2
- package/dist/owletto/dist/assets/_owner-CaGsXXBW.js +0 -3
- package/dist/owletto/dist/assets/_shape-DGAkETDp.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-Dd4ZHPY8.js +0 -2
- package/dist/owletto/dist/assets/_slug-cRvJQtNo.js +0 -2
- package/dist/owletto/dist/assets/_view-B5I7mmkl.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-Bwn0dyLo.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-YjSYD0wc.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-CZykJXQp.js +0 -2
- package/dist/owletto/dist/assets/agent-card-controls-DuQJhtqp.js +0 -2
- package/dist/owletto/dist/assets/agent-editor-form-BXQBFHSv.js +0 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-CN7vpC0X.js +0 -2
- package/dist/owletto/dist/assets/agent-list-row-BnP6r4pm.js +0 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-DSjidWHL.js +0 -2
- package/dist/owletto/dist/assets/agent-skills-route-d5jh3oBR.js +0 -2
- package/dist/owletto/dist/assets/agent-tab-intro-DKrC3SQt.js +0 -2
- package/dist/owletto/dist/assets/agents-kXojozTU.js +0 -2
- package/dist/owletto/dist/assets/agents-workbench-CDpJmUVN.js +0 -2
- package/dist/owletto/dist/assets/app._appId-DwNeXRJp.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-Bs3vwAPd.js +0 -2
- package/dist/owletto/dist/assets/automation-row-B5Q1B10y.js +0 -2
- package/dist/owletto/dist/assets/automations-kXojozTU.js +0 -2
- package/dist/owletto/dist/assets/connect-zUot_0kG.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-nsGxe6yO.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-DnclRRXk.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-CDB8atTX.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.index-DBNP2mZo.js +0 -2
- package/dist/owletto/dist/assets/connection-feed-detail-Ckq-qEbD.js +0 -2
- package/dist/owletto/dist/assets/connection-label-BobuYiAG.js +0 -2
- package/dist/owletto/dist/assets/connections-browser-BXsJqieG.js +0 -2
- package/dist/owletto/dist/assets/connector-boxes-CbqSFeVm.js +0 -2
- package/dist/owletto/dist/assets/connector-scope-lists-dQnZARCD.js +0 -2
- package/dist/owletto/dist/assets/create-B34eskZ_.js +0 -2
- package/dist/owletto/dist/assets/create-DLB9sXgU.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-C9PMX7N8.js +0 -3
- package/dist/owletto/dist/assets/create._connectorKey-Bz4OYRiC.js +0 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-B06J7Af1.js +0 -2
- package/dist/owletto/dist/assets/device._deviceId-Bh9S4bFp.js +0 -2
- package/dist/owletto/dist/assets/dynamic-schema-form-qWSRtOAv.js +0 -2
- package/dist/owletto/dist/assets/entity-options-BkU_En_f.js +0 -2
- package/dist/owletto/dist/assets/entity-page-BPFDHY8q.js +0 -2
- package/dist/owletto/dist/assets/entity-pages-DxgbjLMt.js +0 -2
- package/dist/owletto/dist/assets/event-card-CjA_dLzq.js +0 -2
- package/dist/owletto/dist/assets/event-detail-CmC-DVrK.js +0 -2
- package/dist/owletto/dist/assets/events-feed-CGzA1w3R.js +0 -2
- package/dist/owletto/dist/assets/filter-bar-CQ_oE7a9.js +0 -2
- package/dist/owletto/dist/assets/guardrails-DkXatmea.js +0 -2
- package/dist/owletto/dist/assets/identity-BwJy3ixB.js +0 -2
- package/dist/owletto/dist/assets/index-35ehGReZ.js +0 -2
- package/dist/owletto/dist/assets/index-B9hYiwBw.js +0 -2
- package/dist/owletto/dist/assets/index-BjcZVe7n.js +0 -7899
- package/dist/owletto/dist/assets/index-BqAVebvY.js +0 -2
- package/dist/owletto/dist/assets/index-BvK1fS1J.js +0 -2
- package/dist/owletto/dist/assets/index-CNEpTkgw.css +0 -1
- package/dist/owletto/dist/assets/index-CRc73k1t.js +0 -2
- package/dist/owletto/dist/assets/index-CYGaSD3y.js +0 -2
- package/dist/owletto/dist/assets/index-CfZGe-zn.js +0 -2
- package/dist/owletto/dist/assets/index-CzLDNB2E.js +0 -2
- package/dist/owletto/dist/assets/index-D-o5iOVd.js +0 -2
- package/dist/owletto/dist/assets/index-DjYVV1Ml.js +0 -2
- package/dist/owletto/dist/assets/index-VyAX-asP.js +0 -2
- package/dist/owletto/dist/assets/list-skeleton-CIHWCi2a.js +0 -2
- package/dist/owletto/dist/assets/manage-gear-C-0BAMbC.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-Ba32-vVL.js +0 -74
- package/dist/owletto/dist/assets/model-C2q7WDcS.js +0 -2
- package/dist/owletto/dist/assets/models-CZkH5gtj.js +0 -2
- package/dist/owletto/dist/assets/nav-pill-Bam6s3jj.js +0 -2
- package/dist/owletto/dist/assets/new-BJst6K0b.js +0 -2
- package/dist/owletto/dist/assets/new-DgbivfDe.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-Cq8P38s3.js +0 -2
- package/dist/owletto/dist/assets/permissions-BVlbeY4u.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-Diq15_QW.js +0 -2
- package/dist/owletto/dist/assets/record-activity-CTLwq8s1.js +0 -2
- package/dist/owletto/dist/assets/run-activity-link-Dh1YyCfk.js +0 -2
- package/dist/owletto/dist/assets/run-initiator-CCxNv0rK.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-BwTVaRsE.js +0 -2
- package/dist/owletto/dist/assets/runs-table-CYS1jDdL.js +0 -2
- package/dist/owletto/dist/assets/settings-DBgT60nY.js +0 -2
- package/dist/owletto/dist/assets/skills-DDoeRGhJ.js +0 -2
- package/dist/owletto/dist/assets/source-record-panels-m8gECt82.js +0 -2
- package/dist/owletto/dist/assets/status-dot-BnQPFrcU.js +0 -2
- package/dist/owletto/dist/assets/use-scroll-sentinel-BWCrmNIB.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-CDvwie_f.js +0 -2
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import{r as w,j as n,B as V,d6 as ct,fm as js,fn as Es,c0 as Cs,i as ce,d5 as Ct,S as Be,bs as _s,fo as Ms,v as De,fp as Kt,fq as Ts,fr as Rs,fs as Is,H as Ae,bl as $t,bm as Ot,bn as At,bo as Pt,bp as mt,ft as Ls,I as tt,fu as $s,bP as On,fv as An,fw as Pn,fx as Os,l as _t,fy as As,c as nt,u as Jt,eI as Dn,aH as Ps,aI as Ds,cD as Fs,fz as zs,aB as Ws,fA as Fn,b4 as Bs,b8 as Hs,b_ as zn,$ as Vs,L as Pe,X as Us,ey as Wn,c2 as qs,c3 as Gs,fB as Ys,fC as Ks,f5 as Js,c7 as Qs,bt as Bn,fD as Hn,fE as Ze,fF as xt,fG as Xs,fH as Zs,fI as Qt,fJ as er,fK as Bt,fL as Ht,fM as tr,fN as nr,cP as Vn,cQ as bt,dW as sr,da as rr,bN as or,eu as ar,el as ir,e4 as cr,b2 as Un,fO as qn,eW as lr,ff as dr,e9 as ur,V as Vt,cR as Gn,fP as mr,dh as fr,cY as pr,dT as Yn,dV as Kn,cI as Jn,dU as Qn,dX as hr,dY as gr,dZ as yr,d_ as xr,cT as un,fQ as br,fR as vr,cU as wr,Y as kr,fS as Xn,fT as Zn,aq as Nr,fU as Sr,E as es,fV as jr,ch as Ve,k as ts,fW as Dt,fX as Er,fY as Cr,c$ as mn,fZ as Ft,f_ as _r,f$ as Mr,g0 as Tr,eT as Rr,g1 as Ir,g2 as Lr,bj as $r,g3 as Or,a as Ar,g4 as Pr,g5 as Dr,ak as Fr,az as zr}from"./index-BjcZVe7n.js";import{P as Wr}from"./public-shell-ready-Diq15_QW.js";import{f as Br,a as Hr,c as fn,d as Vr,A as Ur}from"./connector-boxes-CbqSFeVm.js";import{u as qr}from"./use-automations-D9hKpufo.js";import{c as Gr}from"./connections-browser-BXsJqieG.js";import{d as Yr,e as Kr}from"./model-C2q7WDcS.js";import{c as Jr}from"./connection-label-BobuYiAG.js";import{f as Qr}from"./feed-event-kinds-BYuZCoU4.js";import{S as Xr}from"./schema-type-editor-panel-v3nR2Oa2.js";import{D as Zr,c as eo}from"./dynamic-schema-form-qWSRtOAv.js";import{S as to,E as ns,a as no,e as so,b as ro,c as oo}from"./entity-pages-DxgbjLMt.js";import{F as ao}from"./filter-bar-CQ_oE7a9.js";import{l as io,p as Mt,e as ss,a as co,S as lo,J as uo}from"./renderer-CHPS-1vD.js";import{u as mo,a as fo,D as po,P as ho,b as rs,c as go,C as yo}from"./core.esm-BsXtvNoI.js";import{v as xo,V as os,M as as,a as is,w as bo,b as vo}from"./view-param-filters-CDvwie_f.js";import{E as wo}from"./entity-type-page-D0ghgRgq.js";import{n as ko}from"./nav-pill-Bam6s3jj.js";import{M as No}from"./member-scope-gate-BQiRAqtx.js";function pn(e){let t=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const c of e)t=Math.min(t,c.x-c.w/2),r=Math.max(r,c.x+c.w/2),s=Math.min(s,c.y-c.h/2),o=Math.max(o,c.y+c.h/2);return Number.isFinite(t)?{x0:t,y0:s,x1:r,y1:o}:null}const vt=(e,t,s)=>e<t?t:e>s?s:e;function So(e,t,s,{padding:r=.12,minZoom:o=.2,maxZoom:c=1.2}={}){const a=Math.max(1,e.x1-e.x0),l=Math.max(1,e.y1-e.y0),h=vt(Math.min(t/(a*(1+r)),s/(l*(1+r))),o,c);return{z:h,x:t/2-(e.x0+e.x1)/2*h,y:s/2-(e.y0+e.y1)/2*h}}function jo(e,t,s=0){if(e===t){const v=e.x+e.w/2,N=e.y-e.h/2;return[{x:v-30,y:N},{x:v-30,y:N-26},{x:v+22,y:N-26},{x:v+22,y:e.y-6},{x:v,y:e.y-6}]}const r=s*8,o=e.x+e.w/2,c=e.y+vt(r,-e.h/2+6,e.h/2-6),a=t.x-t.w/2,l=t.y+vt(r,-t.h/2+6,t.h/2-6);if(a-o>=40){const v=(o+a)/2+r;return[{x:o,y:c},{x:v,y:c},{x:v,y:l},{x:a,y:l}]}const h=Math.max(e.y+e.h/2,t.y+t.h/2)+24+Math.abs(r),i=Math.min(e.y-e.h/2,t.y-t.h/2)-24-Math.abs(r),g=(c+l)/2,p=Math.abs(h-g)<=Math.abs(i-g)?h:i,f=o+24+Math.abs(r),m=a-24-Math.abs(r);return[{x:o,y:c},{x:f,y:c},{x:f,y:p},{x:m,y:p},{x:m,y:l},{x:a,y:l}]}function Eo(e,t,s){const r=s.x-t.x,o=s.y-t.y,c=r*r+o*o,a=c?vt(((e.x-t.x)*r+(e.y-t.y)*o)/c,0,1):0;return Math.hypot(e.x-(t.x+a*r),e.y-(t.y+a*o))}function Co(e,t){let s=Number.POSITIVE_INFINITY;for(let r=0;r<t.length-1;r++)s=Math.min(s,Eo(e,t[r],t[r+1]));return s}function _o(e,t){return Math.abs(t.x-e.x)<=e.w/2&&Math.abs(t.y-e.y)<=e.h/2}class Xe{cells=new Set;static CELL_W=12;static CELL_H=16;keys(t){const s=[],r=Math.floor(t.x0/Xe.CELL_W),o=Math.floor(t.x1/Xe.CELL_W),c=Math.floor(t.y0/Xe.CELL_H),a=Math.floor(t.y1/Xe.CELL_H);for(let l=r;l<=o;l++)for(let h=c;h<=a;h++)s.push(l*1e5+h);return s}isFree(t){return this.keys(t).every(s=>!this.cells.has(s))}reserve(t){for(const s of this.keys(t))this.cells.add(s)}}function Mo(e,t,s,r,o){const c=e.slice(0,-1).map((p,f)=>({i:f,length:Math.hypot(e[f+1].x-p.x,e[f+1].y-p.y)})).sort((p,f)=>f.length-p.length);if(c.length===0)return null;const a=p=>({x0:p.x-t/2,x1:p.x+t/2,y0:p.y-s/2,y1:p.y+s/2}),l=p=>({x:(e[p].x+e[p+1].x)/2,y:(e[p].y+e[p+1].y)/2});for(const{i:p,length:f}of c){if(!o&&f<t*.7)break;const m=l(p);if(r.isFree(a(m)))return r.reserve(a(m)),m}if(!o)return null;const h=l(c[0].i),g=[-1,1,-1.6,1.6].map(p=>({x:h.x,y:h.y+p*(s+12)})).find(p=>r.isFree(a(p)))??h;return r.reserve(a(g)),g}const To=e=>n.jsx(Ct,{icon:e||null,className:"h-4 w-4"}),Ro='600 14px "DM Sans", system-ui, sans-serif',Io='400 11px "DM Sans", system-ui, sans-serif',Lo='500 9px "DM Sans", system-ui, sans-serif',$o='500 11px "DM Sans", system-ui, sans-serif',at=18,hn=8;function gn(e){const t=getComputedStyle(e),s=(r,o)=>t.getPropertyValue(r).trim()||o;return{foreground:s("--foreground","#141414"),muted:s("--muted-foreground","#545454"),card:s("--card","#ffffff"),background:s("--background","#fcfcfb"),border:s("--border","#e7e4dc"),primary:s("--primary","#2f63e8"),mutedSurface:s("--muted","#f3f1ea")}}function ft(e,t,s){if(e.measureText(t).width<=s)return t;let r=0,o=t.length;for(;r<o;){const c=Math.ceil((r+o)/2);e.measureText(`${t.slice(0,c)}…`).width<=s?r=c:o=c-1}return`${t.slice(0,r)}…`}function Oo(e,t,s,r){const o=Math.hypot(s.x-t.x,s.y-t.y);if(o<1)return;const c=(s.x-t.x)/o,a=(s.y-t.y)/o;e.moveTo(s.x-c*r-a*r*.55,s.y-a*r+c*r*.55),e.lineTo(s.x,s.y),e.lineTo(s.x-c*r+a*r*.55,s.y-a*r-c*r*.55)}function cs({boxes:e,edges:t,label:s,onOpenBox:r,openLabel:o,onConnect:c,renderIcon:a=To,className:l}){const h=w.useRef(null),i=w.useRef(null),g=w.useRef(null),p=w.useRef({z:1,x:0,y:0}),f=w.useRef({w:0,h:0,dpr:1}),m=w.useRef(!0),v=w.useRef(new Map),N=w.useRef(null),d=w.useRef(null),j=w.useRef(new Map),S=w.useRef(null),E=w.useRef(""),k=w.useRef(!1),[y,x]=w.useState(()=>new Map),[T,$]=w.useState(null),[F,A]=w.useState(null),[K,H]=w.useState(null),[se,W]=w.useState(null),[ge,ne]=w.useState(0),{placed:U,movedIds:Ce}=w.useMemo(()=>{const C=new Map,u=new Set;for(const M of e){const b=y.get(M.id);b&&b.from.x===M.x&&b.from.y===M.y?(C.set(M.id,{...M,x:b.at.x,y:b.at.y}),u.add(M.id)):C.set(M.id,M)}return{placed:C,movedIds:u}},[e,y]),ue=w.useMemo(()=>{const C=new Map;for(const M of t){const b=[M.source,M.target].sort().join("|");C.set(b,[...C.get(b)??[],M])}const u=new Map;for(const M of t){const b=U.get(M.source),_=U.get(M.target);if(!b||!_)continue;if(M.route&&!Ce.has(b.id)&&!Ce.has(_.id)){u.set(M.id,M.route);continue}const R=C.get([M.source,M.target].sort().join("|"))??[M];u.set(M.id,jo(b,_,R.indexOf(M)-(R.length-1)/2))}return u},[t,U,Ce]),Q=w.useCallback(()=>{m.current=!0},[]),ee=w.useCallback(()=>{const C=pn([...U.values()]),{w:u,h:M}=f.current;!C||!u||!M||(p.current=So(C,u,M),k.current=!0,Q())},[U,Q]),me=C=>{p.current=C,k.current=!1,Q()},_e=C=>{const u=pn(C),{w:M,h:b}=f.current;if(!u||!M||!b)return;const _=p.current,R=24;u.x0*_.z+_.x>=R&&u.y0*_.z+_.y>=R&&u.x1*_.z+_.x<=M-R&&u.y1*_.z+_.y<=b-R||me({..._,x:M/2-(u.x0+u.x1)/2*_.z,y:b/2-(u.y0+u.y1)/2*_.z})},Ue=C=>{W(C);const u=U.get(C);u&&_e([u])},oe=e.map(C=>`${C.id}@${Math.round(C.x)},${Math.round(C.y)}`).join(";");w.useEffect(()=>{!oe||E.current===oe||f.current.w&&(E.current=oe,ee())},[oe,ee]);const ve=w.useRef(ee);ve.current=ee;const Fe=w.useRef(oe);Fe.current=oe,w.useEffect(()=>{const C=h.current,u=i.current;if(!C||!u||typeof ResizeObserver>"u")return;const M=()=>{const _=window.devicePixelRatio||1,R=C.clientWidth,z=C.clientHeight;f.current={w:R,h:z,dpr:_},u.width=Math.round(R*_),u.height=Math.round(z*_);const P=Fe.current;P&&R&&z&&(E.current!==P||k.current)&&(E.current=P,ve.current()),Q()};M();const b=new ResizeObserver(M);return b.observe(C),()=>b.disconnect()},[Q]);const[Me,Te]=w.useState(0);w.useEffect(()=>{const C=g.current,u=i.current;if(!C||!u)return;const M=gn(u).muted;for(const b of C.querySelectorAll("[data-icon-key]")){const _=b.dataset.iconKey??"";if(v.current.has(_))continue;const R=b.querySelector("svg"),z=R?null:b.querySelector("img")?.src;if(!R&&!z){v.current.set(_,b.textContent??"");continue}const P=new Image;if(P.onload=Q,P.onerror=()=>{v.current.delete(_),Te(O=>O+1)},R){const O=R.cloneNode(!0);O.getAttribute("width")||O.setAttribute("width","24"),O.getAttribute("height")||O.setAttribute("height","24");const D=new XMLSerializer().serializeToString(O).replaceAll("currentColor",M);P.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(D)}`}else z&&(P.src=z);v.current.set(_,P)}},[e,ge,Me,Q]);const we=(C,u)=>{const M=p.current;return{x:(C-M.x)/M.z,y:(u-M.y)/M.z}},ze=(C,u)=>{const M=p.current,b=we(C,u),_=T&&T.kind!=="edge"?U.get(T.box.id):void 0;if(_&&c){const O=yn(_);if(Math.hypot(O.x*M.z+M.x-C,O.y*M.z+M.y-u)<=hn+3)return{kind:"handle",box:_}}const R=[...U.values()];for(let O=R.length-1;O>=0;O--)if(_o(R[O],b))return{kind:"box",box:R[O]};let z=null,P=7/M.z;for(const O of t){const D=ue.get(O.id);if(!D)continue;const ae=Co(b,D);ae<P&&(P=ae,z=O)}return z?{kind:"edge",edge:z}:null},fe=w.useMemo(()=>{const C=new Set;for(const M of[F,K])M&&C.add(M);T?.kind==="edge"&&C.add(T.edge.id);const u=T&&T.kind!=="edge"?T.box.id:se;if(u)for(const M of t)(M.source===u||M.target===u)&&C.add(M.id);for(const M of t)M.dimmed&&C.delete(M.id);return C},[t,T,F,K,se]);w.useEffect(Q,[U,ue,fe,T,se,Q]);const ke=w.useCallback(()=>{const C=i.current,u=C?.getContext("2d");if(!C||!u)return;const{w:M,h:b,dpr:_}=f.current,R=gn(C),z=getComputedStyle(C),P=new Map,O=L=>{let G=P.get(L);return G===void 0&&(G=z.getPropertyValue(L).trim(),P.set(L,G)),G},{z:D,x:ae,y:re}=p.current,be=L=>({x:L.x*D+ae,y:L.y*D+re});u.setTransform(_,0,0,_,0,0),u.clearRect(0,0,M,b);const Le=T&&T.kind!=="edge"?T.box.id:null;u.lineJoin="round";for(const L of t){const G=ue.get(L.id);if(!G)continue;const J=G.map(be),B=fe.has(L.id);u.globalAlpha=L.dimmed?.15:B?.95:.55,u.strokeStyle=B?R.foreground:R.muted,u.lineWidth=B?1.75:1.25,u.beginPath(),u.moveTo(J[0].x,J[0].y);for(const X of J.slice(1))u.lineTo(X.x,X.y);L.directed&&Oo(u,J[J.length-2],J[J.length-1],8),u.stroke()}const Ge=new Xe;for(const L of U.values()){const G=be(L),J=L.w*D,B=L.h*D,X=G.x-J/2,q=G.y-B/2;if(Ge.reserve({x0:X,y0:q,x1:X+J,y1:q+B}),X>M||q>b||X+J<0||q+B<0)continue;const Oe=Le===L.id||S.current?.over?.id===L.id;u.globalAlpha=L.dimmed?.25:1,u.beginPath(),u.roundRect(X,q,J,B,8*D),u.fillStyle=L.muted?R.mutedSurface:R.card,u.fill(),u.lineWidth=Oe||se===L.id?1.5:1,u.strokeStyle=Oe||se===L.id?R.primary:R.border,u.stroke();const te=L.accent&&O(L.accent);if(te&&(u.save(),u.clip(),u.fillStyle=te,u.fillRect(X,q,3*D,B),u.restore()),14*D<5)continue;const de=12*D,Z=16*D,ie=L.meta?q+B/2-8*D:q+B/2,je=v.current.get(L.icon??"");je instanceof HTMLImageElement&&je.complete&&je.naturalWidth>0?u.drawImage(je,X+de,ie-Z/2,Z,Z):typeof je=="string"&&je&&(u.font=`${14*D}px system-ui, sans-serif`,u.textBaseline="middle",u.textAlign="left",u.fillText(je,X+de,ie));const We=X+de+Z+8*D,st=12*D;u.textBaseline="middle",u.textAlign="left";let Je=X+J-st-We;if(L.badge){u.font=Lo.replace("9px",`${9*D}px`);const rt=ft(u,L.badge.toUpperCase(),Je*.35),Qe=u.measureText(rt).width+8*D,ot=X+J-st-Qe;u.strokeStyle=R.border,u.lineWidth=1,u.beginPath(),u.roundRect(ot,ie-7*D,Qe,14*D,3*D),u.stroke(),u.fillStyle=R.muted,u.fillText(rt,ot+4*D,ie+.5),Je-=Qe+6*D}u.font=Ro.replace("14px",`${14*D}px`),u.fillStyle=R.foreground,u.fillText(ft(u,L.title,Je),We,ie+.5),L.meta&&(u.font=Io.replace("11px",`${11*D}px`),u.fillStyle=R.muted,u.fillText(ft(u,L.meta,X+J-de-We),We,q+B/2+10*D))}const $e=S.current,Ye=$e?.from??(Le?U.get(Le):void 0);if(c&&Ye&&Ye.w*D>=60){const L=be(yn(Ye));if(u.globalAlpha=1,$e){const G=be($e.to);u.strokeStyle=R.primary,u.lineWidth=2,u.setLineDash([6,4]),u.beginPath(),u.moveTo(L.x,L.y),u.lineTo(G.x,G.y),u.stroke(),u.setLineDash([])}u.fillStyle=R.card,u.strokeStyle=R.primary,u.lineWidth=1.5,u.beginPath(),u.arc(L.x,L.y,hn,0,Math.PI*2),u.fill(),u.stroke(),u.beginPath(),u.moveTo(L.x-4,L.y),u.lineTo(L.x+4,L.y),u.moveTo(L.x,L.y-4),u.lineTo(L.x,L.y+4),u.stroke()}u.font=$o,u.textAlign="center",u.textBaseline="middle";const Ke=(L,G,J,B)=>{u.globalAlpha=1,u.fillStyle=R.background,u.strokeStyle=J?R.foreground:R.border,u.lineWidth=1,u.beginPath(),u.roundRect(L.x-B/2,L.y-at/2,B,at,5),u.fill(),u.stroke(),u.fillStyle=J?R.foreground:R.muted,u.fillText(G,L.x,L.y+.5)},Tt=[...t].sort((L,G)=>Number(fe.has(G.id))-Number(fe.has(L.id)));for(const L of Tt){const G=ue.get(L.id);if(!G||L.dimmed&&!fe.has(L.id))continue;const J=G.map(be),B=fe.has(L.id),q=(B?L.details:[L.summary]).map(Z=>ft(u,Z,200)),Oe=Math.max(...q.map(Z=>u.measureText(Z).width))+14,te=q.length*(at+2);if(!B&&D<.45)continue;const de=Mo(J,Oe,te,Ge,B);de&&q.forEach((Z,ie)=>{Ke({x:de.x,y:de.y-te/2+(at+2)*ie+at/2},Z,B,Oe)})}u.globalAlpha=1},[t,ue,U,fe,T,se,c]);w.useEffect(()=>{let C=0;const u=()=>{C=requestAnimationFrame(u),m.current&&(m.current=!1,ke())};return C=requestAnimationFrame(u),document.addEventListener("visibilitychange",Q),()=>{cancelAnimationFrame(C),document.removeEventListener("visibilitychange",Q)}},[ke,Q]),w.useEffect(()=>{const C=new MutationObserver(()=>{v.current.clear(),ne(u=>u+1),Q()});return C.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>C.disconnect()},[Q]);const ye=(C,u,M)=>{const b=p.current,_=Math.min(3,Math.max(.15,b.z*C));me({z:_,x:u-(u-b.x)*(_/b.z),y:M-(M-b.y)*(_/b.z)})},Ne=C=>{const u=i.current?.getBoundingClientRect();return{x:C.clientX-(u?.left??0),y:C.clientY-(u?.top??0)}},le=C=>{if(C.button!==0&&C.pointerType==="mouse")return;C.currentTarget.setPointerCapture(C.pointerId);const u=Ne(C);if(C.pointerType==="touch"&&(j.current.set(C.pointerId,u),j.current.size===2)){const[_,R]=[...j.current.values()];N.current=null,S.current=null,d.current={d:Math.hypot(_.x-R.x,_.y-R.y)||1,mid:{x:(_.x+R.x)/2,y:(_.y+R.y)/2}};return}const M=ze(u.x,u.y),b={start:u,last:u,hit:M,moved:!1};if(M?.kind==="handle")S.current={from:M.box,to:we(u.x,u.y),over:null};else if(M?.kind==="box"){const _=we(u.x,u.y);b.grab={x:M.box.x-_.x,y:M.box.y-_.y}}N.current=b},Re=C=>{const u=Ne(C);j.current.has(C.pointerId)&&j.current.set(C.pointerId,u);const M=d.current;if(M&&j.current.size===2){const[O,D]=[...j.current.values()],ae=Math.hypot(O.x-D.x,O.y-D.y)||1,re={x:(O.x+D.x)/2,y:(O.y+D.y)/2};me({...p.current,x:p.current.x+re.x-M.mid.x,y:p.current.y+re.y-M.mid.y}),ye(ae/M.d,re.x,re.y),d.current={d:ae,mid:re};return}const b=N.current;if(!b){const O=ze(u.x,u.y);$(ae=>Ao(ae,O)?ae:O);const D=i.current;D&&(D.style.cursor=O?.kind==="handle"?"crosshair":O?"pointer":"grab");return}const _=u.x-b.last.x,R=u.y-b.last.y;if(b.last=u,!b.moved&&Math.hypot(u.x-b.start.x,u.y-b.start.y)>4&&(b.moved=!0),!b.moved)return;const z=S.current;if(z){z.to=we(u.x,u.y);const O=ze(u.x,u.y);z.over=O?.kind==="box"?O.box:null,Q();return}const P=b.hit;if(P?.kind==="box"&&b.grab){const O=we(u.x,u.y),D=e.find(re=>re.id===P.box.id);if(!D)return;const ae={x:O.x+b.grab.x,y:O.y+b.grab.y};x(re=>new Map(re).set(D.id,{at:ae,from:{x:D.x,y:D.y}}));return}me({...p.current,x:p.current.x+_,y:p.current.y+R}),i.current&&(i.current.style.cursor="grabbing")},Se=C=>{if(j.current.delete(C.pointerId),d.current){j.current.size<2&&(d.current=null),N.current=null;return}const u=N.current;N.current=null;const M=S.current;if(S.current=null,!u)return;if(i.current&&(i.current.style.cursor="grab"),M){Q(),M.over&&c&&c(M.from.id,M.over.id);return}if(u.moved)return;const b=u.hit;b?.kind==="box"?r(b.box.id):b?.kind==="edge"?A(_=>_===b.edge.id?null:b.edge.id):A(null)},xe=C=>{j.current.delete(C.pointerId),d.current=null,N.current=null,S.current=null,Q()};w.useEffect(()=>{const C=i.current;if(!C)return;const u=M=>{M.preventDefault();const b=Ne(M);M.ctrlKey||M.metaKey?ye(Math.exp(-M.deltaY*(M.ctrlKey?.01:.002)),b.x,b.y):me({...p.current,x:p.current.x-M.deltaX,y:p.current.y-M.deltaY})};return C.addEventListener("wheel",u,{passive:!1}),()=>C.removeEventListener("wheel",u)});const qe=C=>ye(C,f.current.w/2,f.current.h/2),Ie=[...new Set(e.map(C=>C.icon??""))];return n.jsxs("div",{ref:h,className:ce("relative h-full w-full overflow-hidden",l),children:[n.jsx("canvas",{ref:i,"aria-hidden":"true",className:"block h-full w-full cursor-grab touch-none",onPointerDown:le,onPointerMove:Re,onPointerUp:Se,onPointerCancel:xe,onPointerLeave:()=>{N.current||$(null)}}),n.jsxs("ul",{ref:g,"aria-label":s,className:"sr-only",children:[Ie.map(C=>n.jsx("li",{"aria-hidden":"true","data-icon-key":C,children:a(C)},`icon:${C}`)),e.map(C=>n.jsx("li",{children:n.jsx("button",{type:"button",onClick:()=>r(C.id),onFocus:()=>Ue(C.id),onBlur:()=>W(null),children:o(C)})},C.id)),t.map(C=>n.jsx("li",{"data-revealed":fe.has(C.id)||void 0,children:n.jsx("button",{type:"button","aria-pressed":F===C.id,onClick:()=>A(u=>u===C.id?null:C.id),onFocus:()=>{H(C.id);const u=ue.get(C.id);u&&_e(u.map(M=>({...M,w:0,h:0})))},onBlur:()=>H(null),children:C.ariaLabel})},C.id))]}),n.jsxs("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:[n.jsx(V,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom in",onClick:()=>qe(1.25),children:n.jsx(ct,{className:"h-3.5 w-3.5"})}),n.jsx(V,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom out",onClick:()=>qe(.8),children:n.jsx(js,{className:"h-3.5 w-3.5"})}),n.jsx(V,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Fit to view",onClick:ee,children:n.jsx(Es,{className:"h-3.5 w-3.5"})}),Ce.size>0?n.jsx(V,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Reset layout",onClick:()=>x(new Map),children:n.jsx(Cs,{className:"h-3.5 w-3.5"})}):null]})]})}const yn=e=>({x:e.x+e.w/2,y:e.y});function Ao(e,t){return!e||!t?e===t:e.kind==="edge"||t.kind==="edge"?e.kind==="edge"&&t.kind==="edge"&&e.edge.id===t.edge.id:e.kind===t.kind&&e.box.id===t.box.id}function Xt({label:e,fill:t=!1,schemaActions:s=!1}){return n.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:ce("flex min-w-0 flex-col gap-3",t&&"min-h-0 flex-1"),children:[n.jsx("div",{"aria-hidden":"true",children:n.jsx(Be,{className:"h-5 w-3/4 max-w-xl rounded-none"})}),n.jsxs("div",{className:ce("relative flex min-h-0 flex-col",t&&"flex-1"),"aria-hidden":"true",children:[s?n.jsxs("div",{className:"z-10 flex flex-wrap justify-end gap-2 lg:absolute lg:top-0 lg:right-0",children:[n.jsx(Be,{className:"h-8 w-40 rounded-none"}),n.jsx(Be,{className:"h-8 w-36 rounded-none"})]}):null,n.jsxs("div",{className:ce("relative min-h-[420px]",t?"flex-1":"h-[70vh]"),children:[n.jsxs("div",{className:"absolute top-1/2 left-1/2 flex h-16 w-52 -translate-x-1/2 -translate-y-1/2 items-center gap-3 rounded-xl border border-border bg-card px-4",children:[n.jsx(Be,{className:"h-4 w-4 shrink-0 rounded-none"}),n.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[n.jsx(Be,{className:"h-3.5 w-24 rounded-none"}),n.jsx(Be,{className:"h-2.5 w-32 rounded-none"})]})]}),n.jsx("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:["in","out","fit"].map(r=>n.jsx("div",{className:"flex h-7 w-7 items-center justify-center border border-input bg-background",children:n.jsx(Be,{className:"h-3 w-3 rounded-none"})},r))})]})]})]})}function pt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var zt={exports:{}},xn;function Po(){return xn||(xn=1,(function(e,t){(function(s){e.exports=s()})(function(){return(function(){function s(r,o,c){function a(i,g){if(!o[i]){if(!r[i]){var p=typeof pt=="function"&&pt;if(!g&&p)return p(i,!0);if(l)return l(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var m=o[i]={exports:{}};r[i][0].call(m.exports,function(v){var N=r[i][1][v];return a(N||v)},m,m.exports,s,r,o,c)}return o[i].exports}for(var l=typeof pt=="function"&&pt,h=0;h<c.length;h++)a(c[h]);return a}return s})()({1:[function(s,r,o){Object.defineProperty(o,"__esModule",{value:!0}),o.default=void 0;function c(f){"@babel/helpers - typeof";return c=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},c(f)}function a(f,m){if(!(f instanceof m))throw new TypeError("Cannot call a class as a function")}function l(f,m){for(var v=0;v<m.length;v++){var N=m[v];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(f,i(N.key),N)}}function h(f,m,v){return m&&l(f.prototype,m),Object.defineProperty(f,"prototype",{writable:!1}),f}function i(f){var m=g(f,"string");return c(m)=="symbol"?m:m+""}function g(f,m){if(c(f)!="object"||!f)return f;var v=f[Symbol.toPrimitive];if(v!==void 0){var N=v.call(f,m);if(c(N)!="object")return N;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}o.default=(function(){function f(){var m=this,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},N=v.defaultLayoutOptions,d=N===void 0?{}:N,j=v.algorithms,S=j===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:j,E=v.workerFactory,k=v.workerUrl;if(a(this,f),this.defaultLayoutOptions=d,this.initialized=!1,typeof k>"u"&&typeof E>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var y=E;typeof k<"u"&&typeof E>"u"&&(y=function($){return new Worker($)});var x=y(k);if(typeof x.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new p(x),this.worker.postMessage({cmd:"register",algorithms:S}).then(function(T){return m.initialized=!0}).catch(console.err)}return h(f,[{key:"layout",value:function(v){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=N.layoutOptions,j=d===void 0?this.defaultLayoutOptions:d,S=N.logging,E=S===void 0?!1:S,k=N.measureExecutionTime,y=k===void 0?!1:k;return v?this.worker.postMessage({cmd:"layout",graph:v,layoutOptions:j,options:{logging:E,measureExecutionTime:y}}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker&&this.worker.terminate()}}])})();var p=(function(){function f(m){var v=this;if(a(this,f),m===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=m,this.worker.onmessage=function(N){setTimeout(function(){v.receive(v,N)},0)}}return h(f,[{key:"postMessage",value:function(v){var N=this.id||0;this.id=N+1,v.id=N;var d=this;return new Promise(function(j,S){d.resolvers[N]=function(E,k){E?(d.convertGwtStyleError(E),S(E)):j(k)},d.worker.postMessage(v)})}},{key:"receive",value:function(v,N){var d=N.data,j=v.resolvers[d.id];j&&(delete v.resolvers[d.id],d.error?j(d.error):j(null,d.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(v){if(v){var N=v.__java$exception;N&&(N.cause&&N.cause.backingJsObject&&(v.cause=N.cause.backingJsObject,this.convertGwtStyleError(v.cause)),delete v.__java$exception)}}}])})()},{}],2:[function(s,r,o){var c=s("./elk-api.js").default;Object.defineProperty(r.exports,"__esModule",{value:!0}),r.exports=c,c.default=c},{"./elk-api.js":1}]},{},[2])(2)})})(zt)),zt.exports}var Do=Po();const Fo=_s(Do);function zo(e){return new Worker("/assets/elk-worker.min-BENGc9gn.js",{name:e?.name})}const Wo=200,Bo=320,et=56,Ho=7.4,Vo=5.9,Uo=84,qo=48;function lt(e,t){return Math.round(Math.min(Bo,Math.max(Wo,Uo+e.length*Ho,qo+t.length*Vo)))}function Go(e,t){const s=[];return e>0&&s.push(`${e} ${e===1?"field":"fields"}`),typeof t=="number"&&s.push(`${t.toLocaleString()} ${t===1?"record":"records"}`),s.join(" · ")}function bn(e,t){return e.slug<t.slug?-1:e.slug>t.slug?1:0}function ls(e,t){const s=new Set;return e.filter(r=>r.status!=="active"||r.organization_slug&&r.organization_slug!==t||s.has(r.slug)?!1:(s.add(r.slug),!0))}function Yo(e){const t=e.metadata_schema;if(!t||typeof t!="object")return 0;const s=t.properties;return!s||typeof s!="object"?0:Object.keys(s).length}function ds(e){const{entityTypes:t,relationshipTypes:s,rulesBySlug:r}=e,o=e.ownerSlug??"",c=[...t].sort(bn),a=ls(s,o).sort(bn),l=y=>!y.organization_slug||y.organization_slug===o,h=y=>y.organization_slug||o,i=new Map;for(const y of c)i.set(y.slug,[...i.get(y.slug)??[],y]);const g=y=>(i.get(y.slug)?.length??0)>1?`${h(y)}:${y.slug}`:y.slug,p=new Set(c.filter(l).map(g)),f=y=>{const x=i.get(y)??[];return x.find(l)??(x.length===1?x[0]:void 0)},m=new Set(p),v=a.flatMap(y=>[...r[y.slug]??[]].sort((x,T)=>x.id-T.id).flatMap(x=>{const T=f(x.source_entity_type_slug),$=f(x.target_entity_type_slug);if(!T||!$)return[];const F=g(T),A=g($);return!p.has(F)&&!p.has(A)?[]:(m.add(F),m.add(A),[{rt:y,source:F,target:A}])})),N=c.filter(y=>m.has(g(y))),d=[],j=new Map,S=new Map;for(const{rt:y,source:x,target:T}of v){const $=`${y.slug}|${x}|${T}`,F=S.get($);if(F){F.ruleCount+=1;continue}const A={slug:y.slug,label:y.name||y.slug,ruleCount:1};S.set($,A);const K=`${x}|${T}`,H=j.get(K);if(H){H.data.relationships.push(A),H.data.isSymmetric=H.data.isSymmetric&&y.is_symmetric;continue}const se={id:`pair:${x}|${T}`,source:x,target:T,data:{relationships:[A],isSymmetric:y.is_symmetric}};j.set(K,se),d.push(se)}const E=new Map;for(const{rt:y,source:x,target:T}of v){const $=E.get(y.slug)??new Set;$.add(`${x}|${T}`),E.set(y.slug,$)}for(const{rt:y}of v)if(E.get(y.slug)?.size===1&&typeof y.relationship_count=="number")for(const x of S.values())x.slug===y.slug&&(x.linkCount=y.relationship_count);return{nodes:N.map(y=>{const x=y.name||y.slug,T=Yo(y),$=Go(T,y.entity_count);return{id:g(y),width:lt(x,$),height:et,data:{slug:y.slug,label:x,icon:y.icon,isSystem:Ms(y),organizationSlug:l(y)?void 0:h(y),metaLabel:$}}}),edges:d}}const He=24,Ko=72,Jo=16;let vn=null;function Qo(){return vn??=new Fo({workerFactory:()=>new zo}),vn}const Wt={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"24","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"48","elk.spacing.edgeEdge":"14","elk.spacing.edgeNode":"24","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.crossingMinimization.semiInteractive":"true"};async function Zt(e,{elk:t=Qo(),targetAspect:s}={}){const r=new Set;for(const d of e.edges)r.add(d.source),r.add(d.target);const o=e.nodes.some(d=>d.lane!==void 0),c=e.nodes.filter(d=>o||r.has(d.id)),a=e.nodes.filter(d=>!o&&!r.has(d.id)),l=a.reduce((d,j)=>Math.max(d,j.width),0),h=a.length>0?He+l+Ko:0,i=d=>({x:d.x+He+h,y:d.y+He});let g=[];const p=new Map;if(c.length>0){const d=e.edges.filter(y=>y.source!==y.target),j=y=>t.layout({id:"root",layoutOptions:o?{...y,"elk.partitioning.activate":"true"}:y,children:c.map(x=>({id:x.id,width:x.width,height:x.height,...o?{layoutOptions:{"elk.partitioning.partition":String(x.lane??1)}}:{}})),edges:d.map(x=>({id:x.id,sources:[x.layoutReversed?x.target:x.source],targets:[x.layoutReversed?x.source:x.target]}))});let S=await j(Wt);const E=s&&S.width&&S.height?s*S.width/S.height:1;if(E>1.08){const y=Number(Wt["elk.spacing.nodeNode"]),x=Math.min(E,2.2);S=await j({...Wt,"elk.spacing.nodeNode":String(Math.round(Math.min(180,y*x+et*(x-1))))})}const k=new Map((S.children??[]).map(y=>[y.id,y]));g=c.map(y=>{const x=k.get(y.id);return{...y,position:i({x:x?.x??0,y:x?.y??0})}});for(const y of S.edges??[]){const x=(y.sections??[]).flatMap($=>[$.startPoint,...$.bendPoints??[],$.endPoint]);if(x.length<2)continue;const T=e.edges.find($=>$.id===y.id)?.layoutReversed;p.set(y.id,(T?[...x].reverse():x).map(i))}}let f=He;const m=a.map(d=>{const j={x:He,y:f};return f+=d.height+Jo,{...d,position:j}}),v=new Map([...g,...m].map(d=>[d.id,d]));return{nodes:e.nodes.map(d=>v.get(d.id)??{...d,position:{x:He,y:He}}),edges:e.edges.map(d=>({...d,route:p.get(d.id)??null}))}}function Xo(e,t){return Zt(ds(e),t)}const Ut="connector:",wn=e=>`${Ut}${e}`,Zo={event:"Zap",schedule:"CalendarClock",manual:"Hand"},ea=0,ta=1,kn=2;function na(e,t){const s=new Map;for(const{kind:r,targets:o}of Qr(e?.feeds_schema?.[t]))for(const{entityType:c,creates:a}of o){const l=s.get(c)??{creates:!1,eventKinds:new Set};l.creates||=a,l.eventKinds.add(r),s.set(c,l)}return s}function sa(e,t){const s=new Map(e.connectorDefs.map(d=>[d.key,d])),r=new Map(e.connectorDefs.map(d=>[d.key,d.name])),o=new Map(e.connections.map(d=>[d.id,d])),c=Br(e.feeds),a=d=>`connection:${d}`,l=d=>`automation:${d}`,h=[],i=new Set,g=(d,j,S,E,k=!1)=>{h.push({id:`flow:${d}->${j}`,source:d,target:j,layoutReversed:k,data:{relationships:[],isSymmetric:!1,flow:{summary:S,details:E}}}),i.add(d),i.add(j)},p=new Set(e.connections.map(d=>d.id));for(const d of e.connections){const j=new Map;for(const S of c.get(d.id)??[]){const E=na(s.get(d.connector_key),S.feed_key);for(const[k,y]of E){const x=j.get(k)??{creates:!1,eventKinds:new Set};x.creates||=y.creates;for(const T of y.eventKinds)x.eventKinds.add(T);j.set(k,x)}}for(const[S,E]of j){const k=t.get(S);k&&g(a(d.id),k,E.creates?"creates records":"links records",[`From ${[...E.eventKinds].sort().join(", ")} events`])}}const f=Hr(e.automations);for(const[d,j]of f)if(p.has(d))for(const{automation:S,reason:E,eventTypes:k}of j){const y=l(S.automation_id);E==="trigger"?g(a(d),y,fn.trigger,k.length>0?[`On ${[...k].sort().join(", ")}`]:[]):g(y,a(d),fn.delivery,[],!0)}const m=[];for(const d of e.automations){const j=l(d.automation_id),S=d.entity_type?t.get(d.entity_type):void 0;S&&g(S,j,"anchored here",[d.entity_name?`On ${d.entity_name}`:""].filter(Boolean));const E=Yr(d,r,o),k=Kr(d),y=d.health==="degraded"?"Needs attention":void 0;m.push({id:j,lane:kn,width:lt(`${E.does} ${y??""}`,E.when),height:et,data:{slug:j,label:E.does,icon:k?wn(k):Zo[E.kind],isSystem:!1,badge:y,metaLabel:E.when,ref:{kind:"automation",automationId:d.automation_id}}})}const v=[];for(const d of e.metrics){const j=t.get(d.typeSlug);if(!j)continue;const S=`metric:${d.typeSlug}:${d.name}`;g(j,S,"measures",[d.description].filter(Boolean)),v.push({id:S,lane:kn,width:lt(d.name,d.agg),height:et,data:{slug:S,label:d.name,icon:"ChartColumn",isSystem:!1,metaLabel:d.agg,ref:{kind:"metric",typeSlug:d.typeSlug,name:d.name}}})}return{nodes:[...e.connections.filter(d=>i.has(a(d.id))).map(d=>{const j=Jr(d),S=Gr(d,s.get(d.connector_key)),E=Vr({feeds:c.get(d.id)?.length||d.feed_count,actions:d.operations_summary?.total??0,automations:f.get(d.id)?.length??0}),k=S.needsAttention?"Needs attention":d.device_label??void 0;return{id:a(d.id),lane:ea,width:lt(`${j} ${k??""}`,E),height:et,data:{slug:a(d.id),label:j,icon:wn(d.connector_key),isSystem:!1,badge:k,metaLabel:E,ref:{kind:"connection",connectorKey:d.connector_key,connectionId:d.id}}}}),...m,...v],edges:h}}function it(e){switch(e.data.ref?.kind){case"connection":return"connections";case"automation":return"automations";case"metric":return"metrics";default:return"entities"}}function ra(e,t){const s=new Map;for(const g of e.nodes)(!g.data.organizationSlug||!s.has(g.data.slug))&&s.set(g.data.slug,g.id);const r=sa(t,s),{layers:o}=t,c=[...r.nodes,...e.nodes.map(g=>({...g,lane:ta}))],a=new Set(c.filter(g=>o[it(g)]).map(g=>g.id)),l=[...e.edges,...r.edges].filter(g=>a.has(g.source)&&a.has(g.target)),h=new Set(l.flatMap(g=>[g.source,g.target]));return{graph:{nodes:c.filter(g=>a.has(g.id)&&(it(g)==="entities"||it(g)==="automations"||h.has(g.id))),edges:l},hidden:{connections:o.connections?t.connections.length-r.nodes.filter(g=>it(g)==="connections").length:0}}}const Nn="__new__";function Sn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function oa({entityTypes:e,initialSource:t="",initialTarget:s="",onDone:r}){const o=w.useId(),c=`${o}-relationship`,a=`${o}-name`,l=`${o}-symmetric`,h=`${o}-source`,i=`${o}-target`,{orgContext:g}=De(),{data:p=[]}=Kt(g),f=Ts(),m=Rs(),[v,N]=w.useState(""),[d,j]=w.useState(""),[S,E]=w.useState(!1),[k,y]=w.useState(t),[x,T]=w.useState(s),[$,F]=w.useState(null),A=v===Nn,K=p.filter(W=>W.status==="active"&&W.purpose!==Is&&(!W.organization_slug||W.organization_slug===g?.slug)),H=f.isPending||m.isPending,se=async()=>{if(F(null),!v)return F("Pick a relationship");if(!k||!x)return F("Pick both ends");try{let W=v;if(A){const ge=d.trim();if(!ge)return F("Name the relationship");const ne=Sn(ge);if(!ne)return F("Name must contain a letter or number");W=(await f.mutateAsync({slug:ne,name:ge,is_symmetric:S})).relationship_type.slug,N(W)}await m.mutateAsync({slug:W,source_entity_type_slug:k,target_entity_type_slug:x}),r()}catch(W){F(W instanceof Error?W.message:"Could not save")}};return n.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-3",children:[n.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:"Relationships are defined once for the workspace, then paired with the types they connect."}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ae,{htmlFor:c,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Relationship"}),n.jsxs($t,{value:v,onValueChange:N,children:[n.jsx(Ot,{id:c,className:"h-8 text-xs",children:n.jsx(At,{placeholder:"Pick or define one"})}),n.jsxs(Pt,{children:[K.map(W=>n.jsx(mt,{value:W.slug,children:W.name||W.slug},W.slug)),K.length>0?n.jsx(Ls,{}):null,n.jsx(mt,{value:Nn,children:"Define a new one…"})]})]})]}),A?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ae,{htmlFor:a,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Name"}),n.jsx(tt,{id:a,value:d,onChange:W=>j(W.target.value),placeholder:"works at",className:"h-8 text-xs"}),d.trim()?n.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Slug: ",n.jsx("code",{children:Sn(d)||"—"})]}):null]}),n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs(Ae,{htmlFor:l,className:"text-xs font-normal",children:["Symmetric",n.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:"Both ends mean the same thing, like “connected with”."})]}),n.jsx($s,{id:l,checked:S,onCheckedChange:E})]})]}):null,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ae,{htmlFor:h,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"From"}),n.jsxs($t,{value:k,onValueChange:y,children:[n.jsx(Ot,{id:h,className:"h-8 text-xs",children:n.jsx(At,{placeholder:"Type"})}),n.jsx(Pt,{children:e.map(W=>n.jsx(mt,{value:W.slug,children:W.label},W.slug))})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ae,{htmlFor:i,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"To"}),n.jsxs($t,{value:x,onValueChange:T,children:[n.jsx(Ot,{id:i,className:"h-8 text-xs",children:n.jsx(At,{placeholder:"Type"})}),n.jsx(Pt,{children:e.map(W=>n.jsx(mt,{value:W.slug,children:W.label},W.slug))})]})]}),$?n.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:$}):null,n.jsx(On,{onCancel:r,cancelDisabled:H,className:"[&>button]:h-7 [&>button]:px-3 [&>button]:text-xs",children:n.jsx(V,{type:"button",size:"sm",onClick:se,disabled:H,children:H?"Saving…":"Add relationship"})})]})}const us=288,aa=440,wt=240,kt=720,ia=320,en="lobu.schema-panel-width:v1";function Nt(e,t){if(!Number.isFinite(e))return us;const s=Math.max(wt,Math.min(kt,t-ia));return Math.round(Math.min(s,Math.max(wt,e)))}function ca(){const e=An(en);if(e===null)return null;const t=Number.parseInt(e,10);return!Number.isFinite(t)||t<wt||t>kt?null:t}function la(e){Pn(en,String(Math.round(e)))}function da(){Os(en)}const jn={nodes:[],edges:[]};function ua(e,t,s){const{orgContext:r}=De(),{data:o=[],isLoading:c,isError:a}=_t(r),{data:l=[],isLoading:h,isError:i}=Kt(r),g=w.useMemo(()=>ls(l,e),[l,e]),{data:p,isLoading:f,isError:m}=As(r),v=w.useMemo(()=>{const k=new Map(g.map(x=>[x.id,x.slug])),y={};for(const x of p??[]){const T=k.get(x.relationship_type_id);T&&(y[T]??=[]).push(x)}return y},[p,g]),N=w.useMemo(()=>({entityTypes:o,relationshipTypes:g,rulesBySlug:v,ownerSlug:e,targetAspect:t,flow:s}),[o,g,v,e,t,s]),[d,j]=w.useState(null),S=c||h||f,E=a||i||m;return w.useEffect(()=>{if(S||E)return;let k=!1;const y={targetAspect:N.targetAspect};let x,T;if(N.flow){const $=ra(ds(N),N.flow);x=$.hidden,T=Zt($.graph,y)}else T=Xo(N,y);return T.then($=>{k||j({graph:$,isError:!1,hidden:x})}).catch(()=>{k||j({graph:jn,isError:!0})}),()=>{k=!0}},[N,S,E]),{graph:d?.graph??jn,hidden:d?.hidden,isLoading:!E&&!d,isError:E||d?.isError===!0}}function En(e){const t=e.ruleCount>1?` ×${e.ruleCount}`:"",s=typeof e.linkCount=="number"?` · ${e.linkCount.toLocaleString()}`:"";return`${e.label}${t}${s}`}const qt={connections:"--chart-3",entities:"--chart-5",automations:"--chart-2",metrics:"--chart-4"};function ma(e,t){const s=e.nodes.some(a=>a.data.ref),r=new Map(e.nodes.map(a=>[a.id,a.data.label])),o=e.nodes.map(a=>({id:a.id,x:a.position.x+a.width/2,y:a.position.y+a.height/2,w:a.width,h:a.height,title:a.data.label,meta:a.data.metaLabel,icon:a.data.icon,badge:a.data.badge??a.data.organizationSlug,muted:a.data.isSystem,dimmed:t?!t.nodes.has(a.id):!1,accent:s?qt[it(a)]:void 0})),c=e.edges.map(a=>{const{relationships:l,isSymmetric:h,flow:i}=a.data;if(i)return{id:a.id,source:a.source,target:a.target,route:a.route??null,summary:i.summary,details:[i.summary,...i.details],directed:!0,dimmed:t?!t.edges.has(a.id):!1,ariaLabel:`${r.get(a.source)??a.source} to ${r.get(a.target)??a.target}: ${i.summary}`};const g=l.map(p=>p.label).join(", ");return{id:a.id,source:a.source,target:a.target,route:a.route??null,summary:l.length===1?En(l[0]):`${l.length} relationships`,details:l.map(En),directed:!h,dimmed:t?!t.edges.has(a.id):!1,ariaLabel:`${r.get(a.source)??a.source} ${h?"and":"to"} ${r.get(a.target)??a.target}: ${g}`}});return{boxes:o,edges:c}}const Cn=[{key:"connections",label:"Connections"},{key:"entities",label:"Entities"},{key:"automations",label:"Automations"},{key:"metrics",label:"Metrics"}],fa={count:"Count",count_distinct:"Distinct count",sum:"Sum",min:"Minimum",max:"Maximum"};function pa({metric:e,ownerSlug:t}){const s=(r,o)=>o.length>0?n.jsxs("section",{className:"flex flex-col gap-1.5",children:[n.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:r}),n.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:o.map(c=>n.jsxs("li",{children:[n.jsx("span",{className:"font-medium",children:c.name}),c.description?n.jsx("span",{className:"text-muted-foreground",children:` · ${c.description}`}):null]},c.name))})]}):null;return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"flex flex-col gap-1",children:[n.jsxs("p",{className:"text-sm",children:[fa[e.agg]??e.agg," of"," ",n.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:e.eventSet})," ","events, per ",e.typeLabel]}),e.description?n.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}):null]}),s("Data from",e.sources.map(r=>({name:r,description:""}))),s("Group by",e.dimensions),s("Segments",e.segments),n.jsx(V,{asChild:!0,variant:"outline",size:"sm",className:"self-start",children:n.jsxs(Pe,{to:"/$owner/$entityType",params:{owner:t,entityType:e.typeSlug},children:["Open ",e.typeLabel]})})]})}function ha({ownerSlug:e,metric:t,endpointOptions:s,canAuthor:r,mode:o,onModeChange:c}){const a=()=>c({kind:"index"});return o.kind==="metric"?t?n.jsx(pa,{metric:t,ownerSlug:e}):null:r?o.kind==="create-type"?n.jsx(Xr,{slug:null,onClose:a}):o.kind==="new-relationship"?n.jsx(oa,{entityTypes:s,initialSource:o.source,initialTarget:o.target,onDone:a},`${o.source??""}|${o.target??""}`):null:null}function ga(e){const{mode:t,canAuthor:s,onModeChange:r,isPeekOpen:o}=e,c=s&&t.kind==="create-type",a=t.kind==="metric"?t.name:s&&t.kind==="new-relationship"?"New relationship":c?"New entity type":"Schema",l=w.useRef(null),h=JSON.stringify(t),i=w.useRef(h);return w.useEffect(()=>{i.current!==h&&(i.current=h,l.current?.focus({preventScroll:!0}))},[h]),n.jsx("aside",{style:{"--schema-panel-width":`${e.width}px`},className:ce("order-first flex w-full shrink-0 flex-col lg:order-none lg:w-[var(--schema-panel-width)]",t.kind==="index"?"lg:absolute lg:top-0 lg:right-6 lg:z-10 lg:w-max lg:max-w-[calc(100%-3rem)] lg:max-h-[calc(100%-2rem)]":"bg-background lg:relative",o&&"lg:hidden"),children:n.jsxs("div",{className:ce("flex min-h-0 flex-1 flex-col",t.kind!=="index"&&"lg:absolute lg:inset-0"),children:[n.jsxs("div",{className:t.kind==="index"?"sr-only":"flex h-11 shrink-0 items-center gap-1 border-b border-border px-3",children:[n.jsx("h2",{ref:l,tabIndex:-1,className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground outline-none",children:a}),t.kind!=="index"?n.jsx(V,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Close",onClick:()=>r({kind:"index"}),children:n.jsx(Us,{className:"h-4 w-4"})}):null]}),n.jsx("div",{className:ce("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto",t.kind==="index"?"pb-1":"p-4"),children:n.jsx(ha,{...e})})]})})}function ms(e){const t=e.previousElementSibling,s=e.nextElementSibling;if(t instanceof HTMLElement&&s instanceof HTMLElement){const r=t.clientWidth+s.clientWidth;if(r>0)return r}return 0}function ya({width:e,maxWidth:t,onResize:s,onCommit:r,onReset:o,className:c}){const[a,l]=w.useState(!1),h=w.useRef(0),i=f=>{const m=ms(f);return m>0?m:f.parentElement?.clientWidth??0},g=f=>{if(f.button!==0)return;const m=f.currentTarget;if(!m.parentElement)return;f.preventDefault(),h.current=i(m);const N=f.clientX,d=e;l(!0),m.setPointerCapture(f.pointerId);const j=y=>Nt(d-(y-N),h.current);let S=d;const E=y=>{S=j(y.clientX),s(S)},k=y=>{m.removeEventListener("pointermove",E),m.removeEventListener("pointerup",k),m.removeEventListener("pointercancel",k),l(!1),r(y.type==="pointercancel"?S:j(y.clientX))};m.addEventListener("pointermove",E),m.addEventListener("pointerup",k),m.addEventListener("pointercancel",k)},p=f=>{const m=i(f.currentTarget),v=N=>{f.preventDefault(),r(Nt(e+N,m))};f.key==="ArrowLeft"?v(16):f.key==="ArrowRight"?v(-16):f.key==="Home"&&(f.preventDefault(),o())};return n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize schema panel","aria-valuenow":e,"aria-valuemin":wt,"aria-valuemax":t,tabIndex:0,onPointerDown:g,onKeyDown:p,onDoubleClick:o,className:ce("group hidden shrink-0 cursor-col-resize touch-none items-stretch justify-center px-1.5 outline-none lg:flex",a&&"cursor-col-resize",c),children:n.jsx("div",{className:ce("w-px rounded-full bg-border transition-[background-color,width] group-hover:w-0.5 group-hover:bg-primary/60 group-focus-visible:w-0.5 group-focus-visible:bg-primary",a&&"w-0.5 bg-primary")})})}function xa({ownerSlug:e}){const t=nt(),s=Jt(),r=s?.item!=null,{orgContext:o}=De(),{isAdmin:c}=Dn(o.organizationId),[a,l]=w.useState({connections:!0,entities:!0,automations:!0,metrics:!0}),[h,i]=w.useState({kind:"index"}),g=s?.close,p=w.useCallback(b=>{b.kind!=="index"&&r&&g?.(),i(b)},[r,g]),[f,m]=w.useState(),v=w.useRef(null),N=w.useCallback(b=>{if(v.current?.disconnect(),v.current=null,!b||typeof ResizeObserver>"u")return;const _=()=>{if(!b.clientWidth||!b.clientHeight)return;const z=Math.round(b.clientHeight/b.clientWidth*10)/10;m(P=>P===z?P:z)};_();const R=new ResizeObserver(_);R.observe(b),v.current=R},[]),d=o.organizationId,j=Ps(d),S=Ds(d),E=Fs(d),k=qr(d??void 0),{data:y}=_t(o),x=w.useMemo(()=>y?.filter(b=>zs(b,e)),[y,e]),T=w.useMemo(()=>(x??[]).flatMap(b=>Object.entries(b.metrics_config?.measures??{}).map(([_,R])=>({typeSlug:b.slug,name:_,agg:R.agg,description:R.description}))),[x]),$=j.isLoading||S.isLoading||E.isLoading||k.isLoading,F=w.useMemo(()=>$?null:{connections:j.data??[],feeds:S.data??[],connectorDefs:E.data??[],automations:k.data??[],metrics:T,layers:a},[$,j.data,S.data,E.data,k.data,T,a]),{graph:A,isLoading:K,isError:H,hidden:se}=ua(e,f,F),W=K||$,ge={connections:!$&&(j.data??[]).length===0,entities:!1,automations:!$&&(k.data??[]).length===0,metrics:!$&&T.length===0},ne=h.kind==="metric"?h:null,U=w.useMemo(()=>{if(!ne)return null;const b=`metric:${ne.typeSlug}:${ne.name}`,_=A.edges.find(P=>P.target===b);if(!_)return null;const R=_.source,z=A.edges.filter(P=>P.target===R&&A.nodes.find(O=>O.id===P.source)?.data.ref?.kind==="connection");return{typeId:R,nodes:new Set([b,R,...z.map(P=>P.source)]),edges:new Set([_.id,...z.map(P=>P.id)]),sources:z.map(P=>A.nodes.find(O=>O.id===P.source)?.data.label??P.source)}},[ne,A]),{boxes:Ce,edges:ue}=w.useMemo(()=>ma(A,U),[A,U]),Q=w.useMemo(()=>{if(!ne)return null;const b=x?.find(z=>z.slug===ne.typeSlug),_=b?.metrics_config,R=_?.measures?.[ne.name];return!b||!R?null:{name:ne.name,typeSlug:b.slug,typeLabel:b.name||b.slug,agg:R.agg,eventSet:R.eventSet,description:R.description,dimensions:Object.entries(_?.dimensions??{}).map(([z,P])=>({name:z,description:P.description})),segments:Object.entries(_?.segments??{}).map(([z,P])=>({name:z,description:P.description})),sources:U?.sources??[]}},[ne,x,U]),ee=w.useMemo(()=>new Map(A.nodes.map(b=>[b.id,b.data.slug])),[A.nodes]),me=w.useMemo(()=>new Map(A.nodes.flatMap(b=>b.data.ref?[[b.id,b.data.ref]]:[])),[A.nodes]),{data:_e=[]}=Ws(o.organizationId),Ue=w.useMemo(()=>{const b=new Map;for(const _ of A.nodes)_.data.ref||(!_.data.organizationSlug||!b.has(_.data.slug))&&b.set(_.data.slug,{slug:_.data.slug,label:_.data.label});return[...b.values()]},[A.nodes]),oe=w.useCallback(b=>{const _=me.get(b);if(_?.kind==="connection"){t({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:_.connectorKey,connectionId:String(_.connectionId)},search:{}});return}if(_?.kind==="metric"){p({kind:"metric",typeSlug:_.typeSlug,name:_.name});return}if(_?.kind==="automation"){t({to:"/$owner/automations/$automationId",params:{owner:e,automationId:_.automationId},search:{view:"activity",run_id:void 0}});return}t(Fn(e,ee.get(b)??b))},[t,e,ee,me,p]),ve=w.useCallback((b,_)=>{me.has(b)||me.has(_)||p({kind:"new-relationship",source:ee.get(b)??b,target:ee.get(_)??_})},[ee,me,p]),Fe=A.nodes.some(b=>!b.data.ref&&!b.data.isSystem&&!b.data.organizationSlug),Me=A.nodes.some(b=>b.data.ref),Te="size-6 text-muted-foreground hover:text-foreground",we={connections:n.jsx(Ur,{ownerSlug:e,catalog:_e,trigger:n.jsx(V,{type:"button",variant:"ghost",size:"icon",className:Te,"aria-label":"New connector",title:"New connector",children:n.jsx(ct,{className:"size-3.5"})})}),entities:n.jsx(V,{type:"button",variant:"ghost",size:"icon",className:Te,"aria-label":"Create entity type",title:"Create entity type",onClick:()=>p({kind:"create-type"}),children:n.jsx(ct,{className:"size-3.5"})}),automations:n.jsx(V,{asChild:!0,variant:"ghost",size:"icon",className:Te,children:n.jsx(Pe,{to:"/$owner/automations/new",params:{owner:e},"aria-label":"New Automation",title:"New Automation",children:n.jsx(ct,{className:"size-3.5"})})})},ze=w.useCallback(b=>{const _=b.startsWith(Ut)?b.slice(Ut.length):null;if(!_)return n.jsx(Ct,{icon:b||null,className:"h-4 w-4"});const R=Bs(_,E.data??[],{name:j.data?.find(z=>z.connector_key===_)?.connector_name??_});return n.jsx(Hs,{plain:!0,icon:R.icon,iconUrl:R.iconUrl,name:R.name,faviconDomain:R.faviconDomain})},[E.data,j.data]),fe=c&&h.kind==="create-type",ke=h.kind==="metric"||c&&h.kind!=="index",[ye,Ne]=w.useState(()=>ca()),le=ye??(fe?aa:us),[Re,Se]=w.useState(null),xe=w.useRef(null),qe=w.useCallback(b=>{if(xe.current?.disconnect(),xe.current=null,!b||typeof ResizeObserver>"u")return;const _=b.children[1];if(!_)return;const R=()=>{const P=ms(_);P>0&&Se(O=>O===P?O:P)};R();const z=new ResizeObserver(R);z.observe(b),xe.current=z},[]),Ie=Re===null?le:Nt(le,Re),C=Re===null?kt:Nt(kt,Re),u=w.useCallback(b=>{Ne(b),la(b)},[]),M=w.useCallback(()=>{Ne(null),da()},[]);return W?n.jsx(Xt,{label:"Loading workspace schema",fill:!0,schemaActions:c}):H?n.jsx(zn,{label:"workspace schema"}):n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[n.jsxs("div",{className:ce("flex flex-wrap items-center justify-between gap-3",ke&&"hidden lg:flex"),children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:Me?`Where records come from, the types they land in, and what uses them. Click a box to open it${c?", or drag a type's ⊕ onto another to relate them":""}. Only stored links are drawn${se?.connections?`; ${se.connections} connections have none yet`:""}.`:Fe?A.edges.length>0?`Your workspace schema. Hover a type or select a line to name its relationships, click a type to open it${c?", or drag its ⊕ to relate types.":"."}`:"Your workspace schema. Click a type to open it — relationships appear here once you add one to a type.":c?"Member is already here: everyone in this workspace. Create the first type of record you track — a company, a deal, a ticket — then drag its ⊕ onto Member to relate them.":"Member is already here: everyone in this workspace. An admin can add the types of record this workspace tracks."}),n.jsxs("fieldset",{className:"m-0 flex min-w-0 shrink-0 flex-wrap items-center gap-x-4 gap-y-1 border-0 p-0 text-sm",children:[n.jsx("legend",{className:"sr-only",children:"Show on the map"}),Cn.map(({key:b,label:_})=>{const R=`memory-map-show-${b}`,z=a[b]&&!ge[b]&&Cn.filter(({key:P})=>a[P]&&!ge[P]).length===1;return n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Vs,{id:R,checked:a[b],disabled:z,style:{borderColor:`var(${qt[b]})`,backgroundColor:a[b]?`var(${qt[b]})`:void 0},onCheckedChange:P=>l(O=>({...O,[b]:P===!0}))}),n.jsx("label",{htmlFor:R,className:"inline-flex cursor-pointer select-none items-center",children:_}),c?we[b]:null]},b)})]})]}),n.jsxs("div",{ref:qe,className:"relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 lg:-mr-6 lg:-mb-8 lg:flex-row lg:gap-0",children:[n.jsx("div",{className:ce("flex min-w-0 flex-1 flex-col lg:pb-8",ke&&"hidden lg:flex"),children:n.jsx("div",{ref:N,className:"min-h-[420px] min-w-0 flex-1 overflow-hidden rounded-lg bg-background",children:n.jsx(cs,{boxes:Ce,edges:ue,label:"Workspace schema",onOpenBox:oe,openLabel:b=>`Open ${b.title}`,onConnect:c?ve:void 0,renderIcon:ze})})}),n.jsx(ya,{width:Ie,maxWidth:C,onResize:Ne,onCommit:u,onReset:M,className:r||h.kind==="index"?"lg:hidden":void 0}),n.jsx(ga,{width:Ie,metric:Q,ownerSlug:e,endpointOptions:Ue,canAuthor:c,mode:h,onModeChange:p,isPeekOpen:r})]})]})}function ba({onClose:e,entityTypeSlug:t,orgContext:s,onSuccess:r}){const{data:o,isLoading:c}=Wn(t,s),a=`${s.organizationId??s.slug}:${t}`,l=qs(a,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},o?.metadata_schema),[h,i]=l.field("name"),[g,p]=l.field("customSlug"),[f,m]=l.field("useCustomSlug"),[v,N]=l.field("metadata"),[d,j]=Gs(a,null),S=Ys(),E=f?g:Ks(h),k=async F=>{if(F.preventDefault(),!l.canSubmit)return;if(j(null),!h.trim()){j("Name is required");return}const A=eo(v),K={entityType:t,name:h.trim(),slug:f?g:void 0,metadata:Object.keys(A).length>0?A:void 0};try{const H=await S.mutateAsync(K);if(e(),H.approval_queued||!H.entity){Bn.info("Create queued for approval");return}typeof H.entity.id=="number"&&r?.(H.entity.id)}catch(H){j(H instanceof Error?H.message:"Failed to create entity")}},y=o?.name||t,x=l.revision,T=`Create ${y}`,$=`Add a new ${y.toLowerCase()} to your workspace.`;return c?n.jsx(Js,{rows:6}):n.jsxs("form",{onSubmit:k,children:[n.jsx(Qs,{visible:l.hasConflict,onReload:l.reset}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:T}),n.jsx("p",{className:"text-sm text-muted-foreground",children:$})]}),n.jsxs("div",{className:"grid gap-4 py-4",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsxs(Ae,{htmlFor:"name",children:["Name ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsx(tt,{id:"name",value:h,onChange:F=>i(F.target.value),placeholder:`Enter ${y.toLowerCase()} name`,autoFocus:!0})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Ae,{htmlFor:"slug",children:"URL Slug"}),n.jsx("button",{type:"button",onClick:()=>m(!f),className:"text-xs text-muted-foreground hover:text-foreground",children:f?"Auto-generate":"Customize"})]}),f?n.jsx(tt,{id:"slug",value:g,onChange:F=>p(F.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):n.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:E||"slug-preview"})]}),x&&Object.keys(x).length>0?n.jsxs(n.Fragment,{children:[n.jsx(to,{className:"my-2"}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(Ae,{className:"text-sm font-medium",children:"Additional Fields"}),n.jsx(Zr,{schema:l.revision,values:v,onValuesChange:N,orgContext:s})]})]}):null,d&&n.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:d})]}),n.jsx(On,{onCancel:e,cancelDisabled:S.isPending,className:"mt-2",children:n.jsx(V,{type:"submit",disabled:!l.canSubmit||S.isPending||!h.trim(),children:S.isPending?"Creating...":`Create ${y}`})})]})}function va(e){const t=e?.properties??{},s=tr(e);return Object.entries(t).flatMap(([r,o])=>{const c=s.find(p=>p.field===r);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(r)||!o||o.const!==void 0||o["x-table-column"]!==!0&&o["x-facet"]!==!0&&!c)return[];const a=[o,...Array.isArray(o.anyOf)?o.anyOf:[]],l=c?.options??[],h=l.find(p=>p.value!==null)?.value,i=a.find(p=>["string","number","integer","boolean"].includes(String(p.type)))??(h===void 0?void 0:{type:typeof h});if(!i)return[];const g=o.format==="date-time"||i.format==="date-time"?"datetime-local":o.format==="date"||i.format==="date"?"date":i.type==="number"||i.type==="integer"?"number":i.type==="boolean"?"boolean":"string";return[{field:r,label:String(o["x-table-label"]??o.title??r.replaceAll("_"," ")),type:g,options:g==="boolean"&&!l.some(p=>typeof p.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...l]:l}]})}function wa(e){const t=e?.[Ht];return t===void 0?{}:Qt(t)}function ka(e,t,s){try{const r=wa(t),o=e[Hn],c=o===void 0?void 0:r.presets?.find(g=>g.key===o);if(o!==void 0&&!c)throw new Error("This saved filter is unavailable. Choose another filter.");if(c&&!s&&typeof e.segment=="string"&&e.segment)throw new Error("A saved filter and an explicit selection cannot be combined.");const a=c&&e[Ze]===void 0?{collection:xt(c)}:Xs(e,s);if(a.error)throw a.error;const l=e[Zs],h=l===void 0?c?.table??r.table??{}:Qt({table:typeof l=="string"?JSON.parse(l):l}).table??{},i=!!c&&(_n(a.collection)!==_n(xt(c))||St(h)!==St(c.table??r.table??{}));return{...a,presentation:r,preset:c,table:h,edited:i}}catch(r){return{collection:{},presentation:{},table:{},edited:!1,error:r instanceof Error?r:new Error("Invalid collection configuration")}}}function _n(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(gt)])}function gt(e){return JSON.stringify([e.field,e.op,e.value])}function St(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function Na(e,t){return t?{[Hn]:t,[Ze]:Bt(e)[Ze]??"{}"}:Bt(e)}function Sa(e,t,s,r,o=new Date){let c=t.filters??[],a=e.relativeDate;if(a){const l=(xt({...e,selection:{}},o).filters??[]).map(gt),h=c.map(gt);l.every(i=>h.includes(i))?c=c.filter(i=>!l.includes(gt(i))):a=void 0}return{key:e.key,label:e.label,selection:{...t.search?{search:t.search}:{},...c.length?{filters:c}:{},...t.segment?{segment:t.segment}:{}},...St(s)!==St(r.table??{})?{table:s}:{},...a?{relativeDate:a}:{}}}function ja(e,t,s){const r=[...e.filters??[]],o=s??(t.length===1&&t[0].op==="eq"?r.findIndex(a=>a.field===t[0].field&&a.op==="eq"):-1),c=o>=0?[...r.slice(0,o),...t,...r.slice(o+1)]:[...r,...t];return{...e,filters:nr({filters:c}).filters}}function Ea(e,t){return{...e,filters:e.filters?.filter((s,r)=>r!==t)}}function Ca(e,t){return{...typeof e.$preset=="string"?e[Ze]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[Ze]:String(er(e[Ze]))}:Bt(t),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const _a=[{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 Ma(e){return e.sort&&_a.some(t=>t.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function Ta(e,t,s,r,o){const c={...r,filters:r.filters?.filter(a=>a.field!==s)};return Vn({queryKey:["collection-facets",e,t,s,c],enabled:!!t&&!!s,staleTime:3e4,retry:!1,queryFn:async({signal:a})=>{const l=await bt("query_sdk",{title:`Value counts query for ${s}`,script:`const input = ${JSON.stringify({field:s,collection:c})};
|
|
2
|
-
${t}`},e,{signal:a}),h=l.return_value;if(!l.success||typeof h?.connection!="string"||typeof h.sql!="string")throw new Error(l.error?.message??"Value distribution is unavailable");if(a.aborted)throw new DOMException("Aborted","AbortError");const i=await bt("query_sql",{title:`Value counts for ${s}`,connection:h.connection,sql:h.sql,limit:51},e,{signal:a});if(i.error)throw new Error(i.error);if(!Array.isArray(i.rows))throw new Error("Source did not return value counts");const g=i.rows.map(p=>{const f=p,m=typeof f.count=="string"&&/^\d+$/.test(f.count)?Number(f.count):f.count;if(!(f.value===null||["string","number","boolean"].includes(typeof f.value))||typeof m!="number"||!Number.isSafeInteger(m)||m<0)throw new Error("Source returned an invalid value distribution");return{value:f.value,count:m}});return{values:g.slice(0,50),truncated:g.length>50||i.truncated===!0}}})}const Ra=300;function Ia({label:e,search:t,onSearch:s,className:r}){const o=t??"",[c,a]=w.useState(o),l=w.useRef({search:t,onSearch:s});l.current={search:t,onSearch:s};const h=w.useRef(void 0);w.useEffect(()=>{const g=()=>{clearTimeout(h.current),a(l.current.search??"")};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[]);const i=w.useRef(o);return w.useEffect(()=>{o!==i.current&&(i.current=o,a(o))},[o]),w.useEffect(()=>{if(c===(l.current.search??""))return;const g=setTimeout(()=>{const p=l.current.onSearch;i.current=c,p(c||void 0,!0)},Ra);return h.current=g,()=>clearTimeout(g)},[c]),n.jsxs("div",{className:`relative${r?` ${r}`:""}`,children:[n.jsx(rr,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(tt,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:c,onChange:g=>a(g.target.value),className:"pl-9"})]})}const La={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function $a({field:e,initial:t,org:s,facetQuery:r,collection:o,onApply:c,close:a}){const[l,h]=w.useState(t?.op??"eq"),[i,g]=w.useState(t?.value==null?"":String(t.value)),[p,f]=w.useState(""),[m,v]=w.useState(!1),[N,d]=w.useState(),j=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",S=Ta(s,r,e.field,o),E=x=>{try{const T=m?[{field:e.field,op:"gte",value:e.type==="number"?Number(i):i},{field:e.field,op:"lte",value:e.type==="number"?Number(p):p}]:[{field:e.field,op:l,value:x}];if(e.type==="datetime-local")for(const A of T)typeof A.value=="string"&&(A.value=new Date(A.value).toISOString());if(T.some(A=>typeof A.value=="number"&&!Number.isFinite(A.value)))throw new Error("Enter a valid number.");const $=T[0].value,F=T[1]?.value;if(m&&$!=null&&F!=null&&$>F)throw new Error("The lower bound must be before the upper bound.");c(T),a()}catch(T){d(T instanceof Error?T.message:"Could not apply filter")}},k=[...e.options];for(const x of S.data?.values??[])k.some(T=>T.value===x.value)||k.push({value:x.value,label:x.value===null?"Not supplied":String(x.value)});const y=Math.max(1,...S.data?.values.map(x=>x.count)??[]);return n.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[n.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:m?"range":l,onChange:x=>{v(x.target.value==="range"),x.target.value!=="range"&&h(x.target.value)},children:[n.jsx("option",{value:"eq",children:"is"}),n.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&n.jsxs(n.Fragment,{children:[n.jsx("option",{value:"lt",children:"less than / before"}),n.jsx("option",{value:"lte",children:"at most / on or before"}),n.jsx("option",{value:"gt",children:"greater than / after"}),n.jsx("option",{value:"gte",children:"at least / on or after"}),t?null:n.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&n.jsxs("form",{className:"space-y-2",onSubmit:x=>{x.preventDefault(),E(e.type==="number"?Number(i):i)},children:[n.jsx(tt,{required:!0,"aria-label":m?"From value":"Filter value",type:j,step:e.type==="number"?"any":void 0,value:i,onChange:x=>g(x.target.value),placeholder:"Enter a value…"}),m&&n.jsx(tt,{required:!0,"aria-label":"To value",type:j,step:e.type==="number"?"any":void 0,value:p,onChange:x=>f(x.target.value)}),n.jsx(V,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!m&&(l==="eq"||l==="neq")&&n.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:k.filter(x=>!i||x.label.toLowerCase().includes(i.toLowerCase())).map(x=>{const T=S.data?.values.find($=>$.value===x.value)?.count;return n.jsxs("button",{type:"button","aria-label":x.label,onClick:()=>E(x.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:[T!==void 0&&n.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${T/y*100}%`}}),n.jsx("span",{className:"relative truncate",children:x.label}),n.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:T?.toLocaleString()})]},JSON.stringify(x.value))})}),r&&S.isFetching&&n.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),S.isError&&n.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),S.data?.truncated&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),N&&n.jsx("p",{role:"alert",className:"text-xs text-destructive",children:N})]})}function Oa({collection:e,schema:t,label:s,onChange:r,org:o,facetQuery:c,segmentChip:a,viewFilters:l,onClearAll:h}){const i=va(t),g=(v,N)=>({kind:"custom",className:"w-80",render:d=>n.jsx($a,{field:v,initial:N==null?void 0:e.filters?.[N],org:o,facetQuery:c,collection:e,onApply:j=>r(ja(e,j,N)),close:d})}),p=i.map(v=>({key:v.field,label:v.label,icon:n.jsx(sr,{className:"h-4 w-4"}),editor:g(v)})),f=new Map,m=(e.filters??[]).map((v,N)=>{const d=`${v.field}:${v.op}:${JSON.stringify(v.value)}`,j=f.get(d)??0;f.set(d,j+1);const S=i.find(k=>k.field===v.field),E=S?.options.find(k=>k.value===v.value)?.label??String(v.value??"Not supplied");return{id:`${d}:${j}`,label:S?.label??v.field,op:La[v.op],value:E,editor:S?g(S,N):void 0,onRemove:()=>r(Ea(e,N))}});if(a&&m.unshift(a),l?.fields.length){for(const v of p)v.group=s;p.push(...l.fields),m.push(...l.chips)}return!p.length&&!m.length?null:n.jsx(ao,{label:`${s} filters`,fields:p,chips:m,onClearAll:h??(()=>r({...e,filters:[],segment:void 0}))})}const jt=120,Ee=12;function Mn(e,t){return typeof e.linkId=="number"&&typeof t.linkId=="number"?e.linkId-t.linkId:String(e.linkId).localeCompare(String(t.linkId))}function Aa(e){const t=e.records.slice(0,jt),s=i=>e.types.get(i)??{label:i},r=new Map;for(const i of t)r.set(String(i.id),{source:i.source,entityType:e.typeSlug,slug:i.slug,name:i.name,isFocus:!0,hasMoreLinks:!1});const o=new Map;for(const i of e.links){if(!r.has(String(i.recordId)))continue;const g=o.get(i.recordId)??new Map;g.set(i.linkId,i),o.set(i.recordId,g)}const c=new Map;for(const[i,g]of o){const p=[...g.values()].sort(Mn),f=r.get(String(i));f&&p.length>Ee&&(f.hasMoreLinks=!0);for(const m of p.slice(0,Ee)){c.set(m.linkId,m);const v=String(m.peer.id);r.has(v)||r.set(v,{source:m.peer.source,...m.peer.remote?{remote:m.peer.remote}:{},entityType:m.peer.type,slug:m.peer.slug,name:m.peer.name,isFocus:!1,hasMoreLinks:!1})}}const a=[];for(const[i,g]of r){const p=g.remote?{label:g.entityType}:s(g.entityType),f=g.name||g.slug,m=g.hasMoreLinks?`${p.label} · ${Ee}+ links`:p.label;a.push({id:i,data:{slug:g.slug,label:f,icon:p.icon,isSystem:!1,metaLabel:m},width:lt(f,m),height:et})}const l=new Map;for(const i of[...c.values()].sort(Mn)){const g=String(i.fromId),p=String(i.toId),f=JSON.stringify([g,p]),m=l.get(f)??{source:g,target:p,rels:new Map,symmetric:!0};m.symmetric&&=i.isSymmetric,m.rels.has(i.relSlug)||m.rels.set(i.relSlug,{slug:i.relSlug,label:i.relName,ruleCount:1}),l.set(f,m)}const h=[...l.entries()].map(([i,g])=>({id:`link:${i}`,source:g.source,target:g.target,data:{relationships:[...g.rels.values()],isSymmetric:g.symmetric}}));return{nodes:a,edges:h,records:r,hasMoreRecords:e.hasMore===!0||e.records.length>jt,listedCount:t.length,focusCount:t.length}}async function Pa(e,t){const s=Aa(e);return{...await Zt({nodes:s.nodes,edges:s.edges},t),records:s.records,hasMoreRecords:s.hasMoreRecords,listedCount:s.listedCount,focusCount:s.focusCount}}const Da=8,Fa=3,za=4;function yt(e){return`source:${JSON.stringify([e.type,e.key])}`}function Wa(e,t){return t.map(s=>{const r={type:e,key:s.slug};return{...s,id:yt(r),source:r}})}function Tn(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function Ba(e,t,s){const r=e.slice(0,Da),o=[];let c=0;return await Promise.all(Array.from({length:Math.min(Fa,r.length)},async()=>{for(;c<r.length;){const a=c++,l=r[a];try{if(s?.aborted)throw s.reason;const h=await t(l),i=new Map(l.links.map(d=>[Tn(d),d]));for(const d of h.record_links){const j=Tn(d),S=i.get(j);(!S||S.occurred_at<d.occurred_at)&&i.set(j,d)}const g=new Map((l.relationships??[]).map(d=>[d.id,d]));for(const d of h.relationships??[])g.set(d.id,d);const p=[...g.values()].slice(0,Ee+1),f=[...i.values()].slice(0,Ee+1),m=(l.pagesRead??0)+1,v=!!h.next_cursor&&m>=za,N=h.record_failures.length>0||!!h.relationship_failures?.length||v;o[a]={read:{record:l.record,links:f,failed:N,entityId:l.entityId,relationships:p},...!v&&(N||h.next_cursor&&f.length+p.length<=Ee)?{next:{record:l.record,entityId:l.entityId,relationships:p,pagesRead:m,cursor:h.next_cursor??l.cursor,links:f}}:{}}}catch(h){if(s?.aborted)throw h;o[a]={read:{record:l.record,links:l.links,failed:!0,entityId:l.entityId,relationships:l.relationships},next:{...l,cursor:h instanceof or&&h.status===400?null:l.cursor}}}}})),{reads:o.map(a=>a.read),pending:[...o.flatMap(a=>a.next?[a.next]:[]),...e.slice(r.length)]}}function Ha(e,t){const s=new Map;for(const c of e)for(const a of c.reads)s.set(String(a.entityId??yt(a.record)),a);const r=new Map(t.map(c=>[c.slug,c])),o=[];for(const[c,a]of s){for(const l of a.relationships??[]){const h=(d,j,S)=>S?`remote:${S}`:typeof d=="number"?d:yt({type:j,key:d}),i=h(l.from_entity_id,l.from_entity_type,l.from_entity_url),g=h(l.to_entity_id,l.to_entity_type,l.to_entity_url),p=String(i)===c,f=p?g:i,m=p?l.to_entity_id:l.from_entity_id,v=p?l.to_entity_url:l.from_entity_url,N=(p?l.to_entity_type:l.from_entity_type)??"";o.push({recordId:c,linkId:l.id,fromId:i,toId:g,relSlug:l.relationship_type_slug,relName:l.relationship_type_name,isSymmetric:l.is_symmetric,peer:{id:f,name:(p?l.to_entity_name:l.from_entity_name)??String(m),slug:(p?l.to_entity_slug:l.from_entity_slug)??String(m),type:N,...v?{remote:{url:ar(v)}}:typeof m=="string"?{source:{type:N,key:m}}:{}}})}for(const l of a.links){const h={type:l.entity_type,key:l.key},i=yt(h),g=r.get(l.relationship_type);let p=l.direction==="incoming"?i:c,f=l.direction==="incoming"?c:i;g?.is_symmetric&&p>f&&([p,f]=[f,p]),o.push({recordId:c,linkId:JSON.stringify([p,f,l.relationship_type]),fromId:p,toId:f,relSlug:l.relationship_type,relName:g?.name||l.relationship_type.replaceAll("_"," "),isSymmetric:g?.is_symmetric??!1,peer:{id:i,name:l.name||l.key,slug:l.key,type:l.entity_type,source:h}})}}return{links:o,checked:s.size,failed:[...s.values()].filter(c=>c.failed).length}}function Va(e,t,s,r,o,c=!1){const{orgContext:a}=De(),l=_t(a),h=Kt(a),i=w.useMemo(()=>c?Wa(t,s):s,[c,t,s]),g=w.useMemo(()=>i.slice(0,jt).flatMap(k=>k.source?[{record:k.source,cursor:null,links:[]}]:typeof k.id=="number"?[{entityId:k.id,record:{type:t,key:k.slug},cursor:null,links:[]}]:[]),[i,t]),p=ir({queryKey:["source-records-graph",a.organizationId,e,t,g.map(k=>[k.record,k.entityId])],enabled:!0,initialPageParam:g,queryFn:({pageParam:k,signal:y})=>Ba(k,async x=>{const T=await bt("manage_entity",{action:"list_links",...x.entityId===void 0?{record:x.record,cursor:x.cursor}:{entity_id:x.entityId,offset:Number(x.cursor??0)},limit:Ee+1},e,{signal:y});return{...T,record_links:T.record_links??[],record_failures:T.record_failures??[],next_cursor:x.entityId===void 0?T.next_cursor:T.metadata?.has_more?String(Number(x.cursor??0)+Ee+1):null}},y),getNextPageParam:k=>k.pending.length?k.pending:void 0,staleTime:3e4,retry:!1}),f=w.useMemo(()=>p.data?Ha(p.data.pages,h.data??[]):void 0,[p.data,h.data]),m=f?.links,v=p.isError,N=JSON.stringify([a.organizationId,e,t,c,i.map(k=>[k.id,k.name,k.slug]),r]),d=w.useMemo(()=>new Map((l.data??[]).map(k=>[k.slug,{label:k.name||k.slug,icon:k.icon}])),[l.data]),[j,S]=w.useState(null);w.useEffect(()=>{if(!m)return;let k=!1;return Pa({typeSlug:t,records:i,hasMore:r,links:m,types:d},{targetAspect:o}).then(y=>{k||S({graph:y,key:N,isError:!1})}).catch(()=>{k||S({graph:null,key:N,isError:!0})}),()=>{k=!0}},[m,t,i,r,d,o,N]);const E=j?.key===N?j:null;return{graph:E?.graph??null,isLoading:!v&&!E,isError:v||E?.isError===!0,sourceProgress:{checked:f?.checked??0,total:Math.min(s.length,jt),failed:f?.failed??0,hasMore:!!p.hasNextPage,isFetching:p.isFetching,loadMore:()=>{p.isFetching||p.fetchNextPage()}}}}function Ua(e){const t=new Map(e.nodes.map(o=>[o.id,o.data.label])),s=e.nodes.map(o=>({id:o.id,x:o.position.x+o.width/2,y:o.position.y+o.height/2,w:o.width,h:o.height,title:o.data.label,meta:o.data.metaLabel,icon:o.data.icon,muted:e.records.get(o.id)?.isFocus===!1})),r=e.edges.map(o=>{const{relationships:c,isSymmetric:a}=o.data,l=c.map(h=>h.label);return{id:o.id,source:o.source,target:o.target,route:o.route??null,summary:l.length===1?l[0]:`${l.length} relationships`,details:l,directed:!a,ariaLabel:`${t.get(o.source)??o.source} ${a?"and":"to"} ${t.get(o.target)??o.target}: ${l.join(", ")}`}});return{boxes:s,edges:r}}function qa({ownerSlug:e,typeSlug:t,records:s,hasMore:r,sourceBacked:o=!1}){const c=nt(),a=Jt(),{orgContext:l}=De(),{data:h=[]}=_t(l),i=h.find(y=>y.slug===t)?.name??t,[g,p]=w.useState(),f=w.useRef(null),m=w.useCallback(y=>{if(f.current?.disconnect(),f.current=null,!y||typeof ResizeObserver>"u")return;const x=()=>{if(!y.clientWidth||!y.clientHeight)return;const $=Math.round(y.clientHeight/y.clientWidth*10)/10;p(F=>F===$?F:$)};x();const T=new ResizeObserver(x);T.observe(y),f.current=T},[]),{graph:v,isLoading:N,isError:d,sourceProgress:j}=Va(e,t,s,r,g,o),S=w.useMemo(()=>v?Ua(v):null,[v]),E=w.useCallback(y=>{const x=v?.records.get(y);if(x){if(x.remote){x.remote.url&&window.open(x.remote.url,"_blank","noopener,noreferrer");return}if(a){a.open(io({...x.source?{record:x.source}:{entityId:Number(y)},ownerSlug:e,orgContext:l,name:x.name||x.slug}));return}c({to:cr(e,[{entity_type:x.entityType,slug:x.slug}])})}},[v,e,l,a,c]);if(d)return n.jsx(zn,{label:`${i} graph`});if(N||!v||!S)return n.jsx(Xt,{label:`Loading ${i} graph`});const k=j?n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[n.jsxs("p",{children:["Checked ",j.checked," of ",j.total," records. Up to ",Ee," relationships per record."]}),j.failed>0?n.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),j.hasMore?n.jsx(V,{variant:"outline",size:"sm",disabled:j.isFetching,onClick:j.loadMore,children:j.isFetching?"Loading…":j.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return v.focusCount===0?n.jsxs("div",{className:"space-y-3",children:[k,n.jsx(Un,{icon:qn,title:`No ${i} records match`,description:"Change the search or filters to see records here."})]}):n.jsxs("div",{className:"flex flex-col gap-2",children:[k,n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",v.hasMoreRecords?"the first ":"",v.focusCount," ",i," record",v.focusCount===1?"":"s",". Click a record to see it."]}),n.jsx("div",{ref:m,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:n.jsx(cs,{boxes:S.boxes,edges:S.edges,label:`${i} records`,onOpenBox:E,openLabel:y=>`Show ${y.title}`})})]})}function Ga(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function fs(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function tn(e){const t=e?.properties;if(!t)return null;const o=lr(t).find(([,i])=>fs(i)==="workflowState");if(!o)return null;const[c,a]=o,l=a["x-lobu"]?.states,h=Array.isArray(l)&&l.length>0?l:(a.enum??[]).map(i=>({value:i}));return h.length===0||h.some(i=>typeof i.value!="string")?null:{field:c,states:h.map(i=>({...i,label:i.label||dr(a,i.value)||Ga(i.value),terminal:i.terminal??["done","complete","completed","closed","archived"].includes(i.value.toLowerCase())}))}}function Ya(e){const t=e?.properties;if(!t)return null;const s=Object.entries(t),r=s.find(([,a])=>fs(a)==="sortRank"),o=s.find(([a])=>["rank","sort_rank","order"].includes(a)),c=r??o;return c?{field:c[0]}:null}function Ka(e,{isDerived:t}){const s=e?.["x-lobu"]?.defaultView;return(s==="table"||s==="board")&&!(t&&s!=="table")?s:t?"table":tn(e)?"board":"table"}const ps={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},Ja={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function Qa(e){const{canShowBoard:t,builtinData:s,builtInLabels:r}=e,o=["table",...t?["board"]:[]],c={table:ps,board:Ja};return o.map(a=>({id:a,label:r[a],builtInMode:a,template:c[a],data:s}))}function Gt(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function Et(e,t){if(!t)return e.created_at??String(e.id);const s=Mt(e.metadata);return String(s[t.field]??e.created_at??e.id)}function Xa(e,t){const s=e?Number(e):Number.NaN,r=t?Number(t):Number.NaN;return Number.isFinite(s)&&Number.isFinite(r)&&s<r?String((s+r)/2):Number.isFinite(s)?String(s+1):Number.isFinite(r)?String(r-1):String(Date.now())}function Yt(e,t){const s=Mt(e.metadata);return String(s[t]??"")}function hs(e,t){return[...e].sort((s,r)=>Et(s,t).localeCompare(Et(r,t)))}function Za(e,t,s,r,o){if(!t.startsWith("card:")||!s)return null;const c=Number(t.slice(5)),a=e.find(S=>S.id===c);if(!a)return null;const l=s.startsWith("column:")?s.slice(7):Yt(e.find(S=>`card:${S.id}`===s)??a,r.field);if(!l)return null;const h=hs(e.filter(S=>S.id!==c&&Yt(S,r.field)===l),o),i=s.startsWith("card:")?h.findIndex(S=>`card:${S.id}`===s):h.length,g=i>=0?i:h.length,p=g>0?h[g-1]:void 0,f=h[g],m=o?Xa(p?Et(p,o):void 0,f?Et(f,o):void 0):void 0,v=Mt(a.metadata),N={[r.field]:l,...o&&m?{[o.field]:m}:{}};r.states.find(S=>S.value===l)?.terminal&&!v.completed_at&&(N.completed_at=new Date().toISOString());const j={...v,...N};return{entityId:c,changedMetadata:N,nextMetadata:j}}function Rn(e,t,s){return e.map(r=>r.id===t?{...r,metadata:s}:r)}function ei({id:e,children:t,className:s}){const{setNodeRef:r,isOver:o}=rs({id:`column:${e}`});return n.jsx("div",{ref:r,className:ce("min-h-[220px] rounded-lg bg-card p-2 transition-colors",o?"bg-accent/50":"",s),children:t})}function ti({entity:e,owner:t,statusField:s,entityTypeIcon:r,schema:o,didDragRef:c}){const a=Mt(e.metadata),{attributes:l,listeners:h,setNodeRef:i,transform:g,isDragging:p}=go({id:`card:${e.id}`}),{setNodeRef:f,isOver:m}=rs({id:`card:${e.id}`}),v=Gn(t,ss(e)),N=d=>{c.current&&(d.preventDefault(),d.stopPropagation())};return n.jsx("div",{ref:d=>{i(d),f(d)},style:{transform:yo.Translate.toString(g)},className:ce(fr,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",p?"opacity-60":"",m?"ring-1 ring-ring":""),children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("button",{type:"button",className:"mt-0.5 shrink-0 cursor-grab touch-none text-muted-foreground/60 hover:text-foreground active:cursor-grabbing","aria-label":`Drag ${e.name}`,...l,...h,children:n.jsx(mr,{className:"h-4 w-4"})}),n.jsx(ns,{metadata:a,metadataSchema:o,name:e.name,typeIcon:r,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx(Pe,{to:v,className:"font-medium text-foreground hover:underline",onClick:N,children:e.name}),n.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof a.priority=="string"&&a.priority?n.jsx(Vt,{variant:"outline",className:"text-xs",children:Gt(a.priority)}):null,typeof a[s]=="string"&&a[s]?n.jsx(Vt,{variant:"secondary",className:"text-xs",children:Gt(String(a[s]))}):null]})]})]})})}function ni({owner:e,entities:t,totalCount:s,schema:r,entityTypeIcon:o,onUpdate:c}){const a=w.useMemo(()=>tn(r),[r]),l=w.useMemo(()=>Ya(r),[r]),[h,i]=w.useState(t),[g,p]=w.useState(()=>new Set),f=w.useRef(!1),m=mo(fo(ho,{activationConstraint:{distance:6}})),v=w.useCallback(()=>{window.setTimeout(()=>{f.current=!1},0)},[]);w.useEffect(()=>{i(t)},[t]);const N=w.useMemo(()=>{if(!a)return new Map;const E=new Map(a.states.map(k=>[k.value,[]]));for(const k of h){const y=Yt(k,a.field),x=E.has(y)?y:a.states[0]?.value;x&&E.get(x)?.push(k)}for(const[k,y]of E)E.set(k,hs(y,l));return E},[h,l,a]);if(!a)return null;const d=E=>{p(k=>{const y=new Set(k);return y.has(E)?y.delete(E):y.add(E),y})},j=()=>{f.current=!0},S=E=>{const k=String(E.active.id),y=E.over?String(E.over.id):null,x=Za(h,k,y,a,l);if(!x){v();return}const{entityId:T,changedMetadata:$,nextMetadata:F}=x,K=h.find(H=>H.id===T)?.metadata;i(H=>Rn(H,T,F)),c(T,$).catch(()=>{i(H=>Rn(H,T,K))}),v()};return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-semibold",children:"Board"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",Gt(a.field),typeof s=="number"&&s>h.length?n.jsxs(n.Fragment,{children:[" · ",n.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",h.length," of ",s," — narrow with search"]})]}):null]})]}),n.jsx(po,{sensors:m,onDragStart:j,onDragEnd:S,children:n.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:a.states.map(E=>{const k=N.get(E.value)??[],y=E.collapsed??E.terminal,x=y&&!g.has(E.value);return n.jsxs(ei,{id:E.value,children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[E.terminal?n.jsx(ur,{className:"h-4 w-4 text-muted-foreground"}):null,n.jsx("h3",{className:"text-sm font-medium",children:E.label})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(Vt,{variant:"secondary",className:"text-xs",children:k.length}),y?n.jsx(V,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>d(E.value),children:x?"Show":"Hide"}):null]})]}),x?n.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[k.length," hidden ",E.label?.toLowerCase()," item",k.length===1?"":"s"]}):n.jsx("div",{className:"space-y-2",children:k.length>0?k.map(T=>n.jsx(ti,{entity:T,owner:e,statusField:a.field,entityTypeIcon:o,schema:r,didDragRef:f},T.id)):n.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",E.label?.toLowerCase()," items"]})})]},E.value)})})})]})}const si=w.memo(ni);function ri(e){let t=0;for(let s=0;s<e.length;s++)t=(t<<5)-t+e.charCodeAt(s),t|=0;return t.toString(36)}function gs(e,t){return{queryKey:["metric_series",e,ri(t)],queryFn:()=>bt("metric_series",{sql:t},{slug:e}),staleTime:6e4}}function ys(e,t){const s=!!e&&!!t,r=gs(e??"",t??"");return Vn({...r,enabled:s})}ys.queryOptions=(e,t)=>gs(e,t);function oi(e,t){if(!e?.columns?.length||!e.rows)return[];const s=e.columns.indexOf(t);return s<0?[]:e.rows.map(r=>Number(r[s])||0)}const In=/^[a-z][a-z0-9_]*$/;function ai(e){const t=Object.entries(e);for(const[o,c]of t){if(!In.test(o))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${o}'`);if(!In.test(c))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${c}'`)}const s=t.flatMap(([o,c])=>[`COUNT(*) FILTER (
|
|
3
|
-
WHERE semantic_type = 'change'
|
|
4
|
-
AND metadata->>'category' = 'lifecycle'
|
|
5
|
-
AND metadata->>'entity_type' = '${c}'
|
|
6
|
-
AND metadata->>'op' = 'created'
|
|
7
|
-
) AS ${o}_added`,`COUNT(*) FILTER (
|
|
8
|
-
WHERE semantic_type = 'change'
|
|
9
|
-
AND metadata->>'category' = 'lifecycle'
|
|
10
|
-
AND metadata->>'entity_type' = '${c}'
|
|
11
|
-
AND metadata->>'op' = 'deleted'
|
|
12
|
-
) AS ${o}_removed`]).join(`,
|
|
13
|
-
`),r=t.map(([o])=>` SUM(COALESCE(b.${o}_added, 0) - COALESCE(b.${o}_removed, 0))
|
|
14
|
-
OVER (ORDER BY d.bucket) AS ${o}`).join(`,
|
|
15
|
-
`);return`
|
|
16
|
-
WITH days AS (
|
|
17
|
-
SELECT generate_series(
|
|
18
|
-
date_trunc('day', now() - interval '13 days'),
|
|
19
|
-
date_trunc('day', now()),
|
|
20
|
-
interval '1 day'
|
|
21
|
-
) AS bucket
|
|
22
|
-
),
|
|
23
|
-
buckets AS (
|
|
24
|
-
SELECT
|
|
25
|
-
date_trunc('day', created_at) AS bucket,
|
|
26
|
-
${s}
|
|
27
|
-
FROM events
|
|
28
|
-
WHERE created_at > now() - interval '14 days'
|
|
29
|
-
GROUP BY 1
|
|
30
|
-
)
|
|
31
|
-
SELECT d.bucket,
|
|
32
|
-
${r}
|
|
33
|
-
FROM days d
|
|
34
|
-
LEFT JOIN buckets b ON b.bucket = d.bucket
|
|
35
|
-
ORDER BY d.bucket
|
|
36
|
-
`}const ii={"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 ci(e){if(typeof e.sql=="string"&&e.sql.trim())return e.sql;if(e.lifecycle&&typeof e.lifecycle=="object"){const t=Object.fromEntries(Object.entries(e.lifecycle).map(([s,r])=>[s,String(r)]));if(Object.keys(t).length>0)try{return ai(t)}catch{return null}}return typeof e.preset=="string"?ii[e.preset]??null:null}function li({owner:e,sql:t,lifecycle:s,preset:r,column:o,chart:c,height:a,width:l,color:h,label:i,className:g}){const p=w.useMemo(()=>ci({sql:t,lifecycle:s,preset:r}),[t,s,r]),f=typeof e=="string"&&e?e:null,{data:m}=ys(f,p),v=String(o??""),N=w.useMemo(()=>oi(m,v),[m,v]),d=w.useMemo(()=>!m?.columns?.length||!m.rows?[]:m.rows.map((S,E)=>({label:String(S[0]??"").slice(0,10),value:N[E]??0})),[m,N]);if(!f||!p||!v)return null;const j=c==="line"?n.jsx(co,{data:d,height:typeof a=="number"?a:void 0}):n.jsx(lo,{data:N,height:typeof a=="number"?a:void 0,width:typeof l=="number"?l:void 0,color:typeof h=="string"?h:void 0});return i==null?n.jsx("div",{className:g,children:j}):n.jsxs("div",{className:g,children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:String(i)}),j]})}function di({metadata:e,metadataSchema:t,name:s,typeIcon:r,initialsFallback:o,className:c}){return n.jsx(ns,{metadata:e,metadataSchema:t,name:String(s??""),typeIcon:r,initialsFallback:!!o,className:c})}function ui({entity:e,owner:t,className:s,onClick:r,children:o}){const c=e;if(!c)return n.jsx(n.Fragment,{children:o});const a=Gn(String(t??""),ss(c));return n.jsx(Pe,{to:a,className:s,onClick:r,children:o})}function mi({state:e}){return e?n.jsx(no,{...e}):null}function fi({state:e,onUpdate:t}){return e?n.jsx(si,{...e,onUpdate:t}):null}const pi={"entity-avatar":di,"entity-link":ui,"entity-table":mi,"entity-board":fi,"metric-series":li};function hi({ownerSlug:e,typeSlug:t,title:s,shape:r}){const[o,c]=w.useState(!1),a=nt(),{visible:l,system:h,isTypesLoading:i}=pr(e),g=f=>{c(!1);const m=`/${e}/${Xn(f)}`;a({to:r?`${m}/${Zn}/${r}`:m})},p=f=>n.jsxs(wr,{value:`${f.name} ${f.slug}`,onSelect:()=>g(f.slug),children:[n.jsx(Ct,{icon:f.icon,className:"mr-2 h-4 w-4 shrink-0"}),n.jsx("span",{className:"flex-1 truncate",children:f.name||f.slug}),f.slug===t?n.jsx(kr,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,f.entity_count!=null?n.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:f.entity_count.toLocaleString()}):null]},f.slug);return n.jsxs(Yn,{open:o,onOpenChange:c,children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:n.jsx(Kn,{asChild:!0,children:n.jsxs(V,{type:"button",variant:"ghost",className:"-ml-2 h-auto gap-1.5 px-2 py-1 text-2xl font-semibold tracking-tight",children:[s,n.jsx(Jn,{className:"h-5 w-5 text-muted-foreground"})]})})}),n.jsx(Qn,{align:"start",className:"w-72 p-0",children:n.jsxs(hr,{children:[n.jsx(gr,{autoFocus:!0,placeholder:"Find a type…"}),n.jsxs(yr,{children:[n.jsx(xr,{children:i?"Loading types…":"No type matches."}),l.length>0?n.jsx(un,{heading:"Types",children:l.map(p)}):null,h.length>0?n.jsx(un,{heading:"System",children:h.map(p)}):null]}),n.jsx(br,{}),n.jsxs(Pe,{to:"/$owner/data",params:{owner:e},onClick:()=>c(!1),className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground",children:[n.jsx(vr,{className:"h-4 w-4"}),"Schema map"]})]})})]})}function gi(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,t])=>t.on==="entity").map(([t,s])=>({name:t,description:s.description}))}const ht={table:{label:"Table",icon:Tr},board:{label:"Board",icon:Mr},graph:{label:"Graph",icon:qn}},xs=(e,t)=>`lobu.record-shape:v1:${e}/${t}`,yi=new Set(["table","board","graph"]);function xi(e,t){const s=An(xs(e,t));return s&&yi.has(s)?s:void 0}function bi(e,t,s){Pn(xs(e,t),s)}const Ln=":records";function vi({ownerSlug:e,entityTypeSlug:t,create:s,onCreateChange:r,viewKey:o,shape:c}){const{orgContext:a,hasOrgContext:l}=De(),h=Wn(t,a),{data:i,isLoading:g,error:p}=h;Nr(`/${e}`,a);const f=Sr(),[m,v]=w.useState({key:"",page:0}),N=es({strict:!1}),d=nt(),j=Jt(),S=`/${e}/${Xn(t)}`,E=!g&&i?.slug===t,{collection:k,error:y,presentation:x,preset:T,edited:$,table:F}=w.useMemo(()=>ka(N,i?.metadata_schema,!!o),[N,i?.metadata_schema,o]),A=E?y:void 0,K=w.useMemo(()=>Ca(N,k),[N,k]),[H,se]=w.useState(!1),[W,ge]=w.useState(0),ne=k.search??"",U=k.segment,Ce=JSON.stringify(k),ue=U?gi(i).find(I=>I.name===U)??{name:U,description:""}:null,Q=I=>void d({to:".",search:{...Ve(I),...K},replace:!0}),ee=jr(h.data),me=ee?F.sort:Ma(F),_e=me?.field,Ue=me?.order,oe=w.useMemo(()=>_e?[{id:_e,desc:Ue==="desc"}]:[],[_e,Ue]),ve=w.useCallback(I=>void d({to:".",search:{...o?Ve(N):{},...K,$table:JSON.stringify(I)},replace:!0}),[d,o,N,K]),Fe=w.useCallback(I=>{const Y=typeof I=="function"?I(oe):I;Y[0]&&ve({...F,sort:{field:Y[0].id,order:Y[0].desc?"desc":"asc"}})},[oe,ve,F]),Me=s===!0,Te=()=>r(!0),we=()=>r(!1),ze=oe[0]?.id,fe=oe[0]?oe[0].desc?"desc":"asc":void 0,ke=h.data?.metadata_schema,ye=!!tn(ke)&&!ee,Ne=Ka(ke,{isDerived:ee}),le=ts(a),Re=Dt(le.data??[],t,k),Se=(I,Y=!1,he=Ve(N))=>{const pe=!o||!le.data||Dt(le.data,t,I).some(dt=>dt.key===o);d({to:pe?".":S,search:{...pe&&o?he:{},...Na(I,T?.key),$table:JSON.stringify(F)},replace:Y})},xe=I=>{const Y=I?xt(I):{},he=!o||Dt(le.data??[],t,Y).some(pe=>pe.key===o);se(!1),ge(pe=>pe+1),d({to:he?".":S,search:I?{$preset:I.key}:{}})},{isAdmin:qe}=Dn(a.organizationId),Ie=Er(a),C=qe&&!!i&&!h.isPlaceholderData,u=w.useRef(N);u.current=N;const M=async()=>{if(!T)return;const I=JSON.stringify(N),{data:Y}=await h.refetch(),he=Y?.metadata_schema,pe=he?Qt(he[Ht]??{}):void 0,dt=pe?.presets?.find(ut=>ut.key===T.key);if(!Y||!he||!pe||!dt){Bn.error("This saved filter changed. Reload and try again.");return}const Lt=Sa(dt,k,F,pe);await Ie.mutateAsync({slug:Y.slug,metadata_schema:{...he,[Ht]:{...pe,presets:pe.presets?.map(ut=>ut.key===Lt.key?Lt:ut)}}}).then(()=>!0,()=>!1)&&(await h.refetch(),JSON.stringify(u.current)===I&&xe(Lt))},b=w.useMemo(()=>xi(e,t),[e,t]),_=Cr(le.data??[],t,{viewKey:o,shape:c??(o?void 0:b)},Ne,k),R=_.kind==="builtin"?_.mode==="board"&&!ye?"table":_.mode:null,z=R==="graph";w.useEffect(()=>{c&&E&&R&&bi(e,t,R)},[c,E,R,e,t]);const P=["table",...ye?["board"]:[],"graph"],O=_.kind==="view"?_.view:null,D=_.kind==="missing"?_.key:null,ae=_.kind==="inapplicable"?_:null,re=R==="table"?50:200,be=`${t}?${Ce}&sort=${JSON.stringify(F.sort)}&size=${re}`,Le=m.key===be?m.page:0,Ge=w.useCallback(I=>v(Y=>({key:be,page:I(Y.key===be?Y.page:0)})),[be]),$e=mn(t,a,{limit:re,offset:Le*re,search:ne.trim()||void 0,sortBy:ze,sortOrder:fe,segment:U,filters:k.filters,enabled:E&&!o&&!A}),Ye=mn(t,a,{limit:1,offset:0,parentId:null,search:ne.trim()||void 0,segment:U,filters:k.filters,enabled:E&&!o&&!A&&!ee}),{data:Ke,error:Tt}=$e,L=$e.isLoading||$e.isPending&&$e.fetchStatus==="paused",G=A||p||(o?null:Tt),J=!!o&&le.data===void 0&&le.isError,B=Ke?.entities??[],X=Ke?.metadata?.has_more??!1,q=Ke?.metadata?.total_count??0,Oe=B.length>0||ne.trim().length>0||Le>0||!!U||!!k.filters?.length,te=i?.name?.trim()||Ft(t),de=i?.icon||void 0,Z=ee,ie=ke,je=!A&&(!l||!E||(o?le.data===void 0&&!le.isError:L||!ee&&Ye.isLoading)),We=Ke?.linked_entities??{},st=Ye.data?.metadata?.total_count,Je=q>0&&typeof st=="number"?st<q:!1,rt=w.useMemo(()=>i?.measure_columns??[],[i?.measure_columns]),Qe=w.useCallback(I=>ve({...F,columns:I}),[ve,F]),ot=w.useMemo(()=>({entities:B,owner:e,schema:ie,entityTypeIcon:de,isDerived:Z,measureColumns:rt,linkedEntityLookups:We,hasAnyParents:Je,sorting:oe,onSortingChange:Fe,visibleColumns:F.columns,columnChoices:so(ie,Z,B),onVisibleColumnsChange:Qe,page:Le,pageSize:re,totalCount:q,hasMore:X,pageTitle:te,onPrevPage:()=>Ge(I=>Math.max(0,I-1)),onNextPage:()=>Ge(I=>I+1)}),[B,e,ie,de,Z,rt,We,Je,oe,F.columns,Qe,Fe,Ge,Le,re,q,X,te]),nn=q>B.length,sn=`showing first ${B.length} of ${q} — narrow with search`,rn=w.useMemo(()=>({owner:e,entityType:i,entities:B,totalCount:q,schema:ie,entityTypeIcon:de}),[e,i,B,q,ie,de]),Rt=w.useMemo(()=>({tableState:ot,boardState:rn,owner:e,schema:ie,entityType:i,entityTypeIcon:de,totalCount:q,isTruncated:nn,truncationNotice:sn,canCreate:!Z,addLabel:`Add ${i?.name||Ft(t)}`}),[ot,rn,e,ie,i,de,q,nn,sn,Z,t]),bs=w.useMemo(()=>Qa({canShowBoard:ye,builtinData:Rt,builtInLabels:{table:ht.table.label,board:ht.board.label}}),[ye,Rt]),on=R?bs.find(I=>I.id===R)??null:null,vs=on?.template??ps,ws=on?.data??Rt,an=I=>void d({to:I===Ln?S:`${S}${Lr(I)}`,search:K}),It=Ve(N),ks=xo(O?.params,It,I=>void d({to:".",search:{...Ve(I),...K}})),Ns=()=>Se({...k,filters:[],segment:void 0},!1,bo(O?.params,It)),cn=`Moved on ${i?.name||i?.slug||t} board`,ln=w.useMemo(()=>(I,Y)=>f.mutateAsync({entityId:I,metadata:Y,field_note:cn}),[f,cn]),Ss=w.useMemo(()=>({updateEntity:ln,openCreate:()=>r(!0)}),[ln,r]),dn=I=>j?n.jsx(V,{type:"button",variant:"ghost",size:"icon",className:ce("size-8 text-muted-foreground hover:text-foreground",I),"aria-label":"Edit type",title:"Edit type",onClick:()=>j.open({href:Ir(e,t),title:te}),children:n.jsx(Rr,{className:"h-4 w-4"})}):null;return n.jsx(ro,{title:n.jsx(hi,{ownerSlug:e,typeSlug:t,title:te,shape:o?null:R}),actions:dn(Me||!E?"":"hidden @lg:inline-flex"),controls:n.jsxs(n.Fragment,{children:[Me?n.jsx("div",{className:"max-w-3xl",children:n.jsx(ba,{onClose:we,entityTypeSlug:t,orgContext:a})}):null,!Me&&E&&n.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${te} views`,children:[dn("-mr-1 @lg:hidden"),!o&&P.length>1&&n.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:P.map(I=>{const Y=ht[I].icon,he=R===I;return n.jsx(V,{type:"button",variant:"ghost",size:"sm","aria-pressed":he,title:ht[I].label,"data-testid":`shape-${I}`,className:ce("h-7 px-2",he&&"bg-accent text-accent-foreground"),onClick:()=>void d({to:`${S}/${Zn}/${I}`,search:K,replace:!0}),children:n.jsx(Y,{className:"h-4 w-4"})},I)})}),o&&n.jsx(V,{variant:"ghost",onClick:()=>an(Ln),children:"Records"}),!!x.presets?.length&&n.jsxs(Yn,{open:H,onOpenChange:se,children:[n.jsx(Kn,{asChild:!0,children:n.jsxs(V,{variant:"outline",className:ce("gap-2",$&&"border-dashed border-primary"),"data-edited":$||void 0,title:"Choose saved filter",children:[T?.label??(k.filters?.length||k.search?"Custom filter":"All records"),$?n.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,n.jsx(Jn,{className:"h-4 w-4 text-muted-foreground"})]})}),n.jsxs(Qn,{align:"start",className:"w-60 p-1",children:[n.jsx(V,{variant:T?"ghost":"secondary",className:"w-full justify-start",onClick:()=>xe(),children:"All records"}),x.presets.map(I=>n.jsx(V,{variant:T?.key===I.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>xe(I),children:I.label},I.key))]})]}),T&&$?n.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[n.jsx(V,{variant:"ghost",size:"sm",onClick:()=>xe(T),children:"Reset"}),C?n.jsx(V,{size:"sm",disabled:Ie.isPending,onClick:()=>void M(),children:Ie.isPending?"Saving…":"Save"}):null]}):null,!A&&n.jsx(Oa,{collection:k,schema:ie,label:te,org:a??"",facetQuery:x.facetQuery,onChange:Se,viewFilters:ks,onClearAll:Ns,segmentChip:ue?{id:"segment",label:"Segment",op:"is",value:Ft(ue.name),title:ue.description||void 0,editor:ue.description?{kind:"custom",render:()=>n.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:ue.description})}:void 0,onRemove:()=>Se({...k,segment:void 0})}:void 0},`filters:${t}:${W}`),Re.map(I=>n.jsx(V,{"data-testid":`tab-${I.key}`,variant:o===I.key?"secondary":"ghost","aria-pressed":o===I.key,onClick:()=>an(I.key),children:I.name},I.key)),n.jsx(Ia,{label:te,search:k.search,onSearch:(I,Y)=>Se({...k,search:I},Y),className:"ml-auto min-w-40 max-w-64 flex-1"},`search:${t}:${W}`),!Z&&!o?n.jsxs(V,{size:"sm","aria-label":`Add ${te||"entity"}`,onClick:()=>Te(),children:[n.jsx(ct,{className:"mr-2 h-4 w-4"}),"Add"]}):null]})]}),children:Me?null:je?z?n.jsx(Xt,{label:`Loading ${te} graph`}):n.jsx(oo,{}):G?n.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[G.message||`Failed to load ${te.toLowerCase()}.`,A&&n.jsx(V,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>Se({}),children:"Clear filters"})]}):J?n.jsx(os,{onRetry:()=>void le.refetch()}):ae?n.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[n.jsxs("h2",{className:"text-lg font-semibold",children:["“",ae.view.name,"” doesn’t apply to the current filters"]}),n.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(ae.when).map(([I,Y])=>`${I} is ${Y===null?"not supplied":String(Y)}`).join(" and "),"."]}),n.jsx(Pe,{to:S,search:K,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${te}`})]}):D?n.jsx(as,{viewKey:D,backTo:S,backLabel:`Back to ${te}`}):O?n.jsx(is,{orgSlug:e,viewKey:O.key,scope:{type:t,collection:k},params:It,onParamsChange:Q,contentHash:O.content_hash,title:O.name,minHeight:320}):z&&Oe?n.jsx(qa,{ownerSlug:e,typeSlug:t,sourceBacked:ee,records:B.map(I=>({...I,id:I.id??JSON.stringify([I.entity_type,I.slug])})),hasMore:X}):Oe?n.jsx(uo,{template:vs,data:ws,actions:Ss,components:pi}):n.jsx(Un,{icon:_r,iconElement:n.jsx(Ct,{icon:i?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${te.toLowerCase()} yet`,description:Z?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${i?.name?.toLowerCase()||"entity"}.`,actionLabel:Z?void 0:`Add ${i?.name||"Entity"}`,onAction:Z?void 0:()=>Te()})})}function wi({ownerSlug:e,typeScope:t,create:s,createType:r=!1,viewKey:o,shape:c}){const a=nt(),{orgContext:l}=De(),h=es({strict:!1}),i=t?$r(t):void 0,g=i==="$member",p=()=>{a({to:"/$owner/data",params:{owner:e},search:{}})},f=v=>{if(!i)return;const N=Fn(e,i);a({to:N.to,params:N.params,search:v?{create:!0}:{},replace:!0})},m=r?n.jsx("div",{className:"mx-auto w-full max-w-3xl",children:n.jsx(wo,{entityType:null,orgContext:l,onClose:p})}):i?n.jsx(vi,{ownerSlug:e,entityTypeSlug:i,create:s,onCreateChange:f,viewKey:o,shape:c}):n.jsx(ki,{ownerSlug:e,viewKey:o,search:h});return n.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:g?n.jsx(No,{children:m}):m})}function ki({ownerSlug:e,viewKey:t,search:s}){const r=nt(),{orgContext:o}=De(),{data:c,isError:a,error:l,refetch:h}=ts(o),i=Or(c??[],t),g=Ar(),p=Pr(c??[]),f=a?Dr(l,{subject:"Views"}):null;return t&&c===void 0?a?n.jsx(os,{error:l,onRetry:()=>void h()}):null:i.kind==="missing"?n.jsx(as,{viewKey:i.key,backTo:`/${e}/data`,backLabel:"Back to Memory"}):n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[g&&p.length>0?n.jsxs("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-wrap gap-1",children:[n.jsx(Pe,{to:"/$owner/data",params:{owner:e},search:{},activeOptions:{exact:!0},"aria-current":t?void 0:"page",className:$n(!t),children:"Overview"}),p.map(m=>n.jsx(Pe,{to:"/$owner/data/-/views/$viewKey",params:{owner:e,viewKey:m.key},search:{},activeOptions:{exact:!0},"aria-current":t===m.key?"page":void 0,className:$n(t===m.key),children:m.name},m.key))]}):null,g&&f?n.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:[f.title,"."," ",f.retryable?n.jsx("button",{type:"button",onClick:()=>void h(),className:"underline underline-offset-4",children:"Retry"}):null]}):null,i.kind==="view"?n.jsxs(n.Fragment,{children:[n.jsx(vo,{decls:i.view.params,params:Ve(s),onParamsChange:m=>void r({to:".",search:m})}),n.jsx(is,{orgSlug:e,viewKey:i.view.key,scope:{},params:Ve(s),onParamsChange:m=>void r({to:".",search:m,replace:!0}),contentHash:i.view.content_hash,title:i.view.name,minHeight:400})]}):n.jsx(xa,{ownerSlug:e})]})}const $n=e=>ko(e,"min-h-10 max-w-full gap-2 px-3 text-sm break-words");function Bi({ownerSlug:e,typeScope:t,create:s,createType:r=!1,viewKey:o,shape:c}){return n.jsxs(Fr,{className:"gap-6 pt-2.5 pb-8",children:[n.jsx(Wr,{}),n.jsx(zr,{owner:e,children:a=>n.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:n.jsx(wi,{ownerSlug:a.ownerSlug,typeScope:t,create:s,createType:r,viewKey:o,shape:c})})})]})}export{Bi as M};
|
|
74
|
-
//# sourceMappingURL=memory-browse-page-Ba32-vVL.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{bs as C,fl as R}from"./index-BjcZVe7n.js";var U={exports:{}},I;function W(){return I||(I=1,(function(u,d){(function(O,_){u.exports=_()})(globalThis,()=>(()=>{var y={949(X,v,m){Object.defineProperty(v,"__esModule",{value:!0}),v.CronParser=void 0;var r=m(515),T=(function(){function f(t,e,o){e===void 0&&(e=!0),o===void 0&&(o=!1),this.expression=t,this.dayOfWeekStartIndexZero=e,this.monthStartIndexZero=o}return f.prototype.parse=function(){var t,e,o=(t=this.expression)!==null&&t!==void 0?t:"";if(o==="@reboot")return e=["@reboot","","","","","",""],e;if(o.startsWith("@")){var n=this.parseSpecial(this.expression);e=this.extractParts(n)}else e=this.extractParts(this.expression);return this.normalize(e),this.validate(e),e},f.prototype.parseSpecial=function(t){var e={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},o=e[t];if(!o)throw new Error("Unknown special expression.");return o},f.prototype.extractParts=function(t){if(!this.expression)throw new Error("cron expression is empty");for(var e=t.trim().split(/[ ]+/),o=0;o<e.length;o++)if(e[o].includes(",")){var n=e[o].split(",").map(function(a){return a.trim()}).filter(function(a){return a!==""}).map(function(a){return isNaN(Number(a))?a:Number(a)}).filter(function(a){return a!==null&&a!==""});n.length===0&&n.push("*"),n.sort(function(a,s){return a!==null&&s!==null?a-s:0}),e[o]=n.map(function(a){return a!==null?a.toString():""}).join(",")}if(e.length<5)throw new Error("Expression has only ".concat(e.length," part").concat(e.length==1?"":"s",". At least 5 parts are required."));if(e.length==5)e.unshift(""),e.push("");else if(e.length==6){var i=/\d{4}$/.test(e[5])||e[4]=="?"||e[2]=="?";i?e.unshift(""):e.push("")}else if(e.length>7)throw new Error("Expression has ".concat(e.length," parts; too many!"));return e},f.prototype.normalize=function(t){var e=this;if(t[3]=t[3].replace("?","*"),t[5]=t[5].replace("?","*"),t[2]=t[2].replace("?","*"),t[0].indexOf("0/")==0&&(t[0]=t[0].replace("0/","*/")),t[1].indexOf("0/")==0&&(t[1]=t[1].replace("0/","*/")),t[2].indexOf("0/")==0&&(t[2]=t[2].replace("0/","*/")),t[3].indexOf("1/")==0&&(t[3]=t[3].replace("1/","*/")),t[4].indexOf("1/")==0&&(t[4]=t[4].replace("1/","*/")),t[6].indexOf("1/")==0&&(t[6]=t[6].replace("1/","*/")),t[5]=t[5].replace(/(^\d)|([^#/\s]\d)/g,function(l){var g=l.replace(/\D/,""),h=g;return e.dayOfWeekStartIndexZero?g=="7"&&(h="0"):h=(parseInt(g)-1).toString(),l.replace(g,h)}),t[5]=="L"&&(t[5]="6"),t[3]=="?"&&(t[3]="*"),t[3].indexOf("W")>-1&&(t[3].indexOf(",")>-1||t[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var o={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in o)t[5]=t[5].replace(new RegExp(n,"gi"),o[n].toString());t[4]=t[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(l){var g=l.replace(/\D/,""),h=g;return e.monthStartIndexZero&&(h=(parseInt(g)+1).toString()),l.replace(g,h)});var i={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in i)t[4]=t[4].replace(new RegExp(a,"gi"),i[a].toString());t[0]=="0"&&(t[0]=""),!/\*|\-|\,|\//.test(t[2])&&(/\*|\//.test(t[1])||/\*|\//.test(t[0]))&&(t[2]+="-".concat(t[2]));for(var s=0;s<t.length;s++)if(t[s].indexOf(",")!=-1&&(t[s]=t[s].split(",").filter(function(l){return l!==""}).join(",")||"*"),t[s]=="*/1"&&(t[s]="*"),t[s].indexOf("/")>-1&&!/^\*|\-|\,/.test(t[s])){var c=null;switch(s){case 4:c="12";break;case 5:c="6";break;case 6:c="9999";break;default:c=null;break}if(c!==null){var p=t[s].split("/");t[s]="".concat(p[0],"-").concat(c,"/").concat(p[1])}}},f.prototype.validate=function(t){var e="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(t[0],e),this.validateOnlyExpectedCharactersFound(t[1],e),this.validateOnlyExpectedCharactersFound(t[2],e),this.validateOnlyExpectedCharactersFound(t[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(t[4],e),this.validateOnlyExpectedCharactersFound(t[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(t[6],e),this.validateAnyRanges(t)},f.prototype.validateAnyRanges=function(t){r.default.secondRange(t[0]),r.default.minuteRange(t[1]),r.default.hourRange(t[2]),r.default.dayOfMonthRange(t[3]),r.default.monthRange(t[4],this.monthStartIndexZero),r.default.dayOfWeekRange(t[5],this.dayOfWeekStartIndexZero)},f.prototype.validateOnlyExpectedCharactersFound=function(t,e){var o=t.match(new RegExp("[^".concat(e,"]+"),"gi"));if(o&&o.length)throw new Error("Expression contains invalid values: '".concat(o.toString(),"'"))},f})();v.CronParser=T},333(X,v,m){Object.defineProperty(v,"__esModule",{value:!0}),v.ExpressionDescriptor=void 0;var r=m(823),T=m(949),f=(function(){function t(e,o){if(this.expression=e,this.options=o,this.expressionParts=new Array(5),!this.options.locale&&t.defaultLocale&&(this.options.locale=t.defaultLocale),!t.locales[this.options.locale]){var n=Object.keys(t.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=t.locales[this.options.locale],o.use24HourTimeFormat===void 0&&(o.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return t.toString=function(e,o){var n=o===void 0?{}:o,i=n.throwExceptionOnParseError,a=i===void 0?!0:i,s=n.verbose,c=s===void 0?!1:s,p=n.dayOfWeekStartIndexZero,l=p===void 0?!0:p,g=n.monthStartIndexZero,h=g===void 0?!1:g,S=n.use24HourTimeFormat,x=n.trimHoursLeadingZero,b=x===void 0?!1:x,k=n.locale,D=k===void 0?null:k,E=n.logicalAndDayFields,A=E===void 0?!1:E,M={throwExceptionOnParseError:a,verbose:c,dayOfWeekStartIndexZero:l,monthStartIndexZero:h,use24HourTimeFormat:S,trimHoursLeadingZero:b,locale:D,logicalAndDayFields:A};M.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var H=new t(e,M);return H.getFullDescription()},t.initialize=function(e,o){o===void 0&&(o="en"),t.specialCharacters=["/","-",",","*"],t.defaultLocale=o,e.load(t.locales)},t.prototype.getFullDescription=function(){var e,o,n="";try{var i=new T.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=i.parse(),this.expressionParts[0]==="@reboot")return((o=(e=this.i18n).atReboot)===null||o===void 0?void 0:o.call(e))||"Run once, at startup";var a=this.getTimeOfDayDescription(),s=this.getDayOfMonthDescription(),c=this.getMonthDescription(),p=this.getDayOfWeekDescription(),l=this.getYearDescription();n+=a+s+p+c+l,n=this.transformVerbosity(n,!!this.options.verbose),n=n.charAt(0).toLocaleUpperCase()+n.substr(1)}catch(g){if(!this.options.throwExceptionOnParseError)n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(g)}return n},t.prototype.getTimeOfDayDescription=function(){var e=this.expressionParts[0],o=this.expressionParts[1],n=this.expressionParts[2],i="";if(!r.StringUtilities.containsAny(o,t.specialCharacters)&&!r.StringUtilities.containsAny(n,t.specialCharacters)&&!r.StringUtilities.containsAny(e,t.specialCharacters))i+=this.i18n.atSpace()+this.formatTime(n,o,e);else if(!e&&o.indexOf("-")>-1&&!(o.indexOf(",")>-1)&&!(o.indexOf("/")>-1)&&!r.StringUtilities.containsAny(n,t.specialCharacters)){var a=o.split("-");i+=r.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(n,a[0],""),this.formatTime(n,a[1],""))}else if(!e&&n.indexOf(",")>-1&&n.indexOf("-")==-1&&n.indexOf("/")==-1&&!r.StringUtilities.containsAny(o,t.specialCharacters)){var s=n.split(",");i+=this.i18n.at();for(var c=0;c<s.length;c++)i&&(i+=" "),i+=this.formatTime(s[c],o,""),c<s.length-2&&(i+=","),c==s.length-2&&(i+=this.i18n.spaceAnd())}else{var p=this.getSecondsDescription(),l=this.getMinutesDescription(),g=this.getHoursDescription();if(i+=p,i&&l&&(i+=", "),i+=l,l===g)return i;i&&g&&(i+=", "),i+=g}return i},t.prototype.getSecondsDescription=function(){var e=this,o=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(n){return n},function(n){return r.StringUtilities.format(e.i18n.everyX0Seconds(n),n)},function(n){return e.i18n.secondsX0ThroughX1PastTheMinute()},function(n){return n=="0"?"":parseInt(n)<20?e.i18n.atX0SecondsPastTheMinute(n):e.i18n.atX0SecondsPastTheMinuteGt20()||e.i18n.atX0SecondsPastTheMinute(n)});return o},t.prototype.getMinutesDescription=function(){var e=this,o=this.expressionParts[0],n=this.expressionParts[2],i=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(a){return a},function(a){return r.StringUtilities.format(e.i18n.everyX0Minutes(a),a)},function(a){return e.i18n.minutesX0ThroughX1PastTheHour()},function(a){var s,c;try{return a=="0"&&n.indexOf("/")==-1&&o==""?e.i18n.everyHour():a=="0"?((c=(s=e.i18n).onTheHour)===null||c===void 0?void 0:c.call(s))||e.i18n.atX0MinutesPastTheHour(a):parseInt(a)<20?e.i18n.atX0MinutesPastTheHour(a):e.i18n.atX0MinutesPastTheHourGt20()||e.i18n.atX0MinutesPastTheHour(a)}catch{return e.i18n.atX0MinutesPastTheHour(a)}});return i},t.prototype.getHoursDescription=function(){var e=this,o=this.expressionParts[2],n=0,i=[];o.split("/")[0].split(",").forEach(function(c){var p=c.split("-");p.length===2&&i.push({value:p[1],index:n+1}),n+=p.length});var a=0,s=this.getSegmentDescription(o,this.i18n.everyHour(),function(c){var p=i.find(function(g){return g.value===c&&g.index===a}),l=p&&e.expressionParts[1]!=="0";return a++,l?e.formatTime(c,"59",""):e.formatTime(c,"0","")},function(c){return r.StringUtilities.format(e.i18n.everyX0Hours(c),c)},function(c){return e.i18n.betweenX0AndX1()},function(c){return e.i18n.atX0()});return s},t.prototype.getDayOfWeekDescription=function(){var e=this,o=this.i18n.daysOfTheWeek(),n=null;return this.expressionParts[5]=="*"?n="":n=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(i,a){var s=i;i.indexOf("#")>-1?s=i.substring(0,i.indexOf("#")):i.indexOf("L")>-1&&(s=s.replace("L",""));var c=parseInt(s),p=e.i18n.daysOfTheWeekInCase?e.i18n.daysOfTheWeekInCase(a)[c]:o[c];if(i.indexOf("#")>-1){var l=null,g=i.substring(i.indexOf("#")+1),h=i.substring(0,i.indexOf("#"));switch(g){case"1":l=e.i18n.first(h);break;case"2":l=e.i18n.second(h);break;case"3":l=e.i18n.third(h);break;case"4":l=e.i18n.fourth(h);break;case"5":l=e.i18n.fifth(h);break}p=l+" "+p}return p},function(i){return parseInt(i)==1?"":r.StringUtilities.format(e.i18n.commaEveryX0DaysOfTheWeek(i),i)},function(i){var a=i.substring(0,i.indexOf("-")),s=e.expressionParts[3]!="*";return s?e.i18n.commaAndX0ThroughX1(a):e.i18n.commaX0ThroughX1(a)},function(i){var a=null;if(i.indexOf("#")>-1){var s=i.substring(i.indexOf("#")+1),c=i.substring(0,i.indexOf("#"));a=e.i18n.commaOnThe(s,c).trim()+e.i18n.spaceX0OfTheMonth()}else if(i.indexOf("L")>-1)a=e.i18n.commaOnTheLastX0OfTheMonth(i.replace("L",""));else{var p=e.expressionParts[3]!="*";p?e.options.logicalAndDayFields?a=e.i18n.commaOnlyOnX0(i):a=e.i18n.commaAndOnX0():a=e.i18n.commaOnlyOnX0(i)}return a}),n},t.prototype.getMonthDescription=function(){var e=this,o=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(i,a){return a&&e.i18n.monthsOfTheYearInCase?e.i18n.monthsOfTheYearInCase(a)[parseInt(i)-1]:o[parseInt(i)-1]},function(i){return parseInt(i)==1?"":r.StringUtilities.format(e.i18n.commaEveryX0Months(i),i)},function(i){return e.i18n.commaMonthX0ThroughMonthX1()||e.i18n.commaX0ThroughX1()},function(i){return e.i18n.commaOnlyInMonthX0?e.i18n.commaOnlyInMonthX0():e.i18n.commaOnlyInX0()});return n},t.prototype.getDayOfMonthDescription=function(){var e=this,o=null,n=this.expressionParts[3];switch(n){case"L":o=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":o=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var i=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(i){var a=parseInt(i[0].replace("W","")),s=a==1?this.i18n.firstWeekday():r.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());o=r.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),s);break}else{var c=n.match(/L-(\d{1,2})/);if(c){var p=c[1];o=r.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(p),p);break}else{if(n=="*"&&this.expressionParts[5]!="*")return"";o=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(l){return l=="L"?e.i18n.lastDay():e.i18n.dayX0?r.StringUtilities.format(e.i18n.dayX0(),l):l},function(l){return l=="1"?e.i18n.commaEveryDay():e.i18n.commaEveryX0Days(l)},function(l){return e.i18n.commaBetweenDayX0AndX1OfTheMonth(l)},function(l){return e.i18n.commaOnDayX0OfTheMonth(l)})}break}}return o},t.prototype.getYearDescription=function(){var e=this,o=this.getSegmentDescription(this.expressionParts[6],"",function(n){return/^\d+$/.test(n)?new Date(parseInt(n),1).getFullYear().toString():n},function(n){return r.StringUtilities.format(e.i18n.commaEveryX0Years(n),n)},function(n){return e.i18n.commaYearX0ThroughYearX1()||e.i18n.commaX0ThroughX1()},function(n){return e.i18n.commaOnlyInYearX0?e.i18n.commaOnlyInYearX0():e.i18n.commaOnlyInX0()});return o},t.prototype.getSegmentDescription=function(e,o,n,i,a,s){var c=null,p=e.indexOf("/")>-1,l=e.indexOf("-")>-1,g=e.indexOf(",")>-1;if(!e)c="";else if(e==="*")c=o;else if(!p&&!l&&!g)c=r.StringUtilities.format(s(e),n(e));else if(g){for(var h=e.split(","),S="",x=this.i18n.spaceAnd(),b=0;b<h.length;b++)if(b>0&&h.length>2&&(S+=",",b<h.length-1&&(S+=" ")),b>0&&h.length>1&&(b==h.length-1||h.length==2)&&(S+=x==","&&h.length>2?" ":"".concat(x," ")),h[b].indexOf("/")>-1||h[b].indexOf("-")>-1){var k=h[b].indexOf("-")>-1&&h[b].indexOf("/")==-1,D=this.getSegmentDescription(h[b],o,n,i,k?this.i18n.commaX0ThroughX1:a,s);k&&(D=D.replace(", ","")),S+=D}else if(!p)S+=n(h[b]);else{var E=this.getSegmentDescription(h[b],o,n,i,a,s);E&&E.startsWith(", ")&&(E=E.substring(2)),S+=E}p?c=S:c=r.StringUtilities.format(s(e),S)}else if(p){var h=e.split("/");if(c=r.StringUtilities.format(i(h[1]),h[1]),h[0].indexOf("-")>-1){var A=this.generateRangeSegmentDescription(h[0],a,n);A.indexOf(", ")!=0&&(c+=", "),c+=A}else if(h[0].indexOf("*")==-1){var M=r.StringUtilities.format(s(h[0]),n(h[0]));M=M.replace(", ",""),c+=r.StringUtilities.format(this.i18n.commaStartingX0(),M)}}else l&&(c=this.generateRangeSegmentDescription(e,a,n));return c},t.prototype.generateRangeSegmentDescription=function(e,o,n){var i="",a=e.split("-"),s=n(a[0],1),c=n(a[1],2),p=o(e);return i+=r.StringUtilities.format(p,s,c),i},t.prototype.formatTime=function(e,o,n){var i=0,a=0,s=parseInt(e)+i,c=parseInt(o)+a;c>=60?(c-=60,s+=1):c<0&&(c+=60,s-=1),s>=24?s=s-24:s<0&&(s=24+s);var p="",l=!1;this.options.use24HourTimeFormat||(l=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),p=l?"".concat(this.getPeriod(s)," "):" ".concat(this.getPeriod(s)),s>12&&(s-=12),s===0&&(s=12));var g="";n&&(g=":".concat(("00"+n).substring(n.length)));var h=s.toString(),S=("00"+h).substring(h.length),x=c.toString(),b=("00"+x).substring(x.length),k=this.options.trimHoursLeadingZero?h:S;return"".concat(l?p:"").concat(k,":").concat(b).concat(g).concat(l?"":p)},t.prototype.transformVerbosity=function(e,o){if(!o&&(e=e.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),e=e.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),e=e.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),e=e.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,i=Object.entries(this.i18n.conciseVerbosityReplacements());n<i.length;n++){var a=i[n],s=a[0],c=a[1];e=e.replace(new RegExp(s,"g"),c)}return e},t.prototype.getPeriod=function(e){return e>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},t.locales={},t})();v.ExpressionDescriptor=f},747(X,v,m){Object.defineProperty(v,"__esModule",{value:!0}),v.enLocaleLoader=void 0;var r=m(486),T=(function(){function f(){}return f.prototype.load=function(t){t.en=new r.en},f})();v.enLocaleLoader=T},486(X,v){Object.defineProperty(v,"__esModule",{value:!0}),v.en=void 0;var m=(function(){function r(){}return r.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},r.prototype.atX0MinutesPastTheHourGt20=function(){return null},r.prototype.commaMonthX0ThroughMonthX1=function(){return null},r.prototype.commaYearX0ThroughYearX1=function(){return null},r.prototype.use24HourTimeFormatByDefault=function(){return!1},r.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},r.prototype.everyMinute=function(){return"every minute"},r.prototype.everyHour=function(){return"every hour"},r.prototype.atSpace=function(){return"At "},r.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},r.prototype.at=function(){return"At"},r.prototype.spaceAnd=function(){return" and"},r.prototype.everySecond=function(){return"every second"},r.prototype.everyX0Seconds=function(){return"every %s seconds"},r.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},r.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},r.prototype.everyX0Minutes=function(){return"every %s minutes"},r.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},r.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},r.prototype.everyX0Hours=function(){return"every %s hours"},r.prototype.betweenX0AndX1=function(){return"between %s and %s"},r.prototype.atX0=function(){return"at %s"},r.prototype.commaEveryDay=function(){return", every day"},r.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},r.prototype.commaX0ThroughX1=function(){return", %s through %s"},r.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},r.prototype.first=function(){return"first"},r.prototype.second=function(){return"second"},r.prototype.third=function(){return"third"},r.prototype.fourth=function(){return"fourth"},r.prototype.fifth=function(){return"fifth"},r.prototype.commaOnThe=function(){return", on the "},r.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},r.prototype.lastDay=function(){return"the last day"},r.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},r.prototype.commaOnlyOnX0=function(){return", only on %s"},r.prototype.commaAndOnX0=function(){return", and on %s"},r.prototype.commaEveryX0Months=function(){return", every %s months"},r.prototype.commaOnlyInX0=function(){return", only in %s"},r.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},r.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},r.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},r.prototype.firstWeekday=function(){return"first weekday"},r.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},r.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},r.prototype.commaEveryX0Days=function(){return", every %s days in a month"},r.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},r.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},r.prototype.commaEveryHour=function(){return", every hour"},r.prototype.commaEveryX0Years=function(){return", every %s years"},r.prototype.commaStartingX0=function(){return", starting %s"},r.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},r.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},r.prototype.atReboot=function(){return"Run once, at startup"},r.prototype.onTheHour=function(){return"on the hour"},r})();v.en=m},515(X,v){Object.defineProperty(v,"__esModule",{value:!0});function m(T,f){if(!T)throw new Error(f)}var r=(function(){function T(){}return T.secondRange=function(f){for(var t=f.split(","),e=0;e<t.length;e++)if(!isNaN(parseInt(t[e],10))){var o=parseInt(t[e],10);m(o>=0&&o<=59,"seconds part must be >= 0 and <= 59")}},T.minuteRange=function(f){for(var t=f.split(","),e=0;e<t.length;e++)if(!isNaN(parseInt(t[e],10))){var o=parseInt(t[e],10);m(o>=0&&o<=59,"minutes part must be >= 0 and <= 59")}},T.hourRange=function(f){for(var t=f.split(","),e=0;e<t.length;e++)if(!isNaN(parseInt(t[e],10))){var o=parseInt(t[e],10);m(o>=0&&o<=23,"hours part must be >= 0 and <= 23")}},T.dayOfMonthRange=function(f){for(var t=f.split(","),e=0;e<t.length;e++)if(!isNaN(parseInt(t[e],10))){var o=parseInt(t[e],10);m(o>=1&&o<=31,"DOM part must be >= 1 and <= 31")}},T.monthRange=function(f,t){for(var e=f.split(","),o=0;o<e.length;o++)if(!isNaN(parseInt(e[o],10))){var n=parseInt(e[o],10);m(n>=1&&n<=12,t?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},T.dayOfWeekRange=function(f,t){for(var e=f.split(","),o=0;o<e.length;o++)if(!isNaN(parseInt(e[o],10))){var n=parseInt(e[o],10);m(n>=0&&n<=6,t?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},T})();v.default=r},823(X,v){Object.defineProperty(v,"__esModule",{value:!0}),v.StringUtilities=void 0;var m=(function(){function r(){}return r.format=function(T){for(var f=[],t=1;t<arguments.length;t++)f[t-1]=arguments[t];return T.replace(/%s/g,function(e){return f.shift()})},r.containsAny=function(T,f){return f.some(function(t){return T.indexOf(t)>-1})},r})();v.StringUtilities=m}},O={};function _(X){var v=O[X];if(v!==void 0)return v.exports;var m=O[X]={exports:{}};return y[X](m,m.exports,_),m.exports}var w={};return(()=>{var X=w;Object.defineProperty(X,"__esModule",{value:!0}),X.toString=void 0;var v=_(333),m=_(747);v.ExpressionDescriptor.initialize(new m.enLocaleLoader),X.default=v.ExpressionDescriptor;var r=v.ExpressionDescriptor.toString;X.toString=r})(),w})())})(U)),U.exports}var F=W();const N=C(F);function j(u){const d=u?.execution_config?.executor;if(d&&typeof d=="object"&&"kind"in d){if(d.kind==="external")return"external";if(d.kind==="script")return"script"}return u?.device_worker_id?"device":u?.managed_agent_id?"agent":"manual"}function K(u){const d=j(u);return d==="agent"||d==="device"?u?.managed_agent_id??null:null}function Y(u){try{return N.toString(u.trim(),{throwExceptionOnParseError:!0})}catch{return`On schedule ${u.trim()}`}}function Z(u,d){return d.get(u)??u}function B(u){return R(u.replace(/^\$/,""))}function $(u,d){const y=d?.display_name?.trim();return y&&d?.external_tenant_id===u?y:`#${u}`}function V(u,d){if(!u||typeof u!="object"||Array.isArray(u))return"";const y=u;return typeof y.repository=="string"?` in ${y.repository}`:typeof y.channel_id=="string"?` in ${$(y.channel_id,d)}`:typeof y.resource_ref=="string"?` for ${y.resource_ref}`:""}function P(u){return Array.isArray(u.triggers)?u.triggers.filter(d=>!!d&&typeof d=="object"):[]}function G(u,d,y){if(u.kind==="schedule"&&typeof u.cron=="string")return Y(u.cron);if(u.kind==="event"&&u.source!=="workspace"&&typeof u.connector_key=="string"){const O=Array.isArray(u.event_types)?u.event_types.filter(X=>typeof X=="string"):[],_=O.length>0?O.join(" or "):"an event",w=typeof u.connection_id=="number"?y.get(u.connection_id):void 0;return`${Z(u.connector_key,d)} sends ${_}${V(u.match,w)}`}if(u.kind==="event"&&u.source==="workspace"){const O=Array.isArray(u.event_types)?u.event_types.filter(X=>typeof X=="string"):[],_=O.length>0?O.join(" or "):"an event",w=typeof u.entity_type=="string"?` on ${B(u.entity_type)}`:"";return`another Automation writes ${_}${w}`}return null}function z(u){return u.health==="degraded"?"error":"enabled"}function J(u,d=new Map,y=new Map){const O=P(u),_=u.name?.trim()||"Untitled automation",w=O.some(f=>f.kind==="event"),X=O.some(f=>f.kind==="schedule"),v=w?"event":X?"schedule":"manual",m=O.map(f=>G(f,d,y)).filter(f=>!!f);let r="When started manually";m.length===1?r=`When ${m[0]}`:m.length>1&&(r=`When ${m[0]}${m.slice(1).map(f=>`, or when ${f}`).join("")}`);const T=O.some(f=>f.kind==="event"&&f.output==="reply_to_source")?"source":"silent";return{key:`automation:${u.automation_id}`,kind:v,when:r,does:_,output:{destination:T},state:z(u),sortTime:u.next_run_at?Date.parse(u.next_run_at):null,automation:u}}const L={event:0,schedule:1,manual:2};function Q(u,d=new Map,y=new Map){return u.map(O=>J(O,d,y)).sort((O,_)=>O.state!==_.state?O.state==="enabled"?-1:1:L[O.kind]!==L[_.kind]?L[O.kind]-L[_.kind]:O.sortTime!==_.sortTime?O.sortTime===null?1:_.sortTime===null?-1:O.sortTime-_.sortTime:O.when.localeCompare(_.when)||O.key.localeCompare(_.key))}const ee={kind:"all",output:"any",state:"any"};function te(u,d){return u.filter(y=>(d.kind==="all"||y.kind===d.kind)&&(d.output==="any"||(d.output==="reply"?y.output.destination==="source":y.output.destination==="silent"))&&(d.state==="any"||(d.state==="active"?y.state==="enabled":y.state==="error")))}function ne(u){const d=Array.isArray(u.triggers)?u.triggers:[];for(const y of d)if(y&&typeof y=="object"&&y.kind==="event"&&y.source!=="workspace"&&typeof y.connector_key=="string")return y.connector_key;return null}export{ee as D,j as a,K as b,N as c,J as d,ne as e,te as f,Q as m};
|
|
2
|
-
//# sourceMappingURL=model-C2q7WDcS.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j4 as r,j as m}from"./index-BjcZVe7n.js";import{a as i}from"./agents-workbench-CDpJmUVN.js";import"./agent-editor-form-BXQBFHSv.js";import"./definition-comparison-B5WgZILB.js";import"./automation-source-list-Dhucq1sI.js";import"./schema-value-BFb7jCBo.js";import"./json-diff-DtZtra_g.js";import"./index-Vcq4gwWv.js";import"./model-selector-B2cjCn0V.js";import"./proposal-review-shell-BED-DO9C.js";import"./runs-BntGAKQG.js";import"./nav-pill-Bam6s3jj.js";function R(){const{owner:o,agentId:t}=r.useParams();return m.jsx(i,{owner:o,agentId:t,tab:"models"})}export{R as component};
|
|
2
|
-
//# sourceMappingURL=models-CZkH5gtj.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as o}from"./index-BjcZVe7n.js";function i(e,n){return o("inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",n,e?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground")}export{i as n};
|
|
2
|
-
//# sourceMappingURL=nav-pill-Bam6s3jj.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{hC as o,c as p,a6 as x,q as b,at as h,bb as w,j as a,ak as f,al as j,gS as A,b3 as L,gT as C,L as S,gU as N,f5 as k,b2 as y,c5 as E}from"./index-BjcZVe7n.js";import{A as O}from"./agent-editor-form-BXQBFHSv.js";import"./definition-comparison-B5WgZILB.js";import"./automation-source-list-Dhucq1sI.js";import"./schema-value-BFb7jCBo.js";import"./json-diff-DtZtra_g.js";import"./index-Vcq4gwWv.js";import"./model-selector-B2cjCn0V.js";function M(){const{owner:e}=o.useParams(),t=o.useSearch(),r=p(),i=x(),{isAuthenticated:c}=b(),{isMember:g,isLoading:m}=h(),n=c&&g,{data:u=[],isLoading:d}=w({enabled:n});return a.jsx(f,{className:"gap-3 pt-2.5 pb-8",children:a.jsxs(j,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(A,{breadcrumb:a.jsx(C,{crumbs:[a.jsx(S,{to:"/$owner/agents",params:{owner:e},className:N,children:"Agents"},"agents")]}),icon:a.jsx(L.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),m||n&&d?a.jsx(k,{rows:1}):n?a.jsx(O,{mode:{kind:"create"},existingAgentIds:u.map(s=>s.agentId),onCreated:async s=>{const l=["agents",e];if(await i.refetchQueries({queryKey:l,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/settings",params:{owner:e,agentId:s},search:{run_id:void 0}})}}):a.jsx(y,{icon:E,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{M as component};
|
|
2
|
-
//# sourceMappingURL=new-BJst6K0b.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as S,at as C,aH as k,aB as A,bb as T,r as g,j as e,ak as L,al as B,gT as P,L as p,gU as R,d1 as $,S as f,hm as w,az as I}from"./index-BjcZVe7n.js";import{C as O,A as D}from"./create-automation-form-C9PMX7N8.js";import"./model-C2q7WDcS.js";import"./entity-options-BkU_En_f.js";import"./connection-label-BobuYiAG.js";import"./use-automations-D9hKpufo.js";import"./model-selector-B2cjCn0V.js";import"./skill-editor-D_W3QlRz.js";import"./json-diff-DtZtra_g.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-CJGCatFS.js";import"./automation-source-list-Dhucq1sI.js";function E(n){return n.includes(":")?n.slice(n.indexOf(":")+1):n}function F({prefillAgentId:n,onCancel:t,initialTriggers:l,conversationSetup:h}){const{org:a}=C(),[c,d]=g.useState({ready:!1,triggers:[]}),[u,N]=g.useState(),o=g.useCallback(s=>{d(m=>JSON.stringify(m)===JSON.stringify(s)?m:s)},[]),r=u??l;return e.jsx(O,{startFromScratch:!!l,organizationId:a?.id??"",prefillAgentId:n,conversationSetup:h,onClose:t,onPrefillTriggers:s=>N(s.length>0?s:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!c.ready,createFields:{triggers:c.triggers},triggerFields:e.jsx(D,{organizationId:a?.id??null,initialTriggers:r,onChange:o},JSON.stringify(r??"new"))})}function z({owner:n,prefilled:t}){const l=S(),{org:h}=C(),a=k(h?.id??null,{status:"active",limit:500}),c=A(h?.id??null),{data:d=[]}=T(),u=!!(t?.platform&&(t.listen||t.resource)),N=u&&(a.isLoading||c.isLoading),o=g.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const x=a.data??[],j=t.connection?x.find(i=>i.slug===t.connection):(()=>{const i=x.filter(v=>v.connector_key!==t.platform?!1:t.resource?!0:v.facets.chat&&(v.external_tenant_id??"")===(t.team??""));return i.length===1?i[0]:void 0})();if(t.connection&&!j)return;const b=t.events?.split(",").map(i=>i.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...j?{connection_id:j.id}:{},event_types:b.length>0?b:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:E(t.listen??"")},execution:"turn",active_run:t.listen?"steer":"queue",output:t.listen?"reply_to_source":"silent",skip_if_unchanged:!t.listen}]},[a.data,t]),r=c.data?.find(x=>x.key===t?.platform)?.name,s=t?.label??t?.listen,m=g.useMemo(()=>t?.listen&&o&&s?{name:r?`${r}: ${s}`:s}:void 0,[s,r,o,t?.listen]),y=()=>void l({to:"/$owner/automations",params:{owner:n}}),_=o?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:u&&!a.isLoading?"Choose the matching connection and event, then define the reaction.":"Start from a template, from scratch, or clone an existing Automation.";return e.jsx(L,{className:"gap-6 pt-2.5 pb-8",children:e.jsxs(B,{className:"flex min-w-0 flex-col gap-4",children:[e.jsx(P,{crumbs:[e.jsx(p,{to:"/$owner/automations",params:{owner:n},className:R,children:"Automations"},"automations")],current:"New automation"}),e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:e.jsxs("h1",{className:"flex min-w-0 items-center gap-2 truncate font-display text-xl font-semibold",children:[e.jsx($,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"New automation"]})})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:_}),m&&!t?.agent?e.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.length===0?"This workspace has no agents yet. ":"Choose the agent that answers here, or ",e.jsx(p,{to:"/$owner/agents/new",params:{owner:n},search:t,className:"underline underline-offset-4",children:d.length===0?"Create an agent":"create an agent"})," ","and come back to finish this setup."]}):null,N?e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"h-10 w-full"}),e.jsx(f,{className:"h-32 w-full"})]}):u&&t?.connection&&!o?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"This connection is no longer available. Reopen setup from your conversation."}):e.jsx(F,{prefillAgentId:t?.agent,onCancel:y,initialTriggers:o,conversationSetup:m})]})})}function K(){const{owner:n}=w.useParams(),t=w.useSearch();return e.jsx(I,{owner:n,children:()=>e.jsx(z,{owner:n,prefilled:t})})}export{K as component};
|
|
2
|
-
//# sourceMappingURL=new-DgbivfDe.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,dw as H,js as A,jt as V,ju as z,jv as q,jw as U,r as f,hA as G,u as C,aB as W,aH as Q,S as b,iM as Y,B as N,jx as Z,jy as R,jz as J,d3 as X,o as S,aq as D,cm as F,ab as I,eI as ee,v as te,l as se,fS as ne,w as re,L as $,jA as ie,fA as oe,fV as ae,fO as ce,jB as le,g1 as E,cz as de,az as ue,jC as me,at as pe,k as xe,jD as he,cP as fe,ec as ye,cQ as ge,p as je,gy as ve,eC as Ne,jE as we,ek as be,jF as ke,eH as Ae,a0 as Ce,jG as Se}from"./index-BjcZVe7n.js";import{u as Ie,A as Pe}from"./automation-detail-content-Bs3vwAPd.js";import{A as Le}from"./agent-loading-shells-_18OREnx.js";import{s as _e,h as Re,R as Te,A as $e}from"./agent-thread-FyEO-y44.js";import{C as Ee,b as Oe,A as ze}from"./connection-feed-detail-Ckq-qEbD.js";import{O as De}from"./connect-menu-CezOH3s7.js";import{a as Fe}from"./connections-browser-BXsJqieG.js";import{f as Be}from"./connector-scope-lists-dQnZARCD.js";import{S as Me}from"./source-record-panels-m8gECt82.js";import{E as T}from"./events-feed-CGzA1w3R.js";import{S as Ke}from"./schema-type-editor-panel-v3nR2Oa2.js";import{c as He,s as Ve,k as qe}from"./renderer-CHPS-1vD.js";import{E as Ue}from"./event-detail-CmC-DVrK.js";import{V as Ge,R as We}from"./views-access-required-CZ1fvAks.js";import{R as Qe,b as Ye}from"./event-card-CjA_dLzq.js";import{V as Ze,a as Je}from"./view-param-filters-CDvwie_f.js";import{S as Xe,g as et}from"./runs-table-CYS1jDdL.js";import{R as tt}from"./runs-panel-BwTVaRsE.js";import{b as st}from"./use-automations-D9hKpufo.js";import{b as nt}from"./model-C2q7WDcS.js";import"./create-automation-form-C9PMX7N8.js";import"./entity-options-BkU_En_f.js";import"./connection-label-BobuYiAG.js";import"./model-selector-B2cjCn0V.js";import"./skill-editor-D_W3QlRz.js";import"./json-diff-DtZtra_g.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-CJGCatFS.js";import"./automation-source-list-Dhucq1sI.js";import"./proposal-review-shell-BED-DO9C.js";import"./runs-BntGAKQG.js";import"./definition-comparison-B5WgZILB.js";import"./schema-value-BFb7jCBo.js";import"./app-bridge-C4nPtae3.js";import"./pending-seed-BP3xHM2d.js";import"./feed-event-kinds-BYuZCoU4.js";import"./status-dot-BnQPFrcU.js";import"./client-activity-scopes-BD2HBo-_.js";import"./client-rows-x_CxeWkP.js";import"./use-scroll-sentinel-BWCrmNIB.js";import"./entity-type-page-D0ghgRgq.js";import"./change-summary-DeuXQEpb.js";import"./card-g4yxo4Hr.js";import"./table-DALHuXPE.js";import"./dynamic-schema-form-qWSRtOAv.js";import"./filter-bar-CQ_oE7a9.js";import"./record-session-DOFgdd43.js";import"./run-initiator-CCxNv0rK.js";import"./clients-Cmp0LmOp.js";import"./copy-button-Ddf7lBjZ.js";import"./agent-list-row-BnP6r4pm.js";import"./automation-row-B5Q1B10y.js";import"./manage-gear-C-0BAMbC.js";function rt(t){if(!t||typeof t!="object")return[];const n=t.properties;if(!n)return[];const s=Array.isArray(t.required)?new Set(t.required.map(String)):new Set;return Object.entries(n).map(([r,i])=>({name:r,type:String(i.type??"any"),required:s.has(r),description:typeof i.description=="string"?i.description:void 0}))}function it({fields:t}){return t.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No fields."}):e.jsx("ul",{className:"space-y-2",children:t.map(n=>e.jsxs("li",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[e.jsx("code",{className:"text-xs font-medium text-foreground",children:n.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:n.type}),n.required?e.jsx("span",{className:"text-[10px] font-medium text-amber-600 dark:text-amber-400",children:"required"}):null]}),n.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:n.description}):null]},n.name))})}function P({item:t,hideHeading:n=!1}){const s=t.schemaSections;return s?e.jsxs("article",{className:n?"space-y-4":"space-y-4 px-5 py-5",children:[!n&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("h2",{className:"text-base font-medium text-foreground",children:t.title}),s.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}):null]})]}),s.sections.map(r=>{const i=rt(r.schema);return e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:r.title}),r.description?e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:r.description}):null]}),e.jsx(it,{fields:i})]},r.title)})]}):null}function ot({actions:t}){const n=Object.entries(t).map(([s,r])=>{const i=r;return{id:s,name:i.name??s,description:i.description,action:i}});return e.jsx(A,{entries:n,label:"actions",renderDetail:({name:s,action:r})=>e.jsx(P,{hideHeading:!0,item:{href:"",title:s,schemaSections:z(r)}})})}function at({feeds:t}){const n=Object.entries(t).map(([s,r])=>{const i=r;return{id:s,name:i.name??s,description:i.description,feed:i}});return e.jsx(A,{entries:n,label:"feed types",renderDetail:({name:s,feed:r})=>e.jsx(P,{hideHeading:!0,item:{href:"",title:s,schemaSections:V(r)}})})}function ct(t){const n=[];return t.forEach((s,r)=>{n.push({id:`sep:${s.runId}`,role:"system",parts:[{type:"text",text:lt(s,r)}],createdAt:s.completedAt?new Date(s.completedAt).getTime():void 0});for(const i of s.messages)n.push({...i,id:`r${s.runId}:${i.id}`})}),n}function lt(t,n){const s=(t.pendingActionCount??0)>0?`Waiting for you (${t.pendingActionCount})`:t.status==="completed"?"Completed":t.status??"Completed",r=(t.autoAppliedCount??0)>0?` · ${t.autoAppliedCount} applied automatically`:"",i=t.completedAt?new Date(t.completedAt).toLocaleString():null;return i?`Run ${n+1} · ${s}${r} · ${i}`:`Run ${n+1} · ${s}${r}`}const B=Symbol("trusted-automation-interaction");function dt(t){return Object.defineProperty(t,B,{value:!0}),t}function ut(t){return{title:`${t} items waiting for you`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:[{type:"text",value:"Review the individual proposals below, or decide the whole run at once.",muted:!0}],actions:[{id:"approve-all",label:"Approve all",variant:"primary",icon:"check",confirm:!0,confirmPrompt:`Approve all ${t} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${t} proposals.`},{id:"reject-all",label:"Reject all",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${t} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${t} proposals.`}]}}const mt=new Set(["automation-approval-batch"]);function pt(t){return new Promise(n=>{t({onSettled:(s,r)=>n(!!r)})})}function xt(){const t=q(),n=U();return f.useMemo(()=>({toolNames:mt,resolve:(s,r)=>{if(!r||typeof r!="object"||r[B]!==!0)return null;const i=r;if(s==="automation-approval-batch"){const o=typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0?i.runId:null,c=typeof i.count=="number"&&Number.isSafeInteger(i.count)&&i.count>1?i.count:null,a=Array.isArray(i.runIds)?i.runIds.filter(l=>typeof l=="number"&&Number.isSafeInteger(l)&&l>0):[];return o===null||c===null||a.length!==c||new Set(a).size!==c?null:{view:ut(c),handlers:{manage_operations:l=>l.action!=="approve"&&l.action!=="reject"?Promise.resolve(!0):pt(p=>l.action==="approve"?t.mutate({run_id:o,run_ids:a},p):n.mutate({run_id:o,run_ids:a},p))}}}return null}}),[t,n])}const ht=/(?:^|\n)Run this Automation now/;function ft(t){return t.role==="user"&&t.parts.some(n=>n.type==="text"&&ht.test(n.text))}function yt(t){return`history-interaction:${t.runId}:${t.eventId??"error"}`}function gt({agentId:t,automationId:n,ownerSlug:s,runId:r}){const{data:i,isLoading:o}=G(t,n,{orgSlug:s,...r!=null?{runId:r}:{}}),c=xt(),a=C(),l=f.useCallback(d=>{a?.open({href:`/${s}/automations/${n}?view=activity&run_id=${d}`,title:`Automation run #${d}`,runId:d})},[a,s,n]),p=f.useMemo(()=>{const d=i?.runs??[],j=(r!=null?d.filter(m=>m.runId===r):d).slice().reverse();return ct(j.map(m=>{const g=m.messages.map(u=>_e(u,{showToolCalls:!0})).filter(u=>u!==null&&!ft(u));m.task?.trim()&&g.unshift({id:"task",role:"user",parts:[{type:"text",text:m.task.trim()}]});const v=m.actions??[],h=v.filter(u=>u.status==="pending");if(h.length>1){const u=h.map(x=>x.runId).sort((x,k)=>x-k);g.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${m.runId}`,toolName:"automation-approval-batch",args:dt({runId:m.runId,count:h.length,runIds:u})}]})}for(const u of v){const x=Re([u],{workspaceSlug:s,agentId:t,webOrigin:typeof window>"u"?null:window.location.origin});x&&g.push({...x,id:yt(u)})}return{runId:m.runId,completedAt:m.completedAt,status:m.status,pendingActionCount:m.pendingActionCount,autoAppliedCount:m.autoAppliedCount,messages:g}}))},[t,i,s,r]);return o?e.jsx(Le,{readOnly:!0}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No run transcripts yet. Recent runs will show here when the Automation fires (failed runs appear with their prompt even without a full transcript)."}):e.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:e.jsx(Te,{messages:p,workspaceSlug:s,children:e.jsx($e,{readOnly:!0,readerPositionMode:"runs",interactionExtension:c,onRunSelect:r==null&&a?l:void 0})})})}function jt({panel:t}){const n=W(t.organizationId),s=t.section==="connections"||!!t.connectionId,r=Q(t.organizationId,{connectorKey:t.connectorKey,connectionIds:t.connectionId?[t.connectionId]:void 0,enabled:s}),i=n.data?.find(c=>c.key===t.connectorKey),o=r.data?.find(c=>c.id===t.connectionId&&c.connector_key===t.connectorKey);return n.isLoading||s&&r.isLoading?e.jsx("div",{className:"p-5",children:e.jsx(b,{className:"h-28 w-full"})}):n.isError||s&&r.isError?e.jsx("p",{role:"alert",className:"p-5 text-sm",children:"Could not load this connector. Close the pane and try again."}):t.connectionId&&!o||!i&&!o&&t.section!=="connections"?e.jsx("p",{className:"p-5 text-sm",children:"This connection is no longer available."}):e.jsx("div",{className:"p-5",children:t.section==="connections"?e.jsx(Fe,{connections:r.data??[],connector:i,connectorKey:t.connectorKey,ownerSlug:t.ownerSlug}):o?e.jsx(wt,{connection:o,connector:i,panel:t}):i?t.section==="oauth-apps"?e.jsx(De,{connector:i,organizationId:t.organizationId,newApp:!!t.newApp}):t.section==="feeds"?e.jsx(vt,{connector:i}):i.installed===!1?e.jsx(Nt,{connector:i,ownerSlug:t.ownerSlug}):e.jsx(kt,{connector:i,ownerSlug:t.ownerSlug}):null},`${t.connectorKey}:${t.connectionId??"connector"}:${t.section}`)}function vt({connector:t}){return e.jsx(at,{feeds:t.feeds_schema??{}})}function Nt({connector:t,ownerSlug:n}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection."," ",e.jsx(R,{ownerSlug:n,connectorKey:t.key})]}),e.jsx(ot,{actions:t.actions_schema??{}})]})}function wt({connection:t,connector:n,panel:s}){const[r,i]=f.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:r,children:s.section==="feeds"?e.jsx(bt,{connection:t,connector:n,ownerSlug:s.ownerSlug}):e.jsx(Y,{connection:t,ownerSlug:s.ownerSlug,inPeek:!0,onReviewPermissions:n?()=>i(!0):void 0})}),r&&n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>i(!1),children:"Back to actions"}),e.jsx("h2",{className:"text-base font-semibold",children:"Provider permissions"}),e.jsx(Z,{connection:t,connectorDef:n})]})]})}function bt({connection:t,connector:n,ownerSlug:s}){const{data:r=[],isLoading:i,isError:o}=X(t.id),[c,a]=f.useState(!1),l=t.facets?.chat??!1;if(i)return e.jsx(b,{className:"h-28 w-full"});if(o)return e.jsx("p",{role:"alert",children:"Could not load sources. Close the pane and try again."});const p=r.map(d=>({id:String(d.id),name:d.display_name||d.feed_key,status:Be(d)??(d.operations.includes("sync")?"Sync enabled":"Live access"),feed:d}));return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:c,children:e.jsx(A,{entries:p,label:l?"channels":"feeds",action:Object.keys(n?.feeds_schema??{}).length>0?e.jsx(N,{size:"sm",variant:"outline",onClick:()=>a(!0),children:l?"Add channel":"Add feed"}):void 0,renderDetail:({feed:d})=>d.store==="channel_messages"?e.jsx(Ee,{feed:d,hideHeader:!0}):e.jsx(Oe,{feed:d,connectorDef:n,ownerSlug:s})})}),c&&n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold",children:l?"Add channel":"Add feed"}),e.jsx(ze,{organizationId:t.organization_id,connections:[t],connectorDefinitions:[n],onClose:()=>a(!1)})]})]})}function kt({connector:t,ownerSlug:n}){const{data:s=[],isLoading:r,isError:i}=J(t.key);if(r)return e.jsx(b,{className:"h-28 w-full"});if(i)return e.jsx("p",{role:"alert",children:"Could not load actions. Close the pane and try again."});const o=t.actions_schema??{},c=s.map(a=>({id:a.operation_key,name:a.name??a.operation_key,description:a.description,operation:a}));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection. Click an action to inspect its inputs."," ",e.jsx(R,{ownerSlug:n,connectorKey:t.key})]}),e.jsx(A,{entries:c,label:"actions",renderControl:()=>e.jsx(R,{ownerSlug:n,connectorKey:t.key}),renderDetail:({operation:a,name:l})=>o[a.operation_key]?e.jsx(P,{hideHeading:!0,item:{href:"",title:l,schemaSections:z(o[a.operation_key])}}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No input fields."})})]})}function At({owner:t,path:n}){const{data:s,isLoading:r}=S(t,{slug:t}),i=s?.workspace,o=i?.type==="organization"?i.id:null,c=o?{slug:t}:void 0,{data:a,isLoading:l}=D(`/${t}/${F(n)}`,c),p=a?.entity,d=p?.id;return r||l?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(I,{className:"mr-2"})," Loading…"]}):o?d==null?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't find this record. It may have been deleted, or it may live in a workspace you can't access."}):p?.is_derived?e.jsx(Me,{record:{type:p.entity_type,key:p.slug},orgContext:c}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(T,{organizationId:o,ownerSlug:t,entityId:typeof d=="number"?d:void 0,filters:{sortBy:"date",sortOrder:"desc"},emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to this record yet."})})}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."})}function Ct(t){if(Array.isArray(t.enum))return`One of ${t.enum.length}`;if(t.format==="date"||t.format==="date-time")return"Date";if(t.format==="uri")return"Link";if(t.format==="email")return"Email";const n=Array.isArray(t.type)?t.type[0]:t.type;return n==="array"?"List":n==="object"?"Group":n==="integer"||n==="number"?"Number":n==="boolean"?"Yes / no":"Text"}function St({owner:t,typeSlug:n,view:s}){const{data:r,isLoading:i}=S(t,{slug:t}),o=r?.workspace,c=o?.type==="organization"?o.id:null,{isAdmin:a}=ee(c??void 0),{orgContext:l}=te(),{data:p,isSuccess:d}=se(l),y=(p??[]).find(w=>w.slug===n),j=d&&!y,m=`/${t}/${ne(n)}`,{pathname:g}=re(),v=g===m||g===`${m}/`||g.startsWith(`${m}/-/`),h=f.useMemo(()=>He(y?.metadata_schema),[y?.metadata_schema]),u=C(),x=u?.close;f.useEffect(()=>{j&&x?.()},[j,x]);const k=f.useMemo(()=>({entityTypes:[n],sortBy:"date",sortOrder:"desc"}),[n]);if(i)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(I,{className:"mr-2"})," Loading…"]});if(j)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This entity type no longer exists."});if(!c)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."});const K=y?.name??n;return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-4 py-2.5",children:[v?null:e.jsx(N,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs($,{...oe(t,n),children:[e.jsx(ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Browse records"]})}),y&&!v&&!ae(y)&&y.entity_count!==0?e.jsx(N,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs($,{to:"/$owner/$entityType/-/$shape",params:{owner:t,entityType:n,shape:"graph"},search:le(E(t,n)),children:[e.jsx(ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Graph"]})}):null,s!=="activity"&&u?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"ml-auto h-8 gap-1.5 text-xs text-muted-foreground hover:text-foreground",onClick:()=>u.open({href:E(t,n,"activity"),title:`${K} activity`}),children:[e.jsx(de,{className:"h-3.5 w-3.5"}),"Activity"]}):null]}),s==="activity"?e.jsx("div",{className:"px-4 py-4",children:e.jsx(T,{organizationId:c,ownerSlug:t,filters:k,showEntityLinks:!0,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to these records yet."})})}):a?e.jsx("div",{className:"p-4",children:e.jsx(Ke,{slug:n,onClose:()=>x?.()})}):h.length>0?e.jsxs("section",{"aria-labelledby":"entity-type-peek-fields",className:"px-4 py-4",children:[e.jsx("h3",{id:"entity-type-peek-fields",className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Fields"}),e.jsx("dl",{className:"divide-y divide-border/60 text-sm",children:h.map(w=>e.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1.5",title:w.prop.description,children:[e.jsx("dt",{className:"min-w-0 truncate",children:Ve(w)}),e.jsx("dd",{className:"shrink-0 text-xs text-muted-foreground",children:Ct(w.prop)})]},w.key))})]}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This type has no fields yet."})]})}function It({owner:t,eventId:n,viewKey:s}){const r=C(),i=(o,c)=>e.jsx(Ue,{owner:c,organizationId:o,eventId:n,viewKey:s,dense:!0,onSelectView:r?a=>r.retarget(a):void 0},`${c}/${n}/${s??""}`);return e.jsx("div",{className:"px-4 py-4",children:t==="me"?i(null,t):e.jsx(ue,{owner:t,children:({organizationId:o,ownerSlug:c})=>o?i(o,c):e.jsx("div",{className:"h-40 animate-pulse rounded-md bg-muted/40"})})})}function L({owner:t,runId:n,runIds:s,contentIds:r}){const{data:i,isLoading:o}=S(t==="me"?null:t,{slug:t}),c=i?.workspace,a=t!=="me"&&c?.type==="organization"?c.id:null,l=f.useMemo(()=>{if(t==="me")return r?.length?{contentIds:r,sortBy:"date",sortOrder:"desc"}:void 0;const d=s??(n!=null?[n]:void 0);if(!(!d?.length&&!r?.length))return{...d?.length?{runIds:d}:{},...r?.length?{contentIds:r}:{}}},[t,r,n,s]),p=l!=null;return t!=="me"&&o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(I,{className:"mr-2"})," Loading…"]}):t!=="me"&&a==null?e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):p?e.jsx("div",{className:"px-4 py-4",children:e.jsx(T,{presentation:"detail",organizationId:a,ownerSlug:t,filters:l,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:n!=null||s?.length?"No matching events from this run yet.":"No matching events yet."})})}):e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing to preview."})}const _=25;function Pt({target:t}){const[n,s]=f.useState(0),{data:r,isLoading:i,isError:o,refetch:c}=me(t.entityId,t.orgContext,{relationshipType:t.relationshipType,limit:_,offset:n}),a=r?.total;return e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.label," · ",t.entityName,a!==void 0?` · ${a} current ${a===1?"link":"links"}`:r?` · ${r.rows.length} shown`:""]}),e.jsx(Qe,{count:r?.failures?.length??0,onRetry:()=>void c()}),i?e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"h-6 w-full"}),e.jsx(b,{className:"h-6 w-full"})]}):o||!r?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Could not load these links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void c(),children:"Retry"})]}):r.rows.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No links on this page."}):e.jsx("ul",{className:"divide-y divide-border",children:r.rows.map(l=>e.jsx("li",{className:"flex items-center justify-between gap-3 py-1.5",children:e.jsx(Ye,{row:l,entityId:t.entityId,ownerSlug:t.ownerSlug,orgContext:t.orgContext})},l.id))}),r&&(n>0||r.hasMore)?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:n===0,onClick:()=>s(Math.max(0,n-_)),children:"Previous"}),e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[r.rows.length," shown",a===void 0?"":` of ${a}`]}),e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:!r.hasMore,onClick:()=>s(n+_),children:"Next"})]}):null]})}function Lt({owner:t,path:n,viewKey:s}){const[r,i]=f.useState({}),{data:o,isLoading:c}=S(t,{slug:t}),a=o?.workspace,l=a?.type==="organization"?a.id:null,p=l?{slug:t,organizationId:l}:void 0,{data:d,isLoading:y}=D(`/${t}/${F(n)}`,p),{isMember:j,isPublic:m,isLoading:g}=pe(t),v=j||m,h=xe({slug:t,organizationId:j?l:null}),u=d?.entity;if(c||y||g||v&&h.isLoading)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(I,{className:"mr-2"})," Loading…"]});if(!v)return e.jsx(Ge,{});if(h.isError)return e.jsx(Ze,{onRetry:()=>void h.refetch()});const x=u?he(h.data??[],{type:u.entity_type,id:u.id??u.slug}).find(k=>k.key===s):void 0;return!l||!u||!x?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This view isn't attached to this record any more."}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(Je,{orgSlug:t,viewKey:x.key,scope:{type:u.entity_type,entity:u.is_derived?u.slug:u.id??u.slug},params:r,onParamsChange:i,contentHash:x.content_hash,title:x.name,minHeight:320})})}function M({owner:t,runId:n}){const s=fe({queryKey:["run-outcome",t,n],queryFn:async()=>{const i=await ge("manage_operations",{action:"get_run",run_id:n},{slug:t});if(!i.run)throw new Error(i.error||"Run not found");return i.run},enabled:t!=="me",staleTime:15e3,refetchInterval:i=>["pending","claimed","running"].includes(i.state.data?.status??"")?5e3:!1});if(t==="me")return null;if(s.isLoading)return e.jsx("p",{role:"status",className:"px-4 pt-4 text-xs text-muted-foreground",children:"Loading run…"});if(!s.data)return e.jsx("p",{role:"alert",className:"px-4 pt-4 text-sm text-destructive",children:"Could not load this run."});const r=s.data;return e.jsxs("section",{"aria-label":"Run outcome",className:"space-y-2 border-b px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Xe,{status:et(r.status),children:r.status}),e.jsx("time",{dateTime:r.created_at,className:"text-xs text-muted-foreground",children:ye(r.created_at)})]}),r.connection_display_name?e.jsx("p",{className:"text-sm",children:r.connection_display_name}):null,r.error_message?e.jsx("p",{className:"whitespace-pre-wrap break-words text-sm text-destructive",children:r.error_message}):null,s.isError?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Could not refresh this run. Showing its last known outcome."}):null]})}function Rs({item:t}){const n=C();if(t.connectorPanel)return e.jsx(jt,{panel:t.connectorPanel});if(t.schemaSections)return e.jsx(P,{item:t});if(t.recordField)return e.jsx(We,{target:t.recordField});if(t.recordPeer)return e.jsx(qe,{target:t.recordPeer});if(t.recordLinks)return e.jsx(Pt,{target:t.recordLinks});if(typeof t.browserUrl=="string"&&t.browserUrl.length>0)return e.jsx(O,{item:t});const s=t.href?je(t.href):null;return s?s.kind==="runs"?e.jsx("section",{"aria-label":"Runs history",className:"p-4",children:e.jsx(tt,{scope:{workspace:!0},ownerSlug:s.owner,filterState:s.filters,onFilterChange:r=>n?.retarget(ve(s.owner,r))})}):s.kind==="memory"?"runId"in s?e.jsxs(e.Fragment,{children:[e.jsx(M,{owner:s.owner,runId:s.runId}),e.jsx(L,{owner:s.owner,runId:s.runId})]}):"runIds"in s?e.jsx(L,{owner:s.owner,runIds:s.runIds}):e.jsx(L,{owner:s.owner,contentIds:s.contentIds}):s.kind==="entity"?e.jsx(At,{owner:s.owner,path:s.path}):s.kind==="entity-type"?e.jsx(St,{owner:s.owner,typeSlug:s.typeSlug,view:s.view}):s.kind==="record-view"?e.jsx(Lt,{owner:s.owner,path:s.path,viewKey:s.viewKey}):s.kind==="event"?e.jsx(It,{owner:s.owner,eventId:s.eventId,viewKey:s.viewKey}):t.runId?e.jsx(_t,{owner:s.owner,automationId:s.automationId,runId:t.runId}):e.jsx(Rt,{owner:s.owner,automationId:s.automationId}):e.jsx(O,{item:t})}function O({item:t}){const n=t.body,s=t.notificationType??"generic",r=t.createdAt,i=t.browserUrl??null,o=t.browserHandoff??null;return e.jsxs("article",{className:"space-y-4 px-5 py-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ne,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:we(s)}),r?e.jsx("span",{children:be(r)}):null]})]}),n?e.jsx("div",{className:"text-sm leading-6 text-foreground/90",children:e.jsx(ke,{text:n,linkPolicy:s==="action_approval_needed"?"app-links":"strip"})}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional details were provided."}),t.owner&&t.sourceAttribution?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground/80",children:"Generated from"}),e.jsx(Ae,{owner:t.owner,source:t.sourceAttribution,className:"text-xs"})]}):null,i?e.jsx("div",{className:"space-y-2",children:o?.state==="expired"?e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:o.error_message??"This draft expired before the page was opened."}):o?.state==="completed"||o?.state==="preparing"?e.jsx("p",{className:"text-sm text-muted-foreground",children:o.state==="preparing"?"Preparing draft — keep your browser tab open.":"Draft prepared — review and post in your browser."}):e.jsxs(N,{type:"button",size:"sm",className:"h-8 text-sm",onClick:()=>{Se(i)},children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Open post"]})}):null]})}function _t({owner:t,automationId:n,runId:s}){const{organizationId:r}=Ie(t),i=st(n,void 0,r),o=nt(i.data?.automation);return o?e.jsx(gt,{agentId:o,automationId:n,ownerSlug:t,runId:s}):i.isLoading?e.jsx(b,{className:"h-24 w-full rounded-lg"}):e.jsx(M,{owner:t,runId:s})}function Rt({owner:t,automationId:n}){return e.jsx(Pe,{owner:t,agentId:null,automationId:n,view:"activity",onDone:()=>{}})}export{Rs as PeekPaneContent};
|
|
2
|
-
//# sourceMappingURL=peek-pane-content-Cq8P38s3.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{v as i,eI as r,j as e,j3 as c}from"./index-BjcZVe7n.js";import{A as m}from"./agent-permissions-matrix-DSjidWHL.js";import{A as g,a as l}from"./agent-tab-intro-DKrC3SQt.js";function x({owner:n,agentId:s}){const{orgContext:t}=i(),{isAdmin:a,isLoading:o}=r(t.organizationId);return e.jsx(g,{children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(l,{description:"Control which data, agent settings, and connector actions this agent may use automatically, with approval, or not at all."}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(m,{owner:n,agentId:s})})]}):o?null:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Only organization admins can view or change agent permissions."})})}function h(){const{owner:n,agentId:s}=c.useParams();return e.jsx(x,{owner:n,agentId:s})}export{h as component};
|
|
2
|
-
//# sourceMappingURL=permissions-BVlbeY4u.js.map
|