decocms 2.310.9 → 2.310.10
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/client/assets/{AlertCircle-dmAxGfdw.js → AlertCircle-C2Kq9sP5.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-B5Pmgm3m.js → ArrowNarrowLeft-CtJPKQti.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-Di5qgspg.js → ArrowUpRight-CC_IBduD.js} +1 -1
- package/dist/client/assets/{Check-CoZObZfw.js → Check-8mi3AYKX.js} +1 -1
- package/dist/client/assets/{CheckCircle-CymGi1vs.js → CheckCircle-DN6M9EOU.js} +1 -1
- package/dist/client/assets/{ChevronDown-BYVKL3lw.js → ChevronDown-uewl1bwO.js} +1 -1
- package/dist/client/assets/{ChevronRight-C1-MREha.js → ChevronRight-CCrVuKwq.js} +1 -1
- package/dist/client/assets/{ChevronUp-DEJu7vcr.js → ChevronUp-DBRtGVBG.js} +1 -1
- package/dist/client/assets/{Container-C-gv68K3.js → Container-iNRgecVs.js} +1 -1
- package/dist/client/assets/{DotsVertical-BGA0iFJE.js → DotsVertical-BFkn4l7W.js} +1 -1
- package/dist/client/assets/{LinkExternal01-DFR79haX.js → LinkExternal01-C0SukdlX.js} +1 -1
- package/dist/client/assets/{Lock01-C7ffyA7b.js → Lock01-DrMjxg7_.js} +1 -1
- package/dist/client/assets/{Palette-YRlo3qST.js → Palette-B3GUBwDn.js} +1 -1
- package/dist/client/assets/{Play-W_nmstmM.js → Play-X_jxvK3z.js} +1 -1
- package/dist/client/assets/{Plus-BlcqyD1c.js → Plus-DrvlnS13.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-PuuFD9kE.js → RefreshCcw01-Fv5N4uZX.js} +1 -1
- package/dist/client/assets/{SearchMd-Cao-tsku.js → SearchMd-CvC8K2bA.js} +1 -1
- package/dist/client/assets/{Settings02-CMH55uu4.js → Settings02-Dp59S32g.js} +1 -1
- package/dist/client/assets/{Shield01-BO11ag-O.js → Shield01-CNaokdKB.js} +1 -1
- package/dist/client/assets/{Star01-CT1-Dwgl.js → Star01-C6oeO1Ak.js} +1 -1
- package/dist/client/assets/{Sun-CZX18uSg.js → Sun-Brr68tKM.js} +1 -1
- package/dist/client/assets/{Tool01-CkahRpzI.js → Tool01-aRUajebu.js} +1 -1
- package/dist/client/assets/{Trash01-DKGk_jtN.js → Trash01-CbD3JV1r.js} +1 -1
- package/dist/client/assets/{User01-CKWvc4f3.js → User01-DgN3y7Wm.js} +1 -1
- package/dist/client/assets/{Users03-BNJux13w.js → Users03-DpX7qz1q.js} +1 -1
- package/dist/client/assets/{X-DV_Dk1et.js → X-BPB3AnNC.js} +1 -1
- package/dist/client/assets/{XCircle-B03IdlZI.js → XCircle-BcurAQXM.js} +1 -1
- package/dist/client/assets/{XClose-DO3Jw2Iw.js → XClose-BpBqOBr0.js} +1 -1
- package/dist/client/assets/{Zap-CRY_cqST.js → Zap-FnE4yTgm.js} +1 -1
- package/dist/client/assets/{ZapSquare-DN4FFgDX.js → ZapSquare-DTXvHII8.js} +1 -1
- package/dist/client/assets/{accordion-CK1j-E3o.js → accordion-C2Kw8vOW.js} +1 -1
- package/dist/client/assets/{agent-icon-BuL7s1QY.js → agent-icon-DmFxQL-w.js} +1 -1
- package/dist/client/assets/{agents-list-DZLuDkTU.js → agents-list-DeiKac1A.js} +1 -1
- package/dist/client/assets/ai-providers-BaO9GV46.js +1 -0
- package/dist/client/assets/{alert-dialog-isc4o1-I.js → alert-dialog-CgPM83OZ.js} +1 -1
- package/dist/client/assets/{auth-catchall-C6M8n_qi.js → auth-catchall-C-PAm6ZL.js} +1 -1
- package/dist/client/assets/{automation-list-row-DpgLcgFR.js → automation-list-row-B6FveCl-.js} +1 -1
- package/dist/client/assets/{automations-DkAmc4i3.js → automations-CXpeWc-P.js} +1 -1
- package/dist/client/assets/{avatar-DiDbRWhL.js → avatar-R_EpLjLl.js} +1 -1
- package/dist/client/assets/{badge-CcZ6rzZn.js → badge-BRPQ2RXs.js} +1 -1
- package/dist/client/assets/{brand-context-bECXteWO.js → brand-context-VkbfuEAP.js} +1 -1
- package/dist/client/assets/{card-Dyb5BvJt.js → card-BRMBr6rT.js} +1 -1
- package/dist/client/assets/{chat-context-CEizejmQ.js → chat-context-B6LniWh4.js} +1 -1
- package/dist/client/assets/{checkbox-BQTCEZdR.js → checkbox-BblhT8hm.js} +1 -1
- package/dist/client/assets/{collection-detail-p2x4ej8F.js → collection-detail-jGRcLklu.js} +1 -1
- package/dist/client/assets/{collection-display-button-qvCsF5ZQ.js → collection-display-button-pckzcvu0.js} +1 -1
- package/dist/client/assets/{collection-search-D_h_Cv4k.js → collection-search-DSNbkFi1.js} +1 -1
- package/dist/client/assets/{collection-search-CbVyOd8I.js → collection-search-Dx8FaY02.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-DEWFnK11.js → collection-table-wrapper-VAZMo6kd.js} +1 -1
- package/dist/client/assets/{collection-tabs-FmSrPuTk.js → collection-tabs-BNmGhBX4.js} +1 -1
- package/dist/client/assets/{collections-BllQf3RV.js → collections-Dvzt0ZNN.js} +1 -1
- package/dist/client/assets/{command-BFqloV6u.js → command-D-hEs58n.js} +1 -1
- package/dist/client/assets/{connection-card-ZDJNBKt1.js → connection-card-DItj_2IY.js} +1 -1
- package/dist/client/assets/{connection-detail-Bv_VTkme.js → connection-detail-DKK-p3nN.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-BPWJCRm4.js → connection-form-helpers-CqjB58DM.js} +1 -1
- package/dist/client/assets/{connections-C4_JMZUe.js → connections-o9GkxKpU.js} +1 -1
- package/dist/client/assets/{constants-2NOiN3ZN.js → constants-DGqDuCM6.js} +1 -1
- package/dist/client/assets/{constants-C13iIB-x.js → constants-TOA097jd.js} +1 -1
- package/dist/client/assets/{dialog-Bm2ikVw1.js → dialog-BIz1GP40.js} +1 -1
- package/dist/client/assets/{domain-settings-DU7Hy3hX.js → domain-settings-Cw-RjCkh.js} +1 -1
- package/dist/client/assets/{drawer-B-6CGObe.js → drawer-DeI1k7rI.js} +1 -1
- package/dist/client/assets/{dropdown-menu-BgdOElZe.js → dropdown-menu-CVHV92Hd.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-B8gbCAdF.js → dynamic-plugin-layout-DzaSbnSD.js} +1 -1
- package/dist/client/assets/{empty-state-M47VX7Kg.js → empty-state-CsO6fXax.js} +1 -1
- package/dist/client/assets/{empty-state-C6U2d6Iz.js → empty-state-DyZKbBnm.js} +1 -1
- package/dist/client/assets/{extract-connection-data-D-R6UfWy.js → extract-connection-data-CUnE0R1z.js} +1 -1
- package/dist/client/assets/{features-Da9ot7ES.js → features-1BU-fGDo.js} +1 -1
- package/dist/client/assets/{form-BtPrdx-O.js → form-DC3ztBaq.js} +1 -1
- package/dist/client/assets/{general-BG62xLug.js → general-CnC_f06H.js} +1 -1
- package/dist/client/assets/index-245DoaKF.js +1 -0
- package/dist/client/assets/{index-DwWrsogB.js → index-B6-6SdwK.js} +1 -1
- package/dist/client/assets/{index-B7E_TqLL.js → index-Bd-TvWO2.js} +1 -1
- package/dist/client/assets/{index-CJ7tezbs.js → index-BlZUyqNd.js} +2 -2
- package/dist/client/assets/{index-Daezupu2.js → index-BlnWfdPR.js} +1 -1
- package/dist/client/assets/{index-B8kTK5az.js → index-C57DmctK.js} +1 -1
- package/dist/client/assets/{index-CkG8PUwG.js → index-CbqGifzG.js} +3 -3
- package/dist/client/assets/{index-Qm4SNvbw.js → index-D7cq1ZGD.js} +1 -1
- package/dist/client/assets/{index-DxGAxKWV.js → index-DFYb3Vpx.js} +1 -1
- package/dist/client/assets/{index-NB4Mduyj.js → index-DLT73ts-.js} +1 -1
- package/dist/client/assets/{index-BGe9yRbG.js → index-DrLrIvkx.js} +1 -1
- package/dist/client/assets/{index-WuQt9nPz.js → index-Dvixz6yi.js} +1 -1
- package/dist/client/assets/{index-AFdAkH-K.js → index-GNXHd8Mf.js} +1 -1
- package/dist/client/assets/{index-CwKjHTTq.js → index-UojFMTLq.js} +1 -1
- package/dist/client/assets/index-c5PVgI_h.js +1 -0
- package/dist/client/assets/{index-DtGR3bfn.js → index-fZC6RD3v.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-DgD5FfMR.js → infiniteQueryObserver--n1cwXQ3.js} +1 -1
- package/dist/client/assets/{input-icoGmB9A.js → input-IMib1XXi.js} +1 -1
- package/dist/client/assets/{integration-icon-j7ghn9fJ.js → integration-icon-BcQ6nvGQ.js} +1 -1
- package/dist/client/assets/{label-DwvsOTNS.js → label-BF3A-7va.js} +1 -1
- package/dist/client/assets/{layout-DNIR8-Gh.js → layout-CYH5LRmI.js} +1 -1
- package/dist/client/assets/{lean-canvas-recruit-modal-CWnnJj13.js → lean-canvas-recruit-modal-Co3Pdhei.js} +1 -1
- package/dist/client/assets/{login-B8k4XLcx.js → login-DEc-TFri.js} +1 -1
- package/dist/client/assets/{members-Dbapgu6b.js → members-C6yb3qP6.js} +1 -1
- package/dist/client/assets/{monaco-editor-9inEh7xO.js → monaco-editor-CIc49-ol.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-BHorL9l7.js → monitoring-stats-row-CsWNy_j8.js} +1 -1
- package/dist/client/assets/{oauth-callback-CChdekEG.js → oauth-callback-R-Bw8hrO.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-WQJptNwQ.js → oauth-callback-ai-provider-CUDjs3hN.js} +1 -1
- package/dist/client/assets/{onboarding-BzAXbJFJ.js → onboarding-CqMGDXrZ.js} +1 -1
- package/dist/client/assets/{org-layout-C36c0Pnr.js → org-layout-DphhPFpe.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-DjTzbgei.js → org-plugin-layout-B-I7FI8h.js} +1 -1
- package/dist/client/assets/{pair-DFjjTBxK.js → pair-DY8QPktF.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-GKGnpdyc.js → plugin-empty-state-BZy0fBVH.js} +1 -1
- package/dist/client/assets/{plugin-header-CqdUd-_y.js → plugin-header-CkLM2-lj.js} +1 -1
- package/dist/client/assets/{plugin-layout-CmX7ns9R.js → plugin-layout-30U_ewhr.js} +1 -1
- package/dist/client/assets/{popover-D_mzt8K-.js → popover-DNgwAx9Z.js} +1 -1
- package/dist/client/assets/{profile-l21waEZY.js → profile-CEE9ZZqn.js} +1 -1
- package/dist/client/assets/{project-app-view-DxehH6hP.js → project-app-view-DiCZcUip.js} +1 -1
- package/dist/client/assets/registry-DvsbyjKa.js +2 -0
- package/dist/client/assets/{registry-layout-Cbt57EG3.js → registry-layout-JBM4bR0G.js} +1 -1
- package/dist/client/assets/{required-auth-layout-Dw6MDr53.js → required-auth-layout-Ct1Qic00.js} +1 -1
- package/dist/client/assets/{reset-password-BKSptcrB.js → reset-password-D4u9tX7x.js} +1 -1
- package/dist/client/assets/{roles-D2adhbyA.js → roles-1l3z_zFU.js} +1 -1
- package/dist/client/assets/{scroll-area-PAWYGyUn.js → scroll-area-BOXDpfo4.js} +1 -1
- package/dist/client/assets/{search-input-aEr0S-jx.js → search-input-B4DkDHlW.js} +1 -1
- package/dist/client/assets/{select-CCp_dm-8.js → select-Cq3xZiQ5.js} +1 -1
- package/dist/client/assets/{select-model-DvEurWhO.js → select-model-k80wu5Pg.js} +1 -1
- package/dist/client/assets/settings-layout-BRNqIdJy.js +1 -0
- package/dist/client/assets/{settings-section-CyFvqFYP.js → settings-section-DuBFbDJh.js} +1 -1
- package/dist/client/assets/{shell-layout-D3MTPgKe.js → shell-layout-Biylk4dt.js} +1 -1
- package/dist/client/assets/{skeleton-B9eUxWyV.js → skeleton-8YZ7FRdJ.js} +1 -1
- package/dist/client/assets/{sso-C5CIXiBT.js → sso-DYf-HKpX.js} +1 -1
- package/dist/client/assets/{store-B-QOQxiI.js → store-gk30Uetz.js} +1 -1
- package/dist/client/assets/store-registry-DQg-S5Pq.js +2 -0
- package/dist/client/assets/{switch-D3jsuVqF.js → switch-JEYeupUE.js} +1 -1
- package/dist/client/assets/{table-BDdckIYz.js → table-DXz6Ne28.js} +1 -1
- package/dist/client/assets/{tabs-IOtx7wF_.js → tabs-DGHdxspT.js} +1 -1
- package/dist/client/assets/{task-status-cqc-yyHP.js → task-status-D3yOR3Rw.js} +1 -1
- package/dist/client/assets/{textarea-BnNXmx3Y.js → textarea-Byzq1Tag.js} +1 -1
- package/dist/client/assets/{toggle-group-CtNug1AN.js → toggle-group-iM11rQDQ.js} +1 -1
- package/dist/client/assets/{tools-list-OK0eBQ2-.js → tools-list-Bl74NcgJ.js} +1 -1
- package/dist/client/assets/{tooltip-CgMBEJ1D.js → tooltip-CFVYr91W.js} +1 -1
- package/dist/client/assets/{types-9ClSFAcb.js → types-CtN4LDEQ.js} +1 -1
- package/dist/client/assets/{use-ai-providers-CwrAqPK8.js → use-ai-providers-AxSx2mei.js} +1 -1
- package/dist/client/assets/{use-collections-J581b1V6.js → use-collections-BTtpR02V.js} +1 -1
- package/dist/client/assets/{use-connection-ClgerwwF.js → use-connection-C2keyruh.js} +1 -1
- package/dist/client/assets/{use-copy-DfoEPJYg.js → use-copy-CjrjEzGR.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-BVCqQhR9.js → use-create-virtual-mcp-4-L0RDrZ.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-BZFAEb2X.js → use-debounced-autosave-Cgsc15ij.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-DrHzIpMn.js → use-decopilot-events-CHyT765k.js} +1 -1
- package/dist/client/assets/{use-delete-connection-r9tq33yO.js → use-delete-connection-Dr1RMEfK.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-BiJUnXqe.js → use-infinite-scroll-B6apK_e6.js} +1 -1
- package/dist/client/assets/{use-list-state-DjgKOoV4.js → use-list-state-IspgLdDd.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-DrjB_1aW.js → use-mcp-tools-BJa7tdVW.js} +1 -1
- package/dist/client/assets/{use-members-YXTlTBnJ.js → use-members-CmOgxRUf.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-a_qVz0hx.js → use-navigate-to-agent-CHMFR1ZO.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-S_JrdH5c.js → use-org-auth-client-QmlbF_wd.js} +1 -1
- package/dist/client/assets/{use-org-sso-ByR6WIOr.js → use-org-sso-CZxuEwzK.js} +1 -1
- package/dist/client/assets/{use-organization-roles-CUDaH6Ds.js → use-organization-roles-ByHQCBC7.js} +1 -1
- package/dist/client/assets/{use-organization-settings-BvDmL50b.js → use-organization-settings-CUGnoKbY.js} +1 -1
- package/dist/client/assets/{use-registry-connections-BtL_BpNO.js → use-registry-connections-CAHIxYD2.js} +1 -1
- package/dist/client/assets/{use-status-sounds-DWHIYYpy.js → use-status-sounds-D34DNC68.js} +1 -1
- package/dist/client/assets/{use-tasks-B9rHJzLa.js → use-tasks-Dt-gbeRh.js} +1 -1
- package/dist/client/assets/{use-view-mode-DkE-SOvf.js → use-view-mode--UJYYM2y.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-CIedFfzt.js → use-virtual-mcp-CNyZ0pwV.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-DeJoxETV.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-CBbBRTcV.js +1 -0
- package/dist/client/assets/{user-BakGW47z.js → user-DJ1C04bV.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-DR7PcZfm.js → view-mode-toggle-DS5tFvFk.js} +1 -1
- package/dist/client/assets/{workflow-CSNmmmKf.js → workflow-BClHU4t7.js} +1 -1
- package/dist/client/assets/workflow-detail-B6kzSF7O.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -1
- package/dist/server/node_modules/escape-string-regexp/index.d.ts +18 -0
- package/dist/server/node_modules/escape-string-regexp/index.js +11 -0
- package/dist/server/node_modules/{get-east-asian-width → escape-string-regexp}/license +1 -1
- package/dist/server/node_modules/escape-string-regexp/package.json +43 -0
- package/dist/server/node_modules/escape-string-regexp/readme.md +29 -0
- package/dist/server/node_modules/pg-int8/LICENSE +13 -0
- package/dist/server/node_modules/pg-int8/README.md +16 -0
- package/dist/server/node_modules/pg-int8/index.js +100 -0
- package/dist/server/node_modules/pg-int8/package.json +24 -0
- package/dist/server/node_modules/postgres-interval/index.d.ts +20 -0
- package/dist/server/node_modules/postgres-interval/index.js +125 -0
- package/dist/server/node_modules/{postgres-date → postgres-interval}/package.json +11 -8
- package/dist/server/node_modules/postgres-interval/readme.md +48 -0
- package/package.json +1 -1
- package/dist/client/assets/ai-providers-CKU4YYdO.js +0 -1
- package/dist/client/assets/index-D6_8Dfq1.js +0 -1
- package/dist/client/assets/index-da3cMpwe.js +0 -1
- package/dist/client/assets/registry-BwMw1E_A.js +0 -2
- package/dist/client/assets/settings-layout-DD5s9jz9.js +0 -1
- package/dist/client/assets/store-registry-DeHxcxuH.js +0 -2
- package/dist/client/assets/useInfiniteQuery-BnMBc2sn.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-DRJEzN-I.js +0 -1
- package/dist/client/assets/workflow-detail-DnUnNIQp.js +0 -1
- package/dist/server/node_modules/get-east-asian-width/index.d.ts +0 -60
- package/dist/server/node_modules/get-east-asian-width/index.js +0 -30
- package/dist/server/node_modules/get-east-asian-width/lookup-data.js +0 -18
- package/dist/server/node_modules/get-east-asian-width/lookup.js +0 -135
- package/dist/server/node_modules/get-east-asian-width/package.json +0 -71
- package/dist/server/node_modules/get-east-asian-width/readme.md +0 -65
- package/dist/server/node_modules/get-east-asian-width/utilities.js +0 -24
- package/dist/server/node_modules/postgres-date/index.js +0 -116
- package/dist/server/node_modules/postgres-date/readme.md +0 -49
- package/dist/server/node_modules/xtend/.jshintrc +0 -30
- package/dist/server/node_modules/xtend/LICENSE +0 -20
- package/dist/server/node_modules/xtend/README.md +0 -32
- package/dist/server/node_modules/xtend/immutable.js +0 -19
- package/dist/server/node_modules/xtend/mutable.js +0 -17
- package/dist/server/node_modules/xtend/package.json +0 -55
- package/dist/server/node_modules/xtend/test.js +0 -103
- /package/dist/server/node_modules/{postgres-date → postgres-interval}/license +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-
|
|
2
|
-
import{o as ds,r as L,p as Ll,q as Ol,e as H,s as ge,K as Ls,n as Xo,a as Jo,c as re,j as o,l as Me,B as ne,E as Ht,b as Ei,v as ci,f as At,d as sn,w as zl,x as _e,y as $l,V as Fl,t as Se,z as Zo,C as Hl,D as $t,F as Wl,G as Nn,L as Ul,H as Hi,I as ti,J as ct,M as Qo,P as Vl,_ as Kl,Q as ea,R as ta,T as ql,g as Gl}from"./index-CJ7tezbs.js";import{C as je,u as Yl,w as Xl,A as Jl,T as Zl,a as Ql,S as ec}from"./index-B8kTK5az.js";import{I as us}from"./integration-icon-j7ghn9fJ.js";import{S as Bt,u as Fe,g as sa,a as ia}from"./constants-C13iIB-x.js";import{u as Ct,a as tc}from"./use-virtual-mcp-CIedFfzt.js";import{a as sc}from"./Users03-BNJux13w.js";import{u as ra,a as gt,b as Ti,c as fs,t as ic,d as jn}from"./chat-context-CEizejmQ.js";import{i as Os}from"./AlertCircle-dmAxGfdw.js";import{i as rc}from"./CheckCircle-CymGi1vs.js";import{n as En,a as nc}from"./ZapSquare-DN4FFgDX.js";import{i as oc,a as ac,b as lc,c as Di,d as cc}from"./XCircle-B03IdlZI.js";import{s as ls,i as hc}from"./XClose-DO3Jw2Iw.js";import{c as dc,r as uc,p as na,f as Tn,a as fc,F as mc,t as Dn,M as rn,G as oa,L as _c,i as pc,b as gc,d as vc,e as xc}from"./pair-DFjjTBxK.js";import{C as bc,a as Rn,b as Mn,c as Sc,d as yc,e as wc,f as Cc}from"./command-BFqloV6u.js";import{P as Vs,a as Ks,b as qs}from"./popover-D_mzt8K-.js";import{i as Ms,a as xi,b as kc,c as Nc,p as Ri,g as Mi,d as nn,e as aa,h as mr,f as Wi,j as In,A as An,k as la,l as jc,m as Ec,n as Tc,t as Dc,o as Rc,q as hi,r as ca,s as ha,u as da,v as Bn,w as Mc,x as Is,y as Ic,z as Ac,B as ua}from"./agent-icon-BuL7s1QY.js";import{u as ms,a as Bc}from"./use-mcp-tools-DrjB_1aW.js";import{u as Pc,a as Lc}from"./use-ai-providers-CwrAqPK8.js";import{g as Kt,c as Pn,u as Oc,b as _r,d as zc,e as $c,f as Fc,T as Hc}from"./index-da3cMpwe.js";import{u as Ii,i as Wc}from"./shell-layout-D3MTPgKe.js";import{i as Uc,P as lt,u as Vc,c as Kc,d as qc,e as Gc}from"./index-DxGAxKWV.js";import{u as fa,T as qe,a as Ge,b as Ye,c as Yc}from"./tooltip-CgMBEJ1D.js";import{u as Xc}from"./use-status-sounds-DWHIYYpy.js";import{E as zs}from"./empty-state-M47VX7Kg.js";import{A as Jc,a as Zc,b as Qc,c as eh,R as ma,d as th,e as sh}from"./accordion-CK1j-E3o.js";import{u as Ai,a as on,b as ih}from"./use-connection-ClgerwwF.js";import{g as rh}from"./constants-2NOiN3ZN.js";import{u as nh,g as oh}from"./types-9ClSFAcb.js";import{u as _a,G as ah}from"./lean-canvas-recruit-modal-CWnnJj13.js";import{U as pa}from"./user-BakGW47z.js";import{T as lh,u as ga}from"./tools-list-OK0eBQ2-.js";import{u as ch}from"./unwrap-tool-result-BYXdCQMg.js";import{s as va,g as hh}from"./connection-slug-eyAPH6o3.js";import{A as xa,a as ba,b as Sa,c as ya,d as wa,e as Ca,f as ka,g as Na}from"./alert-dialog-isc4o1-I.js";import{D as dh,a as an,b as ln,c as ja,d as Ea}from"./dialog-Bm2ikVw1.js";import{C as uh,a as Ln}from"./card-Dyb5BvJt.js";import{I as _s}from"./input-icoGmB9A.js";import{L as As}from"./label-DwvsOTNS.js";import{S as ts,a as ss,b as is,c as rs,d as It}from"./select-CCp_dm-8.js";import{S as pr}from"./switch-D3jsuVqF.js";import{T as On}from"./textarea-BnNXmx3Y.js";import{i as di}from"./Play-W_nmstmM.js";import{s as cs}from"./Plus-BlcqyD1c.js";import{a as fh}from"./Settings02-CMH55uu4.js";import{t as Ta,i as mh}from"./Tool01-CkahRpzI.js";import{s as gr}from"./Trash01-DKGk_jtN.js";import{u as bi}from"./use-debounced-autosave-BZFAEb2X.js";import{S as Da}from"./scroll-area-PAWYGyUn.js";import{i as Ra,a as _h}from"./SearchMd-Cao-tsku.js";import{C as ph}from"./collection-tabs-FmSrPuTk.js";import{C as gh}from"./checkbox-BQTCEZdR.js";import{u as vh,T as Ui,a as xh,b as bh,c as Vi}from"./tabs-IOtx7wF_.js";import{D as Sh,a as yh,b as wh}from"./drawer-B-6CGObe.js";import{i as Bi}from"./Check-CoZObZfw.js";import{n as qt}from"./LinkExternal01-DFR79haX.js";import{S as Ch}from"./index-WuQt9nPz.js";import{D as ns,a as os,b as as,c as wt,d as kh,e as Nh,f as jh}from"./dropdown-menu-BgdOElZe.js";import{t as vr}from"./ChevronDown-BYVKL3lw.js";import{i as Ma}from"./RefreshCcw01-PuuFD9kE.js";import{V as Eh}from"./view-mode-toggle-DR7PcZfm.js";import{M as Th}from"./select-model-DvEurWhO.js";import{u as Dh}from"./use-organization-settings-BvDmL50b.js";import{u as Gs,a as Rh,b as Mh,c as Ih,A as Ah,d as Bh}from"./automation-list-row-DpgLcgFR.js";import{i as $s}from"./Zap-CRY_cqST.js";import{S as Ph}from"./search-input-aEr0S-jx.js";import"./use-navigate-to-agent-a_qVz0hx.js";import"./use-tasks-B9rHJzLa.js";import"./use-collections-J581b1V6.js";import"./collection-search-D_h_Cv4k.js";import"./form-BtPrdx-O.js";import"./Star01-CT1-Dwgl.js";import"./Lock01-C7ffyA7b.js";import"./X-DV_Dk1et.js";import"./toggle-group-CtNug1AN.js";import"./index-Daezupu2.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-ZDJNBKt1.js";import"./use-registry-connections-BtL_BpNO.js";import"./useInfiniteQuery-BnMBc2sn.js";import"./infiniteQueryObserver-DgD5FfMR.js";import"./extract-connection-data-D-R6UfWy.js";import"./Container-C-gv68K3.js";import"./connection-form-helpers-BPWJCRm4.js";import"./use-infinite-scroll-BiJUnXqe.js";import"./useSuspenseInfiniteQuery-DRJEzN-I.js";import"./badge-CcZ6rzZn.js";import"./ChevronRight-C1-MREha.js";import"./use-decopilot-events-DrHzIpMn.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-DfoEPJYg.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-CZX18uSg.js";import"./index-Qm4SNvbw.js";import"./ArrowNarrowLeft-B5Pmgm3m.js";import"./ArrowUpRight-Di5qgspg.js";import"./ChevronUp-DEJu7vcr.js";import"./DotsVertical-BGA0iFJE.js";import"./Palette-YRlo3qST.js";import"./Shield01-BO11ag-O.js";import"./User01-CKWvc4f3.js";import"./skeleton-B9eUxWyV.js";import"./avatar-DiDbRWhL.js";import"./index-AFdAkH-K.js";import"./collection-search-CbVyOd8I.js";import"./use-create-virtual-mcp-BVCqQhR9.js";import"./task-status-cqc-yyHP.js";import"./required-auth-layout-Dw6MDr53.js";import"./use-org-sso-ByR6WIOr.js";import"./collections-BllQf3RV.js";import"./settings-section-CyFvqFYP.js";import"./formatDistanceToNow-Cb2QZZJn.js";function Lh(t,e){const s=ds(e);return Oh({filters:{...t,status:"pending"}},s).length}function zn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Oh(t={},e){const s=ds(e).getMutationCache(),i=L.useRef(t),r=L.useRef(null);return r.current===null&&(r.current=zn(s,t)),L.useEffect(()=>{i.current=t}),L.useSyncExternalStore(L.useCallback(n=>s.subscribe(()=>{const a=Ll(r.current,zn(s,i.current));r.current!==a&&(r.current=a,Ol.schedule(n))}),[s]),()=>r.current,()=>r.current)}function zh(t,e){const s=H.c(40),{org:i,locator:r}=ge();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Bt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=Fe(n),l=ds();let h;s[3]!==t||s[4]!==i.id?(h=Ls.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Xo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(w.isError){const N=w.content,D=Array.isArray(N)&&N[0]&&typeof N[0]=="object"?N[0].text??"Create failed":"Create failed";throw new Error(D)}return w.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:Ls.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Jo(p);let v,b;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=b):(v=s[28],b=s[29]),L.useEffect(v,b),!t){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[30]=x):x=s[30],x}if(f.isLoading){let x;return s[31]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[31]=x):x=s[31],x}if(f.isError){const x=f.error;let w;return s[32]!==x?(w={status:"error",error:x},s[32]=x,s[33]=w):w=s[33],w}if(f.isSuccess&&f.data){let x;return s[34]!==f.data?(x={status:"ready",task:f.data},s[34]=f.data,s[35]=x):x=s[35],x}if(g.isPending||f.isSuccess&&!f.data){let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[36]=x):x=s[36],x}if(g.isError){let x;return s[37]!==g.error?(x={status:"error",error:g.error},s[37]=g.error,s[38]=x):x=s[38],x}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function bs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function $n(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function $h(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Fh(t){const e=H.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Hh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Hh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Wh(t){const e=H.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let w;return e[27]!==x||e[28]!==f?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=w):w=e[29],w}function Uh(t){const e=H.c(19),{part:s}=t,i=s.input?.agent_id,r=Ct(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(us,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=re("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Me,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(oc,{size:12,className:"text-destructive"}):c?o.jsx(Os,{size:12,className:"text-warning"}):o.jsx(rc,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function Vh(t){const e=H.c(58),{onClose:s,back:i,className:r}=t,[n,a]=L.useState(null),{messages:l}=ra(),{tasks:h,taskId:c}=gt(),{selectedModel:u,selectedVirtualMcp:d}=Ti();let f,_,m,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let k;e[17]!==c?(k=q=>q.id===c,e[17]=c,e[18]=k):k=e[18];const N=h.find(k),D=dc(l),j=[...l].reverse().find(sd),B=j?.metadata?.usage,I=j?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,R=B?.contextTokens??B?.totalTokens??0,y=I&&I>0?(R/I*100).toFixed(1):null,T=l;let E;e[19]!==T?(E=T.filter(td).reduce(ed,0),e[19]=T,e[20]=E):E=e[20];const C=E,P=l;let M;e[21]!==P?(M=P.filter(Qh).reduce(Zh,0),e[21]=P,e[22]=M):M=e[22];const F=M,U=Math.max(0,D.totalTokens-C-F),z=l[0],V=l.at(-1),se=z?.metadata?.created_at??N?.created_at,te=V?.metadata?.created_at??N?.updated_at,X=l.filter(Jh),$=l.flatMap(Yh),A=u?.modelId?$h(u.modelId):"—",G=d?.title??"Decopilot",Y=[{label:"Session",value:N?.title??"New chat"},{label:"Messages",value:X.length},{label:"Agent",value:G},{label:"Model",value:A},{label:"Context Limit",value:I?bs(I):"—"},{label:"Session Tokens (billed)",value:D.totalTokens>0?bs(D.totalTokens):"0"},{label:"Usage",value:y!==null?`${y}%`:"—"},{label:"Input Tokens",value:D.inputTokens>0?bs(D.inputTokens):"0"},{label:"Output Tokens",value:D.outputTokens>0?bs(D.outputTokens):"0"},{label:"Reasoning Tokens",value:D.reasoningTokens>0?bs(D.reasoningTokens):"0"},{label:"Cost",value:D.cost>0?`$${D.cost<.001?D.cost.toFixed(6):D.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:$n(se)},{label:"Last Activity",value:$n(te)}];if(!N&&X.length===0){let q;e[23]!==r?(q=re("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=q):q=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let ue;e[26]!==i?(ue=i?o.jsx(En,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let de;e[28]!==s||e[29]!==ue?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=de):de=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=fe):fe=e[31];let He;e[32]!==q||e[33]!==de?(He=o.jsxs("div",{className:q,children:[de,fe]}),e[32]=q,e[33]=de,e[34]=He):He=e[34],S=He;break e}e[35]!==r?(v=re("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let Q;e[37]===Symbol.for("react.memo_cache_sentinel")?(Q=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=Q):Q=e[37];let ie;e[38]!==i?(ie=i?o.jsx(En,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ie):ie=e[39],e[40]!==s||e[41]!==ie?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Q,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:ie})]}),e[40]=s,e[41]=ie,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=$.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:$.map(Gh)})]}),m=o.jsx(Fh,{items:Y});let ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ee):ee=e[43],e[44]!==F||e[45]!==U||e[46]!==C?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[ee,o.jsx(Wh,{userTokens:C,assistantTokens:F,otherTokens:U})]}),e[44]=F,e[45]=U,e[46]=C,e[47]=p):p=e[47],g=X.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:X.map(q=>{const he=q.metadata?.created_at,ue=n?.id===q.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(ue?null:q),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:re("shrink-0 font-medium",q.role==="user"?"text-chart-1":"text-chart-2"),children:q.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:q.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&o.jsxs(o.Fragment,{children:[q.role==="assistant"&&(()=>{const de=q.metadata?._request;if(!de)return null;const fe=de.systemSections??[],He=Math.max(1,...fe.map(qh)),Ae=fe.reduce(Kh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),fe.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(Ae/4).toLocaleString()," ","tok"]})]}),fe.map((We,Ue)=>{const ot=We.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Ue}`,ke=We.chars/He*100,xt=Math.round(We.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:ot}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",xt.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${ke}%`}})})]},Ue)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(q,null,2)})]})]},q.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=x):x=e[53];let w;return e[54]!==v||e[55]!==b||e[56]!==x?(w=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=w):w=e[57],w}function Kh(t,e){return t+e.chars}function qh(t){return t.chars}function Gh(t,e){return o.jsx(Uh,{part:t},e)}function Yh(t){return(t.parts??[]).filter(Xh)}function Xh(t){return t.type==="tool-subtask"}function Jh(t){return t.role!=="system"}function Zh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Qh(t){return t.role==="assistant"}function ed(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function td(t){return t.role==="user"}function sd(t){return t.role==="assistant"&&t.metadata?.usage}const Fn=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Hn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function id(){const t=Fn[Math.floor(Math.random()*Fn.length)],e=Hn[Math.floor(Math.random()*Hn.length)];return`deco/${t}-${e}`}function rd(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function nd(t){const e=H.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=Fe(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:cd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=ms(g);let x,w;e[11]!==r||e[12]!==a?(w=new Set(Object.keys(a?.[r]??{})),x=[...w].sort().map(ld),e[11]=r,e[12]=a,e[13]=x,e[14]=w):(x=e[13],w=e[14]);const k=x;let N;if(e[15]!==v||e[16]!==w){const I=Array.isArray(v)?v:v?.branches??[];let R;e[18]!==w?(R=y=>!w.has(y.name),e[18]=w,e[19]=R):R=e[19],N=I.filter(ad).filter(R).map(od),e[15]=v,e[16]=w,e[17]=N}else N=e[17];const D=N,j=Array.isArray(v)?null:v?.default_branch??null;let B;return e[20]!==j||e[21]!==S||e[22]!==b||e[23]!==D||e[24]!==k?(B={yours:k,others:D,defaultBase:j,isLoading:b,isError:S},e[20]=j,e[21]=S,e[22]=b,e[23]=D,e[24]=k,e[25]=B):B=e[25],B}function od(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function ad(t){return typeof t.name=="string"}function ld(t){return{name:t,source:"yours"}}function cd(t){return rd(t)}function hd(t){const e=H.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=L.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=nd(_);let b;e[9]!==u?(b=C=>{u(C),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(Ms,{className:"h-3.5 w-3.5"}),e[11]=w):w=e[11];let k;e[12]!==x?(k=o.jsx(Vs,{asChild:!0,children:o.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[w,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=k):k=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(yc,{placeholder:"Search branches…"}),e[14]=N):N=e[14];let D;e[15]!==S?(D=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[N,o.jsx(ne,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(id()),children:"New"})]}),e[15]=S,e[16]=D):D=e[16];let j;e[17]!==v?(j=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=j):j=e[18];let B;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(B=!v&&!g&&m.length===0&&p.length===0&&o.jsx(bc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=B):B=e[23];let I;e[24]!==S||e[25]!==m?(I=m.length>0&&o.jsx(Rn,{heading:"Your branches",children:m.map(C=>o.jsxs(Mn,{value:C.name,onSelect:()=>S(C.name),children:[o.jsx(Ms,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:C.name})]},C.name))}),e[24]=S,e[25]=m,e[26]=I):I=e[26];let R;e[27]!==p||e[28]!==S?(R=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(Sc,{}),o.jsx(Rn,{heading:"Other branches in repo",children:p.map(C=>o.jsxs(Mn,{value:C.name,onSelect:()=>S(C.name),children:[o.jsx(Ms,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:C.name}),C.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",C.author]})]},C.name))})]}),e[27]=p,e[28]=S,e[29]=R):R=e[29];let y;e[30]!==R||e[31]!==j||e[32]!==B||e[33]!==I?(y=o.jsxs(wc,{children:[j,B,I,R]}),e[30]=R,e[31]=j,e[32]=B,e[33]=I,e[34]=y):y=e[34];let T;e[35]!==y||e[36]!==D?(T=o.jsx(Ks,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(Cc,{children:[D,y]})}),e[35]=y,e[36]=D,e[37]=T):T=e[37];let E;return e[38]!==d||e[39]!==T||e[40]!==k?(E=o.jsxs(qs,{open:d,onOpenChange:f,children:[k,T]}),e[38]=d,e[39]=T,e[40]=k,e[41]=E):E=e[41],E}function dd(){const t=H.c(27),{org:e}=ge(),{selectedVirtualMcp:s}=Ti(),{data:i}=Ei.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=gt();let a;t[0]!==e.id?(a=sa(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Ct(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(sc,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(us,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(hd,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=b):b=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,b]}),t[19]=m,t[20]=p,t[21]=v,t[22]=b,t[23]=S):S=t[23];let x;t[24]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[24]=x):x=t[24];let w;return t[25]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[25]=S,t[26]=w):w=t[26],w}function ud(){const t=H.c(26),{org:e}=ge(),s=Pc(),{isChatEmpty:i}=ra(),[r,n]=L.useState("chat"),a=Yl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Xl(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(dd,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Vh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(je,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Ia(){const t=H.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ht,{fallback:e,children:o.jsx(L.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(ud,{})})}),t[1]=s):s=t[1],s}async function fd(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Aa=["VM_START"],si=new Map,md=t=>`${t.virtualMcpId}::${t.branch??""}`,Ki=new Set,Si={mark:(t,e)=>Ki.add(`${t}::${e}`),clear:(t,e)=>Ki.delete(`${t}::${e}`),isStopped:(t,e)=>Ki.has(`${t}::${e}`)};function cn(t){const e=ds();return Jo({mutationKey:Aa,mutationFn:async s=>{s.branch&&Si.clear(s.virtualMcpId,s.branch);const i=md(s),r=si.get(i);if(r)return r;const n=(async()=>(await fd(t,"VM_START",s)).structuredContent)();si.set(i,n);try{return await n}finally{si.get(i)===n&&si.delete(i)}},onSuccess:()=>{ci(e)}})}function Ba(t,e){const s=H.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Aa,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Lh(i)>0}const _d={settings:Nc,automations:kc,env:xi,preview:ac,git:Ms};function Wn(t){const e=Ri(t);if(e.type==="icon"){const s=Mi(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function qi(t){if(t.kind==="system")return{kind:"component",Component:_d[t.tabId]};const e=Wn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Wn(s.icon);return i||{kind:"fallback"}}function pd(t){const{org:e}=ge(),s=Fe({connectionId:Bt,orgId:e.id,orgSlug:e.slug}),{data:i}=zl({queryKey:Ls.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Pa(t){const e=H.c(8),s=At();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=sn(i),n=Ct(t.virtualMcpId),a=pd(t.taskId),{currentBranch:l}=gt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Kt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ai(m),{activeTab:g,mainOpen:v}=uc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(gd)}:null}),b=na(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const j of f){const B=Tn(j.appId,j.toolName);x.set(B,{id:B,title:j.toolName,appId:j.appId,iconKey:j.toolName})}for(const j of d){const B=Tn(j.connectionId,j.toolName);x.set(B,{id:B,title:j.label||j.toolName,appId:j.connectionId,iconKey:j.toolName,iconUrl:j.icon??null})}let w;e[2]!==p?(w=j=>({id:j.id,title:j.title,kind:"agent",icon:qi({tabId:j.id,kind:"agent",appId:j.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const k=[...u.map(w),...Array.from(x.values()).map(j=>({id:j.id,title:j.title,kind:"expanded",icon:qi({tabId:j.iconKey,kind:"expanded",appId:j.appId,iconUrl:j.iconUrl,connections:p})})),...S.map(j=>({id:j.id,title:j.title,kind:"system",icon:qi({tabId:j.id,kind:"system",connections:p})}))];let N;return e[4]!==g||e[5]!==v||e[6]!==s?(N=j=>{const B=fc({clickedId:j,activeTab:g,mainOpen:v});s({to:".",search:I=>({...I,main:B}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=N):N=e[7],{activeTab:g,mainOpen:v,setActiveTab:N,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:k}}function gd(t){return{id:t.id}}function La(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-DiCZcUip.js","assets/index-BlZUyqNd.js","assets/index-CpHJcJk3.css","assets/pair-DY8QPktF.js","assets/agent-icon-DmFxQL-w.js","assets/AlertCircle-C2Kq9sP5.js","assets/Tool01-aRUajebu.js","assets/XClose-BpBqOBr0.js","assets/RefreshCcw01-Fv5N4uZX.js","assets/ArrowNarrowLeft-CtJPKQti.js","assets/XCircle-BcurAQXM.js","assets/ArrowUpRight-CC_IBduD.js","assets/ZapSquare-DTXvHII8.js","assets/Users03-DpX7qz1q.js","assets/CheckCircle-DN6M9EOU.js","assets/Check-8mi3AYKX.js","assets/ChevronDown-uewl1bwO.js","assets/ChevronRight-CCrVuKwq.js","assets/ChevronUp-DBRtGVBG.js","assets/DotsVertical-BFkn4l7W.js","assets/Container-iNRgecVs.js","assets/Star01-C6oeO1Ak.js","assets/Palette-B3GUBwDn.js","assets/SearchMd-CvC8K2bA.js","assets/index-DFYb3Vpx.js","assets/tooltip-CFVYr91W.js","assets/X-BPB3AnNC.js","assets/LinkExternal01-C0SukdlX.js","assets/Lock01-DrMjxg7_.js","assets/Sun-Brr68tKM.js","assets/Play-X_jxvK3z.js","assets/Plus-DrvlnS13.js","assets/Settings02-Dp59S32g.js","assets/Shield01-CNaokdKB.js","assets/Trash01-CbD3JV1r.js","assets/User01-DgN3y7Wm.js","assets/Zap-FnE4yTgm.js","assets/index-Dvixz6yi.js","assets/use-copy-CjrjEzGR.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-BIz1GP40.js","assets/content-blocks-o63cs2vh.js","assets/types-CtN4LDEQ.js","assets/constants-TOA097jd.js","assets/chat-context-B6LniWh4.js","assets/use-virtual-mcp-CNyZ0pwV.js","assets/use-collections-BTtpR02V.js","assets/use-ai-providers-AxSx2mei.js","assets/use-decopilot-events-CHyT765k.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-Dt-gbeRh.js","assets/use-organization-settings-CUGnoKbY.js","assets/shell-layout-Biylk4dt.js","assets/required-auth-layout-Ct1Qic00.js","assets/use-org-sso-CZxuEwzK.js","assets/integration-icon-BcQ6nvGQ.js","assets/use-mcp-tools-BJa7tdVW.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as ds,r as L,p as Ll,q as Ol,e as H,s as ge,K as Ls,n as Xo,a as Jo,c as re,j as o,l as Me,B as ne,E as Ht,b as Ei,v as ci,f as At,d as sn,w as zl,x as _e,y as $l,V as Fl,t as Se,z as Zo,C as Hl,D as $t,F as Wl,G as Nn,L as Ul,H as Hi,I as ti,J as ct,M as Qo,P as Vl,_ as Kl,Q as ea,R as ta,T as ql,g as Gl}from"./index-BlZUyqNd.js";import{C as je,u as Yl,w as Xl,A as Jl,T as Zl,a as Ql,S as ec}from"./index-C57DmctK.js";import{I as us}from"./integration-icon-BcQ6nvGQ.js";import{S as Bt,u as Fe,g as sa,a as ia}from"./constants-TOA097jd.js";import{u as Ct,a as tc}from"./use-virtual-mcp-CNyZ0pwV.js";import{a as sc}from"./Users03-DpX7qz1q.js";import{u as ra,a as gt,b as Ti,c as fs,t as ic,d as jn}from"./chat-context-B6LniWh4.js";import{i as Os}from"./AlertCircle-C2Kq9sP5.js";import{i as rc}from"./CheckCircle-DN6M9EOU.js";import{n as En,a as nc}from"./ZapSquare-DTXvHII8.js";import{i as oc,a as ac,b as lc,c as Di,d as cc}from"./XCircle-BcurAQXM.js";import{s as ls,i as hc}from"./XClose-BpBqOBr0.js";import{c as dc,r as uc,p as na,f as Tn,a as fc,F as mc,t as Dn,M as rn,G as oa,L as _c,i as pc,b as gc,d as vc,e as xc}from"./pair-DY8QPktF.js";import{C as bc,a as Rn,b as Mn,c as Sc,d as yc,e as wc,f as Cc}from"./command-D-hEs58n.js";import{P as Vs,a as Ks,b as qs}from"./popover-DNgwAx9Z.js";import{i as Ms,a as xi,b as kc,c as Nc,p as Ri,g as Mi,d as nn,e as aa,h as mr,f as Wi,j as In,A as An,k as la,l as jc,m as Ec,n as Tc,t as Dc,o as Rc,q as hi,r as ca,s as ha,u as da,v as Bn,w as Mc,x as Is,y as Ic,z as Ac,B as ua}from"./agent-icon-DmFxQL-w.js";import{u as ms,a as Bc}from"./use-mcp-tools-BJa7tdVW.js";import{u as Pc,a as Lc}from"./use-ai-providers-AxSx2mei.js";import{g as Kt,c as Pn,u as Oc,b as _r,d as zc,e as $c,f as Fc,T as Hc}from"./index-245DoaKF.js";import{u as Ii,i as Wc}from"./shell-layout-Biylk4dt.js";import{i as Uc,P as lt,u as Vc,c as Kc,d as qc,e as Gc}from"./index-DFYb3Vpx.js";import{u as fa,T as qe,a as Ge,b as Ye,c as Yc}from"./tooltip-CFVYr91W.js";import{u as Xc}from"./use-status-sounds-D34DNC68.js";import{E as zs}from"./empty-state-CsO6fXax.js";import{A as Jc,a as Zc,b as Qc,c as eh,R as ma,d as th,e as sh}from"./accordion-C2Kw8vOW.js";import{u as Ai,a as on,b as ih}from"./use-connection-C2keyruh.js";import{g as rh}from"./constants-DGqDuCM6.js";import{u as nh,g as oh}from"./types-CtN4LDEQ.js";import{u as _a,G as ah}from"./lean-canvas-recruit-modal-Co3Pdhei.js";import{U as pa}from"./user-DJ1C04bV.js";import{T as lh,u as ga}from"./tools-list-Bl74NcgJ.js";import{u as ch}from"./unwrap-tool-result-BYXdCQMg.js";import{s as va,g as hh}from"./connection-slug-eyAPH6o3.js";import{A as xa,a as ba,b as Sa,c as ya,d as wa,e as Ca,f as ka,g as Na}from"./alert-dialog-CgPM83OZ.js";import{D as dh,a as an,b as ln,c as ja,d as Ea}from"./dialog-BIz1GP40.js";import{C as uh,a as Ln}from"./card-BRMBr6rT.js";import{I as _s}from"./input-IMib1XXi.js";import{L as As}from"./label-BF3A-7va.js";import{S as ts,a as ss,b as is,c as rs,d as It}from"./select-Cq3xZiQ5.js";import{S as pr}from"./switch-JEYeupUE.js";import{T as On}from"./textarea-Byzq1Tag.js";import{i as di}from"./Play-X_jxvK3z.js";import{s as cs}from"./Plus-DrvlnS13.js";import{a as fh}from"./Settings02-Dp59S32g.js";import{t as Ta,i as mh}from"./Tool01-aRUajebu.js";import{s as gr}from"./Trash01-CbD3JV1r.js";import{u as bi}from"./use-debounced-autosave-Cgsc15ij.js";import{S as Da}from"./scroll-area-BOXDpfo4.js";import{i as Ra,a as _h}from"./SearchMd-CvC8K2bA.js";import{C as ph}from"./collection-tabs-BNmGhBX4.js";import{C as gh}from"./checkbox-BblhT8hm.js";import{u as vh,T as Ui,a as xh,b as bh,c as Vi}from"./tabs-DGHdxspT.js";import{D as Sh,a as yh,b as wh}from"./drawer-DeI1k7rI.js";import{i as Bi}from"./Check-8mi3AYKX.js";import{n as qt}from"./LinkExternal01-C0SukdlX.js";import{S as Ch}from"./index-Dvixz6yi.js";import{D as ns,a as os,b as as,c as wt,d as kh,e as Nh,f as jh}from"./dropdown-menu-CVHV92Hd.js";import{t as vr}from"./ChevronDown-uewl1bwO.js";import{i as Ma}from"./RefreshCcw01-Fv5N4uZX.js";import{V as Eh}from"./view-mode-toggle-DS5tFvFk.js";import{M as Th}from"./select-model-k80wu5Pg.js";import{u as Dh}from"./use-organization-settings-CUGnoKbY.js";import{u as Gs,a as Rh,b as Mh,c as Ih,A as Ah,d as Bh}from"./automation-list-row-B6FveCl-.js";import{i as $s}from"./Zap-FnE4yTgm.js";import{S as Ph}from"./search-input-B4DkDHlW.js";import"./use-navigate-to-agent-CHMFR1ZO.js";import"./use-tasks-Dt-gbeRh.js";import"./use-collections-BTtpR02V.js";import"./collection-search-DSNbkFi1.js";import"./form-DC3ztBaq.js";import"./Star01-C6oeO1Ak.js";import"./Lock01-DrMjxg7_.js";import"./X-BPB3AnNC.js";import"./toggle-group-iM11rQDQ.js";import"./index-BlnWfdPR.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-DItj_2IY.js";import"./use-registry-connections-CAHIxYD2.js";import"./useInfiniteQuery-DeJoxETV.js";import"./infiniteQueryObserver--n1cwXQ3.js";import"./extract-connection-data-CUnE0R1z.js";import"./Container-iNRgecVs.js";import"./connection-form-helpers-CqjB58DM.js";import"./use-infinite-scroll-B6apK_e6.js";import"./useSuspenseInfiniteQuery-CBbBRTcV.js";import"./badge-BRPQ2RXs.js";import"./ChevronRight-CCrVuKwq.js";import"./use-decopilot-events-CHyT765k.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-CjrjEzGR.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-Brr68tKM.js";import"./index-D7cq1ZGD.js";import"./ArrowNarrowLeft-CtJPKQti.js";import"./ArrowUpRight-CC_IBduD.js";import"./ChevronUp-DBRtGVBG.js";import"./DotsVertical-BFkn4l7W.js";import"./Palette-B3GUBwDn.js";import"./Shield01-CNaokdKB.js";import"./User01-DgN3y7Wm.js";import"./skeleton-8YZ7FRdJ.js";import"./avatar-R_EpLjLl.js";import"./index-GNXHd8Mf.js";import"./collection-search-Dx8FaY02.js";import"./use-create-virtual-mcp-4-L0RDrZ.js";import"./task-status-D3yOR3Rw.js";import"./required-auth-layout-Ct1Qic00.js";import"./use-org-sso-CZxuEwzK.js";import"./collections-Dvzt0ZNN.js";import"./settings-section-DuBFbDJh.js";import"./formatDistanceToNow-Cb2QZZJn.js";function Lh(t,e){const s=ds(e);return Oh({filters:{...t,status:"pending"}},s).length}function zn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Oh(t={},e){const s=ds(e).getMutationCache(),i=L.useRef(t),r=L.useRef(null);return r.current===null&&(r.current=zn(s,t)),L.useEffect(()=>{i.current=t}),L.useSyncExternalStore(L.useCallback(n=>s.subscribe(()=>{const a=Ll(r.current,zn(s,i.current));r.current!==a&&(r.current=a,Ol.schedule(n))}),[s]),()=>r.current,()=>r.current)}function zh(t,e){const s=H.c(40),{org:i,locator:r}=ge();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Bt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=Fe(n),l=ds();let h;s[3]!==t||s[4]!==i.id?(h=Ls.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Xo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(w.isError){const N=w.content,D=Array.isArray(N)&&N[0]&&typeof N[0]=="object"?N[0].text??"Create failed":"Create failed";throw new Error(D)}return w.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:Ls.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Jo(p);let v,b;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=b):(v=s[28],b=s[29]),L.useEffect(v,b),!t){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[30]=x):x=s[30],x}if(f.isLoading){let x;return s[31]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[31]=x):x=s[31],x}if(f.isError){const x=f.error;let w;return s[32]!==x?(w={status:"error",error:x},s[32]=x,s[33]=w):w=s[33],w}if(f.isSuccess&&f.data){let x;return s[34]!==f.data?(x={status:"ready",task:f.data},s[34]=f.data,s[35]=x):x=s[35],x}if(g.isPending||f.isSuccess&&!f.data){let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[36]=x):x=s[36],x}if(g.isError){let x;return s[37]!==g.error?(x={status:"error",error:g.error},s[37]=g.error,s[38]=x):x=s[38],x}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function bs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function $n(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function $h(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Fh(t){const e=H.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Hh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Hh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Wh(t){const e=H.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let w;return e[27]!==x||e[28]!==f?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=w):w=e[29],w}function Uh(t){const e=H.c(19),{part:s}=t,i=s.input?.agent_id,r=Ct(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(us,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=re("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Me,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(oc,{size:12,className:"text-destructive"}):c?o.jsx(Os,{size:12,className:"text-warning"}):o.jsx(rc,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function Vh(t){const e=H.c(58),{onClose:s,back:i,className:r}=t,[n,a]=L.useState(null),{messages:l}=ra(),{tasks:h,taskId:c}=gt(),{selectedModel:u,selectedVirtualMcp:d}=Ti();let f,_,m,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let k;e[17]!==c?(k=q=>q.id===c,e[17]=c,e[18]=k):k=e[18];const N=h.find(k),D=dc(l),j=[...l].reverse().find(sd),B=j?.metadata?.usage,I=j?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,R=B?.contextTokens??B?.totalTokens??0,y=I&&I>0?(R/I*100).toFixed(1):null,T=l;let E;e[19]!==T?(E=T.filter(td).reduce(ed,0),e[19]=T,e[20]=E):E=e[20];const C=E,P=l;let M;e[21]!==P?(M=P.filter(Qh).reduce(Zh,0),e[21]=P,e[22]=M):M=e[22];const F=M,U=Math.max(0,D.totalTokens-C-F),z=l[0],V=l.at(-1),se=z?.metadata?.created_at??N?.created_at,te=V?.metadata?.created_at??N?.updated_at,X=l.filter(Jh),$=l.flatMap(Yh),A=u?.modelId?$h(u.modelId):"—",G=d?.title??"Decopilot",Y=[{label:"Session",value:N?.title??"New chat"},{label:"Messages",value:X.length},{label:"Agent",value:G},{label:"Model",value:A},{label:"Context Limit",value:I?bs(I):"—"},{label:"Session Tokens (billed)",value:D.totalTokens>0?bs(D.totalTokens):"0"},{label:"Usage",value:y!==null?`${y}%`:"—"},{label:"Input Tokens",value:D.inputTokens>0?bs(D.inputTokens):"0"},{label:"Output Tokens",value:D.outputTokens>0?bs(D.outputTokens):"0"},{label:"Reasoning Tokens",value:D.reasoningTokens>0?bs(D.reasoningTokens):"0"},{label:"Cost",value:D.cost>0?`$${D.cost<.001?D.cost.toFixed(6):D.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:$n(se)},{label:"Last Activity",value:$n(te)}];if(!N&&X.length===0){let q;e[23]!==r?(q=re("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=q):q=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let ue;e[26]!==i?(ue=i?o.jsx(En,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let de;e[28]!==s||e[29]!==ue?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=de):de=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=fe):fe=e[31];let He;e[32]!==q||e[33]!==de?(He=o.jsxs("div",{className:q,children:[de,fe]}),e[32]=q,e[33]=de,e[34]=He):He=e[34],S=He;break e}e[35]!==r?(v=re("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let Q;e[37]===Symbol.for("react.memo_cache_sentinel")?(Q=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=Q):Q=e[37];let ie;e[38]!==i?(ie=i?o.jsx(En,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ie):ie=e[39],e[40]!==s||e[41]!==ie?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Q,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:ie})]}),e[40]=s,e[41]=ie,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=$.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:$.map(Gh)})]}),m=o.jsx(Fh,{items:Y});let ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ee):ee=e[43],e[44]!==F||e[45]!==U||e[46]!==C?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[ee,o.jsx(Wh,{userTokens:C,assistantTokens:F,otherTokens:U})]}),e[44]=F,e[45]=U,e[46]=C,e[47]=p):p=e[47],g=X.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:X.map(q=>{const he=q.metadata?.created_at,ue=n?.id===q.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(ue?null:q),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:re("shrink-0 font-medium",q.role==="user"?"text-chart-1":"text-chart-2"),children:q.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:q.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&o.jsxs(o.Fragment,{children:[q.role==="assistant"&&(()=>{const de=q.metadata?._request;if(!de)return null;const fe=de.systemSections??[],He=Math.max(1,...fe.map(qh)),Ae=fe.reduce(Kh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),fe.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(Ae/4).toLocaleString()," ","tok"]})]}),fe.map((We,Ue)=>{const ot=We.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Ue}`,ke=We.chars/He*100,xt=Math.round(We.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:ot}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",xt.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${ke}%`}})})]},Ue)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(q,null,2)})]})]},q.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=x):x=e[53];let w;return e[54]!==v||e[55]!==b||e[56]!==x?(w=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=w):w=e[57],w}function Kh(t,e){return t+e.chars}function qh(t){return t.chars}function Gh(t,e){return o.jsx(Uh,{part:t},e)}function Yh(t){return(t.parts??[]).filter(Xh)}function Xh(t){return t.type==="tool-subtask"}function Jh(t){return t.role!=="system"}function Zh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Qh(t){return t.role==="assistant"}function ed(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function td(t){return t.role==="user"}function sd(t){return t.role==="assistant"&&t.metadata?.usage}const Fn=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Hn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function id(){const t=Fn[Math.floor(Math.random()*Fn.length)],e=Hn[Math.floor(Math.random()*Hn.length)];return`deco/${t}-${e}`}function rd(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function nd(t){const e=H.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=Fe(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:cd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=ms(g);let x,w;e[11]!==r||e[12]!==a?(w=new Set(Object.keys(a?.[r]??{})),x=[...w].sort().map(ld),e[11]=r,e[12]=a,e[13]=x,e[14]=w):(x=e[13],w=e[14]);const k=x;let N;if(e[15]!==v||e[16]!==w){const I=Array.isArray(v)?v:v?.branches??[];let R;e[18]!==w?(R=y=>!w.has(y.name),e[18]=w,e[19]=R):R=e[19],N=I.filter(ad).filter(R).map(od),e[15]=v,e[16]=w,e[17]=N}else N=e[17];const D=N,j=Array.isArray(v)?null:v?.default_branch??null;let B;return e[20]!==j||e[21]!==S||e[22]!==b||e[23]!==D||e[24]!==k?(B={yours:k,others:D,defaultBase:j,isLoading:b,isError:S},e[20]=j,e[21]=S,e[22]=b,e[23]=D,e[24]=k,e[25]=B):B=e[25],B}function od(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function ad(t){return typeof t.name=="string"}function ld(t){return{name:t,source:"yours"}}function cd(t){return rd(t)}function hd(t){const e=H.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=L.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=nd(_);let b;e[9]!==u?(b=C=>{u(C),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(Ms,{className:"h-3.5 w-3.5"}),e[11]=w):w=e[11];let k;e[12]!==x?(k=o.jsx(Vs,{asChild:!0,children:o.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[w,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=k):k=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(yc,{placeholder:"Search branches…"}),e[14]=N):N=e[14];let D;e[15]!==S?(D=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[N,o.jsx(ne,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(id()),children:"New"})]}),e[15]=S,e[16]=D):D=e[16];let j;e[17]!==v?(j=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=j):j=e[18];let B;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(B=!v&&!g&&m.length===0&&p.length===0&&o.jsx(bc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=B):B=e[23];let I;e[24]!==S||e[25]!==m?(I=m.length>0&&o.jsx(Rn,{heading:"Your branches",children:m.map(C=>o.jsxs(Mn,{value:C.name,onSelect:()=>S(C.name),children:[o.jsx(Ms,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:C.name})]},C.name))}),e[24]=S,e[25]=m,e[26]=I):I=e[26];let R;e[27]!==p||e[28]!==S?(R=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(Sc,{}),o.jsx(Rn,{heading:"Other branches in repo",children:p.map(C=>o.jsxs(Mn,{value:C.name,onSelect:()=>S(C.name),children:[o.jsx(Ms,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:C.name}),C.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",C.author]})]},C.name))})]}),e[27]=p,e[28]=S,e[29]=R):R=e[29];let y;e[30]!==R||e[31]!==j||e[32]!==B||e[33]!==I?(y=o.jsxs(wc,{children:[j,B,I,R]}),e[30]=R,e[31]=j,e[32]=B,e[33]=I,e[34]=y):y=e[34];let T;e[35]!==y||e[36]!==D?(T=o.jsx(Ks,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(Cc,{children:[D,y]})}),e[35]=y,e[36]=D,e[37]=T):T=e[37];let E;return e[38]!==d||e[39]!==T||e[40]!==k?(E=o.jsxs(qs,{open:d,onOpenChange:f,children:[k,T]}),e[38]=d,e[39]=T,e[40]=k,e[41]=E):E=e[41],E}function dd(){const t=H.c(27),{org:e}=ge(),{selectedVirtualMcp:s}=Ti(),{data:i}=Ei.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=gt();let a;t[0]!==e.id?(a=sa(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Ct(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(sc,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(us,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(hd,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=b):b=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,b]}),t[19]=m,t[20]=p,t[21]=v,t[22]=b,t[23]=S):S=t[23];let x;t[24]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[24]=x):x=t[24];let w;return t[25]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[25]=S,t[26]=w):w=t[26],w}function ud(){const t=H.c(26),{org:e}=ge(),s=Pc(),{isChatEmpty:i}=ra(),[r,n]=L.useState("chat"),a=Yl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Xl(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(dd,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Vh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(je,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Ia(){const t=H.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ht,{fallback:e,children:o.jsx(L.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(ud,{})})}),t[1]=s):s=t[1],s}async function fd(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Aa=["VM_START"],si=new Map,md=t=>`${t.virtualMcpId}::${t.branch??""}`,Ki=new Set,Si={mark:(t,e)=>Ki.add(`${t}::${e}`),clear:(t,e)=>Ki.delete(`${t}::${e}`),isStopped:(t,e)=>Ki.has(`${t}::${e}`)};function cn(t){const e=ds();return Jo({mutationKey:Aa,mutationFn:async s=>{s.branch&&Si.clear(s.virtualMcpId,s.branch);const i=md(s),r=si.get(i);if(r)return r;const n=(async()=>(await fd(t,"VM_START",s)).structuredContent)();si.set(i,n);try{return await n}finally{si.get(i)===n&&si.delete(i)}},onSuccess:()=>{ci(e)}})}function Ba(t,e){const s=H.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Aa,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Lh(i)>0}const _d={settings:Nc,automations:kc,env:xi,preview:ac,git:Ms};function Wn(t){const e=Ri(t);if(e.type==="icon"){const s=Mi(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function qi(t){if(t.kind==="system")return{kind:"component",Component:_d[t.tabId]};const e=Wn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Wn(s.icon);return i||{kind:"fallback"}}function pd(t){const{org:e}=ge(),s=Fe({connectionId:Bt,orgId:e.id,orgSlug:e.slug}),{data:i}=zl({queryKey:Ls.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Pa(t){const e=H.c(8),s=At();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=sn(i),n=Ct(t.virtualMcpId),a=pd(t.taskId),{currentBranch:l}=gt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Kt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ai(m),{activeTab:g,mainOpen:v}=uc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(gd)}:null}),b=na(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const j of f){const B=Tn(j.appId,j.toolName);x.set(B,{id:B,title:j.toolName,appId:j.appId,iconKey:j.toolName})}for(const j of d){const B=Tn(j.connectionId,j.toolName);x.set(B,{id:B,title:j.label||j.toolName,appId:j.connectionId,iconKey:j.toolName,iconUrl:j.icon??null})}let w;e[2]!==p?(w=j=>({id:j.id,title:j.title,kind:"agent",icon:qi({tabId:j.id,kind:"agent",appId:j.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const k=[...u.map(w),...Array.from(x.values()).map(j=>({id:j.id,title:j.title,kind:"expanded",icon:qi({tabId:j.iconKey,kind:"expanded",appId:j.appId,iconUrl:j.iconUrl,connections:p})})),...S.map(j=>({id:j.id,title:j.title,kind:"system",icon:qi({tabId:j.id,kind:"system",connections:p})}))];let N;return e[4]!==g||e[5]!==v||e[6]!==s?(N=j=>{const B=fc({clickedId:j,activeTab:g,mainOpen:v});s({to:".",search:I=>({...I,main:B}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=N):N=e[7],{activeTab:g,mainOpen:v,setActiveTab:N,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:k}}function gd(t){return{id:t.id}}function La(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
3
3
|
<current_instructions>${n}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function vd(t){const e=H.c(84),{value:s,onChange:i,onColorChange:r,name:n,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:u}=t,d=a===void 0?"lg":a,f=c===void 0?!0:c,_=u===void 0?!1:u,[m,p]=L.useState(!1),[g,v]=L.useState("icons"),[b,S]=L.useState(""),[x,w]=L.useState("blue");let k;e[0]!==s?(k=Ri(s),e[0]=s,e[1]=k):k=e[1];const N=k,D=N.type==="icon"||N.type==="url"&&N.color?N.color:x;let j;e[2]!==i||e[3]!==D?(j=ke=>{i(Wi(ke,D))},e[2]=i,e[3]=D,e[4]=j):j=e[4];const B=j;let I;e[5]!==i||e[6]!==r||e[7]!==N.name||e[8]!==N.type||e[9]!==N.url?(I=ke=>{w(ke),r?.(ke),N.type==="icon"?i(Wi(N.name,ke)):N.type==="url"&&i(In(N.url,ke))},e[5]=i,e[6]=r,e[7]=N.name,e[8]=N.type,e[9]=N.url,e[10]=I):I=e[10];const R=I;let y;e[11]!==i||e[12]!==D?(y=ke=>{i(In(ke,D)),p(!1)},e[11]=i,e[12]=D,e[13]=y):y=e[13];const T=y;let E;e[14]!==i||e[15]!==D?(E=()=>{const ke=nn(),xt=ke[Math.floor(Math.random()*ke.length)];i(Wi(xt,D))},e[14]=i,e[15]=D,e[16]=E):E=e[16];const C=E;let P,M,F,U,z,V,se,te;if(e[17]!==l||e[18]!==_||e[19]!==m||e[20]!==d){const ke={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};M=qs,V=_?!1:m,se=p,P=Vs,z=!0,te="button",F=_,U=re("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",ke[d],l),e[17]=l,e[18]=_,e[19]=m,e[20]=d,e[21]=P,e[22]=M,e[23]=F,e[24]=U,e[25]=z,e[26]=V,e[27]=se,e[28]=te}else P=e[21],M=e[22],F=e[23],U=e[24],z=e[25],V=e[26],se=e[27],te=e[28];let X;e[29]!==h||e[30]!==n||e[31]!==d||e[32]!==s?(X=o.jsx(An,{icon:s,name:n,size:d,className:h}),e[29]=h,e[30]=n,e[31]=d,e[32]=s,e[33]=X):X=e[33];let $;e[34]!==_||e[35]!==f?($=f&&!_&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(la,{size:16,className:"text-white"})}),e[34]=_,e[35]=f,e[36]=$):$=e[36];let A;e[37]!==F||e[38]!==U||e[39]!==X||e[40]!==$||e[41]!==te?(A=o.jsxs("button",{type:te,disabled:F,className:U,children:[X,$]}),e[37]=F,e[38]=U,e[39]=X,e[40]=$,e[41]=te,e[42]=A):A=e[42];let G;e[43]!==P||e[44]!==z||e[45]!==A?(G=o.jsx(P,{asChild:z,children:A}),e[43]=P,e[44]=z,e[45]=A,e[46]=G):G=e[46];let Y;e[47]!==n||e[48]!==s?(Y=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(An,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=Y):Y=e[49];let Q;e[50]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>v("icons"),e[50]=Q):Q=e[50];const ie=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ee;e[51]!==ie?(ee=re("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ie),e[51]=ie,e[52]=ee):ee=e[52];let q;e[53]!==ee?(q=o.jsx("button",{type:"button",onClick:Q,className:ee,children:"Icons"}),e[53]=ee,e[54]=q):q=e[54];let he;e[55]===Symbol.for("react.memo_cache_sentinel")?(he=()=>v("upload"),e[55]=he):he=e[55];const ue=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let de;e[56]!==ue?(de=re("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ue),e[56]=ue,e[57]=de):de=e[57];let fe;e[58]!==de?(fe=o.jsx("button",{type:"button",onClick:he,className:de,children:"Upload"}),e[58]=de,e[59]=fe):fe=e[59];let He;e[60]===Symbol.for("react.memo_cache_sentinel")?(He=o.jsx("div",{className:"flex-1"}),e[60]=He):He=e[60];let Ae;e[61]!==q||e[62]!==fe?(Ae=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[q,fe,He]}),e[61]=q,e[62]=fe,e[63]=Ae):Ae=e[63];let We;e[64]!==R||e[65]!==C||e[66]!==B||e[67]!==T||e[68]!==N.name||e[69]!==N.type||e[70]!==b||e[71]!==D||e[72]!==g?(We=g==="icons"?o.jsx(yd,{search:b,onSearchChange:S,selectedColor:D,onColorChange:R,onSelectIcon:B,onRandom:C,currentIconName:N.type==="icon"?N.name:null}):o.jsx(wd,{onUpload:T}),e[64]=R,e[65]=C,e[66]=B,e[67]=T,e[68]=N.name,e[69]=N.type,e[70]=b,e[71]=D,e[72]=g,e[73]=We):We=e[73];let Ue;e[74]!==Y||e[75]!==Ae||e[76]!==We?(Ue=o.jsx(Ks,{align:"start",className:"w-80 p-0",onOpenAutoFocus:xd,children:o.jsxs("div",{className:"flex flex-col",children:[Y,Ae,We]})}),e[74]=Y,e[75]=Ae,e[76]=We,e[77]=Ue):Ue=e[77];let ot;return e[78]!==M||e[79]!==V||e[80]!==se||e[81]!==G||e[82]!==Ue?(ot=o.jsxs(M,{open:V,onOpenChange:se,children:[G,Ue]}),e[78]=M,e[79]=V,e[80]=se,e[81]=G,e[82]=Ue,e[83]=ot):ot=e[83],ot}function xd(t){return t.preventDefault()}function bd(t){const e=H.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=L.useState(!1);let a,l,h,c,u,d,f;if(e[0]!==r||e[1]!==s){const b=aa(s);l=qs,d=r,f=n,a=Vs,u=!0,h="button",c=re("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",b.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=h,e[5]=c,e[6]=u,e[7]=d,e[8]=f}else a=e[2],l=e[3],h=e[4],c=e[5],u=e[6],d=e[7],f=e[8];let _;e[9]!==h||e[10]!==c?(_=o.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=_):_=e[11];let m;e[12]!==a||e[13]!==u||e[14]!==_?(m=o.jsx(a,{asChild:u,children:_}),e[12]=a,e[13]=u,e[14]=_,e[15]=m):m=e[15];let p;e[16]!==i||e[17]!==s?(p=Ec.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:re("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",b.dot,s===b.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:b.name},b.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let g;e[19]!==p?(g=o.jsx(Ks,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Sd,children:o.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=g):g=e[20];let v;return e[21]!==l||e[22]!==d||e[23]!==f||e[24]!==m||e[25]!==g?(v=o.jsxs(l,{open:d,onOpenChange:f,children:[m,g]}),e[21]=l,e[22]=d,e[23]=f,e[24]=m,e[25]=g,e[26]=v):v=e[26],v}function Sd(t){return t.preventDefault()}function yd(t){const e=H.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,u,d,f,_,m,p;if(e[0]!==h||e[1]!==n||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const x=nn(),w=aa(r);u=s.trim()?x.filter(R=>{const y=mr(R),T=s.toLowerCase();return y.includes(T)||R.toLowerCase().includes(T)}):x,m="flex flex-col";let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(Ra,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=k):k=e[14];let N;e[15]!==i?(N=R=>i(R.target.value),e[15]=i,e[16]=N):N=e[16];let D;e[17]!==s||e[18]!==N?(D=o.jsxs("div",{className:"relative flex-1",children:[k,o.jsx(_s,{value:s,onChange:N,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=N,e[19]=D):D=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(jc,{size:14,className:"text-muted-foreground"}),e[20]=j):j=e[20];let B;e[21]!==l?(B=o.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:j}),e[21]=l,e[22]=B):B=e[22];let I;e[23]!==n||e[24]!==r?(I=o.jsx(bd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=I):I=e[25],e[26]!==B||e[27]!==I||e[28]!==D?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[D,B,I]}),e[26]=B,e[27]=I,e[28]=D,e[29]=p):p=e[29],c=Da,_="h-56",d="grid grid-cols-9 gap-0.5 px-2 pb-2",f=u.map(R=>{const y=Mi(R);return y?o.jsx("button",{type:"button",onClick:()=>a(R),className:re("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===R?re(w.bg,w.text):re(w.text,"hover:bg-accent")),title:R,children:o.jsx(y,{size:18})},R):null}),e[0]=h,e[1]=n,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=_,e[12]=m,e[13]=p}else c=e[7],u=e[8],d=e[9],f=e[10],_=e[11],m=e[12],p=e[13];let g;e[30]!==d||e[31]!==f?(g=o.jsx("div",{className:d,children:f}),e[30]=d,e[31]=f,e[32]=g):g=e[32];let v;e[33]!==u.length?(v=u.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=u.length,e[34]=v):v=e[34];let b;e[35]!==c||e[36]!==_||e[37]!==g||e[38]!==v?(b=o.jsxs(c,{className:_,children:[g,v]}),e[35]=c,e[36]=_,e[37]=g,e[38]=v,e[39]=b):b=e[39];let S;return e[40]!==m||e[41]!==p||e[42]!==b?(S=o.jsxs("div",{className:m,children:[p,b]}),e[40]=m,e[41]=p,e[42]=b,e[43]=S):S=e[43],S}function wd(t){const e=H.c(27),{onUpload:s}=t,i=L.useRef(null);let r;e[0]!==s?(r=k=>{const N=k.target.files?.[0];if(!N)return;if(N.size>2097152){_e.error("Image must be smaller than 2MB"),k.target.value="";return}const D=new FileReader;D.onerror=()=>{_e.error("Failed to read image file"),i.current&&(i.current.value="")},D.onloadend=()=>{D.readyState===FileReader.DONE&&D.result&&s(D.result),i.current&&(i.current.value="")},D.readAsDataURL(N)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=L.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const k=a.trim();k&&(s(k),l(""))},e[2]=s,e[3]=a,e[4]=h):h=e[4];const c=h;let u;e[5]!==n?(u=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i.current?.click(),e[7]=d):d=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsxs("button",{type:"button",onClick:d,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[o.jsx(lc,{size:20}),o.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=_):_=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=k=>l(k.target.value),e[10]=m):m=e[10];let p;e[11]!==c?(p=k=>{k.key==="Enter"&&(k.preventDefault(),c())},e[11]=c,e[12]=p):p=e[12];let g;e[13]!==a||e[14]!==p?(g=o.jsx(_s,{value:a,onChange:m,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=g):g=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const b=!v;let S;e[18]!==c||e[19]!==b?(S=o.jsx(ne,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:b,children:"Apply"}),e[18]=c,e[19]=b,e[20]=S):S=e[20];let x;e[21]!==S||e[22]!==g?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,S]}),e[21]=S,e[22]=g,e[23]=x):x=e[23];let w;return e[24]!==x||e[25]!==u?(w=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,f,_,x]}),e[24]=x,e[25]=u,e[26]=w):w=e[26],w}function Cd(t){const e=H.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=Ri(s);if(n.type==="icon"){const a=Mi(n.name);if(a){let l;e[2]!==a?(l=o.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(Uc,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function kd(t){const e=H.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=L.useState(!1),[h,c]=L.useState("");let u;e[0]!==s?(u=Ri(s),e[0]=s,e[1]=u):u=e[1];const d=u,f=d.type==="icon"?d.name:null;let _,m,p,g,v,b,S,x,w,k,N,D,j,B,I;if(e[2]!==r||e[3]!==f||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const M=nn();g=h.trim()?M.filter(X=>{const $=h.toLowerCase();return mr(X).includes($)||X.toLowerCase().includes($)}):M,p=qs,v=n?!1:a,b=l;const F=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let U;e[24]!==r||e[25]!==F?(U=re("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",F,r),e[24]=r,e[25]=F,e[26]=U):U=e[26];let z;e[27]!==s?(z=o.jsx(Cd,{value:s}),e[27]=s,e[28]=z):z=e[28],e[29]!==n||e[30]!==U||e[31]!==z?(S=o.jsx(Vs,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:U,children:z})}),e[29]=n,e[30]=U,e[31]=z,e[32]=S):S=e[32],m=Ks,j="start",B="w-64 p-0",I=Nd,N="flex flex-col";let V;e[33]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx(Ra,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=V):V=e[33];let se;e[34]===Symbol.for("react.memo_cache_sentinel")?(se=X=>c(X.target.value),e[34]=se):se=e[34],e[35]!==h?(D=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[V,o.jsx(_s,{value:h,onChange:se,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=D):D=e[36],_=Da,k="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let te;e[37]!==f||e[38]!==i?(te=X=>{const $=Mi(X);return $?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${X}`),l(!1)},className:re("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===X?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:mr(X),children:o.jsx($,{size:16})},X):null},e[37]=f,e[38]=i,e[39]=te):te=e[39],w=g.map(te),e[2]=r,e[3]=f,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=_,e[10]=m,e[11]=p,e[12]=g,e[13]=v,e[14]=b,e[15]=S,e[16]=x,e[17]=w,e[18]=k,e[19]=N,e[20]=D,e[21]=j,e[22]=B,e[23]=I}else _=e[9],m=e[10],p=e[11],g=e[12],v=e[13],b=e[14],S=e[15],x=e[16],w=e[17],k=e[18],N=e[19],D=e[20],j=e[21],B=e[22],I=e[23];let R;e[40]!==x||e[41]!==w?(R=o.jsx("div",{className:x,children:w}),e[40]=x,e[41]=w,e[42]=R):R=e[42];let y;e[43]!==g.length?(y=g.length===0&&o.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=g.length,e[44]=y):y=e[44];let T;e[45]!==_||e[46]!==R||e[47]!==y||e[48]!==k?(T=o.jsxs(_,{className:k,children:[R,y]}),e[45]=_,e[46]=R,e[47]=y,e[48]=k,e[49]=T):T=e[49];let E;e[50]!==T||e[51]!==N||e[52]!==D?(E=o.jsxs("div",{className:N,children:[D,T]}),e[50]=T,e[51]=N,e[52]=D,e[53]=E):E=e[53];let C;e[54]!==m||e[55]!==E||e[56]!==j||e[57]!==B||e[58]!==I?(C=o.jsx(m,{align:j,className:B,onOpenAutoFocus:I,children:E}),e[54]=m,e[55]=E,e[56]=j,e[57]=B,e[58]=I,e[59]=C):C=e[59];let P;return e[60]!==p||e[61]!==v||e[62]!==b||e[63]!==S||e[64]!==C?(P=o.jsxs(p,{open:v,onOpenChange:b,children:[S,C]}),e[60]=p,e[61]=v,e[62]=b,e[63]=S,e[64]=C,e[65]=P):P=e[65],P}function Nd(t){return t.preventDefault()}function ui(){const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx(Me,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Gi(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[o.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:o.jsx($l,{className:"h-6 w-6 text-destructive"})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),o.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function jd(t){const e=H.c(23),{item:s,isSelected:i,onToggle:r,disabled:n}=t,a=n?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let h;e[0]!==a||e[1]!==l?(h=re("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=h):h=e[2];let c;e[3]!==s.name?(c=o.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let u;e[5]!==s.tags?(u=s.tags&&o.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=u):u=e[6];let d;e[7]!==c||e[8]!==u?(d=o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,u]}),e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]!==s.description?(f=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let _;e[12]!==d||e[13]!==f?(_=o.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[d,f]}),e[12]=d,e[13]=f,e[14]=_):_=e[14];let m;e[15]!==n||e[16]!==i||e[17]!==r?(m=o.jsx(gh,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=m):m=e[18];let p;return e[19]!==h||e[20]!==_||e[21]!==m?(p=o.jsxs("label",{className:h,children:[_,m]}),e[19]=h,e[20]=_,e[21]=m,e[22]=p):p=e[22],p}function hn(t){const e=H.c(13),{items:s,selections:i,onToggle:r,emptyMessage:n,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==n||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const d=s.map(Ed);if(s.length===0){let f;e[8]!==n?(f=o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:n})}),e[8]=n,e[9]=f):f=e[9],c=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(f=>o.jsx(jd,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,d),disabled:a},f.id))}e[0]=a,e[1]=n,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=h,e[7]=c}else l=e[5],h=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;return e[10]!==l||e[11]!==h?(u=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=u):u=e[12],u}function Ed(t){return t.id}function Td(t){const e=H.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ge();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=Fe(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Bc(c);let d;e[6]!==u.tools?(d=u.tools.map(Dd),e[6]=u.tools,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(hn,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function Dd(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(lh,{annotations:t.annotations,_meta:t._meta})}}function Rd(t){const e=H.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ge();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=Fe(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=nh(c);let d;e[6]!==u.resources?(d=u.resources.map(Md),e[6]=u.resources,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(hn,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function Md(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Id(t){const e=H.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ge();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=Fe(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=vh(c);let d;e[6]!==u.prompts?(d=u.prompts.map(Ad),e[6]=u.prompts,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(hn,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function Ad(t){return{id:t.name,name:t.name,description:t.description}}function Bd(t){const e=H.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:u,toggleAllPrompts:d,onTabChange:f}=t,_=n[r],m=i==="tools"?_?.tools===null:i==="resources"?_?.resources===null:_?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==u||e[4]!==c?(p=()=>{i==="tools"?c(r):i==="resources"?u(r):d(r)},e[0]=i,e[1]=r,e[2]=d,e[3]=u,e[4]=c,e[5]=p):p=e[5];const g=p;let v;e[6]!==s.icon||e[7]!==s.title?(v=o.jsx(us,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=v):v=e[8];let b;e[9]!==s.title?(b=o.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=b):b=e[10];let S;e[11]!==s.description?(S=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=S):S=e[12];let x;e[13]!==b||e[14]!==S?(x=o.jsxs("div",{className:"flex-1 min-w-0",children:[b,S]}),e[13]=b,e[14]=S,e[15]=x):x=e[15];let w;e[16]!==v||e[17]!==x?(w=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[v,x]})}),e[16]=v,e[17]=x,e[18]=w):w=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=k):k=e[19];let N;e[20]!==f?(N=P=>f(P),e[20]=f,e[21]=N):N=e[21];let D;e[22]!==i||e[23]!==N?(D=o.jsx(ph,{tabs:k,activeTab:i,onTabChange:N}),e[22]=i,e[23]=N,e[24]=D):D=e[24];const j=m?"Deselect all":"Select all";let B;e[25]!==g||e[26]!==j?(B=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:j}),e[25]=g,e[26]=j,e[27]=B):B=e[27];let I;e[28]!==B||e[29]!==D?(I=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[D,B]}),e[28]=B,e[29]=D,e[30]=I):I=e[30];let R;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(R=i==="tools"&&o.jsx(Ht,{fallback:Gi("Tools not supported by this server"),children:o.jsx(L.Suspense,{fallback:o.jsx(ui,{}),children:o.jsx(Td,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(P,M)=>a(r,P,M)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=R):R=e[35];let y;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(y=i==="resources"&&o.jsx(Ht,{fallback:Gi("Resources not supported by this server"),children:o.jsx(L.Suspense,{fallback:o.jsx(ui,{}),children:o.jsx(Rd,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(P,M)=>l(r,P,M)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=y):y=e[40];let T;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(T=i==="prompts"&&o.jsx(Ht,{fallback:Gi("Prompts not supported by this server"),children:o.jsx(L.Suspense,{fallback:o.jsx(ui,{}),children:o.jsx(Id,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(P,M)=>h(r,P,M)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=T):T=e[45];let E;e[46]!==R||e[47]!==y||e[48]!==T?(E=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[R,y,T]}),e[46]=R,e[47]=y,e[48]=T,e[49]=E):E=e[49];let C;return e[50]!==I||e[51]!==E||e[52]!==w?(C=o.jsxs(o.Fragment,{children:[w,I,E]}),e[50]=I,e[51]=E,e[52]=w,e[53]=C):C=e[53],C}function Pd(t){const e=H.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let n;e[0]!==s?(n={connectionId:s},e[0]=s,e[1]=n):n=e[1];const a=ga(n);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:o.jsx(Tc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),o.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=u):u=e[3];let d;e[4]!==s||e[5]!==i?(d=i&&o.jsx(ne,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=d):d=e[6];let f;return e[7]!==d?(f=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,u,d]}),e[7]=d,e[8]=f):f=e[8],f}let h;return e[9]!==r?(h=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function Ld(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function Un(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Od(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function zd(t){const e=H.c(49),{open:s,onOpenChange:i,selectedId:r,form:n,connections:a,onAuthenticate:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={activeTab:"tools"},e[0]=h):h=e[0];const[c,u]=L.useReducer(Od,h),d=on(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let _;e[3]!==f?(_=Ld(f),e[3]=f,e[4]=_):_=e[4];const m=_;let p;e[5]!==n||e[6]!==m?(p=(V,se,te,X)=>{const $=m[V]?.[se];let A;$===null?A=X.filter(Y=>Y!==te):$?.includes(te)?A=$.filter(Y=>Y!==te):(A=[...$??[],te],A.length===X.length&&(A=null));const G={...m};G[V]?G[V]={...G[V]}:G[V]={tools:null,resources:null,prompts:null},G[V][se]=A,n.setValue("connections",Un(G),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=m,e[7]=p):p=e[7];const g=p;let v;e[8]!==n||e[9]!==m?(v=(V,se)=>{const X=m[V]?.[se]===null?[]:null,$={...m};$[V]?$[V]={...$[V]}:$[V]={tools:null,resources:null,prompts:null},$[V][se]=X,n.setValue("connections",Un($),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=m,e[10]=v):v=e[10];const b=v;let S;e[11]!==g?(S=(V,se,te)=>g(V,"tools",se,te),e[11]=g,e[12]=S):S=e[12];const x=S;let w;e[13]!==g?(w=(V,se,te)=>g(V,"resources",se,te),e[13]=g,e[14]=w):w=e[14];const k=w;let N;e[15]!==g?(N=(V,se,te)=>g(V,"prompts",se,te),e[15]=g,e[16]=N):N=e[16];const D=N;let j;e[17]!==b?(j=V=>b(V,"tools"),e[17]=b,e[18]=j):j=e[18];const B=j;let I;e[19]!==b?(I=V=>b(V,"resources"),e[19]=b,e[20]=I):I=e[20];const R=I;let y;e[21]!==b?(y=V=>b(V,"prompts"),e[21]=b,e[22]=y):y=e[22];const T=y;if(!r||!d)return null;let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ui,{}),e[23]=E):E=e[23];let C;e[24]===Symbol.for("react.memo_cache_sentinel")?(C=V=>u({type:"SET_ACTIVE_TAB",payload:V}),e[24]=C):C=e[24];let P;e[25]!==d||e[26]!==c.activeTab||e[27]!==m||e[28]!==r||e[29]!==T||e[30]!==R||e[31]!==B||e[32]!==D||e[33]!==k||e[34]!==x?(P=o.jsx(Bd,{currentConnection:d,activeTab:c.activeTab,selectedId:r,formData:m,toggleTool:x,toggleResource:k,togglePrompt:D,toggleAllTools:B,toggleAllResources:R,toggleAllPrompts:T,onTabChange:C},r),e[25]=d,e[26]=c.activeTab,e[27]=m,e[28]=r,e[29]=T,e[30]=R,e[31]=B,e[32]=D,e[33]=k,e[34]=x,e[35]=P):P=e[35];let M;e[36]!==l||e[37]!==r||e[38]!==P?(M=o.jsx(L.Suspense,{fallback:E,children:o.jsx(Pd,{connectionId:r,onAuthenticate:l,children:P})}),e[36]=l,e[37]=r,e[38]=P,e[39]=M):M=e[39];let F;e[40]!==i?(F=o.jsx(dh,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(ne,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=F):F=e[41];let U;e[42]!==M||e[43]!==F?(U=o.jsxs(an,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[M,F]}),e[42]=M,e[43]=F,e[44]=U):U=e[44];let z;return e[45]!==i||e[46]!==s||e[47]!==U?(z=o.jsx(ln,{open:s,onOpenChange:i,children:U}),e[45]=i,e[46]=s,e[47]=U,e[48]=z):z=e[48],z}const Yi={tools:null,resources:null,prompts:null},$d=Fl.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Fd(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function Hd(t){const e=H.c(11),{url:s,agentId:i}=t,[r,n]=L.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Se("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),_e.success("Agent URL copied to clipboard"),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let h;e[3]!==r?(h=r?o.jsx(Bi,{size:20,className:"text-green-600"}):o.jsx(Di,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let u;e[5]!==c?(u=o.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==h||e[9]!==u?(d=o.jsxs(ne,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,u]}),e[7]=l,e[8]=h,e[9]=u,e[10]=d):d=e[10],d}function Wd(t){const e=H.c(8),{url:s,serverName:i,agentId:r}=t;let n;e[0]!==r||e[1]!==i||e[2]!==s?(n=()=>{Se("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=va(i),f=Fd(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),_=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(f)}`;window.open(_,"_blank"),_e.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=n):n=e[3];const a=n;let l,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),h=o.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=h):(l=e[4],h=e[5]);let c;return e[6]!==a?(c=o.jsxs(ne,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,h]}),e[6]=a,e[7]=c):c=e[7],c}function Ud(t){const e=H.c(12),{url:s,serverName:i,agentId:r}=t,[n,a]=L.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{Se("agent_connect_action",{agent_id:r,action:"install_claude_code"});const _=va(i),p=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${_}" '${p.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(g),a(!0),_e.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=r,e[1]=i,e[2]=s,e[3]=l):l=e[3];const h=l;let c;e[4]!==n?(c=n?o.jsx(Bi,{size:20,className:"text-green-600"}):o.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=n,e[5]=c):c=e[5];const u=n?"Copied!":"Install on Claude Code";let d;e[6]!==u?(d=o.jsx("span",{className:"text-xs font-medium",children:u}),e[6]=u,e[7]=d):d=e[7];let f;return e[8]!==h||e[9]!==c||e[10]!==d?(f=o.jsxs(ne,{type:"button",variant:"outline",onClick:h,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,d]}),e[8]=h,e[9]=c,e[10]=d,e[11]=f):f=e[11],f}function Vd({virtualMcp:t}){const{org:e}=ge(),s=Fe({connectionId:Bt,orgId:e.id,orgSlug:e.slug}),[i,r]=L.useState(null),[n,a]=L.useState(!1),[l,h]=L.useState(!1),c=t.id,u=t.title||`agent-${c.slice(0,8)}`,d=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${u}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),Se("agent_typegen_key_generated",{agent_id:c})}catch{Se("agent_typegen_key_failed",{agent_id:c}),_e.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{Se("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(d),h(!0),_e.success("Command copied to clipboard"),setTimeout(()=>h(!1),2e3)};return o.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",o.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&o.jsxs(ne,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:n,children:[n?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(_h,{size:14}),o.jsx("span",{children:n?"Generating…":"Generate API key"})]})]}),i&&o.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:d}),o.jsx(ne,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Bi,{size:12,className:"text-green-600"}):o.jsx(Di,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(Kd,{apiKey:i,agentId:c})]})}function Kd(t){const e=H.c(21),{apiKey:s,agentId:i}=t,[r,n]=L.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
|
|
4
4
|
${h}`;let u;e[0]!==i||e[1]!==s||e[2]!==c?(u=async()=>{Se("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=u):u=e[3];const d=u,f=!s;let _;e[4]!==f?(_=re({"opacity-50":f}),e[4]=f,e[5]=_):_=e[5];let m;e[6]!==l||e[7]!==_?(m=o.jsx("span",{className:_,children:l}),e[6]=l,e[7]=_,e[8]=m):m=e[8];let p,g;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("br",{}),g=o.jsx("span",{children:h}),e[9]=p,e[10]=g):(p=e[9],g=e[10]);let v;e[11]!==m?(v=o.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[m,p,g]}),e[11]=m,e[12]=v):v=e[12];let b;e[13]!==r?(b=r?o.jsx(Bi,{size:12,className:"text-green-600"}):o.jsx(Di,{size:12}),e[13]=r,e[14]=b):b=e[14];let S;e[15]!==d||e[16]!==b?(S=o.jsx(ne,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:d,children:b}),e[15]=d,e[16]=b,e[17]=S):S=e[17];let x;return e[18]!==v||e[19]!==S?(x=o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[v,S]})}),e[18]=v,e[19]=S,e[20]=x):x=e[20],x}function qd(t){const e=H.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(L.Suspense,{fallback:i,children:o.jsx(Vd,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Gd(t){const e=H.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:n}=ge(),a=`/api/${n.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const h=l;let c;e[2]!==r.id||e[3]!==r.title?(c=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=c):c=e[4];const u=c,d=fa();let f;e[5]!==r.id||e[6]!==h.href?(f=o.jsx(Hd,{url:h.href,agentId:r.id}),e[5]=r.id,e[6]=h.href,e[7]=f):f=e[7];let _,m;e[8]!==u||e[9]!==r.id||e[10]!==h.href?(_=o.jsx(Wd,{url:h.href,serverName:u,agentId:r.id}),m=o.jsx(Ud,{url:h.href,serverName:u,agentId:r.id}),e[8]=u,e[9]=r.id,e[10]=h.href,e[11]=_,e[12]=m):(_=e[11],m=e[12]);let p;e[13]!==f||e[14]!==_||e[15]!==m?(p=o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,_,m]})}),e[13]=f,e[14]=_,e[15]=m,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let v;e[18]!==r?(v=o.jsx(qd,{virtualMcp:r}),e[18]=r,e[19]=v):v=e[19];let b;e[20]!==p||e[21]!==v?(b=o.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,v]}),e[20]=p,e[21]=v,e[22]=b):b=e[22];const S=b;if(d){let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Sh,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=N):N=e[23];let D;e[24]!==S?(D=o.jsx(yh,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[N,S]})}),e[24]=S,e[25]=D):D=e[25];let j;return e[26]!==i||e[27]!==s||e[28]!==D?(j=o.jsx(wh,{open:s,onOpenChange:i,children:D}),e[26]=i,e[27]=s,e[28]=D,e[29]=j):j=e[29],j}let x;e[30]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(ja,{children:o.jsx(Ea,{children:"Connect"})}),e[30]=x):x=e[30];let w;e[31]!==S?(w=o.jsxs(an,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[x,S]}),e[31]=S,e[32]=w):w=e[32];let k;return e[33]!==i||e[34]!==s||e[35]!==w?(k=o.jsx(ln,{open:s,onOpenChange:i,children:w}),e[33]=i,e[34]=s,e[35]=w,e[36]=k):k=e[36],k}function Yd(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function Xd(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function Jd(t){const e=H.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=on(s),{org:u}=ge();if(!c)return null;let d;e[0]!==c?(d=hh(c),e[0]=c,e[1]=d):d=e[1];const f=d;let _;e[2]!==s?(_=o.jsx(tu,{connection_id:s}),e[2]=s,e[3]=_):_=e[3];let m;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==u.slug||e[16]!==f||e[17]!==i?(m=o.jsx(eu,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:f,orgSlug:u.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=n,e[14]=l,e[15]=u.slug,e[16]=f,e[17]=i,e[18]=m):m=e[18];let p;return e[19]!==_||e[20]!==m?(p=o.jsx(L.Suspense,{fallback:_,children:m}),e[19]=_,e[20]=m,e[21]=p):p=e[21],p}const Vn="__new_instance__";async function Zd(t,e){const s=t?.idToken??null;if(s){const r=Kn(s);if(r)return r}const i=t?.userinfoEndpoint??null;if(i)try{const r=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const n=await r.json(),a=typeof n.email=="string"?n.email:typeof n.upn=="string"?n.upn:typeof n.preferred_username=="string"?n.preferred_username:null;if(a)return a}}catch{}return Kn(e)}function Kn(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function Qd(t){const e=H.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:n,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const h=Ai(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===Vn?a?.():n(i,p)},e[2]=i,e[3]=a,e[4]=n,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(ss,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(is,{})}),e[6]=u):u=e[6];let d;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>o.jsx(It,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=p):p=e[13],d=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=d}else d=e[10];let f;e[14]!==a?(f=a&&o.jsx(It,{value:Vn,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let _;e[16]!==d||e[17]!==f?(_=o.jsxs(rs,{children:[d,f]}),e[16]=d,e[17]=f,e[18]=_):_=e[18];let m;return e[19]!==i||e[20]!==c||e[21]!==_?(m=o.jsxs(ts,{value:i,onValueChange:c,children:[u,_]}),e[19]=i,e[20]=c,e[21]=_,e[22]=m):m=e[22],m}function eu(t){const e=H.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:n,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:u,onOpenSettings:d,onRemove:f,onAuthenticate:_,onSwitchInstance:m,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=ga(g),S=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,x=S?"border-destructive/50 bg-destructive/5":"border-border";let w;e[2]!==x?(w=re("rounded-xl border overflow-hidden transition-colors",x),e[2]=x,e[3]=w):w=e[3];let k;e[4]!==h||e[5]!==l?(k={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=k):k=e[6];let N;e[7]!==n||e[8]!==i?(N=o.jsx(us,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=N):N=e[9];let D;e[10]!==i?(D=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=D):D=e[11];let j;e[12]!==r||e[13]!==S?(j=S?o.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=S,e[14]=j):j=e[14];let B;e[15]!==D||e[16]!==j?(B=o.jsxs("div",{className:"flex-1 min-w-0",children:[D,j]}),e[15]=D,e[16]=j,e[17]=B):B=e[17];let I;e[18]!==s||e[19]!==S||e[20]!==_?(I=S?o.jsx(ne,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:X=>{X.preventDefault(),X.stopPropagation(),_(s)},children:"Authorize"}):o.jsxs(qe,{delayDuration:0,children:[o.jsx(Ge,{asChild:!0,children:o.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:o.jsx(fh,{size:16})})}),o.jsx(Ye,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=_,e[21]=I):I=e[21];let R;e[22]!==k||e[23]!==N||e[24]!==B||e[25]!==I?(R=o.jsxs(Ul,{to:"/$org/settings/connections/$appSlug",params:k,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[N,B,I]}),e[22]=k,e[23]=N,e[24]=B,e[25]=I,e[26]=R):R=e[26];let y;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==m||e[31]!==u?(y=c&&o.jsx(Qd,{appName:c,connectionId:s,usedConnectionIds:u,onSwitchInstance:m,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=m,e[31]=u,e[32]=y):y=e[32];let T;e[33]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsx(Rc,{size:13}),e[33]=T):T=e[33];let E;e[34]!==d?(E=o.jsx(Ge,{asChild:!0,children:o.jsx(ne,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d,"aria-label":"Configure resources",children:T})}),e[34]=d,e[35]=E):E=e[35];let C;e[36]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(Ye,{side:"bottom",children:"Configure resources"}),e[36]=C):C=e[36];let P;e[37]!==E?(P=o.jsxs(qe,{delayDuration:0,children:[E,C]}),e[37]=E,e[38]=P):P=e[38];let M;e[39]===Symbol.for("react.memo_cache_sentinel")?(M=o.jsx(ls,{size:13}),e[39]=M):M=e[39];let F;e[40]!==f?(F=o.jsx(Ge,{asChild:!0,children:o.jsx(ne,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:M})}),e[40]=f,e[41]=F):F=e[41];let U;e[42]===Symbol.for("react.memo_cache_sentinel")?(U=o.jsx(Ye,{side:"bottom",children:"Remove"}),e[42]=U):U=e[42];let z;e[43]!==F?(z=o.jsxs(qe,{delayDuration:0,children:[F,U]}),e[43]=F,e[44]=z):z=e[44];let V;e[45]!==P||e[46]!==z?(V=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[P,z]}),e[45]=P,e[46]=z,e[47]=V):V=e[47];let se;e[48]!==y||e[49]!==V?(se=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[y,V]}),e[48]=y,e[49]=V,e[50]=se):se=e[50];let te;return e[51]!==R||e[52]!==se||e[53]!==w?(te=o.jsxs("div",{className:w,children:[R,se]}),e[51]=R,e[52]=se,e[53]=w,e[54]=te):te=e[54],te}function tu(t){const e=H.c(17),{connection_id:s}=t,i=on(s);if(!i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Oa,{}),e[0]=d):d=e[0],d}let r;e[1]!==i.icon||e[2]!==i.title?(r=o.jsx(us,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=r):r=e[3];let n;e[4]!==i.title?(n=o.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=n):n=e[5];let a;e[6]!==i.description?(a=i.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==n||e[9]!==a?(l=o.jsxs("div",{className:"flex-1 min-w-0",children:[n,a]}),e[8]=n,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let u;return e[15]!==h?(u=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=u):u=e[16],u}function Oa(){const t=H.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),o.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function su({virtualMcpId:t,form:e,flushAndSave:s}){const{org:i}=ge(),r=Fe({connectionId:Bt,orgId:i.id,orgSlug:i.slug}),n=Ct(t),a=(n?.connections??[]).map(y=>y.connection_id).sort(),{data:l}=Xo({queryKey:Ls.projectConnectionDetails(t,a),enabled:a.length>0,queryFn:async()=>await Promise.all(a.map(async T=>{try{const E=await r.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:T}}),{item:C}=ch(E),P=(C?.tools??[]).filter(M=>!!oh(M._meta)).map(M=>({name:M.name,description:M.description}));return{fetchOk:!0,id:T,title:C?.title??T,icon:C?.icon??null,uiTools:P}}catch{return{fetchOk:!1,id:T,title:T,icon:null,uiTools:[]}}}))}),h=(l??[]).filter(y=>y.uiTools.length>0),c=new Set(mc),u=e.watch("metadata.ui.pinnedViews")??[],d=e.watch("metadata.ui.layout")??null,f=d?.defaultMainView??null,_=d?.chatDefaultOpen??!1,m=!f||f.type==="chat"?"chat":f.type==="instructions"||f.type==="connections"||f.type==="layout"?"settings":c.has(f.type)?f.type:`${f.type}:${f.id??""}:${f.toolName??""}`,p=y=>{const[T,E,C]=y.split(":");return T?T==="chat"?{type:T}:c.has(T)?{type:T}:T==="ext-apps"&&E?{type:"ext-apps",id:E,toolName:C||void 0}:null:null},g=y=>{e.setValue("metadata.ui.pinnedViews",y,{shouldDirty:!0})},v=y=>{e.setValue("metadata.ui.layout",{...d,...y},{shouldDirty:!0})},b=L.useRef(!1);if(l&&l.length>0&&!b.current){b.current=!0;const y=new Set((l??[]).filter(C=>C.fetchOk).map(C=>C.id)),T=new Set(h.flatMap(C=>C.uiTools.map(P=>`${C.id}:${P.name}`))),E=u.filter(C=>!y.has(C.connectionId)||T.has(`${C.connectionId}:${C.toolName}`));E.length!==u.length&&(g(E),f?.type==="ext-apps"&&!E.some(C=>C.connectionId===f.id&&C.toolName===f.toolName)&&v({defaultMainView:{type:"chat"}}))}const S=(y,T)=>{if(u.some(C=>C.connectionId===y&&C.toolName===T)){const C=u.filter(M=>!(M.connectionId===y&&M.toolName===T));g(C);const P=`ext-apps:${y}:${T}`;m===P&&v({defaultMainView:{type:"chat"}})}else g([...u,{connectionId:y,toolName:T,label:Dn(T),icon:null}]);s()},x=(y,T,E)=>{g(u.map(C=>C.connectionId===y&&C.toolName===T?{...C,label:E}:C))},w=()=>{s()},k=(y,T,E)=>{g(u.map(C=>C.connectionId===y&&C.toolName===T?{...C,icon:E}:C)),s()},N=y=>{v({defaultMainView:p(y)}),s()},D=a.length===0,j=l&&h.length===0,B=!!Kt(n),I=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];B&&(I.push({value:"env",label:"Terminal"}),I.push({value:"preview",label:"Preview"}));for(const y of u)I.push({value:`ext-apps:${y.connectionId}:${y.toolName}`,label:y.label||y.toolName});const R=h.length>0||D||j;return o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-3",children:o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),o.jsxs(uh,{className:"p-6 gap-5",children:[o.jsxs(Ln,{className:"p-0 space-y-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(As,{className:"font-normal text-foreground",children:"Main view"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),o.jsxs(ts,{value:m,onValueChange:N,children:[o.jsx(ss,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(is,{})}),o.jsx(rs,{children:I.map(y=>o.jsx(It,{value:y.value,className:"capitalize",children:y.label},y.value))})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(As,{className:"font-normal text-foreground",children:"Show chat"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),o.jsxs(qe,{delayDuration:0,children:[o.jsx(Ge,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(pr,{checked:m==="chat"?!0:_,disabled:m==="chat",onCheckedChange:y=>{v({chatDefaultOpen:y}),s()}})})}),m==="chat"&&o.jsx(Ye,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),R&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(Ln,{className:"p-0 space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(As,{className:"font-normal text-foreground",children:"Pinned views"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),D&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),j&&!D&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),h.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:h.map((y,T)=>o.jsxs("div",{children:[T>0&&o.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx(us,{icon:y.icon,name:y.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:y.title})]}),o.jsx("div",{className:"space-y-1.5",children:y.uiTools.map(E=>{const C=u.some(M=>M.connectionId===y.id&&M.toolName===E.name),P=u.find(M=>M.connectionId===y.id&&M.toolName===E.name);return o.jsxs("div",{className:re("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",C?"bg-accent/40 border-border":"bg-transparent border-border"),children:[o.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[o.jsx(kd,{value:P?.icon??null,onChange:M=>k(y.id,E.name,M),disabled:!C}),o.jsx(_s,{value:C&&P?P.label:Dn(E.name),onChange:M=>x(y.id,E.name,M.target.value),onBlur:w,className:"h-7 text-sm w-40",disabled:!C,readOnly:!C})]}),o.jsx(pr,{checked:C,onCheckedChange:()=>S(y.id,E.name)})]},E.name)})})]},y.id))})]})]})]})]})}function iu({virtualMcp:t,hideOwnTitle:e}){const{org:s}=ge(),i=tc(),r=ih(),n=ds(),a=Fe({connectionId:Bt,orgId:s.id,orgSlug:s.slug}),l=Zo({resolver:Hl($d),defaultValues:t}),h=l.watch("connections"),c=!!Kt(t),[u,d]=L.useReducer(Yd,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[f,_]=L.useState(!1),[m,p]=L.useState(!1),{createNewTask:g,setChatOpen:v}=Ii(),{sendMessage:b}=fs(),S=_a(),x=async()=>{if(m)return;const A=l.getValues("metadata.instructions");if(A?.trim()){p(!0);try{B(),Se("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:A.length}),await S(["studio-agent-manager"]),v(!0),await b({tiptapDoc:La({managerAgentId:ia.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:A})})}finally{p(!1)}}},w=()=>{B(),Se("agent_test_clicked",{agent_id:t.id}),g()},[k,N]=L.useReducer(Xd,null),D=()=>{k!==null&&(Se("agent_updated",{agent_id:t.id,fields:Array.from(k.fields),instructions_length:k.instructionsLength,save_count:k.saveCount,edit_duration_ms:Date.now()-k.start}),N({type:"reset"}))},{schedule:j,flush:B}=bi({delayMs:3e4,save:async()=>D()}),I=async()=>{const A=Object.keys(l.control._formState.dirtyFields);if(A.length===0)return;const G=A.includes("metadata"),Y=l.getValues();l.reset(Y,{keepValues:!0}),await i.update.mutateAsync({id:t.id,data:Y}),N({type:"accumulate",now:Date.now(),fields:A,instructionsLength:G?Y.metadata?.instructions?.length??0:null}),j()},{schedule:R,flush:y}=bi({save:I});L.useEffect(()=>{const A=l.watch(()=>R());return()=>A.unsubscribe()},[]);const T=()=>{Se("connections_dialog_opened",{source:"agent_settings",mode:"add"}),d({type:"SET_ADD_DIALOG_OPEN",payload:!0})},E=async A=>{const G=l.getValues("connections");if(G.some(ie=>ie.connection_id===A))return;l.setValue("connections",[...G,{connection_id:A,selected_tools:Yi.tools,selected_resources:Yi.resources,selected_prompts:Yi.prompts}],{shouldDirty:!0}),d({type:"SET_ADD_DIALOG_OPEN",payload:!1});const Y=new URL(`/api/${s.slug}/mcp/${A}`,window.location.origin),Q=await Nn({url:Y.href,token:null,orgId:s.id});Q.supportsOAuth&&!Q.isAuthenticated&&await U(A)},C=A=>{const Y=l.getValues("connections").filter(Q=>Q.connection_id!==A);l.setValue("connections",Y,{shouldDirty:!0})},P=(A,G)=>{const Y=l.getValues("connections");if(Y.some(Q=>Q.connection_id===G)){_e.error("This instance is already added to the agent");return}l.setValue("connections",Y.map(Q=>Q.connection_id===A?{...Q,connection_id:G}:Q),{shouldDirty:!0})},M=async A=>{if(l.getValues("connections").find(Y=>Y.connection_id===A))try{const Y=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:A}}),{item:Q}=Y.structuredContent??{};if(!Q)return;const ie=Q.title.replace(/\s*\(.*?\)\s*$/,""),ee=rh("conn"),q=`${ie} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:ee,title:q,description:Q.description??null,connection_type:Q.connection_type,connection_url:Q.connection_url??null,connection_token:null,icon:Q.icon??null,app_name:Q.app_name??null,app_id:Q.app_id??null,connection_headers:Q.connection_headers??null});const he=new URL(`/api/${s.slug}/mcp/${ee}`,window.location.origin),ue=await Nn({url:he.href,token:null,orgId:s.id});if(ue.supportsOAuth&&!ue.isAuthenticated){const de=await U(ee);if(!de){await r.delete.mutateAsync(ee);return}await r.update.mutateAsync({id:ee,data:{title:`${ie} (${de})`}})}P(A,ee),_e.success("New instance created")}catch(Y){console.error("Failed to create instance:",Y),_e.error("Failed to create instance")}},F=A=>{d({type:"OPEN_SETTINGS",payload:A})},U=async A=>{const{token:G,tokenInfo:Y,error:Q}=await Wl({connectionId:A,orgSlug:s.slug,scope:"offline_access"});if(Q||!G)return _e.error(`Authentication failed: ${Q}`),null;if(Y)try{const ee=await fetch(`/api/${s.slug}/connections/${A}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:Y.accessToken,refreshToken:Y.refreshToken,expiresIn:Y.expiresIn,scope:Y.scope,clientId:Y.clientId,clientSecret:Y.clientSecret,tokenEndpoint:Y.tokenEndpoint})});if(!ee.ok)console.error("Failed to save OAuth token:",await ee.text()),await r.update.mutateAsync({id:A,data:{connection_token:G}});else try{await r.update.mutateAsync({id:A,data:{}})}catch(q){console.warn("Failed to refresh connection tools after OAuth:",q)}}catch(ee){console.error("Error saving OAuth token:",ee),await r.update.mutateAsync({id:A,data:{connection_token:G}})}else await r.update.mutateAsync({id:A,data:{connection_token:G}});const ie=new URL(`/api/${s.slug}/mcp/${A}`,window.location.origin);return await n.invalidateQueries({queryKey:Ls.isMCPAuthenticated(ie.href,null)}),_e.success("Authentication successful"),Zd(Y,G)},z=()=>{const A=l.getValues("metadata.instructions")??"",G=`<role>
|
|
5
5
|
Define who this agent is and what it specializes in.
|
|
@@ -179,4 +179,4 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
179
179
|
`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return xr.get()},set promptLabel(t){xr.set(t)},get tooMuchOutput(){return br.get()},set tooMuchOutput(t){br.set(t)}}}_verifyIntegers(...t){for(dt of t)if(dt===1/0||isNaN(dt)||dt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(dt of t)if(dt&&(dt===1/0||isNaN(dt)||dt%1!==0||dt<0))throw new Error("This API only accepts positive integers")}};var Tp=2,Dp=1,Rp=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,u=r-h-e;return{cols:Math.max(Tp,Math.floor(u/t.css.cell.width)),rows:Math.max(Dp,Math.floor(c/t.css.cell.height))}}};function Mp({source:t,onReady:e,onSelectionChange:s,className:i}){const r=L.useRef(null),n=L.useRef(null),a=L.useRef(s);a.current=s;const l=Gt(),h=L.useRef(t);return h.current=t,Zu((c,u)=>{c===h.current&&n.current?.write(u)}),L.useEffect(()=>{const c=r.current;if(!c)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,f=new Ep({allowTransparency:!1,fontFamily:d("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:d("--sidebar")||d("--card")||d("--background")||"#1e1e1e",cursor:"transparent",foreground:d("--foreground")||"#d4d4d4",selectionBackground:d("--accent"),selectionForeground:d("--accent-foreground"),black:d("--muted"),red:d("--destructive"),green:d("--success"),yellow:d("--warning"),blue:d("--chart-1"),magenta:d("--chart-3"),cyan:d("--chart-5"),white:d("--foreground"),brightBlack:d("--muted-foreground"),brightRed:d("--destructive"),brightGreen:d("--success"),brightYellow:d("--warning"),brightBlue:d("--chart-1"),brightMagenta:d("--chart-3"),brightCyan:d("--chart-5"),brightWhite:d("--foreground")}}),_=new Rp;f.loadAddon(_),f.open(c),_.fit();const m=l.getBuffer(t);m&&f.write(m),n.current=f,e?.(f);const p=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),g=new ResizeObserver(()=>{_.fit()});return g.observe(c),()=>{p.dispose(),g.disconnect(),n.current=null,f.dispose()}},[]),o.jsx("div",{ref:r,className:re("overflow-hidden bg-sidebar px-4 py-3 [&_.xterm]:h-full [&_.xterm-screen]:min-h-full [&_.xterm-viewport]:overscroll-contain",i)})}function Ip(){const t=H.c(2),s=yn()?.entity;let i;return t[0]!==s?(i=Kt(s),t[0]=s,t[1]=i):i=t[1],i}const Ap={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}},Bp=["dev","start"];function Pp({daemonOpen:t=!1}){const{org:e}=ge(),s=yn(),i=ds(),{data:r}=Ei.useSession(),{currentBranch:n,setCurrentTaskBranch:a}=gt(),l=r?.user?.id,h=s?.entity?.metadata,c=l&&n?h?.vmMap?.[l]?.[n]:void 0,u=c&&n?{previewUrl:c.previewUrl,vmId:c.vmId,branch:n,runnerKind:c.runnerKind}:null,[d,f]=L.useState(null),[_,m]=L.useState(""),[p,g]=L.useState(""),[v,b]=L.useState(!1),[S,x]=L.useState(new Set),w=L.useRef(!1),k=L.useRef(Date.now()),[N,D]=L.useState("setup"),[j,B]=L.useState([]),I=L.useRef(new Map),{sendMessage:R}=fs(),{setChatOpen:y}=Ii(),[T,E]=L.useState(!1),C=L.useRef(null),P=J=>{D(J),E(!1),C.current=null},M=(J,W,ae)=>{J===N&&(E(W),C.current=W?ae:null)},F=()=>{const J=C.current?.();if(!J)return;y(!0),R({parts:[{type:"text",text:`<server-logs>
|
|
180
180
|
${J}
|
|
181
181
|
</server-logs>`}]}),I.current.get(N)?.clearSelection()},U=Fe({connectionId:Bt,orgId:e.id,orgSlug:e.slug}),z=Gt(),V=z.phase?.kind==="failed"&&z.phase.reason==="sandbox-evicted",se=Ba(s?.entity?.id,n??void 0),te=z.suspended?"suspended":V?"idle":z.notFound?"creating":u?"running":se?"creating":"idle",X=d??te;if(L.useEffect(()=>{d==="creating"&&te==="running"&&f(null),d==="stopping"&&te==="idle"&&f(null)},[te,d]),S.size>0){let J=!1;const W=new Set(S);for(const ae of S)z.activeProcesses.includes(ae)||(W.delete(ae),J=!0);J&&x(W)}const $=cn(U),{mutate:A,isPending:G}=$,Y=s?.entity?.id,Q=z.notFound?c?.vmId??null:null,ie=L.useRef(null);L.useEffect(()=>{if(!Q||!Y||G||ie.current===Q)return;ie.current=Q;const J={virtualMcpId:Y};n&&(J.branch=n),A(J,{onError:W=>{console.error("[env] reprovision VM_START failed",W)}})},[Q,Y,n,G,A]);const ee=L.useRef(!1);L.useEffect(()=>{if(z.scripts.length>0&&!ee.current){ee.current=!0;for(const J of Bp)if(z.scripts.includes(J)){B([J]),P(J);break}}},[z.scripts]);const q=async(J,W)=>{const ae=await U.callTool({name:J,arguments:W}),Ne=ae.content;if(Ne?.[0]?.text?.startsWith("Error:"))throw new Error(Ne[0].text);return ae.structuredContent??ae},he=async J=>{if(!(v||!u||!Y||!n)){b(!0);try{const W=new URLSearchParams({virtualMcpId:Y,branch:n}).toString(),ae=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/exec/${encodeURIComponent(J)}?${W}`,{method:"POST"});if(!ae.ok)throw new Error(`Exec failed: ${ae.statusText}`)}finally{b(!1)}}},ue=async J=>{if(!(!u||!Y||!n)&&!S.has(J)){x(W=>{const ae=new Set(W);return ae.add(J),ae});try{const W=new URLSearchParams({virtualMcpId:Y,branch:n}).toString(),ae=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/kill/${encodeURIComponent(J)}?${W}`,{method:"POST"});if(!ae.ok)throw new Error(`Kill failed: ${ae.statusText}`)}catch{x(W=>{const ae=new Set(W);return ae.delete(J),ae}),_e.error(`Failed to stop ${J}`)}}},de=J=>{j.includes(J)||B(W=>[...W,J]),P(J),he(J)},fe=async()=>{if(!w.current){w.current=!0,s?.entity?.id&&n&&Si.clear(s.entity.id,n),k.current=Date.now(),f("creating"),m("Connecting..."),g(""),ee.current=!1,B([]),P("setup"),z.resetConnection();try{if(!s?.entity)throw new Error("No virtual MCP context");const J={virtualMcpId:s.entity.id};n&&(J.branch=n);const W=await q("VM_START",J);if(!W.vmId||!W.branch)throw new Error("Invalid VM response — missing fields");n||a(W.branch),m(""),ci(i)}catch(J){f("error"),g(J instanceof Error?J.message:"Failed to start VM")}finally{w.current=!1}}},He=async()=>{const J=u?.branch??n;f("stopping");const W=s?.entity?.id;if(W&&J&&Si.mark(W,J),W&&J)try{await U.callTool({name:"VM_DELETE",arguments:{virtualMcpId:W,branch:J}})}catch{}ci(i)},Ae=Ip(),We=s?.entity?.metadata?.runtime,Ue="__none__",ot=Object.keys(Ap),ke=async(J,W)=>{if(s?.entity)try{await U.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:s.entity.id,data:{metadata:{runtime:{...We,[J]:W}}}}}),ci(i)}catch{_e.error("Failed to update setting")}};if(X==="idle"||X==="stopping"){const J=X==="stopping";return o.jsx("div",{className:"flex flex-col items-center justify-center w-full h-full p-6",children:o.jsxs("div",{className:"flex flex-col gap-4 w-full max-w-xs",children:[Ae&&o.jsxs("a",{href:`https://github.com/${Ae.owner}/${Ae.name}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-4 rounded-lg border border-border hover:bg-accent/50 transition-colors",children:[o.jsx(ah,{size:24}),o.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[o.jsxs("span",{className:"text-sm font-medium truncate",children:[Ae.owner,"/",Ae.name]}),o.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["github.com/",Ae.owner,"/",Ae.name]})]}),o.jsx(qt,{size:14,className:"text-muted-foreground shrink-0"})]}),V&&o.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Sandbox was removed. Start a new one to continue."}),o.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-2 w-full",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(As,{htmlFor:"env-runtime",className:"text-xs font-medium",children:"Runtime"}),o.jsxs(ts,{value:We?.selected??Ue,onValueChange:W=>ke("selected",W===Ue?null:W),children:[o.jsx(ss,{id:"env-runtime",className:"w-28",children:o.jsx(is,{placeholder:"None"})}),o.jsxs(rs,{children:[o.jsx(It,{value:Ue,children:"None"}),ot.map(W=>o.jsx(It,{value:W,children:W},W))]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(As,{htmlFor:"env-port",className:"text-xs font-medium",children:"Port"}),o.jsx(_s,{id:"env-port",placeholder:"3001",className:"w-20 h-8",defaultValue:We?.port??"",onBlur:W=>ke("port",W.target.value||null)})]}),o.jsxs(ne,{onClick:fe,disabled:J,children:[J?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(di,{size:14}),J?"Stopping...":"Run"]})]})]})})}if(X==="creating"){const J=z.notFound?"Sandbox was stopped, we're restarting it…":_;return o.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full gap-4",children:[o.jsx(Me,{size:24,className:"animate-spin text-muted-foreground"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:J}),o.jsx(_c,{since:k.current})]})}if(X==="error")return o.jsx(Ua,{errorMsg:p,onRetry:fe});if(X==="suspended")return o.jsx(Wa,{onResume:fe});const xt=["setup",...j,...t?["daemon"]:[]],ei=z.scripts.filter(J=>!j.includes(J));return o.jsx("div",{className:"flex flex-col w-full h-full",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex h-12 items-center border-b border-border px-2 shrink-0",children:[xt.map(J=>o.jsx("button",{type:"button",onClick:()=>P(J),className:re("flex items-center h-full px-3 text-sm whitespace-nowrap border-b-2 mb-[-1px] capitalize transition-all hover:text-foreground",N===J?"text-foreground border-primary":"text-muted-foreground border-transparent"),children:J},J)),ei.length>0&&o.jsxs(ns,{children:[o.jsx(os,{asChild:!0,children:o.jsx("button",{type:"button",className:"flex items-center h-full px-2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(cs,{size:14})})}),o.jsx(as,{align:"start",children:ei.map(J=>o.jsx(wt,{onClick:()=>de(J),children:J},J))})]}),o.jsx("div",{className:"flex-1 flex justify-center",children:u?.vmId&&o.jsxs("div",{className:"flex items-center",children:[o.jsxs(qe,{children:[o.jsx(Ge,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 rounded-l bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors border-r border-border/50",onClick:()=>navigator.clipboard.writeText(u?.vmId??""),children:u.vmId})}),o.jsx(Ye,{side:"bottom",children:"Copy VM ID"})]}),o.jsxs(ns,{children:[o.jsx(os,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 self-stretch rounded-r bg-muted px-0.5 text-[10px] text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(vr,{size:10})})}),o.jsx(as,{align:"center",children:o.jsxs(wt,{onClick:He,children:[o.jsx(Bn,{size:12}),"Stop Server"]})})]})]})}),o.jsxs("div",{className:"flex items-center gap-1",children:[T&&o.jsxs("button",{type:"button",onClick:F,className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[o.jsx(Mc,{size:12}),"Add to chat"]}),N!=="setup"&&N!=="daemon"&&j.includes(N)&&(()=>{const J=z.activeProcesses.includes(N),W=S.has(N),ae=J&&!W,Ne=v||W,vs=()=>he(N),xs=()=>ue(N),Pt=v?"Running...":W?"Stopping...":J?"Restart":"Run";return o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",disabled:Ne,onClick:vs,className:re("flex items-center gap-1 border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",ae?"rounded-l-md border-r-0":"rounded-md"),children:[Ne?o.jsx(Me,{size:12,className:"animate-spin"}):o.jsx(di,{size:12}),Pt]}),ae&&o.jsxs(ns,{children:[o.jsx(os,{asChild:!0,children:o.jsx("button",{type:"button",disabled:Ne,className:"flex items-center self-stretch rounded-r-md border border-border px-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",children:o.jsx(vr,{size:12})})}),o.jsx(as,{align:"end",children:o.jsxs(wt,{onClick:xs,children:[o.jsx(Bn,{size:12}),"Stop"]})})]})]})})()]})]}),o.jsx("div",{className:"flex-1 overflow-hidden",children:xt.map(J=>o.jsx("div",{className:re("h-full",N===J?"block":"hidden"),children:z.hasData(J)||J==="setup"||J==="daemon"?o.jsx(Mp,{source:J,onReady:W=>{I.current.set(J,W)},onSelectionChange:(W,ae)=>M(J,W,ae),className:"h-full"}):o.jsx(zs,{className:"h-full",image:null,title:`Script "${J}" not running`,description:`Click Run to start "${J}".`,actions:o.jsxs(ne,{variant:"outline",size:"sm",disabled:v,onClick:()=>he(J),children:[v?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(di,{size:14}),"Run"]})})},J))})]})})}function Lp(t){const e=H.c(1);let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Pp,{}),e[0]=s):s=e[0],s}function Ps(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function Op(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const n=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(n){const l=(n[2]??"0").padStart(2,"0"),h=(n[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),u=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${u} UTC`}return t}function zp(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function $p(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const n=parseInt(r[1]);return n%7===0?{count:n/7,unit:"weeks"}:{count:n,unit:"days"}}return null}function Fp(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Hp=[{label:"Minute",cron:"* * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Wp(t){const e=H.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:n,onEventSelect:a}=t,{triggerAdd:l}=Gs(),[h,c]=L.useState(!1),u=i??h;let d;e[0]!==r?(d=I=>{r?r(I):c(I)},e[0]=r,e[1]=d):d=e[1];const f=d;let _;e[2]!==l||e[3]!==s||e[4]!==f?(_=async I=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:I}),_e.success("Starter added"),f(!1)}catch(R){const y=R,T=y instanceof Error?y.message:"Failed to add starter";_e.error(T)}},e[2]=l,e[3]=s,e[4]=f,e[5]=_):_=e[5];const m=_;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx(os,{asChild:!0,children:o.jsxs(ne,{variant:"outline",size:"sm",children:[o.jsx(cs,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsxs(kh,{className:"gap-2.5",children:[o.jsx(Is,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==m?(v=Hp.map(I=>o.jsxs(wt,{className:"gap-2.5",onSelect:()=>m(I.cron),disabled:l.isPending,children:[o.jsx(Is,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",I.label]},I.cron)),e[8]=l,e[9]=m,e[10]=v):v=e[10];let b;e[11]!==v?(b=o.jsxs(Nh,{children:[g,o.jsx(jh,{className:"w-[160px]",children:v})]}),e[11]=v,e[12]=b):b=e[12];let S;e[13]!==f||e[14]!==n?(S=()=>{f(!1),n?.()},e[13]=f,e[14]=n,e[15]=S):S=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Is,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=x):x=e[16];let w;e[17]!==S?(w=o.jsxs(wt,{className:"gap-2.5",onSelect:S,children:[x,"Custom (cron)"]}),e[17]=S,e[18]=w):w=e[18];let k;e[19]!==f||e[20]!==a?(k=()=>{f(!1),a?.()},e[19]=f,e[20]=a,e[21]=k):k=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx($s,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=N):N=e[22];let D;e[23]!==k?(D=o.jsxs(wt,{className:"gap-2.5",onSelect:k,children:[N,"Event"]}),e[23]=k,e[24]=D):D=e[24];let j;e[25]!==D||e[26]!==b||e[27]!==w?(j=o.jsxs(as,{align:"end",className:"w-[200px]",children:[b,w,D]}),e[25]=D,e[26]=b,e[27]=w,e[28]=j):j=e[28];let B;return e[29]!==f||e[30]!==u||e[31]!==j?(B=o.jsxs(ns,{open:u,onOpenChange:f,children:[p,j]}),e[29]=f,e[30]=u,e[31]=j,e[32]=B):B=e[32],B}function Up(t){const e=H.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:n,triggerRemove:a}=Gs(),[l,h]=L.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?$p(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const u=c,[d,f]=L.useState(u?.count??1),[_,m]=L.useState(!1),[p,g]=L.useState(s.cron_expression??""),v=a.isPending||n.isPending,b=s.type==="cron";let S;e[2]!==i||e[3]!==a||e[4]!==s.id?(S=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),_e.success("Starter removed")}catch{_e.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=S):S=e[5];const x=S;let w;e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(w=async()=>{const z=p.trim();if(!z||!Ps(z)||z===s.cron_expression){m(!1),g(s.cron_expression??"");return}try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:z}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),m(!1)}catch{_e.error("Failed to update starter"),g(s.cron_expression??""),m(!1)}},e[6]=n,e[7]=i,e[8]=p,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=w):w=e[12];const k=w;let N;e[13]!==n||e[14]!==i||e[15]!==u||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(N=async z=>{if(!u)return;const V=Math.max(1,z),se=zp(V,u.unit);if(se!==s.cron_expression)try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:se}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{_e.error("Failed to update starter"),f(u.count)}},e[13]=n,e[14]=i,e[15]=u,e[16]=a,e[17]=s.cron_expression,e[18]=s.id,e[19]=N):N=e[19];const D=N;let j;e[20]!==b?(j=b?o.jsx(Is,{size:14,className:"text-muted-foreground shrink-0"}):o.jsx($s,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=b,e[21]=j):j=e[21];let B;e[22]!==r||e[23]!==d||e[24]!==p||e[25]!==D||e[26]!==k||e[27]!==u||e[28]!==b||e[29]!==_||e[30]!==v||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(B=u&&b?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),o.jsx("input",{type:"number",min:1,value:d,onChange:z=>f(parseInt(z.target.value)||1),onBlur:()=>D(d),onKeyDown:z=>{z.key==="Enter"&&z.target.blur(),z.key==="Escape"&&f(u.count)},disabled:v,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),o.jsx("span",{className:"text-sm",children:Fp(u.unit,d)})]}):b&&_?o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"text",value:p,onChange:z=>g(z.target.value),onBlur:k,onKeyDown:z=>{z.key==="Enter"&&z.target.blur(),z.key==="Escape"&&(m(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!Ps(p)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):o.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:b?Op(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!b&&s.params&&Object.keys(s.params).length>0&&o.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(Vp).join(", ")})]}),e[22]=r,e[23]=d,e[24]=p,e[25]=D,e[26]=k,e[27]=u,e[28]=b,e[29]=_,e[30]=v,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=B):B=e[34];let I;e[35]!==v?(I=v&&o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=I):I=e[36];let R;e[37]!==u||e[38]!==b||e[39]!==_||e[40]!==s.cron_expression?(R=b&&!u&&!_&&o.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{g(s.cron_expression??""),m(!0)},children:o.jsx(mh,{size:13,className:"text-muted-foreground"})}),e[37]=u,e[38]=b,e[39]=_,e[40]=s.cron_expression,e[41]=R):R=e[41];let y;e[42]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:o.jsx(ls,{size:13,className:"text-muted-foreground"})}),e[42]=y):y=e[42];let T;e[43]!==I||e[44]!==R?(T=o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[I,R,y]}),e[43]=I,e[44]=R,e[45]=T):T=e[45];let E;e[46]!==T||e[47]!==j||e[48]!==B?(E=o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[j,B,T]}),e[46]=T,e[47]=j,e[48]=B,e[49]=E):E=e[49];let C;e[50]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsxs(Sa,{children:[o.jsx(ya,{children:"Remove Starter"}),o.jsx(wa,{children:"Are you sure you want to remove this starter?"})]}),e[50]=C):C=e[50];let P;e[51]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx(ka,{children:"Cancel"}),e[51]=P):P=e[51];let M;e[52]!==x?(M=o.jsxs(ba,{children:[C,o.jsxs(Ca,{children:[P,o.jsx(Na,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=x,e[53]=M):M=e[53];let F;e[54]!==l||e[55]!==M?(F=o.jsx(xa,{open:l,onOpenChange:h,children:M}),e[54]=l,e[55]=M,e[56]=F):F=e[56];let U;return e[57]!==E||e[58]!==F?(U=o.jsxs(o.Fragment,{children:[E,F]}),e[57]=E,e[58]=F,e[59]=U):U=e[59],U}function Vp(t){const[e,s]=t;return`${e}: ${s}`}function Kp(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1}}case"reset":return null}}function qp(t){const e=H.c(55),{automationId:s,onDone:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const n=Ai(r),[a,l]=L.useState(),[h,c]=L.useState();let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={},e[1]=u):u=e[1];const[d,f]=L.useState(u),{triggerAdd:_}=Gs(),{data:m,isLoading:p}=Rh(a);let g,v,b,S,x,w;if(e[2]!==_||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==p||e[7]!==i||e[8]!==d||e[9]!==n||e[10]!==m){const D=m?.find(M=>M.type===h);let j;e[17]!==_||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==d?(j=async()=>{if(!(!a||!h))try{await _.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:d}),Se("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),_e.success("Event trigger added"),i()}catch{_e.error("Failed to add event trigger")}},e[17]=_,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=d,e[23]=j):j=e[23],g=j,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let B,I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx($s,{size:14,className:"text-muted-foreground shrink-0"}),B=o.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=B,e[25]=I):(B=e[24],I=e[25]);let R;e[26]===Symbol.for("react.memo_cache_sentinel")?(R=o.jsx(ls,{size:13}),e[26]=R):R=e[26],e[27]!==i?(b=o.jsxs("div",{className:"flex items-center gap-2",children:[I,B,o.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:R})]}),e[27]=i,e[28]=b):b=e[28];const y=a??"";let T;e[29]===Symbol.for("react.memo_cache_sentinel")?(T=M=>{l(M),c(void 0),f({})},e[29]=T):T=e[29];let E;e[30]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ss,{className:"w-full",children:o.jsx(is,{placeholder:"Select connection..."})}),e[30]=E):E=e[30];let C;e[31]!==n?(C=n.length===0?o.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):n.map(Xp),e[31]=n,e[32]=C):C=e[32];let P;e[33]!==C?(P=o.jsx(rs,{children:C}),e[33]=C,e[34]=P):P=e[34],e[35]!==y||e[36]!==P?(S=o.jsxs(ts,{value:y,onValueChange:T,children:[E,P]}),e[35]=y,e[36]=P,e[37]=S):S=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==m?(x=a&&o.jsxs(ts,{value:h??"",onValueChange:M=>{c(M),f({})},children:[o.jsx(ss,{className:"w-full",children:p?o.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(Me,{size:13,className:"animate-spin"}),"Loading events..."]}):o.jsx(is,{placeholder:"Select event type...",children:h??"Select event type..."})}),o.jsx(rs,{children:m?.map(Yp)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=m,e[42]=x):x=e[42],w=D?.paramsSchema&&Object.keys(D.paramsSchema).length>0&&o.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(D.paramsSchema).map(M=>{const[F,U]=M;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("label",{className:"text-xs text-muted-foreground",children:[F,U.description&&o.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",U.description]})]}),U.enum?o.jsxs(ts,{value:d[F]??"",onValueChange:z=>f(V=>({...V,[F]:z})),children:[o.jsx(ss,{className:"w-full",children:o.jsx(is,{placeholder:`Select ${F}...`})}),o.jsx(rs,{children:U.enum.map(Gp)})]}):o.jsx("input",{type:"text",value:d[F]??"",onChange:z=>f(V=>({...V,[F]:z.target.value})),placeholder:U.description??F,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},F)})}),e[2]=_,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=d,e[9]=n,e[10]=m,e[11]=g,e[12]=v,e[13]=b,e[14]=S,e[15]=x,e[16]=w}else g=e[11],v=e[12],b=e[13],S=e[14],x=e[15],w=e[16];let k;e[43]!==_||e[44]!==a||e[45]!==h||e[46]!==g?(k=a&&h&&o.jsx(ne,{size:"sm",onClick:g,disabled:_.isPending,children:_.isPending?o.jsx(Me,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=_,e[44]=a,e[45]=h,e[46]=g,e[47]=k):k=e[47];let N;return e[48]!==v||e[49]!==b||e[50]!==S||e[51]!==x||e[52]!==w||e[53]!==k?(N=o.jsxs("div",{className:v,children:[b,S,x,w,k]}),e[48]=v,e[49]=b,e[50]=S,e[51]=x,e[52]=w,e[53]=k,e[54]=N):N=e[54],N}function Gp(t){return o.jsx(It,{value:t,children:t},t)}function Yp(t){return o.jsx(It,{value:t.type,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:t.type}),o.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function Xp(t){return o.jsx(It,{value:t.id,children:t.title},t.id)}function Jp({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:n}=ge(),{update:a,triggerAdd:l}=Gs(),h=Ai(),c=new Map(h.map(W=>[W.id,W.title])),{createTaskWithMessage:u}=gt(),{setModel:d,setSimpleModeTier:f,credentialId:_,selectedModel:m}=Ti(),p=Dh(),{setChatOpen:g}=Ii(),{sendMessage:v}=fs(),b=_a(),[S,x]=Vl(),w=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[k,N]=L.useState(w),[D,j]=L.useState(!1),[B,I]=L.useState(!1),[R,y]=L.useState(""),[T,E]=L.useState(!1),[C,P]=L.useState(!1),[M,F]=L.useState(!1),[U,z]=L.useState(!1),V=async()=>{if(C)return;const ae=jn(k).filter(Ne=>Ne.type==="text").map(Ne=>Ne.text).join(`
|
|
182
|
-
`);if(ae.trim()){P(!0);try{xt(),Se("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ae.length}),await b(["studio-automation-manager"]),g(!0),await v({tiptapDoc:La({managerAgentId:ia.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ae})})}finally{P(!1)}}},se=e.models?.credentialId||_||"",te=e.models?.thinking?.id||m?.modelId||"",X=e.models?.tier??"",$=Zo({defaultValues:{name:e.name,active:e.active,credential_id:se,model_id:te,tier:X}}),A=$.watch("active"),G=$.watch("credential_id"),Y=$.watch("model_id"),{models:Q,isLoading:ie}=Lc(G||void 0),ee=Q.find(W=>W.modelId===Y)??null,q=$.watch("tier"),he=["fast","smart","thinking"].find(W=>p.chat[W]?.modelId===Y&&p.chat[W]?.keyId===G),ue=q||he||"smart",de=W=>{const ae=p.chat[W];ae&&($.setValue("credential_id",ae.keyId,{shouldDirty:!0}),$.setValue("model_id",ae.modelId,{shouldDirty:!0}),$.setValue("tier",W,{shouldDirty:!0}))},[fe,He]=L.useReducer(Kp,null),Ae=()=>{fe!==null&&(Se("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(fe.fields),save_count:fe.saveCount,edit_duration_ms:Date.now()-fe.start}),He({type:"reset"}))},We=async()=>{const W=$.control._formState.dirtyFields,ae=Object.keys(W);if(ae.length===0&&!U)return!0;const Ne=$.getValues(),vs=Ne.credential_id&&Ne.model_id?Ne.credential_id:"",xs=Ne.credential_id&&Ne.model_id?Ne.model_id:"";vs!==Ne.credential_id&&$.setValue("credential_id",vs),xs!==Ne.model_id&&$.setValue("model_id",xs);const Pt=$.getValues(),Bl=$.control._defaultValues;$.reset(Pt,{keepValues:!0});const wn=U;z(!1);const Cn=p.enabled?Pt.tier||he:Pt.tier||void 0,Pl={id:t,name:Pt.name,active:Pt.active,models:{credentialId:vs,thinking:{id:xs},...Cn?{tier:Cn}:{}},messages:ic(k),temperature:0};try{await a.mutateAsync(Pl)}catch{return $.reset(Bl,{keepValues:!0}),wn&&z(!0),!1}const kn=[...ae];return wn&&kn.push("messages"),He({type:"accumulate",now:Date.now(),fields:kn}),ke(),!0},{schedule:Ue,flush:ot}=bi({save:We}),{schedule:ke,flush:xt}=bi({delayMs:3e4,save:async()=>Ae()});L.useEffect(()=>{const W=$.watch(()=>Ue());return()=>W.unsubscribe()},[]);const ei=W=>{if(N(W),!M){F(!0);return}z(!0),Ue()},J=async()=>{Se("automation_test_clicked",{automation_id:t,agent_id:r});const W=await ot();if(xt(),!W)return;if(!k){_e.error("No instructions configured for this automation");return}p.enabled?f(ue):ee&&G&&d({...ee,keyId:G}),g(!0),x({...S,toolApprovalLevel:"auto"});const ae=jn(k);u({message:{tiptapDoc:k,parts:ae},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(ne,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Ma,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx($t,{control:$.control,name:"name",render:({field:W})=>o.jsx(_s,{...W,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(ne,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(gr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx($t,{control:$.control,name:"active",render:({field:W})=>o.jsx(pr,{checked:W.value,onCheckedChange:ae=>{W.onChange(ae),ot()},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:A?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(pa,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Wp,{automationId:t,open:D,onOpenChange:j,onCustomSelect:()=>{I(!0),E(!1),y("")},onEventSelect:()=>{E(!0),I(!1)}})]}),e.triggers.length===0&&!B?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>j(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(W=>o.jsx(Up,{trigger:W,automationId:t,connectionName:W.connection_id?c.get(W.connection_id):void 0},W.id))}),B&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Is,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:R,onChange:W=>y(W.target.value),onBlur:async()=>{const W=R.trim();if(!(!W||!Ps(W)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:W}),Se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),_e.success("Starter added"),I(!1),y("")}catch{_e.error("Failed to add starter")}},onKeyDown:async W=>{const ae=R.trim();W.key==="Enter"&&ae&&Ps(ae)&&W.target.blur(),W.key==="Escape"&&(I(!1),y(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),R&&!Ps(R)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{I(!1),y("")},children:o.jsx(ls,{size:13})})]}),T&&o.jsx(L.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(qp,{automationId:t,onDone:()=>E(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:C||!k,onClick:V,children:[o.jsx(Ta,{size:13}),"Improve"]})]}),o.jsx(Zl,{tiptapDoc:k,setTiptapDoc:ei,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(Ql,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[p.enabled?o.jsx(ec,{tier:ue,onSelect:de}):o.jsx(Th,{model:ee,isLoading:ie,credentialId:G||null,onCredentialChange:W=>{$.setValue("credential_id",W??"",{shouldDirty:!0}),$.setValue("model_id","",{shouldDirty:!0}),$.setValue("tier","",{shouldDirty:!0})},onModelChange:W=>{$.setValue("model_id",W.modelId,{shouldDirty:!0}),$.setValue("tier","",{shouldDirty:!0})},placeholder:"Model"}),o.jsxs(qe,{children:[o.jsx(Ge,{asChild:!0,children:o.jsxs(ne,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:J,disabled:!r,children:[o.jsx(hc,{size:16}),"Test"]})}),o.jsx(Ye,{children:"Test Automation"})]})]})]})})]})]})]})}function Zp(t){const e=H.c(5),{tabId:s}=t;let i;e[0]!==s?(i=na(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(lt,{children:o.jsx(lt.Content,{children:o.jsx(lt.Body,{children:o.jsx(L.Suspense,{fallback:n,children:o.jsx(Qp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Qp(t){const e=H.c(8),{id:s}=t,i=At(),{data:r,isLoading:n}=Mh(s);let a;e[0]!==i?(a=()=>i({to:".",search:eg,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Jp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function eg(t){return{...t,main:"automations"}}function tg(t){const e=H.c(20),{virtualMcpId:s}=t,i=At(),{data:r}=Ih(s),n=r===void 0?[]:r,{create:a}=Gs(),{selectedModel:l,credentialId:h}=Ti(),[c,u]=L.useState(""),d=c.toLowerCase(),f=n.filter(R=>R.name.toLowerCase().includes(d));let _;e[0]!==i?(_=R=>i({to:".",search:y=>({...y,main:"automation:"+R}),replace:!0}),e[0]=i,e[1]=_):_=e[1];const m=_,p=async()=>{if(a.isPending)return;Se("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const R=l?.modelId&&h?{credentialId:h,modelId:l.modelId}:null,y=await a.mutateAsync(Bh(s,R));m(y.id)},g=lt,v=lt,b=lt;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(lt.Title,{children:"Automations"}),e[2]=S):S=e[2];const x=n.length>0&&o.jsx(Ph,{value:c,onChange:u,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(cs,{size:14}),e[3]=w):w=e[3];let k;e[4]!==a.isPending||e[5]!==p?(k=o.jsxs(ne,{size:"sm",onClick:p,disabled:a.isPending,children:[w,"New automation"]}),e[4]=a.isPending,e[5]=p,e[6]=k):k=e[6];let N;e[7]!==x||e[8]!==k?(N=o.jsxs("div",{className:"flex flex-col gap-6",children:[S,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[x,k]})]}),e[7]=x,e[8]=k,e[9]=N):N=e[9];const D=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(zs,{image:o.jsx($s,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(ne,{size:"sm",onClick:p,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):f.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(zs,{image:o.jsx($s,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${c}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:f.map(R=>o.jsx(Ah,{automation:R,onClick:()=>m(R.id)},R.id))});let j;e[10]!==D||e[11]!==b.Body||e[12]!==N?(j=o.jsxs(b.Body,{children:[N,D]}),e[10]=D,e[11]=b.Body,e[12]=N,e[13]=j):j=e[13];let B;e[14]!==j||e[15]!==v.Content?(B=o.jsx(v.Content,{children:j}),e[14]=j,e[15]=v.Content,e[16]=B):B=e[16];let I;return e[17]!==g||e[18]!==B?(I=o.jsx(g,{children:B}),e[17]=g,e[18]=B,e[19]=I):I=e[19],I}function sg(t){const e=H.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(L.Suspense,{fallback:i,children:o.jsx(tg,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Uo=L.lazy(()=>Kl(()=>import("./project-app-view-DxehH6hP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function ig(t){const e=H.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Pa(r);if(pc(n)){let m;return e[3]!==i?(m=o.jsx(qn,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Pu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(sg,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Lp,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(xf,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Zp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=gc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=x=>x.appId===u.connectionId&&x.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let b;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(b=o.jsx(L.Suspense,{fallback:g,children:o.jsx(Uo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=b):b=e[29],b}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(L.Suspense,{fallback:m,children:o.jsx(Uo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx(qn,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function rg(t){const e=H.c(7),{children:s,defaultSize:i}=t,[,r]=L.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ta.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=ea(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(ma,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function ng(t){const e=H.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Pn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=ta.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=ea(c,45),d=L.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const B=d.current;if(!B)return;const I=Pn(r,n),R=I.chat>0&&I.chat<100?u:I.chat,y=I.chat>0&&I.chat<100?100-u:I.main;B.setLayout([R,y])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),L.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Ia,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx(rg,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(th,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[18]=w):w=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=re("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=k):k=e[19];let N;e[20]!==i||e[21]!==s?(N=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:k,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ht,{children:o.jsx(ig,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=N):N=e[22];let D;e[23]!==h.main||e[24]!==N?(D=o.jsx(ma,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:N}),e[23]=h.main,e[24]=N,e[25]=D):D=e[25];let j;return e[26]!==D||e[27]!==m||e[28]!==b?(j=o.jsxs(sh,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,D]},m),e[26]=D,e[27]=m,e[28]=b,e[29]=j):j=e[29],j}const ur="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Vo="bg-sidebar-accent text-sidebar-foreground",fr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function og(t){const e=H.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Oc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{Se("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Vo:fr;let u;e[3]!==c?(u=re(ur,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Ic,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(Ge,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Ye,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(qe,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{Se("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?Vo:fr;let v;e[16]!==g?(v=re(ur,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Ac,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ge,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ye,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let w;e[24]!==S?(w=o.jsxs(qe,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=w):w=e[25];const k=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let N;e[26]!==k?(N=re("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",k),e[26]=k,e[27]=N):N=e[27];const D=!l,j=l?0:-1,B=!l,I=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let R;e[28]!==I?(R=re(ur,fr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",I),e[28]=I,e[29]=R):R=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(la,{size:16}),e[30]=y):y=e[30];let T;e[31]!==r||e[32]!==D||e[33]!==j||e[34]!==B||e[35]!==R?(T=o.jsx(Ge,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:D,tabIndex:j,"aria-hidden":B,className:R,children:y})}),e[31]=r,e[32]=D,e[33]=j,e[34]=B,e[35]=R,e[36]=T):T=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(Ye,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let C;e[38]!==T?(C=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(qe,{delayDuration:300,children:[T,E]})}),e[38]=T,e[39]=C):C=e[39];let P;e[40]!==N||e[41]!==C?(P=o.jsx("div",{className:N,children:C}),e[40]=N,e[41]=C,e[42]=P):P=e[42];let M;return e[43]!==w||e[44]!==P||e[45]!==m?(M=o.jsxs(o.Fragment,{children:[m,w,P]}),e[43]=w,e[44]=P,e[45]=m,e[46]=M):M=e[46],M}function ag(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function lg(t){const e=H.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=re("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(cg,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function cg(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}function hg(t){const e=H.c(13),{overflow:s,onSelect:i}=t,[r,n]=L.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Vs,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ca,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(dg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Ks,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(qs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function dg(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}const ug=6;function fg(t){const e=H.c(20),{virtualMcpId:s,taskId:i}=t,r=At();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Pa(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=vc({activeTab:l,mainOpen:h}),v=k=>k.id==="automations"?g:h&&k.id===l,S=a.find(k=>v(k))?.id??null,{visible:x,overflow:w}=ag(a,S,ug);d=w,u=k=>{const N=a.find(j=>j.id===k),D=S===k&&h;if(Se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:N?.kind??null,was_active:D}),k==="automations"){const j=xc({activeTab:l,mainOpen:h});r({to:".",search:B=>({...B,main:j}),replace:!0});return}c(k)},f="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(k=>o.jsx(lg,{title:k.title,icon:k.icon,active:v(k),onClick:()=>u(k.id)},k.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(hg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function mg(t){const e=H.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=re("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(ql,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function _g(t){const e=H.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(ku({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(Cu({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(ne,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(vr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(os,{asChild:!0,children:o.jsx(ne,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(as,{align:"end",children:o.jsx(wt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(ns,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const pg=new Set(["failure","timed_out","cancelled","action_required"]);function gg(t){return t.status==="completed"&&pg.has(t.conclusion)}function vg(t){return t.status==="queued"||t.status==="in_progress"}function xg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(gg).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(vg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function bg(){return Gt().branchStatus}const Sg=6e4,yg=3e4;function wg(t){const e=H.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Fe(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Sg,refetchIntervalInBackground:!1,staleTime:yg,select:Cg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],ms(l)}function Cg(t){const e=Ys(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function kg(t){const e=H.c(42),{virtualMcpId:s}=t,{org:i}=ge(),r=Ct(s),{currentBranch:n}=gt(),a=fs(),l=r?.metadata?.githubRepo??null,h=bg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=za(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==b||e[12]!==S?(x={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:b,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=b,e[12]=S,e[13]=x):x=e[13];const w=Fa(x),k=l?.connectionId??"",N=l?.owner??"",D=l?.name??"",j=p&&p.state==="open"?p.number:null;let B;e[14]!==i.id||e[15]!==i.slug||e[16]!==k||e[17]!==N||e[18]!==D||e[19]!==j?(B={orgId:i.id,orgSlug:i.slug,connectionId:k,owner:N,repo:D,prNumber:j},e[14]=i.id,e[15]=i.slug,e[16]=k,e[17]=N,e[18]=D,e[19]=j,e[20]=B):B=e[20];const I=wg(B);if(!l?.connectionId||!n)return null;let R;e[21]!==h||e[22]!==w.data||e[23]!==p||e[24]!==m.isPending||e[25]!==I.data?(R=xg({branchStatus:h,pr:p,checks:w.data??[],reviews:I.data??null,loading:m.isPending}),e[21]=h,e[22]=w.data,e[23]=p,e[24]=m.isPending,e[25]=I.data,e[26]=R):R=e[26];const y=R;let T;e[27]!==a?(T=V=>a.sendMessage({parts:[{type:"text",text:V}]}),e[27]=a,e[28]=T):T=e[28];const E=T,C=a.isStreaming;let P;e[29]!==n||e[30]!==y||e[31]!==C||e[32]!==p||e[33]!==E?(P=V=>{if(!C)switch(V){case"commit-and-push":{E(pu({branch:n}));return}case"create-pr":{E(gu({branch:n}));return}case"reopen":{p&&E(vu({prNumber:p.number}));return}case"rebase":{E(xu({branch:n}));return}case"fix-checks":{p&&E(Su({prNumber:p.number,failingChecks:y.meta?.failingChecks??[]}));return}case"mark-ready":{p&&E(yu({prNumber:p.number}));return}case"resolve-comments":{p&&E(wu({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=y,e[31]=C,e[32]=p,e[33]=E,e[34]=P):P=e[34];const M=P;let F;e[35]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx(mg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=F):F=e[35];const U=p?.number;let z;return e[36]!==y||e[37]!==C||e[38]!==M||e[39]!==E||e[40]!==U?(z=o.jsxs(o.Fragment,{children:[F,o.jsx(Ng,{button:y,isStreaming:C,onActivate:M,prNumber:U,send:E})]}),e[36]=y,e[37]=C,e[38]=M,e[39]=E,e[40]=U,e[41]=z):z=e[41],z}function Ng(t){const e=H.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(_g,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx(Ko,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(Ch,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(ne,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx(Ko,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function Ko(t){const e=H.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Ge,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Ye,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Yc,{children:o.jsxs(qe,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function jg(t){const e=H.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(_r.Right,{children:o.jsx(kg,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Qt=L.createContext(null);function yn(){return L.use(Qt)}function qo(t){const e=H.c(7),{children:s}=t,{taskId:i}=gt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Ia,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ht,{fallback:r,children:o.jsx(L.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Go(t){const e=H.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],L.useLayoutEffect(r),null}function Eg(t){const e=H.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(nc,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Yo(t){const e=H.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ge(),{currentBranch:l}=gt(),{data:h}=Ei.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Bt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=Fe(u),{mutate:f}=cn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=L.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:Tg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),L.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Ju,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function Tg(t){console.error("[auto-start-vm] failed:",t)}function Dg(){const t=H.c(96),e=fa(),s=At(),{org:i}=ge(),r=zc()?.tasksOpen??!1;Xc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Gl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=sn(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??sa(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=zh(a.taskId??"",d),_=Ct(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Kt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const x=$c(g,S),{setOpenMobile:w,openMobile:k}=Vc(),N=w,D=L.useRef(null);let j,B;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const X=$=>{Wc($)&&$.shiftKey&&$.code==="KeyS"&&!$.repeat&&($.preventDefault(),D.current?.())};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},B=[],t[12]=j,t[13]=B):(j=t[12],B=t[13]),L.useEffect(j,B);const I=d;let R;t[14]!==_||t[15]!==d?(R={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=R):R=t[16];const y=R;if(f.status==="creating"||f.status==="loading"){let X;t[17]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Me,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=X):X=t[17];let $;return t[18]!==y?($=o.jsx(Qt,{value:y,children:X}),t[18]=y,t[19]=$):$=t[19],$}if(f.status==="error"){let X;t[20]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=X):X=t[20];let $;t[21]!==f.error.message?($=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[X,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=$):$=t[22];let A;return t[23]!==y||t[24]!==$?(A=o.jsx(Qt,{value:y,children:$}),t[23]=y,t[24]=$,t[25]=A):A=t[25],A}if(!_){let X;t[26]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx(Os,{size:48,className:"text-muted-foreground"}),t[26]=X):X=t[26];const $=`The agent "${d}" does not exist in this organization.`;let A;t[27]!==s||t[28]!==l?(A=o.jsx(ne,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=A):A=t[29];let G;t[30]!==$||t[31]!==A?(G=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(zs,{image:X,title:"Agent not found",description:$,actions:A})})}),t[30]=$,t[31]=A,t[32]=G):G=t[32];let Y;return t[33]!==y||t[34]!==G?(Y=o.jsx(Qt,{value:y,children:G}),t[33]=y,t[34]=G,t[35]=Y):Y=t[35],Y}if(e){let X;t[36]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx(Kc,{className:"sr-only",children:"Navigation"}),t[36]=X):X=t[36];let $;t[37]!==N?($=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Fc,{onClose:()=>N(!1)})}),t[37]=N,t[38]=$):$=t[38];let A;t[39]===Symbol.for("react.memo_cache_sentinel")?(A=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Hc,{})}),t[39]=A):A=t[39];let G;t[40]!==$?(G=o.jsxs(qc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[X,o.jsxs("div",{className:"flex h-full",children:[$,A]})]}),t[40]=$,t[41]=G):G=t[41];let Y;t[42]!==k||t[43]!==N||t[44]!==G?(Y=o.jsx(Gc,{open:k,onOpenChange:N,children:G}),t[42]=k,t[43]=N,t[44]=G,t[45]=Y):Y=t[45];const Q=Y,ie=_?.metadata?.vmMap;let ee;t[46]!==x.createNewTask?(ee=o.jsx(Go,{onNewTaskRef:D,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=ee):ee=t[47];let q;t[48]!==N?(q=o.jsx(Eg,{onOpenSidebar:()=>N(!0)}),t[48]=N,t[49]=q):q=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(qo,{})}),t[50]=he):he=t[50];let ue;t[51]!==b||t[52]!==Q||t[53]!==ie||t[54]!==ee||t[55]!==q||t[56]!==d?(ue=o.jsxs(Yo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:ie,children:[ee,q,he,Q]}),t[51]=b,t[52]=Q,t[53]=ie,t[54]=ee,t[55]=q,t[56]=d,t[57]=ue):ue=t[57];let de;t[58]!==I||t[59]!==ue?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:I,children:ue},I)}),t[58]=I,t[59]=ue,t[60]=de):de=t[60];let fe;return t[61]!==y||t[62]!==de?(fe=o.jsx(Qt,{value:y,children:de}),t[61]=y,t[62]=de,t[63]=fe):fe=t[63],fe}const T=r?void 0:x.createNewTask;let E;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==T?(E=o.jsx(_r.Toggles,{children:o.jsx(og,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:T})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=T,t[67]=E):E=t[67];let C;t[68]!==x.taskId||t[69]!==d?(C=o.jsx(_r.Tabs,{children:o.jsx(fg,{virtualMcpId:d,taskId:x.taskId})}),t[68]=x.taskId,t[69]=d,t[70]=C):C=t[70];const P=_?.metadata?.vmMap;let M;t[71]!==_?(M=o.jsx(jg,{virtualMcp:_}),t[71]=_,t[72]=M):M=t[72];let F;t[73]!==x.createNewTask?(F=o.jsx(Go,{onNewTaskRef:D,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=F):F=t[74];let U;t[75]===Symbol.for("react.memo_cache_sentinel")?(U=o.jsx(qo,{}),t[75]=U):U=t[75];let z;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==d?(z=o.jsx(ng,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:U}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=d,t[80]=z):z=t[80];let V;t[81]!==b||t[82]!==P||t[83]!==M||t[84]!==F||t[85]!==z||t[86]!==d?(V=o.jsxs(Yo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:P,children:[M,F,z]}),t[81]=b,t[82]=P,t[83]=M,t[84]=F,t[85]=z,t[86]=d,t[87]=V):V=t[87];let se;t[88]!==I||t[89]!==C||t[90]!==V?(se=o.jsxs(je.Provider,{virtualMcpId:I,children:[C,V]},I),t[88]=I,t[89]=C,t[90]=V,t[91]=se):se=t[91];let te;return t[92]!==y||t[93]!==E||t[94]!==se?(te=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Qt,{value:y,children:[E,se]})}),t[92]=y,t[93]=E,t[94]=se,t[95]=te):te=t[95],te}function O1(){const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(L.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Dg,{})}),t[0]=e):e=t[0],e}export{O1 as default,yn as useInsetContext};
|
|
182
|
+
`);if(ae.trim()){P(!0);try{xt(),Se("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ae.length}),await b(["studio-automation-manager"]),g(!0),await v({tiptapDoc:La({managerAgentId:ia.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ae})})}finally{P(!1)}}},se=e.models?.credentialId||_||"",te=e.models?.thinking?.id||m?.modelId||"",X=e.models?.tier??"",$=Zo({defaultValues:{name:e.name,active:e.active,credential_id:se,model_id:te,tier:X}}),A=$.watch("active"),G=$.watch("credential_id"),Y=$.watch("model_id"),{models:Q,isLoading:ie}=Lc(G||void 0),ee=Q.find(W=>W.modelId===Y)??null,q=$.watch("tier"),he=["fast","smart","thinking"].find(W=>p.chat[W]?.modelId===Y&&p.chat[W]?.keyId===G),ue=q||he||"smart",de=W=>{const ae=p.chat[W];ae&&($.setValue("credential_id",ae.keyId,{shouldDirty:!0}),$.setValue("model_id",ae.modelId,{shouldDirty:!0}),$.setValue("tier",W,{shouldDirty:!0}))},[fe,He]=L.useReducer(Kp,null),Ae=()=>{fe!==null&&(Se("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(fe.fields),save_count:fe.saveCount,edit_duration_ms:Date.now()-fe.start}),He({type:"reset"}))},We=async()=>{const W=$.control._formState.dirtyFields,ae=Object.keys(W);if(ae.length===0&&!U)return!0;const Ne=$.getValues(),vs=Ne.credential_id&&Ne.model_id?Ne.credential_id:"",xs=Ne.credential_id&&Ne.model_id?Ne.model_id:"";vs!==Ne.credential_id&&$.setValue("credential_id",vs),xs!==Ne.model_id&&$.setValue("model_id",xs);const Pt=$.getValues(),Bl=$.control._defaultValues;$.reset(Pt,{keepValues:!0});const wn=U;z(!1);const Cn=p.enabled?Pt.tier||he:Pt.tier||void 0,Pl={id:t,name:Pt.name,active:Pt.active,models:{credentialId:vs,thinking:{id:xs},...Cn?{tier:Cn}:{}},messages:ic(k),temperature:0};try{await a.mutateAsync(Pl)}catch{return $.reset(Bl,{keepValues:!0}),wn&&z(!0),!1}const kn=[...ae];return wn&&kn.push("messages"),He({type:"accumulate",now:Date.now(),fields:kn}),ke(),!0},{schedule:Ue,flush:ot}=bi({save:We}),{schedule:ke,flush:xt}=bi({delayMs:3e4,save:async()=>Ae()});L.useEffect(()=>{const W=$.watch(()=>Ue());return()=>W.unsubscribe()},[]);const ei=W=>{if(N(W),!M){F(!0);return}z(!0),Ue()},J=async()=>{Se("automation_test_clicked",{automation_id:t,agent_id:r});const W=await ot();if(xt(),!W)return;if(!k){_e.error("No instructions configured for this automation");return}p.enabled?f(ue):ee&&G&&d({...ee,keyId:G}),g(!0),x({...S,toolApprovalLevel:"auto"});const ae=jn(k);u({message:{tiptapDoc:k,parts:ae},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(ne,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Ma,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx($t,{control:$.control,name:"name",render:({field:W})=>o.jsx(_s,{...W,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(ne,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(gr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx($t,{control:$.control,name:"active",render:({field:W})=>o.jsx(pr,{checked:W.value,onCheckedChange:ae=>{W.onChange(ae),ot()},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:A?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(pa,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Wp,{automationId:t,open:D,onOpenChange:j,onCustomSelect:()=>{I(!0),E(!1),y("")},onEventSelect:()=>{E(!0),I(!1)}})]}),e.triggers.length===0&&!B?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>j(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(W=>o.jsx(Up,{trigger:W,automationId:t,connectionName:W.connection_id?c.get(W.connection_id):void 0},W.id))}),B&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Is,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:R,onChange:W=>y(W.target.value),onBlur:async()=>{const W=R.trim();if(!(!W||!Ps(W)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:W}),Se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),_e.success("Starter added"),I(!1),y("")}catch{_e.error("Failed to add starter")}},onKeyDown:async W=>{const ae=R.trim();W.key==="Enter"&&ae&&Ps(ae)&&W.target.blur(),W.key==="Escape"&&(I(!1),y(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),R&&!Ps(R)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{I(!1),y("")},children:o.jsx(ls,{size:13})})]}),T&&o.jsx(L.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Me,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(qp,{automationId:t,onDone:()=>E(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:C||!k,onClick:V,children:[o.jsx(Ta,{size:13}),"Improve"]})]}),o.jsx(Zl,{tiptapDoc:k,setTiptapDoc:ei,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(Ql,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[p.enabled?o.jsx(ec,{tier:ue,onSelect:de}):o.jsx(Th,{model:ee,isLoading:ie,credentialId:G||null,onCredentialChange:W=>{$.setValue("credential_id",W??"",{shouldDirty:!0}),$.setValue("model_id","",{shouldDirty:!0}),$.setValue("tier","",{shouldDirty:!0})},onModelChange:W=>{$.setValue("model_id",W.modelId,{shouldDirty:!0}),$.setValue("tier","",{shouldDirty:!0})},placeholder:"Model"}),o.jsxs(qe,{children:[o.jsx(Ge,{asChild:!0,children:o.jsxs(ne,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:J,disabled:!r,children:[o.jsx(hc,{size:16}),"Test"]})}),o.jsx(Ye,{children:"Test Automation"})]})]})]})})]})]})]})}function Zp(t){const e=H.c(5),{tabId:s}=t;let i;e[0]!==s?(i=na(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(lt,{children:o.jsx(lt.Content,{children:o.jsx(lt.Body,{children:o.jsx(L.Suspense,{fallback:n,children:o.jsx(Qp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Qp(t){const e=H.c(8),{id:s}=t,i=At(),{data:r,isLoading:n}=Mh(s);let a;e[0]!==i?(a=()=>i({to:".",search:eg,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Jp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function eg(t){return{...t,main:"automations"}}function tg(t){const e=H.c(20),{virtualMcpId:s}=t,i=At(),{data:r}=Ih(s),n=r===void 0?[]:r,{create:a}=Gs(),{selectedModel:l,credentialId:h}=Ti(),[c,u]=L.useState(""),d=c.toLowerCase(),f=n.filter(R=>R.name.toLowerCase().includes(d));let _;e[0]!==i?(_=R=>i({to:".",search:y=>({...y,main:"automation:"+R}),replace:!0}),e[0]=i,e[1]=_):_=e[1];const m=_,p=async()=>{if(a.isPending)return;Se("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const R=l?.modelId&&h?{credentialId:h,modelId:l.modelId}:null,y=await a.mutateAsync(Bh(s,R));m(y.id)},g=lt,v=lt,b=lt;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(lt.Title,{children:"Automations"}),e[2]=S):S=e[2];const x=n.length>0&&o.jsx(Ph,{value:c,onChange:u,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(cs,{size:14}),e[3]=w):w=e[3];let k;e[4]!==a.isPending||e[5]!==p?(k=o.jsxs(ne,{size:"sm",onClick:p,disabled:a.isPending,children:[w,"New automation"]}),e[4]=a.isPending,e[5]=p,e[6]=k):k=e[6];let N;e[7]!==x||e[8]!==k?(N=o.jsxs("div",{className:"flex flex-col gap-6",children:[S,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[x,k]})]}),e[7]=x,e[8]=k,e[9]=N):N=e[9];const D=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(zs,{image:o.jsx($s,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(ne,{size:"sm",onClick:p,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):f.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(zs,{image:o.jsx($s,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${c}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:f.map(R=>o.jsx(Ah,{automation:R,onClick:()=>m(R.id)},R.id))});let j;e[10]!==D||e[11]!==b.Body||e[12]!==N?(j=o.jsxs(b.Body,{children:[N,D]}),e[10]=D,e[11]=b.Body,e[12]=N,e[13]=j):j=e[13];let B;e[14]!==j||e[15]!==v.Content?(B=o.jsx(v.Content,{children:j}),e[14]=j,e[15]=v.Content,e[16]=B):B=e[16];let I;return e[17]!==g||e[18]!==B?(I=o.jsx(g,{children:B}),e[17]=g,e[18]=B,e[19]=I):I=e[19],I}function sg(t){const e=H.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(L.Suspense,{fallback:i,children:o.jsx(tg,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Uo=L.lazy(()=>Kl(()=>import("./project-app-view-DiCZcUip.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function ig(t){const e=H.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Pa(r);if(pc(n)){let m;return e[3]!==i?(m=o.jsx(qn,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Pu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(sg,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Lp,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(xf,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Zp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=gc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=x=>x.appId===u.connectionId&&x.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let b;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(b=o.jsx(L.Suspense,{fallback:g,children:o.jsx(Uo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=b):b=e[29],b}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(L.Suspense,{fallback:m,children:o.jsx(Uo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx(qn,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function rg(t){const e=H.c(7),{children:s,defaultSize:i}=t,[,r]=L.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ta.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=ea(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(ma,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function ng(t){const e=H.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Pn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=ta.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=ea(c,45),d=L.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const B=d.current;if(!B)return;const I=Pn(r,n),R=I.chat>0&&I.chat<100?u:I.chat,y=I.chat>0&&I.chat<100?100-u:I.main;B.setLayout([R,y])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),L.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Ia,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx(rg,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(th,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[18]=w):w=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=re("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=k):k=e[19];let N;e[20]!==i||e[21]!==s?(N=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:k,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ht,{children:o.jsx(ig,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=N):N=e[22];let D;e[23]!==h.main||e[24]!==N?(D=o.jsx(ma,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:N}),e[23]=h.main,e[24]=N,e[25]=D):D=e[25];let j;return e[26]!==D||e[27]!==m||e[28]!==b?(j=o.jsxs(sh,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,D]},m),e[26]=D,e[27]=m,e[28]=b,e[29]=j):j=e[29],j}const ur="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Vo="bg-sidebar-accent text-sidebar-foreground",fr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function og(t){const e=H.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Oc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{Se("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Vo:fr;let u;e[3]!==c?(u=re(ur,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Ic,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(Ge,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Ye,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(qe,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{Se("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?Vo:fr;let v;e[16]!==g?(v=re(ur,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Ac,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ge,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ye,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let w;e[24]!==S?(w=o.jsxs(qe,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=w):w=e[25];const k=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let N;e[26]!==k?(N=re("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",k),e[26]=k,e[27]=N):N=e[27];const D=!l,j=l?0:-1,B=!l,I=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let R;e[28]!==I?(R=re(ur,fr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",I),e[28]=I,e[29]=R):R=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(la,{size:16}),e[30]=y):y=e[30];let T;e[31]!==r||e[32]!==D||e[33]!==j||e[34]!==B||e[35]!==R?(T=o.jsx(Ge,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:D,tabIndex:j,"aria-hidden":B,className:R,children:y})}),e[31]=r,e[32]=D,e[33]=j,e[34]=B,e[35]=R,e[36]=T):T=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(Ye,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let C;e[38]!==T?(C=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(qe,{delayDuration:300,children:[T,E]})}),e[38]=T,e[39]=C):C=e[39];let P;e[40]!==N||e[41]!==C?(P=o.jsx("div",{className:N,children:C}),e[40]=N,e[41]=C,e[42]=P):P=e[42];let M;return e[43]!==w||e[44]!==P||e[45]!==m?(M=o.jsxs(o.Fragment,{children:[m,w,P]}),e[43]=w,e[44]=P,e[45]=m,e[46]=M):M=e[46],M}function ag(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function lg(t){const e=H.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=re("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(cg,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function cg(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}function hg(t){const e=H.c(13),{overflow:s,onSelect:i}=t,[r,n]=L.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Vs,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ca,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(dg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Ks,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(qs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function dg(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}const ug=6;function fg(t){const e=H.c(20),{virtualMcpId:s,taskId:i}=t,r=At();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Pa(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=vc({activeTab:l,mainOpen:h}),v=k=>k.id==="automations"?g:h&&k.id===l,S=a.find(k=>v(k))?.id??null,{visible:x,overflow:w}=ag(a,S,ug);d=w,u=k=>{const N=a.find(j=>j.id===k),D=S===k&&h;if(Se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:N?.kind??null,was_active:D}),k==="automations"){const j=xc({activeTab:l,mainOpen:h});r({to:".",search:B=>({...B,main:j}),replace:!0});return}c(k)},f="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(k=>o.jsx(lg,{title:k.title,icon:k.icon,active:v(k),onClick:()=>u(k.id)},k.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(hg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function mg(t){const e=H.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=re("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(ql,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function _g(t){const e=H.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(ku({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(Cu({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(ne,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(vr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(os,{asChild:!0,children:o.jsx(ne,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(as,{align:"end",children:o.jsx(wt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(ns,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const pg=new Set(["failure","timed_out","cancelled","action_required"]);function gg(t){return t.status==="completed"&&pg.has(t.conclusion)}function vg(t){return t.status==="queued"||t.status==="in_progress"}function xg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(gg).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(vg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function bg(){return Gt().branchStatus}const Sg=6e4,yg=3e4;function wg(t){const e=H.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Fe(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Sg,refetchIntervalInBackground:!1,staleTime:yg,select:Cg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],ms(l)}function Cg(t){const e=Ys(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function kg(t){const e=H.c(42),{virtualMcpId:s}=t,{org:i}=ge(),r=Ct(s),{currentBranch:n}=gt(),a=fs(),l=r?.metadata?.githubRepo??null,h=bg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=za(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==b||e[12]!==S?(x={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:b,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=b,e[12]=S,e[13]=x):x=e[13];const w=Fa(x),k=l?.connectionId??"",N=l?.owner??"",D=l?.name??"",j=p&&p.state==="open"?p.number:null;let B;e[14]!==i.id||e[15]!==i.slug||e[16]!==k||e[17]!==N||e[18]!==D||e[19]!==j?(B={orgId:i.id,orgSlug:i.slug,connectionId:k,owner:N,repo:D,prNumber:j},e[14]=i.id,e[15]=i.slug,e[16]=k,e[17]=N,e[18]=D,e[19]=j,e[20]=B):B=e[20];const I=wg(B);if(!l?.connectionId||!n)return null;let R;e[21]!==h||e[22]!==w.data||e[23]!==p||e[24]!==m.isPending||e[25]!==I.data?(R=xg({branchStatus:h,pr:p,checks:w.data??[],reviews:I.data??null,loading:m.isPending}),e[21]=h,e[22]=w.data,e[23]=p,e[24]=m.isPending,e[25]=I.data,e[26]=R):R=e[26];const y=R;let T;e[27]!==a?(T=V=>a.sendMessage({parts:[{type:"text",text:V}]}),e[27]=a,e[28]=T):T=e[28];const E=T,C=a.isStreaming;let P;e[29]!==n||e[30]!==y||e[31]!==C||e[32]!==p||e[33]!==E?(P=V=>{if(!C)switch(V){case"commit-and-push":{E(pu({branch:n}));return}case"create-pr":{E(gu({branch:n}));return}case"reopen":{p&&E(vu({prNumber:p.number}));return}case"rebase":{E(xu({branch:n}));return}case"fix-checks":{p&&E(Su({prNumber:p.number,failingChecks:y.meta?.failingChecks??[]}));return}case"mark-ready":{p&&E(yu({prNumber:p.number}));return}case"resolve-comments":{p&&E(wu({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=y,e[31]=C,e[32]=p,e[33]=E,e[34]=P):P=e[34];const M=P;let F;e[35]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx(mg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=F):F=e[35];const U=p?.number;let z;return e[36]!==y||e[37]!==C||e[38]!==M||e[39]!==E||e[40]!==U?(z=o.jsxs(o.Fragment,{children:[F,o.jsx(Ng,{button:y,isStreaming:C,onActivate:M,prNumber:U,send:E})]}),e[36]=y,e[37]=C,e[38]=M,e[39]=E,e[40]=U,e[41]=z):z=e[41],z}function Ng(t){const e=H.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(_g,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx(Ko,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(Ch,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(ne,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx(Ko,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function Ko(t){const e=H.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Ge,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Ye,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Yc,{children:o.jsxs(qe,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function jg(t){const e=H.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(_r.Right,{children:o.jsx(kg,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Qt=L.createContext(null);function yn(){return L.use(Qt)}function qo(t){const e=H.c(7),{children:s}=t,{taskId:i}=gt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Ia,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ht,{fallback:r,children:o.jsx(L.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Go(t){const e=H.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],L.useLayoutEffect(r),null}function Eg(t){const e=H.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(nc,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Yo(t){const e=H.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ge(),{currentBranch:l}=gt(),{data:h}=Ei.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Bt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=Fe(u),{mutate:f}=cn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=L.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:Tg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),L.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Ju,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function Tg(t){console.error("[auto-start-vm] failed:",t)}function Dg(){const t=H.c(96),e=fa(),s=At(),{org:i}=ge(),r=zc()?.tasksOpen??!1;Xc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Gl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=sn(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??sa(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=zh(a.taskId??"",d),_=Ct(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Kt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const x=$c(g,S),{setOpenMobile:w,openMobile:k}=Vc(),N=w,D=L.useRef(null);let j,B;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const X=$=>{Wc($)&&$.shiftKey&&$.code==="KeyS"&&!$.repeat&&($.preventDefault(),D.current?.())};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},B=[],t[12]=j,t[13]=B):(j=t[12],B=t[13]),L.useEffect(j,B);const I=d;let R;t[14]!==_||t[15]!==d?(R={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=R):R=t[16];const y=R;if(f.status==="creating"||f.status==="loading"){let X;t[17]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Me,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=X):X=t[17];let $;return t[18]!==y?($=o.jsx(Qt,{value:y,children:X}),t[18]=y,t[19]=$):$=t[19],$}if(f.status==="error"){let X;t[20]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=X):X=t[20];let $;t[21]!==f.error.message?($=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[X,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=$):$=t[22];let A;return t[23]!==y||t[24]!==$?(A=o.jsx(Qt,{value:y,children:$}),t[23]=y,t[24]=$,t[25]=A):A=t[25],A}if(!_){let X;t[26]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx(Os,{size:48,className:"text-muted-foreground"}),t[26]=X):X=t[26];const $=`The agent "${d}" does not exist in this organization.`;let A;t[27]!==s||t[28]!==l?(A=o.jsx(ne,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=A):A=t[29];let G;t[30]!==$||t[31]!==A?(G=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(zs,{image:X,title:"Agent not found",description:$,actions:A})})}),t[30]=$,t[31]=A,t[32]=G):G=t[32];let Y;return t[33]!==y||t[34]!==G?(Y=o.jsx(Qt,{value:y,children:G}),t[33]=y,t[34]=G,t[35]=Y):Y=t[35],Y}if(e){let X;t[36]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx(Kc,{className:"sr-only",children:"Navigation"}),t[36]=X):X=t[36];let $;t[37]!==N?($=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Fc,{onClose:()=>N(!1)})}),t[37]=N,t[38]=$):$=t[38];let A;t[39]===Symbol.for("react.memo_cache_sentinel")?(A=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Hc,{})}),t[39]=A):A=t[39];let G;t[40]!==$?(G=o.jsxs(qc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[X,o.jsxs("div",{className:"flex h-full",children:[$,A]})]}),t[40]=$,t[41]=G):G=t[41];let Y;t[42]!==k||t[43]!==N||t[44]!==G?(Y=o.jsx(Gc,{open:k,onOpenChange:N,children:G}),t[42]=k,t[43]=N,t[44]=G,t[45]=Y):Y=t[45];const Q=Y,ie=_?.metadata?.vmMap;let ee;t[46]!==x.createNewTask?(ee=o.jsx(Go,{onNewTaskRef:D,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=ee):ee=t[47];let q;t[48]!==N?(q=o.jsx(Eg,{onOpenSidebar:()=>N(!0)}),t[48]=N,t[49]=q):q=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(qo,{})}),t[50]=he):he=t[50];let ue;t[51]!==b||t[52]!==Q||t[53]!==ie||t[54]!==ee||t[55]!==q||t[56]!==d?(ue=o.jsxs(Yo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:ie,children:[ee,q,he,Q]}),t[51]=b,t[52]=Q,t[53]=ie,t[54]=ee,t[55]=q,t[56]=d,t[57]=ue):ue=t[57];let de;t[58]!==I||t[59]!==ue?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:I,children:ue},I)}),t[58]=I,t[59]=ue,t[60]=de):de=t[60];let fe;return t[61]!==y||t[62]!==de?(fe=o.jsx(Qt,{value:y,children:de}),t[61]=y,t[62]=de,t[63]=fe):fe=t[63],fe}const T=r?void 0:x.createNewTask;let E;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==T?(E=o.jsx(_r.Toggles,{children:o.jsx(og,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:T})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=T,t[67]=E):E=t[67];let C;t[68]!==x.taskId||t[69]!==d?(C=o.jsx(_r.Tabs,{children:o.jsx(fg,{virtualMcpId:d,taskId:x.taskId})}),t[68]=x.taskId,t[69]=d,t[70]=C):C=t[70];const P=_?.metadata?.vmMap;let M;t[71]!==_?(M=o.jsx(jg,{virtualMcp:_}),t[71]=_,t[72]=M):M=t[72];let F;t[73]!==x.createNewTask?(F=o.jsx(Go,{onNewTaskRef:D,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=F):F=t[74];let U;t[75]===Symbol.for("react.memo_cache_sentinel")?(U=o.jsx(qo,{}),t[75]=U):U=t[75];let z;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==d?(z=o.jsx(ng,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:U}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=d,t[80]=z):z=t[80];let V;t[81]!==b||t[82]!==P||t[83]!==M||t[84]!==F||t[85]!==z||t[86]!==d?(V=o.jsxs(Yo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:P,children:[M,F,z]}),t[81]=b,t[82]=P,t[83]=M,t[84]=F,t[85]=z,t[86]=d,t[87]=V):V=t[87];let se;t[88]!==I||t[89]!==C||t[90]!==V?(se=o.jsxs(je.Provider,{virtualMcpId:I,children:[C,V]},I),t[88]=I,t[89]=C,t[90]=V,t[91]=se):se=t[91];let te;return t[92]!==y||t[93]!==E||t[94]!==se?(te=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Qt,{value:y,children:[E,se]})}),t[92]=y,t[93]=E,t[94]=se,t[95]=te):te=t[95],te}function O1(){const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(L.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Dg,{})}),t[0]=e):e=t[0],e}export{O1 as default,yn as useInsetContext};
|