decocms 2.312.0 → 2.312.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-DgIbjZFP.js → AlertCircle-ERuf6aAv.js} +1 -1
- package/dist/client/assets/{Archive-C3oinC0s.js → Archive-CI9Epn9-.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-VswvJrav.js → ArrowNarrowLeft-BKXifKxP.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-pHL6O-19.js → ArrowUpRight-BVXRPr5x.js} +1 -1
- package/dist/client/assets/{Check-aa9K7ozq.js → Check-Dw-NNjqo.js} +1 -1
- package/dist/client/assets/{CheckCircle-D3x4CQc4.js → CheckCircle-DDlK7D0f.js} +1 -1
- package/dist/client/assets/{ChevronDown-COohyJel.js → ChevronDown-CKzufdMF.js} +1 -1
- package/dist/client/assets/{ChevronRight-BkYTpADa.js → ChevronRight-DHugiPa5.js} +1 -1
- package/dist/client/assets/{ChevronUp-CvIufmOE.js → ChevronUp-ftnK3X6N.js} +1 -1
- package/dist/client/assets/{Container-BwxK1zsB.js → Container-CBjPTaAm.js} +1 -1
- package/dist/client/assets/{DotsVertical-DmOpiu7I.js → DotsVertical-2sZM-_B-.js} +1 -1
- package/dist/client/assets/{LayoutLeft-CqVDbbUj.js → LayoutLeft-DbGS7aH0.js} +1 -1
- package/dist/client/assets/{LinkExternal01-D3EwQo2i.js → LinkExternal01-BB8PEfNz.js} +1 -1
- package/dist/client/assets/{Lock01-3Z5YegUt.js → Lock01-BtdrYKDm.js} +1 -1
- package/dist/client/assets/{Palette-BmNvJ0d9.js → Palette-CBvID2VE.js} +1 -1
- package/dist/client/assets/{Play-C-f37c5A.js → Play-2WAveRPh.js} +1 -1
- package/dist/client/assets/{Plus-DY7vA0mY.js → Plus-D0grveYD.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-D3efDqWQ.js → RefreshCcw01-BF_TovZP.js} +1 -1
- package/dist/client/assets/{SearchMd-BP8uZLZv.js → SearchMd-9Lp0KuHW.js} +1 -1
- package/dist/client/assets/{Settings02-CoMmXn-C.js → Settings02-kS8gRV3C.js} +1 -1
- package/dist/client/assets/{Shield01-C7wSpsYO.js → Shield01-BT26kZxz.js} +1 -1
- package/dist/client/assets/{Star01-C6jUiq1l.js → Star01-r_zmzcnE.js} +1 -1
- package/dist/client/assets/{Sun-Dp0B2a5M.js → Sun-CqquG-7-.js} +1 -1
- package/dist/client/assets/{Tool01-DLlBXWXE.js → Tool01-CZrEw9GG.js} +1 -1
- package/dist/client/assets/{Trash01-Bm2xp20o.js → Trash01-BfewA6Ab.js} +1 -1
- package/dist/client/assets/{User01-DRdPMx3w.js → User01-DB87Ecsr.js} +1 -1
- package/dist/client/assets/{Users03-BL_5hYu_.js → Users03-BgtpPlOT.js} +1 -1
- package/dist/client/assets/{X-BEU0MHUr.js → X-MkRobXsq.js} +1 -1
- package/dist/client/assets/{XCircle-J7xeYsqG.js → XCircle-BLjPn4jt.js} +1 -1
- package/dist/client/assets/{XClose-Ds1dTxMH.js → XClose-Cr0_UGK3.js} +1 -1
- package/dist/client/assets/{Zap-B4-wkcyX.js → Zap-DRgyzoAR.js} +1 -1
- package/dist/client/assets/{ZapSquare-Br7mI2dC.js → ZapSquare-5AS1CTub.js} +1 -1
- package/dist/client/assets/{accordion-C6T2-sSh.js → accordion-Vcv9vx8b.js} +1 -1
- package/dist/client/assets/{agent-icon-B5Lepjyg.js → agent-icon-CHawCeGj.js} +1 -1
- package/dist/client/assets/{agents-list-BxHllP9U.js → agents-list-Bp1nGcHn.js} +1 -1
- package/dist/client/assets/{ai-providers-d9GuTz8R.js → ai-providers-B9DIEKIu.js} +1 -1
- package/dist/client/assets/{alert-dialog-BCbgR3di.js → alert-dialog-BrfyOA8d.js} +1 -1
- package/dist/client/assets/{auth-catchall-MxSymLX3.js → auth-catchall-2HftXMlZ.js} +1 -1
- package/dist/client/assets/{automation-list-row-BWnR0Wjj.js → automation-list-row-eIHh56lV.js} +1 -1
- package/dist/client/assets/{automations-Bz7nADNi.js → automations-41UlbdiX.js} +1 -1
- package/dist/client/assets/{avatar-B-WvEQQh.js → avatar-DFG27SpR.js} +1 -1
- package/dist/client/assets/{badge-CNmz6zWn.js → badge-CyXlfcBA.js} +1 -1
- package/dist/client/assets/{brand-context-8zg2xn8H.js → brand-context-Dy4Broqm.js} +1 -1
- package/dist/client/assets/{card-BYgw1vi2.js → card-b9f3cSc7.js} +1 -1
- package/dist/client/assets/{chat-context-aSv7zVBn.js → chat-context-CBEjrtlA.js} +1 -1
- package/dist/client/assets/{checkbox-C2spUlz3.js → checkbox-B-5dNGXU.js} +1 -1
- package/dist/client/assets/{collection-detail-B-dCse2_.js → collection-detail-60PTYGbo.js} +1 -1
- package/dist/client/assets/{collection-display-button-l-NTxSUK.js → collection-display-button-2Q1qlgg7.js} +1 -1
- package/dist/client/assets/{collection-search-BfemXUsr.js → collection-search-CF_YUmub.js} +1 -1
- package/dist/client/assets/{collection-search-D8_CBVzq.js → collection-search-CeOmn4VX.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-0n-5l4UJ.js → collection-table-wrapper-BCrWxTNq.js} +1 -1
- package/dist/client/assets/{collection-tabs-CqzKmYGm.js → collection-tabs-BzOEZ7_c.js} +1 -1
- package/dist/client/assets/{collections-Cuocn47g.js → collections-DfDlNVfw.js} +1 -1
- package/dist/client/assets/{command-BQRe_Fje.js → command-1vgVMo-o.js} +1 -1
- package/dist/client/assets/{connection-card-BAH-_mNT.js → connection-card-CWY5aJHR.js} +1 -1
- package/dist/client/assets/{connection-detail-DI72xr4q.js → connection-detail-J3WYkO2_.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-BZl_1Yqu.js → connection-form-helpers-V_S7kOM3.js} +1 -1
- package/dist/client/assets/{connections-DJhXDLUO.js → connections-Ci7EQIuw.js} +1 -1
- package/dist/client/assets/{constants-B0----Qm.js → constants-Bpr1SrBK.js} +1 -1
- package/dist/client/assets/{constants-CIP80jF-.js → constants-BxAwlKEt.js} +1 -1
- package/dist/client/assets/{dialog-C_RX-AQt.js → dialog-BFONggAc.js} +1 -1
- package/dist/client/assets/{domain-settings-DNYks8cr.js → domain-settings-DR2YXCNC.js} +1 -1
- package/dist/client/assets/{drawer-XcInLzwE.js → drawer-DPE2UfDW.js} +1 -1
- package/dist/client/assets/{dropdown-menu-5TLJbEBI.js → dropdown-menu-BdpYdHvo.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-DERb69N2.js → dynamic-plugin-layout-jhvTbKwm.js} +1 -1
- package/dist/client/assets/{empty-state-Cp10WCIm.js → empty-state-C8B-PY4B.js} +1 -1
- package/dist/client/assets/{empty-state-C2KaC_Qh.js → empty-state-Ds_81ifx.js} +1 -1
- package/dist/client/assets/{extract-connection-data-C288mPce.js → extract-connection-data-BbuEAUmV.js} +1 -1
- package/dist/client/assets/{features-DrzEH5fg.js → features-DhCStbTJ.js} +1 -1
- package/dist/client/assets/{form-0EbWbv9V.js → form-B8LulHdI.js} +1 -1
- package/dist/client/assets/{general-DBYHhZW6.js → general-bOTHD-QQ.js} +1 -1
- package/dist/client/assets/{index-CDPuXQh9.js → index-BHPgwaHi.js} +1 -1
- package/dist/client/assets/{index-C7cQ6LLR.js → index-BKHWKQ7T.js} +1 -1
- package/dist/client/assets/{index-uHvJMymL.js → index-Bix1l1uh.js} +1 -1
- package/dist/client/assets/{index-DisG42x6.js → index-C4_Nt78h.js} +1 -1
- package/dist/client/assets/{index-BZ56DfF3.js → index-CAJfUS9H.js} +3 -3
- package/dist/client/assets/{index-Cze3SONv.js → index-CVjB3eh1.js} +1 -1
- package/dist/client/assets/{index-Bt1fPbef.js → index-CaonkSAJ.js} +1 -1
- package/dist/client/assets/{index-xUCBR4Jh.js → index-CoMcjeGv.js} +2 -2
- package/dist/client/assets/{index-Cwjty6pU.js → index-DB-1u_Lp.js} +1 -1
- package/dist/client/assets/{index-URPAEU-i.js → index-DDhZDmpn.js} +1 -1
- package/dist/client/assets/{index-XNLf7Fjv.js → index-DVXn-o-d.js} +1 -1
- package/dist/client/assets/{index-HWD0WtFK.js → index-DZpCM_Ye.js} +1 -1
- package/dist/client/assets/{index-BYYBAht5.js → index-DcvDT1BH.js} +1 -1
- package/dist/client/assets/{index-CmsyCfFn.js → index-Du6DwcIl.js} +1 -1
- package/dist/client/assets/{index-DL0cg4Sy.js → index-_a3sfx9A.js} +2 -2
- package/dist/client/assets/{index-DDUrBgzN.js → index-tuSBNy7Z.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-DCVrd5pN.js → infiniteQueryObserver-CCfSTQJW.js} +1 -1
- package/dist/client/assets/{input-CCf4EPNk.js → input-CLyArZAZ.js} +1 -1
- package/dist/client/assets/{integration-icon-F29rJiGn.js → integration-icon-BHVwtvVd.js} +1 -1
- package/dist/client/assets/{label-BrmLejNm.js → label-DaQ778PR.js} +1 -1
- package/dist/client/assets/{layout-DVLgQZef.js → layout-36aJdu5h.js} +1 -1
- package/dist/client/assets/{lean-canvas-recruit-modal-51wnfw_w.js → lean-canvas-recruit-modal-Cp7w5Yzr.js} +1 -1
- package/dist/client/assets/{login-g5WUE_1m.js → login-DWlC4uSb.js} +1 -1
- package/dist/client/assets/{members-CjNcZZkJ.js → members-Dt2WHe5e.js} +1 -1
- package/dist/client/assets/{monaco-editor-B4gYKZgx.js → monaco-editor-BTpSpiaS.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-Ce8KaHuJ.js → monitoring-stats-row-5ybqv9s5.js} +1 -1
- package/dist/client/assets/{oauth-callback-Be7SkbaR.js → oauth-callback-6h8lqTVI.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-DGE3iQ3P.js → oauth-callback-ai-provider-sCU77ITv.js} +1 -1
- package/dist/client/assets/{onboarding-Dp8uaKFQ.js → onboarding-CYUS6d_c.js} +1 -1
- package/dist/client/assets/{org-layout-CbmnnWes.js → org-layout-Cjg2_QgT.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-OWKU4NF6.js → org-plugin-layout-gpAiuBtf.js} +1 -1
- package/dist/client/assets/{pair-CR5fdfUV.js → pair-Dfx2VDcu.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-BGGc2TrB.js → plugin-empty-state-CKebWDOa.js} +1 -1
- package/dist/client/assets/{plugin-header-CuM9tImh.js → plugin-header-BnX3_uiT.js} +1 -1
- package/dist/client/assets/{plugin-layout-BUbR1Rtp.js → plugin-layout-D9RO_KiG.js} +1 -1
- package/dist/client/assets/{popover-EwlTcjqV.js → popover-CjkpEiTE.js} +1 -1
- package/dist/client/assets/{profile-unqFgTVV.js → profile-DIAEi3Wh.js} +1 -1
- package/dist/client/assets/{project-app-view-BGEyiVSD.js → project-app-view-STAPzbR7.js} +1 -1
- package/dist/client/assets/registry--_J6xL4O.js +2 -0
- package/dist/client/assets/{registry-layout-BhuMc8jd.js → registry-layout-57KSjOXo.js} +1 -1
- package/dist/client/assets/{required-auth-layout-BF8p72H7.js → required-auth-layout-BThC9-U7.js} +1 -1
- package/dist/client/assets/{reset-password-BcpO6RRm.js → reset-password-B_VWu4fY.js} +1 -1
- package/dist/client/assets/{roles-vMp1SmX5.js → roles-BzMjZN1X.js} +1 -1
- package/dist/client/assets/{scroll-area-CELk3Mmw.js → scroll-area-fh9U9MHB.js} +1 -1
- package/dist/client/assets/{search-input-Dn4Pg53J.js → search-input-BQvqnxrN.js} +1 -1
- package/dist/client/assets/{select-BsEzdOFM.js → select-Wcqz-g0G.js} +1 -1
- package/dist/client/assets/{select-model-CMvi5mKv.js → select-model-DNKOCT1K.js} +1 -1
- package/dist/client/assets/{settings-layout-SPkXrn6W.js → settings-layout-CwUUNdaO.js} +1 -1
- package/dist/client/assets/{settings-section-B0IdECpp.js → settings-section-JVAjMEt8.js} +1 -1
- package/dist/client/assets/{shell-layout-D69vTgwv.js → shell-layout-Bz9lZQVY.js} +1 -1
- package/dist/client/assets/{sidebar-CEaAddWO.js → sidebar-DAeODPsL.js} +1 -1
- package/dist/client/assets/{skeleton-BydKNGdG.js → skeleton-BLclv8kT.js} +1 -1
- package/dist/client/assets/{spinner-CMg2UHyb.js → spinner-DnlGnBXF.js} +1 -1
- package/dist/client/assets/{sso-CU_2tH9M.js → sso-BrXmJ2I4.js} +1 -1
- package/dist/client/assets/{store-DmMo4dqP.js → store-DUXn21Np.js} +1 -1
- package/dist/client/assets/store-registry-DOxHwGOb.js +2 -0
- package/dist/client/assets/{switch-CpPJgX3Z.js → switch-Ckms2ja4.js} +1 -1
- package/dist/client/assets/{table-DvshqBHZ.js → table-CwjuFSQ3.js} +1 -1
- package/dist/client/assets/{tabs-XVsrMooL.js → tabs-1aaQ63Sr.js} +1 -1
- package/dist/client/assets/{task-status-B72j4SrB.js → task-status-B4sbD0o1.js} +1 -1
- package/dist/client/assets/{textarea-BYbT4tbc.js → textarea-BYfjo1_E.js} +1 -1
- package/dist/client/assets/{toggle-group-CEAl71x-.js → toggle-group-D-6M9i6u.js} +1 -1
- package/dist/client/assets/{tools-list-bFM-v0FI.js → tools-list-CeAP-pSC.js} +1 -1
- package/dist/client/assets/{tooltip-AWuCEA2U.js → tooltip-C0fjlVcO.js} +1 -1
- package/dist/client/assets/{types-CU4jWLjn.js → types-CGIbyQGc.js} +1 -1
- package/dist/client/assets/{use-ai-providers-B1OI2CIf.js → use-ai-providers-B9KrhoJu.js} +1 -1
- package/dist/client/assets/{use-collections-D0B-JFQ7.js → use-collections-DiZ2ax9f.js} +1 -1
- package/dist/client/assets/{use-connection-CtIj_RJA.js → use-connection-CjuTRKXt.js} +1 -1
- package/dist/client/assets/{use-copy-D_gDWAbg.js → use-copy-v_lAeoPt.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-poFHUu8W.js → use-create-virtual-mcp-BeCJlwzK.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-BGxMMdPD.js → use-debounced-autosave-Bx5zX-oh.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-hoK9fHvn.js → use-decopilot-events-CTbEMJUR.js} +1 -1
- package/dist/client/assets/{use-delete-connection-BhlBi1FW.js → use-delete-connection-H0_N4AfS.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-C2jLxN9Z.js → use-infinite-scroll-CdQPwmSi.js} +1 -1
- package/dist/client/assets/{use-list-state-Cr5c0njZ.js → use-list-state-DEafJAl0.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-CuCdREA6.js → use-mcp-tools-BhYfGuEe.js} +1 -1
- package/dist/client/assets/{use-members-CBm8zooS.js → use-members-D_vrkLzO.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-DuZ9B5bJ.js → use-navigate-to-agent-Dgy6Vgnk.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-B_jHxryd.js → use-org-auth-client-DIKSrkdJ.js} +1 -1
- package/dist/client/assets/{use-org-sso-D3NSe5ZU.js → use-org-sso-CjA-iSSa.js} +1 -1
- package/dist/client/assets/{use-organization-roles-CRKenEoR.js → use-organization-roles-Bg01cmKR.js} +1 -1
- package/dist/client/assets/{use-organization-settings-C_omnexa.js → use-organization-settings-BSGABThn.js} +1 -1
- package/dist/client/assets/{use-registry-connections--_PoD42X.js → use-registry-connections-CRSTloWi.js} +1 -1
- package/dist/client/assets/{use-status-sounds-aVa-jCse.js → use-status-sounds-CNQgHBud.js} +1 -1
- package/dist/client/assets/{use-tasks-COHzjoMD.js → use-tasks-DpLDw0OJ.js} +1 -1
- package/dist/client/assets/{use-view-mode-CUKpn6Nl.js → use-view-mode-838CJJ99.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-DTEHzUSp.js → use-virtual-mcp-BcU_WFds.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-B5TQbcQA.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-DNcETcP6.js +1 -0
- package/dist/client/assets/{user-DFc_JDuu.js → user-DCWmkhjg.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-DOq6DEUm.js → view-mode-toggle-C_UCqkmc.js} +1 -1
- package/dist/client/assets/{workflow-Cq_1R0yx.js → workflow-1eErmNbJ.js} +1 -1
- package/dist/client/assets/workflow-detail-JCbLYsbu.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -1
- package/dist/server/node_modules/ansi-styles/index.d.ts +236 -0
- package/dist/server/node_modules/ansi-styles/index.js +223 -0
- package/dist/server/node_modules/ansi-styles/license +9 -0
- package/dist/server/node_modules/ansi-styles/package.json +54 -0
- package/dist/server/node_modules/ansi-styles/readme.md +173 -0
- package/dist/server/node_modules/cli-cursor/index.d.ts +47 -0
- package/dist/server/node_modules/cli-cursor/index.js +39 -0
- package/dist/server/node_modules/cli-cursor/license +9 -0
- package/dist/server/node_modules/cli-cursor/package.json +49 -0
- package/dist/server/node_modules/cli-cursor/readme.md +51 -0
- package/dist/server/node_modules/get-east-asian-width/index.d.ts +60 -0
- package/dist/server/node_modules/get-east-asian-width/index.js +30 -0
- package/dist/server/node_modules/get-east-asian-width/license +9 -0
- package/dist/server/node_modules/get-east-asian-width/lookup-data.js +18 -0
- package/dist/server/node_modules/get-east-asian-width/lookup.js +135 -0
- package/dist/server/node_modules/get-east-asian-width/package.json +71 -0
- package/dist/server/node_modules/get-east-asian-width/readme.md +65 -0
- package/dist/server/node_modules/get-east-asian-width/utilities.js +24 -0
- package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/dist/server/node_modules/is-fullwidth-code-point/index.js +12 -0
- package/dist/server/node_modules/is-fullwidth-code-point/license +9 -0
- package/dist/server/node_modules/is-fullwidth-code-point/package.json +53 -0
- package/dist/server/node_modules/is-fullwidth-code-point/readme.md +31 -0
- package/package.json +1 -1
- package/dist/client/assets/registry-H-erkkte.js +0 -2
- package/dist/client/assets/store-registry-ukqdTlTM.js +0 -2
- package/dist/client/assets/useInfiniteQuery-CpIDGdPN.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-LpJXXkIA.js +0 -1
- package/dist/client/assets/workflow-detail-5bk-KUIV.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as ce,b as Et,u as Js,z as Vn,C as mn,j as n,B as Q,x as se,r as w,o as Dt,f as tt,l as at,G as Wt,F as Gt,t as $,K as Ae,e as L,Q as Xs,R as Zs,c as z,a as fn,g as ei,d as ti,H as nt,J as kt,E as ni,P as pn,ap as si,n as hn,y as Xn,aq as ii,ar as Zn,as as ri,at as Le,au as Qt,ao as oi,av as ai,aw as Ht,ax as li,ay as ci,az as di,aA as ui,w as Vi,aB as mi,aC as fi,aD as pi,aE as hi}from"./index-DL0cg4Sy.js";import{b as Fe,a as Ue,c as Oe,d as $e,e as Mt,D as es}from"./dialog-C_RX-AQt.js";import{S as gi}from"./switch-CpPJgX3Z.js";import{I as Ie}from"./input-CCf4EPNk.js";import{b as gn,u as xi}from"./use-connection-CtIj_RJA.js";import{S as xt,u as ze,W as ts,g as xn,i as Nn,c as bi}from"./constants-CIP80jF-.js";import{a as yi,c as vi}from"./lean-canvas-recruit-modal-51wnfw_w.js";import{a as bn}from"./use-navigate-to-agent-DuZ9B5bJ.js";import{a as wi,A as yn,K as ji,L as ns,b as Ai,M as Si,N as ss,o as ki,O as _i,P as Ni,H as is}from"./agent-icon-B5Lepjyg.js";import{t as Ci,b as Lt,u as vn,a as Ii,g as Ri,h as Ti,w as Pi,A as Ei,i as Di,j as Mi}from"./chat-context-aSv7zVBn.js";import{b as Ft,a as Ut,c as Ot,D as $t,d as Li,e as Fi,f as Ui}from"./drawer-XcInLzwE.js";import{u as Bt,T as lt,a as ct,b as dt,c as rn}from"./tooltip-AWuCEA2U.js";import{I as rs}from"./integration-icon-F29rJiGn.js";import{a as os,b as Oi,u as $i}from"./use-virtual-mcp-DTEHzUSp.js";import{u as Bi}from"./use-tasks-COHzjoMD.js";import{r as zi,i as qi}from"./shell-layout-D69vTgwv.js";import{j as zt,k as We,l as Ki,s as wn,t as Yi,m as Wi,n as Gi,o as Qi,q as mt,u as Hi,v as Ji,c as Xi,S as Zi,w as er,x as Cn}from"./pair-CR5fdfUV.js";import{S as _t}from"./spinner-CMg2UHyb.js";import{C as as}from"./collection-search-BfemXUsr.js";import{u as tr,g as jn,a as nr,c as sr,l as Nt}from"./tabs-XVsrMooL.js";import{F as me,b as fe,c as Ce,d as pe,f as he,a as ft}from"./form-0EbWbv9V.js";import{s as ir,i as rr}from"./XClose-Ds1dTxMH.js";import{c as ls}from"./ZapSquare-Br7mI2dC.js";import{i as pt}from"./Check-aa9K7ozq.js";import{s as ut}from"./Star01-C6jUiq1l.js";import{t as or,a as cs}from"./Tool01-DLlBXWXE.js";import{i as ds}from"./Lock01-3Z5YegUt.js";import{s as us}from"./Plus-DY7vA0mY.js";import{f as Jt,d as Vs,t as ar,g as lr,b as cr}from"./XCircle-J7xeYsqG.js";import{i as it}from"./X-BEU0MHUr.js";import{i as ms}from"./AlertCircle-DgIbjZFP.js";import{S as fs,a as ps,b as hs,c as gs,d as Xe}from"./select-BsEzdOFM.js";import{i as dr}from"./RefreshCcw01-D3efDqWQ.js";import{T as xs,a as Ct}from"./toggle-group-CEAl71x-.js";import{u as ur}from"./use-ai-providers-B1OI2CIf.js";import{m as qt,g as Vr,i as mr,a as bs,N as fr}from"./select-model-CMvi5mKv.js";import{c as Ze,a as ys,b as vs,D as ws,d as pr,e as hr,f as gr}from"./dropdown-menu-5TLJbEBI.js";import{u as Kt,P as on,a as xr,b as br,c as yr,E as vr,i as wr,d as jr}from"./index-HWD0WtFK.js";import{S as Ar}from"./index-uHvJMymL.js";import{r as js,l as Vt}from"./types-CU4jWLjn.js";import{p as Sr,q as In}from"./question-004-sINsf4GQ.js";import{g as kr}from"./connection-slug-eyAPH6o3.js";import{u as As,a as Ss,g as _r,C as Xt}from"./connection-card-BAH-_mNT.js";import{C as Nr}from"./collection-tabs-CqzKmYGm.js";import{g as Cr}from"./constants-B0----Qm.js";import{T as Ir}from"./textarea-BYbT4tbc.js";import{n as At}from"./Container-BwxK1zsB.js";import{c as Rr,i as vt,a as Rn,E as Tr,p as Pr,b as Er,d as Dr}from"./connection-form-helpers-BZl_1Yqu.js";import{u as Tn}from"./use-infinite-scroll-C2jLxN9Z.js";import{u as Mr}from"./useSuspenseInfiniteQuery-LpJXXkIA.js";import{g as Lr,e as Fr,a as Ur}from"./extract-connection-data-C288mPce.js";import{B as wt}from"./badge-CNmz6zWn.js";import{i as Or}from"./ChevronRight-BkYTpADa.js";function $r({open:t,onOpenChange:e,onCreated:s}){const{org:i}=ce(),{data:r}=Et.useSession(),{stdioEnabled:o}=Js(),a=Bt(),d=gn(),l=As(),V=Ss(l,"").items,c=Vn({resolver:mn(Rr),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),m=c.watch("ui_type"),p=c.watch("connection_url"),x=c.watch("npx_package"),g=vt({uiType:m,connectionUrl:p??"",npxPackage:x??""})??Rn({uiType:m,connectionUrl:p??"",registryItems:V}),f=A=>{const y=A.trim();if(!y)return;const j=!!c.formState.dirtyFields.title,P=!!c.formState.dirtyFields.description,D=!!c.formState.dirtyFields.env_vars,R=_=>{if(_&&(!j&&!c.getValues("title").trim()&&_.title&&c.setValue("title",_.title,{shouldDirty:!1}),!P&&!(c.getValues("description")??"").trim()&&_.description&&c.setValue("description",_.description,{shouldDirty:!1}),!D&&_.envVarKeys?.length)){const k=c.getValues("env_vars")??[],E=new Set(k.map(I=>I.key)),M=_.envVarKeys.filter(I=>!E.has(I));M.length>0&&c.setValue("env_vars",[...k,...M.map(I=>({key:I,value:""}))],{shouldDirty:!0})}},T=Pr(y);if(T&&o){c.setValue("ui_type","NPX",{shouldDirty:!0}),c.setValue("npx_package",T.packageName,{shouldDirty:!0}),c.setValue("connection_url","",{shouldDirty:!0}),c.setValue("connection_token",null,{shouldDirty:!0}),R(vt({uiType:"NPX",npxPackage:T.packageName}));return}if(y.startsWith("http://")||y.startsWith("https://")){const _=m==="HTTP"||m==="SSE"||m==="Websocket"?m:"HTTP";c.setValue("ui_type",_,{shouldDirty:!0}),c.setValue("connection_url",y,{shouldDirty:!0}),R(vt({uiType:_,connectionUrl:y})??Rn({uiType:_,connectionUrl:y,registryItems:V}));return}m==="NPX"&&R(vt({uiType:"NPX",npxPackage:y}))},b=A=>{A||c.reset(),e(A)},h=async A=>{let y,j=null,P=null,D=null;A.ui_type==="NPX"?(y="STDIO",j="",D=Er(A.npx_package||"",A.env_vars||[])):A.ui_type==="STDIO"?(y="STDIO",j="",D=Dr(A.stdio_command||"",A.stdio_args||"",A.stdio_cwd,A.env_vars||[])):(y=A.ui_type,j=A.connection_url||"",P=A.connection_token||null);const R=Cr("conn");try{await d.create.mutateAsync({id:R,title:A.title,description:A.description||null,connection_type:y,connection_url:j,connection_token:P,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:r?.user?.id||"system",organization_id:i.id,icon:A.icon??null,app_name:null,app_id:null,connection_headers:D,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),c.reset(),e(!1),s?.(R)}catch{se.error("Failed to create connection")}},v="Create Connection",S="Create a custom connection in your organization. Fill in the details below.",C=c.formState.isSubmitting?"Saving...":"Create Connection",N=n.jsxs("div",{className:"grid gap-4",children:[n.jsx(me,{control:c.control,name:"ui_type",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Type *"}),n.jsxs(fs,{value:A.value,onValueChange:A.onChange,children:[n.jsx(pe,{children:n.jsx(ps,{children:n.jsx(hs,{})})}),n.jsxs(gs,{children:[n.jsx(Xe,{value:"HTTP",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(ut,{className:"w-4 h-4"}),"HTTP"]})}),n.jsx(Xe,{value:"SSE",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(ut,{className:"w-4 h-4"}),"SSE"]})}),n.jsx(Xe,{value:"Websocket",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(ut,{className:"w-4 h-4"}),"Websocket"]})}),o&&n.jsxs(n.Fragment,{children:[n.jsx(Xe,{value:"NPX",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(At,{className:"w-4 h-4"}),"NPX Package"]})}),n.jsx(Xe,{value:"STDIO",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(wi,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),n.jsx(he,{})]})}),m==="NPX"&&n.jsx(me,{control:c.control,name:"npx_package",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"NPM Package *"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"@perplexity-ai/mcp-server",...A,value:A.value??"",onPaste:y=>{const j=y.clipboardData.getData("text");j&&(y.preventDefault(),c.setValue("npx_package",j.trim(),{shouldDirty:!0}),f(j))},onBlur:y=>{f(y.target.value),A.onBlur()}})}),n.jsx(he,{})]})}),m==="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[n.jsx(me,{control:c.control,name:"stdio_command",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Command *"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"node, bun, python...",...A,value:A.value??""})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"stdio_args",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Arguments"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"arg1 arg2 --flag value",...A,value:A.value??""})}),n.jsx(he,{})]})})]}),n.jsx(me,{control:c.control,name:"stdio_cwd",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Working Directory"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"/path/to/project (optional)",...A,value:A.value??""})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),n.jsx(he,{})]})})]}),(m==="NPX"||m==="STDIO")&&n.jsx(me,{control:c.control,name:"env_vars",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Environment Variables"}),n.jsx(pe,{children:n.jsx(Tr,{value:A.value??[],onChange:A.onChange})}),n.jsx(he,{})]})}),m!=="NPX"&&m!=="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsx(me,{control:c.control,name:"connection_url",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"URL *"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"https://example.com/mcp",...A,value:A.value??"",onPaste:y=>{const j=y.clipboardData.getData("text");j&&(y.preventDefault(),c.setValue("connection_url",j.trim(),{shouldDirty:!0}),f(j))},onBlur:y=>{f(y.target.value),A.onBlur()}})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"connection_token",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:g?.token?.label??"Token (optional)"}),n.jsx(pe,{children:n.jsx(Ie,{type:"password",placeholder:g?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...A,value:A.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(he,{})]})})]}),n.jsx(me,{control:c.control,name:"title",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Name *"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"My Connection",...A})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"description",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Description"}),n.jsx(pe,{children:n.jsx(Ir,{placeholder:"A brief description of this connection",rows:3,...A,value:A.value??""})}),n.jsx(he,{})]})})]});return a?n.jsx(Ft,{open:t,onOpenChange:b,children:n.jsxs(Ut,{className:"max-h-[90vh]",children:[n.jsx(Ot,{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($t,{children:v}),n.jsx(Li,{className:"mt-1",children:S})]}),n.jsx(Fi,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:n.jsx(ir,{size:16})})})]})}),n.jsx(ft,{...c,children:n.jsxs("form",{onSubmit:c.handleSubmit(h),children:[n.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:N}),n.jsx(Ui,{children:n.jsx(Q,{type:"submit",disabled:c.formState.isSubmitting,className:"w-full",children:C})})]})})]})}):n.jsx(Fe,{open:t,onOpenChange:b,children:n.jsxs(Ue,{className:"sm:max-w-[525px]",children:[n.jsxs(Oe,{children:[n.jsx($e,{children:v}),n.jsx(Mt,{children:S})]}),n.jsx(ft,{...c,children:n.jsxs("form",{onSubmit:c.handleSubmit(h),children:[n.jsx("div",{className:"py-4",children:N}),n.jsxs(es,{children:[n.jsx(Q,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),n.jsx(Q,{type:"submit",disabled:c.formState.isSubmitting,className:"min-w-40",children:C})]})]})})]})})}function Br(t){const e=L.c(73),{mode:s,agentId:i,addedConnectionIds:r,onAdd:o,onCloneAndAdd:a,onConnectAndAdd:d,connectingItemId:l,search:u,onCreateConnection:V,onBrowseNavigate:c,defaultTab:m}=t,p=s===void 0?"add":s,x=m===void 0?"connected":m,{org:g}=ce(),f=w.useDeferredValue(u),b=u!==f,h=f.trim().toLowerCase();let v;e[0]!==x?(v=U=>U??x,e[0]=x,e[1]=v):v=e[1];const[S,C]=Xs(Zs.connectionsTab(g.slug)+(x==="all"?":home-modal":":agent-modal"),v);let N;e[2]!==S||e[3]!==C?(N=U=>{U!==S&&$("connections_dialog_tab_changed",{to_tab:U}),C(U)},e[2]=S,e[3]=C,e[4]=N):N=e[4];const A=N;let y;e[5]!==g.id||e[6]!==g.slug?(y={connectionId:xt,orgId:g.id,orgSlug:g.slug},e[5]=g.id,e[6]=g.slug,e[7]=y):y=e[7];const j=ze(y);let P,D,R;if(e[8]!==j||e[9]!==f||e[10]!==g.id){R=f?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:f.trim()},{field:["description"],operator:"contains",value:f.trim()}]}:void 0;const U={...R&&{where:R},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},W=JSON.stringify(U);D=Mr,P=Ae.collectionListInfinite(j,g.id,"","CONNECTIONS",W),e[8]=j,e[9]=f,e[10]=g.id,e[11]=P,e[12]=D,e[13]=R}else P=e[11],D=e[12],R=e[13];let T;e[14]!==j||e[15]!==R?(T=async U=>{const{pageParam:W}=U,le=W===void 0?0:W;return(await j.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...R&&{where:R},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:le}})).structuredContent},e[14]=j,e[15]=R,e[16]=T):T=e[16];let _;e[17]!==P||e[18]!==T?(_={queryKey:P,queryFn:T,initialPageParam:0,getNextPageParam:Gr,staleTime:3e4},e[17]=P,e[18]=T,e[19]=_):_=e[19];const{data:k,fetchNextPage:E,hasNextPage:M,isFetchingNextPage:I}=D(_),F=k?.pages.flatMap(Wr)??[],O=_r(F),B=new Set(F.filter(Yr).map(Kr)),Y=As(),X=Ss(Y,f),Z=Tn(X.loadMore,X.hasMore,X.isLoadingMore),H=Tn(E,M??!1,I),q=S==="all"||!!h,ee=q?X.items.filter(U=>{const W=Lr(U);if(W&&B.has(W))return!1;if(!h)return!0;const le=U._meta?.["mcp.mesh"];return[U.title,U.description,U.name,U.server?.title,U.server?.description,U.server?.name,le?.friendly_name,le?.friendlyName].filter(Boolean).join(" ").toLowerCase().includes(h)}):[],J=ee.filter(qr),te=ee.filter(zr);let ie;e[20]!==r?(ie=U=>U.some(W=>r.has(W.id)),e[20]=r,e[21]=ie):ie=e[21];const oe=ie;let de;e[22]!==r||e[23]!==i||e[24]!==l||e[25]!==oe||e[26]!==p||e[27]!==o||e[28]!==c||e[29]!==a?(de=(U,W,le,Ne,ve)=>{const Be=oe(ve),we=ve.find(Ve=>!r.has(Ve.id)),ae=ve[0];if(p==="browse"){const Ve=kr(ae);return n.jsx(Xt,{connection:{title:W,icon:le,description:ve.length>1?`${ve.length} instances`:Ne??void 0},fallbackIcon:n.jsx(At,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs(wt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(pt,{size:11})," Connected"]}),onClick:()=>{$("connection_browse_clicked",{app_name:ae.app_name??null,connection_id:ae.id,instances_count:ve.length}),c?.(Ve)}},U)}return n.jsx(Xt,{connection:{title:W,icon:le,description:Ne},fallbackIcon:n.jsx(At,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[Be&&n.jsxs(wt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(pt,{size:11})," Added"]}),n.jsx(Q,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:l!==null,onClick:Ve=>{Ve.stopPropagation(),we?($("connection_add_clicked",{action:"use_existing",app_name:ae.app_name??null,connection_id:we.id}),i&&$("agent_connection_attached",{agent_id:i,connection_id:we.id,app_name:ae.app_name??null,mode:"existing"}),o(we.id)):($("connection_add_clicked",{action:"clone",app_name:ae.app_name??null,base_connection_id:ae.id}),a(ae))},children:"Add"})]})},U)},e[22]=r,e[23]=i,e[24]=l,e[25]=oe,e[26]=p,e[27]=o,e[28]=c,e[29]=a,e[30]=de):de=e[30];const ne=de;let re;e[31]!==l||e[32]!==p||e[33]!==d?(re=U=>{const W=U._meta?.["mcp.mesh"],le=W?.friendlyName||W?.friendly_name||U.server?.title||U.title||U.server?.name||U.name||U.id||"",Ne=U.server?.description||U.description||null,ve=U.server?.icons?.[0]?.src||Ur(U.server?.repository)||null,Be=W?.official===!0,we=W?.verified===!0,ae=W?.owner==="deco";return n.jsx(Xt,{connection:{title:le,description:Ne,icon:ve},fallbackIcon:n.jsx(At,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[ae&&n.jsxs(lt,{children:[n.jsx(ct,{asChild:!0,children:n.jsx("span",{className:"inline-flex items-center justify-center size-5 rounded-md bg-muted shrink-0",children:n.jsx("img",{src:"/logos/deco logo.svg",alt:"Made by Deco",className:"size-3"})})}),n.jsx(dt,{children:"Built and maintained by Deco"})]}),!ae&&Be&&n.jsxs(lt,{children:[n.jsx(ct,{asChild:!0,children:n.jsx(wt,{variant:"outline",size:"icon",children:n.jsx(Jt,{})})}),n.jsx(dt,{children:"Built and maintained by the official vendor"})]}),!ae&&!Be&&we&&n.jsxs(lt,{children:[n.jsx(ct,{asChild:!0,children:n.jsx(wt,{variant:"outline",size:"icon",children:n.jsx(Jt,{})})}),n.jsx(dt,{children:"Verified by the Deco team"})]}),n.jsx(Q,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:l!==null,onClick:Ve=>{Ve.stopPropagation(),$("connection_add_clicked",{action:"connect_new",registry_item_id:U.id,app_name:W?.friendlyName||U.server?.name||U.name||null}),d(U)},children:l===U.id?n.jsx(at,{size:14,className:"animate-spin"}):p==="browse"?"Connect":"Add"})]})},`catalog-${U.id}`)},e[31]=l,e[32]=p,e[33]=d,e[34]=re):re=e[34];const je=re,K=!h&&n.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[n.jsx(Nr,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:S,onTabChange:U=>A(U)}),n.jsxs(Q,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{$("connections_dialog_custom_clicked"),V()},children:[n.jsx(us,{size:12}),"Custom Connection"]})]}),ue=b&&"opacity-50 pointer-events-none";let Re;e[35]!==ue?(Re=z("flex-1 overflow-auto p-5 transition-opacity duration-150",ue),e[35]=ue,e[36]=Re):Re=e[36];const qe="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let Ke;e[37]!==ne?(Ke=U=>{if(U.type==="group")return ne(U.key,U.title,U.icon,null,U.connections);const W=U.connection;return ne(W.id,W.title,W.icon,W.description??null,[W])},e[37]=ne,e[38]=Ke):Ke=e[38];const Te=O.map(Ke);let ge;e[39]!==H?(ge=n.jsx("div",{ref:H,className:"col-span-full h-1"}),e[39]=H,e[40]=ge):ge=e[40];let Se;e[41]!==I?(Se=I&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(at,{size:24,className:"animate-spin text-muted-foreground"})}),e[41]=I,e[42]=Se):Se=e[42];const Pe=q&&J.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx(Jt,{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"})]}),Ee=q&&J.map(je),Ge=q&&te.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"})]}),De=q&&te.map(je);let Me;e[43]!==Z||e[44]!==Y||e[45]!==q?(Me=q&&Y.length>0&&n.jsx("div",{ref:Z,className:"col-span-full h-1"}),e[43]=Z,e[44]=Y,e[45]=q,e[46]=Me):Me=e[46];let xe;e[47]!==X.isLoadingMore||e[48]!==q?(xe=q&&X.isLoadingMore&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(at,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=X.isLoadingMore,e[48]=q,e[49]=xe):xe=e[49];let be;e[50]!==Te||e[51]!==ge||e[52]!==Se||e[53]!==Pe||e[54]!==Ee||e[55]!==Ge||e[56]!==De||e[57]!==Me||e[58]!==xe?(be=n.jsxs("div",{className:qe,children:[Te,ge,Se,Pe,Ee,Ge,De,Me,xe]}),e[50]=Te,e[51]=ge,e[52]=Se,e[53]=Pe,e[54]=Ee,e[55]=Ge,e[56]=De,e[57]=Me,e[58]=xe,e[59]=be):be=e[59];let ke;e[60]!==S||e[61]!==O.length||e[62]!==te||e[63]!==u||e[64]!==J?(ke=O.length===0&&J.length===0&&te.length===0&&n.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:u?`No connections match "${u}"`:S==="connected"?"No connections yet":"No connections available"}),e[60]=S,e[61]=O.length,e[62]=te,e[63]=u,e[64]=J,e[65]=ke):ke=e[65];let ye;e[66]!==Re||e[67]!==be||e[68]!==ke?(ye=n.jsxs("div",{className:Re,children:[be,ke]}),e[66]=Re,e[67]=be,e[68]=ke,e[69]=ye):ye=e[69];let _e;return e[70]!==K||e[71]!==ye?(_e=n.jsxs(n.Fragment,{children:[K,ye]}),e[70]=K,e[71]=ye,e[72]=_e):_e=e[72],_e}function zr(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function qr(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function Kr(t){return t.app_name}function Yr(t){return t.app_name}function Wr(t){return t?.items??[]}function Gr(t,e){if(t?.hasMore)return e.reduce(Qr,0)}function Qr(t,e){return t+(e?.items?.length??0)}function Hr({open:t,onOpenChange:e,defaultTab:s,initialSearch:i="",...r}){const o=r.mode??"add",a="agentId"in r?r.agentId:void 0,d="addedConnectionIds"in r?r.addedConnectionIds??new Set:new Set,l="onAdd"in r&&r.onAdd?r.onAdd:y=>{},u=(y,j,P)=>{a&&$("agent_connection_attached",{agent_id:a,connection_id:y,app_name:j,mode:P})},[V,c]=w.useState(null),[m,p]=w.useState(i),[x,g]=w.useState(!1),{org:f}=ce(),{data:b}=Et.useSession(),h=gn(),v=Dt(),S=tt(),C=y=>{e(!1),S({to:"/$org/settings/connections/$appSlug",params:{org:f.slug,appSlug:y}})},N=async y=>{c(y.app_name??y.id);try{const P=`${y.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,R=(await h.create.mutateAsync({title:P,description:y.description??null,connection_type:y.connection_type,connection_url:y.connection_url??null,connection_token:null,icon:y.icon??null,app_name:y.app_name??null,app_id:y.app_id??null,connection_headers:y.connection_headers??null})).id,T=new URL(`/api/${f.slug}/mcp/${R}`,window.location.origin),_=await Wt({url:T.href,token:null,orgId:f.id});if(_.supportsOAuth&&!_.isAuthenticated){const{token:k,tokenInfo:E,error:M}=await Gt({connectionId:R,orgSlug:f.slug,scope:"offline_access"});if(M||!k){$("connection_oauth_failed",{connection_id:R,flow:"clone",error:M??"no_token"}),se.error(`Authentication failed: ${M??"no token received"}`),await h.delete.mutateAsync(R);return}if($("connection_oauth_succeeded",{connection_id:R,flow:"clone"}),E)try{(await fetch(`/api/${f.slug}/connections/${R}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:E.accessToken,refreshToken:E.refreshToken,expiresIn:E.expiresIn,scope:E.scope,clientId:E.clientId,clientSecret:E.clientSecret,tokenEndpoint:E.tokenEndpoint})})).ok?await h.update.mutateAsync({id:R,data:{}}):await h.update.mutateAsync({id:R,data:{connection_token:k}})}catch{await h.update.mutateAsync({id:R,data:{connection_token:k}})}else await h.update.mutateAsync({id:R,data:{connection_token:k}});await v.invalidateQueries({queryKey:Ae.isMCPAuthenticated(T.href,null)})}u(R,y.app_name??null,"clone"),l(R)}catch(j){console.error("Failed to add connection:",j),se.error("Failed to add connection")}finally{c(null)}},A=async y=>{if(!(!f||!b?.user?.id)){c(y.id);try{const j=Fr(y,f.id,b.user.id,{remoteIndex:0}),P=j.connection_type==="STDIO",D=!!j.connection_url,R=P&&j.connection_headers&&typeof j.connection_headers=="object"&&"command"in j.connection_headers;if(!D&&!R){se.error("This MCP Server cannot be connected: no connection method available"),c(null);return}const{id:T}=await h.create.mutateAsync(j),_=new URL(`/api/${f.slug}/mcp/${T}`,window.location.origin),k=await Wt({url:_.href,token:null,orgId:f.id});if(k.supportsOAuth&&!k.isAuthenticated){const{token:E,tokenInfo:M,error:I}=await Gt({connectionId:T,orgSlug:f.slug,scope:"offline_access"});if(I||!E){$("connection_oauth_failed",{connection_id:T,flow:"connect_new",error:I??"no_token"}),se.warning("Couldn't sign in to this connection",{description:`It was added to your agent, but its sign-in setup looks off. You can try authenticating again later from the connection's settings. (${I??"no token received"})`}),u(T,j.app_name??null,"new"),l(T);return}if($("connection_oauth_succeeded",{connection_id:T,flow:"connect_new"}),M)try{(await fetch(`/api/${f.slug}/connections/${T}/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 h.update.mutateAsync({id:T,data:{}}):await h.update.mutateAsync({id:T,data:{connection_token:E}})}catch{await h.update.mutateAsync({id:T,data:{connection_token:E}})}else await h.update.mutateAsync({id:T,data:{connection_token:E}});await v.invalidateQueries({queryKey:Ae.isMCPAuthenticated(_.href,null)}),se.success("Connected and authenticated")}else se.success("Connected");u(T,j.app_name??null,"new"),l(T)}catch(j){console.error("Failed to connect:",j),se.error("Failed to connect")}finally{c(null)}}};return n.jsxs(Fe,{open:t,onOpenChange:e,children:[n.jsxs(Ue,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[n.jsx(Oe,{className:"px-6 pt-5 pb-0 shrink-0",children:n.jsx($e,{className:"text-base font-semibold",children:o==="browse"?"Connections":"Add Connection"})}),n.jsx("div",{className:"pt-3 shrink-0",children:n.jsx(as,{value:m,onChange:p,placeholder:"Search connections..."})}),n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(at,{size:24,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Br,{mode:o,agentId:a,addedConnectionIds:d,onAdd:l,onCloneAndAdd:N,onConnectAndAdd:A,connectingItemId:V,search:m,onCreateConnection:()=>g(!0),onBrowseNavigate:C,defaultTab:s})})]}),n.jsx($r,{open:x,onOpenChange:g,onCreated:async y=>{g(!1);const j=new URL(`/api/${f.slug}/mcp/${y}`,window.location.origin),P=await Wt({url:j.href,token:null,orgId:f.id});if(P.supportsOAuth&&!P.isAuthenticated){const{token:D,tokenInfo:R,error:T}=await Gt({connectionId:y,orgSlug:f.slug,scope:"offline_access"});if(T||!D){$("connection_oauth_failed",{connection_id:y,flow:"custom_create",error:T??"no_token"}),se.warning("Couldn't sign in to this connection",{description:`It was added to your agent, but its sign-in setup looks off. You can try authenticating again later from the connection's settings. (${T??"no token received"})`}),u(y,null,"custom"),l(y),e(!1);return}if($("connection_oauth_succeeded",{connection_id:y,flow:"custom_create"}),R)try{(await fetch(`/api/${f.slug}/connections/${y}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:R.accessToken,refreshToken:R.refreshToken,expiresIn:R.expiresIn,scope:R.scope,clientId:R.clientId,clientSecret:R.clientSecret,tokenEndpoint:R.tokenEndpoint})})).ok?await h.update.mutateAsync({id:y,data:{}}):await h.update.mutateAsync({id:y,data:{connection_token:D}})}catch{await h.update.mutateAsync({id:y,data:{connection_token:D}})}else await h.update.mutateAsync({id:y,data:{connection_token:D}});await v.invalidateQueries({queryKey:Ae.isMCPAuthenticated(j.href,null)})}u(y,null,"custom"),l(y),e(!1)}})]})}const Jr='# Broken Link Finder\n\nYou are the **Broken Link Finder**, a specialist agent focused on the health of the site\'s link structure.\n\n## Your mission\n\nDiscover and track broken links and long redirect chains. You are invoked as a sub-task by an orchestrator agent — your job is to detect link health and return a structured findings report. The orchestrator decides what to do with your findings (file issues, dedup, etc.).\n\nYou are **mechanical**: collect → check → classify → emit findings. Leave subjective judgment to other agents.\n\n## Input (expect this in the prompt)\n\nThe orchestrator will pass per-site configuration. Expected fields:\n\n```yaml\nsite_root_url: <https://example.com>\nmax_pages: <optional integer, default 100, max 200>\ncheck_external: <optional bool, default false>\n```\n\nIf required fields are missing (`site_root_url`), return an error summary and stop — do not proceed with defaults or guess.\n\n## Available tools\n\n- **site-diagnostics MCP**:\n - `collect_site_links` — discovers all unique outbound link targets across the site and returns them with source-page attribution. Does NOT check status.\n - `check_urls` — takes a batch of URLs (max 100 per call) and returns their HTTP status, error kind, and redirect chains.\n\n---\n\n## Step 1 — Collect link targets (one call)\n\nCall `collect_site_links` once to get the full deduplicated list of outbound link targets and their source pages:\n\n```\ncollect_site_links({\n url: <site_root_url from input>,\n maxPages: <max_pages from input, default 100>,\n checkExternal: <check_external from input, default false>\n})\n```\n\nThis returns:\n- `links`: array of `{ targetUrl, scope: "internal"|"external", sourcePages, sourcePagesTotal }` — **each target appears exactly once**\n- Metadata: `pagesCrawled`, `pagesFetched`, `linksSkipped`, optional `error`\n\n**If `result.error` is set**, the scan failed at the root (e.g. site unreachable). Return a single finding with `kind: site-unreachable` and the error in `evidence`. Then stop.\n\nKeep the `links` array in memory — you\'ll need it in Step 3 for classification and source attribution.\n\n## Step 2 — Check the targets (batched calls)\n\nExtract `targetUrl` from each entry in `links`. Slice the resulting URL list into **disjoint batches of up to 100 URLs** and call `check_urls` on each batch:\n\n```\ncheck_urls({ urls: batch_of_100_urls })\n```\n\nCollect every batch\'s `results` entries into a single flat array. Order doesn\'t matter — you\'ll join back by `targetUrl`.\n\n**Rules for this step:**\n- Slice deterministically (e.g. consecutive slices of 100) so batches are disjoint. Do not pass the same URL in two batches.\n- Call `check_urls` sequentially or in parallel — your choice. The tool is idempotent.\n- If a single `check_urls` call errors entirely, skip that batch and continue with the others. Note the skipped count in the wrap-up summary.\n\n## Step 3 — Classify each finding\n\nFor every target with a check result, join the `collect_site_links` entry (for `scope`, `sourcePages`, `sourcePagesTotal`) with the `check_urls` entry (for `status`, `errorKind`, `chain`, `hops`).\n\nA finding is emitted for:\n- **Broken**: `status >= 400` OR `status === 0`\n- **Long redirect chain**: `hops > 3` (even if the final status is 2xx)\n\nOther targets (2xx, short-chain redirects) produce no finding.\n\nMap check result → `kind`:\n\n| Check result | `kind` |\n|---|---|\n| `status: 404` | `link-404` |\n| `status: 4xx` (not 404) | `link-4xx-other` |\n| `status: 5xx` | `link-5xx` |\n| `status: 0`, `errorKind: "dns"` | `link-dns-failure` |\n| `status: 0`, `errorKind: "redirect-loop"` | `redirect-loop` |\n| `hops > 3` (success final status) | `redirect-chain-long` |\n| `status: 0`, `errorKind: "timeout"` or `"connection"` | **skip — no finding** |\n\n**Important**: timeouts and connection errors are **not** broken links — they just mean the server didn\'t respond in our time window. Could be a slow server, an overloaded CDN, rate-limiting against our bot, or a transient network blip. Flagging these as broken produces false positives. If a URL is genuinely dead, it\'ll usually surface as `dns`, a 4xx/5xx, or a redirect loop. Skip timeout/connection entries silently.\n\n## Catalog of severity rules\n\n**High severity:**\n- `link-404` when `scope: "internal"`\n- `link-5xx` when `scope: "internal"`\n- `redirect-loop` (either scope)\n\n**Medium severity:**\n- `link-4xx-other` (internal)\n- `redirect-chain-long` (internal)\n- `link-404` (external) when `sourcePagesTotal >= 5`\n\n**Low severity:**\n- `link-404` (external) when `sourcePagesTotal < 5`\n- `link-dns-failure` (external)\n- `redirect-chain-long` (external)\n- `link-4xx-other` on external scope\n\n## Step 4 — Return a structured findings report\n\nReturn a single response with this shape (YAML preferred):\n\n```yaml\nspecialist: links\nsummary:\n pages_crawled: <pagesCrawled>\n pages_fetched: <pagesFetched>\n unique_link_targets: <links.length>\n targets_dropped_by_collect_cap: <linksSkipped>\n batches_checked: <n>\n batches_skipped_due_to_errors: <n>\n broken_links: <n> # internal + external\n long_redirect_chains: <n>\nfindings:\n - kind: <kind slug>\n severity: <low|medium|high>\n target:\n url: <full broken URL>\n route: <path if internal; otherwise the external host>\n scope: <internal | external>\n evidence: |\n - Status code / error: <e.g. `404 Not Found`, `DNS failure`, `redirect-loop`>\n - Redirect chain (if applicable): A → B → C → D → E\n - Found on pages (at time of detection):\n - /page-1\n - /page-2\n - (... up to 20 from `sourcePages`)\n - Total pages linking to this target: <sourcePagesTotal>\n impact: <1 sentence tailored to scope + kind>\n suggested_fix: |\n <actionable:>\n - If internal 404: update link to correct destination OR create 301 redirect\n - If internal 5xx: investigate server-side handler for the route (may be app bug)\n - If redirect chain: shorten to single-hop direct redirect in routing config\n - If external: update link to equivalent resource OR remove the mention\n - List likely files/components if you can infer (e.g. "appears on many pages — likely in a shared component like `app/components/Nav.tsx` or menu config")\n - ...\n```\n\nIf `collect_site_links` returned `error`, return a single `kind: site-unreachable` finding with the error in `evidence`.\n\nIf there are zero findings, return `findings: []` — that is the correct output for a healthy link graph.\n\n---\n\n## General rules\n\n- **Trust the scanner.** If `check_urls` reports a URL as broken or long-chain, emit a finding. Do not re-verify with other tools.\n- **Accept some flakiness.** A transient network blip may cause a false positive once. Downstream dedup across runs resolves it.\n- **Group by destination, not by origin.** One broken URL = one finding, even if linked on 50 pages. `collect_site_links` already returns it grouped this way.\n- **Prioritize internals.** Broken external links are the other site\'s responsibility; report but with lower severity.\n- **Never invent status codes.** Report what the scanner returned.\n',Xr='# SEO Auditor\n\nYou are the **SEO Auditor**, a specialist agent focused on technical SEO hygiene.\n\n## Your mission\n\nAudit the on-page SEO health of target URLs and return a structured findings report. You focus on **technical SEO** (meta tags, structured data, canonicals, sitemap/robots, heading structure, indexability) — not editorial content or keyword strategy (those are the scope of other agents).\n\nYou are invoked as a sub-task by an orchestrator agent. Your job is to analyze and report. The orchestrator decides what to do with your findings (file issues, dedup against history, etc.).\n\n## Input (expect this in the prompt)\n\nThe orchestrator will pass per-site configuration. Expected fields:\n\n```yaml\nurls:\n - <url to audit>\n - <... one or more>\n```\n\nIf required fields are missing, return an error summary and stop — do not proceed with defaults or guess.\n\n## Available tools\n\n- **site-diagnostics MCP**: `audit_seo`, `fetch_page`, `render_page`, `crawl_site`\n\n---\n\n## Step 1 — Diagnostic\n\nFor each target URL:\n\n1. **Structured audit**: call `audit_seo({ url })`. It returns a structured report — use it as your primary source.\n2. **Raw HTML check**: use `fetch_page({ url })` to see the HTML served (important for crawlers that don\'t execute JS). Confirm critical meta tags are in the initial HTML, not only after hydration.\n3. **Post-render check**: use `render_page({ url })` to see the final DOM. Problems like canonical being overwritten by JS show up here.\n4. **Site structure checks** (only if you have permission for broad crawling, or via sampling): use `crawl_site` to identify orphan pages, canonical loops, or excessive navigation depth.\n5. **Always check**: `/robots.txt` and `/sitemap.xml` via `fetch_page`. These two are root-level and affect the whole site.\n\nOrganize findings into a list. Each finding must have:\n- `kind` (kebab-case slug, see catalog below)\n- `severity` (high | medium | low, see criteria below)\n- `target.url` and `target.route` (normalize: lowercase host, no query, no trailing slash except for `/`)\n- `evidence` (raw data: CSS selector, HTML snippet, observed value)\n- `impact` (1-2 sentences connecting to real metrics)\n- `suggested_fix` (actionable; include file/line if you can infer from framework patterns)\n\n## Step 1.5 — Validate page intent (critical; runs before classification)\n\nBefore you emit *any* finding about a page\'s title, meta description, headings, or indexability, you must answer one question: **did the site owner intend this URL to be a public, indexable page?**\n\nIf the answer is no, the observed "problems" are intentional configuration, not bugs. Reporting them wastes maintainer time and erodes this agent\'s credibility.\n\n### Three signals that the URL is NOT a real public page\n\nCheck these in order. Hitting any one of them means **skip all SEO findings for this URL** except legitimately site-wide problems (e.g. broken sitemap, broken robots.txt).\n\n**Signal 1 — Not in sitemap.** Fetch `/sitemap.xml` (and its child sitemaps, if it\'s a sitemap index). If the URL doesn\'t appear in any sitemap, the owner didn\'t declare it as public. Common on e-commerce platforms where routes like `/p`, `/c`, `/blog` are catchall or routing prefixes, not real pages.\n\n**Signal 2 — Explicit `noindex` + not in sitemap.** If the page serves `<meta name="robots" content="noindex*">` **and** isn\'t in the sitemap, this is a deliberate double-lock by the owner. Respect it. Do **not** flag `noindex-on-important-page` in this case.\n\n**Signal 3 — Title is the URL slug (template fallback).** If `<title>` equals the last path segment (e.g. `<title>blog</title>` for `/blog`, `<title>p</title>` for `/p`), the page is being rendered by a fallback template — nobody configured real content for this route. Skip.\n\n### Platform-specific catchalls (especially Brazilian e-commerce / VTEX / deco-cx)\n\nThese paths are routing prefixes, **not pages**. They may return HTTP 200 but are not meant to be indexable:\n\n- `/p`, `/c`, `/b` — VTEX product / category / brand route prefixes. Real pages live at `/<slug>/p`, `/<slug>/c`, etc. The bare prefixes are catchalls.\n- `/blog`, `/blogs`, `/editorial`, `/revista`, `/conteudo`, `/magazine`, `/noticias`, `/artigos` — common editorial prefixes. If the site doesn\'t have an editorial section, these hit a fallback.\n- `/search`, `/busca`, `/s` — search endpoints, not indexable pages.\n- `/departamento`, `/categoria` — category prefixes.\n- `/checkout`, `/cart`, `/carrinho`, `/login`, `/account`, `/minha-conta` — transactional/private routes. Intentionally `noindex`.\n\n### The "is this page actually important?" checklist\n\nBefore emitting a finding that calls a page "important" (like `noindex-on-important-page` or `title-missing` on anything critical):\n\n1. Is the URL in `/sitemap.xml`? → If no, skip.\n2. Does the page have substantive, unique content (not a fallback with title = URL slug)? → If no, skip.\n3. Is the path a known platform catchall (see list above)? → If yes, skip.\n\nOnly flag if all three pass.\n\n### What still counts as a finding even on non-indexable pages\n\nSite-wide SEO issues affect the whole domain and are worth reporting regardless of individual page intent:\n- `sitemap-missing` (the sitemap itself is broken)\n- `robots-blocking-important-path` (robots.txt blocks something that IS in the sitemap)\n- `structured-data-invalid` on pages that ARE in the sitemap\n- Duplicate titles / meta descriptions across pages that ARE in the sitemap\n\n## Catalog of `kind`\n\nTwo flavors of finding:\n\n- **Per-page** kinds — emitted when auditing a specific URL (e.g. `audit_seo` of a single page OR when your targeted inspection of one of the input URLs finds the issue). Marked **[intent-gated]** — must pass Step 1.5 before being emitted. Target is the specific URL.\n- **Aggregate** kinds — emitted once per site-wide pattern detected by `audit_seo`. Marked **[aggregate]**. Target is the site root (`/`). Evidence MUST include the affected URL sample from `audit_seo.issues[].sampleUrls`. One finding per aggregate kind per site.\n\n**High severity (per-page):**\n- `noindex-on-important-page` **[intent-gated]** — meta robots `noindex` on a page that IS in the sitemap and should be indexed\n- `canonical-pointing-to-wrong-url` **[intent-gated]** — canonical points to a different URL that isn\'t the canonical equivalent\n- `canonical-missing-on-paginated-or-faceted` **[intent-gated]** — pagination/filters without canonical\n- `title-missing` **[intent-gated]** — no `<title>` or empty on a page that IS in the sitemap\n- `structured-data-invalid` **[intent-gated]** — JSON-LD with syntax error or invalid schema.org\n\n**High severity (site-wide):**\n- `sitemap-missing` — `/sitemap.xml` returns 404 or 5xx\n- `robots-blocking-important-path` — `/robots.txt` disallows a path that IS in the sitemap\n- `broken-links-site-wide` **[aggregate]** — `audit_seo` reports broken outbound links across the site\n- `non-indexable-pages-site-wide` **[aggregate]** — `audit_seo` reports many non-indexable pages (note: some non-indexable pages are intentional catchalls — only high severity if the absolute count is large relative to `totalPagesCrawled`, e.g. > 30%)\n\n**Medium severity (per-page):**\n- `meta-description-missing` **[intent-gated]** — no `<meta name="description">` on a sitemap page the agent audited directly\n- `h1-missing` **[intent-gated]** — no `<h1>` on a sitemap page the agent audited directly\n- `h1-duplicate` **[intent-gated]** — multiple `<h1>` on a single page\n- `og-tags-missing` **[intent-gated]** — `og:title` and/or `og:description` missing\n- `structured-data-missing` **[intent-gated]** — page-type (product, article, etc.) without relevant JSON-LD\n- `title-too-long` **[intent-gated]** — `<title>` > 60 characters (truncation in SERP)\n- `title-too-short` **[intent-gated]** — `<title>` < 10 characters (rare; usually means template fallback — double-check page intent)\n- `meta-description-too-long` **[intent-gated]** — description > 160 characters\n\n**Medium severity (site-wide):**\n- `pages-missing-h1` **[aggregate]** — `audit_seo` reports N pages without an H1 tag\n- `pages-missing-meta-description` **[aggregate]** — `audit_seo` reports N pages without a meta description\n- `duplicate-titles` **[aggregate]** — multiple pages share the same `<title>`\n- `duplicate-meta-descriptions` **[aggregate]** — multiple pages share the same meta description\n- `duplicate-content` **[aggregate]** — multiple pages share substantially identical content\n- `broken-resources-site-wide` **[aggregate]** — broken images / scripts across the site\n- `hreflang-broken` — `hreflang` attribute with invalid value or broken reciprocity\n\n**Low severity (per-page):**\n- `meta-description-too-short` **[intent-gated]** — description < 50 characters\n- `og-image-missing` **[intent-gated]** — `og:image` missing\n- `heading-hierarchy-skipped` **[intent-gated]** — jumps from H1 to H3, etc.\n\n**Low severity (site-wide):**\n- `internal-link-using-absolute-url` — internal links with absolute URLs\n\n### Evidence requirements for aggregate kinds\n\nWhen emitting an `[aggregate]` kind, the `evidence` of the finding MUST include:\n\n1. **Total count** — from `audit_seo.issues[].count`\n2. **Sample URLs** — from `audit_seo.issues[].sampleUrls`. Render up to all 20 entries as a bulleted list. If `count > sampleUrls.length`, add a line like `(and <count - sampleUrls.length> more)`.\n3. **If `sampleUrls` is empty** (the tool didn\'t expose per-URL detail — happens for `broken-links-site-wide`, `duplicate-content`, `broken-resources-site-wide`), note it explicitly: `Note: audit_seo did not return per-URL detail for this issue type. A human will need to inspect the full audit_seo report or re-run with deeper crawling.`\n\nAn aggregate finding without either sample URLs or the note is **not actionable** and must not be emitted.\n\nTarget for aggregate kinds stays `target.url: https://<host>/` and `target.route: /`.\n\n## Step 2 — Return a structured findings report\n\nReturn a single response with this shape (YAML or JSON; YAML preferred for readability):\n\n```yaml\nspecialist: seo\nsummary:\n urls_audited: <n>\n findings: <n>\n diagnostic_failures: <n> # urls where audit tooling errored\nfindings:\n - kind: <kind slug>\n severity: <low|medium|high>\n target:\n url: <full URL>\n route: <normalized path>\n evidence: |\n <multi-line raw data: observed value, selector, HTML snippet, audit_seo output>\n impact: <1-2 sentences connecting to ranking/indexation/CTR>\n suggested_fix: <actionable; likely file/component, pseudo-code, correct value>\n - ...\n```\n\nIf a URL\'s diagnostic tooling errored entirely, emit a single `kind: diagnostic-failed` finding for that URL with the error in `evidence` instead of inventing data.\n\nIf there are zero findings, return `findings: []` — that is the correct output for healthy targets.\n\n---\n\n## General rules\n\n- **Never invent data in `evidence`.** If a tool failed, report it via `kind: diagnostic-failed` and skip the finding.\n- Always normalize `route`: lowercase host, no trailing slash (except for `/`), no query string, no fragment.\n- Your credibility is your currency. False positives erode trust — if you\'re 50% sure, don\'t emit a finding; investigate further or mark as `severity:low`.\n- **Never report a page as broken when it\'s a known catchall.** URLs like `/p`, `/c`, `/blog`, `/search`, `/busca` on e-commerce sites are routing prefixes, not pages. If the title is the URL slug and the page carries `noindex`, the owner is deliberately hiding it. That\'s correct behavior, not a bug.\n- **Sitemap is the ground truth for "is this page public?"**. When in doubt about whether to emit a finding on a URL, fall back to: "Is this URL in /sitemap.xml?" If not, default to silence.\n',Zr=`# Performance Watchdog
|
|
1
|
+
import{s as ce,b as Et,u as Js,z as Vn,C as mn,j as n,B as Q,x as se,r as w,o as Dt,f as tt,l as at,G as Wt,F as Gt,t as $,K as Ae,e as L,Q as Xs,R as Zs,c as z,a as fn,g as ei,d as ti,H as nt,J as kt,E as ni,P as pn,ap as si,n as hn,y as Xn,aq as ii,ar as Zn,as as ri,at as Le,au as Qt,ao as oi,av as ai,aw as Ht,ax as li,ay as ci,az as di,aA as ui,w as Vi,aB as mi,aC as fi,aD as pi,aE as hi}from"./index-_a3sfx9A.js";import{b as Fe,a as Ue,c as Oe,d as $e,e as Mt,D as es}from"./dialog-BFONggAc.js";import{S as gi}from"./switch-Ckms2ja4.js";import{I as Ie}from"./input-CLyArZAZ.js";import{b as gn,u as xi}from"./use-connection-CjuTRKXt.js";import{S as xt,u as ze,W as ts,g as xn,i as Nn,c as bi}from"./constants-BxAwlKEt.js";import{a as yi,c as vi}from"./lean-canvas-recruit-modal-Cp7w5Yzr.js";import{a as bn}from"./use-navigate-to-agent-Dgy6Vgnk.js";import{a as wi,A as yn,K as ji,L as ns,b as Ai,M as Si,N as ss,o as ki,O as _i,P as Ni,H as is}from"./agent-icon-CHawCeGj.js";import{t as Ci,b as Lt,u as vn,a as Ii,g as Ri,h as Ti,w as Pi,A as Ei,i as Di,j as Mi}from"./chat-context-CBEjrtlA.js";import{b as Ft,a as Ut,c as Ot,D as $t,d as Li,e as Fi,f as Ui}from"./drawer-DPE2UfDW.js";import{u as Bt,T as lt,a as ct,b as dt,c as rn}from"./tooltip-C0fjlVcO.js";import{I as rs}from"./integration-icon-BHVwtvVd.js";import{a as os,b as Oi,u as $i}from"./use-virtual-mcp-BcU_WFds.js";import{u as Bi}from"./use-tasks-DpLDw0OJ.js";import{r as zi,i as qi}from"./shell-layout-Bz9lZQVY.js";import{j as zt,k as We,l as Ki,s as wn,t as Yi,m as Wi,n as Gi,o as Qi,q as mt,u as Hi,v as Ji,c as Xi,S as Zi,w as er,x as Cn}from"./pair-Dfx2VDcu.js";import{S as _t}from"./spinner-DnlGnBXF.js";import{C as as}from"./collection-search-CF_YUmub.js";import{u as tr,g as jn,a as nr,c as sr,l as Nt}from"./tabs-1aaQ63Sr.js";import{F as me,b as fe,c as Ce,d as pe,f as he,a as ft}from"./form-B8LulHdI.js";import{s as ir,i as rr}from"./XClose-Cr0_UGK3.js";import{c as ls}from"./ZapSquare-5AS1CTub.js";import{i as pt}from"./Check-Dw-NNjqo.js";import{s as ut}from"./Star01-r_zmzcnE.js";import{t as or,a as cs}from"./Tool01-CZrEw9GG.js";import{i as ds}from"./Lock01-BtdrYKDm.js";import{s as us}from"./Plus-D0grveYD.js";import{f as Jt,d as Vs,t as ar,g as lr,b as cr}from"./XCircle-BLjPn4jt.js";import{i as it}from"./X-MkRobXsq.js";import{i as ms}from"./AlertCircle-ERuf6aAv.js";import{S as fs,a as ps,b as hs,c as gs,d as Xe}from"./select-Wcqz-g0G.js";import{i as dr}from"./RefreshCcw01-BF_TovZP.js";import{T as xs,a as Ct}from"./toggle-group-D-6M9i6u.js";import{u as ur}from"./use-ai-providers-B9KrhoJu.js";import{m as qt,g as Vr,i as mr,a as bs,N as fr}from"./select-model-DNKOCT1K.js";import{c as Ze,a as ys,b as vs,D as ws,d as pr,e as hr,f as gr}from"./dropdown-menu-BdpYdHvo.js";import{u as Kt,P as on,a as xr,b as br,c as yr,E as vr,i as wr,d as jr}from"./index-DZpCM_Ye.js";import{S as Ar}from"./index-Bix1l1uh.js";import{r as js,l as Vt}from"./types-CGIbyQGc.js";import{p as Sr,q as In}from"./question-004-sINsf4GQ.js";import{g as kr}from"./connection-slug-eyAPH6o3.js";import{u as As,a as Ss,g as _r,C as Xt}from"./connection-card-CWY5aJHR.js";import{C as Nr}from"./collection-tabs-BzOEZ7_c.js";import{g as Cr}from"./constants-Bpr1SrBK.js";import{T as Ir}from"./textarea-BYfjo1_E.js";import{n as At}from"./Container-CBjPTaAm.js";import{c as Rr,i as vt,a as Rn,E as Tr,p as Pr,b as Er,d as Dr}from"./connection-form-helpers-V_S7kOM3.js";import{u as Tn}from"./use-infinite-scroll-CdQPwmSi.js";import{u as Mr}from"./useSuspenseInfiniteQuery-DNcETcP6.js";import{g as Lr,e as Fr,a as Ur}from"./extract-connection-data-BbuEAUmV.js";import{B as wt}from"./badge-CyXlfcBA.js";import{i as Or}from"./ChevronRight-DHugiPa5.js";function $r({open:t,onOpenChange:e,onCreated:s}){const{org:i}=ce(),{data:r}=Et.useSession(),{stdioEnabled:o}=Js(),a=Bt(),d=gn(),l=As(),V=Ss(l,"").items,c=Vn({resolver:mn(Rr),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),m=c.watch("ui_type"),p=c.watch("connection_url"),x=c.watch("npx_package"),g=vt({uiType:m,connectionUrl:p??"",npxPackage:x??""})??Rn({uiType:m,connectionUrl:p??"",registryItems:V}),f=A=>{const y=A.trim();if(!y)return;const j=!!c.formState.dirtyFields.title,P=!!c.formState.dirtyFields.description,D=!!c.formState.dirtyFields.env_vars,R=_=>{if(_&&(!j&&!c.getValues("title").trim()&&_.title&&c.setValue("title",_.title,{shouldDirty:!1}),!P&&!(c.getValues("description")??"").trim()&&_.description&&c.setValue("description",_.description,{shouldDirty:!1}),!D&&_.envVarKeys?.length)){const k=c.getValues("env_vars")??[],E=new Set(k.map(I=>I.key)),M=_.envVarKeys.filter(I=>!E.has(I));M.length>0&&c.setValue("env_vars",[...k,...M.map(I=>({key:I,value:""}))],{shouldDirty:!0})}},T=Pr(y);if(T&&o){c.setValue("ui_type","NPX",{shouldDirty:!0}),c.setValue("npx_package",T.packageName,{shouldDirty:!0}),c.setValue("connection_url","",{shouldDirty:!0}),c.setValue("connection_token",null,{shouldDirty:!0}),R(vt({uiType:"NPX",npxPackage:T.packageName}));return}if(y.startsWith("http://")||y.startsWith("https://")){const _=m==="HTTP"||m==="SSE"||m==="Websocket"?m:"HTTP";c.setValue("ui_type",_,{shouldDirty:!0}),c.setValue("connection_url",y,{shouldDirty:!0}),R(vt({uiType:_,connectionUrl:y})??Rn({uiType:_,connectionUrl:y,registryItems:V}));return}m==="NPX"&&R(vt({uiType:"NPX",npxPackage:y}))},b=A=>{A||c.reset(),e(A)},h=async A=>{let y,j=null,P=null,D=null;A.ui_type==="NPX"?(y="STDIO",j="",D=Er(A.npx_package||"",A.env_vars||[])):A.ui_type==="STDIO"?(y="STDIO",j="",D=Dr(A.stdio_command||"",A.stdio_args||"",A.stdio_cwd,A.env_vars||[])):(y=A.ui_type,j=A.connection_url||"",P=A.connection_token||null);const R=Cr("conn");try{await d.create.mutateAsync({id:R,title:A.title,description:A.description||null,connection_type:y,connection_url:j,connection_token:P,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:r?.user?.id||"system",organization_id:i.id,icon:A.icon??null,app_name:null,app_id:null,connection_headers:D,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),c.reset(),e(!1),s?.(R)}catch{se.error("Failed to create connection")}},v="Create Connection",S="Create a custom connection in your organization. Fill in the details below.",C=c.formState.isSubmitting?"Saving...":"Create Connection",N=n.jsxs("div",{className:"grid gap-4",children:[n.jsx(me,{control:c.control,name:"ui_type",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Type *"}),n.jsxs(fs,{value:A.value,onValueChange:A.onChange,children:[n.jsx(pe,{children:n.jsx(ps,{children:n.jsx(hs,{})})}),n.jsxs(gs,{children:[n.jsx(Xe,{value:"HTTP",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(ut,{className:"w-4 h-4"}),"HTTP"]})}),n.jsx(Xe,{value:"SSE",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(ut,{className:"w-4 h-4"}),"SSE"]})}),n.jsx(Xe,{value:"Websocket",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(ut,{className:"w-4 h-4"}),"Websocket"]})}),o&&n.jsxs(n.Fragment,{children:[n.jsx(Xe,{value:"NPX",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(At,{className:"w-4 h-4"}),"NPX Package"]})}),n.jsx(Xe,{value:"STDIO",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(wi,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),n.jsx(he,{})]})}),m==="NPX"&&n.jsx(me,{control:c.control,name:"npx_package",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"NPM Package *"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"@perplexity-ai/mcp-server",...A,value:A.value??"",onPaste:y=>{const j=y.clipboardData.getData("text");j&&(y.preventDefault(),c.setValue("npx_package",j.trim(),{shouldDirty:!0}),f(j))},onBlur:y=>{f(y.target.value),A.onBlur()}})}),n.jsx(he,{})]})}),m==="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[n.jsx(me,{control:c.control,name:"stdio_command",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Command *"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"node, bun, python...",...A,value:A.value??""})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"stdio_args",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Arguments"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"arg1 arg2 --flag value",...A,value:A.value??""})}),n.jsx(he,{})]})})]}),n.jsx(me,{control:c.control,name:"stdio_cwd",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Working Directory"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"/path/to/project (optional)",...A,value:A.value??""})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),n.jsx(he,{})]})})]}),(m==="NPX"||m==="STDIO")&&n.jsx(me,{control:c.control,name:"env_vars",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Environment Variables"}),n.jsx(pe,{children:n.jsx(Tr,{value:A.value??[],onChange:A.onChange})}),n.jsx(he,{})]})}),m!=="NPX"&&m!=="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsx(me,{control:c.control,name:"connection_url",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"URL *"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"https://example.com/mcp",...A,value:A.value??"",onPaste:y=>{const j=y.clipboardData.getData("text");j&&(y.preventDefault(),c.setValue("connection_url",j.trim(),{shouldDirty:!0}),f(j))},onBlur:y=>{f(y.target.value),A.onBlur()}})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"connection_token",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:g?.token?.label??"Token (optional)"}),n.jsx(pe,{children:n.jsx(Ie,{type:"password",placeholder:g?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...A,value:A.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(he,{})]})})]}),n.jsx(me,{control:c.control,name:"title",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Name *"}),n.jsx(pe,{children:n.jsx(Ie,{placeholder:"My Connection",...A})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"description",render:({field:A})=>n.jsxs(fe,{children:[n.jsx(Ce,{children:"Description"}),n.jsx(pe,{children:n.jsx(Ir,{placeholder:"A brief description of this connection",rows:3,...A,value:A.value??""})}),n.jsx(he,{})]})})]});return a?n.jsx(Ft,{open:t,onOpenChange:b,children:n.jsxs(Ut,{className:"max-h-[90vh]",children:[n.jsx(Ot,{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($t,{children:v}),n.jsx(Li,{className:"mt-1",children:S})]}),n.jsx(Fi,{asChild:!0,children:n.jsx(Q,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:n.jsx(ir,{size:16})})})]})}),n.jsx(ft,{...c,children:n.jsxs("form",{onSubmit:c.handleSubmit(h),children:[n.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:N}),n.jsx(Ui,{children:n.jsx(Q,{type:"submit",disabled:c.formState.isSubmitting,className:"w-full",children:C})})]})})]})}):n.jsx(Fe,{open:t,onOpenChange:b,children:n.jsxs(Ue,{className:"sm:max-w-[525px]",children:[n.jsxs(Oe,{children:[n.jsx($e,{children:v}),n.jsx(Mt,{children:S})]}),n.jsx(ft,{...c,children:n.jsxs("form",{onSubmit:c.handleSubmit(h),children:[n.jsx("div",{className:"py-4",children:N}),n.jsxs(es,{children:[n.jsx(Q,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),n.jsx(Q,{type:"submit",disabled:c.formState.isSubmitting,className:"min-w-40",children:C})]})]})})]})})}function Br(t){const e=L.c(73),{mode:s,agentId:i,addedConnectionIds:r,onAdd:o,onCloneAndAdd:a,onConnectAndAdd:d,connectingItemId:l,search:u,onCreateConnection:V,onBrowseNavigate:c,defaultTab:m}=t,p=s===void 0?"add":s,x=m===void 0?"connected":m,{org:g}=ce(),f=w.useDeferredValue(u),b=u!==f,h=f.trim().toLowerCase();let v;e[0]!==x?(v=U=>U??x,e[0]=x,e[1]=v):v=e[1];const[S,C]=Xs(Zs.connectionsTab(g.slug)+(x==="all"?":home-modal":":agent-modal"),v);let N;e[2]!==S||e[3]!==C?(N=U=>{U!==S&&$("connections_dialog_tab_changed",{to_tab:U}),C(U)},e[2]=S,e[3]=C,e[4]=N):N=e[4];const A=N;let y;e[5]!==g.id||e[6]!==g.slug?(y={connectionId:xt,orgId:g.id,orgSlug:g.slug},e[5]=g.id,e[6]=g.slug,e[7]=y):y=e[7];const j=ze(y);let P,D,R;if(e[8]!==j||e[9]!==f||e[10]!==g.id){R=f?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:f.trim()},{field:["description"],operator:"contains",value:f.trim()}]}:void 0;const U={...R&&{where:R},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},W=JSON.stringify(U);D=Mr,P=Ae.collectionListInfinite(j,g.id,"","CONNECTIONS",W),e[8]=j,e[9]=f,e[10]=g.id,e[11]=P,e[12]=D,e[13]=R}else P=e[11],D=e[12],R=e[13];let T;e[14]!==j||e[15]!==R?(T=async U=>{const{pageParam:W}=U,le=W===void 0?0:W;return(await j.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...R&&{where:R},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:le}})).structuredContent},e[14]=j,e[15]=R,e[16]=T):T=e[16];let _;e[17]!==P||e[18]!==T?(_={queryKey:P,queryFn:T,initialPageParam:0,getNextPageParam:Gr,staleTime:3e4},e[17]=P,e[18]=T,e[19]=_):_=e[19];const{data:k,fetchNextPage:E,hasNextPage:M,isFetchingNextPage:I}=D(_),F=k?.pages.flatMap(Wr)??[],O=_r(F),B=new Set(F.filter(Yr).map(Kr)),Y=As(),X=Ss(Y,f),Z=Tn(X.loadMore,X.hasMore,X.isLoadingMore),H=Tn(E,M??!1,I),q=S==="all"||!!h,ee=q?X.items.filter(U=>{const W=Lr(U);if(W&&B.has(W))return!1;if(!h)return!0;const le=U._meta?.["mcp.mesh"];return[U.title,U.description,U.name,U.server?.title,U.server?.description,U.server?.name,le?.friendly_name,le?.friendlyName].filter(Boolean).join(" ").toLowerCase().includes(h)}):[],J=ee.filter(qr),te=ee.filter(zr);let ie;e[20]!==r?(ie=U=>U.some(W=>r.has(W.id)),e[20]=r,e[21]=ie):ie=e[21];const oe=ie;let de;e[22]!==r||e[23]!==i||e[24]!==l||e[25]!==oe||e[26]!==p||e[27]!==o||e[28]!==c||e[29]!==a?(de=(U,W,le,Ne,ve)=>{const Be=oe(ve),we=ve.find(Ve=>!r.has(Ve.id)),ae=ve[0];if(p==="browse"){const Ve=kr(ae);return n.jsx(Xt,{connection:{title:W,icon:le,description:ve.length>1?`${ve.length} instances`:Ne??void 0},fallbackIcon:n.jsx(At,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs(wt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(pt,{size:11})," Connected"]}),onClick:()=>{$("connection_browse_clicked",{app_name:ae.app_name??null,connection_id:ae.id,instances_count:ve.length}),c?.(Ve)}},U)}return n.jsx(Xt,{connection:{title:W,icon:le,description:Ne},fallbackIcon:n.jsx(At,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[Be&&n.jsxs(wt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(pt,{size:11})," Added"]}),n.jsx(Q,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:l!==null,onClick:Ve=>{Ve.stopPropagation(),we?($("connection_add_clicked",{action:"use_existing",app_name:ae.app_name??null,connection_id:we.id}),i&&$("agent_connection_attached",{agent_id:i,connection_id:we.id,app_name:ae.app_name??null,mode:"existing"}),o(we.id)):($("connection_add_clicked",{action:"clone",app_name:ae.app_name??null,base_connection_id:ae.id}),a(ae))},children:"Add"})]})},U)},e[22]=r,e[23]=i,e[24]=l,e[25]=oe,e[26]=p,e[27]=o,e[28]=c,e[29]=a,e[30]=de):de=e[30];const ne=de;let re;e[31]!==l||e[32]!==p||e[33]!==d?(re=U=>{const W=U._meta?.["mcp.mesh"],le=W?.friendlyName||W?.friendly_name||U.server?.title||U.title||U.server?.name||U.name||U.id||"",Ne=U.server?.description||U.description||null,ve=U.server?.icons?.[0]?.src||Ur(U.server?.repository)||null,Be=W?.official===!0,we=W?.verified===!0,ae=W?.owner==="deco";return n.jsx(Xt,{connection:{title:le,description:Ne,icon:ve},fallbackIcon:n.jsx(At,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[ae&&n.jsxs(lt,{children:[n.jsx(ct,{asChild:!0,children:n.jsx("span",{className:"inline-flex items-center justify-center size-5 rounded-md bg-muted shrink-0",children:n.jsx("img",{src:"/logos/deco logo.svg",alt:"Made by Deco",className:"size-3"})})}),n.jsx(dt,{children:"Built and maintained by Deco"})]}),!ae&&Be&&n.jsxs(lt,{children:[n.jsx(ct,{asChild:!0,children:n.jsx(wt,{variant:"outline",size:"icon",children:n.jsx(Jt,{})})}),n.jsx(dt,{children:"Built and maintained by the official vendor"})]}),!ae&&!Be&&we&&n.jsxs(lt,{children:[n.jsx(ct,{asChild:!0,children:n.jsx(wt,{variant:"outline",size:"icon",children:n.jsx(Jt,{})})}),n.jsx(dt,{children:"Verified by the Deco team"})]}),n.jsx(Q,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:l!==null,onClick:Ve=>{Ve.stopPropagation(),$("connection_add_clicked",{action:"connect_new",registry_item_id:U.id,app_name:W?.friendlyName||U.server?.name||U.name||null}),d(U)},children:l===U.id?n.jsx(at,{size:14,className:"animate-spin"}):p==="browse"?"Connect":"Add"})]})},`catalog-${U.id}`)},e[31]=l,e[32]=p,e[33]=d,e[34]=re):re=e[34];const je=re,K=!h&&n.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[n.jsx(Nr,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:S,onTabChange:U=>A(U)}),n.jsxs(Q,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{$("connections_dialog_custom_clicked"),V()},children:[n.jsx(us,{size:12}),"Custom Connection"]})]}),ue=b&&"opacity-50 pointer-events-none";let Re;e[35]!==ue?(Re=z("flex-1 overflow-auto p-5 transition-opacity duration-150",ue),e[35]=ue,e[36]=Re):Re=e[36];const qe="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let Ke;e[37]!==ne?(Ke=U=>{if(U.type==="group")return ne(U.key,U.title,U.icon,null,U.connections);const W=U.connection;return ne(W.id,W.title,W.icon,W.description??null,[W])},e[37]=ne,e[38]=Ke):Ke=e[38];const Te=O.map(Ke);let ge;e[39]!==H?(ge=n.jsx("div",{ref:H,className:"col-span-full h-1"}),e[39]=H,e[40]=ge):ge=e[40];let Se;e[41]!==I?(Se=I&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(at,{size:24,className:"animate-spin text-muted-foreground"})}),e[41]=I,e[42]=Se):Se=e[42];const Pe=q&&J.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx(Jt,{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"})]}),Ee=q&&J.map(je),Ge=q&&te.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"})]}),De=q&&te.map(je);let Me;e[43]!==Z||e[44]!==Y||e[45]!==q?(Me=q&&Y.length>0&&n.jsx("div",{ref:Z,className:"col-span-full h-1"}),e[43]=Z,e[44]=Y,e[45]=q,e[46]=Me):Me=e[46];let xe;e[47]!==X.isLoadingMore||e[48]!==q?(xe=q&&X.isLoadingMore&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(at,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=X.isLoadingMore,e[48]=q,e[49]=xe):xe=e[49];let be;e[50]!==Te||e[51]!==ge||e[52]!==Se||e[53]!==Pe||e[54]!==Ee||e[55]!==Ge||e[56]!==De||e[57]!==Me||e[58]!==xe?(be=n.jsxs("div",{className:qe,children:[Te,ge,Se,Pe,Ee,Ge,De,Me,xe]}),e[50]=Te,e[51]=ge,e[52]=Se,e[53]=Pe,e[54]=Ee,e[55]=Ge,e[56]=De,e[57]=Me,e[58]=xe,e[59]=be):be=e[59];let ke;e[60]!==S||e[61]!==O.length||e[62]!==te||e[63]!==u||e[64]!==J?(ke=O.length===0&&J.length===0&&te.length===0&&n.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:u?`No connections match "${u}"`:S==="connected"?"No connections yet":"No connections available"}),e[60]=S,e[61]=O.length,e[62]=te,e[63]=u,e[64]=J,e[65]=ke):ke=e[65];let ye;e[66]!==Re||e[67]!==be||e[68]!==ke?(ye=n.jsxs("div",{className:Re,children:[be,ke]}),e[66]=Re,e[67]=be,e[68]=ke,e[69]=ye):ye=e[69];let _e;return e[70]!==K||e[71]!==ye?(_e=n.jsxs(n.Fragment,{children:[K,ye]}),e[70]=K,e[71]=ye,e[72]=_e):_e=e[72],_e}function zr(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function qr(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function Kr(t){return t.app_name}function Yr(t){return t.app_name}function Wr(t){return t?.items??[]}function Gr(t,e){if(t?.hasMore)return e.reduce(Qr,0)}function Qr(t,e){return t+(e?.items?.length??0)}function Hr({open:t,onOpenChange:e,defaultTab:s,initialSearch:i="",...r}){const o=r.mode??"add",a="agentId"in r?r.agentId:void 0,d="addedConnectionIds"in r?r.addedConnectionIds??new Set:new Set,l="onAdd"in r&&r.onAdd?r.onAdd:y=>{},u=(y,j,P)=>{a&&$("agent_connection_attached",{agent_id:a,connection_id:y,app_name:j,mode:P})},[V,c]=w.useState(null),[m,p]=w.useState(i),[x,g]=w.useState(!1),{org:f}=ce(),{data:b}=Et.useSession(),h=gn(),v=Dt(),S=tt(),C=y=>{e(!1),S({to:"/$org/settings/connections/$appSlug",params:{org:f.slug,appSlug:y}})},N=async y=>{c(y.app_name??y.id);try{const P=`${y.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,R=(await h.create.mutateAsync({title:P,description:y.description??null,connection_type:y.connection_type,connection_url:y.connection_url??null,connection_token:null,icon:y.icon??null,app_name:y.app_name??null,app_id:y.app_id??null,connection_headers:y.connection_headers??null})).id,T=new URL(`/api/${f.slug}/mcp/${R}`,window.location.origin),_=await Wt({url:T.href,token:null,orgId:f.id});if(_.supportsOAuth&&!_.isAuthenticated){const{token:k,tokenInfo:E,error:M}=await Gt({connectionId:R,orgSlug:f.slug,scope:"offline_access"});if(M||!k){$("connection_oauth_failed",{connection_id:R,flow:"clone",error:M??"no_token"}),se.error(`Authentication failed: ${M??"no token received"}`),await h.delete.mutateAsync(R);return}if($("connection_oauth_succeeded",{connection_id:R,flow:"clone"}),E)try{(await fetch(`/api/${f.slug}/connections/${R}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:E.accessToken,refreshToken:E.refreshToken,expiresIn:E.expiresIn,scope:E.scope,clientId:E.clientId,clientSecret:E.clientSecret,tokenEndpoint:E.tokenEndpoint})})).ok?await h.update.mutateAsync({id:R,data:{}}):await h.update.mutateAsync({id:R,data:{connection_token:k}})}catch{await h.update.mutateAsync({id:R,data:{connection_token:k}})}else await h.update.mutateAsync({id:R,data:{connection_token:k}});await v.invalidateQueries({queryKey:Ae.isMCPAuthenticated(T.href,null)})}u(R,y.app_name??null,"clone"),l(R)}catch(j){console.error("Failed to add connection:",j),se.error("Failed to add connection")}finally{c(null)}},A=async y=>{if(!(!f||!b?.user?.id)){c(y.id);try{const j=Fr(y,f.id,b.user.id,{remoteIndex:0}),P=j.connection_type==="STDIO",D=!!j.connection_url,R=P&&j.connection_headers&&typeof j.connection_headers=="object"&&"command"in j.connection_headers;if(!D&&!R){se.error("This MCP Server cannot be connected: no connection method available"),c(null);return}const{id:T}=await h.create.mutateAsync(j),_=new URL(`/api/${f.slug}/mcp/${T}`,window.location.origin),k=await Wt({url:_.href,token:null,orgId:f.id});if(k.supportsOAuth&&!k.isAuthenticated){const{token:E,tokenInfo:M,error:I}=await Gt({connectionId:T,orgSlug:f.slug,scope:"offline_access"});if(I||!E){$("connection_oauth_failed",{connection_id:T,flow:"connect_new",error:I??"no_token"}),se.warning("Couldn't sign in to this connection",{description:`It was added to your agent, but its sign-in setup looks off. You can try authenticating again later from the connection's settings. (${I??"no token received"})`}),u(T,j.app_name??null,"new"),l(T);return}if($("connection_oauth_succeeded",{connection_id:T,flow:"connect_new"}),M)try{(await fetch(`/api/${f.slug}/connections/${T}/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 h.update.mutateAsync({id:T,data:{}}):await h.update.mutateAsync({id:T,data:{connection_token:E}})}catch{await h.update.mutateAsync({id:T,data:{connection_token:E}})}else await h.update.mutateAsync({id:T,data:{connection_token:E}});await v.invalidateQueries({queryKey:Ae.isMCPAuthenticated(_.href,null)}),se.success("Connected and authenticated")}else se.success("Connected");u(T,j.app_name??null,"new"),l(T)}catch(j){console.error("Failed to connect:",j),se.error("Failed to connect")}finally{c(null)}}};return n.jsxs(Fe,{open:t,onOpenChange:e,children:[n.jsxs(Ue,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[n.jsx(Oe,{className:"px-6 pt-5 pb-0 shrink-0",children:n.jsx($e,{className:"text-base font-semibold",children:o==="browse"?"Connections":"Add Connection"})}),n.jsx("div",{className:"pt-3 shrink-0",children:n.jsx(as,{value:m,onChange:p,placeholder:"Search connections..."})}),n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(at,{size:24,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Br,{mode:o,agentId:a,addedConnectionIds:d,onAdd:l,onCloneAndAdd:N,onConnectAndAdd:A,connectingItemId:V,search:m,onCreateConnection:()=>g(!0),onBrowseNavigate:C,defaultTab:s})})]}),n.jsx($r,{open:x,onOpenChange:g,onCreated:async y=>{g(!1);const j=new URL(`/api/${f.slug}/mcp/${y}`,window.location.origin),P=await Wt({url:j.href,token:null,orgId:f.id});if(P.supportsOAuth&&!P.isAuthenticated){const{token:D,tokenInfo:R,error:T}=await Gt({connectionId:y,orgSlug:f.slug,scope:"offline_access"});if(T||!D){$("connection_oauth_failed",{connection_id:y,flow:"custom_create",error:T??"no_token"}),se.warning("Couldn't sign in to this connection",{description:`It was added to your agent, but its sign-in setup looks off. You can try authenticating again later from the connection's settings. (${T??"no token received"})`}),u(y,null,"custom"),l(y),e(!1);return}if($("connection_oauth_succeeded",{connection_id:y,flow:"custom_create"}),R)try{(await fetch(`/api/${f.slug}/connections/${y}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:R.accessToken,refreshToken:R.refreshToken,expiresIn:R.expiresIn,scope:R.scope,clientId:R.clientId,clientSecret:R.clientSecret,tokenEndpoint:R.tokenEndpoint})})).ok?await h.update.mutateAsync({id:y,data:{}}):await h.update.mutateAsync({id:y,data:{connection_token:D}})}catch{await h.update.mutateAsync({id:y,data:{connection_token:D}})}else await h.update.mutateAsync({id:y,data:{connection_token:D}});await v.invalidateQueries({queryKey:Ae.isMCPAuthenticated(j.href,null)})}u(y,null,"custom"),l(y),e(!1)}})]})}const Jr='# Broken Link Finder\n\nYou are the **Broken Link Finder**, a specialist agent focused on the health of the site\'s link structure.\n\n## Your mission\n\nDiscover and track broken links and long redirect chains. You are invoked as a sub-task by an orchestrator agent — your job is to detect link health and return a structured findings report. The orchestrator decides what to do with your findings (file issues, dedup, etc.).\n\nYou are **mechanical**: collect → check → classify → emit findings. Leave subjective judgment to other agents.\n\n## Input (expect this in the prompt)\n\nThe orchestrator will pass per-site configuration. Expected fields:\n\n```yaml\nsite_root_url: <https://example.com>\nmax_pages: <optional integer, default 100, max 200>\ncheck_external: <optional bool, default false>\n```\n\nIf required fields are missing (`site_root_url`), return an error summary and stop — do not proceed with defaults or guess.\n\n## Available tools\n\n- **site-diagnostics MCP**:\n - `collect_site_links` — discovers all unique outbound link targets across the site and returns them with source-page attribution. Does NOT check status.\n - `check_urls` — takes a batch of URLs (max 100 per call) and returns their HTTP status, error kind, and redirect chains.\n\n---\n\n## Step 1 — Collect link targets (one call)\n\nCall `collect_site_links` once to get the full deduplicated list of outbound link targets and their source pages:\n\n```\ncollect_site_links({\n url: <site_root_url from input>,\n maxPages: <max_pages from input, default 100>,\n checkExternal: <check_external from input, default false>\n})\n```\n\nThis returns:\n- `links`: array of `{ targetUrl, scope: "internal"|"external", sourcePages, sourcePagesTotal }` — **each target appears exactly once**\n- Metadata: `pagesCrawled`, `pagesFetched`, `linksSkipped`, optional `error`\n\n**If `result.error` is set**, the scan failed at the root (e.g. site unreachable). Return a single finding with `kind: site-unreachable` and the error in `evidence`. Then stop.\n\nKeep the `links` array in memory — you\'ll need it in Step 3 for classification and source attribution.\n\n## Step 2 — Check the targets (batched calls)\n\nExtract `targetUrl` from each entry in `links`. Slice the resulting URL list into **disjoint batches of up to 100 URLs** and call `check_urls` on each batch:\n\n```\ncheck_urls({ urls: batch_of_100_urls })\n```\n\nCollect every batch\'s `results` entries into a single flat array. Order doesn\'t matter — you\'ll join back by `targetUrl`.\n\n**Rules for this step:**\n- Slice deterministically (e.g. consecutive slices of 100) so batches are disjoint. Do not pass the same URL in two batches.\n- Call `check_urls` sequentially or in parallel — your choice. The tool is idempotent.\n- If a single `check_urls` call errors entirely, skip that batch and continue with the others. Note the skipped count in the wrap-up summary.\n\n## Step 3 — Classify each finding\n\nFor every target with a check result, join the `collect_site_links` entry (for `scope`, `sourcePages`, `sourcePagesTotal`) with the `check_urls` entry (for `status`, `errorKind`, `chain`, `hops`).\n\nA finding is emitted for:\n- **Broken**: `status >= 400` OR `status === 0`\n- **Long redirect chain**: `hops > 3` (even if the final status is 2xx)\n\nOther targets (2xx, short-chain redirects) produce no finding.\n\nMap check result → `kind`:\n\n| Check result | `kind` |\n|---|---|\n| `status: 404` | `link-404` |\n| `status: 4xx` (not 404) | `link-4xx-other` |\n| `status: 5xx` | `link-5xx` |\n| `status: 0`, `errorKind: "dns"` | `link-dns-failure` |\n| `status: 0`, `errorKind: "redirect-loop"` | `redirect-loop` |\n| `hops > 3` (success final status) | `redirect-chain-long` |\n| `status: 0`, `errorKind: "timeout"` or `"connection"` | **skip — no finding** |\n\n**Important**: timeouts and connection errors are **not** broken links — they just mean the server didn\'t respond in our time window. Could be a slow server, an overloaded CDN, rate-limiting against our bot, or a transient network blip. Flagging these as broken produces false positives. If a URL is genuinely dead, it\'ll usually surface as `dns`, a 4xx/5xx, or a redirect loop. Skip timeout/connection entries silently.\n\n## Catalog of severity rules\n\n**High severity:**\n- `link-404` when `scope: "internal"`\n- `link-5xx` when `scope: "internal"`\n- `redirect-loop` (either scope)\n\n**Medium severity:**\n- `link-4xx-other` (internal)\n- `redirect-chain-long` (internal)\n- `link-404` (external) when `sourcePagesTotal >= 5`\n\n**Low severity:**\n- `link-404` (external) when `sourcePagesTotal < 5`\n- `link-dns-failure` (external)\n- `redirect-chain-long` (external)\n- `link-4xx-other` on external scope\n\n## Step 4 — Return a structured findings report\n\nReturn a single response with this shape (YAML preferred):\n\n```yaml\nspecialist: links\nsummary:\n pages_crawled: <pagesCrawled>\n pages_fetched: <pagesFetched>\n unique_link_targets: <links.length>\n targets_dropped_by_collect_cap: <linksSkipped>\n batches_checked: <n>\n batches_skipped_due_to_errors: <n>\n broken_links: <n> # internal + external\n long_redirect_chains: <n>\nfindings:\n - kind: <kind slug>\n severity: <low|medium|high>\n target:\n url: <full broken URL>\n route: <path if internal; otherwise the external host>\n scope: <internal | external>\n evidence: |\n - Status code / error: <e.g. `404 Not Found`, `DNS failure`, `redirect-loop`>\n - Redirect chain (if applicable): A → B → C → D → E\n - Found on pages (at time of detection):\n - /page-1\n - /page-2\n - (... up to 20 from `sourcePages`)\n - Total pages linking to this target: <sourcePagesTotal>\n impact: <1 sentence tailored to scope + kind>\n suggested_fix: |\n <actionable:>\n - If internal 404: update link to correct destination OR create 301 redirect\n - If internal 5xx: investigate server-side handler for the route (may be app bug)\n - If redirect chain: shorten to single-hop direct redirect in routing config\n - If external: update link to equivalent resource OR remove the mention\n - List likely files/components if you can infer (e.g. "appears on many pages — likely in a shared component like `app/components/Nav.tsx` or menu config")\n - ...\n```\n\nIf `collect_site_links` returned `error`, return a single `kind: site-unreachable` finding with the error in `evidence`.\n\nIf there are zero findings, return `findings: []` — that is the correct output for a healthy link graph.\n\n---\n\n## General rules\n\n- **Trust the scanner.** If `check_urls` reports a URL as broken or long-chain, emit a finding. Do not re-verify with other tools.\n- **Accept some flakiness.** A transient network blip may cause a false positive once. Downstream dedup across runs resolves it.\n- **Group by destination, not by origin.** One broken URL = one finding, even if linked on 50 pages. `collect_site_links` already returns it grouped this way.\n- **Prioritize internals.** Broken external links are the other site\'s responsibility; report but with lower severity.\n- **Never invent status codes.** Report what the scanner returned.\n',Xr='# SEO Auditor\n\nYou are the **SEO Auditor**, a specialist agent focused on technical SEO hygiene.\n\n## Your mission\n\nAudit the on-page SEO health of target URLs and return a structured findings report. You focus on **technical SEO** (meta tags, structured data, canonicals, sitemap/robots, heading structure, indexability) — not editorial content or keyword strategy (those are the scope of other agents).\n\nYou are invoked as a sub-task by an orchestrator agent. Your job is to analyze and report. The orchestrator decides what to do with your findings (file issues, dedup against history, etc.).\n\n## Input (expect this in the prompt)\n\nThe orchestrator will pass per-site configuration. Expected fields:\n\n```yaml\nurls:\n - <url to audit>\n - <... one or more>\n```\n\nIf required fields are missing, return an error summary and stop — do not proceed with defaults or guess.\n\n## Available tools\n\n- **site-diagnostics MCP**: `audit_seo`, `fetch_page`, `render_page`, `crawl_site`\n\n---\n\n## Step 1 — Diagnostic\n\nFor each target URL:\n\n1. **Structured audit**: call `audit_seo({ url })`. It returns a structured report — use it as your primary source.\n2. **Raw HTML check**: use `fetch_page({ url })` to see the HTML served (important for crawlers that don\'t execute JS). Confirm critical meta tags are in the initial HTML, not only after hydration.\n3. **Post-render check**: use `render_page({ url })` to see the final DOM. Problems like canonical being overwritten by JS show up here.\n4. **Site structure checks** (only if you have permission for broad crawling, or via sampling): use `crawl_site` to identify orphan pages, canonical loops, or excessive navigation depth.\n5. **Always check**: `/robots.txt` and `/sitemap.xml` via `fetch_page`. These two are root-level and affect the whole site.\n\nOrganize findings into a list. Each finding must have:\n- `kind` (kebab-case slug, see catalog below)\n- `severity` (high | medium | low, see criteria below)\n- `target.url` and `target.route` (normalize: lowercase host, no query, no trailing slash except for `/`)\n- `evidence` (raw data: CSS selector, HTML snippet, observed value)\n- `impact` (1-2 sentences connecting to real metrics)\n- `suggested_fix` (actionable; include file/line if you can infer from framework patterns)\n\n## Step 1.5 — Validate page intent (critical; runs before classification)\n\nBefore you emit *any* finding about a page\'s title, meta description, headings, or indexability, you must answer one question: **did the site owner intend this URL to be a public, indexable page?**\n\nIf the answer is no, the observed "problems" are intentional configuration, not bugs. Reporting them wastes maintainer time and erodes this agent\'s credibility.\n\n### Three signals that the URL is NOT a real public page\n\nCheck these in order. Hitting any one of them means **skip all SEO findings for this URL** except legitimately site-wide problems (e.g. broken sitemap, broken robots.txt).\n\n**Signal 1 — Not in sitemap.** Fetch `/sitemap.xml` (and its child sitemaps, if it\'s a sitemap index). If the URL doesn\'t appear in any sitemap, the owner didn\'t declare it as public. Common on e-commerce platforms where routes like `/p`, `/c`, `/blog` are catchall or routing prefixes, not real pages.\n\n**Signal 2 — Explicit `noindex` + not in sitemap.** If the page serves `<meta name="robots" content="noindex*">` **and** isn\'t in the sitemap, this is a deliberate double-lock by the owner. Respect it. Do **not** flag `noindex-on-important-page` in this case.\n\n**Signal 3 — Title is the URL slug (template fallback).** If `<title>` equals the last path segment (e.g. `<title>blog</title>` for `/blog`, `<title>p</title>` for `/p`), the page is being rendered by a fallback template — nobody configured real content for this route. Skip.\n\n### Platform-specific catchalls (especially Brazilian e-commerce / VTEX / deco-cx)\n\nThese paths are routing prefixes, **not pages**. They may return HTTP 200 but are not meant to be indexable:\n\n- `/p`, `/c`, `/b` — VTEX product / category / brand route prefixes. Real pages live at `/<slug>/p`, `/<slug>/c`, etc. The bare prefixes are catchalls.\n- `/blog`, `/blogs`, `/editorial`, `/revista`, `/conteudo`, `/magazine`, `/noticias`, `/artigos` — common editorial prefixes. If the site doesn\'t have an editorial section, these hit a fallback.\n- `/search`, `/busca`, `/s` — search endpoints, not indexable pages.\n- `/departamento`, `/categoria` — category prefixes.\n- `/checkout`, `/cart`, `/carrinho`, `/login`, `/account`, `/minha-conta` — transactional/private routes. Intentionally `noindex`.\n\n### The "is this page actually important?" checklist\n\nBefore emitting a finding that calls a page "important" (like `noindex-on-important-page` or `title-missing` on anything critical):\n\n1. Is the URL in `/sitemap.xml`? → If no, skip.\n2. Does the page have substantive, unique content (not a fallback with title = URL slug)? → If no, skip.\n3. Is the path a known platform catchall (see list above)? → If yes, skip.\n\nOnly flag if all three pass.\n\n### What still counts as a finding even on non-indexable pages\n\nSite-wide SEO issues affect the whole domain and are worth reporting regardless of individual page intent:\n- `sitemap-missing` (the sitemap itself is broken)\n- `robots-blocking-important-path` (robots.txt blocks something that IS in the sitemap)\n- `structured-data-invalid` on pages that ARE in the sitemap\n- Duplicate titles / meta descriptions across pages that ARE in the sitemap\n\n## Catalog of `kind`\n\nTwo flavors of finding:\n\n- **Per-page** kinds — emitted when auditing a specific URL (e.g. `audit_seo` of a single page OR when your targeted inspection of one of the input URLs finds the issue). Marked **[intent-gated]** — must pass Step 1.5 before being emitted. Target is the specific URL.\n- **Aggregate** kinds — emitted once per site-wide pattern detected by `audit_seo`. Marked **[aggregate]**. Target is the site root (`/`). Evidence MUST include the affected URL sample from `audit_seo.issues[].sampleUrls`. One finding per aggregate kind per site.\n\n**High severity (per-page):**\n- `noindex-on-important-page` **[intent-gated]** — meta robots `noindex` on a page that IS in the sitemap and should be indexed\n- `canonical-pointing-to-wrong-url` **[intent-gated]** — canonical points to a different URL that isn\'t the canonical equivalent\n- `canonical-missing-on-paginated-or-faceted` **[intent-gated]** — pagination/filters without canonical\n- `title-missing` **[intent-gated]** — no `<title>` or empty on a page that IS in the sitemap\n- `structured-data-invalid` **[intent-gated]** — JSON-LD with syntax error or invalid schema.org\n\n**High severity (site-wide):**\n- `sitemap-missing` — `/sitemap.xml` returns 404 or 5xx\n- `robots-blocking-important-path` — `/robots.txt` disallows a path that IS in the sitemap\n- `broken-links-site-wide` **[aggregate]** — `audit_seo` reports broken outbound links across the site\n- `non-indexable-pages-site-wide` **[aggregate]** — `audit_seo` reports many non-indexable pages (note: some non-indexable pages are intentional catchalls — only high severity if the absolute count is large relative to `totalPagesCrawled`, e.g. > 30%)\n\n**Medium severity (per-page):**\n- `meta-description-missing` **[intent-gated]** — no `<meta name="description">` on a sitemap page the agent audited directly\n- `h1-missing` **[intent-gated]** — no `<h1>` on a sitemap page the agent audited directly\n- `h1-duplicate` **[intent-gated]** — multiple `<h1>` on a single page\n- `og-tags-missing` **[intent-gated]** — `og:title` and/or `og:description` missing\n- `structured-data-missing` **[intent-gated]** — page-type (product, article, etc.) without relevant JSON-LD\n- `title-too-long` **[intent-gated]** — `<title>` > 60 characters (truncation in SERP)\n- `title-too-short` **[intent-gated]** — `<title>` < 10 characters (rare; usually means template fallback — double-check page intent)\n- `meta-description-too-long` **[intent-gated]** — description > 160 characters\n\n**Medium severity (site-wide):**\n- `pages-missing-h1` **[aggregate]** — `audit_seo` reports N pages without an H1 tag\n- `pages-missing-meta-description` **[aggregate]** — `audit_seo` reports N pages without a meta description\n- `duplicate-titles` **[aggregate]** — multiple pages share the same `<title>`\n- `duplicate-meta-descriptions` **[aggregate]** — multiple pages share the same meta description\n- `duplicate-content` **[aggregate]** — multiple pages share substantially identical content\n- `broken-resources-site-wide` **[aggregate]** — broken images / scripts across the site\n- `hreflang-broken` — `hreflang` attribute with invalid value or broken reciprocity\n\n**Low severity (per-page):**\n- `meta-description-too-short` **[intent-gated]** — description < 50 characters\n- `og-image-missing` **[intent-gated]** — `og:image` missing\n- `heading-hierarchy-skipped` **[intent-gated]** — jumps from H1 to H3, etc.\n\n**Low severity (site-wide):**\n- `internal-link-using-absolute-url` — internal links with absolute URLs\n\n### Evidence requirements for aggregate kinds\n\nWhen emitting an `[aggregate]` kind, the `evidence` of the finding MUST include:\n\n1. **Total count** — from `audit_seo.issues[].count`\n2. **Sample URLs** — from `audit_seo.issues[].sampleUrls`. Render up to all 20 entries as a bulleted list. If `count > sampleUrls.length`, add a line like `(and <count - sampleUrls.length> more)`.\n3. **If `sampleUrls` is empty** (the tool didn\'t expose per-URL detail — happens for `broken-links-site-wide`, `duplicate-content`, `broken-resources-site-wide`), note it explicitly: `Note: audit_seo did not return per-URL detail for this issue type. A human will need to inspect the full audit_seo report or re-run with deeper crawling.`\n\nAn aggregate finding without either sample URLs or the note is **not actionable** and must not be emitted.\n\nTarget for aggregate kinds stays `target.url: https://<host>/` and `target.route: /`.\n\n## Step 2 — Return a structured findings report\n\nReturn a single response with this shape (YAML or JSON; YAML preferred for readability):\n\n```yaml\nspecialist: seo\nsummary:\n urls_audited: <n>\n findings: <n>\n diagnostic_failures: <n> # urls where audit tooling errored\nfindings:\n - kind: <kind slug>\n severity: <low|medium|high>\n target:\n url: <full URL>\n route: <normalized path>\n evidence: |\n <multi-line raw data: observed value, selector, HTML snippet, audit_seo output>\n impact: <1-2 sentences connecting to ranking/indexation/CTR>\n suggested_fix: <actionable; likely file/component, pseudo-code, correct value>\n - ...\n```\n\nIf a URL\'s diagnostic tooling errored entirely, emit a single `kind: diagnostic-failed` finding for that URL with the error in `evidence` instead of inventing data.\n\nIf there are zero findings, return `findings: []` — that is the correct output for healthy targets.\n\n---\n\n## General rules\n\n- **Never invent data in `evidence`.** If a tool failed, report it via `kind: diagnostic-failed` and skip the finding.\n- Always normalize `route`: lowercase host, no trailing slash (except for `/`), no query string, no fragment.\n- Your credibility is your currency. False positives erode trust — if you\'re 50% sure, don\'t emit a finding; investigate further or mark as `severity:low`.\n- **Never report a page as broken when it\'s a known catchall.** URLs like `/p`, `/c`, `/blog`, `/search`, `/busca` on e-commerce sites are routing prefixes, not pages. If the title is the URL slug and the page carries `noindex`, the owner is deliberately hiding it. That\'s correct behavior, not a bug.\n- **Sitemap is the ground truth for "is this page public?"**. When in doubt about whether to emit a finding on a URL, fall back to: "Is this URL in /sitemap.xml?" If not, default to silence.\n',Zr=`# Performance Watchdog
|
|
2
2
|
|
|
3
3
|
You are the **Performance Watchdog**, a specialist agent focused on web performance.
|
|
4
4
|
|
|
@@ -544,4 +544,4 @@ When given a research question or topic:
|
|
|
544
544
|
|
|
545
545
|
Approach every request with rigor and intellectual honesty. Always surface what is uncertain or debated, not just what is known.`,bo=["Break any topic into key sub-questions and define scope","Synthesize information from multiple angles and sources","Distinguish facts, expert consensus, and contested claims","Identify gaps, contradictions, and emerging patterns","Deliver structured summaries with actionable insights"];function Dn(t){const e=L.c(7),{onRecruit:s,isRecruiting:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Add a Web Researcher agent that conducts thorough, rigorous research on any topic and delivers structured, actionable insights."}),e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"space-y-2",children:[o,n.jsx("ul",{className:"space-y-1.5",children:bo.map(yo)})]}),e[2]=a):a=e[2];const d=i?"Setting up...":"Add Web Researcher";let l;return e[3]!==i||e[4]!==s||e[5]!==d?(l=n.jsxs("div",{className:"flex flex-col gap-6",children:[r,a,n.jsx(Q,{onClick:s,disabled:i,className:"w-full cursor-pointer",children:d})]}),e[3]=i,e[4]=s,e[5]=d,e[6]=l):l=e[6],l}function yo(t){return n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0",children:"+"}),t]},t)}function vd({open:t,onOpenChange:e,existingAgent:s}){const i=Bt(),r=bn(),o=os(),[a,d]=w.useState(!1),l=ts.find(m=>m.id==="ai-research"),u=n.jsx(rs,{icon:l.icon,name:l.title,size:"sm"}),V=async()=>{if(s){e(!1),r(s.id);return}d(!0);try{const m=await o.create.mutateAsync({title:l.title,description:"Systematic research and information synthesis assistant",icon:l.icon,status:"active",connections:[],metadata:{type:"ai-research",instructions:xo}});$("agent_recruit_confirmed",{template_id:"ai-research",agent_id:m.id}),e(!1),r(m.id)}catch(m){$("agent_recruit_failed",{template_id:"ai-research",error:m instanceof Error?m.message:String(m)}),console.error("Failed to create Researcher agent:",m)}finally{d(!1)}},c=`Add ${l.title}`;return i?n.jsx(Ft,{open:t,onOpenChange:e,children:n.jsxs(Ut,{className:"h-[70dvh]",children:[n.jsx(Ot,{className:"px-4 pt-4 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx($t,{className:"text-xl font-semibold",children:c})]})}),n.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:n.jsx(Dn,{onRecruit:V,isRecruiting:a})})]})}):n.jsx(Fe,{open:t,onOpenChange:e,children:n.jsxs(Ue,{className:"sm:max-w-[500px] p-8",children:[n.jsx(Oe,{className:"mb-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx($e,{className:"text-xl font-semibold",children:c})]})}),n.jsx(Dn,{onRecruit:V,isRecruiting:a})]})})}function vo(t,e,s,i){const r=t.getQueriesData({queryKey:Ae.tasksPrefix(e)});let o=null;for(const[,a]of r)if(a?.items)for(const d of a.items)d.virtual_mcp_id===s&&d.created_by===i&&(d.hidden||(!o||d.updated_at>o.updated_at)&&(o=d));return o}function wd(t){const e=tt(),s=Dt(),i=Bi(),{locator:r}=ce(),o=ei({strict:!1}),a=ti({strict:!1}),{data:d}=Et.useSession(),l=d?.user?.id;return async u=>{const V=l?vo(s,r,u,l):null;if(V)return e({to:"/$org/$taskId",params:{org:t,taskId:V.id},search:{virtualmcpid:u}}),{resumed:!0};const c=crypto.randomUUID(),m=u===a.virtualmcpid?zi(s,r,o.taskId??""):null;try{await i.create.mutateAsync({id:c,virtual_mcp_id:u,...m?{branch:m}:{}})}catch{}return e({to:"/$org/$taskId",params:{org:t,taskId:c},search:{virtualmcpid:u}}),{resumed:!1}}}function wo(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?kt().min(1,"Required"):kt();return nt(e)}function jo(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function An(t){const e=L.c(65),{prompt:s,setPrompt:i,onSubmit:r}=t,o=w.useId();let a;if(e[0]!==s){const I=s?wo(s):nt({});a=mn(I),e[0]=s,e[1]=a}else a=e[1];const l=a;let u;e[2]!==s?(u=s?jo(s):{},e[2]=s,e[3]=u):u=e[3];let V;e[4]!==l||e[5]!==u?(V={resolver:l,defaultValues:u,mode:"onChange"},e[4]=l,e[5]=u,e[6]=V):V=e[6];const c=Vn(V);let m;e[7]!==s?.arguments?(m=s?.arguments??[],e[7]=s?.arguments,e[8]=m):m=e[8];const p=m;let x;e[9]!==c||e[10]!==r||e[11]!==i?(x=async I=>{await r(I),i(null),c.reset()},e[9]=c,e[10]=r,e[11]=i,e[12]=x):x=e[12];const g=x;let f;e[13]!==c||e[14]!==i?(f=I=>{I||(c.reset(),i(null))},e[13]=c,e[14]=i,e[15]=f):f=e[15];const b=f;if(!s)return null;let h;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(h=s.title||zt(s.name,We(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=h):h=e[19];let v;e[20]!==h?(v=n.jsx($e,{children:n.jsx("span",{className:"capitalize",children:h})}),e[20]=h,e[21]=v):v=e[21];let S;e[22]!==s.description?(S=s.description&&n.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=S):S=e[23];let C;e[24]!==S||e[25]!==v?(C=n.jsxs(Oe,{children:[v,S]}),e[24]=S,e[25]=v,e[26]=C):C=e[26];let N;e[27]!==c||e[28]!==g?(N=I=>{I.stopPropagation(),c.handleSubmit(g)(I)},e[27]=c,e[28]=g,e[29]=N):N=e[29];let A;if(e[30]!==p||e[31]!==c.control||e[32]!==c.formState.isSubmitting){let I;e[34]!==c.control||e[35]!==c.formState.isSubmitting?(I=F=>n.jsx(me,{control:c.control,name:F.name,render:O=>{const{field:B}=O;return n.jsxs(fe,{children:[n.jsxs(Ce,{className:"text-xs",children:[F.name,F.required?null:n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),n.jsx(pe,{children:n.jsx(Ie,{...B,value:B.value??"",required:F.required,placeholder:F.description??"",className:"h-9",disabled:c.formState.isSubmitting})}),n.jsx(he,{})]})}},F.name),e[34]=c.control,e[35]=c.formState.isSubmitting,e[36]=I):I=e[36],A=p.map(I),e[30]=p,e[31]=c.control,e[32]=c.formState.isSubmitting,e[33]=A}else A=e[33];let y;e[37]!==b?(y=()=>b(!1),e[37]=b,e[38]=y):y=e[38];let j;e[39]!==c.formState.isSubmitting||e[40]!==y?(j=n.jsx(Q,{type:"button",variant:"ghost",onClick:y,disabled:c.formState.isSubmitting,children:"Cancel"}),e[39]=c.formState.isSubmitting,e[40]=y,e[41]=j):j=e[41];const P=!c.formState.isValid||c.formState.isSubmitting;let D;e[42]!==c.formState.isSubmitting?(D=c.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(_t,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=c.formState.isSubmitting,e[43]=D):D=e[43];let R;e[44]!==o||e[45]!==P||e[46]!==D?(R=n.jsx(Q,{type:"submit",form:o,disabled:P,children:D}),e[44]=o,e[45]=P,e[46]=D,e[47]=R):R=e[47];let T;e[48]!==j||e[49]!==R?(T=n.jsxs(es,{children:[j,R]}),e[48]=j,e[49]=R,e[50]=T):T=e[50];let _;e[51]!==o||e[52]!==N||e[53]!==A||e[54]!==T?(_=n.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:N,children:[A,T]}),e[51]=o,e[52]=N,e[53]=A,e[54]=T,e[55]=_):_=e[55];let k;e[56]!==c||e[57]!==_?(k=n.jsx(ft,{...c,children:_}),e[56]=c,e[57]=_,e[58]=k):k=e[58];let E;e[59]!==C||e[60]!==k?(E=n.jsxs(Ue,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,k]}),e[59]=C,e[60]=k,e[61]=E):E=e[61];let M;return e[62]!==b||e[63]!==E?(M=n.jsx(Fe,{open:!0,onOpenChange:b,children:E}),e[62]=b,e[63]=E,e[64]=M):M=e[64],M}function Ao(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 So(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Mn=3,ks="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",ko="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function _s(t){const e=L.c(46),{item:s,onSelect:i,isLoading:r,isDisabled:o,variant:a}=t,d=a===void 0?"pill":a,{prompt:l}=s;let u;if(e[0]!==l._meta||e[1]!==l.name||e[2]!==l.title){const A=We(l._meta);u=l.title??zt(l.name,A),e[0]=l._meta,e[1]=l.name,e[2]=l.title,e[3]=u}else u=e[3];const V=u,c=l.description||null;if(d==="card"){let A;e[4]!==i||e[5]!==l?(A=()=>i(l),e[4]=i,e[5]=l,e[6]=A):A=e[6];const y=o||r,j=r&&"bg-accent/40",P=(o||r)&&"cursor-not-allowed opacity-50";let D;e[7]!==j||e[8]!==P?(D=z(ko,"hover:bg-accent/60 text-foreground",j,P),e[7]=j,e[8]=P,e[9]=D):D=e[9];let R;e[10]!==V?(R=n.jsx("span",{className:"font-medium truncate capitalize",children:V}),e[10]=V,e[11]=R):R=e[11];let T;e[12]!==r?(T=r&&n.jsx(_t,{size:"xs"}),e[12]=r,e[13]=T):T=e[13];let _;e[14]!==R||e[15]!==T?(_=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[R,T]}),e[14]=R,e[15]=T,e[16]=_):_=e[16];let k;e[17]!==c?(k=c&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:c}),e[17]=c,e[18]=k):k=e[18];let E;return e[19]!==_||e[20]!==k||e[21]!==A||e[22]!==y||e[23]!==D?(E=n.jsxs("button",{type:"button",onClick:A,disabled:y,className:D,children:[_,k]}),e[19]=_,e[20]=k,e[21]=A,e[22]=y,e[23]=D,e[24]=E):E=e[24],E}let m;e[25]!==i||e[26]!==l?(m=()=>i(l),e[25]=i,e[26]=l,e[27]=m):m=e[27];const p=o||r,x=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let f;e[28]!==x||e[29]!==g?(f=z(ks,"hover:bg-muted/70 hover:text-foreground",x,g),e[28]=x,e[29]=g,e[30]=f):f=e[30];let b;e[31]!==V?(b=n.jsx("span",{className:"capitalize",children:V}),e[31]=V,e[32]=b):b=e[32];let h;e[33]!==r?(h=r&&n.jsx(_t,{size:"xs"}),e[33]=r,e[34]=h):h=e[34];let v;e[35]!==m||e[36]!==p||e[37]!==f||e[38]!==b||e[39]!==h?(v=n.jsx(ct,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:m,disabled:p,className:f,children:[b,h]})}),e[35]=m,e[36]=p,e[37]=f,e[38]=b,e[39]=h,e[40]=v):v=e[40];const S=c??V;let C;e[41]!==S?(C=n.jsx(dt,{side:"top",className:"max-w-xs",children:n.jsx("p",{className:"text-xs",children:S})}),e[41]=S,e[42]=C):C=e[42];let N;return e[43]!==v||e[44]!==C?(N=n.jsxs(lt,{delayDuration:400,children:[v,C]}),e[43]=v,e[44]=C,e[45]=N):N=e[45],N}function _o(t){const e=L.c(41),{items:s,open:i,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[d,l]=w.useState(""),u=!!a;let V;e[0]!==s||e[1]!==d?(V=d.trim()?s.filter(y=>{const j=d.toLowerCase();return y.prompt.name.toLowerCase().includes(j)||(y.prompt.title??"").toLowerCase().includes(j)||(y.prompt.description??"").toLowerCase().includes(j)}):s,e[0]=s,e[1]=d,e[2]=V):V=e[2];const c=V,m=Bt();let p;e[3]!==c.length||e[4]!==d?(p=c.length===0&&n.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",d,"”"]}),e[3]=c.length,e[4]=d,e[5]=p):p=e[5];let x;if(e[6]!==c||e[7]!==u||e[8]!==a?.name||e[9]!==r||e[10]!==o){let y;e[12]!==u||e[13]!==a?.name||e[14]!==r||e[15]!==o?(y=j=>n.jsx(_s,{item:j,variant:"card",onSelect:P=>{r(!1),o(P)},isLoading:a?.name===j.prompt.name,isDisabled:u&&a?.name!==j.prompt.name},j.prompt.name),e[12]=u,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=y):y=e[16],x=c.map(y),e[6]=c,e[7]=u,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=x}else x=e[11];let g;e[17]!==p||e[18]!==x?(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:[p,x]})}),e[17]=p,e[18]=x,e[19]=g):g=e[19];const f=g;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=y=>{y.key==="Escape"&&l("")},e[20]=b):b=e[20];let h;e[21]!==d?(h=n.jsx(as,{value:d,onChange:l,placeholder:"Search prompts...",onKeyDown:b}),e[21]=d,e[22]=h):h=e[22];const v=h;if(m){let y;e[23]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Ot,{className:"sr-only",children:n.jsx($t,{children:"All prompts"})}),e[23]=y):y=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 P;e[25]!==f||e[26]!==v?(P=n.jsxs(Ut,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[y,j,v,f]}),e[25]=f,e[26]=v,e[27]=P):P=e[27];let D;return e[28]!==r||e[29]!==i||e[30]!==P?(D=n.jsx(rn,{delayDuration:400,children:n.jsx(Ft,{open:i,onOpenChange:r,children:P})}),e[28]=r,e[29]=i,e[30]=P,e[31]=D):D=e[31],D}let S;e[32]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Oe,{className:"sr-only",children:n.jsx($e,{children:"All prompts"})}),e[32]=S):S=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 N;e[34]!==f||e[35]!==v?(N=n.jsxs(Ue,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[S,C,v,f]}),e[34]=f,e[35]=v,e[36]=N):N=e[36];let A;return e[37]!==r||e[38]!==i||e[39]!==N?(A=n.jsx(rn,{delayDuration:400,children:n.jsx(Fe,{open:i,onOpenChange:r,children:N})}),e[37]=r,e[38]=i,e[39]=N,e[40]=A):A=e[40],A}function No(t){const e=L.c(29),{items:s,onSelect:i,loadingPrompt:r,className:o}=t,[a,d]=w.useState(!1);if(s.length===0)return null;let l,u,V;if(e[0]!==s||e[1]!==r||e[2]!==i){const b=s.slice(0,Mn);let h;e[6]!==s?(h=s.slice(Mn),e[6]=s,e[7]=h):h=e[7],l=h,u=!!r;let v;e[8]!==u||e[9]!==r?.name||e[10]!==i?(v=S=>n.jsx(_s,{item:S,onSelect:i,isLoading:r?.name===S.prompt.name,isDisabled:u&&r?.name!==S.prompt.name},S.prompt.name),e[8]=u,e[9]=r?.name,e[10]=i,e[11]=v):v=e[11],V=b.map(v),e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=u,e[5]=V}else l=e[3],u=e[4],V=e[5];const c=V;let m;e[12]!==o?(m=z("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=m):m=e[13];let p;e[14]!==l.length||e[15]!==u?(p=l.length>0&&n.jsxs("button",{type:"button",disabled:u,onClick:()=>d(!0),className:z(ks,"hover:bg-muted/70 hover:text-foreground",u&&"opacity-50 cursor-not-allowed"),children:["+",l.length," more"]}),e[14]=l.length,e[15]=u,e[16]=p):p=e[16];let x;e[17]!==c||e[18]!==m||e[19]!==p?(x=n.jsxs("div",{className:m,children:[c,p]}),e[17]=c,e[18]=m,e[19]=p,e[20]=x):x=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==i?(g=n.jsx(_o,{items:s,open:a,onOpenChange:d,onSelect:i,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=i,e[25]=g):g=e[25];let f;return e[26]!==x||e[27]!==g?(f=n.jsxs(rn,{delayDuration:400,children:[x,g]}),e[26]=x,e[27]=g,e[28]=f):f=e[28],f}function Co(){return null}function Io(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 Ro(t){const e=L.c(31),{connectionId:s}=t,{sendMessage:i}=vn(),{tiptapDocRef:r}=Lt(),{org:o}=ce();let a;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const d=ze(a);let l;e[4]!==d?(l={client:d,staleTime:6e4},e[4]=d,e[5]=l):l=e[5];const{data:u}=tr(l);let V;e[6]!==u?.prompts?(V=u?.prompts??[],e[6]=u?.prompts,e[7]=V):V=e[7];const c=V;let m;e[8]!==c?(m=c.map(To),e[8]=c,e[9]=m):m=e[9];const p=m;let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x={stage:"idle"},e[10]=x):x=e[10];const[g,f]=w.useReducer(Io,x),[b,h]=w.useState(null);let v;e[11]!==d||e[12]!==i||e[13]!==r?(v=async(_,k)=>{if(!d){se.error("MCP client not available"),f({type:"RESET"});return}try{const E=await jn(d,_.name,k);f({type:"RESET"});const M=So(r.current,{type:"paragraph",content:[Ki({id:_.name,name:wn(_.name,We(_._meta)),metadata:E.messages,char:"/"})]});await i(M)}catch(E){console.error("[ice-breakers] Failed to fetch prompt:",E),se.error("Failed to load prompt. Please try again."),f({type:"RESET"})}},e[11]=d,e[12]=i,e[13]=r,e[14]=v):v=e[14];const S=v;let C;e[15]!==S?(C=async _=>{if(_.arguments&&_.arguments.length>0){f({type:"SELECT_PROMPT",prompt:_}),h(_);return}f({type:"START_LOADING",prompt:_}),await S(_)},e[15]=S,e[16]=C):C=e[16];const N=C;let A;e[17]!==b||e[18]!==S?(A=async _=>{b&&(f({type:"START_LOADING",prompt:b,arguments:_}),h(null),await S(b,_))},e[17]=b,e[18]=S,e[19]=A):A=e[19];const y=A;if(p.length===0)return null;const j=g.stage==="loading"?g.prompt:null;let P;e[20]!==N||e[21]!==p||e[22]!==j?(P=n.jsx(No,{items:p,onSelect:N,loadingPrompt:j}),e[20]=N,e[21]=p,e[22]=j,e[23]=P):P=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{h(null),f({type:"RESET"})},e[24]=D):D=e[24];let R;e[25]!==b||e[26]!==y?(R=n.jsx(An,{prompt:b,setPrompt:D,onSubmit:y}),e[25]=b,e[26]=y,e[27]=R):R=e[27];let T;return e[28]!==P||e[29]!==R?(T=n.jsxs(n.Fragment,{children:[P,R]}),e[28]=P,e[29]=R,e[30]=T):T=e[30],T}function To(t){return{prompt:t}}function Po(t){const e=L.c(13),{className:s}=t,{selectedVirtualMcp:i}=Lt(),{org:r}=ce();let o;e[0]!==r.id?(o=xn(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,d=i?.id??a;let l;e[2]!==s?(l=z("w-full @container",s),e[2]=s,e[3]=l):l=e[3];const u=d??"default";let V;e[4]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(Co,{}),e[4]=V):V=e[4];let c;e[5]!==d?(c=n.jsx(Ro,{connectionId:d}),e[5]=d,e[6]=c):c=e[6];let m;e[7]!==u||e[8]!==c?(m=n.jsx(ni,{fallback:null,children:n.jsx(w.Suspense,{fallback:V,children:c},u)}),e[7]=u,e[8]=c,e[9]=m):m=e[9];let p;return e[10]!==l||e[11]!==m?(p=n.jsx("div",{className:l,children:m}),e[10]=l,e[11]=m,e[12]=p):p=e[12],p}function Ns(t){const e=L.c(21),{current:s,total:i,onPrev:r,onNext:o}=t;if(i<=1)return null;const a=s===0,d=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let l;e[0]!==d?(l=z("p-0.5 rounded transition-colors",d),e[0]=d,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(dr,{size:14}),e[2]=u):u=e[2];let V;e[3]!==r||e[4]!==a||e[5]!==l?(V=n.jsx("button",{type:"button",onClick:r,disabled:a,className:l,"aria-label":"Previous question",children:u}),e[3]=r,e[4]=a,e[5]=l,e[6]=V):V=e[6];const c=s+1;let m;e[7]!==c||e[8]!==i?(m=n.jsxs("span",{className:"tabular-nums text-xs",children:[c," of ",i]}),e[7]=c,e[8]=i,e[9]=m):m=e[9];const p=s===i-1,x=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==x?(g=z("p-0.5 rounded transition-colors",x),e[10]=x,e[11]=g):g=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Vs,{size:14}),e[12]=f):f=e[12];let b;e[13]!==o||e[14]!==g||e[15]!==p?(b=n.jsx("button",{type:"button",onClick:o,disabled:p,className:g,"aria-label":"Next question",children:f}),e[13]=o,e[14]=g,e[15]=p,e[16]=b):b=e[16];let h;return e[17]!==b||e[18]!==V||e[19]!==m?(h=n.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[V,m,b]}),e[17]=b,e[18]=V,e[19]=m,e[20]=h):h=e[20],h}function It(t){const e=L.c(18),{title:s,children:i,footerLeft:r,footerRight:o,className:a}=t,d=a??"border-border";let l;e[0]!==d?(l=z("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",d),e[0]=d,e[1]=l):l=e[1];let u;e[2]!==s?(u=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]=u):u=e[3];let V;e[4]!==i?(V=n.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=V):V=e[5];let c;e[6]!==r?(c=n.jsx("div",{children:r}),e[6]=r,e[7]=c):c=e[7];let m;e[8]!==o?(m=n.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==m?(p=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:[c,m]})}),e[10]=c,e[11]=m,e[12]=p):p=e[12];let x;return e[13]!==l||e[14]!==u||e[15]!==V||e[16]!==p?(x=n.jsxs("div",{className:l,children:[u,V,p]}),e[13]=l,e[14]=u,e[15]=V,e[16]=p,e[17]=x):x=e[17],x}const Eo="User denied this tool call, give other alternatives.",Do=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function Mo(t){const e=L.c(9),{onYolo:s}=t,[i,r]=pn();let o;e[0]!==s||e[1]!==i||e[2]!==r?(o=V=>{const c=V;r({...i,toolApprovalLevel:c}),c==="auto"&&s()},e[0]=s,e[1]=i,e[2]=r,e[3]=o):o=e[3];const a=o;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(ps,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:Fo,children:n.jsx(hs,{})}),e[4]=d):d=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(gs,{children:Do.map(Lo)}),e[5]=l):l=e[5];let u;return e[6]!==a||e[7]!==i.toolApprovalLevel?(u=n.jsxs(fs,{value:i.toolApprovalLevel,onValueChange:a,children:[d,l]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=u):u=e[8],u}function Lo(t){return n.jsx(Xe,{value:t.value,children:t.label},t.value)}function Fo(t){return t.stopPropagation()}function Uo(t){const e=L.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 Oo(t){const e=L.c(42),{approvals:s,onRespond:i}=t,[r,o]=w.useState(0),a=Math.min(r,s.length-1),d=s[a];if(!d)return null;let l;e[0]!==d.approvalId||e[1]!==i?(l=()=>{i(d.approvalId,!1,Eo)},e[0]=d.approvalId,e[1]=i,e[2]=l):l=e[2];const u=l;let V;e[3]!==d.approvalId||e[4]!==i?(V=()=>{i(d.approvalId,!0)},e[3]=d.approvalId,e[4]=i,e[5]=V):V=e[5];const c=V;let m;e[6]!==s||e[7]!==i?(m=()=>{for(const T of s)i(T.approvalId,!0)},e[6]=s,e[7]=i,e[8]=m):m=e[8];const p=m;let x;e[9]!==a?(x=()=>{a>0&&o(a-1)},e[9]=a,e[10]=x):x=e[10];const g=x;let f;e[11]!==s.length||e[12]!==a?(f=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=f):f=e[13];const b=f;let h;e[14]!==p?(h=n.jsx(Mo,{onYolo:p}),e[14]=p,e[15]=h):h=e[15];let v;e[16]!==s.length||e[17]!==b||e[18]!==g||e[19]!==a?(v=n.jsx(Ns,{current:a,total:s.length,onPrev:g,onNext:b}),e[16]=s.length,e[17]=b,e[18]=g,e[19]=a,e[20]=v):v=e[20];let S;e[21]!==h||e[22]!==v?(S=n.jsxs("div",{className:"flex items-center gap-2",children:[h,v]}),e[21]=h,e[22]=v,e[23]=S):S=e[23];const C=S;let N;e[24]!==u?(N=n.jsx(Q,{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:u,children:"Deny"}),e[24]=u,e[25]=N):N=e[25];let A;e[26]!==s.length||e[27]!==p?(A=s.length>1&&n.jsx(Q,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:p,children:"Accept All"}),e[26]=s.length,e[27]=p,e[28]=A):A=e[28];let y;e[29]!==c?(y=n.jsx(Q,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:c,children:"Accept"}),e[29]=c,e[30]=y):y=e[30];let j;e[31]!==A||e[32]!==y||e[33]!==N?(j=n.jsxs(n.Fragment,{children:[N,A,y]}),e[31]=A,e[32]=y,e[33]=N,e[34]=j):j=e[34];const P=j;let D;e[35]!==d.input?(D=n.jsx(Uo,{input:d.input}),e[35]=d.input,e[36]=D):D=e[36];let R;return e[37]!==d.friendlyName||e[38]!==C||e[39]!==P||e[40]!==D?(R=n.jsx(It,{title:d.friendlyName,footerLeft:C,footerRight:P,children:D}),e[37]=d.friendlyName,e[38]=C,e[39]=P,e[40]=D,e[41]=R):R=e[41],R}function $o(){const t=L.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(ji,{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 Bo(t){const e=L.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($o,{}),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(Oo,{approvals:s,onRespond:r}),e[1]=s,e[2]=r,e[3]=o):o=e[3],o}function zo(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:Yi(Wi(i)),input:s.input})}return e}function qo(t){const e=L.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 d;e[3]!==r?(d=n.jsx(Q,{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]=d):d=e[4];let l;e[5]!==a?(l=n.jsx(Q,{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]=l):l=e[6];let u;e[7]!==d||e[8]!==l?(u=n.jsxs(n.Fragment,{children:[d,l]}),e[7]=d,e[8]=l,e[9]=u):u=e[9];const V=u;let c;e[10]!==s.plan?(c=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(Gi,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=c):c=e[11];let m;return e[12]!==V||e[13]!==c?(m=n.jsx(It,{title:"Implementation Plan",footerRight:V,className:"border-dashed border-purple-500",children:c}),e[12]=V,e[13]=c,e[14]=m):m=e[14],m}function Ko(){const t=L.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(pt,{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 Yo(t){const e=L.c(7),{plans:s,isStreaming:i,onApprove:r,onDismiss:o}=t;if(i&&s.length===0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Ko,{}),e[0]=u):u=e[0],u}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const d=a;if(!d)return null;let l;return e[3]!==d||e[4]!==r||e[5]!==o?(l=n.jsx(qo,{plan:d,onApprove:r,onDismiss:o}),e[3]=d,e[4]=r,e[5]=o,e[6]=l):l=e[6],l}function Wo(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 Ln=nt({response:kt().min(1,"Response is required")}),Go=nt({response:kt().min(1,"Please select or enter an option")}),Qo=nt({response:si(["yes","no"])});function Ho(t){switch(t.type){case"text":return Ln;case"choice":return Go;case"confirm":return Qo;default:return Ln}}function Jo(t){const e={};for(const s of t)e[s.toolCallId]=Ho(s.input);return nt(e)}function Xo(t){const e=L.c(6),{control:s,name:i,placeholder:r}=t;let o;e[0]!==r?(o=d=>{const{field:l}=d;return n.jsxs(fe,{children:[n.jsx(pe,{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(ns,{size:16,className:"text-muted-foreground"})}),n.jsx("input",{...l,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(he,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=n.jsx(me,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Cs(t,e){const s=L.c(4);let i,r;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const d=a.target.tagName;if(d==="INPUT"||d==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const l=Number.parseInt(a.key,10);l>=1&&l<=t&&(a.preventDefault(),e(l-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]),w.useEffect(i,r)}function Zo(t){const e=L.c(9),{control:s,name:i,options:r}=t,[o,a]=w.useState(!1),d=w.useRef(null),l=w.useRef(null);let u;if(e[0]!==r?(u=m=>{l.current?.onChange(r[m]??""),a(!1)},e[0]=r,e[1]=u):u=e[1],Cs(r.length,u),r.length===0)return null;let V;e[2]!==o||e[3]!==r?(V=m=>{const{field:p}=m;l.current=p;const x=o||!!p.value&&!r.includes(p.value);return n.jsxs(fe,{children:[n.jsx(pe,{children:n.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[r.map((g,f)=>{const b=p.value===g;return n.jsxs("button",{type:"button",onClick:()=>{p.onChange(g??""),a(!1)},className:z("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",b&&"bg-accent/50",!b&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[n.jsx("span",{className:z("flex items-center justify-center size-6 rounded-md text-sm shrink-0",b?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f+1}),n.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${f}-${g}`)}),n.jsxs("div",{className:z("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",x&&"bg-accent/50",!x&&"hover:bg-accent/30"),onClick:()=>{a(!0),r.includes(p.value)&&p.onChange(""),setTimeout(()=>d.current?.focus(),0)},children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(ns,{size:16,className:"text-muted-foreground"})}),x?n.jsx("input",{ref:d,type:"text",value:p.value,onChange:g=>p.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(he,{})]})},e[2]=o,e[3]=r,e[4]=V):V=e[4];let c;return e[5]!==s||e[6]!==i||e[7]!==V?(c=n.jsx(me,{control:s,name:i,render:V}),e[5]=s,e[6]=i,e[7]=V,e[8]=c):c=e[8],c}function ea(t){const e=L.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=w.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=V=>{a.current?.onChange(o[V]??"")},e[1]=d):d=e[1],Cs(o.length,d);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=V=>{const{field:c}=V;return a.current=c,n.jsxs(fe,{children:[n.jsx(pe,{children:n.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(m=>{const p=c.value===m;return n.jsxs("button",{type:"button",onClick:()=>c.onChange(m),className:z("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),"aria-label":`Confirm ${m}`,children:[n.jsx("span",{className:z("flex items-center justify-center size-6 rounded-md text-sm shrink-0",p?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),n.jsx("span",{className:"text-sm text-foreground capitalize",children:m})]},m)})})}),n.jsx(he,{})]})},e[2]=l):l=e[2];let u;return e[3]!==s||e[4]!==i?(u=n.jsx(me,{control:s,name:i,render:l}),e[3]=s,e[4]=i,e[5]=u):u=e[5],u}function Fn(t){const e=L.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(Xo,{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 d;return e[6]!==i||e[7]!==r||e[8]!==a?(d=n.jsx(Zo,{control:i,name:r,options:a}),e[6]=i,e[7]=r,e[8]=a,e[9]=d):d=e[9],d}case"confirm":{let o;return e[10]!==i||e[11]!==r?(o=n.jsx(ea,{control:i,name:r}),e[10]=i,e[11]=r,e[12]=o):o=e[12],o}default:return null}}function ta({parts:t,onSubmit:e}){const[s,i]=w.useState(t[0]?.toolCallId??""),r=Jo(t.map(h=>({toolCallId:h.toolCallId,input:h.input}))),o=Vn({resolver:mn(r),defaultValues:Object.fromEntries(t.map(h=>[h.toolCallId,{response:""}]))}),a=o.watch(),d=t.findIndex(h=>h.toolCallId===s),l=!!a[s]?.response,u=t.every(h=>!!a[h.toolCallId]?.response),V=h=>{for(const v of t){const S=h[v.toolCallId]?.response;S&&e(v,S)}},c=h=>t.find(v=>!h[v.toolCallId]?.response&&v.toolCallId!==s)??null,m=()=>{const h=o.getValues();if(t.every(S=>!!h[S.toolCallId]?.response))o.handleSubmit(V)();else{const S=c(h);S&&i(S.toolCallId)}},p=()=>{o.setValue(`${s}.response`,"user has skip this question"),m()},x=()=>{if(d>0){const h=t[d-1];h&&i(h.toolCallId)}},g=()=>{if(d<t.length-1){const h=t[d+1];h&&i(h.toolCallId)}},f=n.jsxs(n.Fragment,{children:[n.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7",children:"Skip"}),n.jsx(Q,{type:"button",size:"sm",disabled:!l,onClick:m,className:z("h-7",l?"":"opacity-50"),children:u?"Submit":"Next"})]}),b=n.jsx(Ns,{current:d,total:t.length,onPrev:x,onNext:g});if(t.length===1){const h=t[0];return h?.input?n.jsx(ft,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(V),autoComplete:"off",children:n.jsx(It,{title:h.input?.prompt??"Question",footerRight:f,children:n.jsx(Fn,{input:h.input,control:o.control,name:`${h.toolCallId}.response`})})})}):null}return n.jsx(ft,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(V),autoComplete:"off",children:n.jsx(nr,{value:s,onValueChange:i,children:t.map(h=>n.jsx(sr,{value:h.toolCallId,className:"mt-0",children:n.jsx(It,{title:h.input?.prompt??"Question",footerLeft:b,footerRight:f,children:n.jsx(Fn,{input:h.input,control:o.control,name:`${h.toolCallId}.response`})})},h.toolCallId))})})})}function na(){const t=L.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(ar,{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 Is(t){const e=L.c(6),{userAskParts:s,isStreaming:i,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(sa),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let l;return e[2]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(na,{}),e[2]=l):l=e[2],l}if(a.length===0)return null;let d;return e[3]!==r||e[4]!==a?(d=n.jsx(ta,{parts:a,onSubmit:r}),e[3]=r,e[4]=a,e[5]=d):d=e[5],d}function sa(t){return t.state==="input-available"}const Un=new Map;function Rs(){const{org:t}=ce(),e=ze({connectionId:xt,orgId:t.id,orgSlug:t.slug}),s=ur(),i=s.find(f=>f.providerId==="deco"),{data:r,isLoading:o,refetch:a,isFetching:d}=hn({queryKey:Ae.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const f=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return f?.isError?null:f.structuredContent??null}}),l=r?.balanceCents??null,u=l!=null?l/100:null,V=w.useRef(new Map);if(l!=null){const f=Un.get(t.id);V.current.get(t.id)&&f!=null&&l>f&&$("credits_topped_up_detected",{organization_id:t.id,delta_cents:l-f,previous_balance_cents:f,new_balance_cents:l}),Un.set(t.id,l),V.current.set(t.id,!0)}const c=!!i,m=l!=null&&l>0,p=l!=null&&l===0,x=l!=null&&l===200,g=s.length>0&&s.every(f=>f.providerId==="deco");return{hasDecoKey:c,decoKeyId:i?.id??null,balanceCents:l,balanceDollars:u,hasCredits:m,isZeroBalance:p,isInitialFreeCredit:x,hasOnlyDecoProvider:g,isLoading:o,isFetching:d,refetch:a}}function ia(t){return t?t.message.startsWith("[CREDITS]"):!1}const ra={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"}]},oa=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Ts(t){const e=L.c(44),{onDismiss:s}=t,{org:i}=ce(),r=tt(),{decoKeyId:o}=Rs();let a;e[0]!==i.id||e[1]!==i.slug?(a={connectionId:xt,orgId:i.id,orgSlug:i.slug},e[0]=i.id,e[1]=i.slug,e[2]=a):a=e[2];const d=ze(a),[l,u]=w.useState(""),[V,c]=w.useState(!1),[m,p]=w.useState("usd"),x=m==="brl"?"R$":"$";let g,f;e[3]!==i.id?(g=()=>{$("credits_exhausted_shown",{organization_id:i.id})},f=[i.id],e[3]=i.id,e[4]=g,e[5]=f):(g=e[4],f=e[5]),w.useEffect(g,f);let b;e[6]!==d||e[7]!==m?(b=async I=>{const F=await d.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:I,currency:m}});if(F?.isError)throw new Error(F.content?.[0]?.text??"Failed to get top-up URL");return F.structuredContent?.url},e[6]=d,e[7]=m,e[8]=b):b=e[8];let h;e[9]!==s?(h=I=>{I&&window.open(I,"_blank","noopener,noreferrer"),s?.()},e[9]=s,e[10]=h):h=e[10];let v;e[11]!==b||e[12]!==h?(v={mutationFn:b,onSuccess:h,onError:ca},e[11]=b,e[12]=h,e[13]=v):v=e[13];const{mutate:S,isPending:C}=fn(v),N=parseFloat(l),A=!isNaN(N)&&N>=1;let y;e[14]!==s?(y=I=>!I&&s?.(),e[14]=s,e[15]=y):y=e[15];let j;e[16]===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[16]=j):j=e[16];let P;e[17]===Symbol.for("react.memo_cache_sentinel")?(P=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[17]=P):P=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[P,n.jsxs(Oe,{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($e,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),n.jsx(Mt,{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[18]=D):D=e[18];let R;e[19]!==m||e[20]!==x||e[21]!==l||e[22]!==N||e[23]!==o||e[24]!==A||e[25]!==C||e[26]!==V||e[27]!==S?(R=o&&n.jsxs("div",{className:"px-8 pt-5 pb-6",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(xs,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:I=>{I&&p(I)},children:[n.jsx(Ct,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(Ct,{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:ra[m].map(I=>{const{dollars:F,label:O}=I;return n.jsxs("button",{type:"button",disabled:C,onClick:()=>{$("credits_topup_clicked",{amount_cents:F*100,currency:m,tier_label:O,source:"exhausted_banner"}),S(F*100)},className:z("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:[x,F]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},F)})}),V?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:x}),n.jsx(Ie,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:I=>u(I.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(Q,{className:"h-10",disabled:!A||C,onClick:()=>{$("credits_topup_clicked",{amount_cents:Math.round(N*100),currency:m,tier_label:"custom",source:"exhausted_banner"}),S(Math.round(N*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:()=>c(!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:oa.map(aa)})]}),e[19]=m,e[20]=x,e[21]=l,e[22]=N,e[23]=o,e[24]=A,e[25]=C,e[26]=V,e[27]=S,e[28]=R):R=e[28];let T;e[29]!==s?(T=n.jsx(Q,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[29]=s,e[30]=T):T=e[30];let _;e[31]!==r||e[32]!==s||e[33]!==i.slug?(_=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[31]=r,e[32]=s,e[33]=i.slug,e[34]=_):_=e[34];let k;e[35]!==T||e[36]!==_?(k=n.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[T,_]}),e[35]=T,e[36]=_,e[37]=k):k=e[37];let E;e[38]!==R||e[39]!==k?(E=n.jsxs(Ue,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:la,children:[D,R,k]}),e[38]=R,e[39]=k,e[40]=E):E=e[40];let M;return e[41]!==E||e[42]!==y?(M=n.jsx(Fe,{open:!0,onOpenChange:y,children:E}),e[41]=E,e[42]=y,e[43]=M):M=e[43],M}function aa(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(pt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),n.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function la(t){return t.preventDefault()}function ca(t){se.error(`Top-up failed: ${t.message}`)}const da={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 Rt(t){const e=L.c(32),{variant:s,onDismiss:i}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?t.error.message:da[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,d=r?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",l=r?"text-destructive":"text-amber-600 dark:text-amber-500",u=r?ms:Xn;let V;e[0]!==d?(V=z("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",d),e[0]=d,e[1]=V):V=e[1];let c;e[2]!==l?(c=z("mt-0.5 shrink-0",l),e[2]=l,e[3]=c):c=e[3];let m;e[4]!==u?(m=n.jsx(u,{size:16}),e[4]=u,e[5]=m):m=e[5];let p;e[6]!==c||e[7]!==m?(p=n.jsx("div",{className:c,children:m}),e[6]=c,e[7]=m,e[8]=p):p=e[8];let x;e[9]!==l?(x=z("text-xs mb-1 font-medium",l),e[9]=l,e[10]=x):x=e[10];let g;e[11]!==x||e[12]!==o?(g=n.jsx("div",{className:x,children:o}),e[11]=x,e[12]=o,e[13]=g):g=e[13];let f;e[14]!==a?(f=n.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=f):f=e[15];let b;e[16]!==r||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(b=n.jsx("div",{className:"flex gap-2",children:r?n.jsxs(n.Fragment,{children:[n.jsx(Q,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),n.jsx(Q,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):n.jsx(Q,{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]=b):b=e[19];let h;e[20]!==g||e[21]!==f||e[22]!==b?(h=n.jsxs("div",{className:"flex-1 min-w-0",children:[g,f,b]}),e[20]=g,e[21]=f,e[22]=b,e[23]=h):h=e[23];let v;e[24]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(it,{size:14}),e[24]=v):v=e[24];let S;e[25]!==i?(S=n.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:v}),e[25]=i,e[26]=S):S=e[26];let C;return e[27]!==V||e[28]!==S||e[29]!==p||e[30]!==h?(C=n.jsx("div",{className:"px-0.5",children:n.jsxs("div",{className:V,children:[p,h,S]})}),e[27]=V,e[28]=S,e[29]=p,e[30]=h,e[31]=C):C=e[31],C}function Yt(){const t=L.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:r,messages:o,isStreaming:a,isWaitingForApprovals:d,addToolOutput:l,addToolApprovalResponse:u,sendMessage:V}=vn(),[c,m]=pn(),{virtualMcpId:p,createTaskWithMessage:x}=Ii();let g,f,b,h;if(t[0]!==o){const k=o.at(-1);h=k?.role==="assistant"?k.parts.filter(ma):null,g=h?.filter(Va)?.length,f=k?.role==="assistant"?Wo(k.parts):[],b=k?.role==="assistant"?zo(k.parts):[],t[0]=o,t[1]=g,t[2]=f,t[3]=b,t[4]=h}else g=t[1],f=t[2],b=t[3],h=t[4];const v=b;let S;t[5]!==e||t[6]!==V?(S=()=>{if(e){const E={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};V(E)}},t[5]=e,t[6]=V,t[7]=S):S=t[7];const C=S;let N;t[8]!==V?(N=()=>{V({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=V,t[9]=N):N=t[9];const A=N;let y;t[10]!==l?(y=(k,E)=>{l({tool:"user_ask",toolCallId:k.toolCallId,output:{response:E}})},t[10]=l,t[11]=y):y=t[11];const j=y;let P;t[12]!==x||t[13]!==c||t[14]!==m||t[15]!==p?(P=k=>{m({...c,toolApprovalLevel:"auto"}),x({virtualMcpId:p,message:{parts:[{type:"text",text:`Implement this plan:
|
|
546
546
|
|
|
547
|
-
${k}`}]}})},t[12]=x,t[13]=c,t[14]=m,t[15]=p,t[16]=P):P=t[16];const D=P,R=ua;let T;t[17]!==u?(T=(k,E,M)=>{u({id:k,approved:E,...M?{reason:M}:{}})},t[17]=u,t[18]=T):T=t[18];const _=T;if(g){let k;return t[19]!==j||t[20]!==a||t[21]!==h?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Is,{userAskParts:h,isStreaming:a,onSubmit:j})}),t[19]=j,t[20]=a,t[21]=h,t[22]=k):k=t[22],k}if(f.length>0){let k;return t[23]!==D||t[24]!==a||t[25]!==f?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Yo,{plans:f,isStreaming:a,onApprove:D,onDismiss:R})}),t[23]=D,t[24]=a,t[25]=f,t[26]=k):k=t[26],k}if(v.length>0||a&&d){let k;return t[27]!==_||t[28]!==a||t[29]!==v?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Bo,{approvals:v,isStreaming:a,onRespond:_})}),t[27]=_,t[28]=a,t[29]=v,t[30]=k):k=t[30],k}if(!a&&e){if(ia(e)){let E;return t[31]!==s?(E=n.jsx(Ts,{onDismiss:s}),t[31]=s,t[32]=E):E=t[32],E}let k;return t[33]!==s||t[34]!==e||t[35]!==C?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Rt,{variant:"error",error:e,onDismiss:s,onFixInChat:C})}),t[33]=s,t[34]=e,t[35]=C,t[36]=k):k=t[36],k}if(!a&&i&&i!=="stop"&&!d){let k;return t[37]!==r||t[38]!==i||t[39]!==A?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Rt,{variant:"warning",finishReason:i,onDismiss:r,onContinue:A})}),t[37]=r,t[38]=i,t[39]=A,t[40]=k):k=t[40],k}return null}function ua(){document.querySelector("[data-chat-input]")?.focus()}function Va(t){return t.state!=="output-available"}function ma(t){return t.type==="tool-user_ask"}Yt.Error=function(e){return n.jsx(Rt,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};Yt.Warning=function(e){return n.jsx(Rt,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};Yt.UserAskQuestion=Is;const en=[{value:"fast",label:"Fast",Icon:Ai,description:"Quicker responses"},{value:"smart",label:"Smart",Icon:or,description:"Balanced quality"},{value:"thinking",label:"Thinking",Icon:Si,description:"Deeper reasoning"}];function fa(t){const e=L.c(17),{tier:s,onSelect:i}=t;let r;e[0]!==s?(r=en.find(p=>p.value===s)??en[1],e[0]=s,e[1]=r):r=e[1];const o=r,a=o.Icon;let d;e[2]!==a?(d=n.jsx(a,{size:14}),e[2]=a,e[3]=d):d=e[3];let l;e[4]!==o.label?(l=n.jsx("span",{className:"hidden sm:inline",children:o.label}),e[4]=o.label,e[5]=l):l=e[5];let u;e[6]!==d||e[7]!==l?(u=n.jsx(ys,{asChild:!0,children:n.jsxs(Q,{type:"button",variant:"ghost",size:"default",className:"text-muted-foreground hover:text-foreground",children:[d,l]})}),e[6]=d,e[7]=l,e[8]=u):u=e[8];let V;e[9]!==i||e[10]!==s?(V=en.map(p=>{const{value:x,label:g,Icon:f,description:b}=p;return n.jsxs(Ze,{onSelect:()=>i(x),children:[n.jsx(f,{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:b})]}),s===x&&n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"On"})]},x)}),e[9]=i,e[10]=s,e[11]=V):V=e[11];let c;e[12]!==V?(c=n.jsx(vs,{align:"end",className:"w-52 p-1.5",children:V}),e[12]=V,e[13]=c):c=e[13];let m;return e[14]!==u||e[15]!==c?(m=n.jsxs(ws,{children:[u,c]}),e[14]=u,e[15]=c,e[16]=m):m=e[16],m}async function Sn(t,e,s,i,r){if(!qt(e)){se.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!mr(o,e)){const d=bs(e),l=e?.title??"This model";r?r({fileName:s.name,modelName:l,accepted:d}):se.error(`"${s.name}" can't be attached`,{description:`${l} accepts ${d}.`});return}const a=10*1024*1024;if(s.size>a){se.error(`File "${s.name}" exceeds 10MB limit`);return}try{const d=new FileReader,l=new Promise((c,m)=>{d.onload=()=>{const p=d.result;if(typeof p!="string"){m(new Error("Failed to read file as data URL"));return}const x=p.includes(",")?p.split(",")[1]??p:p;c(x)},d.onerror=m});d.readAsDataURL(s);const u=await l,V={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:u};Qi(t,{from:i,to:i},V)}catch(d){console.error("Failed to process file:",d),se.error(`Failed to load file "${s.name}"`)}}function pa(t){const e=L.c(8),{editor:s,selectedModel:i,onUnsupportedFile:r}=t,o=w.useRef(ga);let a,d;e[0]!==s||e[1]!==r||e[2]!==i?(a=()=>{o.current=async(V,c)=>{await Sn(s,i,V,c,r)}},d=[s,i,r],e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),w.useEffect(a,d);let l,u;return e[5]!==s?(l=()=>{if(s?.isDestroyed)return;const V=new on("fileDropHandler");s.state.plugins.find(p=>p.spec.key===V)&&s.unregisterPlugin(V);const m=new xr({key:V,props:{handleDrop:(p,x,g,f)=>{if(f)return!1;const b=x.dataTransfer?.files;if(!b||b.length===0)return!1;x.preventDefault();const h=p.posAtCoords({left:x.clientX,top:x.clientY});if(!h)return!1;const v=Array.from(b),S=h.pos;for(const C of v)o.current?.(C,S);return!0},handlePaste:(p,x)=>{const g=x.clipboardData?.items;if(!g)return!1;const f=Array.from(g).filter(ha);if(f.length===0)return!1;x.preventDefault();const{from:b}=p.state.selection;for(const h of f){const v=h.getAsFile();v&&o.current?.(v,b)}return!0}}});return s.registerPlugin(m),()=>{s?.isDestroyed||s.unregisterPlugin(V)}},u=[s],e[5]=s,e[6]=l,e[7]=u):(l=e[6],u=e[7]),w.useEffect(l,u),null}function ha(t){return t.kind==="file"}function ga(){return Promise.resolve()}function xa(t){const e=L.c(24),{selectedModel:s,isStreaming:i,icon:r,onUnsupportedFile:o}=t,{editor:a}=Kt(),d=w.useRef(null);let l;e[0]!==s?(l=qt(s),e[0]=s,e[1]=l):l=e[1];const u=l;let V;e[2]!==a||e[3]!==o||e[4]!==s?(V=async C=>{const N=C.target.files;if(!N||N.length===0||!a)return;const A=Array.from(N),{from:y}=a.state.selection,j=y;for(const P of A)await Sn(a,s,P,j,o);d.current&&(d.current.value="")},e[2]=a,e[3]=o,e[4]=s,e[5]=V):V=e[5];const c=V;if(!a||!u)return null;let m;e[6]!==s?(m=Vr(s),e[6]=s,e[7]=m):m=e[7];let p;e[8]!==c||e[9]!==i||e[10]!==m?(p=n.jsx("input",{ref:d,type:"file",multiple:!0,accept:m,className:"hidden",onChange:c,disabled:i}),e[8]=c,e[9]=i,e[10]=m,e[11]=p):p=e[11];const x=i||!u;let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=()=>d.current?.click(),e[12]=g):g=e[12];let f;e[13]!==r?(f=r??n.jsx(ss,{size:16}),e[13]=r,e[14]=f):f=e[14];let b;e[15]!==x||e[16]!==f?(b=n.jsx(ct,{asChild:!0,children:n.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground/75",disabled:x,onClick:g,children:f})}),e[15]=x,e[16]=f,e[17]=b):b=e[17];let h;e[18]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(dt,{side:"top",children:"Add file"}),e[18]=h):h=e[18];let v;e[19]!==b?(v=n.jsxs(lt,{children:[b,h]}),e[19]=b,e[20]=v):v=e[20];let S;return e[21]!==v||e[22]!==p?(S=n.jsxs(n.Fragment,{children:[p,v]}),e[21]=v,e[22]=p,e[23]=S):S=e[23],S}function ba(t){const e=L.c(26),{info:s,onClose:i}=t,r=s!==null;let o;e[0]!==i?(o=C=>!C&&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 d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=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]=d):d=e[3];let l,u;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=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(Xn,{size:18})}),u=n.jsx($e,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=l,e[5]=u):(l=e[4],u=e[5]);const V=s?.fileName;let c;e[6]!==V?(c=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[d,n.jsxs(Oe,{className:"relative gap-4",children:[l,n.jsxs("div",{children:[u,n.jsxs(Mt,{className:"mt-1.5 text-sm leading-relaxed",children:[n.jsxs("span",{className:"font-medium text-foreground",children:["“",V,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=V,e[7]=c):c=e[7];const m=s?.modelName;let p;e[8]!==m?(p=n.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[m," accepts"]}),e[8]=m,e[9]=p):p=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(ss,{size:14,className:"text-muted-foreground"}),e[10]=x):x=e[10];const g=s?.accepted;let f;e[11]!==g?(f=n.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[x,n.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=f):f=e[12];let b;e[13]!==p||e[14]!==f?(b=n.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:n.jsxs("div",{className:"rounded-xl border border-border p-4",children:[p,f]})}),e[13]=p,e[14]=f,e[15]=b):b=e[15];let h;e[16]!==i?(h=n.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:n.jsx(Q,{onClick:i,children:"Got it"})}),e[16]=i,e[17]=h):h=e[17];let v;e[18]!==b||e[19]!==h||e[20]!==c?(v=n.jsxs(Ue,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:ya,children:[c,b,h]}),e[18]=b,e[19]=h,e[20]=c,e[21]=v):v=e[21];let S;return e[22]!==r||e[23]!==v||e[24]!==o?(S=n.jsx(Fe,{open:r,onOpenChange:o,children:v}),e[22]=r,e[23]=v,e[24]=o,e[25]=S):S=e[25],S}function ya(t){return t.preventDefault()}function va(){const t=L.c(3),[e,s]=w.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 wa=br;var ja=["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] *)"],ln=ja.join(","),Ps=typeof Element>"u",ht=Ps?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Tt=!Ps&&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},Pt=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]"):Pt(e.parentNode));return a},Aa=function(e){var s,i=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return i===""||i==="true"},Sa=function(e,s,i){if(Pt(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(ln));return s&&ht.call(e,ln)&&r.unshift(e),r=r.filter(i),r},cn=function(e,s,i){for(var r=[],o=Array.from(e);o.length;){var a=o.shift();if(!Pt(a,!1))if(a.tagName==="SLOT"){var d=a.assignedElements(),l=d.length?d:a.children,u=cn(l,!0,i);i.flatten?r.push.apply(r,u):r.push({scopeParent:a,candidates:u})}else{var V=ht.call(a,ln);V&&i.filter(a)&&(s||!e.includes(a))&&r.push(a);var c=a.shadowRoot||typeof i.getShadowRoot=="function"&&i.getShadowRoot(a),m=!Pt(c,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(c&&m){var p=cn(c===!0?a.children:c.children,!0,i);i.flatten?r.push.apply(r,p):r.push({scopeParent:a,candidates:p})}else o.unshift.apply(o,a.children)}}return r},Es=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Ds=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Aa(e))&&!Es(e)?0:e.tabIndex},ka=function(e,s){var i=Ds(e);return i<0&&s&&!Es(e)?0:i},_a=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},Ms=function(e){return e.tagName==="INPUT"},Na=function(e){return Ms(e)&&e.type==="hidden"},Ca=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(i){return i.tagName==="SUMMARY"});return s},Ia=function(e,s){for(var i=0;i<e.length;i++)if(e[i].checked&&e[i].form===s)return e[i]},Ra=function(e){if(!e.name)return!0;var s=e.form||Tt(e),i=function(d){return s.querySelectorAll('input[type="radio"][name="'+d+'"]')},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=Ia(r,e.form);return!o||o===e},Ta=function(e){return Ms(e)&&e.type==="radio"},Pa=function(e){return Ta(e)&&!Ra(e)},Ea=function(e){var s,i=e&&Tt(e),r=(s=i)===null||s===void 0?void 0:s.host,o=!1;if(i&&i!==e){var a,d,l;for(o=!!((a=r)!==null&&a!==void 0&&(d=a.ownerDocument)!==null&&d!==void 0&&d.contains(r)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!o&&r;){var u,V,c;i=Tt(r),r=(u=i)===null||u===void 0?void 0:u.host,o=!!((V=r)!==null&&V!==void 0&&(c=V.ownerDocument)!==null&&c!==void 0&&c.contains(r))}}return o},On=function(e){var s=e.getBoundingClientRect(),i=s.width,r=s.height;return i===0&&r===0},Da=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=ht.call(e,"details>summary:first-of-type"),d=a?e.parentElement:e;if(ht.call(d,"details:not([open]) *"))return!0;if(!i||i==="full"||i==="full-native"||i==="legacy-full"){if(typeof r=="function"){for(var l=e;e;){var u=e.parentElement,V=Tt(e);if(u&&!u.shadowRoot&&r(u)===!0)return On(e);e.assignedSlot?e=e.assignedSlot:!u&&V!==e.ownerDocument?e=V.host:e=u}e=l}if(Ea(e))return!e.getClientRects().length;if(i!=="legacy-full")return!0}else if(i==="non-zero-area")return On(e);return!1},Ma=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 ht.call(s,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}s=s.parentElement}return!1},La=function(e,s){return!(s.disabled||Na(s)||Da(s,e)||Ca(s)||Ma(s))},$n=function(e,s){return!(Pa(s)||Ds(s)<0||!La(e,s))},Fa=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},Ls=function(e){var s=[],i=[];return e.forEach(function(r,o){var a=!!r.scopeParent,d=a?r.scopeParent:r,l=ka(d,a),u=a?Ls(r.candidates):d;l===0?a?s.push.apply(s,u):s.push(d):i.push({documentOrder:o,tabIndex:l,item:r,isScope:a,content:u})}),i.sort(_a).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(s)},Fs=function(e,s){s=s||{};var i;return s.getShadowRoot?i=cn([e],s.includeContainer,{filter:$n.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:Fa}):i=Sa(e,s.includeContainer,$n.bind(null,s)),Ls(i)};function Ua(){return/apple/i.test(navigator.vendor)}const Bn="data-floating-ui-focusable";function Oa(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 dn(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&ii(s)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function st(t){return"composedPath"in t?t.composedPath()[0]:t.target}function tn(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 $a(t){return t.matches("html,body")}function gt(t){return t?.ownerDocument||document}function Ba(t){return t?t.hasAttribute(Bn)?t:t.querySelector("["+Bn+"]")||t:null}function St(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,...St(t,r.id,s)])}function za(t){return"nativeEvent"in t}var qa=typeof document<"u",Ka=function(){},He=qa?w.useLayoutEffect:Ka;const Ya={...Zn},Wa=Ya.useInsertionEffect,Ga=Wa||(t=>t());function et(t){const e=w.useRef(()=>{});return Ga(()=>{e.current=t}),w.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 Us=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Os(t,e){const s=Fs(t,Us()),i=s.length;if(i===0)return;const r=Oa(gt(t)),o=s.indexOf(r),a=o===-1?e===1?0:i-1:o+e;return s[a]}function Qa(t){return Os(gt(t).body,1)||t}function Ha(t){return Os(gt(t).body,-1)||t}function nn(t,e){const s=e||t.currentTarget,i=t.relatedTarget;return!i||!dn(s,i)}function Ja(t){Fs(t,Us()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function zn(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 Xa="data-floating-ui-focusable",qn="active",Kn="selected",Za={...Zn};let Yn=!1,el=0;const Wn=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+el++;function tl(){const[t,e]=w.useState(()=>Yn?Wn():void 0);return He(()=>{t==null&&e(Wn())},[]),w.useEffect(()=>{Yn=!0},[]),t}const nl=Za.useId,kn=nl||tl;function sl(){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 il=w.createContext(null),rl=w.createContext(null),$s=()=>{var t;return((t=w.useContext(il))==null?void 0:t.id)||null},Bs=()=>w.useContext(rl);function _n(t){return"data-floating-ui-"+t}const ol={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},Gn=w.forwardRef(function(e,s){const[i,r]=w.useState();He(()=>{Ua()&&r("button")},[]);const o={ref:s,tabIndex:0,role:i,"aria-hidden":i?void 0:!0,[_n("focus-guard")]:"",style:ol};return n.jsx("span",{...e,...o})}),al={clipPath:"inset(50%)",position:"fixed",top:0,left:0},zs=w.createContext(null),Qn=_n("portal");function ll(t){t===void 0&&(t={});const{id:e,root:s}=t,i=kn(),r=dl(),[o,a]=w.useState(null),d=w.useRef(null);return He(()=>()=>{o?.remove(),queueMicrotask(()=>{d.current=null})},[o]),He(()=>{if(!i||d.current)return;const l=e?document.getElementById(e):null;if(!l)return;const u=document.createElement("div");u.id=i,u.setAttribute(Qn,""),l.appendChild(u),d.current=u,a(u)},[e,i]),He(()=>{if(s===null||!i||d.current)return;let l=s||r?.portalNode;l&&!ui(l)&&(l=l.current),l=l||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,l.appendChild(u));const V=document.createElement("div");V.id=i,V.setAttribute(Qn,""),l=u||l,l.appendChild(V),d.current=V,a(V)},[e,s,i,r]),o}function cl(t){const{children:e,id:s,root:i,preserveTabOrder:r=!0}=t,o=ll({id:s,root:i}),[a,d]=w.useState(null),l=w.useRef(null),u=w.useRef(null),V=w.useRef(null),c=w.useRef(null),m=a?.modal,p=a?.open,x=!!a&&!a.modal&&a.open&&r&&!!(i||o);return w.useEffect(()=>{if(!o||!r||m)return;function g(f){o&&nn(f)&&(f.type==="focusin"?zn:Ja)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,r,m]),w.useEffect(()=>{o&&(p||zn(o))},[p,o]),n.jsxs(zs.Provider,{value:w.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:V,afterInsideRef:c,portalNode:o,setFocusManagerState:d}),[r,o]),children:[x&&o&&n.jsx(Gn,{"data-type":"outside",ref:l,onFocus:g=>{if(nn(g,o)){var f;(f=V.current)==null||f.focus()}else{const b=a?a.domReference:null,h=Ha(b);h?.focus()}}}),x&&o&&n.jsx("span",{"aria-owns":o.id,style:al}),o&&oi.createPortal(e,o),x&&o&&n.jsx(Gn,{"data-type":"outside",ref:u,onFocus:g=>{if(nn(g,o)){var f;(f=c.current)==null||f.focus()}else{const b=a?a.domReference:null,h=Qa(b);h?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const dl=()=>w.useContext(zs),ul={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Vl={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Hn=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 ml(t,e){e===void 0&&(e={});const{open:s,onOpenChange:i,elements:r,dataRef:o}=t,{enabled:a=!0,escapeKey:d=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:V=!1,referencePressEvent:c="pointerdown",ancestorScroll:m=!1,bubbles:p,capture:x}=e,g=Bs(),f=et(typeof l=="function"?l:()=>!1),b=typeof l=="function"?f:l,h=w.useRef(!1),{escapeKey:v,outsidePress:S}=Hn(p),{escapeKey:C,outsidePress:N}=Hn(x),A=w.useRef(!1),y=et(_=>{var k;if(!s||!a||!d||_.key!=="Escape"||A.current)return;const E=(k=o.current.floatingContext)==null?void 0:k.nodeId,M=g?St(g.nodesRef.current,E):[];if(!v&&(_.stopPropagation(),M.length>0)){let I=!0;if(M.forEach(F=>{var O;if((O=F.context)!=null&&O.open&&!F.context.dataRef.current.__escapeKeyBubbles){I=!1;return}}),!I)return}i(!1,za(_)?_.nativeEvent:_,"escape-key")}),j=et(_=>{var k;const E=()=>{var M;y(_),(M=st(_))==null||M.removeEventListener("keydown",E)};(k=st(_))==null||k.addEventListener("keydown",E)}),P=et(_=>{var k;const E=o.current.insideReactTree;o.current.insideReactTree=!1;const M=h.current;if(h.current=!1,u==="click"&&M||E||typeof b=="function"&&!b(_))return;const I=st(_),F="["+_n("inert")+"]",O=gt(r.floating).querySelectorAll(F);let B=Le(I)?I:null;for(;B&&!Ht(B);){const H=li(B);if(Ht(H)||!Le(H))break;B=H}if(O.length&&Le(I)&&!$a(I)&&!dn(I,r.floating)&&Array.from(O).every(H=>!dn(B,H)))return;if(ci(I)&&T){const H=Ht(I),q=di(I),ee=/auto|scroll/,J=H||ee.test(q.overflowX),te=H||ee.test(q.overflowY),ie=J&&I.clientWidth>0&&I.scrollWidth>I.clientWidth,oe=te&&I.clientHeight>0&&I.scrollHeight>I.clientHeight,de=q.direction==="rtl",ne=oe&&(de?_.offsetX<=I.offsetWidth-I.clientWidth:_.offsetX>I.clientWidth),re=ie&&_.offsetY>I.clientHeight;if(ne||re)return}const Y=(k=o.current.floatingContext)==null?void 0:k.nodeId,X=g&&St(g.nodesRef.current,Y).some(H=>{var q;return tn(_,(q=H.context)==null?void 0:q.elements.floating)});if(tn(_,r.floating)||tn(_,r.domReference)||X)return;const Z=g?St(g.nodesRef.current,Y):[];if(Z.length>0){let H=!0;if(Z.forEach(q=>{var ee;if((ee=q.context)!=null&&ee.open&&!q.context.dataRef.current.__outsidePressBubbles){H=!1;return}}),!H)return}i(!1,_,"outside-press")}),D=et(_=>{var k;const E=()=>{var M;P(_),(M=st(_))==null||M.removeEventListener(u,E)};(k=st(_))==null||k.addEventListener(u,E)});w.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=v,o.current.__outsidePressBubbles=S;let _=-1;function k(O){i(!1,O,"ancestor-scroll")}function E(){window.clearTimeout(_),A.current=!0}function M(){_=window.setTimeout(()=>{A.current=!1},ai()?5:0)}const I=gt(r.floating);d&&(I.addEventListener("keydown",C?j:y,C),I.addEventListener("compositionstart",E),I.addEventListener("compositionend",M)),b&&I.addEventListener(u,N?D:P,N);let F=[];return m&&(Le(r.domReference)&&(F=Qt(r.domReference)),Le(r.floating)&&(F=F.concat(Qt(r.floating))),!Le(r.reference)&&r.reference&&r.reference.contextElement&&(F=F.concat(Qt(r.reference.contextElement)))),F=F.filter(O=>{var B;return O!==((B=I.defaultView)==null?void 0:B.visualViewport)}),F.forEach(O=>{O.addEventListener("scroll",k,{passive:!0})}),()=>{d&&(I.removeEventListener("keydown",C?j:y,C),I.removeEventListener("compositionstart",E),I.removeEventListener("compositionend",M)),b&&I.removeEventListener(u,N?D:P,N),F.forEach(O=>{O.removeEventListener("scroll",k)}),window.clearTimeout(_)}},[o,r,d,b,u,s,i,m,a,v,S,y,C,j,P,N,D]),w.useEffect(()=>{o.current.insideReactTree=!1},[o,b,u]);const R=w.useMemo(()=>({onKeyDown:y,...V&&{[ul[c]]:_=>{i(!1,_.nativeEvent,"reference-press")},...c!=="click"&&{onClick(_){i(!1,_.nativeEvent,"reference-press")}}}}),[y,i,V,c]),T=w.useMemo(()=>{function _(k){k.button===0&&(h.current=!0)}return{onKeyDown:y,onMouseDown:_,onMouseUp:_,[Vl[u]]:()=>{o.current.insideReactTree=!0}}},[y,u,o]);return w.useMemo(()=>a?{reference:R,floating:T}:{},[a,R,T])}function fl(t){const{open:e=!1,onOpenChange:s,elements:i}=t,r=kn(),o=w.useRef({}),[a]=w.useState(()=>sl()),d=$s()!=null,[l,u]=w.useState(i.reference),V=et((p,x,g)=>{o.current.openEvent=p?x:void 0,a.emit("openchange",{open:p,event:x,reason:g,nested:d}),s?.(p,x,g)}),c=w.useMemo(()=>({setPositionReference:u}),[]),m=w.useMemo(()=>({reference:l||i.reference||null,floating:i.floating||null,domReference:i.reference}),[l,i.reference,i.floating]);return w.useMemo(()=>({dataRef:o,open:e,onOpenChange:V,elements:m,events:a,floatingId:r,refs:c}),[e,V,m,a,r,c])}function pl(t){t===void 0&&(t={});const{nodeId:e}=t,s=fl({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||s,r=i.elements,[o,a]=w.useState(null),[d,l]=w.useState(null),V=r?.domReference||o,c=w.useRef(null),m=Bs();He(()=>{V&&(c.current=V)},[V]);const p=ri({...t,elements:{...r,...d&&{reference:d}}}),x=w.useCallback(v=>{const S=Le(v)?{getBoundingClientRect:()=>v.getBoundingClientRect(),getClientRects:()=>v.getClientRects(),contextElement:v}:v;l(S),p.refs.setReference(S)},[p.refs]),g=w.useCallback(v=>{(Le(v)||v===null)&&(c.current=v,a(v)),(Le(p.refs.reference.current)||p.refs.reference.current===null||v!==null&&!Le(v))&&p.refs.setReference(v)},[p.refs]),f=w.useMemo(()=>({...p.refs,setReference:g,setPositionReference:x,domReference:c}),[p.refs,g,x]),b=w.useMemo(()=>({...p.elements,domReference:V}),[p.elements,V]),h=w.useMemo(()=>({...p,...i,refs:f,elements:b,nodeId:e}),[p,f,b,e,i]);return He(()=>{i.dataRef.current.floatingContext=h;const v=m?.nodesRef.current.find(S=>S.id===e);v&&(v.context=h)}),w.useMemo(()=>({...p,context:h,refs:f,elements:b}),[p,f,b,h])}function sn(t,e,s){const i=new Map,r=s==="item";let o=t;if(r&&t){const{[qn]:a,[Kn]:d,...l}=t;o=l}return{...s==="floating"&&{tabIndex:-1,[Xa]:""},...o,...e.map(a=>{const d=a?a[s]:null;return typeof d=="function"?t?d(t):null:d}).concat(t).reduce((a,d)=>(d&&Object.entries(d).forEach(l=>{let[u,V]=l;if(!(r&&[qn,Kn].includes(u)))if(u.indexOf("on")===0){if(i.has(u)||i.set(u,[]),typeof V=="function"){var c;(c=i.get(u))==null||c.push(V),a[u]=function(){for(var m,p=arguments.length,x=new Array(p),g=0;g<p;g++)x[g]=arguments[g];return(m=i.get(u))==null?void 0:m.map(f=>f(...x)).find(f=>f!==void 0)}}}else a[u]=V}),a),{})}}function hl(t){t===void 0&&(t=[]);const e=t.map(d=>d?.reference),s=t.map(d=>d?.floating),i=t.map(d=>d?.item),r=w.useCallback(d=>sn(d,t,"reference"),e),o=w.useCallback(d=>sn(d,t,"floating"),s),a=w.useCallback(d=>sn(d,t,"item"),i);return w.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:a}),[r,o,a])}const gl=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function xl(t,e){var s,i;e===void 0&&(e={});const{open:r,elements:o,floatingId:a}=t,{enabled:d=!0,role:l="dialog"}=e,u=kn(),V=((s=o.domReference)==null?void 0:s.id)||u,c=w.useMemo(()=>{var h;return((h=Ba(o.floating))==null?void 0:h.id)||a},[o.floating,a]),m=(i=gl.get(l))!=null?i:l,x=$s()!=null,g=w.useMemo(()=>m==="tooltip"||l==="label"?{["aria-"+(l==="label"?"labelledby":"describedby")]:r?c:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":m==="alertdialog"?"dialog":m,"aria-controls":r?c:void 0,...m==="listbox"&&{role:"combobox"},...m==="menu"&&{id:V},...m==="menu"&&x&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[m,c,x,r,V,l]),f=w.useMemo(()=>{const h={id:c,...m&&{role:m}};return m==="tooltip"||l==="label"?h:{...h,...m==="menu"&&{"aria-labelledby":V}}},[m,c,V,l]),b=w.useCallback(h=>{let{active:v,selected:S}=h;const C={role:"option",...v&&{id:c+"-fui-option"}};switch(l){case"select":case"combobox":return{...C,"aria-selected":S}}return{}},[c,l]);return w.useMemo(()=>d?{reference:g,floating:f,item:b}:{},[d,g,f,b])}function bl(t){const e=L.c(26),{editor:s,query:i,items:r,onSelect:o,onClose:a}=t,[d,l]=w.useState(0),u=w.useRef(r),V=w.useRef(d),c=w.useRef(o),m=w.useRef(a),p=w.useDeferredValue(i);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{l(0)},e[0]=x):x=e[0];let g;e[1]!==p?(g=[p],e[1]=p,e[2]=g):g=e[2],w.useEffect(x,g);let f,b;e[3]!==r.length||e[4]!==d?(f=()=>{d>=r.length&&r.length>0&&l(0)},b=[r.length,d],e[3]=r.length,e[4]=d,e[5]=f,e[6]=b):(f=e[5],b=e[6]),w.useEffect(f,b);let h,v;e[7]!==r?(h=()=>{u.current=r},v=[r],e[7]=r,e[8]=h,e[9]=v):(h=e[8],v=e[9]),w.useEffect(h,v);let S,C;e[10]!==d?(S=()=>{V.current=d},C=[d],e[10]=d,e[11]=S,e[12]=C):(S=e[11],C=e[12]),w.useEffect(S,C);let N,A;e[13]!==o?(A=()=>{c.current=o},N=[o],e[13]=o,e[14]=N,e[15]=A):(N=e[14],A=e[15]),w.useEffect(A,N);let y,j;e[16]!==a?(y=()=>{m.current=a},j=[a],e[16]=a,e[17]=y,e[18]=j):(y=e[17],j=e[18]),w.useEffect(y,j);let P;e[19]!==s.isDestroyed||e[20]!==s.view.dom?(P=()=>{const _=s.view.dom;if(s?.isDestroyed||!_)return;const k=M=>{const I=u.current;if(!I.length)return!1;const F=()=>l(B=>(B+1)%I.length),O=()=>l(B=>(B-1+I.length)%I.length);switch(M.key){case"ArrowUp":return M.preventDefault(),O(),!0;case"ArrowDown":return M.preventDefault(),F(),!0;case"Tab":return M.preventDefault(),M.shiftKey?O():F(),!0;case"Home":return M.preventDefault(),l(0),!0;case"End":return M.preventDefault(),l(I.length-1),!0;case"Enter":{if(M.isComposing)return!1;M.preventDefault();const B=V.current;return B!==-1&&I[B]&&c.current?.(I[B],B),!0}case"Escape":return M.preventDefault(),m.current?.(),!0;default:return!1}},E=M=>{k(M)};return _.addEventListener("keydown",E,!0),()=>{_?.removeEventListener("keydown",E,!0)}},e[19]=s.isDestroyed,e[20]=s.view.dom,e[21]=P):P=e[21];let D;e[22]!==s?(D=[s],e[22]=s,e[23]=D):D=e[23],w.useEffect(P,D);const R=r.length?d:void 0;let T;return e[24]!==R?(T={selectedIndex:R,setSelectedIndex:l},e[24]=R,e[25]=T):T=e[25],T}function yl(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 qs=w.createContext(void 0);function Ks(){const t=w.useContext(qs);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function vl({editor:t,char:e,pluginKey:s,allow:i,onOpenChange:r}){const[o,a]=w.useReducer(yl,{open:!1,element:null,query:"",range:null,selectedItem:null}),d=w.useRef(r);return d.current=r,w.useEffect(()=>{if(t?.isDestroyed)return;const l=s instanceof on?s:new on(s);t.state.plugins.find(c=>c.spec.key===l)&&t.unregisterPlugin(l);const V=Ar({pluginKey:l,editor:t,char:e,allow(c){const m=t.state.doc.resolve(c.range.from);for(let p=m.depth;p>0;p--)if(m.node(p).type.name==="image")return!1;return!(i&&!i(c))},command(){},render:()=>({onStart:c=>{a({type:"ON_START",payload:{element:c.decorationNode??null,query:c.query,range:c.range}}),d.current?.(!0)},onUpdate:c=>{a({type:"ON_UPDATE",payload:{element:c.decorationNode??null,query:c.query,range:c.range}})},onKeyDown:c=>c.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),d.current?.(!1)}}),items:()=>[]});return t.registerPlugin(V),()=>{t?.isDestroyed||t.unregisterPlugin(l)}},[t,s,e,a,i]),{state:o,dispatch:a}}function wl({editor:t,queryKey:e,queryFn:s,onSelect:i}){const{state:r,dispatch:o}=Ks(),a=w.useDeferredValue(r.query),{data:d}=Vi({queryKey:Ae.suggestionItems(e,r.open,a),queryFn:()=>r.open?s({query:a}):[]}),l=()=>{o({type:"ON_EXIT"})},u=async(c,m)=>{if(!(r.selectedItem!==null||!r.range)){o({type:"SET_SELECTED_ITEM",payload:c});try{const{view:p}=t,g=p.state.selection.$to.nodeAfter?.text?.startsWith(" "),f=r.range?{...r.range}:{from:0,to:0};g&&r.range&&(f.to+=1),await i({range:f,item:c})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):l()}catch{l()}}},{selectedIndex:V}=bl({editor:t,query:a,items:d,onSelect:u,onClose:l});return{selectedItem:r.selectedItem,items:d,selectedIndex:V,close:l,onSelect:u}}function jl({children:t}){const{state:e,dispatch:s}=Ks(),{open:i,element:r}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:d,context:l}=pl({placement:"bottom-start",open:i,onOpenChange:m=>{m||o()},elements:{reference:r},middleware:[mi(10),fi(),pi()],whileElementsMounted:hi}),u=ml(l,{outsidePress:m=>!(m.target instanceof Element&&m.target.closest(".ProseMirror"))}),V=xl(l,{role:"listbox"}),{getFloatingProps:c}=hl([u,V]);return i?n.jsx(cl,{children:n.jsx("div",{ref:a.setFloating,style:d,...c(),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 Al=t=>{const e=L.c(29),{item:s,isSelected:i,onSelect:r,isLoading:o,ref:a}=t;let d;if(e[0]!==s){const N=We(s._meta);d=s.title||zt(s.name,N),e[0]=s,e[1]=d}else d=e[1];const l=d,u=s.description||null,V=s.icon,c=i&&"bg-accent text-accent-foreground",m=o&&"pointer-events-none opacity-50";let p;e[2]!==c||e[3]!==m?(p=z("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",c,m),e[2]=c,e[3]=m,e[4]=p):p=e[4];let x;e[5]!==V||e[6]!==l?(x=V!==void 0&&n.jsx(yn,{icon:V,name:l,size:"xs",className:"mr-2"}),e[5]=V,e[6]=l,e[7]=x):x=e[7];let g;e[8]!==l?(g=n.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:l}),e[8]=l,e[9]=g):g=e[9];let f;e[10]!==o?(f=o&&n.jsx(_t,{size:"xs"}),e[10]=o,e[11]=f):f=e[11];let b;e[12]!==g||e[13]!==f?(b=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,f]}),e[12]=g,e[13]=f,e[14]=b):b=e[14];let h;e[15]!==u?(h=u&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:u}),e[15]=u,e[16]=h):h=e[16];let v;e[17]!==b||e[18]!==h?(v=n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[b,h]}),e[17]=b,e[18]=h,e[19]=v):v=e[19];let S;e[20]!==s.drillable?(S=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]=S):S=e[21];let C;return e[22]!==r||e[23]!==a||e[24]!==v||e[25]!==S||e[26]!==p||e[27]!==x?(C=n.jsxs("div",{ref:a,onClick:r,className:p,children:[x,v,S]}),e[22]=r,e[23]=a,e[24]=v,e[25]=S,e[26]=p,e[27]=x,e[28]=C):C=e[28],C},Sl=t=>{const e=L.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:d,selectedIndex:l,onSelect:u,selectedItem:V}=wl(a);if(!d.length){let x;return e[5]===Symbol.for("react.memo_cache_sentinel")?(x=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]=x):x=e[5],x}let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=c):c=e[6];let m;if(e[7]!==u||e[8]!==d||e[9]!==l||e[10]!==V?.name){let x;e[12]!==u||e[13]!==l||e[14]!==V?.name?(x=(g,f)=>n.jsx(Al,{item:g,isSelected:f===l,ref:f===l?Nl:void 0,onSelect:()=>u(g,f),isLoading:V?.name===g.name},g.name),e[12]=u,e[13]=l,e[14]=V?.name,e[15]=x):x=e[15],m=d.map(x),e[7]=u,e[8]=d,e[9]=l,e[10]=V?.name,e[11]=m}else m=e[11];let p;return e[16]!==m?(p=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:c,children:n.jsx("div",{className:"p-1",children:m})}),e[16]=m,e[17]=p):p=e[17],p};function kl(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"p-1",children:[...Array(3)].map(_l)}),t[0]=e):e=t[0],e}function _l(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 Ys(t){const e=L.c(18),{editor:s,char:i,pluginKey:r,queryKey:o,queryFn:a,onSelect:d,allow:l,onOpenChange:u}=t;let V;e[0]!==l||e[1]!==i||e[2]!==s||e[3]!==u||e[4]!==r?(V={editor:s,char:i,pluginKey:r,allow:l,onOpenChange:u},e[0]=l,e[1]=i,e[2]=s,e[3]=u,e[4]=r,e[5]=V):V=e[5];const{state:c,dispatch:m}=vl(V);let p;e[6]!==m||e[7]!==c?(p={state:c,dispatch:m},e[6]=m,e[7]=c,e[8]=p):p=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(kl,{}),e[9]=x):x=e[9];let g;e[10]!==s||e[11]!==d||e[12]!==a||e[13]!==o?(g=n.jsx(jl,{children:n.jsx(w.Suspense,{fallback:x,children:n.jsx(Sl,{editor:s,queryKey:o,queryFn:a,onSelect:d})})}),e[10]=s,e[11]=d,e[12]=a,e[13]=o,e[14]=g):g=e[14];let f;return e[15]!==p||e[16]!==g?(f=n.jsx(qs.Provider,{value:p,children:g}),e[15]=p,e[16]=g,e[17]=f):f=e[17],f}function Nl(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const Cl=[{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}],Il=({editor:t,virtualMcpId:e})=>{const s=Dt(),{org:i}=ce(),r=Oi(),o=ze({connectionId:e,orgId:i.id,orgSlug:i.slug}),a=Ae.virtualMcpResources(e,i.id),[d,l]=w.useState("categories"),u=w.useRef(d);u.current=d;const V=w.useRef(null),c=w.useRef(!1),m=["at-mention",i.id,e??"default",d],p=async({item:f,range:b})=>{if($("chat_picker_item_selected",{picker:"@",item_kind:f.kind,item_name:f.name}),f.kind!=="category"&&(c.current=!0),f.kind==="category")return l(f.name==="agents"?"agents":"resources"),!1;if(f.kind==="agent"&&f.agentId){mt(t,b,{id:f.agentId,name:f.name,metadata:{agentId:f.agentId,title:f.name},char:"@"}),l("categories");return}if(f.kind==="resource"&&f.uri&&o){try{const h=await js(o,f.uri);mt(t,b,{id:f.uri,name:f.uri,metadata:h.contents,char:"@"})}catch(h){console.error("[at-mention] Failed to fetch resource:",h),se.error("Failed to load resource. Please try again.")}l("categories");return}},x=async f=>{const{query:b}=f,h=u.current;if(h==="categories"){if(!b.trim())return Cl;const C=b.toLowerCase(),N=r.filter(y=>y.status==="active"&&(!y.id||!Nn(y.id))&&y.id!==e&&(y.title.toLowerCase().includes(C)||y.description?.toLowerCase().includes(C))).map(y=>({name:y.title,title:y.title,description:y.description??void 0,icon:y.icon??null,kind:"agent",agentId:y.id})),A=await(async()=>{if(!o)return[];let y=s.getQueryData(a);return y||(y=await s.fetchQuery({queryKey:a,queryFn:()=>Vt(o),staleTime:6e4})),(y?.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[...N,...A]}if(h==="agents"){let C=r.filter(N=>N.status==="active"&&(!N.id||!Nn(N.id))&&N.id!==e);if(b.trim()){const N=b.toLowerCase();C=C.filter(A=>A.title.toLowerCase().includes(N)||A.description?.toLowerCase().includes(N))}return C.map(N=>({name:N.title,title:N.title,description:N.description??void 0,icon:N.icon??null,kind:"agent",agentId:N.id}))}if(!o)return[];let v=s.getQueryData(a);v?s.fetchQuery({queryKey:a,queryFn:()=>Vt(o),staleTime:6e4}).catch(()=>{}):v=await s.fetchQuery({queryKey:a,queryFn:()=>Vt(o),staleTime:6e4});let S=v?.resources??[];if(b.trim()){const C=b.toLowerCase();S=S.filter(N=>N.uri.toLowerCase().includes(C)||N.name?.toLowerCase().includes(C)||N.description?.toLowerCase().includes(C))}return S.map(C=>({name:C.name??C.uri,title:C.name,description:C.description,kind:"resource",uri:C.uri}))},g=f=>{if(f)V.current=Date.now(),c.current=!1,$("chat_picker_opened",{picker:"@"});else{const b=V.current;$("chat_picker_closed",{picker:"@",outcome:c.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),V.current=null,l("categories")}};return n.jsx(Ys,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:m,queryFn:x,onSelect:p,onOpenChange:g})};function Rl(t,e,s){const i=$i(t),r=xi(),o=new Map(r.map(u=>[u.id,u])),a=(i?.connections??[]).map(u=>u.connection_id),{data:d}=hn({queryKey:Ae.promptConnectionMap(e,a),queryFn:async()=>{const u={};return await Promise.all(a.map(async V=>{try{const c=await bi({connectionId:V,orgId:e,orgSlug:s}),m=await Nt(c);for(const p of m.prompts)p.name in u||(u[p.name]=V)}catch{}})),u},staleTime:6e4,enabled:a.length>0}),l=new Map;for(const[u,V]of Object.entries(d??{})){const c=o.get(V);c&&l.set(u,c)}return l}async function Jn(t,e,s,i,r,o){try{const a=await jn(s,i,o);mt(t,e,{id:i,name:wn(i,r),metadata:a.messages,char:"/"})}catch(a){console.error("[slash] Failed to fetch prompt:",a),se.error("Failed to load prompt. Please try again.")}}async function Tl(t,e,s,i){try{const r=await js(s,i);mt(t,e,{id:i,name:i,metadata:r.contents,char:"/"})}catch(r){console.error("[slash] Failed to fetch resource:",r),se.error("Failed to load resource. Please try again.")}}const Pl=({editor:t,virtualMcpId:e})=>{const s=Dt(),{org:i}=ce(),r=ze({connectionId:e,orgId:i.id,orgSlug:i.slug}),o=Rl(e,i.id,i.slug),a=w.useRef(o);a.current=o;const d=Ae.virtualMcpPrompts(e,i.id),l=Ae.virtualMcpResources(e,i.id),u=["slash-mention",i.id,e??"default"],[V,c]=w.useState(null),m=w.useRef(null),p=w.useRef(!1),x=async({item:h,range:v})=>{if($("chat_picker_item_selected",{picker:"/",item_kind:h.kind,item_name:h.name}),p.current=!0,!!r)if(h.kind==="prompt"){if(h.arguments&&h.arguments.length>0){c({range:v,item:h});return}const S=We(h._meta);await Jn(t,v,r,h.name,S)}else h.uri&&await Tl(t,v,r,h.uri)},g=async h=>{if(!V||!r)return;const{range:v,item:S}=V,C=We(S._meta);await Jn(t,v,r,S.name,C,h),c(null)},f=async h=>{const{query:v}=h;if(!r)return[];const[S,C]=await Promise.all([El(s,d,r),Dl(s,l,r)]),N=v.trim().toLowerCase(),A=(S??[]).filter(j=>!N||j.name.toLowerCase().includes(N)||j.title?.toLowerCase().includes(N)||j.description?.toLowerCase().includes(N)).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})),y=(C??[]).filter(j=>!N||j.uri.toLowerCase().includes(N)||j.name?.toLowerCase().includes(N)||j.description?.toLowerCase().includes(N)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}));return[...A,...y]},b=V?.item.kind==="prompt"?{name:V.item.name,arguments:V.item.arguments,description:V.item.description}:null;return n.jsxs(n.Fragment,{children:[n.jsx(Ys,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:u,queryFn:f,onSelect:x,onOpenChange:h=>{if(h)m.current=Date.now(),p.current=!1,$("chat_picker_opened",{picker:"/"});else{const v=m.current;$("chat_picker_closed",{picker:"/",outcome:p.current?"selected":"dismissed",duration_ms:v?Date.now()-v:null}),m.current=null}}}),n.jsx(An,{prompt:b,setPrompt:()=>c(null),onSubmit:g})]})};async function El(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>Nt(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>Nt(s),staleTime:6e4}),i?.prompts??[]}async function Dl(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>Vt(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>Vt(s),staleTime:6e4}),i?.resources??[]}function Ml(t){return[wr.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),wa.configure({placeholder:()=>t.current??"Ask anything, / for prompts, @ for agents & resources...",showOnlyWhenEditable:!1}),Hi,Ji]}function Ll({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:i=!1,placeholder:r,onSubmit:o,children:a}){const d=w.useRef(o),l=w.useRef(e),u=w.useRef(i),V=w.useRef(r),c=yr({extensions:Ml(V),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:(m,p)=>p.key==="Enter"&&!p.shiftKey&&u.current?(p.preventDefault(),d.current?.(),!0):!1},onUpdate:({editor:m})=>{l.current(m?.getJSON())}});return w.useEffect(()=>{c?.setEditable(!s)},[c,s]),w.useEffect(()=>{d.current=o},[o]),w.useEffect(()=>{l.current=e},[e]),w.useEffect(()=>{u.current=i},[i]),w.useEffect(()=>{V.current=r},[r]),w.useEffect(()=>{if(c?.isDestroyed)return;const m=JSON.stringify(c?.getJSON()),p=JSON.stringify(t||{type:"doc",content:[]});m!==p&&c.commands.setContent(t||{type:"doc",content:[]})},[c,t]),n.jsx(vr.Provider,{value:{editor:c},children:a})}function Fl(t){const e=L.c(26),{disabled:s,virtualMcpId:i,showFileUploader:r,selectedModel:o,onUnsupportedFile:a,ref:d,className:l}=t,u=s===void 0?!1:s,V=r===void 0?!1:r,{editor:c}=Kt();let m,p;if(e[0]!==c?(m=()=>({focus:()=>{c?.commands.focus()},clear:()=>{c?.commands.clearContent(!0)},appendText:y=>{if(!c)return;const j=c.state.doc.textContent.trim()==="";c.commands.focus("end"),j||c.commands.insertContent(" "),c.commands.insertContent(y)},syncVoiceText:(y,j)=>{if(c&&(c.commands.setContent(y||{type:"doc",content:[]}),j)){c.commands.focus("end");const P=c.state.doc.textContent.trim().length>0;c.commands.insertContent(P?" "+j:j)}},restoreContent:y=>{c&&c.commands.setContent(y||{type:"doc",content:[]})}}),p=[c],e[0]=c,e[1]=m,e[2]=p):(m=e[1],p=e[2]),w.useImperativeHandle(d??null,m,p),!c)return null;const x=u&&"cursor-not-allowed opacity-70",g=u&&"[&_.ProseMirror]:cursor-not-allowed";let f;e[3]!==l||e[4]!==x||e[5]!==g?(f=z("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",l,"[&_.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",x,g),e[3]=l,e[4]=x,e[5]=g,e[6]=f):f=e[6];let b;e[7]!==c||e[8]!==f?(b=n.jsx(jr,{editor:c,className:f}),e[7]=c,e[8]=f,e[9]=b):b=e[9];const h=i??null;let v;e[10]!==c||e[11]!==h?(v=n.jsx(w.Suspense,{fallback:null,children:n.jsx(Pl,{editor:c,virtualMcpId:h})}),e[10]=c,e[11]=h,e[12]=v):v=e[12];const S=i??null;let C;e[13]!==c||e[14]!==S?(C=n.jsx(w.Suspense,{fallback:null,children:n.jsx(Il,{editor:c,virtualMcpId:S})}),e[13]=c,e[14]=S,e[15]=C):C=e[15];let N;e[16]!==c||e[17]!==a||e[18]!==o||e[19]!==V?(N=V&&o?n.jsx(pa,{editor:c,selectedModel:o,onUnsupportedFile:a}):null,e[16]=c,e[17]=a,e[18]=o,e[19]=V,e[20]=N):N=e[20];let A;return e[21]!==v||e[22]!==C||e[23]!==N||e[24]!==b?(A=n.jsxs(n.Fragment,{children:[b,v,C,N]}),e[21]=v,e[22]=C,e[23]=N,e[24]=b,e[25]=A):A=e[25],A}function un(t){const e=L.c(3),[s]=pn();let i;return e[0]!==s.enableSounds||e[1]!==t?(i=()=>{s.enableSounds&&Sr(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 Ul={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"},Ol=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function $l(){const t=L.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:Ol.map(Bl)}),t[0]=e):e=t[0],e}function Bl(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 zl(t){const e=L.c(116),{disabled:s,onOpenConnections:i,virtualMcpId:r}=t,[o,a]=w.useState(!1),d=un(Ul),{org:l}=ce(),{editor:u}=Kt();let V;e[0]!==l.id||e[1]!==l.slug||e[2]!==r?(V={connectionId:r,orgId:l.id,orgSlug:l.slug},e[0]=l.id,e[1]=l.slug,e[2]=r,e[3]=V):V=e[3];const c=ze(V);let m;e[4]!==l.id||e[5]!==r?(m=Ae.virtualMcpPrompts(r,l.id),e[4]=l.id,e[5]=r,e[6]=m):m=e[6];const p=m;let x;e[7]!==c?(x=()=>Nt(c),e[7]=c,e[8]=x):x=e[8];const g=o&&!!c;let f;e[9]!==p||e[10]!==x||e[11]!==g?(f={queryKey:p,queryFn:x,staleTime:6e4,enabled:g},e[9]=p,e[10]=x,e[11]=g,e[12]=f):f=e[12];const{data:b,isLoading:h}=hn(f);let v;e[13]!==b?.prompts?(v=b?.prompts??[],e[13]=b?.prompts,e[14]=v):v=e[14];const S=v,[C,N]=w.useState(null),{chatMode:A,setChatMode:y}=Lt(),j=A==="plan";let P;e[15]!==A||e[16]!==j||e[17]!==d||e[18]!==y?(P=()=>{d();const G=j?"default":"plan";$("chat_mode_changed",{from_mode:A,to_mode:G,source:"tools_popover"}),y(G),a(!1)},e[15]=A,e[16]=j,e[17]=d,e[18]=y,e[19]=P):P=e[19];const D=P;let R;e[20]!==i?(R=()=>{i(),a(!1)},e[20]=i,e[21]=R):R=e[21];const T=R;let _;e[22]!==c||e[23]!==u?(_=async(G,yt)=>{if(!u||!c)return;const Gs=We(G._meta),Qs={from:u.state.selection.from,to:u.state.selection.to};try{const Hs=await jn(c,G.name,yt);mt(u,Qs,{id:G.name,name:wn(G.name,Gs),metadata:Hs.messages,char:"/"})}catch{se.error("Failed to load prompt. Please try again.")}},e[22]=c,e[23]=u,e[24]=_):_=e[24];const k=_;let E;e[25]!==k?(E=async G=>{a(!1);const yt=!!(G.arguments&&G.arguments.length>0);if($("chat_prompt_inserted",{prompt_name:G.name,with_arguments:yt}),yt){N(G);return}await k(G)},e[25]=k,e[26]=E):E=e[26];const M=E;let I;e[27]!==C||e[28]!==k?(I=async G=>{C&&(await k(C,G),N(null))},e[27]=C,e[28]=k,e[29]=I):I=e[29];const F=I;let O;e[30]!==A||e[31]!==d||e[32]!==y?(O=()=>{d();const G=A==="gen-image"?"default":"gen-image";$("chat_mode_changed",{from_mode:A,to_mode:G,source:"tools_popover"}),y(G),a(!1)},e[30]=A,e[31]=d,e[32]=y,e[33]=O):O=e[33];const B=O;let Y;e[34]!==A||e[35]!==d||e[36]!==y?(Y=()=>{d();const G=A==="web-search"?"default":"web-search";$("chat_mode_changed",{from_mode:A,to_mode:G,source:"tools_popover"}),y(G),a(!1)},e[34]=A,e[35]=d,e[36]=y,e[37]=Y):Y=e[37];const X=Y,Z=A==="gen-image",H=A==="web-search";let q;e[38]!==A||e[39]!==o?(q=G=>{G&&!o&&$("chat_tools_popover_opened",{chat_mode:A}),a(G)},e[38]=A,e[39]=o,e[40]=q):q=e[40];let ee,J;e[41]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx(ki,{size:14}),J=n.jsx("span",{className:"hidden sm:inline",children:"Tools"}),e[41]=ee,e[42]=J):(ee=e[41],J=e[42]);let te;e[43]!==s?(te=n.jsx(ys,{asChild:!0,children:n.jsxs(Q,{type:"button",variant:"ghost",size:"default",disabled:s,className:"text-muted-foreground hover:text-foreground",children:[ee,J]})}),e[43]=s,e[44]=te):te=e[44];const ie=j&&"text-violet-600 dark:text-violet-400";let oe;e[45]!==ie?(oe=z(ie),e[45]=ie,e[46]=oe):oe=e[46];const de=j&&"text-violet-500";let ne;e[47]!==de?(ne=z(de),e[47]=de,e[48]=ne):ne=e[48];let re;e[49]!==ne?(re=n.jsx(ls,{size:16,className:ne}),e[49]=ne,e[50]=re):re=e[50];let je;e[51]===Symbol.for("react.memo_cache_sentinel")?(je=n.jsx("span",{className:"flex-1",children:"Plan mode"}),e[51]=je):je=e[51];let K;e[52]!==j?(K=j&&n.jsx("span",{className:"text-xs text-violet-500 font-medium",children:"On"}),e[52]=j,e[53]=K):K=e[53];let ue;e[54]!==D||e[55]!==oe||e[56]!==re||e[57]!==K?(ue=n.jsxs(Ze,{onClick:D,className:oe,children:[re,je,K]}),e[54]=D,e[55]=oe,e[56]=re,e[57]=K,e[58]=ue):ue=e[58];const Re=Z&&"text-pink-600 dark:text-pink-400";let qe;e[59]!==Re?(qe=z(Re),e[59]=Re,e[60]=qe):qe=e[60];const Ke=Z&&"text-pink-500";let Te;e[61]!==Ke?(Te=z(Ke),e[61]=Ke,e[62]=Te):Te=e[62];let ge;e[63]!==Te?(ge=n.jsx(cs,{size:16,className:Te}),e[63]=Te,e[64]=ge):ge=e[64];let Se;e[65]===Symbol.for("react.memo_cache_sentinel")?(Se=n.jsx("span",{className:"flex-1",children:"Create image"}),e[65]=Se):Se=e[65];let Pe;e[66]!==Z?(Pe=Z&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"}),e[66]=Z,e[67]=Pe):Pe=e[67];let Ee;e[68]!==B||e[69]!==qe||e[70]!==ge||e[71]!==Pe?(Ee=n.jsxs(Ze,{onClick:B,className:qe,children:[ge,Se,Pe]}),e[68]=B,e[69]=qe,e[70]=ge,e[71]=Pe,e[72]=Ee):Ee=e[72];const Ge=H&&"text-blue-600 dark:text-blue-400";let De;e[73]!==Ge?(De=z(Ge),e[73]=Ge,e[74]=De):De=e[74];const Me=H&&"text-blue-500";let xe;e[75]!==Me?(xe=z(Me),e[75]=Me,e[76]=xe):xe=e[76];let be;e[77]!==xe?(be=n.jsx(ut,{size:16,className:xe}),e[77]=xe,e[78]=be):be=e[78];let ke;e[79]===Symbol.for("react.memo_cache_sentinel")?(ke=n.jsx("span",{className:"flex-1",children:"Web search"}),e[79]=ke):ke=e[79];let ye;e[80]!==H?(ye=H&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"}),e[80]=H,e[81]=ye):ye=e[81];let _e;e[82]!==X||e[83]!==De||e[84]!==be||e[85]!==ye?(_e=n.jsxs(Ze,{onClick:X,className:De,children:[be,ke,ye]}),e[82]=X,e[83]=De,e[84]=be,e[85]=ye,e[86]=_e):_e=e[86];let U;e[87]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsxs(pr,{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[87]=U):U=e[87];let W;e[88]!==M||e[89]!==h||e[90]!==S?(W=h?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(at,{size:14,className:"animate-spin"}),"Loading prompts…"]}):S.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):S.map(G=>n.jsxs(Ze,{onClick:()=>M(G),className:"flex flex-col items-start gap-0.5",children:[n.jsx("span",{className:"font-medium text-sm capitalize",children:G.title||zt(G.name,We(G._meta))}),G.description&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:G.description})]},G.name)),e[88]=M,e[89]=h,e[90]=S,e[91]=W):W=e[91];let le;e[92]!==W?(le=n.jsxs(hr,{children:[U,n.jsx(gr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:W})]}),e[92]=W,e[93]=le):le=e[93];let Ne,ve;e[94]===Symbol.for("react.memo_cache_sentinel")?(Ne=n.jsx(lr,{size:16}),ve=n.jsx("span",{className:"flex-1",children:"Connections"}),e[94]=Ne,e[95]=ve):(Ne=e[94],ve=e[95]);let Be;e[96]===Symbol.for("react.memo_cache_sentinel")?(Be=n.jsx(w.Suspense,{children:n.jsx($l,{})}),e[96]=Be):Be=e[96];let we;e[97]!==T?(we=n.jsxs(Ze,{onClick:T,children:[Ne,ve,Be]}),e[97]=T,e[98]=we):we=e[98];let ae;e[99]!==ue||e[100]!==Ee||e[101]!==_e||e[102]!==le||e[103]!==we?(ae=n.jsxs(vs,{align:"start",className:"w-52 p-1.5",children:[ue,Ee,_e,le,we]}),e[99]=ue,e[100]=Ee,e[101]=_e,e[102]=le,e[103]=we,e[104]=ae):ae=e[104];let Ve;e[105]!==o||e[106]!==q||e[107]!==te||e[108]!==ae?(Ve=n.jsxs(ws,{open:o,onOpenChange:q,children:[te,ae]}),e[105]=o,e[106]=q,e[107]=te,e[108]=ae,e[109]=Ve):Ve=e[109];let Je;e[110]!==C||e[111]!==F?(Je=n.jsx(An,{prompt:C,setPrompt:N,onSubmit:F}),e[110]=C,e[111]=F,e[112]=Je):Je=e[112];let bt;return e[113]!==Ve||e[114]!==Je?(bt=n.jsxs(n.Fragment,{children:[Ve,Je]}),e[113]=Ve,e[114]=Je,e[115]=bt):bt=e[115],bt}const ql=[{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 Kl(){const t=L.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:ql.map(Yl)}),t[0]=e):e=t[0],e}function Yl(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 Wl(t){const e=L.c(6),{onClick:s}=t;let i,r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=z("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(Kl,{}),a=n.jsx(Or,{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 d;return e[4]!==s?(d=n.jsxs("button",{type:"button",onClick:s,className:i,children:[r,o,a]}),e[4]=s,e[5]=d):d=e[5],d}const ot=48;function Gl(){const t=L.c(9),[e,s]=w.useState("idle"),[i,r]=w.useState(""),[o,a]=w.useState(""),[d,l]=w.useState(Jl),u=w.useRef(null),V=w.useRef(null),c=w.useRef(null),m=w.useRef(null),p=w.useRef(0),x=w.useRef(!1),g=w.useRef(""),f=w.useRef(""),b=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0),V.current?.close().catch(Hl),m.current?.getTracks().forEach(Ql),c.current=null,V.current=null,m.current=null},t[0]=h):h=t[0];const v=h;let S;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const D=R=>{m.current=R;const T=new AudioContext;V.current=T;const _=T.createMediaStreamSource(R),k=T.createAnalyser();k.fftSize=128,k.smoothingTimeConstant=.8,_.connect(k),c.current=k;const E=new Uint8Array(k.frequencyBinCount),M=()=>{if(!c.current)return;c.current.getByteFrequencyData(E);const I=[];for(let F=0;F<ot;F++){const O=Math.floor(F/ot*E.length);I.push(Math.max(.04,(E[O]??0)/255))}l(I),p.current=requestAnimationFrame(M)};M()};S=async()=>{const R=window.SpeechRecognition||window.webkitSpeechRecognition;if(!R){s("unsupported");return}let T;try{T=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}r(""),a(""),f.current="",g.current="",x.current=!0,s("recording"),D(T);const _=new R;u.current=_,_.interimResults=!0,_.continuous=!0,_.lang=navigator.language||"en-US",_.onresult=k=>{let E="",M="";for(let I=k.resultIndex;I<k.results.length;I++){const F=k.results[I],O=F?.[0]?.transcript??"";F?.isFinal?M=M+O:E=E+O}M&&(g.current=g.current+M,r(g.current)),f.current=E,a(E)},_.onend=()=>{if(x.current)try{_.start()}catch{}};try{_.start()}catch{s("idle")}},t[1]=S}else S=t[1];const C=S;let N;t[2]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{x.current=!1,u.current?.stop(),v(),s("idle"),l(Array(ot).fill(.05)),a("");const D=(g.current+(f.current?" "+f.current:"")).trim();return r(""),g.current="",f.current="",D},t[2]=N):N=t[2];const A=N;let y;t[3]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{x.current=!1,u.current?.abort(),v(),s("idle"),r(""),a(""),l(Array(ot).fill(.05)),g.current="",f.current=""},t[3]=y):y=t[3];const j=y;let P;return t[4]!==o||t[5]!==e||t[6]!==i||t[7]!==d?(P={status:e,transcript:i,interimTranscript:o,waveformData:d,isSupported:b,startRecording:C,stopRecording:A,cancelRecording:j},t[4]=o,t[5]=e,t[6]=i,t[7]=d,t[8]=P):P=t[8],P}function Ql(t){return t.stop()}function Hl(){}function Jl(){return Array(ot).fill(.05)}function Xl(t){const e=L.c(4),{data:s}=t;let i;e[0]!==s?(i=s.map(Zl),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 Zl(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)}function ec(t,e){const s=L.c(5),{editor:i}=Kt(),[r,o]=w.useState(!1),a=w.useRef(0);let d,l;return s[0]!==i||s[1]!==e||s[2]!==t?(d=()=>{const u=p=>{p.dataTransfer?.types.includes("Files")&&(p.preventDefault(),a.current=a.current+1,o(!0))},V=p=>{p.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},c=tc,m=p=>{if(p.preventDefault(),a.current=0,o(!1),!i||!t||!qt(t))return;const x=p.dataTransfer?.files;if(!x||x.length===0)return;const{from:g}=i.state.selection;for(const f of Array.from(x))Sn(i,t,f,g,e)};return window.addEventListener("dragenter",u),window.addEventListener("dragleave",V),window.addEventListener("dragover",c),window.addEventListener("drop",m),()=>{window.removeEventListener("dragenter",u),window.removeEventListener("dragleave",V),window.removeEventListener("dragover",c),window.removeEventListener("drop",m)}},l=[i,t,e],s[0]=i,s[1]=e,s[2]=t,s[3]=d,s[4]=l):(d=s[3],l=s[4]),w.useEffect(d,l),r}function tc(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function nc(t){const e=L.c(11),{selectedModel:s,onUnsupportedFile:i}=t,r=ec(s,i);let o;e[0]!==s?(o=qt(s),e[0]=s,e[1]=o):o=e[1];const a=o,d=r?"opacity-100":"opacity-0 pointer-events-none",l=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let u;e[2]!==d||e[3]!==l?(u=z("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",d,l),e[2]=d,e[3]=l,e[4]=u):u=e[4];let V;e[5]!==s||e[6]!==a?(V=a?n.jsxs(n.Fragment,{children:[n.jsx(cr,{size:24}),n.jsxs("span",{className:"text-sm font-medium",children:["Drop ",bs(s)," here"]})]}):n.jsxs(n.Fragment,{children:[n.jsx(ds,{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]=V):V=e[7];let c;return e[8]!==u||e[9]!==V?(c=n.jsx("div",{className:u,children:V}),e[8]=u,e[9]=V,e[10]=c):c=e[10],c}function sc(){const t=L.c(5),e=tt(),{org:s,locator:i}=ce();let r;return t[0]!==i||t[1]!==e||t[2]!==s.id||t[3]!==s.slug?(r=o=>{const{tiptapDoc:a,virtualMcp:d}=o,l=crypto.randomUUID(),u=d?.id??xn(s.id).id;Pi(sessionStorage,i,l,{tiptapDoc:a}),e({to:"/$org/$taskId",params:{org:s.slug,taskId:l},search:{virtualmcpid:u,autosend:Ei}})},t[0]=i,t[1]=e,t[2]=s.id,t[3]=s.slug,t[4]=r):r=t[4],r}function ic({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=Ri(),i=Ti(),r=s?.messages??[],o=s?.isStreaming??!1,a=s?.isRunInProgress??!1,d=s?.stop??(()=>{}),l=i?.taskId??"",u=i?.tasks??[],V=sc(),{selectedModel:c,selectedVirtualMcp:m,isModelsLoading:p,tiptapDocRef:x,imageModel:g,deepResearchModel:f,chatMode:b,setChatMode:h,simpleModeTier:v,setSimpleModeTier:S}=Lt(),{data:C}=Et.useSession(),N=C?.user?.id,{org:A}=ce(),y=xn(A.id).id,j=un(In),[P,D]=w.useState(!1),{unsupportedFile:R,onUnsupportedFile:T,clearUnsupportedFile:_}=va(),k=Gl(),E=w.useRef(void 0),M=async()=>{E.current=B,await k.startRecording();const K=k.status==="recording"?"started":k.status==="unsupported"?"unsupported":k.status==="permission-denied"?"permission_denied":"unknown";$("chat_voice_started",{thread_id:l,outcome:K})},I=()=>{$("chat_voice_confirmed",{thread_id:l});const K=k.stopRecording();ee.current?.syncVoiceText(E.current,K),ee.current?.focus()},F=()=>{$("chat_voice_cancelled",{thread_id:l}),k.cancelRecording(),ee.current?.restoreContent(E.current)};w.useEffect(()=>{if(k.status!=="recording")return;const K=(k.transcript+(k.interimTranscript?" "+k.interimTranscript:"")).trim();ee.current?.syncVoiceText(E.current,K)},[k.transcript,k.interimTranscript,k.status]);const O=u.find(K=>K.id===l),[B,Y]=w.useState(void 0),X=K=>{Y(K),x.current=K},Z=w.useRef(l);Z.current!==l&&(Z.current=l,Y(void 0),x.current=void 0);const q=[...r].reverse().find(K=>K.role==="assistant")?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow,ee=w.useRef(null),J=b==="plan";w.useEffect(()=>{const K=ue=>{qi(ue)&&ue.code==="KeyL"&&(ue.preventDefault(),ue.shiftKey&&h(b==="plan"?"default":"plan"),ee.current?.focus())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[b,h]);const te=Xi(r),ie=[...r].reverse().find(K=>K.role==="assistant"&&K.metadata?.usage)?.metadata?.usage,oe=ie?.contextTokens??(ie?.totalTokens??0)-(ie?.reasoningTokens??0),de=un(In),ne=!o&&!p&&!Ao(B),re=o||a,je=K=>{K?.preventDefault(),o?($("chat_message_stopped",{thread_id:l}),d()):a?($("chat_message_stopped",{thread_id:l}),d()):ne&&B&&($("chat_message_sent",{thread_id:l||null,mode:b,model_id:c?.modelId??null,model_provider:c?.providerId??null,virtual_mcp_id:m?.id??null,submission:K?"button_or_enter":"programmatic"}),de(),s?s.sendMessage(B):V({tiptapDoc:B,virtualMcp:m}),X(void 0))};return N&&O?.created_by&&O.created_by!==N?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(ds,{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"}),s&&i&&n.jsx(Yt,{}),n.jsx(Ll,{tiptapDoc:B,setTiptapDoc:X,disabled:o,enterToSubmit:!0,onSubmit:je,children:n.jsxs("form",{onSubmit:je,className:z("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(nc,{selectedModel:c,onUnsupportedFile:T}),n.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:n.jsx(Fl,{ref:ee,disabled:o||k.status==="recording",virtualMcpId:m?.id??y,showFileUploader:!0,selectedModel:c,onUnsupportedFile:T})}),n.jsx("div",{className:"flex items-center justify-between p-2.5 gap-1",children:k.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(Xl,{data:k.waveformData.slice(0,28)}),n.jsx("button",{type:"button",onClick:F,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(it,{size:16})}),n.jsx("button",{type:"button",onClick:I,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(pt,{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(xa,{selectedModel:c,isStreaming:o,icon:n.jsx(us,{size:16}),onUnsupportedFile:T}),n.jsx(zl,{disabled:o,onOpenConnections:()=>{$("connections_dialog_opened",{source:"tools_popover",mode:"add"}),D(!0)},virtualMcpId:m?.id??y}),J&&n.jsxs("button",{type:"button",onClick:()=>{j(),$("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),h("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(ls,{size:14,className:"shrink-0"}),"Plan mode",n.jsx(it,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),b==="gen-image"&&g&&n.jsxs("button",{type:"button",disabled:o,onClick:()=>{j(),$("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),h("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 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[n.jsx(cs,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:"Create image"}),n.jsx(it,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),b==="web-search"&&f&&n.jsxs("button",{type:"button",disabled:o,onClick:()=>{j(),$("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),h("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 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[n.jsx(ut,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:"Web search"}),n.jsx(it,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),q&&oe>0&&n.jsx(Zi,{usage:te,totalTokens:oe,contextWindow:q,onOpenContextPanel:t})]}),n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.jsx(fa,{tier:v,onSelect:S}),k.isSupported&&!o&&!a&&n.jsx(Q,{type:"button",onClick:M,variant:"ghost",size:"icon",className:z("size-8 rounded-lg transition-colors",k.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:k.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:n.jsx(_i,{size:18})}),n.jsx(Q,{type:re?"button":"submit",onClick:K=>{re&&(K.preventDefault(),K.stopPropagation(),d())},variant:ne||re?"default":"ghost",size:"icon",disabled:!ne&&!re,className:z("size-8 rounded-lg transition-all",!ne&&!re&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:o?"Stop generating":a?"Cancel run":"Send message (Enter)",children:re?n.jsx(Ni,{size:20}):n.jsx(rr,{size:20})})]})]})})]})},l),e&&n.jsx(Wl,{onClick:()=>{$("connections_banner_clicked",{source:"home_chat_input"}),$("connections_dialog_opened",{source:"home_banner",mode:"add"}),D(!0)}})]})}),n.jsx(Hr,{mode:"browse",open:P,onOpenChange:D,defaultTab:"all"}),n.jsx(ba,{info:R,onClose:_})]})}const rc={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 Ws(t){return`deco-credits-empty-dismissed:${t}`}function jd(t){try{return localStorage.getItem(Ws(t))==="1"}catch{return!1}}function oc(){const t=L.c(50),{org:e}=ce(),s=tt(),{decoKeyId:i}=Rs();let r;t[0]!==e.id||t[1]!==e.slug?(r={connectionId:xt,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=r):r=t[2];const o=ze(r),[a,d]=w.useState(!0),[l,u]=w.useState(""),[V,c]=w.useState(!1),[m,p]=w.useState("usd"),x=m==="brl"?"R$":"$";let g;t[3]!==e.id?(g=()=>{$("credits_empty_state_dismissed",{organization_id:e.id}),d(!1);try{localStorage.setItem(Ws(e.id),"1")}catch{}},t[3]=e.id,t[4]=g):g=t[4];const f=g;let b,h;t[5]!==a||t[6]!==e.id?(b=()=>{a&&$("credits_empty_state_shown",{organization_id:e.id})},h=[a,e.id],t[5]=a,t[6]=e.id,t[7]=b,t[8]=h):(b=t[7],h=t[8]),w.useEffect(b,h);let v;t[9]!==o||t[10]!==m?(v=async Y=>{const X=await o.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:Y,currency:m}});if(X?.isError)throw new Error(X.content?.[0]?.text??"Failed to get top-up URL");return X.structuredContent?.url},t[9]=o,t[10]=m,t[11]=v):v=t[11];let S;t[12]!==f?(S=Y=>{Y&&window.open(Y,"_blank","noopener,noreferrer"),f()},t[12]=f,t[13]=S):S=t[13];let C;t[14]!==v||t[15]!==S?(C={mutationFn:v,onSuccess:S,onError:lc},t[14]=v,t[15]=S,t[16]=C):C=t[16];const{mutate:N,isPending:A}=fn(C),y=parseFloat(l),j=!isNaN(y)&&y>=1;if(!a)return null;let P;t[17]!==f?(P=Y=>!Y&&f(),t[17]=f,t[18]=P):P=t[18];let D;t[19]===Symbol.for("react.memo_cache_sentinel")?(D=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[19]=D):D=t[19];let R;t[20]===Symbol.for("react.memo_cache_sentinel")?(R=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(is,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[20]=R):R=t[20];let T;t[21]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[D,n.jsxs(Oe,{className:"relative gap-3",children:[R,n.jsxs("div",{className:"text-center",children:[n.jsx($e,{className:"text-lg font-semibold",children:"This workspace has no credits"}),n.jsx(Mt,{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[21]=T):T=t[21];let _;t[22]!==m||t[23]!==x||t[24]!==l||t[25]!==y||t[26]!==i||t[27]!==j||t[28]!==A||t[29]!==V||t[30]!==N?(_=i&&n.jsxs("div",{className:"px-6 pb-5",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(xs,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:Y=>{Y&&p(Y)},children:[n.jsx(Ct,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(Ct,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:rc[m].map(Y=>{const{dollars:X,label:Z}=Y;return n.jsxs("button",{type:"button",disabled:A,onClick:()=>{$("credits_topup_clicked",{amount_cents:X*100,currency:m,tier_label:Z,source:"empty_state"}),N(X*100)},className:z("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:[x,X]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:Z})]},X)})}),V?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:x}),n.jsx(Ie,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:Y=>u(Y.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(Q,{className:"h-10",disabled:!j||A,onClick:()=>{$("credits_topup_clicked",{amount_cents:Math.round(y*100),currency:m,tier_label:"custom",source:"empty_state"}),N(Math.round(y*100))},children:A?"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:()=>c(!0),children:"Enter custom amount"})]}),t[22]=m,t[23]=x,t[24]=l,t[25]=y,t[26]=i,t[27]=j,t[28]=A,t[29]=V,t[30]=N,t[31]=_):_=t[31];let k;t[32]!==f||t[33]!==s||t[34]!==e.slug?(k=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),f()},t[32]=f,t[33]=s,t[34]=e.slug,t[35]=k):k=t[35];let E;t[36]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Vs,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[36]=E):E=t[36];let M;t[37]!==k?(M=n.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:k,children:["Use your own provider",E]}),t[37]=k,t[38]=M):M=t[38];let I;t[39]!==f?(I=n.jsx(Q,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:f,children:"Skip for now"}),t[39]=f,t[40]=I):I=t[40];let F;t[41]!==M||t[42]!==I?(F=n.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[M,I]}),t[41]=M,t[42]=I,t[43]=F):F=t[43];let O;t[44]!==_||t[45]!==F?(O=n.jsxs(Ue,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:ac,children:[T,_,F]}),t[44]=_,t[45]=F,t[46]=O):O=t[46];let B;return t[47]!==O||t[48]!==P?(B=n.jsx(Fe,{open:!0,onOpenChange:P,children:O}),t[47]=O,t[48]=P,t[49]=B):B=t[49],B}function ac(t){return t.preventDefault()}function lc(t){se.error(`Top-up failed: ${t.message}`)}function cc(t){const e=L.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=z("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(is,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let d;return e[4]!==r?(d=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]=d):d=e[5],d}function dc(){const t=L.c(8),{org:e}=ce(),s=tt();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=z("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(ms,{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 d;return t[6]!==i?(d=n.jsxs("button",{type:"button",onClick:i,className:r,children:[o,a]}),t[6]=i,t[7]=d):d=t[7],d}function uc(t){const e=L.c(11),{className:s}=t;let i;e[0]!==s?(i=z("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 d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=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(jt,{align:"right",width:"w-3/4"}),n.jsx(jt,{align:"left",width:"w-full",lines:3}),n.jsx(jt,{align:"right",width:"w-2/3"}),n.jsx(jt,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=d):d=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=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]=l):l=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=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]=u):u=e[7];let V;e[8]===Symbol.for("react.memo_cache_sentinel")?(V=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:[l,n.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[u,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]=V):V=e[8];let c;return e[9]!==i?(c=n.jsxs("div",{className:i,children:[a,d,V]}),e[9]=i,e[10]=c):c=e[10],c}function jt(t){const e=L.c(22),{align:s,width:i,lines:r}=t,o=i===void 0?"w-full":i,a=r===void 0?1:r,d=s==="right"?"flex-row-reverse":"flex-row";let l;e[0]!==d?(l=z("flex w-full gap-4 px-4 py-2",d),e[0]=d,e[1]=l):l=e[1];const u=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let V;e[2]!==u?(V=z("flex min-w-0 flex-col gap-2",u),e[2]=u,e[3]=V):V=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=c):c=e[4];const m=s==="right"?"bg-muted":"bg-transparent border border-border/40";let p;e[5]!==m||e[6]!==o?(p=z("min-w-0 rounded-2xl p-4",m,o),e[5]=m,e[6]=o,e[7]=p):p=e[7];let x;e[8]!==a?(x=Array.from({length:a}),e[8]=a,e[9]=x):x=e[9];let g;e[10]!==a||e[11]!==x?(g=n.jsx("div",{className:"space-y-2",children:x.map((v,S)=>n.jsx("div",{className:z("h-3 rounded bg-muted-foreground/20 animate-pulse",S===a-1?"w-3/4":"w-full"),style:{animationDelay:`${S*.1}s`}},S))}),e[10]=a,e[11]=x,e[12]=g):g=e[12];let f;e[13]!==g||e[14]!==p?(f=n.jsx("div",{className:p,children:g}),e[13]=g,e[14]=p,e[15]=f):f=e[15];let b;e[16]!==f||e[17]!==V?(b=n.jsxs("div",{className:V,children:[c,f]}),e[16]=f,e[17]=V,e[18]=b):b=e[18];let h;return e[19]!==b||e[20]!==l?(h=n.jsx("div",{className:l,children:b}),e[19]=b,e[20]=l,e[21]=h):h=e[21],h}function Vc(t){const e=L.c(5),{className:s,children:i}=t;let r;e[0]!==s?(r=z("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 mc(t){const e=L.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=z("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 fc(t){const e=L.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 pc(){const t=L.c(16),{messages:e,status:s}=vn(),i=er(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 d;if(t[2]!==a||t[3]!==o||t[4]!==i||t[5]!==e||t[6]!==s){const l=e.at(-1),u=!a&&l?.role==="assistant"&&l.parts.filter(xc).some(gc),V=!a&&l?.role==="assistant"&&l.parts.some(hc);let c;if(t[8]!==i||t[9]!==s){let p;t[11]!==i.length||t[12]!==s?(p=(x,g)=>n.jsx(Cn,{pair:x,isLastPair:!1,status:g===i.length-1?s:void 0},`pair-${x.user.id}`),t[11]=i.length,t[12]=s,t[13]=p):p=t[13],c=i.slice(0,-1).map(p),t[8]=i,t[9]=s,t[10]=c}else c=t[10];let m;t[14]!==c?(m=n.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:c}),t[14]=c,t[15]=m):m=t[15],d=n.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[m,o&&n.jsx("div",{className:z("min-h-full min-w-0 max-w-2xl mx-auto w-full",(u||V)&&"pb-60"),children:n.jsx(Cn,{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]=d}else d=t[7];return d}function hc(t){return"state"in t&&t.state==="approval-requested"}function gc(t){return t.state==="input-available"}function xc(t){return t.type==="tool-user_ask"}function bc(t){const e=L.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=z("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 Ad=Object.assign(Vc,{Main:mc,Messages:pc,EmptyState:fc,Footer:bc,Input:ic,Provider:Mi,ActiveTaskProvider:Di,Skeleton:uc,IceBreakers:Po,NoAiProviderEmptyState:fr,CreditsEmptyState:oc,CreditsEyebrow:cc,NoCreditsEyebrow:dc,CreditsExhaustedBanner:Ts});export{Hr as A,Ad as C,fa as S,Ll as T,Fl as a,wd as b,bd as c,yd as d,vd as e,Rs as u,jd as w};
|
|
547
|
+
${k}`}]}})},t[12]=x,t[13]=c,t[14]=m,t[15]=p,t[16]=P):P=t[16];const D=P,R=ua;let T;t[17]!==u?(T=(k,E,M)=>{u({id:k,approved:E,...M?{reason:M}:{}})},t[17]=u,t[18]=T):T=t[18];const _=T;if(g){let k;return t[19]!==j||t[20]!==a||t[21]!==h?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Is,{userAskParts:h,isStreaming:a,onSubmit:j})}),t[19]=j,t[20]=a,t[21]=h,t[22]=k):k=t[22],k}if(f.length>0){let k;return t[23]!==D||t[24]!==a||t[25]!==f?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Yo,{plans:f,isStreaming:a,onApprove:D,onDismiss:R})}),t[23]=D,t[24]=a,t[25]=f,t[26]=k):k=t[26],k}if(v.length>0||a&&d){let k;return t[27]!==_||t[28]!==a||t[29]!==v?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Bo,{approvals:v,isStreaming:a,onRespond:_})}),t[27]=_,t[28]=a,t[29]=v,t[30]=k):k=t[30],k}if(!a&&e){if(ia(e)){let E;return t[31]!==s?(E=n.jsx(Ts,{onDismiss:s}),t[31]=s,t[32]=E):E=t[32],E}let k;return t[33]!==s||t[34]!==e||t[35]!==C?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Rt,{variant:"error",error:e,onDismiss:s,onFixInChat:C})}),t[33]=s,t[34]=e,t[35]=C,t[36]=k):k=t[36],k}if(!a&&i&&i!=="stop"&&!d){let k;return t[37]!==r||t[38]!==i||t[39]!==A?(k=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Rt,{variant:"warning",finishReason:i,onDismiss:r,onContinue:A})}),t[37]=r,t[38]=i,t[39]=A,t[40]=k):k=t[40],k}return null}function ua(){document.querySelector("[data-chat-input]")?.focus()}function Va(t){return t.state!=="output-available"}function ma(t){return t.type==="tool-user_ask"}Yt.Error=function(e){return n.jsx(Rt,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};Yt.Warning=function(e){return n.jsx(Rt,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};Yt.UserAskQuestion=Is;const en=[{value:"fast",label:"Fast",Icon:Ai,description:"Quicker responses"},{value:"smart",label:"Smart",Icon:or,description:"Balanced quality"},{value:"thinking",label:"Thinking",Icon:Si,description:"Deeper reasoning"}];function fa(t){const e=L.c(17),{tier:s,onSelect:i}=t;let r;e[0]!==s?(r=en.find(p=>p.value===s)??en[1],e[0]=s,e[1]=r):r=e[1];const o=r,a=o.Icon;let d;e[2]!==a?(d=n.jsx(a,{size:14}),e[2]=a,e[3]=d):d=e[3];let l;e[4]!==o.label?(l=n.jsx("span",{className:"hidden sm:inline",children:o.label}),e[4]=o.label,e[5]=l):l=e[5];let u;e[6]!==d||e[7]!==l?(u=n.jsx(ys,{asChild:!0,children:n.jsxs(Q,{type:"button",variant:"ghost",size:"default",className:"text-muted-foreground hover:text-foreground",children:[d,l]})}),e[6]=d,e[7]=l,e[8]=u):u=e[8];let V;e[9]!==i||e[10]!==s?(V=en.map(p=>{const{value:x,label:g,Icon:f,description:b}=p;return n.jsxs(Ze,{onSelect:()=>i(x),children:[n.jsx(f,{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:b})]}),s===x&&n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"On"})]},x)}),e[9]=i,e[10]=s,e[11]=V):V=e[11];let c;e[12]!==V?(c=n.jsx(vs,{align:"end",className:"w-52 p-1.5",children:V}),e[12]=V,e[13]=c):c=e[13];let m;return e[14]!==u||e[15]!==c?(m=n.jsxs(ws,{children:[u,c]}),e[14]=u,e[15]=c,e[16]=m):m=e[16],m}async function Sn(t,e,s,i,r){if(!qt(e)){se.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!mr(o,e)){const d=bs(e),l=e?.title??"This model";r?r({fileName:s.name,modelName:l,accepted:d}):se.error(`"${s.name}" can't be attached`,{description:`${l} accepts ${d}.`});return}const a=10*1024*1024;if(s.size>a){se.error(`File "${s.name}" exceeds 10MB limit`);return}try{const d=new FileReader,l=new Promise((c,m)=>{d.onload=()=>{const p=d.result;if(typeof p!="string"){m(new Error("Failed to read file as data URL"));return}const x=p.includes(",")?p.split(",")[1]??p:p;c(x)},d.onerror=m});d.readAsDataURL(s);const u=await l,V={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:u};Qi(t,{from:i,to:i},V)}catch(d){console.error("Failed to process file:",d),se.error(`Failed to load file "${s.name}"`)}}function pa(t){const e=L.c(8),{editor:s,selectedModel:i,onUnsupportedFile:r}=t,o=w.useRef(ga);let a,d;e[0]!==s||e[1]!==r||e[2]!==i?(a=()=>{o.current=async(V,c)=>{await Sn(s,i,V,c,r)}},d=[s,i,r],e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),w.useEffect(a,d);let l,u;return e[5]!==s?(l=()=>{if(s?.isDestroyed)return;const V=new on("fileDropHandler");s.state.plugins.find(p=>p.spec.key===V)&&s.unregisterPlugin(V);const m=new xr({key:V,props:{handleDrop:(p,x,g,f)=>{if(f)return!1;const b=x.dataTransfer?.files;if(!b||b.length===0)return!1;x.preventDefault();const h=p.posAtCoords({left:x.clientX,top:x.clientY});if(!h)return!1;const v=Array.from(b),S=h.pos;for(const C of v)o.current?.(C,S);return!0},handlePaste:(p,x)=>{const g=x.clipboardData?.items;if(!g)return!1;const f=Array.from(g).filter(ha);if(f.length===0)return!1;x.preventDefault();const{from:b}=p.state.selection;for(const h of f){const v=h.getAsFile();v&&o.current?.(v,b)}return!0}}});return s.registerPlugin(m),()=>{s?.isDestroyed||s.unregisterPlugin(V)}},u=[s],e[5]=s,e[6]=l,e[7]=u):(l=e[6],u=e[7]),w.useEffect(l,u),null}function ha(t){return t.kind==="file"}function ga(){return Promise.resolve()}function xa(t){const e=L.c(24),{selectedModel:s,isStreaming:i,icon:r,onUnsupportedFile:o}=t,{editor:a}=Kt(),d=w.useRef(null);let l;e[0]!==s?(l=qt(s),e[0]=s,e[1]=l):l=e[1];const u=l;let V;e[2]!==a||e[3]!==o||e[4]!==s?(V=async C=>{const N=C.target.files;if(!N||N.length===0||!a)return;const A=Array.from(N),{from:y}=a.state.selection,j=y;for(const P of A)await Sn(a,s,P,j,o);d.current&&(d.current.value="")},e[2]=a,e[3]=o,e[4]=s,e[5]=V):V=e[5];const c=V;if(!a||!u)return null;let m;e[6]!==s?(m=Vr(s),e[6]=s,e[7]=m):m=e[7];let p;e[8]!==c||e[9]!==i||e[10]!==m?(p=n.jsx("input",{ref:d,type:"file",multiple:!0,accept:m,className:"hidden",onChange:c,disabled:i}),e[8]=c,e[9]=i,e[10]=m,e[11]=p):p=e[11];const x=i||!u;let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=()=>d.current?.click(),e[12]=g):g=e[12];let f;e[13]!==r?(f=r??n.jsx(ss,{size:16}),e[13]=r,e[14]=f):f=e[14];let b;e[15]!==x||e[16]!==f?(b=n.jsx(ct,{asChild:!0,children:n.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground/75",disabled:x,onClick:g,children:f})}),e[15]=x,e[16]=f,e[17]=b):b=e[17];let h;e[18]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(dt,{side:"top",children:"Add file"}),e[18]=h):h=e[18];let v;e[19]!==b?(v=n.jsxs(lt,{children:[b,h]}),e[19]=b,e[20]=v):v=e[20];let S;return e[21]!==v||e[22]!==p?(S=n.jsxs(n.Fragment,{children:[p,v]}),e[21]=v,e[22]=p,e[23]=S):S=e[23],S}function ba(t){const e=L.c(26),{info:s,onClose:i}=t,r=s!==null;let o;e[0]!==i?(o=C=>!C&&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 d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=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]=d):d=e[3];let l,u;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=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(Xn,{size:18})}),u=n.jsx($e,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=l,e[5]=u):(l=e[4],u=e[5]);const V=s?.fileName;let c;e[6]!==V?(c=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[d,n.jsxs(Oe,{className:"relative gap-4",children:[l,n.jsxs("div",{children:[u,n.jsxs(Mt,{className:"mt-1.5 text-sm leading-relaxed",children:[n.jsxs("span",{className:"font-medium text-foreground",children:["“",V,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=V,e[7]=c):c=e[7];const m=s?.modelName;let p;e[8]!==m?(p=n.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[m," accepts"]}),e[8]=m,e[9]=p):p=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(ss,{size:14,className:"text-muted-foreground"}),e[10]=x):x=e[10];const g=s?.accepted;let f;e[11]!==g?(f=n.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[x,n.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=f):f=e[12];let b;e[13]!==p||e[14]!==f?(b=n.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:n.jsxs("div",{className:"rounded-xl border border-border p-4",children:[p,f]})}),e[13]=p,e[14]=f,e[15]=b):b=e[15];let h;e[16]!==i?(h=n.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:n.jsx(Q,{onClick:i,children:"Got it"})}),e[16]=i,e[17]=h):h=e[17];let v;e[18]!==b||e[19]!==h||e[20]!==c?(v=n.jsxs(Ue,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:ya,children:[c,b,h]}),e[18]=b,e[19]=h,e[20]=c,e[21]=v):v=e[21];let S;return e[22]!==r||e[23]!==v||e[24]!==o?(S=n.jsx(Fe,{open:r,onOpenChange:o,children:v}),e[22]=r,e[23]=v,e[24]=o,e[25]=S):S=e[25],S}function ya(t){return t.preventDefault()}function va(){const t=L.c(3),[e,s]=w.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 wa=br;var ja=["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] *)"],ln=ja.join(","),Ps=typeof Element>"u",ht=Ps?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Tt=!Ps&&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},Pt=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]"):Pt(e.parentNode));return a},Aa=function(e){var s,i=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return i===""||i==="true"},Sa=function(e,s,i){if(Pt(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(ln));return s&&ht.call(e,ln)&&r.unshift(e),r=r.filter(i),r},cn=function(e,s,i){for(var r=[],o=Array.from(e);o.length;){var a=o.shift();if(!Pt(a,!1))if(a.tagName==="SLOT"){var d=a.assignedElements(),l=d.length?d:a.children,u=cn(l,!0,i);i.flatten?r.push.apply(r,u):r.push({scopeParent:a,candidates:u})}else{var V=ht.call(a,ln);V&&i.filter(a)&&(s||!e.includes(a))&&r.push(a);var c=a.shadowRoot||typeof i.getShadowRoot=="function"&&i.getShadowRoot(a),m=!Pt(c,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(c&&m){var p=cn(c===!0?a.children:c.children,!0,i);i.flatten?r.push.apply(r,p):r.push({scopeParent:a,candidates:p})}else o.unshift.apply(o,a.children)}}return r},Es=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Ds=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Aa(e))&&!Es(e)?0:e.tabIndex},ka=function(e,s){var i=Ds(e);return i<0&&s&&!Es(e)?0:i},_a=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},Ms=function(e){return e.tagName==="INPUT"},Na=function(e){return Ms(e)&&e.type==="hidden"},Ca=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(i){return i.tagName==="SUMMARY"});return s},Ia=function(e,s){for(var i=0;i<e.length;i++)if(e[i].checked&&e[i].form===s)return e[i]},Ra=function(e){if(!e.name)return!0;var s=e.form||Tt(e),i=function(d){return s.querySelectorAll('input[type="radio"][name="'+d+'"]')},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=Ia(r,e.form);return!o||o===e},Ta=function(e){return Ms(e)&&e.type==="radio"},Pa=function(e){return Ta(e)&&!Ra(e)},Ea=function(e){var s,i=e&&Tt(e),r=(s=i)===null||s===void 0?void 0:s.host,o=!1;if(i&&i!==e){var a,d,l;for(o=!!((a=r)!==null&&a!==void 0&&(d=a.ownerDocument)!==null&&d!==void 0&&d.contains(r)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!o&&r;){var u,V,c;i=Tt(r),r=(u=i)===null||u===void 0?void 0:u.host,o=!!((V=r)!==null&&V!==void 0&&(c=V.ownerDocument)!==null&&c!==void 0&&c.contains(r))}}return o},On=function(e){var s=e.getBoundingClientRect(),i=s.width,r=s.height;return i===0&&r===0},Da=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=ht.call(e,"details>summary:first-of-type"),d=a?e.parentElement:e;if(ht.call(d,"details:not([open]) *"))return!0;if(!i||i==="full"||i==="full-native"||i==="legacy-full"){if(typeof r=="function"){for(var l=e;e;){var u=e.parentElement,V=Tt(e);if(u&&!u.shadowRoot&&r(u)===!0)return On(e);e.assignedSlot?e=e.assignedSlot:!u&&V!==e.ownerDocument?e=V.host:e=u}e=l}if(Ea(e))return!e.getClientRects().length;if(i!=="legacy-full")return!0}else if(i==="non-zero-area")return On(e);return!1},Ma=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 ht.call(s,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}s=s.parentElement}return!1},La=function(e,s){return!(s.disabled||Na(s)||Da(s,e)||Ca(s)||Ma(s))},$n=function(e,s){return!(Pa(s)||Ds(s)<0||!La(e,s))},Fa=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},Ls=function(e){var s=[],i=[];return e.forEach(function(r,o){var a=!!r.scopeParent,d=a?r.scopeParent:r,l=ka(d,a),u=a?Ls(r.candidates):d;l===0?a?s.push.apply(s,u):s.push(d):i.push({documentOrder:o,tabIndex:l,item:r,isScope:a,content:u})}),i.sort(_a).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(s)},Fs=function(e,s){s=s||{};var i;return s.getShadowRoot?i=cn([e],s.includeContainer,{filter:$n.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:Fa}):i=Sa(e,s.includeContainer,$n.bind(null,s)),Ls(i)};function Ua(){return/apple/i.test(navigator.vendor)}const Bn="data-floating-ui-focusable";function Oa(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 dn(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&ii(s)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function st(t){return"composedPath"in t?t.composedPath()[0]:t.target}function tn(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 $a(t){return t.matches("html,body")}function gt(t){return t?.ownerDocument||document}function Ba(t){return t?t.hasAttribute(Bn)?t:t.querySelector("["+Bn+"]")||t:null}function St(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,...St(t,r.id,s)])}function za(t){return"nativeEvent"in t}var qa=typeof document<"u",Ka=function(){},He=qa?w.useLayoutEffect:Ka;const Ya={...Zn},Wa=Ya.useInsertionEffect,Ga=Wa||(t=>t());function et(t){const e=w.useRef(()=>{});return Ga(()=>{e.current=t}),w.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 Us=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Os(t,e){const s=Fs(t,Us()),i=s.length;if(i===0)return;const r=Oa(gt(t)),o=s.indexOf(r),a=o===-1?e===1?0:i-1:o+e;return s[a]}function Qa(t){return Os(gt(t).body,1)||t}function Ha(t){return Os(gt(t).body,-1)||t}function nn(t,e){const s=e||t.currentTarget,i=t.relatedTarget;return!i||!dn(s,i)}function Ja(t){Fs(t,Us()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function zn(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 Xa="data-floating-ui-focusable",qn="active",Kn="selected",Za={...Zn};let Yn=!1,el=0;const Wn=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+el++;function tl(){const[t,e]=w.useState(()=>Yn?Wn():void 0);return He(()=>{t==null&&e(Wn())},[]),w.useEffect(()=>{Yn=!0},[]),t}const nl=Za.useId,kn=nl||tl;function sl(){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 il=w.createContext(null),rl=w.createContext(null),$s=()=>{var t;return((t=w.useContext(il))==null?void 0:t.id)||null},Bs=()=>w.useContext(rl);function _n(t){return"data-floating-ui-"+t}const ol={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},Gn=w.forwardRef(function(e,s){const[i,r]=w.useState();He(()=>{Ua()&&r("button")},[]);const o={ref:s,tabIndex:0,role:i,"aria-hidden":i?void 0:!0,[_n("focus-guard")]:"",style:ol};return n.jsx("span",{...e,...o})}),al={clipPath:"inset(50%)",position:"fixed",top:0,left:0},zs=w.createContext(null),Qn=_n("portal");function ll(t){t===void 0&&(t={});const{id:e,root:s}=t,i=kn(),r=dl(),[o,a]=w.useState(null),d=w.useRef(null);return He(()=>()=>{o?.remove(),queueMicrotask(()=>{d.current=null})},[o]),He(()=>{if(!i||d.current)return;const l=e?document.getElementById(e):null;if(!l)return;const u=document.createElement("div");u.id=i,u.setAttribute(Qn,""),l.appendChild(u),d.current=u,a(u)},[e,i]),He(()=>{if(s===null||!i||d.current)return;let l=s||r?.portalNode;l&&!ui(l)&&(l=l.current),l=l||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,l.appendChild(u));const V=document.createElement("div");V.id=i,V.setAttribute(Qn,""),l=u||l,l.appendChild(V),d.current=V,a(V)},[e,s,i,r]),o}function cl(t){const{children:e,id:s,root:i,preserveTabOrder:r=!0}=t,o=ll({id:s,root:i}),[a,d]=w.useState(null),l=w.useRef(null),u=w.useRef(null),V=w.useRef(null),c=w.useRef(null),m=a?.modal,p=a?.open,x=!!a&&!a.modal&&a.open&&r&&!!(i||o);return w.useEffect(()=>{if(!o||!r||m)return;function g(f){o&&nn(f)&&(f.type==="focusin"?zn:Ja)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,r,m]),w.useEffect(()=>{o&&(p||zn(o))},[p,o]),n.jsxs(zs.Provider,{value:w.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:V,afterInsideRef:c,portalNode:o,setFocusManagerState:d}),[r,o]),children:[x&&o&&n.jsx(Gn,{"data-type":"outside",ref:l,onFocus:g=>{if(nn(g,o)){var f;(f=V.current)==null||f.focus()}else{const b=a?a.domReference:null,h=Ha(b);h?.focus()}}}),x&&o&&n.jsx("span",{"aria-owns":o.id,style:al}),o&&oi.createPortal(e,o),x&&o&&n.jsx(Gn,{"data-type":"outside",ref:u,onFocus:g=>{if(nn(g,o)){var f;(f=c.current)==null||f.focus()}else{const b=a?a.domReference:null,h=Qa(b);h?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const dl=()=>w.useContext(zs),ul={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Vl={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Hn=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 ml(t,e){e===void 0&&(e={});const{open:s,onOpenChange:i,elements:r,dataRef:o}=t,{enabled:a=!0,escapeKey:d=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:V=!1,referencePressEvent:c="pointerdown",ancestorScroll:m=!1,bubbles:p,capture:x}=e,g=Bs(),f=et(typeof l=="function"?l:()=>!1),b=typeof l=="function"?f:l,h=w.useRef(!1),{escapeKey:v,outsidePress:S}=Hn(p),{escapeKey:C,outsidePress:N}=Hn(x),A=w.useRef(!1),y=et(_=>{var k;if(!s||!a||!d||_.key!=="Escape"||A.current)return;const E=(k=o.current.floatingContext)==null?void 0:k.nodeId,M=g?St(g.nodesRef.current,E):[];if(!v&&(_.stopPropagation(),M.length>0)){let I=!0;if(M.forEach(F=>{var O;if((O=F.context)!=null&&O.open&&!F.context.dataRef.current.__escapeKeyBubbles){I=!1;return}}),!I)return}i(!1,za(_)?_.nativeEvent:_,"escape-key")}),j=et(_=>{var k;const E=()=>{var M;y(_),(M=st(_))==null||M.removeEventListener("keydown",E)};(k=st(_))==null||k.addEventListener("keydown",E)}),P=et(_=>{var k;const E=o.current.insideReactTree;o.current.insideReactTree=!1;const M=h.current;if(h.current=!1,u==="click"&&M||E||typeof b=="function"&&!b(_))return;const I=st(_),F="["+_n("inert")+"]",O=gt(r.floating).querySelectorAll(F);let B=Le(I)?I:null;for(;B&&!Ht(B);){const H=li(B);if(Ht(H)||!Le(H))break;B=H}if(O.length&&Le(I)&&!$a(I)&&!dn(I,r.floating)&&Array.from(O).every(H=>!dn(B,H)))return;if(ci(I)&&T){const H=Ht(I),q=di(I),ee=/auto|scroll/,J=H||ee.test(q.overflowX),te=H||ee.test(q.overflowY),ie=J&&I.clientWidth>0&&I.scrollWidth>I.clientWidth,oe=te&&I.clientHeight>0&&I.scrollHeight>I.clientHeight,de=q.direction==="rtl",ne=oe&&(de?_.offsetX<=I.offsetWidth-I.clientWidth:_.offsetX>I.clientWidth),re=ie&&_.offsetY>I.clientHeight;if(ne||re)return}const Y=(k=o.current.floatingContext)==null?void 0:k.nodeId,X=g&&St(g.nodesRef.current,Y).some(H=>{var q;return tn(_,(q=H.context)==null?void 0:q.elements.floating)});if(tn(_,r.floating)||tn(_,r.domReference)||X)return;const Z=g?St(g.nodesRef.current,Y):[];if(Z.length>0){let H=!0;if(Z.forEach(q=>{var ee;if((ee=q.context)!=null&&ee.open&&!q.context.dataRef.current.__outsidePressBubbles){H=!1;return}}),!H)return}i(!1,_,"outside-press")}),D=et(_=>{var k;const E=()=>{var M;P(_),(M=st(_))==null||M.removeEventListener(u,E)};(k=st(_))==null||k.addEventListener(u,E)});w.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=v,o.current.__outsidePressBubbles=S;let _=-1;function k(O){i(!1,O,"ancestor-scroll")}function E(){window.clearTimeout(_),A.current=!0}function M(){_=window.setTimeout(()=>{A.current=!1},ai()?5:0)}const I=gt(r.floating);d&&(I.addEventListener("keydown",C?j:y,C),I.addEventListener("compositionstart",E),I.addEventListener("compositionend",M)),b&&I.addEventListener(u,N?D:P,N);let F=[];return m&&(Le(r.domReference)&&(F=Qt(r.domReference)),Le(r.floating)&&(F=F.concat(Qt(r.floating))),!Le(r.reference)&&r.reference&&r.reference.contextElement&&(F=F.concat(Qt(r.reference.contextElement)))),F=F.filter(O=>{var B;return O!==((B=I.defaultView)==null?void 0:B.visualViewport)}),F.forEach(O=>{O.addEventListener("scroll",k,{passive:!0})}),()=>{d&&(I.removeEventListener("keydown",C?j:y,C),I.removeEventListener("compositionstart",E),I.removeEventListener("compositionend",M)),b&&I.removeEventListener(u,N?D:P,N),F.forEach(O=>{O.removeEventListener("scroll",k)}),window.clearTimeout(_)}},[o,r,d,b,u,s,i,m,a,v,S,y,C,j,P,N,D]),w.useEffect(()=>{o.current.insideReactTree=!1},[o,b,u]);const R=w.useMemo(()=>({onKeyDown:y,...V&&{[ul[c]]:_=>{i(!1,_.nativeEvent,"reference-press")},...c!=="click"&&{onClick(_){i(!1,_.nativeEvent,"reference-press")}}}}),[y,i,V,c]),T=w.useMemo(()=>{function _(k){k.button===0&&(h.current=!0)}return{onKeyDown:y,onMouseDown:_,onMouseUp:_,[Vl[u]]:()=>{o.current.insideReactTree=!0}}},[y,u,o]);return w.useMemo(()=>a?{reference:R,floating:T}:{},[a,R,T])}function fl(t){const{open:e=!1,onOpenChange:s,elements:i}=t,r=kn(),o=w.useRef({}),[a]=w.useState(()=>sl()),d=$s()!=null,[l,u]=w.useState(i.reference),V=et((p,x,g)=>{o.current.openEvent=p?x:void 0,a.emit("openchange",{open:p,event:x,reason:g,nested:d}),s?.(p,x,g)}),c=w.useMemo(()=>({setPositionReference:u}),[]),m=w.useMemo(()=>({reference:l||i.reference||null,floating:i.floating||null,domReference:i.reference}),[l,i.reference,i.floating]);return w.useMemo(()=>({dataRef:o,open:e,onOpenChange:V,elements:m,events:a,floatingId:r,refs:c}),[e,V,m,a,r,c])}function pl(t){t===void 0&&(t={});const{nodeId:e}=t,s=fl({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||s,r=i.elements,[o,a]=w.useState(null),[d,l]=w.useState(null),V=r?.domReference||o,c=w.useRef(null),m=Bs();He(()=>{V&&(c.current=V)},[V]);const p=ri({...t,elements:{...r,...d&&{reference:d}}}),x=w.useCallback(v=>{const S=Le(v)?{getBoundingClientRect:()=>v.getBoundingClientRect(),getClientRects:()=>v.getClientRects(),contextElement:v}:v;l(S),p.refs.setReference(S)},[p.refs]),g=w.useCallback(v=>{(Le(v)||v===null)&&(c.current=v,a(v)),(Le(p.refs.reference.current)||p.refs.reference.current===null||v!==null&&!Le(v))&&p.refs.setReference(v)},[p.refs]),f=w.useMemo(()=>({...p.refs,setReference:g,setPositionReference:x,domReference:c}),[p.refs,g,x]),b=w.useMemo(()=>({...p.elements,domReference:V}),[p.elements,V]),h=w.useMemo(()=>({...p,...i,refs:f,elements:b,nodeId:e}),[p,f,b,e,i]);return He(()=>{i.dataRef.current.floatingContext=h;const v=m?.nodesRef.current.find(S=>S.id===e);v&&(v.context=h)}),w.useMemo(()=>({...p,context:h,refs:f,elements:b}),[p,f,b,h])}function sn(t,e,s){const i=new Map,r=s==="item";let o=t;if(r&&t){const{[qn]:a,[Kn]:d,...l}=t;o=l}return{...s==="floating"&&{tabIndex:-1,[Xa]:""},...o,...e.map(a=>{const d=a?a[s]:null;return typeof d=="function"?t?d(t):null:d}).concat(t).reduce((a,d)=>(d&&Object.entries(d).forEach(l=>{let[u,V]=l;if(!(r&&[qn,Kn].includes(u)))if(u.indexOf("on")===0){if(i.has(u)||i.set(u,[]),typeof V=="function"){var c;(c=i.get(u))==null||c.push(V),a[u]=function(){for(var m,p=arguments.length,x=new Array(p),g=0;g<p;g++)x[g]=arguments[g];return(m=i.get(u))==null?void 0:m.map(f=>f(...x)).find(f=>f!==void 0)}}}else a[u]=V}),a),{})}}function hl(t){t===void 0&&(t=[]);const e=t.map(d=>d?.reference),s=t.map(d=>d?.floating),i=t.map(d=>d?.item),r=w.useCallback(d=>sn(d,t,"reference"),e),o=w.useCallback(d=>sn(d,t,"floating"),s),a=w.useCallback(d=>sn(d,t,"item"),i);return w.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:a}),[r,o,a])}const gl=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function xl(t,e){var s,i;e===void 0&&(e={});const{open:r,elements:o,floatingId:a}=t,{enabled:d=!0,role:l="dialog"}=e,u=kn(),V=((s=o.domReference)==null?void 0:s.id)||u,c=w.useMemo(()=>{var h;return((h=Ba(o.floating))==null?void 0:h.id)||a},[o.floating,a]),m=(i=gl.get(l))!=null?i:l,x=$s()!=null,g=w.useMemo(()=>m==="tooltip"||l==="label"?{["aria-"+(l==="label"?"labelledby":"describedby")]:r?c:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":m==="alertdialog"?"dialog":m,"aria-controls":r?c:void 0,...m==="listbox"&&{role:"combobox"},...m==="menu"&&{id:V},...m==="menu"&&x&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[m,c,x,r,V,l]),f=w.useMemo(()=>{const h={id:c,...m&&{role:m}};return m==="tooltip"||l==="label"?h:{...h,...m==="menu"&&{"aria-labelledby":V}}},[m,c,V,l]),b=w.useCallback(h=>{let{active:v,selected:S}=h;const C={role:"option",...v&&{id:c+"-fui-option"}};switch(l){case"select":case"combobox":return{...C,"aria-selected":S}}return{}},[c,l]);return w.useMemo(()=>d?{reference:g,floating:f,item:b}:{},[d,g,f,b])}function bl(t){const e=L.c(24),{editor:s,query:i,items:r,onSelect:o,onClose:a}=t,[d,l]=w.useState(0),u=w.useRef(r),V=w.useRef(d),c=w.useRef(o),m=w.useRef(a),p=w.useDeferredValue(i);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{l(0)},e[0]=x):x=e[0];let g;e[1]!==p?(g=[p],e[1]=p,e[2]=g):g=e[2],w.useEffect(x,g);let f,b;e[3]!==r.length||e[4]!==d?(f=()=>{d>=r.length&&r.length>0&&l(0)},b=[r.length,d],e[3]=r.length,e[4]=d,e[5]=f,e[6]=b):(f=e[5],b=e[6]),w.useEffect(f,b);let h,v;e[7]!==r?(h=()=>{u.current=r},v=[r],e[7]=r,e[8]=h,e[9]=v):(h=e[8],v=e[9]),w.useEffect(h,v);let S,C;e[10]!==d?(S=()=>{V.current=d},C=[d],e[10]=d,e[11]=S,e[12]=C):(S=e[11],C=e[12]),w.useEffect(S,C);let N,A;e[13]!==o?(A=()=>{c.current=o},N=[o],e[13]=o,e[14]=N,e[15]=A):(N=e[14],A=e[15]),w.useEffect(A,N);let y,j;e[16]!==a?(y=()=>{m.current=a},j=[a],e[16]=a,e[17]=y,e[18]=j):(y=e[17],j=e[18]),w.useEffect(y,j);let P,D;e[19]!==s?(P=()=>{if(s?.isDestroyed)return;let _;try{_=s.view.dom}catch{return}if(!_)return;const k=M=>{const I=u.current;if(!I.length)return!1;const F=()=>l(B=>(B+1)%I.length),O=()=>l(B=>(B-1+I.length)%I.length);switch(M.key){case"ArrowUp":return M.preventDefault(),O(),!0;case"ArrowDown":return M.preventDefault(),F(),!0;case"Tab":return M.preventDefault(),M.shiftKey?O():F(),!0;case"Home":return M.preventDefault(),l(0),!0;case"End":return M.preventDefault(),l(I.length-1),!0;case"Enter":{if(M.isComposing)return!1;M.preventDefault();const B=V.current;return B!==-1&&I[B]&&c.current?.(I[B],B),!0}case"Escape":return M.preventDefault(),m.current?.(),!0;default:return!1}},E=M=>{k(M)};return _.addEventListener("keydown",E,!0),()=>{_?.removeEventListener("keydown",E,!0)}},D=[s],e[19]=s,e[20]=P,e[21]=D):(P=e[20],D=e[21]),w.useEffect(P,D);const R=r.length?d:void 0;let T;return e[22]!==R?(T={selectedIndex:R,setSelectedIndex:l},e[22]=R,e[23]=T):T=e[23],T}function yl(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 qs=w.createContext(void 0);function Ks(){const t=w.useContext(qs);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function vl({editor:t,char:e,pluginKey:s,allow:i,onOpenChange:r}){const[o,a]=w.useReducer(yl,{open:!1,element:null,query:"",range:null,selectedItem:null}),d=w.useRef(r);return d.current=r,w.useEffect(()=>{if(t?.isDestroyed)return;const l=s instanceof on?s:new on(s);t.state.plugins.find(c=>c.spec.key===l)&&t.unregisterPlugin(l);const V=Ar({pluginKey:l,editor:t,char:e,allow(c){const m=t.state.doc.resolve(c.range.from);for(let p=m.depth;p>0;p--)if(m.node(p).type.name==="image")return!1;return!(i&&!i(c))},command(){},render:()=>({onStart:c=>{a({type:"ON_START",payload:{element:c.decorationNode??null,query:c.query,range:c.range}}),d.current?.(!0)},onUpdate:c=>{a({type:"ON_UPDATE",payload:{element:c.decorationNode??null,query:c.query,range:c.range}})},onKeyDown:c=>c.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),d.current?.(!1)}}),items:()=>[]});return t.registerPlugin(V),()=>{t?.isDestroyed||t.unregisterPlugin(l)}},[t,s,e,a,i]),{state:o,dispatch:a}}function wl({editor:t,queryKey:e,queryFn:s,onSelect:i}){const{state:r,dispatch:o}=Ks(),a=w.useDeferredValue(r.query),{data:d}=Vi({queryKey:Ae.suggestionItems(e,r.open,a),queryFn:()=>r.open?s({query:a}):[]}),l=()=>{o({type:"ON_EXIT"})},u=async(c,m)=>{if(!(r.selectedItem!==null||!r.range)){o({type:"SET_SELECTED_ITEM",payload:c});try{const{view:p}=t,g=p.state.selection.$to.nodeAfter?.text?.startsWith(" "),f=r.range?{...r.range}:{from:0,to:0};g&&r.range&&(f.to+=1),await i({range:f,item:c})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):l()}catch{l()}}},{selectedIndex:V}=bl({editor:t,query:a,items:d,onSelect:u,onClose:l});return{selectedItem:r.selectedItem,items:d,selectedIndex:V,close:l,onSelect:u}}function jl({children:t}){const{state:e,dispatch:s}=Ks(),{open:i,element:r}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:d,context:l}=pl({placement:"bottom-start",open:i,onOpenChange:m=>{m||o()},elements:{reference:r},middleware:[mi(10),fi(),pi()],whileElementsMounted:hi}),u=ml(l,{outsidePress:m=>!(m.target instanceof Element&&m.target.closest(".ProseMirror"))}),V=xl(l,{role:"listbox"}),{getFloatingProps:c}=hl([u,V]);return i?n.jsx(cl,{children:n.jsx("div",{ref:a.setFloating,style:d,...c(),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 Al=t=>{const e=L.c(29),{item:s,isSelected:i,onSelect:r,isLoading:o,ref:a}=t;let d;if(e[0]!==s){const N=We(s._meta);d=s.title||zt(s.name,N),e[0]=s,e[1]=d}else d=e[1];const l=d,u=s.description||null,V=s.icon,c=i&&"bg-accent text-accent-foreground",m=o&&"pointer-events-none opacity-50";let p;e[2]!==c||e[3]!==m?(p=z("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",c,m),e[2]=c,e[3]=m,e[4]=p):p=e[4];let x;e[5]!==V||e[6]!==l?(x=V!==void 0&&n.jsx(yn,{icon:V,name:l,size:"xs",className:"mr-2"}),e[5]=V,e[6]=l,e[7]=x):x=e[7];let g;e[8]!==l?(g=n.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:l}),e[8]=l,e[9]=g):g=e[9];let f;e[10]!==o?(f=o&&n.jsx(_t,{size:"xs"}),e[10]=o,e[11]=f):f=e[11];let b;e[12]!==g||e[13]!==f?(b=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,f]}),e[12]=g,e[13]=f,e[14]=b):b=e[14];let h;e[15]!==u?(h=u&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:u}),e[15]=u,e[16]=h):h=e[16];let v;e[17]!==b||e[18]!==h?(v=n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[b,h]}),e[17]=b,e[18]=h,e[19]=v):v=e[19];let S;e[20]!==s.drillable?(S=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]=S):S=e[21];let C;return e[22]!==r||e[23]!==a||e[24]!==v||e[25]!==S||e[26]!==p||e[27]!==x?(C=n.jsxs("div",{ref:a,onClick:r,className:p,children:[x,v,S]}),e[22]=r,e[23]=a,e[24]=v,e[25]=S,e[26]=p,e[27]=x,e[28]=C):C=e[28],C},Sl=t=>{const e=L.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:d,selectedIndex:l,onSelect:u,selectedItem:V}=wl(a);if(!d.length){let x;return e[5]===Symbol.for("react.memo_cache_sentinel")?(x=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]=x):x=e[5],x}let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=c):c=e[6];let m;if(e[7]!==u||e[8]!==d||e[9]!==l||e[10]!==V?.name){let x;e[12]!==u||e[13]!==l||e[14]!==V?.name?(x=(g,f)=>n.jsx(Al,{item:g,isSelected:f===l,ref:f===l?Nl:void 0,onSelect:()=>u(g,f),isLoading:V?.name===g.name},g.name),e[12]=u,e[13]=l,e[14]=V?.name,e[15]=x):x=e[15],m=d.map(x),e[7]=u,e[8]=d,e[9]=l,e[10]=V?.name,e[11]=m}else m=e[11];let p;return e[16]!==m?(p=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:c,children:n.jsx("div",{className:"p-1",children:m})}),e[16]=m,e[17]=p):p=e[17],p};function kl(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"p-1",children:[...Array(3)].map(_l)}),t[0]=e):e=t[0],e}function _l(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 Ys(t){const e=L.c(18),{editor:s,char:i,pluginKey:r,queryKey:o,queryFn:a,onSelect:d,allow:l,onOpenChange:u}=t;let V;e[0]!==l||e[1]!==i||e[2]!==s||e[3]!==u||e[4]!==r?(V={editor:s,char:i,pluginKey:r,allow:l,onOpenChange:u},e[0]=l,e[1]=i,e[2]=s,e[3]=u,e[4]=r,e[5]=V):V=e[5];const{state:c,dispatch:m}=vl(V);let p;e[6]!==m||e[7]!==c?(p={state:c,dispatch:m},e[6]=m,e[7]=c,e[8]=p):p=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(kl,{}),e[9]=x):x=e[9];let g;e[10]!==s||e[11]!==d||e[12]!==a||e[13]!==o?(g=n.jsx(jl,{children:n.jsx(w.Suspense,{fallback:x,children:n.jsx(Sl,{editor:s,queryKey:o,queryFn:a,onSelect:d})})}),e[10]=s,e[11]=d,e[12]=a,e[13]=o,e[14]=g):g=e[14];let f;return e[15]!==p||e[16]!==g?(f=n.jsx(qs.Provider,{value:p,children:g}),e[15]=p,e[16]=g,e[17]=f):f=e[17],f}function Nl(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const Cl=[{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}],Il=({editor:t,virtualMcpId:e})=>{const s=Dt(),{org:i}=ce(),r=Oi(),o=ze({connectionId:e,orgId:i.id,orgSlug:i.slug}),a=Ae.virtualMcpResources(e,i.id),[d,l]=w.useState("categories"),u=w.useRef(d);u.current=d;const V=w.useRef(null),c=w.useRef(!1),m=["at-mention",i.id,e??"default",d],p=async({item:f,range:b})=>{if($("chat_picker_item_selected",{picker:"@",item_kind:f.kind,item_name:f.name}),f.kind!=="category"&&(c.current=!0),f.kind==="category")return l(f.name==="agents"?"agents":"resources"),!1;if(f.kind==="agent"&&f.agentId){mt(t,b,{id:f.agentId,name:f.name,metadata:{agentId:f.agentId,title:f.name},char:"@"}),l("categories");return}if(f.kind==="resource"&&f.uri&&o){try{const h=await js(o,f.uri);mt(t,b,{id:f.uri,name:f.uri,metadata:h.contents,char:"@"})}catch(h){console.error("[at-mention] Failed to fetch resource:",h),se.error("Failed to load resource. Please try again.")}l("categories");return}},x=async f=>{const{query:b}=f,h=u.current;if(h==="categories"){if(!b.trim())return Cl;const C=b.toLowerCase(),N=r.filter(y=>y.status==="active"&&(!y.id||!Nn(y.id))&&y.id!==e&&(y.title.toLowerCase().includes(C)||y.description?.toLowerCase().includes(C))).map(y=>({name:y.title,title:y.title,description:y.description??void 0,icon:y.icon??null,kind:"agent",agentId:y.id})),A=await(async()=>{if(!o)return[];let y=s.getQueryData(a);return y||(y=await s.fetchQuery({queryKey:a,queryFn:()=>Vt(o),staleTime:6e4})),(y?.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[...N,...A]}if(h==="agents"){let C=r.filter(N=>N.status==="active"&&(!N.id||!Nn(N.id))&&N.id!==e);if(b.trim()){const N=b.toLowerCase();C=C.filter(A=>A.title.toLowerCase().includes(N)||A.description?.toLowerCase().includes(N))}return C.map(N=>({name:N.title,title:N.title,description:N.description??void 0,icon:N.icon??null,kind:"agent",agentId:N.id}))}if(!o)return[];let v=s.getQueryData(a);v?s.fetchQuery({queryKey:a,queryFn:()=>Vt(o),staleTime:6e4}).catch(()=>{}):v=await s.fetchQuery({queryKey:a,queryFn:()=>Vt(o),staleTime:6e4});let S=v?.resources??[];if(b.trim()){const C=b.toLowerCase();S=S.filter(N=>N.uri.toLowerCase().includes(C)||N.name?.toLowerCase().includes(C)||N.description?.toLowerCase().includes(C))}return S.map(C=>({name:C.name??C.uri,title:C.name,description:C.description,kind:"resource",uri:C.uri}))},g=f=>{if(f)V.current=Date.now(),c.current=!1,$("chat_picker_opened",{picker:"@"});else{const b=V.current;$("chat_picker_closed",{picker:"@",outcome:c.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),V.current=null,l("categories")}};return n.jsx(Ys,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:m,queryFn:x,onSelect:p,onOpenChange:g})};function Rl(t,e,s){const i=$i(t),r=xi(),o=new Map(r.map(u=>[u.id,u])),a=(i?.connections??[]).map(u=>u.connection_id),{data:d}=hn({queryKey:Ae.promptConnectionMap(e,a),queryFn:async()=>{const u={};return await Promise.all(a.map(async V=>{try{const c=await bi({connectionId:V,orgId:e,orgSlug:s}),m=await Nt(c);for(const p of m.prompts)p.name in u||(u[p.name]=V)}catch{}})),u},staleTime:6e4,enabled:a.length>0}),l=new Map;for(const[u,V]of Object.entries(d??{})){const c=o.get(V);c&&l.set(u,c)}return l}async function Jn(t,e,s,i,r,o){try{const a=await jn(s,i,o);mt(t,e,{id:i,name:wn(i,r),metadata:a.messages,char:"/"})}catch(a){console.error("[slash] Failed to fetch prompt:",a),se.error("Failed to load prompt. Please try again.")}}async function Tl(t,e,s,i){try{const r=await js(s,i);mt(t,e,{id:i,name:i,metadata:r.contents,char:"/"})}catch(r){console.error("[slash] Failed to fetch resource:",r),se.error("Failed to load resource. Please try again.")}}const Pl=({editor:t,virtualMcpId:e})=>{const s=Dt(),{org:i}=ce(),r=ze({connectionId:e,orgId:i.id,orgSlug:i.slug}),o=Rl(e,i.id,i.slug),a=w.useRef(o);a.current=o;const d=Ae.virtualMcpPrompts(e,i.id),l=Ae.virtualMcpResources(e,i.id),u=["slash-mention",i.id,e??"default"],[V,c]=w.useState(null),m=w.useRef(null),p=w.useRef(!1),x=async({item:h,range:v})=>{if($("chat_picker_item_selected",{picker:"/",item_kind:h.kind,item_name:h.name}),p.current=!0,!!r)if(h.kind==="prompt"){if(h.arguments&&h.arguments.length>0){c({range:v,item:h});return}const S=We(h._meta);await Jn(t,v,r,h.name,S)}else h.uri&&await Tl(t,v,r,h.uri)},g=async h=>{if(!V||!r)return;const{range:v,item:S}=V,C=We(S._meta);await Jn(t,v,r,S.name,C,h),c(null)},f=async h=>{const{query:v}=h;if(!r)return[];const[S,C]=await Promise.all([El(s,d,r),Dl(s,l,r)]),N=v.trim().toLowerCase(),A=(S??[]).filter(j=>!N||j.name.toLowerCase().includes(N)||j.title?.toLowerCase().includes(N)||j.description?.toLowerCase().includes(N)).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})),y=(C??[]).filter(j=>!N||j.uri.toLowerCase().includes(N)||j.name?.toLowerCase().includes(N)||j.description?.toLowerCase().includes(N)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}));return[...A,...y]},b=V?.item.kind==="prompt"?{name:V.item.name,arguments:V.item.arguments,description:V.item.description}:null;return n.jsxs(n.Fragment,{children:[n.jsx(Ys,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:u,queryFn:f,onSelect:x,onOpenChange:h=>{if(h)m.current=Date.now(),p.current=!1,$("chat_picker_opened",{picker:"/"});else{const v=m.current;$("chat_picker_closed",{picker:"/",outcome:p.current?"selected":"dismissed",duration_ms:v?Date.now()-v:null}),m.current=null}}}),n.jsx(An,{prompt:b,setPrompt:()=>c(null),onSubmit:g})]})};async function El(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>Nt(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>Nt(s),staleTime:6e4}),i?.prompts??[]}async function Dl(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>Vt(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>Vt(s),staleTime:6e4}),i?.resources??[]}function Ml(t){return[wr.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),wa.configure({placeholder:()=>t.current??"Ask anything, / for prompts, @ for agents & resources...",showOnlyWhenEditable:!1}),Hi,Ji]}function Ll({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:i=!1,placeholder:r,onSubmit:o,children:a}){const d=w.useRef(o),l=w.useRef(e),u=w.useRef(i),V=w.useRef(r),c=yr({extensions:Ml(V),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:(m,p)=>p.key==="Enter"&&!p.shiftKey&&u.current?(p.preventDefault(),d.current?.(),!0):!1},onUpdate:({editor:m})=>{l.current(m?.getJSON())}});return w.useEffect(()=>{c?.setEditable(!s)},[c,s]),w.useEffect(()=>{d.current=o},[o]),w.useEffect(()=>{l.current=e},[e]),w.useEffect(()=>{u.current=i},[i]),w.useEffect(()=>{V.current=r},[r]),w.useEffect(()=>{if(c?.isDestroyed)return;const m=JSON.stringify(c?.getJSON()),p=JSON.stringify(t||{type:"doc",content:[]});m!==p&&c.commands.setContent(t||{type:"doc",content:[]})},[c,t]),n.jsx(vr.Provider,{value:{editor:c},children:a})}function Fl(t){const e=L.c(26),{disabled:s,virtualMcpId:i,showFileUploader:r,selectedModel:o,onUnsupportedFile:a,ref:d,className:l}=t,u=s===void 0?!1:s,V=r===void 0?!1:r,{editor:c}=Kt();let m,p;if(e[0]!==c?(m=()=>({focus:()=>{c?.commands.focus()},clear:()=>{c?.commands.clearContent(!0)},appendText:y=>{if(!c)return;const j=c.state.doc.textContent.trim()==="";c.commands.focus("end"),j||c.commands.insertContent(" "),c.commands.insertContent(y)},syncVoiceText:(y,j)=>{if(c&&(c.commands.setContent(y||{type:"doc",content:[]}),j)){c.commands.focus("end");const P=c.state.doc.textContent.trim().length>0;c.commands.insertContent(P?" "+j:j)}},restoreContent:y=>{c&&c.commands.setContent(y||{type:"doc",content:[]})}}),p=[c],e[0]=c,e[1]=m,e[2]=p):(m=e[1],p=e[2]),w.useImperativeHandle(d??null,m,p),!c)return null;const x=u&&"cursor-not-allowed opacity-70",g=u&&"[&_.ProseMirror]:cursor-not-allowed";let f;e[3]!==l||e[4]!==x||e[5]!==g?(f=z("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",l,"[&_.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",x,g),e[3]=l,e[4]=x,e[5]=g,e[6]=f):f=e[6];let b;e[7]!==c||e[8]!==f?(b=n.jsx(jr,{editor:c,className:f}),e[7]=c,e[8]=f,e[9]=b):b=e[9];const h=i??null;let v;e[10]!==c||e[11]!==h?(v=n.jsx(w.Suspense,{fallback:null,children:n.jsx(Pl,{editor:c,virtualMcpId:h})}),e[10]=c,e[11]=h,e[12]=v):v=e[12];const S=i??null;let C;e[13]!==c||e[14]!==S?(C=n.jsx(w.Suspense,{fallback:null,children:n.jsx(Il,{editor:c,virtualMcpId:S})}),e[13]=c,e[14]=S,e[15]=C):C=e[15];let N;e[16]!==c||e[17]!==a||e[18]!==o||e[19]!==V?(N=V&&o?n.jsx(pa,{editor:c,selectedModel:o,onUnsupportedFile:a}):null,e[16]=c,e[17]=a,e[18]=o,e[19]=V,e[20]=N):N=e[20];let A;return e[21]!==v||e[22]!==C||e[23]!==N||e[24]!==b?(A=n.jsxs(n.Fragment,{children:[b,v,C,N]}),e[21]=v,e[22]=C,e[23]=N,e[24]=b,e[25]=A):A=e[25],A}function un(t){const e=L.c(3),[s]=pn();let i;return e[0]!==s.enableSounds||e[1]!==t?(i=()=>{s.enableSounds&&Sr(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 Ul={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"},Ol=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function $l(){const t=L.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:Ol.map(Bl)}),t[0]=e):e=t[0],e}function Bl(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 zl(t){const e=L.c(116),{disabled:s,onOpenConnections:i,virtualMcpId:r}=t,[o,a]=w.useState(!1),d=un(Ul),{org:l}=ce(),{editor:u}=Kt();let V;e[0]!==l.id||e[1]!==l.slug||e[2]!==r?(V={connectionId:r,orgId:l.id,orgSlug:l.slug},e[0]=l.id,e[1]=l.slug,e[2]=r,e[3]=V):V=e[3];const c=ze(V);let m;e[4]!==l.id||e[5]!==r?(m=Ae.virtualMcpPrompts(r,l.id),e[4]=l.id,e[5]=r,e[6]=m):m=e[6];const p=m;let x;e[7]!==c?(x=()=>Nt(c),e[7]=c,e[8]=x):x=e[8];const g=o&&!!c;let f;e[9]!==p||e[10]!==x||e[11]!==g?(f={queryKey:p,queryFn:x,staleTime:6e4,enabled:g},e[9]=p,e[10]=x,e[11]=g,e[12]=f):f=e[12];const{data:b,isLoading:h}=hn(f);let v;e[13]!==b?.prompts?(v=b?.prompts??[],e[13]=b?.prompts,e[14]=v):v=e[14];const S=v,[C,N]=w.useState(null),{chatMode:A,setChatMode:y}=Lt(),j=A==="plan";let P;e[15]!==A||e[16]!==j||e[17]!==d||e[18]!==y?(P=()=>{d();const G=j?"default":"plan";$("chat_mode_changed",{from_mode:A,to_mode:G,source:"tools_popover"}),y(G),a(!1)},e[15]=A,e[16]=j,e[17]=d,e[18]=y,e[19]=P):P=e[19];const D=P;let R;e[20]!==i?(R=()=>{i(),a(!1)},e[20]=i,e[21]=R):R=e[21];const T=R;let _;e[22]!==c||e[23]!==u?(_=async(G,yt)=>{if(!u||!c)return;const Gs=We(G._meta),Qs={from:u.state.selection.from,to:u.state.selection.to};try{const Hs=await jn(c,G.name,yt);mt(u,Qs,{id:G.name,name:wn(G.name,Gs),metadata:Hs.messages,char:"/"})}catch{se.error("Failed to load prompt. Please try again.")}},e[22]=c,e[23]=u,e[24]=_):_=e[24];const k=_;let E;e[25]!==k?(E=async G=>{a(!1);const yt=!!(G.arguments&&G.arguments.length>0);if($("chat_prompt_inserted",{prompt_name:G.name,with_arguments:yt}),yt){N(G);return}await k(G)},e[25]=k,e[26]=E):E=e[26];const M=E;let I;e[27]!==C||e[28]!==k?(I=async G=>{C&&(await k(C,G),N(null))},e[27]=C,e[28]=k,e[29]=I):I=e[29];const F=I;let O;e[30]!==A||e[31]!==d||e[32]!==y?(O=()=>{d();const G=A==="gen-image"?"default":"gen-image";$("chat_mode_changed",{from_mode:A,to_mode:G,source:"tools_popover"}),y(G),a(!1)},e[30]=A,e[31]=d,e[32]=y,e[33]=O):O=e[33];const B=O;let Y;e[34]!==A||e[35]!==d||e[36]!==y?(Y=()=>{d();const G=A==="web-search"?"default":"web-search";$("chat_mode_changed",{from_mode:A,to_mode:G,source:"tools_popover"}),y(G),a(!1)},e[34]=A,e[35]=d,e[36]=y,e[37]=Y):Y=e[37];const X=Y,Z=A==="gen-image",H=A==="web-search";let q;e[38]!==A||e[39]!==o?(q=G=>{G&&!o&&$("chat_tools_popover_opened",{chat_mode:A}),a(G)},e[38]=A,e[39]=o,e[40]=q):q=e[40];let ee,J;e[41]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx(ki,{size:14}),J=n.jsx("span",{className:"hidden sm:inline",children:"Tools"}),e[41]=ee,e[42]=J):(ee=e[41],J=e[42]);let te;e[43]!==s?(te=n.jsx(ys,{asChild:!0,children:n.jsxs(Q,{type:"button",variant:"ghost",size:"default",disabled:s,className:"text-muted-foreground hover:text-foreground",children:[ee,J]})}),e[43]=s,e[44]=te):te=e[44];const ie=j&&"text-violet-600 dark:text-violet-400";let oe;e[45]!==ie?(oe=z(ie),e[45]=ie,e[46]=oe):oe=e[46];const de=j&&"text-violet-500";let ne;e[47]!==de?(ne=z(de),e[47]=de,e[48]=ne):ne=e[48];let re;e[49]!==ne?(re=n.jsx(ls,{size:16,className:ne}),e[49]=ne,e[50]=re):re=e[50];let je;e[51]===Symbol.for("react.memo_cache_sentinel")?(je=n.jsx("span",{className:"flex-1",children:"Plan mode"}),e[51]=je):je=e[51];let K;e[52]!==j?(K=j&&n.jsx("span",{className:"text-xs text-violet-500 font-medium",children:"On"}),e[52]=j,e[53]=K):K=e[53];let ue;e[54]!==D||e[55]!==oe||e[56]!==re||e[57]!==K?(ue=n.jsxs(Ze,{onClick:D,className:oe,children:[re,je,K]}),e[54]=D,e[55]=oe,e[56]=re,e[57]=K,e[58]=ue):ue=e[58];const Re=Z&&"text-pink-600 dark:text-pink-400";let qe;e[59]!==Re?(qe=z(Re),e[59]=Re,e[60]=qe):qe=e[60];const Ke=Z&&"text-pink-500";let Te;e[61]!==Ke?(Te=z(Ke),e[61]=Ke,e[62]=Te):Te=e[62];let ge;e[63]!==Te?(ge=n.jsx(cs,{size:16,className:Te}),e[63]=Te,e[64]=ge):ge=e[64];let Se;e[65]===Symbol.for("react.memo_cache_sentinel")?(Se=n.jsx("span",{className:"flex-1",children:"Create image"}),e[65]=Se):Se=e[65];let Pe;e[66]!==Z?(Pe=Z&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"}),e[66]=Z,e[67]=Pe):Pe=e[67];let Ee;e[68]!==B||e[69]!==qe||e[70]!==ge||e[71]!==Pe?(Ee=n.jsxs(Ze,{onClick:B,className:qe,children:[ge,Se,Pe]}),e[68]=B,e[69]=qe,e[70]=ge,e[71]=Pe,e[72]=Ee):Ee=e[72];const Ge=H&&"text-blue-600 dark:text-blue-400";let De;e[73]!==Ge?(De=z(Ge),e[73]=Ge,e[74]=De):De=e[74];const Me=H&&"text-blue-500";let xe;e[75]!==Me?(xe=z(Me),e[75]=Me,e[76]=xe):xe=e[76];let be;e[77]!==xe?(be=n.jsx(ut,{size:16,className:xe}),e[77]=xe,e[78]=be):be=e[78];let ke;e[79]===Symbol.for("react.memo_cache_sentinel")?(ke=n.jsx("span",{className:"flex-1",children:"Web search"}),e[79]=ke):ke=e[79];let ye;e[80]!==H?(ye=H&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"}),e[80]=H,e[81]=ye):ye=e[81];let _e;e[82]!==X||e[83]!==De||e[84]!==be||e[85]!==ye?(_e=n.jsxs(Ze,{onClick:X,className:De,children:[be,ke,ye]}),e[82]=X,e[83]=De,e[84]=be,e[85]=ye,e[86]=_e):_e=e[86];let U;e[87]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsxs(pr,{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[87]=U):U=e[87];let W;e[88]!==M||e[89]!==h||e[90]!==S?(W=h?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(at,{size:14,className:"animate-spin"}),"Loading prompts…"]}):S.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):S.map(G=>n.jsxs(Ze,{onClick:()=>M(G),className:"flex flex-col items-start gap-0.5",children:[n.jsx("span",{className:"font-medium text-sm capitalize",children:G.title||zt(G.name,We(G._meta))}),G.description&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:G.description})]},G.name)),e[88]=M,e[89]=h,e[90]=S,e[91]=W):W=e[91];let le;e[92]!==W?(le=n.jsxs(hr,{children:[U,n.jsx(gr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:W})]}),e[92]=W,e[93]=le):le=e[93];let Ne,ve;e[94]===Symbol.for("react.memo_cache_sentinel")?(Ne=n.jsx(lr,{size:16}),ve=n.jsx("span",{className:"flex-1",children:"Connections"}),e[94]=Ne,e[95]=ve):(Ne=e[94],ve=e[95]);let Be;e[96]===Symbol.for("react.memo_cache_sentinel")?(Be=n.jsx(w.Suspense,{children:n.jsx($l,{})}),e[96]=Be):Be=e[96];let we;e[97]!==T?(we=n.jsxs(Ze,{onClick:T,children:[Ne,ve,Be]}),e[97]=T,e[98]=we):we=e[98];let ae;e[99]!==ue||e[100]!==Ee||e[101]!==_e||e[102]!==le||e[103]!==we?(ae=n.jsxs(vs,{align:"start",className:"w-52 p-1.5",children:[ue,Ee,_e,le,we]}),e[99]=ue,e[100]=Ee,e[101]=_e,e[102]=le,e[103]=we,e[104]=ae):ae=e[104];let Ve;e[105]!==o||e[106]!==q||e[107]!==te||e[108]!==ae?(Ve=n.jsxs(ws,{open:o,onOpenChange:q,children:[te,ae]}),e[105]=o,e[106]=q,e[107]=te,e[108]=ae,e[109]=Ve):Ve=e[109];let Je;e[110]!==C||e[111]!==F?(Je=n.jsx(An,{prompt:C,setPrompt:N,onSubmit:F}),e[110]=C,e[111]=F,e[112]=Je):Je=e[112];let bt;return e[113]!==Ve||e[114]!==Je?(bt=n.jsxs(n.Fragment,{children:[Ve,Je]}),e[113]=Ve,e[114]=Je,e[115]=bt):bt=e[115],bt}const ql=[{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 Kl(){const t=L.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:ql.map(Yl)}),t[0]=e):e=t[0],e}function Yl(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 Wl(t){const e=L.c(6),{onClick:s}=t;let i,r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=z("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(Kl,{}),a=n.jsx(Or,{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 d;return e[4]!==s?(d=n.jsxs("button",{type:"button",onClick:s,className:i,children:[r,o,a]}),e[4]=s,e[5]=d):d=e[5],d}const ot=48;function Gl(){const t=L.c(9),[e,s]=w.useState("idle"),[i,r]=w.useState(""),[o,a]=w.useState(""),[d,l]=w.useState(Jl),u=w.useRef(null),V=w.useRef(null),c=w.useRef(null),m=w.useRef(null),p=w.useRef(0),x=w.useRef(!1),g=w.useRef(""),f=w.useRef(""),b=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0),V.current?.close().catch(Hl),m.current?.getTracks().forEach(Ql),c.current=null,V.current=null,m.current=null},t[0]=h):h=t[0];const v=h;let S;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const D=R=>{m.current=R;const T=new AudioContext;V.current=T;const _=T.createMediaStreamSource(R),k=T.createAnalyser();k.fftSize=128,k.smoothingTimeConstant=.8,_.connect(k),c.current=k;const E=new Uint8Array(k.frequencyBinCount),M=()=>{if(!c.current)return;c.current.getByteFrequencyData(E);const I=[];for(let F=0;F<ot;F++){const O=Math.floor(F/ot*E.length);I.push(Math.max(.04,(E[O]??0)/255))}l(I),p.current=requestAnimationFrame(M)};M()};S=async()=>{const R=window.SpeechRecognition||window.webkitSpeechRecognition;if(!R){s("unsupported");return}let T;try{T=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}r(""),a(""),f.current="",g.current="",x.current=!0,s("recording"),D(T);const _=new R;u.current=_,_.interimResults=!0,_.continuous=!0,_.lang=navigator.language||"en-US",_.onresult=k=>{let E="",M="";for(let I=k.resultIndex;I<k.results.length;I++){const F=k.results[I],O=F?.[0]?.transcript??"";F?.isFinal?M=M+O:E=E+O}M&&(g.current=g.current+M,r(g.current)),f.current=E,a(E)},_.onend=()=>{if(x.current)try{_.start()}catch{}};try{_.start()}catch{s("idle")}},t[1]=S}else S=t[1];const C=S;let N;t[2]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{x.current=!1,u.current?.stop(),v(),s("idle"),l(Array(ot).fill(.05)),a("");const D=(g.current+(f.current?" "+f.current:"")).trim();return r(""),g.current="",f.current="",D},t[2]=N):N=t[2];const A=N;let y;t[3]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{x.current=!1,u.current?.abort(),v(),s("idle"),r(""),a(""),l(Array(ot).fill(.05)),g.current="",f.current=""},t[3]=y):y=t[3];const j=y;let P;return t[4]!==o||t[5]!==e||t[6]!==i||t[7]!==d?(P={status:e,transcript:i,interimTranscript:o,waveformData:d,isSupported:b,startRecording:C,stopRecording:A,cancelRecording:j},t[4]=o,t[5]=e,t[6]=i,t[7]=d,t[8]=P):P=t[8],P}function Ql(t){return t.stop()}function Hl(){}function Jl(){return Array(ot).fill(.05)}function Xl(t){const e=L.c(4),{data:s}=t;let i;e[0]!==s?(i=s.map(Zl),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 Zl(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)}function ec(t,e){const s=L.c(5),{editor:i}=Kt(),[r,o]=w.useState(!1),a=w.useRef(0);let d,l;return s[0]!==i||s[1]!==e||s[2]!==t?(d=()=>{const u=p=>{p.dataTransfer?.types.includes("Files")&&(p.preventDefault(),a.current=a.current+1,o(!0))},V=p=>{p.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},c=tc,m=p=>{if(p.preventDefault(),a.current=0,o(!1),!i||!t||!qt(t))return;const x=p.dataTransfer?.files;if(!x||x.length===0)return;const{from:g}=i.state.selection;for(const f of Array.from(x))Sn(i,t,f,g,e)};return window.addEventListener("dragenter",u),window.addEventListener("dragleave",V),window.addEventListener("dragover",c),window.addEventListener("drop",m),()=>{window.removeEventListener("dragenter",u),window.removeEventListener("dragleave",V),window.removeEventListener("dragover",c),window.removeEventListener("drop",m)}},l=[i,t,e],s[0]=i,s[1]=e,s[2]=t,s[3]=d,s[4]=l):(d=s[3],l=s[4]),w.useEffect(d,l),r}function tc(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function nc(t){const e=L.c(11),{selectedModel:s,onUnsupportedFile:i}=t,r=ec(s,i);let o;e[0]!==s?(o=qt(s),e[0]=s,e[1]=o):o=e[1];const a=o,d=r?"opacity-100":"opacity-0 pointer-events-none",l=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let u;e[2]!==d||e[3]!==l?(u=z("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",d,l),e[2]=d,e[3]=l,e[4]=u):u=e[4];let V;e[5]!==s||e[6]!==a?(V=a?n.jsxs(n.Fragment,{children:[n.jsx(cr,{size:24}),n.jsxs("span",{className:"text-sm font-medium",children:["Drop ",bs(s)," here"]})]}):n.jsxs(n.Fragment,{children:[n.jsx(ds,{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]=V):V=e[7];let c;return e[8]!==u||e[9]!==V?(c=n.jsx("div",{className:u,children:V}),e[8]=u,e[9]=V,e[10]=c):c=e[10],c}function sc(){const t=L.c(5),e=tt(),{org:s,locator:i}=ce();let r;return t[0]!==i||t[1]!==e||t[2]!==s.id||t[3]!==s.slug?(r=o=>{const{tiptapDoc:a,virtualMcp:d}=o,l=crypto.randomUUID(),u=d?.id??xn(s.id).id;Pi(sessionStorage,i,l,{tiptapDoc:a}),e({to:"/$org/$taskId",params:{org:s.slug,taskId:l},search:{virtualmcpid:u,autosend:Ei}})},t[0]=i,t[1]=e,t[2]=s.id,t[3]=s.slug,t[4]=r):r=t[4],r}function ic({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=Ri(),i=Ti(),r=s?.messages??[],o=s?.isStreaming??!1,a=s?.isRunInProgress??!1,d=s?.stop??(()=>{}),l=i?.taskId??"",u=i?.tasks??[],V=sc(),{selectedModel:c,selectedVirtualMcp:m,isModelsLoading:p,tiptapDocRef:x,imageModel:g,deepResearchModel:f,chatMode:b,setChatMode:h,simpleModeTier:v,setSimpleModeTier:S}=Lt(),{data:C}=Et.useSession(),N=C?.user?.id,{org:A}=ce(),y=xn(A.id).id,j=un(In),[P,D]=w.useState(!1),{unsupportedFile:R,onUnsupportedFile:T,clearUnsupportedFile:_}=va(),k=Gl(),E=w.useRef(void 0),M=async()=>{E.current=B,await k.startRecording();const K=k.status==="recording"?"started":k.status==="unsupported"?"unsupported":k.status==="permission-denied"?"permission_denied":"unknown";$("chat_voice_started",{thread_id:l,outcome:K})},I=()=>{$("chat_voice_confirmed",{thread_id:l});const K=k.stopRecording();ee.current?.syncVoiceText(E.current,K),ee.current?.focus()},F=()=>{$("chat_voice_cancelled",{thread_id:l}),k.cancelRecording(),ee.current?.restoreContent(E.current)};w.useEffect(()=>{if(k.status!=="recording")return;const K=(k.transcript+(k.interimTranscript?" "+k.interimTranscript:"")).trim();ee.current?.syncVoiceText(E.current,K)},[k.transcript,k.interimTranscript,k.status]);const O=u.find(K=>K.id===l),[B,Y]=w.useState(void 0),X=K=>{Y(K),x.current=K},Z=w.useRef(l);Z.current!==l&&(Z.current=l,Y(void 0),x.current=void 0);const q=[...r].reverse().find(K=>K.role==="assistant")?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow,ee=w.useRef(null),J=b==="plan";w.useEffect(()=>{const K=ue=>{qi(ue)&&ue.code==="KeyL"&&(ue.preventDefault(),ue.shiftKey&&h(b==="plan"?"default":"plan"),ee.current?.focus())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[b,h]);const te=Xi(r),ie=[...r].reverse().find(K=>K.role==="assistant"&&K.metadata?.usage)?.metadata?.usage,oe=ie?.contextTokens??(ie?.totalTokens??0)-(ie?.reasoningTokens??0),de=un(In),ne=!o&&!p&&!Ao(B),re=o||a,je=K=>{K?.preventDefault(),o?($("chat_message_stopped",{thread_id:l}),d()):a?($("chat_message_stopped",{thread_id:l}),d()):ne&&B&&($("chat_message_sent",{thread_id:l||null,mode:b,model_id:c?.modelId??null,model_provider:c?.providerId??null,virtual_mcp_id:m?.id??null,submission:K?"button_or_enter":"programmatic"}),de(),s?s.sendMessage(B):V({tiptapDoc:B,virtualMcp:m}),X(void 0))};return N&&O?.created_by&&O.created_by!==N?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(ds,{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"}),s&&i&&n.jsx(Yt,{}),n.jsx(Ll,{tiptapDoc:B,setTiptapDoc:X,disabled:o,enterToSubmit:!0,onSubmit:je,children:n.jsxs("form",{onSubmit:je,className:z("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(nc,{selectedModel:c,onUnsupportedFile:T}),n.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:n.jsx(Fl,{ref:ee,disabled:o||k.status==="recording",virtualMcpId:m?.id??y,showFileUploader:!0,selectedModel:c,onUnsupportedFile:T})}),n.jsx("div",{className:"flex items-center justify-between p-2.5 gap-1",children:k.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(Xl,{data:k.waveformData.slice(0,28)}),n.jsx("button",{type:"button",onClick:F,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(it,{size:16})}),n.jsx("button",{type:"button",onClick:I,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(pt,{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(xa,{selectedModel:c,isStreaming:o,icon:n.jsx(us,{size:16}),onUnsupportedFile:T}),n.jsx(zl,{disabled:o,onOpenConnections:()=>{$("connections_dialog_opened",{source:"tools_popover",mode:"add"}),D(!0)},virtualMcpId:m?.id??y}),J&&n.jsxs("button",{type:"button",onClick:()=>{j(),$("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),h("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(ls,{size:14,className:"shrink-0"}),"Plan mode",n.jsx(it,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),b==="gen-image"&&g&&n.jsxs("button",{type:"button",disabled:o,onClick:()=>{j(),$("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),h("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 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[n.jsx(cs,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:"Create image"}),n.jsx(it,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),b==="web-search"&&f&&n.jsxs("button",{type:"button",disabled:o,onClick:()=>{j(),$("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),h("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 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[n.jsx(ut,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:"Web search"}),n.jsx(it,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),q&&oe>0&&n.jsx(Zi,{usage:te,totalTokens:oe,contextWindow:q,onOpenContextPanel:t})]}),n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.jsx(fa,{tier:v,onSelect:S}),k.isSupported&&!o&&!a&&n.jsx(Q,{type:"button",onClick:M,variant:"ghost",size:"icon",className:z("size-8 rounded-lg transition-colors",k.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:k.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:n.jsx(_i,{size:18})}),n.jsx(Q,{type:re?"button":"submit",onClick:K=>{re&&(K.preventDefault(),K.stopPropagation(),d())},variant:ne||re?"default":"ghost",size:"icon",disabled:!ne&&!re,className:z("size-8 rounded-lg transition-all",!ne&&!re&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:o?"Stop generating":a?"Cancel run":"Send message (Enter)",children:re?n.jsx(Ni,{size:20}):n.jsx(rr,{size:20})})]})]})})]})},l),e&&n.jsx(Wl,{onClick:()=>{$("connections_banner_clicked",{source:"home_chat_input"}),$("connections_dialog_opened",{source:"home_banner",mode:"add"}),D(!0)}})]})}),n.jsx(Hr,{mode:"browse",open:P,onOpenChange:D,defaultTab:"all"}),n.jsx(ba,{info:R,onClose:_})]})}const rc={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 Ws(t){return`deco-credits-empty-dismissed:${t}`}function jd(t){try{return localStorage.getItem(Ws(t))==="1"}catch{return!1}}function oc(){const t=L.c(50),{org:e}=ce(),s=tt(),{decoKeyId:i}=Rs();let r;t[0]!==e.id||t[1]!==e.slug?(r={connectionId:xt,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=r):r=t[2];const o=ze(r),[a,d]=w.useState(!0),[l,u]=w.useState(""),[V,c]=w.useState(!1),[m,p]=w.useState("usd"),x=m==="brl"?"R$":"$";let g;t[3]!==e.id?(g=()=>{$("credits_empty_state_dismissed",{organization_id:e.id}),d(!1);try{localStorage.setItem(Ws(e.id),"1")}catch{}},t[3]=e.id,t[4]=g):g=t[4];const f=g;let b,h;t[5]!==a||t[6]!==e.id?(b=()=>{a&&$("credits_empty_state_shown",{organization_id:e.id})},h=[a,e.id],t[5]=a,t[6]=e.id,t[7]=b,t[8]=h):(b=t[7],h=t[8]),w.useEffect(b,h);let v;t[9]!==o||t[10]!==m?(v=async Y=>{const X=await o.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:Y,currency:m}});if(X?.isError)throw new Error(X.content?.[0]?.text??"Failed to get top-up URL");return X.structuredContent?.url},t[9]=o,t[10]=m,t[11]=v):v=t[11];let S;t[12]!==f?(S=Y=>{Y&&window.open(Y,"_blank","noopener,noreferrer"),f()},t[12]=f,t[13]=S):S=t[13];let C;t[14]!==v||t[15]!==S?(C={mutationFn:v,onSuccess:S,onError:lc},t[14]=v,t[15]=S,t[16]=C):C=t[16];const{mutate:N,isPending:A}=fn(C),y=parseFloat(l),j=!isNaN(y)&&y>=1;if(!a)return null;let P;t[17]!==f?(P=Y=>!Y&&f(),t[17]=f,t[18]=P):P=t[18];let D;t[19]===Symbol.for("react.memo_cache_sentinel")?(D=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[19]=D):D=t[19];let R;t[20]===Symbol.for("react.memo_cache_sentinel")?(R=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(is,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[20]=R):R=t[20];let T;t[21]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[D,n.jsxs(Oe,{className:"relative gap-3",children:[R,n.jsxs("div",{className:"text-center",children:[n.jsx($e,{className:"text-lg font-semibold",children:"This workspace has no credits"}),n.jsx(Mt,{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[21]=T):T=t[21];let _;t[22]!==m||t[23]!==x||t[24]!==l||t[25]!==y||t[26]!==i||t[27]!==j||t[28]!==A||t[29]!==V||t[30]!==N?(_=i&&n.jsxs("div",{className:"px-6 pb-5",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(xs,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:Y=>{Y&&p(Y)},children:[n.jsx(Ct,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(Ct,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:rc[m].map(Y=>{const{dollars:X,label:Z}=Y;return n.jsxs("button",{type:"button",disabled:A,onClick:()=>{$("credits_topup_clicked",{amount_cents:X*100,currency:m,tier_label:Z,source:"empty_state"}),N(X*100)},className:z("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:[x,X]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:Z})]},X)})}),V?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:x}),n.jsx(Ie,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:Y=>u(Y.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(Q,{className:"h-10",disabled:!j||A,onClick:()=>{$("credits_topup_clicked",{amount_cents:Math.round(y*100),currency:m,tier_label:"custom",source:"empty_state"}),N(Math.round(y*100))},children:A?"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:()=>c(!0),children:"Enter custom amount"})]}),t[22]=m,t[23]=x,t[24]=l,t[25]=y,t[26]=i,t[27]=j,t[28]=A,t[29]=V,t[30]=N,t[31]=_):_=t[31];let k;t[32]!==f||t[33]!==s||t[34]!==e.slug?(k=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),f()},t[32]=f,t[33]=s,t[34]=e.slug,t[35]=k):k=t[35];let E;t[36]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Vs,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[36]=E):E=t[36];let M;t[37]!==k?(M=n.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:k,children:["Use your own provider",E]}),t[37]=k,t[38]=M):M=t[38];let I;t[39]!==f?(I=n.jsx(Q,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:f,children:"Skip for now"}),t[39]=f,t[40]=I):I=t[40];let F;t[41]!==M||t[42]!==I?(F=n.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[M,I]}),t[41]=M,t[42]=I,t[43]=F):F=t[43];let O;t[44]!==_||t[45]!==F?(O=n.jsxs(Ue,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:ac,children:[T,_,F]}),t[44]=_,t[45]=F,t[46]=O):O=t[46];let B;return t[47]!==O||t[48]!==P?(B=n.jsx(Fe,{open:!0,onOpenChange:P,children:O}),t[47]=O,t[48]=P,t[49]=B):B=t[49],B}function ac(t){return t.preventDefault()}function lc(t){se.error(`Top-up failed: ${t.message}`)}function cc(t){const e=L.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=z("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(is,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let d;return e[4]!==r?(d=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]=d):d=e[5],d}function dc(){const t=L.c(8),{org:e}=ce(),s=tt();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=z("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(ms,{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 d;return t[6]!==i?(d=n.jsxs("button",{type:"button",onClick:i,className:r,children:[o,a]}),t[6]=i,t[7]=d):d=t[7],d}function uc(t){const e=L.c(11),{className:s}=t;let i;e[0]!==s?(i=z("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 d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=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(jt,{align:"right",width:"w-3/4"}),n.jsx(jt,{align:"left",width:"w-full",lines:3}),n.jsx(jt,{align:"right",width:"w-2/3"}),n.jsx(jt,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=d):d=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=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]=l):l=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=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]=u):u=e[7];let V;e[8]===Symbol.for("react.memo_cache_sentinel")?(V=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:[l,n.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[u,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]=V):V=e[8];let c;return e[9]!==i?(c=n.jsxs("div",{className:i,children:[a,d,V]}),e[9]=i,e[10]=c):c=e[10],c}function jt(t){const e=L.c(22),{align:s,width:i,lines:r}=t,o=i===void 0?"w-full":i,a=r===void 0?1:r,d=s==="right"?"flex-row-reverse":"flex-row";let l;e[0]!==d?(l=z("flex w-full gap-4 px-4 py-2",d),e[0]=d,e[1]=l):l=e[1];const u=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let V;e[2]!==u?(V=z("flex min-w-0 flex-col gap-2",u),e[2]=u,e[3]=V):V=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=c):c=e[4];const m=s==="right"?"bg-muted":"bg-transparent border border-border/40";let p;e[5]!==m||e[6]!==o?(p=z("min-w-0 rounded-2xl p-4",m,o),e[5]=m,e[6]=o,e[7]=p):p=e[7];let x;e[8]!==a?(x=Array.from({length:a}),e[8]=a,e[9]=x):x=e[9];let g;e[10]!==a||e[11]!==x?(g=n.jsx("div",{className:"space-y-2",children:x.map((v,S)=>n.jsx("div",{className:z("h-3 rounded bg-muted-foreground/20 animate-pulse",S===a-1?"w-3/4":"w-full"),style:{animationDelay:`${S*.1}s`}},S))}),e[10]=a,e[11]=x,e[12]=g):g=e[12];let f;e[13]!==g||e[14]!==p?(f=n.jsx("div",{className:p,children:g}),e[13]=g,e[14]=p,e[15]=f):f=e[15];let b;e[16]!==f||e[17]!==V?(b=n.jsxs("div",{className:V,children:[c,f]}),e[16]=f,e[17]=V,e[18]=b):b=e[18];let h;return e[19]!==b||e[20]!==l?(h=n.jsx("div",{className:l,children:b}),e[19]=b,e[20]=l,e[21]=h):h=e[21],h}function Vc(t){const e=L.c(5),{className:s,children:i}=t;let r;e[0]!==s?(r=z("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 mc(t){const e=L.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=z("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 fc(t){const e=L.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 pc(){const t=L.c(16),{messages:e,status:s}=vn(),i=er(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 d;if(t[2]!==a||t[3]!==o||t[4]!==i||t[5]!==e||t[6]!==s){const l=e.at(-1),u=!a&&l?.role==="assistant"&&l.parts.filter(xc).some(gc),V=!a&&l?.role==="assistant"&&l.parts.some(hc);let c;if(t[8]!==i||t[9]!==s){let p;t[11]!==i.length||t[12]!==s?(p=(x,g)=>n.jsx(Cn,{pair:x,isLastPair:!1,status:g===i.length-1?s:void 0},`pair-${x.user.id}`),t[11]=i.length,t[12]=s,t[13]=p):p=t[13],c=i.slice(0,-1).map(p),t[8]=i,t[9]=s,t[10]=c}else c=t[10];let m;t[14]!==c?(m=n.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:c}),t[14]=c,t[15]=m):m=t[15],d=n.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[m,o&&n.jsx("div",{className:z("min-h-full min-w-0 max-w-2xl mx-auto w-full",(u||V)&&"pb-60"),children:n.jsx(Cn,{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]=d}else d=t[7];return d}function hc(t){return"state"in t&&t.state==="approval-requested"}function gc(t){return t.state==="input-available"}function xc(t){return t.type==="tool-user_ask"}function bc(t){const e=L.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=z("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 Ad=Object.assign(Vc,{Main:mc,Messages:pc,EmptyState:fc,Footer:bc,Input:ic,Provider:Mi,ActiveTaskProvider:Di,Skeleton:uc,IceBreakers:Po,NoAiProviderEmptyState:fr,CreditsEmptyState:oc,CreditsEyebrow:cc,NoCreditsEyebrow:dc,CreditsExhaustedBanner:Ts});export{Hr as A,Ad as C,fa as S,Ll as T,Fl as a,wd as b,bd as c,yd as d,vd as e,Rs as u,jd as w};
|