decocms 2.286.0 → 2.286.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-DTmaHldD.js → AlertCircle-Bgzr6uRA.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-DlPeFc4v.js → ArrowNarrowLeft-ByrdB8Dd.js} +1 -1
- package/dist/client/assets/{CheckCircle-DJ3lme5R.js → CheckCircle-88bls7UK.js} +1 -1
- package/dist/client/assets/{ChevronDown-DGnjAtqs.js → ChevronDown-Jd-cYHC-.js} +1 -1
- package/dist/client/assets/{ChevronRight-DV9No7GF.js → ChevronRight-71i8ke8L.js} +1 -1
- package/dist/client/assets/{ChevronUp-BkSgkwhO.js → ChevronUp-D_szSdLd.js} +1 -1
- package/dist/client/assets/{Container-B1nHZdmn.js → Container-DWaKXfYv.js} +1 -1
- package/dist/client/assets/{DotsVertical-Bp2tW8JI.js → DotsVertical-CjXyjLNU.js} +1 -1
- package/dist/client/assets/{LinkExternal01-BBbCPDtX.js → LinkExternal01-DB08YntP.js} +1 -1
- package/dist/client/assets/{Lock01-DpPIS3K7.js → Lock01-dBhVogWg.js} +1 -1
- package/dist/client/assets/{Palette-CI8n49a8.js → Palette-DuWQiO51.js} +1 -1
- package/dist/client/assets/{Play-DKFUTU3G.js → Play-D7pqvkYq.js} +1 -1
- package/dist/client/assets/{Plus-oXFwCrYz.js → Plus-BzxOIhxj.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-B10mKiE2.js → RefreshCcw01-BxULs6ec.js} +1 -1
- package/dist/client/assets/{SearchMd-BRJBvWf4.js → SearchMd-D6tCV38D.js} +1 -1
- package/dist/client/assets/{Settings02-Dm9dFDqk.js → Settings02-MyfUtBA4.js} +1 -1
- package/dist/client/assets/{Shield01-BZJVBd5S.js → Shield01-CMw4M4Ml.js} +1 -1
- package/dist/client/assets/{Star01-_IJK5Yjt.js → Star01-DZHrISf9.js} +1 -1
- package/dist/client/assets/{Sun-QqE1VnS_.js → Sun-C8X8gjZW.js} +1 -1
- package/dist/client/assets/{Tool01-CKowkGsd.js → Tool01-BscqkhhO.js} +1 -1
- package/dist/client/assets/{Trash01-C6bAXG6g.js → Trash01-DZpzvWVW.js} +1 -1
- package/dist/client/assets/{User01-C2-anwoO.js → User01-VHn0SqBP.js} +1 -1
- package/dist/client/assets/{Users03-DqYvPeZM.js → Users03-DwNyb_q2.js} +1 -1
- package/dist/client/assets/{X-i9zBn6Hn.js → X-BuUY-erD.js} +1 -1
- package/dist/client/assets/{XCircle-C1sJYG9R.js → XCircle-BFZeumzD.js} +1 -1
- package/dist/client/assets/{XClose-BbIo6xHe.js → XClose-ANREDbeo.js} +1 -1
- package/dist/client/assets/{Zap-KmbRMccM.js → Zap-BxJkZzJb.js} +1 -1
- package/dist/client/assets/{ZapSquare-DT93lGV4.js → ZapSquare-Bz3HDhTc.js} +1 -1
- package/dist/client/assets/{accordion-BV3tm7bj.js → accordion-DK_chPAh.js} +1 -1
- package/dist/client/assets/{agent-icon-CyE6nkC1.js → agent-icon-DKQKq---.js} +1 -1
- package/dist/client/assets/{agents-list-7o6gZt-q.js → agents-list-DBdCJGrz.js} +1 -1
- package/dist/client/assets/ai-providers-BhNFwI7O.js +1 -0
- package/dist/client/assets/{alert-dialog-CicrCOay.js → alert-dialog-CtGXaT-Y.js} +1 -1
- package/dist/client/assets/{auth-catchall-Cyd7fWQv.js → auth-catchall-B4ADnlpm.js} +1 -1
- package/dist/client/assets/{automation-list-row-B4Vfg4UC.js → automation-list-row-B_yW9vLo.js} +1 -1
- package/dist/client/assets/{automations-DRM_lJom.js → automations-B3iEjSty.js} +1 -1
- package/dist/client/assets/{avatar-CF1bgUpD.js → avatar-DcLXZkYK.js} +1 -1
- package/dist/client/assets/{badge-s_TAXGUN.js → badge-BJBM0LXp.js} +1 -1
- package/dist/client/assets/brand-context-BahSISOs.js +1 -0
- package/dist/client/assets/{card-CaekC2K0.js → card-DqrPrhd5.js} +1 -1
- package/dist/client/assets/{chat-context-DP5UfIrn.js → chat-context-DfEaB6Uj.js} +1 -1
- package/dist/client/assets/{checkbox-DznLgPgR.js → checkbox-Dplb_VaM.js} +1 -1
- package/dist/client/assets/{collection-detail-CTQuhG7N.js → collection-detail-KgUZfuij.js} +1 -1
- package/dist/client/assets/{collection-display-button-BgYKhoGQ.js → collection-display-button-DecHBxzk.js} +1 -1
- package/dist/client/assets/{collection-search-Bo2bOvRn.js → collection-search-B_zW9IS4.js} +1 -1
- package/dist/client/assets/{collection-search-DMqppne6.js → collection-search-DF-hPm66.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-KnWZIddd.js → collection-table-wrapper-DG-B8ykv.js} +1 -1
- package/dist/client/assets/{collection-tabs-CU6MCzSn.js → collection-tabs-tHg8euhu.js} +1 -1
- package/dist/client/assets/{collections-DHmXATua.js → collections-KKlyNHih.js} +1 -1
- package/dist/client/assets/{command-D4w2xkZT.js → command-Cpu7RbMv.js} +1 -1
- package/dist/client/assets/{connection-card-DBz-rrLk.js → connection-card-CD0fnfut.js} +1 -1
- package/dist/client/assets/{connection-detail-zHqb5ZSw.js → connection-detail-CFY9ol5g.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-CBEV0IXi.js → connection-form-helpers-DVewXDLo.js} +1 -1
- package/dist/client/assets/{connections-CHiGbl1F.js → connections-B-Liq5Ll.js} +1 -1
- package/dist/client/assets/{constants-v4RUVkEN.js → constants-D7DNenhk.js} +1 -1
- package/dist/client/assets/{constants-DDHDU3PV.js → constants-aD7HJ6sY.js} +1 -1
- package/dist/client/assets/{dialog-C4lREl-t.js → dialog-nGTWjCEa.js} +1 -1
- package/dist/client/assets/{drawer-BTCEaGGQ.js → drawer-DyPUsgdj.js} +1 -1
- package/dist/client/assets/{dropdown-menu-v2GifVOh.js → dropdown-menu-Cc_jn9Z7.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-CVBBnlEt.js → dynamic-plugin-layout-Bun8S8Gm.js} +1 -1
- package/dist/client/assets/{empty-state-DdKZ_is7.js → empty-state-CqQa90x5.js} +1 -1
- package/dist/client/assets/{empty-state-BdQTFnZA.js → empty-state-DgThOXBB.js} +1 -1
- package/dist/client/assets/{extract-connection-data-CfXvFcGA.js → extract-connection-data-Bx0uarS8.js} +1 -1
- package/dist/client/assets/{features-fsR9zLkr.js → features-ekquKatz.js} +1 -1
- package/dist/client/assets/{form-D7DN8UcB.js → form-DB-TdsHz.js} +1 -1
- package/dist/client/assets/{general-WQbdllPl.js → general-BrK_oI6y.js} +1 -1
- package/dist/client/assets/{github-repo-picker-DZqLC6FL.js → github-repo-picker-CwCtQ7G3.js} +1 -1
- package/dist/client/assets/{index-DBclwIf_.js → index-Amg25tew.js} +1 -1
- package/dist/client/assets/{index-D-RCnwJQ.js → index-BZopUfMN.js} +1 -1
- package/dist/client/assets/{index-qXZ0t4XR.js → index-BfYZ2YG_.js} +4 -4
- package/dist/client/assets/{index-FnxI6OGR.js → index-CT9V-xpg.js} +1 -1
- package/dist/client/assets/{index-C5AR7k1c.js → index-CwstDhH7.js} +1 -1
- package/dist/client/assets/{index-D34n6J5J.js → index-DhJrYN5i.js} +2 -2
- package/dist/client/assets/{index-CHKi_s_a.js → index-DtMbbDUN.js} +1 -1
- package/dist/client/assets/{index-e3AFJ_dX.js → index-DtdOoKdU.js} +1 -1
- package/dist/client/assets/{index-zDq2Zqio.js → index-DvgxnJsz.js} +1 -1
- package/dist/client/assets/{index-DnJZfbsP.js → index-pD6VF9-w.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-1_M-sq16.js → infiniteQueryObserver-B_9sKQsI.js} +1 -1
- package/dist/client/assets/{input-urtyHxks.js → input-COFLoOjb.js} +1 -1
- package/dist/client/assets/{integration-icon-Cdkk9YPE.js → integration-icon-DKrcAAs9.js} +1 -1
- package/dist/client/assets/{label-Bt4h_QUk.js → label-BZVcstmy.js} +1 -1
- package/dist/client/assets/{layout-B5SDe6IW.js → layout-Dp5y9gtR.js} +1 -1
- package/dist/client/assets/{login-7zFMf3C1.js → login-ComGApTe.js} +1 -1
- package/dist/client/assets/{members-Dy7hWkQ8.js → members-CHnKVrrd.js} +1 -1
- package/dist/client/assets/{monaco-editor-lveN-AoO.js → monaco-editor-EL8K9shU.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-D3x0_phM.js → monitoring-stats-row-D9crys0K.js} +1 -1
- package/dist/client/assets/{oauth-callback-BJALVgfT.js → oauth-callback-B0mEhNIK.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-o8Hfz-wL.js → oauth-callback-ai-provider-Dj0EctfO.js} +1 -1
- package/dist/client/assets/{onboarding-DlI3PsIA.js → onboarding-czNV0UuI.js} +1 -1
- package/dist/client/assets/{org-layout-DPzm8vzJ.js → org-layout-CGtnLM_Q.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-DB72TzxO.js → org-plugin-layout-Ba2ZEzcE.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-BzyxU1IF.js → plugin-empty-state-fmAUJ6xt.js} +1 -1
- package/dist/client/assets/{plugin-header-hJH6-4Nr.js → plugin-header-3c9kItnR.js} +1 -1
- package/dist/client/assets/{plugin-layout-l_MDXBYc.js → plugin-layout-CUFHRJeM.js} +1 -1
- package/dist/client/assets/{popover-j_PzMtdY.js → popover-Bo1-wNsY.js} +1 -1
- package/dist/client/assets/{profile-lf_QL3Ye.js → profile-C4ZfFzUo.js} +1 -1
- package/dist/client/assets/{project-app-view-DuFzKNXE.js → project-app-view-DbITEuQv.js} +1 -1
- package/dist/client/assets/registry-CrUw5Sj_.js +2 -0
- package/dist/client/assets/{registry-layout-DRb_iR_v.js → registry-layout-q6bMBk9s.js} +1 -1
- package/dist/client/assets/{required-auth-layout-C2o7AZ4K.js → required-auth-layout-CP-yDaO3.js} +1 -1
- package/dist/client/assets/{reset-password-DTEY3I_i.js → reset-password-CpFcPkI4.js} +1 -1
- package/dist/client/assets/{roles-DW1_Kn6r.js → roles-CSJcHSQ8.js} +1 -1
- package/dist/client/assets/{scroll-area-BebfgLv6.js → scroll-area-CXUp8wR9.js} +1 -1
- package/dist/client/assets/{search-input-dmuYGYsk.js → search-input-ClG6niuo.js} +1 -1
- package/dist/client/assets/{select-CePxsPeP.js → select-Cn3ZnqjJ.js} +1 -1
- package/dist/client/assets/{select-model-QQ7yjZl9.js → select-model-BwE-9vfJ.js} +1 -1
- package/dist/client/assets/{settings-layout-Cd1tdTnr.js → settings-layout-dHGH4vpw.js} +1 -1
- package/dist/client/assets/{shell-layout-BE22YA40.js → shell-layout-BsqL_vND.js} +1 -1
- package/dist/client/assets/{skeleton-C9NsUzIb.js → skeleton-DOcx8lZU.js} +1 -1
- package/dist/client/assets/{sso-QSGlyP2n.js → sso-37Vu3qt9.js} +1 -1
- package/dist/client/assets/{store-BB9yi6PD.js → store-D1kidhJ8.js} +1 -1
- package/dist/client/assets/store-registry-qx_8ffch.js +2 -0
- package/dist/client/assets/{switch-VBeL01bM.js → switch-ihM2hYRH.js} +1 -1
- package/dist/client/assets/{table-CQMW-Toa.js → table-CAUXYO7-.js} +1 -1
- package/dist/client/assets/{tabs-DOoLL5wa.js → tabs-DcOxSeRf.js} +1 -1
- package/dist/client/assets/{task-status-vvRP86lz.js → task-status-CHfFeACA.js} +1 -1
- package/dist/client/assets/{textarea-Ie4QUdo5.js → textarea-CsnX9Ktr.js} +1 -1
- package/dist/client/assets/{toggle-group-C077Smww.js → toggle-group-_HWF3GFc.js} +1 -1
- package/dist/client/assets/{tools-list-UnPsMGhr.js → tools-list-A0gJUqTb.js} +1 -1
- package/dist/client/assets/{types-D4PfKOFF.js → types-BGXCye_w.js} +1 -1
- package/dist/client/assets/{use-ai-providers-DHuVj1kn.js → use-ai-providers-DSLKay0D.js} +1 -1
- package/dist/client/assets/{use-collections-DRlHpXQL.js → use-collections-DvPoAlor.js} +1 -1
- package/dist/client/assets/{use-connection-Cif-LY0f.js → use-connection-MU3rXx28.js} +1 -1
- package/dist/client/assets/{use-copy-uiSuMvtc.js → use-copy-tC0v6ypy.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-CBpw3zXA.js → use-create-virtual-mcp-C-LLRhrB.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-Dpt6CcIN.js → use-decopilot-events-fHBaJaln.js} +1 -1
- package/dist/client/assets/{use-delete-connection-BZmW9ZAz.js → use-delete-connection-CowwQ4CA.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-CWlV3gJA.js → use-infinite-scroll-BUM8dH47.js} +1 -1
- package/dist/client/assets/{use-list-state-BJZWeXjY.js → use-list-state-Ba4O0IuX.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-BYVtg7WH.js → use-mcp-tools-B5zpuics.js} +1 -1
- package/dist/client/assets/{use-members-M_p47epa.js → use-members-Bhu2ZnQb.js} +1 -1
- package/dist/client/assets/{use-mobile-CxvYCzu9.js → use-mobile-C4Yo3nsX.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-CFIKBq0L.js → use-navigate-to-agent-Bx0DB5DW.js} +1 -1
- package/dist/client/assets/{use-org-sso-CACnH9GQ.js → use-org-sso-BK-ft_ER.js} +1 -1
- package/dist/client/assets/{use-organization-roles-o4lVU0iD.js → use-organization-roles-uEcrMWhG.js} +1 -1
- package/dist/client/assets/{use-organization-settings-BD9CIHH5.js → use-organization-settings-CMC2yyUM.js} +1 -1
- package/dist/client/assets/{use-registry-connections-DR_etJ2H.js → use-registry-connections-Biq_9qgb.js} +1 -1
- package/dist/client/assets/{use-status-sounds-Ce7WandB.js → use-status-sounds-DfhTS64d.js} +1 -1
- package/dist/client/assets/{use-tasks-Dpp1DK1f.js → use-tasks-DofxyZR4.js} +1 -1
- package/dist/client/assets/{use-view-mode-CZPzVaxj.js → use-view-mode-DSeYcON6.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-0vHwLInn.js → use-virtual-mcp-WT1ZdgMM.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-Gkc0b2zi.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-YePUpUV3.js +1 -0
- package/dist/client/assets/{user-xj80BAo3.js → user-5oBDTi_W.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-D5CGwPOj.js → view-mode-toggle-BvyYLass.js} +1 -1
- package/dist/client/assets/{workflow-CD_DiE5j.js → workflow-DoVF6xyx.js} +1 -1
- package/dist/client/assets/workflow-detail-XUi-wHY3.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -1
- 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/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/slice-ansi/index.d.ts +19 -0
- package/dist/server/node_modules/slice-ansi/index.js +260 -0
- package/dist/server/node_modules/{is-fullwidth-code-point → slice-ansi}/license +1 -0
- package/dist/server/node_modules/slice-ansi/package.json +59 -0
- package/dist/server/node_modules/slice-ansi/readme.md +54 -0
- package/dist/server/node_modules/slice-ansi/tokenize-ansi.js +752 -0
- package/package.json +1 -1
- package/dist/client/assets/ai-providers-DI3UF9nU.js +0 -1
- package/dist/client/assets/brand-context-iopLFZ2k.js +0 -1
- package/dist/client/assets/registry-D3m_WKwq.js +0 -2
- package/dist/client/assets/store-registry-BSp-W72J.js +0 -2
- package/dist/client/assets/useInfiniteQuery-B4w-6TrV.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-WURyRq6p.js +0 -1
- package/dist/client/assets/workflow-detail-CxWEb-ID.js +0 -1
- package/dist/server/node_modules/ansi-regex/index.d.ts +0 -33
- package/dist/server/node_modules/ansi-regex/index.js +0 -14
- package/dist/server/node_modules/ansi-regex/package.json +0 -61
- package/dist/server/node_modules/ansi-regex/readme.md +0 -66
- package/dist/server/node_modules/emoji-regex/LICENSE-MIT.txt +0 -20
- package/dist/server/node_modules/emoji-regex/README.md +0 -107
- package/dist/server/node_modules/emoji-regex/index.d.ts +0 -3
- package/dist/server/node_modules/emoji-regex/index.js +0 -4
- package/dist/server/node_modules/emoji-regex/index.mjs +0 -4
- package/dist/server/node_modules/emoji-regex/package.json +0 -45
- package/dist/server/node_modules/environment/index.d.ts +0 -74
- package/dist/server/node_modules/environment/index.js +0 -47
- package/dist/server/node_modules/environment/license +0 -9
- package/dist/server/node_modules/environment/package.json +0 -74
- package/dist/server/node_modules/environment/readme.md +0 -94
- package/dist/server/node_modules/escape-string-regexp/index.d.ts +0 -18
- package/dist/server/node_modules/escape-string-regexp/index.js +0 -11
- package/dist/server/node_modules/escape-string-regexp/license +0 -9
- package/dist/server/node_modules/escape-string-regexp/package.json +0 -43
- package/dist/server/node_modules/escape-string-regexp/readme.md +0 -29
- package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
- package/dist/server/node_modules/is-fullwidth-code-point/index.js +0 -12
- package/dist/server/node_modules/is-fullwidth-code-point/package.json +0 -53
- package/dist/server/node_modules/is-fullwidth-code-point/readme.md +0 -31
- package/dist/server/node_modules/is-unicode-supported/index.d.ts +0 -12
- package/dist/server/node_modules/is-unicode-supported/index.js +0 -21
- package/dist/server/node_modules/is-unicode-supported/license +0 -9
- package/dist/server/node_modules/is-unicode-supported/package.json +0 -47
- package/dist/server/node_modules/is-unicode-supported/readme.md +0 -35
- package/dist/server/node_modules/onetime/index.d.ts +0 -64
- package/dist/server/node_modules/onetime/index.js +0 -44
- package/dist/server/node_modules/onetime/license +0 -9
- package/dist/server/node_modules/onetime/package.json +0 -43
- package/dist/server/node_modules/onetime/readme.md +0 -94
- package/dist/server/node_modules/restore-cursor/index.d.ts +0 -11
- package/dist/server/node_modules/restore-cursor/index.js +0 -11
- package/dist/server/node_modules/restore-cursor/license +0 -9
- package/dist/server/node_modules/restore-cursor/package.json +0 -55
- package/dist/server/node_modules/restore-cursor/readme.md +0 -31
- package/dist/server/node_modules/string-width/index.d.ts +0 -39
- package/dist/server/node_modules/string-width/index.js +0 -82
- package/dist/server/node_modules/string-width/license +0 -9
- package/dist/server/node_modules/string-width/package.json +0 -64
- package/dist/server/node_modules/string-width/readme.md +0 -66
- /package/dist/server/node_modules/{ansi-regex → get-east-asian-width}/license +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-
|
|
2
|
-
import{o as bt,r as j,p as wf,q as Vf,e as O,s as _e,K as Ze,n as ji,a as Ni,v as as,w as gr,x as Ai,j as r,B as oe,y as pt,c as Y,E as ls,z as ue,C as ei,_ as Cf,t as re,f as Oe,D as wa,F as kf,R as vd,G as jf,H as rs,I as Kn,J as Ei,L as Nf,M as qn,P as Af,Q as Ef,T as If,U as Tf,V as bd,W as Rf,X as Mf,Y as Df,Z as Pf,$ as pl,l as Ne,b as dt,u as Lf,a0 as Zi,a1 as Yr,a2 as Va,a3 as Ca,g as _r,a4 as yd,d as ti,a5 as Of,a6 as Bf,a7 as $f,a8 as zf,a9 as Sd,aa as wd,ab as Ff,ac as Uf,ad as Hf,ae as Wf,af as Kf,ag as qf,ah as Gf,ai as Li,aj as Yf,ak as Xf,al as Jf,am as Qf,an as Vd,ao as Zf,ap as em,aq as tm,ar as sm,as as im,at as rm,au as nm,av as om,aw as am,ax as lm,ay as Cd,az as Xr,aA as cm,aB as pi,aC as Pr,aD as kd,aE as dm,aF as hm}from"./index-D34n6J5J.js";import{u as $s,a as Ii,b as Lt,A as um,C as fm,t as jd,c as Co,d as mm,e as Cn,f as gl}from"./chat-context-DP5UfIrn.js";import{d as kn,g as Ls,c as pm,s as ka,t as ko,a as gm,M as _m,i as xm,b as or,e as vm,F as bm,f as Nd,S as ym,u as Sm,h as _l,j as wm,k as Vm,l as jo,r as Cm,m as km,p as Ad,n as jm,o as Nm,q as ja,G as Am,L as Em,v as Im,w as Tm,x as Rm,y as Mm}from"./task-status-vvRP86lz.js";import{S as ar,u as jn,P as No,a as Dm,b as Pm,c as Lm,E as Om,i as Bm,d as $m,e as Ed}from"./scroll-area-BebfgLv6.js";import{T as bi,u as ms,a as qe,b as Ge,c as Ye}from"./use-mobile-CxvYCzu9.js";import{D as qt,a as Gt,b as Na,c as Ot,d as Bt,e as Nn}from"./dialog-C4lREl-t.js";import{D as An,a as si,b as ii,c as ri,d as zm,e as Fm,f as Um}from"./drawer-BTCEaGGQ.js";import{C as Id}from"./collection-search-Bo2bOvRn.js";import{S as yt,u as Ae,g as En,i as lr,c as Hm,W as jt,a as Wm,b as Aa}from"./constants-DDHDU3PV.js";import{u as Td,g as Ea,T as Rd,a as Jr,l as hn,b as Gn,c as Km}from"./tabs-DOoLL5wa.js";import{F as yi,a as gt,b as _t,c as Ht,d as xt,e as vt,f as qm}from"./form-D7DN8UcB.js";import{I as at}from"./input-urtyHxks.js";import{i as Md,u as xr,r as Dd}from"./shell-layout-BE22YA40.js";import{D as Qe,a as Qr,b as Zr,c as cs,d as ds,e as hs,f as Pd,g as Ld,h as xl}from"./dropdown-menu-v2GifVOh.js";import{s as Os,i as Od}from"./XClose-BbIo6xHe.js";import{t as Gm,i as Bd,n as $d,A as Qt,a as zd,b as Ia,c as Ym,d as Xm,e as Fd,f as Jm,g as Ta,h as er,j as Qm,k as Ra,s as Zm,l as ep,p as vr,m as br,o as tp,q as vl,r as bl,u as sp,v as yl,w as ip,x as Ma,y as Ud,z as Ao,B as Yn,C as Sl,D as rp,E as np,F as op,G as ap,H as Hd,I as Wd,J as Kd,K as qd,L as wl,M as lp,N as tr,O as cp,P as dp,Q as hp,R as Gd}from"./agent-icon-CyE6nkC1.js";import{n as Yd,a as Eo,i as up,b as fp,c as mp}from"./ZapSquare-DT93lGV4.js";import{i as Mt,t as cr}from"./ChevronDown-DGnjAtqs.js";import{s as vi}from"./Star01-_IJK5Yjt.js";import{a as Io,t as Da}from"./Tool01-CKowkGsd.js";import{i as Xd}from"./Lock01-DpPIS3K7.js";import{s as Dt}from"./Plus-oXFwCrYz.js";import{i as In,t as pp,a as gp,b as _p,c as Jd,d as xp,e as vp,f as Si,g as Qd}from"./XCircle-C1sJYG9R.js";import{i as Es}from"./X-i9zBn6Hn.js";import{i as Bs}from"./AlertCircle-DTmaHldD.js";import{S as Ts,a as Rs,b as Nt,c as Ms,d as Ds}from"./select-CePxsPeP.js";import{i as Pa}from"./RefreshCcw01-B10mKiE2.js";import{T as Zd,a as un}from"./toggle-group-C077Smww.js";import{u as La,a as eh}from"./use-ai-providers-DHuVj1kn.js";import{m as Tn,g as bp,i as yp,a as th,M as sh,N as Sp}from"./select-model-QQ7yjZl9.js";import{S as wp,A as Vp,a as Cp,b as kp,c as jp,R as ih,d as Np,e as Ap}from"./accordion-BV3tm7bj.js";import{r as rh,l as sr,u as Ep,g as Ip}from"./types-D4PfKOFF.js";import{u as Rn,a as $t,b as Oa}from"./use-virtual-mcp-0vHwLInn.js";import{u as yr,a as Mn,b as Ba}from"./use-connection-Cif-LY0f.js";import{p as Tp,q as Vl}from"./question-004-sINsf4GQ.js";import{g as Cl}from"./ai-providers-logos-CS4PCiqI.js";import{g as nh,s as oh}from"./connection-slug-eyAPH6o3.js";import{u as ah,a as lh,g as Rp,C as Xn}from"./connection-card-DBz-rrLk.js";import{C as ch}from"./collection-tabs-CU6MCzSn.js";import{g as dh}from"./constants-v4RUVkEN.js";import{T as To}from"./textarea-Ie4QUdo5.js";import{n as en}from"./Container-B1nHZdmn.js";import{c as Mp,i as Lr,a as kl,E as Dp,p as Pp,b as Lp,d as Op}from"./connection-form-helpers-CBEV0IXi.js";import{u as jl}from"./use-infinite-scroll-CWlV3gJA.js";import{u as Bp}from"./useSuspenseInfiniteQuery-WURyRq6p.js";import{g as $p,e as zp,a as Fp}from"./extract-connection-data-CfXvFcGA.js";import{B as Nl}from"./badge-s_TAXGUN.js";import{i as $a}from"./ChevronRight-DV9No7GF.js";import{I as ps}from"./integration-icon-Cdkk9YPE.js";import{S as wi}from"./skeleton-C9NsUzIb.js";import{u as Up}from"./use-organization-settings-BD9CIHH5.js";import{a as Dn}from"./Users03-DqYvPeZM.js";import{G as hh,u as Hp,I as fn,S as uh,L as fh,a as mh,b as ph}from"./github-repo-picker-DZqLC6FL.js";import{u as Sr,a as gh}from"./use-navigate-to-agent-CFIKBq0L.js";import{S as mn}from"./switch-VBeL01bM.js";import{u as _h}from"./use-create-virtual-mcp-CBpw3zXA.js";import{i as Wp}from"./CheckCircle-DJ3lme5R.js";import{C as Kp,a as Al,b as El,c as qp,d as Gp,e as Yp,f as Xp}from"./command-D4w2xkZT.js";import{P as zs,a as Fs,b as Us}from"./popover-j_PzMtdY.js";import{u as ni,a as Jp}from"./use-mcp-tools-BYVtg7WH.js";import{E as Vi}from"./empty-state-BdQTFnZA.js";import{u as Qp}from"./use-decopilot-events-Dpt6CcIN.js";import{i as Ci}from"./Zap-KmbRMccM.js";import{i as xh,S as wr,a as Vr,b as es,u as Cr,c as Zt,d as Pt,e as vh,f as bh,g as Zp,h as yh,j as Sh,P as Jt,k as eg,l as tg,m as sg,n as ig,o as rg,p as ng}from"./index-zDq2Zqio.js";import{A as Il}from"./avatar-CF1bgUpD.js";import{n as og,a as ag,i as lg}from"./Sun-QqE1VnS_.js";import{a as kr}from"./Settings02-Dm9dFDqk.js";import{i as cg}from"./Shield01-BZJVBd5S.js";import{A as za,a as Fa,b as Ua,c as Ha,d as Wa,e as Ka,f as qa,g as wh}from"./alert-dialog-CicrCOay.js";import"./index-C5AR7k1c.js";import{u as dg,a as Tl,K as hg,P as ug,S as fg,v as mg,D as pg,c as gg,s as _g,b as xg,d as vg,C as bg,e as yg}from"./collection-search-DMqppne6.js";import{u as Vh}from"./use-tasks-Dpp1DK1f.js";import{u as Sg}from"./use-status-sounds-Ce7WandB.js";import{T as wg,u as Ch}from"./tools-list-UnPsMGhr.js";import{u as Jn}from"./unwrap-tool-result-BYXdCQMg.js";import{C as Vg,a as Rl}from"./card-CaekC2K0.js";import{L as ir}from"./label-Bt4h_QUk.js";import{i as tn}from"./Play-DKFUTU3G.js";import{s as Ro}from"./Trash01-C6bAXG6g.js";import{i as kh,a as Cg}from"./SearchMd-BRJBvWf4.js";import{C as kg}from"./checkbox-DznLgPgR.js";import{n as oi}from"./LinkExternal01-BBbCPDtX.js";import{V as jg}from"./view-mode-toggle-D5CGwPOj.js";import{U as Ng}from"./user-xj80BAo3.js";import{u as jr,a as Ag,b as Eg,c as Ig,A as Tg,d as Rg}from"./automation-list-row-B4Vfg4UC.js";import{S as Mg}from"./search-input-dmuYGYsk.js";import"./use-collections-DRlHpXQL.js";import"./use-copy-uiSuMvtc.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./DotsVertical-Bp2tW8JI.js";import"./required-auth-layout-C2o7AZ4K.js";import"./use-org-sso-CACnH9GQ.js";import"./ArrowNarrowLeft-DlPeFc4v.js";import"./ChevronUp-BkSgkwhO.js";import"./Palette-CI8n49a8.js";import"./User01-C2-anwoO.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-DR_etJ2H.js";import"./useInfiniteQuery-B4w-6TrV.js";import"./infiniteQueryObserver-1_M-sq16.js";import"./collections-DHmXATua.js";import"./index-FnxI6OGR.js";import"./create-sse-subscription-CxkOgzKf.js";function Dg(t,e){const s=bt(e);return Pg({filters:{...t,status:"pending"}},s).length}function Ml(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Pg(t={},e){const s=bt(e).getMutationCache(),i=j.useRef(t),n=j.useRef(null);return n.current===null&&(n.current=Ml(s,t)),j.useEffect(()=>{i.current=t}),j.useSyncExternalStore(j.useCallback(o=>s.subscribe(()=>{const a=wf(n.current,Ml(s,i.current));n.current!==a&&(n.current=a,Vf.schedule(o))}),[s]),()=>n.current,()=>n.current)}function Lg(t,e){const s=O.c(37),{org:i,locator:n}=_e();let o;s[0]!==i.id?(o={connectionId:yt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Ae(o),l=bt();let c;s[2]!==t||s[3]!==i.id?(c=Ze.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=ji(u);let f;s[11]!==a||s[12]!==e?(f=async v=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:v,virtual_mcp_id:e}}});if(y.isError){const C=y.content,S=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(S)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=f):f=s[13];let m;s[14]!==n||s[15]!==i.id||s[16]!==h||s[17]!==l?(m=()=>{l.invalidateQueries({predicate:v=>v.queryKey[1]===i.id&&v.queryKey[3]==="collection"&&v.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:Ze.tasksPrefix(n)}),h.refetch()},s[14]=n,s[15]=i.id,s[16]=h,s[17]=l,s[18]=m):m=s[18];let p;s[19]!==f||s[20]!==m?(p={mutationFn:f,onSuccess:m},s[19]=f,s[20]=m,s[21]=p):p=s[21];const g=Ni(p);let _,b;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},b=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=b):(_=s[26],b=s[27]),j.useEffect(_,b),h.isLoading){let v;return s[28]===Symbol.for("react.memo_cache_sentinel")?(v={status:"loading"},s[28]=v):v=s[28],v}if(h.isError){const v=h.error;let y;return s[29]!==v?(y={status:"error",error:v},s[29]=v,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let v;return s[31]!==h.data?(v={status:"ready",task:h.data},s[31]=h.data,s[32]=v):v=s[32],v}if(g.isPending||h.isSuccess&&!h.data){let v;return s[33]===Symbol.for("react.memo_cache_sentinel")?(v={status:"creating"},s[33]=v):v=s[33],v}if(g.isError){let v;return s[34]!==g.error?(v={status:"error",error:g.error},s[34]=g.error,s[35]=v):v=s[35],v}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function Og(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?pt().min(1,"Required"):pt();return as(e)}function Bg(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Ga(t){const e=O.c(65),{prompt:s,setPrompt:i,onSubmit:n}=t,o=j.useId();let a;if(e[0]!==s){const R=s?Og(s):as({});a=gr(R),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?Bg(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=Ai(u);let f;e[7]!==s?.arguments?(f=s?.arguments??[],e[7]=s?.arguments,e[8]=f):f=e[8];const m=f;let p;e[9]!==h||e[10]!==n||e[11]!==i?(p=async R=>{await n(R),i(null),h.reset()},e[9]=h,e[10]=n,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=R=>{R||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const b=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||kn(s.name,Ls(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let v;e[20]!==x?(v=r.jsx(qt,{children:r.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=v):v=e[21];let y;e[22]!==s.description?(y=s.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let V;e[24]!==y||e[25]!==v?(V=r.jsxs(Gt,{children:[v,y]}),e[24]=y,e[25]=v,e[26]=V):V=e[26];let C;e[27]!==h||e[28]!==g?(C=R=>{R.stopPropagation(),h.handleSubmit(g)(R)},e[27]=h,e[28]=g,e[29]=C):C=e[29];let S;if(e[30]!==m||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let R;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(R=P=>r.jsx(gt,{control:h.control,name:P.name,render:B=>{const{field:$}=B;return r.jsxs(_t,{children:[r.jsxs(Ht,{className:"text-xs",children:[P.name,P.required?null:r.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),r.jsx(xt,{children:r.jsx(at,{...$,value:$.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),r.jsx(vt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=R):R=e[36],S=m.map(R),e[30]=m,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=S}else S=e[33];let w;e[37]!==b?(w=()=>b(!1),e[37]=b,e[38]=w):w=e[38];let k;e[39]!==h.formState.isSubmitting||e[40]!==w?(k=r.jsx(oe,{type:"button",variant:"ghost",onClick:w,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=w,e[41]=k):k=e[41];const T=!h.formState.isValid||h.formState.isSubmitting;let M;e[42]!==h.formState.isSubmitting?(M=h.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(ar,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=M):M=e[43];let I;e[44]!==o||e[45]!==T||e[46]!==M?(I=r.jsx(oe,{type:"submit",form:o,disabled:T,children:M}),e[44]=o,e[45]=T,e[46]=M,e[47]=I):I=e[47];let E;e[48]!==k||e[49]!==I?(E=r.jsxs(Na,{children:[k,I]}),e[48]=k,e[49]=I,e[50]=E):E=e[50];let N;e[51]!==o||e[52]!==C||e[53]!==S||e[54]!==E?(N=r.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:C,children:[S,E]}),e[51]=o,e[52]=C,e[53]=S,e[54]=E,e[55]=N):N=e[55];let A;e[56]!==h||e[57]!==N?(A=r.jsx(yi,{...h,children:N}),e[56]=h,e[57]=N,e[58]=A):A=e[58];let D;e[59]!==V||e[60]!==A?(D=r.jsxs(Ot,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[V,A]}),e[59]=V,e[60]=A,e[61]=D):D=e[61];let L;return e[62]!==b||e[63]!==D?(L=r.jsx(Bt,{open:!0,onOpenChange:b,children:D}),e[62]=b,e[63]=D,e[64]=L):L=e[64],L}function $g(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 zg(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Dl=3,jh="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",Fg="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Nh(t){const e=O.c(46),{item:s,onSelect:i,isLoading:n,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const S=Ls(c._meta);d=c.title??kn(c.name,S),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let S;e[4]!==i||e[5]!==c?(S=()=>i(c),e[4]=i,e[5]=c,e[6]=S):S=e[6];const w=o||n,k=n&&"bg-accent/40",T=(o||n)&&"cursor-not-allowed opacity-50";let M;e[7]!==k||e[8]!==T?(M=Y(Fg,"hover:bg-accent/60 text-foreground",k,T),e[7]=k,e[8]=T,e[9]=M):M=e[9];let I;e[10]!==u?(I=r.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=I):I=e[11];let E;e[12]!==n?(E=n&&r.jsx(ar,{size:"xs"}),e[12]=n,e[13]=E):E=e[13];let N;e[14]!==I||e[15]!==E?(N=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[I,E]}),e[14]=I,e[15]=E,e[16]=N):N=e[16];let A;e[17]!==h?(A=h&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=A):A=e[18];let D;return e[19]!==N||e[20]!==A||e[21]!==S||e[22]!==w||e[23]!==M?(D=r.jsxs("button",{type:"button",onClick:S,disabled:w,className:M,children:[N,A]}),e[19]=N,e[20]=A,e[21]=S,e[22]=w,e[23]=M,e[24]=D):D=e[24],D}let f;e[25]!==i||e[26]!==c?(f=()=>i(c),e[25]=i,e[26]=c,e[27]=f):f=e[27];const m=o||n,p=n&&"bg-muted/50",g=(o||n)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=Y(jh,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let b;e[31]!==u?(b=r.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=b):b=e[32];let x;e[33]!==n?(x=n&&r.jsx(ar,{size:"xs"}),e[33]=n,e[34]=x):x=e[34];let v;e[35]!==f||e[36]!==m||e[37]!==_||e[38]!==b||e[39]!==x?(v=r.jsx(qe,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:f,disabled:m,className:_,children:[b,x]})}),e[35]=f,e[36]=m,e[37]=_,e[38]=b,e[39]=x,e[40]=v):v=e[40];const y=h??u;let V;e[41]!==y?(V=r.jsx(Ge,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=V):V=e[42];let C;return e[43]!==v||e[44]!==V?(C=r.jsxs(Ye,{delayDuration:400,children:[v,V]}),e[43]=v,e[44]=V,e[45]=C):C=e[45],C}function Ug(t){const e=O.c(41),{items:s,open:i,onOpenChange:n,onSelect:o,loadingPrompt:a}=t,[l,c]=j.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(w=>{const k=l.toLowerCase();return w.prompt.name.toLowerCase().includes(k)||(w.prompt.title??"").toLowerCase().includes(k)||(w.prompt.description??"").toLowerCase().includes(k)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,f=ms();let m;e[3]!==h.length||e[4]!==l?(m=h.length===0&&r.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==n||e[10]!==o){let w;e[12]!==d||e[13]!==a?.name||e[14]!==n||e[15]!==o?(w=k=>r.jsx(Nh,{item:k,variant:"card",onSelect:T=>{n(!1),o(T)},isLoading:a?.name===k.prompt.name,isDisabled:d&&a?.name!==k.prompt.name},k.prompt.name),e[12]=d,e[13]=a?.name,e[14]=n,e[15]=o,e[16]=w):w=e[16],p=h.map(w),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=n,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const _=g;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=w=>{w.key==="Escape"&&c("")},e[20]=b):b=e[20];let x;e[21]!==l?(x=r.jsx(Id,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:b}),e[21]=l,e[22]=x):x=e[22];const v=x;if(f){let w;e[23]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(An,{className:"sr-only",children:r.jsx(si,{children:"All prompts"})}),e[23]=w):w=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=k):k=e[24];let T;e[25]!==_||e[26]!==v?(T=r.jsxs(ii,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[w,k,v,_]}),e[25]=_,e[26]=v,e[27]=T):T=e[27];let M;return e[28]!==n||e[29]!==i||e[30]!==T?(M=r.jsx(bi,{delayDuration:400,children:r.jsx(ri,{open:i,onOpenChange:n,children:T})}),e[28]=n,e[29]=i,e[30]=T,e[31]=M):M=e[31],M}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Gt,{className:"sr-only",children:r.jsx(qt,{children:"All prompts"})}),e[32]=y):y=e[32];let V;e[33]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=V):V=e[33];let C;e[34]!==_||e[35]!==v?(C=r.jsxs(Ot,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,V,v,_]}),e[34]=_,e[35]=v,e[36]=C):C=e[36];let S;return e[37]!==n||e[38]!==i||e[39]!==C?(S=r.jsx(bi,{delayDuration:400,children:r.jsx(Bt,{open:i,onOpenChange:n,children:C})}),e[37]=n,e[38]=i,e[39]=C,e[40]=S):S=e[40],S}function Hg(t){const e=O.c(29),{items:s,onSelect:i,loadingPrompt:n,className:o}=t,[a,l]=j.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==n||e[2]!==i){const b=s.slice(0,Dl);let x;e[6]!==s?(x=s.slice(Dl),e[6]=s,e[7]=x):x=e[7],c=x,d=!!n;let v;e[8]!==d||e[9]!==n?.name||e[10]!==i?(v=y=>r.jsx(Nh,{item:y,onSelect:i,isLoading:n?.name===y.prompt.name,isDisabled:d&&n?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=n?.name,e[10]=i,e[11]=v):v=e[11],u=b.map(v),e[0]=s,e[1]=n,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let f;e[12]!==o?(f=Y("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&r.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:Y(jh,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==f||e[19]!==m?(p=r.jsxs("div",{className:f,children:[h,m]}),e[17]=h,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==n||e[23]!==a||e[24]!==i?(g=r.jsx(Ug,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:n}),e[21]=s,e[22]=n,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=r.jsxs(bi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function Wg(){return null}function Kg(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 qg(t){const e=O.c(30),{connectionId:s}=t,{sendMessage:i}=Ii(),{tiptapDocRef:n}=$s(),{org:o}=_e();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Ae(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Td(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let f;e[7]!==h?(f=h.map(Gg),e[7]=h,e[8]=f):f=e[8];const m=f;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=j.useReducer(Kg,p),[b,x]=j.useState(null);let v;e[10]!==l||e[11]!==i||e[12]!==n?(v=async(N,A)=>{if(!l){ue.error("MCP client not available"),_({type:"RESET"});return}try{const D=await Ea(l,N.name,A);_({type:"RESET"});const L=zg(n.current,{type:"paragraph",content:[pm({id:N.name,name:ka(N.name,Ls(N._meta)),metadata:D.messages,char:"/"})]});await i(L)}catch(D){console.error("[ice-breakers] Failed to fetch prompt:",D),ue.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=n,e[13]=v):v=e[13];const y=v;let V;e[14]!==y?(V=async N=>{if(N.arguments&&N.arguments.length>0){_({type:"SELECT_PROMPT",prompt:N}),x(N);return}_({type:"START_LOADING",prompt:N}),await y(N)},e[14]=y,e[15]=V):V=e[15];const C=V;let S;e[16]!==b||e[17]!==y?(S=async N=>{b&&(_({type:"START_LOADING",prompt:b,arguments:N}),x(null),await y(b,N))},e[16]=b,e[17]=y,e[18]=S):S=e[18];const w=S;if(m.length===0)return null;const k=g.stage==="loading"?g.prompt:null;let T;e[19]!==C||e[20]!==m||e[21]!==k?(T=r.jsx(Hg,{items:m,onSelect:C,loadingPrompt:k}),e[19]=C,e[20]=m,e[21]=k,e[22]=T):T=e[22];let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{x(null),_({type:"RESET"})},e[23]=M):M=e[23];let I;e[24]!==b||e[25]!==w?(I=r.jsx(Ga,{prompt:b,setPrompt:M,onSubmit:w}),e[24]=b,e[25]=w,e[26]=I):I=e[26];let E;return e[27]!==T||e[28]!==I?(E=r.jsxs(r.Fragment,{children:[T,I]}),e[27]=T,e[28]=I,e[29]=E):E=e[29],E}function Gg(t){return{prompt:t}}function Yg(t){const e=O.c(13),{className:s}=t,{selectedVirtualMcp:i}=$s(),{org:n}=_e();let o;e[0]!==n.id?(o=En(n.id),e[0]=n.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=Y("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Wg,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=r.jsx(qg,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let f;e[7]!==d||e[8]!==h?(f=r.jsx(ls,{fallback:null,children:r.jsx(j.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=r.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}function Ah(t){const e=O.c(21),{current:s,total:i,onPrev:n,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=Y("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Pa,{size:14}),e[2]=d):d=e[2];let u;e[3]!==n||e[4]!==a||e[5]!==c?(u=r.jsx("button",{type:"button",onClick:n,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=n,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let f;e[7]!==h||e[8]!==i?(f=r.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=f):f=e[9];const m=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=Y("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(In,{size:14}),e[12]=_):_=e[12];let b;e[13]!==o||e[14]!==g||e[15]!==m?(b=r.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=m,e[16]=b):b=e[16];let x;return e[17]!==b||e[18]!==u||e[19]!==f?(x=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,f,b]}),e[17]=b,e[18]=u,e[19]=f,e[20]=x):x=e[20],x}function pn(t){const e=O.c(18),{title:s,children:i,footerLeft:n,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=Y("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=r.jsx("div",{className:"flex items-center gap-2 p-4",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=r.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==n?(h=r.jsx("div",{children:n}),e[6]=n,e[7]=h):h=e[7];let f;e[8]!==o?(f=r.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==h||e[11]!==f?(m=r.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[h,f]})}),e[10]=h,e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==m?(p=r.jsxs("div",{className:c,children:[d,u,m]}),e[13]=c,e[14]=d,e[15]=u,e[16]=m,e[17]=p):p=e[17],p}const Xg="User denied this tool call, give other alternatives.",Jg=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function Qg(t){const e=O.c(9),{onYolo:s}=t,[i,n]=ei();let o;e[0]!==s||e[1]!==i||e[2]!==n?(o=u=>{const h=u;n({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=n,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ms,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:e_,children:r.jsx(Ds,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Ts,{children:Jg.map(Zg)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=r.jsxs(Rs,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function Zg(t){return r.jsx(Nt,{value:t.value,children:t.label},t.value)}function e_(t){return t.stopPropagation()}function t_(t){const e=O.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.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 n;return e[3]!==i?(n=r.jsx("div",{className:"px-4",children:r.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]=n):n=e[4],n}function s_(t){const e=O.c(42),{approvals:s,onRespond:i}=t,[n,o]=j.useState(0),a=Math.min(n,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,Xg)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let f;e[6]!==s||e[7]!==i?(f=()=>{for(const E of s)i(E.approvalId,!0)},e[6]=s,e[7]=i,e[8]=f):f=e[8];const m=f;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const b=_;let x;e[14]!==m?(x=r.jsx(Qg,{onYolo:m}),e[14]=m,e[15]=x):x=e[15];let v;e[16]!==s.length||e[17]!==b||e[18]!==g||e[19]!==a?(v=r.jsx(Ah,{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 y;e[21]!==x||e[22]!==v?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[x,v]}),e[21]=x,e[22]=v,e[23]=y):y=e[23];const V=y;let C;e[24]!==d?(C=r.jsx(oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:d,children:"Deny"}),e[24]=d,e[25]=C):C=e[25];let S;e[26]!==s.length||e[27]!==m?(S=s.length>1&&r.jsx(oe,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:m,children:"Accept All"}),e[26]=s.length,e[27]=m,e[28]=S):S=e[28];let w;e[29]!==h?(w=r.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=w):w=e[30];let k;e[31]!==S||e[32]!==w||e[33]!==C?(k=r.jsxs(r.Fragment,{children:[C,S,w]}),e[31]=S,e[32]=w,e[33]=C,e[34]=k):k=e[34];const T=k;let M;e[35]!==l.input?(M=r.jsx(t_,{input:l.input}),e[35]=l.input,e[36]=M):M=e[36];let I;return e[37]!==l.friendlyName||e[38]!==V||e[39]!==T||e[40]!==M?(I=r.jsx(pn,{title:l.friendlyName,footerLeft:V,footerRight:T,children:M}),e[37]=l.friendlyName,e[38]=V,e[39]=T,e[40]=M,e[41]=I):I=e[41],I}function i_(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(Gm,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function r_(t){const e=O.c(4),{approvals:s,isStreaming:i,onRespond:n}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(i_,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==n?(o=r.jsx(s_,{approvals:s,onRespond:n}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function n_(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:ko(gm(i)),input:s.input})}return e}function o_(t){const e=O.c(15),{plan:s,onApprove:i,onDismiss:n}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==n?(l=r.jsx(oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:n,children:"Keep iterating"}),e[3]=n,e[4]=l):l=e[4];let c;e[5]!==a?(c=r.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=r.jsxs(r.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(_m,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let f;return e[12]!==u||e[13]!==h?(f=r.jsx(pn,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=f):f=e[14],f}function a_(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(Mt,{className:"size-5 text-purple-500 shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function l_(t){const e=O.c(7),{plans:s,isStreaming:i,onApprove:n,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(a_,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==n||e[5]!==o?(c=r.jsx(o_,{plan:l,onApprove:n,onDismiss:o}),e[3]=l,e[4]=n,e[5]=o,e[6]=c):c=e[6],c}function c_(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 Pl=as({response:pt().min(1,"Response is required")}),d_=as({response:pt().min(1,"Please select or enter an option")}),h_=as({response:Cf(["yes","no"])});function u_(t){switch(t.type){case"text":return Pl;case"choice":return d_;case"confirm":return h_;default:return Pl}}function f_(t){const e={};for(const s of t)e[s.toolCallId]=u_(s.input);return as(e)}function m_(t){const e=O.c(6),{control:s,name:i,placeholder:n}=t;let o;e[0]!==n?(o=l=>{const{field:c}=l;return r.jsxs(_t,{children:[r.jsx(xt,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(Bd,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...c,type:"text",placeholder:n||"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"})]})})}),r.jsx(vt,{})]})},e[0]=n,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=r.jsx(gt,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Eh(t,e){const s=O.c(4);let i,n;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},n=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=n):(i=s[2],n=s[3]),j.useEffect(i,n)}function p_(t){const e=O.c(9),{control:s,name:i,options:n}=t,[o,a]=j.useState(!1),l=j.useRef(null),c=j.useRef(null);let d;if(e[0]!==n?(d=f=>{c.current?.onChange(n[f]??""),a(!1)},e[0]=n,e[1]=d):d=e[1],Eh(n.length,d),n.length===0)return null;let u;e[2]!==o||e[3]!==n?(u=f=>{const{field:m}=f;c.current=m;const p=o||!!m.value&&!n.includes(m.value);return r.jsxs(_t,{children:[r.jsx(xt,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[n.map((g,_)=>{const b=m.value===g;return r.jsxs("button",{type:"button",onClick:()=>{m.onChange(g??""),a(!1)},className:Y("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:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",b?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),r.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),r.jsxs("div",{className:Y("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),n.includes(m.value)&&m.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(Bd,{size:16,className:"text-muted-foreground"})}),p?r.jsx("input",{ref:l,type:"text",value:m.value,onChange:g=>m.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):r.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),r.jsx(vt,{})]})},e[2]=o,e[3]=n,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=r.jsx(gt,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function g_(t){const e=O.c(6),{control:s,name:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=["yes","no"],e[0]=n):n=e[0];const o=n,a=j.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],Eh(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,r.jsxs(_t,{children:[r.jsx(xt,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=h.value===f;return r.jsxs("button",{type:"button",onClick:()=>h.onChange(f),className:Y("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),r.jsx(vt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=r.jsx(gt,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Ll(t){const e=O.c(13),{input:s,control:i,name:n}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==n?(o=r.jsx(m_,{control:i,name:n,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=n,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==i||e[7]!==n||e[8]!==a?(l=r.jsx(p_,{control:i,name:n,options:a}),e[6]=i,e[7]=n,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==n?(o=r.jsx(g_,{control:i,name:n}),e[10]=i,e[11]=n,e[12]=o):o=e[12],o}default:return null}}function __({parts:t,onSubmit:e}){const[s,i]=j.useState(t[0]?.toolCallId??""),n=f_(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=Ai({resolver:gr(n),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const v of t){const y=x[v.toolCallId]?.response;y&&e(v,y)}},h=x=>t.find(v=>!x[v.toolCallId]?.response&&v.toolCallId!==s)??null,f=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},m=()=>{o.setValue(`${s}.response`,"user has skip this question"),f()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=r.jsxs(r.Fragment,{children:[r.jsx(oe,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7",children:"Skip"}),r.jsx(oe,{type:"button",size:"sm",disabled:!c,onClick:f,className:Y("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),b=r.jsx(Ah,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?r.jsx(yi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(pn,{title:x.input?.prompt??"Question",footerRight:_,children:r.jsx(Ll,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return r.jsx(yi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(Rd,{value:s,onValueChange:i,children:t.map(x=>r.jsx(Jr,{value:x.toolCallId,className:"mt-0",children:r.jsx(pn,{title:x.input?.prompt??"Question",footerLeft:b,footerRight:_,children:r.jsx(Ll,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function x_(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(pp,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Ih(t){const e=O.c(6),{userAskParts:s,isStreaming:i,onSubmit:n}=t;let o;e[0]!==s?(o=s.filter(v_),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(x_,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==n||e[4]!==a?(l=r.jsx(__,{parts:a,onSubmit:n}),e[3]=n,e[4]=a,e[5]=l):l=e[5],l}function v_(t){return t.state==="input-available"}const Ol=new Map;function Pn(){const{org:t}=_e(),e=Ae({connectionId:yt,orgId:t.id}),s=La(),i=s.find(_=>_.providerId==="deco"),{data:n,isLoading:o,refetch:a,isFetching:l}=ji({queryKey:Ze.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=n?.balanceCents??null,d=c!=null?c/100:null,u=j.useRef(new Map);if(c!=null){const _=Ol.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&re("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Ol.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,f=c!=null&&c>0,m=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:f,isZeroBalance:m,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function b_(t){return t?t.message.startsWith("[CREDITS]"):!1}const y_={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"}]},S_=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Th(t){const e=O.c(43),{onDismiss:s}=t,{org:i}=_e(),n=Oe(),{decoKeyId:o}=Pn();let a;e[0]!==i.id?(a={connectionId:yt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Ae(a),[c,d]=j.useState(""),[u,h]=j.useState(!1),[f,m]=j.useState("usd"),p=f==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{re("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),j.useEffect(g,_);let b;e[5]!==l||e[6]!==f?(b=async R=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:R,currency:f}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=f,e[7]=b):b=e[7];let x;e[8]!==s?(x=R=>{R&&window.open(R,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let v;e[10]!==b||e[11]!==x?(v={mutationFn:b,onSuccess:x,onError:C_},e[10]=b,e[11]=x,e[12]=v):v=e[12];const{mutate:y,isPending:V}=Ni(v),C=parseFloat(c),S=!isNaN(C)&&C>=1;let w;e[13]!==s?(w=R=>!R&&s?.(),e[13]=s,e[14]=w):w=e[14];let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[15]=k):k=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:k.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=T):T=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[T,r.jsxs(Gt,{className:"relative gap-4",children:[r.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"}),r.jsxs("div",{children:[r.jsx(qt,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),r.jsx(Nn,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[17]=M):M=e[17];let I;e[18]!==f||e[19]!==p||e[20]!==c||e[21]!==C||e[22]!==o||e[23]!==S||e[24]!==V||e[25]!==u||e[26]!==y?(I=o&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(Zd,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:R=>{R&&m(R)},children:[r.jsx(un,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(un,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:y_[f].map(R=>{const{dollars:P,label:B}=R;return r.jsxs("button",{type:"button",disabled:V,onClick:()=>{re("credits_topup_clicked",{amount_cents:P*100,currency:f,tier_label:B,source:"exhausted_banner"}),y(P*100)},className:Y("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:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:B})]},P)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(at,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:R=>d(R.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(oe,{className:"h-10",disabled:!S||V,onClick:()=>{re("credits_topup_clicked",{amount_cents:Math.round(C*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(C*100))},children:V?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:S_.map(w_)})]}),e[18]=f,e[19]=p,e[20]=c,e[21]=C,e[22]=o,e[23]=S,e[24]=V,e[25]=u,e[26]=y,e[27]=I):I=e[27];let E;e[28]!==s?(E=r.jsx(oe,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=E):E=e[29];let N;e[30]!==n||e[31]!==s||e[32]!==i.slug?(N=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{n({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=n,e[31]=s,e[32]=i.slug,e[33]=N):N=e[33];let A;e[34]!==E||e[35]!==N?(A=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[E,N]}),e[34]=E,e[35]=N,e[36]=A):A=e[36];let D;e[37]!==I||e[38]!==A?(D=r.jsxs(Ot,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:V_,children:[M,I,A]}),e[37]=I,e[38]=A,e[39]=D):D=e[39];let L;return e[40]!==D||e[41]!==w?(L=r.jsx(Bt,{open:!0,onOpenChange:w,children:D}),e[40]=D,e[41]=w,e[42]=L):L=e[42],L}function w_(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(Mt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function V_(t){return t.preventDefault()}function C_(t){ue.error(`Top-up failed: ${t.message}`)}const k_={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 gn(t){const e=O.c(32),{variant:s,onDismiss:i}=t,n=s==="error",o=n?"Error occurred":"Response incomplete",a=n?t.error.message:k_[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=n?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=n?"text-destructive":"text-amber-600 dark:text-amber-500",d=n?Bs:wa;let u;e[0]!==l?(u=Y("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=Y("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==d?(f=r.jsx(d,{size:16}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==f?(m=r.jsx("div",{className:h,children:f}),e[6]=h,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==c?(p=Y("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=r.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=r.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let b;e[16]!==n||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(b=r.jsx("div",{className:"flex gap-2",children:n?r.jsxs(r.Fragment,{children:[r.jsx(oe,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),r.jsx(oe,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):r.jsx(oe,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=n,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=b):b=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==b?(x=r.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,b]}),e[20]=g,e[21]=_,e[22]=b,e[23]=x):x=e[23];let v;e[24]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Es,{size:14}),e[24]=v):v=e[24];let y;e[25]!==i?(y=r.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]=y):y=e[26];let V;return e[27]!==u||e[28]!==y||e[29]!==m||e[30]!==x?(V=r.jsx("div",{className:"px-0.5",children:r.jsxs("div",{className:u,children:[m,x,y]})}),e[27]=u,e[28]=y,e[29]=m,e[30]=x,e[31]=V):V=e[31],V}function Ln(){const t=O.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:n,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Ii(),[h,f]=ei(),{virtualMcpId:m,createTaskWithMessage:p}=Lt();let g,_,b,x;if(t[0]!==o){const A=o.at(-1);x=A?.role==="assistant"?A.parts.filter(A_):null,g=x?.filter(N_)?.length,_=A?.role==="assistant"?c_(A.parts):[],b=A?.role==="assistant"?n_(A.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=b,t[4]=x}else g=t[1],_=t[2],b=t[3],x=t[4];const v=b;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const D={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(D)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const V=y;let C;t[8]!==u?(C=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=C):C=t[9];const S=C;let w;t[10]!==c?(w=(A,D)=>{c({tool:"user_ask",toolCallId:A.toolCallId,output:{response:D}})},t[10]=c,t[11]=w):w=t[11];const k=w;let T;t[12]!==p||t[13]!==h||t[14]!==f||t[15]!==m?(T=A=>{f({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:m,message:{parts:[{type:"text",text:`Implement this plan:
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-DbITEuQv.js","assets/index-DhJrYN5i.js","assets/index-BCwsJqWc.css","assets/task-status-CHfFeACA.js","assets/agent-icon-DKQKq---.js","assets/AlertCircle-Bgzr6uRA.js","assets/Tool01-BscqkhhO.js","assets/XClose-ANREDbeo.js","assets/RefreshCcw01-BxULs6ec.js","assets/ArrowNarrowLeft-ByrdB8Dd.js","assets/XCircle-BFZeumzD.js","assets/ZapSquare-Bz3HDhTc.js","assets/Users03-DwNyb_q2.js","assets/CheckCircle-88bls7UK.js","assets/ChevronDown-Jd-cYHC-.js","assets/ChevronRight-71i8ke8L.js","assets/ChevronUp-D_szSdLd.js","assets/DotsVertical-CjXyjLNU.js","assets/Container-DWaKXfYv.js","assets/Star01-DZHrISf9.js","assets/Palette-DuWQiO51.js","assets/SearchMd-D6tCV38D.js","assets/index-DvgxnJsz.js","assets/use-mobile-C4Yo3nsX.js","assets/X-BuUY-erD.js","assets/LinkExternal01-DB08YntP.js","assets/Lock01-dBhVogWg.js","assets/Sun-C8X8gjZW.js","assets/Play-D7pqvkYq.js","assets/Plus-BzxOIhxj.js","assets/Settings02-MyfUtBA4.js","assets/Shield01-CMw4M4Ml.js","assets/Trash01-DZpzvWVW.js","assets/User01-VHn0SqBP.js","assets/Zap-BxJkZzJb.js","assets/scroll-area-CXUp8wR9.js","assets/select-Cn3ZnqjJ.js","assets/use-copy-tC0v6ypy.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-nGTWjCEa.js","assets/content-blocks-o63cs2vh.js","assets/types-BGXCye_w.js","assets/constants-aD7HJ6sY.js","assets/chat-context-DfEaB6Uj.js","assets/use-virtual-mcp-WT1ZdgMM.js","assets/use-collections-DvPoAlor.js","assets/use-ai-providers-DSLKay0D.js","assets/use-decopilot-events-fHBaJaln.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-DofxyZR4.js","assets/use-organization-settings-CMC2yyUM.js","assets/shell-layout-BsqL_vND.js","assets/required-auth-layout-CP-yDaO3.js","assets/use-org-sso-BK-ft_ER.js","assets/integration-icon-DKrcAAs9.js","assets/use-mcp-tools-B5zpuics.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as bt,r as j,p as wf,q as Vf,e as O,s as _e,K as Ze,n as ji,a as Ni,v as as,w as gr,x as Ai,j as r,B as oe,y as pt,c as Y,E as ls,z as ue,C as ei,_ as Cf,t as re,f as Oe,D as wa,F as kf,R as vd,G as jf,H as rs,I as Kn,J as Ei,L as Nf,M as qn,P as Af,Q as Ef,T as If,U as Tf,V as bd,W as Rf,X as Mf,Y as Df,Z as Pf,$ as pl,l as Ne,b as dt,u as Lf,a0 as Zi,a1 as Yr,a2 as Va,a3 as Ca,g as _r,a4 as yd,d as ti,a5 as Of,a6 as Bf,a7 as $f,a8 as zf,a9 as Sd,aa as wd,ab as Ff,ac as Uf,ad as Hf,ae as Wf,af as Kf,ag as qf,ah as Gf,ai as Li,aj as Yf,ak as Xf,al as Jf,am as Qf,an as Vd,ao as Zf,ap as em,aq as tm,ar as sm,as as im,at as rm,au as nm,av as om,aw as am,ax as lm,ay as Cd,az as Xr,aA as cm,aB as pi,aC as Pr,aD as kd,aE as dm,aF as hm}from"./index-DhJrYN5i.js";import{u as $s,a as Ii,b as Lt,A as um,C as fm,t as jd,c as Co,d as mm,e as Cn,f as gl}from"./chat-context-DfEaB6Uj.js";import{d as kn,g as Ls,c as pm,s as ka,t as ko,a as gm,M as _m,i as xm,b as or,e as vm,F as bm,f as Nd,S as ym,u as Sm,h as _l,j as wm,k as Vm,l as jo,r as Cm,m as km,p as Ad,n as jm,o as Nm,q as ja,G as Am,L as Em,v as Im,w as Tm,x as Rm,y as Mm}from"./task-status-CHfFeACA.js";import{S as ar,u as jn,P as No,a as Dm,b as Pm,c as Lm,E as Om,i as Bm,d as $m,e as Ed}from"./scroll-area-CXUp8wR9.js";import{T as bi,u as ms,a as qe,b as Ge,c as Ye}from"./use-mobile-C4Yo3nsX.js";import{D as qt,a as Gt,b as Na,c as Ot,d as Bt,e as Nn}from"./dialog-nGTWjCEa.js";import{D as An,a as si,b as ii,c as ri,d as zm,e as Fm,f as Um}from"./drawer-DyPUsgdj.js";import{C as Id}from"./collection-search-B_zW9IS4.js";import{S as yt,u as Ae,g as En,i as lr,c as Hm,W as jt,a as Wm,b as Aa}from"./constants-aD7HJ6sY.js";import{u as Td,g as Ea,T as Rd,a as Jr,l as hn,b as Gn,c as Km}from"./tabs-DcOxSeRf.js";import{F as yi,a as gt,b as _t,c as Ht,d as xt,e as vt,f as qm}from"./form-DB-TdsHz.js";import{I as at}from"./input-COFLoOjb.js";import{i as Md,u as xr,r as Dd}from"./shell-layout-BsqL_vND.js";import{D as Qe,a as Qr,b as Zr,c as cs,d as ds,e as hs,f as Pd,g as Ld,h as xl}from"./dropdown-menu-Cc_jn9Z7.js";import{s as Os,i as Od}from"./XClose-ANREDbeo.js";import{t as Gm,i as Bd,n as $d,A as Qt,a as zd,b as Ia,c as Ym,d as Xm,e as Fd,f as Jm,g as Ta,h as er,j as Qm,k as Ra,s as Zm,l as ep,p as vr,m as br,o as tp,q as vl,r as bl,u as sp,v as yl,w as ip,x as Ma,y as Ud,z as Ao,B as Yn,C as Sl,D as rp,E as np,F as op,G as ap,H as Hd,I as Wd,J as Kd,K as qd,L as wl,M as lp,N as tr,O as cp,P as dp,Q as hp,R as Gd}from"./agent-icon-DKQKq---.js";import{n as Yd,a as Eo,i as up,b as fp,c as mp}from"./ZapSquare-Bz3HDhTc.js";import{i as Mt,t as cr}from"./ChevronDown-Jd-cYHC-.js";import{s as vi}from"./Star01-DZHrISf9.js";import{a as Io,t as Da}from"./Tool01-BscqkhhO.js";import{i as Xd}from"./Lock01-dBhVogWg.js";import{s as Dt}from"./Plus-BzxOIhxj.js";import{i as In,t as pp,a as gp,b as _p,c as Jd,d as xp,e as vp,f as Si,g as Qd}from"./XCircle-BFZeumzD.js";import{i as Es}from"./X-BuUY-erD.js";import{i as Bs}from"./AlertCircle-Bgzr6uRA.js";import{S as Ts,a as Rs,b as Nt,c as Ms,d as Ds}from"./select-Cn3ZnqjJ.js";import{i as Pa}from"./RefreshCcw01-BxULs6ec.js";import{T as Zd,a as un}from"./toggle-group-_HWF3GFc.js";import{u as La,a as eh}from"./use-ai-providers-DSLKay0D.js";import{m as Tn,g as bp,i as yp,a as th,M as sh,N as Sp}from"./select-model-BwE-9vfJ.js";import{S as wp,A as Vp,a as Cp,b as kp,c as jp,R as ih,d as Np,e as Ap}from"./accordion-DK_chPAh.js";import{r as rh,l as sr,u as Ep,g as Ip}from"./types-BGXCye_w.js";import{u as Rn,a as $t,b as Oa}from"./use-virtual-mcp-WT1ZdgMM.js";import{u as yr,a as Mn,b as Ba}from"./use-connection-MU3rXx28.js";import{p as Tp,q as Vl}from"./question-004-sINsf4GQ.js";import{g as Cl}from"./ai-providers-logos-CS4PCiqI.js";import{g as nh,s as oh}from"./connection-slug-eyAPH6o3.js";import{u as ah,a as lh,g as Rp,C as Xn}from"./connection-card-CD0fnfut.js";import{C as ch}from"./collection-tabs-tHg8euhu.js";import{g as dh}from"./constants-D7DNenhk.js";import{T as To}from"./textarea-CsnX9Ktr.js";import{n as en}from"./Container-DWaKXfYv.js";import{c as Mp,i as Lr,a as kl,E as Dp,p as Pp,b as Lp,d as Op}from"./connection-form-helpers-DVewXDLo.js";import{u as jl}from"./use-infinite-scroll-BUM8dH47.js";import{u as Bp}from"./useSuspenseInfiniteQuery-YePUpUV3.js";import{g as $p,e as zp,a as Fp}from"./extract-connection-data-Bx0uarS8.js";import{B as Nl}from"./badge-BJBM0LXp.js";import{i as $a}from"./ChevronRight-71i8ke8L.js";import{I as ps}from"./integration-icon-DKrcAAs9.js";import{S as wi}from"./skeleton-DOcx8lZU.js";import{u as Up}from"./use-organization-settings-CMC2yyUM.js";import{a as Dn}from"./Users03-DwNyb_q2.js";import{G as hh,u as Hp,I as fn,S as uh,L as fh,a as mh,b as ph}from"./github-repo-picker-CwCtQ7G3.js";import{u as Sr,a as gh}from"./use-navigate-to-agent-Bx0DB5DW.js";import{S as mn}from"./switch-ihM2hYRH.js";import{u as _h}from"./use-create-virtual-mcp-C-LLRhrB.js";import{i as Wp}from"./CheckCircle-88bls7UK.js";import{C as Kp,a as Al,b as El,c as qp,d as Gp,e as Yp,f as Xp}from"./command-Cpu7RbMv.js";import{P as zs,a as Fs,b as Us}from"./popover-Bo1-wNsY.js";import{u as ni,a as Jp}from"./use-mcp-tools-B5zpuics.js";import{E as Vi}from"./empty-state-DgThOXBB.js";import{u as Qp}from"./use-decopilot-events-fHBaJaln.js";import{i as Ci}from"./Zap-BxJkZzJb.js";import{i as xh,S as wr,a as Vr,b as es,u as Cr,c as Zt,d as Pt,e as vh,f as bh,g as Zp,h as yh,j as Sh,P as Jt,k as eg,l as tg,m as sg,n as ig,o as rg,p as ng}from"./index-DvgxnJsz.js";import{A as Il}from"./avatar-DcLXZkYK.js";import{n as og,a as ag,i as lg}from"./Sun-C8X8gjZW.js";import{a as kr}from"./Settings02-MyfUtBA4.js";import{i as cg}from"./Shield01-CMw4M4Ml.js";import{A as za,a as Fa,b as Ua,c as Ha,d as Wa,e as Ka,f as qa,g as wh}from"./alert-dialog-CtGXaT-Y.js";import"./index-CwstDhH7.js";import{u as dg,a as Tl,K as hg,P as ug,S as fg,v as mg,D as pg,c as gg,s as _g,b as xg,d as vg,C as bg,e as yg}from"./collection-search-DF-hPm66.js";import{u as Vh}from"./use-tasks-DofxyZR4.js";import{u as Sg}from"./use-status-sounds-DfhTS64d.js";import{T as wg,u as Ch}from"./tools-list-A0gJUqTb.js";import{u as Jn}from"./unwrap-tool-result-BYXdCQMg.js";import{C as Vg,a as Rl}from"./card-DqrPrhd5.js";import{L as ir}from"./label-BZVcstmy.js";import{i as tn}from"./Play-D7pqvkYq.js";import{s as Ro}from"./Trash01-DZpzvWVW.js";import{i as kh,a as Cg}from"./SearchMd-D6tCV38D.js";import{C as kg}from"./checkbox-Dplb_VaM.js";import{n as oi}from"./LinkExternal01-DB08YntP.js";import{V as jg}from"./view-mode-toggle-BvyYLass.js";import{U as Ng}from"./user-5oBDTi_W.js";import{u as jr,a as Ag,b as Eg,c as Ig,A as Tg,d as Rg}from"./automation-list-row-B_yW9vLo.js";import{S as Mg}from"./search-input-ClG6niuo.js";import"./use-collections-DvPoAlor.js";import"./use-copy-tC0v6ypy.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./DotsVertical-CjXyjLNU.js";import"./required-auth-layout-CP-yDaO3.js";import"./use-org-sso-BK-ft_ER.js";import"./ArrowNarrowLeft-ByrdB8Dd.js";import"./ChevronUp-D_szSdLd.js";import"./Palette-DuWQiO51.js";import"./User01-VHn0SqBP.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-Biq_9qgb.js";import"./useInfiniteQuery-Gkc0b2zi.js";import"./infiniteQueryObserver-B_9sKQsI.js";import"./collections-KKlyNHih.js";import"./index-CT9V-xpg.js";import"./create-sse-subscription-CxkOgzKf.js";function Dg(t,e){const s=bt(e);return Pg({filters:{...t,status:"pending"}},s).length}function Ml(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Pg(t={},e){const s=bt(e).getMutationCache(),i=j.useRef(t),n=j.useRef(null);return n.current===null&&(n.current=Ml(s,t)),j.useEffect(()=>{i.current=t}),j.useSyncExternalStore(j.useCallback(o=>s.subscribe(()=>{const a=wf(n.current,Ml(s,i.current));n.current!==a&&(n.current=a,Vf.schedule(o))}),[s]),()=>n.current,()=>n.current)}function Lg(t,e){const s=O.c(37),{org:i,locator:n}=_e();let o;s[0]!==i.id?(o={connectionId:yt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Ae(o),l=bt();let c;s[2]!==t||s[3]!==i.id?(c=Ze.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=ji(u);let f;s[11]!==a||s[12]!==e?(f=async v=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:v,virtual_mcp_id:e}}});if(y.isError){const C=y.content,S=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(S)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=f):f=s[13];let m;s[14]!==n||s[15]!==i.id||s[16]!==h||s[17]!==l?(m=()=>{l.invalidateQueries({predicate:v=>v.queryKey[1]===i.id&&v.queryKey[3]==="collection"&&v.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:Ze.tasksPrefix(n)}),h.refetch()},s[14]=n,s[15]=i.id,s[16]=h,s[17]=l,s[18]=m):m=s[18];let p;s[19]!==f||s[20]!==m?(p={mutationFn:f,onSuccess:m},s[19]=f,s[20]=m,s[21]=p):p=s[21];const g=Ni(p);let _,b;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},b=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=b):(_=s[26],b=s[27]),j.useEffect(_,b),h.isLoading){let v;return s[28]===Symbol.for("react.memo_cache_sentinel")?(v={status:"loading"},s[28]=v):v=s[28],v}if(h.isError){const v=h.error;let y;return s[29]!==v?(y={status:"error",error:v},s[29]=v,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let v;return s[31]!==h.data?(v={status:"ready",task:h.data},s[31]=h.data,s[32]=v):v=s[32],v}if(g.isPending||h.isSuccess&&!h.data){let v;return s[33]===Symbol.for("react.memo_cache_sentinel")?(v={status:"creating"},s[33]=v):v=s[33],v}if(g.isError){let v;return s[34]!==g.error?(v={status:"error",error:g.error},s[34]=g.error,s[35]=v):v=s[35],v}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function Og(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?pt().min(1,"Required"):pt();return as(e)}function Bg(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Ga(t){const e=O.c(65),{prompt:s,setPrompt:i,onSubmit:n}=t,o=j.useId();let a;if(e[0]!==s){const R=s?Og(s):as({});a=gr(R),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?Bg(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=Ai(u);let f;e[7]!==s?.arguments?(f=s?.arguments??[],e[7]=s?.arguments,e[8]=f):f=e[8];const m=f;let p;e[9]!==h||e[10]!==n||e[11]!==i?(p=async R=>{await n(R),i(null),h.reset()},e[9]=h,e[10]=n,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=R=>{R||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const b=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||kn(s.name,Ls(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let v;e[20]!==x?(v=r.jsx(qt,{children:r.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=v):v=e[21];let y;e[22]!==s.description?(y=s.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let V;e[24]!==y||e[25]!==v?(V=r.jsxs(Gt,{children:[v,y]}),e[24]=y,e[25]=v,e[26]=V):V=e[26];let C;e[27]!==h||e[28]!==g?(C=R=>{R.stopPropagation(),h.handleSubmit(g)(R)},e[27]=h,e[28]=g,e[29]=C):C=e[29];let S;if(e[30]!==m||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let R;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(R=P=>r.jsx(gt,{control:h.control,name:P.name,render:B=>{const{field:$}=B;return r.jsxs(_t,{children:[r.jsxs(Ht,{className:"text-xs",children:[P.name,P.required?null:r.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),r.jsx(xt,{children:r.jsx(at,{...$,value:$.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),r.jsx(vt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=R):R=e[36],S=m.map(R),e[30]=m,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=S}else S=e[33];let w;e[37]!==b?(w=()=>b(!1),e[37]=b,e[38]=w):w=e[38];let k;e[39]!==h.formState.isSubmitting||e[40]!==w?(k=r.jsx(oe,{type:"button",variant:"ghost",onClick:w,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=w,e[41]=k):k=e[41];const T=!h.formState.isValid||h.formState.isSubmitting;let M;e[42]!==h.formState.isSubmitting?(M=h.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(ar,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=M):M=e[43];let I;e[44]!==o||e[45]!==T||e[46]!==M?(I=r.jsx(oe,{type:"submit",form:o,disabled:T,children:M}),e[44]=o,e[45]=T,e[46]=M,e[47]=I):I=e[47];let E;e[48]!==k||e[49]!==I?(E=r.jsxs(Na,{children:[k,I]}),e[48]=k,e[49]=I,e[50]=E):E=e[50];let N;e[51]!==o||e[52]!==C||e[53]!==S||e[54]!==E?(N=r.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:C,children:[S,E]}),e[51]=o,e[52]=C,e[53]=S,e[54]=E,e[55]=N):N=e[55];let A;e[56]!==h||e[57]!==N?(A=r.jsx(yi,{...h,children:N}),e[56]=h,e[57]=N,e[58]=A):A=e[58];let D;e[59]!==V||e[60]!==A?(D=r.jsxs(Ot,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[V,A]}),e[59]=V,e[60]=A,e[61]=D):D=e[61];let L;return e[62]!==b||e[63]!==D?(L=r.jsx(Bt,{open:!0,onOpenChange:b,children:D}),e[62]=b,e[63]=D,e[64]=L):L=e[64],L}function $g(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 zg(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Dl=3,jh="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",Fg="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Nh(t){const e=O.c(46),{item:s,onSelect:i,isLoading:n,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const S=Ls(c._meta);d=c.title??kn(c.name,S),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let S;e[4]!==i||e[5]!==c?(S=()=>i(c),e[4]=i,e[5]=c,e[6]=S):S=e[6];const w=o||n,k=n&&"bg-accent/40",T=(o||n)&&"cursor-not-allowed opacity-50";let M;e[7]!==k||e[8]!==T?(M=Y(Fg,"hover:bg-accent/60 text-foreground",k,T),e[7]=k,e[8]=T,e[9]=M):M=e[9];let I;e[10]!==u?(I=r.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=I):I=e[11];let E;e[12]!==n?(E=n&&r.jsx(ar,{size:"xs"}),e[12]=n,e[13]=E):E=e[13];let N;e[14]!==I||e[15]!==E?(N=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[I,E]}),e[14]=I,e[15]=E,e[16]=N):N=e[16];let A;e[17]!==h?(A=h&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=A):A=e[18];let D;return e[19]!==N||e[20]!==A||e[21]!==S||e[22]!==w||e[23]!==M?(D=r.jsxs("button",{type:"button",onClick:S,disabled:w,className:M,children:[N,A]}),e[19]=N,e[20]=A,e[21]=S,e[22]=w,e[23]=M,e[24]=D):D=e[24],D}let f;e[25]!==i||e[26]!==c?(f=()=>i(c),e[25]=i,e[26]=c,e[27]=f):f=e[27];const m=o||n,p=n&&"bg-muted/50",g=(o||n)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=Y(jh,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let b;e[31]!==u?(b=r.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=b):b=e[32];let x;e[33]!==n?(x=n&&r.jsx(ar,{size:"xs"}),e[33]=n,e[34]=x):x=e[34];let v;e[35]!==f||e[36]!==m||e[37]!==_||e[38]!==b||e[39]!==x?(v=r.jsx(qe,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:f,disabled:m,className:_,children:[b,x]})}),e[35]=f,e[36]=m,e[37]=_,e[38]=b,e[39]=x,e[40]=v):v=e[40];const y=h??u;let V;e[41]!==y?(V=r.jsx(Ge,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=V):V=e[42];let C;return e[43]!==v||e[44]!==V?(C=r.jsxs(Ye,{delayDuration:400,children:[v,V]}),e[43]=v,e[44]=V,e[45]=C):C=e[45],C}function Ug(t){const e=O.c(41),{items:s,open:i,onOpenChange:n,onSelect:o,loadingPrompt:a}=t,[l,c]=j.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(w=>{const k=l.toLowerCase();return w.prompt.name.toLowerCase().includes(k)||(w.prompt.title??"").toLowerCase().includes(k)||(w.prompt.description??"").toLowerCase().includes(k)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,f=ms();let m;e[3]!==h.length||e[4]!==l?(m=h.length===0&&r.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==n||e[10]!==o){let w;e[12]!==d||e[13]!==a?.name||e[14]!==n||e[15]!==o?(w=k=>r.jsx(Nh,{item:k,variant:"card",onSelect:T=>{n(!1),o(T)},isLoading:a?.name===k.prompt.name,isDisabled:d&&a?.name!==k.prompt.name},k.prompt.name),e[12]=d,e[13]=a?.name,e[14]=n,e[15]=o,e[16]=w):w=e[16],p=h.map(w),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=n,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const _=g;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=w=>{w.key==="Escape"&&c("")},e[20]=b):b=e[20];let x;e[21]!==l?(x=r.jsx(Id,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:b}),e[21]=l,e[22]=x):x=e[22];const v=x;if(f){let w;e[23]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(An,{className:"sr-only",children:r.jsx(si,{children:"All prompts"})}),e[23]=w):w=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=k):k=e[24];let T;e[25]!==_||e[26]!==v?(T=r.jsxs(ii,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[w,k,v,_]}),e[25]=_,e[26]=v,e[27]=T):T=e[27];let M;return e[28]!==n||e[29]!==i||e[30]!==T?(M=r.jsx(bi,{delayDuration:400,children:r.jsx(ri,{open:i,onOpenChange:n,children:T})}),e[28]=n,e[29]=i,e[30]=T,e[31]=M):M=e[31],M}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Gt,{className:"sr-only",children:r.jsx(qt,{children:"All prompts"})}),e[32]=y):y=e[32];let V;e[33]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=V):V=e[33];let C;e[34]!==_||e[35]!==v?(C=r.jsxs(Ot,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,V,v,_]}),e[34]=_,e[35]=v,e[36]=C):C=e[36];let S;return e[37]!==n||e[38]!==i||e[39]!==C?(S=r.jsx(bi,{delayDuration:400,children:r.jsx(Bt,{open:i,onOpenChange:n,children:C})}),e[37]=n,e[38]=i,e[39]=C,e[40]=S):S=e[40],S}function Hg(t){const e=O.c(29),{items:s,onSelect:i,loadingPrompt:n,className:o}=t,[a,l]=j.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==n||e[2]!==i){const b=s.slice(0,Dl);let x;e[6]!==s?(x=s.slice(Dl),e[6]=s,e[7]=x):x=e[7],c=x,d=!!n;let v;e[8]!==d||e[9]!==n?.name||e[10]!==i?(v=y=>r.jsx(Nh,{item:y,onSelect:i,isLoading:n?.name===y.prompt.name,isDisabled:d&&n?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=n?.name,e[10]=i,e[11]=v):v=e[11],u=b.map(v),e[0]=s,e[1]=n,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let f;e[12]!==o?(f=Y("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&r.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:Y(jh,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==f||e[19]!==m?(p=r.jsxs("div",{className:f,children:[h,m]}),e[17]=h,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==n||e[23]!==a||e[24]!==i?(g=r.jsx(Ug,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:n}),e[21]=s,e[22]=n,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=r.jsxs(bi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function Wg(){return null}function Kg(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 qg(t){const e=O.c(30),{connectionId:s}=t,{sendMessage:i}=Ii(),{tiptapDocRef:n}=$s(),{org:o}=_e();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Ae(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Td(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let f;e[7]!==h?(f=h.map(Gg),e[7]=h,e[8]=f):f=e[8];const m=f;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=j.useReducer(Kg,p),[b,x]=j.useState(null);let v;e[10]!==l||e[11]!==i||e[12]!==n?(v=async(N,A)=>{if(!l){ue.error("MCP client not available"),_({type:"RESET"});return}try{const D=await Ea(l,N.name,A);_({type:"RESET"});const L=zg(n.current,{type:"paragraph",content:[pm({id:N.name,name:ka(N.name,Ls(N._meta)),metadata:D.messages,char:"/"})]});await i(L)}catch(D){console.error("[ice-breakers] Failed to fetch prompt:",D),ue.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=n,e[13]=v):v=e[13];const y=v;let V;e[14]!==y?(V=async N=>{if(N.arguments&&N.arguments.length>0){_({type:"SELECT_PROMPT",prompt:N}),x(N);return}_({type:"START_LOADING",prompt:N}),await y(N)},e[14]=y,e[15]=V):V=e[15];const C=V;let S;e[16]!==b||e[17]!==y?(S=async N=>{b&&(_({type:"START_LOADING",prompt:b,arguments:N}),x(null),await y(b,N))},e[16]=b,e[17]=y,e[18]=S):S=e[18];const w=S;if(m.length===0)return null;const k=g.stage==="loading"?g.prompt:null;let T;e[19]!==C||e[20]!==m||e[21]!==k?(T=r.jsx(Hg,{items:m,onSelect:C,loadingPrompt:k}),e[19]=C,e[20]=m,e[21]=k,e[22]=T):T=e[22];let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{x(null),_({type:"RESET"})},e[23]=M):M=e[23];let I;e[24]!==b||e[25]!==w?(I=r.jsx(Ga,{prompt:b,setPrompt:M,onSubmit:w}),e[24]=b,e[25]=w,e[26]=I):I=e[26];let E;return e[27]!==T||e[28]!==I?(E=r.jsxs(r.Fragment,{children:[T,I]}),e[27]=T,e[28]=I,e[29]=E):E=e[29],E}function Gg(t){return{prompt:t}}function Yg(t){const e=O.c(13),{className:s}=t,{selectedVirtualMcp:i}=$s(),{org:n}=_e();let o;e[0]!==n.id?(o=En(n.id),e[0]=n.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=Y("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Wg,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=r.jsx(qg,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let f;e[7]!==d||e[8]!==h?(f=r.jsx(ls,{fallback:null,children:r.jsx(j.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=r.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}function Ah(t){const e=O.c(21),{current:s,total:i,onPrev:n,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=Y("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Pa,{size:14}),e[2]=d):d=e[2];let u;e[3]!==n||e[4]!==a||e[5]!==c?(u=r.jsx("button",{type:"button",onClick:n,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=n,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let f;e[7]!==h||e[8]!==i?(f=r.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=f):f=e[9];const m=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=Y("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(In,{size:14}),e[12]=_):_=e[12];let b;e[13]!==o||e[14]!==g||e[15]!==m?(b=r.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=m,e[16]=b):b=e[16];let x;return e[17]!==b||e[18]!==u||e[19]!==f?(x=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,f,b]}),e[17]=b,e[18]=u,e[19]=f,e[20]=x):x=e[20],x}function pn(t){const e=O.c(18),{title:s,children:i,footerLeft:n,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=Y("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=r.jsx("div",{className:"flex items-center gap-2 p-4",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=r.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==n?(h=r.jsx("div",{children:n}),e[6]=n,e[7]=h):h=e[7];let f;e[8]!==o?(f=r.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==h||e[11]!==f?(m=r.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[h,f]})}),e[10]=h,e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==m?(p=r.jsxs("div",{className:c,children:[d,u,m]}),e[13]=c,e[14]=d,e[15]=u,e[16]=m,e[17]=p):p=e[17],p}const Xg="User denied this tool call, give other alternatives.",Jg=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function Qg(t){const e=O.c(9),{onYolo:s}=t,[i,n]=ei();let o;e[0]!==s||e[1]!==i||e[2]!==n?(o=u=>{const h=u;n({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=n,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ms,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:e_,children:r.jsx(Ds,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Ts,{children:Jg.map(Zg)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=r.jsxs(Rs,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function Zg(t){return r.jsx(Nt,{value:t.value,children:t.label},t.value)}function e_(t){return t.stopPropagation()}function t_(t){const e=O.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.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 n;return e[3]!==i?(n=r.jsx("div",{className:"px-4",children:r.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]=n):n=e[4],n}function s_(t){const e=O.c(42),{approvals:s,onRespond:i}=t,[n,o]=j.useState(0),a=Math.min(n,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,Xg)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let f;e[6]!==s||e[7]!==i?(f=()=>{for(const E of s)i(E.approvalId,!0)},e[6]=s,e[7]=i,e[8]=f):f=e[8];const m=f;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const b=_;let x;e[14]!==m?(x=r.jsx(Qg,{onYolo:m}),e[14]=m,e[15]=x):x=e[15];let v;e[16]!==s.length||e[17]!==b||e[18]!==g||e[19]!==a?(v=r.jsx(Ah,{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 y;e[21]!==x||e[22]!==v?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[x,v]}),e[21]=x,e[22]=v,e[23]=y):y=e[23];const V=y;let C;e[24]!==d?(C=r.jsx(oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:d,children:"Deny"}),e[24]=d,e[25]=C):C=e[25];let S;e[26]!==s.length||e[27]!==m?(S=s.length>1&&r.jsx(oe,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:m,children:"Accept All"}),e[26]=s.length,e[27]=m,e[28]=S):S=e[28];let w;e[29]!==h?(w=r.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=w):w=e[30];let k;e[31]!==S||e[32]!==w||e[33]!==C?(k=r.jsxs(r.Fragment,{children:[C,S,w]}),e[31]=S,e[32]=w,e[33]=C,e[34]=k):k=e[34];const T=k;let M;e[35]!==l.input?(M=r.jsx(t_,{input:l.input}),e[35]=l.input,e[36]=M):M=e[36];let I;return e[37]!==l.friendlyName||e[38]!==V||e[39]!==T||e[40]!==M?(I=r.jsx(pn,{title:l.friendlyName,footerLeft:V,footerRight:T,children:M}),e[37]=l.friendlyName,e[38]=V,e[39]=T,e[40]=M,e[41]=I):I=e[41],I}function i_(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(Gm,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function r_(t){const e=O.c(4),{approvals:s,isStreaming:i,onRespond:n}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(i_,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==n?(o=r.jsx(s_,{approvals:s,onRespond:n}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function n_(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:ko(gm(i)),input:s.input})}return e}function o_(t){const e=O.c(15),{plan:s,onApprove:i,onDismiss:n}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==n?(l=r.jsx(oe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:n,children:"Keep iterating"}),e[3]=n,e[4]=l):l=e[4];let c;e[5]!==a?(c=r.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=r.jsxs(r.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(_m,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let f;return e[12]!==u||e[13]!==h?(f=r.jsx(pn,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=f):f=e[14],f}function a_(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(Mt,{className:"size-5 text-purple-500 shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function l_(t){const e=O.c(7),{plans:s,isStreaming:i,onApprove:n,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(a_,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==n||e[5]!==o?(c=r.jsx(o_,{plan:l,onApprove:n,onDismiss:o}),e[3]=l,e[4]=n,e[5]=o,e[6]=c):c=e[6],c}function c_(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 Pl=as({response:pt().min(1,"Response is required")}),d_=as({response:pt().min(1,"Please select or enter an option")}),h_=as({response:Cf(["yes","no"])});function u_(t){switch(t.type){case"text":return Pl;case"choice":return d_;case"confirm":return h_;default:return Pl}}function f_(t){const e={};for(const s of t)e[s.toolCallId]=u_(s.input);return as(e)}function m_(t){const e=O.c(6),{control:s,name:i,placeholder:n}=t;let o;e[0]!==n?(o=l=>{const{field:c}=l;return r.jsxs(_t,{children:[r.jsx(xt,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(Bd,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...c,type:"text",placeholder:n||"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"})]})})}),r.jsx(vt,{})]})},e[0]=n,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=r.jsx(gt,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Eh(t,e){const s=O.c(4);let i,n;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},n=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=n):(i=s[2],n=s[3]),j.useEffect(i,n)}function p_(t){const e=O.c(9),{control:s,name:i,options:n}=t,[o,a]=j.useState(!1),l=j.useRef(null),c=j.useRef(null);let d;if(e[0]!==n?(d=f=>{c.current?.onChange(n[f]??""),a(!1)},e[0]=n,e[1]=d):d=e[1],Eh(n.length,d),n.length===0)return null;let u;e[2]!==o||e[3]!==n?(u=f=>{const{field:m}=f;c.current=m;const p=o||!!m.value&&!n.includes(m.value);return r.jsxs(_t,{children:[r.jsx(xt,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[n.map((g,_)=>{const b=m.value===g;return r.jsxs("button",{type:"button",onClick:()=>{m.onChange(g??""),a(!1)},className:Y("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:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",b?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),r.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),r.jsxs("div",{className:Y("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),n.includes(m.value)&&m.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(Bd,{size:16,className:"text-muted-foreground"})}),p?r.jsx("input",{ref:l,type:"text",value:m.value,onChange:g=>m.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):r.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),r.jsx(vt,{})]})},e[2]=o,e[3]=n,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=r.jsx(gt,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function g_(t){const e=O.c(6),{control:s,name:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=["yes","no"],e[0]=n):n=e[0];const o=n,a=j.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],Eh(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,r.jsxs(_t,{children:[r.jsx(xt,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=h.value===f;return r.jsxs("button",{type:"button",onClick:()=>h.onChange(f),className:Y("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),r.jsx(vt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=r.jsx(gt,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Ll(t){const e=O.c(13),{input:s,control:i,name:n}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==n?(o=r.jsx(m_,{control:i,name:n,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=n,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==i||e[7]!==n||e[8]!==a?(l=r.jsx(p_,{control:i,name:n,options:a}),e[6]=i,e[7]=n,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==n?(o=r.jsx(g_,{control:i,name:n}),e[10]=i,e[11]=n,e[12]=o):o=e[12],o}default:return null}}function __({parts:t,onSubmit:e}){const[s,i]=j.useState(t[0]?.toolCallId??""),n=f_(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=Ai({resolver:gr(n),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const v of t){const y=x[v.toolCallId]?.response;y&&e(v,y)}},h=x=>t.find(v=>!x[v.toolCallId]?.response&&v.toolCallId!==s)??null,f=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},m=()=>{o.setValue(`${s}.response`,"user has skip this question"),f()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=r.jsxs(r.Fragment,{children:[r.jsx(oe,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7",children:"Skip"}),r.jsx(oe,{type:"button",size:"sm",disabled:!c,onClick:f,className:Y("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),b=r.jsx(Ah,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?r.jsx(yi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(pn,{title:x.input?.prompt??"Question",footerRight:_,children:r.jsx(Ll,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return r.jsx(yi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(Rd,{value:s,onValueChange:i,children:t.map(x=>r.jsx(Jr,{value:x.toolCallId,className:"mt-0",children:r.jsx(pn,{title:x.input?.prompt??"Question",footerLeft:b,footerRight:_,children:r.jsx(Ll,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function x_(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(pp,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Ih(t){const e=O.c(6),{userAskParts:s,isStreaming:i,onSubmit:n}=t;let o;e[0]!==s?(o=s.filter(v_),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(x_,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==n||e[4]!==a?(l=r.jsx(__,{parts:a,onSubmit:n}),e[3]=n,e[4]=a,e[5]=l):l=e[5],l}function v_(t){return t.state==="input-available"}const Ol=new Map;function Pn(){const{org:t}=_e(),e=Ae({connectionId:yt,orgId:t.id}),s=La(),i=s.find(_=>_.providerId==="deco"),{data:n,isLoading:o,refetch:a,isFetching:l}=ji({queryKey:Ze.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=n?.balanceCents??null,d=c!=null?c/100:null,u=j.useRef(new Map);if(c!=null){const _=Ol.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&re("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Ol.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,f=c!=null&&c>0,m=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:f,isZeroBalance:m,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function b_(t){return t?t.message.startsWith("[CREDITS]"):!1}const y_={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"}]},S_=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Th(t){const e=O.c(43),{onDismiss:s}=t,{org:i}=_e(),n=Oe(),{decoKeyId:o}=Pn();let a;e[0]!==i.id?(a={connectionId:yt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Ae(a),[c,d]=j.useState(""),[u,h]=j.useState(!1),[f,m]=j.useState("usd"),p=f==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{re("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),j.useEffect(g,_);let b;e[5]!==l||e[6]!==f?(b=async R=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:R,currency:f}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=f,e[7]=b):b=e[7];let x;e[8]!==s?(x=R=>{R&&window.open(R,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let v;e[10]!==b||e[11]!==x?(v={mutationFn:b,onSuccess:x,onError:C_},e[10]=b,e[11]=x,e[12]=v):v=e[12];const{mutate:y,isPending:V}=Ni(v),C=parseFloat(c),S=!isNaN(C)&&C>=1;let w;e[13]!==s?(w=R=>!R&&s?.(),e[13]=s,e[14]=w):w=e[14];let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[15]=k):k=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:k.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=T):T=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[T,r.jsxs(Gt,{className:"relative gap-4",children:[r.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"}),r.jsxs("div",{children:[r.jsx(qt,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),r.jsx(Nn,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[17]=M):M=e[17];let I;e[18]!==f||e[19]!==p||e[20]!==c||e[21]!==C||e[22]!==o||e[23]!==S||e[24]!==V||e[25]!==u||e[26]!==y?(I=o&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(Zd,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:R=>{R&&m(R)},children:[r.jsx(un,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(un,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:y_[f].map(R=>{const{dollars:P,label:B}=R;return r.jsxs("button",{type:"button",disabled:V,onClick:()=>{re("credits_topup_clicked",{amount_cents:P*100,currency:f,tier_label:B,source:"exhausted_banner"}),y(P*100)},className:Y("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:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:B})]},P)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(at,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:R=>d(R.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(oe,{className:"h-10",disabled:!S||V,onClick:()=>{re("credits_topup_clicked",{amount_cents:Math.round(C*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(C*100))},children:V?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:S_.map(w_)})]}),e[18]=f,e[19]=p,e[20]=c,e[21]=C,e[22]=o,e[23]=S,e[24]=V,e[25]=u,e[26]=y,e[27]=I):I=e[27];let E;e[28]!==s?(E=r.jsx(oe,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=E):E=e[29];let N;e[30]!==n||e[31]!==s||e[32]!==i.slug?(N=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{n({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=n,e[31]=s,e[32]=i.slug,e[33]=N):N=e[33];let A;e[34]!==E||e[35]!==N?(A=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[E,N]}),e[34]=E,e[35]=N,e[36]=A):A=e[36];let D;e[37]!==I||e[38]!==A?(D=r.jsxs(Ot,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:V_,children:[M,I,A]}),e[37]=I,e[38]=A,e[39]=D):D=e[39];let L;return e[40]!==D||e[41]!==w?(L=r.jsx(Bt,{open:!0,onOpenChange:w,children:D}),e[40]=D,e[41]=w,e[42]=L):L=e[42],L}function w_(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(Mt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function V_(t){return t.preventDefault()}function C_(t){ue.error(`Top-up failed: ${t.message}`)}const k_={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 gn(t){const e=O.c(32),{variant:s,onDismiss:i}=t,n=s==="error",o=n?"Error occurred":"Response incomplete",a=n?t.error.message:k_[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=n?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=n?"text-destructive":"text-amber-600 dark:text-amber-500",d=n?Bs:wa;let u;e[0]!==l?(u=Y("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=Y("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==d?(f=r.jsx(d,{size:16}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==f?(m=r.jsx("div",{className:h,children:f}),e[6]=h,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==c?(p=Y("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=r.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=r.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let b;e[16]!==n||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(b=r.jsx("div",{className:"flex gap-2",children:n?r.jsxs(r.Fragment,{children:[r.jsx(oe,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),r.jsx(oe,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):r.jsx(oe,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=n,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=b):b=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==b?(x=r.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,b]}),e[20]=g,e[21]=_,e[22]=b,e[23]=x):x=e[23];let v;e[24]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Es,{size:14}),e[24]=v):v=e[24];let y;e[25]!==i?(y=r.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]=y):y=e[26];let V;return e[27]!==u||e[28]!==y||e[29]!==m||e[30]!==x?(V=r.jsx("div",{className:"px-0.5",children:r.jsxs("div",{className:u,children:[m,x,y]})}),e[27]=u,e[28]=y,e[29]=m,e[30]=x,e[31]=V):V=e[31],V}function Ln(){const t=O.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:n,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Ii(),[h,f]=ei(),{virtualMcpId:m,createTaskWithMessage:p}=Lt();let g,_,b,x;if(t[0]!==o){const A=o.at(-1);x=A?.role==="assistant"?A.parts.filter(A_):null,g=x?.filter(N_)?.length,_=A?.role==="assistant"?c_(A.parts):[],b=A?.role==="assistant"?n_(A.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=b,t[4]=x}else g=t[1],_=t[2],b=t[3],x=t[4];const v=b;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const D={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(D)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const V=y;let C;t[8]!==u?(C=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=C):C=t[9];const S=C;let w;t[10]!==c?(w=(A,D)=>{c({tool:"user_ask",toolCallId:A.toolCallId,output:{response:D}})},t[10]=c,t[11]=w):w=t[11];const k=w;let T;t[12]!==p||t[13]!==h||t[14]!==f||t[15]!==m?(T=A=>{f({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:m,message:{parts:[{type:"text",text:`Implement this plan:
|
|
3
3
|
|
|
4
4
|
${A}`}]}})},t[12]=p,t[13]=h,t[14]=f,t[15]=m,t[16]=T):T=t[16];const M=T,I=j_;let E;t[17]!==d?(E=(A,D,L)=>{d({id:A,approved:D,...L?{reason:L}:{}})},t[17]=d,t[18]=E):E=t[18];const N=E;if(g){let A;return t[19]!==k||t[20]!==a||t[21]!==x?(A=r.jsx("div",{className:"absolute bottom-full left-0 right-0",children:r.jsx(Ih,{userAskParts:x,isStreaming:a,onSubmit:k})}),t[19]=k,t[20]=a,t[21]=x,t[22]=A):A=t[22],A}if(_.length>0){let A;return t[23]!==M||t[24]!==a||t[25]!==_?(A=r.jsx("div",{className:"absolute bottom-full left-0 right-0",children:r.jsx(l_,{plans:_,isStreaming:a,onApprove:M,onDismiss:I})}),t[23]=M,t[24]=a,t[25]=_,t[26]=A):A=t[26],A}if(v.length>0||a&&l){let A;return t[27]!==N||t[28]!==a||t[29]!==v?(A=r.jsx("div",{className:"absolute bottom-full left-0 right-0",children:r.jsx(r_,{approvals:v,isStreaming:a,onRespond:N})}),t[27]=N,t[28]=a,t[29]=v,t[30]=A):A=t[30],A}if(!a&&e){if(b_(e)){let D;return t[31]!==s?(D=r.jsx(Th,{onDismiss:s}),t[31]=s,t[32]=D):D=t[32],D}let A;return t[33]!==s||t[34]!==e||t[35]!==V?(A=r.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:r.jsx(gn,{variant:"error",error:e,onDismiss:s,onFixInChat:V})}),t[33]=s,t[34]=e,t[35]=V,t[36]=A):A=t[36],A}if(!a&&i&&i!=="stop"&&!l){let A;return t[37]!==n||t[38]!==i||t[39]!==S?(A=r.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:r.jsx(gn,{variant:"warning",finishReason:i,onDismiss:n,onContinue:S})}),t[37]=n,t[38]=i,t[39]=S,t[40]=A):A=t[40],A}return null}function j_(){document.querySelector("[data-chat-input]")?.focus()}function N_(t){return t.state!=="output-available"}function A_(t){return t.type==="tool-user_ask"}Ln.Error=function(e){return r.jsx(gn,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};Ln.Warning=function(e){return r.jsx(gn,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};Ln.UserAskQuestion=Ih;async function Ya(t,e,s,i,n){if(!Tn(e)){ue.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!yp(o,e)){const l=th(e),c=e?.title??"This model";n?n({fileName:s.name,modelName:c,accepted:l}):ue.error(`"${s.name}" can't be attached`,{description:`${c} accepts ${l}. PowerPoint, Word, and Excel files aren't supported yet.`});return}const a=10*1024*1024;if(s.size>a){ue.error(`File "${s.name}" exceeds 10MB limit`);return}try{const l=new FileReader,c=new Promise((h,f)=>{l.onload=()=>{const m=l.result;if(typeof m!="string"){f(new Error("Failed to read file as data URL"));return}const p=m.includes(",")?m.split(",")[1]??m:m;h(p)},l.onerror=f});l.readAsDataURL(s);const d=await c,u={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:d};xm(t,{from:i,to:i},u)}catch(l){console.error("Failed to process file:",l),ue.error(`Failed to load file "${s.name}"`)}}function E_(t){const e=O.c(8),{editor:s,selectedModel:i,onUnsupportedFile:n}=t,o=j.useRef(T_);let a,l;e[0]!==s||e[1]!==n||e[2]!==i?(a=()=>{o.current=async(u,h)=>{await Ya(s,i,u,h,n)}},l=[s,i,n],e[0]=s,e[1]=n,e[2]=i,e[3]=a,e[4]=l):(a=e[3],l=e[4]),j.useEffect(a,l);let c,d;return e[5]!==s?(c=()=>{if(s?.isDestroyed)return;const u=new No("fileDropHandler");s.state.plugins.find(m=>m.spec.key===u)&&s.unregisterPlugin(u);const f=new Dm({key:u,props:{handleDrop:(m,p,g,_)=>{if(_)return!1;const b=p.dataTransfer?.files;if(!b||b.length===0)return!1;p.preventDefault();const x=m.posAtCoords({left:p.clientX,top:p.clientY});if(!x)return!1;const v=Array.from(b),y=x.pos;for(const V of v)o.current?.(V,y);return!0},handlePaste:(m,p)=>{const g=p.clipboardData?.items;if(!g)return!1;const _=Array.from(g).filter(I_);if(_.length===0)return!1;p.preventDefault();const{from:b}=m.state.selection;for(const x of _){const v=x.getAsFile();v&&o.current?.(v,b)}return!0}}});return s.registerPlugin(f),()=>{s?.isDestroyed||s.unregisterPlugin(u)}},d=[s],e[5]=s,e[6]=c,e[7]=d):(c=e[6],d=e[7]),j.useEffect(c,d),null}function I_(t){return t.kind==="file"}function T_(){return Promise.resolve()}function R_(t){const e=O.c(24),{selectedModel:s,isStreaming:i,icon:n,onUnsupportedFile:o}=t,{editor:a}=jn(),l=j.useRef(null);let c;e[0]!==s?(c=Tn(s),e[0]=s,e[1]=c):c=e[1];const d=c;let u;e[2]!==a||e[3]!==o||e[4]!==s?(u=async V=>{const C=V.target.files;if(!C||C.length===0||!a)return;const S=Array.from(C),{from:w}=a.state.selection,k=w;for(const T of S)await Ya(a,s,T,k,o);l.current&&(l.current.value="")},e[2]=a,e[3]=o,e[4]=s,e[5]=u):u=e[5];const h=u;if(!a||!d)return null;let f;e[6]!==s?(f=bp(s),e[6]=s,e[7]=f):f=e[7];let m;e[8]!==h||e[9]!==i||e[10]!==f?(m=r.jsx("input",{ref:l,type:"file",multiple:!0,accept:f,className:"hidden",onChange:h,disabled:i}),e[8]=h,e[9]=i,e[10]=f,e[11]=m):m=e[11];const p=i||!d;let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=()=>l.current?.click(),e[12]=g):g=e[12];let _;e[13]!==n?(_=n??r.jsx($d,{size:16}),e[13]=n,e[14]=_):_=e[14];let b;e[15]!==p||e[16]!==_?(b=r.jsx(qe,{asChild:!0,children:r.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground/75",disabled:p,onClick:g,children:_})}),e[15]=p,e[16]=_,e[17]=b):b=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Ge,{side:"top",children:"Add file"}),e[18]=x):x=e[18];let v;e[19]!==b?(v=r.jsxs(Ye,{children:[b,x]}),e[19]=b,e[20]=v):v=e[20];let y;return e[21]!==v||e[22]!==m?(y=r.jsxs(r.Fragment,{children:[m,v]}),e[21]=v,e[22]=m,e[23]=y):y=e[23],y}const M_=["PowerPoint (.pptx)","Word documents (.docx)","Excel spreadsheets (.xlsx)"];function D_(t){const e=O.c(29),{info:s,onClose:i}=t,n=s!==null;let o;e[0]!==i?(o=S=>!S&&i(),e[0]=i,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:a.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=l):l=e[3];let c,d;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:r.jsx(wa,{size:18})}),d=r.jsx(qt,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=c,e[5]=d):(c=e[4],d=e[5]);const u=s?.fileName;let h;e[6]!==u?(h=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[l,r.jsxs(Gt,{className:"relative gap-4",children:[c,r.jsxs("div",{children:[d,r.jsxs(Nn,{className:"mt-1.5 text-sm leading-relaxed",children:[r.jsxs("span",{className:"font-medium text-foreground",children:["“",u,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=u,e[7]=h):h=e[7];const f=s?.modelName;let m;e[8]!==f?(m=r.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[f," accepts"]}),e[8]=f,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx($d,{size:14,className:"text-muted-foreground"}),e[10]=p):p=e[10];const g=s?.accepted;let _;e[11]!==g?(_=r.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[p,r.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=_):_=e[12];let b;e[13]!==m||e[14]!==_?(b=r.jsxs("div",{className:"rounded-xl border border-border p-4",children:[m,_]}),e[13]=m,e[14]=_,e[15]=b):b=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsxs("div",{className:"rounded-xl bg-muted/25 border border-border/50 p-4 space-y-2",children:[r.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Not supported yet"}),M_.map(P_)]}),e[16]=x):x=e[16];let v;e[17]!==b?(v=r.jsxs("div",{className:"px-8 pt-3 pb-6 space-y-3",children:[b,x]}),e[17]=b,e[18]=v):v=e[18];let y;e[19]!==i?(y=r.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:r.jsx(oe,{onClick:i,children:"Got it"})}),e[19]=i,e[20]=y):y=e[20];let V;e[21]!==v||e[22]!==y||e[23]!==h?(V=r.jsxs(Ot,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:L_,children:[h,v,y]}),e[21]=v,e[22]=y,e[23]=h,e[24]=V):V=e[24];let C;return e[25]!==n||e[26]!==V||e[27]!==o?(C=r.jsx(Bt,{open:n,onOpenChange:o,children:V}),e[25]=n,e[26]=V,e[27]=o,e[28]=C):C=e[28],C}function P_(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-muted shrink-0",children:r.jsx(Es,{size:10,className:"text-muted-foreground"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function L_(t){return t.preventDefault()}function O_(){const t=O.c(3),[e,s]=j.useState(null);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>s(null),t[0]=i):i=t[0];let n;return t[1]!==e?(n={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:i},t[1]=e,t[2]=n):n=t[2],n}var B_=Pm;var $_=["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] *)"],Mo=$_.join(","),Rh=typeof Element>"u",dr=Rh?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,_n=!Rh&&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},xn=function(e,s){var i;s===void 0&&(s=!0);var n=e==null||(i=e.getAttribute)===null||i===void 0?void 0:i.call(e,"inert"),o=n===""||n==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):xn(e.parentNode));return a},z_=function(e){var s,i=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return i===""||i==="true"},F_=function(e,s,i){if(xn(e))return[];var n=Array.prototype.slice.apply(e.querySelectorAll(Mo));return s&&dr.call(e,Mo)&&n.unshift(e),n=n.filter(i),n},Do=function(e,s,i){for(var n=[],o=Array.from(e);o.length;){var a=o.shift();if(!xn(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=Do(c,!0,i);i.flatten?n.push.apply(n,d):n.push({scopeParent:a,candidates:d})}else{var u=dr.call(a,Mo);u&&i.filter(a)&&(s||!e.includes(a))&&n.push(a);var h=a.shadowRoot||typeof i.getShadowRoot=="function"&&i.getShadowRoot(a),f=!xn(h,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(h&&f){var m=Do(h===!0?a.children:h.children,!0,i);i.flatten?n.push.apply(n,m):n.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return n},Mh=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Dh=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||z_(e))&&!Mh(e)?0:e.tabIndex},U_=function(e,s){var i=Dh(e);return i<0&&s&&!Mh(e)?0:i},H_=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},Ph=function(e){return e.tagName==="INPUT"},W_=function(e){return Ph(e)&&e.type==="hidden"},K_=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(i){return i.tagName==="SUMMARY"});return s},q_=function(e,s){for(var i=0;i<e.length;i++)if(e[i].checked&&e[i].form===s)return e[i]},G_=function(e){if(!e.name)return!0;var s=e.form||_n(e),i=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},n;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")n=i(window.CSS.escape(e.name));else try{n=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=q_(n,e.form);return!o||o===e},Y_=function(e){return Ph(e)&&e.type==="radio"},X_=function(e){return Y_(e)&&!G_(e)},J_=function(e){var s,i=e&&_n(e),n=(s=i)===null||s===void 0?void 0:s.host,o=!1;if(i&&i!==e){var a,l,c;for(o=!!((a=n)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(n)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&n;){var d,u,h;i=_n(n),n=(d=i)===null||d===void 0?void 0:d.host,o=!!((u=n)!==null&&u!==void 0&&(h=u.ownerDocument)!==null&&h!==void 0&&h.contains(n))}}return o},Bl=function(e){var s=e.getBoundingClientRect(),i=s.width,n=s.height;return i===0&&n===0},Q_=function(e,s){var i=s.displayCheck,n=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=dr.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(dr.call(l,"details:not([open]) *"))return!0;if(!i||i==="full"||i==="full-native"||i==="legacy-full"){if(typeof n=="function"){for(var c=e;e;){var d=e.parentElement,u=_n(e);if(d&&!d.shadowRoot&&n(d)===!0)return Bl(e);e.assignedSlot?e=e.assignedSlot:!d&&u!==e.ownerDocument?e=u.host:e=d}e=c}if(J_(e))return!e.getClientRects().length;if(i!=="legacy-full")return!0}else if(i==="non-zero-area")return Bl(e);return!1},Z_=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 n=s.children.item(i);if(n.tagName==="LEGEND")return dr.call(s,"fieldset[disabled] *")?!0:!n.contains(e)}return!0}s=s.parentElement}return!1},ex=function(e,s){return!(s.disabled||W_(s)||Q_(s,e)||K_(s)||Z_(s))},$l=function(e,s){return!(X_(s)||Dh(s)<0||!ex(e,s))},tx=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},Lh=function(e){var s=[],i=[];return e.forEach(function(n,o){var a=!!n.scopeParent,l=a?n.scopeParent:n,c=U_(l,a),d=a?Lh(n.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):i.push({documentOrder:o,tabIndex:c,item:n,isScope:a,content:d})}),i.sort(H_).reduce(function(n,o){return o.isScope?n.push.apply(n,o.content):n.push(o.content),n},[]).concat(s)},Oh=function(e,s){s=s||{};var i;return s.getShadowRoot?i=Do([e],s.includeContainer,{filter:$l.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:tx}):i=F_(e,s.includeContainer,$l.bind(null,s)),Lh(i)};function sx(){return/apple/i.test(navigator.vendor)}const zl="data-floating-ui-focusable";function ix(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 Po(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&kf(s)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function Oi(t){return"composedPath"in t?t.composedPath()[0]:t.target}function Qn(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 rx(t){return t.matches("html,body")}function hr(t){return t?.ownerDocument||document}function nx(t){return t?t.hasAttribute(zl)?t:t.querySelector("["+zl+"]")||t:null}function sn(t,e,s){return s===void 0&&(s=!0),t.filter(n=>{var o;return n.parentId===e&&(!s||((o=n.context)==null?void 0:o.open))}).flatMap(n=>[n,...sn(t,n.id,s)])}function ox(t){return"nativeEvent"in t}var ax=typeof document<"u",lx=function(){},Xs=ax?j.useLayoutEffect:lx;const cx={...vd},dx=cx.useInsertionEffect,hx=dx||(t=>t());function gi(t){const e=j.useRef(()=>{});return hx(()=>{e.current=t}),j.useCallback(function(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];return e.current==null?void 0:e.current(...i)},[])}const Bh=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function $h(t,e){const s=Oh(t,Bh()),i=s.length;if(i===0)return;const n=ix(hr(t)),o=s.indexOf(n),a=o===-1?e===1?0:i-1:o+e;return s[a]}function ux(t){return $h(hr(t).body,1)||t}function fx(t){return $h(hr(t).body,-1)||t}function Zn(t,e){const s=e||t.currentTarget,i=t.relatedTarget;return!i||!Po(s,i)}function mx(t){Oh(t,Bh()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function Fl(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 px="data-floating-ui-focusable",Ul="active",Hl="selected",gx={...vd};let Wl=!1,_x=0;const Kl=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+_x++;function xx(){const[t,e]=j.useState(()=>Wl?Kl():void 0);return Xs(()=>{t==null&&e(Kl())},[]),j.useEffect(()=>{Wl=!0},[]),t}const vx=gx.useId,Xa=vx||xx;function bx(){const t=new Map;return{emit(e,s){var i;(i=t.get(e))==null||i.forEach(n=>n(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 yx=j.createContext(null),Sx=j.createContext(null),zh=()=>{var t;return((t=j.useContext(yx))==null?void 0:t.id)||null},Fh=()=>j.useContext(Sx);function Ja(t){return"data-floating-ui-"+t}const wx={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},ql=j.forwardRef(function(e,s){const[i,n]=j.useState();Xs(()=>{sx()&&n("button")},[]);const o={ref:s,tabIndex:0,role:i,"aria-hidden":i?void 0:!0,[Ja("focus-guard")]:"",style:wx};return r.jsx("span",{...e,...o})}),Vx={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Uh=j.createContext(null),Gl=Ja("portal");function Cx(t){t===void 0&&(t={});const{id:e,root:s}=t,i=Xa(),n=jx(),[o,a]=j.useState(null),l=j.useRef(null);return Xs(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),Xs(()=>{if(!i||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=i,d.setAttribute(Gl,""),c.appendChild(d),l.current=d,a(d)},[e,i]),Xs(()=>{if(s===null||!i||l.current)return;let c=s||n?.portalNode;c&&!Tf(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const u=document.createElement("div");u.id=i,u.setAttribute(Gl,""),c=d||c,c.appendChild(u),l.current=u,a(u)},[e,s,i,n]),o}function kx(t){const{children:e,id:s,root:i,preserveTabOrder:n=!0}=t,o=Cx({id:s,root:i}),[a,l]=j.useState(null),c=j.useRef(null),d=j.useRef(null),u=j.useRef(null),h=j.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&n&&!!(i||o);return j.useEffect(()=>{if(!o||!n||f)return;function g(_){o&&Zn(_)&&(_.type==="focusin"?Fl:mx)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,n,f]),j.useEffect(()=>{o&&(m||Fl(o))},[m,o]),r.jsxs(Uh.Provider,{value:j.useMemo(()=>({preserveTabOrder:n,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:u,afterInsideRef:h,portalNode:o,setFocusManagerState:l}),[n,o]),children:[p&&o&&r.jsx(ql,{"data-type":"outside",ref:c,onFocus:g=>{if(Zn(g,o)){var _;(_=u.current)==null||_.focus()}else{const b=a?a.domReference:null,x=fx(b);x?.focus()}}}),p&&o&&r.jsx("span",{"aria-owns":o.id,style:Vx}),o&&Ei.createPortal(e,o),p&&o&&r.jsx(ql,{"data-type":"outside",ref:d,onFocus:g=>{if(Zn(g,o)){var _;(_=h.current)==null||_.focus()}else{const b=a?a.domReference:null,x=ux(b);x?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const jx=()=>j.useContext(Uh),Nx={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Ax={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Yl=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 Ex(t,e){e===void 0&&(e={});const{open:s,onOpenChange:i,elements:n,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:u=!1,referencePressEvent:h="pointerdown",ancestorScroll:f=!1,bubbles:m,capture:p}=e,g=Fh(),_=gi(typeof c=="function"?c:()=>!1),b=typeof c=="function"?_:c,x=j.useRef(!1),{escapeKey:v,outsidePress:y}=Yl(m),{escapeKey:V,outsidePress:C}=Yl(p),S=j.useRef(!1),w=gi(N=>{var A;if(!s||!a||!l||N.key!=="Escape"||S.current)return;const D=(A=o.current.floatingContext)==null?void 0:A.nodeId,L=g?sn(g.nodesRef.current,D):[];if(!v&&(N.stopPropagation(),L.length>0)){let R=!0;if(L.forEach(P=>{var B;if((B=P.context)!=null&&B.open&&!P.context.dataRef.current.__escapeKeyBubbles){R=!1;return}}),!R)return}i(!1,ox(N)?N.nativeEvent:N,"escape-key")}),k=gi(N=>{var A;const D=()=>{var L;w(N),(L=Oi(N))==null||L.removeEventListener("keydown",D)};(A=Oi(N))==null||A.addEventListener("keydown",D)}),T=gi(N=>{var A;const D=o.current.insideReactTree;o.current.insideReactTree=!1;const L=x.current;if(x.current=!1,d==="click"&&L||D||typeof b=="function"&&!b(N))return;const R=Oi(N),P="["+Ja("inert")+"]",B=hr(n.floating).querySelectorAll(P);let $=rs(R)?R:null;for(;$&&!qn($);){const K=Af($);if(qn(K)||!rs(K))break;$=K}if(B.length&&rs(R)&&!rx(R)&&!Po(R,n.floating)&&Array.from(B).every(K=>!Po($,K)))return;if(Ef(R)&&E){const K=qn(R),H=If(R),U=/auto|scroll/,X=K||U.test(H.overflowX),W=K||U.test(H.overflowY),G=X&&R.clientWidth>0&&R.scrollWidth>R.clientWidth,se=W&&R.clientHeight>0&&R.scrollHeight>R.clientHeight,ee=H.direction==="rtl",J=se&&(ee?N.offsetX<=R.offsetWidth-R.clientWidth:N.offsetX>R.clientWidth),ae=G&&N.offsetY>R.clientHeight;if(J||ae)return}const z=(A=o.current.floatingContext)==null?void 0:A.nodeId,q=g&&sn(g.nodesRef.current,z).some(K=>{var H;return Qn(N,(H=K.context)==null?void 0:H.elements.floating)});if(Qn(N,n.floating)||Qn(N,n.domReference)||q)return;const F=g?sn(g.nodesRef.current,z):[];if(F.length>0){let K=!0;if(F.forEach(H=>{var U;if((U=H.context)!=null&&U.open&&!H.context.dataRef.current.__outsidePressBubbles){K=!1;return}}),!K)return}i(!1,N,"outside-press")}),M=gi(N=>{var A;const D=()=>{var L;T(N),(L=Oi(N))==null||L.removeEventListener(d,D)};(A=Oi(N))==null||A.addEventListener(d,D)});j.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=v,o.current.__outsidePressBubbles=y;let N=-1;function A(B){i(!1,B,"ancestor-scroll")}function D(){window.clearTimeout(N),S.current=!0}function L(){N=window.setTimeout(()=>{S.current=!1},Nf()?5:0)}const R=hr(n.floating);l&&(R.addEventListener("keydown",V?k:w,V),R.addEventListener("compositionstart",D),R.addEventListener("compositionend",L)),b&&R.addEventListener(d,C?M:T,C);let P=[];return f&&(rs(n.domReference)&&(P=Kn(n.domReference)),rs(n.floating)&&(P=P.concat(Kn(n.floating))),!rs(n.reference)&&n.reference&&n.reference.contextElement&&(P=P.concat(Kn(n.reference.contextElement)))),P=P.filter(B=>{var $;return B!==(($=R.defaultView)==null?void 0:$.visualViewport)}),P.forEach(B=>{B.addEventListener("scroll",A,{passive:!0})}),()=>{l&&(R.removeEventListener("keydown",V?k:w,V),R.removeEventListener("compositionstart",D),R.removeEventListener("compositionend",L)),b&&R.removeEventListener(d,C?M:T,C),P.forEach(B=>{B.removeEventListener("scroll",A)}),window.clearTimeout(N)}},[o,n,l,b,d,s,i,f,a,v,y,w,V,k,T,C,M]),j.useEffect(()=>{o.current.insideReactTree=!1},[o,b,d]);const I=j.useMemo(()=>({onKeyDown:w,...u&&{[Nx[h]]:N=>{i(!1,N.nativeEvent,"reference-press")},...h!=="click"&&{onClick(N){i(!1,N.nativeEvent,"reference-press")}}}}),[w,i,u,h]),E=j.useMemo(()=>{function N(A){A.button===0&&(x.current=!0)}return{onKeyDown:w,onMouseDown:N,onMouseUp:N,[Ax[d]]:()=>{o.current.insideReactTree=!0}}},[w,d,o]);return j.useMemo(()=>a?{reference:I,floating:E}:{},[a,I,E])}function Ix(t){const{open:e=!1,onOpenChange:s,elements:i}=t,n=Xa(),o=j.useRef({}),[a]=j.useState(()=>bx()),l=zh()!=null,[c,d]=j.useState(i.reference),u=gi((m,p,g)=>{o.current.openEvent=m?p:void 0,a.emit("openchange",{open:m,event:p,reason:g,nested:l}),s?.(m,p,g)}),h=j.useMemo(()=>({setPositionReference:d}),[]),f=j.useMemo(()=>({reference:c||i.reference||null,floating:i.floating||null,domReference:i.reference}),[c,i.reference,i.floating]);return j.useMemo(()=>({dataRef:o,open:e,onOpenChange:u,elements:f,events:a,floatingId:n,refs:h}),[e,u,f,a,n,h])}function Tx(t){t===void 0&&(t={});const{nodeId:e}=t,s=Ix({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||s,n=i.elements,[o,a]=j.useState(null),[l,c]=j.useState(null),u=n?.domReference||o,h=j.useRef(null),f=Fh();Xs(()=>{u&&(h.current=u)},[u]);const m=jf({...t,elements:{...n,...l&&{reference:l}}}),p=j.useCallback(v=>{const y=rs(v)?{getBoundingClientRect:()=>v.getBoundingClientRect(),getClientRects:()=>v.getClientRects(),contextElement:v}:v;c(y),m.refs.setReference(y)},[m.refs]),g=j.useCallback(v=>{(rs(v)||v===null)&&(h.current=v,a(v)),(rs(m.refs.reference.current)||m.refs.reference.current===null||v!==null&&!rs(v))&&m.refs.setReference(v)},[m.refs]),_=j.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:h}),[m.refs,g,p]),b=j.useMemo(()=>({...m.elements,domReference:u}),[m.elements,u]),x=j.useMemo(()=>({...m,...i,refs:_,elements:b,nodeId:e}),[m,_,b,e,i]);return Xs(()=>{i.dataRef.current.floatingContext=x;const v=f?.nodesRef.current.find(y=>y.id===e);v&&(v.context=x)}),j.useMemo(()=>({...m,context:x,refs:_,elements:b}),[m,_,b,x])}function eo(t,e,s){const i=new Map,n=s==="item";let o=t;if(n&&t){const{[Ul]:a,[Hl]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[px]:""},...o,...e.map(a=>{const l=a?a[s]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((a,l)=>(l&&Object.entries(l).forEach(c=>{let[d,u]=c;if(!(n&&[Ul,Hl].includes(d)))if(d.indexOf("on")===0){if(i.has(d)||i.set(d,[]),typeof u=="function"){var h;(h=i.get(d))==null||h.push(u),a[d]=function(){for(var f,m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];return(f=i.get(d))==null?void 0:f.map(_=>_(...p)).find(_=>_!==void 0)}}}else a[d]=u}),a),{})}}function Rx(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),i=t.map(l=>l?.item),n=j.useCallback(l=>eo(l,t,"reference"),e),o=j.useCallback(l=>eo(l,t,"floating"),s),a=j.useCallback(l=>eo(l,t,"item"),i);return j.useMemo(()=>({getReferenceProps:n,getFloatingProps:o,getItemProps:a}),[n,o,a])}const Mx=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Dx(t,e){var s,i;e===void 0&&(e={});const{open:n,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=Xa(),u=((s=o.domReference)==null?void 0:s.id)||d,h=j.useMemo(()=>{var x;return((x=nx(o.floating))==null?void 0:x.id)||a},[o.floating,a]),f=(i=Mx.get(c))!=null?i:c,p=zh()!=null,g=j.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:n?h:void 0}:{"aria-expanded":n?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":n?h:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:u},...f==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[f,h,p,n,u,c]),_=j.useMemo(()=>{const x={id:h,...f&&{role:f}};return f==="tooltip"||c==="label"?x:{...x,...f==="menu"&&{"aria-labelledby":u}}},[f,h,u,c]),b=j.useCallback(x=>{let{active:v,selected:y}=x;const V={role:"option",...v&&{id:h+"-fui-option"}};switch(c){case"select":case"combobox":return{...V,"aria-selected":y}}return{}},[h,c]);return j.useMemo(()=>l?{reference:g,floating:_,item:b}:{},[l,g,_,b])}function Px(t){const e=O.c(26),{editor:s,query:i,items:n,onSelect:o,onClose:a}=t,[l,c]=j.useState(0),d=j.useRef(n),u=j.useRef(l),h=j.useRef(o),f=j.useRef(a),m=j.useDeferredValue(i);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{c(0)},e[0]=p):p=e[0];let g;e[1]!==m?(g=[m],e[1]=m,e[2]=g):g=e[2],j.useEffect(p,g);let _,b;e[3]!==n.length||e[4]!==l?(_=()=>{l>=n.length&&n.length>0&&c(0)},b=[n.length,l],e[3]=n.length,e[4]=l,e[5]=_,e[6]=b):(_=e[5],b=e[6]),j.useEffect(_,b);let x,v;e[7]!==n?(x=()=>{d.current=n},v=[n],e[7]=n,e[8]=x,e[9]=v):(x=e[8],v=e[9]),j.useEffect(x,v);let y,V;e[10]!==l?(y=()=>{u.current=l},V=[l],e[10]=l,e[11]=y,e[12]=V):(y=e[11],V=e[12]),j.useEffect(y,V);let C,S;e[13]!==o?(S=()=>{h.current=o},C=[o],e[13]=o,e[14]=C,e[15]=S):(C=e[14],S=e[15]),j.useEffect(S,C);let w,k;e[16]!==a?(w=()=>{f.current=a},k=[a],e[16]=a,e[17]=w,e[18]=k):(w=e[17],k=e[18]),j.useEffect(w,k);let T;e[19]!==s.isDestroyed||e[20]!==s.view.dom?(T=()=>{const N=s.view.dom;if(s?.isDestroyed||!N)return;const A=L=>{const R=d.current;if(!R.length)return!1;const P=()=>c($=>($+1)%R.length),B=()=>c($=>($-1+R.length)%R.length);switch(L.key){case"ArrowUp":return L.preventDefault(),B(),!0;case"ArrowDown":return L.preventDefault(),P(),!0;case"Tab":return L.preventDefault(),L.shiftKey?B():P(),!0;case"Home":return L.preventDefault(),c(0),!0;case"End":return L.preventDefault(),c(R.length-1),!0;case"Enter":{if(L.isComposing)return!1;L.preventDefault();const $=u.current;return $!==-1&&R[$]&&h.current?.(R[$],$),!0}case"Escape":return L.preventDefault(),f.current?.(),!0;default:return!1}},D=L=>{A(L)};return N.addEventListener("keydown",D,!0),()=>{N?.removeEventListener("keydown",D,!0)}},e[19]=s.isDestroyed,e[20]=s.view.dom,e[21]=T):T=e[21];let M;e[22]!==s?(M=[s],e[22]=s,e[23]=M):M=e[23],j.useEffect(T,M);const I=n.length?l:void 0;let E;return e[24]!==I?(E={selectedIndex:I,setSelectedIndex:c},e[24]=I,e[25]=E):E=e[25],E}function Lx(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 Hh=j.createContext(void 0);function Wh(){const t=j.useContext(Hh);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function Ox({editor:t,char:e,pluginKey:s,allow:i,onOpenChange:n}){const[o,a]=j.useReducer(Lx,{open:!1,element:null,query:"",range:null,selectedItem:null}),l=j.useRef(n);return l.current=n,j.useEffect(()=>{if(t?.isDestroyed)return;const c=s instanceof No?s:new No(s);t.state.plugins.find(h=>h.spec.key===c)&&t.unregisterPlugin(c);const u=wp({pluginKey:c,editor:t,char:e,allow(h){const f=t.state.doc.resolve(h.range.from);for(let m=f.depth;m>0;m--)if(f.node(m).type.name==="image")return!1;return!(i&&!i(h))},command(){},render:()=>({onStart:h=>{a({type:"ON_START",payload:{element:h.decorationNode??null,query:h.query,range:h.range}}),l.current?.(!0)},onUpdate:h=>{a({type:"ON_UPDATE",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onKeyDown:h=>h.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),l.current?.(!1)}}),items:()=>[]});return t.registerPlugin(u),()=>{t?.isDestroyed||t.unregisterPlugin(c)}},[t,s,e,a,i]),{state:o,dispatch:a}}function Bx({editor:t,queryKey:e,queryFn:s,onSelect:i}){const{state:n,dispatch:o}=Wh(),a=j.useDeferredValue(n.query),{data:l}=bd({queryKey:Ze.suggestionItems(e,n.open,a),queryFn:()=>n.open?s({query:a}):[]}),c=()=>{o({type:"ON_EXIT"})},d=async(h,f)=>{if(!(n.selectedItem!==null||!n.range)){o({type:"SET_SELECTED_ITEM",payload:h});try{const{view:m}=t,g=m.state.selection.$to.nodeAfter?.text?.startsWith(" "),_=n.range?{...n.range}:{from:0,to:0};g&&n.range&&(_.to+=1),await i({range:_,item:h})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):c()}catch{c()}}},{selectedIndex:u}=Px({editor:t,query:a,items:l,onSelect:d,onClose:c});return{selectedItem:n.selectedItem,items:l,selectedIndex:u,close:c,onSelect:d}}function $x({children:t}){const{state:e,dispatch:s}=Wh(),{open:i,element:n}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=Tx({placement:"bottom-start",open:i,onOpenChange:f=>{f||o()},elements:{reference:n},middleware:[Rf(10),Mf(),Df()],whileElementsMounted:Pf}),d=Ex(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),u=Dx(c,{role:"listbox"}),{getFloatingProps:h}=Rx([d,u]);return i?r.jsx(kx,{children:r.jsx("div",{ref:a.setFloating,style:l,...h(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const zx=t=>{const e=O.c(29),{item:s,isSelected:i,onSelect:n,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const C=Ls(s._meta);l=s.title||kn(s.name,C),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,u=s.icon,h=i&&"bg-accent text-accent-foreground",f=o&&"pointer-events-none opacity-50";let m;e[2]!==h||e[3]!==f?(m=Y("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",h,f),e[2]=h,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==u||e[6]!==c?(p=u!==void 0&&r.jsx(Qt,{icon:u,name:c,size:"xs",className:"mr-2"}),e[5]=u,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=r.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let _;e[10]!==o?(_=o&&r.jsx(ar,{size:"xs"}),e[10]=o,e[11]=_):_=e[11];let b;e[12]!==g||e[13]!==_?(b=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,_]}),e[12]=g,e[13]=_,e[14]=b):b=e[14];let x;e[15]!==d?(x=d&&r.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=x):x=e[16];let v;e[17]!==b||e[18]!==x?(v=r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[b,x]}),e[17]=b,e[18]=x,e[19]=v):v=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&r.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=y):y=e[21];let V;return e[22]!==n||e[23]!==a||e[24]!==v||e[25]!==y||e[26]!==m||e[27]!==p?(V=r.jsxs("div",{ref:a,onClick:n,className:m,children:[p,v,y]}),e[22]=n,e[23]=a,e[24]=v,e[25]=y,e[26]=m,e[27]=p,e[28]=V):V=e[28],V},Fx=t=>{const e=O.c(18),{editor:s,queryKey:i,queryFn:n,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==n||e[3]!==i?(a={editor:s,queryKey:i,queryFn:n,onSelect:o},e[0]=s,e[1]=o,e[2]=n,e[3]=i,e[4]=a):a=e[4];const{items:l,selectedIndex:c,onSelect:d,selectedItem:u}=Bx(a);if(!l.length){let p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=p):p=e[5],p}let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=h):h=e[6];let f;if(e[7]!==d||e[8]!==l||e[9]!==c||e[10]!==u?.name){let p;e[12]!==d||e[13]!==c||e[14]!==u?.name?(p=(g,_)=>r.jsx(zx,{item:g,isSelected:_===c,ref:_===c?Wx:void 0,onSelect:()=>d(g,_),isLoading:u?.name===g.name},g.name),e[12]=d,e[13]=c,e[14]=u?.name,e[15]=p):p=e[15],f=l.map(p),e[7]=d,e[8]=l,e[9]=c,e[10]=u?.name,e[11]=f}else f=e[11];let m;return e[16]!==f?(m=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:h,children:r.jsx("div",{className:"p-1",children:f})}),e[16]=f,e[17]=m):m=e[17],m};function Ux(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"p-1",children:[...Array(3)].map(Hx)}),t[0]=e):e=t[0],e}function Hx(t,e){return r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[r.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),r.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function Kh(t){const e=O.c(18),{editor:s,char:i,pluginKey:n,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let u;e[0]!==c||e[1]!==i||e[2]!==s||e[3]!==d||e[4]!==n?(u={editor:s,char:i,pluginKey:n,allow:c,onOpenChange:d},e[0]=c,e[1]=i,e[2]=s,e[3]=d,e[4]=n,e[5]=u):u=e[5];const{state:h,dispatch:f}=Ox(u);let m;e[6]!==f||e[7]!==h?(m={state:h,dispatch:f},e[6]=f,e[7]=h,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Ux,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=r.jsx($x,{children:r.jsx(j.Suspense,{fallback:p,children:r.jsx(Fx,{editor:s,queryKey:o,queryFn:a,onSelect:l})})}),e[10]=s,e[11]=l,e[12]=a,e[13]=o,e[14]=g):g=e[14];let _;return e[15]!==m||e[16]!==g?(_=r.jsx(Hh.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=_):_=e[17],_}function Wx(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const Kx=[{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}],qx=({editor:t,virtualMcpId:e})=>{const s=bt(),{org:i}=_e(),n=Rn(),o=Ae({connectionId:e,orgId:i.id}),a=Ze.virtualMcpResources(e,i.id),[l,c]=j.useState("categories"),d=j.useRef(l);d.current=l;const u=j.useRef(null),h=j.useRef(!1),f=["at-mention",i.id,e??"default",l],m=async({item:_,range:b})=>{if(re("chat_picker_item_selected",{picker:"@",item_kind:_.kind,item_name:_.name}),_.kind!=="category"&&(h.current=!0),_.kind==="category")return c(_.name==="agents"?"agents":"resources"),!1;if(_.kind==="agent"&&_.agentId){or(t,b,{id:_.agentId,name:_.name,metadata:{agentId:_.agentId,title:_.name},char:"@"}),c("categories");return}if(_.kind==="resource"&&_.uri&&o){try{const x=await rh(o,_.uri);or(t,b,{id:_.uri,name:_.uri,metadata:x.contents,char:"@"})}catch(x){console.error("[at-mention] Failed to fetch resource:",x),ue.error("Failed to load resource. Please try again.")}c("categories");return}},p=async _=>{const{query:b}=_,x=d.current;if(x==="categories"){if(!b.trim())return Kx;const V=b.toLowerCase(),C=n.filter(w=>w.status==="active"&&(!w.id||!lr(w.id))&&w.id!==e&&(w.title.toLowerCase().includes(V)||w.description?.toLowerCase().includes(V))).map(w=>({name:w.title,title:w.title,description:w.description??void 0,icon:w.icon??null,kind:"agent",agentId:w.id})),S=await(async()=>{if(!o)return[];let w=s.getQueryData(a);return w||(w=await s.fetchQuery({queryKey:a,queryFn:()=>sr(o),staleTime:6e4})),(w?.resources??[]).filter(k=>k.uri.toLowerCase().includes(V)||k.name?.toLowerCase().includes(V)||k.description?.toLowerCase().includes(V)).map(k=>({name:k.name??k.uri,title:k.name,description:k.description,kind:"resource",uri:k.uri}))})();return[...C,...S]}if(x==="agents"){let V=n.filter(C=>C.status==="active"&&(!C.id||!lr(C.id))&&C.id!==e);if(b.trim()){const C=b.toLowerCase();V=V.filter(S=>S.title.toLowerCase().includes(C)||S.description?.toLowerCase().includes(C))}return V.map(C=>({name:C.title,title:C.title,description:C.description??void 0,icon:C.icon??null,kind:"agent",agentId:C.id}))}if(!o)return[];let v=s.getQueryData(a);v?s.fetchQuery({queryKey:a,queryFn:()=>sr(o),staleTime:6e4}).catch(()=>{}):v=await s.fetchQuery({queryKey:a,queryFn:()=>sr(o),staleTime:6e4});let y=v?.resources??[];if(b.trim()){const V=b.toLowerCase();y=y.filter(C=>C.uri.toLowerCase().includes(V)||C.name?.toLowerCase().includes(V)||C.description?.toLowerCase().includes(V))}return y.map(V=>({name:V.name??V.uri,title:V.name,description:V.description,kind:"resource",uri:V.uri}))},g=_=>{if(_)u.current=Date.now(),h.current=!1,re("chat_picker_opened",{picker:"@"});else{const b=u.current;re("chat_picker_closed",{picker:"@",outcome:h.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),u.current=null,c("categories")}};return r.jsx(Kh,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:f,queryFn:p,onSelect:m,onOpenChange:g})};function Gx(t,e){const s=$t(t),i=yr(),n=new Map(i.map(c=>[c.id,c])),o=(s?.connections??[]).map(c=>c.connection_id),{data:a}=ji({queryKey:Ze.promptConnectionMap(e,o),queryFn:async()=>{const c={};return await Promise.all(o.map(async d=>{try{const u=await Hm({connectionId:d,orgId:e}),h=await hn(u);for(const f of h.prompts)f.name in c||(c[f.name]=d)}catch{}})),c},staleTime:6e4,enabled:o.length>0}),l=new Map;for(const[c,d]of Object.entries(a??{})){const u=n.get(d);u&&l.set(c,u)}return l}async function Xl(t,e,s,i,n,o){try{const a=await Ea(s,i,o);or(t,e,{id:i,name:ka(i,n),metadata:a.messages,char:"/"})}catch(a){console.error("[slash] Failed to fetch prompt:",a),ue.error("Failed to load prompt. Please try again.")}}async function Yx(t,e,s,i){try{const n=await rh(s,i);or(t,e,{id:i,name:i,metadata:n.contents,char:"/"})}catch(n){console.error("[slash] Failed to fetch resource:",n),ue.error("Failed to load resource. Please try again.")}}const Xx=({editor:t,virtualMcpId:e})=>{const s=bt(),{org:i}=_e(),n=Ae({connectionId:e,orgId:i.id}),o=Gx(e,i.id),a=j.useRef(o);a.current=o;const l=Ze.virtualMcpPrompts(e,i.id),c=Ze.virtualMcpResources(e,i.id),d=["slash-mention",i.id,e??"default"],[u,h]=j.useState(null),f=j.useRef(null),m=j.useRef(!1),p=async({item:x,range:v})=>{if(re("chat_picker_item_selected",{picker:"/",item_kind:x.kind,item_name:x.name}),m.current=!0,!!n)if(x.kind==="prompt"){if(x.arguments&&x.arguments.length>0){h({range:v,item:x});return}const y=Ls(x._meta);await Xl(t,v,n,x.name,y)}else x.uri&&await Yx(t,v,n,x.uri)},g=async x=>{if(!u||!n)return;const{range:v,item:y}=u,V=Ls(y._meta);await Xl(t,v,n,y.name,V,x),h(null)},_=async x=>{const{query:v}=x;if(!n)return[];const[y,V]=await Promise.all([Jx(s,l,n),Qx(s,c,n)]),C=v.trim().toLowerCase(),S=(y??[]).filter(k=>!C||k.name.toLowerCase().includes(C)||k.title?.toLowerCase().includes(C)||k.description?.toLowerCase().includes(C)).map(k=>({name:k.name,title:k.title,description:k.description,icon:a.current.get(k.name)?.icon??null,kind:"prompt",arguments:k.arguments,_meta:k._meta})),w=(V??[]).filter(k=>!C||k.uri.toLowerCase().includes(C)||k.name?.toLowerCase().includes(C)||k.description?.toLowerCase().includes(C)).map(k=>({name:k.name??k.uri,title:k.name,description:k.description,kind:"resource",uri:k.uri}));return[...S,...w]},b=u?.item.kind==="prompt"?{name:u.item.name,arguments:u.item.arguments,description:u.item.description}:null;return r.jsxs(r.Fragment,{children:[r.jsx(Kh,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:d,queryFn:_,onSelect:p,onOpenChange:x=>{if(x)f.current=Date.now(),m.current=!1,re("chat_picker_opened",{picker:"/"});else{const v=f.current;re("chat_picker_closed",{picker:"/",outcome:m.current?"selected":"dismissed",duration_ms:v?Date.now()-v:null}),f.current=null}}}),r.jsx(Ga,{prompt:b,setPrompt:()=>h(null),onSubmit:g})]})};async function Jx(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>hn(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>hn(s),staleTime:6e4}),i?.prompts??[]}async function Qx(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>sr(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>sr(s),staleTime:6e4}),i?.resources??[]}function Zx(t){return[Bm.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),B_.configure({placeholder:()=>t.current??"Ask anything, / for prompts, @ for agents & resources...",showOnlyWhenEditable:!1}),vm,bm]}function qh({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:i=!1,placeholder:n,onSubmit:o,children:a}){const l=j.useRef(o),c=j.useRef(e),d=j.useRef(i),u=j.useRef(n),h=Lm({extensions:Zx(u),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(f,m)=>m.key==="Enter"&&!m.shiftKey&&d.current?(m.preventDefault(),l.current?.(),!0):!1},onUpdate:({editor:f})=>{c.current(f?.getJSON())}});return j.useEffect(()=>{h?.setEditable(!s)},[h,s]),j.useEffect(()=>{l.current=o},[o]),j.useEffect(()=>{c.current=e},[e]),j.useEffect(()=>{d.current=i},[i]),j.useEffect(()=>{u.current=n},[n]),j.useEffect(()=>{if(h?.isDestroyed)return;const f=JSON.stringify(h?.getJSON()),m=JSON.stringify(t||{type:"doc",content:[]});f!==m&&h.commands.setContent(t||{type:"doc",content:[]})},[h,t]),r.jsx(Om.Provider,{value:{editor:h},children:a})}function Gh(t){const e=O.c(26),{disabled:s,virtualMcpId:i,showFileUploader:n,selectedModel:o,onUnsupportedFile:a,ref:l,className:c}=t,d=s===void 0?!1:s,u=n===void 0?!1:n,{editor:h}=jn();let f,m;if(e[0]!==h?(f=()=>({focus:()=>{h?.commands.focus()},clear:()=>{h?.commands.clearContent(!0)},appendText:w=>{if(!h)return;const k=h.state.doc.textContent.trim()==="";h.commands.focus("end"),k||h.commands.insertContent(" "),h.commands.insertContent(w)},syncVoiceText:(w,k)=>{if(h&&(h.commands.setContent(w||{type:"doc",content:[]}),k)){h.commands.focus("end");const T=h.state.doc.textContent.trim().length>0;h.commands.insertContent(T?" "+k:k)}},restoreContent:w=>{h&&h.commands.setContent(w||{type:"doc",content:[]})}}),m=[h],e[0]=h,e[1]=f,e[2]=m):(f=e[1],m=e[2]),j.useImperativeHandle(l??null,f,m),!h)return null;const p=d&&"cursor-not-allowed opacity-70",g=d&&"[&_.ProseMirror]:cursor-not-allowed";let _;e[3]!==c||e[4]!==p||e[5]!==g?(_=Y("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",c,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",p,g),e[3]=c,e[4]=p,e[5]=g,e[6]=_):_=e[6];let b;e[7]!==h||e[8]!==_?(b=r.jsx($m,{editor:h,className:_}),e[7]=h,e[8]=_,e[9]=b):b=e[9];const x=i??null;let v;e[10]!==h||e[11]!==x?(v=r.jsx(j.Suspense,{fallback:null,children:r.jsx(Xx,{editor:h,virtualMcpId:x})}),e[10]=h,e[11]=x,e[12]=v):v=e[12];const y=i??null;let V;e[13]!==h||e[14]!==y?(V=r.jsx(j.Suspense,{fallback:null,children:r.jsx(qx,{editor:h,virtualMcpId:y})}),e[13]=h,e[14]=y,e[15]=V):V=e[15];let C;e[16]!==h||e[17]!==a||e[18]!==o||e[19]!==u?(C=u&&o?r.jsx(E_,{editor:h,selectedModel:o,onUnsupportedFile:a}):null,e[16]=h,e[17]=a,e[18]=o,e[19]=u,e[20]=C):C=e[20];let S;return e[21]!==v||e[22]!==V||e[23]!==C||e[24]!==b?(S=r.jsxs(r.Fragment,{children:[b,v,V,C]}),e[21]=v,e[22]=V,e[23]=C,e[24]=b,e[25]=S):S=e[25],S}function Lo(t){const e=O.c(3),[s]=ei();let i;return e[0]!==s.enableSounds||e[1]!==t?(i=()=>{s.enableSounds&&Tp(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 e1={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"},t1=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function s1(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1.5",children:t1.map(i1)}),t[0]=e):e=t[0],e}function i1(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function r1(t){const e=O.c(129),{disabled:s,onOpenConnections:i,virtualMcpId:n}=t,[o,a]=j.useState(!1),l=Lo(e1),{org:c}=_e(),{editor:d}=jn();let u;e[0]!==c.id||e[1]!==n?(u={connectionId:n,orgId:c.id},e[0]=c.id,e[1]=n,e[2]=u):u=e[2];const h=Ae(u);let f;e[3]!==c.id||e[4]!==n?(f=Ze.virtualMcpPrompts(n,c.id),e[3]=c.id,e[4]=n,e[5]=f):f=e[5];const m=f;let p;e[6]!==h?(p=()=>hn(h),e[6]=h,e[7]=p):p=e[7];const g=o&&!!h;let _;e[8]!==m||e[9]!==p||e[10]!==g?(_={queryKey:m,queryFn:p,staleTime:6e4,enabled:g},e[8]=m,e[9]=p,e[10]=g,e[11]=_):_=e[11];const{data:b,isLoading:x}=ji(_);let v;e[12]!==b?.prompts?(v=b?.prompts??[],e[12]=b?.prompts,e[13]=v):v=e[13];const y=v,[V,C]=j.useState(null),{credentialId:S,imageModel:w,setImageModel:k,deepResearchModel:T,setDeepResearchModel:M,chatMode:I,setChatMode:E,simpleModeEnabled:N}=$s(),A=I==="plan",[D,L]=j.useState(!1),[R,P]=j.useState(!1),{models:B,isLoading:$}=eh(D||R?S??void 0:void 0);let z,q,F,K,H,U,X,W,G,se,ee,J,ae;if(e[14]!==V||e[15]!==B||e[16]!==I||e[17]!==h||e[18]!==T||e[19]!==s||e[20]!==d||e[21]!==w||e[22]!==D||e[23]!==$||e[24]!==A||e[25]!==i||e[26]!==o||e[27]!==l||e[28]!==R||e[29]!==E||e[30]!==M||e[31]!==k||e[32]!==N){const te=B.filter(o1),ie=B.filter(n1);let Ce;e[46]!==I||e[47]!==A||e[48]!==l||e[49]!==E?(Ce=()=>{l();const ge=A?"default":"plan";re("chat_mode_changed",{from_mode:I,to_mode:ge,source:"tools_popover"}),E(ge),a(!1)},e[46]=I,e[47]=A,e[48]=l,e[49]=E,e[50]=Ce):Ce=e[50];const ze=Ce;let Fe;e[51]!==i?(Fe=()=>{i(),a(!1)},e[51]=i,e[52]=Fe):Fe=e[52],F=Fe;let ft;e[53]!==h||e[54]!==d?(ft=async(ge,Vs)=>{if(!d||!h)return;const Di=Ls(ge._meta),Pi={from:d.state.selection.from,to:d.state.selection.to};try{const Sf=await Ea(h,ge.name,Vs);or(d,Pi,{id:ge.name,name:ka(ge.name,Di),metadata:Sf.messages,char:"/"})}catch{ue.error("Failed to load prompt. Please try again.")}},e[53]=h,e[54]=d,e[55]=ft):ft=e[55];const He=ft;let tt;e[56]!==He?(tt=async ge=>{a(!1);const Vs=!!(ge.arguments&&ge.arguments.length>0);if(re("chat_prompt_inserted",{prompt_name:ge.name,with_arguments:Vs}),Vs){C(ge);return}await He(ge)},e[56]=He,e[57]=tt):tt=e[57],H=tt;let ht;e[58]!==V||e[59]!==He?(ht=async ge=>{V&&(await He(V,ge),C(null))},e[58]=V,e[59]=He,e[60]=ht):ht=e[60],K=ht;let pe;e[61]!==l||e[62]!==k?(pe=ge=>{l(),re("chat_image_model_selected",{model_id:ge.modelId,model_title:ge.title,provider:ge.providerId??null}),k(ge),a(!1)},e[61]=l,e[62]=k,e[63]=pe):pe=e[63];const ke=pe;let st;e[64]!==l||e[65]!==M?(st=ge=>{l(),re("chat_search_model_selected",{model_id:ge.modelId,model_title:ge.title,provider:ge.providerId??null}),M(ge),a(!1)},e[64]=l,e[65]=M,e[66]=st):st=e[66];const zt=st;let De;e[67]!==I||e[68]!==l||e[69]!==E?(De=()=>{l();const ge=I==="gen-image"?"default":"gen-image";re("chat_mode_changed",{from_mode:I,to_mode:ge,source:"tools_popover"}),E(ge),a(!1)},e[67]=I,e[68]=l,e[69]=E,e[70]=De):De=e[70];const Yt=De;let At;e[71]!==I||e[72]!==l||e[73]!==E?(At=()=>{l();const ge=I==="web-search"?"default":"web-search";re("chat_mode_changed",{from_mode:I,to_mode:ge,source:"tools_popover"}),E(ge),a(!1)},e[71]=I,e[72]=l,e[73]=E,e[74]=At):At=e[74];const Et=At,Ct=I==="gen-image",ws=I==="web-search";q=cs,W=o,e[75]!==I||e[76]!==o?(G=ge=>{ge&&!o&&re("chat_tools_popover_opened",{chat_mode:I}),a(ge)},e[75]=I,e[76]=o,e[77]=G):G=e[77];let Rr,Mr;e[78]===Symbol.for("react.memo_cache_sentinel")?(Rr=r.jsx(zd,{size:14}),Mr=r.jsx("span",{className:"hidden sm:inline",children:"Tools"}),e[78]=Rr,e[79]=Mr):(Rr=e[78],Mr=e[79]),e[80]!==s?(se=r.jsx(ds,{asChild:!0,children:r.jsxs(oe,{type:"button",variant:"ghost",size:"default",disabled:s,className:"text-muted-foreground hover:text-foreground",children:[Rr,Mr]})}),e[80]=s,e[81]=se):se=e[81],z=hs,ee="start",J="w-52 p-1.5";const Hn=A&&"text-violet-600 dark:text-violet-400";let li;e[82]!==Hn?(li=Y(Hn),e[82]=Hn,e[83]=li):li=e[83];const Wn=A&&"text-violet-500";let ci;e[84]!==Wn?(ci=Y(Wn),e[84]=Wn,e[85]=ci):ci=e[85];let di;e[86]!==ci?(di=r.jsx(Yd,{size:16,className:ci}),e[86]=ci,e[87]=di):di=e[87];let Dr;e[88]===Symbol.for("react.memo_cache_sentinel")?(Dr=r.jsx("span",{className:"flex-1",children:"Plan mode"}),e[88]=Dr):Dr=e[88];let hi;e[89]!==A?(hi=A&&r.jsx("span",{className:"text-xs text-violet-500 font-medium",children:"On"}),e[89]=A,e[90]=hi):hi=e[90],e[91]!==ze||e[92]!==li||e[93]!==di||e[94]!==hi?(ae=r.jsxs(Qe,{onClick:ze,className:li,children:[di,Dr,hi]}),e[91]=ze,e[92]=li,e[93]=di,e[94]=hi,e[95]=ae):ae=e[95],U=N?r.jsxs(Qe,{onClick:Yt,className:Y(Ct&&"text-pink-600 dark:text-pink-400"),children:[r.jsx(Io,{size:16,className:Y(Ct&&"text-pink-500")}),r.jsx("span",{className:"flex-1",children:"Create image"}),Ct&&r.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}):r.jsxs(Qr,{open:D,onOpenChange:L,children:[r.jsxs("div",{className:"flex items-center rounded-lg",children:[r.jsxs(Qe,{onClick:Yt,disabled:!w,className:Y("flex-1 rounded-r-none pr-1",Ct&&"text-pink-600 dark:text-pink-400"),children:[r.jsx(Io,{size:16,className:Y(Ct&&"text-pink-500")}),r.jsx("span",{className:"flex-1",children:"Create image"}),Ct&&r.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),r.jsx(pl,{className:Y("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:r.jsx(cr,{size:14})})]}),r.jsx(Zr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:$?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ne,{size:14,className:"animate-spin"}),"Loading models…"]}):te.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No image models available"}):te.map(ge=>{const Vs=w?.modelId===ge.modelId,Di=Cl(ge),Pi=ge.title.includes(": ")?ge.title.split(": ").slice(1).join(": "):ge.title;return r.jsxs(Qe,{onClick:()=>ke(ge),className:"flex items-center gap-2",children:[r.jsx("img",{src:Di,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),r.jsx("span",{className:"flex-1 text-sm truncate",children:Pi}),Vs&&r.jsx(Mt,{size:14,className:"text-pink-500 shrink-0"})]},ge.modelId)})})]}),X=N?r.jsxs(Qe,{onClick:Et,className:Y(ws&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(vi,{size:16,className:Y(ws&&"text-blue-500")}),r.jsx("span",{className:"flex-1",children:"Web search"}),ws&&r.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}):T&&r.jsxs(Qr,{open:R,onOpenChange:P,children:[r.jsxs("div",{className:"flex items-center rounded-lg",children:[r.jsxs(Qe,{onClick:Et,className:Y("flex-1 rounded-r-none pr-1",ws&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(vi,{size:16,className:Y(ws&&"text-blue-500")}),r.jsx("span",{className:"flex-1",children:"Web search"}),ws&&r.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),r.jsx(pl,{className:Y("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:r.jsx(cr,{size:14})})]}),r.jsx(Zr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:$?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ne,{size:14,className:"animate-spin"}),"Loading models…"]}):ie.map(ge=>{const Vs=T?.modelId===ge.modelId,Di=Cl(ge),Pi=ge.title.includes(": ")?ge.title.split(": ").slice(1).join(": "):ge.title;return r.jsxs(Qe,{onClick:()=>zt(ge),className:"flex items-center gap-2",children:[r.jsx("img",{src:Di,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),r.jsx("span",{className:"flex-1 text-sm truncate",children:Pi}),Vs&&r.jsx(Mt,{size:14,className:"text-blue-500 shrink-0"})]},ge.modelId)})})]}),e[14]=V,e[15]=B,e[16]=I,e[17]=h,e[18]=T,e[19]=s,e[20]=d,e[21]=w,e[22]=D,e[23]=$,e[24]=A,e[25]=i,e[26]=o,e[27]=l,e[28]=R,e[29]=E,e[30]=M,e[31]=k,e[32]=N,e[33]=z,e[34]=q,e[35]=F,e[36]=K,e[37]=H,e[38]=U,e[39]=X,e[40]=W,e[41]=G,e[42]=se,e[43]=ee,e[44]=J,e[45]=ae}else z=e[33],q=e[34],F=e[35],K=e[36],H=e[37],U=e[38],X=e[39],W=e[40],G=e[41],se=e[42],ee=e[43],J=e[44],ae=e[45];let Z;e[96]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsxs(Pd,{className:"gap-2",children:[r.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),r.jsx("span",{className:"flex-1",children:"Prompts"})]}),e[96]=Z):Z=e[96];let de;e[97]!==H||e[98]!==x||e[99]!==y?(de=x?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ne,{size:14,className:"animate-spin"}),"Loading prompts…"]}):y.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):y.map(te=>r.jsxs(Qe,{onClick:()=>H(te),className:"flex flex-col items-start gap-0.5",children:[r.jsx("span",{className:"font-medium text-sm capitalize",children:te.title||kn(te.name,Ls(te._meta))}),te.description&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:te.description})]},te.name)),e[97]=H,e[98]=x,e[99]=y,e[100]=de):de=e[100];let me;e[101]!==de?(me=r.jsxs(Qr,{children:[Z,r.jsx(Zr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:de})]}),e[101]=de,e[102]=me):me=e[102];let le,he;e[103]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx(gp,{size:16}),he=r.jsx("span",{className:"flex-1",children:"Connections"}),e[103]=le,e[104]=he):(le=e[103],he=e[104]);let be;e[105]===Symbol.for("react.memo_cache_sentinel")?(be=r.jsx(j.Suspense,{children:r.jsx(s1,{})}),e[105]=be):be=e[105];let fe;e[106]!==F?(fe=r.jsxs(Qe,{onClick:F,children:[le,he,be]}),e[106]=F,e[107]=fe):fe=e[107];let ye;e[108]!==z||e[109]!==U||e[110]!==X||e[111]!==me||e[112]!==fe||e[113]!==ee||e[114]!==J||e[115]!==ae?(ye=r.jsxs(z,{align:ee,className:J,children:[ae,U,X,me,fe]}),e[108]=z,e[109]=U,e[110]=X,e[111]=me,e[112]=fe,e[113]=ee,e[114]=J,e[115]=ae,e[116]=ye):ye=e[116];let ve;e[117]!==q||e[118]!==W||e[119]!==G||e[120]!==se||e[121]!==ye?(ve=r.jsxs(q,{open:W,onOpenChange:G,children:[se,ye]}),e[117]=q,e[118]=W,e[119]=G,e[120]=se,e[121]=ye,e[122]=ve):ve=e[122];let Ve;e[123]!==V||e[124]!==K?(Ve=r.jsx(Ga,{prompt:V,setPrompt:C,onSubmit:K}),e[123]=V,e[124]=K,e[125]=Ve):Ve=e[125];let Ie;return e[126]!==ve||e[127]!==Ve?(Ie=r.jsxs(r.Fragment,{children:[ve,Ve]}),e[126]=ve,e[127]=Ve,e[128]=Ie):Ie=e[128],Ie}function n1(t){const e=t.modelId.toLowerCase().replace(/[^a-z0-9]/g,"");return e.includes("sonar")||e.includes("deepresearch")}function o1(t){return t.capabilities?.includes("image")}function a1({open:t,onOpenChange:e,onCreated:s}){const{org:i}=_e(),{data:n}=dt.useSession(),{stdioEnabled:o}=Lf(),a=ms(),l=Mn(),c=ah(),u=lh(c,"").items,h=Ai({resolver:gr(Mp),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),f=h.watch("ui_type"),m=h.watch("connection_url"),p=h.watch("npx_package"),g=Lr({uiType:f,connectionUrl:m??"",npxPackage:p??""})??kl({uiType:f,connectionUrl:m??"",registryItems:u}),_=S=>{const w=S.trim();if(!w)return;const k=!!h.formState.dirtyFields.title,T=!!h.formState.dirtyFields.description,M=!!h.formState.dirtyFields.env_vars,I=N=>{if(N&&(!k&&!h.getValues("title").trim()&&N.title&&h.setValue("title",N.title,{shouldDirty:!1}),!T&&!(h.getValues("description")??"").trim()&&N.description&&h.setValue("description",N.description,{shouldDirty:!1}),!M&&N.envVarKeys?.length)){const A=h.getValues("env_vars")??[],D=new Set(A.map(R=>R.key)),L=N.envVarKeys.filter(R=>!D.has(R));L.length>0&&h.setValue("env_vars",[...A,...L.map(R=>({key:R,value:""}))],{shouldDirty:!0})}},E=Pp(w);if(E&&o){h.setValue("ui_type","NPX",{shouldDirty:!0}),h.setValue("npx_package",E.packageName,{shouldDirty:!0}),h.setValue("connection_url","",{shouldDirty:!0}),h.setValue("connection_token",null,{shouldDirty:!0}),I(Lr({uiType:"NPX",npxPackage:E.packageName}));return}if(w.startsWith("http://")||w.startsWith("https://")){const N=f==="HTTP"||f==="SSE"||f==="Websocket"?f:"HTTP";h.setValue("ui_type",N,{shouldDirty:!0}),h.setValue("connection_url",w,{shouldDirty:!0}),I(Lr({uiType:N,connectionUrl:w})??kl({uiType:N,connectionUrl:w,registryItems:u}));return}f==="NPX"&&I(Lr({uiType:"NPX",npxPackage:w}))},b=S=>{S||h.reset(),e(S)},x=async S=>{let w,k=null,T=null,M=null;S.ui_type==="NPX"?(w="STDIO",k="",M=Lp(S.npx_package||"",S.env_vars||[])):S.ui_type==="STDIO"?(w="STDIO",k="",M=Op(S.stdio_command||"",S.stdio_args||"",S.stdio_cwd,S.env_vars||[])):(w=S.ui_type,k=S.connection_url||"",T=S.connection_token||null);const I=dh("conn");try{await l.create.mutateAsync({id:I,title:S.title,description:S.description||null,connection_type:w,connection_url:k,connection_token:T,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:n?.user?.id||"system",organization_id:i.id,icon:S.icon??null,app_name:null,app_id:null,connection_headers:M,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),h.reset(),e(!1),s?.(I)}catch{ue.error("Failed to create connection")}},v="Create Connection",y="Create a custom connection in your organization. Fill in the details below.",V=h.formState.isSubmitting?"Saving...":"Create Connection",C=r.jsxs("div",{className:"grid gap-4",children:[r.jsx(gt,{control:h.control,name:"ui_type",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:"Type *"}),r.jsxs(Rs,{value:S.value,onValueChange:S.onChange,children:[r.jsx(xt,{children:r.jsx(Ms,{children:r.jsx(Ds,{})})}),r.jsxs(Ts,{children:[r.jsx(Nt,{value:"HTTP",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(vi,{className:"w-4 h-4"}),"HTTP"]})}),r.jsx(Nt,{value:"SSE",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(vi,{className:"w-4 h-4"}),"SSE"]})}),r.jsx(Nt,{value:"Websocket",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(vi,{className:"w-4 h-4"}),"Websocket"]})}),o&&r.jsxs(r.Fragment,{children:[r.jsx(Nt,{value:"NPX",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(en,{className:"w-4 h-4"}),"NPX Package"]})}),r.jsx(Nt,{value:"STDIO",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ia,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),r.jsx(vt,{})]})}),f==="NPX"&&r.jsx(gt,{control:h.control,name:"npx_package",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:"NPM Package *"}),r.jsx(xt,{children:r.jsx(at,{placeholder:"@perplexity-ai/mcp-server",...S,value:S.value??"",onPaste:w=>{const k=w.clipboardData.getData("text");k&&(w.preventDefault(),h.setValue("npx_package",k.trim(),{shouldDirty:!0}),_(k))},onBlur:w=>{_(w.target.value),S.onBlur()}})}),r.jsx(vt,{})]})}),f==="STDIO"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[r.jsx(gt,{control:h.control,name:"stdio_command",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:"Command *"}),r.jsx(xt,{children:r.jsx(at,{placeholder:"node, bun, python...",...S,value:S.value??""})}),r.jsx(vt,{})]})}),r.jsx(gt,{control:h.control,name:"stdio_args",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:"Arguments"}),r.jsx(xt,{children:r.jsx(at,{placeholder:"arg1 arg2 --flag value",...S,value:S.value??""})}),r.jsx(vt,{})]})})]}),r.jsx(gt,{control:h.control,name:"stdio_cwd",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:"Working Directory"}),r.jsx(xt,{children:r.jsx(at,{placeholder:"/path/to/project (optional)",...S,value:S.value??""})}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),r.jsx(vt,{})]})})]}),(f==="NPX"||f==="STDIO")&&r.jsx(gt,{control:h.control,name:"env_vars",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:"Environment Variables"}),r.jsx(xt,{children:r.jsx(Dp,{value:S.value??[],onChange:S.onChange})}),r.jsx(vt,{})]})}),f!=="NPX"&&f!=="STDIO"&&r.jsxs(r.Fragment,{children:[r.jsx(gt,{control:h.control,name:"connection_url",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:"URL *"}),r.jsx(xt,{children:r.jsx(at,{placeholder:"https://example.com/mcp",...S,value:S.value??"",onPaste:w=>{const k=w.clipboardData.getData("text");k&&(w.preventDefault(),h.setValue("connection_url",k.trim(),{shouldDirty:!0}),_(k))},onBlur:w=>{_(w.target.value),S.onBlur()}})}),r.jsx(vt,{})]})}),r.jsx(gt,{control:h.control,name:"connection_token",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:g?.token?.label??"Token (optional)"}),r.jsx(xt,{children:r.jsx(at,{type:"password",placeholder:g?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...S,value:S.value??""})}),g?.token?.helperText&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.id==="github"&&r.jsxs(r.Fragment,{children:[" ","·"," ",r.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"})]})]}),r.jsx(vt,{})]})})]}),r.jsx(gt,{control:h.control,name:"title",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:"Name *"}),r.jsx(xt,{children:r.jsx(at,{placeholder:"My Connection",...S})}),r.jsx(vt,{})]})}),r.jsx(gt,{control:h.control,name:"description",render:({field:S})=>r.jsxs(_t,{children:[r.jsx(Ht,{children:"Description"}),r.jsx(xt,{children:r.jsx(To,{placeholder:"A brief description of this connection",rows:3,...S,value:S.value??""})}),r.jsx(vt,{})]})})]});return a?r.jsx(ri,{open:t,onOpenChange:b,children:r.jsxs(ii,{className:"max-h-[90vh]",children:[r.jsx(An,{className:"pb-2",children:r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex-1 text-left",children:[r.jsx(si,{children:v}),r.jsx(zm,{className:"mt-1",children:y})]}),r.jsx(Fm,{asChild:!0,children:r.jsx(oe,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:r.jsx(Os,{size:16})})})]})}),r.jsx(yi,{...h,children:r.jsxs("form",{onSubmit:h.handleSubmit(x),children:[r.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:C}),r.jsx(Um,{children:r.jsx(oe,{type:"submit",disabled:h.formState.isSubmitting,className:"w-full",children:V})})]})})]})}):r.jsx(Bt,{open:t,onOpenChange:b,children:r.jsxs(Ot,{className:"sm:max-w-[525px]",children:[r.jsxs(Gt,{children:[r.jsx(qt,{children:v}),r.jsx(Nn,{children:y})]}),r.jsx(yi,{...h,children:r.jsxs("form",{onSubmit:h.handleSubmit(x),children:[r.jsx("div",{className:"py-4",children:C}),r.jsxs(Na,{children:[r.jsx(oe,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),r.jsx(oe,{type:"submit",disabled:h.formState.isSubmitting,className:"min-w-40",children:V})]})]})})]})})}function l1(t){const e=O.c(79),{mode:s,agentId:i,addedConnectionIds:n,onAdd:o,onCloneAndAdd:a,onConnectAndAdd:l,connectingItemId:c,search:d,onCreateConnection:u,onBrowseNavigate:h,defaultTab:f}=t,m=s===void 0?"add":s,p=f===void 0?"connected":f,{org:g}=_e(),_=j.useDeferredValue(d),b=d!==_;let x;e[0]!==_?(x=_.toLowerCase(),e[0]=_,e[1]=x):x=e[1];const v=x;let y;e[2]!==p?(y=pe=>pe??p,e[2]=p,e[3]=y):y=e[3];const[V,C]=Va(Ca.connectionsTab(g.slug)+(p==="all"?":home-modal":":agent-modal"),y);let S;e[4]!==V||e[5]!==C?(S=pe=>{pe!==V&&re("connections_dialog_tab_changed",{to_tab:pe}),C(pe)},e[4]=V,e[5]=C,e[6]=S):S=e[6];const w=S;let k;e[7]!==g.id?(k={connectionId:yt,orgId:g.id},e[7]=g.id,e[8]=k):k=e[8];const T=Ae(k);let M,I,E;if(e[9]!==T||e[10]!==_||e[11]!==g.id){E=_?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:_.trim()},{field:["description"],operator:"contains",value:_.trim()}]}:void 0;const pe={...E&&{where:E},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},ke=JSON.stringify(pe);I=Bp,M=Ze.collectionListInfinite(T,g.id,"","CONNECTIONS",ke),e[9]=T,e[10]=_,e[11]=g.id,e[12]=M,e[13]=I,e[14]=E}else M=e[12],I=e[13],E=e[14];let N;e[15]!==T||e[16]!==E?(N=async pe=>{const{pageParam:ke}=pe,st=ke===void 0?0:ke;return(await T.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...E&&{where:E},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:st}})).structuredContent},e[15]=T,e[16]=E,e[17]=N):N=e[17];let A;e[18]!==M||e[19]!==N?(A={queryKey:M,queryFn:N,initialPageParam:0,getNextPageParam:m1,staleTime:3e4},e[18]=M,e[19]=N,e[20]=A):A=e[20];const{data:D,fetchNextPage:L,hasNextPage:R,isFetchingNextPage:P}=I(A),B=D?.pages.flatMap(f1)??[],$=Rp(B),z=new Set(B.filter(u1).map(h1)),q=ah(),F=lh(q,_),K=jl(F.loadMore,F.hasMore,F.isLoadingMore),H=jl(L,R??!1,P),U=V==="all"||!!v,X=U?F.items.filter(pe=>{const ke=$p(pe);return!(ke&&z.has(ke))}):[],W=X.filter(d1),G=X.filter(c1);let se;e[21]!==n?(se=pe=>pe.some(ke=>n.has(ke.id)),e[21]=n,e[22]=se):se=e[22];const ee=se;let J;e[23]!==n||e[24]!==i||e[25]!==c||e[26]!==ee||e[27]!==m||e[28]!==o||e[29]!==h||e[30]!==a?(J=(pe,ke,st,zt,De)=>{const Yt=ee(De),At=De.find(Ct=>!n.has(Ct.id)),Et=De[0];if(m==="browse"){const Ct=nh(Et);return r.jsx(Xn,{connection:{title:ke,icon:st,description:De.length>1?`${De.length} instances`:zt??void 0},fallbackIcon:r.jsx(en,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsxs(Nl,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(Mt,{size:11})," Connected"]}),onClick:()=>{re("connection_browse_clicked",{app_name:Et.app_name??null,connection_id:Et.id,instances_count:De.length}),h?.(Ct)}},pe)}return r.jsx(Xn,{connection:{title:ke,icon:st,description:zt},fallbackIcon:r.jsx(en,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsxs("div",{className:"flex items-center gap-1.5",children:[Yt&&r.jsxs(Nl,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(Mt,{size:11})," Added"]}),r.jsx(oe,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Ct=>{Ct.stopPropagation(),At?(re("connection_add_clicked",{action:"use_existing",app_name:Et.app_name??null,connection_id:At.id}),i&&re("agent_connection_attached",{agent_id:i,connection_id:At.id,app_name:Et.app_name??null,mode:"existing"}),o(At.id)):(re("connection_add_clicked",{action:"clone",app_name:Et.app_name??null,base_connection_id:Et.id}),a(Et))},children:"Add"})]})},pe)},e[23]=n,e[24]=i,e[25]=c,e[26]=ee,e[27]=m,e[28]=o,e[29]=h,e[30]=a,e[31]=J):J=e[31];const ae=J;let Z;e[32]!==c||e[33]!==m||e[34]!==l?(Z=pe=>{const ke=pe._meta?.["mcp.mesh"],st=ke?.friendlyName||ke?.friendly_name||pe.server?.title||pe.title||pe.server?.name||pe.name||pe.id||"",zt=pe.server?.description||pe.description||null,De=pe.server?.icons?.[0]?.src||Fp(pe.server?.repository)||null;return r.jsx(Xn,{connection:{title:st,description:zt,icon:De},fallbackIcon:r.jsx(en,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsx(oe,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Yt=>{Yt.stopPropagation(),re("connection_add_clicked",{action:"connect_new",registry_item_id:pe.id,app_name:pe._meta?.["mcp.mesh"]?.friendlyName||pe.server?.name||pe.name||null}),l(pe)},children:c===pe.id?r.jsx(Ne,{size:14,className:"animate-spin"}):m==="browse"?"Connect":"Add"})},`catalog-${pe.id}`)},e[32]=c,e[33]=m,e[34]=l,e[35]=Z):Z=e[35];const de=Z;let me;e[36]!==V||e[37]!==w||e[38]!==u||e[39]!==v?(me=!v&&r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[r.jsx(ch,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:V,onTabChange:pe=>w(pe)}),r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{re("connections_dialog_custom_clicked"),u()},children:[r.jsx(Dt,{size:12}),"Custom Connection"]})]}),e[36]=V,e[37]=w,e[38]=u,e[39]=v,e[40]=me):me=e[40];const le=b&&"opacity-50 pointer-events-none";let he;e[41]!==le?(he=Y("flex-1 overflow-auto p-5 transition-opacity duration-150",le),e[41]=le,e[42]=he):he=e[42];const be="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let fe;e[43]!==ae?(fe=pe=>{if(pe.type==="group")return ae(pe.key,pe.title,pe.icon,null,pe.connections);const ke=pe.connection;return ae(ke.id,ke.title,ke.icon,ke.description??null,[ke])},e[43]=ae,e[44]=fe):fe=e[44];const ye=$.map(fe);let ve;e[45]!==H?(ve=r.jsx("div",{ref:H,className:"col-span-full h-1"}),e[45]=H,e[46]=ve):ve=e[46];let Ve;e[47]!==P?(Ve=P&&r.jsx("div",{className:"col-span-full flex justify-center py-6",children:r.jsx(Ne,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=P,e[48]=Ve):Ve=e[48];const Ie=U&&W.length>0&&r.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[r.jsx(_p,{size:13,className:"text-muted-foreground shrink-0"}),r.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),te=U&&W.map(de),ie=U&&G.length>0&&r.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[r.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),Ce=U&&G.map(de);let ze;e[49]!==K||e[50]!==q||e[51]!==U?(ze=U&&q.length>0&&r.jsx("div",{ref:K,className:"col-span-full h-1"}),e[49]=K,e[50]=q,e[51]=U,e[52]=ze):ze=e[52];let Fe;e[53]!==F.isLoadingMore||e[54]!==U?(Fe=U&&F.isLoadingMore&&r.jsx("div",{className:"col-span-full flex justify-center py-6",children:r.jsx(Ne,{size:24,className:"animate-spin text-muted-foreground"})}),e[53]=F.isLoadingMore,e[54]=U,e[55]=Fe):Fe=e[55];let ft;e[56]!==ye||e[57]!==ve||e[58]!==Ve||e[59]!==Ie||e[60]!==te||e[61]!==ie||e[62]!==Ce||e[63]!==ze||e[64]!==Fe?(ft=r.jsxs("div",{className:be,children:[ye,ve,Ve,Ie,te,ie,Ce,ze,Fe]}),e[56]=ye,e[57]=ve,e[58]=Ve,e[59]=Ie,e[60]=te,e[61]=ie,e[62]=Ce,e[63]=ze,e[64]=Fe,e[65]=ft):ft=e[65];let He;e[66]!==V||e[67]!==$.length||e[68]!==G||e[69]!==d||e[70]!==W?(He=$.length===0&&W.length===0&&G.length===0&&r.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:d?`No connections match "${d}"`:V==="connected"?"No connections yet":"No connections available"}),e[66]=V,e[67]=$.length,e[68]=G,e[69]=d,e[70]=W,e[71]=He):He=e[71];let tt;e[72]!==he||e[73]!==ft||e[74]!==He?(tt=r.jsxs("div",{className:he,children:[ft,He]}),e[72]=he,e[73]=ft,e[74]=He,e[75]=tt):tt=e[75];let ht;return e[76]!==me||e[77]!==tt?(ht=r.jsxs(r.Fragment,{children:[me,tt]}),e[76]=me,e[77]=tt,e[78]=ht):ht=e[78],ht}function c1(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function d1(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function h1(t){return t.app_name}function u1(t){return t.app_name}function f1(t){return t?.items??[]}function m1(t,e){if(t?.hasMore)return e.reduce(p1,0)}function p1(t,e){return t+(e?.items?.length??0)}function Qa({open:t,onOpenChange:e,defaultTab:s,initialSearch:i="",...n}){const o=n.mode??"add",a="agentId"in n?n.agentId:void 0,l="addedConnectionIds"in n?n.addedConnectionIds??new Set:new Set,c="onAdd"in n&&n.onAdd?n.onAdd:w=>{},d=(w,k,T)=>{a&&re("agent_connection_attached",{agent_id:a,connection_id:w,app_name:k,mode:T})},[u,h]=j.useState(null),[f,m]=j.useState(i),[p,g]=j.useState(!1),{org:_}=_e(),{data:b}=dt.useSession(),x=Mn(),v=bt(),y=Oe(),V=w=>{e(!1),y({to:"/$org/settings/connections/$appSlug",params:{org:_.slug,appSlug:w}})},C=async w=>{h(w.app_name??w.id);try{const T=`${w.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,I=(await x.create.mutateAsync({title:T,description:w.description??null,connection_type:w.connection_type,connection_url:w.connection_url??null,connection_token:null,icon:w.icon??null,app_name:w.app_name??null,app_id:w.app_id??null,connection_headers:w.connection_headers??null})).id,E=new URL(`/mcp/${I}`,window.location.origin),N=await Zi({url:E.href,token:null});if(N.supportsOAuth&&!N.isAuthenticated){const{token:A,tokenInfo:D,error:L}=await Yr({connectionId:I,scope:"offline_access"});if(L||!A){re("connection_oauth_failed",{connection_id:I,flow:"clone",error:L??"no_token"}),ue.error(`Authentication failed: ${L??"no token received"}`),await x.delete.mutateAsync(I);return}if(re("connection_oauth_succeeded",{connection_id:I,flow:"clone"}),D)try{(await fetch(`/api/connections/${I}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:D.accessToken,refreshToken:D.refreshToken,expiresIn:D.expiresIn,scope:D.scope,clientId:D.clientId,clientSecret:D.clientSecret,tokenEndpoint:D.tokenEndpoint})})).ok?await x.update.mutateAsync({id:I,data:{}}):await x.update.mutateAsync({id:I,data:{connection_token:A}})}catch{await x.update.mutateAsync({id:I,data:{connection_token:A}})}else await x.update.mutateAsync({id:I,data:{connection_token:A}});await v.invalidateQueries({queryKey:Ze.isMCPAuthenticated(E.href,null)})}d(I,w.app_name??null,"clone"),c(I)}catch(k){console.error("Failed to add connection:",k),ue.error("Failed to add connection")}finally{h(null)}},S=async w=>{if(!(!_||!b?.user?.id)){h(w.id);try{const k=zp(w,_.id,b.user.id,{remoteIndex:0}),T=k.connection_type==="STDIO",M=!!k.connection_url,I=T&&k.connection_headers&&typeof k.connection_headers=="object"&&"command"in k.connection_headers;if(!M&&!I){ue.error("This MCP Server cannot be connected: no connection method available"),h(null);return}const{id:E}=await x.create.mutateAsync(k),N=new URL(`/mcp/${E}`,window.location.origin),A=await Zi({url:N.href,token:null});if(A.supportsOAuth&&!A.isAuthenticated){const{token:D,tokenInfo:L,error:R}=await Yr({connectionId:E,scope:"offline_access"});if(R||!D){re("connection_oauth_failed",{connection_id:E,flow:"connect_new",error:R??"no_token"}),ue.error(`Authentication failed: ${R??"no token received"}`),d(E,k.app_name??null,"new"),c(E);return}if(re("connection_oauth_succeeded",{connection_id:E,flow:"connect_new"}),L)try{(await fetch(`/api/connections/${E}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:L.accessToken,refreshToken:L.refreshToken,expiresIn:L.expiresIn,scope:L.scope,clientId:L.clientId,clientSecret:L.clientSecret,tokenEndpoint:L.tokenEndpoint})})).ok?await x.update.mutateAsync({id:E,data:{}}):await x.update.mutateAsync({id:E,data:{connection_token:D}})}catch{await x.update.mutateAsync({id:E,data:{connection_token:D}})}else await x.update.mutateAsync({id:E,data:{connection_token:D}});await v.invalidateQueries({queryKey:Ze.isMCPAuthenticated(N.href,null)}),ue.success("Connected and authenticated")}else ue.success("Connected");d(E,k.app_name??null,"new"),c(E)}catch(k){console.error("Failed to connect:",k),ue.error("Failed to connect")}finally{h(null)}}};return r.jsxs(Bt,{open:t,onOpenChange:e,children:[r.jsxs(Ot,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[r.jsx(Gt,{className:"px-6 pt-5 pb-0 shrink-0",children:r.jsx(qt,{className:"text-base font-semibold",children:o==="browse"?"Connections":"Add Connection"})}),r.jsx("div",{className:"pt-3 shrink-0",children:r.jsx(Id,{value:f,onChange:m,placeholder:"Search connections..."})}),r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:24,className:"animate-spin text-muted-foreground"})}),children:r.jsx(l1,{mode:o,agentId:a,addedConnectionIds:l,onAdd:c,onCloneAndAdd:C,onConnectAndAdd:S,connectingItemId:u,search:f,onCreateConnection:()=>g(!0),onBrowseNavigate:V,defaultTab:s})})]}),r.jsx(a1,{open:p,onOpenChange:g,onCreated:async w=>{g(!1);const k=new URL(`/mcp/${w}`,window.location.origin),T=await Zi({url:k.href,token:null});if(T.supportsOAuth&&!T.isAuthenticated){const{token:M,tokenInfo:I,error:E}=await Yr({connectionId:w,scope:"offline_access"});if(E||!M){re("connection_oauth_failed",{connection_id:w,flow:"custom_create",error:E??"no_token"}),ue.error(`Authentication failed: ${E??"no token received"}`),await x.delete.mutateAsync(w);return}if(re("connection_oauth_succeeded",{connection_id:w,flow:"custom_create"}),I)try{(await fetch(`/api/connections/${w}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:I.accessToken,refreshToken:I.refreshToken,expiresIn:I.expiresIn,scope:I.scope,clientId:I.clientId,clientSecret:I.clientSecret,tokenEndpoint:I.tokenEndpoint})})).ok?await x.update.mutateAsync({id:w,data:{}}):await x.update.mutateAsync({id:w,data:{connection_token:M}})}catch{await x.update.mutateAsync({id:w,data:{connection_token:M}})}else await x.update.mutateAsync({id:w,data:{connection_token:M}});await v.invalidateQueries({queryKey:Ze.isMCPAuthenticated(k.href,null)})}d(w,null,"custom"),c(w),e(!1)}})]})}const g1=[{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 _1(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1",children:g1.map(x1)}),t[0]=e):e=t[0],e}function x1(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function v1(t){const e=O.c(6),{onClick:s}=t;let i,n,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Y("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),n=r.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=r.jsx(_1,{}),a=r.jsx($a,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=i,e[1]=n,e[2]=o,e[3]=a):(i=e[0],n=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=r.jsxs("button",{type:"button",onClick:s,className:i,children:[n,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const Ki=48;function b1(){const t=O.c(9),[e,s]=j.useState("idle"),[i,n]=j.useState(""),[o,a]=j.useState(""),[l,c]=j.useState(w1),d=j.useRef(null),u=j.useRef(null),h=j.useRef(null),f=j.useRef(null),m=j.useRef(0),p=j.useRef(!1),g=j.useRef(""),_=j.useRef(""),b=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let x;t[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),u.current?.close().catch(S1),f.current?.getTracks().forEach(y1),h.current=null,u.current=null,f.current=null},t[0]=x):x=t[0];const v=x;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const M=I=>{f.current=I;const E=new AudioContext;u.current=E;const N=E.createMediaStreamSource(I),A=E.createAnalyser();A.fftSize=128,A.smoothingTimeConstant=.8,N.connect(A),h.current=A;const D=new Uint8Array(A.frequencyBinCount),L=()=>{if(!h.current)return;h.current.getByteFrequencyData(D);const R=[];for(let P=0;P<Ki;P++){const B=Math.floor(P/Ki*D.length);R.push(Math.max(.04,(D[B]??0)/255))}c(R),m.current=requestAnimationFrame(L)};L()};y=async()=>{const I=window.SpeechRecognition||window.webkitSpeechRecognition;if(!I){s("unsupported");return}let E;try{E=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}n(""),a(""),_.current="",g.current="",p.current=!0,s("recording"),M(E);const N=new I;d.current=N,N.interimResults=!0,N.continuous=!0,N.lang=navigator.language||"en-US",N.onresult=A=>{let D="",L="";for(let R=A.resultIndex;R<A.results.length;R++){const P=A.results[R],B=P?.[0]?.transcript??"";P?.isFinal?L=L+B:D=D+B}L&&(g.current=g.current+L,n(g.current)),_.current=D,a(D)},N.onend=()=>{if(p.current)try{N.start()}catch{}};try{N.start()}catch{s("idle")}},t[1]=y}else y=t[1];const V=y;let C;t[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{p.current=!1,d.current?.stop(),v(),s("idle"),c(Array(Ki).fill(.05)),a("");const M=(g.current+(_.current?" "+_.current:"")).trim();return n(""),g.current="",_.current="",M},t[2]=C):C=t[2];const S=C;let w;t[3]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{p.current=!1,d.current?.abort(),v(),s("idle"),n(""),a(""),c(Array(Ki).fill(.05)),g.current="",_.current=""},t[3]=w):w=t[3];const k=w;let T;return t[4]!==o||t[5]!==e||t[6]!==i||t[7]!==l?(T={status:e,transcript:i,interimTranscript:o,waveformData:l,isSupported:b,startRecording:V,stopRecording:S,cancelRecording:k},t[4]=o,t[5]=e,t[6]=i,t[7]=l,t[8]=T):T=t[8],T}function y1(t){return t.stop()}function S1(){}function w1(){return Array(Ki).fill(.05)}function V1(t){const e=O.c(4),{data:s}=t;let i;e[0]!==s?(i=s.map(C1),e[0]=s,e[1]=i):i=e[1];let n;return e[2]!==i?(n=r.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:i}),e[2]=i,e[3]=n):n=e[3],n}function C1(t,e){return r.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}const to=[{value:"fast",label:"Fast",Icon:Fd,description:"Quicker responses"},{value:"smart",label:"Smart",Icon:Da,description:"Balanced quality"},{value:"thinking",label:"Thinking",Icon:Jm,description:"Deeper reasoning"}];function k1(t){const e=O.c(17),{tier:s,onSelect:i}=t;let n;e[0]!==s?(n=to.find(m=>m.value===s)??to[1],e[0]=s,e[1]=n):n=e[1];const o=n,a=o.Icon;let l;e[2]!==a?(l=r.jsx(a,{size:14}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o.label?(c=r.jsx("span",{className:"hidden sm:inline",children:o.label}),e[4]=o.label,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==c?(d=r.jsx(ds,{asChild:!0,children:r.jsxs(oe,{type:"button",variant:"ghost",size:"default",className:"text-muted-foreground hover:text-foreground",children:[l,c]})}),e[6]=l,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==i||e[10]!==s?(u=to.map(m=>{const{value:p,label:g,Icon:_,description:b}=m;return r.jsxs(Qe,{onSelect:()=>i(p),children:[r.jsx(_,{size:16,className:"text-muted-foreground"}),r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[r.jsx("span",{children:g}),r.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:b})]}),s===p&&r.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"On"})]},p)}),e[9]=i,e[10]=s,e[11]=u):u=e[11];let h;e[12]!==u?(h=r.jsx(hs,{align:"end",className:"w-52 p-1.5",children:u}),e[12]=u,e[13]=h):h=e[13];let f;return e[14]!==d||e[15]!==h?(f=r.jsxs(cs,{children:[d,h]}),e[14]=d,e[15]=h,e[16]=f):f=e[16],f}function j1(t,e){const s=O.c(5),{editor:i}=jn(),[n,o]=j.useState(!1),a=j.useRef(0);let l,c;return s[0]!==i||s[1]!==e||s[2]!==t?(l=()=>{const d=m=>{m.dataTransfer?.types.includes("Files")&&(m.preventDefault(),a.current=a.current+1,o(!0))},u=m=>{m.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},h=N1,f=m=>{if(m.preventDefault(),a.current=0,o(!1),!i||!t||!Tn(t))return;const p=m.dataTransfer?.files;if(!p||p.length===0)return;const{from:g}=i.state.selection;for(const _ of Array.from(p))Ya(i,t,_,g,e)};return window.addEventListener("dragenter",d),window.addEventListener("dragleave",u),window.addEventListener("dragover",h),window.addEventListener("drop",f),()=>{window.removeEventListener("dragenter",d),window.removeEventListener("dragleave",u),window.removeEventListener("dragover",h),window.removeEventListener("drop",f)}},c=[i,t,e],s[0]=i,s[1]=e,s[2]=t,s[3]=l,s[4]=c):(l=s[3],c=s[4]),j.useEffect(l,c),n}function N1(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function A1(t){const e=O.c(11),{selectedModel:s,onUnsupportedFile:i}=t,n=j1(s,i);let o;e[0]!==s?(o=Tn(s),e[0]=s,e[1]=o):o=e[1];const a=o,l=n?"opacity-100":"opacity-0 pointer-events-none",c=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let d;e[2]!==l||e[3]!==c?(d=Y("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",l,c),e[2]=l,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==s||e[6]!==a?(u=a?r.jsxs(r.Fragment,{children:[r.jsx(Jd,{size:24}),r.jsxs("span",{className:"text-sm font-medium",children:["Drop ",th(s)," here"]})]}):r.jsxs(r.Fragment,{children:[r.jsx(Xd,{size:24}),r.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=s,e[6]=a,e[7]=u):u=e[7];let h;return e[8]!==d||e[9]!==u?(h=r.jsx("div",{className:d,children:u}),e[8]=d,e[9]=u,e[10]=h):h=e[10],h}function E1({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const{messages:s,isStreaming:i,isRunInProgress:n,sendMessage:o,stop:a}=Ii(),{taskId:l,tasks:c}=Lt(),{selectedModel:d,selectedVirtualMcp:u,isModelsLoading:h,tiptapDocRef:f,imageModel:m,deepResearchModel:p,chatMode:g,setChatMode:_,simpleModeEnabled:b,simpleModeTier:x,setSimpleModeTier:v}=$s(),{data:y}=dt.useSession(),V=y?.user?.id,{org:C}=_e(),S=En(C.id).id,w=Lo(Vl),[k,T]=j.useState(!1),{unsupportedFile:M,onUnsupportedFile:I,clearUnsupportedFile:E}=O_(),N=b1(),A=j.useRef(void 0),D=async()=>{A.current=B,await N.startRecording();const Z=N.status==="recording"?"started":N.status==="unsupported"?"unsupported":N.status==="permission-denied"?"permission_denied":"unknown";re("chat_voice_started",{thread_id:l,outcome:Z})},L=()=>{re("chat_voice_confirmed",{thread_id:l});const Z=N.stopRecording();H.current?.syncVoiceText(A.current,Z),H.current?.focus()},R=()=>{re("chat_voice_cancelled",{thread_id:l}),N.cancelRecording(),H.current?.restoreContent(A.current)};j.useEffect(()=>{if(N.status!=="recording")return;const Z=(N.transcript+(N.interimTranscript?" "+N.interimTranscript:"")).trim();H.current?.syncVoiceText(A.current,Z)},[N.transcript,N.interimTranscript,N.status]);const P=c.find(Z=>Z.id===l),[B,$]=j.useState(void 0),z=Z=>{$(Z),f.current=Z},q=j.useRef(l);q.current!==l&&(q.current=l,$(void 0),f.current=void 0);const K=[...s].reverse().find(Z=>Z.role==="assistant")?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow,H=j.useRef(null),U=g==="plan";j.useEffect(()=>{const Z=de=>{Md(de)&&de.code==="KeyL"&&(de.preventDefault(),de.shiftKey&&_(g==="plan"?"default":"plan"),H.current?.focus())};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[g,_]);const X=Nd(s),W=[...s].reverse().find(Z=>Z.role==="assistant"&&Z.metadata?.usage)?.metadata?.usage,G=W?.contextTokens??(W?.totalTokens??0)-(W?.reasoningTokens??0),se=Lo(Vl),ee=!i&&!!d&&!h&&!$g(B),J=i||n,ae=Z=>{Z?.preventDefault(),i?(re("chat_message_stopped",{thread_id:l}),a()):n?(re("chat_message_stopped",{thread_id:l}),a()):ee&&B&&(re("chat_message_sent",{thread_id:l,mode:g,model_id:d?.modelId??null,model_provider:d?.providerId??null,virtual_mcp_id:u?.id??null,submission:Z?"button_or_enter":"programmatic"}),se(),o(B),z(void 0))};return V&&P?.created_by&&P.created_by!==V?r.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:[r.jsx(Xd,{size:14,className:"shrink-0"}),r.jsx("span",{className:"text-sm",children:"Read only — you're viewing someone else's thread"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col w-full justify-end",children:r.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&r.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),r.jsx(Ln,{}),r.jsx(qh,{tiptapDoc:B,setTiptapDoc:z,disabled:i||!d,enterToSubmit:!0,onSubmit:ae,children:r.jsxs("form",{onSubmit:ae,className:Y("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-background dark:bg-muted card-shadow"),children:[r.jsx(A1,{selectedModel:d,onUnsupportedFile:I}),r.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:r.jsx(Gh,{ref:H,disabled:i||!d||N.status==="recording",virtualMcpId:u?.id??S,showFileUploader:!0,selectedModel:d,onUnsupportedFile:I})}),r.jsx("div",{className:"flex items-center justify-between p-2.5 gap-1",children:N.status==="recording"?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsx(V1,{data:N.waveformData.slice(0,28)}),r.jsx("button",{type:"button",onClick:R,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:r.jsx(Es,{size:16})}),r.jsx("button",{type:"button",onClick:L,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:r.jsx(Mt,{size:16})})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:[r.jsx(R_,{selectedModel:d,isStreaming:i,icon:r.jsx(Dt,{size:16}),onUnsupportedFile:I}),r.jsx(r1,{disabled:i,onOpenConnections:()=>{re("connections_dialog_opened",{source:"tools_popover",mode:"add"}),T(!0)},virtualMcpId:u?.id??S}),U&&r.jsxs("button",{type:"button",onClick:()=>{w(),re("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[r.jsx(Yd,{size:14,className:"shrink-0"}),"Plan mode",r.jsx(Es,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="gen-image"&&m&&r.jsxs("button",{type:"button",onClick:()=>{w(),re("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[r.jsx(Io,{size:14,className:"shrink-0"}),r.jsx("span",{className:"max-w-[120px] truncate",children:b?"Create image":m.title.includes(": ")?m.title.split(": ").slice(1).join(": "):m.title}),r.jsx(Es,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="web-search"&&p&&r.jsxs("button",{type:"button",onClick:()=>{w(),re("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[r.jsx(vi,{size:14,className:"shrink-0"}),r.jsx("span",{className:"max-w-[120px] truncate",children:b?"Web search":p.title.includes(": ")?p.title.split(": ").slice(1).join(": "):p.title}),r.jsx(Es,{size:14,className:"shrink-0 hidden group-hover:block"})]}),K&&G>0&&r.jsx(ym,{usage:X,totalTokens:G,contextWindow:K,onOpenContextPanel:t})]}),r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[b?r.jsx(k1,{tier:x,onSelect:v}):r.jsx(sh,{placeholder:"Model",variant:"borderless",className:"h-8 text-sm py-2 min-w-0"}),N.isSupported&&!i&&!n&&r.jsx(oe,{type:"button",onClick:D,variant:"ghost",size:"icon",className:Y("size-8 rounded-lg transition-colors",N.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:N.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:r.jsx(Ym,{size:18})}),r.jsx(oe,{type:J?"button":"submit",onClick:Z=>{J&&(Z.preventDefault(),Z.stopPropagation(),a())},variant:ee||J?"default":"ghost",size:"icon",disabled:!ee&&!J,className:Y("size-8 rounded-lg transition-all",!ee&&!J&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:i?"Stop generating":n?"Cancel run":"Send message (Enter)",children:J?r.jsx(Xm,{size:20}):r.jsx(Od,{size:20})})]})]})})]})},l),e&&r.jsx(v1,{onClick:()=>{re("connections_banner_clicked",{source:"home_chat_input"}),re("connections_dialog_opened",{source:"home_banner",mode:"add"}),T(!0)}})]})}),r.jsx(Qa,{mode:"browse",open:k,onOpenChange:T,defaultTab:"all"}),r.jsx(D_,{info:M,onClose:E})]})}const I1={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 Yh(t){return`deco-credits-empty-dismissed:${t}`}function T1(t){try{return localStorage.getItem(Yh(t))==="1"}catch{return!1}}function R1(){const t=O.c(49),{org:e}=_e(),s=Oe(),{decoKeyId:i}=Pn();let n;t[0]!==e.id?(n={connectionId:yt,orgId:e.id},t[0]=e.id,t[1]=n):n=t[1];const o=Ae(n),[a,l]=j.useState(!0),[c,d]=j.useState(""),[u,h]=j.useState(!1),[f,m]=j.useState("usd"),p=f==="brl"?"R$":"$";let g;t[2]!==e.id?(g=()=>{re("credits_empty_state_dismissed",{organization_id:e.id}),l(!1);try{localStorage.setItem(Yh(e.id),"1")}catch{}},t[2]=e.id,t[3]=g):g=t[3];const _=g;let b,x;t[4]!==a||t[5]!==e.id?(b=()=>{a&&re("credits_empty_state_shown",{organization_id:e.id})},x=[a,e.id],t[4]=a,t[5]=e.id,t[6]=b,t[7]=x):(b=t[6],x=t[7]),j.useEffect(b,x);let v;t[8]!==o||t[9]!==f?(v=async z=>{const q=await o.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:z,currency:f}});if(q?.isError)throw new Error(q.content?.[0]?.text??"Failed to get top-up URL");return q.structuredContent?.url},t[8]=o,t[9]=f,t[10]=v):v=t[10];let y;t[11]!==_?(y=z=>{z&&window.open(z,"_blank","noopener,noreferrer"),_()},t[11]=_,t[12]=y):y=t[12];let V;t[13]!==v||t[14]!==y?(V={mutationFn:v,onSuccess:y,onError:D1},t[13]=v,t[14]=y,t[15]=V):V=t[15];const{mutate:C,isPending:S}=Ni(V),w=parseFloat(c),k=!isNaN(w)&&w>=1;if(!a)return null;let T;t[16]!==_?(T=z=>!z&&_(),t[16]=_,t[17]=T):T=t[17];let M;t[18]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-amber-500/8 to-transparent pointer-events-none rounded-t-lg"}),t[18]=M):M=t[18];let I;t[19]===Symbol.for("react.memo_cache_sentinel")?(I=r.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:r.jsx(Ta,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[19]=I):I=t[19];let E;t[20]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[M,r.jsxs(Gt,{className:"relative gap-3",children:[I,r.jsxs("div",{className:"text-center",children:[r.jsx(qt,{className:"text-lg font-semibold",children:"This workspace has no credits"}),r.jsx(Nn,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:"Your free credits were used in another workspace. Add credits to use AI here."})]})]})]}),t[20]=E):E=t[20];let N;t[21]!==f||t[22]!==p||t[23]!==c||t[24]!==w||t[25]!==i||t[26]!==k||t[27]!==S||t[28]!==u||t[29]!==C?(N=i&&r.jsxs("div",{className:"px-6 pb-5",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(Zd,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:z=>{z&&m(z)},children:[r.jsx(un,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(un,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:I1[f].map(z=>{const{dollars:q,label:F}=z;return r.jsxs("button",{type:"button",disabled:S,onClick:()=>{re("credits_topup_clicked",{amount_cents:q*100,currency:f,tier_label:F,source:"empty_state"}),C(q*100)},className:Y("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:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,q]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:F})]},q)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(at,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:z=>d(z.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(oe,{className:"h-10",disabled:!k||S,onClick:()=>{re("credits_topup_clicked",{amount_cents:Math.round(w*100),currency:f,tier_label:"custom",source:"empty_state"}),C(Math.round(w*100))},children:S?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),t[21]=f,t[22]=p,t[23]=c,t[24]=w,t[25]=i,t[26]=k,t[27]=S,t[28]=u,t[29]=C,t[30]=N):N=t[30];let A;t[31]!==_||t[32]!==s||t[33]!==e.slug?(A=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),_()},t[31]=_,t[32]=s,t[33]=e.slug,t[34]=A):A=t[34];let D;t[35]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(In,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[35]=D):D=t[35];let L;t[36]!==A?(L=r.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:A,children:["Use your own provider",D]}),t[36]=A,t[37]=L):L=t[37];let R;t[38]!==_?(R=r.jsx(oe,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:_,children:"Skip for now"}),t[38]=_,t[39]=R):R=t[39];let P;t[40]!==L||t[41]!==R?(P=r.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[L,R]}),t[40]=L,t[41]=R,t[42]=P):P=t[42];let B;t[43]!==N||t[44]!==P?(B=r.jsxs(Ot,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:M1,children:[E,N,P]}),t[43]=N,t[44]=P,t[45]=B):B=t[45];let $;return t[46]!==B||t[47]!==T?($=r.jsx(Bt,{open:!0,onOpenChange:T,children:B}),t[46]=B,t[47]=T,t[48]=$):$=t[48],$}function M1(t){return t.preventDefault()}function D1(t){ue.error(`Top-up failed: ${t.message}`)}function P1(t){const e=O.c(6),{balanceDollars:s}=t;let i;e[0]!==s?(i=s.toFixed(2),e[0]=s,e[1]=i):i=e[1];const n=i;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=Y("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=r.jsx(Ta,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==n?(l=r.jsxs("div",{className:o,children:[a,r.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",n," in credits to get started"]})]}),e[4]=n,e[5]=l):l=e[5],l}function L1(){const t=O.c(8),{org:e}=_e(),s=Oe();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 n,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=Y("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=r.jsx(Bs,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=r.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=n,t[4]=o,t[5]=a):(n=t[3],o=t[4],a=t[5]);let l;return t[6]!==i?(l=r.jsxs("button",{type:"button",onClick:i,className:n,children:[o,a]}),t[6]=i,t[7]=l):l=t[7],l}function O1(t){const e=O.c(11),{className:s}=t;let i;e[0]!==s?(i=Y("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=i):i=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=n):n=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("div",{className:"flex items-center gap-3",children:[n,r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),r.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=r.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:r.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),r.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[r.jsx(Or,{align:"right",width:"w-3/4"}),r.jsx(Or,{align:"left",width:"w-full",lines:3}),r.jsx(Or,{align:"right",width:"w-2/3"}),r.jsx(Or,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:r.jsx("div",{className:"relative flex-1",children:r.jsxs("div",{className:"space-y-2 p-2",children:[r.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),r.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"px-4 py-4",children:r.jsx("div",{className:"mx-auto w-full max-w-2xl",children:r.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),r.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=u):u=e[8];let h;return e[9]!==i?(h=r.jsxs("div",{className:i,children:[a,l,u]}),e[9]=i,e[10]=h):h=e[10],h}function Or(t){const e=O.c(22),{align:s,width:i,lines:n}=t,o=i===void 0?"w-full":i,a=n===void 0?1:n,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=Y("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=c):c=e[1];const d=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let u;e[2]!==d?(u=Y("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=u):u=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=h):h=e[4];const f=s==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==f||e[6]!==o?(m=Y("min-w-0 rounded-2xl p-4",f,o),e[5]=f,e[6]=o,e[7]=m):m=e[7];let p;e[8]!==a?(p=Array.from({length:a}),e[8]=a,e[9]=p):p=e[9];let g;e[10]!==a||e[11]!==p?(g=r.jsx("div",{className:"space-y-2",children:p.map((v,y)=>r.jsx("div",{className:Y("h-3 rounded bg-muted-foreground/20 animate-pulse",y===a-1?"w-3/4":"w-full"),style:{animationDelay:`${y*.1}s`}},y))}),e[10]=a,e[11]=p,e[12]=g):g=e[12];let _;e[13]!==g||e[14]!==m?(_=r.jsx("div",{className:m,children:g}),e[13]=g,e[14]=m,e[15]=_):_=e[15];let b;e[16]!==_||e[17]!==u?(b=r.jsxs("div",{className:u,children:[h,_]}),e[16]=_,e[17]=u,e[18]=b):b=e[18];let x;return e[19]!==b||e[20]!==c?(x=r.jsx("div",{className:c,children:b}),e[19]=b,e[20]=c,e[21]=x):x=e[21],x}function B1(t){const e=O.c(5),{className:s,children:i}=t;let n;e[0]!==s?(n=Y("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=n):n=e[1];let o;return e[2]!==i||e[3]!==n?(o=r.jsx("div",{className:n,children:i}),e[2]=i,e[3]=n,e[4]=o):o=e[4],o}function $1(t){const e=O.c(5),{children:s,className:i}=t;let n;e[0]!==i?(n=Y("flex-1 min-h-0 overflow-y-auto isolate",i),e[0]=i,e[1]=n):n=e[1];let o;return e[2]!==s||e[3]!==n?(o=r.jsx("div",{className:n,children:s}),e[2]=s,e[3]=n,e[4]=o):o=e[4],o}function z1(t){const e=O.c(2),{children:s}=t;let i;return e[0]!==s?(i=r.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 F1(){const t=O.c(16),{messages:e,status:s}=Ii(),i=Sm(e);let n;t[0]!==i?(n=i.at(-1),t[0]=i,t[1]=n):n=t[1];const o=n,a=s==="submitted"||s==="streaming";let l;if(t[2]!==a||t[3]!==o||t[4]!==i||t[5]!==e||t[6]!==s){const c=e.at(-1),d=!a&&c?.role==="assistant"&&c.parts.filter(W1).some(H1),u=!a&&c?.role==="assistant"&&c.parts.some(U1);let h;if(t[8]!==i||t[9]!==s){let m;t[11]!==i.length||t[12]!==s?(m=(p,g)=>r.jsx(_l,{pair:p,isLastPair:!1,status:g===i.length-1?s:void 0},`pair-${p.user.id}`),t[11]=i.length,t[12]=s,t[13]=m):m=t[13],h=i.slice(0,-1).map(m),t[8]=i,t[9]=s,t[10]=h}else h=t[10];let f;t[14]!==h?(f=r.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:h}),t[14]=h,t[15]=f):f=t[15],l=r.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[f,o&&r.jsx("div",{className:Y("min-h-full min-w-0 max-w-2xl mx-auto w-full",(d||u)&&"pb-60"),children:r.jsx(_l,{pair:o,isLastPair:!0,status:s},`pair-${o?.user.id}`)})]}),t[2]=a,t[3]=o,t[4]=i,t[5]=e,t[6]=s,t[7]=l}else l=t[7];return l}function U1(t){return"state"in t&&t.state==="approval-requested"}function H1(t){return t.state==="input-available"}function W1(t){return t.type==="tool-user_ask"}function K1(t){const e=O.c(5),{children:s,className:i}=t;let n;e[0]!==i?(n=Y("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",i),e[0]=i,e[1]=n):n=e[1];let o;return e[2]!==s||e[3]!==n?(o=r.jsx("div",{className:n,children:s}),e[2]=s,e[3]=n,e[4]=o):o=e[4],o}const Ee=Object.assign(B1,{Main:$1,Messages:F1,EmptyState:z1,Footer:K1,Input:E1,Provider:fm,ActiveTaskProvider:um,Skeleton:O1,IceBreakers:Yg,NoAiProviderEmptyState:Sp,CreditsEmptyState:R1,CreditsEyebrow:P1,NoCreditsEyebrow:L1,CreditsExhaustedBanner:Th}),q1=`You are an image generator agent. Every request of the user is somewhat related to creating, editing or varying an image. You have access to image generation tools
|
|
5
5
|
|
|
@@ -545,7 +545,7 @@ target:
|
|
|
545
545
|
• One issue per { kind, target.route } pair. Dedup uses those two fields from the body frontmatter.
|
|
546
546
|
• Always normalize route: lowercase host, no trailing slash (except "/"), no query string, no fragment.`)])),{type:"doc",content:c.map((d,u)=>u<c.length-1?rv(d):d)}}function rv(t){const e=t.content;if(!e||e.length===0)return t;const s=e[e.length-1];return!s||s.type!=="text"||typeof s.text!="string"?t:{...t,content:[...e.slice(0,-1),{...s,text:`${s.text}
|
|
547
547
|
|
|
548
|
-
`}]}}function Ws(t){return{type:"paragraph",content:t}}function Cs(t){return{type:"text",text:t}}function nv({agentId:t,title:e}){return{type:"mention",attrs:{id:t,name:e,char:"@",metadata:{agentId:t,title:e}}}}const qi="deco/site-diagnostics";function Qh(t){const e=O.c(15),{open:s,onOpenChange:i}=t,[n,o]=j.useState(null);let a;e[0]!==i?(a=()=>{o(null),i(!1)},e[0]=i,e[1]=a):a=e[1];const l=a,c=s&&n===null;let d;e[2]!==n||e[3]!==i?(d=p=>{!p&&n===null&&i(!1)},e[2]=n,e[3]=i,e[4]=d):d=e[4];let u;e[5]!==c||e[6]!==d?(u=r.jsx(hh,{open:c,onOpenChange:d,title:"Set up self-healing repo",hideAutoRespondCheckbox:!0,onImportComplete:o}),e[5]=c,e[6]=d,e[7]=u):u=e[7];const h=s&&n!==null;let f;e[8]!==l||e[9]!==n||e[10]!==h?(f=r.jsx(ov,{open:h,payload:n,onClose:l}),e[8]=l,e[9]=n,e[10]=h,e[11]=f):f=e[11];let m;return e[12]!==u||e[13]!==f?(m=r.jsxs(r.Fragment,{children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14],m}function ov(t){const e=O.c(66),{open:s,payload:i,onClose:n}=t,{org:o}=_e(),a=Sr(),l=Mn();let c;e[0]!==o.id?(c={connectionId:yt,orgId:o.id},e[0]=o.id,e[1]=c):c=e[1];const d=Ae(c),[u,h]=j.useState(""),[f,m]=j.useState(cv);let p;e[2]!==s?(p={enabled:s},e[2]=s,e[3]=p):p=e[3];const{data:g}=Hp(qi,p);let _;e[4]!==l||e[5]!==f||e[6]!==i||e[7]!==d||e[8]!==g||e[9]!==u?(_=async()=>{if(!i)throw new Error("No imported repo payload");const X=Zl(u);if(!X)throw new Error("Enter a valid https:// URL");const W=Oo.filter(J=>f[J.id]);if(W.length===0)return{succeeded:[],failed:[]};const G=await fv({selfClient:d,createConnection:l.create.mutateAsync,registry:g}),se=[],ee=[];for(const J of W)try{await mv({template:J,selfClient:d,siteDiagnosticsConnectionId:G,projectAgentId:i.virtualMcpId,owner:i.repo.owner,repo:i.repo.name,siteRootUrl:X}),se.push(J.title)}catch(ae){const Z=ae;console.error(`Failed to set up ${J.title}:`,Z),ee.push(J.title)}return{succeeded:se,failed:ee}},e[4]=l,e[5]=f,e[6]=i,e[7]=d,e[8]=g,e[9]=u,e[10]=_):_=e[10];let b;e[11]!==a||e[12]!==n||e[13]!==i?.virtualMcpId?(b=X=>{const{succeeded:W,failed:G}=X;W.length>0?ue.success(`Self-healing repo ready — ${W.length} specialist${W.length>1?"s":""} set up`):G.length===0&&ue.success("Repo imported. Add specialists later from automations."),G.length>0&&ue.warning(`Could not set up: ${G.join(", ")}. You can add them later from the automations view.`);const se=i?.virtualMcpId;n(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),se&&a(se)},e[11]=a,e[12]=n,e[13]=i?.virtualMcpId,e[14]=b):b=e[14];let x;e[15]!==_||e[16]!==b?(x={mutationFn:_,onSuccess:b,onError:lv},e[15]=_,e[16]=b,e[17]=x):x=e[17];const v=Ni(x);let y;e[18]!==v.isPending||e[19]!==u?(y=Zl(u)!==null&&!v.isPending,e[18]=v.isPending,e[19]=u,e[20]=y):y=e[20];const V=y;let C;e[21]!==n||e[22]!==v.isPending?(C=X=>{!X&&!v.isPending&&n()},e[21]=n,e[22]=v.isPending,e[23]=C):C=e[23];let S;e[24]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Gt,{className:"h-12 border-b border-border px-4 flex flex-row items-center shrink-0 space-y-0",children:r.jsx(qt,{className:"text-sm font-medium text-foreground",children:"Add specialist monitors"})}),e[24]=S):S=e[24];let w;e[25]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Specialists run on a daily schedule. Your repo agent collects their findings and opens GitHub issues, then writes the fixes."}),e[25]=w):w=e[25];let k;e[26]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("label",{htmlFor:"self-healing-site-url",className:"text-xs font-medium text-foreground",children:"Production URL"}),e[26]=k):k=e[26];let T;e[27]===Symbol.for("react.memo_cache_sentinel")?(T=X=>h(X.target.value),e[27]=T):T=e[27];let M;e[28]!==u?(M=r.jsx(at,{id:"self-healing-site-url",type:"url",placeholder:"https://example.com",value:u,onChange:T,autoFocus:!0}),e[28]=u,e[29]=M):M=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("p",{className:"text-xs text-muted-foreground",children:"The site the specialists will monitor."}),e[30]=I):I=e[30];let E;e[31]!==M?(E=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[k,M,I]}),e[31]=M,e[32]=E):E=e[32];let N;e[33]!==f?(N=Oo.map(X=>r.jsx(dv,{template:X,enabled:f[X.id]??!1,onToggle:W=>m(G=>({...G,[X.id]:W}))},X.id)),e[33]=f,e[34]=N):N=e[34];let A,D;e[35]===Symbol.for("react.memo_cache_sentinel")?(A=sv.map(av),D=r.jsx(uv,{}),e[35]=A,e[36]=D):(A=e[35],D=e[36]);let L;e[37]!==N?(L=r.jsxs("div",{className:"flex flex-col gap-2",children:[N,A,D]}),e[37]=N,e[38]=L):L=e[38];let R;e[39]!==E||e[40]!==L?(R=r.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 flex flex-col gap-4",children:[w,E,L]}),e[39]=E,e[40]=L,e[41]=R):R=e[41];let P;e[42]!==a||e[43]!==n||e[44]!==i?.virtualMcpId||e[45]!==v.isPending?(P=()=>{if(!v.isPending){const X=i?.virtualMcpId;n(),X&&a(X)}},e[42]=a,e[43]=n,e[44]=i?.virtualMcpId,e[45]=v.isPending,e[46]=P):P=e[46];let B;e[47]!==v.isPending||e[48]!==P?(B=r.jsx("button",{type:"button",onClick:P,disabled:v.isPending,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 cursor-pointer",children:"Skip for now"}),e[47]=v.isPending,e[48]=P,e[49]=B):B=e[49];let $;e[50]!==v?($=()=>v.mutate(),e[50]=v,e[51]=$):$=e[51];const z=!V,q=v.isPending?"Setting up...":"Set up specialists";let F;e[52]!==$||e[53]!==z||e[54]!==q?(F=r.jsx(oe,{onClick:$,disabled:z,size:"sm",children:q}),e[52]=$,e[53]=z,e[54]=q,e[55]=F):F=e[55];let K;e[56]!==B||e[57]!==F?(K=r.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center justify-between gap-3 shrink-0",children:[B,F]}),e[56]=B,e[57]=F,e[58]=K):K=e[58];let H;e[59]!==R||e[60]!==K?(H=r.jsxs(Ot,{className:"sm:max-w-[560px] max-h-[85svh] p-0 gap-0 overflow-hidden flex flex-col",children:[S,R,K]}),e[59]=R,e[60]=K,e[61]=H):H=e[61];let U;return e[62]!==s||e[63]!==H||e[64]!==C?(U=r.jsx(Bt,{open:s,onOpenChange:C,children:H}),e[62]=s,e[63]=H,e[64]=C,e[65]=U):U=e[65],U}function av(t){return r.jsx(hv,{title:t.title,description:t.description,icon:t.icon},t.id)}function lv(t){ue.error("Failed to set up specialists: "+(t instanceof Error?t.message:"Unknown error"))}function cv(){const t={};for(const e of Oo)t[e.id]=!0;return t}function dv(t){const e=O.c(20),{template:s,enabled:i,onToggle:n}=t,o=i?"bg-accent/30":"hover:bg-accent/30";let a;e[0]!==o?(a=Y("flex items-center gap-3 rounded-lg border border-border px-3 py-3 cursor-pointer transition-colors",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==s.icon||e[3]!==s.title?(l=r.jsx(Qt,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=l):l=e[4];let c;e[5]!==s.title?(c=r.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s.title}),e[5]=s.title,e[6]=c):c=e[6];let d;e[7]!==s.description?(d=r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[7]=s.description,e[8]=d):d=e[8];let u;e[9]!==c||e[10]!==d?(u=r.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[c,d]}),e[9]=c,e[10]=d,e[11]=u):u=e[11];let h;e[12]!==i||e[13]!==n?(h=r.jsx(mn,{checked:i,onCheckedChange:n,className:"shrink-0"}),e[12]=i,e[13]=n,e[14]=h):h=e[14];let f;return e[15]!==a||e[16]!==l||e[17]!==u||e[18]!==h?(f=r.jsxs("label",{className:a,children:[l,u,h]}),e[15]=a,e[16]=l,e[17]=u,e[18]=h,e[19]=f):f=e[19],f}function hv(t){const e=O.c(14),{title:s,description:i,icon:n}=t;let o;e[0]!==n||e[1]!==s?(o=r.jsx(Qt,{icon:n,name:s,size:"sm",className:"shrink-0"}),e[0]=n,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==s?(a=r.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s}),e[3]=s,e[4]=a):a=e[4];let l;e[5]!==i?(l=r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:i}),e[5]=i,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==l?(c=r.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a,l]}),e[7]=a,e[8]=l,e[9]=c):c=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground shrink-0",children:"Coming soon"}),e[10]=d):d=e[10];let u;return e[11]!==o||e[12]!==c?(u=r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-dashed border-border px-3 py-3 opacity-60",children:[o,c,d]}),e[11]=o,e[12]=c,e[13]=u):u=e[13],u}function uv(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center justify-center rounded-lg border border-dashed border-border px-3 py-3 text-xs text-muted-foreground",children:"More specialists coming soon"}),t[0]=e):e=t[0],e}function Zl(t){const e=t.trim();if(!e)return null;try{const s=new URL(e);return s.protocol!=="https:"&&s.protocol!=="http:"?null:s.origin+(s.pathname==="/"?"":s.pathname)}catch{return null}}async function fv({selfClient:t,createConnection:e,registry:s}){const n=(await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:qi},limit:1,offset:0}})).structuredContent?.items?.find(u=>u.app_id===qi);if(n)return n.id;const o=s?.server?.remotes?.[0]?.url;if(!o)throw new Error("Site Diagnostics MCP is not available in the registry right now.");const a=s?.title??s?.server?.title??s?.server?.name??"Site Diagnostics",l=s?.server?.icons?.[0]?.src??null,c=s?.server?.description??null;return(await e({title:a,description:c,icon:l,connection_type:"HTTP",connection_url:o,app_name:s?.server?.name??"site-diagnostics",app_id:qi,metadata:{type:"site-diagnostics",source:"store",registry_item_id:qi,verified:!0}})).id}async function mv({template:t,selfClient:e,siteDiagnosticsConnectionId:s,projectAgentId:i,owner:n,repo:o,siteRootUrl:a}){const l=`${o}: ${t.title}`,d=(await e.callTool({name:"AUTOMATION_LIST",arguments:{virtual_mcp_id:i}})).structuredContent?.automations?.find(h=>h.name===l);let u;if(!(d&&d.trigger_count>0)){if(d)u=d.id;else{const h=await pv({template:t,selfClient:e,siteDiagnosticsConnectionId:s}),f=iv({template:t,specialistAgentId:h,owner:n,repo:o,siteRootUrl:a}),m=jd(f),p=await e.callTool({name:"AUTOMATION_CREATE",arguments:{name:l,virtual_mcp_id:i,agent:{id:i},messages:m,active:!0}});u=(p.structuredContent??p).id}await e.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:u,type:"cron",cron_expression:t.cron}})}}async function pv({template:t,selfClient:e,siteDiagnosticsConnectionId:s}){const n=(await e.callTool({name:"COLLECTION_VIRTUAL_MCP_LIST",arguments:{where:{field:["metadata","specialistId"],operator:"eq",value:t.id},limit:1,offset:0}})).structuredContent?.items?.find(l=>l.metadata?.specialistId===t.id);if(n)return n.id;const o=await e.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:t.title,description:t.description,icon:t.icon,pinned:!1,metadata:{specialistId:t.id,instructions:t.instructions},connections:[{connection_id:s,selected_tools:t.siteDiagnosticsTools,selected_resources:null,selected_prompts:null}]}}});return(o.structuredContent??o).item.id}function gv(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}const _v=8;function ec(t){const e=O.c(21),{agent:s,onSpecialClick:i,tracking:n}=t,{org:o}=_e(),a=Oe();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==n.action||e[6]!==n.template_id||e[7]!==n.tile_kind?(l=()=>{if(re("home_agent_tile_clicked",{template_id:n.template_id,agent_id:s.id,agent_title:s.title,tile_kind:n.tile_kind,action:n.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=n.action,e[6]=n.template_id,e[7]=n.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Dn,{size:24}),e[10]=h):h=e[10];let f;e[11]!==s.icon||e[12]!==s.title?(f=r.jsx(ps,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=f):f=e[13];let m;e[14]!==s.title?(m=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=m):m=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==f||e[19]!==m?(p=r.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[f,m]}),e[16]=c,e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20],p}function xv(){const t=O.c(8),e=Oe(),{org:s}=_e();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let n;t[1]!==e||t[2]!==s.slug?(n=()=>{re("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=n):n=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx($a,{size:20,className:"text-foreground"})}),a=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==n?(l=r.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:n,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function vv(){const t=O.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=_h(e);let n;t[1]!==s?(n=()=>{re("home_create_agent_clicked"),s()},t[1]=s,t[2]=n):n=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Dt,{size:20,className:"text-muted-foreground"})}),l=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==n?(c=r.jsxs("button",{type:"button",onClick:n,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=n,t[8]=c):c=t[8],c}function Br(t,e,s){return t.find(i=>i.id!==null&&(i.metadata?.type===e||i.title===s))}function bv(){const t=O.c(52),e=Rn(),{locator:s}=_e(),i=Up(),[n,o]=j.useState(!1),[a,l]=j.useState(!1),[c,d]=j.useState(!1),[u,h]=j.useState(!1),[f,m]=j.useState(!1),[p,g]=j.useState(!1),[_,b]=j.useState(!1),[x]=ei(),v=Sr();let y,V,C,S,w,k,T,M;if(t[0]!==s||t[1]!==v||t[2]!==i||t[3]!==x||t[4]!==e){const F=jt.find(Tv),K=jt.find(Iv),H=jt.find(Ev),U=jt.find(Av),X=jt.find(Nv),W=jt.find(jv),G=jt.find(kv);C=Br(e,K.id,K.title),y=Br(e,H.id,H.title),V=Br(e,U.id,U.title),S=Br(e,X.id,X.title);const se=Z=>{if(Z===F.id)return{key:Z,kind:"template-recruit",templateId:"site-editor",agent:F,onClick:"import-deco"};if(Z===K.id)return C?{key:C.id,kind:"existing",templateId:"site-diagnostics",agent:C}:{key:Z,kind:"template-recruit",templateId:"site-diagnostics",agent:K,onClick:"diagnostics"};if(Z===H.id)return y?{key:y.id,kind:"existing",templateId:"ai-image",agent:y}:{key:Z,kind:"template-recruit",templateId:"ai-image",agent:H,onClick:"ai-image"};if(Z===X.id)return S?{key:S.id,kind:"existing",templateId:"lean-canvas",agent:S}:{key:Z,kind:"template-recruit",templateId:"lean-canvas",agent:X,onClick:"lean-canvas"};if(Z===W.id)return{key:Z,kind:"template-recruit",templateId:"studio-pack",agent:W,onClick:"studio-pack"};if(Z===G.id)return x.experimental_vibecode?{key:Z,kind:"template-recruit",templateId:"self-healing-storefront",agent:G,onClick:"self-healing"}:null;if(Z===U.id)return V?{key:V.id,kind:"existing",templateId:"ai-research",agent:V}:{key:Z,kind:"template-recruit",templateId:"ai-research",agent:U,onClick:"ai-research"};const de=e.find(me=>me.id!==null&&me.id===Z&&!lr(me.id));return de?{key:de.id,kind:"existing",templateId:null,agent:de}:null};let ee;if(i?.ids)ee=i.ids.map(se).filter(Cv).slice(0,_v);else{const de=[F.id,G.id,K.id,H.id,U.id].map(se).filter(Vv),me=gv(s),le=e.filter(wv).filter(he=>he.id!==C?.id&&he.id!==y?.id&&he.id!==V?.id).sort((he,be)=>{const fe=me.indexOf(he.id),ye=me.indexOf(be.id);return fe!==-1&&ye!==-1?fe-ye:fe!==-1?-1:ye!==-1?1:new Date(be.updated_at).getTime()-new Date(he.updated_at).getTime()}).slice(0,4).map(Sv);ee=[...de,...le]}w=ee.some(yv);let J;t[13]!==v?(J=Z=>{if(Z.kind==="template-recruit"){const de={"import-deco":()=>o(!0),diagnostics:()=>l(!0),"ai-image":()=>d(!0),"ai-research":()=>h(!0),"lean-canvas":()=>m(!0),"studio-pack":()=>g(!0),"self-healing":()=>b(!0)}[Z.onClick];return r.jsx(ec,{agent:Z.agent,onSpecialClick:de,tracking:{template_id:Z.templateId,tile_kind:"template",action:"open_modal"}},Z.key)}return r.jsx(ec,{agent:Z.agent,onSpecialClick:()=>v(Z.agent.id),tracking:{template_id:Z.templateId,tile_kind:Z.templateId?"existing":"recent",action:"navigate"}},Z.key)},t[13]=v,t[14]=J):J=t[14];const ae=J;M="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",k="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",T=ee.map(ae),t[0]=s,t[1]=v,t[2]=i,t[3]=x,t[4]=e,t[5]=y,t[6]=V,t[7]=C,t[8]=S,t[9]=w,t[10]=k,t[11]=T,t[12]=M}else y=t[5],V=t[6],C=t[7],S=t[8],w=t[9],k=t[10],T=t[11],M=t[12];let I;t[15]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(vv,{}),t[15]=I):I=t[15];let E;t[16]!==w?(E=w&&r.jsx(xv,{}),t[16]=w,t[17]=E):E=t[17];let N;t[18]!==k||t[19]!==T||t[20]!==E?(N=r.jsxs("div",{className:k,children:[T,I,E]}),t[18]=k,t[19]=T,t[20]=E,t[21]=N):N=t[21];let A;t[22]!==M||t[23]!==N?(A=r.jsx("div",{className:M,children:N}),t[22]=M,t[23]=N,t[24]=A):A=t[24];let D;t[25]!==n?(D=r.jsx(fn,{open:n,onOpenChange:o}),t[25]=n,t[26]=D):D=t[26];let L;t[27]!==a||t[28]!==C?(L=r.jsx(uh,{open:a,onOpenChange:l,existingAgent:C}),t[27]=a,t[28]=C,t[29]=L):L=t[29];let R;t[30]!==c||t[31]!==y?(R=r.jsx(Xh,{open:c,onOpenChange:d,existingAgent:y}),t[30]=c,t[31]=y,t[32]=R):R=t[32];let P;t[33]!==u||t[34]!==V?(P=r.jsx(Jh,{open:u,onOpenChange:h,existingAgent:V}),t[33]=u,t[34]=V,t[35]=P):P=t[35];let B;t[36]!==S||t[37]!==f?(B=r.jsx(fh,{open:f,onOpenChange:m,existingAgent:S}),t[36]=S,t[37]=f,t[38]=B):B=t[38];let $;t[39]!==p?($=r.jsx(mh,{open:p,onOpenChange:g}),t[39]=p,t[40]=$):$=t[40];let z;t[41]!==_?(z=r.jsx(Qh,{open:_,onOpenChange:b}),t[41]=_,t[42]=z):z=t[42];let q;return t[43]!==P||t[44]!==B||t[45]!==$||t[46]!==z||t[47]!==A||t[48]!==D||t[49]!==L||t[50]!==R?(q=r.jsxs(r.Fragment,{children:[A,D,L,R,P,B,$,z]}),t[43]=P,t[44]=B,t[45]=$,t[46]=z,t[47]=A,t[48]=D,t[49]=L,t[50]=R,t[51]=q):q=t[51],q}function yv(t){return t.kind==="existing"&&t.templateId===null}function Sv(t){return{key:t.id,kind:"existing",templateId:null,agent:t}}function wv(t){return t.id!==null&&!lr(t.id)}function Vv(t){return t!==null}function Cv(t){return t!==null}function kv(t){return t.id==="self-healing-storefront"}function jv(t){return t.id==="studio-pack"}function Nv(t){return t.id==="lean-canvas"}function Av(t){return t.id==="ai-research"}function Ev(t){return t.id==="ai-image"}function Iv(t){return t.id==="site-diagnostics"}function Tv(t){return t.id==="site-editor"}function Rv(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:r.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(Mv)})}),t[0]=e):e=t[0],e}function Mv(t,e){return r.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[r.jsx(wi,{className:"size-12 rounded-xl shrink-0"}),r.jsx(wi,{className:"h-3 sm:h-4 w-full"})]},e)}function tc(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(j.Suspense,{fallback:r.jsx(Rv,{}),children:r.jsx(bv,{})}),t[0]=e):e=t[0],e}function Bi(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function sc(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Dv(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Pv(t){const e=O.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Lv),e[0]=s,e[1]=i):i=e[1];let n;return e[2]!==i?(n=r.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=n):n=e[3],n}function Lv(t){return r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),r.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Ov(t){const e=O.c(30),{userTokens:s,assistantTokens:i,otherTokens:n}=t,o=s+i+n,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?n/o*100:0;let d;e[0]!==a?(d=a>0&&r.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&r.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&r.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let f;e[6]!==d||e[7]!==u||e[8]!==h?(f=r.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=r.jsxs("div",{className:"flex items-center gap-1.5",children:[m,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let b;e[16]!==l?(b=l.toFixed(1),e[16]=l,e[17]=b):b=e[17];let x;e[18]!==b?(x=r.jsxs("div",{className:"flex items-center gap-1.5",children:[_,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",b,"%"]})]}),e[18]=b,e[19]=x):x=e[19];let v;e[20]!==c||e[21]!==n?(v=n>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=n,e[22]=v):v=e[22];let y;e[23]!==x||e[24]!==v||e[25]!==g?(y=r.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,v]}),e[23]=x,e[24]=v,e[25]=g,e[26]=y):y=e[26];let V;return e[27]!==y||e[28]!==f?(V=r.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=V):V=e[29],V}function Bv(t){const e=O.c(19),{part:s}=t,i=s.input?.agent_id,n=$t(i),o=n?.title??"Subtask",a=n?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=r.jsx(ps,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let f;e[3]!==h?(f=Y("shrink-0 font-medium",h),e[3]=h,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==f?(m=r.jsx("span",{className:f,children:o}),e[5]=o,e[6]=f,e[7]=m):m=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=r.jsx("span",{className:"ml-auto shrink-0",children:l?r.jsx(Ne,{size:12,className:"animate-spin text-muted-foreground"}):c?r.jsx(xp,{size:12,className:"text-destructive"}):d?r.jsx(Bs,{size:12,className:"text-warning"}):r.jsx(Wp,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==m||e[16]!==p||e[17]!==g?(_=r.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,m,p,g]}),e[14]=u,e[15]=m,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function $v(t){const e=O.c(58),{onClose:s,back:i,className:n}=t,[o,a]=j.useState(null),{messages:l}=Ii(),{tasks:c,taskId:d}=Lt(),{selectedModel:u,selectedVirtualMcp:h}=$s();let f,m,p,g,_,b,x,v;if(e[0]!==i||e[1]!==n||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){v=Symbol.for("react.early_return_sentinel");e:{let C;e[17]!==d?(C=J=>J.id===d,e[17]=d,e[18]=C):C=e[18];const S=c.find(C),w=Nd(l),k=[...l].reverse().find(Yv),T=k?.metadata?.usage,M=k?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,I=T?.contextTokens??T?.totalTokens??0,E=M&&M>0?(I/M*100).toFixed(1):null,N=l;let A;e[19]!==N?(A=N.filter(Gv).reduce(qv,0),e[19]=N,e[20]=A):A=e[20];const D=A,L=l;let R;e[21]!==L?(R=L.filter(Kv).reduce(Wv,0),e[21]=L,e[22]=R):R=e[22];const P=R,B=Math.max(0,w.totalTokens-D-P),$=l[0],z=l.at(-1),q=$?.metadata?.created_at??S?.created_at,F=z?.metadata?.created_at??S?.updated_at,K=l.filter(Hv),H=l.flatMap(Fv),U=u?.modelId?Dv(u.modelId):"—",X=h?.title??"Decopilot",W=[{label:"Session",value:S?.title??"New chat"},{label:"Messages",value:K.length},{label:"Agent",value:X},{label:"Model",value:U},{label:"Context Limit",value:M?Bi(M):"—"},{label:"Session Tokens (billed)",value:w.totalTokens>0?Bi(w.totalTokens):"0"},{label:"Usage",value:E!==null?`${E}%`:"—"},{label:"Input Tokens",value:w.inputTokens>0?Bi(w.inputTokens):"0"},{label:"Output Tokens",value:w.outputTokens>0?Bi(w.outputTokens):"0"},{label:"Reasoning Tokens",value:w.reasoningTokens>0?Bi(w.reasoningTokens):"0"},{label:"Cost",value:w.cost>0?`$${w.cost<.001?w.cost.toFixed(6):w.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:sc(q)},{label:"Last Activity",value:sc(F)}];if(!S&&K.length===0){let J;e[23]!==n?(J=Y("flex flex-col h-full w-full border-l border-border bg-background",n),e[23]=n,e[24]=J):J=e[24];let ae;e[25]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ae):ae=e[25];let Z;e[26]!==i?(Z=i?r.jsx(Eo,{size:14,className:"text-muted-foreground"}):r.jsx(Os,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=Z):Z=e[27];let de;e[28]!==s||e[29]!==Z?(de=r.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ae,r.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:Z})]}),e[28]=s,e[29]=Z,e[30]=de):de=e[30];let me;e[31]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=me):me=e[31];let le;e[32]!==J||e[33]!==de?(le=r.jsxs("div",{className:J,children:[de,me]}),e[32]=J,e[33]=de,e[34]=le):le=e[34],v=le;break e}e[35]!==n?(b=Y("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",n),e[35]=n,e[36]=b):b=e[36];let G;e[37]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=G):G=e[37];let se;e[38]!==i?(se=i?r.jsx(Eo,{size:14}):r.jsx(Os,{size:14}),e[38]=i,e[39]=se):se=e[39],e[40]!==s||e[41]!==se?(x=r.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[G,r.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:se})]}),e[40]=s,e[41]=se,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",m=H.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),r.jsx("div",{className:"flex flex-col gap-1",children:H.map(zv)})]}),p=r.jsx(Pv,{items:W});let ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ee):ee=e[43],e[44]!==P||e[45]!==B||e[46]!==D?(g=r.jsxs("div",{className:"flex flex-col gap-3",children:[ee,r.jsx(Ov,{userTokens:D,assistantTokens:P,otherTokens:B})]}),e[44]=P,e[45]=B,e[46]=D,e[47]=g):g=e[47],_=K.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),r.jsx("div",{className:"flex flex-col gap-1",children:K.map(J=>{const ae=J.metadata?.created_at,Z=o?.id===J.id;return r.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(Z?null:J),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:Y("shrink-0 font-medium",J.role==="user"?"text-chart-1":"text-chart-2"),children:J.role}),r.jsx("span",{className:"text-muted-foreground",children:"•"}),r.jsx("span",{className:"truncate text-muted-foreground font-mono",children:J.id})]}),ae&&r.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ae).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),Z&&r.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(J,null,2)})]},J.id)})})]})}e[0]=i,e[1]=n,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=b,e[15]=x,e[16]=v}else f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],b=e[14],x=e[15],v=e[16];if(v!==Symbol.for("react.early_return_sentinel"))return v;let y;e[48]!==f||e[49]!==m||e[50]!==p||e[51]!==g||e[52]!==_?(y=r.jsxs("div",{className:f,children:[m,p,g,_]}),e[48]=f,e[49]=m,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let V;return e[54]!==b||e[55]!==x||e[56]!==y?(V=r.jsxs("div",{className:b,children:[x,y]}),e[54]=b,e[55]=x,e[56]=y,e[57]=V):V=e[57],V}function zv(t,e){return r.jsx(Bv,{part:t},e)}function Fv(t){return(t.parts??[]).filter(Uv)}function Uv(t){return t.type==="tool-subtask"}function Hv(t){return t.role!=="system"}function Wv(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Kv(t){return t.role==="assistant"}function qv(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gv(t){return t.role==="user"}function Yv(t){return t.role==="assistant"&&t.metadata?.usage}const ic=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],rc=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Xv(){const t=ic[Math.floor(Math.random()*ic.length)],e=rc[Math.floor(Math.random()*rc.length)];return`deco/${t}-${e}`}function Jv(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Qv(t){const e=O.c(25),{orgId:s,userId:i,connectionId:n,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=n??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const f=Ae(h);let m;e[3]!==a||e[4]!==l?(m={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=m):m=e[5];const p=d&&!!n&&!!a&&!!l;let g;e[6]!==f||e[7]!==m||e[8]!==p?(g={client:f,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:sb},e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:b,isError:x}=ni(g);let v,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),v=[...y].sort().map(tb),e[10]=i,e[11]=o,e[12]=v,e[13]=y):(v=e[12],y=e[13]);const V=v;let C;if(e[14]!==_||e[15]!==y){const T=Array.isArray(_)?_:_?.branches??[];let M;e[17]!==y?(M=I=>!y.has(I.name),e[17]=y,e[18]=M):M=e[18],C=T.filter(eb).filter(M).map(Zv),e[14]=_,e[15]=y,e[16]=C}else C=e[16];const S=C,w=Array.isArray(_)?null:_?.default_branch??null;let k;return e[19]!==w||e[20]!==x||e[21]!==b||e[22]!==S||e[23]!==V?(k={yours:V,others:S,defaultBase:w,isLoading:b,isError:x},e[19]=w,e[20]=x,e[21]=b,e[22]=S,e[23]=V,e[24]=k):k=e[24],k}function Zv(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function eb(t){return typeof t.name=="string"}function tb(t){return{name:t,source:"yours"}}function sb(t){return Jv(t)}function ib(t){const e=O.c(41),{orgId:s,userId:i,connectionId:n,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=j.useState(!1);let f;e[0]!==n||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(f={orgId:s,userId:i,connectionId:n,vmMap:l,owner:o,repo:a,enabled:u},e[0]=n,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=f):f=e[7];const{yours:m,others:p,isLoading:g,isError:_}=Qv(f);let b;e[8]!==d?(b=A=>{d(A),h(!1)},e[8]=d,e[9]=b):b=e[9];const x=b,v=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(er,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let V;e[11]!==v?(V=r.jsx(zs,{asChild:!0,children:r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,r.jsx("span",{className:"max-w-[200px] truncate",children:v})]})}),e[11]=v,e[12]=V):V=e[12];let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Gp,{placeholder:"Search branches…"}),e[13]=C):C=e[13];let S;e[14]!==x?(S=r.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[C,r.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>x(Xv()),children:"New"})]}),e[14]=x,e[15]=S):S=e[15];let w;e[16]!==_?(w=_&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[16]=_,e[17]=w):w=e[17];let k;e[18]!==_||e[19]!==g||e[20]!==p.length||e[21]!==m.length?(k=!_&&!g&&m.length===0&&p.length===0&&r.jsx(Kp,{children:"No branches found."}),e[18]=_,e[19]=g,e[20]=p.length,e[21]=m.length,e[22]=k):k=e[22];let T;e[23]!==x||e[24]!==m?(T=m.length>0&&r.jsx(Al,{heading:"Your branches",children:m.map(A=>r.jsxs(El,{value:A.name,onSelect:()=>x(A.name),children:[r.jsx(er,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:A.name})]},A.name))}),e[23]=x,e[24]=m,e[25]=T):T=e[25];let M;e[26]!==p||e[27]!==x?(M=p.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(qp,{}),r.jsx(Al,{heading:"Other branches in repo",children:p.map(A=>r.jsxs(El,{value:A.name,onSelect:()=>x(A.name),children:[r.jsx(er,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:A.name}),A.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",A.author]})]},A.name))})]}),e[26]=p,e[27]=x,e[28]=M):M=e[28];let I;e[29]!==M||e[30]!==w||e[31]!==k||e[32]!==T?(I=r.jsxs(Yp,{children:[w,k,T,M]}),e[29]=M,e[30]=w,e[31]=k,e[32]=T,e[33]=I):I=e[33];let E;e[34]!==I||e[35]!==S?(E=r.jsx(Fs,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:r.jsxs(Xp,{children:[S,I]})}),e[34]=I,e[35]=S,e[36]=E):E=e[36];let N;return e[37]!==u||e[38]!==E||e[39]!==V?(N=r.jsxs(Us,{open:u,onOpenChange:h,children:[V,E]}),e[37]=u,e[38]=E,e[39]=V,e[40]=N):N=e[40],N}const rb=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),nb="/decotexture.svg";function nc(t){const e=O.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:rb},e[0]=i):i=e[0];let n,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:r.jsx(ps,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=r.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=n,e[2]=o):(n=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("img",{src:nb,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:r.jsx(In,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=r.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[n,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function ob(){const t=O.c(5),{data:e}=dt.useSession();let s;t[0]!==e?.user?.email?(s=Ze.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let n;t[2]!==s||t[3]!==i?(n={queryKey:s,queryFn:ab,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=n):n=t[4];const{data:o}=ji(n);return o?.isDecoUser??!1}async function ab(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function lb(t){const e=O.c(56),{onOpenContextPanel:s}=t,{data:i}=dt.useSession(),[n,o]=j.useState(!1),a=ob(),l=ms(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:f}=Pn();let m;e[0]!==i?.user?.name?(m=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=m):m=e[1];const p=m,g=c&&u&&h!=null,_=c&&d&&f;if(l){let E;e[2]!==h||e[3]!==g?(E=g&&r.jsx("div",{className:"mb-4",children:r.jsx(Ee.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=E):E=e[4];let N;e[5]!==_?(N=_&&r.jsx("div",{className:"mb-4",children:r.jsx(Ee.NoCreditsEyebrow,{})}),e[5]=_,e[6]=N):N=e[6];let A;e[7]!==p?(A=r.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=A):A=e[8];let D;e[9]!==E||e[10]!==N||e[11]!==A?(D=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[E,N,A]}),e[9]=E,e[10]=N,e[11]=A,e[12]=D):D=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(tc,{}),e[13]=L):L=e[13];let R;e[14]!==s?(R=r.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,r.jsx(Ee.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=R):R=e[15];let P;e[16]!==a?(P=a&&r.jsx("div",{className:"w-full",children:r.jsx(nc,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let B;e[18]!==D||e[19]!==R||e[20]!==P?(B=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[D,R,P]}),e[18]=D,e[19]=R,e[20]=P,e[21]=B):B=e[21];let $;e[22]!==n?($=r.jsx(fn,{open:n,onOpenChange:o}),e[22]=n,e[23]=$):$=e[23];let z;return e[24]!==$||e[25]!==B?(z=r.jsxs(r.Fragment,{children:[B,$]}),e[24]=$,e[25]=B,e[26]=z):z=e[26],z}let b;e[27]!==h||e[28]!==g?(b=g&&r.jsx("div",{className:"mb-4",children:r.jsx(Ee.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=b):b=e[29];let x;e[30]!==_?(x=_&&r.jsx("div",{className:"mb-4",children:r.jsx(Ee.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let v;e[32]!==p?(v=r.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=v):v=e[33];let y;e[34]!==b||e[35]!==x||e[36]!==v?(y=r.jsxs("div",{className:"text-center mb-10",children:[b,x,v]}),e[34]=b,e[35]=x,e[36]=v,e[37]=y):y=e[37];let V;e[38]!==s?(V=r.jsx("div",{className:"w-full",children:r.jsx(Ee.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=V):V=e[39];let C;e[40]!==y||e[41]!==V?(C=r.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,V]}),e[40]=y,e[41]=V,e[42]=C):C=e[42];let S;e[43]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"w-full mt-10 mx-auto",children:r.jsx(tc,{})}),e[43]=S):S=e[43];let w;e[44]!==C?(w=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[C,S]}),e[44]=C,e[45]=w):w=e[45];let k;e[46]!==a?(k=a&&r.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:r.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:r.jsx(nc,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=k):k=e[47];let T;e[48]!==k||e[49]!==w?(T=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[w,k]}),e[48]=k,e[49]=w,e[50]=T):T=e[50];let M;e[51]!==n?(M=r.jsx(fn,{open:n,onOpenChange:o}),e[51]=n,e[52]=M):M=e[52];let I;return e[53]!==T||e[54]!==M?(I=r.jsxs(r.Fragment,{children:[T,M]}),e[53]=T,e[54]=M,e[55]=I):I=e[55],I}function cb(){const t=O.c(26),{org:e}=_e(),{selectedVirtualMcp:s}=$s(),{data:i}=dt.useSession(),{currentBranch:n,setCurrentTaskBranch:o}=Lt();let a;t[0]!==e.id?(a=En(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=$t(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,f=!!h?.connectionId&&!!u;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Dn,{size:32}),t[2]=m):m=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=r.jsx(ps,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=r.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let b;t[8]!==_?(b=r.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=b):b=t[9];let x;t[10]!==n||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==f||t[16]!==u?(x=f&&r.jsx("div",{className:"mt-2",children:r.jsx(ib,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:n??void 0,onChange:o})}),t[10]=n,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=f,t[16]=u,t[17]=x):x=t[17];let v;t[18]!==p||t[19]!==g||t[20]!==b||t[21]!==x?(v=r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,b,x]}),t[18]=p,t[19]=g,t[20]=b,t[21]=x,t[22]=v):v=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"w-full max-w-3xl mx-auto",children:r.jsx(Ee.IceBreakers,{})}),t[23]=y):y=t[23];let V;return t[24]!==v?(V=r.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[v,y]}),t[24]=v,t[25]=V):V=t[25],V}function db(t){const e=O.c(27),{variant:s}=t,{org:i}=_e(),n=La(),{isChatEmpty:o}=Ii(),[a,l]=j.useState("chat"),c=Pn();if(n.length===0){let V;return e[0]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Ee,{className:"animate-in fade-in-0 duration-200",children:r.jsx(Ee.Main,{className:"flex flex-col items-center",children:r.jsx(Ee.EmptyState,{children:r.jsx(Ee.NoAiProviderEmptyState,{})})})}),e[0]=V):V=e[0],V}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!T1(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&r.jsx(Ee.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const f=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;e[10]!==f?(m=Y("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),e[10]=f,e[11]=m):m=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?r.jsx(lb,{onOpenContextPanel:()=>l("context")}):r.jsxs(r.Fragment,{children:[r.jsx(Ee.Main,{children:r.jsx(cb,{})}),r.jsx(Ee.Footer,{children:r.jsx(Ee.Input,{onOpenContextPanel:()=>l("context")})})]}):r.jsxs(r.Fragment,{children:[r.jsx(Ee.Main,{children:r.jsx(Ee.Messages,{})}),r.jsx(Ee.Footer,{children:r.jsx(Ee.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==m||e[16]!==p?(g=r.jsx("div",{className:m,children:p}),e[15]=m,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let b;e[18]!==_?(b=Y("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=b):b=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx($v,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let v;e[21]!==b?(v=r.jsx("div",{className:b,children:x}),e[21]=b,e[22]=v):v=e[22];let y;return e[23]!==v||e[24]!==h||e[25]!==g?(y=r.jsxs(Ee,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,v]}),e[23]=v,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function Zh(t){const e=O.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Ee.Skeleton,{}),e[0]=i):i=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Ee.Skeleton,{}),e[1]=n):n=e[1];let o;return e[2]!==s?(o=r.jsx(ls,{fallback:i,children:r.jsx(j.Suspense,{fallback:n,children:r.jsx(db,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function hb(){const t=O.c(6),{org:e,locator:s}=_e(),i=bt();let n;t[0]!==s||t[1]!==i?(n=()=>{i.invalidateQueries({queryKey:Ze.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=n):n=t[2];let o;t[3]!==e.id||t[4]!==n?(o={orgId:e.id,onTaskStatus:n},t[3]=e.id,t[4]=n,t[5]=o):o=t[5],Qp(o)}function ub(t){const e=O.c(8),{virtualMcpId:s,size:i,showAutomationBadge:n}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?r.jsx(fb,{virtualMcpId:s,size:o}):r.jsx(Qt,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==n?(l=n&&r.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:r.jsx(Ci,{size:10,className:"text-white"})}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=r.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function fb(t){const e=O.c(6),{virtualMcpId:s,size:i}=t,n=$t(s);if(!n){let l;return e[0]!==i?(l=r.jsx(Qt,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=n.icon??null;let a;return e[2]!==n.title||e[3]!==i||e[4]!==o?(a=r.jsx(Qt,{icon:o,name:n.title,size:i}),e[2]=n.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function bs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function mb(t){const e=O.c(42),{task:s,isActive:i,onClick:n,onArchive:o,showAutomationBadge:a}=t,l=wm(s.status),c=l.icon,d=$t(s.virtual_mcp_id);let u;e[0]!==d?(u=bs(d),e[0]=d,e[1]=u):u=e[1];const h=u,f="button",m=0;let p;e[2]!==n?(p=B=>{B.target===B.currentTarget&&(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),n())},e[2]=n,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=Y("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let b;e[6]!==a||e[7]!==s.virtual_mcp_id?(b=r.jsx(ub,{virtualMcpId:s.virtual_mcp_id,size:"xs",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=b):b=e[8];const x=s.title||"Untitled task";let v;e[9]!==x?(v=r.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=v):v=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate font-mono",children:s.branch}),r.jsx("span",{className:"shrink-0",children:"·"})]}):h?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),r.jsx("span",{className:"shrink-0",children:"·"})]}):null,r.jsx("span",{className:"shrink-0",children:Vm(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let V;e[15]!==y||e[16]!==v?(V=r.jsxs("div",{className:"flex-1 min-w-0",children:[v,y]}),e[15]=y,e[16]=v,e[17]=V):V=e[17];const C="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",S="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",w=l.label,k=14,T=Y(l.iconClassName,s.status==="in_progress"&&"animate-spin");let M;e[18]!==c||e[19]!==T?(M=r.jsx(c,{size:k,className:T}),e[18]=c,e[19]=T,e[20]=M):M=e[20];let I;e[21]!==l||e[22]!==M?(I=r.jsx("span",{className:S,"aria-label":w,children:M}),e[21]=l,e[22]=M,e[23]=I):I=e[23];let E;e[24]!==o?(E=B=>{B.stopPropagation(),o()},e[24]=o,e[25]=E):E=e[25];let N;e[26]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(Qm,{size:14}),e[26]=N):N=e[26];let A;e[27]!==E?(A=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Archive task",onClick:E,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:N})}),e[27]=E,e[28]=A):A=e[28];let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Ge,{side:"right",children:"Archive"}),e[29]=D):D=e[29];let L;e[30]!==A?(L=r.jsxs(Ye,{children:[A,D]}),e[30]=A,e[31]=L):L=e[31];let R;e[32]!==I||e[33]!==L?(R=r.jsxs("div",{className:C,children:[I,L]}),e[32]=I,e[33]=L,e[34]=R):R=e[34];let P;return e[35]!==n||e[36]!==V||e[37]!==R||e[38]!==p||e[39]!==_||e[40]!==b?(P=r.jsxs("div",{role:f,tabIndex:m,onClick:n,onKeyDown:p,className:_,children:[b,V,R]}),e[35]=n,e[36]=V,e[37]=R,e[38]=p,e[39]=_,e[40]=b,e[41]=P):P=e[41],P}const eu={all:"All tasks",manual:"Chats",automation:"Automation"},tu={all:"All members",mine:"Mine only"};function pb(t){const e=O.c(57),{title:s,tasks:i,activeTaskId:n,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[f,m]=j.useState("all"),[p,g]=j.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(K=>K.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const b=_;let x;e[4]!==f||e[5]!==b?(x=f==="automation"?b.filter(vb):f==="manual"?b.filter(xb):b,e[4]=f,e[5]=b,e[6]=x):x=e[6];const v=x;let y;e[7]!==s?(y=r.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let V;e[9]!==p?(V=r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?r.jsx(Zm,{size:16}):r.jsx(Dn,{size:16})})}),e[9]=p,e[10]=V):V=e[10];let C;e[11]!==p?(C=K=>{const H=K;H!==p&&re("tasks_panel_member_filter_changed",{to_value:H}),g(H)},e[11]=p,e[12]=C):C=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=Object.keys(tu),e[13]=S):S=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=S.map(_b),e[14]=w):w=e[14];let k;e[15]!==p||e[16]!==C?(k=r.jsx(hs,{align:"end",children:r.jsx(xl,{value:p,onValueChange:C,children:w})}),e[15]=p,e[16]=C,e[17]=k):k=e[17];let T;e[18]!==V||e[19]!==k?(T=r.jsxs(cs,{children:[V,k]}),e[18]=V,e[19]=k,e[20]=T):T=e[20];const M=f!=="all"&&"text-purple-500";let I;e[21]!==M?(I=Y("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",M),e[21]=M,e[22]=I):I=e[22];let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(vp,{size:16}),e[23]=E):E=e[23];let N;e[24]!==I?(N=r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter tasks",className:I,children:E})}),e[24]=I,e[25]=N):N=e[25];let A;e[26]!==f?(A=K=>{const H=K;H!==f&&re("tasks_panel_filter_changed",{to_value:H}),m(H)},e[26]=f,e[27]=A):A=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=Object.keys(eu),e[28]=D):D=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=D.map(gb),e[29]=L):L=e[29];let R;e[30]!==f||e[31]!==A?(R=r.jsx(hs,{align:"end",children:r.jsx(xl,{value:f,onValueChange:A,children:L})}),e[30]=f,e[31]=A,e[32]=R):R=e[32];let P;e[33]!==N||e[34]!==R?(P=r.jsxs(cs,{children:[N,R]}),e[33]=N,e[34]=R,e[35]=P):P=e[35];let B;e[36]!==l||e[37]!==c||e[38]!==s?(B=c&&l&&r.jsx("button",{type:"button",onClick:()=>{re("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:r.jsx(Ra,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=B):B=e[39];let $;e[40]!==P||e[41]!==B||e[42]!==T?($=r.jsxs("div",{className:"flex items-center gap-0.5",children:[T,P,B]}),e[40]=P,e[41]=B,e[42]=T,e[43]=$):$=e[43];let z;e[44]!==$||e[45]!==y?(z=r.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,$]}),e[44]=$,e[45]=y,e[46]=z):z=e[46];let q;e[47]!==n||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==v?(q=v.length===0&&u?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):v.map(K=>r.jsx(mb,{task:K,isActive:n===K.id,onClick:()=>{n!==K.id&&re("tasks_panel_task_clicked",{thread_id:K.id,virtual_mcp_id:K.virtual_mcp_id??null,from_automation:!!K.fromAutomation}),o(K)},onArchive:()=>{re("tasks_panel_task_archived",{thread_id:K.id,virtual_mcp_id:K.virtual_mcp_id??null}),a(K)},showAutomationBadge:d||K.fromAutomation},K.id)),e[47]=n,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=v,e[53]=q):q=e[53];let F;return e[54]!==z||e[55]!==q?(F=r.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[z,q]}),e[54]=z,e[55]=q,e[56]=F):F=e[56],F}function gb(t){return r.jsx(Ld,{value:t,children:eu[t]},t)}function _b(t){return r.jsx(Ld,{value:t,children:tu[t]},t)}function xb(t){return!t.fromAutomation}function vb(t){return t.fromAutomation}function bb(){const t=O.c(22);hb();const{data:e}=dt.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:n}=Co(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=Co(o),{setTaskId:l,createNewTask:c}=xr();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=_r(d),{locator:h,org:f}=_e(),m=bt();let p;t[3]!==f.id?(p={connectionId:yt,orgId:f.id},t[3]=f.id,t[4]=p):p=t[4];const g=Ae(p),_=u.taskId??null;let b;t[5]!==a||t[6]!==n?(b=[...n,...a.map(Sb)].sort(yb),t[5]=a,t[6]=n,t[7]=b):b=t[7];const x=b;let v;t[8]!==g||t[9]!==h||t[10]!==m?(v=async S=>{try{await mm(g,S.id,{hidden:!0}),m.invalidateQueries({queryKey:Ze.tasksPrefix(h)})}catch(w){const T=w;ue.error(`Failed to archive task: ${T.message}`)}},t[8]=g,t[9]=h,t[10]=m,t[11]=v):v=t[11];const y=v;if(x.length===0){let S;return t[12]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"h-full flex items-center justify-center p-4",children:r.jsx(Vi,{image:r.jsx(ep,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=S):S=t[12],S}let V;t[13]!==l?(V=S=>l(S.id,S.virtual_mcp_id),t[13]=l,t[14]=V):V=t[14];let C;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==V?(C=r.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:r.jsx(pb,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:V,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=V,t[21]=C):C=t[21],C}function yb(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function Sb(t){return{...t,fromAutomation:!0}}function wb(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(Vb)}),t[0]=e):e=t[0],e}function Vb(t,e){return r.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function su(){const t=O.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Ee.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ls,{fallback:e,children:r.jsx(j.Suspense,{fallback:r.jsx(wb,{}),children:r.jsx(bb,{})})}),t[1]=s):s=t[1],s}function iu(){const t=O.c(77),{org:e}=_e(),s=Oe(),i=yd(),{setTasksOpen:n,openTab:o}=xr(),a=e.slug,l=_e().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=_r(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=ti(u),f=i.location.pathname;let m;t[2]!==l.enabledPlugins?(m=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=m):m=t[3];const p=m;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let b,x,v,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let H;t[17]!==p?(H=ae=>p.includes(ae.pluginId),t[17]=p,t[18]=H):H=t[18];const U=Of.filter(H),X=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const W=d.taskId??"",G=d.pluginId;let se;t[19]!==G?(se=ae=>G===ae,t[19]=G,t[20]=se):se=t[20],b=se;let ee;t[21]!==W||t[22]!==s||t[23]!==a||t[24]!==X?(ee=ae=>{const Z=W||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:Z,pluginId:ae},search:de=>({...de,virtualmcpid:X})})},t[21]=W,t[22]=s,t[23]=a,t[24]=X,t[25]=ee):ee=t[25],v=ee;let J;t[26]!==b||t[27]!==v?(J=ae=>({key:ae.pluginId,label:ae.label,icon:ae.icon,isActive:b(ae.pluginId),onClick:()=>v(ae.pluginId)}),t[26]=b,t[27]=v,t[28]=J):J=t[28],y=U.map(J),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=b,t[14]=x,t[15]=v,t[16]=y}else b=t[13],x=t[14],v=t[15],y=t[16];const V=y;let C;if(t[29]!==p||t[30]!==b||t[31]!==v){let H;t[33]!==p?(H=W=>p.includes(W.pluginId),t[33]=p,t[34]=H):H=t[34];const U=Bf.filter(H);let X;t[35]!==b||t[36]!==v?(X=W=>({type:"group",group:{id:`${W.pluginId}-${W.id}`,label:W.label,items:W.items.map((G,se)=>({key:`${W.pluginId}-${W.id}-${se}`,label:G.label,icon:G.icon,isActive:b(W.pluginId),onClick:()=>v(W.pluginId)})),defaultExpanded:W.defaultExpanded??!0}}),t[35]=b,t[36]=v,t[37]=X):X=t[37],C=U.map(X),t[29]=p,t[30]=b,t[31]=v,t[32]=C}else C=t[32];const S=C;let w;if(t[38]!==o||t[39]!==_){let H;t[41]!==o?(H=U=>{const X=vr(U.icon),W=X.type==="icon"?br(X.name):null;return{key:`app-${U.connectionId}-${U.toolName}`,label:U.label||U.toolName,icon:W?r.jsx(W,{size:16,className:"text-muted-foreground"}):X.type==="url"?r.jsx("img",{src:X.url,alt:"",className:"size-4 rounded"}):r.jsx(xh,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(jo(U.connectionId,U.toolName))}},t[41]=o,t[42]=H):H=t[42],w=_.map(H),t[38]=o,t[39]=_,t[40]=w}else w=t[40];const k=w;let T;t[43]!==k?(T=k.length>0?{type:"group",group:{id:"apps",label:"Apps",items:k,defaultExpanded:!0}}:null,t[43]=k,t[44]=T):T=t[44];const M=T;let I;t[45]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(tp,{className:"size-4!"}),t[45]=I):I=t[45];const E=f===`/${a}`||f===`/${a}/`;let N;t[46]!==s||t[47]!==a||t[48]!==n?(N=()=>{n(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=n,t[49]=N):N=t[49];let A;t[50]!==N||t[51]!==E?(A={key:"home",label:"Home",icon:I,isActive:E,onClick:N},t[50]=N,t[51]=E,t[52]=A):A=t[52];const D=A;let L;t[53]!==p?(L=p.includes($f),t[53]=p,t[54]=L):L=t[54];const R=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(zf,{className:"size-4!"}),t[55]=P):P=t[55];let B;t[56]!==a||t[57]!==f?(B=f.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=f,t[58]=B):B=t[58];let $;t[59]!==s||t[60]!==a?($=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=$):$=t[61];let z;t[62]!==B||t[63]!==$?(z={key:"workflows",label:"Workflows",icon:P,isActive:B,onClick:$},t[62]=B,t[63]=$,t[64]=z):z=t[64];const q=z;let F;if(t[65]!==D||t[66]!==x||t[67]!==R||t[68]!==q){const H=[D];x&&R&&H.push(q),F={type:"items",items:H},t[65]=D,t[66]=x,t[67]=R,t[68]=q,t[69]=F}else F=t[69];let K;if(t[70]!==M||t[71]!==S||t[72]!==V||t[73]!==F){if(K=[F],V.length>0){let H;t[75]!==V?(H={type:"items",items:V},t[75]=V,t[76]=H):H=t[76],K.push(H)}S.length>0&&K.push(...S),M&&K.push(M),t[70]=M,t[71]=S,t[72]=V,t[73]=F,t[74]=K}else K=t[74];return K}function ru(t){const e=O.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex h-6 items-center",children:r.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsxs(wr,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,r.jsx(Vr,{children:r.jsx(es,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=n):n=e[2],n}function Cb(){const t=O.c(7),s=Sd().logo??wd,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(yh,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function nu(t){const e=O.c(15),{item:s}=t,{isMobile:i,setOpenMobile:n}=Cr();let o;e[0]!==i||e[1]!==s||e[2]!==n?(o=()=>{re("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&n(!1)},e[0]=i,e[1]=s,e[2]=n,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=Y(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=r.jsx(Zt,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=r.jsx(Pt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function kb(t){const e=O.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(vh,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,n=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(Nb),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=r.jsx(ru,{label:i,defaultExpanded:n,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map(jb),e[8]=s.items,e[9]=i):i=e[9];let n;return e[10]!==i?(n=r.jsx(wr,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Vr,{children:r.jsx(es,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=n):n=e[11],n}}}function jb(t){return r.jsx(nu,{item:t},t.key)}function Nb(t){return r.jsx(nu,{item:t},t.key)}function Ab(t){const e=O.c(14),{sections:s,header:i,footer:n,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(Cb,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=Y("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(Eb),e[3]=s,e[4]=h):h=e[4];let f;e[5]!==o||e[6]!==u||e[7]!==h?(f=r.jsxs(bh,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=f):f=e[8];let m;return e[9]!==n||e[10]!==i||e[11]!==f||e[12]!==c?(m=r.jsxs(Zp,{variant:c,children:[d,i,f,n]}),e[9]=n,e[10]=i,e[11]=f,e[12]=c,e[13]=m):m=e[13],m}function Eb(t,e){return r.jsx(kb,{section:t},e)}function ou(t){const e=O.c(2);let s;return e[0]!==t?(s=r.jsx(Ab,{...t}),e[0]=t,e[1]=s):s=e[1],s}ou.Skeleton=function(){return r.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>r.jsx("div",{className:"w-full h-8",children:r.jsx(wi,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function Ib(){const t=O.c(7),s=Sd().logo??wd,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(yh,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function oc(t){const e=O.c(15),{item:s,onClose:i}=t,n=s.isActive&&"z-10";let o;e[0]!==n?(o=Y(n),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=r.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=r.jsx(Zt,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=r.jsx(Pt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function Tb(t){const e=O.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(vh,{className:"my-2"}),e[0]=n):n=e[0],n}case"spacer":{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"flex-1"}),e[1]=n):n=e[1],n}case"group":{const n=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>r.jsx(oc,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=r.jsx(ru,{label:n,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let n;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>r.jsx(oc,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],n=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=n}else n=e[13];let o;return e[16]!==n?(o=r.jsx(wr,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Vr,{children:r.jsx(es,{className:"gap-1.5",children:n})})}),e[16]=n,e[17]=o):o=e[17],o}}}function Rb(t){const e=O.c(12),{sections:s,onClose:i,footer:n,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(Ib,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,f)=>r.jsx(Tb,{section:h,onClose:i},f),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=r.jsxs(bh,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==n||e[10]!==c?(d=r.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,n]}),e[9]=n,e[10]=c,e[11]=d):d=e[11],d}function au(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Mb=as({name:pt().min(2,"Organization name is required")});function Db(t){const e=O.c(41),{open:s,onOpenChange:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={resolver:gr(Mb),defaultValues:{name:""}},e[0]=n):n=e[0];const o=Ai(n);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:Lb,onSuccess:Pb},e[1]=a):a=e[1];const l=Ni(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsxs(Ua,{children:[r.jsx(Ha,{children:"Create a new organization"}),r.jsx(Wa,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let S;e[6]!==l?(S=w=>l.mutateAsync(w),e[6]=l,e[7]=S):S=e[7],u=o.handleSubmit(S),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=S=>{const{field:w}=S;return r.jsxs(_t,{children:[r.jsx(Ht,{children:"Organization Name"}),r.jsx(xt,{children:r.jsx(at,{...w,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),r.jsx(qm,{children:"The name of your company or organization"}),w.value&&r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",r.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",au(w.value)]})]}),r.jsx(vt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let f;e[10]!==o.control||e[11]!==h?(f=r.jsx(gt,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=f):f=e[12];let m;e[13]!==c?(m=c&&r.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=r.jsx(za,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let b;e[21]!==o.formState.isSubmitting?(b=o.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(ar,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=b):b=e[22];let x;e[23]!==_||e[24]!==b?(x=r.jsx(oe,{type:"submit",variant:"default",disabled:_,children:b}),e[23]=_,e[24]=b,e[25]=x):x=e[25];let v;e[26]!==x||e[27]!==g?(v=r.jsxs(Ka,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=v):v=e[28];let y;e[29]!==v||e[30]!==u||e[31]!==f||e[32]!==m?(y=r.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[f,m,v]}),e[29]=v,e[30]=u,e[31]=f,e[32]=m,e[33]=y):y=e[33];let V;e[34]!==o||e[35]!==y?(V=r.jsxs(Fa,{children:[d,r.jsx(yi,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=V):V=e[36];let C;return e[37]!==i||e[38]!==s||e[39]!==V?(C=r.jsx(qa,{open:s,onOpenChange:i,children:V}),e[37]=i,e[38]=s,e[39]=V,e[40]=C):C=e[40],C}function Pb(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function Lb(t){const e=au(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await dt.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function Bo(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function Ob(t){const e=O.c(13),{org:s,size:i}=t,n=i===void 0?"sm":i,o=n==="xs"?"size-5":"size-6",a=n==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=Y(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:Bo(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?r.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:Y("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=r.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function $r(t){const e=O.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=r.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let f;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(f=r.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=f):f=e[10],f}let n;e[11]!==s||e[12]!==i?(n=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=n):n=e[13];let o;e[14]!==s.icon?(o=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=r.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==n||e[19]!==o||e[20]!==a?(l=r.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=n,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function ac(t){const e=O.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:n,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Dt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,r.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==n||e[5]!==i||e[6]!==s){let f;e[8]!==n||e[9]!==i?(f=m=>r.jsxs("button",{type:"button",onClick:()=>n(m.slug),className:Y("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",m.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[r.jsx(Ob,{org:m,size:"sm"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:m.name}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:m.slug})]}),m.slug===i&&r.jsx(Mt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},m.id),e[8]=n,e[9]=i,e[10]=f):f=e[10],d=s.map(f),e[4]=n,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=r.jsxs(r.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function lc(t){const e=O.c(142),{user:s,userImage:i,menuItems:n,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f,close:m,isMobile:p}=t;if(p){const W=s?.name??"U";let G;e[0]!==W||e[1]!==i?(G=r.jsx(Il,{url:i,fallback:W,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=W,e[1]=i,e[2]=G):G=e[2];const se=s?.name??"User";let ee;e[3]!==se?(ee=r.jsx("p",{className:"text-sm font-medium truncate",children:se}),e[3]=se,e[4]=ee):ee=e[4];const J=s?.email;let ae;e[5]!==J?(ae=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:J}),e[5]=J,e[6]=ae):ae=e[6];let Z;e[7]!==ee||e[8]!==ae?(Z=r.jsxs("div",{className:"flex-1 min-w-0",children:[ee,ae]}),e[7]=ee,e[8]=ae,e[9]=Z):Z=e[9];let de;e[10]!==s?(de=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(Fb)},e[10]=s,e[11]=de):de=e[11];let me;e[12]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx(Si,{size:14}),e[12]=me):me=e[12];let le;e[13]!==de?(le=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:de,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:me})}),e[13]=de,e[14]=le):le=e[14];let he;e[15]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsx(Ge,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=he):he=e[15];let be;e[16]!==le?(be=r.jsx(bi,{delayDuration:300,children:r.jsxs(Ye,{children:[le,he]})}),e[16]=le,e[17]=be):be=e[17];let fe;e[18]!==be||e[19]!==G||e[20]!==Z?(fe=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[G,Z,be]}),e[18]=be,e[19]=G,e[20]=Z,e[21]=fe):fe=e[21];let ye;e[22]!==f||e[23]!==h||e[24]!==u||e[25]!==d?(ye=r.jsx("div",{className:"border-b border-border pb-2",children:r.jsx(ac,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[22]=f,e[23]=h,e[24]=u,e[25]=d,e[26]=ye):ye=e[26];let ve;if(e[27]!==m||e[28]!==n){let De;e[30]!==m?(De=Yt=>r.jsx($r,{item:Yt,onClose:m},Yt.key),e[30]=m,e[31]=De):De=e[31],ve=n.map(De),e[27]=m,e[28]=n,e[29]=ve}else ve=e[29];let Ve;e[32]!==m||e[33]!==o?(Ve=r.jsx($r,{item:o,onClose:m}),e[32]=m,e[33]=o,e[34]=Ve):Ve=e[34];let Ie;e[35]!==ve||e[36]!==Ve?(Ie=r.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,Ve]}),e[35]=ve,e[36]=Ve,e[37]=Ie):Ie=e[37];let te;e[38]!==ye||e[39]!==Ie?(te=r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[ye,Ie]}),e[38]=ye,e[39]=Ie,e[40]=te):te=e[40];let ie;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let De;e[45]!==l.theme||e[46]!==c?(De=Yt=>{const{value:At,icon:Et,label:Ct}=Yt;return r.jsx("button",{type:"button","aria-label":Ct,onClick:()=>c(ws=>({...ws,theme:At})),className:Y("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===At?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Et},At)},e[45]=l.theme,e[46]=c,e[47]=De):De=e[47],ie=a.map(De),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=ie}else ie=e[44];let Ce;e[48]!==ie?(Ce=r.jsx("div",{className:"flex items-center gap-0.5",children:ie}),e[48]=ie,e[49]=Ce):Ce=e[49];const ze=l.enableSounds?"Disable sounds":"Enable sounds";let Fe;e[50]!==c?(Fe=()=>c(zb),e[50]=c,e[51]=Fe):Fe=e[51];const ft=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let He;e[52]!==ft?(He=Y("size-8 rounded-md flex items-center justify-center transition-colors",ft),e[52]=ft,e[53]=He):He=e[53];let tt;e[54]!==l.enableSounds?(tt=l.enableSounds?r.jsx(vl,{size:14}):r.jsx(bl,{size:14}),e[54]=l.enableSounds,e[55]=tt):tt=e[55];let ht;e[56]!==ze||e[57]!==Fe||e[58]!==He||e[59]!==tt?(ht=r.jsx("button",{type:"button","aria-label":ze,onClick:Fe,className:He,children:tt}),e[56]=ze,e[57]=Fe,e[58]=He,e[59]=tt,e[60]=ht):ht=e[60];let pe;e[61]===Symbol.for("react.memo_cache_sentinel")?(pe=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.286.0"]}),e[61]=pe):pe=e[61];let ke;e[62]!==ht?(ke=r.jsxs("div",{className:"flex items-center gap-2",children:[ht,pe]}),e[62]=ht,e[63]=ke):ke=e[63];let st;e[64]!==Ce||e[65]!==ke?(st=r.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[Ce,ke]}),e[64]=Ce,e[65]=ke,e[66]=st):st=e[66];let zt;return e[67]!==fe||e[68]!==te||e[69]!==st?(zt=r.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[fe,te,st]}),e[67]=fe,e[68]=te,e[69]=st,e[70]=zt):zt=e[70],zt}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=r.jsx(Il,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const b=s?.name??"User";let x;e[74]!==b?(x=r.jsx("p",{className:"text-sm font-medium truncate",children:b}),e[74]=b,e[75]=x):x=e[75];const v=s?.email;let y;e[76]!==v?(y=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:v}),e[76]=v,e[77]=y):y=e[77];let V;e[78]!==x||e[79]!==y?(V=r.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=V):V=e[80];let C;e[81]!==s?(C=()=>{s?.id&&navigator.clipboard.writeText(s.id).then($b)},e[81]=s,e[82]=C):C=e[82];let S;e[83]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Si,{size:14}),e[83]=S):S=e[83];let w;e[84]!==C?(w=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:C,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:S})}),e[84]=C,e[85]=w):w=e[85];let k;e[86]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Ge,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=k):k=e[86];let T;e[87]!==w?(T=r.jsx(bi,{delayDuration:300,children:r.jsxs(Ye,{children:[w,k]})}),e[87]=w,e[88]=T):T=e[88];let M;e[89]!==T||e[90]!==_||e[91]!==V?(M=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,V,T]}),e[89]=T,e[90]=_,e[91]=V,e[92]=M):M=e[92];let I;if(e[93]!==m||e[94]!==n){let W;e[96]!==m?(W=G=>r.jsx($r,{item:G,onClose:m},G.key),e[96]=m,e[97]=W):W=e[97],I=n.map(W),e[93]=m,e[94]=n,e[95]=I}else I=e[95];let E;e[98]!==m||e[99]!==o?(E=r.jsx($r,{item:o,onClose:m}),e[98]=m,e[99]=o,e[100]=E):E=e[100];let N;e[101]!==I||e[102]!==E?(N=r.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[I,E]}),e[101]=I,e[102]=E,e[103]=N):N=e[103];let A;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let W;e[108]!==l.theme||e[109]!==c?(W=G=>{const{value:se,icon:ee,label:J}=G;return r.jsx("button",{type:"button","aria-label":J,onClick:()=>c(ae=>({...ae,theme:se})),className:Y("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===se?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:ee},se)},e[108]=l.theme,e[109]=c,e[110]=W):W=e[110],A=a.map(W),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=A}else A=e[107];let D;e[111]!==A?(D=r.jsx("div",{className:"flex items-center gap-0.5",children:A}),e[111]=A,e[112]=D):D=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let R;e[113]!==c?(R=()=>c(Bb),e[113]=c,e[114]=R):R=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let B;e[115]!==P?(B=Y("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=B):B=e[116];let $;e[117]!==l.enableSounds?($=l.enableSounds?r.jsx(vl,{size:14}):r.jsx(bl,{size:14}),e[117]=l.enableSounds,e[118]=$):$=e[118];let z;e[119]!==L||e[120]!==R||e[121]!==B||e[122]!==$?(z=r.jsx("button",{type:"button","aria-label":L,onClick:R,className:B,children:$}),e[119]=L,e[120]=R,e[121]=B,e[122]=$,e[123]=z):z=e[123];let q;e[124]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.286.0"]}),e[124]=q):q=e[124];let F;e[125]!==z?(F=r.jsxs("div",{className:"flex items-center gap-2",children:[z,q]}),e[125]=z,e[126]=F):F=e[126];let K;e[127]!==D||e[128]!==F?(K=r.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[D,F]}),e[127]=D,e[128]=F,e[129]=K):K=e[129];let H;e[130]!==M||e[131]!==N||e[132]!==K?(H=r.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[M,N,K]}),e[130]=M,e[131]=N,e[132]=K,e[133]=H):H=e[133];let U;e[134]!==f||e[135]!==h||e[136]!==u||e[137]!==d?(U=r.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:r.jsx(ac,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[134]=f,e[135]=h,e[136]=u,e[137]=d,e[138]=U):U=e[138];let X;return e[139]!==H||e[140]!==U?(X=r.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[H,U]}),e[139]=H,e[140]=U,e[141]=X):X=e[141],X}function Bb(t){return{...t,enableSounds:!t.enableSounds}}function $b(){ue.success("User ID copied")}function zb(t){return{...t,enableSounds:!t.enableSounds}}function Fb(){ue.success("User ID copied")}function lu(){const t=O.c(50),{data:e}=dt.useSession(),{data:s}=dt.useListOrganizations(),i=Oe();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org",shouldThrow:!1},t[0]=n):n=t[0];const a=Ff(n)?.params.org,[l,c]=ei(),d=ms(),[u,h]=j.useState(!1),[f,m]=j.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const v=s?.find(X=>X.slug===a);let y;if(t[11]!==a||t[12]!==s){let X;t[14]!==a?(X=(W,G)=>W.slug===a?-1:G.slug===a?1:W.name.localeCompare(G.name),t[14]=a,t[15]=X):X=t[15],y=[...s??[]].sort(X),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const V=y;let C;t[16]!==i?(C=X=>{h(!1),i({to:"/$org",params:{org:X}})},t[16]=i,t[17]=C):C=t[17];const S=C;let w;t[18]===Symbol.for("react.memo_cache_sentinel")?(w=()=>h(!1),t[18]=w):w=t[18];const k=w;let T;t[19]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(kr,{size:16}),t[19]=T):T=t[19];let M;t[20]!==i||t[21]!==a?(M={key:"preferences",label:"Preferences",icon:T,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=M):M=t[22];let I;t[23]===Symbol.for("react.memo_cache_sentinel")?(I={key:"terms",label:"Terms of Use",icon:r.jsx(sp,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=I):I=t[23];let E;t[24]===Symbol.for("react.memo_cache_sentinel")?(E={key:"privacy",label:"Privacy Policy",icon:r.jsx(cg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=E):E=t[24];let N;t[25]===Symbol.for("react.memo_cache_sentinel")?(N={key:"github",label:"decocms/studio",icon:r.jsx(Uf,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=N):N=t[25];let A;t[26]===Symbol.for("react.memo_cache_sentinel")?(A={key:"community",label:"Community",icon:r.jsx(Dn,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=A):A=t[26];let D;t[27]===Symbol.for("react.memo_cache_sentinel")?(D={key:"homepage",label:"Homepage",icon:r.jsx(Qd,{size:16}),href:"https://decocms.com",external:!0},t[27]=D):D=t[27];let L;t[28]!==M?(L=[M,I,E,N,A,D],t[28]=M,t[29]=L):L=t[29];const R=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:r.jsx(up,{size:16}),onClick:Hb},t[30]=P):P=t[30];const B=P;let $;t[31]===Symbol.for("react.memo_cache_sentinel")?($={value:"light",icon:r.jsx(og,{size:14}),label:"Light theme"},t[31]=$):$=t[31];let z;t[32]===Symbol.for("react.memo_cache_sentinel")?(z={value:"dark",icon:r.jsx(ag,{size:14}),label:"Dark theme"},t[32]=z):z=t[32];let q;t[33]===Symbol.for("react.memo_cache_sentinel")?(q=[$,z,{value:"system",icon:r.jsx(lg,{size:14}),label:"System theme"}],t[33]=q):q=t[33];const F=q;let K;t[34]===Symbol.for("react.memo_cache_sentinel")?(K=()=>{h(!1),m(!0)},t[34]=K):K=t[34];let H;t[35]!==S||t[36]!==d||t[37]!==R||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==V||t[42]!==p||t[43]!==g?(H={user:p,userImage:g,menuItems:R,signOutItem:B,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:V,orgParam:a,onSelectOrg:S,onCreateOrg:K,close:k,isMobile:d},t[35]=S,t[36]=d,t[37]=R,t[38]=a,t[39]=l,t[40]=c,t[41]=V,t[42]=p,t[43]=g,t[44]=H):H=t[44];const U=H;_=d?r.jsxs(ri,{open:u,onOpenChange:h,direction:"bottom",children:[r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[r.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:v?.logo?void 0:Bo(v?.name??""),children:v?.logo?r.jsx("img",{src:v.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(v?.name??"?").slice(0,2).toUpperCase()})}),r.jsx("span",{className:"truncate",children:v?.name??"Account"})]}),r.jsxs(ii,{className:"h-[80dvh] p-0",children:[r.jsx(si,{className:"sr-only",children:"Account"}),r.jsx(lc,{...U})]})]}):r.jsxs(Us,{open:u,onOpenChange:h,children:[r.jsx(zs,{asChild:!0,children:r.jsx(Zt,{tooltip:v?.name??"Account",className:"rounded-md",children:r.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:v?.logo?void 0:Bo(v?.name??""),children:v?.logo?r.jsx("img",{src:v.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(v?.name??"?").slice(0,2).toUpperCase()})})})}),r.jsx(Fs,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:Ub,children:r.jsx(lc,{...U})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let b;t[45]!==f?(b=r.jsx(Db,{open:f,onOpenChange:m}),t[45]=f,t[46]=b):b=t[46];let x;return t[47]!==_||t[48]!==b?(x=r.jsxs(r.Fragment,{children:[_,b]}),t[47]=_,t[48]=b,t[49]=x):x=t[49],x}function Ub(t){return t.preventDefault()}function Hb(){re("signed_out",{source:"account_popover"}),dt.signOut()}function Wb({invitation:t}){const[e,s]=j.useState(!1),[i,n]=j.useState(!1),o=bt(),a=async()=>{s(!0);try{const c=await dt.organization.acceptInvitation({invitationId:t.id});if(c.error)ue.error(c.error.message),s(!1);else{const d=await dt.organization.setActive({organizationId:t.organizationId});ue.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{ue.error("Failed to accept invitation"),s(!1)}},l=async()=>{n(!0);try{const c=await dt.organization.rejectInvitation({invitationId:t.id});c.error?(ue.error(c.error.message),n(!1)):(ue.success("Invitation declined"),o.invalidateQueries())}catch{ue.error("Failed to decline invitation"),n(!1)}};return r.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),r.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:r.jsx(Mt,{size:14})}),r.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:r.jsx(Os,{size:14})})]})]})}function Kb(){const t=j.useContext(Hf),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class qb extends j.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function Gb(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function Yb(){const t=O.c(19),e=Oe(),{org:s}=_e();let i;t[0]!==s.id?(i={connectionId:yt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const n=Ae(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==n?(a={client:n,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:Xb},t[3]=n,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=ni(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const f=h;let m;t[9]!==u?(m=Y(u!=null&&Gb(u)),t[9]=u,t[10]=m):m=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(Ta,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==m||t[16]!==p||t[17]!==f?(_=r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(Zt,{tooltip:f,className:m,onClick:p,children:g})})}),t[15]=m,t[16]=p,t[17]=f,t[18]=_):_=t[18],_}function Xb(t){return t.structuredContent}function Jb(){const t=O.c(1);if(!La().some(Qb))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Yb,{}),t[0]=i):i=t[0],i}function Qb(t){return t.providerId==="deco"}function Zb(){const t=O.c(3),[e,s]=j.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(Zt,{tooltip:"Connections",onClick:()=>{re("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:r.jsx(fp,{size:24})})})}),t[0]=i):i=t[0];let n;return t[1]!==e?(n=r.jsxs(r.Fragment,{children:[i,r.jsx(Qa,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=n):n=t[2],n}function e0(){const t=O.c(11),e=Kb();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(yl,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&r.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let n;t[3]!==i?(n=r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(zs,{asChild:!0,children:r.jsxs(Zt,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=n):n=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:r.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=r.jsxs(Fs,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[r.jsx(yl,{size:24,className:"text-muted-foreground/50"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):r.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(t0)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==n||t[9]!==a?(l=r.jsxs(Us,{children:[n,a]}),t[8]=n,t[9]=a,t[10]=l):l=t[10],l}function t0(t){return r.jsx(Wb,{invitation:t},t.id)}function s0(){const t=O.c(6),e=Oe(),{org:s}=_e();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let n;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(kr,{size:24}),t[3]=n):n=t[3];let o;return t[4]!==i?(o=r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(Zt,{tooltip:"Settings",onClick:i,children:n})})}),t[4]=i,t[5]=o):o=t[5],o}function i0(){const t=O.c(5);let e,s,i,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(qb,{children:r.jsx(j.Suspense,{fallback:null,children:r.jsx(Jb,{})})}),s=r.jsx(Zb,{}),i=r.jsx(e0,{}),n=r.jsx(s0,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=n):(e=t[0],s=t[1],i=t[2],n=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs(Sh,{className:"px-2 pb-3 gap-1",children:[e,s,i,n,r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(lu,{})})})]}),t[4]=o):o=t[4],o}function r0(){const t=O.c(10),e=Oe(),{org:s}=_e(),{setOpenMobile:i}=Cr();let n;t[0]!==e||t[1]!==s.slug||t[2]!==i?(n=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=n):n=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(kr,{}),t[4]=o):o=t[4];let a;t[5]!==n?(a=r.jsx(Pt,{children:r.jsx(Zt,{tooltip:"Settings",onClick:n,children:o})}),t[5]=n,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Pt,{children:r.jsx(lu,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=r.jsx(Sh,{children:r.jsxs(es,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}var Za="ContextMenu",[n0]=Zf(Za,[Vd]),St=Vd(),[o0,cu]=n0(Za),du=t=>{const{__scopeContextMenu:e,children:s,onOpenChange:i,dir:n,modal:o=!0}=t,[a,l]=j.useState(!1),c=St(e),d=Wf(i),u=j.useCallback(h=>{l(h),d(h)},[d]);return r.jsx(o0,{scope:e,open:a,onOpenChange:u,modal:o,children:r.jsx(Kf,{...c,dir:n,open:a,onOpenChange:u,modal:o,children:s})})};du.displayName=Za;var hu="ContextMenuTrigger",uu=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,disabled:i=!1,...n}=t,o=cu(hu,s),a=St(s),l=j.useRef({x:0,y:0}),c=j.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=j.useRef(0),u=j.useCallback(()=>window.clearTimeout(d.current),[]),h=f=>{l.current={x:f.clientX,y:f.clientY},o.onOpenChange(!0)};return j.useEffect(()=>u,[u]),j.useEffect(()=>{i&&u()},[i,u]),r.jsxs(r.Fragment,{children:[r.jsx(qf,{...a,virtualRef:c}),r.jsx(Gf.span,{"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,...n,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:i?t.onContextMenu:Li(t.onContextMenu,f=>{u(),h(f),f.preventDefault()}),onPointerDown:i?t.onPointerDown:Li(t.onPointerDown,zr(f=>{u(),d.current=window.setTimeout(()=>h(f),700)})),onPointerMove:i?t.onPointerMove:Li(t.onPointerMove,zr(u)),onPointerCancel:i?t.onPointerCancel:Li(t.onPointerCancel,zr(u)),onPointerUp:i?t.onPointerUp:Li(t.onPointerUp,zr(u))})]})});uu.displayName=hu;var a0="ContextMenuPortal",fu=t=>{const{__scopeContextMenu:e,...s}=t,i=St(e);return r.jsx(Yf,{...i,...s})};fu.displayName=a0;var mu="ContextMenuContent",pu=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=cu(mu,s),o=St(s),a=j.useRef(!1);return r.jsx(Xf,{...o,...i,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{t.onCloseAutoFocus?.(l),!l.defaultPrevented&&a.current&&l.preventDefault(),a.current=!1},onInteractOutside:l=>{t.onInteractOutside?.(l),!l.defaultPrevented&&!n.modal&&(a.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});pu.displayName=mu;var l0="ContextMenuGroup",c0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(em,{...n,...i,ref:e})});c0.displayName=l0;var d0="ContextMenuLabel",h0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(tm,{...n,...i,ref:e})});h0.displayName=d0;var u0="ContextMenuItem",gu=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(Jf,{...n,...i,ref:e})});gu.displayName=u0;var f0="ContextMenuCheckboxItem",m0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(sm,{...n,...i,ref:e})});m0.displayName=f0;var p0="ContextMenuRadioGroup",g0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(im,{...n,...i,ref:e})});g0.displayName=p0;var _0="ContextMenuRadioItem",x0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(rm,{...n,...i,ref:e})});x0.displayName=_0;var v0="ContextMenuItemIndicator",b0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(nm,{...n,...i,ref:e})});b0.displayName=v0;var y0="ContextMenuSeparator",_u=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(Qf,{...n,...i,ref:e})});_u.displayName=y0;var S0="ContextMenuArrow",w0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(om,{...n,...i,ref:e})});w0.displayName=S0;var V0="ContextMenuSubTrigger",C0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(am,{...n,...i,ref:e})});C0.displayName=V0;var k0="ContextMenuSubContent",j0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(lm,{...n,...i,ref:e,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});j0.displayName=k0;function zr(t){return e=>e.pointerType!=="mouse"?t(e):void 0}var N0=du,A0=uu,E0=fu,I0=pu,T0=gu,R0=_u;function M0(t){const e=O.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i=r.jsx(N0,{"data-slot":"context-menu",...s}),e[2]=s,e[3]=i):i=e[3],i}function D0(t){const e=O.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i=r.jsx(A0,{"data-slot":"context-menu-trigger",...s}),e[2]=s,e[3]=i):i=e[3],i}function P0(t){const e=O.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let n;e[3]!==s?(n=Y("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",s),e[3]=s,e[4]=n):n=e[4];let o;return e[5]!==i||e[6]!==n?(o=r.jsx(E0,{children:r.jsx(I0,{"data-slot":"context-menu-content",className:n,...i})}),e[5]=i,e[6]=n,e[7]=o):o=e[7],o}function cc(t){const e=O.c(12);let s,i,n,o;e[0]!==t?({className:s,inset:i,variant:o,...n}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=o):(s=e[1],i=e[2],n=e[3],o=e[4]);const a=o===void 0?"default":o;let l;e[5]!==s?(l=Y("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[5]=s,e[6]=l):l=e[6];let c;return e[7]!==i||e[8]!==n||e[9]!==l||e[10]!==a?(c=r.jsx(T0,{"data-slot":"context-menu-item","data-inset":i,"data-variant":a,className:l,...n}),e[7]=i,e[8]=n,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function L0(t){const e=O.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let n;e[3]!==s?(n=Y("bg-border -mx-1 my-1 h-px",s),e[3]=s,e[4]=n):n=e[4];let o;return e[5]!==i||e[6]!==n?(o=r.jsx(R0,{"data-slot":"context-menu-separator",className:n,...i}),e[5]=i,e[6]=n,e[7]=o):o=e[7],o}function xu(t){const e=Oe(),s=bt(),i=Vh(),{locator:n}=_e(),o=_r({strict:!1}),a=ti({strict:!1});return async l=>{const c=crypto.randomUUID(),d=l===a.virtualmcpid?Dd(s,n,o.taskId??""):null;try{await i.create.mutateAsync({id:c,virtual_mcp_id:l,...d?{branch:d}:{}})}catch{}e({to:"/$org/$taskId",params:{org:t,taskId:c},search:{virtualmcpid:l}})}}function O0({agent:t,org:e,onUnpin:s,isDragging:i}){const n=Oe(),{isMobile:o,setOpenMobile:a}=Cr(),l=xu(e),d=yd({select:v=>v.location.pathname}).startsWith(`/${e}/${t.id}`),[u,h]=j.useState(null),f=j.useRef(null),m=j.useRef(null),p=j.useRef(!1);p.current=!!i,i&&(u||m.current)&&(m.current&&(clearTimeout(m.current),m.current=null),u&&h(null));const g=v=>{if(p.current)return;const y=v.currentTarget.getBoundingClientRect();m.current=setTimeout(()=>{p.current||h(y)},550)},_=v=>{m.current&&(clearTimeout(m.current),m.current=null),!(f.current&&v.relatedTarget instanceof Node&&f.current.contains(v.relatedTarget))&&h(null)},b=u?Math.round(u.height*.9):0,x=u?u.width+b:0;return r.jsx(M0,{children:r.jsxs(Pt,{className:Y(u&&"z-[55]"),children:[r.jsx(D0,{asChild:!0,children:r.jsx(Zt,{tooltip:u?void 0:t.title,isActive:d,onClick:()=>{re("sidebar_agent_pin_clicked",{agent_id:t.id,agent_title:t.title}),l(t.id),o&&a(!1)},onMouseEnter:g,onMouseLeave:_,children:r.jsx(Qt,{icon:t.icon,name:t.title,size:"xs",className:"w-full h-full [&_svg]:w-1/2 [&_svg]:h-1/2"})})}),r.jsxs(P0,{children:[r.jsxs(cc,{onClick:()=>{const v=crypto.randomUUID();n({to:"/$org/$taskId",params:{org:e,taskId:v},search:{virtualmcpid:t.id}})},children:[r.jsx(kr,{size:14}),"Settings"]}),r.jsx(L0,{}),r.jsxs(cc,{onClick:()=>{s(),d&&n({to:"/$org",params:{org:e}})},className:"",children:[r.jsx(Es,{size:14}),"Unpin"]})]}),u&&Ei.createPortal(r.jsx("button",{ref:f,type:"button",onMouseLeave:()=>h(null),onClick:v=>{v.stopPropagation(),h(null),s(),n({to:"/$org",params:{org:e}})},className:Y("flex items-center justify-center","bg-sidebar-accent text-muted-foreground","rounded-xl cursor-pointer","animate-in fade-in-0 slide-in-from-right-2","duration-150 [animation-timing-function:cubic-bezier(0.165,0.84,0.44,1)]","hover:text-foreground transition-colors"),style:{position:"fixed",top:u.top,left:u.left,height:u.height,width:x,paddingLeft:u.width,zIndex:50,boxShadow:"inset 0 0 0.5px 1px hsla(0, 0%, 100%, 0.075), 0 0 0 0.5px hsla(0, 0%, 0%, 0.12)"},children:r.jsx(Es,{size:14})}),document.body)]})})}function B0(t){const e=O.c(18);let s;e[0]!==t.agent.id?(s={id:t.agent.id},e[0]=t.agent.id,e[1]=s):s=e[1];const{attributes:i,listeners:n,setNodeRef:o,transform:a,transition:l,isDragging:c}=vg(s);let d;e[2]!==a?(d=bg.Transform.toString(a?{...a,x:0}:null),e[2]=a,e[3]=d):d=e[3];const u=c?.5:void 0,h=c?100:void 0;let f;e[4]!==d||e[5]!==u||e[6]!==h||e[7]!==l?(f={transform:d,transition:l,opacity:u,zIndex:h},e[4]=d,e[5]=u,e[6]=h,e[7]=l,e[8]=f):f=e[8];const m=f;let p;e[9]!==c||e[10]!==t?(p=r.jsx(O0,{...t,isDragging:c}),e[9]=c,e[10]=t,e[11]=p):p=e[11];let g;return e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==m||e[16]!==p?(g=r.jsx("div",{ref:o,style:m,...i,...n,tabIndex:-1,className:"w-full",children:p}),e[12]=i,e[13]=n,e[14]=o,e[15]=m,e[16]=p,e[17]=g):g=e[17],g}function $0(t){const e=O.c(9),{agent:s,onClick:i}=t;let n;e[0]!==s.icon||e[1]!==s.title?(n=r.jsx(Qt,{icon:s.icon,name:s.title,size:"md",className:"transition-transform group-hover:scale-105"}),e[0]=s.icon,e[1]=s.title,e[2]=n):n=e[2];let o;e[3]!==s.title?(o=r.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground line-clamp-2 w-full",children:s.title}),e[3]=s.title,e[4]=o):o=e[4];let a;return e[5]!==i||e[6]!==n||e[7]!==o?(a=r.jsxs("button",{type:"button",onClick:i,className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group",children:[n,o]}),e[5]=i,e[6]=n,e[7]=o,e[8]=a):a=e[8],a}function z0(t){const e=O.c(80),{onClose:s,onOpenImportDeco:i,onOpenGithubImport:n,onOpenSelfHealing:o,onOpenDiagnosticsModal:a,onOpenLeanCanvasModal:l,onOpenStudioPackModal:c,onOpenAiImageModal:d,onOpenAiResearchModal:u}=t,[h,f]=j.useState(""),m=Rn(),{org:p}=_e();let g;e[0]!==m?(g=m.filter(Y0).map(G0),e[0]=m,e[1]=g):g=e[1];const _=g,{pin:b,isPinned:x}=gh(p.id,_);let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v={navigateOnCreate:!0},e[2]=v):v=e[2];const{createVirtualMCP:y,isCreating:V}=_h(v),[C]=ei(),S=xu(p.slug),w=Sr();let k,T,M,I,E,N,A,D;if(e[3]!==m||e[4]!==y||e[5]!==V||e[6]!==x||e[7]!==w||e[8]!==S||e[9]!==s||e[10]!==d||e[11]!==u||e[12]!==a||e[13]!==n||e[14]!==i||e[15]!==l||e[16]!==o||e[17]!==c||e[18]!==b||e[19]!==C.experimental_vibecode||e[20]!==h){const q=h.toLowerCase();D=m.filter(q0).filter(ie=>!h||ie.title.toLowerCase().includes(q));let F;e[29]!==m?(F=m.some(K0),e[29]=m,e[30]=F):F=e[30];const K=F;k=jt.filter(ie=>(!h||ie.title.toLowerCase().includes(q))&&!(ie.id==="studio-pack"&&K)&&!(ie.id==="self-healing-storefront"&&!C.experimental_vibecode));let H;e[31]===Symbol.for("react.memo_cache_sentinel")?(H=jt.find(W0),e[31]=H):H=e[31];const U=H,X=U?m.find(ie=>ie.metadata?.type===U.id):void 0;let W;e[32]===Symbol.for("react.memo_cache_sentinel")?(W=jt.find(H0),e[32]=W):W=e[32];const G=W,se=G?m.find(ie=>ie.metadata?.type===G.id):void 0;let ee;e[33]===Symbol.for("react.memo_cache_sentinel")?(ee=jt.find(U0),e[33]=ee):ee=e[33];const J=ee,ae=J?m.find(ie=>ie.metadata?.type===J.id):void 0;let Z;e[34]===Symbol.for("react.memo_cache_sentinel")?(Z=jt.find(F0),e[34]=Z):Z=e[34];const de=Z,me=de?m.find(ie=>ie.metadata?.type===de.id):void 0;let le;e[35]!==x||e[36]!==S||e[37]!==s||e[38]!==b?(le=ie=>{x(ie.id)||b(ie.id),s(),f(""),S(ie.id)},e[35]=x,e[36]=S,e[37]=s,e[38]=b,e[39]=le):le=e[39];const he=le,be=ie=>{s(),f(""),ie==="self-healing-storefront"?o():ie==="site-editor"?i():ie==="site-diagnostics"?X?w(X.id):a():ie==="lean-canvas"?se?w(se.id):l():ie==="ai-image"?ae?w(ae.id):d():ie==="ai-research"?me?w(me.id):u():ie==="studio-pack"?c():S(ie)};N="flex flex-col max-h-[min(640px,80dvh)]",e[40]!==h?(A=r.jsx(yg,{value:h,onChange:f,placeholder:"Search agents..."}),e[40]=h,e[41]=A):A=e[41],T="overflow-y-auto flex-1 min-h-0 px-3 pb-3",e[42]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx("div",{className:"px-1 pt-3 pb-2",children:r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Agents"})}),e[42]=M):M=e[42];let fe;e[43]!==y||e[44]!==s?(fe=async()=>{re("agent_create_new_clicked",{source:"browse_popover"}),await y(),s()},e[43]=y,e[44]=s,e[45]=fe):fe=e[45];let ye,ve;e[46]===Symbol.for("react.memo_cache_sentinel")?(ye=r.jsx("div",{className:"w-12 h-12 rounded-xl border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-105",children:r.jsx(Dt,{size:16,className:"text-muted-foreground"})}),ve=r.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground",children:"Create new"}),e[46]=ye,e[47]=ve):(ye=e[46],ve=e[47]);let Ve;e[48]!==V||e[49]!==fe?(Ve=r.jsxs("button",{type:"button",disabled:V,onClick:fe,className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group disabled:opacity-50 disabled:cursor-not-allowed",children:[ye,ve]}),e[48]=V,e[49]=fe,e[50]=Ve):Ve=e[50];let Ie;e[51]!==s||e[52]!==n||e[53]!==C.experimental_vibecode?(Ie=C.experimental_vibecode&&r.jsxs("button",{type:"button",onClick:()=>{re("agent_import_clicked",{source:"github"}),n(),s()},className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl border-2 border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-105",children:r.jsx(ph,{className:"size-5 text-muted-foreground"})}),r.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground",children:"Import GitHub"})]}),e[51]=s,e[52]=n,e[53]=C.experimental_vibecode,e[54]=Ie):Ie=e[54];let te;e[55]!==he?(te=ie=>r.jsx($0,{agent:ie,onClick:()=>he(ie)},ie.id),e[55]=he,e[56]=te):te=e[56],I=r.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[Ve,Ie,D.map(te)]}),E=k.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-1 pt-4 pb-2",children:r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Agent templates"})}),r.jsx("div",{className:"grid grid-cols-3 gap-1",children:k.map(ie=>r.jsxs("button",{type:"button",onClick:()=>{re("agent_template_clicked",{template_id:ie.id,template_title:ie.title}),be(ie.id)},className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group disabled:opacity-50 disabled:cursor-not-allowed",children:[r.jsx(Qt,{icon:ie.icon,name:ie.title,size:"md",className:"transition-transform group-hover:scale-105"}),r.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground line-clamp-2 w-full",children:ie.title})]},ie.id))})]}),e[3]=m,e[4]=y,e[5]=V,e[6]=x,e[7]=w,e[8]=S,e[9]=s,e[10]=d,e[11]=u,e[12]=a,e[13]=n,e[14]=i,e[15]=l,e[16]=o,e[17]=c,e[18]=b,e[19]=C.experimental_vibecode,e[20]=h,e[21]=k,e[22]=T,e[23]=M,e[24]=I,e[25]=E,e[26]=N,e[27]=A,e[28]=D}else k=e[21],T=e[22],M=e[23],I=e[24],E=e[25],N=e[26],A=e[27],D=e[28];let L;e[57]!==k||e[58]!==V||e[59]!==h||e[60]!==D.length?(L=D.length===0&&k.length===0&&!V&&r.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:h?"No agents found":"No agents yet"}),e[57]=k,e[58]=V,e[59]=h,e[60]=D.length,e[61]=L):L=e[61];let R;e[62]!==T||e[63]!==M||e[64]!==I||e[65]!==E||e[66]!==L?(R=r.jsxs("div",{className:T,children:[M,I,E,L]}),e[62]=T,e[63]=M,e[64]=I,e[65]=E,e[66]=L,e[67]=R):R=e[67];let P;e[68]!==p.slug?(P={org:p.slug},e[68]=p.slug,e[69]=P):P=e[69];let B;e[70]!==s?(B=()=>s(),e[70]=s,e[71]=B):B=e[71];let $;e[72]!==P||e[73]!==B?($=r.jsx("div",{className:"border-t border-border px-3 py-2.5",children:r.jsx(Cd,{to:"/$org/settings/agents",params:P,onClick:B,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center justify-center",children:"See all agents"})}),e[72]=P,e[73]=B,e[74]=$):$=e[74];let z;return e[75]!==R||e[76]!==$||e[77]!==N||e[78]!==A?(z=r.jsxs("div",{className:N,children:[A,R,$]}),e[75]=R,e[76]=$,e[77]=N,e[78]=A,e[79]=z):z=e[79],z}function F0(t){return t.id==="ai-research"}function U0(t){return t.id==="ai-image"}function H0(t){return t.id==="lean-canvas"}function W0(t){return t.id==="site-diagnostics"}function K0(t){return Wm(t.id)}function q0(t){return!lr(t.id)}function G0(t){return t.id}function Y0(t){return t.pinned}function X0(){const t=O.c(36),[e,s]=j.useState(!1),[i,n]=j.useState(!1),[o,a]=j.useState(!1),[l,c]=j.useState(!1),[d,u]=j.useState(!1),[h,f]=j.useState(!1),[m,p]=j.useState(!1),[g,_]=j.useState(!1),[b,x]=j.useState(!1),v=ms(),{setOpenMobile:y}=Cr();let V;t[0]!==v||t[1]!==y?(V=()=>{s(!1),v&&y(!1)},t[0]=v,t[1]=y,t[2]=V):V=t[2];const C=V;let S;t[3]!==C||t[4]!==e?(S=e&&r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(wi,{className:"h-4 w-24"})}),children:r.jsx(z0,{onClose:C,onOpenImportDeco:()=>n(!0),onOpenGithubImport:()=>{a(!0),C()},onOpenSelfHealing:()=>{c(!0),C()},onOpenDiagnosticsModal:()=>u(!0),onOpenLeanCanvasModal:()=>f(!0),onOpenStudioPackModal:()=>p(!0),onOpenAiImageModal:()=>_(!0),onOpenAiResearchModal:()=>x(!0)})}),t[3]=C,t[4]=e,t[5]=S):S=t[5];const w=S;let k;t[6]!==v||t[7]!==e||t[8]!==w?(k=v?r.jsxs(r.Fragment,{children:[r.jsx(Pt,{children:r.jsx(Zt,{tooltip:"Browse agents",className:"bg-muted/75 hover:bg-sidebar-accent",onClick:()=>{re("agent_browser_opened",{surface:"mobile_drawer"}),s(!0)},children:r.jsx(Dt,{className:"!opacity-100"})})}),r.jsx(ri,{open:e,onOpenChange:s,direction:"bottom",children:r.jsxs(ii,{className:"max-h-[85dvh] p-0",children:[r.jsx(si,{className:"sr-only",children:"Browse agents"}),w]})})]}):r.jsxs(Us,{open:e,onOpenChange:P=>{P&&!e&&re("agent_browser_opened",{surface:"desktop_popover"}),s(P)},children:[r.jsx(Pt,{children:r.jsx(zs,{asChild:!0,children:r.jsx(Zt,{tooltip:"Browse agents",className:"bg-muted/75 hover:bg-sidebar-accent",children:r.jsx(Dt,{className:"!opacity-100"})})})}),r.jsx(Fs,{className:"w-[380px] p-0 overflow-hidden",side:"right",align:"start",children:w})]}),t[6]=v,t[7]=e,t[8]=w,t[9]=k):k=t[9];let T;t[10]!==i?(T=r.jsx(fn,{open:i,onOpenChange:n}),t[10]=i,t[11]=T):T=t[11];let M;t[12]!==o?(M=r.jsx(hh,{open:o,onOpenChange:a}),t[12]=o,t[13]=M):M=t[13];let I;t[14]!==l?(I=r.jsx(Qh,{open:l,onOpenChange:c}),t[14]=l,t[15]=I):I=t[15];let E;t[16]!==d?(E=r.jsx(uh,{open:d,onOpenChange:u}),t[16]=d,t[17]=E):E=t[17];let N;t[18]!==h?(N=r.jsx(fh,{open:h,onOpenChange:f}),t[18]=h,t[19]=N):N=t[19];let A;t[20]!==m?(A=r.jsx(mh,{open:m,onOpenChange:p}),t[20]=m,t[21]=A):A=t[21];let D;t[22]!==g?(D=r.jsx(Xh,{open:g,onOpenChange:_}),t[22]=g,t[23]=D):D=t[23];let L;t[24]!==b?(L=r.jsx(Jh,{open:b,onOpenChange:x}),t[24]=b,t[25]=L):L=t[25];let R;return t[26]!==L||t[27]!==k||t[28]!==T||t[29]!==M||t[30]!==I||t[31]!==E||t[32]!==N||t[33]!==A||t[34]!==D?(R=r.jsxs(r.Fragment,{children:[k,T,M,I,E,N,A,D,L]}),t[26]=L,t[27]=k,t[28]=T,t[29]=M,t[30]=I,t[31]=E,t[32]=N,t[33]=A,t[34]=D,t[35]=R):R=t[35],R}function J0(){const t=O.c(34),e=Rn(),{org:s}=_e();let i;t[0]!==e?(i=e.filter(ty).map(ey),t[0]=e,t[1]=i):i=t[1];const n=i,{pinnedIds:o,unpin:a,reorder:l}=gh(s.id,n),c=new Map(e.map(Z0)),d=o.map(R=>c.get(R)).filter(Q0);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{distance:5}},t[2]=u):u=t[2];let h;t[3]===Symbol.for("react.memo_cache_sentinel")?(h={coordinateGetter:_g},t[3]=h):h=t[3];const f=dg(Tl(ug,u),Tl(hg,h));let m;t[4]!==o||t[5]!==l?(m=R=>{const{active:P,over:B}=R;if(!B||P.id===B.id)return;const $=o.indexOf(P.id),z=o.indexOf(B.id);$===-1||z===-1||l(xg([...o],$,z))},t[4]=o,t[5]=l,t[6]=m):m=t[6];const p=m,g=wr,_="py-0 px-0 mt-2 flex-1 min-h-0";let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"h-px bg-border mx-2 mb-2"}),t[7]=b):b=t[7];const x=Vr,v="flex flex-1 min-h-0 flex-col overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",y=es,V="gap-2";let C;t[8]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(X0,{}),t[8]=C):C=t[8];const S=pg,w=gg,k=fg,T=mg;let M;t[9]!==s.slug||t[10]!==a?(M=R=>r.jsx(B0,{agent:R,org:s.slug,onUnpin:()=>a(R.id)},R.id),t[9]=s.slug,t[10]=a,t[11]=M):M=t[11];const I=d.map(M);let E;t[12]!==k||t[13]!==o||t[14]!==T||t[15]!==I?(E=r.jsx(k,{items:o,strategy:T,children:I}),t[12]=k,t[13]=o,t[14]=T,t[15]=I,t[16]=E):E=t[16];let N;t[17]!==S||t[18]!==p||t[19]!==f||t[20]!==E||t[21]!==w?(N=r.jsx(S,{sensors:f,collisionDetection:w,onDragEnd:p,children:E}),t[17]=S,t[18]=p,t[19]=f,t[20]=E,t[21]=w,t[22]=N):N=t[22];let A;t[23]!==y||t[24]!==N||t[25]!==C?(A=r.jsxs(y,{className:V,children:[C,N]}),t[23]=y,t[24]=N,t[25]=C,t[26]=A):A=t[26];let D;t[27]!==x||t[28]!==A?(D=r.jsx(x,{className:v,children:A}),t[27]=x,t[28]=A,t[29]=D):D=t[29];let L;return t[30]!==g||t[31]!==D||t[32]!==b?(L=r.jsxs(g,{className:_,children:[b,D]}),t[30]=g,t[31]=D,t[32]=b,t[33]=L):L=t[33],L}function Q0(t){return!!t}function Z0(t){return[t.id,t]}function ey(t){return t.id}function ty(t){return t.pinned}function vu(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(j.Suspense,{fallback:r.jsx(wr,{className:"py-0 px-0",children:r.jsx(Vr,{children:r.jsx(es,{className:"gap-2",children:r.jsx(Pt,{children:r.jsxs("div",{className:"flex items-center gap-2 px-2 py-2",children:[r.jsx(wi,{className:"h-4 w-4 rounded"}),r.jsx(wi,{className:"h-4 flex-1"})]})})})})}),children:r.jsx(J0,{})}),t[0]=e):e=t[0],e}function sy(){const t=O.c(4),e=iu();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(i0,{}),t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ls,{children:r.jsx(j.Suspense,{fallback:null,children:r.jsx(vu,{})})}),t[1]=i):i=t[1];let n;return t[2]!==e?(n=r.jsx(ou,{sections:e,footer:s,additionalContent:i}),t[2]=e,t[3]=n):n=t[3],n}function iy(t){const e=O.c(5),{onClose:s}=t,i=iu();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(r0,{}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(ls,{children:r.jsx(j.Suspense,{fallback:null,children:r.jsx(vu,{})})}),e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i?(a=r.jsx(Rb,{sections:i,onClose:s,footer:n,additionalContent:o}),e[2]=s,e[3]=i,e[4]=a):a=e[4],a}async function ry(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const n=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(n)}return i}const bu=["VM_START"],Fr=new Map,ny=t=>`${t.virtualMcpId}::${t.branch??""}`;function el(t){const e=bt();return Ni({mutationKey:bu,mutationFn:async s=>{const i=ny(s),n=Fr.get(i);if(n)return n;const o=(async()=>(await ry(t,"VM_START",s)).structuredContent)();Fr.set(i,o);try{return await o}finally{Fr.get(i)===o&&Fr.delete(i)}},onSuccess:()=>{Xr(e)}})}function oy(t,e){const s=O.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:bu,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Dg(i)>0}function ay(t,e){return t===1?!0:t===0?!1:e}function ly(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,n=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:n}}function dc(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function cy(t,e){return t===1?!0:t===0?!1:e}function dy(t,e){const s=Oe(),i=ti({strict:!1}),n=_r({strict:!1}),o=bt(),a=Vh(),{locator:l}=_e(),{virtualMcpId:c,orgSlug:d,isAgentRoute:u}=e,h=ly({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),f=cy(i.chat,h.chatOpen),m=h.mainOpen,p=j.useRef(crypto.randomUUID()),g=n.taskId??p.current,_="/$org/$taskId",b=T=>({org:d,taskId:T}),x=u?{virtualmcpid:c}:{},v=(T,M)=>{s({to:_,params:b(g),search:I=>({...I,...T}),replace:M?.replace??!1})},y=(T,M)=>{s({to:_,params:b(T),search:I=>{const E={};return M?E.virtualmcpid=M:u&&(E.virtualmcpid=c),I.tasks&&(E.tasks=I.tasks),E}})},V=()=>{m?v({main:"0"},{replace:!0}):v({main:Cm(t)},{replace:!0})},C=()=>{v({chat:f?0:1},{replace:!0})},S=()=>{f||v({chat:1},{replace:!0})},w=async()=>{const T=crypto.randomUUID(),M=Dd(o,l,g);try{await a.create.mutateAsync({id:T,virtual_mcp_id:c,...M?{branch:M}:{}})}catch{}s({to:_,params:b(T),search:I=>{const E={...x,chat:1};return I.tasks&&(E.tasks=I.tasks),E}})},k=T=>{v({main:T},{replace:!0})};return{taskId:g,mainOpen:m,chatOpen:f,mainParam:i.main,setTaskId:y,toggleMain:V,toggleChat:C,openChat:S,createNewTask:w,openTab:k}}const tl=j.createContext(null);function hy(t){const e=O.c(15),{children:s}=t,i=Oe();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},e[0]=n):n=e[0];const o=ti(n);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={owner:"all",status:"open"},e[1]=a):a=e[1];const{tasks:l}=Co(a);let c;e[2]!==o.tasks||e[3]!==l.length?(c=()=>ay(o.tasks,l.length>0),e[2]=o.tasks,e[3]=l.length,e[4]=c):c=e[4];const[d,u]=j.useState(c);let h,f;e[5]!==i||e[6]!==d?(h=()=>{i({search:(b=>({...b,tasks:d?1:0})),replace:!0})},f=[d,i],e[5]=i,e[6]=d,e[7]=h,e[8]=f):(h=e[7],f=e[8]),j.useEffect(h,f);let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=()=>u(uy),e[9]=m):m=e[9];const p=m;let g;e[10]!==d?(g={tasksOpen:d,toggleTasks:p},e[10]=d,e[11]=g):g=e[11];let _;return e[12]!==s||e[13]!==g?(_=r.jsx(tl.Provider,{value:g,children:s}),e[12]=s,e[13]=g,e[14]=_):_=e[14],_}function uy(t){return!t}function yu(){const t=j.useContext(tl);if(!t)throw new Error("useTasksPanelState must be used inside <TasksPanelStateProvider>");return t}function fy(){return j.useContext(tl)}const Su=j.createContext(null);function Hs(){const t=j.use(Su);if(!t)throw new Error("Toolbar.* must be used inside <Toolbar>");return t}function Re(t){const e=O.c(10),{children:s}=t,[i,n]=j.useState(null),[o,a]=j.useState(null),[l,c]=j.useState(null),[d,u]=j.useState(null);let h;e[0]!==l||e[1]!==d||e[2]!==o||e[3]!==i?(h={togglesEl:i,setTogglesEl:n,tabsEl:o,setTabsEl:a,centerEl:l,setCenterEl:c,rightEl:d,setRightEl:u},e[0]=l,e[1]=d,e[2]=o,e[3]=i,e[4]=h):h=e[4];let f;e[5]!==s?(f=r.jsx("div",{className:"flex flex-col h-full min-h-0",children:s}),e[5]=s,e[6]=f):f=e[6];let m;return e[7]!==h||e[8]!==f?(m=r.jsx(Su,{value:h,children:f}),e[7]=h,e[8]=f,e[9]=m):m=e[9],m}function my(t){const e=O.c(2),{children:s}=t;let i;return e[0]!==s?(i=r.jsx("div",{className:"shrink-0 grid grid-cols-3 items-center pl-1 pr-2 pt-0.25 h-12",children:s}),e[0]=s,e[1]=i):i=e[1],i}function py(t){const e=O.c(2),{children:s}=t;let i;return e[0]!==s?(i=r.jsx("div",{className:"flex items-center gap-0.5 min-w-0 justify-self-start",children:s}),e[0]=s,e[1]=i):i=e[1],i}function gy(t){const e=O.c(2),{children:s}=t;let i;return e[0]!==s?(i=r.jsx("div",{className:"flex items-center justify-end gap-0.5 min-w-0 justify-self-end",children:s}),e[0]=s,e[1]=i):i=e[1],i}function _y(){const t=O.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("button",{type:"button",onClick:vy,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground transition-colors",title:"Go back",children:r.jsx(Eo,{size:16})}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs(r.Fragment,{children:[e,r.jsx("button",{type:"button",onClick:xy,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground transition-colors",title:"Go forward",children:r.jsx($a,{size:16})})]}),t[1]=s):s=t[1],s}function xy(){return window.history.forward()}function vy(){return window.history.back()}function by(){const t=O.c(2),{setCenterEl:e}=Hs();let s;return t[0]!==e?(s=r.jsx("div",{ref:e,className:"min-w-0 flex items-center justify-center gap-2"}),t[0]=e,t[1]=s):s=t[1],s}function yy(t){const e=O.c(3),{children:s}=t,{centerEl:i}=Hs();if(!i)return null;let n;return e[0]!==i||e[1]!==s?(n=Ei.createPortal(s,i),e[0]=i,e[1]=s,e[2]=n):n=e[2],n}function Sy(){const t=O.c(2),{setTabsEl:e}=Hs();let s;return t[0]!==e?(s=r.jsx("div",{ref:e,className:"shrink-0 flex items-center overflow-x-auto"}),t[0]=e,t[1]=s):s=t[1],s}function wy(t){const e=O.c(3),{children:s}=t,{tabsEl:i}=Hs();if(!i)return null;let n;return e[0]!==s||e[1]!==i?(n=Ei.createPortal(s,i),e[0]=s,e[1]=i,e[2]=n):n=e[2],n}function Vy(){const t=O.c(2),{setTogglesEl:e}=Hs();let s;return t[0]!==e?(s=r.jsx("div",{ref:e,className:"flex items-center gap-0.5 shrink-0 ml-0.5"}),t[0]=e,t[1]=s):s=t[1],s}function Cy(t){const e=O.c(3),{children:s}=t,{togglesEl:i}=Hs();if(!i)return null;let n;return e[0]!==s||e[1]!==i?(n=Ei.createPortal(s,i),e[0]=s,e[1]=i,e[2]=n):n=e[2],n}function ky(){const t=O.c(2),{setRightEl:e}=Hs();let s;return t[0]!==e?(s=r.jsx("div",{ref:e,className:"flex items-center justify-end gap-0.5 shrink-0"}),t[0]=e,t[1]=s):s=t[1],s}function jy(t){const e=O.c(3),{children:s}=t,{rightEl:i}=Hs();if(!i)return null;let n;return e[0]!==s||e[1]!==i?(n=Ei.createPortal(s,i),e[0]=s,e[1]=i,e[2]=n):n=e[2],n}Re.Header=my;Re.LeftColumn=py;Re.RightColumn=gy;Re.Nav=_y;Re.CenterSlot=by;Re.Center=yy;Re.TabsSlot=Sy;Re.Tabs=wy;Re.TogglesSlot=Vy;Re.Toggles=Cy;Re.RightSlot=ky;Re.Right=jy;const Ny=280;function Ay(){const t=O.c(2),{tasksOpen:e}=yu();if(!e)return null;let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={width:`${Ny}px`},t[0]=s):s=t[0];let i;return t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("aside",{className:"shrink-0 h-full bg-sidebar pb-1",style:s,children:r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:r.jsx(su,{})})})}),t[1]=i):i=t[1],i}function Ey(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(j.Suspense,{fallback:null,children:r.jsx(Ay,{})}),t[0]=e):e=t[0],e}const Iy={settings:ip,automations:Fd,env:Ia,preview:Qd,git:er};function hc(t){const e=vr(t);if(e.type==="icon"){const s=br(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function io(t){if(t.kind==="system")return{kind:"component",Component:Iy[t.tabId]};const e=hc(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(n=>n.id===t.appId);if(!s)return{kind:"fallback"};const i=hc(s.icon);return i||{kind:"fallback"}}function Ty(t){const{org:e}=_e(),s=Ae({connectionId:yt,orgId:e.id}),{data:i}=bd({queryKey:Ze.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const n=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(n.structuredContent??n).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function wu(t){const e=O.c(8),s=Oe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const n=ti(i),o=$t(t.virtualMcpId),a=Ty(t.taskId),{currentBranch:l}=Lt(),c=o?.metadata?.ui??null,d=c?.layout??null,u=d?.tabs??[],h=c?.pinnedViews??[],f=a?.expanded_tools??[],m=!!(o&&bs(o));let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p={includeVirtual:!0},e[1]=p):p=e[1];const g=yr(p),{activeTab:_,mainOpen:b}=km({mainParam:n.main,metadata:d?{defaultMainView:d.defaultMainView??null,tabs:u.map(Ry)}:null}),x=Ad(_),v=[];m&&(v.push({id:"preview",title:"Preview"}),v.push({id:"env",title:"Terminal"}),v.push({id:"git",title:l??"git"})),v.push({id:"settings",title:"Settings"}),v.push({id:"automations",title:"Automations"});const y=new Map;for(const k of f){const T=jo(k.appId,k.toolName);y.set(T,{id:T,title:k.toolName,appId:k.appId,iconKey:k.toolName})}for(const k of h){const T=jo(k.connectionId,k.toolName);y.set(T,{id:T,title:k.label||k.toolName,appId:k.connectionId,iconKey:k.toolName,iconUrl:k.icon??null})}let V;e[2]!==g?(V=k=>({id:k.id,title:k.title,kind:"agent",icon:io({tabId:k.id,kind:"agent",appId:k.view.appId,connections:g})}),e[2]=g,e[3]=V):V=e[3];const C=[...u.map(V),...Array.from(y.values()).map(k=>({id:k.id,title:k.title,kind:"expanded",icon:io({tabId:k.iconKey,kind:"expanded",appId:k.appId,iconUrl:k.iconUrl,connections:g})})),...v.map(k=>({id:k.id,title:k.title,kind:"system",icon:io({tabId:k.id,kind:"system",connections:g})}))];let S;return e[4]!==_||e[5]!==b||e[6]!==s?(S=k=>{const T=jm({clickedId:k,activeTab:_,mainOpen:b});s({to:".",search:M=>({...M,main:T}),replace:!0})},e[4]=_,e[5]=b,e[6]=s,e[7]=S):S=e[7],{activeTab:_,mainOpen:b,setActiveTab:S,systemTabs:v,layoutTabs:u,expandedTools:f,automationTabParsed:x,tabs:C}}function Ry(t){return{id:t.id}}function My(t){const e=O.c(84),{value:s,onChange:i,onColorChange:n,name:o,size:a,className:l,avatarClassName:c,showHoverOverlay:d,disabled:u}=t,h=a===void 0?"lg":a,f=d===void 0?!0:d,m=u===void 0?!1:u,[p,g]=j.useState(!1),[_,b]=j.useState("icons"),[x,v]=j.useState(""),[y,V]=j.useState("blue");let C;e[0]!==s?(C=vr(s),e[0]=s,e[1]=C):C=e[1];const S=C,w=S.type==="icon"||S.type==="url"&&S.color?S.color:y;let k;e[2]!==i||e[3]!==w?(k=ve=>{i(Yn(ve,w))},e[2]=i,e[3]=w,e[4]=k):k=e[4];const T=k;let M;e[5]!==i||e[6]!==n||e[7]!==S.name||e[8]!==S.type||e[9]!==S.url?(M=ve=>{V(ve),n?.(ve),S.type==="icon"?i(Yn(S.name,ve)):S.type==="url"&&i(Sl(S.url,ve))},e[5]=i,e[6]=n,e[7]=S.name,e[8]=S.type,e[9]=S.url,e[10]=M):M=e[10];const I=M;let E;e[11]!==i||e[12]!==w?(E=ve=>{i(Sl(ve,w)),g(!1)},e[11]=i,e[12]=w,e[13]=E):E=e[13];const N=E;let A;e[14]!==i||e[15]!==w?(A=()=>{const ve=Ma(),Ve=ve[Math.floor(Math.random()*ve.length)];i(Yn(Ve,w))},e[14]=i,e[15]=w,e[16]=A):A=e[16];const D=A;let L,R,P,B,$,z,q,F;if(e[17]!==l||e[18]!==m||e[19]!==p||e[20]!==h){const ve={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};R=Us,z=m?!1:p,q=g,L=zs,$=!0,F="button",P=m,B=Y("relative group overflow-hidden",m?"cursor-default opacity-50":"cursor-pointer",ve[h],l),e[17]=l,e[18]=m,e[19]=p,e[20]=h,e[21]=L,e[22]=R,e[23]=P,e[24]=B,e[25]=$,e[26]=z,e[27]=q,e[28]=F}else L=e[21],R=e[22],P=e[23],B=e[24],$=e[25],z=e[26],q=e[27],F=e[28];let K;e[29]!==c||e[30]!==o||e[31]!==h||e[32]!==s?(K=r.jsx(Qt,{icon:s,name:o,size:h,className:c}),e[29]=c,e[30]=o,e[31]=h,e[32]=s,e[33]=K):K=e[33];let H;e[34]!==m||e[35]!==f?(H=f&&!m&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:r.jsx(Ra,{size:16,className:"text-white"})}),e[34]=m,e[35]=f,e[36]=H):H=e[36];let U;e[37]!==P||e[38]!==B||e[39]!==K||e[40]!==H||e[41]!==F?(U=r.jsxs("button",{type:F,disabled:P,className:B,children:[K,H]}),e[37]=P,e[38]=B,e[39]=K,e[40]=H,e[41]=F,e[42]=U):U=e[42];let X;e[43]!==L||e[44]!==$||e[45]!==U?(X=r.jsx(L,{asChild:$,children:U}),e[43]=L,e[44]=$,e[45]=U,e[46]=X):X=e[46];let W;e[47]!==o||e[48]!==s?(W=r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx(Qt,{icon:s,name:o,size:"xl"})}),e[47]=o,e[48]=s,e[49]=W):W=e[49];let G;e[50]===Symbol.for("react.memo_cache_sentinel")?(G=()=>b("icons"),e[50]=G):G=e[50];const se=_==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ee;e[51]!==se?(ee=Y("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",se),e[51]=se,e[52]=ee):ee=e[52];let J;e[53]!==ee?(J=r.jsx("button",{type:"button",onClick:G,className:ee,children:"Icons"}),e[53]=ee,e[54]=J):J=e[54];let ae;e[55]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>b("upload"),e[55]=ae):ae=e[55];const Z=_==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let de;e[56]!==Z?(de=Y("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",Z),e[56]=Z,e[57]=de):de=e[57];let me;e[58]!==de?(me=r.jsx("button",{type:"button",onClick:ae,className:de,children:"Upload"}),e[58]=de,e[59]=me):me=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx("div",{className:"flex-1"}),e[60]=le):le=e[60];let he;e[61]!==J||e[62]!==me?(he=r.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[J,me,le]}),e[61]=J,e[62]=me,e[63]=he):he=e[63];let be;e[64]!==I||e[65]!==D||e[66]!==T||e[67]!==N||e[68]!==S.name||e[69]!==S.type||e[70]!==x||e[71]!==w||e[72]!==_?(be=_==="icons"?r.jsx(Oy,{search:x,onSearchChange:v,selectedColor:w,onColorChange:I,onSelectIcon:T,onRandom:D,currentIconName:S.type==="icon"?S.name:null}):r.jsx(By,{onUpload:N}),e[64]=I,e[65]=D,e[66]=T,e[67]=N,e[68]=S.name,e[69]=S.type,e[70]=x,e[71]=w,e[72]=_,e[73]=be):be=e[73];let fe;e[74]!==W||e[75]!==he||e[76]!==be?(fe=r.jsx(Fs,{align:"start",className:"w-80 p-0",onOpenAutoFocus:Dy,children:r.jsxs("div",{className:"flex flex-col",children:[W,he,be]})}),e[74]=W,e[75]=he,e[76]=be,e[77]=fe):fe=e[77];let ye;return e[78]!==R||e[79]!==z||e[80]!==q||e[81]!==X||e[82]!==fe?(ye=r.jsxs(R,{open:z,onOpenChange:q,children:[X,fe]}),e[78]=R,e[79]=z,e[80]=q,e[81]=X,e[82]=fe,e[83]=ye):ye=e[83],ye}function Dy(t){return t.preventDefault()}function Py(t){const e=O.c(27),{selectedColor:s,onColorChange:i}=t,[n,o]=j.useState(!1);let a,l,c,d,u,h,f;if(e[0]!==n||e[1]!==s){const x=Ud(s);l=Us,h=n,f=o,a=zs,u=!0,c="button",d=Y("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",x.dot,"ring-foreground/20"),e[0]=n,e[1]=s,e[2]=a,e[3]=l,e[4]=c,e[5]=d,e[6]=u,e[7]=h,e[8]=f}else a=e[2],l=e[3],c=e[4],d=e[5],u=e[6],h=e[7],f=e[8];let m;e[9]!==c||e[10]!==d?(m=r.jsx("button",{type:c,className:d,title:"Change color"}),e[9]=c,e[10]=d,e[11]=m):m=e[11];let p;e[12]!==a||e[13]!==u||e[14]!==m?(p=r.jsx(a,{asChild:u,children:m}),e[12]=a,e[13]=u,e[14]=m,e[15]=p):p=e[15];let g;e[16]!==i||e[17]!==s?(g=np.map(x=>r.jsx("button",{type:"button",onClick:()=>{i(x.name),o(!1)},className:Y("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",x.dot,s===x.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:x.name},x.name)),e[16]=i,e[17]=s,e[18]=g):g=e[18];let _;e[19]!==g?(_=r.jsx(Fs,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Ly,children:r.jsx("div",{className:"grid grid-cols-4 gap-1",children:g})}),e[19]=g,e[20]=_):_=e[20];let b;return e[21]!==l||e[22]!==h||e[23]!==f||e[24]!==p||e[25]!==_?(b=r.jsxs(l,{open:h,onOpenChange:f,children:[p,_]}),e[21]=l,e[22]=h,e[23]=f,e[24]=p,e[25]=_,e[26]=b):b=e[26],b}function Ly(t){return t.preventDefault()}function Oy(t){const e=O.c(44),{search:s,onSearchChange:i,selectedColor:n,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:c}=t;let d,u,h,f,m,p,g;if(e[0]!==c||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==n){const y=Ma(),V=Ud(n);u=s.trim()?y.filter(I=>{const E=Ao(I),N=s.toLowerCase();return E.includes(N)||I.toLowerCase().includes(N)}):y,p="flex flex-col";let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(kh,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=C):C=e[14];let S;e[15]!==i?(S=I=>i(I.target.value),e[15]=i,e[16]=S):S=e[16];let w;e[17]!==s||e[18]!==S?(w=r.jsxs("div",{className:"relative flex-1",children:[C,r.jsx(at,{value:s,onChange:S,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=S,e[19]=w):w=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(rp,{size:14,className:"text-muted-foreground"}),e[20]=k):k=e[20];let T;e[21]!==l?(T=r.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:k}),e[21]=l,e[22]=T):T=e[22];let M;e[23]!==o||e[24]!==n?(M=r.jsx(Py,{selectedColor:n,onColorChange:o}),e[23]=o,e[24]=n,e[25]=M):M=e[25],e[26]!==T||e[27]!==M||e[28]!==w?(g=r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[w,T,M]}),e[26]=T,e[27]=M,e[28]=w,e[29]=g):g=e[29],d=Ed,m="h-56",h="grid grid-cols-9 gap-0.5 px-2 pb-2",f=u.map(I=>{const E=br(I);return E?r.jsx("button",{type:"button",onClick:()=>a(I),className:Y("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",c===I?Y(V.bg,V.text):Y(V.text,"hover:bg-accent")),title:I,children:r.jsx(E,{size:18})},I):null}),e[0]=c,e[1]=o,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=n,e[7]=d,e[8]=u,e[9]=h,e[10]=f,e[11]=m,e[12]=p,e[13]=g}else d=e[7],u=e[8],h=e[9],f=e[10],m=e[11],p=e[12],g=e[13];let _;e[30]!==h||e[31]!==f?(_=r.jsx("div",{className:h,children:f}),e[30]=h,e[31]=f,e[32]=_):_=e[32];let b;e[33]!==u.length?(b=u.length===0&&r.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=u.length,e[34]=b):b=e[34];let x;e[35]!==d||e[36]!==m||e[37]!==_||e[38]!==b?(x=r.jsxs(d,{className:m,children:[_,b]}),e[35]=d,e[36]=m,e[37]=_,e[38]=b,e[39]=x):x=e[39];let v;return e[40]!==p||e[41]!==g||e[42]!==x?(v=r.jsxs("div",{className:p,children:[g,x]}),e[40]=p,e[41]=g,e[42]=x,e[43]=v):v=e[43],v}function By(t){const e=O.c(27),{onUpload:s}=t,i=j.useRef(null);let n;e[0]!==s?(n=C=>{const S=C.target.files?.[0];if(!S)return;if(S.size>2097152){ue.error("Image must be smaller than 2MB"),C.target.value="";return}const w=new FileReader;w.onerror=()=>{ue.error("Failed to read image file"),i.current&&(i.current.value="")},w.onloadend=()=>{w.readyState===FileReader.DONE&&w.result&&s(w.result),i.current&&(i.current.value="")},w.readAsDataURL(S)},e[0]=s,e[1]=n):n=e[1];const o=n,[a,l]=j.useState("");let c;e[2]!==s||e[3]!==a?(c=()=>{const C=a.trim();C&&(s(C),l(""))},e[2]=s,e[3]=a,e[4]=c):c=e[4];const d=c;let u;e[5]!==o?(u=r.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:o}),e[5]=o,e[6]=u):u=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=()=>i.current?.click(),e[7]=h):h=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsxs("button",{type:"button",onClick:h,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[r.jsx(Jd,{size:20}),r.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=C=>l(C.target.value),e[10]=p):p=e[10];let g;e[11]!==d?(g=C=>{C.key==="Enter"&&(C.preventDefault(),d())},e[11]=d,e[12]=g):g=e[12];let _;e[13]!==a||e[14]!==g?(_=r.jsx(at,{value:a,onChange:p,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:g}),e[13]=a,e[14]=g,e[15]=_):_=e[15];let b;e[16]!==a?(b=a.trim(),e[16]=a,e[17]=b):b=e[17];const x=!b;let v;e[18]!==d||e[19]!==x?(v=r.jsx(oe,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:d,disabled:x,children:"Apply"}),e[18]=d,e[19]=x,e[20]=v):v=e[20];let y;e[21]!==v||e[22]!==_?(y=r.jsxs("div",{className:"flex items-center gap-1.5",children:[_,v]}),e[21]=v,e[22]=_,e[23]=y):y=e[23];let V;return e[24]!==y||e[25]!==u?(V=r.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,f,m,y]}),e[24]=y,e[25]=u,e[26]=V):V=e[26],V}function $y(t){const e=O.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=vr(s);if(o.type==="icon"){const a=br(o.name);if(a){let l;e[2]!==a?(l=r.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let n;return e[4]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(xh,{size:16,className:"text-muted-foreground"}),e[4]=n):n=e[4],n}function zy(t){const e=O.c(66),{value:s,onChange:i,className:n,disabled:o}=t,[a,l]=j.useState(!1),[c,d]=j.useState("");let u;e[0]!==s?(u=vr(s),e[0]=s,e[1]=u):u=e[1];const h=u,f=h.type==="icon"?h.name:null;let m,p,g,_,b,x,v,y,V,C,S,w,k,T,M;if(e[2]!==n||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==c||e[8]!==s){const R=Ma();_=c.trim()?R.filter(K=>{const H=c.toLowerCase();return Ao(K).includes(H)||K.toLowerCase().includes(H)}):R,g=Us,b=o?!1:a,x=l;const P=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let B;e[24]!==n||e[25]!==P?(B=Y("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",P,n),e[24]=n,e[25]=P,e[26]=B):B=e[26];let $;e[27]!==s?($=r.jsx($y,{value:s}),e[27]=s,e[28]=$):$=e[28],e[29]!==o||e[30]!==B||e[31]!==$?(v=r.jsx(zs,{asChild:!0,children:r.jsx("button",{type:"button",disabled:o,className:B,children:$})}),e[29]=o,e[30]=B,e[31]=$,e[32]=v):v=e[32],p=Fs,k="start",T="w-64 p-0",M=Fy,S="flex flex-col";let z;e[33]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(kh,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=z):z=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=K=>d(K.target.value),e[34]=q):q=e[34],e[35]!==c?(w=r.jsx("div",{className:"px-2 py-2",children:r.jsxs("div",{className:"relative",children:[z,r.jsx(at,{value:c,onChange:q,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=c,e[36]=w):w=e[36],m=Ed,C="h-48",y="grid grid-cols-8 gap-0.5 px-2 pb-2";let F;e[37]!==f||e[38]!==i?(F=K=>{const H=br(K);return H?r.jsx("button",{type:"button",onClick:()=>{i(`icon://${K}`),l(!1)},className:Y("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===K?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:Ao(K),children:r.jsx(H,{size:16})},K):null},e[37]=f,e[38]=i,e[39]=F):F=e[39],V=_.map(F),e[2]=n,e[3]=f,e[4]=o,e[5]=i,e[6]=a,e[7]=c,e[8]=s,e[9]=m,e[10]=p,e[11]=g,e[12]=_,e[13]=b,e[14]=x,e[15]=v,e[16]=y,e[17]=V,e[18]=C,e[19]=S,e[20]=w,e[21]=k,e[22]=T,e[23]=M}else m=e[9],p=e[10],g=e[11],_=e[12],b=e[13],x=e[14],v=e[15],y=e[16],V=e[17],C=e[18],S=e[19],w=e[20],k=e[21],T=e[22],M=e[23];let I;e[40]!==y||e[41]!==V?(I=r.jsx("div",{className:y,children:V}),e[40]=y,e[41]=V,e[42]=I):I=e[42];let E;e[43]!==_.length?(E=_.length===0&&r.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=_.length,e[44]=E):E=e[44];let N;e[45]!==m||e[46]!==I||e[47]!==E||e[48]!==C?(N=r.jsxs(m,{className:C,children:[I,E]}),e[45]=m,e[46]=I,e[47]=E,e[48]=C,e[49]=N):N=e[49];let A;e[50]!==N||e[51]!==S||e[52]!==w?(A=r.jsxs("div",{className:S,children:[w,N]}),e[50]=N,e[51]=S,e[52]=w,e[53]=A):A=e[53];let D;e[54]!==p||e[55]!==A||e[56]!==k||e[57]!==T||e[58]!==M?(D=r.jsx(p,{align:k,className:T,onOpenAutoFocus:M,children:A}),e[54]=p,e[55]=A,e[56]=k,e[57]=T,e[58]=M,e[59]=D):D=e[59];let L;return e[60]!==g||e[61]!==b||e[62]!==x||e[63]!==v||e[64]!==D?(L=r.jsxs(g,{open:b,onOpenChange:x,children:[v,D]}),e[60]=g,e[61]=b,e[62]=x,e[63]=v,e[64]=D,e[65]=L):L=e[65],L}function Fy(t){return t.preventDefault()}function rn(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(Ne,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function ro(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[r.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:r.jsx(wa,{className:"h-6 w-6 text-destructive"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),r.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function Uy(t){const e=O.c(23),{item:s,isSelected:i,onToggle:n,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let c;e[0]!==a||e[1]!==l?(c=Y("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==s.name?(d=r.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=d):d=e[4];let u;e[5]!==s.tags?(u=s.tags&&r.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=u):u=e[6];let h;e[7]!==d||e[8]!==u?(h=r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d,u]}),e[7]=d,e[8]=u,e[9]=h):h=e[9];let f;e[10]!==s.description?(f=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let m;e[12]!==h||e[13]!==f?(m=r.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[h,f]}),e[12]=h,e[13]=f,e[14]=m):m=e[14];let p;e[15]!==o||e[16]!==i||e[17]!==n?(p=r.jsx(kg,{checked:i,onCheckedChange:n,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=i,e[17]=n,e[18]=p):p=e[18];let g;return e[19]!==c||e[20]!==m||e[21]!==p?(g=r.jsxs("label",{className:c,children:[m,p]}),e[19]=c,e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function sl(t){const e=O.c(13),{items:s,selections:i,onToggle:n,emptyMessage:o,disabled:a}=t;let l,c,d;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==n||e[4]!==i){d=Symbol.for("react.early_return_sentinel");e:{const h=s.map(Hy);if(s.length===0){let f;e[8]!==o?(f=r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],d=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",c=s.map(f=>r.jsx(Uy,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>n(f.id,h),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=n,e[4]=i,e[5]=l,e[6]=c,e[7]=d}else l=e[5],c=e[6],d=e[7];if(d!==Symbol.for("react.early_return_sentinel"))return d;let u;return e[10]!==l||e[11]!==c?(u=r.jsx("div",{className:l,children:c}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function Hy(t){return t.id}function Wy(t){const e=O.c(12),{connectionId:s,selections:i,onToggle:n,disabled:o}=t,{org:a}=_e();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const c=Ae(l);let d;e[3]!==c?(d={client:c},e[3]=c,e[4]=d):d=e[4];const{data:u}=Jp(d);let h;e[5]!==u.tools?(h=u.tools.map(Ky),e[5]=u.tools,e[6]=h):h=e[6];const f=h;let m;return e[7]!==o||e[8]!==f||e[9]!==n||e[10]!==i?(m=r.jsx(sl,{items:f,selections:i,onToggle:n,emptyMessage:"No tools available",disabled:o}),e[7]=o,e[8]=f,e[9]=n,e[10]=i,e[11]=m):m=e[11],m}function Ky(t){return{id:t.name,name:t.name,description:t.description,tags:r.jsx(wg,{annotations:t.annotations,_meta:t._meta})}}function qy(t){const e=O.c(12),{connectionId:s,selections:i,onToggle:n,disabled:o}=t,{org:a}=_e();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const c=Ae(l);let d;e[3]!==c?(d={client:c},e[3]=c,e[4]=d):d=e[4];const{data:u}=Ep(d);let h;e[5]!==u.resources?(h=u.resources.map(Gy),e[5]=u.resources,e[6]=h):h=e[6];const f=h;let m;return e[7]!==o||e[8]!==f||e[9]!==n||e[10]!==i?(m=r.jsx(sl,{items:f,selections:i,onToggle:n,emptyMessage:"No resources available",disabled:o}),e[7]=o,e[8]=f,e[9]=n,e[10]=i,e[11]=m):m=e[11],m}function Gy(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Yy(t){const e=O.c(12),{connectionId:s,selections:i,onToggle:n,disabled:o}=t,{org:a}=_e();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const c=Ae(l);let d;e[3]!==c?(d={client:c},e[3]=c,e[4]=d):d=e[4];const{data:u}=Td(d);let h;e[5]!==u.prompts?(h=u.prompts.map(Xy),e[5]=u.prompts,e[6]=h):h=e[6];const f=h;let m;return e[7]!==o||e[8]!==f||e[9]!==n||e[10]!==i?(m=r.jsx(sl,{items:f,selections:i,onToggle:n,emptyMessage:"No prompts available",disabled:o}),e[7]=o,e[8]=f,e[9]=n,e[10]=i,e[11]=m):m=e[11],m}function Xy(t){return{id:t.name,name:t.name,description:t.description}}function Jy(t){const e=O.c(54),{currentConnection:s,activeTab:i,selectedId:n,formData:o,toggleTool:a,toggleResource:l,togglePrompt:c,toggleAllTools:d,toggleAllResources:u,toggleAllPrompts:h,onTabChange:f}=t,m=o[n],p=i==="tools"?m?.tools===null:i==="resources"?m?.resources===null:m?.prompts===null;let g;e[0]!==i||e[1]!==n||e[2]!==h||e[3]!==u||e[4]!==d?(g=()=>{i==="tools"?d(n):i==="resources"?u(n):h(n)},e[0]=i,e[1]=n,e[2]=h,e[3]=u,e[4]=d,e[5]=g):g=e[5];const _=g;let b;e[6]!==s.icon||e[7]!==s.title?(b=r.jsx(ps,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=b):b=e[8];let x;e[9]!==s.title?(x=r.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=x):x=e[10];let v;e[11]!==s.description?(v=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=v):v=e[12];let y;e[13]!==x||e[14]!==v?(y=r.jsxs("div",{className:"flex-1 min-w-0",children:[x,v]}),e[13]=x,e[14]=v,e[15]=y):y=e[15];let V;e[16]!==b||e[17]!==y?(V=r.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-3",children:[b,y]})}),e[16]=b,e[17]=y,e[18]=V):V=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=C):C=e[19];let S;e[20]!==f?(S=L=>f(L),e[20]=f,e[21]=S):S=e[21];let w;e[22]!==i||e[23]!==S?(w=r.jsx(ch,{tabs:C,activeTab:i,onTabChange:S}),e[22]=i,e[23]=S,e[24]=w):w=e[24];const k=p?"Deselect all":"Select all";let T;e[25]!==_||e[26]!==k?(T=r.jsx("button",{type:"button",onClick:_,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:k}),e[25]=_,e[26]=k,e[27]=T):T=e[27];let M;e[28]!==T||e[29]!==w?(M=r.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[w,T]}),e[28]=T,e[29]=w,e[30]=M):M=e[30];let I;e[31]!==i||e[32]!==o||e[33]!==n||e[34]!==a?(I=i==="tools"&&r.jsx(ls,{fallback:ro("Tools not supported by this server"),children:r.jsx(j.Suspense,{fallback:r.jsx(rn,{}),children:r.jsx(Wy,{connectionId:n,selections:o[n]?o[n].tools:[],onToggle:(L,R)=>a(n,L,R)})})}),e[31]=i,e[32]=o,e[33]=n,e[34]=a,e[35]=I):I=e[35];let E;e[36]!==i||e[37]!==o||e[38]!==n||e[39]!==l?(E=i==="resources"&&r.jsx(ls,{fallback:ro("Resources not supported by this server"),children:r.jsx(j.Suspense,{fallback:r.jsx(rn,{}),children:r.jsx(qy,{connectionId:n,selections:o[n]?o[n].resources:[],onToggle:(L,R)=>l(n,L,R)})})}),e[36]=i,e[37]=o,e[38]=n,e[39]=l,e[40]=E):E=e[40];let N;e[41]!==i||e[42]!==o||e[43]!==n||e[44]!==c?(N=i==="prompts"&&r.jsx(ls,{fallback:ro("Prompts not supported by this server"),children:r.jsx(j.Suspense,{fallback:r.jsx(rn,{}),children:r.jsx(Yy,{connectionId:n,selections:o[n]?o[n].prompts:[],onToggle:(L,R)=>c(n,L,R)})})}),e[41]=i,e[42]=o,e[43]=n,e[44]=c,e[45]=N):N=e[45];let A;e[46]!==I||e[47]!==E||e[48]!==N?(A=r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[I,E,N]}),e[46]=I,e[47]=E,e[48]=N,e[49]=A):A=e[49];let D;return e[50]!==M||e[51]!==A||e[52]!==V?(D=r.jsxs(r.Fragment,{children:[V,M,A]}),e[50]=M,e[51]=A,e[52]=V,e[53]=D):D=e[53],D}function Qy(t){const e=O.c(11),{connectionId:s,onAuthenticate:i,children:n}=t;let o;e[0]!==s?(o={connectionId:s},e[0]=s,e[1]=o):o=e[1];const a=Ch(o);if(a.supportsOAuth&&!a.isAuthenticated){let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:r.jsx(op,{size:22,className:"text-muted-foreground"})}),e[2]=d):d=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),r.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=u):u=e[3];let h;e[4]!==s||e[5]!==i?(h=i&&r.jsx(oe,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=h):h=e[6];let f;return e[7]!==h?(f=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[d,u,h]}),e[7]=h,e[8]=f):f=e[8],f}let c;return e[9]!==n?(c=r.jsx(r.Fragment,{children:n}),e[9]=n,e[10]=c):c=e[10],c}function Zy(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function uc(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function e2(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function t2(t){const e=O.c(49),{open:s,onOpenChange:i,selectedId:n,form:o,connections:a,onAuthenticate:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activeTab:"tools"},e[0]=c):c=e[0];const[d,u]=j.useReducer(e2,c),h=Ba(n??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=Zy(f),e[3]=f,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==p?(g=(z,q,F,K)=>{const H=p[z]?.[q];let U;H===null?U=K.filter(W=>W!==F):H?.includes(F)?U=H.filter(W=>W!==F):(U=[...H??[],F],U.length===K.length&&(U=null));const X={...p};X[z]?X[z]={...X[z]}:X[z]={tools:null,resources:null,prompts:null},X[z][q]=U,o.setValue("connections",uc(X),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=g):g=e[7];const _=g;let b;e[8]!==o||e[9]!==p?(b=(z,q)=>{const K=p[z]?.[q]===null?[]:null,H={...p};H[z]?H[z]={...H[z]}:H[z]={tools:null,resources:null,prompts:null},H[z][q]=K,o.setValue("connections",uc(H),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=b):b=e[10];const x=b;let v;e[11]!==_?(v=(z,q,F)=>_(z,"tools",q,F),e[11]=_,e[12]=v):v=e[12];const y=v;let V;e[13]!==_?(V=(z,q,F)=>_(z,"resources",q,F),e[13]=_,e[14]=V):V=e[14];const C=V;let S;e[15]!==_?(S=(z,q,F)=>_(z,"prompts",q,F),e[15]=_,e[16]=S):S=e[16];const w=S;let k;e[17]!==x?(k=z=>x(z,"tools"),e[17]=x,e[18]=k):k=e[18];const T=k;let M;e[19]!==x?(M=z=>x(z,"resources"),e[19]=x,e[20]=M):M=e[20];const I=M;let E;e[21]!==x?(E=z=>x(z,"prompts"),e[21]=x,e[22]=E):E=e[22];const N=E;if(!n||!h)return null;let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(rn,{}),e[23]=A):A=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=z=>u({type:"SET_ACTIVE_TAB",payload:z}),e[24]=D):D=e[24];let L;e[25]!==h||e[26]!==d.activeTab||e[27]!==p||e[28]!==n||e[29]!==N||e[30]!==I||e[31]!==T||e[32]!==w||e[33]!==C||e[34]!==y?(L=r.jsx(Jy,{currentConnection:h,activeTab:d.activeTab,selectedId:n,formData:p,toggleTool:y,toggleResource:C,togglePrompt:w,toggleAllTools:T,toggleAllResources:I,toggleAllPrompts:N,onTabChange:D},n),e[25]=h,e[26]=d.activeTab,e[27]=p,e[28]=n,e[29]=N,e[30]=I,e[31]=T,e[32]=w,e[33]=C,e[34]=y,e[35]=L):L=e[35];let R;e[36]!==l||e[37]!==n||e[38]!==L?(R=r.jsx(j.Suspense,{fallback:A,children:r.jsx(Qy,{connectionId:n,onAuthenticate:l,children:L})}),e[36]=l,e[37]=n,e[38]=L,e[39]=R):R=e[39];let P;e[40]!==i?(P=r.jsx(Na,{className:"px-6 py-4 border-t border-border shrink-0",children:r.jsx(oe,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=P):P=e[41];let B;e[42]!==R||e[43]!==P?(B=r.jsxs(Ot,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[R,P]}),e[42]=R,e[43]=P,e[44]=B):B=e[44];let $;return e[45]!==i||e[46]!==s||e[47]!==B?($=r.jsx(Bt,{open:s,onOpenChange:i,children:B}),e[45]=i,e[46]=s,e[47]=B,e[48]=$):$=e[48],$}const no={tools:null,resources:null,prompts:null},s2=cm.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function i2(t){const s=new TextEncoder().encode(t),i=Array.from(s,n=>String.fromCharCode(n)).join("");return btoa(i)}function r2(t){const e=O.c(11),{url:s,agentId:i}=t,[n,o]=j.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{re("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),ue.success("Agent URL copied to clipboard"),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let c;e[3]!==n?(c=n?r.jsx(Mt,{size:20,className:"text-green-600"}):r.jsx(Si,{size:20}),e[3]=n,e[4]=c):c=e[4];const d=n?"Copied!":"Copy URL";let u;e[5]!==d?(u=r.jsx("span",{className:"text-xs font-medium",children:d}),e[5]=d,e[6]=u):u=e[6];let h;return e[7]!==l||e[8]!==c||e[9]!==u?(h=r.jsxs(oe,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,u]}),e[7]=l,e[8]=c,e[9]=u,e[10]=h):h=e[10],h}function n2(t){const e=O.c(8),{url:s,serverName:i,agentId:n}=t;let o;e[0]!==n||e[1]!==i||e[2]!==s?(o=()=>{re("agent_connect_action",{agent_id:n,action:"install_cursor"});const u=oh(i),f=i2(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(f)}`;window.open(m,"_blank"),ue.success("Opening Cursor...")},e[0]=n,e[1]=i,e[2]=s,e[3]=o):o=e[3];const a=o;let l,c;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),c=r.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=c):(l=e[4],c=e[5]);let d;return e[6]!==a?(d=r.jsxs(oe,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,c]}),e[6]=a,e[7]=d):d=e[7],d}function o2(t){const e=O.c(12),{url:s,serverName:i,agentId:n}=t,[o,a]=j.useState(!1);let l;e[0]!==n||e[1]!==i||e[2]!==s?(l=async()=>{re("agent_connect_action",{agent_id:n,action:"install_claude_code"});const m=oh(i),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),_=`claude mcp add-json "${m}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(_),a(!0),ue.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=n,e[1]=i,e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==o?(d=o?r.jsx(Mt,{size:20,className:"text-green-600"}):r.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=o,e[5]=d):d=e[5];const u=o?"Copied!":"Install on Claude Code";let h;e[6]!==u?(h=r.jsx("span",{className:"text-xs font-medium",children:u}),e[6]=u,e[7]=h):h=e[7];let f;return e[8]!==c||e[9]!==d||e[10]!==h?(f=r.jsxs(oe,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,h]}),e[8]=c,e[9]=d,e[10]=h,e[11]=f):f=e[11],f}function a2({virtualMcp:t}){const{org:e}=_e(),s=Ae({connectionId:yt,orgId:e.id}),[i,n]=j.useState(null),[o,a]=j.useState(!1),[l,c]=j.useState(!1),d=t.id,u=t.title||`agent-${d.slice(0,8)}`,h=i?`bunx @decocms/typegen@latest --mcp ${d} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${d} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const g=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${u}`,permissions:{[d]:["*"]}}})).structuredContent?.key;if(!g)throw new Error("No key in response");n(g),re("agent_typegen_key_generated",{agent_id:d})}catch{re("agent_typegen_key_failed",{agent_id:d}),ue.error("Failed to generate API key")}finally{a(!1)}},m=async()=>{re("agent_connect_action",{agent_id:d,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(h),c(!0),ue.success("Command copied to clipboard"),setTimeout(()=>c(!1),2e3)};return r.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",r.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&r.jsxs(oe,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?r.jsx(Ne,{size:14,className:"animate-spin"}):r.jsx(Cg,{size:14}),r.jsx("span",{children:o?"Generating…":"Generate API key"})]})]}),i&&r.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:h}),r.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?r.jsx(Mt,{size:12,className:"text-green-600"}):r.jsx(Si,{size:12})})]})}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),r.jsx(l2,{apiKey:i,agentId:d})]})}function l2(t){const e=O.c(21),{apiKey:s,agentId:i}=t,[n,o]=j.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",c=`MESH_BASE_URL=${a}`,d=`${l}
|
|
548
|
+
`}]}}function Ws(t){return{type:"paragraph",content:t}}function Cs(t){return{type:"text",text:t}}function nv({agentId:t,title:e}){return{type:"mention",attrs:{id:t,name:e,char:"@",metadata:{agentId:t,title:e}}}}const qi="deco/site-diagnostics";function Qh(t){const e=O.c(15),{open:s,onOpenChange:i}=t,[n,o]=j.useState(null);let a;e[0]!==i?(a=()=>{o(null),i(!1)},e[0]=i,e[1]=a):a=e[1];const l=a,c=s&&n===null;let d;e[2]!==n||e[3]!==i?(d=p=>{!p&&n===null&&i(!1)},e[2]=n,e[3]=i,e[4]=d):d=e[4];let u;e[5]!==c||e[6]!==d?(u=r.jsx(hh,{open:c,onOpenChange:d,title:"Set up self-healing repo",hideAutoRespondCheckbox:!0,onImportComplete:o}),e[5]=c,e[6]=d,e[7]=u):u=e[7];const h=s&&n!==null;let f;e[8]!==l||e[9]!==n||e[10]!==h?(f=r.jsx(ov,{open:h,payload:n,onClose:l}),e[8]=l,e[9]=n,e[10]=h,e[11]=f):f=e[11];let m;return e[12]!==u||e[13]!==f?(m=r.jsxs(r.Fragment,{children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14],m}function ov(t){const e=O.c(66),{open:s,payload:i,onClose:n}=t,{org:o}=_e(),a=Sr(),l=Mn();let c;e[0]!==o.id?(c={connectionId:yt,orgId:o.id},e[0]=o.id,e[1]=c):c=e[1];const d=Ae(c),[u,h]=j.useState(""),[f,m]=j.useState(cv);let p;e[2]!==s?(p={enabled:s},e[2]=s,e[3]=p):p=e[3];const{data:g}=Hp(qi,p);let _;e[4]!==l||e[5]!==f||e[6]!==i||e[7]!==d||e[8]!==g||e[9]!==u?(_=async()=>{if(!i)throw new Error("No imported repo payload");const X=Zl(u);if(!X)throw new Error("Enter a valid https:// URL");const W=Oo.filter(J=>f[J.id]);if(W.length===0)return{succeeded:[],failed:[]};const G=await fv({selfClient:d,createConnection:l.create.mutateAsync,registry:g}),se=[],ee=[];for(const J of W)try{await mv({template:J,selfClient:d,siteDiagnosticsConnectionId:G,projectAgentId:i.virtualMcpId,owner:i.repo.owner,repo:i.repo.name,siteRootUrl:X}),se.push(J.title)}catch(ae){const Z=ae;console.error(`Failed to set up ${J.title}:`,Z),ee.push(J.title)}return{succeeded:se,failed:ee}},e[4]=l,e[5]=f,e[6]=i,e[7]=d,e[8]=g,e[9]=u,e[10]=_):_=e[10];let b;e[11]!==a||e[12]!==n||e[13]!==i?.virtualMcpId?(b=X=>{const{succeeded:W,failed:G}=X;W.length>0?ue.success(`Self-healing repo ready — ${W.length} specialist${W.length>1?"s":""} set up`):G.length===0&&ue.success("Repo imported. Add specialists later from automations."),G.length>0&&ue.warning(`Could not set up: ${G.join(", ")}. You can add them later from the automations view.`);const se=i?.virtualMcpId;n(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),se&&a(se)},e[11]=a,e[12]=n,e[13]=i?.virtualMcpId,e[14]=b):b=e[14];let x;e[15]!==_||e[16]!==b?(x={mutationFn:_,onSuccess:b,onError:lv},e[15]=_,e[16]=b,e[17]=x):x=e[17];const v=Ni(x);let y;e[18]!==v.isPending||e[19]!==u?(y=Zl(u)!==null&&!v.isPending,e[18]=v.isPending,e[19]=u,e[20]=y):y=e[20];const V=y;let C;e[21]!==n||e[22]!==v.isPending?(C=X=>{!X&&!v.isPending&&n()},e[21]=n,e[22]=v.isPending,e[23]=C):C=e[23];let S;e[24]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Gt,{className:"h-12 border-b border-border px-4 flex flex-row items-center shrink-0 space-y-0",children:r.jsx(qt,{className:"text-sm font-medium text-foreground",children:"Add specialist monitors"})}),e[24]=S):S=e[24];let w;e[25]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Specialists run on a daily schedule. Your repo agent collects their findings and opens GitHub issues, then writes the fixes."}),e[25]=w):w=e[25];let k;e[26]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("label",{htmlFor:"self-healing-site-url",className:"text-xs font-medium text-foreground",children:"Production URL"}),e[26]=k):k=e[26];let T;e[27]===Symbol.for("react.memo_cache_sentinel")?(T=X=>h(X.target.value),e[27]=T):T=e[27];let M;e[28]!==u?(M=r.jsx(at,{id:"self-healing-site-url",type:"url",placeholder:"https://example.com",value:u,onChange:T,autoFocus:!0}),e[28]=u,e[29]=M):M=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("p",{className:"text-xs text-muted-foreground",children:"The site the specialists will monitor."}),e[30]=I):I=e[30];let E;e[31]!==M?(E=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[k,M,I]}),e[31]=M,e[32]=E):E=e[32];let N;e[33]!==f?(N=Oo.map(X=>r.jsx(dv,{template:X,enabled:f[X.id]??!1,onToggle:W=>m(G=>({...G,[X.id]:W}))},X.id)),e[33]=f,e[34]=N):N=e[34];let A,D;e[35]===Symbol.for("react.memo_cache_sentinel")?(A=sv.map(av),D=r.jsx(uv,{}),e[35]=A,e[36]=D):(A=e[35],D=e[36]);let L;e[37]!==N?(L=r.jsxs("div",{className:"flex flex-col gap-2",children:[N,A,D]}),e[37]=N,e[38]=L):L=e[38];let R;e[39]!==E||e[40]!==L?(R=r.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 flex flex-col gap-4",children:[w,E,L]}),e[39]=E,e[40]=L,e[41]=R):R=e[41];let P;e[42]!==a||e[43]!==n||e[44]!==i?.virtualMcpId||e[45]!==v.isPending?(P=()=>{if(!v.isPending){const X=i?.virtualMcpId;n(),X&&a(X)}},e[42]=a,e[43]=n,e[44]=i?.virtualMcpId,e[45]=v.isPending,e[46]=P):P=e[46];let B;e[47]!==v.isPending||e[48]!==P?(B=r.jsx("button",{type:"button",onClick:P,disabled:v.isPending,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 cursor-pointer",children:"Skip for now"}),e[47]=v.isPending,e[48]=P,e[49]=B):B=e[49];let $;e[50]!==v?($=()=>v.mutate(),e[50]=v,e[51]=$):$=e[51];const z=!V,q=v.isPending?"Setting up...":"Set up specialists";let F;e[52]!==$||e[53]!==z||e[54]!==q?(F=r.jsx(oe,{onClick:$,disabled:z,size:"sm",children:q}),e[52]=$,e[53]=z,e[54]=q,e[55]=F):F=e[55];let K;e[56]!==B||e[57]!==F?(K=r.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center justify-between gap-3 shrink-0",children:[B,F]}),e[56]=B,e[57]=F,e[58]=K):K=e[58];let H;e[59]!==R||e[60]!==K?(H=r.jsxs(Ot,{className:"sm:max-w-[560px] max-h-[85svh] p-0 gap-0 overflow-hidden flex flex-col",children:[S,R,K]}),e[59]=R,e[60]=K,e[61]=H):H=e[61];let U;return e[62]!==s||e[63]!==H||e[64]!==C?(U=r.jsx(Bt,{open:s,onOpenChange:C,children:H}),e[62]=s,e[63]=H,e[64]=C,e[65]=U):U=e[65],U}function av(t){return r.jsx(hv,{title:t.title,description:t.description,icon:t.icon},t.id)}function lv(t){ue.error("Failed to set up specialists: "+(t instanceof Error?t.message:"Unknown error"))}function cv(){const t={};for(const e of Oo)t[e.id]=!0;return t}function dv(t){const e=O.c(20),{template:s,enabled:i,onToggle:n}=t,o=i?"bg-accent/30":"hover:bg-accent/30";let a;e[0]!==o?(a=Y("flex items-center gap-3 rounded-lg border border-border px-3 py-3 cursor-pointer transition-colors",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==s.icon||e[3]!==s.title?(l=r.jsx(Qt,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=l):l=e[4];let c;e[5]!==s.title?(c=r.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s.title}),e[5]=s.title,e[6]=c):c=e[6];let d;e[7]!==s.description?(d=r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[7]=s.description,e[8]=d):d=e[8];let u;e[9]!==c||e[10]!==d?(u=r.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[c,d]}),e[9]=c,e[10]=d,e[11]=u):u=e[11];let h;e[12]!==i||e[13]!==n?(h=r.jsx(mn,{checked:i,onCheckedChange:n,className:"shrink-0"}),e[12]=i,e[13]=n,e[14]=h):h=e[14];let f;return e[15]!==a||e[16]!==l||e[17]!==u||e[18]!==h?(f=r.jsxs("label",{className:a,children:[l,u,h]}),e[15]=a,e[16]=l,e[17]=u,e[18]=h,e[19]=f):f=e[19],f}function hv(t){const e=O.c(14),{title:s,description:i,icon:n}=t;let o;e[0]!==n||e[1]!==s?(o=r.jsx(Qt,{icon:n,name:s,size:"sm",className:"shrink-0"}),e[0]=n,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==s?(a=r.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s}),e[3]=s,e[4]=a):a=e[4];let l;e[5]!==i?(l=r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:i}),e[5]=i,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==l?(c=r.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a,l]}),e[7]=a,e[8]=l,e[9]=c):c=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground shrink-0",children:"Coming soon"}),e[10]=d):d=e[10];let u;return e[11]!==o||e[12]!==c?(u=r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-dashed border-border px-3 py-3 opacity-60",children:[o,c,d]}),e[11]=o,e[12]=c,e[13]=u):u=e[13],u}function uv(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center justify-center rounded-lg border border-dashed border-border px-3 py-3 text-xs text-muted-foreground",children:"More specialists coming soon"}),t[0]=e):e=t[0],e}function Zl(t){const e=t.trim();if(!e)return null;try{const s=new URL(e);return s.protocol!=="https:"&&s.protocol!=="http:"?null:s.origin+(s.pathname==="/"?"":s.pathname)}catch{return null}}async function fv({selfClient:t,createConnection:e,registry:s}){const n=(await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:qi},limit:1,offset:0}})).structuredContent?.items?.find(u=>u.app_id===qi);if(n)return n.id;const o=s?.server?.remotes?.[0]?.url;if(!o)throw new Error("Site Diagnostics MCP is not available in the registry right now.");const a=s?.title??s?.server?.title??s?.server?.name??"Site Diagnostics",l=s?.server?.icons?.[0]?.src??null,c=s?.server?.description??null;return(await e({title:a,description:c,icon:l,connection_type:"HTTP",connection_url:o,app_name:s?.server?.name??"site-diagnostics",app_id:qi,metadata:{type:"site-diagnostics",source:"store",registry_item_id:qi,verified:!0}})).id}async function mv({template:t,selfClient:e,siteDiagnosticsConnectionId:s,projectAgentId:i,owner:n,repo:o,siteRootUrl:a}){const l=`${o}: ${t.title}`,d=(await e.callTool({name:"AUTOMATION_LIST",arguments:{virtual_mcp_id:i}})).structuredContent?.automations?.find(h=>h.name===l);let u;if(!(d&&d.trigger_count>0)){if(d)u=d.id;else{const h=await pv({template:t,selfClient:e,siteDiagnosticsConnectionId:s}),f=iv({template:t,specialistAgentId:h,owner:n,repo:o,siteRootUrl:a}),m=jd(f),p=await e.callTool({name:"AUTOMATION_CREATE",arguments:{name:l,virtual_mcp_id:i,agent:{id:i},messages:m,active:!0}});u=(p.structuredContent??p).id}await e.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:u,type:"cron",cron_expression:t.cron}})}}async function pv({template:t,selfClient:e,siteDiagnosticsConnectionId:s}){const n=(await e.callTool({name:"COLLECTION_VIRTUAL_MCP_LIST",arguments:{where:{field:["metadata","specialistId"],operator:"eq",value:t.id},limit:1,offset:0}})).structuredContent?.items?.find(l=>l.metadata?.specialistId===t.id);if(n)return n.id;const o=await e.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:t.title,description:t.description,icon:t.icon,pinned:!1,metadata:{specialistId:t.id,instructions:t.instructions},connections:[{connection_id:s,selected_tools:t.siteDiagnosticsTools,selected_resources:null,selected_prompts:null}]}}});return(o.structuredContent??o).item.id}function gv(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}const _v=8;function ec(t){const e=O.c(21),{agent:s,onSpecialClick:i,tracking:n}=t,{org:o}=_e(),a=Oe();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==n.action||e[6]!==n.template_id||e[7]!==n.tile_kind?(l=()=>{if(re("home_agent_tile_clicked",{template_id:n.template_id,agent_id:s.id,agent_title:s.title,tile_kind:n.tile_kind,action:n.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=n.action,e[6]=n.template_id,e[7]=n.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Dn,{size:24}),e[10]=h):h=e[10];let f;e[11]!==s.icon||e[12]!==s.title?(f=r.jsx(ps,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=f):f=e[13];let m;e[14]!==s.title?(m=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=m):m=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==f||e[19]!==m?(p=r.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[f,m]}),e[16]=c,e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20],p}function xv(){const t=O.c(8),e=Oe(),{org:s}=_e();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let n;t[1]!==e||t[2]!==s.slug?(n=()=>{re("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=n):n=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx($a,{size:20,className:"text-foreground"})}),a=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==n?(l=r.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:n,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function vv(){const t=O.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=_h(e);let n;t[1]!==s?(n=()=>{re("home_create_agent_clicked"),s()},t[1]=s,t[2]=n):n=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Dt,{size:20,className:"text-muted-foreground"})}),l=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==n?(c=r.jsxs("button",{type:"button",onClick:n,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=n,t[8]=c):c=t[8],c}function Br(t,e,s){return t.find(i=>i.id!==null&&(i.metadata?.type===e||i.title===s))}function bv(){const t=O.c(52),e=Rn(),{locator:s}=_e(),i=Up(),[n,o]=j.useState(!1),[a,l]=j.useState(!1),[c,d]=j.useState(!1),[u,h]=j.useState(!1),[f,m]=j.useState(!1),[p,g]=j.useState(!1),[_,b]=j.useState(!1),[x]=ei(),v=Sr();let y,V,C,S,w,k,T,M;if(t[0]!==s||t[1]!==v||t[2]!==i||t[3]!==x||t[4]!==e){const F=jt.find(Tv),K=jt.find(Iv),H=jt.find(Ev),U=jt.find(Av),X=jt.find(Nv),W=jt.find(jv),G=jt.find(kv);C=Br(e,K.id,K.title),y=Br(e,H.id,H.title),V=Br(e,U.id,U.title),S=Br(e,X.id,X.title);const se=Z=>{if(Z===F.id)return{key:Z,kind:"template-recruit",templateId:"site-editor",agent:F,onClick:"import-deco"};if(Z===K.id)return C?{key:C.id,kind:"existing",templateId:"site-diagnostics",agent:C}:{key:Z,kind:"template-recruit",templateId:"site-diagnostics",agent:K,onClick:"diagnostics"};if(Z===H.id)return y?{key:y.id,kind:"existing",templateId:"ai-image",agent:y}:{key:Z,kind:"template-recruit",templateId:"ai-image",agent:H,onClick:"ai-image"};if(Z===X.id)return S?{key:S.id,kind:"existing",templateId:"lean-canvas",agent:S}:{key:Z,kind:"template-recruit",templateId:"lean-canvas",agent:X,onClick:"lean-canvas"};if(Z===W.id)return{key:Z,kind:"template-recruit",templateId:"studio-pack",agent:W,onClick:"studio-pack"};if(Z===G.id)return x.experimental_vibecode?{key:Z,kind:"template-recruit",templateId:"self-healing-storefront",agent:G,onClick:"self-healing"}:null;if(Z===U.id)return V?{key:V.id,kind:"existing",templateId:"ai-research",agent:V}:{key:Z,kind:"template-recruit",templateId:"ai-research",agent:U,onClick:"ai-research"};const de=e.find(me=>me.id!==null&&me.id===Z&&!lr(me.id));return de?{key:de.id,kind:"existing",templateId:null,agent:de}:null};let ee;if(i?.ids)ee=i.ids.map(se).filter(Cv).slice(0,_v);else{const de=[F.id,G.id,K.id,H.id,U.id].map(se).filter(Vv),me=gv(s),le=e.filter(wv).filter(he=>he.id!==C?.id&&he.id!==y?.id&&he.id!==V?.id).sort((he,be)=>{const fe=me.indexOf(he.id),ye=me.indexOf(be.id);return fe!==-1&&ye!==-1?fe-ye:fe!==-1?-1:ye!==-1?1:new Date(be.updated_at).getTime()-new Date(he.updated_at).getTime()}).slice(0,4).map(Sv);ee=[...de,...le]}w=ee.some(yv);let J;t[13]!==v?(J=Z=>{if(Z.kind==="template-recruit"){const de={"import-deco":()=>o(!0),diagnostics:()=>l(!0),"ai-image":()=>d(!0),"ai-research":()=>h(!0),"lean-canvas":()=>m(!0),"studio-pack":()=>g(!0),"self-healing":()=>b(!0)}[Z.onClick];return r.jsx(ec,{agent:Z.agent,onSpecialClick:de,tracking:{template_id:Z.templateId,tile_kind:"template",action:"open_modal"}},Z.key)}return r.jsx(ec,{agent:Z.agent,onSpecialClick:()=>v(Z.agent.id),tracking:{template_id:Z.templateId,tile_kind:Z.templateId?"existing":"recent",action:"navigate"}},Z.key)},t[13]=v,t[14]=J):J=t[14];const ae=J;M="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",k="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",T=ee.map(ae),t[0]=s,t[1]=v,t[2]=i,t[3]=x,t[4]=e,t[5]=y,t[6]=V,t[7]=C,t[8]=S,t[9]=w,t[10]=k,t[11]=T,t[12]=M}else y=t[5],V=t[6],C=t[7],S=t[8],w=t[9],k=t[10],T=t[11],M=t[12];let I;t[15]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(vv,{}),t[15]=I):I=t[15];let E;t[16]!==w?(E=w&&r.jsx(xv,{}),t[16]=w,t[17]=E):E=t[17];let N;t[18]!==k||t[19]!==T||t[20]!==E?(N=r.jsxs("div",{className:k,children:[T,I,E]}),t[18]=k,t[19]=T,t[20]=E,t[21]=N):N=t[21];let A;t[22]!==M||t[23]!==N?(A=r.jsx("div",{className:M,children:N}),t[22]=M,t[23]=N,t[24]=A):A=t[24];let D;t[25]!==n?(D=r.jsx(fn,{open:n,onOpenChange:o}),t[25]=n,t[26]=D):D=t[26];let L;t[27]!==a||t[28]!==C?(L=r.jsx(uh,{open:a,onOpenChange:l,existingAgent:C}),t[27]=a,t[28]=C,t[29]=L):L=t[29];let R;t[30]!==c||t[31]!==y?(R=r.jsx(Xh,{open:c,onOpenChange:d,existingAgent:y}),t[30]=c,t[31]=y,t[32]=R):R=t[32];let P;t[33]!==u||t[34]!==V?(P=r.jsx(Jh,{open:u,onOpenChange:h,existingAgent:V}),t[33]=u,t[34]=V,t[35]=P):P=t[35];let B;t[36]!==S||t[37]!==f?(B=r.jsx(fh,{open:f,onOpenChange:m,existingAgent:S}),t[36]=S,t[37]=f,t[38]=B):B=t[38];let $;t[39]!==p?($=r.jsx(mh,{open:p,onOpenChange:g}),t[39]=p,t[40]=$):$=t[40];let z;t[41]!==_?(z=r.jsx(Qh,{open:_,onOpenChange:b}),t[41]=_,t[42]=z):z=t[42];let q;return t[43]!==P||t[44]!==B||t[45]!==$||t[46]!==z||t[47]!==A||t[48]!==D||t[49]!==L||t[50]!==R?(q=r.jsxs(r.Fragment,{children:[A,D,L,R,P,B,$,z]}),t[43]=P,t[44]=B,t[45]=$,t[46]=z,t[47]=A,t[48]=D,t[49]=L,t[50]=R,t[51]=q):q=t[51],q}function yv(t){return t.kind==="existing"&&t.templateId===null}function Sv(t){return{key:t.id,kind:"existing",templateId:null,agent:t}}function wv(t){return t.id!==null&&!lr(t.id)}function Vv(t){return t!==null}function Cv(t){return t!==null}function kv(t){return t.id==="self-healing-storefront"}function jv(t){return t.id==="studio-pack"}function Nv(t){return t.id==="lean-canvas"}function Av(t){return t.id==="ai-research"}function Ev(t){return t.id==="ai-image"}function Iv(t){return t.id==="site-diagnostics"}function Tv(t){return t.id==="site-editor"}function Rv(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:r.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(Mv)})}),t[0]=e):e=t[0],e}function Mv(t,e){return r.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[r.jsx(wi,{className:"size-12 rounded-xl shrink-0"}),r.jsx(wi,{className:"h-3 sm:h-4 w-full"})]},e)}function tc(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(j.Suspense,{fallback:r.jsx(Rv,{}),children:r.jsx(bv,{})}),t[0]=e):e=t[0],e}function Bi(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function sc(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Dv(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Pv(t){const e=O.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Lv),e[0]=s,e[1]=i):i=e[1];let n;return e[2]!==i?(n=r.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=n):n=e[3],n}function Lv(t){return r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),r.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Ov(t){const e=O.c(30),{userTokens:s,assistantTokens:i,otherTokens:n}=t,o=s+i+n,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?n/o*100:0;let d;e[0]!==a?(d=a>0&&r.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&r.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&r.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let f;e[6]!==d||e[7]!==u||e[8]!==h?(f=r.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=r.jsxs("div",{className:"flex items-center gap-1.5",children:[m,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let b;e[16]!==l?(b=l.toFixed(1),e[16]=l,e[17]=b):b=e[17];let x;e[18]!==b?(x=r.jsxs("div",{className:"flex items-center gap-1.5",children:[_,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",b,"%"]})]}),e[18]=b,e[19]=x):x=e[19];let v;e[20]!==c||e[21]!==n?(v=n>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=n,e[22]=v):v=e[22];let y;e[23]!==x||e[24]!==v||e[25]!==g?(y=r.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,v]}),e[23]=x,e[24]=v,e[25]=g,e[26]=y):y=e[26];let V;return e[27]!==y||e[28]!==f?(V=r.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=V):V=e[29],V}function Bv(t){const e=O.c(19),{part:s}=t,i=s.input?.agent_id,n=$t(i),o=n?.title??"Subtask",a=n?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=r.jsx(ps,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let f;e[3]!==h?(f=Y("shrink-0 font-medium",h),e[3]=h,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==f?(m=r.jsx("span",{className:f,children:o}),e[5]=o,e[6]=f,e[7]=m):m=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=r.jsx("span",{className:"ml-auto shrink-0",children:l?r.jsx(Ne,{size:12,className:"animate-spin text-muted-foreground"}):c?r.jsx(xp,{size:12,className:"text-destructive"}):d?r.jsx(Bs,{size:12,className:"text-warning"}):r.jsx(Wp,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==m||e[16]!==p||e[17]!==g?(_=r.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,m,p,g]}),e[14]=u,e[15]=m,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function $v(t){const e=O.c(58),{onClose:s,back:i,className:n}=t,[o,a]=j.useState(null),{messages:l}=Ii(),{tasks:c,taskId:d}=Lt(),{selectedModel:u,selectedVirtualMcp:h}=$s();let f,m,p,g,_,b,x,v;if(e[0]!==i||e[1]!==n||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){v=Symbol.for("react.early_return_sentinel");e:{let C;e[17]!==d?(C=J=>J.id===d,e[17]=d,e[18]=C):C=e[18];const S=c.find(C),w=Nd(l),k=[...l].reverse().find(Yv),T=k?.metadata?.usage,M=k?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,I=T?.contextTokens??T?.totalTokens??0,E=M&&M>0?(I/M*100).toFixed(1):null,N=l;let A;e[19]!==N?(A=N.filter(Gv).reduce(qv,0),e[19]=N,e[20]=A):A=e[20];const D=A,L=l;let R;e[21]!==L?(R=L.filter(Kv).reduce(Wv,0),e[21]=L,e[22]=R):R=e[22];const P=R,B=Math.max(0,w.totalTokens-D-P),$=l[0],z=l.at(-1),q=$?.metadata?.created_at??S?.created_at,F=z?.metadata?.created_at??S?.updated_at,K=l.filter(Hv),H=l.flatMap(Fv),U=u?.modelId?Dv(u.modelId):"—",X=h?.title??"Decopilot",W=[{label:"Session",value:S?.title??"New chat"},{label:"Messages",value:K.length},{label:"Agent",value:X},{label:"Model",value:U},{label:"Context Limit",value:M?Bi(M):"—"},{label:"Session Tokens (billed)",value:w.totalTokens>0?Bi(w.totalTokens):"0"},{label:"Usage",value:E!==null?`${E}%`:"—"},{label:"Input Tokens",value:w.inputTokens>0?Bi(w.inputTokens):"0"},{label:"Output Tokens",value:w.outputTokens>0?Bi(w.outputTokens):"0"},{label:"Reasoning Tokens",value:w.reasoningTokens>0?Bi(w.reasoningTokens):"0"},{label:"Cost",value:w.cost>0?`$${w.cost<.001?w.cost.toFixed(6):w.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:sc(q)},{label:"Last Activity",value:sc(F)}];if(!S&&K.length===0){let J;e[23]!==n?(J=Y("flex flex-col h-full w-full border-l border-border bg-background",n),e[23]=n,e[24]=J):J=e[24];let ae;e[25]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ae):ae=e[25];let Z;e[26]!==i?(Z=i?r.jsx(Eo,{size:14,className:"text-muted-foreground"}):r.jsx(Os,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=Z):Z=e[27];let de;e[28]!==s||e[29]!==Z?(de=r.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ae,r.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:Z})]}),e[28]=s,e[29]=Z,e[30]=de):de=e[30];let me;e[31]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=me):me=e[31];let le;e[32]!==J||e[33]!==de?(le=r.jsxs("div",{className:J,children:[de,me]}),e[32]=J,e[33]=de,e[34]=le):le=e[34],v=le;break e}e[35]!==n?(b=Y("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",n),e[35]=n,e[36]=b):b=e[36];let G;e[37]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=G):G=e[37];let se;e[38]!==i?(se=i?r.jsx(Eo,{size:14}):r.jsx(Os,{size:14}),e[38]=i,e[39]=se):se=e[39],e[40]!==s||e[41]!==se?(x=r.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[G,r.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:se})]}),e[40]=s,e[41]=se,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",m=H.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),r.jsx("div",{className:"flex flex-col gap-1",children:H.map(zv)})]}),p=r.jsx(Pv,{items:W});let ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ee):ee=e[43],e[44]!==P||e[45]!==B||e[46]!==D?(g=r.jsxs("div",{className:"flex flex-col gap-3",children:[ee,r.jsx(Ov,{userTokens:D,assistantTokens:P,otherTokens:B})]}),e[44]=P,e[45]=B,e[46]=D,e[47]=g):g=e[47],_=K.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),r.jsx("div",{className:"flex flex-col gap-1",children:K.map(J=>{const ae=J.metadata?.created_at,Z=o?.id===J.id;return r.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(Z?null:J),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:Y("shrink-0 font-medium",J.role==="user"?"text-chart-1":"text-chart-2"),children:J.role}),r.jsx("span",{className:"text-muted-foreground",children:"•"}),r.jsx("span",{className:"truncate text-muted-foreground font-mono",children:J.id})]}),ae&&r.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ae).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),Z&&r.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(J,null,2)})]},J.id)})})]})}e[0]=i,e[1]=n,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=b,e[15]=x,e[16]=v}else f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],b=e[14],x=e[15],v=e[16];if(v!==Symbol.for("react.early_return_sentinel"))return v;let y;e[48]!==f||e[49]!==m||e[50]!==p||e[51]!==g||e[52]!==_?(y=r.jsxs("div",{className:f,children:[m,p,g,_]}),e[48]=f,e[49]=m,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let V;return e[54]!==b||e[55]!==x||e[56]!==y?(V=r.jsxs("div",{className:b,children:[x,y]}),e[54]=b,e[55]=x,e[56]=y,e[57]=V):V=e[57],V}function zv(t,e){return r.jsx(Bv,{part:t},e)}function Fv(t){return(t.parts??[]).filter(Uv)}function Uv(t){return t.type==="tool-subtask"}function Hv(t){return t.role!=="system"}function Wv(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Kv(t){return t.role==="assistant"}function qv(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gv(t){return t.role==="user"}function Yv(t){return t.role==="assistant"&&t.metadata?.usage}const ic=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],rc=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Xv(){const t=ic[Math.floor(Math.random()*ic.length)],e=rc[Math.floor(Math.random()*rc.length)];return`deco/${t}-${e}`}function Jv(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Qv(t){const e=O.c(25),{orgId:s,userId:i,connectionId:n,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=n??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const f=Ae(h);let m;e[3]!==a||e[4]!==l?(m={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=m):m=e[5];const p=d&&!!n&&!!a&&!!l;let g;e[6]!==f||e[7]!==m||e[8]!==p?(g={client:f,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:sb},e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:b,isError:x}=ni(g);let v,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),v=[...y].sort().map(tb),e[10]=i,e[11]=o,e[12]=v,e[13]=y):(v=e[12],y=e[13]);const V=v;let C;if(e[14]!==_||e[15]!==y){const T=Array.isArray(_)?_:_?.branches??[];let M;e[17]!==y?(M=I=>!y.has(I.name),e[17]=y,e[18]=M):M=e[18],C=T.filter(eb).filter(M).map(Zv),e[14]=_,e[15]=y,e[16]=C}else C=e[16];const S=C,w=Array.isArray(_)?null:_?.default_branch??null;let k;return e[19]!==w||e[20]!==x||e[21]!==b||e[22]!==S||e[23]!==V?(k={yours:V,others:S,defaultBase:w,isLoading:b,isError:x},e[19]=w,e[20]=x,e[21]=b,e[22]=S,e[23]=V,e[24]=k):k=e[24],k}function Zv(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function eb(t){return typeof t.name=="string"}function tb(t){return{name:t,source:"yours"}}function sb(t){return Jv(t)}function ib(t){const e=O.c(41),{orgId:s,userId:i,connectionId:n,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=j.useState(!1);let f;e[0]!==n||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(f={orgId:s,userId:i,connectionId:n,vmMap:l,owner:o,repo:a,enabled:u},e[0]=n,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=f):f=e[7];const{yours:m,others:p,isLoading:g,isError:_}=Qv(f);let b;e[8]!==d?(b=A=>{d(A),h(!1)},e[8]=d,e[9]=b):b=e[9];const x=b,v=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(er,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let V;e[11]!==v?(V=r.jsx(zs,{asChild:!0,children:r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,r.jsx("span",{className:"max-w-[200px] truncate",children:v})]})}),e[11]=v,e[12]=V):V=e[12];let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Gp,{placeholder:"Search branches…"}),e[13]=C):C=e[13];let S;e[14]!==x?(S=r.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[C,r.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>x(Xv()),children:"New"})]}),e[14]=x,e[15]=S):S=e[15];let w;e[16]!==_?(w=_&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[16]=_,e[17]=w):w=e[17];let k;e[18]!==_||e[19]!==g||e[20]!==p.length||e[21]!==m.length?(k=!_&&!g&&m.length===0&&p.length===0&&r.jsx(Kp,{children:"No branches found."}),e[18]=_,e[19]=g,e[20]=p.length,e[21]=m.length,e[22]=k):k=e[22];let T;e[23]!==x||e[24]!==m?(T=m.length>0&&r.jsx(Al,{heading:"Your branches",children:m.map(A=>r.jsxs(El,{value:A.name,onSelect:()=>x(A.name),children:[r.jsx(er,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:A.name})]},A.name))}),e[23]=x,e[24]=m,e[25]=T):T=e[25];let M;e[26]!==p||e[27]!==x?(M=p.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(qp,{}),r.jsx(Al,{heading:"Other branches in repo",children:p.map(A=>r.jsxs(El,{value:A.name,onSelect:()=>x(A.name),children:[r.jsx(er,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:A.name}),A.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",A.author]})]},A.name))})]}),e[26]=p,e[27]=x,e[28]=M):M=e[28];let I;e[29]!==M||e[30]!==w||e[31]!==k||e[32]!==T?(I=r.jsxs(Yp,{children:[w,k,T,M]}),e[29]=M,e[30]=w,e[31]=k,e[32]=T,e[33]=I):I=e[33];let E;e[34]!==I||e[35]!==S?(E=r.jsx(Fs,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:r.jsxs(Xp,{children:[S,I]})}),e[34]=I,e[35]=S,e[36]=E):E=e[36];let N;return e[37]!==u||e[38]!==E||e[39]!==V?(N=r.jsxs(Us,{open:u,onOpenChange:h,children:[V,E]}),e[37]=u,e[38]=E,e[39]=V,e[40]=N):N=e[40],N}const rb=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),nb="/decotexture.svg";function nc(t){const e=O.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:rb},e[0]=i):i=e[0];let n,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:r.jsx(ps,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=r.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=n,e[2]=o):(n=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("img",{src:nb,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:r.jsx(In,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=r.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[n,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function ob(){const t=O.c(5),{data:e}=dt.useSession();let s;t[0]!==e?.user?.email?(s=Ze.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let n;t[2]!==s||t[3]!==i?(n={queryKey:s,queryFn:ab,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=n):n=t[4];const{data:o}=ji(n);return o?.isDecoUser??!1}async function ab(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function lb(t){const e=O.c(56),{onOpenContextPanel:s}=t,{data:i}=dt.useSession(),[n,o]=j.useState(!1),a=ob(),l=ms(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:f}=Pn();let m;e[0]!==i?.user?.name?(m=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=m):m=e[1];const p=m,g=c&&u&&h!=null,_=c&&d&&f;if(l){let E;e[2]!==h||e[3]!==g?(E=g&&r.jsx("div",{className:"mb-4",children:r.jsx(Ee.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=E):E=e[4];let N;e[5]!==_?(N=_&&r.jsx("div",{className:"mb-4",children:r.jsx(Ee.NoCreditsEyebrow,{})}),e[5]=_,e[6]=N):N=e[6];let A;e[7]!==p?(A=r.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=A):A=e[8];let D;e[9]!==E||e[10]!==N||e[11]!==A?(D=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[E,N,A]}),e[9]=E,e[10]=N,e[11]=A,e[12]=D):D=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(tc,{}),e[13]=L):L=e[13];let R;e[14]!==s?(R=r.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,r.jsx(Ee.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=R):R=e[15];let P;e[16]!==a?(P=a&&r.jsx("div",{className:"w-full",children:r.jsx(nc,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let B;e[18]!==D||e[19]!==R||e[20]!==P?(B=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[D,R,P]}),e[18]=D,e[19]=R,e[20]=P,e[21]=B):B=e[21];let $;e[22]!==n?($=r.jsx(fn,{open:n,onOpenChange:o}),e[22]=n,e[23]=$):$=e[23];let z;return e[24]!==$||e[25]!==B?(z=r.jsxs(r.Fragment,{children:[B,$]}),e[24]=$,e[25]=B,e[26]=z):z=e[26],z}let b;e[27]!==h||e[28]!==g?(b=g&&r.jsx("div",{className:"mb-4",children:r.jsx(Ee.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=b):b=e[29];let x;e[30]!==_?(x=_&&r.jsx("div",{className:"mb-4",children:r.jsx(Ee.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let v;e[32]!==p?(v=r.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=v):v=e[33];let y;e[34]!==b||e[35]!==x||e[36]!==v?(y=r.jsxs("div",{className:"text-center mb-10",children:[b,x,v]}),e[34]=b,e[35]=x,e[36]=v,e[37]=y):y=e[37];let V;e[38]!==s?(V=r.jsx("div",{className:"w-full",children:r.jsx(Ee.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=V):V=e[39];let C;e[40]!==y||e[41]!==V?(C=r.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,V]}),e[40]=y,e[41]=V,e[42]=C):C=e[42];let S;e[43]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"w-full mt-10 mx-auto",children:r.jsx(tc,{})}),e[43]=S):S=e[43];let w;e[44]!==C?(w=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[C,S]}),e[44]=C,e[45]=w):w=e[45];let k;e[46]!==a?(k=a&&r.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:r.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:r.jsx(nc,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=k):k=e[47];let T;e[48]!==k||e[49]!==w?(T=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[w,k]}),e[48]=k,e[49]=w,e[50]=T):T=e[50];let M;e[51]!==n?(M=r.jsx(fn,{open:n,onOpenChange:o}),e[51]=n,e[52]=M):M=e[52];let I;return e[53]!==T||e[54]!==M?(I=r.jsxs(r.Fragment,{children:[T,M]}),e[53]=T,e[54]=M,e[55]=I):I=e[55],I}function cb(){const t=O.c(26),{org:e}=_e(),{selectedVirtualMcp:s}=$s(),{data:i}=dt.useSession(),{currentBranch:n,setCurrentTaskBranch:o}=Lt();let a;t[0]!==e.id?(a=En(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=$t(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,f=!!h?.connectionId&&!!u;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Dn,{size:32}),t[2]=m):m=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=r.jsx(ps,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=r.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let b;t[8]!==_?(b=r.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=b):b=t[9];let x;t[10]!==n||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==f||t[16]!==u?(x=f&&r.jsx("div",{className:"mt-2",children:r.jsx(ib,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:n??void 0,onChange:o})}),t[10]=n,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=f,t[16]=u,t[17]=x):x=t[17];let v;t[18]!==p||t[19]!==g||t[20]!==b||t[21]!==x?(v=r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,b,x]}),t[18]=p,t[19]=g,t[20]=b,t[21]=x,t[22]=v):v=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"w-full max-w-3xl mx-auto",children:r.jsx(Ee.IceBreakers,{})}),t[23]=y):y=t[23];let V;return t[24]!==v?(V=r.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[v,y]}),t[24]=v,t[25]=V):V=t[25],V}function db(t){const e=O.c(27),{variant:s}=t,{org:i}=_e(),n=La(),{isChatEmpty:o}=Ii(),[a,l]=j.useState("chat"),c=Pn();if(n.length===0){let V;return e[0]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Ee,{className:"animate-in fade-in-0 duration-200",children:r.jsx(Ee.Main,{className:"flex flex-col items-center",children:r.jsx(Ee.EmptyState,{children:r.jsx(Ee.NoAiProviderEmptyState,{})})})}),e[0]=V):V=e[0],V}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!T1(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&r.jsx(Ee.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const f=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;e[10]!==f?(m=Y("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),e[10]=f,e[11]=m):m=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?r.jsx(lb,{onOpenContextPanel:()=>l("context")}):r.jsxs(r.Fragment,{children:[r.jsx(Ee.Main,{children:r.jsx(cb,{})}),r.jsx(Ee.Footer,{children:r.jsx(Ee.Input,{onOpenContextPanel:()=>l("context")})})]}):r.jsxs(r.Fragment,{children:[r.jsx(Ee.Main,{children:r.jsx(Ee.Messages,{})}),r.jsx(Ee.Footer,{children:r.jsx(Ee.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==m||e[16]!==p?(g=r.jsx("div",{className:m,children:p}),e[15]=m,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let b;e[18]!==_?(b=Y("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=b):b=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx($v,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let v;e[21]!==b?(v=r.jsx("div",{className:b,children:x}),e[21]=b,e[22]=v):v=e[22];let y;return e[23]!==v||e[24]!==h||e[25]!==g?(y=r.jsxs(Ee,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,v]}),e[23]=v,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function Zh(t){const e=O.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Ee.Skeleton,{}),e[0]=i):i=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Ee.Skeleton,{}),e[1]=n):n=e[1];let o;return e[2]!==s?(o=r.jsx(ls,{fallback:i,children:r.jsx(j.Suspense,{fallback:n,children:r.jsx(db,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function hb(){const t=O.c(6),{org:e,locator:s}=_e(),i=bt();let n;t[0]!==s||t[1]!==i?(n=()=>{i.invalidateQueries({queryKey:Ze.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=n):n=t[2];let o;t[3]!==e.id||t[4]!==n?(o={orgId:e.id,onTaskStatus:n},t[3]=e.id,t[4]=n,t[5]=o):o=t[5],Qp(o)}function ub(t){const e=O.c(8),{virtualMcpId:s,size:i,showAutomationBadge:n}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?r.jsx(fb,{virtualMcpId:s,size:o}):r.jsx(Qt,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==n?(l=n&&r.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:r.jsx(Ci,{size:10,className:"text-white"})}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=r.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function fb(t){const e=O.c(6),{virtualMcpId:s,size:i}=t,n=$t(s);if(!n){let l;return e[0]!==i?(l=r.jsx(Qt,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=n.icon??null;let a;return e[2]!==n.title||e[3]!==i||e[4]!==o?(a=r.jsx(Qt,{icon:o,name:n.title,size:i}),e[2]=n.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function bs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function mb(t){const e=O.c(42),{task:s,isActive:i,onClick:n,onArchive:o,showAutomationBadge:a}=t,l=wm(s.status),c=l.icon,d=$t(s.virtual_mcp_id);let u;e[0]!==d?(u=bs(d),e[0]=d,e[1]=u):u=e[1];const h=u,f="button",m=0;let p;e[2]!==n?(p=B=>{B.target===B.currentTarget&&(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),n())},e[2]=n,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=Y("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let b;e[6]!==a||e[7]!==s.virtual_mcp_id?(b=r.jsx(ub,{virtualMcpId:s.virtual_mcp_id,size:"xs",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=b):b=e[8];const x=s.title||"Untitled task";let v;e[9]!==x?(v=r.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=v):v=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate font-mono",children:s.branch}),r.jsx("span",{className:"shrink-0",children:"·"})]}):h?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),r.jsx("span",{className:"shrink-0",children:"·"})]}):null,r.jsx("span",{className:"shrink-0",children:Vm(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let V;e[15]!==y||e[16]!==v?(V=r.jsxs("div",{className:"flex-1 min-w-0",children:[v,y]}),e[15]=y,e[16]=v,e[17]=V):V=e[17];const C="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",S="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",w=l.label,k=14,T=Y(l.iconClassName,s.status==="in_progress"&&"animate-spin");let M;e[18]!==c||e[19]!==T?(M=r.jsx(c,{size:k,className:T}),e[18]=c,e[19]=T,e[20]=M):M=e[20];let I;e[21]!==l||e[22]!==M?(I=r.jsx("span",{className:S,"aria-label":w,children:M}),e[21]=l,e[22]=M,e[23]=I):I=e[23];let E;e[24]!==o?(E=B=>{B.stopPropagation(),o()},e[24]=o,e[25]=E):E=e[25];let N;e[26]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(Qm,{size:14}),e[26]=N):N=e[26];let A;e[27]!==E?(A=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Archive task",onClick:E,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:N})}),e[27]=E,e[28]=A):A=e[28];let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Ge,{side:"right",children:"Archive"}),e[29]=D):D=e[29];let L;e[30]!==A?(L=r.jsxs(Ye,{children:[A,D]}),e[30]=A,e[31]=L):L=e[31];let R;e[32]!==I||e[33]!==L?(R=r.jsxs("div",{className:C,children:[I,L]}),e[32]=I,e[33]=L,e[34]=R):R=e[34];let P;return e[35]!==n||e[36]!==V||e[37]!==R||e[38]!==p||e[39]!==_||e[40]!==b?(P=r.jsxs("div",{role:f,tabIndex:m,onClick:n,onKeyDown:p,className:_,children:[b,V,R]}),e[35]=n,e[36]=V,e[37]=R,e[38]=p,e[39]=_,e[40]=b,e[41]=P):P=e[41],P}const eu={all:"All tasks",manual:"Chats",automation:"Automation"},tu={all:"All members",mine:"Mine only"};function pb(t){const e=O.c(57),{title:s,tasks:i,activeTaskId:n,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[f,m]=j.useState("all"),[p,g]=j.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(K=>K.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const b=_;let x;e[4]!==f||e[5]!==b?(x=f==="automation"?b.filter(vb):f==="manual"?b.filter(xb):b,e[4]=f,e[5]=b,e[6]=x):x=e[6];const v=x;let y;e[7]!==s?(y=r.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let V;e[9]!==p?(V=r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?r.jsx(Zm,{size:16}):r.jsx(Dn,{size:16})})}),e[9]=p,e[10]=V):V=e[10];let C;e[11]!==p?(C=K=>{const H=K;H!==p&&re("tasks_panel_member_filter_changed",{to_value:H}),g(H)},e[11]=p,e[12]=C):C=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=Object.keys(tu),e[13]=S):S=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=S.map(_b),e[14]=w):w=e[14];let k;e[15]!==p||e[16]!==C?(k=r.jsx(hs,{align:"end",children:r.jsx(xl,{value:p,onValueChange:C,children:w})}),e[15]=p,e[16]=C,e[17]=k):k=e[17];let T;e[18]!==V||e[19]!==k?(T=r.jsxs(cs,{children:[V,k]}),e[18]=V,e[19]=k,e[20]=T):T=e[20];const M=f!=="all"&&"text-purple-500";let I;e[21]!==M?(I=Y("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",M),e[21]=M,e[22]=I):I=e[22];let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(vp,{size:16}),e[23]=E):E=e[23];let N;e[24]!==I?(N=r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter tasks",className:I,children:E})}),e[24]=I,e[25]=N):N=e[25];let A;e[26]!==f?(A=K=>{const H=K;H!==f&&re("tasks_panel_filter_changed",{to_value:H}),m(H)},e[26]=f,e[27]=A):A=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=Object.keys(eu),e[28]=D):D=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=D.map(gb),e[29]=L):L=e[29];let R;e[30]!==f||e[31]!==A?(R=r.jsx(hs,{align:"end",children:r.jsx(xl,{value:f,onValueChange:A,children:L})}),e[30]=f,e[31]=A,e[32]=R):R=e[32];let P;e[33]!==N||e[34]!==R?(P=r.jsxs(cs,{children:[N,R]}),e[33]=N,e[34]=R,e[35]=P):P=e[35];let B;e[36]!==l||e[37]!==c||e[38]!==s?(B=c&&l&&r.jsx("button",{type:"button",onClick:()=>{re("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:r.jsx(Ra,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=B):B=e[39];let $;e[40]!==P||e[41]!==B||e[42]!==T?($=r.jsxs("div",{className:"flex items-center gap-0.5",children:[T,P,B]}),e[40]=P,e[41]=B,e[42]=T,e[43]=$):$=e[43];let z;e[44]!==$||e[45]!==y?(z=r.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,$]}),e[44]=$,e[45]=y,e[46]=z):z=e[46];let q;e[47]!==n||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==v?(q=v.length===0&&u?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):v.map(K=>r.jsx(mb,{task:K,isActive:n===K.id,onClick:()=>{n!==K.id&&re("tasks_panel_task_clicked",{thread_id:K.id,virtual_mcp_id:K.virtual_mcp_id??null,from_automation:!!K.fromAutomation}),o(K)},onArchive:()=>{re("tasks_panel_task_archived",{thread_id:K.id,virtual_mcp_id:K.virtual_mcp_id??null}),a(K)},showAutomationBadge:d||K.fromAutomation},K.id)),e[47]=n,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=v,e[53]=q):q=e[53];let F;return e[54]!==z||e[55]!==q?(F=r.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[z,q]}),e[54]=z,e[55]=q,e[56]=F):F=e[56],F}function gb(t){return r.jsx(Ld,{value:t,children:eu[t]},t)}function _b(t){return r.jsx(Ld,{value:t,children:tu[t]},t)}function xb(t){return!t.fromAutomation}function vb(t){return t.fromAutomation}function bb(){const t=O.c(22);hb();const{data:e}=dt.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:n}=Co(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=Co(o),{setTaskId:l,createNewTask:c}=xr();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=_r(d),{locator:h,org:f}=_e(),m=bt();let p;t[3]!==f.id?(p={connectionId:yt,orgId:f.id},t[3]=f.id,t[4]=p):p=t[4];const g=Ae(p),_=u.taskId??null;let b;t[5]!==a||t[6]!==n?(b=[...n,...a.map(Sb)].sort(yb),t[5]=a,t[6]=n,t[7]=b):b=t[7];const x=b;let v;t[8]!==g||t[9]!==h||t[10]!==m?(v=async S=>{try{await mm(g,S.id,{hidden:!0}),m.invalidateQueries({queryKey:Ze.tasksPrefix(h)})}catch(w){const T=w;ue.error(`Failed to archive task: ${T.message}`)}},t[8]=g,t[9]=h,t[10]=m,t[11]=v):v=t[11];const y=v;if(x.length===0){let S;return t[12]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"h-full flex items-center justify-center p-4",children:r.jsx(Vi,{image:r.jsx(ep,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=S):S=t[12],S}let V;t[13]!==l?(V=S=>l(S.id,S.virtual_mcp_id),t[13]=l,t[14]=V):V=t[14];let C;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==V?(C=r.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:r.jsx(pb,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:V,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=V,t[21]=C):C=t[21],C}function yb(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function Sb(t){return{...t,fromAutomation:!0}}function wb(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(Vb)}),t[0]=e):e=t[0],e}function Vb(t,e){return r.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function su(){const t=O.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Ee.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ls,{fallback:e,children:r.jsx(j.Suspense,{fallback:r.jsx(wb,{}),children:r.jsx(bb,{})})}),t[1]=s):s=t[1],s}function iu(){const t=O.c(77),{org:e}=_e(),s=Oe(),i=yd(),{setTasksOpen:n,openTab:o}=xr(),a=e.slug,l=_e().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=_r(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=ti(u),f=i.location.pathname;let m;t[2]!==l.enabledPlugins?(m=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=m):m=t[3];const p=m;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let b,x,v,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let H;t[17]!==p?(H=ae=>p.includes(ae.pluginId),t[17]=p,t[18]=H):H=t[18];const U=Of.filter(H),X=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const W=d.taskId??"",G=d.pluginId;let se;t[19]!==G?(se=ae=>G===ae,t[19]=G,t[20]=se):se=t[20],b=se;let ee;t[21]!==W||t[22]!==s||t[23]!==a||t[24]!==X?(ee=ae=>{const Z=W||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:Z,pluginId:ae},search:de=>({...de,virtualmcpid:X})})},t[21]=W,t[22]=s,t[23]=a,t[24]=X,t[25]=ee):ee=t[25],v=ee;let J;t[26]!==b||t[27]!==v?(J=ae=>({key:ae.pluginId,label:ae.label,icon:ae.icon,isActive:b(ae.pluginId),onClick:()=>v(ae.pluginId)}),t[26]=b,t[27]=v,t[28]=J):J=t[28],y=U.map(J),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=b,t[14]=x,t[15]=v,t[16]=y}else b=t[13],x=t[14],v=t[15],y=t[16];const V=y;let C;if(t[29]!==p||t[30]!==b||t[31]!==v){let H;t[33]!==p?(H=W=>p.includes(W.pluginId),t[33]=p,t[34]=H):H=t[34];const U=Bf.filter(H);let X;t[35]!==b||t[36]!==v?(X=W=>({type:"group",group:{id:`${W.pluginId}-${W.id}`,label:W.label,items:W.items.map((G,se)=>({key:`${W.pluginId}-${W.id}-${se}`,label:G.label,icon:G.icon,isActive:b(W.pluginId),onClick:()=>v(W.pluginId)})),defaultExpanded:W.defaultExpanded??!0}}),t[35]=b,t[36]=v,t[37]=X):X=t[37],C=U.map(X),t[29]=p,t[30]=b,t[31]=v,t[32]=C}else C=t[32];const S=C;let w;if(t[38]!==o||t[39]!==_){let H;t[41]!==o?(H=U=>{const X=vr(U.icon),W=X.type==="icon"?br(X.name):null;return{key:`app-${U.connectionId}-${U.toolName}`,label:U.label||U.toolName,icon:W?r.jsx(W,{size:16,className:"text-muted-foreground"}):X.type==="url"?r.jsx("img",{src:X.url,alt:"",className:"size-4 rounded"}):r.jsx(xh,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(jo(U.connectionId,U.toolName))}},t[41]=o,t[42]=H):H=t[42],w=_.map(H),t[38]=o,t[39]=_,t[40]=w}else w=t[40];const k=w;let T;t[43]!==k?(T=k.length>0?{type:"group",group:{id:"apps",label:"Apps",items:k,defaultExpanded:!0}}:null,t[43]=k,t[44]=T):T=t[44];const M=T;let I;t[45]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(tp,{className:"size-4!"}),t[45]=I):I=t[45];const E=f===`/${a}`||f===`/${a}/`;let N;t[46]!==s||t[47]!==a||t[48]!==n?(N=()=>{n(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=n,t[49]=N):N=t[49];let A;t[50]!==N||t[51]!==E?(A={key:"home",label:"Home",icon:I,isActive:E,onClick:N},t[50]=N,t[51]=E,t[52]=A):A=t[52];const D=A;let L;t[53]!==p?(L=p.includes($f),t[53]=p,t[54]=L):L=t[54];const R=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(zf,{className:"size-4!"}),t[55]=P):P=t[55];let B;t[56]!==a||t[57]!==f?(B=f.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=f,t[58]=B):B=t[58];let $;t[59]!==s||t[60]!==a?($=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=$):$=t[61];let z;t[62]!==B||t[63]!==$?(z={key:"workflows",label:"Workflows",icon:P,isActive:B,onClick:$},t[62]=B,t[63]=$,t[64]=z):z=t[64];const q=z;let F;if(t[65]!==D||t[66]!==x||t[67]!==R||t[68]!==q){const H=[D];x&&R&&H.push(q),F={type:"items",items:H},t[65]=D,t[66]=x,t[67]=R,t[68]=q,t[69]=F}else F=t[69];let K;if(t[70]!==M||t[71]!==S||t[72]!==V||t[73]!==F){if(K=[F],V.length>0){let H;t[75]!==V?(H={type:"items",items:V},t[75]=V,t[76]=H):H=t[76],K.push(H)}S.length>0&&K.push(...S),M&&K.push(M),t[70]=M,t[71]=S,t[72]=V,t[73]=F,t[74]=K}else K=t[74];return K}function ru(t){const e=O.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex h-6 items-center",children:r.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsxs(wr,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,r.jsx(Vr,{children:r.jsx(es,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=n):n=e[2],n}function Cb(){const t=O.c(7),s=Sd().logo??wd,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(yh,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function nu(t){const e=O.c(15),{item:s}=t,{isMobile:i,setOpenMobile:n}=Cr();let o;e[0]!==i||e[1]!==s||e[2]!==n?(o=()=>{re("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&n(!1)},e[0]=i,e[1]=s,e[2]=n,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=Y(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=r.jsx(Zt,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=r.jsx(Pt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function kb(t){const e=O.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(vh,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,n=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(Nb),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=r.jsx(ru,{label:i,defaultExpanded:n,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map(jb),e[8]=s.items,e[9]=i):i=e[9];let n;return e[10]!==i?(n=r.jsx(wr,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Vr,{children:r.jsx(es,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=n):n=e[11],n}}}function jb(t){return r.jsx(nu,{item:t},t.key)}function Nb(t){return r.jsx(nu,{item:t},t.key)}function Ab(t){const e=O.c(14),{sections:s,header:i,footer:n,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(Cb,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=Y("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(Eb),e[3]=s,e[4]=h):h=e[4];let f;e[5]!==o||e[6]!==u||e[7]!==h?(f=r.jsxs(bh,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=f):f=e[8];let m;return e[9]!==n||e[10]!==i||e[11]!==f||e[12]!==c?(m=r.jsxs(Zp,{variant:c,children:[d,i,f,n]}),e[9]=n,e[10]=i,e[11]=f,e[12]=c,e[13]=m):m=e[13],m}function Eb(t,e){return r.jsx(kb,{section:t},e)}function ou(t){const e=O.c(2);let s;return e[0]!==t?(s=r.jsx(Ab,{...t}),e[0]=t,e[1]=s):s=e[1],s}ou.Skeleton=function(){return r.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>r.jsx("div",{className:"w-full h-8",children:r.jsx(wi,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function Ib(){const t=O.c(7),s=Sd().logo??wd,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(yh,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function oc(t){const e=O.c(15),{item:s,onClose:i}=t,n=s.isActive&&"z-10";let o;e[0]!==n?(o=Y(n),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=r.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=r.jsx(Zt,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=r.jsx(Pt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function Tb(t){const e=O.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(vh,{className:"my-2"}),e[0]=n):n=e[0],n}case"spacer":{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"flex-1"}),e[1]=n):n=e[1],n}case"group":{const n=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>r.jsx(oc,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=r.jsx(ru,{label:n,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let n;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>r.jsx(oc,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],n=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=n}else n=e[13];let o;return e[16]!==n?(o=r.jsx(wr,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Vr,{children:r.jsx(es,{className:"gap-1.5",children:n})})}),e[16]=n,e[17]=o):o=e[17],o}}}function Rb(t){const e=O.c(12),{sections:s,onClose:i,footer:n,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(Ib,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,f)=>r.jsx(Tb,{section:h,onClose:i},f),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=r.jsxs(bh,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==n||e[10]!==c?(d=r.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,n]}),e[9]=n,e[10]=c,e[11]=d):d=e[11],d}function au(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Mb=as({name:pt().min(2,"Organization name is required")});function Db(t){const e=O.c(41),{open:s,onOpenChange:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={resolver:gr(Mb),defaultValues:{name:""}},e[0]=n):n=e[0];const o=Ai(n);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:Lb,onSuccess:Pb},e[1]=a):a=e[1];const l=Ni(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsxs(Ua,{children:[r.jsx(Ha,{children:"Create a new organization"}),r.jsx(Wa,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let S;e[6]!==l?(S=w=>l.mutateAsync(w),e[6]=l,e[7]=S):S=e[7],u=o.handleSubmit(S),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=S=>{const{field:w}=S;return r.jsxs(_t,{children:[r.jsx(Ht,{children:"Organization Name"}),r.jsx(xt,{children:r.jsx(at,{...w,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),r.jsx(qm,{children:"The name of your company or organization"}),w.value&&r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",r.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",au(w.value)]})]}),r.jsx(vt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let f;e[10]!==o.control||e[11]!==h?(f=r.jsx(gt,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=f):f=e[12];let m;e[13]!==c?(m=c&&r.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=r.jsx(za,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let b;e[21]!==o.formState.isSubmitting?(b=o.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(ar,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=b):b=e[22];let x;e[23]!==_||e[24]!==b?(x=r.jsx(oe,{type:"submit",variant:"default",disabled:_,children:b}),e[23]=_,e[24]=b,e[25]=x):x=e[25];let v;e[26]!==x||e[27]!==g?(v=r.jsxs(Ka,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=v):v=e[28];let y;e[29]!==v||e[30]!==u||e[31]!==f||e[32]!==m?(y=r.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[f,m,v]}),e[29]=v,e[30]=u,e[31]=f,e[32]=m,e[33]=y):y=e[33];let V;e[34]!==o||e[35]!==y?(V=r.jsxs(Fa,{children:[d,r.jsx(yi,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=V):V=e[36];let C;return e[37]!==i||e[38]!==s||e[39]!==V?(C=r.jsx(qa,{open:s,onOpenChange:i,children:V}),e[37]=i,e[38]=s,e[39]=V,e[40]=C):C=e[40],C}function Pb(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function Lb(t){const e=au(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await dt.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function Bo(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function Ob(t){const e=O.c(13),{org:s,size:i}=t,n=i===void 0?"sm":i,o=n==="xs"?"size-5":"size-6",a=n==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=Y(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:Bo(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?r.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:Y("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=r.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function $r(t){const e=O.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=r.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let f;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(f=r.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=f):f=e[10],f}let n;e[11]!==s||e[12]!==i?(n=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=n):n=e[13];let o;e[14]!==s.icon?(o=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=r.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==n||e[19]!==o||e[20]!==a?(l=r.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=n,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function ac(t){const e=O.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:n,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Dt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,r.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==n||e[5]!==i||e[6]!==s){let f;e[8]!==n||e[9]!==i?(f=m=>r.jsxs("button",{type:"button",onClick:()=>n(m.slug),className:Y("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",m.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[r.jsx(Ob,{org:m,size:"sm"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:m.name}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:m.slug})]}),m.slug===i&&r.jsx(Mt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},m.id),e[8]=n,e[9]=i,e[10]=f):f=e[10],d=s.map(f),e[4]=n,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=r.jsxs(r.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function lc(t){const e=O.c(142),{user:s,userImage:i,menuItems:n,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f,close:m,isMobile:p}=t;if(p){const W=s?.name??"U";let G;e[0]!==W||e[1]!==i?(G=r.jsx(Il,{url:i,fallback:W,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=W,e[1]=i,e[2]=G):G=e[2];const se=s?.name??"User";let ee;e[3]!==se?(ee=r.jsx("p",{className:"text-sm font-medium truncate",children:se}),e[3]=se,e[4]=ee):ee=e[4];const J=s?.email;let ae;e[5]!==J?(ae=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:J}),e[5]=J,e[6]=ae):ae=e[6];let Z;e[7]!==ee||e[8]!==ae?(Z=r.jsxs("div",{className:"flex-1 min-w-0",children:[ee,ae]}),e[7]=ee,e[8]=ae,e[9]=Z):Z=e[9];let de;e[10]!==s?(de=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(Fb)},e[10]=s,e[11]=de):de=e[11];let me;e[12]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx(Si,{size:14}),e[12]=me):me=e[12];let le;e[13]!==de?(le=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:de,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:me})}),e[13]=de,e[14]=le):le=e[14];let he;e[15]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsx(Ge,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=he):he=e[15];let be;e[16]!==le?(be=r.jsx(bi,{delayDuration:300,children:r.jsxs(Ye,{children:[le,he]})}),e[16]=le,e[17]=be):be=e[17];let fe;e[18]!==be||e[19]!==G||e[20]!==Z?(fe=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[G,Z,be]}),e[18]=be,e[19]=G,e[20]=Z,e[21]=fe):fe=e[21];let ye;e[22]!==f||e[23]!==h||e[24]!==u||e[25]!==d?(ye=r.jsx("div",{className:"border-b border-border pb-2",children:r.jsx(ac,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[22]=f,e[23]=h,e[24]=u,e[25]=d,e[26]=ye):ye=e[26];let ve;if(e[27]!==m||e[28]!==n){let De;e[30]!==m?(De=Yt=>r.jsx($r,{item:Yt,onClose:m},Yt.key),e[30]=m,e[31]=De):De=e[31],ve=n.map(De),e[27]=m,e[28]=n,e[29]=ve}else ve=e[29];let Ve;e[32]!==m||e[33]!==o?(Ve=r.jsx($r,{item:o,onClose:m}),e[32]=m,e[33]=o,e[34]=Ve):Ve=e[34];let Ie;e[35]!==ve||e[36]!==Ve?(Ie=r.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,Ve]}),e[35]=ve,e[36]=Ve,e[37]=Ie):Ie=e[37];let te;e[38]!==ye||e[39]!==Ie?(te=r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[ye,Ie]}),e[38]=ye,e[39]=Ie,e[40]=te):te=e[40];let ie;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let De;e[45]!==l.theme||e[46]!==c?(De=Yt=>{const{value:At,icon:Et,label:Ct}=Yt;return r.jsx("button",{type:"button","aria-label":Ct,onClick:()=>c(ws=>({...ws,theme:At})),className:Y("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===At?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Et},At)},e[45]=l.theme,e[46]=c,e[47]=De):De=e[47],ie=a.map(De),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=ie}else ie=e[44];let Ce;e[48]!==ie?(Ce=r.jsx("div",{className:"flex items-center gap-0.5",children:ie}),e[48]=ie,e[49]=Ce):Ce=e[49];const ze=l.enableSounds?"Disable sounds":"Enable sounds";let Fe;e[50]!==c?(Fe=()=>c(zb),e[50]=c,e[51]=Fe):Fe=e[51];const ft=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let He;e[52]!==ft?(He=Y("size-8 rounded-md flex items-center justify-center transition-colors",ft),e[52]=ft,e[53]=He):He=e[53];let tt;e[54]!==l.enableSounds?(tt=l.enableSounds?r.jsx(vl,{size:14}):r.jsx(bl,{size:14}),e[54]=l.enableSounds,e[55]=tt):tt=e[55];let ht;e[56]!==ze||e[57]!==Fe||e[58]!==He||e[59]!==tt?(ht=r.jsx("button",{type:"button","aria-label":ze,onClick:Fe,className:He,children:tt}),e[56]=ze,e[57]=Fe,e[58]=He,e[59]=tt,e[60]=ht):ht=e[60];let pe;e[61]===Symbol.for("react.memo_cache_sentinel")?(pe=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.286.1"]}),e[61]=pe):pe=e[61];let ke;e[62]!==ht?(ke=r.jsxs("div",{className:"flex items-center gap-2",children:[ht,pe]}),e[62]=ht,e[63]=ke):ke=e[63];let st;e[64]!==Ce||e[65]!==ke?(st=r.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[Ce,ke]}),e[64]=Ce,e[65]=ke,e[66]=st):st=e[66];let zt;return e[67]!==fe||e[68]!==te||e[69]!==st?(zt=r.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[fe,te,st]}),e[67]=fe,e[68]=te,e[69]=st,e[70]=zt):zt=e[70],zt}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=r.jsx(Il,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const b=s?.name??"User";let x;e[74]!==b?(x=r.jsx("p",{className:"text-sm font-medium truncate",children:b}),e[74]=b,e[75]=x):x=e[75];const v=s?.email;let y;e[76]!==v?(y=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:v}),e[76]=v,e[77]=y):y=e[77];let V;e[78]!==x||e[79]!==y?(V=r.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=V):V=e[80];let C;e[81]!==s?(C=()=>{s?.id&&navigator.clipboard.writeText(s.id).then($b)},e[81]=s,e[82]=C):C=e[82];let S;e[83]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Si,{size:14}),e[83]=S):S=e[83];let w;e[84]!==C?(w=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:C,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:S})}),e[84]=C,e[85]=w):w=e[85];let k;e[86]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Ge,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=k):k=e[86];let T;e[87]!==w?(T=r.jsx(bi,{delayDuration:300,children:r.jsxs(Ye,{children:[w,k]})}),e[87]=w,e[88]=T):T=e[88];let M;e[89]!==T||e[90]!==_||e[91]!==V?(M=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,V,T]}),e[89]=T,e[90]=_,e[91]=V,e[92]=M):M=e[92];let I;if(e[93]!==m||e[94]!==n){let W;e[96]!==m?(W=G=>r.jsx($r,{item:G,onClose:m},G.key),e[96]=m,e[97]=W):W=e[97],I=n.map(W),e[93]=m,e[94]=n,e[95]=I}else I=e[95];let E;e[98]!==m||e[99]!==o?(E=r.jsx($r,{item:o,onClose:m}),e[98]=m,e[99]=o,e[100]=E):E=e[100];let N;e[101]!==I||e[102]!==E?(N=r.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[I,E]}),e[101]=I,e[102]=E,e[103]=N):N=e[103];let A;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let W;e[108]!==l.theme||e[109]!==c?(W=G=>{const{value:se,icon:ee,label:J}=G;return r.jsx("button",{type:"button","aria-label":J,onClick:()=>c(ae=>({...ae,theme:se})),className:Y("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===se?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:ee},se)},e[108]=l.theme,e[109]=c,e[110]=W):W=e[110],A=a.map(W),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=A}else A=e[107];let D;e[111]!==A?(D=r.jsx("div",{className:"flex items-center gap-0.5",children:A}),e[111]=A,e[112]=D):D=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let R;e[113]!==c?(R=()=>c(Bb),e[113]=c,e[114]=R):R=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let B;e[115]!==P?(B=Y("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=B):B=e[116];let $;e[117]!==l.enableSounds?($=l.enableSounds?r.jsx(vl,{size:14}):r.jsx(bl,{size:14}),e[117]=l.enableSounds,e[118]=$):$=e[118];let z;e[119]!==L||e[120]!==R||e[121]!==B||e[122]!==$?(z=r.jsx("button",{type:"button","aria-label":L,onClick:R,className:B,children:$}),e[119]=L,e[120]=R,e[121]=B,e[122]=$,e[123]=z):z=e[123];let q;e[124]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.286.1"]}),e[124]=q):q=e[124];let F;e[125]!==z?(F=r.jsxs("div",{className:"flex items-center gap-2",children:[z,q]}),e[125]=z,e[126]=F):F=e[126];let K;e[127]!==D||e[128]!==F?(K=r.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[D,F]}),e[127]=D,e[128]=F,e[129]=K):K=e[129];let H;e[130]!==M||e[131]!==N||e[132]!==K?(H=r.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[M,N,K]}),e[130]=M,e[131]=N,e[132]=K,e[133]=H):H=e[133];let U;e[134]!==f||e[135]!==h||e[136]!==u||e[137]!==d?(U=r.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:r.jsx(ac,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[134]=f,e[135]=h,e[136]=u,e[137]=d,e[138]=U):U=e[138];let X;return e[139]!==H||e[140]!==U?(X=r.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[H,U]}),e[139]=H,e[140]=U,e[141]=X):X=e[141],X}function Bb(t){return{...t,enableSounds:!t.enableSounds}}function $b(){ue.success("User ID copied")}function zb(t){return{...t,enableSounds:!t.enableSounds}}function Fb(){ue.success("User ID copied")}function lu(){const t=O.c(50),{data:e}=dt.useSession(),{data:s}=dt.useListOrganizations(),i=Oe();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org",shouldThrow:!1},t[0]=n):n=t[0];const a=Ff(n)?.params.org,[l,c]=ei(),d=ms(),[u,h]=j.useState(!1),[f,m]=j.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const v=s?.find(X=>X.slug===a);let y;if(t[11]!==a||t[12]!==s){let X;t[14]!==a?(X=(W,G)=>W.slug===a?-1:G.slug===a?1:W.name.localeCompare(G.name),t[14]=a,t[15]=X):X=t[15],y=[...s??[]].sort(X),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const V=y;let C;t[16]!==i?(C=X=>{h(!1),i({to:"/$org",params:{org:X}})},t[16]=i,t[17]=C):C=t[17];const S=C;let w;t[18]===Symbol.for("react.memo_cache_sentinel")?(w=()=>h(!1),t[18]=w):w=t[18];const k=w;let T;t[19]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(kr,{size:16}),t[19]=T):T=t[19];let M;t[20]!==i||t[21]!==a?(M={key:"preferences",label:"Preferences",icon:T,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=M):M=t[22];let I;t[23]===Symbol.for("react.memo_cache_sentinel")?(I={key:"terms",label:"Terms of Use",icon:r.jsx(sp,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=I):I=t[23];let E;t[24]===Symbol.for("react.memo_cache_sentinel")?(E={key:"privacy",label:"Privacy Policy",icon:r.jsx(cg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=E):E=t[24];let N;t[25]===Symbol.for("react.memo_cache_sentinel")?(N={key:"github",label:"decocms/studio",icon:r.jsx(Uf,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=N):N=t[25];let A;t[26]===Symbol.for("react.memo_cache_sentinel")?(A={key:"community",label:"Community",icon:r.jsx(Dn,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=A):A=t[26];let D;t[27]===Symbol.for("react.memo_cache_sentinel")?(D={key:"homepage",label:"Homepage",icon:r.jsx(Qd,{size:16}),href:"https://decocms.com",external:!0},t[27]=D):D=t[27];let L;t[28]!==M?(L=[M,I,E,N,A,D],t[28]=M,t[29]=L):L=t[29];const R=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:r.jsx(up,{size:16}),onClick:Hb},t[30]=P):P=t[30];const B=P;let $;t[31]===Symbol.for("react.memo_cache_sentinel")?($={value:"light",icon:r.jsx(og,{size:14}),label:"Light theme"},t[31]=$):$=t[31];let z;t[32]===Symbol.for("react.memo_cache_sentinel")?(z={value:"dark",icon:r.jsx(ag,{size:14}),label:"Dark theme"},t[32]=z):z=t[32];let q;t[33]===Symbol.for("react.memo_cache_sentinel")?(q=[$,z,{value:"system",icon:r.jsx(lg,{size:14}),label:"System theme"}],t[33]=q):q=t[33];const F=q;let K;t[34]===Symbol.for("react.memo_cache_sentinel")?(K=()=>{h(!1),m(!0)},t[34]=K):K=t[34];let H;t[35]!==S||t[36]!==d||t[37]!==R||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==V||t[42]!==p||t[43]!==g?(H={user:p,userImage:g,menuItems:R,signOutItem:B,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:V,orgParam:a,onSelectOrg:S,onCreateOrg:K,close:k,isMobile:d},t[35]=S,t[36]=d,t[37]=R,t[38]=a,t[39]=l,t[40]=c,t[41]=V,t[42]=p,t[43]=g,t[44]=H):H=t[44];const U=H;_=d?r.jsxs(ri,{open:u,onOpenChange:h,direction:"bottom",children:[r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[r.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:v?.logo?void 0:Bo(v?.name??""),children:v?.logo?r.jsx("img",{src:v.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(v?.name??"?").slice(0,2).toUpperCase()})}),r.jsx("span",{className:"truncate",children:v?.name??"Account"})]}),r.jsxs(ii,{className:"h-[80dvh] p-0",children:[r.jsx(si,{className:"sr-only",children:"Account"}),r.jsx(lc,{...U})]})]}):r.jsxs(Us,{open:u,onOpenChange:h,children:[r.jsx(zs,{asChild:!0,children:r.jsx(Zt,{tooltip:v?.name??"Account",className:"rounded-md",children:r.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:v?.logo?void 0:Bo(v?.name??""),children:v?.logo?r.jsx("img",{src:v.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(v?.name??"?").slice(0,2).toUpperCase()})})})}),r.jsx(Fs,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:Ub,children:r.jsx(lc,{...U})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let b;t[45]!==f?(b=r.jsx(Db,{open:f,onOpenChange:m}),t[45]=f,t[46]=b):b=t[46];let x;return t[47]!==_||t[48]!==b?(x=r.jsxs(r.Fragment,{children:[_,b]}),t[47]=_,t[48]=b,t[49]=x):x=t[49],x}function Ub(t){return t.preventDefault()}function Hb(){re("signed_out",{source:"account_popover"}),dt.signOut()}function Wb({invitation:t}){const[e,s]=j.useState(!1),[i,n]=j.useState(!1),o=bt(),a=async()=>{s(!0);try{const c=await dt.organization.acceptInvitation({invitationId:t.id});if(c.error)ue.error(c.error.message),s(!1);else{const d=await dt.organization.setActive({organizationId:t.organizationId});ue.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{ue.error("Failed to accept invitation"),s(!1)}},l=async()=>{n(!0);try{const c=await dt.organization.rejectInvitation({invitationId:t.id});c.error?(ue.error(c.error.message),n(!1)):(ue.success("Invitation declined"),o.invalidateQueries())}catch{ue.error("Failed to decline invitation"),n(!1)}};return r.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),r.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:r.jsx(Mt,{size:14})}),r.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:r.jsx(Os,{size:14})})]})]})}function Kb(){const t=j.useContext(Hf),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class qb extends j.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function Gb(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function Yb(){const t=O.c(19),e=Oe(),{org:s}=_e();let i;t[0]!==s.id?(i={connectionId:yt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const n=Ae(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==n?(a={client:n,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:Xb},t[3]=n,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=ni(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const f=h;let m;t[9]!==u?(m=Y(u!=null&&Gb(u)),t[9]=u,t[10]=m):m=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(Ta,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==m||t[16]!==p||t[17]!==f?(_=r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(Zt,{tooltip:f,className:m,onClick:p,children:g})})}),t[15]=m,t[16]=p,t[17]=f,t[18]=_):_=t[18],_}function Xb(t){return t.structuredContent}function Jb(){const t=O.c(1);if(!La().some(Qb))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Yb,{}),t[0]=i):i=t[0],i}function Qb(t){return t.providerId==="deco"}function Zb(){const t=O.c(3),[e,s]=j.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(Zt,{tooltip:"Connections",onClick:()=>{re("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:r.jsx(fp,{size:24})})})}),t[0]=i):i=t[0];let n;return t[1]!==e?(n=r.jsxs(r.Fragment,{children:[i,r.jsx(Qa,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=n):n=t[2],n}function e0(){const t=O.c(11),e=Kb();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(yl,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&r.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let n;t[3]!==i?(n=r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(zs,{asChild:!0,children:r.jsxs(Zt,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=n):n=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:r.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=r.jsxs(Fs,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[r.jsx(yl,{size:24,className:"text-muted-foreground/50"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):r.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(t0)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==n||t[9]!==a?(l=r.jsxs(Us,{children:[n,a]}),t[8]=n,t[9]=a,t[10]=l):l=t[10],l}function t0(t){return r.jsx(Wb,{invitation:t},t.id)}function s0(){const t=O.c(6),e=Oe(),{org:s}=_e();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let n;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(kr,{size:24}),t[3]=n):n=t[3];let o;return t[4]!==i?(o=r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(Zt,{tooltip:"Settings",onClick:i,children:n})})}),t[4]=i,t[5]=o):o=t[5],o}function i0(){const t=O.c(5);let e,s,i,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(qb,{children:r.jsx(j.Suspense,{fallback:null,children:r.jsx(Jb,{})})}),s=r.jsx(Zb,{}),i=r.jsx(e0,{}),n=r.jsx(s0,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=n):(e=t[0],s=t[1],i=t[2],n=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs(Sh,{className:"px-2 pb-3 gap-1",children:[e,s,i,n,r.jsx(es,{children:r.jsx(Pt,{children:r.jsx(lu,{})})})]}),t[4]=o):o=t[4],o}function r0(){const t=O.c(10),e=Oe(),{org:s}=_e(),{setOpenMobile:i}=Cr();let n;t[0]!==e||t[1]!==s.slug||t[2]!==i?(n=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=n):n=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(kr,{}),t[4]=o):o=t[4];let a;t[5]!==n?(a=r.jsx(Pt,{children:r.jsx(Zt,{tooltip:"Settings",onClick:n,children:o})}),t[5]=n,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Pt,{children:r.jsx(lu,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=r.jsx(Sh,{children:r.jsxs(es,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}var Za="ContextMenu",[n0]=Zf(Za,[Vd]),St=Vd(),[o0,cu]=n0(Za),du=t=>{const{__scopeContextMenu:e,children:s,onOpenChange:i,dir:n,modal:o=!0}=t,[a,l]=j.useState(!1),c=St(e),d=Wf(i),u=j.useCallback(h=>{l(h),d(h)},[d]);return r.jsx(o0,{scope:e,open:a,onOpenChange:u,modal:o,children:r.jsx(Kf,{...c,dir:n,open:a,onOpenChange:u,modal:o,children:s})})};du.displayName=Za;var hu="ContextMenuTrigger",uu=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,disabled:i=!1,...n}=t,o=cu(hu,s),a=St(s),l=j.useRef({x:0,y:0}),c=j.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=j.useRef(0),u=j.useCallback(()=>window.clearTimeout(d.current),[]),h=f=>{l.current={x:f.clientX,y:f.clientY},o.onOpenChange(!0)};return j.useEffect(()=>u,[u]),j.useEffect(()=>{i&&u()},[i,u]),r.jsxs(r.Fragment,{children:[r.jsx(qf,{...a,virtualRef:c}),r.jsx(Gf.span,{"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,...n,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:i?t.onContextMenu:Li(t.onContextMenu,f=>{u(),h(f),f.preventDefault()}),onPointerDown:i?t.onPointerDown:Li(t.onPointerDown,zr(f=>{u(),d.current=window.setTimeout(()=>h(f),700)})),onPointerMove:i?t.onPointerMove:Li(t.onPointerMove,zr(u)),onPointerCancel:i?t.onPointerCancel:Li(t.onPointerCancel,zr(u)),onPointerUp:i?t.onPointerUp:Li(t.onPointerUp,zr(u))})]})});uu.displayName=hu;var a0="ContextMenuPortal",fu=t=>{const{__scopeContextMenu:e,...s}=t,i=St(e);return r.jsx(Yf,{...i,...s})};fu.displayName=a0;var mu="ContextMenuContent",pu=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=cu(mu,s),o=St(s),a=j.useRef(!1);return r.jsx(Xf,{...o,...i,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{t.onCloseAutoFocus?.(l),!l.defaultPrevented&&a.current&&l.preventDefault(),a.current=!1},onInteractOutside:l=>{t.onInteractOutside?.(l),!l.defaultPrevented&&!n.modal&&(a.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});pu.displayName=mu;var l0="ContextMenuGroup",c0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(em,{...n,...i,ref:e})});c0.displayName=l0;var d0="ContextMenuLabel",h0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(tm,{...n,...i,ref:e})});h0.displayName=d0;var u0="ContextMenuItem",gu=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(Jf,{...n,...i,ref:e})});gu.displayName=u0;var f0="ContextMenuCheckboxItem",m0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(sm,{...n,...i,ref:e})});m0.displayName=f0;var p0="ContextMenuRadioGroup",g0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(im,{...n,...i,ref:e})});g0.displayName=p0;var _0="ContextMenuRadioItem",x0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(rm,{...n,...i,ref:e})});x0.displayName=_0;var v0="ContextMenuItemIndicator",b0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(nm,{...n,...i,ref:e})});b0.displayName=v0;var y0="ContextMenuSeparator",_u=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(Qf,{...n,...i,ref:e})});_u.displayName=y0;var S0="ContextMenuArrow",w0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(om,{...n,...i,ref:e})});w0.displayName=S0;var V0="ContextMenuSubTrigger",C0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(am,{...n,...i,ref:e})});C0.displayName=V0;var k0="ContextMenuSubContent",j0=j.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,n=St(s);return r.jsx(lm,{...n,...i,ref:e,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});j0.displayName=k0;function zr(t){return e=>e.pointerType!=="mouse"?t(e):void 0}var N0=du,A0=uu,E0=fu,I0=pu,T0=gu,R0=_u;function M0(t){const e=O.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i=r.jsx(N0,{"data-slot":"context-menu",...s}),e[2]=s,e[3]=i):i=e[3],i}function D0(t){const e=O.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i=r.jsx(A0,{"data-slot":"context-menu-trigger",...s}),e[2]=s,e[3]=i):i=e[3],i}function P0(t){const e=O.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let n;e[3]!==s?(n=Y("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",s),e[3]=s,e[4]=n):n=e[4];let o;return e[5]!==i||e[6]!==n?(o=r.jsx(E0,{children:r.jsx(I0,{"data-slot":"context-menu-content",className:n,...i})}),e[5]=i,e[6]=n,e[7]=o):o=e[7],o}function cc(t){const e=O.c(12);let s,i,n,o;e[0]!==t?({className:s,inset:i,variant:o,...n}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=o):(s=e[1],i=e[2],n=e[3],o=e[4]);const a=o===void 0?"default":o;let l;e[5]!==s?(l=Y("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[5]=s,e[6]=l):l=e[6];let c;return e[7]!==i||e[8]!==n||e[9]!==l||e[10]!==a?(c=r.jsx(T0,{"data-slot":"context-menu-item","data-inset":i,"data-variant":a,className:l,...n}),e[7]=i,e[8]=n,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function L0(t){const e=O.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let n;e[3]!==s?(n=Y("bg-border -mx-1 my-1 h-px",s),e[3]=s,e[4]=n):n=e[4];let o;return e[5]!==i||e[6]!==n?(o=r.jsx(R0,{"data-slot":"context-menu-separator",className:n,...i}),e[5]=i,e[6]=n,e[7]=o):o=e[7],o}function xu(t){const e=Oe(),s=bt(),i=Vh(),{locator:n}=_e(),o=_r({strict:!1}),a=ti({strict:!1});return async l=>{const c=crypto.randomUUID(),d=l===a.virtualmcpid?Dd(s,n,o.taskId??""):null;try{await i.create.mutateAsync({id:c,virtual_mcp_id:l,...d?{branch:d}:{}})}catch{}e({to:"/$org/$taskId",params:{org:t,taskId:c},search:{virtualmcpid:l}})}}function O0({agent:t,org:e,onUnpin:s,isDragging:i}){const n=Oe(),{isMobile:o,setOpenMobile:a}=Cr(),l=xu(e),d=yd({select:v=>v.location.pathname}).startsWith(`/${e}/${t.id}`),[u,h]=j.useState(null),f=j.useRef(null),m=j.useRef(null),p=j.useRef(!1);p.current=!!i,i&&(u||m.current)&&(m.current&&(clearTimeout(m.current),m.current=null),u&&h(null));const g=v=>{if(p.current)return;const y=v.currentTarget.getBoundingClientRect();m.current=setTimeout(()=>{p.current||h(y)},550)},_=v=>{m.current&&(clearTimeout(m.current),m.current=null),!(f.current&&v.relatedTarget instanceof Node&&f.current.contains(v.relatedTarget))&&h(null)},b=u?Math.round(u.height*.9):0,x=u?u.width+b:0;return r.jsx(M0,{children:r.jsxs(Pt,{className:Y(u&&"z-[55]"),children:[r.jsx(D0,{asChild:!0,children:r.jsx(Zt,{tooltip:u?void 0:t.title,isActive:d,onClick:()=>{re("sidebar_agent_pin_clicked",{agent_id:t.id,agent_title:t.title}),l(t.id),o&&a(!1)},onMouseEnter:g,onMouseLeave:_,children:r.jsx(Qt,{icon:t.icon,name:t.title,size:"xs",className:"w-full h-full [&_svg]:w-1/2 [&_svg]:h-1/2"})})}),r.jsxs(P0,{children:[r.jsxs(cc,{onClick:()=>{const v=crypto.randomUUID();n({to:"/$org/$taskId",params:{org:e,taskId:v},search:{virtualmcpid:t.id}})},children:[r.jsx(kr,{size:14}),"Settings"]}),r.jsx(L0,{}),r.jsxs(cc,{onClick:()=>{s(),d&&n({to:"/$org",params:{org:e}})},className:"",children:[r.jsx(Es,{size:14}),"Unpin"]})]}),u&&Ei.createPortal(r.jsx("button",{ref:f,type:"button",onMouseLeave:()=>h(null),onClick:v=>{v.stopPropagation(),h(null),s(),n({to:"/$org",params:{org:e}})},className:Y("flex items-center justify-center","bg-sidebar-accent text-muted-foreground","rounded-xl cursor-pointer","animate-in fade-in-0 slide-in-from-right-2","duration-150 [animation-timing-function:cubic-bezier(0.165,0.84,0.44,1)]","hover:text-foreground transition-colors"),style:{position:"fixed",top:u.top,left:u.left,height:u.height,width:x,paddingLeft:u.width,zIndex:50,boxShadow:"inset 0 0 0.5px 1px hsla(0, 0%, 100%, 0.075), 0 0 0 0.5px hsla(0, 0%, 0%, 0.12)"},children:r.jsx(Es,{size:14})}),document.body)]})})}function B0(t){const e=O.c(18);let s;e[0]!==t.agent.id?(s={id:t.agent.id},e[0]=t.agent.id,e[1]=s):s=e[1];const{attributes:i,listeners:n,setNodeRef:o,transform:a,transition:l,isDragging:c}=vg(s);let d;e[2]!==a?(d=bg.Transform.toString(a?{...a,x:0}:null),e[2]=a,e[3]=d):d=e[3];const u=c?.5:void 0,h=c?100:void 0;let f;e[4]!==d||e[5]!==u||e[6]!==h||e[7]!==l?(f={transform:d,transition:l,opacity:u,zIndex:h},e[4]=d,e[5]=u,e[6]=h,e[7]=l,e[8]=f):f=e[8];const m=f;let p;e[9]!==c||e[10]!==t?(p=r.jsx(O0,{...t,isDragging:c}),e[9]=c,e[10]=t,e[11]=p):p=e[11];let g;return e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==m||e[16]!==p?(g=r.jsx("div",{ref:o,style:m,...i,...n,tabIndex:-1,className:"w-full",children:p}),e[12]=i,e[13]=n,e[14]=o,e[15]=m,e[16]=p,e[17]=g):g=e[17],g}function $0(t){const e=O.c(9),{agent:s,onClick:i}=t;let n;e[0]!==s.icon||e[1]!==s.title?(n=r.jsx(Qt,{icon:s.icon,name:s.title,size:"md",className:"transition-transform group-hover:scale-105"}),e[0]=s.icon,e[1]=s.title,e[2]=n):n=e[2];let o;e[3]!==s.title?(o=r.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground line-clamp-2 w-full",children:s.title}),e[3]=s.title,e[4]=o):o=e[4];let a;return e[5]!==i||e[6]!==n||e[7]!==o?(a=r.jsxs("button",{type:"button",onClick:i,className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group",children:[n,o]}),e[5]=i,e[6]=n,e[7]=o,e[8]=a):a=e[8],a}function z0(t){const e=O.c(80),{onClose:s,onOpenImportDeco:i,onOpenGithubImport:n,onOpenSelfHealing:o,onOpenDiagnosticsModal:a,onOpenLeanCanvasModal:l,onOpenStudioPackModal:c,onOpenAiImageModal:d,onOpenAiResearchModal:u}=t,[h,f]=j.useState(""),m=Rn(),{org:p}=_e();let g;e[0]!==m?(g=m.filter(Y0).map(G0),e[0]=m,e[1]=g):g=e[1];const _=g,{pin:b,isPinned:x}=gh(p.id,_);let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v={navigateOnCreate:!0},e[2]=v):v=e[2];const{createVirtualMCP:y,isCreating:V}=_h(v),[C]=ei(),S=xu(p.slug),w=Sr();let k,T,M,I,E,N,A,D;if(e[3]!==m||e[4]!==y||e[5]!==V||e[6]!==x||e[7]!==w||e[8]!==S||e[9]!==s||e[10]!==d||e[11]!==u||e[12]!==a||e[13]!==n||e[14]!==i||e[15]!==l||e[16]!==o||e[17]!==c||e[18]!==b||e[19]!==C.experimental_vibecode||e[20]!==h){const q=h.toLowerCase();D=m.filter(q0).filter(ie=>!h||ie.title.toLowerCase().includes(q));let F;e[29]!==m?(F=m.some(K0),e[29]=m,e[30]=F):F=e[30];const K=F;k=jt.filter(ie=>(!h||ie.title.toLowerCase().includes(q))&&!(ie.id==="studio-pack"&&K)&&!(ie.id==="self-healing-storefront"&&!C.experimental_vibecode));let H;e[31]===Symbol.for("react.memo_cache_sentinel")?(H=jt.find(W0),e[31]=H):H=e[31];const U=H,X=U?m.find(ie=>ie.metadata?.type===U.id):void 0;let W;e[32]===Symbol.for("react.memo_cache_sentinel")?(W=jt.find(H0),e[32]=W):W=e[32];const G=W,se=G?m.find(ie=>ie.metadata?.type===G.id):void 0;let ee;e[33]===Symbol.for("react.memo_cache_sentinel")?(ee=jt.find(U0),e[33]=ee):ee=e[33];const J=ee,ae=J?m.find(ie=>ie.metadata?.type===J.id):void 0;let Z;e[34]===Symbol.for("react.memo_cache_sentinel")?(Z=jt.find(F0),e[34]=Z):Z=e[34];const de=Z,me=de?m.find(ie=>ie.metadata?.type===de.id):void 0;let le;e[35]!==x||e[36]!==S||e[37]!==s||e[38]!==b?(le=ie=>{x(ie.id)||b(ie.id),s(),f(""),S(ie.id)},e[35]=x,e[36]=S,e[37]=s,e[38]=b,e[39]=le):le=e[39];const he=le,be=ie=>{s(),f(""),ie==="self-healing-storefront"?o():ie==="site-editor"?i():ie==="site-diagnostics"?X?w(X.id):a():ie==="lean-canvas"?se?w(se.id):l():ie==="ai-image"?ae?w(ae.id):d():ie==="ai-research"?me?w(me.id):u():ie==="studio-pack"?c():S(ie)};N="flex flex-col max-h-[min(640px,80dvh)]",e[40]!==h?(A=r.jsx(yg,{value:h,onChange:f,placeholder:"Search agents..."}),e[40]=h,e[41]=A):A=e[41],T="overflow-y-auto flex-1 min-h-0 px-3 pb-3",e[42]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx("div",{className:"px-1 pt-3 pb-2",children:r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Agents"})}),e[42]=M):M=e[42];let fe;e[43]!==y||e[44]!==s?(fe=async()=>{re("agent_create_new_clicked",{source:"browse_popover"}),await y(),s()},e[43]=y,e[44]=s,e[45]=fe):fe=e[45];let ye,ve;e[46]===Symbol.for("react.memo_cache_sentinel")?(ye=r.jsx("div",{className:"w-12 h-12 rounded-xl border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-105",children:r.jsx(Dt,{size:16,className:"text-muted-foreground"})}),ve=r.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground",children:"Create new"}),e[46]=ye,e[47]=ve):(ye=e[46],ve=e[47]);let Ve;e[48]!==V||e[49]!==fe?(Ve=r.jsxs("button",{type:"button",disabled:V,onClick:fe,className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group disabled:opacity-50 disabled:cursor-not-allowed",children:[ye,ve]}),e[48]=V,e[49]=fe,e[50]=Ve):Ve=e[50];let Ie;e[51]!==s||e[52]!==n||e[53]!==C.experimental_vibecode?(Ie=C.experimental_vibecode&&r.jsxs("button",{type:"button",onClick:()=>{re("agent_import_clicked",{source:"github"}),n(),s()},className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl border-2 border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-105",children:r.jsx(ph,{className:"size-5 text-muted-foreground"})}),r.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground",children:"Import GitHub"})]}),e[51]=s,e[52]=n,e[53]=C.experimental_vibecode,e[54]=Ie):Ie=e[54];let te;e[55]!==he?(te=ie=>r.jsx($0,{agent:ie,onClick:()=>he(ie)},ie.id),e[55]=he,e[56]=te):te=e[56],I=r.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[Ve,Ie,D.map(te)]}),E=k.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-1 pt-4 pb-2",children:r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Agent templates"})}),r.jsx("div",{className:"grid grid-cols-3 gap-1",children:k.map(ie=>r.jsxs("button",{type:"button",onClick:()=>{re("agent_template_clicked",{template_id:ie.id,template_title:ie.title}),be(ie.id)},className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group disabled:opacity-50 disabled:cursor-not-allowed",children:[r.jsx(Qt,{icon:ie.icon,name:ie.title,size:"md",className:"transition-transform group-hover:scale-105"}),r.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground line-clamp-2 w-full",children:ie.title})]},ie.id))})]}),e[3]=m,e[4]=y,e[5]=V,e[6]=x,e[7]=w,e[8]=S,e[9]=s,e[10]=d,e[11]=u,e[12]=a,e[13]=n,e[14]=i,e[15]=l,e[16]=o,e[17]=c,e[18]=b,e[19]=C.experimental_vibecode,e[20]=h,e[21]=k,e[22]=T,e[23]=M,e[24]=I,e[25]=E,e[26]=N,e[27]=A,e[28]=D}else k=e[21],T=e[22],M=e[23],I=e[24],E=e[25],N=e[26],A=e[27],D=e[28];let L;e[57]!==k||e[58]!==V||e[59]!==h||e[60]!==D.length?(L=D.length===0&&k.length===0&&!V&&r.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:h?"No agents found":"No agents yet"}),e[57]=k,e[58]=V,e[59]=h,e[60]=D.length,e[61]=L):L=e[61];let R;e[62]!==T||e[63]!==M||e[64]!==I||e[65]!==E||e[66]!==L?(R=r.jsxs("div",{className:T,children:[M,I,E,L]}),e[62]=T,e[63]=M,e[64]=I,e[65]=E,e[66]=L,e[67]=R):R=e[67];let P;e[68]!==p.slug?(P={org:p.slug},e[68]=p.slug,e[69]=P):P=e[69];let B;e[70]!==s?(B=()=>s(),e[70]=s,e[71]=B):B=e[71];let $;e[72]!==P||e[73]!==B?($=r.jsx("div",{className:"border-t border-border px-3 py-2.5",children:r.jsx(Cd,{to:"/$org/settings/agents",params:P,onClick:B,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center justify-center",children:"See all agents"})}),e[72]=P,e[73]=B,e[74]=$):$=e[74];let z;return e[75]!==R||e[76]!==$||e[77]!==N||e[78]!==A?(z=r.jsxs("div",{className:N,children:[A,R,$]}),e[75]=R,e[76]=$,e[77]=N,e[78]=A,e[79]=z):z=e[79],z}function F0(t){return t.id==="ai-research"}function U0(t){return t.id==="ai-image"}function H0(t){return t.id==="lean-canvas"}function W0(t){return t.id==="site-diagnostics"}function K0(t){return Wm(t.id)}function q0(t){return!lr(t.id)}function G0(t){return t.id}function Y0(t){return t.pinned}function X0(){const t=O.c(36),[e,s]=j.useState(!1),[i,n]=j.useState(!1),[o,a]=j.useState(!1),[l,c]=j.useState(!1),[d,u]=j.useState(!1),[h,f]=j.useState(!1),[m,p]=j.useState(!1),[g,_]=j.useState(!1),[b,x]=j.useState(!1),v=ms(),{setOpenMobile:y}=Cr();let V;t[0]!==v||t[1]!==y?(V=()=>{s(!1),v&&y(!1)},t[0]=v,t[1]=y,t[2]=V):V=t[2];const C=V;let S;t[3]!==C||t[4]!==e?(S=e&&r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(wi,{className:"h-4 w-24"})}),children:r.jsx(z0,{onClose:C,onOpenImportDeco:()=>n(!0),onOpenGithubImport:()=>{a(!0),C()},onOpenSelfHealing:()=>{c(!0),C()},onOpenDiagnosticsModal:()=>u(!0),onOpenLeanCanvasModal:()=>f(!0),onOpenStudioPackModal:()=>p(!0),onOpenAiImageModal:()=>_(!0),onOpenAiResearchModal:()=>x(!0)})}),t[3]=C,t[4]=e,t[5]=S):S=t[5];const w=S;let k;t[6]!==v||t[7]!==e||t[8]!==w?(k=v?r.jsxs(r.Fragment,{children:[r.jsx(Pt,{children:r.jsx(Zt,{tooltip:"Browse agents",className:"bg-muted/75 hover:bg-sidebar-accent",onClick:()=>{re("agent_browser_opened",{surface:"mobile_drawer"}),s(!0)},children:r.jsx(Dt,{className:"!opacity-100"})})}),r.jsx(ri,{open:e,onOpenChange:s,direction:"bottom",children:r.jsxs(ii,{className:"max-h-[85dvh] p-0",children:[r.jsx(si,{className:"sr-only",children:"Browse agents"}),w]})})]}):r.jsxs(Us,{open:e,onOpenChange:P=>{P&&!e&&re("agent_browser_opened",{surface:"desktop_popover"}),s(P)},children:[r.jsx(Pt,{children:r.jsx(zs,{asChild:!0,children:r.jsx(Zt,{tooltip:"Browse agents",className:"bg-muted/75 hover:bg-sidebar-accent",children:r.jsx(Dt,{className:"!opacity-100"})})})}),r.jsx(Fs,{className:"w-[380px] p-0 overflow-hidden",side:"right",align:"start",children:w})]}),t[6]=v,t[7]=e,t[8]=w,t[9]=k):k=t[9];let T;t[10]!==i?(T=r.jsx(fn,{open:i,onOpenChange:n}),t[10]=i,t[11]=T):T=t[11];let M;t[12]!==o?(M=r.jsx(hh,{open:o,onOpenChange:a}),t[12]=o,t[13]=M):M=t[13];let I;t[14]!==l?(I=r.jsx(Qh,{open:l,onOpenChange:c}),t[14]=l,t[15]=I):I=t[15];let E;t[16]!==d?(E=r.jsx(uh,{open:d,onOpenChange:u}),t[16]=d,t[17]=E):E=t[17];let N;t[18]!==h?(N=r.jsx(fh,{open:h,onOpenChange:f}),t[18]=h,t[19]=N):N=t[19];let A;t[20]!==m?(A=r.jsx(mh,{open:m,onOpenChange:p}),t[20]=m,t[21]=A):A=t[21];let D;t[22]!==g?(D=r.jsx(Xh,{open:g,onOpenChange:_}),t[22]=g,t[23]=D):D=t[23];let L;t[24]!==b?(L=r.jsx(Jh,{open:b,onOpenChange:x}),t[24]=b,t[25]=L):L=t[25];let R;return t[26]!==L||t[27]!==k||t[28]!==T||t[29]!==M||t[30]!==I||t[31]!==E||t[32]!==N||t[33]!==A||t[34]!==D?(R=r.jsxs(r.Fragment,{children:[k,T,M,I,E,N,A,D,L]}),t[26]=L,t[27]=k,t[28]=T,t[29]=M,t[30]=I,t[31]=E,t[32]=N,t[33]=A,t[34]=D,t[35]=R):R=t[35],R}function J0(){const t=O.c(34),e=Rn(),{org:s}=_e();let i;t[0]!==e?(i=e.filter(ty).map(ey),t[0]=e,t[1]=i):i=t[1];const n=i,{pinnedIds:o,unpin:a,reorder:l}=gh(s.id,n),c=new Map(e.map(Z0)),d=o.map(R=>c.get(R)).filter(Q0);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{distance:5}},t[2]=u):u=t[2];let h;t[3]===Symbol.for("react.memo_cache_sentinel")?(h={coordinateGetter:_g},t[3]=h):h=t[3];const f=dg(Tl(ug,u),Tl(hg,h));let m;t[4]!==o||t[5]!==l?(m=R=>{const{active:P,over:B}=R;if(!B||P.id===B.id)return;const $=o.indexOf(P.id),z=o.indexOf(B.id);$===-1||z===-1||l(xg([...o],$,z))},t[4]=o,t[5]=l,t[6]=m):m=t[6];const p=m,g=wr,_="py-0 px-0 mt-2 flex-1 min-h-0";let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"h-px bg-border mx-2 mb-2"}),t[7]=b):b=t[7];const x=Vr,v="flex flex-1 min-h-0 flex-col overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",y=es,V="gap-2";let C;t[8]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(X0,{}),t[8]=C):C=t[8];const S=pg,w=gg,k=fg,T=mg;let M;t[9]!==s.slug||t[10]!==a?(M=R=>r.jsx(B0,{agent:R,org:s.slug,onUnpin:()=>a(R.id)},R.id),t[9]=s.slug,t[10]=a,t[11]=M):M=t[11];const I=d.map(M);let E;t[12]!==k||t[13]!==o||t[14]!==T||t[15]!==I?(E=r.jsx(k,{items:o,strategy:T,children:I}),t[12]=k,t[13]=o,t[14]=T,t[15]=I,t[16]=E):E=t[16];let N;t[17]!==S||t[18]!==p||t[19]!==f||t[20]!==E||t[21]!==w?(N=r.jsx(S,{sensors:f,collisionDetection:w,onDragEnd:p,children:E}),t[17]=S,t[18]=p,t[19]=f,t[20]=E,t[21]=w,t[22]=N):N=t[22];let A;t[23]!==y||t[24]!==N||t[25]!==C?(A=r.jsxs(y,{className:V,children:[C,N]}),t[23]=y,t[24]=N,t[25]=C,t[26]=A):A=t[26];let D;t[27]!==x||t[28]!==A?(D=r.jsx(x,{className:v,children:A}),t[27]=x,t[28]=A,t[29]=D):D=t[29];let L;return t[30]!==g||t[31]!==D||t[32]!==b?(L=r.jsxs(g,{className:_,children:[b,D]}),t[30]=g,t[31]=D,t[32]=b,t[33]=L):L=t[33],L}function Q0(t){return!!t}function Z0(t){return[t.id,t]}function ey(t){return t.id}function ty(t){return t.pinned}function vu(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(j.Suspense,{fallback:r.jsx(wr,{className:"py-0 px-0",children:r.jsx(Vr,{children:r.jsx(es,{className:"gap-2",children:r.jsx(Pt,{children:r.jsxs("div",{className:"flex items-center gap-2 px-2 py-2",children:[r.jsx(wi,{className:"h-4 w-4 rounded"}),r.jsx(wi,{className:"h-4 flex-1"})]})})})})}),children:r.jsx(J0,{})}),t[0]=e):e=t[0],e}function sy(){const t=O.c(4),e=iu();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(i0,{}),t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ls,{children:r.jsx(j.Suspense,{fallback:null,children:r.jsx(vu,{})})}),t[1]=i):i=t[1];let n;return t[2]!==e?(n=r.jsx(ou,{sections:e,footer:s,additionalContent:i}),t[2]=e,t[3]=n):n=t[3],n}function iy(t){const e=O.c(5),{onClose:s}=t,i=iu();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(r0,{}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(ls,{children:r.jsx(j.Suspense,{fallback:null,children:r.jsx(vu,{})})}),e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i?(a=r.jsx(Rb,{sections:i,onClose:s,footer:n,additionalContent:o}),e[2]=s,e[3]=i,e[4]=a):a=e[4],a}async function ry(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const n=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(n)}return i}const bu=["VM_START"],Fr=new Map,ny=t=>`${t.virtualMcpId}::${t.branch??""}`;function el(t){const e=bt();return Ni({mutationKey:bu,mutationFn:async s=>{const i=ny(s),n=Fr.get(i);if(n)return n;const o=(async()=>(await ry(t,"VM_START",s)).structuredContent)();Fr.set(i,o);try{return await o}finally{Fr.get(i)===o&&Fr.delete(i)}},onSuccess:()=>{Xr(e)}})}function oy(t,e){const s=O.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:bu,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Dg(i)>0}function ay(t,e){return t===1?!0:t===0?!1:e}function ly(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,n=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:n}}function dc(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function cy(t,e){return t===1?!0:t===0?!1:e}function dy(t,e){const s=Oe(),i=ti({strict:!1}),n=_r({strict:!1}),o=bt(),a=Vh(),{locator:l}=_e(),{virtualMcpId:c,orgSlug:d,isAgentRoute:u}=e,h=ly({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),f=cy(i.chat,h.chatOpen),m=h.mainOpen,p=j.useRef(crypto.randomUUID()),g=n.taskId??p.current,_="/$org/$taskId",b=T=>({org:d,taskId:T}),x=u?{virtualmcpid:c}:{},v=(T,M)=>{s({to:_,params:b(g),search:I=>({...I,...T}),replace:M?.replace??!1})},y=(T,M)=>{s({to:_,params:b(T),search:I=>{const E={};return M?E.virtualmcpid=M:u&&(E.virtualmcpid=c),I.tasks&&(E.tasks=I.tasks),E}})},V=()=>{m?v({main:"0"},{replace:!0}):v({main:Cm(t)},{replace:!0})},C=()=>{v({chat:f?0:1},{replace:!0})},S=()=>{f||v({chat:1},{replace:!0})},w=async()=>{const T=crypto.randomUUID(),M=Dd(o,l,g);try{await a.create.mutateAsync({id:T,virtual_mcp_id:c,...M?{branch:M}:{}})}catch{}s({to:_,params:b(T),search:I=>{const E={...x,chat:1};return I.tasks&&(E.tasks=I.tasks),E}})},k=T=>{v({main:T},{replace:!0})};return{taskId:g,mainOpen:m,chatOpen:f,mainParam:i.main,setTaskId:y,toggleMain:V,toggleChat:C,openChat:S,createNewTask:w,openTab:k}}const tl=j.createContext(null);function hy(t){const e=O.c(15),{children:s}=t,i=Oe();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},e[0]=n):n=e[0];const o=ti(n);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={owner:"all",status:"open"},e[1]=a):a=e[1];const{tasks:l}=Co(a);let c;e[2]!==o.tasks||e[3]!==l.length?(c=()=>ay(o.tasks,l.length>0),e[2]=o.tasks,e[3]=l.length,e[4]=c):c=e[4];const[d,u]=j.useState(c);let h,f;e[5]!==i||e[6]!==d?(h=()=>{i({search:(b=>({...b,tasks:d?1:0})),replace:!0})},f=[d,i],e[5]=i,e[6]=d,e[7]=h,e[8]=f):(h=e[7],f=e[8]),j.useEffect(h,f);let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=()=>u(uy),e[9]=m):m=e[9];const p=m;let g;e[10]!==d?(g={tasksOpen:d,toggleTasks:p},e[10]=d,e[11]=g):g=e[11];let _;return e[12]!==s||e[13]!==g?(_=r.jsx(tl.Provider,{value:g,children:s}),e[12]=s,e[13]=g,e[14]=_):_=e[14],_}function uy(t){return!t}function yu(){const t=j.useContext(tl);if(!t)throw new Error("useTasksPanelState must be used inside <TasksPanelStateProvider>");return t}function fy(){return j.useContext(tl)}const Su=j.createContext(null);function Hs(){const t=j.use(Su);if(!t)throw new Error("Toolbar.* must be used inside <Toolbar>");return t}function Re(t){const e=O.c(10),{children:s}=t,[i,n]=j.useState(null),[o,a]=j.useState(null),[l,c]=j.useState(null),[d,u]=j.useState(null);let h;e[0]!==l||e[1]!==d||e[2]!==o||e[3]!==i?(h={togglesEl:i,setTogglesEl:n,tabsEl:o,setTabsEl:a,centerEl:l,setCenterEl:c,rightEl:d,setRightEl:u},e[0]=l,e[1]=d,e[2]=o,e[3]=i,e[4]=h):h=e[4];let f;e[5]!==s?(f=r.jsx("div",{className:"flex flex-col h-full min-h-0",children:s}),e[5]=s,e[6]=f):f=e[6];let m;return e[7]!==h||e[8]!==f?(m=r.jsx(Su,{value:h,children:f}),e[7]=h,e[8]=f,e[9]=m):m=e[9],m}function my(t){const e=O.c(2),{children:s}=t;let i;return e[0]!==s?(i=r.jsx("div",{className:"shrink-0 grid grid-cols-3 items-center pl-1 pr-2 pt-0.25 h-12",children:s}),e[0]=s,e[1]=i):i=e[1],i}function py(t){const e=O.c(2),{children:s}=t;let i;return e[0]!==s?(i=r.jsx("div",{className:"flex items-center gap-0.5 min-w-0 justify-self-start",children:s}),e[0]=s,e[1]=i):i=e[1],i}function gy(t){const e=O.c(2),{children:s}=t;let i;return e[0]!==s?(i=r.jsx("div",{className:"flex items-center justify-end gap-0.5 min-w-0 justify-self-end",children:s}),e[0]=s,e[1]=i):i=e[1],i}function _y(){const t=O.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("button",{type:"button",onClick:vy,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground transition-colors",title:"Go back",children:r.jsx(Eo,{size:16})}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs(r.Fragment,{children:[e,r.jsx("button",{type:"button",onClick:xy,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground transition-colors",title:"Go forward",children:r.jsx($a,{size:16})})]}),t[1]=s):s=t[1],s}function xy(){return window.history.forward()}function vy(){return window.history.back()}function by(){const t=O.c(2),{setCenterEl:e}=Hs();let s;return t[0]!==e?(s=r.jsx("div",{ref:e,className:"min-w-0 flex items-center justify-center gap-2"}),t[0]=e,t[1]=s):s=t[1],s}function yy(t){const e=O.c(3),{children:s}=t,{centerEl:i}=Hs();if(!i)return null;let n;return e[0]!==i||e[1]!==s?(n=Ei.createPortal(s,i),e[0]=i,e[1]=s,e[2]=n):n=e[2],n}function Sy(){const t=O.c(2),{setTabsEl:e}=Hs();let s;return t[0]!==e?(s=r.jsx("div",{ref:e,className:"shrink-0 flex items-center overflow-x-auto"}),t[0]=e,t[1]=s):s=t[1],s}function wy(t){const e=O.c(3),{children:s}=t,{tabsEl:i}=Hs();if(!i)return null;let n;return e[0]!==s||e[1]!==i?(n=Ei.createPortal(s,i),e[0]=s,e[1]=i,e[2]=n):n=e[2],n}function Vy(){const t=O.c(2),{setTogglesEl:e}=Hs();let s;return t[0]!==e?(s=r.jsx("div",{ref:e,className:"flex items-center gap-0.5 shrink-0 ml-0.5"}),t[0]=e,t[1]=s):s=t[1],s}function Cy(t){const e=O.c(3),{children:s}=t,{togglesEl:i}=Hs();if(!i)return null;let n;return e[0]!==s||e[1]!==i?(n=Ei.createPortal(s,i),e[0]=s,e[1]=i,e[2]=n):n=e[2],n}function ky(){const t=O.c(2),{setRightEl:e}=Hs();let s;return t[0]!==e?(s=r.jsx("div",{ref:e,className:"flex items-center justify-end gap-0.5 shrink-0"}),t[0]=e,t[1]=s):s=t[1],s}function jy(t){const e=O.c(3),{children:s}=t,{rightEl:i}=Hs();if(!i)return null;let n;return e[0]!==s||e[1]!==i?(n=Ei.createPortal(s,i),e[0]=s,e[1]=i,e[2]=n):n=e[2],n}Re.Header=my;Re.LeftColumn=py;Re.RightColumn=gy;Re.Nav=_y;Re.CenterSlot=by;Re.Center=yy;Re.TabsSlot=Sy;Re.Tabs=wy;Re.TogglesSlot=Vy;Re.Toggles=Cy;Re.RightSlot=ky;Re.Right=jy;const Ny=280;function Ay(){const t=O.c(2),{tasksOpen:e}=yu();if(!e)return null;let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={width:`${Ny}px`},t[0]=s):s=t[0];let i;return t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("aside",{className:"shrink-0 h-full bg-sidebar pb-1",style:s,children:r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:r.jsx(su,{})})})}),t[1]=i):i=t[1],i}function Ey(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(j.Suspense,{fallback:null,children:r.jsx(Ay,{})}),t[0]=e):e=t[0],e}const Iy={settings:ip,automations:Fd,env:Ia,preview:Qd,git:er};function hc(t){const e=vr(t);if(e.type==="icon"){const s=br(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function io(t){if(t.kind==="system")return{kind:"component",Component:Iy[t.tabId]};const e=hc(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(n=>n.id===t.appId);if(!s)return{kind:"fallback"};const i=hc(s.icon);return i||{kind:"fallback"}}function Ty(t){const{org:e}=_e(),s=Ae({connectionId:yt,orgId:e.id}),{data:i}=bd({queryKey:Ze.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const n=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(n.structuredContent??n).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function wu(t){const e=O.c(8),s=Oe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const n=ti(i),o=$t(t.virtualMcpId),a=Ty(t.taskId),{currentBranch:l}=Lt(),c=o?.metadata?.ui??null,d=c?.layout??null,u=d?.tabs??[],h=c?.pinnedViews??[],f=a?.expanded_tools??[],m=!!(o&&bs(o));let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p={includeVirtual:!0},e[1]=p):p=e[1];const g=yr(p),{activeTab:_,mainOpen:b}=km({mainParam:n.main,metadata:d?{defaultMainView:d.defaultMainView??null,tabs:u.map(Ry)}:null}),x=Ad(_),v=[];m&&(v.push({id:"preview",title:"Preview"}),v.push({id:"env",title:"Terminal"}),v.push({id:"git",title:l??"git"})),v.push({id:"settings",title:"Settings"}),v.push({id:"automations",title:"Automations"});const y=new Map;for(const k of f){const T=jo(k.appId,k.toolName);y.set(T,{id:T,title:k.toolName,appId:k.appId,iconKey:k.toolName})}for(const k of h){const T=jo(k.connectionId,k.toolName);y.set(T,{id:T,title:k.label||k.toolName,appId:k.connectionId,iconKey:k.toolName,iconUrl:k.icon??null})}let V;e[2]!==g?(V=k=>({id:k.id,title:k.title,kind:"agent",icon:io({tabId:k.id,kind:"agent",appId:k.view.appId,connections:g})}),e[2]=g,e[3]=V):V=e[3];const C=[...u.map(V),...Array.from(y.values()).map(k=>({id:k.id,title:k.title,kind:"expanded",icon:io({tabId:k.iconKey,kind:"expanded",appId:k.appId,iconUrl:k.iconUrl,connections:g})})),...v.map(k=>({id:k.id,title:k.title,kind:"system",icon:io({tabId:k.id,kind:"system",connections:g})}))];let S;return e[4]!==_||e[5]!==b||e[6]!==s?(S=k=>{const T=jm({clickedId:k,activeTab:_,mainOpen:b});s({to:".",search:M=>({...M,main:T}),replace:!0})},e[4]=_,e[5]=b,e[6]=s,e[7]=S):S=e[7],{activeTab:_,mainOpen:b,setActiveTab:S,systemTabs:v,layoutTabs:u,expandedTools:f,automationTabParsed:x,tabs:C}}function Ry(t){return{id:t.id}}function My(t){const e=O.c(84),{value:s,onChange:i,onColorChange:n,name:o,size:a,className:l,avatarClassName:c,showHoverOverlay:d,disabled:u}=t,h=a===void 0?"lg":a,f=d===void 0?!0:d,m=u===void 0?!1:u,[p,g]=j.useState(!1),[_,b]=j.useState("icons"),[x,v]=j.useState(""),[y,V]=j.useState("blue");let C;e[0]!==s?(C=vr(s),e[0]=s,e[1]=C):C=e[1];const S=C,w=S.type==="icon"||S.type==="url"&&S.color?S.color:y;let k;e[2]!==i||e[3]!==w?(k=ve=>{i(Yn(ve,w))},e[2]=i,e[3]=w,e[4]=k):k=e[4];const T=k;let M;e[5]!==i||e[6]!==n||e[7]!==S.name||e[8]!==S.type||e[9]!==S.url?(M=ve=>{V(ve),n?.(ve),S.type==="icon"?i(Yn(S.name,ve)):S.type==="url"&&i(Sl(S.url,ve))},e[5]=i,e[6]=n,e[7]=S.name,e[8]=S.type,e[9]=S.url,e[10]=M):M=e[10];const I=M;let E;e[11]!==i||e[12]!==w?(E=ve=>{i(Sl(ve,w)),g(!1)},e[11]=i,e[12]=w,e[13]=E):E=e[13];const N=E;let A;e[14]!==i||e[15]!==w?(A=()=>{const ve=Ma(),Ve=ve[Math.floor(Math.random()*ve.length)];i(Yn(Ve,w))},e[14]=i,e[15]=w,e[16]=A):A=e[16];const D=A;let L,R,P,B,$,z,q,F;if(e[17]!==l||e[18]!==m||e[19]!==p||e[20]!==h){const ve={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};R=Us,z=m?!1:p,q=g,L=zs,$=!0,F="button",P=m,B=Y("relative group overflow-hidden",m?"cursor-default opacity-50":"cursor-pointer",ve[h],l),e[17]=l,e[18]=m,e[19]=p,e[20]=h,e[21]=L,e[22]=R,e[23]=P,e[24]=B,e[25]=$,e[26]=z,e[27]=q,e[28]=F}else L=e[21],R=e[22],P=e[23],B=e[24],$=e[25],z=e[26],q=e[27],F=e[28];let K;e[29]!==c||e[30]!==o||e[31]!==h||e[32]!==s?(K=r.jsx(Qt,{icon:s,name:o,size:h,className:c}),e[29]=c,e[30]=o,e[31]=h,e[32]=s,e[33]=K):K=e[33];let H;e[34]!==m||e[35]!==f?(H=f&&!m&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:r.jsx(Ra,{size:16,className:"text-white"})}),e[34]=m,e[35]=f,e[36]=H):H=e[36];let U;e[37]!==P||e[38]!==B||e[39]!==K||e[40]!==H||e[41]!==F?(U=r.jsxs("button",{type:F,disabled:P,className:B,children:[K,H]}),e[37]=P,e[38]=B,e[39]=K,e[40]=H,e[41]=F,e[42]=U):U=e[42];let X;e[43]!==L||e[44]!==$||e[45]!==U?(X=r.jsx(L,{asChild:$,children:U}),e[43]=L,e[44]=$,e[45]=U,e[46]=X):X=e[46];let W;e[47]!==o||e[48]!==s?(W=r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx(Qt,{icon:s,name:o,size:"xl"})}),e[47]=o,e[48]=s,e[49]=W):W=e[49];let G;e[50]===Symbol.for("react.memo_cache_sentinel")?(G=()=>b("icons"),e[50]=G):G=e[50];const se=_==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ee;e[51]!==se?(ee=Y("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",se),e[51]=se,e[52]=ee):ee=e[52];let J;e[53]!==ee?(J=r.jsx("button",{type:"button",onClick:G,className:ee,children:"Icons"}),e[53]=ee,e[54]=J):J=e[54];let ae;e[55]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>b("upload"),e[55]=ae):ae=e[55];const Z=_==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let de;e[56]!==Z?(de=Y("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",Z),e[56]=Z,e[57]=de):de=e[57];let me;e[58]!==de?(me=r.jsx("button",{type:"button",onClick:ae,className:de,children:"Upload"}),e[58]=de,e[59]=me):me=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx("div",{className:"flex-1"}),e[60]=le):le=e[60];let he;e[61]!==J||e[62]!==me?(he=r.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[J,me,le]}),e[61]=J,e[62]=me,e[63]=he):he=e[63];let be;e[64]!==I||e[65]!==D||e[66]!==T||e[67]!==N||e[68]!==S.name||e[69]!==S.type||e[70]!==x||e[71]!==w||e[72]!==_?(be=_==="icons"?r.jsx(Oy,{search:x,onSearchChange:v,selectedColor:w,onColorChange:I,onSelectIcon:T,onRandom:D,currentIconName:S.type==="icon"?S.name:null}):r.jsx(By,{onUpload:N}),e[64]=I,e[65]=D,e[66]=T,e[67]=N,e[68]=S.name,e[69]=S.type,e[70]=x,e[71]=w,e[72]=_,e[73]=be):be=e[73];let fe;e[74]!==W||e[75]!==he||e[76]!==be?(fe=r.jsx(Fs,{align:"start",className:"w-80 p-0",onOpenAutoFocus:Dy,children:r.jsxs("div",{className:"flex flex-col",children:[W,he,be]})}),e[74]=W,e[75]=he,e[76]=be,e[77]=fe):fe=e[77];let ye;return e[78]!==R||e[79]!==z||e[80]!==q||e[81]!==X||e[82]!==fe?(ye=r.jsxs(R,{open:z,onOpenChange:q,children:[X,fe]}),e[78]=R,e[79]=z,e[80]=q,e[81]=X,e[82]=fe,e[83]=ye):ye=e[83],ye}function Dy(t){return t.preventDefault()}function Py(t){const e=O.c(27),{selectedColor:s,onColorChange:i}=t,[n,o]=j.useState(!1);let a,l,c,d,u,h,f;if(e[0]!==n||e[1]!==s){const x=Ud(s);l=Us,h=n,f=o,a=zs,u=!0,c="button",d=Y("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",x.dot,"ring-foreground/20"),e[0]=n,e[1]=s,e[2]=a,e[3]=l,e[4]=c,e[5]=d,e[6]=u,e[7]=h,e[8]=f}else a=e[2],l=e[3],c=e[4],d=e[5],u=e[6],h=e[7],f=e[8];let m;e[9]!==c||e[10]!==d?(m=r.jsx("button",{type:c,className:d,title:"Change color"}),e[9]=c,e[10]=d,e[11]=m):m=e[11];let p;e[12]!==a||e[13]!==u||e[14]!==m?(p=r.jsx(a,{asChild:u,children:m}),e[12]=a,e[13]=u,e[14]=m,e[15]=p):p=e[15];let g;e[16]!==i||e[17]!==s?(g=np.map(x=>r.jsx("button",{type:"button",onClick:()=>{i(x.name),o(!1)},className:Y("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",x.dot,s===x.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:x.name},x.name)),e[16]=i,e[17]=s,e[18]=g):g=e[18];let _;e[19]!==g?(_=r.jsx(Fs,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Ly,children:r.jsx("div",{className:"grid grid-cols-4 gap-1",children:g})}),e[19]=g,e[20]=_):_=e[20];let b;return e[21]!==l||e[22]!==h||e[23]!==f||e[24]!==p||e[25]!==_?(b=r.jsxs(l,{open:h,onOpenChange:f,children:[p,_]}),e[21]=l,e[22]=h,e[23]=f,e[24]=p,e[25]=_,e[26]=b):b=e[26],b}function Ly(t){return t.preventDefault()}function Oy(t){const e=O.c(44),{search:s,onSearchChange:i,selectedColor:n,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:c}=t;let d,u,h,f,m,p,g;if(e[0]!==c||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==n){const y=Ma(),V=Ud(n);u=s.trim()?y.filter(I=>{const E=Ao(I),N=s.toLowerCase();return E.includes(N)||I.toLowerCase().includes(N)}):y,p="flex flex-col";let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(kh,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=C):C=e[14];let S;e[15]!==i?(S=I=>i(I.target.value),e[15]=i,e[16]=S):S=e[16];let w;e[17]!==s||e[18]!==S?(w=r.jsxs("div",{className:"relative flex-1",children:[C,r.jsx(at,{value:s,onChange:S,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=S,e[19]=w):w=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(rp,{size:14,className:"text-muted-foreground"}),e[20]=k):k=e[20];let T;e[21]!==l?(T=r.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:k}),e[21]=l,e[22]=T):T=e[22];let M;e[23]!==o||e[24]!==n?(M=r.jsx(Py,{selectedColor:n,onColorChange:o}),e[23]=o,e[24]=n,e[25]=M):M=e[25],e[26]!==T||e[27]!==M||e[28]!==w?(g=r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[w,T,M]}),e[26]=T,e[27]=M,e[28]=w,e[29]=g):g=e[29],d=Ed,m="h-56",h="grid grid-cols-9 gap-0.5 px-2 pb-2",f=u.map(I=>{const E=br(I);return E?r.jsx("button",{type:"button",onClick:()=>a(I),className:Y("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",c===I?Y(V.bg,V.text):Y(V.text,"hover:bg-accent")),title:I,children:r.jsx(E,{size:18})},I):null}),e[0]=c,e[1]=o,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=n,e[7]=d,e[8]=u,e[9]=h,e[10]=f,e[11]=m,e[12]=p,e[13]=g}else d=e[7],u=e[8],h=e[9],f=e[10],m=e[11],p=e[12],g=e[13];let _;e[30]!==h||e[31]!==f?(_=r.jsx("div",{className:h,children:f}),e[30]=h,e[31]=f,e[32]=_):_=e[32];let b;e[33]!==u.length?(b=u.length===0&&r.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=u.length,e[34]=b):b=e[34];let x;e[35]!==d||e[36]!==m||e[37]!==_||e[38]!==b?(x=r.jsxs(d,{className:m,children:[_,b]}),e[35]=d,e[36]=m,e[37]=_,e[38]=b,e[39]=x):x=e[39];let v;return e[40]!==p||e[41]!==g||e[42]!==x?(v=r.jsxs("div",{className:p,children:[g,x]}),e[40]=p,e[41]=g,e[42]=x,e[43]=v):v=e[43],v}function By(t){const e=O.c(27),{onUpload:s}=t,i=j.useRef(null);let n;e[0]!==s?(n=C=>{const S=C.target.files?.[0];if(!S)return;if(S.size>2097152){ue.error("Image must be smaller than 2MB"),C.target.value="";return}const w=new FileReader;w.onerror=()=>{ue.error("Failed to read image file"),i.current&&(i.current.value="")},w.onloadend=()=>{w.readyState===FileReader.DONE&&w.result&&s(w.result),i.current&&(i.current.value="")},w.readAsDataURL(S)},e[0]=s,e[1]=n):n=e[1];const o=n,[a,l]=j.useState("");let c;e[2]!==s||e[3]!==a?(c=()=>{const C=a.trim();C&&(s(C),l(""))},e[2]=s,e[3]=a,e[4]=c):c=e[4];const d=c;let u;e[5]!==o?(u=r.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:o}),e[5]=o,e[6]=u):u=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=()=>i.current?.click(),e[7]=h):h=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsxs("button",{type:"button",onClick:h,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[r.jsx(Jd,{size:20}),r.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=C=>l(C.target.value),e[10]=p):p=e[10];let g;e[11]!==d?(g=C=>{C.key==="Enter"&&(C.preventDefault(),d())},e[11]=d,e[12]=g):g=e[12];let _;e[13]!==a||e[14]!==g?(_=r.jsx(at,{value:a,onChange:p,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:g}),e[13]=a,e[14]=g,e[15]=_):_=e[15];let b;e[16]!==a?(b=a.trim(),e[16]=a,e[17]=b):b=e[17];const x=!b;let v;e[18]!==d||e[19]!==x?(v=r.jsx(oe,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:d,disabled:x,children:"Apply"}),e[18]=d,e[19]=x,e[20]=v):v=e[20];let y;e[21]!==v||e[22]!==_?(y=r.jsxs("div",{className:"flex items-center gap-1.5",children:[_,v]}),e[21]=v,e[22]=_,e[23]=y):y=e[23];let V;return e[24]!==y||e[25]!==u?(V=r.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,f,m,y]}),e[24]=y,e[25]=u,e[26]=V):V=e[26],V}function $y(t){const e=O.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=vr(s);if(o.type==="icon"){const a=br(o.name);if(a){let l;e[2]!==a?(l=r.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let n;return e[4]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(xh,{size:16,className:"text-muted-foreground"}),e[4]=n):n=e[4],n}function zy(t){const e=O.c(66),{value:s,onChange:i,className:n,disabled:o}=t,[a,l]=j.useState(!1),[c,d]=j.useState("");let u;e[0]!==s?(u=vr(s),e[0]=s,e[1]=u):u=e[1];const h=u,f=h.type==="icon"?h.name:null;let m,p,g,_,b,x,v,y,V,C,S,w,k,T,M;if(e[2]!==n||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==c||e[8]!==s){const R=Ma();_=c.trim()?R.filter(K=>{const H=c.toLowerCase();return Ao(K).includes(H)||K.toLowerCase().includes(H)}):R,g=Us,b=o?!1:a,x=l;const P=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let B;e[24]!==n||e[25]!==P?(B=Y("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",P,n),e[24]=n,e[25]=P,e[26]=B):B=e[26];let $;e[27]!==s?($=r.jsx($y,{value:s}),e[27]=s,e[28]=$):$=e[28],e[29]!==o||e[30]!==B||e[31]!==$?(v=r.jsx(zs,{asChild:!0,children:r.jsx("button",{type:"button",disabled:o,className:B,children:$})}),e[29]=o,e[30]=B,e[31]=$,e[32]=v):v=e[32],p=Fs,k="start",T="w-64 p-0",M=Fy,S="flex flex-col";let z;e[33]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(kh,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=z):z=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=K=>d(K.target.value),e[34]=q):q=e[34],e[35]!==c?(w=r.jsx("div",{className:"px-2 py-2",children:r.jsxs("div",{className:"relative",children:[z,r.jsx(at,{value:c,onChange:q,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=c,e[36]=w):w=e[36],m=Ed,C="h-48",y="grid grid-cols-8 gap-0.5 px-2 pb-2";let F;e[37]!==f||e[38]!==i?(F=K=>{const H=br(K);return H?r.jsx("button",{type:"button",onClick:()=>{i(`icon://${K}`),l(!1)},className:Y("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===K?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:Ao(K),children:r.jsx(H,{size:16})},K):null},e[37]=f,e[38]=i,e[39]=F):F=e[39],V=_.map(F),e[2]=n,e[3]=f,e[4]=o,e[5]=i,e[6]=a,e[7]=c,e[8]=s,e[9]=m,e[10]=p,e[11]=g,e[12]=_,e[13]=b,e[14]=x,e[15]=v,e[16]=y,e[17]=V,e[18]=C,e[19]=S,e[20]=w,e[21]=k,e[22]=T,e[23]=M}else m=e[9],p=e[10],g=e[11],_=e[12],b=e[13],x=e[14],v=e[15],y=e[16],V=e[17],C=e[18],S=e[19],w=e[20],k=e[21],T=e[22],M=e[23];let I;e[40]!==y||e[41]!==V?(I=r.jsx("div",{className:y,children:V}),e[40]=y,e[41]=V,e[42]=I):I=e[42];let E;e[43]!==_.length?(E=_.length===0&&r.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=_.length,e[44]=E):E=e[44];let N;e[45]!==m||e[46]!==I||e[47]!==E||e[48]!==C?(N=r.jsxs(m,{className:C,children:[I,E]}),e[45]=m,e[46]=I,e[47]=E,e[48]=C,e[49]=N):N=e[49];let A;e[50]!==N||e[51]!==S||e[52]!==w?(A=r.jsxs("div",{className:S,children:[w,N]}),e[50]=N,e[51]=S,e[52]=w,e[53]=A):A=e[53];let D;e[54]!==p||e[55]!==A||e[56]!==k||e[57]!==T||e[58]!==M?(D=r.jsx(p,{align:k,className:T,onOpenAutoFocus:M,children:A}),e[54]=p,e[55]=A,e[56]=k,e[57]=T,e[58]=M,e[59]=D):D=e[59];let L;return e[60]!==g||e[61]!==b||e[62]!==x||e[63]!==v||e[64]!==D?(L=r.jsxs(g,{open:b,onOpenChange:x,children:[v,D]}),e[60]=g,e[61]=b,e[62]=x,e[63]=v,e[64]=D,e[65]=L):L=e[65],L}function Fy(t){return t.preventDefault()}function rn(){const t=O.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(Ne,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function ro(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[r.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:r.jsx(wa,{className:"h-6 w-6 text-destructive"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),r.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function Uy(t){const e=O.c(23),{item:s,isSelected:i,onToggle:n,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let c;e[0]!==a||e[1]!==l?(c=Y("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==s.name?(d=r.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=d):d=e[4];let u;e[5]!==s.tags?(u=s.tags&&r.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=u):u=e[6];let h;e[7]!==d||e[8]!==u?(h=r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d,u]}),e[7]=d,e[8]=u,e[9]=h):h=e[9];let f;e[10]!==s.description?(f=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let m;e[12]!==h||e[13]!==f?(m=r.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[h,f]}),e[12]=h,e[13]=f,e[14]=m):m=e[14];let p;e[15]!==o||e[16]!==i||e[17]!==n?(p=r.jsx(kg,{checked:i,onCheckedChange:n,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=i,e[17]=n,e[18]=p):p=e[18];let g;return e[19]!==c||e[20]!==m||e[21]!==p?(g=r.jsxs("label",{className:c,children:[m,p]}),e[19]=c,e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function sl(t){const e=O.c(13),{items:s,selections:i,onToggle:n,emptyMessage:o,disabled:a}=t;let l,c,d;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==n||e[4]!==i){d=Symbol.for("react.early_return_sentinel");e:{const h=s.map(Hy);if(s.length===0){let f;e[8]!==o?(f=r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],d=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",c=s.map(f=>r.jsx(Uy,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>n(f.id,h),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=n,e[4]=i,e[5]=l,e[6]=c,e[7]=d}else l=e[5],c=e[6],d=e[7];if(d!==Symbol.for("react.early_return_sentinel"))return d;let u;return e[10]!==l||e[11]!==c?(u=r.jsx("div",{className:l,children:c}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function Hy(t){return t.id}function Wy(t){const e=O.c(12),{connectionId:s,selections:i,onToggle:n,disabled:o}=t,{org:a}=_e();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const c=Ae(l);let d;e[3]!==c?(d={client:c},e[3]=c,e[4]=d):d=e[4];const{data:u}=Jp(d);let h;e[5]!==u.tools?(h=u.tools.map(Ky),e[5]=u.tools,e[6]=h):h=e[6];const f=h;let m;return e[7]!==o||e[8]!==f||e[9]!==n||e[10]!==i?(m=r.jsx(sl,{items:f,selections:i,onToggle:n,emptyMessage:"No tools available",disabled:o}),e[7]=o,e[8]=f,e[9]=n,e[10]=i,e[11]=m):m=e[11],m}function Ky(t){return{id:t.name,name:t.name,description:t.description,tags:r.jsx(wg,{annotations:t.annotations,_meta:t._meta})}}function qy(t){const e=O.c(12),{connectionId:s,selections:i,onToggle:n,disabled:o}=t,{org:a}=_e();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const c=Ae(l);let d;e[3]!==c?(d={client:c},e[3]=c,e[4]=d):d=e[4];const{data:u}=Ep(d);let h;e[5]!==u.resources?(h=u.resources.map(Gy),e[5]=u.resources,e[6]=h):h=e[6];const f=h;let m;return e[7]!==o||e[8]!==f||e[9]!==n||e[10]!==i?(m=r.jsx(sl,{items:f,selections:i,onToggle:n,emptyMessage:"No resources available",disabled:o}),e[7]=o,e[8]=f,e[9]=n,e[10]=i,e[11]=m):m=e[11],m}function Gy(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Yy(t){const e=O.c(12),{connectionId:s,selections:i,onToggle:n,disabled:o}=t,{org:a}=_e();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const c=Ae(l);let d;e[3]!==c?(d={client:c},e[3]=c,e[4]=d):d=e[4];const{data:u}=Td(d);let h;e[5]!==u.prompts?(h=u.prompts.map(Xy),e[5]=u.prompts,e[6]=h):h=e[6];const f=h;let m;return e[7]!==o||e[8]!==f||e[9]!==n||e[10]!==i?(m=r.jsx(sl,{items:f,selections:i,onToggle:n,emptyMessage:"No prompts available",disabled:o}),e[7]=o,e[8]=f,e[9]=n,e[10]=i,e[11]=m):m=e[11],m}function Xy(t){return{id:t.name,name:t.name,description:t.description}}function Jy(t){const e=O.c(54),{currentConnection:s,activeTab:i,selectedId:n,formData:o,toggleTool:a,toggleResource:l,togglePrompt:c,toggleAllTools:d,toggleAllResources:u,toggleAllPrompts:h,onTabChange:f}=t,m=o[n],p=i==="tools"?m?.tools===null:i==="resources"?m?.resources===null:m?.prompts===null;let g;e[0]!==i||e[1]!==n||e[2]!==h||e[3]!==u||e[4]!==d?(g=()=>{i==="tools"?d(n):i==="resources"?u(n):h(n)},e[0]=i,e[1]=n,e[2]=h,e[3]=u,e[4]=d,e[5]=g):g=e[5];const _=g;let b;e[6]!==s.icon||e[7]!==s.title?(b=r.jsx(ps,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=b):b=e[8];let x;e[9]!==s.title?(x=r.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=x):x=e[10];let v;e[11]!==s.description?(v=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=v):v=e[12];let y;e[13]!==x||e[14]!==v?(y=r.jsxs("div",{className:"flex-1 min-w-0",children:[x,v]}),e[13]=x,e[14]=v,e[15]=y):y=e[15];let V;e[16]!==b||e[17]!==y?(V=r.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-3",children:[b,y]})}),e[16]=b,e[17]=y,e[18]=V):V=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=C):C=e[19];let S;e[20]!==f?(S=L=>f(L),e[20]=f,e[21]=S):S=e[21];let w;e[22]!==i||e[23]!==S?(w=r.jsx(ch,{tabs:C,activeTab:i,onTabChange:S}),e[22]=i,e[23]=S,e[24]=w):w=e[24];const k=p?"Deselect all":"Select all";let T;e[25]!==_||e[26]!==k?(T=r.jsx("button",{type:"button",onClick:_,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:k}),e[25]=_,e[26]=k,e[27]=T):T=e[27];let M;e[28]!==T||e[29]!==w?(M=r.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[w,T]}),e[28]=T,e[29]=w,e[30]=M):M=e[30];let I;e[31]!==i||e[32]!==o||e[33]!==n||e[34]!==a?(I=i==="tools"&&r.jsx(ls,{fallback:ro("Tools not supported by this server"),children:r.jsx(j.Suspense,{fallback:r.jsx(rn,{}),children:r.jsx(Wy,{connectionId:n,selections:o[n]?o[n].tools:[],onToggle:(L,R)=>a(n,L,R)})})}),e[31]=i,e[32]=o,e[33]=n,e[34]=a,e[35]=I):I=e[35];let E;e[36]!==i||e[37]!==o||e[38]!==n||e[39]!==l?(E=i==="resources"&&r.jsx(ls,{fallback:ro("Resources not supported by this server"),children:r.jsx(j.Suspense,{fallback:r.jsx(rn,{}),children:r.jsx(qy,{connectionId:n,selections:o[n]?o[n].resources:[],onToggle:(L,R)=>l(n,L,R)})})}),e[36]=i,e[37]=o,e[38]=n,e[39]=l,e[40]=E):E=e[40];let N;e[41]!==i||e[42]!==o||e[43]!==n||e[44]!==c?(N=i==="prompts"&&r.jsx(ls,{fallback:ro("Prompts not supported by this server"),children:r.jsx(j.Suspense,{fallback:r.jsx(rn,{}),children:r.jsx(Yy,{connectionId:n,selections:o[n]?o[n].prompts:[],onToggle:(L,R)=>c(n,L,R)})})}),e[41]=i,e[42]=o,e[43]=n,e[44]=c,e[45]=N):N=e[45];let A;e[46]!==I||e[47]!==E||e[48]!==N?(A=r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[I,E,N]}),e[46]=I,e[47]=E,e[48]=N,e[49]=A):A=e[49];let D;return e[50]!==M||e[51]!==A||e[52]!==V?(D=r.jsxs(r.Fragment,{children:[V,M,A]}),e[50]=M,e[51]=A,e[52]=V,e[53]=D):D=e[53],D}function Qy(t){const e=O.c(11),{connectionId:s,onAuthenticate:i,children:n}=t;let o;e[0]!==s?(o={connectionId:s},e[0]=s,e[1]=o):o=e[1];const a=Ch(o);if(a.supportsOAuth&&!a.isAuthenticated){let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:r.jsx(op,{size:22,className:"text-muted-foreground"})}),e[2]=d):d=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),r.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=u):u=e[3];let h;e[4]!==s||e[5]!==i?(h=i&&r.jsx(oe,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=h):h=e[6];let f;return e[7]!==h?(f=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[d,u,h]}),e[7]=h,e[8]=f):f=e[8],f}let c;return e[9]!==n?(c=r.jsx(r.Fragment,{children:n}),e[9]=n,e[10]=c):c=e[10],c}function Zy(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function uc(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function e2(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function t2(t){const e=O.c(49),{open:s,onOpenChange:i,selectedId:n,form:o,connections:a,onAuthenticate:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activeTab:"tools"},e[0]=c):c=e[0];const[d,u]=j.useReducer(e2,c),h=Ba(n??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=Zy(f),e[3]=f,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==p?(g=(z,q,F,K)=>{const H=p[z]?.[q];let U;H===null?U=K.filter(W=>W!==F):H?.includes(F)?U=H.filter(W=>W!==F):(U=[...H??[],F],U.length===K.length&&(U=null));const X={...p};X[z]?X[z]={...X[z]}:X[z]={tools:null,resources:null,prompts:null},X[z][q]=U,o.setValue("connections",uc(X),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=g):g=e[7];const _=g;let b;e[8]!==o||e[9]!==p?(b=(z,q)=>{const K=p[z]?.[q]===null?[]:null,H={...p};H[z]?H[z]={...H[z]}:H[z]={tools:null,resources:null,prompts:null},H[z][q]=K,o.setValue("connections",uc(H),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=b):b=e[10];const x=b;let v;e[11]!==_?(v=(z,q,F)=>_(z,"tools",q,F),e[11]=_,e[12]=v):v=e[12];const y=v;let V;e[13]!==_?(V=(z,q,F)=>_(z,"resources",q,F),e[13]=_,e[14]=V):V=e[14];const C=V;let S;e[15]!==_?(S=(z,q,F)=>_(z,"prompts",q,F),e[15]=_,e[16]=S):S=e[16];const w=S;let k;e[17]!==x?(k=z=>x(z,"tools"),e[17]=x,e[18]=k):k=e[18];const T=k;let M;e[19]!==x?(M=z=>x(z,"resources"),e[19]=x,e[20]=M):M=e[20];const I=M;let E;e[21]!==x?(E=z=>x(z,"prompts"),e[21]=x,e[22]=E):E=e[22];const N=E;if(!n||!h)return null;let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(rn,{}),e[23]=A):A=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=z=>u({type:"SET_ACTIVE_TAB",payload:z}),e[24]=D):D=e[24];let L;e[25]!==h||e[26]!==d.activeTab||e[27]!==p||e[28]!==n||e[29]!==N||e[30]!==I||e[31]!==T||e[32]!==w||e[33]!==C||e[34]!==y?(L=r.jsx(Jy,{currentConnection:h,activeTab:d.activeTab,selectedId:n,formData:p,toggleTool:y,toggleResource:C,togglePrompt:w,toggleAllTools:T,toggleAllResources:I,toggleAllPrompts:N,onTabChange:D},n),e[25]=h,e[26]=d.activeTab,e[27]=p,e[28]=n,e[29]=N,e[30]=I,e[31]=T,e[32]=w,e[33]=C,e[34]=y,e[35]=L):L=e[35];let R;e[36]!==l||e[37]!==n||e[38]!==L?(R=r.jsx(j.Suspense,{fallback:A,children:r.jsx(Qy,{connectionId:n,onAuthenticate:l,children:L})}),e[36]=l,e[37]=n,e[38]=L,e[39]=R):R=e[39];let P;e[40]!==i?(P=r.jsx(Na,{className:"px-6 py-4 border-t border-border shrink-0",children:r.jsx(oe,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=P):P=e[41];let B;e[42]!==R||e[43]!==P?(B=r.jsxs(Ot,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[R,P]}),e[42]=R,e[43]=P,e[44]=B):B=e[44];let $;return e[45]!==i||e[46]!==s||e[47]!==B?($=r.jsx(Bt,{open:s,onOpenChange:i,children:B}),e[45]=i,e[46]=s,e[47]=B,e[48]=$):$=e[48],$}const no={tools:null,resources:null,prompts:null},s2=cm.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function i2(t){const s=new TextEncoder().encode(t),i=Array.from(s,n=>String.fromCharCode(n)).join("");return btoa(i)}function r2(t){const e=O.c(11),{url:s,agentId:i}=t,[n,o]=j.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{re("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),ue.success("Agent URL copied to clipboard"),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let c;e[3]!==n?(c=n?r.jsx(Mt,{size:20,className:"text-green-600"}):r.jsx(Si,{size:20}),e[3]=n,e[4]=c):c=e[4];const d=n?"Copied!":"Copy URL";let u;e[5]!==d?(u=r.jsx("span",{className:"text-xs font-medium",children:d}),e[5]=d,e[6]=u):u=e[6];let h;return e[7]!==l||e[8]!==c||e[9]!==u?(h=r.jsxs(oe,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,u]}),e[7]=l,e[8]=c,e[9]=u,e[10]=h):h=e[10],h}function n2(t){const e=O.c(8),{url:s,serverName:i,agentId:n}=t;let o;e[0]!==n||e[1]!==i||e[2]!==s?(o=()=>{re("agent_connect_action",{agent_id:n,action:"install_cursor"});const u=oh(i),f=i2(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(f)}`;window.open(m,"_blank"),ue.success("Opening Cursor...")},e[0]=n,e[1]=i,e[2]=s,e[3]=o):o=e[3];const a=o;let l,c;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),c=r.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=c):(l=e[4],c=e[5]);let d;return e[6]!==a?(d=r.jsxs(oe,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,c]}),e[6]=a,e[7]=d):d=e[7],d}function o2(t){const e=O.c(12),{url:s,serverName:i,agentId:n}=t,[o,a]=j.useState(!1);let l;e[0]!==n||e[1]!==i||e[2]!==s?(l=async()=>{re("agent_connect_action",{agent_id:n,action:"install_claude_code"});const m=oh(i),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),_=`claude mcp add-json "${m}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(_),a(!0),ue.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=n,e[1]=i,e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==o?(d=o?r.jsx(Mt,{size:20,className:"text-green-600"}):r.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=o,e[5]=d):d=e[5];const u=o?"Copied!":"Install on Claude Code";let h;e[6]!==u?(h=r.jsx("span",{className:"text-xs font-medium",children:u}),e[6]=u,e[7]=h):h=e[7];let f;return e[8]!==c||e[9]!==d||e[10]!==h?(f=r.jsxs(oe,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,h]}),e[8]=c,e[9]=d,e[10]=h,e[11]=f):f=e[11],f}function a2({virtualMcp:t}){const{org:e}=_e(),s=Ae({connectionId:yt,orgId:e.id}),[i,n]=j.useState(null),[o,a]=j.useState(!1),[l,c]=j.useState(!1),d=t.id,u=t.title||`agent-${d.slice(0,8)}`,h=i?`bunx @decocms/typegen@latest --mcp ${d} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${d} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const g=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${u}`,permissions:{[d]:["*"]}}})).structuredContent?.key;if(!g)throw new Error("No key in response");n(g),re("agent_typegen_key_generated",{agent_id:d})}catch{re("agent_typegen_key_failed",{agent_id:d}),ue.error("Failed to generate API key")}finally{a(!1)}},m=async()=>{re("agent_connect_action",{agent_id:d,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(h),c(!0),ue.success("Command copied to clipboard"),setTimeout(()=>c(!1),2e3)};return r.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",r.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&r.jsxs(oe,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?r.jsx(Ne,{size:14,className:"animate-spin"}):r.jsx(Cg,{size:14}),r.jsx("span",{children:o?"Generating…":"Generate API key"})]})]}),i&&r.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:h}),r.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?r.jsx(Mt,{size:12,className:"text-green-600"}):r.jsx(Si,{size:12})})]})}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),r.jsx(l2,{apiKey:i,agentId:d})]})}function l2(t){const e=O.c(21),{apiKey:s,agentId:i}=t,[n,o]=j.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",c=`MESH_BASE_URL=${a}`,d=`${l}
|
|
549
549
|
${c}`;let u;e[0]!==i||e[1]!==s||e[2]!==d?(u=async()=>{re("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(d),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=d,e[3]=u):u=e[3];const h=u,f=!s;let m;e[4]!==f?(m=Y({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let p;e[6]!==l||e[7]!==m?(p=r.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let g,_;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx("br",{}),_=r.jsx("span",{children:c}),e[9]=g,e[10]=_):(g=e[9],_=e[10]);let b;e[11]!==p?(b=r.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,g,_]}),e[11]=p,e[12]=b):b=e[12];let x;e[13]!==n?(x=n?r.jsx(Mt,{size:12,className:"text-green-600"}):r.jsx(Si,{size:12}),e[13]=n,e[14]=x):x=e[14];let v;e[15]!==h||e[16]!==x?(v=r.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:h,children:x}),e[15]=h,e[16]=x,e[17]=v):v=e[17];let y;return e[18]!==b||e[19]!==v?(y=r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[b,v]})}),e[18]=b,e[19]=v,e[20]=y):y=e[20],y}function c2(t){const e=O.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx(j.Suspense,{fallback:i,children:r.jsx(a2,{virtualMcp:s})}),e[1]=s,e[2]=n):n=e[2],n}function d2(t){const e=O.c(37),{open:s,onOpenChange:i,virtualMcp:n}=t,o=`/mcp/virtual-mcp/${n.id}`;let a;e[0]!==o?(a=new URL(o,window.location.origin),e[0]=o,e[1]=a):a=e[1];const l=a;let c;e[2]!==n.id||e[3]!==n.title?(c=n.title||`agent-${n.id?.slice(0,8)??"default"}`,e[2]=n.id,e[3]=n.title,e[4]=c):c=e[4];const d=c,u=ms();let h;e[5]!==n.id||e[6]!==l.href?(h=r.jsx(r2,{url:l.href,agentId:n.id}),e[5]=n.id,e[6]=l.href,e[7]=h):h=e[7];let f,m;e[8]!==d||e[9]!==n.id||e[10]!==l.href?(f=r.jsx(n2,{url:l.href,serverName:d,agentId:n.id}),m=r.jsx(o2,{url:l.href,serverName:d,agentId:n.id}),e[8]=d,e[9]=n.id,e[10]=l.href,e[11]=f,e[12]=m):(f=e[11],m=e[12]);let p;e[13]!==h||e[14]!==f||e[15]!==m?(p=r.jsx("div",{className:"flex flex-col gap-3 pt-2",children:r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[h,f,m]})}),e[13]=h,e[14]=f,e[15]=m,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let _;e[18]!==n?(_=r.jsx(c2,{virtualMcp:n}),e[18]=n,e[19]=_):_=e[19];let b;e[20]!==p||e[21]!==_?(b=r.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,_]}),e[20]=p,e[21]=_,e[22]=b):b=e[22];const x=b;if(u){let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(si,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=C):C=e[23];let S;e[24]!==x?(S=r.jsx(ii,{children:r.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[C,x]})}),e[24]=x,e[25]=S):S=e[25];let w;return e[26]!==i||e[27]!==s||e[28]!==S?(w=r.jsx(ri,{open:s,onOpenChange:i,children:S}),e[26]=i,e[27]=s,e[28]=S,e[29]=w):w=e[29],w}let v;e[30]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Gt,{children:r.jsx(qt,{children:"Connect"})}),e[30]=v):v=e[30];let y;e[31]!==x?(y=r.jsxs(Ot,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[v,x]}),e[31]=x,e[32]=y):y=e[32];let V;return e[33]!==i||e[34]!==s||e[35]!==y?(V=r.jsx(Bt,{open:s,onOpenChange:i,children:y}),e[33]=i,e[34]=s,e[35]=y,e[36]=V):V=e[36],V}function h2(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function u2(t){const e=O.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:n,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}=t,d=Ba(s),{org:u}=_e();if(!d)return null;let h;e[0]!==d?(h=nh(d),e[0]=d,e[1]=h):h=e[1];const f=h;let m;e[2]!==s?(m=r.jsx(g2,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==d.app_name||e[5]!==d.connection_type||e[6]!==d.description||e[7]!==d.icon||e[8]!==d.title||e[9]!==s||e[10]!==a||e[11]!==c||e[12]!==n||e[13]!==o||e[14]!==l||e[15]!==u.slug||e[16]!==f||e[17]!==i?(p=r.jsx(p2,{connection_id:s,connectionTitle:d.title,connectionDescription:d.description,connectionIcon:d.icon,connectionType:d.connection_type,slug:f,orgSlug:u.slug,appName:d.app_name,usedConnectionIds:i,onOpenSettings:n,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}),e[4]=d.app_name,e[5]=d.connection_type,e[6]=d.description,e[7]=d.icon,e[8]=d.title,e[9]=s,e[10]=a,e[11]=c,e[12]=n,e[13]=o,e[14]=l,e[15]=u.slug,e[16]=f,e[17]=i,e[18]=p):p=e[18];let g;return e[19]!==m||e[20]!==p?(g=r.jsx(j.Suspense,{fallback:m,children:p}),e[19]=m,e[20]=p,e[21]=g):g=e[21],g}const fc="__new_instance__";async function f2(t,e){const s=t?.idToken??null;if(s){const n=mc(s);if(n)return n}const i=t?.userinfoEndpoint??null;if(i)try{const n=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){const o=await n.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return mc(e)}function mc(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function m2(t){const e=O.c(23),{appName:s,connectionId:i,usedConnectionIds:n,onSwitchInstance:o,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const c=yr(l);if(c.length<=1)return null;let d;e[2]!==i||e[3]!==a||e[4]!==o?(d=g=>{g===fc?a?.():o(i,g)},e[2]=i,e[3]=a,e[4]=o,e[5]=d):d=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Ms,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:r.jsx(Ds,{})}),e[6]=u):u=e[6];let h;if(e[7]!==i||e[8]!==c||e[9]!==n){let g;e[11]!==i||e[12]!==n?(g=_=>r.jsx(Nt,{value:_.id,className:"text-xs",disabled:_.id!==i&&n.has(_.id),children:_.title},_.id),e[11]=i,e[12]=n,e[13]=g):g=e[13],h=c.map(g),e[7]=i,e[8]=c,e[9]=n,e[10]=h}else h=e[10];let f;e[14]!==a?(f=a&&r.jsx(Nt,{value:fc,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let m;e[16]!==h||e[17]!==f?(m=r.jsxs(Ts,{children:[h,f]}),e[16]=h,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==i||e[20]!==d||e[21]!==m?(p=r.jsxs(Rs,{value:i,onValueChange:d,children:[u,m]}),e[19]=i,e[20]=d,e[21]=m,e[22]=p):p=e[22],p}function p2(t){const e=O.c(55),{connection_id:s,connectionTitle:i,connectionDescription:n,connectionIcon:o,connectionType:a,slug:l,orgSlug:c,appName:d,usedConnectionIds:u,onOpenSettings:h,onRemove:f,onAuthenticate:m,onSwitchInstance:p,onNewInstance:g}=t;let _;e[0]!==s?(_={connectionId:s},e[0]=s,e[1]=_):_=e[1];const b=Ch(_),v=!(a==="VIRTUAL")&&b.supportsOAuth&&!b.isAuthenticated,y=v?"border-destructive/50 bg-destructive/5":"border-border";let V;e[2]!==y?(V=Y("rounded-xl border overflow-hidden transition-colors",y),e[2]=y,e[3]=V):V=e[3];let C;e[4]!==c||e[5]!==l?(C={org:c,appSlug:l},e[4]=c,e[5]=l,e[6]=C):C=e[6];let S;e[7]!==o||e[8]!==i?(S=r.jsx(ps,{icon:o,name:i,size:"sm",className:"shrink-0"}),e[7]=o,e[8]=i,e[9]=S):S=e[9];let w;e[10]!==i?(w=r.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=w):w=e[11];let k;e[12]!==n||e[13]!==v?(k=v?r.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):n&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n}),e[12]=n,e[13]=v,e[14]=k):k=e[14];let T;e[15]!==w||e[16]!==k?(T=r.jsxs("div",{className:"flex-1 min-w-0",children:[w,k]}),e[15]=w,e[16]=k,e[17]=T):T=e[17];let M;e[18]!==s||e[19]!==v||e[20]!==m?(M=v?r.jsx(oe,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:K=>{K.preventDefault(),K.stopPropagation(),m(s)},children:"Authorize"}):r.jsxs(Ye,{delayDuration:0,children:[r.jsx(qe,{asChild:!0,children:r.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:r.jsx(kr,{size:16})})}),r.jsx(Ge,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=v,e[20]=m,e[21]=M):M=e[21];let I;e[22]!==C||e[23]!==S||e[24]!==T||e[25]!==M?(I=r.jsxs(Cd,{to:"/$org/settings/connections/$appSlug",params:C,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[S,T,M]}),e[22]=C,e[23]=S,e[24]=T,e[25]=M,e[26]=I):I=e[26];let E;e[27]!==d||e[28]!==s||e[29]!==g||e[30]!==p||e[31]!==u?(E=d&&r.jsx(m2,{appName:d,connectionId:s,usedConnectionIds:u,onSwitchInstance:p,onNewInstance:g}),e[27]=d,e[28]=s,e[29]=g,e[30]=p,e[31]=u,e[32]=E):E=e[32];let N;e[33]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(zd,{size:13}),e[33]=N):N=e[33];let A;e[34]!==h?(A=r.jsx(qe,{asChild:!0,children:r.jsx(oe,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,"aria-label":"Configure resources",children:N})}),e[34]=h,e[35]=A):A=e[35];let D;e[36]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Ge,{side:"bottom",children:"Configure resources"}),e[36]=D):D=e[36];let L;e[37]!==A?(L=r.jsxs(Ye,{delayDuration:0,children:[A,D]}),e[37]=A,e[38]=L):L=e[38];let R;e[39]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(Os,{size:13}),e[39]=R):R=e[39];let P;e[40]!==f?(P=r.jsx(qe,{asChild:!0,children:r.jsx(oe,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:R})}),e[40]=f,e[41]=P):P=e[41];let B;e[42]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsx(Ge,{side:"bottom",children:"Remove"}),e[42]=B):B=e[42];let $;e[43]!==P?($=r.jsxs(Ye,{delayDuration:0,children:[P,B]}),e[43]=P,e[44]=$):$=e[44];let z;e[45]!==L||e[46]!==$?(z=r.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[L,$]}),e[45]=L,e[46]=$,e[47]=z):z=e[47];let q;e[48]!==E||e[49]!==z?(q=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[E,z]}),e[48]=E,e[49]=z,e[50]=q):q=e[50];let F;return e[51]!==I||e[52]!==q||e[53]!==V?(F=r.jsxs("div",{className:V,children:[I,q]}),e[51]=I,e[52]=q,e[53]=V,e[54]=F):F=e[54],F}function g2(t){const e=O.c(17),{connection_id:s}=t,i=Ba(s);if(!i){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Vu,{}),e[0]=h):h=e[0],h}let n;e[1]!==i.icon||e[2]!==i.title?(n=r.jsx(ps,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=n):n=e[3];let o;e[4]!==i.title?(o=r.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=o):o=e[5];let a;e[6]!==i.description?(a=i.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==o||e[9]!==a?(l=r.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==n||e[12]!==l?(c=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[n,l]}),e[11]=n,e[12]=l,e[13]=c):c=e[13];let d;e[14]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:r.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=d):d=e[14];let u;return e[15]!==c?(u=r.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[c,d]}),e[15]=c,e[16]=u):u=e[16],u}function Vu(){const t=O.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),r.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,r.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:r.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function _2({virtualMcpId:t}){const{org:e}=_e(),s=Ae({connectionId:yt,orgId:e.id}),i=bt(),n=$t(t),o=(n?.connections??[]).map(P=>P.connection_id).sort(),{data:a}=ji({queryKey:Ze.projectConnectionDetails(t,o),enabled:o.length>0,queryFn:async()=>await Promise.all(o.map(async B=>{try{const $=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:B}}),{item:z}=Jn($),q=(z?.tools??[]).filter(F=>!!Ip(F._meta)).map(F=>({name:F.name,description:F.description}));return{fetchOk:!0,id:B,title:z?.title??B,icon:z?.icon??null,uiTools:q}}catch{return{fetchOk:!1,id:B,title:B,icon:null,uiTools:[]}}}))}),l=(a??[]).filter(P=>P.uiTools.length>0),c=new Set(Nm),d=n?.metadata?.ui,u=d?.pinnedViews??[],h=d?.layout?.defaultMainView??null,f=d?.layout?.chatDefaultOpen??!1,m=!h||h.type==="chat"?"chat":h.type==="instructions"||h.type==="connections"||h.type==="layout"?"settings":c.has(h.type)?h.type:`${h.type}:${h.id??""}:${h.toolName??""}`,[p,g]=j.useState(u),[_,b]=j.useState(m),[x,v]=j.useState(f),[y,V]=j.useState(!1),C=P=>{const[B,$,z]=P.split(":");return B?B==="chat"?{type:B}:c.has(B)?{type:B}:B==="ext-apps"&&$?{type:"ext-apps",id:$,toolName:z||void 0}:null:null},S=j.useRef(!1);if(a&&a.length>0&&!S.current){S.current=!0;const P=new Set((a??[]).filter(z=>z.fetchOk).map(z=>z.id)),B=new Set(l.flatMap(z=>z.uiTools.map(q=>`${z.id}:${q.name}`))),$=u.filter(z=>!P.has(z.connectionId)||B.has(`${z.connectionId}:${z.toolName}`));if($.length!==u.length){g($);let z=_;h?.type==="ext-apps"&&!$.some(q=>q.connectionId===h.id&&q.toolName===h.toolName)&&(z="chat",b(z)),s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:$,layout:{defaultMainView:C(z),chatDefaultOpen:x}}}).then(q=>{Jn(q),i.invalidateQueries({predicate:F=>Array.isArray(F.queryKey)&&F.queryKey.includes("collection")&&F.queryKey.includes("VIRTUAL_MCP")})}).catch(()=>{g(u),b(m)})}}const w=(P,B,$)=>{V(!0),(async()=>{try{const q=await s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:P,layout:{defaultMainView:C(B),chatDefaultOpen:$??x}}});Jn(q),i.invalidateQueries({predicate:F=>Array.isArray(F.queryKey)&&F.queryKey.includes("collection")&&F.queryKey.includes("VIRTUAL_MCP")}),ue.success("Layout updated")}catch(q){ue.error("Failed to update layout: "+(q instanceof Error?q.message:"Unknown error"))}finally{V(!1)}})()},k=(P,B)=>{const $=p.some(F=>F.connectionId===P&&F.toolName===B);let z,q=_;if($){z=p.filter(K=>!(K.connectionId===P&&K.toolName===B));const F=`ext-apps:${P}:${B}`;_===F&&(q="chat",b(q))}else z=[...p,{connectionId:P,toolName:B,label:ko(B),icon:null}];g(z),w(z,q)},T=(P,B,$)=>{g(z=>z.map(q=>q.connectionId===P&&q.toolName===B?{...q,label:$}:q))},M=()=>{w(p,_)},I=(P,B,$)=>{g(q=>q.map(F=>F.connectionId===P&&F.toolName===B?{...F,icon:$}:F));const z=p.map(q=>q.connectionId===P&&q.toolName===B?{...q,icon:$}:q);w(z,_)},E=P=>{b(P),w(p,P)},N=o.length===0,A=a&&l.length===0,D=!!bs(n),L=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];D&&(L.push({value:"env",label:"Terminal"}),L.push({value:"preview",label:"Preview"}));for(const P of p)L.push({value:`ext-apps:${P.connectionId}:${P.toolName}`,label:P.label||P.toolName});const R=l.length>0||N||A;return r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-3",children:r.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),r.jsxs(Vg,{className:"p-6 gap-5",children:[r.jsxs(Rl,{className:"p-0 space-y-5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(ir,{className:"font-normal text-foreground",children:"Main view"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),r.jsxs(Rs,{value:_,onValueChange:E,children:[r.jsx(Ms,{className:"w-44 h-8 text-sm capitalize shrink-0",children:r.jsx(Ds,{})}),r.jsx(Ts,{children:L.map(P=>r.jsx(Nt,{value:P.value,className:"capitalize",children:P.label},P.value))})]})]}),r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(ir,{className:"font-normal text-foreground",children:"Show chat"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),r.jsxs(Ye,{delayDuration:0,children:[r.jsx(qe,{asChild:!0,children:r.jsx("span",{className:"shrink-0",children:r.jsx(mn,{checked:_==="chat"?!0:x,disabled:_==="chat"||y,onCheckedChange:P=>{v(P),w(p,_,P)}})})}),_==="chat"&&r.jsx(Ge,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),R&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"border-t border-border -mx-6"}),r.jsxs(Rl,{className:"p-0 space-y-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-4",children:r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(ir,{className:"font-normal text-foreground",children:"Pinned views"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),N&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),A&&!N&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),l.length>0&&r.jsx("div",{className:"space-y-4 pt-1",children:l.map((P,B)=>r.jsxs("div",{children:[B>0&&r.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),r.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[r.jsx(ps,{icon:P.icon,name:P.title,size:"xs",className:"shrink-0"}),r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:P.title})]}),r.jsx("div",{className:"space-y-1.5",children:P.uiTools.map($=>{const z=p.some(F=>F.connectionId===P.id&&F.toolName===$.name),q=p.find(F=>F.connectionId===P.id&&F.toolName===$.name);return r.jsxs("div",{className:Y("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",z?"bg-accent/40 border-border":"bg-transparent border-border"),children:[r.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[r.jsx(zy,{value:q?.icon??null,onChange:F=>I(P.id,$.name,F),disabled:!z||y}),r.jsx(at,{value:z&&q?q.label:ko($.name),onChange:F=>T(P.id,$.name,F.target.value),onBlur:M,className:"h-7 text-sm w-40",disabled:!z||y,readOnly:!z})]}),r.jsx(mn,{checked:z,onCheckedChange:()=>k(P.id,$.name),disabled:y})]},$.name)})})]},P.id))})]})]})]})]})}function x2({virtualMcp:t,hideOwnTitle:e}){const{org:s}=_e(),i=Oa(),n=Mn(),o=bt(),a=Ae({connectionId:yt,orgId:s.id}),l=Ai({resolver:gr(s2),defaultValues:t}),c=l.watch("connections"),d=!!bs(t),[u,h]=j.useReducer(h2,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[f,m]=j.useState(!1),{createTaskWithMessage:p}=Lt(),{setChatMode:g}=$s(),{createNewTask:_}=xr(),b=()=>{const U=l.getValues("metadata.instructions");U?.trim()&&(T(),re("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:U.length}),g("plan"),p({virtualMcpId:Aa(s.id),message:{parts:[{type:"text",text:`/writing-prompts ${t.id}
|
|
550
550
|
|
|
551
551
|
<instructions>
|
|
@@ -732,4 +732,4 @@ ${te}
|
|
|
732
732
|
|
|
733
733
|
<message>
|
|
734
734
|
${he}
|
|
735
|
-
</message>`}]}}))},L=e.models?.credentialId||m||"",R=e.models?.thinking?.id||p?.modelId||"",P=Ai({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:R}}),B=P.watch("active"),$=P.watch("credential_id"),z=P.watch("model_id"),{models:q,isLoading:F}=eh($||void 0),K=q.find(le=>le.modelId===z)??null,H=j.useRef(null),U=j.useRef(new Set),X=j.useRef(0),W=j.useRef(null),G=3e4,se=()=>{W.current&&(clearTimeout(W.current),W.current=null),H.current!==null&&(re("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(U.current),save_count:X.current,edit_duration_ms:Date.now()-H.current}),H.current=null,U.current=new Set,X.current=0)},ee=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!A.current)return!0;const he=Object.keys(P.formState.dirtyFields),be=A.current;A.current=!1;const fe=P.getValues();try{const ye=fe.credential_id&&fe.model_id?fe.credential_id:"",ve=fe.credential_id&&fe.model_id?fe.model_id:"",Ve={id:t,name:fe.name,active:fe.active,agent:{id:o},models:{credentialId:ye,thinking:{id:ve}},messages:jd(v),temperature:0};await l.mutateAsync(Ve),H.current===null&&(H.current=Date.now());for(const Ie of he)U.current.add(Ie);return be&&U.current.add("messages"),X.current+=1,W.current&&clearTimeout(W.current),W.current=setTimeout(se,G),P.reset({...fe,credential_id:ye,model_id:ve}),!0}catch{return A.current=!0,!1}},J=()=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee()},1e3)},ae=async()=>(N.current&&clearTimeout(N.current),ee()),Z=le=>{if(y(le),!E.current){E.current=!0;return}A.current=!0,J()},de=j.useRef(!1);de.current||(de.current=!0,P.watch(()=>{J()}));const me=async()=>{re("automation_test_clicked",{automation_id:t,agent_id:o});const le=await ae();if(se(),!le)return;if(!v){ue.error("No instructions configured for this automation");return}K&&$&&f({...K,keyId:$}),b({..._,toolApprovalLevel:"auto"});const he=gl(v);h({message:{tiptapDoc:v,parts:he},virtualMcpId:o||void 0})};return r.jsxs(r.Fragment,{children:[i&&r.jsx("div",{className:"flex items-center pb-4 shrink-0",children:r.jsxs(oe,{variant:"ghost",size:"sm",onClick:i,children:[r.jsx(Pa,{size:14}),"Back to list"]})}),r.jsxs("div",{className:"flex flex-col gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(at,{...P.register("name"),placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}}),n&&r.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:r.jsx(Ro,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(pi,{control:P.control,name:"active",render:({field:le})=>r.jsx(mn,{checked:le.value,onCheckedChange:he=>{le.onChange(he),setTimeout(()=>ae(),0)},className:"cursor-pointer"})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:B?"Active":"Inactive"}),r.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),r.jsx(Ng,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),r.jsx(QC,{automationId:t,open:V,onOpenChange:C,onCustomSelect:()=>{w(!0),I(!1),T("")},onEventSelect:()=>{I(!0),w(!1)}})]}),e.triggers.length===0&&!S?r.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",r.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>C(!0),children:"Add a starter"})," ","to get going."]})}):r.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(le=>r.jsx(ZC,{trigger:le,automationId:t,connectionName:le.connection_id?u.get(le.connection_id):void 0},le.id))}),S&&r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[r.jsx(tr,{size:14,className:"text-muted-foreground shrink-0"}),r.jsx("input",{type:"text",value:k,onChange:le=>T(le.target.value),onBlur:async()=>{const le=k.trim();if(!(!le||!nr(le)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:le}),re("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ue.success("Starter added"),w(!1),T("")}catch{ue.error("Failed to add starter")}},onKeyDown:async le=>{const he=k.trim();le.key==="Enter"&&he&&nr(he)&&le.target.blur(),le.key==="Escape"&&(w(!1),T(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!nr(k)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&r.jsx(Ne,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),r.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),T("")},children:r.jsx(Os,{size:13})})]}),M&&r.jsx(j.Suspense,{fallback:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[r.jsx(Ne,{size:13,className:"animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:r.jsx(t3,{automationId:t,onDone:()=>I(!1)})})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!v,onClick:D,children:[r.jsx(Da,{size:13}),"Improve"]})]}),r.jsx(qh,{tiptapDoc:v,setTiptapDoc:Z,placeholder:"What should this automation do?",children:r.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[r.jsx(Gh,{virtualMcpId:o||null,className:"max-h-[45vh]"}),r.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[r.jsx(sh,{model:K,isLoading:F,credentialId:$||null,onCredentialChange:le=>{P.setValue("credential_id",le??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:le=>P.setValue("model_id",le.modelId,{shouldDirty:!0}),placeholder:"Model"}),r.jsxs(Ye,{children:[r.jsx(qe,{asChild:!0,children:r.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:me,disabled:!o,children:[r.jsx(Od,{size:16}),"Test"]})}),r.jsx(Ge,{children:"Test Automation"})]})]})]})})]})]})]})}function o3(t){const e=O.c(6),{tabId:s,virtualMcpId:i}=t;let n;e[0]!==s?(n=Ad(s),e[0]=s,e[1]=n):n=e[1];const o=n;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=r.jsx(Jt,{children:r.jsx(Jt.Content,{children:r.jsx(Jt.Body,{children:r.jsx(j.Suspense,{fallback:a,children:r.jsx(a3,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function a3(t){const e=O.c(9),{id:s,virtualMcpId:i}=t,n=Oe(),{data:o,isLoading:a}=Eg(s);let l;e[0]!==n?(l=()=>n({to:".",search:l3,replace:!0}),e[0]=n,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=r.jsx(n3,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function l3(t){return{...t,main:"automations"}}function c3(t){const e=O.c(20),{virtualMcpId:s}=t,i=Oe(),{data:n}=Ig(s),o=n===void 0?[]:n,{create:a}=jr(),[l,c]=j.useState(""),d=l.toLowerCase(),u=o.filter(T=>T.name.toLowerCase().includes(d));let h;e[0]!==i?(h=T=>i({to:".",search:M=>({...M,main:"automation:"+T}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const f=h,m=async()=>{if(a.isPending)return;re("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const T=await a.mutateAsync(Rg(s));f(T.id)},p=Jt,g=Jt,_=Jt;let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Jt.Title,{children:"Automations"}),e[2]=b):b=e[2];const x=o.length>0&&r.jsx(Mg,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Dt,{size:14}),e[3]=v):v=e[3];let y;e[4]!==a.isPending||e[5]!==m?(y=r.jsxs(oe,{size:"sm",onClick:m,disabled:a.isPending,children:[v,"New automation"]}),e[4]=a.isPending,e[5]=m,e[6]=y):y=e[6];let V;e[7]!==x||e[8]!==y?(V=r.jsxs("div",{className:"flex flex-col gap-6",children:[b,r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[x,y]})]}),e[7]=x,e[8]=y,e[9]=V):V=e[9];const C=o.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Vi,{image:r.jsx(Ci,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:r.jsxs(oe,{size:"sm",onClick:m,disabled:a.isPending,children:[r.jsx(Dt,{size:14}),"New automation"]})})}):u.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Vi,{image:r.jsx(Ci,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):r.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(T=>r.jsx(Tg,{automation:T,onClick:()=>f(T.id)},T.id))});let S;e[10]!==C||e[11]!==_.Body||e[12]!==V?(S=r.jsxs(_.Body,{children:[V,C]}),e[10]=C,e[11]=_.Body,e[12]=V,e[13]=S):S=e[13];let w;e[14]!==S||e[15]!==g.Content?(w=r.jsx(g.Content,{children:S}),e[14]=S,e[15]=g.Content,e[16]=w):w=e[16];let k;return e[17]!==p||e[18]!==w?(k=r.jsx(p,{children:w}),e[17]=p,e[18]=w,e[19]=k):k=e[19],k}function d3(t){const e=O.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx(j.Suspense,{fallback:i,children:r.jsx(c3,{virtualMcpId:s})}),e[1]=s,e[2]=n):n=e[2],n}const ud=j.lazy(()=>dm(()=>import("./project-app-view-DuFzKNXE.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55])).then(t=>({default:t.AppViewContent})));function h3(t){const e=O.c(44),{taskId:s,virtualMcpId:i}=t;let n;e[0]!==s||e[1]!==i?(n={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=n):n=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=wu(n);if(Im(o)){let p;return e[3]!==i?(p=r.jsx(pc,{virtualMcpId:i}),e[3]=i,e[4]=p):p=e[4],p}if(o==="git"){let p;return e[5]!==i?(p=r.jsx(J2,{virtualMcpId:i}),e[5]=i,e[6]=p):p=e[6],p}if(o==="automations"){let p;return e[7]!==i?(p=r.jsx(d3,{virtualMcpId:i}),e[7]=i,e[8]=p):p=e[8],p}if(o==="env"){let p;return e[9]!==i?(p=r.jsx(KC,{virtualMcpId:i}),e[9]=i,e[10]=p):p=e[10],p}if(o==="preview"){let p;return e[11]!==i?(p=r.jsx(NS,{virtualMcpId:i}),e[11]=i,e[12]=p):p=e[12],p}if(c){let p;return e[13]!==o||e[14]!==i?(p=r.jsx(o3,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=p):p=e[15],p}let d;e[16]!==o?(d=Tm(o),e[16]=o,e[17]=d):d=e[17];const u=d;if(u){let p;if(e[18]!==l||e[19]!==u.connectionId||e[20]!==u.toolName){let v;e[22]!==u.connectionId||e[23]!==u.toolName?(v=y=>y.appId===u.connectionId&&y.toolName===u.toolName,e[22]=u.connectionId,e[23]=u.toolName,e[24]=v):v=e[24],p=l.find(v),e[18]=l,e[19]=u.connectionId,e[20]=u.toolName,e[21]=p}else p=e[21];const g=p;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[25]=_):_=e[25];const b=g?.args;let x;return e[26]!==o||e[27]!==u.connectionId||e[28]!==u.toolName||e[29]!==b?(x=r.jsx(j.Suspense,{fallback:_,children:r.jsx(ud,{connectionId:u.connectionId,toolName:u.toolName,args:b},o)}),e[26]=o,e[27]=u.connectionId,e[28]=u.toolName,e[29]=b,e[30]=x):x=e[30],x}let h;if(e[31]!==o||e[32]!==a){let p;e[34]!==o?(p=g=>g.id===o,e[34]=o,e[35]=p):p=e[35],h=a.find(p),e[31]=o,e[32]=a,e[33]=h}else h=e[33];const f=h;if(f){let p;e[36]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[36]=p):p=e[36];let g;return e[37]!==o||e[38]!==f.id||e[39]!==f.view.appId||e[40]!==f.view.args?(g=r.jsx(j.Suspense,{fallback:p,children:r.jsx(ud,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},o)}),e[37]=o,e[38]=f.id,e[39]=f.view.appId,e[40]=f.view.args,e[41]=g):g=e[41],g}let m;return e[42]!==i?(m=r.jsx(pc,{virtualMcpId:i}),e[42]=i,e[43]=m):m=e[43],m}function u3(t){const e=O.c(7),{children:s,defaultSize:i}=t,[,n]=j.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ca.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=Va(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=f=>n(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=r.jsx(ih,{defaultSize:c,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=c,e[5]=u,e[6]=h):h=e[6],h}function f3(t){const e=O.c(31),{virtualMcpId:s,taskId:i,chatOpen:n,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==n||e[1]!==o?(c=dc(n,o),e[0]=n,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=Ca.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=Va(u,45),f=j.useRef(null);let m,p;e[4]!==n||e[5]!==o||e[6]!==h?(m=()=>{const M=f.current;if(!M)return;const I=dc(n,o),E=I.chat>0&&I.chat<100?h:I.chat,N=I.chat>0&&I.chat<100?100-h:I.main;M.setLayout([E,N])},p=[n,o,h],e[4]=n,e[5]=o,e[6]=h,e[7]=m,e[8]=p):(m=e[7],p=e[8]),j.useEffect(m,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let b;e[10]!==l||e[11]!==a?(b=l??r.jsx(Zh,{variant:a}),e[10]=l,e[11]=a,e[12]=b):b=e[12];let x;e[13]!==b?(x=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:b})}),e[13]=b,e[14]=x):x=e[14];let v;e[15]!==d.chat||e[16]!==x?(v=r.jsx(u3,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=v):v=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Np,{className:"bg-sidebar"}),e[18]=y):y=e[18];const V=d.main;let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C={overflow:"visible"},e[19]=C):C=e[19];let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=Y("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[20]=S):S=e[20];let w;e[21]!==i||e[22]!==s?(w=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:S,children:r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(h3,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=w):w=e[23];let k;e[24]!==d.main||e[25]!==w?(k=r.jsx(ih,{className:"min-w-0 flex flex-col",order:2,defaultSize:V,style:C,collapsible:!0,collapsedSize:0,minSize:20,children:w}),e[24]=d.main,e[25]=w,e[26]=k):k=e[26];let T;return e[27]!==k||e[28]!==g||e[29]!==v?(T=r.jsxs(Ap,{ref:f,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[v,y,k]},g),e[27]=k,e[28]=g,e[29]=v,e[30]=T):T=e[30],T}const wo="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",fd="bg-sidebar-accent text-sidebar-foreground",Vo="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function m3(t){const e=O.c(38),{isDecopilot:s,chatOpen:i,toggleChat:n,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=yu(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{re("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?fd:Vo;let h;e[3]!==u?(h=Y(wo,u),e[3]=u,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(hp,{size:16}),e[5]=f):f=e[5];let m;e[6]!==d||e[7]!==h||e[8]!==a?(m=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:f})}),e[6]=d,e[7]=h,e[8]=a,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Ge,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==m?(g=r.jsxs(Ye,{delayDuration:300,children:[m,p]}),e[11]=m,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==n?(_=!s&&r.jsxs(Ye,{delayDuration:300,children:[r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",onClick:()=>{re("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),n()},"aria-pressed":i,className:Y(wo,i?fd:Vo),children:r.jsx(dp,{size:16})})}),r.jsx(Ge,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=n,e[16]=_):_=e[16];const b=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==b?(x=Y("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",b),e[17]=b,e[18]=x):x=e[18];const v=!c,y=c?0:-1,V=!c,C=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let S;e[19]!==C?(S=Y(wo,Vo,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",C),e[19]=C,e[20]=S):S=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Ra,{size:16}),e[21]=w):w=e[21];let k;e[22]!==o||e[23]!==v||e[24]!==y||e[25]!==V||e[26]!==S?(k=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",onClick:o,disabled:v,tabIndex:y,"aria-hidden":V,className:S,children:w})}),e[22]=o,e[23]=v,e[24]=y,e[25]=V,e[26]=S,e[27]=k):k=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Ge,{side:"bottom",children:"New task"}),e[28]=T):T=e[28];let M;e[29]!==k?(M=r.jsx("div",{className:"overflow-hidden",children:r.jsxs(Ye,{delayDuration:300,children:[k,T]})}),e[29]=k,e[30]=M):M=e[30];let I;e[31]!==x||e[32]!==M?(I=r.jsx("div",{className:x,children:M}),e[31]=x,e[32]=M,e[33]=I):I=e[33];let E;return e[34]!==I||e[35]!==g||e[36]!==_?(E=r.jsxs(r.Fragment,{children:[g,_,I]}),e[34]=I,e[35]=g,e[36]=_,e[37]=E):E=e[37],E}function p3(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),n=t.slice(s);if(e==null)return{visible:i,overflow:n};if(i.some(h=>h.id===e))return{visible:i,overflow:n};const a=n.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:n};const l=i[i.length-1],c=n[a],d=[...i.slice(0,-1),c],u=[l,...n.slice(0,a),...n.slice(a+1)];return{visible:d,overflow:u}}function g3(t){const e=O.c(13),{title:s,icon:i,active:n,onClick:o}=t,a=n?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=Y("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==i?(c=r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(_3,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=r.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==n||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=r.jsxs("button",{type:"button",onClick:o,"aria-pressed":n,"aria-label":s,className:l,children:[c,d]}),e[6]=n,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function _3(t){const e=O.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Gd,{className:"size-4"}),e[4]=i):i=e[4],i}function x3(t){const e=O.c(13),{overflow:s,onSelect:i}=t,[n,o]=j.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(zs,{asChild:!0,children:r.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:r.jsx(Wd,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(v3,{icon:m.icon})}),r.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=r.jsx(Fs,{align:"end",className:"w-56 p-1",children:r.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==n||e[11]!==u?(h=r.jsxs(Us,{open:n,onOpenChange:o,children:[c,u]}),e[10]=n,e[11]=u,e[12]=h):h=e[12],h}function v3(t){const e=O.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Gd,{className:"size-4"}),e[4]=i):i=e[4],i}const b3=6;function y3(t){const e=O.c(20),{virtualMcpId:s,taskId:i}=t,n=Oe();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=wu(o);let u,h,f,m;if(e[3]!==l||e[4]!==c||e[5]!==n||e[6]!==d||e[7]!==a||e[8]!==s){const _=Rm({activeTab:l,mainOpen:c}),b=C=>C.id==="automations"?_:c&&C.id===l,v=a.find(C=>b(C))?.id??null,{visible:y,overflow:V}=p3(a,v,b3);h=V,u=C=>{const S=a.find(k=>k.id===C),w=v===C&&c;if(re("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:C,tab_kind:S?.kind??null,was_active:w}),C==="automations"){const k=Mm({activeTab:l,mainOpen:c});n({to:".",search:T=>({...T,main:k}),replace:!0});return}d(C)},f="flex items-center min-w-0 ml-auto gap-0.5",m=y.map(C=>r.jsx(g3,{title:C.title,icon:C.icon,active:b(C),onClick:()=>u(C.id)},C.id)),e[3]=l,e[4]=c,e[5]=n,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=f,e[12]=m}else u=e[9],h=e[10],f=e[11],m=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&r.jsx(x3,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=r.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}function S3(t){const e=O.c(12);let s,i,n,o;e[0]!==t?({className:s,orientation:n,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=o):(s=e[1],i=e[2],n=e[3],o=e[4]);const a=n===void 0?"horizontal":n,l=o===void 0?!0:o;let c;e[5]!==s?(c=Y("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=r.jsx(hm,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function w3(t){const e=O.c(20),{prNumber:s,disabled:i,send:n}=t;let o;e[0]!==s||e[1]!==n?(o=()=>n($2({prNumber:s})),e[0]=s,e[1]=n,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==n?(l=()=>n(B2({prNumber:s})),e[3]=s,e[4]=n,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=r.jsx(oe,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(cr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=r.jsx(ds,{asChild:!0,children:r.jsx(oe,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let f;e[12]!==c?(f=r.jsx(hs,{align:"end",children:r.jsx(Qe,{onClick:c,children:"Review"})}),e[12]=c,e[13]=f):f=e[13];let m;e[14]!==h||e[15]!==f?(m=r.jsxs(cs,{children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=r.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,m]}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}const V3=new Set(["failure","timed_out","cancelled","action_required"]);function C3(t){return t.status==="completed"&&V3.has(t.conclusion)}function k3(t){return t.status==="queued"||t.status==="in_progress"}function j3(t){const{branchStatus:e,pr:s,checks:i,reviews:n}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((n?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(C3).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(k3)?{label:"Running tests…",disabled:!0}:n?.draft?{label:"Mark ready",action:"mark-ready"}:(n?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:n?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function N3(){return Ti().branchStatus}const A3=6e4,E3=3e4;function I3(t){const e=O.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Ae(s),n=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==n?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:n},e[3]=t.owner,e[4]=t.repo,e[5]=n,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:A3,refetchIntervalInBackground:!1,staleTime:E3,select:T3},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],ni(l)}function T3(t){const e=Nr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),n=Number(e.review_comments??0),o=s==="blocked"&&n>0?n:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function R3(t){const e=O.c(38),{virtualMcpId:s}=t,{org:i}=_e(),n=$t(s),{currentBranch:o}=Lt(),a=Cn(),l=n?.metadata?.githubRepo??null,c=N3(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",f=o??null;let m;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==f?(m={orgId:i.id,connectionId:d,owner:u,repo:h,branch:f},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=f,e[5]=m):m=e[5];const g=Cu(m).data??null,_=l?.connectionId??"",b=l?.owner??"",x=l?.name??"",v=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==b||e[9]!==x||e[10]!==v?(y={orgId:i.id,connectionId:_,owner:b,repo:x,prNumber:v},e[6]=i.id,e[7]=_,e[8]=b,e[9]=x,e[10]=v,e[11]=y):y=e[11];const V=ju(y),C=l?.connectionId??"",S=l?.owner??"",w=l?.name??"",k=g&&g.state==="open"?g.number:null;let T;e[12]!==i.id||e[13]!==C||e[14]!==S||e[15]!==w||e[16]!==k?(T={orgId:i.id,connectionId:C,owner:S,repo:w,prNumber:k},e[12]=i.id,e[13]=C,e[14]=S,e[15]=w,e[16]=k,e[17]=T):T=e[17];const M=I3(T);if(!l?.connectionId||!o)return null;let I;e[18]!==c||e[19]!==V.data||e[20]!==g||e[21]!==M.data?(I=j3({branchStatus:c,pr:g,checks:V.data??[],reviews:M.data??null}),e[18]=c,e[19]=V.data,e[20]=g,e[21]=M.data,e[22]=I):I=e[22];const E=I;if(!E)return null;let N;e[23]!==a?(N=z=>a.sendMessage({parts:[{type:"text",text:z}]}),e[23]=a,e[24]=N):N=e[24];const A=N,D=a.isStreaming;let L;e[25]!==o||e[26]!==E||e[27]!==D||e[28]!==g||e[29]!==A?(L=z=>{if(!D)switch(z){case"commit-and-push":{A(I2({branch:o}));return}case"create-pr":{A(T2({branch:o}));return}case"reopen":{g&&A(R2({prNumber:g.number}));return}case"rebase":{A(M2({branch:o}));return}case"fix-checks":{g&&A(P2({prNumber:g.number,failingChecks:E.meta?.failingChecks??[]}));return}case"mark-ready":{g&&A(L2({prNumber:g.number}));return}case"resolve-comments":{g&&A(O2({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=E,e[27]=D,e[28]=g,e[29]=A,e[30]=L):L=e[30];const R=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(S3,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const B=g?.number;let $;return e[32]!==E||e[33]!==D||e[34]!==R||e[35]!==A||e[36]!==B?($=r.jsxs(r.Fragment,{children:[P,r.jsx(M3,{button:E,isStreaming:D,onActivate:R,prNumber:B,send:A})]}),e[32]=E,e[33]=D,e[34]=R,e[35]=A,e[36]=B,e[37]=$):$=e[37],$}function M3(t){const e=O.c(18),{button:s,isStreaming:i}=t,n=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==n||e[1]!==t.prNumber||e[2]!==t.send?(u=r.jsx(w3,{prNumber:t.prNumber,disabled:n,send:t.send}),e[0]=n,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let h;return e[4]!==u||e[5]!==o?(h=r.jsx(md,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==n||e[12]!==a||e[13]!==l?(c=r.jsx(oe,{size:"sm",variant:a,disabled:n,onClick:l,children:s.label}),e[10]=s.label,e[11]=n,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=r.jsx(md,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function md(t){const e=O.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=r.jsx(r.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let n;e[2]!==i?(n=r.jsx(qe,{asChild:!0,children:r.jsx("span",{children:i})}),e[2]=i,e[3]=n):n=e[3];let o;e[4]!==s?(o=r.jsx(Ge,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==o?(a=r.jsx(bi,{children:r.jsxs(Ye,{children:[n,o]})}),e[6]=n,e[7]=o,e[8]=a):a=e[8],a}function D3(t){const e=O.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=r.jsx(Re.Right,{children:r.jsx(R3,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const _i=j.createContext(null);function ml(){return j.use(_i)}function pd(t){const e=O.c(8),{children:s,variant:i}=t,{taskId:n}=Lt();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Ee.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??r.jsx(Zh,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==n?(c=r.jsx(ls,{fallback:o,children:r.jsx(j.Suspense,{fallback:a,children:r.jsx(Ee.ActiveTaskProvider,{taskId:n,children:l})})}),e[5]=l,e[6]=n,e[7]=c):c=e[7],c}function gd(t){const e=O.c(3),{onNewTaskRef:s,createNewTask:i}=t;let n;return e[0]!==i||e[1]!==s?(n=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=n):n=e[2],j.useLayoutEffect(n),null}function P3(t){const e=O.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(mp,{size:20}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:r.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=n):n=e[2],n}function _d(t){const e=O.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:n,children:o}=t,{org:a}=_e(),{currentBranch:l}=Lt(),{data:c}=dt.useSession(),d=c?.user?.id,u=d&&l?n?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const f=h;let m;e[2]!==a.id?(m={connectionId:yt,orgId:a.id},e[2]=a.id,e[3]=m):m=e[3];const p=Ae(m),{mutate:g}=el(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const b=j.useRef(_);let x,v;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==n?(x=()=>{i&&d&&l&&(n?.[d]?.[l]||b.current.has(l)||(b.current.add(l),g({virtualMcpId:s,branch:l},{onError:L3})))},v=[i,d,l,n,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=n,e[11]=x,e[12]=v):(x=e[11],v=e[12]),j.useEffect(x,v);let y;return e[13]!==o||e[14]!==f?(y=r.jsx(uS,{daemonBaseUrl:f,children:o}),e[13]=o,e[14]=f,e[15]=y):y=e[15],y}function L3(t){console.error("[auto-start-vm] failed:",t)}function xd(){const t=O.c(106),e=ms(),s=Oe(),{org:i}=_e(),n=fy()?.tasksOpen??!1;Sg(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=_r(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=ti(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??En(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let f;t[5]!==i.id?(f=Aa(i.id),t[5]=i.id,t[6]=f):f=t[6];const m=h===f,p=!m,g=Lg(a.taskId??"",h),_=$t(h),b=_?.metadata?.ui?.layout??null;let x;t[7]!==b?(x=b?{defaultMainView:b.defaultMainView??null,chatDefaultOpen:b.chatDefaultOpen??null}:null,t[7]=b,t[8]=x):x=t[8];const v=x;let y;t[9]!==_?(y=_&&bs(_),t[9]=_,t[10]=y):y=t[10];const V=!!y;let C;t[11]!==p||t[12]!==l||t[13]!==h?(C={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=C):C=t[14];const S=dy(v,C),{setOpenMobile:w,openMobile:k}=Cr(),T=w,M=j.useRef(null);let I,E;t[15]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const W=G=>{Md(G)&&G.shiftKey&&G.code==="KeyS"&&!G.repeat&&(G.preventDefault(),M.current?.())};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},E=[],t[15]=I,t[16]=E):(I=t[15],E=t[16]),j.useEffect(I,E);const N=h;let A;t[17]!==_||t[18]!==h?(A={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=A):A=t[19];const D=A;if(g.status==="creating"||g.status==="loading"){let W;t[20]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[r.jsx(Ne,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=W):W=t[20];let G;return t[21]!==D?(G=r.jsx(_i,{value:D,children:W}),t[21]=D,t[22]=G):G=t[22],G}if(g.status==="error"){let W;t[23]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=W):W=t[23];let G;t[24]!==g.error.message?(G=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[W,r.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=G):G=t[25];let se;return t[26]!==D||t[27]!==G?(se=r.jsx(_i,{value:D,children:G}),t[26]=D,t[27]=G,t[28]=se):se=t[28],se}if(!_){let W;t[29]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(Bs,{size:48,className:"text-muted-foreground"}),t[29]=W):W=t[29];const G=`The agent "${h}" does not exist in this organization.`;let se;t[30]!==s||t[31]!==l?(se=r.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=se):se=t[32];let ee;t[33]!==G||t[34]!==se?(ee=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:r.jsx(Vi,{image:W,title:"Agent not found",description:G,actions:se})})}),t[33]=G,t[34]=se,t[35]=ee):ee=t[35];let J;return t[36]!==D||t[37]!==ee?(J=r.jsx(_i,{value:D,children:ee}),t[36]=D,t[37]=ee,t[38]=J):J=t[38],J}if(e){let W;t[39]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(ig,{className:"sr-only",children:"Navigation"}),t[39]=W):W=t[39];let G;t[40]!==T?(G=r.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:r.jsx(iy,{onClose:()=>T(!1)})}),t[40]=T,t[41]=G):G=t[41];let se;t[42]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:r.jsx(su,{})}),t[42]=se):se=t[42];let ee;t[43]!==G?(ee=r.jsxs(rg,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[W,r.jsxs("div",{className:"flex h-full",children:[G,se]})]}),t[43]=G,t[44]=ee):ee=t[44];let J;t[45]!==k||t[46]!==T||t[47]!==ee?(J=r.jsx(ng,{open:k,onOpenChange:T,children:ee}),t[45]=k,t[46]=T,t[47]=ee,t[48]=J):J=t[48];const ae=J,Z=_?.metadata?.vmMap;let de;t[49]!==S.createNewTask?(de=r.jsx(gd,{onNewTaskRef:M,createNewTask:S.createNewTask}),t[49]=S.createNewTask,t[50]=de):de=t[50];let me;t[51]!==T?(me=r.jsx(P3,{onOpenSidebar:()=>T(!0)}),t[51]=T,t[52]=me):me=t[52];const le=m?"home":void 0;let he;t[53]!==le?(he=r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(pd,{variant:le})}),t[53]=le,t[54]=he):he=t[54];let be;t[55]!==V||t[56]!==ae||t[57]!==Z||t[58]!==de||t[59]!==me||t[60]!==he||t[61]!==h?(be=r.jsxs(_d,{virtualMcpId:h,hasActiveGithubRepo:V,vmMap:Z,children:[de,me,he,ae]}),t[55]=V,t[56]=ae,t[57]=Z,t[58]=de,t[59]=me,t[60]=he,t[61]=h,t[62]=be):be=t[62];let fe;t[63]!==N||t[64]!==be?(fe=r.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:r.jsx(Ee.Provider,{virtualMcpId:N,children:be},N)}),t[63]=N,t[64]=be,t[65]=fe):fe=t[65];let ye;return t[66]!==D||t[67]!==fe?(ye=r.jsx(_i,{value:D,children:fe}),t[66]=D,t[67]=fe,t[68]=ye):ye=t[68],ye}const L=n?void 0:S.createNewTask;let R;t[69]!==m||t[70]!==S.chatOpen||t[71]!==S.toggleChat||t[72]!==L?(R=r.jsx(Re.Toggles,{children:r.jsx(m3,{isDecopilot:m,chatOpen:S.chatOpen,toggleChat:S.toggleChat,onNewTask:L})}),t[69]=m,t[70]=S.chatOpen,t[71]=S.toggleChat,t[72]=L,t[73]=R):R=t[73];let P;t[74]!==m||t[75]!==S.taskId||t[76]!==h?(P=!m&&r.jsx(Re.Tabs,{children:r.jsx(y3,{virtualMcpId:h,taskId:S.taskId})}),t[74]=m,t[75]=S.taskId,t[76]=h,t[77]=P):P=t[77];const B=_?.metadata?.vmMap;let $;t[78]!==_||t[79]!==m?($=!m&&r.jsx(D3,{virtualMcp:_}),t[78]=_,t[79]=m,t[80]=$):$=t[80];let z;t[81]!==S.createNewTask?(z=r.jsx(gd,{onNewTaskRef:M,createNewTask:S.createNewTask}),t[81]=S.createNewTask,t[82]=z):z=t[82];const q=m?"home":void 0;let F;t[83]!==q?(F=r.jsx(pd,{variant:q}),t[83]=q,t[84]=F):F=t[84];let K;t[85]!==S.chatOpen||t[86]!==S.mainOpen||t[87]!==S.taskId||t[88]!==F||t[89]!==h?(K=r.jsx(f3,{virtualMcpId:h,taskId:S.taskId,chatOpen:S.chatOpen,mainOpen:S.mainOpen,chatContent:F}),t[85]=S.chatOpen,t[86]=S.mainOpen,t[87]=S.taskId,t[88]=F,t[89]=h,t[90]=K):K=t[90];let H;t[91]!==V||t[92]!==B||t[93]!==$||t[94]!==z||t[95]!==K||t[96]!==h?(H=r.jsxs(_d,{virtualMcpId:h,hasActiveGithubRepo:V,vmMap:B,children:[$,z,K]}),t[91]=V,t[92]=B,t[93]=$,t[94]=z,t[95]=K,t[96]=h,t[97]=H):H=t[97];let U;t[98]!==N||t[99]!==P||t[100]!==H?(U=r.jsxs(Ee.Provider,{virtualMcpId:N,children:[P,H]},N),t[98]=N,t[99]=P,t[100]=H,t[101]=U):U=t[101];let X;return t[102]!==D||t[103]!==R||t[104]!==U?(X=r.jsxs(_i,{value:D,children:[R,U]}),t[102]=D,t[103]=R,t[104]=U,t[105]=X):X=t[105],X}function Pj(){const t=O.c(5),e=ms();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(sy,{}),t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={background:"transparent",containerType:"inline-size"},t[2]=n):n=t[2];let o;return t[3]!==e?(o=r.jsx(eg,{defaultOpen:!1,children:r.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:r.jsxs(tg,{className:"flex-1 bg-sidebar",style:s,children:[i,r.jsx(sg,{className:"flex flex-col",style:n,children:e?r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(xd,{})}):r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(hy,{children:r.jsxs(Re,{children:[r.jsxs(Re.Header,{children:[r.jsxs(Re.LeftColumn,{children:[r.jsx(Re.Nav,{}),r.jsx(Re.TogglesSlot,{})]}),r.jsx(Re.CenterSlot,{}),r.jsxs(Re.RightColumn,{children:[r.jsx(Re.TabsSlot,{}),r.jsx(Re.RightSlot,{})]})]}),r.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[r.jsx(Ey,{}),r.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(xd,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{Pj as default,ml as useInsetContext};
|
|
735
|
+
</message>`}]}}))},L=e.models?.credentialId||m||"",R=e.models?.thinking?.id||p?.modelId||"",P=Ai({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:R}}),B=P.watch("active"),$=P.watch("credential_id"),z=P.watch("model_id"),{models:q,isLoading:F}=eh($||void 0),K=q.find(le=>le.modelId===z)??null,H=j.useRef(null),U=j.useRef(new Set),X=j.useRef(0),W=j.useRef(null),G=3e4,se=()=>{W.current&&(clearTimeout(W.current),W.current=null),H.current!==null&&(re("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(U.current),save_count:X.current,edit_duration_ms:Date.now()-H.current}),H.current=null,U.current=new Set,X.current=0)},ee=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!A.current)return!0;const he=Object.keys(P.formState.dirtyFields),be=A.current;A.current=!1;const fe=P.getValues();try{const ye=fe.credential_id&&fe.model_id?fe.credential_id:"",ve=fe.credential_id&&fe.model_id?fe.model_id:"",Ve={id:t,name:fe.name,active:fe.active,agent:{id:o},models:{credentialId:ye,thinking:{id:ve}},messages:jd(v),temperature:0};await l.mutateAsync(Ve),H.current===null&&(H.current=Date.now());for(const Ie of he)U.current.add(Ie);return be&&U.current.add("messages"),X.current+=1,W.current&&clearTimeout(W.current),W.current=setTimeout(se,G),P.reset({...fe,credential_id:ye,model_id:ve}),!0}catch{return A.current=!0,!1}},J=()=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee()},1e3)},ae=async()=>(N.current&&clearTimeout(N.current),ee()),Z=le=>{if(y(le),!E.current){E.current=!0;return}A.current=!0,J()},de=j.useRef(!1);de.current||(de.current=!0,P.watch(()=>{J()}));const me=async()=>{re("automation_test_clicked",{automation_id:t,agent_id:o});const le=await ae();if(se(),!le)return;if(!v){ue.error("No instructions configured for this automation");return}K&&$&&f({...K,keyId:$}),b({..._,toolApprovalLevel:"auto"});const he=gl(v);h({message:{tiptapDoc:v,parts:he},virtualMcpId:o||void 0})};return r.jsxs(r.Fragment,{children:[i&&r.jsx("div",{className:"flex items-center pb-4 shrink-0",children:r.jsxs(oe,{variant:"ghost",size:"sm",onClick:i,children:[r.jsx(Pa,{size:14}),"Back to list"]})}),r.jsxs("div",{className:"flex flex-col gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(at,{...P.register("name"),placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}}),n&&r.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:r.jsx(Ro,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(pi,{control:P.control,name:"active",render:({field:le})=>r.jsx(mn,{checked:le.value,onCheckedChange:he=>{le.onChange(he),setTimeout(()=>ae(),0)},className:"cursor-pointer"})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:B?"Active":"Inactive"}),r.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),r.jsx(Ng,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),r.jsx(QC,{automationId:t,open:V,onOpenChange:C,onCustomSelect:()=>{w(!0),I(!1),T("")},onEventSelect:()=>{I(!0),w(!1)}})]}),e.triggers.length===0&&!S?r.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",r.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>C(!0),children:"Add a starter"})," ","to get going."]})}):r.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(le=>r.jsx(ZC,{trigger:le,automationId:t,connectionName:le.connection_id?u.get(le.connection_id):void 0},le.id))}),S&&r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[r.jsx(tr,{size:14,className:"text-muted-foreground shrink-0"}),r.jsx("input",{type:"text",value:k,onChange:le=>T(le.target.value),onBlur:async()=>{const le=k.trim();if(!(!le||!nr(le)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:le}),re("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ue.success("Starter added"),w(!1),T("")}catch{ue.error("Failed to add starter")}},onKeyDown:async le=>{const he=k.trim();le.key==="Enter"&&he&&nr(he)&&le.target.blur(),le.key==="Escape"&&(w(!1),T(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!nr(k)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&r.jsx(Ne,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),r.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),T("")},children:r.jsx(Os,{size:13})})]}),M&&r.jsx(j.Suspense,{fallback:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[r.jsx(Ne,{size:13,className:"animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:r.jsx(t3,{automationId:t,onDone:()=>I(!1)})})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!v,onClick:D,children:[r.jsx(Da,{size:13}),"Improve"]})]}),r.jsx(qh,{tiptapDoc:v,setTiptapDoc:Z,placeholder:"What should this automation do?",children:r.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[r.jsx(Gh,{virtualMcpId:o||null,className:"max-h-[45vh]"}),r.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[r.jsx(sh,{model:K,isLoading:F,credentialId:$||null,onCredentialChange:le=>{P.setValue("credential_id",le??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:le=>P.setValue("model_id",le.modelId,{shouldDirty:!0}),placeholder:"Model"}),r.jsxs(Ye,{children:[r.jsx(qe,{asChild:!0,children:r.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:me,disabled:!o,children:[r.jsx(Od,{size:16}),"Test"]})}),r.jsx(Ge,{children:"Test Automation"})]})]})]})})]})]})]})}function o3(t){const e=O.c(6),{tabId:s,virtualMcpId:i}=t;let n;e[0]!==s?(n=Ad(s),e[0]=s,e[1]=n):n=e[1];const o=n;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=r.jsx(Jt,{children:r.jsx(Jt.Content,{children:r.jsx(Jt.Body,{children:r.jsx(j.Suspense,{fallback:a,children:r.jsx(a3,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function a3(t){const e=O.c(9),{id:s,virtualMcpId:i}=t,n=Oe(),{data:o,isLoading:a}=Eg(s);let l;e[0]!==n?(l=()=>n({to:".",search:l3,replace:!0}),e[0]=n,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=r.jsx(n3,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function l3(t){return{...t,main:"automations"}}function c3(t){const e=O.c(20),{virtualMcpId:s}=t,i=Oe(),{data:n}=Ig(s),o=n===void 0?[]:n,{create:a}=jr(),[l,c]=j.useState(""),d=l.toLowerCase(),u=o.filter(T=>T.name.toLowerCase().includes(d));let h;e[0]!==i?(h=T=>i({to:".",search:M=>({...M,main:"automation:"+T}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const f=h,m=async()=>{if(a.isPending)return;re("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const T=await a.mutateAsync(Rg(s));f(T.id)},p=Jt,g=Jt,_=Jt;let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Jt.Title,{children:"Automations"}),e[2]=b):b=e[2];const x=o.length>0&&r.jsx(Mg,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Dt,{size:14}),e[3]=v):v=e[3];let y;e[4]!==a.isPending||e[5]!==m?(y=r.jsxs(oe,{size:"sm",onClick:m,disabled:a.isPending,children:[v,"New automation"]}),e[4]=a.isPending,e[5]=m,e[6]=y):y=e[6];let V;e[7]!==x||e[8]!==y?(V=r.jsxs("div",{className:"flex flex-col gap-6",children:[b,r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[x,y]})]}),e[7]=x,e[8]=y,e[9]=V):V=e[9];const C=o.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Vi,{image:r.jsx(Ci,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:r.jsxs(oe,{size:"sm",onClick:m,disabled:a.isPending,children:[r.jsx(Dt,{size:14}),"New automation"]})})}):u.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Vi,{image:r.jsx(Ci,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):r.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(T=>r.jsx(Tg,{automation:T,onClick:()=>f(T.id)},T.id))});let S;e[10]!==C||e[11]!==_.Body||e[12]!==V?(S=r.jsxs(_.Body,{children:[V,C]}),e[10]=C,e[11]=_.Body,e[12]=V,e[13]=S):S=e[13];let w;e[14]!==S||e[15]!==g.Content?(w=r.jsx(g.Content,{children:S}),e[14]=S,e[15]=g.Content,e[16]=w):w=e[16];let k;return e[17]!==p||e[18]!==w?(k=r.jsx(p,{children:w}),e[17]=p,e[18]=w,e[19]=k):k=e[19],k}function d3(t){const e=O.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx(j.Suspense,{fallback:i,children:r.jsx(c3,{virtualMcpId:s})}),e[1]=s,e[2]=n):n=e[2],n}const ud=j.lazy(()=>dm(()=>import("./project-app-view-DbITEuQv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55])).then(t=>({default:t.AppViewContent})));function h3(t){const e=O.c(44),{taskId:s,virtualMcpId:i}=t;let n;e[0]!==s||e[1]!==i?(n={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=n):n=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=wu(n);if(Im(o)){let p;return e[3]!==i?(p=r.jsx(pc,{virtualMcpId:i}),e[3]=i,e[4]=p):p=e[4],p}if(o==="git"){let p;return e[5]!==i?(p=r.jsx(J2,{virtualMcpId:i}),e[5]=i,e[6]=p):p=e[6],p}if(o==="automations"){let p;return e[7]!==i?(p=r.jsx(d3,{virtualMcpId:i}),e[7]=i,e[8]=p):p=e[8],p}if(o==="env"){let p;return e[9]!==i?(p=r.jsx(KC,{virtualMcpId:i}),e[9]=i,e[10]=p):p=e[10],p}if(o==="preview"){let p;return e[11]!==i?(p=r.jsx(NS,{virtualMcpId:i}),e[11]=i,e[12]=p):p=e[12],p}if(c){let p;return e[13]!==o||e[14]!==i?(p=r.jsx(o3,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=p):p=e[15],p}let d;e[16]!==o?(d=Tm(o),e[16]=o,e[17]=d):d=e[17];const u=d;if(u){let p;if(e[18]!==l||e[19]!==u.connectionId||e[20]!==u.toolName){let v;e[22]!==u.connectionId||e[23]!==u.toolName?(v=y=>y.appId===u.connectionId&&y.toolName===u.toolName,e[22]=u.connectionId,e[23]=u.toolName,e[24]=v):v=e[24],p=l.find(v),e[18]=l,e[19]=u.connectionId,e[20]=u.toolName,e[21]=p}else p=e[21];const g=p;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[25]=_):_=e[25];const b=g?.args;let x;return e[26]!==o||e[27]!==u.connectionId||e[28]!==u.toolName||e[29]!==b?(x=r.jsx(j.Suspense,{fallback:_,children:r.jsx(ud,{connectionId:u.connectionId,toolName:u.toolName,args:b},o)}),e[26]=o,e[27]=u.connectionId,e[28]=u.toolName,e[29]=b,e[30]=x):x=e[30],x}let h;if(e[31]!==o||e[32]!==a){let p;e[34]!==o?(p=g=>g.id===o,e[34]=o,e[35]=p):p=e[35],h=a.find(p),e[31]=o,e[32]=a,e[33]=h}else h=e[33];const f=h;if(f){let p;e[36]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),e[36]=p):p=e[36];let g;return e[37]!==o||e[38]!==f.id||e[39]!==f.view.appId||e[40]!==f.view.args?(g=r.jsx(j.Suspense,{fallback:p,children:r.jsx(ud,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},o)}),e[37]=o,e[38]=f.id,e[39]=f.view.appId,e[40]=f.view.args,e[41]=g):g=e[41],g}let m;return e[42]!==i?(m=r.jsx(pc,{virtualMcpId:i}),e[42]=i,e[43]=m):m=e[43],m}function u3(t){const e=O.c(7),{children:s,defaultSize:i}=t,[,n]=j.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ca.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=Va(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=f=>n(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=r.jsx(ih,{defaultSize:c,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=c,e[5]=u,e[6]=h):h=e[6],h}function f3(t){const e=O.c(31),{virtualMcpId:s,taskId:i,chatOpen:n,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==n||e[1]!==o?(c=dc(n,o),e[0]=n,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=Ca.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=Va(u,45),f=j.useRef(null);let m,p;e[4]!==n||e[5]!==o||e[6]!==h?(m=()=>{const M=f.current;if(!M)return;const I=dc(n,o),E=I.chat>0&&I.chat<100?h:I.chat,N=I.chat>0&&I.chat<100?100-h:I.main;M.setLayout([E,N])},p=[n,o,h],e[4]=n,e[5]=o,e[6]=h,e[7]=m,e[8]=p):(m=e[7],p=e[8]),j.useEffect(m,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let b;e[10]!==l||e[11]!==a?(b=l??r.jsx(Zh,{variant:a}),e[10]=l,e[11]=a,e[12]=b):b=e[12];let x;e[13]!==b?(x=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:b})}),e[13]=b,e[14]=x):x=e[14];let v;e[15]!==d.chat||e[16]!==x?(v=r.jsx(u3,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=v):v=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Np,{className:"bg-sidebar"}),e[18]=y):y=e[18];const V=d.main;let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C={overflow:"visible"},e[19]=C):C=e[19];let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=Y("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[20]=S):S=e[20];let w;e[21]!==i||e[22]!==s?(w=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:S,children:r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(h3,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=w):w=e[23];let k;e[24]!==d.main||e[25]!==w?(k=r.jsx(ih,{className:"min-w-0 flex flex-col",order:2,defaultSize:V,style:C,collapsible:!0,collapsedSize:0,minSize:20,children:w}),e[24]=d.main,e[25]=w,e[26]=k):k=e[26];let T;return e[27]!==k||e[28]!==g||e[29]!==v?(T=r.jsxs(Ap,{ref:f,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[v,y,k]},g),e[27]=k,e[28]=g,e[29]=v,e[30]=T):T=e[30],T}const wo="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",fd="bg-sidebar-accent text-sidebar-foreground",Vo="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function m3(t){const e=O.c(38),{isDecopilot:s,chatOpen:i,toggleChat:n,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=yu(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{re("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?fd:Vo;let h;e[3]!==u?(h=Y(wo,u),e[3]=u,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(hp,{size:16}),e[5]=f):f=e[5];let m;e[6]!==d||e[7]!==h||e[8]!==a?(m=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:f})}),e[6]=d,e[7]=h,e[8]=a,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Ge,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==m?(g=r.jsxs(Ye,{delayDuration:300,children:[m,p]}),e[11]=m,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==n?(_=!s&&r.jsxs(Ye,{delayDuration:300,children:[r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",onClick:()=>{re("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),n()},"aria-pressed":i,className:Y(wo,i?fd:Vo),children:r.jsx(dp,{size:16})})}),r.jsx(Ge,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=n,e[16]=_):_=e[16];const b=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==b?(x=Y("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",b),e[17]=b,e[18]=x):x=e[18];const v=!c,y=c?0:-1,V=!c,C=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let S;e[19]!==C?(S=Y(wo,Vo,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",C),e[19]=C,e[20]=S):S=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Ra,{size:16}),e[21]=w):w=e[21];let k;e[22]!==o||e[23]!==v||e[24]!==y||e[25]!==V||e[26]!==S?(k=r.jsx(qe,{asChild:!0,children:r.jsx("button",{type:"button",onClick:o,disabled:v,tabIndex:y,"aria-hidden":V,className:S,children:w})}),e[22]=o,e[23]=v,e[24]=y,e[25]=V,e[26]=S,e[27]=k):k=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Ge,{side:"bottom",children:"New task"}),e[28]=T):T=e[28];let M;e[29]!==k?(M=r.jsx("div",{className:"overflow-hidden",children:r.jsxs(Ye,{delayDuration:300,children:[k,T]})}),e[29]=k,e[30]=M):M=e[30];let I;e[31]!==x||e[32]!==M?(I=r.jsx("div",{className:x,children:M}),e[31]=x,e[32]=M,e[33]=I):I=e[33];let E;return e[34]!==I||e[35]!==g||e[36]!==_?(E=r.jsxs(r.Fragment,{children:[g,_,I]}),e[34]=I,e[35]=g,e[36]=_,e[37]=E):E=e[37],E}function p3(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),n=t.slice(s);if(e==null)return{visible:i,overflow:n};if(i.some(h=>h.id===e))return{visible:i,overflow:n};const a=n.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:n};const l=i[i.length-1],c=n[a],d=[...i.slice(0,-1),c],u=[l,...n.slice(0,a),...n.slice(a+1)];return{visible:d,overflow:u}}function g3(t){const e=O.c(13),{title:s,icon:i,active:n,onClick:o}=t,a=n?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=Y("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==i?(c=r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(_3,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=r.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==n||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=r.jsxs("button",{type:"button",onClick:o,"aria-pressed":n,"aria-label":s,className:l,children:[c,d]}),e[6]=n,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function _3(t){const e=O.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Gd,{className:"size-4"}),e[4]=i):i=e[4],i}function x3(t){const e=O.c(13),{overflow:s,onSelect:i}=t,[n,o]=j.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(zs,{asChild:!0,children:r.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:r.jsx(Wd,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(v3,{icon:m.icon})}),r.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=r.jsx(Fs,{align:"end",className:"w-56 p-1",children:r.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==n||e[11]!==u?(h=r.jsxs(Us,{open:n,onOpenChange:o,children:[c,u]}),e[10]=n,e[11]=u,e[12]=h):h=e[12],h}function v3(t){const e=O.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Gd,{className:"size-4"}),e[4]=i):i=e[4],i}const b3=6;function y3(t){const e=O.c(20),{virtualMcpId:s,taskId:i}=t,n=Oe();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=wu(o);let u,h,f,m;if(e[3]!==l||e[4]!==c||e[5]!==n||e[6]!==d||e[7]!==a||e[8]!==s){const _=Rm({activeTab:l,mainOpen:c}),b=C=>C.id==="automations"?_:c&&C.id===l,v=a.find(C=>b(C))?.id??null,{visible:y,overflow:V}=p3(a,v,b3);h=V,u=C=>{const S=a.find(k=>k.id===C),w=v===C&&c;if(re("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:C,tab_kind:S?.kind??null,was_active:w}),C==="automations"){const k=Mm({activeTab:l,mainOpen:c});n({to:".",search:T=>({...T,main:k}),replace:!0});return}d(C)},f="flex items-center min-w-0 ml-auto gap-0.5",m=y.map(C=>r.jsx(g3,{title:C.title,icon:C.icon,active:b(C),onClick:()=>u(C.id)},C.id)),e[3]=l,e[4]=c,e[5]=n,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=f,e[12]=m}else u=e[9],h=e[10],f=e[11],m=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&r.jsx(x3,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=r.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}function S3(t){const e=O.c(12);let s,i,n,o;e[0]!==t?({className:s,orientation:n,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=o):(s=e[1],i=e[2],n=e[3],o=e[4]);const a=n===void 0?"horizontal":n,l=o===void 0?!0:o;let c;e[5]!==s?(c=Y("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=r.jsx(hm,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function w3(t){const e=O.c(20),{prNumber:s,disabled:i,send:n}=t;let o;e[0]!==s||e[1]!==n?(o=()=>n($2({prNumber:s})),e[0]=s,e[1]=n,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==n?(l=()=>n(B2({prNumber:s})),e[3]=s,e[4]=n,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=r.jsx(oe,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(cr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=r.jsx(ds,{asChild:!0,children:r.jsx(oe,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let f;e[12]!==c?(f=r.jsx(hs,{align:"end",children:r.jsx(Qe,{onClick:c,children:"Review"})}),e[12]=c,e[13]=f):f=e[13];let m;e[14]!==h||e[15]!==f?(m=r.jsxs(cs,{children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=r.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,m]}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}const V3=new Set(["failure","timed_out","cancelled","action_required"]);function C3(t){return t.status==="completed"&&V3.has(t.conclusion)}function k3(t){return t.status==="queued"||t.status==="in_progress"}function j3(t){const{branchStatus:e,pr:s,checks:i,reviews:n}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((n?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(C3).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(k3)?{label:"Running tests…",disabled:!0}:n?.draft?{label:"Mark ready",action:"mark-ready"}:(n?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:n?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function N3(){return Ti().branchStatus}const A3=6e4,E3=3e4;function I3(t){const e=O.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Ae(s),n=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==n?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:n},e[3]=t.owner,e[4]=t.repo,e[5]=n,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:A3,refetchIntervalInBackground:!1,staleTime:E3,select:T3},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],ni(l)}function T3(t){const e=Nr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),n=Number(e.review_comments??0),o=s==="blocked"&&n>0?n:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function R3(t){const e=O.c(38),{virtualMcpId:s}=t,{org:i}=_e(),n=$t(s),{currentBranch:o}=Lt(),a=Cn(),l=n?.metadata?.githubRepo??null,c=N3(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",f=o??null;let m;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==f?(m={orgId:i.id,connectionId:d,owner:u,repo:h,branch:f},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=f,e[5]=m):m=e[5];const g=Cu(m).data??null,_=l?.connectionId??"",b=l?.owner??"",x=l?.name??"",v=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==b||e[9]!==x||e[10]!==v?(y={orgId:i.id,connectionId:_,owner:b,repo:x,prNumber:v},e[6]=i.id,e[7]=_,e[8]=b,e[9]=x,e[10]=v,e[11]=y):y=e[11];const V=ju(y),C=l?.connectionId??"",S=l?.owner??"",w=l?.name??"",k=g&&g.state==="open"?g.number:null;let T;e[12]!==i.id||e[13]!==C||e[14]!==S||e[15]!==w||e[16]!==k?(T={orgId:i.id,connectionId:C,owner:S,repo:w,prNumber:k},e[12]=i.id,e[13]=C,e[14]=S,e[15]=w,e[16]=k,e[17]=T):T=e[17];const M=I3(T);if(!l?.connectionId||!o)return null;let I;e[18]!==c||e[19]!==V.data||e[20]!==g||e[21]!==M.data?(I=j3({branchStatus:c,pr:g,checks:V.data??[],reviews:M.data??null}),e[18]=c,e[19]=V.data,e[20]=g,e[21]=M.data,e[22]=I):I=e[22];const E=I;if(!E)return null;let N;e[23]!==a?(N=z=>a.sendMessage({parts:[{type:"text",text:z}]}),e[23]=a,e[24]=N):N=e[24];const A=N,D=a.isStreaming;let L;e[25]!==o||e[26]!==E||e[27]!==D||e[28]!==g||e[29]!==A?(L=z=>{if(!D)switch(z){case"commit-and-push":{A(I2({branch:o}));return}case"create-pr":{A(T2({branch:o}));return}case"reopen":{g&&A(R2({prNumber:g.number}));return}case"rebase":{A(M2({branch:o}));return}case"fix-checks":{g&&A(P2({prNumber:g.number,failingChecks:E.meta?.failingChecks??[]}));return}case"mark-ready":{g&&A(L2({prNumber:g.number}));return}case"resolve-comments":{g&&A(O2({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=E,e[27]=D,e[28]=g,e[29]=A,e[30]=L):L=e[30];const R=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(S3,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const B=g?.number;let $;return e[32]!==E||e[33]!==D||e[34]!==R||e[35]!==A||e[36]!==B?($=r.jsxs(r.Fragment,{children:[P,r.jsx(M3,{button:E,isStreaming:D,onActivate:R,prNumber:B,send:A})]}),e[32]=E,e[33]=D,e[34]=R,e[35]=A,e[36]=B,e[37]=$):$=e[37],$}function M3(t){const e=O.c(18),{button:s,isStreaming:i}=t,n=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==n||e[1]!==t.prNumber||e[2]!==t.send?(u=r.jsx(w3,{prNumber:t.prNumber,disabled:n,send:t.send}),e[0]=n,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let h;return e[4]!==u||e[5]!==o?(h=r.jsx(md,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==n||e[12]!==a||e[13]!==l?(c=r.jsx(oe,{size:"sm",variant:a,disabled:n,onClick:l,children:s.label}),e[10]=s.label,e[11]=n,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=r.jsx(md,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function md(t){const e=O.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=r.jsx(r.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let n;e[2]!==i?(n=r.jsx(qe,{asChild:!0,children:r.jsx("span",{children:i})}),e[2]=i,e[3]=n):n=e[3];let o;e[4]!==s?(o=r.jsx(Ge,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==o?(a=r.jsx(bi,{children:r.jsxs(Ye,{children:[n,o]})}),e[6]=n,e[7]=o,e[8]=a):a=e[8],a}function D3(t){const e=O.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=r.jsx(Re.Right,{children:r.jsx(R3,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const _i=j.createContext(null);function ml(){return j.use(_i)}function pd(t){const e=O.c(8),{children:s,variant:i}=t,{taskId:n}=Lt();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Ee.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??r.jsx(Zh,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==n?(c=r.jsx(ls,{fallback:o,children:r.jsx(j.Suspense,{fallback:a,children:r.jsx(Ee.ActiveTaskProvider,{taskId:n,children:l})})}),e[5]=l,e[6]=n,e[7]=c):c=e[7],c}function gd(t){const e=O.c(3),{onNewTaskRef:s,createNewTask:i}=t;let n;return e[0]!==i||e[1]!==s?(n=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=n):n=e[2],j.useLayoutEffect(n),null}function P3(t){const e=O.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(mp,{size:20}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:r.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=n):n=e[2],n}function _d(t){const e=O.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:n,children:o}=t,{org:a}=_e(),{currentBranch:l}=Lt(),{data:c}=dt.useSession(),d=c?.user?.id,u=d&&l?n?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const f=h;let m;e[2]!==a.id?(m={connectionId:yt,orgId:a.id},e[2]=a.id,e[3]=m):m=e[3];const p=Ae(m),{mutate:g}=el(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const b=j.useRef(_);let x,v;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==n?(x=()=>{i&&d&&l&&(n?.[d]?.[l]||b.current.has(l)||(b.current.add(l),g({virtualMcpId:s,branch:l},{onError:L3})))},v=[i,d,l,n,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=n,e[11]=x,e[12]=v):(x=e[11],v=e[12]),j.useEffect(x,v);let y;return e[13]!==o||e[14]!==f?(y=r.jsx(uS,{daemonBaseUrl:f,children:o}),e[13]=o,e[14]=f,e[15]=y):y=e[15],y}function L3(t){console.error("[auto-start-vm] failed:",t)}function xd(){const t=O.c(106),e=ms(),s=Oe(),{org:i}=_e(),n=fy()?.tasksOpen??!1;Sg(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=_r(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=ti(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??En(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let f;t[5]!==i.id?(f=Aa(i.id),t[5]=i.id,t[6]=f):f=t[6];const m=h===f,p=!m,g=Lg(a.taskId??"",h),_=$t(h),b=_?.metadata?.ui?.layout??null;let x;t[7]!==b?(x=b?{defaultMainView:b.defaultMainView??null,chatDefaultOpen:b.chatDefaultOpen??null}:null,t[7]=b,t[8]=x):x=t[8];const v=x;let y;t[9]!==_?(y=_&&bs(_),t[9]=_,t[10]=y):y=t[10];const V=!!y;let C;t[11]!==p||t[12]!==l||t[13]!==h?(C={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=C):C=t[14];const S=dy(v,C),{setOpenMobile:w,openMobile:k}=Cr(),T=w,M=j.useRef(null);let I,E;t[15]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const W=G=>{Md(G)&&G.shiftKey&&G.code==="KeyS"&&!G.repeat&&(G.preventDefault(),M.current?.())};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},E=[],t[15]=I,t[16]=E):(I=t[15],E=t[16]),j.useEffect(I,E);const N=h;let A;t[17]!==_||t[18]!==h?(A={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=A):A=t[19];const D=A;if(g.status==="creating"||g.status==="loading"){let W;t[20]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[r.jsx(Ne,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=W):W=t[20];let G;return t[21]!==D?(G=r.jsx(_i,{value:D,children:W}),t[21]=D,t[22]=G):G=t[22],G}if(g.status==="error"){let W;t[23]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=W):W=t[23];let G;t[24]!==g.error.message?(G=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[W,r.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=G):G=t[25];let se;return t[26]!==D||t[27]!==G?(se=r.jsx(_i,{value:D,children:G}),t[26]=D,t[27]=G,t[28]=se):se=t[28],se}if(!_){let W;t[29]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(Bs,{size:48,className:"text-muted-foreground"}),t[29]=W):W=t[29];const G=`The agent "${h}" does not exist in this organization.`;let se;t[30]!==s||t[31]!==l?(se=r.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=se):se=t[32];let ee;t[33]!==G||t[34]!==se?(ee=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:r.jsx(Vi,{image:W,title:"Agent not found",description:G,actions:se})})}),t[33]=G,t[34]=se,t[35]=ee):ee=t[35];let J;return t[36]!==D||t[37]!==ee?(J=r.jsx(_i,{value:D,children:ee}),t[36]=D,t[37]=ee,t[38]=J):J=t[38],J}if(e){let W;t[39]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(ig,{className:"sr-only",children:"Navigation"}),t[39]=W):W=t[39];let G;t[40]!==T?(G=r.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:r.jsx(iy,{onClose:()=>T(!1)})}),t[40]=T,t[41]=G):G=t[41];let se;t[42]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:r.jsx(su,{})}),t[42]=se):se=t[42];let ee;t[43]!==G?(ee=r.jsxs(rg,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[W,r.jsxs("div",{className:"flex h-full",children:[G,se]})]}),t[43]=G,t[44]=ee):ee=t[44];let J;t[45]!==k||t[46]!==T||t[47]!==ee?(J=r.jsx(ng,{open:k,onOpenChange:T,children:ee}),t[45]=k,t[46]=T,t[47]=ee,t[48]=J):J=t[48];const ae=J,Z=_?.metadata?.vmMap;let de;t[49]!==S.createNewTask?(de=r.jsx(gd,{onNewTaskRef:M,createNewTask:S.createNewTask}),t[49]=S.createNewTask,t[50]=de):de=t[50];let me;t[51]!==T?(me=r.jsx(P3,{onOpenSidebar:()=>T(!0)}),t[51]=T,t[52]=me):me=t[52];const le=m?"home":void 0;let he;t[53]!==le?(he=r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(pd,{variant:le})}),t[53]=le,t[54]=he):he=t[54];let be;t[55]!==V||t[56]!==ae||t[57]!==Z||t[58]!==de||t[59]!==me||t[60]!==he||t[61]!==h?(be=r.jsxs(_d,{virtualMcpId:h,hasActiveGithubRepo:V,vmMap:Z,children:[de,me,he,ae]}),t[55]=V,t[56]=ae,t[57]=Z,t[58]=de,t[59]=me,t[60]=he,t[61]=h,t[62]=be):be=t[62];let fe;t[63]!==N||t[64]!==be?(fe=r.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:r.jsx(Ee.Provider,{virtualMcpId:N,children:be},N)}),t[63]=N,t[64]=be,t[65]=fe):fe=t[65];let ye;return t[66]!==D||t[67]!==fe?(ye=r.jsx(_i,{value:D,children:fe}),t[66]=D,t[67]=fe,t[68]=ye):ye=t[68],ye}const L=n?void 0:S.createNewTask;let R;t[69]!==m||t[70]!==S.chatOpen||t[71]!==S.toggleChat||t[72]!==L?(R=r.jsx(Re.Toggles,{children:r.jsx(m3,{isDecopilot:m,chatOpen:S.chatOpen,toggleChat:S.toggleChat,onNewTask:L})}),t[69]=m,t[70]=S.chatOpen,t[71]=S.toggleChat,t[72]=L,t[73]=R):R=t[73];let P;t[74]!==m||t[75]!==S.taskId||t[76]!==h?(P=!m&&r.jsx(Re.Tabs,{children:r.jsx(y3,{virtualMcpId:h,taskId:S.taskId})}),t[74]=m,t[75]=S.taskId,t[76]=h,t[77]=P):P=t[77];const B=_?.metadata?.vmMap;let $;t[78]!==_||t[79]!==m?($=!m&&r.jsx(D3,{virtualMcp:_}),t[78]=_,t[79]=m,t[80]=$):$=t[80];let z;t[81]!==S.createNewTask?(z=r.jsx(gd,{onNewTaskRef:M,createNewTask:S.createNewTask}),t[81]=S.createNewTask,t[82]=z):z=t[82];const q=m?"home":void 0;let F;t[83]!==q?(F=r.jsx(pd,{variant:q}),t[83]=q,t[84]=F):F=t[84];let K;t[85]!==S.chatOpen||t[86]!==S.mainOpen||t[87]!==S.taskId||t[88]!==F||t[89]!==h?(K=r.jsx(f3,{virtualMcpId:h,taskId:S.taskId,chatOpen:S.chatOpen,mainOpen:S.mainOpen,chatContent:F}),t[85]=S.chatOpen,t[86]=S.mainOpen,t[87]=S.taskId,t[88]=F,t[89]=h,t[90]=K):K=t[90];let H;t[91]!==V||t[92]!==B||t[93]!==$||t[94]!==z||t[95]!==K||t[96]!==h?(H=r.jsxs(_d,{virtualMcpId:h,hasActiveGithubRepo:V,vmMap:B,children:[$,z,K]}),t[91]=V,t[92]=B,t[93]=$,t[94]=z,t[95]=K,t[96]=h,t[97]=H):H=t[97];let U;t[98]!==N||t[99]!==P||t[100]!==H?(U=r.jsxs(Ee.Provider,{virtualMcpId:N,children:[P,H]},N),t[98]=N,t[99]=P,t[100]=H,t[101]=U):U=t[101];let X;return t[102]!==D||t[103]!==R||t[104]!==U?(X=r.jsxs(_i,{value:D,children:[R,U]}),t[102]=D,t[103]=R,t[104]=U,t[105]=X):X=t[105],X}function Pj(){const t=O.c(5),e=ms();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(sy,{}),t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={background:"transparent",containerType:"inline-size"},t[2]=n):n=t[2];let o;return t[3]!==e?(o=r.jsx(eg,{defaultOpen:!1,children:r.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:r.jsxs(tg,{className:"flex-1 bg-sidebar",style:s,children:[i,r.jsx(sg,{className:"flex flex-col",style:n,children:e?r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(xd,{})}):r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(hy,{children:r.jsxs(Re,{children:[r.jsxs(Re.Header,{children:[r.jsxs(Re.LeftColumn,{children:[r.jsx(Re.Nav,{}),r.jsx(Re.TogglesSlot,{})]}),r.jsx(Re.CenterSlot,{}),r.jsxs(Re.RightColumn,{children:[r.jsx(Re.TabsSlot,{}),r.jsx(Re.RightSlot,{})]})]}),r.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[r.jsx(Ey,{}),r.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:r.jsx(j.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ne,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(xd,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{Pj as default,ml as useInsetContext};
|