decocms 4.49.0 → 4.49.2

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 (219) hide show
  1. package/dist/client/assets/{AlertCircle-k25R3-Si.js → AlertCircle-B9onYPsx.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight-goUbSV_t.js → ArrowUpRight-31bYFmB1.js} +1 -1
  3. package/dist/client/assets/{Check-tfEbDiSO.js → Check-CAm_pNZb.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-B-AysnVj.js → CheckCircle-LZxCN5IY.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-DDh3Hhw_.js → ChevronDown-DDQcR6fD.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-3DlxSDpa.js → ChevronRight-ZwqhPdyq.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-CGRHCTkf.js → ChevronUp-CFaryGNc.js} +1 -1
  8. package/dist/client/assets/{Circle-9NU9F6cw.js → Circle-Cb2xDFmW.js} +1 -1
  9. package/dist/client/assets/{Copy01-v70-83R3.js → Copy01-CuE5Mdxv.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-CJNxrPQc.js → DotsVertical-8bp0B0ya.js} +1 -1
  11. package/dist/client/assets/{Eye-BQAd-UWR.js → Eye-DkQOgqLy.js} +1 -1
  12. package/dist/client/assets/{FilterLines-WY77jC6d.js → FilterLines-DXM-OYLy.js} +1 -1
  13. package/dist/client/assets/{Globe01-BJm_6L1K.js → Globe01-DBXbzkud.js} +1 -1
  14. package/dist/client/assets/{Globe04-Bvx5rGM6.js → Globe04-D3KvtDDx.js} +1 -1
  15. package/dist/client/assets/{HardDrive-DqhFpjyW.js → HardDrive-C-0ZSA5F.js} +1 -1
  16. package/dist/client/assets/{Key01-Ca3H4Guz.js → Key01-Dd9wKRX6.js} +1 -1
  17. package/dist/client/assets/{LayoutLeft-LgchNodn.js → LayoutLeft-lNBuuI5W.js} +1 -1
  18. package/dist/client/assets/{LinkExternal01-4WLYi2mX.js → LinkExternal01-D_Rlg4XY.js} +1 -1
  19. package/dist/client/assets/{List-CP5qu-Ed.js → List-5gTuVFju.js} +1 -1
  20. package/dist/client/assets/{Loading02-EeaKovpr.js → Loading02-BKjix3t4.js} +1 -1
  21. package/dist/client/assets/{Monitor01-B7DuF8uL.js → Monitor01-BxJdzfiN.js} +1 -1
  22. package/dist/client/assets/{Palette-BDkRrX1I.js → Palette-DHuaqxQW.js} +1 -1
  23. package/dist/client/assets/{Play-DSAmPT6o.js → Play-siKyKpye.js} +1 -1
  24. package/dist/client/assets/{Plus-C1-9U7xY.js → Plus-OhB-LRM_.js} +1 -1
  25. package/dist/client/assets/{SearchLg-CvEhHQsI.js → SearchLg-Cw1vzWS4.js} +1 -1
  26. package/dist/client/assets/{SearchMd-DiN4RXkm.js → SearchMd-OFgwXHVA.js} +1 -1
  27. package/dist/client/assets/{Settings02-C31aohuM.js → Settings02-B3B_P5fs.js} +1 -1
  28. package/dist/client/assets/{Shield01-CszvfMrq.js → Shield01-BGz5Kh9w.js} +1 -1
  29. package/dist/client/assets/{Star01-DGbt_SIN.js → Star01-CKALy4hI.js} +1 -1
  30. package/dist/client/assets/{Stars01-BKEHGK4f.js → Stars01-CVOa90uJ.js} +1 -1
  31. package/dist/client/assets/{Stars02-KrIAmQsB.js → Stars02-DEytbopx.js} +1 -1
  32. package/dist/client/assets/{Sun-BdOFeDi1.js → Sun-C9p5qQM_.js} +1 -1
  33. package/dist/client/assets/{SwitchHorizontal01-C6ZclJC7.js → SwitchHorizontal01-X4Ivgb48.js} +1 -1
  34. package/dist/client/assets/{Tool01-MLrVuoSu.js → Tool01-De44pARs.js} +1 -1
  35. package/dist/client/assets/{Trash01-DggFSL1b.js → Trash01-CldWiayK.js} +1 -1
  36. package/dist/client/assets/{Upload01-Cxs1z0Jh.js → Upload01-BdN7-z6J.js} +1 -1
  37. package/dist/client/assets/{User01-L5odKA9U.js → User01-DICqHJXD.js} +1 -1
  38. package/dist/client/assets/{Users01-0hD-3O0B.js → Users01-BbT3orCr.js} +1 -1
  39. package/dist/client/assets/{Users03-OwsRMjku.js → Users03-7hIYOoO1.js} +1 -1
  40. package/dist/client/assets/{X-BSHZ0M6H.js → X-CWu4KAgv.js} +1 -1
  41. package/dist/client/assets/{XCircle-Ce3AP-z1.js → XCircle-BnMyXX6H.js} +1 -1
  42. package/dist/client/assets/{XClose-Dha2rZyS.js → XClose-B4Kds20_.js} +1 -1
  43. package/dist/client/assets/{Zap-MjamIo9C.js → Zap-kwvB2Aey.js} +1 -1
  44. package/dist/client/assets/{ZapSquare-2TYVPpzw.js → ZapSquare-CO43pmjR.js} +1 -1
  45. package/dist/client/assets/{ZoomOut-DOMq8Qks.js → ZoomOut-DAzAklM3.js} +1 -1
  46. package/dist/client/assets/{access-gate-B7i8fTcq.js → access-gate-DPJVwytb.js} +1 -1
  47. package/dist/client/assets/{add-section-modal-BFa2vink.js → add-section-modal-nY5ZEjwv.js} +1 -1
  48. package/dist/client/assets/{agent-capabilities-CcfbqOca.js → agent-capabilities-DiwM8z_R.js} +1 -1
  49. package/dist/client/assets/{agent-icon-BxlAfYtU.js → agent-icon-D9GYV26D.js} +1 -1
  50. package/dist/client/assets/{agents-list-Dpg0mQ5j.js → agents-list-Djll6W7z.js} +1 -1
  51. package/dist/client/assets/{ai-providers-hukOcDkN.js → ai-providers-7YFyaNPR.js} +1 -1
  52. package/dist/client/assets/{alert-CPrpIdPz.js → alert-DH6_1sf9.js} +1 -1
  53. package/dist/client/assets/{alert-dialog-9kOsUrrA.js → alert-dialog-C-4lAz2-.js} +1 -1
  54. package/dist/client/assets/{app-editor-BznZUTpm.js → app-editor-COWA0gLS.js} +1 -1
  55. package/dist/client/assets/{auth-DEpjtwun.js → auth-5F6-aJmo.js} +1 -1
  56. package/dist/client/assets/{auth-catchall-D_RkydrM.js → auth-catchall-T_Tc3w05.js} +1 -1
  57. package/dist/client/assets/{auth-entry-jFqYAMuT.js → auth-entry-BOu9WfTk.js} +1 -1
  58. package/dist/client/assets/{auth-split-layout-7N_nwEWR.js → auth-split-layout-B2X42J2r.js} +1 -1
  59. package/dist/client/assets/{authenticate-and-persist-oauth-Z5iZl3NY.js → authenticate-and-persist-oauth-DDtpfxrP.js} +1 -1
  60. package/dist/client/assets/{automation-list-row-DoFEAvgQ.js → automation-list-row-aWkha2kK.js} +1 -1
  61. package/dist/client/assets/{automation-runs-DbWyk7jb.js → automation-runs-BJpZPWhG.js} +1 -1
  62. package/dist/client/assets/{automations-CABzNKUu.js → automations-BpLrGqO1.js} +1 -1
  63. package/dist/client/assets/{autosend-hYfyQlKa.js → autosend-Ho-hw6LZ.js} +1 -1
  64. package/dist/client/assets/{avatar-B5g154Et.js → avatar-DuOsWYcG.js} +1 -1
  65. package/dist/client/assets/{badge-qy7vzuZ8.js → badge-CzvDyOP_.js} +1 -1
  66. package/dist/client/assets/{block-document-DNsS2KRT.js → block-document-BOy_zGcw.js} +1 -1
  67. package/dist/client/assets/{brand-context-D7jkbFUV.js → brand-context-R0iVvEH8.js} +1 -1
  68. package/dist/client/assets/{breadcrumb-COfYELC8.js → breadcrumb-voNACu1V.js} +1 -1
  69. package/dist/client/assets/{buckets-CB-PCLi2.js → buckets-Bb05h-zL.js} +1 -1
  70. package/dist/client/assets/{bulk-category-panel-EPnEykuu.js → bulk-category-panel-BTQtHqS3.js} +1 -1
  71. package/dist/client/assets/{calendar-CqrMvOtO.js → calendar-CFx1zR5S.js} +1 -1
  72. package/dist/client/assets/{capability-load-error-DcdUflTi.js → capability-load-error-z2KG7Z7c.js} +1 -1
  73. package/dist/client/assets/{card-BhI7Np_f.js → card-kXMv7TY0.js} +1 -1
  74. package/dist/client/assets/{category-editor-BiFT8zOt.js → category-editor-DSCqUCPd.js} +1 -1
  75. package/dist/client/assets/{chat-context-DbtHJFUr.js → chat-context-DwqbCivU.js} +1 -1
  76. package/dist/client/assets/{checkbox-C9d1lIYX.js → checkbox-B7RCGW8m.js} +1 -1
  77. package/dist/client/assets/{cli-auth-success-Bv1VcbtV.js → cli-auth-success-DJBNtNIm.js} +1 -1
  78. package/dist/client/assets/{collection-detail-CRVut8n4.js → collection-detail-BEA2EhoB.js} +1 -1
  79. package/dist/client/assets/{collection-display-button-Cruq60_Q.js → collection-display-button-CegkzxeF.js} +1 -1
  80. package/dist/client/assets/{collection-search-CwUbH4qH.js → collection-search-BPxsVhJJ.js} +1 -1
  81. package/dist/client/assets/{collection-table-wrapper-BjYwYC4q.js → collection-table-wrapper-CTf5_GQE.js} +1 -1
  82. package/dist/client/assets/{collection-tabs-ClxY84rJ.js → collection-tabs-B9fzylNI.js} +1 -1
  83. package/dist/client/assets/{command-B3cu0Aev.js → command-DQcISPQW.js} +1 -1
  84. package/dist/client/assets/commerce-onboarding-DogAzM5M.js +1 -0
  85. package/dist/client/assets/{connect-desktop-dialog-CsHMUYFP.js → connect-desktop-dialog-epPbnUVm.js} +1 -1
  86. package/dist/client/assets/{connection-card-CDb2GmfN.js → connection-card-BKI86wdV.js} +1 -1
  87. package/dist/client/assets/{connection-detail-DaB9Caux.js → connection-detail-BnmFVoeJ.js} +1 -1
  88. package/dist/client/assets/{connection-form-helpers-DwHnDZGX.js → connection-form-helpers-BwLjgtsz.js} +1 -1
  89. package/dist/client/assets/{connections-C5LmG-ha.js → connections-CyvrAE2b.js} +1 -1
  90. package/dist/client/assets/{decopilot-sse-pool-Xn1jBQQZ.js → decopilot-sse-pool-OlccTr4u.js} +1 -1
  91. package/dist/client/assets/{dialog-Doo4cf6x.js → dialog-GMipq3bN.js} +1 -1
  92. package/dist/client/assets/{domain-settings-DY3jmP1m.js → domain-settings-B-sqks9R.js} +1 -1
  93. package/dist/client/assets/{drawer-CzFCT3PH.js → drawer-DS0hJ2mS.js} +1 -1
  94. package/dist/client/assets/{dropdown-menu-Zn5Qzoi0.js → dropdown-menu-BcNFF_FB.js} +1 -1
  95. package/dist/client/assets/{empty-state-B5ZXJOuz.js → empty-state-D4qJAGbA.js} +1 -1
  96. package/dist/client/assets/{extract-connection-data-CAN-85EW.js → extract-connection-data-BqrHdbra.js} +1 -1
  97. package/dist/client/assets/{file-explorer-37Ixz2H8.js → file-explorer-t9hk2bdP.js} +1 -1
  98. package/dist/client/assets/{file-type-icon-CpecjgQb.js → file-type-icon-BhN035oL.js} +1 -1
  99. package/dist/client/assets/{files-7KwaVvpP.js → files-C8O9yA5-.js} +1 -1
  100. package/dist/client/assets/{form-DGt94nWL.js → form-DsLI-cso.js} +1 -1
  101. package/dist/client/assets/{general-DpPTR2IV.js → general-D8XS_oON.js} +1 -1
  102. package/dist/client/assets/{github-repo-picker-DFQ47NAm.js → github-repo-picker-dtivs6I9.js} +1 -1
  103. package/dist/client/assets/{hooks-CVWEOPPl.js → hooks-BZkcj2r4.js} +1 -1
  104. package/dist/client/assets/{index-DRHqcbla.js → index-B1051xzt.js} +1 -1
  105. package/dist/client/assets/{index-CO1L2k6F.js → index-B7JNGFVx.js} +3 -3
  106. package/dist/client/assets/{index-DH2YDD3V.js → index-BKndjreU.js} +1 -1
  107. package/dist/client/assets/{index-B9mjAGk9.js → index-BVZ_r-K-.js} +1 -1
  108. package/dist/client/assets/{index-8tv7d0Ve.js → index-BrBhXbYM.js} +1 -1
  109. package/dist/client/assets/{index-rTzepySe.js → index-BxU_rwXD.js} +1 -1
  110. package/dist/client/assets/{index-CiXX-fWm.js → index-CD5Jwhj2.js} +1 -1
  111. package/dist/client/assets/{index-dIqwxqlw.js → index-CYYm5HCO.js} +1 -1
  112. package/dist/client/assets/{index-CeaSA5WZ.js → index-CgKTaY8f.js} +1 -1
  113. package/dist/client/assets/{index-CDfGnUft.js → index-DN4es646.js} +1 -1
  114. package/dist/client/assets/{index-BiBP_IJ-.js → index-DeTRNkFd.js} +1 -1
  115. package/dist/client/assets/{index-B-lL4Bof.js → index-PHwNl1XB.js} +7 -7
  116. package/dist/client/assets/{index-B46tvY2S.js → index-Tg8sdJ1w.js} +1 -1
  117. package/dist/client/assets/{index-BHFkoj3g.js → index-VqwZFWNF.js} +1 -1
  118. package/dist/client/assets/{index-redirect-SiI_MmOn.js → index-redirect-BYibEEwr.js} +1 -1
  119. package/dist/client/assets/{input-COW4go5N.js → input-CHky12sK.js} +1 -1
  120. package/dist/client/assets/{integration-icon-BnLf1D5y.js → integration-icon-BFZYNQuW.js} +1 -1
  121. package/dist/client/assets/{invite-member-dialog-D-VduUaY.js → invite-member-dialog-ektjPOuy.js} +1 -1
  122. package/dist/client/assets/{label-D-dsSZO9.js → label-msw6-gdP.js} +1 -1
  123. package/dist/client/assets/{login-BBExhs0i.js → login-CHaF3CC3.js} +1 -1
  124. package/dist/client/assets/{mcp-oauth-BkvwEKNk.js → mcp-oauth-7gmCRD5I.js} +1 -1
  125. package/dist/client/assets/{members-BsA618Ds.js → members-Bvb6D5QH.js} +1 -1
  126. package/dist/client/assets/{monaco-editor-RTekDV_G.js → monaco-editor-Zx0Ag8L5.js} +1 -1
  127. package/dist/client/assets/{monitoring-stats-row-DXsXFCSg.js → monitoring-stats-row-CJCcXz8y.js} +1 -1
  128. package/dist/client/assets/{oauth-callback-ai-provider-C_RrwpQT.js → oauth-callback-ai-provider-CvagoZEl.js} +1 -1
  129. package/dist/client/assets/{oauth-callback-CqjNzHWn.js → oauth-callback-mA-xzC34.js} +1 -1
  130. package/dist/client/assets/{onboarding-BWDDHwD0.js → onboarding-BjQanYXn.js} +1 -1
  131. package/dist/client/assets/{org-install-Bey3pM-s.js → org-install-BEQYqnp_.js} +1 -1
  132. package/dist/client/assets/{org-layout-CBrTiXLW.js → org-layout-wpb8P17S.js} +1 -1
  133. package/dist/client/assets/{organization-choice-BcTXS06q.js → organization-choice-Cg_2h-2D.js} +1 -1
  134. package/dist/client/assets/page-seo-sheet-nHtaw93i.js +1 -0
  135. package/dist/client/assets/{popover-COxSNUI9.js → popover-Bz_Xru-P.js} +1 -1
  136. package/dist/client/assets/{post-editor-Dg36btgx.js → post-editor-HL0rlBj2.js} +1 -1
  137. package/dist/client/assets/{primitives-ySArMO8A.js → primitives-DIBvRULT.js} +1 -1
  138. package/dist/client/assets/{profile-CHW3d_C3.js → profile-CX7d-Erk.js} +1 -1
  139. package/dist/client/assets/project-app-view-B7vqrrdE.js +1 -0
  140. package/dist/client/assets/record-editor-B1ZKaNCA.js +1 -0
  141. package/dist/client/assets/registry-kBrMyKY-.js +2 -0
  142. package/dist/client/assets/{registry-layout-DM6iRP4R.js → registry-layout-C4kp6l98.js} +1 -1
  143. package/dist/client/assets/{require-capability-C0bowvl-.js → require-capability-BWjUaB5B.js} +1 -1
  144. package/dist/client/assets/{required-auth-layout-CANoL34o.js → required-auth-layout-Cinp25Ct.js} +1 -1
  145. package/dist/client/assets/{reset-password-Bu-RIMAl.js → reset-password-DZDseYc6.js} +1 -1
  146. package/dist/client/assets/{roles-CEWWPS9R.js → roles-BUZuQxBh.js} +1 -1
  147. package/dist/client/assets/{search-input-B51XuoAi.js → search-input-gJuqvZHJ.js} +1 -1
  148. package/dist/client/assets/{secrets-D3WG23GX.js → secrets-D2SNOS8o.js} +1 -1
  149. package/dist/client/assets/{sections-editor-BmLUDELp.js → sections-editor-C5Un2D1A.js} +1 -1
  150. package/dist/client/assets/{select-B1glqaL5.js → select-djrgFxBF.js} +1 -1
  151. package/dist/client/assets/{select-model-CTRtCpyq.js → select-model-CHyztNvP.js} +1 -1
  152. package/dist/client/assets/{seo-editor-BiVjKNYD.js → seo-editor-BvsGgsGT.js} +1 -1
  153. package/dist/client/assets/{seo-save-Di9kBsWL.js → seo-save-CoT8WcVH.js} +1 -1
  154. package/dist/client/assets/{settings-layout-DWTWQdbp.js → settings-layout-DOzm1d9a.js} +1 -1
  155. package/dist/client/assets/{settings-section-BJ5Z9sbk.js → settings-section-DamXIdEC.js} +1 -1
  156. package/dist/client/assets/{shell-controls-C_t0yT4o.js → shell-controls-BZPUCjyN.js} +1 -1
  157. package/dist/client/assets/{shell-layout-BtQe-dI_.js → shell-layout-DbtPHFXH.js} +1 -1
  158. package/dist/client/assets/{sidebar-xOgqyAzw.js → sidebar-bjJvb4gf.js} +1 -1
  159. package/dist/client/assets/{skeleton-Y0aYZIGv.js → skeleton-DL4GzfYu.js} +1 -1
  160. package/dist/client/assets/{sso-p-GWEiH_.js → sso-BsxfLmwX.js} +1 -1
  161. package/dist/client/assets/{store-DG4R5TyA.js → store-DjwC4BRa.js} +1 -1
  162. package/dist/client/assets/store-registry-B2phgpZb.js +2 -0
  163. package/dist/client/assets/{studio-tools-CkzkLbeK.js → studio-tools-CXs7tmNe.js} +1 -1
  164. package/dist/client/assets/{switch-BeCDglKS.js → switch-DZFKDGrI.js} +1 -1
  165. package/dist/client/assets/{table-CK7f3A2A.js → table-CBgjwcYZ.js} +1 -1
  166. package/dist/client/assets/{tabs-CJJv0rqZ.js → tabs-ZPYmeZvl.js} +1 -1
  167. package/dist/client/assets/{textarea-BoXzEDCS.js → textarea-CGL1_Au9.js} +1 -1
  168. package/dist/client/assets/{toggle-group-D8suAen9.js → toggle-group-DnVLPXfF.js} +1 -1
  169. package/dist/client/assets/{toolbar-L2J1s5cv.js → toolbar-DgjSQqtK.js} +1 -1
  170. package/dist/client/assets/{toolbar-icon-button-D8lNvCwb.js → toolbar-icon-button-vYHpP2V_.js} +1 -1
  171. package/dist/client/assets/{tools-list-B9fSZWYy.js → tools-list-BoQVqGkv.js} +1 -1
  172. package/dist/client/assets/{tooltip-B8UTXuYj.js → tooltip-DfM4QSuK.js} +1 -1
  173. package/dist/client/assets/{types-CI4ZpBJG.js → types-BCdM8Cqh.js} +1 -1
  174. package/dist/client/assets/{use-ai-providers-CakVoxd1.js → use-ai-providers-ZXXawdWI.js} +1 -1
  175. package/dist/client/assets/{use-automations-DeM5roCe.js → use-automations-Bihj6PCT.js} +1 -1
  176. package/dist/client/assets/{use-capability-B9S8HhSs.js → use-capability-BLp--8xF.js} +1 -1
  177. package/dist/client/assets/{use-clock-tick-JSYy3xwe.js → use-clock-tick-bhMgDN35.js} +1 -1
  178. package/dist/client/assets/{use-collections-DwtBugWF.js → use-collections-CD3k8D6X.js} +1 -1
  179. package/dist/client/assets/{use-connection-BDpHVnM9.js → use-connection-DDhhP7Ph.js} +1 -1
  180. package/dist/client/assets/{use-copy-CVEWQijj.js → use-copy-akuTSKf4.js} +1 -1
  181. package/dist/client/assets/{use-create-virtual-mcp-CyHPTRnR.js → use-create-virtual-mcp-_RLJSy4_.js} +1 -1
  182. package/dist/client/assets/{use-debounced-autosave-C-WNNWm4.js → use-debounced-autosave-B1tAicTn.js} +1 -1
  183. package/dist/client/assets/{use-debounced-value-bUjKN4su.js → use-debounced-value-oPrTFKLx.js} +1 -1
  184. package/dist/client/assets/{use-decopilot-events-vQdREpgW.js → use-decopilot-events-B15cvyYy.js} +1 -1
  185. package/dist/client/assets/{use-delete-connection-CHv507Hm.js → use-delete-connection-a61PAN9R.js} +1 -1
  186. package/dist/client/assets/{use-file-configs-D4DkA1o5.js → use-file-configs-Z7phqTHa.js} +1 -1
  187. package/dist/client/assets/{use-infinite-scroll-C76DIcY8.js → use-infinite-scroll-BVH17KKe.js} +1 -1
  188. package/dist/client/assets/{use-join-requests-D6ap2Uj2.js → use-join-requests-DZL_bSIS.js} +1 -1
  189. package/dist/client/assets/{use-mcp-client-DwetKDRa.js → use-mcp-client-DvbRbjIF.js} +1 -1
  190. package/dist/client/assets/{use-mcp-prompts-Dd5bB4_b.js → use-mcp-prompts-CYvAbk37.js} +1 -1
  191. package/dist/client/assets/{use-mcp-tools-BUiL0JOE.js → use-mcp-tools-DFWJ7tBv.js} +1 -1
  192. package/dist/client/assets/{use-members-BH7s_bbV.js → use-members-BDnKuBZb.js} +1 -1
  193. package/dist/client/assets/{use-mobile-BK99wTJG.js → use-mobile-KXOF-k75.js} +1 -1
  194. package/dist/client/assets/{use-navigate-to-agent-C6bEo5XD.js → use-navigate-to-agent-ZdTP31W5.js} +1 -1
  195. package/dist/client/assets/{use-org-auth-client-C_ymtLDP.js → use-org-auth-client-C3nOVxFM.js} +1 -1
  196. package/dist/client/assets/{use-org-sso-C-2oQsVK.js → use-org-sso-6Kgm_D55.js} +1 -1
  197. package/dist/client/assets/{use-organization-roles-BlEJ6Gvi.js → use-organization-roles-CsFElDKy.js} +1 -1
  198. package/dist/client/assets/{use-organization-settings-DDeNqP-7.js → use-organization-settings-D9bn2vMB.js} +1 -1
  199. package/dist/client/assets/{use-registry-connections-D-CxCgyF.js → use-registry-connections-CxelwF1s.js} +1 -1
  200. package/dist/client/assets/{use-secrets-Bh4ndTN4.js → use-secrets-P82GL4M9.js} +1 -1
  201. package/dist/client/assets/{use-status-sounds-BcOUu7LR.js → use-status-sounds-DH9ry82I.js} +1 -1
  202. package/dist/client/assets/{use-view-mode-SybAG8SK.js → use-view-mode-YB5NATmH.js} +1 -1
  203. package/dist/client/assets/{use-virtual-mcp-KIabF-QC.js → use-virtual-mcp-DSK2scNk.js} +1 -1
  204. package/dist/client/assets/useInfiniteQuery-B3mthAoE.js +1 -0
  205. package/dist/client/assets/useSuspenseInfiniteQuery-Dgafp0Uz.js +1 -0
  206. package/dist/client/assets/{variant-calendar-DlZJbhfj.js → variant-calendar-D_GhERcJ.js} +1 -1
  207. package/dist/client/assets/{view-mode-toggle-C3x6LuYl.js → view-mode-toggle-Dm0P_i1M.js} +1 -1
  208. package/dist/client/index.html +1 -1
  209. package/dist/server/cli.js +1 -1
  210. package/dist/server/server.js +1 -1
  211. package/package.json +1 -1
  212. package/dist/client/assets/commerce-onboarding-BYoRokdz.js +0 -1
  213. package/dist/client/assets/page-seo-sheet-C9KcJIyh.js +0 -1
  214. package/dist/client/assets/project-app-view-DSJYwYNP.js +0 -1
  215. package/dist/client/assets/record-editor-BKk1cGnm.js +0 -1
  216. package/dist/client/assets/registry-jF11637A.js +0 -2
  217. package/dist/client/assets/store-registry-D_uqHVBf.js +0 -2
  218. package/dist/client/assets/useInfiniteQuery-BauhQX45.js +0 -1
  219. package/dist/client/assets/useSuspenseInfiniteQuery-DJ9BuAY-.js +0 -1
@@ -0,0 +1 @@
1
+ import{m as At,n as Ue,s as Lt,o as Pt,Q as ct,p as ye,q as zt,v as Ut,r as K,w as $t,x as Dt,y as Mt,z as qt,C as st,D as Ft,E as Kt,F as Vt,c as F,l as ie,j as t,B,d as fe,K as Y,G as _e,H as le,I as Se,J as Ne,i as Re,k as ge,t as ke,L as ve,M as Z,O as dt,P as ut,a as Ae,u as mt,R as Ht,b as ft,T as Qt,U as pt,V as Gt}from"./index-B7JNGFVx.js";import{A as Bt}from"./auth-entry-BOu9WfTk.js";import{A as Wt}from"./auth-split-layout-B2X42J2r.js";import{O as nt}from"./organization-choice-Cg_2h-2D.js";import{f as Yt}from"./tab-id-bb-jjgGv.js";import{I as be}from"./input-CHky12sK.js";import{u as Le}from"./use-mcp-client-DvbRbjIF.js";import{W as Me,S as gt,g as Jt,C as Zt}from"./constants-B72Xmt_K.js";import{i as ht}from"./XCircle-BnMyXX6H.js";import{I as qe}from"./integration-icon-BFZYNQuW.js";import{D as he,a as xt,b as yt,c as bt,d as vt,e as Ct}from"./dialog-GMipq3bN.js";import{T as Fe,a as Ke,b as Ve}from"./tooltip-DfM4QSuK.js";import{i as He}from"./CheckCircle-LZxCN5IY.js";import{i as jt,t as Xt,a as _t}from"./agent-icon-D9GYV26D.js";import{g as es,c as ts,e as ss}from"./extract-connection-data-BqrHdbra.js";import{g as ns,f as os}from"./github-installations-D2vHSx02.js";import{F as ce,a as Ee,b as de,c as Oe,d as ue,e as me,f as is}from"./form-DsLI-cso.js";import{i as rs}from"./Check-CAm_pNZb.js";import{a as St}from"./Copy01-CuE5Mdxv.js";import{i as as}from"./Settings02-B3B_P5fs.js";import{s as ls}from"./Eye-DkQOgqLy.js";import{u as cs}from"./use-debounced-value-oPrTFKLx.js";import{a as ds}from"./authenticate-and-persist-oauth-DDtpfxrP.js";import{i as Nt}from"./ArrowUpRight-31bYFmB1.js";import"./backoff-CrEUbyZT.js";import"./delay-CnY5UFtP.js";import"./avatar-DuOsWYcG.js";import"./User01-DICqHJXD.js";import"./auth-5F6-aJmo.js";import"./X-CWu4KAgv.js";import"./AlertCircle-B9onYPsx.js";import"./Tool01-De44pARs.js";import"./SwitchHorizontal01-X4Ivgb48.js";import"./ZapSquare-CO43pmjR.js";import"./Users03-7hIYOoO1.js";import"./Loading02-BKjix3t4.js";import"./ChevronDown-DDQcR6fD.js";import"./ChevronRight-ZwqhPdyq.js";import"./ChevronUp-CFaryGNc.js";import"./Circle-Cb2xDFmW.js";import"./Stars02-DEytbopx.js";import"./ZoomOut-DAzAklM3.js";import"./DotsVertical-8bp0B0ya.js";import"./Globe01-DBXbzkud.js";import"./FilterLines-DXM-OYLy.js";import"./Star01-CKALy4hI.js";import"./Globe04-D3KvtDDx.js";import"./HardDrive-C-0ZSA5F.js";import"./Key01-Dd9wKRX6.js";import"./LayoutLeft-lNBuuI5W.js";import"./LinkExternal01-D_Rlg4XY.js";import"./List-5gTuVFju.js";import"./Monitor01-BxJdzfiN.js";import"./Sun-C9p5qQM_.js";import"./Palette-DHuaqxQW.js";import"./Play-siKyKpye.js";import"./Plus-OhB-LRM_.js";import"./SearchLg-Cw1vzWS4.js";import"./SearchMd-OFgwXHVA.js";import"./Shield01-BGz5Kh9w.js";import"./Stars01-CVOa90uJ.js";import"./Trash01-CldWiayK.js";import"./Upload01-BdN7-z6J.js";import"./Users01-BbT3orCr.js";import"./XClose-B4Kds20_.js";import"./Zap-kwvB2Aey.js";import"./label-msw6-gdP.js";import"./mcp-oauth-7gmCRD5I.js";function ot(n,e){const s=new Set(e);return n.filter(o=>!s.has(o))}function us(n,e,s){const o=n.slice(0);return o[e]=s,o}var ms=class extends At{#o;#e;#i;#n;#t;#s;#r;#a;#l;#c=[];constructor(n,e,s){super(),this.#o=n,this.#n=s,this.#i=[],this.#t=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(n=>{n.subscribe(e=>{this.#f(n,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(n=>{n.destroy()})}setQueries(n,e){this.#i=n,this.#n=e,Ue.batch(()=>{const s=this.#t,o=this.#m(this.#i);o.forEach(l=>l.observer.setOptions(l.defaultedQueryOptions));const i=o.map(l=>l.observer),r=i.map(l=>l.getCurrentResult()),a=s.length!==i.length,c=i.some((l,p)=>l!==s[p]),d=a||c,m=d?!0:r.some((l,p)=>{const f=this.#e[p];return!f||!Lt(l,f)});!d&&!m||(d&&(this.#c=o,this.#t=i),this.#e=r,this.hasListeners()&&(d&&(ot(s,i).forEach(l=>{l.destroy()}),ot(i,s).forEach(l=>{l.subscribe(p=>{this.#f(l,p)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(n=>n.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(n,e){const s=this.#m(n),o=s.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions)),i=s.map(r=>r.defaultedQueryOptions.queryHash);return[o,r=>this.#u(r??o,e,i),()=>this.#d(o,s)]}#d(n,e){return e.map((s,o)=>{const i=n[o];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,r=>{e.forEach(a=>{a.observer.trackProp(r)})})})}#u(n,e,s){if(e){const o=this.#l,i=s!==void 0&&o!==void 0&&(o.length!==s.length||s.some((r,a)=>r!==o[a]));return(!this.#s||this.#e!==this.#a||i||e!==this.#r)&&(this.#r=e,this.#a=this.#e,s!==void 0&&(this.#l=s),this.#s=Pt(this.#s,e(n))),this.#s}return n}#g(){return this.#n?.combine!==void 0&&this.#t.some((n,e)=>n.options.suspense&&this.#e[e]?.data===void 0)}#m(n){const e=new Map;this.#t.forEach(o=>{const i=o.options.queryHash;if(!i)return;const r=e.get(i);r?r.push(o):e.set(i,[o])});const s=[];return n.forEach(o=>{const i=this.#o.defaultQueryOptions(o),a=e.get(i.queryHash)?.shift()??new ct(this.#o,i);s.push({defaultedQueryOptions:i,observer:a})}),s}#f(n,e){const s=this.#t.indexOf(n);s!==-1&&(this.#e=us(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const n=this.#d(this.#e,this.#c),e=this.#g(),s=this.#s,o=e?s:this.#u(n,this.#n?.combine);(e||s!==o)&&Ue.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function fs({queries:n,...e},s){const o=ye(s),i=zt(),r=Ut(),a=K.useMemo(()=>n.map(C=>{const x=o.defaultQueryOptions(C);return x._optimisticResults=i?"isRestoring":"optimistic",x}),[n,o,i]);a.forEach(C=>{$t(C);const x=o.getQueryCache().get(C.queryHash);Dt(C,r,x)}),Mt(r);const[c]=K.useState(()=>new ms(o,a,e)),[d,m,l]=c.getOptimisticResult(a,e.combine),p=!i&&e.subscribed!==!1;K.useSyncExternalStore(K.useCallback(C=>p?c.subscribe(Ue.batchCalls(C)):qt,[c,p]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),K.useEffect(()=>{c.setQueries(a,e)},[a,e,c]);const h=d.some((C,x)=>st(a[x],C))?d.flatMap((C,x)=>{const g=a[x];if(g&&st(g,C)){const u=new ct(o,g);return Ft(g,u,r)}return[]}):[];if(h.length>0)throw Promise.all(h);const y=d.find((C,x)=>{const g=a[x];return g&&Kt({result:C,errorResetBoundary:r,throwOnError:g.throwOnError,query:o.getQueryCache().get(g.queryHash),suspense:g.suspense})});if(y?.error)throw y.error;return m(l())}function ps(n,e){return fs({...n,queries:n.queries.map(s=>({...s,suspense:!0,throwOnError:Vt,enabled:!0,placeholderData:void 0}))},e)}const gs=/^[a-zA-Z][a-zA-Z\d+.-]*:/,hs=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//,xs=/^[^\s/:?#]+\.[^\s/:?#]+:\d+(?:[/?#]|$)/,ys=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function ae(n){const e=n.trim();if(!e)return{ok:!1,error:"Enter a website URL."};const s=gs.test(e),o=hs.test(e),i=xs.test(e);if(s&&!o&&!i)return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const r=o?e:`https://${e}`;let a;try{a=new URL(r)}catch{return{ok:!1,error:"Enter a valid website URL."}}if(a.protocol!=="http:"&&a.protocol!=="https:")return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const c=a.hostname.split(".");return c.length<2||c.some(d=>!d||!ys.test(d))?{ok:!1,error:"Enter a valid website URL."}:(a.protocol="https:",{ok:!0,value:a.origin})}function bs(n,e){if(!n.trim())return!0;const s=ae(n);if(!s.ok||!e)return!1;const o=ae(e);return o.ok&&o.value===s.value}function $e(n){const e=F.c(14),{children:s,className:o,wrapperClassName:i}=n,[r,a]=K.useState(!0);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=C=>{if(!C)return;const x=()=>{const u=C.scrollHeight-C.scrollTop-C.clientHeight<8;a(u)};x(),C.addEventListener("scroll",x,{passive:!0});const g=new ResizeObserver(x);g.observe(C);for(const u of Array.from(C.children))g.observe(u);return()=>{C.removeEventListener("scroll",x),g.disconnect()}},e[0]=c):c=e[0];const d=c;let m;e[1]!==i?(m=ie("relative",i),e[1]=i,e[2]=m):m=e[2];let l;e[3]!==s||e[4]!==o?(l=t.jsx("div",{ref:d,className:o,children:s}),e[3]=s,e[4]=o,e[5]=l):l=e[5];const p=r?"opacity-0":"opacity-100";let f;e[6]!==p?(f=ie("pointer-events-none absolute inset-x-0 -bottom-px h-[72px]","bg-gradient-to-t from-sidebar from-[6px] to-transparent","backdrop-blur-[1px] [mask-image:linear-gradient(to_top,black_6px,transparent)]","transition-opacity duration-200",p),e[6]=p,e[7]=f):f=e[7];let h;e[8]!==f?(h=t.jsx("div",{"aria-hidden":!0,className:f}),e[8]=f,e[9]=h):h=e[9];let y;return e[10]!==m||e[11]!==l||e[12]!==h?(y=t.jsxs("div",{className:m,children:[l,h]}),e[10]=m,e[11]=l,e[12]=h,e[13]=y):y=e[13],y}function vs(n){const e=n.properties;if(!e)return[];const s=[];for(const[o,i]of Object.entries(e)){const c=i?.properties?.__type?.const;typeof c=="string"&&c.length>0&&s.push({fieldKey:o,bindingType:c})}return s}const Cs=[{fieldKey:"vtex",bindingType:"vtex"},{fieldKey:"ga4",bindingType:"google-analytics"},{fieldKey:"gsc",bindingType:"google-search-console"},{fieldKey:"github",bindingType:"github"}];function js(n,e){const s=[];if(n.length&&s.push({field:["id"],operator:"in",value:n}),e.length&&s.push({field:["name"],operator:"in",value:e}),s.length!==0)return s.length===1?s[0]:{operator:"or",conditions:s}}function se(n){const e=n;if(e.isError)throw new Error(e.content?.find(s=>s.text)?.text??"Tool call failed");return e.structuredContent??n}function _s(n,e,s,o){return{...n??{},[e]:{__type:s,value:o}}}function De(n){return n==null?!1:typeof n=="string"?n.trim().length>0:typeof n=="number"||typeof n=="boolean"?!0:Array.isArray(n)?n.some(De):typeof n=="object"?Object.entries(n).some(([e,s])=>!e.startsWith("__")&&De(s)):!1}function Ss(n){const e={accountName:"Nome da conta",appKey:"App Key",appToken:"App Token",propertyId:"Propriedade",siteUrl:"Site"};return e[n]?e[n]:n.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\b\w/g,s=>s.toUpperCase())}function Ns(n){return De(n)?typeof n=="string"?n.trim():typeof n=="number"||typeof n=="boolean"?String(n):JSON.stringify(n):null}function Es(n){return n?Object.entries(n).flatMap(([e,s])=>{if(e.startsWith("__"))return[];const o=Ns(s);return o?[{key:e,label:Ss(e),value:o}]:[]}):[]}function ws({autoOpenFieldKey:n,card:e}){return n===e.fieldKey&&e.satisfied&&!!e.linkedConnectionId}function Ts(n,e,s){const o=n.filter(i=>(i.app_name===e||!!s&&i.app_id===s)&&ns(i)===null);return o.length===0?null:(o.sort((i,r)=>{const a=c=>c.status==="active"?0:1;return a(i)!==a(r)?a(i)-a(r):(r.updated_at??"").localeCompare(i.updated_at??"")}),o[0].id)}function Os(n){return n.server?.icons?.[0]?.src??es(n.server?.repository)??null}function Is(n,e){const s=n._meta?.["mcp.mesh"];return s?.friendlyName||s?.friendly_name||n.title||n.server?.title||n.server?.name||e}function Rs(n){const e=[],s=new Map(n.connections.map(o=>[o.id,o]));for(const o of n.requirements){const i=n.curated[o.bindingType],r=i?n.itemsById[i.registryAppId]:n.itemsByName[o.bindingType];if(!r)continue;const a=n.configurationState?.[o.fieldKey]?.value,c=a?s.get(a):void 0,d=a&&c?a:null,m=d?n.connectionReadiness?.[d]!==!1:!1,l=!!d&&m,p=l?void 0:n.saBindings?.[o.bindingType],f=l||!!p,h=l?"oauth":p?"sa":null;e.push({fieldKey:o.fieldKey,bindingType:o.bindingType,registryItem:r,title:Is(r,o.bindingType),icon:Os(r),headline:i?.headline??r._meta?.["mcp.mesh"]?.short_description??null,area:i?.area??null,bullets:i?.bullets??[],satisfied:f,candidateConnectionId:f?null:d||Ts(n.connections,o.bindingType,i?.registryAppId),linkedConnectionId:d,configurationState:c?.configuration_state??null,boundVia:h,boundResource:p?.resource??null})}return e}function ks(n,e){if(!n)return null;const s=i=>{const r=i.startsWith("sc-domain:")?i.substring(10):(()=>{try{return new URL(i.startsWith("http")?i:`https://${i}`).hostname}catch{return null}})();return r===null?i:r.startsWith("www.")?r.substring(4):r},o=s(n);for(const i of e)if(s(i.siteUrl)===o)return i.siteUrl;return null}function As(n){return(n?.response?.accountSummaries??[]).map(o=>({account:o.account,options:(o.propertySummaries??[]).map(i=>({value:i.property,label:`${i.displayName} (${o.displayName})`}))}))}function it(n){const e=F.c(38);let s,o,i,r,a;e[0]!==n?({value:a,onChange:o,placeholder:i,className:s,...r}=n,e[0]=n,e[1]=s,e[2]=o,e[3]=i,e[4]=r,e[5]=a):(s=e[1],o=e[2],i=e[3],r=e[4],a=e[5]);const[c,d]=K.useState(!1),[m,l]=K.useState(!1);let p;e[6]!==a?(p=async()=>{if(a)try{await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3)}catch(I){console.error("Failed to copy text: ",I)}},e[6]=a,e[7]=p):p=e[7];const f=p;let h;e[8]!==c?(h=()=>{d(!c)},e[8]=c,e[9]=h):h=e[9];const y=h,C=c?"text":"password";let x;e[10]!==s?(x=ie("pr-20",s),e[10]=s,e[11]=x):x=e[11];let g;e[12]!==o||e[13]!==i||e[14]!==r||e[15]!==C||e[16]!==x||e[17]!==a?(g=t.jsx(be,{type:C,value:a,onChange:o,placeholder:i,className:x,...r}),e[12]=o,e[13]=i,e[14]=r,e[15]=C,e[16]=x,e[17]=a,e[18]=g):g=e[18];const u=c?"Hide password":"Show password";let v;e[19]!==c?(v=c?t.jsx(as,{size:16}):t.jsx(ls,{size:16}),e[19]=c,e[20]=v):v=e[20];let b;e[21]!==u||e[22]!==v||e[23]!==y?(b=t.jsx(B,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:y,title:u,children:v}),e[21]=u,e[22]=v,e[23]=y,e[24]=b):b=e[24];const _=!a,w=m?"Copied!":"Copy token";let S;e[25]!==m?(S=m?t.jsx(rs,{size:16}):t.jsx(St,{size:16}),e[25]=m,e[26]=S):S=e[26];let j;e[27]!==f||e[28]!==w||e[29]!==S||e[30]!==_?(j=t.jsx(B,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f,disabled:_,title:w,children:S}),e[27]=f,e[28]=w,e[29]=S,e[30]=_,e[31]=j):j=e[31];let E;e[32]!==j||e[33]!==b?(E=t.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-1 h-8",children:[b,j]}),e[32]=j,e[33]=b,e[34]=E):E=e[34];let O;return e[35]!==E||e[36]!==g?(O=t.jsxs("div",{className:"relative",children:[g,E]}),e[35]=E,e[36]=g,e[37]=O):O=e[37],O}function Qe(n){const e=F.c(19),{card:s,selfClient:o,org:i,onDone:r,onError:a}=n,c=ye();let d;e[0]!==s||e[1]!==o?(d=async x=>{const g={...s.configurationState??{},...x};await o.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:s.linkedConnectionId||s.candidateConnectionId,data:{configuration_state:g}}})},e[0]=s,e[1]=o,e[2]=d):d=e[2];let m;e[3]!==r||e[4]!==i||e[5]!==c?(m=async()=>{await c.invalidateQueries({queryKey:Y.commerceDiscoveryCompanionConnectionsPrefix(i.id)}),r()},e[3]=r,e[4]=i,e[5]=c,e[6]=m):m=e[6];let l;e[7]!==a?(l=x=>{a?.(x)},e[7]=a,e[8]=l):l=e[8];let p;e[9]!==d||e[10]!==m||e[11]!==l?(p={mutationFn:d,onSuccess:m,onError:l},e[9]=d,e[10]=m,e[11]=l,e[12]=p):p=e[12];const f=fe(p);let h;e[13]!==f?(h=x=>f.mutate(x),e[13]=f,e[14]=h):h=e[14];const y=h;let C;return e[15]!==f.error||e[16]!==f.isPending||e[17]!==y?(C={save:y,isPending:f.isPending,error:f.error},e[15]=f.error,e[16]=f.isPending,e[17]=y,e[18]=C):C=e[18],C}const Ls=_e({accountName:le().min(1,"Informe o nome da conta"),appKey:le().optional(),appToken:le().optional()});function Ps(n){const e=F.c(63),{card:s,selfClient:o,org:i,onDone:r,onIsPendingChange:a}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=Se(Ls),e[0]=c):c=e[0];const d=s.configurationState?.accountName||"",m=s.configurationState?.appKey||"",l=s.configurationState?.appToken||"";let p;e[1]!==d||e[2]!==m||e[3]!==l?(p={resolver:c,defaultValues:{accountName:d,appKey:m,appToken:l}},e[1]=d,e[2]=m,e[3]=l,e[4]=p):p=e[4];const f=Ne(p);let h;e[5]!==s.configurationState?.accountName||e[6]!==s.configurationState?.appKey||e[7]!==s.configurationState?.appToken||e[8]!==f?(h=()=>{f.reset({accountName:s.configurationState?.accountName||"",appKey:s.configurationState?.appKey||"",appToken:s.configurationState?.appToken||""})},e[5]=s.configurationState?.accountName,e[6]=s.configurationState?.appKey,e[7]=s.configurationState?.appToken,e[8]=f,e[9]=h):h=e[9];let y;e[10]!==s.configurationState||e[11]!==f?(y=[s.configurationState,f],e[10]=s.configurationState,e[11]=f,e[12]=y):y=e[12],K.useEffect(h,y);let C;e[13]!==s||e[14]!==r||e[15]!==i||e[16]!==o?(C={card:s,selfClient:o,org:i,onDone:r},e[13]=s,e[14]=r,e[15]=i,e[16]=o,e[17]=C):C=e[17];const{save:x,isPending:g,error:u}=Qe(C);let v,b;e[18]!==g||e[19]!==a?(b=()=>{a?.(g)},v=[g,a],e[18]=g,e[19]=a,e[20]=v,e[21]=b):(v=e[20],b=e[21]),K.useEffect(b,v);let _;if(e[22]!==f||e[23]!==x){let $;e[25]!==x?($=async k=>{x(k)},e[25]=x,e[26]=$):$=e[26],_=f.handleSubmit($),e[22]=f,e[23]=x,e[24]=_}else _=e[24];const w=_;let S;e[27]!==g?(S=$=>{const{field:k}=$;return t.jsxs(de,{children:[t.jsx(Oe,{children:"Nome da conta"}),t.jsx(ue,{children:t.jsx(be,{placeholder:"Nome da sua conta VTEX",...k,disabled:g})}),t.jsx(me,{})]})},e[27]=g,e[28]=S):S=e[28];let j;e[29]!==f.control||e[30]!==S?(j=t.jsx(ce,{control:f.control,name:"accountName",render:S}),e[29]=f.control,e[30]=S,e[31]=j):j=e[31];let E;e[32]!==g?(E=$=>{const{field:k}=$;return t.jsxs(de,{children:[t.jsx(Oe,{children:"App Key (opcional)"}),t.jsx(ue,{children:t.jsx(it,{placeholder:"App Key da VTEX",...k,disabled:g})}),t.jsx(me,{})]})},e[32]=g,e[33]=E):E=e[33];let O;e[34]!==f.control||e[35]!==E?(O=t.jsx(ce,{control:f.control,name:"appKey",render:E}),e[34]=f.control,e[35]=E,e[36]=O):O=e[36];let I;e[37]!==g?(I=$=>{const{field:k}=$;return t.jsxs(de,{children:[t.jsx(Oe,{children:"App Token (opcional)"}),t.jsx(ue,{children:t.jsx(it,{placeholder:"App Token da VTEX",...k,disabled:g})}),t.jsx(me,{})]})},e[37]=g,e[38]=I):I=e[38];let N;e[39]!==f.control||e[40]!==I?(N=t.jsx(ce,{control:f.control,name:"appToken",render:I}),e[39]=f.control,e[40]=I,e[41]=N):N=e[41];let A;e[42]!==f||e[43]!==j||e[44]!==O||e[45]!==N?(A=t.jsxs(Ee,{...f,children:[j,O,N]}),e[42]=f,e[43]=j,e[44]=O,e[45]=N,e[46]=A):A=e[46];let P;e[47]!==u?(P=u&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:u instanceof Error?u.message:"Não foi possível salvar a configuração"}),e[47]=u,e[48]=P):P=e[48];let L;e[49]!==g||e[50]!==r?(L=t.jsx(B,{type:"button",variant:"outline",onClick:r,disabled:g,children:"Cancelar"}),e[49]=g,e[50]=r,e[51]=L):L=e[51];const M=g?"Salvando...":"Salvar";let U;e[52]!==g||e[53]!==M?(U=t.jsx(B,{type:"submit",disabled:g,children:M}),e[52]=g,e[53]=M,e[54]=U):U=e[54];let T;e[55]!==L||e[56]!==U?(T=t.jsxs(he,{className:"pt-4",children:[L,U]}),e[55]=L,e[56]=U,e[57]=T):T=e[57];let R;return e[58]!==w||e[59]!==A||e[60]!==P||e[61]!==T?(R=t.jsxs("form",{onSubmit:w,className:"space-y-4",children:[A,P,T]}),e[58]=w,e[59]=A,e[60]=P,e[61]=T,e[62]=R):R=e[62],R}function Ge(n){const e=F.c(29),{options:s,value:o,onChange:i,disabled:r,ariaLabel:a,searchPlaceholder:c,hideSearch:d}=n,m=c===void 0?"Buscar...":c,l=d===void 0?!1:d,[p,f]=K.useState("");let h,y,C;if(e[0]!==s||e[1]!==p||e[2]!==o){const S=p.trim().toLowerCase();h=S?s.filter(j=>j.label.toLowerCase().includes(S)):s,y=h.map(zs),C=y.includes(o)?o:y[0]??"",e[0]=s,e[1]=p,e[2]=o,e[3]=h,e[4]=y,e[5]=C}else h=e[3],y=e[4],C=e[5];const x=C;let g;e[6]!==r||e[7]!==y||e[8]!==i?(g=function(j){if(r||!["ArrowDown","ArrowRight","ArrowUp","ArrowLeft","Home","End"].includes(j.key))return;j.preventDefault();const O=j.currentTarget.dataset.value,I=y.indexOf(O),N=y.length;if(N===0)return;let A;j.key==="ArrowDown"||j.key==="ArrowRight"?A=(I+1)%N:j.key==="ArrowUp"||j.key==="ArrowLeft"?A=(I-1+N)%N:j.key==="Home"?A=0:A=N-1;const P=y[A];i(P),j.currentTarget.closest('[role="radiogroup"]')?.querySelector(`[data-value="${CSS.escape(P)}"]`)?.focus()},e[6]=r,e[7]=y,e[8]=i,e[9]=g):g=e[9];const u=g;let v;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==p||e[14]!==m?(v=l?null:t.jsxs("div",{className:"relative",children:[t.jsx(jt,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),t.jsx(be,{type:"text",value:p,onChange:S=>f(S.target.value),disabled:r,placeholder:m,"aria-label":`Buscar ${a}`,className:"h-8 pl-8"})]}),e[10]=a,e[11]=r,e[12]=l,e[13]=p,e[14]=m,e[15]=v):v=e[15];let b;e[16]!==r||e[17]!==h||e[18]!==u||e[19]!==i||e[20]!==x||e[21]!==o?(b=h.length===0?t.jsx("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:"Nenhum resultado"}):h.map(S=>{const j=S.value===o;return t.jsxs("button",{type:"button",role:"radio","aria-checked":j,disabled:r,"data-value":S.value,tabIndex:S.value===x?0:-1,onClick:()=>i(S.value),onKeyDown:u,className:ie("flex w-full items-center justify-between gap-2 rounded-sm px-2 py-2 text-left text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:pointer-events-none disabled:opacity-50",j?"bg-muted font-medium text-foreground":"text-foreground hover:bg-muted/50"),children:[t.jsx("span",{className:"truncate",children:S.label}),j?t.jsx(He,{size:16,className:"shrink-0 text-primary"}):null]},S.value)}),e[16]=r,e[17]=h,e[18]=u,e[19]=i,e[20]=x,e[21]=o,e[22]=b):b=e[22];let _;e[23]!==a||e[24]!==b?(_=t.jsx("div",{role:"radiogroup","aria-label":a,className:"max-h-[280px] overflow-y-auto",children:b}),e[23]=a,e[24]=b,e[25]=_):_=e[25];let w;return e[26]!==v||e[27]!==_?(w=t.jsxs("div",{className:"space-y-2",children:[v,_]}),e[26]=v,e[27]=_,e[28]=w):w=e[28],w}function zs(n){return n.value}function Pe(n){const e=F.c(16),{label:s,iconSize:o,className:i,iconClassName:r,labelClassName:a}=n,c=o===void 0?14:o;let d;e[0]!==i?(d=ie("inline-flex items-center gap-2",i),e[0]=i,e[1]=d):d=e[1];let m;e[2]!==r?(m=ie("shrink-0 animate-spin",r),e[2]=r,e[3]=m):m=e[3];let l;e[4]!==c||e[5]!==m?(l=t.jsx(Re,{size:c,className:m}),e[4]=c,e[5]=m,e[6]=l):l=e[6];let p;e[7]!==a?(p=ie("text-sm",a),e[7]=a,e[8]=p):p=e[8];let f;e[9]!==s||e[10]!==p?(f=t.jsx("span",{className:p,children:s}),e[9]=s,e[10]=p,e[11]=f):f=e[11];let h;return e[12]!==d||e[13]!==l||e[14]!==f?(h=t.jsxs("span",{className:d,children:[l,f]}),e[12]=d,e[13]=l,e[14]=f,e[15]=h):h=e[15],h}const Us=_e({propertyId:le().min(1,"Selecione uma propriedade")});function $s(n){const e=F.c(68),{card:s,connectionId:o,companionClient:i,selfClient:r,org:a,onDone:c,onDisconnect:d,onIsPendingChange:m}=n;let l;e[0]!==o||e[1]!==a.id?(l=Y.commerceDiscoveryCompanionGaProperties(a.id,o),e[0]=o,e[1]=a.id,e[2]=l):l=e[2];let p;e[3]!==i?(p=async()=>{const D=await i.callTool({name:"get-account-summaries",arguments:{}}),V=se(D);return As(V)},e[3]=i,e[4]=p):p=e[4];let f;e[5]!==l||e[6]!==p?(f={queryKey:l,queryFn:p},e[5]=l,e[6]=p,e[7]=f):f=e[7];const h=ge(f);let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=Se(Us),e[8]=y):y=e[8];const C=s.configurationState?.propertyId||"";let x;e[9]!==C?(x={resolver:y,defaultValues:{propertyId:C}},e[9]=C,e[10]=x):x=e[10];const g=Ne(x);let u;e[11]!==s||e[12]!==c||e[13]!==a||e[14]!==r?(u={card:s,selfClient:r,org:a,onDone:c},e[11]=s,e[12]=c,e[13]=a,e[14]=r,e[15]=u):u=e[15];const{save:v,isPending:b,error:_}=Qe(u);let w,S;e[16]!==b||e[17]!==m?(w=()=>{m?.(b)},S=[b,m],e[16]=b,e[17]=m,e[18]=w,e[19]=S):(w=e[18],S=e[19]),K.useEffect(w,S);let j;if(e[20]!==g||e[21]!==v){let D;e[23]!==v?(D=async V=>{v(V)},e[23]=v,e[24]=D):D=e[24],j=g.handleSubmit(D),e[20]=g,e[21]=v,e[22]=j}else j=e[22];const E=j;if(h.isLoading){let D;return e[25]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:t.jsx(Pe,{label:"Carregando propriedades..."})}),e[25]=D):D=e[25],D}if(h.isError){let D;return e[26]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx("div",{className:"space-y-4",children:t.jsx("p",{className:"text-sm text-destructive",children:"Não foi possível carregar as propriedades do Google Analytics."})}),e[26]=D):D=e[26],D}let O;e[27]!==h.data?(O=h.data||[],e[27]=h.data,e[28]=O):O=e[28];const I=O;if(I.flatMap(Ms).length===0){let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhuma propriedade do Google Analytics foi encontrada. Conecte uma conta do Google Analytics com propriedades."}),e[29]=D):D=e[29];let V;e[30]!==d?(V=d?t.jsx("button",{type:"button",onClick:d,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive",children:"Desconectar conta"}):t.jsx("span",{}),e[30]=d,e[31]=V):V=e[31];let G;e[32]!==c?(G=t.jsx(B,{type:"button",variant:"outline",onClick:c,children:"Fechar"}),e[32]=c,e[33]=G):G=e[33];let J;return e[34]!==V||e[35]!==G?(J=t.jsxs("div",{className:"space-y-4",children:[D,t.jsxs(he,{className:"flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[V,G]})]}),e[34]=V,e[35]=G,e[36]=J):J=e[36],J}let A;e[37]!==b||e[38]!==I?(A=D=>{const{field:V}=D;return t.jsxs(de,{children:[t.jsx(ue,{children:t.jsx(Ge,{options:I.flatMap(Ds),value:V.value,onChange:V.onChange,disabled:b,ariaLabel:"Propriedade do Google Analytics"})}),t.jsx(me,{})]})},e[37]=b,e[38]=I,e[39]=A):A=e[39];let P;e[40]!==g.control||e[41]!==A?(P=t.jsx(ce,{control:g.control,name:"propertyId",render:A}),e[40]=g.control,e[41]=A,e[42]=P):P=e[42];let L;e[43]!==g||e[44]!==P?(L=t.jsx(Ee,{...g,children:P}),e[43]=g,e[44]=P,e[45]=L):L=e[45];let M;e[46]!==_?(M=_&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:_ instanceof Error?_.message:"Não foi possível salvar a configuração"}),e[46]=_,e[47]=M):M=e[47];let U;e[48]!==b||e[49]!==d?(U=d?t.jsx("button",{type:"button",onClick:d,disabled:b,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive disabled:opacity-50",children:"Desconectar conta"}):t.jsx("span",{}),e[48]=b,e[49]=d,e[50]=U):U=e[50];let T;e[51]!==b||e[52]!==c?(T=t.jsx(B,{type:"button",variant:"outline",onClick:c,disabled:b,children:"Cancelar"}),e[51]=b,e[52]=c,e[53]=T):T=e[53];const R=b?"Salvando...":"Salvar";let $;e[54]!==b||e[55]!==R?($=t.jsx(B,{type:"submit",disabled:b,children:R}),e[54]=b,e[55]=R,e[56]=$):$=e[56];let k;e[57]!==T||e[58]!==$?(k=t.jsxs("div",{className:"flex gap-2",children:[T,$]}),e[57]=T,e[58]=$,e[59]=k):k=e[59];let q;e[60]!==U||e[61]!==k?(q=t.jsxs(he,{className:"flex-col gap-2 pt-4 sm:flex-row sm:items-center sm:justify-between",children:[U,k]}),e[60]=U,e[61]=k,e[62]=q):q=e[62];let H;return e[63]!==E||e[64]!==L||e[65]!==M||e[66]!==q?(H=t.jsxs("form",{onSubmit:E,className:"space-y-4",children:[L,M,q]}),e[63]=E,e[64]=L,e[65]=M,e[66]=q,e[67]=H):H=e[67],H}function Ds(n){return n.options}function Ms(n){return n.options}const qs=_e({siteUrl:le().min(1,"Selecione um site")});function Fs(n){const e=F.c(59),{card:s,connectionId:o,companionClient:i,selfClient:r,org:a,contextSiteUrl:c,onDone:d,onIsPendingChange:m}=n;let l;e[0]!==o||e[1]!==a.id?(l=Y.commerceDiscoveryCompanionGscSites(a.id,o),e[0]=o,e[1]=a.id,e[2]=l):l=e[2];let p;e[3]!==i?(p=async()=>{const k=await i.callTool({name:"list_sites",arguments:{}});return se(k).sites||[]},e[3]=i,e[4]=p):p=e[4];let f;e[5]!==l||e[6]!==p?(f={queryKey:l,queryFn:p},e[5]=l,e[6]=p,e[7]=f):f=e[7];const h=ge(f);let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=Se(qs),e[8]=y):y=e[8];const C=s.configurationState?.siteUrl||"";let x;e[9]!==C?(x={resolver:y,defaultValues:{siteUrl:C}},e[9]=C,e[10]=x):x=e[10];const g=Ne(x);let u;e[11]!==s||e[12]!==d||e[13]!==a||e[14]!==r?(u={card:s,selfClient:r,org:a,onDone:d},e[11]=s,e[12]=d,e[13]=a,e[14]=r,e[15]=u):u=e[15];const{save:v,isPending:b,error:_}=Qe(u);let w,S;e[16]!==b||e[17]!==m?(w=()=>{m?.(b)},S=[b,m],e[16]=b,e[17]=m,e[18]=w,e[19]=S):(w=e[18],S=e[19]),K.useEffect(w,S);let j;if(e[20]!==g||e[21]!==v){let k;e[23]!==v?(k=async q=>{v(q)},e[23]=v,e[24]=k):k=e[24],j=g.handleSubmit(k),e[20]=g,e[21]=v,e[22]=j}else j=e[22];const E=j;if(h.isLoading){let k;return e[25]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:t.jsx(Pe,{label:"Carregando sites..."})}),e[25]=k):k=e[25],k}if(h.isError){let k;return e[26]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx("div",{className:"space-y-4",children:t.jsx("p",{className:"text-sm text-destructive",children:"Não foi possível carregar os sites do Google Search Console."})}),e[26]=k):k=e[26],k}let O,I;if(e[27]!==s.configurationState?.siteUrl||e[28]!==c||e[29]!==g||e[30]!==h.data){I=Symbol.for("react.early_return_sentinel");e:{if(O=h.data||[],O.length===0){let q;e[33]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx("div",{className:"space-y-4",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum site verificado foi encontrado. Verifique um site no Google Search Console."})}),e[33]=q):q=e[33],I=q;break e}const k=s.configurationState?.siteUrl;if(k&&g.getValues("siteUrl")!==k)g.setValue("siteUrl",k);else if(!k&&!g.getValues("siteUrl")){const q=ks(c,O);q&&g.setValue("siteUrl",q)}}e[27]=s.configurationState?.siteUrl,e[28]=c,e[29]=g,e[30]=h.data,e[31]=O,e[32]=I}else O=e[31],I=e[32];if(I!==Symbol.for("react.early_return_sentinel"))return I;let N;e[34]!==b||e[35]!==O?(N=k=>{const{field:q}=k;return t.jsxs(de,{children:[t.jsx(ue,{children:t.jsx(Ge,{options:O.map(Ks),value:q.value,onChange:q.onChange,disabled:b,ariaLabel:"Site verificado"})}),t.jsx(me,{})]})},e[34]=b,e[35]=O,e[36]=N):N=e[36];let A;e[37]!==g.control||e[38]!==N?(A=t.jsx(ce,{control:g.control,name:"siteUrl",render:N}),e[37]=g.control,e[38]=N,e[39]=A):A=e[39];let P;e[40]!==g||e[41]!==A?(P=t.jsx(Ee,{...g,children:A}),e[40]=g,e[41]=A,e[42]=P):P=e[42];let L;e[43]!==_?(L=_&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:_ instanceof Error?_.message:"Não foi possível salvar a configuração"}),e[43]=_,e[44]=L):L=e[44];let M;e[45]!==b||e[46]!==d?(M=t.jsx(B,{type:"button",variant:"outline",onClick:d,disabled:b,children:"Cancelar"}),e[45]=b,e[46]=d,e[47]=M):M=e[47];const U=b?"Salvando...":"Salvar";let T;e[48]!==b||e[49]!==U?(T=t.jsx(B,{type:"submit",disabled:b,children:U}),e[48]=b,e[49]=U,e[50]=T):T=e[50];let R;e[51]!==M||e[52]!==T?(R=t.jsxs(he,{className:"pt-4",children:[M,T]}),e[51]=M,e[52]=T,e[53]=R):R=e[53];let $;return e[54]!==E||e[55]!==P||e[56]!==L||e[57]!==R?($=t.jsxs("form",{onSubmit:E,className:"space-y-4",children:[P,L,R]}),e[54]=E,e[55]=P,e[56]=L,e[57]=R,e[58]=$):$=e[58],$}function Ks(n){return{value:n.siteUrl,label:n.siteUrl}}const Vs=_e({githubRepo:le().min(1,"Selecione um repositório")}),Hs=15e3,Qs=/^[\w.-]+\/[\w.-]+$/;async function Gs(n,e,s,o){const{installations:i}=await os(n,s),r=o.trim(),a=await Promise.allSettled(i.map(async l=>{const p=l.type==="User"?"user":"org",f=r?`${p}:${l.login} ${r} in:name`:`${p}:${l.login}`,y=await e.callTool({name:"search_repositories",arguments:{query:f,page:1,perPage:50}},void 0,{signal:AbortSignal.timeout(Hs)}),C=y.content?.[0]?.text;if(y.isError)throw new Error(C??"search_repositories failed");if(!C)throw new Error("empty search_repositories response");return JSON.parse(C).items??[]})),c=new Map;let d=0;for(const l of a){if(l.status==="rejected"){d+=1;continue}for(const p of l.value)p.full_name&&!c.has(p.full_name)&&c.set(p.full_name,p)}return{repos:Array.from(c.values()).sort((l,p)=>(p.updated_at??"").localeCompare(l.updated_at??"")).map(l=>l.full_name),failed:d,total:i.length}}function Bs(n){const e=F.c(80),{connectionId:s,companionClient:o,selfClient:i,org:r,onDone:a,onIsPendingChange:c}=n,d=ye();let m;e[0]!==r.id?(m=Me.COMMERCE_DISCOVERY(r.id),e[0]=r.id,e[1]=m):m=e[1];const l=m,[p,f]=K.useState(""),h=cs(p,300);let y;e[2]!==s||e[3]!==r.id?(y=Y.commerceDiscoveryCompanionGithubSelected(r.id,s),e[2]=s,e[3]=r.id,e[4]=y):y=e[4];let C;e[5]!==l||e[6]!==i?(C=async()=>{const W=await i.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:l}}),te=se(W).item?.configuration_state??null;return typeof te?.github_repo=="string"?te.github_repo:""},e[5]=l,e[6]=i,e[7]=C):C=e[7];let x;e[8]!==y||e[9]!==C?(x={queryKey:y,queryFn:C},e[8]=y,e[9]=C,e[10]=x):x=e[10];const g=ge(x);let u;e[11]!==s||e[12]!==h||e[13]!==r.id?(u=Y.commerceDiscoveryCompanionGithubRepos(r.id,s,h.trim()),e[11]=s,e[12]=h,e[13]=r.id,e[14]=u):u=e[14];let v;e[15]!==o||e[16]!==s||e[17]!==h||e[18]!==i?(v=()=>Gs(W=>i.callTool(W),o,s,h),e[15]=o,e[16]=s,e[17]=h,e[18]=i,e[19]=v):v=e[19];let b;e[20]!==u||e[21]!==v?(b={queryKey:u,queryFn:v},e[20]=u,e[21]=v,e[22]=b):b=e[22];const _=ge(b);let w;e[23]===Symbol.for("react.memo_cache_sentinel")?(w={resolver:Se(Vs),defaultValues:{githubRepo:""}},e[23]=w):w=e[23];const S=Ne(w);let j;e[24]!==l||e[25]!==i?(j=async W=>{const te=await i.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:l}}),kt={...se(te).item?.configuration_state??null??{},github_repo:W};await i.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:l,data:{configuration_state:kt}}})},e[24]=l,e[25]=i,e[26]=j):j=e[26];let E;e[27]!==l||e[28]!==a||e[29]!==r.id||e[30]!==d?(E=async()=>{await d.invalidateQueries({queryKey:Y.commerceDiscoveryConnection(r.id,l)}),await d.invalidateQueries({queryKey:Y.commerceDiscoveryCompanionConnectionsPrefix(r.id)}),a()},e[27]=l,e[28]=a,e[29]=r.id,e[30]=d,e[31]=E):E=e[31];let O;e[32]!==E||e[33]!==j?(O={mutationFn:j,onSuccess:E},e[32]=E,e[33]=j,e[34]=O):O=e[34];const I=fe(O),N=I.isPending;let A,P;e[35]!==N||e[36]!==c?(A=()=>{c?.(N)},P=[N,c],e[35]=N,e[36]=c,e[37]=A,e[38]=P):(A=e[37],P=e[38]),K.useEffect(A,P);let L;if(e[39]!==S||e[40]!==I){let W;e[42]!==I?(W=async te=>{I.mutate(te.githubRepo)},e[42]=I,e[43]=W):W=e[43],L=S.handleSubmit(W),e[39]=S,e[40]=I,e[41]=L}else L=e[41];const M=L,U=g.data??"";U&&S.getValues("githubRepo")!==U&&S.setValue("githubRepo",U);let T,R,$;if(e[44]!==h||e[45]!==_.data?.failed||e[46]!==_.data?.repos||e[47]!==_.data?.total||e[48]!==U){const W=_.data?.repos??[];T=_.data?.failed??0,$=_.data?.total??0;const te=h.trim();R=[...W],te&&Qs.test(te)&&!R.includes(te)&&R.unshift(te),U&&!R.includes(U)&&R.push(U),e[44]=h,e[45]=_.data?.failed,e[46]=_.data?.repos,e[47]=_.data?.total,e[48]=U,e[49]=T,e[50]=R,e[51]=$}else T=e[49],R=e[50],$=e[51];const k=$>0&&T===$,q=_.isError||k?"Não foi possível buscar os repositórios (erro ou tempo esgotado). Tente novamente ou digite o repositório no formato owner/nome.":T>0?"Parte da busca falhou — alguns repositórios podem não ter aparecido. Tente novamente ou digite owner/nome.":null;let H;e[52]===Symbol.for("react.memo_cache_sentinel")?(H=t.jsx(jt,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),e[52]=H):H=e[52];let D;e[53]===Symbol.for("react.memo_cache_sentinel")?(D=W=>f(W.target.value),e[53]=D):D=e[53];let V;e[54]!==N||e[55]!==p?(V=t.jsxs("div",{className:"relative",children:[H,t.jsx(be,{type:"text",value:p,onChange:D,disabled:N,placeholder:"Buscar repositório (ex: deco-sites/fila-store)","aria-label":"Buscar repositório",className:"h-8 pl-8"})]}),e[54]=N,e[55]=p,e[56]=V):V=e[56];let G;e[57]!==S||e[58]!==N||e[59]!==R||e[60]!==_.isLoading||e[61]!==q?(G=_.isLoading?t.jsx("div",{className:"flex min-h-[160px] items-center justify-center",children:t.jsx(Pe,{label:"Carregando repositórios..."})}):t.jsxs(t.Fragment,{children:[q&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:q}),R.length===0?!q&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum repositório encontrado. Digite o nome do repositório (owner/nome) para buscar."}):t.jsx(Ee,{...S,children:t.jsx(ce,{control:S.control,name:"githubRepo",render:W=>{const{field:te}=W;return t.jsxs(de,{children:[t.jsx(ue,{children:t.jsx(Ge,{options:R.map(Ws),value:te.value,onChange:te.onChange,disabled:N,ariaLabel:"Repositório",hideSearch:!0})}),t.jsx(me,{})]})}})})]}),e[57]=S,e[58]=N,e[59]=R,e[60]=_.isLoading,e[61]=q,e[62]=G):G=e[62];let J;e[63]!==I.error?(J=I.error&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:I.error instanceof Error?I.error.message:"Não foi possível salvar a configuração"}),e[63]=I.error,e[64]=J):J=e[64];let X;e[65]!==N||e[66]!==a?(X=t.jsx(B,{type:"button",variant:"outline",onClick:a,disabled:N,children:"Cancelar"}),e[65]=N,e[66]=a,e[67]=X):X=e[67];const oe=N?"Salvando...":"Salvar";let Q;e[68]!==N||e[69]!==oe?(Q=t.jsx(B,{type:"submit",disabled:N,children:oe}),e[68]=N,e[69]=oe,e[70]=Q):Q=e[70];let z;e[71]!==X||e[72]!==Q?(z=t.jsxs(he,{className:"pt-4",children:[X,Q]}),e[71]=X,e[72]=Q,e[73]=z):z=e[73];let ee;return e[74]!==M||e[75]!==V||e[76]!==G||e[77]!==J||e[78]!==z?(ee=t.jsxs("form",{onSubmit:M,className:"space-y-4",children:[V,G,J,z]}),e[74]=M,e[75]=V,e[76]=G,e[77]=J,e[78]=z,e[79]=ee):ee=e[79],ee}function Ws(n){return{value:n,label:n}}const Ys={vtex:Ps,"google-analytics":$s,"google-search-console":Fs,github:Bs},xe="deco-reader@decocms.iam.gserviceaccount.com",Et={"google-analytics":"ga4","google-search-console":"gsc"},wt={ga4:{label:"Google Analytics",resourceLabel:"ID da propriedade",resourcePlaceholder:"ex: 123456789",resourceHint:"No GA4: Admin → Detalhes da propriedade → ID da propriedade (só números).",connectSteps:["Abra o Google Analytics (GA4) da sua loja.","Vá em Admin → Acesso à propriedade (Gerenciamento de acesso).",`Clique em + → Adicionar usuários, cole ${xe} e conceda o papel Leitor.`,"Copie o ID da propriedade (Admin → Detalhes da propriedade) e cole abaixo."]},gsc:{label:"Google Search Console",resourceLabel:"Site / propriedade",resourcePlaceholder:"ex: sc-domain:sualoja.com.br",resourceHint:"Use o mesmo formato que aparece no Search Console: sc-domain:sualoja.com.br ou https://www.sualoja.com.br/.",connectSteps:["Abra o Google Search Console da sua loja.","Vá em Configurações → Usuários e permissões.",`Clique em Adicionar usuário, cole ${xe} e escolha permissão Completa.`,"Copie o endereço do site como aparece no seletor de propriedades e cole abaixo."]}};function Js(n,e){const s=wt[n].label;switch(e){case"no-access":return{title:`Ainda não conseguimos acessar este recurso no ${s}.`,steps:n==="ga4"?[`Confirme que ${xe} foi adicionado em Admin → Acesso à propriedade com o papel Leitor.`,"Confira se o ID da propriedade está correto (só números, sem o prefixo 'properties/').","A concessão de acesso pode levar alguns segundos — tente novamente."]:[`Confirme que ${xe} foi adicionado em Configurações → Usuários e permissões.`,"A permissão precisa ser Completa ou Restrita — 'Não verificado' não funciona.","Confira se o endereço do site está exatamente como aparece no Search Console."]};case"no-web-stream":return{title:"Esta propriedade do GA4 não tem um fluxo de dados da Web (site) configurado.",steps:["No GA4, vá em Admin → Fluxos de dados.","Clique em Adicionar fluxo → Web.","Informe a URL do site da sua loja e salve o fluxo.","Volte aqui e tente vincular de novo. (Propriedades só de app precisam de vínculo manual — fale com o suporte.)"]};case"no-match":return{title:"O recurso informado não corresponde ao domínio desta loja.",steps:n==="ga4"?["Verifique se digitou o ID da propriedade certa — provavelmente é de outro site.","No GA4, o site medido aparece em Admin → Fluxos de dados → (seu fluxo Web) → URL do stream."]:["Verifique se selecionou a propriedade do Search Console referente a esta loja.","O endereço precisa cobrir o mesmo domínio do diagnóstico."]};case"resource_already_bound":return{title:"Este recurso já está vinculado a outra loja.",steps:["Se este recurso é realmente desta loja, fale com o suporte para uma revisão manual.","Caso tenha digitado o id errado, confira e tente novamente."]};default:return{title:"Não foi possível verificar o acesso a este recurso.",steps:["Revise os passos de acesso acima e tente novamente.","Se persistir, fale com o suporte."]}}}function Zs(n){const e=F.c(76),{provider:s,siteUrl:o,selfClient:i,org:r,initialResourceId:a,onDone:c,onIsPendingChange:d,onOAuthInstead:m}=n,l=wt[s],p=ye(),[f,h]=K.useState(null);let y,C;if(e[0]!==l.resourceLabel){const Q=_e({resourceId:le().trim().min(1,`Informe o ${l.resourceLabel.toLowerCase()}`)});C=Ne,y=Se(Q),e[0]=l.resourceLabel,e[1]=y,e[2]=C}else y=e[1],C=e[2];const x=a??"";let g;e[3]!==x?(g={resourceId:x},e[3]=x,e[4]=g):g=e[4];let u;e[5]!==y||e[6]!==g?(u={resolver:y,defaultValues:g},e[5]=y,e[6]=g,e[7]=u):u=e[7];const v=C(u);let b;e[8]!==s||e[9]!==i||e[10]!==o?(b=async Q=>{if(!o)throw new Error("URL da loja indisponível — recarregue a página.");const z=await i.callTool({name:"COMMERCE_DISCOVERY_BIND",arguments:{siteUrl:o,provider:s,resourceId:Q.resourceId}});return se(z)},e[8]=s,e[9]=i,e[10]=o,e[11]=b):b=e[11];let _,w;e[12]!==d?(_=()=>d?.(!0),w=()=>d?.(!1),e[12]=d,e[13]=_,e[14]=w):(_=e[13],w=e[14]);let S;e[15]!==l.label||e[16]!==c||e[17]!==r||e[18]!==s||e[19]!==p||e[20]!==o?(S=async Q=>{if(Q.ok){h(null),ke.success(`${l.label} conectado`),o&&await p.invalidateQueries({queryKey:Y.commerceDiscoveryConnectionStatus(r.id,o)}),c();return}h({...Js(s,Q.reason??"unknown"),detail:Q.detail})},e[15]=l.label,e[16]=c,e[17]=r,e[18]=s,e[19]=p,e[20]=o,e[21]=S):S=e[21];let j;e[22]!==b||e[23]!==_||e[24]!==w||e[25]!==S?(j={mutationFn:b,onMutate:_,onSettled:w,onSuccess:S},e[22]=b,e[23]=_,e[24]=w,e[25]=S,e[26]=j):j=e[26];const E=fe(j);let O;if(e[27]!==v||e[28]!==E){let Q;e[30]!==E?(Q=z=>E.mutate(z),e[30]=E,e[31]=Q):Q=e[31],O=v.handleSubmit(Q),e[27]=v,e[28]=E,e[29]=O}else O=e[29];const I=O,N=E.isPending,A=tn;let P;e[32]!==l.connectSteps?(P=l.connectSteps.map(en),e[32]=l.connectSteps,e[33]=P):P=e[33];let L;e[34]!==P?(L=t.jsx("ol",{className:"space-y-2 text-sm text-muted-foreground",children:P}),e[34]=P,e[35]=L):L=e[35];let M;e[36]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx("code",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:xe}),e[36]=M):M=e[36];let U;e[37]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted/40 p-2",children:[M,t.jsx(B,{type:"button",variant:"ghost",size:"icon-sm",onClick:A,"aria-label":"Copiar e-mail do service account",children:t.jsx(St,{size:16})})]}),e[37]=U):U=e[37];let T;e[38]!==l.resourceHint||e[39]!==l.resourceLabel||e[40]!==l.resourcePlaceholder||e[41]!==N?(T=Q=>{const{field:z}=Q;return t.jsxs(de,{children:[t.jsx(Oe,{children:l.resourceLabel}),t.jsx(ue,{children:t.jsx(be,{...z,placeholder:l.resourcePlaceholder,disabled:N,autoComplete:"off"})}),t.jsx(is,{children:l.resourceHint}),t.jsx(me,{})]})},e[38]=l.resourceHint,e[39]=l.resourceLabel,e[40]=l.resourcePlaceholder,e[41]=N,e[42]=T):T=e[42];let R;e[43]!==v.control||e[44]!==T?(R=t.jsx(ce,{control:v.control,name:"resourceId",render:T}),e[43]=v.control,e[44]=T,e[45]=R):R=e[45];let $;e[46]!==v||e[47]!==R?($=t.jsx(Ee,{...v,children:R}),e[46]=v,e[47]=R,e[48]=$):$=e[48];let k;e[49]!==f?(k=f&&t.jsxs("div",{role:"alert",className:"space-y-2 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:f.title}),t.jsx("ol",{className:"space-y-1 text-sm text-muted-foreground",children:f.steps.map(Xs)})]}),e[49]=f,e[50]=k):k=e[50];let q;e[51]!==E.error||e[52]!==E.isError?(q=E.isError&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:E.error instanceof Error?E.error.message:"Não foi possível vincular."}),e[51]=E.error,e[52]=E.isError,e[53]=q):q=e[53];let H;e[54]!==N||e[55]!==m?(H=m?t.jsx("button",{type:"button",onClick:m,disabled:N,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:opacity-50",children:"autorizar via login do Google"}):t.jsx("span",{}),e[54]=N,e[55]=m,e[56]=H):H=e[56];let D;e[57]!==N||e[58]!==c?(D=t.jsx(B,{type:"button",variant:"outline",onClick:c,disabled:N,children:"Cancelar"}),e[57]=N,e[58]=c,e[59]=D):D=e[59];const V=N?"Verificando...":"Vincular";let G;e[60]!==N||e[61]!==V?(G=t.jsx(B,{type:"submit",disabled:N,children:V}),e[60]=N,e[61]=V,e[62]=G):G=e[62];let J;e[63]!==D||e[64]!==G?(J=t.jsxs("div",{className:"flex gap-2",children:[D,G]}),e[63]=D,e[64]=G,e[65]=J):J=e[65];let X;e[66]!==H||e[67]!==J?(X=t.jsxs(he,{className:"flex-col gap-2 pt-2 sm:flex-row sm:items-center sm:justify-between",children:[H,J]}),e[66]=H,e[67]=J,e[68]=X):X=e[68];let oe;return e[69]!==I||e[70]!==L||e[71]!==$||e[72]!==k||e[73]!==q||e[74]!==X?(oe=t.jsxs("form",{onSubmit:I,className:"space-y-4",children:[L,U,$,k,q,X]}),e[69]=I,e[70]=L,e[71]=$,e[72]=k,e[73]=q,e[74]=X,e[75]=oe):oe=e[75],oe}function Xs(n){return t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{"aria-hidden":!0,children:"•"}),t.jsx("span",{children:n})]},n)}function en(n,e){return t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium text-foreground",children:e+1}),t.jsx("span",{children:n})]},n)}function tn(){navigator.clipboard?.writeText(xe),ke.success("E-mail copiado")}function sn(){const n=F.c(2);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("div",{className:"size-9 shrink-0 animate-pulse rounded-lg bg-muted/60"}),n[0]=e):e=n[0];let s;return n[1]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border bg-card p-4 sm:h-full sm:flex-col sm:items-stretch",children:[e,t.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[t.jsx("div",{className:"h-4 w-24 animate-pulse rounded bg-muted/60"}),t.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-muted/60"})]}),t.jsx("div",{className:"h-8 w-20 shrink-0 animate-pulse rounded-lg bg-muted/60 sm:mt-auto sm:w-full"})]}),n[1]=s):s=n[1],s}const rt="rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground";function nn(n){const e=F.c(39),{card:s,connecting:o,disconnecting:i,disabled:r,onConnect:a,onDisconnect:c,org:d,selfClient:m,siteUrl:l,autoOpenConfigFieldKey:p,onAutoOpenConfigHandled:f}=n,h=s.linkedConnectionId,y=Et[s.bindingType],C=!!y&&s.boundVia!=="oauth";let x;e[0]!==p||e[1]!==s||e[2]!==o||e[3]!==r||e[4]!==i||e[5]!==h||e[6]!==f||e[7]!==a||e[8]!==c||e[9]!==d||e[10]!==y||e[11]!==m||e[12]!==l||e[13]!==C?(x=C&&y?t.jsx(on,{card:s,provider:y,org:d,selfClient:m,siteUrl:l,onOAuthInstead:a,disabled:r,connecting:o}):s.satisfied&&h?t.jsxs("div",{className:"flex items-center justify-end gap-1 sm:justify-start",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[t.jsx(He,{size:16,className:"text-success"})," Conectado"]}),t.jsx(K.Suspense,{fallback:t.jsx(rn,{}),children:t.jsx(an,{card:s,org:d,selfClient:m,connectionId:h,contextSiteUrl:l,autoOpen:ws({autoOpenFieldKey:p,card:s}),onAutoOpenHandled:f})}),t.jsxs(Fe,{children:[t.jsx(Ke,{asChild:!0,children:t.jsx(B,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:r||i,onClick:c,"aria-label":`Desconectar ${s.title}`,children:i?t.jsx(Re,{size:16,className:"animate-spin"}):t.jsx(Xt,{size:16})})}),t.jsx(Ve,{children:"Desconectar"})]})]}):t.jsx(B,{type:"button",variant:"outline",size:"sm",className:"sm:w-full",disabled:r||o,onClick:a,"aria-label":`Conectar ${s.title}`,children:o?t.jsx(Re,{size:16,className:"animate-spin"}):"Conectar"}),e[0]=p,e[1]=s,e[2]=o,e[3]=r,e[4]=i,e[5]=h,e[6]=f,e[7]=a,e[8]=c,e[9]=d,e[10]=y,e[11]=m,e[12]=l,e[13]=C,e[14]=x):x=e[14];const g=x;let u;e[15]!==s.icon||e[16]!==s.title?(u=t.jsx(qe,{icon:s.icon,name:s.title,size:"sm",fit:"contain",className:"shrink-0 p-1.5"}),e[15]=s.icon,e[16]=s.title,e[17]=u):u=e[17];let v;e[18]!==s.area?(v=s.area&&t.jsx("span",{className:ie("hidden sm:inline-block",rt),children:s.area}),e[18]=s.area,e[19]=v):v=e[19];let b;e[20]!==u||e[21]!==v?(b=t.jsxs("div",{className:"shrink-0 self-start sm:flex sm:w-full sm:items-center sm:justify-between sm:gap-2",children:[u,v]}),e[20]=u,e[21]=v,e[22]=b):b=e[22];let _;e[23]!==s.area?(_=s.area&&t.jsx("span",{className:ie("mb-1 inline-block sm:hidden",rt),children:s.area}),e[23]=s.area,e[24]=_):_=e[24];let w;e[25]!==s.title?(w=t.jsx("p",{className:"text-sm font-medium text-foreground",children:s.title}),e[25]=s.title,e[26]=w):w=e[26];let S;e[27]!==s.headline?(S=s.headline&&t.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm leading-5 text-muted-foreground",children:s.headline}),e[27]=s.headline,e[28]=S):S=e[28];let j;e[29]!==_||e[30]!==w||e[31]!==S?(j=t.jsxs("div",{className:"min-w-0 flex-1",children:[_,w,S]}),e[29]=_,e[30]=w,e[31]=S,e[32]=j):j=e[32];let E;e[33]!==g?(E=t.jsx("div",{className:"shrink-0 sm:mt-auto sm:w-full sm:pt-1",children:g}),e[33]=g,e[34]=E):E=e[34];let O;return e[35]!==b||e[36]!==j||e[37]!==E?(O=t.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border bg-card p-4 sm:h-full sm:flex-col sm:items-stretch",children:[b,j,E]}),e[35]=b,e[36]=j,e[37]=E,e[38]=O):O=e[38],O}function on(n){const e=F.c(39),{card:s,provider:o,org:i,selfClient:r,siteUrl:a,onOAuthInstead:c,disabled:d,connecting:m}=n,[l,p]=K.useState(!1),[f,h]=K.useState(!1);let y;e[0]!==f?(y=A=>{!A&&f||p(A)},e[0]=f,e[1]=y):y=e[1];const C=y;let x;e[2]!==s.satisfied||e[3]!==s.title||e[4]!==m||e[5]!==d?(x=s.satisfied?t.jsxs("div",{className:"flex items-center justify-end gap-1 sm:justify-start",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[t.jsx(He,{size:16,className:"text-success"})," Conectado"]}),t.jsxs(Fe,{children:[t.jsx(Ke,{asChild:!0,children:t.jsx(B,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:()=>p(!0),"aria-label":`Configurar ${s.title}`,children:t.jsx(_t,{size:16})})}),t.jsx(Ve,{children:"Editar configuração"})]})]}):t.jsx(B,{type:"button",variant:"outline",size:"sm",className:"sm:w-full",disabled:d||m,onClick:()=>p(!0),"aria-label":`Conectar ${s.title}`,children:m?t.jsx(Re,{size:16,className:"animate-spin"}):"Conectar"}),e[2]=s.satisfied,e[3]=s.title,e[4]=m,e[5]=d,e[6]=x):x=e[6];let g;e[7]!==s.icon||e[8]!==s.title?(g=t.jsx(qe,{icon:s.icon,name:s.title,size:"md",fit:"contain",className:"p-1.5"}),e[7]=s.icon,e[8]=s.title,e[9]=g):g=e[9];let u;e[10]!==s.title?(u=t.jsx(xt,{children:s.title}),e[10]=s.title,e[11]=u):u=e[11];let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(yt,{children:"Conceda acesso ao nosso leitor e informe o identificador"}),e[12]=v):v=e[12];let b;e[13]!==u?(b=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[u,v]}),e[13]=u,e[14]=b):b=e[14];let _;e[15]!==g||e[16]!==b?(_=t.jsxs(bt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[g,b]}),e[15]=g,e[16]=b,e[17]=_):_=e[17];const w=s.boundResource??void 0;let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=()=>p(!1),e[18]=S):S=e[18];let j;e[19]!==s.satisfied||e[20]!==c?(j=s.satisfied?void 0:()=>{p(!1),c()},e[19]=s.satisfied,e[20]=c,e[21]=j):j=e[21];let E;e[22]!==i||e[23]!==o||e[24]!==r||e[25]!==a||e[26]!==j||e[27]!==w?(E=t.jsx(Zs,{provider:o,siteUrl:a,selfClient:r,org:i,initialResourceId:w,onDone:S,onIsPendingChange:h,onOAuthInstead:j}),e[22]=i,e[23]=o,e[24]=r,e[25]=a,e[26]=j,e[27]=w,e[28]=E):E=e[28];let O;e[29]!==E||e[30]!==_?(O=t.jsxs(vt,{className:"sm:max-w-lg",children:[_,E]}),e[29]=E,e[30]=_,e[31]=O):O=e[31];let I;e[32]!==C||e[33]!==l||e[34]!==O?(I=t.jsx(Ct,{open:l,onOpenChange:C,children:O}),e[32]=C,e[33]=l,e[34]=O,e[35]=I):I=e[35];let N;return e[36]!==I||e[37]!==x?(N=t.jsxs(t.Fragment,{children:[x,I]}),e[36]=I,e[37]=x,e[38]=N):N=e[38],N}function rn(){const n=F.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("div",{className:"size-8 shrink-0 animate-pulse rounded-lg bg-muted/60"}),n[0]=e):e=n[0],e}function an(n){const e=F.c(60),{card:s,org:o,selfClient:i,connectionId:r,contextSiteUrl:a,autoOpen:c,onAutoOpenHandled:d}=n;let m;e[0]!==r||e[1]!==o.id||e[2]!==o.slug?(m={connectionId:r,orgId:o.id,orgSlug:o.slug},e[0]=r,e[1]=o.id,e[2]=o.slug,e[3]=m):m=e[3];const l=Le(m),[p,f]=K.useState(c),[h,y]=K.useState(!1),C=ye(),x=Ys[s.bindingType],g=Es(s.configurationState);let u;e[4]!==c||e[5]!==d?(u=()=>{f(!1),c&&d()},e[4]=c,e[5]=d,e[6]=u):u=e[6];const v=u;let b;e[7]!==v||e[8]!==h?(b=V=>{if(!(!V&&h)){if(!V){v();return}f(!0)}},e[7]=v,e[8]=h,e[9]=b):b=e[9];const _=b;let w;e[10]!==r||e[11]!==i?(w=async()=>{await i.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:r,force:!0}})},e[10]=r,e[11]=i,e[12]=w):w=e[12];let S;e[13]!==s.title||e[14]!==v||e[15]!==o.id||e[16]!==C?(S=async()=>{await C.invalidateQueries({queryKey:Y.commerceDiscoveryCompanionConnectionsPrefix(o.id)}),ke.success(`${s.title} desconectado`),v()},e[13]=s.title,e[14]=v,e[15]=o.id,e[16]=C,e[17]=S):S=e[17];let j;e[18]!==w||e[19]!==S?(j={mutationFn:w,onSuccess:S,onError:ln},e[18]=w,e[19]=S,e[20]=j):j=e[20];const E=fe(j);if(!x)return null;let O;e[21]===Symbol.for("react.memo_cache_sentinel")?(O=()=>f(!0),e[21]=O):O=e[21];const I=`Configurar ${s.title}`;let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(_t,{size:16}),e[22]=N):N=e[22];let A;e[23]!==I?(A=t.jsx(Ke,{asChild:!0,children:t.jsx(B,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:O,"aria-label":I,children:N})}),e[23]=I,e[24]=A):A=e[24];const P=g.length>0?"Editar configuração":"Configurar";let L;e[25]!==P?(L=t.jsx(Ve,{children:P}),e[25]=P,e[26]=L):L=e[26];let M;e[27]!==A||e[28]!==L?(M=t.jsxs(Fe,{children:[A,L]}),e[27]=A,e[28]=L,e[29]=M):M=e[29];let U;e[30]!==s.icon||e[31]!==s.title?(U=t.jsx(qe,{icon:s.icon,name:s.title,size:"md",fit:"contain",className:"p-1.5"}),e[30]=s.icon,e[31]=s.title,e[32]=U):U=e[32];let T;e[33]!==s.title?(T=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[t.jsx(xt,{children:s.title}),t.jsxs(yt,{children:["Configure o ",s.title," para enriquecer os dados"]})]}),e[33]=s.title,e[34]=T):T=e[34];let R;e[35]!==U||e[36]!==T?(R=t.jsxs(bt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[U,T]}),e[35]=U,e[36]=T,e[37]=R):R=e[37];let $;e[38]!==E?($=()=>E.mutate(),e[38]=E,e[39]=$):$=e[39];let k;e[40]!==x||e[41]!==s||e[42]!==v||e[43]!==l||e[44]!==r||e[45]!==a||e[46]!==o||e[47]!==i||e[48]!==$?(k=t.jsx(x,{card:s,connectionId:r,companionClient:l,selfClient:i,org:o,contextSiteUrl:a,onDone:v,onDisconnect:$,onIsPendingChange:y}),e[40]=x,e[41]=s,e[42]=v,e[43]=l,e[44]=r,e[45]=a,e[46]=o,e[47]=i,e[48]=$,e[49]=k):k=e[49];let q;e[50]!==R||e[51]!==k?(q=t.jsxs(vt,{className:"sm:max-w-lg",children:[R,k]}),e[50]=R,e[51]=k,e[52]=q):q=e[52];let H;e[53]!==p||e[54]!==_||e[55]!==q?(H=t.jsx(Ct,{open:p,onOpenChange:_,children:q}),e[53]=p,e[54]=_,e[55]=q,e[56]=H):H=e[56];let D;return e[57]!==M||e[58]!==H?(D=t.jsxs(t.Fragment,{children:[M,H]}),e[57]=M,e[58]=H,e[59]=D):D=e[59],D}function ln(){ke.error("Não foi possível desconectar. Tente novamente.")}const Be={vtex:{registryAppId:"deco/vtex",area:"Catálogo",headline:"Rupturas e PDPs que travam suas vendas."},"google-analytics":{registryAppId:"deco/google-analytics",area:"Funil",headline:"Onde a receita vaza no seu funil."},"google-search-console":{registryAppId:"deco/google-search-console",area:"Busca",headline:"O tráfego de busca que você deixa na mesa."},github:{registryAppId:"deco/mcp-github",area:"Engenharia",headline:"A saúde da entrega de código por trás da sua loja."}};function cn(n){const e=F.c(40),{selfClient:s,org:o,cdConnectionId:i,siteUrl:r}=n;let a;e[0]!==i||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:i,orgId:o.id,orgSlug:o.slug},e[0]=i,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const c=Le(a);let d;e[4]!==i||e[5]!==o.id?(d=Y.commerceDiscoveryCompanionSchema(o.id,i),e[4]=i,e[5]=o.id,e[6]=d):d=e[6];let m;e[7]!==c?(m=async()=>{const z=await c.callTool({name:"MCP_CONFIGURATION",arguments:{}});return se(z)},e[7]=c,e[8]=m):m=e[8];let l;e[9]!==d||e[10]!==m?(l={queryKey:d,queryFn:m,retry:!1},e[9]=d,e[10]=m,e[11]=l):l=e[11];const p=ge(l),f=p.data?.stateSchema?vs(p.data.stateSchema):null,h=f&&f.length>0?f:Cs,y=h.map(bn),C=h.map(yn).filter(xn),x=h.filter(hn).map(gn),g=[...C,...x].sort().join(",");let u;e[12]!==i||e[13]!==o.id?(u=Y.commerceDiscoveryConnection(o.id,i),e[12]=i,e[13]=o.id,e[14]=u):u=e[14];let v;e[15]!==i||e[16]!==s?(v=async()=>{const z=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:i}});return se(z)},e[15]=i,e[16]=s,e[17]=v):v=e[17];let b;e[18]!==u||e[19]!==v?(b={queryKey:u,queryFn:v},e[18]=u,e[19]=v,e[20]=b):b=e[20];const w=ve(b).data?.item?.configuration_state??null;let S;e[21]!==w?(S=z=>w?.[z.fieldKey]?.value,e[21]=w,e[22]=S):S=e[22];const j=h.map(S).filter(pn),E=[...y.map(fn),...C.map(mn),...j.map(un)].sort().join(","),I=ve({queryKey:Y.commerceDiscoveryCompanionConnections(o.id,E),queryFn:async()=>{if(h.length===0)return{items:[]};const z=[{field:["app_name"],operator:"in",value:y},{field:["app_id"],operator:"in",value:C}];j.length>0&&z.push({field:["id"],operator:"in",value:j});const ee=await s.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{operator:"or",conditions:z},limit:1e3}});return se(ee)}}).data?.items??[],N=new Set(j),A=I.filter(z=>N.has(z.id)),P=A.filter(dn);let L;e[23]!==o.id||e[24]!==o.slug?(L=z=>({queryKey:Y.commerceDiscoveryCompanionOAuthStatus(o.id,z.id),queryFn:async()=>{try{const ee=await fetch(`/api/${encodeURIComponent(o.slug)}/connections/${encodeURIComponent(z.id)}/oauth-token/status`,{credentials:"include"});return ee.ok?{hasToken:(await ee.json()).hasToken===!0}:{hasToken:!1}}catch{return{hasToken:!1}}},retry:!1}),e[23]=o.id,e[24]=o.slug,e[25]=L):L=e[25];const M=ps({queries:P.map(L)});let U;e[26]!==M?(U=(z,ee)=>[z.id,M[ee]?.data?.hasToken===!0],e[26]=M,e[27]=U):U=e[27];const T=new Map(P.map(U)),R={};for(const z of A)R[z.id]=!z.oauth_config||!!z.connection_token||T.get(z.id)===!0;const $=ve({queryKey:Y.commerceDiscoveryCompanionRegistry(o.id,g),queryFn:async()=>{if(h.length===0)return{items:[]};const z=js(C,x),ee=await ts(Me.REGISTRY(o.id),o.id,o.slug,"COLLECTION_REGISTRY_APP_LIST",{...z?{where:z}:{},limit:1e3});return se(ee)}}),k={},q={};for(const z of $.data?.items??[])k[z.id]=z,z.server?.name&&(q[z.server.name]=z);let H;e[28]!==o.id||e[29]!==r?(H=Y.commerceDiscoveryConnectionStatus(o.id,r??""),e[28]=o.id,e[29]=r,e[30]=H):H=e[30];const D=!!r;let V;e[31]!==s||e[32]!==r?(V=async()=>{const z=await s.callTool({name:"COMMERCE_DISCOVERY_CONNECTION_STATUS",arguments:{siteUrl:r}});return se(z)},e[31]=s,e[32]=r,e[33]=V):V=e[33];let G;e[34]!==H||e[35]!==D||e[36]!==V?(G={queryKey:H,enabled:D,queryFn:V},e[34]=H,e[35]=D,e[36]=V,e[37]=G):G=e[37];const J=ge(G),X={};for(const[z,ee]of Object.entries(Et)){const W=J.data?.providers?.[ee];W?.connected&&W.via==="sa"&&(X[z]={resource:W.resource??null})}const oe=Rs({requirements:h,itemsById:k,itemsByName:q,connections:I,connectionReadiness:R,configurationState:w,curated:Be,saBindings:X});let Q;return e[38]!==oe?(Q={cards:oe},e[38]=oe,e[39]=Q):Q=e[39],Q}function dn(n){return n.oauth_config&&!n.connection_token}function un(n){return`linked:${n}`}function mn(n){return`app:${n}`}function fn(n){return`binding:${n}`}function pn(n){return typeof n=="string"&&n.length>0}function gn(n){return n.bindingType}function hn(n){return!Be[n.bindingType]}function xn(n){return!!n}function yn(n){return Be[n.bindingType]?.registryAppId}function bn(n){return n.bindingType}function vn({selfClient:n,org:e,userId:s,cdConnectionId:o,domain:i,siteUrl:r}){const a=ye(),[c,d]=K.useState(null),[m,l]=K.useState(null),[p,f]=K.useState(null),h=async(x,g)=>{const u=await n.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:x,data:g}});return se(u)};async function y(x){d(x.fieldKey),f(null);const g={app_name:x.title,field_key:x.fieldKey,organization_id:e.id,domain:i,site_url:r};Z("commerce_onboarding_companion_connect_clicked",g);try{let u=x.candidateConnectionId;if(!u){const j=ss(x.registryItem,e.id,s,{remoteIndex:0}),E=j.connection_type==="STDIO",O=!!j.connection_url,I=E&&j.connection_headers&&typeof j.connection_headers=="object"&&"command"in j.connection_headers;if(!O&&!I)return Z("commerce_onboarding_companion_connect_failed",{...g,error:"no_connection_method"}),f(`${x.title} cannot be connected: no connection method available`),!1;const N=await n.callTool({name:"COLLECTION_CONNECTIONS_CREATE",arguments:{data:j}});u=se(N).item.id}const v=u,b=await ds({connectionId:v,orgId:e.id,orgSlug:e.slug,persistFallback:j=>h(v,{connection_token:j}).then(()=>{})});if(!b.ok)return Z("commerce_onboarding_companion_connect_failed",{...g,error:b.error}),f(`Couldn't sign in to ${x.title}: ${b.error}`),!1;const _=await n.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),w=se(_).item?.configuration_state??null,S=_s(w,x.fieldKey,x.bindingType,v);return x.bindingType==="github"&&delete S.github_repo,await h(o,{configuration_state:S}),await a.invalidateQueries({queryKey:Y.commerceDiscoveryConnection(e.id,o)}),await a.invalidateQueries({queryKey:Y.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),Z("commerce_onboarding_companion_connected",g),!0}catch(u){return Z("commerce_onboarding_companion_connect_failed",{...g,error:u instanceof Error?u.message:String(u)}),f(u instanceof Error?u.message:String(u)),!1}finally{d(null)}}async function C(x){l(x.fieldKey),f(null);const g={app_name:x.title,field_key:x.fieldKey,organization_id:e.id,domain:i,site_url:r};Z("commerce_onboarding_companion_disconnect_clicked",g);try{const u=await n.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),b={...se(u).item?.configuration_state??null??{}};return delete b[x.fieldKey],x.bindingType==="github"&&delete b.github_repo,await h(o,{configuration_state:b}),await a.invalidateQueries({queryKey:Y.commerceDiscoveryConnection(e.id,o)}),await a.invalidateQueries({queryKey:Y.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),Z("commerce_onboarding_companion_disconnected",g),!0}catch(u){return Z("commerce_onboarding_companion_disconnect_failed",{...g,error:u instanceof Error?u.message:String(u)}),f(u instanceof Error?u.message:String(u)),!1}finally{l(null)}}return{connect:y,connectingFieldKey:c,disconnect:C,disconnectingFieldKey:m,error:p}}const We="flex min-h-0 flex-1 flex-col gap-6 md:grid md:flex-none md:gap-4";function Ye(){const n=F.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("h1",{className:"text-2xl font-medium leading-8 text-foreground",children:"Conecte suas ferramentas para ver o diagnóstico completo"}),n[0]=e):e=n[0],e}function Cn(){const n=F.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[0,1,2,3].map(jn)}),n[0]=e):e=n[0],e}function jn(n){return t.jsx(sn,{},n)}function Je(){const n=F.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("div",{className:We,children:[t.jsx(Ye,{}),t.jsx(Cn,{})]}),n[0]=e):e=n[0],e}function _n(n){const e=F.c(5),{onRetry:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Ye,{}),e[0]=o):o=e[0];let i,r;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("p",{className:"text-sm text-foreground",children:"Não foi possível carregar as integrações complementares."}),r=t.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Algo deu errado ao carregar suas integrações."}),e[1]=i,e[2]=r):(i=e[1],r=e[2]);let a;return e[3]!==s?(a=t.jsxs("div",{className:We,children:[o,t.jsxs("div",{role:"alert",className:"rounded-2xl border border-border bg-card p-4",children:[i,r,t.jsx(B,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:s,children:"Tentar novamente"})]})]}),e[3]=s,e[4]=a):a=e[4],a}function Sn(n){const e=F.c(2);let s;return e[0]!==n?(s=t.jsx(dt,{children:o=>{const{reset:i}=o;return t.jsx(ut,{fallback:r=>{const{resetError:a}=r;return t.jsx(_n,{onRetry:()=>{i(),a()}})},children:t.jsx(K.Suspense,{fallback:t.jsx(Je,{}),children:t.jsx(Nn,{...n})})})}}),e[0]=n,e[1]=s):s=e[1],s}function Nn(n){const e=F.c(46),{org:s,cdConnectionId:o,siteUrl:i,onReadinessChange:r}=n,{data:a}=Ae.useSession(),c=a?.user?.id??"";let d;if(e[0]!==i){const I=i?ae(i):null;if(I?.ok)try{d=new URL(I.value).hostname}catch{d=void 0}e[0]=i,e[1]=d}else d=e[1];let m;e[2]!==s.id||e[3]!==s.slug?(m={connectionId:gt,orgId:s.id,orgSlug:s.slug},e[2]=s.id,e[3]=s.slug,e[4]=m):m=e[4];const l=Le(m);let p;e[5]!==o||e[6]!==s||e[7]!==l||e[8]!==i?(p={selfClient:l,org:s,cdConnectionId:o,siteUrl:i},e[5]=o,e[6]=s,e[7]=l,e[8]=i,e[9]=p):p=e[9];const{cards:f}=cn(p);let h;e[10]!==o||e[11]!==s||e[12]!==l||e[13]!==d||e[14]!==i||e[15]!==c?(h={selfClient:l,org:s,userId:c,cdConnectionId:o,domain:d,siteUrl:i},e[10]=o,e[11]=s,e[12]=l,e[13]=d,e[14]=i,e[15]=c,e[16]=h):h=e[16];const{connect:y,connectingFieldKey:C,disconnect:x,disconnectingFieldKey:g,error:u}=vn(h),[v,b]=K.useState(null);if(r?.(f.length===0||f.some(En)),f.length===0)return null;const _=C!==null||g!==null;let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(Ye,{}),e[17]=w):w=e[17];let S;e[18]!==u?(S=u&&t.jsx("p",{role:"alert",className:"mb-3 text-sm text-destructive",children:u}),e[18]=u,e[19]=S):S=e[19];let j;if(e[20]!==v||e[21]!==_||e[22]!==f||e[23]!==y||e[24]!==C||e[25]!==x||e[26]!==g||e[27]!==s||e[28]!==l||e[29]!==i){let I;e[31]!==v||e[32]!==_||e[33]!==y||e[34]!==C||e[35]!==x||e[36]!==g||e[37]!==s||e[38]!==l||e[39]!==i?(I=N=>{const A=async()=>{await y(N)&&b(N.fieldKey)};return t.jsx(nn,{card:N,connecting:C===N.fieldKey,disconnecting:g===N.fieldKey,disabled:_&&C!==N.fieldKey&&g!==N.fieldKey,org:s,selfClient:l,siteUrl:i,autoOpenConfigFieldKey:v,onAutoOpenConfigHandled:()=>b(P=>P===N.fieldKey?null:P),onConnect:()=>{A()},onDisconnect:()=>{x(N)}},N.fieldKey)},e[31]=v,e[32]=_,e[33]=y,e[34]=C,e[35]=x,e[36]=g,e[37]=s,e[38]=l,e[39]=i,e[40]=I):I=e[40],j=f.map(I),e[20]=v,e[21]=_,e[22]=f,e[23]=y,e[24]=C,e[25]=x,e[26]=g,e[27]=s,e[28]=l,e[29]=i,e[30]=j}else j=e[30];let E;e[41]!==j?(E=t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:j}),e[41]=j,e[42]=E):E=e[42];let O;return e[43]!==S||e[44]!==E?(O=t.jsxs("div",{className:We,children:[w,t.jsxs($e,{wrapperClassName:"flex min-h-0 flex-1 flex-col md:block",className:"-mx-1 min-h-0 flex-1 overflow-y-auto px-1 md:max-h-[min(60vh,calc(100dvh-330px))] md:flex-none",children:[S,E]})]}),e[43]=S,e[44]=E,e[45]=O):O=e[45],O}function En(n){return n.satisfied}const Ze="https://decocms.com/agendar",wn="Precisa de ajuda? Fale conosco",Tn="Agende uma chamada de 20 minutos e rodamos o diagnóstico com você, ao vivo.",Ce=[{photo:"https://decoims.com/image?src=decocms%2Fb07a1c19-0cd6-49c8-b326-86055ee78605%2Fauthor-1763423987973-baby.jpeg&quality=original&fit=cover&width=200&height=200",alt:"Especialista da deco"},{photo:"https://decoims.com/decocms/07c2daf4-a3c2-485e-a1a8-341585a06e3b/cecilia.png",alt:"Especialista da deco"},{photo:"https://decoims.com/decocms/48013ca2-3277-464b-b0f1-dd5f1f08d986/tavano.png",alt:"Especialista da deco"}],On="var(--brand-green-dark)";function Xe({siteUrl:n,email:e}){const s=new URL(Ze);return n&&s.searchParams.set("siteUrl",n),e&&s.searchParams.set("email",e),s.toString()}function In(n){const e=F.c(12),{href:s,size:o,className:i,orgId:r}=n,a=s===void 0?Ze:s,c=o===void 0?"lg":o;let d;e[0]!==i?(d=ie("w-full",i),e[0]=i,e[1]=d):d=e[1];let m;e[2]!==r?(m=()=>Z("commerce_onboarding_meeting_cta_clicked",{placement:"visual_card",organization_id:r}),e[2]=r,e[3]=m):m=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(Nt,{size:16}),e[4]=l):l=e[4];let p;e[5]!==a||e[6]!==m?(p=t.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",onClick:m,children:["Agendar uma reunião",l]}),e[5]=a,e[6]=m,e[7]=p):p=e[7];let f;return e[8]!==c||e[9]!==d||e[10]!==p?(f=t.jsx(B,{asChild:!0,variant:"outline",size:c,className:d,children:p}),e[8]=c,e[9]=d,e[10]=p,e[11]=f):f=e[11],f}function Rn(n){const e=F.c(10),{size:s}=n,o=s===void 0?72:s;let i;e[0]!==o?(i=Math.round(o*.3),e[0]=o,e[1]=i):i=e[1];const r=i;let a;e[2]!==o?(a={height:o},e[2]=o,e[3]=a):a=e[3];let c;e[4]!==r||e[5]!==o?(c=Ce.map((m,l)=>t.jsxs("div",{className:"relative shrink-0",style:{width:o,height:o,marginLeft:l===0?0:-r,zIndex:Ce.length-l},children:[t.jsx("div",{className:"h-full w-full overflow-hidden rounded-full border-4 border-card bg-muted",children:t.jsx("img",{src:m.photo,alt:m.alt,className:"h-full w-full object-cover",loading:"lazy"})}),l===0&&t.jsxs("span",{className:"absolute bottom-1.5 right-1.5 flex h-3.5 w-3.5",children:[t.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-success opacity-60 motion-safe:animate-ping","aria-hidden":!0}),t.jsx("span",{className:"relative inline-flex h-3.5 w-3.5 rounded-full border-2 border-card bg-success"})]})]},m.photo)),e[4]=r,e[5]=o,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=t.jsx("div",{className:"flex items-end",style:a,children:c}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function et(n){const e=F.c(6),{href:s,orgId:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("div",{className:"h-20",style:{backgroundColor:On}}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{className:"-mt-9 mb-4",children:t.jsx(Rn,{})}),e[1]=r):r=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx("h2",{className:"text-lg font-medium leading-6 text-foreground",children:wn}),t.jsx("p",{className:"text-sm leading-5 text-muted-foreground",children:Tn})]}),e[2]=a):a=e[2];let c;return e[3]!==s||e[4]!==o?(c=t.jsx("div",{className:"relative flex h-full w-full items-center justify-center p-10",children:t.jsxs("div",{className:"w-full max-w-[440px] overflow-hidden rounded-3xl border border-border bg-card card-shadow",children:[i,t.jsxs("div",{className:"px-8 pb-8",children:[r,a,t.jsx(In,{href:s,size:"lg",className:"mt-6",orgId:o})]})]})}),e[3]=s,e[4]=o,e[5]=c):c=e[5],c}function kn(n){const e=F.c(13),{className:s,href:o,orgId:i}=n,r=o===void 0?Ze:o;let a;e[0]!==i?(a=()=>Z("commerce_onboarding_meeting_cta_clicked",{placement:"mobile_banner",organization_id:i}),e[0]=i,e[1]=a):a=e[1];let c;e[2]!==s?(c=ie("flex items-center gap-4 rounded-2xl border border-border bg-card p-5 card-shadow transition-colors hover:bg-accent",s),e[2]=s,e[3]=c):c=e[3];let d,m;e[4]===Symbol.for("react.memo_cache_sentinel")?(d={height:44,width:44+2*Math.round(30.799999999999997)},m=Ce.map(An),e[4]=d,e[5]=m):(d=e[4],m=e[5]);let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsxs("span",{className:"relative flex shrink-0 items-center",style:d,children:[m,t.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-3 w-3 rounded-full border-2 border-card bg-success","aria-hidden":!0,style:{zIndex:Ce.length+1}})]}),e[6]=l):l=e[6];let p,f;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsxs("span",{className:"flex-1 text-base font-medium leading-5 text-foreground",children:["Precisa de ajuda?",t.jsx("br",{}),"Fale conosco"]}),f=t.jsx(Nt,{size:18,className:"shrink-0 text-muted-foreground"}),e[7]=p,e[8]=f):(p=e[7],f=e[8]);let h;return e[9]!==r||e[10]!==a||e[11]!==c?(h=t.jsxs("a",{href:r,target:"_blank",rel:"noreferrer",onClick:a,className:c,children:[l,p,f]}),e[9]=r,e[10]=a,e[11]=c,e[12]=h):h=e[12],h}function An(n,e){return t.jsx("span",{className:"absolute block h-11 w-11 overflow-hidden rounded-full border-2 border-card",style:{left:e*Math.round(30.799999999999997),zIndex:Ce.length-e},children:t.jsx("img",{src:n.photo,alt:n.alt,className:"h-full w-full object-cover",loading:"lazy"})},n.photo)}function Tt(n){const e=F.c(10),{host:s}=n,o=`https://www.google.com/s2/favicons?domain=${s}&sz=128`;let i,r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("img",{src:"/logos/deco logo.svg",alt:"Deco",className:"h-7 w-7 dark:hidden"}),r=t.jsx("img",{src:"/logos/deco logo negative.svg",alt:"Deco",className:"h-7 w-7 hidden dark:block"}),a=t.jsx("div",{className:"h-6 w-px rotate-12 bg-border","aria-hidden":"true"}),e[0]=i,e[1]=r,e[2]=a):(i=e[0],r=e[1],a=e[2]);let c;e[3]!==o?(c=t.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-white",children:t.jsx("img",{src:o,alt:"",className:"h-5 w-5",loading:"lazy"})}),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==s?(d=t.jsx("span",{className:"text-lg font-medium text-foreground",children:s}),e[5]=s,e[6]=d):d=e[6];let m;return e[7]!==c||e[8]!==d?(m=t.jsxs("div",{className:"flex items-center gap-3",children:[i,r,a,c,d]}),e[7]=c,e[8]=d,e[9]=m):m=e[9],m}const Ln={workspace:"Preparando seu workspace de commerce...",generic:"Preparando..."};function Pn(n){return Ln[n]}function tt(n){const e=F.c(4),{variant:s}=n;let o;e[0]!==s?(o=Pn(s),e[0]=s,e[1]=o):o=e[1];let i;return e[2]!==o?(i=t.jsx("div",{className:"flex justify-center py-4",role:"status","aria-live":"polite",children:t.jsx(Pe,{label:o,className:"text-muted-foreground"})}),e[2]=o,e[3]=i):i=e[3],i}function ci(){const n=F.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Un,{}),n[0]=e):e=n[0],e}const Ot=K.createContext(null),It=()=>K.useContext(Ot);function ne(n){const e=F.c(13);let s,o;e[0]!==n?({visual:o,...s}=n,e[0]=n,e[1]=s,e[2]=o):(s=e[1],o=e[2]);let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i={from:"/commerce-onboarding"},e[3]=i):i=e[3];const r=mt(i),{data:a}=Ae.useSession(),c=a?.user?.email;let d;e[4]!==r.siteUrl||e[5]!==c?(d=Xe({siteUrl:r.siteUrl,email:c}),e[4]=r.siteUrl,e[5]=c,e[6]=d):d=e[6];const m=d;let l;e[7]!==m||e[8]!==o?(l=o??t.jsx(et,{href:m}),e[7]=m,e[8]=o,e[9]=l):l=e[9];let p;return e[10]!==s||e[11]!==l?(p=t.jsx(Wt,{...s,visual:l}),e[10]=s,e[11]=l,e[12]=p):p=e[12],p}const zn={signUpFailed:"Falha ao criar conta",signInFailed:"Falha ao entrar",authenticationFailed:"Falha na autenticação",resetEmailFailed:"Não foi possível enviar o e-mail de redefinição",otpSendFailed:"Não foi possível enviar o código",invalidCode:"Código inválido",invalidEmail:"E-mail inválido",invalidEmailOrPassword:"E-mail ou senha inválidos. Tente novamente.",accountExists:"Já existe uma conta com este e-mail. Tente entrar em vez de criar uma nova conta.",networkError:"Erro de rede. Verifique sua conexão e tente novamente.",tooManyAttempts:"Muitas tentativas. Aguarde um momento e tente novamente.",invalidOrExpiredCode:"Código inválido ou expirado. Tente novamente.",genericError:"Algo deu errado. Tente novamente.",resetPasswordTitle:"Redefinir sua senha",verificationCodeTitle:"Informe o código de verificação",welcomeTitle:"Bem-vindo à deco",resetPasswordSubtitle:"Enviaremos um link de redefinição",codeSentTo:n=>`Código enviado para ${n}`,defaultSubtitle:"Entre ou crie uma nova conta",resetEmailSent:"Verifique seu e-mail para redefinir a senha.",continueWith:n=>`Continuar com ${n}`,divider:"ou",emailLabel:"E-mail",emailPlaceholder:"Endereço de e-mail",sending:"Enviando...",sendCode:"Enviar código",verificationCodeLabel:"Código de verificação",enterCodePlaceholder:"Informe o código",verifying:"Verificando...",verify:"Verificar",useDifferentEmail:"Usar outro e-mail",sendResetLink:"Enviar link de redefinição",nameLabel:"Nome",namePlaceholder:"Seu nome",passwordLabel:"Senha",forgotPassword:"Esqueceu a senha?",creatingAccount:"Criando conta...",signingIn:"Entrando...",continue:"Continuar",backToSignIn:"Voltar para entrar",signInWithPassword:"Entrar com senha",alreadyHaveAccount:"Já tem uma conta? ",dontHaveAccount:"Não tem uma conta? ",signIn:"Entrar",signUp:"Criar conta",signInWithEmailCode:"Entrar com código por e-mail"};function pe(n){if(!n)return null;const e=ae(n);return e.ok?new URL(e.value).hostname:null}function at(n){switch(n){case"Enter a website URL.":return"Informe a URL de um site.";case"Use an HTTP or HTTPS website URL.":return"Use uma URL de site HTTP ou HTTPS.";case"Enter a valid website URL.":return"Informe uma URL de site válida.";default:return n}}let lt=!1;function Un(){const n=mt({from:"/commerce-onboarding"}),{org:e,siteUrl:s}=n,o=pe(s);return!lt&&Ht()&&(lt=!0,Z("commerce_onboarding_viewed",{site_url:s,domain:o??void 0,...o?{$set:{last_scanned_domain:o}}:{}})),t.jsx(Ot.Provider,{value:o,children:t.jsx($n,{requestedOrgSlug:e,siteUrl:s})})}function $n(n){const e=F.c(8),{requestedOrgSlug:s,siteUrl:o}=n,{data:i,isPending:r}=Ae.useSession(),a=It();if(r){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(ne,{children:t.jsx(tt,{variant:"generic"})}),e[0]=d):d=e[0],d}if(!i){const d=typeof window>"u"?"/commerce-onboarding":`${window.location.pathname}${window.location.search}`;let m;e[1]!==a?(m=a?t.jsx(Tt,{host:a}):void 0,e[1]=a,e[2]=m):m=e[2];let l;return e[3]!==m?(l=t.jsx(ne,{children:t.jsx(Bt,{callbackUrl:d,allowAutoLogin:!1,title:"Desbloqueie seu diagnóstico completo",subtitle:null,brand:m,copy:zn})}),e[3]=m,e[4]=l):l=e[4],l}let c;return e[5]!==s||e[6]!==o?(c=t.jsx(Dn,{requestedOrgSlug:s,siteUrl:o}),e[5]=s,e[6]=o,e[7]=c):c=e[7],c}function Dn(n){const e=F.c(43),{requestedOrgSlug:s,siteUrl:o}=n,i=ft(),r=Qt(),[a,c]=K.useState(null),[d,m]=K.useState(null),l=r.data?.map(qn)??[];let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={mutationFn:Mn,retry:!1,onSuccess:u=>{m(u)}},e[0]=p):p=e[0];const f=fe(p);if(r.isPending){let u;return e[1]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(ne,{children:t.jsx(tt,{variant:"workspace"})}),e[1]=u):u=e[1],u}if(r.error){let u;return e[2]!==r?(u=t.jsx(Ie,{title:"Não foi possível carregar suas organizações",description:"Tente novamente para continuar a configuração de commerce nesta página.",actionLabel:"Tentar novamente",onRetry:()=>r.refetch()}),e[2]=r,e[3]=u):u=e[3],u}const h=s?l.find(u=>u.slug===s):null;if(h){let u;return e[4]!==h||e[5]!==o?(u=t.jsx(Te,{org:h,initialSiteUrl:o}),e[4]=h,e[5]=o,e[6]=u):u=e[6],u}if(s){let u;return e[7]!==r?(u=t.jsx(Ie,{title:"Organização não encontrada",description:"Não conseguimos encontrar essa organização na sua conta.",actionLabel:"Tentar novamente",onRetry:()=>r.refetch()}),e[7]=r,e[8]=u):u=e[8],u}if(a){let u;return e[9]!==a||e[10]!==o?(u=t.jsx(Te,{org:a,initialSiteUrl:o}),e[9]=a,e[10]=o,e[11]=u):u=e[11],u}if(l.length===1&&l[0]){let u;return e[12]!==l[0]||e[13]!==o?(u=t.jsx(Te,{org:l[0],initialSiteUrl:o}),e[12]=l[0],e[13]=o,e[14]=u):u=e[14],u}if(l.length>1){let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(re,{title:"Escolha uma organização",description:"Selecione onde o diagnóstico de commerce deve continuar."}),e[15]=u):u=e[15];let v;e[16]!==i||e[17]!==o?(v=_=>i({to:"/commerce-onboarding",search:{org:_.slug,siteUrl:o}}),e[16]=i,e[17]=o,e[18]=v):v=e[18];let b;return e[19]!==l||e[20]!==v?(b=t.jsx(ne,{children:t.jsxs("div",{className:"grid gap-10",children:[u,t.jsx($e,{className:"-mx-1 max-h-[60vh] overflow-y-auto px-1",children:t.jsx(nt,{organizations:l,selectLabel:"Continuar",onSelected:v})})]})}),e[19]=l,e[20]=v,e[21]=b):b=e[21],b}if(!d){let u;e[22]!==f?(u=()=>{f.reset(),f.mutate()},e[22]=f,e[23]=u):u=e[23];let v;return e[24]!==f||e[25]!==u?(v=t.jsx(Fn,{mutation:f,onRetry:u}),e[24]=f,e[25]=u,e[26]=v):v=e[26],v}const y=d;if(y?.success&&(y.status==="created"||y.status==="joined"||y.status==="already_has_organization")&&y.organization){let u;return e[27]!==y.organization||e[28]!==o?(u=t.jsx(Te,{org:y.organization,initialSiteUrl:o}),e[27]=y.organization,e[28]=o,e[29]=u):u=e[29],u}if(y?.status==="ambiguous"&&y.organizations&&y.organizations.length>0){let u;e[30]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(re,{title:"Escolha uma organização",description:"Seu e-mail pode acessar mais de uma organização. Escolha onde a configuração de commerce deve continuar."}),e[30]=u):u=e[30];const v=y.domain??void 0;let b;e[31]!==i||e[32]!==o?(b=(w,S)=>{pt(),c({...w,slug:S}),i({to:"/commerce-onboarding",search:{org:S,siteUrl:o}})},e[31]=i,e[32]=o,e[33]=b):b=e[33];let _;return e[34]!==y.organizations||e[35]!==v||e[36]!==b?(_=t.jsx(ne,{children:t.jsxs("div",{className:"grid gap-10",children:[u,t.jsx($e,{className:"-mx-1 max-h-[60vh] overflow-y-auto px-1",children:t.jsx(nt,{organizations:y.organizations,domain:v,onJoined:b})})]})}),e[34]=y.organizations,e[35]=v,e[36]=b,e[37]=_):_=e[37],_}const C=y?.error??"Não conseguimos determinar uma organização de commerce para esta conta.";let x;e[38]!==f?(x=()=>{m(null),f.reset()},e[38]=f,e[39]=x):x=e[39];let g;return e[40]!==C||e[41]!==x?(g=t.jsx(Ie,{title:"O onboarding de commerce precisa de suporte",description:C,actionLabel:"Tentar novamente",onRetry:x}),e[40]=C,e[41]=x,e[42]=g):g=e[42],g}async function Mn(){const e=await(await fetch("/api/auth/custom/ensure-organization",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}})).json();return e.success&&(e.status==="created"||e.status==="joined"||e.status==="already_has_organization")&&e.organization&&pt(),e}function qn(n){return{id:n.id,name:n.name,slug:n.slug,logo:n.logo??null}}function Fn(n){const e=F.c(7),{mutation:s,onRetry:o}=n,i=K.useRef(!1);let r;e[0]!==s?(r=m=>{!m||i.current||(i.current=!0,s.mutate())},e[0]=s,e[1]=r):r=e[1];const a=r;if(s.error){let m;return e[2]!==o?(m=t.jsx(Ie,{title:"Onboarding de commerce indisponível",description:"Não foi possível preparar uma organização para a configuração de commerce. Tente novamente por esta página ou fale com o suporte.",actionLabel:"Tentar novamente",onRetry:o}),e[2]=o,e[3]=m):m=e[3],m}let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(tt,{variant:"generic"}),e[4]=c):c=e[4];let d;return e[5]!==a?(d=t.jsx(ne,{children:t.jsx("div",{ref:a,children:c})}),e[5]=a,e[6]=d):d=e[6],d}function re(n){const e=F.c(8),{title:s,description:o}=n,i=It();let r;e[0]!==i?(r=i?t.jsx(Tt,{host:i}):t.jsxs("div",{children:[t.jsx("img",{src:"/logos/deco logo.svg",alt:"Deco",className:"h-12 w-12 dark:hidden"}),t.jsx("img",{src:"/logos/deco logo negative.svg",alt:"Deco",className:"h-12 w-12 hidden dark:block"})]}),e[0]=i,e[1]=r):r=e[1];let a;e[2]!==o||e[3]!==s?(a=(s||o)&&t.jsxs("div",{className:"space-y-2",children:[s&&t.jsx("h1",{className:"text-2xl font-medium leading-8",children:s}),o&&t.jsx("p",{className:"text-base text-muted-foreground leading-6",children:o})]}),e[2]=o,e[3]=s,e[4]=a):a=e[4];let c;return e[5]!==r||e[6]!==a?(c=t.jsxs("div",{className:"grid gap-10",children:[r,a]}),e[5]=r,e[6]=a,e[7]=c):c=e[7],c}function Ie(n){const e=F.c(9),{title:s,description:o,actionLabel:i,onRetry:r}=n;let a;e[0]!==o||e[1]!==s?(a=t.jsx(re,{title:s,description:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let c;e[3]!==i||e[4]!==r?(c=t.jsx(B,{type:"button",size:"xl",className:"w-full",onClick:r,children:i}),e[3]=i,e[4]=r,e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==c?(d=t.jsx(ne,{children:t.jsxs("div",{className:"grid gap-10",children:[a,c]})}),e[6]=a,e[7]=c,e[8]=d):d=e[8],d}function Kn(n){return n.content?.find(e=>e.text)?.text??"A configuração do Commerce Discovery falhou."}function we(n){const e=n;if(e.isError)throw new Error(Kn(e));return e.structuredContent??n}function Te(n){const e=F.c(11),{org:s,initialSiteUrl:o}=n,{data:i}=Ae.useSession(),r=i?.user?.email;let a;e[0]!==o||e[1]!==r?(a=Xe({siteUrl:o,email:r}),e[0]=o,e[1]=r,e[2]=a):a=e[2];const c=a;let d;e[3]!==c||e[4]!==s.id?(d=t.jsx(et,{href:c,orgId:s.id}),e[3]=c,e[4]=s.id,e[5]=d):d=e[5];const m=d;let l;return e[6]!==o||e[7]!==m||e[8]!==s||e[9]!==i?.user?.email?(l=t.jsx(dt,{children:p=>{const{reset:f}=p;return t.jsx(ut,{fallback:h=>{const{error:y,resetError:C}=h;return t.jsx(ne,{visual:m,children:t.jsx(Vn,{orgName:s.name,message:y instanceof Error?y.message:"Não foi possível verificar a configuração do Commerce Discovery.",onRetry:()=>{f(),C()}})})},children:t.jsx(K.Suspense,{fallback:t.jsx(Rt,{visual:m}),children:t.jsx(Hn,{org:s,initialSiteUrl:o,sessionEmail:i?.user?.email},`${s.id}:${o??""}`)})})}}),e[6]=o,e[7]=m,e[8]=s,e[9]=i?.user?.email,e[10]=l):l=e[10],l}function Rt(n){const e=F.c(3),{visual:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-6 md:grid md:gap-4",children:[t.jsx(re,{}),t.jsx(Je,{})]}),e[0]=o):o=e[0];let i;return e[1]!==s?(i=t.jsx(ne,{align:"fill",visual:s,children:o}),e[1]=s,e[2]=i):i=e[2],i}function Vn(n){const e=F.c(10),{orgName:s,message:o,onRetry:i}=n,r=`A configuração de commerce continuará em ${s}.`;let a;e[0]!==r?(a=t.jsx(re,{title:"Diagnóstico de commerce",description:r}),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==o?(c=t.jsx(je,{message:o}),e[2]=o,e[3]=c):c=e[3];let d;e[4]!==i?(d=t.jsx(B,{type:"button",size:"xl",className:"w-full",onClick:i,children:"Tentar novamente"}),e[4]=i,e[5]=d):d=e[5];let m;return e[6]!==a||e[7]!==c||e[8]!==d?(m=t.jsxs("div",{className:"grid gap-10",children:[a,c,d]}),e[6]=a,e[7]=c,e[8]=d,e[9]=m):m=e[9],m}function Hn({org:n,initialSiteUrl:e,sessionEmail:s}){const o=ft(),i=Le({connectionId:gt,orgId:n.id,orgSlug:n.slug}),[r,a]=K.useState(e??""),[c,d]=K.useState(null),[m,l]=K.useState(null),p=K.useRef(!1),f=Me.COMMERCE_DISCOVERY(n.id),h=Jt(n.id),y=ve({queryKey:Y.commerceDiscoveryConnection(n.id,f),queryFn:async()=>{const T=await i.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:f}});return we(T)},retry:!1}),C=ve({queryKey:Y.commerceDiscoveryVirtualMcp(n.id,h),queryFn:async()=>{const T=await i.callTool({name:"COLLECTION_VIRTUAL_MCP_GET",arguments:{id:h}});return we(T)},retry:!1}),x=fe({mutationFn:async T=>{const R=await i.callTool({name:"COMMERCE_DISCOVERY_SETUP",arguments:{siteUrl:T}});return we(R)},retry:!1,onSuccess:(T,R)=>{Z("commerce_onboarding_setup_succeeded",{domain:pe(R)??void 0,organization_id:n.id}),d(T),l(null),y.refetch(),C.refetch()},onError:(T,R)=>{Z("commerce_onboarding_setup_failed",{domain:pe(R)??void 0,organization_id:n.id,error:T instanceof Error?T.message:String(T)}),l(T instanceof Error?T.message:"A configuração do Commerce Discovery falhou.")}}),g=fe({mutationFn:async T=>{const R=await i.callTool({name:"COMMERCE_DISCOVERY_RUN",arguments:{siteUrl:T}});return we(R)},retry:!1}),[u,v]=K.useState(null),b=!!y.data.item&&!!C.data.item,_=y.data.item,w=typeof _?.metadata?.siteUrl=="string"?_.metadata.siteUrl:void 0,j=bs(e||r||"",w),E=b&&j,O=e||r||w||"",I=Xe({siteUrl:O,email:s}),N=t.jsx(et,{href:I,orgId:n.id}),A=T=>{const R=ae(T);if(!R.ok){l(at(R.error));return}l(null),x.mutate(R.value)},P=T=>{!T||p.current||E||!e||(p.current=!0,A(e))},L=T=>{T.preventDefault();const R=ae(r);R.ok&&Z("commerce_onboarding_site_url_submitted",{domain:new URL(R.value).hostname,organization_id:n.id}),A(r)},M=c?.reportApp??{connectionId:f,virtualMcpId:h,toolName:Zt},U=async()=>{v(null),Z("commerce_onboarding_open_report_clicked",{domain:pe(O)??void 0,organization_id:n.id});const T=ae(O);if(T.ok)try{const R=await g.mutateAsync(T.value);if(!R.triggered){Z("commerce_onboarding_run_failed",{domain:pe(O)??void 0,organization_id:n.id,error:R.reason??"not_triggered"}),v("Não foi possível gerar o relatório para este site. Recarregue a página e tente novamente.");return}}catch(R){Z("commerce_onboarding_run_failed",{domain:pe(O)??void 0,organization_id:n.id,error:R instanceof Error?R.message:String(R)}),v("Algo deu errado ao gerar seu relatório. Tente novamente em instantes.");return}localStorage.setItem(Gt.sidebarOpen(),JSON.stringify(!1)),o({to:"/$org/$taskId",params:{org:n.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:M.virtualMcpId,main:Yt(M.connectionId,M.toolName)}})};if(E)return t.jsx(Qn,{org:n,reportApp:M,onOpenReport:U,isSubmitting:g.isPending,error:u,meetingUrl:I,meetingVisual:N,siteUrl:O});if(x.isPending)return t.jsx(Rt,{visual:N});if(e){const T=ae(e);return T.ok?t.jsx(ne,{visual:N,children:t.jsxs("div",{ref:P,className:"grid gap-10",children:[t.jsx(re,{title:"Diagnóstico de commerce",description:`O Commerce Discovery está sendo preparado para ${T.value}.`}),m?t.jsxs(t.Fragment,{children:[t.jsx(je,{message:m}),t.jsx(ze,{siteUrl:r,error:null,isSubmitting:x.isPending,onSiteUrlChange:a,onSubmit:L})]}):t.jsx(Je,{})]})}):t.jsx(ne,{visual:N,children:t.jsxs("div",{className:"grid gap-10",children:[t.jsx(re,{title:"Diagnóstico de commerce",description:`A configuração de commerce continuará em ${n.name}.`}),t.jsx(je,{message:at(T.error)}),t.jsx(ze,{siteUrl:r,error:m,isSubmitting:x.isPending,onSiteUrlChange:a,onSubmit:L})]})})}return t.jsx(ne,{visual:N,children:t.jsxs("div",{className:"grid gap-10",children:[t.jsx(re,{title:"Diagnóstico de commerce",description:`A configuração de commerce continuará em ${n.name}.`}),t.jsx(ze,{siteUrl:r,error:m,isSubmitting:x.isPending,onSiteUrlChange:a,onSubmit:L})]})})}function ze(n){const e=F.c(20),{siteUrl:s,error:o,isSubmitting:i,onSiteUrlChange:r,onSubmit:a}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("label",{className:"text-sm font-medium",htmlFor:"commerce-site-url",children:"URL do site"}),e[0]=c):c=e[0];let d;e[1]!==r?(d=x=>r(x.target.value),e[1]=r,e[2]=d):d=e[2];const m=!!o;let l;e[3]!==i||e[4]!==s||e[5]!==d||e[6]!==m?(l=t.jsx(be,{id:"commerce-site-url",type:"text",inputMode:"url",value:s,onChange:d,placeholder:"https://example.com","aria-invalid":m,disabled:i}),e[3]=i,e[4]=s,e[5]=d,e[6]=m,e[7]=l):l=e[7];let p;e[8]!==o?(p=o?t.jsx(je,{message:o}):null,e[8]=o,e[9]=p):p=e[9];let f;e[10]!==l||e[11]!==p?(f=t.jsxs("div",{className:"grid gap-2",children:[c,l,p]}),e[10]=l,e[11]=p,e[12]=f):f=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(ht,{size:16}),e[13]=h):h=e[13];let y;e[14]!==i?(y=t.jsxs(B,{type:"submit",size:"xl",className:"w-full",disabled:i,children:["Continuar",h]}),e[14]=i,e[15]=y):y=e[15];let C;return e[16]!==a||e[17]!==f||e[18]!==y?(C=t.jsxs("form",{className:"grid gap-4",onSubmit:a,children:[f,y]}),e[16]=a,e[17]=f,e[18]=y,e[19]=C):C=e[19],C}function Qn(n){const e=F.c(27),{org:s,reportApp:o,onOpenReport:i,isSubmitting:r,error:a,meetingUrl:c,meetingVisual:d,siteUrl:m}=n,[l,p]=K.useState(!0);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(re,{}),e[0]=f):f=e[0];let h;e[1]!==s||e[2]!==o.connectionId||e[3]!==m?(h=t.jsx(Sn,{org:s,cdConnectionId:o.connectionId,siteUrl:m,onReadinessChange:p}),e[1]=s,e[2]=o.connectionId,e[3]=m,e[4]=h):h=e[4];let y;e[5]!==c||e[6]!==s.id?(y=t.jsx(kn,{className:"md:hidden",href:c,orgId:s.id}),e[5]=c,e[6]=s.id,e[7]=y):y=e[7];let C;e[8]!==a?(C=a?t.jsx(je,{message:a}):null,e[8]=a,e[9]=C):C=e[9];const x=r||!o.virtualMcpId||!l,g=r?"Abrindo relatório...":"Ver relatório completo";let u;e[10]!==r?(u=r?null:t.jsx(ht,{size:18}),e[10]=r,e[11]=u):u=e[11];let v;e[12]!==i||e[13]!==x||e[14]!==g||e[15]!==u?(v=t.jsxs(B,{type:"button",size:"xl",className:"w-full rounded-2xl text-base font-medium",onClick:i,disabled:x,children:[g,u]}),e[12]=i,e[13]=x,e[14]=g,e[15]=u,e[16]=v):v=e[16];let b;e[17]!==y||e[18]!==C||e[19]!==v?(b=t.jsxs("div",{className:"flex shrink-0 flex-col gap-3 md:mt-8",children:[y,C,v]}),e[17]=y,e[18]=C,e[19]=v,e[20]=b):b=e[20];let _;e[21]!==h||e[22]!==b?(_=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-6 md:grid md:gap-4",children:[f,h,b]}),e[21]=h,e[22]=b,e[23]=_):_=e[23];let w;return e[24]!==d||e[25]!==_?(w=t.jsx(ne,{align:"fill",visual:d,children:_}),e[24]=d,e[25]=_,e[26]=w):w=e[26],w}function je(n){const e=F.c(2),{message:s}=n;let o;return e[0]!==s?(o=t.jsx("p",{className:"text-sm leading-5 text-destructive",role:"alert",children:s}),e[0]=s,e[1]=o):o=e[1],o}export{ci as default};
@@ -1 +1 @@
1
- import{c as L,$ as I,K as M,k as S,j as s,r as T,B as R,l as v}from"./index-CO1L2k6F.js";import{a as E,b as _,c as D,d as A,e as B}from"./dialog-Doo4cf6x.js";import{S as $}from"./chat-context-DbtHJFUr.js";import{i as O}from"./Check-tfEbDiSO.js";import{a as F}from"./Copy01-v70-83R3.js";import{u as K}from"./studio-tools-CkzkLbeK.js";const y={online:!1,capabilities:[],ready:!1};function H(l){const e=L.c(9),{org:n}=I(),o=K(),i=l?.fast??!1;let t;e[0]!==n.id?(t=M.currentLink(n.id),e[0]=n.id,e[1]=t):t=e[1];let a;e[2]!==o?(a=async()=>{const u=await o.call("LINK_CURRENT_GET",{});return u?{...u,ready:!0}:{...y,ready:!0}},e[2]=o,e[3]=a):a=e[3];const d=i?1e3:1e4,g=i?2e3:15e3;let c;e[4]!==t||e[5]!==a||e[6]!==d||e[7]!==g?(c={queryKey:t,queryFn:a,staleTime:d,refetchInterval:g,refetchOnWindowFocus:!0},e[4]=t,e[5]=a,e[6]=d,e[7]=g,e[8]=c):c=e[8];const{data:r}=S(c);return r??y}function k(l){const e=L.c(3),{size:n}=l,o=n===void 0?16:n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("path",{d:"M13 12L18.5 5M7.63965 3L12.5 12L13.6865 3M4.48381 6.71679L11.9872 12M3 12L11.9872 12.473M12.2244 13.177L7 20M4.84194 16.8682L11.2824 12.9758M11.5 21L12.665 13.177M21 14L13.1846 12.668M21 10.5788L13 12.3223M16.779 19.646L12.8876 13.3772M19.3566 18.207L13.313 12.9893"}),e[0]=i):i=e[0];let t;return e[1]!==o?(t=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:o,height:o,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i}),e[1]=o,e[2]=t):t=e[2],t}function w(l){const e=L.c(3),{size:n}=l,o=n===void 0?16:n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("path",{clipRule:"evenodd",d:"M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"}),e[0]=i):i=e[0];let t;return e[1]!==o?(t=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:o,height:o,fill:"currentColor",fillRule:"evenodd","aria-hidden":"true",children:i}),e[1]=o,e[2]=t):t=e[2],t}const P={"claude-code":{label:"Claude Code",Icon:k},codex:{label:"Codex",Icon:w}};function J(l){return(l&&P[l])??null}const N="bunx decocms@latest link",z=[{capability:"claude-code",label:"Claude Code",description:"Runs through the Claude Code CLI",icon:s.jsx(k,{size:18})},{capability:"codex",label:"Codex",description:"Runs through the Codex CLI",icon:s.jsx(w,{size:18})}];function V(l){return z.filter(e=>l.includes(e.capability)).map(e=>e.label)}function X(l){const e=L.c(23),{open:n,onOpenChange:o}=l;let i;e[0]!==n?(i={fast:n},e[0]=n,e[1]=i):i=e[1];const t=H(i),[a,d]=T.useState(!1),g=t.hostname??t.machineId??"Your desktop",c=t.online?`Connected to ${g}`:"Connect your desktop";let r;e[2]!==c?(r=s.jsx(E,{children:c}),e[2]=c,e[3]=r):r=e[3];const u=t.online?"This machine provides the following local agents.":"Run this command in your desktop terminal. The dialog will close once your desktop is online.";let m;e[4]!==u?(m=s.jsx(_,{children:u}),e[4]=u,e[5]=m):m=e[5];let x;e[6]!==r||e[7]!==m?(x=s.jsxs(D,{children:[r,m]}),e[6]=r,e[7]=m,e[8]=x):x=e[8];let f;e[9]!==a||e[10]!==t.online?(f=!t.online&&s.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-muted px-3 py-2 font-mono text-sm",children:[s.jsx("span",{className:"flex-1",children:N}),s.jsx(R,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>{navigator.clipboard.writeText(N),d(!0),setTimeout(()=>d(!1),1500)},children:a?s.jsx(O,{size:14}):s.jsx(F,{size:14})})]}),e[9]=a,e[10]=t.online,e[11]=f):f=e[11];let p;e[12]!==t.capabilities||e[13]!==t.online?(p=t.online?s.jsx("div",{className:"flex flex-col gap-3 text-sm",children:s.jsx("div",{className:"flex flex-col gap-2",children:z.map(b=>{const C=t.capabilities.includes(b.capability);return s.jsxs("div",{className:v("flex items-center gap-3 rounded-md border px-3 py-2",C?"border-border bg-background text-foreground":"border-border/60 bg-muted/40 text-muted-foreground"),children:[s.jsx("div",{className:v("flex size-6 items-center justify-center",C?"text-foreground":"text-muted-foreground"),children:b.icon}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium",children:b.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:C?b.description:"Not detected"})]}),s.jsx("span",{className:v("size-2 rounded-full",C?"bg-success":"bg-muted-foreground/30")})]},b.capability)})})}):s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx($,{size:"sm"}),"Waiting for desktop…"]}),e[12]=t.capabilities,e[13]=t.online,e[14]=p):p=e[14];let h;e[15]!==x||e[16]!==f||e[17]!==p?(h=s.jsxs(A,{className:"sm:max-w-md",children:[x,f,p]}),e[15]=x,e[16]=f,e[17]=p,e[18]=h):h=e[18];let j;return e[19]!==o||e[20]!==n||e[21]!==h?(j=s.jsx(B,{open:n,onOpenChange:o,children:h}),e[19]=o,e[20]=n,e[21]=h,e[22]=j):j=e[22],j}export{X as C,k as a,w as b,J as l,H as u,V as v};
1
+ import{c as L,$ as I,K as M,k as S,j as s,r as T,B as R,l as v}from"./index-B7JNGFVx.js";import{a as E,b as _,c as D,d as A,e as B}from"./dialog-GMipq3bN.js";import{S as $}from"./chat-context-DwqbCivU.js";import{i as O}from"./Check-CAm_pNZb.js";import{a as F}from"./Copy01-CuE5Mdxv.js";import{u as K}from"./studio-tools-CXs7tmNe.js";const y={online:!1,capabilities:[],ready:!1};function H(l){const e=L.c(9),{org:n}=I(),o=K(),i=l?.fast??!1;let t;e[0]!==n.id?(t=M.currentLink(n.id),e[0]=n.id,e[1]=t):t=e[1];let a;e[2]!==o?(a=async()=>{const u=await o.call("LINK_CURRENT_GET",{});return u?{...u,ready:!0}:{...y,ready:!0}},e[2]=o,e[3]=a):a=e[3];const d=i?1e3:1e4,g=i?2e3:15e3;let c;e[4]!==t||e[5]!==a||e[6]!==d||e[7]!==g?(c={queryKey:t,queryFn:a,staleTime:d,refetchInterval:g,refetchOnWindowFocus:!0},e[4]=t,e[5]=a,e[6]=d,e[7]=g,e[8]=c):c=e[8];const{data:r}=S(c);return r??y}function k(l){const e=L.c(3),{size:n}=l,o=n===void 0?16:n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("path",{d:"M13 12L18.5 5M7.63965 3L12.5 12L13.6865 3M4.48381 6.71679L11.9872 12M3 12L11.9872 12.473M12.2244 13.177L7 20M4.84194 16.8682L11.2824 12.9758M11.5 21L12.665 13.177M21 14L13.1846 12.668M21 10.5788L13 12.3223M16.779 19.646L12.8876 13.3772M19.3566 18.207L13.313 12.9893"}),e[0]=i):i=e[0];let t;return e[1]!==o?(t=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:o,height:o,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i}),e[1]=o,e[2]=t):t=e[2],t}function w(l){const e=L.c(3),{size:n}=l,o=n===void 0?16:n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("path",{clipRule:"evenodd",d:"M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"}),e[0]=i):i=e[0];let t;return e[1]!==o?(t=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:o,height:o,fill:"currentColor",fillRule:"evenodd","aria-hidden":"true",children:i}),e[1]=o,e[2]=t):t=e[2],t}const P={"claude-code":{label:"Claude Code",Icon:k},codex:{label:"Codex",Icon:w}};function J(l){return(l&&P[l])??null}const N="bunx decocms@latest link",z=[{capability:"claude-code",label:"Claude Code",description:"Runs through the Claude Code CLI",icon:s.jsx(k,{size:18})},{capability:"codex",label:"Codex",description:"Runs through the Codex CLI",icon:s.jsx(w,{size:18})}];function V(l){return z.filter(e=>l.includes(e.capability)).map(e=>e.label)}function X(l){const e=L.c(23),{open:n,onOpenChange:o}=l;let i;e[0]!==n?(i={fast:n},e[0]=n,e[1]=i):i=e[1];const t=H(i),[a,d]=T.useState(!1),g=t.hostname??t.machineId??"Your desktop",c=t.online?`Connected to ${g}`:"Connect your desktop";let r;e[2]!==c?(r=s.jsx(E,{children:c}),e[2]=c,e[3]=r):r=e[3];const u=t.online?"This machine provides the following local agents.":"Run this command in your desktop terminal. The dialog will close once your desktop is online.";let m;e[4]!==u?(m=s.jsx(_,{children:u}),e[4]=u,e[5]=m):m=e[5];let x;e[6]!==r||e[7]!==m?(x=s.jsxs(D,{children:[r,m]}),e[6]=r,e[7]=m,e[8]=x):x=e[8];let f;e[9]!==a||e[10]!==t.online?(f=!t.online&&s.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-muted px-3 py-2 font-mono text-sm",children:[s.jsx("span",{className:"flex-1",children:N}),s.jsx(R,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>{navigator.clipboard.writeText(N),d(!0),setTimeout(()=>d(!1),1500)},children:a?s.jsx(O,{size:14}):s.jsx(F,{size:14})})]}),e[9]=a,e[10]=t.online,e[11]=f):f=e[11];let p;e[12]!==t.capabilities||e[13]!==t.online?(p=t.online?s.jsx("div",{className:"flex flex-col gap-3 text-sm",children:s.jsx("div",{className:"flex flex-col gap-2",children:z.map(b=>{const C=t.capabilities.includes(b.capability);return s.jsxs("div",{className:v("flex items-center gap-3 rounded-md border px-3 py-2",C?"border-border bg-background text-foreground":"border-border/60 bg-muted/40 text-muted-foreground"),children:[s.jsx("div",{className:v("flex size-6 items-center justify-center",C?"text-foreground":"text-muted-foreground"),children:b.icon}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium",children:b.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:C?b.description:"Not detected"})]}),s.jsx("span",{className:v("size-2 rounded-full",C?"bg-success":"bg-muted-foreground/30")})]},b.capability)})})}):s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx($,{size:"sm"}),"Waiting for desktop…"]}),e[12]=t.capabilities,e[13]=t.online,e[14]=p):p=e[14];let h;e[15]!==x||e[16]!==f||e[17]!==p?(h=s.jsxs(A,{className:"sm:max-w-md",children:[x,f,p]}),e[15]=x,e[16]=f,e[17]=p,e[18]=h):h=e[18];let j;return e[19]!==o||e[20]!==n||e[21]!==h?(j=s.jsx(B,{open:n,onOpenChange:o,children:h}),e[19]=o,e[20]=n,e[21]=h,e[22]=j):j=e[22],j}export{X as C,k as a,w as b,J as l,H as u,V as v};
@@ -1 +1 @@
1
- import{g as _}from"./connection-slug-eyAPH6o3.js";import{c as R,$ as T,aV as k,K as D,l as E,j as x}from"./index-CO1L2k6F.js";import{u as K}from"./use-registry-connections-D-CxCgyF.js";import{e as Q}from"./use-organization-settings-DDeNqP-7.js";import{S as w}from"./constants-B72Xmt_K.js";import{u as F}from"./useInfiniteQuery-BauhQX45.js";import{c as H}from"./use-mcp-client-DwetKDRa.js";import{i as V,f as q}from"./extract-connection-data-CAN-85EW.js";import{C as G}from"./card-BhI7Np_f.js";import{I as U}from"./integration-icon-BnLf1D5y.js";function ae(s){const e=new Map;for(const o of s){const c=_(o),r=e.get(c);r?r.push(o):e.set(c,[o])}const t=[],l=new Set;for(const o of s){const c=_(o);if(l.has(c))continue;l.add(c);const r=e.get(c),m=r[0];r.length===1?t.push({type:"single",connection:m}):t.push({type:"group",key:c,icon:m.icon,title:m.app_name?m.title.replace(/\s*\(\d+\)\s*$/,""):m.title,connections:r})}return t}function ue(){const s=R.c(6),e=K(),t=Q(),l=T().project.enabledPlugins??[];let o;if(s[0]!==l||s[1]!==t||s[2]!==e){let c;s[4]!==t?(c=r=>t(r.id),s[4]=t,s[5]=c):c=s[5],o=e.filter(c).map(X),l.includes("private-registry")&&t(w)&&o.push({id:w,title:"Private Registry",icon:null}),s[0]=l,s[1]=t,s[2]=e,s[3]=o}else o=s[3];return o}function X(s){return{id:s.id,title:s.title,icon:s.icon}}const Y=24,$=3;function A(s){return s.id.includes("community-registry")}function z(s){const e=s?.trim().split(/\s+/).filter(Boolean)??[];if(e.length===0)return;const t=[["title"],["description"],["name"],["server","title"]];return{operator:"or",conditions:e.flatMap(l=>t.map(o=>({field:o,operator:"contains",value:l})))}}function S(s,e,t,l,o){const c=s.map(u=>u.id).sort().join(","),r=z(o),{data:m,fetchNextPage:d,hasNextPage:f,isFetchingNextPage:p,isLoading:P}=F({queryKey:D.storeDiscovery(e,`${c}:${o??""}`),queryFn:async({pageParam:u})=>{const n=u??{};return await Promise.all(s.map(async i=>{const y=n[i.id];if(y==="EXHAUSTED")return{registryId:i.id,registryTitle:i.title,registryIcon:i.icon,items:[]};const j=V(i.id,e);let h;for(let I=0;I<$;I++){let C=null;try{C=await H({connectionId:i.id,orgId:e,orgSlug:t});const v={limit:Y};y&&(v.cursor=y),r&&(v.where=r);const b=await C.callTool({name:j,arguments:v}),N=b.structuredContent??b,M=N.nextCursor||N.cursor||void 0,L=q(N?[N]:[]);return{registryId:i.id,registryTitle:i.title,registryIcon:i.icon,items:L,nextCursor:M}}catch(v){h=v}finally{await C?.close().catch(()=>{})}}return console.warn(`[useMergedStoreDiscovery] Registry "${i.title}" (${i.id}) failed after ${$} attempts:`,h),{registryId:i.id,registryTitle:i.title,registryIcon:i.icon,items:[]}}))},initialPageParam:{},getNextPageParam:u=>{const n={};let a=!1;for(const i of u)i.registryId&&(i.nextCursor?(n[i.registryId]=i.nextCursor,a=!0):n[i.registryId]="EXHAUSTED");return a?n:void 0},staleTime:3600*1e3,placeholderData:k,retry:!1,enabled:s.length>0}),g=[];if(m?.pages)for(const u of m.pages)for(const n of u)for(const a of n.items)g.push({...a,_sourceName:a._sourceName??n.registryTitle,_sourceIcon:a._sourceIcon??n.registryIcon,_registryId:a._registryId??n.registryId});return{items:g,hasMore:f??!1,isLoadingMore:p,isInitialLoading:P,fetchNextPage:()=>{f&&!p&&d()}}}function fe(s,e){const t=R.c(16),{org:l}=T();let o;t[0]!==s?(o=s.filter(W),t[0]=s,t[1]=o):o=t[1];const c=o;let r;t[2]!==s?(r=s.filter(B),t[2]=s,t[3]=r):r=t[3];const m=r,d=S(c,l.id,l.slug,!0,e),f=S(m,l.id,l.slug,!0,e);let p;if(t[4]!==f.items||t[5]!==d.items){const y=new Set;p=[];const j=[...d.items,...f.items];for(const h of j){const I=`${h._registryId}:${h.id}`;y.has(I)||(y.add(I),p.push(h))}t[4]=f.items,t[5]=d.items,t[6]=p}else p=t[6];const P=d.isInitialLoading||f.isInitialLoading,g=d.isLoadingMore||f.isLoadingMore,u=d.hasMore||f.hasMore;let n;t[7]!==f||t[8]!==d?(n=()=>{d.hasMore&&d.fetchNextPage(),f.hasMore&&f.fetchNextPage()},t[7]=f,t[8]=d,t[9]=n):n=t[9];const a=n;let i;return t[10]!==u||t[11]!==P||t[12]!==g||t[13]!==p||t[14]!==a?(i={items:p,hasMore:u,isLoadingMore:g,isInitialLoading:P,loadMore:a},t[10]=u,t[11]=P,t[12]=g,t[13]=p,t[14]=a,t[15]=i):i=t[15],i}function B(s){return A(s)}function W(s){return!A(s)}function de(s){const e=R.c(37),{connection:t,onClick:l,headerActions:o,headerActionsAlwaysVisible:c,body:r,footer:m,className:d,fallbackIcon:f}=s,p=c===void 0?!1:c,P=l&&"hover:bg-muted/50";let g;e[0]!==d||e[1]!==P?(g=E("cursor-pointer transition-colors group overflow-hidden flex flex-col h-full",P,d),e[0]=d,e[1]=P,e[2]=g):g=e[2];let u;e[3]!==t.icon||e[4]!==t.title||e[5]!==f?(u=x.jsx(U,{icon:t.icon,name:t.title,size:"sm",className:"shrink-0 shadow-sm",fallbackIcon:f}),e[3]=t.icon,e[4]=t.title,e[5]=f,e[6]=u):u=e[6];let n;e[7]!==o||e[8]!==p?(n=o&&x.jsx("div",{className:E("transition-opacity",!p&&"sm:opacity-0 sm:group-hover:opacity-100"),onClick:J,children:o}),e[7]=o,e[8]=p,e[9]=n):n=e[9];let a;e[10]!==n?(a=x.jsx("div",{className:"relative",children:n}),e[10]=n,e[11]=a):a=e[11];let i;e[12]!==u||e[13]!==a?(i=x.jsxs("div",{className:"flex items-start justify-between",children:[u,a]}),e[12]=u,e[13]=a,e[14]=i):i=e[14];let y;e[15]!==t.title?(y=x.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:t.title}),e[15]=t.title,e[16]=y):y=e[16];const j=t.description||"No description";let h;e[17]!==j?(h=x.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:j}),e[17]=j,e[18]=h):h=e[18];let I;e[19]!==h||e[20]!==y?(I=x.jsxs("div",{className:"flex flex-col gap-1",children:[y,h]}),e[19]=h,e[20]=y,e[21]=I):I=e[21];let C;e[22]!==r?(C=r&&x.jsx("div",{children:r}),e[22]=r,e[23]=C):C=e[23];let v;e[24]!==I||e[25]!==C||e[26]!==i?(v=x.jsxs("div",{className:"flex flex-col gap-3 p-4.5",children:[i,I,C]}),e[24]=I,e[25]=C,e[26]=i,e[27]=v):v=e[27];let b;e[28]!==m?(b=m&&x.jsx("div",{className:"border-t border-border mt-auto",children:x.jsx("div",{className:"h-14 flex items-center p-4.5",onClick:Z,children:m})}),e[28]=m,e[29]=b):b=e[29];let N;e[30]!==v||e[31]!==b?(N=x.jsxs("div",{className:"flex flex-col flex-1",children:[v,b]}),e[30]=v,e[31]=b,e[32]=N):N=e[32];let M;return e[33]!==l||e[34]!==N||e[35]!==g?(M=x.jsx(G,{className:g,onClick:l,children:N}),e[33]=l,e[34]=N,e[35]=g,e[36]=M):M=e[36],M}function Z(s){return s.stopPropagation()}function J(s){return s.stopPropagation()}export{de as C,fe as a,ae as g,ue as u};
1
+ import{g as _}from"./connection-slug-eyAPH6o3.js";import{c as R,$ as T,aV as k,K as D,l as E,j as x}from"./index-B7JNGFVx.js";import{u as K}from"./use-registry-connections-CxelwF1s.js";import{e as Q}from"./use-organization-settings-D9bn2vMB.js";import{S as w}from"./constants-B72Xmt_K.js";import{u as F}from"./useInfiniteQuery-B3mthAoE.js";import{c as H}from"./use-mcp-client-DvbRbjIF.js";import{i as V,f as q}from"./extract-connection-data-BqrHdbra.js";import{C as G}from"./card-kXMv7TY0.js";import{I as U}from"./integration-icon-BFZYNQuW.js";function ae(s){const e=new Map;for(const o of s){const c=_(o),r=e.get(c);r?r.push(o):e.set(c,[o])}const t=[],l=new Set;for(const o of s){const c=_(o);if(l.has(c))continue;l.add(c);const r=e.get(c),m=r[0];r.length===1?t.push({type:"single",connection:m}):t.push({type:"group",key:c,icon:m.icon,title:m.app_name?m.title.replace(/\s*\(\d+\)\s*$/,""):m.title,connections:r})}return t}function ue(){const s=R.c(6),e=K(),t=Q(),l=T().project.enabledPlugins??[];let o;if(s[0]!==l||s[1]!==t||s[2]!==e){let c;s[4]!==t?(c=r=>t(r.id),s[4]=t,s[5]=c):c=s[5],o=e.filter(c).map(X),l.includes("private-registry")&&t(w)&&o.push({id:w,title:"Private Registry",icon:null}),s[0]=l,s[1]=t,s[2]=e,s[3]=o}else o=s[3];return o}function X(s){return{id:s.id,title:s.title,icon:s.icon}}const Y=24,$=3;function A(s){return s.id.includes("community-registry")}function z(s){const e=s?.trim().split(/\s+/).filter(Boolean)??[];if(e.length===0)return;const t=[["title"],["description"],["name"],["server","title"]];return{operator:"or",conditions:e.flatMap(l=>t.map(o=>({field:o,operator:"contains",value:l})))}}function S(s,e,t,l,o){const c=s.map(u=>u.id).sort().join(","),r=z(o),{data:m,fetchNextPage:d,hasNextPage:f,isFetchingNextPage:p,isLoading:P}=F({queryKey:D.storeDiscovery(e,`${c}:${o??""}`),queryFn:async({pageParam:u})=>{const n=u??{};return await Promise.all(s.map(async i=>{const y=n[i.id];if(y==="EXHAUSTED")return{registryId:i.id,registryTitle:i.title,registryIcon:i.icon,items:[]};const j=V(i.id,e);let h;for(let I=0;I<$;I++){let C=null;try{C=await H({connectionId:i.id,orgId:e,orgSlug:t});const v={limit:Y};y&&(v.cursor=y),r&&(v.where=r);const b=await C.callTool({name:j,arguments:v}),N=b.structuredContent??b,M=N.nextCursor||N.cursor||void 0,L=q(N?[N]:[]);return{registryId:i.id,registryTitle:i.title,registryIcon:i.icon,items:L,nextCursor:M}}catch(v){h=v}finally{await C?.close().catch(()=>{})}}return console.warn(`[useMergedStoreDiscovery] Registry "${i.title}" (${i.id}) failed after ${$} attempts:`,h),{registryId:i.id,registryTitle:i.title,registryIcon:i.icon,items:[]}}))},initialPageParam:{},getNextPageParam:u=>{const n={};let a=!1;for(const i of u)i.registryId&&(i.nextCursor?(n[i.registryId]=i.nextCursor,a=!0):n[i.registryId]="EXHAUSTED");return a?n:void 0},staleTime:3600*1e3,placeholderData:k,retry:!1,enabled:s.length>0}),g=[];if(m?.pages)for(const u of m.pages)for(const n of u)for(const a of n.items)g.push({...a,_sourceName:a._sourceName??n.registryTitle,_sourceIcon:a._sourceIcon??n.registryIcon,_registryId:a._registryId??n.registryId});return{items:g,hasMore:f??!1,isLoadingMore:p,isInitialLoading:P,fetchNextPage:()=>{f&&!p&&d()}}}function fe(s,e){const t=R.c(16),{org:l}=T();let o;t[0]!==s?(o=s.filter(W),t[0]=s,t[1]=o):o=t[1];const c=o;let r;t[2]!==s?(r=s.filter(B),t[2]=s,t[3]=r):r=t[3];const m=r,d=S(c,l.id,l.slug,!0,e),f=S(m,l.id,l.slug,!0,e);let p;if(t[4]!==f.items||t[5]!==d.items){const y=new Set;p=[];const j=[...d.items,...f.items];for(const h of j){const I=`${h._registryId}:${h.id}`;y.has(I)||(y.add(I),p.push(h))}t[4]=f.items,t[5]=d.items,t[6]=p}else p=t[6];const P=d.isInitialLoading||f.isInitialLoading,g=d.isLoadingMore||f.isLoadingMore,u=d.hasMore||f.hasMore;let n;t[7]!==f||t[8]!==d?(n=()=>{d.hasMore&&d.fetchNextPage(),f.hasMore&&f.fetchNextPage()},t[7]=f,t[8]=d,t[9]=n):n=t[9];const a=n;let i;return t[10]!==u||t[11]!==P||t[12]!==g||t[13]!==p||t[14]!==a?(i={items:p,hasMore:u,isLoadingMore:g,isInitialLoading:P,loadMore:a},t[10]=u,t[11]=P,t[12]=g,t[13]=p,t[14]=a,t[15]=i):i=t[15],i}function B(s){return A(s)}function W(s){return!A(s)}function de(s){const e=R.c(37),{connection:t,onClick:l,headerActions:o,headerActionsAlwaysVisible:c,body:r,footer:m,className:d,fallbackIcon:f}=s,p=c===void 0?!1:c,P=l&&"hover:bg-muted/50";let g;e[0]!==d||e[1]!==P?(g=E("cursor-pointer transition-colors group overflow-hidden flex flex-col h-full",P,d),e[0]=d,e[1]=P,e[2]=g):g=e[2];let u;e[3]!==t.icon||e[4]!==t.title||e[5]!==f?(u=x.jsx(U,{icon:t.icon,name:t.title,size:"sm",className:"shrink-0 shadow-sm",fallbackIcon:f}),e[3]=t.icon,e[4]=t.title,e[5]=f,e[6]=u):u=e[6];let n;e[7]!==o||e[8]!==p?(n=o&&x.jsx("div",{className:E("transition-opacity",!p&&"sm:opacity-0 sm:group-hover:opacity-100"),onClick:J,children:o}),e[7]=o,e[8]=p,e[9]=n):n=e[9];let a;e[10]!==n?(a=x.jsx("div",{className:"relative",children:n}),e[10]=n,e[11]=a):a=e[11];let i;e[12]!==u||e[13]!==a?(i=x.jsxs("div",{className:"flex items-start justify-between",children:[u,a]}),e[12]=u,e[13]=a,e[14]=i):i=e[14];let y;e[15]!==t.title?(y=x.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:t.title}),e[15]=t.title,e[16]=y):y=e[16];const j=t.description||"No description";let h;e[17]!==j?(h=x.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:j}),e[17]=j,e[18]=h):h=e[18];let I;e[19]!==h||e[20]!==y?(I=x.jsxs("div",{className:"flex flex-col gap-1",children:[y,h]}),e[19]=h,e[20]=y,e[21]=I):I=e[21];let C;e[22]!==r?(C=r&&x.jsx("div",{children:r}),e[22]=r,e[23]=C):C=e[23];let v;e[24]!==I||e[25]!==C||e[26]!==i?(v=x.jsxs("div",{className:"flex flex-col gap-3 p-4.5",children:[i,I,C]}),e[24]=I,e[25]=C,e[26]=i,e[27]=v):v=e[27];let b;e[28]!==m?(b=m&&x.jsx("div",{className:"border-t border-border mt-auto",children:x.jsx("div",{className:"h-14 flex items-center p-4.5",onClick:Z,children:m})}),e[28]=m,e[29]=b):b=e[29];let N;e[30]!==v||e[31]!==b?(N=x.jsxs("div",{className:"flex flex-col flex-1",children:[v,b]}),e[30]=v,e[31]=b,e[32]=N):N=e[32];let M;return e[33]!==l||e[34]!==N||e[35]!==g?(M=x.jsx(G,{className:g,onClick:l,children:N}),e[33]=l,e[34]=N,e[35]=g,e[36]=M):M=e[36],M}function Z(s){return s.stopPropagation()}function J(s){return s.stopPropagation()}export{de as C,fe as a,ae as g,ue as u};
@@ -1 +1 @@
1
- import{G as he,aa as Ie,a$ as Ae,H as le,a8 as $e,c as P,j as t,i as ge,B as V,r as X,l as je,$ as J,L as De,K as ne,b as Y,aF as ce,W as Pe,b0 as Oe,P as Me,e as ze,b1 as Ee,p as Ve,J as Ue,I as Fe,t as G,b2 as Re}from"./index-CO1L2k6F.js";import{a as Le}from"./extract-connection-data-CAN-85EW.js";import{E as ve}from"./empty-state-B5ZXJOuz.js";import{E as He,c as Be,r as We,b as qe,d as Ge}from"./connection-form-helpers-DwHnDZGX.js";import{c as Xe,S as Ke,V as Qe}from"./index-B9mjAGk9.js";import{u as be,T as Je}from"./tools-list-B9fSZWYy.js";import{u as Ye}from"./use-members-BH7s_bbV.js";import{A as Ze}from"./avatar-B5g154Et.js";import{a as Ne,b as ye,u as et}from"./use-connection-BDpHVnM9.js";import{u as _e}from"./use-mcp-client-DwetKDRa.js";import{a as tt}from"./use-mcp-tools-BUiL0JOE.js";import{a as st}from"./use-mcp-prompts-Dd5bB4_b.js";import{i as nt,a as ot}from"./mcp-oauth-BkvwEKNk.js";import{I as oe}from"./integration-icon-BnLf1D5y.js";import{s as it}from"./Plus-C1-9U7xY.js";import{N as at,O as rt,aq as lt,ak as ct}from"./agent-icon-BxlAfYtU.js";import{a as Ce,s as dt}from"./Settings02-C31aohuM.js";import{s as ae}from"./Trash01-DggFSL1b.js";import{q as mt,p as ut,o as xt,m as pt,n as ft}from"./sidebar-xOgqyAzw.js";import{F as L,b as H,c as B,d as E,e as W,f as ht,a as gt}from"./form-DGt94nWL.js";import{I as q}from"./input-COW4go5N.js";import{u as jt,D as vt}from"./use-delete-connection-CHv507Hm.js";import{c as bt,C as Nt,B as yt,a as _t,b as Ct,d as St,e as wt}from"./monitoring-stats-row-DXsXFCSg.js";import{u as kt}from"./studio-tools-CkzkLbeK.js";import{a as Tt}from"./use-virtual-mcp-KIabF-QC.js";import{i as Se}from"./ChevronRight-3DlxSDpa.js";import{a as we}from"./Users03-OwsRMjku.js";import{b as ee,c as It,T as te,a as At}from"./tabs-CJJv0rqZ.js";import{g as ke}from"./connection-slug-eyAPH6o3.js";import{n as $t}from"./ZapSquare-2TYVPpzw.js";import{d as Dt}from"./Tool01-MLrVuoSu.js";import{g as re,M as Pt}from"./types-CI4ZpBJG.js";import{C as Ot}from"./collection-search-CwUbH4qH.js";import{C as Mt}from"./card-BhI7Np_f.js";import{B as zt}from"./badge-qy7vzuZ8.js";import{D as Et,a as Vt,c as Ut,d as de}from"./dropdown-menu-Zn5Qzoi0.js";import{a as me,c as ue,d as xe,S as pe,b as R}from"./select-B1glqaL5.js";import{i as Ft}from"./CheckCircle-B-AysnVj.js";import{t as Rt}from"./ChevronDown-DDh3Hhw_.js";import{n as Lt}from"./XCircle-Ce3AP-z1.js";import{s as se}from"./Star01-DGbt_SIN.js";import{s as Ht}from"./XClose-Dha2rZyS.js";import"./constants-B72Xmt_K.js";import"./index-CeaSA5WZ.js";import"./ZoomOut-DOMq8Qks.js";import"./Key01-Ca3H4Guz.js";import"./auth-DEpjtwun.js";import"./use-registry-connections-D-CxCgyF.js";import"./use-organization-settings-DDeNqP-7.js";import"./index-rTzepySe.js";import"./index-CDfGnUft.js";import"./index-CiXX-fWm.js";import"./popover-COxSNUI9.js";import"./tooltip-B8UTXuYj.js";import"./Check-tfEbDiSO.js";import"./SearchMd-DiN4RXkm.js";import"./use-mobile-BK99wTJG.js";import"./use-create-virtual-mcp-CyHPTRnR.js";import"./use-navigate-to-agent-C6bEo5XD.js";import"./hooks-CVWEOPPl.js";import"./decopilot-sse-pool-Xn1jBQQZ.js";import"./backoff-CrEUbyZT.js";import"./delay-CnY5UFtP.js";import"./reusable-new-chat-CouMjkYR.js";import"./Eye-BQAd-UWR.js";import"./use-org-auth-client-C_ymtLDP.js";import"./User01-L5odKA9U.js";import"./use-collections-DwtBugWF.js";import"./AlertCircle-k25R3-Si.js";import"./SwitchHorizontal01-C6ZclJC7.js";import"./ArrowUpRight-goUbSV_t.js";import"./Loading02-EeaKovpr.js";import"./ChevronUp-CGRHCTkf.js";import"./Circle-9NU9F6cw.js";import"./Stars02-KrIAmQsB.js";import"./Copy01-v70-83R3.js";import"./DotsVertical-CJNxrPQc.js";import"./Globe01-BJm_6L1K.js";import"./FilterLines-WY77jC6d.js";import"./Globe04-Bvx5rGM6.js";import"./HardDrive-DqhFpjyW.js";import"./LayoutLeft-LgchNodn.js";import"./LinkExternal01-4WLYi2mX.js";import"./List-CP5qu-Ed.js";import"./Monitor01-B7DuF8uL.js";import"./Sun-BdOFeDi1.js";import"./Palette-BDkRrX1I.js";import"./Play-DSAmPT6o.js";import"./SearchLg-CvEhHQsI.js";import"./Shield01-CszvfMrq.js";import"./Stars01-BKEHGK4f.js";import"./Upload01-Cxs1z0Jh.js";import"./Users01-0hD-3O0B.js";import"./X-BSHZ0M6H.js";import"./Zap-MjamIo9C.js";import"./label-D-dsSZO9.js";import"./alert-dialog-9kOsUrrA.js";const Bt=he({scopes:$e(le()).describe("List of scopes available"),stateSchema:Ie(le(),Ae()).describe("JSON Schema (draft-07) defining the state structure")}),Wt=[{name:"MCP_CONFIGURATION",inputSchema:he({}),outputSchema:Bt}];function qt(s){const e=P.c(46),{instance:n,onConfigure:i,onAuthenticate:a,onDelete:o,onToggleStatus:r}=s;let d;e[0]!==n.id?(d={connectionId:n.id},e[0]=n.id,e[1]=d):d=e[1];const l=be(d),x=!(n.connection_type==="VIRTUAL")&&l.supportsOAuth&&!l.isAuthenticated,p=n.status!=="active",c=x||p?"border-destructive/50 bg-destructive/5":"border-transparent";let h;e[2]!==c?(h=je("flex items-center gap-3 rounded-lg border px-4 py-2.5 transition-colors",c),e[2]=c,e[3]=h):h=e[3];let g;e[4]!==n.icon||e[5]!==n.title?(g=t.jsx(oe,{icon:n.icon,name:n.title,size:"xs",className:"shrink-0"}),e[4]=n.icon,e[5]=n.title,e[6]=g):g=e[6];let v;e[7]!==n.title?(v=t.jsx("p",{className:"text-sm font-medium truncate",children:n.title}),e[7]=n.title,e[8]=v):v=e[8];let b;e[9]!==n.status||e[10]!==p||e[11]!==x?(b=x?t.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):p?t.jsx("span",{className:"text-xs text-destructive font-medium",children:n.status==="error"?"Disabled (error)":"Disabled"}):null,e[9]=n.status,e[10]=p,e[11]=x,e[12]=b):b=e[12];let j;e[13]!==v||e[14]!==b?(j=t.jsxs("div",{className:"flex-1 min-w-0",children:[v,b]}),e[13]=v,e[14]=b,e[15]=j):j=e[15];let N;e[16]!==n||e[17]!==x||e[18]!==a?(N=x&&t.jsx(V,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>a(n),children:"Authorize"}),e[16]=n,e[17]=x,e[18]=a,e[19]=N):N=e[19];let T;e[20]!==n||e[21]!==p||e[22]!==r?(T=p?t.jsxs(V,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",onClick:()=>r(n,"active"),children:[t.jsx(at,{size:13}),"Enable"]}):t.jsx(V,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",onClick:()=>r(n,"inactive"),title:"Disable",children:t.jsx(rt,{size:13})}),e[20]=n,e[21]=p,e[22]=r,e[23]=T):T=e[23];let S;e[24]!==n||e[25]!==i?(S=()=>i(n),e[24]=n,e[25]=i,e[26]=S):S=e[26];let y;e[27]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(Ce,{size:13}),e[27]=y):y=e[27];let I;e[28]!==S?(I=t.jsx(V,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:S,title:"Configure",children:y}),e[28]=S,e[29]=I):I=e[29];let _;e[30]!==n||e[31]!==o?(_=()=>o(n),e[30]=n,e[31]=o,e[32]=_):_=e[32];let k;e[33]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(ae,{size:13}),e[33]=k):k=e[33];let C;e[34]!==_?(C=t.jsx(V,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:_,title:"Delete",children:k}),e[34]=_,e[35]=C):C=e[35];let f;e[36]!==I||e[37]!==C||e[38]!==N||e[39]!==T?(f=t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[N,T,I,C]}),e[36]=I,e[37]=C,e[38]=N,e[39]=T,e[40]=f):f=e[40];let w;return e[41]!==f||e[42]!==h||e[43]!==g||e[44]!==j?(w=t.jsxs("div",{className:h,children:[g,j,f]}),e[41]=f,e[42]=h,e[43]=g,e[44]=j,e[45]=w):w=e[45],w}function Gt(s){const e=P.c(15),{instance:n,onConfigure:i}=s;let a;e[0]!==n.icon||e[1]!==n.title?(a=t.jsx(oe,{icon:n.icon,name:n.title,size:"xs",className:"shrink-0"}),e[0]=n.icon,e[1]=n.title,e[2]=a):a=e[2];let o;e[3]!==n.title?(o=t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium truncate",children:n.title})}),e[3]=n.title,e[4]=o):o=e[4];let r;e[5]!==n||e[6]!==i?(r=()=>i(n),e[5]=n,e[6]=i,e[7]=r):r=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(Ce,{size:13}),e[8]=d):d=e[8];let l;e[9]!==r?(l=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:t.jsx(V,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,title:"Configure",children:d})}),e[9]=r,e[10]=l):l=e[10];let u;return e[11]!==a||e[12]!==o||e[13]!==l?(u=t.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-transparent px-4 py-2.5 transition-colors",children:[a,o,l]}),e[11]=a,e[12]=o,e[13]=l,e[14]=u):u=e[14],u}function Xt(s){const e=P.c(27),{instances:n,onConfigure:i,onAuthenticate:a,onDelete:o,onToggleStatus:r,onAdd:d,isAdding:l}=s;if(n.length===0)return null;const u=n.length===1?"Instance":"Instances";let x;e[0]!==u?(x=t.jsx("h3",{className:"text-sm font-semibold text-foreground",children:u}),e[0]=u,e[1]=x):x=e[1];let p;e[2]!==l?(p=l?t.jsx(ge,{size:13,className:"animate-spin"}):t.jsx(it,{size:13}),e[2]=l,e[3]=p):p=e[3];let c;e[4]!==l||e[5]!==d||e[6]!==p?(c=t.jsxs(V,{variant:"default",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:d,disabled:l,children:[p,"Add instance"]}),e[4]=l,e[5]=d,e[6]=p,e[7]=c):c=e[7];let h;e[8]!==x||e[9]!==c?(h=t.jsxs("div",{className:"px-5 py-4 border-b border-border flex items-center justify-between",children:[x,c]}),e[8]=x,e[9]=c,e[10]=h):h=e[10];let g;if(e[11]!==n||e[12]!==a||e[13]!==i||e[14]!==o||e[15]!==r){let j;e[17]!==a||e[18]!==i||e[19]!==o||e[20]!==r?(j=N=>t.jsx(X.Suspense,{fallback:t.jsx(Gt,{instance:N,onConfigure:i}),children:t.jsx(qt,{instance:N,onConfigure:i,onAuthenticate:a,onDelete:o,onToggleStatus:r})},N.id),e[17]=a,e[18]=i,e[19]=o,e[20]=r,e[21]=j):j=e[21],g=n.map(j),e[11]=n,e[12]=a,e[13]=i,e[14]=o,e[15]=r,e[16]=g}else g=e[16];let v;e[22]!==g?(v=t.jsx("div",{className:"p-2 flex flex-col gap-1",children:g}),e[22]=g,e[23]=v):v=e[23];let b;return e[24]!==h||e[25]!==v?(b=t.jsxs("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[h,v]}),e[24]=h,e[25]=v,e[26]=b):b=e[26],b}function Kt(s,e=3){const n=new Map;for(const i of s){if(!i.isError)continue;const a=(i.errorMessage??"").trim()||"Unknown error";n.set(a,(n.get(a)??0)+1)}return[...n.entries()].map(([i,a])=>({message:i,count:a})).sort((i,a)=>a.count-i.count).slice(0,e)}const Qt=[{value:"7d",label:"7d"},{value:"14d",label:"14d"},{value:"30d",label:"30d"}];function Jt(s){const e=new Date,n=new Date(e);return s==="7d"?n.setDate(n.getDate()-7):s==="14d"?n.setDate(n.getDate()-14):n.setDate(n.getDate()-30),{startDate:n,endDate:e}}const Yt={calls:{label:"Tool calls"},errors:{label:"Errors"}};function Zt(s){const e=P.c(1),{connectionId:n,orgId:i,timeframe:a}=s,o=kt(),r=Jt(a),{data:d}=De({queryKey:ne.connectionActivity(n,a,i),queryFn:async()=>await o.call("MONITORING_LOGS_LIST",{startDate:r.startDate.toISOString(),endDate:r.endDate.toISOString(),connectionId:n,limit:2e3,offset:0}),staleTime:3e5}),l=bt(d?.logs??[],r),u=l.data,x=l.totalCalls>0,p=Kt(d?.logs??[]),c=l.totalCalls>0?Math.round(l.totalErrors/l.totalCalls*100):0;let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Tool calls"}),e[0]=h):h=e[0],t.jsxs("div",{children:[t.jsxs("div",{className:"flex gap-6 px-5 pb-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-2xl font-semibold text-foreground tabular-nums",children:l.totalCalls.toLocaleString()}),h]}),l.totalErrors>0&&t.jsxs("div",{children:[t.jsx("p",{className:"text-2xl font-semibold text-destructive tabular-nums",children:l.totalErrors.toLocaleString()}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Errors"})]}),l.avgDurationMs>0&&t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xl font-semibold text-foreground tabular-nums",children:[Math.round(l.avgDurationMs),"ms"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Avg latency"})]})]}),x?t.jsxs("div",{children:[t.jsx(Nt,{config:Yt,className:"h-16 w-full",children:t.jsxs(yt,{data:u,barCategoryGap:"4%",children:[t.jsx(_t,{content:t.jsx(Ct,{labelFormatter:ss}),cursor:{fill:"var(--muted)"}}),t.jsx(St,{dataKey:"calls",radius:[2,2,0,0],minPointSize:1,children:u.map(ts)})]})}),t.jsxs("div",{className:"flex justify-between px-3 mt-1 pb-3",children:[t.jsx("span",{className:"text-[10px] text-muted-foreground",children:u[0]?.label}),t.jsx("span",{className:"text-[10px] text-muted-foreground",children:u[u.length-1]?.label})]})]}):t.jsx("div",{className:"h-20 flex items-center justify-center",children:t.jsx("p",{className:"text-sm text-muted-foreground/60",children:"No activity in this period"})}),p.length>0&&t.jsxs("div",{className:"px-5 py-4 border-t border-border",children:[t.jsxs("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:["Top errors",c>0?` · ${c}% of calls failed`:""]}),t.jsx("ul",{className:"space-y-1.5",children:p.map(es)})]})]})}function es(s){return t.jsxs("li",{className:"flex items-start gap-2 text-xs",children:[t.jsxs("span",{className:"tabular-nums text-destructive font-medium shrink-0",children:[s.count.toLocaleString(),"×"]}),t.jsx("span",{className:"text-muted-foreground truncate",title:s.message,children:s.message})]},s.message)}function ts(s,e){return t.jsx(wt,{fill:s.errorRate>50?"var(--destructive)":"var(--chart-1)",fillOpacity:s.calls===0?.2:s.errorRate>50?.7:.85},`cell-${e}`)}function ss(s,e){const n=Array.isArray(e)?e[0]:void 0;return n&&typeof n=="object"&&"payload"in n?n.payload?.label??"":""}function ns(){const s=P.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("div",{children:[t.jsx("div",{className:"flex gap-6 px-5 pb-4",children:t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("div",{className:"h-7 w-16 rounded-md bg-muted animate-pulse"}),t.jsx("div",{className:"h-3 w-14 rounded bg-muted animate-pulse"})]})}),t.jsx("div",{className:"h-20 w-full rounded-md bg-muted animate-pulse"})]}),s[0]=e):e=s[0],e}function os(s){const e=P.c(13),{connectionId:n}=s,[i,a]=X.useState("14d"),{org:o}=J();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{children:t.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Activity"})}),e[0]=r):r=e[0];let d;e[1]!==i?(d=Qt.map(c=>t.jsx("button",{type:"button",onClick:()=>a(c.value),className:je("px-2.5 py-1 text-xs font-medium rounded-md transition-colors",i===c.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:c.label},c.value)),e[1]=i,e[2]=d):d=e[2];let l;e[3]!==d?(l=t.jsxs("div",{className:"px-5 py-4 flex items-center justify-between",children:[r,t.jsx("div",{className:"flex items-center gap-0.5 bg-muted rounded-lg p-0.5",children:d})]}),e[3]=d,e[4]=l):l=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(ns,{}),e[5]=u):u=e[5];let x;e[6]!==n||e[7]!==o.id||e[8]!==i?(x=t.jsx(X.Suspense,{fallback:u,children:t.jsx(Zt,{connectionId:n,orgId:o.id,timeframe:i})}),e[6]=n,e[7]=o.id,e[8]=i,e[9]=x):x=e[9];let p;return e[10]!==l||e[11]!==x?(p=t.jsxs("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[l,x]}),e[10]=l,e[11]=x,e[12]=p):p=e[12],p}function is(s){const e=P.c(15),{virtualMcp:n,org:i}=s,a=Y();let o;e[0]!==a||e[1]!==i||e[2]!==n.id?(o=()=>{const p=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:i,taskId:p},search:{virtualmcpid:n.id}})},e[0]=a,e[1]=i,e[2]=n.id,e[3]=o):o=e[3];let r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(we,{size:16}),e[4]=r):r=e[4];let d;e[5]!==n.icon||e[6]!==n.title?(d=t.jsx(oe,{icon:n.icon,name:n.title,size:"xs",fallbackIcon:r}),e[5]=n.icon,e[6]=n.title,e[7]=d):d=e[7];let l;e[8]!==n.title?(l=t.jsx("span",{className:"flex-1 text-sm font-medium text-foreground truncate",children:n.title}),e[8]=n.title,e[9]=l):l=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Se,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors shrink-0"}),e[10]=u):u=e[10];let x;return e[11]!==o||e[12]!==d||e[13]!==l?(x=t.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-3 rounded-lg hover:bg-muted/50 transition-colors group text-left w-full",children:[d,l,u]}),e[11]=o,e[12]=d,e[13]=l,e[14]=x):x=e[14],x}function as(s){const e=P.c(7),{virtualMcps:n,org:i}=s;let a;if(e[0]!==i||e[1]!==n){let r;e[3]!==i?(r=d=>t.jsx(is,{virtualMcp:d,org:i},d.id),e[3]=i,e[4]=r):r=e[4],a=n.map(r),e[0]=i,e[1]=n,e[2]=a}else a=e[2];let o;return e[5]!==a?(o=t.jsx("div",{className:"flex flex-col gap-3",children:t.jsx("div",{className:"flex flex-col gap-2",children:a})}),e[5]=a,e[6]=o):o=e[6],o}function rs(s){const e=P.c(7),{connection:n}=s,{org:i}=J();let a;e[0]!==n.id?(a={filters:[{column:"connection_id",value:n.id}]},e[0]=n.id,e[1]=a):a=e[1];const o=Tt(a);if(!(o.length>0)){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(t.Fragment,{}),e[2]=u):u=e[2],u}let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("div",{className:"px-5 py-4 border-b border-border",children:t.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Used by agents"})}),e[3]=d):d=e[3];let l;return e[4]!==i.slug||e[5]!==o?(l=t.jsxs("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[d,t.jsx("div",{className:"px-5 py-4",children:t.jsx(as,{virtualMcps:o,org:i.slug})})]}),e[4]=i.slug,e[5]=o,e[6]=l):l=e[6],l}function ls(s){const e=P.c(31),{tools:n,connectionId:i,org:a}=s,o=Y(),{org:r}=J();let d;e[0]!==i||e[1]!==r.id||e[2]!==r.slug?(d={connectionId:i,orgId:r.id,orgSlug:r.slug},e[0]=i,e[1]=r.id,e[2]=r.slug,e[3]=d):d=e[3];const l=_e(d),u=Ne(i);let x;e[4]!==u||e[5]!==i?(x=u?ke(u):i,e[4]=u,e[5]=i,e[6]=x):x=e[6];const p=x,[c,h]=X.useState("");let g,v,b,j;if(e[7]!==p||e[8]!==l||e[9]!==o||e[10]!==a||e[11]!==c||e[12]!==n){const S=(n??[]).filter(cs),y=c.toLowerCase().trim(),I=y?S.filter(f=>f.name.toLowerCase().includes(y)||f.description&&f.description.toLowerCase().includes(y)):S;let _;e[17]!==p||e[18]!==o||e[19]!==a?(_=f=>{o({to:"/$org/settings/connections/$appSlug/$collectionName/$itemId",params:{org:a,appSlug:p,collectionName:"tools",itemId:encodeURIComponent(f.name)}})},e[17]=p,e[18]=o,e[19]=a,e[20]=_):_=e[20];const k=_;b="flex flex-col h-full overflow-hidden";let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=f=>{f.key==="Escape"&&(h(""),f.target.blur())},e[21]=C):C=e[21],e[22]!==c?(j=t.jsx(Ot,{value:c,onChange:h,placeholder:"Search apps...",onKeyDown:C}),e[22]=c,e[23]=j):j=e[23],g="flex-1 overflow-auto p-5",v=I.length===0?t.jsx(ve,{image:null,title:c?"No apps found":"No apps available",description:c?"Try adjusting your search terms":"This connection doesn't have any tools with interactive UIs yet."}):t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(320px,1fr))] gap-4",children:I.map(f=>{const w=re(f._meta);return t.jsxs(Mt,{className:"cursor-pointer transition-colors overflow-hidden gap-0",onClick:()=>k(f),children:[t.jsx("div",{className:"h-[200px] overflow-hidden border-b border-border",children:t.jsx(Pt,{resourceURI:w,toolInfo:{tool:f},displayMode:"inline",minHeight:200,maxHeight:200,client:l})}),t.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:f.name}),t.jsx(Je,{annotations:f.annotations,_meta:f._meta})]}),f.description&&t.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:f.description})]})]},f.name)})}),e[7]=p,e[8]=l,e[9]=o,e[10]=a,e[11]=c,e[12]=n,e[13]=g,e[14]=v,e[15]=b,e[16]=j}else g=e[13],v=e[14],b=e[15],j=e[16];let N;e[24]!==g||e[25]!==v?(N=t.jsx("div",{className:g,children:v}),e[24]=g,e[25]=v,e[26]=N):N=e[26];let T;return e[27]!==b||e[28]!==j||e[29]!==N?(T=t.jsxs("div",{className:b,children:[j,N]}),e[27]=b,e[28]=j,e[29]=N,e[30]=T):T=e[30],T}function cs(s){return!!re(s._meta)}function Te(s){const e=s.replace(/[._]/g," ").trim().split(/\s+/),n=r=>r.charAt(0).toUpperCase()+r.slice(1),i=new Set(["list","create","get","update","delete","fetch","search","run","trigger","review","send","check"]),a=e.map(n),o=e[e.length-1];return a.length>=2&&o&&i.has(o)?[a.pop(),...a].join(" "):a.join(" ")}function ie(s){const e=P.c(2),{label:n}=s;let i;return e[0]!==n?(i=t.jsx("div",{className:"px-5 py-8 text-center",children:t.jsxs("p",{className:"text-sm text-muted-foreground",children:["No ",n," available."]})}),e[0]=n,e[1]=i):i=e[1],i}function ds(s){const e=P.c(50),{tools:n,prompts:i,resources:a,connectionId:o,org:r}=s;let d;e[0]!==i?(d=i===void 0?[]:i,e[0]=i,e[1]=d):d=e[1];const l=d;let u;e[2]!==a?(u=a===void 0?[]:a,e[2]=a,e[3]=u):u=e[3];const x=u,p=Y(),c=Ne(o??"");let h;e[4]!==c||e[5]!==o?(h=c?ke(c):o,e[4]=c,e[5]=o,e[6]=h):h=e[6];const g=h;let v;e[7]!==g||e[8]!==o||e[9]!==p||e[10]!==r?(v=function($){!o||!r||p({to:"/$org/settings/connections/$appSlug/$collectionName/$itemId",params:{org:r,appSlug:g,collectionName:"tools",itemId:encodeURIComponent($)}})},e[7]=g,e[8]=o,e[9]=p,e[10]=r,e[11]=v):v=e[11];const b=v;let j;e[12]!==o||e[13]!==r||e[14]!==n?(j=o&&r&&n.some(xs),e[12]=o,e[13]=r,e[14]=n,e[15]=j):j=e[15];const N=j;if(n.length+l.length+x.length===0){let m;return e[16]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"rounded-xl border border-border bg-card p-5",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Capabilities"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No capabilities discovered yet. The connection may still be connecting."})]}),e[16]=m):m=e[16],m}let S;e[17]!==n.length?(S=t.jsxs(ee,{value:"tools",variant:"underline",children:["Tools (",n.length,")"]}),e[17]=n.length,e[18]=S):S=e[18];let y;e[19]!==N?(y=N&&t.jsx(ee,{value:"apps",variant:"underline",children:"UI"}),e[19]=N,e[20]=y):y=e[20];let I,_;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(ee,{value:"prompts",variant:"underline",children:"Prompts"}),_=t.jsx(ee,{value:"resources",variant:"underline",children:"Resources"}),e[21]=I,e[22]=_):(I=e[21],_=e[22]);let k;e[23]!==S||e[24]!==y?(k=t.jsx("div",{className:"px-5 flex items-center justify-between border-b border-border",children:t.jsxs(It,{variant:"underline",className:"gap-1",children:[S,y,I,_]})}),e[23]=S,e[24]=y,e[25]=k):k=e[25];let C;e[26]!==b||e[27]!==n?(C=n.length>0?n.map(m=>t.jsxs("button",{type:"button",className:"w-full flex items-start gap-3 px-5 py-3 text-left hover:bg-muted/40 transition-colors cursor-pointer",onClick:()=>b(m.name),children:[t.jsx("div",{className:"mt-0.5 shrink-0 size-7 rounded-md bg-muted flex items-center justify-center",children:t.jsx(Dt,{size:13,className:"text-muted-foreground"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:Te(m.name)}),m.description&&t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed line-clamp-2",children:m.description})]}),t.jsx(Se,{size:16,className:"text-muted-foreground shrink-0 mt-0.5"})]},m.name)):t.jsx(ie,{label:"tools"}),e[26]=b,e[27]=n,e[28]=C):C=e[28];let f;e[29]!==C?(f=t.jsx(te,{value:"tools",className:"h-auto",children:t.jsx("div",{className:"divide-y divide-border",children:C})}),e[29]=C,e[30]=f):f=e[30];let w;e[31]!==o||e[32]!==N||e[33]!==r||e[34]!==n?(w=N&&t.jsx(te,{value:"apps",className:"h-auto min-h-[200px]",children:t.jsx(ls,{tools:n,connectionId:o,org:r})}),e[31]=o,e[32]=N,e[33]=r,e[34]=n,e[35]=w):w=e[35];let M;e[36]!==l?(M=l.length>0?l.map(us):t.jsx(ie,{label:"prompts"}),e[36]=l,e[37]=M):M=e[37];let O;e[38]!==M?(O=t.jsx(te,{value:"prompts",className:"h-auto",children:t.jsx("div",{className:"divide-y divide-border",children:M})}),e[38]=M,e[39]=O):O=e[39];let A;e[40]!==x?(A=x.length>0?x.map(ms):t.jsx(ie,{label:"resources"}),e[40]=x,e[41]=A):A=e[41];let z;e[42]!==A?(z=t.jsx(te,{value:"resources",className:"h-auto",children:t.jsx("div",{className:"divide-y divide-border",children:A})}),e[42]=A,e[43]=z):z=e[43];let U;return e[44]!==k||e[45]!==f||e[46]!==w||e[47]!==O||e[48]!==z?(U=t.jsx("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:t.jsxs(At,{defaultValue:"tools",variant:"underline",children:[k,f,w,O,z]})}),e[44]=k,e[45]=f,e[46]=w,e[47]=O,e[48]=z,e[49]=U):U=e[49],U}function ms(s){return t.jsxs("div",{className:"flex items-start gap-3 px-5 py-3",children:[t.jsx("div",{className:"mt-0.5 shrink-0 size-7 rounded-md bg-muted flex items-center justify-center",children:t.jsx(lt,{size:13,className:"text-muted-foreground"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:s.name}),s.description&&t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed line-clamp-2",children:s.description}),s.uri&&t.jsx("div",{className:"text-xs text-muted-foreground/60 font-mono mt-0.5 truncate",children:s.uri})]})]},s.uri??s.name)}function us(s){return t.jsxs("div",{className:"flex items-start gap-3 px-5 py-3",children:[t.jsx("div",{className:"mt-0.5 shrink-0 size-7 rounded-md bg-muted flex items-center justify-center",children:t.jsx($t,{size:13,className:"text-muted-foreground"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:Te(s.name)}),s.description&&t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed line-clamp-2",children:s.description})]})]},s.name)}function xs(s){return re(s._meta)}function ps(s){const e=P.c(13),{connection:n,displayTitle:i}=s,a=i??n.title;let o;e[0]!==n.icon||e[1]!==a?(o=t.jsx(oe,{icon:n.icon,name:a,size:"xl",className:"shrink-0"}),e[0]=n.icon,e[1]=a,e[2]=o):o=e[2];let r;e[3]!==a?(r=t.jsx("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:t.jsx("h1",{className:"text-lg md:text-xl font-semibold tracking-tight text-foreground leading-none",children:a})}),e[3]=a,e[4]=r):r=e[4];let d;e[5]!==n.description?(d=n.description&&t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed line-clamp-2",children:n.description}),e[5]=n.description,e[6]=d):d=e[6];let l;e[7]!==r||e[8]!==d?(l=t.jsxs("div",{className:"flex-1 min-w-0",children:[r,d]}),e[7]=r,e[8]=d,e[9]=l):l=e[9];let u;return e[10]!==o||e[11]!==l?(u=t.jsxs("div",{className:"flex items-center gap-4 md:gap-6 py-5 md:py-7 px-4 md:px-8 bg-background border-b border-border shrink-0",children:[o,l]}),e[10]=o,e[11]=l,e[12]=u):u=e[12],u}function fs({form:s,connection:e,hasOAuthToken:n,onReauthenticate:i,onRemoveOAuth:a}){const o=ce({control:s.control,name:"ui_type"}),r=ce({control:s.control,name:"connection_url"}),{stdioEnabled:d}=Pe(),l=(()=>{if(typeof r!="string"||!r)return!1;try{const c=new URL(r);return c.hostname==="api.githubcopilot.com"&&c.pathname.replace(/\/+$/,"")==="/mcp"}catch{return!1}})(),u=d||e.connection_type==="STDIO",x=e.connection_type==="VIRTUAL",p=x?Oe(e.connection_url):null;return x?t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Type"}),t.jsxs("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:[t.jsx(we,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm",children:"Virtual MCP"})]}),t.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&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Virtual MCP ID"}),t.jsx("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:t.jsx("code",{className:"text-sm text-muted-foreground",children:p})})]})]}):t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(L,{control:s.control,name:"ui_type",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Connection"}),o!=="NPX"&&o!=="STDIO"?t.jsxs("div",{className:"flex items-stretch rounded-lg border border-border overflow-hidden",children:[t.jsxs(me,{value:c.value,onValueChange:c.onChange,children:[t.jsx(E,{children:t.jsxs(ue,{className:"h-full! w-auto min-w-[90px] border-0 rounded-none bg-muted/50 focus:ring-0 focus:ring-offset-0",children:[t.jsx(se,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t.jsx(xe,{})]})}),t.jsxs(pe,{children:[t.jsx(R,{value:"HTTP",children:"HTTP"}),t.jsx(R,{value:"SSE",children:"SSE"}),t.jsx(R,{value:"Websocket",children:"Websocket"}),u&&t.jsxs(t.Fragment,{children:[t.jsx(R,{value:"NPX",children:"NPX Package"}),t.jsx(R,{value:"STDIO",children:"Custom Command"})]})]})]}),t.jsx("div",{className:"w-px bg-border"}),t.jsx(L,{control:s.control,name:"connection_url",render:({field:h})=>t.jsx(H,{className:"flex-1 min-w-0",children:t.jsx(E,{children:t.jsx(q,{placeholder:"https://example.com/mcp",...h,value:h.value??"",className:"h-10 border-0 rounded-none focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent"})})})})]}):t.jsxs(me,{value:c.value,onValueChange:c.onChange,children:[t.jsx(E,{children:t.jsx(ue,{className:"h-10",children:t.jsx(xe,{})})}),t.jsxs(pe,{children:[t.jsx(R,{value:"HTTP",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(se,{className:"w-4 h-4"}),"HTTP"]})}),t.jsx(R,{value:"SSE",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(se,{className:"w-4 h-4"}),"SSE"]})}),t.jsx(R,{value:"Websocket",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(se,{className:"w-4 h-4"}),"Websocket"]})}),u&&t.jsxs(t.Fragment,{children:[t.jsx(R,{value:"NPX",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Lt,{className:"w-4 h-4"}),"NPX Package"]})}),t.jsx(R,{value:"STDIO",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(ct,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),t.jsx(W,{})]})}),o==="NPX"&&t.jsx(L,{control:s.control,name:"npx_package",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"NPM Package"}),t.jsx(E,{children:t.jsx(q,{placeholder:"@perplexity-ai/mcp-server",...c,value:c.value||"",className:"h-10 rounded-lg"})}),t.jsx(W,{})]})}),o==="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsx(L,{control:s.control,name:"stdio_command",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Command"}),t.jsx(E,{children:t.jsx(q,{placeholder:"node, bun, python...",...c,value:c.value||"",className:"h-10 rounded-lg"})}),t.jsx(W,{})]})}),t.jsx(L,{control:s.control,name:"stdio_args",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Arguments"}),t.jsx(E,{children:t.jsx(q,{placeholder:"arg1 arg2 --flag value",...c,value:c.value||"",className:"h-10 rounded-lg"})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Space-separated arguments"}),t.jsx(W,{})]})})]}),t.jsx(L,{control:s.control,name:"stdio_cwd",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Working Directory"}),t.jsx(E,{children:t.jsx(q,{placeholder:"/path/to/project (optional)",...c,value:c.value||"",className:"h-10 rounded-lg"})}),t.jsx(W,{})]})})]}),(o==="NPX"||o==="STDIO")&&t.jsx(L,{control:s.control,name:"env_vars",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Environment Variables"}),t.jsx(E,{children:t.jsx(He,{value:c.value??[],onChange:c.onChange})}),t.jsx(W,{})]})}),o!=="NPX"&&o!=="STDIO"&&t.jsx(L,{control:s.control,name:"connection_token",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:l?"GitHub Personal Access Token":"Token"}),n?t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs(Et,{children:[t.jsx(Vt,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex items-center gap-1.5 cursor-pointer",children:t.jsxs(zt,{variant:"success",className:"gap-1.5",children:[t.jsx(Ft,{size:12}),"Authenticated via OAuth",t.jsx(Rt,{size:12})]})})}),t.jsxs(Ut,{align:"start",children:[t.jsxs(de,{onClick:i,children:[t.jsx(dt,{size:16}),"Re-authenticate"]}),t.jsxs(de,{variant:"destructive",onClick:a,children:[t.jsx(ae,{size:16}),"Remove OAuth"]})]})]})}):e.connection_token&&c.value===null?t.jsxs("div",{className:"relative group",children:[t.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:"••••••••••••••••"}),t.jsx("button",{type:"button",onClick:()=>c.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:t.jsx(Ht,{size:14,className:"text-muted-foreground"})})]}):t.jsxs(t.Fragment,{children:[t.jsx(E,{children:t.jsx(q,{type:"password",placeholder:l?"Paste your GitHub PAT":"Enter access token...",...c,value:c.value||"",className:"h-10 rounded-lg"})}),l&&t.jsxs(ht,{children:["Create a PAT at"," ",t.jsx("a",{href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"github.com/settings/personal-access-tokens"})]})]}),t.jsx(W,{})]})})]})}function hs(s){return s.command==="npx"}function gs(s){return s.args?.find(e=>!e.startsWith("-"))??""}function js(s){return{command:s.command,args:s.args?.join(" ")??"",cwd:s.cwd??""}}function fe(s,e){const n={title:s.title,description:s.description??"",icon:s.icon??null,configuration_state:s.configuration_state??{},configuration_scopes:s.configuration_scopes||[]};if(s.connection_type==="STDIO"&&Re(s.connection_headers)){const i=s.connection_headers,a=We(i.envVars);if(hs(i)){const r=gs(i);return{...n,ui_type:"NPX",connection_url:"",connection_token:null,npx_package:r,stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:a}}const o=js(i);return{...n,ui_type:"STDIO",connection_url:"",connection_token:null,npx_package:"",stdio_command:o.command,stdio_args:o.args,stdio_cwd:o.cwd,env_vars:a}}return{...n,ui_type:s.connection_type,connection_url:s.connection_url??"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}function vs(s){let e,n=null,i=null,a=null;return s.ui_type==="NPX"?(e="STDIO",n="",a=qe(s.npx_package||"",s.env_vars||[])):s.ui_type==="STDIO"?(e="STDIO",n="",a=Ge(s.stdio_command||"",s.stdio_args||"",s.stdio_cwd,s.env_vars||[])):(e=s.ui_type,n=s.connection_url||"",i=s.connection_token||null),{title:s.title,description:s.description||null,icon:s.icon??null,connection_type:e,connection_url:n,...i&&{connection_token:i},...a&&{connection_headers:a},configuration_state:s.configuration_state??null,configuration_scopes:s.configuration_scopes??null}}function bs({connection:s,connectionId:e,org:n,isUpdating:i,tools:a,prompts:o,resources:r,siblings:d}){const l=Y({from:"/$org/settings/connections/$appSlug"}),u=Ve(),x=ye(),{org:p}=J(),c=jt({onSuccess:()=>{d.length<=1&&l({to:"/$org/settings/connections",params:{org:n}})}}),[h,g]=X.useState(null),[v,b]=X.useState(!1),j=be({connectionId:e}),{data:N}=Ye(),T=N?.data?.members??[],S=h??s,y=T.find(m=>m.userId===S.created_by),_=s?.connection_type==="VIRTUAL"||j.isAuthenticated,k={...s,tools:a},C=Xe(k,Wt),f=Ue({resolver:Fe(Be),values:fe(h??s)}),w=f.formState.isDirty,M=async()=>{if(!await f.trigger())return;const $=f.getValues(),D=vs($),F=h?.id??e;await x.update.mutateAsync({id:F,data:D}),f.reset($)},O=()=>{f.reset(fe(h??s))},A=async m=>{const{token:$,tokenInfo:D,error:F}=await ot({connectionId:m,orgSlug:p.slug,scope:"offline_access"});if(F||!$){G.error(`Authentication failed: ${F}`);return}if(D)try{const K=await fetch(`/api/${p.slug}/connections/${m}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:D.accessToken,refreshToken:D.refreshToken,expiresIn:D.expiresIn,scope:D.scope,clientId:D.clientId,clientSecret:D.clientSecret,tokenEndpoint:D.tokenEndpoint})});if(!K.ok)console.error("Failed to save OAuth token:",await K.text()),await x.update.mutateAsync({id:m,data:{connection_token:$}});else try{await x.update.mutateAsync({id:m,data:{}})}catch(Z){console.warn("Failed to refresh connection tools after OAuth:",Z)}}catch(K){console.error("Error saving OAuth token:",K),await x.update.mutateAsync({id:m,data:{connection_token:$}})}else await x.update.mutateAsync({id:m,data:{connection_token:$}});const Q=new URL(`/api/${p.slug}/mcp/${m}`,window.location.origin);await u.invalidateQueries({queryKey:ne.isMCPAuthenticated(Q.href,null)}),await u.invalidateQueries({queryKey:ne.mcpClientPrefix()}),G.success("Authentication successful")},z=()=>A(s.id),U=async()=>{try{const m=await fetch(`/api/${p.slug}/connections/${s.id}/oauth-token`,{method:"DELETE",credentials:"include"});if(!m.ok){const D=await m.text();G.error(`Failed to remove OAuth: ${D}`);return}const $=new URL(`/api/${p.slug}/mcp/${s.id}`,window.location.origin);await u.invalidateQueries({queryKey:ne.isMCPAuthenticated($.href,null)}),G.success("OAuth removed. You can now re-authenticate with a different account.")}catch(m){console.error("Error removing OAuth token:",m),G.error("Failed to remove OAuth")}};return t.jsxs(t.Fragment,{children:[t.jsx(vt,{...c}),t.jsx(mt,{open:h!==null,onOpenChange:m=>{m||g(null)},children:t.jsxs(ut,{side:"right",className:"sm:max-w-[520px] p-0 flex flex-col gap-0 overflow-hidden",children:[t.jsxs(xt,{className:"px-4 py-3 md:px-6 md:py-4 border-b border-border shrink-0",children:[t.jsx(pt,{className:"text-base",children:h?.title??s.title}),t.jsx(ft,{className:"text-xs",children:"Update URL, authentication, and other settings"}),y&&t.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Connected by"}),t.jsx(Ze,{url:y.user?.image??void 0,fallback:y.user?.name??y.user?.email??"?",size:"3xs",shape:"circle"}),t.jsx("span",{className:"text-xs font-medium text-foreground",children:y.user?.name||y.user?.email})]})]}),t.jsxs(gt,{...f,children:[t.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 md:px-6 md:py-5 flex flex-col gap-4 md:gap-6",children:[t.jsxs("div",{className:"flex flex-col gap-3 md:gap-4",children:[t.jsx(L,{control:f.control,name:"title",render:({field:m})=>t.jsxs(H,{children:[t.jsx(B,{children:"Name"}),t.jsx(E,{children:t.jsx(q,{...m})}),t.jsx(W,{})]})}),t.jsx(L,{control:f.control,name:"description",render:({field:m})=>t.jsxs(H,{children:[t.jsx(B,{children:"Description"}),t.jsx(E,{children:t.jsx(q,{...m,value:m.value||""})}),t.jsx(W,{})]})})]}),t.jsx(fs,{form:f,connection:h??s,hasOAuthToken:j.hasOAuthToken,onReauthenticate:z,onRemoveOAuth:U}),t.jsx(Ke,{connection:h??s,form:f,hasMcpBinding:C,isMCPAuthenticated:_,supportsOAuth:j.supportsOAuth,isServerError:j.isServerError,onAuthenticate:z,onViewReadme:void 0})]}),t.jsxs("div",{className:"px-6 py-4 border-t border-border flex gap-2 shrink-0",children:[t.jsx(V,{onClick:M,disabled:!w||i,className:"flex-1",children:i?"Saving…":"Save changes"}),w&&t.jsx(V,{variant:"outline",onClick:O,children:"Undo"}),t.jsxs(V,{variant:"outline",className:"gap-2 text-muted-foreground hover:text-destructive hover:border-destructive",onClick:()=>{const m=h??s;g(null),c.requestDelete(m)},children:[t.jsx(ae,{size:15}),"Delete"]})]})]},h?.id??s.id)]})}),t.jsx(Qe,{hideHeader:!0,children:t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[t.jsx(ps,{connection:s,displayTitle:(()=>{const m=d[0]??s;return m.app_name?m.title.replace(/\s*\(\d+\)\s*$/,""):m.title})()}),t.jsx("div",{className:"flex-1 overflow-auto @container",children:t.jsxs("div",{className:"grid grid-cols-1 @3xl:grid-cols-2 gap-5 p-6",children:[t.jsx(os,{connectionId:e}),t.jsxs("div",{className:"flex flex-col gap-5",children:[t.jsx(Xt,{instances:d,onConfigure:m=>g(m),onAuthenticate:m=>A(m.id),onDelete:m=>c.requestDelete(m),onToggleStatus:async(m,$)=>{try{await x.update.mutateAsync({id:m.id,data:{status:$}}),G.success($==="active"?"Connection enabled":"Connection disabled")}catch{G.error("Failed to update connection")}},isAdding:v,onAdd:async()=>{b(!0);try{const m=d[0]??s,$=m.title.replace(/\s*\(\d+\)\s*$/,""),D=d.length+1,F=`${$} (${D})`,Q=Le("conn");await x.create.mutateAsync({id:Q,title:F,description:m.description??null,connection_type:m.connection_type,connection_url:m.connection_url??null,connection_token:null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:m.created_by,organization_id:m.organization_id,icon:m.icon??null,app_name:m.app_name??null,app_id:m.app_id??null,connection_headers:m.connection_headers??null,oauth_config:null,configuration_state:m.configuration_state??null,metadata:null,tools:null,bindings:null,status:"inactive"});const K=new URL(`/api/${p.slug}/mcp/${Q}`,window.location.origin),Z=await nt({url:K.href,token:null,orgId:p.id});Z.supportsOAuth&&!Z.isAuthenticated&&await A(Q)}finally{b(!1)}}}),t.jsx(rs,{connection:s})]}),t.jsx("div",{className:"@3xl:col-span-2",children:t.jsx(ds,{tools:a,prompts:o,resources:r,connectionId:e,org:n})})]})})]})})]})}function Ns(){const s=P.c(39);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/$org/settings/connections/$appSlug"},s[0]=e):e=s[0];const n=Y(e);let i;s[1]===Symbol.for("react.memo_cache_sentinel")?(i={from:"/shell/$org/settings/connections/$appSlug"},s[1]=i):i=s[1];const{appSlug:a,org:o}=ze(i),{org:r}=J(),d=ye();let l;s[2]!==a?(l={slug:a},s[2]=a,s[3]=l):l=s[3];const u=et(l),x=u[0]??null,p=x?.id??"",c=p||null;let h;s[4]!==r.id||s[5]!==r.slug||s[6]!==c?(h={connectionId:c,orgId:r.id,orgSlug:r.slug},s[4]=r.id,s[5]=r.slug,s[6]=c,s[7]=h):h=s[7];const g=_e(h);let v;s[8]!==g?(v={client:g},s[8]=g,s[9]=v):v=s[9];const{data:b}=tt(v);let j;if(s[10]!==x?.tools||s[11]!==p||s[12]!==u||s[13]!==b){const A=b?b.tools.map(ks):(x?.tools??[]).map(ws);e:{if(u.length<=1){j=A;break e}const z=new Set,U=[],m=Cs;for(const $ of u){const D=$.id===p?A:m($.tools);for(const F of D)z.has(F.name)||(z.add(F.name),U.push(F))}j=U.length>0?U:A}s[10]=x?.tools,s[11]=p,s[12]=u,s[13]=b,s[14]=j}else j=s[14];const N=j;let T;s[15]!==g?(T={client:g},s[15]=g,s[16]=T):T=s[16];const{data:S}=st(T);let y;s[17]!==g?(y={client:g},s[17]=g,s[18]=y):y=s[18];const{data:I}=Ee(y);let _;s[19]!==S?.prompts?(_=S?.prompts??[],s[19]=S?.prompts,s[20]=_):_=s[20];let k;s[21]!==_?(k=_.map(_s),s[21]=_,s[22]=k):k=s[22];const C=k;let f;s[23]!==I?.resources?(f=I?.resources??[],s[23]=I?.resources,s[24]=f):f=s[24];let w;s[25]!==f?(w=f.map(ys),s[25]=f,s[26]=w):w=s[26];const M=w;if(!x){let A;return s[27]!==n||s[28]!==o?(A=t.jsx("div",{className:"flex h-full w-full bg-background",children:t.jsx(ve,{title:"Connection not found",description:"This connection may have been deleted or you may not have access.",actions:t.jsx(V,{variant:"outline",onClick:()=>n({to:"/$org/settings/connections",params:{org:o}}),children:"Back to connections"})})}),s[27]=n,s[28]=o,s[29]=A):A=s[29],A}let O;return s[30]!==d.update.isPending||s[31]!==N||s[32]!==x||s[33]!==p||s[34]!==o||s[35]!==C||s[36]!==M||s[37]!==u?(O=t.jsx(bs,{org:o,connection:x,connectionId:p,isUpdating:d.update.isPending,tools:N,prompts:C,resources:M,siblings:u}),s[30]=d.update.isPending,s[31]=N,s[32]=x,s[33]=p,s[34]=o,s[35]=C,s[36]=M,s[37]=u,s[38]=O):O=s[38],O}function ys(s){return{name:s.name,description:s.description,uri:s.uri}}function _s(s){return{name:s.name,description:s.description}}function Cs(s){return(s??[]).map(Ss)}function Ss(s){return{name:s.name,description:s.description,inputSchema:s.inputSchema??{},outputSchema:s.outputSchema,annotations:s.annotations,_meta:s._meta}}function ws(s){return{name:s.name,description:s.description,inputSchema:s.inputSchema,outputSchema:s.outputSchema,annotations:s.annotations,_meta:s._meta}}function ks(s){return{name:s.name,description:s.description,inputSchema:s.inputSchema,outputSchema:s.outputSchema,annotations:s.annotations,_meta:s._meta}}function Ts(){const s=P.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Me,{children:t.jsx(X.Suspense,{fallback:t.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:t.jsx(ge,{size:32,className:"animate-spin text-muted-foreground"})}),children:t.jsx(Ns,{})})}),s[0]=e):e=s[0],e}function bo(){const s=P.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ts,{}),s[0]=e):e=s[0],e}export{bo as default};
1
+ import{G as he,aa as Ie,a$ as Ae,H as le,a8 as $e,c as P,j as t,i as ge,B as V,r as X,l as je,$ as J,L as De,K as ne,b as Y,aF as ce,W as Pe,b0 as Oe,P as Me,e as ze,b1 as Ee,p as Ve,J as Ue,I as Fe,t as G,b2 as Re}from"./index-B7JNGFVx.js";import{a as Le}from"./extract-connection-data-BqrHdbra.js";import{E as ve}from"./empty-state-D4qJAGbA.js";import{E as He,c as Be,r as We,b as qe,d as Ge}from"./connection-form-helpers-BwLjgtsz.js";import{c as Xe,S as Ke,V as Qe}from"./index-BVZ_r-K-.js";import{u as be,T as Je}from"./tools-list-BoQVqGkv.js";import{u as Ye}from"./use-members-BDnKuBZb.js";import{A as Ze}from"./avatar-DuOsWYcG.js";import{a as Ne,b as ye,u as et}from"./use-connection-DDhhP7Ph.js";import{u as _e}from"./use-mcp-client-DvbRbjIF.js";import{a as tt}from"./use-mcp-tools-DFWJ7tBv.js";import{a as st}from"./use-mcp-prompts-CYvAbk37.js";import{i as nt,a as ot}from"./mcp-oauth-7gmCRD5I.js";import{I as oe}from"./integration-icon-BFZYNQuW.js";import{s as it}from"./Plus-OhB-LRM_.js";import{N as at,O as rt,aq as lt,ak as ct}from"./agent-icon-D9GYV26D.js";import{a as Ce,s as dt}from"./Settings02-B3B_P5fs.js";import{s as ae}from"./Trash01-CldWiayK.js";import{q as mt,p as ut,o as xt,m as pt,n as ft}from"./sidebar-bjJvb4gf.js";import{F as L,b as H,c as B,d as E,e as W,f as ht,a as gt}from"./form-DsLI-cso.js";import{I as q}from"./input-CHky12sK.js";import{u as jt,D as vt}from"./use-delete-connection-a61PAN9R.js";import{c as bt,C as Nt,B as yt,a as _t,b as Ct,d as St,e as wt}from"./monitoring-stats-row-CJCcXz8y.js";import{u as kt}from"./studio-tools-CXs7tmNe.js";import{a as Tt}from"./use-virtual-mcp-DSK2scNk.js";import{i as Se}from"./ChevronRight-ZwqhPdyq.js";import{a as we}from"./Users03-7hIYOoO1.js";import{b as ee,c as It,T as te,a as At}from"./tabs-ZPYmeZvl.js";import{g as ke}from"./connection-slug-eyAPH6o3.js";import{n as $t}from"./ZapSquare-CO43pmjR.js";import{d as Dt}from"./Tool01-De44pARs.js";import{g as re,M as Pt}from"./types-BCdM8Cqh.js";import{C as Ot}from"./collection-search-BPxsVhJJ.js";import{C as Mt}from"./card-kXMv7TY0.js";import{B as zt}from"./badge-CzvDyOP_.js";import{D as Et,a as Vt,c as Ut,d as de}from"./dropdown-menu-BcNFF_FB.js";import{a as me,c as ue,d as xe,S as pe,b as R}from"./select-djrgFxBF.js";import{i as Ft}from"./CheckCircle-LZxCN5IY.js";import{t as Rt}from"./ChevronDown-DDQcR6fD.js";import{n as Lt}from"./XCircle-BnMyXX6H.js";import{s as se}from"./Star01-CKALy4hI.js";import{s as Ht}from"./XClose-B4Kds20_.js";import"./constants-B72Xmt_K.js";import"./index-CgKTaY8f.js";import"./ZoomOut-DAzAklM3.js";import"./Key01-Dd9wKRX6.js";import"./auth-5F6-aJmo.js";import"./use-registry-connections-CxelwF1s.js";import"./use-organization-settings-D9bn2vMB.js";import"./index-BxU_rwXD.js";import"./index-DN4es646.js";import"./index-CD5Jwhj2.js";import"./popover-Bz_Xru-P.js";import"./tooltip-DfM4QSuK.js";import"./Check-CAm_pNZb.js";import"./SearchMd-OFgwXHVA.js";import"./use-mobile-KXOF-k75.js";import"./use-create-virtual-mcp-_RLJSy4_.js";import"./use-navigate-to-agent-ZdTP31W5.js";import"./hooks-BZkcj2r4.js";import"./decopilot-sse-pool-OlccTr4u.js";import"./backoff-CrEUbyZT.js";import"./delay-CnY5UFtP.js";import"./reusable-new-chat-CouMjkYR.js";import"./Eye-DkQOgqLy.js";import"./use-org-auth-client-C3nOVxFM.js";import"./User01-DICqHJXD.js";import"./use-collections-CD3k8D6X.js";import"./AlertCircle-B9onYPsx.js";import"./SwitchHorizontal01-X4Ivgb48.js";import"./ArrowUpRight-31bYFmB1.js";import"./Loading02-BKjix3t4.js";import"./ChevronUp-CFaryGNc.js";import"./Circle-Cb2xDFmW.js";import"./Stars02-DEytbopx.js";import"./Copy01-CuE5Mdxv.js";import"./DotsVertical-8bp0B0ya.js";import"./Globe01-DBXbzkud.js";import"./FilterLines-DXM-OYLy.js";import"./Globe04-D3KvtDDx.js";import"./HardDrive-C-0ZSA5F.js";import"./LayoutLeft-lNBuuI5W.js";import"./LinkExternal01-D_Rlg4XY.js";import"./List-5gTuVFju.js";import"./Monitor01-BxJdzfiN.js";import"./Sun-C9p5qQM_.js";import"./Palette-DHuaqxQW.js";import"./Play-siKyKpye.js";import"./SearchLg-Cw1vzWS4.js";import"./Shield01-BGz5Kh9w.js";import"./Stars01-CVOa90uJ.js";import"./Upload01-BdN7-z6J.js";import"./Users01-BbT3orCr.js";import"./X-CWu4KAgv.js";import"./Zap-kwvB2Aey.js";import"./label-msw6-gdP.js";import"./alert-dialog-C-4lAz2-.js";const Bt=he({scopes:$e(le()).describe("List of scopes available"),stateSchema:Ie(le(),Ae()).describe("JSON Schema (draft-07) defining the state structure")}),Wt=[{name:"MCP_CONFIGURATION",inputSchema:he({}),outputSchema:Bt}];function qt(s){const e=P.c(46),{instance:n,onConfigure:i,onAuthenticate:a,onDelete:o,onToggleStatus:r}=s;let d;e[0]!==n.id?(d={connectionId:n.id},e[0]=n.id,e[1]=d):d=e[1];const l=be(d),x=!(n.connection_type==="VIRTUAL")&&l.supportsOAuth&&!l.isAuthenticated,p=n.status!=="active",c=x||p?"border-destructive/50 bg-destructive/5":"border-transparent";let h;e[2]!==c?(h=je("flex items-center gap-3 rounded-lg border px-4 py-2.5 transition-colors",c),e[2]=c,e[3]=h):h=e[3];let g;e[4]!==n.icon||e[5]!==n.title?(g=t.jsx(oe,{icon:n.icon,name:n.title,size:"xs",className:"shrink-0"}),e[4]=n.icon,e[5]=n.title,e[6]=g):g=e[6];let v;e[7]!==n.title?(v=t.jsx("p",{className:"text-sm font-medium truncate",children:n.title}),e[7]=n.title,e[8]=v):v=e[8];let b;e[9]!==n.status||e[10]!==p||e[11]!==x?(b=x?t.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):p?t.jsx("span",{className:"text-xs text-destructive font-medium",children:n.status==="error"?"Disabled (error)":"Disabled"}):null,e[9]=n.status,e[10]=p,e[11]=x,e[12]=b):b=e[12];let j;e[13]!==v||e[14]!==b?(j=t.jsxs("div",{className:"flex-1 min-w-0",children:[v,b]}),e[13]=v,e[14]=b,e[15]=j):j=e[15];let N;e[16]!==n||e[17]!==x||e[18]!==a?(N=x&&t.jsx(V,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>a(n),children:"Authorize"}),e[16]=n,e[17]=x,e[18]=a,e[19]=N):N=e[19];let T;e[20]!==n||e[21]!==p||e[22]!==r?(T=p?t.jsxs(V,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",onClick:()=>r(n,"active"),children:[t.jsx(at,{size:13}),"Enable"]}):t.jsx(V,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",onClick:()=>r(n,"inactive"),title:"Disable",children:t.jsx(rt,{size:13})}),e[20]=n,e[21]=p,e[22]=r,e[23]=T):T=e[23];let S;e[24]!==n||e[25]!==i?(S=()=>i(n),e[24]=n,e[25]=i,e[26]=S):S=e[26];let y;e[27]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(Ce,{size:13}),e[27]=y):y=e[27];let I;e[28]!==S?(I=t.jsx(V,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:S,title:"Configure",children:y}),e[28]=S,e[29]=I):I=e[29];let _;e[30]!==n||e[31]!==o?(_=()=>o(n),e[30]=n,e[31]=o,e[32]=_):_=e[32];let k;e[33]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(ae,{size:13}),e[33]=k):k=e[33];let C;e[34]!==_?(C=t.jsx(V,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:_,title:"Delete",children:k}),e[34]=_,e[35]=C):C=e[35];let f;e[36]!==I||e[37]!==C||e[38]!==N||e[39]!==T?(f=t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[N,T,I,C]}),e[36]=I,e[37]=C,e[38]=N,e[39]=T,e[40]=f):f=e[40];let w;return e[41]!==f||e[42]!==h||e[43]!==g||e[44]!==j?(w=t.jsxs("div",{className:h,children:[g,j,f]}),e[41]=f,e[42]=h,e[43]=g,e[44]=j,e[45]=w):w=e[45],w}function Gt(s){const e=P.c(15),{instance:n,onConfigure:i}=s;let a;e[0]!==n.icon||e[1]!==n.title?(a=t.jsx(oe,{icon:n.icon,name:n.title,size:"xs",className:"shrink-0"}),e[0]=n.icon,e[1]=n.title,e[2]=a):a=e[2];let o;e[3]!==n.title?(o=t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium truncate",children:n.title})}),e[3]=n.title,e[4]=o):o=e[4];let r;e[5]!==n||e[6]!==i?(r=()=>i(n),e[5]=n,e[6]=i,e[7]=r):r=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(Ce,{size:13}),e[8]=d):d=e[8];let l;e[9]!==r?(l=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:t.jsx(V,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,title:"Configure",children:d})}),e[9]=r,e[10]=l):l=e[10];let u;return e[11]!==a||e[12]!==o||e[13]!==l?(u=t.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-transparent px-4 py-2.5 transition-colors",children:[a,o,l]}),e[11]=a,e[12]=o,e[13]=l,e[14]=u):u=e[14],u}function Xt(s){const e=P.c(27),{instances:n,onConfigure:i,onAuthenticate:a,onDelete:o,onToggleStatus:r,onAdd:d,isAdding:l}=s;if(n.length===0)return null;const u=n.length===1?"Instance":"Instances";let x;e[0]!==u?(x=t.jsx("h3",{className:"text-sm font-semibold text-foreground",children:u}),e[0]=u,e[1]=x):x=e[1];let p;e[2]!==l?(p=l?t.jsx(ge,{size:13,className:"animate-spin"}):t.jsx(it,{size:13}),e[2]=l,e[3]=p):p=e[3];let c;e[4]!==l||e[5]!==d||e[6]!==p?(c=t.jsxs(V,{variant:"default",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:d,disabled:l,children:[p,"Add instance"]}),e[4]=l,e[5]=d,e[6]=p,e[7]=c):c=e[7];let h;e[8]!==x||e[9]!==c?(h=t.jsxs("div",{className:"px-5 py-4 border-b border-border flex items-center justify-between",children:[x,c]}),e[8]=x,e[9]=c,e[10]=h):h=e[10];let g;if(e[11]!==n||e[12]!==a||e[13]!==i||e[14]!==o||e[15]!==r){let j;e[17]!==a||e[18]!==i||e[19]!==o||e[20]!==r?(j=N=>t.jsx(X.Suspense,{fallback:t.jsx(Gt,{instance:N,onConfigure:i}),children:t.jsx(qt,{instance:N,onConfigure:i,onAuthenticate:a,onDelete:o,onToggleStatus:r})},N.id),e[17]=a,e[18]=i,e[19]=o,e[20]=r,e[21]=j):j=e[21],g=n.map(j),e[11]=n,e[12]=a,e[13]=i,e[14]=o,e[15]=r,e[16]=g}else g=e[16];let v;e[22]!==g?(v=t.jsx("div",{className:"p-2 flex flex-col gap-1",children:g}),e[22]=g,e[23]=v):v=e[23];let b;return e[24]!==h||e[25]!==v?(b=t.jsxs("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[h,v]}),e[24]=h,e[25]=v,e[26]=b):b=e[26],b}function Kt(s,e=3){const n=new Map;for(const i of s){if(!i.isError)continue;const a=(i.errorMessage??"").trim()||"Unknown error";n.set(a,(n.get(a)??0)+1)}return[...n.entries()].map(([i,a])=>({message:i,count:a})).sort((i,a)=>a.count-i.count).slice(0,e)}const Qt=[{value:"7d",label:"7d"},{value:"14d",label:"14d"},{value:"30d",label:"30d"}];function Jt(s){const e=new Date,n=new Date(e);return s==="7d"?n.setDate(n.getDate()-7):s==="14d"?n.setDate(n.getDate()-14):n.setDate(n.getDate()-30),{startDate:n,endDate:e}}const Yt={calls:{label:"Tool calls"},errors:{label:"Errors"}};function Zt(s){const e=P.c(1),{connectionId:n,orgId:i,timeframe:a}=s,o=kt(),r=Jt(a),{data:d}=De({queryKey:ne.connectionActivity(n,a,i),queryFn:async()=>await o.call("MONITORING_LOGS_LIST",{startDate:r.startDate.toISOString(),endDate:r.endDate.toISOString(),connectionId:n,limit:2e3,offset:0}),staleTime:3e5}),l=bt(d?.logs??[],r),u=l.data,x=l.totalCalls>0,p=Kt(d?.logs??[]),c=l.totalCalls>0?Math.round(l.totalErrors/l.totalCalls*100):0;let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Tool calls"}),e[0]=h):h=e[0],t.jsxs("div",{children:[t.jsxs("div",{className:"flex gap-6 px-5 pb-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-2xl font-semibold text-foreground tabular-nums",children:l.totalCalls.toLocaleString()}),h]}),l.totalErrors>0&&t.jsxs("div",{children:[t.jsx("p",{className:"text-2xl font-semibold text-destructive tabular-nums",children:l.totalErrors.toLocaleString()}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Errors"})]}),l.avgDurationMs>0&&t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xl font-semibold text-foreground tabular-nums",children:[Math.round(l.avgDurationMs),"ms"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Avg latency"})]})]}),x?t.jsxs("div",{children:[t.jsx(Nt,{config:Yt,className:"h-16 w-full",children:t.jsxs(yt,{data:u,barCategoryGap:"4%",children:[t.jsx(_t,{content:t.jsx(Ct,{labelFormatter:ss}),cursor:{fill:"var(--muted)"}}),t.jsx(St,{dataKey:"calls",radius:[2,2,0,0],minPointSize:1,children:u.map(ts)})]})}),t.jsxs("div",{className:"flex justify-between px-3 mt-1 pb-3",children:[t.jsx("span",{className:"text-[10px] text-muted-foreground",children:u[0]?.label}),t.jsx("span",{className:"text-[10px] text-muted-foreground",children:u[u.length-1]?.label})]})]}):t.jsx("div",{className:"h-20 flex items-center justify-center",children:t.jsx("p",{className:"text-sm text-muted-foreground/60",children:"No activity in this period"})}),p.length>0&&t.jsxs("div",{className:"px-5 py-4 border-t border-border",children:[t.jsxs("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:["Top errors",c>0?` · ${c}% of calls failed`:""]}),t.jsx("ul",{className:"space-y-1.5",children:p.map(es)})]})]})}function es(s){return t.jsxs("li",{className:"flex items-start gap-2 text-xs",children:[t.jsxs("span",{className:"tabular-nums text-destructive font-medium shrink-0",children:[s.count.toLocaleString(),"×"]}),t.jsx("span",{className:"text-muted-foreground truncate",title:s.message,children:s.message})]},s.message)}function ts(s,e){return t.jsx(wt,{fill:s.errorRate>50?"var(--destructive)":"var(--chart-1)",fillOpacity:s.calls===0?.2:s.errorRate>50?.7:.85},`cell-${e}`)}function ss(s,e){const n=Array.isArray(e)?e[0]:void 0;return n&&typeof n=="object"&&"payload"in n?n.payload?.label??"":""}function ns(){const s=P.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("div",{children:[t.jsx("div",{className:"flex gap-6 px-5 pb-4",children:t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("div",{className:"h-7 w-16 rounded-md bg-muted animate-pulse"}),t.jsx("div",{className:"h-3 w-14 rounded bg-muted animate-pulse"})]})}),t.jsx("div",{className:"h-20 w-full rounded-md bg-muted animate-pulse"})]}),s[0]=e):e=s[0],e}function os(s){const e=P.c(13),{connectionId:n}=s,[i,a]=X.useState("14d"),{org:o}=J();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{children:t.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Activity"})}),e[0]=r):r=e[0];let d;e[1]!==i?(d=Qt.map(c=>t.jsx("button",{type:"button",onClick:()=>a(c.value),className:je("px-2.5 py-1 text-xs font-medium rounded-md transition-colors",i===c.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:c.label},c.value)),e[1]=i,e[2]=d):d=e[2];let l;e[3]!==d?(l=t.jsxs("div",{className:"px-5 py-4 flex items-center justify-between",children:[r,t.jsx("div",{className:"flex items-center gap-0.5 bg-muted rounded-lg p-0.5",children:d})]}),e[3]=d,e[4]=l):l=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(ns,{}),e[5]=u):u=e[5];let x;e[6]!==n||e[7]!==o.id||e[8]!==i?(x=t.jsx(X.Suspense,{fallback:u,children:t.jsx(Zt,{connectionId:n,orgId:o.id,timeframe:i})}),e[6]=n,e[7]=o.id,e[8]=i,e[9]=x):x=e[9];let p;return e[10]!==l||e[11]!==x?(p=t.jsxs("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[l,x]}),e[10]=l,e[11]=x,e[12]=p):p=e[12],p}function is(s){const e=P.c(15),{virtualMcp:n,org:i}=s,a=Y();let o;e[0]!==a||e[1]!==i||e[2]!==n.id?(o=()=>{const p=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:i,taskId:p},search:{virtualmcpid:n.id}})},e[0]=a,e[1]=i,e[2]=n.id,e[3]=o):o=e[3];let r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(we,{size:16}),e[4]=r):r=e[4];let d;e[5]!==n.icon||e[6]!==n.title?(d=t.jsx(oe,{icon:n.icon,name:n.title,size:"xs",fallbackIcon:r}),e[5]=n.icon,e[6]=n.title,e[7]=d):d=e[7];let l;e[8]!==n.title?(l=t.jsx("span",{className:"flex-1 text-sm font-medium text-foreground truncate",children:n.title}),e[8]=n.title,e[9]=l):l=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Se,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors shrink-0"}),e[10]=u):u=e[10];let x;return e[11]!==o||e[12]!==d||e[13]!==l?(x=t.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-3 rounded-lg hover:bg-muted/50 transition-colors group text-left w-full",children:[d,l,u]}),e[11]=o,e[12]=d,e[13]=l,e[14]=x):x=e[14],x}function as(s){const e=P.c(7),{virtualMcps:n,org:i}=s;let a;if(e[0]!==i||e[1]!==n){let r;e[3]!==i?(r=d=>t.jsx(is,{virtualMcp:d,org:i},d.id),e[3]=i,e[4]=r):r=e[4],a=n.map(r),e[0]=i,e[1]=n,e[2]=a}else a=e[2];let o;return e[5]!==a?(o=t.jsx("div",{className:"flex flex-col gap-3",children:t.jsx("div",{className:"flex flex-col gap-2",children:a})}),e[5]=a,e[6]=o):o=e[6],o}function rs(s){const e=P.c(7),{connection:n}=s,{org:i}=J();let a;e[0]!==n.id?(a={filters:[{column:"connection_id",value:n.id}]},e[0]=n.id,e[1]=a):a=e[1];const o=Tt(a);if(!(o.length>0)){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(t.Fragment,{}),e[2]=u):u=e[2],u}let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("div",{className:"px-5 py-4 border-b border-border",children:t.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Used by agents"})}),e[3]=d):d=e[3];let l;return e[4]!==i.slug||e[5]!==o?(l=t.jsxs("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[d,t.jsx("div",{className:"px-5 py-4",children:t.jsx(as,{virtualMcps:o,org:i.slug})})]}),e[4]=i.slug,e[5]=o,e[6]=l):l=e[6],l}function ls(s){const e=P.c(31),{tools:n,connectionId:i,org:a}=s,o=Y(),{org:r}=J();let d;e[0]!==i||e[1]!==r.id||e[2]!==r.slug?(d={connectionId:i,orgId:r.id,orgSlug:r.slug},e[0]=i,e[1]=r.id,e[2]=r.slug,e[3]=d):d=e[3];const l=_e(d),u=Ne(i);let x;e[4]!==u||e[5]!==i?(x=u?ke(u):i,e[4]=u,e[5]=i,e[6]=x):x=e[6];const p=x,[c,h]=X.useState("");let g,v,b,j;if(e[7]!==p||e[8]!==l||e[9]!==o||e[10]!==a||e[11]!==c||e[12]!==n){const S=(n??[]).filter(cs),y=c.toLowerCase().trim(),I=y?S.filter(f=>f.name.toLowerCase().includes(y)||f.description&&f.description.toLowerCase().includes(y)):S;let _;e[17]!==p||e[18]!==o||e[19]!==a?(_=f=>{o({to:"/$org/settings/connections/$appSlug/$collectionName/$itemId",params:{org:a,appSlug:p,collectionName:"tools",itemId:encodeURIComponent(f.name)}})},e[17]=p,e[18]=o,e[19]=a,e[20]=_):_=e[20];const k=_;b="flex flex-col h-full overflow-hidden";let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=f=>{f.key==="Escape"&&(h(""),f.target.blur())},e[21]=C):C=e[21],e[22]!==c?(j=t.jsx(Ot,{value:c,onChange:h,placeholder:"Search apps...",onKeyDown:C}),e[22]=c,e[23]=j):j=e[23],g="flex-1 overflow-auto p-5",v=I.length===0?t.jsx(ve,{image:null,title:c?"No apps found":"No apps available",description:c?"Try adjusting your search terms":"This connection doesn't have any tools with interactive UIs yet."}):t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(320px,1fr))] gap-4",children:I.map(f=>{const w=re(f._meta);return t.jsxs(Mt,{className:"cursor-pointer transition-colors overflow-hidden gap-0",onClick:()=>k(f),children:[t.jsx("div",{className:"h-[200px] overflow-hidden border-b border-border",children:t.jsx(Pt,{resourceURI:w,toolInfo:{tool:f},displayMode:"inline",minHeight:200,maxHeight:200,client:l})}),t.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:f.name}),t.jsx(Je,{annotations:f.annotations,_meta:f._meta})]}),f.description&&t.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:f.description})]})]},f.name)})}),e[7]=p,e[8]=l,e[9]=o,e[10]=a,e[11]=c,e[12]=n,e[13]=g,e[14]=v,e[15]=b,e[16]=j}else g=e[13],v=e[14],b=e[15],j=e[16];let N;e[24]!==g||e[25]!==v?(N=t.jsx("div",{className:g,children:v}),e[24]=g,e[25]=v,e[26]=N):N=e[26];let T;return e[27]!==b||e[28]!==j||e[29]!==N?(T=t.jsxs("div",{className:b,children:[j,N]}),e[27]=b,e[28]=j,e[29]=N,e[30]=T):T=e[30],T}function cs(s){return!!re(s._meta)}function Te(s){const e=s.replace(/[._]/g," ").trim().split(/\s+/),n=r=>r.charAt(0).toUpperCase()+r.slice(1),i=new Set(["list","create","get","update","delete","fetch","search","run","trigger","review","send","check"]),a=e.map(n),o=e[e.length-1];return a.length>=2&&o&&i.has(o)?[a.pop(),...a].join(" "):a.join(" ")}function ie(s){const e=P.c(2),{label:n}=s;let i;return e[0]!==n?(i=t.jsx("div",{className:"px-5 py-8 text-center",children:t.jsxs("p",{className:"text-sm text-muted-foreground",children:["No ",n," available."]})}),e[0]=n,e[1]=i):i=e[1],i}function ds(s){const e=P.c(50),{tools:n,prompts:i,resources:a,connectionId:o,org:r}=s;let d;e[0]!==i?(d=i===void 0?[]:i,e[0]=i,e[1]=d):d=e[1];const l=d;let u;e[2]!==a?(u=a===void 0?[]:a,e[2]=a,e[3]=u):u=e[3];const x=u,p=Y(),c=Ne(o??"");let h;e[4]!==c||e[5]!==o?(h=c?ke(c):o,e[4]=c,e[5]=o,e[6]=h):h=e[6];const g=h;let v;e[7]!==g||e[8]!==o||e[9]!==p||e[10]!==r?(v=function($){!o||!r||p({to:"/$org/settings/connections/$appSlug/$collectionName/$itemId",params:{org:r,appSlug:g,collectionName:"tools",itemId:encodeURIComponent($)}})},e[7]=g,e[8]=o,e[9]=p,e[10]=r,e[11]=v):v=e[11];const b=v;let j;e[12]!==o||e[13]!==r||e[14]!==n?(j=o&&r&&n.some(xs),e[12]=o,e[13]=r,e[14]=n,e[15]=j):j=e[15];const N=j;if(n.length+l.length+x.length===0){let m;return e[16]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"rounded-xl border border-border bg-card p-5",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Capabilities"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No capabilities discovered yet. The connection may still be connecting."})]}),e[16]=m):m=e[16],m}let S;e[17]!==n.length?(S=t.jsxs(ee,{value:"tools",variant:"underline",children:["Tools (",n.length,")"]}),e[17]=n.length,e[18]=S):S=e[18];let y;e[19]!==N?(y=N&&t.jsx(ee,{value:"apps",variant:"underline",children:"UI"}),e[19]=N,e[20]=y):y=e[20];let I,_;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(ee,{value:"prompts",variant:"underline",children:"Prompts"}),_=t.jsx(ee,{value:"resources",variant:"underline",children:"Resources"}),e[21]=I,e[22]=_):(I=e[21],_=e[22]);let k;e[23]!==S||e[24]!==y?(k=t.jsx("div",{className:"px-5 flex items-center justify-between border-b border-border",children:t.jsxs(It,{variant:"underline",className:"gap-1",children:[S,y,I,_]})}),e[23]=S,e[24]=y,e[25]=k):k=e[25];let C;e[26]!==b||e[27]!==n?(C=n.length>0?n.map(m=>t.jsxs("button",{type:"button",className:"w-full flex items-start gap-3 px-5 py-3 text-left hover:bg-muted/40 transition-colors cursor-pointer",onClick:()=>b(m.name),children:[t.jsx("div",{className:"mt-0.5 shrink-0 size-7 rounded-md bg-muted flex items-center justify-center",children:t.jsx(Dt,{size:13,className:"text-muted-foreground"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:Te(m.name)}),m.description&&t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed line-clamp-2",children:m.description})]}),t.jsx(Se,{size:16,className:"text-muted-foreground shrink-0 mt-0.5"})]},m.name)):t.jsx(ie,{label:"tools"}),e[26]=b,e[27]=n,e[28]=C):C=e[28];let f;e[29]!==C?(f=t.jsx(te,{value:"tools",className:"h-auto",children:t.jsx("div",{className:"divide-y divide-border",children:C})}),e[29]=C,e[30]=f):f=e[30];let w;e[31]!==o||e[32]!==N||e[33]!==r||e[34]!==n?(w=N&&t.jsx(te,{value:"apps",className:"h-auto min-h-[200px]",children:t.jsx(ls,{tools:n,connectionId:o,org:r})}),e[31]=o,e[32]=N,e[33]=r,e[34]=n,e[35]=w):w=e[35];let M;e[36]!==l?(M=l.length>0?l.map(us):t.jsx(ie,{label:"prompts"}),e[36]=l,e[37]=M):M=e[37];let O;e[38]!==M?(O=t.jsx(te,{value:"prompts",className:"h-auto",children:t.jsx("div",{className:"divide-y divide-border",children:M})}),e[38]=M,e[39]=O):O=e[39];let A;e[40]!==x?(A=x.length>0?x.map(ms):t.jsx(ie,{label:"resources"}),e[40]=x,e[41]=A):A=e[41];let z;e[42]!==A?(z=t.jsx(te,{value:"resources",className:"h-auto",children:t.jsx("div",{className:"divide-y divide-border",children:A})}),e[42]=A,e[43]=z):z=e[43];let U;return e[44]!==k||e[45]!==f||e[46]!==w||e[47]!==O||e[48]!==z?(U=t.jsx("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:t.jsxs(At,{defaultValue:"tools",variant:"underline",children:[k,f,w,O,z]})}),e[44]=k,e[45]=f,e[46]=w,e[47]=O,e[48]=z,e[49]=U):U=e[49],U}function ms(s){return t.jsxs("div",{className:"flex items-start gap-3 px-5 py-3",children:[t.jsx("div",{className:"mt-0.5 shrink-0 size-7 rounded-md bg-muted flex items-center justify-center",children:t.jsx(lt,{size:13,className:"text-muted-foreground"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:s.name}),s.description&&t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed line-clamp-2",children:s.description}),s.uri&&t.jsx("div",{className:"text-xs text-muted-foreground/60 font-mono mt-0.5 truncate",children:s.uri})]})]},s.uri??s.name)}function us(s){return t.jsxs("div",{className:"flex items-start gap-3 px-5 py-3",children:[t.jsx("div",{className:"mt-0.5 shrink-0 size-7 rounded-md bg-muted flex items-center justify-center",children:t.jsx($t,{size:13,className:"text-muted-foreground"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:Te(s.name)}),s.description&&t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed line-clamp-2",children:s.description})]})]},s.name)}function xs(s){return re(s._meta)}function ps(s){const e=P.c(13),{connection:n,displayTitle:i}=s,a=i??n.title;let o;e[0]!==n.icon||e[1]!==a?(o=t.jsx(oe,{icon:n.icon,name:a,size:"xl",className:"shrink-0"}),e[0]=n.icon,e[1]=a,e[2]=o):o=e[2];let r;e[3]!==a?(r=t.jsx("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:t.jsx("h1",{className:"text-lg md:text-xl font-semibold tracking-tight text-foreground leading-none",children:a})}),e[3]=a,e[4]=r):r=e[4];let d;e[5]!==n.description?(d=n.description&&t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed line-clamp-2",children:n.description}),e[5]=n.description,e[6]=d):d=e[6];let l;e[7]!==r||e[8]!==d?(l=t.jsxs("div",{className:"flex-1 min-w-0",children:[r,d]}),e[7]=r,e[8]=d,e[9]=l):l=e[9];let u;return e[10]!==o||e[11]!==l?(u=t.jsxs("div",{className:"flex items-center gap-4 md:gap-6 py-5 md:py-7 px-4 md:px-8 bg-background border-b border-border shrink-0",children:[o,l]}),e[10]=o,e[11]=l,e[12]=u):u=e[12],u}function fs({form:s,connection:e,hasOAuthToken:n,onReauthenticate:i,onRemoveOAuth:a}){const o=ce({control:s.control,name:"ui_type"}),r=ce({control:s.control,name:"connection_url"}),{stdioEnabled:d}=Pe(),l=(()=>{if(typeof r!="string"||!r)return!1;try{const c=new URL(r);return c.hostname==="api.githubcopilot.com"&&c.pathname.replace(/\/+$/,"")==="/mcp"}catch{return!1}})(),u=d||e.connection_type==="STDIO",x=e.connection_type==="VIRTUAL",p=x?Oe(e.connection_url):null;return x?t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Type"}),t.jsxs("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:[t.jsx(we,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm",children:"Virtual MCP"})]}),t.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&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Virtual MCP ID"}),t.jsx("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:t.jsx("code",{className:"text-sm text-muted-foreground",children:p})})]})]}):t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(L,{control:s.control,name:"ui_type",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Connection"}),o!=="NPX"&&o!=="STDIO"?t.jsxs("div",{className:"flex items-stretch rounded-lg border border-border overflow-hidden",children:[t.jsxs(me,{value:c.value,onValueChange:c.onChange,children:[t.jsx(E,{children:t.jsxs(ue,{className:"h-full! w-auto min-w-[90px] border-0 rounded-none bg-muted/50 focus:ring-0 focus:ring-offset-0",children:[t.jsx(se,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t.jsx(xe,{})]})}),t.jsxs(pe,{children:[t.jsx(R,{value:"HTTP",children:"HTTP"}),t.jsx(R,{value:"SSE",children:"SSE"}),t.jsx(R,{value:"Websocket",children:"Websocket"}),u&&t.jsxs(t.Fragment,{children:[t.jsx(R,{value:"NPX",children:"NPX Package"}),t.jsx(R,{value:"STDIO",children:"Custom Command"})]})]})]}),t.jsx("div",{className:"w-px bg-border"}),t.jsx(L,{control:s.control,name:"connection_url",render:({field:h})=>t.jsx(H,{className:"flex-1 min-w-0",children:t.jsx(E,{children:t.jsx(q,{placeholder:"https://example.com/mcp",...h,value:h.value??"",className:"h-10 border-0 rounded-none focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent"})})})})]}):t.jsxs(me,{value:c.value,onValueChange:c.onChange,children:[t.jsx(E,{children:t.jsx(ue,{className:"h-10",children:t.jsx(xe,{})})}),t.jsxs(pe,{children:[t.jsx(R,{value:"HTTP",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(se,{className:"w-4 h-4"}),"HTTP"]})}),t.jsx(R,{value:"SSE",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(se,{className:"w-4 h-4"}),"SSE"]})}),t.jsx(R,{value:"Websocket",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(se,{className:"w-4 h-4"}),"Websocket"]})}),u&&t.jsxs(t.Fragment,{children:[t.jsx(R,{value:"NPX",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Lt,{className:"w-4 h-4"}),"NPX Package"]})}),t.jsx(R,{value:"STDIO",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(ct,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),t.jsx(W,{})]})}),o==="NPX"&&t.jsx(L,{control:s.control,name:"npx_package",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"NPM Package"}),t.jsx(E,{children:t.jsx(q,{placeholder:"@perplexity-ai/mcp-server",...c,value:c.value||"",className:"h-10 rounded-lg"})}),t.jsx(W,{})]})}),o==="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsx(L,{control:s.control,name:"stdio_command",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Command"}),t.jsx(E,{children:t.jsx(q,{placeholder:"node, bun, python...",...c,value:c.value||"",className:"h-10 rounded-lg"})}),t.jsx(W,{})]})}),t.jsx(L,{control:s.control,name:"stdio_args",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Arguments"}),t.jsx(E,{children:t.jsx(q,{placeholder:"arg1 arg2 --flag value",...c,value:c.value||"",className:"h-10 rounded-lg"})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Space-separated arguments"}),t.jsx(W,{})]})})]}),t.jsx(L,{control:s.control,name:"stdio_cwd",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Working Directory"}),t.jsx(E,{children:t.jsx(q,{placeholder:"/path/to/project (optional)",...c,value:c.value||"",className:"h-10 rounded-lg"})}),t.jsx(W,{})]})})]}),(o==="NPX"||o==="STDIO")&&t.jsx(L,{control:s.control,name:"env_vars",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:"Environment Variables"}),t.jsx(E,{children:t.jsx(He,{value:c.value??[],onChange:c.onChange})}),t.jsx(W,{})]})}),o!=="NPX"&&o!=="STDIO"&&t.jsx(L,{control:s.control,name:"connection_token",render:({field:c})=>t.jsxs(H,{className:"flex flex-col gap-3",children:[t.jsx(B,{className:"text-xs text-muted-foreground font-medium",children:l?"GitHub Personal Access Token":"Token"}),n?t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs(Et,{children:[t.jsx(Vt,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex items-center gap-1.5 cursor-pointer",children:t.jsxs(zt,{variant:"success",className:"gap-1.5",children:[t.jsx(Ft,{size:12}),"Authenticated via OAuth",t.jsx(Rt,{size:12})]})})}),t.jsxs(Ut,{align:"start",children:[t.jsxs(de,{onClick:i,children:[t.jsx(dt,{size:16}),"Re-authenticate"]}),t.jsxs(de,{variant:"destructive",onClick:a,children:[t.jsx(ae,{size:16}),"Remove OAuth"]})]})]})}):e.connection_token&&c.value===null?t.jsxs("div",{className:"relative group",children:[t.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:"••••••••••••••••"}),t.jsx("button",{type:"button",onClick:()=>c.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:t.jsx(Ht,{size:14,className:"text-muted-foreground"})})]}):t.jsxs(t.Fragment,{children:[t.jsx(E,{children:t.jsx(q,{type:"password",placeholder:l?"Paste your GitHub PAT":"Enter access token...",...c,value:c.value||"",className:"h-10 rounded-lg"})}),l&&t.jsxs(ht,{children:["Create a PAT at"," ",t.jsx("a",{href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"github.com/settings/personal-access-tokens"})]})]}),t.jsx(W,{})]})})]})}function hs(s){return s.command==="npx"}function gs(s){return s.args?.find(e=>!e.startsWith("-"))??""}function js(s){return{command:s.command,args:s.args?.join(" ")??"",cwd:s.cwd??""}}function fe(s,e){const n={title:s.title,description:s.description??"",icon:s.icon??null,configuration_state:s.configuration_state??{},configuration_scopes:s.configuration_scopes||[]};if(s.connection_type==="STDIO"&&Re(s.connection_headers)){const i=s.connection_headers,a=We(i.envVars);if(hs(i)){const r=gs(i);return{...n,ui_type:"NPX",connection_url:"",connection_token:null,npx_package:r,stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:a}}const o=js(i);return{...n,ui_type:"STDIO",connection_url:"",connection_token:null,npx_package:"",stdio_command:o.command,stdio_args:o.args,stdio_cwd:o.cwd,env_vars:a}}return{...n,ui_type:s.connection_type,connection_url:s.connection_url??"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}function vs(s){let e,n=null,i=null,a=null;return s.ui_type==="NPX"?(e="STDIO",n="",a=qe(s.npx_package||"",s.env_vars||[])):s.ui_type==="STDIO"?(e="STDIO",n="",a=Ge(s.stdio_command||"",s.stdio_args||"",s.stdio_cwd,s.env_vars||[])):(e=s.ui_type,n=s.connection_url||"",i=s.connection_token||null),{title:s.title,description:s.description||null,icon:s.icon??null,connection_type:e,connection_url:n,...i&&{connection_token:i},...a&&{connection_headers:a},configuration_state:s.configuration_state??null,configuration_scopes:s.configuration_scopes??null}}function bs({connection:s,connectionId:e,org:n,isUpdating:i,tools:a,prompts:o,resources:r,siblings:d}){const l=Y({from:"/$org/settings/connections/$appSlug"}),u=Ve(),x=ye(),{org:p}=J(),c=jt({onSuccess:()=>{d.length<=1&&l({to:"/$org/settings/connections",params:{org:n}})}}),[h,g]=X.useState(null),[v,b]=X.useState(!1),j=be({connectionId:e}),{data:N}=Ye(),T=N?.data?.members??[],S=h??s,y=T.find(m=>m.userId===S.created_by),_=s?.connection_type==="VIRTUAL"||j.isAuthenticated,k={...s,tools:a},C=Xe(k,Wt),f=Ue({resolver:Fe(Be),values:fe(h??s)}),w=f.formState.isDirty,M=async()=>{if(!await f.trigger())return;const $=f.getValues(),D=vs($),F=h?.id??e;await x.update.mutateAsync({id:F,data:D}),f.reset($)},O=()=>{f.reset(fe(h??s))},A=async m=>{const{token:$,tokenInfo:D,error:F}=await ot({connectionId:m,orgSlug:p.slug,scope:"offline_access"});if(F||!$){G.error(`Authentication failed: ${F}`);return}if(D)try{const K=await fetch(`/api/${p.slug}/connections/${m}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:D.accessToken,refreshToken:D.refreshToken,expiresIn:D.expiresIn,scope:D.scope,clientId:D.clientId,clientSecret:D.clientSecret,tokenEndpoint:D.tokenEndpoint})});if(!K.ok)console.error("Failed to save OAuth token:",await K.text()),await x.update.mutateAsync({id:m,data:{connection_token:$}});else try{await x.update.mutateAsync({id:m,data:{}})}catch(Z){console.warn("Failed to refresh connection tools after OAuth:",Z)}}catch(K){console.error("Error saving OAuth token:",K),await x.update.mutateAsync({id:m,data:{connection_token:$}})}else await x.update.mutateAsync({id:m,data:{connection_token:$}});const Q=new URL(`/api/${p.slug}/mcp/${m}`,window.location.origin);await u.invalidateQueries({queryKey:ne.isMCPAuthenticated(Q.href,null)}),await u.invalidateQueries({queryKey:ne.mcpClientPrefix()}),G.success("Authentication successful")},z=()=>A(s.id),U=async()=>{try{const m=await fetch(`/api/${p.slug}/connections/${s.id}/oauth-token`,{method:"DELETE",credentials:"include"});if(!m.ok){const D=await m.text();G.error(`Failed to remove OAuth: ${D}`);return}const $=new URL(`/api/${p.slug}/mcp/${s.id}`,window.location.origin);await u.invalidateQueries({queryKey:ne.isMCPAuthenticated($.href,null)}),G.success("OAuth removed. You can now re-authenticate with a different account.")}catch(m){console.error("Error removing OAuth token:",m),G.error("Failed to remove OAuth")}};return t.jsxs(t.Fragment,{children:[t.jsx(vt,{...c}),t.jsx(mt,{open:h!==null,onOpenChange:m=>{m||g(null)},children:t.jsxs(ut,{side:"right",className:"sm:max-w-[520px] p-0 flex flex-col gap-0 overflow-hidden",children:[t.jsxs(xt,{className:"px-4 py-3 md:px-6 md:py-4 border-b border-border shrink-0",children:[t.jsx(pt,{className:"text-base",children:h?.title??s.title}),t.jsx(ft,{className:"text-xs",children:"Update URL, authentication, and other settings"}),y&&t.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Connected by"}),t.jsx(Ze,{url:y.user?.image??void 0,fallback:y.user?.name??y.user?.email??"?",size:"3xs",shape:"circle"}),t.jsx("span",{className:"text-xs font-medium text-foreground",children:y.user?.name||y.user?.email})]})]}),t.jsxs(gt,{...f,children:[t.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 md:px-6 md:py-5 flex flex-col gap-4 md:gap-6",children:[t.jsxs("div",{className:"flex flex-col gap-3 md:gap-4",children:[t.jsx(L,{control:f.control,name:"title",render:({field:m})=>t.jsxs(H,{children:[t.jsx(B,{children:"Name"}),t.jsx(E,{children:t.jsx(q,{...m})}),t.jsx(W,{})]})}),t.jsx(L,{control:f.control,name:"description",render:({field:m})=>t.jsxs(H,{children:[t.jsx(B,{children:"Description"}),t.jsx(E,{children:t.jsx(q,{...m,value:m.value||""})}),t.jsx(W,{})]})})]}),t.jsx(fs,{form:f,connection:h??s,hasOAuthToken:j.hasOAuthToken,onReauthenticate:z,onRemoveOAuth:U}),t.jsx(Ke,{connection:h??s,form:f,hasMcpBinding:C,isMCPAuthenticated:_,supportsOAuth:j.supportsOAuth,isServerError:j.isServerError,onAuthenticate:z,onViewReadme:void 0})]}),t.jsxs("div",{className:"px-6 py-4 border-t border-border flex gap-2 shrink-0",children:[t.jsx(V,{onClick:M,disabled:!w||i,className:"flex-1",children:i?"Saving…":"Save changes"}),w&&t.jsx(V,{variant:"outline",onClick:O,children:"Undo"}),t.jsxs(V,{variant:"outline",className:"gap-2 text-muted-foreground hover:text-destructive hover:border-destructive",onClick:()=>{const m=h??s;g(null),c.requestDelete(m)},children:[t.jsx(ae,{size:15}),"Delete"]})]})]},h?.id??s.id)]})}),t.jsx(Qe,{hideHeader:!0,children:t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[t.jsx(ps,{connection:s,displayTitle:(()=>{const m=d[0]??s;return m.app_name?m.title.replace(/\s*\(\d+\)\s*$/,""):m.title})()}),t.jsx("div",{className:"flex-1 overflow-auto @container",children:t.jsxs("div",{className:"grid grid-cols-1 @3xl:grid-cols-2 gap-5 p-6",children:[t.jsx(os,{connectionId:e}),t.jsxs("div",{className:"flex flex-col gap-5",children:[t.jsx(Xt,{instances:d,onConfigure:m=>g(m),onAuthenticate:m=>A(m.id),onDelete:m=>c.requestDelete(m),onToggleStatus:async(m,$)=>{try{await x.update.mutateAsync({id:m.id,data:{status:$}}),G.success($==="active"?"Connection enabled":"Connection disabled")}catch{G.error("Failed to update connection")}},isAdding:v,onAdd:async()=>{b(!0);try{const m=d[0]??s,$=m.title.replace(/\s*\(\d+\)\s*$/,""),D=d.length+1,F=`${$} (${D})`,Q=Le("conn");await x.create.mutateAsync({id:Q,title:F,description:m.description??null,connection_type:m.connection_type,connection_url:m.connection_url??null,connection_token:null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:m.created_by,organization_id:m.organization_id,icon:m.icon??null,app_name:m.app_name??null,app_id:m.app_id??null,connection_headers:m.connection_headers??null,oauth_config:null,configuration_state:m.configuration_state??null,metadata:null,tools:null,bindings:null,status:"inactive"});const K=new URL(`/api/${p.slug}/mcp/${Q}`,window.location.origin),Z=await nt({url:K.href,token:null,orgId:p.id});Z.supportsOAuth&&!Z.isAuthenticated&&await A(Q)}finally{b(!1)}}}),t.jsx(rs,{connection:s})]}),t.jsx("div",{className:"@3xl:col-span-2",children:t.jsx(ds,{tools:a,prompts:o,resources:r,connectionId:e,org:n})})]})})]})})]})}function Ns(){const s=P.c(39);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/$org/settings/connections/$appSlug"},s[0]=e):e=s[0];const n=Y(e);let i;s[1]===Symbol.for("react.memo_cache_sentinel")?(i={from:"/shell/$org/settings/connections/$appSlug"},s[1]=i):i=s[1];const{appSlug:a,org:o}=ze(i),{org:r}=J(),d=ye();let l;s[2]!==a?(l={slug:a},s[2]=a,s[3]=l):l=s[3];const u=et(l),x=u[0]??null,p=x?.id??"",c=p||null;let h;s[4]!==r.id||s[5]!==r.slug||s[6]!==c?(h={connectionId:c,orgId:r.id,orgSlug:r.slug},s[4]=r.id,s[5]=r.slug,s[6]=c,s[7]=h):h=s[7];const g=_e(h);let v;s[8]!==g?(v={client:g},s[8]=g,s[9]=v):v=s[9];const{data:b}=tt(v);let j;if(s[10]!==x?.tools||s[11]!==p||s[12]!==u||s[13]!==b){const A=b?b.tools.map(ks):(x?.tools??[]).map(ws);e:{if(u.length<=1){j=A;break e}const z=new Set,U=[],m=Cs;for(const $ of u){const D=$.id===p?A:m($.tools);for(const F of D)z.has(F.name)||(z.add(F.name),U.push(F))}j=U.length>0?U:A}s[10]=x?.tools,s[11]=p,s[12]=u,s[13]=b,s[14]=j}else j=s[14];const N=j;let T;s[15]!==g?(T={client:g},s[15]=g,s[16]=T):T=s[16];const{data:S}=st(T);let y;s[17]!==g?(y={client:g},s[17]=g,s[18]=y):y=s[18];const{data:I}=Ee(y);let _;s[19]!==S?.prompts?(_=S?.prompts??[],s[19]=S?.prompts,s[20]=_):_=s[20];let k;s[21]!==_?(k=_.map(_s),s[21]=_,s[22]=k):k=s[22];const C=k;let f;s[23]!==I?.resources?(f=I?.resources??[],s[23]=I?.resources,s[24]=f):f=s[24];let w;s[25]!==f?(w=f.map(ys),s[25]=f,s[26]=w):w=s[26];const M=w;if(!x){let A;return s[27]!==n||s[28]!==o?(A=t.jsx("div",{className:"flex h-full w-full bg-background",children:t.jsx(ve,{title:"Connection not found",description:"This connection may have been deleted or you may not have access.",actions:t.jsx(V,{variant:"outline",onClick:()=>n({to:"/$org/settings/connections",params:{org:o}}),children:"Back to connections"})})}),s[27]=n,s[28]=o,s[29]=A):A=s[29],A}let O;return s[30]!==d.update.isPending||s[31]!==N||s[32]!==x||s[33]!==p||s[34]!==o||s[35]!==C||s[36]!==M||s[37]!==u?(O=t.jsx(bs,{org:o,connection:x,connectionId:p,isUpdating:d.update.isPending,tools:N,prompts:C,resources:M,siblings:u}),s[30]=d.update.isPending,s[31]=N,s[32]=x,s[33]=p,s[34]=o,s[35]=C,s[36]=M,s[37]=u,s[38]=O):O=s[38],O}function ys(s){return{name:s.name,description:s.description,uri:s.uri}}function _s(s){return{name:s.name,description:s.description}}function Cs(s){return(s??[]).map(Ss)}function Ss(s){return{name:s.name,description:s.description,inputSchema:s.inputSchema??{},outputSchema:s.outputSchema,annotations:s.annotations,_meta:s._meta}}function ws(s){return{name:s.name,description:s.description,inputSchema:s.inputSchema,outputSchema:s.outputSchema,annotations:s.annotations,_meta:s._meta}}function ks(s){return{name:s.name,description:s.description,inputSchema:s.inputSchema,outputSchema:s.outputSchema,annotations:s.annotations,_meta:s._meta}}function Ts(){const s=P.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Me,{children:t.jsx(X.Suspense,{fallback:t.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:t.jsx(ge,{size:32,className:"animate-spin text-muted-foreground"})}),children:t.jsx(Ns,{})})}),s[0]=e):e=s[0],e}function bo(){const s=P.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ts,{}),s[0]=e):e=s[0],e}export{bo as default};