decocms 4.181.2 → 4.181.3

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 (235) hide show
  1. package/dist/client/assets/{AlertCircle-DhwfTi65.js → AlertCircle-BTxQkLh_.js} +1 -1
  2. package/dist/client/assets/{AreaChart-CXKI3JpY.js → AreaChart-54GTf9Wv.js} +1 -1
  3. package/dist/client/assets/{ArrowUp-BWR9dQl8.js → ArrowUp-CiT0cU4D.js} +1 -1
  4. package/dist/client/assets/{ArrowUpRight-D4qu9qE6.js → ArrowUpRight-KmOQGUGd.js} +1 -1
  5. package/dist/client/assets/{Check-7fe09mMg.js → Check-Dw-gymvq.js} +1 -1
  6. package/dist/client/assets/{CheckCircle-D5saJ3-2.js → CheckCircle-CJSSqHjK.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-DFqNx4Ma.js → ChevronDown-DJaWgVC0.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-CRnb0aSS.js → ChevronRight-DLaD7kHP.js} +1 -1
  9. package/dist/client/assets/{ChevronUp-CvH3Jbpe.js → ChevronUp-C4i-02np.js} +1 -1
  10. package/dist/client/assets/{Copy01-CCrRD_v-.js → Copy01-Cmo8Ag8o.js} +1 -1
  11. package/dist/client/assets/{CpuChip01-Cm6Xgyie.js → CpuChip01-K-xlLMGB.js} +1 -1
  12. package/dist/client/assets/{CreditCard01-CNzw0ddZ.js → CreditCard01-CmetOEMF.js} +1 -1
  13. package/dist/client/assets/{DotsVertical-6MyHH5sK.js → DotsVertical-BH53E0xj.js} +1 -1
  14. package/dist/client/assets/{Eye-D2tsgwEB.js → Eye-B6gNJQkZ.js} +1 -1
  15. package/dist/client/assets/{FilterLines--Qcv2fTv.js → FilterLines-Cpf5z5Iu.js} +1 -1
  16. package/dist/client/assets/{HardDrive-_f2c9Jkk.js → HardDrive-Dv_gzUWs.js} +1 -1
  17. package/dist/client/assets/{Key01-1xwZnZcu.js → Key01-ai3raIR8.js} +1 -1
  18. package/dist/client/assets/{LayoutLeft-D19TYd87.js → LayoutLeft-BUkBSDrI.js} +1 -1
  19. package/dist/client/assets/{LinkExternal01-Dw7qYNHV.js → LinkExternal01-C_HyHuei.js} +1 -1
  20. package/dist/client/assets/{LogOut01-BLN2nxXZ.js → LogOut01-CcD6g7YP.js} +1 -1
  21. package/dist/client/assets/{Monitor01-DoHemlFB.js → Monitor01-DH8zVvcw.js} +1 -1
  22. package/dist/client/assets/{Palette-DQn4hdOZ.js → Palette-BVF7aPzx.js} +1 -1
  23. package/dist/client/assets/{Play-Dtsx6JqS.js → Play-DktqrYeq.js} +1 -1
  24. package/dist/client/assets/{Plus-fsakZj2i.js → Plus-D3gVN1IJ.js} +1 -1
  25. package/dist/client/assets/{SearchLg-B6A7YmGB.js → SearchLg-X8pCQ7Bs.js} +1 -1
  26. package/dist/client/assets/{SearchMd-Yh9NWGHH.js → SearchMd-BGw6nenO.js} +1 -1
  27. package/dist/client/assets/{Settings02-Lx-1u3Bn.js → Settings02-DLn641-3.js} +1 -1
  28. package/dist/client/assets/{Shield01-BJ3TiyrY.js → Shield01-MX0RzfQ2.js} +1 -1
  29. package/dist/client/assets/{Star01-D56V4TVC.js → Star01-jcE2iXLN.js} +1 -1
  30. package/dist/client/assets/{Stars01-BV53-GPu.js → Stars01-B33s_mIG.js} +1 -1
  31. package/dist/client/assets/{Stars02-B2Wf8VG1.js → Stars02-CUMfm05b.js} +1 -1
  32. package/dist/client/assets/{Sun-DfSj0AwW.js → Sun-DL3Et2O2.js} +1 -1
  33. package/dist/client/assets/{SwitchHorizontal01-0vB7r3W7.js → SwitchHorizontal01-Ca1irFIT.js} +1 -1
  34. package/dist/client/assets/{Tool01-Krxro8Eb.js → Tool01-CoHxo05I.js} +1 -1
  35. package/dist/client/assets/{Tool02-BYunryUZ.js → Tool02-q7KgS36M.js} +1 -1
  36. package/dist/client/assets/{Trash01-EgpeoR-H.js → Trash01-C_iTJrzM.js} +1 -1
  37. package/dist/client/assets/{TrendUp01-DXZnUZEU.js → TrendUp01-C64GToZR.js} +1 -1
  38. package/dist/client/assets/{Upload01-B_YOepEj.js → Upload01-C_wNHEuX.js} +1 -1
  39. package/dist/client/assets/{User01-BVhAcPFu.js → User01-DbfhZ4ti.js} +1 -1
  40. package/dist/client/assets/{Users01-CfMh8jDn.js → Users01-DVMG5rdr.js} +1 -1
  41. package/dist/client/assets/{Users03-v7hzkYQA.js → Users03-CJSf0I5d.js} +1 -1
  42. package/dist/client/assets/{X-Cv0UCoHc.js → X-BGd3Yd9R.js} +1 -1
  43. package/dist/client/assets/{XCircle-DHmH1ofD.js → XCircle-BzhEmj9C.js} +1 -1
  44. package/dist/client/assets/{XClose-C028jAbZ.js → XClose-yx7RXMlE.js} +1 -1
  45. package/dist/client/assets/{Zap-DWrOJOIs.js → Zap-Cc1RYTno.js} +1 -1
  46. package/dist/client/assets/{ZapSquare-CK872AWs.js → ZapSquare--_Wuc2N_.js} +1 -1
  47. package/dist/client/assets/{access-gate-BgnqMDuH.js → access-gate-BSUWjwCs.js} +1 -1
  48. package/dist/client/assets/{add-section-modal-CMGW4M05.js → add-section-modal-CB73EjN8.js} +1 -1
  49. package/dist/client/assets/{agent-icon-ClQ6MFoq.js → agent-icon-LwtXnQ8r.js} +1 -1
  50. package/dist/client/assets/{agents-list-D4encQ2B.js → agents-list-CrnSFHfy.js} +1 -1
  51. package/dist/client/assets/{ai-providers-CtnxxO-g.js → ai-providers-oJ038Zl_.js} +1 -1
  52. package/dist/client/assets/{alert-D--gPplk.js → alert-BGnJ_noO.js} +1 -1
  53. package/dist/client/assets/{alert-dialog-BmxMiJzj.js → alert-dialog-qDSW0Crq.js} +1 -1
  54. package/dist/client/assets/app-editor-DILiTJoW.js +1 -0
  55. package/dist/client/assets/{auth-BKrzkQE7.js → auth-DIPKpaIr.js} +1 -1
  56. package/dist/client/assets/{auth-catchall-JkfMFsIl.js → auth-catchall-CYL9uxik.js} +1 -1
  57. package/dist/client/assets/{auth-entry-bs5kljRR.js → auth-entry-DImJpw9E.js} +1 -1
  58. package/dist/client/assets/{auth-split-layout-Focpghx1.js → auth-split-layout-s6sRFVyK.js} +1 -1
  59. package/dist/client/assets/{authenticate-and-persist-oauth-BpB5Oaek.js → authenticate-and-persist-oauth-CaPu7RQh.js} +1 -1
  60. package/dist/client/assets/{automation-list-row-CWhy6hWm.js → automation-list-row-3pYfyU0O.js} +1 -1
  61. package/dist/client/assets/{automation-runs-B2FWi9UR.js → automation-runs-D2d3Wb2r.js} +1 -1
  62. package/dist/client/assets/{automations-pgwbDNQF.js → automations-DclhicEU.js} +1 -1
  63. package/dist/client/assets/{avatar-DPeJxtUT.js → avatar-CEbbtaiZ.js} +1 -1
  64. package/dist/client/assets/{badge-BON79ftm.js → badge-C1OyErpa.js} +1 -1
  65. package/dist/client/assets/billing-DRZX3EmX.js +6 -0
  66. package/dist/client/assets/{block-document-sNv31PCH.js → block-document-C3rhxAfS.js} +1 -1
  67. package/dist/client/assets/{brand-context-BnwI3qzC.js → brand-context-aUlyRlh0.js} +1 -1
  68. package/dist/client/assets/{buckets-DnBKR3GG.js → buckets-DELnzTrg.js} +1 -1
  69. package/dist/client/assets/bulk-category-panel-MPj9Giz3.js +1 -0
  70. package/dist/client/assets/{calendar-DDTH236u.js → calendar-Cgmlwp6s.js} +1 -1
  71. package/dist/client/assets/{capability-load-error-DaWbWNmk.js → capability-load-error-CO2UqFKW.js} +1 -1
  72. package/dist/client/assets/{card-_M-bn-6c.js → card-D0L8m2Fk.js} +1 -1
  73. package/dist/client/assets/category-editor-B-verZ0D.js +1 -0
  74. package/dist/client/assets/{chat-context-tVEHCSX5.js → chat-context-D6CbggZW.js} +1 -1
  75. package/dist/client/assets/{checkbox-YqK6rwSF.js → checkbox-DtFnclfC.js} +1 -1
  76. package/dist/client/assets/{cli-auth-success-zUMcbAKo.js → cli-auth-success-Bicb4f4q.js} +1 -1
  77. package/dist/client/assets/{collection-detail-RpRySuf7.js → collection-detail-CAcg5xcf.js} +1 -1
  78. package/dist/client/assets/{collection-display-button-KsZ-MLPt.js → collection-display-button-BCy_2J75.js} +1 -1
  79. package/dist/client/assets/{collection-search-BjSxnSjJ.js → collection-search-2xNmmwyF.js} +1 -1
  80. package/dist/client/assets/{collection-table-wrapper-BWtp84vf.js → collection-table-wrapper-CTDA0KGg.js} +1 -1
  81. package/dist/client/assets/{collection-tabs-5nGCOfxk.js → collection-tabs-CTBrfSnI.js} +1 -1
  82. package/dist/client/assets/{command-BfEiAydz.js → command-CC22u5HT.js} +1 -1
  83. package/dist/client/assets/{commerce-onboarding-B0MLztec.js → commerce-onboarding-DPhOKMuI.js} +1 -1
  84. package/dist/client/assets/{companions-core-EBpmeIUx.js → companions-core-DhobrWwt.js} +1 -1
  85. package/dist/client/assets/{connect-C7QBnQPp.js → connect-BpuNc0ED.js} +1 -1
  86. package/dist/client/assets/{connection-iwdkv-CM.js → connection-D7v6o0sJ.js} +1 -1
  87. package/dist/client/assets/{connection-card-DSAVcix6.js → connection-card-Go0wl4dH.js} +1 -1
  88. package/dist/client/assets/{connection-detail-CXbDLJBm.js → connection-detail-DHeSqYBk.js} +1 -1
  89. package/dist/client/assets/{connection-form-helpers-CNuWl6PY.js → connection-form-helpers-C8vqp-PX.js} +1 -1
  90. package/dist/client/assets/{connections-BiRKuv9V.js → connections-B0ZbAgCH.js} +1 -1
  91. package/dist/client/assets/{decopilot-sse-pool-C_7bumAG.js → decopilot-sse-pool-BSRr7Awl.js} +1 -1
  92. package/dist/client/assets/{dialog-BaQ3_w8_.js → dialog-nd9Y9UDf.js} +1 -1
  93. package/dist/client/assets/{domain-settings-CdoOjSht.js → domain-settings-BwjA2jso.js} +1 -1
  94. package/dist/client/assets/{drawer-DzfGx-oA.js → drawer-Y02E8bZP.js} +1 -1
  95. package/dist/client/assets/{dropdown-menu-BlQ1KaCg.js → dropdown-menu-DYJ4Ot9-.js} +1 -1
  96. package/dist/client/assets/{empty-state-CLumFPMt.js → empty-state-CCnFw3SI.js} +1 -1
  97. package/dist/client/assets/{extract-connection-data-B3R7rEs4.js → extract-connection-data-B6jF9vIP.js} +1 -1
  98. package/dist/client/assets/file-explorer-DpEAqpKl.js +2 -0
  99. package/dist/client/assets/{form-Cz3JG_Nj.js → form-DZe1OoXa.js} +1 -1
  100. package/dist/client/assets/general-BcbT-g-z.js +1 -0
  101. package/dist/client/assets/{github-repo-picker-CHXo4WUU.js → github-repo-picker-R7F1yX2B.js} +1 -1
  102. package/dist/client/assets/{hooks-DuSycRtz.js → hooks-BcHj3Ob3.js} +1 -1
  103. package/dist/client/assets/{index-Cte3Qotw.js → index-BC57PyF6.js} +1 -1
  104. package/dist/client/assets/{index-6Wy7SN7a.js → index-Bd-WG2FD.js} +1 -1
  105. package/dist/client/assets/{index-QHgw-nQE.js → index-Bk-CGEfI.js} +1 -1
  106. package/dist/client/assets/{index-CM5jFPpd.js → index-Cattr6nA.js} +35 -35
  107. package/dist/client/assets/{index-BbV1LXbP.js → index-Cd-mxy8I.js} +1 -1
  108. package/dist/client/assets/index-CdeKbNns.js +77 -0
  109. package/dist/client/assets/{index-Dc-kHG2N.js → index-Ci-xAbr8.js} +1 -1
  110. package/dist/client/assets/{index-C_tlTFTQ.js → index-D01T8L5t.js} +1 -1
  111. package/dist/client/assets/{index-Csj4ulP-.js → index-DSL_ub0T.js} +5 -5
  112. package/dist/client/assets/{index-BLiCxBFm.js → index-DjdZgCR6.js} +1 -1
  113. package/dist/client/assets/{index-D6gquhyQ.js → index-Dllcdz9M.js} +1 -1
  114. package/dist/client/assets/{index-BYAu2SO4.js → index-FXSmmHSb.js} +1 -1
  115. package/dist/client/assets/{index-redirect-DlRa9qk7.js → index-redirect-CmpV-Jj_.js} +1 -1
  116. package/dist/client/assets/{input-5_ihaBYH.js → input-D-iDTYtd.js} +1 -1
  117. package/dist/client/assets/{integration-icon-B_iJXwRI.js → integration-icon-BdwbQSLL.js} +1 -1
  118. package/dist/client/assets/{invite-member-dialog-d5R9AKjX.js → invite-member-dialog-BzkSk1Ge.js} +1 -1
  119. package/dist/client/assets/{label-BXyWlH3c.js → label-CxOnDTfr.js} +1 -1
  120. package/dist/client/assets/{layout-BqmRqncM.js → layout-GbjkVmGk.js} +1 -1
  121. package/dist/client/assets/{login-BHf7tXQm.js → login-BPeVUOhv.js} +1 -1
  122. package/dist/client/assets/{mcp-oauth-DpJ3kn83.js → mcp-oauth-DPdfbG_o.js} +1 -1
  123. package/dist/client/assets/members-Dm_2MGcL.js +1 -0
  124. package/dist/client/assets/{monaco-editor-B4SGDglp.js → monaco-editor-C86Ru8dd.js} +1 -1
  125. package/dist/client/assets/{monitoring-stats-row-C7ZDGWU8.js → monitoring-stats-row-BwPJ9hvQ.js} +1 -1
  126. package/dist/client/assets/{multi-select-C3t1eBvR.js → multi-select-CmcBjW31.js} +1 -1
  127. package/dist/client/assets/{oauth-callback-6_hjYEY8.js → oauth-callback-CW40581a.js} +1 -1
  128. package/dist/client/assets/{oauth-callback-ai-provider-CZuQoiSC.js → oauth-callback-ai-provider-BxEnbW0f.js} +1 -1
  129. package/dist/client/assets/{onboarding-BcHzqLxX.js → onboarding-DkoxJYt2.js} +1 -1
  130. package/dist/client/assets/{org-layout-C_p3W9up.js → org-layout-4xil_83z.js} +1 -1
  131. package/dist/client/assets/{organization-choice-CVhAwuDa.js → organization-choice-DXN-yJMk.js} +1 -1
  132. package/dist/client/assets/{orgs-9OqOkv9x.js → orgs-pac80290.js} +1 -1
  133. package/dist/client/assets/{page-seo-form-hf_pWp_F.js → page-seo-form-Bk_lJRhg.js} +1 -1
  134. package/dist/client/assets/{popover-Byln4TuQ.js → popover-BzY6SGD5.js} +1 -1
  135. package/dist/client/assets/post-editor-Caeo9yZ0.js +1 -0
  136. package/dist/client/assets/{primitives-Df3Bn_ya.js → primitives-D59xgpfo.js} +1 -1
  137. package/dist/client/assets/{profile-CS_iAKkm.js → profile-CWK3fjie.js} +1 -1
  138. package/dist/client/assets/project-app-view-DOxMbUNa.js +1 -0
  139. package/dist/client/assets/record-editor-_niGq24j.js +1 -0
  140. package/dist/client/assets/redirect-editor-CV9xq4Ct.js +1 -0
  141. package/dist/client/assets/registry-DNAqKX9b.js +2 -0
  142. package/dist/client/assets/{registry-layout-vt4vhU8c.js → registry-layout-BtBW4sei.js} +1 -1
  143. package/dist/client/assets/{reports-_cLV6W7t.js → reports-zFMLtR1A.js} +1 -1
  144. package/dist/client/assets/{require-capability-BmrfZmFk.js → require-capability-Br1pAJen.js} +1 -1
  145. package/dist/client/assets/{required-auth-layout-DssttDRY.js → required-auth-layout-D-kXHcFc.js} +1 -1
  146. package/dist/client/assets/{reset-password-J-GZyivg.js → reset-password-DxnpIDQZ.js} +1 -1
  147. package/dist/client/assets/{roles-DcqOrq9D.js → roles-BkhveSy6.js} +1 -1
  148. package/dist/client/assets/{search-input-BcMesWuB.js → search-input-C115Kksl.js} +1 -1
  149. package/dist/client/assets/{secrets-3-rsElai.js → secrets-BBfooOeU.js} +1 -1
  150. package/dist/client/assets/{sections-editor-G2RgoSGR.js → sections-editor-DK40H8jT.js} +2 -2
  151. package/dist/client/assets/{select-SGu4_FtX.js → select-DoSBsXS-.js} +1 -1
  152. package/dist/client/assets/{select-model-cIVouYTm.js → select-model-BoNfnd6b.js} +1 -1
  153. package/dist/client/assets/{self-tool-result-CACndU_u.js → self-tool-result-DtUlgJUE.js} +1 -1
  154. package/dist/client/assets/seo-editor-BIY7X9oK.js +1 -0
  155. package/dist/client/assets/{settings-layout-JwWYh0P3.js → settings-layout-BJ2Ef5pZ.js} +1 -1
  156. package/dist/client/assets/{settings-section-CXUhMVs1.js → settings-section-CDsu-DGw.js} +1 -1
  157. package/dist/client/assets/{shell-controls-y6dmq3Ut.js → shell-controls-Dr9vMfYa.js} +1 -1
  158. package/dist/client/assets/{shell-layout-DLhKvUEj.js → shell-layout-DBQkutH7.js} +1 -1
  159. package/dist/client/assets/{sidebar-QbwqQIu3.js → sidebar-B2MwaU8I.js} +1 -1
  160. package/dist/client/assets/{skeleton-s6ngmE7x.js → skeleton-Byy9MKOd.js} +1 -1
  161. package/dist/client/assets/{spinner-DzW40heC.js → spinner-DkNs3_AG.js} +1 -1
  162. package/dist/client/assets/{sso-BMlDhirk.js → sso-DBWJAZWr.js} +1 -1
  163. package/dist/client/assets/{store-BKcscc7a.js → store-CEwQ2QQ2.js} +1 -1
  164. package/dist/client/assets/store-registry-D7sYPe7R.js +2 -0
  165. package/dist/client/assets/{studio-tools-ByQe0nxW.js → studio-tools-CCpiCxVq.js} +1 -1
  166. package/dist/client/assets/{switch-DFCKdzt7.js → switch-Ckyz60oQ.js} +1 -1
  167. package/dist/client/assets/{tab-id-BiTYDOcZ.js → tab-id-DamQoqFe.js} +1 -1
  168. package/dist/client/assets/{table-DlRW6FZv.js → table-g2dB7kHC.js} +1 -1
  169. package/dist/client/assets/{tabs-C5vm-_nz.js → tabs-DhhmWcXn.js} +1 -1
  170. package/dist/client/assets/{textarea-CKeVZVzt.js → textarea-ml1xcq4m.js} +1 -1
  171. package/dist/client/assets/{toggle-group-DnYIxYbk.js → toggle-group-DaJb5ecI.js} +1 -1
  172. package/dist/client/assets/{toolbar-DwU8FQW4.js → toolbar-Dehgj7Nj.js} +1 -1
  173. package/dist/client/assets/{tooltip-CxHFa6IC.js → tooltip-fNNHHvCP.js} +1 -1
  174. package/dist/client/assets/{use-ai-providers-Co7pb7Qr.js → use-ai-providers-CwtqZyAl.js} +1 -1
  175. package/dist/client/assets/{use-automations-BP5ujW2a.js → use-automations-v0SaJAdt.js} +1 -1
  176. package/dist/client/assets/{use-autosave-D8ji2Fa4.js → use-autosave-CNHqftWQ.js} +1 -1
  177. package/dist/client/assets/{use-capability-DqWvGlPP.js → use-capability-6s_CDaCx.js} +1 -1
  178. package/dist/client/assets/{use-clock-tick-DSZ3Gm8N.js → use-clock-tick-Cw81SvwW.js} +1 -1
  179. package/dist/client/assets/{use-connection-DyO48bWG.js → use-connection-CzkVTaht.js} +1 -1
  180. package/dist/client/assets/{use-copy-6Jj0xxnI.js → use-copy-BYYLTgJg.js} +1 -1
  181. package/dist/client/assets/{use-create-virtual-mcp-Bmy5mqEA.js → use-create-virtual-mcp-jDvPk26o.js} +1 -1
  182. package/dist/client/assets/{use-debounced-autosave-D_DmEb8w.js → use-debounced-autosave-CWSN1_X_.js} +1 -1
  183. package/dist/client/assets/{use-debounced-value-_FeINZsD.js → use-debounced-value-D4-eJghO.js} +1 -1
  184. package/dist/client/assets/{use-deco-credits-C_lnLrG5.js → use-deco-credits-Dwwqo-VH.js} +1 -1
  185. package/dist/client/assets/{use-decopilot-events-L_uDUkvt.js → use-decopilot-events-CMeACuxN.js} +1 -1
  186. package/dist/client/assets/{use-delete-connection-CMqGCbIX.js → use-delete-connection-DV_zsO6y.js} +1 -1
  187. package/dist/client/assets/{use-deployment-admin-DnjeA_1_.js → use-deployment-admin-By7yhBUI.js} +1 -1
  188. package/dist/client/assets/{use-file-configs-BHd6zoJg.js → use-file-configs-Z-5fKuaj.js} +1 -1
  189. package/dist/client/assets/{use-infinite-scroll-D_VL9wUU.js → use-infinite-scroll-fXFRW5gQ.js} +1 -1
  190. package/dist/client/assets/{use-join-requests-yfo1t6jl.js → use-join-requests-BoAzPTLj.js} +1 -1
  191. package/dist/client/assets/{use-mcp-client-D_w4YfXz.js → use-mcp-client-DqHVlRT-.js} +1 -1
  192. package/dist/client/assets/{use-mcp-tools-ApQ-yd9r.js → use-mcp-tools-DBw2JL-y.js} +1 -1
  193. package/dist/client/assets/{use-members-BHIh4BMi.js → use-members-DsNs-XXd.js} +1 -1
  194. package/dist/client/assets/{use-mobile-BTbk3OtS.js → use-mobile-DTQQN7CZ.js} +1 -1
  195. package/dist/client/assets/{use-navigate-to-agent-DlOybjQl.js → use-navigate-to-agent-DGSYNDms.js} +1 -1
  196. package/dist/client/assets/use-open-billing-url-BiA8ypry.js +1 -0
  197. package/dist/client/assets/{use-org-auth-client-B81bJ_PA.js → use-org-auth-client-BoO3p-ZD.js} +1 -1
  198. package/dist/client/assets/{use-org-sso-DA_tV60t.js → use-org-sso-pjSvX-hU.js} +1 -1
  199. package/dist/client/assets/{use-organization-roles--CkNNivC.js → use-organization-roles-CDb_-Y7M.js} +1 -1
  200. package/dist/client/assets/{use-organization-settings-BIlGedqq.js → use-organization-settings-DDGI0ux_.js} +1 -1
  201. package/dist/client/assets/{use-registry-connections-CS7FZ6vE.js → use-registry-connections-9HNFG4EX.js} +1 -1
  202. package/dist/client/assets/{use-secrets-YHPDYoG0.js → use-secrets-DuY_szss.js} +1 -1
  203. package/dist/client/assets/{use-status-sounds-Dmzs3AZM.js → use-status-sounds-DrHItgaG.js} +1 -1
  204. package/dist/client/assets/{use-tags-BwYUEYku.js → use-tags-D9BTOCB6.js} +1 -1
  205. package/dist/client/assets/{use-view-mode-BrMghI3p.js → use-view-mode-BBNpqulX.js} +1 -1
  206. package/dist/client/assets/{use-virtual-mcp-CSlt6IBv.js → use-virtual-mcp-CTQtyJk0.js} +1 -1
  207. package/dist/client/assets/useInfiniteQuery-CAndPTbu.js +1 -0
  208. package/dist/client/assets/{useQueries-y3ZS11ts.js → useQueries-YKDnkiqD.js} +1 -1
  209. package/dist/client/assets/{useRouterState-BWggJFL2.js → useRouterState-D-3vvriX.js} +1 -1
  210. package/dist/client/assets/useSuspenseInfiniteQuery-CR3WF7F3.js +1 -0
  211. package/dist/client/assets/{users-u61YI361.js → users-DFm1KNAU.js} +1 -1
  212. package/dist/client/assets/{variant-calendar-CesD7nTB.js → variant-calendar-lUVRsxSt.js} +1 -1
  213. package/dist/client/assets/{view-mode-toggle-D5P-Fw97.js → view-mode-toggle-BjkWD1Pd.js} +1 -1
  214. package/dist/client/index.html +1 -1
  215. package/dist/server/cli.js +143 -143
  216. package/dist/server/migrate.js +1 -1
  217. package/dist/server/server.js +121 -121
  218. package/package.json +1 -1
  219. package/dist/client/assets/app-editor-DL3n5aIo.js +0 -1
  220. package/dist/client/assets/billing-CSRO_Xhf.js +0 -6
  221. package/dist/client/assets/bulk-category-panel-D6Bqf27J.js +0 -1
  222. package/dist/client/assets/category-editor-8aLxI0zu.js +0 -1
  223. package/dist/client/assets/file-explorer-C8bBTplO.js +0 -2
  224. package/dist/client/assets/general-BMPq4RKk.js +0 -1
  225. package/dist/client/assets/index-DmMjm15X.js +0 -77
  226. package/dist/client/assets/members-GtIKQUzd.js +0 -1
  227. package/dist/client/assets/post-editor-MzsGcDsk.js +0 -1
  228. package/dist/client/assets/project-app-view-BGhZ4HbH.js +0 -1
  229. package/dist/client/assets/record-editor-5tOBqSaF.js +0 -1
  230. package/dist/client/assets/redirect-editor-DV_7QC_m.js +0 -1
  231. package/dist/client/assets/registry-CCbAvu-S.js +0 -2
  232. package/dist/client/assets/seo-editor-CRdRftoa.js +0 -1
  233. package/dist/client/assets/store-registry-CATZt53a.js +0 -2
  234. package/dist/client/assets/useInfiniteQuery-DRBWKJK0.js +0 -1
  235. package/dist/client/assets/useSuspenseInfiniteQuery-CfunhPPn.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as $,ag as ut,c as G,b as se,j as s,Y as Be,Z as ve,F as xe,o as we,_ as We,$ as Ve,e as je,K as ce,t as ne,B as le,p as ie,m as oe,n as mt,d as ft,E as pt,z as xt}from"./index-Csj4ulP-.js";import{c as He,e as qe,d as Ye,a as gt,b as Ge,h as vt,D as bt}from"./dialog-BaQ3_w8_.js";import{d as yt,b as jt,a as St,D as Nt}from"./drawer-DzfGx-oA.js";import{u as wt}from"./use-mobile-BTbk3OtS.js";import{u as Xe}from"./chat-context-tVEHCSX5.js";import{C as kt}from"./checkbox-YqK6rwSF.js";import{I as pe}from"./input-5_ihaBYH.js";import{S as _t,a as Ct,b as It,c as Mt,d as Et}from"./select-SGu4_FtX.js";import{S as ee}from"./skeleton-s6ngmE7x.js";import{i as Qe,b as Je,c as Ot,a as At,s as Pt}from"./Settings02-Lx-1u3Bn.js";import{d as Tt,a as Lt,b as zt,i as Rt}from"./Tool01-Krxro8Eb.js";import{i as Ft}from"./Key01-1xwZnZcu.js";import{i as Ze}from"./SearchMd-Yh9NWGHH.js";import{f as ke,u as Kt,b as Dt}from"./use-ai-providers-Co7pb7Qr.js";import{g as _e}from"./ai-providers-logos-DD3qZ33J.js";import{i as Me}from"./Monitor01-DoHemlFB.js";import{i as $t}from"./AlertCircle-DhwfTi65.js";import{S as Ee}from"./spinner-DzW40heC.js";import{u as Ne}from"./studio-tools-ByQe0nxW.js";import{i as Ut}from"./ChevronRight-CRnb0aSS.js";import{A as Bt}from"./avatar-DPeJxtUT.js";import{S as Oe,a as Ae,b as et}from"./settings-section-CXUhMVs1.js";import{s as tt}from"./Eye-D2tsgwEB.js";import{i as Wt,D as Vt}from"./tab-id-BiTYDOcZ.js";import{u as Ht}from"./use-is-desktop-app-BNujXJc_.js";import{t as Pe}from"./ChevronDown-DFqNx4Ma.js";import{t as qt}from"./Stars01-BV53-GPu.js";function fe(n,e,t){let i=t.initialDeps??[],o,l=!0;function a(){var r,h,d;let c;t.key&&((r=t.debug)!=null&&r.call(t))&&(c=Date.now());const f=n();if(!(f.length!==i.length||f.some((m,j)=>i[j]!==m)))return o;i=f;let u;if(t.key&&((h=t.debug)!=null&&h.call(t))&&(u=Date.now()),o=e(...f),t.key&&((d=t.debug)!=null&&d.call(t))){const m=Math.round((Date.now()-c)*100)/100,j=Math.round((Date.now()-u)*100)/100,N=j/16,S=(b,I)=>{for(b=String(b);b.length<I;)b=" "+b;return b};console.info(`%c⏱ ${S(j,5)} /${S(m,5)} ms`,`
1
+ import{r as $,ag as ut,c as G,b as se,j as s,Y as Be,Z as ve,F as xe,o as we,_ as We,$ as Ve,e as je,K as ce,t as ne,B as le,p as ie,m as oe,n as mt,d as ft,E as pt,z as xt}from"./index-DSL_ub0T.js";import{c as He,e as qe,d as Ye,a as gt,b as Ge,h as vt,D as bt}from"./dialog-nd9Y9UDf.js";import{d as yt,b as jt,a as St,D as Nt}from"./drawer-Y02E8bZP.js";import{u as wt}from"./use-mobile-DTQQN7CZ.js";import{u as Xe}from"./chat-context-D6CbggZW.js";import{C as kt}from"./checkbox-DtFnclfC.js";import{I as pe}from"./input-D-iDTYtd.js";import{S as _t,a as Ct,b as It,c as Mt,d as Et}from"./select-DoSBsXS-.js";import{S as ee}from"./skeleton-Byy9MKOd.js";import{i as Qe,b as Je,c as Ot,a as At,s as Pt}from"./Settings02-DLn641-3.js";import{d as Tt,a as Lt,b as zt,i as Rt}from"./Tool01-CoHxo05I.js";import{i as Ft}from"./Key01-ai3raIR8.js";import{i as Ze}from"./SearchMd-BGw6nenO.js";import{f as ke,u as Kt,b as Dt}from"./use-ai-providers-CwtqZyAl.js";import{g as _e}from"./ai-providers-logos-DD3qZ33J.js";import{i as Me}from"./Monitor01-DH8zVvcw.js";import{i as $t}from"./AlertCircle-BTxQkLh_.js";import{S as Ee}from"./spinner-DkNs3_AG.js";import{u as Ne}from"./studio-tools-CCpiCxVq.js";import{i as Ut}from"./ChevronRight-DLaD7kHP.js";import{A as Bt}from"./avatar-CEbbtaiZ.js";import{S as Oe,a as Ae,b as et}from"./settings-section-CDsu-DGw.js";import{s as tt}from"./Eye-B6gNJQkZ.js";import{i as Wt,D as Vt}from"./tab-id-DamQoqFe.js";import{u as Ht}from"./use-is-desktop-app-BNujXJc_.js";import{t as Pe}from"./ChevronDown-DJaWgVC0.js";import{t as qt}from"./Stars01-B33s_mIG.js";function fe(n,e,t){let i=t.initialDeps??[],o,l=!0;function a(){var r,h,d;let c;t.key&&((r=t.debug)!=null&&r.call(t))&&(c=Date.now());const f=n();if(!(f.length!==i.length||f.some((m,j)=>i[j]!==m)))return o;i=f;let u;if(t.key&&((h=t.debug)!=null&&h.call(t))&&(u=Date.now()),o=e(...f),t.key&&((d=t.debug)!=null&&d.call(t))){const m=Math.round((Date.now()-c)*100)/100,j=Math.round((Date.now()-u)*100)/100,N=j/16,S=(b,I)=>{for(b=String(b);b.length<I;)b=" "+b;return b};console.info(`%c⏱ ${S(j,5)} /${S(m,5)} ms`,`
2
2
  font-size: .6rem;
3
3
  font-weight: bold;
4
4
  color: hsl(${Math.max(0,Math.min(120-120*N,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(l&&t.skipInitialOnChange)&&t.onChange(o),l=!1,o}return a.updateDeps=r=>{i=r},a}function Te(n,e){if(n===void 0)throw new Error("Unexpected undefined");return n}const Yt=(n,e)=>Math.abs(n-e)<1.01,Gt=(n,e,t)=>{let i;return function(...o){n.clearTimeout(i),i=n.setTimeout(()=>e.apply(this,o),t)}},Le=n=>{const{offsetWidth:e,offsetHeight:t}=n;return{width:e,height:t}},Xt=n=>n,Qt=n=>{const e=Math.max(n.startIndex-n.overscan,0),t=Math.min(n.endIndex+n.overscan,n.count-1),i=[];for(let o=e;o<=t;o++)i.push(o);return i},Jt=(n,e)=>{const t=n.scrollElement;if(!t)return;const i=n.targetWindow;if(!i)return;const o=a=>{const{width:r,height:h}=a;e({width:Math.round(r),height:Math.round(h)})};if(o(Le(t)),!i.ResizeObserver)return()=>{};const l=new i.ResizeObserver(a=>{const r=()=>{const h=a[0];if(h?.borderBoxSize){const d=h.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Le(t))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return l.observe(t,{box:"border-box"}),()=>{l.unobserve(t)}},ze={passive:!0},Re=typeof window>"u"?!0:"onscrollend"in window,Zt=(n,e)=>{const t=n.scrollElement;if(!t)return;const i=n.targetWindow;if(!i)return;let o=0;const l=n.options.useScrollendEvent&&Re?()=>{}:Gt(i,()=>{e(o,!1)},n.options.isScrollingResetDelay),a=c=>()=>{const{horizontal:f,isRtl:p}=n.options;o=f?t.scrollLeft*(p&&-1||1):t.scrollTop,l(),e(o,c)},r=a(!0),h=a(!1);t.addEventListener("scroll",r,ze);const d=n.options.useScrollendEvent&&Re;return d&&t.addEventListener("scrollend",h,ze),()=>{t.removeEventListener("scroll",r),d&&t.removeEventListener("scrollend",h)}},es=(n,e,t)=>{if(e?.borderBoxSize){const i=e.borderBoxSize[0];if(i)return Math.round(i[t.options.horizontal?"inlineSize":"blockSize"])}return n[t.options.horizontal?"offsetWidth":"offsetHeight"]},ts=(n,{adjustments:e=0,behavior:t},i)=>{var o,l;const a=n+e;(l=(o=i.scrollElement)==null?void 0:o.scrollTo)==null||l.call(o,{[i.options.horizontal?"left":"top"]:a,behavior:t})};class ss{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var t,i,o;return((o=(i=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:i.now)==null?void 0:o.call(i))??Date.now()},this.observer=(()=>{let t=null;const i=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(l=>{const a=()=>{const r=l.target,h=this.indexFromElement(r);if(!r.isConnected){this.observer.unobserve(r);return}this.shouldMeasureDuringScroll(h)&&this.resizeItem(h,this.options.measureElement(r,l,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var o;(o=i())==null||o.disconnect(),t=null},observe:o=>{var l;return(l=i())==null?void 0:l.observe(o,{box:"border-box"})},unobserve:o=>{var l;return(l=i())==null?void 0:l.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([i,o])=>{typeof o>"u"&&delete t[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Xt,rangeExtractor:Qt,onChange:()=>{},measureElement:es,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...t}},this.notify=t=>{var i,o;(o=(i=this.options).onChange)==null||o.call(i,this,t)},this.maybeNotify=fe(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,l)=>{this.scrollAdjustments=0,this.scrollDirection=l?this.getScrollOffset()<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=l,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,i)=>{const o=new Map,l=new Map;for(let a=i-1;a>=0;a--){const r=t[a];if(o.has(r.lane))continue;const h=l.get(r.lane);if(h==null||r.end>h.end?l.set(r.lane,r):r.end<h.end&&o.set(r.lane,!0),o.size===this.options.lanes)break}return l.size===this.options.lanes?Array.from(l.values()).sort((a,r)=>a.end===r.end?a.index-r.index:a.end-r.end)[0]:void 0},this.getMeasurementOptions=fe(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,i,o,l,a,r,h)=>(this.prevLanes!==void 0&&this.prevLanes!==r&&(this.lanesChangedFlag=!0),this.prevLanes=r,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:i,scrollMargin:o,getItemKey:l,enabled:a,lanes:r,laneAssignmentMode:h}),{key:!1}),this.getMeasurements=fe(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:i,scrollMargin:o,getItemKey:l,enabled:a,lanes:r,laneAssignmentMode:h},d)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const u of this.laneAssignments.keys())u>=t&&this.laneAssignments.delete(u);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(u=>{this.itemSizeCache.set(u.key,u.size)}));const c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const f=this.measurementsCache.slice(0,c),p=new Array(r).fill(void 0);for(let u=0;u<c;u++){const m=f[u];m&&(p[m.lane]=u)}for(let u=c;u<t;u++){const m=l(u),j=this.laneAssignments.get(u);let N,S;const b=h==="estimate"||d.has(m);if(j!==void 0&&this.options.lanes>1){N=j;const k=p[N],x=k!==void 0?f[k]:void 0;S=x?x.end+this.options.gap:i+o}else{const k=this.options.lanes===1?f[u-1]:this.getFurthestMeasurement(f,u);S=k?k.end+this.options.gap:i+o,N=k?k.lane:u%this.options.lanes,this.options.lanes>1&&b&&this.laneAssignments.set(u,N)}const I=d.get(m),E=typeof I=="number"?I:this.options.estimateSize(u),O=S+E;f[u]={index:u,start:S,size:E,end:O,key:m,lane:N},p[N]=u}return this.measurementsCache=f,f},{key:!1,debug:()=>this.options.debug}),this.calculateRange=fe(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,i,o,l)=>this.range=t.length>0&&i>0?is({measurements:t,outerSize:i,scrollOffset:o,lanes:l}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=fe(()=>{let t=null,i=null;const o=this.calculateRange();return o&&(t=o.startIndex,i=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,i]},(t,i,o,l,a)=>l===null||a===null?[]:t({startIndex:l,endIndex:a,overscan:i,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const i=this.options.indexAttribute,o=t.getAttribute(i);return o?parseInt(o,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(o!==void 0&&this.range){const l=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,o-l),r=Math.min(this.options.count-1,o+l);return t>=a&&t<=r}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((a,r)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(r))});return}const i=this.indexFromElement(t),o=this.options.getItemKey(i),l=this.elementsCache.get(o);l!==t&&(l&&this.observer.unobserve(l),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,i)=>{var o;const l=this.measurementsCache[t];if(!l)return;const a=this.itemSizeCache.get(l.key)??l.size,r=i-a;r!==0&&(((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(l,r,this):l.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(l.index),this.itemSizeCache=new Map(this.itemSizeCache.set(l.key,i)),this.notify(!1))},this.getVirtualItems=fe(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,i)=>{const o=[];for(let l=0,a=t.length;l<a;l++){const r=t[l],h=i[r];o.push(h)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const i=this.getMeasurements();if(i.length!==0)return Te(i[st(0,i.length-1,o=>Te(i[o]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,i,o=0)=>{if(!this.scrollElement)return 0;const l=this.getSize(),a=this.getScrollOffset();i==="auto"&&(i=t>=a+l?"end":"start"),i==="center"?t+=(o-l)/2:i==="end"&&(t-=l);const r=this.getMaxScrollOffset();return Math.max(Math.min(r,t),0)},this.getOffsetForIndex=(t,i="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getSize(),l=this.getScrollOffset(),a=this.measurementsCache[t];if(!a)return;if(i==="auto")if(a.end>=l+o-this.options.scrollPaddingEnd)i="end";else if(a.start<=l+this.options.scrollPaddingStart)i="start";else return[l,i];if(i==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),i];const r=i==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(r,i,a.size),i]},this.scrollToOffset=(t,{align:i="start",behavior:o="auto"}={})=>{const l=this.getOffsetForAlignment(t,i),a=this.now();this.scrollState={index:null,align:i,behavior:o,startedAt:a,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:i="auto",behavior:o="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const l=this.getOffsetForIndex(t,i);if(!l)return;const[a,r]=l,h=this.now();this.scrollState={index:t,align:r,behavior:o,startedAt:h,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:i="auto"}={})=>{const o=this.getScrollOffset()+t,l=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var t;const i=this.getMeasurements();let o;if(i.length===0)o=this.options.paddingStart;else if(this.options.lanes===1)o=((t=i[i.length-1])==null?void 0:t.end)??0;else{const l=Array(this.options.lanes).fill(null);let a=i.length-1;for(;a>=0&&l.some(r=>r===null);){const r=i[a];l[r.lane]===null&&(l[r.lane]=r.end),a--}o=Math.max(...l.filter(r=>r!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:i,behavior:o})=>{this.options.scrollToFn(t,{behavior:o,adjustments:i},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=i?i[0]:this.scrollState.lastTargetOffset,l=1,a=o!==this.scrollState.lastTargetOffset;if(!a&&Yt(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=l){this.scrollState=null;return}}else this.scrollState.stableFrames=0,a&&(this.scrollState.lastTargetOffset=o,this.scrollState.behavior="auto",this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const st=(n,e,t,i)=>{for(;n<=e;){const o=(n+e)/2|0,l=t(o);if(l<i)n=o+1;else if(l>i)e=o-1;else return o}return n>0?n-1:0};function is({measurements:n,outerSize:e,scrollOffset:t,lanes:i}){const o=n.length-1,l=h=>n[h].start;if(n.length<=i)return{startIndex:0,endIndex:o};let a=st(0,o,l,t),r=a;if(i===1)for(;r<o&&n[r].end<t+e;)r++;else if(i>1){const h=Array(i).fill(0);for(;r<o&&h.some(c=>c<t+e);){const c=n[r];h[c.lane]=c.end,r++}const d=Array(i).fill(t+e);for(;a>=0&&d.some(c=>c>=t);){const c=n[a];d[c.lane]=c.start,a--}a=Math.max(0,a-a%i),r=Math.min(o,r+(i-1-r%i))}return{startIndex:a,endIndex:r}}const Fe=typeof document<"u"?$.useLayoutEffect:$.useEffect;function ns({useFlushSync:n=!0,...e}){const t=$.useReducer(()=>({}),{})[1],i={...e,onChange:(l,a)=>{var r;n&&a?ut.flushSync(t):t(),(r=e.onChange)==null||r.call(e,l,a)}},[o]=$.useState(()=>new ss(i));return o.setOptions(i),Fe(()=>o._didMount(),[]),Fe(()=>o._willUpdate()),o}function ls(n){return ns({observeElementRect:Jt,observeElementOffset:Zt,scrollToFn:ts,...n})}const it=[{id:"openai",name:"OpenAI",description:"GPT-4, GPT-5, and other OpenAI models",logo:"https://decoims.com/decocms/b51001ef-ae58-4db4-8a75-9e6d2df2dd8e/openai.png",baseUrlPlaceholder:"https://api.openai.com/v1",defaultBaseUrl:"https://api.openai.com/v1",apiKeyRecommended:!0,helpText:"Use your OpenAI API key (starts with sk-)."},{id:"litellm",name:"LiteLLM",description:"Connect to a LiteLLM gateway your team manages",logo:"https://decoims.com/decocms/e974ae05-ad64-4b4a-8444-d9705f019b85/litellm.png",baseUrlPlaceholder:"http://localhost:4000",apiKeyRecommended:!0,helpText:"Point at your LiteLLM proxy. The base URL should be the root of the proxy (we'll append /v1)."},{id:"ollama",name:"Ollama",description:"Run open-source models on your own computer",logo:"https://decoims.com/decocms/2bb2f822-5288-4b7c-a541-dcbef76525a0/ollama.png",baseUrlPlaceholder:"http://localhost:11434",apiKeyRecommended:!1,helpText:"Ollama exposes /v1 by default — no API key required for local use."},{id:"lm-studio",name:"LM Studio",description:"Open models running through LM Studio",logo:"https://decoims.com/decocms/9f0ab1a9-d2d5-4f3e-9de0-aadd4926428d/lmstudio.webp",baseUrlPlaceholder:"http://localhost:1234",apiKeyRecommended:!1,helpText:"Start the local server in LM Studio, then paste its base URL here."},{id:"vllm",name:"vLLM",description:"Connect to your team's self-hosted vLLM server",logo:"https://decoims.com/decocms/b6c60e4f-a4aa-443c-981f-ad0f31640e22/vllm.png",baseUrlPlaceholder:"http://localhost:8000",apiKeyRecommended:!1}];function be(n){if(n)return it.find(e=>e.id===n)}const Ke=4;function ge(n){const e=G.c(8),{logo:t,name:i,description:o,onClick:l}=n;let a;e[0]!==t||e[1]!==i?(a=t?s.jsx("img",{src:t,alt:i,className:"size-8 rounded-md object-contain dark:bg-white dark:p-0.5"}):s.jsx(Bt,{fallback:i.charAt(0),className:"size-8 bg-primary/10 text-primary"}),e[0]=t,e[1]=i,e[2]=a):a=e[2];let r;return e[3]!==o||e[4]!==i||e[5]!==l||e[6]!==a?(r=s.jsx(et,{onClick:l,icon:a,title:i,description:o}),e[3]=o,e[4]=i,e[5]=l,e[6]=a,e[7]=r):r=e[7],r}function nt(n){const e=G.c(38),{providers:t,onSelect:i,onShowAll:o}=n,l=se();let a;e[0]!==t?(a=t.find(cs),e[0]=t,e[1]=a):a=e[1];const r=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h={openrouter:0,llmapi:1,anthropic:2,google:3},e[2]=h):h=e[2];const d=h;let c;if(e[3]!==i||e[4]!==t||e[5]!==l){let E;e[7]===Symbol.for("react.memo_cache_sentinel")?(E=(y,C)=>{const z=d[y.id]??Number.MAX_SAFE_INTEGER,A=d[C.id]??Number.MAX_SAFE_INTEGER;return z-A},e[7]=E):E=e[7];const O=t.filter(as).sort(E);let k;e[8]!==t?(k=t.find(rs),e[8]=t,e[9]=k):k=e[9];const x=k;let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=be("openai"),e[10]=w):w=e[10];const _=w;let M;e[11]!==i?(M=y=>s.jsx(ge,{logo:y.logo,name:y.name,description:y.description,onClick:()=>i({kind:"provider",provider:y})},y.id),e[11]=i,e[12]=M):M=e[12];let v;e[13]!==i||e[14]!==x?(v=x&&_?[s.jsx(ge,{logo:_.logo,name:_.name,description:_.description,onClick:()=>i({kind:"openai-compatible",provider:x,preset:_})},_.id)]:[],e[13]=i,e[14]=x,e[15]=v):v=e[15];let g;e[16]!==i||e[17]!==x||e[18]!==l?(g=x?[...it.filter(os).map(y=>s.jsx(ge,{logo:y.logo,name:y.name,description:y.description,onClick:()=>i({kind:"openai-compatible",provider:x,preset:y})},y.id)),s.jsx(ge,{logo:x.logo,name:l("settings.aiProviders.customOpenAiCompatible"),description:l("settings.aiProviders.customOpenAiDescription"),onClick:()=>i({kind:"openai-compatible",provider:x,preset:null})},"custom")]:[],e[16]=i,e[17]=x,e[18]=l,e[19]=g):g=e[19],c=[...O.map(M),...v,...g],e[3]=i,e[4]=t,e[5]=l,e[6]=c}else c=e[6];const f=c,p=f.length-Ke,u=!!o&&p>0;let m;e[20]!==f||e[21]!==u?(m=u?f.slice(0,Ke):f,e[20]=f,e[21]=u,e[22]=m):m=e[22];const j=m;let N;e[23]!==r||e[24]!==i||e[25]!==l?(N=r&&s.jsx(Oe,{children:s.jsxs("div",{className:"relative rounded-xl border border-violet-400/30 bg-gradient-to-br from-violet-50/50 via-transparent to-lime-50/30 dark:from-violet-950/20 dark:to-lime-950/10 p-1.5",children:[s.jsx("div",{className:"absolute inset-0 rounded-xl bg-gradient-to-br from-violet-400/5 to-lime-400/5 pointer-events-none"}),s.jsx("p",{className:"text-xs font-medium text-violet-700 dark:text-violet-400 mb-1.5 px-2 pt-2 relative",children:l("settings.aiProviders.recommended")}),s.jsx(Ae,{className:"relative",children:s.jsx(ge,{logo:r.logo,name:r.name,description:r.description,onClick:()=>i({kind:"provider",provider:r})})})]})}),e[23]=r,e[24]=i,e[25]=l,e[26]=N):N=e[26];let S;e[27]!==p||e[28]!==o||e[29]!==u||e[30]!==l?(S=u&&s.jsx(et,{onClick:o,title:l(p===1?"settings.aiProviders.moreProvidersSingular":"settings.aiProviders.moreProvidersPlural",{count:p}),action:s.jsx(Ut,{size:16,className:"text-muted-foreground"})}),e[27]=p,e[28]=o,e[29]=u,e[30]=l,e[31]=S):S=e[31];let b;e[32]!==S||e[33]!==j?(b=s.jsx(Oe,{children:s.jsxs(Ae,{children:[j,S]})}),e[32]=S,e[33]=j,e[34]=b):b=e[34];let I;return e[35]!==N||e[36]!==b?(I=s.jsxs("div",{className:"flex flex-col gap-6",children:[N,b]}),e[35]=N,e[36]=b,e[37]=I):I=e[37],I}function os(n){return n.id!=="openai"}function rs(n){return n.id==="openai-compatible"}function as(n){return n.id!=="deco"&&n.id!=="openai-compatible"}function cs(n){return n.id==="deco"}const ds=Be({label:ve().optional(),apiKey:ve().min(1,"API key is required")});function hs(n){const e=G.c(87),{providerId:t,onCancel:i,onSuccess:o}=n,{org:l}=xe(),a=Ne(),r=we(),[h,d]=$.useState(!1),c=se();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={resolver:We(ds),defaultValues:{label:"",apiKey:""}},e[0]=f):f=e[0];const{register:p,handleSubmit:u,formState:m}=Ve(f),{errors:j}=m;let N;e[1]!==t||e[2]!==a||e[3]!==c?(N=async Y=>{await a.call("AI_PROVIDER_KEY_CREATE",{providerId:t,label:Y.label||c("settings.connectForms.defaultKeyLabel"),apiKey:Y.apiKey})},e[1]=t,e[2]=a,e[3]=c,e[4]=N):N=e[4];let S;e[5]!==o||e[6]!==l||e[7]!==r||e[8]!==c?(S=()=>{r.invalidateQueries({queryKey:ce.aiProviderKeys(l.id)}),r.invalidateQueries({queryKey:ce.aiProviders(l.id)}),ne.success(c("settings.connectForms.keySavedSuccess")),o()},e[5]=o,e[6]=l,e[7]=r,e[8]=c,e[9]=S):S=e[9];let b;e[10]!==c?(b=Y=>{ne.error(c("settings.connectForms.failedSaveKey",{error:Y.message}))},e[10]=c,e[11]=b):b=e[11];let I;e[12]!==N||e[13]!==S||e[14]!==b?(I={mutationFn:N,onSuccess:S,onError:b},e[12]=N,e[13]=S,e[14]=b,e[15]=I):I=e[15];const{mutate:E,isPending:O,error:k}=je(I);let x;e[16]!==E?(x=Y=>E(Y),e[16]=E,e[17]=x):x=e[17];let w;e[18]!==u||e[19]!==x?(w=u(x),e[18]=u,e[19]=x,e[20]=w):w=e[20];let _;e[21]!==c?(_=c("settings.connectForms.labelField"),e[21]=c,e[22]=_):_=e[22];let M;e[23]!==_?(M=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:_}),e[23]=_,e[24]=M):M=e[24];let v;e[25]!==c?(v=c("settings.connectForms.labelPlaceholder"),e[25]=c,e[26]=v):v=e[26];let g;e[27]!==p?(g=p("label"),e[27]=p,e[28]=g):g=e[28];let y;e[29]!==v||e[30]!==g?(y=s.jsx(pe,{placeholder:v,...g,className:"h-8 text-sm"}),e[29]=v,e[30]=g,e[31]=y):y=e[31];let C;e[32]!==M||e[33]!==y?(C=s.jsxs("div",{className:"space-y-1",children:[M,y]}),e[32]=M,e[33]=y,e[34]=C):C=e[34];let z;e[35]!==c?(z=c("settings.connectForms.apiKeyField"),e[35]=c,e[36]=z):z=e[36];let A;e[37]!==z?(A=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:z}),e[37]=z,e[38]=A):A=e[38];const P=h?"text":"password";let T;e[39]!==p?(T=p("apiKey"),e[39]=p,e[40]=T):T=e[40];let L;e[41]!==P||e[42]!==T?(L=s.jsx(pe,{type:P,placeholder:"sk-...",...T,className:"ph-no-capture h-8 text-sm pr-8"}),e[41]=P,e[42]=T,e[43]=L):L=e[43];let F;e[44]!==h?(F=()=>d(!h),e[44]=h,e[45]=F):F=e[45];let K;e[46]!==h||e[47]!==c?(K=c(h?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[46]=h,e[47]=c,e[48]=K):K=e[48];let X;e[49]!==h?(X=h?s.jsx(Qe,{size:14}):s.jsx(tt,{size:14}),e[49]=h,e[50]=X):X=e[50];let V;e[51]!==F||e[52]!==K||e[53]!==X?(V=s.jsx("button",{type:"button",onClick:F,"aria-label":K,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:X}),e[51]=F,e[52]=K,e[53]=X,e[54]=V):V=e[54];let Q;e[55]!==L||e[56]!==V?(Q=s.jsxs("div",{className:"relative",children:[L,V]}),e[55]=L,e[56]=V,e[57]=Q):Q=e[57];let J;e[58]!==j.apiKey?(J=j.apiKey&&s.jsx("p",{className:"text-xs text-destructive",children:j.apiKey.message}),e[58]=j.apiKey,e[59]=J):J=e[59];let H;e[60]!==A||e[61]!==Q||e[62]!==J?(H=s.jsxs("div",{className:"space-y-1",children:[A,Q,J]}),e[60]=A,e[61]=Q,e[62]=J,e[63]=H):H=e[63];let U;e[64]!==k?(U=k&&s.jsx("p",{className:"text-xs text-destructive",children:k.message}),e[64]=k,e[65]=U):U=e[65];let B;e[66]!==c?(B=c("settings.connectForms.cancel"),e[66]=c,e[67]=B):B=e[67];let W;e[68]!==O||e[69]!==i||e[70]!==B?(W=s.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:O,children:B}),e[68]=O,e[69]=i,e[70]=B,e[71]=W):W=e[71];let Z;e[72]!==O||e[73]!==c?(Z=c(O?"settings.connectForms.saving":"settings.connectForms.saveKey"),e[72]=O,e[73]=c,e[74]=Z):Z=e[74];let R;e[75]!==O||e[76]!==Z?(R=s.jsx(le,{type:"submit",size:"sm",disabled:O,children:Z}),e[75]=O,e[76]=Z,e[77]=R):R=e[77];let D;e[78]!==W||e[79]!==R?(D=s.jsxs(He,{children:[W,R]}),e[78]=W,e[79]=R,e[80]=D):D=e[80];let q;return e[81]!==C||e[82]!==H||e[83]!==U||e[84]!==D||e[85]!==w?(q=s.jsxs("form",{onSubmit:w,className:"space-y-3",children:[C,H,U,D]}),e[81]=C,e[82]=H,e[83]=U,e[84]=D,e[85]=w,e[86]=q):q=e[86],q}const us=Be({label:ve().optional(),baseUrl:ve().min(1,"Base URL is required"),apiKey:ve().optional()});function ms(n){const e=G.c(105),{preset:t,onCancel:i,onSuccess:o}=n,{org:l}=xe(),a=Ne(),r=we(),[h,d]=$.useState(!1),c=se();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=We(us),e[0]=f):f=e[0];const p=t?.defaultBaseUrl??"";let u;e[1]!==p?(u={resolver:f,defaultValues:{label:"",baseUrl:p,apiKey:""}},e[1]=p,e[2]=u):u=e[2];const{register:m,handleSubmit:j,formState:N}=Ve(u),{errors:S}=N;let b;e[3]!==t||e[4]!==a?(b=async ae=>{const ht=JSON.stringify({baseUrl:ae.baseUrl,apiKey:ae.apiKey||""});await a.call("AI_PROVIDER_KEY_CREATE",{providerId:"openai-compatible",label:ae.label||t?.name||ae.baseUrl,apiKey:ht,...t?{presetId:t.id}:{}})},e[3]=t,e[4]=a,e[5]=b):b=e[5];let I;e[6]!==o||e[7]!==l||e[8]!==r||e[9]!==c?(I=()=>{r.invalidateQueries({queryKey:ce.aiProviderKeys(l.id)}),r.invalidateQueries({queryKey:ce.aiProviders(l.id)}),ne.success(c("settings.connectForms.connectionSavedSuccess")),o()},e[6]=o,e[7]=l,e[8]=r,e[9]=c,e[10]=I):I=e[10];let E;e[11]!==c?(E=ae=>{ne.error(c("settings.connectForms.failedSaveConnection",{error:ae.message}))},e[11]=c,e[12]=E):E=e[12];let O;e[13]!==b||e[14]!==I||e[15]!==E?(O={mutationFn:b,onSuccess:I,onError:E},e[13]=b,e[14]=I,e[15]=E,e[16]=O):O=e[16];const{mutate:k,isPending:x,error:w}=je(O);let _;e[17]!==t||e[18]!==c?(_=t?c("settings.connectForms.labelPlaceholderPreset",{name:t.name}):c("settings.connectForms.labelPlaceholderOpenAiCompatible"),e[17]=t,e[18]=c,e[19]=_):_=e[19];const M=_;let v;e[20]!==t?.baseUrlPlaceholder||e[21]!==c?(v=t?.baseUrlPlaceholder??c("settings.connectForms.baseUrlPlaceholder"),e[20]=t?.baseUrlPlaceholder,e[21]=c,e[22]=v):v=e[22];const g=v;let y;e[23]!==k?(y=ae=>k(ae),e[23]=k,e[24]=y):y=e[24];let C;e[25]!==j||e[26]!==y?(C=j(y),e[25]=j,e[26]=y,e[27]=C):C=e[27];let z;e[28]!==c?(z=c("settings.connectForms.labelField"),e[28]=c,e[29]=z):z=e[29];let A;e[30]!==z?(A=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:z}),e[30]=z,e[31]=A):A=e[31];let P;e[32]!==m?(P=m("label"),e[32]=m,e[33]=P):P=e[33];let T;e[34]!==M||e[35]!==P?(T=s.jsx(pe,{placeholder:M,...P,className:"h-8 text-sm"}),e[34]=M,e[35]=P,e[36]=T):T=e[36];let L;e[37]!==A||e[38]!==T?(L=s.jsxs("div",{className:"space-y-1",children:[A,T]}),e[37]=A,e[38]=T,e[39]=L):L=e[39];let F;e[40]!==g||e[41]!==S||e[42]!==t?.defaultBaseUrl||e[43]!==m||e[44]!==c?(F=t?.defaultBaseUrl?s.jsx("input",{type:"hidden",...m("baseUrl")}):s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:c("settings.connectForms.baseUrlField")}),s.jsx(pe,{type:"url",placeholder:g,...m("baseUrl"),className:"h-8 text-sm"}),S.baseUrl&&s.jsx("p",{className:"text-xs text-destructive",children:S.baseUrl.message})]}),e[40]=g,e[41]=S,e[42]=t?.defaultBaseUrl,e[43]=m,e[44]=c,e[45]=F):F=e[45];let K;e[46]!==c?(K=c("settings.connectForms.apiKeyField"),e[46]=c,e[47]=K):K=e[47];let X;e[48]!==t?.apiKeyRecommended||e[49]!==c?(X=t?.apiKeyRecommended?c("settings.connectForms.recommended"):c("settings.connectForms.optional"),e[48]=t?.apiKeyRecommended,e[49]=c,e[50]=X):X=e[50];let V;e[51]!==X?(V=s.jsxs("span",{className:"text-muted-foreground/60",children:["(",X,")"]}),e[51]=X,e[52]=V):V=e[52];let Q;e[53]!==K||e[54]!==V?(Q=s.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:[K," ",V]}),e[53]=K,e[54]=V,e[55]=Q):Q=e[55];const J=h?"text":"password";let H;e[56]!==m?(H=m("apiKey"),e[56]=m,e[57]=H):H=e[57];let U;e[58]!==J||e[59]!==H?(U=s.jsx(pe,{type:J,placeholder:"sk-...",...H,className:"ph-no-capture h-8 text-sm pr-8"}),e[58]=J,e[59]=H,e[60]=U):U=e[60];let B;e[61]!==h?(B=()=>d(!h),e[61]=h,e[62]=B):B=e[62];let W;e[63]!==h||e[64]!==c?(W=c(h?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[63]=h,e[64]=c,e[65]=W):W=e[65];let Z;e[66]!==h?(Z=h?s.jsx(Qe,{size:14}):s.jsx(tt,{size:14}),e[66]=h,e[67]=Z):Z=e[67];let R;e[68]!==B||e[69]!==W||e[70]!==Z?(R=s.jsx("button",{type:"button",onClick:B,"aria-label":W,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:Z}),e[68]=B,e[69]=W,e[70]=Z,e[71]=R):R=e[71];let D;e[72]!==U||e[73]!==R?(D=s.jsxs("div",{className:"relative",children:[U,R]}),e[72]=U,e[73]=R,e[74]=D):D=e[74];let q;e[75]!==Q||e[76]!==D?(q=s.jsxs("div",{className:"space-y-1",children:[Q,D]}),e[75]=Q,e[76]=D,e[77]=q):q=e[77];let Y;e[78]!==t?(Y=t?.helpText&&s.jsx("p",{className:"text-xs text-muted-foreground",children:t.helpText}),e[78]=t,e[79]=Y):Y=e[79];let te;e[80]!==w?(te=w&&s.jsx("p",{className:"text-xs text-destructive",children:w.message}),e[80]=w,e[81]=te):te=e[81];let re;e[82]!==c?(re=c("settings.connectForms.cancel"),e[82]=c,e[83]=re):re=e[83];let de;e[84]!==x||e[85]!==i||e[86]!==re?(de=s.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:x,children:re}),e[84]=x,e[85]=i,e[86]=re,e[87]=de):de=e[87];let he;e[88]!==x||e[89]!==c?(he=c(x?"settings.connectForms.saving":"settings.connectForms.saveConnection"),e[88]=x,e[89]=c,e[90]=he):he=e[90];let ue;e[91]!==x||e[92]!==he?(ue=s.jsx(le,{type:"submit",size:"sm",disabled:x,children:he}),e[91]=x,e[92]=he,e[93]=ue):ue=e[93];let me;e[94]!==de||e[95]!==ue?(me=s.jsxs(He,{children:[de,ue]}),e[94]=de,e[95]=ue,e[96]=me):me=e[96];let ye;return e[97]!==C||e[98]!==L||e[99]!==F||e[100]!==q||e[101]!==Y||e[102]!==te||e[103]!==me?(ye=s.jsxs("form",{onSubmit:C,className:"space-y-3",children:[L,F,q,Y,te,me]}),e[97]=C,e[98]=L,e[99]=F,e[100]=q,e[101]=Y,e[102]=te,e[103]=me,e[104]=ye):ye=e[104],ye}const fs={kind:"closed"};function ps(n,e){switch(e.type){case"open":return n.kind==="closed"?{kind:"grid"}:n;case"close":return{kind:"closed"};case"back":switch(n.kind){case"form":case"oauth-pending":case"provision-pending":case"provision-error":return{kind:"grid"};default:return n}case"select-form":return n.kind!=="grid"?n:{kind:"form",providerId:e.providerId,presetId:e.presetId};case"select-oauth":return n.kind!=="grid"?n:{kind:"oauth-pending",providerId:e.providerId,stateToken:e.stateToken};case"oauth-failed":return n.kind==="oauth-pending"?{kind:"grid"}:n;case"select-provision":return n.kind!=="grid"?n:{kind:"provision-pending",providerId:e.providerId};case"provision-error":return n.kind!=="provision-pending"?n:{kind:"provision-error",providerId:n.providerId,error:e.error};case"retry-provision":return n.kind!=="provision-error"?n:{kind:"provision-pending",providerId:n.providerId}}}function xs(n){switch(n.kind){case"form":case"oauth-pending":case"provision-pending":case"provision-error":return n.providerId;default:return null}}function gs({open:n,onOpenChange:e,initialProvider:t}){const i=se(),l=ke()?.providers??[],{org:a}=xe(),r=Ne(),h=we(),[d,c]=$.useReducer(ps,fs),f=$.useRef(!1);$.useEffect(()=>{n&&d.kind==="closed"?c({type:"open"}):!n&&d.kind!=="closed"&&c({type:"close"})},[n,d.kind]);const p=()=>{f.current=!1,c({type:"close"}),e(!1)},u=()=>{h.invalidateQueries({queryKey:ce.aiProviderKeys(a.id)}),h.invalidateQueries({queryKey:ce.aiProviders(a.id)})},{mutate:m}=je({mutationFn:async({providerId:v,code:g,stateToken:y,label:C})=>(await r.call("AI_PROVIDER_OAUTH_EXCHANGE",{providerId:v,code:g,stateToken:y,label:C}),v),onSuccess:v=>{ie("ai_provider_oauth_succeeded",{provider_id:v}),u();const g=l.find(y=>y.id===v);ne.success(i("settings.connectProviderDialog.oauthSuccessMessage",{provider:g?.name??i("settings.connectProviderDialog.defaultProviderName")})),p()},onError:(v,g)=>{ie("ai_provider_oauth_failed",{provider_id:g.providerId,error:v.message}),ne.error(i("settings.connectProviderDialog.oauthFailedMessage",{error:v.message})),c({type:"oauth-failed"})}}),{mutate:j}=je({mutationFn:async v=>(await r.call("AI_PROVIDER_PROVISION_KEY",{providerId:v}),v),onSuccess:v=>{ie("ai_provider_provision_succeeded",{provider_id:v}),u();const g=l.find(y=>y.id===v);ne.success(i("settings.connectProviderDialog.provisionSuccessMessage",{provider:g?.name??i("settings.connectProviderDialog.defaultProviderName")})),p()},onError:(v,g)=>{ie("ai_provider_provision_failed",{provider_id:g,error:v.message}),c({type:"provision-error",error:v.message})}}),N=async v=>{const{provider:g}=v,y=v.kind==="openai-compatible"?v.preset?.id??null:null,C=g.supportedMethods.includes("oauth-pkce"),z=g.supportedMethods.includes("api-key");if(g.supportsProvision===!0){ie("ai_provider_connect_clicked",{provider_id:g.id,method:"provision"}),c({type:"select-provision",providerId:g.id}),j(g.id);return}if(C){ie("ai_provider_connect_clicked",{provider_id:g.id,method:"oauth-pkce"});try{const P=await r.call("AI_PROVIDER_OAUTH_URL",{providerId:g.id,callbackUrl:`${window.location.origin}/oauth/callback/ai-provider`});if(!P?.url)throw new Error("Invalid response from AI_PROVIDER_OAUTH_URL");c({type:"select-oauth",providerId:g.id,stateToken:P.stateToken}),window.open(P.url,"AiProviderOAuth","width=600,height=700")}catch(P){ne.error(i("settings.connectProviderDialog.startOAuthFailedMessage",{error:P instanceof Error?P.message:String(P)}))}return}z&&(ie("ai_provider_connect_clicked",{provider_id:g.id,...y!==null?{preset_id:y}:{},method:"api-key"}),c({type:"select-form",providerId:g.id,presetId:y}))},S=$.useRef(N);S.current=N;const b=$.useRef(t);b.current=t,$.useEffect(()=>{!b.current||d.kind!=="grid"||f.current||(f.current=!0,S.current(b.current))},[d.kind]);const I=d.kind==="oauth-pending"?d.stateToken:null,E=d.kind==="oauth-pending"?d.providerId:null;$.useEffect(()=>{if(d.kind!=="oauth-pending")return;let v=!1;const g=d.stateToken,y=d.providerId,C=A=>{if(A.origin!==window.location.origin||A.data?.type!=="AI_PROVIDER_OAUTH_CALLBACK")return;const{code:P,stateToken:T}=A.data;if(T!==g){ne.error(i("settings.connectProviderDialog.securityCheckFailedMessage")),c({type:"oauth-failed"});return}v=!0;const L=l.find(F=>F.id===y);m({providerId:y,code:P,stateToken:g,label:L?.name??y})};window.addEventListener("message",C);const z=setTimeout(()=>{v||(ie("ai_provider_oauth_timeout",{provider_id:y}),c({type:"oauth-failed"}),ne.error(i("settings.connectProviderDialog.connectionTimedOutMessage")))},12e4);return()=>{window.removeEventListener("message",C),clearTimeout(z)}},[d.kind,I,E,m]);const O=xs(d),k=O?l.find(v=>v.id===O):null,w=(d.kind==="form"&&d.presetId?be(d.presetId):null)?.name??k?.name??i("settings.connectProviderDialog.defaultTitle"),_=d.kind!=="grid"&&d.kind!=="closed",M=()=>{t?p():c({type:"back"})};return s.jsx(qe,{open:d.kind!=="closed",onOpenChange:v=>!v&&p(),children:s.jsxs(Ye,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",children:[s.jsxs(gt,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[_&&s.jsx(le,{variant:"ghost",size:"icon","aria-label":i("settings.connectProviderDialog.backButtonLabel"),className:"h-7 w-7",onClick:M,children:s.jsx(Je,{size:16})}),s.jsx(Ge,{children:w})]}),d.kind==="grid"&&!t&&s.jsx(vt,{children:i("settings.connectProviderDialog.gridDescription")})]}),d.kind==="grid"&&!t&&s.jsx(nt,{providers:l,onSelect:N}),d.kind==="form"&&(d.providerId==="openai-compatible"?s.jsx(ms,{preset:d.presetId?be(d.presetId):void 0,onCancel:()=>c({type:"back"}),onSuccess:()=>{u(),p()}}):s.jsx(hs,{providerId:d.providerId,onCancel:()=>c({type:"back"}),onSuccess:()=>{u(),p()}})),d.kind==="oauth-pending"&&s.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[s.jsx(Ee,{size:"lg"}),s.jsx("p",{className:"text-sm text-muted-foreground text-center",children:i("settings.connectProviderDialog.oauthPendingMessage")})]}),d.kind==="provision-pending"&&s.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[s.jsx(Ee,{size:"lg"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:i("settings.connectProviderDialog.provisionPendingMessage")})]}),d.kind==="provision-error"&&s.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[s.jsx($t,{size:28,className:"text-destructive"}),s.jsx("p",{className:"text-sm text-foreground text-center",children:d.error}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(le,{variant:"outline",size:"sm",onClick:()=>c({type:"back"}),children:i("settings.connectProviderDialog.backButton")}),s.jsx(le,{size:"sm",onClick:()=>{c({type:"retry-provision"}),j(d.providerId)},children:i("settings.connectProviderDialog.retryButton")})]})]})]})})}function vs(){const n=G.c(7),{org:e}=xe(),t=Ne();let i;n[0]!==e.id?(i=ce.defaultBrand(e.id),n[0]=e.id,n[1]=i):i=n[1];let o;n[2]!==t?(o=async()=>{const{items:r}=await t.call("BRAND_CONTEXT_LIST",{});return(Array.isArray(r)?r:[]).find(bs)??null},n[2]=t,n[3]=o):o=n[3];let l;n[4]!==i||n[5]!==o?(l={queryKey:i,queryFn:o},n[4]=i,n[5]=o,n[6]=l):l=n[6];const{data:a}=mt(l);return a??null}function bs(n){return n.isDefault&&!n.archivedAt}function ys(n){const e=n.colors;if(!e)return null;if(Array.isArray(e)){const t=e.find(o=>typeof o=="object"&&o!==null&&"label"in o&&/primary|brand|main/i.test(o.label)),i=t?t.value:e[0]?.value;return typeof i=="string"?i:null}if(typeof e=="object"){const t=e;return t.primary??Object.values(t)[0]??null}return null}function js(n){const e=G.c(49);let t;e[0]!==n?(t=n===void 0?{}:n,e[0]=n,e[1]=t):t=e[1];const{title:i,description:o}=t,l=se(),{org:a}=xe(),r=vs(),[h,d]=$.useState(null),[c,f]=$.useState(!1),[p,u]=$.useState(!1),m=Ht();let j;e[2]!==m?(j=Wt()&&!m,e[2]=m,e[3]=j):j=e[3];const N=j,S=ke();let b;e[4]!==S?.providers?(b=S?.providers??[],e[4]=S?.providers,e[5]=b):b=e[5];const I=b,E=a.name;let O;e[6]!==r?(O=r?ys(r):null,e[6]=r,e[7]=O):O=e[7];const k=O,x=r?.favicon??r?.logo??null;let w;e[8]!==E||e[9]!==l||e[10]!==i?(w=i??(E?l("chat.noAiProviderEmptyState.headingWithOrg",{org:E}):l("chat.noAiProviderEmptyState.headingDefault")),e[8]=E,e[9]=l,e[10]=i,e[11]=w):w=e[11];const _=w;let M;e[12]!==o||e[13]!==l?(M=o??l("chat.noAiProviderEmptyState.subtitleDefault"),e[12]=o,e[13]=l,e[14]=M):M=e[14];const v=M,g=!!(x||k);let y;e[15]!==k?(y=k?{backgroundColor:`${k}18`,borderColor:`${k}30`}:void 0,e[15]=k,e[16]=y):y=e[16];const C=y,z=g?"flex items-center justify-center size-14 rounded-2xl border":"flex items-center justify-center size-14 rounded-2xl bg-muted border border-border";let A;e[17]!==z||e[18]!==C||e[19]!==x||e[20]!==N||e[21]!==k||e[22]!==l?(A=x?s.jsx("div",{className:z,style:C,children:s.jsx("img",{src:x,alt:"",className:"size-7 rounded object-contain"})}):N?s.jsx("button",{type:"button",onClick:()=>u(!0),"aria-label":l("downloadApp.openLabel"),className:oe(z,"cursor-pointer transition-colors hover:bg-accent"),style:C,children:s.jsx(Me,{size:24,style:k?{color:k}:void 0,className:oe(!k&&"text-muted-foreground")})}):s.jsx("div",{className:z,style:C,children:s.jsx(Me,{size:24,style:k?{color:k}:void 0,className:oe(!k&&"text-muted-foreground")})}),e[17]=z,e[18]=C,e[19]=x,e[20]=N,e[21]=k,e[22]=l,e[23]=A):A=e[23];let P;e[24]!==_?(P=s.jsx("p",{className:"text-xl font-semibold text-foreground tracking-tight",children:_}),e[24]=_,e[25]=P):P=e[25];let T;e[26]!==v?(T=s.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:v}),e[26]=v,e[27]=T):T=e[27];let L;e[28]!==T||e[29]!==P?(L=s.jsxs("div",{className:"space-y-2",children:[P,T]}),e[28]=T,e[29]=P,e[30]=L):L=e[30];let F;e[31]!==L||e[32]!==A?(F=s.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[A,L]}),e[31]=L,e[32]=A,e[33]=F):F=e[33];let K,X;e[34]===Symbol.for("react.memo_cache_sentinel")?(K=Z=>d(Z),X=()=>f(!0),e[34]=K,e[35]=X):(K=e[34],X=e[35]);let V;e[36]!==I?(V=s.jsx("div",{className:"w-full",children:s.jsx(nt,{providers:I,onSelect:K,onShowAll:X})}),e[36]=I,e[37]=V):V=e[37];const Q=h!==null||c;let J;e[38]===Symbol.for("react.memo_cache_sentinel")?(J=Z=>{Z||(d(null),f(!1))},e[38]=J):J=e[38];const H=h??void 0;let U;e[39]!==Q||e[40]!==H?(U=s.jsx(gs,{open:Q,onOpenChange:J,initialProvider:H}),e[39]=Q,e[40]=H,e[41]=U):U=e[41];let B;e[42]!==p?(B=s.jsx(Vt,{open:p,onOpenChange:u}),e[42]=p,e[43]=B):B=e[43];let W;return e[44]!==F||e[45]!==V||e[46]!==U||e[47]!==B?(W=s.jsxs("div",{className:"flex flex-col items-center gap-8 w-full max-w-3xl px-4",children:[F,V,U,B]}),e[44]=F,e[45]=V,e[46]=U,e[47]=B,e[48]=W):W=e[48],W}function Ce(n){const e=n.title.includes(": ");return{provider:e?n.title.split(": ")[0]??"":n.modelId.split("/")[0]??"",displayName:e?n.title.split(": ").slice(1).join(": "):n.title}}function Ss(n){return n<32e3?{level:1,labelKey:"chat.shared.contextLevelSmall",descriptionKey:"chat.shared.contextLevelSmallDesc"}:n<2e5?{level:2,labelKey:"chat.shared.contextLevelMedium",descriptionKey:"chat.shared.contextLevelMediumDesc"}:n<5e5?{level:3,labelKey:"chat.shared.contextLevelLarge",descriptionKey:"chat.shared.contextLevelLargeDesc"}:{level:4,labelKey:"chat.shared.contextLevelVeryLarge",descriptionKey:"chat.shared.contextLevelVeryLargeDesc"}}const Ns=["bg-destructive","bg-warning","bg-success","bg-success"],ws=["text-success","text-warning","text-warning","text-destructive"];function ks(n,e){const t=Math.round(n*.75/1e3),i=t>=1?`${t}K`:`${Math.round(n*.75)}`;return e("chat.shared.approxWords",{wordCount:i})}function _s(n){return n<1?{level:1,labelKey:"chat.shared.costLevelCheap"}:n<5?{level:2,labelKey:"chat.shared.costLevelModerate"}:n<15?{level:3,labelKey:"chat.shared.costLevelHigh"}:{level:4,labelKey:"chat.shared.costLevelExpensive"}}const Cs={text:{icon:s.jsx(zt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityText"},vision:{icon:s.jsx(Lt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityVision"},image:{icon:s.jsx(Ot,{className:"size-3.5"}),labelKey:"chat.shared.capabilityImage"},tools:{icon:s.jsx(Tt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityTools"},reasoning:{icon:s.jsx(qt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityReasoning"},"web-search":{icon:s.jsx(Ze,{className:"size-3.5"}),labelKey:"chat.shared.capabilityWebSearch"}};function Is(n){const e=G.c(10),{capability:t}=n,i=se(),o=Cs[t];if(o){const h=o.icon;let d;e[0]!==o.labelKey||e[1]!==i?(d=i(o.labelKey),e[0]=o.labelKey,e[1]=i,e[2]=d):d=e[2];let c;return e[3]!==o.icon||e[4]!==d?(c=s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground border border-border rounded px-2 py-0.5",children:[h,d]}),e[3]=o.icon,e[4]=d,e[5]=c):c=e[5],c}let l;e[6]!==t?(l=t.charAt(0).toUpperCase(),e[6]=t,e[7]=l):l=e[7];const a=l+t.slice(1);let r;return e[8]!==a?(r=s.jsx("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground border border-border rounded px-2 py-0.5",children:a}),e[8]=a,e[9]=r):r=e[9],r}function Ms(n){const e=G.c(59),{model:t,compact:i}=n,o=i===void 0?!1:i,l=se();if(!t){let x;e[0]!==l?(x=l("chat.shared.hoverToPreview"),e[0]=l,e[1]=x):x=e[1];let w;return e[2]!==x?(w=s.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:x}),e[2]=x,e[3]=w):w=e[3],w}const a=t.costs?.input!=null?t.costs.input*1e6:null,r=t.costs?.output!=null?t.costs.output*1e6:null;let h;e[4]!==t?(h=Ce(t),e[4]=t,e[5]=h):h=e[5];const{provider:d,displayName:c}=h;if(o){let x;e[6]!==t.limits||e[7]!==l?(x=t.limits?.contextWindow&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:l("chat.shared.context")}),s.jsxs("span",{className:"text-foreground font-medium",children:[t.limits.contextWindow.toLocaleString()," ",l("chat.shared.tokens")]})]}),e[6]=t.limits,e[7]=l,e[8]=x):x=e[8];let w;e[9]!==a||e[10]!==l?(w=a!=null&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:l("chat.shared.input")}),s.jsxs("span",{className:"text-foreground font-medium",children:["$",a.toFixed(2)," / 1M"]})]}),e[9]=a,e[10]=l,e[11]=w):w=e[11];let _;e[12]!==r||e[13]!==l?(_=r!=null&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:l("chat.shared.output")}),s.jsxs("span",{className:"text-foreground font-medium",children:["$",r.toFixed(2)," / 1M"]})]}),e[12]=r,e[13]=l,e[14]=_):_=e[14];let M;e[15]!==t.limits||e[16]!==l?(M=t.limits?.maxOutputTokens&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:l("chat.shared.outputLimit")}),s.jsxs("span",{className:"text-foreground font-medium",children:[t.limits.maxOutputTokens.toLocaleString()," ",l("chat.shared.tokens")]})]}),e[15]=t.limits,e[16]=l,e[17]=M):M=e[17];let v;return e[18]!==x||e[19]!==w||e[20]!==_||e[21]!==M?(v=s.jsxs("div",{className:"flex flex-col gap-2 pt-3 pb-3 px-3 text-xs",children:[x,w,_,M]}),e[18]=x,e[19]=w,e[20]=_,e[21]=M,e[22]=v):v=e[22],v}let f;e[23]!==d?(f=s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:d}),e[23]=d,e[24]=f):f=e[24];let p;e[25]!==t.logo||e[26]!==t.title?(p=t.logo&&s.jsx("img",{src:t.logo,className:"size-6 shrink-0 rounded-md dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[25]=t.logo,e[26]=t.title,e[27]=p):p=e[27];let u;e[28]!==c?(u=s.jsx("p",{className:"text-lg font-semibold leading-snug tracking-tight",children:c}),e[28]=c,e[29]=u):u=e[29];let m;e[30]!==p||e[31]!==u?(m=s.jsxs("div",{className:"flex items-center gap-2.5",children:[p,u]}),e[30]=p,e[31]=u,e[32]=m):m=e[32];let j;e[33]!==t.modelId?(j=s.jsx("p",{className:"text-xs text-muted-foreground/50 font-mono",children:t.modelId}),e[33]=t.modelId,e[34]=j):j=e[34];let N;e[35]!==f||e[36]!==m||e[37]!==j?(N=s.jsxs("div",{className:"flex flex-col gap-1 pt-1 pr-6",children:[f,m,j]}),e[35]=f,e[36]=m,e[37]=j,e[38]=N):N=e[38];let S;e[39]!==t.capabilities?(S=t.capabilities&&t.capabilities.length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pb-4 border-b border-border",children:[...new Set(t.capabilities)].map(Es)}),e[39]=t.capabilities,e[40]=S):S=e[40];let b;e[41]!==t.limits||e[42]!==l?(b=t.limits?.contextWindow&&(()=>{const{level:x,labelKey:w,descriptionKey:_}=Ss(t.limits.contextWindow);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:l("chat.shared.contextWindow")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex items-center gap-0.5",children:[1,2,3,4].map(M=>s.jsx("div",{className:oe("w-2 h-2 rounded-full",M<=x?Ns[x-1]:"bg-muted")},M))}),s.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:l(w)}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["— ",l(_)]})]}),s.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.limits.contextWindow.toLocaleString()," ",l("chat.shared.tokens")]})]})})(),e[41]=t.limits,e[42]=l,e[43]=b):b=e[43];let I;e[44]!==t.limits||e[45]!==l?(I=t.limits?.maxOutputTokens&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:l("chat.shared.outputLimit")}),s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsxs("span",{className:"text-sm text-foreground",children:[t.limits.maxOutputTokens.toLocaleString()," ",l("chat.shared.tokens")]}),s.jsx("span",{className:"text-sm text-muted-foreground",children:ks(t.limits.maxOutputTokens,l)})]})]}),e[44]=t.limits,e[45]=l,e[46]=I):I=e[46];let E;e[47]!==a||e[48]!==r||e[49]!==l?(E=(a!=null||r!=null)&&(()=>{const{level:x,labelKey:w}=a!=null?_s(a):{level:0,labelKey:null};return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:l("chat.shared.pricing")}),a!=null&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex items-center",children:[1,2,3,4].map(_=>s.jsx("span",{className:oe("text-sm font-bold leading-none",_<=x?ws[x-1]:"text-muted-foreground/20"),children:"$"},_))}),s.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:w?l(w):""})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[a!=null&&s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:l("chat.shared.input")}),s.jsxs("span",{className:"text-xs text-foreground",children:["$",a.toFixed(2)," / 1M"," ",l("chat.shared.tokens")]})]}),r!=null&&s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:l("chat.shared.output")}),s.jsxs("span",{className:"text-xs text-foreground",children:["$",r.toFixed(2)," / 1M"," ",l("chat.shared.tokens")]})]})]})]})})(),e[47]=a,e[48]=r,e[49]=l,e[50]=E):E=e[50];let O;e[51]!==b||e[52]!==I||e[53]!==E?(O=s.jsxs("div",{className:"flex flex-col gap-6",children:[b,I,E]}),e[51]=b,e[52]=I,e[53]=E,e[54]=O):O=e[54];let k;return e[55]!==O||e[56]!==N||e[57]!==S?(k=s.jsxs("div",{className:"flex flex-col gap-5 py-1 px-1.5",children:[N,S,O]}),e[55]=O,e[56]=N,e[57]=S,e[58]=k):k=e[58],k}function Es(n){return s.jsx(Is,{capability:n},n)}function lt(n){const e=G.c(22),{model:t,placeholder:i,isLoading:o}=n,l=o===void 0?!1:o,a=se();let r;e[0]!==i||e[1]!==a?(r=i??a("chat.shared.selectModel"),e[0]=i,e[1]=a,e[2]=r):r=e[2];const h=r;if(l){let S;return e[3]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(ee,{className:"w-5 h-5 rounded-sm shrink-0"}),s.jsx(ee,{className:"w-16 h-3 hidden md:block"})]}),e[3]=S):S=e[3],S}if(!t){let S;e[4]!==h?(S=s.jsx("span",{className:"text-sm text-muted-foreground",children:h}),e[4]=h,e[5]=S):S=e[5];let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(Pe,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[6]=b):b=e[6];let I;return e[7]!==S?(I=s.jsxs("div",{className:"flex items-center gap-1.5",children:[S,b]}),e[7]=S,e[8]=I):I=e[8],I}let d;e[9]!==t?(d=Ce(t),e[9]=t,e[10]=d):d=e[10];const{displayName:c}=d;let f;e[11]!==t?(f=_e(t),e[11]=t,e[12]=f):f=e[12];const p=f;let u;e[13]!==t.title||e[14]!==p?(u=s.jsx("img",{src:p,className:"w-3.5 h-3.5 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[13]=t.title,e[14]=p,e[15]=u):u=e[15];let m;e[16]!==c?(m=s.jsx("span",{className:"text-sm truncate whitespace-nowrap text-muted-foreground max-w-[100px] sm:max-w-none",children:c}),e[16]=c,e[17]=m):m=e[17];let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Pe,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[18]=j):j=e[18];let N;return e[19]!==u||e[20]!==m?(N=s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden",children:[u,m,j]}),e[19]=u,e[20]=m,e[21]=N):N=e[21],N}const Os=["vision","image","file","audio","video"],ot=["image/png","image/jpeg","image/gif","image/webp"],rt=["application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];function Ie(n){const e=n?.capabilities;return e?Os.some(t=>e.includes(t)):!1}function Li(n,e){if(!n)return!1;if(n.startsWith("text/"))return!0;const t=e?.capabilities??[],i=t.includes("vision")||t.includes("image"),o=t.includes("file"),l=t.includes("audio"),a=t.includes("video");return!!(i&&ot.includes(n)||o&&n==="application/pdf"||l&&n.startsWith("audio/")||a&&n.startsWith("video/")||Ie(e)&&rt.includes(n))}function zi(n){const e=n?.capabilities??[],t=["text/*"];return(e.includes("vision")||e.includes("image"))&&t.push(...ot),e.includes("file")&&t.push("application/pdf"),e.includes("audio")&&t.push("audio/*"),e.includes("video")&&t.push("video/*"),Ie(n)&&t.push(...rt),t.join(",")}function Ri(n){const e=n?.capabilities??[],t=[];return(e.includes("vision")||e.includes("image"))&&t.push("chat.shared.fileTypeImages"),e.includes("file")&&t.push("chat.shared.fileTypePdfs"),e.includes("audio")&&t.push("chat.shared.fileTypeAudio"),e.includes("video")&&t.push("chat.shared.fileTypeVideo"),Ie(n)&&t.push("chat.shared.fileTypeOffice"),{parts:t,count:t.length}}const at=["smarter","faster","cheaper"],As={smarter:"chat.decopilot.tierSmarter",faster:"chat.decopilot.tierFaster",cheaper:"chat.decopilot.tierCheaper"},Ps=[{tier:"smarter",prefixes:["anthropic/claude-opus-4.8","anthropic/claude-sonnet-4.6","anthropic/claude-4.6-sonnet","openai/gpt-5.3-codex","google/gemini-3-pro","google/gemini-2.5-pro","cohere/command-r-plus","cohere/command-a"]},{tier:"faster",prefixes:["anthropic/claude-haiku-4.5","anthropic/claude-4.5-haiku","google/gemini-3-flash","openai/gpt-5.1-codex-mini","x-ai/grok-code-fast","x-ai/grok-3","mistralai/mistral-large","mistralai/codestral","mistralai/mistral-medium","minimax/minimax-m1"]},{tier:"cheaper",prefixes:["google/gemini-2.5-flash-lite","google/gemini-2.5-flash","google/gemini-2.0-flash","deepseek/deepseek-v3","openai/gpt-oss-120b","mistralai/mistral-small","mistralai/pixtral","cohere/command-r"]}],Ts=Ps.flatMap(({tier:n,prefixes:e})=>e.map(t=>({tier:n,prefix:t}))).sort((n,e)=>e.prefix.length-n.prefix.length),Ls="google/gemini-2.5-pro",De=new Map;function zs(n){const e=De.get(n);if(e!==void 0)return e;let t=null;if(n.endsWith(":free"))t="cheaper";else for(const{tier:i,prefix:o}of Ts)if(n.startsWith(o)){if(o===Ls&&n.length>o.length&&n[o.length]==="-"){const a=n[o.length+1];if(!a||!/\d/.test(a))continue}t=i;break}return De.set(n,t),t}function $e(n){const e={smarter:[],faster:[],cheaper:[],other:[]};for(const t of n){const i=zs(t.modelId);e[i??"other"].push(t)}for(const t of Object.keys(e))e[t].sort((i,o)=>i.title.localeCompare(o.title));return e}const ct="studio:model-shortlist:",Rs=new Set(["anthropic/claude-opus-4.8","anthropic/claude-sonnet-4.6","anthropic/claude-4.6-sonnet","anthropic/claude-sonnet-4.6:extended","openai/gpt-5.3-codex","google/gemini-3-pro-preview","google/gemini-2.5-pro","anthropic/claude-haiku-4.5","anthropic/claude-haiku-4.5-20251001","anthropic/claude-4.5-haiku","google/gemini-3-flash-preview","openai/gpt-5.1-codex-mini","x-ai/grok-code-fast-1","google/gemini-2.5-flash","deepseek/deepseek-v3.2","google/gemini-2.5-flash-lite","openai/gpt-oss-120b:free"]);function Fs(n){try{const e=localStorage.getItem(ct+n);return e?new Set(JSON.parse(e)):null}catch{return null}}function Ks(n,e){localStorage.setItem(ct+n,JSON.stringify([...e]))}function Ds(n){const e=G.c(21),{model:t,onHover:i}=n;let o;e[0]!==t?(o=Ce(t),e[0]=t,e[1]=o):o=e[1];const{displayName:l,provider:a}=o;let r;e[2]!==t?(r=_e(t),e[2]=t,e[3]=r):r=e[3];const h=r;let d;e[4]!==t||e[5]!==i?(d=()=>i(t),e[4]=t,e[5]=i,e[6]=d):d=e[6];let c;e[7]!==t.title||e[8]!==h?(c=s.jsx("img",{src:h,className:"w-4 h-4 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[7]=t.title,e[8]=h,e[9]=c):c=e[9];let f;e[10]!==l?(f=s.jsx("span",{className:"text-sm text-foreground leading-tight truncate",children:l}),e[10]=l,e[11]=f):f=e[11];let p;e[12]!==a?(p=s.jsx("span",{className:"text-xs text-muted-foreground/60 leading-tight",children:a}),e[12]=a,e[13]=p):p=e[13];let u;e[14]!==f||e[15]!==p?(u=s.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[f,p]}),e[14]=f,e[15]=p,e[16]=u):u=e[16];let m;return e[17]!==d||e[18]!==c||e[19]!==u?(m=s.jsxs("div",{className:"flex items-center gap-2.5 py-2 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:d,children:[c,u]}),e[17]=d,e[18]=c,e[19]=u,e[20]=m):m=e[20],m}function $s(n){const e=G.c(16),{error:t,onRetry:i}=n,o=se();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx("div",{className:"bg-destructive/10 p-2 rounded-full",children:s.jsx(xt,{className:"size-5 text-destructive"})}),e[0]=l):l=e[0];const a=o("chat.decopilot.failedToLoadModels");let r;e[1]!==a?(r=s.jsx("p",{className:"text-sm font-medium text-foreground",children:a}),e[1]=a,e[2]=r):r=e[2];const h=t?.message||o("chat.decopilot.couldNotFetchModels"),d=" "+o("chat.decopilot.tryAnotherProviderOrRetry");let c;e[3]!==h||e[4]!==d?(c=s.jsxs("p",{className:"text-xs text-muted-foreground max-w-[260px]",children:[h,d]}),e[3]=h,e[4]=d,e[5]=c):c=e[5];let f;e[6]!==r||e[7]!==c?(f=s.jsxs("div",{className:"flex flex-col gap-1",children:[r,c]}),e[6]=r,e[7]=c,e[8]=f):f=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(Pt,{className:"size-3.5"}),e[9]=p):p=e[9];const u=o("chat.decopilot.retry");let m;e[10]!==i||e[11]!==u?(m=s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(le,{variant:"outline",size:"sm",onClick:i,className:"gap-1.5",children:[p,u]})}),e[10]=i,e[11]=u,e[12]=m):m=e[12];let j;return e[13]!==m||e[14]!==f?(j=s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-4 py-8 text-center",children:[l,f,m]}),e[13]=m,e[14]=f,e[15]=j):j=e[15],j}function Us(){const n=G.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:Array.from({length:6}).map(Bs)}),n[0]=e):e=n[0],e}function Bs(n,e){return s.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[s.jsx(ee,{className:"size-5 shrink-0 rounded-sm"}),s.jsx(ee,{className:"flex-1 h-4"}),s.jsx(ee,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function Ue(n){const e=G.c(12),{label:t,models:i,onSelect:o,onHover:l}=n;if(i.length===0)return null;let a;e[0]!==t?(a=s.jsx("div",{className:"text-xs font-medium text-muted-foreground px-3 pt-3 pb-1",children:t}),e[0]=t,e[1]=a):a=e[1];let r;if(e[2]!==i||e[3]!==l||e[4]!==o){let d;e[6]!==l||e[7]!==o?(d=c=>s.jsx("button",{type:"button",onClick:()=>o(c),onFocus:()=>l(c),className:"w-full text-left cursor-pointer",children:s.jsx(Ds,{model:c,onHover:l})},c.modelId),e[6]=l,e[7]=o,e[8]=d):d=e[8],r=i.map(d),e[2]=i,e[3]=l,e[4]=o,e[5]=r}else r=e[5];let h;return e[9]!==a||e[10]!==r?(h=s.jsxs("div",{children:[a,r]}),e[9]=a,e[10]=r,e[11]=h):h=e[11],h}function Se(n,e){return e(n==="other"?"chat.decopilot.tierOther":As[n])}function Ws(n){const e=G.c(21),{model:t,isChecked:i,onToggle:o,onHover:l}=n,[a,r]=$.useState(i);a!==i&&r(i);let h;e[0]!==t?(h=_e(t),e[0]=t,e[1]=h):h=e[1];const d=h;let c;e[2]!==t||e[3]!==l?(c=()=>l(t),e[2]=t,e[3]=l,e[4]=c):c=e[4];let f;e[5]!==t.modelId||e[6]!==o?(f=()=>{r(Vs),o(t.modelId)},e[5]=t.modelId,e[6]=o,e[7]=f):f=e[7];let p;e[8]!==a||e[9]!==f?(p=s.jsx(kt,{checked:a,onCheckedChange:f}),e[8]=a,e[9]=f,e[10]=p):p=e[10];let u;e[11]!==d||e[12]!==t.title?(u=s.jsx("img",{src:d,className:"w-5 h-5 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[11]=d,e[12]=t.title,e[13]=u):u=e[13];let m;e[14]!==t.title?(m=s.jsx("span",{className:"text-sm text-foreground flex-1 min-w-0 line-clamp-1",children:t.title}),e[14]=t.title,e[15]=m):m=e[15];let j;return e[16]!==c||e[17]!==p||e[18]!==u||e[19]!==m?(j=s.jsxs("label",{className:"flex items-center gap-3 min-h-8 py-2.5 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:c,children:[p,u,m]}),e[16]=c,e[17]=p,e[18]=u,e[19]=m,e[20]=j):j=e[20],j}function Vs(n){return!n}function Hs(n,e){const t=[];for(const i of at)if(n[i].length>0){t.push({type:"header",label:Se(i,e)});for(const o of n[i])t.push({type:"model",model:o})}if(n.other.length>0){t.push({type:"header",label:Se("other",e)});for(const i of n.other)t.push({type:"model",model:i})}return t}function qs({items:n,shortlistSet:e,onToggle:t,onHover:i}){const o=$.useRef(null),l=ls({count:n.length,getScrollElement:()=>o.current,estimateSize:a=>n[a]?.type==="header"?36:44,overscan:6});return s.jsx("div",{ref:o,className:"flex-1 overflow-y-auto",children:s.jsx("div",{className:"relative",style:{height:l.getTotalSize()},children:l.getVirtualItems().map(a=>{const r=n[a.index];return r?s.jsx("div",{"data-index":a.index,ref:l.measureElement,className:"absolute left-0 right-0 top-0 px-0.5",style:{transform:`translateY(${a.start}px)`},children:r.type==="header"?s.jsx("div",{className:"text-xs font-medium text-muted-foreground px-3 pt-3 pb-1",children:r.label}):s.jsx(Ws,{model:r.model,isChecked:e.has(r.model.modelId),onToggle:t,onHover:i})},a.key):null})})})}function Ys(n){const e=G.c(30),{keyId:t,searchTerm:i,onHover:o,onModelSelect:l,managing:a,onToggleManage:r,filterModels:h}=n,d=se(),{models:c}=Dt(t),f=h?c.filter(h):c.filter(Gs);let p;e[0]!==t?(p=()=>(t?Fs(t):null)??Rs,e[0]=t,e[1]=p):p=e[1];const[u,m]=$.useState(p),[,j]=$.useTransition();let N;e[2]!==t||e[3]!==j?(N=g=>{t&&j(()=>{m(y=>{const C=new Set(y);return C.has(g)?C.delete(g):C.add(g),Ks(t,C),C})})},e[2]=t,e[3]=j,e[4]=N):N=e[4];const S=N,b=i.toLowerCase().trim(),I=g=>b?g.filter(y=>y.title.toLowerCase().includes(b)||y.modelId.toLowerCase().includes(b)):g;if(a){const g=$e(I(f)),y=Hs(g,d);let C;e[5]!==u?(C=L=>u.has(L.modelId),e[5]=u,e[6]=C):C=e[6];const z=f.filter(C).length;let A;e[7]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(Je,{size:14}),e[7]=A):A=e[7];let P;e[8]!==d?(P=d("chat.decopilot.back"),e[8]=d,e[9]=P):P=e[9];let T;return e[10]!==r||e[11]!==P?(T=s.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground cursor-pointer",children:[A,P]}),e[10]=r,e[11]=P,e[12]=T):T=e[12],s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[T,s.jsx("span",{className:"text-xs text-muted-foreground",children:d("chat.decopilot.selectedCount",{count:z})})]}),s.jsx(qs,{items:y,shortlistSet:u,onToggle:S,onHover:o})]})}let E;e[13]!==u?(E=g=>u.has(g.modelId),e[13]=u,e[14]=E):E=e[14];const O=f.filter(E),k=O.length>0?O:f,x=$e(I(k));let w;e[15]!==x||e[16]!==o||e[17]!==l||e[18]!==d?(w=at.map(g=>s.jsx(Ue,{label:Se(g,d),models:x[g],onSelect:l,onHover:o},g)),e[15]=x,e[16]=o,e[17]=l,e[18]=d,e[19]=w):w=e[19];let _;e[20]!==d?(_=Se("other",d),e[20]=d,e[21]=_):_=e[21];let M;e[22]!==x.other||e[23]!==o||e[24]!==l||e[25]!==_?(M=s.jsx(Ue,{label:_,models:x.other,onSelect:l,onHover:o}),e[22]=x.other,e[23]=o,e[24]=l,e[25]=_,e[26]=M):M=e[26];let v;return e[27]!==w||e[28]!==M?(v=s.jsxs("div",{className:"flex-1 overflow-y-auto px-0.5 pt-1 [touch-action:pan-y]",children:[w,M]}),e[27]=w,e[28]=M,e[29]=v):v=e[29],v}function Gs(n){return n.asyncResearch!==!0}function Xs(){const n=G.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:s.jsxs("div",{className:"flex items-center gap-2.5 h-12 px-4",children:[s.jsx(ee,{className:"size-4 shrink-0"}),s.jsx(ee,{className:"flex-1 h-6"}),s.jsx(ee,{className:"w-[140px] h-8 shrink-0"})]})}),n[0]=e):e=n[0];let t;n[1]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[420px] md:min-w-[420px] min-h-0 overflow-hidden",children:[e,s.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:Array.from({length:8}).map(Qs)})]}),n[1]=t):t=n[1];let i;n[2]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(ee,{className:"size-6 shrink-0"}),s.jsx(ee,{className:"h-6 w-32"})]}),n[2]=i):i=n[2];let o;n[3]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[i,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ee,{className:"h-6 w-20 rounded-md"}),s.jsx(ee,{className:"h-6 w-24 rounded-md"})]})]}),n[3]=o):o=n[3];let l;n[4]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(ee,{className:"h-4 w-24"}),s.jsx(ee,{className:"h-4 w-32"})]}),n[4]=l):l=n[4];let a;return n[5]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsxs("div",{className:"flex flex-col md:flex-row h-full sm:h-[460px] min-h-0",children:[t,s.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:s.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[o,s.jsxs("div",{className:"flex flex-col gap-4",children:[l,s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(ee,{className:"h-4 w-16"}),s.jsx(ee,{className:"h-4 w-40"})]})]})]})})]}),n[5]=a):a=n[5],a}function Qs(n,e){return s.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[s.jsx(ee,{className:"size-5 shrink-0 rounded-sm"}),s.jsx(ee,{className:"flex-1 h-4"}),s.jsx(ee,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function dt(n){const e=G.c(66),{onClose:t,credentialId:i,onCredentialChange:o,selectedModel:l,onModelChange:a,filterModels:r,compact:h}=n,d=se(),[c,f]=$.useState(null),[p,u]=$.useState(""),[m,j]=$.useState(!1),N=$.useRef(null),S=ke(),b=Kt();let I;e[0]!==S?.providers?(I=Object.fromEntries((S?.providers??[]).map(ei)),e[0]=S?.providers,e[1]=I):I=e[1];const E=I,O=ft(),{org:k}=xe();let x;e[2]!==o?(x=R=>{o(R),f(null)},e[2]=o,e[3]=x):x=e[3];const w=x;let _;e[4]!==i||e[5]!==t||e[6]!==a?(_=R=>{i&&(a(R),u(""),t())},e[4]=i,e[5]=t,e[6]=a,e[7]=_):_=e[7];const M=_;if(b.length===0){const R=!h&&"sm:w-[740px]";let D;e[8]!==R?(D=oe("flex items-center justify-center p-8 w-full",R),e[8]=R,e[9]=D):D=e[9];let q;e[10]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(js,{}),e[10]=q):q=e[10];let Y;return e[11]!==D?(Y=s.jsx("div",{className:D,children:q}),e[11]=D,e[12]=Y):Y=e[12],Y}const v=h?"sm:h-[420px]":"sm:h-[460px]";let g;e[13]!==v?(g=oe("flex flex-col md:flex-row h-full min-h-0",v),e[13]=v,e[14]=g):g=e[14];const y=h?"w-full":"md:border-r md:w-[420px] md:min-w-[420px]";let C;e[15]!==y?(C=oe("flex-1 flex flex-col min-h-0 overflow-hidden",y),e[15]=y,e[16]=C):C=e[16];let z;e[17]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(Ze,{size:16,className:"text-muted-foreground shrink-0"}),e[17]=z):z=e[17];let A;e[18]!==m||e[19]!==d?(A=d(m?"chat.decopilot.searchAllModels":"chat.decopilot.searchForModel"),e[18]=m,e[19]=d,e[20]=A):A=e[20];let P;e[21]===Symbol.for("react.memo_cache_sentinel")?(P=R=>u(R.target.value),e[21]=P):P=e[21];let T;e[22]!==p||e[23]!==A?(T=s.jsx(pe,{ref:N,type:"text",placeholder:A,value:p,onChange:P,className:"flex-1 min-w-0 border-0 !shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"}),e[22]=p,e[23]=A,e[24]=T):T=e[24];let L;e[25]!==i||e[26]!==w||e[27]!==b||e[28]!==E||e[29]!==d?(L=b.length>0&&s.jsxs(_t,{value:i??"",onValueChange:w,children:[s.jsxs(Ct,{size:"sm",className:"w-auto max-w-[140px] h-8 shrink-0 gap-1.5 px-2 [&>svg:last-child]:hidden",onClick:Zs,children:[s.jsx(It,{placeholder:d("chat.decopilot.key"),children:(()=>{const R=b.find(re=>re.id===i),D=R?E[R.providerId]:void 0,q=be(R?.presetId),Y=q?.logo??D?.logo,te=q?.name??D?.name??R?.providerId??"Key";return s.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[Y?s.jsx("img",{src:Y,alt:te,className:"w-4 h-4 rounded shrink-0 dark:bg-white dark:rounded-sm dark:p-px"}):s.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary shrink-0",children:te.slice(0,1).toUpperCase()}),s.jsx("span",{className:"text-xs truncate",children:te})]})})()}),s.jsx(Rt,{className:"size-4 opacity-50 shrink-0 pointer-events-none"})]}),s.jsx(Mt,{children:b.map(R=>{const D=E[R.providerId],q=be(R.presetId),Y=q?.logo??D?.logo,te=q?.name??D?.name??R.providerId;return s.jsx(Et,{value:R.id,children:s.jsxs("div",{className:"flex items-center gap-2",children:[Y?s.jsx("img",{src:Y,alt:te,className:"w-4 h-4 rounded dark:bg-white dark:rounded-sm dark:p-px"}):s.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:te.slice(0,1).toUpperCase()}),s.jsxs("span",{children:[te," — ",R.label]})]})},R.id)})})]}),e[25]=i,e[26]=w,e[27]=b,e[28]=E,e[29]=d,e[30]=L):L=e[30];let F;e[31]!==T||e[32]!==L?(F=s.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:s.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 pr-12 md:pr-4 cursor-text",children:[z,T,L]})}),e[31]=T,e[32]=L,e[33]=F):F=e[33];let K;e[34]!==i?(K=R=>{const{error:D,resetError:q}=R;return s.jsx($s,{error:D,onRetry:q,credentialId:i??void 0})},e[34]=i,e[35]=K):K=e[35];let X;e[36]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(Us,{}),e[36]=X):X=e[36];const V=i??void 0;let Q;e[37]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>j(Js),e[37]=Q):Q=e[37];let J;e[38]!==r||e[39]!==M||e[40]!==m||e[41]!==p||e[42]!==V?(J=s.jsx($.Suspense,{fallback:X,children:s.jsx(Ys,{keyId:V,searchTerm:p,onHover:f,onModelSelect:M,managing:m,onToggleManage:Q,filterModels:r})}),e[38]=r,e[39]=M,e[40]=m,e[41]=p,e[42]=V,e[43]=J):J=e[43];let H;e[44]!==i||e[45]!==K||e[46]!==J?(H=s.jsx(pt,{fallback:K,children:J},i),e[44]=i,e[45]=K,e[46]=J,e[47]=H):H=e[47];let U;e[48]!==m||e[49]!==O||e[50]!==k||e[51]!==d?(U=!m&&s.jsxs("div",{className:"border-t border-border flex",children:[s.jsxs("button",{type:"button",onClick:()=>$.startTransition(()=>j(!0)),className:"flex items-center gap-2 flex-1 px-4 py-2.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer",children:[s.jsx(At,{className:"size-3.5 shrink-0"}),d("chat.decopilot.manageModels")]}),s.jsx("div",{className:"w-px bg-border shrink-0"}),s.jsxs("button",{type:"button",onClick:()=>O({to:"/$org/settings/ai-providers",params:{org:k.slug}}),className:"flex items-center gap-2 flex-1 px-4 py-2.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer",children:[s.jsx(Ft,{className:"size-3.5 shrink-0"}),d("chat.decopilot.manageApiKeys")]})]}),e[48]=m,e[49]=O,e[50]=k,e[51]=d,e[52]=U):U=e[52];let B;e[53]!==F||e[54]!==H||e[55]!==U||e[56]!==C?(B=s.jsxs("div",{className:C,children:[F,H,U]}),e[53]=F,e[54]=H,e[55]=U,e[56]=C,e[57]=B):B=e[57];let W;e[58]!==h||e[59]!==c||e[60]!==l?(W=!h&&s.jsx("div",{className:"hidden md:flex md:flex-col md:w-[320px] md:shrink-0 p-3",children:s.jsx(Ms,{model:c??l??null})}),e[58]=h,e[59]=c,e[60]=l,e[61]=W):W=e[61];let Z;return e[62]!==B||e[63]!==W||e[64]!==g?(Z=s.jsxs("div",{className:g,children:[B,W]}),e[62]=B,e[63]=W,e[64]=g,e[65]=Z):Z=e[65],Z}function Js(n){return!n}function Zs(n){return n.stopPropagation()}function ei(n){return[n.id,n]}function ti(n){const e=G.c(12),{onClose:t}=n,{credentialId:i,setCredentialId:o,selectedModel:l,setModel:a}=Xe();let r;e[0]!==o?(r=c=>{ie("chat_credential_changed",{credential_id:c}),o(c)},e[0]=o,e[1]=r):r=e[1];let h;e[2]!==i||e[3]!==l?.modelId||e[4]!==a?(h=c=>{i&&(ie("chat_model_changed",{from_model_id:l?.modelId??null,to_model_id:c.modelId,to_model_provider:c.providerId??null,credential_id:i}),a({...c,keyId:i}))},e[2]=i,e[3]=l?.modelId,e[4]=a,e[5]=h):h=e[5];let d;return e[6]!==i||e[7]!==t||e[8]!==l||e[9]!==r||e[10]!==h?(d=s.jsx(dt,{onClose:t,credentialId:i,onCredentialChange:r,selectedModel:l,onModelChange:h}),e[6]=i,e[7]=t,e[8]=l,e[9]=r,e[10]=h,e[11]=d):d=e[11],d}function si(n){const e=G.c(2),{onClose:t}=n;let i;return e[0]!==t?(i=s.jsx(ti,{onClose:t}),e[0]=t,e[1]=i):i=e[1],i}function ii(n){const e=G.c(2);let t;return e[0]!==n?(t=s.jsx(dt,{...n}),e[0]=n,e[1]=t):t=e[1],t}function ni(n){const e=G.c(2),{onClose:t}=n;let i;return e[0]!==t?(i=s.jsx(si,{onClose:t}),e[0]=t,e[1]=i):i=e[1],i}function li(n){const e=G.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let i;return e[2]!==t?(i=s.jsx(ii,{...t}),e[2]=t,e[3]=i):i=e[3],i}function Fi(n){const e=G.c(48),{variant:t,className:i,placeholder:o,model:l,isLoading:a,credentialId:r,onCredentialChange:h,onModelChange:d,filterModels:c}=n,f=t===void 0?"borderless":t,p=o===void 0?"Select model":o,u=se(),[m,j]=$.useState(!1),N=d!==void 0,S=wt(),b=f==="borderless"?"ghost":"outline",I=f==="borderless"&&"md:border-none";let E;e[0]!==i||e[1]!==I?(E=oe("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer border-0 group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 shrink justify-start overflow-hidden",I,i),e[0]=i,e[1]=I,e[2]=E):E=e[2];let O;e[3]!==a||e[4]!==l||e[5]!==p||e[6]!==N?(O=N?s.jsx(lt,{model:l??null,placeholder:p,isLoading:a}):s.jsx(ri,{placeholder:p}),e[3]=a,e[4]=l,e[5]=p,e[6]=N,e[7]=O):O=e[7];let k;e[8]!==b||e[9]!==E||e[10]!==O?(k=s.jsx(le,{variant:b,size:"sm",className:E,children:O}),e[8]=b,e[9]=E,e[10]=O,e[11]=k):k=e[11];const x=k;let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Xs,{}),e[12]=w):w=e[12];let _;e[13]!==r||e[14]!==c||e[15]!==l||e[16]!==h||e[17]!==d||e[18]!==N?(_=s.jsx($.Suspense,{fallback:w,children:N?s.jsx(li,{onClose:()=>j(!1),credentialId:r??null,onCredentialChange:h??oi,selectedModel:l??null,onModelChange:d,filterModels:c}):s.jsx(ni,{onClose:()=>j(!1)})}),e[13]=r,e[14]=c,e[15]=l,e[16]=h,e[17]=d,e[18]=N,e[19]=_):_=e[19];const M=_;if(S){let A;e[20]!==x?(A=s.jsx(yt,{asChild:!0,children:x}),e[20]=x,e[21]=A):A=e[21];let P;e[22]!==u?(P=u("chat.selectModel.selectModel"),e[22]=u,e[23]=P):P=e[23];let T;e[24]!==P?(T=s.jsx(jt,{className:"sr-only",children:P}),e[24]=P,e[25]=T):T=e[25];let L;e[26]!==M?(L=s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:M}),e[26]=M,e[27]=L):L=e[27];let F;e[28]!==T||e[29]!==L?(F=s.jsxs(St,{className:"p-0 flex flex-col max-h-[95vh]",children:[T,L]}),e[28]=T,e[29]=L,e[30]=F):F=e[30];let K;return e[31]!==m||e[32]!==A||e[33]!==F?(K=s.jsxs(Nt,{open:m,onOpenChange:j,children:[A,F]}),e[31]=m,e[32]=A,e[33]=F,e[34]=K):K=e[34],K}let v;e[35]!==x?(v=s.jsx(bt,{asChild:!0,children:x}),e[35]=x,e[36]=v):v=e[36];let g;e[37]!==u?(g=u("chat.selectModel.selectModel"),e[37]=u,e[38]=g):g=e[38];let y;e[39]!==g?(y=s.jsx(Ge,{className:"sr-only",children:g}),e[39]=g,e[40]=y):y=e[40];let C;e[41]!==M||e[42]!==y?(C=s.jsxs(Ye,{className:"p-0 gap-0 sm:max-w-fit overflow-hidden h-[100dvh] sm:h-auto max-h-[100dvh] sm:max-h-[85vh] w-full max-w-full sm:max-w-fit rounded-none sm:rounded-xl border-0 sm:border",closeButtonClassName:"top-3.5 right-3.5 z-20",children:[y,M]}),e[41]=M,e[42]=y,e[43]=C):C=e[43];let z;return e[44]!==m||e[45]!==v||e[46]!==C?(z=s.jsxs(qe,{open:m,onOpenChange:j,children:[v,C]}),e[44]=m,e[45]=v,e[46]=C,e[47]=z):z=e[47],z}function oi(){}function ri(n){const e=G.c(4),{placeholder:t}=n,{selectedModel:i,isModelsLoading:o}=Xe();let l;return e[0]!==o||e[1]!==i||e[2]!==t?(l=s.jsx(lt,{model:i,placeholder:t,isLoading:o}),e[0]=o,e[1]=i,e[2]=t,e[3]=l):l=e[3],l}export{gs as C,li as M,js as N,nt as P,Xs as a,zi as b,Fi as c,be as d,Ri as g,Li as i,Ie as m};
@@ -1 +1 @@
1
- import{X as rt,c as H,r as Q,m as ue,j as n,b as te,k as Ie,B as Z,o as ve,e as Ne,K as X,Y as be,Z as re,_ as Ce,$ as ye,n as he,a0 as at,t as Se,u as lt,x as Te,p as me,Q as ct,E as dt,a as mt}from"./index-Csj4ulP-.js";import{W as Ve,g as ut,u as we,S as ft}from"./use-mcp-client-D_w4YfXz.js";import{I as Fe}from"./integration-icon-B_iJXwRI.js";import{c as pe,b as Ge,h as Me,a as Qe,d as He,e as We}from"./dialog-BaQ3_w8_.js";import{c as ke,T as Le,a as Ae}from"./tooltip-CxHFa6IC.js";import{k as Ye,f as Ze,a as pt}from"./agent-icon-ClQ6MFoq.js";import{u as ee,t as gt,m as ht,s as Ke,g as xt,p as bt,F as Ct,b as yt,a as jt,c as vt}from"./companions-core-EBpmeIUx.js";import{i as Xe}from"./CheckCircle-D5saJ3-2.js";import{F as ae,a as je,b as le,c as fe,d as ce,e as de,f as St}from"./form-Cz3JG_Nj.js";import{I as ge}from"./input-5_ihaBYH.js";import{i as _t}from"./Check-7fe09mMg.js";import{a as Je}from"./Copy01-CCrRD_v-.js";import{i as Nt}from"./Settings02-Lx-1u3Bn.js";import{s as Ot}from"./Eye-D2tsgwEB.js";import{u as Tt}from"./use-debounced-value-_FeINZsD.js";import{f as et,a as Et,p as It,i as wt}from"./provision-repo-scoped-github-connection-B2s3ApVy.js";import{c as Ft,e as kt}from"./extract-connection-data-B3R7rEs4.js";import{u as Lt}from"./useQueries-y3ZS11ts.js";import{a as At}from"./authenticate-and-persist-oauth-BpB5Oaek.js";function Rt(i,e){return Lt({...i,queries:i.queries.map(t=>({...t,suspense:!0,throwOnError:rt,enabled:!0,placeholderData:void 0}))},e)}const Dt=/^[a-zA-Z][a-zA-Z\d+.-]*:/,Pt=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//,$t=/^[^\s/:?#]+\.[^\s/:?#]+:\d+(?:[/?#]|$)/,qt=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function _e(i){const e=i.trim();if(!e)return{ok:!1,error:"Enter a website URL."};const t=Dt.test(e),o=Pt.test(e),u=$t.test(e);if(t&&!o&&!u)return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const d=o?e:`https://${e}`;let l;try{l=new URL(d)}catch{return{ok:!1,error:"Enter a valid website URL."}}if(l.protocol!=="http:"&&l.protocol!=="https:")return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const r=l.hostname.split(".");return r.length<2||r.some(f=>!f||!qt.test(f))?{ok:!1,error:"Enter a valid website URL."}:(l.protocol="https:",{ok:!0,value:l.origin})}function so(i,e){if(!i.trim())return!0;const t=_e(i);if(!t.ok||!e)return!1;const o=_e(e);return o.ok&&o.value===t.value}function io(i){if(!i)return null;const e=_e(i);return e.ok?new URL(e.value).hostname:null}function Kt(i){const e=H.c(14),{children:t,className:o,wrapperClassName:u}=i,[d,l]=Q.useState(!0);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=C=>{if(!C)return;const h=()=>{const m=C.scrollHeight-C.scrollTop-C.clientHeight<8;l(m)};h(),C.addEventListener("scroll",h,{passive:!0});const x=new ResizeObserver(h);x.observe(C);for(const m of Array.from(C.children))x.observe(m);return()=>{C.removeEventListener("scroll",h),x.disconnect()}},e[0]=r):r=e[0];const f=r;let p;e[1]!==u?(p=ue("relative",u),e[1]=u,e[2]=p):p=e[2];let s;e[3]!==t||e[4]!==o?(s=n.jsx("div",{ref:f,className:o,children:t}),e[3]=t,e[4]=o,e[5]=s):s=e[5];const a=d?"opacity-0":"opacity-100";let g;e[6]!==a?(g=ue("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",a),e[6]=a,e[7]=g):g=e[7];let c;e[8]!==g?(c=n.jsx("div",{"aria-hidden":!0,className:g}),e[8]=g,e[9]=c):c=e[9];let b;return e[10]!==p||e[11]!==s||e[12]!==c?(b=n.jsxs("div",{className:p,children:[s,c]}),e[10]=p,e[11]=s,e[12]=c,e[13]=b):b=e[13],b}function Ut(i){const e=H.c(25),{icon:t,title:o,headline:u,required:d,attention:l,action:r}=i,f=te(),p=l?"border-warning/50 bg-warning/[0.04]":"border-border";let s;e[0]!==p?(s=ue("relative flex items-center justify-between gap-3 rounded-lg border bg-card p-3.5 sm:gap-4 sm:p-4",p),e[0]=p,e[1]=s):s=e[1];let a;e[2]!==d||e[3]!==f?(a=d&&n.jsx("span",{className:"absolute -top-3 right-4 rounded-full border border-input bg-background px-3 py-1 text-xs font-medium text-foreground",children:f("commerceOnboarding.companionCard.required")}),e[2]=d,e[3]=f,e[4]=a):a=e[4];let g;e[5]!==t||e[6]!==o?(g=n.jsx(Fe,{icon:t,name:o,size:"sm",fit:"contain",className:"size-[30px] shrink-0 p-1"}),e[5]=t,e[6]=o,e[7]=g):g=e[7];let c;e[8]!==o?(c=n.jsx("span",{className:"text-sm font-medium text-foreground",children:o}),e[8]=o,e[9]=c):c=e[9];let b;e[10]!==u?(b=u&&n.jsx("p",{className:"hidden text-sm leading-5 text-muted-foreground sm:block",children:u}),e[10]=u,e[11]=b):b=e[11];let C;e[12]!==c||e[13]!==b?(C=n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[c,b]}),e[12]=c,e[13]=b,e[14]=C):C=e[14];let h;e[15]!==g||e[16]!==C?(h=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3 sm:items-start",children:[g,C]}),e[15]=g,e[16]=C,e[17]=h):h=e[17];let x;e[18]!==r?(x=n.jsx("div",{className:"shrink-0",children:r}),e[18]=r,e[19]=x):x=e[19];let m;return e[20]!==s||e[21]!==a||e[22]!==h||e[23]!==x?(m=n.jsxs("div",{className:s,children:[a,h,x]}),e[20]=s,e[21]=a,e[22]=h,e[23]=x,e[24]=m):m=e[24],m}function tt(i){const e=H.c(12),{connecting:t,disabled:o,title:u,primary:d,onConnect:l}=i,r=te(),f=d?"default":"outline",p=o||t;let s;e[0]!==r||e[1]!==u?(s=r("commerceOnboarding.companionCard.connectAriaLabel",{title:u}),e[0]=r,e[1]=u,e[2]=s):s=e[2];let a;e[3]!==t||e[4]!==r?(a=t?n.jsx(Ie,{size:16,className:"animate-spin"}):r("commerceOnboarding.companionCard.connect"),e[3]=t,e[4]=r,e[5]=a):a=e[5];let g;return e[6]!==l||e[7]!==f||e[8]!==p||e[9]!==s||e[10]!==a?(g=n.jsx(Z,{type:"button",variant:f,size:"sm",disabled:p,onClick:l,"aria-label":s,children:a}),e[6]=l,e[7]=f,e[8]=p,e[9]=s,e[10]=a,e[11]=g):g=e[11],g}function Bt(i){const e=H.c(11),{disabled:t,title:o,onConfigure:u}=i,d=te();let l;e[0]!==d||e[1]!==o?(l=d("commerceOnboarding.companionCard.configureAriaLabel",{title:o}),e[0]=d,e[1]=o,e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Ye,{size:16}),e[3]=r):r=e[3];let f;e[4]!==d?(f=d("commerceOnboarding.companionCard.finishSetup"),e[4]=d,e[5]=f):f=e[5];let p;return e[6]!==t||e[7]!==u||e[8]!==l||e[9]!==f?(p=n.jsxs(Z,{type:"button",variant:"outline",size:"sm",className:"border-warning/60 text-warning hover:bg-warning/10 hover:text-warning",disabled:t,onClick:u,"aria-label":l,children:[r,f]}),e[6]=t,e[7]=u,e[8]=l,e[9]=f,e[10]=p):p=e[10],p}function nt(i){const e=H.c(9),{detail:t,controls:o}=i,u=te();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Xe,{size:16,className:"text-success"}),e[0]=d):d=e[0];let l;e[1]!==t||e[2]!==u?(l=t?n.jsx("span",{className:"max-w-40 truncate text-foreground",children:t}):u("commerceOnboarding.companionCard.connected"),e[1]=t,e[2]=u,e[3]=l):l=e[3];let r;e[4]!==l?(r=n.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[d," ",l]}),e[4]=l,e[5]=r):r=e[5];let f;return e[6]!==o||e[7]!==r?(f=n.jsxs("div",{className:"flex items-center gap-1",children:[r,o]}),e[6]=o,e[7]=r,e[8]=f):f=e[8],f}function ot(i){const e=H.c(4),{ariaLabel:t,onClick:o}=i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Ye,{size:16}),e[0]=u):u=e[0];let d;return e[1]!==t||e[2]!==o?(d=n.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:o,"aria-label":t,children:u}),e[1]=t,e[2]=o,e[3]=d):d=e[3],d}function Ee(i){const e=H.c(38);let t,o,u,d,l;e[0]!==i?({value:l,onChange:o,placeholder:u,className:t,...d}=i,e[0]=i,e[1]=t,e[2]=o,e[3]=u,e[4]=d,e[5]=l):(t=e[1],o=e[2],u=e[3],d=e[4],l=e[5]);const[r,f]=Q.useState(!1),[p,s]=Q.useState(!1);let a;e[6]!==l?(a=async()=>{if(l)try{await navigator.clipboard.writeText(l),s(!0),setTimeout(()=>s(!1),2e3)}catch(N){console.error("Failed to copy text: ",N)}},e[6]=l,e[7]=a):a=e[7];const g=a;let c;e[8]!==r?(c=()=>{f(!r)},e[8]=r,e[9]=c):c=e[9];const b=c,C=r?"text":"password";let h;e[10]!==t?(h=ue("pr-20",t),e[10]=t,e[11]=h):h=e[11];let x;e[12]!==o||e[13]!==u||e[14]!==d||e[15]!==C||e[16]!==h||e[17]!==l?(x=n.jsx(ge,{type:C,value:l,onChange:o,placeholder:u,className:h,...d}),e[12]=o,e[13]=u,e[14]=d,e[15]=C,e[16]=h,e[17]=l,e[18]=x):x=e[18];const m=r?"Hide password":"Show password";let v;e[19]!==r?(v=r?n.jsx(Nt,{size:16}):n.jsx(Ot,{size:16}),e[19]=r,e[20]=v):v=e[20];let y;e[21]!==m||e[22]!==v||e[23]!==b?(y=n.jsx(Z,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:b,title:m,children:v}),e[21]=m,e[22]=v,e[23]=b,e[24]=y):y=e[24];const E=!l,_=p?"Copied!":"Copy token";let S;e[25]!==p?(S=p?n.jsx(_t,{size:16}):n.jsx(Je,{size:16}),e[25]=p,e[26]=S):S=e[26];let j;e[27]!==g||e[28]!==_||e[29]!==S||e[30]!==E?(j=n.jsx(Z,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:g,disabled:E,title:_,children:S}),e[27]=g,e[28]=_,e[29]=S,e[30]=E,e[31]=j):j=e[31];let w;e[32]!==j||e[33]!==y?(w=n.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-1 h-8",children:[y,j]}),e[32]=j,e[33]=y,e[34]=w):w=e[34];let O;return e[35]!==w||e[36]!==x?(O=n.jsxs("div",{className:"relative",children:[x,w]}),e[35]=w,e[36]=x,e[37]=O):O=e[37],O}function Oe(i){const e=H.c(19),{card:t,selfClient:o,org:u,onDone:d,onError:l}=i,r=ve();let f;e[0]!==t||e[1]!==o?(f=async h=>{const{values:x,connectionToken:m}=h,y={configuration_state:{...t.configurationState??{},...x}};m!==void 0&&(y.connection_token=m),await o.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:t.linkedConnectionId||t.candidateConnectionId,data:y}})},e[0]=t,e[1]=o,e[2]=f):f=e[2];let p;e[3]!==d||e[4]!==u||e[5]!==r?(p=async()=>{await r.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(u.id)}),d()},e[3]=d,e[4]=u,e[5]=r,e[6]=p):p=e[6];let s;e[7]!==l?(s=h=>{l?.(h)},e[7]=l,e[8]=s):s=e[8];let a;e[9]!==f||e[10]!==p||e[11]!==s?(a={mutationFn:f,onSuccess:p,onError:s},e[9]=f,e[10]=p,e[11]=s,e[12]=a):a=e[12];const g=Ne(a);let c;e[13]!==g?(c=(h,x)=>g.mutate({values:h,connectionToken:x?.connectionToken}),e[13]=g,e[14]=c):c=e[14];const b=c;let C;return e[15]!==g.error||e[16]!==g.isPending||e[17]!==b?(C={save:b,isPending:g.isPending,error:g.error},e[15]=g.error,e[16]=g.isPending,e[17]=b,e[18]=C):C=e[18],C}const zt=be({accountName:re().min(1,"Informe o nome da conta"),appKey:re().optional(),appToken:re().optional()});function Vt(i){const e=H.c(73),{card:t,selfClient:o,org:u,onDone:d,onIsPendingChange:l}=i,r=te();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=Ce(zt),e[0]=f):f=e[0];const p=t.configurationState?.accountName||"",s=t.configurationState?.appKey||"",a=t.configurationState?.appToken||"";let g;e[1]!==p||e[2]!==s||e[3]!==a?(g={resolver:f,defaultValues:{accountName:p,appKey:s,appToken:a}},e[1]=p,e[2]=s,e[3]=a,e[4]=g):g=e[4];const c=ye(g);let b;e[5]!==t.configurationState?.accountName||e[6]!==t.configurationState?.appKey||e[7]!==t.configurationState?.appToken||e[8]!==c?(b=()=>{c.reset({accountName:t.configurationState?.accountName||"",appKey:t.configurationState?.appKey||"",appToken:t.configurationState?.appToken||""})},e[5]=t.configurationState?.accountName,e[6]=t.configurationState?.appKey,e[7]=t.configurationState?.appToken,e[8]=c,e[9]=b):b=e[9];let C;e[10]!==t.configurationState||e[11]!==c?(C=[t.configurationState,c],e[10]=t.configurationState,e[11]=c,e[12]=C):C=e[12],Q.useEffect(b,C);let h;e[13]!==t||e[14]!==d||e[15]!==u||e[16]!==o?(h={card:t,selfClient:o,org:u,onDone:d},e[13]=t,e[14]=d,e[15]=u,e[16]=o,e[17]=h):h=e[17];const{save:x,isPending:m,error:v}=Oe(h);let y,E;e[18]!==m||e[19]!==l?(E=()=>{l?.(m)},y=[m,l],e[18]=m,e[19]=l,e[20]=y,e[21]=E):(y=e[20],E=e[21]),Q.useEffect(E,y);let _;if(e[22]!==c||e[23]!==x){let k;e[25]!==x?(k=async F=>{x(F)},e[25]=x,e[26]=k):k=e[26],_=c.handleSubmit(k),e[22]=c,e[23]=x,e[24]=_}else _=e[24];const S=_;let j;e[27]!==m||e[28]!==r?(j=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.vtexConfigForm.accountNameLabel")}),n.jsx(ce,{children:n.jsx(ge,{placeholder:r("commerceOnboarding.vtexConfigForm.accountNamePlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[27]=m,e[28]=r,e[29]=j):j=e[29];let w;e[30]!==c.control||e[31]!==j?(w=n.jsx(ae,{control:c.control,name:"accountName",render:j}),e[30]=c.control,e[31]=j,e[32]=w):w=e[32];let O;e[33]!==m||e[34]!==r?(O=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.vtexConfigForm.appKeyLabel")}),n.jsx(ce,{children:n.jsx(Ee,{placeholder:r("commerceOnboarding.vtexConfigForm.appKeyPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[33]=m,e[34]=r,e[35]=O):O=e[35];let N;e[36]!==c.control||e[37]!==O?(N=n.jsx(ae,{control:c.control,name:"appKey",render:O}),e[36]=c.control,e[37]=O,e[38]=N):N=e[38];let I;e[39]!==m||e[40]!==r?(I=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.vtexConfigForm.appTokenLabel")}),n.jsx(ce,{children:n.jsx(Ee,{placeholder:r("commerceOnboarding.vtexConfigForm.appTokenPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[39]=m,e[40]=r,e[41]=I):I=e[41];let T;e[42]!==c.control||e[43]!==I?(T=n.jsx(ae,{control:c.control,name:"appToken",render:I}),e[42]=c.control,e[43]=I,e[44]=T):T=e[44];let L;e[45]!==c||e[46]!==w||e[47]!==N||e[48]!==T?(L=n.jsxs(je,{...c,children:[w,N,T]}),e[45]=c,e[46]=w,e[47]=N,e[48]=T,e[49]=L):L=e[49];let $;e[50]!==v||e[51]!==r?($=v&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v instanceof Error?v.message:r("commerceOnboarding.vtexConfigForm.savingError")}),e[50]=v,e[51]=r,e[52]=$):$=e[52];let A;e[53]!==r?(A=r("commerceOnboarding.vtexConfigForm.cancelButton"),e[53]=r,e[54]=A):A=e[54];let q;e[55]!==m||e[56]!==d||e[57]!==A?(q=n.jsx(Z,{type:"button",variant:"outline",onClick:d,disabled:m,children:A}),e[55]=m,e[56]=d,e[57]=A,e[58]=q):q=e[58];let P;e[59]!==m||e[60]!==r?(P=r(m?"commerceOnboarding.vtexConfigForm.savingButton":"commerceOnboarding.vtexConfigForm.saveButton"),e[59]=m,e[60]=r,e[61]=P):P=e[61];let B;e[62]!==m||e[63]!==P?(B=n.jsx(Z,{type:"submit",disabled:m,children:P}),e[62]=m,e[63]=P,e[64]=B):B=e[64];let K;e[65]!==q||e[66]!==B?(K=n.jsxs(pe,{className:"pt-4",children:[q,B]}),e[65]=q,e[66]=B,e[67]=K):K=e[67];let z;return e[68]!==S||e[69]!==L||e[70]!==$||e[71]!==K?(z=n.jsxs("form",{onSubmit:S,className:"space-y-4",children:[L,$,K]}),e[68]=S,e[69]=L,e[70]=$,e[71]=K,e[72]=z):z=e[72],z}const Gt=(i,e)=>be({storeDomain:re().min(1,e("commerceOnboarding.shopifyConfigForm.storeDomainRequired")),accessToken:re().optional(),apiVersion:re().optional()}).refine(t=>i||!!t.accessToken?.trim(),{path:["accessToken"],message:e("commerceOnboarding.shopifyConfigForm.accessTokenRequired")});function Mt(i){const e=H.c(76),{card:t,selfClient:o,org:u,onDone:d,onIsPendingChange:l}=i,r=te();let f;e[0]!==t.configured||e[1]!==r?(f=Ce(Gt(t.configured,r)),e[0]=t.configured,e[1]=r,e[2]=f):f=e[2];const p=t.configurationState?.storeDomain||"",s=t.configurationState?.apiVersion||"";let a;e[3]!==p||e[4]!==s?(a={storeDomain:p,accessToken:"",apiVersion:s},e[3]=p,e[4]=s,e[5]=a):a=e[5];let g;e[6]!==f||e[7]!==a?(g={resolver:f,defaultValues:a},e[6]=f,e[7]=a,e[8]=g):g=e[8];const c=ye(g);let b;e[9]!==t.configurationState?.apiVersion||e[10]!==t.configurationState?.storeDomain||e[11]!==c?(b=()=>{c.reset({storeDomain:t.configurationState?.storeDomain||"",accessToken:"",apiVersion:t.configurationState?.apiVersion||""})},e[9]=t.configurationState?.apiVersion,e[10]=t.configurationState?.storeDomain,e[11]=c,e[12]=b):b=e[12];let C;e[13]!==t.configurationState||e[14]!==c?(C=[t.configurationState,c],e[13]=t.configurationState,e[14]=c,e[15]=C):C=e[15],Q.useEffect(b,C);let h;e[16]!==t||e[17]!==d||e[18]!==u||e[19]!==o?(h={card:t,selfClient:o,org:u,onDone:d},e[16]=t,e[17]=d,e[18]=u,e[19]=o,e[20]=h):h=e[20];const{save:x,isPending:m,error:v}=Oe(h);let y,E;e[21]!==m||e[22]!==l?(E=()=>{l?.(m)},y=[m,l],e[21]=m,e[22]=l,e[23]=y,e[24]=E):(y=e[23],E=e[24]),Q.useEffect(E,y);let _;if(e[25]!==c||e[26]!==x){let k;e[28]!==x?(k=async F=>{const R=F.apiVersion?.trim(),U=F.accessToken?.trim();x({storeDomain:F.storeDomain.trim(),...R?{apiVersion:R}:{}},U?{connectionToken:U}:void 0)},e[28]=x,e[29]=k):k=e[29],_=c.handleSubmit(k),e[25]=c,e[26]=x,e[27]=_}else _=e[27];const S=_;let j;e[30]!==m||e[31]!==r?(j=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.shopifyConfigForm.storeDomainLabel")}),n.jsx(ce,{children:n.jsx(ge,{placeholder:r("commerceOnboarding.shopifyConfigForm.storeDomainPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[30]=m,e[31]=r,e[32]=j):j=e[32];let w;e[33]!==c.control||e[34]!==j?(w=n.jsx(ae,{control:c.control,name:"storeDomain",render:j}),e[33]=c.control,e[34]=j,e[35]=w):w=e[35];let O;e[36]!==m||e[37]!==r?(O=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.shopifyConfigForm.accessTokenLabel")}),n.jsx(ce,{children:n.jsx(Ee,{placeholder:r("commerceOnboarding.shopifyConfigForm.accessTokenPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[36]=m,e[37]=r,e[38]=O):O=e[38];let N;e[39]!==c.control||e[40]!==O?(N=n.jsx(ae,{control:c.control,name:"accessToken",render:O}),e[39]=c.control,e[40]=O,e[41]=N):N=e[41];let I;e[42]!==m||e[43]!==r?(I=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.shopifyConfigForm.apiVersionLabel")}),n.jsx(ce,{children:n.jsx(ge,{placeholder:r("commerceOnboarding.shopifyConfigForm.apiVersionPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[42]=m,e[43]=r,e[44]=I):I=e[44];let T;e[45]!==c.control||e[46]!==I?(T=n.jsx(ae,{control:c.control,name:"apiVersion",render:I}),e[45]=c.control,e[46]=I,e[47]=T):T=e[47];let L;e[48]!==c||e[49]!==w||e[50]!==N||e[51]!==T?(L=n.jsxs(je,{...c,children:[w,N,T]}),e[48]=c,e[49]=w,e[50]=N,e[51]=T,e[52]=L):L=e[52];let $;e[53]!==v||e[54]!==r?($=v&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v instanceof Error?v.message:r("commerceOnboarding.shopifyConfigForm.savingError")}),e[53]=v,e[54]=r,e[55]=$):$=e[55];let A;e[56]!==r?(A=r("commerceOnboarding.shopifyConfigForm.cancelButton"),e[56]=r,e[57]=A):A=e[57];let q;e[58]!==m||e[59]!==d||e[60]!==A?(q=n.jsx(Z,{type:"button",variant:"outline",onClick:d,disabled:m,children:A}),e[58]=m,e[59]=d,e[60]=A,e[61]=q):q=e[61];let P;e[62]!==m||e[63]!==r?(P=r(m?"commerceOnboarding.shopifyConfigForm.savingButton":"commerceOnboarding.shopifyConfigForm.saveButton"),e[62]=m,e[63]=r,e[64]=P):P=e[64];let B;e[65]!==m||e[66]!==P?(B=n.jsx(Z,{type:"submit",disabled:m,children:P}),e[65]=m,e[66]=P,e[67]=B):B=e[67];let K;e[68]!==q||e[69]!==B?(K=n.jsxs(pe,{className:"pt-4",children:[q,B]}),e[68]=q,e[69]=B,e[70]=K):K=e[70];let z;return e[71]!==S||e[72]!==L||e[73]!==$||e[74]!==K?(z=n.jsxs("form",{onSubmit:S,className:"space-y-4",children:[L,$,K]}),e[71]=S,e[72]=L,e[73]=$,e[74]=K,e[75]=z):z=e[75],z}function Re(i){const e=H.c(31),{options:t,value:o,onChange:u,disabled:d,ariaLabel:l,searchPlaceholder:r,hideSearch:f}=i,p=f===void 0?!1:f,s=te(),[a,g]=Q.useState("");let c,b,C;if(e[0]!==t||e[1]!==a||e[2]!==o){const S=a.trim().toLowerCase();c=S?t.filter(j=>j.label.toLowerCase().includes(S)):t,b=c.map(Qt),C=b.includes(o)?o:b[0]??"",e[0]=t,e[1]=a,e[2]=o,e[3]=c,e[4]=b,e[5]=C}else c=e[3],b=e[4],C=e[5];const h=C;let x;e[6]!==d||e[7]!==b||e[8]!==u?(x=function(j){if(d||!["ArrowDown","ArrowRight","ArrowUp","ArrowLeft","Home","End"].includes(j.key))return;j.preventDefault();const O=j.currentTarget.dataset.value,N=b.indexOf(O),I=b.length;if(I===0)return;let T;j.key==="ArrowDown"||j.key==="ArrowRight"?T=(N+1)%I:j.key==="ArrowUp"||j.key==="ArrowLeft"?T=(N-1+I)%I:j.key==="Home"?T=0:T=I-1;const L=b[T];u(L),j.currentTarget.closest('[role="radiogroup"]')?.querySelector(`[data-value="${CSS.escape(L)}"]`)?.focus()},e[6]=d,e[7]=b,e[8]=u,e[9]=x):x=e[9];const m=x;let v;e[10]!==l||e[11]!==d||e[12]!==p||e[13]!==a||e[14]!==r||e[15]!==s?(v=p?null:n.jsxs("div",{className:"relative",children:[n.jsx(Ze,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),n.jsx(ge,{type:"text",value:a,onChange:S=>g(S.target.value),disabled:d,placeholder:r??s("commerceOnboarding.selectableList.searchPlaceholder"),"aria-label":s("commerceOnboarding.selectableList.searchAriaLabel",{label:l}),className:"h-8 pl-8"})]}),e[10]=l,e[11]=d,e[12]=p,e[13]=a,e[14]=r,e[15]=s,e[16]=v):v=e[16];let y;e[17]!==d||e[18]!==c||e[19]!==m||e[20]!==u||e[21]!==s||e[22]!==h||e[23]!==o?(y=c.length===0?n.jsx("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:s("commerceOnboarding.selectableList.noResults")}):c.map(S=>{const j=S.value===o;return n.jsxs("button",{type:"button",role:"radio","aria-checked":j,disabled:d,"data-value":S.value,tabIndex:S.value===h?0:-1,onClick:()=>u(S.value),onKeyDown:m,className:ue("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:[n.jsx("span",{className:"truncate",children:S.label}),j?n.jsx(Xe,{size:16,className:"shrink-0 text-primary"}):null]},S.value)}),e[17]=d,e[18]=c,e[19]=m,e[20]=u,e[21]=s,e[22]=h,e[23]=o,e[24]=y):y=e[24];let E;e[25]!==l||e[26]!==y?(E=n.jsx("div",{role:"radiogroup","aria-label":l,className:"max-h-[280px] overflow-y-auto",children:y}),e[25]=l,e[26]=y,e[27]=E):E=e[27];let _;return e[28]!==v||e[29]!==E?(_=n.jsxs("div",{className:"space-y-2",children:[v,E]}),e[28]=v,e[29]=E,e[30]=_):_=e[30],_}function Qt(i){return i.value}function De(i){const e=H.c(16),{label:t,iconSize:o,className:u,iconClassName:d,labelClassName:l}=i,r=o===void 0?14:o;let f;e[0]!==u?(f=ue("inline-flex items-center gap-2",u),e[0]=u,e[1]=f):f=e[1];let p;e[2]!==d?(p=ue("shrink-0 animate-spin",d),e[2]=d,e[3]=p):p=e[3];let s;e[4]!==r||e[5]!==p?(s=n.jsx(Ie,{size:r,className:p}),e[4]=r,e[5]=p,e[6]=s):s=e[6];let a;e[7]!==l?(a=ue("text-sm",l),e[7]=l,e[8]=a):a=e[8];let g;e[9]!==t||e[10]!==a?(g=n.jsx("span",{className:a,children:t}),e[9]=t,e[10]=a,e[11]=g):g=e[11];let c;return e[12]!==f||e[13]!==s||e[14]!==g?(c=n.jsxs("span",{className:f,children:[s,g]}),e[12]=f,e[13]=s,e[14]=g,e[15]=c):c=e[15],c}const Ht=be({propertyId:re().min(1,"Selecione uma propriedade")});function Wt(i){const e=H.c(68),{card:t,connectionId:o,companionClient:u,selfClient:d,org:l,onDone:r,onDisconnect:f,onIsPendingChange:p}=i;let s;e[0]!==o||e[1]!==l.id?(s=X.commerceDiscoveryCompanionGaProperties(l.id,o),e[0]=o,e[1]=l.id,e[2]=s):s=e[2];let a;e[3]!==u?(a=async()=>{const R=await u.callTool({name:"get-account-summaries",arguments:{}}),U=ee(R);return gt(U)},e[3]=u,e[4]=a):a=e[4];let g;e[5]!==s||e[6]!==a?(g={queryKey:s,queryFn:a},e[5]=s,e[6]=a,e[7]=g):g=e[7];const c=he(g);let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=Ce(Ht),e[8]=b):b=e[8];const C=t.configurationState?.propertyId||"";let h;e[9]!==C?(h={resolver:b,defaultValues:{propertyId:C}},e[9]=C,e[10]=h):h=e[10];const x=ye(h);let m;e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==d?(m={card:t,selfClient:d,org:l,onDone:r},e[11]=t,e[12]=r,e[13]=l,e[14]=d,e[15]=m):m=e[15];const{save:v,isPending:y,error:E}=Oe(m);let _,S;e[16]!==y||e[17]!==p?(_=()=>{p?.(y)},S=[y,p],e[16]=y,e[17]=p,e[18]=_,e[19]=S):(_=e[18],S=e[19]),Q.useEffect(_,S);let j;if(e[20]!==x||e[21]!==v){let R;e[23]!==v?(R=async U=>{v(U)},e[23]=v,e[24]=R):R=e[24],j=x.handleSubmit(R),e[20]=x,e[21]=v,e[22]=j}else j=e[22];const w=j;if(c.isLoading){let R;return e[25]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:n.jsx(De,{label:"Carregando propriedades..."})}),e[25]=R):R=e[25],R}if(c.isError){let R;return e[26]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-destructive",children:"Não foi possível carregar as propriedades do Google Analytics."})}),e[26]=R):R=e[26],R}let O;e[27]!==c.data?(O=c.data||[],e[27]=c.data,e[28]=O):O=e[28];const N=O;if(N.flatMap(Zt).length===0){let R;e[29]===Symbol.for("react.memo_cache_sentinel")?(R=n.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]=R):R=e[29];let U;e[30]!==f?(U=f?n.jsx("button",{type:"button",onClick:f,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive",children:"Desconectar conta"}):n.jsx("span",{}),e[30]=f,e[31]=U):U=e[31];let G;e[32]!==r?(G=n.jsx(Z,{type:"button",variant:"outline",onClick:r,children:"Fechar"}),e[32]=r,e[33]=G):G=e[33];let W;return e[34]!==U||e[35]!==G?(W=n.jsxs("div",{className:"space-y-4",children:[R,n.jsxs(pe,{className:"flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[U,G]})]}),e[34]=U,e[35]=G,e[36]=W):W=e[36],W}let T;e[37]!==y||e[38]!==N?(T=R=>{const{field:U}=R;return n.jsxs(le,{children:[n.jsx(ce,{children:n.jsx(Re,{options:N.flatMap(Yt),value:U.value,onChange:U.onChange,disabled:y,ariaLabel:"Propriedade do Google Analytics"})}),n.jsx(de,{})]})},e[37]=y,e[38]=N,e[39]=T):T=e[39];let L;e[40]!==x.control||e[41]!==T?(L=n.jsx(ae,{control:x.control,name:"propertyId",render:T}),e[40]=x.control,e[41]=T,e[42]=L):L=e[42];let $;e[43]!==x||e[44]!==L?($=n.jsx(je,{...x,children:L}),e[43]=x,e[44]=L,e[45]=$):$=e[45];let A;e[46]!==E?(A=E&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:E instanceof Error?E.message:"Não foi possível salvar a configuração"}),e[46]=E,e[47]=A):A=e[47];let q;e[48]!==y||e[49]!==f?(q=f?n.jsx("button",{type:"button",onClick:f,disabled:y,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive disabled:opacity-50",children:"Desconectar conta"}):n.jsx("span",{}),e[48]=y,e[49]=f,e[50]=q):q=e[50];let P;e[51]!==y||e[52]!==r?(P=n.jsx(Z,{type:"button",variant:"outline",onClick:r,disabled:y,children:"Cancelar"}),e[51]=y,e[52]=r,e[53]=P):P=e[53];const B=y?"Salvando...":"Salvar";let K;e[54]!==y||e[55]!==B?(K=n.jsx(Z,{type:"submit",disabled:y,children:B}),e[54]=y,e[55]=B,e[56]=K):K=e[56];let z;e[57]!==P||e[58]!==K?(z=n.jsxs("div",{className:"flex gap-2",children:[P,K]}),e[57]=P,e[58]=K,e[59]=z):z=e[59];let k;e[60]!==q||e[61]!==z?(k=n.jsxs(pe,{className:"flex-col gap-2 pt-4 sm:flex-row sm:items-center sm:justify-between",children:[q,z]}),e[60]=q,e[61]=z,e[62]=k):k=e[62];let F;return e[63]!==w||e[64]!==$||e[65]!==A||e[66]!==k?(F=n.jsxs("form",{onSubmit:w,className:"space-y-4",children:[$,A,k]}),e[63]=w,e[64]=$,e[65]=A,e[66]=k,e[67]=F):F=e[67],F}function Yt(i){return i.options}function Zt(i){return i.options}const Xt=i=>be({siteUrl:re().min(1,i("commerceOnboarding.googleSearchConsoleConfigForm.siteRequired"))});function Jt(i){const e=H.c(83),{card:t,connectionId:o,companionClient:u,selfClient:d,org:l,contextSiteUrl:r,onDone:f,onIsPendingChange:p}=i,s=te();let a;e[0]!==o||e[1]!==l.id?(a=X.commerceDiscoveryCompanionGscSites(l.id,o),e[0]=o,e[1]=l.id,e[2]=a):a=e[2];let g;e[3]!==u?(g=async()=>{const D=await u.callTool({name:"list_sites",arguments:{}});return ee(D).sites||[]},e[3]=u,e[4]=g):g=e[4];let c;e[5]!==a||e[6]!==g?(c={queryKey:a,queryFn:g},e[5]=a,e[6]=g,e[7]=c):c=e[7];const b=he(c);let C;e[8]!==s?(C=Ce(Xt(s)),e[8]=s,e[9]=C):C=e[9];const h=t.configurationState?.siteUrl||"";let x;e[10]!==h?(x={siteUrl:h},e[10]=h,e[11]=x):x=e[11];let m;e[12]!==C||e[13]!==x?(m={resolver:C,defaultValues:x},e[12]=C,e[13]=x,e[14]=m):m=e[14];const v=ye(m);let y;e[15]!==t||e[16]!==f||e[17]!==l||e[18]!==d?(y={card:t,selfClient:d,org:l,onDone:f},e[15]=t,e[16]=f,e[17]=l,e[18]=d,e[19]=y):y=e[19];const{save:E,isPending:_,error:S}=Oe(y),j=Q.useRef(!1),w=t.configurationState?.siteUrl;let O,N;e[20]!==_||e[21]!==p?(N=()=>{p?.(_)},O=[_,p],e[20]=_,e[21]=p,e[22]=O,e[23]=N):(O=e[22],N=e[23]),Q.useEffect(N,O);let I,T;e[24]!==r||e[25]!==v||e[26]!==w||e[27]!==b.data||e[28]!==b.isSuccess?(I=()=>{if(!(j.current||!b.isSuccess)){if(j.current=!0,w){v.getValues("siteUrl")!==w&&v.setValue("siteUrl",w);return}if(!v.getValues("siteUrl")){const D=ht(r,b.data??[]);D&&v.setValue("siteUrl",D)}}},T=[b.isSuccess,b.data,w,r,v],e[24]=r,e[25]=v,e[26]=w,e[27]=b.data,e[28]=b.isSuccess,e[29]=I,e[30]=T):(I=e[29],T=e[30]),Q.useEffect(I,T);let L;if(e[31]!==v||e[32]!==E){let D;e[34]!==E?(D=async M=>{E(M)},e[34]=E,e[35]=D):D=e[35],L=v.handleSubmit(D),e[31]=v,e[32]=E,e[33]=L}else L=e[33];const $=L;if(b.isLoading){let D;e[36]!==s?(D=s("commerceOnboarding.googleSearchConsoleConfigForm.loadingSites"),e[36]=s,e[37]=D):D=e[37];let M;return e[38]!==D?(M=n.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:n.jsx(De,{label:D})}),e[38]=D,e[39]=M):M=e[39],M}if(b.isError){let D;e[40]!==s?(D=s("commerceOnboarding.googleSearchConsoleConfigForm.loadSitesError"),e[40]=s,e[41]=D):D=e[41];let M;return e[42]!==D?(M=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-destructive",children:D})}),e[42]=D,e[43]=M):M=e[43],M}let A;e[44]!==b.data?(A=b.data||[],e[44]=b.data,e[45]=A):A=e[45];const q=A;if(q.length===0){let D;e[46]!==s?(D=s("commerceOnboarding.googleSearchConsoleConfigForm.noSitesFound"),e[46]=s,e[47]=D):D=e[47];let M;return e[48]!==D?(M=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:D})}),e[48]=D,e[49]=M):M=e[49],M}let P;e[50]!==_||e[51]!==q||e[52]!==s?(P=D=>{const{field:M}=D;return n.jsxs(le,{children:[n.jsx(ce,{children:n.jsx(Re,{options:q.map(en),value:M.value,onChange:M.onChange,disabled:_,ariaLabel:s("commerceOnboarding.googleSearchConsoleConfigForm.siteAriaLabel")})}),n.jsx(de,{})]})},e[50]=_,e[51]=q,e[52]=s,e[53]=P):P=e[53];let B;e[54]!==v.control||e[55]!==P?(B=n.jsx(ae,{control:v.control,name:"siteUrl",render:P}),e[54]=v.control,e[55]=P,e[56]=B):B=e[56];let K;e[57]!==v||e[58]!==B?(K=n.jsx(je,{...v,children:B}),e[57]=v,e[58]=B,e[59]=K):K=e[59];let z;e[60]!==S||e[61]!==s?(z=S&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:S instanceof Error?S.message:s("commerceOnboarding.googleSearchConsoleConfigForm.savingError")}),e[60]=S,e[61]=s,e[62]=z):z=e[62];let k;e[63]!==s?(k=s("commerceOnboarding.googleSearchConsoleConfigForm.cancelButton"),e[63]=s,e[64]=k):k=e[64];let F;e[65]!==_||e[66]!==f||e[67]!==k?(F=n.jsx(Z,{type:"button",variant:"outline",onClick:f,disabled:_,children:k}),e[65]=_,e[66]=f,e[67]=k,e[68]=F):F=e[68];let R;e[69]!==_||e[70]!==s?(R=s(_?"commerceOnboarding.googleSearchConsoleConfigForm.savingButton":"commerceOnboarding.googleSearchConsoleConfigForm.saveButton"),e[69]=_,e[70]=s,e[71]=R):R=e[71];let U;e[72]!==_||e[73]!==R?(U=n.jsx(Z,{type:"submit",disabled:_,children:R}),e[72]=_,e[73]=R,e[74]=U):U=e[74];let G;e[75]!==F||e[76]!==U?(G=n.jsxs(pe,{className:"pt-4",children:[F,U]}),e[75]=F,e[76]=U,e[77]=G):G=e[77];let W;return e[78]!==$||e[79]!==K||e[80]!==z||e[81]!==G?(W=n.jsxs("form",{onSubmit:$,className:"space-y-4",children:[K,z,G]}),e[78]=$,e[79]=K,e[80]=z,e[81]=G,e[82]=W):W=e[82],W}function en(i){return{value:i.siteUrl,label:i.siteUrl}}function tn(i){const[e,t]=i.split("/");return!e||!t?null:{owner:e,name:t}}function nn(i){const{existingRepo:e,owner:t,name:o}=i;return e?.connectionId&&e.owner.toLowerCase()===t.toLowerCase()&&e.name.toLowerCase()===o.toLowerCase()?{connectionId:e.connectionId,installationId:e.installationId}:null}function on(i){const{existingRepo:e,existingConnections:t,repoConnectionId:o}=i,u=e?.connectionId&&e.connectionId!==o?e.connectionId:void 0,d=[...t.filter(l=>l.connection_id!==o&&l.connection_id!==u),{connection_id:o,selected_tools:[]}];return{staleConnectionId:u,mergedConnections:d}}const sn=be({githubRepo:re().min(1,"commerceOnboarding.githubConfigForm.selectRepository")}),rn=15e3,an=/^[\w.-]+\/[\w.-]+$/;async function ln(i,e,t,o){const{installations:u}=await et(i,t),d=o.trim(),l=await Promise.allSettled(u.map(async s=>{const a=s.type==="User"?"user":"org",g=d?`${a}:${s.login} ${d} in:name`:`${a}:${s.login}`,b=await e.callTool({name:"search_repositories",arguments:{query:g,page:1,perPage:50}},void 0,{signal:AbortSignal.timeout(rn)}),C=b.content?.[0]?.text;if(b.isError)throw new Error(C??"search_repositories failed");if(!C)throw new Error("empty search_repositories response");return JSON.parse(C).items??[]})),r=new Map;let f=0;for(const s of l){if(s.status==="rejected"){f+=1;continue}for(const a of s.value)a.full_name&&!r.has(a.full_name)&&r.set(a.full_name,a)}return{repos:Array.from(r.values()).sort((s,a)=>(a.updated_at??"").localeCompare(s.updated_at??"")).map(s=>s.full_name),failed:f,total:u.length}}function cn({connectionId:i,companionClient:e,selfClient:t,org:o,onDone:u,onIsPendingChange:d}){const l=te(),r=ve(),f=Ve.COMMERCE_DISCOVERY(o.id),[p,s]=Q.useState(""),a=Tt(p,300),g=Q.useRef(!1),c=he({queryKey:X.commerceDiscoveryCompanionGithubSelected(o.id,i),queryFn:async()=>{const N=await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:f}}),I=ee(N).item?.configuration_state??null;return typeof I?.github_repo=="string"?I.github_repo:""}}),b=he({queryKey:X.commerceDiscoveryCompanionGithubRepos(o.id,i,a.trim()),queryFn:()=>ln(N=>t.callTool(N),e,i,a)}),C=ye({resolver:Ce(sn),defaultValues:{githubRepo:""}}),h=Ne({mutationFn:async N=>{const I=await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:f}}),L={...ee(I).item?.configuration_state??null??{},github_repo:N};await t.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:f,data:{configuration_state:L}}});const $=tn(N);if(!$)throw new Error(l("commerceOnboarding.githubConfigForm.invalidRepository",{repo:N}));const{owner:A,name:q}=$,P=ut(o.id),B=ee(await t.callTool({name:"COLLECTION_VIRTUAL_MCP_GET",arguments:{id:P}})).item,K=B?.metadata?.githubRepo,z=B?.connections??[],k=nn({existingRepo:K,owner:A,name:q});let F=k?.connectionId,R=k?.installationId,U;if(!F){const{installations:D}=await et(J=>t.callTool(J),i),M=Et(D,A);if(!M)throw new Error(l("commerceOnboarding.githubConfigForm.noGithubInstallation",{owner:A}));R=M.installationId;const se=ee(await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:i}})).item;if(!se)throw new Error(l("commerceOnboarding.githubConfigForm.githubConnectionNotFound"));const{childConnectionId:ne,reused:oe}=await It({orgSlug:o.slug,sourceConnection:se,installationId:R,owner:A,repo:q,githubCallTool:J=>e.callTool(J),selfCallTool:J=>t.callTool(J)});F=ne,U=oe?void 0:ne}const{staleConnectionId:G,mergedConnections:W}=on({existingRepo:K,existingConnections:z,repoConnectionId:F});try{if(await t.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:P,data:{connections:W,metadata:{githubRepo:{owner:A,name:q,url:`https://github.com/${N}`,installationId:R,connectionId:F}}}}}),G){const D=ee(await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:G}})).item;D&&!wt(D)&&await t.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:G,force:!0}}).catch(()=>{})}}catch(D){throw U&&await t.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:U,force:!0}}).catch(()=>{}),D}},onSuccess:async()=>{await r.invalidateQueries({queryKey:X.commerceDiscoveryConnection(o.id,f)}),await r.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(o.id)}),at(r,o.id),u()}}),x=h.isPending;Q.useEffect(()=>{d?.(x)},[x,d]);const m=c.data??"";Q.useEffect(()=>{!c.isSuccess||g.current||(g.current=!0,c.data&&C.setValue("githubRepo",c.data))},[c.isSuccess,c.data,C]);const v=C.handleSubmit(async N=>{h.mutate(N.githubRepo)}),y=b.data?.repos??[],E=b.data?.failed??0,_=b.data?.total??0,S=a.trim(),j=[...y];S&&an.test(S)&&!j.includes(S)&&j.unshift(S),m&&!j.includes(m)&&j.push(m);const w=_>0&&E===_,O=b.isError||w?l("commerceOnboarding.githubConfigForm.searchFailedTotal"):E>0?l("commerceOnboarding.githubConfigForm.searchFailedPartial"):null;return n.jsxs("form",{onSubmit:v,className:"space-y-4",children:[n.jsxs("div",{className:"relative",children:[n.jsx(Ze,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),n.jsx(ge,{type:"text",value:p,onChange:N=>s(N.target.value),disabled:x,placeholder:l("commerceOnboarding.githubConfigForm.searchRepositoryPlaceholder"),"aria-label":l("commerceOnboarding.githubConfigForm.searchRepositoryLabel"),className:"h-8 pl-8"})]}),b.isLoading?n.jsx("div",{className:"flex min-h-[160px] items-center justify-center",children:n.jsx(De,{label:l("commerceOnboarding.githubConfigForm.loadingRepositories")})}):n.jsxs(n.Fragment,{children:[O&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:O}),j.length===0?!O&&n.jsx("p",{className:"text-sm text-muted-foreground",children:l("commerceOnboarding.githubConfigForm.noRepositoriesFound")}):n.jsx(je,{...C,children:n.jsx(ae,{control:C.control,name:"githubRepo",render:({field:N})=>n.jsxs(le,{children:[n.jsx(ce,{children:n.jsx(Re,{options:j.map(I=>({value:I,label:I})),value:N.value,onChange:N.onChange,disabled:x,ariaLabel:"Repositório",hideSearch:!0})}),n.jsx(de,{})]})})})]}),h.error&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:h.error instanceof Error?h.error.message:l("commerceOnboarding.githubConfigForm.failedToSave")}),n.jsxs(pe,{className:"pt-4",children:[n.jsx(Z,{type:"button",variant:"outline",onClick:u,disabled:x,children:l("commerceOnboarding.githubConfigForm.cancel")}),n.jsx(Z,{type:"submit",disabled:x,children:l(x?"commerceOnboarding.githubConfigForm.saving":"commerceOnboarding.githubConfigForm.save")})]})]})}const dn={vtex:Vt,shopify:Mt,"google-analytics":Wt,"google-search-console":Jt,github:cn},xe="deco-reader@decocms.iam.gserviceaccount.com",st={"google-analytics":"ga4","google-search-console":"gsc"},it={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 mn(i,e){const t=it[i].label;switch(e){case"no-access":return{title:`Ainda não conseguimos acessar este recurso no ${t}.`,steps:i==="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:i==="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 un(i){const e=H.c(95),{provider:t,siteUrl:o,selfClient:u,org:d,initialResourceId:l,onDone:r,onIsPendingChange:f,onOAuthInstead:p}=i,s=te(),a=it[t],g=ve(),[c,b]=Q.useState(null);let C,h;if(e[0]!==a.resourceLabel||e[1]!==s){const Y=be({resourceId:re().trim().min(1,s("commerceOnboarding.saBindingForm.resourceIdRequired",{resourceLabel:a.resourceLabel.toLowerCase()}))});h=ye,C=Ce(Y),e[0]=a.resourceLabel,e[1]=s,e[2]=C,e[3]=h}else C=e[2],h=e[3];const x=l??"";let m;e[4]!==x?(m={resourceId:x},e[4]=x,e[5]=m):m=e[5];let v;e[6]!==C||e[7]!==m?(v={resolver:C,defaultValues:m},e[6]=C,e[7]=m,e[8]=v):v=e[8];const y=h(v);let E;e[9]!==t||e[10]!==u||e[11]!==o||e[12]!==s?(E=async Y=>{if(!o)throw new Error(s("commerceOnboarding.saBindingForm.storeUrlUnavailable"));const ie=await u.callTool({name:"COMMERCE_DISCOVERY_BIND",arguments:{siteUrl:o,provider:t,resourceId:Y.resourceId}});return ee(ie)},e[9]=t,e[10]=u,e[11]=o,e[12]=s,e[13]=E):E=e[13];let _,S;e[14]!==f?(_=()=>f?.(!0),S=()=>f?.(!1),e[14]=f,e[15]=_,e[16]=S):(_=e[15],S=e[16]);let j;e[17]!==a.label||e[18]!==r||e[19]!==d||e[20]!==t||e[21]!==g||e[22]!==o||e[23]!==s?(j=async Y=>{if(Y.ok){b(null),Se.success(s("commerceOnboarding.saBindingForm.connectedSuccess",{label:a.label})),o&&await g.invalidateQueries({queryKey:X.commerceDiscoveryConnectionStatus(d.id,o)}),r();return}b({...mn(t,Y.reason??"unknown"),detail:Y.detail})},e[17]=a.label,e[18]=r,e[19]=d,e[20]=t,e[21]=g,e[22]=o,e[23]=s,e[24]=j):j=e[24];let w;e[25]!==E||e[26]!==_||e[27]!==S||e[28]!==j?(w={mutationFn:E,onMutate:_,onSettled:S,onSuccess:j},e[25]=E,e[26]=_,e[27]=S,e[28]=j,e[29]=w):w=e[29];const O=Ne(w);let N;if(e[30]!==y||e[31]!==O){let Y;e[33]!==O?(Y=ie=>O.mutate(ie),e[33]=O,e[34]=Y):Y=e[34],N=y.handleSubmit(Y),e[30]=y,e[31]=O,e[32]=N}else N=e[32];const I=N,T=O.isPending;let L;e[35]!==s?(L=()=>{navigator.clipboard?.writeText(xe),Se.success(s("commerceOnboarding.saBindingForm.emailCopied"))},e[35]=s,e[36]=L):L=e[36];const $=L;let A;e[37]!==a.connectSteps?(A=a.connectSteps.map(pn),e[37]=a.connectSteps,e[38]=A):A=e[38];let q;e[39]!==A?(q=n.jsx("ol",{className:"space-y-2 text-sm text-muted-foreground",children:A}),e[39]=A,e[40]=q):q=e[40];let P;e[41]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx("code",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:xe}),e[41]=P):P=e[41];let B;e[42]!==s?(B=s("commerceOnboarding.saBindingForm.copyEmailLabel"),e[42]=s,e[43]=B):B=e[43];let K;e[44]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Je,{size:16}),e[44]=K):K=e[44];let z;e[45]!==$||e[46]!==B?(z=n.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted/40 p-2",children:[P,n.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",onClick:$,"aria-label":B,children:K})]}),e[45]=$,e[46]=B,e[47]=z):z=e[47];let k;e[48]!==a.resourceHint||e[49]!==a.resourceLabel||e[50]!==a.resourcePlaceholder||e[51]!==T?(k=Y=>{const{field:ie}=Y;return n.jsxs(le,{children:[n.jsx(fe,{children:a.resourceLabel}),n.jsx(ce,{children:n.jsx(ge,{...ie,placeholder:a.resourcePlaceholder,disabled:T,autoComplete:"off"})}),n.jsx(St,{children:a.resourceHint}),n.jsx(de,{})]})},e[48]=a.resourceHint,e[49]=a.resourceLabel,e[50]=a.resourcePlaceholder,e[51]=T,e[52]=k):k=e[52];let F;e[53]!==y.control||e[54]!==k?(F=n.jsx(ae,{control:y.control,name:"resourceId",render:k}),e[53]=y.control,e[54]=k,e[55]=F):F=e[55];let R;e[56]!==y||e[57]!==F?(R=n.jsx(je,{...y,children:F}),e[56]=y,e[57]=F,e[58]=R):R=e[58];let U;e[59]!==c?(U=c&&n.jsxs("div",{role:"alert",className:"space-y-2 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:c.title}),n.jsx("ol",{className:"space-y-1 text-sm text-muted-foreground",children:c.steps.map(fn)})]}),e[59]=c,e[60]=U):U=e[60];let G;e[61]!==O.error||e[62]!==O.isError||e[63]!==s?(G=O.isError&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:O.error instanceof Error?O.error.message:s("commerceOnboarding.saBindingForm.bindError")}),e[61]=O.error,e[62]=O.isError,e[63]=s,e[64]=G):G=e[64];let W;e[65]!==T||e[66]!==p||e[67]!==s?(W=p?n.jsx("button",{type:"button",onClick:p,disabled:T,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:opacity-50",children:s("commerceOnboarding.saBindingForm.googleLoginAlternative")}):n.jsx("span",{}),e[65]=T,e[66]=p,e[67]=s,e[68]=W):W=e[68];let D;e[69]!==s?(D=s("commerceOnboarding.saBindingForm.cancel"),e[69]=s,e[70]=D):D=e[70];let M;e[71]!==T||e[72]!==r||e[73]!==D?(M=n.jsx(Z,{type:"button",variant:"outline",onClick:r,disabled:T,children:D}),e[71]=T,e[72]=r,e[73]=D,e[74]=M):M=e[74];let se;e[75]!==T||e[76]!==s?(se=s(T?"commerceOnboarding.saBindingForm.verifying":"commerceOnboarding.saBindingForm.bind"),e[75]=T,e[76]=s,e[77]=se):se=e[77];let ne;e[78]!==T||e[79]!==se?(ne=n.jsx(Z,{type:"submit",disabled:T,children:se}),e[78]=T,e[79]=se,e[80]=ne):ne=e[80];let oe;e[81]!==M||e[82]!==ne?(oe=n.jsxs("div",{className:"flex gap-2",children:[M,ne]}),e[81]=M,e[82]=ne,e[83]=oe):oe=e[83];let J;e[84]!==W||e[85]!==oe?(J=n.jsxs(pe,{className:"flex-col gap-2 pt-2 sm:flex-row sm:items-center sm:justify-between",children:[W,oe]}),e[84]=W,e[85]=oe,e[86]=J):J=e[86];let V;return e[87]!==I||e[88]!==q||e[89]!==z||e[90]!==R||e[91]!==U||e[92]!==G||e[93]!==J?(V=n.jsxs("form",{onSubmit:I,className:"space-y-4",children:[q,z,R,U,G,J]}),e[87]=I,e[88]=q,e[89]=z,e[90]=R,e[91]=U,e[92]=G,e[93]=J,e[94]=V):V=e[94],V}function fn(i){return n.jsxs("li",{className:"flex gap-2",children:[n.jsx("span",{"aria-hidden":!0,children:"•"}),n.jsx("span",{children:i})]},i)}function pn(i,e){return n.jsxs("li",{className:"flex gap-2",children:[n.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}),n.jsx("span",{children:i})]},i)}function gn(){const i=H.c(2);let e;i[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-9 shrink-0 animate-pulse rounded-lg bg-muted/60"}),i[0]=e):e=i[0];let t;return i[1]===Symbol.for("react.memo_cache_sentinel")?(t=n.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border bg-card p-3 sm:h-full sm:flex-col sm:items-stretch sm:p-4",children:[e,n.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[n.jsx("div",{className:"h-4 w-24 animate-pulse rounded bg-muted/60"}),n.jsx("div",{className:"hidden h-3 w-full animate-pulse rounded bg-muted/60 sm:block"})]}),n.jsx("div",{className:"h-8 w-20 shrink-0 animate-pulse rounded-lg bg-muted/60 sm:mt-auto sm:w-full"})]}),i[1]=t):t=i[1],t}function Ue(i){const e=H.c(17),{title:t,disconnecting:o,disabled:u,onDisconnect:d}=i,l=te(),r=u||o;let f;e[0]!==l||e[1]!==t?(f=l("commerceOnboarding.companionCard.disconnectAriaLabel",{title:t}),e[0]=l,e[1]=t,e[2]=f):f=e[2];let p;e[3]!==o?(p=o?n.jsx(Ie,{size:16,className:"animate-spin"}):n.jsx(pt,{size:16}),e[3]=o,e[4]=p):p=e[4];let s;e[5]!==d||e[6]!==r||e[7]!==f||e[8]!==p?(s=n.jsx(Le,{asChild:!0,children:n.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:r,onClick:d,"aria-label":f,children:p})}),e[5]=d,e[6]=r,e[7]=f,e[8]=p,e[9]=s):s=e[9];let a;e[10]!==l?(a=l("commerceOnboarding.companionCard.disconnect"),e[10]=l,e[11]=a):a=e[11];let g;e[12]!==a?(g=n.jsx(Ae,{children:a}),e[12]=a,e[13]=g):g=e[13];let c;return e[14]!==s||e[15]!==g?(c=n.jsxs(ke,{children:[s,g]}),e[14]=s,e[15]=g,e[16]=c):c=e[16],c}function hn(i){const e=H.c(23),{card:t,connecting:o,disconnecting:u,disabled:d,onConnect:l,onDisconnect:r,org:f,selfClient:p,siteUrl:s,autoOpenConfigFieldKey:a,onAutoOpenConfigHandled:g}=i,c=t.linkedConnectionId,b=st[t.bindingType],C=!!b&&t.boundVia!=="oauth",h=t.satisfied&&!t.configured;let x;e[0]!==a||e[1]!==t||e[2]!==o||e[3]!==d||e[4]!==u||e[5]!==c||e[6]!==h||e[7]!==g||e[8]!==l||e[9]!==r||e[10]!==f||e[11]!==b||e[12]!==p||e[13]!==s||e[14]!==C?(x=C&&b?n.jsx(xn,{card:t,provider:b,org:f,selfClient:p,siteUrl:s,onOAuthInstead:l,disabled:d,connecting:o,primary:t.required}):t.satisfied&&c?h?n.jsxs("div",{className:"flex items-center justify-end gap-1 sm:justify-start",children:[n.jsx(Q.Suspense,{fallback:n.jsx(Be,{}),children:n.jsx(ze,{card:t,org:f,selfClient:p,connectionId:c,contextSiteUrl:s,variant:"configure",disabled:d,autoOpen:Ke({autoOpenFieldKey:a,card:t}),onAutoOpenHandled:g})}),n.jsx(Ue,{title:t.title,disconnecting:u,disabled:d,onDisconnect:r})]}):n.jsx(nt,{detail:t.connectedDetail,controls:n.jsxs(n.Fragment,{children:[n.jsx(Q.Suspense,{fallback:n.jsx(Be,{}),children:n.jsx(ze,{card:t,org:f,selfClient:p,connectionId:c,contextSiteUrl:s,variant:"gear",disabled:d,autoOpen:Ke({autoOpenFieldKey:a,card:t}),onAutoOpenHandled:g})}),n.jsx(Ue,{title:t.title,disconnecting:u,disabled:d,onDisconnect:r})]})}):n.jsx(tt,{connecting:o,disabled:d,title:t.title,primary:t.required,onConnect:l}),e[0]=a,e[1]=t,e[2]=o,e[3]=d,e[4]=u,e[5]=c,e[6]=h,e[7]=g,e[8]=l,e[9]=r,e[10]=f,e[11]=b,e[12]=p,e[13]=s,e[14]=C,e[15]=x):x=e[15];const m=x,v=t.required&&!t.satisfied;let y;return e[16]!==m||e[17]!==t.headline||e[18]!==t.icon||e[19]!==t.title||e[20]!==h||e[21]!==v?(y=n.jsx(Ut,{icon:t.icon,title:t.title,headline:t.headline,required:v,attention:h,action:m}),e[16]=m,e[17]=t.headline,e[18]=t.icon,e[19]=t.title,e[20]=h,e[21]=v,e[22]=y):y=e[22],y}function xn(i){const e=H.c(46),{card:t,provider:o,org:u,selfClient:d,siteUrl:l,onOAuthInstead:r,disabled:f,connecting:p,primary:s}=i,a=te(),[g,c]=Q.useState(!1),[b,C]=Q.useState(!1);let h;e[0]!==b?(h=A=>{!A&&b||c(A)},e[0]=b,e[1]=h):h=e[1];const x=h;let m;e[2]!==t.connectedDetail||e[3]!==t.satisfied||e[4]!==t.title||e[5]!==p||e[6]!==f||e[7]!==s||e[8]!==a?(m=t.satisfied?n.jsx(nt,{detail:t.connectedDetail,controls:n.jsxs(ke,{children:[n.jsx(Le,{asChild:!0,children:n.jsx(ot,{ariaLabel:a("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),onClick:()=>c(!0)})}),n.jsx(Ae,{children:a("commerceOnboarding.companionCard.editConfiguration")})]})}):n.jsx(tt,{connecting:p,disabled:f,title:t.title,primary:s,onConnect:()=>c(!0)}),e[2]=t.connectedDetail,e[3]=t.satisfied,e[4]=t.title,e[5]=p,e[6]=f,e[7]=s,e[8]=a,e[9]=m):m=e[9];let v;e[10]!==t.icon||e[11]!==t.title?(v=n.jsx(Fe,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[10]=t.icon,e[11]=t.title,e[12]=v):v=e[12];let y;e[13]!==t.title?(y=n.jsx(Ge,{children:t.title}),e[13]=t.title,e[14]=y):y=e[14];let E;e[15]!==a?(E=a("commerceOnboarding.companionCard.grantAccessDescription"),e[15]=a,e[16]=E):E=e[16];let _;e[17]!==E?(_=n.jsx(Me,{children:E}),e[17]=E,e[18]=_):_=e[18];let S;e[19]!==y||e[20]!==_?(S=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[y,_]}),e[19]=y,e[20]=_,e[21]=S):S=e[21];let j;e[22]!==v||e[23]!==S?(j=n.jsxs(Qe,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[v,S]}),e[22]=v,e[23]=S,e[24]=j):j=e[24];const w=t.boundResource??void 0;let O;e[25]===Symbol.for("react.memo_cache_sentinel")?(O=()=>c(!1),e[25]=O):O=e[25];let N;e[26]!==t.satisfied||e[27]!==r?(N=t.satisfied?void 0:()=>{c(!1),r()},e[26]=t.satisfied,e[27]=r,e[28]=N):N=e[28];let I;e[29]!==u||e[30]!==o||e[31]!==d||e[32]!==l||e[33]!==N||e[34]!==w?(I=n.jsx(un,{provider:o,siteUrl:l,selfClient:d,org:u,initialResourceId:w,onDone:O,onIsPendingChange:C,onOAuthInstead:N}),e[29]=u,e[30]=o,e[31]=d,e[32]=l,e[33]=N,e[34]=w,e[35]=I):I=e[35];let T;e[36]!==I||e[37]!==j?(T=n.jsxs(He,{className:"sm:max-w-lg",children:[j,I]}),e[36]=I,e[37]=j,e[38]=T):T=e[38];let L;e[39]!==x||e[40]!==g||e[41]!==T?(L=n.jsx(We,{open:g,onOpenChange:x,children:T}),e[39]=x,e[40]=g,e[41]=T,e[42]=L):L=e[42];let $;return e[43]!==L||e[44]!==m?($=n.jsxs(n.Fragment,{children:[m,L]}),e[43]=L,e[44]=m,e[45]=$):$=e[45],$}function Be(){const i=H.c(1);let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-8 shrink-0 animate-pulse rounded-lg bg-muted/60"}),i[0]=e):e=i[0],e}function ze(i){const e=H.c(71),{card:t,org:o,selfClient:u,connectionId:d,contextSiteUrl:l,variant:r,disabled:f,autoOpen:p,onAutoOpenHandled:s}=i,a=te();let g;e[0]!==d||e[1]!==o.id||e[2]!==o.slug?(g={connectionId:d,orgId:o.id,orgSlug:o.slug},e[0]=d,e[1]=o.id,e[2]=o.slug,e[3]=g):g=e[3];const c=we(g),[b,C]=Q.useState(p),[h,x]=Q.useState(!1),m=ve(),v=dn[t.bindingType];let y;e[4]!==t.configurationState?(y=xt(t.configurationState),e[4]=t.configurationState,e[5]=y):y=e[5];const E=y;let _;e[6]!==p||e[7]!==s?(_=()=>{C(!1),p&&s()},e[6]=p,e[7]=s,e[8]=_):_=e[8];const S=_;let j;e[9]!==S||e[10]!==h?(j=D=>{if(!(!D&&h)){if(!D){S();return}C(!0)}},e[9]=S,e[10]=h,e[11]=j):j=e[11];const w=j;let O;e[12]!==d||e[13]!==u?(O=async()=>{await u.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:d,force:!0}})},e[12]=d,e[13]=u,e[14]=O):O=e[14];let N;e[15]!==t.title||e[16]!==S||e[17]!==o.id||e[18]!==m||e[19]!==a?(N=async()=>{await m.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(o.id)}),Se.success(a("commerceOnboarding.companionCard.disconnectedSuccess",{title:t.title})),S()},e[15]=t.title,e[16]=S,e[17]=o.id,e[18]=m,e[19]=a,e[20]=N):N=e[20];let I;e[21]!==a?(I=()=>{Se.error(a("commerceOnboarding.companionCard.disconnectError"))},e[21]=a,e[22]=I):I=e[22];let T;e[23]!==O||e[24]!==N||e[25]!==I?(T={mutationFn:O,onSuccess:N,onError:I},e[23]=O,e[24]=N,e[25]=I,e[26]=T):T=e[26];const L=Ne(T);if(!v)return null;let $;e[27]!==t.title||e[28]!==f||e[29]!==E||e[30]!==a||e[31]!==r?($=r==="configure"?n.jsx(Bt,{disabled:f,title:t.title,onConfigure:()=>C(!0)}):n.jsxs(ke,{children:[n.jsx(Le,{asChild:!0,children:n.jsx(ot,{ariaLabel:a("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),onClick:()=>C(!0)})}),n.jsx(Ae,{children:E.length>0?a("commerceOnboarding.companionCard.editConfiguration"):a("commerceOnboarding.companionCard.configure")})]}),e[27]=t.title,e[28]=f,e[29]=E,e[30]=a,e[31]=r,e[32]=$):$=e[32];const A=$;let q;e[33]!==t.icon||e[34]!==t.title?(q=n.jsx(Fe,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[33]=t.icon,e[34]=t.title,e[35]=q):q=e[35];let P;e[36]!==t.title?(P=n.jsx(Ge,{children:t.title}),e[36]=t.title,e[37]=P):P=e[37];let B;e[38]!==t.title||e[39]!==a?(B=a("commerceOnboarding.companionCard.configureDescription",{title:t.title}),e[38]=t.title,e[39]=a,e[40]=B):B=e[40];let K;e[41]!==B?(K=n.jsx(Me,{children:B}),e[41]=B,e[42]=K):K=e[42];let z;e[43]!==P||e[44]!==K?(z=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[P,K]}),e[43]=P,e[44]=K,e[45]=z):z=e[45];let k;e[46]!==q||e[47]!==z?(k=n.jsxs(Qe,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[q,z]}),e[46]=q,e[47]=z,e[48]=k):k=e[48];let F;e[49]!==L?(F=()=>L.mutate(),e[49]=L,e[50]=F):F=e[50];let R;e[51]!==v||e[52]!==t||e[53]!==S||e[54]!==c||e[55]!==d||e[56]!==l||e[57]!==o||e[58]!==u||e[59]!==F?(R=n.jsx(v,{card:t,connectionId:d,companionClient:c,selfClient:u,org:o,contextSiteUrl:l,onDone:S,onDisconnect:F,onIsPendingChange:x}),e[51]=v,e[52]=t,e[53]=S,e[54]=c,e[55]=d,e[56]=l,e[57]=o,e[58]=u,e[59]=F,e[60]=R):R=e[60];let U;e[61]!==k||e[62]!==R?(U=n.jsxs(He,{className:"sm:max-w-lg",children:[k,R]}),e[61]=k,e[62]=R,e[63]=U):U=e[63];let G;e[64]!==b||e[65]!==w||e[66]!==U?(G=n.jsx(We,{open:b,onOpenChange:w,children:U}),e[64]=b,e[65]=w,e[66]=U,e[67]=G):G=e[67];let W;return e[68]!==G||e[69]!==A?(W=n.jsxs(n.Fragment,{children:[A,G]}),e[68]=G,e[69]=A,e[70]=W):W=e[70],W}const Pe={vtex:{registryAppId:"deco/vtex",area:"Catálogo",headline:"Rupturas e PDPs que travam suas vendas."},shopify:{registryAppId:"deco/shopify",area:"Catálogo",headline:"Pedidos, estoque e catálogo direto da sua Shopify."},"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 bn(i){const e=H.c(43),{selfClient:t,org:o,cdConnectionId:u,siteUrl:d}=i;let l;e[0]!==u||e[1]!==o.id||e[2]!==o.slug?(l={connectionId:u,orgId:o.id,orgSlug:o.slug},e[0]=u,e[1]=o.id,e[2]=o.slug,e[3]=l):l=e[3];const r=we(l);let f;e[4]!==u||e[5]!==o.id?(f=X.commerceDiscoveryCompanionSchema(o.id,u),e[4]=u,e[5]=o.id,e[6]=f):f=e[6];let p;e[7]!==r?(p=async()=>{const V=await r.callTool({name:"MCP_CONFIGURATION",arguments:{}});return ee(V)},e[7]=r,e[8]=p):p=e[8];let s;e[9]!==f||e[10]!==p?(s={queryKey:f,queryFn:p,retry:!1},e[9]=f,e[10]=p,e[11]=s):s=e[11];const a=he(s),g=a.data?.stateSchema?bt(a.data.stateSchema):null;let c;e[12]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},e[12]=c):c=e[12];const{shopify:b}=lt(c);let C;e[13]!==b?(C=V=>V.bindingType!=="shopify"||b!=null,e[13]=b,e[14]=C):C=e[14];const h=(g&&g.length>0?g:Ct).filter(C),x=h.map(En),m=h.map(Tn).filter(On),v=h.filter(Nn).map(_n),y=[...m,...v].sort().join(",");let E;e[15]!==u||e[16]!==o.id?(E=X.commerceDiscoveryConnection(o.id,u),e[15]=u,e[16]=o.id,e[17]=E):E=e[17];let _;e[18]!==u||e[19]!==t?(_=async()=>{const V=await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:u}});return ee(V)},e[18]=u,e[19]=t,e[20]=_):_=e[20];let S;e[21]!==E||e[22]!==_?(S={queryKey:E,queryFn:_},e[21]=E,e[22]=_,e[23]=S):S=e[23];const w=Te(S).data?.item?.configuration_state??null;let O;e[24]!==w?(O=V=>w?.[V.fieldKey]?.value,e[24]=w,e[25]=O):O=e[25];const N=h.map(O).filter(Sn),I=[...x.map(vn),...m.map(jn),...N.map(yn)].sort().join(","),L=Te({queryKey:X.commerceDiscoveryCompanionConnections(o.id,I),queryFn:async()=>{if(h.length===0)return{items:[]};const V=[{field:["app_name"],operator:"in",value:x},{field:["app_id"],operator:"in",value:m}];N.length>0&&V.push({field:["id"],operator:"in",value:N});const Y=await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{operator:"or",conditions:V},limit:1e3}});return ee(Y)}}).data?.items??[],$=new Set(N),A=L.filter(V=>$.has(V.id)),q=A.filter(Cn);let P;e[26]!==o.id||e[27]!==o.slug?(P=V=>({queryKey:X.commerceDiscoveryCompanionOAuthStatus(o.id,V.id),queryFn:async()=>{try{const Y=await fetch(`/api/${encodeURIComponent(o.slug)}/connections/${encodeURIComponent(V.id)}/oauth-token/status`,{credentials:"include"});return Y.ok?{hasToken:(await Y.json()).hasToken===!0}:{hasToken:!1}}catch{return{hasToken:!1}}},retry:!1}),e[26]=o.id,e[27]=o.slug,e[28]=P):P=e[28];const B=Rt({queries:q.map(P)});let K;e[29]!==B?(K=(V,Y)=>[V.id,B[Y]?.data?.hasToken===!0],e[29]=B,e[30]=K):K=e[30];const z=new Map(q.map(K)),k={};for(const V of A)k[V.id]=!V.oauth_config||!!V.connection_token||z.get(V.id)===!0;const F=Te({queryKey:X.commerceDiscoveryCompanionRegistry(o.id,y),queryFn:async()=>{if(h.length===0)return{items:[]};const V=yt(m,v),Y=await Ft(Ve.REGISTRY(o.id),o.id,o.slug,"COLLECTION_REGISTRY_APP_LIST",{...V?{where:V}:{},limit:1e3});return ee(Y)}}),R={},U={};for(const V of F.data?.items??[])R[V.id]=V,V.server?.name&&(U[V.server.name]=V);let G;e[31]!==o.id||e[32]!==d?(G=X.commerceDiscoveryConnectionStatus(o.id,d??""),e[31]=o.id,e[32]=d,e[33]=G):G=e[33];const W=!!d;let D;e[34]!==t||e[35]!==d?(D=async()=>{const V=await t.callTool({name:"COMMERCE_DISCOVERY_CONNECTION_STATUS",arguments:{siteUrl:d}});return ee(V)},e[34]=t,e[35]=d,e[36]=D):D=e[36];let M;e[37]!==G||e[38]!==W||e[39]!==D?(M={queryKey:G,enabled:W,queryFn:D},e[37]=G,e[38]=W,e[39]=D,e[40]=M):M=e[40];const se=he(M),ne={};for(const[V,Y]of Object.entries(st)){const ie=se.data?.providers?.[Y];ie?.connected&&ie.via==="sa"&&(ne[V]={resource:ie.resource??null})}const oe=jt({requirements:h,itemsById:R,itemsByName:U,connections:L,connectionReadiness:k,configurationState:w,curated:Pe,saBindings:ne});let J;return e[41]!==oe?(J={cards:oe},e[41]=oe,e[42]=J):J=e[42],J}function Cn(i){return i.oauth_config&&!i.connection_token}function yn(i){return`linked:${i}`}function jn(i){return`app:${i}`}function vn(i){return`binding:${i}`}function Sn(i){return typeof i=="string"&&i.length>0}function _n(i){return i.bindingType}function Nn(i){return!Pe[i.bindingType]}function On(i){return!!i}function Tn(i){return Pe[i.bindingType]?.registryAppId}function En(i){return i.bindingType}function In({selfClient:i,org:e,userId:t,cdConnectionId:o,domain:u,siteUrl:d}){const l=ve(),[r,f]=Q.useState(null),[p,s]=Q.useState(null),[a,g]=Q.useState(null),c=async(h,x)=>{const m=await i.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:h,data:x}});return ee(m)};async function b(h){f(h.fieldKey),g(null);const x={app_name:h.title,field_key:h.fieldKey,organization_id:e.id,domain:u,site_url:d};me("commerce_onboarding_companion_connect_clicked",x);try{let m=h.candidateConnectionId;if(!m){const j=kt(h.registryItem,e.id,t,{remoteIndex:0}),w=j.connection_type==="STDIO",O=!!j.connection_url,N=w&&j.connection_headers&&typeof j.connection_headers=="object"&&"command"in j.connection_headers;if(!O&&!N)return me("commerce_onboarding_companion_connect_failed",{...x,error:"no_connection_method"}),g(`${h.title} cannot be connected: no connection method available`),!1;const I=await i.callTool({name:"COLLECTION_CONNECTIONS_CREATE",arguments:{data:j}});m=ee(I).item.id}const v=m,y=await At({connectionId:v,orgId:e.id,orgSlug:e.slug,persistFallback:j=>c(v,{connection_token:j}).then(()=>{})});if(!y.ok)return me("commerce_onboarding_companion_connect_failed",{...x,error:y.error}),g(`Couldn't sign in to ${h.title}: ${y.error}`),!1;const E=await i.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),_=ee(E).item?.configuration_state??null,S=vt(_,h.fieldKey,h.bindingType,v);return h.bindingType==="github"&&delete S.github_repo,await c(o,{configuration_state:S}),await l.invalidateQueries({queryKey:X.commerceDiscoveryConnection(e.id,o)}),await l.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),me("commerce_onboarding_companion_connected",x),!0}catch(m){return me("commerce_onboarding_companion_connect_failed",{...x,error:m instanceof Error?m.message:String(m)}),g(m instanceof Error?m.message:String(m)),!1}finally{f(null)}}async function C(h){s(h.fieldKey),g(null);const x={app_name:h.title,field_key:h.fieldKey,organization_id:e.id,domain:u,site_url:d};me("commerce_onboarding_companion_disconnect_clicked",x);try{const m=await i.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),y={...ee(m).item?.configuration_state??null??{}};return delete y[h.fieldKey],h.bindingType==="github"&&delete y.github_repo,await c(o,{configuration_state:y}),await l.invalidateQueries({queryKey:X.commerceDiscoveryConnection(e.id,o)}),await l.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),me("commerce_onboarding_companion_disconnected",x),!0}catch(m){return me("commerce_onboarding_companion_disconnect_failed",{...x,error:m instanceof Error?m.message:String(m)}),g(m instanceof Error?m.message:String(m)),!1}finally{s(null)}}return{connect:b,connectingFieldKey:r,disconnect:C,disconnectingFieldKey:p,error:a}}const $e="flex min-h-0 flex-1 flex-col gap-6 md:grid md:flex-none md:gap-6";function qe(){const i=H.c(4),e=te();let t;i[0]!==e?(t=e("routes.commerceOnboarding.companionSection.title"),i[0]=e,i[1]=t):t=i[1];let o;return i[2]!==t?(o=n.jsx("h1",{className:"text-lg font-medium leading-6 text-foreground lg:text-xl lg:leading-7",children:t}),i[2]=t,i[3]=o):o=i[3],o}function wn(){const i=H.c(1);let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2,3].map(Fn)}),i[0]=e):e=i[0],e}function Fn(i){return n.jsx(gn,{},i)}function kn(){const i=H.c(1);let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:$e,children:[n.jsx(qe,{}),n.jsx(wn,{})]}),i[0]=e):e=i[0],e}function Ln(i){const e=H.c(18),{onRetry:t}=i,o=te();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(qe,{}),e[0]=u):u=e[0];let d;e[1]!==o?(d=o("routes.commerceOnboarding.companionSection.loadError"),e[1]=o,e[2]=d):d=e[2];let l;e[3]!==d?(l=n.jsx("p",{className:"text-sm text-foreground",children:d}),e[3]=d,e[4]=l):l=e[4];let r;e[5]!==o?(r=o("routes.commerceOnboarding.companionSection.loadErrorDescription"),e[5]=o,e[6]=r):r=e[6];let f;e[7]!==r?(f=n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r}),e[7]=r,e[8]=f):f=e[8];let p;e[9]!==o?(p=o("routes.commerceOnboarding.companionSection.retry"),e[9]=o,e[10]=p):p=e[10];let s;e[11]!==t||e[12]!==p?(s=n.jsx(Z,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:t,children:p}),e[11]=t,e[12]=p,e[13]=s):s=e[13];let a;return e[14]!==l||e[15]!==f||e[16]!==s?(a=n.jsxs("div",{className:$e,children:[u,n.jsxs("div",{role:"alert",className:"rounded-2xl border border-border bg-card p-4",children:[l,f,s]})]}),e[14]=l,e[15]=f,e[16]=s,e[17]=a):a=e[17],a}function ro(i){const e=H.c(2);let t;return e[0]!==i?(t=n.jsx(ct,{children:o=>{const{reset:u}=o;return n.jsx(dt,{fallback:d=>{const{resetError:l}=d;return n.jsx(Ln,{onRetry:()=>{u(),l()}})},children:n.jsx(Q.Suspense,{fallback:n.jsx(kn,{}),children:n.jsx(An,{...i})})})}}),e[0]=i,e[1]=t):t=e[1],t}function An(i){const e=H.c(53),{org:t,cdConnectionId:o,siteUrl:u,onReadinessChange:d}=i,{data:l}=mt.useSession(),r=l?.user?.id??"";let f;if(e[0]!==u){const P=u?_e(u):null;if(P?.ok)try{f=new URL(P.value).hostname}catch{f=void 0}e[0]=u,e[1]=f}else f=e[1];let p;e[2]!==t.id||e[3]!==t.slug?(p={connectionId:ft,orgId:t.id,orgSlug:t.slug},e[2]=t.id,e[3]=t.slug,e[4]=p):p=e[4];const s=we(p);let a;e[5]!==o||e[6]!==t||e[7]!==s||e[8]!==u?(a={selfClient:s,org:t,cdConnectionId:o,siteUrl:u},e[5]=o,e[6]=t,e[7]=s,e[8]=u,e[9]=a):a=e[9];const{cards:g}=bn(a);let c;e[10]!==o||e[11]!==t||e[12]!==s||e[13]!==f||e[14]!==u||e[15]!==r?(c={selfClient:s,org:t,userId:r,cdConnectionId:o,domain:f,siteUrl:u},e[10]=o,e[11]=t,e[12]=s,e[13]=f,e[14]=u,e[15]=r,e[16]=c):c=e[16];const{connect:b,connectingFieldKey:C,disconnect:h,disconnectingFieldKey:x,error:m}=In(c),[v,y]=Q.useState(null),E=Pn;let _,S,j,w,O,N,I,T,L;if(e[17]!==v||e[18]!==g||e[19]!==b||e[20]!==m||e[21]!==C||e[22]!==h||e[23]!==x||e[24]!==d||e[25]!==t||e[26]!==s||e[27]!==u){j=Symbol.for("react.early_return_sentinel");e:{const P=g.filter(Dn),B=g.filter(Rn),K=P.length>0?P.every(E):g.length===0||g.some(E);if(d?.(K),g.length===0){j=null;break e}const z=C!==null||x!==null,k=F=>{const R=async()=>{await b(F)&&y(F.fieldKey)};return n.jsx(hn,{card:F,connecting:C===F.fieldKey,disconnecting:x===F.fieldKey,disabled:z&&C!==F.fieldKey&&x!==F.fieldKey,org:t,selfClient:s,siteUrl:u,autoOpenConfigFieldKey:v,onAutoOpenConfigHandled:()=>y(U=>U===F.fieldKey?null:U),onConnect:()=>{R()},onDisconnect:()=>{h(F)}},F.fieldKey)};L=$e,e[37]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(qe,{}),e[37]=S):S=e[37],_=Kt,N="flex min-h-0 flex-1 flex-col md:block",I="-mx-1 min-h-0 flex-1 overflow-y-auto px-1 md:max-h-[min(60vh,calc(100dvh-330px))] md:flex-none",e[38]!==m?(T=m&&n.jsx("p",{role:"alert",className:"mb-3 text-sm text-destructive",children:m}),e[38]=m,e[39]=T):T=e[39],w="flex flex-col gap-4 pt-3",O=[...P,...B].map(k)}e[17]=v,e[18]=g,e[19]=b,e[20]=m,e[21]=C,e[22]=h,e[23]=x,e[24]=d,e[25]=t,e[26]=s,e[27]=u,e[28]=_,e[29]=S,e[30]=j,e[31]=w,e[32]=O,e[33]=N,e[34]=I,e[35]=T,e[36]=L}else _=e[28],S=e[29],j=e[30],w=e[31],O=e[32],N=e[33],I=e[34],T=e[35],L=e[36];if(j!==Symbol.for("react.early_return_sentinel"))return j;let $;e[40]!==w||e[41]!==O?($=n.jsx("div",{className:w,children:O}),e[40]=w,e[41]=O,e[42]=$):$=e[42];let A;e[43]!==_||e[44]!==$||e[45]!==N||e[46]!==I||e[47]!==T?(A=n.jsxs(_,{wrapperClassName:N,className:I,children:[T,$]}),e[43]=_,e[44]=$,e[45]=N,e[46]=I,e[47]=T,e[48]=A):A=e[48];let q;return e[49]!==S||e[50]!==A||e[51]!==L?(q=n.jsxs("div",{className:L,children:[S,A]}),e[49]=S,e[50]=A,e[51]=L,e[52]=q):q=e[52],q}function Rn(i){return!i.required}function Dn(i){return i.required}function Pn(i){return i.satisfied&&i.configured}function $n(i){return i.content?.find(e=>e.text)?.text??"A configuração do Commerce Discovery falhou."}function ao(i){const e=i;if(e.isError)throw new Error($n(e));return e.structuredContent??i}export{kn as C,De as L,Kt as S,ro as a,so as i,_e as n,ao as p,io as s};
1
+ import{X as rt,c as H,r as Q,m as ue,j as n,b as te,k as Ie,B as Z,o as ve,e as Ne,K as X,Y as be,Z as re,_ as Ce,$ as ye,n as he,a0 as at,t as Se,u as lt,x as Te,p as me,Q as ct,E as dt,a as mt}from"./index-DSL_ub0T.js";import{W as Ve,g as ut,u as we,S as ft}from"./use-mcp-client-DqHVlRT-.js";import{I as Fe}from"./integration-icon-BdwbQSLL.js";import{c as pe,b as Ge,h as Me,a as Qe,d as He,e as We}from"./dialog-nd9Y9UDf.js";import{c as ke,T as Le,a as Ae}from"./tooltip-fNNHHvCP.js";import{k as Ye,f as Ze,a as pt}from"./agent-icon-LwtXnQ8r.js";import{u as ee,t as gt,m as ht,s as Ke,g as xt,p as bt,F as Ct,b as yt,a as jt,c as vt}from"./companions-core-DhobrWwt.js";import{i as Xe}from"./CheckCircle-CJSSqHjK.js";import{F as ae,a as je,b as le,c as fe,d as ce,e as de,f as St}from"./form-DZe1OoXa.js";import{I as ge}from"./input-D-iDTYtd.js";import{i as _t}from"./Check-Dw-gymvq.js";import{a as Je}from"./Copy01-Cmo8Ag8o.js";import{i as Nt}from"./Settings02-DLn641-3.js";import{s as Ot}from"./Eye-B6gNJQkZ.js";import{u as Tt}from"./use-debounced-value-D4-eJghO.js";import{f as et,a as Et,p as It,i as wt}from"./provision-repo-scoped-github-connection-B2s3ApVy.js";import{c as Ft,e as kt}from"./extract-connection-data-B6jF9vIP.js";import{u as Lt}from"./useQueries-YKDnkiqD.js";import{a as At}from"./authenticate-and-persist-oauth-CaPu7RQh.js";function Rt(i,e){return Lt({...i,queries:i.queries.map(t=>({...t,suspense:!0,throwOnError:rt,enabled:!0,placeholderData:void 0}))},e)}const Dt=/^[a-zA-Z][a-zA-Z\d+.-]*:/,Pt=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//,$t=/^[^\s/:?#]+\.[^\s/:?#]+:\d+(?:[/?#]|$)/,qt=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function _e(i){const e=i.trim();if(!e)return{ok:!1,error:"Enter a website URL."};const t=Dt.test(e),o=Pt.test(e),u=$t.test(e);if(t&&!o&&!u)return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const d=o?e:`https://${e}`;let l;try{l=new URL(d)}catch{return{ok:!1,error:"Enter a valid website URL."}}if(l.protocol!=="http:"&&l.protocol!=="https:")return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const r=l.hostname.split(".");return r.length<2||r.some(f=>!f||!qt.test(f))?{ok:!1,error:"Enter a valid website URL."}:(l.protocol="https:",{ok:!0,value:l.origin})}function so(i,e){if(!i.trim())return!0;const t=_e(i);if(!t.ok||!e)return!1;const o=_e(e);return o.ok&&o.value===t.value}function io(i){if(!i)return null;const e=_e(i);return e.ok?new URL(e.value).hostname:null}function Kt(i){const e=H.c(14),{children:t,className:o,wrapperClassName:u}=i,[d,l]=Q.useState(!0);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=C=>{if(!C)return;const h=()=>{const m=C.scrollHeight-C.scrollTop-C.clientHeight<8;l(m)};h(),C.addEventListener("scroll",h,{passive:!0});const x=new ResizeObserver(h);x.observe(C);for(const m of Array.from(C.children))x.observe(m);return()=>{C.removeEventListener("scroll",h),x.disconnect()}},e[0]=r):r=e[0];const f=r;let p;e[1]!==u?(p=ue("relative",u),e[1]=u,e[2]=p):p=e[2];let s;e[3]!==t||e[4]!==o?(s=n.jsx("div",{ref:f,className:o,children:t}),e[3]=t,e[4]=o,e[5]=s):s=e[5];const a=d?"opacity-0":"opacity-100";let g;e[6]!==a?(g=ue("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",a),e[6]=a,e[7]=g):g=e[7];let c;e[8]!==g?(c=n.jsx("div",{"aria-hidden":!0,className:g}),e[8]=g,e[9]=c):c=e[9];let b;return e[10]!==p||e[11]!==s||e[12]!==c?(b=n.jsxs("div",{className:p,children:[s,c]}),e[10]=p,e[11]=s,e[12]=c,e[13]=b):b=e[13],b}function Ut(i){const e=H.c(25),{icon:t,title:o,headline:u,required:d,attention:l,action:r}=i,f=te(),p=l?"border-warning/50 bg-warning/[0.04]":"border-border";let s;e[0]!==p?(s=ue("relative flex items-center justify-between gap-3 rounded-lg border bg-card p-3.5 sm:gap-4 sm:p-4",p),e[0]=p,e[1]=s):s=e[1];let a;e[2]!==d||e[3]!==f?(a=d&&n.jsx("span",{className:"absolute -top-3 right-4 rounded-full border border-input bg-background px-3 py-1 text-xs font-medium text-foreground",children:f("commerceOnboarding.companionCard.required")}),e[2]=d,e[3]=f,e[4]=a):a=e[4];let g;e[5]!==t||e[6]!==o?(g=n.jsx(Fe,{icon:t,name:o,size:"sm",fit:"contain",className:"size-[30px] shrink-0 p-1"}),e[5]=t,e[6]=o,e[7]=g):g=e[7];let c;e[8]!==o?(c=n.jsx("span",{className:"text-sm font-medium text-foreground",children:o}),e[8]=o,e[9]=c):c=e[9];let b;e[10]!==u?(b=u&&n.jsx("p",{className:"hidden text-sm leading-5 text-muted-foreground sm:block",children:u}),e[10]=u,e[11]=b):b=e[11];let C;e[12]!==c||e[13]!==b?(C=n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[c,b]}),e[12]=c,e[13]=b,e[14]=C):C=e[14];let h;e[15]!==g||e[16]!==C?(h=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3 sm:items-start",children:[g,C]}),e[15]=g,e[16]=C,e[17]=h):h=e[17];let x;e[18]!==r?(x=n.jsx("div",{className:"shrink-0",children:r}),e[18]=r,e[19]=x):x=e[19];let m;return e[20]!==s||e[21]!==a||e[22]!==h||e[23]!==x?(m=n.jsxs("div",{className:s,children:[a,h,x]}),e[20]=s,e[21]=a,e[22]=h,e[23]=x,e[24]=m):m=e[24],m}function tt(i){const e=H.c(12),{connecting:t,disabled:o,title:u,primary:d,onConnect:l}=i,r=te(),f=d?"default":"outline",p=o||t;let s;e[0]!==r||e[1]!==u?(s=r("commerceOnboarding.companionCard.connectAriaLabel",{title:u}),e[0]=r,e[1]=u,e[2]=s):s=e[2];let a;e[3]!==t||e[4]!==r?(a=t?n.jsx(Ie,{size:16,className:"animate-spin"}):r("commerceOnboarding.companionCard.connect"),e[3]=t,e[4]=r,e[5]=a):a=e[5];let g;return e[6]!==l||e[7]!==f||e[8]!==p||e[9]!==s||e[10]!==a?(g=n.jsx(Z,{type:"button",variant:f,size:"sm",disabled:p,onClick:l,"aria-label":s,children:a}),e[6]=l,e[7]=f,e[8]=p,e[9]=s,e[10]=a,e[11]=g):g=e[11],g}function Bt(i){const e=H.c(11),{disabled:t,title:o,onConfigure:u}=i,d=te();let l;e[0]!==d||e[1]!==o?(l=d("commerceOnboarding.companionCard.configureAriaLabel",{title:o}),e[0]=d,e[1]=o,e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Ye,{size:16}),e[3]=r):r=e[3];let f;e[4]!==d?(f=d("commerceOnboarding.companionCard.finishSetup"),e[4]=d,e[5]=f):f=e[5];let p;return e[6]!==t||e[7]!==u||e[8]!==l||e[9]!==f?(p=n.jsxs(Z,{type:"button",variant:"outline",size:"sm",className:"border-warning/60 text-warning hover:bg-warning/10 hover:text-warning",disabled:t,onClick:u,"aria-label":l,children:[r,f]}),e[6]=t,e[7]=u,e[8]=l,e[9]=f,e[10]=p):p=e[10],p}function nt(i){const e=H.c(9),{detail:t,controls:o}=i,u=te();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Xe,{size:16,className:"text-success"}),e[0]=d):d=e[0];let l;e[1]!==t||e[2]!==u?(l=t?n.jsx("span",{className:"max-w-40 truncate text-foreground",children:t}):u("commerceOnboarding.companionCard.connected"),e[1]=t,e[2]=u,e[3]=l):l=e[3];let r;e[4]!==l?(r=n.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[d," ",l]}),e[4]=l,e[5]=r):r=e[5];let f;return e[6]!==o||e[7]!==r?(f=n.jsxs("div",{className:"flex items-center gap-1",children:[r,o]}),e[6]=o,e[7]=r,e[8]=f):f=e[8],f}function ot(i){const e=H.c(4),{ariaLabel:t,onClick:o}=i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Ye,{size:16}),e[0]=u):u=e[0];let d;return e[1]!==t||e[2]!==o?(d=n.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:o,"aria-label":t,children:u}),e[1]=t,e[2]=o,e[3]=d):d=e[3],d}function Ee(i){const e=H.c(38);let t,o,u,d,l;e[0]!==i?({value:l,onChange:o,placeholder:u,className:t,...d}=i,e[0]=i,e[1]=t,e[2]=o,e[3]=u,e[4]=d,e[5]=l):(t=e[1],o=e[2],u=e[3],d=e[4],l=e[5]);const[r,f]=Q.useState(!1),[p,s]=Q.useState(!1);let a;e[6]!==l?(a=async()=>{if(l)try{await navigator.clipboard.writeText(l),s(!0),setTimeout(()=>s(!1),2e3)}catch(N){console.error("Failed to copy text: ",N)}},e[6]=l,e[7]=a):a=e[7];const g=a;let c;e[8]!==r?(c=()=>{f(!r)},e[8]=r,e[9]=c):c=e[9];const b=c,C=r?"text":"password";let h;e[10]!==t?(h=ue("pr-20",t),e[10]=t,e[11]=h):h=e[11];let x;e[12]!==o||e[13]!==u||e[14]!==d||e[15]!==C||e[16]!==h||e[17]!==l?(x=n.jsx(ge,{type:C,value:l,onChange:o,placeholder:u,className:h,...d}),e[12]=o,e[13]=u,e[14]=d,e[15]=C,e[16]=h,e[17]=l,e[18]=x):x=e[18];const m=r?"Hide password":"Show password";let v;e[19]!==r?(v=r?n.jsx(Nt,{size:16}):n.jsx(Ot,{size:16}),e[19]=r,e[20]=v):v=e[20];let y;e[21]!==m||e[22]!==v||e[23]!==b?(y=n.jsx(Z,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:b,title:m,children:v}),e[21]=m,e[22]=v,e[23]=b,e[24]=y):y=e[24];const E=!l,_=p?"Copied!":"Copy token";let S;e[25]!==p?(S=p?n.jsx(_t,{size:16}):n.jsx(Je,{size:16}),e[25]=p,e[26]=S):S=e[26];let j;e[27]!==g||e[28]!==_||e[29]!==S||e[30]!==E?(j=n.jsx(Z,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:g,disabled:E,title:_,children:S}),e[27]=g,e[28]=_,e[29]=S,e[30]=E,e[31]=j):j=e[31];let w;e[32]!==j||e[33]!==y?(w=n.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-1 h-8",children:[y,j]}),e[32]=j,e[33]=y,e[34]=w):w=e[34];let O;return e[35]!==w||e[36]!==x?(O=n.jsxs("div",{className:"relative",children:[x,w]}),e[35]=w,e[36]=x,e[37]=O):O=e[37],O}function Oe(i){const e=H.c(19),{card:t,selfClient:o,org:u,onDone:d,onError:l}=i,r=ve();let f;e[0]!==t||e[1]!==o?(f=async h=>{const{values:x,connectionToken:m}=h,y={configuration_state:{...t.configurationState??{},...x}};m!==void 0&&(y.connection_token=m),await o.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:t.linkedConnectionId||t.candidateConnectionId,data:y}})},e[0]=t,e[1]=o,e[2]=f):f=e[2];let p;e[3]!==d||e[4]!==u||e[5]!==r?(p=async()=>{await r.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(u.id)}),d()},e[3]=d,e[4]=u,e[5]=r,e[6]=p):p=e[6];let s;e[7]!==l?(s=h=>{l?.(h)},e[7]=l,e[8]=s):s=e[8];let a;e[9]!==f||e[10]!==p||e[11]!==s?(a={mutationFn:f,onSuccess:p,onError:s},e[9]=f,e[10]=p,e[11]=s,e[12]=a):a=e[12];const g=Ne(a);let c;e[13]!==g?(c=(h,x)=>g.mutate({values:h,connectionToken:x?.connectionToken}),e[13]=g,e[14]=c):c=e[14];const b=c;let C;return e[15]!==g.error||e[16]!==g.isPending||e[17]!==b?(C={save:b,isPending:g.isPending,error:g.error},e[15]=g.error,e[16]=g.isPending,e[17]=b,e[18]=C):C=e[18],C}const zt=be({accountName:re().min(1,"Informe o nome da conta"),appKey:re().optional(),appToken:re().optional()});function Vt(i){const e=H.c(73),{card:t,selfClient:o,org:u,onDone:d,onIsPendingChange:l}=i,r=te();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=Ce(zt),e[0]=f):f=e[0];const p=t.configurationState?.accountName||"",s=t.configurationState?.appKey||"",a=t.configurationState?.appToken||"";let g;e[1]!==p||e[2]!==s||e[3]!==a?(g={resolver:f,defaultValues:{accountName:p,appKey:s,appToken:a}},e[1]=p,e[2]=s,e[3]=a,e[4]=g):g=e[4];const c=ye(g);let b;e[5]!==t.configurationState?.accountName||e[6]!==t.configurationState?.appKey||e[7]!==t.configurationState?.appToken||e[8]!==c?(b=()=>{c.reset({accountName:t.configurationState?.accountName||"",appKey:t.configurationState?.appKey||"",appToken:t.configurationState?.appToken||""})},e[5]=t.configurationState?.accountName,e[6]=t.configurationState?.appKey,e[7]=t.configurationState?.appToken,e[8]=c,e[9]=b):b=e[9];let C;e[10]!==t.configurationState||e[11]!==c?(C=[t.configurationState,c],e[10]=t.configurationState,e[11]=c,e[12]=C):C=e[12],Q.useEffect(b,C);let h;e[13]!==t||e[14]!==d||e[15]!==u||e[16]!==o?(h={card:t,selfClient:o,org:u,onDone:d},e[13]=t,e[14]=d,e[15]=u,e[16]=o,e[17]=h):h=e[17];const{save:x,isPending:m,error:v}=Oe(h);let y,E;e[18]!==m||e[19]!==l?(E=()=>{l?.(m)},y=[m,l],e[18]=m,e[19]=l,e[20]=y,e[21]=E):(y=e[20],E=e[21]),Q.useEffect(E,y);let _;if(e[22]!==c||e[23]!==x){let k;e[25]!==x?(k=async F=>{x(F)},e[25]=x,e[26]=k):k=e[26],_=c.handleSubmit(k),e[22]=c,e[23]=x,e[24]=_}else _=e[24];const S=_;let j;e[27]!==m||e[28]!==r?(j=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.vtexConfigForm.accountNameLabel")}),n.jsx(ce,{children:n.jsx(ge,{placeholder:r("commerceOnboarding.vtexConfigForm.accountNamePlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[27]=m,e[28]=r,e[29]=j):j=e[29];let w;e[30]!==c.control||e[31]!==j?(w=n.jsx(ae,{control:c.control,name:"accountName",render:j}),e[30]=c.control,e[31]=j,e[32]=w):w=e[32];let O;e[33]!==m||e[34]!==r?(O=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.vtexConfigForm.appKeyLabel")}),n.jsx(ce,{children:n.jsx(Ee,{placeholder:r("commerceOnboarding.vtexConfigForm.appKeyPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[33]=m,e[34]=r,e[35]=O):O=e[35];let N;e[36]!==c.control||e[37]!==O?(N=n.jsx(ae,{control:c.control,name:"appKey",render:O}),e[36]=c.control,e[37]=O,e[38]=N):N=e[38];let I;e[39]!==m||e[40]!==r?(I=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.vtexConfigForm.appTokenLabel")}),n.jsx(ce,{children:n.jsx(Ee,{placeholder:r("commerceOnboarding.vtexConfigForm.appTokenPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[39]=m,e[40]=r,e[41]=I):I=e[41];let T;e[42]!==c.control||e[43]!==I?(T=n.jsx(ae,{control:c.control,name:"appToken",render:I}),e[42]=c.control,e[43]=I,e[44]=T):T=e[44];let L;e[45]!==c||e[46]!==w||e[47]!==N||e[48]!==T?(L=n.jsxs(je,{...c,children:[w,N,T]}),e[45]=c,e[46]=w,e[47]=N,e[48]=T,e[49]=L):L=e[49];let $;e[50]!==v||e[51]!==r?($=v&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v instanceof Error?v.message:r("commerceOnboarding.vtexConfigForm.savingError")}),e[50]=v,e[51]=r,e[52]=$):$=e[52];let A;e[53]!==r?(A=r("commerceOnboarding.vtexConfigForm.cancelButton"),e[53]=r,e[54]=A):A=e[54];let q;e[55]!==m||e[56]!==d||e[57]!==A?(q=n.jsx(Z,{type:"button",variant:"outline",onClick:d,disabled:m,children:A}),e[55]=m,e[56]=d,e[57]=A,e[58]=q):q=e[58];let P;e[59]!==m||e[60]!==r?(P=r(m?"commerceOnboarding.vtexConfigForm.savingButton":"commerceOnboarding.vtexConfigForm.saveButton"),e[59]=m,e[60]=r,e[61]=P):P=e[61];let B;e[62]!==m||e[63]!==P?(B=n.jsx(Z,{type:"submit",disabled:m,children:P}),e[62]=m,e[63]=P,e[64]=B):B=e[64];let K;e[65]!==q||e[66]!==B?(K=n.jsxs(pe,{className:"pt-4",children:[q,B]}),e[65]=q,e[66]=B,e[67]=K):K=e[67];let z;return e[68]!==S||e[69]!==L||e[70]!==$||e[71]!==K?(z=n.jsxs("form",{onSubmit:S,className:"space-y-4",children:[L,$,K]}),e[68]=S,e[69]=L,e[70]=$,e[71]=K,e[72]=z):z=e[72],z}const Gt=(i,e)=>be({storeDomain:re().min(1,e("commerceOnboarding.shopifyConfigForm.storeDomainRequired")),accessToken:re().optional(),apiVersion:re().optional()}).refine(t=>i||!!t.accessToken?.trim(),{path:["accessToken"],message:e("commerceOnboarding.shopifyConfigForm.accessTokenRequired")});function Mt(i){const e=H.c(76),{card:t,selfClient:o,org:u,onDone:d,onIsPendingChange:l}=i,r=te();let f;e[0]!==t.configured||e[1]!==r?(f=Ce(Gt(t.configured,r)),e[0]=t.configured,e[1]=r,e[2]=f):f=e[2];const p=t.configurationState?.storeDomain||"",s=t.configurationState?.apiVersion||"";let a;e[3]!==p||e[4]!==s?(a={storeDomain:p,accessToken:"",apiVersion:s},e[3]=p,e[4]=s,e[5]=a):a=e[5];let g;e[6]!==f||e[7]!==a?(g={resolver:f,defaultValues:a},e[6]=f,e[7]=a,e[8]=g):g=e[8];const c=ye(g);let b;e[9]!==t.configurationState?.apiVersion||e[10]!==t.configurationState?.storeDomain||e[11]!==c?(b=()=>{c.reset({storeDomain:t.configurationState?.storeDomain||"",accessToken:"",apiVersion:t.configurationState?.apiVersion||""})},e[9]=t.configurationState?.apiVersion,e[10]=t.configurationState?.storeDomain,e[11]=c,e[12]=b):b=e[12];let C;e[13]!==t.configurationState||e[14]!==c?(C=[t.configurationState,c],e[13]=t.configurationState,e[14]=c,e[15]=C):C=e[15],Q.useEffect(b,C);let h;e[16]!==t||e[17]!==d||e[18]!==u||e[19]!==o?(h={card:t,selfClient:o,org:u,onDone:d},e[16]=t,e[17]=d,e[18]=u,e[19]=o,e[20]=h):h=e[20];const{save:x,isPending:m,error:v}=Oe(h);let y,E;e[21]!==m||e[22]!==l?(E=()=>{l?.(m)},y=[m,l],e[21]=m,e[22]=l,e[23]=y,e[24]=E):(y=e[23],E=e[24]),Q.useEffect(E,y);let _;if(e[25]!==c||e[26]!==x){let k;e[28]!==x?(k=async F=>{const R=F.apiVersion?.trim(),U=F.accessToken?.trim();x({storeDomain:F.storeDomain.trim(),...R?{apiVersion:R}:{}},U?{connectionToken:U}:void 0)},e[28]=x,e[29]=k):k=e[29],_=c.handleSubmit(k),e[25]=c,e[26]=x,e[27]=_}else _=e[27];const S=_;let j;e[30]!==m||e[31]!==r?(j=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.shopifyConfigForm.storeDomainLabel")}),n.jsx(ce,{children:n.jsx(ge,{placeholder:r("commerceOnboarding.shopifyConfigForm.storeDomainPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[30]=m,e[31]=r,e[32]=j):j=e[32];let w;e[33]!==c.control||e[34]!==j?(w=n.jsx(ae,{control:c.control,name:"storeDomain",render:j}),e[33]=c.control,e[34]=j,e[35]=w):w=e[35];let O;e[36]!==m||e[37]!==r?(O=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.shopifyConfigForm.accessTokenLabel")}),n.jsx(ce,{children:n.jsx(Ee,{placeholder:r("commerceOnboarding.shopifyConfigForm.accessTokenPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[36]=m,e[37]=r,e[38]=O):O=e[38];let N;e[39]!==c.control||e[40]!==O?(N=n.jsx(ae,{control:c.control,name:"accessToken",render:O}),e[39]=c.control,e[40]=O,e[41]=N):N=e[41];let I;e[42]!==m||e[43]!==r?(I=k=>{const{field:F}=k;return n.jsxs(le,{children:[n.jsx(fe,{children:r("commerceOnboarding.shopifyConfigForm.apiVersionLabel")}),n.jsx(ce,{children:n.jsx(ge,{placeholder:r("commerceOnboarding.shopifyConfigForm.apiVersionPlaceholder"),...F,disabled:m})}),n.jsx(de,{})]})},e[42]=m,e[43]=r,e[44]=I):I=e[44];let T;e[45]!==c.control||e[46]!==I?(T=n.jsx(ae,{control:c.control,name:"apiVersion",render:I}),e[45]=c.control,e[46]=I,e[47]=T):T=e[47];let L;e[48]!==c||e[49]!==w||e[50]!==N||e[51]!==T?(L=n.jsxs(je,{...c,children:[w,N,T]}),e[48]=c,e[49]=w,e[50]=N,e[51]=T,e[52]=L):L=e[52];let $;e[53]!==v||e[54]!==r?($=v&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v instanceof Error?v.message:r("commerceOnboarding.shopifyConfigForm.savingError")}),e[53]=v,e[54]=r,e[55]=$):$=e[55];let A;e[56]!==r?(A=r("commerceOnboarding.shopifyConfigForm.cancelButton"),e[56]=r,e[57]=A):A=e[57];let q;e[58]!==m||e[59]!==d||e[60]!==A?(q=n.jsx(Z,{type:"button",variant:"outline",onClick:d,disabled:m,children:A}),e[58]=m,e[59]=d,e[60]=A,e[61]=q):q=e[61];let P;e[62]!==m||e[63]!==r?(P=r(m?"commerceOnboarding.shopifyConfigForm.savingButton":"commerceOnboarding.shopifyConfigForm.saveButton"),e[62]=m,e[63]=r,e[64]=P):P=e[64];let B;e[65]!==m||e[66]!==P?(B=n.jsx(Z,{type:"submit",disabled:m,children:P}),e[65]=m,e[66]=P,e[67]=B):B=e[67];let K;e[68]!==q||e[69]!==B?(K=n.jsxs(pe,{className:"pt-4",children:[q,B]}),e[68]=q,e[69]=B,e[70]=K):K=e[70];let z;return e[71]!==S||e[72]!==L||e[73]!==$||e[74]!==K?(z=n.jsxs("form",{onSubmit:S,className:"space-y-4",children:[L,$,K]}),e[71]=S,e[72]=L,e[73]=$,e[74]=K,e[75]=z):z=e[75],z}function Re(i){const e=H.c(31),{options:t,value:o,onChange:u,disabled:d,ariaLabel:l,searchPlaceholder:r,hideSearch:f}=i,p=f===void 0?!1:f,s=te(),[a,g]=Q.useState("");let c,b,C;if(e[0]!==t||e[1]!==a||e[2]!==o){const S=a.trim().toLowerCase();c=S?t.filter(j=>j.label.toLowerCase().includes(S)):t,b=c.map(Qt),C=b.includes(o)?o:b[0]??"",e[0]=t,e[1]=a,e[2]=o,e[3]=c,e[4]=b,e[5]=C}else c=e[3],b=e[4],C=e[5];const h=C;let x;e[6]!==d||e[7]!==b||e[8]!==u?(x=function(j){if(d||!["ArrowDown","ArrowRight","ArrowUp","ArrowLeft","Home","End"].includes(j.key))return;j.preventDefault();const O=j.currentTarget.dataset.value,N=b.indexOf(O),I=b.length;if(I===0)return;let T;j.key==="ArrowDown"||j.key==="ArrowRight"?T=(N+1)%I:j.key==="ArrowUp"||j.key==="ArrowLeft"?T=(N-1+I)%I:j.key==="Home"?T=0:T=I-1;const L=b[T];u(L),j.currentTarget.closest('[role="radiogroup"]')?.querySelector(`[data-value="${CSS.escape(L)}"]`)?.focus()},e[6]=d,e[7]=b,e[8]=u,e[9]=x):x=e[9];const m=x;let v;e[10]!==l||e[11]!==d||e[12]!==p||e[13]!==a||e[14]!==r||e[15]!==s?(v=p?null:n.jsxs("div",{className:"relative",children:[n.jsx(Ze,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),n.jsx(ge,{type:"text",value:a,onChange:S=>g(S.target.value),disabled:d,placeholder:r??s("commerceOnboarding.selectableList.searchPlaceholder"),"aria-label":s("commerceOnboarding.selectableList.searchAriaLabel",{label:l}),className:"h-8 pl-8"})]}),e[10]=l,e[11]=d,e[12]=p,e[13]=a,e[14]=r,e[15]=s,e[16]=v):v=e[16];let y;e[17]!==d||e[18]!==c||e[19]!==m||e[20]!==u||e[21]!==s||e[22]!==h||e[23]!==o?(y=c.length===0?n.jsx("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:s("commerceOnboarding.selectableList.noResults")}):c.map(S=>{const j=S.value===o;return n.jsxs("button",{type:"button",role:"radio","aria-checked":j,disabled:d,"data-value":S.value,tabIndex:S.value===h?0:-1,onClick:()=>u(S.value),onKeyDown:m,className:ue("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:[n.jsx("span",{className:"truncate",children:S.label}),j?n.jsx(Xe,{size:16,className:"shrink-0 text-primary"}):null]},S.value)}),e[17]=d,e[18]=c,e[19]=m,e[20]=u,e[21]=s,e[22]=h,e[23]=o,e[24]=y):y=e[24];let E;e[25]!==l||e[26]!==y?(E=n.jsx("div",{role:"radiogroup","aria-label":l,className:"max-h-[280px] overflow-y-auto",children:y}),e[25]=l,e[26]=y,e[27]=E):E=e[27];let _;return e[28]!==v||e[29]!==E?(_=n.jsxs("div",{className:"space-y-2",children:[v,E]}),e[28]=v,e[29]=E,e[30]=_):_=e[30],_}function Qt(i){return i.value}function De(i){const e=H.c(16),{label:t,iconSize:o,className:u,iconClassName:d,labelClassName:l}=i,r=o===void 0?14:o;let f;e[0]!==u?(f=ue("inline-flex items-center gap-2",u),e[0]=u,e[1]=f):f=e[1];let p;e[2]!==d?(p=ue("shrink-0 animate-spin",d),e[2]=d,e[3]=p):p=e[3];let s;e[4]!==r||e[5]!==p?(s=n.jsx(Ie,{size:r,className:p}),e[4]=r,e[5]=p,e[6]=s):s=e[6];let a;e[7]!==l?(a=ue("text-sm",l),e[7]=l,e[8]=a):a=e[8];let g;e[9]!==t||e[10]!==a?(g=n.jsx("span",{className:a,children:t}),e[9]=t,e[10]=a,e[11]=g):g=e[11];let c;return e[12]!==f||e[13]!==s||e[14]!==g?(c=n.jsxs("span",{className:f,children:[s,g]}),e[12]=f,e[13]=s,e[14]=g,e[15]=c):c=e[15],c}const Ht=be({propertyId:re().min(1,"Selecione uma propriedade")});function Wt(i){const e=H.c(68),{card:t,connectionId:o,companionClient:u,selfClient:d,org:l,onDone:r,onDisconnect:f,onIsPendingChange:p}=i;let s;e[0]!==o||e[1]!==l.id?(s=X.commerceDiscoveryCompanionGaProperties(l.id,o),e[0]=o,e[1]=l.id,e[2]=s):s=e[2];let a;e[3]!==u?(a=async()=>{const R=await u.callTool({name:"get-account-summaries",arguments:{}}),U=ee(R);return gt(U)},e[3]=u,e[4]=a):a=e[4];let g;e[5]!==s||e[6]!==a?(g={queryKey:s,queryFn:a},e[5]=s,e[6]=a,e[7]=g):g=e[7];const c=he(g);let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=Ce(Ht),e[8]=b):b=e[8];const C=t.configurationState?.propertyId||"";let h;e[9]!==C?(h={resolver:b,defaultValues:{propertyId:C}},e[9]=C,e[10]=h):h=e[10];const x=ye(h);let m;e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==d?(m={card:t,selfClient:d,org:l,onDone:r},e[11]=t,e[12]=r,e[13]=l,e[14]=d,e[15]=m):m=e[15];const{save:v,isPending:y,error:E}=Oe(m);let _,S;e[16]!==y||e[17]!==p?(_=()=>{p?.(y)},S=[y,p],e[16]=y,e[17]=p,e[18]=_,e[19]=S):(_=e[18],S=e[19]),Q.useEffect(_,S);let j;if(e[20]!==x||e[21]!==v){let R;e[23]!==v?(R=async U=>{v(U)},e[23]=v,e[24]=R):R=e[24],j=x.handleSubmit(R),e[20]=x,e[21]=v,e[22]=j}else j=e[22];const w=j;if(c.isLoading){let R;return e[25]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:n.jsx(De,{label:"Carregando propriedades..."})}),e[25]=R):R=e[25],R}if(c.isError){let R;return e[26]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-destructive",children:"Não foi possível carregar as propriedades do Google Analytics."})}),e[26]=R):R=e[26],R}let O;e[27]!==c.data?(O=c.data||[],e[27]=c.data,e[28]=O):O=e[28];const N=O;if(N.flatMap(Zt).length===0){let R;e[29]===Symbol.for("react.memo_cache_sentinel")?(R=n.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]=R):R=e[29];let U;e[30]!==f?(U=f?n.jsx("button",{type:"button",onClick:f,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive",children:"Desconectar conta"}):n.jsx("span",{}),e[30]=f,e[31]=U):U=e[31];let G;e[32]!==r?(G=n.jsx(Z,{type:"button",variant:"outline",onClick:r,children:"Fechar"}),e[32]=r,e[33]=G):G=e[33];let W;return e[34]!==U||e[35]!==G?(W=n.jsxs("div",{className:"space-y-4",children:[R,n.jsxs(pe,{className:"flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[U,G]})]}),e[34]=U,e[35]=G,e[36]=W):W=e[36],W}let T;e[37]!==y||e[38]!==N?(T=R=>{const{field:U}=R;return n.jsxs(le,{children:[n.jsx(ce,{children:n.jsx(Re,{options:N.flatMap(Yt),value:U.value,onChange:U.onChange,disabled:y,ariaLabel:"Propriedade do Google Analytics"})}),n.jsx(de,{})]})},e[37]=y,e[38]=N,e[39]=T):T=e[39];let L;e[40]!==x.control||e[41]!==T?(L=n.jsx(ae,{control:x.control,name:"propertyId",render:T}),e[40]=x.control,e[41]=T,e[42]=L):L=e[42];let $;e[43]!==x||e[44]!==L?($=n.jsx(je,{...x,children:L}),e[43]=x,e[44]=L,e[45]=$):$=e[45];let A;e[46]!==E?(A=E&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:E instanceof Error?E.message:"Não foi possível salvar a configuração"}),e[46]=E,e[47]=A):A=e[47];let q;e[48]!==y||e[49]!==f?(q=f?n.jsx("button",{type:"button",onClick:f,disabled:y,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive disabled:opacity-50",children:"Desconectar conta"}):n.jsx("span",{}),e[48]=y,e[49]=f,e[50]=q):q=e[50];let P;e[51]!==y||e[52]!==r?(P=n.jsx(Z,{type:"button",variant:"outline",onClick:r,disabled:y,children:"Cancelar"}),e[51]=y,e[52]=r,e[53]=P):P=e[53];const B=y?"Salvando...":"Salvar";let K;e[54]!==y||e[55]!==B?(K=n.jsx(Z,{type:"submit",disabled:y,children:B}),e[54]=y,e[55]=B,e[56]=K):K=e[56];let z;e[57]!==P||e[58]!==K?(z=n.jsxs("div",{className:"flex gap-2",children:[P,K]}),e[57]=P,e[58]=K,e[59]=z):z=e[59];let k;e[60]!==q||e[61]!==z?(k=n.jsxs(pe,{className:"flex-col gap-2 pt-4 sm:flex-row sm:items-center sm:justify-between",children:[q,z]}),e[60]=q,e[61]=z,e[62]=k):k=e[62];let F;return e[63]!==w||e[64]!==$||e[65]!==A||e[66]!==k?(F=n.jsxs("form",{onSubmit:w,className:"space-y-4",children:[$,A,k]}),e[63]=w,e[64]=$,e[65]=A,e[66]=k,e[67]=F):F=e[67],F}function Yt(i){return i.options}function Zt(i){return i.options}const Xt=i=>be({siteUrl:re().min(1,i("commerceOnboarding.googleSearchConsoleConfigForm.siteRequired"))});function Jt(i){const e=H.c(83),{card:t,connectionId:o,companionClient:u,selfClient:d,org:l,contextSiteUrl:r,onDone:f,onIsPendingChange:p}=i,s=te();let a;e[0]!==o||e[1]!==l.id?(a=X.commerceDiscoveryCompanionGscSites(l.id,o),e[0]=o,e[1]=l.id,e[2]=a):a=e[2];let g;e[3]!==u?(g=async()=>{const D=await u.callTool({name:"list_sites",arguments:{}});return ee(D).sites||[]},e[3]=u,e[4]=g):g=e[4];let c;e[5]!==a||e[6]!==g?(c={queryKey:a,queryFn:g},e[5]=a,e[6]=g,e[7]=c):c=e[7];const b=he(c);let C;e[8]!==s?(C=Ce(Xt(s)),e[8]=s,e[9]=C):C=e[9];const h=t.configurationState?.siteUrl||"";let x;e[10]!==h?(x={siteUrl:h},e[10]=h,e[11]=x):x=e[11];let m;e[12]!==C||e[13]!==x?(m={resolver:C,defaultValues:x},e[12]=C,e[13]=x,e[14]=m):m=e[14];const v=ye(m);let y;e[15]!==t||e[16]!==f||e[17]!==l||e[18]!==d?(y={card:t,selfClient:d,org:l,onDone:f},e[15]=t,e[16]=f,e[17]=l,e[18]=d,e[19]=y):y=e[19];const{save:E,isPending:_,error:S}=Oe(y),j=Q.useRef(!1),w=t.configurationState?.siteUrl;let O,N;e[20]!==_||e[21]!==p?(N=()=>{p?.(_)},O=[_,p],e[20]=_,e[21]=p,e[22]=O,e[23]=N):(O=e[22],N=e[23]),Q.useEffect(N,O);let I,T;e[24]!==r||e[25]!==v||e[26]!==w||e[27]!==b.data||e[28]!==b.isSuccess?(I=()=>{if(!(j.current||!b.isSuccess)){if(j.current=!0,w){v.getValues("siteUrl")!==w&&v.setValue("siteUrl",w);return}if(!v.getValues("siteUrl")){const D=ht(r,b.data??[]);D&&v.setValue("siteUrl",D)}}},T=[b.isSuccess,b.data,w,r,v],e[24]=r,e[25]=v,e[26]=w,e[27]=b.data,e[28]=b.isSuccess,e[29]=I,e[30]=T):(I=e[29],T=e[30]),Q.useEffect(I,T);let L;if(e[31]!==v||e[32]!==E){let D;e[34]!==E?(D=async M=>{E(M)},e[34]=E,e[35]=D):D=e[35],L=v.handleSubmit(D),e[31]=v,e[32]=E,e[33]=L}else L=e[33];const $=L;if(b.isLoading){let D;e[36]!==s?(D=s("commerceOnboarding.googleSearchConsoleConfigForm.loadingSites"),e[36]=s,e[37]=D):D=e[37];let M;return e[38]!==D?(M=n.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:n.jsx(De,{label:D})}),e[38]=D,e[39]=M):M=e[39],M}if(b.isError){let D;e[40]!==s?(D=s("commerceOnboarding.googleSearchConsoleConfigForm.loadSitesError"),e[40]=s,e[41]=D):D=e[41];let M;return e[42]!==D?(M=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-destructive",children:D})}),e[42]=D,e[43]=M):M=e[43],M}let A;e[44]!==b.data?(A=b.data||[],e[44]=b.data,e[45]=A):A=e[45];const q=A;if(q.length===0){let D;e[46]!==s?(D=s("commerceOnboarding.googleSearchConsoleConfigForm.noSitesFound"),e[46]=s,e[47]=D):D=e[47];let M;return e[48]!==D?(M=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:D})}),e[48]=D,e[49]=M):M=e[49],M}let P;e[50]!==_||e[51]!==q||e[52]!==s?(P=D=>{const{field:M}=D;return n.jsxs(le,{children:[n.jsx(ce,{children:n.jsx(Re,{options:q.map(en),value:M.value,onChange:M.onChange,disabled:_,ariaLabel:s("commerceOnboarding.googleSearchConsoleConfigForm.siteAriaLabel")})}),n.jsx(de,{})]})},e[50]=_,e[51]=q,e[52]=s,e[53]=P):P=e[53];let B;e[54]!==v.control||e[55]!==P?(B=n.jsx(ae,{control:v.control,name:"siteUrl",render:P}),e[54]=v.control,e[55]=P,e[56]=B):B=e[56];let K;e[57]!==v||e[58]!==B?(K=n.jsx(je,{...v,children:B}),e[57]=v,e[58]=B,e[59]=K):K=e[59];let z;e[60]!==S||e[61]!==s?(z=S&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:S instanceof Error?S.message:s("commerceOnboarding.googleSearchConsoleConfigForm.savingError")}),e[60]=S,e[61]=s,e[62]=z):z=e[62];let k;e[63]!==s?(k=s("commerceOnboarding.googleSearchConsoleConfigForm.cancelButton"),e[63]=s,e[64]=k):k=e[64];let F;e[65]!==_||e[66]!==f||e[67]!==k?(F=n.jsx(Z,{type:"button",variant:"outline",onClick:f,disabled:_,children:k}),e[65]=_,e[66]=f,e[67]=k,e[68]=F):F=e[68];let R;e[69]!==_||e[70]!==s?(R=s(_?"commerceOnboarding.googleSearchConsoleConfigForm.savingButton":"commerceOnboarding.googleSearchConsoleConfigForm.saveButton"),e[69]=_,e[70]=s,e[71]=R):R=e[71];let U;e[72]!==_||e[73]!==R?(U=n.jsx(Z,{type:"submit",disabled:_,children:R}),e[72]=_,e[73]=R,e[74]=U):U=e[74];let G;e[75]!==F||e[76]!==U?(G=n.jsxs(pe,{className:"pt-4",children:[F,U]}),e[75]=F,e[76]=U,e[77]=G):G=e[77];let W;return e[78]!==$||e[79]!==K||e[80]!==z||e[81]!==G?(W=n.jsxs("form",{onSubmit:$,className:"space-y-4",children:[K,z,G]}),e[78]=$,e[79]=K,e[80]=z,e[81]=G,e[82]=W):W=e[82],W}function en(i){return{value:i.siteUrl,label:i.siteUrl}}function tn(i){const[e,t]=i.split("/");return!e||!t?null:{owner:e,name:t}}function nn(i){const{existingRepo:e,owner:t,name:o}=i;return e?.connectionId&&e.owner.toLowerCase()===t.toLowerCase()&&e.name.toLowerCase()===o.toLowerCase()?{connectionId:e.connectionId,installationId:e.installationId}:null}function on(i){const{existingRepo:e,existingConnections:t,repoConnectionId:o}=i,u=e?.connectionId&&e.connectionId!==o?e.connectionId:void 0,d=[...t.filter(l=>l.connection_id!==o&&l.connection_id!==u),{connection_id:o,selected_tools:[]}];return{staleConnectionId:u,mergedConnections:d}}const sn=be({githubRepo:re().min(1,"commerceOnboarding.githubConfigForm.selectRepository")}),rn=15e3,an=/^[\w.-]+\/[\w.-]+$/;async function ln(i,e,t,o){const{installations:u}=await et(i,t),d=o.trim(),l=await Promise.allSettled(u.map(async s=>{const a=s.type==="User"?"user":"org",g=d?`${a}:${s.login} ${d} in:name`:`${a}:${s.login}`,b=await e.callTool({name:"search_repositories",arguments:{query:g,page:1,perPage:50}},void 0,{signal:AbortSignal.timeout(rn)}),C=b.content?.[0]?.text;if(b.isError)throw new Error(C??"search_repositories failed");if(!C)throw new Error("empty search_repositories response");return JSON.parse(C).items??[]})),r=new Map;let f=0;for(const s of l){if(s.status==="rejected"){f+=1;continue}for(const a of s.value)a.full_name&&!r.has(a.full_name)&&r.set(a.full_name,a)}return{repos:Array.from(r.values()).sort((s,a)=>(a.updated_at??"").localeCompare(s.updated_at??"")).map(s=>s.full_name),failed:f,total:u.length}}function cn({connectionId:i,companionClient:e,selfClient:t,org:o,onDone:u,onIsPendingChange:d}){const l=te(),r=ve(),f=Ve.COMMERCE_DISCOVERY(o.id),[p,s]=Q.useState(""),a=Tt(p,300),g=Q.useRef(!1),c=he({queryKey:X.commerceDiscoveryCompanionGithubSelected(o.id,i),queryFn:async()=>{const N=await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:f}}),I=ee(N).item?.configuration_state??null;return typeof I?.github_repo=="string"?I.github_repo:""}}),b=he({queryKey:X.commerceDiscoveryCompanionGithubRepos(o.id,i,a.trim()),queryFn:()=>ln(N=>t.callTool(N),e,i,a)}),C=ye({resolver:Ce(sn),defaultValues:{githubRepo:""}}),h=Ne({mutationFn:async N=>{const I=await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:f}}),L={...ee(I).item?.configuration_state??null??{},github_repo:N};await t.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:f,data:{configuration_state:L}}});const $=tn(N);if(!$)throw new Error(l("commerceOnboarding.githubConfigForm.invalidRepository",{repo:N}));const{owner:A,name:q}=$,P=ut(o.id),B=ee(await t.callTool({name:"COLLECTION_VIRTUAL_MCP_GET",arguments:{id:P}})).item,K=B?.metadata?.githubRepo,z=B?.connections??[],k=nn({existingRepo:K,owner:A,name:q});let F=k?.connectionId,R=k?.installationId,U;if(!F){const{installations:D}=await et(J=>t.callTool(J),i),M=Et(D,A);if(!M)throw new Error(l("commerceOnboarding.githubConfigForm.noGithubInstallation",{owner:A}));R=M.installationId;const se=ee(await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:i}})).item;if(!se)throw new Error(l("commerceOnboarding.githubConfigForm.githubConnectionNotFound"));const{childConnectionId:ne,reused:oe}=await It({orgSlug:o.slug,sourceConnection:se,installationId:R,owner:A,repo:q,githubCallTool:J=>e.callTool(J),selfCallTool:J=>t.callTool(J)});F=ne,U=oe?void 0:ne}const{staleConnectionId:G,mergedConnections:W}=on({existingRepo:K,existingConnections:z,repoConnectionId:F});try{if(await t.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:P,data:{connections:W,metadata:{githubRepo:{owner:A,name:q,url:`https://github.com/${N}`,installationId:R,connectionId:F}}}}}),G){const D=ee(await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:G}})).item;D&&!wt(D)&&await t.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:G,force:!0}}).catch(()=>{})}}catch(D){throw U&&await t.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:U,force:!0}}).catch(()=>{}),D}},onSuccess:async()=>{await r.invalidateQueries({queryKey:X.commerceDiscoveryConnection(o.id,f)}),await r.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(o.id)}),at(r,o.id),u()}}),x=h.isPending;Q.useEffect(()=>{d?.(x)},[x,d]);const m=c.data??"";Q.useEffect(()=>{!c.isSuccess||g.current||(g.current=!0,c.data&&C.setValue("githubRepo",c.data))},[c.isSuccess,c.data,C]);const v=C.handleSubmit(async N=>{h.mutate(N.githubRepo)}),y=b.data?.repos??[],E=b.data?.failed??0,_=b.data?.total??0,S=a.trim(),j=[...y];S&&an.test(S)&&!j.includes(S)&&j.unshift(S),m&&!j.includes(m)&&j.push(m);const w=_>0&&E===_,O=b.isError||w?l("commerceOnboarding.githubConfigForm.searchFailedTotal"):E>0?l("commerceOnboarding.githubConfigForm.searchFailedPartial"):null;return n.jsxs("form",{onSubmit:v,className:"space-y-4",children:[n.jsxs("div",{className:"relative",children:[n.jsx(Ze,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),n.jsx(ge,{type:"text",value:p,onChange:N=>s(N.target.value),disabled:x,placeholder:l("commerceOnboarding.githubConfigForm.searchRepositoryPlaceholder"),"aria-label":l("commerceOnboarding.githubConfigForm.searchRepositoryLabel"),className:"h-8 pl-8"})]}),b.isLoading?n.jsx("div",{className:"flex min-h-[160px] items-center justify-center",children:n.jsx(De,{label:l("commerceOnboarding.githubConfigForm.loadingRepositories")})}):n.jsxs(n.Fragment,{children:[O&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:O}),j.length===0?!O&&n.jsx("p",{className:"text-sm text-muted-foreground",children:l("commerceOnboarding.githubConfigForm.noRepositoriesFound")}):n.jsx(je,{...C,children:n.jsx(ae,{control:C.control,name:"githubRepo",render:({field:N})=>n.jsxs(le,{children:[n.jsx(ce,{children:n.jsx(Re,{options:j.map(I=>({value:I,label:I})),value:N.value,onChange:N.onChange,disabled:x,ariaLabel:"Repositório",hideSearch:!0})}),n.jsx(de,{})]})})})]}),h.error&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:h.error instanceof Error?h.error.message:l("commerceOnboarding.githubConfigForm.failedToSave")}),n.jsxs(pe,{className:"pt-4",children:[n.jsx(Z,{type:"button",variant:"outline",onClick:u,disabled:x,children:l("commerceOnboarding.githubConfigForm.cancel")}),n.jsx(Z,{type:"submit",disabled:x,children:l(x?"commerceOnboarding.githubConfigForm.saving":"commerceOnboarding.githubConfigForm.save")})]})]})}const dn={vtex:Vt,shopify:Mt,"google-analytics":Wt,"google-search-console":Jt,github:cn},xe="deco-reader@decocms.iam.gserviceaccount.com",st={"google-analytics":"ga4","google-search-console":"gsc"},it={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 mn(i,e){const t=it[i].label;switch(e){case"no-access":return{title:`Ainda não conseguimos acessar este recurso no ${t}.`,steps:i==="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:i==="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 un(i){const e=H.c(95),{provider:t,siteUrl:o,selfClient:u,org:d,initialResourceId:l,onDone:r,onIsPendingChange:f,onOAuthInstead:p}=i,s=te(),a=it[t],g=ve(),[c,b]=Q.useState(null);let C,h;if(e[0]!==a.resourceLabel||e[1]!==s){const Y=be({resourceId:re().trim().min(1,s("commerceOnboarding.saBindingForm.resourceIdRequired",{resourceLabel:a.resourceLabel.toLowerCase()}))});h=ye,C=Ce(Y),e[0]=a.resourceLabel,e[1]=s,e[2]=C,e[3]=h}else C=e[2],h=e[3];const x=l??"";let m;e[4]!==x?(m={resourceId:x},e[4]=x,e[5]=m):m=e[5];let v;e[6]!==C||e[7]!==m?(v={resolver:C,defaultValues:m},e[6]=C,e[7]=m,e[8]=v):v=e[8];const y=h(v);let E;e[9]!==t||e[10]!==u||e[11]!==o||e[12]!==s?(E=async Y=>{if(!o)throw new Error(s("commerceOnboarding.saBindingForm.storeUrlUnavailable"));const ie=await u.callTool({name:"COMMERCE_DISCOVERY_BIND",arguments:{siteUrl:o,provider:t,resourceId:Y.resourceId}});return ee(ie)},e[9]=t,e[10]=u,e[11]=o,e[12]=s,e[13]=E):E=e[13];let _,S;e[14]!==f?(_=()=>f?.(!0),S=()=>f?.(!1),e[14]=f,e[15]=_,e[16]=S):(_=e[15],S=e[16]);let j;e[17]!==a.label||e[18]!==r||e[19]!==d||e[20]!==t||e[21]!==g||e[22]!==o||e[23]!==s?(j=async Y=>{if(Y.ok){b(null),Se.success(s("commerceOnboarding.saBindingForm.connectedSuccess",{label:a.label})),o&&await g.invalidateQueries({queryKey:X.commerceDiscoveryConnectionStatus(d.id,o)}),r();return}b({...mn(t,Y.reason??"unknown"),detail:Y.detail})},e[17]=a.label,e[18]=r,e[19]=d,e[20]=t,e[21]=g,e[22]=o,e[23]=s,e[24]=j):j=e[24];let w;e[25]!==E||e[26]!==_||e[27]!==S||e[28]!==j?(w={mutationFn:E,onMutate:_,onSettled:S,onSuccess:j},e[25]=E,e[26]=_,e[27]=S,e[28]=j,e[29]=w):w=e[29];const O=Ne(w);let N;if(e[30]!==y||e[31]!==O){let Y;e[33]!==O?(Y=ie=>O.mutate(ie),e[33]=O,e[34]=Y):Y=e[34],N=y.handleSubmit(Y),e[30]=y,e[31]=O,e[32]=N}else N=e[32];const I=N,T=O.isPending;let L;e[35]!==s?(L=()=>{navigator.clipboard?.writeText(xe),Se.success(s("commerceOnboarding.saBindingForm.emailCopied"))},e[35]=s,e[36]=L):L=e[36];const $=L;let A;e[37]!==a.connectSteps?(A=a.connectSteps.map(pn),e[37]=a.connectSteps,e[38]=A):A=e[38];let q;e[39]!==A?(q=n.jsx("ol",{className:"space-y-2 text-sm text-muted-foreground",children:A}),e[39]=A,e[40]=q):q=e[40];let P;e[41]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx("code",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:xe}),e[41]=P):P=e[41];let B;e[42]!==s?(B=s("commerceOnboarding.saBindingForm.copyEmailLabel"),e[42]=s,e[43]=B):B=e[43];let K;e[44]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Je,{size:16}),e[44]=K):K=e[44];let z;e[45]!==$||e[46]!==B?(z=n.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted/40 p-2",children:[P,n.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",onClick:$,"aria-label":B,children:K})]}),e[45]=$,e[46]=B,e[47]=z):z=e[47];let k;e[48]!==a.resourceHint||e[49]!==a.resourceLabel||e[50]!==a.resourcePlaceholder||e[51]!==T?(k=Y=>{const{field:ie}=Y;return n.jsxs(le,{children:[n.jsx(fe,{children:a.resourceLabel}),n.jsx(ce,{children:n.jsx(ge,{...ie,placeholder:a.resourcePlaceholder,disabled:T,autoComplete:"off"})}),n.jsx(St,{children:a.resourceHint}),n.jsx(de,{})]})},e[48]=a.resourceHint,e[49]=a.resourceLabel,e[50]=a.resourcePlaceholder,e[51]=T,e[52]=k):k=e[52];let F;e[53]!==y.control||e[54]!==k?(F=n.jsx(ae,{control:y.control,name:"resourceId",render:k}),e[53]=y.control,e[54]=k,e[55]=F):F=e[55];let R;e[56]!==y||e[57]!==F?(R=n.jsx(je,{...y,children:F}),e[56]=y,e[57]=F,e[58]=R):R=e[58];let U;e[59]!==c?(U=c&&n.jsxs("div",{role:"alert",className:"space-y-2 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:c.title}),n.jsx("ol",{className:"space-y-1 text-sm text-muted-foreground",children:c.steps.map(fn)})]}),e[59]=c,e[60]=U):U=e[60];let G;e[61]!==O.error||e[62]!==O.isError||e[63]!==s?(G=O.isError&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:O.error instanceof Error?O.error.message:s("commerceOnboarding.saBindingForm.bindError")}),e[61]=O.error,e[62]=O.isError,e[63]=s,e[64]=G):G=e[64];let W;e[65]!==T||e[66]!==p||e[67]!==s?(W=p?n.jsx("button",{type:"button",onClick:p,disabled:T,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:opacity-50",children:s("commerceOnboarding.saBindingForm.googleLoginAlternative")}):n.jsx("span",{}),e[65]=T,e[66]=p,e[67]=s,e[68]=W):W=e[68];let D;e[69]!==s?(D=s("commerceOnboarding.saBindingForm.cancel"),e[69]=s,e[70]=D):D=e[70];let M;e[71]!==T||e[72]!==r||e[73]!==D?(M=n.jsx(Z,{type:"button",variant:"outline",onClick:r,disabled:T,children:D}),e[71]=T,e[72]=r,e[73]=D,e[74]=M):M=e[74];let se;e[75]!==T||e[76]!==s?(se=s(T?"commerceOnboarding.saBindingForm.verifying":"commerceOnboarding.saBindingForm.bind"),e[75]=T,e[76]=s,e[77]=se):se=e[77];let ne;e[78]!==T||e[79]!==se?(ne=n.jsx(Z,{type:"submit",disabled:T,children:se}),e[78]=T,e[79]=se,e[80]=ne):ne=e[80];let oe;e[81]!==M||e[82]!==ne?(oe=n.jsxs("div",{className:"flex gap-2",children:[M,ne]}),e[81]=M,e[82]=ne,e[83]=oe):oe=e[83];let J;e[84]!==W||e[85]!==oe?(J=n.jsxs(pe,{className:"flex-col gap-2 pt-2 sm:flex-row sm:items-center sm:justify-between",children:[W,oe]}),e[84]=W,e[85]=oe,e[86]=J):J=e[86];let V;return e[87]!==I||e[88]!==q||e[89]!==z||e[90]!==R||e[91]!==U||e[92]!==G||e[93]!==J?(V=n.jsxs("form",{onSubmit:I,className:"space-y-4",children:[q,z,R,U,G,J]}),e[87]=I,e[88]=q,e[89]=z,e[90]=R,e[91]=U,e[92]=G,e[93]=J,e[94]=V):V=e[94],V}function fn(i){return n.jsxs("li",{className:"flex gap-2",children:[n.jsx("span",{"aria-hidden":!0,children:"•"}),n.jsx("span",{children:i})]},i)}function pn(i,e){return n.jsxs("li",{className:"flex gap-2",children:[n.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}),n.jsx("span",{children:i})]},i)}function gn(){const i=H.c(2);let e;i[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-9 shrink-0 animate-pulse rounded-lg bg-muted/60"}),i[0]=e):e=i[0];let t;return i[1]===Symbol.for("react.memo_cache_sentinel")?(t=n.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border bg-card p-3 sm:h-full sm:flex-col sm:items-stretch sm:p-4",children:[e,n.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[n.jsx("div",{className:"h-4 w-24 animate-pulse rounded bg-muted/60"}),n.jsx("div",{className:"hidden h-3 w-full animate-pulse rounded bg-muted/60 sm:block"})]}),n.jsx("div",{className:"h-8 w-20 shrink-0 animate-pulse rounded-lg bg-muted/60 sm:mt-auto sm:w-full"})]}),i[1]=t):t=i[1],t}function Ue(i){const e=H.c(17),{title:t,disconnecting:o,disabled:u,onDisconnect:d}=i,l=te(),r=u||o;let f;e[0]!==l||e[1]!==t?(f=l("commerceOnboarding.companionCard.disconnectAriaLabel",{title:t}),e[0]=l,e[1]=t,e[2]=f):f=e[2];let p;e[3]!==o?(p=o?n.jsx(Ie,{size:16,className:"animate-spin"}):n.jsx(pt,{size:16}),e[3]=o,e[4]=p):p=e[4];let s;e[5]!==d||e[6]!==r||e[7]!==f||e[8]!==p?(s=n.jsx(Le,{asChild:!0,children:n.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:r,onClick:d,"aria-label":f,children:p})}),e[5]=d,e[6]=r,e[7]=f,e[8]=p,e[9]=s):s=e[9];let a;e[10]!==l?(a=l("commerceOnboarding.companionCard.disconnect"),e[10]=l,e[11]=a):a=e[11];let g;e[12]!==a?(g=n.jsx(Ae,{children:a}),e[12]=a,e[13]=g):g=e[13];let c;return e[14]!==s||e[15]!==g?(c=n.jsxs(ke,{children:[s,g]}),e[14]=s,e[15]=g,e[16]=c):c=e[16],c}function hn(i){const e=H.c(23),{card:t,connecting:o,disconnecting:u,disabled:d,onConnect:l,onDisconnect:r,org:f,selfClient:p,siteUrl:s,autoOpenConfigFieldKey:a,onAutoOpenConfigHandled:g}=i,c=t.linkedConnectionId,b=st[t.bindingType],C=!!b&&t.boundVia!=="oauth",h=t.satisfied&&!t.configured;let x;e[0]!==a||e[1]!==t||e[2]!==o||e[3]!==d||e[4]!==u||e[5]!==c||e[6]!==h||e[7]!==g||e[8]!==l||e[9]!==r||e[10]!==f||e[11]!==b||e[12]!==p||e[13]!==s||e[14]!==C?(x=C&&b?n.jsx(xn,{card:t,provider:b,org:f,selfClient:p,siteUrl:s,onOAuthInstead:l,disabled:d,connecting:o,primary:t.required}):t.satisfied&&c?h?n.jsxs("div",{className:"flex items-center justify-end gap-1 sm:justify-start",children:[n.jsx(Q.Suspense,{fallback:n.jsx(Be,{}),children:n.jsx(ze,{card:t,org:f,selfClient:p,connectionId:c,contextSiteUrl:s,variant:"configure",disabled:d,autoOpen:Ke({autoOpenFieldKey:a,card:t}),onAutoOpenHandled:g})}),n.jsx(Ue,{title:t.title,disconnecting:u,disabled:d,onDisconnect:r})]}):n.jsx(nt,{detail:t.connectedDetail,controls:n.jsxs(n.Fragment,{children:[n.jsx(Q.Suspense,{fallback:n.jsx(Be,{}),children:n.jsx(ze,{card:t,org:f,selfClient:p,connectionId:c,contextSiteUrl:s,variant:"gear",disabled:d,autoOpen:Ke({autoOpenFieldKey:a,card:t}),onAutoOpenHandled:g})}),n.jsx(Ue,{title:t.title,disconnecting:u,disabled:d,onDisconnect:r})]})}):n.jsx(tt,{connecting:o,disabled:d,title:t.title,primary:t.required,onConnect:l}),e[0]=a,e[1]=t,e[2]=o,e[3]=d,e[4]=u,e[5]=c,e[6]=h,e[7]=g,e[8]=l,e[9]=r,e[10]=f,e[11]=b,e[12]=p,e[13]=s,e[14]=C,e[15]=x):x=e[15];const m=x,v=t.required&&!t.satisfied;let y;return e[16]!==m||e[17]!==t.headline||e[18]!==t.icon||e[19]!==t.title||e[20]!==h||e[21]!==v?(y=n.jsx(Ut,{icon:t.icon,title:t.title,headline:t.headline,required:v,attention:h,action:m}),e[16]=m,e[17]=t.headline,e[18]=t.icon,e[19]=t.title,e[20]=h,e[21]=v,e[22]=y):y=e[22],y}function xn(i){const e=H.c(46),{card:t,provider:o,org:u,selfClient:d,siteUrl:l,onOAuthInstead:r,disabled:f,connecting:p,primary:s}=i,a=te(),[g,c]=Q.useState(!1),[b,C]=Q.useState(!1);let h;e[0]!==b?(h=A=>{!A&&b||c(A)},e[0]=b,e[1]=h):h=e[1];const x=h;let m;e[2]!==t.connectedDetail||e[3]!==t.satisfied||e[4]!==t.title||e[5]!==p||e[6]!==f||e[7]!==s||e[8]!==a?(m=t.satisfied?n.jsx(nt,{detail:t.connectedDetail,controls:n.jsxs(ke,{children:[n.jsx(Le,{asChild:!0,children:n.jsx(ot,{ariaLabel:a("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),onClick:()=>c(!0)})}),n.jsx(Ae,{children:a("commerceOnboarding.companionCard.editConfiguration")})]})}):n.jsx(tt,{connecting:p,disabled:f,title:t.title,primary:s,onConnect:()=>c(!0)}),e[2]=t.connectedDetail,e[3]=t.satisfied,e[4]=t.title,e[5]=p,e[6]=f,e[7]=s,e[8]=a,e[9]=m):m=e[9];let v;e[10]!==t.icon||e[11]!==t.title?(v=n.jsx(Fe,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[10]=t.icon,e[11]=t.title,e[12]=v):v=e[12];let y;e[13]!==t.title?(y=n.jsx(Ge,{children:t.title}),e[13]=t.title,e[14]=y):y=e[14];let E;e[15]!==a?(E=a("commerceOnboarding.companionCard.grantAccessDescription"),e[15]=a,e[16]=E):E=e[16];let _;e[17]!==E?(_=n.jsx(Me,{children:E}),e[17]=E,e[18]=_):_=e[18];let S;e[19]!==y||e[20]!==_?(S=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[y,_]}),e[19]=y,e[20]=_,e[21]=S):S=e[21];let j;e[22]!==v||e[23]!==S?(j=n.jsxs(Qe,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[v,S]}),e[22]=v,e[23]=S,e[24]=j):j=e[24];const w=t.boundResource??void 0;let O;e[25]===Symbol.for("react.memo_cache_sentinel")?(O=()=>c(!1),e[25]=O):O=e[25];let N;e[26]!==t.satisfied||e[27]!==r?(N=t.satisfied?void 0:()=>{c(!1),r()},e[26]=t.satisfied,e[27]=r,e[28]=N):N=e[28];let I;e[29]!==u||e[30]!==o||e[31]!==d||e[32]!==l||e[33]!==N||e[34]!==w?(I=n.jsx(un,{provider:o,siteUrl:l,selfClient:d,org:u,initialResourceId:w,onDone:O,onIsPendingChange:C,onOAuthInstead:N}),e[29]=u,e[30]=o,e[31]=d,e[32]=l,e[33]=N,e[34]=w,e[35]=I):I=e[35];let T;e[36]!==I||e[37]!==j?(T=n.jsxs(He,{className:"sm:max-w-lg",children:[j,I]}),e[36]=I,e[37]=j,e[38]=T):T=e[38];let L;e[39]!==x||e[40]!==g||e[41]!==T?(L=n.jsx(We,{open:g,onOpenChange:x,children:T}),e[39]=x,e[40]=g,e[41]=T,e[42]=L):L=e[42];let $;return e[43]!==L||e[44]!==m?($=n.jsxs(n.Fragment,{children:[m,L]}),e[43]=L,e[44]=m,e[45]=$):$=e[45],$}function Be(){const i=H.c(1);let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-8 shrink-0 animate-pulse rounded-lg bg-muted/60"}),i[0]=e):e=i[0],e}function ze(i){const e=H.c(71),{card:t,org:o,selfClient:u,connectionId:d,contextSiteUrl:l,variant:r,disabled:f,autoOpen:p,onAutoOpenHandled:s}=i,a=te();let g;e[0]!==d||e[1]!==o.id||e[2]!==o.slug?(g={connectionId:d,orgId:o.id,orgSlug:o.slug},e[0]=d,e[1]=o.id,e[2]=o.slug,e[3]=g):g=e[3];const c=we(g),[b,C]=Q.useState(p),[h,x]=Q.useState(!1),m=ve(),v=dn[t.bindingType];let y;e[4]!==t.configurationState?(y=xt(t.configurationState),e[4]=t.configurationState,e[5]=y):y=e[5];const E=y;let _;e[6]!==p||e[7]!==s?(_=()=>{C(!1),p&&s()},e[6]=p,e[7]=s,e[8]=_):_=e[8];const S=_;let j;e[9]!==S||e[10]!==h?(j=D=>{if(!(!D&&h)){if(!D){S();return}C(!0)}},e[9]=S,e[10]=h,e[11]=j):j=e[11];const w=j;let O;e[12]!==d||e[13]!==u?(O=async()=>{await u.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:d,force:!0}})},e[12]=d,e[13]=u,e[14]=O):O=e[14];let N;e[15]!==t.title||e[16]!==S||e[17]!==o.id||e[18]!==m||e[19]!==a?(N=async()=>{await m.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(o.id)}),Se.success(a("commerceOnboarding.companionCard.disconnectedSuccess",{title:t.title})),S()},e[15]=t.title,e[16]=S,e[17]=o.id,e[18]=m,e[19]=a,e[20]=N):N=e[20];let I;e[21]!==a?(I=()=>{Se.error(a("commerceOnboarding.companionCard.disconnectError"))},e[21]=a,e[22]=I):I=e[22];let T;e[23]!==O||e[24]!==N||e[25]!==I?(T={mutationFn:O,onSuccess:N,onError:I},e[23]=O,e[24]=N,e[25]=I,e[26]=T):T=e[26];const L=Ne(T);if(!v)return null;let $;e[27]!==t.title||e[28]!==f||e[29]!==E||e[30]!==a||e[31]!==r?($=r==="configure"?n.jsx(Bt,{disabled:f,title:t.title,onConfigure:()=>C(!0)}):n.jsxs(ke,{children:[n.jsx(Le,{asChild:!0,children:n.jsx(ot,{ariaLabel:a("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),onClick:()=>C(!0)})}),n.jsx(Ae,{children:E.length>0?a("commerceOnboarding.companionCard.editConfiguration"):a("commerceOnboarding.companionCard.configure")})]}),e[27]=t.title,e[28]=f,e[29]=E,e[30]=a,e[31]=r,e[32]=$):$=e[32];const A=$;let q;e[33]!==t.icon||e[34]!==t.title?(q=n.jsx(Fe,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[33]=t.icon,e[34]=t.title,e[35]=q):q=e[35];let P;e[36]!==t.title?(P=n.jsx(Ge,{children:t.title}),e[36]=t.title,e[37]=P):P=e[37];let B;e[38]!==t.title||e[39]!==a?(B=a("commerceOnboarding.companionCard.configureDescription",{title:t.title}),e[38]=t.title,e[39]=a,e[40]=B):B=e[40];let K;e[41]!==B?(K=n.jsx(Me,{children:B}),e[41]=B,e[42]=K):K=e[42];let z;e[43]!==P||e[44]!==K?(z=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[P,K]}),e[43]=P,e[44]=K,e[45]=z):z=e[45];let k;e[46]!==q||e[47]!==z?(k=n.jsxs(Qe,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[q,z]}),e[46]=q,e[47]=z,e[48]=k):k=e[48];let F;e[49]!==L?(F=()=>L.mutate(),e[49]=L,e[50]=F):F=e[50];let R;e[51]!==v||e[52]!==t||e[53]!==S||e[54]!==c||e[55]!==d||e[56]!==l||e[57]!==o||e[58]!==u||e[59]!==F?(R=n.jsx(v,{card:t,connectionId:d,companionClient:c,selfClient:u,org:o,contextSiteUrl:l,onDone:S,onDisconnect:F,onIsPendingChange:x}),e[51]=v,e[52]=t,e[53]=S,e[54]=c,e[55]=d,e[56]=l,e[57]=o,e[58]=u,e[59]=F,e[60]=R):R=e[60];let U;e[61]!==k||e[62]!==R?(U=n.jsxs(He,{className:"sm:max-w-lg",children:[k,R]}),e[61]=k,e[62]=R,e[63]=U):U=e[63];let G;e[64]!==b||e[65]!==w||e[66]!==U?(G=n.jsx(We,{open:b,onOpenChange:w,children:U}),e[64]=b,e[65]=w,e[66]=U,e[67]=G):G=e[67];let W;return e[68]!==G||e[69]!==A?(W=n.jsxs(n.Fragment,{children:[A,G]}),e[68]=G,e[69]=A,e[70]=W):W=e[70],W}const Pe={vtex:{registryAppId:"deco/vtex",area:"Catálogo",headline:"Rupturas e PDPs que travam suas vendas."},shopify:{registryAppId:"deco/shopify",area:"Catálogo",headline:"Pedidos, estoque e catálogo direto da sua Shopify."},"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 bn(i){const e=H.c(43),{selfClient:t,org:o,cdConnectionId:u,siteUrl:d}=i;let l;e[0]!==u||e[1]!==o.id||e[2]!==o.slug?(l={connectionId:u,orgId:o.id,orgSlug:o.slug},e[0]=u,e[1]=o.id,e[2]=o.slug,e[3]=l):l=e[3];const r=we(l);let f;e[4]!==u||e[5]!==o.id?(f=X.commerceDiscoveryCompanionSchema(o.id,u),e[4]=u,e[5]=o.id,e[6]=f):f=e[6];let p;e[7]!==r?(p=async()=>{const V=await r.callTool({name:"MCP_CONFIGURATION",arguments:{}});return ee(V)},e[7]=r,e[8]=p):p=e[8];let s;e[9]!==f||e[10]!==p?(s={queryKey:f,queryFn:p,retry:!1},e[9]=f,e[10]=p,e[11]=s):s=e[11];const a=he(s),g=a.data?.stateSchema?bt(a.data.stateSchema):null;let c;e[12]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},e[12]=c):c=e[12];const{shopify:b}=lt(c);let C;e[13]!==b?(C=V=>V.bindingType!=="shopify"||b!=null,e[13]=b,e[14]=C):C=e[14];const h=(g&&g.length>0?g:Ct).filter(C),x=h.map(En),m=h.map(Tn).filter(On),v=h.filter(Nn).map(_n),y=[...m,...v].sort().join(",");let E;e[15]!==u||e[16]!==o.id?(E=X.commerceDiscoveryConnection(o.id,u),e[15]=u,e[16]=o.id,e[17]=E):E=e[17];let _;e[18]!==u||e[19]!==t?(_=async()=>{const V=await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:u}});return ee(V)},e[18]=u,e[19]=t,e[20]=_):_=e[20];let S;e[21]!==E||e[22]!==_?(S={queryKey:E,queryFn:_},e[21]=E,e[22]=_,e[23]=S):S=e[23];const w=Te(S).data?.item?.configuration_state??null;let O;e[24]!==w?(O=V=>w?.[V.fieldKey]?.value,e[24]=w,e[25]=O):O=e[25];const N=h.map(O).filter(Sn),I=[...x.map(vn),...m.map(jn),...N.map(yn)].sort().join(","),L=Te({queryKey:X.commerceDiscoveryCompanionConnections(o.id,I),queryFn:async()=>{if(h.length===0)return{items:[]};const V=[{field:["app_name"],operator:"in",value:x},{field:["app_id"],operator:"in",value:m}];N.length>0&&V.push({field:["id"],operator:"in",value:N});const Y=await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{operator:"or",conditions:V},limit:1e3}});return ee(Y)}}).data?.items??[],$=new Set(N),A=L.filter(V=>$.has(V.id)),q=A.filter(Cn);let P;e[26]!==o.id||e[27]!==o.slug?(P=V=>({queryKey:X.commerceDiscoveryCompanionOAuthStatus(o.id,V.id),queryFn:async()=>{try{const Y=await fetch(`/api/${encodeURIComponent(o.slug)}/connections/${encodeURIComponent(V.id)}/oauth-token/status`,{credentials:"include"});return Y.ok?{hasToken:(await Y.json()).hasToken===!0}:{hasToken:!1}}catch{return{hasToken:!1}}},retry:!1}),e[26]=o.id,e[27]=o.slug,e[28]=P):P=e[28];const B=Rt({queries:q.map(P)});let K;e[29]!==B?(K=(V,Y)=>[V.id,B[Y]?.data?.hasToken===!0],e[29]=B,e[30]=K):K=e[30];const z=new Map(q.map(K)),k={};for(const V of A)k[V.id]=!V.oauth_config||!!V.connection_token||z.get(V.id)===!0;const F=Te({queryKey:X.commerceDiscoveryCompanionRegistry(o.id,y),queryFn:async()=>{if(h.length===0)return{items:[]};const V=yt(m,v),Y=await Ft(Ve.REGISTRY(o.id),o.id,o.slug,"COLLECTION_REGISTRY_APP_LIST",{...V?{where:V}:{},limit:1e3});return ee(Y)}}),R={},U={};for(const V of F.data?.items??[])R[V.id]=V,V.server?.name&&(U[V.server.name]=V);let G;e[31]!==o.id||e[32]!==d?(G=X.commerceDiscoveryConnectionStatus(o.id,d??""),e[31]=o.id,e[32]=d,e[33]=G):G=e[33];const W=!!d;let D;e[34]!==t||e[35]!==d?(D=async()=>{const V=await t.callTool({name:"COMMERCE_DISCOVERY_CONNECTION_STATUS",arguments:{siteUrl:d}});return ee(V)},e[34]=t,e[35]=d,e[36]=D):D=e[36];let M;e[37]!==G||e[38]!==W||e[39]!==D?(M={queryKey:G,enabled:W,queryFn:D},e[37]=G,e[38]=W,e[39]=D,e[40]=M):M=e[40];const se=he(M),ne={};for(const[V,Y]of Object.entries(st)){const ie=se.data?.providers?.[Y];ie?.connected&&ie.via==="sa"&&(ne[V]={resource:ie.resource??null})}const oe=jt({requirements:h,itemsById:R,itemsByName:U,connections:L,connectionReadiness:k,configurationState:w,curated:Pe,saBindings:ne});let J;return e[41]!==oe?(J={cards:oe},e[41]=oe,e[42]=J):J=e[42],J}function Cn(i){return i.oauth_config&&!i.connection_token}function yn(i){return`linked:${i}`}function jn(i){return`app:${i}`}function vn(i){return`binding:${i}`}function Sn(i){return typeof i=="string"&&i.length>0}function _n(i){return i.bindingType}function Nn(i){return!Pe[i.bindingType]}function On(i){return!!i}function Tn(i){return Pe[i.bindingType]?.registryAppId}function En(i){return i.bindingType}function In({selfClient:i,org:e,userId:t,cdConnectionId:o,domain:u,siteUrl:d}){const l=ve(),[r,f]=Q.useState(null),[p,s]=Q.useState(null),[a,g]=Q.useState(null),c=async(h,x)=>{const m=await i.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:h,data:x}});return ee(m)};async function b(h){f(h.fieldKey),g(null);const x={app_name:h.title,field_key:h.fieldKey,organization_id:e.id,domain:u,site_url:d};me("commerce_onboarding_companion_connect_clicked",x);try{let m=h.candidateConnectionId;if(!m){const j=kt(h.registryItem,e.id,t,{remoteIndex:0}),w=j.connection_type==="STDIO",O=!!j.connection_url,N=w&&j.connection_headers&&typeof j.connection_headers=="object"&&"command"in j.connection_headers;if(!O&&!N)return me("commerce_onboarding_companion_connect_failed",{...x,error:"no_connection_method"}),g(`${h.title} cannot be connected: no connection method available`),!1;const I=await i.callTool({name:"COLLECTION_CONNECTIONS_CREATE",arguments:{data:j}});m=ee(I).item.id}const v=m,y=await At({connectionId:v,orgId:e.id,orgSlug:e.slug,persistFallback:j=>c(v,{connection_token:j}).then(()=>{})});if(!y.ok)return me("commerce_onboarding_companion_connect_failed",{...x,error:y.error}),g(`Couldn't sign in to ${h.title}: ${y.error}`),!1;const E=await i.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),_=ee(E).item?.configuration_state??null,S=vt(_,h.fieldKey,h.bindingType,v);return h.bindingType==="github"&&delete S.github_repo,await c(o,{configuration_state:S}),await l.invalidateQueries({queryKey:X.commerceDiscoveryConnection(e.id,o)}),await l.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),me("commerce_onboarding_companion_connected",x),!0}catch(m){return me("commerce_onboarding_companion_connect_failed",{...x,error:m instanceof Error?m.message:String(m)}),g(m instanceof Error?m.message:String(m)),!1}finally{f(null)}}async function C(h){s(h.fieldKey),g(null);const x={app_name:h.title,field_key:h.fieldKey,organization_id:e.id,domain:u,site_url:d};me("commerce_onboarding_companion_disconnect_clicked",x);try{const m=await i.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),y={...ee(m).item?.configuration_state??null??{}};return delete y[h.fieldKey],h.bindingType==="github"&&delete y.github_repo,await c(o,{configuration_state:y}),await l.invalidateQueries({queryKey:X.commerceDiscoveryConnection(e.id,o)}),await l.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),me("commerce_onboarding_companion_disconnected",x),!0}catch(m){return me("commerce_onboarding_companion_disconnect_failed",{...x,error:m instanceof Error?m.message:String(m)}),g(m instanceof Error?m.message:String(m)),!1}finally{s(null)}}return{connect:b,connectingFieldKey:r,disconnect:C,disconnectingFieldKey:p,error:a}}const $e="flex min-h-0 flex-1 flex-col gap-6 md:grid md:flex-none md:gap-6";function qe(){const i=H.c(4),e=te();let t;i[0]!==e?(t=e("routes.commerceOnboarding.companionSection.title"),i[0]=e,i[1]=t):t=i[1];let o;return i[2]!==t?(o=n.jsx("h1",{className:"text-lg font-medium leading-6 text-foreground lg:text-xl lg:leading-7",children:t}),i[2]=t,i[3]=o):o=i[3],o}function wn(){const i=H.c(1);let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2,3].map(Fn)}),i[0]=e):e=i[0],e}function Fn(i){return n.jsx(gn,{},i)}function kn(){const i=H.c(1);let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:$e,children:[n.jsx(qe,{}),n.jsx(wn,{})]}),i[0]=e):e=i[0],e}function Ln(i){const e=H.c(18),{onRetry:t}=i,o=te();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(qe,{}),e[0]=u):u=e[0];let d;e[1]!==o?(d=o("routes.commerceOnboarding.companionSection.loadError"),e[1]=o,e[2]=d):d=e[2];let l;e[3]!==d?(l=n.jsx("p",{className:"text-sm text-foreground",children:d}),e[3]=d,e[4]=l):l=e[4];let r;e[5]!==o?(r=o("routes.commerceOnboarding.companionSection.loadErrorDescription"),e[5]=o,e[6]=r):r=e[6];let f;e[7]!==r?(f=n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r}),e[7]=r,e[8]=f):f=e[8];let p;e[9]!==o?(p=o("routes.commerceOnboarding.companionSection.retry"),e[9]=o,e[10]=p):p=e[10];let s;e[11]!==t||e[12]!==p?(s=n.jsx(Z,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:t,children:p}),e[11]=t,e[12]=p,e[13]=s):s=e[13];let a;return e[14]!==l||e[15]!==f||e[16]!==s?(a=n.jsxs("div",{className:$e,children:[u,n.jsxs("div",{role:"alert",className:"rounded-2xl border border-border bg-card p-4",children:[l,f,s]})]}),e[14]=l,e[15]=f,e[16]=s,e[17]=a):a=e[17],a}function ro(i){const e=H.c(2);let t;return e[0]!==i?(t=n.jsx(ct,{children:o=>{const{reset:u}=o;return n.jsx(dt,{fallback:d=>{const{resetError:l}=d;return n.jsx(Ln,{onRetry:()=>{u(),l()}})},children:n.jsx(Q.Suspense,{fallback:n.jsx(kn,{}),children:n.jsx(An,{...i})})})}}),e[0]=i,e[1]=t):t=e[1],t}function An(i){const e=H.c(53),{org:t,cdConnectionId:o,siteUrl:u,onReadinessChange:d}=i,{data:l}=mt.useSession(),r=l?.user?.id??"";let f;if(e[0]!==u){const P=u?_e(u):null;if(P?.ok)try{f=new URL(P.value).hostname}catch{f=void 0}e[0]=u,e[1]=f}else f=e[1];let p;e[2]!==t.id||e[3]!==t.slug?(p={connectionId:ft,orgId:t.id,orgSlug:t.slug},e[2]=t.id,e[3]=t.slug,e[4]=p):p=e[4];const s=we(p);let a;e[5]!==o||e[6]!==t||e[7]!==s||e[8]!==u?(a={selfClient:s,org:t,cdConnectionId:o,siteUrl:u},e[5]=o,e[6]=t,e[7]=s,e[8]=u,e[9]=a):a=e[9];const{cards:g}=bn(a);let c;e[10]!==o||e[11]!==t||e[12]!==s||e[13]!==f||e[14]!==u||e[15]!==r?(c={selfClient:s,org:t,userId:r,cdConnectionId:o,domain:f,siteUrl:u},e[10]=o,e[11]=t,e[12]=s,e[13]=f,e[14]=u,e[15]=r,e[16]=c):c=e[16];const{connect:b,connectingFieldKey:C,disconnect:h,disconnectingFieldKey:x,error:m}=In(c),[v,y]=Q.useState(null),E=Pn;let _,S,j,w,O,N,I,T,L;if(e[17]!==v||e[18]!==g||e[19]!==b||e[20]!==m||e[21]!==C||e[22]!==h||e[23]!==x||e[24]!==d||e[25]!==t||e[26]!==s||e[27]!==u){j=Symbol.for("react.early_return_sentinel");e:{const P=g.filter(Dn),B=g.filter(Rn),K=P.length>0?P.every(E):g.length===0||g.some(E);if(d?.(K),g.length===0){j=null;break e}const z=C!==null||x!==null,k=F=>{const R=async()=>{await b(F)&&y(F.fieldKey)};return n.jsx(hn,{card:F,connecting:C===F.fieldKey,disconnecting:x===F.fieldKey,disabled:z&&C!==F.fieldKey&&x!==F.fieldKey,org:t,selfClient:s,siteUrl:u,autoOpenConfigFieldKey:v,onAutoOpenConfigHandled:()=>y(U=>U===F.fieldKey?null:U),onConnect:()=>{R()},onDisconnect:()=>{h(F)}},F.fieldKey)};L=$e,e[37]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(qe,{}),e[37]=S):S=e[37],_=Kt,N="flex min-h-0 flex-1 flex-col md:block",I="-mx-1 min-h-0 flex-1 overflow-y-auto px-1 md:max-h-[min(60vh,calc(100dvh-330px))] md:flex-none",e[38]!==m?(T=m&&n.jsx("p",{role:"alert",className:"mb-3 text-sm text-destructive",children:m}),e[38]=m,e[39]=T):T=e[39],w="flex flex-col gap-4 pt-3",O=[...P,...B].map(k)}e[17]=v,e[18]=g,e[19]=b,e[20]=m,e[21]=C,e[22]=h,e[23]=x,e[24]=d,e[25]=t,e[26]=s,e[27]=u,e[28]=_,e[29]=S,e[30]=j,e[31]=w,e[32]=O,e[33]=N,e[34]=I,e[35]=T,e[36]=L}else _=e[28],S=e[29],j=e[30],w=e[31],O=e[32],N=e[33],I=e[34],T=e[35],L=e[36];if(j!==Symbol.for("react.early_return_sentinel"))return j;let $;e[40]!==w||e[41]!==O?($=n.jsx("div",{className:w,children:O}),e[40]=w,e[41]=O,e[42]=$):$=e[42];let A;e[43]!==_||e[44]!==$||e[45]!==N||e[46]!==I||e[47]!==T?(A=n.jsxs(_,{wrapperClassName:N,className:I,children:[T,$]}),e[43]=_,e[44]=$,e[45]=N,e[46]=I,e[47]=T,e[48]=A):A=e[48];let q;return e[49]!==S||e[50]!==A||e[51]!==L?(q=n.jsxs("div",{className:L,children:[S,A]}),e[49]=S,e[50]=A,e[51]=L,e[52]=q):q=e[52],q}function Rn(i){return!i.required}function Dn(i){return i.required}function Pn(i){return i.satisfied&&i.configured}function $n(i){return i.content?.find(e=>e.text)?.text??"A configuração do Commerce Discovery falhou."}function ao(i){const e=i;if(e.isError)throw new Error($n(e));return e.structuredContent??i}export{kn as C,De as L,Kt as S,ro as a,so as i,_e as n,ao as p,io as s};