decocms 2.281.2 → 2.281.4-alpha.1
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-BeQFaTo3.js → AlertCircle-7JjFgLc7.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-C-IANgnQ.js → ArrowNarrowLeft-Dede_Ne2.js} +1 -1
- package/dist/client/assets/{CheckCircle-Dh4A5tI_.js → CheckCircle-CTW72EON.js} +1 -1
- package/dist/client/assets/{ChevronDown-D9aZn2Hi.js → ChevronDown-kxc5hHzL.js} +1 -1
- package/dist/client/assets/{ChevronRight-CkL59Zuk.js → ChevronRight-DDbSh6n1.js} +1 -1
- package/dist/client/assets/{ChevronUp-C7hCnblE.js → ChevronUp-Dp8gBsiQ.js} +1 -1
- package/dist/client/assets/{Container-CSvdcipc.js → Container-DbPEBCPd.js} +1 -1
- package/dist/client/assets/{LinkExternal01-sdvrsKlM.js → LinkExternal01-DGpodMuQ.js} +1 -1
- package/dist/client/assets/{Lock01-CneVnDQd.js → Lock01-DWeyLAgC.js} +1 -1
- package/dist/client/assets/{Palette-Bo0ad1R6.js → Palette-9DjyOnf4.js} +1 -1
- package/dist/client/assets/{Play-BhoAd8Uu.js → Play-CGVWyYId.js} +1 -1
- package/dist/client/assets/{Plus-79r9zazJ.js → Plus-BZ8TfrO6.js} +1 -1
- package/dist/client/assets/{SearchMd-00qF-7Ba.js → SearchMd-DiHiiShh.js} +1 -1
- package/dist/client/assets/{Settings02-B6cIpcv6.js → Settings02-BrMLRmyq.js} +1 -1
- package/dist/client/assets/{Star01-RArWROxo.js → Star01-DOZUyUGI.js} +1 -1
- package/dist/client/assets/{Sun-CaIYIMZ6.js → Sun-D9NMWxb1.js} +1 -1
- package/dist/client/assets/{Tool01-BK4G_l0X.js → Tool01-CPwXEQb5.js} +1 -1
- package/dist/client/assets/{Trash01-PNv-fbRK.js → Trash01-JJPVWHIh.js} +1 -1
- package/dist/client/assets/{Upload01-BeVyQxbB.js → Upload01-CAASdeK2.js} +1 -1
- package/dist/client/assets/{User01-BirINwKI.js → User01-DzewYYcp.js} +1 -1
- package/dist/client/assets/{Users03-Dpk7x7z4.js → Users03-1bfUrVZT.js} +1 -1
- package/dist/client/assets/{X-KSz9xyi5.js → X-CyqBZIBt.js} +1 -1
- package/dist/client/assets/{XCircle-uU-3aWe3.js → XCircle-C0Pb9VbS.js} +1 -1
- package/dist/client/assets/{Zap-DvQy6Azt.js → Zap-WS6KKy8N.js} +1 -1
- package/dist/client/assets/{ZapSquare-Dk1UmO2a.js → ZapSquare-DBz9qdVm.js} +1 -1
- package/dist/client/assets/{accordion-w6xYXziw.js → accordion-iHKIJir4.js} +1 -1
- package/dist/client/assets/{agent-icon-CMOX8nfk.js → agent-icon-OPgA0_xh.js} +1 -1
- package/dist/client/assets/{agents-list-CeEeRXns.js → agents-list-EtMSypXC.js} +1 -1
- package/dist/client/assets/ai-providers-BkPyz71b.js +1 -0
- package/dist/client/assets/{alert-dialog-DtwmYIx7.js → alert-dialog-CvUq9c2l.js} +1 -1
- package/dist/client/assets/{auth-catchall-CMH1u4oJ.js → auth-catchall-C2AFIXKV.js} +1 -1
- package/dist/client/assets/{automation-list-row-Sb9JaQY9.js → automation-list-row-srgvCKZh.js} +1 -1
- package/dist/client/assets/{automations-Dmw1cKQC.js → automations-Dp2hsJvG.js} +1 -1
- package/dist/client/assets/{avatar-BSJnhSPL.js → avatar-BAGLgwIy.js} +1 -1
- package/dist/client/assets/{badge-BbahYJz-.js → badge-Csg5fgRc.js} +1 -1
- package/dist/client/assets/{brand-context-9yJi8LtT.js → brand-context-D7GISA6v.js} +1 -1
- package/dist/client/assets/{card-BBjkVedQ.js → card-bx_QeXw_.js} +1 -1
- package/dist/client/assets/{chat-context-BVA22TkC.js → chat-context-OvrSchhz.js} +1 -1
- package/dist/client/assets/{checkbox-BNYrEZke.js → checkbox-C7KSBfZr.js} +1 -1
- package/dist/client/assets/{collection-detail-WDWjdfFo.js → collection-detail-BcTctJfQ.js} +1 -1
- package/dist/client/assets/{collection-display-button-C_SpzkVL.js → collection-display-button-B4SGVjCw.js} +1 -1
- package/dist/client/assets/{collection-search-3gkmMFfK.js → collection-search-DOj_zhXC.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-Nq245ZaG.js → collection-table-wrapper-C7ZPBElG.js} +1 -1
- package/dist/client/assets/{collection-tabs-DQAAB0E9.js → collection-tabs-DrO0tDqW.js} +1 -1
- package/dist/client/assets/{collections-CvC03WFa.js → collections-DRefuj7X.js} +1 -1
- package/dist/client/assets/{command-COmac0HY.js → command-CGYZopFY.js} +1 -1
- package/dist/client/assets/{connection-card-C-lcUJmx.js → connection-card-x5-U4xYO.js} +1 -1
- package/dist/client/assets/{connection-detail-DXUAuxOs.js → connection-detail-DNT7n-qD.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-Beczk_I1.js → connection-form-helpers-Cieg3At7.js} +1 -1
- package/dist/client/assets/{connections-jiDZ88zc.js → connections-CcMp0k3e.js} +1 -1
- package/dist/client/assets/{constants-K9p6sFeA.js → constants-BTGWOBGG.js} +1 -1
- package/dist/client/assets/{constants-BXYBvBo8.js → constants-DfNucTio.js} +1 -1
- package/dist/client/assets/{dialog-Cu_M3bSF.js → dialog-CDZoEVTf.js} +1 -1
- package/dist/client/assets/{drawer-C0zWk4g_.js → drawer-BtA5XqsS.js} +1 -1
- package/dist/client/assets/{dropdown-menu-DVLrmulo.js → dropdown-menu-DU8JG2pk.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-4eAl2fmh.js → dynamic-plugin-layout-DI-gMMKE.js} +1 -1
- package/dist/client/assets/{empty-state-BKZHnGIj.js → empty-state-B2WkME-3.js} +1 -1
- package/dist/client/assets/{empty-state-CUC0Gkix.js → empty-state-BxCE5vnH.js} +1 -1
- package/dist/client/assets/{extract-connection-data-CvyRIMCz.js → extract-connection-data-DBjTfzuX.js} +1 -1
- package/dist/client/assets/{features-XCvz9PLL.js → features-BTMuaR90.js} +1 -1
- package/dist/client/assets/{form-Ddm04alF.js → form-nehB0yqt.js} +1 -1
- package/dist/client/assets/{general-DUSBEOfs.js → general-aaZSKs7j.js} +1 -1
- package/dist/client/assets/{index-Cg0hncqj.js → index-0Nuumosr.js} +1 -1
- package/dist/client/assets/{index-BPDAXzpD.js → index-A1TjNoro.js} +1 -1
- package/dist/client/assets/{index-BdfTJahg.js → index-BD-lTLoS.js} +1 -1
- package/dist/client/assets/{index-FLw-zxvs.js → index-BFKRaI9q.js} +1 -1
- package/dist/client/assets/{index-BrtLQXUh.js → index-C7LpArfe.js} +1 -1
- package/dist/client/assets/{index-uAQGGxtu.js → index-CFqkoEQr.js} +1 -1
- package/dist/client/assets/{index-BhIzdEY1.js → index-DkLXfxeF.js} +2 -2
- package/dist/client/assets/{index-BH8gPP0f.js → index-DvGOE4TR.js} +1 -1
- package/dist/client/assets/{index-CU16qbkD.js → index-FCEJcMKv.js} +4 -4
- package/dist/client/assets/{index-BHskyDSR.js → index-nsskrYaZ.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-BO26Xlha.js → infiniteQueryObserver-VUPo5ONC.js} +1 -1
- package/dist/client/assets/{input-Bz8fx1AG.js → input-Dxp3-aWz.js} +1 -1
- package/dist/client/assets/{integration-icon-Byenx_4j.js → integration-icon-DUduEF01.js} +1 -1
- package/dist/client/assets/{label-DaHwCWWB.js → label-BVoDYtUr.js} +1 -1
- package/dist/client/assets/{layout-C8AFQnZg.js → layout-C9Y7P28P.js} +1 -1
- package/dist/client/assets/{lean-canvas-recruit-modal-mykHJAKm.js → lean-canvas-recruit-modal-N8EVMVv5.js} +1 -1
- package/dist/client/assets/{login-DwiMJDl5.js → login-kx3MQEcu.js} +1 -1
- package/dist/client/assets/{members-Cd_WsIS9.js → members-BucBnRu5.js} +1 -1
- package/dist/client/assets/{monaco-editor-D27CWon0.js → monaco-editor-WwGGEq4E.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-C-XRpFjl.js → monitoring-stats-row-D5uhoKE2.js} +1 -1
- package/dist/client/assets/{oauth-callback-GuSY-vSr.js → oauth-callback-BB1bfQ0C.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-D3FgevI5.js → oauth-callback-ai-provider-Cx11JY4J.js} +1 -1
- package/dist/client/assets/{onboarding-PM_BE0uA.js → onboarding-CRDp-7ts.js} +1 -1
- package/dist/client/assets/{org-layout-C251Cbcv.js → org-layout-DWgxefUR.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-BwQLOazi.js → org-plugin-layout-B0IS-vI9.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-DLXHjQeu.js → plugin-empty-state-C9Il8L-B.js} +1 -1
- package/dist/client/assets/{plugin-header-BddmOg85.js → plugin-header-DF-027xA.js} +1 -1
- package/dist/client/assets/{plugin-layout-RqfANRb_.js → plugin-layout-CQviDmLQ.js} +1 -1
- package/dist/client/assets/{popover-BEF8mI0w.js → popover-_s_tQK3Z.js} +1 -1
- package/dist/client/assets/{profile-DrdPa8Y7.js → profile-BAAvq5PA.js} +1 -1
- package/dist/client/assets/{project-app-view-XrA_5t6Q.js → project-app-view-CWfRTdtF.js} +1 -1
- package/dist/client/assets/registry-BO9_rH5u.js +2 -0
- package/dist/client/assets/{registry-layout-CwCyJT-v.js → registry-layout-DQKjQh-i.js} +1 -1
- package/dist/client/assets/{required-auth-layout-Cxviv7yN.js → required-auth-layout-CXhuopzx.js} +1 -1
- package/dist/client/assets/{reset-password-DYbWh4Wq.js → reset-password-DZzWPbSN.js} +1 -1
- package/dist/client/assets/{scroll-area-_gjorSmM.js → scroll-area-hAa33XcH.js} +1 -1
- package/dist/client/assets/{search-input-Dflevf_r.js → search-input-C61ZvpPR.js} +1 -1
- package/dist/client/assets/{select-ruUaRI3f.js → select-DRB8tE_p.js} +1 -1
- package/dist/client/assets/{select-model-BgS5BYlp.js → select-model-CP81c55I.js} +1 -1
- package/dist/client/assets/settings-layout-UJNERdUa.js +1 -0
- package/dist/client/assets/{shell-layout-Lnkya_bN.js → shell-layout-DAhaxub0.js} +1 -1
- package/dist/client/assets/{skeleton-CvZ1yhmk.js → skeleton-3sAmljB_.js} +1 -1
- package/dist/client/assets/{sso-DVCm0NAv.js → sso-BmmBRsro.js} +1 -1
- package/dist/client/assets/{store-BAtOk8g6.js → store-Dq5sv0Ed.js} +1 -1
- package/dist/client/assets/store-registry-BfCS4xd0.js +2 -0
- package/dist/client/assets/{switch-C4VRxkon.js → switch-DL640Ue6.js} +1 -1
- package/dist/client/assets/{table-C1xMho2l.js → table-Dbi2W1JY.js} +1 -1
- package/dist/client/assets/{tabs-MUC8gGmo.js → tabs-BByMWKiD.js} +1 -1
- package/dist/client/assets/{task-status-DBTk3ApD.js → task-status-CmmBYEnr.js} +1 -1
- package/dist/client/assets/{textarea-Dh5aI-9Q.js → textarea-DHlYLEvo.js} +1 -1
- package/dist/client/assets/{toggle-group-qqPb8p7Z.js → toggle-group-CZBEspMS.js} +1 -1
- package/dist/client/assets/{tools-list-5INqbH2J.js → tools-list-DuX1kehi.js} +1 -1
- package/dist/client/assets/{types-Bp-YI7R5.js → types-DvTqSron.js} +1 -1
- package/dist/client/assets/{use-ai-providers-BXn7VXga.js → use-ai-providers-ClS89y7X.js} +1 -1
- package/dist/client/assets/{use-collections-Dg7sh01O.js → use-collections-Dv9KwC2D.js} +1 -1
- package/dist/client/assets/{use-connection-DhM_x-jA.js → use-connection-BmcG6E0P.js} +1 -1
- package/dist/client/assets/{use-copy-BuEIWb6s.js → use-copy-BkRNxEwn.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-KKiF-MXD.js → use-create-virtual-mcp-CH8VJize.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-BSRQhWTI.js → use-decopilot-events-BwyevFSM.js} +1 -1
- package/dist/client/assets/{use-delete-connection-EjeBh_jx.js → use-delete-connection-DfVzQzgY.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-BvRRlmDj.js → use-infinite-scroll-C0yn-Y6f.js} +1 -1
- package/dist/client/assets/{use-list-state-DJ8S20f9.js → use-list-state-D4yuEOh_.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-C0kKBiKr.js → use-mcp-tools-B1TR0GK5.js} +1 -1
- package/dist/client/assets/{use-members-D4VPX3yK.js → use-members-BSe-l5RV.js} +1 -1
- package/dist/client/assets/{use-mobile-BXRLCdzR.js → use-mobile-D7gj1mMa.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-C1QNfHMd.js → use-navigate-to-agent-BOFYFzjJ.js} +1 -1
- package/dist/client/assets/{use-org-sso-C1E2S5f1.js → use-org-sso-BIx4Rk_Y.js} +1 -1
- package/dist/client/assets/{use-organization-settings-NQDr_YDe.js → use-organization-settings-CcY3Vn-c.js} +1 -1
- package/dist/client/assets/{use-registry-connections-2buwPIEr.js → use-registry-connections-G41Zams2.js} +1 -1
- package/dist/client/assets/{use-status-sounds-C5rJSnr7.js → use-status-sounds-Cq0X5c0g.js} +1 -1
- package/dist/client/assets/{use-tasks-DoJvFu21.js → use-tasks-DqpLygvk.js} +1 -1
- package/dist/client/assets/{use-view-mode-eHr1pnSD.js → use-view-mode-hEZSGIRN.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-DPQanfrd.js → use-virtual-mcp-B0nMlTA1.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-D-Fu49PN.js +1 -0
- package/dist/client/assets/{user-D-0Dg4hb.js → user-B-lqJM9i.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-C9JdTAIx.js → view-mode-toggle-DSiIUGAP.js} +1 -1
- package/dist/client/assets/{workflow-Bo7CKW-_.js → workflow-C2B3R0BC.js} +1 -1
- package/dist/client/assets/workflow-detail-EmQ0YEuI.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +4 -2
- package/dist/server/node_modules/postgres-date/index.js +116 -0
- package/dist/server/node_modules/{postgres-bytea → postgres-date}/package.json +7 -8
- package/dist/server/node_modules/postgres-date/readme.md +49 -0
- package/dist/server/node_modules/split2/LICENSE +13 -0
- package/dist/server/node_modules/split2/README.md +85 -0
- package/dist/server/node_modules/split2/bench.js +27 -0
- package/dist/server/node_modules/split2/index.js +141 -0
- package/dist/server/node_modules/split2/package.json +39 -0
- package/dist/server/node_modules/split2/test.js +409 -0
- package/dist/server/server.js +3 -1
- package/package.json +1 -1
- package/dist/client/assets/ai-providers-_ruFOoFf.js +0 -1
- package/dist/client/assets/registry-hvW8DAlR.js +0 -2
- package/dist/client/assets/settings-layout-C9QCDWL8.js +0 -1
- package/dist/client/assets/store-registry-DyRkwg3g.js +0 -2
- package/dist/client/assets/useInfiniteQuery-Cozeocmy.js +0 -1
- package/dist/client/assets/workflow-detail-cv-DGPKy.js +0 -1
- package/dist/server/node_modules/ansi-styles/index.d.ts +0 -236
- package/dist/server/node_modules/ansi-styles/index.js +0 -223
- package/dist/server/node_modules/ansi-styles/license +0 -9
- package/dist/server/node_modules/ansi-styles/package.json +0 -54
- package/dist/server/node_modules/ansi-styles/readme.md +0 -173
- package/dist/server/node_modules/onetime/index.d.ts +0 -64
- package/dist/server/node_modules/onetime/index.js +0 -44
- package/dist/server/node_modules/onetime/license +0 -9
- package/dist/server/node_modules/onetime/package.json +0 -43
- package/dist/server/node_modules/onetime/readme.md +0 -94
- package/dist/server/node_modules/pg/LICENSE +0 -21
- package/dist/server/node_modules/pg/README.md +0 -95
- package/dist/server/node_modules/pg/esm/index.mjs +0 -20
- package/dist/server/node_modules/pg/lib/client.js +0 -743
- package/dist/server/node_modules/pg/lib/connection-parameters.js +0 -171
- package/dist/server/node_modules/pg/lib/connection.js +0 -221
- package/dist/server/node_modules/pg/lib/crypto/cert-signatures.js +0 -122
- package/dist/server/node_modules/pg/lib/crypto/sasl.js +0 -212
- package/dist/server/node_modules/pg/lib/crypto/utils-legacy.js +0 -43
- package/dist/server/node_modules/pg/lib/crypto/utils-webcrypto.js +0 -89
- package/dist/server/node_modules/pg/lib/crypto/utils.js +0 -9
- package/dist/server/node_modules/pg/lib/defaults.js +0 -91
- package/dist/server/node_modules/pg/lib/index.js +0 -73
- package/dist/server/node_modules/pg/lib/native/client.js +0 -323
- package/dist/server/node_modules/pg/lib/native/index.js +0 -2
- package/dist/server/node_modules/pg/lib/native/query.js +0 -165
- package/dist/server/node_modules/pg/lib/query.js +0 -252
- package/dist/server/node_modules/pg/lib/result.js +0 -109
- package/dist/server/node_modules/pg/lib/stream.js +0 -83
- package/dist/server/node_modules/pg/lib/type-overrides.js +0 -35
- package/dist/server/node_modules/pg/lib/utils.js +0 -217
- package/dist/server/node_modules/pg/package.json +0 -76
- package/dist/server/node_modules/postgres-array/index.d.ts +0 -4
- package/dist/server/node_modules/postgres-array/index.js +0 -97
- package/dist/server/node_modules/postgres-array/package.json +0 -35
- package/dist/server/node_modules/postgres-array/readme.md +0 -43
- package/dist/server/node_modules/postgres-bytea/index.js +0 -33
- package/dist/server/node_modules/postgres-bytea/license +0 -21
- package/dist/server/node_modules/postgres-bytea/readme.md +0 -34
- /package/dist/server/node_modules/{postgres-array → postgres-date}/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 Mt,r as S,p as Jm,q as Qm,e as B,s as ye,K as ct,n as Wi,a as Ki,v as js,w as Un,x as qi,j as n,B as oe,y as Et,c as X,E as Ns,z as fe,C as yi,_ as Zm,t as ie,f as qe,D as fl,F as ep,R as Ih,G as tp,H as Vs,I as Ao,J as ms,L as sp,M as Eo,P as ip,Q as np,T as rp,U as op,V as Rh,W as ap,X as lp,Y as cp,Z as dp,$ as pc,l as De,b as St,u as hp,a0 as bn,a1 as wr,a2 as ml,a3 as pl,g as Hn,a4 as Th,d as Si,a5 as up,a6 as fp,a7 as mp,a8 as pp,a9 as Dh,aa as Mh,ab as gp,ac as _p,ad as xp,ae as Ut,af as vp,ag as bp,ah as yp,ai as Sp,aj as sn,ak as wp,al as Vp,am as Cp,an as kp,ao as Ph,ap as jp,aq as Np,ar as Ap,as as Ep,at as Ip,au as Rp,av as Tp,aw as Dp,ax as Mp,ay as Pp,az as Lh,aA as Vr,aB as Lp,aC as Ri,aD as cr,aE as Oh,aF as Op,aG as Bp}from"./index-BhIzdEY1.js";import{u as ai,a as Gi,b as es,A as zp,C as $p,t as Bh,c as ha,d as Fp,e as ro,f as gc}from"./chat-context-BVA22TkC.js";import{d as oo,g as ni,c as Up,s as gl,t as Hp,a as Wp,M as Kp,i as qp,b as En,e as Gp,F as Yp,f as zh,S as Xp,u as Jp,h as _c,j as Qp,k as Zp,l as ua,r as eg,m as tg,p as $h,n as sg,o as ig,q as _l,G as ng,L as rg,v as og,w as ag,x as lg,y as cg}from"./task-status-DBTk3ApD.js";import{S as In,u as ao,P as fa,a as dg,b as hg,c as ug,E as fg,i as mg,d as pg,e as Fh}from"./scroll-area-_gjorSmM.js";import{T as Oi,u as Ms,a as st,b as it,c as nt}from"./use-mobile-BXRLCdzR.js";import{D as ds,a as hs,b as xl,c as ts,d as ss,e as lo}from"./dialog-Cu_M3bSF.js";import{D as co,a as wi,b as Vi,c as Ci,d as gg,e as _g,f as xg}from"./drawer-C0zWk4g_.js";import{C as Uh}from"./collection-search-3gkmMFfK.js";import{S as Pt,u as Le,g as ho,i as Br,c as vg,W as zs,a as bg,b as vl}from"./constants-BXYBvBo8.js";import{u as Hh,g as bl,T as Wh,a as Cr,l as zr,b as Io,c as yg}from"./tabs-MUC8gGmo.js";import{F as Bi,a as It,b as Rt,c as os,d as Tt,e as Dt,f as Sg}from"./form-Ddm04alF.js";import{I as gt}from"./input-Bz8fx1AG.js";import{i as Kh,u as Wn,r as qh}from"./shell-layout-Lnkya_bN.js";import{D as at,a as kr,b as jr,c as As,d as Es,e as Is,f as Gh,g as Yh,h as xc}from"./dropdown-menu-DVLrmulo.js";import{t as wg,i as Xh,n as Jh,A as gs,a as Qh,b as yl,s as ri,c as Vg,d as Cg,e as Zh,f as eu,g as kg,h as Sl,j as yn,k as jg,l as wl,m as Ng,o as Ag,p as Kn,q as qn,r as Eg,u as vc,v as bc,w as Ig,x as Rg,y as yc,z as Tg,B as Vl,C as tu,D as ma,E as Ro,F as Sc,G as Dg,H as Mg,I as Pg,J as Lg,K as su,L as iu,M as nu,N as ru,O as wc,P as Og,Q as Sn,R as Bg,S as zg,T as $g,U as ou}from"./agent-icon-CMOX8nfk.js";import{n as au,a as pa,i as Fg,b as Ug,c as Hg}from"./ZapSquare-Dk1UmO2a.js";import{i as Jt,t as Rn}from"./ChevronDown-D9aZn2Hi.js";import{s as Pi}from"./Star01-RArWROxo.js";import{a as ga,t as Cl}from"./Tool01-BK4G_l0X.js";import{i as lu}from"./Lock01-CneVnDQd.js";import{s as Qt}from"./Plus-79r9zazJ.js";import{i as cu}from"./Upload01-BeVyQxbB.js";import{i as Js}from"./X-KSz9xyi5.js";import{i as oi}from"./AlertCircle-BeQFaTo3.js";import{S as Zs,a as ei,b as Ht,c as ti,d as si}from"./select-ruUaRI3f.js";import{i as kl,a as jl,b as Wg}from"./SearchMd-00qF-7Ba.js";import{i as uo,t as Kg,a as qg,b as Gg,c as Yg,d as Xg,e as zi,f as du}from"./XCircle-uU-3aWe3.js";import{T as hu,a as $r}from"./toggle-group-qqPb8p7Z.js";import{u as Nl,a as uu}from"./use-ai-providers-BXn7VXga.js";import{m as fo,g as Jg,i as Qg,a as fu,M as mu,N as Zg}from"./select-model-BgS5BYlp.js";import{S as e_,A as t_,a as s_,b as i_,c as n_,R as pu,d as r_,e as o_}from"./accordion-w6xYXziw.js";import{r as gu,l as wn,u as a_,g as l_}from"./types-Bp-YI7R5.js";import{u as mo,a as is,b as Al}from"./use-virtual-mcp-DPQanfrd.js";import{u as Gn,a as po,b as El}from"./use-connection-DhM_x-jA.js";import{p as c_,q as Vc}from"./question-004-sINsf4GQ.js";import{g as Cc}from"./ai-providers-logos-CS4PCiqI.js";import{g as _u,s as xu}from"./connection-slug-eyAPH6o3.js";import{u as vu,a as bu,g as d_,C as To}from"./connection-card-C-lcUJmx.js";import{C as yu}from"./collection-tabs-DQAAB0E9.js";import{g as Su}from"./constants-K9p6sFeA.js";import{T as _a}from"./textarea-Dh5aI-9Q.js";import{n as Nr}from"./Container-CSvdcipc.js";import{c as h_,i as dr,a as kc,E as u_,p as f_,b as m_,d as p_}from"./connection-form-helpers-Beczk_I1.js";import{u as jc}from"./use-infinite-scroll-BvRRlmDj.js";import{u as g_,C as __,a as Nc,b as Ac,c as x_,d as v_,e as b_,f as y_}from"./command-COmac0HY.js";import{g as S_,e as w_,a as V_}from"./extract-connection-data-CvyRIMCz.js";import{B as Ec}from"./badge-BbahYJz-.js";import{i as Il}from"./ChevronRight-CkL59Zuk.js";import{I as Ps}from"./integration-icon-Byenx_4j.js";import{S as $i}from"./skeleton-CvZ1yhmk.js";import{a as go}from"./Users03-Dpk7x7z4.js";import{G as wu,u as C_,a as Fr,I as Ur,S as Vu,L as k_,b as j_}from"./lean-canvas-recruit-modal-mykHJAKm.js";import{u as Yn,a as Cu}from"./use-navigate-to-agent-C1QNfHMd.js";import{S as Hr}from"./switch-C4VRxkon.js";import{u as ku}from"./use-create-virtual-mcp-KKiF-MXD.js";import{i as N_}from"./CheckCircle-Dh4A5tI_.js";import{P as li,a as ci,b as di}from"./popover-BEF8mI0w.js";import{u as ki,a as A_}from"./use-mcp-tools-C0kKBiKr.js";import{E as Fi}from"./empty-state-BKZHnGIj.js";import{u as E_}from"./use-decopilot-events-BSRQhWTI.js";import{i as Ui}from"./Zap-DvQy6Azt.js";import{i as ju,S as Xn,a as Jn,b as vs,u as Qn,c as _s,d as Zt,e as Nu,f as Au,g as I_,h as Eu,j as Iu,P as ps,k as R_,l as T_,m as D_,n as M_,o as P_,p as L_}from"./index-BH8gPP0f.js";import{A as Ic}from"./avatar-BSJnhSPL.js";import{n as O_,a as B_,i as z_}from"./Sun-CaIYIMZ6.js";import{a as Zn}from"./Settings02-B6cIpcv6.js";import{A as Rl,a as Tl,b as Dl,c as Ml,d as Pl,e as Ll,f as Ol,g as Ru}from"./alert-dialog-DtwmYIx7.js";import"./index-uAQGGxtu.js";import{u as Tu}from"./use-tasks-DoJvFu21.js";import{u as $_}from"./use-status-sounds-C5rJSnr7.js";import{T as F_,u as Du}from"./tools-list-5INqbH2J.js";import{u as Do}from"./unwrap-tool-result-BYXdCQMg.js";import{C as U_,a as Rc}from"./card-BBjkVedQ.js";import{L as Vn}from"./label-DaHwCWWB.js";import{i as Ar}from"./Play-BhoAd8Uu.js";import{s as xa}from"./Trash01-PNv-fbRK.js";import{C as H_}from"./checkbox-BNYrEZke.js";import{n as ji}from"./LinkExternal01-sdvrsKlM.js";import{V as W_}from"./view-mode-toggle-C9JdTAIx.js";import{U as K_}from"./user-D-0Dg4hb.js";import{u as er,a as q_,b as G_,c as Y_,A as X_,d as J_}from"./automation-list-row-Sb9JaQY9.js";import{S as Q_}from"./search-input-Dflevf_r.js";import"./use-collections-Dg7sh01O.js";import"./use-organization-settings-NQDr_YDe.js";import"./use-copy-BuEIWb6s.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./required-auth-layout-Cxviv7yN.js";import"./use-org-sso-C1E2S5f1.js";import"./ArrowNarrowLeft-C-IANgnQ.js";import"./ChevronUp-C7hCnblE.js";import"./Palette-Bo0ad1R6.js";import"./User01-BirINwKI.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-2buwPIEr.js";import"./useInfiniteQuery-Cozeocmy.js";import"./infiniteQueryObserver-BO26Xlha.js";import"./collections-CvC03WFa.js";import"./index-BHskyDSR.js";import"./create-sse-subscription-CxkOgzKf.js";function Z_(t,e){const s=Mt(e);return ex({filters:{...t,status:"pending"}},s).length}function Tc(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function ex(t={},e){const s=Mt(e).getMutationCache(),i=S.useRef(t),r=S.useRef(null);return r.current===null&&(r.current=Tc(s,t)),S.useEffect(()=>{i.current=t}),S.useSyncExternalStore(S.useCallback(o=>s.subscribe(()=>{const a=Jm(r.current,Tc(s,i.current));r.current!==a&&(r.current=a,Qm.schedule(o))}),[s]),()=>r.current,()=>r.current)}function tx(t,e){const s=B.c(37),{org:i,locator:r}=ye();let o;s[0]!==i.id?(o={connectionId:Pt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Le(o),l=Mt();let c;s[2]!==t||s[3]!==i.id?(c=ct.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=Wi(u);let f;s[11]!==a||s[12]!==e?(f=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const k=y.content,w=Array.isArray(k)&&k[0]&&typeof k[0]=="object"?k[0].text??"Create failed":"Create failed";throw new Error(w)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=f):f=s[13];let m;s[14]!==r||s[15]!==i.id||s[16]!==h||s[17]!==l?(m=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:ct.tasksPrefix(r)}),h.refetch()},s[14]=r,s[15]=i.id,s[16]=h,s[17]=l,s[18]=m):m=s[18];let p;s[19]!==f||s[20]!==m?(p={mutationFn:f,onSuccess:m},s[19]=f,s[20]=m,s[21]=p):p=s[21];const g=Ki(p);let _,v;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},v=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=v):(_=s[26],v=s[27]),S.useEffect(_,v),h.isLoading){let b;return s[28]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[28]=b):b=s[28],b}if(h.isError){const b=h.error;let y;return s[29]!==b?(y={status:"error",error:b},s[29]=b,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let b;return s[31]!==h.data?(b={status:"ready",task:h.data},s[31]=h.data,s[32]=b):b=s[32],b}if(g.isPending||h.isSuccess&&!h.data){let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[33]=b):b=s[33],b}if(g.isError){let b;return s[34]!==g.error?(b={status:"error",error:g.error},s[34]=g.error,s[35]=b):b=s[35],b}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function sx(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Et().min(1,"Required"):Et();return js(e)}function ix(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Bl(t){const e=B.c(65),{prompt:s,setPrompt:i,onSubmit:r}=t,o=S.useId();let a;if(e[0]!==s){const D=s?sx(s):js({});a=Un(D),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?ix(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=qi(u);let f;e[7]!==s?.arguments?(f=s?.arguments??[],e[7]=s?.arguments,e[8]=f):f=e[8];const m=f;let p;e[9]!==h||e[10]!==r||e[11]!==i?(p=async D=>{await r(D),i(null),h.reset()},e[9]=h,e[10]=r,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=D=>{D||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const v=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||oo(s.name,ni(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let b;e[20]!==x?(b=n.jsx(ds,{children:n.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=b):b=e[21];let y;e[22]!==s.description?(y=s.description&&n.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let C;e[24]!==y||e[25]!==b?(C=n.jsxs(hs,{children:[b,y]}),e[24]=y,e[25]=b,e[26]=C):C=e[26];let k;e[27]!==h||e[28]!==g?(k=D=>{D.stopPropagation(),h.handleSubmit(g)(D)},e[27]=h,e[28]=g,e[29]=k):k=e[29];let w;if(e[30]!==m||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let D;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(D=P=>n.jsx(It,{control:h.control,name:P.name,render:O=>{const{field:$}=O;return n.jsxs(Rt,{children:[n.jsxs(os,{className:"text-xs",children:[P.name,P.required?null:n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),n.jsx(Tt,{children:n.jsx(gt,{...$,value:$.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),n.jsx(Dt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=D):D=e[36],w=m.map(D),e[30]=m,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=w}else w=e[33];let V;e[37]!==v?(V=()=>v(!1),e[37]=v,e[38]=V):V=e[38];let j;e[39]!==h.formState.isSubmitting||e[40]!==V?(j=n.jsx(oe,{type:"button",variant:"ghost",onClick:V,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=V,e[41]=j):j=e[41];const R=!h.formState.isValid||h.formState.isSubmitting;let T;e[42]!==h.formState.isSubmitting?(T=h.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(In,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=T):T=e[43];let I;e[44]!==o||e[45]!==R||e[46]!==T?(I=n.jsx(oe,{type:"submit",form:o,disabled:R,children:T}),e[44]=o,e[45]=R,e[46]=T,e[47]=I):I=e[47];let A;e[48]!==j||e[49]!==I?(A=n.jsxs(xl,{children:[j,I]}),e[48]=j,e[49]=I,e[50]=A):A=e[50];let N;e[51]!==o||e[52]!==k||e[53]!==w||e[54]!==A?(N=n.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:k,children:[w,A]}),e[51]=o,e[52]=k,e[53]=w,e[54]=A,e[55]=N):N=e[55];let E;e[56]!==h||e[57]!==N?(E=n.jsx(Bi,{...h,children:N}),e[56]=h,e[57]=N,e[58]=E):E=e[58];let M;e[59]!==C||e[60]!==E?(M=n.jsxs(ts,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,E]}),e[59]=C,e[60]=E,e[61]=M):M=e[61];let L;return e[62]!==v||e[63]!==M?(L=n.jsx(ss,{open:!0,onOpenChange:v,children:M}),e[62]=v,e[63]=M,e[64]=L):L=e[64],L}function nx(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}function rx(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Dc=3,Mu="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",ox="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Pu(t){const e=B.c(46),{item:s,onSelect:i,isLoading:r,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const w=ni(c._meta);d=c.title??oo(c.name,w),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let w;e[4]!==i||e[5]!==c?(w=()=>i(c),e[4]=i,e[5]=c,e[6]=w):w=e[6];const V=o||r,j=r&&"bg-accent/40",R=(o||r)&&"cursor-not-allowed opacity-50";let T;e[7]!==j||e[8]!==R?(T=X(ox,"hover:bg-accent/60 text-foreground",j,R),e[7]=j,e[8]=R,e[9]=T):T=e[9];let I;e[10]!==u?(I=n.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=I):I=e[11];let A;e[12]!==r?(A=r&&n.jsx(In,{size:"xs"}),e[12]=r,e[13]=A):A=e[13];let N;e[14]!==I||e[15]!==A?(N=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[I,A]}),e[14]=I,e[15]=A,e[16]=N):N=e[16];let E;e[17]!==h?(E=h&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=E):E=e[18];let M;return e[19]!==N||e[20]!==E||e[21]!==w||e[22]!==V||e[23]!==T?(M=n.jsxs("button",{type:"button",onClick:w,disabled:V,className:T,children:[N,E]}),e[19]=N,e[20]=E,e[21]=w,e[22]=V,e[23]=T,e[24]=M):M=e[24],M}let f;e[25]!==i||e[26]!==c?(f=()=>i(c),e[25]=i,e[26]=c,e[27]=f):f=e[27];const m=o||r,p=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=X(Mu,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let v;e[31]!==u?(v=n.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=v):v=e[32];let x;e[33]!==r?(x=r&&n.jsx(In,{size:"xs"}),e[33]=r,e[34]=x):x=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==_||e[38]!==v||e[39]!==x?(b=n.jsx(st,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:f,disabled:m,className:_,children:[v,x]})}),e[35]=f,e[36]=m,e[37]=_,e[38]=v,e[39]=x,e[40]=b):b=e[40];const y=h??u;let C;e[41]!==y?(C=n.jsx(it,{side:"top",className:"max-w-xs",children:n.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=C):C=e[42];let k;return e[43]!==b||e[44]!==C?(k=n.jsxs(nt,{delayDuration:400,children:[b,C]}),e[43]=b,e[44]=C,e[45]=k):k=e[45],k}function ax(t){const e=B.c(41),{items:s,open:i,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[l,c]=S.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(V=>{const j=l.toLowerCase();return V.prompt.name.toLowerCase().includes(j)||(V.prompt.title??"").toLowerCase().includes(j)||(V.prompt.description??"").toLowerCase().includes(j)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,f=Ms();let m;e[3]!==h.length||e[4]!==l?(m=h.length===0&&n.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==r||e[10]!==o){let V;e[12]!==d||e[13]!==a?.name||e[14]!==r||e[15]!==o?(V=j=>n.jsx(Pu,{item:j,variant:"card",onSelect:R=>{r(!1),o(R)},isLoading:a?.name===j.prompt.name,isDisabled:d&&a?.name!==j.prompt.name},j.prompt.name),e[12]=d,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=V):V=e[16],p=h.map(V),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=n.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const _=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=V=>{V.key==="Escape"&&c("")},e[20]=v):v=e[20];let x;e[21]!==l?(x=n.jsx(Uh,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=x):x=e[22];const b=x;if(f){let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(co,{className:"sr-only",children:n.jsx(wi,{children:"All prompts"})}),e[23]=V):V=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=j):j=e[24];let R;e[25]!==_||e[26]!==b?(R=n.jsxs(Vi,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[V,j,b,_]}),e[25]=_,e[26]=b,e[27]=R):R=e[27];let T;return e[28]!==r||e[29]!==i||e[30]!==R?(T=n.jsx(Oi,{delayDuration:400,children:n.jsx(Ci,{open:i,onOpenChange:r,children:R})}),e[28]=r,e[29]=i,e[30]=R,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(hs,{className:"sr-only",children:n.jsx(ds,{children:"All prompts"})}),e[32]=y):y=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=C):C=e[33];let k;e[34]!==_||e[35]!==b?(k=n.jsxs(ts,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,C,b,_]}),e[34]=_,e[35]=b,e[36]=k):k=e[36];let w;return e[37]!==r||e[38]!==i||e[39]!==k?(w=n.jsx(Oi,{delayDuration:400,children:n.jsx(ss,{open:i,onOpenChange:r,children:k})}),e[37]=r,e[38]=i,e[39]=k,e[40]=w):w=e[40],w}function lx(t){const e=B.c(29),{items:s,onSelect:i,loadingPrompt:r,className:o}=t,[a,l]=S.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==r||e[2]!==i){const v=s.slice(0,Dc);let x;e[6]!==s?(x=s.slice(Dc),e[6]=s,e[7]=x):x=e[7],c=x,d=!!r;let b;e[8]!==d||e[9]!==r?.name||e[10]!==i?(b=y=>n.jsx(Pu,{item:y,onSelect:i,isLoading:r?.name===y.prompt.name,isDisabled:d&&r?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=r?.name,e[10]=i,e[11]=b):b=e[11],u=v.map(b),e[0]=s,e[1]=r,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let f;e[12]!==o?(f=X("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&n.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:X(Mu,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==f||e[19]!==m?(p=n.jsxs("div",{className:f,children:[h,m]}),e[17]=h,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==i?(g=n.jsx(ax,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=n.jsxs(Oi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function cx(){return null}function dx(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function hx(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:i}=Gi(),{tiptapDocRef:r}=ai(),{org:o}=ye();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Le(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Hh(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let f;e[7]!==h?(f=h.map(ux),e[7]=h,e[8]=f):f=e[8];const m=f;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=S.useReducer(dx,p),[v,x]=S.useState(null);let b;e[10]!==l||e[11]!==i||e[12]!==r?(b=async(N,E)=>{if(!l){fe.error("MCP client not available"),_({type:"RESET"});return}try{const M=await bl(l,N.name,E);_({type:"RESET"});const L=rx(r.current,{type:"paragraph",content:[Up({id:N.name,name:gl(N.name,ni(N._meta)),metadata:M.messages,char:"/"})]});await i(L)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),fe.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=r,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async N=>{if(N.arguments&&N.arguments.length>0){_({type:"SELECT_PROMPT",prompt:N}),x(N);return}_({type:"START_LOADING",prompt:N}),await y(N)},e[14]=y,e[15]=C):C=e[15];const k=C;let w;e[16]!==v||e[17]!==y?(w=async N=>{v&&(_({type:"START_LOADING",prompt:v,arguments:N}),x(null),await y(v,N))},e[16]=v,e[17]=y,e[18]=w):w=e[18];const V=w;if(m.length===0)return null;const j=g.stage==="loading"?g.prompt:null;let R;e[19]!==k||e[20]!==m||e[21]!==j?(R=n.jsx(lx,{items:m,onSelect:k,loadingPrompt:j}),e[19]=k,e[20]=m,e[21]=j,e[22]=R):R=e[22];let T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{x(null),_({type:"RESET"})},e[23]=T):T=e[23];let I;e[24]!==v||e[25]!==V?(I=n.jsx(Bl,{prompt:v,setPrompt:T,onSubmit:V}),e[24]=v,e[25]=V,e[26]=I):I=e[26];let A;return e[27]!==R||e[28]!==I?(A=n.jsxs(n.Fragment,{children:[R,I]}),e[27]=R,e[28]=I,e[29]=A):A=e[29],A}function ux(t){return{prompt:t}}function fx(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:i}=ai(),{org:r}=ye();let o;e[0]!==r.id?(o=ho(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=X("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(cx,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=n.jsx(hx,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let f;e[7]!==d||e[8]!==h?(f=n.jsx(Ns,{fallback:null,children:n.jsx(S.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=n.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}function Lu(t){const e=B.c(21),{current:s,total:i,onPrev:r,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=X("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(kl,{size:14}),e[2]=d):d=e[2];let u;e[3]!==r||e[4]!==a||e[5]!==c?(u=n.jsx("button",{type:"button",onClick:r,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let f;e[7]!==h||e[8]!==i?(f=n.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=f):f=e[9];const m=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=X("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(uo,{size:14}),e[12]=_):_=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=n.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let x;return e[17]!==v||e[18]!==u||e[19]!==f?(x=n.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,f,v]}),e[17]=v,e[18]=u,e[19]=f,e[20]=x):x=e[20],x}function Wr(t){const e=B.c(18),{title:s,children:i,footerLeft:r,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=X("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=n.jsx("div",{className:"flex items-center gap-2 p-4",children:n.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=n.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==r?(h=n.jsx("div",{children:r}),e[6]=r,e[7]=h):h=e[7];let f;e[8]!==o?(f=n.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==h||e[11]!==f?(m=n.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:n.jsxs("div",{className:"flex items-center justify-between",children:[h,f]})}),e[10]=h,e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==m?(p=n.jsxs("div",{className:c,children:[d,u,m]}),e[13]=c,e[14]=d,e[15]=u,e[16]=m,e[17]=p):p=e[17],p}const mx="User denied this tool call, give other alternatives.",px=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function gx(t){const e=B.c(9),{onYolo:s}=t,[i,r]=yi();let o;e[0]!==s||e[1]!==i||e[2]!==r?(o=u=>{const h=u;r({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=r,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ti,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:xx,children:n.jsx(si,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Zs,{children:px.map(_x)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=n.jsxs(ei,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function _x(t){return n.jsx(Ht,{value:t.value,children:t.label},t.value)}function xx(t){return t.stopPropagation()}function vx(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let i;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],i=o}catch{i=String(s)}let r;return e[3]!==i?(r=n.jsx("div",{className:"px-4",children:n.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[3]=i,e[4]=r):r=e[4],r}function bx(t){const e=B.c(42),{approvals:s,onRespond:i}=t,[r,o]=S.useState(0),a=Math.min(r,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,mx)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let f;e[6]!==s||e[7]!==i?(f=()=>{for(const A of s)i(A.approvalId,!0)},e[6]=s,e[7]=i,e[8]=f):f=e[8];const m=f;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const v=_;let x;e[14]!==m?(x=n.jsx(gx,{onYolo:m}),e[14]=m,e[15]=x):x=e[15];let b;e[16]!==s.length||e[17]!==v||e[18]!==g||e[19]!==a?(b=n.jsx(Lu,{current:a,total:s.length,onPrev:g,onNext:v}),e[16]=s.length,e[17]=v,e[18]=g,e[19]=a,e[20]=b):b=e[20];let y;e[21]!==x||e[22]!==b?(y=n.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23];const C=y;let k;e[24]!==d?(k=n.jsx(oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:d,children:"Deny"}),e[24]=d,e[25]=k):k=e[25];let w;e[26]!==s.length||e[27]!==m?(w=s.length>1&&n.jsx(oe,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:m,children:"Accept All"}),e[26]=s.length,e[27]=m,e[28]=w):w=e[28];let V;e[29]!==h?(V=n.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=V):V=e[30];let j;e[31]!==w||e[32]!==V||e[33]!==k?(j=n.jsxs(n.Fragment,{children:[k,w,V]}),e[31]=w,e[32]=V,e[33]=k,e[34]=j):j=e[34];const R=j;let T;e[35]!==l.input?(T=n.jsx(vx,{input:l.input}),e[35]=l.input,e[36]=T):T=e[36];let I;return e[37]!==l.friendlyName||e[38]!==C||e[39]!==R||e[40]!==T?(I=n.jsx(Wr,{title:l.friendlyName,footerLeft:C,footerRight:R,children:T}),e[37]=l.friendlyName,e[38]=C,e[39]=R,e[40]=T,e[41]=I):I=e[41],I}function yx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(wg,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function Sx(t){const e=B.c(4),{approvals:s,isStreaming:i,onRespond:r}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(yx,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==r?(o=n.jsx(bx,{approvals:s,onRespond:r}),e[1]=s,e[2]=r,e[3]=o):o=e[3],o}function wx(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const i="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:i,friendlyName:Hp(Wp(i)),input:s.input})}return e}function Vx(t){const e=B.c(15),{plan:s,onApprove:i,onDismiss:r}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==r?(l=n.jsx(oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let c;e[5]!==a?(c=n.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=n.jsxs(n.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=n.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:n.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:n.jsx(Kp,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let f;return e[12]!==u||e[13]!==h?(f=n.jsx(Wr,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=f):f=e[14],f}function Cx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Jt,{className:"size-5 text-purple-500 shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function kx(t){const e=B.c(7),{plans:s,isStreaming:i,onApprove:r,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Cx,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==r||e[5]!==o?(c=n.jsx(Vx,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function jx(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const i=s.input;e.push({toolCallId:s.toolCallId,plan:i.plan,state:s.state})}return e}const Mc=js({response:Et().min(1,"Response is required")}),Nx=js({response:Et().min(1,"Please select or enter an option")}),Ax=js({response:Zm(["yes","no"])});function Ex(t){switch(t.type){case"text":return Mc;case"choice":return Nx;case"confirm":return Ax;default:return Mc}}function Ix(t){const e={};for(const s of t)e[s.toolCallId]=Ex(s.input);return js(e)}function Rx(t){const e=B.c(6),{control:s,name:i,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:c}=l;return n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsx("div",{className:"px-2",children:n.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(Xh,{size:16,className:"text-muted-foreground"})}),n.jsx("input",{...c,type:"text",placeholder:r||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),n.jsx(Dt,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=n.jsx(It,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Ou(t,e){const s=B.c(4);let i,r;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=r):(i=s[2],r=s[3]),S.useEffect(i,r)}function Tx(t){const e=B.c(9),{control:s,name:i,options:r}=t,[o,a]=S.useState(!1),l=S.useRef(null),c=S.useRef(null);let d;if(e[0]!==r?(d=f=>{c.current?.onChange(r[f]??""),a(!1)},e[0]=r,e[1]=d):d=e[1],Ou(r.length,d),r.length===0)return null;let u;e[2]!==o||e[3]!==r?(u=f=>{const{field:m}=f;c.current=m;const p=o||!!m.value&&!r.includes(m.value);return n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[r.map((g,_)=>{const v=m.value===g;return n.jsxs("button",{type:"button",onClick:()=>{m.onChange(g??""),a(!1)},className:X("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",v&&"bg-accent/50",!v&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[n.jsx("span",{className:X("flex items-center justify-center size-6 rounded-md text-sm shrink-0",v?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),n.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),n.jsxs("div",{className:X("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),r.includes(m.value)&&m.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(Xh,{size:16,className:"text-muted-foreground"})}),p?n.jsx("input",{ref:l,type:"text",value:m.value,onChange:g=>m.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):n.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),n.jsx(Dt,{})]})},e[2]=o,e[3]=r,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=n.jsx(It,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function Dx(t){const e=B.c(6),{control:s,name:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=S.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],Ou(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=h.value===f;return n.jsxs("button",{type:"button",onClick:()=>h.onChange(f),className:X("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[n.jsx("span",{className:X("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),n.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),n.jsx(Dt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=n.jsx(It,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Pc(t){const e=B.c(13),{input:s,control:i,name:r}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==r?(o=n.jsx(Rx,{control:i,name:r,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=r,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==i||e[7]!==r||e[8]!==a?(l=n.jsx(Tx,{control:i,name:r,options:a}),e[6]=i,e[7]=r,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==r?(o=n.jsx(Dx,{control:i,name:r}),e[10]=i,e[11]=r,e[12]=o):o=e[12],o}default:return null}}function Mx({parts:t,onSubmit:e}){const[s,i]=S.useState(t[0]?.toolCallId??""),r=Ix(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=qi({resolver:Un(r),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const b of t){const y=x[b.toolCallId]?.response;y&&e(b,y)}},h=x=>t.find(b=>!x[b.toolCallId]?.response&&b.toolCallId!==s)??null,f=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},m=()=>{o.setValue(`${s}.response`,"user has skip this question"),f()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=n.jsxs(n.Fragment,{children:[n.jsx(oe,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7",children:"Skip"}),n.jsx(oe,{type:"button",size:"sm",disabled:!c,onClick:f,className:X("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),v=n.jsx(Lu,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?n.jsx(Bi,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:n.jsx(Wr,{title:x.input?.prompt??"Question",footerRight:_,children:n.jsx(Pc,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return n.jsx(Bi,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:n.jsx(Wh,{value:s,onValueChange:i,children:t.map(x=>n.jsx(Cr,{value:x.toolCallId,className:"mt-0",children:n.jsx(Wr,{title:x.input?.prompt??"Question",footerLeft:v,footerRight:_,children:n.jsx(Pc,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function Px(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Kg,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Bu(t){const e=B.c(6),{userAskParts:s,isStreaming:i,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(Lx),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Px,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==r||e[4]!==a?(l=n.jsx(Mx,{parts:a,onSubmit:r}),e[3]=r,e[4]=a,e[5]=l):l=e[5],l}function Lx(t){return t.state==="input-available"}const Lc=new Map;function _o(){const{org:t}=ye(),e=Le({connectionId:Pt,orgId:t.id}),s=Nl(),i=s.find(_=>_.providerId==="deco"),{data:r,isLoading:o,refetch:a,isFetching:l}=Wi({queryKey:ct.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=r?.balanceCents??null,d=c!=null?c/100:null,u=S.useRef(new Map);if(c!=null){const _=Lc.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&ie("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Lc.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,f=c!=null&&c>0,m=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:f,isZeroBalance:m,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function Ox(t){return t?t.message.startsWith("[CREDITS]"):!1}const Bx={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},zx=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function zu(t){const e=B.c(43),{onDismiss:s}=t,{org:i}=ye(),r=qe(),{decoKeyId:o}=_o();let a;e[0]!==i.id?(a={connectionId:Pt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Le(a),[c,d]=S.useState(""),[u,h]=S.useState(!1),[f,m]=S.useState("usd"),p=f==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{ie("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),S.useEffect(g,_);let v;e[5]!==l||e[6]!==f?(v=async D=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:D,currency:f}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=f,e[7]=v):v=e[7];let x;e[8]!==s?(x=D=>{D&&window.open(D,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let b;e[10]!==v||e[11]!==x?(b={mutationFn:v,onSuccess:x,onError:Ux},e[10]=v,e[11]=x,e[12]=b):b=e[12];const{mutate:y,isPending:C}=Ki(b),k=parseFloat(c),w=!isNaN(k)&&k>=1;let V;e[13]!==s?(V=D=>!D&&s?.(),e[13]=s,e[14]=V):V=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[15]=j):j=e[15];let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=R):R=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[R,n.jsxs(hs,{className:"relative gap-4",children:[n.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),n.jsxs("div",{children:[n.jsx(ds,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),n.jsx(lo,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[17]=T):T=e[17];let I;e[18]!==f||e[19]!==p||e[20]!==c||e[21]!==k||e[22]!==o||e[23]!==w||e[24]!==C||e[25]!==u||e[26]!==y?(I=o&&n.jsxs("div",{className:"px-8 pt-5 pb-6",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(hu,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:D=>{D&&m(D)},children:[n.jsx($r,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx($r,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsxs("div",{className:"rounded-xl border border-border p-5",children:[n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Bx[f].map(D=>{const{dollars:P,label:O}=D;return n.jsxs("button",{type:"button",disabled:C,onClick:()=>{ie("credits_topup_clicked",{amount_cents:P*100,currency:f,tier_label:O,source:"exhausted_banner"}),y(P*100)},className:X("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},P)})}),u?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),n.jsx(gt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:D=>d(D.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(oe,{className:"h-10",disabled:!w||C,onClick:()=>{ie("credits_topup_clicked",{amount_cents:Math.round(k*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(k*100))},children:C?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),n.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:zx.map($x)})]}),e[18]=f,e[19]=p,e[20]=c,e[21]=k,e[22]=o,e[23]=w,e[24]=C,e[25]=u,e[26]=y,e[27]=I):I=e[27];let A;e[28]!==s?(A=n.jsx(oe,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=A):A=e[29];let N;e[30]!==r||e[31]!==s||e[32]!==i.slug?(N=n.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=r,e[31]=s,e[32]=i.slug,e[33]=N):N=e[33];let E;e[34]!==A||e[35]!==N?(E=n.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[A,N]}),e[34]=A,e[35]=N,e[36]=E):E=e[36];let M;e[37]!==I||e[38]!==E?(M=n.jsxs(ts,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Fx,children:[T,I,E]}),e[37]=I,e[38]=E,e[39]=M):M=e[39];let L;return e[40]!==M||e[41]!==V?(L=n.jsx(ss,{open:!0,onOpenChange:V,children:M}),e[40]=M,e[41]=V,e[42]=L):L=e[42],L}function $x(t){return n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:n.jsx(Jt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),n.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Fx(t){return t.preventDefault()}function Ux(t){fe.error(`Top-up failed: ${t.message}`)}const Hx={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function Kr(t){const e=B.c(32),{variant:s,onDismiss:i}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?t.error.message:Hx[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=r?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=r?"text-destructive":"text-amber-600 dark:text-amber-500",d=r?oi:fl;let u;e[0]!==l?(u=X("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=X("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==d?(f=n.jsx(d,{size:16}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==f?(m=n.jsx("div",{className:h,children:f}),e[6]=h,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==c?(p=X("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=n.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=n.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let v;e[16]!==r||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(v=n.jsx("div",{className:"flex gap-2",children:r?n.jsxs(n.Fragment,{children:[n.jsx(oe,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),n.jsx(oe,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):n.jsx(oe,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=r,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=v):v=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==v?(x=n.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,v]}),e[20]=g,e[21]=_,e[22]=v,e[23]=x):x=e[23];let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Js,{size:14}),e[24]=b):b=e[24];let y;e[25]!==i?(y=n.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:b}),e[25]=i,e[26]=y):y=e[26];let C;return e[27]!==u||e[28]!==y||e[29]!==m||e[30]!==x?(C=n.jsx("div",{className:"px-0.5",children:n.jsxs("div",{className:u,children:[m,x,y]})}),e[27]=u,e[28]=y,e[29]=m,e[30]=x,e[31]=C):C=e[31],C}function xo(){const t=B.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:r,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Gi(),[h,f]=yi(),{virtualMcpId:m,createTaskWithMessage:p}=es();let g,_,v,x;if(t[0]!==o){const E=o.at(-1);x=E?.role==="assistant"?E.parts.filter(qx):null,g=x?.filter(Kx)?.length,_=E?.role==="assistant"?jx(E.parts):[],v=E?.role==="assistant"?wx(E.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=v,t[4]=x}else g=t[1],_=t[2],v=t[3],x=t[4];const b=v;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const M={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(M)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const C=y;let k;t[8]!==u?(k=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=k):k=t[9];const w=k;let V;t[10]!==c?(V=(E,M)=>{c({tool:"user_ask",toolCallId:E.toolCallId,output:{response:M}})},t[10]=c,t[11]=V):V=t[11];const j=V;let R;t[12]!==p||t[13]!==h||t[14]!==f||t[15]!==m?(R=E=>{f({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:m,message:{parts:[{type:"text",text:`Implement this plan:
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-CWfRTdtF.js","assets/index-DkLXfxeF.js","assets/index-C_Ncklfg.css","assets/task-status-CmmBYEnr.js","assets/agent-icon-OPgA0_xh.js","assets/AlertCircle-7JjFgLc7.js","assets/Tool01-CPwXEQb5.js","assets/SearchMd-DiHiiShh.js","assets/ArrowNarrowLeft-Dede_Ne2.js","assets/XCircle-C0Pb9VbS.js","assets/ZapSquare-DBz9qdVm.js","assets/Users03-1bfUrVZT.js","assets/CheckCircle-CTW72EON.js","assets/ChevronDown-kxc5hHzL.js","assets/ChevronRight-DDbSh6n1.js","assets/ChevronUp-Dp8gBsiQ.js","assets/Container-DbPEBCPd.js","assets/Star01-DOZUyUGI.js","assets/Palette-9DjyOnf4.js","assets/index-DvGOE4TR.js","assets/use-mobile-D7gj1mMa.js","assets/X-CyqBZIBt.js","assets/LinkExternal01-DGpodMuQ.js","assets/Lock01-DWeyLAgC.js","assets/Sun-D9NMWxb1.js","assets/Play-CGVWyYId.js","assets/Plus-BZ8TfrO6.js","assets/Settings02-BrMLRmyq.js","assets/Trash01-JJPVWHIh.js","assets/Upload01-CAASdeK2.js","assets/User01-DzewYYcp.js","assets/Zap-WS6KKy8N.js","assets/scroll-area-hAa33XcH.js","assets/select-DRB8tE_p.js","assets/use-copy-BkRNxEwn.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-CDZoEVTf.js","assets/content-blocks-o63cs2vh.js","assets/types-DvTqSron.js","assets/constants-DfNucTio.js","assets/chat-context-OvrSchhz.js","assets/use-virtual-mcp-B0nMlTA1.js","assets/use-collections-Dv9KwC2D.js","assets/use-ai-providers-ClS89y7X.js","assets/use-decopilot-events-BwyevFSM.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-DqpLygvk.js","assets/use-organization-settings-CcY3Vn-c.js","assets/shell-layout-DAhaxub0.js","assets/required-auth-layout-CXhuopzx.js","assets/use-org-sso-BIx4Rk_Y.js","assets/integration-icon-DUduEF01.js","assets/use-mcp-tools-B1TR0GK5.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as Mt,r as S,p as Jm,q as Qm,e as B,s as ye,K as ct,n as Wi,a as Ki,v as js,w as Un,x as qi,j as n,B as oe,y as Et,c as X,E as Ns,z as fe,C as yi,_ as Zm,t as ie,f as qe,D as fl,F as ep,R as Ih,G as tp,H as Vs,I as Ao,J as ms,L as sp,M as Eo,P as ip,Q as np,T as rp,U as op,V as Rh,W as ap,X as lp,Y as cp,Z as dp,$ as pc,l as De,b as St,u as hp,a0 as bn,a1 as wr,a2 as ml,a3 as pl,g as Hn,a4 as Th,d as Si,a5 as up,a6 as fp,a7 as mp,a8 as pp,a9 as Dh,aa as Mh,ab as gp,ac as _p,ad as xp,ae as Ut,af as vp,ag as bp,ah as yp,ai as Sp,aj as sn,ak as wp,al as Vp,am as Cp,an as kp,ao as Ph,ap as jp,aq as Np,ar as Ap,as as Ep,at as Ip,au as Rp,av as Tp,aw as Dp,ax as Mp,ay as Pp,az as Lh,aA as Vr,aB as Lp,aC as Ri,aD as cr,aE as Oh,aF as Op,aG as Bp}from"./index-DkLXfxeF.js";import{u as ai,a as Gi,b as es,A as zp,C as $p,t as Bh,c as ha,d as Fp,e as ro,f as gc}from"./chat-context-OvrSchhz.js";import{d as oo,g as ni,c as Up,s as gl,t as Hp,a as Wp,M as Kp,i as qp,b as En,e as Gp,F as Yp,f as zh,S as Xp,u as Jp,h as _c,j as Qp,k as Zp,l as ua,r as eg,m as tg,p as $h,n as sg,o as ig,q as _l,G as ng,L as rg,v as og,w as ag,x as lg,y as cg}from"./task-status-CmmBYEnr.js";import{S as In,u as ao,P as fa,a as dg,b as hg,c as ug,E as fg,i as mg,d as pg,e as Fh}from"./scroll-area-hAa33XcH.js";import{T as Oi,u as Ms,a as st,b as it,c as nt}from"./use-mobile-D7gj1mMa.js";import{D as ds,a as hs,b as xl,c as ts,d as ss,e as lo}from"./dialog-CDZoEVTf.js";import{D as co,a as wi,b as Vi,c as Ci,d as gg,e as _g,f as xg}from"./drawer-BtA5XqsS.js";import{C as Uh}from"./collection-search-DOj_zhXC.js";import{S as Pt,u as Le,g as ho,i as Br,c as vg,W as zs,a as bg,b as vl}from"./constants-DfNucTio.js";import{u as Hh,g as bl,T as Wh,a as Cr,l as zr,b as Io,c as yg}from"./tabs-BByMWKiD.js";import{F as Bi,a as It,b as Rt,c as os,d as Tt,e as Dt,f as Sg}from"./form-nehB0yqt.js";import{I as gt}from"./input-Dxp3-aWz.js";import{i as Kh,u as Wn,r as qh}from"./shell-layout-DAhaxub0.js";import{D as at,a as kr,b as jr,c as As,d as Es,e as Is,f as Gh,g as Yh,h as xc}from"./dropdown-menu-DU8JG2pk.js";import{t as wg,i as Xh,n as Jh,A as gs,a as Qh,b as yl,s as ri,c as Vg,d as Cg,e as Zh,f as eu,g as kg,h as Sl,j as yn,k as jg,l as wl,m as Ng,o as Ag,p as Kn,q as qn,r as Eg,u as vc,v as bc,w as Ig,x as Rg,y as yc,z as Tg,B as Vl,C as tu,D as ma,E as Ro,F as Sc,G as Dg,H as Mg,I as Pg,J as Lg,K as su,L as iu,M as nu,N as ru,O as wc,P as Og,Q as Sn,R as Bg,S as zg,T as $g,U as ou}from"./agent-icon-OPgA0_xh.js";import{n as au,a as pa,i as Fg,b as Ug,c as Hg}from"./ZapSquare-DBz9qdVm.js";import{i as Jt,t as Rn}from"./ChevronDown-kxc5hHzL.js";import{s as Pi}from"./Star01-DOZUyUGI.js";import{a as ga,t as Cl}from"./Tool01-CPwXEQb5.js";import{i as lu}from"./Lock01-DWeyLAgC.js";import{s as Qt}from"./Plus-BZ8TfrO6.js";import{i as cu}from"./Upload01-CAASdeK2.js";import{i as Js}from"./X-CyqBZIBt.js";import{i as oi}from"./AlertCircle-7JjFgLc7.js";import{S as Zs,a as ei,b as Ht,c as ti,d as si}from"./select-DRB8tE_p.js";import{i as kl,a as jl,b as Wg}from"./SearchMd-DiHiiShh.js";import{i as uo,t as Kg,a as qg,b as Gg,c as Yg,d as Xg,e as zi,f as du}from"./XCircle-C0Pb9VbS.js";import{T as hu,a as $r}from"./toggle-group-CZBEspMS.js";import{u as Nl,a as uu}from"./use-ai-providers-ClS89y7X.js";import{m as fo,g as Jg,i as Qg,a as fu,M as mu,N as Zg}from"./select-model-CP81c55I.js";import{S as e_,A as t_,a as s_,b as i_,c as n_,R as pu,d as r_,e as o_}from"./accordion-iHKIJir4.js";import{r as gu,l as wn,u as a_,g as l_}from"./types-DvTqSron.js";import{u as mo,a as is,b as Al}from"./use-virtual-mcp-B0nMlTA1.js";import{u as Gn,a as po,b as El}from"./use-connection-BmcG6E0P.js";import{p as c_,q as Vc}from"./question-004-sINsf4GQ.js";import{g as Cc}from"./ai-providers-logos-CS4PCiqI.js";import{g as _u,s as xu}from"./connection-slug-eyAPH6o3.js";import{u as vu,a as bu,g as d_,C as To}from"./connection-card-x5-U4xYO.js";import{C as yu}from"./collection-tabs-DrO0tDqW.js";import{g as Su}from"./constants-BTGWOBGG.js";import{T as _a}from"./textarea-DHlYLEvo.js";import{n as Nr}from"./Container-DbPEBCPd.js";import{c as h_,i as dr,a as kc,E as u_,p as f_,b as m_,d as p_}from"./connection-form-helpers-Cieg3At7.js";import{u as jc}from"./use-infinite-scroll-C0yn-Y6f.js";import{u as g_,C as __,a as Nc,b as Ac,c as x_,d as v_,e as b_,f as y_}from"./command-CGYZopFY.js";import{g as S_,e as w_,a as V_}from"./extract-connection-data-DBjTfzuX.js";import{B as Ec}from"./badge-Csg5fgRc.js";import{i as Il}from"./ChevronRight-DDbSh6n1.js";import{I as Ps}from"./integration-icon-DUduEF01.js";import{S as $i}from"./skeleton-3sAmljB_.js";import{a as go}from"./Users03-1bfUrVZT.js";import{G as wu,u as C_,a as Fr,I as Ur,S as Vu,L as k_,b as j_}from"./lean-canvas-recruit-modal-N8EVMVv5.js";import{u as Yn,a as Cu}from"./use-navigate-to-agent-BOFYFzjJ.js";import{S as Hr}from"./switch-DL640Ue6.js";import{u as ku}from"./use-create-virtual-mcp-CH8VJize.js";import{i as N_}from"./CheckCircle-CTW72EON.js";import{P as li,a as ci,b as di}from"./popover-_s_tQK3Z.js";import{u as ki,a as A_}from"./use-mcp-tools-B1TR0GK5.js";import{E as Fi}from"./empty-state-B2WkME-3.js";import{u as E_}from"./use-decopilot-events-BwyevFSM.js";import{i as Ui}from"./Zap-WS6KKy8N.js";import{i as ju,S as Xn,a as Jn,b as vs,u as Qn,c as _s,d as Zt,e as Nu,f as Au,g as I_,h as Eu,j as Iu,P as ps,k as R_,l as T_,m as D_,n as M_,o as P_,p as L_}from"./index-DvGOE4TR.js";import{A as Ic}from"./avatar-BAGLgwIy.js";import{n as O_,a as B_,i as z_}from"./Sun-D9NMWxb1.js";import{a as Zn}from"./Settings02-BrMLRmyq.js";import{A as Rl,a as Tl,b as Dl,c as Ml,d as Pl,e as Ll,f as Ol,g as Ru}from"./alert-dialog-CvUq9c2l.js";import"./index-CFqkoEQr.js";import{u as Tu}from"./use-tasks-DqpLygvk.js";import{u as $_}from"./use-status-sounds-Cq0X5c0g.js";import{T as F_,u as Du}from"./tools-list-DuX1kehi.js";import{u as Do}from"./unwrap-tool-result-BYXdCQMg.js";import{C as U_,a as Rc}from"./card-bx_QeXw_.js";import{L as Vn}from"./label-BVoDYtUr.js";import{i as Ar}from"./Play-CGVWyYId.js";import{s as xa}from"./Trash01-JJPVWHIh.js";import{C as H_}from"./checkbox-C7KSBfZr.js";import{n as ji}from"./LinkExternal01-DGpodMuQ.js";import{V as W_}from"./view-mode-toggle-DSiIUGAP.js";import{U as K_}from"./user-B-lqJM9i.js";import{u as er,a as q_,b as G_,c as Y_,A as X_,d as J_}from"./automation-list-row-srgvCKZh.js";import{S as Q_}from"./search-input-C61ZvpPR.js";import"./use-collections-Dv9KwC2D.js";import"./use-organization-settings-CcY3Vn-c.js";import"./use-copy-BkRNxEwn.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./required-auth-layout-CXhuopzx.js";import"./use-org-sso-BIx4Rk_Y.js";import"./ArrowNarrowLeft-Dede_Ne2.js";import"./ChevronUp-Dp8gBsiQ.js";import"./Palette-9DjyOnf4.js";import"./User01-DzewYYcp.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-G41Zams2.js";import"./useInfiniteQuery-D-Fu49PN.js";import"./infiniteQueryObserver-VUPo5ONC.js";import"./collections-DRefuj7X.js";import"./index-nsskrYaZ.js";import"./create-sse-subscription-CxkOgzKf.js";function Z_(t,e){const s=Mt(e);return ex({filters:{...t,status:"pending"}},s).length}function Tc(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function ex(t={},e){const s=Mt(e).getMutationCache(),i=S.useRef(t),r=S.useRef(null);return r.current===null&&(r.current=Tc(s,t)),S.useEffect(()=>{i.current=t}),S.useSyncExternalStore(S.useCallback(o=>s.subscribe(()=>{const a=Jm(r.current,Tc(s,i.current));r.current!==a&&(r.current=a,Qm.schedule(o))}),[s]),()=>r.current,()=>r.current)}function tx(t,e){const s=B.c(37),{org:i,locator:r}=ye();let o;s[0]!==i.id?(o={connectionId:Pt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Le(o),l=Mt();let c;s[2]!==t||s[3]!==i.id?(c=ct.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=Wi(u);let f;s[11]!==a||s[12]!==e?(f=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const k=y.content,w=Array.isArray(k)&&k[0]&&typeof k[0]=="object"?k[0].text??"Create failed":"Create failed";throw new Error(w)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=f):f=s[13];let m;s[14]!==r||s[15]!==i.id||s[16]!==h||s[17]!==l?(m=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:ct.tasksPrefix(r)}),h.refetch()},s[14]=r,s[15]=i.id,s[16]=h,s[17]=l,s[18]=m):m=s[18];let p;s[19]!==f||s[20]!==m?(p={mutationFn:f,onSuccess:m},s[19]=f,s[20]=m,s[21]=p):p=s[21];const g=Ki(p);let _,v;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},v=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=v):(_=s[26],v=s[27]),S.useEffect(_,v),h.isLoading){let b;return s[28]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[28]=b):b=s[28],b}if(h.isError){const b=h.error;let y;return s[29]!==b?(y={status:"error",error:b},s[29]=b,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let b;return s[31]!==h.data?(b={status:"ready",task:h.data},s[31]=h.data,s[32]=b):b=s[32],b}if(g.isPending||h.isSuccess&&!h.data){let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[33]=b):b=s[33],b}if(g.isError){let b;return s[34]!==g.error?(b={status:"error",error:g.error},s[34]=g.error,s[35]=b):b=s[35],b}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function sx(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Et().min(1,"Required"):Et();return js(e)}function ix(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Bl(t){const e=B.c(65),{prompt:s,setPrompt:i,onSubmit:r}=t,o=S.useId();let a;if(e[0]!==s){const D=s?sx(s):js({});a=Un(D),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?ix(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=qi(u);let f;e[7]!==s?.arguments?(f=s?.arguments??[],e[7]=s?.arguments,e[8]=f):f=e[8];const m=f;let p;e[9]!==h||e[10]!==r||e[11]!==i?(p=async D=>{await r(D),i(null),h.reset()},e[9]=h,e[10]=r,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=D=>{D||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const v=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||oo(s.name,ni(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let b;e[20]!==x?(b=n.jsx(ds,{children:n.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=b):b=e[21];let y;e[22]!==s.description?(y=s.description&&n.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let C;e[24]!==y||e[25]!==b?(C=n.jsxs(hs,{children:[b,y]}),e[24]=y,e[25]=b,e[26]=C):C=e[26];let k;e[27]!==h||e[28]!==g?(k=D=>{D.stopPropagation(),h.handleSubmit(g)(D)},e[27]=h,e[28]=g,e[29]=k):k=e[29];let w;if(e[30]!==m||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let D;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(D=P=>n.jsx(It,{control:h.control,name:P.name,render:O=>{const{field:$}=O;return n.jsxs(Rt,{children:[n.jsxs(os,{className:"text-xs",children:[P.name,P.required?null:n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),n.jsx(Tt,{children:n.jsx(gt,{...$,value:$.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),n.jsx(Dt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=D):D=e[36],w=m.map(D),e[30]=m,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=w}else w=e[33];let V;e[37]!==v?(V=()=>v(!1),e[37]=v,e[38]=V):V=e[38];let j;e[39]!==h.formState.isSubmitting||e[40]!==V?(j=n.jsx(oe,{type:"button",variant:"ghost",onClick:V,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=V,e[41]=j):j=e[41];const R=!h.formState.isValid||h.formState.isSubmitting;let T;e[42]!==h.formState.isSubmitting?(T=h.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(In,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=T):T=e[43];let I;e[44]!==o||e[45]!==R||e[46]!==T?(I=n.jsx(oe,{type:"submit",form:o,disabled:R,children:T}),e[44]=o,e[45]=R,e[46]=T,e[47]=I):I=e[47];let A;e[48]!==j||e[49]!==I?(A=n.jsxs(xl,{children:[j,I]}),e[48]=j,e[49]=I,e[50]=A):A=e[50];let N;e[51]!==o||e[52]!==k||e[53]!==w||e[54]!==A?(N=n.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:k,children:[w,A]}),e[51]=o,e[52]=k,e[53]=w,e[54]=A,e[55]=N):N=e[55];let E;e[56]!==h||e[57]!==N?(E=n.jsx(Bi,{...h,children:N}),e[56]=h,e[57]=N,e[58]=E):E=e[58];let M;e[59]!==C||e[60]!==E?(M=n.jsxs(ts,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,E]}),e[59]=C,e[60]=E,e[61]=M):M=e[61];let L;return e[62]!==v||e[63]!==M?(L=n.jsx(ss,{open:!0,onOpenChange:v,children:M}),e[62]=v,e[63]=M,e[64]=L):L=e[64],L}function nx(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}function rx(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Dc=3,Mu="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",ox="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Pu(t){const e=B.c(46),{item:s,onSelect:i,isLoading:r,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const w=ni(c._meta);d=c.title??oo(c.name,w),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let w;e[4]!==i||e[5]!==c?(w=()=>i(c),e[4]=i,e[5]=c,e[6]=w):w=e[6];const V=o||r,j=r&&"bg-accent/40",R=(o||r)&&"cursor-not-allowed opacity-50";let T;e[7]!==j||e[8]!==R?(T=X(ox,"hover:bg-accent/60 text-foreground",j,R),e[7]=j,e[8]=R,e[9]=T):T=e[9];let I;e[10]!==u?(I=n.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=I):I=e[11];let A;e[12]!==r?(A=r&&n.jsx(In,{size:"xs"}),e[12]=r,e[13]=A):A=e[13];let N;e[14]!==I||e[15]!==A?(N=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[I,A]}),e[14]=I,e[15]=A,e[16]=N):N=e[16];let E;e[17]!==h?(E=h&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=E):E=e[18];let M;return e[19]!==N||e[20]!==E||e[21]!==w||e[22]!==V||e[23]!==T?(M=n.jsxs("button",{type:"button",onClick:w,disabled:V,className:T,children:[N,E]}),e[19]=N,e[20]=E,e[21]=w,e[22]=V,e[23]=T,e[24]=M):M=e[24],M}let f;e[25]!==i||e[26]!==c?(f=()=>i(c),e[25]=i,e[26]=c,e[27]=f):f=e[27];const m=o||r,p=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=X(Mu,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let v;e[31]!==u?(v=n.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=v):v=e[32];let x;e[33]!==r?(x=r&&n.jsx(In,{size:"xs"}),e[33]=r,e[34]=x):x=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==_||e[38]!==v||e[39]!==x?(b=n.jsx(st,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:f,disabled:m,className:_,children:[v,x]})}),e[35]=f,e[36]=m,e[37]=_,e[38]=v,e[39]=x,e[40]=b):b=e[40];const y=h??u;let C;e[41]!==y?(C=n.jsx(it,{side:"top",className:"max-w-xs",children:n.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=C):C=e[42];let k;return e[43]!==b||e[44]!==C?(k=n.jsxs(nt,{delayDuration:400,children:[b,C]}),e[43]=b,e[44]=C,e[45]=k):k=e[45],k}function ax(t){const e=B.c(41),{items:s,open:i,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[l,c]=S.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(V=>{const j=l.toLowerCase();return V.prompt.name.toLowerCase().includes(j)||(V.prompt.title??"").toLowerCase().includes(j)||(V.prompt.description??"").toLowerCase().includes(j)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,f=Ms();let m;e[3]!==h.length||e[4]!==l?(m=h.length===0&&n.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==r||e[10]!==o){let V;e[12]!==d||e[13]!==a?.name||e[14]!==r||e[15]!==o?(V=j=>n.jsx(Pu,{item:j,variant:"card",onSelect:R=>{r(!1),o(R)},isLoading:a?.name===j.prompt.name,isDisabled:d&&a?.name!==j.prompt.name},j.prompt.name),e[12]=d,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=V):V=e[16],p=h.map(V),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=n.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const _=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=V=>{V.key==="Escape"&&c("")},e[20]=v):v=e[20];let x;e[21]!==l?(x=n.jsx(Uh,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=x):x=e[22];const b=x;if(f){let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(co,{className:"sr-only",children:n.jsx(wi,{children:"All prompts"})}),e[23]=V):V=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=j):j=e[24];let R;e[25]!==_||e[26]!==b?(R=n.jsxs(Vi,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[V,j,b,_]}),e[25]=_,e[26]=b,e[27]=R):R=e[27];let T;return e[28]!==r||e[29]!==i||e[30]!==R?(T=n.jsx(Oi,{delayDuration:400,children:n.jsx(Ci,{open:i,onOpenChange:r,children:R})}),e[28]=r,e[29]=i,e[30]=R,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(hs,{className:"sr-only",children:n.jsx(ds,{children:"All prompts"})}),e[32]=y):y=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=C):C=e[33];let k;e[34]!==_||e[35]!==b?(k=n.jsxs(ts,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,C,b,_]}),e[34]=_,e[35]=b,e[36]=k):k=e[36];let w;return e[37]!==r||e[38]!==i||e[39]!==k?(w=n.jsx(Oi,{delayDuration:400,children:n.jsx(ss,{open:i,onOpenChange:r,children:k})}),e[37]=r,e[38]=i,e[39]=k,e[40]=w):w=e[40],w}function lx(t){const e=B.c(29),{items:s,onSelect:i,loadingPrompt:r,className:o}=t,[a,l]=S.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==r||e[2]!==i){const v=s.slice(0,Dc);let x;e[6]!==s?(x=s.slice(Dc),e[6]=s,e[7]=x):x=e[7],c=x,d=!!r;let b;e[8]!==d||e[9]!==r?.name||e[10]!==i?(b=y=>n.jsx(Pu,{item:y,onSelect:i,isLoading:r?.name===y.prompt.name,isDisabled:d&&r?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=r?.name,e[10]=i,e[11]=b):b=e[11],u=v.map(b),e[0]=s,e[1]=r,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let f;e[12]!==o?(f=X("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&n.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:X(Mu,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==f||e[19]!==m?(p=n.jsxs("div",{className:f,children:[h,m]}),e[17]=h,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==i?(g=n.jsx(ax,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=n.jsxs(Oi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function cx(){return null}function dx(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function hx(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:i}=Gi(),{tiptapDocRef:r}=ai(),{org:o}=ye();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Le(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Hh(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let f;e[7]!==h?(f=h.map(ux),e[7]=h,e[8]=f):f=e[8];const m=f;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=S.useReducer(dx,p),[v,x]=S.useState(null);let b;e[10]!==l||e[11]!==i||e[12]!==r?(b=async(N,E)=>{if(!l){fe.error("MCP client not available"),_({type:"RESET"});return}try{const M=await bl(l,N.name,E);_({type:"RESET"});const L=rx(r.current,{type:"paragraph",content:[Up({id:N.name,name:gl(N.name,ni(N._meta)),metadata:M.messages,char:"/"})]});await i(L)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),fe.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=r,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async N=>{if(N.arguments&&N.arguments.length>0){_({type:"SELECT_PROMPT",prompt:N}),x(N);return}_({type:"START_LOADING",prompt:N}),await y(N)},e[14]=y,e[15]=C):C=e[15];const k=C;let w;e[16]!==v||e[17]!==y?(w=async N=>{v&&(_({type:"START_LOADING",prompt:v,arguments:N}),x(null),await y(v,N))},e[16]=v,e[17]=y,e[18]=w):w=e[18];const V=w;if(m.length===0)return null;const j=g.stage==="loading"?g.prompt:null;let R;e[19]!==k||e[20]!==m||e[21]!==j?(R=n.jsx(lx,{items:m,onSelect:k,loadingPrompt:j}),e[19]=k,e[20]=m,e[21]=j,e[22]=R):R=e[22];let T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{x(null),_({type:"RESET"})},e[23]=T):T=e[23];let I;e[24]!==v||e[25]!==V?(I=n.jsx(Bl,{prompt:v,setPrompt:T,onSubmit:V}),e[24]=v,e[25]=V,e[26]=I):I=e[26];let A;return e[27]!==R||e[28]!==I?(A=n.jsxs(n.Fragment,{children:[R,I]}),e[27]=R,e[28]=I,e[29]=A):A=e[29],A}function ux(t){return{prompt:t}}function fx(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:i}=ai(),{org:r}=ye();let o;e[0]!==r.id?(o=ho(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=X("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(cx,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=n.jsx(hx,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let f;e[7]!==d||e[8]!==h?(f=n.jsx(Ns,{fallback:null,children:n.jsx(S.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=n.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}function Lu(t){const e=B.c(21),{current:s,total:i,onPrev:r,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=X("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(kl,{size:14}),e[2]=d):d=e[2];let u;e[3]!==r||e[4]!==a||e[5]!==c?(u=n.jsx("button",{type:"button",onClick:r,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let f;e[7]!==h||e[8]!==i?(f=n.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=f):f=e[9];const m=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=X("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(uo,{size:14}),e[12]=_):_=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=n.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let x;return e[17]!==v||e[18]!==u||e[19]!==f?(x=n.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,f,v]}),e[17]=v,e[18]=u,e[19]=f,e[20]=x):x=e[20],x}function Wr(t){const e=B.c(18),{title:s,children:i,footerLeft:r,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=X("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=n.jsx("div",{className:"flex items-center gap-2 p-4",children:n.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=n.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==r?(h=n.jsx("div",{children:r}),e[6]=r,e[7]=h):h=e[7];let f;e[8]!==o?(f=n.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==h||e[11]!==f?(m=n.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:n.jsxs("div",{className:"flex items-center justify-between",children:[h,f]})}),e[10]=h,e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==m?(p=n.jsxs("div",{className:c,children:[d,u,m]}),e[13]=c,e[14]=d,e[15]=u,e[16]=m,e[17]=p):p=e[17],p}const mx="User denied this tool call, give other alternatives.",px=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function gx(t){const e=B.c(9),{onYolo:s}=t,[i,r]=yi();let o;e[0]!==s||e[1]!==i||e[2]!==r?(o=u=>{const h=u;r({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=r,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ti,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:xx,children:n.jsx(si,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Zs,{children:px.map(_x)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=n.jsxs(ei,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function _x(t){return n.jsx(Ht,{value:t.value,children:t.label},t.value)}function xx(t){return t.stopPropagation()}function vx(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let i;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],i=o}catch{i=String(s)}let r;return e[3]!==i?(r=n.jsx("div",{className:"px-4",children:n.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[3]=i,e[4]=r):r=e[4],r}function bx(t){const e=B.c(42),{approvals:s,onRespond:i}=t,[r,o]=S.useState(0),a=Math.min(r,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,mx)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let f;e[6]!==s||e[7]!==i?(f=()=>{for(const A of s)i(A.approvalId,!0)},e[6]=s,e[7]=i,e[8]=f):f=e[8];const m=f;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const v=_;let x;e[14]!==m?(x=n.jsx(gx,{onYolo:m}),e[14]=m,e[15]=x):x=e[15];let b;e[16]!==s.length||e[17]!==v||e[18]!==g||e[19]!==a?(b=n.jsx(Lu,{current:a,total:s.length,onPrev:g,onNext:v}),e[16]=s.length,e[17]=v,e[18]=g,e[19]=a,e[20]=b):b=e[20];let y;e[21]!==x||e[22]!==b?(y=n.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23];const C=y;let k;e[24]!==d?(k=n.jsx(oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:d,children:"Deny"}),e[24]=d,e[25]=k):k=e[25];let w;e[26]!==s.length||e[27]!==m?(w=s.length>1&&n.jsx(oe,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:m,children:"Accept All"}),e[26]=s.length,e[27]=m,e[28]=w):w=e[28];let V;e[29]!==h?(V=n.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=V):V=e[30];let j;e[31]!==w||e[32]!==V||e[33]!==k?(j=n.jsxs(n.Fragment,{children:[k,w,V]}),e[31]=w,e[32]=V,e[33]=k,e[34]=j):j=e[34];const R=j;let T;e[35]!==l.input?(T=n.jsx(vx,{input:l.input}),e[35]=l.input,e[36]=T):T=e[36];let I;return e[37]!==l.friendlyName||e[38]!==C||e[39]!==R||e[40]!==T?(I=n.jsx(Wr,{title:l.friendlyName,footerLeft:C,footerRight:R,children:T}),e[37]=l.friendlyName,e[38]=C,e[39]=R,e[40]=T,e[41]=I):I=e[41],I}function yx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(wg,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function Sx(t){const e=B.c(4),{approvals:s,isStreaming:i,onRespond:r}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(yx,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==r?(o=n.jsx(bx,{approvals:s,onRespond:r}),e[1]=s,e[2]=r,e[3]=o):o=e[3],o}function wx(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const i="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:i,friendlyName:Hp(Wp(i)),input:s.input})}return e}function Vx(t){const e=B.c(15),{plan:s,onApprove:i,onDismiss:r}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==r?(l=n.jsx(oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let c;e[5]!==a?(c=n.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=n.jsxs(n.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=n.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:n.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:n.jsx(Kp,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let f;return e[12]!==u||e[13]!==h?(f=n.jsx(Wr,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=f):f=e[14],f}function Cx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Jt,{className:"size-5 text-purple-500 shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function kx(t){const e=B.c(7),{plans:s,isStreaming:i,onApprove:r,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Cx,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==r||e[5]!==o?(c=n.jsx(Vx,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function jx(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const i=s.input;e.push({toolCallId:s.toolCallId,plan:i.plan,state:s.state})}return e}const Mc=js({response:Et().min(1,"Response is required")}),Nx=js({response:Et().min(1,"Please select or enter an option")}),Ax=js({response:Zm(["yes","no"])});function Ex(t){switch(t.type){case"text":return Mc;case"choice":return Nx;case"confirm":return Ax;default:return Mc}}function Ix(t){const e={};for(const s of t)e[s.toolCallId]=Ex(s.input);return js(e)}function Rx(t){const e=B.c(6),{control:s,name:i,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:c}=l;return n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsx("div",{className:"px-2",children:n.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(Xh,{size:16,className:"text-muted-foreground"})}),n.jsx("input",{...c,type:"text",placeholder:r||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),n.jsx(Dt,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=n.jsx(It,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Ou(t,e){const s=B.c(4);let i,r;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=r):(i=s[2],r=s[3]),S.useEffect(i,r)}function Tx(t){const e=B.c(9),{control:s,name:i,options:r}=t,[o,a]=S.useState(!1),l=S.useRef(null),c=S.useRef(null);let d;if(e[0]!==r?(d=f=>{c.current?.onChange(r[f]??""),a(!1)},e[0]=r,e[1]=d):d=e[1],Ou(r.length,d),r.length===0)return null;let u;e[2]!==o||e[3]!==r?(u=f=>{const{field:m}=f;c.current=m;const p=o||!!m.value&&!r.includes(m.value);return n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[r.map((g,_)=>{const v=m.value===g;return n.jsxs("button",{type:"button",onClick:()=>{m.onChange(g??""),a(!1)},className:X("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",v&&"bg-accent/50",!v&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[n.jsx("span",{className:X("flex items-center justify-center size-6 rounded-md text-sm shrink-0",v?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),n.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),n.jsxs("div",{className:X("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),r.includes(m.value)&&m.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(Xh,{size:16,className:"text-muted-foreground"})}),p?n.jsx("input",{ref:l,type:"text",value:m.value,onChange:g=>m.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):n.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),n.jsx(Dt,{})]})},e[2]=o,e[3]=r,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=n.jsx(It,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function Dx(t){const e=B.c(6),{control:s,name:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=S.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],Ou(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=h.value===f;return n.jsxs("button",{type:"button",onClick:()=>h.onChange(f),className:X("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[n.jsx("span",{className:X("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),n.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),n.jsx(Dt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=n.jsx(It,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Pc(t){const e=B.c(13),{input:s,control:i,name:r}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==r?(o=n.jsx(Rx,{control:i,name:r,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=r,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==i||e[7]!==r||e[8]!==a?(l=n.jsx(Tx,{control:i,name:r,options:a}),e[6]=i,e[7]=r,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==r?(o=n.jsx(Dx,{control:i,name:r}),e[10]=i,e[11]=r,e[12]=o):o=e[12],o}default:return null}}function Mx({parts:t,onSubmit:e}){const[s,i]=S.useState(t[0]?.toolCallId??""),r=Ix(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=qi({resolver:Un(r),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const b of t){const y=x[b.toolCallId]?.response;y&&e(b,y)}},h=x=>t.find(b=>!x[b.toolCallId]?.response&&b.toolCallId!==s)??null,f=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},m=()=>{o.setValue(`${s}.response`,"user has skip this question"),f()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=n.jsxs(n.Fragment,{children:[n.jsx(oe,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7",children:"Skip"}),n.jsx(oe,{type:"button",size:"sm",disabled:!c,onClick:f,className:X("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),v=n.jsx(Lu,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?n.jsx(Bi,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:n.jsx(Wr,{title:x.input?.prompt??"Question",footerRight:_,children:n.jsx(Pc,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return n.jsx(Bi,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:n.jsx(Wh,{value:s,onValueChange:i,children:t.map(x=>n.jsx(Cr,{value:x.toolCallId,className:"mt-0",children:n.jsx(Wr,{title:x.input?.prompt??"Question",footerLeft:v,footerRight:_,children:n.jsx(Pc,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function Px(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Kg,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Bu(t){const e=B.c(6),{userAskParts:s,isStreaming:i,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(Lx),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Px,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==r||e[4]!==a?(l=n.jsx(Mx,{parts:a,onSubmit:r}),e[3]=r,e[4]=a,e[5]=l):l=e[5],l}function Lx(t){return t.state==="input-available"}const Lc=new Map;function _o(){const{org:t}=ye(),e=Le({connectionId:Pt,orgId:t.id}),s=Nl(),i=s.find(_=>_.providerId==="deco"),{data:r,isLoading:o,refetch:a,isFetching:l}=Wi({queryKey:ct.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=r?.balanceCents??null,d=c!=null?c/100:null,u=S.useRef(new Map);if(c!=null){const _=Lc.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&ie("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Lc.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,f=c!=null&&c>0,m=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:f,isZeroBalance:m,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function Ox(t){return t?t.message.startsWith("[CREDITS]"):!1}const Bx={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},zx=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function zu(t){const e=B.c(43),{onDismiss:s}=t,{org:i}=ye(),r=qe(),{decoKeyId:o}=_o();let a;e[0]!==i.id?(a={connectionId:Pt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Le(a),[c,d]=S.useState(""),[u,h]=S.useState(!1),[f,m]=S.useState("usd"),p=f==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{ie("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),S.useEffect(g,_);let v;e[5]!==l||e[6]!==f?(v=async D=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:D,currency:f}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=f,e[7]=v):v=e[7];let x;e[8]!==s?(x=D=>{D&&window.open(D,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let b;e[10]!==v||e[11]!==x?(b={mutationFn:v,onSuccess:x,onError:Ux},e[10]=v,e[11]=x,e[12]=b):b=e[12];const{mutate:y,isPending:C}=Ki(b),k=parseFloat(c),w=!isNaN(k)&&k>=1;let V;e[13]!==s?(V=D=>!D&&s?.(),e[13]=s,e[14]=V):V=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[15]=j):j=e[15];let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=R):R=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[R,n.jsxs(hs,{className:"relative gap-4",children:[n.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),n.jsxs("div",{children:[n.jsx(ds,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),n.jsx(lo,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[17]=T):T=e[17];let I;e[18]!==f||e[19]!==p||e[20]!==c||e[21]!==k||e[22]!==o||e[23]!==w||e[24]!==C||e[25]!==u||e[26]!==y?(I=o&&n.jsxs("div",{className:"px-8 pt-5 pb-6",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(hu,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:D=>{D&&m(D)},children:[n.jsx($r,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx($r,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsxs("div",{className:"rounded-xl border border-border p-5",children:[n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Bx[f].map(D=>{const{dollars:P,label:O}=D;return n.jsxs("button",{type:"button",disabled:C,onClick:()=>{ie("credits_topup_clicked",{amount_cents:P*100,currency:f,tier_label:O,source:"exhausted_banner"}),y(P*100)},className:X("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},P)})}),u?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),n.jsx(gt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:D=>d(D.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(oe,{className:"h-10",disabled:!w||C,onClick:()=>{ie("credits_topup_clicked",{amount_cents:Math.round(k*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(k*100))},children:C?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),n.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:zx.map($x)})]}),e[18]=f,e[19]=p,e[20]=c,e[21]=k,e[22]=o,e[23]=w,e[24]=C,e[25]=u,e[26]=y,e[27]=I):I=e[27];let A;e[28]!==s?(A=n.jsx(oe,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=A):A=e[29];let N;e[30]!==r||e[31]!==s||e[32]!==i.slug?(N=n.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=r,e[31]=s,e[32]=i.slug,e[33]=N):N=e[33];let E;e[34]!==A||e[35]!==N?(E=n.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[A,N]}),e[34]=A,e[35]=N,e[36]=E):E=e[36];let M;e[37]!==I||e[38]!==E?(M=n.jsxs(ts,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Fx,children:[T,I,E]}),e[37]=I,e[38]=E,e[39]=M):M=e[39];let L;return e[40]!==M||e[41]!==V?(L=n.jsx(ss,{open:!0,onOpenChange:V,children:M}),e[40]=M,e[41]=V,e[42]=L):L=e[42],L}function $x(t){return n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:n.jsx(Jt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),n.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Fx(t){return t.preventDefault()}function Ux(t){fe.error(`Top-up failed: ${t.message}`)}const Hx={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function Kr(t){const e=B.c(32),{variant:s,onDismiss:i}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?t.error.message:Hx[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=r?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=r?"text-destructive":"text-amber-600 dark:text-amber-500",d=r?oi:fl;let u;e[0]!==l?(u=X("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=X("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==d?(f=n.jsx(d,{size:16}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==f?(m=n.jsx("div",{className:h,children:f}),e[6]=h,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==c?(p=X("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=n.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=n.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let v;e[16]!==r||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(v=n.jsx("div",{className:"flex gap-2",children:r?n.jsxs(n.Fragment,{children:[n.jsx(oe,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),n.jsx(oe,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):n.jsx(oe,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=r,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=v):v=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==v?(x=n.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,v]}),e[20]=g,e[21]=_,e[22]=v,e[23]=x):x=e[23];let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Js,{size:14}),e[24]=b):b=e[24];let y;e[25]!==i?(y=n.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:b}),e[25]=i,e[26]=y):y=e[26];let C;return e[27]!==u||e[28]!==y||e[29]!==m||e[30]!==x?(C=n.jsx("div",{className:"px-0.5",children:n.jsxs("div",{className:u,children:[m,x,y]})}),e[27]=u,e[28]=y,e[29]=m,e[30]=x,e[31]=C):C=e[31],C}function xo(){const t=B.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:r,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Gi(),[h,f]=yi(),{virtualMcpId:m,createTaskWithMessage:p}=es();let g,_,v,x;if(t[0]!==o){const E=o.at(-1);x=E?.role==="assistant"?E.parts.filter(qx):null,g=x?.filter(Kx)?.length,_=E?.role==="assistant"?jx(E.parts):[],v=E?.role==="assistant"?wx(E.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=v,t[4]=x}else g=t[1],_=t[2],v=t[3],x=t[4];const b=v;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const M={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(M)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const C=y;let k;t[8]!==u?(k=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=k):k=t[9];const w=k;let V;t[10]!==c?(V=(E,M)=>{c({tool:"user_ask",toolCallId:E.toolCallId,output:{response:M}})},t[10]=c,t[11]=V):V=t[11];const j=V;let R;t[12]!==p||t[13]!==h||t[14]!==f||t[15]!==m?(R=E=>{f({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:m,message:{parts:[{type:"text",text:`Implement this plan:
|
|
3
3
|
|
|
4
4
|
${E}`}]}})},t[12]=p,t[13]=h,t[14]=f,t[15]=m,t[16]=R):R=t[16];const T=R,I=Wx;let A;t[17]!==d?(A=(E,M,L)=>{d({id:E,approved:M,...L?{reason:L}:{}})},t[17]=d,t[18]=A):A=t[18];const N=A;if(g){let E;return t[19]!==j||t[20]!==a||t[21]!==x?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Bu,{userAskParts:x,isStreaming:a,onSubmit:j})}),t[19]=j,t[20]=a,t[21]=x,t[22]=E):E=t[22],E}if(_.length>0){let E;return t[23]!==T||t[24]!==a||t[25]!==_?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(kx,{plans:_,isStreaming:a,onApprove:T,onDismiss:I})}),t[23]=T,t[24]=a,t[25]=_,t[26]=E):E=t[26],E}if(b.length>0||a&&l){let E;return t[27]!==N||t[28]!==a||t[29]!==b?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Sx,{approvals:b,isStreaming:a,onRespond:N})}),t[27]=N,t[28]=a,t[29]=b,t[30]=E):E=t[30],E}if(!a&&e){if(Ox(e)){let M;return t[31]!==s?(M=n.jsx(zu,{onDismiss:s}),t[31]=s,t[32]=M):M=t[32],M}let E;return t[33]!==s||t[34]!==e||t[35]!==C?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Kr,{variant:"error",error:e,onDismiss:s,onFixInChat:C})}),t[33]=s,t[34]=e,t[35]=C,t[36]=E):E=t[36],E}if(!a&&i&&i!=="stop"&&!l){let E;return t[37]!==r||t[38]!==i||t[39]!==w?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Kr,{variant:"warning",finishReason:i,onDismiss:r,onContinue:w})}),t[37]=r,t[38]=i,t[39]=w,t[40]=E):E=t[40],E}return null}function Wx(){document.querySelector("[data-chat-input]")?.focus()}function Kx(t){return t.state!=="output-available"}function qx(t){return t.type==="tool-user_ask"}xo.Error=function(e){return n.jsx(Kr,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};xo.Warning=function(e){return n.jsx(Kr,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};xo.UserAskQuestion=Bu;async function zl(t,e,s,i,r){if(!fo(e)){fe.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!Qg(o,e)){const l=fu(e),c=e?.title??"This model";r?r({fileName:s.name,modelName:c,accepted:l}):fe.error(`"${s.name}" can't be attached`,{description:`${c} accepts ${l}. PowerPoint, Word, and Excel files aren't supported yet.`});return}const a=10*1024*1024;if(s.size>a){fe.error(`File "${s.name}" exceeds 10MB limit`);return}try{const l=new FileReader,c=new Promise((h,f)=>{l.onload=()=>{const m=l.result;if(typeof m!="string"){f(new Error("Failed to read file as data URL"));return}const p=m.includes(",")?m.split(",")[1]??m:m;h(p)},l.onerror=f});l.readAsDataURL(s);const d=await c,u={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:d};qp(t,{from:i,to:i},u)}catch(l){console.error("Failed to process file:",l),fe.error(`Failed to load file "${s.name}"`)}}function Gx(t){const e=B.c(8),{editor:s,selectedModel:i,onUnsupportedFile:r}=t,o=S.useRef(Xx);let a,l;e[0]!==s||e[1]!==r||e[2]!==i?(a=()=>{o.current=async(u,h)=>{await zl(s,i,u,h,r)}},l=[s,i,r],e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=l):(a=e[3],l=e[4]),S.useEffect(a,l);let c,d;return e[5]!==s?(c=()=>{if(s?.isDestroyed)return;const u=new fa("fileDropHandler");s.state.plugins.find(m=>m.spec.key===u)&&s.unregisterPlugin(u);const f=new dg({key:u,props:{handleDrop:(m,p,g,_)=>{if(_)return!1;const v=p.dataTransfer?.files;if(!v||v.length===0)return!1;p.preventDefault();const x=m.posAtCoords({left:p.clientX,top:p.clientY});if(!x)return!1;const b=Array.from(v),y=x.pos;for(const C of b)o.current?.(C,y);return!0},handlePaste:(m,p)=>{const g=p.clipboardData?.items;if(!g)return!1;const _=Array.from(g).filter(Yx);if(_.length===0)return!1;p.preventDefault();const{from:v}=m.state.selection;for(const x of _){const b=x.getAsFile();b&&o.current?.(b,v)}return!0}}});return s.registerPlugin(f),()=>{s?.isDestroyed||s.unregisterPlugin(u)}},d=[s],e[5]=s,e[6]=c,e[7]=d):(c=e[6],d=e[7]),S.useEffect(c,d),null}function Yx(t){return t.kind==="file"}function Xx(){return Promise.resolve()}function Jx(t){const e=B.c(24),{selectedModel:s,isStreaming:i,icon:r,onUnsupportedFile:o}=t,{editor:a}=ao(),l=S.useRef(null);let c;e[0]!==s?(c=fo(s),e[0]=s,e[1]=c):c=e[1];const d=c;let u;e[2]!==a||e[3]!==o||e[4]!==s?(u=async C=>{const k=C.target.files;if(!k||k.length===0||!a)return;const w=Array.from(k),{from:V}=a.state.selection,j=V;for(const R of w)await zl(a,s,R,j,o);l.current&&(l.current.value="")},e[2]=a,e[3]=o,e[4]=s,e[5]=u):u=e[5];const h=u;if(!a||!d)return null;let f;e[6]!==s?(f=Jg(s),e[6]=s,e[7]=f):f=e[7];let m;e[8]!==h||e[9]!==i||e[10]!==f?(m=n.jsx("input",{ref:l,type:"file",multiple:!0,accept:f,className:"hidden",onChange:h,disabled:i}),e[8]=h,e[9]=i,e[10]=f,e[11]=m):m=e[11];const p=i||!d;let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=()=>l.current?.click(),e[12]=g):g=e[12];let _;e[13]!==r?(_=r??n.jsx(Jh,{size:16}),e[13]=r,e[14]=_):_=e[14];let v;e[15]!==p||e[16]!==_?(v=n.jsx(st,{asChild:!0,children:n.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground/75",disabled:p,onClick:g,children:_})}),e[15]=p,e[16]=_,e[17]=v):v=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(it,{side:"top",children:"Add file"}),e[18]=x):x=e[18];let b;e[19]!==v?(b=n.jsxs(nt,{children:[v,x]}),e[19]=v,e[20]=b):b=e[20];let y;return e[21]!==b||e[22]!==m?(y=n.jsxs(n.Fragment,{children:[m,b]}),e[21]=b,e[22]=m,e[23]=y):y=e[23],y}const Qx=["PowerPoint (.pptx)","Word documents (.docx)","Excel spreadsheets (.xlsx)"];function Zx(t){const e=B.c(29),{info:s,onClose:i}=t,r=s!==null;let o;e[0]!==i?(o=w=>!w&&i(),e[0]=i,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:a.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=l):l=e[3];let c,d;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:n.jsx(fl,{size:18})}),d=n.jsx(ds,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=c,e[5]=d):(c=e[4],d=e[5]);const u=s?.fileName;let h;e[6]!==u?(h=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[l,n.jsxs(hs,{className:"relative gap-4",children:[c,n.jsxs("div",{children:[d,n.jsxs(lo,{className:"mt-1.5 text-sm leading-relaxed",children:[n.jsxs("span",{className:"font-medium text-foreground",children:["“",u,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=u,e[7]=h):h=e[7];const f=s?.modelName;let m;e[8]!==f?(m=n.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[f," accepts"]}),e[8]=f,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Jh,{size:14,className:"text-muted-foreground"}),e[10]=p):p=e[10];const g=s?.accepted;let _;e[11]!==g?(_=n.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[p,n.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=_):_=e[12];let v;e[13]!==m||e[14]!==_?(v=n.jsxs("div",{className:"rounded-xl border border-border p-4",children:[m,_]}),e[13]=m,e[14]=_,e[15]=v):v=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsxs("div",{className:"rounded-xl bg-muted/25 border border-border/50 p-4 space-y-2",children:[n.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Not supported yet"}),Qx.map(e1)]}),e[16]=x):x=e[16];let b;e[17]!==v?(b=n.jsxs("div",{className:"px-8 pt-3 pb-6 space-y-3",children:[v,x]}),e[17]=v,e[18]=b):b=e[18];let y;e[19]!==i?(y=n.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:n.jsx(oe,{onClick:i,children:"Got it"})}),e[19]=i,e[20]=y):y=e[20];let C;e[21]!==b||e[22]!==y||e[23]!==h?(C=n.jsxs(ts,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:t1,children:[h,b,y]}),e[21]=b,e[22]=y,e[23]=h,e[24]=C):C=e[24];let k;return e[25]!==r||e[26]!==C||e[27]!==o?(k=n.jsx(ss,{open:r,onOpenChange:o,children:C}),e[25]=r,e[26]=C,e[27]=o,e[28]=k):k=e[28],k}function e1(t){return n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-muted shrink-0",children:n.jsx(Js,{size:10,className:"text-muted-foreground"})}),n.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function t1(t){return t.preventDefault()}function s1(){const t=B.c(3),[e,s]=S.useState(null);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>s(null),t[0]=i):i=t[0];let r;return t[1]!==e?(r={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:i},t[1]=e,t[2]=r):r=t[2],r}var i1=hg;var n1=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],va=n1.join(","),$u=typeof Element>"u",Tn=$u?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,qr=!$u&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},Gr=function(e,s){var i;s===void 0&&(s=!0);var r=e==null||(i=e.getAttribute)===null||i===void 0?void 0:i.call(e,"inert"),o=r===""||r==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):Gr(e.parentNode));return a},r1=function(e){var s,i=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return i===""||i==="true"},o1=function(e,s,i){if(Gr(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(va));return s&&Tn.call(e,va)&&r.unshift(e),r=r.filter(i),r},ba=function(e,s,i){for(var r=[],o=Array.from(e);o.length;){var a=o.shift();if(!Gr(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=ba(c,!0,i);i.flatten?r.push.apply(r,d):r.push({scopeParent:a,candidates:d})}else{var u=Tn.call(a,va);u&&i.filter(a)&&(s||!e.includes(a))&&r.push(a);var h=a.shadowRoot||typeof i.getShadowRoot=="function"&&i.getShadowRoot(a),f=!Gr(h,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(h&&f){var m=ba(h===!0?a.children:h.children,!0,i);i.flatten?r.push.apply(r,m):r.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return r},Fu=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Uu=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||r1(e))&&!Fu(e)?0:e.tabIndex},a1=function(e,s){var i=Uu(e);return i<0&&s&&!Fu(e)?0:i},l1=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},Hu=function(e){return e.tagName==="INPUT"},c1=function(e){return Hu(e)&&e.type==="hidden"},d1=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(i){return i.tagName==="SUMMARY"});return s},h1=function(e,s){for(var i=0;i<e.length;i++)if(e[i].checked&&e[i].form===s)return e[i]},u1=function(e){if(!e.name)return!0;var s=e.form||qr(e),i=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=i(window.CSS.escape(e.name));else try{r=i(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var o=h1(r,e.form);return!o||o===e},f1=function(e){return Hu(e)&&e.type==="radio"},m1=function(e){return f1(e)&&!u1(e)},p1=function(e){var s,i=e&&qr(e),r=(s=i)===null||s===void 0?void 0:s.host,o=!1;if(i&&i!==e){var a,l,c;for(o=!!((a=r)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(r)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&r;){var d,u,h;i=qr(r),r=(d=i)===null||d===void 0?void 0:d.host,o=!!((u=r)!==null&&u!==void 0&&(h=u.ownerDocument)!==null&&h!==void 0&&h.contains(r))}}return o},Oc=function(e){var s=e.getBoundingClientRect(),i=s.width,r=s.height;return i===0&&r===0},g1=function(e,s){var i=s.displayCheck,r=s.getShadowRoot;if(i==="full-native"&&"checkVisibility"in e){var o=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(e).visibility==="hidden")return!0;var a=Tn.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(Tn.call(l,"details:not([open]) *"))return!0;if(!i||i==="full"||i==="full-native"||i==="legacy-full"){if(typeof r=="function"){for(var c=e;e;){var d=e.parentElement,u=qr(e);if(d&&!d.shadowRoot&&r(d)===!0)return Oc(e);e.assignedSlot?e=e.assignedSlot:!d&&u!==e.ownerDocument?e=u.host:e=d}e=c}if(p1(e))return!e.getClientRects().length;if(i!=="legacy-full")return!0}else if(i==="non-zero-area")return Oc(e);return!1},_1=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var i=0;i<s.children.length;i++){var r=s.children.item(i);if(r.tagName==="LEGEND")return Tn.call(s,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}s=s.parentElement}return!1},x1=function(e,s){return!(s.disabled||c1(s)||g1(s,e)||d1(s)||_1(s))},Bc=function(e,s){return!(m1(s)||Uu(s)<0||!x1(e,s))},v1=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},Wu=function(e){var s=[],i=[];return e.forEach(function(r,o){var a=!!r.scopeParent,l=a?r.scopeParent:r,c=a1(l,a),d=a?Wu(r.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):i.push({documentOrder:o,tabIndex:c,item:r,isScope:a,content:d})}),i.sort(l1).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(s)},Ku=function(e,s){s=s||{};var i;return s.getShadowRoot?i=ba([e],s.includeContainer,{filter:Bc.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:v1}):i=o1(e,s.includeContainer,Bc.bind(null,s)),Wu(i)};function b1(){return/apple/i.test(navigator.vendor)}const zc="data-floating-ui-focusable";function y1(t){let e=t.activeElement;for(;((s=e)==null||(s=s.shadowRoot)==null?void 0:s.activeElement)!=null;){var s;e=e.shadowRoot.activeElement}return e}function ya(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&ep(s)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function nn(t){return"composedPath"in t?t.composedPath()[0]:t.target}function Mo(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const s=t;return s.target!=null&&e.contains(s.target)}function S1(t){return t.matches("html,body")}function Dn(t){return t?.ownerDocument||document}function w1(t){return t?t.hasAttribute(zc)?t:t.querySelector("["+zc+"]")||t:null}function Er(t,e,s){return s===void 0&&(s=!0),t.filter(r=>{var o;return r.parentId===e&&(!s||((o=r.context)==null?void 0:o.open))}).flatMap(r=>[r,...Er(t,r.id,s)])}function V1(t){return"nativeEvent"in t}var C1=typeof document<"u",k1=function(){},_i=C1?S.useLayoutEffect:k1;const j1={...Ih},N1=j1.useInsertionEffect,A1=N1||(t=>t());function Ti(t){const e=S.useRef(()=>{});return A1(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}const qu=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Gu(t,e){const s=Ku(t,qu()),i=s.length;if(i===0)return;const r=y1(Dn(t)),o=s.indexOf(r),a=o===-1?e===1?0:i-1:o+e;return s[a]}function E1(t){return Gu(Dn(t).body,1)||t}function I1(t){return Gu(Dn(t).body,-1)||t}function Po(t,e){const s=e||t.currentTarget,i=t.relatedTarget;return!i||!ya(s,i)}function R1(t){Ku(t,qu()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function $c(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const i=s.dataset.tabindex;delete s.dataset.tabindex,i?s.setAttribute("tabindex",i):s.removeAttribute("tabindex")})}const T1="data-floating-ui-focusable",Fc="active",Uc="selected",D1={...Ih};let Hc=!1,M1=0;const Wc=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+M1++;function P1(){const[t,e]=S.useState(()=>Hc?Wc():void 0);return _i(()=>{t==null&&e(Wc())},[]),S.useEffect(()=>{Hc=!0},[]),t}const L1=D1.useId,$l=L1||P1;function O1(){const t=new Map;return{emit(e,s){var i;(i=t.get(e))==null||i.forEach(r=>r(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var i;(i=t.get(e))==null||i.delete(s)}}}const B1=S.createContext(null),z1=S.createContext(null),Yu=()=>{var t;return((t=S.useContext(B1))==null?void 0:t.id)||null},Xu=()=>S.useContext(z1);function Fl(t){return"data-floating-ui-"+t}const $1={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},Kc=S.forwardRef(function(e,s){const[i,r]=S.useState();_i(()=>{b1()&&r("button")},[]);const o={ref:s,tabIndex:0,role:i,"aria-hidden":i?void 0:!0,[Fl("focus-guard")]:"",style:$1};return n.jsx("span",{...e,...o})}),F1={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Ju=S.createContext(null),qc=Fl("portal");function U1(t){t===void 0&&(t={});const{id:e,root:s}=t,i=$l(),r=W1(),[o,a]=S.useState(null),l=S.useRef(null);return _i(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),_i(()=>{if(!i||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=i,d.setAttribute(qc,""),c.appendChild(d),l.current=d,a(d)},[e,i]),_i(()=>{if(s===null||!i||l.current)return;let c=s||r?.portalNode;c&&!op(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const u=document.createElement("div");u.id=i,u.setAttribute(qc,""),c=d||c,c.appendChild(u),l.current=u,a(u)},[e,s,i,r]),o}function H1(t){const{children:e,id:s,root:i,preserveTabOrder:r=!0}=t,o=U1({id:s,root:i}),[a,l]=S.useState(null),c=S.useRef(null),d=S.useRef(null),u=S.useRef(null),h=S.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&r&&!!(i||o);return S.useEffect(()=>{if(!o||!r||f)return;function g(_){o&&Po(_)&&(_.type==="focusin"?$c:R1)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,r,f]),S.useEffect(()=>{o&&(m||$c(o))},[m,o]),n.jsxs(Ju.Provider,{value:S.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:u,afterInsideRef:h,portalNode:o,setFocusManagerState:l}),[r,o]),children:[p&&o&&n.jsx(Kc,{"data-type":"outside",ref:c,onFocus:g=>{if(Po(g,o)){var _;(_=u.current)==null||_.focus()}else{const v=a?a.domReference:null,x=I1(v);x?.focus()}}}),p&&o&&n.jsx("span",{"aria-owns":o.id,style:F1}),o&&ms.createPortal(e,o),p&&o&&n.jsx(Kc,{"data-type":"outside",ref:d,onFocus:g=>{if(Po(g,o)){var _;(_=h.current)==null||_.focus()}else{const v=a?a.domReference:null,x=E1(v);x?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const W1=()=>S.useContext(Ju),K1={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},q1={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Gc=t=>{var e,s;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(s=t?.outsidePress)!=null?s:!0}};function G1(t,e){e===void 0&&(e={});const{open:s,onOpenChange:i,elements:r,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:u=!1,referencePressEvent:h="pointerdown",ancestorScroll:f=!1,bubbles:m,capture:p}=e,g=Xu(),_=Ti(typeof c=="function"?c:()=>!1),v=typeof c=="function"?_:c,x=S.useRef(!1),{escapeKey:b,outsidePress:y}=Gc(m),{escapeKey:C,outsidePress:k}=Gc(p),w=S.useRef(!1),V=Ti(N=>{var E;if(!s||!a||!l||N.key!=="Escape"||w.current)return;const M=(E=o.current.floatingContext)==null?void 0:E.nodeId,L=g?Er(g.nodesRef.current,M):[];if(!b&&(N.stopPropagation(),L.length>0)){let D=!0;if(L.forEach(P=>{var O;if((O=P.context)!=null&&O.open&&!P.context.dataRef.current.__escapeKeyBubbles){D=!1;return}}),!D)return}i(!1,V1(N)?N.nativeEvent:N,"escape-key")}),j=Ti(N=>{var E;const M=()=>{var L;V(N),(L=nn(N))==null||L.removeEventListener("keydown",M)};(E=nn(N))==null||E.addEventListener("keydown",M)}),R=Ti(N=>{var E;const M=o.current.insideReactTree;o.current.insideReactTree=!1;const L=x.current;if(x.current=!1,d==="click"&&L||M||typeof v=="function"&&!v(N))return;const D=nn(N),P="["+Fl("inert")+"]",O=Dn(r.floating).querySelectorAll(P);let $=Vs(D)?D:null;for(;$&&!Eo($);){const K=ip($);if(Eo(K)||!Vs(K))break;$=K}if(O.length&&Vs(D)&&!S1(D)&&!ya(D,r.floating)&&Array.from(O).every(K=>!ya($,K)))return;if(np(D)&&A){const K=Eo(D),H=rp(D),U=/auto|scroll/,Y=K||U.test(H.overflowX),q=K||U.test(H.overflowY),G=Y&&D.clientWidth>0&&D.scrollWidth>D.clientWidth,ee=q&&D.clientHeight>0&&D.scrollHeight>D.clientHeight,Z=H.direction==="rtl",J=ee&&(Z?N.offsetX<=D.offsetWidth-D.clientWidth:N.offsetX>D.clientWidth),se=G&&N.offsetY>D.clientHeight;if(J||se)return}const z=(E=o.current.floatingContext)==null?void 0:E.nodeId,W=g&&Er(g.nodesRef.current,z).some(K=>{var H;return Mo(N,(H=K.context)==null?void 0:H.elements.floating)});if(Mo(N,r.floating)||Mo(N,r.domReference)||W)return;const F=g?Er(g.nodesRef.current,z):[];if(F.length>0){let K=!0;if(F.forEach(H=>{var U;if((U=H.context)!=null&&U.open&&!H.context.dataRef.current.__outsidePressBubbles){K=!1;return}}),!K)return}i(!1,N,"outside-press")}),T=Ti(N=>{var E;const M=()=>{var L;R(N),(L=nn(N))==null||L.removeEventListener(d,M)};(E=nn(N))==null||E.addEventListener(d,M)});S.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=b,o.current.__outsidePressBubbles=y;let N=-1;function E(O){i(!1,O,"ancestor-scroll")}function M(){window.clearTimeout(N),w.current=!0}function L(){N=window.setTimeout(()=>{w.current=!1},sp()?5:0)}const D=Dn(r.floating);l&&(D.addEventListener("keydown",C?j:V,C),D.addEventListener("compositionstart",M),D.addEventListener("compositionend",L)),v&&D.addEventListener(d,k?T:R,k);let P=[];return f&&(Vs(r.domReference)&&(P=Ao(r.domReference)),Vs(r.floating)&&(P=P.concat(Ao(r.floating))),!Vs(r.reference)&&r.reference&&r.reference.contextElement&&(P=P.concat(Ao(r.reference.contextElement)))),P=P.filter(O=>{var $;return O!==(($=D.defaultView)==null?void 0:$.visualViewport)}),P.forEach(O=>{O.addEventListener("scroll",E,{passive:!0})}),()=>{l&&(D.removeEventListener("keydown",C?j:V,C),D.removeEventListener("compositionstart",M),D.removeEventListener("compositionend",L)),v&&D.removeEventListener(d,k?T:R,k),P.forEach(O=>{O.removeEventListener("scroll",E)}),window.clearTimeout(N)}},[o,r,l,v,d,s,i,f,a,b,y,V,C,j,R,k,T]),S.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const I=S.useMemo(()=>({onKeyDown:V,...u&&{[K1[h]]:N=>{i(!1,N.nativeEvent,"reference-press")},...h!=="click"&&{onClick(N){i(!1,N.nativeEvent,"reference-press")}}}}),[V,i,u,h]),A=S.useMemo(()=>{function N(E){E.button===0&&(x.current=!0)}return{onKeyDown:V,onMouseDown:N,onMouseUp:N,[q1[d]]:()=>{o.current.insideReactTree=!0}}},[V,d,o]);return S.useMemo(()=>a?{reference:I,floating:A}:{},[a,I,A])}function Y1(t){const{open:e=!1,onOpenChange:s,elements:i}=t,r=$l(),o=S.useRef({}),[a]=S.useState(()=>O1()),l=Yu()!=null,[c,d]=S.useState(i.reference),u=Ti((m,p,g)=>{o.current.openEvent=m?p:void 0,a.emit("openchange",{open:m,event:p,reason:g,nested:l}),s?.(m,p,g)}),h=S.useMemo(()=>({setPositionReference:d}),[]),f=S.useMemo(()=>({reference:c||i.reference||null,floating:i.floating||null,domReference:i.reference}),[c,i.reference,i.floating]);return S.useMemo(()=>({dataRef:o,open:e,onOpenChange:u,elements:f,events:a,floatingId:r,refs:h}),[e,u,f,a,r,h])}function X1(t){t===void 0&&(t={});const{nodeId:e}=t,s=Y1({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||s,r=i.elements,[o,a]=S.useState(null),[l,c]=S.useState(null),u=r?.domReference||o,h=S.useRef(null),f=Xu();_i(()=>{u&&(h.current=u)},[u]);const m=tp({...t,elements:{...r,...l&&{reference:l}}}),p=S.useCallback(b=>{const y=Vs(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;c(y),m.refs.setReference(y)},[m.refs]),g=S.useCallback(b=>{(Vs(b)||b===null)&&(h.current=b,a(b)),(Vs(m.refs.reference.current)||m.refs.reference.current===null||b!==null&&!Vs(b))&&m.refs.setReference(b)},[m.refs]),_=S.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:h}),[m.refs,g,p]),v=S.useMemo(()=>({...m.elements,domReference:u}),[m.elements,u]),x=S.useMemo(()=>({...m,...i,refs:_,elements:v,nodeId:e}),[m,_,v,e,i]);return _i(()=>{i.dataRef.current.floatingContext=x;const b=f?.nodesRef.current.find(y=>y.id===e);b&&(b.context=x)}),S.useMemo(()=>({...m,context:x,refs:_,elements:v}),[m,_,v,x])}function Lo(t,e,s){const i=new Map,r=s==="item";let o=t;if(r&&t){const{[Fc]:a,[Uc]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[T1]:""},...o,...e.map(a=>{const l=a?a[s]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((a,l)=>(l&&Object.entries(l).forEach(c=>{let[d,u]=c;if(!(r&&[Fc,Uc].includes(d)))if(d.indexOf("on")===0){if(i.has(d)||i.set(d,[]),typeof u=="function"){var h;(h=i.get(d))==null||h.push(u),a[d]=function(){for(var f,m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];return(f=i.get(d))==null?void 0:f.map(_=>_(...p)).find(_=>_!==void 0)}}}else a[d]=u}),a),{})}}function J1(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),i=t.map(l=>l?.item),r=S.useCallback(l=>Lo(l,t,"reference"),e),o=S.useCallback(l=>Lo(l,t,"floating"),s),a=S.useCallback(l=>Lo(l,t,"item"),i);return S.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:a}),[r,o,a])}const Q1=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Z1(t,e){var s,i;e===void 0&&(e={});const{open:r,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=$l(),u=((s=o.domReference)==null?void 0:s.id)||d,h=S.useMemo(()=>{var x;return((x=w1(o.floating))==null?void 0:x.id)||a},[o.floating,a]),f=(i=Q1.get(c))!=null?i:c,p=Yu()!=null,g=S.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:r?h:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":r?h:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:u},...f==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[f,h,p,r,u,c]),_=S.useMemo(()=>{const x={id:h,...f&&{role:f}};return f==="tooltip"||c==="label"?x:{...x,...f==="menu"&&{"aria-labelledby":u}}},[f,h,u,c]),v=S.useCallback(x=>{let{active:b,selected:y}=x;const C={role:"option",...b&&{id:h+"-fui-option"}};switch(c){case"select":case"combobox":return{...C,"aria-selected":y}}return{}},[h,c]);return S.useMemo(()=>l?{reference:g,floating:_,item:v}:{},[l,g,_,v])}function ev(t){const e=B.c(26),{editor:s,query:i,items:r,onSelect:o,onClose:a}=t,[l,c]=S.useState(0),d=S.useRef(r),u=S.useRef(l),h=S.useRef(o),f=S.useRef(a),m=S.useDeferredValue(i);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{c(0)},e[0]=p):p=e[0];let g;e[1]!==m?(g=[m],e[1]=m,e[2]=g):g=e[2],S.useEffect(p,g);let _,v;e[3]!==r.length||e[4]!==l?(_=()=>{l>=r.length&&r.length>0&&c(0)},v=[r.length,l],e[3]=r.length,e[4]=l,e[5]=_,e[6]=v):(_=e[5],v=e[6]),S.useEffect(_,v);let x,b;e[7]!==r?(x=()=>{d.current=r},b=[r],e[7]=r,e[8]=x,e[9]=b):(x=e[8],b=e[9]),S.useEffect(x,b);let y,C;e[10]!==l?(y=()=>{u.current=l},C=[l],e[10]=l,e[11]=y,e[12]=C):(y=e[11],C=e[12]),S.useEffect(y,C);let k,w;e[13]!==o?(w=()=>{h.current=o},k=[o],e[13]=o,e[14]=k,e[15]=w):(k=e[14],w=e[15]),S.useEffect(w,k);let V,j;e[16]!==a?(V=()=>{f.current=a},j=[a],e[16]=a,e[17]=V,e[18]=j):(V=e[17],j=e[18]),S.useEffect(V,j);let R;e[19]!==s.isDestroyed||e[20]!==s.view.dom?(R=()=>{const N=s.view.dom;if(s?.isDestroyed||!N)return;const E=L=>{const D=d.current;if(!D.length)return!1;const P=()=>c($=>($+1)%D.length),O=()=>c($=>($-1+D.length)%D.length);switch(L.key){case"ArrowUp":return L.preventDefault(),O(),!0;case"ArrowDown":return L.preventDefault(),P(),!0;case"Tab":return L.preventDefault(),L.shiftKey?O():P(),!0;case"Home":return L.preventDefault(),c(0),!0;case"End":return L.preventDefault(),c(D.length-1),!0;case"Enter":{if(L.isComposing)return!1;L.preventDefault();const $=u.current;return $!==-1&&D[$]&&h.current?.(D[$],$),!0}case"Escape":return L.preventDefault(),f.current?.(),!0;default:return!1}},M=L=>{E(L)};return N.addEventListener("keydown",M,!0),()=>{N?.removeEventListener("keydown",M,!0)}},e[19]=s.isDestroyed,e[20]=s.view.dom,e[21]=R):R=e[21];let T;e[22]!==s?(T=[s],e[22]=s,e[23]=T):T=e[23],S.useEffect(R,T);const I=r.length?l:void 0;let A;return e[24]!==I?(A={selectedIndex:I,setSelectedIndex:c},e[24]=I,e[25]=A):A=e[25],A}function tv(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const Qu=S.createContext(void 0);function Zu(){const t=S.useContext(Qu);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function sv({editor:t,char:e,pluginKey:s,allow:i,onOpenChange:r}){const[o,a]=S.useReducer(tv,{open:!1,element:null,query:"",range:null,selectedItem:null}),l=S.useRef(r);return l.current=r,S.useEffect(()=>{if(t?.isDestroyed)return;const c=s instanceof fa?s:new fa(s);t.state.plugins.find(h=>h.spec.key===c)&&t.unregisterPlugin(c);const u=e_({pluginKey:c,editor:t,char:e,allow(h){const f=t.state.doc.resolve(h.range.from);for(let m=f.depth;m>0;m--)if(f.node(m).type.name==="image")return!1;return!(i&&!i(h))},command(){},render:()=>({onStart:h=>{a({type:"ON_START",payload:{element:h.decorationNode??null,query:h.query,range:h.range}}),l.current?.(!0)},onUpdate:h=>{a({type:"ON_UPDATE",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onKeyDown:h=>h.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),l.current?.(!1)}}),items:()=>[]});return t.registerPlugin(u),()=>{t?.isDestroyed||t.unregisterPlugin(c)}},[t,s,e,a,i]),{state:o,dispatch:a}}function iv({editor:t,queryKey:e,queryFn:s,onSelect:i}){const{state:r,dispatch:o}=Zu(),a=S.useDeferredValue(r.query),{data:l}=Rh({queryKey:ct.suggestionItems(e,r.open,a),queryFn:()=>r.open?s({query:a}):[]}),c=()=>{o({type:"ON_EXIT"})},d=async(h,f)=>{if(!(r.selectedItem!==null||!r.range)){o({type:"SET_SELECTED_ITEM",payload:h});try{const{view:m}=t,g=m.state.selection.$to.nodeAfter?.text?.startsWith(" "),_=r.range?{...r.range}:{from:0,to:0};g&&r.range&&(_.to+=1),await i({range:_,item:h})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):c()}catch{c()}}},{selectedIndex:u}=ev({editor:t,query:a,items:l,onSelect:d,onClose:c});return{selectedItem:r.selectedItem,items:l,selectedIndex:u,close:c,onSelect:d}}function nv({children:t}){const{state:e,dispatch:s}=Zu(),{open:i,element:r}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=X1({placement:"bottom-start",open:i,onOpenChange:f=>{f||o()},elements:{reference:r},middleware:[ap(10),lp(),cp()],whileElementsMounted:dp}),d=G1(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),u=Z1(c,{role:"listbox"}),{getFloatingProps:h}=J1([d,u]);return i?n.jsx(H1,{children:n.jsx("div",{ref:a.setFloating,style:l,...h(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const rv=t=>{const e=B.c(29),{item:s,isSelected:i,onSelect:r,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const k=ni(s._meta);l=s.title||oo(s.name,k),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,u=s.icon,h=i&&"bg-accent text-accent-foreground",f=o&&"pointer-events-none opacity-50";let m;e[2]!==h||e[3]!==f?(m=X("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",h,f),e[2]=h,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==u||e[6]!==c?(p=u!==void 0&&n.jsx(gs,{icon:u,name:c,size:"xs",className:"mr-2"}),e[5]=u,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=n.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let _;e[10]!==o?(_=o&&n.jsx(In,{size:"xs"}),e[10]=o,e[11]=_):_=e[11];let v;e[12]!==g||e[13]!==_?(v=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,_]}),e[12]=g,e[13]=_,e[14]=v):v=e[14];let x;e[15]!==d?(x=d&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=x):x=e[16];let b;e[17]!==v||e[18]!==x?(b=n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,x]}),e[17]=v,e[18]=x,e[19]=b):b=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&n.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=y):y=e[21];let C;return e[22]!==r||e[23]!==a||e[24]!==b||e[25]!==y||e[26]!==m||e[27]!==p?(C=n.jsxs("div",{ref:a,onClick:r,className:m,children:[p,b,y]}),e[22]=r,e[23]=a,e[24]=b,e[25]=y,e[26]=m,e[27]=p,e[28]=C):C=e[28],C},ov=t=>{const e=B.c(18),{editor:s,queryKey:i,queryFn:r,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==i?(a={editor:s,queryKey:i,queryFn:r,onSelect:o},e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=a):a=e[4];const{items:l,selectedIndex:c,onSelect:d,selectedItem:u}=iv(a);if(!l.length){let p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=p):p=e[5],p}let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=h):h=e[6];let f;if(e[7]!==d||e[8]!==l||e[9]!==c||e[10]!==u?.name){let p;e[12]!==d||e[13]!==c||e[14]!==u?.name?(p=(g,_)=>n.jsx(rv,{item:g,isSelected:_===c,ref:_===c?cv:void 0,onSelect:()=>d(g,_),isLoading:u?.name===g.name},g.name),e[12]=d,e[13]=c,e[14]=u?.name,e[15]=p):p=e[15],f=l.map(p),e[7]=d,e[8]=l,e[9]=c,e[10]=u?.name,e[11]=f}else f=e[11];let m;return e[16]!==f?(m=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:h,children:n.jsx("div",{className:"p-1",children:f})}),e[16]=f,e[17]=m):m=e[17],m};function av(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"p-1",children:[...Array(3)].map(lv)}),t[0]=e):e=t[0],e}function lv(t,e){return n.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[n.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),n.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function ef(t){const e=B.c(18),{editor:s,char:i,pluginKey:r,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let u;e[0]!==c||e[1]!==i||e[2]!==s||e[3]!==d||e[4]!==r?(u={editor:s,char:i,pluginKey:r,allow:c,onOpenChange:d},e[0]=c,e[1]=i,e[2]=s,e[3]=d,e[4]=r,e[5]=u):u=e[5];const{state:h,dispatch:f}=sv(u);let m;e[6]!==f||e[7]!==h?(m={state:h,dispatch:f},e[6]=f,e[7]=h,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(av,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=n.jsx(nv,{children:n.jsx(S.Suspense,{fallback:p,children:n.jsx(ov,{editor:s,queryKey:o,queryFn:a,onSelect:l})})}),e[10]=s,e[11]=l,e[12]=a,e[13]=o,e[14]=g):g=e[14];let _;return e[15]!==m||e[16]!==g?(_=n.jsx(Qu.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=_):_=e[17],_}function cv(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const dv=[{name:"agents",title:"Agents",description:"Mention an agent to hand off work",kind:"category",drillable:!0},{name:"resources",title:"Resources",description:"Attach a resource as context",kind:"category",drillable:!0}],hv=({editor:t,virtualMcpId:e})=>{const s=Mt(),{org:i}=ye(),r=mo(),o=Le({connectionId:e,orgId:i.id}),a=ct.virtualMcpResources(e,i.id),[l,c]=S.useState("categories"),d=S.useRef(l);d.current=l;const u=S.useRef(null),h=S.useRef(!1),f=["at-mention",i.id,e??"default",l],m=async({item:_,range:v})=>{if(ie("chat_picker_item_selected",{picker:"@",item_kind:_.kind,item_name:_.name}),_.kind!=="category"&&(h.current=!0),_.kind==="category")return c(_.name==="agents"?"agents":"resources"),!1;if(_.kind==="agent"&&_.agentId){En(t,v,{id:_.agentId,name:_.name,metadata:{agentId:_.agentId,title:_.name},char:"@"}),c("categories");return}if(_.kind==="resource"&&_.uri&&o){try{const x=await gu(o,_.uri);En(t,v,{id:_.uri,name:_.uri,metadata:x.contents,char:"@"})}catch(x){console.error("[at-mention] Failed to fetch resource:",x),fe.error("Failed to load resource. Please try again.")}c("categories");return}},p=async _=>{const{query:v}=_,x=d.current;if(x==="categories"){if(!v.trim())return dv;const C=v.toLowerCase(),k=r.filter(V=>V.status==="active"&&(!V.id||!Br(V.id))&&V.id!==e&&(V.title.toLowerCase().includes(C)||V.description?.toLowerCase().includes(C))).map(V=>({name:V.title,title:V.title,description:V.description??void 0,icon:V.icon??null,kind:"agent",agentId:V.id})),w=await(async()=>{if(!o)return[];let V=s.getQueryData(a);return V||(V=await s.fetchQuery({queryKey:a,queryFn:()=>wn(o),staleTime:6e4})),(V?.resources??[]).filter(j=>j.uri.toLowerCase().includes(C)||j.name?.toLowerCase().includes(C)||j.description?.toLowerCase().includes(C)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}))})();return[...k,...w]}if(x==="agents"){let C=r.filter(k=>k.status==="active"&&(!k.id||!Br(k.id))&&k.id!==e);if(v.trim()){const k=v.toLowerCase();C=C.filter(w=>w.title.toLowerCase().includes(k)||w.description?.toLowerCase().includes(k))}return C.map(k=>({name:k.title,title:k.title,description:k.description??void 0,icon:k.icon??null,kind:"agent",agentId:k.id}))}if(!o)return[];let b=s.getQueryData(a);b?s.fetchQuery({queryKey:a,queryFn:()=>wn(o),staleTime:6e4}).catch(()=>{}):b=await s.fetchQuery({queryKey:a,queryFn:()=>wn(o),staleTime:6e4});let y=b?.resources??[];if(v.trim()){const C=v.toLowerCase();y=y.filter(k=>k.uri.toLowerCase().includes(C)||k.name?.toLowerCase().includes(C)||k.description?.toLowerCase().includes(C))}return y.map(C=>({name:C.name??C.uri,title:C.name,description:C.description,kind:"resource",uri:C.uri}))},g=_=>{if(_)u.current=Date.now(),h.current=!1,ie("chat_picker_opened",{picker:"@"});else{const v=u.current;ie("chat_picker_closed",{picker:"@",outcome:h.current?"selected":"dismissed",duration_ms:v?Date.now()-v:null}),u.current=null,c("categories")}};return n.jsx(ef,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:f,queryFn:p,onSelect:m,onOpenChange:g})};function uv(t,e){const s=is(t),i=Gn(),r=new Map(i.map(c=>[c.id,c])),o=(s?.connections??[]).map(c=>c.connection_id),{data:a}=Wi({queryKey:ct.promptConnectionMap(e,o),queryFn:async()=>{const c={};return await Promise.all(o.map(async d=>{try{const u=await vg({connectionId:d,orgId:e}),h=await zr(u);for(const f of h.prompts)f.name in c||(c[f.name]=d)}catch{}})),c},staleTime:6e4,enabled:o.length>0}),l=new Map;for(const[c,d]of Object.entries(a??{})){const u=r.get(d);u&&l.set(c,u)}return l}async function Yc(t,e,s,i,r,o){try{const a=await bl(s,i,o);En(t,e,{id:i,name:gl(i,r),metadata:a.messages,char:"/"})}catch(a){console.error("[slash] Failed to fetch prompt:",a),fe.error("Failed to load prompt. Please try again.")}}async function fv(t,e,s,i){try{const r=await gu(s,i);En(t,e,{id:i,name:i,metadata:r.contents,char:"/"})}catch(r){console.error("[slash] Failed to fetch resource:",r),fe.error("Failed to load resource. Please try again.")}}const mv=({editor:t,virtualMcpId:e})=>{const s=Mt(),{org:i}=ye(),r=Le({connectionId:e,orgId:i.id}),o=uv(e,i.id),a=S.useRef(o);a.current=o;const l=ct.virtualMcpPrompts(e,i.id),c=ct.virtualMcpResources(e,i.id),d=["slash-mention",i.id,e??"default"],[u,h]=S.useState(null),f=S.useRef(null),m=S.useRef(!1),p=async({item:x,range:b})=>{if(ie("chat_picker_item_selected",{picker:"/",item_kind:x.kind,item_name:x.name}),m.current=!0,!!r)if(x.kind==="prompt"){if(x.arguments&&x.arguments.length>0){h({range:b,item:x});return}const y=ni(x._meta);await Yc(t,b,r,x.name,y)}else x.uri&&await fv(t,b,r,x.uri)},g=async x=>{if(!u||!r)return;const{range:b,item:y}=u,C=ni(y._meta);await Yc(t,b,r,y.name,C,x),h(null)},_=async x=>{const{query:b}=x;if(!r)return[];const[y,C]=await Promise.all([pv(s,l,r),gv(s,c,r)]),k=b.trim().toLowerCase(),w=(y??[]).filter(j=>!k||j.name.toLowerCase().includes(k)||j.title?.toLowerCase().includes(k)||j.description?.toLowerCase().includes(k)).map(j=>({name:j.name,title:j.title,description:j.description,icon:a.current.get(j.name)?.icon??null,kind:"prompt",arguments:j.arguments,_meta:j._meta})),V=(C??[]).filter(j=>!k||j.uri.toLowerCase().includes(k)||j.name?.toLowerCase().includes(k)||j.description?.toLowerCase().includes(k)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}));return[...w,...V]},v=u?.item.kind==="prompt"?{name:u.item.name,arguments:u.item.arguments,description:u.item.description}:null;return n.jsxs(n.Fragment,{children:[n.jsx(ef,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:d,queryFn:_,onSelect:p,onOpenChange:x=>{if(x)f.current=Date.now(),m.current=!1,ie("chat_picker_opened",{picker:"/"});else{const b=f.current;ie("chat_picker_closed",{picker:"/",outcome:m.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),f.current=null}}}),n.jsx(Bl,{prompt:v,setPrompt:()=>h(null),onSubmit:g})]})};async function pv(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>zr(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>zr(s),staleTime:6e4}),i?.prompts??[]}async function gv(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>wn(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>wn(s),staleTime:6e4}),i?.resources??[]}function _v(t){return[mg.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),i1.configure({placeholder:()=>t.current??"Ask anything, / for prompts, @ for agents & resources...",showOnlyWhenEditable:!1}),Gp,Yp]}function tf({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:i=!1,placeholder:r,onSubmit:o,children:a}){const l=S.useRef(o),c=S.useRef(e),d=S.useRef(i),u=S.useRef(r),h=ug({extensions:_v(u),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(f,m)=>m.key==="Enter"&&!m.shiftKey&&d.current?(m.preventDefault(),l.current?.(),!0):!1},onUpdate:({editor:f})=>{c.current(f?.getJSON())}});return S.useEffect(()=>{h?.setEditable(!s)},[h,s]),S.useEffect(()=>{l.current=o},[o]),S.useEffect(()=>{c.current=e},[e]),S.useEffect(()=>{d.current=i},[i]),S.useEffect(()=>{u.current=r},[r]),S.useEffect(()=>{if(h?.isDestroyed)return;const f=JSON.stringify(h?.getJSON()),m=JSON.stringify(t||{type:"doc",content:[]});f!==m&&h.commands.setContent(t||{type:"doc",content:[]})},[h,t]),n.jsx(fg.Provider,{value:{editor:h},children:a})}function sf(t){const e=B.c(26),{disabled:s,virtualMcpId:i,showFileUploader:r,selectedModel:o,onUnsupportedFile:a,ref:l,className:c}=t,d=s===void 0?!1:s,u=r===void 0?!1:r,{editor:h}=ao();let f,m;if(e[0]!==h?(f=()=>({focus:()=>{h?.commands.focus()},clear:()=>{h?.commands.clearContent(!0)},appendText:V=>{if(!h)return;const j=h.state.doc.textContent.trim()==="";h.commands.focus("end"),j||h.commands.insertContent(" "),h.commands.insertContent(V)},syncVoiceText:(V,j)=>{if(h&&(h.commands.setContent(V||{type:"doc",content:[]}),j)){h.commands.focus("end");const R=h.state.doc.textContent.trim().length>0;h.commands.insertContent(R?" "+j:j)}},restoreContent:V=>{h&&h.commands.setContent(V||{type:"doc",content:[]})}}),m=[h],e[0]=h,e[1]=f,e[2]=m):(f=e[1],m=e[2]),S.useImperativeHandle(l??null,f,m),!h)return null;const p=d&&"cursor-not-allowed opacity-70",g=d&&"[&_.ProseMirror]:cursor-not-allowed";let _;e[3]!==c||e[4]!==p||e[5]!==g?(_=X("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",c,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",p,g),e[3]=c,e[4]=p,e[5]=g,e[6]=_):_=e[6];let v;e[7]!==h||e[8]!==_?(v=n.jsx(pg,{editor:h,className:_}),e[7]=h,e[8]=_,e[9]=v):v=e[9];const x=i??null;let b;e[10]!==h||e[11]!==x?(b=n.jsx(S.Suspense,{fallback:null,children:n.jsx(mv,{editor:h,virtualMcpId:x})}),e[10]=h,e[11]=x,e[12]=b):b=e[12];const y=i??null;let C;e[13]!==h||e[14]!==y?(C=n.jsx(S.Suspense,{fallback:null,children:n.jsx(hv,{editor:h,virtualMcpId:y})}),e[13]=h,e[14]=y,e[15]=C):C=e[15];let k;e[16]!==h||e[17]!==a||e[18]!==o||e[19]!==u?(k=u&&o?n.jsx(Gx,{editor:h,selectedModel:o,onUnsupportedFile:a}):null,e[16]=h,e[17]=a,e[18]=o,e[19]=u,e[20]=k):k=e[20];let w;return e[21]!==b||e[22]!==C||e[23]!==k||e[24]!==v?(w=n.jsxs(n.Fragment,{children:[v,b,C,k]}),e[21]=b,e[22]=C,e[23]=k,e[24]=v,e[25]=w):w=e[25],w}function Sa(t){const e=B.c(3),[s]=yi();let i;return e[0]!==s.enableSounds||e[1]!==t?(i=()=>{s.enableSounds&&c_(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=i):i=e[2],i}const xv={name:"switch-005",dataUri:"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0VAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABkAABU4ABMTEx0dHR0nJycnMTExMTs7OztERERETk5OTlhYWFhiYmJibGxsbHZ2dnZ/f39/iYmJiZOTk5OdnZ2dp6enp7GxsbG7u7u7xMTExM7Ozs7Y2NjY4uLi4uzs7Oz29vb2/////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBVYAAAAAAAAVOPCP8KUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAACEwDXvQRAAG8Ii93HtACUCAABAKCJwfaCEHwfeoEAQdEAYygIHBOCAIAgCAJh9QIOg+D5/ygPh/wfB8DuKAgCHyn9QPh/5SCDv+CEHAQdxOD4B27c39tbckkqYbBAYAN9bNJLB+aXAf5wQAKdzxfbmrVIRQ4xNx3HwnoDmLhfMhgJiiw/HREXNCHqjvHEPEG8QjBYlxQNepJAT0kC8ip6JzSWj1TasoG+iyycbf2Uil1ovf1f/oUtR1qP+s1WSBFKoAAU02BDjMhuP/7UsQEgws8bRpd8YABJYPeBf9wCGXTGxBYcw5AJFMFMAmQQAhGAxgLBgHIAMYAAALhgAchipbe/91aU1VV4zcZj1Vf1XgYCIMBNrsBAIGs9/Ue4i/xFPeqCqwViI9/UeLf///rOngdA3OPHFjmOBv+EQnGahgaZxVplmkAH5JadDTQlNCEuGNiWYbCCONWdUJg6HXNazFdu1T+VgaEpOP70exv7f2/4b/yH//2/4cqCX/zWRUrIw+IPNMNlDnjAXQas/I4AzmYifA0tMSCgQDF//tSxBCDSzzi3k/sQwEyCtjJ/rBZAk+Uqj1YhA5YMCAAMwgOUchTkK7OR7LbMl0W1H6SvzG0Q2ZzfKUhnmTobv9DNhS1v7P8h//8Gv8gTRt1jReZ7YEjmMQg9hhwwMycHooasFmZyjcZGBKJD+IwbMCQQLoi+IQXCcIoydKoilI2MWFS5uJdDEu2taRrYI2ZSqKY50pJLv2NfjUAAuQAMfqVQ/T3PDQgMJMeEZ45hJzY6MNoFMxqTj1zNGQKJjAxEsSCBgQJBSIL0mcKYQJfVAn/+1LEGwLKlEKrD3MiYcuMkVa/wABB8Vh6M1q1epbvXwWBURhkyEhWZ/////////////9gjZ/Wt4w+4MNMCpE4TBYQl4w1IHvMDdA2zBngBMwc8COMDhCpDAfgOAAgrBgNYU+YC0FBGAkAMpgWoSCYAGESGBGAKBgXgJOdiOJmMCmNwCYNDJhYRPykRCJhTBnEUzlsjv4UNLj/z97n3Mv/7z1nZqyitYAZIqErIwMwJAqEw0GAAMFptJMaqFwB8CQIWlhuhuDAwNjfuwrQFAYXCf/7UsQVAA+9PTP42gYRdiIu9zBwAPbFUCi0DAhgNcS+7cDwVgM05A9bUDeuQMyE/u3CygVISgZhpIau/9PhdQG2C9DpxZZJmn/dn/Psmt0EFm////l84ThUTopE4VD/9JkubOGasTvN30C20G21qgUCkVCoUCgPMywrPCGly27V5q5t24vl/8jSlSAPCxzNseNCw3oh3NGBu4BZJ5hv7DRSfR/+eWG7nA8IKh2Olv5iz3q5m3//Joxo3JqNyYkSuGt/k6D4DeoBOHmHdl0dkZYA//tSxAUAC4B1Z/2DADEcA17Z/uhI4Yoik/TrZo+ww7UtmpW4LDWu2IacoJKJJeTSM+ZmAYBEiU+ZnnAwCn1VVVV6JUJQVnioKhrgqdKgqGpUFeCp0sDR3ztQNREDRUFioKuxKCpYGQBlRIBk+aLwb8KblGQVDdphPYTUdBOGbVpAaTF6ZdjEV0iRUZRCYkA4oUQDx5zqDugtXvza/7fuNNvfZ+j9v+T/2f//J/4cAAOTpE5K4zksR9MfIB+TDcQTI4gNs1XKAzEFUrGkxABYEBb/+1LEEYNKrEjgT/TCwYYVmUX+mHoKgWhKU5Eiw9SFIRmppw+3fYo4siPhUFeexM8KgIO6wVuPDDy01qeRaVbw357//y3+o8M0pBNlNLCGBzGKwyYw2IIFOE1WNTjRM6x8MlA1AxDhUHTAkEiyKpnbWrLcaOBotBUKbk1pypcWDAIK00AhKLGkUco6q9VWvM53mcaq3tVa8zjTM/tX//EDP//////////XAAmrwAAPoKwcw0ShDCZD/BQlhzinxQdorsOuXTEIC01ZkJyu4k/qPP/7UsQUAEjkrrkvZaPBIRXUoe5QObfMhYKX9RVgTPqCSCaSCaSC0XVdV1f/////6IAlguuAJSiDRNloNBsZg+0+Ts8MMCn81WUTRAlIi+GHECD0y8AWDIqswYsxGOSKVV7MqOni8tkVOip0fZX/////9HrMCbAz2EHGS4GKAAiRAAAYAcDdKd4G6Z/nwYgJ0ZAIgZyC8aPAs/iPBhwMpWDQNARltNS5Y61v//9i8Yl4SkFkIGTkAc0UBrIYLPA4MYBEy+YLMRuY4nhTC3hZA68H//tSxCoAyQC6mY6CkWDJBIsBz/QUrgNmahSzcrYw0/HhfnMAZBojDsgTFkDR5MDkG/DZEbk2FCmowqdqv2TYABiJwqqYjaQRGZ1URZ1DhSsdiHX/GBu0QpzIBNSaLqZ0ARkwFARxMrpt/Eh47mbQAhhU6sisFUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LESoHHJCRaj/dmYAIAQAAQAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsSLg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsShg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",duration:.609,format:"mp3",license:"CC0",author:"Kenney"},vv=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function bv(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center -space-x-1.5",children:vv.map(yv)}),t[0]=e):e=t[0],e}function yv(t){return n.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function Sv(t){const e=B.c(129),{disabled:s,onOpenConnections:i,virtualMcpId:r}=t,[o,a]=S.useState(!1),l=Sa(xv),{org:c}=ye(),{editor:d}=ao();let u;e[0]!==c.id||e[1]!==r?(u={connectionId:r,orgId:c.id},e[0]=c.id,e[1]=r,e[2]=u):u=e[2];const h=Le(u);let f;e[3]!==c.id||e[4]!==r?(f=ct.virtualMcpPrompts(r,c.id),e[3]=c.id,e[4]=r,e[5]=f):f=e[5];const m=f;let p;e[6]!==h?(p=()=>zr(h),e[6]=h,e[7]=p):p=e[7];const g=o&&!!h;let _;e[8]!==m||e[9]!==p||e[10]!==g?(_={queryKey:m,queryFn:p,staleTime:6e4,enabled:g},e[8]=m,e[9]=p,e[10]=g,e[11]=_):_=e[11];const{data:v,isLoading:x}=Wi(_);let b;e[12]!==v?.prompts?(b=v?.prompts??[],e[12]=v?.prompts,e[13]=b):b=e[13];const y=b,[C,k]=S.useState(null),{credentialId:w,imageModel:V,setImageModel:j,deepResearchModel:R,setDeepResearchModel:T,chatMode:I,setChatMode:A,simpleModeEnabled:N}=ai(),E=I==="plan",[M,L]=S.useState(!1),[D,P]=S.useState(!1),{models:O,isLoading:$}=uu(M||D?w??void 0:void 0);let z,W,F,K,H,U,Y,q,G,ee,Z,J,se;if(e[14]!==C||e[15]!==O||e[16]!==I||e[17]!==h||e[18]!==R||e[19]!==s||e[20]!==d||e[21]!==V||e[22]!==M||e[23]!==$||e[24]!==E||e[25]!==i||e[26]!==o||e[27]!==l||e[28]!==D||e[29]!==A||e[30]!==T||e[31]!==j||e[32]!==N){const te=O.filter(Vv),ue=O.filter(wv);let Ve;e[46]!==I||e[47]!==E||e[48]!==l||e[49]!==A?(Ve=()=>{l();const _e=E?"default":"plan";ie("chat_mode_changed",{from_mode:I,to_mode:_e,source:"tools_popover"}),A(_e),a(!1)},e[46]=I,e[47]=E,e[48]=l,e[49]=A,e[50]=Ve):Ve=e[50];const Ee=Ve;let Te;e[51]!==i?(Te=()=>{i(),a(!1)},e[51]=i,e[52]=Te):Te=e[52],F=Te;let be;e[53]!==h||e[54]!==d?(be=async(_e,zt)=>{if(!d||!h)return;const $t=ni(_e._meta),us={from:d.state.selection.from,to:d.state.selection.to};try{const tn=await bl(h,_e.name,zt);En(d,us,{id:_e.name,name:gl(_e.name,$t),metadata:tn.messages,char:"/"})}catch{fe.error("Failed to load prompt. Please try again.")}},e[53]=h,e[54]=d,e[55]=be):be=e[55];const je=be;let $e;e[56]!==je?($e=async _e=>{a(!1);const zt=!!(_e.arguments&&_e.arguments.length>0);if(ie("chat_prompt_inserted",{prompt_name:_e.name,with_arguments:zt}),zt){k(_e);return}await je(_e)},e[56]=je,e[57]=$e):$e=e[57],H=$e;let Ge;e[58]!==C||e[59]!==je?(Ge=async _e=>{C&&(await je(C,_e),k(null))},e[58]=C,e[59]=je,e[60]=Ge):Ge=e[60],K=Ge;let ge;e[61]!==l||e[62]!==j?(ge=_e=>{l(),ie("chat_image_model_selected",{model_id:_e.modelId,model_title:_e.title,provider:_e.providerId??null}),j(_e),a(!1)},e[61]=l,e[62]=j,e[63]=ge):ge=e[63];const Ae=ge;let Ze;e[64]!==l||e[65]!==T?(Ze=_e=>{l(),ie("chat_search_model_selected",{model_id:_e.modelId,model_title:_e.title,provider:_e.providerId??null}),T(_e),a(!1)},e[64]=l,e[65]=T,e[66]=Ze):Ze=e[66];const Ct=Ze;let Be;e[67]!==I||e[68]!==l||e[69]!==A?(Be=()=>{l();const _e=I==="gen-image"?"default":"gen-image";ie("chat_mode_changed",{from_mode:I,to_mode:_e,source:"tools_popover"}),A(_e),a(!1)},e[67]=I,e[68]=l,e[69]=A,e[70]=Be):Be=e[70];const Kt=Be;let kt;e[71]!==I||e[72]!==l||e[73]!==A?(kt=()=>{l();const _e=I==="web-search"?"default":"web-search";ie("chat_mode_changed",{from_mode:I,to_mode:_e,source:"tools_popover"}),A(_e),a(!1)},e[71]=I,e[72]=l,e[73]=A,e[74]=kt):kt=e[74];const Ie=kt,Me=I==="gen-image",Ye=I==="web-search";W=As,q=o,e[75]!==I||e[76]!==o?(G=_e=>{_e&&!o&&ie("chat_tools_popover_opened",{chat_mode:I}),a(_e)},e[75]=I,e[76]=o,e[77]=G):G=e[77];let qt,xt;e[78]===Symbol.for("react.memo_cache_sentinel")?(qt=n.jsx(Qh,{size:14}),xt=n.jsx("span",{className:"hidden sm:inline",children:"Tools"}),e[78]=qt,e[79]=xt):(qt=e[78],xt=e[79]),e[80]!==s?(ee=n.jsx(Es,{asChild:!0,children:n.jsxs(oe,{type:"button",variant:"ghost",size:"default",disabled:s,className:"text-muted-foreground hover:text-foreground",children:[qt,xt]})}),e[80]=s,e[81]=ee):ee=e[81],z=Is,Z="start",J="w-52 p-1.5";const vt=E&&"text-violet-600 dark:text-violet-400";let bt;e[82]!==vt?(bt=X(vt),e[82]=vt,e[83]=bt):bt=e[83];const bs=E&&"text-violet-500";let Fe;e[84]!==bs?(Fe=X(bs),e[84]=bs,e[85]=Fe):Fe=e[85];let jt;e[86]!==Fe?(jt=n.jsx(au,{size:16,className:Fe}),e[86]=Fe,e[87]=jt):jt=e[87];let Nt;e[88]===Symbol.for("react.memo_cache_sentinel")?(Nt=n.jsx("span",{className:"flex-1",children:"Plan mode"}),e[88]=Nt):Nt=e[88];let wt;e[89]!==E?(wt=E&&n.jsx("span",{className:"text-xs text-violet-500 font-medium",children:"On"}),e[89]=E,e[90]=wt):wt=e[90],e[91]!==Ee||e[92]!==bt||e[93]!==jt||e[94]!==wt?(se=n.jsxs(at,{onClick:Ee,className:bt,children:[jt,Nt,wt]}),e[91]=Ee,e[92]=bt,e[93]=jt,e[94]=wt,e[95]=se):se=e[95],U=N?n.jsxs(at,{onClick:Kt,className:X(Me&&"text-pink-600 dark:text-pink-400"),children:[n.jsx(ga,{size:16,className:X(Me&&"text-pink-500")}),n.jsx("span",{className:"flex-1",children:"Create image"}),Me&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}):n.jsxs(kr,{open:M,onOpenChange:L,children:[n.jsxs("div",{className:"flex items-center rounded-lg",children:[n.jsxs(at,{onClick:Kt,disabled:!V,className:X("flex-1 rounded-r-none pr-1",Me&&"text-pink-600 dark:text-pink-400"),children:[n.jsx(ga,{size:16,className:X(Me&&"text-pink-500")}),n.jsx("span",{className:"flex-1",children:"Create image"}),Me&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),n.jsx(pc,{className:X("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:n.jsx(Rn,{size:14})})]}),n.jsx(jr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:$?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(De,{size:14,className:"animate-spin"}),"Loading models…"]}):te.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No image models available"}):te.map(_e=>{const zt=V?.modelId===_e.modelId,$t=Cc(_e),us=_e.title.includes(": ")?_e.title.split(": ").slice(1).join(": "):_e.title;return n.jsxs(at,{onClick:()=>Ae(_e),className:"flex items-center gap-2",children:[n.jsx("img",{src:$t,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),n.jsx("span",{className:"flex-1 text-sm truncate",children:us}),zt&&n.jsx(Jt,{size:14,className:"text-pink-500 shrink-0"})]},_e.modelId)})})]}),Y=N?n.jsxs(at,{onClick:Ie,className:X(Ye&&"text-blue-600 dark:text-blue-400"),children:[n.jsx(Pi,{size:16,className:X(Ye&&"text-blue-500")}),n.jsx("span",{className:"flex-1",children:"Web search"}),Ye&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}):R&&n.jsxs(kr,{open:D,onOpenChange:P,children:[n.jsxs("div",{className:"flex items-center rounded-lg",children:[n.jsxs(at,{onClick:Ie,className:X("flex-1 rounded-r-none pr-1",Ye&&"text-blue-600 dark:text-blue-400"),children:[n.jsx(Pi,{size:16,className:X(Ye&&"text-blue-500")}),n.jsx("span",{className:"flex-1",children:"Web search"}),Ye&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),n.jsx(pc,{className:X("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:n.jsx(Rn,{size:14})})]}),n.jsx(jr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:$?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(De,{size:14,className:"animate-spin"}),"Loading models…"]}):ue.map(_e=>{const zt=R?.modelId===_e.modelId,$t=Cc(_e),us=_e.title.includes(": ")?_e.title.split(": ").slice(1).join(": "):_e.title;return n.jsxs(at,{onClick:()=>Ct(_e),className:"flex items-center gap-2",children:[n.jsx("img",{src:$t,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),n.jsx("span",{className:"flex-1 text-sm truncate",children:us}),zt&&n.jsx(Jt,{size:14,className:"text-blue-500 shrink-0"})]},_e.modelId)})})]}),e[14]=C,e[15]=O,e[16]=I,e[17]=h,e[18]=R,e[19]=s,e[20]=d,e[21]=V,e[22]=M,e[23]=$,e[24]=E,e[25]=i,e[26]=o,e[27]=l,e[28]=D,e[29]=A,e[30]=T,e[31]=j,e[32]=N,e[33]=z,e[34]=W,e[35]=F,e[36]=K,e[37]=H,e[38]=U,e[39]=Y,e[40]=q,e[41]=G,e[42]=ee,e[43]=Z,e[44]=J,e[45]=se}else z=e[33],W=e[34],F=e[35],K=e[36],H=e[37],U=e[38],Y=e[39],q=e[40],G=e[41],ee=e[42],Z=e[43],J=e[44],se=e[45];let ne;e[96]===Symbol.for("react.memo_cache_sentinel")?(ne=n.jsxs(Gh,{className:"gap-2",children:[n.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),n.jsx("span",{className:"flex-1",children:"Prompts"})]}),e[96]=ne):ne=e[96];let ce;e[97]!==H||e[98]!==x||e[99]!==y?(ce=x?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(De,{size:14,className:"animate-spin"}),"Loading prompts…"]}):y.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):y.map(te=>n.jsxs(at,{onClick:()=>H(te),className:"flex flex-col items-start gap-0.5",children:[n.jsx("span",{className:"font-medium text-sm capitalize",children:te.title||oo(te.name,ni(te._meta))}),te.description&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:te.description})]},te.name)),e[97]=H,e[98]=x,e[99]=y,e[100]=ce):ce=e[100];let xe;e[101]!==ce?(xe=n.jsxs(kr,{children:[ne,n.jsx(jr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:ce})]}),e[101]=ce,e[102]=xe):xe=e[102];let ae,he;e[103]===Symbol.for("react.memo_cache_sentinel")?(ae=n.jsx(qg,{size:16}),he=n.jsx("span",{className:"flex-1",children:"Connections"}),e[103]=ae,e[104]=he):(ae=e[103],he=e[104]);let pe;e[105]===Symbol.for("react.memo_cache_sentinel")?(pe=n.jsx(S.Suspense,{children:n.jsx(bv,{})}),e[105]=pe):pe=e[105];let me;e[106]!==F?(me=n.jsxs(at,{onClick:F,children:[ae,he,pe]}),e[106]=F,e[107]=me):me=e[107];let we;e[108]!==z||e[109]!==U||e[110]!==Y||e[111]!==xe||e[112]!==me||e[113]!==Z||e[114]!==J||e[115]!==se?(we=n.jsxs(z,{align:Z,className:J,children:[se,U,Y,xe,me]}),e[108]=z,e[109]=U,e[110]=Y,e[111]=xe,e[112]=me,e[113]=Z,e[114]=J,e[115]=se,e[116]=we):we=e[116];let ve;e[117]!==W||e[118]!==q||e[119]!==G||e[120]!==ee||e[121]!==we?(ve=n.jsxs(W,{open:q,onOpenChange:G,children:[ee,we]}),e[117]=W,e[118]=q,e[119]=G,e[120]=ee,e[121]=we,e[122]=ve):ve=e[122];let de;e[123]!==C||e[124]!==K?(de=n.jsx(Bl,{prompt:C,setPrompt:k,onSubmit:K}),e[123]=C,e[124]=K,e[125]=de):de=e[125];let Re;return e[126]!==ve||e[127]!==de?(Re=n.jsxs(n.Fragment,{children:[ve,de]}),e[126]=ve,e[127]=de,e[128]=Re):Re=e[128],Re}function wv(t){const e=t.modelId.toLowerCase().replace(/[^a-z0-9]/g,"");return e.includes("sonar")||e.includes("deepresearch")}function Vv(t){return t.capabilities?.includes("image")}function Cv({open:t,onOpenChange:e,onCreated:s}){const{org:i}=ye(),{data:r}=St.useSession(),{stdioEnabled:o}=hp(),a=Ms(),l=po(),c=vu(),u=bu(c,"").items,h=qi({resolver:Un(h_),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),f=h.watch("ui_type"),m=h.watch("connection_url"),p=h.watch("npx_package"),g=dr({uiType:f,connectionUrl:m??"",npxPackage:p??""})??kc({uiType:f,connectionUrl:m??"",registryItems:u}),_=w=>{const V=w.trim();if(!V)return;const j=!!h.formState.dirtyFields.title,R=!!h.formState.dirtyFields.description,T=!!h.formState.dirtyFields.env_vars,I=N=>{if(N&&(!j&&!h.getValues("title").trim()&&N.title&&h.setValue("title",N.title,{shouldDirty:!1}),!R&&!(h.getValues("description")??"").trim()&&N.description&&h.setValue("description",N.description,{shouldDirty:!1}),!T&&N.envVarKeys?.length)){const E=h.getValues("env_vars")??[],M=new Set(E.map(D=>D.key)),L=N.envVarKeys.filter(D=>!M.has(D));L.length>0&&h.setValue("env_vars",[...E,...L.map(D=>({key:D,value:""}))],{shouldDirty:!0})}},A=f_(V);if(A&&o){h.setValue("ui_type","NPX",{shouldDirty:!0}),h.setValue("npx_package",A.packageName,{shouldDirty:!0}),h.setValue("connection_url","",{shouldDirty:!0}),h.setValue("connection_token",null,{shouldDirty:!0}),I(dr({uiType:"NPX",npxPackage:A.packageName}));return}if(V.startsWith("http://")||V.startsWith("https://")){const N=f==="HTTP"||f==="SSE"||f==="Websocket"?f:"HTTP";h.setValue("ui_type",N,{shouldDirty:!0}),h.setValue("connection_url",V,{shouldDirty:!0}),I(dr({uiType:N,connectionUrl:V})??kc({uiType:N,connectionUrl:V,registryItems:u}));return}f==="NPX"&&I(dr({uiType:"NPX",npxPackage:V}))},v=w=>{w||h.reset(),e(w)},x=async w=>{let V,j=null,R=null,T=null;w.ui_type==="NPX"?(V="STDIO",j="",T=m_(w.npx_package||"",w.env_vars||[])):w.ui_type==="STDIO"?(V="STDIO",j="",T=p_(w.stdio_command||"",w.stdio_args||"",w.stdio_cwd,w.env_vars||[])):(V=w.ui_type,j=w.connection_url||"",R=w.connection_token||null);const I=Su("conn");try{await l.create.mutateAsync({id:I,title:w.title,description:w.description||null,connection_type:V,connection_url:j,connection_token:R,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:r?.user?.id||"system",organization_id:i.id,icon:w.icon??null,app_name:null,app_id:null,connection_headers:T,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),h.reset(),e(!1),s?.(I)}catch{fe.error("Failed to create connection")}},b="Create Connection",y="Create a custom connection in your organization. Fill in the details below.",C=h.formState.isSubmitting?"Saving...":"Create Connection",k=n.jsxs("div",{className:"grid gap-4",children:[n.jsx(It,{control:h.control,name:"ui_type",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Type *"}),n.jsxs(ei,{value:w.value,onValueChange:w.onChange,children:[n.jsx(Tt,{children:n.jsx(ti,{children:n.jsx(si,{})})}),n.jsxs(Zs,{children:[n.jsx(Ht,{value:"HTTP",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Pi,{className:"w-4 h-4"}),"HTTP"]})}),n.jsx(Ht,{value:"SSE",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Pi,{className:"w-4 h-4"}),"SSE"]})}),n.jsx(Ht,{value:"Websocket",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Pi,{className:"w-4 h-4"}),"Websocket"]})}),o&&n.jsxs(n.Fragment,{children:[n.jsx(Ht,{value:"NPX",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Nr,{className:"w-4 h-4"}),"NPX Package"]})}),n.jsx(Ht,{value:"STDIO",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(yl,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),n.jsx(Dt,{})]})}),f==="NPX"&&n.jsx(It,{control:h.control,name:"npx_package",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"NPM Package *"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"@perplexity-ai/mcp-server",...w,value:w.value??"",onPaste:V=>{const j=V.clipboardData.getData("text");j&&(V.preventDefault(),h.setValue("npx_package",j.trim(),{shouldDirty:!0}),_(j))},onBlur:V=>{_(V.target.value),w.onBlur()}})}),n.jsx(Dt,{})]})}),f==="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[n.jsx(It,{control:h.control,name:"stdio_command",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Command *"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"node, bun, python...",...w,value:w.value??""})}),n.jsx(Dt,{})]})}),n.jsx(It,{control:h.control,name:"stdio_args",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Arguments"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"arg1 arg2 --flag value",...w,value:w.value??""})}),n.jsx(Dt,{})]})})]}),n.jsx(It,{control:h.control,name:"stdio_cwd",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Working Directory"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"/path/to/project (optional)",...w,value:w.value??""})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),n.jsx(Dt,{})]})})]}),(f==="NPX"||f==="STDIO")&&n.jsx(It,{control:h.control,name:"env_vars",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Environment Variables"}),n.jsx(Tt,{children:n.jsx(u_,{value:w.value??[],onChange:w.onChange})}),n.jsx(Dt,{})]})}),f!=="NPX"&&f!=="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsx(It,{control:h.control,name:"connection_url",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"URL *"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"https://example.com/mcp",...w,value:w.value??"",onPaste:V=>{const j=V.clipboardData.getData("text");j&&(V.preventDefault(),h.setValue("connection_url",j.trim(),{shouldDirty:!0}),_(j))},onBlur:V=>{_(V.target.value),w.onBlur()}})}),n.jsx(Dt,{})]})}),n.jsx(It,{control:h.control,name:"connection_token",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:g?.token?.label??"Token (optional)"}),n.jsx(Tt,{children:n.jsx(gt,{type:"password",placeholder:g?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...w,value:w.value??""})}),g?.token?.helperText&&n.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.id==="github"&&n.jsxs(n.Fragment,{children:[" ","·"," ",n.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),n.jsx(Dt,{})]})})]}),n.jsx(It,{control:h.control,name:"title",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Name *"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"My Connection",...w})}),n.jsx(Dt,{})]})}),n.jsx(It,{control:h.control,name:"description",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Description"}),n.jsx(Tt,{children:n.jsx(_a,{placeholder:"A brief description of this connection",rows:3,...w,value:w.value??""})}),n.jsx(Dt,{})]})})]});return a?n.jsx(Ci,{open:t,onOpenChange:v,children:n.jsxs(Vi,{className:"max-h-[90vh]",children:[n.jsx(co,{className:"pb-2",children:n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"flex-1 text-left",children:[n.jsx(wi,{children:b}),n.jsx(gg,{className:"mt-1",children:y})]}),n.jsx(_g,{asChild:!0,children:n.jsx(oe,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:n.jsx(ri,{size:16})})})]})}),n.jsx(Bi,{...h,children:n.jsxs("form",{onSubmit:h.handleSubmit(x),children:[n.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:k}),n.jsx(xg,{children:n.jsx(oe,{type:"submit",disabled:h.formState.isSubmitting,className:"w-full",children:C})})]})})]})}):n.jsx(ss,{open:t,onOpenChange:v,children:n.jsxs(ts,{className:"sm:max-w-[525px]",children:[n.jsxs(hs,{children:[n.jsx(ds,{children:b}),n.jsx(lo,{children:y})]}),n.jsx(Bi,{...h,children:n.jsxs("form",{onSubmit:h.handleSubmit(x),children:[n.jsx("div",{className:"py-4",children:k}),n.jsxs(xl,{children:[n.jsx(oe,{type:"button",variant:"outline",onClick:()=>v(!1),children:"Cancel"}),n.jsx(oe,{type:"submit",disabled:h.formState.isSubmitting,className:"min-w-40",children:C})]})]})})]})})}function kv(t){const e=B.c(79),{mode:s,agentId:i,addedConnectionIds:r,onAdd:o,onCloneAndAdd:a,onConnectAndAdd:l,connectingItemId:c,search:d,onCreateConnection:u,onBrowseNavigate:h,defaultTab:f}=t,m=s===void 0?"add":s,p=f===void 0?"connected":f,{org:g}=ye(),_=S.useDeferredValue(d),v=d!==_;let x;e[0]!==_?(x=_.toLowerCase(),e[0]=_,e[1]=x):x=e[1];const b=x;let y;e[2]!==p?(y=ge=>ge??p,e[2]=p,e[3]=y):y=e[3];const[C,k]=ml(pl.connectionsTab(g.slug)+(p==="all"?":home-modal":":agent-modal"),y);let w;e[4]!==C||e[5]!==k?(w=ge=>{ge!==C&&ie("connections_dialog_tab_changed",{to_tab:ge}),k(ge)},e[4]=C,e[5]=k,e[6]=w):w=e[6];const V=w;let j;e[7]!==g.id?(j={connectionId:Pt,orgId:g.id},e[7]=g.id,e[8]=j):j=e[8];const R=Le(j);let T,I,A;if(e[9]!==R||e[10]!==_||e[11]!==g.id){A=_?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:_.trim()},{field:["description"],operator:"contains",value:_.trim()}]}:void 0;const ge={...A&&{where:A},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},Ae=JSON.stringify(ge);I=g_,T=ct.collectionListInfinite(R,g.id,"","CONNECTIONS",Ae),e[9]=R,e[10]=_,e[11]=g.id,e[12]=T,e[13]=I,e[14]=A}else T=e[12],I=e[13],A=e[14];let N;e[15]!==R||e[16]!==A?(N=async ge=>{const{pageParam:Ae}=ge,Ze=Ae===void 0?0:Ae;return(await R.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...A&&{where:A},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:Ze}})).structuredContent},e[15]=R,e[16]=A,e[17]=N):N=e[17];let E;e[18]!==T||e[19]!==N?(E={queryKey:T,queryFn:N,initialPageParam:0,getNextPageParam:Rv,staleTime:3e4},e[18]=T,e[19]=N,e[20]=E):E=e[20];const{data:M,fetchNextPage:L,hasNextPage:D,isFetchingNextPage:P}=I(E),O=M?.pages.flatMap(Iv)??[],$=d_(O),z=new Set(O.filter(Ev).map(Av)),W=vu(),F=bu(W,_),K=jc(F.loadMore,F.hasMore,F.isLoadingMore),H=jc(L,D??!1,P),U=C==="all"||!!b,Y=U?F.items.filter(ge=>{const Ae=S_(ge);return!(Ae&&z.has(Ae))}):[],q=Y.filter(Nv),G=Y.filter(jv);let ee;e[21]!==r?(ee=ge=>ge.some(Ae=>r.has(Ae.id)),e[21]=r,e[22]=ee):ee=e[22];const Z=ee;let J;e[23]!==r||e[24]!==i||e[25]!==c||e[26]!==Z||e[27]!==m||e[28]!==o||e[29]!==h||e[30]!==a?(J=(ge,Ae,Ze,Ct,Be)=>{const Kt=Z(Be),kt=Be.find(Me=>!r.has(Me.id)),Ie=Be[0];if(m==="browse"){const Me=_u(Ie);return n.jsx(To,{connection:{title:Ae,icon:Ze,description:Be.length>1?`${Be.length} instances`:Ct??void 0},fallbackIcon:n.jsx(Nr,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs(Ec,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(Jt,{size:11})," Connected"]}),onClick:()=>{ie("connection_browse_clicked",{app_name:Ie.app_name??null,connection_id:Ie.id,instances_count:Be.length}),h?.(Me)}},ge)}return n.jsx(To,{connection:{title:Ae,icon:Ze,description:Ct},fallbackIcon:n.jsx(Nr,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[Kt&&n.jsxs(Ec,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(Jt,{size:11})," Added"]}),n.jsx(oe,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Me=>{Me.stopPropagation(),kt?(ie("connection_add_clicked",{action:"use_existing",app_name:Ie.app_name??null,connection_id:kt.id}),i&&ie("agent_connection_attached",{agent_id:i,connection_id:kt.id,app_name:Ie.app_name??null,mode:"existing"}),o(kt.id)):(ie("connection_add_clicked",{action:"clone",app_name:Ie.app_name??null,base_connection_id:Ie.id}),a(Ie))},children:"Add"})]})},ge)},e[23]=r,e[24]=i,e[25]=c,e[26]=Z,e[27]=m,e[28]=o,e[29]=h,e[30]=a,e[31]=J):J=e[31];const se=J;let ne;e[32]!==c||e[33]!==m||e[34]!==l?(ne=ge=>{const Ae=ge._meta?.["mcp.mesh"],Ze=Ae?.friendlyName||Ae?.friendly_name||ge.server?.title||ge.title||ge.server?.name||ge.name||ge.id||"",Ct=ge.server?.description||ge.description||null,Be=ge.server?.icons?.[0]?.src||V_(ge.server?.repository)||null;return n.jsx(To,{connection:{title:Ze,description:Ct,icon:Be},fallbackIcon:n.jsx(Nr,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsx(oe,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Kt=>{Kt.stopPropagation(),ie("connection_add_clicked",{action:"connect_new",registry_item_id:ge.id,app_name:ge._meta?.["mcp.mesh"]?.friendlyName||ge.server?.name||ge.name||null}),l(ge)},children:c===ge.id?n.jsx(De,{size:14,className:"animate-spin"}):m==="browse"?"Connect":"Add"})},`catalog-${ge.id}`)},e[32]=c,e[33]=m,e[34]=l,e[35]=ne):ne=e[35];const ce=ne;let xe;e[36]!==C||e[37]!==V||e[38]!==u||e[39]!==b?(xe=!b&&n.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[n.jsx(yu,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:C,onTabChange:ge=>V(ge)}),n.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{ie("connections_dialog_custom_clicked"),u()},children:[n.jsx(Qt,{size:12}),"Custom Connection"]})]}),e[36]=C,e[37]=V,e[38]=u,e[39]=b,e[40]=xe):xe=e[40];const ae=v&&"opacity-50 pointer-events-none";let he;e[41]!==ae?(he=X("flex-1 overflow-auto p-5 transition-opacity duration-150",ae),e[41]=ae,e[42]=he):he=e[42];const pe="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let me;e[43]!==se?(me=ge=>{if(ge.type==="group")return se(ge.key,ge.title,ge.icon,null,ge.connections);const Ae=ge.connection;return se(Ae.id,Ae.title,Ae.icon,Ae.description??null,[Ae])},e[43]=se,e[44]=me):me=e[44];const we=$.map(me);let ve;e[45]!==H?(ve=n.jsx("div",{ref:H,className:"col-span-full h-1"}),e[45]=H,e[46]=ve):ve=e[46];let de;e[47]!==P?(de=P&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(De,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=P,e[48]=de):de=e[48];const Re=U&&q.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx(Gg,{size:13,className:"text-muted-foreground shrink-0"}),n.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),te=U&&q.map(ce),ue=U&&G.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),Ve=U&&G.map(ce);let Ee;e[49]!==K||e[50]!==W||e[51]!==U?(Ee=U&&W.length>0&&n.jsx("div",{ref:K,className:"col-span-full h-1"}),e[49]=K,e[50]=W,e[51]=U,e[52]=Ee):Ee=e[52];let Te;e[53]!==F.isLoadingMore||e[54]!==U?(Te=U&&F.isLoadingMore&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(De,{size:24,className:"animate-spin text-muted-foreground"})}),e[53]=F.isLoadingMore,e[54]=U,e[55]=Te):Te=e[55];let be;e[56]!==we||e[57]!==ve||e[58]!==de||e[59]!==Re||e[60]!==te||e[61]!==ue||e[62]!==Ve||e[63]!==Ee||e[64]!==Te?(be=n.jsxs("div",{className:pe,children:[we,ve,de,Re,te,ue,Ve,Ee,Te]}),e[56]=we,e[57]=ve,e[58]=de,e[59]=Re,e[60]=te,e[61]=ue,e[62]=Ve,e[63]=Ee,e[64]=Te,e[65]=be):be=e[65];let je;e[66]!==C||e[67]!==$.length||e[68]!==G||e[69]!==d||e[70]!==q?(je=$.length===0&&q.length===0&&G.length===0&&n.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:d?`No connections match "${d}"`:C==="connected"?"No connections yet":"No connections available"}),e[66]=C,e[67]=$.length,e[68]=G,e[69]=d,e[70]=q,e[71]=je):je=e[71];let $e;e[72]!==he||e[73]!==be||e[74]!==je?($e=n.jsxs("div",{className:he,children:[be,je]}),e[72]=he,e[73]=be,e[74]=je,e[75]=$e):$e=e[75];let Ge;return e[76]!==xe||e[77]!==$e?(Ge=n.jsxs(n.Fragment,{children:[xe,$e]}),e[76]=xe,e[77]=$e,e[78]=Ge):Ge=e[78],Ge}function jv(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function Nv(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function Av(t){return t.app_name}function Ev(t){return t.app_name}function Iv(t){return t?.items??[]}function Rv(t,e){if(t?.hasMore)return e.reduce(Tv,0)}function Tv(t,e){return t+(e?.items?.length??0)}function Ul({open:t,onOpenChange:e,defaultTab:s,initialSearch:i="",...r}){const o=r.mode??"add",a="agentId"in r?r.agentId:void 0,l="addedConnectionIds"in r?r.addedConnectionIds??new Set:new Set,c="onAdd"in r&&r.onAdd?r.onAdd:V=>{},d=(V,j,R)=>{a&&ie("agent_connection_attached",{agent_id:a,connection_id:V,app_name:j,mode:R})},[u,h]=S.useState(null),[f,m]=S.useState(i),[p,g]=S.useState(!1),{org:_}=ye(),{data:v}=St.useSession(),x=po(),b=Mt(),y=qe(),C=V=>{e(!1),y({to:"/$org/settings/connections/$appSlug",params:{org:_.slug,appSlug:V}})},k=async V=>{h(V.app_name??V.id);try{const R=`${V.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,I=(await x.create.mutateAsync({title:R,description:V.description??null,connection_type:V.connection_type,connection_url:V.connection_url??null,connection_token:null,icon:V.icon??null,app_name:V.app_name??null,app_id:V.app_id??null,connection_headers:V.connection_headers??null})).id,A=new URL(`/mcp/${I}`,window.location.origin),N=await bn({url:A.href,token:null});if(N.supportsOAuth&&!N.isAuthenticated){const{token:E,tokenInfo:M,error:L}=await wr({connectionId:I,scope:"offline_access"});if(L||!E){ie("connection_oauth_failed",{connection_id:I,flow:"clone",error:L??"no_token"}),fe.error(`Authentication failed: ${L??"no token received"}`),await x.delete.mutateAsync(I);return}if(ie("connection_oauth_succeeded",{connection_id:I,flow:"clone"}),M)try{(await fetch(`/api/connections/${I}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:M.accessToken,refreshToken:M.refreshToken,expiresIn:M.expiresIn,scope:M.scope,clientId:M.clientId,clientSecret:M.clientSecret,tokenEndpoint:M.tokenEndpoint})})).ok?await x.update.mutateAsync({id:I,data:{}}):await x.update.mutateAsync({id:I,data:{connection_token:E}})}catch{await x.update.mutateAsync({id:I,data:{connection_token:E}})}else await x.update.mutateAsync({id:I,data:{connection_token:E}});await b.invalidateQueries({queryKey:ct.isMCPAuthenticated(A.href,null)})}d(I,V.app_name??null,"clone"),c(I)}catch(j){console.error("Failed to add connection:",j),fe.error("Failed to add connection")}finally{h(null)}},w=async V=>{if(!(!_||!v?.user?.id)){h(V.id);try{const j=w_(V,_.id,v.user.id,{remoteIndex:0}),R=j.connection_type==="STDIO",T=!!j.connection_url,I=R&&j.connection_headers&&typeof j.connection_headers=="object"&&"command"in j.connection_headers;if(!T&&!I){fe.error("This MCP Server cannot be connected: no connection method available"),h(null);return}const{id:A}=await x.create.mutateAsync(j),N=new URL(`/mcp/${A}`,window.location.origin),E=await bn({url:N.href,token:null});if(E.supportsOAuth&&!E.isAuthenticated){const{token:M,tokenInfo:L,error:D}=await wr({connectionId:A,scope:"offline_access"});if(D||!M){ie("connection_oauth_failed",{connection_id:A,flow:"connect_new",error:D??"no_token"}),fe.error(`Authentication failed: ${D??"no token received"}`),d(A,j.app_name??null,"new"),c(A);return}if(ie("connection_oauth_succeeded",{connection_id:A,flow:"connect_new"}),L)try{(await fetch(`/api/connections/${A}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:L.accessToken,refreshToken:L.refreshToken,expiresIn:L.expiresIn,scope:L.scope,clientId:L.clientId,clientSecret:L.clientSecret,tokenEndpoint:L.tokenEndpoint})})).ok?await x.update.mutateAsync({id:A,data:{}}):await x.update.mutateAsync({id:A,data:{connection_token:M}})}catch{await x.update.mutateAsync({id:A,data:{connection_token:M}})}else await x.update.mutateAsync({id:A,data:{connection_token:M}});await b.invalidateQueries({queryKey:ct.isMCPAuthenticated(N.href,null)}),fe.success("Connected and authenticated")}else fe.success("Connected");d(A,j.app_name??null,"new"),c(A)}catch(j){console.error("Failed to connect:",j),fe.error("Failed to connect")}finally{h(null)}}};return n.jsxs(ss,{open:t,onOpenChange:e,children:[n.jsxs(ts,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[n.jsx(hs,{className:"px-6 pt-5 pb-0 shrink-0",children:n.jsx(ds,{className:"text-base font-semibold",children:o==="browse"?"Connections":"Add Connection"})}),n.jsx("div",{className:"pt-3 shrink-0",children:n.jsx(Uh,{value:f,onChange:m,placeholder:"Search connections..."})}),n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:24,className:"animate-spin text-muted-foreground"})}),children:n.jsx(kv,{mode:o,agentId:a,addedConnectionIds:l,onAdd:c,onCloneAndAdd:k,onConnectAndAdd:w,connectingItemId:u,search:f,onCreateConnection:()=>g(!0),onBrowseNavigate:C,defaultTab:s})})]}),n.jsx(Cv,{open:p,onOpenChange:g,onCreated:async V=>{g(!1);const j=new URL(`/mcp/${V}`,window.location.origin),R=await bn({url:j.href,token:null});if(R.supportsOAuth&&!R.isAuthenticated){const{token:T,tokenInfo:I,error:A}=await wr({connectionId:V,scope:"offline_access"});if(A||!T){ie("connection_oauth_failed",{connection_id:V,flow:"custom_create",error:A??"no_token"}),fe.error(`Authentication failed: ${A??"no token received"}`),await x.delete.mutateAsync(V);return}if(ie("connection_oauth_succeeded",{connection_id:V,flow:"custom_create"}),I)try{(await fetch(`/api/connections/${V}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:I.accessToken,refreshToken:I.refreshToken,expiresIn:I.expiresIn,scope:I.scope,clientId:I.clientId,clientSecret:I.clientSecret,tokenEndpoint:I.tokenEndpoint})})).ok?await x.update.mutateAsync({id:V,data:{}}):await x.update.mutateAsync({id:V,data:{connection_token:T}})}catch{await x.update.mutateAsync({id:V,data:{connection_token:T}})}else await x.update.mutateAsync({id:V,data:{connection_token:T}});await b.invalidateQueries({queryKey:ct.isMCPAuthenticated(j.href,null)})}d(V,null,"custom"),c(V),e(!1)}})]})}const Dv=[{src:"/connections/github.png",name:"GitHub"},{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/linear.png",name:"Linear"},{src:"/connections/shopify.png",name:"Shopify"},{src:"/connections/firecrawl.png",name:"Firecrawl"},{src:"/connections/perplexity.png",name:"Perplexity"}];function Mv(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center -space-x-1",children:Dv.map(Pv)}),t[0]=e):e=t[0],e}function Pv(t){return n.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function Lv(t){const e=B.c(6),{onClick:s}=t;let i,r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=X("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),r=n.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=n.jsx(Mv,{}),a=n.jsx(Il,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=i,e[1]=r,e[2]=o,e[3]=a):(i=e[0],r=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=n.jsxs("button",{type:"button",onClick:s,className:i,children:[r,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const fn=48;function Ov(){const t=B.c(9),[e,s]=S.useState("idle"),[i,r]=S.useState(""),[o,a]=S.useState(""),[l,c]=S.useState($v),d=S.useRef(null),u=S.useRef(null),h=S.useRef(null),f=S.useRef(null),m=S.useRef(0),p=S.useRef(!1),g=S.useRef(""),_=S.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let x;t[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),u.current?.close().catch(zv),f.current?.getTracks().forEach(Bv),h.current=null,u.current=null,f.current=null},t[0]=x):x=t[0];const b=x;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const T=I=>{f.current=I;const A=new AudioContext;u.current=A;const N=A.createMediaStreamSource(I),E=A.createAnalyser();E.fftSize=128,E.smoothingTimeConstant=.8,N.connect(E),h.current=E;const M=new Uint8Array(E.frequencyBinCount),L=()=>{if(!h.current)return;h.current.getByteFrequencyData(M);const D=[];for(let P=0;P<fn;P++){const O=Math.floor(P/fn*M.length);D.push(Math.max(.04,(M[O]??0)/255))}c(D),m.current=requestAnimationFrame(L)};L()};y=async()=>{const I=window.SpeechRecognition||window.webkitSpeechRecognition;if(!I){s("unsupported");return}let A;try{A=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}r(""),a(""),_.current="",g.current="",p.current=!0,s("recording"),T(A);const N=new I;d.current=N,N.interimResults=!0,N.continuous=!0,N.lang=navigator.language||"en-US",N.onresult=E=>{let M="",L="";for(let D=E.resultIndex;D<E.results.length;D++){const P=E.results[D],O=P?.[0]?.transcript??"";P?.isFinal?L=L+O:M=M+O}L&&(g.current=g.current+L,r(g.current)),_.current=M,a(M)},N.onend=()=>{if(p.current)try{N.start()}catch{}};try{N.start()}catch{s("idle")}},t[1]=y}else y=t[1];const C=y;let k;t[2]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{p.current=!1,d.current?.stop(),b(),s("idle"),c(Array(fn).fill(.05)),a("");const T=(g.current+(_.current?" "+_.current:"")).trim();return r(""),g.current="",_.current="",T},t[2]=k):k=t[2];const w=k;let V;t[3]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{p.current=!1,d.current?.abort(),b(),s("idle"),r(""),a(""),c(Array(fn).fill(.05)),g.current="",_.current=""},t[3]=V):V=t[3];const j=V;let R;return t[4]!==o||t[5]!==e||t[6]!==i||t[7]!==l?(R={status:e,transcript:i,interimTranscript:o,waveformData:l,isSupported:v,startRecording:C,stopRecording:w,cancelRecording:j},t[4]=o,t[5]=e,t[6]=i,t[7]=l,t[8]=R):R=t[8],R}function Bv(t){return t.stop()}function zv(){}function $v(){return Array(fn).fill(.05)}function Fv(t){const e=B.c(4),{data:s}=t;let i;e[0]!==s?(i=s.map(Uv),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Uv(t,e){return n.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}const Oo=[{value:"fast",label:"Fast",Icon:eu,description:"Quicker responses"},{value:"smart",label:"Smart",Icon:Cl,description:"Balanced quality"},{value:"thinking",label:"Thinking",Icon:kg,description:"Deeper reasoning"}];function Hv(t){const e=B.c(17),{tier:s,onSelect:i}=t;let r;e[0]!==s?(r=Oo.find(m=>m.value===s)??Oo[1],e[0]=s,e[1]=r):r=e[1];const o=r,a=o.Icon;let l;e[2]!==a?(l=n.jsx(a,{size:14}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o.label?(c=n.jsx("span",{className:"hidden sm:inline",children:o.label}),e[4]=o.label,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==c?(d=n.jsx(Es,{asChild:!0,children:n.jsxs(oe,{type:"button",variant:"ghost",size:"default",className:"text-muted-foreground hover:text-foreground",children:[l,c]})}),e[6]=l,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==i||e[10]!==s?(u=Oo.map(m=>{const{value:p,label:g,Icon:_,description:v}=m;return n.jsxs(at,{onSelect:()=>i(p),children:[n.jsx(_,{size:16,className:"text-muted-foreground"}),n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx("span",{children:g}),n.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:v})]}),s===p&&n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"On"})]},p)}),e[9]=i,e[10]=s,e[11]=u):u=e[11];let h;e[12]!==u?(h=n.jsx(Is,{align:"end",className:"w-52 p-1.5",children:u}),e[12]=u,e[13]=h):h=e[13];let f;return e[14]!==d||e[15]!==h?(f=n.jsxs(As,{children:[d,h]}),e[14]=d,e[15]=h,e[16]=f):f=e[16],f}function Wv(t,e){const s=B.c(5),{editor:i}=ao(),[r,o]=S.useState(!1),a=S.useRef(0);let l,c;return s[0]!==i||s[1]!==e||s[2]!==t?(l=()=>{const d=m=>{m.dataTransfer?.types.includes("Files")&&(m.preventDefault(),a.current=a.current+1,o(!0))},u=m=>{m.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},h=Kv,f=m=>{if(m.preventDefault(),a.current=0,o(!1),!i||!t||!fo(t))return;const p=m.dataTransfer?.files;if(!p||p.length===0)return;const{from:g}=i.state.selection;for(const _ of Array.from(p))zl(i,t,_,g,e)};return window.addEventListener("dragenter",d),window.addEventListener("dragleave",u),window.addEventListener("dragover",h),window.addEventListener("drop",f),()=>{window.removeEventListener("dragenter",d),window.removeEventListener("dragleave",u),window.removeEventListener("dragover",h),window.removeEventListener("drop",f)}},c=[i,t,e],s[0]=i,s[1]=e,s[2]=t,s[3]=l,s[4]=c):(l=s[3],c=s[4]),S.useEffect(l,c),r}function Kv(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function qv(t){const e=B.c(11),{selectedModel:s,onUnsupportedFile:i}=t,r=Wv(s,i);let o;e[0]!==s?(o=fo(s),e[0]=s,e[1]=o):o=e[1];const a=o,l=r?"opacity-100":"opacity-0 pointer-events-none",c=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let d;e[2]!==l||e[3]!==c?(d=X("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",l,c),e[2]=l,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==s||e[6]!==a?(u=a?n.jsxs(n.Fragment,{children:[n.jsx(cu,{size:24}),n.jsxs("span",{className:"text-sm font-medium",children:["Drop ",fu(s)," here"]})]}):n.jsxs(n.Fragment,{children:[n.jsx(lu,{size:24}),n.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=s,e[6]=a,e[7]=u):u=e[7];let h;return e[8]!==d||e[9]!==u?(h=n.jsx("div",{className:d,children:u}),e[8]=d,e[9]=u,e[10]=h):h=e[10],h}function Gv({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const{messages:s,isStreaming:i,isRunInProgress:r,sendMessage:o,stop:a}=Gi(),{taskId:l,tasks:c}=es(),{selectedModel:d,selectedVirtualMcp:u,isModelsLoading:h,tiptapDocRef:f,imageModel:m,deepResearchModel:p,chatMode:g,setChatMode:_,simpleModeEnabled:v,simpleModeTier:x,setSimpleModeTier:b}=ai(),{data:y}=St.useSession(),C=y?.user?.id,{org:k}=ye(),w=ho(k.id).id,V=Sa(Vc),[j,R]=S.useState(!1),{unsupportedFile:T,onUnsupportedFile:I,clearUnsupportedFile:A}=s1(),N=Ov(),E=S.useRef(void 0),M=async()=>{E.current=O,await N.startRecording();const ne=N.status==="recording"?"started":N.status==="unsupported"?"unsupported":N.status==="permission-denied"?"permission_denied":"unknown";ie("chat_voice_started",{thread_id:l,outcome:ne})},L=()=>{ie("chat_voice_confirmed",{thread_id:l});const ne=N.stopRecording();H.current?.syncVoiceText(E.current,ne),H.current?.focus()},D=()=>{ie("chat_voice_cancelled",{thread_id:l}),N.cancelRecording(),H.current?.restoreContent(E.current)};S.useEffect(()=>{if(N.status!=="recording")return;const ne=(N.transcript+(N.interimTranscript?" "+N.interimTranscript:"")).trim();H.current?.syncVoiceText(E.current,ne)},[N.transcript,N.interimTranscript,N.status]);const P=c.find(ne=>ne.id===l),[O,$]=S.useState(void 0),z=ne=>{$(ne),f.current=ne},W=S.useRef(l);W.current!==l&&(W.current=l,$(void 0),f.current=void 0);const K=[...s].reverse().find(ne=>ne.role==="assistant")?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow,H=S.useRef(null),U=g==="plan";S.useEffect(()=>{const ne=ce=>{Kh(ce)&&ce.code==="KeyL"&&(ce.preventDefault(),ce.shiftKey&&_(g==="plan"?"default":"plan"),H.current?.focus())};return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},[g,_]);const Y=zh(s),q=[...s].reverse().find(ne=>ne.role==="assistant"&&ne.metadata?.usage)?.metadata?.usage,G=q?.contextTokens??(q?.totalTokens??0)-(q?.reasoningTokens??0),ee=Sa(Vc),Z=!i&&!!d&&!h&&!nx(O),J=i||r,se=ne=>{ne?.preventDefault(),i?(ie("chat_message_stopped",{thread_id:l}),a()):r?(ie("chat_message_stopped",{thread_id:l}),a()):Z&&O&&(ie("chat_message_sent",{thread_id:l,mode:g,model_id:d?.modelId??null,model_provider:d?.providerId??null,virtual_mcp_id:u?.id??null,submission:ne?"button_or_enter":"programmatic"}),ee(),o(O),z(void 0))};return C&&P?.created_by&&P.created_by!==C?n.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[n.jsx(lu,{size:14,className:"shrink-0"}),n.jsx("span",{className:"text-sm",children:"Read only — you're viewing someone else's thread"})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-col w-full justify-end",children:n.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&n.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),n.jsx(xo,{}),n.jsx(tf,{tiptapDoc:O,setTiptapDoc:z,disabled:i||!d,enterToSubmit:!0,onSubmit:se,children:n.jsxs("form",{onSubmit:se,className:X("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-background dark:bg-muted card-shadow"),children:[n.jsx(qv,{selectedModel:d,onUnsupportedFile:I}),n.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:n.jsx(sf,{ref:H,disabled:i||!d||N.status==="recording",virtualMcpId:u?.id??w,showFileUploader:!0,selectedModel:d,onUnsupportedFile:I})}),n.jsx("div",{className:"flex items-center justify-between p-2.5 gap-1",children:N.status==="recording"?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex-1"}),n.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[n.jsx(Fv,{data:N.waveformData.slice(0,28)}),n.jsx("button",{type:"button",onClick:D,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Cancel recording",children:n.jsx(Js,{size:16})}),n.jsx("button",{type:"button",onClick:L,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:n.jsx(Jt,{size:16})})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:[n.jsx(Jx,{selectedModel:d,isStreaming:i,icon:n.jsx(Qt,{size:16}),onUnsupportedFile:I}),n.jsx(Sv,{disabled:i,onOpenConnections:()=>{ie("connections_dialog_opened",{source:"tools_popover",mode:"add"}),R(!0)},virtualMcpId:u?.id??w}),U&&n.jsxs("button",{type:"button",onClick:()=>{V(),ie("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(au,{size:14,className:"shrink-0"}),"Plan mode",n.jsx(Js,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="gen-image"&&m&&n.jsxs("button",{type:"button",onClick:()=>{V(),ie("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(ga,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:v?"Create image":m.title.includes(": ")?m.title.split(": ").slice(1).join(": "):m.title}),n.jsx(Js,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="web-search"&&p&&n.jsxs("button",{type:"button",onClick:()=>{V(),ie("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(Pi,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:v?"Web search":p.title.includes(": ")?p.title.split(": ").slice(1).join(": "):p.title}),n.jsx(Js,{size:14,className:"shrink-0 hidden group-hover:block"})]}),K&&G>0&&n.jsx(Xp,{usage:Y,totalTokens:G,contextWindow:K,onOpenContextPanel:t})]}),n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[v?n.jsx(Hv,{tier:x,onSelect:b}):n.jsx(mu,{placeholder:"Model",variant:"borderless",className:"h-8 text-sm py-2 min-w-0"}),N.isSupported&&!i&&!r&&n.jsx(oe,{type:"button",onClick:M,variant:"ghost",size:"icon",className:X("size-8 rounded-lg transition-colors",N.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:N.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:n.jsx(Vg,{size:18})}),n.jsx(oe,{type:J?"button":"submit",onClick:ne=>{J&&(ne.preventDefault(),ne.stopPropagation(),a())},variant:Z||J?"default":"ghost",size:"icon",disabled:!Z&&!J,className:X("size-8 rounded-lg transition-all",!Z&&!J&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:i?"Stop generating":r?"Cancel run":"Send message (Enter)",children:J?n.jsx(Cg,{size:20}):n.jsx(Zh,{size:20})})]})]})})]})},l),e&&n.jsx(Lv,{onClick:()=>{ie("connections_banner_clicked",{source:"home_chat_input"}),ie("connections_dialog_opened",{source:"home_banner",mode:"add"}),R(!0)}})]})}),n.jsx(Ul,{mode:"browse",open:j,onOpenChange:R,defaultTab:"all"}),n.jsx(Zx,{info:T,onClose:A})]})}const Yv={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]};function nf(t){return`deco-credits-empty-dismissed:${t}`}function Xv(t){try{return localStorage.getItem(nf(t))==="1"}catch{return!1}}function Jv(){const t=B.c(49),{org:e}=ye(),s=qe(),{decoKeyId:i}=_o();let r;t[0]!==e.id?(r={connectionId:Pt,orgId:e.id},t[0]=e.id,t[1]=r):r=t[1];const o=Le(r),[a,l]=S.useState(!0),[c,d]=S.useState(""),[u,h]=S.useState(!1),[f,m]=S.useState("usd"),p=f==="brl"?"R$":"$";let g;t[2]!==e.id?(g=()=>{ie("credits_empty_state_dismissed",{organization_id:e.id}),l(!1);try{localStorage.setItem(nf(e.id),"1")}catch{}},t[2]=e.id,t[3]=g):g=t[3];const _=g;let v,x;t[4]!==a||t[5]!==e.id?(v=()=>{a&&ie("credits_empty_state_shown",{organization_id:e.id})},x=[a,e.id],t[4]=a,t[5]=e.id,t[6]=v,t[7]=x):(v=t[6],x=t[7]),S.useEffect(v,x);let b;t[8]!==o||t[9]!==f?(b=async z=>{const W=await o.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:z,currency:f}});if(W?.isError)throw new Error(W.content?.[0]?.text??"Failed to get top-up URL");return W.structuredContent?.url},t[8]=o,t[9]=f,t[10]=b):b=t[10];let y;t[11]!==_?(y=z=>{z&&window.open(z,"_blank","noopener,noreferrer"),_()},t[11]=_,t[12]=y):y=t[12];let C;t[13]!==b||t[14]!==y?(C={mutationFn:b,onSuccess:y,onError:Zv},t[13]=b,t[14]=y,t[15]=C):C=t[15];const{mutate:k,isPending:w}=Ki(C),V=parseFloat(c),j=!isNaN(V)&&V>=1;if(!a)return null;let R;t[16]!==_?(R=z=>!z&&_(),t[16]=_,t[17]=R):R=t[17];let T;t[18]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-amber-500/8 to-transparent pointer-events-none rounded-t-lg"}),t[18]=T):T=t[18];let I;t[19]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-100 dark:bg-amber-900/40 border border-amber-200/60 dark:border-amber-800/40 mx-auto",children:n.jsx(Sl,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[19]=I):I=t[19];let A;t[20]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[T,n.jsxs(hs,{className:"relative gap-3",children:[I,n.jsxs("div",{className:"text-center",children:[n.jsx(ds,{className:"text-lg font-semibold",children:"This workspace has no credits"}),n.jsx(lo,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:"Your free credits were used in another workspace. Add credits to use AI here."})]})]})]}),t[20]=A):A=t[20];let N;t[21]!==f||t[22]!==p||t[23]!==c||t[24]!==V||t[25]!==i||t[26]!==j||t[27]!==w||t[28]!==u||t[29]!==k?(N=i&&n.jsxs("div",{className:"px-6 pb-5",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(hu,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:z=>{z&&m(z)},children:[n.jsx($r,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx($r,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Yv[f].map(z=>{const{dollars:W,label:F}=z;return n.jsxs("button",{type:"button",disabled:w,onClick:()=>{ie("credits_topup_clicked",{amount_cents:W*100,currency:f,tier_label:F,source:"empty_state"}),k(W*100)},className:X("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,W]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:F})]},W)})}),u?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),n.jsx(gt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:z=>d(z.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(oe,{className:"h-10",disabled:!j||w,onClick:()=>{ie("credits_topup_clicked",{amount_cents:Math.round(V*100),currency:f,tier_label:"custom",source:"empty_state"}),k(Math.round(V*100))},children:w?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),t[21]=f,t[22]=p,t[23]=c,t[24]=V,t[25]=i,t[26]=j,t[27]=w,t[28]=u,t[29]=k,t[30]=N):N=t[30];let E;t[31]!==_||t[32]!==s||t[33]!==e.slug?(E=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),_()},t[31]=_,t[32]=s,t[33]=e.slug,t[34]=E):E=t[34];let M;t[35]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(uo,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[35]=M):M=t[35];let L;t[36]!==E?(L=n.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:E,children:["Use your own provider",M]}),t[36]=E,t[37]=L):L=t[37];let D;t[38]!==_?(D=n.jsx(oe,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:_,children:"Skip for now"}),t[38]=_,t[39]=D):D=t[39];let P;t[40]!==L||t[41]!==D?(P=n.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[L,D]}),t[40]=L,t[41]=D,t[42]=P):P=t[42];let O;t[43]!==N||t[44]!==P?(O=n.jsxs(ts,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Qv,children:[A,N,P]}),t[43]=N,t[44]=P,t[45]=O):O=t[45];let $;return t[46]!==O||t[47]!==R?($=n.jsx(ss,{open:!0,onOpenChange:R,children:O}),t[46]=O,t[47]=R,t[48]=$):$=t[48],$}function Qv(t){return t.preventDefault()}function Zv(t){fe.error(`Top-up failed: ${t.message}`)}function eb(t){const e=B.c(6),{balanceDollars:s}=t;let i;e[0]!==s?(i=s.toFixed(2),e[0]=s,e[1]=i):i=e[1];const r=i;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=X("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-emerald-50 dark:bg-emerald-950/30","border border-emerald-200/60 dark:border-emerald-800/40","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=n.jsx(Sl,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==r?(l=n.jsxs("div",{className:o,children:[a,n.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",r," in credits to get started"]})]}),e[4]=r,e[5]=l):l=e[5],l}function tb(){const t=B.c(8),{org:e}=ye(),s=qe();let i;t[0]!==s||t[1]!==e.slug?(i=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=i):i=t[2];let r,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=X("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-amber-50 dark:bg-amber-950/30","border border-amber-200/60 dark:border-amber-800/40","hover:bg-amber-100/60 dark:hover:bg-amber-900/30","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),o=n.jsx(oi,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=n.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=r,t[4]=o,t[5]=a):(r=t[3],o=t[4],a=t[5]);let l;return t[6]!==i?(l=n.jsxs("button",{type:"button",onClick:i,className:r,children:[o,a]}),t[6]=i,t[7]=l):l=t[7],l}function sb(t){const e=B.c(11),{className:s}=t;let i;e[0]!==s?(i=X("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=i):i=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex items-center gap-3",children:[r,n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),n.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:n.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,n.jsxs("div",{className:"flex items-end gap-2",children:[n.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),n.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:n.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[n.jsx(hr,{align:"right",width:"w-3/4"}),n.jsx(hr,{align:"left",width:"w-full",lines:3}),n.jsx(hr,{align:"right",width:"w-2/3"}),n.jsx(hr,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:n.jsx("div",{className:"relative flex-1",children:n.jsxs("div",{className:"space-y-2 p-2",children:[n.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),n.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex items-center gap-1",children:n.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"px-4 py-4",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:n.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,n.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),n.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=u):u=e[8];let h;return e[9]!==i?(h=n.jsxs("div",{className:i,children:[a,l,u]}),e[9]=i,e[10]=h):h=e[10],h}function hr(t){const e=B.c(22),{align:s,width:i,lines:r}=t,o=i===void 0?"w-full":i,a=r===void 0?1:r,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=X("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=c):c=e[1];const d=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let u;e[2]!==d?(u=X("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=u):u=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=h):h=e[4];const f=s==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==f||e[6]!==o?(m=X("min-w-0 rounded-2xl p-4",f,o),e[5]=f,e[6]=o,e[7]=m):m=e[7];let p;e[8]!==a?(p=Array.from({length:a}),e[8]=a,e[9]=p):p=e[9];let g;e[10]!==a||e[11]!==p?(g=n.jsx("div",{className:"space-y-2",children:p.map((b,y)=>n.jsx("div",{className:X("h-3 rounded bg-muted-foreground/20 animate-pulse",y===a-1?"w-3/4":"w-full"),style:{animationDelay:`${y*.1}s`}},y))}),e[10]=a,e[11]=p,e[12]=g):g=e[12];let _;e[13]!==g||e[14]!==m?(_=n.jsx("div",{className:m,children:g}),e[13]=g,e[14]=m,e[15]=_):_=e[15];let v;e[16]!==_||e[17]!==u?(v=n.jsxs("div",{className:u,children:[h,_]}),e[16]=_,e[17]=u,e[18]=v):v=e[18];let x;return e[19]!==v||e[20]!==c?(x=n.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=x):x=e[21],x}function ib(t){const e=B.c(5),{className:s,children:i}=t;let r;e[0]!==s?(r=X("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==i||e[3]!==r?(o=n.jsx("div",{className:r,children:i}),e[2]=i,e[3]=r,e[4]=o):o=e[4],o}function nb(t){const e=B.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=X("flex-1 min-h-0 overflow-y-auto isolate",i),e[0]=i,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=n.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function rb(t){const e=B.c(2),{children:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"h-full w-full flex items-center justify-center max-w-2xl mx-auto",children:s}),e[0]=s,e[1]=i):i=e[1],i}function ob(){const t=B.c(16),{messages:e,status:s}=Gi(),i=Jp(e);let r;t[0]!==i?(r=i.at(-1),t[0]=i,t[1]=r):r=t[1];const o=r,a=s==="submitted"||s==="streaming";let l;if(t[2]!==a||t[3]!==o||t[4]!==i||t[5]!==e||t[6]!==s){const c=e.at(-1),d=!a&&c?.role==="assistant"&&c.parts.filter(cb).some(lb),u=!a&&c?.role==="assistant"&&c.parts.some(ab);let h;if(t[8]!==i||t[9]!==s){let m;t[11]!==i.length||t[12]!==s?(m=(p,g)=>n.jsx(_c,{pair:p,isLastPair:!1,status:g===i.length-1?s:void 0},`pair-${p.user.id}`),t[11]=i.length,t[12]=s,t[13]=m):m=t[13],h=i.slice(0,-1).map(m),t[8]=i,t[9]=s,t[10]=h}else h=t[10];let f;t[14]!==h?(f=n.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:h}),t[14]=h,t[15]=f):f=t[15],l=n.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[f,o&&n.jsx("div",{className:X("min-h-full min-w-0 max-w-2xl mx-auto w-full",(d||u)&&"pb-60"),children:n.jsx(_c,{pair:o,isLastPair:!0,status:s},`pair-${o?.user.id}`)})]}),t[2]=a,t[3]=o,t[4]=i,t[5]=e,t[6]=s,t[7]=l}else l=t[7];return l}function ab(t){return"state"in t&&t.state==="approval-requested"}function lb(t){return t.state==="input-available"}function cb(t){return t.type==="tool-user_ask"}function db(t){const e=B.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=X("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",i),e[0]=i,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=n.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}const Oe=Object.assign(ib,{Main:nb,Messages:ob,EmptyState:rb,Footer:db,Input:Gv,Provider:$p,ActiveTaskProvider:zp,Skeleton:sb,IceBreakers:fx,NoAiProviderEmptyState:Zg,CreditsEmptyState:Jv,CreditsEyebrow:eb,NoCreditsEyebrow:tb,CreditsExhaustedBanner:zu}),hb=`You are an image generator agent. Every request of the user is somewhat related to creating, editing or varying an image. You have access to image generation tools
|
|
5
5
|
|
|
@@ -545,7 +545,7 @@ target:
|
|
|
545
545
|
• One issue per { kind, target.route } pair. Dedup uses those two fields from the body frontmatter.
|
|
546
546
|
• Always normalize route: lowercase host, no trailing slash (except "/"), no query string, no fragment.`)])),{type:"doc",content:c.map((d,u)=>u<c.length-1?Vb(d):d)}}function Vb(t){const e=t.content;if(!e||e.length===0)return t;const s=e[e.length-1];return!s||s.type!=="text"||typeof s.text!="string"?t:{...t,content:[...e.slice(0,-1),{...s,text:`${s.text}
|
|
547
547
|
|
|
548
|
-
`}]}}function ui(t){return{type:"paragraph",content:t}}function Ws(t){return{type:"text",text:t}}function Cb({agentId:t,title:e}){return{type:"mention",attrs:{id:t,name:e,char:"@",metadata:{agentId:t,title:e}}}}const mn="deco/site-diagnostics";function rf(t){const e=B.c(15),{open:s,onOpenChange:i}=t,[r,o]=S.useState(null);let a;e[0]!==i?(a=()=>{o(null),i(!1)},e[0]=i,e[1]=a):a=e[1];const l=a,c=s&&r===null;let d;e[2]!==r||e[3]!==i?(d=p=>{!p&&r===null&&i(!1)},e[2]=r,e[3]=i,e[4]=d):d=e[4];let u;e[5]!==c||e[6]!==d?(u=n.jsx(wu,{open:c,onOpenChange:d,title:"Set up self-healing repo",hideAutoRespondCheckbox:!0,onImportComplete:o}),e[5]=c,e[6]=d,e[7]=u):u=e[7];const h=s&&r!==null;let f;e[8]!==l||e[9]!==r||e[10]!==h?(f=n.jsx(kb,{open:h,payload:r,onClose:l}),e[8]=l,e[9]=r,e[10]=h,e[11]=f):f=e[11];let m;return e[12]!==u||e[13]!==f?(m=n.jsxs(n.Fragment,{children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14],m}function kb(t){const e=B.c(66),{open:s,payload:i,onClose:r}=t,{org:o}=ye(),a=Yn(),l=po();let c;e[0]!==o.id?(c={connectionId:Pt,orgId:o.id},e[0]=o.id,e[1]=c):c=e[1];const d=Le(c),[u,h]=S.useState(""),[f,m]=S.useState(Ab);let p;e[2]!==s?(p={enabled:s},e[2]=s,e[3]=p):p=e[3];const{data:g}=C_(mn,p);let _;e[4]!==l||e[5]!==f||e[6]!==i||e[7]!==d||e[8]!==g||e[9]!==u?(_=async()=>{if(!i)throw new Error("No imported repo payload");const Y=Qc(u);if(!Y)throw new Error("Enter a valid https:// URL");const q=wa.filter(J=>f[J.id]);if(q.length===0)return{succeeded:[],failed:[]};const G=await Tb({selfClient:d,createConnection:l.create.mutateAsync,registry:g}),ee=[],Z=[];for(const J of q)try{await Db({template:J,selfClient:d,siteDiagnosticsConnectionId:G,projectAgentId:i.virtualMcpId,owner:i.repo.owner,repo:i.repo.name,siteRootUrl:Y}),ee.push(J.title)}catch(se){const ne=se;console.error(`Failed to set up ${J.title}:`,ne),Z.push(J.title)}return{succeeded:ee,failed:Z}},e[4]=l,e[5]=f,e[6]=i,e[7]=d,e[8]=g,e[9]=u,e[10]=_):_=e[10];let v;e[11]!==a||e[12]!==r||e[13]!==i?.virtualMcpId?(v=Y=>{const{succeeded:q,failed:G}=Y;q.length>0?fe.success(`Self-healing repo ready — ${q.length} specialist${q.length>1?"s":""} set up`):G.length===0&&fe.success("Repo imported. Add specialists later from automations."),G.length>0&&fe.warning(`Could not set up: ${G.join(", ")}. You can add them later from the automations view.`);const ee=i?.virtualMcpId;r(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),ee&&a(ee)},e[11]=a,e[12]=r,e[13]=i?.virtualMcpId,e[14]=v):v=e[14];let x;e[15]!==_||e[16]!==v?(x={mutationFn:_,onSuccess:v,onError:Nb},e[15]=_,e[16]=v,e[17]=x):x=e[17];const b=Ki(x);let y;e[18]!==b.isPending||e[19]!==u?(y=Qc(u)!==null&&!b.isPending,e[18]=b.isPending,e[19]=u,e[20]=y):y=e[20];const C=y;let k;e[21]!==r||e[22]!==b.isPending?(k=Y=>{!Y&&!b.isPending&&r()},e[21]=r,e[22]=b.isPending,e[23]=k):k=e[23];let w;e[24]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(hs,{className:"h-12 border-b border-border px-4 flex flex-row items-center shrink-0 space-y-0",children:n.jsx(ds,{className:"text-sm font-medium text-foreground",children:"Add specialist monitors"})}),e[24]=w):w=e[24];let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Specialists run on a daily schedule. Your repo agent collects their findings and opens GitHub issues, then writes the fixes."}),e[25]=V):V=e[25];let j;e[26]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("label",{htmlFor:"self-healing-site-url",className:"text-xs font-medium text-foreground",children:"Production URL"}),e[26]=j):j=e[26];let R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=Y=>h(Y.target.value),e[27]=R):R=e[27];let T;e[28]!==u?(T=n.jsx(gt,{id:"self-healing-site-url",type:"url",placeholder:"https://example.com",value:u,onChange:R,autoFocus:!0}),e[28]=u,e[29]=T):T=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("p",{className:"text-xs text-muted-foreground",children:"The site the specialists will monitor."}),e[30]=I):I=e[30];let A;e[31]!==T?(A=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[j,T,I]}),e[31]=T,e[32]=A):A=e[32];let N;e[33]!==f?(N=wa.map(Y=>n.jsx(Eb,{template:Y,enabled:f[Y.id]??!1,onToggle:q=>m(G=>({...G,[Y.id]:q}))},Y.id)),e[33]=f,e[34]=N):N=e[34];let E,M;e[35]===Symbol.for("react.memo_cache_sentinel")?(E=Sb.map(jb),M=n.jsx(Rb,{}),e[35]=E,e[36]=M):(E=e[35],M=e[36]);let L;e[37]!==N?(L=n.jsxs("div",{className:"flex flex-col gap-2",children:[N,E,M]}),e[37]=N,e[38]=L):L=e[38];let D;e[39]!==A||e[40]!==L?(D=n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 flex flex-col gap-4",children:[V,A,L]}),e[39]=A,e[40]=L,e[41]=D):D=e[41];let P;e[42]!==a||e[43]!==r||e[44]!==i?.virtualMcpId||e[45]!==b.isPending?(P=()=>{if(!b.isPending){const Y=i?.virtualMcpId;r(),Y&&a(Y)}},e[42]=a,e[43]=r,e[44]=i?.virtualMcpId,e[45]=b.isPending,e[46]=P):P=e[46];let O;e[47]!==b.isPending||e[48]!==P?(O=n.jsx("button",{type:"button",onClick:P,disabled:b.isPending,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 cursor-pointer",children:"Skip for now"}),e[47]=b.isPending,e[48]=P,e[49]=O):O=e[49];let $;e[50]!==b?($=()=>b.mutate(),e[50]=b,e[51]=$):$=e[51];const z=!C,W=b.isPending?"Setting up...":"Set up specialists";let F;e[52]!==$||e[53]!==z||e[54]!==W?(F=n.jsx(oe,{onClick:$,disabled:z,size:"sm",children:W}),e[52]=$,e[53]=z,e[54]=W,e[55]=F):F=e[55];let K;e[56]!==O||e[57]!==F?(K=n.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center justify-between gap-3 shrink-0",children:[O,F]}),e[56]=O,e[57]=F,e[58]=K):K=e[58];let H;e[59]!==D||e[60]!==K?(H=n.jsxs(ts,{className:"sm:max-w-[560px] max-h-[85svh] p-0 gap-0 overflow-hidden flex flex-col",children:[w,D,K]}),e[59]=D,e[60]=K,e[61]=H):H=e[61];let U;return e[62]!==s||e[63]!==H||e[64]!==k?(U=n.jsx(ss,{open:s,onOpenChange:k,children:H}),e[62]=s,e[63]=H,e[64]=k,e[65]=U):U=e[65],U}function jb(t){return n.jsx(Ib,{title:t.title,description:t.description,icon:t.icon},t.id)}function Nb(t){fe.error("Failed to set up specialists: "+(t instanceof Error?t.message:"Unknown error"))}function Ab(){const t={};for(const e of wa)t[e.id]=!0;return t}function Eb(t){const e=B.c(20),{template:s,enabled:i,onToggle:r}=t,o=i?"bg-accent/30":"hover:bg-accent/30";let a;e[0]!==o?(a=X("flex items-center gap-3 rounded-lg border border-border px-3 py-3 cursor-pointer transition-colors",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==s.icon||e[3]!==s.title?(l=n.jsx(gs,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=l):l=e[4];let c;e[5]!==s.title?(c=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s.title}),e[5]=s.title,e[6]=c):c=e[6];let d;e[7]!==s.description?(d=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[7]=s.description,e[8]=d):d=e[8];let u;e[9]!==c||e[10]!==d?(u=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[c,d]}),e[9]=c,e[10]=d,e[11]=u):u=e[11];let h;e[12]!==i||e[13]!==r?(h=n.jsx(Hr,{checked:i,onCheckedChange:r,className:"shrink-0"}),e[12]=i,e[13]=r,e[14]=h):h=e[14];let f;return e[15]!==a||e[16]!==l||e[17]!==u||e[18]!==h?(f=n.jsxs("label",{className:a,children:[l,u,h]}),e[15]=a,e[16]=l,e[17]=u,e[18]=h,e[19]=f):f=e[19],f}function Ib(t){const e=B.c(14),{title:s,description:i,icon:r}=t;let o;e[0]!==r||e[1]!==s?(o=n.jsx(gs,{icon:r,name:s,size:"sm",className:"shrink-0"}),e[0]=r,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s}),e[3]=s,e[4]=a):a=e[4];let l;e[5]!==i?(l=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:i}),e[5]=i,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==l?(c=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a,l]}),e[7]=a,e[8]=l,e[9]=c):c=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground shrink-0",children:"Coming soon"}),e[10]=d):d=e[10];let u;return e[11]!==o||e[12]!==c?(u=n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-dashed border-border px-3 py-3 opacity-60",children:[o,c,d]}),e[11]=o,e[12]=c,e[13]=u):u=e[13],u}function Rb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center rounded-lg border border-dashed border-border px-3 py-3 text-xs text-muted-foreground",children:"More specialists coming soon"}),t[0]=e):e=t[0],e}function Qc(t){const e=t.trim();if(!e)return null;try{const s=new URL(e);return s.protocol!=="https:"&&s.protocol!=="http:"?null:s.origin+(s.pathname==="/"?"":s.pathname)}catch{return null}}async function Tb({selfClient:t,createConnection:e,registry:s}){const r=(await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:mn},limit:1,offset:0}})).structuredContent?.items?.find(u=>u.app_id===mn);if(r)return r.id;const o=s?.server?.remotes?.[0]?.url;if(!o)throw new Error("Site Diagnostics MCP is not available in the registry right now.");const a=s?.title??s?.server?.title??s?.server?.name??"Site Diagnostics",l=s?.server?.icons?.[0]?.src??null,c=s?.server?.description??null;return(await e({title:a,description:c,icon:l,connection_type:"HTTP",connection_url:o,app_name:s?.server?.name??"site-diagnostics",app_id:mn,metadata:{type:"site-diagnostics",source:"store",registry_item_id:mn,verified:!0}})).id}async function Db({template:t,selfClient:e,siteDiagnosticsConnectionId:s,projectAgentId:i,owner:r,repo:o,siteRootUrl:a}){const l=`${o}: ${t.title}`,d=(await e.callTool({name:"AUTOMATION_LIST",arguments:{virtual_mcp_id:i}})).structuredContent?.automations?.find(h=>h.name===l);let u;if(!(d&&d.trigger_count>0)){if(d)u=d.id;else{const h=await Mb({template:t,selfClient:e,siteDiagnosticsConnectionId:s}),f=wb({template:t,specialistAgentId:h,owner:r,repo:o,siteRootUrl:a}),m=Bh(f),p=await e.callTool({name:"AUTOMATION_CREATE",arguments:{name:l,virtual_mcp_id:i,agent:{id:i},messages:m,active:!0}});u=(p.structuredContent??p).id}await e.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:u,type:"cron",cron_expression:t.cron}})}}async function Mb({template:t,selfClient:e,siteDiagnosticsConnectionId:s}){const r=(await e.callTool({name:"COLLECTION_VIRTUAL_MCP_LIST",arguments:{where:{field:["metadata","specialistId"],operator:"eq",value:t.id},limit:1,offset:0}})).structuredContent?.items?.find(l=>l.metadata?.specialistId===t.id);if(r)return r.id;const o=await e.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:t.title,description:t.description,icon:t.icon,pinned:!1,metadata:{specialistId:t.id,instructions:t.instructions},connections:[{connection_id:s,selected_tools:t.siteDiagnosticsTools,selected_resources:null,selected_prompts:null}]}}});return(o.structuredContent??o).item.id}function Pb(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}function rn(t){const e=B.c(21),{agent:s,onSpecialClick:i,tracking:r}=t,{org:o}=ye(),a=qe();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==r.action||e[6]!==r.template_id||e[7]!==r.tile_kind?(l=()=>{if(ie("home_agent_tile_clicked",{template_id:r.template_id,agent_id:s.id,agent_title:s.title,tile_kind:r.tile_kind,action:r.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=r.action,e[6]=r.template_id,e[7]=r.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(go,{size:24}),e[10]=h):h=e[10];let f;e[11]!==s.icon||e[12]!==s.title?(f=n.jsx(Ps,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=f):f=e[13];let m;e[14]!==s.title?(m=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=m):m=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==f||e[19]!==m?(p=n.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[f,m]}),e[16]=c,e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20],p}function Lb(){const t=B.c(8),e=qe(),{org:s}=ye();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let r;t[1]!==e||t[2]!==s.slug?(r=()=>{ie("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=r):r=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:n.jsx(Il,{size:20,className:"text-foreground"})}),a=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==r?(l=n.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:r,children:[o,a]}),t[6]=r,t[7]=l):l=t[7],l}function Ob(){const t=B.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=ku(e);let r;t[1]!==s?(r=()=>{ie("home_create_agent_clicked"),s()},t[1]=s,t[2]=r):r=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:n.jsx(Qt,{size:20,className:"text-muted-foreground"})}),l=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==r?(c=n.jsxs("button",{type:"button",onClick:r,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=r,t[8]=c):c=t[8],c}function Bb(){const t=B.c(103),e=mo(),{locator:s}=ye(),[i,r]=S.useState(!1),[o,a]=S.useState(!1),[l,c]=S.useState(!1),[d,u]=S.useState(!1),[h,f]=S.useState(!1),[m]=yi(),p=Yn();let g;t[0]===Symbol.for("react.memo_cache_sentinel")?(g=zs.find(Hb),t[0]=g):g=t[0];const _=g;let v;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=zs.find(Ub),t[1]=v):v=t[1];const x=v;let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=zs.find(Fb),t[2]=b):b=t[2];const y=b;let C;t[3]===Symbol.for("react.memo_cache_sentinel")?(C=zs.find($b),t[3]=C):C=t[3];const k=C;let w,V,j,R,T,I,A,N,E,M,L,D;if(t[4]!==s||t[5]!==p||t[6]!==m.experimental_vibecode||t[7]!==e){const q=Pb(s),G=e.filter(zb).sort((be,je)=>{const $e=q.indexOf(be.id),Ge=q.indexOf(je.id);return $e!==-1&&Ge!==-1?$e-Ge:$e!==-1?-1:Ge!==-1?1:new Date(je.updated_at).getTime()-new Date(be.updated_at).getTime()}).slice(0,4);let ee;if(t[20]!==e){let be;t[22]===Symbol.for("react.memo_cache_sentinel")?(be=je=>je.id!==null&&(je.metadata?.type===x.id||je.title===x.title),t[22]=be):be=t[22],ee=e.find(be),t[20]=e,t[21]=ee}else ee=t[21];j=ee;let Z;if(t[23]!==e){let be;t[25]===Symbol.for("react.memo_cache_sentinel")?(be=je=>je.id!==null&&(je.metadata?.type===y.id||je.title===y.title),t[25]=be):be=t[25],Z=e.find(be),t[23]=e,t[24]=Z}else Z=t[24];w=Z;let J;if(t[26]!==e){let be;t[28]===Symbol.for("react.memo_cache_sentinel")?(be=je=>je.id!==null&&(je.metadata?.type===k.id||je.title===k.title),t[28]=be):be=t[28],J=e.find(be),t[26]=e,t[27]=J}else J=t[27];V=J,R=G.length>0,t[29]!==m.experimental_vibecode?(I=m.experimental_vibecode&&n.jsx("div",{className:"w-full flex justify-center mb-4",children:n.jsxs("button",{type:"button",onClick:()=>f(!0),className:"w-full max-w-[560px] flex items-center gap-3 rounded-xl border border-primary/30 bg-gradient-to-br from-primary/10 via-primary/5 to-transparent px-4 py-3 text-left transition-colors hover:border-primary/50 hover:from-primary/15 cursor-pointer group",children:[n.jsx("div",{className:"size-10 rounded-lg bg-primary/15 flex items-center justify-center shrink-0 transition-transform group-hover:scale-105",children:n.jsx(Fr,{className:"size-5 text-primary"})}),n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:"Set up self-healing repo"}),n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:"Connect GitHub and add specialist monitors that open issues automatically."})]})]})}),t[29]=m.experimental_vibecode,t[30]=I):I=t[30],T="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",A="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",t[31]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(rn,{agent:_,onSpecialClick:()=>r(!0),tracking:{template_id:_.id,tile_kind:"template",action:"open_modal"}},_.id),t[31]=N):N=t[31];const se=j??x;let ne;t[32]!==j||t[33]!==p?(ne=j?()=>p(j.id):()=>a(!0),t[32]=j,t[33]=p,t[34]=ne):ne=t[34];const ce=j?"existing":"template",xe=j?"navigate":"open_modal";let ae;t[35]!==ce||t[36]!==xe?(ae={template_id:x.id,tile_kind:ce,action:xe},t[35]=ce,t[36]=xe,t[37]=ae):ae=t[37],t[38]!==se||t[39]!==ne||t[40]!==ae?(E=n.jsx(rn,{agent:se,onSpecialClick:ne,tracking:ae},x.id),t[38]=se,t[39]=ne,t[40]=ae,t[41]=E):E=t[41];const he=w??y;let pe;t[42]!==w||t[43]!==p?(pe=w?()=>p(w.id):()=>c(!0),t[42]=w,t[43]=p,t[44]=pe):pe=t[44];const me=w?"existing":"template",we=w?"navigate":"open_modal";let ve;t[45]!==me||t[46]!==we?(ve={template_id:y.id,tile_kind:me,action:we},t[45]=me,t[46]=we,t[47]=ve):ve=t[47],t[48]!==he||t[49]!==pe||t[50]!==ve?(M=n.jsx(rn,{agent:he,onSpecialClick:pe,tracking:ve},y.id),t[48]=he,t[49]=pe,t[50]=ve,t[51]=M):M=t[51];const de=V??k;let Re;t[52]!==V||t[53]!==p?(Re=V?()=>p(V.id):()=>u(!0),t[52]=V,t[53]=p,t[54]=Re):Re=t[54];const te=V?"existing":"template",ue=V?"navigate":"open_modal";let Ve;t[55]!==te||t[56]!==ue?(Ve={template_id:k.id,tile_kind:te,action:ue},t[55]=te,t[56]=ue,t[57]=Ve):Ve=t[57],t[58]!==de||t[59]!==Re||t[60]!==Ve?(L=n.jsx(rn,{agent:de,onSpecialClick:Re,tracking:Ve},k.id),t[58]=de,t[59]=Re,t[60]=Ve,t[61]=L):L=t[61];let Ee;t[62]!==w?.id||t[63]!==V?.id||t[64]!==j?.id?(Ee=be=>be.id!==j?.id&&be.id!==w?.id&&be.id!==V?.id,t[62]=w?.id,t[63]=V?.id,t[64]=j?.id,t[65]=Ee):Ee=t[65];let Te;t[66]!==p?(Te=be=>n.jsx(rn,{agent:be,onSpecialClick:()=>p(be.id),tracking:{template_id:null,tile_kind:"recent",action:"navigate"}},be.id??"default"),t[66]=p,t[67]=Te):Te=t[67],D=G.filter(Ee).map(Te),t[4]=s,t[5]=p,t[6]=m.experimental_vibecode,t[7]=e,t[8]=w,t[9]=V,t[10]=j,t[11]=R,t[12]=T,t[13]=I,t[14]=A,t[15]=N,t[16]=E,t[17]=M,t[18]=L,t[19]=D}else w=t[8],V=t[9],j=t[10],R=t[11],T=t[12],I=t[13],A=t[14],N=t[15],E=t[16],M=t[17],L=t[18],D=t[19];let P;t[68]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(Ob,{}),t[68]=P):P=t[68];let O;t[69]!==R?(O=R&&n.jsx(Lb,{}),t[69]=R,t[70]=O):O=t[70];let $;t[71]!==O||t[72]!==A||t[73]!==N||t[74]!==E||t[75]!==M||t[76]!==L||t[77]!==D?($=n.jsxs("div",{className:A,children:[N,E,M,L,D,P,O]}),t[71]=O,t[72]=A,t[73]=N,t[74]=E,t[75]=M,t[76]=L,t[77]=D,t[78]=$):$=t[78];let z;t[79]!==T||t[80]!==$?(z=n.jsx("div",{className:T,children:$}),t[79]=T,t[80]=$,t[81]=z):z=t[81];let W;t[82]!==i?(W=n.jsx(Ur,{open:i,onOpenChange:r}),t[82]=i,t[83]=W):W=t[83];let F;t[84]!==o||t[85]!==j?(F=n.jsx(Vu,{open:o,onOpenChange:a,existingAgent:j}),t[84]=o,t[85]=j,t[86]=F):F=t[86];let K;t[87]!==l||t[88]!==w?(K=n.jsx(mb,{open:l,onOpenChange:c,existingAgent:w}),t[87]=l,t[88]=w,t[89]=K):K=t[89];let H;t[90]!==d||t[91]!==V?(H=n.jsx(xb,{open:d,onOpenChange:u,existingAgent:V}),t[90]=d,t[91]=V,t[92]=H):H=t[92];let U;t[93]!==h?(U=n.jsx(rf,{open:h,onOpenChange:f}),t[93]=h,t[94]=U):U=t[94];let Y;return t[95]!==I||t[96]!==z||t[97]!==W||t[98]!==F||t[99]!==K||t[100]!==H||t[101]!==U?(Y=n.jsxs(n.Fragment,{children:[I,z,W,F,K,H,U]}),t[95]=I,t[96]=z,t[97]=W,t[98]=F,t[99]=K,t[100]=H,t[101]=U,t[102]=Y):Y=t[102],Y}function zb(t){return t.id!==null&&!Br(t.id)}function $b(t){return t.id==="ai-research"}function Fb(t){return t.id==="ai-image"}function Ub(t){return t.id==="site-diagnostics"}function Hb(t){return t.id==="site-editor"}function Wb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:n.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(Kb)})}),t[0]=e):e=t[0],e}function Kb(t,e){return n.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[n.jsx($i,{className:"size-12 rounded-xl shrink-0"}),n.jsx($i,{className:"h-3 sm:h-4 w-full"})]},e)}function Zc(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(S.Suspense,{fallback:n.jsx(Wb,{}),children:n.jsx(Bb,{})}),t[0]=e):e=t[0],e}function on(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function ed(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 qb(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Gb(t){const e=B.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Yb),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.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 Yb(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Xb(t){const e=B.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?r/o*100:0;let d;e[0]!==a?(d=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let f;e[6]!==d||e[7]!==u||e[8]!==h?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[_,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==c||e[21]!==r?(b=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=r,e[22]=b):b=e[22];let y;e[23]!==x||e[24]!==b||e[25]!==g?(y=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,b]}),e[23]=x,e[24]=b,e[25]=g,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==f?(C=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=C):C=e[29],C}function Jb(t){const e=B.c(19),{part:s}=t,i=s.input?.agent_id,r=is(i),o=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=n.jsx(Ps,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let f;e[3]!==h?(f=X("shrink-0 font-medium",h),e[3]=h,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==f?(m=n.jsx("span",{className:f,children:o}),e[5]=o,e[6]=f,e[7]=m):m=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=n.jsx("span",{className:"ml-auto shrink-0",children:l?n.jsx(De,{size:12,className:"animate-spin text-muted-foreground"}):c?n.jsx(Yg,{size:12,className:"text-destructive"}):d?n.jsx(oi,{size:12,className:"text-warning"}):n.jsx(N_,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==m||e[16]!==p||e[17]!==g?(_=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,m,p,g]}),e[14]=u,e[15]=m,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function Qb(t){const e=B.c(58),{onClose:s,back:i,className:r}=t,[o,a]=S.useState(null),{messages:l}=Gi(),{tasks:c,taskId:d}=es(),{selectedModel:u,selectedVirtualMcp:h}=ai();let f,m,p,g,_,v,x,b;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){b=Symbol.for("react.early_return_sentinel");e:{let k;e[17]!==d?(k=J=>J.id===d,e[17]=d,e[18]=k):k=e[18];const w=c.find(k),V=zh(l),j=[...l].reverse().find(a0),R=j?.metadata?.usage,T=j?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,I=R?.contextTokens??R?.totalTokens??0,A=T&&T>0?(I/T*100).toFixed(1):null,N=l;let E;e[19]!==N?(E=N.filter(o0).reduce(r0,0),e[19]=N,e[20]=E):E=e[20];const M=E,L=l;let D;e[21]!==L?(D=L.filter(n0).reduce(i0,0),e[21]=L,e[22]=D):D=e[22];const P=D,O=Math.max(0,V.totalTokens-M-P),$=l[0],z=l.at(-1),W=$?.metadata?.created_at??w?.created_at,F=z?.metadata?.created_at??w?.updated_at,K=l.filter(s0),H=l.flatMap(e0),U=u?.modelId?qb(u.modelId):"—",Y=h?.title??"Decopilot",q=[{label:"Session",value:w?.title??"New chat"},{label:"Messages",value:K.length},{label:"Agent",value:Y},{label:"Model",value:U},{label:"Context Limit",value:T?on(T):"—"},{label:"Session Tokens (billed)",value:V.totalTokens>0?on(V.totalTokens):"0"},{label:"Usage",value:A!==null?`${A}%`:"—"},{label:"Input Tokens",value:V.inputTokens>0?on(V.inputTokens):"0"},{label:"Output Tokens",value:V.outputTokens>0?on(V.outputTokens):"0"},{label:"Reasoning Tokens",value:V.reasoningTokens>0?on(V.reasoningTokens):"0"},{label:"Cost",value:V.cost>0?`$${V.cost<.001?V.cost.toFixed(6):V.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:ed(W)},{label:"Last Activity",value:ed(F)}];if(!w&&K.length===0){let J;e[23]!==r?(J=X("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=J):J=e[24];let se;e[25]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=se):se=e[25];let ne;e[26]!==i?(ne=i?n.jsx(pa,{size:14,className:"text-muted-foreground"}):n.jsx(ri,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ne):ne=e[27];let ce;e[28]!==s||e[29]!==ne?(ce=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[se,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ne})]}),e[28]=s,e[29]=ne,e[30]=ce):ce=e[30];let xe;e[31]===Symbol.for("react.memo_cache_sentinel")?(xe=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=xe):xe=e[31];let ae;e[32]!==J||e[33]!==ce?(ae=n.jsxs("div",{className:J,children:[ce,xe]}),e[32]=J,e[33]=ce,e[34]=ae):ae=e[34],b=ae;break e}e[35]!==r?(v=X("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 G;e[37]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=G):G=e[37];let ee;e[38]!==i?(ee=i?n.jsx(pa,{size:14}):n.jsx(ri,{size:14}),e[38]=i,e[39]=ee):ee=e[39],e[40]!==s||e[41]!==ee?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[G,n.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:ee})]}),e[40]=s,e[41]=ee,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",m=H.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:H.map(Zb)})]}),p=n.jsx(Gb,{items:q});let Z;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=Z):Z=e[43],e[44]!==P||e[45]!==O||e[46]!==M?(g=n.jsxs("div",{className:"flex flex-col gap-3",children:[Z,n.jsx(Xb,{userTokens:M,assistantTokens:P,otherTokens:O})]}),e[44]=P,e[45]=O,e[46]=M,e[47]=g):g=e[47],_=K.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:K.map(J=>{const se=J.metadata?.created_at,ne=o?.id===J.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(ne?null:J),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:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:X("shrink-0 font-medium",J.role==="user"?"text-chart-1":"text-chart-2"),children:J.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:J.id})]}),se&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(se).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ne&&n.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(J,null,2)})]},J.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=v,e[15]=x,e[16]=b}else f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],v=e[14],x=e[15],b=e[16];if(b!==Symbol.for("react.early_return_sentinel"))return b;let y;e[48]!==f||e[49]!==m||e[50]!==p||e[51]!==g||e[52]!==_?(y=n.jsxs("div",{className:f,children:[m,p,g,_]}),e[48]=f,e[49]=m,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let C;return e[54]!==v||e[55]!==x||e[56]!==y?(C=n.jsxs("div",{className:v,children:[x,y]}),e[54]=v,e[55]=x,e[56]=y,e[57]=C):C=e[57],C}function Zb(t,e){return n.jsx(Jb,{part:t},e)}function e0(t){return(t.parts??[]).filter(t0)}function t0(t){return t.type==="tool-subtask"}function s0(t){return t.role!=="system"}function i0(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function n0(t){return t.role==="assistant"}function r0(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function o0(t){return t.role==="user"}function a0(t){return t.role==="assistant"&&t.metadata?.usage}const td=["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"],sd=["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 l0(){const t=td[Math.floor(Math.random()*td.length)],e=sd[Math.floor(Math.random()*sd.length)];return`deco/${t}-${e}`}function c0(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 d0(t){const e=B.c(25),{orgId:s,userId:i,connectionId:r,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=r??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const f=Le(h);let m;e[3]!==a||e[4]!==l?(m={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=m):m=e[5];const p=d&&!!r&&!!a&&!!l;let g;e[6]!==f||e[7]!==m||e[8]!==p?(g={client:f,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:m0},e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:v,isError:x}=ki(g);let b,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),b=[...y].sort().map(f0),e[10]=i,e[11]=o,e[12]=b,e[13]=y):(b=e[12],y=e[13]);const C=b;let k;if(e[14]!==_||e[15]!==y){const R=Array.isArray(_)?_:_?.branches??[];let T;e[17]!==y?(T=I=>!y.has(I.name),e[17]=y,e[18]=T):T=e[18],k=R.filter(u0).filter(T).map(h0),e[14]=_,e[15]=y,e[16]=k}else k=e[16];const w=k,V=Array.isArray(_)?null:_?.default_branch??null;let j;return e[19]!==V||e[20]!==x||e[21]!==v||e[22]!==w||e[23]!==C?(j={yours:C,others:w,defaultBase:V,isLoading:v,isError:x},e[19]=V,e[20]=x,e[21]=v,e[22]=w,e[23]=C,e[24]=j):j=e[24],j}function h0(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function u0(t){return typeof t.name=="string"}function f0(t){return{name:t,source:"yours"}}function m0(t){return c0(t)}function p0(t){const e=B.c(41),{orgId:s,userId:i,connectionId:r,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=S.useState(!1);let f;e[0]!==r||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(f={orgId:s,userId:i,connectionId:r,vmMap:l,owner:o,repo:a,enabled:u},e[0]=r,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=f):f=e[7];const{yours:m,others:p,isLoading:g,isError:_}=d0(f);let v;e[8]!==d?(v=E=>{d(E),h(!1)},e[8]=d,e[9]=v):v=e[9];const x=v,b=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(yn,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let C;e[11]!==b?(C=n.jsx(li,{asChild:!0,children:n.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,n.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[11]=b,e[12]=C):C=e[12];let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(v_,{placeholder:"Search branches…"}),e[13]=k):k=e[13];let w;e[14]!==x?(w=n.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:[k,n.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>x(l0()),children:"New"})]}),e[14]=x,e[15]=w):w=e[15];let V;e[16]!==_?(V=_&&n.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[16]=_,e[17]=V):V=e[17];let j;e[18]!==_||e[19]!==g||e[20]!==p.length||e[21]!==m.length?(j=!_&&!g&&m.length===0&&p.length===0&&n.jsx(__,{children:"No branches found."}),e[18]=_,e[19]=g,e[20]=p.length,e[21]=m.length,e[22]=j):j=e[22];let R;e[23]!==x||e[24]!==m?(R=m.length>0&&n.jsx(Nc,{heading:"Your branches",children:m.map(E=>n.jsxs(Ac,{value:E.name,onSelect:()=>x(E.name),children:[n.jsx(yn,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:E.name})]},E.name))}),e[23]=x,e[24]=m,e[25]=R):R=e[25];let T;e[26]!==p||e[27]!==x?(T=p.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(x_,{}),n.jsx(Nc,{heading:"Other branches in repo",children:p.map(E=>n.jsxs(Ac,{value:E.name,onSelect:()=>x(E.name),children:[n.jsx(yn,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:E.name}),E.author&&n.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",E.author]})]},E.name))})]}),e[26]=p,e[27]=x,e[28]=T):T=e[28];let I;e[29]!==T||e[30]!==V||e[31]!==j||e[32]!==R?(I=n.jsxs(b_,{children:[V,j,R,T]}),e[29]=T,e[30]=V,e[31]=j,e[32]=R,e[33]=I):I=e[33];let A;e[34]!==I||e[35]!==w?(A=n.jsx(ci,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(y_,{children:[w,I]})}),e[34]=I,e[35]=w,e[36]=A):A=e[36];let N;return e[37]!==u||e[38]!==A||e[39]!==C?(N=n.jsxs(di,{open:u,onOpenChange:h,children:[C,A]}),e[37]=u,e[38]=A,e[39]=C,e[40]=N):N=e[40],N}const g0=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),_0="/decotexture.svg";function id(t){const e=B.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:g0},e[0]=i):i=e[0];let r,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:n.jsx(Ps,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=n.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("img",{src:_0,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:n.jsx(uo,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=n.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[r,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function x0(){const t=B.c(5),{data:e}=St.useSession();let s;t[0]!==e?.user?.email?(s=ct.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let r;t[2]!==s||t[3]!==i?(r={queryKey:s,queryFn:v0,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=r):r=t[4];const{data:o}=Wi(r);return o?.isDecoUser??!1}async function v0(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function b0(t){const e=B.c(56),{onOpenContextPanel:s}=t,{data:i}=St.useSession(),[r,o]=S.useState(!1),a=x0(),l=Ms(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:f}=_o();let m;e[0]!==i?.user?.name?(m=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=m):m=e[1];const p=m,g=c&&u&&h!=null,_=c&&d&&f;if(l){let A;e[2]!==h||e[3]!==g?(A=g&&n.jsx("div",{className:"mb-4",children:n.jsx(Oe.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=A):A=e[4];let N;e[5]!==_?(N=_&&n.jsx("div",{className:"mb-4",children:n.jsx(Oe.NoCreditsEyebrow,{})}),e[5]=_,e[6]=N):N=e[6];let E;e[7]!==p?(E=n.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=E):E=e[8];let M;e[9]!==A||e[10]!==N||e[11]!==E?(M=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[A,N,E]}),e[9]=A,e[10]=N,e[11]=E,e[12]=M):M=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Zc,{}),e[13]=L):L=e[13];let D;e[14]!==s?(D=n.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,n.jsx(Oe.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=D):D=e[15];let P;e[16]!==a?(P=a&&n.jsx("div",{className:"w-full",children:n.jsx(id,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let O;e[18]!==M||e[19]!==D||e[20]!==P?(O=n.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[M,D,P]}),e[18]=M,e[19]=D,e[20]=P,e[21]=O):O=e[21];let $;e[22]!==r?($=n.jsx(Ur,{open:r,onOpenChange:o}),e[22]=r,e[23]=$):$=e[23];let z;return e[24]!==$||e[25]!==O?(z=n.jsxs(n.Fragment,{children:[O,$]}),e[24]=$,e[25]=O,e[26]=z):z=e[26],z}let v;e[27]!==h||e[28]!==g?(v=g&&n.jsx("div",{className:"mb-4",children:n.jsx(Oe.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=v):v=e[29];let x;e[30]!==_?(x=_&&n.jsx("div",{className:"mb-4",children:n.jsx(Oe.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let b;e[32]!==p?(b=n.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=b):b=e[33];let y;e[34]!==v||e[35]!==x||e[36]!==b?(y=n.jsxs("div",{className:"text-center mb-10",children:[v,x,b]}),e[34]=v,e[35]=x,e[36]=b,e[37]=y):y=e[37];let C;e[38]!==s?(C=n.jsx("div",{className:"w-full",children:n.jsx(Oe.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=C):C=e[39];let k;e[40]!==y||e[41]!==C?(k=n.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,C]}),e[40]=y,e[41]=C,e[42]=k):k=e[42];let w;e[43]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("div",{className:"w-full mt-10 mx-auto",children:n.jsx(Zc,{})}),e[43]=w):w=e[43];let V;e[44]!==k?(V=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[k,w]}),e[44]=k,e[45]=V):V=e[45];let j;e[46]!==a?(j=a&&n.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:n.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:n.jsx(id,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=j):j=e[47];let R;e[48]!==j||e[49]!==V?(R=n.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[V,j]}),e[48]=j,e[49]=V,e[50]=R):R=e[50];let T;e[51]!==r?(T=n.jsx(Ur,{open:r,onOpenChange:o}),e[51]=r,e[52]=T):T=e[52];let I;return e[53]!==R||e[54]!==T?(I=n.jsxs(n.Fragment,{children:[R,T]}),e[53]=R,e[54]=T,e[55]=I):I=e[55],I}function y0(){const t=B.c(26),{org:e}=ye(),{selectedVirtualMcp:s}=ai(),{data:i}=St.useSession(),{currentBranch:r,setCurrentTaskBranch:o}=es();let a;t[0]!==e.id?(a=ho(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=is(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,f=!!h?.connectionId&&!!u;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(go,{size:32}),t[2]=m):m=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=n.jsx(Ps,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==_?(v=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=v):v=t[9];let x;t[10]!==r||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==f||t[16]!==u?(x=f&&n.jsx("div",{className:"mt-2",children:n.jsx(p0,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:r??void 0,onChange:o})}),t[10]=r,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=f,t[16]=u,t[17]=x):x=t[17];let b;t[18]!==p||t[19]!==g||t[20]!==v||t[21]!==x?(b=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,v,x]}),t[18]=p,t[19]=g,t[20]=v,t[21]=x,t[22]=b):b=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"w-full max-w-3xl mx-auto",children:n.jsx(Oe.IceBreakers,{})}),t[23]=y):y=t[23];let C;return t[24]!==b?(C=n.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,y]}),t[24]=b,t[25]=C):C=t[25],C}function S0(t){const e=B.c(27),{variant:s}=t,{org:i}=ye(),r=Nl(),{isChatEmpty:o}=Gi(),[a,l]=S.useState("chat"),c=_o();if(r.length===0){let C;return e[0]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Oe,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Oe.Main,{className:"flex flex-col items-center",children:n.jsx(Oe.EmptyState,{children:n.jsx(Oe.NoAiProviderEmptyState,{})})})}),e[0]=C):C=e[0],C}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!Xv(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&n.jsx(Oe.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const f=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;e[10]!==f?(m=X("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),e[10]=f,e[11]=m):m=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?n.jsx(b0,{onOpenContextPanel:()=>l("context")}):n.jsxs(n.Fragment,{children:[n.jsx(Oe.Main,{children:n.jsx(y0,{})}),n.jsx(Oe.Footer,{children:n.jsx(Oe.Input,{onOpenContextPanel:()=>l("context")})})]}):n.jsxs(n.Fragment,{children:[n.jsx(Oe.Main,{children:n.jsx(Oe.Messages,{})}),n.jsx(Oe.Footer,{children:n.jsx(Oe.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==m||e[16]!==p?(g=n.jsx("div",{className:m,children:p}),e[15]=m,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let v;e[18]!==_?(v=X("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=v):v=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Qb,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let b;e[21]!==v?(b=n.jsx("div",{className:v,children:x}),e[21]=v,e[22]=b):b=e[22];let y;return e[23]!==b||e[24]!==h||e[25]!==g?(y=n.jsxs(Oe,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,b]}),e[23]=b,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function of(t){const e=B.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Oe.Skeleton,{}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Oe.Skeleton,{}),e[1]=r):r=e[1];let o;return e[2]!==s?(o=n.jsx(Ns,{fallback:i,children:n.jsx(S.Suspense,{fallback:r,children:n.jsx(S0,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function w0(){const t=B.c(6),{org:e,locator:s}=ye(),i=Mt();let r;t[0]!==s||t[1]!==i?(r=()=>{i.invalidateQueries({queryKey:ct.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=r):r=t[2];let o;t[3]!==e.id||t[4]!==r?(o={orgId:e.id,onTaskStatus:r},t[3]=e.id,t[4]=r,t[5]=o):o=t[5],E_(o)}function V0(t){const e=B.c(8),{virtualMcpId:s,size:i,showAutomationBadge:r}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?n.jsx(C0,{virtualMcpId:s,size:o}):n.jsx(gs,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==r?(l=r&&n.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:n.jsx(Ui,{size:10,className:"text-white"})}),e[3]=r,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=n.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function C0(t){const e=B.c(6),{virtualMcpId:s,size:i}=t,r=is(s);if(!r){let l;return e[0]!==i?(l=n.jsx(gs,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=r.icon??null;let a;return e[2]!==r.title||e[3]!==i||e[4]!==o?(a=n.jsx(gs,{icon:o,name:r.title,size:i}),e[2]=r.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Fs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function k0(t){const e=B.c(42),{task:s,isActive:i,onClick:r,onArchive:o,showAutomationBadge:a}=t,l=Qp(s.status),c=l.icon,d=is(s.virtual_mcp_id);let u;e[0]!==d?(u=Fs(d),e[0]=d,e[1]=u):u=e[1];const h=u,f="button",m=0;let p;e[2]!==r?(p=O=>{O.target===O.currentTarget&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),r())},e[2]=r,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=X("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let v;e[6]!==a||e[7]!==s.virtual_mcp_id?(v=n.jsx(V0,{virtualMcpId:s.virtual_mcp_id,size:"xs",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=v):v=e[8];const x=s.title||"Untitled task";let b;e[9]!==x?(b=n.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=b):b=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&n.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"truncate font-mono",children:s.branch}),n.jsx("span",{className:"shrink-0",children:"·"})]}):h?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),n.jsx("span",{className:"shrink-0",children:"·"})]}):null,n.jsx("span",{className:"shrink-0",children:Zp(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let C;e[15]!==y||e[16]!==b?(C=n.jsxs("div",{className:"flex-1 min-w-0",children:[b,y]}),e[15]=y,e[16]=b,e[17]=C):C=e[17];const k="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",w="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",V=l.label,j=14,R=X(l.iconClassName,s.status==="in_progress"&&"animate-spin");let T;e[18]!==c||e[19]!==R?(T=n.jsx(c,{size:j,className:R}),e[18]=c,e[19]=R,e[20]=T):T=e[20];let I;e[21]!==l||e[22]!==T?(I=n.jsx("span",{className:w,"aria-label":V,children:T}),e[21]=l,e[22]=T,e[23]=I):I=e[23];let A;e[24]!==o?(A=O=>{O.stopPropagation(),o()},e[24]=o,e[25]=A):A=e[25];let N;e[26]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(jg,{size:14}),e[26]=N):N=e[26];let E;e[27]!==A?(E=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Archive task",onClick:A,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:N})}),e[27]=A,e[28]=E):E=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(it,{side:"right",children:"Archive"}),e[29]=M):M=e[29];let L;e[30]!==E?(L=n.jsxs(nt,{children:[E,M]}),e[30]=E,e[31]=L):L=e[31];let D;e[32]!==I||e[33]!==L?(D=n.jsxs("div",{className:k,children:[I,L]}),e[32]=I,e[33]=L,e[34]=D):D=e[34];let P;return e[35]!==r||e[36]!==C||e[37]!==D||e[38]!==p||e[39]!==_||e[40]!==v?(P=n.jsxs("div",{role:f,tabIndex:m,onClick:r,onKeyDown:p,className:_,children:[v,C,D]}),e[35]=r,e[36]=C,e[37]=D,e[38]=p,e[39]=_,e[40]=v,e[41]=P):P=e[41],P}const af={all:"All tasks",manual:"Chats",automation:"Automation"},lf={all:"All members",mine:"Mine only"};function j0(t){const e=B.c(57),{title:s,tasks:i,activeTaskId:r,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[f,m]=S.useState("all"),[p,g]=S.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(K=>K.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const v=_;let x;e[4]!==f||e[5]!==v?(x=f==="automation"?v.filter(I0):f==="manual"?v.filter(E0):v,e[4]=f,e[5]=v,e[6]=x):x=e[6];const b=x;let y;e[7]!==s?(y=n.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let C;e[9]!==p?(C=n.jsx(Es,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?n.jsx(Ng,{size:16}):n.jsx(go,{size:16})})}),e[9]=p,e[10]=C):C=e[10];let k;e[11]!==p?(k=K=>{const H=K;H!==p&&ie("tasks_panel_member_filter_changed",{to_value:H}),g(H)},e[11]=p,e[12]=k):k=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=Object.keys(lf),e[13]=w):w=e[13];let V;e[14]===Symbol.for("react.memo_cache_sentinel")?(V=w.map(A0),e[14]=V):V=e[14];let j;e[15]!==p||e[16]!==k?(j=n.jsx(Is,{align:"end",children:n.jsx(xc,{value:p,onValueChange:k,children:V})}),e[15]=p,e[16]=k,e[17]=j):j=e[17];let R;e[18]!==C||e[19]!==j?(R=n.jsxs(As,{children:[C,j]}),e[18]=C,e[19]=j,e[20]=R):R=e[20];const T=f!=="all"&&"text-purple-500";let I;e[21]!==T?(I=X("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",T),e[21]=T,e[22]=I):I=e[22];let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(Xg,{size:16}),e[23]=A):A=e[23];let N;e[24]!==I?(N=n.jsx(Es,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Filter tasks",className:I,children:A})}),e[24]=I,e[25]=N):N=e[25];let E;e[26]!==f?(E=K=>{const H=K;H!==f&&ie("tasks_panel_filter_changed",{to_value:H}),m(H)},e[26]=f,e[27]=E):E=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(af),e[28]=M):M=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=M.map(N0),e[29]=L):L=e[29];let D;e[30]!==f||e[31]!==E?(D=n.jsx(Is,{align:"end",children:n.jsx(xc,{value:f,onValueChange:E,children:L})}),e[30]=f,e[31]=E,e[32]=D):D=e[32];let P;e[33]!==N||e[34]!==D?(P=n.jsxs(As,{children:[N,D]}),e[33]=N,e[34]=D,e[35]=P):P=e[35];let O;e[36]!==l||e[37]!==c||e[38]!==s?(O=c&&l&&n.jsx("button",{type:"button",onClick:()=>{ie("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:n.jsx(wl,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=O):O=e[39];let $;e[40]!==P||e[41]!==O||e[42]!==R?($=n.jsxs("div",{className:"flex items-center gap-0.5",children:[R,P,O]}),e[40]=P,e[41]=O,e[42]=R,e[43]=$):$=e[43];let z;e[44]!==$||e[45]!==y?(z=n.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,$]}),e[44]=$,e[45]=y,e[46]=z):z=e[46];let W;e[47]!==r||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==b?(W=b.length===0&&u?n.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):b.map(K=>n.jsx(k0,{task:K,isActive:r===K.id,onClick:()=>{r!==K.id&&ie("tasks_panel_task_clicked",{thread_id:K.id,virtual_mcp_id:K.virtual_mcp_id??null,from_automation:!!K.fromAutomation}),o(K)},onArchive:()=>{ie("tasks_panel_task_archived",{thread_id:K.id,virtual_mcp_id:K.virtual_mcp_id??null}),a(K)},showAutomationBadge:d||K.fromAutomation},K.id)),e[47]=r,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=b,e[53]=W):W=e[53];let F;return e[54]!==z||e[55]!==W?(F=n.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[z,W]}),e[54]=z,e[55]=W,e[56]=F):F=e[56],F}function N0(t){return n.jsx(Yh,{value:t,children:af[t]},t)}function A0(t){return n.jsx(Yh,{value:t,children:lf[t]},t)}function E0(t){return!t.fromAutomation}function I0(t){return t.fromAutomation}function R0(){const t=B.c(22);w0();const{data:e}=St.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:r}=ha(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=ha(o),{setTaskId:l,createNewTask:c}=Wn();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=Hn(d),{locator:h,org:f}=ye(),m=Mt();let p;t[3]!==f.id?(p={connectionId:Pt,orgId:f.id},t[3]=f.id,t[4]=p):p=t[4];const g=Le(p),_=u.taskId??null;let v;t[5]!==a||t[6]!==r?(v=[...r,...a.map(D0)].sort(T0),t[5]=a,t[6]=r,t[7]=v):v=t[7];const x=v;let b;t[8]!==g||t[9]!==h||t[10]!==m?(b=async w=>{try{await Fp(g,w.id,{hidden:!0}),m.invalidateQueries({queryKey:ct.tasksPrefix(h)})}catch(V){const R=V;fe.error(`Failed to archive task: ${R.message}`)}},t[8]=g,t[9]=h,t[10]=m,t[11]=b):b=t[11];const y=b;if(x.length===0){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("div",{className:"h-full flex items-center justify-center p-4",children:n.jsx(Fi,{image:n.jsx(Ag,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=w):w=t[12],w}let C;t[13]!==l?(C=w=>l(w.id,w.virtual_mcp_id),t[13]=l,t[14]=C):C=t[14];let k;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==C?(k=n.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:n.jsx(j0,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:C,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=C,t[21]=k):k=t[21],k}function T0(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function D0(t){return{...t,fromAutomation:!0}}function M0(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(P0)}),t[0]=e):e=t[0],e}function P0(t,e){return n.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function cf(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Oe.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Ns,{fallback:e,children:n.jsx(S.Suspense,{fallback:n.jsx(M0,{}),children:n.jsx(R0,{})})}),t[1]=s):s=t[1],s}function df(){const t=B.c(77),{org:e}=ye(),s=qe(),i=Th(),{setTasksOpen:r,openTab:o}=Wn(),a=e.slug,l=ye().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=Hn(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=Si(u),f=i.location.pathname;let m;t[2]!==l.enabledPlugins?(m=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=m):m=t[3];const p=m;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let v,x,b,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let H;t[17]!==p?(H=se=>p.includes(se.pluginId),t[17]=p,t[18]=H):H=t[18];const U=up.filter(H),Y=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const q=d.taskId??"",G=d.pluginId;let ee;t[19]!==G?(ee=se=>G===se,t[19]=G,t[20]=ee):ee=t[20],v=ee;let Z;t[21]!==q||t[22]!==s||t[23]!==a||t[24]!==Y?(Z=se=>{const ne=q||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:ne,pluginId:se},search:ce=>({...ce,virtualmcpid:Y})})},t[21]=q,t[22]=s,t[23]=a,t[24]=Y,t[25]=Z):Z=t[25],b=Z;let J;t[26]!==v||t[27]!==b?(J=se=>({key:se.pluginId,label:se.label,icon:se.icon,isActive:v(se.pluginId),onClick:()=>b(se.pluginId)}),t[26]=v,t[27]=b,t[28]=J):J=t[28],y=U.map(J),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=v,t[14]=x,t[15]=b,t[16]=y}else v=t[13],x=t[14],b=t[15],y=t[16];const C=y;let k;if(t[29]!==p||t[30]!==v||t[31]!==b){let H;t[33]!==p?(H=q=>p.includes(q.pluginId),t[33]=p,t[34]=H):H=t[34];const U=fp.filter(H);let Y;t[35]!==v||t[36]!==b?(Y=q=>({type:"group",group:{id:`${q.pluginId}-${q.id}`,label:q.label,items:q.items.map((G,ee)=>({key:`${q.pluginId}-${q.id}-${ee}`,label:G.label,icon:G.icon,isActive:v(q.pluginId),onClick:()=>b(q.pluginId)})),defaultExpanded:q.defaultExpanded??!0}}),t[35]=v,t[36]=b,t[37]=Y):Y=t[37],k=U.map(Y),t[29]=p,t[30]=v,t[31]=b,t[32]=k}else k=t[32];const w=k;let V;if(t[38]!==o||t[39]!==_){let H;t[41]!==o?(H=U=>{const Y=Kn(U.icon),q=Y.type==="icon"?qn(Y.name):null;return{key:`app-${U.connectionId}-${U.toolName}`,label:U.label||U.toolName,icon:q?n.jsx(q,{size:16,className:"text-muted-foreground"}):Y.type==="url"?n.jsx("img",{src:Y.url,alt:"",className:"size-4 rounded"}):n.jsx(ju,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(ua(U.connectionId,U.toolName))}},t[41]=o,t[42]=H):H=t[42],V=_.map(H),t[38]=o,t[39]=_,t[40]=V}else V=t[40];const j=V;let R;t[43]!==j?(R=j.length>0?{type:"group",group:{id:"apps",label:"Apps",items:j,defaultExpanded:!0}}:null,t[43]=j,t[44]=R):R=t[44];const T=R;let I;t[45]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(Eg,{className:"size-4!"}),t[45]=I):I=t[45];const A=f===`/${a}`||f===`/${a}/`;let N;t[46]!==s||t[47]!==a||t[48]!==r?(N=()=>{r(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=r,t[49]=N):N=t[49];let E;t[50]!==N||t[51]!==A?(E={key:"home",label:"Home",icon:I,isActive:A,onClick:N},t[50]=N,t[51]=A,t[52]=E):E=t[52];const M=E;let L;t[53]!==p?(L=p.includes(mp),t[53]=p,t[54]=L):L=t[54];const D=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(pp,{className:"size-4!"}),t[55]=P):P=t[55];let O;t[56]!==a||t[57]!==f?(O=f.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=f,t[58]=O):O=t[58];let $;t[59]!==s||t[60]!==a?($=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=$):$=t[61];let z;t[62]!==O||t[63]!==$?(z={key:"workflows",label:"Workflows",icon:P,isActive:O,onClick:$},t[62]=O,t[63]=$,t[64]=z):z=t[64];const W=z;let F;if(t[65]!==M||t[66]!==x||t[67]!==D||t[68]!==W){const H=[M];x&&D&&H.push(W),F={type:"items",items:H},t[65]=M,t[66]=x,t[67]=D,t[68]=W,t[69]=F}else F=t[69];let K;if(t[70]!==T||t[71]!==w||t[72]!==C||t[73]!==F){if(K=[F],C.length>0){let H;t[75]!==C?(H={type:"items",items:C},t[75]=C,t[76]=H):H=t[76],K.push(H)}w.length>0&&K.push(...w),T&&K.push(T),t[70]=T,t[71]=w,t[72]=C,t[73]=F,t[74]=K}else K=t[74];return K}function hf(t){const e=B.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex h-6 items-center",children:n.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsxs(Xn,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,n.jsx(Jn,{children:n.jsx(vs,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=r):r=e[2],r}function L0(){const t=B.c(7),s=Dh().logo??Mh,i=typeof s=="string"?s:s.light,r=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=n.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==r?(a=n.jsx("img",{src:r,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=r,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=n.jsx(Eu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:n.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function uf(t){const e=B.c(15),{item:s}=t,{isMobile:i,setOpenMobile:r}=Qn();let o;e[0]!==i||e[1]!==s||e[2]!==r?(o=()=>{ie("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&r(!1)},e[0]=i,e[1]=s,e[2]=r,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=X(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=n.jsx(_s,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=n.jsx(Zt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function O0(t){const e=B.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Nu,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,r=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(z0),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=n.jsx(hf,{label:i,defaultExpanded:r,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map(B0),e[8]=s.items,e[9]=i):i=e[9];let r;return e[10]!==i?(r=n.jsx(Xn,{className:"pt-0 pr-0 pb-0 pl-0",children:n.jsx(Jn,{children:n.jsx(vs,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=r):r=e[11],r}}}function B0(t){return n.jsx(uf,{item:t},t.key)}function z0(t){return n.jsx(uf,{item:t},t.key)}function $0(t){const e=B.c(14),{sections:s,header:i,footer:r,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"h-10 shrink-0"}),children:n.jsx(L0,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=X("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(F0),e[3]=s,e[4]=h):h=e[4];let f;e[5]!==o||e[6]!==u||e[7]!==h?(f=n.jsxs(Au,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=f):f=e[8];let m;return e[9]!==r||e[10]!==i||e[11]!==f||e[12]!==c?(m=n.jsxs(I_,{variant:c,children:[d,i,f,r]}),e[9]=r,e[10]=i,e[11]=f,e[12]=c,e[13]=m):m=e[13],m}function F0(t,e){return n.jsx(O0,{section:t},e)}function ff(t){const e=B.c(2);let s;return e[0]!==t?(s=n.jsx($0,{...t}),e[0]=t,e[1]=s):s=e[1],s}ff.Skeleton=function(){return n.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>n.jsx("div",{className:"w-full h-8",children:n.jsx($i,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function U0(){const t=B.c(7),s=Dh().logo??Mh,i=typeof s=="string"?s:s.light,r=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=n.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==r?(a=n.jsx("img",{src:r,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=r,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=n.jsx(Eu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:n.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function nd(t){const e=B.c(15),{item:s,onClose:i}=t,r=s.isActive&&"z-10";let o;e[0]!==r?(o=X(r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=n.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=n.jsx(_s,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=n.jsx(Zt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function H0(t){const e=B.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Nu,{className:"my-2"}),e[0]=r):r=e[0],r}case"spacer":{let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"flex-1"}),e[1]=r):r=e[1],r}case"group":{const r=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>n.jsx(nd,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=n.jsx(hf,{label:r,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let r;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>n.jsx(nd,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],r=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=r}else r=e[13];let o;return e[16]!==r?(o=n.jsx(Xn,{className:"pt-0 pr-0 pb-0 pl-0",children:n.jsx(Jn,{children:n.jsx(vs,{className:"gap-1.5",children:r})})}),e[16]=r,e[17]=o):o=e[17],o}}}function W0(t){const e=B.c(12),{sections:s,onClose:i,footer:r,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"h-10 shrink-0"}),children:n.jsx(U0,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,f)=>n.jsx(H0,{section:h,onClose:i},f),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=n.jsxs(Au,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==r||e[10]!==c?(d=n.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,r]}),e[9]=r,e[10]=c,e[11]=d):d=e[11],d}function mf(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const K0=js({name:Et().min(2,"Organization name is required")});function q0(t){const e=B.c(41),{open:s,onOpenChange:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={resolver:Un(K0),defaultValues:{name:""}},e[0]=r):r=e[0];const o=qi(r);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:Y0,onSuccess:G0},e[1]=a):a=e[1];const l=Ki(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(Dl,{children:[n.jsx(Ml,{children:"Create a new organization"}),n.jsx(Pl,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let w;e[6]!==l?(w=V=>l.mutateAsync(V),e[6]=l,e[7]=w):w=e[7],u=o.handleSubmit(w),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=w=>{const{field:V}=w;return n.jsxs(Rt,{children:[n.jsx(os,{children:"Organization Name"}),n.jsx(Tt,{children:n.jsx(gt,{...V,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),n.jsx(Sg,{children:"The name of your company or organization"}),V.value&&n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",n.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",mf(V.value)]})]}),n.jsx(Dt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let f;e[10]!==o.control||e[11]!==h?(f=n.jsx(It,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=f):f=e[12];let m;e[13]!==c?(m=c&&n.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=n.jsx(Rl,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let v;e[21]!==o.formState.isSubmitting?(v=o.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(In,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=v):v=e[22];let x;e[23]!==_||e[24]!==v?(x=n.jsx(oe,{type:"submit",variant:"default",disabled:_,children:v}),e[23]=_,e[24]=v,e[25]=x):x=e[25];let b;e[26]!==x||e[27]!==g?(b=n.jsxs(Ll,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==u||e[31]!==f||e[32]!==m?(y=n.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[f,m,b]}),e[29]=b,e[30]=u,e[31]=f,e[32]=m,e[33]=y):y=e[33];let C;e[34]!==o||e[35]!==y?(C=n.jsxs(Tl,{children:[d,n.jsx(Bi,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=C):C=e[36];let k;return e[37]!==i||e[38]!==s||e[39]!==C?(k=n.jsx(Ol,{open:s,onOpenChange:i,children:C}),e[37]=i,e[38]=s,e[39]=C,e[40]=k):k=e[40],k}function G0(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function Y0(t){const e=mf(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await St.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function Va(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function X0(t){const e=B.c(13),{org:s,size:i}=t,r=i===void 0?"sm":i,o=r==="xs"?"size-5":"size-6",a=r==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=X(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:Va(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?n.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:X("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=n.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function ur(t){const e=B.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=n.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=n.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let f;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(f=n.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=f):f=e[10],f}let r;e[11]!==s||e[12]!==i?(r=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=r):r=e[13];let o;e[14]!==s.icon?(o=n.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=n.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==r||e[19]!==o||e[20]!==a?(l=n.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=r,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function rd(t){const e=B.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:r,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Qt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=n.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,n.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==r||e[5]!==i||e[6]!==s){let f;e[8]!==r||e[9]!==i?(f=m=>n.jsxs("button",{type:"button",onClick:()=>r(m.slug),className:X("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",m.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[n.jsx(X0,{org:m,size:"sm"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:m.name}),n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:m.slug})]}),m.slug===i&&n.jsx(Jt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},m.id),e[8]=r,e[9]=i,e[10]=f):f=e[10],d=s.map(f),e[4]=r,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=n.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=n.jsxs(n.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function od(t){const e=B.c(142),{user:s,userImage:i,menuItems:r,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f,close:m,isMobile:p}=t;if(p){const q=s?.name??"U";let G;e[0]!==q||e[1]!==i?(G=n.jsx(Ic,{url:i,fallback:q,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=q,e[1]=i,e[2]=G):G=e[2];const ee=s?.name??"User";let Z;e[3]!==ee?(Z=n.jsx("p",{className:"text-sm font-medium truncate",children:ee}),e[3]=ee,e[4]=Z):Z=e[4];const J=s?.email;let se;e[5]!==J?(se=n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:J}),e[5]=J,e[6]=se):se=e[6];let ne;e[7]!==Z||e[8]!==se?(ne=n.jsxs("div",{className:"flex-1 min-w-0",children:[Z,se]}),e[7]=Z,e[8]=se,e[9]=ne):ne=e[9];let ce;e[10]!==s?(ce=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(ey)},e[10]=s,e[11]=ce):ce=e[11];let xe;e[12]===Symbol.for("react.memo_cache_sentinel")?(xe=n.jsx(zi,{size:14}),e[12]=xe):xe=e[12];let ae;e[13]!==ce?(ae=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",tabIndex:-1,onClick:ce,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:xe})}),e[13]=ce,e[14]=ae):ae=e[14];let he;e[15]===Symbol.for("react.memo_cache_sentinel")?(he=n.jsx(it,{side:"right",children:n.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=he):he=e[15];let pe;e[16]!==ae?(pe=n.jsx(Oi,{delayDuration:300,children:n.jsxs(nt,{children:[ae,he]})}),e[16]=ae,e[17]=pe):pe=e[17];let me;e[18]!==pe||e[19]!==G||e[20]!==ne?(me=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[G,ne,pe]}),e[18]=pe,e[19]=G,e[20]=ne,e[21]=me):me=e[21];let we;e[22]!==f||e[23]!==h||e[24]!==u||e[25]!==d?(we=n.jsx("div",{className:"border-b border-border pb-2",children:n.jsx(rd,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[22]=f,e[23]=h,e[24]=u,e[25]=d,e[26]=we):we=e[26];let ve;if(e[27]!==m||e[28]!==r){let Be;e[30]!==m?(Be=Kt=>n.jsx(ur,{item:Kt,onClose:m},Kt.key),e[30]=m,e[31]=Be):Be=e[31],ve=r.map(Be),e[27]=m,e[28]=r,e[29]=ve}else ve=e[29];let de;e[32]!==m||e[33]!==o?(de=n.jsx(ur,{item:o,onClose:m}),e[32]=m,e[33]=o,e[34]=de):de=e[34];let Re;e[35]!==ve||e[36]!==de?(Re=n.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,de]}),e[35]=ve,e[36]=de,e[37]=Re):Re=e[37];let te;e[38]!==we||e[39]!==Re?(te=n.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[we,Re]}),e[38]=we,e[39]=Re,e[40]=te):te=e[40];let ue;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let Be;e[45]!==l.theme||e[46]!==c?(Be=Kt=>{const{value:kt,icon:Ie,label:Me}=Kt;return n.jsx("button",{type:"button","aria-label":Me,onClick:()=>c(Ye=>({...Ye,theme:kt})),className:X("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===kt?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Ie},kt)},e[45]=l.theme,e[46]=c,e[47]=Be):Be=e[47],ue=a.map(Be),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=ue}else ue=e[44];let Ve;e[48]!==ue?(Ve=n.jsx("div",{className:"flex items-center gap-0.5",children:ue}),e[48]=ue,e[49]=Ve):Ve=e[49];const Ee=l.enableSounds?"Disable sounds":"Enable sounds";let Te;e[50]!==c?(Te=()=>c(Z0),e[50]=c,e[51]=Te):Te=e[51];const be=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let je;e[52]!==be?(je=X("size-8 rounded-md flex items-center justify-center transition-colors",be),e[52]=be,e[53]=je):je=e[53];let $e;e[54]!==l.enableSounds?($e=l.enableSounds?n.jsx(vc,{size:14}):n.jsx(bc,{size:14}),e[54]=l.enableSounds,e[55]=$e):$e=e[55];let Ge;e[56]!==Ee||e[57]!==Te||e[58]!==je||e[59]!==$e?(Ge=n.jsx("button",{type:"button","aria-label":Ee,onClick:Te,className:je,children:$e}),e[56]=Ee,e[57]=Te,e[58]=je,e[59]=$e,e[60]=Ge):Ge=e[60];let ge;e[61]===Symbol.for("react.memo_cache_sentinel")?(ge=n.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.281.2"]}),e[61]=ge):ge=e[61];let Ae;e[62]!==Ge?(Ae=n.jsxs("div",{className:"flex items-center gap-2",children:[Ge,ge]}),e[62]=Ge,e[63]=Ae):Ae=e[63];let Ze;e[64]!==Ve||e[65]!==Ae?(Ze=n.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[Ve,Ae]}),e[64]=Ve,e[65]=Ae,e[66]=Ze):Ze=e[66];let Ct;return e[67]!==me||e[68]!==te||e[69]!==Ze?(Ct=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[me,te,Ze]}),e[67]=me,e[68]=te,e[69]=Ze,e[70]=Ct):Ct=e[70],Ct}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=n.jsx(Ic,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const v=s?.name??"User";let x;e[74]!==v?(x=n.jsx("p",{className:"text-sm font-medium truncate",children:v}),e[74]=v,e[75]=x):x=e[75];const b=s?.email;let y;e[76]!==b?(y=n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:b}),e[76]=b,e[77]=y):y=e[77];let C;e[78]!==x||e[79]!==y?(C=n.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=C):C=e[80];let k;e[81]!==s?(k=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(Q0)},e[81]=s,e[82]=k):k=e[82];let w;e[83]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(zi,{size:14}),e[83]=w):w=e[83];let V;e[84]!==k?(V=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",tabIndex:-1,onClick:k,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:w})}),e[84]=k,e[85]=V):V=e[85];let j;e[86]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(it,{side:"right",children:n.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=j):j=e[86];let R;e[87]!==V?(R=n.jsx(Oi,{delayDuration:300,children:n.jsxs(nt,{children:[V,j]})}),e[87]=V,e[88]=R):R=e[88];let T;e[89]!==R||e[90]!==_||e[91]!==C?(T=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,C,R]}),e[89]=R,e[90]=_,e[91]=C,e[92]=T):T=e[92];let I;if(e[93]!==m||e[94]!==r){let q;e[96]!==m?(q=G=>n.jsx(ur,{item:G,onClose:m},G.key),e[96]=m,e[97]=q):q=e[97],I=r.map(q),e[93]=m,e[94]=r,e[95]=I}else I=e[95];let A;e[98]!==m||e[99]!==o?(A=n.jsx(ur,{item:o,onClose:m}),e[98]=m,e[99]=o,e[100]=A):A=e[100];let N;e[101]!==I||e[102]!==A?(N=n.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[I,A]}),e[101]=I,e[102]=A,e[103]=N):N=e[103];let E;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let q;e[108]!==l.theme||e[109]!==c?(q=G=>{const{value:ee,icon:Z,label:J}=G;return n.jsx("button",{type:"button","aria-label":J,onClick:()=>c(se=>({...se,theme:ee})),className:X("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===ee?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Z},ee)},e[108]=l.theme,e[109]=c,e[110]=q):q=e[110],E=a.map(q),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=E}else E=e[107];let M;e[111]!==E?(M=n.jsx("div",{className:"flex items-center gap-0.5",children:E}),e[111]=E,e[112]=M):M=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let D;e[113]!==c?(D=()=>c(J0),e[113]=c,e[114]=D):D=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let O;e[115]!==P?(O=X("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=O):O=e[116];let $;e[117]!==l.enableSounds?($=l.enableSounds?n.jsx(vc,{size:14}):n.jsx(bc,{size:14}),e[117]=l.enableSounds,e[118]=$):$=e[118];let z;e[119]!==L||e[120]!==D||e[121]!==O||e[122]!==$?(z=n.jsx("button",{type:"button","aria-label":L,onClick:D,className:O,children:$}),e[119]=L,e[120]=D,e[121]=O,e[122]=$,e[123]=z):z=e[123];let W;e[124]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.281.2"]}),e[124]=W):W=e[124];let F;e[125]!==z?(F=n.jsxs("div",{className:"flex items-center gap-2",children:[z,W]}),e[125]=z,e[126]=F):F=e[126];let K;e[127]!==M||e[128]!==F?(K=n.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[M,F]}),e[127]=M,e[128]=F,e[129]=K):K=e[129];let H;e[130]!==T||e[131]!==N||e[132]!==K?(H=n.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[T,N,K]}),e[130]=T,e[131]=N,e[132]=K,e[133]=H):H=e[133];let U;e[134]!==f||e[135]!==h||e[136]!==u||e[137]!==d?(U=n.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:n.jsx(rd,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[134]=f,e[135]=h,e[136]=u,e[137]=d,e[138]=U):U=e[138];let Y;return e[139]!==H||e[140]!==U?(Y=n.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[H,U]}),e[139]=H,e[140]=U,e[141]=Y):Y=e[141],Y}function J0(t){return{...t,enableSounds:!t.enableSounds}}function Q0(){fe.success("User ID copied")}function Z0(t){return{...t,enableSounds:!t.enableSounds}}function ey(){fe.success("User ID copied")}function pf(){const t=B.c(50),{data:e}=St.useSession(),{data:s}=St.useListOrganizations(),i=qe();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org",shouldThrow:!1},t[0]=r):r=t[0];const a=gp(r)?.params.org,[l,c]=yi(),d=Ms(),[u,h]=S.useState(!1),[f,m]=S.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const b=s?.find(Y=>Y.slug===a);let y;if(t[11]!==a||t[12]!==s){let Y;t[14]!==a?(Y=(q,G)=>q.slug===a?-1:G.slug===a?1:q.name.localeCompare(G.name),t[14]=a,t[15]=Y):Y=t[15],y=[...s??[]].sort(Y),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const C=y;let k;t[16]!==i?(k=Y=>{h(!1),i({to:"/$org",params:{org:Y}})},t[16]=i,t[17]=k):k=t[17];const w=k;let V;t[18]===Symbol.for("react.memo_cache_sentinel")?(V=()=>h(!1),t[18]=V):V=t[18];const j=V;let R;t[19]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Zn,{size:16}),t[19]=R):R=t[19];let T;t[20]!==i||t[21]!==a?(T={key:"preferences",label:"Preferences",icon:R,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=T):T=t[22];let I;t[23]===Symbol.for("react.memo_cache_sentinel")?(I={key:"terms",label:"Terms of Use",icon:n.jsx(Ig,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=I):I=t[23];let A;t[24]===Symbol.for("react.memo_cache_sentinel")?(A={key:"privacy",label:"Privacy Policy",icon:n.jsx(Rg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=A):A=t[24];let N;t[25]===Symbol.for("react.memo_cache_sentinel")?(N={key:"github",label:"decocms/studio",icon:n.jsx(_p,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=N):N=t[25];let E;t[26]===Symbol.for("react.memo_cache_sentinel")?(E={key:"community",label:"Community",icon:n.jsx(go,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=E):E=t[26];let M;t[27]===Symbol.for("react.memo_cache_sentinel")?(M={key:"homepage",label:"Homepage",icon:n.jsx(du,{size:16}),href:"https://decocms.com",external:!0},t[27]=M):M=t[27];let L;t[28]!==T?(L=[T,I,A,N,E,M],t[28]=T,t[29]=L):L=t[29];const D=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:n.jsx(Fg,{size:16}),onClick:sy},t[30]=P):P=t[30];const O=P;let $;t[31]===Symbol.for("react.memo_cache_sentinel")?($={value:"light",icon:n.jsx(O_,{size:14}),label:"Light theme"},t[31]=$):$=t[31];let z;t[32]===Symbol.for("react.memo_cache_sentinel")?(z={value:"dark",icon:n.jsx(B_,{size:14}),label:"Dark theme"},t[32]=z):z=t[32];let W;t[33]===Symbol.for("react.memo_cache_sentinel")?(W=[$,z,{value:"system",icon:n.jsx(z_,{size:14}),label:"System theme"}],t[33]=W):W=t[33];const F=W;let K;t[34]===Symbol.for("react.memo_cache_sentinel")?(K=()=>{h(!1),m(!0)},t[34]=K):K=t[34];let H;t[35]!==w||t[36]!==d||t[37]!==D||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==C||t[42]!==p||t[43]!==g?(H={user:p,userImage:g,menuItems:D,signOutItem:O,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:C,orgParam:a,onSelectOrg:w,onCreateOrg:K,close:j,isMobile:d},t[35]=w,t[36]=d,t[37]=D,t[38]=a,t[39]=l,t[40]=c,t[41]=C,t[42]=p,t[43]=g,t[44]=H):H=t[44];const U=H;_=d?n.jsxs(Ci,{open:u,onOpenChange:h,direction:"bottom",children:[n.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[n.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:Va(b?.name??""),children:b?.logo?n.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(b?.name??"?").slice(0,2).toUpperCase()})}),n.jsx("span",{className:"truncate",children:b?.name??"Account"})]}),n.jsxs(Vi,{className:"h-[80dvh] p-0",children:[n.jsx(wi,{className:"sr-only",children:"Account"}),n.jsx(od,{...U})]})]}):n.jsxs(di,{open:u,onOpenChange:h,children:[n.jsx(li,{asChild:!0,children:n.jsx(_s,{tooltip:b?.name??"Account",className:"rounded-md",children:n.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:Va(b?.name??""),children:b?.logo?n.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(b?.name??"?").slice(0,2).toUpperCase()})})})}),n.jsx(ci,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:ty,children:n.jsx(od,{...U})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let v;t[45]!==f?(v=n.jsx(q0,{open:f,onOpenChange:m}),t[45]=f,t[46]=v):v=t[46];let x;return t[47]!==_||t[48]!==v?(x=n.jsxs(n.Fragment,{children:[_,v]}),t[47]=_,t[48]=v,t[49]=x):x=t[49],x}function ty(t){return t.preventDefault()}function sy(){ie("signed_out",{source:"account_popover"}),St.signOut()}function iy({invitation:t}){const[e,s]=S.useState(!1),[i,r]=S.useState(!1),o=Mt(),a=async()=>{s(!0);try{const c=await St.organization.acceptInvitation({invitationId:t.id});if(c.error)fe.error(c.error.message),s(!1);else{const d=await St.organization.setActive({organizationId:t.organizationId});fe.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{fe.error("Failed to accept invitation"),s(!1)}},l=async()=>{r(!0);try{const c=await St.organization.rejectInvitation({invitationId:t.id});c.error?(fe.error(c.error.message),r(!1)):(fe.success("Invitation declined"),o.invalidateQueries())}catch{fe.error("Failed to decline invitation"),r(!1)}};return n.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),n.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),n.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[n.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:n.jsx(Jt,{size:14})}),n.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:n.jsx(ri,{size:14})})]})]})}function ny(){const t=S.useContext(xp),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class ry extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function oy(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function ay(){const t=B.c(19),e=qe(),{org:s}=ye();let i;t[0]!==s.id?(i={connectionId:Pt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const r=Le(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==r?(a={client:r,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:ly},t[3]=r,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=ki(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const f=h;let m;t[9]!==u?(m=X(u!=null&&oy(u)),t[9]=u,t[10]=m):m=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Sl,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==m||t[16]!==p||t[17]!==f?(_=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:f,className:m,onClick:p,children:g})})}),t[15]=m,t[16]=p,t[17]=f,t[18]=_):_=t[18],_}function ly(t){return t.structuredContent}function cy(){const t=B.c(1);if(!Nl().some(dy))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ay,{}),t[0]=i):i=t[0],i}function dy(t){return t.providerId==="deco"}function hy(){const t=B.c(3),[e,s]=S.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Connections",onClick:()=>{ie("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:n.jsx(Ug,{size:24})})})}),t[0]=i):i=t[0];let r;return t[1]!==e?(r=n.jsxs(n.Fragment,{children:[i,n.jsx(Ul,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=r):r=t[2],r}function uy(){const t=B.c(11),e=ny();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(yc,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&n.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let r;t[3]!==i?(r=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(li,{asChild:!0,children:n.jsxs(_s,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=r):r=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:n.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=n.jsxs(ci,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[n.jsx(yc,{size:24,className:"text-muted-foreground/50"}),n.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):n.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(fy)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==r||t[9]!==a?(l=n.jsxs(di,{children:[r,a]}),t[8]=r,t[9]=a,t[10]=l):l=t[10],l}function fy(t){return n.jsx(iy,{invitation:t},t.id)}function my(){const t=B.c(6),e=qe(),{org:s}=ye();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Zn,{size:24}),t[3]=r):r=t[3];let o;return t[4]!==i?(o=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Settings",onClick:i,children:r})})}),t[4]=i,t[5]=o):o=t[5],o}function py(){const t=B.c(5);let e,s,i,r;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(ry,{children:n.jsx(S.Suspense,{fallback:null,children:n.jsx(cy,{})})}),s=n.jsx(hy,{}),i=n.jsx(uy,{}),r=n.jsx(my,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=r):(e=t[0],s=t[1],i=t[2],r=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs(Iu,{className:"px-2 pb-3 gap-1",children:[e,s,i,r,n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(pf,{})})})]}),t[4]=o):o=t[4],o}function gy(){const t=B.c(10),e=qe(),{org:s}=ye(),{setOpenMobile:i}=Qn();let r;t[0]!==e||t[1]!==s.slug||t[2]!==i?(r=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=r):r=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Zn,{}),t[4]=o):o=t[4];let a;t[5]!==r?(a=n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Settings",onClick:r,children:o})}),t[5]=r,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Zt,{children:n.jsx(pf,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=n.jsx(Iu,{children:n.jsxs(vs,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}function _y(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return S.useMemo(()=>i=>{e.forEach(r=>r(i))},e)}const vo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Yi(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Hl(t){return"nodeType"in t}function Wt(t){var e,s;return t?Yi(t)?t:Hl(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Wl(t){const{Document:e}=Wt(t);return t instanceof e}function tr(t){return Yi(t)?!1:t instanceof Wt(t).HTMLElement}function gf(t){return t instanceof Wt(t).SVGElement}function Xi(t){return t?Yi(t)?t.document:Hl(t)?Wl(t)?t:tr(t)||gf(t)?t.ownerDocument:document:document:document}const Ts=vo?S.useLayoutEffect:S.useEffect;function Kl(t){const e=S.useRef(t);return Ts(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}function xy(){const t=S.useRef(null),e=S.useCallback((i,r)=>{t.current=setInterval(i,r)},[]),s=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Mn(t,e){e===void 0&&(e=[t]);const s=S.useRef(t);return Ts(()=>{s.current!==t&&(s.current=t)},e),s}function sr(t,e){const s=S.useRef();return S.useMemo(()=>{const i=t(s.current);return s.current=i,i},[...e])}function Yr(t){const e=Kl(t),s=S.useRef(null),i=S.useCallback(r=>{r!==s.current&&e?.(r,s.current),s.current=r},[]);return[s,i]}function Ca(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let zo={};function ir(t,e){return S.useMemo(()=>{if(e)return e;const s=zo[t]==null?0:zo[t]+1;return zo[t]=s,t+"-"+s},[t,e])}function _f(t){return function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;r<s;r++)i[r-1]=arguments[r];return i.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const u=o[c];u!=null&&(o[c]=u+t*d)}return o},{...e})}}const Li=_f(1),Pn=_f(-1);function vy(t){return"clientX"in t&&"clientY"in t}function ql(t){if(!t)return!1;const{KeyboardEvent:e}=Wt(t.target);return e&&t instanceof e}function by(t){if(!t)return!1;const{TouchEvent:e}=Wt(t.target);return e&&t instanceof e}function ka(t){if(by(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return vy(t)?{x:t.clientX,y:t.clientY}:null}const Ln=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Ln.Translate.toString(t),Ln.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:i}=t;return e+" "+s+"ms "+i}}}),ad="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function yy(t){return t.matches(ad)?t:t.querySelector(ad)}const Sy={display:"none"};function wy(t){let{id:e,value:s}=t;return Ut.createElement("div",{id:e,style:Sy},s)}function Vy(t){let{id:e,announcement:s,ariaLiveType:i="assertive"}=t;const r={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ut.createElement("div",{id:e,style:r,role:"status","aria-live":i,"aria-atomic":!0},s)}function Cy(){const[t,e]=S.useState("");return{announce:S.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const xf=S.createContext(null);function ky(t){const e=S.useContext(xf);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function jy(){const[t]=S.useState(()=>new Set),e=S.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[S.useCallback(i=>{let{type:r,event:o}=i;t.forEach(a=>{var l;return(l=a[r])==null?void 0:l.call(a,o)})},[t]),e]}const Ny={draggable:`
|
|
548
|
+
`}]}}function ui(t){return{type:"paragraph",content:t}}function Ws(t){return{type:"text",text:t}}function Cb({agentId:t,title:e}){return{type:"mention",attrs:{id:t,name:e,char:"@",metadata:{agentId:t,title:e}}}}const mn="deco/site-diagnostics";function rf(t){const e=B.c(15),{open:s,onOpenChange:i}=t,[r,o]=S.useState(null);let a;e[0]!==i?(a=()=>{o(null),i(!1)},e[0]=i,e[1]=a):a=e[1];const l=a,c=s&&r===null;let d;e[2]!==r||e[3]!==i?(d=p=>{!p&&r===null&&i(!1)},e[2]=r,e[3]=i,e[4]=d):d=e[4];let u;e[5]!==c||e[6]!==d?(u=n.jsx(wu,{open:c,onOpenChange:d,title:"Set up self-healing repo",hideAutoRespondCheckbox:!0,onImportComplete:o}),e[5]=c,e[6]=d,e[7]=u):u=e[7];const h=s&&r!==null;let f;e[8]!==l||e[9]!==r||e[10]!==h?(f=n.jsx(kb,{open:h,payload:r,onClose:l}),e[8]=l,e[9]=r,e[10]=h,e[11]=f):f=e[11];let m;return e[12]!==u||e[13]!==f?(m=n.jsxs(n.Fragment,{children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14],m}function kb(t){const e=B.c(66),{open:s,payload:i,onClose:r}=t,{org:o}=ye(),a=Yn(),l=po();let c;e[0]!==o.id?(c={connectionId:Pt,orgId:o.id},e[0]=o.id,e[1]=c):c=e[1];const d=Le(c),[u,h]=S.useState(""),[f,m]=S.useState(Ab);let p;e[2]!==s?(p={enabled:s},e[2]=s,e[3]=p):p=e[3];const{data:g}=C_(mn,p);let _;e[4]!==l||e[5]!==f||e[6]!==i||e[7]!==d||e[8]!==g||e[9]!==u?(_=async()=>{if(!i)throw new Error("No imported repo payload");const Y=Qc(u);if(!Y)throw new Error("Enter a valid https:// URL");const q=wa.filter(J=>f[J.id]);if(q.length===0)return{succeeded:[],failed:[]};const G=await Tb({selfClient:d,createConnection:l.create.mutateAsync,registry:g}),ee=[],Z=[];for(const J of q)try{await Db({template:J,selfClient:d,siteDiagnosticsConnectionId:G,projectAgentId:i.virtualMcpId,owner:i.repo.owner,repo:i.repo.name,siteRootUrl:Y}),ee.push(J.title)}catch(se){const ne=se;console.error(`Failed to set up ${J.title}:`,ne),Z.push(J.title)}return{succeeded:ee,failed:Z}},e[4]=l,e[5]=f,e[6]=i,e[7]=d,e[8]=g,e[9]=u,e[10]=_):_=e[10];let v;e[11]!==a||e[12]!==r||e[13]!==i?.virtualMcpId?(v=Y=>{const{succeeded:q,failed:G}=Y;q.length>0?fe.success(`Self-healing repo ready — ${q.length} specialist${q.length>1?"s":""} set up`):G.length===0&&fe.success("Repo imported. Add specialists later from automations."),G.length>0&&fe.warning(`Could not set up: ${G.join(", ")}. You can add them later from the automations view.`);const ee=i?.virtualMcpId;r(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),ee&&a(ee)},e[11]=a,e[12]=r,e[13]=i?.virtualMcpId,e[14]=v):v=e[14];let x;e[15]!==_||e[16]!==v?(x={mutationFn:_,onSuccess:v,onError:Nb},e[15]=_,e[16]=v,e[17]=x):x=e[17];const b=Ki(x);let y;e[18]!==b.isPending||e[19]!==u?(y=Qc(u)!==null&&!b.isPending,e[18]=b.isPending,e[19]=u,e[20]=y):y=e[20];const C=y;let k;e[21]!==r||e[22]!==b.isPending?(k=Y=>{!Y&&!b.isPending&&r()},e[21]=r,e[22]=b.isPending,e[23]=k):k=e[23];let w;e[24]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(hs,{className:"h-12 border-b border-border px-4 flex flex-row items-center shrink-0 space-y-0",children:n.jsx(ds,{className:"text-sm font-medium text-foreground",children:"Add specialist monitors"})}),e[24]=w):w=e[24];let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Specialists run on a daily schedule. Your repo agent collects their findings and opens GitHub issues, then writes the fixes."}),e[25]=V):V=e[25];let j;e[26]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("label",{htmlFor:"self-healing-site-url",className:"text-xs font-medium text-foreground",children:"Production URL"}),e[26]=j):j=e[26];let R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=Y=>h(Y.target.value),e[27]=R):R=e[27];let T;e[28]!==u?(T=n.jsx(gt,{id:"self-healing-site-url",type:"url",placeholder:"https://example.com",value:u,onChange:R,autoFocus:!0}),e[28]=u,e[29]=T):T=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("p",{className:"text-xs text-muted-foreground",children:"The site the specialists will monitor."}),e[30]=I):I=e[30];let A;e[31]!==T?(A=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[j,T,I]}),e[31]=T,e[32]=A):A=e[32];let N;e[33]!==f?(N=wa.map(Y=>n.jsx(Eb,{template:Y,enabled:f[Y.id]??!1,onToggle:q=>m(G=>({...G,[Y.id]:q}))},Y.id)),e[33]=f,e[34]=N):N=e[34];let E,M;e[35]===Symbol.for("react.memo_cache_sentinel")?(E=Sb.map(jb),M=n.jsx(Rb,{}),e[35]=E,e[36]=M):(E=e[35],M=e[36]);let L;e[37]!==N?(L=n.jsxs("div",{className:"flex flex-col gap-2",children:[N,E,M]}),e[37]=N,e[38]=L):L=e[38];let D;e[39]!==A||e[40]!==L?(D=n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 flex flex-col gap-4",children:[V,A,L]}),e[39]=A,e[40]=L,e[41]=D):D=e[41];let P;e[42]!==a||e[43]!==r||e[44]!==i?.virtualMcpId||e[45]!==b.isPending?(P=()=>{if(!b.isPending){const Y=i?.virtualMcpId;r(),Y&&a(Y)}},e[42]=a,e[43]=r,e[44]=i?.virtualMcpId,e[45]=b.isPending,e[46]=P):P=e[46];let O;e[47]!==b.isPending||e[48]!==P?(O=n.jsx("button",{type:"button",onClick:P,disabled:b.isPending,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 cursor-pointer",children:"Skip for now"}),e[47]=b.isPending,e[48]=P,e[49]=O):O=e[49];let $;e[50]!==b?($=()=>b.mutate(),e[50]=b,e[51]=$):$=e[51];const z=!C,W=b.isPending?"Setting up...":"Set up specialists";let F;e[52]!==$||e[53]!==z||e[54]!==W?(F=n.jsx(oe,{onClick:$,disabled:z,size:"sm",children:W}),e[52]=$,e[53]=z,e[54]=W,e[55]=F):F=e[55];let K;e[56]!==O||e[57]!==F?(K=n.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center justify-between gap-3 shrink-0",children:[O,F]}),e[56]=O,e[57]=F,e[58]=K):K=e[58];let H;e[59]!==D||e[60]!==K?(H=n.jsxs(ts,{className:"sm:max-w-[560px] max-h-[85svh] p-0 gap-0 overflow-hidden flex flex-col",children:[w,D,K]}),e[59]=D,e[60]=K,e[61]=H):H=e[61];let U;return e[62]!==s||e[63]!==H||e[64]!==k?(U=n.jsx(ss,{open:s,onOpenChange:k,children:H}),e[62]=s,e[63]=H,e[64]=k,e[65]=U):U=e[65],U}function jb(t){return n.jsx(Ib,{title:t.title,description:t.description,icon:t.icon},t.id)}function Nb(t){fe.error("Failed to set up specialists: "+(t instanceof Error?t.message:"Unknown error"))}function Ab(){const t={};for(const e of wa)t[e.id]=!0;return t}function Eb(t){const e=B.c(20),{template:s,enabled:i,onToggle:r}=t,o=i?"bg-accent/30":"hover:bg-accent/30";let a;e[0]!==o?(a=X("flex items-center gap-3 rounded-lg border border-border px-3 py-3 cursor-pointer transition-colors",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==s.icon||e[3]!==s.title?(l=n.jsx(gs,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=l):l=e[4];let c;e[5]!==s.title?(c=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s.title}),e[5]=s.title,e[6]=c):c=e[6];let d;e[7]!==s.description?(d=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[7]=s.description,e[8]=d):d=e[8];let u;e[9]!==c||e[10]!==d?(u=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[c,d]}),e[9]=c,e[10]=d,e[11]=u):u=e[11];let h;e[12]!==i||e[13]!==r?(h=n.jsx(Hr,{checked:i,onCheckedChange:r,className:"shrink-0"}),e[12]=i,e[13]=r,e[14]=h):h=e[14];let f;return e[15]!==a||e[16]!==l||e[17]!==u||e[18]!==h?(f=n.jsxs("label",{className:a,children:[l,u,h]}),e[15]=a,e[16]=l,e[17]=u,e[18]=h,e[19]=f):f=e[19],f}function Ib(t){const e=B.c(14),{title:s,description:i,icon:r}=t;let o;e[0]!==r||e[1]!==s?(o=n.jsx(gs,{icon:r,name:s,size:"sm",className:"shrink-0"}),e[0]=r,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s}),e[3]=s,e[4]=a):a=e[4];let l;e[5]!==i?(l=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:i}),e[5]=i,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==l?(c=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a,l]}),e[7]=a,e[8]=l,e[9]=c):c=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground shrink-0",children:"Coming soon"}),e[10]=d):d=e[10];let u;return e[11]!==o||e[12]!==c?(u=n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-dashed border-border px-3 py-3 opacity-60",children:[o,c,d]}),e[11]=o,e[12]=c,e[13]=u):u=e[13],u}function Rb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center rounded-lg border border-dashed border-border px-3 py-3 text-xs text-muted-foreground",children:"More specialists coming soon"}),t[0]=e):e=t[0],e}function Qc(t){const e=t.trim();if(!e)return null;try{const s=new URL(e);return s.protocol!=="https:"&&s.protocol!=="http:"?null:s.origin+(s.pathname==="/"?"":s.pathname)}catch{return null}}async function Tb({selfClient:t,createConnection:e,registry:s}){const r=(await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:mn},limit:1,offset:0}})).structuredContent?.items?.find(u=>u.app_id===mn);if(r)return r.id;const o=s?.server?.remotes?.[0]?.url;if(!o)throw new Error("Site Diagnostics MCP is not available in the registry right now.");const a=s?.title??s?.server?.title??s?.server?.name??"Site Diagnostics",l=s?.server?.icons?.[0]?.src??null,c=s?.server?.description??null;return(await e({title:a,description:c,icon:l,connection_type:"HTTP",connection_url:o,app_name:s?.server?.name??"site-diagnostics",app_id:mn,metadata:{type:"site-diagnostics",source:"store",registry_item_id:mn,verified:!0}})).id}async function Db({template:t,selfClient:e,siteDiagnosticsConnectionId:s,projectAgentId:i,owner:r,repo:o,siteRootUrl:a}){const l=`${o}: ${t.title}`,d=(await e.callTool({name:"AUTOMATION_LIST",arguments:{virtual_mcp_id:i}})).structuredContent?.automations?.find(h=>h.name===l);let u;if(!(d&&d.trigger_count>0)){if(d)u=d.id;else{const h=await Mb({template:t,selfClient:e,siteDiagnosticsConnectionId:s}),f=wb({template:t,specialistAgentId:h,owner:r,repo:o,siteRootUrl:a}),m=Bh(f),p=await e.callTool({name:"AUTOMATION_CREATE",arguments:{name:l,virtual_mcp_id:i,agent:{id:i},messages:m,active:!0}});u=(p.structuredContent??p).id}await e.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:u,type:"cron",cron_expression:t.cron}})}}async function Mb({template:t,selfClient:e,siteDiagnosticsConnectionId:s}){const r=(await e.callTool({name:"COLLECTION_VIRTUAL_MCP_LIST",arguments:{where:{field:["metadata","specialistId"],operator:"eq",value:t.id},limit:1,offset:0}})).structuredContent?.items?.find(l=>l.metadata?.specialistId===t.id);if(r)return r.id;const o=await e.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:t.title,description:t.description,icon:t.icon,pinned:!1,metadata:{specialistId:t.id,instructions:t.instructions},connections:[{connection_id:s,selected_tools:t.siteDiagnosticsTools,selected_resources:null,selected_prompts:null}]}}});return(o.structuredContent??o).item.id}function Pb(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}function rn(t){const e=B.c(21),{agent:s,onSpecialClick:i,tracking:r}=t,{org:o}=ye(),a=qe();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==r.action||e[6]!==r.template_id||e[7]!==r.tile_kind?(l=()=>{if(ie("home_agent_tile_clicked",{template_id:r.template_id,agent_id:s.id,agent_title:s.title,tile_kind:r.tile_kind,action:r.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=r.action,e[6]=r.template_id,e[7]=r.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(go,{size:24}),e[10]=h):h=e[10];let f;e[11]!==s.icon||e[12]!==s.title?(f=n.jsx(Ps,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=f):f=e[13];let m;e[14]!==s.title?(m=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=m):m=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==f||e[19]!==m?(p=n.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[f,m]}),e[16]=c,e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20],p}function Lb(){const t=B.c(8),e=qe(),{org:s}=ye();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let r;t[1]!==e||t[2]!==s.slug?(r=()=>{ie("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=r):r=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:n.jsx(Il,{size:20,className:"text-foreground"})}),a=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==r?(l=n.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:r,children:[o,a]}),t[6]=r,t[7]=l):l=t[7],l}function Ob(){const t=B.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=ku(e);let r;t[1]!==s?(r=()=>{ie("home_create_agent_clicked"),s()},t[1]=s,t[2]=r):r=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:n.jsx(Qt,{size:20,className:"text-muted-foreground"})}),l=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==r?(c=n.jsxs("button",{type:"button",onClick:r,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=r,t[8]=c):c=t[8],c}function Bb(){const t=B.c(103),e=mo(),{locator:s}=ye(),[i,r]=S.useState(!1),[o,a]=S.useState(!1),[l,c]=S.useState(!1),[d,u]=S.useState(!1),[h,f]=S.useState(!1),[m]=yi(),p=Yn();let g;t[0]===Symbol.for("react.memo_cache_sentinel")?(g=zs.find(Hb),t[0]=g):g=t[0];const _=g;let v;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=zs.find(Ub),t[1]=v):v=t[1];const x=v;let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=zs.find(Fb),t[2]=b):b=t[2];const y=b;let C;t[3]===Symbol.for("react.memo_cache_sentinel")?(C=zs.find($b),t[3]=C):C=t[3];const k=C;let w,V,j,R,T,I,A,N,E,M,L,D;if(t[4]!==s||t[5]!==p||t[6]!==m.experimental_vibecode||t[7]!==e){const q=Pb(s),G=e.filter(zb).sort((be,je)=>{const $e=q.indexOf(be.id),Ge=q.indexOf(je.id);return $e!==-1&&Ge!==-1?$e-Ge:$e!==-1?-1:Ge!==-1?1:new Date(je.updated_at).getTime()-new Date(be.updated_at).getTime()}).slice(0,4);let ee;if(t[20]!==e){let be;t[22]===Symbol.for("react.memo_cache_sentinel")?(be=je=>je.id!==null&&(je.metadata?.type===x.id||je.title===x.title),t[22]=be):be=t[22],ee=e.find(be),t[20]=e,t[21]=ee}else ee=t[21];j=ee;let Z;if(t[23]!==e){let be;t[25]===Symbol.for("react.memo_cache_sentinel")?(be=je=>je.id!==null&&(je.metadata?.type===y.id||je.title===y.title),t[25]=be):be=t[25],Z=e.find(be),t[23]=e,t[24]=Z}else Z=t[24];w=Z;let J;if(t[26]!==e){let be;t[28]===Symbol.for("react.memo_cache_sentinel")?(be=je=>je.id!==null&&(je.metadata?.type===k.id||je.title===k.title),t[28]=be):be=t[28],J=e.find(be),t[26]=e,t[27]=J}else J=t[27];V=J,R=G.length>0,t[29]!==m.experimental_vibecode?(I=m.experimental_vibecode&&n.jsx("div",{className:"w-full flex justify-center mb-4",children:n.jsxs("button",{type:"button",onClick:()=>f(!0),className:"w-full max-w-[560px] flex items-center gap-3 rounded-xl border border-primary/30 bg-gradient-to-br from-primary/10 via-primary/5 to-transparent px-4 py-3 text-left transition-colors hover:border-primary/50 hover:from-primary/15 cursor-pointer group",children:[n.jsx("div",{className:"size-10 rounded-lg bg-primary/15 flex items-center justify-center shrink-0 transition-transform group-hover:scale-105",children:n.jsx(Fr,{className:"size-5 text-primary"})}),n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:"Set up self-healing repo"}),n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:"Connect GitHub and add specialist monitors that open issues automatically."})]})]})}),t[29]=m.experimental_vibecode,t[30]=I):I=t[30],T="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",A="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",t[31]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(rn,{agent:_,onSpecialClick:()=>r(!0),tracking:{template_id:_.id,tile_kind:"template",action:"open_modal"}},_.id),t[31]=N):N=t[31];const se=j??x;let ne;t[32]!==j||t[33]!==p?(ne=j?()=>p(j.id):()=>a(!0),t[32]=j,t[33]=p,t[34]=ne):ne=t[34];const ce=j?"existing":"template",xe=j?"navigate":"open_modal";let ae;t[35]!==ce||t[36]!==xe?(ae={template_id:x.id,tile_kind:ce,action:xe},t[35]=ce,t[36]=xe,t[37]=ae):ae=t[37],t[38]!==se||t[39]!==ne||t[40]!==ae?(E=n.jsx(rn,{agent:se,onSpecialClick:ne,tracking:ae},x.id),t[38]=se,t[39]=ne,t[40]=ae,t[41]=E):E=t[41];const he=w??y;let pe;t[42]!==w||t[43]!==p?(pe=w?()=>p(w.id):()=>c(!0),t[42]=w,t[43]=p,t[44]=pe):pe=t[44];const me=w?"existing":"template",we=w?"navigate":"open_modal";let ve;t[45]!==me||t[46]!==we?(ve={template_id:y.id,tile_kind:me,action:we},t[45]=me,t[46]=we,t[47]=ve):ve=t[47],t[48]!==he||t[49]!==pe||t[50]!==ve?(M=n.jsx(rn,{agent:he,onSpecialClick:pe,tracking:ve},y.id),t[48]=he,t[49]=pe,t[50]=ve,t[51]=M):M=t[51];const de=V??k;let Re;t[52]!==V||t[53]!==p?(Re=V?()=>p(V.id):()=>u(!0),t[52]=V,t[53]=p,t[54]=Re):Re=t[54];const te=V?"existing":"template",ue=V?"navigate":"open_modal";let Ve;t[55]!==te||t[56]!==ue?(Ve={template_id:k.id,tile_kind:te,action:ue},t[55]=te,t[56]=ue,t[57]=Ve):Ve=t[57],t[58]!==de||t[59]!==Re||t[60]!==Ve?(L=n.jsx(rn,{agent:de,onSpecialClick:Re,tracking:Ve},k.id),t[58]=de,t[59]=Re,t[60]=Ve,t[61]=L):L=t[61];let Ee;t[62]!==w?.id||t[63]!==V?.id||t[64]!==j?.id?(Ee=be=>be.id!==j?.id&&be.id!==w?.id&&be.id!==V?.id,t[62]=w?.id,t[63]=V?.id,t[64]=j?.id,t[65]=Ee):Ee=t[65];let Te;t[66]!==p?(Te=be=>n.jsx(rn,{agent:be,onSpecialClick:()=>p(be.id),tracking:{template_id:null,tile_kind:"recent",action:"navigate"}},be.id??"default"),t[66]=p,t[67]=Te):Te=t[67],D=G.filter(Ee).map(Te),t[4]=s,t[5]=p,t[6]=m.experimental_vibecode,t[7]=e,t[8]=w,t[9]=V,t[10]=j,t[11]=R,t[12]=T,t[13]=I,t[14]=A,t[15]=N,t[16]=E,t[17]=M,t[18]=L,t[19]=D}else w=t[8],V=t[9],j=t[10],R=t[11],T=t[12],I=t[13],A=t[14],N=t[15],E=t[16],M=t[17],L=t[18],D=t[19];let P;t[68]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(Ob,{}),t[68]=P):P=t[68];let O;t[69]!==R?(O=R&&n.jsx(Lb,{}),t[69]=R,t[70]=O):O=t[70];let $;t[71]!==O||t[72]!==A||t[73]!==N||t[74]!==E||t[75]!==M||t[76]!==L||t[77]!==D?($=n.jsxs("div",{className:A,children:[N,E,M,L,D,P,O]}),t[71]=O,t[72]=A,t[73]=N,t[74]=E,t[75]=M,t[76]=L,t[77]=D,t[78]=$):$=t[78];let z;t[79]!==T||t[80]!==$?(z=n.jsx("div",{className:T,children:$}),t[79]=T,t[80]=$,t[81]=z):z=t[81];let W;t[82]!==i?(W=n.jsx(Ur,{open:i,onOpenChange:r}),t[82]=i,t[83]=W):W=t[83];let F;t[84]!==o||t[85]!==j?(F=n.jsx(Vu,{open:o,onOpenChange:a,existingAgent:j}),t[84]=o,t[85]=j,t[86]=F):F=t[86];let K;t[87]!==l||t[88]!==w?(K=n.jsx(mb,{open:l,onOpenChange:c,existingAgent:w}),t[87]=l,t[88]=w,t[89]=K):K=t[89];let H;t[90]!==d||t[91]!==V?(H=n.jsx(xb,{open:d,onOpenChange:u,existingAgent:V}),t[90]=d,t[91]=V,t[92]=H):H=t[92];let U;t[93]!==h?(U=n.jsx(rf,{open:h,onOpenChange:f}),t[93]=h,t[94]=U):U=t[94];let Y;return t[95]!==I||t[96]!==z||t[97]!==W||t[98]!==F||t[99]!==K||t[100]!==H||t[101]!==U?(Y=n.jsxs(n.Fragment,{children:[I,z,W,F,K,H,U]}),t[95]=I,t[96]=z,t[97]=W,t[98]=F,t[99]=K,t[100]=H,t[101]=U,t[102]=Y):Y=t[102],Y}function zb(t){return t.id!==null&&!Br(t.id)}function $b(t){return t.id==="ai-research"}function Fb(t){return t.id==="ai-image"}function Ub(t){return t.id==="site-diagnostics"}function Hb(t){return t.id==="site-editor"}function Wb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:n.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(Kb)})}),t[0]=e):e=t[0],e}function Kb(t,e){return n.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[n.jsx($i,{className:"size-12 rounded-xl shrink-0"}),n.jsx($i,{className:"h-3 sm:h-4 w-full"})]},e)}function Zc(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(S.Suspense,{fallback:n.jsx(Wb,{}),children:n.jsx(Bb,{})}),t[0]=e):e=t[0],e}function on(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function ed(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 qb(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Gb(t){const e=B.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Yb),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.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 Yb(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Xb(t){const e=B.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?r/o*100:0;let d;e[0]!==a?(d=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let f;e[6]!==d||e[7]!==u||e[8]!==h?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[_,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==c||e[21]!==r?(b=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=r,e[22]=b):b=e[22];let y;e[23]!==x||e[24]!==b||e[25]!==g?(y=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,b]}),e[23]=x,e[24]=b,e[25]=g,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==f?(C=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=C):C=e[29],C}function Jb(t){const e=B.c(19),{part:s}=t,i=s.input?.agent_id,r=is(i),o=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=n.jsx(Ps,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let f;e[3]!==h?(f=X("shrink-0 font-medium",h),e[3]=h,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==f?(m=n.jsx("span",{className:f,children:o}),e[5]=o,e[6]=f,e[7]=m):m=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=n.jsx("span",{className:"ml-auto shrink-0",children:l?n.jsx(De,{size:12,className:"animate-spin text-muted-foreground"}):c?n.jsx(Yg,{size:12,className:"text-destructive"}):d?n.jsx(oi,{size:12,className:"text-warning"}):n.jsx(N_,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==m||e[16]!==p||e[17]!==g?(_=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,m,p,g]}),e[14]=u,e[15]=m,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function Qb(t){const e=B.c(58),{onClose:s,back:i,className:r}=t,[o,a]=S.useState(null),{messages:l}=Gi(),{tasks:c,taskId:d}=es(),{selectedModel:u,selectedVirtualMcp:h}=ai();let f,m,p,g,_,v,x,b;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){b=Symbol.for("react.early_return_sentinel");e:{let k;e[17]!==d?(k=J=>J.id===d,e[17]=d,e[18]=k):k=e[18];const w=c.find(k),V=zh(l),j=[...l].reverse().find(a0),R=j?.metadata?.usage,T=j?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,I=R?.contextTokens??R?.totalTokens??0,A=T&&T>0?(I/T*100).toFixed(1):null,N=l;let E;e[19]!==N?(E=N.filter(o0).reduce(r0,0),e[19]=N,e[20]=E):E=e[20];const M=E,L=l;let D;e[21]!==L?(D=L.filter(n0).reduce(i0,0),e[21]=L,e[22]=D):D=e[22];const P=D,O=Math.max(0,V.totalTokens-M-P),$=l[0],z=l.at(-1),W=$?.metadata?.created_at??w?.created_at,F=z?.metadata?.created_at??w?.updated_at,K=l.filter(s0),H=l.flatMap(e0),U=u?.modelId?qb(u.modelId):"—",Y=h?.title??"Decopilot",q=[{label:"Session",value:w?.title??"New chat"},{label:"Messages",value:K.length},{label:"Agent",value:Y},{label:"Model",value:U},{label:"Context Limit",value:T?on(T):"—"},{label:"Session Tokens (billed)",value:V.totalTokens>0?on(V.totalTokens):"0"},{label:"Usage",value:A!==null?`${A}%`:"—"},{label:"Input Tokens",value:V.inputTokens>0?on(V.inputTokens):"0"},{label:"Output Tokens",value:V.outputTokens>0?on(V.outputTokens):"0"},{label:"Reasoning Tokens",value:V.reasoningTokens>0?on(V.reasoningTokens):"0"},{label:"Cost",value:V.cost>0?`$${V.cost<.001?V.cost.toFixed(6):V.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:ed(W)},{label:"Last Activity",value:ed(F)}];if(!w&&K.length===0){let J;e[23]!==r?(J=X("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=J):J=e[24];let se;e[25]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=se):se=e[25];let ne;e[26]!==i?(ne=i?n.jsx(pa,{size:14,className:"text-muted-foreground"}):n.jsx(ri,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ne):ne=e[27];let ce;e[28]!==s||e[29]!==ne?(ce=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[se,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ne})]}),e[28]=s,e[29]=ne,e[30]=ce):ce=e[30];let xe;e[31]===Symbol.for("react.memo_cache_sentinel")?(xe=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=xe):xe=e[31];let ae;e[32]!==J||e[33]!==ce?(ae=n.jsxs("div",{className:J,children:[ce,xe]}),e[32]=J,e[33]=ce,e[34]=ae):ae=e[34],b=ae;break e}e[35]!==r?(v=X("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 G;e[37]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=G):G=e[37];let ee;e[38]!==i?(ee=i?n.jsx(pa,{size:14}):n.jsx(ri,{size:14}),e[38]=i,e[39]=ee):ee=e[39],e[40]!==s||e[41]!==ee?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[G,n.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:ee})]}),e[40]=s,e[41]=ee,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",m=H.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:H.map(Zb)})]}),p=n.jsx(Gb,{items:q});let Z;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=Z):Z=e[43],e[44]!==P||e[45]!==O||e[46]!==M?(g=n.jsxs("div",{className:"flex flex-col gap-3",children:[Z,n.jsx(Xb,{userTokens:M,assistantTokens:P,otherTokens:O})]}),e[44]=P,e[45]=O,e[46]=M,e[47]=g):g=e[47],_=K.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:K.map(J=>{const se=J.metadata?.created_at,ne=o?.id===J.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(ne?null:J),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:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:X("shrink-0 font-medium",J.role==="user"?"text-chart-1":"text-chart-2"),children:J.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:J.id})]}),se&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(se).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ne&&n.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(J,null,2)})]},J.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=v,e[15]=x,e[16]=b}else f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],v=e[14],x=e[15],b=e[16];if(b!==Symbol.for("react.early_return_sentinel"))return b;let y;e[48]!==f||e[49]!==m||e[50]!==p||e[51]!==g||e[52]!==_?(y=n.jsxs("div",{className:f,children:[m,p,g,_]}),e[48]=f,e[49]=m,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let C;return e[54]!==v||e[55]!==x||e[56]!==y?(C=n.jsxs("div",{className:v,children:[x,y]}),e[54]=v,e[55]=x,e[56]=y,e[57]=C):C=e[57],C}function Zb(t,e){return n.jsx(Jb,{part:t},e)}function e0(t){return(t.parts??[]).filter(t0)}function t0(t){return t.type==="tool-subtask"}function s0(t){return t.role!=="system"}function i0(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function n0(t){return t.role==="assistant"}function r0(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function o0(t){return t.role==="user"}function a0(t){return t.role==="assistant"&&t.metadata?.usage}const td=["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"],sd=["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 l0(){const t=td[Math.floor(Math.random()*td.length)],e=sd[Math.floor(Math.random()*sd.length)];return`deco/${t}-${e}`}function c0(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 d0(t){const e=B.c(25),{orgId:s,userId:i,connectionId:r,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=r??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const f=Le(h);let m;e[3]!==a||e[4]!==l?(m={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=m):m=e[5];const p=d&&!!r&&!!a&&!!l;let g;e[6]!==f||e[7]!==m||e[8]!==p?(g={client:f,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:m0},e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:v,isError:x}=ki(g);let b,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),b=[...y].sort().map(f0),e[10]=i,e[11]=o,e[12]=b,e[13]=y):(b=e[12],y=e[13]);const C=b;let k;if(e[14]!==_||e[15]!==y){const R=Array.isArray(_)?_:_?.branches??[];let T;e[17]!==y?(T=I=>!y.has(I.name),e[17]=y,e[18]=T):T=e[18],k=R.filter(u0).filter(T).map(h0),e[14]=_,e[15]=y,e[16]=k}else k=e[16];const w=k,V=Array.isArray(_)?null:_?.default_branch??null;let j;return e[19]!==V||e[20]!==x||e[21]!==v||e[22]!==w||e[23]!==C?(j={yours:C,others:w,defaultBase:V,isLoading:v,isError:x},e[19]=V,e[20]=x,e[21]=v,e[22]=w,e[23]=C,e[24]=j):j=e[24],j}function h0(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function u0(t){return typeof t.name=="string"}function f0(t){return{name:t,source:"yours"}}function m0(t){return c0(t)}function p0(t){const e=B.c(41),{orgId:s,userId:i,connectionId:r,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=S.useState(!1);let f;e[0]!==r||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(f={orgId:s,userId:i,connectionId:r,vmMap:l,owner:o,repo:a,enabled:u},e[0]=r,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=f):f=e[7];const{yours:m,others:p,isLoading:g,isError:_}=d0(f);let v;e[8]!==d?(v=E=>{d(E),h(!1)},e[8]=d,e[9]=v):v=e[9];const x=v,b=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(yn,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let C;e[11]!==b?(C=n.jsx(li,{asChild:!0,children:n.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,n.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[11]=b,e[12]=C):C=e[12];let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(v_,{placeholder:"Search branches…"}),e[13]=k):k=e[13];let w;e[14]!==x?(w=n.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:[k,n.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>x(l0()),children:"New"})]}),e[14]=x,e[15]=w):w=e[15];let V;e[16]!==_?(V=_&&n.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[16]=_,e[17]=V):V=e[17];let j;e[18]!==_||e[19]!==g||e[20]!==p.length||e[21]!==m.length?(j=!_&&!g&&m.length===0&&p.length===0&&n.jsx(__,{children:"No branches found."}),e[18]=_,e[19]=g,e[20]=p.length,e[21]=m.length,e[22]=j):j=e[22];let R;e[23]!==x||e[24]!==m?(R=m.length>0&&n.jsx(Nc,{heading:"Your branches",children:m.map(E=>n.jsxs(Ac,{value:E.name,onSelect:()=>x(E.name),children:[n.jsx(yn,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:E.name})]},E.name))}),e[23]=x,e[24]=m,e[25]=R):R=e[25];let T;e[26]!==p||e[27]!==x?(T=p.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(x_,{}),n.jsx(Nc,{heading:"Other branches in repo",children:p.map(E=>n.jsxs(Ac,{value:E.name,onSelect:()=>x(E.name),children:[n.jsx(yn,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:E.name}),E.author&&n.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",E.author]})]},E.name))})]}),e[26]=p,e[27]=x,e[28]=T):T=e[28];let I;e[29]!==T||e[30]!==V||e[31]!==j||e[32]!==R?(I=n.jsxs(b_,{children:[V,j,R,T]}),e[29]=T,e[30]=V,e[31]=j,e[32]=R,e[33]=I):I=e[33];let A;e[34]!==I||e[35]!==w?(A=n.jsx(ci,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(y_,{children:[w,I]})}),e[34]=I,e[35]=w,e[36]=A):A=e[36];let N;return e[37]!==u||e[38]!==A||e[39]!==C?(N=n.jsxs(di,{open:u,onOpenChange:h,children:[C,A]}),e[37]=u,e[38]=A,e[39]=C,e[40]=N):N=e[40],N}const g0=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),_0="/decotexture.svg";function id(t){const e=B.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:g0},e[0]=i):i=e[0];let r,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:n.jsx(Ps,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=n.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("img",{src:_0,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:n.jsx(uo,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=n.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[r,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function x0(){const t=B.c(5),{data:e}=St.useSession();let s;t[0]!==e?.user?.email?(s=ct.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let r;t[2]!==s||t[3]!==i?(r={queryKey:s,queryFn:v0,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=r):r=t[4];const{data:o}=Wi(r);return o?.isDecoUser??!1}async function v0(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function b0(t){const e=B.c(56),{onOpenContextPanel:s}=t,{data:i}=St.useSession(),[r,o]=S.useState(!1),a=x0(),l=Ms(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:f}=_o();let m;e[0]!==i?.user?.name?(m=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=m):m=e[1];const p=m,g=c&&u&&h!=null,_=c&&d&&f;if(l){let A;e[2]!==h||e[3]!==g?(A=g&&n.jsx("div",{className:"mb-4",children:n.jsx(Oe.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=A):A=e[4];let N;e[5]!==_?(N=_&&n.jsx("div",{className:"mb-4",children:n.jsx(Oe.NoCreditsEyebrow,{})}),e[5]=_,e[6]=N):N=e[6];let E;e[7]!==p?(E=n.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=E):E=e[8];let M;e[9]!==A||e[10]!==N||e[11]!==E?(M=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[A,N,E]}),e[9]=A,e[10]=N,e[11]=E,e[12]=M):M=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Zc,{}),e[13]=L):L=e[13];let D;e[14]!==s?(D=n.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,n.jsx(Oe.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=D):D=e[15];let P;e[16]!==a?(P=a&&n.jsx("div",{className:"w-full",children:n.jsx(id,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let O;e[18]!==M||e[19]!==D||e[20]!==P?(O=n.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[M,D,P]}),e[18]=M,e[19]=D,e[20]=P,e[21]=O):O=e[21];let $;e[22]!==r?($=n.jsx(Ur,{open:r,onOpenChange:o}),e[22]=r,e[23]=$):$=e[23];let z;return e[24]!==$||e[25]!==O?(z=n.jsxs(n.Fragment,{children:[O,$]}),e[24]=$,e[25]=O,e[26]=z):z=e[26],z}let v;e[27]!==h||e[28]!==g?(v=g&&n.jsx("div",{className:"mb-4",children:n.jsx(Oe.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=v):v=e[29];let x;e[30]!==_?(x=_&&n.jsx("div",{className:"mb-4",children:n.jsx(Oe.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let b;e[32]!==p?(b=n.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=b):b=e[33];let y;e[34]!==v||e[35]!==x||e[36]!==b?(y=n.jsxs("div",{className:"text-center mb-10",children:[v,x,b]}),e[34]=v,e[35]=x,e[36]=b,e[37]=y):y=e[37];let C;e[38]!==s?(C=n.jsx("div",{className:"w-full",children:n.jsx(Oe.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=C):C=e[39];let k;e[40]!==y||e[41]!==C?(k=n.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,C]}),e[40]=y,e[41]=C,e[42]=k):k=e[42];let w;e[43]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("div",{className:"w-full mt-10 mx-auto",children:n.jsx(Zc,{})}),e[43]=w):w=e[43];let V;e[44]!==k?(V=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[k,w]}),e[44]=k,e[45]=V):V=e[45];let j;e[46]!==a?(j=a&&n.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:n.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:n.jsx(id,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=j):j=e[47];let R;e[48]!==j||e[49]!==V?(R=n.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[V,j]}),e[48]=j,e[49]=V,e[50]=R):R=e[50];let T;e[51]!==r?(T=n.jsx(Ur,{open:r,onOpenChange:o}),e[51]=r,e[52]=T):T=e[52];let I;return e[53]!==R||e[54]!==T?(I=n.jsxs(n.Fragment,{children:[R,T]}),e[53]=R,e[54]=T,e[55]=I):I=e[55],I}function y0(){const t=B.c(26),{org:e}=ye(),{selectedVirtualMcp:s}=ai(),{data:i}=St.useSession(),{currentBranch:r,setCurrentTaskBranch:o}=es();let a;t[0]!==e.id?(a=ho(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=is(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,f=!!h?.connectionId&&!!u;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(go,{size:32}),t[2]=m):m=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=n.jsx(Ps,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==_?(v=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=v):v=t[9];let x;t[10]!==r||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==f||t[16]!==u?(x=f&&n.jsx("div",{className:"mt-2",children:n.jsx(p0,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:r??void 0,onChange:o})}),t[10]=r,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=f,t[16]=u,t[17]=x):x=t[17];let b;t[18]!==p||t[19]!==g||t[20]!==v||t[21]!==x?(b=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,v,x]}),t[18]=p,t[19]=g,t[20]=v,t[21]=x,t[22]=b):b=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"w-full max-w-3xl mx-auto",children:n.jsx(Oe.IceBreakers,{})}),t[23]=y):y=t[23];let C;return t[24]!==b?(C=n.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,y]}),t[24]=b,t[25]=C):C=t[25],C}function S0(t){const e=B.c(27),{variant:s}=t,{org:i}=ye(),r=Nl(),{isChatEmpty:o}=Gi(),[a,l]=S.useState("chat"),c=_o();if(r.length===0){let C;return e[0]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Oe,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Oe.Main,{className:"flex flex-col items-center",children:n.jsx(Oe.EmptyState,{children:n.jsx(Oe.NoAiProviderEmptyState,{})})})}),e[0]=C):C=e[0],C}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!Xv(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&n.jsx(Oe.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const f=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;e[10]!==f?(m=X("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),e[10]=f,e[11]=m):m=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?n.jsx(b0,{onOpenContextPanel:()=>l("context")}):n.jsxs(n.Fragment,{children:[n.jsx(Oe.Main,{children:n.jsx(y0,{})}),n.jsx(Oe.Footer,{children:n.jsx(Oe.Input,{onOpenContextPanel:()=>l("context")})})]}):n.jsxs(n.Fragment,{children:[n.jsx(Oe.Main,{children:n.jsx(Oe.Messages,{})}),n.jsx(Oe.Footer,{children:n.jsx(Oe.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==m||e[16]!==p?(g=n.jsx("div",{className:m,children:p}),e[15]=m,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let v;e[18]!==_?(v=X("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=v):v=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Qb,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let b;e[21]!==v?(b=n.jsx("div",{className:v,children:x}),e[21]=v,e[22]=b):b=e[22];let y;return e[23]!==b||e[24]!==h||e[25]!==g?(y=n.jsxs(Oe,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,b]}),e[23]=b,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function of(t){const e=B.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Oe.Skeleton,{}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Oe.Skeleton,{}),e[1]=r):r=e[1];let o;return e[2]!==s?(o=n.jsx(Ns,{fallback:i,children:n.jsx(S.Suspense,{fallback:r,children:n.jsx(S0,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function w0(){const t=B.c(6),{org:e,locator:s}=ye(),i=Mt();let r;t[0]!==s||t[1]!==i?(r=()=>{i.invalidateQueries({queryKey:ct.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=r):r=t[2];let o;t[3]!==e.id||t[4]!==r?(o={orgId:e.id,onTaskStatus:r},t[3]=e.id,t[4]=r,t[5]=o):o=t[5],E_(o)}function V0(t){const e=B.c(8),{virtualMcpId:s,size:i,showAutomationBadge:r}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?n.jsx(C0,{virtualMcpId:s,size:o}):n.jsx(gs,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==r?(l=r&&n.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:n.jsx(Ui,{size:10,className:"text-white"})}),e[3]=r,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=n.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function C0(t){const e=B.c(6),{virtualMcpId:s,size:i}=t,r=is(s);if(!r){let l;return e[0]!==i?(l=n.jsx(gs,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=r.icon??null;let a;return e[2]!==r.title||e[3]!==i||e[4]!==o?(a=n.jsx(gs,{icon:o,name:r.title,size:i}),e[2]=r.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Fs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function k0(t){const e=B.c(42),{task:s,isActive:i,onClick:r,onArchive:o,showAutomationBadge:a}=t,l=Qp(s.status),c=l.icon,d=is(s.virtual_mcp_id);let u;e[0]!==d?(u=Fs(d),e[0]=d,e[1]=u):u=e[1];const h=u,f="button",m=0;let p;e[2]!==r?(p=O=>{O.target===O.currentTarget&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),r())},e[2]=r,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=X("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let v;e[6]!==a||e[7]!==s.virtual_mcp_id?(v=n.jsx(V0,{virtualMcpId:s.virtual_mcp_id,size:"xs",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=v):v=e[8];const x=s.title||"Untitled task";let b;e[9]!==x?(b=n.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=b):b=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&n.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"truncate font-mono",children:s.branch}),n.jsx("span",{className:"shrink-0",children:"·"})]}):h?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),n.jsx("span",{className:"shrink-0",children:"·"})]}):null,n.jsx("span",{className:"shrink-0",children:Zp(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let C;e[15]!==y||e[16]!==b?(C=n.jsxs("div",{className:"flex-1 min-w-0",children:[b,y]}),e[15]=y,e[16]=b,e[17]=C):C=e[17];const k="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",w="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",V=l.label,j=14,R=X(l.iconClassName,s.status==="in_progress"&&"animate-spin");let T;e[18]!==c||e[19]!==R?(T=n.jsx(c,{size:j,className:R}),e[18]=c,e[19]=R,e[20]=T):T=e[20];let I;e[21]!==l||e[22]!==T?(I=n.jsx("span",{className:w,"aria-label":V,children:T}),e[21]=l,e[22]=T,e[23]=I):I=e[23];let A;e[24]!==o?(A=O=>{O.stopPropagation(),o()},e[24]=o,e[25]=A):A=e[25];let N;e[26]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(jg,{size:14}),e[26]=N):N=e[26];let E;e[27]!==A?(E=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Archive task",onClick:A,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:N})}),e[27]=A,e[28]=E):E=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(it,{side:"right",children:"Archive"}),e[29]=M):M=e[29];let L;e[30]!==E?(L=n.jsxs(nt,{children:[E,M]}),e[30]=E,e[31]=L):L=e[31];let D;e[32]!==I||e[33]!==L?(D=n.jsxs("div",{className:k,children:[I,L]}),e[32]=I,e[33]=L,e[34]=D):D=e[34];let P;return e[35]!==r||e[36]!==C||e[37]!==D||e[38]!==p||e[39]!==_||e[40]!==v?(P=n.jsxs("div",{role:f,tabIndex:m,onClick:r,onKeyDown:p,className:_,children:[v,C,D]}),e[35]=r,e[36]=C,e[37]=D,e[38]=p,e[39]=_,e[40]=v,e[41]=P):P=e[41],P}const af={all:"All tasks",manual:"Chats",automation:"Automation"},lf={all:"All members",mine:"Mine only"};function j0(t){const e=B.c(57),{title:s,tasks:i,activeTaskId:r,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[f,m]=S.useState("all"),[p,g]=S.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(K=>K.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const v=_;let x;e[4]!==f||e[5]!==v?(x=f==="automation"?v.filter(I0):f==="manual"?v.filter(E0):v,e[4]=f,e[5]=v,e[6]=x):x=e[6];const b=x;let y;e[7]!==s?(y=n.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let C;e[9]!==p?(C=n.jsx(Es,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?n.jsx(Ng,{size:16}):n.jsx(go,{size:16})})}),e[9]=p,e[10]=C):C=e[10];let k;e[11]!==p?(k=K=>{const H=K;H!==p&&ie("tasks_panel_member_filter_changed",{to_value:H}),g(H)},e[11]=p,e[12]=k):k=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=Object.keys(lf),e[13]=w):w=e[13];let V;e[14]===Symbol.for("react.memo_cache_sentinel")?(V=w.map(A0),e[14]=V):V=e[14];let j;e[15]!==p||e[16]!==k?(j=n.jsx(Is,{align:"end",children:n.jsx(xc,{value:p,onValueChange:k,children:V})}),e[15]=p,e[16]=k,e[17]=j):j=e[17];let R;e[18]!==C||e[19]!==j?(R=n.jsxs(As,{children:[C,j]}),e[18]=C,e[19]=j,e[20]=R):R=e[20];const T=f!=="all"&&"text-purple-500";let I;e[21]!==T?(I=X("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",T),e[21]=T,e[22]=I):I=e[22];let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(Xg,{size:16}),e[23]=A):A=e[23];let N;e[24]!==I?(N=n.jsx(Es,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Filter tasks",className:I,children:A})}),e[24]=I,e[25]=N):N=e[25];let E;e[26]!==f?(E=K=>{const H=K;H!==f&&ie("tasks_panel_filter_changed",{to_value:H}),m(H)},e[26]=f,e[27]=E):E=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(af),e[28]=M):M=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=M.map(N0),e[29]=L):L=e[29];let D;e[30]!==f||e[31]!==E?(D=n.jsx(Is,{align:"end",children:n.jsx(xc,{value:f,onValueChange:E,children:L})}),e[30]=f,e[31]=E,e[32]=D):D=e[32];let P;e[33]!==N||e[34]!==D?(P=n.jsxs(As,{children:[N,D]}),e[33]=N,e[34]=D,e[35]=P):P=e[35];let O;e[36]!==l||e[37]!==c||e[38]!==s?(O=c&&l&&n.jsx("button",{type:"button",onClick:()=>{ie("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:n.jsx(wl,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=O):O=e[39];let $;e[40]!==P||e[41]!==O||e[42]!==R?($=n.jsxs("div",{className:"flex items-center gap-0.5",children:[R,P,O]}),e[40]=P,e[41]=O,e[42]=R,e[43]=$):$=e[43];let z;e[44]!==$||e[45]!==y?(z=n.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,$]}),e[44]=$,e[45]=y,e[46]=z):z=e[46];let W;e[47]!==r||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==b?(W=b.length===0&&u?n.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):b.map(K=>n.jsx(k0,{task:K,isActive:r===K.id,onClick:()=>{r!==K.id&&ie("tasks_panel_task_clicked",{thread_id:K.id,virtual_mcp_id:K.virtual_mcp_id??null,from_automation:!!K.fromAutomation}),o(K)},onArchive:()=>{ie("tasks_panel_task_archived",{thread_id:K.id,virtual_mcp_id:K.virtual_mcp_id??null}),a(K)},showAutomationBadge:d||K.fromAutomation},K.id)),e[47]=r,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=b,e[53]=W):W=e[53];let F;return e[54]!==z||e[55]!==W?(F=n.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[z,W]}),e[54]=z,e[55]=W,e[56]=F):F=e[56],F}function N0(t){return n.jsx(Yh,{value:t,children:af[t]},t)}function A0(t){return n.jsx(Yh,{value:t,children:lf[t]},t)}function E0(t){return!t.fromAutomation}function I0(t){return t.fromAutomation}function R0(){const t=B.c(22);w0();const{data:e}=St.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:r}=ha(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=ha(o),{setTaskId:l,createNewTask:c}=Wn();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=Hn(d),{locator:h,org:f}=ye(),m=Mt();let p;t[3]!==f.id?(p={connectionId:Pt,orgId:f.id},t[3]=f.id,t[4]=p):p=t[4];const g=Le(p),_=u.taskId??null;let v;t[5]!==a||t[6]!==r?(v=[...r,...a.map(D0)].sort(T0),t[5]=a,t[6]=r,t[7]=v):v=t[7];const x=v;let b;t[8]!==g||t[9]!==h||t[10]!==m?(b=async w=>{try{await Fp(g,w.id,{hidden:!0}),m.invalidateQueries({queryKey:ct.tasksPrefix(h)})}catch(V){const R=V;fe.error(`Failed to archive task: ${R.message}`)}},t[8]=g,t[9]=h,t[10]=m,t[11]=b):b=t[11];const y=b;if(x.length===0){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("div",{className:"h-full flex items-center justify-center p-4",children:n.jsx(Fi,{image:n.jsx(Ag,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=w):w=t[12],w}let C;t[13]!==l?(C=w=>l(w.id,w.virtual_mcp_id),t[13]=l,t[14]=C):C=t[14];let k;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==C?(k=n.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:n.jsx(j0,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:C,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=C,t[21]=k):k=t[21],k}function T0(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function D0(t){return{...t,fromAutomation:!0}}function M0(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(P0)}),t[0]=e):e=t[0],e}function P0(t,e){return n.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function cf(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Oe.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Ns,{fallback:e,children:n.jsx(S.Suspense,{fallback:n.jsx(M0,{}),children:n.jsx(R0,{})})}),t[1]=s):s=t[1],s}function df(){const t=B.c(77),{org:e}=ye(),s=qe(),i=Th(),{setTasksOpen:r,openTab:o}=Wn(),a=e.slug,l=ye().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=Hn(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=Si(u),f=i.location.pathname;let m;t[2]!==l.enabledPlugins?(m=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=m):m=t[3];const p=m;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let v,x,b,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let H;t[17]!==p?(H=se=>p.includes(se.pluginId),t[17]=p,t[18]=H):H=t[18];const U=up.filter(H),Y=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const q=d.taskId??"",G=d.pluginId;let ee;t[19]!==G?(ee=se=>G===se,t[19]=G,t[20]=ee):ee=t[20],v=ee;let Z;t[21]!==q||t[22]!==s||t[23]!==a||t[24]!==Y?(Z=se=>{const ne=q||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:ne,pluginId:se},search:ce=>({...ce,virtualmcpid:Y})})},t[21]=q,t[22]=s,t[23]=a,t[24]=Y,t[25]=Z):Z=t[25],b=Z;let J;t[26]!==v||t[27]!==b?(J=se=>({key:se.pluginId,label:se.label,icon:se.icon,isActive:v(se.pluginId),onClick:()=>b(se.pluginId)}),t[26]=v,t[27]=b,t[28]=J):J=t[28],y=U.map(J),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=v,t[14]=x,t[15]=b,t[16]=y}else v=t[13],x=t[14],b=t[15],y=t[16];const C=y;let k;if(t[29]!==p||t[30]!==v||t[31]!==b){let H;t[33]!==p?(H=q=>p.includes(q.pluginId),t[33]=p,t[34]=H):H=t[34];const U=fp.filter(H);let Y;t[35]!==v||t[36]!==b?(Y=q=>({type:"group",group:{id:`${q.pluginId}-${q.id}`,label:q.label,items:q.items.map((G,ee)=>({key:`${q.pluginId}-${q.id}-${ee}`,label:G.label,icon:G.icon,isActive:v(q.pluginId),onClick:()=>b(q.pluginId)})),defaultExpanded:q.defaultExpanded??!0}}),t[35]=v,t[36]=b,t[37]=Y):Y=t[37],k=U.map(Y),t[29]=p,t[30]=v,t[31]=b,t[32]=k}else k=t[32];const w=k;let V;if(t[38]!==o||t[39]!==_){let H;t[41]!==o?(H=U=>{const Y=Kn(U.icon),q=Y.type==="icon"?qn(Y.name):null;return{key:`app-${U.connectionId}-${U.toolName}`,label:U.label||U.toolName,icon:q?n.jsx(q,{size:16,className:"text-muted-foreground"}):Y.type==="url"?n.jsx("img",{src:Y.url,alt:"",className:"size-4 rounded"}):n.jsx(ju,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(ua(U.connectionId,U.toolName))}},t[41]=o,t[42]=H):H=t[42],V=_.map(H),t[38]=o,t[39]=_,t[40]=V}else V=t[40];const j=V;let R;t[43]!==j?(R=j.length>0?{type:"group",group:{id:"apps",label:"Apps",items:j,defaultExpanded:!0}}:null,t[43]=j,t[44]=R):R=t[44];const T=R;let I;t[45]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(Eg,{className:"size-4!"}),t[45]=I):I=t[45];const A=f===`/${a}`||f===`/${a}/`;let N;t[46]!==s||t[47]!==a||t[48]!==r?(N=()=>{r(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=r,t[49]=N):N=t[49];let E;t[50]!==N||t[51]!==A?(E={key:"home",label:"Home",icon:I,isActive:A,onClick:N},t[50]=N,t[51]=A,t[52]=E):E=t[52];const M=E;let L;t[53]!==p?(L=p.includes(mp),t[53]=p,t[54]=L):L=t[54];const D=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(pp,{className:"size-4!"}),t[55]=P):P=t[55];let O;t[56]!==a||t[57]!==f?(O=f.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=f,t[58]=O):O=t[58];let $;t[59]!==s||t[60]!==a?($=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=$):$=t[61];let z;t[62]!==O||t[63]!==$?(z={key:"workflows",label:"Workflows",icon:P,isActive:O,onClick:$},t[62]=O,t[63]=$,t[64]=z):z=t[64];const W=z;let F;if(t[65]!==M||t[66]!==x||t[67]!==D||t[68]!==W){const H=[M];x&&D&&H.push(W),F={type:"items",items:H},t[65]=M,t[66]=x,t[67]=D,t[68]=W,t[69]=F}else F=t[69];let K;if(t[70]!==T||t[71]!==w||t[72]!==C||t[73]!==F){if(K=[F],C.length>0){let H;t[75]!==C?(H={type:"items",items:C},t[75]=C,t[76]=H):H=t[76],K.push(H)}w.length>0&&K.push(...w),T&&K.push(T),t[70]=T,t[71]=w,t[72]=C,t[73]=F,t[74]=K}else K=t[74];return K}function hf(t){const e=B.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex h-6 items-center",children:n.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsxs(Xn,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,n.jsx(Jn,{children:n.jsx(vs,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=r):r=e[2],r}function L0(){const t=B.c(7),s=Dh().logo??Mh,i=typeof s=="string"?s:s.light,r=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=n.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==r?(a=n.jsx("img",{src:r,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=r,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=n.jsx(Eu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:n.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function uf(t){const e=B.c(15),{item:s}=t,{isMobile:i,setOpenMobile:r}=Qn();let o;e[0]!==i||e[1]!==s||e[2]!==r?(o=()=>{ie("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&r(!1)},e[0]=i,e[1]=s,e[2]=r,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=X(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=n.jsx(_s,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=n.jsx(Zt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function O0(t){const e=B.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Nu,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,r=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(z0),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=n.jsx(hf,{label:i,defaultExpanded:r,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map(B0),e[8]=s.items,e[9]=i):i=e[9];let r;return e[10]!==i?(r=n.jsx(Xn,{className:"pt-0 pr-0 pb-0 pl-0",children:n.jsx(Jn,{children:n.jsx(vs,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=r):r=e[11],r}}}function B0(t){return n.jsx(uf,{item:t},t.key)}function z0(t){return n.jsx(uf,{item:t},t.key)}function $0(t){const e=B.c(14),{sections:s,header:i,footer:r,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"h-10 shrink-0"}),children:n.jsx(L0,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=X("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(F0),e[3]=s,e[4]=h):h=e[4];let f;e[5]!==o||e[6]!==u||e[7]!==h?(f=n.jsxs(Au,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=f):f=e[8];let m;return e[9]!==r||e[10]!==i||e[11]!==f||e[12]!==c?(m=n.jsxs(I_,{variant:c,children:[d,i,f,r]}),e[9]=r,e[10]=i,e[11]=f,e[12]=c,e[13]=m):m=e[13],m}function F0(t,e){return n.jsx(O0,{section:t},e)}function ff(t){const e=B.c(2);let s;return e[0]!==t?(s=n.jsx($0,{...t}),e[0]=t,e[1]=s):s=e[1],s}ff.Skeleton=function(){return n.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>n.jsx("div",{className:"w-full h-8",children:n.jsx($i,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function U0(){const t=B.c(7),s=Dh().logo??Mh,i=typeof s=="string"?s:s.light,r=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=n.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==r?(a=n.jsx("img",{src:r,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=r,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=n.jsx(Eu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:n.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function nd(t){const e=B.c(15),{item:s,onClose:i}=t,r=s.isActive&&"z-10";let o;e[0]!==r?(o=X(r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=n.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=n.jsx(_s,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=n.jsx(Zt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function H0(t){const e=B.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Nu,{className:"my-2"}),e[0]=r):r=e[0],r}case"spacer":{let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"flex-1"}),e[1]=r):r=e[1],r}case"group":{const r=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>n.jsx(nd,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=n.jsx(hf,{label:r,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let r;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>n.jsx(nd,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],r=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=r}else r=e[13];let o;return e[16]!==r?(o=n.jsx(Xn,{className:"pt-0 pr-0 pb-0 pl-0",children:n.jsx(Jn,{children:n.jsx(vs,{className:"gap-1.5",children:r})})}),e[16]=r,e[17]=o):o=e[17],o}}}function W0(t){const e=B.c(12),{sections:s,onClose:i,footer:r,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"h-10 shrink-0"}),children:n.jsx(U0,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,f)=>n.jsx(H0,{section:h,onClose:i},f),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=n.jsxs(Au,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==r||e[10]!==c?(d=n.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,r]}),e[9]=r,e[10]=c,e[11]=d):d=e[11],d}function mf(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const K0=js({name:Et().min(2,"Organization name is required")});function q0(t){const e=B.c(41),{open:s,onOpenChange:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={resolver:Un(K0),defaultValues:{name:""}},e[0]=r):r=e[0];const o=qi(r);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:Y0,onSuccess:G0},e[1]=a):a=e[1];const l=Ki(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(Dl,{children:[n.jsx(Ml,{children:"Create a new organization"}),n.jsx(Pl,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let w;e[6]!==l?(w=V=>l.mutateAsync(V),e[6]=l,e[7]=w):w=e[7],u=o.handleSubmit(w),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=w=>{const{field:V}=w;return n.jsxs(Rt,{children:[n.jsx(os,{children:"Organization Name"}),n.jsx(Tt,{children:n.jsx(gt,{...V,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),n.jsx(Sg,{children:"The name of your company or organization"}),V.value&&n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",n.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",mf(V.value)]})]}),n.jsx(Dt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let f;e[10]!==o.control||e[11]!==h?(f=n.jsx(It,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=f):f=e[12];let m;e[13]!==c?(m=c&&n.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=n.jsx(Rl,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let v;e[21]!==o.formState.isSubmitting?(v=o.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(In,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=v):v=e[22];let x;e[23]!==_||e[24]!==v?(x=n.jsx(oe,{type:"submit",variant:"default",disabled:_,children:v}),e[23]=_,e[24]=v,e[25]=x):x=e[25];let b;e[26]!==x||e[27]!==g?(b=n.jsxs(Ll,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==u||e[31]!==f||e[32]!==m?(y=n.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[f,m,b]}),e[29]=b,e[30]=u,e[31]=f,e[32]=m,e[33]=y):y=e[33];let C;e[34]!==o||e[35]!==y?(C=n.jsxs(Tl,{children:[d,n.jsx(Bi,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=C):C=e[36];let k;return e[37]!==i||e[38]!==s||e[39]!==C?(k=n.jsx(Ol,{open:s,onOpenChange:i,children:C}),e[37]=i,e[38]=s,e[39]=C,e[40]=k):k=e[40],k}function G0(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function Y0(t){const e=mf(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await St.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function Va(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function X0(t){const e=B.c(13),{org:s,size:i}=t,r=i===void 0?"sm":i,o=r==="xs"?"size-5":"size-6",a=r==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=X(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:Va(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?n.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:X("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=n.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function ur(t){const e=B.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=n.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=n.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let f;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(f=n.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=f):f=e[10],f}let r;e[11]!==s||e[12]!==i?(r=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=r):r=e[13];let o;e[14]!==s.icon?(o=n.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=n.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==r||e[19]!==o||e[20]!==a?(l=n.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=r,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function rd(t){const e=B.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:r,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Qt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=n.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,n.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==r||e[5]!==i||e[6]!==s){let f;e[8]!==r||e[9]!==i?(f=m=>n.jsxs("button",{type:"button",onClick:()=>r(m.slug),className:X("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",m.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[n.jsx(X0,{org:m,size:"sm"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:m.name}),n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:m.slug})]}),m.slug===i&&n.jsx(Jt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},m.id),e[8]=r,e[9]=i,e[10]=f):f=e[10],d=s.map(f),e[4]=r,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=n.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=n.jsxs(n.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function od(t){const e=B.c(142),{user:s,userImage:i,menuItems:r,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f,close:m,isMobile:p}=t;if(p){const q=s?.name??"U";let G;e[0]!==q||e[1]!==i?(G=n.jsx(Ic,{url:i,fallback:q,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=q,e[1]=i,e[2]=G):G=e[2];const ee=s?.name??"User";let Z;e[3]!==ee?(Z=n.jsx("p",{className:"text-sm font-medium truncate",children:ee}),e[3]=ee,e[4]=Z):Z=e[4];const J=s?.email;let se;e[5]!==J?(se=n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:J}),e[5]=J,e[6]=se):se=e[6];let ne;e[7]!==Z||e[8]!==se?(ne=n.jsxs("div",{className:"flex-1 min-w-0",children:[Z,se]}),e[7]=Z,e[8]=se,e[9]=ne):ne=e[9];let ce;e[10]!==s?(ce=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(ey)},e[10]=s,e[11]=ce):ce=e[11];let xe;e[12]===Symbol.for("react.memo_cache_sentinel")?(xe=n.jsx(zi,{size:14}),e[12]=xe):xe=e[12];let ae;e[13]!==ce?(ae=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",tabIndex:-1,onClick:ce,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:xe})}),e[13]=ce,e[14]=ae):ae=e[14];let he;e[15]===Symbol.for("react.memo_cache_sentinel")?(he=n.jsx(it,{side:"right",children:n.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=he):he=e[15];let pe;e[16]!==ae?(pe=n.jsx(Oi,{delayDuration:300,children:n.jsxs(nt,{children:[ae,he]})}),e[16]=ae,e[17]=pe):pe=e[17];let me;e[18]!==pe||e[19]!==G||e[20]!==ne?(me=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[G,ne,pe]}),e[18]=pe,e[19]=G,e[20]=ne,e[21]=me):me=e[21];let we;e[22]!==f||e[23]!==h||e[24]!==u||e[25]!==d?(we=n.jsx("div",{className:"border-b border-border pb-2",children:n.jsx(rd,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[22]=f,e[23]=h,e[24]=u,e[25]=d,e[26]=we):we=e[26];let ve;if(e[27]!==m||e[28]!==r){let Be;e[30]!==m?(Be=Kt=>n.jsx(ur,{item:Kt,onClose:m},Kt.key),e[30]=m,e[31]=Be):Be=e[31],ve=r.map(Be),e[27]=m,e[28]=r,e[29]=ve}else ve=e[29];let de;e[32]!==m||e[33]!==o?(de=n.jsx(ur,{item:o,onClose:m}),e[32]=m,e[33]=o,e[34]=de):de=e[34];let Re;e[35]!==ve||e[36]!==de?(Re=n.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,de]}),e[35]=ve,e[36]=de,e[37]=Re):Re=e[37];let te;e[38]!==we||e[39]!==Re?(te=n.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[we,Re]}),e[38]=we,e[39]=Re,e[40]=te):te=e[40];let ue;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let Be;e[45]!==l.theme||e[46]!==c?(Be=Kt=>{const{value:kt,icon:Ie,label:Me}=Kt;return n.jsx("button",{type:"button","aria-label":Me,onClick:()=>c(Ye=>({...Ye,theme:kt})),className:X("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===kt?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Ie},kt)},e[45]=l.theme,e[46]=c,e[47]=Be):Be=e[47],ue=a.map(Be),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=ue}else ue=e[44];let Ve;e[48]!==ue?(Ve=n.jsx("div",{className:"flex items-center gap-0.5",children:ue}),e[48]=ue,e[49]=Ve):Ve=e[49];const Ee=l.enableSounds?"Disable sounds":"Enable sounds";let Te;e[50]!==c?(Te=()=>c(Z0),e[50]=c,e[51]=Te):Te=e[51];const be=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let je;e[52]!==be?(je=X("size-8 rounded-md flex items-center justify-center transition-colors",be),e[52]=be,e[53]=je):je=e[53];let $e;e[54]!==l.enableSounds?($e=l.enableSounds?n.jsx(vc,{size:14}):n.jsx(bc,{size:14}),e[54]=l.enableSounds,e[55]=$e):$e=e[55];let Ge;e[56]!==Ee||e[57]!==Te||e[58]!==je||e[59]!==$e?(Ge=n.jsx("button",{type:"button","aria-label":Ee,onClick:Te,className:je,children:$e}),e[56]=Ee,e[57]=Te,e[58]=je,e[59]=$e,e[60]=Ge):Ge=e[60];let ge;e[61]===Symbol.for("react.memo_cache_sentinel")?(ge=n.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.281.4-alpha.1"]}),e[61]=ge):ge=e[61];let Ae;e[62]!==Ge?(Ae=n.jsxs("div",{className:"flex items-center gap-2",children:[Ge,ge]}),e[62]=Ge,e[63]=Ae):Ae=e[63];let Ze;e[64]!==Ve||e[65]!==Ae?(Ze=n.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[Ve,Ae]}),e[64]=Ve,e[65]=Ae,e[66]=Ze):Ze=e[66];let Ct;return e[67]!==me||e[68]!==te||e[69]!==Ze?(Ct=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[me,te,Ze]}),e[67]=me,e[68]=te,e[69]=Ze,e[70]=Ct):Ct=e[70],Ct}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=n.jsx(Ic,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const v=s?.name??"User";let x;e[74]!==v?(x=n.jsx("p",{className:"text-sm font-medium truncate",children:v}),e[74]=v,e[75]=x):x=e[75];const b=s?.email;let y;e[76]!==b?(y=n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:b}),e[76]=b,e[77]=y):y=e[77];let C;e[78]!==x||e[79]!==y?(C=n.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=C):C=e[80];let k;e[81]!==s?(k=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(Q0)},e[81]=s,e[82]=k):k=e[82];let w;e[83]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(zi,{size:14}),e[83]=w):w=e[83];let V;e[84]!==k?(V=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",tabIndex:-1,onClick:k,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:w})}),e[84]=k,e[85]=V):V=e[85];let j;e[86]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(it,{side:"right",children:n.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=j):j=e[86];let R;e[87]!==V?(R=n.jsx(Oi,{delayDuration:300,children:n.jsxs(nt,{children:[V,j]})}),e[87]=V,e[88]=R):R=e[88];let T;e[89]!==R||e[90]!==_||e[91]!==C?(T=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,C,R]}),e[89]=R,e[90]=_,e[91]=C,e[92]=T):T=e[92];let I;if(e[93]!==m||e[94]!==r){let q;e[96]!==m?(q=G=>n.jsx(ur,{item:G,onClose:m},G.key),e[96]=m,e[97]=q):q=e[97],I=r.map(q),e[93]=m,e[94]=r,e[95]=I}else I=e[95];let A;e[98]!==m||e[99]!==o?(A=n.jsx(ur,{item:o,onClose:m}),e[98]=m,e[99]=o,e[100]=A):A=e[100];let N;e[101]!==I||e[102]!==A?(N=n.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[I,A]}),e[101]=I,e[102]=A,e[103]=N):N=e[103];let E;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let q;e[108]!==l.theme||e[109]!==c?(q=G=>{const{value:ee,icon:Z,label:J}=G;return n.jsx("button",{type:"button","aria-label":J,onClick:()=>c(se=>({...se,theme:ee})),className:X("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===ee?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Z},ee)},e[108]=l.theme,e[109]=c,e[110]=q):q=e[110],E=a.map(q),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=E}else E=e[107];let M;e[111]!==E?(M=n.jsx("div",{className:"flex items-center gap-0.5",children:E}),e[111]=E,e[112]=M):M=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let D;e[113]!==c?(D=()=>c(J0),e[113]=c,e[114]=D):D=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let O;e[115]!==P?(O=X("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=O):O=e[116];let $;e[117]!==l.enableSounds?($=l.enableSounds?n.jsx(vc,{size:14}):n.jsx(bc,{size:14}),e[117]=l.enableSounds,e[118]=$):$=e[118];let z;e[119]!==L||e[120]!==D||e[121]!==O||e[122]!==$?(z=n.jsx("button",{type:"button","aria-label":L,onClick:D,className:O,children:$}),e[119]=L,e[120]=D,e[121]=O,e[122]=$,e[123]=z):z=e[123];let W;e[124]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.281.4-alpha.1"]}),e[124]=W):W=e[124];let F;e[125]!==z?(F=n.jsxs("div",{className:"flex items-center gap-2",children:[z,W]}),e[125]=z,e[126]=F):F=e[126];let K;e[127]!==M||e[128]!==F?(K=n.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[M,F]}),e[127]=M,e[128]=F,e[129]=K):K=e[129];let H;e[130]!==T||e[131]!==N||e[132]!==K?(H=n.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[T,N,K]}),e[130]=T,e[131]=N,e[132]=K,e[133]=H):H=e[133];let U;e[134]!==f||e[135]!==h||e[136]!==u||e[137]!==d?(U=n.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:n.jsx(rd,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[134]=f,e[135]=h,e[136]=u,e[137]=d,e[138]=U):U=e[138];let Y;return e[139]!==H||e[140]!==U?(Y=n.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[H,U]}),e[139]=H,e[140]=U,e[141]=Y):Y=e[141],Y}function J0(t){return{...t,enableSounds:!t.enableSounds}}function Q0(){fe.success("User ID copied")}function Z0(t){return{...t,enableSounds:!t.enableSounds}}function ey(){fe.success("User ID copied")}function pf(){const t=B.c(50),{data:e}=St.useSession(),{data:s}=St.useListOrganizations(),i=qe();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org",shouldThrow:!1},t[0]=r):r=t[0];const a=gp(r)?.params.org,[l,c]=yi(),d=Ms(),[u,h]=S.useState(!1),[f,m]=S.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const b=s?.find(Y=>Y.slug===a);let y;if(t[11]!==a||t[12]!==s){let Y;t[14]!==a?(Y=(q,G)=>q.slug===a?-1:G.slug===a?1:q.name.localeCompare(G.name),t[14]=a,t[15]=Y):Y=t[15],y=[...s??[]].sort(Y),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const C=y;let k;t[16]!==i?(k=Y=>{h(!1),i({to:"/$org",params:{org:Y}})},t[16]=i,t[17]=k):k=t[17];const w=k;let V;t[18]===Symbol.for("react.memo_cache_sentinel")?(V=()=>h(!1),t[18]=V):V=t[18];const j=V;let R;t[19]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Zn,{size:16}),t[19]=R):R=t[19];let T;t[20]!==i||t[21]!==a?(T={key:"preferences",label:"Preferences",icon:R,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=T):T=t[22];let I;t[23]===Symbol.for("react.memo_cache_sentinel")?(I={key:"terms",label:"Terms of Use",icon:n.jsx(Ig,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=I):I=t[23];let A;t[24]===Symbol.for("react.memo_cache_sentinel")?(A={key:"privacy",label:"Privacy Policy",icon:n.jsx(Rg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=A):A=t[24];let N;t[25]===Symbol.for("react.memo_cache_sentinel")?(N={key:"github",label:"decocms/studio",icon:n.jsx(_p,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=N):N=t[25];let E;t[26]===Symbol.for("react.memo_cache_sentinel")?(E={key:"community",label:"Community",icon:n.jsx(go,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=E):E=t[26];let M;t[27]===Symbol.for("react.memo_cache_sentinel")?(M={key:"homepage",label:"Homepage",icon:n.jsx(du,{size:16}),href:"https://decocms.com",external:!0},t[27]=M):M=t[27];let L;t[28]!==T?(L=[T,I,A,N,E,M],t[28]=T,t[29]=L):L=t[29];const D=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:n.jsx(Fg,{size:16}),onClick:sy},t[30]=P):P=t[30];const O=P;let $;t[31]===Symbol.for("react.memo_cache_sentinel")?($={value:"light",icon:n.jsx(O_,{size:14}),label:"Light theme"},t[31]=$):$=t[31];let z;t[32]===Symbol.for("react.memo_cache_sentinel")?(z={value:"dark",icon:n.jsx(B_,{size:14}),label:"Dark theme"},t[32]=z):z=t[32];let W;t[33]===Symbol.for("react.memo_cache_sentinel")?(W=[$,z,{value:"system",icon:n.jsx(z_,{size:14}),label:"System theme"}],t[33]=W):W=t[33];const F=W;let K;t[34]===Symbol.for("react.memo_cache_sentinel")?(K=()=>{h(!1),m(!0)},t[34]=K):K=t[34];let H;t[35]!==w||t[36]!==d||t[37]!==D||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==C||t[42]!==p||t[43]!==g?(H={user:p,userImage:g,menuItems:D,signOutItem:O,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:C,orgParam:a,onSelectOrg:w,onCreateOrg:K,close:j,isMobile:d},t[35]=w,t[36]=d,t[37]=D,t[38]=a,t[39]=l,t[40]=c,t[41]=C,t[42]=p,t[43]=g,t[44]=H):H=t[44];const U=H;_=d?n.jsxs(Ci,{open:u,onOpenChange:h,direction:"bottom",children:[n.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[n.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:Va(b?.name??""),children:b?.logo?n.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(b?.name??"?").slice(0,2).toUpperCase()})}),n.jsx("span",{className:"truncate",children:b?.name??"Account"})]}),n.jsxs(Vi,{className:"h-[80dvh] p-0",children:[n.jsx(wi,{className:"sr-only",children:"Account"}),n.jsx(od,{...U})]})]}):n.jsxs(di,{open:u,onOpenChange:h,children:[n.jsx(li,{asChild:!0,children:n.jsx(_s,{tooltip:b?.name??"Account",className:"rounded-md",children:n.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:Va(b?.name??""),children:b?.logo?n.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(b?.name??"?").slice(0,2).toUpperCase()})})})}),n.jsx(ci,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:ty,children:n.jsx(od,{...U})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let v;t[45]!==f?(v=n.jsx(q0,{open:f,onOpenChange:m}),t[45]=f,t[46]=v):v=t[46];let x;return t[47]!==_||t[48]!==v?(x=n.jsxs(n.Fragment,{children:[_,v]}),t[47]=_,t[48]=v,t[49]=x):x=t[49],x}function ty(t){return t.preventDefault()}function sy(){ie("signed_out",{source:"account_popover"}),St.signOut()}function iy({invitation:t}){const[e,s]=S.useState(!1),[i,r]=S.useState(!1),o=Mt(),a=async()=>{s(!0);try{const c=await St.organization.acceptInvitation({invitationId:t.id});if(c.error)fe.error(c.error.message),s(!1);else{const d=await St.organization.setActive({organizationId:t.organizationId});fe.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{fe.error("Failed to accept invitation"),s(!1)}},l=async()=>{r(!0);try{const c=await St.organization.rejectInvitation({invitationId:t.id});c.error?(fe.error(c.error.message),r(!1)):(fe.success("Invitation declined"),o.invalidateQueries())}catch{fe.error("Failed to decline invitation"),r(!1)}};return n.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),n.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),n.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[n.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:n.jsx(Jt,{size:14})}),n.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:n.jsx(ri,{size:14})})]})]})}function ny(){const t=S.useContext(xp),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class ry extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function oy(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function ay(){const t=B.c(19),e=qe(),{org:s}=ye();let i;t[0]!==s.id?(i={connectionId:Pt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const r=Le(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==r?(a={client:r,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:ly},t[3]=r,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=ki(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const f=h;let m;t[9]!==u?(m=X(u!=null&&oy(u)),t[9]=u,t[10]=m):m=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Sl,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==m||t[16]!==p||t[17]!==f?(_=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:f,className:m,onClick:p,children:g})})}),t[15]=m,t[16]=p,t[17]=f,t[18]=_):_=t[18],_}function ly(t){return t.structuredContent}function cy(){const t=B.c(1);if(!Nl().some(dy))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ay,{}),t[0]=i):i=t[0],i}function dy(t){return t.providerId==="deco"}function hy(){const t=B.c(3),[e,s]=S.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Connections",onClick:()=>{ie("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:n.jsx(Ug,{size:24})})})}),t[0]=i):i=t[0];let r;return t[1]!==e?(r=n.jsxs(n.Fragment,{children:[i,n.jsx(Ul,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=r):r=t[2],r}function uy(){const t=B.c(11),e=ny();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(yc,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&n.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let r;t[3]!==i?(r=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(li,{asChild:!0,children:n.jsxs(_s,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=r):r=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:n.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=n.jsxs(ci,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[n.jsx(yc,{size:24,className:"text-muted-foreground/50"}),n.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):n.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(fy)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==r||t[9]!==a?(l=n.jsxs(di,{children:[r,a]}),t[8]=r,t[9]=a,t[10]=l):l=t[10],l}function fy(t){return n.jsx(iy,{invitation:t},t.id)}function my(){const t=B.c(6),e=qe(),{org:s}=ye();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Zn,{size:24}),t[3]=r):r=t[3];let o;return t[4]!==i?(o=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Settings",onClick:i,children:r})})}),t[4]=i,t[5]=o):o=t[5],o}function py(){const t=B.c(5);let e,s,i,r;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(ry,{children:n.jsx(S.Suspense,{fallback:null,children:n.jsx(cy,{})})}),s=n.jsx(hy,{}),i=n.jsx(uy,{}),r=n.jsx(my,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=r):(e=t[0],s=t[1],i=t[2],r=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs(Iu,{className:"px-2 pb-3 gap-1",children:[e,s,i,r,n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(pf,{})})})]}),t[4]=o):o=t[4],o}function gy(){const t=B.c(10),e=qe(),{org:s}=ye(),{setOpenMobile:i}=Qn();let r;t[0]!==e||t[1]!==s.slug||t[2]!==i?(r=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=r):r=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Zn,{}),t[4]=o):o=t[4];let a;t[5]!==r?(a=n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Settings",onClick:r,children:o})}),t[5]=r,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Zt,{children:n.jsx(pf,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=n.jsx(Iu,{children:n.jsxs(vs,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}function _y(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return S.useMemo(()=>i=>{e.forEach(r=>r(i))},e)}const vo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Yi(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Hl(t){return"nodeType"in t}function Wt(t){var e,s;return t?Yi(t)?t:Hl(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Wl(t){const{Document:e}=Wt(t);return t instanceof e}function tr(t){return Yi(t)?!1:t instanceof Wt(t).HTMLElement}function gf(t){return t instanceof Wt(t).SVGElement}function Xi(t){return t?Yi(t)?t.document:Hl(t)?Wl(t)?t:tr(t)||gf(t)?t.ownerDocument:document:document:document}const Ts=vo?S.useLayoutEffect:S.useEffect;function Kl(t){const e=S.useRef(t);return Ts(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}function xy(){const t=S.useRef(null),e=S.useCallback((i,r)=>{t.current=setInterval(i,r)},[]),s=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Mn(t,e){e===void 0&&(e=[t]);const s=S.useRef(t);return Ts(()=>{s.current!==t&&(s.current=t)},e),s}function sr(t,e){const s=S.useRef();return S.useMemo(()=>{const i=t(s.current);return s.current=i,i},[...e])}function Yr(t){const e=Kl(t),s=S.useRef(null),i=S.useCallback(r=>{r!==s.current&&e?.(r,s.current),s.current=r},[]);return[s,i]}function Ca(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let zo={};function ir(t,e){return S.useMemo(()=>{if(e)return e;const s=zo[t]==null?0:zo[t]+1;return zo[t]=s,t+"-"+s},[t,e])}function _f(t){return function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;r<s;r++)i[r-1]=arguments[r];return i.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const u=o[c];u!=null&&(o[c]=u+t*d)}return o},{...e})}}const Li=_f(1),Pn=_f(-1);function vy(t){return"clientX"in t&&"clientY"in t}function ql(t){if(!t)return!1;const{KeyboardEvent:e}=Wt(t.target);return e&&t instanceof e}function by(t){if(!t)return!1;const{TouchEvent:e}=Wt(t.target);return e&&t instanceof e}function ka(t){if(by(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return vy(t)?{x:t.clientX,y:t.clientY}:null}const Ln=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Ln.Translate.toString(t),Ln.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:i}=t;return e+" "+s+"ms "+i}}}),ad="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function yy(t){return t.matches(ad)?t:t.querySelector(ad)}const Sy={display:"none"};function wy(t){let{id:e,value:s}=t;return Ut.createElement("div",{id:e,style:Sy},s)}function Vy(t){let{id:e,announcement:s,ariaLiveType:i="assertive"}=t;const r={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ut.createElement("div",{id:e,style:r,role:"status","aria-live":i,"aria-atomic":!0},s)}function Cy(){const[t,e]=S.useState("");return{announce:S.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const xf=S.createContext(null);function ky(t){const e=S.useContext(xf);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function jy(){const[t]=S.useState(()=>new Set),e=S.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[S.useCallback(i=>{let{type:r,event:o}=i;t.forEach(a=>{var l;return(l=a[r])==null?void 0:l.call(a,o)})},[t]),e]}const Ny={draggable:`
|
|
549
549
|
To pick up a draggable item, press the space bar.
|
|
550
550
|
While dragging, use the arrow keys to move the item.
|
|
551
551
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
@@ -736,4 +736,4 @@ ${te}
|
|
|
736
736
|
|
|
737
737
|
<message>
|
|
738
738
|
${he}
|
|
739
|
-
</message>`}]}}))},L=e.models?.credentialId||m||"",D=e.models?.thinking?.id||p?.modelId||"",P=qi({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:D}}),O=P.watch("active"),$=P.watch("credential_id"),z=P.watch("model_id"),{models:W,isLoading:F}=uu($||void 0),K=W.find(ae=>ae.modelId===z)??null,H=S.useRef(null),U=S.useRef(new Set),Y=S.useRef(0),q=S.useRef(null),G=3e4,ee=()=>{q.current&&(clearTimeout(q.current),q.current=null),H.current!==null&&(ie("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(U.current),save_count:Y.current,edit_duration_ms:Date.now()-H.current}),H.current=null,U.current=new Set,Y.current=0)},Z=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!E.current)return!0;const he=Object.keys(P.formState.dirtyFields),pe=E.current;E.current=!1;const me=P.getValues();try{const we=me.credential_id&&me.model_id?me.credential_id:"",ve=me.credential_id&&me.model_id?me.model_id:"",de={id:t,name:me.name,active:me.active,agent:{id:o},models:{credentialId:we,thinking:{id:ve}},messages:Bh(b),temperature:0};await l.mutateAsync(de),H.current===null&&(H.current=Date.now());for(const Re of he)U.current.add(Re);return pe&&U.current.add("messages"),Y.current+=1,q.current&&clearTimeout(q.current),q.current=setTimeout(ee,G),P.reset({...me,credential_id:we,model_id:ve}),!0}catch{return E.current=!0,!1}},J=()=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{Z()},1e3)},se=async()=>(N.current&&clearTimeout(N.current),Z()),ne=ae=>{if(y(ae),!A.current){A.current=!0;return}E.current=!0,J()},ce=S.useRef(!1);ce.current||(ce.current=!0,P.watch(()=>{J()}));const xe=async()=>{ie("automation_test_clicked",{automation_id:t,agent_id:o});const ae=await se();if(ee(),!ae)return;if(!b){fe.error("No instructions configured for this automation");return}K&&$&&f({...K,keyId:$}),v({..._,toolApprovalLevel:"auto"});const he=gc(b);h({message:{tiptapDoc:b,parts:he},virtualMcpId:o||void 0})};return n.jsxs(n.Fragment,{children:[i&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(oe,{variant:"ghost",size:"sm",onClick:i,children:[n.jsx(kl,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(gt,{...P.register("name"),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"}}),r&&n.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:r,children:n.jsx(xa,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ri,{control:P.control,name:"active",render:({field:ae})=>n.jsx(Hr,{checked:ae.value,onCheckedChange:he=>{ae.onChange(he),setTimeout(()=>se(),0)},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(K_,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(Xj,{automationId:t,open:C,onOpenChange:k,onCustomSelect:()=>{V(!0),I(!1),R("")},onEventSelect:()=>{I(!0),V(!1)}})]}),e.triggers.length===0&&!w?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>k(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ae=>n.jsx(Jj,{trigger:ae,automationId:t,connectionName:ae.connection_id?u.get(ae.connection_id):void 0},ae.id))}),w&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(Sn,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:j,onChange:ae=>R(ae.target.value),onBlur:async()=>{const ae=j.trim();if(!(!ae||!An(ae)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:ae}),ie("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),fe.success("Starter added"),V(!1),R("")}catch{fe.error("Failed to add starter")}},onKeyDown:async ae=>{const he=j.trim();ae.key==="Enter"&&he&&An(he)&&ae.target.blur(),ae.key==="Escape"&&(V(!1),R(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!An(j)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&n.jsx(De,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.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:()=>{V(!1),R("")},children:n.jsx(ri,{size:13})})]}),T&&n.jsx(S.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(De,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Zj,{automationId:t,onDone:()=>I(!1)})})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!b,onClick:M,children:[n.jsx(Cl,{size:13}),"Improve"]})]}),n.jsx(tf,{tiptapDoc:b,setTiptapDoc:ne,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(sf,{virtualMcpId:o||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(mu,{model:K,isLoading:F,credentialId:$||null,onCredentialChange:ae=>{P.setValue("credential_id",ae??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:ae=>P.setValue("model_id",ae.modelId,{shouldDirty:!0}),placeholder:"Model"}),n.jsxs(nt,{children:[n.jsx(st,{asChild:!0,children:n.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:xe,disabled:!o,children:[n.jsx(Zh,{size:16}),"Test"]})}),n.jsx(it,{children:"Test Automation"})]})]})]})})]})]})]})}function n5(t){const e=B.c(6),{tabId:s,virtualMcpId:i}=t;let r;e[0]!==s?(r=$h(s),e[0]=s,e[1]=r):r=e[1];const o=r;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=n.jsx(ps,{children:n.jsx(ps.Content,{children:n.jsx(ps.Body,{children:n.jsx(S.Suspense,{fallback:a,children:n.jsx(r5,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function r5(t){const e=B.c(9),{id:s,virtualMcpId:i}=t,r=qe(),{data:o,isLoading:a}=G_(s);let l;e[0]!==r?(l=()=>r({to:".",search:o5,replace:!0}),e[0]=r,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=n.jsx(i5,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function o5(t){return{...t,main:"automations"}}function a5(t){const e=B.c(19),{virtualMcpId:s}=t,i=qe(),{data:r}=Y_(s),o=r===void 0?[]:r,{create:a}=er(),[l,c]=S.useState(""),d=l.toLowerCase(),u=o.filter(j=>j.name.toLowerCase().includes(d));let h;e[0]!==i?(h=j=>i({to:".",search:R=>({...R,main:"automation:"+j}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const f=h,m=async()=>{if(a.isPending)return;ie("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const j=await a.mutateAsync(J_(s));f(j.id)},p=ps,g=ps,_=ps;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Qt,{size:14}),e[2]=v):v=e[2];let x;e[3]!==a.isPending||e[4]!==m?(x=n.jsx(ps.Title,{actions:n.jsxs(oe,{size:"sm",onClick:m,disabled:a.isPending,children:[v,"New automation"]}),children:"Automations"}),e[3]=a.isPending,e[4]=m,e[5]=x):x=e[5];const b=o.length>0&&n.jsx(Q_,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[6]!==x||e[7]!==b?(y=n.jsxs("div",{className:"flex flex-col gap-6",children:[x,b]}),e[6]=x,e[7]=b,e[8]=y):y=e[8];const C=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Fi,{image:n.jsx(Ui,{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:n.jsxs(oe,{size:"sm",onClick:m,disabled:a.isPending,children:[n.jsx(Qt,{size:14}),"New automation"]})})}):u.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Fi,{image:n.jsx(Ui,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(j=>n.jsx(X_,{automation:j,onClick:()=>f(j.id)},j.id))});let k;e[9]!==_.Body||e[10]!==y||e[11]!==C?(k=n.jsxs(_.Body,{children:[y,C]}),e[9]=_.Body,e[10]=y,e[11]=C,e[12]=k):k=e[12];let w;e[13]!==k||e[14]!==g.Content?(w=n.jsx(g.Content,{children:k}),e[13]=k,e[14]=g.Content,e[15]=w):w=e[15];let V;return e[16]!==p||e[17]!==w?(V=n.jsx(p,{children:w}),e[16]=p,e[17]=w,e[18]=V):V=e[18],V}function l5(t){const e=B.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(S.Suspense,{fallback:i,children:n.jsx(a5,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Vh=S.lazy(()=>Op(()=>import("./project-app-view-XrA_5t6Q.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])).then(t=>({default:t.AppViewContent})));function c5(t){const e=B.c(35),{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:o,layoutTabs:a,automationTabParsed:l}=Zf(r);if(og(o)){let m;return e[3]!==i?(m=n.jsx(jd,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(o==="git"){let m;return e[5]!==i?(m=n.jsx(YV,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(o==="automations"){let m;return e[7]!==i?(m=n.jsx(l5,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(o==="env"){let m;return e[9]!==i?(m=n.jsx(Hj,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(o==="preview"){let m;return e[11]!==i?(m=n.jsx(kC,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(l){let m;return e[13]!==o||e[14]!==i?(m=n.jsx(n5,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=m):m=e[15],m}let c;e[16]!==o?(c=ag(o),e[16]=o,e[17]=c):c=e[17];const d=c;if(d){let m;e[18]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[18]=m):m=e[18];let p;return e[19]!==o||e[20]!==d.connectionId||e[21]!==d.toolName?(p=n.jsx(S.Suspense,{fallback:m,children:n.jsx(Vh,{connectionId:d.connectionId,toolName:d.toolName},o)}),e[19]=o,e[20]=d.connectionId,e[21]=d.toolName,e[22]=p):p=e[22],p}let u;if(e[23]!==o||e[24]!==a){let m;e[26]!==o?(m=p=>p.id===o,e[26]=o,e[27]=m):m=e[27],u=a.find(m),e[23]=o,e[24]=a,e[25]=u}else u=e[25];const h=u;if(h){let m;e[28]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=m):m=e[28];let p;return e[29]!==o||e[30]!==h.id||e[31]!==h.view.appId?(p=n.jsx(S.Suspense,{fallback:m,children:n.jsx(Vh,{connectionId:h.view.appId,toolName:h.id},o)}),e[29]=o,e[30]=h.id,e[31]=h.view.appId,e[32]=p):p=e[32],p}let f;return e[33]!==i?(f=n.jsx(jd,{virtualMcpId:i}),e[33]=i,e[34]=f):f=e[34],f}function d5(t){const e=B.c(7),{children:s,defaultSize:i}=t,[,r]=S.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=pl.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=ml(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=n.jsx(pu,{defaultSize:c,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]=c,e[5]=u,e[6]=h):h=e[6],h}function h5(t){const e=B.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==r||e[1]!==o?(c=Sd(r,o),e[0]=r,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=pl.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=ml(u,45),f=S.useRef(null);let m,p;e[4]!==r||e[5]!==o||e[6]!==h?(m=()=>{const T=f.current;if(!T)return;const I=Sd(r,o),A=I.chat>0&&I.chat<100?h:I.chat,N=I.chat>0&&I.chat<100?100-h:I.main;T.setLayout([A,N])},p=[r,o,h],e[4]=r,e[5]=o,e[6]=h,e[7]=m,e[8]=p):(m=e[7],p=e[8]),S.useEffect(m,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let v;e[10]!==l||e[11]!==a?(v=l??n.jsx(of,{variant:a}),e[10]=l,e[11]=a,e[12]=v):v=e[12];let x;e[13]!==v?(x=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[13]=v,e[14]=x):x=e[14];let b;e[15]!==d.chat||e[16]!==x?(b=n.jsx(d5,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=b):b=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(r_,{className:"bg-sidebar"}),e[18]=y):y=e[18];const C=d.main;let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k={overflow:"visible"},e[19]=k):k=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=X("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[20]=w):w=e[20];let V;e[21]!==i||e[22]!==s?(V=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:w,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(c5,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=V):V=e[23];let j;e[24]!==d.main||e[25]!==V?(j=n.jsx(pu,{className:"min-w-0 flex flex-col",order:2,defaultSize:C,style:k,collapsible:!0,collapsedSize:0,minSize:20,children:V}),e[24]=d.main,e[25]=V,e[26]=j):j=e[26];let R;return e[27]!==j||e[28]!==g||e[29]!==b?(R=n.jsxs(o_,{ref:f,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[b,y,j]},g),e[27]=j,e[28]=g,e[29]=b,e[30]=R):R=e[30],R}const ca="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Ch="bg-sidebar-accent text-sidebar-foreground",da="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function u5(t){const e=B.c(38),{isDecopilot:s,chatOpen:i,toggleChat:r,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=Jf(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{ie("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?Ch:da;let h;e[3]!==u?(h=X(ca,u),e[3]=u,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx($g,{size:16}),e[5]=f):f=e[5];let m;e[6]!==d||e[7]!==h||e[8]!==a?(m=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:f})}),e[6]=d,e[7]=h,e[8]=a,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(it,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==m?(g=n.jsxs(nt,{delayDuration:300,children:[m,p]}),e[11]=m,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==r?(_=!s&&n.jsxs(nt,{delayDuration:300,children:[n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>{ie("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),r()},"aria-pressed":i,className:X(ca,i?Ch:da),children:n.jsx(zg,{size:16})})}),n.jsx(it,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=r,e[16]=_):_=e[16];const v=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==v?(x=X("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",v),e[17]=v,e[18]=x):x=e[18];const b=!c,y=c?0:-1,C=!c,k=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let w;e[19]!==k?(w=X(ca,da,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",k),e[19]=k,e[20]=w):w=e[20];let V;e[21]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(wl,{size:16}),e[21]=V):V=e[21];let j;e[22]!==o||e[23]!==b||e[24]!==y||e[25]!==C||e[26]!==w?(j=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,disabled:b,tabIndex:y,"aria-hidden":C,className:w,children:V})}),e[22]=o,e[23]=b,e[24]=y,e[25]=C,e[26]=w,e[27]=j):j=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(it,{side:"bottom",children:"New task"}),e[28]=R):R=e[28];let T;e[29]!==j?(T=n.jsx("div",{className:"overflow-hidden",children:n.jsxs(nt,{delayDuration:300,children:[j,R]})}),e[29]=j,e[30]=T):T=e[30];let I;e[31]!==x||e[32]!==T?(I=n.jsx("div",{className:x,children:T}),e[31]=x,e[32]=T,e[33]=I):I=e[33];let A;return e[34]!==I||e[35]!==g||e[36]!==_?(A=n.jsxs(n.Fragment,{children:[g,_,I]}),e[34]=I,e[35]=g,e[36]=_,e[37]=A):A=e[37],A}function f5(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(h=>h.id===e))return{visible:i,overflow:r};const a=r.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],c=r[a],d=[...i.slice(0,-1),c],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:d,overflow:u}}function m5(t){const e=B.c(13),{title:s,icon:i,active:r,onClick:o}=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=X("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 c;e[2]!==i?(c=n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(p5,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=n.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==r||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=n.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,"aria-label":s,className:l,children:[c,d]}),e[6]=r,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function p5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.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=n.jsx(ou,{className:"size-4"}),e[4]=i):i=e[4],i}function g5(t){const e=B.c(13),{overflow:s,onSelect:i}=t,[r,o]=S.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(li,{asChild:!0,children:n.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:n.jsx(iu,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(_5,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=n.jsx(ci,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==r||e[11]!==u?(h=n.jsxs(di,{open:r,onOpenChange:o,children:[c,u]}),e[10]=r,e[11]=u,e[12]=h):h=e[12],h}function _5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.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=n.jsx(ou,{className:"size-4"}),e[4]=i):i=e[4],i}const x5=6;function v5(t){const e=B.c(20),{virtualMcpId:s,taskId:i}=t,r=qe();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=Zf(o);let u,h,f,m;if(e[3]!==l||e[4]!==c||e[5]!==r||e[6]!==d||e[7]!==a||e[8]!==s){const _=lg({activeTab:l,mainOpen:c}),v=k=>k.id==="automations"?_:c&&k.id===l,b=a.find(k=>v(k))?.id??null,{visible:y,overflow:C}=f5(a,b,x5);h=C,u=k=>{const w=a.find(j=>j.id===k),V=b===k&&c;if(ie("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:w?.kind??null,was_active:V}),k==="automations"){const j=cg({activeTab:l,mainOpen:c});r({to:".",search:R=>({...R,main:j}),replace:!0});return}d(k)},f="flex items-center min-w-0 ml-auto gap-0.5",m=y.map(k=>n.jsx(m5,{title:k.title,icon:k.icon,active:v(k),onClick:()=>u(k.id)},k.id)),e[3]=l,e[4]=c,e[5]=r,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=f,e[12]=m}else u=e[9],h=e[10],f=e[11],m=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&n.jsx(g5,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=n.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}function b5(t){const e=B.c(12);let s,i,r,o;e[0]!==t?({className:s,orientation:r,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=o):(s=e[1],i=e[2],r=e[3],o=e[4]);const a=r===void 0?"horizontal":r,l=o===void 0?!0:o;let c;e[5]!==s?(c=X("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]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=n.jsx(Bp,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function y5(t){const e=B.c(20),{prNumber:s,disabled:i,send:r}=t;let o;e[0]!==s||e[1]!==r?(o=()=>r(OV({prNumber:s})),e[0]=s,e[1]=r,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==r?(l=()=>r(LV({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=n.jsx(oe,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Rn,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=n.jsx(Es,{asChild:!0,children:n.jsx(oe,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let f;e[12]!==c?(f=n.jsx(Is,{align:"end",children:n.jsx(at,{onClick:c,children:"Review"})}),e[12]=c,e[13]=f):f=e[13];let m;e[14]!==h||e[15]!==f?(m=n.jsxs(As,{children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,m]}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}const S5=new Set(["failure","timed_out","cancelled","action_required"]);function w5(t){return t.status==="completed"&&S5.has(t.conclusion)}function V5(t){return t.status==="queued"||t.status==="in_progress"}function C5(t){const{branchStatus:e,pr:s,checks:i,reviews:r}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(w5).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(V5)?{label:"Running tests…",disabled:!0}:r?.draft?{label:"Mark ready",action:"mark-ready"}:(r?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function k5(){return Qi().branchStatus}const j5=6e4,N5=3e4;function A5(t){const e=B.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Le(s),r=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:j5,refetchIntervalInBackground:!1,staleTime:N5,select:E5},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],ki(l)}function E5(t){const e=nr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),o=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function I5(t){const e=B.c(38),{virtualMcpId:s}=t,{org:i}=ye(),r=is(s),{currentBranch:o}=es(),a=ro(),l=r?.metadata?.githubRepo??null,c=k5(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",f=o??null;let m;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==f?(m={orgId:i.id,connectionId:d,owner:u,repo:h,branch:f},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=f,e[5]=m):m=e[5];const g=tm(m).data??null,_=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",b=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==v||e[9]!==x||e[10]!==b?(y={orgId:i.id,connectionId:_,owner:v,repo:x,prNumber:b},e[6]=i.id,e[7]=_,e[8]=v,e[9]=x,e[10]=b,e[11]=y):y=e[11];const C=im(y),k=l?.connectionId??"",w=l?.owner??"",V=l?.name??"",j=g&&g.state==="open"?g.number:null;let R;e[12]!==i.id||e[13]!==k||e[14]!==w||e[15]!==V||e[16]!==j?(R={orgId:i.id,connectionId:k,owner:w,repo:V,prNumber:j},e[12]=i.id,e[13]=k,e[14]=w,e[15]=V,e[16]=j,e[17]=R):R=e[17];const T=A5(R);if(!l?.connectionId||!o)return null;let I;e[18]!==c||e[19]!==C.data||e[20]!==g||e[21]!==T.data?(I=C5({branchStatus:c,pr:g,checks:C.data??[],reviews:T.data??null}),e[18]=c,e[19]=C.data,e[20]=g,e[21]=T.data,e[22]=I):I=e[22];const A=I;if(!A)return null;let N;e[23]!==a?(N=z=>a.sendMessage({parts:[{type:"text",text:z}]}),e[23]=a,e[24]=N):N=e[24];const E=N,M=a.isStreaming;let L;e[25]!==o||e[26]!==A||e[27]!==M||e[28]!==g||e[29]!==E?(L=z=>{if(!M)switch(z){case"commit-and-push":{E(AV({branch:o}));return}case"create-pr":{E(EV({branch:o}));return}case"reopen":{g&&E(IV({prNumber:g.number}));return}case"rebase":{E(RV({branch:o}));return}case"fix-checks":{g&&E(DV({prNumber:g.number,failingChecks:A.meta?.failingChecks??[]}));return}case"mark-ready":{g&&E(MV({prNumber:g.number}));return}case"resolve-comments":{g&&E(PV({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=A,e[27]=M,e[28]=g,e[29]=E,e[30]=L):L=e[30];const D=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(b5,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const O=g?.number;let $;return e[32]!==A||e[33]!==M||e[34]!==D||e[35]!==E||e[36]!==O?($=n.jsxs(n.Fragment,{children:[P,n.jsx(R5,{button:A,isStreaming:M,onActivate:D,prNumber:O,send:E})]}),e[32]=A,e[33]=M,e[34]=D,e[35]=E,e[36]=O,e[37]=$):$=e[37],$}function R5(t){const e=B.c(18),{button:s,isStreaming:i}=t,r=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=n.jsx(y5,{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 h;return e[4]!==u||e[5]!==o?(h=n.jsx(kh,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==r||e[12]!==a||e[13]!==l?(c=n.jsx(oe,{size:"sm",variant:a,disabled:r,onClick:l,children:s.label}),e[10]=s.label,e[11]=r,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=n.jsx(kh,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function kh(t){const e=B.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=n.jsx(n.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=n.jsx(st,{asChild:!0,children:n.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=n.jsx(it,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(Oi,{children:n.jsxs(nt,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function T5(t){const e=B.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=n.jsx(Ue.Right,{children:n.jsx(I5,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const Di=S.createContext(null);function mc(){return S.use(Di)}function jh(t){const e=B.c(8),{children:s,variant:i}=t,{taskId:r}=es();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.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]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Oe.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??n.jsx(of,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==r?(c=n.jsx(Ns,{fallback:o,children:n.jsx(S.Suspense,{fallback:a,children:n.jsx(Oe.ActiveTaskProvider,{taskId:r,children:l})})}),e[5]=l,e[6]=r,e[7]=c):c=e[7],c}function Nh(t){const e=B.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],S.useLayoutEffect(r),null}function D5(t){const e=B.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Hg,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:n.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 Ah(t){const e=B.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:o}=t,{org:a}=ye(),{currentBranch:l}=es(),{data:c}=St.useSession(),d=c?.user?.id,u=d&&l?r?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const f=h;let m;e[2]!==a.id?(m={connectionId:Pt,orgId:a.id},e[2]=a.id,e[3]=m):m=e[3];const p=Le(m),{mutate:g}=ec(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const v=S.useRef(_);let x,b;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==r?(x=()=>{i&&d&&l&&(r?.[d]?.[l]||v.current.has(l)||(v.current.add(l),g({virtualMcpId:s,branch:l},{onError:M5})))},b=[i,d,l,r,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=r,e[11]=x,e[12]=b):(x=e[11],b=e[12]),S.useEffect(x,b);let y;return e[13]!==o||e[14]!==f?(y=n.jsx(dC,{daemonBaseUrl:f,children:o}),e[13]=o,e[14]=f,e[15]=y):y=e[15],y}function M5(t){console.error("[auto-start-vm] failed:",t)}function Eh(){const t=B.c(106),e=Ms(),s=qe(),{org:i}=ye(),r=hw()?.tasksOpen??!1;$_(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=Hn(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=Si(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??ho(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let f;t[5]!==i.id?(f=vl(i.id),t[5]=i.id,t[6]=f):f=t[6];const m=h===f,p=!m,g=tx(a.taskId??"",h),_=is(h),v=_?.metadata?.ui?.layout??null;let x;t[7]!==v?(x=v?{defaultMainView:v.defaultMainView??null,chatDefaultOpen:v.chatDefaultOpen??null}:null,t[7]=v,t[8]=x):x=t[8];const b=x;let y;t[9]!==_?(y=_&&Fs(_),t[9]=_,t[10]=y):y=t[10];const C=!!y;let k;t[11]!==p||t[12]!==l||t[13]!==h?(k={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=k):k=t[14];const w=lw(b,k),{setOpenMobile:V,openMobile:j}=Qn(),R=V,T=S.useRef(null);let I,A;t[15]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const q=G=>{Kh(G)&&G.shiftKey&&G.code==="KeyS"&&!G.repeat&&(G.preventDefault(),T.current?.())};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},A=[],t[15]=I,t[16]=A):(I=t[15],A=t[16]),S.useEffect(I,A);const N=h;let E;t[17]!==_||t[18]!==h?(E={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=E):E=t[19];const M=E;if(g.status==="creating"||g.status==="loading"){let q;t[20]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[n.jsx(De,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=q):q=t[20];let G;return t[21]!==M?(G=n.jsx(Di,{value:M,children:q}),t[21]=M,t[22]=G):G=t[22],G}if(g.status==="error"){let q;t[23]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=q):q=t[23];let G;t[24]!==g.error.message?(G=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.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:[q,n.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=G):G=t[25];let ee;return t[26]!==M||t[27]!==G?(ee=n.jsx(Di,{value:M,children:G}),t[26]=M,t[27]=G,t[28]=ee):ee=t[28],ee}if(!_){let q;t[29]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(oi,{size:48,className:"text-muted-foreground"}),t[29]=q):q=t[29];const G=`The agent "${h}" does not exist in this organization.`;let ee;t[30]!==s||t[31]!==l?(ee=n.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=ee):ee=t[32];let Z;t[33]!==G||t[34]!==ee?(Z=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:n.jsx(Fi,{image:q,title:"Agent not found",description:G,actions:ee})})}),t[33]=G,t[34]=ee,t[35]=Z):Z=t[35];let J;return t[36]!==M||t[37]!==Z?(J=n.jsx(Di,{value:M,children:Z}),t[36]=M,t[37]=Z,t[38]=J):J=t[38],J}if(e){let q;t[39]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(M_,{className:"sr-only",children:"Navigation"}),t[39]=q):q=t[39];let G;t[40]!==R?(G=n.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:n.jsx(tw,{onClose:()=>R(!1)})}),t[40]=R,t[41]=G):G=t[41];let ee;t[42]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:n.jsx(cf,{})}),t[42]=ee):ee=t[42];let Z;t[43]!==G?(Z=n.jsxs(P_,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[q,n.jsxs("div",{className:"flex h-full",children:[G,ee]})]}),t[43]=G,t[44]=Z):Z=t[44];let J;t[45]!==j||t[46]!==R||t[47]!==Z?(J=n.jsx(L_,{open:j,onOpenChange:R,children:Z}),t[45]=j,t[46]=R,t[47]=Z,t[48]=J):J=t[48];const se=J,ne=_?.metadata?.vmMap;let ce;t[49]!==w.createNewTask?(ce=n.jsx(Nh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[49]=w.createNewTask,t[50]=ce):ce=t[50];let xe;t[51]!==R?(xe=n.jsx(D5,{onOpenSidebar:()=>R(!0)}),t[51]=R,t[52]=xe):xe=t[52];const ae=m?"home":void 0;let he;t[53]!==ae?(he=n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(jh,{variant:ae})}),t[53]=ae,t[54]=he):he=t[54];let pe;t[55]!==C||t[56]!==se||t[57]!==ne||t[58]!==ce||t[59]!==xe||t[60]!==he||t[61]!==h?(pe=n.jsxs(Ah,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:ne,children:[ce,xe,he,se]}),t[55]=C,t[56]=se,t[57]=ne,t[58]=ce,t[59]=xe,t[60]=he,t[61]=h,t[62]=pe):pe=t[62];let me;t[63]!==N||t[64]!==pe?(me=n.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:n.jsx(Oe.Provider,{virtualMcpId:N,children:pe},N)}),t[63]=N,t[64]=pe,t[65]=me):me=t[65];let we;return t[66]!==M||t[67]!==me?(we=n.jsx(Di,{value:M,children:me}),t[66]=M,t[67]=me,t[68]=we):we=t[68],we}const L=r?void 0:w.createNewTask;let D;t[69]!==m||t[70]!==w.chatOpen||t[71]!==w.toggleChat||t[72]!==L?(D=n.jsx(Ue.Toggles,{children:n.jsx(u5,{isDecopilot:m,chatOpen:w.chatOpen,toggleChat:w.toggleChat,onNewTask:L})}),t[69]=m,t[70]=w.chatOpen,t[71]=w.toggleChat,t[72]=L,t[73]=D):D=t[73];let P;t[74]!==m||t[75]!==w.taskId||t[76]!==h?(P=!m&&n.jsx(Ue.Tabs,{children:n.jsx(v5,{virtualMcpId:h,taskId:w.taskId})}),t[74]=m,t[75]=w.taskId,t[76]=h,t[77]=P):P=t[77];const O=_?.metadata?.vmMap;let $;t[78]!==_||t[79]!==m?($=!m&&n.jsx(T5,{virtualMcp:_}),t[78]=_,t[79]=m,t[80]=$):$=t[80];let z;t[81]!==w.createNewTask?(z=n.jsx(Nh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[81]=w.createNewTask,t[82]=z):z=t[82];const W=m?"home":void 0;let F;t[83]!==W?(F=n.jsx(jh,{variant:W}),t[83]=W,t[84]=F):F=t[84];let K;t[85]!==w.chatOpen||t[86]!==w.mainOpen||t[87]!==w.taskId||t[88]!==F||t[89]!==h?(K=n.jsx(h5,{virtualMcpId:h,taskId:w.taskId,chatOpen:w.chatOpen,mainOpen:w.mainOpen,chatContent:F}),t[85]=w.chatOpen,t[86]=w.mainOpen,t[87]=w.taskId,t[88]=F,t[89]=h,t[90]=K):K=t[90];let H;t[91]!==C||t[92]!==O||t[93]!==$||t[94]!==z||t[95]!==K||t[96]!==h?(H=n.jsxs(Ah,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:O,children:[$,z,K]}),t[91]=C,t[92]=O,t[93]=$,t[94]=z,t[95]=K,t[96]=h,t[97]=H):H=t[97];let U;t[98]!==N||t[99]!==P||t[100]!==H?(U=n.jsxs(Oe.Provider,{virtualMcpId:N,children:[P,H]},N),t[98]=N,t[99]=P,t[100]=H,t[101]=U):U=t[101];let Y;return t[102]!==M||t[103]!==D||t[104]!==U?(Y=n.jsxs(Di,{value:M,children:[D,U]}),t[102]=M,t[103]=D,t[104]=U,t[105]=Y):Y=t[105],Y}function AN(){const t=B.c(5),e=Ms();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ew,{}),t[1]=i):i=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r={background:"transparent",containerType:"inline-size"},t[2]=r):r=t[2];let o;return t[3]!==e?(o=n.jsx(R_,{defaultOpen:!1,children:n.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:n.jsxs(T_,{className:"flex-1 bg-sidebar",style:s,children:[i,n.jsx(D_,{className:"flex flex-col",style:r,children:e?n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Eh,{})}):n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(cw,{children:n.jsxs(Ue,{children:[n.jsxs(Ue.Header,{children:[n.jsxs(Ue.LeftColumn,{children:[n.jsx(Ue.Nav,{}),n.jsx(Ue.TogglesSlot,{})]}),n.jsx(Ue.CenterSlot,{}),n.jsxs(Ue.RightColumn,{children:[n.jsx(Ue.TabsSlot,{}),n.jsx(Ue.RightSlot,{})]})]}),n.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[n.jsx(Nw,{}),n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Eh,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{AN as default,mc as useInsetContext};
|
|
739
|
+
</message>`}]}}))},L=e.models?.credentialId||m||"",D=e.models?.thinking?.id||p?.modelId||"",P=qi({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:D}}),O=P.watch("active"),$=P.watch("credential_id"),z=P.watch("model_id"),{models:W,isLoading:F}=uu($||void 0),K=W.find(ae=>ae.modelId===z)??null,H=S.useRef(null),U=S.useRef(new Set),Y=S.useRef(0),q=S.useRef(null),G=3e4,ee=()=>{q.current&&(clearTimeout(q.current),q.current=null),H.current!==null&&(ie("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(U.current),save_count:Y.current,edit_duration_ms:Date.now()-H.current}),H.current=null,U.current=new Set,Y.current=0)},Z=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!E.current)return!0;const he=Object.keys(P.formState.dirtyFields),pe=E.current;E.current=!1;const me=P.getValues();try{const we=me.credential_id&&me.model_id?me.credential_id:"",ve=me.credential_id&&me.model_id?me.model_id:"",de={id:t,name:me.name,active:me.active,agent:{id:o},models:{credentialId:we,thinking:{id:ve}},messages:Bh(b),temperature:0};await l.mutateAsync(de),H.current===null&&(H.current=Date.now());for(const Re of he)U.current.add(Re);return pe&&U.current.add("messages"),Y.current+=1,q.current&&clearTimeout(q.current),q.current=setTimeout(ee,G),P.reset({...me,credential_id:we,model_id:ve}),!0}catch{return E.current=!0,!1}},J=()=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{Z()},1e3)},se=async()=>(N.current&&clearTimeout(N.current),Z()),ne=ae=>{if(y(ae),!A.current){A.current=!0;return}E.current=!0,J()},ce=S.useRef(!1);ce.current||(ce.current=!0,P.watch(()=>{J()}));const xe=async()=>{ie("automation_test_clicked",{automation_id:t,agent_id:o});const ae=await se();if(ee(),!ae)return;if(!b){fe.error("No instructions configured for this automation");return}K&&$&&f({...K,keyId:$}),v({..._,toolApprovalLevel:"auto"});const he=gc(b);h({message:{tiptapDoc:b,parts:he},virtualMcpId:o||void 0})};return n.jsxs(n.Fragment,{children:[i&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(oe,{variant:"ghost",size:"sm",onClick:i,children:[n.jsx(kl,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(gt,{...P.register("name"),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"}}),r&&n.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:r,children:n.jsx(xa,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ri,{control:P.control,name:"active",render:({field:ae})=>n.jsx(Hr,{checked:ae.value,onCheckedChange:he=>{ae.onChange(he),setTimeout(()=>se(),0)},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(K_,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(Xj,{automationId:t,open:C,onOpenChange:k,onCustomSelect:()=>{V(!0),I(!1),R("")},onEventSelect:()=>{I(!0),V(!1)}})]}),e.triggers.length===0&&!w?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>k(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ae=>n.jsx(Jj,{trigger:ae,automationId:t,connectionName:ae.connection_id?u.get(ae.connection_id):void 0},ae.id))}),w&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(Sn,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:j,onChange:ae=>R(ae.target.value),onBlur:async()=>{const ae=j.trim();if(!(!ae||!An(ae)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:ae}),ie("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),fe.success("Starter added"),V(!1),R("")}catch{fe.error("Failed to add starter")}},onKeyDown:async ae=>{const he=j.trim();ae.key==="Enter"&&he&&An(he)&&ae.target.blur(),ae.key==="Escape"&&(V(!1),R(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!An(j)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&n.jsx(De,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.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:()=>{V(!1),R("")},children:n.jsx(ri,{size:13})})]}),T&&n.jsx(S.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(De,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Zj,{automationId:t,onDone:()=>I(!1)})})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!b,onClick:M,children:[n.jsx(Cl,{size:13}),"Improve"]})]}),n.jsx(tf,{tiptapDoc:b,setTiptapDoc:ne,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(sf,{virtualMcpId:o||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(mu,{model:K,isLoading:F,credentialId:$||null,onCredentialChange:ae=>{P.setValue("credential_id",ae??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:ae=>P.setValue("model_id",ae.modelId,{shouldDirty:!0}),placeholder:"Model"}),n.jsxs(nt,{children:[n.jsx(st,{asChild:!0,children:n.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:xe,disabled:!o,children:[n.jsx(Zh,{size:16}),"Test"]})}),n.jsx(it,{children:"Test Automation"})]})]})]})})]})]})]})}function n5(t){const e=B.c(6),{tabId:s,virtualMcpId:i}=t;let r;e[0]!==s?(r=$h(s),e[0]=s,e[1]=r):r=e[1];const o=r;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=n.jsx(ps,{children:n.jsx(ps.Content,{children:n.jsx(ps.Body,{children:n.jsx(S.Suspense,{fallback:a,children:n.jsx(r5,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function r5(t){const e=B.c(9),{id:s,virtualMcpId:i}=t,r=qe(),{data:o,isLoading:a}=G_(s);let l;e[0]!==r?(l=()=>r({to:".",search:o5,replace:!0}),e[0]=r,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=n.jsx(i5,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function o5(t){return{...t,main:"automations"}}function a5(t){const e=B.c(19),{virtualMcpId:s}=t,i=qe(),{data:r}=Y_(s),o=r===void 0?[]:r,{create:a}=er(),[l,c]=S.useState(""),d=l.toLowerCase(),u=o.filter(j=>j.name.toLowerCase().includes(d));let h;e[0]!==i?(h=j=>i({to:".",search:R=>({...R,main:"automation:"+j}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const f=h,m=async()=>{if(a.isPending)return;ie("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const j=await a.mutateAsync(J_(s));f(j.id)},p=ps,g=ps,_=ps;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Qt,{size:14}),e[2]=v):v=e[2];let x;e[3]!==a.isPending||e[4]!==m?(x=n.jsx(ps.Title,{actions:n.jsxs(oe,{size:"sm",onClick:m,disabled:a.isPending,children:[v,"New automation"]}),children:"Automations"}),e[3]=a.isPending,e[4]=m,e[5]=x):x=e[5];const b=o.length>0&&n.jsx(Q_,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[6]!==x||e[7]!==b?(y=n.jsxs("div",{className:"flex flex-col gap-6",children:[x,b]}),e[6]=x,e[7]=b,e[8]=y):y=e[8];const C=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Fi,{image:n.jsx(Ui,{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:n.jsxs(oe,{size:"sm",onClick:m,disabled:a.isPending,children:[n.jsx(Qt,{size:14}),"New automation"]})})}):u.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Fi,{image:n.jsx(Ui,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(j=>n.jsx(X_,{automation:j,onClick:()=>f(j.id)},j.id))});let k;e[9]!==_.Body||e[10]!==y||e[11]!==C?(k=n.jsxs(_.Body,{children:[y,C]}),e[9]=_.Body,e[10]=y,e[11]=C,e[12]=k):k=e[12];let w;e[13]!==k||e[14]!==g.Content?(w=n.jsx(g.Content,{children:k}),e[13]=k,e[14]=g.Content,e[15]=w):w=e[15];let V;return e[16]!==p||e[17]!==w?(V=n.jsx(p,{children:w}),e[16]=p,e[17]=w,e[18]=V):V=e[18],V}function l5(t){const e=B.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(S.Suspense,{fallback:i,children:n.jsx(a5,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Vh=S.lazy(()=>Op(()=>import("./project-app-view-CWfRTdtF.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])).then(t=>({default:t.AppViewContent})));function c5(t){const e=B.c(35),{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:o,layoutTabs:a,automationTabParsed:l}=Zf(r);if(og(o)){let m;return e[3]!==i?(m=n.jsx(jd,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(o==="git"){let m;return e[5]!==i?(m=n.jsx(YV,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(o==="automations"){let m;return e[7]!==i?(m=n.jsx(l5,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(o==="env"){let m;return e[9]!==i?(m=n.jsx(Hj,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(o==="preview"){let m;return e[11]!==i?(m=n.jsx(kC,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(l){let m;return e[13]!==o||e[14]!==i?(m=n.jsx(n5,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=m):m=e[15],m}let c;e[16]!==o?(c=ag(o),e[16]=o,e[17]=c):c=e[17];const d=c;if(d){let m;e[18]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[18]=m):m=e[18];let p;return e[19]!==o||e[20]!==d.connectionId||e[21]!==d.toolName?(p=n.jsx(S.Suspense,{fallback:m,children:n.jsx(Vh,{connectionId:d.connectionId,toolName:d.toolName},o)}),e[19]=o,e[20]=d.connectionId,e[21]=d.toolName,e[22]=p):p=e[22],p}let u;if(e[23]!==o||e[24]!==a){let m;e[26]!==o?(m=p=>p.id===o,e[26]=o,e[27]=m):m=e[27],u=a.find(m),e[23]=o,e[24]=a,e[25]=u}else u=e[25];const h=u;if(h){let m;e[28]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=m):m=e[28];let p;return e[29]!==o||e[30]!==h.id||e[31]!==h.view.appId?(p=n.jsx(S.Suspense,{fallback:m,children:n.jsx(Vh,{connectionId:h.view.appId,toolName:h.id},o)}),e[29]=o,e[30]=h.id,e[31]=h.view.appId,e[32]=p):p=e[32],p}let f;return e[33]!==i?(f=n.jsx(jd,{virtualMcpId:i}),e[33]=i,e[34]=f):f=e[34],f}function d5(t){const e=B.c(7),{children:s,defaultSize:i}=t,[,r]=S.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=pl.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=ml(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=n.jsx(pu,{defaultSize:c,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]=c,e[5]=u,e[6]=h):h=e[6],h}function h5(t){const e=B.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==r||e[1]!==o?(c=Sd(r,o),e[0]=r,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=pl.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=ml(u,45),f=S.useRef(null);let m,p;e[4]!==r||e[5]!==o||e[6]!==h?(m=()=>{const T=f.current;if(!T)return;const I=Sd(r,o),A=I.chat>0&&I.chat<100?h:I.chat,N=I.chat>0&&I.chat<100?100-h:I.main;T.setLayout([A,N])},p=[r,o,h],e[4]=r,e[5]=o,e[6]=h,e[7]=m,e[8]=p):(m=e[7],p=e[8]),S.useEffect(m,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let v;e[10]!==l||e[11]!==a?(v=l??n.jsx(of,{variant:a}),e[10]=l,e[11]=a,e[12]=v):v=e[12];let x;e[13]!==v?(x=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[13]=v,e[14]=x):x=e[14];let b;e[15]!==d.chat||e[16]!==x?(b=n.jsx(d5,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=b):b=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(r_,{className:"bg-sidebar"}),e[18]=y):y=e[18];const C=d.main;let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k={overflow:"visible"},e[19]=k):k=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=X("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[20]=w):w=e[20];let V;e[21]!==i||e[22]!==s?(V=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:w,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(c5,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=V):V=e[23];let j;e[24]!==d.main||e[25]!==V?(j=n.jsx(pu,{className:"min-w-0 flex flex-col",order:2,defaultSize:C,style:k,collapsible:!0,collapsedSize:0,minSize:20,children:V}),e[24]=d.main,e[25]=V,e[26]=j):j=e[26];let R;return e[27]!==j||e[28]!==g||e[29]!==b?(R=n.jsxs(o_,{ref:f,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[b,y,j]},g),e[27]=j,e[28]=g,e[29]=b,e[30]=R):R=e[30],R}const ca="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Ch="bg-sidebar-accent text-sidebar-foreground",da="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function u5(t){const e=B.c(38),{isDecopilot:s,chatOpen:i,toggleChat:r,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=Jf(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{ie("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?Ch:da;let h;e[3]!==u?(h=X(ca,u),e[3]=u,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx($g,{size:16}),e[5]=f):f=e[5];let m;e[6]!==d||e[7]!==h||e[8]!==a?(m=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:f})}),e[6]=d,e[7]=h,e[8]=a,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(it,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==m?(g=n.jsxs(nt,{delayDuration:300,children:[m,p]}),e[11]=m,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==r?(_=!s&&n.jsxs(nt,{delayDuration:300,children:[n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>{ie("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),r()},"aria-pressed":i,className:X(ca,i?Ch:da),children:n.jsx(zg,{size:16})})}),n.jsx(it,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=r,e[16]=_):_=e[16];const v=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==v?(x=X("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",v),e[17]=v,e[18]=x):x=e[18];const b=!c,y=c?0:-1,C=!c,k=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let w;e[19]!==k?(w=X(ca,da,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",k),e[19]=k,e[20]=w):w=e[20];let V;e[21]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(wl,{size:16}),e[21]=V):V=e[21];let j;e[22]!==o||e[23]!==b||e[24]!==y||e[25]!==C||e[26]!==w?(j=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,disabled:b,tabIndex:y,"aria-hidden":C,className:w,children:V})}),e[22]=o,e[23]=b,e[24]=y,e[25]=C,e[26]=w,e[27]=j):j=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(it,{side:"bottom",children:"New task"}),e[28]=R):R=e[28];let T;e[29]!==j?(T=n.jsx("div",{className:"overflow-hidden",children:n.jsxs(nt,{delayDuration:300,children:[j,R]})}),e[29]=j,e[30]=T):T=e[30];let I;e[31]!==x||e[32]!==T?(I=n.jsx("div",{className:x,children:T}),e[31]=x,e[32]=T,e[33]=I):I=e[33];let A;return e[34]!==I||e[35]!==g||e[36]!==_?(A=n.jsxs(n.Fragment,{children:[g,_,I]}),e[34]=I,e[35]=g,e[36]=_,e[37]=A):A=e[37],A}function f5(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(h=>h.id===e))return{visible:i,overflow:r};const a=r.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],c=r[a],d=[...i.slice(0,-1),c],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:d,overflow:u}}function m5(t){const e=B.c(13),{title:s,icon:i,active:r,onClick:o}=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=X("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 c;e[2]!==i?(c=n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(p5,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=n.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==r||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=n.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,"aria-label":s,className:l,children:[c,d]}),e[6]=r,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function p5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.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=n.jsx(ou,{className:"size-4"}),e[4]=i):i=e[4],i}function g5(t){const e=B.c(13),{overflow:s,onSelect:i}=t,[r,o]=S.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(li,{asChild:!0,children:n.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:n.jsx(iu,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(_5,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=n.jsx(ci,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==r||e[11]!==u?(h=n.jsxs(di,{open:r,onOpenChange:o,children:[c,u]}),e[10]=r,e[11]=u,e[12]=h):h=e[12],h}function _5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.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=n.jsx(ou,{className:"size-4"}),e[4]=i):i=e[4],i}const x5=6;function v5(t){const e=B.c(20),{virtualMcpId:s,taskId:i}=t,r=qe();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=Zf(o);let u,h,f,m;if(e[3]!==l||e[4]!==c||e[5]!==r||e[6]!==d||e[7]!==a||e[8]!==s){const _=lg({activeTab:l,mainOpen:c}),v=k=>k.id==="automations"?_:c&&k.id===l,b=a.find(k=>v(k))?.id??null,{visible:y,overflow:C}=f5(a,b,x5);h=C,u=k=>{const w=a.find(j=>j.id===k),V=b===k&&c;if(ie("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:w?.kind??null,was_active:V}),k==="automations"){const j=cg({activeTab:l,mainOpen:c});r({to:".",search:R=>({...R,main:j}),replace:!0});return}d(k)},f="flex items-center min-w-0 ml-auto gap-0.5",m=y.map(k=>n.jsx(m5,{title:k.title,icon:k.icon,active:v(k),onClick:()=>u(k.id)},k.id)),e[3]=l,e[4]=c,e[5]=r,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=f,e[12]=m}else u=e[9],h=e[10],f=e[11],m=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&n.jsx(g5,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=n.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}function b5(t){const e=B.c(12);let s,i,r,o;e[0]!==t?({className:s,orientation:r,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=o):(s=e[1],i=e[2],r=e[3],o=e[4]);const a=r===void 0?"horizontal":r,l=o===void 0?!0:o;let c;e[5]!==s?(c=X("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]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=n.jsx(Bp,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function y5(t){const e=B.c(20),{prNumber:s,disabled:i,send:r}=t;let o;e[0]!==s||e[1]!==r?(o=()=>r(OV({prNumber:s})),e[0]=s,e[1]=r,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==r?(l=()=>r(LV({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=n.jsx(oe,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Rn,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=n.jsx(Es,{asChild:!0,children:n.jsx(oe,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let f;e[12]!==c?(f=n.jsx(Is,{align:"end",children:n.jsx(at,{onClick:c,children:"Review"})}),e[12]=c,e[13]=f):f=e[13];let m;e[14]!==h||e[15]!==f?(m=n.jsxs(As,{children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,m]}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}const S5=new Set(["failure","timed_out","cancelled","action_required"]);function w5(t){return t.status==="completed"&&S5.has(t.conclusion)}function V5(t){return t.status==="queued"||t.status==="in_progress"}function C5(t){const{branchStatus:e,pr:s,checks:i,reviews:r}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(w5).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(V5)?{label:"Running tests…",disabled:!0}:r?.draft?{label:"Mark ready",action:"mark-ready"}:(r?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function k5(){return Qi().branchStatus}const j5=6e4,N5=3e4;function A5(t){const e=B.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Le(s),r=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:j5,refetchIntervalInBackground:!1,staleTime:N5,select:E5},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],ki(l)}function E5(t){const e=nr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),o=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function I5(t){const e=B.c(38),{virtualMcpId:s}=t,{org:i}=ye(),r=is(s),{currentBranch:o}=es(),a=ro(),l=r?.metadata?.githubRepo??null,c=k5(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",f=o??null;let m;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==f?(m={orgId:i.id,connectionId:d,owner:u,repo:h,branch:f},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=f,e[5]=m):m=e[5];const g=tm(m).data??null,_=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",b=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==v||e[9]!==x||e[10]!==b?(y={orgId:i.id,connectionId:_,owner:v,repo:x,prNumber:b},e[6]=i.id,e[7]=_,e[8]=v,e[9]=x,e[10]=b,e[11]=y):y=e[11];const C=im(y),k=l?.connectionId??"",w=l?.owner??"",V=l?.name??"",j=g&&g.state==="open"?g.number:null;let R;e[12]!==i.id||e[13]!==k||e[14]!==w||e[15]!==V||e[16]!==j?(R={orgId:i.id,connectionId:k,owner:w,repo:V,prNumber:j},e[12]=i.id,e[13]=k,e[14]=w,e[15]=V,e[16]=j,e[17]=R):R=e[17];const T=A5(R);if(!l?.connectionId||!o)return null;let I;e[18]!==c||e[19]!==C.data||e[20]!==g||e[21]!==T.data?(I=C5({branchStatus:c,pr:g,checks:C.data??[],reviews:T.data??null}),e[18]=c,e[19]=C.data,e[20]=g,e[21]=T.data,e[22]=I):I=e[22];const A=I;if(!A)return null;let N;e[23]!==a?(N=z=>a.sendMessage({parts:[{type:"text",text:z}]}),e[23]=a,e[24]=N):N=e[24];const E=N,M=a.isStreaming;let L;e[25]!==o||e[26]!==A||e[27]!==M||e[28]!==g||e[29]!==E?(L=z=>{if(!M)switch(z){case"commit-and-push":{E(AV({branch:o}));return}case"create-pr":{E(EV({branch:o}));return}case"reopen":{g&&E(IV({prNumber:g.number}));return}case"rebase":{E(RV({branch:o}));return}case"fix-checks":{g&&E(DV({prNumber:g.number,failingChecks:A.meta?.failingChecks??[]}));return}case"mark-ready":{g&&E(MV({prNumber:g.number}));return}case"resolve-comments":{g&&E(PV({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=A,e[27]=M,e[28]=g,e[29]=E,e[30]=L):L=e[30];const D=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(b5,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const O=g?.number;let $;return e[32]!==A||e[33]!==M||e[34]!==D||e[35]!==E||e[36]!==O?($=n.jsxs(n.Fragment,{children:[P,n.jsx(R5,{button:A,isStreaming:M,onActivate:D,prNumber:O,send:E})]}),e[32]=A,e[33]=M,e[34]=D,e[35]=E,e[36]=O,e[37]=$):$=e[37],$}function R5(t){const e=B.c(18),{button:s,isStreaming:i}=t,r=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=n.jsx(y5,{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 h;return e[4]!==u||e[5]!==o?(h=n.jsx(kh,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==r||e[12]!==a||e[13]!==l?(c=n.jsx(oe,{size:"sm",variant:a,disabled:r,onClick:l,children:s.label}),e[10]=s.label,e[11]=r,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=n.jsx(kh,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function kh(t){const e=B.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=n.jsx(n.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=n.jsx(st,{asChild:!0,children:n.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=n.jsx(it,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(Oi,{children:n.jsxs(nt,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function T5(t){const e=B.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=n.jsx(Ue.Right,{children:n.jsx(I5,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const Di=S.createContext(null);function mc(){return S.use(Di)}function jh(t){const e=B.c(8),{children:s,variant:i}=t,{taskId:r}=es();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.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]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Oe.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??n.jsx(of,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==r?(c=n.jsx(Ns,{fallback:o,children:n.jsx(S.Suspense,{fallback:a,children:n.jsx(Oe.ActiveTaskProvider,{taskId:r,children:l})})}),e[5]=l,e[6]=r,e[7]=c):c=e[7],c}function Nh(t){const e=B.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],S.useLayoutEffect(r),null}function D5(t){const e=B.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Hg,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:n.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 Ah(t){const e=B.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:o}=t,{org:a}=ye(),{currentBranch:l}=es(),{data:c}=St.useSession(),d=c?.user?.id,u=d&&l?r?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const f=h;let m;e[2]!==a.id?(m={connectionId:Pt,orgId:a.id},e[2]=a.id,e[3]=m):m=e[3];const p=Le(m),{mutate:g}=ec(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const v=S.useRef(_);let x,b;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==r?(x=()=>{i&&d&&l&&(r?.[d]?.[l]||v.current.has(l)||(v.current.add(l),g({virtualMcpId:s,branch:l},{onError:M5})))},b=[i,d,l,r,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=r,e[11]=x,e[12]=b):(x=e[11],b=e[12]),S.useEffect(x,b);let y;return e[13]!==o||e[14]!==f?(y=n.jsx(dC,{daemonBaseUrl:f,children:o}),e[13]=o,e[14]=f,e[15]=y):y=e[15],y}function M5(t){console.error("[auto-start-vm] failed:",t)}function Eh(){const t=B.c(106),e=Ms(),s=qe(),{org:i}=ye(),r=hw()?.tasksOpen??!1;$_(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=Hn(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=Si(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??ho(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let f;t[5]!==i.id?(f=vl(i.id),t[5]=i.id,t[6]=f):f=t[6];const m=h===f,p=!m,g=tx(a.taskId??"",h),_=is(h),v=_?.metadata?.ui?.layout??null;let x;t[7]!==v?(x=v?{defaultMainView:v.defaultMainView??null,chatDefaultOpen:v.chatDefaultOpen??null}:null,t[7]=v,t[8]=x):x=t[8];const b=x;let y;t[9]!==_?(y=_&&Fs(_),t[9]=_,t[10]=y):y=t[10];const C=!!y;let k;t[11]!==p||t[12]!==l||t[13]!==h?(k={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=k):k=t[14];const w=lw(b,k),{setOpenMobile:V,openMobile:j}=Qn(),R=V,T=S.useRef(null);let I,A;t[15]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const q=G=>{Kh(G)&&G.shiftKey&&G.code==="KeyS"&&!G.repeat&&(G.preventDefault(),T.current?.())};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},A=[],t[15]=I,t[16]=A):(I=t[15],A=t[16]),S.useEffect(I,A);const N=h;let E;t[17]!==_||t[18]!==h?(E={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=E):E=t[19];const M=E;if(g.status==="creating"||g.status==="loading"){let q;t[20]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[n.jsx(De,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=q):q=t[20];let G;return t[21]!==M?(G=n.jsx(Di,{value:M,children:q}),t[21]=M,t[22]=G):G=t[22],G}if(g.status==="error"){let q;t[23]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=q):q=t[23];let G;t[24]!==g.error.message?(G=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.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:[q,n.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=G):G=t[25];let ee;return t[26]!==M||t[27]!==G?(ee=n.jsx(Di,{value:M,children:G}),t[26]=M,t[27]=G,t[28]=ee):ee=t[28],ee}if(!_){let q;t[29]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(oi,{size:48,className:"text-muted-foreground"}),t[29]=q):q=t[29];const G=`The agent "${h}" does not exist in this organization.`;let ee;t[30]!==s||t[31]!==l?(ee=n.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=ee):ee=t[32];let Z;t[33]!==G||t[34]!==ee?(Z=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:n.jsx(Fi,{image:q,title:"Agent not found",description:G,actions:ee})})}),t[33]=G,t[34]=ee,t[35]=Z):Z=t[35];let J;return t[36]!==M||t[37]!==Z?(J=n.jsx(Di,{value:M,children:Z}),t[36]=M,t[37]=Z,t[38]=J):J=t[38],J}if(e){let q;t[39]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(M_,{className:"sr-only",children:"Navigation"}),t[39]=q):q=t[39];let G;t[40]!==R?(G=n.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:n.jsx(tw,{onClose:()=>R(!1)})}),t[40]=R,t[41]=G):G=t[41];let ee;t[42]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:n.jsx(cf,{})}),t[42]=ee):ee=t[42];let Z;t[43]!==G?(Z=n.jsxs(P_,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[q,n.jsxs("div",{className:"flex h-full",children:[G,ee]})]}),t[43]=G,t[44]=Z):Z=t[44];let J;t[45]!==j||t[46]!==R||t[47]!==Z?(J=n.jsx(L_,{open:j,onOpenChange:R,children:Z}),t[45]=j,t[46]=R,t[47]=Z,t[48]=J):J=t[48];const se=J,ne=_?.metadata?.vmMap;let ce;t[49]!==w.createNewTask?(ce=n.jsx(Nh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[49]=w.createNewTask,t[50]=ce):ce=t[50];let xe;t[51]!==R?(xe=n.jsx(D5,{onOpenSidebar:()=>R(!0)}),t[51]=R,t[52]=xe):xe=t[52];const ae=m?"home":void 0;let he;t[53]!==ae?(he=n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(jh,{variant:ae})}),t[53]=ae,t[54]=he):he=t[54];let pe;t[55]!==C||t[56]!==se||t[57]!==ne||t[58]!==ce||t[59]!==xe||t[60]!==he||t[61]!==h?(pe=n.jsxs(Ah,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:ne,children:[ce,xe,he,se]}),t[55]=C,t[56]=se,t[57]=ne,t[58]=ce,t[59]=xe,t[60]=he,t[61]=h,t[62]=pe):pe=t[62];let me;t[63]!==N||t[64]!==pe?(me=n.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:n.jsx(Oe.Provider,{virtualMcpId:N,children:pe},N)}),t[63]=N,t[64]=pe,t[65]=me):me=t[65];let we;return t[66]!==M||t[67]!==me?(we=n.jsx(Di,{value:M,children:me}),t[66]=M,t[67]=me,t[68]=we):we=t[68],we}const L=r?void 0:w.createNewTask;let D;t[69]!==m||t[70]!==w.chatOpen||t[71]!==w.toggleChat||t[72]!==L?(D=n.jsx(Ue.Toggles,{children:n.jsx(u5,{isDecopilot:m,chatOpen:w.chatOpen,toggleChat:w.toggleChat,onNewTask:L})}),t[69]=m,t[70]=w.chatOpen,t[71]=w.toggleChat,t[72]=L,t[73]=D):D=t[73];let P;t[74]!==m||t[75]!==w.taskId||t[76]!==h?(P=!m&&n.jsx(Ue.Tabs,{children:n.jsx(v5,{virtualMcpId:h,taskId:w.taskId})}),t[74]=m,t[75]=w.taskId,t[76]=h,t[77]=P):P=t[77];const O=_?.metadata?.vmMap;let $;t[78]!==_||t[79]!==m?($=!m&&n.jsx(T5,{virtualMcp:_}),t[78]=_,t[79]=m,t[80]=$):$=t[80];let z;t[81]!==w.createNewTask?(z=n.jsx(Nh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[81]=w.createNewTask,t[82]=z):z=t[82];const W=m?"home":void 0;let F;t[83]!==W?(F=n.jsx(jh,{variant:W}),t[83]=W,t[84]=F):F=t[84];let K;t[85]!==w.chatOpen||t[86]!==w.mainOpen||t[87]!==w.taskId||t[88]!==F||t[89]!==h?(K=n.jsx(h5,{virtualMcpId:h,taskId:w.taskId,chatOpen:w.chatOpen,mainOpen:w.mainOpen,chatContent:F}),t[85]=w.chatOpen,t[86]=w.mainOpen,t[87]=w.taskId,t[88]=F,t[89]=h,t[90]=K):K=t[90];let H;t[91]!==C||t[92]!==O||t[93]!==$||t[94]!==z||t[95]!==K||t[96]!==h?(H=n.jsxs(Ah,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:O,children:[$,z,K]}),t[91]=C,t[92]=O,t[93]=$,t[94]=z,t[95]=K,t[96]=h,t[97]=H):H=t[97];let U;t[98]!==N||t[99]!==P||t[100]!==H?(U=n.jsxs(Oe.Provider,{virtualMcpId:N,children:[P,H]},N),t[98]=N,t[99]=P,t[100]=H,t[101]=U):U=t[101];let Y;return t[102]!==M||t[103]!==D||t[104]!==U?(Y=n.jsxs(Di,{value:M,children:[D,U]}),t[102]=M,t[103]=D,t[104]=U,t[105]=Y):Y=t[105],Y}function AN(){const t=B.c(5),e=Ms();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ew,{}),t[1]=i):i=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r={background:"transparent",containerType:"inline-size"},t[2]=r):r=t[2];let o;return t[3]!==e?(o=n.jsx(R_,{defaultOpen:!1,children:n.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:n.jsxs(T_,{className:"flex-1 bg-sidebar",style:s,children:[i,n.jsx(D_,{className:"flex flex-col",style:r,children:e?n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Eh,{})}):n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(cw,{children:n.jsxs(Ue,{children:[n.jsxs(Ue.Header,{children:[n.jsxs(Ue.LeftColumn,{children:[n.jsx(Ue.Nav,{}),n.jsx(Ue.TogglesSlot,{})]}),n.jsx(Ue.CenterSlot,{}),n.jsxs(Ue.RightColumn,{children:[n.jsx(Ue.TabsSlot,{}),n.jsx(Ue.RightSlot,{})]})]}),n.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[n.jsx(Nw,{}),n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(De,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Eh,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{AN as default,mc as useInsetContext};
|