@decocms/mesh 2.65.1 → 2.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/client/assets/{AlertCircle-Sq0aBvsC.js → AlertCircle-B2fkM138.js} +1 -1
  2. package/dist/client/assets/{ArrowUp-CvxgIRrE.js → ArrowUp-D1AvEfzg.js} +1 -1
  3. package/dist/client/assets/{Calendar-DS_6zH5D.js → Calendar-BVWxw6KN.js} +1 -1
  4. package/dist/client/assets/{Check-DNCI8C1c.js → Check-G0Uo7MV1.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-COsIOW0_.js → CheckCircle-Brh6alH0.js} +1 -1
  6. package/dist/client/assets/{ChevronDown-CmDSkkyU.js → ChevronDown-CVB8bXEV.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-Cme_aOxM.js → ChevronRight-c4NlNF9A.js} +1 -1
  8. package/dist/client/assets/{Code01-DlwIBx5j.js → Code01-BVAq1cya.js} +1 -1
  9. package/dist/client/assets/{Copy01-CX9SC5FE.js → Copy01-C07m3ESL.js} +1 -1
  10. package/dist/client/assets/{DotsHorizontal-Dz0bRPai.js → DotsHorizontal-AVoj4qko.js} +1 -1
  11. package/dist/client/assets/{DotsVertical-CC8faZfe.js → DotsVertical-BgAR-Qt1.js} +1 -1
  12. package/dist/client/assets/{Download01-Cj1VuArg.js → Download01-BaWv-MPX.js} +1 -1
  13. package/dist/client/assets/{Edit01-C8mqwImV.js → Edit01-abEeaaHN.js} +1 -1
  14. package/dist/client/assets/{File02-3scwR97O.js → File02-Cxg7VGhK.js} +1 -1
  15. package/dist/client/assets/{File06-BmoKv1ZA.js → File06-B-BJJgbp.js} +1 -1
  16. package/dist/client/assets/{FilterLines-BcuJXQ3t.js → FilterLines-CpavrtRH.js} +1 -1
  17. package/dist/client/assets/{Globe02-BQTpYCGK.js → Globe02-DjAe4vbB.js} +1 -1
  18. package/dist/client/assets/{Grid01-CH_80p-4.js → Grid01-DkGwMObb.js} +1 -1
  19. package/dist/client/assets/{Home02-KQaRNwL3.js → Home02-C1aheEOO.js} +1 -1
  20. package/dist/client/assets/{Image01-qkpxD1yj.js → Image01-BnPQLh0E.js} +1 -1
  21. package/dist/client/assets/{Inbox01-mn1giWLi.js → Inbox01-TnJNmMxq.js} +1 -1
  22. package/dist/client/assets/{InfoCircle-jWdDj_pa.js → InfoCircle-CPCf05Up.js} +1 -1
  23. package/dist/client/assets/{LinkExternal01-BJcBkMgt.js → LinkExternal01-4WgHKQsl.js} +1 -1
  24. package/dist/client/assets/{List-BWbZDQVx.js → List-_b-aWM0n.js} +1 -1
  25. package/dist/client/assets/{Loading01-DuNH8QVR.js → Loading01-DJg-4sIh.js} +1 -1
  26. package/dist/client/assets/{Lock01-CCyf9a9X.js → Lock01-bcOvI0Ko.js} +1 -1
  27. package/dist/client/assets/{Pin01-CU7bB1L8.js → Pin01-BmWi3GT3.js} +1 -1
  28. package/dist/client/assets/{Play-CrBwr4cr.js → Play-DmKqcTBT.js} +1 -1
  29. package/dist/client/assets/{Plus-ZDIS0vbh.js → Plus-BfhQyaT2.js} +1 -1
  30. package/dist/client/assets/{SearchMd-6GhPnBK1.js → SearchMd-vzH73w2C.js} +1 -1
  31. package/dist/client/assets/{Share07-BDsQfZYE.js → Share07-BebYFAZG.js} +1 -1
  32. package/dist/client/assets/{Terminal-Bx4QINJq.js → Terminal-cm5IHqjb.js} +1 -1
  33. package/dist/client/assets/{Tool01-DoELZ-Fj.js → Tool01-8pfwvGVO.js} +1 -1
  34. package/dist/client/assets/{Trash01-DGR7JKVH.js → Trash01-uXqVqZ4v.js} +1 -1
  35. package/dist/client/assets/{Upload01-C08PhgQO.js → Upload01-D8CqJSKT.js} +1 -1
  36. package/dist/client/assets/{Users03-C-DkXcQ6.js → Users03-BKCrYRx-.js} +1 -1
  37. package/dist/client/assets/{X-Cw8dXC6B.js → X-BW6YCcKc.js} +1 -1
  38. package/dist/client/assets/{XClose-BOKH0Ji3.js → XClose-C2NXNxvY.js} +1 -1
  39. package/dist/client/assets/{agent-connections-preview-C1QLXOEH.js → agent-connections-preview-CGKlKFHn.js} +1 -1
  40. package/dist/client/assets/agent-detail-M33WpTr5.js +1 -0
  41. package/dist/client/assets/{agents-Br3GzWPS.js → agents-BjHugWl0.js} +1 -1
  42. package/dist/client/assets/{alert-dialog-Bt2DNs-q.js → alert-dialog-fJOs6NlL.js} +1 -1
  43. package/dist/client/assets/{auth-catchall-C-ZsonS7.js → auth-catchall-D-r62wiG.js} +1 -1
  44. package/dist/client/assets/{badge-DsLVLnaN.js → badge-BB7crk7y.js} +1 -1
  45. package/dist/client/assets/{binder-AghfMQli.js → binder-CbZhSXdv.js} +1 -1
  46. package/dist/client/assets/{breadcrumb-k6_ciPji.js → breadcrumb-niivPcbv.js} +1 -1
  47. package/dist/client/assets/{button-C2Npiaxw.js → button-CjH_jeJQ.js} +1 -1
  48. package/dist/client/assets/{card-CuSLw2Wn.js → card-BuSwLKUe.js} +1 -1
  49. package/dist/client/assets/{checkbox-CeETLr6E.js → checkbox-jehQHPHA.js} +1 -1
  50. package/dist/client/assets/{circle-alert-Bwtfy9KA.js → circle-alert-B-boz6lj.js} +1 -1
  51. package/dist/client/assets/{collection-detail-BioqVjvv.js → collection-detail-1T0ecY8Q.js} +3 -3
  52. package/dist/client/assets/{collection-search-BT1Haqdl.js → collection-search-CEX16zDI.js} +1 -1
  53. package/dist/client/assets/{collection-tab-CadD9eyl.js → collection-tab-CN84ifuT.js} +1 -1
  54. package/dist/client/assets/{collection-table-wrapper-BlVqD0Fp.js → collection-table-wrapper-Cf-srhsL.js} +1 -1
  55. package/dist/client/assets/{collection-tabs-D8pHKDB9.js → collection-tabs-BHUXhrq0.js} +1 -1
  56. package/dist/client/assets/{command-Dzjf2dKr.js → command-CI8tLx1q.js} +1 -1
  57. package/dist/client/assets/{connect-BulmDFHR.js → connect-DnxowUrB.js} +1 -1
  58. package/dist/client/assets/{connection-card-_pmn_9ur.js → connection-card-BMgz1e9v.js} +1 -1
  59. package/dist/client/assets/connection-detail-DJfMln3d.js +1 -0
  60. package/dist/client/assets/connections-D9cfv_7-.js +1 -0
  61. package/dist/client/assets/constants-CW07-qnN.js +1 -0
  62. package/dist/client/assets/constants-CeDPLV3j.js +1 -0
  63. package/dist/client/assets/{create-organization-dialog-CUyzVLEt.js → create-organization-dialog-DEJZtz9m.js} +1 -1
  64. package/dist/client/assets/{dialog-ByiIrjjH.js → dialog-BjAQMOK4.js} +1 -1
  65. package/dist/client/assets/{dropdown-menu-BXLews1x.js → dropdown-menu-vCMq_394.js} +1 -1
  66. package/dist/client/assets/{dynamic-plugin-layout-CQpxZjNJ.js → dynamic-plugin-layout-DkBPIXG_.js} +1 -1
  67. package/dist/client/assets/{empty-state-DCefUqf-.js → empty-state-BvjoZw7e.js} +1 -1
  68. package/dist/client/assets/{empty-state-BhLPGCFf.js → empty-state-Gbw_otIT.js} +1 -1
  69. package/dist/client/assets/{env-vars-editor-CyRZUIFU.js → env-vars-editor-B1PughxC.js} +1 -1
  70. package/dist/client/assets/{error-boundary-CZlFheRY.js → error-boundary-CfjGe8GJ.js} +1 -1
  71. package/dist/client/assets/{extract-connection-data-DQkYWC-q.js → extract-connection-data-CF78Ki23.js} +1 -1
  72. package/dist/client/assets/{file-browser-bPGGZg11.js → file-browser-nwtZ6onU.js} +2 -2
  73. package/dist/client/assets/{form-CJsO1IWr.js → form-CHBB34OT.js} +1 -1
  74. package/dist/client/assets/{grid-view-CQCNSuKd.js → grid-view-DL05Fujd.js} +1 -1
  75. package/dist/client/assets/{home-B_4GnWnZ.js → home-CLtjbN9e.js} +1 -1
  76. package/dist/client/assets/{index-CuLYtmwa.js → index-8kTnOBNx.js} +82 -82
  77. package/dist/client/assets/{index-S9nBXez3.js → index-BMLEzHeY.js} +2 -2
  78. package/dist/client/assets/index-Bmf5NCxB.js +1 -0
  79. package/dist/client/assets/{index-ymK78sXU.js → index-BsfqdgCF.js} +1 -1
  80. package/dist/client/assets/{index-Cm3M40mu.js → index-CnGxfk10.js} +2 -2
  81. package/dist/client/assets/index-Ctm-JrdL.js +1 -0
  82. package/dist/client/assets/index-Cy9rBAOX.css +1 -0
  83. package/dist/client/assets/{index-EJkHYsSC.js → index-D0blI3XW.js} +1 -1
  84. package/dist/client/assets/{index-DR06FVTS.js → index-OwZGmo7I.js} +1 -1
  85. package/dist/client/assets/{infiniteQueryObserver-Bk6kPCGD.js → infiniteQueryObserver-eQjHgw7d.js} +1 -1
  86. package/dist/client/assets/{input-WEkqgPCx.js → input-BlxXRmnq.js} +1 -1
  87. package/dist/client/assets/{layout-DhWpZyaF.js → layout-DF2Vd6dD.js} +1 -1
  88. package/dist/client/assets/{localstorage-keys-1daarnfj.js → localstorage-keys-CYYT4Okl.js} +1 -1
  89. package/dist/client/assets/{login-C6Z0Hf-G.js → login-rMJme3Jv.js} +1 -1
  90. package/dist/client/assets/{mcp-oauth-BeGVYXYi.js → mcp-oauth-CPPdR_so.js} +1 -1
  91. package/dist/client/assets/{mcp-server-card-TH49CKyg.js → mcp-server-card-Dz6OItSH.js} +1 -1
  92. package/dist/client/assets/mcp-server-detail-CKCgTImi.js +2 -0
  93. package/dist/client/assets/members-2hnMfIOo.js +3 -0
  94. package/dist/client/assets/{monaco-editor-D62uyIRE.js → monaco-editor-DYG-izQC.js} +1 -1
  95. package/dist/client/assets/{monitoring-C8lQE18O.js → monitoring-45wfQEuI.js} +5 -5
  96. package/dist/client/assets/{oauth-callback-BRmmw_vE.js → oauth-callback-DrWbOmjU.js} +1 -1
  97. package/dist/client/assets/page-CqA3sqGx.js +1 -0
  98. package/dist/client/assets/{page-C6Z5AAxa.js → page-Dig-kXzy.js} +1 -1
  99. package/dist/client/assets/{plugin-empty-state-CiNAFBPt.js → plugin-empty-state-D_A0ZR3o.js} +1 -1
  100. package/dist/client/assets/{plugin-header-Cs7vmVyn.js → plugin-header-CICDX7I-.js} +1 -1
  101. package/dist/client/assets/{plugins-DxTFEvsx.js → plugins-Cj62SDQ2.js} +1 -1
  102. package/dist/client/assets/{popover-DyvWBt1E.js → popover-JdYFp74u.js} +1 -1
  103. package/dist/client/assets/{registry-utils-RKHarYmu.js → registry-utils-BwCYxc2h.js} +1 -1
  104. package/dist/client/assets/{resizable-DqIEdFEF.js → resizable-CRqJtbE0.js} +1 -1
  105. package/dist/client/assets/{select-DP5Dfkvv.js → select-Br1I42DX.js} +1 -1
  106. package/dist/client/assets/{settings-DW3RHdzH.js → settings-Csz6dsxM.js} +1 -1
  107. package/dist/client/assets/shell-layout-CLklIdz9.js +12 -0
  108. package/dist/client/assets/{spinner-CAgETmH3.js → spinner-BmgAJqAH.js} +1 -1
  109. package/dist/client/assets/{store-invite-DfU-qVkO.js → store-invite-DoSHlGQN.js} +1 -1
  110. package/dist/client/assets/{switch-D7U_Vekt.js → switch-CMXpi8bR.js} +1 -1
  111. package/dist/client/assets/{table-20ccyhvp.js → table-CGj3hOxZ.js} +1 -1
  112. package/dist/client/assets/{textarea-D3xU8GPb.js → textarea-Dg4rxulg.js} +1 -1
  113. package/dist/client/assets/{tools-list-DTW_RJ6B.js → tools-list-BVu0EauP.js} +1 -1
  114. package/dist/client/assets/{typewriter-title-BZWOVDcY.js → typewriter-title-bodc21io.js} +1 -1
  115. package/dist/client/assets/{use-binding-OJZZKHfM.js → use-binding-D3U0XVop.js} +1 -1
  116. package/dist/client/assets/use-connection-D8sP6Sf6.js +1 -0
  117. package/dist/client/assets/{use-create-virtual-mcp-BJbJkcpt.js → use-create-virtual-mcp-D7NmkZa5.js} +1 -1
  118. package/dist/client/assets/use-deco-chat-open-cI1K_3H4.js +23 -0
  119. package/dist/client/assets/{use-list-state--e44Cg6A.js → use-list-state-BAGJ3irz.js} +1 -1
  120. package/dist/client/assets/{use-mcp-prompts-m9itAfo1.js → use-mcp-prompts-vgmIJb9h.js} +1 -1
  121. package/dist/client/assets/use-mcp-tools-X7PZhTof.js +1 -0
  122. package/dist/client/assets/{use-mobile-BQcJDrUC.js → use-mobile-r7mBIBEK.js} +1 -1
  123. package/dist/client/assets/{use-organization-settings-DT-GwMSs.js → use-organization-settings-CdospZv2.js} +1 -1
  124. package/dist/client/assets/{use-virtual-mcp-Bib66D0T.js → use-virtual-mcp-DrasHs63.js} +1 -1
  125. package/dist/client/assets/useInfiniteQuery-CmVm1W19.js +1 -0
  126. package/dist/client/assets/{useMutation-D0FAjxJB.js → useMutation-CUbpcpQz.js} +1 -1
  127. package/dist/client/assets/useQuery-CyQI_ufp.js +1 -0
  128. package/dist/client/assets/{view-mode-toggle-e1wVUIQC.js → view-mode-toggle-C6XvJAEJ.js} +1 -1
  129. package/dist/client/assets/{workflow-Criibj7u.js → workflow-BSVWLVOc.js} +1 -1
  130. package/dist/client/index.html +2 -2
  131. package/dist/server/cli.js +192 -174
  132. package/dist/server/migrate.js +169 -157
  133. package/dist/server/server.js +168 -162
  134. package/package.json +1 -1
  135. package/dist/client/assets/agent-detail-Jt4PhiY7.js +0 -1
  136. package/dist/client/assets/collapsible-kdbIagB_.js +0 -23
  137. package/dist/client/assets/connection-detail-DtAXMJt7.js +0 -1
  138. package/dist/client/assets/connections-Cgg4Ehdx.js +0 -1
  139. package/dist/client/assets/constants-BLEeM90x.js +0 -1
  140. package/dist/client/assets/constants-CiJIPOcv.js +0 -1
  141. package/dist/client/assets/index-9jleOnNn.js +0 -1
  142. package/dist/client/assets/index-Bj5Q4dXx.css +0 -1
  143. package/dist/client/assets/index-DaLWui-m.js +0 -1
  144. package/dist/client/assets/mcp-server-detail-B5lwLhNL.js +0 -2
  145. package/dist/client/assets/members-CGC1M2Fl.js +0 -3
  146. package/dist/client/assets/page-C11n8gYY.js +0 -1
  147. package/dist/client/assets/shell-layout-DVjDk4PE.js +0 -12
  148. package/dist/client/assets/use-connection-DsOrNBOn.js +0 -1
  149. package/dist/client/assets/use-deco-chat-open-BWq3TCrl.js +0 -1
  150. package/dist/client/assets/useInfiniteQuery-DEJMvJ24.js +0 -1
  151. package/dist/client/assets/useQuery-9ftL5KuZ.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/mesh",
3
- "version": "2.65.1",
3
+ "version": "2.67.0",
4
4
  "description": "MCP Mesh - Self-hostable MCP Gateway for managing AI connections and tools",
5
5
  "author": "Deco team",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- import{r as _,j as t,b7 as ct,ak as xe,an as Ne,b6 as dt,av as mt,aV as ut,am as ft,at as pt,b8 as He,aq as xt,c as T,u as he,V as ht,s as gt,t as Oe,v as bt,a as jt,bs as vt,k as Nt,h as yt,l as Ct,ah as _t}from"./index-S9nBXez3.js";import{i as Tt,a as St,u as kt,C as wt,b as It}from"./collapsible-kdbIagB_.js";import{I as ge,T as ce,c as ye,b as de,a as me,E as Et}from"./empty-state-DCefUqf-.js";import{E as pe,i as At}from"./error-boundary-CZlFheRY.js";import{I as Ot,R as Dt,a as $t,S as Rt,P as Lt}from"./index-EJkHYsSC.js";import{u as Pt}from"./use-deco-chat-open-BWq3TCrl.js";import{B as De}from"./badge-DsLVLnaN.js";import{c as Y,B as X}from"./button-C2Npiaxw.js";import{I as Me}from"./input-WEkqgPCx.js";import{S as zt}from"./switch-D7U_Vekt.js";import{T as Vt}from"./textarea-D3xU8GPb.js";import{e as Mt,i as Ft,c as Bt}from"./use-connection-DsOrNBOn.js";import{u as Gt,a as Ht}from"./use-virtual-mcp-Bib66D0T.js";import{i as Ue}from"./ChevronRight-Cme_aOxM.js";import{n as Ut}from"./select-DP5Dfkvv.js";import{i as $e}from"./File02-3scwR97O.js";import{i as We}from"./Loading01-DuNH8QVR.js";import{i as Wt}from"./Play-CrBwr4cr.js";import{s as Fe}from"./Plus-ZDIS0vbh.js";import{i as Kt}from"./Share07-BDsQfZYE.js";import{a as Re}from"./Tool01-DoELZ-Fj.js";import{B as qt,a as Yt,b as Be,c as Jt,d as Zt,e as Qt}from"./breadcrumb-k6_ciPji.js";import{a as Xt,V as es}from"./layout-DhWpZyaF.js";import{C as ts}from"./collection-search-BT1Haqdl.js";import{C as Le}from"./checkbox-CeETLr6E.js";import{e as ss,a as Ke,D as qe,b as ls,c as os}from"./dialog-ByiIrjjH.js";import{u as Pe}from"./constants-CiJIPOcv.js";import{c as ns,u as rs}from"./use-mcp-prompts-m9itAfo1.js";import{s as Ye}from"./slugify-CEUa2lfQ.js";import{i as Je}from"./Check-DNCI8C1c.js";import{i as is}from"./Code01-DlwIBx5j.js";import{a as as}from"./Copy01-CX9SC5FE.js";import{i as Ce}from"./InfoCircle-jWdDj_pa.js";import{A as cs}from"./agent-connections-preview-C1QLXOEH.js";import"./use-binding-OJZZKHfM.js";import"./binder-AghfMQli.js";import"./localstorage-keys-1daarnfj.js";import"./useQuery-9ftL5KuZ.js";import"./useMutation-D0FAjxJB.js";import"./popover-DyvWBt1E.js";import"./ChevronDown-CmDSkkyU.js";import"./File06-BmoKv1ZA.js";import"./Grid01-CH_80p-4.js";import"./Image01-qkpxD1yj.js";import"./SearchMd-6GhPnBK1.js";import"./Pin01-CU7bB1L8.js";import"./use-organization-settings-DT-GwMSs.js";import"./index-9jleOnNn.js";import"./X-Cw8dXC6B.js";import"./infiniteQueryObserver-Bk6kPCGD.js";const Ze=({size:o=24,color:e="currentColor",...s})=>_.createElement("svg",{viewBox:"0 0 24 24",width:o,height:o,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},_.createElement("path",{d:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Z"}));Ze.displayName="Circle";const Qe=({size:o=24,color:e="currentColor",...s})=>_.createElement("svg",{viewBox:"0 0 24 24",width:o,height:o,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},_.createElement("path",{d:"M9 2v3m6-3v3M9 19v3m6-3v3m4-13h3m-3 5h3M2 9h3m-3 5h3m4.8 5h4.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C19 16.72 19 15.88 19 14.2V9.8c0-1.68 0-2.52-.327-3.162a3 3 0 0 0-1.311-1.311C16.72 5 15.88 5 14.2 5H9.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C5 7.28 5 8.12 5 9.8v4.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C7.28 19 8.12 19 9.8 19Z"}));Qe.displayName="CpuChip02";const be=({size:o=24,color:e="currentColor",...s})=>_.createElement("svg",{viewBox:"0 0 24 24",width:o,height:o,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},_.createElement("path",{d:"m9.75 20.75 1.473.818c.284.158.425.237.576.268.133.027.27.027.402 0 .15-.031.292-.11.576-.268l1.473-.818m-9-2.5-1.427-.793c-.3-.166-.45-.25-.558-.368a1 1 0 0 1-.215-.364C3 16.573 3 16.401 3 16.06V14.5m0-5V7.942c0-.343 0-.514.05-.667a1 1 0 0 1 .215-.364c.109-.119.258-.202.558-.368L5.25 5.75m4.5-2.5 1.473-.818c.284-.158.425-.237.576-.267a1 1 0 0 1 .402 0c.15.03.292.11.576.267l1.473.818m4.5 2.5 1.427.793c.3.166.45.25.558.368a1 1 0 0 1 .215.364c.05.153.05.324.05.667V9.5m0 5v1.559c0 .342 0 .514-.05.666a.999.999 0 0 1-.215.364c-.109.119-.258.202-.558.368l-1.427.793m-9-7.5L12 12m0 0 2.25-1.25M12 12v2.5M3 7l2.25 1.25m13.5 0L21 7m-9 12.5V22"}));be.displayName="CubeOutline";var je="Tabs",[ds]=xt(je,[He]),Xe=He(),[ms,ze]=ds(je),et=_.forwardRef((o,e)=>{const{__scopeTabs:s,value:r,onValueChange:l,defaultValue:n,orientation:c="horizontal",dir:i,activationMode:a="automatic",...m}=o,u=ut(i),[d,f]=ft({prop:r,onChange:l,defaultProp:n??"",caller:je});return t.jsx(ms,{scope:s,baseId:pt(),value:d,onValueChange:f,orientation:c,dir:u,activationMode:a,children:t.jsx(xe.div,{dir:u,"data-orientation":c,...m,ref:e})})});et.displayName=je;var tt="TabsList",st=_.forwardRef((o,e)=>{const{__scopeTabs:s,loop:r=!0,...l}=o,n=ze(tt,s),c=Xe(s);return t.jsx(dt,{asChild:!0,...c,orientation:n.orientation,dir:n.dir,loop:r,children:t.jsx(xe.div,{role:"tablist","aria-orientation":n.orientation,...l,ref:e})})});st.displayName=tt;var lt="TabsTrigger",ot=_.forwardRef((o,e)=>{const{__scopeTabs:s,value:r,disabled:l=!1,...n}=o,c=ze(lt,s),i=Xe(s),a=it(c.baseId,r),m=at(c.baseId,r),u=r===c.value;return t.jsx(ct,{asChild:!0,...i,focusable:!l,active:u,children:t.jsx(xe.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":m,"data-state":u?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:a,...n,ref:e,onMouseDown:Ne(o.onMouseDown,d=>{!l&&d.button===0&&d.ctrlKey===!1?c.onValueChange(r):d.preventDefault()}),onKeyDown:Ne(o.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&c.onValueChange(r)}),onFocus:Ne(o.onFocus,()=>{const d=c.activationMode!=="manual";!u&&!l&&d&&c.onValueChange(r)})})})});ot.displayName=lt;var nt="TabsContent",rt=_.forwardRef((o,e)=>{const{__scopeTabs:s,value:r,forceMount:l,children:n,...c}=o,i=ze(nt,s),a=it(i.baseId,r),m=at(i.baseId,r),u=r===i.value,d=_.useRef(u);return _.useEffect(()=>{const f=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(f)},[]),t.jsx(mt,{present:l||u,children:({present:f})=>t.jsx(xe.div,{"data-state":u?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":a,hidden:!f,id:m,tabIndex:0,...c,ref:e,style:{...o.style,animationDuration:d.current?"0s":void 0},children:f&&n})})});rt.displayName=nt;function it(o,e){return`${o}-trigger-${e}`}function at(o,e){return`${o}-content-${e}`}var us=et,fs=st,ps=ot,xs=rt;function hs(o){const e=T.c(10);let s,r,l;e[0]!==o?({className:s,variant:l,...r}=o,e[0]=o,e[1]=s,e[2]=r,e[3]=l):(s=e[1],r=e[2],l=e[3]);const n=l===void 0?"pill":l;let c;e[4]!==s?(c=Y("flex flex-col gap-2",s),e[4]=s,e[5]=c):c=e[5];let i;return e[6]!==r||e[7]!==c||e[8]!==n?(i=t.jsx(us,{"data-slot":"tabs","data-variant":n,className:c,...r}),e[6]=r,e[7]=c,e[8]=n,e[9]=i):i=e[9],i}function gs(o){const e=T.c(11);let s,r,l;e[0]!==o?({className:s,variant:l,...r}=o,e[0]=o,e[1]=s,e[2]=r,e[3]=l):(s=e[1],r=e[2],l=e[3]);const n=l||"pill",c=n==="underline"?"flex h-[52px] items-center border-b border-border":n==="canvas"?"flex h-10 items-center bg-background relative":"bg-muted text-muted-foreground inline-flex h-10 w-fit items-center justify-center rounded-xl p-[3px]";let i;e[4]!==s||e[5]!==c?(i=Y(c,s),e[4]=s,e[5]=c,e[6]=i):i=e[6];let a;return e[7]!==n||e[8]!==r||e[9]!==i?(a=t.jsx(fs,{"data-slot":"tabs-list","data-variant":n,className:i,...r}),e[7]=n,e[8]=r,e[9]=i,e[10]=a):a=e[10],a}function _e(o){const e=T.c(11);let s,r,l;e[0]!==o?({className:s,variant:l,...r}=o,e[0]=o,e[1]=s,e[2]=r,e[3]=l):(s=e[1],r=e[2],l=e[3]);const n=l||"pill",c=n==="underline"?"cursor-pointer flex items-center h-full px-3 relative text-sm whitespace-nowrap border-b-2 mb-[-1px] transition-all text-muted-foreground border-transparent hover:text-foreground data-[state=active]:text-foreground data-[state=active]:border-foreground disabled:pointer-events-none disabled:opacity-50":n==="canvas"?"cursor-pointer flex items-center h-full px-3 gap-2.5 text-sm whitespace-nowrap transition-all border-r border-b border-border [&>*]:opacity-50 data-[state=active]:[&>*]:opacity-100 data-[state=active]:border-b-0 last:border-r-0 disabled:pointer-events-none max-w-2xs":"data-[state=active]:bg-background dark:data-[state=active]:text-foreground cursor-pointer focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-lg border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4";let i;e[4]!==s||e[5]!==c?(i=Y(c,s),e[4]=s,e[5]=c,e[6]=i):i=e[6];let a;return e[7]!==n||e[8]!==r||e[9]!==i?(a=t.jsx(ps,{"data-slot":"tabs-trigger","data-variant":n,className:i,...r}),e[7]=n,e[8]=r,e[9]=i,e[10]=a):a=e[10],a}function Te(o){const e=T.c(8);let s,r;e[0]!==o?({className:s,...r}=o,e[0]=o,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let l;e[3]!==s?(l=Y("flex-1 outline-none h-full",s),e[3]=s,e[4]=l):l=e[4];let n;return e[5]!==r||e[6]!==l?(n=t.jsx(xs,{"data-slot":"tabs-content",className:l,...r}),e[5]=r,e[6]=l,e[7]=n):n=e[7],n}function Se(o){return o===null?"all":o?.length??0}function bs(o,e){const s=o[e];if(!s)return"";const r=[];return s.tools===null?r.push("all tools"):s.tools&&s.tools.length>0&&r.push(`${s.tools.length} tools`),s.resources===null?r.push("all resources"):s.resources&&s.resources.length>0&&r.push(`${s.resources.length} resources`),s.prompts===null?r.push("all prompts"):s.prompts&&s.prompts.length>0&&r.push(`${s.prompts.length} prompts`),r.join(", ")}function js(o,e){const s=o[e];return s?!((s.tools===void 0||s.tools!==null&&s.tools.length===0)&&(s.resources===void 0||s.resources!==null&&s.resources.length===0)&&(s.prompts===void 0||s.prompts!==null&&s.prompts.length===0)):!1}const vs={tools:null,resources:null,prompts:null};function ke(){const o=T.c(1);let e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("div",{className:"flex items-center justify-center h-32",children:t.jsx(We,{className:"animate-spin text-muted-foreground",size:24})}),o[0]=e):e=o[0],e}function we(o){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?t.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:t.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}):t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[t.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:t.jsx(At,{className:"h-6 w-6 text-destructive"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),t.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 Ns(o){const e=T.c(18),{item:s,isSelected:r,onToggle:l,disabled:n}=o,c=n?"cursor-not-allowed opacity-50":"cursor-pointer",i=r?"bg-accent/25":"hover:bg-muted/50";let a;e[0]!==c||e[1]!==i?(a=Y("flex items-start gap-3 p-4 rounded-lg transition-colors",c,i),e[0]=c,e[1]=i,e[2]=a):a=e[2];let m;e[3]!==s.name?(m=t.jsx("p",{className:"text-sm font-medium leading-none",children:s.name}),e[3]=s.name,e[4]=m):m=e[4];let u;e[5]!==s.description?(u=s.description&&t.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[5]=s.description,e[6]=u):u=e[6];let d;e[7]!==m||e[8]!==u?(d=t.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[m,u]}),e[7]=m,e[8]=u,e[9]=d):d=e[9];let f;e[10]!==n||e[11]!==r||e[12]!==l?(f=t.jsx(Le,{checked:r,onCheckedChange:l,disabled:n,className:"mt-0.5"}),e[10]=n,e[11]=r,e[12]=l,e[13]=f):f=e[13];let h;return e[14]!==a||e[15]!==d||e[16]!==f?(h=t.jsxs("label",{className:a,children:[d,f]}),e[14]=a,e[15]=d,e[16]=f,e[17]=h):h=e[17],h}function Ve(o){const e=T.c(32),{items:s,selections:r,onToggle:l,onToggleAll:n,emptyMessage:c,disabled:i}=o;let a,m,u,d,f;if(e[0]!==i||e[1]!==c||e[2]!==s||e[3]!==l||e[4]!==n||e[5]!==r){f=Symbol.for("react.early_return_sentinel");e:{const p=s.map(ys);if(s.length===0){let C;e[11]!==c?(C=t.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:t.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:c})}),e[11]=c,e[12]=C):C=e[12],f=C;break e}u="flex flex-col h-full";const N=i?"cursor-not-allowed opacity-50":"cursor-pointer";let j;e[13]!==N?(j=Y("flex items-start gap-3 p-4",N),e[13]=N,e[14]=j):j=e[14];let v;e[15]!==s.length?(v=t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("span",{className:"text-sm font-medium",children:["Select All (",s.length,")"]})}),e[15]=s.length,e[16]=v):v=e[16];const g=r===null;let y;e[17]!==i||e[18]!==n||e[19]!==g?(y=t.jsx(Le,{checked:g,onCheckedChange:n,disabled:i,className:"mt-0.5"}),e[17]=i,e[18]=n,e[19]=g,e[20]=y):y=e[20],e[21]!==y||e[22]!==j||e[23]!==v?(d=t.jsx("div",{className:"px-4 border-b border-border shrink-0",children:t.jsxs("label",{className:j,children:[v,y]})}),e[21]=y,e[22]=j,e[23]=v,e[24]=d):d=e[24],a="flex-1 overflow-auto px-4 py-3 space-y-1",m=s.map(C=>t.jsx(Ns,{item:C,isSelected:r===null||r?.includes(C.id),onToggle:()=>l(C.id,p),disabled:i},C.id))}e[0]=i,e[1]=c,e[2]=s,e[3]=l,e[4]=n,e[5]=r,e[6]=a,e[7]=m,e[8]=u,e[9]=d,e[10]=f}else a=e[6],m=e[7],u=e[8],d=e[9],f=e[10];if(f!==Symbol.for("react.early_return_sentinel"))return f;let h;e[25]!==a||e[26]!==m?(h=t.jsx("div",{className:a,children:m}),e[25]=a,e[26]=m,e[27]=h):h=e[27];let x;return e[28]!==u||e[29]!==d||e[30]!==h?(x=t.jsxs("div",{className:u,children:[d,h]}),e[28]=u,e[29]=d,e[30]=h,e[31]=x):x=e[31],x}function ys(o){return o.id}function Cs(o){const e=T.c(13),{connectionId:s,selections:r,onToggle:l,onToggleAll:n,disabled:c}=o,{org:i}=he();let a;e[0]!==s||e[1]!==i.id?(a={connectionId:s,orgId:i.id},e[0]=s,e[1]=i.id,e[2]=a):a=e[2];const m=Pe(a);let u;e[3]!==m?(u={client:m},e[3]=m,e[4]=u):u=e[4];const{data:d}=Ft(u);let f;e[5]!==d.tools?(f=d.tools.map(_s),e[5]=d.tools,e[6]=f):f=e[6];const h=f;let x;return e[7]!==c||e[8]!==h||e[9]!==l||e[10]!==n||e[11]!==r?(x=t.jsx(Ve,{items:h,selections:r,onToggle:l,onToggleAll:n,emptyMessage:"No tools available",disabled:c}),e[7]=c,e[8]=h,e[9]=l,e[10]=n,e[11]=r,e[12]=x):x=e[12],x}function _s(o){return{id:o.name,name:o.name,description:o.description}}function Ts(o){const e=T.c(13),{connectionId:s,selections:r,onToggle:l,onToggleAll:n,disabled:c}=o,{org:i}=he();let a;e[0]!==s||e[1]!==i.id?(a={connectionId:s,orgId:i.id},e[0]=s,e[1]=i.id,e[2]=a):a=e[2];const m=Pe(a);let u;e[3]!==m?(u={client:m},e[3]=m,e[4]=u):u=e[4];const{data:d}=ns(u);let f;e[5]!==d.resources?(f=d.resources.map(Ss),e[5]=d.resources,e[6]=f):f=e[6];const h=f;let x;return e[7]!==c||e[8]!==h||e[9]!==l||e[10]!==n||e[11]!==r?(x=t.jsx(Ve,{items:h,selections:r,onToggle:l,onToggleAll:n,emptyMessage:"No resources available",disabled:c}),e[7]=c,e[8]=h,e[9]=l,e[10]=n,e[11]=r,e[12]=x):x=e[12],x}function Ss(o){return{id:o.name||o.uri,name:o.name||o.uri,description:o.description}}function ks(o){const e=T.c(13),{connectionId:s,selections:r,onToggle:l,onToggleAll:n,disabled:c}=o,{org:i}=he();let a;e[0]!==s||e[1]!==i.id?(a={connectionId:s,orgId:i.id},e[0]=s,e[1]=i.id,e[2]=a):a=e[2];const m=Pe(a);let u;e[3]!==m?(u={client:m},e[3]=m,e[4]=u):u=e[4];const{data:d}=rs(u);let f;e[5]!==d.prompts?(f=d.prompts.map(ws),e[5]=d.prompts,e[6]=f):f=e[6];const h=f;let x;return e[7]!==c||e[8]!==h||e[9]!==l||e[10]!==n||e[11]!==r?(x=t.jsx(Ve,{items:h,selections:r,onToggle:l,onToggleAll:n,emptyMessage:"No prompts available",disabled:c}),e[7]=c,e[8]=h,e[9]=l,e[10]=n,e[11]=r,e[12]=x):x=e[12],x}function ws(o){return{id:o.name,name:o.name,description:o.description}}function Is(o){const e=T.c(24),{connection:s,isSelected:r,hasSelections:l,summary:n,onClick:c,onToggleAll:i,disabled:a}=o,m=a?"cursor-not-allowed opacity-50":"cursor-pointer",u=r?"bg-accent":"hover:bg-muted/50";let d;e[0]!==m||e[1]!==u?(d=Y("flex items-center gap-2 p-2 h-12 rounded-lg transition-colors",m,u),e[0]=m,e[1]=u,e[2]=d):d=e[2];const f=a?void 0:c;let h;e[3]!==s.icon||e[4]!==s.title?(h=t.jsx(ge,{icon:s.icon,name:s.title,size:"xs",className:"shrink-0"}),e[3]=s.icon,e[4]=s.title,e[5]=h):h=e[5];let x;e[6]!==s.title?(x=t.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:s.title}),e[6]=s.title,e[7]=x):x=e[7];let p;e[8]!==l||e[9]!==n?(p=l&&n&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n}),e[8]=l,e[9]=n,e[10]=p):p=e[10];let N;e[11]!==x||e[12]!==p?(N=t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center",children:[x,p]}),e[11]=x,e[12]=p,e[13]=N):N=e[13];let j;e[14]!==a||e[15]!==l||e[16]!==i?(j=t.jsx(Le,{checked:l,onCheckedChange:i,onClick:Es,disabled:a,className:"shrink-0"}),e[14]=a,e[15]=l,e[16]=i,e[17]=j):j=e[17];let v;return e[18]!==d||e[19]!==f||e[20]!==h||e[21]!==N||e[22]!==j?(v=t.jsxs("div",{className:d,onClick:f,children:[h,N,j]}),e[18]=d,e[19]=f,e[20]=h,e[21]=N,e[22]=j,e[23]=v):v=e[23],v}function Es(o){return o.stopPropagation()}function As(o){const e=T.c(22),{allConnections:s,searchTerm:r,selectedId:l,hasSelections:n,getSelectionSummary:c,onConnectionClick:i,onToggleAll:a,disabled:m}=o;let u;e[0]!==s||e[1]!==r?(u=r?s.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())||x.description?.toLowerCase().includes(r.toLowerCase())):s,e[0]=s,e[1]=r,e[2]=u):u=e[2];const d=u;if(d.length===0){const x=r?"No connections found":"No connections available";let p;return e[3]!==x?(p=t.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground p-4",children:x}),e[3]=x,e[4]=p):p=e[4],p}let f;if(e[5]!==m||e[6]!==d||e[7]!==c||e[8]!==n||e[9]!==i||e[10]!==a||e[11]!==l){let x;e[13]!==m||e[14]!==c||e[15]!==n||e[16]!==i||e[17]!==a||e[18]!==l?(x=p=>t.jsx(Is,{connection:p,isSelected:l===p.id,hasSelections:n(p.id),summary:c(p.id),onClick:()=>i(p.id),onToggleAll:()=>a(p.id),disabled:m},p.id),e[13]=m,e[14]=c,e[15]=n,e[16]=i,e[17]=a,e[18]=l,e[19]=x):x=e[19],f=d.map(x),e[5]=m,e[6]=d,e[7]=c,e[8]=n,e[9]=i,e[10]=a,e[11]=l,e[12]=f}else f=e[12];let h;return e[20]!==f?(h=t.jsx("div",{className:"flex flex-col gap-0.5",children:f}),e[20]=f,e[21]=h):h=e[21],h}function Os(o){const e=T.c(75),{currentConnection:s,activeTab:r,selectedId:l,formData:n,toggleTool:c,toggleResource:i,togglePrompt:a,toggleAllTools:m,toggleAllResources:u,toggleAllPrompts:d,onTabChange:f}=o;let h;e[0]!==s.icon||e[1]!==s.title?(h=t.jsx(ge,{icon:s.icon,name:s.title,size:"md",className:"shrink-0"}),e[0]=s.icon,e[1]=s.title,e[2]=h):h=e[2];let x;e[3]!==s.title?(x=t.jsx("h2",{className:"text-lg font-semibold truncate",children:s.title}),e[3]=s.title,e[4]=x):x=e[4];let p;e[5]!==s.description?(p=s.description&&t.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.description}),e[5]=s.description,e[6]=p):p=e[6];let N;e[7]!==x||e[8]!==p?(N=t.jsxs("div",{className:"flex-1 min-w-0",children:[x,p]}),e[7]=x,e[8]=p,e[9]=N):N=e[9];let j;e[10]!==h||e[11]!==N?(j=t.jsx("div",{className:"p-6 border-b border-border shrink-0",children:t.jsxs("div",{className:"flex items-center gap-3",children:[h,N]})}),e[10]=h,e[11]=N,e[12]=j):j=e[12];let v;e[13]!==f?(v=F=>f(F),e[13]=f,e[14]=v):v=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsxs(_e,{value:"tools",variant:"underline",className:"gap-2",children:[t.jsx(Re,{size:16}),"Tools"]}),e[15]=g):g=e[15];let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsxs(_e,{value:"resources",variant:"underline",className:"gap-2",children:[t.jsx(be,{size:16}),"Resources"]}),e[16]=y):y=e[16];let C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsxs(gs,{variant:"underline",className:"shrink-0 px-6",children:[g,y,t.jsxs(_e,{value:"prompts",variant:"underline",className:"gap-2",children:[t.jsx($e,{size:16}),"Prompts"]})]}),e[17]=C):C=e[17];let z;e[18]===Symbol.for("react.memo_cache_sentinel")?(z=we("Tools not supported by this server"),e[18]=z):z=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(ke,{}),e[19]=k):k=e[19];let O;e[20]!==n||e[21]!==l?(O=n[l]?n[l].tools:[],e[20]=n,e[21]=l,e[22]=O):O=e[22];let S;e[23]!==l||e[24]!==c?(S=(F,Z)=>c(l,F,Z),e[23]=l,e[24]=c,e[25]=S):S=e[25];let w;e[26]!==l||e[27]!==m?(w=()=>m(l),e[26]=l,e[27]=m,e[28]=w):w=e[28];let E;e[29]!==l||e[30]!==O||e[31]!==S||e[32]!==w?(E=t.jsx(Te,{value:"tools",className:"flex-1 overflow-hidden mt-0",children:t.jsx(pe,{fallback:z,children:t.jsx(_.Suspense,{fallback:k,children:t.jsx(Cs,{connectionId:l,selections:O,onToggle:S,onToggleAll:w})})})}),e[29]=l,e[30]=O,e[31]=S,e[32]=w,e[33]=E):E=e[33];let D;e[34]===Symbol.for("react.memo_cache_sentinel")?(D=we("Resources not supported by this server"),e[34]=D):D=e[34];let L;e[35]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(ke,{}),e[35]=L):L=e[35];let I;e[36]!==n||e[37]!==l?(I=n[l]?n[l].resources:[],e[36]=n,e[37]=l,e[38]=I):I=e[38];let A;e[39]!==l||e[40]!==i?(A=(F,Z)=>i(l,F,Z),e[39]=l,e[40]=i,e[41]=A):A=e[41];let $;e[42]!==l||e[43]!==u?($=()=>u(l),e[42]=l,e[43]=u,e[44]=$):$=e[44];let P;e[45]!==l||e[46]!==I||e[47]!==A||e[48]!==$?(P=t.jsx(Te,{value:"resources",className:"flex-1 overflow-hidden mt-0",children:t.jsx(pe,{fallback:D,children:t.jsx(_.Suspense,{fallback:L,children:t.jsx(Ts,{connectionId:l,selections:I,onToggle:A,onToggleAll:$})})})}),e[45]=l,e[46]=I,e[47]=A,e[48]=$,e[49]=P):P=e[49];let q;e[50]===Symbol.for("react.memo_cache_sentinel")?(q=we("Prompts not supported by this server"),e[50]=q):q=e[50];let J;e[51]===Symbol.for("react.memo_cache_sentinel")?(J=t.jsx(ke,{}),e[51]=J):J=e[51];let B;e[52]!==n||e[53]!==l?(B=n[l]?n[l].prompts:[],e[52]=n,e[53]=l,e[54]=B):B=e[54];let W;e[55]!==l||e[56]!==a?(W=(F,Z)=>a(l,F,Z),e[55]=l,e[56]=a,e[57]=W):W=e[57];let G;e[58]!==l||e[59]!==d?(G=()=>d(l),e[58]=l,e[59]=d,e[60]=G):G=e[60];let K;e[61]!==l||e[62]!==B||e[63]!==W||e[64]!==G?(K=t.jsx(Te,{value:"prompts",className:"flex-1 overflow-hidden mt-0",children:t.jsx(pe,{fallback:q,children:t.jsx(_.Suspense,{fallback:J,children:t.jsx(ks,{connectionId:l,selections:B,onToggle:W,onToggleAll:G})})})}),e[61]=l,e[62]=B,e[63]=W,e[64]=G,e[65]=K):K=e[65];let H;e[66]!==r||e[67]!==E||e[68]!==P||e[69]!==K||e[70]!==v?(H=t.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:t.jsxs(hs,{value:r,onValueChange:v,variant:"underline",className:"flex-1 flex flex-col overflow-hidden",children:[C,E,P,K]})}),e[66]=r,e[67]=E,e[68]=P,e[69]=K,e[70]=v,e[71]=H):H=e[71];let U;return e[72]!==H||e[73]!==j?(U=t.jsxs(t.Fragment,{children:[j,H]}),e[72]=H,e[73]=j,e[74]=U):U=e[74],U}function Ds(o){const e={};for(const s of o)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function Ie(o){return Object.entries(o).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function $s(o,e){switch(e.type){case"SET_SEARCH_TERM":return{...o,searchTerm:e.payload};case"SET_SELECTED":return{...o,selectedId:e.payload};case"SET_ACTIVE_TAB":return{...o,activeTab:e.payload};case"RESET":return{searchTerm:"",selectedId:e.payload.selectedId??e.payload.firstConnectionId??null,activeTab:"tools"};case"SELECT_CONNECTION":return{...o,selectedId:e.payload,activeTab:"tools"};default:return o}}const Ge=(o,e)=>o.find(s=>s.id===e)??o[0];function Rs(o){const e=T.c(79),{open:s,onOpenChange:r,selectedId:l,form:n,connections:c}=o;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];const a=Mt(i);let m;e[1]!==a||e[2]!==l?(m=Ge(a,l)?.id??null,e[1]=a,e[2]=l,e[3]=m):m=e[3];let u;e[4]!==m?(u={activeTab:"tools",searchTerm:"",selectedId:m},e[4]=m,e[5]=u):u=e[5];const[d,f]=_.useReducer($s,u);let h;e[6]!==c?(h=c??[],e[6]=c,e[7]=h):h=e[7];let x;e[8]!==h?(x=Ds(h),e[8]=h,e[9]=x):x=e[9];const p=x;let N;e[10]!==a||e[11]!==d.selectedId?(N=Ge(a,d.selectedId),e[10]=a,e[11]=d.selectedId,e[12]=N):N=e[12];const j=N;let v;e[13]!==p?(v=b=>js(p,b),e[13]=p,e[14]=v):v=e[14];const g=v;let y;e[15]!==p?(y=b=>bs(p,b),e[15]=p,e[16]=y):y=e[16];const C=y;let z;e[17]!==n||e[18]!==p?(z=(b,R,V,Q)=>{const ie=p[b]?.[R];let M;ie===null?M=Q.filter(ve=>ve!==V):ie?.includes(V)?M=ie.filter(ve=>ve!==V):(M=[...ie??[],V],M.length===Q.length&&(M=null));const ae={...p};ae[b]?ae[b]={...ae[b]}:ae[b]={tools:null,resources:null,prompts:null},ae[b][R]=M,n.setValue("connections",Ie(ae),{shouldDirty:!0,shouldTouch:!0})},e[17]=n,e[18]=p,e[19]=z):z=e[19];const k=z;let O;e[20]!==n||e[21]!==p?(O=(b,R)=>{const ie=p[b]?.[R]===null?[]:null,M={...p};M[b]?M[b]={...M[b]}:M[b]={tools:null,resources:null,prompts:null},M[b][R]=ie,n.setValue("connections",Ie(M),{shouldDirty:!0,shouldTouch:!0})},e[20]=n,e[21]=p,e[22]=O):O=e[22];const S=O;let w;e[23]!==k?(w=(b,R,V)=>k(b,"tools",R,V),e[23]=k,e[24]=w):w=e[24];const E=w;let D;e[25]!==k?(D=(b,R,V)=>k(b,"resources",R,V),e[25]=k,e[26]=D):D=e[26];const L=D;let I;e[27]!==k?(I=(b,R,V)=>k(b,"prompts",R,V),e[27]=k,e[28]=I):I=e[28];const A=I;let $;e[29]!==S?($=b=>S(b,"tools"),e[29]=S,e[30]=$):$=e[30];const P=$;let q;e[31]!==S?(q=b=>S(b,"resources"),e[31]=S,e[32]=q):q=e[32];const J=q;let B;e[33]!==S?(B=b=>S(b,"prompts"),e[33]=S,e[34]=B):B=e[34];const W=B;let G;e[35]!==n||e[36]!==p?(G=b=>{const R=p[b],V=R&&R.tools===null&&R.resources===null&&R.prompts===null,Q={...p};V?delete Q[b]:Q[b]=vs,n.setValue("connections",Ie(Q),{shouldDirty:!0,shouldTouch:!0})},e[35]=n,e[36]=p,e[37]=G):G=e[37];const K=G;let H;e[38]!==a||e[39]!==r||e[40]!==l?(H=b=>{b&&f({type:"RESET",payload:{selectedId:l,firstConnectionId:a[0]?.id??null}}),r(b)},e[38]=a,e[39]=r,e[40]=l,e[41]=H):H=e[41];const U=H;let F;e[42]===Symbol.for("react.memo_cache_sentinel")?(F=b=>{f({type:"SELECT_CONNECTION",payload:b})},e[42]=F):F=e[42];const Z=F;let ue;e[43]===Symbol.for("react.memo_cache_sentinel")?(ue=b=>f({type:"SET_SEARCH_TERM",payload:b}),e[43]=ue):ue=e[43];let ee;e[44]!==d.searchTerm?(ee=t.jsx(ts,{value:d.searchTerm,onChange:ue,placeholder:"Search connections..."}),e[44]=d.searchTerm,e[45]=ee):ee=e[45];let te;e[46]!==a||e[47]!==d.searchTerm||e[48]!==d.selectedId||e[49]!==C||e[50]!==g||e[51]!==K?(te=t.jsx("div",{className:"flex-1 overflow-auto p-2",children:t.jsx(As,{allConnections:a,searchTerm:d.searchTerm,selectedId:d.selectedId,hasSelections:g,getSelectionSummary:C,onConnectionClick:Z,onToggleAll:K})}),e[46]=a,e[47]=d.searchTerm,e[48]=d.selectedId,e[49]=C,e[50]=g,e[51]=K,e[52]=te):te=e[52];let se;e[53]!==ee||e[54]!==te?(se=t.jsxs("div",{className:"w-full sm:w-72 sm:border-r border-b sm:border-b-0 border-border flex flex-col bg-background sm:h-full max-h-[40vh] sm:max-h-full",children:[ee,te]}),e[53]=ee,e[54]=te,e[55]=se):se=e[55];let le;e[56]!==j||e[57]!==d.activeTab||e[58]!==d.selectedId||e[59]!==p||e[60]!==W||e[61]!==J||e[62]!==P||e[63]!==A||e[64]!==L||e[65]!==E?(le=t.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:j&&d.selectedId?t.jsx(Os,{currentConnection:j,activeTab:d.activeTab,selectedId:d.selectedId,formData:p,toggleTool:E,toggleResource:L,togglePrompt:A,toggleAllTools:P,toggleAllResources:J,toggleAllPrompts:W,onTabChange:b=>f({type:"SET_ACTIVE_TAB",payload:b})},d.selectedId):t.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Select a connection to view its tools, resources, and prompts"})}),e[56]=j,e[57]=d.activeTab,e[58]=d.selectedId,e[59]=p,e[60]=W,e[61]=J,e[62]=P,e[63]=A,e[64]=L,e[65]=E,e[66]=le):le=e[66];let oe;e[67]!==se||e[68]!==le?(oe=t.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0 flex-col sm:flex-row",children:[se,le]}),e[67]=se,e[68]=le,e[69]=oe):oe=e[69];let ne;e[70]!==U?(ne=t.jsx(ss,{className:"px-6 py-4 border-t border-border shrink-0",children:t.jsx(X,{variant:"outline",onClick:()=>U(!1),children:"Done"})}),e[70]=U,e[71]=ne):ne=e[71];let re;e[72]!==oe||e[73]!==ne?(re=t.jsxs(Ke,{className:"sm:max-w-5xl h-[80vh] max-h-[80vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[oe,ne]}),e[72]=oe,e[73]=ne,e[74]=re):re=e[74];let fe;return e[75]!==U||e[76]!==s||e[77]!==re?(fe=t.jsx(qe,{open:s,onOpenChange:U,children:re}),e[75]=U,e[76]=s,e[77]=re,e[78]=fe):fe=e[78],fe}const Ls=ht.pick({title:!0,description:!0,status:!0,metadata:!0,connections:!0}).extend({title:gt().min(1,"Name is required").max(255)});function Ps(o){const e=T.c(8);let s,r;e[0]!==o?({className:s,...r}=o,e[0]=o,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let l;e[3]!==s?(l=Y("grid gap-3",s),e[3]=s,e[4]=l):l=e[4];let n;return e[5]!==r||e[6]!==l?(n=t.jsx(Dt,{"data-slot":"radio-group",className:l,...r}),e[5]=r,e[6]=l,e[7]=n):n=e[7],n}function Ee(o){const e=T.c(9);let s,r;e[0]!==o?({className:s,...r}=o,e[0]=o,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let l;e[3]!==s?(l=Y("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",s),e[3]=s,e[4]=l):l=e[4];let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx($t,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:t.jsx(Ze,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})}),e[5]=n):n=e[5];let c;return e[6]!==r||e[7]!==l?(c=t.jsx(Ot,{"data-slot":"radio-group-item",className:l,...r,children:n}),e[6]=r,e[7]=l,e[8]=c):c=e[8],c}function zs(o){const s=new TextEncoder().encode(o),r=Array.from(s,l=>String.fromCharCode(l)).join("");return btoa(r)}function Vs(o){const e=T.c(10),{url:s}=o,[r,l]=_.useState(!1);let n;e[0]!==s?(n=async()=>{await navigator.clipboard.writeText(s),l(!0),Oe.success("Agent URL copied to clipboard"),setTimeout(()=>l(!1),2e3)},e[0]=s,e[1]=n):n=e[1];const c=n;let i;e[2]!==r?(i=r?t.jsx(Je,{size:20,className:"text-green-600"}):t.jsx(as,{size:20}),e[2]=r,e[3]=i):i=e[3];const a=r?"Copied!":"Copy URL";let m;e[4]!==a?(m=t.jsx("span",{className:"text-xs font-medium",children:a}),e[4]=a,e[5]=m):m=e[5];let u;return e[6]!==c||e[7]!==i||e[8]!==m?(u=t.jsxs(X,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[i,m]}),e[6]=c,e[7]=i,e[8]=m,e[9]=u):u=e[9],u}function Ms(o){const e=T.c(7),{url:s,serverName:r}=o;let l;e[0]!==r||e[1]!==s?(l=()=>{const m=Ye(r),d=zs(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),f=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(m)}&config=${encodeURIComponent(d)}`;window.open(f,"_blank"),Oe.success("Opening Cursor...")},e[0]=r,e[1]=s,e[2]=l):l=e[2];const n=l;let c,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=t.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%)"}}),i=t.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[3]=c,e[4]=i):(c=e[3],i=e[4]);let a;return e[5]!==n?(a=t.jsxs(X,{type:"button",variant:"outline",onClick:n,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,i]}),e[5]=n,e[6]=a):a=e[6],a}function Fs(o){const e=T.c(11),{url:s,serverName:r}=o,[l,n]=_.useState(!1);let c;e[0]!==r||e[1]!==s?(c=async()=>{const f=Ye(r),x=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),p=`claude mcp add-json "${f}" '${x.replace(/'/g,"'\\''")}'`;await navigator.clipboard.writeText(p),n(!0),Oe.success("Claude Code command copied to clipboard"),setTimeout(()=>n(!1),2e3)},e[0]=r,e[1]=s,e[2]=c):c=e[2];const i=c;let a;e[3]!==l?(a=l?t.jsx(Je,{size:20,className:"text-green-600"}):t.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[3]=l,e[4]=a):a=e[4];const m=l?"Copied!":"Install on Claude";let u;e[5]!==m?(u=t.jsx("span",{className:"text-xs font-medium",children:m}),e[5]=m,e[6]=u):u=e[6];let d;return e[7]!==i||e[8]!==a||e[9]!==u?(d=t.jsxs(X,{type:"button",variant:"outline",onClick:i,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[a,u]}),e[7]=i,e[8]=a,e[9]=u,e[10]=d):d=e[10],d}function Bs(o){const e=T.c(40),{open:s,onOpenChange:r,virtualMcp:l}=o,[n,c]=_.useState("code_execution");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=P=>{(P==="passthrough"||P==="smart_tool_selection"||P==="code_execution")&&c(P)},e[0]=i):i=e[0];const a=i;let m;e[1]!==n||e[2]!==l.id?(m=new URL(`/mcp/virtual-mcp/${l.id}`,window.location.origin),m.searchParams.set("mode",n),e[1]=n,e[2]=l.id,e[3]=m):m=e[3];let u;e[4]!==l.id||e[5]!==l.title?(u=l.title||`agent-${l.id?.slice(0,8)??"default"}`,e[4]=l.id,e[5]=l.title,e[6]=u):u=e[6];const d=u;let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(ls,{children:t.jsx(os,{children:"Share Agent"})}),e[7]=f):f=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("div",{children:t.jsx("h4",{className:"text-sm font-medium text-foreground mt-1",children:"How should this agent work?"})}),e[8]=h):h=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("div",{className:"p-1.5 shrink-0",children:t.jsx(Tt,{className:"size-5 text-muted-foreground"})}),e[9]=x):x=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Direct access"}),e[10]=p):p=e[10];let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(ce,{asChild:!0,children:t.jsx(Ce,{className:"size-3.5 text-muted-foreground"})}),e[11]=N):N=e[11];let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsxs("label",{htmlFor:"mode-passthrough",className:"flex items-center gap-3 px-3 py-5 rounded-lg border border-border hover:border-ring/50 cursor-pointer transition-colors has-checked:border-ring has-checked:bg-accent/5",children:[x,t.jsxs("div",{className:"flex-1 flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[p,t.jsx(ye,{children:t.jsxs(de,{children:[N,t.jsx(me,{className:"max-w-xs",children:t.jsx("p",{className:"text-xs",children:"All tools are exposed directly via tools/list. Best for small tool surfaces with deterministic behavior."})})]})})]}),t.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Best for small teams or when you need predictable behavior"})]}),t.jsx(Ee,{id:"mode-passthrough",value:"passthrough"})]}),e[12]=j):j=e[12];let v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx("div",{className:"p-1.5 shrink-0",children:t.jsx(St,{className:"size-5 text-muted-foreground"})}),e[13]=v):v=e[13];let g;e[14]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Smart discovery"}),e[14]=g):g=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(ce,{asChild:!0,children:t.jsx(Ce,{className:"size-3.5 text-muted-foreground"})}),e[15]=y):y=e[15];let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsxs("label",{htmlFor:"mode-smart",className:"flex items-center gap-3 px-3 py-5 rounded-lg border border-border hover:border-ring/50 cursor-pointer transition-colors has-checked:border-ring has-checked:bg-accent/5",children:[v,t.jsxs("div",{className:"flex-1 flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[g,t.jsx(ye,{children:t.jsxs(de,{children:[y,t.jsx(me,{className:"max-w-xs",children:t.jsx("p",{className:"text-xs",children:"Uses meta-tools (GATEWAY_SEARCH_TOOLS, GATEWAY_DESCRIBE_TOOLS, GATEWAY_CALL_TOOL) to keep the tool list small and request details on demand."})})]})})]}),t.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Ideal for large teams with many tools - AI finds what it needs"})]}),t.jsx(Ee,{id:"mode-smart",value:"smart_tool_selection"})]}),e[16]=C):C=e[16];let z;e[17]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("div",{className:"p-1.5 shrink-0",children:t.jsx(is,{className:"size-5 text-muted-foreground"})}),e[17]=z):z=e[17];let k;e[18]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Smart execution"}),e[18]=k):k=e[18];let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(ce,{asChild:!0,children:t.jsx(Ce,{className:"size-3.5 text-muted-foreground"})}),e[19]=O):O=e[19];let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsxs("label",{htmlFor:"mode-code",className:"relative flex items-center gap-3 px-3 py-5 rounded-lg border border-border hover:border-ring/50 cursor-pointer transition-colors has-checked:border-ring has-checked:bg-accent/5",children:[z,t.jsxs("div",{className:"flex-1 flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[k,t.jsx(ye,{children:t.jsxs(de,{children:[O,t.jsx(me,{className:"max-w-xs",children:t.jsx("p",{className:"text-xs",children:"Exposes meta-tools for discovery + sandboxed execution (GATEWAY_RUN_CODE). Reduces overhead on large surfaces by shifting work into a controlled runtime."})})]})})]}),t.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Maximum flexibility - AI can write code to orchestrate tools"})]}),t.jsx(Ee,{id:"mode-code",value:"code_execution"}),t.jsx(De,{variant:"outline",className:"absolute -top-2.5 left-1/2 -translate-x-1/2 bg-background z-10",children:"Recommended"})]}),e[20]=S):S=e[20];let w;e[21]!==n?(w=t.jsxs("div",{className:"flex flex-col gap-3",children:[h,t.jsxs(Ps,{value:n,onValueChange:a,className:"flex flex-col gap-4.5",children:[j,C,S]})]}),e[21]=n,e[22]=w):w=e[22];let E;e[23]!==m.href?(E=t.jsx(Vs,{url:m.href}),e[23]=m.href,e[24]=E):E=e[24];let D,L;e[25]!==d||e[26]!==m.href?(D=t.jsx(Ms,{url:m.href,serverName:d}),L=t.jsx(Fs,{url:m.href,serverName:d}),e[25]=d,e[26]=m.href,e[27]=D,e[28]=L):(D=e[27],L=e[28]);let I;e[29]!==E||e[30]!==D||e[31]!==L?(I=t.jsx("div",{className:"flex flex-col gap-3 pt-2",children:t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[E,D,L]})}),e[29]=E,e[30]=D,e[31]=L,e[32]=I):I=e[32];let A;e[33]!==w||e[34]!==I?(A=t.jsxs(Ke,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[f,t.jsxs("div",{className:"flex flex-col gap-6",children:[w,I]})]}),e[33]=w,e[34]=I,e[35]=A):A=e[35];let $;return e[36]!==r||e[37]!==s||e[38]!==A?($=t.jsx(qe,{open:s,onOpenChange:r,children:A}),e[36]=r,e[37]=s,e[38]=A,e[39]=$):$=e[39],$}function Gs(o,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...o,shareDialogOpen:e.payload};case"SET_CONNECTION_DIALOG_OPEN":return{...o,connectionDialogOpen:e.payload};case"SET_EDITING_CONNECTION_ID":return{...o,editingConnectionId:e.payload};case"SET_SKILLS_OPEN":return{...o,skillsOpen:e.payload};default:return o}}function Ae(o){const e=T.c(27),{connection_id:s,selected_tools:r,selected_resources:l,selected_prompts:n,onClick:c}=o,i=Bt(s);if(!i)return null;let a;e[0]!==r?(a=Se(r),e[0]=r,e[1]=a):a=e[1];const m=a;let u;e[2]!==l?(u=Se(l),e[2]=l,e[3]=u):u=e[3];const d=u;let f;e[4]!==n?(f=Se(n),e[4]=n,e[5]=f):f=e[5];const h=f;let x;e[6]!==i.icon||e[7]!==i.title?(x=t.jsx(ge,{icon:i.icon,name:i.title,size:"xs"}),e[6]=i.icon,e[7]=i.title,e[8]=x):x=e[8];let p;e[9]!==i.title?(p=t.jsx("p",{className:"flex-1 text-sm font-normal text-foreground truncate",children:i.title}),e[9]=i.title,e[10]=p):p=e[10];let N;e[11]!==m?(N=m!==0&&t.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:m==="all"?"all":m}),t.jsx(Re,{size:12})]}),e[11]=m,e[12]=N):N=e[12];let j;e[13]!==d?(j=d!==0&&t.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:d==="all"?"all":d}),t.jsx(be,{size:12})]}),e[13]=d,e[14]=j):j=e[14];let v;e[15]!==h?(v=h!==0&&t.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:h==="all"?"all":h}),t.jsx($e,{size:12})]}),e[15]=h,e[16]=v):v=e[16];let g;e[17]!==N||e[18]!==j||e[19]!==v?(g=t.jsxs(De,{variant:"secondary",className:"bg-muted h-5 gap-2 px-1.5 py-1 flex items-center",children:[N,j,v]}),e[17]=N,e[18]=j,e[19]=v,e[20]=g):g=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(Ue,{size:16,className:"text-muted-foreground shrink-0"}),e[21]=y):y=e[21];let C;return e[22]!==c||e[23]!==x||e[24]!==p||e[25]!==g?(C=t.jsxs("div",{onClick:c,className:"w-full h-12 flex items-center gap-2 px-3 rounded-lg border border-border hover:bg-accent/50 transition-colors cursor-pointer",children:[x,p,g,y]}),e[22]=c,e[23]=x,e[24]=p,e[25]=g,e[26]=C):C=e[26],C}Ae.Fallback=function(){return t.jsxs("div",{className:"w-full h-12 flex items-center gap-2 px-3 rounded-lg border border-border",children:[t.jsx("div",{className:"size-5 rounded bg-muted animate-pulse shrink-0"}),t.jsx("div",{className:"flex-1 h-4 rounded bg-muted animate-pulse"}),t.jsxs(De,{variant:"secondary",className:"bg-muted h-5 gap-2 px-1.5 py-1 flex items-center",children:[t.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-muted-foreground/20 animate-pulse"}),t.jsx(Re,{size:12})]}),t.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-muted-foreground/20 animate-pulse"}),t.jsx(be,{size:12})]}),t.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-muted-foreground/20 animate-pulse"}),t.jsx($e,{size:12})]})]}),t.jsx(Ue,{size:16,className:"text-muted-foreground shrink-0"})]})};function Hs({virtualMcp:o}){const{org:e}=he(),r=vt().location.href,l=Ht(),n=Nt({resolver:yt(Ls),defaultValues:o}),c=n.watch("connections"),[i,a]=_.useReducer(Gs,{shareDialogOpen:!1,connectionDialogOpen:!1,editingConnectionId:null,skillsOpen:!1}),[,m]=Pt(),{setVirtualMcpId:u}=kt();_.useEffect(()=>{m(!0),u(o.id)},[o.id]);const d=()=>{u(o.id),m(!0)},f=n.formState.isDirty,h=async()=>{const g=n.getValues(),y=await l.update.mutateAsync({id:o.id,data:g});n.reset(y)},x=()=>{n.reset(o)},p=()=>{a({type:"SET_EDITING_CONNECTION_ID",payload:null}),a({type:"SET_CONNECTION_DIALOG_OPEN",payload:!0})},N=g=>{a({type:"SET_EDITING_CONNECTION_ID",payload:g}),a({type:"SET_CONNECTION_DIALOG_OPEN",payload:!0})},j=l.update.isPending,v=t.jsx(qt,{children:t.jsxs(Yt,{children:[t.jsx(Be,{children:t.jsx(Jt,{asChild:!0,children:t.jsx(Ct,{to:"/$org/agents",params:{org:e.slug},children:"Agents"})})}),t.jsx(Zt,{}),t.jsx(Be,{children:t.jsx(Qt,{children:o.title})})]})});return t.jsxs(Xt,{breadcrumb:v,children:[t.jsxs(es,{children:[t.jsx(Rt,{onSave:h,onUndo:x,isDirty:f,isSaving:j}),t.jsxs(de,{delayDuration:0,children:[t.jsx(ce,{asChild:!0,children:t.jsx("span",{className:"inline-block",children:t.jsxs(X,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 border border-input",onClick:d,"aria-label":"Test Agent",children:[t.jsx(Wt,{size:14}),"Test Agent"]})})}),t.jsx(me,{side:"bottom",children:"Test this agent in chat"})]}),t.jsxs(de,{delayDuration:0,children:[t.jsx(ce,{asChild:!0,children:t.jsx("span",{className:"inline-block",children:t.jsx(X,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:()=>a({type:"SET_SHARE_DIALOG_OPEN",payload:!0}),"aria-label":"Share",children:t.jsx(Kt,{size:14})})})}),t.jsx(me,{side:"bottom",children:"Share"})]}),t.jsx(Lt,{title:o.title,url:r,icon:o.icon??"cpu_chip"})]}),t.jsx("div",{className:"flex h-full w-full bg-background overflow-auto",children:t.jsxs("div",{className:"flex flex-col w-full",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 p-6 shrink-0",children:[t.jsxs("div",{className:"flex items-start gap-4 flex-1 min-w-0",children:[t.jsx(ge,{icon:o.icon,name:n.watch("title")||"Agent",size:"lg",className:"shrink-0 shadow-sm",fallbackIcon:t.jsx(Qe,{})}),t.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[t.jsx(Me,{...n.register("title"),className:"h-auto py-0.5 text-lg! font-medium leading-7 px-1 -mx-1 border-transparent hover:bg-input/25 focus:border-input bg-transparent transition-all",placeholder:"Agent Name"}),t.jsx(Me,{...n.register("description"),className:"h-auto py-0.5 text-base text-muted-foreground leading-6 px-1 -mx-1 border-transparent hover:bg-input/25 focus:border-input bg-transparent transition-all",placeholder:"Add a description..."})]})]}),t.jsx("div",{className:"flex items-center gap-2 shrink-0",children:t.jsx(zt,{checked:n.watch("status")==="active",onCheckedChange:g=>n.setValue("status",g?"active":"inactive",{shouldDirty:!0})})})]}),t.jsxs(wt,{open:i.skillsOpen,onOpenChange:g=>a({type:"SET_SKILLS_OPEN",payload:g}),className:"border-t border-border shrink-0 max-h-[400px] overflow-hidden flex flex-col",children:[c.length===0?t.jsxs("button",{type:"button",onClick:p,className:"w-full flex items-center justify-between px-6 py-4 hover:bg-muted/50 transition-colors cursor-pointer",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Skills"}),t.jsxs("div",{className:"h-7 px-2 inline-flex items-center justify-center gap-1 rounded-md text-sm text-muted-foreground",children:[t.jsx(Fe,{size:14}),"Add"]})]}):t.jsx(It,{asChild:!0,children:t.jsxs("button",{type:"button",className:"w-full flex items-center justify-between px-6 py-4 hover:bg-muted/50 transition-colors cursor-pointer",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Skills"}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"ease-(--ease-out-expo)",style:{width:i.skillsOpen?0:"auto",marginRight:i.skillsOpen?0:4,opacity:i.skillsOpen?0:1,pointerEvents:i.skillsOpen?"none":"auto",transitionProperty:"all",transitionDuration:i.skillsOpen?"0ms":"200ms"},children:t.jsx(cs,{connectionIds:c.map(g=>g.connection_id),maxVisibleIcons:2})}),t.jsxs("div",{role:"button",tabIndex:0,className:"h-7 inline-flex items-center justify-center rounded-md text-sm text-muted-foreground overflow-hidden transition-all duration-200 ease-(--ease-out-expo) hover:bg-accent hover:text-accent-foreground",style:{width:i.skillsOpen?"auto":28,paddingLeft:i.skillsOpen?8:0,paddingRight:i.skillsOpen?8:0,gap:i.skillsOpen?4:0},onPointerDown:g=>{g.stopPropagation()},onClick:g=>{g.stopPropagation(),g.preventDefault(),p()},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.stopPropagation(),g.preventDefault(),p())},children:[t.jsx(Fe,{size:14,className:"shrink-0"}),t.jsx("span",{className:"overflow-hidden whitespace-nowrap transition-all duration-200 ease-(--ease-out-expo)",style:{width:i.skillsOpen?"auto":0,opacity:i.skillsOpen?1:0},children:"Add"})]}),t.jsx("div",{className:"h-7 inline-flex items-center justify-center overflow-hidden transition-all duration-200 ease-(--ease-out-expo)",style:{width:i.skillsOpen?28:0,opacity:i.skillsOpen?1:0},children:t.jsx(Ut,{size:16,className:"shrink-0"})})]})]})}),t.jsx("div",{className:"grid overflow-hidden transition-[grid-template-rows] duration-200 ease-(--ease-out-expo)",style:{gridTemplateRows:i.skillsOpen?"1fr":"0fr"},children:t.jsx("div",{className:"min-h-0 overflow-hidden",children:t.jsx("div",{className:"overflow-y-auto max-h-[300px] mask-[linear-gradient(to_bottom,black_calc(100%-40px),transparent_100%)]",children:t.jsx("div",{className:"flex flex-col gap-2 px-6 pb-4 pt-2",children:c.map(g=>t.jsx(_.Suspense,{fallback:t.jsx(Ae.Fallback,{}),children:t.jsx(Ae,{connection_id:g.connection_id,selected_tools:g.selected_tools,selected_resources:g.selected_resources,selected_prompts:g.selected_prompts,onClick:()=>N(g.connection_id)})},g.connection_id))})})})})]}),t.jsxs("div",{className:"flex flex-col flex-1 p-6 border-t border-border overflow-auto",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Instructions"}),t.jsx(_t,{name:"metadata.instructions",control:n.control,render:({field:g})=>t.jsx(Vt,{...g,value:g.value??"",placeholder:"Write instructions here...",className:"min-h-[200px] resize-none text-sm placeholder:text-muted-foreground/50 leading-relaxed border-0 rounded-none shadow-none px-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus:border-0 bg-transparent"})})]})]})}),t.jsx(Rs,{open:i.connectionDialogOpen,onOpenChange:g=>a({type:"SET_CONNECTION_DIALOG_OPEN",payload:g}),selectedId:i.editingConnectionId,form:n,connections:c}),t.jsx(Bs,{open:i.shareDialogOpen,onOpenChange:g=>a({type:"SET_SHARE_DIALOG_OPEN",payload:g}),virtualMcp:o})]})}function Us(){const o=T.c(6),e=bt();let s;o[0]===Symbol.for("react.memo_cache_sentinel")?(s={from:"/shell/$org/agents/$agentId"},o[0]=s):s=o[0];const r=jt(s),{org:l,agentId:n}=r,c=Gt(n);if(!c){let a;return o[1]!==e||o[2]!==l?(a=t.jsx("div",{className:"flex h-full w-full bg-background",children:t.jsx(Et,{title:"Agent not found",description:"This Agent may have been deleted or you may not have access.",actions:t.jsx(X,{variant:"outline",onClick:()=>e({to:"/$org/agents",params:{org:l}}),children:"Back to agents"})})}),o[1]=e,o[2]=l,o[3]=a):a=o[3],a}let i;return o[4]!==c?(i=t.jsx(Hs,{virtualMcp:c}),o[4]=c,o[5]=i):i=o[5],i}function Bl(){const o=T.c(1);let e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(pe,{children:t.jsx(_.Suspense,{fallback:t.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:t.jsx(We,{size:32,className:"animate-spin text-muted-foreground"})}),children:t.jsx(Us,{})})}),o[0]=e):e=o[0],e}export{Bl as default};
@@ -1,23 +0,0 @@
1
- import{r as S,bu as Ta,bv as Aa,H as Ma,bf as V,s as f,bw as ke,bx as Ot,bj as Ra,bk as ja,be as ka,bg as U,ba as Ee,ad as Ne,o as R,bh as E,bi as se,by as Oa,bz as j,ae as Pa,b5 as Da,c as D,u as Ce,a as Pt,K as Dt,F as $a,t as Be,j as d,g as La,am as Za,ak as Ke,at as Fa,an as Ua,aq as za,av as Ba,al as Va,aW as qa}from"./index-S9nBXez3.js";import{u as Pe,a as et,d as Wa}from"./constants-CiJIPOcv.js";import{b as Ja}from"./use-virtual-mcp-Bib66D0T.js";import{e as Ha,b as $t}from"./use-connection-DsOrNBOn.js";import{a as Ya}from"./use-binding-OJZZKHfM.js";import{u as Ga}from"./Code01-DlwIBx5j.js";import{u as Me,L as Ve}from"./localstorage-keys-1daarnfj.js";import{c as tt,B as Qa}from"./button-C2Npiaxw.js";import{I as Xa}from"./input-WEkqgPCx.js";import{P as Ka,a as es,b as ts}from"./popover-DyvWBt1E.js";import{S as as,a as ss,b as rs,c as os,d as ns}from"./select-DP5Dfkvv.js";import{t as dt}from"./ChevronDown-CmDSkkyU.js";import{i as is}from"./File06-BmoKv1ZA.js";import{c as ls}from"./Grid01-CH_80p-4.js";import{a as cs}from"./Image01-qkpxD1yj.js";import{i as Lt}from"./SearchMd-6GhPnBK1.js";var Ie;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function a(r){throw new Error}t.assertNever=a,t.arrayToEnum=r=>{const o={};for(const i of r)o[i]=i;return o},t.getValidEnumValues=r=>{const o=t.objectKeys(r).filter(n=>typeof r[r[n]]!="number"),i={};for(const n of o)i[n]=r[n];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(o){return r[o]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const o=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&o.push(i);return o},t.find=(r,o)=>{for(const i of r)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,o=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=s,t.jsonStringifyReplacer=(r,o)=>typeof o=="bigint"?o.toString():o})(Ie||(Ie={}));var pt;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(pt||(pt={}));Ie.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Ie.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Oe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){const a=e||function(o){return o.message},s={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(a(i));else{let n=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(n[l]=n[l]||{_errors:[]},n[l]._errors.push(a(i))):n[l]=n[l]||{_errors:[]},n=n[l],c++}}};return r(this),s}static assert(e){if(!(e instanceof Oe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ie.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){const a=Object.create(null),s=[];for(const r of this.issues)if(r.path.length>0){const o=r.path[0];a[o]=a[o]||[],a[o].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:a}}get formErrors(){return this.flatten()}}Oe.create=t=>new Oe(t);var mt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(mt||(mt={}));var w;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(w||(w={}));const us=({size:t=24,color:e="currentColor",...a})=>S.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},S.createElement("path",{d:"M4 7h11m0 0-4 4m4-4-4-4M4 17h16m0 0-4 4m4-4-4-4"}));us.displayName="ArrowsRight";const Zt=({size:t=24,color:e="currentColor",...a})=>S.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},S.createElement("path",{d:"m7 15 5 5 5-5M7 9l5-5 5 5"}));Zt.displayName="ChevronSelectorVertical";const Ft=({size:t=24,color:e="currentColor",...a})=>S.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},S.createElement("path",{d:"M6 16a4 4 0 0 0 4 4h4a4 4 0 0 0 0-8h-4a4 4 0 0 1 0-8h4a4 4 0 0 1 4 4m-6-6v20"}));Ft.displayName="CurrencyDollar";const ds=({size:t=24,color:e="currentColor",...a})=>S.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},S.createElement("path",{d:"M10 17.659V20a2 2 0 1 0 4 0v-2.341M12 2v1m-9 9H2m3.5-6.5-.6-.6m13.6.6.6-.6M22 12h-1m-3 0a6 6 0 1 1-12 0 6 6 0 0 1 12 0Z"}));ds.displayName="Lightbulb02";const Ut=({size:t=24,color:e="currentColor",...a})=>S.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},S.createElement("path",{d:"m18 8 4 4m0 0-4 4m4-4H9m6-7.796A8.383 8.383 0 0 0 10.667 3C5.88 3 2 7.03 2 12s3.88 9 8.667 9A8.384 8.384 0 0 0 15 19.796"}));Ut.displayName="LogOut04";const zt=({size:t=24,color:e="currentColor",...a})=>S.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},S.createElement("path",{d:"m6.5 13 .784 1.569c.266.53.399.796.576 1.026a3 3 0 0 0 .545.545c.23.177.495.31 1.026.575L11 17.5l-1.569.785c-.53.265-.796.398-1.026.575a3 3 0 0 0-.545.545c-.177.23-.31.495-.576 1.026L6.5 22l-.784-1.569c-.266-.53-.399-.796-.576-1.026a3 3 0 0 0-.545-.545c-.23-.177-.495-.31-1.026-.575L2 17.5l1.569-.785c.53-.265.796-.398 1.026-.575a3 3 0 0 0 .545-.545c.177-.23.31-.495.576-1.026L6.5 13ZM15 2l1.179 3.064c.282.734.423 1.1.642 1.409a3 3 0 0 0 .706.706c.309.22.675.36 1.409.642L22 9l-3.064 1.179c-.734.282-1.1.423-1.409.642a3 3 0 0 0-.706.706c-.22.309-.36.675-.642 1.409L15 16l-1.179-3.064c-.282-.734-.423-1.1-.642-1.409a3 3 0 0 0-.706-.706c-.309-.22-.675-.36-1.409-.642L8 9l3.064-1.179c.734-.282 1.1-.423 1.409-.642a3 3 0 0 0 .706-.706c.22-.309.36-.675.642-1.409L15 2Z"}));zt.displayName="Stars01";var Bt="vercel.ai.error",ps=Symbol.for(Bt),ft,ht,X=class Vt extends(ht=Error,ft=ps,ht){constructor({name:e,message:a,cause:s}){super(a),this[ft]=!0,this.name=e,this.cause=s}static isInstance(e){return Vt.hasMarker(e,Bt)}static hasMarker(e,a){const s=Symbol.for(a);return e!=null&&typeof e=="object"&&s in e&&typeof e[s]=="boolean"&&e[s]===!0}};function qt(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Wt="AI_InvalidArgumentError",Jt=`vercel.ai.error.${Wt}`,ms=Symbol.for(Jt),gt,vt,fs=class extends(vt=X,gt=ms,vt){constructor({message:t,cause:e,argument:a}){super({name:Wt,message:t,cause:e}),this[gt]=!0,this.argument=a}static isInstance(t){return X.hasMarker(t,Jt)}},Ht="AI_JSONParseError",Yt=`vercel.ai.error.${Ht}`,hs=Symbol.for(Yt),yt,xt,bt=class extends(xt=X,yt=hs,xt){constructor({text:t,cause:e}){super({name:Ht,message:`JSON parsing failed: Text: ${t}.
2
- Error message: ${qt(e)}`,cause:e}),this[yt]=!0,this.text=t}static isInstance(t){return X.hasMarker(t,Yt)}},Gt="AI_TypeValidationError",Qt=`vercel.ai.error.${Gt}`,gs=Symbol.for(Qt),_t,Et,ve=class qe extends(Et=X,_t=gs,Et){constructor({value:e,cause:a,context:s}){let r="Type validation failed";if(s?.field&&(r+=` for ${s.field}`),s?.entityName||s?.entityId){r+=" (";const o=[];s.entityName&&o.push(s.entityName),s.entityId&&o.push(`id: "${s.entityId}"`),r+=o.join(", "),r+=")"}super({name:Gt,message:`${r}: Value: ${JSON.stringify(e)}.
3
- Error message: ${qt(a)}`,cause:a}),this[_t]=!0,this.value=e,this.context=s}static isInstance(e){return X.hasMarker(e,Qt)}static wrap({value:e,cause:a,context:s}){var r,o,i;return qe.isInstance(a)&&a.value===e&&((r=a.context)==null?void 0:r.field)===s?.field&&((o=a.context)==null?void 0:o.entityName)===s?.entityName&&((i=a.context)==null?void 0:i.entityId)===s?.entityId?a:new qe({value:e,cause:a,context:s})}},Te=({prefix:t,size:e=16,alphabet:a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:s="-"}={})=>{const r=()=>{const o=a.length,i=new Array(e);for(let n=0;n<e;n++)i[n]=a[Math.random()*o|0];return i.join("")};if(t==null)return r;if(a.includes(s))throw new fs({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${a}".`});return()=>`${t}${s}${r()}`},vs=Te();function It(t=globalThis){var e,a,s;return t.window?"runtime/browser":(e=t.navigator)!=null&&e.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(s=(a=t.process)==null?void 0:a.versions)!=null&&s.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function de(t){if(t==null)return{};const e={};if(t instanceof Headers)t.forEach((a,s)=>{e[s.toLowerCase()]=a});else{Array.isArray(t)||(t=Object.entries(t));for(const[a,s]of t)s!=null&&(e[a.toLowerCase()]=s)}return e}function wt(t,...e){const a=new Headers(de(t)),s=a.get("user-agent")||"";return a.set("user-agent",[s,...e].filter(Boolean).join(" ")),Object.fromEntries(a.entries())}var ys=/"__proto__"\s*:/,xs=/"constructor"\s*:/;function St(t){const e=JSON.parse(t);return e===null||typeof e!="object"||ys.test(t)===!1&&xs.test(t)===!1?e:bs(e)}function bs(t){let e=[t];for(;e.length;){const a=e;e=[];for(const s of a){if(Object.prototype.hasOwnProperty.call(s,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(s,"constructor")&&Object.prototype.hasOwnProperty.call(s.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in s){const o=s[r];o&&typeof o=="object"&&e.push(o)}}}return t}function _s(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return St(t)}try{return St(t)}finally{Error.stackTraceLimit=e}}function at(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:a}=t;if(a!=null)for(const s of Object.keys(a))a[s]=ue(a[s])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(ue):ue(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(ue)),t.allOf!=null&&(t.allOf=t.allOf.map(ue)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(ue));const{definitions:e}=t;if(e!=null)for(const a of Object.keys(e))e[a]=ue(e[a]);return t}function ue(t){return typeof t=="boolean"?t:at(t)}var Es=Symbol("Let zodToJsonSchema decide on which parser to use"),Nt={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Is=t=>typeof t=="string"?{...Nt,name:t}:{...Nt,...t};function q(){return{}}function ws(t,e){var a,s,r;const o={type:"array"};return(a=t.type)!=null&&a._def&&((r=(s=t.type)==null?void 0:s._def)==null?void 0:r.typeName)!==w.ZodAny&&(o.items=M(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(o.minItems=t.minLength.value),t.maxLength&&(o.maxItems=t.maxLength.value),t.exactLength&&(o.minItems=t.exactLength.value,o.maxItems=t.exactLength.value),o}function Ss(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function Ns(){return{type:"boolean"}}function Xt(t,e){return M(t.type._def,e)}var Cs=(t,e)=>M(t.innerType._def,e);function Kt(t,e,a){const s=a??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,o)=>Kt(t,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Ts(t)}}var Ts=t=>{const e={type:"integer",format:"unix-time"};for(const a of t.checks)switch(a.kind){case"min":e.minimum=a.value;break;case"max":e.maximum=a.value;break}return e};function As(t,e){return{...M(t.innerType._def,e),default:t.defaultValue()}}function Ms(t,e){return e.effectStrategy==="input"?M(t.schema._def,e):q()}function Rs(t){return{type:"string",enum:Array.from(t.values)}}var js=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function ks(t,e){const a=[M(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),M(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(r=>!!r),s=[];return a.forEach(r=>{if(js(r))s.push(...r.allOf);else{let o=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:i,...n}=r;o=n}s.push(o)}}),s.length?{allOf:s}:void 0}function Os(t){const e=typeof t.value;return e!=="bigint"&&e!=="number"&&e!=="boolean"&&e!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:e==="bigint"?"integer":e,const:t.value}}var Fe=void 0,H={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Fe===void 0&&(Fe=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Fe),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ea(t,e){const a={type:"string"};if(t.checks)for(const s of t.checks)switch(s.kind){case"min":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value;break;case"max":a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"email":switch(e.emailStrategy){case"format:email":Y(a,"email",s.message,e);break;case"format:idn-email":Y(a,"idn-email",s.message,e);break;case"pattern:zod":F(a,H.email,s.message,e);break}break;case"url":Y(a,"uri",s.message,e);break;case"uuid":Y(a,"uuid",s.message,e);break;case"regex":F(a,s.regex,s.message,e);break;case"cuid":F(a,H.cuid,s.message,e);break;case"cuid2":F(a,H.cuid2,s.message,e);break;case"startsWith":F(a,RegExp(`^${Ue(s.value,e)}`),s.message,e);break;case"endsWith":F(a,RegExp(`${Ue(s.value,e)}$`),s.message,e);break;case"datetime":Y(a,"date-time",s.message,e);break;case"date":Y(a,"date",s.message,e);break;case"time":Y(a,"time",s.message,e);break;case"duration":Y(a,"duration",s.message,e);break;case"length":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value,a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"includes":{F(a,RegExp(Ue(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&Y(a,"ipv4",s.message,e),s.version!=="v4"&&Y(a,"ipv6",s.message,e);break}case"base64url":F(a,H.base64url,s.message,e);break;case"jwt":F(a,H.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&F(a,H.ipv4Cidr,s.message,e),s.version!=="v4"&&F(a,H.ipv6Cidr,s.message,e);break}case"emoji":F(a,H.emoji(),s.message,e);break;case"ulid":{F(a,H.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{Y(a,"binary",s.message,e);break}case"contentEncoding:base64":{a.contentEncoding="base64";break}case"pattern:zod":{F(a,H.base64,s.message,e);break}}break}case"nanoid":F(a,H.nanoid,s.message,e)}return a}function Ue(t,e){return e.patternStrategy==="escape"?Ds(t):t}var Ps=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ds(t){let e="";for(let a=0;a<t.length;a++)Ps.has(t[a])||(e+="\\"),e+=t[a];return e}function Y(t,e,a,s){var r;t.format||(r=t.anyOf)!=null&&r.some(o=>o.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...a&&s.errorMessages&&{errorMessage:{format:a}}})):t.format=e}function F(t,e,a,s){var r;t.pattern||(r=t.allOf)!=null&&r.some(o=>o.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:Ct(e,s),...a&&s.errorMessages&&{errorMessage:{pattern:a}}})):t.pattern=Ct(e,s)}function Ct(t,e){var a;if(!e.applyRegexFlags||!t.flags)return t.source;const s={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},r=s.i?t.source.toLowerCase():t.source;let o="",i=!1,n=!1,c=!1;for(let l=0;l<r.length;l++){if(i){o+=r[l],i=!1;continue}if(s.i){if(n){if(r[l].match(/[a-z]/)){c?(o+=r[l],o+=`${r[l-2]}-${r[l]}`.toUpperCase(),c=!1):r[l+1]==="-"&&((a=r[l+2])!=null&&a.match(/[a-z]/))?(o+=r[l],c=!0):o+=`${r[l]}${r[l].toUpperCase()}`;continue}}else if(r[l].match(/[a-z]/)){o+=`[${r[l]}${r[l].toUpperCase()}]`;continue}}if(s.m){if(r[l]==="^"){o+=`(^|(?<=[\r
4
- ]))`;continue}else if(r[l]==="$"){o+=`($|(?=[\r
5
- ]))`;continue}}if(s.s&&r[l]==="."){o+=n?`${r[l]}\r
6
- `:`[${r[l]}\r
7
- ]`;continue}o+=r[l],r[l]==="\\"?i=!0:n&&r[l]==="]"?n=!1:!n&&r[l]==="["&&(n=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return o}function ta(t,e){var a,s,r,o,i,n;const c={type:"object",additionalProperties:(a=M(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?a:e.allowedAdditionalProperties};if(((s=t.keyType)==null?void 0:s._def.typeName)===w.ZodString&&((r=t.keyType._def.checks)!=null&&r.length)){const{type:l,...p}=ea(t.keyType._def,e);return{...c,propertyNames:p}}else{if(((o=t.keyType)==null?void 0:o._def.typeName)===w.ZodEnum)return{...c,propertyNames:{enum:t.keyType._def.values}};if(((i=t.keyType)==null?void 0:i._def.typeName)===w.ZodBranded&&t.keyType._def.type._def.typeName===w.ZodString&&((n=t.keyType._def.type._def.checks)!=null&&n.length)){const{type:l,...p}=Xt(t.keyType._def,e);return{...c,propertyNames:p}}}return c}function $s(t,e){if(e.mapStrategy==="record")return ta(t,e);const a=M(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||q(),s=M(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||q();return{type:"array",maxItems:125,items:{type:"array",items:[a,s],minItems:2,maxItems:2}}}function Ls(t){const e=t.values,s=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),r=Array.from(new Set(s.map(o=>typeof o)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:s}}function Zs(){return{not:q()}}function Fs(){return{type:"null"}}var We={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Us(t,e){const a=t.options instanceof Map?Array.from(t.options.values()):t.options;if(a.every(s=>s._def.typeName in We&&(!s._def.checks||!s._def.checks.length))){const s=a.reduce((r,o)=>{const i=We[o._def.typeName];return i&&!r.includes(i)?[...r,i]:r},[]);return{type:s.length>1?s:s[0]}}else if(a.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){const s=a.reduce((r,o)=>{const i=typeof o._def.value;switch(i){case"string":case"number":case"boolean":return[...r,i];case"bigint":return[...r,"integer"];case"object":if(o._def.value===null)return[...r,"null"];default:return r}},[]);if(s.length===a.length){const r=s.filter((o,i,n)=>n.indexOf(o)===i);return{type:r.length>1?r:r[0],enum:a.reduce((o,i)=>o.includes(i._def.value)?o:[...o,i._def.value],[])}}}else if(a.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:a.reduce((s,r)=>[...s,...r._def.values.filter(o=>!s.includes(o))],[])};return zs(t,e)}var zs=(t,e)=>{const a=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,r)=>M(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${r}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return a.length?{anyOf:a}:void 0};function Bs(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[We[t.innerType._def.typeName],"null"]};const a=M(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}function Vs(t){const e={type:"number"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"int":e.type="integer";break;case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function qs(t,e){const a={type:"object",properties:{}},s=[],r=t.shape();for(const i in r){let n=r[i];if(n===void 0||n._def===void 0)continue;const c=Js(n),l=M(n._def,{...e,currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]});l!==void 0&&(a.properties[i]=l,c||s.push(i))}s.length&&(a.required=s);const o=Ws(t,e);return o!==void 0&&(a.additionalProperties=o),a}function Ws(t,e){if(t.catchall._def.typeName!=="ZodNever")return M(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function Js(t){try{return t.isOptional()}catch{return!0}}var Hs=(t,e)=>{var a;if(e.currentPath.toString()===((a=e.propertyPath)==null?void 0:a.toString()))return M(t.innerType._def,e);const s=M(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return s?{anyOf:[{not:q()},s]}:q()},Ys=(t,e)=>{if(e.pipeStrategy==="input")return M(t.in._def,e);if(e.pipeStrategy==="output")return M(t.out._def,e);const a=M(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=M(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",a?"1":"0"]});return{allOf:[a,s].filter(r=>r!==void 0)}};function Gs(t,e){return M(t.type._def,e)}function Qs(t,e){const s={type:"array",uniqueItems:!0,items:M(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&(s.minItems=t.minSize.value),t.maxSize&&(s.maxItems=t.maxSize.value),s}function Xs(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((a,s)=>M(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[]),additionalItems:M(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((a,s)=>M(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[])}}function Ks(){return{not:q()}}function er(){return q()}var tr=(t,e)=>M(t.innerType._def,e),ar=(t,e,a)=>{switch(e){case w.ZodString:return ea(t,a);case w.ZodNumber:return Vs(t);case w.ZodObject:return qs(t,a);case w.ZodBigInt:return Ss(t);case w.ZodBoolean:return Ns();case w.ZodDate:return Kt(t,a);case w.ZodUndefined:return Ks();case w.ZodNull:return Fs();case w.ZodArray:return ws(t,a);case w.ZodUnion:case w.ZodDiscriminatedUnion:return Us(t,a);case w.ZodIntersection:return ks(t,a);case w.ZodTuple:return Xs(t,a);case w.ZodRecord:return ta(t,a);case w.ZodLiteral:return Os(t);case w.ZodEnum:return Rs(t);case w.ZodNativeEnum:return Ls(t);case w.ZodNullable:return Bs(t,a);case w.ZodOptional:return Hs(t,a);case w.ZodMap:return $s(t,a);case w.ZodSet:return Qs(t,a);case w.ZodLazy:return()=>t.getter()._def;case w.ZodPromise:return Gs(t,a);case w.ZodNaN:case w.ZodNever:return Zs();case w.ZodEffects:return Ms(t,a);case w.ZodAny:return q();case w.ZodUnknown:return er();case w.ZodDefault:return As(t,a);case w.ZodBranded:return Xt(t,a);case w.ZodReadonly:return tr(t,a);case w.ZodCatch:return Cs(t,a);case w.ZodPipeline:return Ys(t,a);case w.ZodFunction:case w.ZodVoid:case w.ZodSymbol:return;default:return(s=>{})()}},sr=(t,e)=>{let a=0;for(;a<t.length&&a<e.length&&t[a]===e[a];a++);return[(t.length-a).toString(),...e.slice(a)].join("/")};function M(t,e,a=!1){var s;const r=e.seen.get(t);if(e.override){const c=(s=e.override)==null?void 0:s.call(e,t,e,r,a);if(c!==Es)return c}if(r&&!a){const c=rr(r,e);if(c!==void 0)return c}const o={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,o);const i=ar(t,t.typeName,e),n=typeof i=="function"?M(i(),e):i;if(n&&or(t,e,n),e.postProcess){const c=e.postProcess(n,t,e);return o.jsonSchema=n,c}return o.jsonSchema=n,n}var rr=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:sr(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((a,s)=>e.currentPath[s]===a)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),q()):e.$refStrategy==="seen"?q():void 0}},or=(t,e,a)=>(t.description&&(a.description=t.description),a),nr=t=>{const e=Is(t),a=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[r._def,{def:r._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}},ir=(t,e)=>{var a;const s=nr(e);let r=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[p,m])=>{var h;return{...l,[p]:(h=M(m._def,{...s,currentPath:[...s.basePath,s.definitionPath,p]},!0))!=null?h:q()}},{}):void 0;const o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,i=(a=M(t._def,o===void 0?s:{...s,currentPath:[...s.basePath,s.definitionPath,o]},!1))!=null?a:q(),n=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;n!==void 0&&(i.title=n);const c=o===void 0?r?{...i,[s.definitionPath]:r}:i:{$ref:[...s.$refStrategy==="relative"?[]:s.basePath,s.definitionPath,o].join("/"),[s.definitionPath]:{...r,[o]:i}};return c.$schema="http://json-schema.org/draft-07/schema#",c},Je=Symbol.for("vercel.ai.schema");function lr(t){let e;return()=>(e==null&&(e=t()),e)}function De(t,{validate:e}={}){return{[Je]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function cr(t){return typeof t=="object"&&t!==null&&Je in t&&t[Je]===!0&&"jsonSchema"in t&&"validate"in t}function st(t){return t==null?De({properties:{},additionalProperties:!1}):cr(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?aa(t):ur(t):t()}function ur(t){return De(()=>at(t["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async e=>{const a=await t["~standard"].validate(e);return"value"in a?{success:!0,value:a.value}:{success:!1,error:new ve({value:e,cause:a.issues})}}})}function dr(t,e){var a;const s=(a=void 0)!=null?a:!1;return De(()=>ir(t,{$refStrategy:s?"root":"none"}),{validate:async r=>{const o=await t.safeParseAsync(r);return o.success?{success:!0,value:o.data}:{success:!1,error:o.error}}})}function pr(t,e){var a;const s=(a=void 0)!=null?a:!1;return De(()=>at(Ma(t,{target:"draft-7",io:"input",reused:s?"ref":"inline"})),{validate:async r=>{const o=await Aa(t,r);return o.success?{success:!0,value:o.data}:{success:!1,error:o.error}}})}function mr(t){return"_zod"in t}function aa(t,e){return mr(t)?pr(t):dr(t)}async function Tt({value:t,schema:e,context:a}){const s=await we({value:t,schema:e,context:a});if(!s.success)throw ve.wrap({value:t,cause:s.error,context:a});return s.value}async function we({value:t,schema:e,context:a}){const s=st(e);try{if(s.validate==null)return{success:!0,value:t,rawValue:t};const r=await s.validate(t);return r.success?{success:!0,value:r.value,rawValue:t}:{success:!1,error:ve.wrap({value:t,cause:r.error,context:a}),rawValue:t}}catch(r){return{success:!1,error:ve.wrap({value:t,cause:r,context:a}),rawValue:t}}}async function pe({text:t,schema:e}){try{const a=_s(t);return e==null?{success:!0,value:a,rawValue:a}:await we({value:a,schema:e})}catch(a){return{success:!1,error:bt.isInstance(a)?a:new bt({text:t,cause:a}),rawValue:void 0}}}function fr({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new Ta).pipeThrough(new TransformStream({async transform({data:a},s){a!=="[DONE]"&&s.enqueue(await pe({text:a,schema:e}))}}))}async function oe(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var hr=Object.defineProperty,gr=(t,e)=>{for(var a in e)hr(t,a,{get:e[a],enumerable:!0})},sa="AI_NoObjectGeneratedError",ra=`vercel.ai.error.${sa}`,vr=Symbol.for(ra),oa,ne=class extends X{constructor({message:t="No object generated.",cause:e,text:a,response:s,usage:r,finishReason:o}){super({name:sa,message:t,cause:e}),this[oa]=!0,this.text=a,this.response=s,this.usage=r,this.finishReason=o}static isInstance(t){return X.hasMarker(t,ra)}};oa=vr;var na="AI_UIMessageStreamError",ia=`vercel.ai.error.${na}`,yr=Symbol.for(ia),la,fe=class extends X{constructor({chunkType:t,chunkId:e,message:a}){super({name:na,message:a}),this[la]=!0,this.chunkType=t,this.chunkId=e}static isInstance(t){return X.hasMarker(t,ia)}};la=yr;var At="6.0.68",ca=V([f(),ke(Uint8Array),ke(ArrayBuffer),Ot(t=>{var e,a;return(a=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?a:!1},{message:"Must be a Buffer"})]),Se=Ra(()=>V([ja(),f(),ka(),U(),Ee(f(),Se.optional()),Ne(Se)])),T=Ee(f(),Ee(f(),Se.optional())),ua=R({type:E("text"),text:f(),providerOptions:T.optional()}),xr=R({type:E("image"),image:V([ca,ke(URL)]),mediaType:f().optional(),providerOptions:T.optional()}),da=R({type:E("file"),data:V([ca,ke(URL)]),filename:f().optional(),mediaType:f(),providerOptions:T.optional()}),br=R({type:E("reasoning"),text:f(),providerOptions:T.optional()}),_r=R({type:E("tool-call"),toolCallId:f(),toolName:f(),input:se(),providerOptions:T.optional(),providerExecuted:U().optional()}),Er=Oa("type",[R({type:E("text"),value:f(),providerOptions:T.optional()}),R({type:E("json"),value:Se,providerOptions:T.optional()}),R({type:E("execution-denied"),reason:f().optional(),providerOptions:T.optional()}),R({type:E("error-text"),value:f(),providerOptions:T.optional()}),R({type:E("error-json"),value:Se,providerOptions:T.optional()}),R({type:E("content"),value:Ne(V([R({type:E("text"),text:f(),providerOptions:T.optional()}),R({type:E("media"),data:f(),mediaType:f()}),R({type:E("file-data"),data:f(),mediaType:f(),filename:f().optional(),providerOptions:T.optional()}),R({type:E("file-url"),url:f(),providerOptions:T.optional()}),R({type:E("file-id"),fileId:V([f(),Ee(f(),f())]),providerOptions:T.optional()}),R({type:E("image-data"),data:f(),mediaType:f(),providerOptions:T.optional()}),R({type:E("image-url"),url:f(),providerOptions:T.optional()}),R({type:E("image-file-id"),fileId:V([f(),Ee(f(),f())]),providerOptions:T.optional()}),R({type:E("custom"),providerOptions:T.optional()})]))})]),pa=R({type:E("tool-result"),toolCallId:f(),toolName:f(),output:Er,providerOptions:T.optional()}),Ir=R({type:E("tool-approval-request"),approvalId:f(),toolCallId:f()}),wr=R({type:E("tool-approval-response"),approvalId:f(),approved:U(),reason:f().optional()}),Sr=R({role:E("system"),content:f(),providerOptions:T.optional()}),Nr=R({role:E("user"),content:V([f(),Ne(V([ua,xr,da]))]),providerOptions:T.optional()}),Cr=R({role:E("assistant"),content:V([f(),Ne(V([ua,da,br,_r,pa,Ir]))]),providerOptions:T.optional()}),Tr=R({role:E("tool"),content:Ne(V([pa,wr])),providerOptions:T.optional()});V([Sr,Nr,Cr,Tr]);function ma(t,e){if(t===void 0&&e===void 0)return;if(t===void 0)return e;if(e===void 0)return t;const a={...t};for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(r===void 0)continue;const o=s in t?t[s]:void 0,i=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),n=o!=null&&typeof o=="object"&&!Array.isArray(o)&&!(o instanceof Date)&&!(o instanceof RegExp);i&&n?a[s]=ma(o,r):a[s]=r}return a}var Ar={};gr(Ar,{array:()=>kr,choice:()=>Or,json:()=>Pr,object:()=>jr,text:()=>Rr});function Mr(t){const e=["ROOT"];let a=-1,s=null;function r(c,l,p){switch(c){case'"':{a=l,e.pop(),e.push(p),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{a=l,s=l,e.pop(),e.push(p),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(p),e.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=l,e.pop(),e.push(p),e.push("INSIDE_NUMBER");break}case"{":{a=l,e.pop(),e.push(p),e.push("INSIDE_OBJECT_START");break}case"[":{a=l,e.pop(),e.push(p),e.push("INSIDE_ARRAY_START");break}}}function o(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{a=l,e.pop();break}}}function i(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=l,e.pop();break}}}for(let c=0;c<t.length;c++){const l=t[c];switch(e[e.length-1]){case"ROOT":r(l,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(l){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{a=c,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{l===":"&&(e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(l,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{o(l,c);break}case"INSIDE_STRING":{switch(l){case'"':{e.pop(),a=c;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:a=c}break}case"INSIDE_ARRAY_START":{l==="]"?(a=c,e.pop()):(a=c,r(l,c,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=c,e.pop();break}default:{a=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(l,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),a=c;break}case"INSIDE_NUMBER":{switch(l){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=c;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&o(l,c);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&o(l,c);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const m=t.substring(s,c+1);!"false".startsWith(m)&&!"true".startsWith(m)&&!"null".startsWith(m)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?o(l,c):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c)):a=c;break}}}let n=t.slice(0,a+1);for(let c=e.length-1;c>=0;c--)switch(e[c]){case"INSIDE_STRING":{n+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{n+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{n+="]";break}case"INSIDE_LITERAL":{const p=t.substring(s,t.length);"true".startsWith(p)?n+="true".slice(p.length):"false".startsWith(p)?n+="false".slice(p.length):"null".startsWith(p)&&(n+="null".slice(p.length))}}return n}async function Ae(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await pe({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await pe({text:Mr(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var Rr=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}},createElementStreamTransform(){}}),jr=({schema:t,name:e,description:a})=>{const s=st(t);return{name:"object",responseFormat:oe(s.jsonSchema).then(r=>({type:"json",schema:r,...e!=null&&{name:e},...a!=null&&{description:a}})),async parseCompleteOutput({text:r},o){const i=await pe({text:r});if(!i.success)throw new ne({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const n=await we({value:i.value,schema:s});if(!n.success)throw new ne({message:"No object generated: response did not match schema.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return n.value},async parsePartialOutput({text:r}){const o=await Ae(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value}}},createElementStreamTransform(){}}},kr=({element:t,name:e,description:a})=>{const s=st(t);return{name:"array",responseFormat:oe(s.jsonSchema).then(r=>{const{$schema:o,...i}=r;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:i}},required:["elements"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}}),async parseCompleteOutput({text:r},o){const i=await pe({text:r});if(!i.success)throw new ne({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const n=i.value;if(n==null||typeof n!="object"||!("elements"in n)||!Array.isArray(n.elements))throw new ne({message:"No object generated: response did not match schema.",cause:new ve({value:n,cause:"response must be an object with an elements array"}),text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});for(const c of n.elements){const l=await we({value:c,schema:s});if(!l.success)throw new ne({message:"No object generated: response did not match schema.",cause:l.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason})}return n.elements},async parsePartialOutput({text:r}){const o=await Ae(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const i=o.value;if(i==null||typeof i!="object"||!("elements"in i)||!Array.isArray(i.elements))return;const n=o.state==="repaired-parse"&&i.elements.length>0?i.elements.slice(0,-1):i.elements,c=[];for(const l of n){const p=await we({value:l,schema:s});p.success&&c.push(p.value)}return{partial:c}}}},createElementStreamTransform(){let r=0;return new TransformStream({transform({partialOutput:o},i){if(o!=null)for(;r<o.length;r++)i.enqueue(o[r])}})}}},Or=({options:t,name:e,description:a})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:t}},required:["result"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}),async parseCompleteOutput({text:s},r){const o=await pe({text:s});if(!o.success)throw new ne({message:"No object generated: could not parse the response.",cause:o.error,text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});const i=o.value;if(i==null||typeof i!="object"||!("result"in i)||typeof i.result!="string"||!t.includes(i.result))throw new ne({message:"No object generated: response did not match schema.",cause:new ve({value:i,cause:"response must be an object that contains a choice value."}),text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.result},async parsePartialOutput({text:s}){const r=await Ae(s);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const o=r.value;if(o==null||typeof o!="object"||!("result"in o)||typeof o.result!="string")return;const i=t.filter(n=>n.startsWith(o.result));return r.state==="successful-parse"?i.includes(o.result)?{partial:o.result}:void 0:i.length===1?{partial:i[0]}:void 0}}},createElementStreamTransform(){}}),Pr=({name:t,description:e}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...t!=null&&{name:t},...e!=null&&{description:e}}),async parseCompleteOutput({text:a},s){const r=await pe({text:a});if(!r.success)throw new ne({message:"No object generated: could not parse the response.",cause:r.error,text:a,response:s.response,usage:s.usage,finishReason:s.finishReason});return r.value},async parsePartialOutput({text:a}){const s=await Ae(a);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return s.value===void 0?void 0:{partial:s.value}}},createElementStreamTransform(){}});Te({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}
8
-
9
- `)},flush(t){t.enqueue(`data: [DONE]
10
-
11
- `)}})}});var Dr=lr(()=>aa(V([j({type:E("text-start"),id:f(),providerMetadata:T.optional()}),j({type:E("text-delta"),id:f(),delta:f(),providerMetadata:T.optional()}),j({type:E("text-end"),id:f(),providerMetadata:T.optional()}),j({type:E("error"),errorText:f()}),j({type:E("tool-input-start"),toolCallId:f(),toolName:f(),providerExecuted:U().optional(),providerMetadata:T.optional(),dynamic:U().optional(),title:f().optional()}),j({type:E("tool-input-delta"),toolCallId:f(),inputTextDelta:f()}),j({type:E("tool-input-available"),toolCallId:f(),toolName:f(),input:se(),providerExecuted:U().optional(),providerMetadata:T.optional(),dynamic:U().optional(),title:f().optional()}),j({type:E("tool-input-error"),toolCallId:f(),toolName:f(),input:se(),providerExecuted:U().optional(),providerMetadata:T.optional(),dynamic:U().optional(),errorText:f(),title:f().optional()}),j({type:E("tool-approval-request"),approvalId:f(),toolCallId:f()}),j({type:E("tool-output-available"),toolCallId:f(),output:se(),providerExecuted:U().optional(),dynamic:U().optional(),preliminary:U().optional()}),j({type:E("tool-output-error"),toolCallId:f(),errorText:f(),providerExecuted:U().optional(),dynamic:U().optional()}),j({type:E("tool-output-denied"),toolCallId:f()}),j({type:E("reasoning-start"),id:f(),providerMetadata:T.optional()}),j({type:E("reasoning-delta"),id:f(),delta:f(),providerMetadata:T.optional()}),j({type:E("reasoning-end"),id:f(),providerMetadata:T.optional()}),j({type:E("source-url"),sourceId:f(),url:f(),title:f().optional(),providerMetadata:T.optional()}),j({type:E("source-document"),sourceId:f(),mediaType:f(),title:f(),filename:f().optional(),providerMetadata:T.optional()}),j({type:E("file"),url:f(),mediaType:f(),providerMetadata:T.optional()}),j({type:Ot(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:f().optional(),data:se(),transient:U().optional()}),j({type:E("start-step")}),j({type:E("finish-step")}),j({type:E("start"),messageId:f().optional(),messageMetadata:se().optional()}),j({type:E("finish"),finishReason:Pa(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:se().optional()}),j({type:E("abort"),reason:f().optional()}),j({type:E("message-metadata"),messageMetadata:se()})])));function $r(t){return t.type.startsWith("data-")}function He(t){return t.type.startsWith("tool-")}function Lr(t){return t.type==="dynamic-tool"}function Ye(t){return He(t)||Lr(t)}function Mt(t){return t.type.split("-").slice(1).join("-")}function Zr({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Fr({stream:t,messageMetadataSchema:e,dataPartSchemas:a,runUpdateMessageJob:s,onError:r,onToolCall:o,onData:i}){return t.pipeThrough(new TransformStream({async transform(n,c){await s(async({state:l,write:p})=>{var m,h,x,y;function g(u){const A=l.message.parts.filter(Ye).find(N=>N.toolCallId===u);if(A==null)throw new fe({chunkType:"tool-invocation",chunkId:u,message:`No tool invocation found for tool call ID "${u}".`});return A}function b(u){var I;const A=l.message.parts.find(O=>He(O)&&O.toolCallId===u.toolCallId),N=u,C=A;A!=null?(A.state=u.state,C.input=N.input,C.output=N.output,C.errorText=N.errorText,C.rawInput=N.rawInput,C.preliminary=N.preliminary,u.title!==void 0&&(C.title=u.title),C.providerExecuted=(I=N.providerExecuted)!=null?I:A.providerExecuted,N.providerMetadata!=null&&(A.callProviderMetadata=N.providerMetadata)):l.message.parts.push({type:`tool-${u.toolName}`,toolCallId:u.toolCallId,state:u.state,title:u.title,input:N.input,output:N.output,rawInput:N.rawInput,errorText:N.errorText,providerExecuted:N.providerExecuted,preliminary:N.preliminary,...N.providerMetadata!=null?{callProviderMetadata:N.providerMetadata}:{}})}function v(u){var I,A;const N=l.message.parts.find(Z=>Z.type==="dynamic-tool"&&Z.toolCallId===u.toolCallId),C=u,O=N;N!=null?(N.state=u.state,O.toolName=u.toolName,O.input=C.input,O.output=C.output,O.errorText=C.errorText,O.rawInput=(I=C.rawInput)!=null?I:O.rawInput,O.preliminary=C.preliminary,u.title!==void 0&&(O.title=u.title),O.providerExecuted=(A=C.providerExecuted)!=null?A:N.providerExecuted,C.providerMetadata!=null&&(N.callProviderMetadata=C.providerMetadata)):l.message.parts.push({type:"dynamic-tool",toolName:u.toolName,toolCallId:u.toolCallId,state:u.state,input:C.input,output:C.output,errorText:C.errorText,preliminary:C.preliminary,providerExecuted:C.providerExecuted,title:u.title,...C.providerMetadata!=null?{callProviderMetadata:C.providerMetadata}:{}})}async function _(u){if(u!=null){const I=l.message.metadata!=null?ma(l.message.metadata,u):u;e!=null&&await Tt({value:I,schema:e,context:{field:"message.metadata",entityId:l.message.id}}),l.message.metadata=I}}switch(n.type){case"text-start":{const u={type:"text",text:"",providerMetadata:n.providerMetadata,state:"streaming"};l.activeTextParts[n.id]=u,l.message.parts.push(u),p();break}case"text-delta":{const u=l.activeTextParts[n.id];if(u==null)throw new fe({chunkType:"text-delta",chunkId:n.id,message:`Received text-delta for missing text part with ID "${n.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});u.text+=n.delta,u.providerMetadata=(m=n.providerMetadata)!=null?m:u.providerMetadata,p();break}case"text-end":{const u=l.activeTextParts[n.id];if(u==null)throw new fe({chunkType:"text-end",chunkId:n.id,message:`Received text-end for missing text part with ID "${n.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});u.state="done",u.providerMetadata=(h=n.providerMetadata)!=null?h:u.providerMetadata,delete l.activeTextParts[n.id],p();break}case"reasoning-start":{const u={type:"reasoning",text:"",providerMetadata:n.providerMetadata,state:"streaming"};l.activeReasoningParts[n.id]=u,l.message.parts.push(u),p();break}case"reasoning-delta":{const u=l.activeReasoningParts[n.id];if(u==null)throw new fe({chunkType:"reasoning-delta",chunkId:n.id,message:`Received reasoning-delta for missing reasoning part with ID "${n.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});u.text+=n.delta,u.providerMetadata=(x=n.providerMetadata)!=null?x:u.providerMetadata,p();break}case"reasoning-end":{const u=l.activeReasoningParts[n.id];if(u==null)throw new fe({chunkType:"reasoning-end",chunkId:n.id,message:`Received reasoning-end for missing reasoning part with ID "${n.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});u.providerMetadata=(y=n.providerMetadata)!=null?y:u.providerMetadata,u.state="done",delete l.activeReasoningParts[n.id],p();break}case"file":{l.message.parts.push({type:"file",mediaType:n.mediaType,url:n.url}),p();break}case"source-url":{l.message.parts.push({type:"source-url",sourceId:n.sourceId,url:n.url,title:n.title,providerMetadata:n.providerMetadata}),p();break}case"source-document":{l.message.parts.push({type:"source-document",sourceId:n.sourceId,mediaType:n.mediaType,title:n.title,filename:n.filename,providerMetadata:n.providerMetadata}),p();break}case"tool-input-start":{const u=l.message.parts.filter(He);l.partialToolCalls[n.toolCallId]={text:"",toolName:n.toolName,index:u.length,dynamic:n.dynamic,title:n.title},n.dynamic?v({toolCallId:n.toolCallId,toolName:n.toolName,state:"input-streaming",input:void 0,providerExecuted:n.providerExecuted,title:n.title,providerMetadata:n.providerMetadata}):b({toolCallId:n.toolCallId,toolName:n.toolName,state:"input-streaming",input:void 0,providerExecuted:n.providerExecuted,title:n.title,providerMetadata:n.providerMetadata}),p();break}case"tool-input-delta":{const u=l.partialToolCalls[n.toolCallId];if(u==null)throw new fe({chunkType:"tool-input-delta",chunkId:n.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${n.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});u.text+=n.inputTextDelta;const{value:I}=await Ae(u.text);u.dynamic?v({toolCallId:n.toolCallId,toolName:u.toolName,state:"input-streaming",input:I,title:u.title}):b({toolCallId:n.toolCallId,toolName:u.toolName,state:"input-streaming",input:I,title:u.title}),p();break}case"tool-input-available":{n.dynamic?v({toolCallId:n.toolCallId,toolName:n.toolName,state:"input-available",input:n.input,providerExecuted:n.providerExecuted,providerMetadata:n.providerMetadata,title:n.title}):b({toolCallId:n.toolCallId,toolName:n.toolName,state:"input-available",input:n.input,providerExecuted:n.providerExecuted,providerMetadata:n.providerMetadata,title:n.title}),p(),o&&!n.providerExecuted&&await o({toolCall:n});break}case"tool-input-error":{n.dynamic?v({toolCallId:n.toolCallId,toolName:n.toolName,state:"output-error",input:n.input,errorText:n.errorText,providerExecuted:n.providerExecuted,providerMetadata:n.providerMetadata}):b({toolCallId:n.toolCallId,toolName:n.toolName,state:"output-error",input:void 0,rawInput:n.input,errorText:n.errorText,providerExecuted:n.providerExecuted,providerMetadata:n.providerMetadata}),p();break}case"tool-approval-request":{const u=g(n.toolCallId);u.state="approval-requested",u.approval={id:n.approvalId},p();break}case"tool-output-denied":{const u=g(n.toolCallId);u.state="output-denied",p();break}case"tool-output-available":{const u=g(n.toolCallId);u.type==="dynamic-tool"?v({toolCallId:n.toolCallId,toolName:u.toolName,state:"output-available",input:u.input,output:n.output,preliminary:n.preliminary,providerExecuted:n.providerExecuted,title:u.title}):b({toolCallId:n.toolCallId,toolName:Mt(u),state:"output-available",input:u.input,output:n.output,providerExecuted:n.providerExecuted,preliminary:n.preliminary,title:u.title}),p();break}case"tool-output-error":{const u=g(n.toolCallId);u.type==="dynamic-tool"?v({toolCallId:n.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:n.errorText,providerExecuted:n.providerExecuted,title:u.title}):b({toolCallId:n.toolCallId,toolName:Mt(u),state:"output-error",input:u.input,rawInput:u.rawInput,errorText:n.errorText,providerExecuted:n.providerExecuted,title:u.title}),p();break}case"start-step":{l.message.parts.push({type:"step-start"});break}case"finish-step":{l.activeTextParts={},l.activeReasoningParts={};break}case"start":{n.messageId!=null&&(l.message.id=n.messageId),await _(n.messageMetadata),(n.messageId!=null||n.messageMetadata!=null)&&p();break}case"finish":{n.finishReason!=null&&(l.finishReason=n.finishReason),await _(n.messageMetadata),n.messageMetadata!=null&&p();break}case"message-metadata":{await _(n.messageMetadata),n.messageMetadata!=null&&p();break}case"error":{r?.(new Error(n.errorText));break}default:if($r(n)){if(a?.[n.type]!=null){const A=l.message.parts.findIndex(C=>"id"in C&&"data"in C&&C.id===n.id&&C.type===n.type),N=A>=0?A:l.message.parts.length;await Tt({value:n.data,schema:a[n.type],context:{field:`message.parts[${N}].data`,entityName:n.type,entityId:n.id}})}const u=n;if(u.transient){i?.(u);break}const I=u.id!=null?l.message.parts.find(A=>u.type===A.type&&u.id===A.id):void 0;I!=null?I.data=u.data:l.message.parts.push(u),i?.(u),p()}}c.enqueue(n)})}}))}async function Ur({stream:t,onError:e}){const a=t.getReader();try{for(;;){const{done:s}=await a.read();if(s)break}}catch(s){e?.(s)}finally{a.releaseLock()}}Te({prefix:"aitxt",size:24});Te({prefix:"aiobj",size:24});var zr=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(t){return new Promise((e,a)=>{this.queue.push(async()=>{try{await t(),e()}catch(s){a(s)}}),this.processQueue()})}};Te({prefix:"aiobj",size:24});async function Br(t){if(t==null)return[];if(!globalThis.FileList||!(t instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(t).map(async e=>{const{name:a,type:s}=e,r=await new Promise((o,i)=>{const n=new FileReader;n.onload=c=>{var l;o((l=c.target)==null?void 0:l.result)},n.onerror=c=>i(c),n.readAsDataURL(e)});return{type:"file",mediaType:s,filename:a,url:r}}))}var Vr=class{constructor({api:t="/api/chat",credentials:e,headers:a,body:s,fetch:r,prepareSendMessagesRequest:o,prepareReconnectToStreamRequest:i}){this.api=t,this.credentials=e,this.headers=a,this.body=s,this.fetch=r,this.prepareSendMessagesRequest=o,this.prepareReconnectToStreamRequest=i}async sendMessages({abortSignal:t,...e}){var a,s,r,o,i;const n=await oe(this.body),c=await oe(this.headers),l=await oe(this.credentials),p={...de(c),...de(e.headers)},m=await((a=this.prepareSendMessagesRequest)==null?void 0:a.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...n,...e.body},headers:p,credentials:l,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),h=(s=m?.api)!=null?s:this.api,x=m?.headers!==void 0?de(m.headers):p,y=m?.body!==void 0?m.body:{...n,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},g=(r=m?.credentials)!=null?r:l,v=await((o=this.fetch)!=null?o:globalThis.fetch)(h,{method:"POST",headers:wt({"Content-Type":"application/json",...x},`ai-sdk/${At}`,It()),body:JSON.stringify(y),credentials:g,signal:t});if(!v.ok)throw new Error((i=await v.text())!=null?i:"Failed to fetch the chat response.");if(!v.body)throw new Error("The response body is empty.");return this.processResponseStream(v.body)}async reconnectToStream(t){var e,a,s,r,o;const i=await oe(this.body),n=await oe(this.headers),c=await oe(this.credentials),l={...de(n),...de(t.headers)},p=await((e=this.prepareReconnectToStreamRequest)==null?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...i,...t.body},headers:l,credentials:c,requestMetadata:t.metadata})),m=(a=p?.api)!=null?a:`${this.api}/${t.chatId}/stream`,h=p?.headers!==void 0?de(p.headers):l,x=(s=p?.credentials)!=null?s:c,g=await((r=this.fetch)!=null?r:globalThis.fetch)(m,{method:"GET",headers:wt(h,`ai-sdk/${At}`,It()),credentials:x});if(g.status===204)return null;if(!g.ok)throw new Error((o=await g.text())!=null?o:"Failed to fetch the chat response.");if(!g.body)throw new Error("The response body is empty.");return this.processResponseStream(g.body)}},fa=class extends Vr{constructor(t={}){super(t)}processResponseStream(t){return fr({stream:t,schema:Dr}).pipeThrough(new TransformStream({async transform(e,a){if(!e.success)throw e.error;a.enqueue(e.value)}}))}},qr=class{constructor({generateId:t=vs,id:e=t(),transport:a=new fa,messageMetadataSchema:s,dataPartSchemas:r,state:o,onError:i,onToolCall:n,onFinish:c,onData:l,sendAutomaticallyWhen:p}){this.activeResponse=void 0,this.jobExecutor=new zr,this.sendMessage=async(m,h)=>{var x,y,g,b;if(m==null){await this.makeRequest({trigger:"submit-message",messageId:(x=this.lastMessage)==null?void 0:x.id,...h});return}let v;if("text"in m||"files"in m?v={parts:[...Array.isArray(m.files)?m.files:await Br(m.files),..."text"in m&&m.text!=null?[{type:"text",text:m.text}]:[]]}:v=m,m.messageId!=null){const _=this.state.messages.findIndex(u=>u.id===m.messageId);if(_===-1)throw new Error(`message with id ${m.messageId} not found`);if(this.state.messages[_].role!=="user")throw new Error(`message with id ${m.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,_+1),this.state.replaceMessage(_,{...v,id:m.messageId,role:(y=v.role)!=null?y:"user",metadata:m.metadata})}else this.state.pushMessage({...v,id:(g=v.id)!=null?g:this.generateId(),role:(b=v.role)!=null?b:"user",metadata:m.metadata});await this.makeRequest({trigger:"submit-message",messageId:m.messageId,...h})},this.regenerate=async({messageId:m,...h}={})=>{const x=m==null?this.state.messages.length-1:this.state.messages.findIndex(y=>y.id===m);if(x===-1)throw new Error(`message ${m} not found`);this.state.messages=this.state.messages.slice(0,this.messages[x].role==="assistant"?x:x+1),await this.makeRequest({trigger:"regenerate-message",messageId:m,...h})},this.resumeStream=async(m={})=>{await this.makeRequest({trigger:"resume-stream",...m})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:m,approved:h,reason:x})=>this.jobExecutor.run(async()=>{const y=this.state.messages,g=y[y.length-1],b=v=>Ye(v)&&v.state==="approval-requested"&&v.approval.id===m?{...v,state:"approval-responded",approval:{id:m,approved:h,reason:x}}:v;this.state.replaceMessage(y.length-1,{...g,parts:g.parts.map(b)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(b)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(v=>{var _;v&&this.makeRequest({trigger:"submit-message",messageId:(_=this.lastMessage)==null?void 0:_.id})})}),this.addToolOutput=async({state:m="output-available",tool:h,toolCallId:x,output:y,errorText:g})=>this.jobExecutor.run(async()=>{const b=this.state.messages,v=b[b.length-1],_=u=>Ye(u)&&u.toolCallId===x?{...u,state:m,output:y,errorText:g}:u;this.state.replaceMessage(b.length-1,{...v,parts:v.parts.map(_)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(_)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(u=>{var I;u&&this.makeRequest({trigger:"submit-message",messageId:(I=this.lastMessage)==null?void 0:I.id})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var m;this.status!=="streaming"&&this.status!=="submitted"||(m=this.activeResponse)!=null&&m.abortController&&this.activeResponse.abortController.abort()},this.id=e,this.transport=a,this.generateId=t,this.messageMetadataSchema=s,this.dataPartSchemas=r,this.state=o,this.onError=i,this.onToolCall=n,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=p}get status(){return this.state.status}setStatus({status:t,error:e}){this.status!==t&&(this.state.status=t,this.state.error=e)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(t){this.state.messages=t}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const t=this.sendAutomaticallyWhen({messages:this.state.messages});return t&&typeof t=="object"&&"then"in t?await t:t}async makeRequest({trigger:t,metadata:e,headers:a,body:s,messageId:r}){var o,i,n;this.setStatus({status:"submitted",error:void 0});const c=this.lastMessage;let l=!1,p=!1,m=!1;try{const h={state:Zr({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{l=!0}),this.activeResponse=h;let x;if(t==="resume-stream"){const g=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:a,body:s});if(g==null){this.setStatus({status:"ready"});return}x=g}else x=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:e,headers:a,body:s,trigger:t,messageId:r});const y=g=>this.jobExecutor.run(()=>g({state:h.state,write:()=>{var b;this.setStatus({status:"streaming"}),h.state.message.id===((b=this.lastMessage)==null?void 0:b.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await Ur({stream:Fr({stream:x,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:y,onError:g=>{throw g}}),onError:g=>{throw g}}),this.setStatus({status:"ready"})}catch(h){if(l||h.name==="AbortError")return l=!0,this.setStatus({status:"ready"}),null;m=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(p=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(i=this.onFinish)==null||i.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:l,isDisconnect:p,isError:m,finishReason:(o=this.activeResponse)==null?void 0:o.state.finishReason})}catch(h){console.error(h)}this.activeResponse=void 0}!m&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(n=this.lastMessage)==null?void 0:n.id,metadata:e,headers:a,body:s})}},ze,Rt;function Wr(){if(Rt)return ze;Rt=1;function t(e,a){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let s,r=0;return function(...i){clearTimeout(s);const n=Date.now(),c=n-r,l=a-c;l<=0?(r=n,e.apply(this,i)):s=setTimeout(()=>{r=Date.now(),e.apply(this,i)},l)}}return ze=t,ze}var Jr=Wr();const Hr=Da(Jr);var ha=(t,e,a)=>{if(!e.has(t))throw TypeError("Cannot "+a)},k=(t,e,a)=>(ha(t,e,"read from private field"),a?a.call(t):e.get(t)),Q=(t,e,a)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,a)},re=(t,e,a,s)=>(ha(t,e,"write to private field"),e.set(t,a),a);function Yr(t,e){return e!=null?Hr(t,e):t}var J,Re,je,xe,be,_e,he,Ge,Qe,Gr=class{constructor(t=[]){Q(this,J,void 0),Q(this,Re,"ready"),Q(this,je,void 0),Q(this,xe,new Set),Q(this,be,new Set),Q(this,_e,new Set),this.pushMessage=e=>{re(this,J,k(this,J).concat(e)),k(this,he).call(this)},this.popMessage=()=>{re(this,J,k(this,J).slice(0,-1)),k(this,he).call(this)},this.replaceMessage=(e,a)=>{re(this,J,[...k(this,J).slice(0,e),this.snapshot(a),...k(this,J).slice(e+1)]),k(this,he).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,a)=>{const s=a?Yr(e,a):e;return k(this,xe).add(s),()=>{k(this,xe).delete(s)}},this["~registerStatusCallback"]=e=>(k(this,be).add(e),()=>{k(this,be).delete(e)}),this["~registerErrorCallback"]=e=>(k(this,_e).add(e),()=>{k(this,_e).delete(e)}),Q(this,he,()=>{k(this,xe).forEach(e=>e())}),Q(this,Ge,()=>{k(this,be).forEach(e=>e())}),Q(this,Qe,()=>{k(this,_e).forEach(e=>e())}),re(this,J,t)}get status(){return k(this,Re)}set status(t){re(this,Re,t),k(this,Ge).call(this)}get error(){return k(this,je)}set error(t){re(this,je,t),k(this,Qe).call(this)}get messages(){return k(this,J)}set messages(t){re(this,J,[...t]),k(this,he).call(this)}};J=new WeakMap;Re=new WeakMap;je=new WeakMap;xe=new WeakMap;be=new WeakMap;_e=new WeakMap;he=new WeakMap;Ge=new WeakMap;Qe=new WeakMap;var ge,jt=class extends qr{constructor({messages:t,...e}){const a=new Gr(t);super({...e,state:a}),Q(this,ge,void 0),this["~registerMessagesCallback"]=(s,r)=>k(this,ge)["~registerMessagesCallback"](s,r),this["~registerStatusCallback"]=s=>k(this,ge)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>k(this,ge)["~registerErrorCallback"](s),re(this,ge,a)}};ge=new WeakMap;function Qr({experimental_throttle:t,resume:e=!1,...a}={}){const s=S.useRef("chat"in a?{}:{onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});"chat"in a||(s.current={onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});const r={...a,onToolCall:h=>{var x,y;return(y=(x=s.current).onToolCall)==null?void 0:y.call(x,h)},onData:h=>{var x,y;return(y=(x=s.current).onData)==null?void 0:y.call(x,h)},onFinish:h=>{var x,y;return(y=(x=s.current).onFinish)==null?void 0:y.call(x,h)},onError:h=>{var x,y;return(y=(x=s.current).onError)==null?void 0:y.call(x,h)},sendAutomaticallyWhen:h=>{var x,y,g;return(g=(y=(x=s.current).sendAutomaticallyWhen)==null?void 0:y.call(x,h))!=null?g:!1}},o=S.useRef("chat"in a?a.chat:new jt(r));("chat"in a&&a.chat!==o.current||"id"in a&&o.current.id!==a.id)&&(o.current="chat"in a?a.chat:new jt(r));const n=S.useCallback(h=>o.current["~registerMessagesCallback"](h,t),[t,o.current.id]),c=S.useSyncExternalStore(n,()=>o.current.messages,()=>o.current.messages),l=S.useSyncExternalStore(o.current["~registerStatusCallback"],()=>o.current.status,()=>o.current.status),p=S.useSyncExternalStore(o.current["~registerErrorCallback"],()=>o.current.error,()=>o.current.error),m=S.useCallback(h=>{typeof h=="function"&&(h=h(o.current.messages)),o.current.messages=h},[o]);return S.useEffect(()=>{e&&o.current.resumeStream()},[e,o]),{id:o.current.id,messages:c,setMessages:m,sendMessage:o.current.sendMessage,regenerate:o.current.regenerate,clearError:o.current.clearError,stop:o.current.stop,error:p,resumeStream:o.current.resumeStream,status:l,addToolResult:o.current.addToolOutput,addToolOutput:o.current.addToolOutput,addToolApprovalResponse:o.current.addToolApprovalResponse}}function Xr(t,e){const a=D.c(5);let s;a[0]!==e?(s=e===void 0?{}:e,a[0]=e,a[1]=s):s=a[1];const r=s,{org:o}=Ce(),i=t??null;let n;a[2]!==o.id||a[3]!==i?(n={connectionId:i,orgId:o.id},a[2]=o.id,a[3]=i,a[4]=n):n=a[4];const c=Pe(n);return $t(t??"no-connection","LLM",c,r)}function rt(){const t=D.c(2),e=Ha();let a;return t[0]!==e?(a={connections:e,binding:"LLMS"},t[0]=e,t[1]=a):a=t[1],Ya(a)}function Kr(t){const e=D.c(10);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const s=Pt(a);let r;if(e[1]!==s.collectionName||e[2]!==s.connectionId||e[3]!==s.itemId||e[4]!==t){r=[],t&&r.push(`### Selected Agent
12
- - ID: ${t}`);let o;e[6]!==s.collectionName||e[7]!==s.connectionId||e[8]!==s.itemId?(o=[],s.connectionId&&o.push(`- Connection ID: ${s.connectionId}`),s.collectionName&&o.push(`- Collection: ${s.collectionName}`),s.itemId&&o.push(`- Item ID: ${s.itemId}`),e[6]=s.collectionName,e[7]=s.connectionId,e[8]=s.itemId,e[9]=o):o=e[9],o.length>0&&r.push(`### Current Resource
13
- The user is viewing the following resource:
14
- ${o.join(`
15
- `)}
16
-
17
- Help the user understand and work with this resource.`),e[1]=s.collectionName,e[2]=s.connectionId,e[3]=s.itemId,e[4]=t,e[5]=r}else r=e[5];return r.join(`
18
-
19
- `)}const ga=50;function eo(){const t=D.c(17),{locator:e,org:a}=Ce();let s;t[0]!==a.id?(s={connectionId:et,orgId:a.id},t[0]=a.id,t[1]=s):s=t[1];const r=Pe(s);let o;t[2]!==e?(o=Dt.threads(e),t[2]=e,t[3]=o):o=t[3];let i;t[4]!==r?(i=async b=>{const{pageParam:v}=b,_=v===void 0?0:v;if(!r)throw new Error("MCP client is not available");const u={limit:ga,offset:_},I=await r.callTool({name:"COLLECTION_THREADS_LIST",arguments:u}),A=I.structuredContent??I;return{items:A.items??[],hasMore:A.hasMore??!1,totalCount:A.totalCount}},t[4]=r,t[5]=i):i=t[5];let n;t[6]!==o||t[7]!==i?(n={queryKey:o,queryFn:i,getNextPageParam:ao,initialPageParam:0,staleTime:3e4},t[6]=o,t[7]=i,t[8]=n):n=t[8];const{data:c,fetchNextPage:l,hasNextPage:p,isFetchingNextPage:m,refetch:h}=Ga(n);let x;t[9]!==c?.pages?(x=c?.pages.flatMap(to)??[],t[9]=c?.pages,t[10]=x):x=t[10];const y=x;let g;return t[11]!==l||t[12]!==p||t[13]!==m||t[14]!==h||t[15]!==y?(g={threads:y,refetch:h,hasNextPage:p,isFetchingNextPage:m,fetchNextPage:l},t[11]=l,t[12]=p,t[13]=m,t[14]=h,t[15]=y,t[16]=g):g=t[16],g}function to(t){return t.items}function ao(t,e){if(t.hasMore)return e.length*ga}function so(t){const e=D.c(6),{org:a}=Ce();let s;e[0]!==a.id?(s={connectionId:et,orgId:a.id},e[0]=a.id,e[1]=s):s=e[1];const r=Pe(s);let o;e[2]!==t?(o={filters:t?[{column:"threadId",value:t}]:[],pageSize:100},e[2]=t,e[3]=o):o=e[3];const i=$t(a.id,"THREAD_MESSAGES",r,o);let n;return e[4]!==i?(n=i??[],e[4]=i,e[5]=n):n=e[5],n}function ro(){const t=D.c(5),e=$a(),{org:a}=Ce();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},t[0]=s):s=t[0];const r=Pt(s);let o;return t[1]!==a||t[2]!==r||t[3]!==e?(o=i=>{const c=i.toolCall.toolName.match(/^COLLECTION_([A-Z_]+)_(CREATE|UPDATE|DELETE)$/);if(!c||!c[1])return;const l=c[1],p=r.connectionId;if(!p)return;e.invalidateQueries({queryKey:Dt.collection(a.slug,p,l)});const m=l.toLowerCase().replace(/_/g," ");Be.success(`${m} updated`)},t[1]=a,t[2]=r,t[3]=e,t[4]=o):o=t[4],o}function B(t){const e=D.c(8);let a,s;e[0]!==t?({className:a,...s}=t,e[0]=t,e[1]=a,e[2]=s):(a=e[1],s=e[2]);let r;e[3]!==a?(r=tt("bg-accent animate-pulse rounded-md",a),e[3]=a,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=d.jsx("div",{"data-slot":"skeleton",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const oo=["x-ai/grok-code-fast-1","anthropic/claude-sonnet-4.5","google/gemini-2.5-flash","xiaomi/mimo-v2-flash:free","google/gemini-3-flash-preview","deepseek/deepseek-v3.2","anthropic/claude-opus-4.5","x-ai/grok-4.1-fast","google/gemini-2.5-flash-lite","google/gemini-2.0-flash-001"],Xe=new Map;oo.forEach((t,e)=>{Xe.set(t,e)});function ot(t){const e=D.c(3);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={pageSize:999},e[0]=a):a=e[0];const s=Xr(t??void 0,a);let r;return e[1]!==s?(r=s.filter(io).sort(no),e[1]=s,e[2]=r):r=e[2],r}function no(t,e){const a=Xe.get(t.id),s=Xe.get(e.id);return a!==void 0&&s!==void 0?a-s:a!==void 0?-1:s!==void 0?1:t.title.localeCompare(e.title)}function io(t){return t.limits?.contextWindow&&t.limits?.maxOutputTokens}const lo={reasoning:{icon:d.jsx(zt,{className:"size-4"}),label:"Reasoning"},"image-upload":{icon:d.jsx(cs,{className:"size-4"}),label:"Can analyze images"},"file-upload":{icon:d.jsx(is,{className:"size-4"}),label:"Can analyze files"},"web-search":{icon:d.jsx(Lt,{className:"size-4"}),label:"Can search the web to answer questions"}};function va(t){const e=D.c(10),{capability:a}=t,s=lo[a];let r,o;e[0]!==a||e[1]!==s?(r=s||{icon:null,label:a},o=r.label.split("-").map(co).join(" "),e[0]=a,e[1]=s,e[2]=r,e[3]=o):(r=e[2],o=e[3]);const i=o;let n;e[4]===Symbol.for("react.memo_cache_sentinel")?(n={backgroundColor:"color-mix(in oklch, var(--chart-1) 15%, transparent)",color:"var(--chart-1)"},e[4]=n):n=e[4];let c;e[5]!==i?(c=d.jsx("span",{children:i}),e[5]=i,e[6]=c):c=e[6];let l;return e[7]!==r.icon||e[8]!==c?(l=d.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 px-1.5 rounded-md text-xs font-medium",style:n,children:[r.icon,c]}),e[7]=r.icon,e[8]=c,e[9]=l):l=e[9],l}function co(t){return t.charAt(0).toUpperCase()+t.slice(1)}function uo(t){const e=D.c(53),{model:a,compact:s}=t,r=s===void 0?!1:s;if(!a){let b;return e[0]===Symbol.for("react.memo_cache_sentinel")?(b=d.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Hover to preview"}),e[0]=b):b=e[0],b}const o=a.limits?.contextWindow||a.costs?.input||a.costs?.output||a.limits?.maxOutputTokens;if(!o&&!r){let b;e[1]!==a.logo||e[2]!==a.title?(b=a.logo&&d.jsx("img",{src:a.logo,className:"w-6 h-6",alt:a.title}),e[1]=a.logo,e[2]=a.title,e[3]=b):b=e[3];let v;e[4]!==a.title?(v=d.jsx("p",{className:"text-lg font-medium leading-7",children:a.title}),e[4]=a.title,e[5]=v):v=e[5];let _;e[6]!==b||e[7]!==v?(_=d.jsxs("div",{className:"flex items-center gap-3 py-2 px-0",children:[b,v]}),e[6]=b,e[7]=v,e[8]=_):_=e[8];let u;e[9]!==a.description?(u=a.description&&d.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),e[9]=a.description,e[10]=u):u=e[10];let I;return e[11]!==_||e[12]!==u?(I=d.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[_,u]}),e[11]=_,e[12]=u,e[13]=I):I=e[13],I}if(!o&&r)return null;if(r){let b;e[14]!==a.limits?(b=a.limits?.contextWindow&&d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted-foreground",children:"Context"}),d.jsxs("span",{className:"text-foreground font-medium",children:[a.limits.contextWindow.toLocaleString()," tokens"]})]}),e[14]=a.limits,e[15]=b):b=e[15];let v;e[16]!==a.costs?(v=a.costs?.input&&d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted-foreground",children:"Input cost"}),d.jsxs("span",{className:"text-foreground font-medium",children:["$",a.costs.input.toFixed(2)," / 1M"]})]}),e[16]=a.costs,e[17]=v):v=e[17];let _;e[18]!==a.costs?(_=a.costs?.output&&d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted-foreground",children:"Output cost"}),d.jsxs("span",{className:"text-foreground font-medium",children:["$",a.costs.output.toFixed(2)," / 1M"]})]}),e[18]=a.costs,e[19]=_):_=e[19];let u;e[20]!==a.limits?(u=a.limits?.maxOutputTokens&&d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),d.jsxs("span",{className:"text-foreground font-medium",children:[a.limits.maxOutputTokens.toLocaleString()," tokens"]})]}),e[20]=a.limits,e[21]=u):u=e[21];let I;return e[22]!==b||e[23]!==v||e[24]!==_||e[25]!==u?(I=d.jsxs("div",{className:"flex flex-col gap-2.5 pt-3 pb-3 px-3 rounded-b-lg text-xs",children:[b,v,_,u]}),e[22]=b,e[23]=v,e[24]=_,e[25]=u,e[26]=I):I=e[26],I}let i;e[27]!==a.logo||e[28]!==a.title?(i=a.logo&&d.jsx("img",{src:a.logo,className:"w-6 h-6 shrink-0",alt:a.title}),e[27]=a.logo,e[28]=a.title,e[29]=i):i=e[29];let n;e[30]!==a.title?(n=d.jsx("p",{className:"text-lg font-medium leading-7 wrap-break-word min-w-0",children:a.title}),e[30]=a.title,e[31]=n):n=e[31];let c;e[32]!==i||e[33]!==n?(c=d.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i,n]}),e[32]=i,e[33]=n,e[34]=c):c=e[34];let l;e[35]!==a.capabilities?(l=a.capabilities&&a.capabilities.length>0&&d.jsx("div",{className:"flex items-center gap-2",children:a.capabilities.map(po)}),e[35]=a.capabilities,e[36]=l):l=e[36];let p;e[37]!==c||e[38]!==l?(p=d.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[c,l]}),e[37]=c,e[38]=l,e[39]=p):p=e[39];let m;e[40]!==a.limits?(m=a.limits?.contextWindow&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(ls,{className:"w-3.5 h-3.5 text-muted-foreground"}),d.jsx("p",{className:"text-sm text-foreground",children:"Context window"})]}),d.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.limits.contextWindow.toLocaleString()," tokens"]})]}),e[40]=a.limits,e[41]=m):m=e[41];let h;e[42]!==a.costs?(h=(a.costs?.input||a.costs?.output)&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(Ft,{className:"w-3.5 h-3.5 text-muted-foreground"}),d.jsx("p",{className:"text-sm text-foreground",children:"Costs"})]}),d.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.costs?.input!==null&&a.costs?.input!==void 0&&d.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",a.costs.input.toFixed(2)," / 1M tokens (input)"]}),a.costs?.output!==null&&a.costs?.output!==void 0&&d.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",a.costs.output.toFixed(2)," / 1M tokens (output)"]})]})]}),e[42]=a.costs,e[43]=h):h=e[43];let x;e[44]!==a.limits?(x=a.limits?.maxOutputTokens&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(Ut,{className:"w-4.5 h-4.5 text-muted-foreground/70"}),d.jsx("p",{className:"text-sm text-foreground",children:"Output limit"})]}),d.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.limits.maxOutputTokens.toLocaleString()," token limit"]})]}),e[44]=a.limits,e[45]=x):x=e[45];let y;e[46]!==m||e[47]!==h||e[48]!==x?(y=d.jsxs("div",{className:"flex flex-col gap-4",children:[m,h,x]}),e[46]=m,e[47]=h,e[48]=x,e[49]=y):y=e[49];let g;return e[50]!==y||e[51]!==p?(g=d.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[p,y]}),e[50]=y,e[51]=p,e[52]=g):g=e[52],g}function po(t){return d.jsx(va,{capability:t},t)}function mo(t){const e=D.c(15),{model:a,onHover:s}=t;let r;e[0]!==a||e[1]!==s?(r=()=>s(a),e[0]=a,e[1]=s,e[2]=r):r=e[2];let o;e[3]!==a.logo||e[4]!==a.title?(o=a.logo&&d.jsx("img",{src:a.logo,className:"w-5 h-5 shrink-0",alt:a.title}),e[3]=a.logo,e[4]=a.title,e[5]=o):o=e[5];let i;e[6]!==a.title?(i=d.jsx("span",{className:"text-sm text-foreground flex-1 min-w-0 line-clamp-1",children:a.title}),e[6]=a.title,e[7]=i):i=e[7];let n;e[8]!==a.capabilities?(n=a.capabilities&&a.capabilities.length>0&&d.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:a.capabilities.slice(0,2).map(fo)}),e[8]=a.capabilities,e[9]=n):n=e[9];let c;return e[10]!==r||e[11]!==o||e[12]!==i||e[13]!==n?(c=d.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:r,children:[o,i,n]}),e[10]=r,e[11]=o,e[12]=i,e[13]=n,e[14]=c):c=e[14],c}function fo(t){return d.jsx(va,{capability:t},t)}function ho(t){const e=D.c(14),{model:a,placeholder:s}=t,r=s===void 0?"Select model":s;if(!a){let l;e[0]!==r?(l=d.jsx("span",{className:"text-sm text-muted-foreground",children:r}),e[0]=r,e[1]=l):l=e[1];let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=d.jsx(dt,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[2]=p):p=e[2];let m;return e[3]!==l?(m=d.jsxs("div",{className:"flex items-center gap-1.5",children:[l,p]}),e[3]=l,e[4]=m):m=e[4],m}let o;e[5]!==a.logo||e[6]!==a.title?(o=a.logo&&d.jsx("img",{src:a.logo,className:"w-5 h-5 shrink-0 rounded-sm",alt:a.title}),e[5]=a.logo,e[6]=a.title,e[7]=o):o=e[7];let i;e[8]!==a.title?(i=d.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground group-data-[state=open]:text-foreground truncate whitespace-nowrap max-w-0 opacity-0 group-hover:max-w-[150px] group-hover:opacity-100 group-data-[state=open]:max-w-[150px] group-data-[state=open]:opacity-100 transition-all duration-200 ease-in-out overflow-hidden",children:a.title}),e[8]=a.title,e[9]=i):i=e[9];let n;e[10]===Symbol.for("react.memo_cache_sentinel")?(n=d.jsx(dt,{size:14,className:"text-muted-foreground opacity-0 max-w-0 group-hover:opacity-50 group-hover:max-w-[14px] group-data-[state=open]:opacity-50 group-data-[state=open]:max-w-[14px] shrink-0 transition-all duration-200 ease-in-out overflow-hidden"}),e[10]=n):n=e[10];let c;return e[11]!==o||e[12]!==i?(c=d.jsxs("div",{className:"flex items-center gap-0 group-hover:gap-2 group-data-[state=open]:gap-2 min-w-0 overflow-hidden transition-all duration-200",children:[o,i,n]}),e[11]=o,e[12]=i,e[13]=c):c=e[13],c}function Qo(t){return t?.capabilities?.includes("vision")===!0}function go(){const t=D.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=d.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:d.jsxs("div",{className:"flex items-center gap-2.5 h-12 px-4",children:[d.jsx(B,{className:"size-4 shrink-0"}),d.jsx(B,{className:"flex-1 h-6"}),d.jsx(B,{className:"w-[140px] h-8 shrink-0"})]})}),t[0]=e):e=t[0];let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=d.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[400px] md:min-w-[400px]",children:[e,d.jsx("div",{className:"flex-1 overflow-y-auto px-0.5 pt-2 space-y-1",children:Array.from({length:6}).map(vo)})]}),t[1]=a):a=t[1];let s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=d.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[d.jsx(B,{className:"size-6 shrink-0"}),d.jsx(B,{className:"h-6 w-32"})]}),t[2]=s):s=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=d.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[s,d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(B,{className:"h-6 w-20 rounded-md"}),d.jsx(B,{className:"h-6 w-24 rounded-md"})]})]}),t[3]=r):r=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx(B,{className:"h-4 w-24"}),d.jsx(B,{className:"h-4 w-32"})]}),t[4]=o):o=t[4];let i;return t[5]===Symbol.for("react.memo_cache_sentinel")?(i=d.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[a,d.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:d.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[r,d.jsxs("div",{className:"flex flex-col gap-4",children:[o,d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx(B,{className:"h-4 w-16"}),d.jsx(B,{className:"h-4 w-40"})]})]})]})})]}),t[5]=i):i=t[5],i}function vo(t,e){return d.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[d.jsx(B,{className:"size-5 shrink-0 rounded-sm"}),d.jsx(B,{className:"flex-1 h-4"}),d.jsx(B,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function yo(t){const e=D.c(39),{selectedModel:a,onModelChange:s,onClose:r,modelsConnections:o}=t,[i,n]=S.useState(null),[c,l]=S.useState(""),p=S.useRef(null),[m,h]=S.useState(a?.connectionId??null),x=rt(),y=o??x,g=ot(m);let b,v;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{setTimeout(()=>{p.current?.focus()},0)},v=[],e[0]=b,e[1]=v):(b=e[0],v=e[1]),S.useEffect(b,v);let _;e[2]!==g||e[3]!==c?(_=c.trim()?g.filter($=>{const W=c.toLowerCase();return $.title.toLowerCase().includes(W)||$.provider?.toLowerCase().includes(W)||$.description?.toLowerCase().includes(W)}):g,e[2]=g,e[3]=c,e[4]=_):_=e[4];const u=_;let I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=$=>{h($)},e[5]=I):I=e[5];const A=I;let N;e[6]!==g||e[7]!==r||e[8]!==s||e[9]!==m?(N=$=>{const W=g.find(Le=>Le.id===$);!W||!m||(s({id:W.id,connectionId:m,provider:W.provider??void 0}),l(""),r())},e[6]=g,e[7]=r,e[8]=s,e[9]=m,e[10]=N):N=e[10];const C=N;let O;e[11]===Symbol.for("react.memo_cache_sentinel")?(O=d.jsx(Lt,{size:16,className:"text-muted-foreground shrink-0"}),e[11]=O):O=e[11];let Z;e[12]===Symbol.for("react.memo_cache_sentinel")?(Z=$=>l($.target.value),e[12]=Z):Z=e[12];let z;e[13]!==c?(z=d.jsx(Xa,{ref:p,type:"text",placeholder:"Search for a model...",value:c,onChange:Z,className:"flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"}),e[13]=c,e[14]=z):z=e[14];let G;e[15]!==y||e[16]!==m?(G=y.length>0&&d.jsxs(as,{value:m??"",onValueChange:A,children:[d.jsxs(ss,{size:"sm",className:"w-auto min-w-[140px] h-8 shrink-0 [&>svg:last-child]:hidden",onClick:bo,children:[d.jsx(rs,{placeholder:"Select connection"}),d.jsx(Zt,{className:"size-4 opacity-50 shrink-0 pointer-events-none"})]}),d.jsx(os,{children:y.map(xo)})]}),e[15]=y,e[16]=m,e[17]=G):G=e[17];let K;e[18]!==z||e[19]!==G?(K=d.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:d.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[O,z,G]})}),e[18]=z,e[19]=G,e[20]=K):K=e[20];let ie;e[21]!==u||e[22]!==C||e[23]!==a?.id?(ie=u.length>0?u.map($=>{const W=$.id===a?.id;return d.jsx("div",{onClick:()=>C($.id),className:tt("rounded-lg mb-1",W&&"bg-accent"),children:d.jsx(mo,{model:$,onHover:n})},$.id)}):d.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No models found"}),e[21]=u,e[22]=C,e[23]=a?.id,e[24]=ie):ie=e[24];let le;e[25]!==ie?(le=d.jsx("div",{className:"flex-1 overflow-y-auto px-0.5 pt-2",children:ie}),e[25]=ie,e[26]=le):le=e[26];let L;e[27]!==K||e[28]!==le?(L=d.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[400px] md:min-w-[400px]",children:[K,le]}),e[27]=K,e[28]=le,e[29]=L):L=e[29];let ee;e[30]!==i||e[31]!==g||e[32]!==a?(ee=i||(a?g.find($=>$.id===a.id):null)||null,e[30]=i,e[31]=g,e[32]=a,e[33]=ee):ee=e[33];let te;e[34]!==ee?(te=d.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:d.jsx(uo,{model:ee})}),e[34]=ee,e[35]=te):te=e[35];let me;return e[36]!==L||e[37]!==te?(me=d.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[L,te]}),e[36]=L,e[37]=te,e[38]=me):me=e[38],me}function xo(t){return d.jsx(ns,{value:t.id,children:d.jsxs("div",{className:"flex items-center gap-2",children:[t.icon?d.jsx("img",{src:t.icon,alt:t.title,className:"w-4 h-4 rounded"}):d.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:t.title.slice(0,1).toUpperCase()}),d.jsx("span",{children:t.title})]})},t.id)}function bo(t){return t.stopPropagation()}function Xo(t){const e=D.c(23),{selectedModel:a,onModelChange:s,modelsConnections:r,variant:o,className:i,placeholder:n}=t,c=o===void 0?"borderless":o,l=n===void 0?"Select model":n,[p,m]=S.useState(!1),h=rt(),x=r??h,y=a?.connectionId??null,g=ot(y);let b;e[0]!==g||e[1]!==a?(b=a?g.find(G=>G.id===a.id):void 0,e[0]=g,e[1]=a,e[2]=b):b=e[2];const v=b;if(x.length===0)return null;const _=c==="borderless"?"ghost":"outline",u=c==="borderless"&&"md:border-none";let I;e[3]!==i||e[4]!==u?(I=tt("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer border-0 group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 shrink justify-start overflow-hidden",u,i),e[3]=i,e[4]=u,e[5]=I):I=e[5];let A;e[6]!==v||e[7]!==l?(A=d.jsx(ho,{model:v,placeholder:l}),e[6]=v,e[7]=l,e[8]=A):A=e[8];let N;e[9]!==_||e[10]!==I||e[11]!==A?(N=d.jsx(Ka,{asChild:!0,children:d.jsx(Qa,{variant:_,size:"sm",className:I,children:A})}),e[9]=_,e[10]=I,e[11]=A,e[12]=N):N=e[12];let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=d.jsx(go,{}),e[13]=C):C=e[13];let O;e[14]===Symbol.for("react.memo_cache_sentinel")?(O=()=>m(!1),e[14]=O):O=e[14];let Z;e[15]!==x||e[16]!==s||e[17]!==a?(Z=d.jsx(es,{className:"w-full md:w-auto p-0",align:"start",side:"bottom",sideOffset:8,children:d.jsx(S.Suspense,{fallback:C,children:d.jsx(yo,{selectedModel:a,onModelChange:s,onClose:O,modelsConnections:x})})}),e[15]=x,e[16]=s,e[17]=a,e[18]=Z):Z=e[18];let z;return e[19]!==p||e[20]!==Z||e[21]!==N?(z=d.jsxs(ts,{open:p,onOpenChange:m,children:[N,Z]}),e[19]=p,e[20]=Z,e[21]=N,e[22]=z):z=e[22],z}const _o=t=>new fa({api:`/api/${t}/decopilot/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:a={}})=>{const{system:s,tiptapDoc:r,...o}=a,i=s?{id:crypto.randomUUID(),role:"system",parts:[{type:"text",text:s}]}:null,n=e.slice(-1).filter(Boolean);return{body:{messages:i?[i,...n]:n,...o}}}}),kt=(t,e)=>t?.find(a=>a.id===e)??t?.[0]??null,Eo=(t,e)=>{const a=D.c(17);let s;a[0]!==t?(s=Ve.chatSelectedModel(t),a[0]=t,a[1]=s):s=a[1];const[r,o]=Me(s,null),i=r?.connectionId;let n;a[2]!==e||a[3]!==i?(n=kt(e,i),a[2]=e,a[3]=i,a[4]=n):n=a[4];const c=n,l=ot(c?.id??null);let p;a[5]!==l?(p=l.filter(Ao).reduce(Mo,void 0),a[5]=l,a[6]=p):p=a[6];const m=p,h=r?.id;let x;a[7]!==l||a[8]!==h?(x=kt(l,h),a[7]=l,a[8]=h,a[9]=x):x=a[9];const y=x;let g;a[10]!==m?.id||a[11]!==c||a[12]!==y?(g=y&&c?.id?{id:y.id,provider:y.provider,limits:y.limits,capabilities:y.capabilities,connectionId:c.id,fastId:m?.id}:null,a[10]=m?.id,a[11]=c,a[12]=y,a[13]=g):g=a[13];const b=g;let v;return a[14]!==b||a[15]!==o?(v=[b,o],a[14]=b,a[15]=o,a[16]=v):v=a[16],v},ya={tiptapDoc:void 0,parentThread:null,finishReason:null};function Io(t,e){switch(e.type){case"SET_TIPTAP_DOC":return{...t,tiptapDoc:e.payload};case"CLEAR_TIPTAP_DOC":return{...t,tiptapDoc:void 0};case"START_BRANCH":return{...t,parentThread:e.payload};case"CLEAR_BRANCH":return{...t,parentThread:null};case"SET_FINISH_REASON":return{...t,finishReason:e.payload};case"CLEAR_FINISH_REASON":return{...t,finishReason:null};case"RESET":return ya;default:return t}}function wo(t,e){const a=[];for(const s of t)"text"in s&&s.text?a.push({type:"text",text:`[${e}]
20
- ${s.text}`}):"blob"in s&&s.blob&&s.mimeType&&a.push({type:"file",url:`data:${s.mimeType};base64,${s.blob}`,filename:String(s.uri),mediaType:String(s.mimeType)});return a}function So(t,e){const a=[];for(const s of t){if(s.role!=="user"||!s.content)continue;const r=Array.isArray(s.content)?s.content:[s.content];for(const o of r)switch(o.type){case"text":{const i=o.text?.trim();if(!i)continue;a.push({type:"text",text:`[${e}]
21
- ${i}`});break}case"image":case"audio":{if(!o.data||!o.mimeType)continue;a.push({type:"file",url:`data:${o.mimeType};base64,${o.data}`,mediaType:o.mimeType});break}case"resource":{const i=o.resource;if(!i||!i.mimeType)continue;i&&("text"in i&&i.text?a.push({type:"text",text:`[${e}]
22
- ${i.text}`}):"blob"in i&&i.blob&&i.mimeType&&a.push({type:"file",url:`data:${i.mimeType};base64,${i.blob}`,filename:String(i.uri),mediaType:String(i.mimeType)}));break}}}return a}function No(t,e){const{mimeType:a,data:s}=t;if(a.startsWith("text/"))try{const r=atob(s);return[{type:"text",text:`${e}
23
- ${r}`}]}catch(r){console.error("Failed to decode text file:",r)}return[{type:"file",url:`data:${a};base64,${s}`,filename:e,mediaType:a}]}function Co(t){if(!t)return[];const e=[];let a="";const s=r=>{if(r){if(r.type==="text"&&"text"in r&&typeof r.text=="string")a+=r.text;else if(r.type==="mention"&&r.attrs){const o=r.attrs.char??"/",i=`${o}${r.attrs.name}`;if(a+=i,o==="@"){const n=r.attrs.metadata||[];e.push(...wo(n,i))}else{const n=r.attrs.metadata||r.attrs.prompts||[];e.push(...So(n,i))}}else if(r.type==="file"&&r.attrs){const o=r.attrs,i=`[file:://${encodeURIComponent(o.name)}]`;a+=i,e.push(...No(o,i))}if("content"in r&&Array.isArray(r.content))for(const o of r.content)s(o)}};return s(t),a.trim()&&e.unshift({type:"text",text:a.trim()}),e}async function To(t,e,a){if(!t)throw new Error("MCP client is not available");const s=await t.callTool({name:"COLLECTION_THREADS_UPDATE",arguments:{id:e,data:a}});return(s.structuredContent??s).item}const xa=S.createContext(null);function Ko({children:t}){const{locator:e,org:a}=Ce(),{threads:s,hasNextPage:r,isFetchingNextPage:o,fetchNextPage:i,refetch:n}=eo(),[c,l]=Me(Ve.assistantChatActiveThread(e),s[0]?.id??crypto.randomUUID()),p=Pe({connectionId:et,orgId:a.id}),{data:m}=La.useSession(),h=m?.user??null,[x,y]=S.useReducer(Io,ya),g=Ja(),[b,v]=Me(`${e}:selected-virtual-mcp-id`,null),_=rt(),[u,I]=Eo(e,_),[A,N]=Me(Ve.chatSelectedMode(e),"code_execution"),C=so(c),O=Kr(b),Z=ro(),z=b?g.find(P=>P.id===b)??null:null,G=Wa(a.id).id,K=_o(a.slug),L=Qr({id:c,messages:C,transport:K,onFinish:async({finishReason:P,isAbort:ae,isDisconnect:ce,isError:ye})=>{y({type:"SET_FINISH_REASON",payload:P??null}),!(P!=="stop"||ae||ce||ye)&&await n()},onToolCall:Z,onError:P=>{console.error("[chat] Error",P)}}),ee=L.status==="submitted"||L.status==="streaming",te=L.messages.length===0,me=P=>y({type:"SET_TIPTAP_DOC",payload:P}),$=()=>y({type:"CLEAR_TIPTAP_DOC"}),W=()=>y({type:"RESET"}),Le=async P=>{try{if(await To(p,P,{hidden:!0})){if(P===c){const ye=s.find(Ze=>Ze.id!==P);l(ye?.id??crypto.randomUUID())}await n()}}catch(ae){const ce=ae;Be.error(`Failed to update thread: ${ce.message}`),console.error("[chat] Failed to update thread:",ae)}},Ea=P=>{v(P)},Ia=P=>{I({id:P.id,connectionId:P.connectionId})},wa=async P=>{if(!u){Be.error("No model configured");return}const ae=Co(P);if(ae.length===0)return;W();const ce={tiptapDoc:P,created_at:new Date().toISOString(),thread_id:c,agent:{id:z?.id??G,mode:A},user:{avatar:h?.image??void 0,name:h?.name??"you"}},ye={...ce,system:O,model:{id:u.id,connectionId:u.connectionId,provider:u.provider??void 0,limits:u.limits??void 0,capabilities:{vision:u.capabilities?.includes("vision")??void 0,text:u.capabilities?.includes("text")??void 0,tools:u.capabilities?.includes("tools")??void 0},fastId:u.fastId}},Ze={id:crypto.randomUUID(),role:"user",parts:ae,metadata:ce};await L.sendMessage(Ze,{metadata:ye})},Sa=()=>L.stop(),Na=()=>y({type:"CLEAR_FINISH_REASON"}),Ca={tiptapDoc:x.tiptapDoc,setTiptapDoc:me,clearTiptapDoc:$,resetInteraction:W,activeThreadId:c,threads:s,setActiveThreadId:l,hideThread:Le,hasNextPage:r,isFetchingNextPage:o,fetchNextPage:i,virtualMcps:g,selectedVirtualMcp:z,setVirtualMcpId:Ea,modelsConnections:_,selectedModel:u,setSelectedModel:Ia,selectedMode:A,setSelectedMode:N,messages:L.messages,chatStatus:L.status,isStreaming:ee,isChatEmpty:te,sendMessage:wa,stopStreaming:Sa,setMessages:L.setMessages,chatError:L.error,clearChatError:L.clearError,finishReason:x.finishReason,clearFinishReason:Na};return d.jsx(xa.Provider,{value:Ca,children:t})}function en(){const t=S.useContext(xa);if(!t)throw new Error("useChat must be used within a ChatProvider");return t}function Ao(t){return(t.costs?.input??0)+(t.costs?.output??0)>0}function Mo(t,e){const a=e.costs?.input??0,s=e.costs?.output??0,r=(t?.costs?.input??0)+(t?.costs?.output??0);return!t||r===0||a+s<r?e:t}var $e="Collapsible",[Ro,tn]=za($e),[jo,nt]=Ro($e),ba=S.forwardRef((t,e)=>{const{__scopeCollapsible:a,open:s,defaultOpen:r,disabled:o,onOpenChange:i,...n}=t,[c,l]=Za({prop:s,defaultProp:r??!1,onChange:i,caller:$e});return d.jsx(jo,{scope:a,disabled:o,contentId:Fa(),open:c,onOpenToggle:S.useCallback(()=>l(p=>!p),[l]),children:d.jsx(Ke.div,{"data-state":ut(c),"data-disabled":o?"":void 0,...n,ref:e})})});ba.displayName=$e;var _a="CollapsibleTrigger",it=S.forwardRef((t,e)=>{const{__scopeCollapsible:a,...s}=t,r=nt(_a,a);return d.jsx(Ke.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":ut(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...s,ref:e,onClick:Ua(t.onClick,r.onOpenToggle)})});it.displayName=_a;var lt="CollapsibleContent",ct=S.forwardRef((t,e)=>{const{forceMount:a,...s}=t,r=nt(lt,t.__scopeCollapsible);return d.jsx(Ba,{present:a||r.open,children:({present:o})=>d.jsx(ko,{...s,ref:e,present:o})})});ct.displayName=lt;var ko=S.forwardRef((t,e)=>{const{__scopeCollapsible:a,present:s,children:r,...o}=t,i=nt(lt,a),[n,c]=S.useState(s),l=S.useRef(null),p=Va(e,l),m=S.useRef(0),h=m.current,x=S.useRef(0),y=x.current,g=i.open||n,b=S.useRef(g),v=S.useRef(void 0);return S.useEffect(()=>{const _=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(_)},[]),qa(()=>{const _=l.current;if(_){v.current=v.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";const u=_.getBoundingClientRect();m.current=u.height,x.current=u.width,b.current||(_.style.transitionDuration=v.current.transitionDuration,_.style.animationName=v.current.animationName),c(s)}},[i.open,s]),d.jsx(Ke.div,{"data-state":ut(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:p,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...t.style},children:g&&r})});function ut(t){return t?"open":"closed"}var Oo=ba,an=it,sn=ct;function rn(t){const e=D.c(4);let a;e[0]!==t?({...a}=t,e[0]=t,e[1]=a):a=e[1];let s;return e[2]!==a?(s=d.jsx(Oo,{"data-slot":"collapsible",...a}),e[2]=a,e[3]=s):s=e[3],s}function on(t){const e=D.c(4);let a;e[0]!==t?({...a}=t,e[0]=t,e[1]=a):a=e[1];let s;return e[2]!==a?(s=d.jsx(it,{"data-slot":"collapsible-trigger",...a}),e[2]=a,e[3]=s):s=e[3],s}function nn(t){const e=D.c(4);let a;e[0]!==t?({...a}=t,e[0]=t,e[1]=a):a=e[1];let s;return e[2]!==a?(s=d.jsx(ct,{"data-slot":"collapsible-content",...a}),e[2]=a,e[3]=s):s=e[3],s}export{rn as C,Xo as M,Oo as R,B as S,an as T,ds as a,on as b,Zt as c,sn as d,tn as e,nn as f,Ko as g,us as i,Qo as m,zt as t,en as u};
@@ -1 +0,0 @@
1
- import{r as Y,c as U,j as n,v as Re,l as ht,u as pt,bA as tt,ac as Tt,p as Mt,bs as Ye,o as xt,ba as Dt,bi as It,s as q,ad as nt,ae as At,a as Vt,f as $t,F as Ot,h as Ft,k as Wt,i as Et,t as _e,K as st}from"./index-S9nBXez3.js";import{I as He,n as Lt,E as ve}from"./empty-state-DCefUqf-.js";import{E as gt}from"./error-boundary-CZlFheRY.js";import{E as Rt,r as zt,e as bt}from"./env-vars-editor-CyRZUIFU.js";import{P as Ke,S as Xt}from"./index-EJkHYsSC.js";import{b as Ut,a as Bt}from"./use-binding-OJZZKHfM.js";import{u as qt,S as Yt}from"./index-Cm3M40mu.js";import{c as Qe,d as jt,j as Ht}from"./use-connection-DsOrNBOn.js";import{u as Kt}from"./constants-CiJIPOcv.js";import{b as Qt,d as Jt}from"./use-mcp-prompts-m9itAfo1.js";import{a as Gt}from"./mcp-oauth-BeGVYXYi.js";import{b as ot,e as Zt,c as en,d as tn,B as nn,a as sn}from"./breadcrumb-k6_ciPji.js";import{B as Be}from"./button-C2Npiaxw.js";import{C as on}from"./collection-tabs-D8pHKDB9.js";import{i as Le}from"./Loading01-DuNH8QVR.js";import{V as Je,a as rn}from"./layout-DhWpZyaF.js";import{C as an}from"./collection-tab-CadD9eyl.js";import{B as qe}from"./badge-DsLVLnaN.js";import{D as cn,a as ln,b as dn,c as rt}from"./dropdown-menu-BXLews1x.js";import{F as J,a as un,b as G,d as K,f as Z,c as ne,e as mn}from"./form-CJsO1IWr.js";import{I as ee}from"./input-WEkqgPCx.js";import{S as at,a as it,b as ct,c as lt,d as Q}from"./select-DP5Dfkvv.js";import{i as yt}from"./CheckCircle-COsIOW0_.js";import{t as fn}from"./ChevronDown-CmDSkkyU.js";import{s as Fe}from"./Globe02-BQTpYCGK.js";import{i as hn}from"./Terminal-Bx4QINJq.js";import{s as pn}from"./Trash01-DGR7JKVH.js";import{t as Ge}from"./Users03-C-DkXcQ6.js";import{s as xn}from"./XClose-BOKH0Ji3.js";import{U as gn}from"./use-list-state--e44Cg6A.js";import{b as bn,a as jn}from"./use-virtual-mcp-Bib66D0T.js";import{i as yn}from"./ChevronRight-Cme_aOxM.js";import{s as vn}from"./Plus-ZDIS0vbh.js";import{t as Ne,c as vt,d as Nn,m as dt,a as We}from"./differenceInSeconds-NQ4PDo0z.js";import{a as Nt,C as wt}from"./collection-table-wrapper-BlVqD0Fp.js";import{C as St}from"./collection-search-BT1Haqdl.js";import{C as _t}from"./card-CuSLw2Wn.js";import{R as wn,T as Sn}from"./tools-list-DTW_RJ6B.js";import"./Pin01-CU7bB1L8.js";import"./use-organization-settings-DT-GwMSs.js";import"./useMutation-D0FAjxJB.js";import"./binder-AghfMQli.js";import"./File06-BmoKv1ZA.js";import"./index-ymK78sXU.js";import"./constants-BLEeM90x.js";import"./registry-utils-RKHarYmu.js";import"./extract-connection-data-DQkYWC-q.js";import"./github-icon-Dp3wHhYE.js";import"./generate-id-Dyweu44Y.js";import"./index-DR06FVTS.js";import"./circle-alert-Bwtfy9KA.js";import"./index-CuLYtmwa.js";import"./X-Cw8dXC6B.js";import"./collapsible-kdbIagB_.js";import"./Code01-DlwIBx5j.js";import"./infiniteQueryObserver-Bk6kPCGD.js";import"./localstorage-keys-1daarnfj.js";import"./useQuery-9ftL5KuZ.js";import"./popover-DyvWBt1E.js";import"./Grid01-CH_80p-4.js";import"./Image01-qkpxD1yj.js";import"./SearchMd-6GhPnBK1.js";import"./spinner-CAgETmH3.js";import"./dialog-ByiIrjjH.js";import"./AlertCircle-Sq0aBvsC.js";import"./ArrowUp-CvxgIRrE.js";import"./Edit01-C8mqwImV.js";import"./Check-DNCI8C1c.js";import"./Copy01-CX9SC5FE.js";import"./monaco-editor-D62uyIRE.js";import"./use-create-virtual-mcp-BJbJkcpt.js";import"./index-9jleOnNn.js";import"./DotsVertical-CC8faZfe.js";import"./empty-state-BhLPGCFf.js";import"./Inbox01-mn1giWLi.js";import"./alert-dialog-Bt2DNs-q.js";import"./use-mobile-BQcJDrUC.js";import"./List-BWbZDQVx.js";import"./view-mode-toggle-e1wVUIQC.js";import"./table-20ccyhvp.js";const Ct=({size:t=24,color:e="currentColor",...s})=>Y.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},Y.createElement("path",{d:"M2 10s2.005-2.732 3.634-4.362A9 9 0 1 1 12 21a9.004 9.004 0 0 1-8.648-6.5M2 10V4m0 6h6"}));Ct.displayName="RefreshCcw01";let _n={};function Cn(){return _n}function ut(t){const e=Ne(t),s=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return s.setUTCFullYear(e.getFullYear()),+t-+s}function Ze(t,...e){const s=vt.bind(null,t||e.find(o=>typeof o=="object"));return e.map(s)}function Ee(t,e){const s=+Ne(t)-+Ne(e);return s<0?-1:s>0?1:s}function Pn(t){return vt(t,Date.now())}function kn(t,e,s){const[o,r]=Ze(s?.in,t,e),c=o.getFullYear()-r.getFullYear(),i=o.getMonth()-r.getMonth();return c*12+i}function Tn(t,e){const s=Ne(t);return s.setHours(23,59,59,999),s}function Mn(t,e){const s=Ne(t),o=s.getMonth();return s.setFullYear(s.getFullYear(),o+1,0),s.setHours(23,59,59,999),s}function Dn(t,e){const s=Ne(t);return+Tn(s)==+Mn(s)}function In(t,e,s){const[o,r,c]=Ze(s?.in,t,t,e),i=Ee(r,c),l=Math.abs(kn(r,c));if(l<1)return 0;r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-i*l);let m=Ee(r,c)===-i;Dn(o)&&l===1&&Ee(o,c)===1&&(m=!1);const d=i*(l-+m);return d===0?0:d}const An={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Vn=(t,e,s)=>{let o;const r=An[t];return typeof r=="string"?o=r:e===1?o=r.one:o=r.other.replace("{{count}}",e.toString()),s?.addSuffix?s.comparison&&s.comparison>0?"in "+o:o+" ago":o};function Ue(t){return(e={})=>{const s=e.width?String(e.width):t.defaultWidth;return t.formats[s]||t.formats[t.defaultWidth]}}const $n={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},On={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Fn={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Wn={date:Ue({formats:$n,defaultWidth:"full"}),time:Ue({formats:On,defaultWidth:"full"}),dateTime:Ue({formats:Fn,defaultWidth:"full"})},En={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ln=(t,e,s,o)=>En[t];function Ce(t){return(e,s)=>{const o=s?.context?String(s.context):"standalone";let r;if(o==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,l=s?.width?String(s.width):i;r=t.formattingValues[l]||t.formattingValues[i]}else{const i=t.defaultWidth,l=s?.width?String(s.width):t.defaultWidth;r=t.values[l]||t.values[i]}const c=t.argumentCallback?t.argumentCallback(e):e;return r[c]}}const Rn={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},zn={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Xn={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Un={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Bn={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},qn={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Yn=(t,e)=>{const s=Number(t),o=s%100;if(o>20||o<10)switch(o%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},Hn={ordinalNumber:Yn,era:Ce({values:Rn,defaultWidth:"wide"}),quarter:Ce({values:zn,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Ce({values:Xn,defaultWidth:"wide"}),day:Ce({values:Un,defaultWidth:"wide"}),dayPeriod:Ce({values:Bn,defaultWidth:"wide",formattingValues:qn,defaultFormattingWidth:"wide"})};function Pe(t){return(e,s={})=>{const o=s.width,r=o&&t.matchPatterns[o]||t.matchPatterns[t.defaultMatchWidth],c=e.match(r);if(!c)return null;const i=c[0],l=o&&t.parsePatterns[o]||t.parsePatterns[t.defaultParseWidth],m=Array.isArray(l)?Qn(l,p=>p.test(i)):Kn(l,p=>p.test(i));let d;d=t.valueCallback?t.valueCallback(m):m,d=s.valueCallback?s.valueCallback(d):d;const x=e.slice(i.length);return{value:d,rest:x}}}function Kn(t,e){for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e(t[s]))return s}function Qn(t,e){for(let s=0;s<t.length;s++)if(e(t[s]))return s}function Jn(t){return(e,s={})=>{const o=e.match(t.matchPattern);if(!o)return null;const r=o[0],c=e.match(t.parsePattern);if(!c)return null;let i=t.valueCallback?t.valueCallback(c[0]):c[0];i=s.valueCallback?s.valueCallback(i):i;const l=e.slice(r.length);return{value:i,rest:l}}}const Gn=/^(\d+)(th|st|nd|rd)?/i,Zn=/\d+/i,es={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ts={any:[/^b/i,/^(a|c)/i]},ns={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ss={any:[/1/i,/2/i,/3/i,/4/i]},os={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},rs={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},as={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},is={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},cs={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ls={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ds={ordinalNumber:Jn({matchPattern:Gn,parsePattern:Zn,valueCallback:t=>parseInt(t,10)}),era:Pe({matchPatterns:es,defaultMatchWidth:"wide",parsePatterns:ts,defaultParseWidth:"any"}),quarter:Pe({matchPatterns:ns,defaultMatchWidth:"wide",parsePatterns:ss,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Pe({matchPatterns:os,defaultMatchWidth:"wide",parsePatterns:rs,defaultParseWidth:"any"}),day:Pe({matchPatterns:as,defaultMatchWidth:"wide",parsePatterns:is,defaultParseWidth:"any"}),dayPeriod:Pe({matchPatterns:cs,defaultMatchWidth:"any",parsePatterns:ls,defaultParseWidth:"any"})},us={code:"en-US",formatDistance:Vn,formatLong:Wn,formatRelative:Ln,localize:Hn,match:ds,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ms(t,e,s){const o=Cn(),r=s?.locale??o.locale??us,c=2520,i=Ee(t,e);if(isNaN(i))throw new RangeError("Invalid time value");const l=Object.assign({},s,{addSuffix:s?.addSuffix,comparison:i}),[m,d]=Ze(s?.in,...i>0?[e,t]:[t,e]),x=Nn(d,m),p=(ut(d)-ut(m))/1e3,a=Math.round((x-p)/60);let g;if(a<2)return s?.includeSeconds?x<5?r.formatDistance("lessThanXSeconds",5,l):x<10?r.formatDistance("lessThanXSeconds",10,l):x<20?r.formatDistance("lessThanXSeconds",20,l):x<40?r.formatDistance("halfAMinute",0,l):x<60?r.formatDistance("lessThanXMinutes",1,l):r.formatDistance("xMinutes",1,l):a===0?r.formatDistance("lessThanXMinutes",1,l):r.formatDistance("xMinutes",a,l);if(a<45)return r.formatDistance("xMinutes",a,l);if(a<90)return r.formatDistance("aboutXHours",1,l);if(a<dt){const u=Math.round(a/60);return r.formatDistance("aboutXHours",u,l)}else{if(a<c)return r.formatDistance("xDays",1,l);if(a<We){const u=Math.round(a/dt);return r.formatDistance("xDays",u,l)}else if(a<We*2)return g=Math.round(a/We),r.formatDistance("aboutXMonths",g,l)}if(g=In(d,m),g<12){const u=Math.round(a/We);return r.formatDistance("xMonths",u,l)}else{const u=g%12,h=Math.trunc(g/12);return u<3?r.formatDistance("aboutXYears",h,l):u<9?r.formatDistance("overXYears",h,l):r.formatDistance("almostXYears",h+1,l)}}function fs(t,e){return ms(t,Pn(t),e)}function hs(t){const e=U.c(13),{virtualMcp:s,org:o}=t;let r;e[0]!==o||e[1]!==s.id?(r={org:o,agentId:s.id},e[0]=o,e[1]=s.id,e[2]=r):r=e[2];let c;e[3]!==s.icon||e[4]!==s.title?(c=s.icon?n.jsx("img",{src:s.icon,alt:s.title,className:"w-5 h-5 rounded-md object-cover shrink-0"}):n.jsx("div",{className:"w-8 h-8 rounded-md bg-primary/10 flex items-center justify-center shrink-0",children:n.jsx(Ge,{size:16,className:"text-primary"})}),e[3]=s.icon,e[4]=s.title,e[5]=c):c=e[5];let i;e[6]!==s.title?(i=n.jsx("span",{className:"flex-1 text-sm font-medium text-foreground truncate",children:s.title}),e[6]=s.title,e[7]=i):i=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(yn,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors shrink-0"}),e[8]=l):l=e[8];let m;return e[9]!==r||e[10]!==c||e[11]!==i?(m=n.jsxs(ht,{to:"/$org/agents/$agentId",params:r,className:"flex items-center gap-3 p-2 pr-1 rounded-lg hover:bg-muted/50 transition-colors group",children:[c,i,l]}),e[9]=r,e[10]=c,e[11]=i,e[12]=m):m=e[12],m}function mt(t){const e=U.c(20),{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i,hasExistingVirtualMcps:l}=t,m=Re(),d=jn();let x;e[0]!==d.create||e[1]!==r||e[2]!==c||e[3]!==s||e[4]!==o||e[5]!==m||e[6]!==i?(x=async()=>{const u=await d.create.mutateAsync({title:`${o} Agent`,description:r??null,icon:c??null,status:"active",connections:[{connection_id:s,selected_tools:null,selected_resources:null,selected_prompts:null}]});m({to:"/$org/agents/$agentId",params:{org:i,agentId:u.id}})},e[0]=d.create,e[1]=r,e[2]=c,e[3]=s,e[4]=o,e[5]=m,e[6]=i,e[7]=x):x=e[7];const p=x;if(l){let u;e[8]!==d.create.isPending?(u=d.create.isPending?n.jsx(Le,{size:16,className:"animate-spin"}):n.jsx(vn,{size:16}),e[8]=d.create.isPending,e[9]=u):u=e[9];let h;return e[10]!==d.create.isPending||e[11]!==p||e[12]!==u?(h=n.jsx(Be,{variant:"ghost",className:"size-6 p-0",onClick:p,disabled:d.create.isPending,children:u}),e[10]=d.create.isPending,e[11]=p,e[12]=u,e[13]=h):h=e[13],h}let a;e[14]!==d.create.isPending?(a=d.create.isPending?n.jsx(Le,{className:"animate-spin text-muted-foreground"}):n.jsx(Ge,{className:"size-3 text-muted-foreground"}),e[14]=d.create.isPending,e[15]=a):a=e[15];let g;return e[16]!==d.create.isPending||e[17]!==p||e[18]!==a?(g=n.jsxs(Be,{variant:"outline",size:"sm",onClick:p,disabled:d.create.isPending,children:[a,"Create an agent"]}),e[16]=d.create.isPending,e[17]=p,e[18]=a,e[19]=g):g=e[19],g}function ps(t){const e=U.c(26),{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i}=t;let l;e[0]!==s?(l={filters:[{column:"connection_id",value:s}]},e[0]=s,e[1]=l):l=e[1];const m=bn(l);if(!(m.length>0)){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("h4",{className:"text-xs text-muted-foreground font-medium",children:"Use in your IDE"}),e[2]=h):h=e[2];let b;return e[3]!==r||e[4]!==c||e[5]!==s||e[6]!==o||e[7]!==i?(b=n.jsxs("div",{className:"p-5 flex items-center justify-between gap-3",children:[h,n.jsx(mt,{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i,hasExistingVirtualMcps:!1})]}),e[3]=r,e[4]=c,e[5]=s,e[6]=o,e[7]=i,e[8]=b):b=e[8],b}let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h4",{className:"text-xs text-muted-foreground font-medium",children:"Agents"}),e[9]=x):x=e[9];let p;e[10]!==r||e[11]!==c||e[12]!==s||e[13]!==o||e[14]!==i?(p=n.jsx("div",{className:"flex flex-col gap-1",children:n.jsxs("div",{className:"flex items-center justify-between",children:[x,n.jsx(mt,{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i,hasExistingVirtualMcps:!0})]})}),e[10]=r,e[11]=c,e[12]=s,e[13]=o,e[14]=i,e[15]=p):p=e[15];let a;if(e[16]!==i||e[17]!==m){let h;e[19]!==i?(h=b=>n.jsx(hs,{virtualMcp:b,org:i},b.id),e[19]=i,e[20]=h):h=e[20],a=m.map(h),e[16]=i,e[17]=m,e[18]=a}else a=e[18];let g;e[21]!==a?(g=n.jsx("div",{className:"flex flex-col gap-2",children:a}),e[21]=a,e[22]=g):g=e[22];let u;return e[23]!==p||e[24]!==g?(u=n.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[p,g]}),e[23]=p,e[24]=g,e[25]=u):u=e[25],u}function xs({form:t,connection:e,hasOAuthToken:s,onReauthenticate:o,onRemoveOAuth:r}){const c=tt({control:t.control,name:"ui_type"}),i=tt({control:t.control,name:"connection_url"}),{stdioEnabled:l}=Tt(),m=(()=>{if(typeof i!="string"||!i)return!1;try{const a=new URL(i);return a.hostname==="api.githubcopilot.com"&&a.pathname.replace(/\/+$/,"")==="/mcp"}catch{return!1}})(),d=l||e.connection_type==="STDIO",x=e.connection_type==="VIRTUAL",p=x?Mt(e.connection_url):null;return x?n.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Type"}),n.jsxs("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:[n.jsx(Ge,{className:"w-4 h-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm",children:"Virtual MCP"})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"This connection references a Virtual MCP. Tools and resources are aggregated dynamically from the Virtual MCP's underlying connections."})]}),p&&n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Virtual MCP ID"}),n.jsx("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:n.jsx("code",{className:"text-sm text-muted-foreground",children:p})})]})]}):n.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[n.jsx(J,{control:t.control,name:"ui_type",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Connection"}),c!=="NPX"&&c!=="STDIO"?n.jsxs("div",{className:"flex items-stretch rounded-lg border border-border overflow-hidden",children:[n.jsxs(at,{value:a.value,onValueChange:a.onChange,children:[n.jsx(K,{children:n.jsxs(it,{className:"h-10 w-auto min-w-[90px] border-0 rounded-none bg-muted/50 focus:ring-0 focus:ring-offset-0",children:[n.jsx(Fe,{className:"w-4 h-4 text-muted-foreground shrink-0"}),n.jsx(ct,{})]})}),n.jsxs(lt,{children:[n.jsx(Q,{value:"HTTP",children:"HTTP"}),n.jsx(Q,{value:"SSE",children:"SSE"}),n.jsx(Q,{value:"Websocket",children:"Websocket"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(Q,{value:"NPX",children:"NPX Package"}),n.jsx(Q,{value:"STDIO",children:"Custom Command"})]})]})]}),n.jsx("div",{className:"w-px bg-border"}),n.jsx(J,{control:t.control,name:"connection_url",render:({field:g})=>n.jsx(G,{className:"flex-1 min-w-0",children:n.jsx(K,{children:n.jsx(ee,{placeholder:"https://example.com/mcp",...g,value:g.value??"",className:"h-10 border-0 rounded-none focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent"})})})})]}):n.jsxs(at,{value:a.value,onValueChange:a.onChange,children:[n.jsx(K,{children:n.jsx(it,{className:"h-10",children:n.jsx(ct,{})})}),n.jsxs(lt,{children:[n.jsx(Q,{value:"HTTP",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"w-4 h-4"}),"HTTP"]})}),n.jsx(Q,{value:"SSE",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"w-4 h-4"}),"SSE"]})}),n.jsx(Q,{value:"Websocket",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"w-4 h-4"}),"Websocket"]})}),d&&n.jsxs(n.Fragment,{children:[n.jsx(Q,{value:"NPX",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Lt,{className:"w-4 h-4"}),"NPX Package"]})}),n.jsx(Q,{value:"STDIO",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(hn,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),n.jsx(Z,{})]})}),c==="NPX"&&n.jsx(J,{control:t.control,name:"npx_package",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"NPM Package"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"@perplexity-ai/mcp-server",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx(Z,{})]})}),c==="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx(J,{control:t.control,name:"stdio_command",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Command"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"node, bun, python...",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx(Z,{})]})}),n.jsx(J,{control:t.control,name:"stdio_args",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Arguments"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"arg1 arg2 --flag value",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Space-separated arguments"}),n.jsx(Z,{})]})})]}),n.jsx(J,{control:t.control,name:"stdio_cwd",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Working Directory"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"/path/to/project (optional)",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx(Z,{})]})})]}),(c==="NPX"||c==="STDIO")&&n.jsx(J,{control:t.control,name:"env_vars",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Environment Variables"}),n.jsx(K,{children:n.jsx(Rt,{value:a.value??[],onChange:a.onChange})}),n.jsx(Z,{})]})}),c!=="NPX"&&c!=="STDIO"&&n.jsx(J,{control:t.control,name:"connection_token",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:m?"GitHub Personal Access Token":"Token"}),s?n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(cn,{children:[n.jsx(ln,{asChild:!0,children:n.jsx("button",{type:"button",className:"inline-flex items-center gap-1.5 cursor-pointer",children:n.jsxs(qe,{variant:"success",className:"gap-1.5",children:[n.jsx(yt,{size:12}),"Authenticated via OAuth",n.jsx(fn,{size:12})]})})}),n.jsxs(dn,{align:"start",children:[n.jsxs(rt,{onClick:o,children:[n.jsx(Ct,{size:16}),"Re-authenticate"]}),n.jsxs(rt,{variant:"destructive",onClick:r,children:[n.jsx(pn,{size:16}),"Remove OAuth"]})]})]})}):e.connection_token&&a.value===null?n.jsxs("div",{className:"relative group",children:[n.jsx("div",{className:"h-10 px-3 flex items-center rounded-lg border border-border bg-muted/50 text-muted-foreground font-mono text-sm",children:"••••••••••••••••"}),n.jsx("button",{type:"button",onClick:()=>a.onChange(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Clear and replace token",children:n.jsx(xn,{size:14,className:"text-muted-foreground"})})]}):n.jsxs(n.Fragment,{children:[n.jsx(K,{children:n.jsx(ee,{type:"password",placeholder:m?"Paste your GitHub PAT":"Enter access token...",...a,value:a.value||"",className:"h-10 rounded-lg"})}),m&&n.jsxs(mn,{children:["Create a PAT at"," ",n.jsx("a",{href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"github.com/settings/personal-access-tokens"})]})]}),n.jsx(Z,{})]})})]})}function gs(t){const e=U.c(43),{form:s,connection:o,isMCPAuthenticated:r,hasOAuthToken:c,onReauthenticate:i,onRemoveOAuth:l}=t,{org:m}=pt();let d;e[0]!==o.icon||e[1]!==o.title?(d=n.jsx(He,{icon:o.icon,name:o.title,size:"lg",className:"shadow-sm"}),e[0]=o.icon,e[1]=o.title,e[2]=d):d=e[2];let x;e[3]!==s.control?(x=n.jsxs("div",{className:"flex flex-col",children:[n.jsx(J,{control:s.control,name:"title",render:js}),n.jsx(J,{control:s.control,name:"description",render:bs})]}),e[3]=s.control,e[4]=x):x=e[4];let p;e[5]!==d||e[6]!==x?(p=n.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[d,x]}),e[5]=d,e[6]=x,e[7]=p):p=e[7];let a;e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==i||e[12]!==l?(a=n.jsx(xs,{form:s,connection:o,hasOAuthToken:c,onReauthenticate:i,onRemoveOAuth:l}),e[8]=o,e[9]=s,e[10]=c,e[11]=i,e[12]=l,e[13]=a):a=e[13];let g;e[14]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Status"}),e[14]=g):g=e[14];let u;e[15]!==r?(u=n.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[g,r?n.jsxs(qe,{variant:"success",className:"gap-1.5 bg-success-foreground text-success",children:[n.jsx(yt,{size:12}),"Connected"]}):n.jsx(qe,{variant:"outline",className:"text-muted-foreground",children:"Not connected"})]}),e[15]=r,e[16]=u):u=e[16];let h;e[17]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Created by"}),e[17]=h):h=e[17];let b;e[18]!==o.created_by?(b=n.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[h,n.jsx(gn,{id:o.created_by,size:"2xs"})]}),e[18]=o.created_by,e[19]=b):b=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Updated"}),e[20]=C):C=e[20];let v;e[21]!==o.updated_at?(v=o.updated_at?fs(new Date(o.updated_at),{addSuffix:!0}):"Unknown",e[21]=o.updated_at,e[22]=v):v=e[22];let j;e[23]!==v?(j=n.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[C,n.jsx("span",{className:"text-sm text-foreground",children:v})]}),e[23]=v,e[24]=j):j=e[24];let w;e[25]!==j||e[26]!==u||e[27]!==b?(w=n.jsxs("div",{className:"flex flex-col gap-2 p-5 border-b border-border",children:[u,b,j]}),e[25]=j,e[26]=u,e[27]=b,e[28]=w):w=e[28];let f;e[29]!==o.description||e[30]!==o.icon||e[31]!==o.id||e[32]!==o.title||e[33]!==m.slug?(f=n.jsx(ps,{connectionId:o.id,connectionTitle:o.title,connectionDescription:o.description,connectionIcon:o.icon,org:m.slug}),e[29]=o.description,e[30]=o.icon,e[31]=o.id,e[32]=o.title,e[33]=m.slug,e[34]=f):f=e[34];let P;e[35]!==w||e[36]!==f||e[37]!==p||e[38]!==a?(P=n.jsxs("div",{className:"flex flex-col h-full overflow-auto",children:[p,a,w,f]}),e[35]=w,e[36]=f,e[37]=p,e[38]=a,e[39]=P):P=e[39];let $;return e[40]!==s||e[41]!==P?($=n.jsx(un,{...s,children:P}),e[40]=s,e[41]=P,e[42]=$):$=e[42],$}function bs(t){const{field:e}=t;return n.jsxs(G,{className:"w-full space-y-0",children:[n.jsx(K,{children:n.jsx(ee,{...e,value:e.value||"",className:"h-auto py-0.5 text-base text-muted-foreground leading-6 px-2 -mx-2 border-transparent hover:bg-input/25 focus:border-input bg-transparent transition-all",placeholder:"Add a description..."})}),n.jsx(Z,{})]})}function js(t){const{field:e}=t;return n.jsxs(G,{className:"flex-1 space-y-0",children:[n.jsx(K,{children:n.jsx(ee,{...e,className:"h-auto py-0.5 text-lg! font-medium leading-7 px-2 -mx-2 border-transparent hover:bg-input/25 focus:border-input bg-transparent transition-all",placeholder:"Connection Name"})}),n.jsx(Z,{})]})}function ys(t){const e=U.c(42),{prompts:s,connectionId:o,org:r,connectionTitle:c,connectionIcon:i,onPromptClick:l,showToolbar:m,emptyMessage:d}=t,x=m===void 0?!0:m,p=d===void 0?"This connection doesn't have any prompts yet.":d,a=Re(),u=Ye().location.href,[h,b]=Y.useState(""),[C,v]=Y.useState("table"),[j,w]=Y.useState("name"),[f,P]=Y.useState("asc");let $;e[0]!==f||e[1]!==j?($=S=>{j===S?(P(_s),f==="desc"&&w(void 0)):(w(S),P("asc"))},e[0]=f,e[1]=j,e[2]=$):$=e[2];const T=$;let V;e[3]!==o||e[4]!==a||e[5]!==l||e[6]!==r?(V=S=>{l?l(S):o&&r&&a({to:"/$org/mcps/$connectionId/$collectionName/$itemId",params:{org:r,connectionId:o,collectionName:"prompts",itemId:encodeURIComponent(S.name)}})},e[3]=o,e[4]=a,e[5]=l,e[6]=r,e[7]=V):V=e[7];const k=V;let O;if(e[8]!==s||e[9]!==h||e[10]!==f||e[11]!==j){const S=!s||s.length===0?[]:h.trim()?(()=>{const H=h.toLowerCase();return s.filter(B=>B.name.toLowerCase().includes(H)||B.description&&B.description.toLowerCase().includes(H))})():s;O=!j||!f?S:[...S].sort((H,B)=>{const se=H[j]||"",we=B[j]||"",te=String(se).localeCompare(String(we));return f==="asc"?te:-te}),e[8]=s,e[9]=h,e[10]=f,e[11]=j,e[12]=O}else O=e[12];const M=O;let X;e[13]===Symbol.for("react.memo_cache_sentinel")?(X=[{id:"name",header:"Name",render:Ss,sortable:!0},{id:"description",header:"Description",render:ws,cellClassName:"flex-1",sortable:!0}],e[13]=X):X=e[13];const N=X;let R;e[14]===Symbol.for("react.memo_cache_sentinel")?(R=N.filter(Ns).map(vs),e[14]=R):R=e[14];const E=R;let I;e[15]!==i||e[16]!==c||e[17]!==T||e[18]!==x||e[19]!==f||e[20]!==j||e[21]!==u||e[22]!==C?(I=x&&n.jsxs(Je,{children:[n.jsx(wt,{viewMode:C,onViewModeChange:v,sortKey:j,sortDirection:f,onSort:T,sortOptions:E}),n.jsx(Ke,{title:c?`${c}: Prompts`:"Prompts",url:u,icon:i??"description"})]}),e[15]=i,e[16]=c,e[17]=T,e[18]=x,e[19]=f,e[20]=j,e[21]=u,e[22]=C,e[23]=I):I=e[23];let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=S=>{S.key==="Escape"&&(b(""),S.target.blur())},e[24]=A):A=e[24];let D;e[25]!==h?(D=n.jsx(St,{value:h,onChange:b,placeholder:"Search prompts...",onKeyDown:A}),e[25]=h,e[26]=D):D=e[26];let y;e[27]!==p||e[28]!==k||e[29]!==T||e[30]!==h||e[31]!==f||e[32]!==j||e[33]!==M||e[34]!==C?(y=C==="cards"?n.jsx("div",{className:"flex-1 overflow-auto p-5",children:M.length===0?n.jsx(ve,{image:null,title:h?"No prompts found":"No prompts available",description:h?"Try adjusting your search terms":p}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:M.map(S=>n.jsx(_t,{className:"cursor-pointer transition-colors",onClick:()=>k(S),children:n.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[n.jsx(He,{icon:null,name:S.name,size:"md",className:"shrink-0 shadow-sm"}),n.jsxs("div",{className:"flex flex-col gap-0",children:[n.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:S.name}),n.jsx("p",{className:"text-base text-muted-foreground line-clamp-2",children:S.description||"No description"})]})]})},S.name))})}):n.jsx(Nt,{columns:N,data:M,isLoading:!1,sortKey:j,sortDirection:f,onSort:T,onRowClick:S=>k(S),emptyState:n.jsx(ve,{image:null,title:h?"No prompts found":"No prompts available",description:h?"Try adjusting your search terms":p})}),e[27]=p,e[28]=k,e[29]=T,e[30]=h,e[31]=f,e[32]=j,e[33]=M,e[34]=C,e[35]=y):y=e[35];let F;e[36]!==D||e[37]!==y?(F=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[D,y]}),e[36]=D,e[37]=y,e[38]=F):F=e[38];let z;return e[39]!==F||e[40]!==I?(z=n.jsxs(n.Fragment,{children:[I,F]}),e[39]=F,e[40]=I,e[41]=z):z=e[41],z}function vs(t){return{id:t.id,label:typeof t.header=="string"?t.header:t.id}}function Ns(t){return t.sortable}function ws(t){return n.jsx("span",{className:"text-sm text-foreground",children:t.description||"—"})}function Ss(t){return n.jsx("span",{className:"text-sm font-medium font-mono text-foreground",children:t.name})}function _s(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Cs(t){const e=U.c(6),{prompts:s,connectionId:o,org:r}=t,c=Qe(o),i=c?.title,l=c?.icon;let m;return e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==l?(m=n.jsx(ys,{prompts:s,connectionId:o,org:r,connectionTitle:i,connectionIcon:l}),e[0]=o,e[1]=r,e[2]=s,e[3]=i,e[4]=l,e[5]=m):m=e[5],m}function Ps(t){const e=U.c(2),{repository:s}=t;let o;return e[0]!==s?(o=n.jsx("div",{className:"flex-1 overflow-y-auto bg-background",children:n.jsx(wn,{repository:s})}),e[0]=s,e[1]=o):o=e[1],o}function ks(t){const e=U.c(39),{resources:s,connectionTitle:o,connectionIcon:r,onResourceClick:c,showToolbar:i,emptyMessage:l}=t,m=i===void 0?!0:i,d=l===void 0?"This connection doesn't have any resources yet.":l,p=Ye().location.href,[a,g]=Y.useState(""),[u,h]=Y.useState("table"),[b,C]=Y.useState("name"),[v,j]=Y.useState("asc");let w;e[0]!==v||e[1]!==b?(w=y=>{b===y?(j($s),v==="desc"&&C(void 0)):(C(y),j("asc"))},e[0]=v,e[1]=b,e[2]=w):w=e[2];const f=w;let P;e[3]!==c?(P=y=>{c&&c(y)},e[3]=c,e[4]=P):P=e[4];const $=P;let T;if(e[5]!==s||e[6]!==a||e[7]!==v||e[8]!==b){const y=!s||s.length===0?[]:a.trim()?(()=>{const F=a.toLowerCase();return s.filter(z=>z.uri.toLowerCase().includes(F)||z.name&&z.name.toLowerCase().includes(F)||z.description&&z.description.toLowerCase().includes(F))})():s;T=!b||!v?y:[...y].sort((F,z)=>{const S=F[b]||"",H=z[b]||"",B=String(S).localeCompare(String(H));return v==="asc"?B:-B}),e[5]=s,e[6]=a,e[7]=v,e[8]=b,e[9]=T}else T=e[9];const V=T;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=[{id:"name",header:"Name",render:Vs,sortable:!0},{id:"uri",header:"URI",render:As,sortable:!0},{id:"description",header:"Description",render:Is,cellClassName:"flex-1",sortable:!0},{id:"mimeType",header:"Type",render:Ds,sortable:!0}],e[10]=k):k=e[10];const O=k;let M;e[11]===Symbol.for("react.memo_cache_sentinel")?(M=O.filter(Ms).map(Ts),e[11]=M):M=e[11];const X=M;let N;e[12]!==r||e[13]!==o||e[14]!==f||e[15]!==m||e[16]!==v||e[17]!==b||e[18]!==p||e[19]!==u?(N=m&&n.jsxs(Je,{children:[n.jsx(wt,{viewMode:u,onViewModeChange:h,sortKey:b,sortDirection:v,onSort:f,sortOptions:X}),n.jsx(Ke,{title:o?`${o}: Resources`:"Resources",url:p,icon:r??"folder"})]}),e[12]=r,e[13]=o,e[14]=f,e[15]=m,e[16]=v,e[17]=b,e[18]=p,e[19]=u,e[20]=N):N=e[20];let R;e[21]===Symbol.for("react.memo_cache_sentinel")?(R=y=>{y.key==="Escape"&&(g(""),y.target.blur())},e[21]=R):R=e[21];let E;e[22]!==a?(E=n.jsx(St,{value:a,onChange:g,placeholder:"Search resources...",onKeyDown:R}),e[22]=a,e[23]=E):E=e[23];let I;e[24]!==d||e[25]!==$||e[26]!==f||e[27]!==a||e[28]!==v||e[29]!==b||e[30]!==V||e[31]!==u?(I=u==="cards"?n.jsx("div",{className:"flex-1 overflow-auto p-5",children:V.length===0?n.jsx(ve,{image:null,title:a?"No resources found":"No resources available",description:a?"Try adjusting your search terms":d}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(y=>n.jsx(_t,{className:"cursor-pointer transition-colors",onClick:()=>$(y),children:n.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[n.jsx(He,{icon:null,name:y.name||y.uri,size:"md",className:"shrink-0 shadow-sm"}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:y.name||y.uri}),n.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:y.uri}),y.description&&n.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:y.description})]})]})},y.uri))})}):n.jsx(Nt,{columns:O,data:V,isLoading:!1,sortKey:b,sortDirection:v,onSort:f,onRowClick:y=>$(y),emptyState:n.jsx(ve,{image:null,title:a?"No resources found":"No resources available",description:a?"Try adjusting your search terms":d})}),e[24]=d,e[25]=$,e[26]=f,e[27]=a,e[28]=v,e[29]=b,e[30]=V,e[31]=u,e[32]=I):I=e[32];let A;e[33]!==E||e[34]!==I?(A=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[E,I]}),e[33]=E,e[34]=I,e[35]=A):A=e[35];let D;return e[36]!==A||e[37]!==N?(D=n.jsxs(n.Fragment,{children:[N,A]}),e[36]=A,e[37]=N,e[38]=D):D=e[38],D}function Ts(t){return{id:t.id,label:typeof t.header=="string"?t.header:t.id}}function Ms(t){return t.sortable}function Ds(t){return n.jsx("span",{className:"text-sm text-muted-foreground",children:t.mimeType||"—"})}function Is(t){return n.jsx("span",{className:"text-sm text-foreground",children:t.description||"—"})}function As(t){return n.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:t.uri})}function Vs(t){return n.jsx("span",{className:"text-sm font-medium text-foreground",children:t.name||t.uri})}function $s(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Os(t){const e=U.c(6),{resources:s,connectionId:o,org:r}=t,c=Qe(o),i=c?.title,l=c?.icon;let m;return e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==l?(m=n.jsx(ks,{resources:s,connectionId:o,org:r,connectionTitle:i,connectionIcon:l}),e[0]=o,e[1]=r,e[2]=s,e[3]=i,e[4]=l,e[5]=m):m=e[5],m}const Fs=xt({key:q().min(1,"Key is required"),value:q()}),Ws=xt({title:q().min(1,"Name is required"),description:q().nullable().optional(),ui_type:At(["HTTP","SSE","Websocket","NPX","STDIO"]),connection_url:q().optional(),connection_token:q().nullable().optional(),npx_package:q().optional(),stdio_command:q().optional(),stdio_args:q().optional(),stdio_cwd:q().optional(),env_vars:nt(Fs).optional(),configuration_scopes:nt(q()).nullable().optional(),configuration_state:Dt(q(),It()).nullable().optional()}).refine(t=>t.ui_type==="NPX"?!!t.npx_package?.trim():!0,{message:"NPM package is required",path:["npx_package"]}).refine(t=>t.ui_type==="STDIO"?!!t.stdio_command?.trim():!0,{message:"Command is required",path:["stdio_command"]}).refine(t=>t.ui_type==="HTTP"||t.ui_type==="SSE"||t.ui_type==="Websocket"?!!t.connection_url?.trim():!0,{message:"URL is required",path:["connection_url"]});function Es(t){const e=U.c(5),{tools:s,connectionId:o,org:r,isLoading:c}=t;let i;return e[0]!==o||e[1]!==c||e[2]!==r||e[3]!==s?(i=n.jsx(Sn,{tools:s,connectionId:o,org:r,isLoading:c}),e[0]=o,e[1]=c,e[2]=r,e[3]=s,e[4]=i):i=e[4],i}function Ls(t){return t.command==="npx"}function Rs(t){return t.args?.find(e=>!e.startsWith("-"))??""}function zs(t){return{command:t.command,args:t.args?.join(" ")??"",cwd:t.cwd??""}}function Xs(t,e){const s={command:"npx",args:["-y",t]},o=bt(e);return Object.keys(o).length>0&&(s.envVars=o),s}function Us(t,e,s,o){const r={command:t};e.trim()&&(r.args=e.trim().split(/\s+/)),s?.trim()&&(r.cwd=s.trim());const c=bt(o);return Object.keys(c).length>0&&(r.envVars=c),r}function ft(t,e){const s={title:t.title,description:t.description??"",configuration_state:t.configuration_state??{},configuration_scopes:t.configuration_scopes||[]};if(t.connection_type==="STDIO"&&Et(t.connection_headers)){const o=t.connection_headers,r=zt(o.envVars);if(Ls(o)){const i=Rs(o);return{...s,ui_type:"NPX",connection_url:"",connection_token:null,npx_package:i,stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:r}}const c=zs(o);return{...s,ui_type:"STDIO",connection_url:"",connection_token:null,npx_package:"",stdio_command:c.command,stdio_args:c.args,stdio_cwd:c.cwd,env_vars:r}}return{...s,ui_type:t.connection_type,connection_url:t.connection_url??"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}function Bs(t){let e,s=null,o=null,r=null;return t.ui_type==="NPX"?(e="STDIO",s="",r=Xs(t.npx_package||"",t.env_vars||[])):t.ui_type==="STDIO"?(e="STDIO",s="",r=Us(t.stdio_command||"",t.stdio_args||"",t.stdio_cwd,t.env_vars||[])):(e=t.ui_type,s=t.connection_url||"",o=t.connection_token||null),{title:t.title,description:t.description||null,connection_type:e,connection_url:s,...o&&{connection_token:o},...r&&{connection_headers:r},configuration_state:t.configuration_state??null,configuration_scopes:t.configuration_scopes??null}}function qs(t){const e=U.c(117),{connection:s,connectionId:o,org:r,requestedTabId:c,collections:i,onUpdate:l,isUpdating:m,prompts:d,resources:x,tools:p,isLoadingTools:a}=t;let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={from:"/$org/mcps/$connectionId"},e[0]=g):g=e[0];const u=Re(g),h=Ot(),C=Ye().location.href,v=jt();let j;e[1]!==o?(j={connectionId:o},e[1]=o,e[2]=j):j=e[2];const w=qt(j),f=w.isAuthenticated;let P;e[3]!==s?(P={connections:[s],binding:"MCP"},e[3]=s,e[4]=P):P=e[4];const T=Bt(P).length>0,V=s?.metadata?.repository,k=!!V?.url;let O;e[5]===Symbol.for("react.memo_cache_sentinel")?(O=Ft(Ws),e[5]=O):O=e[5];let M;e[6]!==s?(M=ft(s),e[6]=s,e[7]=M):M=e[7];let X;e[8]!==M?(X={resolver:O,values:M},e[8]=M,e[9]=X):X=e[9];const N=Wt(X),R=N.formState.isDirty;let E;e[10]!==N||e[11]!==l?(E=async()=>{if(!await N.trigger())return;const L=N.getValues(),ye=Bs(L);await l(ye),N.reset(L)},e[10]=N,e[11]=l,e[12]=E):E=e[12];const I=E;let A;e[13]!==s||e[14]!==N?(A=()=>{N.reset(ft(s))},e[13]=s,e[14]=N,e[15]=A):A=e[15];const D=A;let y;e[16]!==s.id||e[17]!==v||e[18]!==h?(y=async()=>{const{token:_,tokenInfo:L,error:ye}=await Gt({connectionId:s.id});if(ye||!_){_e.error(`Authentication failed: ${ye}`);return}if(L)try{const Oe=await fetch(`/api/connections/${s.id}/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})});if(!Oe.ok)console.error("Failed to save OAuth token:",await Oe.text()),await v.update.mutateAsync({id:s.id,data:{connection_token:_}});else try{await v.update.mutateAsync({id:s.id,data:{}})}catch(et){console.warn("Failed to refresh connection tools after OAuth:",et)}}catch(Oe){console.error("Error saving OAuth token:",Oe),await v.update.mutateAsync({id:s.id,data:{connection_token:_}})}else await v.update.mutateAsync({id:s.id,data:{connection_token:_}});const kt=new URL(`/mcp/${s.id}`,window.location.origin);await h.invalidateQueries({queryKey:st.isMCPAuthenticated(kt.href,null)}),_e.success("Authentication successful")},e[16]=s.id,e[17]=v,e[18]=h,e[19]=y):y=e[19];const F=y;let z;e[20]!==s.id||e[21]!==h?(z=async()=>{try{const _=await fetch(`/api/connections/${s.id}/oauth-token`,{method:"DELETE",credentials:"include"});if(!_.ok){const ye=await _.text();_e.error(`Failed to remove OAuth: ${ye}`);return}const L=new URL(`/mcp/${s.id}`,window.location.origin);await h.invalidateQueries({queryKey:st.isMCPAuthenticated(L.href,null)}),_e.success("OAuth removed. You can now re-authenticate with a different account.")}catch(_){console.error("Error removing OAuth token:",_),_e.error("Failed to remove OAuth")}},e[20]=s.id,e[21]=h,e[22]=z):z=e[22];const S=z,H=p.length,B=d.length,se=x.length,we=H>0||a;let te;e[23]===Symbol.for("react.memo_cache_sentinel")?(te={id:"settings",label:"Settings"},e[23]=te):te=e[23];let oe;e[24]!==a||e[25]!==f||e[26]!==we||e[27]!==H?(oe=f&&we?[{id:"tools",label:"Tools",count:a?void 0:H}]:[],e[24]=a,e[25]=f,e[26]=we,e[27]=H,e[28]=oe):oe=e[28];let re;e[29]!==f||e[30]!==B?(re=f&&B>0?[{id:"prompts",label:"Prompts",count:B}]:[],e[29]=f,e[30]=B,e[31]=re):re=e[31];let ae;e[32]!==f||e[33]!==se?(ae=f&&se>0?[{id:"resources",label:"Resources",count:se}]:[],e[32]=f,e[33]=se,e[34]=ae):ae=e[34];let ke;if(e[35]!==i||e[36]!==k||e[37]!==f||e[38]!==oe||e[39]!==re||e[40]!==ae){let _;e[42]!==k?(_=k?[{id:"readme",label:"README"}]:[],e[42]=k,e[43]=_):_=e[43],ke=[te,...oe,...re,...ae,...f?(i||[]).map(Hs):[],..._],e[35]=i,e[36]=k,e[37]=f,e[38]=oe,e[39]=re,e[40]=ae,e[41]=ke}else ke=e[41];const Se=ke,Pt=f&&Se.some(Ys)?"tools":"settings",W=Se.some(_=>_.id===c)?c:Pt;let Te;e[44]!==u?(Te=_=>{u({search:L=>({...L,tab:_}),replace:!0})},e[44]=u,e[45]=Te):Te=e[45];const ie=Te;let ce;e[46]!==i?(ce=i||[],e[46]=i,e[47]=ce):ce=e[47];let Me;if(e[48]!==W||e[49]!==ce){let _;e[51]!==W?(_=L=>L.name===W,e[51]=W,e[52]=_):_=e[52],Me=ce.find(_),e[48]=W,e[49]=ce,e[50]=Me}else Me=e[50];const De=Me;let le;e[53]!==r?(le=n.jsx(ot,{children:n.jsx(en,{asChild:!0,children:n.jsx(ht,{to:"/$org/mcps",params:{org:r},children:"Connections"})})}),e[53]=r,e[54]=le):le=e[54];let Ie;e[55]===Symbol.for("react.memo_cache_sentinel")?(Ie=n.jsx(tn,{}),e[55]=Ie):Ie=e[55];let de;e[56]!==s.title?(de=n.jsx(ot,{children:n.jsx(Zt,{children:s.title})}),e[56]=s.title,e[57]=de):de=e[57];let Ae;e[58]!==le||e[59]!==de?(Ae=n.jsx(nn,{children:n.jsxs(sn,{children:[le,Ie,de]})}),e[58]=le,e[59]=de,e[60]=Ae):Ae=e[60];const ze=Ae;let ue;e[61]!==I||e[62]!==D||e[63]!==R||e[64]!==m?(ue=n.jsx(Xt,{onSave:I,onUndo:D,isDirty:R,isSaving:m}),e[61]=I,e[62]=D,e[63]=R,e[64]=m,e[65]=ue):ue=e[65];const Xe=s.icon??"settings";let me;e[66]!==s.title||e[67]!==Xe||e[68]!==C?(me=n.jsx(Ke,{title:s.title,url:C,icon:Xe}),e[66]=s.title,e[67]=Xe,e[68]=C,e[69]=me):me=e[69];let fe;e[70]!==ue||e[71]!==me?(fe=n.jsxs(Je,{children:[ue,me]}),e[70]=ue,e[71]=me,e[72]=fe):fe=e[72];let he;e[73]!==w.hasOAuthToken||e[74]!==s||e[75]!==N||e[76]!==F||e[77]!==S||e[78]!==f?(he=n.jsx("div",{className:"w-100 shrink-0 border-r border-border bg-background",children:n.jsx(gs,{form:N,connection:s,isMCPAuthenticated:f,hasOAuthToken:w.hasOAuthToken,onReauthenticate:F,onRemoveOAuth:S})}),e[73]=w.hasOAuthToken,e[74]=s,e[75]=N,e[76]=F,e[77]=S,e[78]=f,e[79]=he):he=e[79];let pe;e[80]!==W||e[81]!==ie||e[82]!==Se?(pe=n.jsx("div",{className:"shrink-0 flex items-center gap-4 px-5 py-3 border-b border-border",children:n.jsx(on,{tabs:Se,activeTab:W,onTabChange:ie,className:"flex-1"})}),e[80]=W,e[81]=ie,e[82]=Se,e[83]=pe):pe=e[83];let Ve;e[84]===Symbol.for("react.memo_cache_sentinel")?(Ve=n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(Le,{size:32,className:"animate-spin text-muted-foreground"})}),e[84]=Ve):Ve=e[84];let xe;e[85]!==De||e[86]!==W||e[87]!==w.isServerError||e[88]!==w.supportsOAuth||e[89]!==s||e[90]!==o||e[91]!==N||e[92]!==F||e[93]!==ie||e[94]!==T||e[95]!==k||e[96]!==a||e[97]!==f||e[98]!==r||e[99]!==d||e[100]!==V||e[101]!==x||e[102]!==p?(xe=n.jsx(Y.Suspense,{fallback:Ve,children:W==="tools"?n.jsx(Es,{tools:p,connectionId:o,org:r,isLoading:a}):W==="prompts"?n.jsx(Cs,{prompts:d,connectionId:o,org:r}):W==="resources"?n.jsx(Os,{resources:x,connectionId:o,org:r}):W==="settings"?n.jsx(Yt,{connection:s,form:N,hasMcpBinding:T,isMCPAuthenticated:f,supportsOAuth:w.supportsOAuth,isServerError:w.isServerError,onAuthenticate:F,onViewReadme:k?()=>ie("readme"):void 0}):W==="readme"&&k?n.jsx(Ps,{repository:V}):De&&f?n.jsx(an,{connectionId:o,org:r,activeCollection:De},W):n.jsx(ve,{title:"Collection not found",description:"This collection may have been deleted or you may not have access."})}),e[85]=De,e[86]=W,e[87]=w.isServerError,e[88]=w.supportsOAuth,e[89]=s,e[90]=o,e[91]=N,e[92]=F,e[93]=ie,e[94]=T,e[95]=k,e[96]=a,e[97]=f,e[98]=r,e[99]=d,e[100]=V,e[101]=x,e[102]=p,e[103]=xe):xe=e[103];let ge;e[104]!==W||e[105]!==xe?(ge=n.jsx("div",{className:"flex-1 overflow-auto",children:n.jsx(gt,{children:xe},W)}),e[104]=W,e[105]=xe,e[106]=ge):ge=e[106];let be;e[107]!==pe||e[108]!==ge?(be=n.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:[pe,ge]}),e[107]=pe,e[108]=ge,e[109]=be):be=e[109];let je;e[110]!==he||e[111]!==be?(je=n.jsxs("div",{className:"flex h-full w-full bg-background overflow-hidden",children:[he,be]}),e[110]=he,e[111]=be,e[112]=je):je=e[112];let $e;return e[113]!==ze||e[114]!==fe||e[115]!==je?($e=n.jsxs(rn,{breadcrumb:ze,children:[fe,je]}),e[113]=ze,e[114]=fe,e[115]=je,e[116]=$e):$e=e[116],$e}function Ys(t){return t.id==="tools"}function Hs(t){return{id:t.name,label:t.displayName}}function Ks(){const t=U.c(43);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/$org/mcps/$connectionId"},t[0]=e):e=t[0];const s=Re(e);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={from:"/shell/$org/mcps/$connectionId"},t[1]=o):o=t[1];const{connectionId:r,org:c}=Vt(o),{org:i}=pt();let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l={from:"/shell/$org/mcps/$connectionId"},t[2]=l):l=t[2];const d=$t(l).tab??"",x=Qe(r),p=jt(),a=Ut(x??void 0);let g;t[3]!==r||t[4]!==i.id?(g={connectionId:r,orgId:i.id},t[3]=r,t[4]=i.id,t[5]=g):g=t[5];const u=Kt(g);let h;t[6]!==u?(h={client:u},t[6]=u,t[7]=h):h=t[7];const{data:b}=Qt(h);let C;t[8]!==u?(C={client:u},t[8]=u,t[9]=C):C=t[9];const{data:v}=Jt(C),j=x?.tools&&x.tools.length>0,w=!j;let f;t[10]!==u||t[11]!==w?(f={client:u,enabled:w},t[10]=u,t[11]=w,t[12]=f):f=t[12];const{data:P,isLoading:$}=Ht(f);let T;t[13]!==b?.prompts?(T=b?.prompts??[],t[13]=b?.prompts,t[14]=T):T=t[14];let V;t[15]!==T?(V=T.map(Gs),t[15]=T,t[16]=V):V=t[16];const k=V;let O;t[17]!==v?.resources?(O=v?.resources??[],t[17]=v?.resources,t[18]=O):O=t[18];let M;t[19]!==O?(M=O.map(Js),t[19]=O,t[20]=M):M=t[20];const X=M;let N;t[21]!==x||t[22]!==j||t[23]!==P?.tools?(N=j?x.tools??[]:(P?.tools??[]).map(Qs),t[21]=x,t[22]=j,t[23]=P?.tools,t[24]=N):N=t[24];const R=N;let E;t[25]!==p.update||t[26]!==r?(E=async D=>{await p.update.mutateAsync({id:r,data:D})},t[25]=p.update,t[26]=r,t[27]=E):E=t[27];const I=E;if(!x){let D;return t[28]!==s||t[29]!==c?(D=n.jsx("div",{className:"flex h-full w-full bg-background",children:n.jsx(ve,{title:"Connection not found",description:"This connection may have been deleted or you may not have access.",actions:n.jsx(Be,{variant:"outline",onClick:()=>s({to:"/$org/mcps",params:{org:c}}),children:"Back to connections"})})}),t[28]=s,t[29]=c,t[30]=D):D=t[30],D}let A;return t[31]!==p.update.isPending||t[32]!==a||t[33]!==x||t[34]!==r||t[35]!==I||t[36]!==$||t[37]!==c||t[38]!==k||t[39]!==d||t[40]!==X||t[41]!==R?(A=n.jsx(qs,{org:c,connection:x,connectionId:r,requestedTabId:d,collections:a,onUpdate:I,isUpdating:p.update.isPending,prompts:k,resources:X,tools:R,isLoadingTools:$}),t[31]=p.update.isPending,t[32]=a,t[33]=x,t[34]=r,t[35]=I,t[36]=$,t[37]=c,t[38]=k,t[39]=d,t[40]=X,t[41]=R,t[42]=A):A=t[42],A}function Qs(t){return{name:t.name,description:t.description,inputSchema:t.inputSchema}}function Js(t){return{uri:t.uri,name:t.name,description:t.description}}function Gs(t){return{name:t.name,description:t.description}}function Zs(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(gt,{children:n.jsx(Y.Suspense,{fallback:n.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:n.jsx(Le,{size:32,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Ks,{})})}),t[0]=e):e=t[0],e}function kr(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Zs,{}),t[0]=e):e=t[0],e}export{kr as default};