decocms 4.125.2 → 4.125.4

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 (238) hide show
  1. package/dist/client/assets/{AlertCircle-DHfPbwmm.js → AlertCircle-CcEccjyR.js} +1 -1
  2. package/dist/client/assets/{AreaChart-D-FRclvq.js → AreaChart-AgjZ5gZj.js} +1 -1
  3. package/dist/client/assets/{ArrowRight-aoYnUAfi.js → ArrowRight-CIvdZA4z.js} +1 -1
  4. package/dist/client/assets/{ArrowUp-gaHL-JMD.js → ArrowUp-Cl5ZoO5X.js} +1 -1
  5. package/dist/client/assets/{ArrowUpRight-owfb6ER7.js → ArrowUpRight-CtNQ3e4k.js} +1 -1
  6. package/dist/client/assets/{Check-DIcuBCVN.js → Check-Dtxj2LqI.js} +1 -1
  7. package/dist/client/assets/{CheckCircle-C9FuklSy.js → CheckCircle-RrNMKG8e.js} +1 -1
  8. package/dist/client/assets/{ChevronDown-B9FSangp.js → ChevronDown-CmbEX7TO.js} +1 -1
  9. package/dist/client/assets/{ChevronRight-BZGq8ec4.js → ChevronRight-BMPkTrZg.js} +1 -1
  10. package/dist/client/assets/{ChevronUp-C8KS626_.js → ChevronUp-CbMsRw8r.js} +1 -1
  11. package/dist/client/assets/{Copy01-DscCSlQa.js → Copy01-CrbYaizo.js} +1 -1
  12. package/dist/client/assets/{DotsVertical-BrcjQf49.js → DotsVertical-BQlOCrVd.js} +1 -1
  13. package/dist/client/assets/{Eye-BfHBDYah.js → Eye-B54Urelq.js} +1 -1
  14. package/dist/client/assets/{FilterLines-CaezqqN6.js → FilterLines-Bg2EesIE.js} +1 -1
  15. package/dist/client/assets/{Globe01-B_-PRcJN.js → Globe01-DvpP_9Tj.js} +1 -1
  16. package/dist/client/assets/{Globe04-CnBEu-Tb.js → Globe04-BJXriPmE.js} +1 -1
  17. package/dist/client/assets/{HardDrive-D0rrQptf.js → HardDrive-BiaaVSII.js} +1 -1
  18. package/dist/client/assets/{Image01-BWs5Cl8W.js → Image01-CVurc-7j.js} +1 -1
  19. package/dist/client/assets/{Key01-meMXc90d.js → Key01-C6WNLK1y.js} +1 -1
  20. package/dist/client/assets/{LayoutLeft-d5DgJxpL.js → LayoutLeft-DBc5szPh.js} +1 -1
  21. package/dist/client/assets/{LinkExternal01-BWDB74Bl.js → LinkExternal01-DA5fHkBq.js} +1 -1
  22. package/dist/client/assets/{LogOut01-DsLUwoTk.js → LogOut01-CPDbdSAa.js} +1 -1
  23. package/dist/client/assets/{Monitor01-DdFs1Uqi.js → Monitor01-RFFbf_lJ.js} +1 -1
  24. package/dist/client/assets/{Package-DgWT9bDS.js → Package-ZpdKTTLo.js} +1 -1
  25. package/dist/client/assets/{Palette-DwuPeqfy.js → Palette-DgBARN1y.js} +1 -1
  26. package/dist/client/assets/{Play-C3OJLofP.js → Play-STtp48-H.js} +1 -1
  27. package/dist/client/assets/{Plus-BMGy0gLt.js → Plus-CFFRbGy1.js} +1 -1
  28. package/dist/client/assets/{SearchLg-Bvo_jSOD.js → SearchLg-C_yYdqOW.js} +1 -1
  29. package/dist/client/assets/{SearchMd-CwtuvWh8.js → SearchMd-M7FYAA0P.js} +1 -1
  30. package/dist/client/assets/{Settings02-B005Jn4G.js → Settings02-CNodVcr-.js} +1 -1
  31. package/dist/client/assets/{Shield01-BktOn7OY.js → Shield01-IbJbQ5vJ.js} +1 -1
  32. package/dist/client/assets/{Star01-COD8B803.js → Star01-CwcXpv8C.js} +1 -1
  33. package/dist/client/assets/{Stars01-DS-jsjsg.js → Stars01-BbfWZsBh.js} +1 -1
  34. package/dist/client/assets/{Stars02-Wk4f773E.js → Stars02-Bv_7kG37.js} +1 -1
  35. package/dist/client/assets/{Sun-DMi1PxWR.js → Sun-DBKNAp0W.js} +1 -1
  36. package/dist/client/assets/{SwitchHorizontal01-CQgBK8Zs.js → SwitchHorizontal01-TR00bSqI.js} +1 -1
  37. package/dist/client/assets/{Tool01-CMGcVT4l.js → Tool01-CMii7oS-.js} +1 -1
  38. package/dist/client/assets/{Tool02-Bg6EYrJZ.js → Tool02-DeuPSlN9.js} +1 -1
  39. package/dist/client/assets/{Trash01-DmDxDqMT.js → Trash01-C2hx9ILk.js} +1 -1
  40. package/dist/client/assets/{TrendUp01-cVD_6pKi.js → TrendUp01-DQtnnEXy.js} +1 -1
  41. package/dist/client/assets/{Upload01-B7Wisg2m.js → Upload01-U7-rI-ck.js} +1 -1
  42. package/dist/client/assets/{User01-CrrDrMtl.js → User01-BLKyUfT3.js} +1 -1
  43. package/dist/client/assets/{Users01-B8Zwqemn.js → Users01-C7iZpwSr.js} +1 -1
  44. package/dist/client/assets/{Users03-CHFYRzMp.js → Users03-C6dcgEIV.js} +1 -1
  45. package/dist/client/assets/{X-kbNEvIkE.js → X-Dhe81Wdu.js} +1 -1
  46. package/dist/client/assets/{XCircle-Bau-QYHG.js → XCircle-DSQd18dF.js} +1 -1
  47. package/dist/client/assets/{XClose-CiEZ9Mmp.js → XClose-Gc4IGtK8.js} +1 -1
  48. package/dist/client/assets/{Zap-COQSXbiz.js → Zap-C3MztcL3.js} +1 -1
  49. package/dist/client/assets/{ZapSquare-CWc873Is.js → ZapSquare-TENV_B5W.js} +1 -1
  50. package/dist/client/assets/{ZoomOut-BzQ5KRW5.js → ZoomOut-B0AzMjEL.js} +1 -1
  51. package/dist/client/assets/{access-gate-BvtsfB8K.js → access-gate-Xa3X5DkS.js} +1 -1
  52. package/dist/client/assets/{add-section-modal-CjPlnHD2.js → add-section-modal-DkdlGTuU.js} +1 -1
  53. package/dist/client/assets/{agent-icon-Bu8L0YTs.js → agent-icon-YL1kb16c.js} +1 -1
  54. package/dist/client/assets/{agents-list-CcBRMCSX.js → agents-list-HxHsxCYR.js} +1 -1
  55. package/dist/client/assets/{ai-providers-Be8br1vH.js → ai-providers-B_yK3yU2.js} +1 -1
  56. package/dist/client/assets/{alert-HFyMw3-6.js → alert-Bl2sP6Du.js} +1 -1
  57. package/dist/client/assets/{alert-dialog-CBCn_UdL.js → alert-dialog-CxVEix6v.js} +1 -1
  58. package/dist/client/assets/{app-editor-B1reldMi.js → app-editor-DbCGGmtw.js} +1 -1
  59. package/dist/client/assets/{auth-Bprl3x_3.js → auth-C_-JQU23.js} +1 -1
  60. package/dist/client/assets/{auth-catchall-Cy7UrKhy.js → auth-catchall-DSTgood7.js} +1 -1
  61. package/dist/client/assets/{auth-entry-CNLeBO8A.js → auth-entry-BLFpDUaC.js} +1 -1
  62. package/dist/client/assets/{auth-split-layout-DRCdjhs2.js → auth-split-layout-Bfu3olQQ.js} +1 -1
  63. package/dist/client/assets/{authenticate-and-persist-oauth-CRUUJSOy.js → authenticate-and-persist-oauth-DhuBe7ww.js} +1 -1
  64. package/dist/client/assets/{automation-list-row-Cr4wP_05.js → automation-list-row-zneRke1f.js} +1 -1
  65. package/dist/client/assets/{automation-runs-Cbng2BoT.js → automation-runs-Bho-sJ6z.js} +1 -1
  66. package/dist/client/assets/{automations-GVbUrn5l.js → automations-3Z7_Rkoa.js} +1 -1
  67. package/dist/client/assets/{autosend-DzUEXq6j.js → autosend-thPIzBxM.js} +1 -1
  68. package/dist/client/assets/{avatar-Dei6fpXi.js → avatar-BO5Wc4n9.js} +1 -1
  69. package/dist/client/assets/{badge-Cmfr9I7J.js → badge-DazAmAwT.js} +1 -1
  70. package/dist/client/assets/{block-document-DIN2deJy.js → block-document-BQvvwKKu.js} +1 -1
  71. package/dist/client/assets/{brand-context-h5RiCjnq.js → brand-context-DzBl90-7.js} +1 -1
  72. package/dist/client/assets/{buckets-Dp3vPQTS.js → buckets-at0x4cUN.js} +1 -1
  73. package/dist/client/assets/{bulk-category-panel-B1Gi9wUq.js → bulk-category-panel-CGUgYVmB.js} +1 -1
  74. package/dist/client/assets/{calendar-DHty8QJT.js → calendar-Y3PksDYj.js} +1 -1
  75. package/dist/client/assets/{capability-load-error-CXxQs63z.js → capability-load-error-Dq-Oox-R.js} +1 -1
  76. package/dist/client/assets/{card-CaGEmByP.js → card-H6G2Nfkp.js} +1 -1
  77. package/dist/client/assets/{category-editor-s0kMzuKL.js → category-editor-CrQf1odc.js} +1 -1
  78. package/dist/client/assets/{chat-context-DRXtbNYB.js → chat-context-iX4Jxrz0.js} +1 -1
  79. package/dist/client/assets/{checkbox-DgJA_ceb.js → checkbox-gnfMT4MD.js} +1 -1
  80. package/dist/client/assets/{cli-auth-success-SqN0HJI8.js → cli-auth-success-Cy3hxziI.js} +1 -1
  81. package/dist/client/assets/{collection-detail-DjW1_lm1.js → collection-detail-CVhNfEsm.js} +1 -1
  82. package/dist/client/assets/{collection-display-button-WGf1YkR8.js → collection-display-button-CDLftXPf.js} +1 -1
  83. package/dist/client/assets/{collection-search-v6k7-ns_.js → collection-search--Swyfisl.js} +1 -1
  84. package/dist/client/assets/{collection-table-wrapper-jxnyW-o6.js → collection-table-wrapper-I_C9IggN.js} +1 -1
  85. package/dist/client/assets/{collection-tabs-BOJ9WXu0.js → collection-tabs-DSfR42wG.js} +1 -1
  86. package/dist/client/assets/{command-Dh8_6SVl.js → command-DAultwG_.js} +1 -1
  87. package/dist/client/assets/{commerce-onboarding-CSi5e0YX.js → commerce-onboarding-UB8LycDN.js} +1 -1
  88. package/dist/client/assets/{companions-core-BSh9cT1E.js → companions-core-DdICjmDQ.js} +1 -1
  89. package/dist/client/assets/{connect-ClEEolrx.js → connect-7IqT1Cpx.js} +1 -1
  90. package/dist/client/assets/{connect-desktop-dialog-C0flGaQ_.js → connect-desktop-dialog-B9RKlJWt.js} +1 -1
  91. package/dist/client/assets/{connection-CauRFt6W.js → connection-Ht_jMY9L.js} +1 -1
  92. package/dist/client/assets/{connection-card-CeYmR-Cx.js → connection-card-Cls8iolX.js} +1 -1
  93. package/dist/client/assets/{connection-detail-_7qtrH4B.js → connection-detail-DR_dYVlj.js} +1 -1
  94. package/dist/client/assets/{connection-form-helpers-7iwRsPVv.js → connection-form-helpers-Db84FxyM.js} +1 -1
  95. package/dist/client/assets/{connections-ZhIMcHMb.js → connections-Z-Uo5Otf.js} +1 -1
  96. package/dist/client/assets/{decopilot-sse-pool-DaQqKB35.js → decopilot-sse-pool-B-5wI-Pj.js} +1 -1
  97. package/dist/client/assets/{dialog-G4ZiTvNx.js → dialog-DbscGgzF.js} +1 -1
  98. package/dist/client/assets/{domain-settings-CweuNubx.js → domain-settings-BnXSBVAJ.js} +1 -1
  99. package/dist/client/assets/{drawer-B75YbbdI.js → drawer-CgYedQxa.js} +1 -1
  100. package/dist/client/assets/{dropdown-menu-Ds67TSY4.js → dropdown-menu-CeCH8mHs.js} +1 -1
  101. package/dist/client/assets/{empty-state-Bta4YdzD.js → empty-state-DAsFsCjC.js} +1 -1
  102. package/dist/client/assets/{extract-connection-data-DgxJXS5w.js → extract-connection-data-Cl4dh9xd.js} +1 -1
  103. package/dist/client/assets/{file-explorer-B6MpksVl.js → file-explorer-CiRzlp-h.js} +1 -1
  104. package/dist/client/assets/{file-type-icon-BBhjyJbf.js → file-type-icon-B8g6dwx7.js} +1 -1
  105. package/dist/client/assets/{files-BIEklIkn.js → files-CnjpT0R-.js} +1 -1
  106. package/dist/client/assets/{form-I0GnjsKQ.js → form-lIcpVZFF.js} +1 -1
  107. package/dist/client/assets/{general-5tGulC2H.js → general-vSTi4cVP.js} +1 -1
  108. package/dist/client/assets/{github-repo-picker-C_zm2Ku6.js → github-repo-picker-BVbTQpq7.js} +1 -1
  109. package/dist/client/assets/{hooks-eTDNg0DR.js → hooks-_8e3OS-G.js} +1 -1
  110. package/dist/client/assets/{index-4RDnlua4.js → index-BEXD6JvL.js} +3 -3
  111. package/dist/client/assets/{index-BymC5LN8.js → index-Br5AUhF4.js} +1 -1
  112. package/dist/client/assets/{index-BN2uaF1T.js → index-CI-X-coD.js} +1 -1
  113. package/dist/client/assets/{index-GeOcC1AM.js → index-CM26Hgr_.js} +1 -1
  114. package/dist/client/assets/{index-Dhdk7EaJ.js → index-D4ObZSJy.js} +1 -1
  115. package/dist/client/assets/{index-BA_hCyLd.js → index-D91ZWx7L.js} +1 -1
  116. package/dist/client/assets/{index-DK_1_-so.js → index-DT5-MRJP.js} +1 -1
  117. package/dist/client/assets/index-Da4BCXs_.js +492 -0
  118. package/dist/client/assets/{index-DNyFrsaH.js → index-Dc3KWP0e.js} +1 -1
  119. package/dist/client/assets/{index-X6AHLbER.js → index-FSK7xtRq.js} +1 -1
  120. package/dist/client/assets/{index-D_e-AGWz.js → index-Wzf1qPRS.js} +1 -1
  121. package/dist/client/assets/{index-BuUlXZv1.js → index-gmik0o6w.js} +3 -3
  122. package/dist/client/assets/{index-redirect-BdqCP6LK.js → index-redirect-M_9QM-r9.js} +1 -1
  123. package/dist/client/assets/{index-D8aJMO1V.js → index-vLuRCk4y.js} +1 -1
  124. package/dist/client/assets/{input-DLUPJjpz.js → input-DXLjV8Um.js} +1 -1
  125. package/dist/client/assets/{integration-icon-DPwYpZT7.js → integration-icon-CJcVQIei.js} +1 -1
  126. package/dist/client/assets/{invite-member-dialog-DWZsYH7X.js → invite-member-dialog-u3fd21RJ.js} +1 -1
  127. package/dist/client/assets/{label-DUcYIAKY.js → label-CGDy7d8-.js} +1 -1
  128. package/dist/client/assets/{layout-B8T6EBXg.js → layout-DcyzuCIZ.js} +1 -1
  129. package/dist/client/assets/{login-DcZyKofL.js → login-CiW0YOXS.js} +1 -1
  130. package/dist/client/assets/{mcp-oauth-Dci8cSOd.js → mcp-oauth-Duli9hv5.js} +1 -1
  131. package/dist/client/assets/{members-BbTqeuTo.js → members-SQPRtGL7.js} +1 -1
  132. package/dist/client/assets/{monaco-editor-dTalnsYm.js → monaco-editor-BPPf6Luv.js} +1 -1
  133. package/dist/client/assets/{monitoring-stats-row-C1tE-n8d.js → monitoring-stats-row-8yQYcsLQ.js} +1 -1
  134. package/dist/client/assets/{multi-select-Cfgtgcax.js → multi-select-DEwOPq6i.js} +1 -1
  135. package/dist/client/assets/{oauth-callback-CdS7aTBF.js → oauth-callback-ButMd6DX.js} +1 -1
  136. package/dist/client/assets/{oauth-callback-ai-provider-CVxXEEWb.js → oauth-callback-ai-provider-DMZsKWRb.js} +1 -1
  137. package/dist/client/assets/{onboarding-6atU8fxu.js → onboarding-Pumdn1JU.js} +1 -1
  138. package/dist/client/assets/{org-install-BgWInxM1.js → org-install-CKF4FJd8.js} +1 -1
  139. package/dist/client/assets/{org-layout-CPBhzMru.js → org-layout-DvGPuBEh.js} +1 -1
  140. package/dist/client/assets/{organization-choice-BSaRjkdA.js → organization-choice-HvVcf-TI.js} +1 -1
  141. package/dist/client/assets/{orgs-DGzKd1EY.js → orgs-CvAcVFcq.js} +1 -1
  142. package/dist/client/assets/{page-seo-form-C-18bHzi.js → page-seo-form-DsKqt7Mm.js} +1 -1
  143. package/dist/client/assets/page-seo-sheet-BqaIHzT5.js +1 -0
  144. package/dist/client/assets/{popover-CgLqhHGP.js → popover-CTKO_kAN.js} +1 -1
  145. package/dist/client/assets/{post-editor-BaU667xO.js → post-editor-KlaAUuAS.js} +1 -1
  146. package/dist/client/assets/{primitives-CXNB8gAp.js → primitives-DsAtm5DL.js} +1 -1
  147. package/dist/client/assets/{profile-CtYiW70i.js → profile-02e5od0Q.js} +1 -1
  148. package/dist/client/assets/project-app-view-DggJEflp.js +1 -0
  149. package/dist/client/assets/record-editor-C2akOqoh.js +1 -0
  150. package/dist/client/assets/{redirect-editor-fK_i-XfS.js → redirect-editor-CsPzi8vr.js} +1 -1
  151. package/dist/client/assets/registry-CycJdV8D.js +2 -0
  152. package/dist/client/assets/{registry-layout-CzJnSkGi.js → registry-layout-CyFCUeE2.js} +1 -1
  153. package/dist/client/assets/{reports-BLso3NNn.js → reports-BsiX4_A6.js} +1 -1
  154. package/dist/client/assets/{require-capability-DJUF6EfI.js → require-capability-BZBVRkKd.js} +1 -1
  155. package/dist/client/assets/{required-auth-layout-CY6VIKkl.js → required-auth-layout-DD8XtcaG.js} +1 -1
  156. package/dist/client/assets/{reset-password-DDDOBPpI.js → reset-password-DTbRcUEl.js} +1 -1
  157. package/dist/client/assets/{roles-DiP4REKC.js → roles-DWH92L6e.js} +1 -1
  158. package/dist/client/assets/{search-input-DOMBq2Er.js → search-input-DZJIbmEn.js} +1 -1
  159. package/dist/client/assets/{secrets-DPYYlx9C.js → secrets-iSLNts2L.js} +1 -1
  160. package/dist/client/assets/sections-editor-Ds-TbaCj.js +2 -0
  161. package/dist/client/assets/{select-BCZLKjJN.js → select-CLa8-PWY.js} +1 -1
  162. package/dist/client/assets/{select-model-CFjdb8F4.js → select-model-DAC8p6XP.js} +1 -1
  163. package/dist/client/assets/{self-tool-result-DeCekO3f.js → self-tool-result-CoHAZ64x.js} +1 -1
  164. package/dist/client/assets/{seo-editor-C_DByLik.js → seo-editor-CzofNAOf.js} +1 -1
  165. package/dist/client/assets/{settings-layout-qfgj2V21.js → settings-layout-qfCiQQJZ.js} +1 -1
  166. package/dist/client/assets/{settings-section-CWj3_FdW.js → settings-section-NxvA_-hs.js} +1 -1
  167. package/dist/client/assets/{shell-controls-sgm1Ghqr.js → shell-controls-th4EsEqc.js} +1 -1
  168. package/dist/client/assets/{shell-layout-A4Klwqzt.js → shell-layout-D1tmT8P_.js} +1 -1
  169. package/dist/client/assets/{sidebar-BZQNMiqx.js → sidebar-D5TYZm99.js} +1 -1
  170. package/dist/client/assets/{skeleton-CXG2AFFX.js → skeleton-Cgx6QdQo.js} +1 -1
  171. package/dist/client/assets/{sso-tXM51xor.js → sso-elKwCqJL.js} +1 -1
  172. package/dist/client/assets/{store-D6KLtEh2.js → store-C9qtasId.js} +1 -1
  173. package/dist/client/assets/store-registry-qKWBJ2vv.js +2 -0
  174. package/dist/client/assets/{studio-tools-BanQp4TZ.js → studio-tools-DyoqIWNE.js} +1 -1
  175. package/dist/client/assets/{switch-DHbzmpde.js → switch-fvndlG7e.js} +1 -1
  176. package/dist/client/assets/{table-wjz_t519.js → table-DRnpojDN.js} +1 -1
  177. package/dist/client/assets/{tabs-BrQ8T12Z.js → tabs-xY2VRpIZ.js} +1 -1
  178. package/dist/client/assets/{textarea-yNbPp_V1.js → textarea-gc-qoQMu.js} +1 -1
  179. package/dist/client/assets/{toggle-group-BLBd1Na5.js → toggle-group-Bno-nFB9.js} +1 -1
  180. package/dist/client/assets/{toolbar-Cge5lcNV.js → toolbar-Bke6Fzcp.js} +1 -1
  181. package/dist/client/assets/{toolbar-icon-button-CWELZhBo.js → toolbar-icon-button-Et9eR2aL.js} +1 -1
  182. package/dist/client/assets/{tooltip-B8bYd-9r.js → tooltip-KLVUr9oF.js} +1 -1
  183. package/dist/client/assets/{use-ai-providers-S5QPPawK.js → use-ai-providers-CqOtTqY0.js} +1 -1
  184. package/dist/client/assets/{use-api-keys-Cl5n0LhD.js → use-api-keys-D4BBtvYl.js} +1 -1
  185. package/dist/client/assets/{use-automations-Du6nHRym.js → use-automations-CdTtxiWz.js} +1 -1
  186. package/dist/client/assets/{use-autosave-BDYAiYhJ.js → use-autosave-CFeMUg5v.js} +1 -1
  187. package/dist/client/assets/{use-capability-BiwL5b_x.js → use-capability-BmQ3xCyH.js} +1 -1
  188. package/dist/client/assets/{use-clock-tick-7IVs3KNJ.js → use-clock-tick-BfRCrtO9.js} +1 -1
  189. package/dist/client/assets/{use-connection-I-DnXuJH.js → use-connection-dGy3F3wj.js} +1 -1
  190. package/dist/client/assets/{use-copy-DTsOKQvO.js → use-copy-BrN5lHME.js} +1 -1
  191. package/dist/client/assets/{use-create-virtual-mcp-dWUtRtkr.js → use-create-virtual-mcp-DrGosIDu.js} +1 -1
  192. package/dist/client/assets/{use-debounced-autosave-BMOZjMIM.js → use-debounced-autosave-ChsIDO4V.js} +1 -1
  193. package/dist/client/assets/{use-debounced-value-DZJqrsuG.js → use-debounced-value-ChB_kdik.js} +1 -1
  194. package/dist/client/assets/{use-deco-credits-UyEP8mkX.js → use-deco-credits-IXGN3Pz9.js} +1 -1
  195. package/dist/client/assets/{use-decopilot-events-BNKUFs1m.js → use-decopilot-events-KHFtAPDT.js} +1 -1
  196. package/dist/client/assets/{use-delete-connection-CLvEM5JF.js → use-delete-connection-x1F-j9n0.js} +1 -1
  197. package/dist/client/assets/{use-deployment-admin-D40uSnVH.js → use-deployment-admin-B4nkRKp4.js} +1 -1
  198. package/dist/client/assets/{use-file-configs-Da4n5Wk_.js → use-file-configs-BV5YdGD9.js} +1 -1
  199. package/dist/client/assets/{use-infinite-scroll-CjI765bv.js → use-infinite-scroll-IFVHS84q.js} +1 -1
  200. package/dist/client/assets/{use-join-requests-_EoYHc02.js → use-join-requests-BA1q1NSK.js} +1 -1
  201. package/dist/client/assets/{use-mcp-auth-status-Cprl0lqq.js → use-mcp-auth-status-Ck13L_Ss.js} +1 -1
  202. package/dist/client/assets/{use-mcp-client-Dggs_wtL.js → use-mcp-client-GDLFUrdz.js} +1 -1
  203. package/dist/client/assets/{use-mcp-tools-BZb2_KlI.js → use-mcp-tools-Cg6-dfhh.js} +1 -1
  204. package/dist/client/assets/{use-members-DTLixo_2.js → use-members-Cc4x2yPK.js} +1 -1
  205. package/dist/client/assets/{use-mobile-D_MHSYLt.js → use-mobile-Cug5-uN5.js} +1 -1
  206. package/dist/client/assets/{use-navigate-to-agent-D8r2um29.js → use-navigate-to-agent-BnAEkEIp.js} +1 -1
  207. package/dist/client/assets/{use-org-auth-client-D8JQ0qMm.js → use-org-auth-client-sPgvD3p2.js} +1 -1
  208. package/dist/client/assets/{use-org-sso-BsOWFttQ.js → use-org-sso-lyDWnw-r.js} +1 -1
  209. package/dist/client/assets/{use-organization-roles-BsjAqShS.js → use-organization-roles-D3oaZ9VC.js} +1 -1
  210. package/dist/client/assets/{use-organization-settings-Cfo4apco.js → use-organization-settings-BImkcQCH.js} +1 -1
  211. package/dist/client/assets/{use-registry-app-Ccw5Zgoa.js → use-registry-app-C2Ie4sAT.js} +1 -1
  212. package/dist/client/assets/{use-registry-connections-DL4Qbjni.js → use-registry-connections-CVB4if3f.js} +1 -1
  213. package/dist/client/assets/{use-secrets-CGKvz62m.js → use-secrets-Du9rEkxB.js} +1 -1
  214. package/dist/client/assets/{use-status-sounds-CAtTty8v.js → use-status-sounds-BFAveT77.js} +1 -1
  215. package/dist/client/assets/{use-view-mode-Butv57c-.js → use-view-mode-D_85DX2w.js} +1 -1
  216. package/dist/client/assets/{use-virtual-mcp-DcKgvXvy.js → use-virtual-mcp-BdH1VOY_.js} +1 -1
  217. package/dist/client/assets/useInfiniteQuery-CEXGRrO5.js +1 -0
  218. package/dist/client/assets/{useQueries-CCY8hrOc.js → useQueries-BW-x5W-N.js} +1 -1
  219. package/dist/client/assets/{useRouterState-BmgvsVqw.js → useRouterState-CFmvF0_D.js} +1 -1
  220. package/dist/client/assets/useSuspenseInfiniteQuery-WzpGimQB.js +1 -0
  221. package/dist/client/assets/{users-BrpQL4K3.js → users-Bur9O3Nn.js} +1 -1
  222. package/dist/client/assets/{variant-calendar-DqtEssYW.js → variant-calendar-DkkuOf3a.js} +1 -1
  223. package/dist/client/assets/view-mode-toggle-CK_9GHTo.js +1 -0
  224. package/dist/client/index.html +1 -1
  225. package/dist/server/cli.js +440 -441
  226. package/dist/server/migrate.js +5 -5
  227. package/dist/server/server.js +253 -253
  228. package/package.json +1 -1
  229. package/dist/client/assets/index-9mX7itVS.js +0 -492
  230. package/dist/client/assets/page-seo-sheet-Cq6MSxcj.js +0 -1
  231. package/dist/client/assets/project-app-view-B-ZNnyXW.js +0 -1
  232. package/dist/client/assets/record-editor-CyFKknlv.js +0 -1
  233. package/dist/client/assets/registry-vH1Mc4gB.js +0 -2
  234. package/dist/client/assets/sections-editor-CK1krdST.js +0 -2
  235. package/dist/client/assets/store-registry-DEiSeyxl.js +0 -2
  236. package/dist/client/assets/useInfiniteQuery-BkEklLkA.js +0 -1
  237. package/dist/client/assets/useSuspenseInfiniteQuery-D1lf4BBq.js +0 -1
  238. package/dist/client/assets/view-mode-toggle-BRNVwU1R.js +0 -1
@@ -1,492 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-CK1krdST.js","assets/index-BuUlXZv1.js","assets/index-DBC4gRwz.css","assets/ChevronDown-B9FSangp.js","assets/agent-icon-Bu8L0YTs.js","assets/AlertCircle-DHfPbwmm.js","assets/Tool01-CMGcVT4l.js","assets/ArrowUp-gaHL-JMD.js","assets/Settings02-B005Jn4G.js","assets/Tool02-Bg6EYrJZ.js","assets/ArrowRight-aoYnUAfi.js","assets/ArrowUpRight-owfb6ER7.js","assets/TrendUp01-cVD_6pKi.js","assets/ZapSquare-CWc873Is.js","assets/ZoomOut-BzQ5KRW5.js","assets/Users03-CHFYRzMp.js","assets/CheckCircle-C9FuklSy.js","assets/Check-DIcuBCVN.js","assets/ChevronRight-BZGq8ec4.js","assets/ChevronUp-C8KS626_.js","assets/DotsVertical-BrcjQf49.js","assets/Stars02-Wk4f773E.js","assets/Copy01-DscCSlQa.js","assets/Globe01-B_-PRcJN.js","assets/Eye-BfHBDYah.js","assets/FilterLines-CaezqqN6.js","assets/Star01-COD8B803.js","assets/Globe04-CnBEu-Tb.js","assets/SwitchHorizontal01-CQgBK8Zs.js","assets/HardDrive-D0rrQptf.js","assets/Image01-BWs5Cl8W.js","assets/Key01-meMXc90d.js","assets/LayoutLeft-d5DgJxpL.js","assets/XCircle-Bau-QYHG.js","assets/LinkExternal01-BWDB74Bl.js","assets/LogOut01-DsLUwoTk.js","assets/Monitor01-DdFs1Uqi.js","assets/Sun-DMi1PxWR.js","assets/Package-DgWT9bDS.js","assets/Palette-DwuPeqfy.js","assets/Play-C3OJLofP.js","assets/Plus-BMGy0gLt.js","assets/SearchLg-Bvo_jSOD.js","assets/SearchMd-CwtuvWh8.js","assets/Shield01-BktOn7OY.js","assets/Stars01-DS-jsjsg.js","assets/Trash01-DmDxDqMT.js","assets/Upload01-B7Wisg2m.js","assets/User01-CrrDrMtl.js","assets/Users01-B8Zwqemn.js","assets/XClose-CiEZ9Mmp.js","assets/X-kbNEvIkE.js","assets/Zap-COQSXbiz.js","assets/automation-runs-Cbng2BoT.js","assets/select-BCZLKjJN.js","assets/tooltip-B8bYd-9r.js","assets/useInfiniteQuery-BkEklLkA.js","assets/use-infinite-scroll-CjI765bv.js","assets/use-connection-I-DnXuJH.js","assets/use-mcp-client-Dggs_wtL.js","assets/auth-Bprl3x_3.js","assets/use-virtual-mcp-DcKgvXvy.js","assets/card-CaGEmByP.js","assets/sidebar-BZQNMiqx.js","assets/use-mobile-D_MHSYLt.js","assets/table-wjz_t519.js","assets/empty-state-Bta4YdzD.js","assets/use-members-DTLixo_2.js","assets/use-org-auth-client-D8JQ0qMm.js","assets/use-clock-tick-7IVs3KNJ.js","assets/use-automations-Du6nHRym.js","assets/studio-tools-BanQp4TZ.js","assets/useSuspenseInfiniteQuery-D1lf4BBq.js","assets/avatar-Dei6fpXi.js","assets/format-time-BnbuEtat.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-DTsOKQvO.js","assets/file-type-icon-BBhjyJbf.js","assets/dialog-G4ZiTvNx.js","assets/tab-id-BijBBRwE.js","assets/hooks-eTDNg0DR.js","assets/delay-CnY5UFtP.js","assets/backoff-CrEUbyZT.js","assets/decopilot-sse-pool-DaQqKB35.js","assets/chat-context-DRXtbNYB.js","assets/autosend-DzUEXq6j.js","assets/use-ai-providers-S5QPPawK.js","assets/location-BpLtHjTZ.js","assets/use-decopilot-events-BNKUFs1m.js","assets/use-organization-settings-Cfo4apco.js","assets/monaco-editor-dTalnsYm.js","assets/index-D8aJMO1V.js","assets/index-BymC5LN8.js","assets/calendar-DHty8QJT.js","assets/shell-layout-A4Klwqzt.js","assets/required-auth-layout-CY6VIKkl.js","assets/use-org-sso-BsOWFttQ.js","assets/integration-icon-DPwYpZT7.js","assets/use-navigate-to-agent-D8r2um29.js","assets/reusable-new-chat-CouMjkYR.js","assets/AreaChart-D-FRclvq.js","assets/form-I0GnjsKQ.js","assets/label-DUcYIAKY.js","assets/input-DLUPJjpz.js","assets/dropdown-menu-Ds67TSY4.js","assets/page-seo-form-C-18bHzi.js","assets/switch-DHbzmpde.js","assets/add-section-modal-CjPlnHD2.js","assets/drawer-B75YbbdI.js","assets/collection-search-v6k7-ns_.js","assets/index-4RDnlua4.js","assets/get-initials-D-f_fDFw.js","assets/popover-CgLqhHGP.js","assets/use-registry-app-Ccw5Zgoa.js","assets/use-mcp-tools-BZb2_KlI.js","assets/github-repo-scope-DjMZbiKa.js","assets/authenticate-and-persist-oauth-CRUUJSOy.js","assets/mcp-oauth-Dci8cSOd.js","assets/extract-connection-data-DgxJXS5w.js","assets/metadata-dUsYcpuu.js","assets/command-Dh8_6SVl.js","assets/index-DNyFrsaH.js","assets/companions-core-BSh9cT1E.js","assets/tabs-BrQ8T12Z.js","assets/toggle-group-BLBd1Na5.js","assets/use-deco-credits-UyEP8mkX.js","assets/alert-dialog-CBCn_UdL.js","assets/toolbar-icon-button-CWELZhBo.js","assets/skeleton-CXG2AFFX.js","assets/github-repo-picker-C_zm2Ku6.js","assets/use-debounced-value-DZJqrsuG.js","assets/provision-repo-scoped-github-connection-2iDn-wQ1.js","assets/connection-card-CeYmR-Cx.js","assets/use-registry-connections-DL4Qbjni.js","assets/retry-CErkP7V6.js","assets/connection-slug-eyAPH6o3.js","assets/textarea-yNbPp_V1.js","assets/connection-form-helpers-7iwRsPVv.js","assets/collection-tabs-BOJ9WXu0.js","assets/badge-Cmfr9I7J.js","assets/connect-desktop-dialog-C0flGaQ_.js","assets/select-model-CFjdb8F4.js","assets/checkbox-DgJA_ceb.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-CWj3_FdW.js","assets/index-DK_1_-so.js","assets/toolbar-Cge5lcNV.js","assets/question-004-sINsf4GQ.js","assets/use-status-sounds-CAtTty8v.js","assets/deco-site-production-url-CaKZ7xBn.js","assets/use-capability-BiwL5b_x.js","assets/pt-BR-CLy76QW2.js","assets/use-mcp-auth-status-Cprl0lqq.js","assets/use-debounced-autosave-BMOZjMIM.js","assets/index-X6AHLbER.js","assets/search-input-DOMBq2Er.js","assets/use-secrets-CGKvz62m.js","assets/useQueries-CCY8hrOc.js","assets/use-file-configs-Da4n5Wk_.js","assets/automation-list-row-Cr4wP_05.js","assets/page-seo-sheet-Cq6MSxcj.js","assets/file-explorer-B6MpksVl.js","assets/app-editor-B1reldMi.js","assets/post-editor-BaU667xO.js","assets/multi-select-Cfgtgcax.js","assets/block-document-DIN2deJy.js","assets/primitives-CXNB8gAp.js","assets/use-autosave-BDYAiYhJ.js","assets/record-editor-CyFKknlv.js","assets/category-editor-s0kMzuKL.js","assets/bulk-category-panel-B1Gi9wUq.js","assets/seo-editor-C_DByLik.js","assets/variant-calendar-DqtEssYW.js","assets/view-mode-toggle-BRNVwU1R.js","assets/redirect-editor-fK_i-XfS.js","assets/project-app-view-B-ZNnyXW.js"])))=>i.map(i=>d[i]);
2
- import{o as Ls,r as N,$ as kx,a0 as Vx,c as F,F as ze,m as ie,j as r,E as hs,b as oe,t as ve,W as sn,a1 as Nx,X as os,a2 as G0,B as le,Z as Y0,Y as Cm,a3 as Tx,a4 as Ax,v as di,a5 as ss,a6 as uo,a7 as Qu,d as jt,e as Ys,p as Fe,a8 as Ex,z as kr,a9 as km,aa as Px,ab as Vm,ac as Rx,ad as fn,ae as Fc,af as Zs,ag as Dx,ah as zc,ai as Ix,aj as Mx,ak as Ox,al as $x,am as Bx,an as Fx,ao as zx,ap as Kx,K as Qe,aq as Nm,ar as So,n as Pt,k as Ze,a as ui,y as J0,_ as Tm,u as Vr,f as Yl,I as Am,G as Em,x as Pm,as as Ux,L as Rm,at as Dm,au as Im,av as gr,aw as rt,ax as Mm,ay as Hx,az as Wx,aA as Om,aB as qx,aC as Gx,aD as Yx,aE as Jx,aF as Ns,aG as ho,U as Xx}from"./index-BuUlXZv1.js";import{i as X0,n as Qx}from"./ArrowUp-gaHL-JMD.js";import{a as Bs,b as Js,S as Ni,c as hi,u as $m,d as ls,e as Bm,s as Zx,f as ev,g as tv,p as sv,h as Q0,A as nv,i as iv,j as rv,k as Rd,V as ov,E as Jl,l as Fm,m as xr,t as av,n as lv,o as cv}from"./chat-context-DRXtbNYB.js";import{s as Nr,g as gn,P as Io,d as Z0,a as dv,M as uv,i as hv,b as fv,F as mv,c as zm,e as Km,S as pv,u as gv,f as xv,h as vv,j as Zu,k as bv,l as Um,O as yv,m as fi,T as _v,n as Hm,R as Lv,C as Sv,G as wv,o as jv,p as Cv,q as kv,A as Vv}from"./automation-runs-Cbng2BoT.js";import{b as Ti,T as Ue,a as He,c as We}from"./tooltip-B8bYd-9r.js";import{a as cs,b as ds,d as Yt,e as Jt,h as On,c as mi}from"./dialog-G4ZiTvNx.js";import{c as Nv,b as Wm,a as qm,D as Gm}from"./drawer-B75YbbdI.js";import{C as Tv}from"./collection-search-v6k7-ns_.js";import{u as Tr}from"./use-mobile-D_MHSYLt.js";import{a as sa,u as pt,i as cl,S as Xl,b as Av,c as Ev,W as Pv,d as Rv,C as eh,g as dl,e as Ym,f as th,m as Dv}from"./use-mcp-client-Dggs_wtL.js";import{u as Jm,g as na,l as Dd,X as Iv,C as Mv,a as Ov,A as $v,b as Bv,c as Fv}from"./AreaChart-D-FRclvq.js";import{c as e9,t as Ai,P as zv,a as Kv,i as vr,g as Uv,b as Hv,u as Xm,E as Wv,d as t9,M as qv,e as Qm,f as Gv,h as Yv,C as Jv}from"./calendar-DHty8QJT.js";import{t as is}from"./ChevronDown-B9FSangp.js";import{i as an}from"./X-kbNEvIkE.js";import{t as Xv,z as Qv,b as Ql,c as Zv,u as Zm}from"./hooks-eTDNg0DR.js";import{K as e6,i as e2,u as ia,a as t2,m as t6}from"./shell-layout-A4Klwqzt.js";import{w as s2,A as s6}from"./autosend-DzUEXq6j.js";import{u as n6,S as i6,a as r6,b as o6,r as sh,i as a6,c as l6,w as c6,H as d6,d as u6,e as h6,f as f6,g as n2,h as m6,j as p6,T as g6,k as x6,P as v6,l as b6,m as y6}from"./index-4RDnlua4.js";import{n as br,b as i2}from"./ZapSquare-CWc873Is.js";import{i as ns}from"./Check-DIcuBCVN.js";import{s as xn}from"./Star01-COD8B803.js";import{a as Dn}from"./Image01-BWs5Cl8W.js";import{t as Zl,n as r2,o as s9,p as n9,q as o2,r as _6,u as L6,A as ii,v as a2,w as l2,x as S6,y as w6,e as c2,z as nh,B as en,C as j6,D as d2,E as C6,F as ec,G as zi,H as k6,I as i9,J as u2,K as h2,L as Id,M as Kc,N as ih,k as f2,O as V6,P as N6,Q as T6,R as A6,S as E6,a as P6,T as r9,U as m2,V as Ki,W as o9,X as p2,j as a9,l as g2,Y as l9,Z as R6,_ as D6,$ as I6,a0 as An,c as x2,a1 as ul,a2 as ra,a3 as M6,a4 as rh,a5 as O6,a6 as $6,a7 as B6,a8 as v2,a9 as hl,aa as b2,ab as F6,ac as z6,ad as K6,ae as U6,af as H6,ag as W6,ah as q6,ai as G6,aj as Y6,ak as oh,al as J6,am as X6,an as Q6,ao as Z6,ap as eb,aq as tb,ar as sb,as as y2,at as nb,au as _2}from"./agent-icon-Bu8L0YTs.js";import{i as Ui}from"./Upload01-B7Wisg2m.js";import{i as jn}from"./AlertCircle-DHfPbwmm.js";import{a as Vs}from"./Copy01-DscCSlQa.js";import{a as Md,b as c9,d as d9,e as u9,F as L2}from"./form-I0GnjsKQ.js";import{d as ut,a as $t,b as qt,c as Bt,S as Ft}from"./select-BCZLKjJN.js";import{b as tc,a as ib,i as rb}from"./Settings02-B005Jn4G.js";import{i as Ar}from"./ArrowRight-aoYnUAfi.js";import{T as ji,a as Er,b as vn,c as oa}from"./tabs-BrQ8T12Z.js";import{t as Od}from"./Tool02-Bg6EYrJZ.js";import{a as h9,T as Mo}from"./toggle-group-BLBd1Na5.js";import{I as et}from"./input-DLUPJjpz.js";import{u as f9,d as m9,a as p9,g as aa,e as S2,f as $s,r as ob,h as ab,i as lb,A as cb,N as db}from"./use-deco-credits-UyEP8mkX.js";import{u as Fs}from"./studio-tools-BanQp4TZ.js";import{i as sc}from"./Monitor01-DdFs1Uqi.js";import{C as ub,l as hb,a as fb,b as mb}from"./connect-desktop-dialog-C0flGaQ_.js";import{s as In}from"./XClose-CiEZ9Mmp.js";import{m as nc,i as pb,g as w2,a as gb,N as xb,M as vb}from"./select-model-CFjdb8F4.js";import{a as Ts,b as As,P as Es}from"./popover-CgLqhHGP.js";import{t as ei}from"./Stars01-DS-jsjsg.js";import{a as la,u as ms,b as g9,c as bb}from"./use-virtual-mcp-DcKgvXvy.js";import{f as yb,a as _b,s as Lb,u as Sb,b as wb,c as jb,d as Cb,g as kb,e as j2,H as x9,h as Vb,R as C2,i as fl,j as k2,k as Nb,F as Tb,l as Ab,m as Eb,n as Pb,o as Rb,p as Db,q as Ib,r as Mb,L as Ob,t as $b,S as Bb,B as Fb,T as v9,v as zb}from"./index-DK_1_-so.js";import{c as vs,D as bs,b as ys,a as Je,d as Oo,e as $o,f as Bo,g as $d,h as Fo,i as Xn,j as La}from"./dropdown-menu-Ds67TSY4.js";import{a as V2,i as Kb}from"./XCircle-Bau-QYHG.js";import{s as _t}from"./Plus-BMGy0gLt.js";import{p as Ub,q as Hb}from"./question-004-sINsf4GQ.js";import{i as yn}from"./ChevronRight-BZGq8ec4.js";import{u as N2}from"./use-ai-providers-S5QPPawK.js";import{i as ic}from"./CheckCircle-C9FuklSy.js";import{I as ln}from"./integration-icon-DPwYpZT7.js";import{u as Wb}from"./use-status-sounds-CAtTty8v.js";import{E as Ei}from"./empty-state-Bta4YdzD.js";import{r as ml,a as qb,p as T2,f as Ja,b as A2,c as E2,d as P2,e as Gb,F as Yb,g as Jb,h as Xb,i as Qb,j as Zb,k as e8,O as t8,l as s8,m as n8}from"./tab-id-BijBBRwE.js";import{T as i8}from"./toolbar-Cge5lcNV.js";import{a as ri,b as Pi,c as ca,i as R2,d as r8,e as o8}from"./ZoomOut-BzQ5KRW5.js";import{u as rc,a as D2,b as I2}from"./use-organization-settings-Cfo4apco.js";import{i as pi,n as a8}from"./Globe01-B_-PRcJN.js";import{u as Mn,a as b9,b as M2}from"./use-connection-I-DnXuJH.js";import{u as da,a as y9,b as O2}from"./use-mcp-tools-BZb2_KlI.js";import{g as oc,M as l8}from"./index-BymC5LN8.js";import{e as $2}from"./backoff-CrEUbyZT.js";import{s as B2,p as c8}from"./deco-site-production-url-CaKZ7xBn.js";import{F as yr,M as _9,O as d8}from"./file-type-icon-BBhjyJbf.js";import{u as u8}from"./use-capability-BiwL5b_x.js";import{p as h8,f as f8}from"./pt-BR-CLy76QW2.js";import{g as m8}from"./extract-connection-data-DgxJXS5w.js";import{A as ur}from"./avatar-Dei6fpXi.js";import{a as p8,i as ah}from"./mcp-oauth-Dci8cSOd.js";import{A as pl,a as gl,b as xl,c as vl,d as bl,e as yl,f as _l,g as Ll}from"./alert-dialog-CBCn_UdL.js";import{C as Sl,a as zo}from"./card-CaGEmByP.js";import{I as g8,R as x8,a as v8,T as F2,u as z2}from"./use-mcp-auth-status-Cprl0lqq.js";import{i as b8,a as K2}from"./DotsVertical-BrcjQf49.js";import{T as Ri}from"./textarea-yNbPp_V1.js";import{i as Di}from"./Play-C3OJLofP.js";import{s as _s}from"./Trash01-DmDxDqMT.js";import{u as wl}from"./use-debounced-autosave-BMOZjMIM.js";import{i as Ko}from"./SearchMd-CwtuvWh8.js";import{P as tn}from"./index-X6AHLbER.js";import{C as Pr}from"./checkbox-DgJA_ceb.js";import{S as L9}from"./search-input-DOMBq2Er.js";import{C as U2}from"./collection-tabs-BOJ9WXu0.js";import{g as y8,s as H2}from"./connection-slug-eyAPH6o3.js";import{L as st}from"./label-DUcYIAKY.js";import{S as _r}from"./switch-DHbzmpde.js";import{i as _8}from"./LayoutLeft-d5DgJxpL.js";import{i as S9}from"./Key01-meMXc90d.js";import{d as Rr}from"./delay-CnY5UFtP.js";import{G as Uo}from"./use-registry-app-Ccw5Zgoa.js";import{G as W2}from"./github-repo-picker-C_zm2Ku6.js";import{S as Et}from"./skeleton-CXG2AFFX.js";import{s as L8}from"./User01-CrrDrMtl.js";import{t as ac}from"./Users01-B8Zwqemn.js";import{u as q2,a as G2}from"./use-secrets-CGKvz62m.js";import{a as Y2}from"./format-time-BnbuEtat.js";import{i as J2}from"./ArrowUpRight-owfb6ER7.js";import{c as w9,s as j9,b as S8}from"./TrendUp01-cVD_6pKi.js";import{g as w8}from"./github-repo-scope-DjMZbiKa.js";import{f as X2}from"./provision-repo-scoped-github-connection-2iDn-wQ1.js";import{u as Q2,a as j8}from"./use-members-DTLixo_2.js";import{m as C8,n as k8,o as V8,p as N8,q as T8,u as A8}from"./sidebar-BZQNMiqx.js";import{n as $n}from"./LinkExternal01-BWDB74Bl.js";import{l as E8,w as P8}from"./index-D8aJMO1V.js";import{i as C9}from"./SearchLg-Bvo_jSOD.js";import{T as fo}from"./toolbar-icon-button-CWELZhBo.js";import{i as k9,a as R8,b as V9,c as N9}from"./Tool01-CMGcVT4l.js";import{b as Hi,C as oi,a as ks,e as Os,c as Wi,d as Dr,f as D8,g as lh}from"./command-Dh8_6SVl.js";import{s as T9}from"./Eye-BfHBDYah.js";import{u as Bd}from"./useQueries-CCY8hrOc.js";import{c as Z2,i as I8}from"./SwitchHorizontal01-CQgBK8Zs.js";import{i as Ii}from"./Zap-COQSXbiz.js";import{M as ua}from"./monaco-editor-dTalnsYm.js";import{u as M8}from"./use-debounced-value-DZJqrsuG.js";import{u as O8,a as ep}from"./use-file-configs-Da4n5Wk_.js";import{u as tp}from"./useInfiniteQuery-BkEklLkA.js";import{i as $8}from"./FilterLines-CaezqqN6.js";import{B as B8}from"./badge-Cmfr9I7J.js";import{u as ha,a as F8,b as z8,c as K8,d as U8}from"./use-automations-Du6nHRym.js";import{s as wo}from"./Stars02-Wk4f773E.js";import{A as H8}from"./automation-list-row-Cr4wP_05.js";import{n as W8}from"./ChevronUp-C8KS626_.js";import{g as q8}from"./get-initials-D-f_fDFw.js";function G8(t,e){const s=Ls(e);return Y8({filters:{...t,status:"pending"}},s).length}function ch(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Y8(t={},e){const s=Ls(e).getMutationCache(),n=N.useRef(t),i=N.useRef(null);return i.current===null&&(i.current=ch(s,t)),N.useEffect(()=>{n.current=t}),N.useSyncExternalStore(N.useCallback(o=>s.subscribe(()=>{const a=kx(i.current,ch(s,n.current));i.current!==a&&(i.current=a,Vx.schedule(o))}),[s]),()=>i.current,()=>i.current)}const dh=3,sp="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",J8="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function np(t){const e=F.c(46),{item:s,onSelect:n,isLoading:i,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const j=gn(c._meta);d=c.title??Z0(c.name,j),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const h=d,u=c.description||null;if(l==="card"){let j;e[4]!==n||e[5]!==c?(j=()=>n(c),e[4]=n,e[5]=c,e[6]=j):j=e[6];const S=o||i,k=i&&"bg-accent/40",C=(o||i)&&"cursor-not-allowed opacity-50";let A;e[7]!==k||e[8]!==C?(A=ie(J8,"hover:bg-accent/60 text-foreground",k,C),e[7]=k,e[8]=C,e[9]=A):A=e[9];let P;e[10]!==h?(P=r.jsx("span",{className:"font-medium truncate capitalize",children:h}),e[10]=h,e[11]=P):P=e[11];let V;e[12]!==i?(V=i&&r.jsx(Ni,{size:"xs"}),e[12]=i,e[13]=V):V=e[13];let T;e[14]!==P||e[15]!==V?(T=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[P,V]}),e[14]=P,e[15]=V,e[16]=T):T=e[16];let R;e[17]!==u?(R=u&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:u}),e[17]=u,e[18]=R):R=e[18];let E;return e[19]!==T||e[20]!==R||e[21]!==j||e[22]!==S||e[23]!==A?(E=r.jsxs("button",{type:"button",onClick:j,disabled:S,className:A,children:[T,R]}),e[19]=T,e[20]=R,e[21]=j,e[22]=S,e[23]=A,e[24]=E):E=e[24],E}let f;e[25]!==n||e[26]!==c?(f=()=>n(c),e[25]=n,e[26]=c,e[27]=f):f=e[27];const m=o||i,p=i&&"bg-muted/50",g=(o||i)&&"cursor-not-allowed opacity-50";let x;e[28]!==p||e[29]!==g?(x=ie(sp,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=x):x=e[30];let v;e[31]!==h?(v=r.jsx("span",{className:"capitalize",children:h}),e[31]=h,e[32]=v):v=e[32];let b;e[33]!==i?(b=i&&r.jsx(Ni,{size:"xs"}),e[33]=i,e[34]=b):b=e[34];let _;e[35]!==f||e[36]!==m||e[37]!==x||e[38]!==v||e[39]!==b?(_=r.jsx(Ue,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:f,disabled:m,className:x,children:[v,b]})}),e[35]=f,e[36]=m,e[37]=x,e[38]=v,e[39]=b,e[40]=_):_=e[40];const y=u??h;let L;e[41]!==y?(L=r.jsx(He,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=L):L=e[42];let w;return e[43]!==_||e[44]!==L?(w=r.jsxs(We,{delayDuration:400,children:[_,L]}),e[43]=_,e[44]=L,e[45]=w):w=e[45],w}function X8(t){const e=F.c(61),{items:s,open:n,onOpenChange:i,onSelect:o,loadingPrompt:a}=t,l=oe(),[c,d]=N.useState(""),h=!!a;let u;e[0]!==s||e[1]!==c?(u=c.trim()?s.filter(P=>{const V=c.toLowerCase();return P.prompt.name.toLowerCase().includes(V)||(P.prompt.title??"").toLowerCase().includes(V)||(P.prompt.description??"").toLowerCase().includes(V)}):s,e[0]=s,e[1]=c,e[2]=u):u=e[2];const f=u,m=Tr();let p;e[3]!==f.length||e[4]!==c||e[5]!==l?(p=f.length===0&&r.jsx("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:l("chat.iceBreakers.noPromptsMatch",{search:c})}),e[3]=f.length,e[4]=c,e[5]=l,e[6]=p):p=e[6];let g;if(e[7]!==f||e[8]!==h||e[9]!==a?.name||e[10]!==i||e[11]!==o){let P;e[13]!==h||e[14]!==a?.name||e[15]!==i||e[16]!==o?(P=V=>r.jsx(np,{item:V,variant:"card",onSelect:T=>{i(!1),o(T)},isLoading:a?.name===V.prompt.name,isDisabled:h&&a?.name!==V.prompt.name},V.prompt.name),e[13]=h,e[14]=a?.name,e[15]=i,e[16]=o,e[17]=P):P=e[17],g=f.map(P),e[7]=f,e[8]=h,e[9]=a?.name,e[10]=i,e[11]=o,e[12]=g}else g=e[12];let x;e[18]!==p||e[19]!==g?(x=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[p,g]})}),e[18]=p,e[19]=g,e[20]=x):x=e[20];const v=x;let b;e[21]!==l?(b=l("chat.iceBreakers.searchPromptsPlaceholder"),e[21]=l,e[22]=b):b=e[22];let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=P=>{P.key==="Escape"&&d("")},e[23]=_):_=e[23];let y;e[24]!==c||e[25]!==b?(y=r.jsx(Tv,{value:c,onChange:d,placeholder:b,onKeyDown:_}),e[24]=c,e[25]=b,e[26]=y):y=e[26];const L=y;if(m){let P;e[27]!==l?(P=l("chat.iceBreakers.allPromptsTitle"),e[27]=l,e[28]=P):P=e[28];let V;e[29]!==P?(V=r.jsx(Nv,{className:"sr-only",children:r.jsx(Wm,{children:P})}),e[29]=P,e[30]=V):V=e[30];let T;e[31]!==l?(T=l("chat.iceBreakers.promptsLabel"),e[31]=l,e[32]=T):T=e[32];let R;e[33]!==T?(R=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:T})}),e[33]=T,e[34]=R):R=e[34];let E;e[35]!==v||e[36]!==L||e[37]!==R||e[38]!==V?(E=r.jsxs(qm,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[V,R,L,v]}),e[35]=v,e[36]=L,e[37]=R,e[38]=V,e[39]=E):E=e[39];let I;return e[40]!==i||e[41]!==n||e[42]!==E?(I=r.jsx(Ti,{delayDuration:400,children:r.jsx(Gm,{open:n,onOpenChange:i,children:E})}),e[40]=i,e[41]=n,e[42]=E,e[43]=I):I=e[43],I}let w;e[44]!==l?(w=l("chat.iceBreakers.allPromptsTitle"),e[44]=l,e[45]=w):w=e[45];let j;e[46]!==w?(j=r.jsx(cs,{className:"sr-only",children:r.jsx(ds,{children:w})}),e[46]=w,e[47]=j):j=e[47];let S;e[48]!==l?(S=l("chat.iceBreakers.promptsLabel"),e[48]=l,e[49]=S):S=e[49];let k;e[50]!==S?(k=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:S})}),e[50]=S,e[51]=k):k=e[51];let C;e[52]!==v||e[53]!==L||e[54]!==k||e[55]!==j?(C=r.jsxs(Yt,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[j,k,L,v]}),e[52]=v,e[53]=L,e[54]=k,e[55]=j,e[56]=C):C=e[56];let A;return e[57]!==i||e[58]!==n||e[59]!==C?(A=r.jsx(Ti,{delayDuration:400,children:r.jsx(Jt,{open:n,onOpenChange:i,children:C})}),e[57]=i,e[58]=n,e[59]=C,e[60]=A):A=e[60],A}function Q8(t){const e=F.c(30),{items:s,onSelect:n,loadingPrompt:i,className:o}=t,a=oe(),[l,c]=N.useState(!1);if(s.length===0)return null;let d,h,u,f,m;if(e[0]!==o||e[1]!==s||e[2]!==i||e[3]!==n||e[4]!==a){const v=s.slice(0,dh),b=s.slice(dh),_=!!i;let y;e[10]!==_||e[11]!==i?.name||e[12]!==n?(y=w=>r.jsx(np,{item:w,onSelect:n,isLoading:i?.name===w.prompt.name,isDisabled:_&&i?.name!==w.prompt.name},w.prompt.name),e[10]=_,e[11]=i?.name,e[12]=n,e[13]=y):y=e[13];const L=v.map(y);d=Ti,m=400,e[14]!==o?(h=ie("w-full flex flex-wrap gap-2 justify-center",o),e[14]=o,e[15]=h):h=e[15],u=L,f=b.length>0&&r.jsx("button",{type:"button",disabled:_,onClick:()=>c(!0),className:ie(sp,"hover:bg-muted/70 hover:text-foreground",_&&"opacity-50 cursor-not-allowed"),children:a("chat.iceBreakers.moreButton",{count:b.length})}),e[0]=o,e[1]=s,e[2]=i,e[3]=n,e[4]=a,e[5]=d,e[6]=h,e[7]=u,e[8]=f,e[9]=m}else d=e[5],h=e[6],u=e[7],f=e[8],m=e[9];let p;e[16]!==h||e[17]!==u||e[18]!==f?(p=r.jsxs("div",{className:h,children:[u,f]}),e[16]=h,e[17]=u,e[18]=f,e[19]=p):p=e[19];let g;e[20]!==s||e[21]!==i||e[22]!==l||e[23]!==n?(g=r.jsx(X8,{items:s,open:l,onOpenChange:c,onSelect:n,loadingPrompt:i}),e[20]=s,e[21]=i,e[22]=l,e[23]=n,e[24]=g):g=e[24];let x;return e[25]!==d||e[26]!==m||e[27]!==p||e[28]!==g?(x=r.jsxs(d,{delayDuration:m,children:[p,g]}),e[25]=d,e[26]=m,e[27]=p,e[28]=g,e[29]=x):x=e[29],x}function Z8(){return null}function ey(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function ty(t){const e=F.c(31),{connectionId:s}=t,n=oe(),{sendMessage:i}=Js(),{org:o}=ze();let a;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=pt(a);let c;e[4]!==l?(c={client:l,staleTime:6e4},e[4]=l,e[5]=c):c=e[5];const{data:d}=Jm(c);let h;e[6]!==d?.prompts?(h=d?.prompts??[],e[6]=d?.prompts,e[7]=h):h=e[7];const u=h;let f;e[8]!==u?(f=u.map(sy),e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[10]=p):p=e[10];const[g,x]=N.useReducer(ey,p),[v,b]=N.useState(null);let _;e[11]!==l||e[12]!==i||e[13]!==n?(_=async(T,R)=>{if(!l){ve.error(n("chat.iceBreakers.mcpClientNotAvailable")),x({type:"RESET"});return}try{const E=await na(l,T.name,R);x({type:"RESET"});const I={type:"doc",content:[{type:"paragraph",content:[e9({id:T.name,name:Nr(T.name,gn(T._meta)),metadata:E.messages,char:"/",kind:"prompt",args:R}),{type:"text",text:" "}]}]};await i(I)}catch(E){console.error("[ice-breakers] Failed to fetch prompt:",E),ve.error(n("chat.iceBreakers.failedToLoadPrompt")),x({type:"RESET"})}},e[11]=l,e[12]=i,e[13]=n,e[14]=_):_=e[14];const y=_;let L;e[15]!==y?(L=async T=>{if(T.arguments&&T.arguments.length>0){x({type:"SELECT_PROMPT",prompt:T}),b(T);return}x({type:"START_LOADING",prompt:T}),await y(T)},e[15]=y,e[16]=L):L=e[16];const w=L;let j;e[17]!==v||e[18]!==y?(j=async T=>{v&&(x({type:"START_LOADING",prompt:v,arguments:T}),b(null),await y(v,T))},e[17]=v,e[18]=y,e[19]=j):j=e[19];const S=j;if(m.length===0)return null;const k=g.stage==="loading"?g.prompt:null;let C;e[20]!==w||e[21]!==m||e[22]!==k?(C=r.jsx(Q8,{items:m,onSelect:w,loadingPrompt:k}),e[20]=w,e[21]=m,e[22]=k,e[23]=C):C=e[23];let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{b(null),x({type:"RESET"})},e[24]=A):A=e[24];let P;e[25]!==v||e[26]!==S?(P=r.jsx(Io,{prompt:v,setPrompt:A,onSubmit:S}),e[25]=v,e[26]=S,e[27]=P):P=e[27];let V;return e[28]!==C||e[29]!==P?(V=r.jsxs(r.Fragment,{children:[C,P]}),e[28]=C,e[29]=P,e[30]=V):V=e[30],V}function sy(t){return{prompt:t}}function ny(t){const e=F.c(13),{className:s}=t,{selectedVirtualMcp:n}=Bs(),{org:i}=ze();let o;e[0]!==i.id?(o=sa(i.id),e[0]=i.id,e[1]=o):o=e[1];const a=o.id,l=n?.id??a;let c;e[2]!==s?(c=ie("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Z8,{}),e[4]=h):h=e[4];let u;e[5]!==l?(u=r.jsx(ty,{connectionId:l}),e[5]=l,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=r.jsx(hs,{fallback:null,children:r.jsx(N.Suspense,{fallback:h,children:u},d)}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=r.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}const Uc="cubic-bezier(0.645, 0.045, 0.355, 1)",iy=44,ry={default:"",error:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-destructive/5 after:pointer-events-none after:-z-10",warning:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-warning/5 after:pointer-events-none after:-z-10"},oy={default:"border-border",error:"border-destructive/30",warning:"border-warning/30"},ay={default:"text-muted-foreground",error:"text-destructive",warning:"text-warning"};function ai(t){const e=F.c(69),{icon:s,label:n,count:i,title:o,footerLeft:a,footerRight:l,children:c,defaultExpanded:d,variant:h,onClose:u}=t,f=h===void 0?"default":h,m=oe(),[p,g]=N.useState(d),[x,v]=N.useState(!1);let b;e[0]!==u?(b=()=>{v(!0),u?.()},e[0]=u,e[1]=b):b=e[1];const _=b;if(x)return null;const y=oy[f],L=ry[f];let w;e[2]!==y||e[3]!==L?(w=ie("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",y,L),e[2]=y,e[3]=L,e[4]=w):w=e[4];let j;e[5]===Symbol.for("react.memo_cache_sentinel")?(j=()=>g(ly),e[5]=j):j=e[5];const S=p&&"rounded-b-none",k=!p&&"rounded-b-xl";let C;e[6]!==S||e[7]!==k?(C=ie("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",S,k),e[6]=S,e[7]=k,e[8]=C):C=e[8];const A=ay[f];let P;e[9]!==A?(P=ie("shrink-0",A),e[9]=A,e[10]=P):P=e[10];let V;e[11]!==s||e[12]!==P?(V=r.jsx("span",{className:P,children:s}),e[11]=s,e[12]=P,e[13]=V):V=e[13];let T;e[14]!==n?(T=r.jsx("span",{className:"flex-1 min-w-0 truncate",children:n}),e[14]=n,e[15]=T):T=e[15];let R;e[16]!==i?(R=i?r.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:i}):null,e[16]=i,e[17]=R):R=e[17];const E=p?"rotate(180deg)":"rotate(0deg)";let I;e[18]!==E?(I=r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:r.jsx(is,{size:16,style:{transform:E,transition:`transform 180ms ${Uc}`}})}),e[18]=E,e[19]=I):I=e[19];let D;e[20]!==m?(D=m("chat.collapsibleHighlight.closeLabel"),e[20]=m,e[21]=D):D=e[21];let M;e[22]!==m?(M=m("chat.collapsibleHighlight.closeTitle"),e[22]=m,e[23]=M):M=e[23];let O,$;e[24]!==_?(O=se=>{se.stopPropagation(),_()},$=se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),_())},e[24]=_,e[25]=O,e[26]=$):(O=e[25],$=e[26]);let B;e[27]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsx(an,{size:16}),e[27]=B):B=e[27];let z;e[28]!==D||e[29]!==M||e[30]!==O||e[31]!==$?(z=r.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":D,title:M,onClick:O,onKeyDown:$,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center justify-center -mr-1 ml-1 p-1 rounded-md hover:bg-accent",children:B}),e[28]=D,e[29]=M,e[30]=O,e[31]=$,e[32]=z):z=e[32];let K;e[33]!==p||e[34]!==V||e[35]!==T||e[36]!==R||e[37]!==I||e[38]!==z||e[39]!==C?(K=r.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":p,onClick:j,className:C,children:[V,T,R,I,z]}),e[33]=p,e[34]=V,e[35]=T,e[36]=R,e[37]=I,e[38]=z,e[39]=C,e[40]=K):K=e[40];const Y=p?"1fr":"0fr";let Q;e[41]!==Y?(Q={display:"grid",gridTemplateRows:Y,transition:`grid-template-rows 180ms ${Uc}`},e[41]=Y,e[42]=Q):Q=e[42];let q;e[43]===Symbol.for("react.memo_cache_sentinel")?(q={overflow:"hidden",minHeight:0},e[43]=q):q=e[43];const H=p?1:0;let U;e[44]!==H?(U={opacity:H,transition:`opacity 120ms ${Uc}`,maxHeight:"60vh"},e[44]=H,e[45]=U):U=e[45];let X;e[46]!==o?(X=o?r.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):r.jsx("div",{className:"border-t border-dashed border-border/60"}),e[46]=o,e[47]=X):X=e[47];let J;e[48]!==c||e[49]!==o?(J=c?r.jsx("div",{className:ie("pb-4",!o&&"pt-4"),children:c}):null,e[48]=c,e[49]=o,e[50]=J):J=e[50];let ee;e[51]!==X||e[52]!==J?(ee=r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[X,J]}),e[51]=X,e[52]=J,e[53]=ee):ee=e[53];let W;e[54]!==a||e[55]!==l?(W=a||l?r.jsx("div",{className:"shrink-0 border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:a}),r.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[54]=a,e[55]=l,e[56]=W):W=e[56];let Z;e[57]!==U||e[58]!==ee||e[59]!==W?(Z=r.jsx("div",{style:q,children:r.jsxs("div",{className:"flex flex-col",style:U,children:[ee,W]})}),e[57]=U,e[58]=ee,e[59]=W,e[60]=Z):Z=e[60];let G;e[61]!==Q||e[62]!==Z?(G=r.jsx("div",{"data-testid":"collapsible-highlight-body",style:Q,children:Z}),e[61]=Q,e[62]=Z,e[63]=G):G=e[63];let te;return e[64]!==K||e[65]!==G||e[66]!==w||e[67]!==f?(te=r.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":f,className:w,children:[K,G]}),e[64]=K,e[65]=G,e[66]=w,e[67]=f,e[68]=te):te=e[68],te}function ly(t){return!t}const cy=sn({content:os().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:G0(["pending","in_progress","completed"]),activeForm:os().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),ip=sn({todos:Nx(cy)}),dy="Plan and track multi-step work. Call with the FULL todo list every time — this replaces the prior list. Call at the start of every multi-step request. Skip only for true one-shots (a single tool call or a direct answer). Mark exactly one todo `in_progress` at a time. Flip a todo to `in_progress` before starting it and to `completed` the moment it finishes — do not batch completions. Your prior tool-call inputs are your current state — read your last call to see where you are.";Xv({description:dy,inputSchema:Qv(ip),execute:async({todos:t})=>({ok:!0,count:t.length})});const uy="tool-todo_write",hy=new Set(["input-available","output-available"]);function fy(t){for(let e=t.length-1;e>=0;e--){const s=t[e];if(s.role!=="assistant")continue;const n=s.parts;if(Array.isArray(n))for(let i=n.length-1;i>=0;i--){const o=n[i];if(o.type!==uy||typeof o.state!="string"||!hy.has(o.state))continue;const a=ip.safeParse(o.input);if(a.success)return a.data.todos}}return[]}function rp(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const n="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:n,friendlyName:Ai(dv(n)),input:s.input})}return e}function op(t){return t.at(-1)}function ap(t){const e=[];for(const s of t)s.type==="tool-propose_plan"&&s.state==="input-available"&&e.push({toolCallId:s.toolCallId,plan:s.input.plan,state:s.state});return e}function my(t){return t?t.message.startsWith("[CREDITS]"):!1}const py={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1,todos:[]};function gy(t){const{messages:e,error:s,finishReason:n,isStreaming:i,isWaitingForApprovals:o}=t;if(!i&&s&&my(s))return{...py,isCreditExhausted:!0};const a=e.at(-1),l=a?.role==="assistant"?a.parts:[],c=l,h=!!c.filter(_=>_.type==="tool-user_ask").filter(_=>_.state!=="output-available").length,u=ap(l),f=rp(c),m=fy(e),p=!i&&!!s,g=f.length>0||i&&o,x=u.length>0,b=!i&&!!n&&n!=="stop"&&!(n==="tool-calls"&&(h||g||x))&&!p;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:p,showWarning:b,hasApprovals:g,hasPlans:x,isWaitingForUserInput:h,todos:m}}function lp(){const t=F.c(6),{messages:e,error:s,finishReason:n,isStreaming:i,isWaitingForApprovals:o}=Js(),a=s??null,l=n??null;let c;return t[0]!==i||t[1]!==o||t[2]!==e||t[3]!==a||t[4]!==l?(c=gy({messages:e,error:a,finishReason:l,isStreaming:i,isWaitingForApprovals:o}),t[0]=i,t[1]=o,t[2]=e,t[3]=a,t[4]=l,t[5]=c):c=t[5],c}function xy(){const t=lp();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function vy(t){const e=F.c(30),{current:s,total:n,onPrev:i,onNext:o}=t,a=oe();if(n<=1)return null;const l=s===0,c=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let d;e[0]!==c?(d=ie("p-0.5 rounded transition-colors",c),e[0]=c,e[1]=d):d=e[1];let h;e[2]!==a?(h=a("chat.pagination.previousLabel"),e[2]=a,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(tc,{size:14}),e[4]=u):u=e[4];let f;e[5]!==i||e[6]!==l||e[7]!==d||e[8]!==h?(f=r.jsx("button",{type:"button",onClick:i,disabled:l,className:d,"aria-label":h,children:u}),e[5]=i,e[6]=l,e[7]=d,e[8]=h,e[9]=f):f=e[9];const m=s+1;let p;e[10]!==a||e[11]!==m||e[12]!==n?(p=a("chat.pagination.counter",{current:m,total:n}),e[10]=a,e[11]=m,e[12]=n,e[13]=p):p=e[13];let g;e[14]!==p?(g=r.jsx("span",{className:"tabular-nums text-xs",children:p}),e[14]=p,e[15]=g):g=e[15];const x=s===n-1,v=s===n-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let b;e[16]!==v?(b=ie("p-0.5 rounded transition-colors",v),e[16]=v,e[17]=b):b=e[17];let _;e[18]!==a?(_=a("chat.pagination.nextLabel"),e[18]=a,e[19]=_):_=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Ar,{size:14}),e[20]=y):y=e[20];let L;e[21]!==o||e[22]!==x||e[23]!==b||e[24]!==_?(L=r.jsx("button",{type:"button",onClick:o,disabled:x,className:b,"aria-label":_,children:y}),e[21]=o,e[22]=x,e[23]=b,e[24]=_,e[25]=L):L=e[25];let w;return e[26]!==L||e[27]!==f||e[28]!==g?(w=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[f,g,L]}),e[26]=L,e[27]=f,e[28]=g,e[29]=w):w=e[29],w}function cp(t){const e=F.c(8),{currentIndex:s,total:n,onPrev:i,onNext:o,extraLeft:a}=t;let l;e[0]!==s||e[1]!==o||e[2]!==i||e[3]!==n?(l=r.jsx(vy,{current:s,total:n,onPrev:i,onNext:o}),e[0]=s,e[1]=o,e[2]=i,e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=r.jsxs("div",{className:"flex items-center gap-2",children:[l,a]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function by(t){const e=F.c(17),{isStreaming:s,isAllAnswered:n,isCurrentAnswered:i,onAdvanceOrSubmit:o,submitLabel:a,nextLabel:l}=t,h=n?a===void 0?"Submit":a:l===void 0?"Next":l,u=n?s:!i,f=u?n?"Waiting for the assistant to finish…":"Answer this item to continue":null;let m;e[0]!==u||e[1]!==o?(m=()=>{u||o()},e[0]=u,e[1]=o,e[2]=m):m=e[2];const p=u&&"opacity-50 cursor-not-allowed";let g;e[3]!==p?(g=ie("h-7 px-2.5 text-xs",p),e[3]=p,e[4]=g):g=e[4];let x;e[5]!==u||e[6]!==h||e[7]!==m||e[8]!==g?(x=r.jsx(le,{type:"button",size:"sm","aria-disabled":u,onClick:m,className:g,children:h}),e[5]=u,e[6]=h,e[7]=m,e[8]=g,e[9]=x):x=e[9];const v=x;if(!f)return v;let b;e[10]!==v?(b=r.jsx(Ue,{asChild:!0,children:v}),e[10]=v,e[11]=b):b=e[11];let _;e[12]!==f?(_=r.jsx(He,{children:f}),e[12]=f,e[13]=_):_=e[13];let y;return e[14]!==b||e[15]!==_?(y=r.jsxs(We,{children:[b,_]}),e[14]=b,e[15]=_,e[16]=y):y=e[16],y}function dp(t,e,s){return t.findIndex(n=>e(n)===s)}function uh(t,e,s,n){return t.length===0?!1:t.every(i=>n(s[e(i)]))}function hh(t,e,s,n,i){if(t.length===0)return null;const o=dp(t,e,i);for(let a=1;a<=t.length;a++){const l=t[(o+a)%t.length];if(!l)continue;const c=e(l);if(c!==i&&!n(s[c]))return c}return null}function yy(t){return!t.isStreaming&&t.allAnswered}function up(t){const{parts:e,partKey:s,schema:n,defaultValues:i,isStreaming:o,hasAnswer:a,onSubmit:l}=t,c=e[0]?s(e[0]):"",[d,h]=N.useState(c),[u,f]=N.useState(!1),m=Y0({resolver:Cm(n),defaultValues:i}),p=m.watch(),g=dp(e,s,d),x=g>=0?e[g]:void 0,v=a(p[d]),b=uh(e,s,p,a),_=yy({isStreaming:o,allAnswered:b}),y=()=>{if(g>0){const A=e[g-1];A&&h(s(A))}},L=()=>{if(g>=0&&g<e.length-1){const A=e[g+1];A&&h(s(A))}},w=()=>{const A=m.getValues(),P=hh(e,s,A,a,d);P&&h(P)},j=()=>{m.handleSubmit(A=>{const P=A;for(const V of e)l(V,P[s(V)])})()},S=N.useRef(j);S.current=j;const k=()=>{_&&(f(!1),S.current())},C=()=>{const A=m.getValues();if(uh(e,s,A,a)){if(o){f(!0);return}f(!1),S.current()}else{const P=hh(e,s,A,a,d);P&&h(P)}};return N.useEffect(()=>{if(u&&!o){if(!b){f(!1);return}f(!1),S.current()}},[u,o,b]),{form:m,activeKey:d,setActiveKey:h,currentIndex:g,currentPart:x,isCurrentAnswered:v,isAllAnswered:b,canSubmit:_,goPrev:y,goNext:L,advanceToNextUnanswered:w,submit:k,submitOrAdvance:C}}const hp="chat.approval.defaultDenyReason";function fp(t){const e=F.c(13),{onYolo:s}=t,n=oe(),[i,o]=di();let a;e[0]!==s||e[1]!==i||e[2]!==o?(a=m=>{const p=m,g=i.toolApprovalLevel??"readonly";o({...i,toolApprovalLevel:p}),p==="auto"&&s(g)},e[0]=s,e[1]=i,e[2]=o,e[3]=a):a=e[3];const l=a,c=i.toolApprovalLevel;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx($t,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:_y,children:r.jsx(qt,{})}),e[4]=d):d=e[4];let h;e[5]!==n?(h=uo.map(m=>r.jsx(ut,{value:m.value,children:n(m.labelKey)},m.value)),e[5]=n,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx(Bt,{children:h}),e[7]=h,e[8]=u):u=e[8];let f;return e[9]!==l||e[10]!==i.toolApprovalLevel||e[11]!==u?(f=r.jsxs(Ft,{value:c,onValueChange:l,children:[d,u]}),e[9]=l,e[10]=i.toolApprovalLevel,e[11]=u,e[12]=f):f=e[12],f}function _y(t){return t.stopPropagation()}function mp(t){const e=F.c(8),{input:s}=t,n=oe();if(s==null){let a;e[0]!==n?(a=n("chat.approval.noInput"),e[0]=n,e[1]=a):a=e[1];let l;return e[2]!==a?(l=r.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:a}),e[2]=a,e[3]=l):l=e[3],l}let i;try{let a;e[4]!==s?(a=JSON.stringify(s,null,2),e[4]=s,e[5]=a):a=e[5],i=a}catch{i=String(s)}let o;return e[6]!==i?(o=r.jsx("div",{className:"px-4",children:r.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[6]=i,e[7]=o):o=e[7],o}function Ly(t){const e=F.c(38),{approval:s,onRespond:n}=t,i=oe(),[o]=di(),a=o.toolApprovalLevel??"readonly";let l;e[0]!==s.approvalId||e[1]!==a||e[2]!==n||e[3]!==i?(l=()=>n(s.approvalId,!1,i(hp),a),e[0]=s.approvalId,e[1]=a,e[2]=n,e[3]=i,e[4]=l):l=e[4];const c=l;let d;e[5]!==s.approvalId||e[6]!==a||e[7]!==n?(d=()=>n(s.approvalId,!0,void 0,a),e[5]=s.approvalId,e[6]=a,e[7]=n,e[8]=d):d=e[8];const h=d;let u;e[9]!==s.approvalId||e[10]!==n?(u=k=>n(s.approvalId,!0,void 0,k),e[9]=s.approvalId,e[10]=n,e[11]=u):u=e[11];const f=u;let m;e[12]!==f?(m=r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(fp,{onYolo:f})}),e[12]=f,e[13]=m):m=e[13];const p=m;let g;e[14]!==i?(g=i("chat.approval.denyButton"),e[14]=i,e[15]=g):g=e[15];let x;e[16]!==c||e[17]!==g?(x=r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:c,children:g}),e[16]=c,e[17]=g,e[18]=x):x=e[18];let v;e[19]!==i?(v=i("chat.approval.acceptButton"),e[19]=i,e[20]=v):v=e[20];let b;e[21]!==h||e[22]!==v?(b=r.jsx(le,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:v}),e[21]=h,e[22]=v,e[23]=b):b=e[23];let _;e[24]!==x||e[25]!==b?(_=r.jsxs(r.Fragment,{children:[x,b]}),e[24]=x,e[25]=b,e[26]=_):_=e[26];const y=_;let L;e[27]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Zl,{size:14}),e[27]=L):L=e[27];let w;e[28]!==i?(w=i("chat.approval.needsApproval"),e[28]=i,e[29]=w):w=e[29];let j;e[30]!==s.input?(j=r.jsx(mp,{input:s.input}),e[30]=s.input,e[31]=j):j=e[31];let S;return e[32]!==s.friendlyName||e[33]!==p||e[34]!==y||e[35]!==w||e[36]!==j?(S=r.jsx(ai,{icon:L,label:w,title:s.friendlyName,defaultExpanded:!0,footerLeft:p,footerRight:y,children:j}),e[32]=s.friendlyName,e[33]=p,e[34]=y,e[35]=w,e[36]=j,e[37]=S):S=e[37],S}const Sy=Tx(os(),sn({approved:Ax().optional(),levelOverride:G0(["auto","readonly"]).optional()}));function wy(t){const e=F.c(46),{approvals:s,isStreaming:n,onRespond:i}=t,o=oe(),[a]=di(),l=a.toolApprovalLevel??"readonly";let c;e[0]!==s?(c=Object.fromEntries(s.map(ky)),e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==l||e[3]!==i||e[4]!==o?(h=(P,V)=>{const T=V;typeof T?.approved=="boolean"&&i(P.approvalId,T.approved,T.approved===!1?o(hp):void 0,T.levelOverride??l)},e[2]=l,e[3]=i,e[4]=o,e[5]=h):h=e[5];let u;e[6]!==s||e[7]!==d||e[8]!==n||e[9]!==h?(u={parts:s,partKey:Cy,schema:Sy,defaultValues:d,isStreaming:n,hasAnswer:jy,onSubmit:h},e[6]=s,e[7]=d,e[8]=n,e[9]=h,e[10]=u):u=e[10];const f=up(u);let m;e[11]!==s||e[12]!==f?(m=P=>{f.form.reset(Object.fromEntries(s.map(V=>[V.approvalId,{approved:!0,levelOverride:P}]))),f.submitOrAdvance()},e[11]=s,e[12]=f,e[13]=m):m=e[13];const p=m,g=f.currentPart,x=f.form;let v;e[14]!==f?(v=P=>{P.preventDefault(),f.submit()},e[14]=f,e[15]=v):v=e[15];let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Zl,{size:14}),e[16]=b):b=e[16];let _;e[17]!==s.length||e[18]!==o?(_=o("chat.approval.batchedLabel",{count:s.length}),e[17]=s.length,e[18]=o,e[19]=_):_=e[19];const y=g?.friendlyName??"";let L;e[20]!==p?(L=r.jsx(fp,{onYolo:p}),e[20]=p,e[21]=L):L=e[21];let w;e[22]!==s.length||e[23]!==f.currentIndex||e[24]!==f.goNext||e[25]!==f.goPrev||e[26]!==L?(w=r.jsx(cp,{currentIndex:f.currentIndex,total:s.length,onPrev:f.goPrev,onNext:f.goNext,extraLeft:L}),e[22]=s.length,e[23]=f.currentIndex,e[24]=f.goNext,e[25]=f.goPrev,e[26]=L,e[27]=w):w=e[27];let j;e[28]!==g||e[29]!==f.form.control||e[30]!==f.submitOrAdvance?(j=g?r.jsx(Vy,{approvalId:g.approvalId,control:f.form.control,onChange:f.submitOrAdvance}):null,e[28]=g,e[29]=f.form.control,e[30]=f.submitOrAdvance,e[31]=j):j=e[31];let S;e[32]!==g?(S=g?r.jsx(mp,{input:g.input}):null,e[32]=g,e[33]=S):S=e[33];let k;e[34]!==w||e[35]!==j||e[36]!==S||e[37]!==_||e[38]!==y?(k=r.jsx(ai,{icon:b,label:_,title:y,defaultExpanded:!0,footerLeft:w,footerRight:j,children:S}),e[34]=w,e[35]=j,e[36]=S,e[37]=_,e[38]=y,e[39]=k):k=e[39];let C;e[40]!==k||e[41]!==v?(C=r.jsx("form",{onSubmit:v,children:k}),e[40]=k,e[41]=v,e[42]=C):C=e[42];let A;return e[43]!==f.form||e[44]!==C?(A=r.jsx(Md,{...x,children:C}),e[43]=f.form,e[44]=C,e[45]=A):A=e[45],A}function jy(t){return typeof t?.approved=="boolean"}function Cy(t){return t.approvalId}function ky(t){return[t.approvalId,{approved:void 0}]}function Vy(t){const e=F.c(7),{approvalId:s,control:n,onChange:i}=t,o=oe(),a=`${s}.approved`;let l;e[0]!==i||e[1]!==o?(l=d=>{const{field:h}=d,u=h.value===!0,f=h.value===!1;return r.jsxs(r.Fragment,{children:[r.jsx(le,{type:"button",variant:f?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{h.onChange(!1),i()},"aria-pressed":f,children:o("chat.approval.denyButton")}),r.jsx(le,{type:"button",variant:u?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{h.onChange(!0),i()},"aria-pressed":u,children:o("chat.approval.acceptButton")})]})},e[0]=i,e[1]=o,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==a||e[5]!==l?(c=r.jsx(ss,{control:n,name:a,render:l}),e[3]=n,e[4]=a,e[5]=l,e[6]=c):c=e[6],c}function Ny(){const t=F.c(5),e=oe();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Zl,{className:"size-5 text-muted-foreground shimmer"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("chat.approval.preparingRequest"),t[1]=e,t[2]=n):n=t[2];let i;return t[3]!==n?(i=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[s,r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:n})]}),t[3]=n,t[4]=i):i=t[4],i}function Ty(t){const e=F.c(8),{approvals:s,isStreaming:n,onRespond:i}=t;if(n&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Ny,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;if(s.length===1){const a=s[0];if(!a)return null;let l;return e[1]!==i||e[2]!==a?(l=r.jsx(Ly,{approval:a,onRespond:i}),e[1]=i,e[2]=a,e[3]=l):l=e[3],l}let o;return e[4]!==s||e[5]!==n||e[6]!==i?(o=r.jsx(wy,{approvals:s,isStreaming:n,onRespond:i}),e[4]=s,e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function Ay(t){const e=F.c(28),{plan:s,onApprove:n,onDismiss:i}=t,o=oe();let a;e[0]!==n||e[1]!==s.plan?(a=()=>{n(s.plan)},e[0]=n,e[1]=s.plan,e[2]=a):a=e[2];const l=a;let c;e[3]!==o?(c=o("chat.proposePlan.keepIterating"),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==i||e[6]!==c?(d=r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:i,children:c}),e[5]=i,e[6]=c,e[7]=d):d=e[7];let h;e[8]!==o?(h=o("chat.proposePlan.letsGo"),e[8]=o,e[9]=h):h=e[9];let u;e[10]!==l||e[11]!==h?(u=r.jsx(le,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:l,children:h}),e[10]=l,e[11]=h,e[12]=u):u=e[12];let f;e[13]!==d||e[14]!==u?(f=r.jsxs(r.Fragment,{children:[d,u]}),e[13]=d,e[14]=u,e[15]=f):f=e[15];const m=f;let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(r2,{size:14}),e[16]=p):p=e[16];let g;e[17]!==o?(g=o("chat.proposePlan.planReady"),e[17]=o,e[18]=g):g=e[18];let x;e[19]!==o?(x=o("chat.proposePlan.implementationPlan"),e[19]=o,e[20]=x):x=e[20];let v;e[21]!==s.plan?(v=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(uv,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[21]=s.plan,e[22]=v):v=e[22];let b;return e[23]!==m||e[24]!==v||e[25]!==g||e[26]!==x?(b=r.jsx(ai,{icon:p,label:g,title:x,defaultExpanded:!0,footerRight:m,children:v}),e[23]=m,e[24]=v,e[25]=g,e[26]=x,e[27]=b):b=e[27],b}function Ey(t){const e=F.c(6),{plans:s,onApprove:n,onDismiss:i}=t;let o;e[0]!==s?(o=op(s),e[0]=s,e[1]=o):o=e[1];const a=o;if(!a)return null;let l;return e[2]!==a||e[3]!==n||e[4]!==i?(l=r.jsx(Ay,{plan:a,onApprove:n,onDismiss:i}),e[2]=a,e[3]=n,e[4]=i,e[5]=l):l=e[5],l}function pp(t){return t?"response"in t?t.response:t.option??t.draft:""}const fh=sn({response:os().min(1,"Response is required")}),Py=sn({option:os().nullable(),draft:os()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),Ry=sn({response:G0(["yes","no"])});function Dy(t){switch(t.type){case"text":return fh;case"choice":return Py;case"confirm":return Ry;default:return fh}}function Iy(t){const e={};for(const s of t)e[s.toolCallId]=Dy(s.input);return sn(e)}function My(t){const e=F.c(7),{control:s,name:n,placeholder:i}=t,o=oe();let a;e[0]!==i||e[1]!==o?(a=c=>{const{field:d}=c,h=d.value??"";return r.jsxs(c9,{children:[r.jsx(d9,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(s9,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...d,value:h,type:"text",placeholder:i||o("chat.userAskQuestion.typeResponse"),autoFocus:!0,"aria-label":o("chat.userAskQuestion.textResponseInputAriaLabel"),className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),r.jsx(u9,{})]})},e[0]=i,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==s||e[4]!==n||e[5]!==a?(l=r.jsx(L2,{control:s,name:n,render:a}),e[3]=s,e[4]=n,e[5]=a,e[6]=l):l=e[6],l}function gp(t,e){const s=F.c(4);let n,i;s[0]!==t||s[1]!==e?(n=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},i=[t,e],s[0]=t,s[1]=e,s[2]=n,s[3]=i):(n=s[2],i=s[3]),N.useEffect(n,i)}function Oy(t){const e=F.c(51),{control:s,name:n,options:i}=t,o=oe(),a=`${n}.option`;let l;e[0]!==s||e[1]!==a?(l={control:s,name:a,defaultValue:null},e[0]=s,e[1]=a,e[2]=l):l=e[2];const{field:c}=Qu(l),d=`${n}.draft`;let h;e[3]!==s||e[4]!==d?(h={control:s,name:d,defaultValue:""},e[3]=s,e[4]=d,e[5]=h):h=e[5];const{field:u}=Qu(h),f=c.value,m=u.value??"";let p;if(e[6]!==c||e[7]!==i?(p=E=>{const I=i[E];I!=null&&c.onChange(I)},e[6]=c,e[7]=i,e[8]=p):p=e[8],gp(i.length,p),i.length===0)return null;const g=f===null;let x;e[9]!==o?(x=o("chat.userAskQuestion.choiceOptionsAriaLabel"),e[9]=o,e[10]=x):x=e[10];let v;if(e[11]!==c||e[12]!==f||e[13]!==i||e[14]!==o){let E;e[16]!==c||e[17]!==f||e[18]!==o?(E=(I,D)=>{const M=f===I;return r.jsxs("button",{type:"button",onClick:()=>c.onChange(I),className:ie("flex items-start gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",M&&"bg-accent/50",!M&&"hover:bg-accent/30"),"aria-label":o("chat.userAskQuestion.selectOption",{option:I}),children:[r.jsx("span",{className:ie("flex items-center justify-center size-6 rounded-md text-sm shrink-0 mt-0.5",M?"bg-chart-1 text-white":"bg-muted text-foreground"),children:D+1}),r.jsx("span",{className:"text-sm text-foreground min-w-0 break-words",children:I})]},`${D}-${I}`)},e[16]=c,e[17]=f,e[18]=o,e[19]=E):E=e[19],v=i.map(E),e[11]=c,e[12]=f,e[13]=i,e[14]=o,e[15]=v}else v=e[15];const b=g&&"bg-accent/50",_=!g&&"hover:bg-accent/30";let y;e[20]!==b||e[21]!==_?(y=ie("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",b,_),e[20]=b,e[21]=_,e[22]=y):y=e[22];let L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(s9,{size:16,className:"text-muted-foreground"})}),e[23]=L):L=e[23];const w=g?m:"";let j;e[24]!==u||e[25]!==c||e[26]!==f?(j=E=>{u.onChange(E.target.value),f!==null&&c.onChange(null)},e[24]=u,e[25]=c,e[26]=f,e[27]=j):j=e[27];let S;e[28]!==c||e[29]!==f?(S=()=>{f!==null&&c.onChange(null)},e[28]=c,e[29]=f,e[30]=S):S=e[30];let k;e[31]!==o?(k=o("chat.userAskQuestion.somethingElsePlaceholder"),e[31]=o,e[32]=k):k=e[32];let C;e[33]!==o?(C=o("chat.userAskQuestion.customChoiceInputAriaLabel"),e[33]=o,e[34]=C):C=e[34];let A;e[35]!==w||e[36]!==j||e[37]!==S||e[38]!==k||e[39]!==C?(A=r.jsx("input",{type:"text",value:w,onChange:j,onFocus:S,placeholder:k,"aria-label":C,className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[35]=w,e[36]=j,e[37]=S,e[38]=k,e[39]=C,e[40]=A):A=e[40];let P;e[41]!==y||e[42]!==A?(P=r.jsxs("label",{className:y,children:[L,A]}),e[41]=y,e[42]=A,e[43]=P):P=e[43];let V;e[44]!==P||e[45]!==x||e[46]!==v?(V=r.jsx(d9,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":x,children:[v,P]})}),e[44]=P,e[45]=x,e[46]=v,e[47]=V):V=e[47];let T;e[48]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(u9,{}),e[48]=T):T=e[48];let R;return e[49]!==V?(R=r.jsxs(c9,{children:[V,T]}),e[49]=V,e[50]=R):R=e[50],R}function $y(t){const e=F.c(8),{control:s,name:n}=t,i=oe();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["yes","no"],e[0]=o):o=e[0];const a=o,l=N.useRef(null);let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{l.current?.onChange(a[u]??"")},e[1]=c):c=e[1],gp(a.length,c);let d;e[2]!==i?(d=u=>{const{field:f}=u;return l.current=f,r.jsxs(c9,{children:[r.jsx(d9,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":i("chat.userAskQuestion.confirmationOptionsAriaLabel"),children:a.map(m=>{const p=f.value===m;return r.jsxs("button",{type:"button",onClick:()=>f.onChange(m),className:ie("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),"aria-label":i("chat.userAskQuestion.confirmValue",{value:i(`chat.userAskQuestion.confirm${m==="yes"?"Yes":"No"}`)}),children:[r.jsx("span",{className:ie("flex items-center justify-center size-6 rounded-md text-sm shrink-0",p?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:i(`chat.userAskQuestion.confirm${m==="yes"?"Yes":"No"}`)})]},m)})})}),r.jsx(u9,{})]})},e[2]=i,e[3]=d):d=e[3];let h;return e[4]!==s||e[5]!==n||e[6]!==d?(h=r.jsx(L2,{control:s,name:n,render:d}),e[4]=s,e[5]=n,e[6]=d,e[7]=h):h=e[7],h}function mh(t){const e=F.c(13),{input:s,control:n,toolCallId:i}=t;switch(s.type){case"text":{const o=`${i}.response`;let a;return e[0]!==n||e[1]!==s.default||e[2]!==o?(a=r.jsx(My,{control:n,name:o,placeholder:s.default}),e[0]=n,e[1]=s.default,e[2]=o,e[3]=a):a=e[3],a}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==n||e[7]!==a||e[8]!==i?(l=r.jsx(Oy,{control:n,name:i,options:a}),e[6]=n,e[7]=a,e[8]=i,e[9]=l):l=e[9],l}case"confirm":{const o=`${i}.response`;let a;return e[10]!==n||e[11]!==o?(a=r.jsx($y,{control:n,name:o}),e[10]=n,e[11]=o,e[12]=a):a=e[12],a}default:return null}}function By(t){const e=F.c(91),{parts:s,isStreaming:n,onSubmit:i}=t;let o;e[0]!==s?(o=Iy(s.map(Uy)),e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=Object.fromEntries(s.map(Ky)),e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==i?(d=($,B)=>{const z=pp(B);z&&i($,z)},e[4]=i,e[5]=d):d=e[5];let h;e[6]!==c||e[7]!==n||e[8]!==s||e[9]!==a||e[10]!==d?(h={parts:s,partKey:zy,schema:a,defaultValues:c,isStreaming:n,hasAnswer:Fy,onSubmit:d},e[6]=c,e[7]=n,e[8]=s,e[9]=a,e[10]=d,e[11]=h):h=e[11];const u=up(h),f=u.currentPart,m=oe();let p;e[12]!==f||e[13]!==u||e[14]!==m?(p=()=>{const $=f;if(!$)return;const B=m("chat.userAskQuestion.skipMessage"),z=$.toolCallId;$.input?.type==="choice"?(u.form.setValue(`${z}.option`,null),u.form.setValue(`${z}.draft`,B)):u.form.setValue(`${z}.response`,B),u.advanceToNextUnanswered()},e[12]=f,e[13]=u,e[14]=m,e[15]=p):p=e[15];const g=p;let x;e[16]!==u.currentIndex||e[17]!==u.goNext||e[18]!==u.goPrev||e[19]!==s.length?(x=r.jsx(cp,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext}),e[16]=u.currentIndex,e[17]=u.goNext,e[18]=u.goPrev,e[19]=s.length,e[20]=x):x=e[20];const v=x;let b;e[21]!==m?(b=m("chat.userAskQuestion.skip"),e[21]=m,e[22]=b):b=e[22];let _;e[23]!==g||e[24]!==b?(_=r.jsx(le,{type:"button",variant:"outline",size:"sm",onClick:g,className:"h-7",children:b}),e[23]=g,e[24]=b,e[25]=_):_=e[25];let y;e[26]!==u.isAllAnswered||e[27]!==u.isCurrentAnswered||e[28]!==u.submitOrAdvance||e[29]!==n?(y=r.jsx(by,{isStreaming:n,isAllAnswered:u.isAllAnswered,isCurrentAnswered:u.isCurrentAnswered,onAdvanceOrSubmit:u.submitOrAdvance}),e[26]=u.isAllAnswered,e[27]=u.isCurrentAnswered,e[28]=u.submitOrAdvance,e[29]=n,e[30]=y):y=e[30];let L;e[31]!==_||e[32]!==y?(L=r.jsxs(r.Fragment,{children:[_,y]}),e[31]=_,e[32]=y,e[33]=L):L=e[33];const w=L;if(s.length===1){const $=s[0];if(!$?.input)return null;const B=u.form;let z;e[34]!==u?(z=ee=>{ee.preventDefault(),u.submit()},e[34]=u,e[35]=z):z=e[35];let K;e[36]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(Od,{size:14}),e[36]=K):K=e[36];let Y;e[37]!==m?(Y=m("chat.userAskQuestion.questionPending"),e[37]=m,e[38]=Y):Y=e[38];let Q;e[39]!==$.input?.prompt||e[40]!==m?(Q=$.input?.prompt??m("chat.userAskQuestion.question"),e[39]=$.input?.prompt,e[40]=m,e[41]=Q):Q=e[41];const q=$.input;let H;e[42]!==u.form.control||e[43]!==$.toolCallId||e[44]!==q?(H=r.jsx(mh,{input:q,control:u.form.control,toolCallId:$.toolCallId}),e[42]=u.form.control,e[43]=$.toolCallId,e[44]=q,e[45]=H):H=e[45];let U;e[46]!==w||e[47]!==Y||e[48]!==Q||e[49]!==H?(U=r.jsx(ai,{icon:K,label:Y,title:Q,defaultExpanded:!0,footerRight:w,children:H}),e[46]=w,e[47]=Y,e[48]=Q,e[49]=H,e[50]=U):U=e[50];let X;e[51]!==z||e[52]!==U?(X=r.jsx("form",{onSubmit:z,autoComplete:"off",children:U}),e[51]=z,e[52]=U,e[53]=X):X=e[53];let J;return e[54]!==u.form||e[55]!==X?(J=r.jsx(Md,{...B,children:X}),e[54]=u.form,e[55]=X,e[56]=J):J=e[56],J}const j=u.form;let S;e[57]!==u?(S=$=>{$.preventDefault(),u.submit()},e[57]=u,e[58]=S):S=e[58];let k;e[59]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Od,{size:14}),e[59]=k):k=e[59];let C;e[60]!==m?(C=m("chat.userAskQuestion.questionPending"),e[60]=m,e[61]=C):C=e[61];const A=u.currentIndex+1;let P;e[62]!==s.length||e[63]!==m||e[64]!==A?(P=m("chat.userAskQuestion.questionCount",{current:A,total:s.length}),e[62]=s.length,e[63]=m,e[64]=A,e[65]=P):P=e[65];let V;e[66]!==f?.input?.prompt||e[67]!==m?(V=f?.input?.prompt??m("chat.userAskQuestion.question"),e[66]=f?.input?.prompt,e[67]=m,e[68]=V):V=e[68];const T=u.activeKey,R=u.setActiveKey;let E;if(e[69]!==u.form||e[70]!==s){let $;e[72]!==u.form?($=B=>r.jsx(ji,{value:B.toolCallId,className:"mt-0",children:r.jsx(mh,{input:B.input,control:u.form.control,toolCallId:B.toolCallId})},B.toolCallId),e[72]=u.form,e[73]=$):$=e[73],E=s.map($),e[69]=u.form,e[70]=s,e[71]=E}else E=e[71];let I;e[74]!==u.activeKey||e[75]!==u.setActiveKey||e[76]!==E?(I=r.jsx(Er,{value:T,onValueChange:R,children:E}),e[74]=u.activeKey,e[75]=u.setActiveKey,e[76]=E,e[77]=I):I=e[77];let D;e[78]!==v||e[79]!==w||e[80]!==C||e[81]!==P||e[82]!==V||e[83]!==I?(D=r.jsx(ai,{icon:k,label:C,count:P,title:V,defaultExpanded:!0,footerLeft:v,footerRight:w,children:I}),e[78]=v,e[79]=w,e[80]=C,e[81]=P,e[82]=V,e[83]=I,e[84]=D):D=e[84];let M;e[85]!==S||e[86]!==D?(M=r.jsx("form",{onSubmit:S,autoComplete:"off",children:D}),e[85]=S,e[86]=D,e[87]=M):M=e[87];let O;return e[88]!==u.form||e[89]!==M?(O=r.jsx(Md,{...j,children:M}),e[88]=u.form,e[89]=M,e[90]=O):O=e[90],O}function Fy(t){return!!pp(t)}function zy(t){return t.toolCallId}function Ky(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function Uy(t){return{toolCallId:t.toolCallId,input:t.input}}function Hy(){const t=F.c(5),e=oe();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Od,{className:"size-5 text-muted-foreground shimmer"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("chat.userAskQuestion.preparingQuestion"),t[1]=e,t[2]=n):n=t[2];let i;return t[3]!==n?(i=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[s,r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:n})]}),t[3]=n,t[4]=i):i=t[4],i}function xp(t){const e=F.c(7),{userAskParts:s,isStreaming:n,onSubmit:i}=t;let o;e[0]!==s?(o=s.filter(Wy),e[0]=s,e[1]=o):o=e[1];const a=o;if(a.length===0){if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Hy,{}),e[2]=c):c=e[2],c}return null}let l;return e[3]!==n||e[4]!==i||e[5]!==a?(l=r.jsx(By,{parts:a,isStreaming:n,onSubmit:i}),e[3]=n,e[4]=i,e[5]=a,e[6]=l):l=e[6],l}function Wy(t){return t.state==="input-available"}function qy(t){const e=t.filter(o=>o.status==="in_progress"),s=t.filter(o=>o.status==="completed").length,n=t.length;if(n>0&&s===n)return{icon:"completed",activity:"All done",progress:`${n}/${n}`};const[i]=e;return i&&e.length===1?{icon:"in_progress",activity:i.activeForm,progress:`${s}/${n} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${s}/${n} done`}:s>0?{icon:"pending",activity:`${n-s} pending`,progress:`${s}/${n} done`}:{icon:"pending",activity:`${n} todos`,progress:"not started"}}function Gy(t){const e=F.c(13),{todos:s}=t;if(s.length===0)return null;let n;e[0]!==s?(n=qy(s),e[0]=s,e[1]=n):n=e[1];const i=n;let o;e[2]!==i.icon?(o=r.jsx(Qy,{status:i.icon}),e[2]=i.icon,e[3]=o):o=e[3];const a=i.activity,l=i.progress;let c;e[4]!==s?(c=s.map(Yy),e[4]=s,e[5]=c):c=e[5];let d;e[6]!==c?(d=r.jsx("ul",{"data-testid":"todos-list",className:"flex flex-col px-2 max-h-[40vh] overflow-y-auto",children:c}),e[6]=c,e[7]=d):d=e[7];let h;return e[8]!==i.activity||e[9]!==i.progress||e[10]!==o||e[11]!==d?(h=r.jsx(ai,{icon:o,label:a,count:l,defaultExpanded:!1,children:d}),e[8]=i.activity,e[9]=i.progress,e[10]=o,e[11]=d,e[12]=h):h=e[12],h}function Yy(t,e){return r.jsx(Jy,{todo:t},e)}function Jy(t){const e=F.c(14),{todo:s}=t,n=s.status==="completed",o=s.status==="in_progress"?s.activeForm:s.content;let a;e[0]!==s.status?(a=r.jsx(Xy,{status:s.status}),e[0]=s.status,e[1]=a):a=e[1];const l=n&&"text-muted-foreground";let c;e[2]!==l?(c=ie("relative text-sm leading-snug pt-px select-none",l),e[2]=l,e[3]=c):c=e[3];const d=n?"100%":"0%",h=n?"width 300ms ease 200ms":"width 150ms ease";let u;e[4]!==d||e[5]!==h?(u=r.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:d,transition:h}}),e[4]=d,e[5]=h,e[6]=u):u=e[6];let f;e[7]!==o||e[8]!==c||e[9]!==u?(f=r.jsxs("span",{className:c,children:[o,u]}),e[7]=o,e[8]=c,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==a||e[12]!==f?(m=r.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,f]}),e[11]=a,e[12]=f,e[13]=m):m=e[13],m}function Xy(t){const e=F.c(4),{status:s}=t,n=s==="completed"?"true":void 0,i=s==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("svg",{viewBox:"0 0 21 21",children:r.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=o):o=e[0];let a;return e[1]!==n||e[2]!==i?(a=r.jsx("div",{className:"todo-cb mt-0.5","data-checked":n,"data-progress":i,"aria-hidden":"true",children:o}),e[1]=n,e[2]=i,e[3]=a):a=e[3],a}function Qy(t){const e=F.c(3),{status:s}=t;if(s==="completed"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:r.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:r.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=i):i=e[0],i}if(s==="in_progress"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=i):i=e[1],i}let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=n):n=e[2],n}const Zy={usd:[{dollars:10,labelKey:"chat.creditsExhaustedBanner.tierStarter"},{dollars:20,labelKey:"chat.creditsExhaustedBanner.tierPopular"},{dollars:100,labelKey:"chat.creditsExhaustedBanner.tierBestValue"}],brl:[{dollars:50,labelKey:"chat.creditsExhaustedBanner.tierStarter"},{dollars:100,labelKey:"chat.creditsExhaustedBanner.tierPopular"},{dollars:500,labelKey:"chat.creditsExhaustedBanner.tierBestValue"}]},e_=["chat.creditsExhaustedBanner.benefit1","chat.creditsExhaustedBanner.benefit2","chat.creditsExhaustedBanner.benefit3"];function vp(t){const e=F.c(65),{onDismiss:s}=t,{org:n}=ze(),i=jt(),{decoKeyId:o}=f9(),a=Fs(),l=oe(),[c,d]=N.useState(""),[h,u]=N.useState(!1),[f,m]=N.useState("usd"),p=f==="brl"?"R$":"$";let g,x;e[0]!==n.id?(g=()=>{Fe("credits_exhausted_shown",{organization_id:n.id})},x=[n.id],e[0]=n.id,e[1]=g,e[2]=x):(g=e[1],x=e[2]),N.useEffect(g,x);let v;e[3]!==f||e[4]!==a?(v=async q=>{const{url:H}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:q,currency:f});return H},e[3]=f,e[4]=a,e[5]=v):v=e[5];let b;e[6]!==s?(b=q=>{q&&window.open(q,"_blank","noopener,noreferrer"),s?.()},e[6]=s,e[7]=b):b=e[7];let _;e[8]!==l?(_=q=>{ve.error(l("chat.creditsExhaustedBanner.topupError",{error:q.message}))},e[8]=l,e[9]=_):_=e[9];let y;e[10]!==v||e[11]!==b||e[12]!==_?(y={mutationFn:v,onSuccess:b,onError:_},e[10]=v,e[11]=b,e[12]=_,e[13]=y):y=e[13];const{mutate:L,isPending:w}=Ys(y),j=parseFloat(c),S=!isNaN(j)&&j>=1;let k;e[14]!==s?(k=q=>!q&&s?.(),e[14]=s,e[15]=k):k=e[15];let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[16]=C):C=e[16];let A;e[17]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:C.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[17]=A):A=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),e[18]=P):P=e[18];let V;e[19]!==l?(V=l("chat.creditsExhaustedBanner.title"),e[19]=l,e[20]=V):V=e[20];let T;e[21]!==V?(T=r.jsx(ds,{className:"text-xl font-semibold tracking-tight",children:V}),e[21]=V,e[22]=T):T=e[22];let R;e[23]!==l?(R=l("chat.creditsExhaustedBanner.description"),e[23]=l,e[24]=R):R=e[24];let E;e[25]!==R?(E=r.jsx(On,{className:"mt-1.5 text-sm leading-relaxed",children:R}),e[25]=R,e[26]=E):E=e[26];let I;e[27]!==T||e[28]!==E?(I=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[A,r.jsxs(cs,{className:"relative gap-4",children:[P,r.jsxs("div",{children:[T,E]})]})]}),e[27]=T,e[28]=E,e[29]=I):I=e[29];let D;e[30]!==f||e[31]!==p||e[32]!==c||e[33]!==j||e[34]!==o||e[35]!==S||e[36]!==w||e[37]!==h||e[38]!==l||e[39]!==L?(D=o&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(h9,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:q=>{q&&m(q)},children:[r.jsx(Mo,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Mo,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Zy[f].map(q=>{const{dollars:H,labelKey:U}=q;return r.jsxs("button",{type:"button",disabled:w,onClick:()=>{Fe("credits_topup_clicked",{amount_cents:H*100,currency:f,tier_label:U,source:"exhausted_banner"}),L(H*100)},className:ie("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,H]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:l(U)})]},H)})}),h?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(et,{type:"number",min:"1",step:"1",placeholder:l("chat.creditsExhaustedBanner.customPlaceholder"),value:c,onChange:q=>d(q.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(le,{className:"h-10",disabled:!S||w,onClick:()=>{Fe("credits_topup_clicked",{amount_cents:Math.round(j*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),L(Math.round(j*100))},children:l(w?"chat.creditsExhaustedBanner.opening":"chat.creditsExhaustedBanner.add")})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>u(!0),children:l("chat.creditsExhaustedBanner.enterCustom")})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:e_.map(q=>r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(ns,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:l(q)})]},q))})]}),e[30]=f,e[31]=p,e[32]=c,e[33]=j,e[34]=o,e[35]=S,e[36]=w,e[37]=h,e[38]=l,e[39]=L,e[40]=D):D=e[40];let M;e[41]!==l?(M=l("chat.creditsExhaustedBanner.dismiss"),e[41]=l,e[42]=M):M=e[42];let O;e[43]!==s||e[44]!==M?(O=r.jsx(le,{variant:"ghost",size:"sm",onClick:s,children:M}),e[43]=s,e[44]=M,e[45]=O):O=e[45];let $;e[46]!==i||e[47]!==s||e[48]!==n.slug?($=()=>{i({to:"/$org/settings/ai-providers",params:{org:n.slug}}),s?.()},e[46]=i,e[47]=s,e[48]=n.slug,e[49]=$):$=e[49];let B;e[50]!==l?(B=l("chat.creditsExhaustedBanner.manageProviders"),e[50]=l,e[51]=B):B=e[51];let z;e[52]!==$||e[53]!==B?(z=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:$,children:B}),e[52]=$,e[53]=B,e[54]=z):z=e[54];let K;e[55]!==O||e[56]!==z?(K=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[O,z]}),e[55]=O,e[56]=z,e[57]=K):K=e[57];let Y;e[58]!==I||e[59]!==D||e[60]!==K?(Y=r.jsxs(Yt,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:t_,children:[I,D,K]}),e[58]=I,e[59]=D,e[60]=K,e[61]=Y):Y=e[61];let Q;return e[62]!==Y||e[63]!==k?(Q=r.jsx(Jt,{open:!0,onOpenChange:k,children:Y}),e[62]=Y,e[63]=k,e[64]=Q):Q=e[64],Q}function t_(t){return t.preventDefault()}function s_(){const t=F.c(24),e=oe(),s=hi(),n=$m(),[i,o]=N.useState(!1);if(!(s?.lockedSandbox==="user-desktop")||!n.ready||n.online)return null;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(sc,{size:14}),t[0]=l):l=t[0];let c;t[1]!==e?(c=e("chat.desktopOfflineBanner.label"),t[1]=e,t[2]=c):c=t[2];let d;t[3]!==e?(d=e("chat.desktopOfflineBanner.title"),t[3]=e,t[4]=d):d=t[4];let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),t[5]=h):h=t[5];let u;t[6]!==e?(u=e("chat.desktopOfflineBanner.reconnectButton"),t[6]=e,t[7]=u):u=t[7];let f;t[8]!==u?(f=r.jsx(le,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:h,children:u}),t[8]=u,t[9]=f):f=t[9];let m;t[10]!==e?(m=e("chat.desktopOfflineBanner.instructions"),t[10]=e,t[11]=m):m=t[11];let p;t[12]!==m?(p=r.jsx("p",{className:"mx-4 text-xs text-muted-foreground",children:m}),t[12]=m,t[13]=p):p=t[13];let g;t[14]!==c||t[15]!==d||t[16]!==f||t[17]!==p?(g=r.jsx(ai,{icon:l,label:c,title:d,defaultExpanded:!0,variant:"warning",footerRight:f,children:p}),t[14]=c,t[15]=d,t[16]=f,t[17]=p,t[18]=g):g=t[18];let x;t[19]!==i?(x=r.jsx(ub,{open:i,onOpenChange:o}),t[19]=i,t[20]=x):x=t[20];let v;return t[21]!==g||t[22]!==x?(v=r.jsxs(r.Fragment,{children:[g,x]}),t[21]=g,t[22]=x,t[23]=v):v=t[23],v}function n_(t){const e=t.trim(),s=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),n=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),i=/failed to fetch|networkerror|load failed|offline/i.test(e),o=/timeout|timed out|aborted|deadline/i.test(e),a=e.length>240,l=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(l){const c=l[1]?.trim().replace(/\.$/,"");return{summary:c?`Your sandbox didn't finish starting up (${c}). Try again.`:"Your sandbox didn't finish starting up. Try again.",rawDetails:t}}return/link_unavailable|user_desktop_link_/i.test(e)?/user_desktop_link_capability_missing/i.test(e)?{summary:"Your desktop is connected, but the CLI this chat uses wasn't detected there. Install it and sign in on your desktop, then try again.",rawDetails:t}:{summary:"Your desktop is offline. Run `bunx decocms@latest link` in a terminal on it, then try again.",rawDetails:t}:n||s&&a?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:i?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:o?{summary:"That took longer than expected. Try again.",rawDetails:t}:s||a?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const i_={length:"chat.highlight.warningDescriptionLength","content-filter":"chat.highlight.warningDescriptionContentFilter","tool-calls":"chat.highlight.warningDescriptionToolCalls"};function jl(t){const e=F.c(29),s=oe(),{variant:n,onDismiss:i}=t,o=n==="error";let a;e[0]!==o||e[1]!==s?(a=s(o?"chat.highlight.errorOccurred":"chat.highlight.responseIncomplete"),e[0]=o,e[1]=s,e[2]=a):a=e[2];const l=a,c=o?jn:kr;let d;e[3]!==t.error||e[4]!==t.finishReason||e[5]!==t.variant||e[6]!==s?(d=t.variant==="error"?t.error.message:(()=>{const b=i_[t.finishReason];return b?s(b):s("chat.highlight.responseStoppedUnexpectedly",{reason:t.finishReason})})(),e[3]=t.error,e[4]=t.finishReason,e[5]=t.variant,e[6]=s,e[7]=d):d=e[7];const h=d;let u;e[8]!==o||e[9]!==h?(u=o?n_(h):{summary:h,rawDetails:null},e[8]=o,e[9]=h,e[10]=u):u=e[10];const{summary:f,rawDetails:m}=u;let p;e[11]!==c?(p=r.jsx(c,{size:14}),e[11]=c,e[12]=p):p=e[12];let g;e[13]!==o||e[14]!==t.onContinue||e[15]!==t.onFixInChat||e[16]!==s?(g=o?r.jsx(le,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:s("chat.highlight.fixInChat")}):r.jsx(le,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:s("chat.highlight.continue")}),e[13]=o,e[14]=t.onContinue,e[15]=t.onFixInChat,e[16]=s,e[17]=g):g=e[17];let x;e[18]!==m||e[19]!==s?(x=m?r.jsxs("details",{className:"group mx-4",children:[r.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[r.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m4.5 3 3 3-3 3"})}),r.jsx("span",{className:"group-open:hidden",children:s("chat.highlight.showTechnicalDetails")}),r.jsx("span",{className:"hidden group-open:inline",children:s("chat.highlight.hideTechnicalDetails")})]}),r.jsxs("div",{className:"relative mt-2",children:[r.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(m).then(()=>ve.success(s("chat.highlight.copiedToClipboard"))).catch(()=>ve.error(s("chat.highlight.couldNotCopy")))},"aria-label":s("chat.highlight.copyErrorDetails"),title:s("chat.highlight.copy"),className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:r.jsx(Vs,{className:"size-3.5"})}),r.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:m})]})]}):null,e[18]=m,e[19]=s,e[20]=x):x=e[20];let v;return e[21]!==l||e[22]!==i||e[23]!==f||e[24]!==p||e[25]!==g||e[26]!==x||e[27]!==n?(v=r.jsx(ai,{icon:p,label:l,title:f,defaultExpanded:!0,variant:n,onClose:i,footerRight:g,children:x}),e[21]=l,e[22]=i,e[23]=f,e[24]=p,e[25]=g,e[26]=x,e[27]=n,e[28]=v):v=e[28],v}function lc(){const t=F.c(67),e=oe(),{error:s,clearError:n,finishReason:i,clearFinishReason:o,messages:a,isStreaming:l,submit:c,sendMessage:d}=Js(),[h,u]=di(),{virtualMcpId:f,createTaskWithMessage:m}=ls(),{chatMode:p,simpleModeTier:g}=Bs();let x;t[0]!==p||t[1]!==g||t[2]!==f?(x=G=>({tier:g,mode:p,toolApprovalLevel:G,agent:f?{id:f}:void 0}),t[0]=p,t[1]=g,t[2]=f,t[3]=x):x=t[3];const v=x;let b;t[4]!==h.toolApprovalLevel?(b=h.toolApprovalLevel??Ex(),t[4]=h.toolApprovalLevel,t[5]=b):b=t[5];const _=b,y=a.at(-1),L=y?.role==="assistant"?y.parts:[],w=L.filter(l_),j=ap(L),S=rp(L);let k;t[6]!==s||t[7]!==d||t[8]!==e?(k=()=>{if(s){const te={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e("chat.highlight.fixInChatMessage",{error:s.message})}]}]};d(te)}},t[6]=s,t[7]=d,t[8]=e,t[9]=k):k=t[9];const C=k;let A;t[10]!==d||t[11]!==e?(A=()=>{const G={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e("chat.highlight.pleaseContinue")}]}]};d(G)},t[10]=d,t[11]=e,t[12]=A):A=t[12];const P=A;let V;t[13]!==v||t[14]!==_||t[15]!==c?(V=(G,te)=>{c({kind:"toolOutput",toolCallId:G.toolCallId,output:{response:te}},v(_))},t[13]=v,t[14]=_,t[15]=c,t[16]=V):V=t[16];const T=V;let R;t[17]!==m||t[18]!==h||t[19]!==u||t[20]!==e||t[21]!==f?(R=G=>{u({...h,toolApprovalLevel:"auto"}),m({virtualMcpId:f,message:{parts:[{type:"text",text:e("chat.highlight.implementPlanMessage",{plan:G})}]}})},t[17]=m,t[18]=h,t[19]=u,t[20]=e,t[21]=f,t[22]=R):R=t[22];const E=R,I=a_;let D;t[23]!==v||t[24]!==c?(D=(G,te,se,re)=>{c({kind:"approval",approvalId:G,approved:te,...se?{reason:se}:{}},v(re))},t[23]=v,t[24]=c,t[25]=D):D=t[25];const M=D,O=lp();if(O.isCreditExhausted){let G;return t[26]!==n?(G=r.jsx(vp,{onDismiss:n}),t[26]=n,t[27]=G):G=t[27],G}const{showError:$,showWarning:B,hasApprovals:z}=O,K=w.map(o_).join("|"),Y=op(j)?.toolCallId??"",Q=S.map(r_).join("|");let q;t[28]!==O.todos?(q=r.jsx(Gy,{todos:O.todos}),t[28]=O.todos,t[29]=q):q=t[29];let H;t[30]===Symbol.for("react.memo_cache_sentinel")?(H=r.jsx(s_,{}),t[30]=H):H=t[30];let U;t[31]!==n||t[32]!==s||t[33]!==C||t[34]!==$?(U=$&&r.jsx(jl,{variant:"error",error:s,onDismiss:n,onFixInChat:C}),t[31]=n,t[32]=s,t[33]=C,t[34]=$,t[35]=U):U=t[35];let X;t[36]!==o||t[37]!==i||t[38]!==P||t[39]!==B?(X=B&&r.jsx(jl,{variant:"warning",finishReason:i,onDismiss:o,onContinue:P}),t[36]=o,t[37]=i,t[38]=P,t[39]=B,t[40]=X):X=t[40];let J;t[41]!==Q||t[42]!==M||t[43]!==z||t[44]!==l||t[45]!==S?(J=z&&r.jsx(Ty,{approvals:S,isStreaming:l,onRespond:M},Q),t[41]=Q,t[42]=M,t[43]=z,t[44]=l,t[45]=S,t[46]=J):J=t[46];let ee;t[47]!==O.hasPlans||t[48]!==E||t[49]!==I||t[50]!==l||t[51]!==j||t[52]!==Y?(ee=O.hasPlans&&r.jsx(Ey,{plans:j,isStreaming:l,onApprove:E,onDismiss:I},Y),t[47]=O.hasPlans,t[48]=E,t[49]=I,t[50]=l,t[51]=j,t[52]=Y,t[53]=ee):ee=t[53];let W;t[54]!==O.isWaitingForUserInput||t[55]!==T||t[56]!==l||t[57]!==K||t[58]!==w?(W=O.isWaitingForUserInput&&r.jsx(xp,{userAskParts:w,isStreaming:l,onSubmit:T},K),t[54]=O.isWaitingForUserInput,t[55]=T,t[56]=l,t[57]=K,t[58]=w,t[59]=W):W=t[59];let Z;return t[60]!==X||t[61]!==J||t[62]!==ee||t[63]!==W||t[64]!==q||t[65]!==U?(Z=r.jsxs("div",{className:"absolute bottom-full left-0 right-0",children:[q,H,U,X,J,ee,W]}),t[60]=X,t[61]=J,t[62]=ee,t[63]=W,t[64]=q,t[65]=U,t[66]=Z):Z=t[66],Z}function r_(t){return t.approvalId}function o_(t){return t.toolCallId}function a_(){document.querySelector("[data-chat-input]")?.focus()}function l_(t){return t.type==="tool-user_ask"}lc.Error=function(e){return r.jsx(jl,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};lc.Warning=function(e){return r.jsx(jl,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};lc.UserAskQuestion=xp;function c_(t){const e=F.c(17),{taskId:s}=t,n=oe(),i=Bm(s),o=Zx(i),a=ev(),{stop:l,removeLocalMessage:c}=Js();if(o.length===0)return null;let d;e[0]!==l?(d=()=>{l()},e[0]=l,e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(X0,{size:14}),e[2]=h):h=e[2];let u;e[3]!==d?(u=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,children:h})}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==n?(f=n("chat.queueTray.sendNow"),e[5]=n,e[6]=f):f=e[6];let m;e[7]!==f?(m=r.jsx(He,{side:"top",children:r.jsx("p",{className:"text-xs",children:f})}),e[7]=f,e[8]=m):m=e[8];let p;e[9]!==u||e[10]!==m?(p=r.jsxs(We,{delayDuration:400,children:[u,m]}),e[9]=u,e[10]=m,e[11]=p):p=e[11];let g;return e[12]!==a||e[13]!==c||e[14]!==n||e[15]!==s?(g=(x,v)=>r.jsxs("div",{className:"group/queuerow flex items-center gap-2 px-3 py-1.5",children:[r.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground dark:bg-background",children:v+1}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:x.text}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/queuerow:opacity-100",children:r.jsx(le,{type:"button",variant:"ghost",size:"icon-sm",title:n("chat.queueTray.removeFromQueue"),onClick:()=>{a.cancel(s,x.messageId).then(b=>{b&&(tv(s,x.messageId),c(x.messageId))})},children:r.jsx(In,{className:"size-3.5"})})})]},x.messageId),e[12]=a,e[13]=c,e[14]=n,e[15]=s,e[16]=g):g=e[16],r.jsxs("div",{className:"mb-1 overflow-hidden rounded-2xl border border-border bg-card dark:bg-muted",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border py-1.5 pr-2 pl-3 text-xs text-muted-foreground",children:[r.jsx("span",{children:n(o.length===1?"chat.queueTray.queuedMessage":"chat.queueTray.queuedMessages",{count:o.length})}),p]}),o.map(g)]})}const d_={fast:{modelId:"claude-code:haiku",label:"Haiku 4.5"},smart:{modelId:"claude-code:sonnet",label:"Sonnet 5"},thinking:{modelId:"claude-code:opus-1m",label:"Opus 4.8 1M"}},u_={fast:{modelId:"codex:gpt-5.6-luna",label:"GPT-5.6 Luna"},smart:{modelId:"codex:gpt-5.6-terra",label:"GPT-5.6 Terra"},thinking:{modelId:"codex:gpt-5.6-sol",label:"GPT-5.6 Sol"}};function h_(t){return t==="claude-code"?d_:t==="codex"?u_:null}function ph(t,e){return h_(t)?.[e]??null}const f_={decopilot:"cloud-decopilot","claude-code-desktop":"local-claude-code","codex-desktop":"local-codex"};function m_(t){return t===null?"cloud-decopilot":f_[t]}function p_(){const t=F.c(2),{pendingAgentOption:e}=Bs();let s;return t[0]!==e?(s=m_(e),t[0]=e,t[1]=s):s=t[1],s}function g_(){return Bs().simpleModeTier}function x_(){return Bs().setSimpleModeTier}const v_={fast:"Quicker responses",smart:"Balanced quality",thinking:"Deeper reasoning"};function bp(t,e){return t==="local-claude-code"?ph("claude-code",e)?.label??null:t==="local-codex"?ph("codex",e)?.label??null:v_[e]}function A9(){const t=F.c(11),e=$m(),s=km();let n;t[0]!==e.capabilities||t[1]!==e.online?(n=e.online&&e.capabilities.includes("claude-code"),t[0]=e.capabilities,t[1]=e.online,t[2]=n):n=t[2];let i;t[3]!==e.capabilities||t[4]!==e.online?(i=e.online&&e.capabilities.includes("codex"),t[3]=e.capabilities,t[4]=e.online,t[5]=i):i=t[5];let o;return t[6]!==e.online||t[7]!==s.runtime.agentSandbox||t[8]!==n||t[9]!==i?(o={agentSandbox:s.runtime.agentSandbox,userDesktop:e.online,claudeCode:n,codex:i},t[6]=e.online,t[7]=s.runtime.agentSandbox,t[8]=n,t[9]=i,t[10]=o):o=t[10],o}const yp=["fast","smart","thinking"];function b_(t){const e=F.c(33),{tier:s,pillIcon:n,pillLabel:i,groups:o,header:a}=t,l=oe();let c;e[0]!==l?(c={fast:l("chat.tierTrigger.tierFast"),smart:l("chat.tierTrigger.tierSmart"),thinking:l("chat.tierTrigger.tierThinking")},e[0]=l,e[1]=c):c=e[1];const d=c,[h,u]=N.useState(!1);let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=P=>{P.onSelect(),u(!1)},e[2]=f):f=e[2];const m=f,p=i??d[s];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=ie("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),e[3]=g):g=e[3];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=ie("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),e[4]=x):x=e[4];const v=d[s];let b;e[5]!==v?(b=r.jsx("span",{className:x,children:v}),e[5]=v,e[6]=b):b=e[6];let _;e[7]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(is,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[7]=_):_=e[7];let y;e[8]!==n||e[9]!==p||e[10]!==b?(y=r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"inline-flex min-w-0 shrink",children:r.jsx(Ts,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"ghost",size:"default","aria-label":p,className:g,children:[n,b,_]})})})}),e[8]=n,e[9]=p,e[10]=b,e[11]=y):y=e[11];let L;e[12]!==p?(L=r.jsx(He,{children:p}),e[12]=p,e[13]=L):L=e[13];let w;e[14]!==y||e[15]!==L?(w=r.jsxs(We,{children:[y,L]}),e[14]=y,e[15]=L,e[16]=w):w=e[16];let j;e[17]!==a?(j=a&&r.jsx("div",{className:"mb-1 border-b border-border/60 pb-1",children:a}),e[17]=a,e[18]=j):j=e[18];let S;if(e[19]!==o||e[20]!==l){let P;e[22]!==l?(P=V=>r.jsxs("div",{className:"flex flex-col",children:[V.label&&r.jsx("div",{className:"flex items-center gap-1.5 px-2 pt-1.5 pb-0.5 text-xs font-medium text-muted-foreground",children:r.jsx("span",{className:"truncate",children:V.label})}),V.rows.map(T=>r.jsxs("button",{type:"button",role:"menuitem","aria-label":V.label?`${V.label} ${T.title}`:T.title,onClick:()=>m(T),className:ie("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),children:[T.icon&&r.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:T.icon}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-sm",children:T.title}),T.subtitle&&r.jsx("div",{className:"text-xs text-muted-foreground",children:T.subtitle})]}),T.active&&r.jsx("span",{title:l("chat.tierTrigger.selected"),children:r.jsx(ns,{size:14,className:"text-foreground mt-0.5"})})]},T.key))]},V.key),e[22]=l,e[23]=P):P=e[23],S=o.map(P),e[19]=o,e[20]=l,e[21]=S}else S=e[21];let k;e[24]!==S?(k=r.jsx("div",{role:"menu",className:"flex flex-col",children:S}),e[24]=S,e[25]=k):k=e[25];let C;e[26]!==j||e[27]!==k?(C=r.jsxs(As,{align:"end",className:"p-1 w-64",children:[j,k]}),e[26]=j,e[27]=k,e[28]=C):C=e[28];let A;return e[29]!==h||e[30]!==w||e[31]!==C?(A=r.jsxs(Es,{open:h,onOpenChange:u,children:[w,C]}),e[29]=h,e[30]=w,e[31]=C,e[32]=A):A=e[32],A}function gh(t){return t==="fast"?r.jsx(n9,{size:16}):t==="thinking"?r.jsx(o2,{size:16}):r.jsx(ei,{size:16})}const y_="flex items-center justify-center gap-1.5 flex-1 rounded-md px-2 py-1.5 text-xs font-medium transition-colors min-w-0",__="bg-background text-foreground shadow-sm",L_="text-muted-foreground hover:text-foreground";function S_(t){const e=F.c(7),{options:s}=t,n=oe();let i;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>r.jsxs("button",{type:"button",onClick:l.onSelect,className:ie(y_,l.active?__:L_),title:l.active?n("chat.tierTrigger.selected"):void 0,children:[l.icon,r.jsx("span",{className:"truncate",children:l.label})]},l.key),e[3]=n,e[4]=a):a=e[4],i=s.map(a),e[0]=s,e[1]=n,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=r.jsx("div",{className:"flex items-center gap-1 p-1 rounded-lg bg-muted",children:i}),e[5]=i,e[6]=o):o=e[6],o}function w_(){const t=F.c(24),e=oe(),{pendingHarnessId:s,setPendingAgentOption:n}=Bs(),i=A9(),o=s==="claude-code"||s==="codex";let a;t[0]!==i?(a=sv(i)??"claude-code-desktop",t[0]=i,t[1]=a):a=t[1];const l=a;let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(_6,{size:14}),t[2]=c):c=t[2];let d;t[3]!==e?(d=e("chat.tierTrigger.runtimeCloud"),t[3]=e,t[4]=d):d=t[4];const h=!o;let u;t[5]!==n?(u=()=>n("decopilot"),t[5]=n,t[6]=u):u=t[6];let f;t[7]!==d||t[8]!==h||t[9]!==u?(f={key:"cloud",icon:c,label:d,active:h,onSelect:u},t[7]=d,t[8]=h,t[9]=u,t[10]=f):f=t[10];let m;t[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(sc,{size:14}),t[11]=m):m=t[11];let p;t[12]!==e?(p=e("chat.tierTrigger.runtimeThisDevice"),t[12]=e,t[13]=p):p=t[13];let g;t[14]!==l||t[15]!==n?(g=()=>n(l),t[14]=l,t[15]=n,t[16]=g):g=t[16];let x;t[17]!==o||t[18]!==p||t[19]!==g?(x={key:"local",icon:m,label:p,active:o,onSelect:g},t[17]=o,t[18]=p,t[19]=g,t[20]=x):x=t[20];let v;return t[21]!==f||t[22]!==x?(v=r.jsx("div",{className:"p-1",children:r.jsx(S_,{options:[f,x]})}),t[21]=f,t[22]=x,t[23]=v):v=t[23],v}function xh(t){return{key:t.key,label:t.label,rows:yp.map(e=>({key:`${t.key}-${e}`,icon:t.icon,title:t.tierLabels[e],subtitle:bp(t.mode,e),active:t.isActiveRuntime&&t.currentTier===e,onSelect:()=>{t.setOption(t.option),t.setTier(e)}}))}}function j_(){const t=F.c(37),e=oe(),s=g_(),n=x_(),i=p_(),{pendingHarnessId:o,setPendingAgentOption:a}=Bs(),l=A9(),d=hi()?.isThreadLocked??!1,h=l.claudeCode||l.codex,u=i!=="cloud-decopilot";let f;t[0]!==e?(f=()=>({fast:e("chat.tierTrigger.tierFast"),smart:e("chat.tierTrigger.tierSmart"),thinking:e("chat.tierTrigger.tierThinking")}),t[0]=e,t[1]=f):f=t[1];const m=f;let p,g;if(t[2]!==l.claudeCode||t[3]!==l.codex||t[4]!==m||t[5]!==u||t[6]!==d||t[7]!==o||t[8]!==a||t[9]!==n||t[10]!==e||t[11]!==s){if(g=m(),u){const w=d?o==="claude-code":l.claudeCode||o==="claude-code",j=d?o==="codex":l.codex||o==="codex",S=w&&j,k=[];if(w){let C;t[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(fb,{size:16}),t[14]=C):C=t[14],k.push(xh({key:"claude-code",label:S?e("chat.tierTrigger.runtimeClaudeCode"):void 0,icon:C,mode:"local-claude-code",option:"claude-code-desktop",isActiveRuntime:o==="claude-code",currentTier:s,setOption:a,setTier:n,tierLabels:g}))}if(j){let C;t[15]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(mb,{size:16}),t[15]=C):C=t[15],k.push(xh({key:"codex",label:S?e("chat.tierTrigger.runtimeCodex"):void 0,icon:C,mode:"local-codex",option:"codex-desktop",isActiveRuntime:o==="codex",currentTier:s,setOption:a,setTier:n,tierLabels:g}))}p=k}else{const w={key:"cloud",rows:yp.map(S=>({key:`cloud-${S}`,icon:gh(S),title:g[S],subtitle:bp("cloud-decopilot",S),active:s===S,onSelect:()=>n(S)}))};let j;t[16]!==w?(j=[w],t[16]=w,t[17]=j):j=t[17],p=j}t[2]=l.claudeCode,t[3]=l.codex,t[4]=m,t[5]=u,t[6]=d,t[7]=o,t[8]=a,t[9]=n,t[10]=e,t[11]=s,t[12]=p,t[13]=g}else p=t[12],g=t[13];let x,v,b,_;if(t[18]!==u||t[19]!==o||t[20]!==e||t[21]!==s||t[22]!==g){const w=u?hb(o):null,j=w?.Icon;x=b_,v=s,b=j?r.jsx(j,{size:16}):gh(s),_=w?`${e(w.labelKey)} ${g[s]}`:g[s],t[18]=u,t[19]=o,t[20]=e,t[21]=s,t[22]=g,t[23]=x,t[24]=v,t[25]=b,t[26]=_}else x=t[23],v=t[24],b=t[25],_=t[26];let y;t[27]!==h||t[28]!==d?(y=h&&!d?r.jsx(w_,{}):void 0,t[27]=h,t[28]=d,t[29]=y):y=t[29];let L;return t[30]!==x||t[31]!==p||t[32]!==v||t[33]!==b||t[34]!==_||t[35]!==y?(L=r.jsx(x,{tier:v,pillIcon:b,pillLabel:_,groups:p,header:y}),t[30]=x,t[31]=p,t[32]=v,t[33]=b,t[34]=_,t[35]=y,t[36]=L):L=t[36],L}async function E9(t,e,s,n,i,o){if(!nc(e)){ve.error("Selected model does not support file uploads");return}const a=s.type||"application/octet-stream";if(!pb(a,e)){const c=w2(e).parts.map(h=>o(h)).join(", "),d=e?.title??"This model";i?i({fileName:s.name,modelName:d,accepted:c}):ve.error(`"${s.name}" can't be attached`,{description:`${d} accepts ${c}.`});return}const l=10*1024*1024;if(s.size>l){ve.error(`File "${s.name}" exceeds 10MB limit`);return}try{const c=new FileReader,d=new Promise((f,m)=>{c.onload=()=>{const p=c.result;if(typeof p!="string"){m(new Error("Failed to read file as data URL"));return}const g=p.includes(",")?p.split(",")[1]??p:p;f(g)},c.onerror=m});c.readAsDataURL(s);const h=await d,u={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:h};hv(t,{from:n,to:n},u)}catch(c){console.error("Failed to process file:",c),ve.error(`Failed to load file "${s.name}"`)}}function C_(t){const e=F.c(9),{editor:s,selectedModel:n,onUnsupportedFile:i}=t,o=oe(),a=N.useRef(V_);let l,c;e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==o?(l=()=>{a.current=async(u,f)=>{await E9(s,n,u,f,i,o)}},c=[s,n,i,o],e[0]=s,e[1]=i,e[2]=n,e[3]=o,e[4]=l,e[5]=c):(l=e[4],c=e[5]),N.useEffect(l,c);let d,h;return e[6]!==s?(d=()=>{if(s?.isDestroyed)return;const u=new zv("fileDropHandler");s.state.plugins.find(p=>p.spec.key===u)&&s.unregisterPlugin(u);const m=new Kv({key:u,props:{handleDrop:(p,g,x,v)=>{if(v)return!1;const b=g.dataTransfer?.files;if(!b||b.length===0)return!1;g.preventDefault();const _=p.posAtCoords({left:g.clientX,top:g.clientY});if(!_)return!1;const y=Array.from(b);return(async()=>{let L=_.pos;for(const w of y)await a.current?.(w,L),L=p.state.selection.to})(),!0},handlePaste:(p,g)=>{const x=g.clipboardData?.items;if(!x)return!1;const v=Array.from(x).filter(k_);return v.length===0?!1:(g.preventDefault(),(async()=>{let b=p.state.selection.from;for(const _ of v){const y=_.getAsFile();y&&(await a.current?.(y,b),b=p.state.selection.to)}})(),!0)}}});return s.registerPlugin(m),()=>{s?.isDestroyed||s.unregisterPlugin(u)}},h=[s],e[6]=s,e[7]=d,e[8]=h):(d=e[7],h=e[8]),N.useEffect(d,h),null}function k_(t){return t.kind==="file"}function V_(){return Promise.resolve()}function N_(t){const e=F.c(43),{info:s,onClose:n}=t,i=oe(),o=s!==null;let a;e[0]!==n?(a=P=>!P&&n(),e[0]=n,e[1]=a):a=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=l):l=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:l.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-warning/15 text-warning",children:r.jsx(kr,{size:18})}),e[4]=d):d=e[4];let h;e[5]!==i?(h=i("chat.uploader.fileTypeNotSupported"),e[5]=i,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx(ds,{className:"text-xl font-semibold tracking-tight",children:h}),e[7]=h,e[8]=u):u=e[8];const f=s?.fileName;let m;e[9]!==f?(m=r.jsxs("span",{className:"font-medium text-foreground",children:["“",f,"”"]}),e[9]=f,e[10]=m):m=e[10];let p;e[11]!==i?(p=i("chat.uploader.cantAttachToChat"),e[11]=i,e[12]=p):p=e[12];let g;e[13]!==p||e[14]!==m?(g=r.jsxs(On,{className:"mt-1.5 text-sm leading-relaxed",children:[m," ",p]}),e[13]=p,e[14]=m,e[15]=g):g=e[15];let x;e[16]!==g||e[17]!==u?(x=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[c,r.jsxs(cs,{className:"relative gap-4",children:[d,r.jsxs("div",{children:[u,g]})]})]}),e[16]=g,e[17]=u,e[18]=x):x=e[18];const v=s?.modelName??"";let b;e[19]!==i||e[20]!==v?(b=i("chat.uploader.accepts",{modelName:v}),e[19]=i,e[20]=v,e[21]=b):b=e[21];let _;e[22]!==b?(_=r.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:b}),e[22]=b,e[23]=_):_=e[23];let y;e[24]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(L6,{size:14,className:"text-muted-foreground"}),e[24]=y):y=e[24];const L=s?.accepted;let w;e[25]!==L?(w=r.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[y,r.jsx("span",{className:"capitalize",children:L})]}),e[25]=L,e[26]=w):w=e[26];let j;e[27]!==_||e[28]!==w?(j=r.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:r.jsxs("div",{className:"rounded-xl border border-border p-4",children:[_,w]})}),e[27]=_,e[28]=w,e[29]=j):j=e[29];let S;e[30]!==i?(S=i("chat.uploader.gotIt"),e[30]=i,e[31]=S):S=e[31];let k;e[32]!==n||e[33]!==S?(k=r.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:r.jsx(le,{onClick:n,children:S})}),e[32]=n,e[33]=S,e[34]=k):k=e[34];let C;e[35]!==x||e[36]!==j||e[37]!==k?(C=r.jsxs(Yt,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:T_,children:[x,j,k]}),e[35]=x,e[36]=j,e[37]=k,e[38]=C):C=e[38];let A;return e[39]!==o||e[40]!==a||e[41]!==C?(A=r.jsx(Jt,{open:o,onOpenChange:a,children:C}),e[39]=o,e[40]=a,e[41]=C,e[42]=A):A=e[42],A}function T_(t){return t.preventDefault()}function A_(){const t=F.c(3),[e,s]=N.useState(null);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>s(null),t[0]=n):n=t[0];let i;return t[1]!==e?(i={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:n},t[1]=e,t[2]=i):i=t[2],i}var E_=fv;var P_=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Fd=P_.join(","),_p=typeof Element>"u",Ho=_p?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Cl=!_p&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},kl=function(e,s){var n;s===void 0&&(s=!0);var i=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"inert"),o=i===""||i==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):kl(e.parentNode));return a},R_=function(e){var s,n=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return n===""||n==="true"},D_=function(e,s,n){if(kl(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Fd));return s&&Ho.call(e,Fd)&&i.unshift(e),i=i.filter(n),i},zd=function(e,s,n){for(var i=[],o=Array.from(e);o.length;){var a=o.shift();if(!kl(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=zd(c,!0,n);n.flatten?i.push.apply(i,d):i.push({scopeParent:a,candidates:d})}else{var h=Ho.call(a,Fd);h&&n.filter(a)&&(s||!e.includes(a))&&i.push(a);var u=a.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(a),f=!kl(u,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(a));if(u&&f){var m=zd(u===!0?a.children:u.children,!0,n);n.flatten?i.push.apply(i,m):i.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return i},Lp=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Sp=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||R_(e))&&!Lp(e)?0:e.tabIndex},I_=function(e,s){var n=Sp(e);return n<0&&s&&!Lp(e)?0:n},M_=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},wp=function(e){return e.tagName==="INPUT"},O_=function(e){return wp(e)&&e.type==="hidden"},$_=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(n){return n.tagName==="SUMMARY"});return s},B_=function(e,s){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===s)return e[n]},F_=function(e){if(!e.name)return!0;var s=e.form||Cl(e),n=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=n(window.CSS.escape(e.name));else try{i=n(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var o=B_(i,e.form);return!o||o===e},z_=function(e){return wp(e)&&e.type==="radio"},K_=function(e){return z_(e)&&!F_(e)},U_=function(e){var s,n=e&&Cl(e),i=(s=n)===null||s===void 0?void 0:s.host,o=!1;if(n&&n!==e){var a,l,c;for(o=!!((a=i)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(i)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&i;){var d,h,u;n=Cl(i),i=(d=n)===null||d===void 0?void 0:d.host,o=!!((h=i)!==null&&h!==void 0&&(u=h.ownerDocument)!==null&&u!==void 0&&u.contains(i))}}return o},vh=function(e){var s=e.getBoundingClientRect(),n=s.width,i=s.height;return n===0&&i===0},H_=function(e,s){var n=s.displayCheck,i=s.getShadowRoot;if(n==="full-native"&&"checkVisibility"in e){var o=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(e).visibility==="hidden")return!0;var a=Ho.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(Ho.call(l,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="full-native"||n==="legacy-full"){if(typeof i=="function"){for(var c=e;e;){var d=e.parentElement,h=Cl(e);if(d&&!d.shadowRoot&&i(d)===!0)return vh(e);e.assignedSlot?e=e.assignedSlot:!d&&h!==e.ownerDocument?e=h.host:e=d}e=c}if(U_(e))return!e.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return vh(e);return!1},W_=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var n=0;n<s.children.length;n++){var i=s.children.item(n);if(i.tagName==="LEGEND")return Ho.call(s,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}s=s.parentElement}return!1},q_=function(e,s){return!(s.disabled||O_(s)||H_(s,e)||$_(s)||W_(s))},bh=function(e,s){return!(K_(s)||Sp(s)<0||!q_(e,s))},G_=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},jp=function(e){var s=[],n=[];return e.forEach(function(i,o){var a=!!i.scopeParent,l=a?i.scopeParent:i,c=I_(l,a),d=a?jp(i.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):n.push({documentOrder:o,tabIndex:c,item:i,isScope:a,content:d})}),n.sort(M_).reduce(function(i,o){return o.isScope?i.push.apply(i,o.content):i.push(o.content),i},[]).concat(s)},Cp=function(e,s){s=s||{};var n;return s.getShadowRoot?n=zd([e],s.includeContainer,{filter:bh.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:G_}):n=D_(e,s.includeContainer,bh.bind(null,s)),jp(n)};function Y_(){return/apple/i.test(navigator.vendor)}const yh="data-floating-ui-focusable";function J_(t){let e=t.activeElement;for(;((s=e)==null||(s=s.shadowRoot)==null?void 0:s.activeElement)!=null;){var s;e=e.shadowRoot.activeElement}return e}function Kd(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&Px(s)){let n=e;for(;n;){if(t===n)return!0;n=n.parentNode||n.host}}return!1}function Yr(t){return"composedPath"in t?t.composedPath()[0]:t.target}function Hc(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const s=t;return s.target!=null&&e.contains(s.target)}function X_(t){return t.matches("html,body")}function Wo(t){return t?.ownerDocument||document}function Q_(t){return t?t.hasAttribute(yh)?t:t.querySelector("["+yh+"]")||t:null}function Xa(t,e,s){return s===void 0&&(s=!0),t.filter(i=>{var o;return i.parentId===e&&(!s||((o=i.context)==null?void 0:o.open))}).flatMap(i=>[i,...Xa(t,i.id,s)])}function Z_(t){return"nativeEvent"in t}var e7=typeof document<"u",t7=function(){},Ci=e7?N.useLayoutEffect:t7;const s7={...Vm},n7=s7.useInsertionEffect,i7=n7||(t=>t());function or(t){const e=N.useRef(()=>{});return i7(()=>{e.current=t}),N.useCallback(function(){for(var s=arguments.length,n=new Array(s),i=0;i<s;i++)n[i]=arguments[i];return e.current==null?void 0:e.current(...n)},[])}const kp=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Vp(t,e){const s=Cp(t,kp()),n=s.length;if(n===0)return;const i=J_(Wo(t)),o=s.indexOf(i),a=o===-1?e===1?0:n-1:o+e;return s[a]}function r7(t){return Vp(Wo(t).body,1)||t}function o7(t){return Vp(Wo(t).body,-1)||t}function Wc(t,e){const s=e||t.currentTarget,n=t.relatedTarget;return!n||!Kd(s,n)}function a7(t){Cp(t,kp()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function _h(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const n=s.dataset.tabindex;delete s.dataset.tabindex,n?s.setAttribute("tabindex",n):s.removeAttribute("tabindex")})}const l7="data-floating-ui-focusable",Lh="active",Sh="selected",c7={...Vm};let wh=!1,d7=0;const jh=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+d7++;function u7(){const[t,e]=N.useState(()=>wh?jh():void 0);return Ci(()=>{t==null&&e(jh())},[]),N.useEffect(()=>{wh=!0},[]),t}const h7=c7.useId,P9=h7||u7;function f7(){const t=new Map;return{emit(e,s){var n;(n=t.get(e))==null||n.forEach(i=>i(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var n;(n=t.get(e))==null||n.delete(s)}}}const m7=N.createContext(null),p7=N.createContext(null),Np=()=>{var t;return((t=N.useContext(m7))==null?void 0:t.id)||null},Tp=()=>N.useContext(p7);function R9(t){return"data-floating-ui-"+t}const g7={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},Ch=N.forwardRef(function(e,s){const[n,i]=N.useState();Ci(()=>{Y_()&&i("button")},[]);const o={ref:s,tabIndex:0,role:n,"aria-hidden":n?void 0:!0,[R9("focus-guard")]:"",style:g7};return r.jsx("span",{...e,...o})}),x7={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Ap=N.createContext(null),kh=R9("portal");function v7(t){t===void 0&&(t={});const{id:e,root:s}=t,n=P9(),i=y7(),[o,a]=N.useState(null),l=N.useRef(null);return Ci(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),Ci(()=>{if(!n||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=n,d.setAttribute(kh,""),c.appendChild(d),l.current=d,a(d)},[e,n]),Ci(()=>{if(s===null||!n||l.current)return;let c=s||i?.portalNode;c&&!$x(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const h=document.createElement("div");h.id=n,h.setAttribute(kh,""),c=d||c,c.appendChild(h),l.current=h,a(h)},[e,s,n,i]),o}function b7(t){const{children:e,id:s,root:n,preserveTabOrder:i=!0}=t,o=v7({id:s,root:n}),[a,l]=N.useState(null),c=N.useRef(null),d=N.useRef(null),h=N.useRef(null),u=N.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&i&&!!(n||o);return N.useEffect(()=>{if(!o||!i||f)return;function g(x){o&&Wc(x)&&(x.type==="focusin"?_h:a7)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,i,f]),N.useEffect(()=>{o&&(m||_h(o))},[m,o]),r.jsxs(Ap.Provider,{value:N.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:h,afterInsideRef:u,portalNode:o,setFocusManagerState:l}),[i,o]),children:[p&&o&&r.jsx(Ch,{"data-type":"outside",ref:c,onFocus:g=>{if(Wc(g,o)){var x;(x=h.current)==null||x.focus()}else{const v=a?a.domReference:null,b=o7(v);b?.focus()}}}),p&&o&&r.jsx("span",{"aria-owns":o.id,style:x7}),o&&Zs.createPortal(e,o),p&&o&&r.jsx(Ch,{"data-type":"outside",ref:d,onFocus:g=>{if(Wc(g,o)){var x;(x=u.current)==null||x.focus()}else{const v=a?a.domReference:null,b=r7(v);b?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const y7=()=>N.useContext(Ap),_7={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},L7={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Vh=t=>{var e,s;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(s=t?.outsidePress)!=null?s:!0}};function S7(t,e){e===void 0&&(e={});const{open:s,onOpenChange:n,elements:i,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:h=!1,referencePressEvent:u="pointerdown",ancestorScroll:f=!1,bubbles:m,capture:p}=e,g=Tp(),x=or(typeof c=="function"?c:()=>!1),v=typeof c=="function"?x:c,b=N.useRef(!1),{escapeKey:_,outsidePress:y}=Vh(m),{escapeKey:L,outsidePress:w}=Vh(p),j=N.useRef(!1),S=or(T=>{var R;if(!s||!a||!l||T.key!=="Escape"||j.current)return;const E=(R=o.current.floatingContext)==null?void 0:R.nodeId,I=g?Xa(g.nodesRef.current,E):[];if(!_&&(T.stopPropagation(),I.length>0)){let D=!0;if(I.forEach(M=>{var O;if((O=M.context)!=null&&O.open&&!M.context.dataRef.current.__escapeKeyBubbles){D=!1;return}}),!D)return}n(!1,Z_(T)?T.nativeEvent:T,"escape-key")}),k=or(T=>{var R;const E=()=>{var I;S(T),(I=Yr(T))==null||I.removeEventListener("keydown",E)};(R=Yr(T))==null||R.addEventListener("keydown",E)}),C=or(T=>{var R;const E=o.current.insideReactTree;o.current.insideReactTree=!1;const I=b.current;if(b.current=!1,d==="click"&&I||E||typeof v=="function"&&!v(T))return;const D=Yr(T),M="["+R9("inert")+"]",O=Wo(i.floating).querySelectorAll(M);let $=fn(D)?D:null;for(;$&&!zc($);){const Y=Ix($);if(zc(Y)||!fn(Y))break;$=Y}if(O.length&&fn(D)&&!X_(D)&&!Kd(D,i.floating)&&Array.from(O).every(Y=>!Kd($,Y)))return;if(Mx(D)&&V){const Y=zc(D),Q=Ox(D),q=/auto|scroll/,H=Y||q.test(Q.overflowX),U=Y||q.test(Q.overflowY),X=H&&D.clientWidth>0&&D.scrollWidth>D.clientWidth,J=U&&D.clientHeight>0&&D.scrollHeight>D.clientHeight,ee=Q.direction==="rtl",W=J&&(ee?T.offsetX<=D.offsetWidth-D.clientWidth:T.offsetX>D.clientWidth),Z=X&&T.offsetY>D.clientHeight;if(W||Z)return}const B=(R=o.current.floatingContext)==null?void 0:R.nodeId,z=g&&Xa(g.nodesRef.current,B).some(Y=>{var Q;return Hc(T,(Q=Y.context)==null?void 0:Q.elements.floating)});if(Hc(T,i.floating)||Hc(T,i.domReference)||z)return;const K=g?Xa(g.nodesRef.current,B):[];if(K.length>0){let Y=!0;if(K.forEach(Q=>{var q;if((q=Q.context)!=null&&q.open&&!Q.context.dataRef.current.__outsidePressBubbles){Y=!1;return}}),!Y)return}n(!1,T,"outside-press")}),A=or(T=>{var R;const E=()=>{var I;C(T),(I=Yr(T))==null||I.removeEventListener(d,E)};(R=Yr(T))==null||R.addEventListener(d,E)});N.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=_,o.current.__outsidePressBubbles=y;let T=-1;function R(O){n(!1,O,"ancestor-scroll")}function E(){window.clearTimeout(T),j.current=!0}function I(){T=window.setTimeout(()=>{j.current=!1},Dx()?5:0)}const D=Wo(i.floating);l&&(D.addEventListener("keydown",L?k:S,L),D.addEventListener("compositionstart",E),D.addEventListener("compositionend",I)),v&&D.addEventListener(d,w?A:C,w);let M=[];return f&&(fn(i.domReference)&&(M=Fc(i.domReference)),fn(i.floating)&&(M=M.concat(Fc(i.floating))),!fn(i.reference)&&i.reference&&i.reference.contextElement&&(M=M.concat(Fc(i.reference.contextElement)))),M=M.filter(O=>{var $;return O!==(($=D.defaultView)==null?void 0:$.visualViewport)}),M.forEach(O=>{O.addEventListener("scroll",R,{passive:!0})}),()=>{l&&(D.removeEventListener("keydown",L?k:S,L),D.removeEventListener("compositionstart",E),D.removeEventListener("compositionend",I)),v&&D.removeEventListener(d,w?A:C,w),M.forEach(O=>{O.removeEventListener("scroll",R)}),window.clearTimeout(T)}},[o,i,l,v,d,s,n,f,a,_,y,S,L,k,C,w,A]),N.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const P=N.useMemo(()=>({onKeyDown:S,...h&&{[_7[u]]:T=>{n(!1,T.nativeEvent,"reference-press")},...u!=="click"&&{onClick(T){n(!1,T.nativeEvent,"reference-press")}}}}),[S,n,h,u]),V=N.useMemo(()=>{function T(R){R.button===0&&(b.current=!0)}return{onKeyDown:S,onMouseDown:T,onMouseUp:T,[L7[d]]:()=>{o.current.insideReactTree=!0}}},[S,d,o]);return N.useMemo(()=>a?{reference:P,floating:V}:{},[a,P,V])}function w7(t){const{open:e=!1,onOpenChange:s,elements:n}=t,i=P9(),o=N.useRef({}),[a]=N.useState(()=>f7()),l=Np()!=null,[c,d]=N.useState(n.reference),h=or((m,p,g)=>{o.current.openEvent=m?p:void 0,a.emit("openchange",{open:m,event:p,reason:g,nested:l}),s?.(m,p,g)}),u=N.useMemo(()=>({setPositionReference:d}),[]),f=N.useMemo(()=>({reference:c||n.reference||null,floating:n.floating||null,domReference:n.reference}),[c,n.reference,n.floating]);return N.useMemo(()=>({dataRef:o,open:e,onOpenChange:h,elements:f,events:a,floatingId:i,refs:u}),[e,h,f,a,i,u])}function j7(t){t===void 0&&(t={});const{nodeId:e}=t,s=w7({...t,elements:{reference:null,floating:null,...t.elements}}),n=t.rootContext||s,i=n.elements,[o,a]=N.useState(null),[l,c]=N.useState(null),h=i?.domReference||o,u=N.useRef(null),f=Tp();Ci(()=>{h&&(u.current=h)},[h]);const m=Rx({...t,elements:{...i,...l&&{reference:l}}}),p=N.useCallback(_=>{const y=fn(_)?{getBoundingClientRect:()=>_.getBoundingClientRect(),getClientRects:()=>_.getClientRects(),contextElement:_}:_;c(y),m.refs.setReference(y)},[m.refs]),g=N.useCallback(_=>{(fn(_)||_===null)&&(u.current=_,a(_)),(fn(m.refs.reference.current)||m.refs.reference.current===null||_!==null&&!fn(_))&&m.refs.setReference(_)},[m.refs]),x=N.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:u}),[m.refs,g,p]),v=N.useMemo(()=>({...m.elements,domReference:h}),[m.elements,h]),b=N.useMemo(()=>({...m,...n,refs:x,elements:v,nodeId:e}),[m,x,v,e,n]);return Ci(()=>{n.dataRef.current.floatingContext=b;const _=f?.nodesRef.current.find(y=>y.id===e);_&&(_.context=b)}),N.useMemo(()=>({...m,context:b,refs:x,elements:v}),[m,x,v,b])}function qc(t,e,s){const n=new Map,i=s==="item";let o=t;if(i&&t){const{[Lh]:a,[Sh]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[l7]:""},...o,...e.map(a=>{const l=a?a[s]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((a,l)=>(l&&Object.entries(l).forEach(c=>{let[d,h]=c;if(!(i&&[Lh,Sh].includes(d)))if(d.indexOf("on")===0){if(n.has(d)||n.set(d,[]),typeof h=="function"){var u;(u=n.get(d))==null||u.push(h),a[d]=function(){for(var f,m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];return(f=n.get(d))==null?void 0:f.map(x=>x(...p)).find(x=>x!==void 0)}}}else a[d]=h}),a),{})}}function C7(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),n=t.map(l=>l?.item),i=N.useCallback(l=>qc(l,t,"reference"),e),o=N.useCallback(l=>qc(l,t,"floating"),s),a=N.useCallback(l=>qc(l,t,"item"),n);return N.useMemo(()=>({getReferenceProps:i,getFloatingProps:o,getItemProps:a}),[i,o,a])}const k7=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function V7(t,e){var s,n;e===void 0&&(e={});const{open:i,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=P9(),h=((s=o.domReference)==null?void 0:s.id)||d,u=N.useMemo(()=>{var b;return((b=Q_(o.floating))==null?void 0:b.id)||a},[o.floating,a]),f=(n=k7.get(c))!=null?n:c,p=Np()!=null,g=N.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:i?u:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":i?u:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:h},...f==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[f,u,p,i,h,c]),x=N.useMemo(()=>{const b={id:u,...f&&{role:f}};return f==="tooltip"||c==="label"?b:{...b,...f==="menu"&&{"aria-labelledby":h}}},[f,u,h,c]),v=N.useCallback(b=>{let{active:_,selected:y}=b;const L={role:"option",..._&&{id:u+"-fui-option"}};switch(c){case"select":case"combobox":return{...L,"aria-selected":y}}return{}},[u,c]);return N.useMemo(()=>l?{reference:g,floating:x,item:v}:{},[l,g,x,v])}function N7({children:t}){const{state:e,dispatch:s}=r6(),{open:n,element:i}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=j7({placement:"bottom-start",open:n,onOpenChange:f=>{f||o()},elements:{reference:i},middleware:[Bx(10),Fx(),zx()],whileElementsMounted:Kx}),d=S7(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),h=V7(c,{role:"listbox"}),{getFloatingProps:u}=C7([d,h]);return n?r.jsx(b7,{children:r.jsx("div",{ref:a.setFloating,style:l,...u(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const T7=t=>{const e=F.c(29),{item:s,isSelected:n,onSelect:i,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const w=gn(s._meta);l=s.title||Z0(s.name,w),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,h=s.icon,u=n&&"bg-accent text-accent-foreground",f=o&&"pointer-events-none opacity-50";let m;e[2]!==u||e[3]!==f?(m=ie("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",u,f),e[2]=u,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==h||e[6]!==c?(p=h!==void 0&&r.jsx(ii,{icon:h,name:c,size:"xs",className:"mr-2"}),e[5]=h,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=r.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let x;e[10]!==o?(x=o&&r.jsx(Ni,{size:"xs"}),e[10]=o,e[11]=x):x=e[11];let v;e[12]!==g||e[13]!==x?(v=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,x]}),e[12]=g,e[13]=x,e[14]=v):v=e[14];let b;e[15]!==d?(b=d&&r.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=b):b=e[16];let _;e[17]!==v||e[18]!==b?(_=r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,b]}),e[17]=v,e[18]=b,e[19]=_):_=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&r.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=y):y=e[21];let L;return e[22]!==i||e[23]!==a||e[24]!==_||e[25]!==y||e[26]!==m||e[27]!==p?(L=r.jsxs("div",{ref:a,onClick:i,className:m,children:[p,_,y]}),e[22]=i,e[23]=a,e[24]=_,e[25]=y,e[26]=m,e[27]=p,e[28]=L):L=e[28],L},A7=t=>{const e=F.c(21),{editor:s,queryKey:n,queryFn:i,onSelect:o}=t,a=oe();let l;e[0]!==s||e[1]!==o||e[2]!==i||e[3]!==n?(l={editor:s,queryKey:n,queryFn:i,onSelect:o},e[0]=s,e[1]=o,e[2]=i,e[3]=n,e[4]=l):l=e[4];const{items:c,selectedIndex:d,onSelect:h,selectedItem:u}=o6(l);if(!c.length){let g;e[5]!==a?(g=a("chat.mention.noItemsFound"),e[5]=a,e[6]=g):g=e[6];let x;return e[7]!==g?(x=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:g}),e[7]=g,e[8]=x):x=e[8],x}let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[9]=f):f=e[9];let m;if(e[10]!==h||e[11]!==c||e[12]!==d||e[13]!==u?.name){let g;e[15]!==h||e[16]!==d||e[17]!==u?.name?(g=(x,v)=>r.jsx(T7,{item:x,isSelected:v===d,ref:v===d?R7:void 0,onSelect:()=>h(x,v),isLoading:u?.name===x.name},`${x.kind??"item"}:${x.name}`),e[15]=h,e[16]=d,e[17]=u?.name,e[18]=g):g=e[18],m=c.map(g),e[10]=h,e[11]=c,e[12]=d,e[13]=u?.name,e[14]=m}else m=e[14];let p;return e[19]!==m?(p=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:f,children:r.jsx("div",{className:"p-1",children:m})}),e[19]=m,e[20]=p):p=e[20],p};function E7(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"p-1",children:[...Array(3)].map(P7)}),t[0]=e):e=t[0],e}function P7(t,e){return r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[r.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),r.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function Ep(t){const e=F.c(18),{editor:s,char:n,pluginKey:i,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let h;e[0]!==c||e[1]!==n||e[2]!==s||e[3]!==d||e[4]!==i?(h={editor:s,char:n,pluginKey:i,allow:c,onOpenChange:d},e[0]=c,e[1]=n,e[2]=s,e[3]=d,e[4]=i,e[5]=h):h=e[5];const{state:u,dispatch:f}=n6(h);let m;e[6]!==f||e[7]!==u?(m={state:u,dispatch:f},e[6]=f,e[7]=u,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(E7,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=r.jsx(N7,{children:r.jsx(N.Suspense,{fallback:p,children:r.jsx(A7,{editor:s,queryKey:o,queryFn:a,onSelect:l})})}),e[10]=s,e[11]=l,e[12]=a,e[13]=o,e[14]=g):g=e[14];let x;return e[15]!==m||e[16]!==g?(x=r.jsx(i6.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=x):x=e[17],x}function R7(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const D7=t=>{const e=F.c(53),{editor:s,virtualMcpId:n,suggestionOpenRef:i}=t,o=oe(),a=Ls(),{org:l}=ze(),c=la();let d;e[0]!==c?(d=m9(c),e[0]=c,e[1]=d):d=e[1];const h=d;let u;e[2]!==l.id||e[3]!==l.slug||e[4]!==n?(u={connectionId:n,orgId:l.id,orgSlug:l.slug},e[2]=l.id,e[3]=l.slug,e[4]=n,e[5]=u):u=e[5];const f=pt(u);let m;e[6]!==l.id||e[7]!==n?(m=Qe.virtualMcpResources(n,l.id),e[6]=l.id,e[7]=n,e[8]=m):m=e[8];const p=m,[g,x]=N.useState("categories");let v;e[9]!==g?(v=()=>g,e[9]=g,e[10]=v):v=e[10];const b=N.useEffectEvent(v),_=N.useRef(null),y=N.useRef(!1),L=n??"default";let w;e[11]!==g||e[12]!==l.id||e[13]!==L?(w=["at-mention",l.id,L,g],e[11]=g,e[12]=l.id,e[13]=L,e[14]=w):w=e[14];const j=w;let S;e[15]!==o?(S=o("chat.mentionAt.agentsTitle"),e[15]=o,e[16]=S):S=e[16];let k;e[17]!==o?(k=o("chat.mentionAt.agentsDescription"),e[17]=o,e[18]=k):k=e[18];let C;e[19]!==S||e[20]!==k?(C={name:"agents",title:S,description:k,kind:"category",drillable:!0},e[19]=S,e[20]=k,e[21]=C):C=e[21];let A;e[22]!==o?(A=o("chat.mentionAt.resourcesTitle"),e[22]=o,e[23]=A):A=e[23];let P;e[24]!==o?(P=o("chat.mentionAt.resourcesDescription"),e[24]=o,e[25]=P):P=e[25];let V;e[26]!==A||e[27]!==P?(V={name:"resources",title:A,description:P,kind:"category",drillable:!0},e[26]=A,e[27]=P,e[28]=V):V=e[28];let T;e[29]!==V||e[30]!==C?(T=[C,V],e[29]=V,e[30]=C,e[31]=T):T=e[31];const R=T;let E;e[32]!==f||e[33]!==s||e[34]!==o?(E=async z=>{const{item:K,range:Y}=z;if(Fe("chat_picker_item_selected",{picker:"@",item_kind:K.kind,item_name:K.name}),K.kind!=="category"&&(y.current=!0),K.kind==="category")return x(K.name==="agents"?"agents":"resources"),!1;if(K.kind==="agent"&&K.agentId){vr(s,Y,{id:K.agentId,name:K.name,metadata:{agentId:K.agentId,title:K.name},char:"@"}),x("categories");return}if(K.kind==="resource"&&K.uri&&f){try{const Q=await Nm(f,K.uri);vr(s,Y,{id:K.uri,name:K.uri,metadata:Q.contents,char:"@"})}catch(Q){console.error("[at-mention] Failed to fetch resource:",Q),ve.error(o("chat.mentionAt.failedToLoadResource"))}x("categories");return}},e[32]=f,e[33]=s,e[34]=o,e[35]=E):E=e[35];const I=E;let D;e[36]!==c||e[37]!==R||e[38]!==f||e[39]!==h||e[40]!==b||e[41]!==a||e[42]!==p||e[43]!==n?(D=async z=>{const{query:K}=z,Y=b();if(Y==="categories"){if(!K.trim())return R;const H=K.toLowerCase(),U=c.filter(J=>J.status==="active"&&(!J.id||!cl(J.id))&&!h.has(J.id)&&J.id!==n&&(J.title.toLowerCase().includes(H)||J.description?.toLowerCase().includes(H))).map(I7),X=await(async()=>{if(!f)return[];let J=a.getQueryData(p);return J||(J=await a.fetchQuery({queryKey:p,queryFn:()=>So(f),staleTime:6e4})),(J?.resources??[]).filter(ee=>ee.uri.toLowerCase().includes(H)||ee.name?.toLowerCase().includes(H)||ee.description?.toLowerCase().includes(H)).map(M7)})();return[...U,...X]}if(Y==="agents"){let H=c.filter(U=>U.status==="active"&&(!U.id||!cl(U.id))&&!h.has(U.id)&&U.id!==n);if(K.trim()){const U=K.toLowerCase();H=H.filter(X=>X.title.toLowerCase().includes(U)||X.description?.toLowerCase().includes(U))}return H.map(O7)}if(!f)return[];let Q=a.getQueryData(p);Q?a.fetchQuery({queryKey:p,queryFn:()=>So(f),staleTime:6e4}).catch($7):Q=await a.fetchQuery({queryKey:p,queryFn:()=>So(f),staleTime:6e4});let q=Q?.resources??[];if(K.trim()){const H=K.toLowerCase();q=q.filter(U=>U.uri.toLowerCase().includes(H)||U.name?.toLowerCase().includes(H)||U.description?.toLowerCase().includes(H))}return q.map(B7)},e[36]=c,e[37]=R,e[38]=f,e[39]=h,e[40]=b,e[41]=a,e[42]=p,e[43]=n,e[44]=D):D=e[44];const M=D;let O;e[45]!==i?(O=z=>{if(i&&(i.current=z),z)_.current=Date.now(),y.current=!1,Fe("chat_picker_opened",{picker:"@"});else{const K=_.current;Fe("chat_picker_closed",{picker:"@",outcome:y.current?"selected":"dismissed",duration_ms:K?Date.now()-K:null}),_.current=null,x("categories")}},e[45]=i,e[46]=O):O=e[46];const $=O;let B;return e[47]!==s||e[48]!==M||e[49]!==I||e[50]!==$||e[51]!==j?(B=r.jsx(Ep,{editor:s,char:"@",pluginKey:"atDropdownMenu",queryKey:j,queryFn:M,onSelect:I,onOpenChange:$}),e[47]=s,e[48]=M,e[49]=I,e[50]=$,e[51]=j,e[52]=B):B=e[52],B};function I7(t){return{name:t.title,title:t.title,description:t.description??void 0,icon:t.icon??null,kind:"agent",agentId:t.id}}function M7(t){return{name:t.name??t.uri,title:t.name,description:t.description,kind:"resource",uri:t.uri}}function O7(t){return{name:t.title,title:t.title,description:t.description??void 0,icon:t.icon??null,kind:"agent",agentId:t.id}}function $7(){}function B7(t){return{name:t.name??t.uri,title:t.name,description:t.description,kind:"resource",uri:t.uri}}async function Nh(t,e,s,n,i,o,a){try{const l=await na(s,n,o);vr(t,e,{id:n,name:Nr(n,i),metadata:l.messages,char:"/",kind:"prompt",args:o})}catch(l){console.error("[slash] Failed to fetch prompt:",l),ve.error(a.t("chat.mentionSlash.failedLoadPrompt"))}}async function F7(t,e,s,n,i){try{const o=await Nm(s,n);vr(t,e,{id:n,name:n,metadata:o.contents,char:"/",kind:"resource"})}catch(o){console.error("[slash] Failed to fetch resource:",o),ve.error(i.t("chat.mentionSlash.failedLoadResource"))}}async function z7(t,e,s,n,i){try{const{files:o,omittedPaths:a}=await yb(s,n.volume,n.path),l={sandboxPath:n.sandboxPath,files:o,omittedPaths:a};vr(t,e,{id:n.id,name:n.name,metadata:l,char:"/",kind:"skill"})}catch(o){console.error("[slash] Failed to fetch skill:",o),ve.error(i.t("chat.mentionSlash.failedLoadSkill"))}}const K7=({editor:t,virtualMcpId:e,suggestionOpenRef:s})=>{const n=oe(),i=Ls(),{org:o}=ze(),a=pt({connectionId:e,orgId:o.id,orgSlug:o.slug}),l=Qe.virtualMcpPrompts(e,o.id),c=Qe.virtualMcpResources(e,o.id),d=Qe.slashSkills(o.id),h=["slash-mention",o.id,e??"default"],[u,f]=N.useState(null),[m,p]=N.useState(null),g=Uv(t);g&&(g.onEditChip=async j=>{if(a)try{const k=(await Th(i,l,a)).find(C=>C.name===j.promptId);if(!k?.arguments||k.arguments.length===0)return;p({...j,prompt:k})}catch(S){console.error("[slash] Failed to load prompt for editing:",S),ve.error(n("chat.mentionSlash.failedLoadPrompt"))}});const x=N.useRef(null),v=N.useRef(!1),b=async({item:j,range:S})=>{if(Fe("chat_picker_item_selected",{picker:"/",item_kind:j.kind,item_name:j.name}),v.current=!0,!!a)if(j.kind==="prompt"){if(j.arguments&&j.arguments.length>0){f({range:S,item:j});return}const k=gn(j._meta);await Nh(t,S,a,j.name,k,void 0,{t:n})}else j.kind==="skill"?j.skill&&await z7(t,S,o.slug,j.skill,{t:n}):j.uri&&await F7(t,S,a,j.uri,{t:n})},_=async j=>{if(!u||!a)return;const{range:S,item:k}=u,C=gn(k._meta);await Nh(t,S,a,k.name,C,j,{t:n}),f(null)},y=async j=>{if(!(!m||!a)){if(!Hv(t,m.pos,m.promptId)){ve.error(n("chat.mentionSlash.failedUpdatePrompt")),p(null);return}try{const S=await na(a,m.promptId,j),k=gn(m.prompt._meta);t.chain().focus().setNodeSelection(m.pos).deleteSelection().insertContentAt(m.pos,e9({id:m.promptId,name:Nr(m.promptId,k),metadata:S.messages,char:"/",kind:"prompt",args:j})).run(),Fe("chat_picker_item_selected",{picker:"/edit",item_kind:"prompt",item_name:m.promptId})}catch(S){console.error("[slash] Failed to update prompt:",S),ve.error(n("chat.mentionSlash.failedUpdatePrompt"))}p(null)}},L=async j=>{const{query:S}=j;if(!a)return[];const[k,C,A]=await Promise.all([Th(i,l,a),H7(i,c,a),U7(i,d,o.slug)]),P=S.trim().toLowerCase(),V=(k??[]).filter(E=>!P||E.name.toLowerCase().includes(P)||E.title?.toLowerCase().includes(P)||E.description?.toLowerCase().includes(P)).map(E=>({name:E.name,title:E.title,description:E.description,kind:"prompt",arguments:E.arguments,_meta:E._meta})),T=(C??[]).filter(E=>!P||E.uri.toLowerCase().includes(P)||E.name?.toLowerCase().includes(P)||E.description?.toLowerCase().includes(P)).map(E=>({name:E.name??E.uri,title:E.name,description:E.description,kind:"resource",uri:E.uri})),R=(A??[]).filter(E=>!P||E.name.toLowerCase().includes(P)||E.id.toLowerCase().includes(P)||E.description?.toLowerCase().includes(P)).map(E=>({name:E.name,title:E.name,description:E.description??void 0,kind:"skill",skill:E}));return[...V,...T,...R]},w=u?.item.kind==="prompt"?{name:u.item.name,title:u.item.title,arguments:u.item.arguments,description:u.item.description,_meta:u.item._meta}:null;return r.jsxs(r.Fragment,{children:[r.jsx(Ep,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:h,queryFn:L,onSelect:b,onOpenChange:j=>{if(s&&(s.current=j),j)x.current=Date.now(),v.current=!1,Fe("chat_picker_opened",{picker:"/"});else{const S=x.current;Fe("chat_picker_closed",{picker:"/",outcome:v.current?"selected":"dismissed",duration_ms:S?Date.now()-S:null}),x.current=null}}}),r.jsx(Io,{prompt:w,setPrompt:()=>f(null),onSubmit:_}),r.jsx(Io,{prompt:m?.prompt??null,setPrompt:()=>p(null),onSubmit:y,defaultValues:m?.args},m?`edit-${m.promptId}-${m.pos}`:"edit-idle")]})};async function Th(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>Dd(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>Dd(s),staleTime:6e4}),n?.prompts??[]}async function U7(t,e,s){const n=t.getQueryData(e),i=()=>t.fetchQuery({queryKey:e,queryFn:()=>_b(s),staleTime:6e4});return n?(i().catch(()=>{}),n):i().catch(()=>[])}async function H7(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>So(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>So(s),staleTime:6e4}),n?.resources??[]}function W7(t){return[zm.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),E_.configure({placeholder:()=>t.current??"Ask anything, / for prompts & skills, @ for agents & resources...",showOnlyWhenEditable:!1}),qv,mv]}function Pp({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:n=!1,placeholder:i,onSubmit:o,suggestionOpenRef:a,children:l}){const c=N.useRef(o),d=N.useRef(e),h=N.useRef(n),u=N.useRef(i),f=Xm({extensions:W7(u),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(m,p)=>p.key==="Enter"&&!p.shiftKey&&h.current&&!a?.current?(p.preventDefault(),c.current?.(),!0):!1},onUpdate:({editor:m})=>{d.current(m?.getJSON())}});return N.useEffect(()=>{f?.setEditable(!s)},[f,s]),N.useEffect(()=>{c.current=o},[o]),N.useEffect(()=>{d.current=e},[e]),N.useEffect(()=>{h.current=n},[n]),N.useEffect(()=>{u.current=i},[i]),N.useEffect(()=>{if(!f||f.isDestroyed)return;const m=JSON.stringify(f.getJSON()),p=JSON.stringify(t||{type:"doc",content:[]});m!==p&&f.commands.setContent(t||{type:"doc",content:[]})},[f,t]),r.jsx(Wv.Provider,{value:{editor:f},children:l})}function Rp(t){const e=F.c(29),{disabled:s,virtualMcpId:n,showFileUploader:i,selectedModel:o,onUnsupportedFile:a,suggestionOpenRef:l,ref:c,className:d}=t,h=s===void 0?!1:s,u=i===void 0?!1:i,{editor:f}=t9();let m,p;if(e[0]!==f?(m=()=>({focus:()=>{f?.commands.focus()},clear:()=>{f?.commands.clearContent(!0)},appendText:k=>{if(!f)return;const C=f.state.doc.textContent.trim()==="";f.commands.focus("end"),C||f.commands.insertContent(" "),f.commands.insertContent(k)},syncVoiceText:(k,C)=>{if(f&&(f.commands.setContent(k||{type:"doc",content:[]}),C)){f.commands.focus("end");const A=f.state.doc.textContent.trim().length>0;f.commands.insertContent({type:"text",text:A?" "+C:C})}},restoreContent:k=>{f&&f.commands.setContent(k||{type:"doc",content:[]})}}),p=[f],e[0]=f,e[1]=m,e[2]=p):(m=e[1],p=e[2]),N.useImperativeHandle(c??null,m,p),!f)return null;const g=h&&"cursor-not-allowed opacity-70",x=h&&"[&_.ProseMirror]:cursor-not-allowed";let v;e[3]!==d||e[4]!==g||e[5]!==x?(v=ie("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",d,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0","[&_.ProseMirror_p.is-editor-empty:first-child::before]:w-full","[&_.ProseMirror_p.is-editor-empty:first-child::before]:break-words",g,x),e[3]=d,e[4]=g,e[5]=x,e[6]=v):v=e[6];let b;e[7]!==f||e[8]!==v?(b=r.jsx(Qm,{editor:f,className:v}),e[7]=f,e[8]=v,e[9]=b):b=e[9];const _=n??null;let y;e[10]!==f||e[11]!==l||e[12]!==_?(y=r.jsx(N.Suspense,{fallback:null,children:r.jsx(K7,{editor:f,virtualMcpId:_,suggestionOpenRef:l})}),e[10]=f,e[11]=l,e[12]=_,e[13]=y):y=e[13];const L=n??null;let w;e[14]!==f||e[15]!==l||e[16]!==L?(w=r.jsx(N.Suspense,{fallback:null,children:r.jsx(D7,{editor:f,virtualMcpId:L,suggestionOpenRef:l})}),e[14]=f,e[15]=l,e[16]=L,e[17]=w):w=e[17];let j;e[18]!==h||e[19]!==f||e[20]!==a||e[21]!==o||e[22]!==u?(j=u&&o&&!h?r.jsx(C_,{editor:f,selectedModel:o,onUnsupportedFile:a}):null,e[18]=h,e[19]=f,e[20]=a,e[21]=o,e[22]=u,e[23]=j):j=e[23];let S;return e[24]!==y||e[25]!==w||e[26]!==j||e[27]!==b?(S=r.jsxs(r.Fragment,{children:[b,y,w,j]}),e[24]=y,e[25]=w,e[26]=j,e[27]=b,e[28]=S):S=e[28],S}function Dp(t){const e=F.c(3),[s]=di();let n;return e[0]!==s.enableSounds||e[1]!==t?(n=()=>{s.enableSounds&&Ub(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=n):n=e[2],n}const q7={name:"switch-005",dataUri:"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0VAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABkAABU4ABMTEx0dHR0nJycnMTExMTs7OztERERETk5OTlhYWFhiYmJibGxsbHZ2dnZ/f39/iYmJiZOTk5OdnZ2dp6enp7GxsbG7u7u7xMTExM7Ozs7Y2NjY4uLi4uzs7Oz29vb2/////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBVYAAAAAAAAVOPCP8KUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAACEwDXvQRAAG8Ii93HtACUCAABAKCJwfaCEHwfeoEAQdEAYygIHBOCAIAgCAJh9QIOg+D5/ygPh/wfB8DuKAgCHyn9QPh/5SCDv+CEHAQdxOD4B27c39tbckkqYbBAYAN9bNJLB+aXAf5wQAKdzxfbmrVIRQ4xNx3HwnoDmLhfMhgJiiw/HREXNCHqjvHEPEG8QjBYlxQNepJAT0kC8ip6JzSWj1TasoG+iyycbf2Uil1ovf1f/oUtR1qP+s1WSBFKoAAU02BDjMhuP/7UsQEgws8bRpd8YABJYPeBf9wCGXTGxBYcw5AJFMFMAmQQAhGAxgLBgHIAMYAAALhgAchipbe/91aU1VV4zcZj1Vf1XgYCIMBNrsBAIGs9/Ue4i/xFPeqCqwViI9/UeLf///rOngdA3OPHFjmOBv+EQnGahgaZxVplmkAH5JadDTQlNCEuGNiWYbCCONWdUJg6HXNazFdu1T+VgaEpOP70exv7f2/4b/yH//2/4cqCX/zWRUrIw+IPNMNlDnjAXQas/I4AzmYifA0tMSCgQDF//tSxBCDSzzi3k/sQwEyCtjJ/rBZAk+Uqj1YhA5YMCAAMwgOUchTkK7OR7LbMl0W1H6SvzG0Q2ZzfKUhnmTobv9DNhS1v7P8h//8Gv8gTRt1jReZ7YEjmMQg9hhwwMycHooasFmZyjcZGBKJD+IwbMCQQLoi+IQXCcIoydKoilI2MWFS5uJdDEu2taRrYI2ZSqKY50pJLv2NfjUAAuQAMfqVQ/T3PDQgMJMeEZ45hJzY6MNoFMxqTj1zNGQKJjAxEsSCBgQJBSIL0mcKYQJfVAn/+1LEGwLKlEKrD3MiYcuMkVa/wABB8Vh6M1q1epbvXwWBURhkyEhWZ/////////////9gjZ/Wt4w+4MNMCpE4TBYQl4w1IHvMDdA2zBngBMwc8COMDhCpDAfgOAAgrBgNYU+YC0FBGAkAMpgWoSCYAGESGBGAKBgXgJOdiOJmMCmNwCYNDJhYRPykRCJhTBnEUzlsjv4UNLj/z97n3Mv/7z1nZqyitYAZIqErIwMwJAqEw0GAAMFptJMaqFwB8CQIWlhuhuDAwNjfuwrQFAYXCf/7UsQVAA+9PTP42gYRdiIu9zBwAPbFUCi0DAhgNcS+7cDwVgM05A9bUDeuQMyE/u3CygVISgZhpIau/9PhdQG2C9DpxZZJmn/dn/Psmt0EFm////l84ThUTopE4VD/9JkubOGasTvN30C20G21qgUCkVCoUCgPMywrPCGly27V5q5t24vl/8jSlSAPCxzNseNCw3oh3NGBu4BZJ5hv7DRSfR/+eWG7nA8IKh2Olv5iz3q5m3//Joxo3JqNyYkSuGt/k6D4DeoBOHmHdl0dkZYA//tSxAUAC4B1Z/2DADEcA17Z/uhI4Yoik/TrZo+ww7UtmpW4LDWu2IacoJKJJeTSM+ZmAYBEiU+ZnnAwCn1VVVV6JUJQVnioKhrgqdKgqGpUFeCp0sDR3ztQNREDRUFioKuxKCpYGQBlRIBk+aLwb8KblGQVDdphPYTUdBOGbVpAaTF6ZdjEV0iRUZRCYkA4oUQDx5zqDugtXvza/7fuNNvfZ+j9v+T/2f//J/4cAAOTpE5K4zksR9MfIB+TDcQTI4gNs1XKAzEFUrGkxABYEBb/+1LEEYNKrEjgT/TCwYYVmUX+mHoKgWhKU5Eiw9SFIRmppw+3fYo4siPhUFeexM8KgIO6wVuPDDy01qeRaVbw357//y3+o8M0pBNlNLCGBzGKwyYw2IIFOE1WNTjRM6x8MlA1AxDhUHTAkEiyKpnbWrLcaOBotBUKbk1pypcWDAIK00AhKLGkUco6q9VWvM53mcaq3tVa8zjTM/tX//EDP//////////XAAmrwAAPoKwcw0ShDCZD/BQlhzinxQdorsOuXTEIC01ZkJyu4k/qPP/7UsQUAEjkrrkvZaPBIRXUoe5QObfMhYKX9RVgTPqCSCaSCaSC0XVdV1f/////6IAlguuAJSiDRNloNBsZg+0+Ts8MMCn81WUTRAlIi+GHECD0y8AWDIqswYsxGOSKVV7MqOni8tkVOip0fZX/////9HrMCbAz2EHGS4GKAAiRAAAYAcDdKd4G6Z/nwYgJ0ZAIgZyC8aPAs/iPBhwMpWDQNARltNS5Y61v//9i8Yl4SkFkIGTkAc0UBrIYLPA4MYBEy+YLMRuY4nhTC3hZA68H//tSxCoAyQC6mY6CkWDJBIsBz/QUrgNmahSzcrYw0/HhfnMAZBojDsgTFkDR5MDkG/DZEbk2FCmowqdqv2TYABiJwqqYjaQRGZ1URZ1DhSsdiHX/GBu0QpzIBNSaLqZ0ARkwFARxMrpt/Eh47mbQAhhU6sisFUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LESoHHJCRaj/dmYAIAQAAQAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsSLg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsShg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",duration:.609,format:"mp3",license:"CC0",author:"Kenney"},G7=e6.togglePlanMode.keys.map(t=>t==="Shift"?"⇧":t).join(""),Y7=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function J7(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1.5",children:Y7.map(X7)}),t[0]=e):e=t[0],e}function X7(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function Q7({disabled:t,onOpenConnections:e,virtualMcpId:s,selectedModel:n,isStreaming:i,onUnsupportedFile:o}){const a=oe(),[l,c]=N.useState(!1),d=Dp(q7),{org:h}=ze(),{editor:u}=t9(),f=N.useRef(null),m=nc(n),p=()=>{!m||i||(c(!1),f.current?.click())},g=async q=>{const H=q.target.files;if(!H||H.length===0||!u)return;const U=Array.from(H),{from:X}=u.state.selection;try{for(const J of U)await E9(u,n??null,J,X,o,a)}finally{f.current&&(f.current.value="")}},x=pt({connectionId:s,orgId:h.id,orgSlug:h.slug}),v=Qe.virtualMcpPrompts(s,h.id),{data:b,isLoading:_}=Pt({queryKey:v,queryFn:()=>Dd(x),staleTime:6e4,enabled:l&&!!x}),y=b?.prompts??[],[L,w]=N.useState(null),{chatMode:j,setChatMode:S}=Bs(),[k,C]=di(),A=uo.find(q=>q.value===k.toolApprovalLevel)??uo[0],P=a(A.shortKey),V=q=>{const H=uo.find(U=>U.value===q);if(H){if(H.value===k.toolApprovalLevel){c(!1);return}d(),Fe("chat_approval_level_changed",{from_level:k.toolApprovalLevel,to_level:H.value,source:"tools_popover"}),C({...k,toolApprovalLevel:H.value}),c(!1)}},T=j==="plan",R=()=>{d();const q=T?"default":"plan";Fe("chat_mode_changed",{from_mode:j,to_mode:q,source:"tools_popover"}),S(q),c(!1)},E=()=>{e(),c(!1)},I=async(q,H)=>{if(!u||!x)return;const U=gn(q._meta),X={from:u.state.selection.from,to:u.state.selection.to};try{const J=await na(x,q.name,H);vr(u,X,{id:q.name,name:Nr(q.name,U),metadata:J.messages,char:"/",kind:"prompt",args:H})}catch{ve.error(a("chat.toolsPopover.failedLoadPrompt"))}},D=async q=>{c(!1);const H=!!(q.arguments&&q.arguments.length>0);if(Fe("chat_prompt_inserted",{prompt_name:q.name,with_arguments:H}),H){w(q);return}await I(q)},M=async q=>{L&&(await I(L,q),w(null))},O=()=>{d();const q=j==="gen-image"?"default":"gen-image";Fe("chat_mode_changed",{from_mode:j,to_mode:q,source:"tools_popover"}),S(q),c(!1)},$=()=>{d();const q=j==="web-search"?"default":"web-search";Fe("chat_mode_changed",{from_mode:j,to_mode:q,source:"tools_popover"}),S(q),c(!1)},B=()=>{d();const q=j==="deep-research"?"default":"deep-research";Fe("chat_mode_changed",{from_mode:j,to_mode:q,source:"tools_popover"}),S(q),c(!1)},z=j==="gen-image",K=j==="web-search",Y=j==="deep-research",Q=r.jsx("input",{ref:f,type:"file",multiple:!0,accept:gb(n??null),className:"hidden",onChange:g,disabled:i});return r.jsxs(r.Fragment,{children:[Q,r.jsxs(vs,{open:l,onOpenChange:q=>{q&&!l&&Fe("chat_tools_popover_opened",{chat_mode:j}),c(q)},children:[r.jsx(bs,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"ghost",size:"default",disabled:t,title:a("chat.toolsPopover.tools"),"aria-label":a("chat.toolsPopover.tools"),className:ie("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),children:[r.jsx(a2,{size:14}),r.jsx("span",{className:ie("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),children:a("chat.toolsPopover.tools")})]})}),r.jsxs(ys,{align:"start",className:"w-56 p-1.5 space-y-1",children:[m?r.jsxs(Je,{onClick:p,disabled:i,children:[r.jsx(_t,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.addFile")})]}):r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsxs(Je,{"aria-disabled":"true",className:"opacity-50 cursor-not-allowed",onSelect:q=>q.preventDefault(),children:[r.jsx(_t,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.addFile")})]})}),r.jsx(He,{side:"right",children:a("chat.toolsPopover.modelNoFileSupport")})]}),r.jsxs(Je,{onClick:R,className:ie(T&&"text-special"),children:[r.jsx(br,{size:16,className:ie(T&&"text-special")}),r.jsx("span",{className:"flex-1 whitespace-nowrap",children:a("chat.toolsPopover.planMode")}),r.jsx("span",{className:ie("text-xs text-muted-foreground",T&&"text-special font-medium"),children:G7})]}),r.jsxs(Je,{onClick:O,className:ie(z&&"text-special"),children:[r.jsx(Dn,{size:16,className:ie(z&&"text-special")}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.createImage")}),z&&r.jsx("span",{className:"text-xs text-special font-medium",children:a("chat.toolsPopover.on")})]}),r.jsxs(Je,{onClick:$,className:ie(K&&"text-special"),children:[r.jsx(xn,{size:16,className:ie(K&&"text-special")}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.webSearch")}),K&&r.jsx("span",{className:"text-xs text-special font-medium",children:a("chat.toolsPopover.on")})]}),r.jsxs(Je,{onClick:B,className:ie(Y&&"text-special"),children:[r.jsx(l2,{size:16,className:ie(Y&&"text-special")}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.deepResearch")}),Y&&r.jsx("span",{className:"text-xs text-special font-medium",children:a("chat.toolsPopover.on")})]}),r.jsxs(Oo,{children:[r.jsxs($o,{className:"gap-2",children:[r.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.prompts")})]}),r.jsx(Bo,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:_?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ze,{size:14,className:"animate-spin"}),a("chat.toolsPopover.loadingPrompts")]}):y.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:a("chat.toolsPopover.noPromptsAvailable")}):y.map(q=>r.jsxs(Je,{onClick:()=>D(q),className:"flex flex-col items-start gap-0.5",children:[r.jsx("span",{className:"font-medium text-sm capitalize",children:q.title||Z0(q.name,gn(q._meta))}),q.description&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:q.description})]},q.name))})]}),r.jsxs(Oo,{children:[r.jsxs($o,{className:"gap-2",children:[r.jsx(Zl,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.approval")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:P})]}),r.jsx(Bo,{className:"w-48 p-1.5",children:r.jsx($d,{value:k.toolApprovalLevel,onValueChange:V,children:uo.map(q=>r.jsx(Fo,{value:q.value,children:a(q.labelKey)},q.value))})})]}),r.jsxs(Je,{onClick:E,children:[r.jsx(V2,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.connections")}),r.jsx(N.Suspense,{children:r.jsx(J7,{})})]})]})]}),r.jsx(Io,{prompt:L,setPrompt:w,onSubmit:M})]})}const Z7=[{src:"/connections/github.png",name:"GitHub"},{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/linear.png",name:"Linear"},{src:"/connections/shopify.png",name:"Shopify"},{src:"/connections/firecrawl.png",name:"Firecrawl"},{src:"/connections/perplexity.png",name:"Perplexity"}];function eL(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1",children:Z7.map(tL)}),t[0]=e):e=t[0],e}function tL(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function sL(t){const e=F.c(6),{onClick:s}=t;let n,i,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ie("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),i=r.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=r.jsx(eL,{}),a=r.jsx(yn,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=n,e[1]=i,e[2]=o,e[3]=a):(n=e[0],i=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=r.jsxs("button",{type:"button",onClick:s,className:n,children:[i,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const mo=48;function nL(){const t=F.c(9),[e,s]=N.useState("idle"),[n,i]=N.useState(""),[o,a]=N.useState(""),[l,c]=N.useState(oL),d=N.useRef(null),h=N.useRef(null),u=N.useRef(null),f=N.useRef(null),m=N.useRef(0),p=N.useRef(!1),g=N.useRef(""),x=N.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),h.current?.close().catch(rL),f.current?.getTracks().forEach(iL),u.current=null,h.current=null,f.current=null},t[0]=b):b=t[0];const _=b;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const A=P=>{f.current=P;const V=new AudioContext;h.current=V;const T=V.createMediaStreamSource(P),R=V.createAnalyser();R.fftSize=128,R.smoothingTimeConstant=.8,T.connect(R),u.current=R;const E=new Uint8Array(R.frequencyBinCount),I=()=>{if(!u.current)return;u.current.getByteFrequencyData(E);const D=[];for(let M=0;M<mo;M++){const O=Math.floor(M/mo*E.length);D.push(Math.max(.04,(E[O]??0)/255))}c(D),m.current=requestAnimationFrame(I)};I()};y=async()=>{const P=window.SpeechRecognition||window.webkitSpeechRecognition;if(!P)return s("unsupported"),"unsupported";let V;try{V=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{return s("permission-denied"),"permission-denied"}i(""),a(""),x.current="",g.current="",p.current=!0,s("recording"),A(V);const T=new P;d.current=T,T.interimResults=!0,T.continuous=!0,T.lang=navigator.language||"en-US",T.onresult=R=>{let E="",I="";for(let D=R.resultIndex;D<R.results.length;D++){const M=R.results[D],O=M?.[0]?.transcript??"";M?.isFinal?I=I+O:E=E+O}I&&(g.current=g.current+I,i(g.current)),x.current=E,a(E)},T.onend=()=>{if(p.current)try{T.start()}catch{}};try{T.start()}catch{return p.current=!1,d.current=null,_(),s("idle"),"idle"}return"recording"},t[1]=y}else y=t[1];const L=y;let w;t[2]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{p.current=!1,d.current?.stop(),_(),s("idle"),c(Array(mo).fill(.05)),a("");const A=(g.current+(x.current?" "+x.current:"")).trim();return i(""),g.current="",x.current="",A},t[2]=w):w=t[2];const j=w;let S;t[3]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{p.current=!1,d.current?.abort(),_(),s("idle"),i(""),a(""),c(Array(mo).fill(.05)),g.current="",x.current=""},t[3]=S):S=t[3];const k=S;let C;return t[4]!==o||t[5]!==e||t[6]!==n||t[7]!==l?(C={status:e,transcript:n,interimTranscript:o,waveformData:l,isSupported:v,startRecording:L,stopRecording:j,cancelRecording:k},t[4]=o,t[5]=e,t[6]=n,t[7]=l,t[8]=C):C=t[8],C}function iL(t){return t.stop()}function rL(){}function oL(){return Array(mo).fill(.05)}function aL(t){const e=F.c(4),{data:s}=t;let n;e[0]!==s?(n=s.map(lL),e[0]=s,e[1]=n):n=e[1];let i;return e[2]!==n?(i=r.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:n}),e[2]=n,e[3]=i):i=e[3],i}function lL(t,e){return r.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}function cL(t){return t.hasDraft?"send":t.isStreaming||t.isRunInProgress?"stop":"disabled"}function dL(t){const e=F.c(3),{message:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(J0,{size:14,className:"shrink-0"}),e[0]=n):n=e[0];const i=s??"";let o;return e[1]!==i?(o=r.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[n,r.jsx("span",{className:"text-sm",children:i})]}),e[1]=i,e[2]=o):o=e[2],o}function uL(t,e,s){const n=F.c(7),{editor:i}=t9(),o=oe(),[a,l]=N.useState(!1),c=N.useRef(0);let d,h;return n[0]!==s||n[1]!==i||n[2]!==e||n[3]!==t||n[4]!==o?(d=()=>{const u=g=>{g.dataTransfer?.types.includes("Files")&&(g.preventDefault(),c.current=c.current+1,l(!0))},f=g=>{g.preventDefault(),c.current=Math.max(0,c.current-1),c.current===0&&l(!1)},m=hL,p=g=>{if(g.preventDefault(),c.current=0,l(!1),s||!i||!t||!nc(t))return;const x=g.dataTransfer?.files;if(!x||x.length===0)return;const v=Array.from(x);(async()=>{let b=i.state.selection.from;for(const _ of v)await E9(i,t,_,b,e,o),b=i.state.selection.to})()};return window.addEventListener("dragenter",u),window.addEventListener("dragleave",f),window.addEventListener("dragover",m),window.addEventListener("drop",p),()=>{window.removeEventListener("dragenter",u),window.removeEventListener("dragleave",f),window.removeEventListener("dragover",m),window.removeEventListener("drop",p)}},h=[i,t,e,o,s],n[0]=s,n[1]=i,n[2]=e,n[3]=t,n[4]=o,n[5]=d,n[6]=h):(d=n[5],h=n[6]),N.useEffect(d,h),a}function hL(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function fL(t){const e=F.c(14),{selectedModel:s}=t,n=oe();let i,o,a;if(e[0]!==s||e[1]!==n){const{parts:d}=w2(s);e[5]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Ui,{size:24}),e[5]=a):a=e[5],i="text-sm font-medium";let h;e[6]!==n?(h=u=>n(u),e[6]=n,e[7]=h):h=e[7],o=n("chat.input.dropFilesHere",{fileTypes:d.map(h).join(", ")}),e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=a}else i=e[2],o=e[3],a=e[4];let l;e[8]!==i||e[9]!==o?(l=r.jsx("span",{className:i,children:o}),e[8]=i,e[9]=o,e[10]=l):l=e[10];let c;return e[11]!==a||e[12]!==l?(c=r.jsxs(r.Fragment,{children:[a,l]}),e[11]=a,e[12]=l,e[13]=c):c=e[13],c}function mL(){const t=F.c(5),e=oe();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(J0,{size:24}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("chat.input.modelCannotReadAttachments"),t[1]=e,t[2]=n):n=t[2];let i;return t[3]!==n?(i=r.jsxs(r.Fragment,{children:[s,r.jsx("span",{className:"text-sm font-medium",children:n})]}),t[3]=n,t[4]=i):i=t[4],i}function pL(t){const e=F.c(11),{selectedModel:s,onUnsupportedFile:n,disabled:i}=t,o=uL(s,n,i);let a;e[0]!==s?(a=nc(s),e[0]=s,e[1]=a):a=e[1];const l=a,c=o?"opacity-100":"opacity-0 pointer-events-none",d=l?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let h;e[2]!==c||e[3]!==d?(h=ie("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==s||e[6]!==l?(u=l?r.jsx(fL,{selectedModel:s}):r.jsx(mL,{}),e[5]=s,e[6]=l,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=r.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}function Sa(t){const e=F.c(14),{onClick:s,label:n,icon:i,colorClass:o,maxWidthClass:a}=t;let l;e[0]!==o?(l=ie("flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium group min-w-0 shrink animate-in fade-in duration-200",o),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==a?(c=ie("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:opacity-100",a),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==n||e[5]!==c?(d=r.jsx("span",{className:c,children:n}),e[4]=n,e[5]=c,e[6]=d):d=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(an,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"}),e[7]=h):h=e[7];let u;return e[8]!==i||e[9]!==n||e[10]!==s||e[11]!==l||e[12]!==d?(u=r.jsxs("button",{type:"button",onClick:s,title:n,"aria-label":n,className:l,children:[i,d,h]}),e[8]=i,e[9]=n,e[10]=s,e[11]=l,e[12]=d,e[13]=u):u=e[13],u}function gL(){const t=F.c(6),e=jt(),{org:s,locator:n}=ze(),{create:i}=Ql();let o;return t[0]!==i||t[1]!==n||t[2]!==e||t[3]!==s.id||t[4]!==s.slug?(o=async a=>{const{tiptapDoc:l,virtualMcp:c}=a,d=crypto.randomUUID(),h=c?.id??sa(s.id).id;s2(sessionStorage,n,d,{tiptapDoc:l});try{await i({id:d,virtual_mcp_id:h})}catch{}const u={virtualmcpid:h,autosend:s6};e({to:"/$org/$taskId",params:{org:s.slug,taskId:d},search:u})},t[0]=i,t[1]=n,t[2]=e,t[3]=s.id,t[4]=s.slug,t[5]=o):o=t[5],o}function xL({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=oe(),n=Q0(),i=hi(),o=n?.messages??[],a=n?.isStreaming??!1,l=n?.isRunInProgress??!1,c=n?.stop??(()=>{}),d=i?.taskId??"",h=d||d6,u=gL(),{selectedModel:f,selectedVirtualMcp:m,isModelsLoading:p,tiptapDocRef:g,imageModel:x,webSearchModel:v,deepResearchModel:b,chatMode:_,setChatMode:y}=Bs(),{data:L}=ui.useSession(),w=L?.user?.id,{org:j,locator:S}=ze(),k=sa(j.id).id,C=Dp(Hb),[A,P]=N.useState(!1),{unsupportedFile:V,onUnsupportedFile:T,clearUnsupportedFile:R}=A_(),E=nL(),I=N.useRef(void 0),D=async()=>{I.current=B;const ce=await E.startRecording();Fe("chat_voice_started",{thread_id:d,outcome:ce==="recording"?"started":ce==="unsupported"?"unsupported":ce==="permission-denied"?"permission_denied":"unknown"})},M=()=>{Fe("chat_voice_confirmed",{thread_id:d});const ce=E.stopRecording();H.current?.syncVoiceText(I.current,ce),H.current?.focus()},O=()=>{Fe("chat_voice_cancelled",{thread_id:d}),E.cancelRecording(),H.current?.restoreContent(I.current)};N.useEffect(()=>{if(E.status!=="recording")return;const ce=(E.transcript+(E.interimTranscript?" "+E.interimTranscript:"")).trim();H.current?.syncVoiceText(I.current,ce)},[E.transcript,E.interimTranscript,E.status]);const $=i?.activeTask??null,[B,z]=N.useState(()=>sh(sessionStorage,S,h)??void 0),K=ce=>{z(ce),g.current=ce,c6(sessionStorage,S,h,ce,{onQuotaExceeded:({docSizeBytes:fe})=>{Fe("chat_draft_quota_exceeded",{thread_id:d||null,doc_size_bytes:fe}),console.warn("[chat-draft] sessionStorage quota exceeded; draft not saved")}})},Y=N.useRef(d);if(Y.current!==d){Y.current=d;const ce=sh(sessionStorage,S,h)??void 0;z(ce),g.current=ce}const q=[...o].reverse().find(ce=>ce.role==="assistant")?.metadata?.modelLimits?.contextWindow??f?.limits?.contextWindow,H=N.useRef(null),U=N.useRef(!1),X=_==="plan",J=ce=>{C(),Fe("chat_mode_changed",{from_mode:ce,to_mode:"default",source:"pill_dismiss"}),y("default")};N.useEffect(()=>{const ce=fe=>{e2(fe)&&fe.code==="KeyL"&&(fe.preventDefault(),fe.shiftKey&&y(_==="plan"?"default":"plan"),H.current?.focus())};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[_,y]);const ee=Km(o),Z=[...o].reverse().find(ce=>ce.role==="assistant"&&ce.metadata?.usage)?.metadata?.usage?.contextTokens??0,G=!p&&!a6(B),te=cL({hasDraft:G,isStreaming:a,isRunInProgress:l}),se=te==="send",re=te==="stop",de=ce=>{if(ce?.preventDefault(),te==="send"&&B){if(Fe("chat_message_sent",{thread_id:d||null,mode:_,model_id:f?.modelId??null,model_provider:f?.providerId??null,virtual_mcp_id:m?.id??null,submission:ce?"button_or_enter":"programmatic"}),n){if(n.isSendInFlight()){ve.info(s("chat.input.stillSendingPreviousMessage"));return}n.sendMessage(B)}else u({tiptapDoc:B,virtualMcp:m});l6(sessionStorage,S,h),K(void 0)}else te==="stop"&&(Fe("chat_message_stopped",{thread_id:d}),c())};return w&&$?.created_by&&$.created_by!==w?r.jsx(dL,{message:s("chat.input.readOnlyOthersChat")}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col w-full justify-end",children:r.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&r.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),n&&i&&r.jsx(lc,{}),n&&i&&d?r.jsx(c_,{taskId:d}):null,r.jsx(Pp,{tiptapDoc:B,setTiptapDoc:K,disabled:E.status==="recording",enterToSubmit:!0,placeholder:s("chat.input.placeholder"),onSubmit:de,suggestionOpenRef:U,children:r.jsxs("form",{onSubmit:de,className:ie("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-card dark:bg-muted card-shadow overflow-hidden"),children:[r.jsx(pL,{selectedModel:f,onUnsupportedFile:T,disabled:E.status==="recording"}),r.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:r.jsx(Rp,{ref:H,disabled:E.status==="recording",virtualMcpId:m?.id??k,showFileUploader:!0,selectedModel:f,onUnsupportedFile:T,suggestionOpenRef:U})}),r.jsx("div",{className:"@container/chat-bottom flex items-center justify-between p-2.5 gap-1",children:E.status==="recording"?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsx(aL,{data:E.waveformData.slice(0,28)}),r.jsx("button",{type:"button",onClick:O,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":s("chat.input.cancelRecording"),children:r.jsx(an,{size:16})}),r.jsx("button",{type:"button",onClick:M,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":s("chat.input.useTranscription"),children:r.jsx(ns,{size:16})})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx(Q7,{disabled:!1,onOpenConnections:()=>{Fe("connections_dialog_opened",{source:"tools_popover",mode:"add"}),P(!0)},virtualMcpId:m?.id??k,selectedModel:f,isStreaming:a,onUnsupportedFile:T}),X&&r.jsx(Sa,{onClick:()=>J("plan"),label:s("chat.input.planMode"),icon:r.jsx(br,{size:14,className:"shrink-0"}),colorClass:"text-violet-600 dark:text-violet-400 hover:bg-violet-500/10",maxWidthClass:"@[320px]/chat-bottom:max-w-32"}),_==="gen-image"&&x&&r.jsx(Sa,{onClick:()=>J("gen-image"),label:s("chat.input.createImage"),icon:r.jsx(Dn,{size:14,className:"shrink-0"}),colorClass:"text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",maxWidthClass:"@[320px]/chat-bottom:max-w-[120px]"}),_==="web-search"&&v&&r.jsx(Sa,{onClick:()=>J("web-search"),label:s("chat.input.webSearch"),icon:r.jsx(xn,{size:14,className:"shrink-0"}),colorClass:"text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",maxWidthClass:"@[320px]/chat-bottom:max-w-[120px]"}),_==="deep-research"&&b&&r.jsx(Sa,{onClick:()=>J("deep-research"),label:s("chat.input.deepResearch"),icon:r.jsx(l2,{size:14,className:"shrink-0"}),colorClass:"text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",maxWidthClass:"@[320px]/chat-bottom:max-w-[120px]"}),q&&Z>0&&r.jsx(pv,{usage:ee,totalTokens:Z,contextWindow:q,onOpenContextPanel:t})]}),r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx(j_,{}),E.isSupported&&r.jsx(le,{type:"button",onClick:D,disabled:!1,variant:"ghost",size:"icon",className:ie("size-8 rounded-lg transition-colors",E.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:E.status==="permission-denied"?s("chat.input.microphoneAccessDenied"):s("chat.input.voiceInput"),"aria-label":E.status==="permission-denied"?s("chat.input.microphoneAccessDenied"):s("chat.input.voiceInput"),children:r.jsx(S6,{size:18})}),r.jsx(le,{type:re?"button":"submit",onClick:ce=>{re&&(ce.preventDefault(),ce.stopPropagation(),c())},variant:se||re?"default":"ghost",size:"icon",disabled:!se&&!re,className:ie("size-8 rounded-lg transition-all",!se&&!re&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:s(te==="stop"?a?"chat.input.stopGenerating":"chat.input.cancelRun":"chat.input.sendMessageEnter"),"aria-label":s(te==="stop"?a?"chat.input.stopGenerating":"chat.input.cancelRun":"chat.input.sendMessage"),children:re?r.jsx(w6,{size:20}):r.jsx(X0,{size:20})})]})]})})]})},d),e&&r.jsx(sL,{onClick:()=>{Fe("connections_banner_clicked",{source:"home_chat_input"}),Fe("connections_dialog_opened",{source:"home_banner",mode:"add"}),P(!0)}})]})}),r.jsx(p9,{mode:"browse",open:A,onOpenChange:P,defaultTab:"all"}),r.jsx(N_,{info:V,onClose:R})]})}function vL(){const t=F.c(7),e=jt(),s=Q0()?.messages??[],n=hi()?.taskId??null;let i;t[0]!==s?(i=s.some(yL),t[0]=s,t[1]=i):i=t[1];const o=i,a=N.useRef(null);let l,c;t[2]!==e||t[3]!==o||t[4]!==n?(l=()=>{!o||!n||a.current===n||(a.current=n,e({to:".",search:bL,replace:!0}))},c=[o,n,e],t[2]=e,t[3]=o,t[4]=n,t[5]=l,t[6]=c):(l=t[5],c=t[6]),N.useEffect(l,c)}function bL(t){return{...t,main:"preview"}}function yL(t){return t.parts?.some(_L)}function _L(t){const e=t;return e.type==="tool-load_repo"&&e.state==="output-available"&&e.output?.success===!0}const LL={usd:[{dollars:10,labelKey:"chat.creditsEmptyState.starterLabel"},{dollars:20,labelKey:"chat.creditsEmptyState.popularLabel"},{dollars:100,labelKey:"chat.creditsEmptyState.bestValueLabel"}],brl:[{dollars:50,labelKey:"chat.creditsEmptyState.starterLabel"},{dollars:100,labelKey:"chat.creditsEmptyState.popularLabel"},{dollars:500,labelKey:"chat.creditsEmptyState.bestValueLabel"}]};function Ip(t){return`deco-credits-empty-dismissed:${t}`}function SL(t){try{return localStorage.getItem(Ip(t))==="1"}catch{return!1}}function wL(){const t=F.c(68),e=oe(),{org:s}=ze(),n=jt(),{decoKeyId:i}=f9(),o=Fs(),[a,l]=N.useState(!0),[c,d]=N.useState(""),[h,u]=N.useState(!1),[f,m]=N.useState("usd"),p=f==="brl"?"R$":"$";let g;t[0]!==s.id?(g=()=>{Fe("credits_empty_state_dismissed",{organization_id:s.id}),l(!1);try{localStorage.setItem(Ip(s.id),"1")}catch{}},t[0]=s.id,t[1]=g):g=t[1];const x=g;let v,b;t[2]!==a||t[3]!==s.id?(v=()=>{a&&Fe("credits_empty_state_shown",{organization_id:s.id})},b=[a,s.id],t[2]=a,t[3]=s.id,t[4]=v,t[5]=b):(v=t[4],b=t[5]),N.useEffect(v,b);let _;t[6]!==f||t[7]!==o?(_=async U=>{const{url:X}=await o.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:U,currency:f});return X},t[6]=f,t[7]=o,t[8]=_):_=t[8];let y;t[9]!==x?(y=U=>{U&&window.open(U,"_blank","noopener,noreferrer"),x()},t[9]=x,t[10]=y):y=t[10];let L;t[11]!==e?(L=U=>{ve.error(e("chat.creditsEmptyState.topUpFailed",{message:U.message}))},t[11]=e,t[12]=L):L=t[12];let w;t[13]!==_||t[14]!==y||t[15]!==L?(w={mutationFn:_,onSuccess:y,onError:L},t[13]=_,t[14]=y,t[15]=L,t[16]=w):w=t[16];const{mutate:j,isPending:S}=Ys(w),k=parseFloat(c),C=!isNaN(k)&&k>=1;if(!a)return null;let A;t[17]!==x?(A=U=>!U&&x(),t[17]=x,t[18]=A):A=t[18];let P;t[19]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-warning/8 to-transparent pointer-events-none rounded-t-lg"}),t[19]=P):P=t[19];let V;t[20]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-warning/10 border border-warning/20 mx-auto",children:r.jsx(c2,{size:20,className:"text-warning"})}),t[20]=V):V=t[20];let T;t[21]!==e?(T=e("chat.creditsEmptyState.title"),t[21]=e,t[22]=T):T=t[22];let R;t[23]!==T?(R=r.jsx(ds,{className:"text-lg font-semibold",children:T}),t[23]=T,t[24]=R):R=t[24];let E;t[25]!==e?(E=e("chat.creditsEmptyState.description"),t[25]=e,t[26]=E):E=t[26];let I;t[27]!==E?(I=r.jsx(On,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:E}),t[27]=E,t[28]=I):I=t[28];let D;t[29]!==R||t[30]!==I?(D=r.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[P,r.jsxs(cs,{className:"relative gap-3",children:[V,r.jsxs("div",{className:"text-center",children:[R,I]})]})]}),t[29]=R,t[30]=I,t[31]=D):D=t[31];let M;t[32]!==f||t[33]!==p||t[34]!==c||t[35]!==k||t[36]!==i||t[37]!==C||t[38]!==S||t[39]!==h||t[40]!==e||t[41]!==j?(M=i&&r.jsxs("div",{className:"px-6 pb-5",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(h9,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:U=>{U&&m(U)},children:[r.jsx(Mo,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Mo,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:LL[f].map(U=>{const{dollars:X,labelKey:J}=U;return r.jsxs("button",{type:"button",disabled:S,onClick:()=>{Fe("credits_topup_clicked",{amount_cents:X*100,currency:f,tier_label:J,source:"empty_state"}),j(X*100)},className:ie("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,X]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:e(J)})]},X)})}),h?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(et,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:U=>d(U.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(le,{className:"h-10",disabled:!C||S,onClick:()=>{Fe("credits_topup_clicked",{amount_cents:Math.round(k*100),currency:f,tier_label:"custom",source:"empty_state"}),j(Math.round(k*100))},children:e(S?"chat.creditsEmptyState.opening":"chat.creditsEmptyState.add")})]}):r.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>u(!0),children:e("chat.creditsEmptyState.enterCustomAmount")})]}),t[32]=f,t[33]=p,t[34]=c,t[35]=k,t[36]=i,t[37]=C,t[38]=S,t[39]=h,t[40]=e,t[41]=j,t[42]=M):M=t[42];let O;t[43]!==x||t[44]!==n||t[45]!==s.slug?(O=()=>{n({to:"/$org/settings/ai-providers",params:{org:s.slug}}),x()},t[43]=x,t[44]=n,t[45]=s.slug,t[46]=O):O=t[46];let $;t[47]!==e?($=e("chat.creditsEmptyState.useYourOwnProvider"),t[47]=e,t[48]=$):$=t[48];let B;t[49]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsx(Ar,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[49]=B):B=t[49];let z;t[50]!==O||t[51]!==$?(z=r.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:O,children:[$,B]}),t[50]=O,t[51]=$,t[52]=z):z=t[52];let K;t[53]!==e?(K=e("chat.creditsEmptyState.skipForNow"),t[53]=e,t[54]=K):K=t[54];let Y;t[55]!==x||t[56]!==K?(Y=r.jsx(le,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:x,children:K}),t[55]=x,t[56]=K,t[57]=Y):Y=t[57];let Q;t[58]!==z||t[59]!==Y?(Q=r.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[z,Y]}),t[58]=z,t[59]=Y,t[60]=Q):Q=t[60];let q;t[61]!==D||t[62]!==M||t[63]!==Q?(q=r.jsxs(Yt,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:jL,children:[D,M,Q]}),t[61]=D,t[62]=M,t[63]=Q,t[64]=q):q=t[64];let H;return t[65]!==q||t[66]!==A?(H=r.jsx(Jt,{open:!0,onOpenChange:A,children:q}),t[65]=q,t[66]=A,t[67]=H):H=t[67],H}function jL(t){return t.preventDefault()}function CL(t){const e=F.c(6),{balanceDollars:s}=t;let n;e[0]!==s?(n=s.toFixed(2),e[0]=s,e[1]=n):n=e[1];const i=n;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=ie("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-success/10 border border-success/20","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=r.jsx(c2,{size:13,className:"text-success"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==i?(l=r.jsxs("div",{className:o,children:[a,r.jsxs("span",{className:"text-xs font-medium text-success tabular-nums",children:["$",i," in credits to get started"]})]}),e[4]=i,e[5]=l):l=e[5],l}function kL(){const t=F.c(8),{org:e}=ze(),s=jt();let n;t[0]!==s||t[1]!==e.slug?(n=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=n):n=t[2];let i,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=ie("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-warning/10 border border-warning/20","hover:bg-warning/15","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),o=r.jsx(jn,{size:13,className:"text-warning"}),a=r.jsx("span",{className:"text-xs font-medium text-warning",children:"No credits remaining · Add more"}),t[3]=i,t[4]=o,t[5]=a):(i=t[3],o=t[4],a=t[5]);let l;return t[6]!==n?(l=r.jsxs("button",{type:"button",onClick:n,className:i,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function VL(t){const e=F.c(11),{className:s}=t;let n;e[0]!==s?(n=ie("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=n):n=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=i):i=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("div",{className:"flex items-center gap-3",children:[i,r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),r.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:r.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),r.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[r.jsx(wa,{align:"right",width:"w-3/4"}),r.jsx(wa,{align:"left",width:"w-full",lines:3}),r.jsx(wa,{align:"right",width:"w-2/3"}),r.jsx(wa,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:r.jsx("div",{className:"relative flex-1",children:r.jsxs("div",{className:"space-y-2 p-2",children:[r.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),r.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"px-4 py-4",children:r.jsx("div",{className:"mx-auto w-full max-w-2xl",children:r.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),r.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=h):h=e[8];let u;return e[9]!==n?(u=r.jsxs("div",{className:n,children:[a,l,h]}),e[9]=n,e[10]=u):u=e[10],u}function wa(t){const e=F.c(22),{align:s,width:n,lines:i}=t,o=n===void 0?"w-full":n,a=i===void 0?1:i,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=ie("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=c):c=e[1];const d=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let h;e[2]!==d?(h=ie("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=u):u=e[4];const f=s==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==f||e[6]!==o?(m=ie("min-w-0 rounded-2xl p-4",f,o),e[5]=f,e[6]=o,e[7]=m):m=e[7];let p;e[8]!==a?(p=Array.from({length:a}),e[8]=a,e[9]=p):p=e[9];let g;e[10]!==a||e[11]!==p?(g=r.jsx("div",{className:"space-y-2",children:p.map((_,y)=>r.jsx("div",{className:ie("h-3 rounded bg-muted-foreground/20 animate-pulse",y===a-1?"w-3/4":"w-full"),style:{animationDelay:`${y*.1}s`}},y))}),e[10]=a,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==g||e[14]!==m?(x=r.jsx("div",{className:m,children:g}),e[13]=g,e[14]=m,e[15]=x):x=e[15];let v;e[16]!==x||e[17]!==h?(v=r.jsxs("div",{className:h,children:[u,x]}),e[16]=x,e[17]=h,e[18]=v):v=e[18];let b;return e[19]!==v||e[20]!==c?(b=r.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=b):b=e[21],b}function NL(t){const e=F.c(7),{scrollRef:s,sentinelRef:n,hasMoreOlder:i,isFetchingOlder:o,fetchOlderMessages:a}=t;let l,c;e[0]!==a||e[1]!==i||e[2]!==o||e[3]!==s||e[4]!==n?(l=()=>{const d=n.current,h=s.current;if(!d||!h||!i)return;const u=new IntersectionObserver(async f=>{if(!f[0]?.isIntersecting||o||!i)return;const p=h.scrollHeight,g=h.scrollTop;await a(),requestAnimationFrame(()=>{const x=h.scrollHeight;h.scrollTop=g+(x-p)})},{root:h,rootMargin:"200px 0px 0px 0px"});return u.observe(d),()=>u.disconnect()},c=[s,n,i,o,a],e[0]=a,e[1]=i,e[2]=o,e[3]=s,e[4]=n,e[5]=l,e[6]=c):(l=e[5],c=e[6]),N.useEffect(l,c)}function TL(t){const e=F.c(5),{className:s,children:n}=t;let i;e[0]!==s?(i=ie("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=i):i=e[1];let o;return e[2]!==n||e[3]!==i?(o=r.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=o):o=e[4],o}function AL(t){const e=F.c(5),{children:s,className:n}=t;let i;e[0]!==n?(i=ie("flex-1 min-h-0 overflow-y-auto isolate",n),e[0]=n,e[1]=i):i=e[1];let o;return e[2]!==s||e[3]!==i?(o=r.jsx("div",{className:i,children:s}),e[2]=s,e[3]=i,e[4]=o):o=e[4],o}function EL(t){const e=F.c(2),{children:s}=t;let n;return e[0]!==s?(n=r.jsx("div",{className:"min-h-full shrink-0 w-full flex items-center justify-center max-w-2xl mx-auto py-10",children:s}),e[0]=s,e[1]=n):n=e[1],n}function PL(){const t=oe(),{messages:e,status:s,hasMoreOlder:n,isFetchingOlder:i,fetchOlderMessages:o}=Js(),{taskId:a}=ls();vL();const l=Bm(a??""),c=rv(l),d=c.size===0?e:e.filter(b=>!c.has(b.id)),h=gv(d),u=h.at(-1),m=xy()*iy+16,p=N.useRef(null),g=N.useRef(null);NL({scrollRef:p,sentinelRef:g,hasMoreOlder:n,isFetchingOlder:i,fetchOlderMessages:o});const x=xv({initial:!1}),v=b=>{p.current=b,x.scrollRef(b)};return r.jsx(vv,{messages:e,children:r.jsxs("div",{className:"relative h-full w-full min-w-0",children:[r.jsx("div",{ref:v,"data-chat-scroller":!0,className:"w-full min-w-0 max-w-full overflow-y-auto h-full [container-type:size]",style:{paddingBottom:m},children:r.jsxs("div",{ref:x.contentRef,className:"overflow-x-clip",children:[r.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[r.jsx("div",{ref:g,"aria-hidden":!0,className:"h-px"}),i&&r.jsx("div",{className:"flex items-center justify-center py-3 text-xs text-muted-foreground",children:t("chat.chat.loadingOlderMessages")}),h.slice(0,-1).map((b,_)=>r.jsx(Zu,{pair:b,isLastPair:!1,status:_===h.length-1?s:void 0},`pair-${b.user?.id??b.assistant?.id}`))]}),u&&r.jsx("div",{className:"min-h-[100cqh] min-w-0 max-w-2xl mx-auto w-full",children:r.jsx(Zu,{pair:u,isLastPair:!0,status:s},`pair-${u.user?.id??u.assistant?.id}`)})]})}),!x.isAtBottom&&r.jsx(le,{type:"button",variant:"outline",size:"icon-sm","aria-label":t("chat.chat.jumpToLatest"),className:"absolute left-1/2 z-50 -translate-x-1/2 rounded-full shadow-md animate-in fade-in duration-200 dark:bg-background dark:hover:bg-accent",style:{bottom:m+8},onClick:()=>{x.scrollToBottom()},children:r.jsx(Qx,{size:14})})]})})}function RL(t){const e=F.c(5),{children:s,className:n}=t;let i;e[0]!==n?(i=ie("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",n),e[0]=n,e[1]=i):i=e[1];let o;return e[2]!==s||e[3]!==i?(o=r.jsx("div",{className:i,children:s}),e[2]=s,e[3]=i,e[4]=o):o=e[4],o}const St=Object.assign(TL,{Main:AL,Messages:PL,EmptyState:EL,Footer:RL,Input:xL,Provider:iv,ActiveTaskProvider:nv,Skeleton:VL,IceBreakers:ny,NoAiProviderEmptyState:xb,CreditsEmptyState:wL,CreditsEyebrow:CL,NoCreditsEyebrow:kL,CreditsExhaustedBanner:vp});function DL(){const t=N2(),{pendingAgentOption:e}=Bs(),s=A9();if(hi()?.isThreadLocked)return!1;const i=e==="claude-code-desktop"&&s.claudeCode||e==="codex-desktop"&&s.codex;return t.length===0&&!i}function Jr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Gc(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function IL(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function ML(t){const e=F.c(4),{items:s}=t;let n;e[0]!==s?(n=s.map(OL),e[0]=s,e[1]=n):n=e[1];let i;return e[2]!==n?(i=r.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:n}),e[2]=n,e[3]=i):i=e[3],i}function OL(t){return r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),r.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function $L(t){const e=F.c(33),{userTokens:s,assistantTokens:n,otherTokens:i}=t,o=oe(),a=s+n+i,l=a>0?s/a*100:0,c=a>0?n/a*100:0,d=a>0?i/a*100:0;let h;e[0]!==l?(h=l>0&&r.jsx("div",{className:"h-full bg-chart-1",style:{width:`${l}%`}}),e[0]=l,e[1]=h):h=e[1];let u;e[2]!==c?(u=c>0&&r.jsx("div",{className:"h-full bg-chart-2",style:{width:`${c}%`}}),e[2]=c,e[3]=u):u=e[3];let f;e[4]!==d?(f=d>0&&r.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${d}%`}}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==u||e[8]!==f?(m=r.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[h,u,f]}),e[6]=h,e[7]=u,e[8]=f,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=p):p=e[10];let g;e[11]!==o||e[12]!==l?(g=o("chat.contextPanel.userPercent",{pct:l.toFixed(1)}),e[11]=o,e[12]=l,e[13]=g):g=e[13];let x;e[14]!==g?(x=r.jsxs("div",{className:"flex items-center gap-1.5",children:[p,r.jsx("span",{className:"text-xs text-muted-foreground",children:g})]}),e[14]=g,e[15]=x):x=e[15];let v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[16]=v):v=e[16];let b;e[17]!==c||e[18]!==o?(b=o("chat.contextPanel.assistantPercent",{pct:c.toFixed(1)}),e[17]=c,e[18]=o,e[19]=b):b=e[19];let _;e[20]!==b?(_=r.jsxs("div",{className:"flex items-center gap-1.5",children:[v,r.jsx("span",{className:"text-xs text-muted-foreground",children:b})]}),e[20]=b,e[21]=_):_=e[21];let y;e[22]!==d||e[23]!==i||e[24]!==o?(y=i>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.contextPanel.otherPercent",{pct:d.toFixed(1)})})]}),e[22]=d,e[23]=i,e[24]=o,e[25]=y):y=e[25];let L;e[26]!==_||e[27]!==y||e[28]!==x?(L=r.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[x,_,y]}),e[26]=_,e[27]=y,e[28]=x,e[29]=L):L=e[29];let w;return e[30]!==L||e[31]!==m?(w=r.jsxs("div",{className:"flex flex-col gap-2",children:[m,L]}),e[30]=L,e[31]=m,e[32]=w):w=e[32],w}function BL(t){const e=F.c(11),{agentId:s,isError:n}=t,i=ms(s),o=i?.title??"Subtask",a=i?.icon??null;let l;e[0]!==a||e[1]!==o?(l=r.jsx(ln,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const c=n?"text-destructive":"text-foreground";let d;e[3]!==c?(d=ie("shrink-0 font-medium",c),e[3]=c,e[4]=d):d=e[4];let h;e[5]!==o||e[6]!==d?(h=r.jsx("span",{className:d,children:o}),e[5]=o,e[6]=d,e[7]=h):h=e[7];let u;return e[8]!==l||e[9]!==h?(u=r.jsxs(r.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function FL(t){const e=F.c(12),{isError:s}=t,n=oe();let i;e[0]!==n?(i=n("chat.contextPanel.subtask"),e[0]=n,e[1]=i):i=e[1];const o=i;let a;e[2]!==o?(a=r.jsx(ln,{icon:null,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[2]=o,e[3]=a):a=e[3];const l=s?"text-destructive":"text-foreground";let c;e[4]!==l?(c=ie("shrink-0 font-medium",l),e[4]=l,e[5]=c):c=e[5];let d;e[6]!==o||e[7]!==c?(d=r.jsx("span",{className:c,children:o}),e[6]=o,e[7]=c,e[8]=d):d=e[8];let h;return e[9]!==a||e[10]!==d?(h=r.jsxs(r.Fragment,{children:[a,d]}),e[9]=a,e[10]=d,e[11]=h):h=e[11],h}function zL(t){const e=F.c(18),{part:s}=t,n=s.input?.agent_id,i=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=r.jsx(FL,{isError:o}),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==o?(c=r.jsx(BL,{agentId:n,isError:o}),e[2]=n,e[3]=o,e[4]=c):c=e[4];let d;e[5]!==l||e[6]!==c?(d=r.jsx(N.Suspense,{fallback:l,children:c}),e[5]=l,e[6]=c,e[7]=d):d=e[7];let h;e[8]!==s.input?(h=s.input?.prompt&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==i?(u=r.jsx("span",{className:"ml-auto shrink-0",children:i?r.jsx(Ze,{size:12,className:"animate-spin text-muted-foreground"}):o?r.jsx(Kb,{size:12,className:"text-destructive"}):a?r.jsx(jn,{size:12,className:"text-warning"}):r.jsx(ic,{size:12,className:"text-success"})}),e[10]=a,e[11]=o,e[12]=i,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==h||e[16]!==u?(f=r.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,h,u]}),e[14]=d,e[15]=h,e[16]=u,e[17]=f):f=e[17],f}function KL(t){const e=F.c(78),{onClose:s,back:n,className:i}=t,o=oe(),[a,l]=N.useState(null),{messages:c}=Js(),{activeTask:d}=ls(),{selectedModel:h,selectedVirtualMcp:u}=Bs();let f,m,p,g,x,v,b,_;if(e[0]!==d||e[1]!==n||e[2]!==i||e[3]!==c||e[4]!==s||e[5]!==a?.id||e[6]!==h||e[7]!==u?.title||e[8]!==o){_=Symbol.for("react.early_return_sentinel");e:{const w=Km(c),j=[...c].reverse().find(eS),S=j?.metadata?.usage,k=j?.metadata?.modelLimits?.contextWindow??h?.limits?.contextWindow??null,C=S?.contextTokens??0,A=k&&k>0?(C/k*100).toFixed(1):null,P=c;let V;e[17]!==P?(V=P.filter(ZL).reduce(QL,0),e[17]=P,e[18]=V):V=e[18];const T=V,R=c;let E;e[19]!==R?(E=R.filter(XL).reduce(JL,0),e[19]=R,e[20]=E):E=e[20];const I=E,D=Math.max(0,w.totalTokens-T-I),M=c[0],O=c.at(-1),$=M?.metadata?.created_at??d?.created_at,B=O?.metadata?.created_at??d?.updated_at,z=c.filter(YL),K=c.flatMap(qL),Y=h?.modelId?IL(h.modelId):"—",Q=u?.title??"Super Agent",q=[{label:o("chat.contextPanel.sessionLabel"),value:d?.title??o("chat.contextPanel.newChat")},{label:o("chat.contextPanel.messagesLabel"),value:z.length},{label:o("chat.contextPanel.agentLabel"),value:Q},{label:o("chat.contextPanel.modelLabel"),value:Y},{label:o("chat.contextPanel.contextLimitLabel"),value:k?Jr(k):"—"},{label:o("chat.contextPanel.sessionTokensLabel"),value:w.totalTokens>0?Jr(w.totalTokens):"0"},{label:o("chat.contextPanel.usageLabel"),value:A!==null?`${A}%`:"—"},{label:o("chat.contextPanel.inputTokensLabel"),value:w.inputTokens>0?Jr(w.inputTokens):"0"},{label:o("chat.contextPanel.outputTokensLabel"),value:w.outputTokens>0?Jr(w.outputTokens):"0"},{label:o("chat.contextPanel.reasoningTokensLabel"),value:w.reasoningTokens>0?Jr(w.reasoningTokens):"0"},{label:o("chat.contextPanel.costLabel"),value:w.cost>0?`$${w.cost<.001?w.cost.toFixed(6):w.cost.toFixed(4)}`:"$0.00"},{label:o("chat.contextPanel.sessionCreatedLabel"),value:Gc($)},{label:o("chat.contextPanel.lastActivityLabel"),value:Gc(B)}];if(!d&&z.length===0){let G;e[21]!==i?(G=ie("flex flex-col h-full w-full border-l border-border bg-background",i),e[21]=i,e[22]=G):G=e[22];let te;e[23]!==o?(te=o("chat.contextPanel.title"),e[23]=o,e[24]=te):te=e[24];let se;e[25]!==te?(se=r.jsx("span",{className:"text-sm font-medium text-foreground",children:te}),e[25]=te,e[26]=se):se=e[26];let re;e[27]!==n?(re=n?r.jsx(nh,{size:14,className:"text-muted-foreground"}):r.jsx(In,{size:14,className:"text-muted-foreground"}),e[27]=n,e[28]=re):re=e[28];let de;e[29]!==s||e[30]!==re?(de=r.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:re}),e[29]=s,e[30]=re,e[31]=de):de=e[31];let ce;e[32]!==se||e[33]!==de?(ce=r.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[se,de]}),e[32]=se,e[33]=de,e[34]=ce):ce=e[34];let fe;e[35]!==o?(fe=o("chat.contextPanel.emptyState"),e[35]=o,e[36]=fe):fe=e[36];let ue;e[37]!==fe?(ue=r.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:fe})}),e[37]=fe,e[38]=ue):ue=e[38];let ae;e[39]!==G||e[40]!==ce||e[41]!==ue?(ae=r.jsxs("div",{className:G,children:[ce,ue]}),e[39]=G,e[40]=ce,e[41]=ue,e[42]=ae):ae=e[42],_=ae;break e}e[43]!==i?(v=ie("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",i),e[43]=i,e[44]=v):v=e[44];let H;e[45]!==o?(H=o("chat.contextPanel.title"),e[45]=o,e[46]=H):H=e[46];let U;e[47]!==H?(U=r.jsx("span",{className:"text-sm font-medium text-foreground",children:H}),e[47]=H,e[48]=U):U=e[48];let X;e[49]!==n?(X=n?r.jsx(nh,{size:14}):r.jsx(In,{size:14}),e[49]=n,e[50]=X):X=e[50];let J;e[51]!==s||e[52]!==X?(J=r.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:X}),e[51]=s,e[52]=X,e[53]=J):J=e[53],e[54]!==U||e[55]!==J?(b=r.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[U,J]}),e[54]=U,e[55]=J,e[56]=b):b=e[56],f="flex flex-col gap-8 p-6",m=K.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.contextPanel.subtasksSection")}),r.jsx("div",{className:"flex flex-col gap-1",children:K.map(WL)})]}),p=r.jsx(ML,{items:q});let ee;e[57]!==o?(ee=o("chat.contextPanel.contextBreakdownSection"),e[57]=o,e[58]=ee):ee=e[58];let W;e[59]!==ee?(W=r.jsx("span",{className:"text-xs text-muted-foreground",children:ee}),e[59]=ee,e[60]=W):W=e[60];let Z;e[61]!==I||e[62]!==D||e[63]!==T?(Z=r.jsx($L,{userTokens:T,assistantTokens:I,otherTokens:D}),e[61]=I,e[62]=D,e[63]=T,e[64]=Z):Z=e[64],e[65]!==W||e[66]!==Z?(g=r.jsxs("div",{className:"flex flex-col gap-3",children:[W,Z]}),e[65]=W,e[66]=Z,e[67]=g):g=e[67],x=z.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.contextPanel.rawMessagesSection")}),r.jsx("div",{className:"flex flex-col gap-1",children:z.map(G=>{const te=G.metadata?.created_at,se=a?.id===G.id;return r.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>l(se?null:G),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:ie("shrink-0 font-medium",G.role==="user"?"text-chart-1":"text-chart-2"),children:G.role}),r.jsx("span",{className:"text-muted-foreground",children:"•"}),r.jsx("span",{className:"truncate text-muted-foreground font-mono",children:G.id})]}),te&&r.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:Gc(te)})]}),se&&r.jsxs(r.Fragment,{children:[G.role==="assistant"&&(()=>{const re=G.metadata?._request;if(!re)return null;const de=re.systemSections??[],ce=Math.max(1,...de.map(HL)),fe=de.reduce(UL,0);return r.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"font-medium text-foreground",children:o("chat.contextPanel.requestLabel")}),r.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[re.activeTools??0," / ",re.tools??0," ",o("chat.contextPanel.toolsActive")]})]}),de.length>0&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"text-muted-foreground",children:[o("chat.contextPanel.systemPromptLabel")," ",r.jsxs("span",{className:"tabular-nums",children:["~",Math.round(fe/4).toLocaleString()," ",o("chat.contextPanel.tokAbbrev")]})]}),de.map((ue,ae)=>{const me=ue.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${ae}`,xe=ue.chars/ce*100,Se=Math.round(ue.chars/4);return r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"font-mono text-foreground truncate",children:me}),r.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Se.toLocaleString()," ",o("chat.contextPanel.tokAbbrev")]})]}),r.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:r.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${xe}%`}})})]},ae)})]})]})})(),r.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(G,null,2)})]})]},G.id)})})]})}e[0]=d,e[1]=n,e[2]=i,e[3]=c,e[4]=s,e[5]=a?.id,e[6]=h,e[7]=u?.title,e[8]=o,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v,e[15]=b,e[16]=_}else f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14],b=e[15],_=e[16];if(_!==Symbol.for("react.early_return_sentinel"))return _;let y;e[68]!==f||e[69]!==m||e[70]!==p||e[71]!==g||e[72]!==x?(y=r.jsxs("div",{className:f,children:[m,p,g,x]}),e[68]=f,e[69]=m,e[70]=p,e[71]=g,e[72]=x,e[73]=y):y=e[73];let L;return e[74]!==v||e[75]!==b||e[76]!==y?(L=r.jsxs("div",{className:v,children:[b,y]}),e[74]=v,e[75]=b,e[76]=y,e[77]=L):L=e[77],L}function UL(t,e){return t+e.chars}function HL(t){return t.chars}function WL(t,e){return r.jsx(zL,{part:t},e)}function qL(t){return(t.parts??[]).filter(GL)}function GL(t){return t.type==="tool-subtask"}function YL(t){return t.role!=="system"}function JL(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function XL(t){return t.role==="assistant"}function QL(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function ZL(t){return t.role==="user"}function eS(t){return t.role==="assistant"&&t.metadata?.usage}function tS(t){const e=F.c(21),{onOpenContextPanel:s}=t,{org:n}=ze(),{selectedVirtualMcp:i}=Bs();let o;e[0]!==n.id?(o=sa(n.id),e[0]=n.id,e[1]=o):o=e[1];const l=i??o,d=ms(l.id)??l,h=d.title??"Super Agent",u=d.icon??null,f=d.description??null;let m;e[2]!==u||e[3]!==h?(m=r.jsx(ii,{icon:u,name:h,size:"lg"}),e[2]=u,e[3]=h,e[4]=m):m=e[4];let p;e[5]!==h?(p=r.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:h}),e[5]=h,e[6]=p):p=e[6];let g;e[7]!==f?(g=f?r.jsx("p",{className:"text-sm text-muted-foreground max-w-md text-balance",children:f}):null,e[7]=f,e[8]=g):g=e[8];let x;e[9]!==p||e[10]!==g?(x=r.jsxs("div",{className:"space-y-1.5",children:[p,g]}),e[9]=p,e[10]=g,e[11]=x):x=e[11];let v;e[12]!==m||e[13]!==x?(v=r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center gap-4 px-6 text-center overflow-hidden",children:[m,x]}),e[12]=m,e[13]=x,e[14]=v):v=e[14];let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(St.IceBreakers,{className:"pb-3"}),e[15]=b):b=e[15];let _;e[16]!==s?(_=r.jsxs(St.Footer,{children:[b,r.jsx(St.Input,{onOpenContextPanel:s})]}),e[16]=s,e[17]=_):_=e[17];let y;return e[18]!==v||e[19]!==_?(y=r.jsxs(r.Fragment,{children:[v,_]}),e[18]=v,e[19]=_,e[20]=y):y=e[20],y}function Ah(t){const e=F.c(17),{outputs:s,collapsed:n,onToggle:i,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=ie(a),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=c):c=e[2];const d=n&&"-rotate-90";let h;e[3]!==d?(h=ie("size-4 text-muted-foreground transition-transform",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==h?(u=r.jsx(is,{className:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==i||e[8]!==u?(f=r.jsxs("button",{type:"button",onClick:i,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[c,u]}),e[7]=i,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==n||e[11]!==s?(m=!n&&r.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(sS)}),e[10]=n,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=r.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function sS(t){return r.jsx(yv,{file:t},t.key)}function nS(){const t=F.c(13),e=hi()?.taskId??null,s=bv();let n;t[0]!==s?(n={enabled:s},t[0]=s,t[1]=n):n=t[1];const{data:i}=Um(e,n),[o,a]=N.useState(!1),[l,c]=N.useState(!0);if(!e||!i||i.length===0)return null;let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>a(rS),t[2]=d):d=t[2];let h;t[3]!==o||t[4]!==i?(h=r.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:r.jsx(Ah,{variant:"card",outputs:i,collapsed:o,onToggle:d})}),t[3]=o,t[4]=i,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>c(iS),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==i?(f=r.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:r.jsx(Ah,{variant:"bar",outputs:i,collapsed:l,onToggle:u})}),t[7]=l,t[8]=i,t[9]=f):f=t[9];let m;return t[10]!==h||t[11]!==f?(m=r.jsxs(r.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function iS(t){return!t}function rS(t){return!t}function oS(){const t=F.c(27),{org:e}=ze(),{isChatEmpty:s}=Js(),{openTab:n}=ia(),[i,o]=N.useState("chat"),a=f9();if(DL()){let y;return t[0]!==n?(y=r.jsx(St,{className:"animate-in fade-in-0 duration-200",children:r.jsx(St.Main,{className:"flex flex-col items-center",children:r.jsx(St.EmptyState,{children:r.jsx(St.NoAiProviderEmptyState,{onLocalRuntimePicked:()=>n("overview")})})})}),t[0]=n,t[1]=y):y=t[1],y}let c;t[2]!==a.hasDecoKey||t[3]!==a.hasOnlyDecoProvider||t[4]!==a.isLoading||t[5]!==a.isZeroBalance||t[6]!==s||t[7]!==e?(c=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&s&&!SL(e.id),t[2]=a.hasDecoKey,t[3]=a.hasOnlyDecoProvider,t[4]=a.isLoading,t[5]=a.isZeroBalance,t[6]=s,t[7]=e,t[8]=c):c=t[8];const d=c;let h;t[9]!==d?(h=d&&r.jsx(St.CreditsEmptyState,{}),t[9]=d,t[10]=h):h=t[10];const u=i!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let f;t[11]!==u?(f=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[11]=u,t[12]=f):f=t[12];let m;t[13]!==s?(m=s?r.jsx(tS,{onOpenContextPanel:()=>o("context")}):r.jsxs(r.Fragment,{children:[r.jsxs(St.Main,{className:"relative flex flex-col overflow-hidden @container",children:[r.jsx(nS,{}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(St.Messages,{})})]}),r.jsx(St.Footer,{children:r.jsx(St.Input,{onOpenContextPanel:()=>o("context")})})]}),t[13]=s,t[14]=m):m=t[14];let p;t[15]!==f||t[16]!==m?(p=r.jsx("div",{className:f,children:m}),t[15]=f,t[16]=m,t[17]=p):p=t[17];const g=i==="context"?"opacity-100":"opacity-0 pointer-events-none";let x;t[18]!==g?(x=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",g),t[18]=g,t[19]=x):x=t[19];let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(KL,{back:!0,onClose:()=>o("chat")}),t[20]=v):v=t[20];let b;t[21]!==x?(b=r.jsx("div",{className:x,children:v}),t[21]=x,t[22]=b):b=t[22];let _;return t[23]!==h||t[24]!==p||t[25]!==b?(_=r.jsxs(St,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,p,b]}),t[23]=h,t[24]=p,t[25]=b,t[26]=_):_=t[26],_}function Mp(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(St.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(hs,{fallback:e,children:r.jsx(N.Suspense,{fallback:r.jsx(St.Skeleton,{}),children:r.jsx(oS,{})})}),t[1]=s):s=t[1],s}async function aS(t,e,s){const n=await t.callTool({name:e,arguments:s});if(n.isError){const i=n.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(i)}return n}const Op=["SANDBOX_START"],ja=new Map,lS=t=>`${t.virtualMcpId}::${t.branch??""}::${t.sandboxProviderKind??""}`,cS=t=>t.message.includes("retry shortly"),Yc=new Set,Ud={mark:(t,e)=>Yc.add(`${t}::${e}`),clear:(t,e)=>Yc.delete(`${t}::${e}`),isStopped:(t,e)=>Yc.has(`${t}::${e}`)};function $p(t){const e=Ls();return Ys({mutationKey:Op,retry:(s,n)=>cS(n)&&s<6,retryDelay:s=>Math.min(500*2**s,5e3),mutationFn:async s=>{s.branch&&Ud.clear(s.virtualMcpId,s.branch);const n=lS(s),i=ja.get(n);if(i)return i;const o=(async()=>(await aS(t,"SANDBOX_START",s)).structuredContent)();ja.set(n,o);try{return await o}finally{ja.get(n)===o&&ja.delete(n)}},onSuccess:()=>{Tm(e),e.invalidateQueries({queryKey:Qe.agentSandboxSessionsPrefix()})}})}function dS(t,e){const s=F.c(3);let n;return s[0]!==e||s[1]!==t?(n={mutationKey:Op,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=n):n=s[2],G8(n)>0}function Eh(t,e){return+(e.sidePanel!==null)+Number(e.mainOpen)<=1?!1:t==="side"?e.sidePanel!==null:e.mainOpen}function uS(t){return t.sidePanel!==null||t.mainOpen?t:{...t,sidePanel:"chat"}}function hS(t){const e=t.mainParamValue===0?"0":t.mainParamValue,s=t.entityMetadata?.defaultMainView??null,n=s==null||s.type==="chat",i=t.mainParamPresent?e!=="0":!n,o=n||t.entityMetadata?.chatDefaultOpen?"chat":null,a=t.sidePanelParamPresent?t.sidePanelParamValue===0?null:t.sidePanelParamValue??null:o;return uS({sidePanel:a,mainOpen:i})}function Jc(t,e){switch(t.type){case"toggleSidePanel":return e.sidePanel===t.sidePanel?Eh("side",e)?{sidepanel:0}:null:{sidepanel:t.sidePanel};case"toggleMain":return e.mainOpen?Eh("main",e)?{main:0}:null:{main:t.openMainValue};case"openSidePanel":return e.sidePanel===t.sidePanel?null:{sidepanel:t.sidePanel}}}function fS(t){return t.sidePanel!==null&&t.mainOpen?{side:33,main:67}:t.sidePanel!==null?{side:100,main:0}:t.mainOpen?{side:0,main:100}:{side:0,main:0}}function mS(t,e){return t==="main"?{sidepanel:0,main:e}:{sidepanel:t,main:0}}function pS(t,e){const s=jt(),n=Vr({strict:!1}),i=Yl({strict:!1}),{create:o}=Ql(),{virtualMcpId:a,orgSlug:l,isAgentRoute:c}=e,d=n.main===0?"0":n.main,{sidePanel:h,mainOpen:u}=hS({entityMetadata:t,mainParamPresent:n.main!==void 0,mainParamValue:d,sidePanelParamPresent:n.sidepanel!==void 0,sidePanelParamValue:n.sidepanel}),f={sidePanel:h,mainOpen:u},m=N.useRef(crypto.randomUUID()),p=i.taskId??m.current,g="/$org/$taskId",x=C=>({org:l,taskId:C}),v=c?{virtualmcpid:a}:{},b=(C,A)=>{s({to:g,params:x(p),search:P=>({...P,...C}),replace:A?.replace??!1})};return{taskId:p,sidePanel:h,mainOpen:u,mainParam:d,setTaskId:(C,A)=>{s({to:g,params:x(C),search:P=>{const V={};return A?V.virtualmcpid=A:c&&(V.virtualmcpid=a),V}})},toggleMain:()=>{const C=Jc({type:"toggleMain",openMainValue:ml(t)},f);C&&b(C,{replace:!0})},toggleSidePanel:C=>{const A=Jc({type:"toggleSidePanel",sidePanel:C},f);A&&b(A,{replace:!0})},setMobileSurface:C=>{const A=d&&d!=="0"?d:ml(t);b(mS(C,A),{replace:!0})},openSidePanel:C=>{const A=Jc({type:"openSidePanel",sidePanel:C},f);A&&b(A,{replace:!0})},createNewTask:async()=>{const C=crypto.randomUUID();try{await o({id:C,virtual_mcp_id:a})}catch{}s({to:g,params:x(C),search:A=>({...v,sidepanel:"chat"})})},openTab:C=>{b({main:C==="0"?0:C},{replace:!0})}}}function gS(t){const e=F.c(10),{org:s}=ze(),n=Zv(),{data:i}=ui.useSession(),o=i?.user?.id,a=t?.id??null,l=!!t&&!!o&&!!t.created_by&&t.created_by!==o;let c;e[0]!==s.id||e[1]!==a?(c=Qe.viewedThreadMetadataRefresh(s.id,a??""),e[0]=s.id,e[1]=a,e[2]=c):c=e[2];const d=!!n&&!!a&&l;let h;e[3]!==n||e[4]!==a?(h=async()=>(await n?.refreshThreadMetadata(a??""),!0),e[3]=n,e[4]=a,e[5]=h):h=e[5];let u;e[6]!==c||e[7]!==d||e[8]!==h?(u={queryKey:c,enabled:d,staleTime:Number.POSITIVE_INFINITY,queryFn:h},e[6]=c,e[7]=d,e[8]=h,e[9]=u):u=e[9],Pt(u)}function Ph(t,e){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function xS(t,e){const s=F.c(8);let n;s[0]!==e?(n=c=>Ph(c,e),s[0]=e,s[1]=n):n=s[1];const[i,o]=Am(t,n);let a;s[2]!==e||s[3]!==i?(a=Ph(i,e),s[2]=e,s[3]=i,s[4]=a):a=s[4];let l;return s[5]!==o||s[6]!==a?(l=[a,o],s[5]=o,s[6]=a,s[7]=l):l=s[7],l}const vS=33;function bS(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Em.sidePanelWidth(),t[0]=e):e=t[0],xS(e,vS)}function Rh(){const t=F.c(3),[e,s]=N.useState(-1);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=a=>{if(!a)return;const l=()=>s(a.clientWidth);l();const c=new ResizeObserver(l);return c.observe(a),()=>c.disconnect()},t[0]=n):n=t[0];const i=n;let o;return t[1]!==e?(o=[e,i],t[1]=e,t[2]=o):o=t[2],o}function yS(t){try{return JSON.parse(t)}catch{return null}}function _S(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,n=s?yS(s):null,i=e.structuredContent;return i==null?n:typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length===0?n??i:i}function qi(t){const e=_S(t);return e===null?null:e}function D9(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function LS(t){if(!t||typeof t!="object")return null;const e=t.content?.find(i=>i.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],n=D9(s);return!n||!s?null:{number:n,htmlUrl:s}}const Dh=/[\r\n<>]/,SS=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function fa(t){const e=t?.userName?.trim();if(!e||Dh.test(e))return null;const s=t?.userEmail?.trim();return!s||Dh.test(s)?{userName:e}:SS.test(s)?{userName:e,userEmail:s}:{userName:e}}function wS(t){return t.split(`
3
- `).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
4
- `).trimEnd()}function jS(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function Bp(t,e){const s=fa(e);if(!s)return t;const n=wS(t),i=jS(s);if(n.includes(i))return n;const o=n.trimEnd();return o.length>0?`${o}
5
-
6
- ${i}`:i}function Fp(t,e){const s=t?.trim();return s?Bp(s,e):s||void 0}const CS=["dev","start"];function kS(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(n=>n.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function I9(t){const e=kS(t);if(e)throw new Error(e)}function zp(t,e){for(const s of e){const n=t[s];if(typeof n=="string"&&n.length>0)return n}}function Kp(t,e){for(const s of e){const n=t[s];if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n;if(typeof n=="string"&&/^\d+$/.test(n)){const i=Number(n);if(i>0)return i}}}function VS(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function NS(t,e){return VS(t)===e}function cc(t){const e=qi(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const n of["pull_requests","items","data"]){const i=s[n];if(Array.isArray(i))return i.filter(o=>o!=null&&typeof o=="object")}}return[]}function TS(t){const e=zp(t,["html_url","htmlUrl","url","URL"]),s=Kp(t,["number","pullNumber"])??D9(e);return!s||!e?null:{number:s,htmlUrl:e}}function AS(t){I9(t);const e=LS(t);if(e)return e;const s=qi(t);if(s&&typeof s=="object"){const n=zp(s,["url","URL","html_url","htmlUrl"]),i=Kp(s,["number","pullNumber"])??D9(n);if(i&&n)return{number:i,htmlUrl:n}}throw new Error("Failed to open pull request")}function ES(t){return/already exists|pull request already/i.test(t)}async function PS(t,e){const s=await t.callTool({name:"list_pull_requests",arguments:{owner:e.owner,repo:e.repo,state:"open",...e.head?{head:e.head}:{},perPage:10}});return I9(s),cc(s)}async function Ih(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const n of s){const o=(await PS(t,{owner:e.owner,repo:e.repo,head:n})).find(l=>NS(l,e.branch)),a=o?TS(o):null;if(a)return a}return null}async function RS(t,e){const s=Fp(e.body,fa(e.coAuthor));if(s)try{await t.callTool({name:"update_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,body:s}})}catch{}}async function DS(t,e){const s=Fp(e.body,fa(e.coAuthor)),n=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:s||void 0,head:e.head,base:e.base}});return AS(n)}async function Mh(t,e){const s=await Ih(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return await RS(t,{owner:e.owner,repo:e.repo,pullNumber:s.number,body:e.body,coAuthor:e.coAuthor}),s;try{return await DS(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base,coAuthor:e.coAuthor})}catch(n){const i=n instanceof Error?n.message:String(n);if(!ES(i))throw n;const o=await Ih(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw n}}async function Up(t,e){const s=fa(e.coAuthor),n=s?Bp(e.commitMessage?.trim()??"",s):e.commitMessage?.trim()||void 0,i=await t.callTool({name:"merge_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,merge_method:"squash",...e.commitTitle?{commit_title:e.commitTitle}:{},...n?{commit_message:n}:{}}});I9(i);const o=qi(i);if(!o||o.merged!==!0)throw new Error(o?.message??"Failed to merge pull request");return{merged:!0,message:o.message??"Pull request merged"}}const M9=6e4,dc=3e4;function Hp(t){const e=t.base,s=t.head,n=s?.repo,i=t.user;return{number:t.number??0,title:t.title??"",body:t.body??"",state:t.state==="closed"?"closed":"open",merged:t.merged_at!=null,mergedAt:t.merged_at??null,base:e?.ref??"main",head:s?.ref??"",headSha:s?.sha??"",headRepoFullName:n?.full_name??null,htmlUrl:t.html_url??"",author:i?.login??""}}function O9(t){const e=F.c(15);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=pt(s);let i;e[4]!==t.branch||e[5]!==t.owner?(i=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=i):i=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==i?(o={owner:t.owner,repo:t.repo,state:"all",...i,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=i,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==n||e[12]!==o||e[13]!==a?(l={client:n,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:M9,refetchIntervalInBackground:!1,staleTime:dc,select:IS},e[11]=n,e[12]=o,e[13]=a,e[14]=l):l=e[14],da(l)}function IS(t){const e=cc(t);return e.length===0?null:Hp(e[0])}const MS=50;function OS(t){const e=F.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=pt(s);let i;e[4]!==t.owner||e[5]!==t.repo?(i={owner:t.owner,repo:t.repo,state:"open",perPage:MS},e[4]=t.owner,e[5]=t.repo,e[6]=i):i=e[6];const o=(t.enabled??!0)&&!!t.connectionId&&!!t.owner&&!!t.repo;let a;return e[7]!==n||e[8]!==i||e[9]!==o?(a={client:n,toolName:"list_pull_requests",toolArguments:i,enabled:o,staleTime:dc,select:$S},e[7]=n,e[8]=i,e[9]=o,e[10]=a):a=e[10],da(a)}function $S(t){return cc(t).map(Hp)}function Wp(t){const e=F.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=pt(s),i=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==i?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:i},e[4]=t.owner,e[5]=t.repo,e[6]=i,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:M9,refetchIntervalInBackground:!1,staleTime:dc,select:BS},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],da(l)}function BS(t){const e=qi(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(FS)}function FS(t){const e=t.started_at,s=t.completed_at,n=e&&s?new Date(s).getTime()-new Date(e).getTime():null;return{id:String(t.id??""),name:String(t.name??""),status:t.status??"completed",conclusion:t.conclusion??null,htmlUrl:String(t.html_url??""),durationMs:n}}function zS(t){const e=F.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=pt(s),i=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==i?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:i},e[4]=t.owner,e[5]=t.repo,e[6]=i,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:M9,refetchIntervalInBackground:!1,staleTime:dc,select:KS},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],da(l)}function KS(t){const e=qi(t);return Array.isArray(e)?e.map(US):[]}function US(t){const e=t.user;return{id:Number(t.id??0),author:e?.login??"",body:String(t.body??""),createdAt:String(t.created_at??""),htmlUrl:String(t.html_url??"")}}function Ir(t,e){const s=(t??"").trim().replace(/^[/\\]+|[/\\]+$/g,"");return s?`${s}/${e}`:e}function qp(t){try{const{hostname:e}=new URL(t);return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="::1"}catch{return!1}}function HS(){if(typeof document>"u")return null;const t=Array.from(document.querySelectorAll("iframe"));for(const e of t){const s=e.getAttribute("src");if(s&&qp(s))return s}return null}function Gp(t,e){const s=t.previewUrl??t.getFallbackPreviewUrl?.()??HS();if(s&&qp(s))return new URL(e,s).toString();const n=new URLSearchParams({path:e});return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${n.toString()}`}function WS(t){return Gp(t,"/.decofile")}async function Yp(t,e){const s=`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/read`,n=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:e,full:!0})});if(n.status===400||n.status===404)return null;if(!n.ok){const o=new Error(`Failed to read ${e}: ${n.status}`);throw o.status=n.status,o}const i=await n.json();if(typeof i.content!="string")return null;try{return JSON.parse(Lb(i.content))}catch{return null}}function uc(t,e){const s=F.c(10),n=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",i=e?.fetchEnabled??!0,o=ms(t?.virtualMcpId)?.metadata?.runtime?.path??null;let a;s[0]!==n?(a=Qe.decofile(n),s[0]=n,s[1]=a):a=s[1];let l;s[2]!==i||s[3]!==o||s[4]!==t?(l=async()=>{const h=()=>Yp(t,Ir(o,".deco/blocks.gen.json"));if(i){const m=await fetch(WS(t),{cache:"no-store"}).catch(YS);if(m?.ok)return await m.json();const p=await h();if(p)return p;const g=new Error(`Failed to fetch decofile: ${m?.status??"network error"}`);throw g.status=m?.status??502,g}const u=await h();if(u)return u;const f=new Error("decofile unavailable (preview down, no committed snapshot)");throw f.status=502,f},s[2]=i,s[3]=o,s[4]=t,s[5]=l):l=s[5];const c=!!t;let d;return s[6]!==a||s[7]!==l||s[8]!==c?(d={queryKey:a,queryFn:l,enabled:c,staleTime:3e4,retry:GS,retryDelay:qS},s[6]=a,s[7]=l,s[8]=c,s[9]=d):d=s[9],Pt(d)}function qS(t){return $2(5e3,1e3,t,2,0)}function GS(t,e){return e.status!==502&&t<2}function YS(){return null}function JS(t){const e=[];return t.fetchEnabled&&t.previewUrl&&e.push({kind:"live",baseUrl:t.previewUrl}),e.push({kind:"committed"}),t.productionUrl&&e.push({kind:"production",baseUrl:t.productionUrl}),e}function hc(t,e){const s=F.c(17),n=e?.fetchEnabled??!0,i=t?.previewUrl,o=ms(t?.virtualMcpId),a=o?.metadata?.runtime?.path??null;let l,c,d;s[0]!==t||s[1]!==i||s[2]!==o?.metadata?.productionUrl?(l=B2(o?.metadata?.productionUrl),d=Pt,c=t?Qe.liveMeta(t.orgSlug,t.virtualMcpId,t.branch,i??"",l??""):Qe.liveMeta(""),s[0]=t,s[1]=i,s[2]=o?.metadata?.productionUrl,s[3]=l,s[4]=c,s[5]=d):(l=s[3],c=s[4],d=s[5]);let h;s[6]!==n||s[7]!==a||s[8]!==t||s[9]!==i||s[10]!==l?(h=async()=>{const p=ZS,g=()=>Yp(t,Ir(a,".deco/meta.gen.json")),x=JS({fetchEnabled:n,previewUrl:i,productionUrl:l});for(const b of x){const _=b.kind==="committed"?await g():await p(b.baseUrl);if(_)return _}const v=new Error("live meta unavailable (dev server down, no committed snapshot, no production fallback)");throw v.status=502,v},s[6]=n,s[7]=a,s[8]=t,s[9]=i,s[10]=l,s[11]=h):h=s[11];const u=!!t,f=e?.refetchInterval;let m;return s[12]!==c||s[13]!==h||s[14]!==u||s[15]!==f?(m={queryKey:c,queryFn:h,enabled:u,refetchInterval:f,refetchIntervalInBackground:!1,staleTime:3e5,retry:QS,retryDelay:XS},s[12]=c,s[13]=h,s[14]=u,s[15]=f,s[16]=m):m=s[16],d(m)}function XS(t){return $2(5e3,1e3,t,2,0)}function QS(t,e){return e.status!==502&&t<3}async function ZS(t){const e=new URL("/live/_meta",t).href,s=await fetch(e,{cache:"no-store"}).catch(ew);return s?.ok?await s.json():null}function ew(){return null}function Oh(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function jo(t){return t.includes("@")}function Hd(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function $h(t,e){if(t===e)return!0;const s=Hd(t);return s?e===s||Hd(e)===s:!1}function $9(t,e){const s=t.manifest?.blocks??{};for(const[n,i]of Object.entries(s))if(e in i)return n;return null}function Jp(t,e){const s=$9(t,e);return s!==null&&s.includes("sections")}function tw(t,e){const s=$9(t,e);return s!==null&&s.includes("apps")}function sw(t,e){const s=$9(t,e);return s!==null&&s.includes("matchers")}function _n(t){return!(/\.\w+$/.test(t)||t==="__proto__"||t==="constructor")}function fc(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const B9="oklch(0.7278 0.151 289)",Xp="website/matchers/always.ts",Mr="website/matchers/never.ts",Gi="website/flags/multivariate.ts",Or="website/flags/multivariate/section.ts";function Lr(){return{__resolveType:Xp}}function At(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())||t}const nw=12,Ca=8,iw=40,rw="__SECTION_REF__";function ow(t){const e=t.type;return e==="array"||Array.isArray(e)&&e.includes("array")}function aw(t,e){let s=t.items;if(!s)return!1;if(typeof s.$ref=="string"&&(s=e(s.$ref)),Array.isArray(s.anyOf)||Array.isArray(s.oneOf))return!0;const i=s.properties?.__resolveType?.enum;return Array.isArray(i)&&typeof i[0]=="string"}const lw="VideoWidget";function Qp(t){return typeof btoa=="function"?btoa(t):Buffer.from(t).toString("base64")}function F9(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function z9(t){const e=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function Zp(t,e){return[`site/apps/${t}/${e}.ts`,`site/apps/${t}/${e}.tsx`,`${t}/apps/${e}.ts`,`${t}/apps/${e}.tsx`]}function K9(t,e){const s=e.manifest?.blocks??{};for(const l of Object.values(s))if(l[t])return l[t];const n=F9(t)??z9(t);if(n){for(const l of Zp(n.vendor,n.app))for(const c of Object.values(s))if(c[l])return c[l]}const i=Qp(t);for(const l of Object.values(s))if(l[i])return l[i];const o=e.schema??{};return(o.$defs??o.definitions??{})[i]?{$ref:`#/definitions/${i}`}:{}}function e3(t,e){if(tw(t,e))return!0;const s=F9(e)??z9(e);if(!s)return!1;const n=t.manifest?.blocks?.apps??{};if(Zp(s.vendor,s.app).some(a=>a in n))return!0;const i=Qp(e),o=t.schema?.$defs??t.schema?.definitions??{};return i in o}function t3(t){return t==="site/apps/site.ts"?!1:F9(t)!==null||z9(t)!==null}function Ln(t,e){const s=e.schema??{},n=K9(t,e),i=s.$defs??s.definitions??{},o=s.root??{},a=v=>{if(v.startsWith("#/root/")){const y=v.slice(7);return o[y]??{}}const b=v.split("/").pop()??"",_=i[b];return _||(b===rw?o.sections??{}:{})};let l;typeof n.$ref=="string"?l=a(n.$ref):Object.keys(n).length>0?l=n:l=s;const c=v=>typeof v.$ref=="string"?a(v.$ref):v,d=v=>{const _=c(v).properties?.type;if(_){if(typeof _.const=="string")return _.const;if(typeof _.default=="string")return _.default;if(Array.isArray(_.enum)&&typeof _.enum[0]=="string")return _.enum[0]}},h=(v,b)=>{const _=c(v);return typeof _.title=="string"&&!_.title.startsWith("#")?_.title:b},u=(v,b=new Set)=>{if(typeof v.$ref!="string"||v.properties||v.anyOf||v.allOf||v.oneOf||v.type)return v;const _=v.$ref.split("/").pop()??"";return!_||b.has(_)?v:u(a(v.$ref),new Set([...b,_]))},f=v=>{const b=v.hide;return b===!0||b==="true"},m=(v,b=new Set,_=0)=>{if(_>nw)return{};if(typeof v.$ref=="string"){const L=v.$ref.split("/").pop()??"";return b.has(L)?{}:m(a(v.$ref),new Set([...b,L]),_+1)}let y={};if(v.properties&&typeof v.properties=="object"&&(y={...y,...v.properties}),Array.isArray(v.required)){const L=Array.isArray(y.__required)?y.__required:[];y.__required=[...L,...v.required]}for(const L of["allOf","anyOf","oneOf"]){const w=v[L];if(Array.isArray(w))for(const j of w)y={...y,...m(j,b,_+1)}}return y},p=(v,b=0,_=new Set)=>{let y=v,L;if(typeof v.$ref=="string"){y=a(v.$ref);const E=v.$ref.split("/").pop()??"";L=E,E===lw&&!y.format&&(y={...y,format:"video-uri"})}y=u(y);const w=L!==void 0&&_.has(L),j=L!==void 0?new Set([..._,L]):_,S=(E,I,D,M=!0)=>!w&&(!M||D<=iw)&&I<Ca?p(E,I,j):void 0;let k;{const E=y.anyOf??y.oneOf;if(Array.isArray(E)){const I=E.filter(M=>!(M.type==="null"||M.type===null)),D=M=>{if(typeof M.const=="string"||typeof M.const=="number")return M.const;if(Array.isArray(M.enum)&&M.enum.length===1&&(typeof M.enum[0]=="string"||typeof M.enum[0]=="number"))return M.enum[0]};I.length>0&&I.every(M=>D(M)!==void 0)&&(k=I.map(M=>D(M)))}}let C,A;if(y.type)C=Array.isArray(y.type)?String(y.type.find(E=>E!=="null")??y.type[0]):String(y.type);else if(y.anyOf||y.allOf||y.oneOf){const I=(y.anyOf??y.allOf??y.oneOf).filter(D=>!(D.type==="null"||D.type===null));if(I.length===0)C="null";else if(I.length===1){const D=I[0];A=D,C=D.type?Array.isArray(D.type)?String(D.type[0]):String(D.type):typeof D.$ref=="string"?"object":"string"}else{if(k){const H=U=>typeof v[U]=="string"?v[U]:typeof y[U]=="string"?y[U]:void 0;return{type:"string",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,enum:k,format:H("format"),options:H("options")}}const D=I.filter(H=>{const U=H.properties?.__resolveType?.enum;return Array.isArray(U)&&typeof U[0]=="string"}),M=I.find(ow),O=D.some(H=>{const U=H.properties?.__resolveType?.enum;return Array.isArray(U)&&U[0]===Gi});if(M){if(!aw(M,a)&&I.length>1){const U=p(M,b+1,j);return{...U,type:"array",title:typeof y.title=="string"?y.title:U.title,description:typeof y.description=="string"?y.description:U.description}}if(O){const U=p(M,b+1,j);return{...U,type:"array",title:typeof y.title=="string"?y.title:U.title,description:typeof y.description=="string"?y.description:U.description}}}if(D.length>0){const H=D.map(Z=>{const te=Z.properties?.__resolveType?.enum??[],se=String(te[0]);return{resolveType:se,title:typeof Z.title=="string"?Z.title:At(se),description:typeof Z.description=="string"?Z.description:void 0,schema:S(Z,b+1,I.length)}}),U=[];for(const Z of I){if(D.includes(Z)||typeof Z.$ref!="string")continue;const G=a(Z.$ref);let te;const se=G.properties?.__resolveType;if(Array.isArray(se?.enum)&&typeof se.enum[0]=="string"&&(te=se.enum[0]),!te&&Array.isArray(G.allOf))for(const re of G.allOf){const de=re.properties?.__resolveType?.enum;if(Array.isArray(de)&&typeof de[0]=="string"){te=de[0];break}}te&&U.push({resolveType:te,title:typeof G.title=="string"&&!G.title.startsWith("#")?G.title:At(te),description:typeof G.description=="string"?G.description:void 0,schema:S(G,b+1,I.length)})}const X=new Set(H.map(Z=>Z.resolveType)),J=[...H,...U.filter(Z=>!X.has(Z.resolveType))],ee=I.filter(Z=>!D.includes(Z)),W=ee.length===1?S(ee[0],b+1,I.length):void 0;return{type:"block-ref",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,anyOfRefs:J,plainSchema:W,hidden:f(y)||f(v)?!0:void 0}}const $=I.map(H=>d(H));if(I.length>1&&$.every(H=>typeof H=="string")){const H=I.map((U,X)=>{const J=c(U),ee=$[X];return{resolveType:ee,title:h(U,ee),description:typeof J.description=="string"?J.description:void 0,discriminatorValue:ee,schema:S(J,b+1,I.length,!1)}});return{type:"block-ref",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:void 0,description:typeof v.description=="string"?v.description:typeof y.description=="string"?y.description:void 0,discriminatorKey:"type",anyOfRefs:H,hidden:f(y)||f(v)?!0:void 0}}const z=H=>{const U=c(H);if(typeof U.title=="string"&&Oh(U.title))return!0;const X=U.properties?.__resolveType?.enum;if(Array.isArray(X)&&typeof X[0]=="string")return!0;if(Array.isArray(U.allOf))for(const J of U.allOf){const ee=J.properties?.__resolveType?.enum;if(Array.isArray(ee)&&typeof ee[0]=="string")return!0}return!1},K=H=>{if(z(H))return!1;const U=c(H);return U.type==="object"||!!U.properties},Q=(Array.isArray(y.anyOf)||Array.isArray(y.oneOf))&&b<Ca&&I.every(K);if(I.every(H=>typeof H.$ref=="string")&&!Q){const H=[];for(const U of I){const X=a(U.$ref);let J,ee;if(typeof X.title=="string"){const Z=Oh(X.title);Z&&(J=Z.blockId,ee=Z.blockId)}if(!J&&Array.isArray(X.allOf))for(const Z of X.allOf){const se=((Z.properties??{}).__resolveType??{}).enum;if(Array.isArray(se)&&typeof se[0]=="string"){J=se[0];break}}if(!J){const G=X.properties?.__resolveType?.enum;Array.isArray(G)&&typeof G[0]=="string"&&(J=G[0])}J||(J=U.$ref.split("/").pop()??"");const W=d(U);!W&&!J.includes("/")||H.push({resolveType:W??J,title:ee??(typeof X.title=="string"&&!X.title.startsWith("#")?X.title:At(J)),description:typeof X.description=="string"?X.description:void 0,discriminatorValue:W,schema:S(X,b+1,I.length)})}return{type:"block-ref",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,anyOfRefs:H,hidden:f(y)||f(v)?!0:void 0}}if(Q){const H=X=>{if(typeof X.const=="string"||typeof X.const=="number"||typeof X.const=="boolean")return X.const;if(Array.isArray(X.enum)&&X.enum.length===1&&(typeof X.enum[0]=="string"||typeof X.enum[0]=="number"||typeof X.enum[0]=="boolean"))return X.enum[0]},U=I.map((X,J)=>{const ee=c(X).properties??{},W={};for(const[Z,G]of Object.entries(ee)){const te=H(G);te!==void 0&&(W[Z]=te)}return{title:h(X,`Option ${J+1}`),schema:p(X,b+1),discriminators:Object.keys(W).length?W:void 0}});return{type:"inline-union",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,inlineUnionBranches:U,hidden:f(y)||f(v)?!0:void 0}}C="object"}}else typeof v.$ref=="string"&&(C="object");let P;if(b<Ca){const E=m(y),I=Object.entries(E).filter(([D])=>!D.startsWith("__")&&D!=="@type");if(I.length>0){P={};for(const[D,M]of I)P[D]=p(M,b+1,j)}}let V;if((C==="array"||y.type==="array")&&b<Ca){let E=y.items;E&&(typeof E.$ref=="string"&&(E=a(E.$ref)),V=p(E,b+1,j),typeof E.title=="string"&&E.title.includes("{{")&&(V.titleBy=E.title))}const T=E=>{const I=A?.[E];return typeof I=="string"?I:void 0},R=()=>{if("default"in v)return v.default;if("default"in y)return y.default;if(A&&"default"in A)return A.default};return{type:C??"string",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:T("title"),description:typeof v.description=="string"?v.description:typeof y.description=="string"?y.description:T("description"),default:R(),enum:Array.isArray(y.enum)?y.enum:k??void 0,format:typeof v.format=="string"?v.format:typeof y.format=="string"?y.format:T("format"),properties:P,items:V,hidden:f(y)||f(v)?!0:void 0,titleBy:typeof y.titleBy=="string"?y.titleBy:T("titleBy"),image:typeof y.image=="string"?y.image:T("image"),options:typeof v.options=="string"?v.options:typeof y.options=="string"?y.options:T("options")}},g=m(l),x={};for(const[v,b]of Object.entries(g))v.startsWith("__")||v==="@type"||(x[v]=p(b,0));return Object.keys(x).length===0?null:{type:"object",title:typeof l.title=="string"?l.title:void 0,properties:x}}function cw(t,e){const s=e.schema??{},n=K9(t,e),i=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?i[n.$ref.split("/").pop()??""]??{}:n,a=o.properties??{};if(Object.keys(a).some(d=>!d.startsWith("__")))return!1;if(o.additionalProperties===!0)return!0;const c=a.__resolveType;return!!c&&Array.isArray(c.enum)&&c.enum[0]===t}function dw(t){const e=n=>{switch(typeof n){case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(n===null)return{type:"string"};if(Array.isArray(n))return{type:"array",items:e(n[0])};const i={};for(const[o,a]of Object.entries(n))o.startsWith("__")||(i[o]=e(a));return{type:"object",properties:i}}default:return{type:"string"}}},s={};for(const[n,i]of Object.entries(t))n.startsWith("__")||(s[n]=e(i));return Object.keys(s).length===0?null:{type:"object",properties:s}}function gi(t,e){const s=e.schema??{},n=K9(t,e),i=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?i[n.$ref.split("/").pop()??""]??{}:Object.keys(n).length>0?n:{...s,...n},a=o.icon,l=o.logo,c=o,d=u=>u===!0||u==="true",h=d(c.hide)||d(c.ignore)||d(c.unlisted);return{title:typeof o.title=="string"?o.title:void 0,description:typeof o.description=="string"?o.description:void 0,icon:typeof a=="string"?a:void 0,logo:typeof l=="string"?l:void 0,hidden:h||void 0}}function ti(t){return t.replace(/\/+$/,"")||"/"}function s3(t){return t.trim().replace(/^\/+|\/+$/g,"")}function uw(t){const e=t.trim();return!(!e.startsWith("/")||e.startsWith("//")||e.includes("..")||e.includes("\\"))}function U9(t){const e=t.trim();return e?uw(e)?null:"Path must start with / and must not contain .. or //.":"Path is required."}const n3=/:([A-Za-z0-9_-]+)|\*/g;function i3(t){return t.replace(/\{([^{}]*)\}\?/g,"$1")}function Vl(t){t=i3(t);const e=[];let s=0;for(const n of t.matchAll(n3))n.index>s&&e.push({type:"text",text:t.slice(s,n.index)}),e.push({type:"param",name:n[1]??"*"}),s=n.index+n[0].length;return s<t.length&&e.push({type:"text",text:t.slice(s)}),e}function Jn(t,e){return i3(t).replace(n3,(s,n)=>{const i=e[n??"*"]?.trim();return i?n!==void 0?encodeURIComponent(i):i.split("/").filter(Boolean).map(encodeURIComponent).join("/")||s:s})}const hw=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"],Bh="website/sections/Rendering/Lazy.tsx";function fs(t){return hw.some(e=>t.endsWith(e))}const r3=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],o3=new Set(r3),fw=new Set(["site/sections/Theme/Theme.tsx"]);function mc(t){return!!(fw.has(t)||fs(t)||t.toLowerCase().includes("preview"))}function Wd(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const n of Object.keys(s))if(o3.has(n))return n;return r3[0]}function qd(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return qd(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(...qd(s));return e}return[]}function mw(t){const e=t.manifest?.blocks??{},s=[];for(const[n,i]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(i)){if(mc(o))continue;const a=gi(o,t);s.push({resolveType:o,title:a.title??At(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function pw(t){const e=t.manifest?.blocks??{},s=[];for(const[n,i]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(i))mc(o)||s.push({resolveType:o,title:At(o)});return s.sort((n,i)=>n.title.localeCompare(i.title))}function a3(t,e){const s=[];for(const[n,i]of Object.entries(e)){if(n.includes("/")||fc(n)||!i||typeof i!="object"||Array.isArray(i))continue;const o=i,a=o.__resolveType;typeof a=="string"&&(o3.has(a)||typeof o.path!="string"&&(mc(a)||Jp(t,a)&&s.push({resolveType:n,title:n,description:typeof o.name=="string"?o.name:void 0,previewBlock:n,isSavedBlock:!0})))}return s}function gw(t,e){const s=_n(e.resolveType),n=s?{}:gi(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||n.title||At(e.resolveType),description:e.description??n.description,previewBlock:e.resolveType,isSavedBlock:s}}function bq(t,e){const s=Wd(t),n=Ln(s,t),i=qd(n?.properties?.sections),o=new Map,a=l=>{if(!mc(l.resolveType)){if(_n(l.resolveType)){fc(l.resolveType)||o.set(l.resolveType,l);return}Jp(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of mw(t))a(l);for(const l of i)a(gw(t,l));for(const l of a3(t,e))a(l);return[...o.values()].sort((l,c)=>l.title.localeCompare(c.title))}function yq(t){const e=t.site;if(!e||typeof e!="object"||Array.isArray(e))return;const s=e.theme;if(!(!s||typeof s!="object"||Array.isArray(s)))return s}const H9="website/loaders/redirect.ts",l3=new Set([H9,"website/loaders/redirects.ts"]),xw={temporary:307,permanent:301},Fh=t=>typeof t=="string"?t:"",vw=t=>t==="permanent"?"permanent":"temporary";function c3(t){const e=t&&typeof t.redirect=="object"&&t.redirect!==null&&!Array.isArray(t.redirect)?t.redirect:{};return{from:Fh(e.from),to:Fh(e.to),type:vw(e.type),discardQueryParameters:e.discardQueryParameters===!0}}function d3(t){const e=[];for(const[s,n]of Object.entries(t)){if(!n||typeof n!="object"||Array.isArray(n))continue;const i=n;if(i.__resolveType!==H9)continue;const{from:o,to:a,type:l,discardQueryParameters:c}=c3(i);e.push({key:s,from:o,to:a,type:l,discardQueryParameters:c})}return e}function _q(t){return c3(t)}function bw(t){const e={from:t.from,to:t.to,type:t.type};return t.discardQueryParameters&&(e.discardQueryParameters=!0),{redirect:e,__resolveType:H9}}function yw(t){return(t.split(/[?#]/)[0]??"").replace(/^\/+/,"").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32)||"redirect"}const _w=1e3;function Lw(t,e){const s=yw(e);for(let n=0;n<_w;n++){const i=`redirects-${s}-${crypto.randomUUID()}`;if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique redirect block key")}function Sw(t){let e=t;e.startsWith("pages-")&&(e=e.slice(6)),e=e.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,""),e=e.replace(/-[0-9a-f]{8,}$/i,"");try{return decodeURIComponent(e)}catch{return e}}function ww(t,e,s){const n=ti;if(s){const o=t.find(a=>a.key===s);if(o)return o}const i=t.filter(o=>n(o.path)===n(e));return i.length===0?null:i.length===1?i[0]??null:[...i].sort((o,a)=>o.key.localeCompare(a.key))[0]??null}const u3=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]),po="site",W9="site/apps/site.ts";function Nl(t,e){return t===po?!0:e.__resolveType===W9}function q9(t,e){return t?G9(t).length>0||d3(t).length>0?!0:e?Y9(t,e).length>0||Gd(t,e)?!0:jw(t,e).length>0:!1:!1}function G9(t){const e=[];for(const[s,n]of Object.entries(t))if(n&&typeof n=="object"&&!Array.isArray(n)){const i=n;typeof i.__resolveType=="string"&&u3.has(i.__resolveType)&&typeof i.path=="string"&&e.push({key:s,name:typeof i.name=="string"?i.name:Sw(s),path:i.path})}return e}function pc(t,e){if(typeof e.name=="string"){const s=e.name.trim();if(s)return s}return t.replace(/[-_]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Tl(t,e,s){const n=typeof e.__resolveType=="string"?e.__resolveType:"",i=n?gi(n,s):{};if(i.title)return i.title;if(typeof e.name=="string"){const o=e.name.trim();if(o)return o}return t.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase())}function Gd(t,e){const s=t[po];if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s,i=n.__resolveType;if(typeof i=="string"&&(Nl(po,n)||e3(e,i)))return{key:po,name:Tl(po,n,e),resolveType:i}}for(const[n,i]of Object.entries(t)){if(n.includes("/")||!i||typeof i!="object"||Array.isArray(i))continue;const o=i;if(!Nl(n,o))continue;const a=typeof o.__resolveType=="string"?o.__resolveType:W9;return{key:n,name:Tl(n,o,e),resolveType:a}}return null}function jw(t,e){const s=[];for(const[n,i]of Object.entries(t)){if(n.includes("/")||!i||typeof i!="object"||Array.isArray(i))continue;const o=i,a=o.__resolveType;typeof a=="string"&&(u3.has(a)||typeof o.path!="string"&&(Nl(n,o)||!e3(e,a)&&!t3(a)||s.push({key:n,name:Tl(n,o,e),resolveType:a})))}return s.sort((n,i)=>n.name.localeCompare(i.name))}function Y9(t,e){return a3(e,t).map(s=>{const n=t[s.resolveType],i=typeof n.__resolveType=="string"?n.__resolveType:"";return{key:s.resolveType,name:s.description??pc(s.resolveType,n),resolveType:i}}).sort((s,n)=>s.name.localeCompare(n.name))}const Cw={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{},subscribeReloadStart:()=>()=>{}},h3=N.createContext(Cw),zh=16384;class kw{data="";append(e){this.data+=e,this.data.length>zh&&(this.data=this.data.slice(this.data.length-zh))}get(){return this.data}clear(){this.data=""}}const Vw=1e3,Nw=3e4,Tw=3e3,Kh=["lifecycle","status","tasks","scripts","branch","reload","file-changed"],Uh="log";function Aw(t,e,s,n){return t[0]==="live-meta"&&t[1]===e&&t[2]===s&&t[3]===n}function Ew(t){if(!t)return null;try{return new URL("/_sandbox/events",t).href}catch{return null}}function Pw(t){return t===404}async function Rw(t){try{const e=await fetch(t,{headers:{Accept:"text/event-stream"},cache:"no-store",signal:AbortSignal.timeout(Tw)});return await e.body?.cancel().catch(()=>{}),Pw(e.status)}catch{return!1}}function Dw({virtualMcpId:t,branch:e,previewUrl:s=null,enabled:n=!0,children:i}){const{org:o}=ze(),a=Ls(),[l,c]=N.useState(null),[d,h]=N.useState({phase:"idle"}),[u,f]=N.useState({state:"running"}),[m,p]=N.useState({kind:"unknown"}),[g,x]=N.useState(!1),[v,b]=N.useState([]),[_,y]=N.useState([]),[,L]=N.useState(0),w=N.useRef(new Map),j=N.useRef(new Set),S=N.useRef(new Set),k=N.useRef(new Set),C=N.useRef(null),A=Ew(s),P=T=>{let R=w.current.get(T);return R||(R=new kw,w.current.set(T,R)),R};N.useEffect(()=>{if(c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),C.current=null,x(!1),b([]),y([]),w.current.clear(),!t||!e||!n)return;const T=`/api/${encodeURIComponent(o.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let R=!1,E=0,I=null,D=null,M=null,O=null,$=null,B=null;const z=J=>{try{const ee=JSON.parse(J.data);c(ee),ee.kind!=="failed"&&(x(!1),E=0),ee.kind==="ready"&&H()}catch(ee){console.warn("[vm-events] bad phase payload",ee)}},K=()=>{x(!0),c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),b([]),y([]),w.current.clear()},Y=J=>{try{const ee=JSON.parse(J.data);if(typeof ee.data!="string")return;E=0;const W=ee.data.replace(/\r?\n/g,`\r
7
- `);P(ee.source).append(W);for(const Z of j.current)try{Z(ee.source,W)}catch{}L(Z=>Z+1)}catch{}},Q=J=>{const ee=J.type;try{const W=JSON.parse(J.data);switch(E=0,ee){case"lifecycle":{const Z=W;if(h(Z.state),Z.state.phase==="running"&&B!=="running"){const se=`${o.slug}/${t}/${e}`;a.invalidateQueries({queryKey:Qe.decofile(se)}),a.invalidateQueries({predicate:re=>re.queryKey[0]==="live-meta"&&typeof re.queryKey[1]=="string"&&re.queryKey[1].startsWith(`${se}/`)})}B=Z.state.phase;const G=Z.state.phase==="running"?Z.state.port:null,te=C.current;if(C.current=G,te!==null&&G!==null&&te!==G)for(const se of S.current)try{se()}catch{}return}case"status":f(W);return;case"tasks":{const G=W.active.map(te=>te.logName??"").filter(Boolean);y(G);return}case"scripts":b(W.scripts);return;case"branch":{const Z=W.meta;p(Z);return}case"reload":for(const Z of S.current)try{Z()}catch{}return;case"file-changed":{const{path:Z}=W,G=`${o.slug}/${t}/${e}`;if(Z.startsWith(".deco/")||Z.includes("/.deco/")){if(B!=="running")return;for(const se of k.current)try{se()}catch{}M&&clearTimeout(M),M=setTimeout(()=>{M=null,a.invalidateQueries({queryKey:Qe.decofile(G)});for(const se of S.current)try{se()}catch{}},500)}else D&&clearTimeout(D),D=setTimeout(()=>{D=null,a.invalidateQueries({predicate:se=>Aw(se.queryKey,o.slug,t,e)})},1e3);return}}}catch{}};function q(){if(R)return;const J=new EventSource(T);O=J,J.onopen=()=>{},J.onerror=()=>{O===J&&J.readyState===EventSource.CLOSED&&X("studio")},J.addEventListener("phase",z),J.addEventListener("gone",K),J.addEventListener(Uh,Y);for(const ee of Kh)J.addEventListener(ee,Q)}function H(){if(R||!A||$)return;const J=new EventSource(A);$=J;let ee=!1;J.onopen=()=>{if(R||$!==J)return;ee=!0,E=0;const W=O;O=null,W?.close()},J.onerror=()=>{$===J&&J.readyState===EventSource.CLOSED&&U(J,ee)},J.addEventListener(Uh,Y);for(const W of Kh)J.addEventListener(W,Q)}async function U(J,ee){const W=A?await Rw(A):!1;if(!(R||$!==J)){if(J.close(),$=null,W){K(),O||q();return}ee&&X("direct")}}function X(J){if(R||I)return;const ee=Math.min(Vw*2**E,Nw);E++,I=setTimeout(()=>{if(I=null,!R){if(J==="direct"){$?.close(),$=null,H();return}O?.close(),O=null,q()}},ee)}return q(),()=>{R=!0,O?.close(),$?.close(),I&&clearTimeout(I),D&&clearTimeout(D),M&&clearTimeout(M)}},[t,e,o.slug,n,A,a]);const V={phase:l,lifecycle:d,status:u,branch:m,notFound:g,scripts:v,activeProcesses:_,getBuffer:T=>w.current.get(T)?.get()??"",hasData:T=>(w.current.get(T)?.get().length??0)>0,subscribeChunks:T=>(j.current.add(T),()=>{j.current.delete(T)}),subscribeReload:T=>(S.current.add(T),()=>{S.current.delete(T)}),subscribeReloadStart:T=>(k.current.add(T),()=>{k.current.delete(T)})};return r.jsx(h3,{value:V,children:i})}function Ps(){return N.use(h3)}function f3(t){const{subscribeChunks:e}=Ps(),s=N.useRef(t);s.current=t,N.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function Iw(t){const{subscribeReload:e}=Ps(),s=N.useRef(t);s.current=t,N.useEffect(()=>e(()=>{s.current?.()}),[e])}function Mw(t){const{subscribeReloadStart:e}=Ps(),s=N.useRef(t);s.current=t,N.useEffect(()=>e(()=>{s.current?.()}),[e])}function m3(t){const e=Object.values(t),[s]=e;return s?e.find(n=>n.sandboxProviderKind!=="user-desktop")??s:null}function Ow(t){return t.othersThreadGate&&!t.previewUrl?{kind:"othersThread",label:t.othersThreadGate.label}:t.appPaused||t.userStopped?{kind:"suspended"}:t.startError&&!t.previewUrl?{kind:"errored",error:t.startError}:t.previewUrl?{kind:"iframe",previewUrl:t.previewUrl}:{kind:"starting"}}const p3={githubNotAuthenticated:"GITHUB_NOT_AUTHENTICATED"},Hh="::";function $w(t){const e=t.indexOf(Hh);if(e>0){const s=t.slice(0,e);if(Object.values(p3).includes(s))return{code:s,message:t.slice(e+Hh.length)}}return{code:null,message:t}}function Bw(t){return t.hasActiveGithubRepo&&!!t.userId&&!t.vmEntry&&!t.userStopped&&!t.isPending&&!t.attempted&&!t.autoStartBlocked}function Fw(t){return t.notFound&&!!t.deadVmId&&!t.isPending&&!t.userStopped&&!t.autoStartBlocked&&t.deadVmId!==t.lastDeadVmId}function zw(t){return!!t.userId&&!!t.createdBy&&t.createdBy!==t.userId?t.branch??t.title??null:null}function Kw(t){const e=t.acknowledgedThreadId!==null&&t.acknowledgedThreadId===t.threadId;return{autoStartBlocked:!!t.othersThreadLabel&&!e}}function ka(t,e,s){const n={virtualMcpId:t};return e&&(n.branch=e),s&&(n.sandboxProviderKind=s),n}const g3=2,Uw=new Set(["scheduling-timeout","reconciler-error","claim-never-created","unknown"]);function x3(t){return Uw.has(t)}function Hw(t){return t.failedReason!==null&&x3(t.failedReason)&&t.attempts<g3&&!t.isPending&&!t.userStopped&&!t.autoStartBlocked&&!t.alreadyHandled}function Ww(t){return t.mutationError?t.mutationError:t.phase?.kind==="failed"&&!t.startPending&&t.claimRetryExhausted?{code:null,message:t.phase.message}:null}function qw(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting";case"errored":return"errored";case"othersThread":return"idle"}}const Gw={branch:null,previewState:{kind:"starting"},status:"idle",vmEntry:null,previewUrl:null,userStopped:!1,start:()=>{},stop:async()=>{},restart:async()=>{},retry:()=>{},resume:()=>{},acknowledgeOthersThread:()=>{}},v3=N.createContext(Gw);function Yi(){return N.use(v3)}function Yw({virtualMcpId:t,branch:e,userId:s,hasActiveGithubRepo:n,sandboxMap:i,sandboxProviderKind:o,sharedDesiredState:a,sharedLifecyclePending:l,othersThreadLabel:c,othersThreadId:d,children:h}){const{org:u}=ze(),{setCurrentTaskBranch:f}=ls(),m=Ps(),p=Ls(),[g,x]=N.useState(null),{autoStartBlocked:v}=Kw({othersThreadLabel:c,acknowledgedThreadId:g,threadId:d}),b=pt({connectionId:Xl,orgId:u.id,orgSlug:u.slug}),_=$p(b),{mutate:y,reset:L}=_,w=N.useRef(new Set),j=N.useRef(null),S=N.useRef(0),k=N.useRef(!1),C=s&&e?Rd(i?.[s]?.[e]):{},A=o?C[o]??null:m3(C),P=A?.previewUrl??null,V=a==="stopped"||!!t&&!!e&&Ud.isStopped(t,e),T=m.status.state==="paused",R=m.phase?.kind==="failed"?m.phase:null,E=!R||!x3(R.reason)||S.current>=g3,I=Ww({mutationError:_.isError&&_.error?$w(_.error.message):null,phase:m.phase,startPending:_.isPending||l,claimRetryExhausted:E}),D=Ow({previewUrl:P,appPaused:T,userStopped:V,startError:I,othersThreadGate:v&&c?{label:c}:null}),M=qw(D),O=e??"",$=w.current.has(O),B=Bw({hasActiveGithubRepo:n,userId:s,vmEntry:A,userStopped:V,isPending:_.isPending||l,attempted:$,autoStartBlocked:v});N.useEffect(()=>{if(!B||!t)return;w.current.add(O);const W=ka(t,e,o);y(W,{onSuccess:Z=>{Z?.branch&&!e&&f(Z.branch)},onError:Z=>{console.error("[sandbox-lifecycle] auto-start failed:",Z)}})},[B,O,e,t,o,y,f]);const z=m.notFound?A?.sandboxHandle??null:null,K=Fw({notFound:m.notFound,deadVmId:z,lastDeadVmId:j.current,isPending:_.isPending||l,userStopped:V,autoStartBlocked:v});N.useEffect(()=>{if(!K||!z||!t)return;j.current=z;const W=ka(t,e,o);y(W,{onSuccess:Z=>{Z?.branch&&!e&&f(Z.branch)},onError:Z=>{console.error("[sandbox-lifecycle] self-heal failed:",Z)}})},[K,z,t,e,o,y,f]);const Y=Hw({failedReason:R?.reason??null,attempts:S.current,isPending:_.isPending||l,userStopped:V,autoStartBlocked:v,alreadyHandled:k.current});N.useEffect(()=>{if(!R){k.current=!1;return}if(!Y||!t)return;k.current=!0,S.current+=1;const W=ka(t,e,o);y(W,{onSuccess:Z=>{Z?.branch&&!e&&f(Z.branch)},onError:Z=>{console.error("[sandbox-lifecycle] claim auto-retry failed:",Z)}})},[R,Y,t,e,o,y,f]);const Q=()=>{if(!t)return;const W=ka(t,e,o);y(W,{onSuccess:Z=>{Z?.branch&&!e&&f(Z.branch)},onError:Z=>{console.error("[sandbox-lifecycle] user start failed:",Z)}})},q=async()=>{if(!t||!e)return;const W=A?.sandboxProviderKind;if(W){Ud.mark(t,e);try{await b.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:t,branch:e,sandboxProviderKind:W}})}catch{}Tm(p),e&&p.invalidateQueries({queryKey:Qe.agentSandboxSession(u.slug,t,e)})}},H=async()=>{await q(),Q()},U=()=>{w.current=new Set,j.current=null,S.current=0,k.current=!1,L(),Q()},ee={branch:e,previewState:D,status:M,vmEntry:A,previewUrl:P,userStopped:V,start:Q,stop:q,restart:H,retry:U,resume:U,acknowledgeOthersThread:()=>x(d)};return r.jsx(v3,{value:ee,children:h})}const Jw={overview:C6,settings:d2,automations:n9,preview:pi,code:j6,content:Pi,git:en,files:ri};function Wh(t){const e=ec(t);if(e.type==="icon"){const s=zi(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Va(t){if(t.kind==="system")return{kind:"component",Component:Jw[t.tabId]};const e=Wh(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(i=>i.id===t.appId);if(!s)return{kind:"fallback"};const n=Wh(s.icon);return n||{kind:"fallback"}}const Xw=[{id:"preview",title:"Preview"},{id:"code",title:"Code"}];function Qw(t){return t?[...Xw]:[]}function b3(t){return t.reportsOnly&&!t.onReportAgent&&(t.tabId==="preview"||t.tabId==="code")}function Zw(t){const{org:e}=ze(),s=Fs(),n=Zm(),i=N.useSyncExternalStore(n.threads.subscribe,n.threads.get),o=t?i.find(l=>l.id===t)??null:null,{data:a}=Pm({queryKey:Qe.ensureTask(e.id,t),queryFn:async()=>{if(!t)return null;try{const{item:l}=await s.call("COLLECTION_THREADS_GET",{id:t});return l??null}catch{return null}},select:l=>l?.metadata??null,staleTime:3e4});return o?.metadata??a??null}function J9(t){const e=F.c(35),s=oe(),n=jt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const o=Vr(i),a=ms(t.virtualMcpId),l=Zw(t.taskId),{org:c}=ze(),{currentBranch:d}=ls();let h;e[1]!==a?(h=aa(a),e[1]=a,e[2]=h):h=e[2];const u=h,f=u?.connectionId??"",m=u?.owner??"",p=u?.name??"",g=u?d:null;let x;e[3]!==c.id||e[4]!==c.slug||e[5]!==f||e[6]!==m||e[7]!==p||e[8]!==g?(x={orgId:c.id,orgSlug:c.slug,connectionId:f,owner:m,repo:p,branch:g},e[3]=c.id,e[4]=c.slug,e[5]=f,e[6]=m,e[7]=p,e[8]=g,e[9]=x):x=e[9];const v=O9(x),b=v.data?.state==="open",_=a?.metadata?.ui??null,y=_?.layout??null,L=y?.tabs??[],w=a?.id?Av(a.id):null,j=l?.expanded_tools??[],S=S2(a),k=$s(a?.metadata)||$s(l),{granted:C}=u8("agents:manage"),A=rc();let P;e[10]===Symbol.for("react.memo_cache_sentinel")?(P={includeVirtual:!0},e[10]=P):P=e[10];const V=Mn(P),T=Ps(),{vmEntry:R,previewUrl:E}=Yi(),I=T.lifecycle.phase==="running";let D;e[11]!==E||e[12]!==R?.sandboxProviderKind?(D=R?.sandboxProviderKind==="user-desktop"&&E?`${E.replace(/\/+$/,"")}/api/mcp`:void 0,e[11]=E,e[12]=R?.sandboxProviderKind,e[13]=D):D=e[13];const M=D,O=Ev({connectionId:w??void 0,orgId:c.id,orgSlug:c.slug,mcpUrl:M}),$=O,B=!!O&&I;let z;e[14]!==B||e[15]!==$?(z={client:$,enabled:B},e[14]=B,e[15]=$,e[16]=z):z=e[16];const{data:K}=y9(z),Y=w&&I?(K?.tools??[]).filter(sj).map(ke=>({connectionId:w,toolName:ke.name,label:Ai(ke.name),icon:null})):[],Q=Y[0],q=Q?Y:_?.pinnedViews??[],H=Q&&w?{type:"ext-apps",id:w,toolName:Q.toolName}:y?.defaultMainView??null,U=k&&a?.id&&d?{orgSlug:c.slug,virtualMcpId:a.id,branch:d,previewUrl:E}:null;let X;e[17]!==I?(X={fetchEnabled:I},e[17]=I,e[18]=X):X=e[18];const{data:J}=uc(U,X);let ee;e[19]!==I?(ee={fetchEnabled:I},e[19]=I,e[20]=ee):ee=e[20];const{data:W}=hc(U,ee),Z=q9(J,W),{activeTab:G,mainOpen:te}=qb({mainParam:o.main,metadata:H||y?{defaultMainView:H,tabs:L.map(tj)}:null}),se=S&&(b||v.isPending&&G==="git"),re=H||y?{defaultMainView:H,tabs:L.map(ej)}:null,de=G==="git"&&!se&&!v.isPending?ml(re):G==="content"&&!Z?ml(re):G,ce=G==="git"&&!se&&!v.isPending?!1:te,fe=T2(de),ue=[];(H?.type==="overview"||A)&&ue.push({id:"overview",title:s("common.mainPanelTabs.overview")});let ae;e[21]!==s?(ae=ke=>({id:ke.id,title:ke.id==="preview"?s("common.mainPanelTabs.preview"):ke.id==="code"?s("common.mainPanelTabs.code"):ke.title}),e[21]=s,e[22]=ae):ae=e[22],ue.push(...Qw(k||A).map(ae));const me=[];k&&Z&&me.push({id:"content",title:s("common.mainPanelTabs.content")}),se&&me.push({id:"git",title:s("common.mainPanelTabs.reviewChanges")}),A||(me.push({id:"automations",title:s("common.mainPanelTabs.automations")}),C&&me.push({id:"settings",title:s("common.mainPanelTabs.settings")}));const xe=new Map;for(const ke of j){const $e=Ja(ke.appId,ke.toolName);xe.set($e,{id:$e,title:ke.toolName,appId:ke.appId,iconKey:ke.toolName})}for(const ke of q){const $e=Ja(ke.connectionId,ke.toolName);xe.set($e,{id:$e,title:ke.label||ke.toolName,appId:ke.connectionId,iconKey:ke.toolName,iconUrl:ke.icon??null})}if(A){const ke=Pv.COMMERCE_DISCOVERY(c.id),$e=Ja(ke,eh);xe.has($e)||xe.set($e,{id:$e,title:s("common.mainPanelTabs.report"),appId:ke,iconKey:eh,iconUrl:Rv})}const Se=A2(de),Ve=Se?Se.key.split("/").pop()??Se.key:null,Ie=Ve?[{id:de,title:Ve,kind:"file",icon:{kind:"component",Component:ke=>N.createElement(yr,{filename:Ve,...ke})}}]:[],Ne=E2(de),Ee=Ne?[{id:de,title:(Ne.path.split("/").pop()??Ne.path).replace(/\.html$/i,""),kind:"file",icon:{kind:"component",Component:ke=>N.createElement(Ne.path.startsWith("pages/")?pi:sc,ke)}}]:[],we=P2(de),Ae=we?we.path.split("/").pop()??we.path:null,be=Ae?[{id:de,title:Ae,kind:"file",icon:{kind:"component",Component:ke=>N.createElement(yr,{filename:Ae,...ke})}}]:[];let je;e[23]!==V?(je=ke=>({id:ke.id,title:ke.title,kind:"agent",icon:Va({tabId:ke.id,kind:"agent",appId:ke.view.appId,connections:V})}),e[23]=V,e[24]=je):je=e[24];const ge=[...ue.map(ke=>({id:ke.id,title:ke.title,kind:"system",icon:Va({tabId:ke.id,kind:"system",connections:V})})),...Ie,...Ee,...be,...L.map(je),...Array.from(xe.values()).map(ke=>({id:ke.id,title:ke.title,kind:"expanded",icon:Va({tabId:ke.iconKey,kind:"expanded",appId:ke.appId,iconUrl:ke.iconUrl,connections:V})})),...me.map(ke=>({id:ke.id,title:ke.title,kind:"system",icon:Va({tabId:ke.id,kind:"system",connections:V})}))],Le=t.virtualMcpId;let ye;e[25]!==c.id?(ye=dl(c.id),e[25]=c.id,e[26]=ye):ye=e[26];const Ce=Le===ye;let Me;return e[27]!==de||e[28]!==ce||e[29]!==n||e[30]!==Ce||e[31]!==c.id||e[32]!==c.slug||e[33]!==A?(Me=ke=>{if(b3({reportsOnly:A,onReportAgent:Ce,tabId:ke})){n({to:"/$org/$taskId",params:{org:c.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:dl(c.id),main:ke}});return}const $e=Gb({clickedId:ke,activeTab:de,mainOpen:ce});n({to:".",search:qe=>({...qe,main:$e}),replace:!0})},e[27]=de,e[28]=ce,e[29]=n,e[30]=Ce,e[31]=c.id,e[32]=c.slug,e[33]=A,e[34]=Me):Me=e[34],{activeTab:de,mainOpen:ce,setActiveTab:Me,systemTabs:[...ue,...me],layoutTabs:L,expandedTools:j,automationTabParsed:fe,tabs:ge}}function ej(t){return{id:t.id}}function tj(t){return{id:t.id}}function sj(t){return!!oc(t._meta)}function y3(t){const{managerAgentId:e,managerName:s,kind:n,id:i,instructions:o}=t,a=` to improve the instructions of ${n} "${i}". Here are its current instructions.
8
- <current_instructions>${o}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function nj(t){const e=F.c(9),s=Fs();let n;e[0]!==t?(n=Qe.user(t),e[0]=t,e[1]=n):n=e[1];let i;e[2]!==s||e[3]!==t?(i=async()=>{const{user:l}=await s.call("USER_GET",{id:t});return l},e[2]=s,e[3]=t,e[4]=i):i=e[4];const o=!!t;let a;return e[5]!==n||e[6]!==i||e[7]!==o?(a={queryKey:n,queryFn:i,staleTime:3e5,retry:1,enabled:o},e[5]=n,e[6]=i,e[7]=o,e[8]=a):a=e[8],Pt(a)}function _3(t){const e=F.c(37),{id:s,size:n,showEmail:i,avatarOnly:o,className:a}=t,l=n===void 0?"xs":n,c=i===void 0?!1:i,d=o===void 0?!1:o,h=oe(),{data:u,isLoading:f,isError:m}=nj(s);if(f){let _;e[0]!==a?(_=ie("flex items-center gap-2",a),e[0]=a,e[1]=_):_=e[1];let y;e[2]!==l?(y=r.jsx(ur.Skeleton,{shape:"circle",size:l}),e[2]=l,e[3]=y):y=e[3];let L;e[4]!==d||e[5]!==c?(L=!d&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"h-3 w-24 bg-muted animate-pulse rounded"}),c&&r.jsx("div",{className:"h-2 w-32 bg-muted animate-pulse rounded"})]}),e[4]=d,e[5]=c,e[6]=L):L=e[6];let w;return e[7]!==_||e[8]!==y||e[9]!==L?(w=r.jsxs("div",{className:_,children:[y,L]}),e[7]=_,e[8]=y,e[9]=L,e[10]=w):w=e[10],w}if(m||!u){let _;e[11]!==a?(_=ie("flex items-center gap-2",a),e[11]=a,e[12]=_):_=e[12];let y;e[13]!==l?(y=r.jsx(ur,{shape:"circle",size:l,fallback:"?",muted:!0}),e[13]=l,e[14]=y):y=e[14];let L;e[15]!==d||e[16]!==h?(L=!d&&r.jsx("div",{className:"flex flex-col",children:r.jsx("div",{className:"text-sm text-muted-foreground",children:h("user.user.unknownUser")})}),e[15]=d,e[16]=h,e[17]=L):L=e[17];let w;return e[18]!==_||e[19]!==y||e[20]!==L?(w=r.jsxs("div",{className:_,children:[y,L]}),e[18]=_,e[19]=y,e[20]=L,e[21]=w):w=e[21],w}let p;e[22]!==a?(p=ie("flex items-center gap-2",a),e[22]=a,e[23]=p):p=e[23];const g=u.image??void 0;let x;e[24]!==l||e[25]!==g||e[26]!==u.name?(x=r.jsx(ur,{shape:"circle",size:l,url:g,fallback:u.name}),e[24]=l,e[25]=g,e[26]=u.name,e[27]=x):x=e[27];let v;e[28]!==d||e[29]!==c||e[30]!==u.email||e[31]!==u.name?(v=!d&&r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"text-sm font-medium",children:u.name}),c&&r.jsx("div",{className:"text-xs text-muted-foreground",children:u.email})]}),e[28]=d,e[29]=c,e[30]=u.email,e[31]=u.name,e[32]=v):v=e[32];let b;return e[33]!==p||e[34]!==x||e[35]!==v?(b=r.jsxs("div",{className:p,children:[x,v]}),e[33]=p,e[34]=x,e[35]=v,e[36]=b):b=e[36],b}function ij(t){const e=F.c(8);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let i;e[3]!==s?(i=ie("grid gap-3",s),e[3]=s,e[4]=i):i=e[4];let o;return e[5]!==n||e[6]!==i?(o=r.jsx(x8,{"data-slot":"radio-group",className:i,...n}),e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function rj(t){const e=F.c(9);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let i;e[3]!==s?(i=ie("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/20 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[2px] disabled:opacity-50",s),e[3]=s,e[4]=i):i=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(v8,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:r.jsx(b8,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})}),e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==i?(a=r.jsx(g8,{"data-slot":"radio-group-item",className:i,...n,children:o}),e[6]=n,e[7]=i,e[8]=a):a=e[8],a}function oj(t){const e=F.c(82),{value:s,onChange:n,onColorChange:i,name:o,size:a,className:l,avatarClassName:c,showHoverOverlay:d,disabled:h}=t,u=a===void 0?"lg":a,f=d===void 0?!0:d,m=h===void 0?!1:h,p=oe(),[g,x]=N.useState(!1),[v,b]=N.useState("icons"),[_,y]=N.useState(""),[L,w]=N.useState("blue");let j;e[0]!==s?(j=ec(s),e[0]=s,e[1]=j):j=e[1];const S=j,k=S.type==="icon"||S.type==="url"&&S.color?S.color:L;let C;e[2]!==n||e[3]!==k?(C=xe=>{n(Kc(xe,k))},e[2]=n,e[3]=k,e[4]=C):C=e[4];const A=C;let P;e[5]!==n||e[6]!==i||e[7]!==S.name||e[8]!==S.type||e[9]!==S.url?(P=xe=>{w(xe),i?.(xe),S.type==="icon"?n(Kc(S.name,xe)):S.type==="url"&&n(ih(S.url,xe))},e[5]=n,e[6]=i,e[7]=S.name,e[8]=S.type,e[9]=S.url,e[10]=P):P=e[10];const V=P;let T;e[11]!==n||e[12]!==k?(T=xe=>{n(ih(xe,k)),x(!1)},e[11]=n,e[12]=k,e[13]=T):T=e[13];const R=T;let E;e[14]!==n||e[15]!==k?(E=()=>{const xe=i9(),Se=xe[Math.floor(Math.random()*xe.length)];n(Kc(Se,k))},e[14]=n,e[15]=k,e[16]=E):E=e[16];const I=E,D=m?!1:g,M=m?"cursor-default opacity-50":"cursor-pointer";let O;e[17]!==l||e[18]!==u||e[19]!==M?(O=ie("relative group overflow-hidden",M,k6(u),l),e[17]=l,e[18]=u,e[19]=M,e[20]=O):O=e[20];let $;e[21]!==c||e[22]!==o||e[23]!==u||e[24]!==s?($=r.jsx(ii,{icon:s,name:o,size:u,className:c}),e[21]=c,e[22]=o,e[23]=u,e[24]=s,e[25]=$):$=e[25];let B;e[26]!==m||e[27]!==f?(B=f&&!m&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:r.jsx(f2,{size:16,className:"text-white"})}),e[26]=m,e[27]=f,e[28]=B):B=e[28];let z;e[29]!==m||e[30]!==O||e[31]!==$||e[32]!==B?(z=r.jsx(Ts,{asChild:!0,children:r.jsxs("button",{type:"button","data-testid":"icon-picker-trigger","aria-label":"Change icon",disabled:m,className:O,children:[$,B]})}),e[29]=m,e[30]=O,e[31]=$,e[32]=B,e[33]=z):z=e[33];let K;e[34]!==o||e[35]!==s?(K=r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx(ii,{icon:s,name:o,size:"xl"})}),e[34]=o,e[35]=s,e[36]=K):K=e[36];let Y;e[37]!==v?(Y=xe=>{if(xe.key!=="ArrowLeft"&&xe.key!=="ArrowRight")return;xe.preventDefault();const Se=v==="icons"?"upload":"icons";b(Se),document.getElementById(`icon-picker-tab-${Se}`)?.focus()},e[37]=v,e[38]=Y):Y=e[38];const Q=v==="icons",q=v==="icons"?0:-1;let H;e[39]===Symbol.for("react.memo_cache_sentinel")?(H=()=>b("icons"),e[39]=H):H=e[39];const U=v==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let X;e[40]!==U?(X=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",U),e[40]=U,e[41]=X):X=e[41];let J;e[42]!==p?(J=p("common.iconPicker.iconsTab"),e[42]=p,e[43]=J):J=e[43];let ee;e[44]!==Q||e[45]!==q||e[46]!==X||e[47]!==J?(ee=r.jsx("button",{id:"icon-picker-tab-icons",type:"button",role:"tab","aria-selected":Q,"aria-controls":"icon-picker-panel-icons",tabIndex:q,onClick:H,className:X,children:J}),e[44]=Q,e[45]=q,e[46]=X,e[47]=J,e[48]=ee):ee=e[48];const W=v==="upload",Z=v==="upload"?0:-1;let G;e[49]===Symbol.for("react.memo_cache_sentinel")?(G=()=>b("upload"),e[49]=G):G=e[49];const te=v==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let se;e[50]!==te?(se=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",te),e[50]=te,e[51]=se):se=e[51];let re;e[52]!==p?(re=p("common.iconPicker.uploadTab"),e[52]=p,e[53]=re):re=e[53];let de;e[54]!==W||e[55]!==Z||e[56]!==se||e[57]!==re?(de=r.jsx("button",{id:"icon-picker-tab-upload",type:"button",role:"tab","aria-selected":W,"aria-controls":"icon-picker-panel-upload",tabIndex:Z,onClick:G,className:se,children:re}),e[54]=W,e[55]=Z,e[56]=se,e[57]=re,e[58]=de):de=e[58];let ce;e[59]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx("div",{className:"flex-1"}),e[59]=ce):ce=e[59];let fe;e[60]!==Y||e[61]!==ee||e[62]!==de?(fe=r.jsxs("div",{role:"tablist","aria-label":"Icon source",className:"flex items-center border-b border-border px-3",onKeyDown:Y,children:[ee,de,ce]}),e[60]=Y,e[61]=ee,e[62]=de,e[63]=fe):fe=e[63];let ue;e[64]!==V||e[65]!==I||e[66]!==A||e[67]!==R||e[68]!==S.name||e[69]!==S.type||e[70]!==_||e[71]!==k||e[72]!==v?(ue=v==="icons"?r.jsx("div",{id:"icon-picker-panel-icons",role:"tabpanel","aria-labelledby":"icon-picker-tab-icons",children:r.jsx(dj,{search:_,onSearchChange:y,selectedColor:k,onColorChange:V,onSelectIcon:A,onRandom:I,currentIconName:S.type==="icon"?S.name:null})}):r.jsx("div",{id:"icon-picker-panel-upload",role:"tabpanel","aria-labelledby":"icon-picker-tab-upload",children:r.jsx(uj,{onUpload:R})}),e[64]=V,e[65]=I,e[66]=A,e[67]=R,e[68]=S.name,e[69]=S.type,e[70]=_,e[71]=k,e[72]=v,e[73]=ue):ue=e[73];let ae;e[74]!==K||e[75]!==fe||e[76]!==ue?(ae=r.jsx(As,{align:"start",className:"w-80 p-0",onOpenAutoFocus:aj,children:r.jsxs("div",{className:"flex flex-col",children:[K,fe,ue]})}),e[74]=K,e[75]=fe,e[76]=ue,e[77]=ae):ae=e[77];let me;return e[78]!==z||e[79]!==ae||e[80]!==D?(me=r.jsxs(Es,{open:D,onOpenChange:x,children:[z,ae]}),e[78]=z,e[79]=ae,e[80]=D,e[81]=me):me=e[81],me}function aj(t){return t.preventDefault()}function lj(t){const e=F.c(33),{selectedColor:s,onColorChange:n}=t,i=oe(),[o,a]=N.useState(!1);let l,c,d,h,u,f,m;if(e[0]!==o||e[1]!==s){const L=u2(s);c=Es,f=o,m=a,l=Ts,u=!0,d="button",h=ie("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",L.dot,"ring-foreground/20"),e[0]=o,e[1]=s,e[2]=l,e[3]=c,e[4]=d,e[5]=h,e[6]=u,e[7]=f,e[8]=m}else l=e[2],c=e[3],d=e[4],h=e[5],u=e[6],f=e[7],m=e[8];let p;e[9]!==i?(p=i("common.iconPicker.changeColor"),e[9]=i,e[10]=p):p=e[10];let g;e[11]!==i?(g=i("common.iconPicker.changeColor"),e[11]=i,e[12]=g):g=e[12];let x;e[13]!==d||e[14]!==h||e[15]!==p||e[16]!==g?(x=r.jsx("button",{type:d,className:h,title:p,"aria-label":g}),e[13]=d,e[14]=h,e[15]=p,e[16]=g,e[17]=x):x=e[17];let v;e[18]!==l||e[19]!==u||e[20]!==x?(v=r.jsx(l,{asChild:u,children:x}),e[18]=l,e[19]=u,e[20]=x,e[21]=v):v=e[21];let b;e[22]!==n||e[23]!==s?(b=N6.map(L=>r.jsx("button",{type:"button",onClick:()=>{n(L.name),a(!1)},className:ie("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",L.dot,s===L.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:L.name,"aria-label":L.name},L.name)),e[22]=n,e[23]=s,e[24]=b):b=e[24];let _;e[25]!==b?(_=r.jsx(As,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:cj,children:r.jsx("div",{className:"grid grid-cols-4 gap-1",children:b})}),e[25]=b,e[26]=_):_=e[26];let y;return e[27]!==c||e[28]!==_||e[29]!==f||e[30]!==m||e[31]!==v?(y=r.jsxs(c,{open:f,onOpenChange:m,children:[v,_]}),e[27]=c,e[28]=_,e[29]=f,e[30]=m,e[31]=v,e[32]=y):y=e[32],y}function cj(t){return t.preventDefault()}function dj(t){const e=F.c(55),{search:s,onSearchChange:n,selectedColor:i,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:c}=t,d=oe();let h,u,f,m,p,g,x;if(e[0]!==c||e[1]!==o||e[2]!==l||e[3]!==n||e[4]!==a||e[5]!==s||e[6]!==i||e[7]!==d){const L=i9(),w=u2(i);u=h2(L,s),g="flex flex-col";let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Ko,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[15]=j):j=e[15];let S;e[16]!==n?(S=E=>n(E.target.value),e[16]=n,e[17]=S):S=e[17];let k;e[18]!==d?(k=d("common.iconPicker.filterPlaceholder"),e[18]=d,e[19]=k):k=e[19];let C;e[20]!==s||e[21]!==S||e[22]!==k?(C=r.jsxs("div",{className:"relative flex-1",children:[j,r.jsx(et,{value:s,onChange:S,placeholder:k,className:"h-8 text-xs pl-7"})]}),e[20]=s,e[21]=S,e[22]=k,e[23]=C):C=e[23];let A;e[24]!==d?(A=d("common.iconPicker.randomIcon"),e[24]=d,e[25]=A):A=e[25];let P;e[26]!==d?(P=d("common.iconPicker.randomIcon"),e[26]=d,e[27]=P):P=e[27];let V;e[28]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(V6,{size:14,className:"text-muted-foreground"}),e[28]=V):V=e[28];let T;e[29]!==l||e[30]!==A||e[31]!==P?(T=r.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:A,"aria-label":P,children:V}),e[29]=l,e[30]=A,e[31]=P,e[32]=T):T=e[32];let R;e[33]!==o||e[34]!==i?(R=r.jsx(lj,{selectedColor:i,onColorChange:o}),e[33]=o,e[34]=i,e[35]=R):R=e[35],e[36]!==T||e[37]!==R||e[38]!==C?(x=r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[C,T,R]}),e[36]=T,e[37]=R,e[38]=C,e[39]=x):x=e[39],h=fi,p="h-56",f="grid grid-cols-9 gap-0.5 px-2 pb-2",m=u.map(E=>{const I=zi(E);return I?r.jsx("button",{type:"button",onClick:()=>a(E),className:ie("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",c===E?ie(w.bg,w.text):ie(w.text,"hover:bg-accent")),title:E,"aria-label":Id(E),children:r.jsx(I,{size:18})},E):null}),e[0]=c,e[1]=o,e[2]=l,e[3]=n,e[4]=a,e[5]=s,e[6]=i,e[7]=d,e[8]=h,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=g,e[14]=x}else h=e[8],u=e[9],f=e[10],m=e[11],p=e[12],g=e[13],x=e[14];let v;e[40]!==f||e[41]!==m?(v=r.jsx("div",{className:f,children:m}),e[40]=f,e[41]=m,e[42]=v):v=e[42];let b;e[43]!==u.length||e[44]!==d?(b=u.length===0&&r.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:d("common.iconPicker.noIconsFound")}),e[43]=u.length,e[44]=d,e[45]=b):b=e[45];let _;e[46]!==h||e[47]!==p||e[48]!==v||e[49]!==b?(_=r.jsxs(h,{className:p,children:[v,b]}),e[46]=h,e[47]=p,e[48]=v,e[49]=b,e[50]=_):_=e[50];let y;return e[51]!==g||e[52]!==x||e[53]!==_?(y=r.jsxs("div",{className:g,children:[x,_]}),e[51]=g,e[52]=x,e[53]=_,e[54]=y):y=e[54],y}function uj(t){const e=F.c(46),{onUpload:s}=t,n=oe(),i=N.useRef(null);let o;e[0]!==s||e[1]!==n?(o=T=>{const R=T.target.files?.[0];if(!R)return;if(R.size>2097152){ve.error(n("common.iconPicker.imageTooLarge")),T.target.value="";return}const E=new FileReader;E.onerror=()=>{ve.error(n("common.iconPicker.failedToReadImage")),i.current&&(i.current.value="")},E.onloadend=()=>{E.readyState===FileReader.DONE&&E.result&&s(E.result),i.current&&(i.current.value="")},E.readAsDataURL(R)},e[0]=s,e[1]=n,e[2]=o):o=e[2];const a=o,[l,c]=N.useState("");let d;e[3]!==s||e[4]!==l?(d=()=>{const T=l.trim();T&&(s(T),c(""))},e[3]=s,e[4]=l,e[5]=d):d=e[5];const h=d;let u;e[6]!==a?(u=r.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=()=>i.current?.click(),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Ui,{size:20}),e[9]=m):m=e[9];let p;e[10]!==n?(p=n("common.iconPicker.uploadHint"),e[10]=n,e[11]=p):p=e[11];let g;e[12]!==p?(g=r.jsxs("button",{type:"button",onClick:f,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[m,r.jsx("span",{className:"text-xs",children:p})]}),e[12]=p,e[13]=g):g=e[13];let x;e[14]!==n?(x=n("common.iconPicker.or"),e[14]=n,e[15]=x):x=e[15];let v;e[16]!==x?(v=r.jsx("span",{className:"text-xs text-muted-foreground",children:x}),e[16]=x,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"flex-1 h-px bg-border"}),e[18]=b):b=e[18];let _;e[19]!==v?(_=r.jsxs("div",{className:"flex items-center gap-2",children:[v,b]}),e[19]=v,e[20]=_):_=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=T=>c(T.target.value),e[21]=y):y=e[21];let L;e[22]!==n?(L=n("common.iconPicker.pasteUrlPlaceholder"),e[22]=n,e[23]=L):L=e[23];let w;e[24]!==h?(w=T=>{T.key==="Enter"&&(T.preventDefault(),h())},e[24]=h,e[25]=w):w=e[25];let j;e[26]!==l||e[27]!==L||e[28]!==w?(j=r.jsx(et,{value:l,onChange:y,placeholder:L,className:"h-8 text-xs flex-1",onKeyDown:w}),e[26]=l,e[27]=L,e[28]=w,e[29]=j):j=e[29];let S;e[30]!==l?(S=l.trim(),e[30]=l,e[31]=S):S=e[31];const k=!S;let C;e[32]!==n?(C=n("common.iconPicker.apply"),e[32]=n,e[33]=C):C=e[33];let A;e[34]!==h||e[35]!==k||e[36]!==C?(A=r.jsx(le,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:h,disabled:k,children:C}),e[34]=h,e[35]=k,e[36]=C,e[37]=A):A=e[37];let P;e[38]!==j||e[39]!==A?(P=r.jsxs("div",{className:"flex items-center gap-1.5",children:[j,A]}),e[38]=j,e[39]=A,e[40]=P):P=e[40];let V;return e[41]!==_||e[42]!==P||e[43]!==u||e[44]!==g?(V=r.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,g,_,P]}),e[41]=_,e[42]=P,e[43]=u,e[44]=g,e[45]=V):V=e[45],V}const hj=25*1024*1024,Xc="home",Qc="knowledge";function qh(t){return t==null?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function xi(t){return t.split("/").pop()??t}function fj(t){const e=F.c(64),{form:s}=t,n=oe(),{upload:i}=Sb(Xc),o=wb(),a=N.useRef(null),[l,c]=N.useState(!1),[d,h]=N.useState(""),[u,f]=N.useState(!1);let m;e[0]!==l?(m={enabled:l},e[0]=l,e[1]=m):m=e[1];const{data:p}=jb(60,m),g=p===void 0?[]:p;let x;e[2]!==l?(x={enabled:l},e[2]=l,e[3]=x):x=e[3];const{data:v}=Cb(x),b=v===void 0?[]:v;let _;e[4]!==s?(_=()=>s.getValues("metadata.knowledge")??[],e[4]=s,e[5]=_):_=e[5];const[y,L]=N.useState(_);let w;e[6]!==s?(w=ae=>{L(ae),s.setValue("metadata.knowledge",ae,{shouldDirty:!0})},e[6]=s,e[7]=w):w=e[7];const j=w;let S;e[8]!==o||e[9]!==y||e[10]!==j||e[11]!==n||e[12]!==i?(S=async ae=>{if(!ae||ae.length===0)return;const me=Array.from(ae).filter(vj);if(me.length!==0){try{await i.mutateAsync({dir:Qc,files:me})}catch(xe){const Se=xe;ve.error(Se instanceof Error?Se.message:n("virtualMcp.filesSection.failedUploadFile"));return}j([...y,...me.map(xe=>({id:crypto.randomUUID(),name:xe.name,volume:Xc,path:`${Qc}/${xe.name}`,url:o(Xc,`${Qc}/${xe.name}`),contentType:xe.type||null,size:xe.size,addedAt:new Date().toISOString()}))])}},e[8]=o,e[9]=y,e[10]=j,e[11]=n,e[12]=i,e[13]=S):S=e[13];const k=S;let C;e[14]!==o||e[15]!==y||e[16]!==j?(C=ae=>{y.some(me=>me.volume===ae.volume&&me.path===ae.path)||(j([...y,{id:crypto.randomUUID(),name:xi(ae.path),volume:ae.volume,path:ae.path,url:o(ae.volume,ae.path),contentType:null,size:ae.size??null,addedAt:new Date().toISOString()}]),c(!1))},e[14]=o,e[15]=y,e[16]=j,e[17]=C):C=e[17];const A=C;let P;e[18]!==o||e[19]!==y||e[20]!==j?(P=ae=>{y.some(me=>me.volume===ae.volume&&me.path===ae.path)||(j([...y,{id:crypto.randomUUID(),name:xi(ae.path),kind:"skill",volume:ae.volume,path:ae.path,url:o(ae.volume,ae.path),contentType:null,size:null,addedAt:new Date().toISOString()}]),c(!1))},e[18]=o,e[19]=y,e[20]=j,e[21]=P):P=e[21];const V=P;let T;e[22]!==y||e[23]!==j?(T=ae=>{j(y.filter(me=>me.id!==ae))},e[22]=y,e[23]=j,e[24]=T):T=e[24];const R=T;let E;e[25]===Symbol.for("react.memo_cache_sentinel")?(E=ae=>{c(ae),ae&&h("")},e[25]=E):E=e[25];const I=E;let D;e[26]!==y?(D=new Set(y.map(xj)),e[26]=y,e[27]=D):D=e[27];const M=D,O=d.toLowerCase();let $;e[28]!==M?($=ae=>!M.has(`${ae.volume}/${ae.path}`),e[28]=M,e[29]=$):$=e[29];const B=g.filter(gj).filter($).filter(ae=>xi(ae.path).toLowerCase().includes(O)).slice(0,5);let z;e[30]!==M?(z=ae=>!M.has(`${ae.volume}/${ae.path}`),e[30]=M,e[31]=z):z=e[31];const K=b.filter(z).filter(ae=>xi(ae.path).toLowerCase().includes(O)).slice(0,5),Y=ae=>r.jsxs(vs,{open:l,onOpenChange:I,children:[r.jsx(bs,{asChild:!0,children:ae}),r.jsxs(ys,{align:"end",className:"w-56",children:[r.jsxs(Je,{onSelect:()=>{a.current?.click()},children:[r.jsx(T6,{size:16}),n("virtualMcp.filesSection.uploadFile")]}),r.jsxs(Oo,{children:[r.jsxs($o,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[r.jsx(ri,{size:16}),n("virtualMcp.filesSection.selectFileOrFolder")]}),r.jsxs(Bo,{className:"w-72 p-0",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[r.jsx(Ko,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("input",{value:d,onChange:me=>h(me.target.value),onKeyDown:pj,placeholder:n("virtualMcp.filesSection.searchFilesPlaceholder"),className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),r.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:B.length===0?r.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:n("virtualMcp.filesSection.noFilesFound")}):B.map(me=>r.jsxs(Je,{onSelect:()=>A(me),children:[r.jsx(yr,{filename:xi(me.path),className:"h-5 w-4 shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:xi(me.path)}),me.size!=null&&r.jsx("span",{className:"text-xs text-muted-foreground",children:qh(me.size)})]},`${me.volume}/${me.path}`))})]})]}),r.jsxs(Oo,{children:[r.jsxs($o,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[r.jsx(ei,{size:16}),n("virtualMcp.filesSection.selectSkill")]}),r.jsxs(Bo,{className:"w-72 p-0",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[r.jsx(Ko,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("input",{value:d,onChange:me=>h(me.target.value),onKeyDown:mj,placeholder:n("virtualMcp.filesSection.searchSkillsPlaceholder"),className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),r.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:K.length===0?r.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:n("virtualMcp.filesSection.noSkillsFound")}):K.map(me=>r.jsxs(Je,{onSelect:()=>V(me),children:[r.jsx(ei,{size:16,className:"shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:xi(me.path)})]},`${me.volume}/${me.path}`))})]})]})]})]}),Q="flex flex-col gap-3";let q;e[32]!==n?(q=n("virtualMcp.filesSection.filesAndSkills"),e[32]=n,e[33]=q):q=e[33];let H;e[34]!==q?(H=r.jsx("h2",{className:"text-sm font-medium text-foreground",children:q}),e[34]=q,e[35]=H):H=e[35];let U;e[36]!==n?(U=n("virtualMcp.filesSection.description"),e[36]=n,e[37]=U):U=e[37];let X;e[38]!==U?(X=r.jsx("p",{className:"text-sm text-muted-foreground",children:U}),e[38]=U,e[39]=X):X=e[39];let J;e[40]!==H||e[41]!==X?(J=r.jsxs("div",{className:"flex flex-col gap-1",children:[H,X]}),e[40]=H,e[41]=X,e[42]=J):J=e[42];const ee=y.length>0&&Y(r.jsxs(le,{variant:"outline",size:"sm",disabled:i.isPending,children:[i.isPending?r.jsx(Ni,{size:"xs"}):r.jsx(_t,{size:14}),n("virtualMcp.filesSection.add")]}));let W;e[43]!==J||e[44]!==ee?(W=r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[J,ee]}),e[43]=J,e[44]=ee,e[45]=W):W=e[45];let Z;e[46]!==k?(Z=r.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:ae=>{k(ae.target.files),ae.target.value=""}}),e[46]=k,e[47]=Z):Z=e[47];let G,te;e[48]===Symbol.for("react.memo_cache_sentinel")?(G=ae=>{ae.preventDefault(),f(!0)},te=()=>f(!1),e[48]=G,e[49]=te):(G=e[48],te=e[49]);let se;e[50]!==k?(se=ae=>{ae.preventDefault(),f(!1),k(ae.dataTransfer.files)},e[50]=k,e[51]=se):se=e[51];const re=u&&"outline outline-2 outline-dashed outline-primary";let de;e[52]!==re?(de=ie("flex flex-col gap-2 rounded-lg",re),e[52]=re,e[53]=de):de=e[53];const ce=y.length===0?Y(r.jsxs("button",{type:"button",className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[r.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:r.jsx(_t,{size:16})}),r.jsx("span",{className:"text-sm text-muted-foreground flex-1",children:n("virtualMcp.filesSection.noFilesOrSkillsYet")})]})):y.map(ae=>r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-card",children:[ae.kind==="skill"?r.jsx("div",{className:"flex items-center justify-center h-8 w-6.5 shrink-0 rounded-md bg-muted text-muted-foreground",children:r.jsx(ei,{size:16})}):r.jsx(yr,{filename:ae.name,className:"h-8 w-6.5 shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:ae.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:ae.kind==="skill"?n("virtualMcp.filesSection.kindSkill"):ae.size!=null?qh(ae.size):n("virtualMcp.filesSection.kindFile")})]}),r.jsx(le,{variant:"ghost",size:"icon",onClick:()=>R(ae.id),"aria-label":n("virtualMcp.filesSection.removeAriaLabel",{name:ae.name}),children:r.jsx(_s,{size:16})})]},ae.id));let fe;e[54]!==G||e[55]!==te||e[56]!==se||e[57]!==de||e[58]!==ce?(fe=r.jsx("div",{onDragOver:G,onDragLeave:te,onDrop:se,className:de,children:ce}),e[54]=G,e[55]=te,e[56]=se,e[57]=de,e[58]=ce,e[59]=fe):fe=e[59];let ue;return e[60]!==W||e[61]!==Z||e[62]!==fe?(ue=r.jsxs("section",{className:Q,children:[W,Z,fe]}),e[60]=W,e[61]=Z,e[62]=fe,e[63]=ue):ue=e[63],ue}function mj(t){return t.stopPropagation()}function pj(t){return t.stopPropagation()}function gj(t){return t.kind!=="dir"}function xj(t){return`${t.volume}/${t.path}`}function vj(t){return t.size<=hj}function bj(t){return t==null?"all":t.length===0?"self":"selected"}function yj(t){const e=F.c(88),{form:s,currentAgentId:n}=t,i=oe(),{org:o}=ze(),a=la(),[l,c]=N.useState(!1);let d;e[0]!==s?(d=s.getValues("metadata.subAgents")??null,e[0]=s,e[1]=d):d=e[1];const h=d;let u;e[2]!==h?(u=()=>bj(h),e[2]=h,e[3]=u):u=e[3];const[f,m]=N.useState(u);let p;e[4]!==h?(p=h??[],e[4]=h,e[5]=p):p=e[5];const[g,x]=N.useState(p);let v,b,_,y,L,w;if(e[6]!==a||e[7]!==n||e[8]!==s||e[9]!==f||e[10]!==o||e[11]!==g||e[12]!==i){let C;e[19]!==n||e[20]!==o?(C=G=>G.id!==n&&G.id!==o.id&&G.status==="active",e[19]=n,e[20]=o,e[21]=C):C=e[21],v=a.filter(C);let A;e[22]!==g?(A=G=>g.includes(G.id),e[22]=g,e[23]=A):A=e[23];const P=v.filter(A);let V;e[24]!==s?(V=(G,te)=>s.setValue("metadata.subAgents",G==="all"?null:G==="self"?[]:te,{shouldDirty:!0}),e[24]=s,e[25]=V):V=e[25];const T=V;let R;e[26]!==T||e[27]!==g?(R=G=>{m(G),T(G,g)},e[26]=T,e[27]=g,e[28]=R):R=e[28];const E=R;let I;e[29]!==T||e[30]!==g?(I=G=>{const te=g.includes(G)?g.filter(se=>se!==G):[...g,G];x(te),T("selected",te)},e[29]=T,e[30]=g,e[31]=I):I=e[31],b=I,L="flex flex-col gap-3";let D;e[32]!==i?(D=i("virtualMcp.subAgentsSection.title"),e[32]=i,e[33]=D):D=e[33];let M;e[34]!==D?(M=r.jsx("h2",{className:"text-sm font-medium text-foreground",children:D}),e[34]=D,e[35]=M):M=e[35];let O;e[36]!==f||e[37]!==i?(O=f==="all"&&r.jsx("p",{className:"text-sm text-muted-foreground",children:i("virtualMcp.subAgentsSection.canDelegateToAnyAgent")}),e[36]=f,e[37]=i,e[38]=O):O=e[38];let $;e[39]!==f||e[40]!==i?($=f==="self"&&r.jsx("p",{className:"text-sm text-muted-foreground",children:i("virtualMcp.subAgentsSection.canOnlyDelegateToItself")}),e[39]=f,e[40]=i,e[41]=$):$=e[41];let B;e[42]!==M||e[43]!==O||e[44]!==$?(B=r.jsxs("div",{className:"flex flex-col gap-1",children:[M,O,$]}),e[42]=M,e[43]=O,e[44]=$,e[45]=B):B=e[45];const z=f==="selected"&&P.length>0&&r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>c(!0),children:[r.jsx(_t,{size:14}),i("virtualMcp.subAgentsSection.addSubAgent")]});let K;e[46]!==E?(K=G=>E(G),e[46]=E,e[47]=K):K=e[47];let Y;e[48]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx($t,{size:"sm",className:"w-auto",children:r.jsx(qt,{})}),e[48]=Y):Y=e[48];let Q;e[49]!==i?(Q=i("virtualMcp.subAgentsSection.anyAgent"),e[49]=i,e[50]=Q):Q=e[50];let q;e[51]!==Q?(q=r.jsx(ut,{value:"all",children:Q}),e[51]=Q,e[52]=q):q=e[52];let H;e[53]!==i?(H=i("virtualMcp.subAgentsSection.specificAgents"),e[53]=i,e[54]=H):H=e[54];let U;e[55]!==H?(U=r.jsx(ut,{value:"selected",children:H}),e[55]=H,e[56]=U):U=e[56];let X;e[57]!==i?(X=i("virtualMcp.subAgentsSection.onlyItself"),e[57]=i,e[58]=X):X=e[58];let J;e[59]!==X?(J=r.jsx(ut,{value:"self",children:X}),e[59]=X,e[60]=J):J=e[60];let ee;e[61]!==q||e[62]!==U||e[63]!==J?(ee=r.jsxs(Bt,{align:"end",children:[q,U,J]}),e[61]=q,e[62]=U,e[63]=J,e[64]=ee):ee=e[64];let W;e[65]!==f||e[66]!==K||e[67]!==ee?(W=r.jsxs(Ft,{value:f,onValueChange:K,children:[Y,ee]}),e[65]=f,e[66]=K,e[67]=ee,e[68]=W):W=e[68];let Z;e[69]!==z||e[70]!==W?(Z=r.jsxs("div",{className:"flex items-center gap-2",children:[z,W]}),e[69]=z,e[70]=W,e[71]=Z):Z=e[71],e[72]!==B||e[73]!==Z?(w=r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[B,Z]}),e[72]=B,e[73]=Z,e[74]=w):w=e[74],_="flex flex-col gap-2",y=f==="selected"&&(P.length>0?P.map(G=>r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-background",children:[r.jsx(ln,{icon:G.icon,name:G.title,size:"sm",className:"shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:G.title}),G.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:G.description})]}),r.jsx(le,{variant:"ghost",size:"icon",onClick:()=>b(G.id),children:r.jsx(In,{size:16})})]},G.id)):r.jsxs("button",{type:"button",onClick:()=>c(!0),className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[r.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:r.jsx(_t,{size:16})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i("virtualMcp.subAgentsSection.emptyStateMessage")})]})),e[6]=a,e[7]=n,e[8]=s,e[9]=f,e[10]=o,e[11]=g,e[12]=i,e[13]=v,e[14]=b,e[15]=_,e[16]=y,e[17]=L,e[18]=w}else v=e[13],b=e[14],_=e[15],y=e[16],L=e[17],w=e[18];let j;e[75]!==_||e[76]!==y?(j=r.jsx("div",{className:_,children:y}),e[75]=_,e[76]=y,e[77]=j):j=e[77];let S;e[78]!==v||e[79]!==b||e[80]!==l||e[81]!==g?(S=r.jsx(_j,{open:l,onOpenChange:c,candidates:v,selectedIds:g,onToggle:b}),e[78]=v,e[79]=b,e[80]=l,e[81]=g,e[82]=S):S=e[82];let k;return e[83]!==L||e[84]!==w||e[85]!==j||e[86]!==S?(k=r.jsxs("section",{className:L,children:[w,j,S]}),e[83]=L,e[84]=w,e[85]=j,e[86]=S,e[87]=k):k=e[87],k}function _j(t){const e=F.c(39),{open:s,onOpenChange:n,candidates:i,selectedIds:o,onToggle:a}=t,l=oe(),[c,d]=N.useState("");let h,u,f,m,p,g,x,v,b;if(e[0]!==i||e[1]!==n||e[2]!==a||e[3]!==s||e[4]!==c||e[5]!==o||e[6]!==l){const w=c.toLowerCase(),j=i.filter(C=>C.title.toLowerCase().includes(w)||C.description?.toLowerCase().includes(w));u=Jt,v=s,b=n,h=Yt,p="max-w-md";let S;e[16]!==l?(S=l("virtualMcp.subAgentsSection.title"),e[16]=l,e[17]=S):S=e[17],e[18]!==S?(g=r.jsx(cs,{children:r.jsx(ds,{children:S})}),e[18]=S,e[19]=g):g=e[19];let k;e[20]!==l?(k=l("virtualMcp.subAgentsSection.searchPlaceholder"),e[20]=l,e[21]=k):k=e[21],e[22]!==c||e[23]!==k?(x=r.jsx(L9,{value:c,onChange:d,placeholder:k,className:"w-full"}),e[22]=c,e[23]=k,e[24]=x):x=e[24],f="flex flex-col gap-1 max-h-80 overflow-y-auto",m=j.length===0?r.jsx("p",{className:"text-sm text-muted-foreground px-1 py-4 text-center",children:l("virtualMcp.subAgentsSection.noAgentsFound")}):j.map(C=>r.jsxs("button",{type:"button",onClick:()=>a(C.id),className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-accent/50 transition-colors cursor-pointer w-full text-left",children:[r.jsx(Pr,{checked:o.includes(C.id),className:"pointer-events-none",tabIndex:-1}),r.jsx(ln,{icon:C.icon,name:C.title,size:"sm",className:"shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:C.title}),C.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:C.description})]})]},C.id)),e[0]=i,e[1]=n,e[2]=a,e[3]=s,e[4]=c,e[5]=o,e[6]=l,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v,e[15]=b}else h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14],b=e[15];let _;e[25]!==f||e[26]!==m?(_=r.jsx("div",{className:f,children:m}),e[25]=f,e[26]=m,e[27]=_):_=e[27];let y;e[28]!==h||e[29]!==p||e[30]!==g||e[31]!==x||e[32]!==_?(y=r.jsxs(h,{className:p,children:[g,x,_]}),e[28]=h,e[29]=p,e[30]=g,e[31]=x,e[32]=_,e[33]=y):y=e[33];let L;return e[34]!==u||e[35]!==v||e[36]!==b||e[37]!==y?(L=r.jsx(u,{open:v,onOpenChange:b,children:y}),e[34]=u,e[35]=v,e[36]=b,e[37]=y,e[38]=L):L=e[38],L}function go(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(Ze,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Na(t,e){return({error:s})=>s?.message?.includes("Method not found")||s?.code===-32601?r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[r.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:r.jsx(kr,{className:"h-6 w-6 text-destructive"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-medium",children:e("virtualMcp.dependencySelectionDialog.somethingWentWrong")}),r.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:s?.message?s.message.length>200?`${s.message.slice(0,200)}...`:s.message:e("virtualMcp.dependencySelectionDialog.unexpectedError")})]})]})}function L3(t){const e=F.c(23),{item:s,isSelected:n,onToggle:i,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=n?"bg-accent/25":"hover:bg-muted/50";let c;e[0]!==a||e[1]!==l?(c=ie("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==s.name?(d=r.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=d):d=e[4];let h;e[5]!==s.tags?(h=s.tags&&r.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=h):h=e[6];let u;e[7]!==d||e[8]!==h?(u=r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d,h]}),e[7]=d,e[8]=h,e[9]=u):u=e[9];let f;e[10]!==s.description?(f=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let m;e[12]!==u||e[13]!==f?(m=r.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14];let p;e[15]!==o||e[16]!==n||e[17]!==i?(p=r.jsx(Pr,{checked:n,onCheckedChange:i,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=n,e[17]=i,e[18]=p):p=e[18];let g;return e[19]!==c||e[20]!==m||e[21]!==p?(g=r.jsxs("label",{className:c,children:[m,p]}),e[19]=c,e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function Lj(t){const e=F.c(35),{activeTab:s,onTabChange:n,showSelectAll:i,isAllSelected:o,handleSelectAll:a}=t,l=oe();let c;e[0]!==l?(c=l("virtualMcp.dependencySelectionDialog.tabTools"),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==c?(d={id:"tools",label:c},e[2]=c,e[3]=d):d=e[3];let h;e[4]!==l?(h=l("virtualMcp.dependencySelectionDialog.tabActive"),e[4]=l,e[5]=h):h=e[5];let u;e[6]!==h?(u={id:"active",label:h},e[6]=h,e[7]=u):u=e[7];let f;e[8]!==l?(f=l("virtualMcp.dependencySelectionDialog.tabResources"),e[8]=l,e[9]=f):f=e[9];let m;e[10]!==f?(m={id:"resources",label:f},e[10]=f,e[11]=m):m=e[11];let p;e[12]!==l?(p=l("virtualMcp.dependencySelectionDialog.tabPrompts"),e[12]=l,e[13]=p):p=e[13];let g;e[14]!==p?(g={id:"prompts",label:p},e[14]=p,e[15]=g):g=e[15];let x;e[16]!==d||e[17]!==u||e[18]!==m||e[19]!==g?(x=[d,u,m,g],e[16]=d,e[17]=u,e[18]=m,e[19]=g,e[20]=x):x=e[20];let v;e[21]!==n?(v=L=>n(L),e[21]=n,e[22]=v):v=e[22];let b;e[23]!==s||e[24]!==v||e[25]!==x?(b=r.jsx(U2,{tabs:x,activeTab:s,onTabChange:v}),e[23]=s,e[24]=v,e[25]=x,e[26]=b):b=e[26];let _;e[27]!==a||e[28]!==o||e[29]!==i||e[30]!==l?(_=i&&r.jsx("button",{type:"button",onClick:a,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:l(o?"virtualMcp.dependencySelectionDialog.deselectAll":"virtualMcp.dependencySelectionDialog.selectAll")}),e[27]=a,e[28]=o,e[29]=i,e[30]=l,e[31]=_):_=e[31];let y;return e[32]!==b||e[33]!==_?(y=r.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[b,_]}),e[32]=b,e[33]=_,e[34]=y):y=e[34],y}function X9(t){const e=F.c(13),{items:s,selections:n,onToggle:i,emptyMessage:o,disabled:a}=t;let l,c,d;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==i||e[4]!==n){d=Symbol.for("react.early_return_sentinel");e:{const u=s.map(Sj);if(s.length===0){let f;e[8]!==o?(f=r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],d=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",c=s.map(f=>r.jsx(L3,{item:f,isSelected:n===null||n?.includes(f.id),onToggle:()=>i(f.id,u),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=i,e[4]=n,e[5]=l,e[6]=c,e[7]=d}else l=e[5],c=e[6],d=e[7];if(d!==Symbol.for("react.early_return_sentinel"))return d;let h;return e[10]!==l||e[11]!==c?(h=r.jsx("div",{className:l,children:c}),e[10]=l,e[11]=c,e[12]=h):h=e[12],h}function Sj(t){return t.id}function wj(t){const e=F.c(22),{connectionId:s,toolSelections:n,onToggleTool:i}=t,o=oe(),{org:a}=ze();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=pt(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=O2(d),u=h.tools;let f,m,p;if(e[6]!==h.tools||e[7]!==i||e[8]!==o||e[9]!==n){p=Symbol.for("react.early_return_sentinel");e:{const x=u.map(Cj);let v;e[13]!==n?(v=y=>n===null||n.includes(y.name),e[13]=n,e[14]=v):v=e[14];const _=h.tools.filter(v).map(jj);if(_.length===0){let y;e[15]!==o?(y=o("virtualMcp.dependencySelectionDialog.noActiveToolsSelected"),e[15]=o,e[16]=y):y=e[16];let L;e[17]!==y?(L=r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:y})}),e[17]=y,e[18]=L):L=e[18],p=L;break e}f="flex-1 overflow-auto px-4 py-3 space-y-1",m=_.map(y=>r.jsx(L3,{item:y,isSelected:!0,onToggle:()=>i(y.id,x)},y.id))}e[6]=h.tools,e[7]=i,e[8]=o,e[9]=n,e[10]=f,e[11]=m,e[12]=p}else f=e[10],m=e[11],p=e[12];if(p!==Symbol.for("react.early_return_sentinel"))return p;let g;return e[19]!==f||e[20]!==m?(g=r.jsx("div",{className:f,children:m}),e[19]=f,e[20]=m,e[21]=g):g=e[21],g}function jj(t){return{id:t.name,name:t.name,description:t.description,tags:r.jsx(F2,{annotations:t.annotations,_meta:t._meta})}}function Cj(t){return t.name}function kj(t){const e=F.c(16),{connectionId:s,selections:n,onToggle:i,disabled:o}=t,{org:a}=ze();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=pt(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=O2(d);let u;e[6]!==h.tools?(u=h.tools.map(Vj),e[6]=h.tools,e[7]=u):u=e[7];const f=u,m=oe();let p;e[8]!==m?(p=m("virtualMcp.dependencySelectionDialog.noToolsAvailable"),e[8]=m,e[9]=p):p=e[9];let g;return e[10]!==o||e[11]!==f||e[12]!==i||e[13]!==n||e[14]!==p?(g=r.jsx(X9,{items:f,selections:n,onToggle:i,emptyMessage:p,disabled:o}),e[10]=o,e[11]=f,e[12]=i,e[13]=n,e[14]=p,e[15]=g):g=e[15],g}function Vj(t){return{id:t.name,name:t.name,description:t.description,tags:r.jsx(F2,{annotations:t.annotations,_meta:t._meta})}}function Nj(t){const e=F.c(16),{connectionId:s,selections:n,onToggle:i,disabled:o}=t,{org:a}=ze();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=pt(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=Ux(d);let u;e[6]!==h.resources?(u=h.resources.map(Tj),e[6]=h.resources,e[7]=u):u=e[7];const f=u,m=oe();let p;e[8]!==m?(p=m("virtualMcp.dependencySelectionDialog.noResourcesAvailable"),e[8]=m,e[9]=p):p=e[9];let g;return e[10]!==o||e[11]!==f||e[12]!==i||e[13]!==n||e[14]!==p?(g=r.jsx(X9,{items:f,selections:n,onToggle:i,emptyMessage:p,disabled:o}),e[10]=o,e[11]=f,e[12]=i,e[13]=n,e[14]=p,e[15]=g):g=e[15],g}function Tj(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Aj(t){const e=F.c(16),{connectionId:s,selections:n,onToggle:i,disabled:o}=t,{org:a}=ze();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=pt(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=Jm(d);let u;e[6]!==h.prompts?(u=h.prompts.map(Ej),e[6]=h.prompts,e[7]=u):u=e[7];const f=u,m=oe();let p;e[8]!==m?(p=m("virtualMcp.dependencySelectionDialog.noPromptsAvailable"),e[8]=m,e[9]=p):p=e[9];let g;return e[10]!==o||e[11]!==f||e[12]!==i||e[13]!==n||e[14]!==p?(g=r.jsx(X9,{items:f,selections:n,onToggle:i,emptyMessage:p,disabled:o}),e[10]=o,e[11]=f,e[12]=i,e[13]=n,e[14]=p,e[15]=g):g=e[15],g}function Ej(t){return{id:t.name,name:t.name,description:t.description}}function Pj(t){const e=F.c(58),{currentConnection:s,activeTab:n,selectedId:i,formData:o,toggleTool:a,toggleResource:l,togglePrompt:c,toggleAllTools:d,toggleAllResources:h,toggleAllPrompts:u,onTabChange:f}=t,m=oe(),p=o[i],g=n==="tools"?p?.tools===null:n==="resources"?p?.resources===null:n==="prompts"?p?.prompts===null:!1,x=n!=="active";let v;e[0]!==n||e[1]!==i||e[2]!==u||e[3]!==h||e[4]!==d?(v=()=>{n==="tools"?d(i):n==="resources"?h(i):n==="prompts"&&u(i)},e[0]=n,e[1]=i,e[2]=u,e[3]=h,e[4]=d,e[5]=v):v=e[5];const b=v;let _;e[6]!==s.icon||e[7]!==s.title?(_=r.jsx(ln,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=_):_=e[8];let y;e[9]!==s.title?(y=r.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=y):y=e[10];let L;e[11]!==s.description?(L=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=L):L=e[12];let w;e[13]!==y||e[14]!==L?(w=r.jsxs("div",{className:"flex-1 min-w-0",children:[y,L]}),e[13]=y,e[14]=L,e[15]=w):w=e[15];let j;e[16]!==_||e[17]!==w?(j=r.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-3",children:[_,w]})}),e[16]=_,e[17]=w,e[18]=j):j=e[18];let S;e[19]!==n||e[20]!==b||e[21]!==g||e[22]!==f||e[23]!==x?(S=r.jsx(Lj,{activeTab:n,onTabChange:f,showSelectAll:x,isAllSelected:g,handleSelectAll:b}),e[19]=n,e[20]=b,e[21]=g,e[22]=f,e[23]=x,e[24]=S):S=e[24];let k;e[25]!==n||e[26]!==o||e[27]!==i||e[28]!==m||e[29]!==a?(k=n==="active"&&r.jsx(hs,{fallback:Na(m("virtualMcp.dependencySelectionDialog.toolsNotSupported"),m),children:r.jsx(N.Suspense,{fallback:r.jsx(go,{}),children:r.jsx(wj,{connectionId:i,toolSelections:o[i]?o[i].tools:[],onToggleTool:(R,E)=>a(i,R,E)})})}),e[25]=n,e[26]=o,e[27]=i,e[28]=m,e[29]=a,e[30]=k):k=e[30];let C;e[31]!==n||e[32]!==o||e[33]!==i||e[34]!==m||e[35]!==a?(C=n==="tools"&&r.jsx(hs,{fallback:Na(m("virtualMcp.dependencySelectionDialog.toolsNotSupported"),m),children:r.jsx(N.Suspense,{fallback:r.jsx(go,{}),children:r.jsx(kj,{connectionId:i,selections:o[i]?o[i].tools:[],onToggle:(R,E)=>a(i,R,E)})})}),e[31]=n,e[32]=o,e[33]=i,e[34]=m,e[35]=a,e[36]=C):C=e[36];let A;e[37]!==n||e[38]!==o||e[39]!==i||e[40]!==m||e[41]!==l?(A=n==="resources"&&r.jsx(hs,{fallback:Na(m("virtualMcp.dependencySelectionDialog.resourcesNotSupported"),m),children:r.jsx(N.Suspense,{fallback:r.jsx(go,{}),children:r.jsx(Nj,{connectionId:i,selections:o[i]?o[i].resources:[],onToggle:(R,E)=>l(i,R,E)})})}),e[37]=n,e[38]=o,e[39]=i,e[40]=m,e[41]=l,e[42]=A):A=e[42];let P;e[43]!==n||e[44]!==o||e[45]!==i||e[46]!==m||e[47]!==c?(P=n==="prompts"&&r.jsx(hs,{fallback:Na(m("virtualMcp.dependencySelectionDialog.promptsNotSupported"),m),children:r.jsx(N.Suspense,{fallback:r.jsx(go,{}),children:r.jsx(Aj,{connectionId:i,selections:o[i]?o[i].prompts:[],onToggle:(R,E)=>c(i,R,E)})})}),e[43]=n,e[44]=o,e[45]=i,e[46]=m,e[47]=c,e[48]=P):P=e[48];let V;e[49]!==A||e[50]!==P||e[51]!==k||e[52]!==C?(V=r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[k,C,A,P]}),e[49]=A,e[50]=P,e[51]=k,e[52]=C,e[53]=V):V=e[53];let T;return e[54]!==V||e[55]!==j||e[56]!==S?(T=r.jsxs(r.Fragment,{children:[j,S,V]}),e[54]=V,e[55]=j,e[56]=S,e[57]=T):T=e[57],T}function Rj(t){const e=F.c(7),{onClose:s}=t,n=oe();let i;e[0]!==s?(i=()=>s(!1),e[0]=s,e[1]=i):i=e[1];let o;e[2]!==n?(o=n("virtualMcp.dependencySelectionDialog.done"),e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==i||e[5]!==o?(a=r.jsx(mi,{className:"px-6 py-4 border-t border-border shrink-0",children:r.jsx(le,{variant:"outline",onClick:i,children:o})}),e[4]=i,e[5]=o,e[6]=a):a=e[6],a}function Dj(t){const e=F.c(23),{connectionId:s,onAuthenticate:n,children:i}=t,o=oe();let a;e[0]!==s?(a={connectionId:s},e[0]=s,e[1]=a):a=e[1];const l=z2(a);if(l.supportsOAuth&&!l.isAuthenticated){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:r.jsx(A6,{size:22,className:"text-muted-foreground"})}),e[2]=h):h=e[2];let u;e[3]!==o?(u=o("virtualMcp.dependencySelectionDialog.authorizationRequired"),e[3]=o,e[4]=u):u=e[4];let f;e[5]!==u?(f=r.jsx("p",{className:"text-sm font-medium",children:u}),e[5]=u,e[6]=f):f=e[6];let m;e[7]!==o?(m=o("virtualMcp.dependencySelectionDialog.authorizationDescription"),e[7]=o,e[8]=m):m=e[8];let p;e[9]!==m?(p=r.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:m}),e[9]=m,e[10]=p):p=e[10];let g;e[11]!==f||e[12]!==p?(g=r.jsxs("div",{className:"space-y-1",children:[f,p]}),e[11]=f,e[12]=p,e[13]=g):g=e[13];let x;e[14]!==s||e[15]!==n||e[16]!==o?(x=n&&r.jsx(le,{variant:"outline",size:"sm",onClick:()=>n(s),children:o("virtualMcp.dependencySelectionDialog.authorize")}),e[14]=s,e[15]=n,e[16]=o,e[17]=x):x=e[17];let v;return e[18]!==g||e[19]!==x?(v=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[h,g,x]}),e[18]=g,e[19]=x,e[20]=v):v=e[20],v}let d;return e[21]!==i?(d=r.jsx(r.Fragment,{children:i}),e[21]=i,e[22]=d):d=e[22],d}function Ij(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function Gh(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Yh(t,e,s,n){const i=t[e]??{tools:null,resources:null,prompts:null};return{...t,[e]:{...i,[s]:n}}}function Mj(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Oj(t){const e=F.c(49),{open:s,onOpenChange:n,selectedId:i,form:o,connections:a,onAuthenticate:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activeTab:"tools"},e[0]=c):c=e[0];const[d,h]=N.useReducer(Mj,c),u=b9(i??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=Ij(f),e[3]=f,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==p?(g=(B,z,K,Y)=>{const Q=p[B]?.[z];let q;Q===null?q=Y.filter(H=>H!==K):Q?.includes(K)?q=Q.filter(H=>H!==K):(q=[...Q??[],K],q.length===Y.length&&(q=null)),o.setValue("connections",Gh(Yh(p,B,z,q)),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=g):g=e[7];const x=g;let v;e[8]!==o||e[9]!==p?(v=(B,z)=>{const Y=p[B]?.[z]===null?[]:null;o.setValue("connections",Gh(Yh(p,B,z,Y)),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=v):v=e[10];const b=v;let _;e[11]!==x?(_=(B,z,K)=>x(B,"tools",z,K),e[11]=x,e[12]=_):_=e[12];const y=_;let L;e[13]!==x?(L=(B,z,K)=>x(B,"resources",z,K),e[13]=x,e[14]=L):L=e[14];const w=L;let j;e[15]!==x?(j=(B,z,K)=>x(B,"prompts",z,K),e[15]=x,e[16]=j):j=e[16];const S=j;let k;e[17]!==b?(k=B=>b(B,"tools"),e[17]=b,e[18]=k):k=e[18];const C=k;let A;e[19]!==b?(A=B=>b(B,"resources"),e[19]=b,e[20]=A):A=e[20];const P=A;let V;e[21]!==b?(V=B=>b(B,"prompts"),e[21]=b,e[22]=V):V=e[22];const T=V;if(!i||!u)return null;let R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(go,{}),e[23]=R):R=e[23];let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=B=>h({type:"SET_ACTIVE_TAB",payload:B}),e[24]=E):E=e[24];let I;e[25]!==u||e[26]!==d.activeTab||e[27]!==p||e[28]!==i||e[29]!==T||e[30]!==P||e[31]!==C||e[32]!==S||e[33]!==w||e[34]!==y?(I=r.jsx(Pj,{currentConnection:u,activeTab:d.activeTab,selectedId:i,formData:p,toggleTool:y,toggleResource:w,togglePrompt:S,toggleAllTools:C,toggleAllResources:P,toggleAllPrompts:T,onTabChange:E},i),e[25]=u,e[26]=d.activeTab,e[27]=p,e[28]=i,e[29]=T,e[30]=P,e[31]=C,e[32]=S,e[33]=w,e[34]=y,e[35]=I):I=e[35];let D;e[36]!==l||e[37]!==i||e[38]!==I?(D=r.jsx(N.Suspense,{fallback:R,children:r.jsx(Dj,{connectionId:i,onAuthenticate:l,children:I})}),e[36]=l,e[37]=i,e[38]=I,e[39]=D):D=e[39];let M;e[40]!==n?(M=r.jsx(Rj,{onClose:n}),e[40]=n,e[41]=M):M=e[41];let O;e[42]!==D||e[43]!==M?(O=r.jsxs(Yt,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[D,M]}),e[42]=D,e[43]=M,e[44]=O):O=e[44];let $;return e[45]!==n||e[46]!==s||e[47]!==O?($=r.jsx(Jt,{open:s,onOpenChange:n,children:O}),e[45]=n,e[46]=s,e[47]=O,e[48]=$):$=e[48],$}const Jh="__new_instance__";function $j(t){const e=F.c(23),{connection_id:s,usedConnectionIds:n,onOpenSettings:i,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}=t,d=b9(s),{org:h}=ze();if(!d)return null;let u;e[0]!==d?(u=y8(d),e[0]=d,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=r.jsx(zj,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==d.app_name||e[5]!==d.connection_type||e[6]!==d.description||e[7]!==d.icon||e[8]!==d.status||e[9]!==d.title||e[10]!==s||e[11]!==a||e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==h.slug||e[17]!==f||e[18]!==n?(p=r.jsx(Fj,{connection_id:s,connectionTitle:d.title,connectionDescription:d.description,connectionIcon:d.icon,connectionType:d.connection_type,connectionStatus:d.status,slug:f,orgSlug:h.slug,appName:d.app_name,usedConnectionIds:n,onOpenSettings:i,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}),e[4]=d.app_name,e[5]=d.connection_type,e[6]=d.description,e[7]=d.icon,e[8]=d.status,e[9]=d.title,e[10]=s,e[11]=a,e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=h.slug,e[17]=f,e[18]=n,e[19]=p):p=e[19];let g;return e[20]!==m||e[21]!==p?(g=r.jsx(N.Suspense,{fallback:m,children:p}),e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function Bj(t){const e=F.c(24),{appName:s,connectionId:n,usedConnectionIds:i,onSwitchInstance:o,onNewInstance:a}=t,l=oe();let c;e[0]!==s?(c={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=c):c=e[1];const d=Mn(c);if(d.length<=1)return null;let h;e[2]!==n||e[3]!==a||e[4]!==o?(h=x=>{x===Jh?a?.():o(n,x)},e[2]=n,e[3]=a,e[4]=o,e[5]=h):h=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx($t,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:r.jsx(qt,{})}),e[6]=u):u=e[6];let f;if(e[7]!==n||e[8]!==d||e[9]!==i){let x;e[11]!==n||e[12]!==i?(x=v=>r.jsx(ut,{value:v.id,className:"text-xs",disabled:v.id!==n&&i.has(v.id),children:v.title},v.id),e[11]=n,e[12]=i,e[13]=x):x=e[13],f=d.map(x),e[7]=n,e[8]=d,e[9]=i,e[10]=f}else f=e[10];let m;e[14]!==a||e[15]!==l?(m=a&&r.jsxs(ut,{value:Jh,className:"text-xs text-muted-foreground",children:["+ ",l("virtualMcp.connectionItem.newInstance")]}),e[14]=a,e[15]=l,e[16]=m):m=e[16];let p;e[17]!==f||e[18]!==m?(p=r.jsxs(Bt,{children:[f,m]}),e[17]=f,e[18]=m,e[19]=p):p=e[19];let g;return e[20]!==n||e[21]!==h||e[22]!==p?(g=r.jsxs(Ft,{value:n,onValueChange:h,children:[u,p]}),e[20]=n,e[21]=h,e[22]=p,e[23]=g):g=e[23],g}function Fj({connection_id:t,connectionTitle:e,connectionDescription:s,connectionIcon:n,connectionType:i,connectionStatus:o,slug:a,orgSlug:l,appName:c,usedConnectionIds:d,onOpenSettings:h,onRemove:u,onAuthenticate:f,onSwitchInstance:m,onNewInstance:p}){const g=z2({connectionId:t}),x=M2(),b=!(i==="VIRTUAL")&&g.supportsOAuth&&!g.isAuthenticated,_=o!=="active",y=oe(),L=async w=>{try{await x.update.mutateAsync({id:t,data:{status:w}}),ve.success(y(w==="active"?"virtualMcp.connectionItem.connectionEnabled":"virtualMcp.connectionItem.connectionDisabled"))}catch{ve.error(y("virtualMcp.connectionItem.failedToUpdateConnection"))}};return r.jsxs("div",{className:ie("rounded-xl border overflow-hidden transition-colors",b||_?"border-destructive/50 bg-destructive/5":"border-border bg-card"),children:[r.jsxs(Rm,{to:"/$org/settings/connections/$appSlug",params:{org:l,appSlug:a},className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[r.jsx(ln,{icon:n,name:e,size:"sm",className:"shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:e}),b?r.jsx("span",{className:"text-xs text-destructive font-medium",children:y("virtualMcp.connectionItem.needsAuthorization")}):_?r.jsx("span",{className:"text-xs text-destructive font-medium",children:y(o==="error"?"virtualMcp.connectionItem.disabledError":"virtualMcp.connectionItem.disabled")}):s&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s})]}),b?r.jsx(le,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:w=>{w.preventDefault(),w.stopPropagation(),f(t)},children:y("virtualMcp.connectionItem.authorize")}):_?r.jsxs(le,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 shrink-0",onClick:w=>{w.preventDefault(),w.stopPropagation(),L("active")},children:[r.jsx(E6,{size:13}),y("virtualMcp.connectionItem.enable")]}):r.jsxs(We,{delayDuration:0,children:[r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:r.jsx(ib,{size:16})})}),r.jsx(He,{side:"bottom",children:y("virtualMcp.connectionItem.connectionSettings")})]})]}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[c&&r.jsx(Bj,{appName:c,connectionId:t,usedConnectionIds:d,onSwitchInstance:m,onNewInstance:p}),r.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[r.jsxs(We,{delayDuration:0,children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,"aria-label":y("virtualMcp.connectionItem.configureResources"),children:r.jsx(a2,{size:13})})}),r.jsx(He,{side:"bottom",children:y("virtualMcp.connectionItem.configureResources")})]}),!_&&r.jsxs(We,{delayDuration:0,children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",onClick:()=>L("inactive"),"aria-label":y("virtualMcp.connectionItem.disableConnection"),children:r.jsx(P6,{size:13})})}),r.jsx(He,{side:"bottom",children:y("virtualMcp.connectionItem.disable")})]}),r.jsxs(We,{delayDuration:0,children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:u,"aria-label":y("virtualMcp.connectionItem.removeConnection"),children:r.jsx(In,{size:13})})}),r.jsx(He,{side:"bottom",children:y("virtualMcp.connectionItem.remove")})]})]})]})]})}function zj(t){const e=F.c(17),{connection_id:s}=t,n=b9(s);if(!n){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(S3,{}),e[0]=u):u=e[0],u}let i;e[1]!==n.icon||e[2]!==n.title?(i=r.jsx(ln,{icon:n.icon,name:n.title,size:"sm",className:"shrink-0"}),e[1]=n.icon,e[2]=n.title,e[3]=i):i=e[3];let o;e[4]!==n.title?(o=r.jsx("p",{className:"text-sm font-medium truncate",children:n.title}),e[4]=n.title,e[5]=o):o=e[5];let a;e[6]!==n.description?(a=n.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e[6]=n.description,e[7]=a):a=e[7];let l;e[8]!==o||e[9]!==a?(l=r.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==i||e[12]!==l?(c=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[i,l]}),e[11]=i,e[12]=l,e[13]=c):c=e[13];let d;e[14]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:r.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=d):d=e[14];let h;return e[15]!==c?(h=r.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[c,d]}),e[15]=c,e[16]=h):h=e[16],h}function S3(){const t=F.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),r.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let n;return t[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,r.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:r.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=n):n=t[2],n}function Kj(t){const e=F.c(5),{value:s}=t;let n;if(e[0]!==s){n=Symbol.for("react.early_return_sentinel");e:{const o=ec(s);if(o.type==="icon"){const a=zi(o.name);if(a){let l;e[2]!==a?(l=r.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],n=l;break e}}}e[0]=s,e[1]=n}else n=e[1];if(n!==Symbol.for("react.early_return_sentinel"))return n;let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(_8,{size:16,className:"text-muted-foreground"}),e[4]=i):i=e[4],i}function Uj(t){const e=F.c(71),{value:s,onChange:n,className:i,disabled:o}=t,a=oe(),[l,c]=N.useState(!1),[d,h]=N.useState("");let u;e[0]!==s?(u=ec(s),e[0]=s,e[1]=u):u=e[1];const f=u,m=f.type==="icon"?f.name:null;let p,g,x,v,b,_,y,L,w,j,S,k,C,A,P;if(e[2]!==i||e[3]!==m||e[4]!==o||e[5]!==n||e[6]!==l||e[7]!==d||e[8]!==a||e[9]!==s){const M=i9();v=h2(M,d),x=Es,b=o?!1:l,_=c;const O=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let $;e[25]!==i||e[26]!==O?($=ie("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,i),e[25]=i,e[26]=O,e[27]=$):$=e[27];let B;e[28]!==s?(B=r.jsx(Kj,{value:s}),e[28]=s,e[29]=B):B=e[29],e[30]!==o||e[31]!==$||e[32]!==B?(y=r.jsx(Ts,{asChild:!0,children:r.jsx("button",{type:"button",disabled:o,"aria-label":"Change icon",className:$,children:B})}),e[30]=o,e[31]=$,e[32]=B,e[33]=y):y=e[33],g=As,C="start",A="w-64 p-0",P=Hj,S="flex flex-col";let z;e[34]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(Ko,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[34]=z):z=e[34];let K;e[35]===Symbol.for("react.memo_cache_sentinel")?(K=q=>h(q.target.value),e[35]=K):K=e[35];let Y;e[36]!==a?(Y=a("common.simpleIconPicker.filterPlaceholder"),e[36]=a,e[37]=Y):Y=e[37],e[38]!==d||e[39]!==Y?(k=r.jsx("div",{className:"px-2 py-2",children:r.jsxs("div",{className:"relative",children:[z,r.jsx(et,{value:d,onChange:K,placeholder:Y,className:"h-7 text-xs pl-7"})]})}),e[38]=d,e[39]=Y,e[40]=k):k=e[40],p=fi,j="h-48",L="grid grid-cols-8 gap-0.5 px-2 pb-2";let Q;e[41]!==m||e[42]!==n?(Q=q=>{const H=zi(q);return H?r.jsx("button",{type:"button",onClick:()=>{n(`icon://${q}`),c(!1)},className:ie("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",m===q?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:Id(q),"aria-label":Id(q),children:r.jsx(H,{size:16})},q):null},e[41]=m,e[42]=n,e[43]=Q):Q=e[43],w=v.map(Q),e[2]=i,e[3]=m,e[4]=o,e[5]=n,e[6]=l,e[7]=d,e[8]=a,e[9]=s,e[10]=p,e[11]=g,e[12]=x,e[13]=v,e[14]=b,e[15]=_,e[16]=y,e[17]=L,e[18]=w,e[19]=j,e[20]=S,e[21]=k,e[22]=C,e[23]=A,e[24]=P}else p=e[10],g=e[11],x=e[12],v=e[13],b=e[14],_=e[15],y=e[16],L=e[17],w=e[18],j=e[19],S=e[20],k=e[21],C=e[22],A=e[23],P=e[24];let V;e[44]!==L||e[45]!==w?(V=r.jsx("div",{className:L,children:w}),e[44]=L,e[45]=w,e[46]=V):V=e[46];let T;e[47]!==v.length||e[48]!==a?(T=v.length===0&&r.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:a("common.simpleIconPicker.noIconsFound")}),e[47]=v.length,e[48]=a,e[49]=T):T=e[49];let R;e[50]!==p||e[51]!==V||e[52]!==T||e[53]!==j?(R=r.jsxs(p,{className:j,children:[V,T]}),e[50]=p,e[51]=V,e[52]=T,e[53]=j,e[54]=R):R=e[54];let E;e[55]!==R||e[56]!==S||e[57]!==k?(E=r.jsxs("div",{className:S,children:[k,R]}),e[55]=R,e[56]=S,e[57]=k,e[58]=E):E=e[58];let I;e[59]!==g||e[60]!==E||e[61]!==C||e[62]!==A||e[63]!==P?(I=r.jsx(g,{align:C,className:A,onOpenAutoFocus:P,children:E}),e[59]=g,e[60]=E,e[61]=C,e[62]=A,e[63]=P,e[64]=I):I=e[64];let D;return e[65]!==x||e[66]!==b||e[67]!==_||e[68]!==y||e[69]!==I?(D=r.jsxs(x,{open:b,onOpenChange:_,children:[y,I]}),e[65]=x,e[66]=b,e[67]=_,e[68]=y,e[69]=I,e[70]=D):D=e[70],D}function Hj(t){return t.preventDefault()}function Wj({virtualMcpId:t,form:e,flushAndSave:s}){const n=oe(),i=Fs(),o=ms(t),a=(o?.connections??[]).map(V=>V.connection_id).sort(),{data:l}=Pt({queryKey:Qe.projectConnectionDetails(t,a),enabled:a.length>0,queryFn:async()=>await Promise.all(a.map(async T=>{try{const{item:R}=await i.call("COLLECTION_CONNECTIONS_GET",{id:T}),E=(R?.tools??[]).flatMap(I=>{const D=oc(I._meta);return D?[{name:I.name,title:I.title,description:I.description,resourceUri:D}]:[]});return{fetchOk:!0,id:T,title:R?.title??T,icon:R?.icon??null,uiTools:E}}catch{return{fetchOk:!1,id:T,title:T,icon:null,uiTools:[]}}}))}),c=(l??[]).filter(V=>V.uiTools.length>0),d=new Set(Yb),h=e.watch("metadata.ui.pinnedViews")??[],u=e.watch("metadata.ui.layout")??null,f=u?.defaultMainView??null,m=u?.chatDefaultOpen??!1,p=!f||f.type==="chat"?"chat":f.type==="instructions"||f.type==="connections"||f.type==="layout"?"settings":d.has(f.type)?f.type:`${f.type}:${f.id??""}:${f.toolName??""}`,g=V=>{const[T,R,E]=V.split(":");return T?T==="chat"?{type:T}:d.has(T)?{type:T}:T==="ext-apps"&&R?{type:"ext-apps",id:R,toolName:E||void 0}:null:null},x=V=>{e.setValue("metadata.ui.pinnedViews",V,{shouldDirty:!0})},v=V=>{e.setValue("metadata.ui.layout",{...u,...V},{shouldDirty:!0})},b=N.useRef(!1);if(l&&l.length>0&&!b.current){b.current=!0;const V=new Set((l??[]).filter(E=>E.fetchOk).map(E=>E.id)),T=new Set(c.flatMap(E=>E.uiTools.map(I=>`${E.id}:${I.name}`))),R=h.filter(E=>!V.has(E.connectionId)||T.has(`${E.connectionId}:${E.toolName}`));R.length!==h.length&&(x(R),f?.type==="ext-apps"&&!R.some(E=>E.connectionId===f.id&&E.toolName===f.toolName)&&v({defaultMainView:{type:"chat"}}))}const _=(V,T)=>{if(h.some(E=>E.connectionId===V&&E.toolName===T)){const E=h.filter(D=>!(D.connectionId===V&&D.toolName===T));x(E);const I=`ext-apps:${V}:${T}`;p===I&&v({defaultMainView:{type:"chat"}})}else{const E=c.find(I=>I.id===V)?.uiTools.find(I=>I.name===T)?.title;x([...h,{connectionId:V,toolName:T,label:E??Ai(T),icon:null}])}s()},y=(V,T,R)=>{x(h.map(E=>E.connectionId===V&&E.toolName===T?{...E,label:R}:E))},L=()=>{s()},w=(V,T,R)=>{x(h.map(E=>E.connectionId===V&&E.toolName===T?{...E,icon:R}:E)),s()},j=V=>{v({defaultMainView:g(V)}),s()},S=a.length===0,k=l&&c.length===0,C=$s(o?.metadata),A=[{value:"chat",label:n("virtualMcp.layoutTabContent.chat")},{value:"settings",label:n("virtualMcp.layoutTabContent.settings")},{value:"automations",label:n("virtualMcp.layoutTabContent.automations")}];C&&A.push({value:"preview",label:n("virtualMcp.layoutTabContent.preview")});for(const V of h)A.push({value:`ext-apps:${V.connectionId}:${V.toolName}`,label:V.label||V.toolName});const P=c.length>0||S||k;return r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-3",children:r.jsx("h2",{className:"text-sm font-medium text-foreground",children:n("virtualMcp.layoutTabContent.layout")})}),r.jsxs(Sl,{className:"p-6 gap-5",children:[r.jsxs(zo,{className:"p-0 space-y-5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(st,{className:"font-normal text-foreground",children:n("virtualMcp.layoutTabContent.mainView")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.mainViewDescription")})]}),r.jsxs(Ft,{value:p,onValueChange:j,children:[r.jsx($t,{className:"w-44 h-8 text-sm capitalize shrink-0",children:r.jsx(qt,{})}),r.jsx(Bt,{children:A.map(V=>r.jsx(ut,{value:V.value,className:"capitalize",children:V.label},V.value))})]})]}),r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(st,{className:"font-normal text-foreground",children:n("virtualMcp.layoutTabContent.showChat")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.showChatDescription")})]}),r.jsxs(We,{delayDuration:0,children:[r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"shrink-0",children:r.jsx(_r,{checked:p==="chat"?!0:m,disabled:p==="chat",onCheckedChange:V=>{v({chatDefaultOpen:V}),s()}})})}),p==="chat"&&r.jsx(He,{side:"top",children:n("virtualMcp.layoutTabContent.chatAlwaysShown")})]})]})]}),P&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"border-t border-border -mx-6"}),r.jsxs(zo,{className:"p-0 space-y-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-4",children:r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(st,{className:"font-normal text-foreground",children:n("virtualMcp.layoutTabContent.pinnedViews")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.pinnedViewsDescription")})]})}),S&&r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.addConnectionMessage")}),k&&!S&&r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.noInteractiveTools")}),c.length>0&&r.jsx("div",{className:"space-y-4 pt-1",children:c.map((V,T)=>r.jsxs("div",{children:[T>0&&r.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),r.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[r.jsx(ln,{icon:V.icon,name:V.title,size:"xs",className:"shrink-0"}),r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:V.title})]}),r.jsx("div",{className:"space-y-1.5",children:V.uiTools.map(R=>{const E=h.some(D=>D.connectionId===V.id&&D.toolName===R.name),I=h.find(D=>D.connectionId===V.id&&D.toolName===R.name);return r.jsxs("div",{className:ie("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",E?"bg-accent/40 border-border":"bg-transparent border-border"),children:[r.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[r.jsx(Uj,{value:I?.icon??null,onChange:D=>w(V.id,R.name,D),disabled:!E}),r.jsx(et,{value:E&&I?I.label:R.title??Ai(R.name),onChange:D=>y(V.id,R.name,D.target.value),onBlur:L,className:"h-7 text-sm w-40",disabled:!E,readOnly:!E})]}),r.jsx(_r,{checked:E,onCheckedChange:()=>_(V.id,R.name)})]},R.name)})})]},V.id))})]})]})]})]})}const Zc={tools:null,resources:null,prompts:null},qj=ov.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Gj(t){const s=new TextEncoder().encode(t),n=Array.from(s,i=>String.fromCharCode(i)).join("");return btoa(n)}function w3(t){return{"x-studio-client":t,"x-mesh-client":t}}function Yj(t){const e=F.c(15),{url:s,agentId:n}=t,i=oe(),[o,a]=N.useState(!1);let l;e[0]!==n||e[1]!==i||e[2]!==s?(l=async()=>{Fe("agent_connect_action",{agent_id:n,action:"copy_url"}),await navigator.clipboard.writeText(s),a(!0),ve.success(i("virtualMcp.virtualMcpShareModal.agentUrlCopied")),await Rr(2e3),a(!1)},e[0]=n,e[1]=i,e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==o?(d=o?r.jsx(ns,{size:20,className:"text-success"}):r.jsx(Vs,{size:20}),e[4]=o,e[5]=d):d=e[5];let h;e[6]!==o||e[7]!==i?(h=i(o?"virtualMcp.virtualMcpShareModal.copied":"virtualMcp.virtualMcpShareModal.copyUrl"),e[6]=o,e[7]=i,e[8]=h):h=e[8];let u;e[9]!==h?(u=r.jsx("span",{className:"text-xs font-medium",children:h}),e[9]=h,e[10]=u):u=e[10];let f;return e[11]!==c||e[12]!==d||e[13]!==u?(f=r.jsxs(le,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,u]}),e[11]=c,e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function Jj(t){const e=F.c(13),{url:s,serverName:n,agentId:i}=t,o=oe();let a;e[0]!==i||e[1]!==n||e[2]!==o||e[3]!==s?(a=()=>{Fe("agent_connect_action",{agent_id:i,action:"install_cursor"});const f=H2(n),m={type:"http",url:s,headers:w3("Cursor")},p=Gj(JSON.stringify(m,null,2)),g=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(f)}&config=${encodeURIComponent(p)}`;window.open(g,"_blank"),ve.success(o("virtualMcp.virtualMcpShareModal.openingCursor"))},e[0]=i,e[1]=n,e[2]=o,e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),e[5]=c):c=e[5];let d;e[6]!==o?(d=o("virtualMcp.virtualMcpShareModal.installOnCursor"),e[6]=o,e[7]=d):d=e[7];let h;e[8]!==d?(h=r.jsx("span",{className:"text-xs font-medium",children:d}),e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==l||e[11]!==h?(u=r.jsxs(le,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,h]}),e[10]=l,e[11]=h,e[12]=u):u=e[12],u}function Xj(t){const e=F.c(16),{url:s,serverName:n,agentId:i}=t,o=oe(),[a,l]=N.useState(!1);let c;e[0]!==i||e[1]!==n||e[2]!==o||e[3]!==s?(c=async()=>{Fe("agent_connect_action",{agent_id:i,action:"install_claude_code"});const p=H2(n),g={type:"http",url:s,headers:w3("Claude Code")},x=JSON.stringify(g,null,2),v=`claude mcp add-json "${p}" '${x.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(v),l(!0),ve.success(o("virtualMcp.virtualMcpShareModal.claudeCodeCommandCopied")),await Rr(2e3),l(!1)},e[0]=i,e[1]=n,e[2]=o,e[3]=s,e[4]=c):c=e[4];const d=c;let h;e[5]!==a?(h=a?r.jsx(ns,{size:20,className:"text-success"}):r.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[5]=a,e[6]=h):h=e[6];let u;e[7]!==a||e[8]!==o?(u=o(a?"virtualMcp.virtualMcpShareModal.copied":"virtualMcp.virtualMcpShareModal.installOnClaudeCode"),e[7]=a,e[8]=o,e[9]=u):u=e[9];let f;e[10]!==u?(f=r.jsx("span",{className:"text-xs font-medium",children:u}),e[10]=u,e[11]=f):f=e[11];let m;return e[12]!==d||e[13]!==h||e[14]!==f?(m=r.jsxs(le,{type:"button",variant:"outline",onClick:d,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,f]}),e[12]=d,e[13]=h,e[14]=f,e[15]=m):m=e[15],m}function Qj({virtualMcp:t}){const e=oe(),s=Fs(),[n,i]=N.useState(null),[o,a]=N.useState(!1),[l,c]=N.useState(!1),d=t.id,h=t.title||`agent-${d.slice(0,8)}`,u=n?`bunx @decocms/typegen@latest --mcp ${d} --key ${n} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${d} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const{key:p}=await s.call("API_KEY_CREATE",{name:`typegen-${h}`,permissions:{[d]:["*"]}});if(!p)throw new Error("No key in response");i(p),Fe("agent_typegen_key_generated",{agent_id:d})}catch{Fe("agent_typegen_key_failed",{agent_id:d}),ve.error(e("virtualMcp.virtualMcpShareModal.failedGenerateApiKey"))}finally{a(!1)}},m=async()=>{Fe("agent_connect_action",{agent_id:d,action:"typegen_copy_command",has_api_key:!!n}),await navigator.clipboard.writeText(u),c(!0),ve.success(e("virtualMcp.virtualMcpShareModal.commandCopied")),await Rr(2e3),c(!1)};return r.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground",children:e("virtualMcp.virtualMcpShareModal.generateTypedClient")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.generateTypedClientDescription")})]}),!n&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?r.jsx(Ze,{size:14,className:"animate-spin"}):r.jsx(S9,{size:14}),r.jsx("span",{children:e(o?"virtualMcp.virtualMcpShareModal.generating":"virtualMcp.virtualMcpShareModal.generateApiKey")})]})]}),n&&r.jsx("p",{className:"rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning",children:e("virtualMcp.virtualMcpShareModal.storeKeySecurely")}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.generateClientLabel")}),r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:u}),r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?r.jsx(ns,{size:12,className:"text-success"}):r.jsx(Vs,{size:12})})]})}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.runtimeVariables")}),r.jsx(Zj,{apiKey:n,agentId:d})]})}function Zj(t){const e=F.c(21),{apiKey:s,agentId:n}=t,[i,o]=N.useState(!1),a=window.location.origin,l=s?`STUDIO_API_KEY=${s}`:"STUDIO_API_KEY=<api-key>",c=`STUDIO_BASE_URL=${a}`,d=`${l}
9
- ${c}`;let h;e[0]!==n||e[1]!==s||e[2]!==d?(h=async()=>{Fe("agent_connect_action",{agent_id:n,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(d),o(!0),await Rr(2e3),o(!1)},e[0]=n,e[1]=s,e[2]=d,e[3]=h):h=e[3];const u=h,f=!s;let m;e[4]!==f?(m=ie({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let p;e[6]!==l||e[7]!==m?(p=r.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let g,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx("br",{}),x=r.jsx("span",{children:c}),e[9]=g,e[10]=x):(g=e[9],x=e[10]);let v;e[11]!==p?(v=r.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,g,x]}),e[11]=p,e[12]=v):v=e[12];let b;e[13]!==i?(b=i?r.jsx(ns,{size:12,className:"text-success"}):r.jsx(Vs,{size:12}),e[13]=i,e[14]=b):b=e[14];let _;e[15]!==u||e[16]!==b?(_=r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:b}),e[15]=u,e[16]=b,e[17]=_):_=e[17];let y;return e[18]!==v||e[19]!==_?(y=r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[v,_]})}),e[18]=v,e[19]=_,e[20]=y):y=e[20],y}function eC(t){const e=F.c(3),{virtualMcp:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=n):n=e[0];let i;return e[1]!==s?(i=r.jsx(N.Suspense,{fallback:n,children:r.jsx(Qj,{virtualMcp:s})}),e[1]=s,e[2]=i):i=e[2],i}const tC={self:["COLLECTION_THREADS_CREATE","COLLECTION_THREADS_GET","COLLECTION_THREAD_MESSAGES_LIST","COLLECTION_THREADS_LIST"]},sC=3600*24*90;function nC({virtualMcp:t}){const e=oe(),s=Fs(),{org:n}=ze(),[i,o]=N.useState(null),[a,l]=N.useState(!1),[c,d]=N.useState(!1),h=t.id,u=t.title||`agent-${h.slice(0,8)}`,m=[`STUDIO_BASE_URL=${window.location.origin}`,`STUDIO_ORG=${n.slug}`,`STUDIO_AGENT_ID=${h}`,`STUDIO_API_KEY=${i??"<api-key>"}`].join(`
10
- `),p=async()=>{l(!0);try{const{key:x}=await s.call("API_KEY_CREATE",{name:`chat-bridge-${u}`,permissions:tC,expiresIn:sC});if(!x)throw new Error("No key in response");o(x),Fe("agent_chat_bridge_key_generated",{agent_id:h})}catch{Fe("agent_chat_bridge_key_failed",{agent_id:h}),ve.error(e("virtualMcp.virtualMcpShareModal.failedCreateApiKey"))}finally{l(!1)}},g=async()=>{Fe("agent_connect_action",{agent_id:h,action:"chat_bridge_copy_env",has_api_key:!!i}),await navigator.clipboard.writeText(m),d(!0),ve.success(e("virtualMcp.virtualMcpShareModal.connectionDetailsCopied")),await Rr(2e3),d(!1)};return r.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground",children:e("virtualMcp.virtualMcpShareModal.callFromYourApp")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.callFromYourAppDescription")})]}),!i&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:p,disabled:a,children:[a?r.jsx(Ze,{size:14,className:"animate-spin"}):r.jsx(S9,{size:14}),r.jsx("span",{children:e(a?"virtualMcp.virtualMcpShareModal.creating":"virtualMcp.virtualMcpShareModal.createApiKey")})]})]}),i&&r.jsx("p",{className:"rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning",children:e("virtualMcp.virtualMcpShareModal.storeKeySecurely")}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.connectionDetails")}),r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:m}),r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:g,children:c?r.jsx(ns,{size:12,className:"text-success"}):r.jsx(Vs,{size:12})})]})})]})}function iC(t){const e=F.c(3),{virtualMcp:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=n):n=e[0];let i;return e[1]!==s?(i=r.jsx(N.Suspense,{fallback:n,children:r.jsx(nC,{virtualMcp:s})}),e[1]=s,e[2]=i):i=e[2],i}function rC(t){const e=F.c(49),{open:s,onOpenChange:n,virtualMcp:i}=t,o=oe(),{org:a}=ze(),l=`/api/${a.slug}/mcp/virtual-mcp/${i.id}`;let c;e[0]!==l?(c=new URL(l,window.location.origin),e[0]=l,e[1]=c):c=e[1];const d=c;let h;e[2]!==i.id||e[3]!==i.title?(h=i.title||`agent-${i.id?.slice(0,8)??"default"}`,e[2]=i.id,e[3]=i.title,e[4]=h):h=e[4];const u=h,f=Tr();let m;e[5]!==i.id||e[6]!==d.href?(m=r.jsx(Yj,{url:d.href,agentId:i.id}),e[5]=i.id,e[6]=d.href,e[7]=m):m=e[7];let p,g;e[8]!==u||e[9]!==i.id||e[10]!==d.href?(p=r.jsx(Jj,{url:d.href,serverName:u,agentId:i.id}),g=r.jsx(Xj,{url:d.href,serverName:u,agentId:i.id}),e[8]=u,e[9]=i.id,e[10]=d.href,e[11]=p,e[12]=g):(p=e[11],g=e[12]);let x;e[13]!==m||e[14]!==p||e[15]!==g?(x=r.jsx("div",{className:"flex flex-col gap-3 pt-2",children:r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[m,p,g]})}),e[13]=m,e[14]=p,e[15]=g,e[16]=x):x=e[16];let v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:"border-t border-border"}),e[17]=v):v=e[17];let b;e[18]!==i?(b=r.jsx(eC,{virtualMcp:i}),e[18]=i,e[19]=b):b=e[19];let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("div",{className:"border-t border-border"}),e[20]=_):_=e[20];let y;e[21]!==i?(y=r.jsx(iC,{virtualMcp:i}),e[21]=i,e[22]=y):y=e[22];let L;e[23]!==y||e[24]!==x||e[25]!==b?(L=r.jsxs("div",{className:"flex flex-col gap-6",children:[x,v,b,_,y]}),e[23]=y,e[24]=x,e[25]=b,e[26]=L):L=e[26];const w=L;if(f){let A;e[27]!==o?(A=o("virtualMcp.virtualMcpShareModal.connect"),e[27]=o,e[28]=A):A=e[28];let P;e[29]!==A?(P=r.jsx(Wm,{className:"mt-4 mb-4 text-base font-semibold",children:A}),e[29]=A,e[30]=P):P=e[30];let V;e[31]!==w||e[32]!==P?(V=r.jsx(qm,{children:r.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[P,w]})}),e[31]=w,e[32]=P,e[33]=V):V=e[33];let T;return e[34]!==n||e[35]!==s||e[36]!==V?(T=r.jsx(Gm,{open:s,onOpenChange:n,children:V}),e[34]=n,e[35]=s,e[36]=V,e[37]=T):T=e[37],T}let j;e[38]!==o?(j=o("virtualMcp.virtualMcpShareModal.connect"),e[38]=o,e[39]=j):j=e[39];let S;e[40]!==j?(S=r.jsx(cs,{children:r.jsx(ds,{children:j})}),e[40]=j,e[41]=S):S=e[41];let k;e[42]!==w||e[43]!==S?(k=r.jsxs(Yt,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[S,w]}),e[42]=w,e[43]=S,e[44]=k):k=e[44];let C;return e[45]!==n||e[46]!==s||e[47]!==k?(C=r.jsx(Jt,{open:s,onOpenChange:n,children:k}),e[45]=n,e[46]=s,e[47]=k,e[48]=C):C=e[48],C}function oC(t){const e=F.c(50),{virtualMcp:s}=t,n=oe(),i=la(),o=g9(),[a,l]=N.useState(!1);let c,d,h,u,f,m,p,g,x;if(e[0]!==o||e[1]!==i||e[2]!==n||e[3]!==s.id||e[4]!==s.metadata){x=Symbol.for("react.early_return_sentinel");e:{const j=m9(i);if(cl(s.id)||$s(s.metadata)||j.has(s.id)){x=null;break e}let S;e[14]!==i||e[15]!==s.id?(S=(i??[]).find(D=>D.metadata?.liveAgentId===s.id)??null,e[14]=i,e[15]=s.id,e[16]=S):S=e[16];const k=S,C=k?.id??null;let A;e[17]!==o.update?(A=(D,M)=>o.update.mutateAsync({id:D,data:{metadata:{liveAgentId:M}}}).catch(lC),e[17]=o.update,e[18]=A):A=e[18];const P=A;let V;e[19]!==P||e[20]!==s.id?(V=D=>{P(D,s.id)},e[19]=P,e[20]=s.id,e[21]=V):V=e[21],h=V;let T;e[22]!==C||e[23]!==P?(T=()=>{C&&P(C,null)},e[22]=C,e[23]=P,e[24]=T):T=e[24];const R=T,E=(i??[]).filter(D=>D.id!==s.id&&$s(D.metadata)&&!j.has(D.id));p="flex flex-col gap-3";let I;e[25]!==n?(I=n("devAgent.devAgentSetup.title"),e[25]=n,e[26]=I):I=e[26],e[27]!==I?(g=r.jsx("h2",{className:"text-sm font-medium text-foreground",children:I}),e[27]=I,e[28]=g):g=e[28],d=Sl,m="p-6 gap-4",c=zo,u="p-0 space-y-4",f=C?r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[r.jsx("span",{className:"text-sm text-foreground truncate",children:k?k.title:C}),r.jsx("span",{className:"text-xs text-muted-foreground",children:n("devAgent.devAgentSetup.linkedDescription")})]}),r.jsx(le,{variant:"outline",size:"sm",className:"shrink-0",onClick:R,children:n("devAgent.devAgentSetup.unlinkButton")})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:n("devAgent.devAgentSetup.linkDescription")}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(le,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>l(!0),children:[r.jsx(Uo,{className:"size-4"}),n("devAgent.devAgentSetup.importButton")]}),E.length>0?r.jsxs(Ft,{onValueChange:h,children:[r.jsx($t,{size:"sm",className:"w-56",children:r.jsx(qt,{placeholder:n("devAgent.devAgentSetup.selectPlaceholder")})}),r.jsx(Bt,{children:E.map(aC)})]}):null]})]})}e[0]=o,e[1]=i,e[2]=n,e[3]=s.id,e[4]=s.metadata,e[5]=c,e[6]=d,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x}else c=e[5],d=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13];if(x!==Symbol.for("react.early_return_sentinel"))return x;let v;e[29]!==c||e[30]!==u||e[31]!==f?(v=r.jsx(c,{className:u,children:f}),e[29]=c,e[30]=u,e[31]=f,e[32]=v):v=e[32];let b;e[33]!==d||e[34]!==m||e[35]!==v?(b=r.jsx(d,{className:m,children:v}),e[33]=d,e[34]=m,e[35]=v,e[36]=b):b=e[36];let _;e[37]!==n?(_=n("devAgent.devAgentSetup.importDialogTitle"),e[37]=n,e[38]=_):_=e[38];let y;e[39]!==h?(y=j=>{const{virtualMcpId:S}=j;l(!1),h(S)},e[39]=h,e[40]=y):y=e[40];let L;e[41]!==a||e[42]!==y||e[43]!==_?(L=r.jsx(W2,{open:a,onOpenChange:l,title:_,onImportComplete:y}),e[41]=a,e[42]=y,e[43]=_,e[44]=L):L=e[44];let w;return e[45]!==L||e[46]!==p||e[47]!==g||e[48]!==b?(w=r.jsxs("div",{className:p,children:[g,b,L]}),e[45]=L,e[46]=p,e[47]=g,e[48]=b,e[49]=w):w=e[49],w}function aC(t){return r.jsx(ut,{value:t.id,children:t.title},t.id)}function lC(){}const cC=/^[A-Za-z_][A-Za-z0-9_]*$/;function dC(t){const e={},s=t.split(/\r?\n/);for(let n=0;n<s.length;n++){let i=(s[n]??"").trim();if(!i||i.startsWith("#"))continue;i.startsWith("export ")&&(i=i.slice(7).trim());const o=i.indexOf("=");if(o<0)throw new Error(`Line ${n+1}: missing '='`);const a=i.slice(0,o).trim();if(!cC.test(a))throw new Error(`Line ${n+1}: invalid key "${a}"`);let l=i.slice(o+1).trim();l.length>=2&&(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),e[a]=l}return e}const j3=/^[A-Za-z0-9_.-]+$/;function C3(t){const e=F.c(15),{field:s,secretById:n}=t,i=oe(),o=s.value||"";if(!o)return null;let a;e[0]!==o||e[1]!==n?(a=n.get(o),e[0]=o,e[1]=n,e[2]=a):a=e[2];const l=a;if(!l){let u;e[3]!==o||e[4]!==i?(u=i("sandbox.envVarsField.missingSecret",{id:o}),e[3]=o,e[4]=i,e[5]=u):u=e[5];let f;return e[6]!==u?(f=r.jsx("span",{className:"text-destructive",children:u}),e[6]=u,e[7]=f):f=e[7],f}let c;e[8]!==l.scope?(c=r.jsx(Q9,{scope:l.scope}),e[8]=l.scope,e[9]=c):c=e[9];let d;e[10]!==l.name?(d=r.jsx("span",{className:"truncate font-mono",children:l.name}),e[10]=l.name,e[11]=d):d=e[11];let h;return e[12]!==c||e[13]!==d?(h=r.jsxs("span",{className:"inline-flex items-center gap-1.5 truncate",children:[c,d]}),e[12]=c,e[13]=d,e[14]=h):h=e[14],h}function Q9(t){const e=F.c(2),{scope:s}=t,n=s==="user"?L8:ac;let i;return e[0]!==n?(i=r.jsx(n,{className:"size-3 text-muted-foreground"}),e[0]=n,e[1]=i):i=e[1],i}async function k3(t,e,s){const n=s?`?branch=${encodeURIComponent(s)}`:"",i=await fetch(`/api/${t}/agent-sandbox-sessions/${e}${n}`,{cache:"no-store"});if(!i.ok)throw new Error("Failed to load sandbox sessions");return(await i.json()).items}function uC(t,e,s){const n=F.c(12);let i;n[0]!==s||n[1]!==t||n[2]!==e?(i=Qe.agentSandboxSession(t,e,s??""),n[0]=s,n[1]=t,n[2]=e,n[3]=i):i=n[3];let o;n[4]!==s||n[5]!==t||n[6]!==e?(o=async()=>s?(await k3(t,e,s))[0]??null:null,n[4]=s,n[5]=t,n[6]=e,n[7]=o):o=n[7];const a=!!s;let l;return n[8]!==i||n[9]!==o||n[10]!==a?(l={queryKey:i,queryFn:o,enabled:a,refetchInterval:5e3},n[8]=i,n[9]=o,n[10]=a,n[11]=l):l=n[11],Pt(l)}function V3(t,e,s){const n=F.c(10),i=s===void 0?!0:s;let o;n[0]!==t||n[1]!==e?(o=Qe.agentSandboxSessions(t,e),n[0]=t,n[1]=e,n[2]=o):o=n[2];let a;n[3]!==t||n[4]!==e?(a=()=>k3(t,e),n[3]=t,n[4]=e,n[5]=a):a=n[5];let l;return n[6]!==i||n[7]!==o||n[8]!==a?(l={queryKey:o,queryFn:a,enabled:i},n[6]=i,n[7]=o,n[8]=a,n[9]=l):l=n[9],Pt(l)}function hC(t){const e=F.c(27),{control:s,form:n,virtualMcpId:i,orgSlug:o}=t,a=oe();let l;e[0]!==a?(l=a("sandbox.envVarsField.title"),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx("div",{className:"flex items-baseline justify-between gap-2",children:r.jsx(st,{className:"font-normal text-foreground",children:l})}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==a?(d=a("sandbox.envVarsField.description"),e[4]=a,e[5]=d):d=e[5];let h;e[6]!==d?(h=r.jsx("p",{className:"text-xs text-muted-foreground",children:d}),e[6]=d,e[7]=h):h=e[7];let u;e[8]!==s||e[9]!==n||e[10]!==o||e[11]!==i?(u=r.jsx(fC,{control:s,form:n,virtualMcpId:i,orgSlug:o}),e[8]=s,e[9]=n,e[10]=o,e[11]=i,e[12]=u):u=e[12];let f;e[13]!==a?(f=v=>{const{error:b}=v;return r.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:b?.message??a("sandbox.envVarsField.failedToLoadSecrets")})},e[13]=a,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Et,{className:"h-9 w-full"}),e[15]=m):m=e[15];let p;e[16]!==s||e[17]!==n?(p=r.jsx(N.Suspense,{fallback:m,children:r.jsx(xC,{control:s,form:n})}),e[16]=s,e[17]=n,e[18]=p):p=e[18];let g;e[19]!==f||e[20]!==p?(g=r.jsx(hs,{fallback:f,children:p}),e[19]=f,e[20]=p,e[21]=g):g=e[21];let x;return e[22]!==c||e[23]!==h||e[24]!==u||e[25]!==g?(x=r.jsxs("div",{className:"space-y-2",children:[c,h,u,g]}),e[22]=c,e[23]=h,e[24]=u,e[25]=g,e[26]=x):x=e[26],x}function fC(t){const e=F.c(29),{control:s,form:n,virtualMcpId:i,orgSlug:o}=t,a=oe(),c=ui.useSession().data?.user?.id,{data:d}=V3(o,i),h=d===void 0?[]:d,u="metadata.runtime.env",f="metadata.sandboxMap";let m;e[0]!==n?(m=()=>JSON.stringify(Xh(n.getValues(u))),e[0]=n,e[1]=m):m=e[1];const[p,g]=N.useState(m);let x;e[2]!==s?(x={control:s,name:u},e[2]=s,e[3]=x):x=e[3];const v=Dm(x);let b;e[4]!==v?(b=JSON.stringify(Xh(v)),e[4]=v,e[5]=b):b=e[5];const _=b,y=_!==p;let L;e[6]!==n?(L=n.getValues(f),e[6]=n,e[7]=L):L=e[7];const w=L;let j;e[8]!==w||e[9]!==c?(j=c?Object.keys(w?.[c]??{}):[],e[8]=w,e[9]=c,e[10]=j):j=e[10];const S=[...new Set([...j,...h.filter(gC).map(pC)])],k=S.length>0,[C,A]=N.useState(!1);if(!y||!k)return null;const P=async()=>{A(!0);const O=await Promise.allSettled(S.map(async B=>{const z=`/api/${encodeURIComponent(o)}/sandbox/${encodeURIComponent(i)}/${encodeURIComponent(B)}/setup/start`,K=await fetch(z,{method:"POST"});if(!K.ok){const Y=await K.text().catch(()=>K.statusText);throw new Error(Y||K.statusText)}}));A(!1);const $=O.filter(mC).length;$===0?(g(_),ve.success(S.length===1?a("sandbox.envVarsField.restartedSingle"):a("sandbox.envVarsField.restartedMultiple",{count:S.length}))):ve.error(a("sandbox.envVarsField.restartFailed",{failed:$,total:S.length}))};let V;e[11]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(kr,{className:"size-3.5 shrink-0"}),e[11]=V):V=e[11];let T;e[12]!==a?(T=a("sandbox.envVarsField.sandboxRunningNotice"),e[12]=a,e[13]=T):T=e[13];let R;e[14]!==T?(R=r.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-warning",children:[V,r.jsx("span",{className:"truncate",children:T})]}),e[14]=T,e[15]=R):R=e[15];let E;e[16]!==C?(E=C?r.jsx(Ze,{className:"size-3.5 animate-spin"}):r.jsx(gr,{className:"size-3.5"}),e[16]=C,e[17]=E):E=e[17];let I;e[18]!==C||e[19]!==a?(I=a(C?"sandbox.envVarsField.restarting":"sandbox.envVarsField.restartDev"),e[18]=C,e[19]=a,e[20]=I):I=e[20];let D;e[21]!==P||e[22]!==C||e[23]!==E||e[24]!==I?(D=r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:C,className:"shrink-0",children:[E,I]}),e[21]=P,e[22]=C,e[23]=E,e[24]=I,e[25]=D):D=e[25];let M;return e[26]!==D||e[27]!==R?(M=r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs",children:[R,D]}),e[26]=D,e[27]=R,e[28]=M):M=e[28],M}function mC(t){return t.status==="rejected"}function pC(t){return t.branch}function gC(t){return t.desiredState==="running"&&t.status==="ready"&&!!t.sandboxHandle}function xC(t){const e=F.c(62),{control:s,form:n}=t,i=oe(),o="metadata.runtime.env";let a;e[0]!==s?(a={control:s,name:o},e[0]=s,e[1]=a):a=e[1];const l=Im(a),{fields:c,append:d,remove:h}=l;let u;e[2]!==n?(u=(O,$)=>{n.setValue(`${o}.${O}`,$,{shouldDirty:!0,shouldTouch:!0})},e[2]=n,e[3]=u):u=e[3];const f=u,m=q2();let p;if(e[4]!==m){p=new Map;for(const O of m)p.set(O.id,O);e[4]=m,e[5]=p}else p=e[5];const[g,x]=N.useState(null);let v;e[6]!==d?(v=()=>{d({key:"",kind:"literal",value:""})},e[6]=d,e[7]=v):v=e[7];const b=v;let _;e[8]!==d||e[9]!==n||e[10]!==i?(_=async()=>{let O;try{O=await navigator.clipboard.readText()}catch{ve.error(i("sandbox.envVarsField.clipboardReadFailed"));return}if(!O.trim()){ve.error(i("sandbox.envVarsField.clipboardEmpty"));return}let $;try{$=dC(O)}catch(q){const H=q;ve.error(H.message);return}const B=Object.entries($);if(B.length===0){ve.error(i("sandbox.envVarsField.nothingToAdd"));return}const z=n.getValues(o)??[],K=new Set;for(const q of z){const H=(q.key??"").trim();H&&K.add(H)}let Y=0,Q=0;for(const[q,H]of B){if(K.has(q)){Q++;continue}d({key:q,kind:"literal",value:H}),K.add(q),Y++}Y===0&&Q>0?ve.message(i("sandbox.envVarsField.allKeysExist",{count:Q})):ve.success(Q>0?i("sandbox.envVarsField.addedWithSkipped",{added:Y,skipped:Q}):i("sandbox.envVarsField.added",{added:Y}))},e[8]=d,e[9]=n,e[10]=i,e[11]=_):_=e[11];const y=_;let L;if(e[12]!==s||e[13]!==c||e[14]!==n||e[15]!==h||e[16]!==p||e[17]!==m||e[18]!==f){let O;e[20]!==s||e[21]!==n||e[22]!==h||e[23]!==p||e[24]!==m||e[25]!==f?(O=($,B)=>r.jsx("li",{className:"rounded-md border border-border bg-background",children:r.jsx(vC,{index:B,control:s,form:n,onUpdateEntry:f,fieldPath:o,secrets:m,secretById:p,onSaveAsSecret:(z,K)=>x({kind:"save-literal",index:B,presetKey:z,presetValue:K}),onCreateNewSecret:z=>x({kind:"create-new",index:B,presetKey:z}),onRemove:()=>h(B)})},$.id),e[20]=s,e[21]=n,e[22]=h,e[23]=p,e[24]=m,e[25]=f,e[26]=O):O=e[26],L=c.map(O),e[12]=s,e[13]=c,e[14]=n,e[15]=h,e[16]=p,e[17]=m,e[18]=f,e[19]=L}else L=e[19];let w;e[27]!==L?(w=r.jsx("ul",{className:"space-y-2",children:L}),e[27]=L,e[28]=w):w=e[28];let j;e[29]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(_t,{className:"size-3.5"}),e[29]=j):j=e[29];let S;e[30]!==i?(S=i("sandbox.envVarsField.addEnvVar"),e[30]=i,e[31]=S):S=e[31];let k;e[32]!==b||e[33]!==S?(k=r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:b,className:"flex-1",children:[j,S]}),e[32]=b,e[33]=S,e[34]=k):k=e[34];let C;e[35]!==i?(C=i("sandbox.envVarsField.pasteDotenvAriaLabel"),e[35]=i,e[36]=C):C=e[36];let A;e[37]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(r2,{className:"size-3.5"}),e[37]=A):A=e[37];let P;e[38]!==i?(P=i("sandbox.envVarsField.pasteDotenv"),e[38]=i,e[39]=P):P=e[39];let V;e[40]!==y||e[41]!==C||e[42]!==P?(V=r.jsx(Ue,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:y,"aria-label":C,children:[A,P]})}),e[40]=y,e[41]=C,e[42]=P,e[43]=V):V=e[43];let T;e[44]!==i?(T=i("sandbox.envVarsField.pasteDotenvTooltip"),e[44]=i,e[45]=T):T=e[45];let R;e[46]!==T?(R=r.jsx(He,{children:T}),e[46]=T,e[47]=R):R=e[47];let E;e[48]!==V||e[49]!==R?(E=r.jsxs(We,{children:[V,R]}),e[48]=V,e[49]=R,e[50]=E):E=e[50];let I;e[51]!==E||e[52]!==k?(I=r.jsxs("div",{className:"flex items-center gap-2",children:[k,E]}),e[51]=E,e[52]=k,e[53]=I):I=e[53];let D;e[54]!==g||e[55]!==n||e[56]!==f?(D=g!==null?r.jsx(yC,{mode:g,onClose:()=>x(null),onSaved:O=>{const $=n.getValues(`${o}.${g.index}.key`)?.trim()??"";f(g.index,{key:$,kind:"secret",secretId:O}),x(null)}}):null,e[54]=g,e[55]=n,e[56]=f,e[57]=D):D=e[57];let M;return e[58]!==I||e[59]!==D||e[60]!==w?(M=r.jsxs("div",{className:"space-y-2",children:[w,I,D]}),e[58]=I,e[59]=D,e[60]=w,e[61]=M):M=e[61],M}function vC(t){const e=F.c(77),{index:s,control:n,form:i,onUpdateEntry:o,fieldPath:a,secrets:l,secretById:c,onSaveAsSecret:d,onCreateNewSecret:h,onRemove:u}=t,f=oe(),m=`${a}.${s}.key`,p=`${a}.${s}.value`,g=`${a}.${s}.secretId`,x=`${a}.${s}.kind`;let v;e[0]!==n||e[1]!==x?(v={control:n,name:x},e[0]=n,e[1]=x,e[2]=v):v=e[2];const _=Dm(v)==="secret"?"secret":"literal";let y;e[3]!==i||e[4]!==s||e[5]!==m||e[6]!==d||e[7]!==o||e[8]!==p?(y=H=>{const U=i.getValues(m)?.trim()??"";if(H==="literal"){o(s,{key:U,kind:"literal",value:""});return}const X=i.getValues(p)??"";if(X.length>0){d(U,X);return}o(s,{key:U,kind:"secret",secretId:""})},e[3]=i,e[4]=s,e[5]=m,e[6]=d,e[7]=o,e[8]=p,e[9]=y):y=e[9];const L=y;let w;e[10]!==s||e[11]!==f?(w=H=>{const{field:U}=H,X=(U.value??"").trim(),J=X.length>0&&!Jl.test(X);return r.jsxs("div",{className:"space-y-1",children:[r.jsx(et,{...U,value:U.value??"",placeholder:f("sandbox.envVarsField.keyPlaceholder"),spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:ie("font-mono",J&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":J,"aria-label":f("sandbox.envVarsField.envVarKeyLabel",{index:s+1}),onBlur:ee=>{const W=ee.target.value.trim();U.onChange(W),U.onBlur()}}),J?r.jsx("p",{className:"text-[11px] text-destructive",children:f("sandbox.envVarsField.invalidKeyMessage")}):null]})},e[10]=s,e[11]=f,e[12]=w):w=e[12];let j;e[13]!==n||e[14]!==m||e[15]!==w?(j=r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx(ss,{control:n,name:m,render:w})}),e[13]=n,e[14]=m,e[15]=w,e[16]=j):j=e[16];let S;e[17]!==L?(S=H=>L(H),e[17]=L,e[18]=S):S=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx($t,{className:"h-9 w-[110px]",children:r.jsx(qt,{})}),e[19]=k):k=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(S9,{className:"size-3.5"}),e[20]=C):C=e[20];let A;e[21]!==f?(A=f("sandbox.envVarsField.literal"),e[21]=f,e[22]=A):A=e[22];let P;e[23]!==A?(P=r.jsx(ut,{value:"literal",children:r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[C,A]})}),e[23]=A,e[24]=P):P=e[24];let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(J0,{className:"size-3.5"}),e[25]=V):V=e[25];let T;e[26]!==f?(T=f("sandbox.envVarsField.secret"),e[26]=f,e[27]=T):T=e[27];let R;e[28]!==T?(R=r.jsx(ut,{value:"secret",children:r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[V,T]})}),e[28]=T,e[29]=R):R=e[29];let E;e[30]!==R||e[31]!==P?(E=r.jsxs(Bt,{children:[P,R]}),e[30]=R,e[31]=P,e[32]=E):E=e[32];let I;e[33]!==_||e[34]!==E||e[35]!==S?(I=r.jsx("div",{className:"shrink-0",children:r.jsxs(Ft,{value:_,onValueChange:S,children:[k,E]})}),e[33]=_,e[34]=E,e[35]=S,e[36]=I):I=e[36];let D;e[37]!==n||e[38]!==i||e[39]!==s||e[40]!==m||e[41]!==_||e[42]!==h||e[43]!==c||e[44]!==g||e[45]!==l||e[46]!==f||e[47]!==p?(D=r.jsx("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:_==="literal"?r.jsx(ss,{control:n,name:p,render:H=>{const{field:U}=H;return r.jsx(et,{...U,value:U.value??"",type:"password",placeholder:f("sandbox.envVarsField.valuePlaceholder"),spellCheck:!1,autoComplete:"off",className:"font-mono","aria-label":f("sandbox.envVarsField.envVarValueLabel",{index:s+1}),onBlur:X=>{U.onChange(X.target.value),U.onBlur()}})}}):r.jsxs(r.Fragment,{children:[r.jsx(ss,{control:n,name:g,render:H=>{const{field:U}=H;return r.jsxs(Ft,{value:U.value||"",onValueChange:X=>U.onChange(X),children:[r.jsx($t,{className:ie("h-9 w-full",!U.value&&"text-muted-foreground"),children:r.jsx(qt,{placeholder:f("sandbox.envVarsField.pickSecretPlaceholder"),children:r.jsx(C3,{field:U,secretById:c})})}),r.jsx(Bt,{children:l.length===0?r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:f("sandbox.envVarsField.noSecretsYet")}):l.map(bC)})]})}}),r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":f("sandbox.envVarsField.createNewSecretAriaLabel"),onClick:()=>{const H=i.getValues(m)?.trim()??"";h(H)},children:r.jsx(_t,{className:"size-3.5"})})}),r.jsx(He,{children:f("sandbox.envVarsField.createNewSecret")})]})]})}),e[37]=n,e[38]=i,e[39]=s,e[40]=m,e[41]=_,e[42]=h,e[43]=c,e[44]=g,e[45]=l,e[46]=f,e[47]=p,e[48]=D):D=e[48];let M;e[49]!==i||e[50]!==m||e[51]!==_||e[52]!==d||e[53]!==f||e[54]!==p?(M=_==="literal"?r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":f("sandbox.envVarsField.saveAsSecretAriaLabel"),onClick:()=>{const H=i.getValues(m)?.trim()??"",U=i.getValues(p)??"";d(H,U)},children:r.jsx(r9,{className:"size-3.5"})})}),r.jsx(He,{children:f("sandbox.envVarsField.saveAsSecret")})]}):null,e[49]=i,e[50]=m,e[51]=_,e[52]=d,e[53]=f,e[54]=p,e[55]=M):M=e[55];let O;e[56]!==f?(O=f("sandbox.envVarsField.removeEnvVarAriaLabel"),e[56]=f,e[57]=O):O=e[57];let $;e[58]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(_s,{className:"size-3.5"}),e[58]=$):$=e[58];let B;e[59]!==u||e[60]!==O?(B=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":O,onClick:u,children:$})}),e[59]=u,e[60]=O,e[61]=B):B=e[61];let z;e[62]!==f?(z=f("sandbox.envVarsField.remove"),e[62]=f,e[63]=z):z=e[63];let K;e[64]!==z?(K=r.jsx(He,{children:z}),e[64]=z,e[65]=K):K=e[65];let Y;e[66]!==B||e[67]!==K?(Y=r.jsxs(We,{children:[B,K]}),e[66]=B,e[67]=K,e[68]=Y):Y=e[68];let Q;e[69]!==M||e[70]!==Y?(Q=r.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[M,Y]}),e[69]=M,e[70]=Y,e[71]=Q):Q=e[71];let q;return e[72]!==I||e[73]!==D||e[74]!==Q||e[75]!==j?(q=r.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[j,I,D,Q]}),e[72]=I,e[73]=D,e[74]=Q,e[75]=j,e[76]=q):q=e[76],q}function bC(t){return r.jsx(ut,{value:t.id,children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx(Q9,{scope:t.scope}),r.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function yC({mode:t,onClose:e,onSaved:s}){const n=oe(),i=t.kind==="save-literal"?t.presetValue:"",o=t.presetKey,[a,l]=N.useState(()=>_C(o)),[c,d]=N.useState("organization"),[h,u]=N.useState(i),[f,m]=N.useState(""),p=G2(),g=a.trim(),x=h.length>0&&g.length>0&&j3.test(g),v=async y=>{if(y.preventDefault(),!!x)try{const L=await p.mutateAsync({scope:c,name:g,value:h,description:f.trim()||void 0});ve.success(n("sandbox.envVarsField.secretSaved",{name:L.name})),s(L.id)}catch(L){ve.error(L instanceof Error?L.message:n("sandbox.envVarsField.failedToSaveSecret"))}},b=t.kind==="save-literal"?n("sandbox.envVarsField.saveValueAsSecretTitle"):n("sandbox.envVarsField.createNewSecretTitle"),_=t.kind==="save-literal"?n("sandbox.envVarsField.saveValueAsSecretDescription"):n("sandbox.envVarsField.createNewSecretDescription");return r.jsx(Jt,{open:!0,onOpenChange:y=>{y||e()},children:r.jsxs(Yt,{className:"sm:max-w-md",children:[r.jsxs(cs,{children:[r.jsx(ds,{children:b}),r.jsx(On,{children:_})]}),r.jsxs("form",{onSubmit:v,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:"save-secret-scope",children:n("sandbox.envVarsField.scopeLabel")}),r.jsxs(Ft,{value:c,onValueChange:y=>d(y),children:[r.jsx($t,{id:"save-secret-scope",children:r.jsx(qt,{})}),r.jsxs(Bt,{children:[r.jsx(ut,{value:"organization",children:n("sandbox.envVarsField.scopeOrganization")}),r.jsx(ut,{value:"user",children:n("sandbox.envVarsField.scopePrivate")})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:"save-secret-name",children:n("sandbox.envVarsField.nameLabel")}),r.jsx(et,{id:"save-secret-name",value:a,onChange:y=>l(y.target.value),placeholder:n("sandbox.envVarsField.namePlaceholder"),autoComplete:"off",required:!0}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("sandbox.envVarsField.nameHelperText")})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:"save-secret-value",children:n("sandbox.envVarsField.valueLabel")}),r.jsx(et,{id:"save-secret-value",type:"password",value:h,onChange:y=>u(y.target.value),placeholder:n("sandbox.envVarsField.secretValuePlaceholder"),autoComplete:"new-password",required:!0})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:"save-secret-description",children:n("sandbox.envVarsField.descriptionLabel")}),r.jsx(Ri,{id:"save-secret-description",value:f,onChange:y=>m(y.target.value),rows:2,placeholder:n("sandbox.envVarsField.descriptionPlaceholder")})]}),r.jsxs(mi,{children:[r.jsx(le,{type:"button",variant:"outline",onClick:e,disabled:p.isPending,children:n("sandbox.envVarsField.cancel")}),r.jsx(le,{type:"submit",disabled:!x||p.isPending,children:p.isPending?n("sandbox.envVarsField.saving"):n("sandbox.envVarsField.saveSecret")})]})]})]})})}function Xh(t){if(!Array.isArray(t))return[];const e=[];for(const s of t){if(!s||typeof s!="object")continue;const n=s,i=(n.key??"").trim();if(!(!i||!Jl.test(i))){if(n.kind==="literal"){e.push({key:i,kind:"literal",value:n.value??""});continue}n.kind==="secret"&&n.secretId&&e.push({key:i,kind:"secret",secretId:n.secretId})}}return e}function _C(t){const e=t.trim();return e&&Jl.test(e)?e:""}function LC(t){const e=F.c(6),{control:s,form:n}=t;let i,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(st,{className:"font-normal text-foreground",children:"Submodule credentials"}),o=r.jsx("p",{className:"text-xs text-muted-foreground",children:"Personal access tokens for cloning private git submodules that live in other repositories. Reference an org/user secret per host; SSH submodule URLs are rewritten to HTTPS so the token applies."}),e[0]=i,e[1]=o):(i=e[0],o=e[1]);let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Et,{className:"h-9 w-full"}),e[2]=a):a=e[2];let l;return e[3]!==s||e[4]!==n?(l=r.jsxs("div",{className:"space-y-2",children:[i,o,r.jsx(hs,{fallback:SC,children:r.jsx(N.Suspense,{fallback:a,children:r.jsx(wC,{control:s,form:n})})})]}),e[3]=s,e[4]=n,e[5]=l):l=e[5],l}function SC(t){const{error:e}=t;return r.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:e?.message??"Failed to load secrets"})}function wC(t){const e=F.c(29),{control:s,form:n}=t,i="metadata.runtime.submoduleCredentials";let o;e[0]!==s?(o={control:s,name:i},e[0]=s,e[1]=o):o=e[1];const{fields:a,append:l,remove:c}=Im(o),d=q2();let h;if(e[2]!==d){h=new Map;for(const y of d)h.set(y.id,y);e[2]=d,e[3]=h}else h=e[3];const[u,f]=N.useState(null);let m;if(e[4]!==s||e[5]!==a||e[6]!==c||e[7]!==h||e[8]!==d){let y;e[10]!==s||e[11]!==c||e[12]!==h||e[13]!==d?(y=(L,w)=>r.jsx("li",{className:"rounded-md border border-border bg-background",children:r.jsx(jC,{index:w,control:s,fieldPath:i,secrets:d,secretById:h,onCreateNewSecret:()=>f(w),onRemove:()=>c(w)})},L.id),e[10]=s,e[11]=c,e[12]=h,e[13]=d,e[14]=y):y=e[14],m=a.map(y),e[4]=s,e[5]=a,e[6]=c,e[7]=h,e[8]=d,e[9]=m}else m=e[9];let p;e[15]!==m?(p=r.jsx("ul",{className:"space-y-2",children:m}),e[15]=m,e[16]=p):p=e[16];let g;e[17]!==l?(g=()=>l({host:"",secretId:""}),e[17]=l,e[18]=g):g=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(_t,{className:"size-3.5"}),e[19]=x):x=e[19];let v;e[20]!==g?(v=r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:g,className:"w-full",children:[x,"Add submodule credential"]}),e[20]=g,e[21]=v):v=e[21];let b;e[22]!==u||e[23]!==n?(b=u!==null?r.jsx(kC,{onClose:()=>f(null),onSaved:y=>{n.setValue(`${i}.${u}.secretId`,y,{shouldDirty:!0,shouldTouch:!0}),f(null)}}):null,e[22]=u,e[23]=n,e[24]=b):b=e[24];let _;return e[25]!==p||e[26]!==v||e[27]!==b?(_=r.jsxs("div",{className:"space-y-2",children:[p,v,b]}),e[25]=p,e[26]=v,e[27]=b,e[28]=_):_=e[28],_}function jC(t){const e=F.c(32),{index:s,control:n,fieldPath:i,secrets:o,secretById:a,onCreateNewSecret:l,onRemove:c}=t,d=`${i}.${s}.host`,h=`${i}.${s}.secretId`;let u;e[0]!==s?(u=k=>{const{field:C}=k,A=(C.value??"").trim(),P=A.length>0&&!Fm.test(A);return r.jsxs("div",{className:"space-y-1",children:[r.jsx(et,{...C,value:C.value??"",placeholder:"github.com",spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:ie("font-mono",P&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":P,"aria-label":`Submodule credential ${s+1} host`,onBlur:V=>{C.onChange(V.target.value.trim()),C.onBlur()}}),P?r.jsx("p",{className:"text-[11px] text-destructive",children:"Bare hostname, e.g. github.com (no scheme or path)."}):null]})},e[0]=s,e[1]=u):u=e[1];let f;e[2]!==n||e[3]!==d||e[4]!==u?(f=r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx(ss,{control:n,name:d,render:u})}),e[2]=n,e[3]=d,e[4]=u,e[5]=f):f=e[5];let m;e[6]!==a||e[7]!==o?(m=k=>{const{field:C}=k;return r.jsxs(Ft,{value:C.value||"",onValueChange:A=>C.onChange(A),children:[r.jsx($t,{className:ie("h-9 w-full",!C.value&&"text-muted-foreground"),children:r.jsx(qt,{placeholder:"Pick a secret…",children:r.jsx(C3,{field:C,secretById:a})})}),r.jsx(Bt,{children:o.length===0?r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No secrets yet. Use the “+” to create one."}):o.map(CC)})]})},e[6]=a,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==n||e[10]!==h||e[11]!==m?(p=r.jsx(ss,{control:n,name:h,render:m}),e[9]=n,e[10]=h,e[11]=m,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(_t,{className:"size-3.5"}),e[13]=g):g=e[13];let x;e[14]!==l?(x=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":"Create new secret",onClick:l,children:g})}),e[14]=l,e[15]=x):x=e[15];let v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(He,{children:"Create new secret"}),e[16]=v):v=e[16];let b;e[17]!==x?(b=r.jsxs(We,{children:[x,v]}),e[17]=x,e[18]=b):b=e[18];let _;e[19]!==p||e[20]!==b?(_=r.jsxs("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:[p,b]}),e[19]=p,e[20]=b,e[21]=_):_=e[21];let y;e[22]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(_s,{className:"size-3.5"}),e[22]=y):y=e[22];let L;e[23]!==c?(L=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove submodule credential",onClick:c,children:y})}),e[23]=c,e[24]=L):L=e[24];let w;e[25]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(He,{children:"Remove"}),e[25]=w):w=e[25];let j;e[26]!==L?(j=r.jsx("div",{className:"flex shrink-0 items-center gap-1",children:r.jsxs(We,{children:[L,w]})}),e[26]=L,e[27]=j):j=e[27];let S;return e[28]!==j||e[29]!==f||e[30]!==_?(S=r.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[f,_,j]}),e[28]=j,e[29]=f,e[30]=_,e[31]=S):S=e[31],S}function CC(t){return r.jsx(ut,{value:t.id,children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx(Q9,{scope:t.scope}),r.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function kC({onClose:t,onSaved:e}){const[s,n]=N.useState(""),[i,o]=N.useState("organization"),[a,l]=N.useState(""),[c,d]=N.useState(""),h=G2(),u=s.trim(),f=a.length>0&&u.length>0&&j3.test(u),m=async p=>{if(p.preventDefault(),!!f)try{const g=await h.mutateAsync({scope:i,name:u,value:a,description:c.trim()||void 0});ve.success(`Saved secret "${g.name}"`),e(g.id)}catch(g){ve.error(g instanceof Error?g.message:"Failed to save")}};return r.jsx(Jt,{open:!0,onOpenChange:p=>{p||t()},children:r.jsxs(Yt,{className:"sm:max-w-md",children:[r.jsxs(cs,{children:[r.jsx(ds,{children:"Create new secret"}),r.jsx(On,{children:"Stored encrypted in the credential vault. The submodule credential will reference the new secret by id — its value never leaves the server."})]}),r.jsxs("form",{onSubmit:m,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:"submodule-secret-scope",children:"Scope"}),r.jsxs(Ft,{value:i,onValueChange:p=>o(p),children:[r.jsx($t,{id:"submodule-secret-scope",children:r.jsx(qt,{})}),r.jsxs(Bt,{children:[r.jsx(ut,{value:"organization",children:"Organization — visible to all members"}),r.jsx(ut,{value:"user",children:"Private — only visible to me"})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:"submodule-secret-name",children:"Name"}),r.jsx(et,{id:"submodule-secret-name",value:s,onChange:p=>n(p.target.value),placeholder:"GITHUB_SUBMODULE_PAT",autoComplete:"off",required:!0}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters, digits, underscore, dot, hyphen."})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:"submodule-secret-value",children:"Personal access token"}),r.jsx(et,{id:"submodule-secret-value",type:"password",value:a,onChange:p=>l(p.target.value),placeholder:"ghp_…",autoComplete:"new-password",required:!0})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:"submodule-secret-description",children:"Description (optional)"}),r.jsx(Ri,{id:"submodule-secret-description",value:c,onChange:p=>d(p.target.value),rows:2,placeholder:"What is this token used for?"})]}),r.jsxs(mi,{children:[r.jsx(le,{type:"button",variant:"outline",onClick:t,disabled:h.isPending,children:"Cancel"}),r.jsx(le,{type:"submit",disabled:!f||h.isPending,children:h.isPending?"Saving…":"Save secret"})]})]})]})})}function VC(t){const e=F.c(21),{repo:s,className:n}=t,i=oe();let o;e[0]!==n?(o=ie("space-y-2",n),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==i?(a=i("sandbox.repoRow.label"),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==a?(l=r.jsx(st,{children:a}),e[4]=a,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Uo,{size:20,className:"shrink-0 text-foreground/60"}),e[6]=c):c=e[6];let d;e[7]!==s||e[8]!==i?(d=r.jsx(Ue,{asChild:!0,children:r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-4 py-3",tabIndex:0,children:[c,r.jsx("div",{className:"min-w-0 flex-1",children:s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"truncate text-sm font-medium",children:[s.owner,"/",s.name]}),r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.url})]}):r.jsx("div",{className:"text-sm text-muted-foreground",children:i("sandbox.repoRow.noRepositoryConnected")})})]})}),e[7]=s,e[8]=i,e[9]=d):d=e[9];let h;e[10]!==i?(h=i("sandbox.repoRow.tooltipContent"),e[10]=i,e[11]=h):h=e[11];let u;e[12]!==h?(u=r.jsx(He,{children:h}),e[12]=h,e[13]=u):u=e[13];let f;e[14]!==d||e[15]!==u?(f=r.jsxs(We,{children:[d,u]}),e[14]=d,e[15]=u,e[16]=f):f=e[16];let m;return e[17]!==o||e[18]!==l||e[19]!==f?(m=r.jsxs("div",{className:o,children:[l,f]}),e[17]=o,e[18]=l,e[19]=f,e[20]=m):m=e[20],m}const NC={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}};function TC(t){const e=t.trim();if(e==="")return{ok:!0,value:null};if(!/^\d+$/.test(e))return{ok:!1};const s=Number(e);return s<1||s>65535?{ok:!1}:{ok:!0,value:String(s)}}const AC=Object.keys(NC),ed="__none__";function EC(t){const e=F.c(47),{control:s}=t,n=oe(),i=N.useRef(null);let o;e[0]!==n?(o=n("sandbox.runtimeFields.packageManager"),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==o?(a=r.jsx(st,{htmlFor:"runtime-pm",children:o}),e[2]=o,e[3]=a):a=e[3];let l;e[4]!==n?(l=S=>{const{field:k}=S;return r.jsxs(Ft,{value:k.value??ed,onValueChange:C=>k.onChange(C===ed?null:C),children:[r.jsx($t,{id:"runtime-pm",children:r.jsx(qt,{placeholder:n("sandbox.runtimeFields.autoDetect")})}),r.jsxs(Bt,{children:[r.jsx(ut,{value:ed,children:n("sandbox.runtimeFields.autoDetect")}),AC.map(RC)]})]})},e[4]=n,e[5]=l):l=e[5];let c;e[6]!==s||e[7]!==l?(c=r.jsx(ss,{control:s,name:"metadata.runtime.selected",render:l}),e[6]=s,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==a||e[10]!==c?(d=r.jsxs("div",{className:"space-y-2",children:[a,c]}),e[9]=a,e[10]=c,e[11]=d):d=e[11];let h;e[12]!==n?(h=n("sandbox.runtimeFields.packagePath"),e[12]=n,e[13]=h):h=e[13];let u;e[14]!==h?(u=r.jsx(st,{htmlFor:"runtime-path",children:h}),e[14]=h,e[15]=u):u=e[15];let f;e[16]!==s?(f=r.jsx(ss,{control:s,name:"metadata.runtime.path",render:PC}),e[16]=s,e[17]=f):f=e[17];let m;e[18]!==n?(m=n("sandbox.runtimeFields.packagePathDescription"),e[18]=n,e[19]=m):m=e[19];let p;e[20]!==m?(p=r.jsx("p",{className:"text-xs text-muted-foreground",children:m}),e[20]=m,e[21]=p):p=e[21];let g;e[22]!==p||e[23]!==u||e[24]!==f?(g=r.jsxs("div",{className:"space-y-2",children:[u,f,p]}),e[22]=p,e[23]=u,e[24]=f,e[25]=g):g=e[25];let x;e[26]!==n?(x=n("sandbox.runtimeFields.devServerPort"),e[26]=n,e[27]=x):x=e[27];let v;e[28]!==x?(v=r.jsx(st,{htmlFor:"runtime-port",children:x}),e[28]=x,e[29]=v):v=e[29];let b;e[30]!==n?(b=S=>{const{field:k}=S;return r.jsx(et,{ref:i,id:"runtime-port",inputMode:"numeric",placeholder:n("sandbox.runtimeFields.auto"),defaultValue:k.value??"",onBlur:C=>{const A=TC(C.target.value);A.ok?k.onChange(A.value):i.current&&(i.current.value=k.value??"")}})},e[30]=n,e[31]=b):b=e[31];let _;e[32]!==s||e[33]!==b?(_=r.jsx(ss,{control:s,name:"metadata.runtime.port",render:b}),e[32]=s,e[33]=b,e[34]=_):_=e[34];let y;e[35]!==n?(y=n("sandbox.runtimeFields.devServerPortDescription"),e[35]=n,e[36]=y):y=e[36];let L;e[37]!==y?(L=r.jsx("p",{className:"text-xs text-muted-foreground",children:y}),e[37]=y,e[38]=L):L=e[38];let w;e[39]!==v||e[40]!==_||e[41]!==L?(w=r.jsxs("div",{className:"space-y-2",children:[v,_,L]}),e[39]=v,e[40]=_,e[41]=L,e[42]=w):w=e[42];let j;return e[43]!==g||e[44]!==w||e[45]!==d?(j=r.jsxs("div",{className:"space-y-5",children:[d,g,w]}),e[43]=g,e[44]=w,e[45]=d,e[46]=j):j=e[46],j}function PC(t){const{field:e}=t;return r.jsx(et,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const n=s.target.value.trim();e.onChange(n===""?null:n)}})}function RC(t){return r.jsx(ut,{value:t,children:t},t)}function DC(t){const e=F.c(17),{control:s}=t,n=oe();let i;e[0]!==n?(i=n("sandbox.productionUrlField.label"),e[0]=n,e[1]=i):i=e[1];let o;e[2]!==i?(o=r.jsx(st,{htmlFor:"production-url",children:i}),e[2]=i,e[3]=o):o=e[3];let a;e[4]!==n?(a=u=>{const{field:f}=u,m=f.value??"";return r.jsx(et,{id:"production-url",type:"url",inputMode:"url",placeholder:n("sandbox.productionUrlField.placeholder"),value:m,onChange:p=>f.onChange(p.target.value===""?null:p.target.value),onBlur:()=>{f.onChange(c8(m)),f.onBlur()}})},e[4]=n,e[5]=a):a=e[5];let l;e[6]!==s||e[7]!==a?(l=r.jsx(ss,{control:s,name:"metadata.productionUrl",render:a}),e[6]=s,e[7]=a,e[8]=l):l=e[8];let c;e[9]!==n?(c=n("sandbox.productionUrlField.description"),e[9]=n,e[10]=c):c=e[10];let d;e[11]!==c?(d=r.jsx("p",{className:"text-xs text-muted-foreground",children:c}),e[11]=c,e[12]=d):d=e[12];let h;return e[13]!==o||e[14]!==l||e[15]!==d?(h=r.jsxs("div",{className:"space-y-2",children:[o,l,d]}),e[13]=o,e[14]=l,e[15]=d,e[16]=h):h=e[16],h}function IC(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function MC(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},n=new Set(s.fields);for(const i of e.fields)n.add(i);return{...s,fields:n,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function OC(t){const e=t.metadata?.runtime?.env;if(!e||e.length===0)return t;const s=e.filter(n=>{if(!n||typeof n!="object")return!1;const i=(n.key??"").trim();return!i||!Jl.test(i)?!1:n.kind==="literal"?!0:n.kind==="secret"?!!n.secretId:!1});return s.length===e.length?t:{...t,metadata:{...t.metadata,runtime:{...t.metadata?.runtime??{},env:s}}}}function $C(t){const e=t.metadata?.runtime?.submoduleCredentials;if(!e||e.length===0)return t;const s=e.filter(n=>{if(!n||typeof n!="object")return!1;const i=(n.host??"").trim();return!i||!Fm.test(i)?!1:!!n.secretId});return s.length===e.length?t:{...t,metadata:{...t.metadata,runtime:{...t.metadata?.runtime??{},submoduleCredentials:s}}}}async function BC(t,e){const s=t?.idToken??null;if(s){const i=Qh(s);if(i)return i}const n=t?.userinfoEndpoint??null;if(n)try{const i=await fetch(n,{headers:{Authorization:`Bearer ${e}`}});if(i.ok){const o=await i.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return Qh(e)}function Qh(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function FC({virtualMcp:t,hideOwnTitle:e}){const s=oe(),[n]=di(),i=n.language==="pt-BR"?h8:void 0,{org:o}=ze(),a=g9(),{data:l}=bb([t.id]),c=l?.get(t.id)?.last_used_at,d=M2(),h=Ls(),u=Fs(),f=Y0({resolver:Cm(qj),defaultValues:t}),m=f.watch("connections"),p=S2(t),g=aa(t),x=g?{owner:g.owner,name:g.name,url:g.url}:null,[v,b]=N.useReducer(IC,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[_,y]=N.useState(!1),[L,w]=N.useState(!1),{createNewTask:j,openSidePanel:S}=ia(),{sendMessage:k}=Js(),C=async()=>{if(L)return;const W=f.getValues("metadata.instructions");if(W?.trim()){w(!0);try{E(),Fe("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:W.length}),S("chat"),await k({tiptapDoc:y3({managerAgentId:Ym.AGENT_MANAGER(o.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:W})})}finally{w(!1)}}},A=()=>{E(),Fe("agent_test_clicked",{agent_id:t.id}),j()},[P,V]=N.useReducer(MC,null),T=()=>{P!==null&&(Fe("agent_updated",{agent_id:t.id,fields:Array.from(P.fields),instructions_length:P.instructionsLength,save_count:P.saveCount,edit_duration_ms:Date.now()-P.start}),V({type:"reset"}))},{schedule:R,flush:E}=wl({delayMs:3e4,save:async()=>T()}),I=async()=>{const W=Object.keys(f.control._formState.dirtyFields);if(W.length===0)return;const Z=W.includes("metadata"),G=f.getValues();f.reset(G,{keepValues:!0});const te=$C(OC(G));await a.update.mutateAsync({id:t.id,data:te}),V({type:"accumulate",now:Date.now(),fields:W,instructionsLength:Z?G.metadata?.instructions?.length??0:null}),R()},{schedule:D,flush:M}=wl({save:I});N.useEffect(()=>{const W=f.watch(()=>D());return()=>W.unsubscribe()},[]);const O=()=>{Fe("connections_dialog_opened",{source:"agent_settings",mode:"add"}),b({type:"SET_ADD_DIALOG_OPEN",payload:!0})},$=async W=>{const Z=f.getValues("connections");if(Z.some(se=>se.connection_id===W))return;f.setValue("connections",[...Z,{connection_id:W,selected_tools:Zc.tools,selected_resources:Zc.resources,selected_prompts:Zc.prompts}],{shouldDirty:!0}),b({type:"SET_ADD_DIALOG_OPEN",payload:!1});const G=new URL(`/api/${o.slug}/mcp/${W}`,window.location.origin),te=await ah({url:G.href,token:null,orgId:o.id});te.supportsOAuth&&!te.isAuthenticated&&await Q(W)},B=W=>{const G=f.getValues("connections").filter(te=>te.connection_id!==W);f.setValue("connections",G,{shouldDirty:!0})},z=(W,Z)=>{const G=f.getValues("connections");if(G.some(te=>te.connection_id===Z)){ve.error(s("virtualMcp.virtualMcp.instanceAlreadyAdded"));return}f.setValue("connections",G.map(te=>te.connection_id===W?{...te,connection_id:Z}:te),{shouldDirty:!0})},K=async W=>{if(f.getValues("connections").find(G=>G.connection_id===W))try{const{item:G}=await u.call("COLLECTION_CONNECTIONS_GET",{id:W});if(!G)return;const te=G.title.replace(/\s*\(.*?\)\s*$/,""),se=m8("conn"),re=`${te} (${Date.now().toString(36).slice(-4)})`;await d.create.mutateAsync({id:se,title:re,description:G.description??null,connection_type:G.connection_type,connection_url:G.connection_url??null,connection_token:null,icon:G.icon??null,app_name:G.app_name??null,app_id:G.app_id??null,connection_headers:G.connection_headers??null});const de=new URL(`/api/${o.slug}/mcp/${se}`,window.location.origin),ce=await ah({url:de.href,token:null,orgId:o.id});if(ce.supportsOAuth&&!ce.isAuthenticated){const fe=await Q(se);if(!fe){await d.delete.mutateAsync(se);return}await d.update.mutateAsync({id:se,data:{title:`${te} (${fe})`}})}z(W,se),ve.success(s("virtualMcp.virtualMcp.newInstanceCreated"))}catch(G){console.error("Failed to create instance:",G),ve.error(s("virtualMcp.virtualMcp.failedToCreateInstance"))}},Y=W=>{b({type:"OPEN_SETTINGS",payload:W})},Q=async W=>{const{token:Z,tokenInfo:G,error:te}=await p8({connectionId:W,orgSlug:o.slug,scope:"offline_access"});if(te||!Z)return ve.error(s("virtualMcp.virtualMcp.authenticationFailed",{error:te??""})),null;if(G)try{const re=await fetch(`/api/${o.slug}/connections/${W}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:G.accessToken,refreshToken:G.refreshToken,expiresIn:G.expiresIn,scope:G.scope,clientId:G.clientId,clientSecret:G.clientSecret,tokenEndpoint:G.tokenEndpoint})});if(!re.ok)console.error("Failed to save OAuth token:",await re.text()),await d.update.mutateAsync({id:W,data:{connection_token:Z}});else try{await d.update.mutateAsync({id:W,data:{}})}catch(de){console.warn("Failed to refresh connection tools after OAuth:",de)}}catch(re){console.error("Error saving OAuth token:",re),await d.update.mutateAsync({id:W,data:{connection_token:Z}})}else await d.update.mutateAsync({id:W,data:{connection_token:Z}});const se=new URL(`/api/${o.slug}/mcp/${W}`,window.location.origin);return await h.invalidateQueries({queryKey:Qe.isMCPAuthenticated(se.href,null)}),ve.success(s("virtualMcp.virtualMcp.authenticationSuccessful")),BC(G,Z)},q=()=>{const W=f.getValues("metadata.instructions")??"",Z=s("virtualMcp.virtualMcp.promptTemplateContent"),G=W.trim()?`${W}
11
-
12
- ${Z}`:Z;f.setValue("metadata.instructions",G,{shouldDirty:!0})},H=new Set(m.map(W=>W.connection_id)),U=jt(),[X,J]=N.useState(!1),ee=async()=>{E();try{await a.delete.mutateAsync(t.id),Fe("agent_deleted",{agent_id:t.id,source:"agent_detail"}),ve.success(s("virtualMcp.virtualMcp.agentDeleted",{title:t.title})),U({to:"/$org",params:{org:o.slug}})}catch{}};return r.jsxs(tn,{children:[r.jsx(tn.Content,{children:r.jsx(tn.Body,{children:r.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&r.jsx(tn.Title,{actions:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(le,{variant:"outline",size:"sm",onClick:A,children:[r.jsx(Di,{size:14,className:"size-[14px]!"}),s("virtualMcp.virtualMcp.testAgent")]}),r.jsx(le,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>J(!0),children:r.jsx(_s,{size:14})})]}),children:s("virtualMcp.virtualMcp.settings")}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ss,{name:"icon",control:f.control,render:({field:W})=>r.jsx(oj,{value:W.value??null,onChange:Z=>{W.onChange(Z),M()},onColorChange:Z=>{f.setValue("metadata.ui.themeColor",Z,{shouldDirty:!0}),M()},name:f.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2"})}),r.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[r.jsx(ss,{name:"title",control:f.control,render:({field:W})=>r.jsx("input",{...W,type:"text",value:W.value??"",onChange:Z=>{W.onChange(Z)},onBlur:()=>{W.onBlur(),M()},disabled:p,placeholder:s("virtualMcp.virtualMcp.agentNamePlaceholder"),className:"text-lg font-medium leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})}),r.jsx(ss,{name:"description",control:f.control,render:({field:W})=>r.jsx("input",{...W,type:"text",value:W.value??"",onChange:Z=>{W.onChange(Z)},onBlur:()=>{W.onBlur(),M()},disabled:p,placeholder:s("virtualMcp.virtualMcp.descriptionPlaceholder"),className:"text-sm text-muted-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})})]}),r.jsxs(le,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{Fe("agent_connect_modal_opened",{agent_id:t.id}),b({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[r.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[r.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:r.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),r.jsx("span",{className:"relative z-10 inline-flex items-center justify-center size-4 rounded-full ring-1 ring-background shrink-0",style:{backgroundColor:"#D97757"},children:r.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),s("virtualMcp.virtualMcp.connect")]})]}),r.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-sm text-muted-foreground",children:[r.jsx(_3,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsxs("span",{children:[s("virtualMcp.virtualMcp.created")," ",new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{children:c?s("virtualMcp.virtualMcp.lastUsed",{time:f8(new Date(c),{addSuffix:!0,locale:i})}):s("virtualMcp.virtualMcp.neverUsed")})]}),r.jsxs("section",{className:"flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.connections")}),m.length>0&&r.jsxs(le,{variant:"outline",size:"sm",onClick:O,children:[r.jsx(_t,{size:14}),s("virtualMcp.virtualMcp.addConnection")]})]}),r.jsx("div",{className:"flex flex-col gap-2",children:m.length===0?r.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[r.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:r.jsx(_t,{size:16})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:s("virtualMcp.virtualMcp.noConnectionsYet")})]}):m.map(W=>r.jsx(hs,{fallback:()=>null,children:r.jsx(N.Suspense,{fallback:r.jsx(S3,{}),children:r.jsx($j,{connection_id:W.connection_id,usedConnectionIds:H,onOpenSettings:()=>Y(W.connection_id),onRemove:()=>B(W.connection_id),onAuthenticate:Q,onSwitchInstance:z,onNewInstance:()=>K(W.connection_id)})})},W.connection_id))})]}),r.jsxs("section",{className:"flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.instructions")}),r.jsxs("div",{className:"flex items-center gap-2",children:[!f.watch("metadata.instructions")?.trim()&&r.jsx(le,{variant:"outline",size:"sm",onClick:q,children:s("virtualMcp.virtualMcp.promptTemplate")}),r.jsxs(le,{variant:"outline",size:"sm",disabled:L||!f.watch("metadata.instructions")?.trim(),onClick:C,children:[r.jsx(ei,{size:13}),s("virtualMcp.virtualMcp.improve")]})]})]}),r.jsx(ss,{name:"metadata.instructions",control:f.control,render:({field:W})=>r.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[r.jsx(Ri,{...W,value:W.value??"",onChange:Z=>{W.onChange(Z)},onBlur:()=>{W.onBlur(),M()},placeholder:s("virtualMcp.virtualMcp.instructionsPlaceholder"),className:"min-h-[200px] max-h-[360px] overflow-auto resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed border-0 shadow-none px-4 py-3 pr-11 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent",style:{boxShadow:"none"}}),r.jsxs(We,{delayDuration:0,children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>y(!0),"aria-label":s("virtualMcp.virtualMcp.openFullscreenEditor"),children:r.jsx(m2,{size:14})})}),r.jsx(He,{side:"left",children:s("virtualMcp.virtualMcp.fullscreen")})]})]})})]}),r.jsx(fj,{form:f}),r.jsx(hs,{fallback:()=>null,children:r.jsx(N.Suspense,{fallback:r.jsxs("section",{className:"flex flex-col gap-3",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.subAgents")}),r.jsx("div",{className:"h-16 rounded-lg border border-dashed border-border animate-pulse"})]}),children:r.jsx(yj,{form:f,currentAgentId:t.id})})}),r.jsx(Wj,{virtualMcpId:t.id,form:f,flushAndSave:M}),r.jsx(oC,{virtualMcp:t}),p&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.publishing")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:s("virtualMcp.virtualMcp.publishingDescription")})]}),r.jsx(Sl,{className:"p-6",children:r.jsx(zo,{className:"p-0",children:r.jsx(ss,{name:"metadata.publishPolicy",control:f.control,render:({field:W})=>r.jsx(ij,{value:W.value??"smart",onValueChange:Z=>{W.onChange(Z),M()},className:"gap-4",children:[{value:"smart",label:s("virtualMcp.virtualMcp.publishPolicySmart"),description:s("virtualMcp.virtualMcp.publishPolicySmartDescription")},{value:"code-review",label:s("virtualMcp.virtualMcp.publishPolicyCodeReview"),description:s("virtualMcp.virtualMcp.publishPolicyCodeReviewDescription")},{value:"open",label:s("virtualMcp.virtualMcp.publishPolicyOpen"),description:s("virtualMcp.virtualMcp.publishPolicyOpenDescription")}].map(Z=>r.jsxs("label",{htmlFor:`publish-policy-${Z.value}`,className:"flex cursor-pointer items-start gap-3",children:[r.jsx(rj,{id:`publish-policy-${Z.value}`,value:Z.value,className:"mt-0.5"}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-sm font-medium text-foreground",children:Z.label}),r.jsx("span",{className:"text-sm text-muted-foreground",children:Z.description})]})]},Z.value))})})})})]}),r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-3",children:r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.sandbox")})}),r.jsx(Sl,{className:"p-6 gap-5",children:r.jsxs(zo,{className:"p-0 space-y-5",children:[r.jsx(VC,{repo:x}),r.jsx(DC,{control:f.control}),r.jsx(EC,{control:f.control}),r.jsx(hC,{control:f.control,form:f,virtualMcpId:t.id,orgSlug:o.slug}),r.jsx(LC,{control:f.control,form:f})]})})]}),r.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium",children:s("virtualMcp.virtualMcp.deleteAgent")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:s("virtualMcp.virtualMcp.deleteAgentDescription")})]}),r.jsxs(le,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>J(!0),children:[r.jsx(_s,{size:14}),s("virtualMcp.virtualMcp.deleteAgent")]})]})]})})}),r.jsx(pl,{open:X,onOpenChange:J,children:r.jsxs(gl,{children:[r.jsxs(xl,{children:[r.jsx(vl,{children:s("virtualMcp.virtualMcp.deleteAgentConfirm")}),r.jsx(bl,{children:s("virtualMcp.virtualMcp.deleteAgentConfirmDescription",{title:t.title})})]}),r.jsxs(yl,{children:[r.jsx(_l,{children:s("virtualMcp.virtualMcp.cancel")}),r.jsx(Ll,{onClick:ee,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:s("virtualMcp.virtualMcp.delete")})]})]})}),r.jsx(p9,{open:v.addDialogOpen,onOpenChange:W=>b({type:"SET_ADD_DIALOG_OPEN",payload:W}),agentId:t.id,addedConnectionIds:H,onAdd:$}),r.jsx(Oj,{open:v.settingsDialogOpen,onOpenChange:W=>{W||b({type:"CLOSE_SETTINGS"})},selectedId:v.settingsConnectionId,form:f,connections:m,onAuthenticate:Q}),r.jsx(rC,{open:v.shareDialogOpen,onOpenChange:W=>b({type:"SET_SHARE_DIALOG_OPEN",payload:W}),virtualMcp:t}),r.jsx(Jt,{open:_,onOpenChange:y,children:r.jsxs(Yt,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[r.jsx(cs,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:r.jsx(ds,{children:s("virtualMcp.virtualMcp.instructions")})}),r.jsx("div",{className:"flex-1 min-h-0 p-6",children:r.jsx(ss,{name:"metadata.instructions",control:f.control,render:({field:W})=>r.jsx(Ri,{...W,value:W.value??"",onChange:Z=>{W.onChange(Z)},onBlur:()=>{W.onBlur(),M()},disabled:p,placeholder:s("virtualMcp.virtualMcp.instructionsPlaceholder"),className:"w-full h-full resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed rounded-xl card-shadow px-4 py-3 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 bg-card border-0",style:{boxShadow:"none"}})})})]})})]})}function zC(t){const e=F.c(22),{virtualMcpId:s,hideOwnTitle:n}=t,i=oe(),o=jt(),{org:a}=ze(),l=ms(s);if(!l){let h;e[0]!==i?(h=i("virtualMcp.virtualMcp.spaceNotFound"),e[0]=i,e[1]=h):h=e[1];let u;e[2]!==i?(u=i("virtualMcp.virtualMcp.spaceNotFoundDescription"),e[2]=i,e[3]=u):u=e[3];let f;e[4]!==o||e[5]!==a.slug?(f=()=>o({to:"/$org",params:{org:a.slug}}),e[4]=o,e[5]=a.slug,e[6]=f):f=e[6];let m;e[7]!==i?(m=i("virtualMcp.virtualMcp.backToSpaces"),e[7]=i,e[8]=m):m=e[8];let p;e[9]!==f||e[10]!==m?(p=r.jsx(le,{variant:"outline",onClick:f,children:m}),e[9]=f,e[10]=m,e[11]=p):p=e[11];let g;return e[12]!==h||e[13]!==u||e[14]!==p?(g=r.jsx("div",{className:"flex h-full w-full bg-background",children:r.jsx(Ei,{title:h,description:u,actions:p})}),e[12]=h,e[13]=u,e[14]=p,e[15]=g):g=e[15],g}let c;e[16]!==l?(c=aa(l)?.connectionId??"",e[16]=l,e[17]=c):c=e[17];let d;return e[18]!==n||e[19]!==c||e[20]!==l?(d=r.jsx(FC,{virtualMcp:l,hideOwnTitle:n},c),e[18]=n,e[19]=c,e[20]=l,e[21]=d):d=e[21],d}function Zh(t){const e=F.c(2),{virtualMcpId:s}=t;let n;return e[0]!==s?(n=r.jsx(zC,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=n):n=e[1],n}const Sr=1,N3=`home-board.layout.v${Sr}`;function T3(t){return`home-board.layout.v${Sr}.${t}`}const A3={version:Sr,tiles:{},hidden:[],shown:[]};function Yd(t){return!t||t.version!==Sr?A3:{version:Sr,tiles:t.tiles??{},hidden:Array.isArray(t.hidden)?t.hidden:[],shown:Array.isArray(t.shown)?t.shown:[]}}function KC(t){return Object.keys(t.tiles).length>0||t.hidden.length>0||(t.shown?.length??0)>0}function UC(t){try{const e=localStorage.getItem(T3(t));return e?Yd(JSON.parse(e)):void 0}catch{return}}function ef(t,e){try{localStorage.setItem(T3(t),JSON.stringify(e))}catch{}}async function tf(t,e){if(!(await fetch(`/api/${t}/kv/${N3}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok)throw new Error("Failed to save board layout")}function HC(t){const e=F.c(24),s=Ls();let n;e[0]!==t?(n=Qe.boardLayout(t),e[0]=t,e[1]=n):n=e[1];const i=n;let o;e[2]!==t?(o=UC(t),e[2]=t,e[3]=o):o=e[3];const a=o;let l;e[4]!==a||e[5]!==t?(l=async()=>{const v=await fetch(`/api/${t}/kv/${N3}`);if(v.status===404)return a&&KC(a)?(await tf(t,a),a):A3;if(!v.ok)throw new Error("Failed to load board layout");const b=await v.json(),_=Yd(b.value);return ef(t,_),_},e[4]=a,e[5]=t,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==i||e[9]!==l?(c={queryKey:i,queryFn:l,initialData:a,staleTime:0,refetchOnWindowFocus:!1},e[7]=a,e[8]=i,e[9]=l,e[10]=c):c=e[10];const{data:d,isLoading:h}=Pt(c);let u;e[11]!==t?(u={mutationFn:v=>tf(t,v)},e[11]=t,e[12]=u):u=e[12];const f=Ys(u);let m;e[13]!==f||e[14]!==t||e[15]!==s||e[16]!==i?(m=v=>{ef(t,v),s.setQueryData(i,v),f.mutate(v)},e[13]=f,e[14]=t,e[15]=s,e[16]=i,e[17]=m):m=e[17];const p=m;let g;e[18]!==d?(g=Yd(d),e[18]=d,e[19]=g):g=e[19];let x;return e[20]!==h||e[21]!==p||e[22]!==g?(x={layout:g,isLoading:h,save:p},e[20]=h,e[21]=p,e[22]=g,e[23]=x):x=e[23],x}const E3=N.createContext(null);function WC(t){const e=F.c(24),{children:s}=t,{org:n}=ze(),i=HC(n.slug),[o,a]=N.useState(!1),[l,c]=N.useState(null);let d;e[0]!==i.layout?(d=()=>{c(i.layout),a(!0)},e[0]=i.layout,e[1]=d):d=e[1];const h=d;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{c(null),a(!1)},e[2]=u):u=e[2];const f=u;let m;e[3]!==l||e[4]!==i?(m=()=>{l&&i.save(l),c(null),a(!1)},e[3]=l,e[4]=i,e[5]=m):m=e[5];const p=m,g=o&&l!==null,x=g?l:i.layout;let v;e[6]!==l||e[7]!==g||e[8]!==i.layout?(v=g?JSON.stringify(l)!==JSON.stringify(i.layout):!1,e[6]=l,e[7]=g,e[8]=i.layout,e[9]=v):v=e[9];const b=v;let _;e[10]!==o||e[11]!==i?(_=j=>{o?c(j):i.save(j)},e[10]=o,e[11]=i,e[12]=_):_=e[12];const y=_;let L;e[13]!==y||e[14]!==h||e[15]!==b||e[16]!==o||e[17]!==x||e[18]!==p||e[19]!==i.isLoading?(L={isEditMode:o,enter:h,cancel:f,save:p,hasChanges:b,layout:x,isLayoutLoading:i.isLoading,commitLayout:y},e[13]=y,e[14]=h,e[15]=b,e[16]=o,e[17]=x,e[18]=p,e[19]=i.isLoading,e[20]=L):L=e[20];let w;return e[21]!==s||e[22]!==L?(w=r.jsx(E3.Provider,{value:L,children:s}),e[21]=s,e[22]=L,e[23]=w):w=e[23],w}function Z9(){const t=N.useContext(E3);if(!t)throw new Error("useHomeEdit must be used within a HomeEditProvider");return t}function qC(t){const e=F.c(30),{generating:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ie("pointer-events-none absolute -bottom-14 left-6 hidden h-48 w-36 -rotate-6 rounded-xl border border-border bg-background shadow-lg sm:block","transition-transform duration-500 ease-out group-hover:-translate-y-2 group-hover:-rotate-3"),e[0]=n):n=e[0];let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"16",cy:"16",r:"12",fill:"none",strokeWidth:"4",className:"stroke-muted"}),e[1]=i):i=e[1];const o=s?"75.4":"22",a=s?"stroke-muted":"stroke-success";let l;e[2]!==a?(l=ie("transition-[stroke-dashoffset] duration-1000 ease-out",a),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o||e[5]!==l?(c=r.jsxs("svg",{viewBox:"0 0 32 32",className:"size-9 shrink-0 -rotate-90",children:[i,r.jsx("circle",{cx:"16",cy:"16",r:"12",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:"75.4",strokeDashoffset:o,className:l})]}),e[4]=o,e[5]=l,e[6]=c):c=e[6];const d=s&&"animate-pulse";let h;e[7]!==d?(h=ie("h-1.5 w-full rounded-full bg-muted",d),e[7]=d,e[8]=h):h=e[8];let u;e[9]!==h?(u=r.jsx("div",{className:h}),e[9]=h,e[10]=u):u=e[10];const f=s&&"animate-pulse";let m;e[11]!==f?(m=ie("h-1.5 w-2/3 rounded-full bg-muted",f),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==m?(p=r.jsx("div",{className:m}),e[13]=m,e[14]=p):p=e[14];let g;e[15]!==p||e[16]!==u?(g=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[u,p]}),e[15]=p,e[16]=u,e[17]=g):g=e[17];let x;e[18]!==g||e[19]!==c?(x=r.jsxs("div",{className:"flex items-center gap-2.5",children:[c,g]}),e[18]=g,e[19]=c,e[20]=x):x=e[20];let v;e[21]===Symbol.for("react.memo_cache_sentinel")?(v=[7,10,5,9,6,8],e[21]=v):v=e[21];let b;e[22]!==s?(b=r.jsx("div",{className:"flex h-10 items-end gap-1.5",children:v.map((L,w)=>r.jsx("div",{style:{height:`${L*4}px`},className:ie("flex-1 rounded-sm",s?"animate-pulse bg-muted":w%2===0?"bg-success/70":"bg-success/30")},`bar-${w}`))}),e[22]=s,e[23]=b):b=e[23];let _;e[24]!==s?(_=r.jsx("div",{className:"flex flex-col gap-1.5",children:["w-full","w-5/6","w-full","w-2/3","w-full"].map((L,w)=>r.jsx("div",{className:ie("h-1.5 rounded-full bg-muted",L,s&&"animate-pulse")},`line-${w}`))}),e[24]=s,e[25]=_):_=e[25];let y;return e[26]!==x||e[27]!==b||e[28]!==_?(y=r.jsx("div",{"aria-hidden":!0,className:n,children:r.jsxs("div",{className:"flex h-full flex-col gap-3 p-4",children:[x,b,_]})}),e[26]=x,e[27]=b,e[28]=_,e[29]=y):y=e[29],y}function GC(t){const e=F.c(47),{status:s,host:n,onOpen:i}=t,o=oe(),a=s==="generating";let l,c,d,h,u,f,m,p,g,x;if(e[0]!==a||e[1]!==n||e[2]!==i||e[3]!==o){const j=n??o("reports.commerceBanner.storeDefault");m="button",p=i,e[14]===Symbol.for("react.memo_cache_sentinel")?(g=ie("group relative block w-full cursor-pointer overflow-hidden rounded-3xl border border-border bg-card card-shadow text-left","transition-colors duration-300 hover:bg-accent/30","animate-in fade-in slide-in-from-bottom-2 duration-500"),e[14]=g):g=e[14];const S=a?"bg-warning/15":"bg-success/15";let k;e[15]!==S?(k=ie("absolute -bottom-24 -left-10 size-64 rounded-full blur-3xl transition-colors duration-700",S),e[15]=S,e[16]=k):k=e[16],e[17]!==k?(x=r.jsx("div",{"aria-hidden":!0,className:k}),e[17]=k,e[18]=x):x=e[18],e[19]!==a?(c=r.jsx(qC,{generating:a}),e[19]=a,e[20]=c):c=e[20],f="relative flex min-h-28 items-center gap-4 px-5 py-5 sm:h-36 sm:gap-6 sm:pr-6 sm:pl-52",h="flex min-w-0 flex-1 flex-col gap-1";let C;e[21]!==a||e[22]!==o?(C=o(a?"reports.commerceBanner.generatingTitle":"reports.commerceBanner.readyTitle"),e[21]=a,e[22]=o,e[23]=C):C=e[23],e[24]!==C?(u=r.jsx("span",{className:"text-base font-medium leading-6 text-foreground sm:text-lg",children:C}),e[24]=C,e[25]=u):u=e[25],l="truncate text-sm text-muted-foreground",d=a?o("reports.commerceBanner.generatingSubtitle",{store:j}):o("reports.commerceBanner.readySubtitle",{store:j}),e[0]=a,e[1]=n,e[2]=i,e[3]=o,e[4]=l,e[5]=c,e[6]=d,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x}else l=e[4],c=e[5],d=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13];let v;e[26]!==l||e[27]!==d?(v=r.jsx("span",{className:l,children:d}),e[26]=l,e[27]=d,e[28]=v):v=e[28];let b;e[29]!==v||e[30]!==h||e[31]!==u?(b=r.jsxs("div",{className:h,children:[u,v]}),e[29]=v,e[30]=h,e[31]=u,e[32]=b):b=e[32];let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=ie("flex size-11 shrink-0 items-center justify-center rounded-full border border-border bg-background","transition-transform duration-300 group-hover:translate-x-1"),e[33]=_):_=e[33];let y;e[34]!==a?(y=r.jsx("div",{className:_,children:a?r.jsxs("span",{className:"relative flex size-2.5",children:[r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-warning opacity-60"}),r.jsx("span",{className:"relative inline-flex size-2.5 rounded-full bg-warning"})]}):r.jsx(Ar,{size:18,className:"text-foreground","aria-hidden":!0})}),e[34]=a,e[35]=y):y=e[35];let L;e[36]!==b||e[37]!==y||e[38]!==f?(L=r.jsxs("div",{className:f,children:[b,y]}),e[36]=b,e[37]=y,e[38]=f,e[39]=L):L=e[39];let w;return e[40]!==c||e[41]!==L||e[42]!==m||e[43]!==p||e[44]!==g||e[45]!==x?(w=r.jsxs("button",{type:m,onClick:p,className:g,children:[x,c,L]}),e[40]=c,e[41]=L,e[42]=m,e[43]=p,e[44]=g,e[45]=x,e[46]=w):w=e[46],w}function YC(){const t=F.c(13),{org:e}=ze(),s=jt(),{diagnostic:n,isSuccess:i,host:o,connectionId:a}=u6();let l;t[0]!==n||t[1]!==i?(l=i?h6(n):"none",t[0]=n,t[1]=i,t[2]=l):l=t[2];const c=l;if(c==="none")return null;let d;t[3]!==a||t[4]!==o||t[5]!==s||t[6]!==e||t[7]!==c?(d=()=>{Fe("home_report_banner_clicked",{organization_id:e.id,status:c,domain:o??void 0}),s(f6(e,a))},t[3]=a,t[4]=o,t[5]=s,t[6]=e,t[7]=c,t[8]=d):d=t[8];const h=d;let u;return t[9]!==o||t[10]!==h||t[11]!==c?(u=r.jsx(GC,{status:c,host:o,onOpen:h}),t[9]=o,t[10]=h,t[11]=c,t[12]=u):u=t[12],u}function JC(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(hs,{fallback:null,children:r.jsx(YC,{})}),t[0]=e):e=t[0],e}function XC({agentId:t}){const e=oe(),{org:s,locator:n}=ze(),i=pt({connectionId:t,orgId:s.id,orgSlug:s.slug}),{create:o}=Ql(),{setTaskId:a}=ia(),[l,c]=N.useState(null),[d,h]=N.useState(!1),u=N.useRef(!1),f=async(v,b)=>{if(!i){ve.error(e("common.useStartThreadFromPrompt.mcpClientNotAvailable"));return}if(!u.current){u.current=!0,h(!0);try{const _=await na(i,v.name,b),y={type:"doc",content:[{type:"paragraph",content:[e9({id:v.name,name:Nr(v.name,gn(v._meta)),metadata:_.messages,char:"/",kind:"prompt",args:b}),{type:"text",text:" "}]}]},L=crypto.randomUUID();s2(sessionStorage,n,L,{tiptapDoc:y}),await o({id:L,virtual_mcp_id:t}),a(L,t,{autosend:!0})}catch(_){console.error("[start-thread-from-prompt] failed",_),ve.error(e("common.useStartThreadFromPrompt.failedToStartChat"))}finally{u.current=!1,h(!1)}}},m=async v=>{if(!u.current){if(v.arguments&&v.arguments.length>0){c(v);return}await f(v)}},p=async v=>{if(!l)return;const b=l;c(null),await f(b,v)};return{start:m,startBlank:async v=>{if(!u.current){u.current=!0,h(!0);try{const b=crypto.randomUUID();await o({id:b,virtual_mcp_id:t}),a(b,t,v?.main?{main:v.main}:void 0)}catch(b){console.error("[start-thread-from-prompt] startBlank failed",b),ve.error(e("common.useStartThreadFromPrompt.failedToStartChat"))}finally{u.current=!1,h(!1)}}},dialog:r.jsx(Io,{prompt:l,setPrompt:v=>c(v),onSubmit:p}),dialogPrompt:l,starting:d}}function QC(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return N.useMemo(()=>n=>{e.forEach(i=>i(n))},e)}const gc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function $r(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function eu(t){return"nodeType"in t}function Ss(t){var e,s;return t?$r(t)?t:eu(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function tu(t){const{Document:e}=Ss(t);return t instanceof e}function ma(t){return $r(t)?!1:t instanceof Ss(t).HTMLElement}function P3(t){return t instanceof Ss(t).SVGElement}function Br(t){return t?$r(t)?t.document:eu(t)?tu(t)?t:ma(t)||P3(t)?t.ownerDocument:document:document:document}const nn=gc?N.useLayoutEffect:N.useEffect;function xc(t){const e=N.useRef(t);return nn(()=>{e.current=t}),N.useCallback(function(){for(var s=arguments.length,n=new Array(s),i=0;i<s;i++)n[i]=arguments[i];return e.current==null?void 0:e.current(...n)},[])}function ZC(){const t=N.useRef(null),e=N.useCallback((n,i)=>{t.current=setInterval(n,i)},[]),s=N.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function qo(t,e){e===void 0&&(e=[t]);const s=N.useRef(t);return nn(()=>{s.current!==t&&(s.current=t)},e),s}function pa(t,e){const s=N.useRef();return N.useMemo(()=>{const n=t(s.current);return s.current=n,n},[...e])}function Al(t){const e=xc(t),s=N.useRef(null),n=N.useCallback(i=>{i!==s.current&&e?.(i,s.current),s.current=i},[]);return[s,n]}function El(t){const e=N.useRef();return N.useEffect(()=>{e.current=t},[t]),e.current}let td={};function ga(t,e){return N.useMemo(()=>{if(e)return e;const s=td[t]==null?0:td[t]+1;return td[t]=s,t+"-"+s},[t,e])}function R3(t){return function(e){for(var s=arguments.length,n=new Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];return n.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const h=o[c];h!=null&&(o[c]=h+t*d)}return o},{...e})}}const hr=R3(1),Go=R3(-1);function ek(t){return"clientX"in t&&"clientY"in t}function vc(t){if(!t)return!1;const{KeyboardEvent:e}=Ss(t.target);return e&&t instanceof e}function tk(t){if(!t)return!1;const{TouchEvent:e}=Ss(t.target);return e&&t instanceof e}function Pl(t){if(tk(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return ek(t)?{x:t.clientX,y:t.clientY}:null}const Sn=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Sn.Translate.toString(t),Sn.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:n}=t;return e+" "+s+"ms "+n}}}),sf="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function sk(t){return t.matches(sf)?t:t.querySelector(sf)}const nk={display:"none"};function ik(t){let{id:e,value:s}=t;return rt.createElement("div",{id:e,style:nk},s)}function rk(t){let{id:e,announcement:s,ariaLiveType:n="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return rt.createElement("div",{id:e,style:i,role:"status","aria-live":n,"aria-atomic":!0},s)}function ok(){const[t,e]=N.useState("");return{announce:N.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const D3=N.createContext(null);function ak(t){const e=N.useContext(D3);N.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function lk(){const[t]=N.useState(()=>new Set),e=N.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[N.useCallback(n=>{let{type:i,event:o}=n;t.forEach(a=>{var l;return(l=a[i])==null?void 0:l.call(a,o)})},[t]),e]}const ck={draggable:`
13
- To pick up a draggable item, press the space bar.
14
- While dragging, use the arrow keys to move the item.
15
- Press space again to drop the item in its new position, or press escape to cancel.
16
- `},dk={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was moved over droppable area "+s.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was dropped over droppable area "+s.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function uk(t){let{announcements:e=dk,container:s,hiddenTextDescribedById:n,screenReaderInstructions:i=ck}=t;const{announce:o,announcement:a}=ok(),l=ga("DndLiveRegion"),[c,d]=N.useState(!1);if(N.useEffect(()=>{d(!0)},[]),ak(N.useMemo(()=>({onDragStart(u){let{active:f}=u;o(e.onDragStart({active:f}))},onDragMove(u){let{active:f,over:m}=u;e.onDragMove&&o(e.onDragMove({active:f,over:m}))},onDragOver(u){let{active:f,over:m}=u;o(e.onDragOver({active:f,over:m}))},onDragEnd(u){let{active:f,over:m}=u;o(e.onDragEnd({active:f,over:m}))},onDragCancel(u){let{active:f,over:m}=u;o(e.onDragCancel({active:f,over:m}))}}),[o,e])),!c)return null;const h=rt.createElement(rt.Fragment,null,rt.createElement(ik,{id:n,value:i.draggable}),rt.createElement(rk,{id:l,announcement:a}));return s?Zs.createPortal(h,s):h}var Ht;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Ht||(Ht={}));function Rl(){}function li(t,e){return N.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function bc(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return N.useMemo(()=>[...e].filter(n=>n!=null),[...e])}const rn=Object.freeze({x:0,y:0});function I3(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function hk(t,e){const s=Pl(t);if(!s)return"0 0";const n={x:(s.x-e.left)/e.width*100,y:(s.y-e.top)/e.height*100};return n.x+"% "+n.y+"%"}function M3(t,e){let{data:{value:s}}=t,{data:{value:n}}=e;return s-n}function fk(t,e){let{data:{value:s}}=t,{data:{value:n}}=e;return n-s}function nf(t){let{left:e,top:s,height:n,width:i}=t;return[{x:e,y:s},{x:e+i,y:s},{x:e,y:s+n},{x:e+i,y:s+n}]}function O3(t,e){if(!t||t.length===0)return null;const[s]=t;return s[e]}function rf(t,e,s){return e===void 0&&(e=t.left),s===void 0&&(s=t.top),{x:e+t.width*.5,y:s+t.height*.5}}const su=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const i=rf(e,e.left,e.top),o=[];for(const a of n){const{id:l}=a,c=s.get(l);if(c){const d=I3(rf(c),i);o.push({id:l,data:{droppableContainer:a,value:d}})}}return o.sort(M3)},mk=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const i=nf(e),o=[];for(const a of n){const{id:l}=a,c=s.get(l);if(c){const d=nf(c),h=i.reduce((f,m,p)=>f+I3(d[p],m),0),u=Number((h/4).toFixed(4));o.push({id:l,data:{droppableContainer:a,value:u}})}}return o.sort(M3)};function pk(t,e){const s=Math.max(e.top,t.top),n=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),o=Math.min(e.top+e.height,t.top+t.height),a=i-n,l=o-s;if(n<i&&s<o){const c=e.width*e.height,d=t.width*t.height,h=a*l,u=h/(c+d-h);return Number(u.toFixed(4))}return 0}const gk=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const i=[];for(const o of n){const{id:a}=o,l=s.get(a);if(l){const c=pk(l,e);c>0&&i.push({id:a,data:{droppableContainer:o,value:c}})}}return i.sort(fk)};function xk(t,e,s){return{...t,scaleX:e&&s?e.width/s.width:1,scaleY:e&&s?e.height/s.height:1}}function $3(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:rn}function vk(t){return function(s){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i.reduce((a,l)=>({...a,top:a.top+t*l.y,bottom:a.bottom+t*l.y,left:a.left+t*l.x,right:a.right+t*l.x}),{...s})}}const bk=vk(1);function B3(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function yk(t,e,s){const n=B3(e);if(!n)return t;const{scaleX:i,scaleY:o,x:a,y:l}=n,c=t.left-a-(1-i)*parseFloat(s),d=t.top-l-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),h=i?t.width/i:t.width,u=o?t.height/o:t.height;return{width:h,height:u,top:d,right:c+h,bottom:d+u,left:c}}const _k={ignoreTransform:!1};function Fr(t,e){e===void 0&&(e=_k);let s=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:h}=Ss(t).getComputedStyle(t);d&&(s=yk(s,d,h))}const{top:n,left:i,width:o,height:a,bottom:l,right:c}=s;return{top:n,left:i,width:o,height:a,bottom:l,right:c}}function of(t){return Fr(t,{ignoreTransform:!0})}function Lk(t){const e=t.innerWidth,s=t.innerHeight;return{top:0,left:0,right:e,bottom:s,width:e,height:s}}function Sk(t,e){return e===void 0&&(e=Ss(t).getComputedStyle(t)),e.position==="fixed"}function wk(t,e){e===void 0&&(e=Ss(t).getComputedStyle(t));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const o=e[i];return typeof o=="string"?s.test(o):!1})}function yc(t,e){const s=[];function n(i){if(e!=null&&s.length>=e||!i)return s;if(tu(i)&&i.scrollingElement!=null&&!s.includes(i.scrollingElement))return s.push(i.scrollingElement),s;if(!ma(i)||P3(i)||s.includes(i))return s;const o=Ss(t).getComputedStyle(i);return i!==t&&wk(i,o)&&s.push(i),Sk(i,o)?s:n(i.parentNode)}return t?n(t):s}function F3(t){const[e]=yc(t,1);return e??null}function sd(t){return!gc||!t?null:$r(t)?t:eu(t)?tu(t)||t===Br(t).scrollingElement?window:ma(t)?t:null:null}function z3(t){return $r(t)?t.scrollX:t.scrollLeft}function K3(t){return $r(t)?t.scrollY:t.scrollTop}function Jd(t){return{x:z3(t),y:K3(t)}}var Qt;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Qt||(Qt={}));function U3(t){return!gc||!t?!1:t===document.scrollingElement}function H3(t){const e={x:0,y:0},s=U3(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-s.width,y:t.scrollHeight-s.height},i=t.scrollTop<=e.y,o=t.scrollLeft<=e.x,a=t.scrollTop>=n.y,l=t.scrollLeft>=n.x;return{isTop:i,isLeft:o,isBottom:a,isRight:l,maxScroll:n,minScroll:e}}const jk={x:.2,y:.2};function Ck(t,e,s,n,i){let{top:o,left:a,right:l,bottom:c}=s;n===void 0&&(n=10),i===void 0&&(i=jk);const{isTop:d,isBottom:h,isLeft:u,isRight:f}=H3(t),m={x:0,y:0},p={x:0,y:0},g={height:e.height*i.y,width:e.width*i.x};return!d&&o<=e.top+g.height?(m.y=Qt.Backward,p.y=n*Math.abs((e.top+g.height-o)/g.height)):!h&&c>=e.bottom-g.height&&(m.y=Qt.Forward,p.y=n*Math.abs((e.bottom-g.height-c)/g.height)),!f&&l>=e.right-g.width?(m.x=Qt.Forward,p.x=n*Math.abs((e.right-g.width-l)/g.width)):!u&&a<=e.left+g.width&&(m.x=Qt.Backward,p.x=n*Math.abs((e.left+g.width-a)/g.width)),{direction:m,speed:p}}function kk(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:a}=window;return{top:0,left:0,right:o,bottom:a,width:o,height:a}}const{top:e,left:s,right:n,bottom:i}=t.getBoundingClientRect();return{top:e,left:s,right:n,bottom:i,width:t.clientWidth,height:t.clientHeight}}function W3(t){return t.reduce((e,s)=>hr(e,Jd(s)),rn)}function Vk(t){return t.reduce((e,s)=>e+z3(s),0)}function Nk(t){return t.reduce((e,s)=>e+K3(s),0)}function q3(t,e){if(e===void 0&&(e=Fr),!t)return;const{top:s,left:n,bottom:i,right:o}=e(t);F3(t)&&(i<=0||o<=0||s>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Tk=[["x",["left","right"],Vk],["y",["top","bottom"],Nk]];class nu{constructor(e,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=yc(s),i=W3(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,a,l]of Tk)for(const c of a)Object.defineProperty(this,c,{get:()=>{const d=l(n),h=i[o]-d;return this.rect[c]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Co{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...s)})},this.target=e}add(e,s,n){var i;(i=this.target)==null||i.addEventListener(e,s,n),this.listeners.push([e,s,n])}}function Ak(t){const{EventTarget:e}=Ss(t);return t instanceof e?t:Br(t)}function nd(t,e){const s=Math.abs(t.x),n=Math.abs(t.y);return typeof e=="number"?Math.sqrt(s**2+n**2)>e:"x"in e&&"y"in e?s>e.x&&n>e.y:"x"in e?s>e.x:"y"in e?n>e.y:!1}var Hs;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Hs||(Hs={}));function af(t){t.preventDefault()}function Ek(t){t.stopPropagation()}var ot;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(ot||(ot={}));const G3={start:[ot.Space,ot.Enter],cancel:[ot.Esc],end:[ot.Space,ot.Enter,ot.Tab]},Pk=(t,e)=>{let{currentCoordinates:s}=e;switch(t.code){case ot.Right:return{...s,x:s.x+25};case ot.Left:return{...s,x:s.x-25};case ot.Down:return{...s,y:s.y+25};case ot.Up:return{...s,y:s.y-25}}};class zr{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:s}}=e;this.props=e,this.listeners=new Co(Br(s)),this.windowListeners=new Co(Ss(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Hs.Resize,this.handleCancel),this.windowListeners.add(Hs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Hs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:s}=this.props,n=e.node.current;n&&q3(n),s(rn)}handleKeyDown(e){if(vc(e)){const{active:s,context:n,options:i}=this.props,{keyboardCodes:o=G3,coordinateGetter:a=Pk,scrollBehavior:l="smooth"}=i,{code:c}=e;if(o.end.includes(c)){this.handleEnd(e);return}if(o.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:d}=n.current,h=d?{x:d.left,y:d.top}:rn;this.referenceCoordinates||(this.referenceCoordinates=h);const u=a(e,{active:s,context:n.current,currentCoordinates:h});if(u){const f=Go(u,h),m={x:0,y:0},{scrollableAncestors:p}=n.current;for(const g of p){const x=e.code,{isTop:v,isRight:b,isLeft:_,isBottom:y,maxScroll:L,minScroll:w}=H3(g),j=kk(g),S={x:Math.min(x===ot.Right?j.right-j.width/2:j.right,Math.max(x===ot.Right?j.left:j.left+j.width/2,u.x)),y:Math.min(x===ot.Down?j.bottom-j.height/2:j.bottom,Math.max(x===ot.Down?j.top:j.top+j.height/2,u.y))},k=x===ot.Right&&!b||x===ot.Left&&!_,C=x===ot.Down&&!y||x===ot.Up&&!v;if(k&&S.x!==u.x){const A=g.scrollLeft+f.x,P=x===ot.Right&&A<=L.x||x===ot.Left&&A>=w.x;if(P&&!f.y){g.scrollTo({left:A,behavior:l});return}P?m.x=g.scrollLeft-A:m.x=x===ot.Right?g.scrollLeft-L.x:g.scrollLeft-w.x,m.x&&g.scrollBy({left:-m.x,behavior:l});break}else if(C&&S.y!==u.y){const A=g.scrollTop+f.y,P=x===ot.Down&&A<=L.y||x===ot.Up&&A>=w.y;if(P&&!f.x){g.scrollTo({top:A,behavior:l});return}P?m.y=g.scrollTop-A:m.y=x===ot.Down?g.scrollTop-L.y:g.scrollTop-w.y,m.y&&g.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,hr(Go(u,this.referenceCoordinates),m))}}}handleMove(e,s){const{onMove:n}=this.props;e.preventDefault(),n(s)}handleEnd(e){const{onEnd:s}=this.props;e.preventDefault(),this.detach(),s()}handleCancel(e){const{onCancel:s}=this.props;e.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}zr.activators=[{eventName:"onKeyDown",handler:(t,e,s)=>{let{keyboardCodes:n=G3,onActivation:i}=e,{active:o}=s;const{code:a}=t.nativeEvent;if(n.start.includes(a)){const l=o.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function lf(t){return!!(t&&"distance"in t)}function cf(t){return!!(t&&"delay"in t)}class iu{constructor(e,s,n){var i;n===void 0&&(n=Ak(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=s;const{event:o}=e,{target:a}=o;this.props=e,this.events=s,this.document=Br(a),this.documentListeners=new Co(this.document),this.listeners=new Co(n),this.windowListeners=new Co(Ss(a)),this.initialCoordinates=(i=Pl(o))!=null?i:rn,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:s,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Hs.Resize,this.handleCancel),this.windowListeners.add(Hs.DragStart,af),this.windowListeners.add(Hs.VisibilityChange,this.handleCancel),this.windowListeners.add(Hs.ContextMenu,af),this.documentListeners.add(Hs.Keydown,this.handleKeydown),s){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(cf(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(lf(s)){this.handlePending(s);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,s){const{active:n,onPending:i}=this.props;i(n,e,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:e}=this,{onStart:s}=this.props;e&&(this.activated=!0,this.documentListeners.add(Hs.Click,Ek,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Hs.SelectionChange,this.removeTextSelection),s(e))}handleMove(e){var s;const{activated:n,initialCoordinates:i,props:o}=this,{onMove:a,options:{activationConstraint:l}}=o;if(!i)return;const c=(s=Pl(e))!=null?s:rn,d=Go(i,c);if(!n&&l){if(lf(l)){if(l.tolerance!=null&&nd(d,l.tolerance))return this.handleCancel();if(nd(d,l.distance))return this.handleStart()}if(cf(l)&&nd(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}e.cancelable&&e.preventDefault(),a(c)}handleEnd(){const{onAbort:e,onEnd:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleCancel(){const{onAbort:e,onCancel:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleKeydown(e){e.code===ot.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const Rk={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Kr extends iu{constructor(e){const{event:s}=e,n=Br(s.target);super(e,Rk,n)}}Kr.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;return!s.isPrimary||s.button!==0?!1:(n?.({event:s}),!0)}}];const Dk={move:{name:"mousemove"},end:{name:"mouseup"}};var Xd;(function(t){t[t.RightClick=2]="RightClick"})(Xd||(Xd={}));class Ik extends iu{constructor(e){super(e,Dk,Br(e.event.target))}}Ik.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;return s.button===Xd.RightClick?!1:(n?.({event:s}),!0)}}];const id={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Mk extends iu{constructor(e){super(e,id)}static setup(){return window.addEventListener(id.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(id.move.name,e)};function e(){}}}Mk.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;const{touches:i}=s;return i.length>1?!1:(n?.({event:s}),!0)}}];var ko;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(ko||(ko={}));var Dl;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Dl||(Dl={}));function Ok(t){let{acceleration:e,activator:s=ko.Pointer,canScroll:n,draggingRect:i,enabled:o,interval:a=5,order:l=Dl.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:h,delta:u,threshold:f}=t;const m=Bk({delta:u,disabled:!o}),[p,g]=ZC(),x=N.useRef({x:0,y:0}),v=N.useRef({x:0,y:0}),b=N.useMemo(()=>{switch(s){case ko.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case ko.DraggableRect:return i}},[s,i,c]),_=N.useRef(null),y=N.useCallback(()=>{const w=_.current;if(!w)return;const j=x.current.x*v.current.x,S=x.current.y*v.current.y;w.scrollBy(j,S)},[]),L=N.useMemo(()=>l===Dl.TreeOrder?[...d].reverse():d,[l,d]);N.useEffect(()=>{if(!o||!d.length||!b){g();return}for(const w of L){if(n?.(w)===!1)continue;const j=d.indexOf(w),S=h[j];if(!S)continue;const{direction:k,speed:C}=Ck(w,S,b,e,f);for(const A of["x","y"])m[A][k[A]]||(C[A]=0,k[A]=0);if(C.x>0||C.y>0){g(),_.current=w,p(y,a),x.current=C,v.current=k;return}}x.current={x:0,y:0},v.current={x:0,y:0},g()},[e,y,n,g,o,a,JSON.stringify(b),JSON.stringify(m),p,d,L,h,JSON.stringify(f)])}const $k={x:{[Qt.Backward]:!1,[Qt.Forward]:!1},y:{[Qt.Backward]:!1,[Qt.Forward]:!1}};function Bk(t){let{delta:e,disabled:s}=t;const n=El(e);return pa(i=>{if(s||!n||!i)return $k;const o={x:Math.sign(e.x-n.x),y:Math.sign(e.y-n.y)};return{x:{[Qt.Backward]:i.x[Qt.Backward]||o.x===-1,[Qt.Forward]:i.x[Qt.Forward]||o.x===1},y:{[Qt.Backward]:i.y[Qt.Backward]||o.y===-1,[Qt.Forward]:i.y[Qt.Forward]||o.y===1}}},[s,e,n])}function Fk(t,e){const s=e!=null?t.get(e):void 0,n=s?s.node.current:null;return pa(i=>{var o;return e==null?null:(o=n??i)!=null?o:null},[n,e])}function zk(t,e){return N.useMemo(()=>t.reduce((s,n)=>{const{sensor:i}=n,o=i.activators.map(a=>({eventName:a.eventName,handler:e(a.handler,n)}));return[...s,...o]},[]),[t,e])}var Yo;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Yo||(Yo={}));var Qd;(function(t){t.Optimized="optimized"})(Qd||(Qd={}));const df=new Map;function Kk(t,e){let{dragging:s,dependencies:n,config:i}=e;const[o,a]=N.useState(null),{frequency:l,measure:c,strategy:d}=i,h=N.useRef(t),u=x(),f=qo(u),m=N.useCallback(function(v){v===void 0&&(v=[]),!f.current&&a(b=>b===null?v:b.concat(v.filter(_=>!b.includes(_))))},[f]),p=N.useRef(null),g=pa(v=>{if(u&&!s)return df;if(!v||v===df||h.current!==t||o!=null){const b=new Map;for(let _ of t){if(!_)continue;if(o&&o.length>0&&!o.includes(_.id)&&_.rect.current){b.set(_.id,_.rect.current);continue}const y=_.node.current,L=y?new nu(c(y),y):null;_.rect.current=L,L&&b.set(_.id,L)}return b}return v},[t,o,s,u,c]);return N.useEffect(()=>{h.current=t},[t]),N.useEffect(()=>{u||m()},[s,u]),N.useEffect(()=>{o&&o.length>0&&a(null)},[JSON.stringify(o)]),N.useEffect(()=>{u||typeof l!="number"||p.current!==null||(p.current=setTimeout(()=>{m(),p.current=null},l))},[l,u,m,...n]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:o!=null};function x(){switch(d){case Yo.Always:return!1;case Yo.BeforeDragging:return s;default:return!s}}}function ru(t,e){return pa(s=>t?s||(typeof e=="function"?e(t):t):null,[e,t])}function Uk(t,e){return ru(t,e)}function Hk(t){let{callback:e,disabled:s}=t;const n=xc(e),i=N.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,s]);return N.useEffect(()=>()=>i?.disconnect(),[i]),i}function _c(t){let{callback:e,disabled:s}=t;const n=xc(e),i=N.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[s]);return N.useEffect(()=>()=>i?.disconnect(),[i]),i}function Wk(t){return new nu(Fr(t),t)}function uf(t,e,s){e===void 0&&(e=Wk);const[n,i]=N.useState(null);function o(){i(c=>{if(!t)return null;if(t.isConnected===!1){var d;return(d=c??s)!=null?d:null}const h=e(t);return JSON.stringify(c)===JSON.stringify(h)?c:h})}const a=Hk({callback(c){if(t)for(const d of c){const{type:h,target:u}=d;if(h==="childList"&&u instanceof HTMLElement&&u.contains(t)){o();break}}}}),l=_c({callback:o});return nn(()=>{o(),t?(l?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),a?.disconnect())},[t]),n}function qk(t){const e=ru(t);return $3(t,e)}const hf=[];function Gk(t){const e=N.useRef(t),s=pa(n=>t?n&&n!==hf&&t&&e.current&&t.parentNode===e.current.parentNode?n:yc(t):hf,[t]);return N.useEffect(()=>{e.current=t},[t]),s}function Yk(t){const[e,s]=N.useState(null),n=N.useRef(t),i=N.useCallback(o=>{const a=sd(o.target);a&&s(l=>l?(l.set(a,Jd(a)),new Map(l)):null)},[]);return N.useEffect(()=>{const o=n.current;if(t!==o){a(o);const l=t.map(c=>{const d=sd(c);return d?(d.addEventListener("scroll",i,{passive:!0}),[d,Jd(d)]):null}).filter(c=>c!=null);s(l.length?new Map(l):null),n.current=t}return()=>{a(t),a(o)};function a(l){l.forEach(c=>{const d=sd(c);d?.removeEventListener("scroll",i)})}},[i,t]),N.useMemo(()=>t.length?e?Array.from(e.values()).reduce((o,a)=>hr(o,a),rn):W3(t):rn,[t,e])}function ff(t,e){e===void 0&&(e=[]);const s=N.useRef(null);return N.useEffect(()=>{s.current=null},e),N.useEffect(()=>{const n=t!==rn;n&&!s.current&&(s.current=t),!n&&s.current&&(s.current=null)},[t]),s.current?Go(t,s.current):rn}function Jk(t){N.useEffect(()=>{if(!gc)return;const e=t.map(s=>{let{sensor:n}=s;return n.setup==null?void 0:n.setup()});return()=>{for(const s of e)s?.()}},t.map(e=>{let{sensor:s}=e;return s}))}function Xk(t,e){return N.useMemo(()=>t.reduce((s,n)=>{let{eventName:i,handler:o}=n;return s[i]=a=>{o(a,e)},s},{}),[t,e])}function Y3(t){return N.useMemo(()=>t?Lk(t):null,[t])}const mf=[];function Qk(t,e){e===void 0&&(e=Fr);const[s]=t,n=Y3(s?Ss(s):null),[i,o]=N.useState(mf);function a(){o(()=>t.length?t.map(c=>U3(c)?n:new nu(e(c),c)):mf)}const l=_c({callback:a});return nn(()=>{l?.disconnect(),a(),t.forEach(c=>l?.observe(c))},[t]),i}function J3(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return ma(e)?e:t}function Zk(t){let{measure:e}=t;const[s,n]=N.useState(null),i=N.useCallback(d=>{for(const{target:h}of d)if(ma(h)){n(u=>{const f=e(h);return u?{...u,width:f.width,height:f.height}:f});break}},[e]),o=_c({callback:i}),a=N.useCallback(d=>{const h=J3(d);o?.disconnect(),h&&o?.observe(h),n(h?e(h):null)},[e,o]),[l,c]=Al(a);return N.useMemo(()=>({nodeRef:l,rect:s,setRef:c}),[s,l,c])}const eV=[{sensor:Kr,options:{}},{sensor:zr,options:{}}],tV={current:{}},Qa={draggable:{measure:of},droppable:{measure:of,strategy:Yo.WhileDragging,frequency:Qd.Optimized},dragOverlay:{measure:Fr}};class Vo extends Map{get(e){var s;return e!=null&&(s=super.get(e))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:s}=e;return!s})}getNodeFor(e){var s,n;return(s=(n=this.get(e))==null?void 0:n.node.current)!=null?s:void 0}}const sV={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Vo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Rl},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Qa,measureDroppableContainers:Rl,windowRect:null,measuringScheduled:!1},X3={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Rl,draggableNodes:new Map,over:null,measureDroppableContainers:Rl},xa=N.createContext(X3),Q3=N.createContext(sV);function nV(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Vo}}}function iV(t,e){switch(e.type){case Ht.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Ht.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Ht.DragEnd:case Ht.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ht.RegisterDroppable:{const{element:s}=e,{id:n}=s,i=new Vo(t.droppable.containers);return i.set(n,s),{...t,droppable:{...t.droppable,containers:i}}}case Ht.SetDroppableDisabled:{const{id:s,key:n,disabled:i}=e,o=t.droppable.containers.get(s);if(!o||n!==o.key)return t;const a=new Vo(t.droppable.containers);return a.set(s,{...o,disabled:i}),{...t,droppable:{...t.droppable,containers:a}}}case Ht.UnregisterDroppable:{const{id:s,key:n}=e,i=t.droppable.containers.get(s);if(!i||n!==i.key)return t;const o=new Vo(t.droppable.containers);return o.delete(s),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function rV(t){let{disabled:e}=t;const{active:s,activatorEvent:n,draggableNodes:i}=N.useContext(xa),o=El(n),a=El(s?.id);return N.useEffect(()=>{if(!e&&!n&&o&&a!=null){if(!vc(o)||document.activeElement===o.target)return;const l=i.get(a);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const h of[c.current,d.current]){if(!h)continue;const u=sk(h);if(u){u.focus();break}}})}},[n,e,i,a,o]),null}function Z3(t,e){let{transform:s,...n}=e;return t!=null&&t.length?t.reduce((i,o)=>o({transform:i,...n}),s):s}function oV(t){return N.useMemo(()=>({draggable:{...Qa.draggable,...t?.draggable},droppable:{...Qa.droppable,...t?.droppable},dragOverlay:{...Qa.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function aV(t){let{activeNode:e,measure:s,initialRect:n,config:i=!0}=t;const o=N.useRef(!1),{x:a,y:l}=typeof i=="boolean"?{x:i,y:i}:i;nn(()=>{if(!a&&!l||!e){o.current=!1;return}if(o.current||!n)return;const d=e?.node.current;if(!d||d.isConnected===!1)return;const h=s(d),u=$3(h,n);if(a||(u.x=0),l||(u.y=0),o.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){const f=F3(d);f&&f.scrollBy({top:u.y,left:u.x})}},[e,a,l,n,s])}const Lc=N.createContext({...rn,scaleX:1,scaleY:1});var Gn;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Gn||(Gn={}));const Sc=N.memo(function(e){var s,n,i,o;let{id:a,accessibility:l,autoScroll:c=!0,children:d,sensors:h=eV,collisionDetection:u=gk,measuring:f,modifiers:m,...p}=e;const g=N.useReducer(iV,void 0,nV),[x,v]=g,[b,_]=lk(),[y,L]=N.useState(Gn.Uninitialized),w=y===Gn.Initialized,{draggable:{active:j,nodes:S,translate:k},droppable:{containers:C}}=x,A=j!=null?S.get(j):null,P=N.useRef({initial:null,translated:null}),V=N.useMemo(()=>{var $e;return j!=null?{id:j,data:($e=A?.data)!=null?$e:tV,rect:P}:null},[j,A]),T=N.useRef(null),[R,E]=N.useState(null),[I,D]=N.useState(null),M=qo(p,Object.values(p)),O=ga("DndDescribedBy",a),$=N.useMemo(()=>C.getEnabled(),[C]),B=oV(f),{droppableRects:z,measureDroppableContainers:K,measuringScheduled:Y}=Kk($,{dragging:w,dependencies:[k.x,k.y],config:B.droppable}),Q=Fk(S,j),q=N.useMemo(()=>I?Pl(I):null,[I]),H=ke(),U=Uk(Q,B.draggable.measure);aV({activeNode:j!=null?S.get(j):null,config:H.layoutShiftCompensation,initialRect:U,measure:B.draggable.measure});const X=uf(Q,B.draggable.measure,U),J=uf(Q?Q.parentElement:null),ee=N.useRef({activatorEvent:null,active:null,activeNode:Q,collisionRect:null,collisions:null,droppableRects:z,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:C,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),W=C.getNodeFor((s=ee.current.over)==null?void 0:s.id),Z=Zk({measure:B.dragOverlay.measure}),G=(n=Z.nodeRef.current)!=null?n:Q,te=w?(i=Z.rect)!=null?i:X:null,se=!!(Z.nodeRef.current&&Z.rect),re=qk(se?null:X),de=Y3(G?Ss(G):null),ce=Gk(w?W??Q:null),fe=Qk(ce),ue=Z3(m,{transform:{x:k.x-re.x,y:k.y-re.y,scaleX:1,scaleY:1},activatorEvent:I,active:V,activeNodeRect:X,containerNodeRect:J,draggingNodeRect:te,over:ee.current.over,overlayNodeRect:Z.rect,scrollableAncestors:ce,scrollableAncestorRects:fe,windowRect:de}),ae=q?hr(q,k):null,me=Yk(ce),xe=ff(me),Se=ff(me,[X]),Ve=hr(ue,xe),Ie=te?bk(te,ue):null,Ne=V&&Ie?u({active:V,collisionRect:Ie,droppableRects:z,droppableContainers:$,pointerCoordinates:ae}):null,Ee=O3(Ne,"id"),[we,Ae]=N.useState(null),be=se?ue:hr(ue,Se),je=xk(be,(o=we?.rect)!=null?o:null,X),ge=N.useRef(null),Le=N.useCallback(($e,qe)=>{let{sensor:lt,options:ft}=qe;if(T.current==null)return;const dt=S.get(T.current);if(!dt)return;const it=$e.nativeEvent,xt=new lt({active:T.current,activeNode:dt,event:it,options:ft,context:ee,onAbort(pe){if(!S.get(pe))return;const{onDragAbort:Xe}=M.current,gt={id:pe};Xe?.(gt),b({type:"onDragAbort",event:gt})},onPending(pe,Be,Xe,gt){if(!S.get(pe))return;const{onDragPending:zt}=M.current,Nt={id:pe,constraint:Be,initialCoordinates:Xe,offset:gt};zt?.(Nt),b({type:"onDragPending",event:Nt})},onStart(pe){const Be=T.current;if(Be==null)return;const Xe=S.get(Be);if(!Xe)return;const{onDragStart:gt}=M.current,Vt={activatorEvent:it,active:{id:Be,data:Xe.data,rect:P}};Zs.unstable_batchedUpdates(()=>{gt?.(Vt),L(Gn.Initializing),v({type:Ht.DragStart,initialCoordinates:pe,active:Be}),b({type:"onDragStart",event:Vt}),E(ge.current),D(it)})},onMove(pe){v({type:Ht.DragMove,coordinates:pe})},onEnd:vt(Ht.DragEnd),onCancel:vt(Ht.DragCancel)});ge.current=xt;function vt(pe){return async function(){const{active:Xe,collisions:gt,over:Vt,scrollAdjustedTranslate:zt}=ee.current;let Nt=null;if(Xe&&zt){const{cancelDrop:ct}=M.current;Nt={activatorEvent:it,active:Xe,collisions:gt,delta:zt,over:Vt},pe===Ht.DragEnd&&typeof ct=="function"&&await Promise.resolve(ct(Nt))&&(pe=Ht.DragCancel)}T.current=null,Zs.unstable_batchedUpdates(()=>{v({type:pe}),L(Gn.Uninitialized),Ae(null),E(null),D(null),ge.current=null;const ct=pe===Ht.DragEnd?"onDragEnd":"onDragCancel";if(Nt){const Rs=M.current[ct];Rs?.(Nt),b({type:ct,event:Nt})}})}}},[S]),ye=N.useCallback(($e,qe)=>(lt,ft)=>{const dt=lt.nativeEvent,it=S.get(ft);if(T.current!==null||!it||dt.dndKit||dt.defaultPrevented)return;const xt={active:it};$e(lt,qe.options,xt)===!0&&(dt.dndKit={capturedBy:qe.sensor},T.current=ft,Le(lt,qe))},[S,Le]),Ce=zk(h,ye);Jk(h),nn(()=>{X&&y===Gn.Initializing&&L(Gn.Initialized)},[X,y]),N.useEffect(()=>{const{onDragMove:$e}=M.current,{active:qe,activatorEvent:lt,collisions:ft,over:dt}=ee.current;if(!qe||!lt)return;const it={active:qe,activatorEvent:lt,collisions:ft,delta:{x:Ve.x,y:Ve.y},over:dt};Zs.unstable_batchedUpdates(()=>{$e?.(it),b({type:"onDragMove",event:it})})},[Ve.x,Ve.y]),N.useEffect(()=>{const{active:$e,activatorEvent:qe,collisions:lt,droppableContainers:ft,scrollAdjustedTranslate:dt}=ee.current;if(!$e||T.current==null||!qe||!dt)return;const{onDragOver:it}=M.current,xt=ft.get(Ee),vt=xt&&xt.rect.current?{id:xt.id,rect:xt.rect.current,data:xt.data,disabled:xt.disabled}:null,pe={active:$e,activatorEvent:qe,collisions:lt,delta:{x:dt.x,y:dt.y},over:vt};Zs.unstable_batchedUpdates(()=>{Ae(vt),it?.(pe),b({type:"onDragOver",event:pe})})},[Ee]),nn(()=>{ee.current={activatorEvent:I,active:V,activeNode:Q,collisionRect:Ie,collisions:Ne,droppableRects:z,draggableNodes:S,draggingNode:G,draggingNodeRect:te,droppableContainers:C,over:we,scrollableAncestors:ce,scrollAdjustedTranslate:Ve},P.current={initial:te,translated:Ie}},[V,Q,Ne,Ie,S,G,te,z,C,we,ce,Ve]),Ok({...H,delta:k,draggingRect:Ie,pointerCoordinates:ae,scrollableAncestors:ce,scrollableAncestorRects:fe});const Me=N.useMemo(()=>({active:V,activeNode:Q,activeNodeRect:X,activatorEvent:I,collisions:Ne,containerNodeRect:J,dragOverlay:Z,draggableNodes:S,droppableContainers:C,droppableRects:z,over:we,measureDroppableContainers:K,scrollableAncestors:ce,scrollableAncestorRects:fe,measuringConfiguration:B,measuringScheduled:Y,windowRect:de}),[V,Q,X,I,Ne,J,Z,S,C,z,we,K,ce,fe,B,Y,de]),Re=N.useMemo(()=>({activatorEvent:I,activators:Ce,active:V,activeNodeRect:X,ariaDescribedById:{draggable:O},dispatch:v,draggableNodes:S,over:we,measureDroppableContainers:K}),[I,Ce,V,X,v,O,S,we,K]);return rt.createElement(D3.Provider,{value:_},rt.createElement(xa.Provider,{value:Re},rt.createElement(Q3.Provider,{value:Me},rt.createElement(Lc.Provider,{value:je},d)),rt.createElement(rV,{disabled:l?.restoreFocus===!1})),rt.createElement(uk,{...l,hiddenTextDescribedById:O}));function ke(){const $e=R?.autoScrollEnabled===!1,qe=typeof c=="object"?c.enabled===!1:c===!1,lt=w&&!$e&&!qe;return typeof c=="object"?{...c,enabled:lt}:{enabled:lt}}}),lV=N.createContext(null),pf="button",cV="Draggable";function eg(t){let{id:e,data:s,disabled:n=!1,attributes:i}=t;const o=ga(cV),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:h,draggableNodes:u,over:f}=N.useContext(xa),{role:m=pf,roleDescription:p="draggable",tabIndex:g=0}=i??{},x=c?.id===e,v=N.useContext(x?Lc:lV),[b,_]=Al(),[y,L]=Al(),w=Xk(a,e),j=qo(s);nn(()=>(u.set(e,{id:e,key:o,node:b,activatorNode:y,data:j}),()=>{const k=u.get(e);k&&k.key===o&&u.delete(e)}),[u,e]);const S=N.useMemo(()=>({role:m,tabIndex:g,"aria-disabled":n,"aria-pressed":x&&m===pf?!0:void 0,"aria-roledescription":p,"aria-describedby":h.draggable}),[n,m,g,x,p,h.draggable]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:S,isDragging:x,listeners:n?void 0:w,node:b,over:f,setNodeRef:_,setActivatorNodeRef:L,transform:v}}function tg(){return N.useContext(Q3)}const dV="Droppable",uV={timeout:25};function hV(t){let{data:e,disabled:s=!1,id:n,resizeObserverConfig:i}=t;const o=ga(dV),{active:a,dispatch:l,over:c,measureDroppableContainers:d}=N.useContext(xa),h=N.useRef({disabled:s}),u=N.useRef(!1),f=N.useRef(null),m=N.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:x}={...uV,...i},v=qo(g??n),b=N.useCallback(()=>{if(!u.current){u.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{d(Array.isArray(v.current)?v.current:[v.current]),m.current=null},x)},[x]),_=_c({callback:b,disabled:p||!a}),y=N.useCallback((S,k)=>{_&&(k&&(_.unobserve(k),u.current=!1),S&&_.observe(S))},[_]),[L,w]=Al(y),j=qo(e);return N.useEffect(()=>{!_||!L.current||(_.disconnect(),u.current=!1,_.observe(L.current))},[L,_]),N.useEffect(()=>(l({type:Ht.RegisterDroppable,element:{id:n,key:o,disabled:s,node:L,rect:f,data:j}}),()=>l({type:Ht.UnregisterDroppable,key:o,id:n})),[n]),N.useEffect(()=>{s!==h.current.disabled&&(l({type:Ht.SetDroppableDisabled,id:n,key:o,disabled:s}),h.current.disabled=s)},[n,o,s,l]),{active:a,rect:f,isOver:c?.id===n,node:L,over:c,setNodeRef:w}}function fV(t){let{animation:e,children:s}=t;const[n,i]=N.useState(null),[o,a]=N.useState(null),l=El(s);return!s&&!n&&l&&i(l),nn(()=>{if(!o)return;const c=n?.key,d=n?.props.id;if(c==null||d==null){i(null);return}Promise.resolve(e(d,o)).then(()=>{i(null)})},[e,n,o]),rt.createElement(rt.Fragment,null,s,n?N.cloneElement(n,{ref:a}):null)}const mV={x:0,y:0,scaleX:1,scaleY:1};function pV(t){let{children:e}=t;return rt.createElement(xa.Provider,{value:X3},rt.createElement(Lc.Provider,{value:mV},e))}const gV={position:"fixed",touchAction:"none"},xV=t=>vc(t)?"transform 250ms ease":void 0,vV=N.forwardRef((t,e)=>{let{as:s,activatorEvent:n,adjustScale:i,children:o,className:a,rect:l,style:c,transform:d,transition:h=xV}=t;if(!l)return null;const u=i?d:{...d,scaleX:1,scaleY:1},f={...gV,width:l.width,height:l.height,top:l.top,left:l.left,transform:Sn.Transform.toString(u),transformOrigin:i&&n?hk(n,l):void 0,transition:typeof h=="function"?h(n):h,...c};return rt.createElement(s,{className:a,style:f,ref:e},o)}),bV=t=>e=>{let{active:s,dragOverlay:n}=e;const i={},{styles:o,className:a}=t;if(o!=null&&o.active)for(const[l,c]of Object.entries(o.active))c!==void 0&&(i[l]=s.node.style.getPropertyValue(l),s.node.style.setProperty(l,c));if(o!=null&&o.dragOverlay)for(const[l,c]of Object.entries(o.dragOverlay))c!==void 0&&n.node.style.setProperty(l,c);return a!=null&&a.active&&s.node.classList.add(a.active),a!=null&&a.dragOverlay&&n.node.classList.add(a.dragOverlay),function(){for(const[c,d]of Object.entries(i))s.node.style.setProperty(c,d);a!=null&&a.active&&s.node.classList.remove(a.active)}},yV=t=>{let{transform:{initial:e,final:s}}=t;return[{transform:Sn.Transform.toString(e)},{transform:Sn.Transform.toString(s)}]},_V={duration:250,easing:"ease",keyframes:yV,sideEffects:bV({styles:{active:{opacity:"0"}}})};function LV(t){let{config:e,draggableNodes:s,droppableContainers:n,measuringConfiguration:i}=t;return xc((o,a)=>{if(e===null)return;const l=s.get(o);if(!l)return;const c=l.node.current;if(!c)return;const d=J3(a);if(!d)return;const{transform:h}=Ss(a).getComputedStyle(a),u=B3(h);if(!u)return;const f=typeof e=="function"?e:SV(e);return q3(c,i.draggable.measure),f({active:{id:o,data:l.data,node:c,rect:i.draggable.measure(c)},draggableNodes:s,dragOverlay:{node:a,rect:i.dragOverlay.measure(d)},droppableContainers:n,measuringConfiguration:i,transform:u})})}function SV(t){const{duration:e,easing:s,sideEffects:n,keyframes:i}={..._V,...t};return o=>{let{active:a,dragOverlay:l,transform:c,...d}=o;if(!e)return;const h={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},u={scaleX:c.scaleX!==1?a.rect.width*c.scaleX/l.rect.width:1,scaleY:c.scaleY!==1?a.rect.height*c.scaleY/l.rect.height:1},f={x:c.x-h.x,y:c.y-h.y,...u},m=i({...d,active:a,dragOverlay:l,transform:{initial:c,final:f}}),[p]=m,g=m[m.length-1];if(JSON.stringify(p)===JSON.stringify(g))return;const x=n?.({active:a,dragOverlay:l,...d}),v=l.node.animate(m,{duration:e,easing:s,fill:"forwards"});return new Promise(b=>{v.onfinish=()=>{x?.(),b()}})}}let gf=0;function wV(t){return N.useMemo(()=>{if(t!=null)return gf++,gf},[t])}const ou=rt.memo(t=>{let{adjustScale:e=!1,children:s,dropAnimation:n,style:i,transition:o,modifiers:a,wrapperElement:l="div",className:c,zIndex:d=999}=t;const{activatorEvent:h,active:u,activeNodeRect:f,containerNodeRect:m,draggableNodes:p,droppableContainers:g,dragOverlay:x,over:v,measuringConfiguration:b,scrollableAncestors:_,scrollableAncestorRects:y,windowRect:L}=tg(),w=N.useContext(Lc),j=wV(u?.id),S=Z3(a,{activatorEvent:h,active:u,activeNodeRect:f,containerNodeRect:m,draggingNodeRect:x.rect,over:v,overlayNodeRect:x.rect,scrollableAncestors:_,scrollableAncestorRects:y,transform:w,windowRect:L}),k=ru(f),C=LV({config:n,draggableNodes:p,droppableContainers:g,measuringConfiguration:b}),A=k?x.setRef:void 0;return rt.createElement(pV,null,rt.createElement(fV,{animation:C},u&&j?rt.createElement(vV,{key:j,id:u.id,ref:A,as:l,activatorEvent:h,adjustScale:e,className:c,transition:o,rect:k,style:{zIndex:d,...i},transform:S},s):null))}),on=6,Tn=100,xf=12,jV=5,CV={w:3,h:2};class Zd extends N.Component{state={hasError:!1,t:void 0};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error"}}componentDidCatch(e,s){console.error("[home-tiles] tile crashed:",e,s.componentStack)}render(){return this.state.hasError?r.jsx(VV,{message:this.state.message}):r.jsx(kV,{children:this.props.children})}}function kV(t){const e=F.c(2),{children:s}=t;let n;return e[0]!==s?(n=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=n):n=e[1],n}function VV(t){const e=F.c(13),{message:s}=t,n=oe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{className:"flex size-8 items-center justify-center rounded-md bg-destructive/10 text-destructive",children:r.jsx(kr,{size:16})}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("home.tileErrorBoundary.tileCrashed"),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==o?(a=r.jsx("p",{className:"text-sm font-medium text-foreground",children:o}),e[3]=o,e[4]=a):a=e[4];let l;e[5]!==s||e[6]!==n?(l=s??n("home.tileErrorBoundary.defaultError"),e[5]=s,e[6]=n,e[7]=l):l=e[7];let c;e[8]!==l?(c=r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:l}),e[8]=l,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==c?(d=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center",children:[i,a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12],d}function NV(t){const e=F.c(76),{tiles:s,isEditMode:n,renderTile:i,onMove:o,onResize:a,onRemove:l}=t,c=Tr(),d=N.useRef(null),[h,u]=N.useState(null),[f,m]=N.useState(null);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={activationConstraint:{distance:4}},e[0]=p):p=e[0];const g=bc(li(Kr,p),li(zr)),x=s.reduce(TV,0),v=n?Math.max(x+2,4):Math.max(x,1);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const $=d.current?.getBoundingClientRect();return $?{cellWidth:$.width/on,cellHeight:Tn}:null},e[1]=b):b=e[1];const _=b;let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=$=>{u(String($.active.id)),m(_())},e[2]=y):y=e[2];const L=y;let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=$=>{const B=String($.active.id),z=f??_();if(u(null),m(null),!z||z.cellWidth<=0)return;const K=s.find(q=>q.id===B);if(!K)return;const Y=Math.round($.delta.x/z.cellWidth),Q=Math.round($.delta.y/z.cellHeight);Y===0&&Q===0||o(B,{x:K.x+Y,y:K.y+Q})},e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6];const j=w;if(c){let $;if(e[7]!==i||e[8]!==s){let z;e[10]!==i?(z=K=>r.jsx("div",{className:"group bg-card card-shadow rounded-2xl overflow-hidden",style:{minHeight:Tn},children:r.jsx(Zd,{children:i(K)})},K.id),e[10]=i,e[11]=z):z=e[11],$=s.map(z),e[7]=i,e[8]=s,e[9]=$}else $=e[9];let B;return e[12]!==$?(B=r.jsx("div",{className:"flex flex-col gap-3 px-4 pb-8",children:$}),e[12]=$,e[13]=B):B=e[13],B}let S,k,C,A,P,V,T,R,E,I;if(e[14]!==h||e[15]!==f||e[16]!==n||e[17]!==j||e[18]!==l||e[19]!==a||e[20]!==i||e[21]!==g||e[22]!==s||e[23]!==v){const $=h?s.find(U=>U.id===h):null;k=Sc,I=g,C=L,A=j;const B=v*Tn,z=n?Tn*4:Tn;let K;e[34]!==B||e[35]!==z?(K={height:B,minHeight:z},e[34]=B,e[35]=z,e[36]=K):K=e[36];let Y;e[37]!==n||e[38]!==s||e[39]!==v?(Y=n&&r.jsx(AV,{rows:v,tiles:s}),e[37]=n,e[38]=s,e[39]=v,e[40]=Y):Y=e[40];let Q;if(e[41]!==h||e[42]!==n||e[43]!==l||e[44]!==a||e[45]!==i||e[46]!==s){let U;e[48]!==h||e[49]!==n||e[50]!==l||e[51]!==a||e[52]!==i?(U=X=>r.jsx(PV,{tile:X,isEditMode:n,isDragging:h===X.id,onResize:a,onRemove:l,children:i(X)},X.id),e[48]=h,e[49]=n,e[50]=l,e[51]=a,e[52]=i,e[53]=U):U=e[53],Q=s.map(U),e[41]=h,e[42]=n,e[43]=l,e[44]=a,e[45]=i,e[46]=s,e[47]=Q}else Q=e[47];e[54]!==K||e[55]!==Y||e[56]!==Q?(P=r.jsxs("div",{ref:d,className:"relative w-full",style:K,children:[Y,Q]}),e[54]=K,e[55]=Y,e[56]=Q,e[57]=P):P=e[57],E=Zs.createPortal,S=ou,V=null;const q=$&&f?$.w*f.cellWidth-xf:void 0,H=$&&f?$.h*f.cellHeight-xf:void 0;e[58]!==q||e[59]!==H?(T={width:q,height:H},e[58]=q,e[59]=H,e[60]=T):T=e[60],R=$&&r.jsx("div",{className:"bg-card card-shadow rounded-2xl shadow-2xl ring-2 ring-primary/40 h-full overflow-hidden opacity-95",children:r.jsx(Zd,{children:i($)})}),e[14]=h,e[15]=f,e[16]=n,e[17]=j,e[18]=l,e[19]=a,e[20]=i,e[21]=g,e[22]=s,e[23]=v,e[24]=S,e[25]=k,e[26]=C,e[27]=A,e[28]=P,e[29]=V,e[30]=T,e[31]=R,e[32]=E,e[33]=I}else S=e[24],k=e[25],C=e[26],A=e[27],P=e[28],V=e[29],T=e[30],R=e[31],E=e[32],I=e[33];let D;e[61]!==S||e[62]!==V||e[63]!==T||e[64]!==R?(D=r.jsx(S,{dropAnimation:V,style:T,children:R}),e[61]=S,e[62]=V,e[63]=T,e[64]=R,e[65]=D):D=e[65];let M;e[66]!==D||e[67]!==E?(M=E(D,document.body),e[66]=D,e[67]=E,e[68]=M):M=e[68];let O;return e[69]!==k||e[70]!==C||e[71]!==A||e[72]!==P||e[73]!==M||e[74]!==I?(O=r.jsxs(k,{sensors:I,onDragStart:C,onDragEnd:A,children:[P,M]}),e[69]=k,e[70]=C,e[71]=A,e[72]=P,e[73]=M,e[74]=I,e[75]=O):O=e[75],O}function TV(t,e){return Math.max(t,e.y+e.h)}function AV(t){const e=F.c(7),{rows:s,tiles:n}=t;let i;e[0]!==n?(i=(c,d)=>n.some(h=>c>=h.x&&c<h.x+h.w&&d>=h.y&&d<h.y+h.h),e[0]=n,e[1]=i):i=e[1];const o=i;let a;if(e[2]!==o||e[3]!==s){a=[];for(let c=0;c<s;c++)for(let d=0;d<on;d++)o(d,c)||a.push({x:d,y:c});e[2]=o,e[3]=s,e[4]=a}else a=e[4];let l;return e[5]!==a?(l=r.jsx("div",{className:"absolute inset-0 pointer-events-none",children:a.map(EV)}),e[5]=a,e[6]=l):l=e[6],l}function EV(t){return r.jsx("div",{className:"absolute p-1",style:{left:`${t.x/on*100}%`,top:t.y*Tn,width:`${1/on*100}%`,height:Tn},children:r.jsx("div",{className:"h-full w-full rounded-2xl border border-dashed border-border/60"})},`${t.x}-${t.y}`)}function PV(t){const e=F.c(32),{tile:s,isEditMode:n,isDragging:i,onResize:o,onRemove:a,children:l}=t,c=oe(),d=!n;let h;e[0]!==d||e[1]!==s.id?(h={id:s.id,disabled:d},e[0]=d,e[1]=s.id,e[2]=h):h=e[2];const{setNodeRef:u,attributes:f,listeners:m,isDragging:p}=eg(h),g=`${s.x/on*100}%`,x=`${s.w/on*100}%`,v=s.y*Tn,b=s.h*Tn,_=p||i,y=!_&&"transition-[left,top,width,height,opacity] duration-200 ease-out",L=_&&"opacity-30";let w;e[3]!==y||e[4]!==L?(w=ie("absolute p-1 will-change-[left,top,width,height,opacity]",y,L),e[3]=y,e[4]=L,e[5]=w):w=e[5];let j;e[6]!==b||e[7]!==g||e[8]!==v||e[9]!==x?(j={left:g,top:v,width:x,height:b},e[6]=b,e[7]=g,e[8]=v,e[9]=x,e[10]=j):j=e[10];const S=n&&"outline outline-1 outline-transparent hover:outline-primary/40";let k;e[11]!==S?(k=ie("group relative h-full bg-card card-shadow rounded-2xl overflow-hidden",S),e[11]=S,e[12]=k):k=e[12];let C;e[13]!==f||e[14]!==n||e[15]!==m||e[16]!==a||e[17]!==o||e[18]!==c||e[19]!==s?(C=n&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",...f,...m,className:"absolute top-2 left-2 z-10 flex size-8 items-center justify-center rounded-md bg-background/90 border border-border text-muted-foreground hover:text-foreground hover:bg-muted cursor-grab active:cursor-grabbing","aria-label":c("home.tileBoard.dragTileAriaLabel"),children:r.jsx(ca,{size:16})}),r.jsx("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-1",children:r.jsx(RV,{tile:s,onResize:o,onRemove:a})})]}),e[13]=f,e[14]=n,e[15]=m,e[16]=a,e[17]=o,e[18]=c,e[19]=s,e[20]=C):C=e[20];let A;e[21]!==l?(A=r.jsx("div",{className:"h-full overflow-hidden",children:r.jsx(Zd,{children:l})}),e[21]=l,e[22]=A):A=e[22];let P;e[23]!==A||e[24]!==k||e[25]!==C?(P=r.jsxs("div",{className:k,children:[C,A]}),e[23]=A,e[24]=k,e[25]=C,e[26]=P):P=e[26];let V;return e[27]!==u||e[28]!==P||e[29]!==w||e[30]!==j?(V=r.jsx("div",{ref:u,className:w,style:j,children:P}),e[27]=u,e[28]=P,e[29]=w,e[30]=j,e[31]=V):V=e[31],V}function RV(t){const e=F.c(28),{tile:s,onResize:n,onRemove:i}=t,[o,a]=N.useState(!1),l=oe();let c;e[0]!==l?(c=l("home.tileBoard.tileOptionsAriaLabel"),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Ki,{size:16}),e[2]=d):d=e[2];let h;e[3]!==c?(h=r.jsx(bs,{asChild:!0,children:r.jsx("button",{type:"button",className:"flex size-8 items-center justify-center rounded-md bg-background/90 border border-border text-muted-foreground hover:text-foreground hover:bg-muted","aria-label":c,children:d})}),e[3]=c,e[4]=h):h=e[4];let u;e[5]!==n||e[6]!==s.id?(u=y=>{n(s.id,y),a(!1)},e[5]=n,e[6]=s.id,e[7]=u):u=e[7];let f;e[8]!==u||e[9]!==s?(f=r.jsx(DV,{tile:s,onPick:u}),e[8]=u,e[9]=s,e[10]=f):f=e[10];let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Xn,{}),e[11]=m):m=e[11];let p;e[12]!==i||e[13]!==s.id?(p=()=>i(s.id),e[12]=i,e[13]=s.id,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(_s,{size:14,className:"mr-2"}),e[15]=g):g=e[15];let x;e[16]!==l?(x=l("home.tileBoard.removeTile"),e[16]=l,e[17]=x):x=e[17];let v;e[18]!==p||e[19]!==x?(v=r.jsxs(Je,{onSelect:p,className:"text-destructive focus:text-destructive",children:[g,x]}),e[18]=p,e[19]=x,e[20]=v):v=e[20];let b;e[21]!==v||e[22]!==f?(b=r.jsxs(ys,{align:"end",className:"w-auto",children:[f,m,v]}),e[21]=v,e[22]=f,e[23]=b):b=e[23];let _;return e[24]!==o||e[25]!==b||e[26]!==h?(_=r.jsxs(vs,{open:o,onOpenChange:a,children:[h,b]}),e[24]=o,e[25]=b,e[26]=h,e[27]=_):_=e[27],_}function DV(t){const e=F.c(26),{tile:s,onPick:n}=t,i=s.minW??1,o=s.minH??1,[a,l]=N.useState(null);let c;e[0]!==a||e[1]!==s.h||e[2]!==s.w?(c=a??{w:s.w,h:s.h},e[0]=a,e[1]=s.h,e[2]=s.w,e[3]=c):c=e[3];const d=c,h=oe();let u;e[4]!==h?(u=h("home.tileBoard.sizeLabel"),e[4]=h,e[5]=u):u=e[5];let f;e[6]!==u?(f=r.jsx("span",{className:"text-xs text-muted-foreground",children:u}),e[6]=u,e[7]=f):f=e[7];let m;e[8]!==d.h||e[9]!==d.w?(m=r.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[d.w," × ",d.h]}),e[8]=d.h,e[9]=d.w,e[10]=m):m=e[10];let p;e[11]!==f||e[12]!==m?(p=r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-4",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13];let g,x;e[14]===Symbol.for("react.memo_cache_sentinel")?(g={gridTemplateColumns:`repeat(${on}, 1.25rem)`},x=()=>l(null),e[14]=g,e[15]=x):(g=e[14],x=e[15]);let v;e[16]!==d.h||e[17]!==d.w||e[18]!==o||e[19]!==i||e[20]!==n||e[21]!==h?(v=r.jsx("div",{className:"grid w-max gap-1",style:g,onPointerLeave:x,children:Array.from({length:jV},(_,y)=>Array.from({length:on},(L,w)=>{const j=w+1,S=y+1,k=j<i||S<o,C=j<=d.w&&S<=d.h;return r.jsx("button",{type:"button",disabled:k,"aria-label":h("home.tileBoard.sizeGridCellAriaLabel",{w:j,h:S}),onPointerEnter:()=>l({w:j,h:S}),onClick:()=>n({w:j,h:S}),className:ie("size-5 rounded-sm border transition-colors",C?"border-primary bg-primary/30":"border-border bg-muted",k?"cursor-not-allowed opacity-40":"cursor-pointer hover:border-primary/60")},`${j}x${S}`)}))}),e[16]=d.h,e[17]=d.w,e[18]=o,e[19]=i,e[20]=n,e[21]=h,e[22]=v):v=e[22];let b;return e[23]!==p||e[24]!==v?(b=r.jsxs("div",{className:"px-2 py-1.5",children:[p,v]}),e[23]=p,e[24]=v,e[25]=b):b=e[25],b}function IV(t,e,s){return t.some(n=>e>=n.x&&e<n.x+n.w&&s>=n.y&&s<n.y+n.h)}function e0(t,e,s){for(let n=0;n<100;n++)for(let i=0;i<=on-e;i++){let o=!0;for(let a=0;a<s&&o;a++)for(let l=0;l<e&&o;l++)IV(t,i+l,n+a)&&(o=!1);if(o)return{x:i,y:n}}return{x:0,y:0}}function rd(t,e,s={w:1,h:1}){const n=Math.max(s.w,Math.min(on,t)),i=Math.max(s.h,Math.min(6,e));return{w:n,h:i}}function od(t,e,s){const n=Math.max(0,Math.min(on-s,t)),i=Math.max(0,e);return{x:n,y:i}}function MV(t,e,s){const n=t.find(c=>c.id===e);if(!n)return t;const i=t.filter(c=>c.id!==e),o=i.find(c=>s.x>=c.x&&s.x<c.x+c.w&&s.y>=c.y&&s.y<c.y+c.h);if(o&&o.w===n.w&&o.h===n.h)return t.map(c=>c.id===e?{...c,x:o.x,y:o.y}:c.id===o.id?{...c,x:n.x,y:n.y}:c);const l=[{...n,x:s.x,y:s.y}];for(const c of i){const d=e0(l,c.w,c.h);l.push({...c,x:d.x,y:d.y})}return l}function OV(t){const e=F.c(42),{layout:s,isLayoutLoading:n,commitLayout:i}=Z9();let o;e[0]!==s.hidden?(o=new Set(s.hidden),e[0]=s.hidden,e[1]=o):o=e[1];const a=o;let l;e[2]!==s.shown?(l=s.shown??[],e[2]=s.shown,e[3]=l):l=e[3];let c;e[4]!==l?(c=new Set(l),e[4]=l,e[5]=c):c=e[5];const d=c;let h,u;if(e[6]!==t||e[7]!==a||e[8]!==s.tiles||e[9]!==d){u=[];let L;e[12]!==a||e[13]!==d?(L=j=>j.pinned?!0:j.defaultHidden?d.has(j.id)&&!a.has(j.id):!a.has(j.id),e[12]=a,e[13]=d,e[14]=L):L=e[14];const w=t.filter(L);h=new Map;for(const j of t)j.minSize&&h.set(j.id,j.minSize);for(const j of w){const S=s.tiles[j.id];if(!S)continue;const k=h.get(j.id),{w:C,h:A}=rd(S.w,S.h,k),{x:P,y:V}=od(S.x,S.y,C);u.push({id:j.id,x:P,y:V,w:C,h:A,minW:k?.w,minH:k?.h})}for(const j of w){if(u.some(V=>V.id===j.id))continue;const S=j.defaultSize??CV,k=h.get(j.id),{w:C,h:A}=rd(S.w,S.h,k),P=e0(u,C,A);u.push({id:j.id,x:P.x,y:P.y,w:C,h:A,minW:k?.w,minH:k?.h})}e[6]=t,e[7]=a,e[8]=s.tiles,e[9]=d,e[10]=h,e[11]=u}else h=e[10],u=e[11];let f;e[15]!==t?(f=new Set(t.map($V)),e[15]=t,e[16]=f):f=e[16];const m=f;let p;e[17]!==m||e[18]!==i||e[19]!==s?(p=(L,w)=>{const j={};for(const S of L)j[S.id]={x:S.x,y:S.y,w:S.w,h:S.h};i({version:Sr,tiles:j,hidden:w.filter(S=>m.has(S)),shown:(s.shown??[]).filter(S=>m.has(S))})},e[17]=m,e[18]=i,e[19]=s,e[20]=p):p=e[20];const g=p;let x;e[21]!==u?(x={visible:u},e[21]=u,e[22]=x):x=e[22];let v;e[23]!==g||e[24]!==s||e[25]!==u?(v=(L,w)=>{const j=u.find(C=>C.id===L);if(!j)return;const S=od(w.x,w.y,j.w);if(S.x===j.x&&S.y===j.y)return;const k=MV(u,L,S);g(k,s.hidden)},e[23]=g,e[24]=s,e[25]=u,e[26]=v):v=e[26];let b;e[27]!==g||e[28]!==s||e[29]!==h||e[30]!==u?(b=(L,w)=>{const j=u.find(T=>T.id===L);if(!j)return;const S=h.get(L),{w:k,h:C}=rd(w.w,w.h,S);if(k===j.w&&C===j.h)return;const A={...j,w:k,h:C,x:od(j.x,j.y,k).x},P=u.filter(T=>T.id!==L),V=[A];for(const T of P){const R=e0(V,T.w,T.h);V.push({...T,x:R.x,y:R.y})}g(V,s.hidden)},e[27]=g,e[28]=s,e[29]=h,e[30]=u,e[31]=b):b=e[31];let _;e[32]!==g||e[33]!==s||e[34]!==u?(_=L=>{const w=u.filter(j=>j.id!==L);g(w,Array.from(new Set([...s.hidden,L])))},e[32]=g,e[33]=s,e[34]=u,e[35]=_):_=e[35];let y;return e[36]!==n||e[37]!==x||e[38]!==v||e[39]!==b||e[40]!==_?(y={snapshot:x,isLoading:n,moveTile:v,resizeTile:b,hideTile:_},e[36]=n,e[37]=x,e[38]=v,e[39]=b,e[40]=_,e[41]=y):y=e[41],y}function $V(t){return t.id}const BV=3,FV=5;function zV(t){const e=F.c(17),{org:s}=ze();let n;e[0]!==s.id||e[1]!==s.slug?(n={connectionId:Xl,orgId:s.id,orgSlug:s.slug},e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const i=pt(n);let o;e[3]!==t||e[4]!==s.id||e[5]!==s.slug?(o={connectionId:t,orgId:s.id,orgSlug:s.slug},e[3]=t,e[4]=s.id,e[5]=s.slug,e[6]=o):o=e[6];const a=pt(o);let l;e[7]!==t||e[8]!==s.id?(l=Qe.homeGithubRecentPrs(s.id,t),e[7]=t,e[8]=s.id,e[9]=l):l=e[9];let c;e[10]!==t||e[11]!==a||e[12]!==i?(c=async()=>{const{installations:h}=await X2(b=>i.callTool(b),t),u=h[0];if(!u)return{repos:[]};const f=u.type==="User"?"user":"org",p=(await a.callTool({name:"search_repositories",arguments:{query:`${f}:${u.login}`,page:1,perPage:30}})).content?.[0]?.text,x=[...p?JSON.parse(p).items??[]:[]].sort(qV).filter(WV).slice(0,BV);return x.length===0?{repos:[]}:{repos:(await Promise.all(x.map(async b=>{const[_,y]=b.full_name.split("/"),L=await a.callTool({name:"list_pull_requests",arguments:{owner:_,repo:y,state:"all",perPage:FV}}),w=cc(L).map(HV).filter(UV);return{repo:b.full_name,prs:w}}))).filter(KV)}},e[10]=t,e[11]=a,e[12]=i,e[13]=c):c=e[13];let d;return e[14]!==l||e[15]!==c?(d={queryKey:l,queryFn:c,staleTime:6e4,retry:!1},e[14]=l,e[15]=c,e[16]=d):d=e[16],Pt(d)}function KV(t){return t.prs.length>0}function UV(t){return t.number>0}function HV(t){return{number:t.number??0,title:t.title??"",merged:t.merged_at!=null,state:t.state==="closed"?"closed":"open",htmlUrl:t.html_url??""}}function WV(t){return t.full_name}function qV(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}const fr=26,GV=7;function YV(t){const e=F.c(17),{org:s}=ze();let n;e[0]!==s.id||e[1]!==s.slug?(n={connectionId:Xl,orgId:s.id,orgSlug:s.slug},e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const i=pt(n);let o;e[3]!==t||e[4]!==s.id||e[5]!==s.slug?(o={connectionId:t,orgId:s.id,orgSlug:s.slug},e[3]=t,e[4]=s.id,e[5]=s.slug,e[6]=o):o=e[6];const a=pt(o);let l;e[7]!==t||e[8]!==s.id?(l=Qe.homeGithubContributions(s.id,t),e[7]=t,e[8]=s.id,e[9]=l):l=e[9];let c;e[10]!==t||e[11]!==a||e[12]!==i?(c=async()=>{const{installations:h}=await X2(k=>i.callTool(k),t),u=h[0];if(!u)return ad();const f=u.type==="User"?"user":"org",p=(await a.callTool({name:"search_repositories",arguments:{query:`${f}:${u.login}`,page:1,perPage:30}})).content?.[0]?.text,x=[...p?JSON.parse(p).items??[]:[]].sort(JV)[0];if(!x?.full_name)return ad();const[v,b]=x.full_name.split("/"),_=new Date(Date.now()-fr*7*864e5),L=(await a.callTool({name:"list_commits",arguments:{owner:v,repo:b,since:_.toISOString(),perPage:100}})).content?.[0]?.text,w=L?JSON.parse(L):[],j=ad(),S=Date.now();for(const k of w){const C=k.commit?.committer?.date??k.commit?.author?.date??"",A=new Date(C);if(isNaN(A.getTime()))continue;const P=Math.floor((S-A.getTime())/864e5);if(P<0||P>=fr*7)continue;const V=fr-1-Math.floor(P/7),T=A.getDay(),R=j[V];R&&(R[T]=(R[T]??0)+1)}return j},e[10]=t,e[11]=a,e[12]=i,e[13]=c):c=e[13];let d;return e[14]!==l||e[15]!==c?(d={queryKey:l,queryFn:c,staleTime:3e5,retry:!1},e[14]=l,e[15]=c,e[16]=d):d=e[16],Pt(d)}function JV(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function ad(){return Array.from({length:fr},()=>Array.from({length:GV},()=>0))}const sg="pageviews",ng="sessions",ig="orders",rg="coding",og="revenue",ag="recent-conversations",au=[{id:sg,titleKey:"home.nativeTiles.pageviews",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:ng,titleKey:"home.nativeTiles.sessions",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:ig,titleKey:"home.nativeTiles.orders",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:og,titleKey:"home.nativeTiles.revenue",defaultSize:{w:3,h:3},minSize:{w:2,h:2}},{id:rg,titleKey:"home.nativeTiles.coding",defaultSize:{w:3,h:3},minSize:{w:2,h:2}},{id:ag,titleKey:"home.nativeTiles.recentConversations",defaultSize:{w:6,h:4},minSize:{w:2,h:2},defaultHidden:!0}];function lg(t){return`native:${t}`}function cg(t){const e=F.c(21),{points:s,metricLabel:n}=t,i=N.useId();let o;if(e[0]!==i){let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=/:/g,e[2]=b):b=e[2],o=i.replace(b,""),e[0]=i,e[1]=o}else o=e[1];const a=o;let l;e[3]!==n?(l={value:{label:n,color:"var(--success)"}},e[3]=n,e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c={top:6,right:0,bottom:0,left:0},e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("line",{x1:0,y1:0,x2:0,y2:8,stroke:"var(--success)",strokeOpacity:.22,strokeWidth:4}),e[6]=d):d=e[6];let h;e[7]!==a?(h=r.jsx("defs",{children:r.jsx("pattern",{id:a,width:6,height:8,patternUnits:"userSpaceOnUse",children:d})}),e[7]=a,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Iv,{dataKey:"label",hide:!0}),e[9]=u):u=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Mv,{cursor:{stroke:"var(--border)"},content:r.jsx(Ov,{indicator:"line"})}),e[10]=f):f=e[10];const m=`url(#${a})`;let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p={r:4,fill:"var(--success)",stroke:"var(--background)",strokeWidth:2},e[11]=p):p=e[11];let g;e[12]!==m?(g=r.jsx($v,{type:"monotone",dataKey:"value",stroke:"var(--success)",strokeWidth:2,fill:m,fillOpacity:1,animationDuration:350,dot:!1,activeDot:p}),e[12]=m,e[13]=g):g=e[13];let x;e[14]!==s||e[15]!==g||e[16]!==h?(x=r.jsxs(Bv,{data:s,margin:c,children:[h,u,f,g]}),e[14]=s,e[15]=g,e[16]=h,e[17]=x):x=e[17];let v;return e[18]!==x||e[19]!==l?(v=r.jsx(Fv,{config:l,className:"h-full w-full",children:x}),e[18]=x,e[19]=l,e[20]=v):v=e[20],v}const dg={pageviews:{value:"12.2k",delta:"+1.9%",series:[9800,10100,9950,10600,10400,11e3,11200,11500,11900,12200]},sessions:{value:"3.2k",delta:"+25.6%",series:[2100,2250,2200,2500,2600,2750,2900,3e3,3100,3200]},orders:{value:"142",delta:"+8.4%",series:[96,102,99,110,108,118,124,131,137,142]},revenue:{value:"$8,240",delta:"+12.0%",series:[6100,6400,6250,6800,6700,7100,7400,7700,8e3,8240]}};function ug(t,e){return t.map((s,n)=>{const i=t.length-1-n;return{label:i===0?e("home.nativeTiles.today"):i===1?e("home.nativeTiles.yesterday"):e("home.nativeTiles.daysAgo",{days:i}),value:s}})}function hg(t){const e=F.c(8),{value:s,delta:n}=t;let i;e[0]!==s?(i=r.jsx("span",{className:"text-2xl font-medium tabular-nums text-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(J2,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==n?(a=r.jsxs("span",{className:"inline-flex items-center gap-1 text-sm font-medium tabular-nums text-success",children:[o,n]}),e[3]=n,e[4]=a):a=e[4];let l;return e[5]!==i||e[6]!==a?(l=r.jsxs("div",{className:"mt-3 flex items-center gap-2.5",children:[i,a]}),e[5]=i,e[6]=a,e[7]=l):l=e[7],l}function XV(t,e){const s=(t*31+e*17+7)%100;return s<38?0:s<60?1+s%2:s<80?3+s%3:s<93?6+s%3:9+s%4}function QV(t){return t===0?"bg-muted-foreground/15":t<=2?"bg-success/25":t<=5?"bg-success/45":t<=8?"bg-success/70":"bg-success"}function fg(t){const e=F.c(4),{grid:s}=t,n=oe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={gridTemplateColumns:`repeat(${fr}, 1fr)`},e[0]=i):i=e[0];let o;return e[1]!==s||e[2]!==n?(o=r.jsx(Ti,{delayDuration:0,children:r.jsx("div",{className:"grid w-full gap-1",style:i,children:Array.from({length:fr},(a,l)=>r.jsx("div",{className:"flex flex-col gap-1",children:Array.from({length:5},(c,d)=>{const h=s?s[l]?.[d]??0:XV(l,d);return r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx("div",{className:ie("aspect-square rounded-[2px]",QV(h))})}),r.jsx(He,{children:h===0?n("home.nativeTiles.noCommits"):n("home.nativeTiles.commits",{count:h})})]},d)})},l))})}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function lu(t){const e=F.c(8),{label:s,icon:n,onConnect:i,pending:o}=t;let a;e[0]!==n||e[1]!==o?(a=o?r.jsx(Ze,{className:"size-4 animate-spin"}):n,e[0]=n,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==s||e[4]!==i||e[5]!==o||e[6]!==a?(l=r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/30 backdrop-blur-[2px]",children:r.jsxs(le,{size:"sm",onClick:i,disabled:o,className:"gap-2 shadow-sm",children:[a,s]})}),e[3]=s,e[4]=i,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function mg(t){const e=F.c(6),{label:s}=t,n=oe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ic,{className:"size-6 text-success/60"}),e[0]=i):i=e[0];let o;e[1]!==s||e[2]!==n?(o=n("home.nativeTiles.connectedSoon",{label:s}),e[1]=s,e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==o?(a=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-center",children:[i,r.jsx("p",{className:"text-xs text-muted-foreground",children:o})]}),e[4]=o,e[5]=a):a=e[5],a}function vf(t){const e=F.c(22),{metricKey:s}=t,n=oe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={slug:"google-analytics"},e[0]=i):i=e[0];const o=Mn(i).length>0,{connect:a,isConnecting:l}=n2("deco/google-analytics"),c=dg[s];if(o||!c){let x;return e[1]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(mg,{label:"Analytics"}),e[1]=x):x=e[1],x}let d;e[2]!==c.series||e[3]!==n?(d=ug(c.series,n),e[2]=c.series,e[3]=n,e[4]=d):d=e[4];let h;e[5]!==s||e[6]!==d?(h=r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(cg,{points:d,metricLabel:s})}),e[5]=s,e[6]=d,e[7]=h):h=e[7];let u;e[8]!==c.delta||e[9]!==c.value?(u=r.jsx(hg,{value:c.value,delta:c.delta}),e[8]=c.delta,e[9]=c.value,e[10]=u):u=e[10];let f;e[11]!==n?(f=n("home.nativeTiles.connectGoogleAnalytics"),e[11]=n,e[12]=f):f=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(i2,{className:"size-4"}),e[13]=m):m=e[13];let p;e[14]!==a||e[15]!==l||e[16]!==f?(p=r.jsx(lu,{label:f,icon:m,onConnect:a,pending:l}),e[14]=a,e[15]=l,e[16]=f,e[17]=p):p=e[17];let g;return e[18]!==h||e[19]!==u||e[20]!==p?(g=r.jsxs("div",{className:"relative flex h-full flex-col",children:[h,u,p]}),e[18]=h,e[19]=u,e[20]=p,e[21]=g):g=e[21],g}function bf(t){const e=F.c(27),{metricKey:s}=t,n=oe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={slug:"vtex"},e[0]=i):i=e[0];const o=Mn(i);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={slug:"shopify"},e[1]=a):a=e[1];const l=Mn(a),c=o.length>0||l.length>0,[d,h]=N.useState(!1),u=dg[s];if(c||!u){let w;return e[2]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(mg,{label:"Commerce"}),e[2]=w):w=e[2],w}let f;e[3]!==u.series||e[4]!==n?(f=ug(u.series,n),e[3]=u.series,e[4]=n,e[5]=f):f=e[5];let m;e[6]!==s||e[7]!==f?(m=r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(cg,{points:f,metricLabel:s})}),e[6]=s,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==u.delta||e[10]!==u.value?(p=r.jsx(hg,{value:u.value,delta:u.delta}),e[9]=u.delta,e[10]=u.value,e[11]=p):p=e[11];let g;e[12]!==n?(g=n("home.nativeTiles.connectCommercePlatform"),e[12]=n,e[13]=g):g=e[13];let x,v;e[14]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(w9,{className:"size-4"}),v=()=>h(!0),e[14]=x,e[15]=v):(x=e[14],v=e[15]);let b;e[16]!==g?(b=r.jsx(lu,{label:g,icon:x,onConnect:v}),e[16]=g,e[17]=b):b=e[17];let _;e[18]!==m||e[19]!==p||e[20]!==b?(_=r.jsxs("div",{className:"relative flex h-full flex-col",children:[m,p,b]}),e[18]=m,e[19]=p,e[20]=b,e[21]=_):_=e[21];let y;e[22]!==d?(y=r.jsx(p9,{mode:"browse",open:d,onOpenChange:h,defaultTab:"all",initialSearch:"shopify vtex"}),e[22]=d,e[23]=y):y=e[23];let L;return e[24]!==_||e[25]!==y?(L=r.jsxs(r.Fragment,{children:[_,y]}),e[24]=_,e[25]=y,e[26]=L):L=e[26],L}function ZV(){const t=F.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={slug:"mcp-github"},t[0]=e):e=t[0];const s=Mn(e);let n;t[1]!==s?(n=w8(s),t[1]=s,t[2]=n):n=t[2];const i=n[0];let o;return t[3]!==i?(o=i?r.jsx(tN,{connectionId:i.id}):r.jsx(eN,{}),t[3]=i,t[4]=o):o=t[4],o}function eN(){const t=F.c(8),e=oe(),{connect:s,isConnecting:n}=n2("deco/mcp-github");let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(fg,{})}),t[0]=i):i=t[0];let o;t[1]!==e?(o=e("home.nativeTiles.connectGithub"),t[1]=e,t[2]=o):o=t[2];let a;t[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Uo,{className:"size-4"}),t[3]=a):a=t[3];let l;return t[4]!==s||t[5]!==n||t[6]!==o?(l=r.jsxs("div",{className:"relative flex h-full flex-col",children:[i,r.jsx(lu,{label:o,icon:a,onConnect:s,pending:n})]}),t[4]=s,t[5]=n,t[6]=o,t[7]=l):l=t[7],l}function tN(t){const e=F.c(9),{connectionId:s}=t,n=oe(),{data:i,isLoading:o}=zV(s),{data:a}=YV(s);let l;e[0]!==a?(l=r.jsx(fg,{grid:a}),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==i||e[3]!==o||e[4]!==n?(c=o?r.jsx("div",{className:"flex flex-col gap-1.5",children:Array.from({length:3},nN)}):!i||i.repos.length===0?r.jsx("p",{className:"text-xs text-muted-foreground",children:n("home.nativeTiles.noRecentPullRequests")}):r.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto",children:i.repos.map(sN)}),e[2]=i,e[3]=o,e[4]=n,e[5]=c):c=e[5];let d;return e[6]!==l||e[7]!==c?(d=r.jsxs("div",{className:"flex h-full flex-col gap-3 overflow-hidden",children:[l,c]}),e[6]=l,e[7]=c,e[8]=d):d=e[8],d}function sN(t){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:t.repo}),t.prs.map(e=>r.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 rounded-md px-1.5 py-1.5 text-sm transition-colors hover:bg-accent/60",children:[r.jsx(en,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate text-foreground",children:e.title}),r.jsxs("span",{className:ie("ml-auto shrink-0 rounded-full px-1.5 py-0.5 text-xs font-medium",e.merged?"bg-success/10 text-success":"bg-muted text-muted-foreground"),children:["#",e.number]})]},`${t.repo}#${e.number}`))]},t.repo)}function nN(t,e){return r.jsx("div",{className:"h-5 w-full animate-pulse rounded-md bg-muted/40"},`pr-skeleton-${e}`)}const iN={completed:{labelKey:"home.nativeTiles.statusCompleted",className:"text-success"},in_progress:{labelKey:"home.nativeTiles.statusRunning",className:"text-foreground"},requires_action:{labelKey:"home.nativeTiles.statusNeedsInput",className:"text-foreground"},failed:{labelKey:"home.nativeTiles.statusFailed",className:"text-destructive"},expired:{labelKey:"home.nativeTiles.statusExpired",className:"text-muted-foreground"}};function rN(){const t=F.c(14),e=oe(),{org:s,locator:n}=ze(),i=Fs(),o=jt(),{data:a}=Q2(),l=a?.data?.members??[],c=new Map(l.map(oN));let d;t[0]!==n?(d=Qe.overviewThreads(n),t[0]=n,t[1]=d):d=t[1];let h;t[2]!==i?(h=async()=>(await i.call("COLLECTION_THREADS_LIST",{limit:12})).items??[],t[2]=i,t[3]=h):h=t[3];let u;t[4]!==d||t[5]!==h?(u={queryKey:d,queryFn:h,staleTime:3e4},t[4]=d,t[5]=h,t[6]=u):u=t[6];const{data:f}=Pm(u);if(f.length===0){let x;t[7]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(o9,{className:"size-6 text-muted-foreground/50"}),t[7]=x):x=t[7];let v;t[8]!==e?(v=e("home.nativeTiles.noConversationsYet"),t[8]=e,t[9]=v):v=t[9];let b;return t[10]!==v?(b=r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-center",children:[x,r.jsx("p",{className:"text-xs text-muted-foreground",children:v})]}),t[10]=v,t[11]=b):b=t[11],b}const m="flex h-full flex-col gap-0.5 overflow-y-auto",p=f.map(x=>{const v=c.get(x.created_by),b=v?.user?.name??v?.user?.email?.split("@")[0]??"Someone",_=x.status?iN[x.status]:void 0,y=x.updated_at?Y2(new Date(x.updated_at)):null;return r.jsxs("button",{type:"button",onClick:()=>o({to:"/$org/$taskId",params:{org:s.slug,taskId:x.id},search:x.virtual_mcp_id?{virtualmcpid:x.virtual_mcp_id}:{}}),className:"flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent/60",children:[r.jsx(ur,{shape:"circle",size:"xs",url:v?.user?.image??void 0,fallback:b.slice(0,2).toUpperCase()}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:x.title||e("home.nativeTiles.untitledConversation")}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[b,y?` · ${y}`:""]})]}),_&&r.jsx("span",{className:ie("shrink-0 text-xs",_.className),children:e(_.labelKey)})]},x.id)});let g;return t[12]!==p?(g=r.jsx("div",{className:m,children:p}),t[12]=p,t[13]=g):g=t[13],g}function oN(t){return[t.userId,t]}function aN(t){const e=F.c(6),{nativeId:s}=t;switch(s){case sg:{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(vf,{metricKey:"pageviews"}),e[0]=n):n=e[0],n}case ng:{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(vf,{metricKey:"sessions"}),e[1]=n):n=e[1],n}case ig:{let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(bf,{metricKey:"orders"}),e[2]=n):n=e[2],n}case og:{let n;return e[3]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(bf,{metricKey:"revenue"}),e[3]=n):n=e[3],n}case rg:{let n;return e[4]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(ZV,{}),e[4]=n):n=e[4],n}case ag:{let n;return e[5]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(N.Suspense,{fallback:r.jsx("div",{className:"h-full animate-pulse bg-muted/30"}),children:r.jsx(rN,{})}),e[5]=n):n=e[5],n}default:return null}}function lN(t){const e=F.c(16),{nativeId:s}=t,n=oe();let i,o,a;if(e[0]!==s||e[1]!==n){let h;e[5]!==s?(h=f=>f.id===s,e[5]=s,e[6]=h):h=e[6];const u=au.find(h);a="flex h-full flex-col overflow-hidden p-4",i="shrink-0 text-xs font-medium text-muted-foreground",o=u?.titleKey?n(u.titleKey):n("home.nativeTiles.tile"),e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=a}else i=e[2],o=e[3],a=e[4];let l;e[7]!==i||e[8]!==o?(l=r.jsx("span",{className:i,children:o}),e[7]=i,e[8]=o,e[9]=l):l=e[9];let c;e[10]!==s?(c=r.jsx("div",{className:"relative mt-2 min-h-0 flex-1",children:r.jsx(aN,{nativeId:s})}),e[10]=s,e[11]=c):c=e[11];let d;return e[12]!==a||e[13]!==l||e[14]!==c?(d=r.jsxs("div",{className:a,children:[l,c]}),e[12]=a,e[13]=l,e[14]=c,e[15]=d):d=e[15],d}const cN={w:3,h:4},dN={w:1,h:2},uN={w:2,h:1};function hN(t){return`prompt:${t.agentId}:${t.promptName||"blank"}`}function fN(t){return t.tileId?`tile:${t.tileId}`:`tile:${t.agentId}:${t.resourceUri}`}function mN(t){return t.promptName?t.agentName:t.description}function pN(t){return{name:t.promptName,title:t.title,description:t.description,arguments:t.arguments,_meta:t._meta}}function pg(t){const e=F.c(14),{org:s}=ze();let n;e[0]!==s.id||e[1]!==s.slug||e[2]!==t.connectionId?(n=Dv({connectionId:t.connectionId,orgId:s.id,orgSlug:s.slug}),e[0]=s.id,e[1]=s.slug,e[2]=t.connectionId,e[3]=n):n=e[3];const{data:i}=Pt(n),o=!!i&&!t.toolName;let a;e[4]!==i||e[5]!==o?(a={client:i,enabled:o},e[4]=i,e[5]=o,e[6]=a):a=e[6];const{data:l}=y9(a);let c;e[7]!==t.resourceUri||e[8]!==t.toolName||e[9]!==l?.tools?(c=t.toolName??l?.tools.find(u=>oc(u._meta)===t.resourceUri)?.name,e[7]=t.resourceUri,e[8]=t.toolName,e[9]=l?.tools,e[10]=c):c=e[10];const d=c;let h;return e[11]!==t.connectionId||e[12]!==d?(h=d?Ja(t.connectionId,d):void 0,e[11]=t.connectionId,e[12]=d,e[13]=h):h=e[13],h}function cu(t){const e=F.c(10);let s;e[0]!==t?(s={agentId:t},e[0]=t,e[1]=s):s=e[1];const{start:n,startBlank:i,dialog:o,starting:a}=XC(s);let l;e[2]!==n||e[3]!==i?(l=h=>{if(!h.promptName){i();return}n(pN(h))},e[2]=n,e[3]=i,e[4]=l):l=e[4];const c=l;let d;return e[5]!==o||e[6]!==c||e[7]!==i||e[8]!==a?(d={open:c,startBlank:i,dialog:o,starting:a},e[5]=o,e[6]=c,e[7]=i,e[8]=a,e[9]=d):d=e[9],d}function gN(t){const e=F.c(32),{entry:s,isEditMode:n}=t,{open:i,dialog:o,starting:a}=cu(s.agentId);let l;e[0]!==s||e[1]!==i?(l=()=>i(s),e[0]=s,e[1]=i,e[2]=l):l=e[2];const c=a||n,d=!n&&"cursor-pointer transition-colors hover:bg-accent/40",h=n&&"cursor-default pl-12",u=a&&"opacity-60";let f;e[3]!==d||e[4]!==h||e[5]!==u?(f=ie("group/tile relative flex h-full w-full items-center gap-3 px-4 py-3 text-left bg-card",d,h,u),e[3]=d,e[4]=h,e[5]=u,e[6]=f):f=e[6];let m;e[7]!==s.agentIcon||e[8]!==s.agentName?(m=r.jsx(ii,{icon:s.agentIcon,name:s.agentName,size:"sm+"}),e[7]=s.agentIcon,e[8]=s.agentName,e[9]=m):m=e[9];let p;e[10]!==s.title?(p=r.jsx("div",{className:"line-clamp-2 text-sm font-medium text-foreground leading-snug",children:s.title}),e[10]=s.title,e[11]=p):p=e[11];let g;e[12]!==s?(g=mN(s),e[12]=s,e[13]=g):g=e[13];let x;e[14]!==g?(x=r.jsx("div",{className:"truncate text-xs text-muted-foreground mt-0.5",children:g}),e[14]=g,e[15]=x):x=e[15];let v;e[16]!==x||e[17]!==p?(v=r.jsxs("div",{className:"min-w-0 flex-1",children:[p,x]}),e[16]=x,e[17]=p,e[18]=v):v=e[18];let b;e[19]!==n?(b=!n&&r.jsx(Ar,{size:16,className:"shrink-0 text-muted-foreground opacity-0 -translate-x-1 transition-all duration-200 group-hover/tile:opacity-100 group-hover/tile:translate-x-0","aria-hidden":!0}),e[19]=n,e[20]=b):b=e[20];let _;e[21]!==a||e[22]!==l||e[23]!==v||e[24]!==b||e[25]!==c||e[26]!==f||e[27]!==m?(_=r.jsxs("button",{type:"button",onClick:l,disabled:c,"aria-busy":a,className:f,children:[m,v,b]}),e[21]=a,e[22]=l,e[23]=v,e[24]=b,e[25]=c,e[26]=f,e[27]=m,e[28]=_):_=e[28];let y;return e[29]!==o||e[30]!==_?(y=r.jsxs(r.Fragment,{children:[_,o]}),e[29]=o,e[30]=_,e[31]=y):y=e[31],y}function xN(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"mt-4 grid w-full grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:Array.from({length:3},vN)}),t[0]=e):e=t[0],e}function vN(t,e){return r.jsxs("div",{className:"flex w-full items-center gap-3 rounded-2xl bg-card card-shadow px-3 py-2.5",children:[r.jsx(Et,{className:"size-10 rounded-xl"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Et,{className:"h-3 w-2/3"}),r.jsx(Et,{className:"h-2.5 w-1/3"})]})]},`chip-skeleton-${e}`)}function bN(t){const e=F.c(18),{tile:s,prompts:n,isEditMode:i,tileWidth:o}=t,{org:a}=ze(),{open:l,startBlank:c,dialog:d,starting:h}=cu(s.agentId),u=n.filter(yN),f=pg(s),m=oe(),p="relative flex h-full w-full flex-col p-3";let g;e[0]!==i||e[1]!==f||e[2]!==c||e[3]!==h||e[4]!==m?(g=!i&&r.jsx("button",{type:"button",onClick:()=>{c(f?{main:f}:void 0)},disabled:h,"aria-busy":h,className:"mb-1 self-start rounded-md px-2 py-1 text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:m("home.homeGrid.openChat")}),e[0]=i,e[1]=f,e[2]=c,e[3]=h,e[4]=m,e[5]=g):g=e[5];const x="flex min-h-0 flex-1 gap-3 overflow-hidden";let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(LN,{}),e[6]=v):v=e[6];let b;e[7]!==a.id||e[8]!==a.slug||e[9]!==s?(b=r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden rounded-lg border border-border",children:r.jsx(N.Suspense,{fallback:v,children:r.jsx(_N,{tile:s,orgId:a.id,orgSlug:a.slug})})}),e[7]=a.id,e[8]=a.slug,e[9]=s,e[10]=b):b=e[10];const _=u.length>0&&!i&&o>=2&&r.jsx("div",{className:"flex w-44 shrink-0 flex-col gap-2 overflow-hidden",children:u.map(w=>r.jsx("button",{type:"button",onClick:()=>l(w),disabled:h,className:"shrink-0 rounded-lg border border-border bg-background px-2.5 py-2 text-left text-xs leading-snug text-foreground transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:r.jsx("span",{className:"line-clamp-2",children:w.title})},w.promptName))});let y;e[11]!==b||e[12]!==_?(y=r.jsxs("div",{className:x,children:[b,_]}),e[11]=b,e[12]=_,e[13]=y):y=e[13];let L;return e[14]!==d||e[15]!==g||e[16]!==y?(L=r.jsxs("div",{className:p,children:[g,y,d]}),e[14]=d,e[15]=g,e[16]=y,e[17]=L):L=e[17],L}function yN(t){return!!t.promptName}function _N(t){const e=F.c(13),{tile:s,orgId:n,orgSlug:i}=t;let o;e[0]!==n||e[1]!==i||e[2]!==s.connectionId?(o={connectionId:s.connectionId,orgId:n,orgSlug:i},e[0]=n,e[1]=i,e[2]=s.connectionId,e[3]=o):o=e[3];const a=pt(o),l=s.minHeight??200,c=s.maxHeight??4e3;let d;return e[4]!==a||e[5]!==n||e[6]!==i||e[7]!==l||e[8]!==c||e[9]!==s.connectionId||e[10]!==s.resourceUri||e[11]!==s.toolInput?(d=r.jsx(l8,{resourceURI:s.resourceUri,orgId:n,orgSlug:i,connectionId:s.connectionId,client:a,toolInput:s.toolInput,displayMode:"fullscreen",minHeight:l,maxHeight:c,className:"h-full"}),e[4]=a,e[5]=n,e[6]=i,e[7]=l,e[8]=c,e[9]=s.connectionId,e[10]=s.resourceUri,e[11]=s.toolInput,e[12]=d):d=e[12],d}function LN(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex h-full w-full flex-col gap-2 p-4",children:[r.jsx(Et,{className:"h-3 w-2/3"}),r.jsx(Et,{className:"h-3 w-1/2"}),r.jsx(Et,{className:"mt-1 h-full w-full rounded-md"})]}),t[0]=e):e=t[0],e}function SN(t){const e=F.c(18),{icon:s,name:n}=t,i=oe();let o;e[0]!==s||e[1]!==n?(o=r.jsx(ii,{icon:s,name:n,size:"sm+"}),e[0]=s,e[1]=n,e[2]=o):o=e[2];let a;e[3]!==n?(a=r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:n}),e[3]=n,e[4]=a):a=e[4];let l;e[5]!==i?(l=i("home.homeGrid.loadingTile"),e[5]=i,e[6]=l):l=e[6];let c;e[7]!==l?(c=r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l}),e[7]=l,e[8]=c):c=e[8];let d;e[9]!==a||e[10]!==c?(d=r.jsxs("div",{className:"min-w-0 flex-1",children:[a,c]}),e[9]=a,e[10]=c,e[11]=d):d=e[11];let h;e[12]!==o||e[13]!==d?(h=r.jsxs("div",{className:"flex items-center gap-2.5",children:[o,d]}),e[12]=o,e[13]=d,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsxs("div",{className:"flex flex-1 flex-col gap-2 pt-1",children:[r.jsx(Et,{className:"h-3 w-3/4"}),r.jsx(Et,{className:"h-3 w-1/2"}),r.jsx(Et,{className:"h-3 w-2/3"})]}),e[15]=u):u=e[15];let f;return e[16]!==h?(f=r.jsxs("div",{className:"flex h-full w-full flex-col gap-3 p-5 opacity-60",children:[h,u]}),e[16]=h,e[17]=f):f=e[17],f}function wN(t){const e=F.c(13),{tile:s,prompts:n,isEditMode:i}=t,o=oe(),{open:a,startBlank:l,dialog:c,starting:d}=cu(s.agentId),h=n.filter(jN),u=pg(s),f="flex h-full w-full flex-col gap-3 p-4";let m;e[0]!==u||e[1]!==l?(m=()=>{l(u?{main:u}:void 0)},e[0]=u,e[1]=l,e[2]=m):m=e[2];const p=d||i;let g;e[3]!==o?(g=o("home.homeGrid.openChat"),e[3]=o,e[4]=g):g=e[4];let x;e[5]!==m||e[6]!==p||e[7]!==g?(x=r.jsx("button",{type:"button",onClick:m,disabled:p,className:"mb-1 self-start rounded-md px-2 py-1 text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:g}),e[5]=m,e[6]=p,e[7]=g,e[8]=x):x=e[8];const v=h.length>0&&!i&&r.jsx("div",{className:"grid grid-cols-1 gap-2 overflow-hidden sm:grid-cols-2",children:h.map(_=>r.jsx("button",{type:"button",onClick:()=>!i&&a(_),disabled:d,className:"rounded-lg border border-border bg-background px-2.5 py-2 text-left text-xs leading-snug text-foreground transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:r.jsx("span",{className:"line-clamp-2",children:_.title})},_.promptName))});let b;return e[9]!==c||e[10]!==x||e[11]!==v?(b=r.jsxs("div",{className:f,children:[x,v,c]}),e[9]=c,e[10]=x,e[11]=v,e[12]=b):b=e[12],b}function jN(t){return!!t.promptName}function CN({isEditMode:t}){const e=oe(),{org:s}=ze(),{isLoading:n,prompts:i,tiles:o}=t2(s.slug),a=i.filter(S=>!th(S.agentId)),l=o.filter(S=>!th(S.agentId)),c=D2()?.ids??[],d=new Set(c),h=I2(),u=Fs(),f=Ls(),m=new Set(l.map(S=>S.agentId)),p=new Map;for(const S of a){const k=p.get(S.agentId);k?k.push(S):p.set(S.agentId,[S])}const g=a.filter(S=>!m.has(S.agentId)),x=[...l.map(S=>({kind:"tile",id:fN(S),data:S})),...g.map(S=>({kind:"prompt",id:hN(S),data:S})),...au.map(S=>({kind:"native",id:lg(S.id),data:S}))],v=new Map(x.map(S=>[S.id,S])),b=OV(x.map(S=>S.kind==="native"?{id:S.id,defaultSize:S.data.defaultSize,minSize:S.data.minSize,defaultHidden:S.data.defaultHidden}:{id:S.id,defaultSize:S.kind==="tile"?cN:uN,minSize:S.kind==="tile"?dN:void 0,pinned:d.has(S.data.agentId)})),_=S=>{h.apply(k=>k.filter(C=>C!==S)).catch(()=>ve.error(e("home.homeGrid.couldntRemoveFromHome")))},y=async S=>{if(l.filter(C=>C.agentId===S.agentId).length<=1){_(S.agentId);return}try{const A=(await u.call("COLLECTION_VIRTUAL_MCP_GET",{id:S.agentId})).item;if(!A)throw new Error("Agent not found");const P=xr(A.metadata?.ui),V=S.tileId?P.filter(T=>T.tileId!==S.tileId):P.filter(T=>T.connectionId!==S.connectionId||T.resourceUri!==S.resourceUri);await u.call("COLLECTION_VIRTUAL_MCP_UPDATE",{id:S.agentId,data:{metadata:{...A.metadata??{},ui:{...A.metadata?.ui??{},homeTile:null,homeTiles:V}}}}),f.invalidateQueries({queryKey:Qe.homeNextActions(s.slug)})}catch{ve.error(e("home.homeGrid.couldntRemoveTile"))}},L=S=>{const k=v.get(S);if(k){if(k.kind==="native"){b.hideTile(S);return}if(!d.has(k.data.agentId)){b.hideTile(S);return}k.kind==="tile"?y(k.data):_(k.data.agentId)}},w=S=>{const k=v.get(S.id);if(!k)return null;if(k.kind==="native")return r.jsx(lN,{nativeId:k.data.id});if(k.kind==="tile"){const C=p.get(k.data.agentId)??[];return r.jsx(hs,{fallback:r.jsx(wN,{tile:k.data,prompts:C,isEditMode:t}),children:r.jsx(N.Suspense,{fallback:r.jsx(SN,{icon:k.data.agentIcon,name:k.data.agentName}),children:r.jsx(bN,{tile:k.data,prompts:C,isEditMode:t,tileWidth:S.w})})})}return r.jsx(gN,{entry:k.data,isEditMode:t})};return n||b.isLoading?r.jsx(xN,{}):b.snapshot.visible.length===0&&!t?null:r.jsx("div",{className:"mt-4 flex w-full max-w-7xl flex-col gap-4",children:r.jsx(NV,{tiles:b.snapshot.visible,isEditMode:t,renderTile:w,onMove:b.moveTile,onResize:b.resizeTile,onRemove:L})})}function wr(t,e,s){const n=t.slice();return n.splice(s<0?n.length+s:s,0,n.splice(e,1)[0]),n}function kN(t,e){return t.reduce((s,n,i)=>{const o=e.get(n);return o&&(s[i]=o),s},Array(t.length))}function Ta(t){return t!==null&&t>=0}function VN(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}function NN(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const gg=t=>{let{rects:e,activeIndex:s,overIndex:n,index:i}=t;const o=wr(e,n,s),a=e[i],l=o[i];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},Aa={scaleX:1,scaleY:1},du=t=>{var e;let{activeIndex:s,activeNodeRect:n,index:i,rects:o,overIndex:a}=t;const l=(e=o[s])!=null?e:n;if(!l)return null;if(i===s){const d=o[a];return d?{x:0,y:s<a?d.top+d.height-(l.top+l.height):d.top-l.top,...Aa}:null}const c=TN(o,i,s);return i>s&&i<=a?{x:0,y:-l.height-c,...Aa}:i<s&&i>=a?{x:0,y:l.height+c,...Aa}:{x:0,y:0,...Aa}};function TN(t,e,s){const n=t[e],i=t[e-1],o=t[e+1];return n?s<e?i?n.top-(i.top+i.height):o?o.top-(n.top+n.height):0:o?o.top-(n.top+n.height):i?n.top-(i.top+i.height):0:0}const xg="Sortable",vg=rt.createContext({activeIndex:-1,containerId:xg,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:gg,disabled:{draggable:!1,droppable:!1}});function uu(t){let{children:e,id:s,items:n,strategy:i=gg,disabled:o=!1}=t;const{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=tg(),u=ga(xg,s),f=l.rect!==null,m=N.useMemo(()=>n.map(w=>typeof w=="object"&&"id"in w?w.id:w),[n]),p=a!=null,g=a?m.indexOf(a.id):-1,x=d?m.indexOf(d.id):-1,v=N.useRef(m),b=!VN(m,v.current),_=x!==-1&&g===-1||b,y=NN(o);nn(()=>{b&&p&&h(m)},[b,m,p,h]),N.useEffect(()=>{v.current=m},[m]);const L=N.useMemo(()=>({activeIndex:g,containerId:u,disabled:y,disableTransforms:_,items:m,overIndex:x,useDragOverlay:f,sortedRects:kN(m,c),strategy:i}),[g,u,y.draggable,y.droppable,_,m,x,c,f,i]);return rt.createElement(vg.Provider,{value:L},e)}const AN=t=>{let{id:e,items:s,activeIndex:n,overIndex:i}=t;return wr(s,n,i).indexOf(e)},EN=t=>{let{containerId:e,isSorting:s,wasDragging:n,index:i,items:o,newIndex:a,previousItems:l,previousContainerId:c,transition:d}=t;return!d||!n||l!==o&&i===a?!1:s?!0:a!==i&&e===c},PN={duration:200,easing:"ease"},bg="transform",RN=Sn.Transition.toString({property:bg,duration:0,easing:"linear"}),DN={roleDescription:"sortable"};function IN(t){let{disabled:e,index:s,node:n,rect:i}=t;const[o,a]=N.useState(null),l=N.useRef(s);return nn(()=>{if(!e&&s!==l.current&&n.current){const c=i.current;if(c){const d=Fr(n.current,{ignoreTransform:!0}),h={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(h.x||h.y)&&a(h)}}s!==l.current&&(l.current=s)},[e,s,n,i]),N.useEffect(()=>{o&&a(null)},[o]),o}function hu(t){let{animateLayoutChanges:e=EN,attributes:s,disabled:n,data:i,getNewIndex:o=AN,id:a,strategy:l,resizeObserverConfig:c,transition:d=PN}=t;const{items:h,containerId:u,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:x,useDragOverlay:v,strategy:b}=N.useContext(vg),_=MN(n,m),y=h.indexOf(a),L=N.useMemo(()=>({sortable:{containerId:u,index:y,items:h},...i}),[u,i,y,h]),w=N.useMemo(()=>h.slice(h.indexOf(a)),[h,a]),{rect:j,node:S,isOver:k,setNodeRef:C}=hV({id:a,data:L,disabled:_.droppable,resizeObserverConfig:{updateMeasurementsFor:w,...c}}),{active:A,activatorEvent:P,activeNodeRect:V,attributes:T,setNodeRef:R,listeners:E,isDragging:I,over:D,setActivatorNodeRef:M,transform:O}=eg({id:a,data:L,attributes:{...DN,...s},disabled:_.draggable}),$=QC(C,R),B=!!A,z=B&&!p&&Ta(f)&&Ta(x),K=!v&&I,Y=K&&z?O:null,q=z?Y??(l??b)({rects:g,activeNodeRect:V,activeIndex:f,overIndex:x,index:y}):null,H=Ta(f)&&Ta(x)?o({id:a,items:h,activeIndex:f,overIndex:x}):y,U=A?.id,X=N.useRef({activeId:U,items:h,newIndex:H,containerId:u}),J=h!==X.current.items,ee=e({active:A,containerId:u,isDragging:I,isSorting:B,id:a,index:y,items:h,newIndex:X.current.newIndex,previousItems:X.current.items,previousContainerId:X.current.containerId,transition:d,wasDragging:X.current.activeId!=null}),W=IN({disabled:!ee,index:y,node:S,rect:j});return N.useEffect(()=>{B&&X.current.newIndex!==H&&(X.current.newIndex=H),u!==X.current.containerId&&(X.current.containerId=u),h!==X.current.items&&(X.current.items=h)},[B,H,u,h]),N.useEffect(()=>{if(U===X.current.activeId)return;if(U!=null&&X.current.activeId==null){X.current.activeId=U;return}const G=setTimeout(()=>{X.current.activeId=U},50);return()=>clearTimeout(G)},[U]),{active:A,activeIndex:f,attributes:T,data:L,rect:j,index:y,newIndex:H,items:h,isOver:k,isSorting:B,isDragging:I,listeners:E,node:S,overIndex:x,over:D,setNodeRef:$,setActivatorNodeRef:M,setDroppableNodeRef:C,setDraggableNodeRef:R,transform:W??q,transition:Z()};function Z(){if(W||J&&X.current.newIndex===y)return RN;if(!(K&&!vc(P)||!d)&&(B||ee))return Sn.Transition.toString({...d,property:bg})}}function MN(t,e){var s,n;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(s=t?.draggable)!=null?s:e.draggable,droppable:(n=t?.droppable)!=null?n:e.droppable}}function Il(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const ON=[ot.Down,ot.Right,ot.Up,ot.Left],fu=(t,e)=>{let{context:{active:s,collisionRect:n,droppableRects:i,droppableContainers:o,over:a,scrollableAncestors:l}}=e;if(ON.includes(t.code)){if(t.preventDefault(),!s||!n)return;const c=[];o.getEnabled().forEach(u=>{if(!u||u!=null&&u.disabled)return;const f=i.get(u.id);if(f)switch(t.code){case ot.Down:n.top<f.top&&c.push(u);break;case ot.Up:n.top>f.top&&c.push(u);break;case ot.Left:n.left>f.left&&c.push(u);break;case ot.Right:n.left<f.left&&c.push(u);break}});const d=mk({collisionRect:n,droppableRects:i,droppableContainers:c});let h=O3(d,"id");if(h===a?.id&&d.length>1&&(h=d[1].id),h!=null){const u=o.get(s.id),f=o.get(h),m=f?i.get(f.id):null,p=f?.node.current;if(p&&m&&u&&f){const x=yc(p).some((w,j)=>l[j]!==w),v=yg(u,f),b=$N(u,f),_=x||!v?{x:0,y:0}:{x:b?n.width-m.width:0,y:b?n.height-m.height:0},y={x:m.left,y:m.top};return _.x&&_.y?y:Go(y,_)}}}};function yg(t,e){return!Il(t)||!Il(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function $N(t,e){return!Il(t)||!Il(e)||!yg(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function mu(t){const e=F.c(11),{isPinned:s,submitting:n,onClick:i,label:o}=t,a=s?"text-muted-foreground hover:bg-destructive/10 hover:text-destructive":"bg-foreground text-background hover:opacity-90";let l;e[0]!==a?(l=ie("inline-flex size-7 shrink-0 items-center justify-center rounded-md text-xs transition-colors disabled:opacity-50 disabled:cursor-progress",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==s||e[3]!==n?(c=n?r.jsx(Ze,{size:12,className:"animate-spin"}):s?r.jsx(p2,{size:14}):r.jsx(_t,{size:14}),e[2]=s,e[3]=n,e[4]=c):c=e[4];let d;return e[5]!==o||e[6]!==i||e[7]!==n||e[8]!==l||e[9]!==c?(d=r.jsx("button",{type:"button",onClick:i,disabled:n,"aria-label":o,title:o,className:l,children:c}),e[5]=o,e[6]=i,e[7]=n,e[8]=l,e[9]=c,e[10]=d):d=e[10],d}function BN(t){const e=F.c(32),{agent:s,home:n,curated:i}=t,{org:o}=ze();let a;e[0]!==s.id||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s.id,orgId:o.id,orgSlug:o.slug},e[0]=s.id,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=pt(a);let c;e[4]!==s.id||e[5]!==o.id?(c=Qe.agentPrompts(o.id,s.id),e[4]=s.id,e[5]=o.id,e[6]=c):c=e[6];let d;e[7]!==l?(d=async()=>{const{prompts:L}=await l.listPrompts();return L.map(UN)},e[7]=l,e[8]=d):d=e[8];let h;e[9]!==c||e[10]!==d?(h={queryKey:c,queryFn:d,staleTime:3e4,retry:!1},e[9]=c,e[10]=d,e[11]=h):h=e[11];const{data:u,isLoading:f,error:m}=Pt(h),p=t2(o.slug);let g,x;if(e[12]!==s.id||e[13]!==u||e[14]!==p.prompts){let L;e[17]!==s.id?(L=j=>j.agentId===s.id&&j.promptName,e[17]=s.id,e[18]=L):L=e[18],g=p.prompts.filter(L).map(KN);let w;e[19]!==u?(w=u??[],e[19]=u,e[20]=w):w=e[20],x=[...w];for(const j of g)x.some(S=>S.name===j.name)||x.push(j);e[12]=s.id,e[13]=u,e[14]=p.prompts,e[15]=g,e[16]=x}else g=e[15],x=e[16];if(f&&g.length===0){let L;return e[21]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(Et,{className:"h-7 w-full"}),r.jsx(Et,{className:"h-7 w-2/3"})]}),e[21]=L):L=e[21],L}if(m&&g.length===0)return console.error("[home-tiles] listPrompts failed for agent",s.id,m),null;if(x.length===0)return null;let v;e[22]!==i||e[23]!==x?(v=i??x.map(zN),e[22]=i,e[23]=x,e[24]=v):v=e[24];let b;e[25]!==v?(b=new Set(v),e[25]=v,e[26]=b):b=e[26];const _=b;let y;return e[27]!==s||e[28]!==n||e[29]!==x||e[30]!==_?(y=r.jsx("div",{className:"flex flex-col gap-0.5",children:x.map(L=>r.jsx(HN,{agent:s,home:n,prompt:L,allPromptNames:x.map(FN),isPinned:_.has(L.name)},L.name))}),e[27]=s,e[28]=n,e[29]=x,e[30]=_,e[31]=y):y=e[31],y}function FN(t){return t.name}function zN(t){return t.name}function KN(t){return{name:t.promptName,title:t.title,description:t.description}}function UN(t){return{name:t.name,title:t.title,description:t.description}}function HN({agent:t,home:e,prompt:s,allPromptNames:n,isPinned:i}){const o=oe(),[a,l]=N.useState(!1),c=async()=>{if(!i&&!e.isOnHome(t.id)&&e.atLimit){ve.error(o("home.agentPromptList.homeIsFull",{limit:Ur}));return}l(!0);try{const d=t.metadata?.ui?.homePrompts;let h;Array.isArray(d)?h=i?d.filter(f=>f!==s.name):[...d,s.name]:h=i?n.filter(f=>f!==s.name):n;const u={...t.metadata??{},ui:{...t.metadata?.ui??{},homePrompts:h}};await e.saveAgentMetadata(t,u)}catch(d){console.error("[home-tiles] failed to toggle prompt",d),ve.error(o("home.agentPromptList.couldntUpdateHome"))}finally{l(!1)}};return r.jsxs("div",{className:"flex items-center gap-2.5 rounded-md px-2 py-1 hover:bg-accent/40",children:[r.jsx("div",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:s.title??Ai(s.name)}),r.jsx(mu,{isPinned:i,submitting:a,onClick:c,label:o(i?"home.agentPromptList.removeFromHome":"home.agentPromptList.addToHome")})]})}function pu(t){const e=F.c(7),{title:s,hint:n}=t;let i;e[0]!==s?(i=r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let o;e[2]!==n?(o=n&&r.jsx("span",{className:"text-xs text-muted-foreground",children:n}),e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==i||e[5]!==o?(a=r.jsxs("div",{className:"flex items-center justify-between px-1",children:[i,o]}),e[4]=i,e[5]=o,e[6]=a):a=e[6],a}const WN={tasks:ic,coding:en,analytics:i2,sales:w9,"recent-conversations":o9};function qN(){const t=F.c(19),e=oe(),{layout:s,commitLayout:n}=Z9();let i;t[0]!==s.hidden?(i=new Set(s.hidden),t[0]=s.hidden,t[1]=i):i=t[1];const o=i;let a;t[2]!==s.shown?(a=s.shown??[],t[2]=s.shown,t[3]=a):a=t[3];let l;t[4]!==a?(l=new Set(a),t[4]=a,t[5]=l):l=t[5];const c=l;let d;t[6]!==e?(d=e("home.nativeTilesSection.builtInTiles"),t[6]=e,t[7]=d):d=t[7];let h;t[8]!==d?(h=r.jsx(pu,{title:d}),t[8]=d,t[9]=h):h=t[9];let u;t[10]!==n||t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==e?(u=au.map(m=>{const p=lg(m.id),g=m.defaultHidden?c.has(p)&&!o.has(p):!o.has(p),x=WN[m.id]??o9,v=()=>{if(m.defaultHidden){n({...s,hidden:s.hidden.filter(b=>b!==p),shown:g?(s.shown??[]).filter(b=>b!==p):[...s.shown??[],p]});return}n({...s,hidden:g?[...s.hidden,p]:s.hidden.filter(b=>b!==p)})};return r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5",children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:r.jsx(x,{size:16})}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:e(m.titleKey)}),r.jsxs(le,{type:"button",size:"sm",variant:g?"outline":"special",className:"h-8 gap-1.5",onClick:v,children:[g?r.jsx(p2,{size:14}):r.jsx(_t,{size:14}),e(g?"home.nativeTilesSection.remove":"home.nativeTilesSection.add")]})]},m.id)}),t[10]=n,t[11]=o,t[12]=s,t[13]=c,t[14]=e,t[15]=u):u=t[15];let f;return t[16]!==h||t[17]!==u?(f=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[h,u]}),t[16]=h,t[17]=u,t[18]=f):f=t[18],f}function GN(t,e,s){const n={};for(const[i,o]of Object.entries(t)){const a=e[i]?.type;if((a==="object"||a==="array")&&typeof o=="string"){if(!o.trim())continue;try{n[i]=JSON.parse(o)}catch{return null}}else if((a==="number"||a==="integer")&&(typeof o=="string"||typeof o=="number")){if(typeof o=="string"&&!o.trim())continue;const l=typeof o=="string"?Number(o):o;if(!Number.isFinite(l)||a==="integer"&&!Number.isInteger(l))return null;n[i]=l}else if(typeof o=="string"){if(!o.trim())continue;n[i]=o}else o!=null&&(n[i]=o)}return s?.some(i=>!(i in n))?null:n}function YN(t,e){if(!t||!e)return{};const s={};for(const[n,i]of Object.entries(t)){const o=e[n]?.type;(o==="object"||o==="array")&&i!=null&&typeof i!="string"?s[n]=JSON.stringify(i,null,2):s[n]=i}return s}function JN(t){if(!t)return"";const e=Object.entries(t).filter(([,s])=>s!=null&&s!=="");return e.length===0?"":e.slice(0,3).map(([s,n])=>{const i=typeof n=="object"?JSON.stringify(n):String(n);return`${s}=${i.length>20?`${i.slice(0,20)}…`:i}`}).join(", ")}function XN(t){const e=F.c(11),{properties:s,required:n,values:i,onChange:o}=t;let a;e[0]!==n?(a=n??[],e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=new Set(a),e[2]=a,e[3]=l):l=e[3];const c=l;let d;e[4]!==s?(d=Object.entries(s),e[4]=s,e[5]=d):d=e[5];let h;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==i?(h=r.jsx("div",{className:"flex flex-col gap-2",children:d.map(u=>{const[f,m]=u;return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("label",{className:"text-xs font-medium leading-none flex items-center gap-1",children:[f,c.has(f)&&r.jsx("span",{className:"text-destructive text-[10px]",children:"*"})]}),r.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:m.type})]}),m.description&&r.jsx("p",{className:"text-[10px] text-muted-foreground leading-snug",children:m.description}),r.jsx(QN,{type:m.type,fieldKey:f,value:i[f],onChange:p=>o(f,p)})]},f)})}),e[6]=o,e[7]=c,e[8]=d,e[9]=i,e[10]=h):h=e[10],h}function QN(t){const e=F.c(40),{type:s,fieldKey:n,value:i,onChange:o}=t,a=oe();if(s==="object"||s==="array"){const u=i??"";let f;e[0]!==o?(f=g=>o(g.target.value),e[0]=o,e[1]=f):f=e[1];let m;e[2]!==n||e[3]!==a?(m=a("common.toolInputForm.jsonPlaceholder",{fieldKey:n}),e[2]=n,e[3]=a,e[4]=m):m=e[4];let p;return e[5]!==u||e[6]!==f||e[7]!==m?(p=r.jsx(Ri,{className:"font-mono text-xs h-16",value:u,onChange:f,placeholder:m,rows:2}),e[5]=u,e[6]=f,e[7]=m,e[8]=p):p=e[8],p}if(s==="boolean"){const u=i!=null?String(i):"";let f;e[9]!==o?(f=L=>o(L==="true"),e[9]=o,e[10]=f):f=e[10];let m;e[11]!==a?(m=a("common.toolInputForm.selectPlaceholder"),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=r.jsx($t,{className:"h-7 text-xs",children:r.jsx(qt,{placeholder:m})}),e[13]=m,e[14]=p):p=e[14];let g;e[15]!==a?(g=a("common.toolInputForm.true"),e[15]=a,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(ut,{value:"true",children:g}),e[17]=g,e[18]=x):x=e[18];let v;e[19]!==a?(v=a("common.toolInputForm.false"),e[19]=a,e[20]=v):v=e[20];let b;e[21]!==v?(b=r.jsx(ut,{value:"false",children:v}),e[21]=v,e[22]=b):b=e[22];let _;e[23]!==x||e[24]!==b?(_=r.jsxs(Bt,{children:[x,b]}),e[23]=x,e[24]=b,e[25]=_):_=e[25];let y;return e[26]!==u||e[27]!==f||e[28]!==p||e[29]!==_?(y=r.jsxs(Ft,{value:u,onValueChange:f,children:[p,_]}),e[26]=u,e[27]=f,e[28]=p,e[29]=_,e[30]=y):y=e[30],y}const l=i??"";let c;e[31]!==o?(c=u=>o(u.target.value),e[31]=o,e[32]=c):c=e[32];let d;e[33]!==n||e[34]!==a?(d=a("common.toolInputForm.enterPlaceholder",{fieldKey:n}),e[33]=n,e[34]=a,e[35]=d):d=e[35];let h;return e[36]!==l||e[37]!==c||e[38]!==d?(h=r.jsx(et,{className:"h-7 text-xs",value:l,onChange:c,placeholder:d}),e[36]=l,e[37]=c,e[38]=d,e[39]=h):h=e[39],h}const Ur=8;function yf(t,e,s){return t.includes(e)||(s?t.filter(i=>s.has(i)).length:t.length)>=Ur?null:[...t,e]}function ZN(t){const e=F.c(29),{open:s,onOpenChange:n}=t,[i,o]=N.useState(""),a=oe();let l;e[0]!==a?(l=a("home.addTileDrawer.title"),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx(C8,{children:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==a?(d=a("home.addTileDrawer.description"),e[4]=a,e[5]=d):d=e[5];let h;e[6]!==d?(h=r.jsx(k8,{children:d}),e[6]=d,e[7]=h):h=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(a9,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none","aria-hidden":!0}),e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=y=>o(y.target.value),e[9]=f):f=e[9];let m;e[10]!==a?(m=a("home.addTileDrawer.searchPlaceholder"),e[10]=a,e[11]=m):m=e[11];let p;e[12]!==i||e[13]!==m?(p=r.jsxs("div",{className:"relative mt-3",children:[u,r.jsx(et,{value:i,onChange:f,placeholder:m,className:"pl-8 h-8 text-sm"})]}),e[12]=i,e[13]=m,e[14]=p):p=e[14];let g;e[15]!==c||e[16]!==h||e[17]!==p?(g=r.jsxs(V8,{className:"px-5 py-4 border-b border-border",children:[c,h,p]}),e[15]=c,e[16]=h,e[17]=p,e[18]=g):g=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(_T,{}),e[19]=x):x=e[19];let v;e[20]!==i?(v=r.jsx(fi,{className:"flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"p-3 flex flex-col gap-4",children:r.jsx(N.Suspense,{fallback:x,children:r.jsx(tT,{search:i})})})}),e[20]=i,e[21]=v):v=e[21];let b;e[22]!==v||e[23]!==g?(b=r.jsxs(N8,{side:"right",className:"w-full sm:max-w-md p-0 flex flex-col",children:[g,v]}),e[22]=v,e[23]=g,e[24]=b):b=e[24];let _;return e[25]!==n||e[26]!==s||e[27]!==b?(_=r.jsx(T8,{open:s,onOpenChange:n,children:b}),e[25]=n,e[26]=s,e[27]=b,e[28]=_):_=e[28],_}function eT(t){const e=F.c(30),{org:s}=ze(),n=D2();let i;e[0]!==n?.ids?(i=n?.ids??[],e[0]=n?.ids,e[1]=i):i=e[1];const o=i,a=I2(),l=g9(),c=Ls();let d;e[2]!==s||e[3]!==c?(d=()=>c.refetchQueries({queryKey:Qe.homeNextActions(s.slug),type:"active"}),e[2]=s,e[3]=c,e[4]=d):d=e[4];const h=d;let u;e[5]!==o?(u=k=>o.includes(k),e[5]=o,e[6]=u):u=e[6];const f=u;let m;e[7]!==o||e[8]!==t?(m=t?o.filter(k=>t.has(k)).length:o.length,e[7]=o,e[8]=t,e[9]=m):m=e[9];const g=m>=Ur;let x;e[10]!==t||e[11]!==a?(x=k=>a.apply(C=>yf(C,k,t)),e[10]=t,e[11]=a,e[12]=x):x=e[12];const v=x;let b;e[13]!==a?(b=k=>a.apply(C=>C.filter(A=>A!==k)),e[13]=a,e[14]=b):b=e[14];const _=b;let y;e[15]!==a?(y=k=>a.apply(()=>k),e[15]=a,e[16]=y):y=e[16];const L=y;let w;e[17]!==l||e[18]!==h||e[19]!==t||e[20]!==a?(w=async(k,C)=>{await l.update.mutateAsync({id:k.id,data:{metadata:C}}),await a.apply(A=>yf(A,k.id,t)),await h()},e[17]=l,e[18]=h,e[19]=t,e[20]=a,e[21]=w):w=e[21];const j=w;let S;return e[22]!==v||e[23]!==g||e[24]!==o||e[25]!==f||e[26]!==_||e[27]!==L||e[28]!==j?(S={homeIds:o,isOnHome:f,atLimit:g,addAgent:v,removeAgent:_,reorder:L,saveAgentMetadata:j},e[22]=v,e[23]=g,e[24]=o,e[25]=f,e[26]=_,e[27]=L,e[28]=j,e[29]=S):S=e[29],S}function tT(t){const e=F.c(24),{search:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={pageSize:1e3},e[0]=n):n=e[0];const i=la(n);let o;e[1]!==i?(o=new Set(i.map(oT)),e[1]=i,e[2]=o):o=e[2];const a=eT(o);let l,c,d;if(e[3]!==i||e[4]!==a||e[5]!==s){const x=new Map(i.map(rT));l=s.trim().toLowerCase();const v=y=>!l||y.title?.toLowerCase().includes(l);c=a.homeIds.map(y=>x.get(y)).filter(iT).filter(v);const b=m9(i);let _;e[9]!==a?(_=y=>!a.isOnHome(y.id),e[9]=a,e[10]=_):_=e[10],d=i.filter(nT).filter(y=>!b.has(y.id)).filter(_).filter(v).sort(sT),e[3]=i,e[4]=a,e[5]=s,e[6]=l,e[7]=c,e[8]=d}else l=e[6],c=e[7],d=e[8];const h=d;let u;e[11]!==a||e[12]!==c?(u=r.jsx(aT,{home:a,agents:c}),e[11]=a,e[12]=c,e[13]=u):u=e[13];let f;e[14]!==l?(f=!l&&r.jsx(qN,{}),e[14]=l,e[15]=f):f=e[15];const m=!!l;let p;e[16]!==h||e[17]!==a||e[18]!==m?(p=r.jsx(cT,{home:a,agents:h,hasSearch:m}),e[16]=h,e[17]=a,e[18]=m,e[19]=p):p=e[19];let g;return e[20]!==u||e[21]!==f||e[22]!==p?(g=r.jsxs(r.Fragment,{children:[u,f,p]}),e[20]=u,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}function sT(t,e){return(t.title??"").localeCompare(e.title??"")}function nT(t){return t.id&&!cl(t.id)}function iT(t){return!!t}function rT(t){return[t.id,t]}function oT(t){return t.id}function aT(t){const e=F.c(19),{home:s,agents:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={activationConstraint:{distance:5}},e[0]=i):i=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={coordinateGetter:fu},e[1]=o):o=e[1];const a=bc(li(Kr,i),li(zr,o)),l=oe();let c;e[2]!==s||e[3]!==l?(c=g=>{const{active:x,over:v}=g;if(!v||x.id===v.id)return;const b=s.homeIds,_=b.indexOf(x.id),y=b.indexOf(v.id);_===-1||y===-1||s.reorder(wr([...b],_,y)).catch(()=>ve.error(l("home.addTileDrawer.reorderError")))},e[2]=s,e[3]=l,e[4]=c):c=e[4];const d=c;let h;e[5]!==l?(h=l("home.addTileDrawer.onHomeTitle"),e[5]=l,e[6]=h):h=e[6];const u=`${s.homeIds.length}/${Ur}`;let f;e[7]!==h||e[8]!==u?(f=r.jsx(pu,{title:h,hint:u}),e[7]=h,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==n||e[11]!==d||e[12]!==s||e[13]!==a||e[14]!==l?(m=n.length===0?r.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:l("home.addTileDrawer.noAgentsOnHome")}):r.jsx(Sc,{sensors:a,collisionDetection:su,onDragEnd:d,children:r.jsx(uu,{items:n.map(lT),strategy:du,children:r.jsx("div",{className:"flex flex-col gap-1",children:n.map(g=>r.jsx(hT,{agent:g,home:s},g.id))})})}),e[10]=n,e[11]=d,e[12]=s,e[13]=a,e[14]=l,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==m?(p=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[f,m]}),e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function lT(t){return t.id}function cT(t){const e=F.c(7),{home:s,agents:n,hasSearch:i}=t,[o,a]=N.useState(20),l=n.slice(0,o),c=oe(),d="flex flex-col gap-1.5";let h;e[0]!==c?(h=c("home.addTileDrawer.addToHomeTitle"),e[0]=c,e[1]=h):h=e[1];let u;e[2]!==h?(u=r.jsx(pu,{title:h}),e[2]=h,e[3]=u):u=e[3];const f=n.length===0?r.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:c(i?"home.addTileDrawer.noAgentsMatch":"home.addTileDrawer.allAgentsOnHome")}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col gap-1",children:l.map(p=>r.jsx(mT,{agent:p,home:s},p.id))}),n.length>o&&r.jsx("button",{type:"button",onClick:()=>a(dT),className:"mt-1 self-center rounded-md px-3 py-1.5 text-xs text-muted-foreground hover:bg-accent/40 hover:text-foreground",children:c("home.addTileDrawer.loadMore",{count:n.length-o})})]});let m;return e[4]!==u||e[5]!==f?(m=r.jsxs("div",{className:d,children:[u,f]}),e[4]=u,e[5]=f,e[6]=m):m=e[6],m}function dT(t){return t+20}function _g(t){const e=F.c(14),s=oe();let n;e[0]!==t.metadata?.ui?(n=xr(t.metadata?.ui).filter(uT),e[0]=t.metadata?.ui,e[1]=n):n=e[1];const i=n.length,o=t.metadata?.ui?.homePrompts,a=Array.isArray(o)?o.length:null;let l;if(e[2]!==a||e[3]!==s||e[4]!==i){if(l=[],i>0){let c;e[6]!==s||e[7]!==i?(c=s("home.addTileDrawer.tileCountLabel",{count:i}),e[6]=s,e[7]=i,e[8]=c):c=e[8],l.push(c)}if(a!==null&&a>0){let c;e[9]!==a||e[10]!==s?(c=s("home.addTileDrawer.promptCountLabel",{count:a}),e[9]=a,e[10]=s,e[11]=c):c=e[11],l.push(c)}if(a===0){let c;e[12]!==s?(c=s("home.addTileDrawer.promptsOffLabel"),e[12]=s,e[13]=c):c=e[13],l.push(c)}e[2]=a,e[3]=s,e[4]=i,e[5]=l}else l=e[5];return l.join(" · ")}function uT(t){return!!t.resourceUri}function hT(t){const e=F.c(70),{agent:s,home:n}=t,[i,o]=N.useState(!1),a=oe();let l;e[0]!==s.id?(l={id:s.id},e[0]=s.id,e[1]=l):l=e[1];const{attributes:c,listeners:d,setNodeRef:h,transform:u,transition:f,isDragging:m}=hu(l),p=_g(s)||a("home.addTileDrawer.quickAccess"),g=`home-agent-expansion-${s.id}`;let x;e[2]!==u?(x=Sn.Transform.toString(u),e[2]=u,e[3]=x):x=e[3];const v=m?.5:void 0,b=m?100:void 0;let _;e[4]!==x||e[5]!==v||e[6]!==b||e[7]!==f?(_={transform:x,transition:f,opacity:v,zIndex:b},e[4]=x,e[5]=v,e[6]=b,e[7]=f,e[8]=_):_=e[8];const y=_,L=m&&"shadow-lg";let w;e[9]!==L?(w=ie("rounded-lg border border-border bg-card",L),e[9]=L,e[10]=w):w=e[10];const j=s.title??s.id;let S;e[11]!==a||e[12]!==j?(S=a("home.addTileDrawer.dragToReorder",{name:j}),e[11]=a,e[12]=j,e[13]=S):S=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(ca,{size:14}),e[14]=k):k=e[14];let C;e[15]!==c||e[16]!==d||e[17]!==S?(C=r.jsx("button",{type:"button",...c,...d,className:"shrink-0 text-muted-foreground hover:text-foreground cursor-grab active:cursor-grabbing outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":S,children:k}),e[15]=c,e[16]=d,e[17]=S,e[18]=C):C=e[18];let A;e[19]===Symbol.for("react.memo_cache_sentinel")?(A=()=>o(fT),e[19]=A):A=e[19];const P=s.title??s.id;let V;e[20]!==s.icon||e[21]!==P?(V=r.jsx(ii,{icon:s.icon,name:P,size:"sm"}),e[20]=s.icon,e[21]=P,e[22]=V):V=e[22];const T=s.title??s.id;let R;e[23]!==T?(R=r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:T}),e[23]=T,e[24]=R):R=e[24];let E;e[25]!==p?(E=r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:p}),e[25]=p,e[26]=E):E=e[26];let I;e[27]!==R||e[28]!==E?(I=r.jsxs("div",{className:"min-w-0 flex-1",children:[R,E]}),e[27]=R,e[28]=E,e[29]=I):I=e[29];const D=i&&"rotate-180";let M;e[30]!==D?(M=ie("shrink-0 text-muted-foreground transition-transform",D),e[30]=D,e[31]=M):M=e[31];let O;e[32]!==M?(O=r.jsx(is,{size:16,className:M}),e[32]=M,e[33]=O):O=e[33];let $;e[34]!==i||e[35]!==g||e[36]!==V||e[37]!==I||e[38]!==O?($=r.jsxs("button",{type:"button",onClick:A,className:"flex min-w-0 flex-1 items-center gap-2.5 text-left outline-none","aria-expanded":i,"aria-controls":g,children:[V,I,O]}),e[34]=i,e[35]=g,e[36]=V,e[37]=I,e[38]=O,e[39]=$):$=e[39];let B;e[40]!==s.id||e[41]!==n||e[42]!==a?(B=()=>n.removeAgent(s.id).catch(()=>ve.error(a("home.addTileDrawer.removeError"))),e[40]=s.id,e[41]=n,e[42]=a,e[43]=B):B=e[43];const z=s.title??s.id;let K;e[44]!==a||e[45]!==z?(K=a("home.addTileDrawer.removeAgentFromHome",{name:z}),e[44]=a,e[45]=z,e[46]=K):K=e[46];const Y=s.title??s.id;let Q;e[47]!==a||e[48]!==Y?(Q=a("home.addTileDrawer.removeAgentFromHome",{name:Y}),e[47]=a,e[48]=Y,e[49]=Q):Q=e[49];let q;e[50]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(an,{size:14}),e[50]=q):q=e[50];let H;e[51]!==B||e[52]!==K||e[53]!==Q?(H=r.jsx("button",{type:"button",onClick:B,"aria-label":K,title:Q,className:"shrink-0 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:q}),e[51]=B,e[52]=K,e[53]=Q,e[54]=H):H=e[54];let U;e[55]!==C||e[56]!==$||e[57]!==H?(U=r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-2.5",children:[C,$,H]}),e[55]=C,e[56]=$,e[57]=H,e[58]=U):U=e[58];let X;e[59]!==s||e[60]!==i||e[61]!==g||e[62]!==n?(X=i&&r.jsx(Lg,{id:g,agent:s,home:n}),e[59]=s,e[60]=i,e[61]=g,e[62]=n,e[63]=X):X=e[63];let J;return e[64]!==h||e[65]!==y||e[66]!==U||e[67]!==X||e[68]!==w?(J=r.jsxs("div",{ref:h,style:y,className:w,children:[U,X]}),e[64]=h,e[65]=y,e[66]=U,e[67]=X,e[68]=w,e[69]=J):J=e[69],J}function fT(t){return!t}function mT({agent:t,home:e}){const[s,n]=N.useState(!1),[i,o]=N.useState(!1),a=_g(t),l=oe(),c=`available-agent-expansion-${t.id}`,d=async()=>{if(!e.atLimit){o(!0);try{await e.addAgent(t.id)}catch{ve.error(l("home.addTileDrawer.addError"))}finally{o(!1)}}};return r.jsxs("div",{className:"rounded-lg border border-border bg-card",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[r.jsxs("button",{type:"button",onClick:()=>n(h=>!h),className:"flex min-w-0 flex-1 items-center gap-3 text-left outline-none","aria-expanded":s,"aria-controls":c,children:[r.jsx(ii,{icon:t.icon,name:t.title??t.id,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t.title??t.id}),a&&r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:a})]}),r.jsx(is,{size:16,className:ie("shrink-0 text-muted-foreground transition-transform",s&&"rotate-180")})]}),r.jsx("button",{type:"button",onClick:d,disabled:i||e.atLimit,"aria-label":l("home.addTileDrawer.addToHomeTitle"),title:e.atLimit?l("home.addTileDrawer.homeFullMessage",{limit:Ur}):l("home.addTileDrawer.addToHomeTitle"),className:"shrink-0 inline-flex size-7 items-center justify-center rounded-md bg-foreground text-background text-xs hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed",children:i?r.jsx(Ze,{size:12,className:"animate-spin"}):r.jsx(_t,{size:14})})]}),s&&r.jsx(Lg,{id:c,agent:t,home:e})]})}function Lg(t){const e=F.c(18),{id:s,agent:n,home:i}=t,o=n.metadata?.ui;let a;e[0]!==o?(a=xr(o),e[0]=o,e[1]=a):a=e[1];const l=a;let c;e[2]!==n.connections?(c=(n.connections??[]).map(pT).sort(),e[2]=n.connections,e[3]=c):c=e[3];const d=c,h=n.metadata?.ui?.homePrompts;let u;e[4]!==n||e[5]!==d||e[6]!==i||e[7]!==l?(u=r.jsx(xT,{agent:n,home:i,connectionIds:d,pinnedTiles:l}),e[4]=n,e[5]=d,e[6]=i,e[7]=l,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(gT,{}),e[9]=f):f=e[9];const m=h??null;let p;e[10]!==n||e[11]!==i||e[12]!==m?(p=r.jsx(N.Suspense,{fallback:f,children:r.jsx(BN,{agent:n,home:i,curated:m})}),e[10]=n,e[11]=i,e[12]=m,e[13]=p):p=e[13];let g;return e[14]!==s||e[15]!==u||e[16]!==p?(g=r.jsxs("div",{id:s,className:"border-t border-border px-3 py-2 flex flex-col gap-3",children:[u,p]}),e[14]=s,e[15]=u,e[16]=p,e[17]=g):g=e[17],g}function pT(t){return t.connection_id}function gT(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[r.jsx(Et,{className:"h-8 w-full"}),r.jsx(Et,{className:"h-8 w-2/3"})]}),t[0]=e):e=t[0],e}function xT({agent:t,home:e,connectionIds:s,pinnedTiles:n}){const i=oe(),o=Fs(),{data:a,isLoading:l}=Pt({queryKey:Qe.projectConnectionDetails(t.id,s),enabled:s.length>0,queryFn:async()=>(await Promise.all(s.map(async f=>{try{const{item:m}=await o.call("COLLECTION_CONNECTIONS_GET",{id:f}),p=(m?.tools??[]).flatMap(g=>{const x=oc(g._meta);return x?[{name:g.name,description:g.description,resourceUri:x,inputSchema:g.inputSchema}]:[]});return{id:f,title:m?.title??f,icon:m?.icon??null,uiTools:p}}catch{return{id:f,title:f,icon:null,uiTools:[]}}}))).filter(f=>f.uiTools.length>0)});if(s.length===0)return null;if(l)return r.jsxs("div",{className:"flex flex-col gap-1 py-0.5",children:[r.jsx(Et,{className:"h-7 w-full"}),r.jsx(Et,{className:"h-7 w-2/3"})]});if(!a||a.length===0)return null;const c=new Map;for(const u of a)for(const f of u.uiTools)c.set(`${u.id}:${f.name}`,{conn:u,tool:f});const d=u=>{if(u.toolName&&u.connectionId)return c.get(`${u.connectionId}:${u.toolName}`);for(const[,f]of c)if(f.conn.id===u.connectionId&&f.tool.resourceUri===u.resourceUri)return f},h=n.some(u=>!!d(u));return r.jsxs("div",{className:"flex flex-col gap-2",children:[h&&r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground px-2",children:i("home.addTileDrawer.pinnedTiles")}),n.map(u=>{const f=d(u);return f?r.jsx(vT,{agent:t,home:e,connection:f.conn,tool:f.tool,tile:u},u.tileId??`${u.connectionId}:${u.resourceUri}:${u.toolName}`):null})]}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground px-2",children:i("home.addTileDrawer.addTileLabel")}),a.map(u=>u.uiTools.map(f=>r.jsx(yT,{agent:t,home:e,connection:u,tool:f},`add:${u.id}:${f.name}`)))]})]})}function t0(t,e){return{...t.metadata??{},ui:{...t.metadata?.ui??{},homeTile:null,homeTiles:e}}}async function s0(t,e,s){try{await e()}catch(n){console.error(`[home-tiles] failed to ${t} tile`,n),ve.error(s("home.addTileDrawer.updateError"))}}function Sg(t,e,s,n){if(!e||Object.keys(e).length===0)return{};const i=GN(t,e,s);if(!i){ve.error(n("home.addTileDrawer.invalidFieldError"));return}return Object.keys(i).length>0?{toolInput:i}:{}}function wg(t){const e=F.c(23),{properties:s,required:n,values:i,onChange:o,onCancel:a,onSubmit:l,submitting:c,submitLabel:d}=t,h=oe();let u;e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==i?(u=r.jsx(XN,{properties:s,required:n,values:i,onChange:o}),e[0]=o,e[1]=s,e[2]=n,e[3]=i,e[4]=u):u=e[4];let f;e[5]!==h?(f=h("home.addTileDrawer.cancel"),e[5]=h,e[6]=f):f=e[6];let m;e[7]!==a||e[8]!==f?(m=r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:a,children:f}),e[7]=a,e[8]=f,e[9]=m):m=e[9];let p;e[10]!==d||e[11]!==c?(p=c?r.jsx(Ze,{size:12,className:"animate-spin"}):d,e[10]=d,e[11]=c,e[12]=p):p=e[12];let g;e[13]!==l||e[14]!==c||e[15]!==p?(g=r.jsx(le,{size:"sm",className:"h-7 text-xs",disabled:c,onClick:l,children:p}),e[13]=l,e[14]=c,e[15]=p,e[16]=g):g=e[16];let x;e[17]!==m||e[18]!==g?(x=r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[m,g]}),e[17]=m,e[18]=g,e[19]=x):x=e[19];let v;return e[20]!==u||e[21]!==x?(v=r.jsxs("div",{className:"px-3 pb-2 pt-1 flex flex-col gap-2",children:[u,x]}),e[20]=u,e[21]=x,e[22]=v):v=e[22],v}function vT(t){const e=F.c(57),{agent:s,home:n,connection:i,tool:o,tile:a}=t,[l,c]=N.useState(!1),[d,h]=N.useState(!1),u=oe();let f;e[0]!==o.inputSchema?(f=o.inputSchema?.properties&&Object.keys(o.inputSchema.properties).length>0,e[0]=o.inputSchema,e[1]=f):f=e[1];const m=f;let p;e[2]!==a.toolInput||e[3]!==o.inputSchema?.properties?(p=()=>YN(a.toolInput,o.inputSchema?.properties),e[2]=a.toolInput,e[3]=o.inputSchema?.properties,e[4]=p):p=e[4];const[g,x]=N.useState(p);let v;e[5]!==s||e[6]!==n||e[7]!==u||e[8]!==a?(v=async()=>{c(!0),await s0("remove",async()=>{const D=xr(s.metadata?.ui),M=a.tileId?D.filter(O=>O.tileId!==a.tileId):D.filter(O=>O!==a);await n.saveAgentMetadata(s,t0(s,M)),h(!1)},u),c(!1)},e[5]=s,e[6]=n,e[7]=u,e[8]=a,e[9]=v):v=e[9];const b=v;let _;e[10]!==s||e[11]!==g||e[12]!==n||e[13]!==u||e[14]!==a||e[15]!==o.inputSchema?.properties||e[16]!==o.inputSchema?.required?(_=async()=>{const D=Sg(g,o.inputSchema?.properties,o.inputSchema?.required,u);if(!D)return;const{toolInput:M}=D;c(!0),await s0("save",async()=>{const $=xr(s.metadata?.ui).map(B=>(a.tileId?B.tileId===a.tileId:B===a)?{...B,toolInput:M}:B);await n.saveAgentMetadata(s,t0(s,$)),h(!1)},u),c(!1)},e[10]=s,e[11]=g,e[12]=n,e[13]=u,e[14]=a,e[15]=o.inputSchema?.properties,e[16]=o.inputSchema?.required,e[17]=_):_=e[17];const y=_;let L;e[18]!==a.toolInput?(L=JN(a.toolInput),e[18]=a.toolInput,e[19]=L):L=e[19];const w=L;let j;e[20]!==i.icon||e[21]!==i.title?(j=r.jsx(ln,{icon:i.icon,name:i.title,size:"xs"}),e[20]=i.icon,e[21]=i.title,e[22]=j):j=e[22];let S;e[23]!==o.name?(S=Ai(o.name),e[23]=o.name,e[24]=S):S=e[24];let k;e[25]!==S?(k=r.jsx("div",{className:"truncate text-sm text-foreground",children:S}),e[25]=S,e[26]=k):k=e[26];let C;e[27]!==w?(C=w&&r.jsx("div",{className:"truncate text-[10px] text-muted-foreground font-mono",children:w}),e[27]=w,e[28]=C):C=e[28];let A;e[29]!==k||e[30]!==C?(A=r.jsxs("div",{className:"min-w-0 flex-1",children:[k,C]}),e[29]=k,e[30]=C,e[31]=A):A=e[31];let P;e[32]!==m||e[33]!==u?(P=m&&r.jsx("button",{type:"button",onClick:()=>h(bT),"aria-label":u("home.addTileDrawer.configureTile"),title:u("home.addTileDrawer.configureTile"),className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60",children:r.jsx(g2,{size:14})}),e[32]=m,e[33]=u,e[34]=P):P=e[34];let V;e[35]!==u?(V=u("home.addTileDrawer.removeFromHome"),e[35]=u,e[36]=V):V=e[36];let T;e[37]!==b||e[38]!==l||e[39]!==V?(T=r.jsx(mu,{isPinned:!0,submitting:l,onClick:b,label:V}),e[37]=b,e[38]=l,e[39]=V,e[40]=T):T=e[40];let R;e[41]!==A||e[42]!==P||e[43]!==T||e[44]!==j?(R=r.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[j,A,P,T]}),e[41]=A,e[42]=P,e[43]=T,e[44]=j,e[45]=R):R=e[45];let E;e[46]!==g||e[47]!==y||e[48]!==m||e[49]!==d||e[50]!==l||e[51]!==u||e[52]!==o.inputSchema?(E=d&&m&&o.inputSchema?.properties&&r.jsx(wg,{properties:o.inputSchema.properties,required:o.inputSchema.required,values:g,onChange:(D,M)=>x(O=>({...O,[D]:M})),onCancel:()=>h(!1),onSubmit:y,submitting:l,submitLabel:u("home.addTileDrawer.save")}),e[46]=g,e[47]=y,e[48]=m,e[49]=d,e[50]=l,e[51]=u,e[52]=o.inputSchema,e[53]=E):E=e[53];let I;return e[54]!==R||e[55]!==E?(I=r.jsxs("div",{className:"flex flex-col rounded-md bg-accent/20",children:[R,E]}),e[54]=R,e[55]=E,e[56]=I):I=e[56],I}function bT(t){return!t}function yT(t){const e=F.c(44),{agent:s,home:n,connection:i,tool:o}=t,[a,l]=N.useState(!1),[c,d]=N.useState(!1),h=oe();let u;e[0]!==o.inputSchema?(u=o.inputSchema?.properties&&Object.keys(o.inputSchema.properties).length>0,e[0]=o.inputSchema,e[1]=u):u=e[1];const f=u;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m={},e[2]=m):m=e[2];const[p,g]=N.useState(m);let x,v;e[3]!==s||e[4]!==i.id||e[5]!==p||e[6]!==f||e[7]!==n||e[8]!==c||e[9]!==h||e[10]!==o.inputSchema?.properties||e[11]!==o.inputSchema?.required||e[12]!==o.name||e[13]!==o.resourceUri?(x=async()=>{if(f&&!c){d(!0);return}if(!n.isOnHome(s.id)&&n.atLimit){ve.error(h("home.addTileDrawer.homeFullMessage",{limit:Ur}));return}await v()},v=async()=>{const C=Sg(p,o.inputSchema?.properties,o.inputSchema?.required,h);if(!C)return;const{toolInput:A}=C;l(!0),await s0("add",async()=>{const V=[...xr(s.metadata?.ui),{tileId:crypto.randomUUID(),connectionId:i.id,resourceUri:o.resourceUri,toolName:o.name,...A?{toolInput:A}:{}}];await n.saveAgentMetadata(s,t0(s,V)),d(!1),g({})},h),l(!1)},e[3]=s,e[4]=i.id,e[5]=p,e[6]=f,e[7]=n,e[8]=c,e[9]=h,e[10]=o.inputSchema?.properties,e[11]=o.inputSchema?.required,e[12]=o.name,e[13]=o.resourceUri,e[14]=x,e[15]=v):(x=e[14],v=e[15]);let b;e[16]!==i.icon||e[17]!==i.title?(b=r.jsx(ln,{icon:i.icon,name:i.title,size:"xs"}),e[16]=i.icon,e[17]=i.title,e[18]=b):b=e[18];let _;e[19]!==o.name?(_=Ai(o.name),e[19]=o.name,e[20]=_):_=e[20];let y;e[21]!==_?(y=r.jsx("div",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:_}),e[21]=_,e[22]=y):y=e[22];let L;e[23]!==h?(L=h("home.addTileDrawer.addToHomeTitle"),e[23]=h,e[24]=L):L=e[24];let w;e[25]!==x||e[26]!==a||e[27]!==L?(w=r.jsx(mu,{isPinned:!1,submitting:a,onClick:x,label:L}),e[25]=x,e[26]=a,e[27]=L,e[28]=w):w=e[28];let j;e[29]!==b||e[30]!==y||e[31]!==w?(j=r.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[b,y,w]}),e[29]=b,e[30]=y,e[31]=w,e[32]=j):j=e[32];let S;e[33]!==p||e[34]!==f||e[35]!==v||e[36]!==c||e[37]!==a||e[38]!==h||e[39]!==o.inputSchema?(S=c&&f&&o.inputSchema?.properties&&r.jsx(wg,{properties:o.inputSchema.properties,required:o.inputSchema.required,values:p,onChange:(C,A)=>g(P=>({...P,[C]:A})),onCancel:()=>{d(!1),g({})},onSubmit:v,submitting:a,submitLabel:h("home.addTileDrawer.pin")}),e[33]=p,e[34]=f,e[35]=v,e[36]=c,e[37]=a,e[38]=h,e[39]=o.inputSchema,e[40]=S):S=e[40];let k;return e[41]!==j||e[42]!==S?(k=r.jsxs("div",{className:"flex flex-col rounded-md hover:bg-accent/40",children:[j,S]}),e[41]=j,e[42]=S,e[43]=k):k=e[43],k}function _T(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col gap-2 p-2",children:Array.from({length:4},LT)}),t[0]=e):e=t[0],e}function LT(t,e){return r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border p-2.5",children:[r.jsx(Et,{className:"size-8 rounded-md"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Et,{className:"h-3 w-1/2"}),r.jsx(Et,{className:"h-2.5 w-1/3"})]})]},e)}const ST=[{id:"all",labelKey:"home.homeTasks.tabAll"},{id:"in_progress",labelKey:"home.homeTasks.tabInProgress"},{id:"in_review",labelKey:"home.homeTasks.tabInReview"},{id:"done",labelKey:"home.homeTasks.tabDone"}],wT=4;function jT(t){const e=F.c(64),{task:s,assignee:n,onOpen:i}=t,o=x6[s.status],a=o.icon,l=v6[s.priority];let c,d,h,u,f,m,p,g,x,v,b,_,y,L;if(e[0]!==a||e[1]!==n?.user?.email||e[2]!==n?.user?.image||e[3]!==n?.user?.name||e[4]!==i||e[5]!==o.iconClassName||e[6]!==s.dueDate||e[7]!==s.title||e[8]!==s.updatedAt){const T=n?.user?.name??n?.user?.email?.split("@")[0]??null;let R;e[23]!==s.updatedAt?(R=Y2(new Date(s.updatedAt)),e[23]=s.updatedAt,e[24]=R):R=e[24],L=R;let E;e[25]!==s.dueDate?(E=s.dueDate?{label:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(s.dueDate)),overdue:new Date(s.dueDate).getTime()<Date.now()}:null,e[25]=s.dueDate,e[26]=E):E=e[26],d=E,b="button",_=i,y="flex w-full items-center gap-3 rounded-2xl bg-card px-4 py-3.5 text-left card-shadow transition-colors hover:bg-accent/60";let I;e[27]!==o.iconClassName?(I=ie("size-4 shrink-0",o.iconClassName),e[27]=o.iconClassName,e[28]=I):I=e[28],e[29]!==a||e[30]!==I?(u=r.jsx(a,{className:I}),e[29]=a,e[30]=I,e[31]=u):u=e[31],e[32]!==s.title?(f=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:s.title}),e[32]=s.title,e[33]=f):f=e[33],v="flex shrink-0 items-center gap-3 text-xs text-muted-foreground",x="hidden @2xl:inline-flex",c=ur,h="circle",m="2xs",p=n?.user?.image??void 0,g=(T??"?").slice(0,2).toUpperCase(),e[0]=a,e[1]=n?.user?.email,e[2]=n?.user?.image,e[3]=n?.user?.name,e[4]=i,e[5]=o.iconClassName,e[6]=s.dueDate,e[7]=s.title,e[8]=s.updatedAt,e[9]=c,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=m,e[15]=p,e[16]=g,e[17]=x,e[18]=v,e[19]=b,e[20]=_,e[21]=y,e[22]=L}else c=e[9],d=e[10],h=e[11],u=e[12],f=e[13],m=e[14],p=e[15],g=e[16],x=e[17],v=e[18],b=e[19],_=e[20],y=e[21],L=e[22];let w;e[34]!==c||e[35]!==h||e[36]!==m||e[37]!==p||e[38]!==g?(w=r.jsx(c,{shape:h,size:m,url:p,fallback:g}),e[34]=c,e[35]=h,e[36]=m,e[37]=p,e[38]=g,e[39]=w):w=e[39];let j;e[40]!==w||e[41]!==x?(j=r.jsx("span",{className:x,children:w}),e[40]=w,e[41]=x,e[42]=j):j=e[42];let S;e[43]!==l.flagClassName?(S=ie("size-3.5 shrink-0",l.flagClassName),e[43]=l.flagClassName,e[44]=S):S=e[44];let k;e[45]!==S?(k=r.jsx(j9,{className:S}),e[45]=S,e[46]=k):k=e[46];let C;e[47]!==d?(C=d&&r.jsxs("span",{className:ie("hidden items-center gap-1 @xl:inline-flex",d.overdue?"text-red-600":""),children:[r.jsx(l9,{className:"size-3"}),d.label]}),e[47]=d,e[48]=C):C=e[48];let A;e[49]!==L?(A=r.jsx("span",{className:"hidden @xl:inline",children:L}),e[49]=L,e[50]=A):A=e[50];let P;e[51]!==j||e[52]!==k||e[53]!==C||e[54]!==A||e[55]!==v?(P=r.jsxs("div",{className:v,children:[j,k,C,A]}),e[51]=j,e[52]=k,e[53]=C,e[54]=A,e[55]=v,e[56]=P):P=e[56];let V;return e[57]!==u||e[58]!==f||e[59]!==P||e[60]!==b||e[61]!==_||e[62]!==y?(V=r.jsxs("button",{type:b,onClick:_,className:y,children:[u,f,P]}),e[57]=u,e[58]=f,e[59]=P,e[60]=b,e[61]=_,e[62]=y,e[63]=V):V=e[63],V}function CT(t,e){const s=t.filter(h=>h.status!=="done");if(s.length===0)return"";const n=s.filter(h=>h.status==="in_progress").length,i=s.filter(h=>h.status==="in_review").length,o=s.filter(h=>h.priority==="urgent"||h.priority==="high").length,a=s.filter(h=>h.dueDate&&new Date(h.dueDate).getTime()<Date.now()).length,l=[];n>0&&l.push(e("home.homeTasks.breakdownInProgress",{count:n})),i>0&&l.push(e("home.homeTasks.breakdownNeedsReview",{count:i}));let c=e("home.homeTasks.summaryLead",{count:s.length});l.length>0&&(c+=` — ${l.join(", ")}`),c+=".";const d=[];return o>0&&d.push(e("home.homeTasks.noteHighPriority",{count:o})),a>0&&d.push(e("home.homeTasks.noteOverdue",{count:a})),d.length>0?`${c} ${d.join(" ")}`:c}function kT(t){const e=F.c(49),{afterSummary:s}=t,n=oe(),i=jt(),{items:o,error:a}=m6(),l=p6(),{data:c}=Q2();let d;if(e[0]!==c?.data?.members){const C=c?.data?.members??[];d=new Map(C.map(TT)),e[0]=c?.data?.members,e[1]=d}else d=e[1];const h=d,[u,f]=N.useState("all"),[m,p]=N.useState(!1);let g,x,v,b,_,y;if(e[2]!==s||e[3]!==a||e[4]!==o||e[5]!==h||e[6]!==i||e[7]!==n||e[8]!==u){const C=a?[]:o,A=[...C].sort(NT);let P;e[15]!==n?(P=(B,z)=>n(B,z),e[15]=n,e[16]=P):P=e[16];const V=CT(C,P),T=u==="all"?A:A.filter(B=>B.status===u);let R;e[17]!==i?(R=()=>i({to:".",search:VT}),e[17]=i,e[18]=R):R=e[18];const E=R;b="flex flex-col gap-10";let I;e[19]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(b6,{size:24,className:"mt-0.5"}),e[19]=I):I=e[19],_=r.jsxs("div",{className:"flex items-start gap-4 animate-in fade-in slide-in-from-top-1 duration-300",children:[I,r.jsx("p",{className:"max-w-3xl text-lg font-medium leading-snug text-foreground",children:V})]}),y=s,g="flex flex-col gap-4";let D;e[20]!==n?(D=n("home.homeTasks.tasksHeading"),e[20]=n,e[21]=D):D=e[21];let M;e[22]!==D?(M=r.jsx("h2",{className:"text-base font-medium text-foreground",children:D}),e[22]=D,e[23]=M):M=e[23];let O;e[24]!==n||e[25]!==u?(O=ST.map(B=>r.jsx("button",{type:"button",onClick:()=>f(B.id),className:ie("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",u===B.id?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:n(B.labelKey)},B.id)),e[24]=n,e[25]=u,e[26]=O):O=e[26];let $;e[27]!==O?($=r.jsx("div",{className:"flex items-center gap-1",children:O}),e[27]=O,e[28]=$):$=e[28],e[29]!==M||e[30]!==$?(x=r.jsxs("div",{className:"flex items-center gap-3",children:[M,$]}),e[29]=M,e[30]=$,e[31]=x):x=e[31],v=T.length===0?r.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-2xl bg-card px-4 py-10 text-center card-shadow",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:u==="all"?n("home.homeTasks.emptyStateNoTasks"):n("home.homeTasks.emptyStateNothing",{status:n(u==="in_progress"?"home.homeTasks.statusInProgress":u==="in_review"?"home.homeTasks.statusInReview":"home.homeTasks.statusDone")})}),u==="all"&&r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[r.jsx(_t,{className:"size-4"}),n("home.homeTasks.createNewTask")]})]}):r.jsxs("div",{className:"flex flex-col gap-2",children:[T.slice(0,wT).map(B=>r.jsx(jT,{task:B,assignee:B.assigneeId?h.get(B.assigneeId):void 0,onOpen:E},B.id)),r.jsxs("button",{type:"button",onClick:E,className:"flex w-full items-center justify-center gap-1.5 rounded-2xl bg-card px-4 py-3 text-sm font-medium text-muted-foreground card-shadow transition-colors hover:bg-accent/60 hover:text-foreground",children:[n("home.homeTasks.seeAllTasks"),r.jsx(J2,{className:"size-3.5"})]})]}),e[2]=s,e[3]=a,e[4]=o,e[5]=h,e[6]=i,e[7]=n,e[8]=u,e[9]=g,e[10]=x,e[11]=v,e[12]=b,e[13]=_,e[14]=y}else g=e[9],x=e[10],v=e[11],b=e[12],_=e[13],y=e[14];let L;e[32]!==g||e[33]!==x||e[34]!==v?(L=r.jsxs("section",{className:g,children:[x,v]}),e[32]=g,e[33]=x,e[34]=v,e[35]=L):L=e[35];let w;e[36]===Symbol.for("react.memo_cache_sentinel")?(w=()=>p(!1),e[36]=w):w=e[36];let j;e[37]!==l.create?(j=C=>{l.create.mutate(C),p(!1)},e[37]=l.create,e[38]=j):j=e[38];let S;e[39]!==l.create.isPending||e[40]!==m||e[41]!==j?(S=r.jsx(g6,{open:m,onClose:w,isSaving:l.create.isPending,onSubmit:j}),e[39]=l.create.isPending,e[40]=m,e[41]=j,e[42]=S):S=e[42];let k;return e[43]!==S||e[44]!==b||e[45]!==_||e[46]!==y||e[47]!==L?(k=r.jsxs("div",{className:b,children:[_,y,L,S]}),e[43]=S,e[44]=b,e[45]=_,e[46]=y,e[47]=L,e[48]=k):k=e[48],k}function VT(t){return{...t,main:"board"}}function NT(t,e){return(e.updatedAt??"").localeCompare(t.updatedAt??"")}function TT(t){return[t.userId,t]}function AT(t){const e=F.c(29),{isEditMode:s,hasChanges:n,onEnter:i,onSave:o,onCancel:a,onAddTile:l}=t,c=oe();if(!s){let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(d2,{size:14}),e[0]=y):y=e[0];let L;e[1]!==c?(L=c("home.customizeToolbar.label"),e[1]=c,e[2]=L):L=e[2];let w;return e[3]!==i||e[4]!==L?(w=r.jsxs(le,{type:"button",size:"sm",variant:"ghost",onClick:i,className:"h-8 gap-1.5 text-muted-foreground",children:[y,L]}),e[3]=i,e[4]=L,e[5]=w):w=e[5],w}let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(_t,{size:14}),e[6]=d):d=e[6];let h;e[7]!==c?(h=c("home.customizeToolbar.addTile"),e[7]=c,e[8]=h):h=e[8];let u;e[9]!==l||e[10]!==h?(u=r.jsxs(le,{type:"button",size:"sm",variant:"ghost",onClick:l,className:"h-8 gap-1.5",children:[d,h]}),e[9]=l,e[10]=h,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(an,{size:14}),e[12]=f):f=e[12];let m;e[13]!==c?(m=c("home.customizeToolbar.cancel"),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==a||e[16]!==m?(p=r.jsxs(le,{type:"button",size:"sm",variant:"ghost",onClick:a,className:"h-8 gap-1.5",children:[f,m]}),e[15]=a,e[16]=m,e[17]=p):p=e[17];const g=!n;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(ns,{size:14}),e[18]=x):x=e[18];let v;e[19]!==c?(v=c("home.customizeToolbar.save"),e[19]=c,e[20]=v):v=e[20];let b;e[21]!==o||e[22]!==g||e[23]!==v?(b=r.jsxs(le,{type:"button",size:"sm",onClick:o,disabled:g,className:"h-8 gap-1.5",children:[x,v]}),e[21]=o,e[22]=g,e[23]=v,e[24]=b):b=e[24];let _;return e[25]!==b||e[26]!==u||e[27]!==p?(_=r.jsxs("div",{className:"flex items-center gap-1",children:[u,p,b]}),e[25]=b,e[26]=u,e[27]=p,e[28]=_):_=e[28],_}function ET(){const t=F.c(18),{isEditMode:e,enter:s,save:n,cancel:i,hasChanges:o}=Z9(),[a,l]=N.useState(!1),c=rc();let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(kT,{afterSummary:r.jsx(JC,{})}),t[0]=d):d=t[0];let h;t[1]!==i||t[2]!==s||t[3]!==o||t[4]!==e||t[5]!==c||t[6]!==n?(h=!c&&r.jsx("div",{className:"flex justify-end",children:r.jsx(AT,{isEditMode:e,hasChanges:o,onEnter:s,onSave:n,onCancel:i,onAddTile:()=>l(!0)})}),t[1]=i,t[2]=s,t[3]=o,t[4]=e,t[5]=c,t[6]=n,t[7]=h):h=t[7];let u;t[8]!==e?(u=r.jsx(CN,{isEditMode:e}),t[8]=e,t[9]=u):u=t[9];let f;t[10]!==h||t[11]!==u?(f=r.jsxs("div",{className:"@container mx-auto flex max-w-5xl flex-col gap-10 px-6 py-8",children:[d,r.jsxs("div",{className:"flex flex-col gap-4",children:[h,u]})]}),t[10]=h,t[11]=u,t[12]=f):f=t[12];let m;t[13]!==a?(m=r.jsx(ZN,{open:a,onOpenChange:l}),t[13]=a,t[14]=m):m=t[14];let p;return t[15]!==f||t[16]!==m?(p=r.jsxs("div",{className:"h-full overflow-y-auto",children:[f,m]}),t[15]=f,t[16]=m,t[17]=p):p=t[17],p}function PT(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(WC,{children:r.jsx(ET,{})}),t[0]=e):e=t[0],e}const RT={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function jr(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,s)=>{if(s.startsWith("#x")||s.startsWith("#X")){const n=Number.parseInt(s.slice(2),16);return Number.isFinite(n)?String.fromCodePoint(n):e}if(s.startsWith("#")){const n=Number.parseInt(s.slice(1),10);return Number.isFinite(n)?String.fromCodePoint(n):e}return RT[s]??e}):""}const DT=10,_f=100,IT=30;function MT(t){const e=t;if(e.isError)return null;const s=e.content?.find(i=>i.type==="resource"),n=s?.resource?.text??s?.text;if(!n)return null;try{const i=JSON.parse(n);return typeof i=="string"?i:i&&typeof i=="object"&&"content"in i&&typeof i.content=="string"?i.content:JSON.stringify(i,null,2)}catch{return n}}async function Ea(t,e,s){try{const n=await t.callTool({name:"get_file_contents",arguments:{owner:e.owner,repo:e.repo,path:e.path,...s}});return MT(n)}catch{return null}}function OT(t){const e=qi(t);return Array.isArray(e)?e.map(s=>{const n=Number(s.additions??0),i=Number(s.changes??n),o=Number(s.deletions??Math.max(0,i-n));return{filename:String(s.filename??""),status:s.status??"modified",additions:n,deletions:o,blobUrl:typeof s.blob_url=="string"?s.blob_url:null,previousFilename:typeof s.previous_filename=="string"?s.previous_filename:null}}):[]}async function $T(t,e,s){if(t.length===0)return;let n=0;async function i(){for(;n<t.length;){const o=n++;await s(t[o])}}await Promise.all(Array.from({length:Math.min(e,t.length)},()=>i()))}async function BT(t,e){const s=[];for(let n=1;n<=IT;n++){const i=await t.callTool({name:"pull_request_read",arguments:{method:"get_files",owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,page:n,perPage:_f}}),o=OT(i);if(s.push(...o),o.length<_f)break}return s}async function Lf(t,e){const n=(await BT(t,e)).filter(a=>a.filename.length>0),i={},o=e.mergeBaseSha?{sha:e.mergeBaseSha}:{ref:e.base};return await $T(n,DT,async a=>{const l=a.filename;if(a.status==="added"){i[l]={from:null,to:await Ea(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})};return}if(a.status==="removed"){i[l]={from:await Ea(t,{owner:e.owner,repo:e.repo,path:l},o),to:null};return}const c=a.previousFilename??l,[d,h]=await Promise.all([Ea(t,{owner:e.owner,repo:e.repo,path:c},o),Ea(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})]);i[l]={from:d,to:h}}),{diffs:i}}function jg(t){return t?Object.keys(t.diffs).length:0}function Ji(t,e,s,n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/git/${n}`}class Cg extends Error{constructor(e,s){super(e),this.status=s,this.name="SandboxGitError"}status}function gu(t){return t instanceof Cg&&(t.status===503||t.status===410||t.status===404)}async function Xi(t){const e=await t.json();if(!t.ok)throw new Cg(typeof e.error=="string"?e.error:`Request failed (${t.status})`,t.status);return e}function Qi(t,e){return fetch(t,{cache:"no-store",...e})}async function Za(t,e,s){const n=await Qi(Ji(t,e,s,"status"));return Xi(n)}async function mr(t,e,s,n){const i=n?.base||n?.headSha?{...n.base?{base:n.base}:{},...n.headSha?{headSha:n.headSha}:{}}:void 0,o=await Qi(Ji(t,e,s,"diff"),{method:"POST",headers:i?{"content-type":"application/json"}:void 0,body:i?JSON.stringify(i):void 0});return Xi(o)}function kg(t){const e={};for(const[s,n]of Object.entries(t.diffs))Vg(s)||Ng(s)||(e[s]=n);return{...t,diffs:e}}async function Sf(t,e,s,n){const i=n?{status:n.status,diff:kg(n.diff)}:{},o=await Qi(Ji(t,e,s,"suggest-commit"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)});return Xi(o)}async function wf(t,e,s,n){const i=await Qi(Ji(t,e,s,"publish"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:n})});await Xi(i)}async function FT(t,e,s,n){const i=await Qi(Ji(t,e,s,"rebase"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({base:n})});await Xi(i)}function Vg(t){return t==="blocks.gen.json"||t.endsWith("/blocks.gen.json")}function Ng(t){return t==="static/tailwind.css"||t.endsWith("/static/tailwind.css")}function zT(t){return t===".deco"||t.endsWith("/.deco")||t.startsWith(".deco/")||t.includes("/.deco/")}function Tg(t){if(!t)return!1;const e=Object.keys(t.diffs);return e.length===0?!1:e.every(s=>zT(s)||Vg(s)||Ng(s))}const KT="smart";function UT(t){return t==="code-review"||t==="open"||t==="smart"?t:KT}function HT(t){let e=5381;const s=n=>{for(let i=0;i<n.length;i++)e=(e<<5)+e+n.charCodeAt(i)|0};for(const n of Object.keys(t.diffs).sort()){const i=t.diffs[n];s(n),s("\0from:"),s(i?.from??""),s("\0to:"),s(i?.to??""),s("\0\0")}return(e>>>0).toString(36)}async function WT(t,e,s,n){const i=await Qi(Ji(t,e,s,"judge-review"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({status:n.status,diff:kg(n.diff),...n.language?{language:n.language}:{}})});return Xi(i)}async function jf(t,e,s,n){const i=await Qi(Ji(t,e,s,"discard"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({filepaths:n})});await Xi(i)}const qT="current";function GT(t){return t?.[qT]??null}function Lq(t,e,s){return["sandbox-git-status",t,e,s]}function Ag(t){return t?t.modified.length+t.created.length+t.deleted.length+t.not_added.length+t.renamed.length:0}function wc(t){return t?Ag(t)>0||t.staged.length>0||t.conflicted.length>0:!1}function Eg(t){return t?wc(t)||t.ahead>0||(t.unpushed??0)>0?!0:t.unpushed===void 0&&(t.aheadOfBase??0)>0&&t.tracking==null:!1}function YT(t,e){return t?Eg(t)||e!=null&&Object.keys(e.diffs).length>0:!1}function JT(t,e){return wc(t)?!1:e.openPrFromCommits||!e.commitToOpenPr&&(t?.aheadOfBase??0)>0}function Pg(t,e){return{diffs:{...t?.diffs??{},...e?.diffs??{}},...t?.mergeBaseSha?{mergeBaseSha:t.mergeBaseSha}:{}}}function XT(t,e="code-review"){return e==="open"?{allowed:!0,reason:null}:Tg(t)?{allowed:!0,reason:null}:{allowed:!1,reason:null}}function QT(t,e){return e!=="smart"||!t||Object.keys(t.diffs).length===0?!1:!Tg(t)}function ZT(t,e){if(e)return{allowed:!1,reason:null,pending:!0};if(!t)return{allowed:!0,reason:null};if(!t.requiresReview)return{allowed:!0,reason:null};const s=t.reason?.trim();return{allowed:!1,reason:s||null}}function eA(t,e,s,n,i,o,a){return["pr-diff",t,e,s,n,i,o,a]}function tA(t){const e=F.c(26),{orgSlug:s,orgId:n,virtualMcpId:i,branch:o,base:a,headSha:l,pullNumber:c,connectionId:d,owner:h,repo:u,enabled:f}=t,m=f===void 0?!0:f;let p;e[0]!==d||e[1]!==n||e[2]!==s?(p={connectionId:d,orgId:n,orgSlug:s},e[0]=d,e[1]=n,e[2]=s,e[3]=p):p=e[3];const g=pt(p);let x;e[4]!==a||e[5]!==o||e[6]!==d||e[7]!==l||e[8]!==s||e[9]!==c||e[10]!==i?(x=eA(s,i,o,a,l,c,d),e[4]=a,e[5]=o,e[6]=d,e[7]=l,e[8]=s,e[9]=c,e[10]=i,e[11]=x):x=e[11];let v;e[12]!==a||e[13]!==o||e[14]!==g||e[15]!==l||e[16]!==s||e[17]!==h||e[18]!==c||e[19]!==u||e[20]!==i?(v=async()=>{try{const y=await mr(s,i,o,{base:a,headSha:l});return jg(y)>0?y:Lf(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l,mergeBaseSha:y.mergeBaseSha})}catch{return Lf(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l})}},e[12]=a,e[13]=o,e[14]=g,e[15]=l,e[16]=s,e[17]=h,e[18]=c,e[19]=u,e[20]=i,e[21]=v):v=e[21];const b=m&&!!o&&!!l&&!!d;let _;return e[22]!==x||e[23]!==v||e[24]!==b?(_={queryKey:x,queryFn:v,enabled:b,refetchInterval:3e4,staleTime:1e4},e[22]=x,e[23]=v,e[24]=b,e[25]=_):_=e[25],Pt(_)}E8.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});function sA(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function Rg(t){const e=F.c(9),{diff:s,emptyMessage:n,rowClassName:i,onDiscardFile:o}=t,a=n===void 0?"No file changes in the working tree":n,l=i===void 0?"px-6":i,[c,d]=N.useState(null),[h,u]=N.useState(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=sA(),e[0]=f):f=e[0];const m=f;if(!s||Object.keys(s.diffs).length===0){let g;return e[1]!==a?(g=r.jsx("div",{className:"flex items-center justify-center py-10 text-sm text-muted-foreground",children:a}),e[1]=a,e[2]=g):g=e[2],g}let p;return e[3]!==s.diffs||e[4]!==h||e[5]!==c||e[6]!==o||e[7]!==l?(p=r.jsx("div",{className:"divide-y",children:Object.entries(s.diffs).map(g=>{const[x,v]=g,{from:b,to:_}=v,y=c===x,L=b===null,w=_===null,j=x.startsWith("/")?x.slice(1):x,S=j.lastIndexOf("/"),k=S>=0?j.slice(S+1):j,C=S>=0?j.slice(0,S):null,A=kb(x),P=L?"bg-success":w?"bg-destructive":"bg-warning";return r.jsxs("div",{children:[r.jsxs("div",{className:ie("flex items-center gap-3 py-3 hover:bg-muted/30",l),children:[r.jsx("button",{type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-transform hover:text-foreground",onClick:()=>d(y?null:x),children:r.jsx(yn,{className:ie("h-3.5 w-3.5 transition-transform",y&&"rotate-90")})}),r.jsx("div",{className:ie("h-2.5 w-2.5 shrink-0 rounded-full",P)}),r.jsx(R2,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:k}),C&&r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:C}),o?r.jsxs(vs,{children:[r.jsx(bs,{asChild:!0,children:r.jsx("button",{type:"button",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground",children:r.jsx(Ki,{className:"h-3.5 w-3.5"})})}),r.jsx(ys,{align:"end",children:r.jsx(Je,{className:"text-destructive focus:text-destructive",onSelect:()=>u(x),children:"Discard changes"})})]}):null]}),h===x&&o?r.jsxs("div",{className:ie("flex items-center justify-between gap-3 border-t bg-destructive/5 py-2.5",l),children:[r.jsxs("span",{className:"text-xs text-destructive",children:["Discard all changes to"," ",r.jsx("span",{className:"font-medium",children:k}),"? This cannot be undone."]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(null),children:"Cancel"}),r.jsx(le,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:()=>{u(null),o(x)},children:"Discard"})]})]}):null,y&&r.jsx("div",{className:"border-t",children:r.jsx(P8,{original:b??"",modified:_??"",language:A,theme:m,height:"380px",options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12}})})]},x)})}),e[3]=s.diffs,e[4]=h,e[5]=c,e[6]=o,e[7]=l,e[8]=p):p=e[8],p}function nA(t){const e=F.c(14),{diffQuery:s}=t,n=oe();if(s.isLoading){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ze,{className:"h-4 w-4 animate-spin"}),e[0]=l):l=e[0];let c;e[1]!==n?(c=n("thread.changesTab.loadingChanges"),e[1]=n,e[2]=c):c=e[2];let d;return e[3]!==c?(d=r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[l,r.jsx("span",{className:"text-sm",children:c})]}),e[3]=c,e[4]=d):d=e[4],d}if(s.isError){let l;e[5]!==n?(l=n("thread.changesTab.couldntLoadPrChanges"),e[5]=n,e[6]=l):l=e[6];let c;return e[7]!==l?(c=r.jsx("div",{className:"py-10 text-sm text-destructive",children:l}),e[7]=l,e[8]=c):c=e[8],c}const i=s.data;let o;e[9]!==n?(o=n("thread.changesTab.noCommittedChanges"),e[9]=n,e[10]=o):o=e[10];let a;return e[11]!==s.data||e[12]!==o?(a=r.jsx(Rg,{diff:i,rowClassName:"px-0",emptyMessage:o}),e[11]=s.data,e[12]=o,e[13]=a):a=e[13],a}const Zi="The user clicked this action deliberately — execute directly. Do not call user_ask unless you hit an actual problem outside the scope of this intent (missing auth, unresolvable conflict, a check with multiple plausible fixes).";function iA(t){return`Reopen PR #${t.prNumber}. ${Zi}`}function rA(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${Zi}`}function oA(t){return`Re-run the \`${t.checkName}\` check on PR #${t.prNumber}. If an empty commit is needed to retrigger CI, create and push one. ${Zi}`}function aA(t){const e=(t.failingChecks??[]).map(s=>`\`${s}\``).join(", ");return`PR #${t.prNumber} has failing checks: ${e}. For each: read the logs, diagnose the root cause, apply the smallest fix that makes it pass, commit, and push. ${Zi}`}function lA(t){return`Mark PR #${t.prNumber} ready for review. ${Zi}`}function cA(t){return`Read the unresolved review threads on PR #${t.prNumber}. For each thread: understand the reviewer's ask, apply the needed changes, commit, push, reply explaining what changed, and resolve the thread. If a comment is a question that doesn't need a code change, reply with the answer and resolve. ${Zi}`}function dA(t){return`Review PR #${t.prNumber}. Read the full diff, analyze every changed file for correctness, security, code quality, and alignment with the repo's patterns. Post specific line-level review comments on concerns, then submit an overall review (approve / request changes / comment) with a concise summary. Do not modify the code — this is a read-and-comment pass. ${Zi}`}function uA(t){const e=F.c(35),{pr:s,connectionId:n,owner:i,repo:o}=t,{org:a}=ze(),l=Js(),c=oe();let d;e[0]!==n||e[1]!==a.id||e[2]!==a.slug||e[3]!==i||e[4]!==s.number||e[5]!==o?(d={orgId:a.id,orgSlug:a.slug,connectionId:n,owner:i,repo:o,prNumber:s.number},e[0]=n,e[1]=a.id,e[2]=a.slug,e[3]=i,e[4]=s.number,e[5]=o,e[6]=d):d=e[6];const h=Wp(d);let u;e[7]!==l||e[8]!==s.number?(u=v=>l.sendMessage({parts:[{type:"text",text:oA({prNumber:s.number,checkName:v})}]}),e[7]=l,e[8]=s.number,e[9]=u):u=e[9];const f=u;if(h.isLoading){let v;e[10]!==c?(v=c("thread.checksTab.loadingChecks"),e[10]=c,e[11]=v):v=e[11];let b;return e[12]!==v?(b=r.jsx("div",{className:"text-sm text-muted-foreground",children:v}),e[12]=v,e[13]=b):b=e[13],b}if(h.isError){let v;e[14]!==c?(v=c("thread.checksTab.couldntLoadCheckRuns"),e[14]=c,e[15]=v):v=e[15];let b;return e[16]!==v?(b=r.jsx("div",{className:"text-sm text-destructive",children:v}),e[16]=v,e[17]=b):b=e[17],b}let m;e[18]!==h.data?(m=h.data??[],e[18]=h.data,e[19]=m):m=e[19];const p=m;if(p.length===0){let v;e[20]!==c?(v=c("thread.checksTab.noCheckRunsOnPrHeadCommit"),e[20]=c,e[21]=v):v=e[21];let b;return e[22]!==v?(b=r.jsx("div",{className:"text-sm text-muted-foreground",children:v}),e[22]=v,e[23]=b):b=e[23],b}let g;if(e[24]!==l||e[25]!==p||e[26]!==f||e[27]!==c){let v;e[29]!==l||e[30]!==f||e[31]!==c?(v=b=>r.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(hA,{check:b}),r.jsx("span",{className:"truncate",children:b.name}),b.durationMs!=null&&r.jsx("span",{className:"text-xs text-muted-foreground",children:fA(b.durationMs)})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[b.htmlUrl&&r.jsx("a",{href:b.htmlUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-7 items-center justify-center rounded px-2 text-xs text-muted-foreground hover:bg-background",title:c("thread.checksTab.viewRun"),children:r.jsx($n,{className:"h-3.5 w-3.5"})}),b.conclusion==="failure"&&r.jsx(le,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>f(b.name),children:c("thread.checksTab.rerun")})]})]},b.id),e[29]=l,e[30]=f,e[31]=c,e[32]=v):v=e[32],g=p.map(v),e[24]=l,e[25]=p,e[26]=f,e[27]=c,e[28]=g}else g=e[28];let x;return e[33]!==g?(x=r.jsx("ul",{className:"flex flex-col gap-0.5",children:g}),e[33]=g,e[34]=x):x=e[34],x}function hA(t){const e=F.c(14),{check:s}=t,n=oe();if(s.status!=="completed"){let a;e[0]!==n?(a=n("thread.checksTab.inProgress"),e[0]=n,e[1]=a):a=e[1];let l;return e[2]!==a?(l=r.jsx("span",{className:"text-muted-foreground","aria-label":a,children:"○"}),e[2]=a,e[3]=l):l=e[3],l}if(s.conclusion==="success"){let a;e[4]!==n?(a=n("thread.checksTab.success"),e[4]=n,e[5]=a):a=e[5];let l;return e[6]!==a?(l=r.jsx("span",{className:"text-success","aria-label":a,children:"✓"}),e[6]=a,e[7]=l):l=e[7],l}if(s.conclusion==="failure"){let a;e[8]!==n?(a=n("thread.checksTab.failure"),e[8]=n,e[9]=a):a=e[9];let l;return e[10]!==a?(l=r.jsx("span",{className:"text-destructive","aria-label":a,children:"✗"}),e[10]=a,e[11]=l):l=e[11],l}const i=s.conclusion??"—";let o;return e[12]!==i?(o=r.jsx("span",{className:"text-muted-foreground","aria-label":i,children:"—"}),e[12]=i,e[13]=o):o=e[13],o}function fA(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}var cn="Accordion",mA=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[xu,pA,gA]=Hx(cn),[jc]=Wx(cn,[gA,Hm]),vu=Hm(),Dg=rt.forwardRef((t,e)=>{const{type:s,...n}=t,i=n,o=n;return r.jsx(xu.Provider,{scope:t.__scopeAccordion,children:s==="multiple"?r.jsx(yA,{...o,ref:e}):r.jsx(bA,{...i,ref:e})})});Dg.displayName=cn;var[Ig,xA]=jc(cn),[Mg,vA]=jc(cn,{collapsible:!1}),bA=rt.forwardRef((t,e)=>{const{value:s,defaultValue:n,onValueChange:i=()=>{},collapsible:o=!1,...a}=t,[l,c]=Om({prop:s,defaultProp:n??"",onChange:i,caller:cn});return r.jsx(Ig,{scope:t.__scopeAccordion,value:rt.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:rt.useCallback(()=>o&&c(""),[o,c]),children:r.jsx(Mg,{scope:t.__scopeAccordion,collapsible:o,children:r.jsx(Og,{...a,ref:e})})})}),yA=rt.forwardRef((t,e)=>{const{value:s,defaultValue:n,onValueChange:i=()=>{},...o}=t,[a,l]=Om({prop:s,defaultProp:n??[],onChange:i,caller:cn}),c=rt.useCallback(h=>l((u=[])=>[...u,h]),[l]),d=rt.useCallback(h=>l((u=[])=>u.filter(f=>f!==h)),[l]);return r.jsx(Ig,{scope:t.__scopeAccordion,value:a,onItemOpen:c,onItemClose:d,children:r.jsx(Mg,{scope:t.__scopeAccordion,collapsible:!0,children:r.jsx(Og,{...o,ref:e})})})}),[_A,Cc]=jc(cn),Og=rt.forwardRef((t,e)=>{const{__scopeAccordion:s,disabled:n,dir:i,orientation:o="vertical",...a}=t,l=rt.useRef(null),c=qx(l,e),d=pA(s),u=Gx(i)==="ltr",f=Yx(t.onKeyDown,m=>{if(!mA.includes(m.key))return;const p=m.target,g=d().filter(S=>!S.ref.current?.disabled),x=g.findIndex(S=>S.ref.current===p),v=g.length;if(x===-1)return;m.preventDefault();let b=x;const _=0,y=v-1,L=()=>{b=x+1,b>y&&(b=_)},w=()=>{b=x-1,b<_&&(b=y)};switch(m.key){case"Home":b=_;break;case"End":b=y;break;case"ArrowRight":o==="horizontal"&&(u?L():w());break;case"ArrowDown":o==="vertical"&&L();break;case"ArrowLeft":o==="horizontal"&&(u?w():L());break;case"ArrowUp":o==="vertical"&&w();break}const j=b%v;g[j].ref.current?.focus()});return r.jsx(_A,{scope:s,disabled:n,direction:i,orientation:o,children:r.jsx(xu.Slot,{scope:s,children:r.jsx(Mm.div,{...a,"data-orientation":o,ref:c,onKeyDown:n?void 0:f})})})}),Ml="AccordionItem",[LA,bu]=jc(Ml),$g=rt.forwardRef((t,e)=>{const{__scopeAccordion:s,value:n,...i}=t,o=Cc(Ml,s),a=xA(Ml,s),l=vu(s),c=Jx(),d=n&&a.value.includes(n)||!1,h=o.disabled||t.disabled;return r.jsx(LA,{scope:s,open:d,disabled:h,triggerId:c,children:r.jsx(Lv,{"data-orientation":o.orientation,"data-state":Hg(d),...l,...i,ref:e,disabled:h,open:d,onOpenChange:u=>{u?a.onItemOpen(n):a.onItemClose(n)}})})});$g.displayName=Ml;var Bg="AccordionHeader",Fg=rt.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,i=Cc(cn,s),o=bu(Bg,s);return r.jsx(Mm.h3,{"data-orientation":i.orientation,"data-state":Hg(o.open),"data-disabled":o.disabled?"":void 0,...n,ref:e})});Fg.displayName=Bg;var n0="AccordionTrigger",zg=rt.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,i=Cc(cn,s),o=bu(n0,s),a=vA(n0,s),l=vu(s);return r.jsx(xu.ItemSlot,{scope:s,children:r.jsx(_v,{"aria-disabled":o.open&&!a.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId,...l,...n,ref:e})})});zg.displayName=n0;var Kg="AccordionContent",Ug=rt.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,i=Cc(cn,s),o=bu(Kg,s),a=vu(s);return r.jsx(Sv,{role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation,...a,...n,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})});Ug.displayName=Kg;function Hg(t){return t?"open":"closed"}var SA=Dg,wA=$g,jA=Fg,CA=zg,kA=Ug;function VA(t){const e=F.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let n;return e[2]!==s?(n=r.jsx(SA,{"data-slot":"accordion",...s}),e[2]=s,e[3]=n):n=e[3],n}function NA(t){const e=F.c(8);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let i;e[3]!==s?(i=ie("border-b last:border-b-0",s),e[3]=s,e[4]=i):i=e[4];let o;return e[5]!==n||e[6]!==i?(o=r.jsx(wA,{"data-slot":"accordion-item",className:i,...n}),e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function TA(t){const e=F.c(11);let s,n,i;e[0]!==t?({className:n,children:s,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i):(s=e[1],n=e[2],i=e[3]);let o;e[4]!==n?(o=ie("focus-visible:border-ring focus-visible:ring-ring/20 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[2px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",n),e[4]=n,e[5]=o):o=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(yn,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=a):a=e[6];let l;return e[7]!==s||e[8]!==i||e[9]!==o?(l=r.jsx(jA,{className:"flex",children:r.jsxs(CA,{"data-slot":"accordion-trigger",className:o,...i,children:[s,a]})}),e[7]=s,e[8]=i,e[9]=o,e[10]=l):l=e[10],l}function AA(t){const e=F.c(12);let s,n,i;e[0]!==t?({className:n,children:s,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i):(s=e[1],n=e[2],i=e[3]);let o;e[4]!==n?(o=ie("pt-0 pb-4",n),e[4]=n,e[5]=o):o=e[5];let a;e[6]!==s||e[7]!==o?(a=r.jsx("div",{className:o,children:s}),e[6]=s,e[7]=o,e[8]=a):a=e[8];let l;return e[9]!==i||e[10]!==a?(l=r.jsx(kA,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...i,children:a}),e[9]=i,e[10]=a,e[11]=l):l=e[11],l}function EA(t){const e=F.c(10),{comments:s,isLoading:n,isError:i}=t;if(n||i||!s||s.length===0)return null;const o=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==o?(a=r.jsxs(TA,{className:"py-3 text-sm font-medium",children:[s.length," comment",o]}),e[0]=s.length,e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map(PA),e[3]=s,e[4]=l):l=e[4];let c;e[5]!==l?(c=r.jsx(AA,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsx(VA,{type:"single",collapsible:!0,className:"border-t border-border",children:r.jsxs(NA,{value:"comments",className:"border-b-0",children:[a,c]})}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function PA(t){return r.jsxs("div",{className:"rounded-md border border-border p-3",children:[r.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",RA(t.createdAt)]}),r.jsx(_9,{id:`pr-comment-${t.id}`,text:jr(t.body)})]},t.id)}function RA(t){if(!t)return"";const e=new Date(t).getTime();if(!Number.isFinite(e))return"";const s=Date.now()-e;if(s<0)return"just now";const n=Math.floor(s/864e5);if(n>0)return`${n}d ago`;const i=Math.floor(s/36e5);if(i>0)return`${i}h ago`;const o=Math.floor(s/6e4);return`${Math.max(1,o)}m ago`}function DA(t){const e=F.c(19),{pr:s,connectionId:n,owner:i,repo:o}=t,{org:a}=ze();let l;e[0]!==n||e[1]!==a.id||e[2]!==a.slug||e[3]!==i||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:n,owner:i,repo:o,prNumber:s.number},e[0]=n,e[1]=a.id,e[2]=a.slug,e[3]=i,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const c=zS(l);let d;e[7]!==s.body||e[8]!==s.number?(d=s.body&&r.jsx("div",{className:"text-sm",children:r.jsx(_9,{id:`pr-body-${s.number}`,text:jr(s.body)})}),e[7]=s.body,e[8]=s.number,e[9]=d):d=e[9];let h;e[10]!==c.data?(h=c.data??[],e[10]=c.data,e[11]=h):h=e[11];let u;e[12]!==c.isError||e[13]!==c.isLoading||e[14]!==h?(u=r.jsx(EA,{comments:h,isLoading:c.isLoading,isError:c.isError}),e[12]=c.isError,e[13]=c.isLoading,e[14]=h,e[15]=u):u=e[15];let f;return e[16]!==d||e[17]!==u?(f=r.jsxs("div",{className:"space-y-8",children:[d,u]}),e[16]=d,e[17]=u,e[18]=f):f=e[18],f}function IA(t){const e=F.c(68),{pr:s,virtualMcpId:n,branch:i,connectionId:o,owner:a,repo:l}=t,{org:c}=ze();let d;e[0]!==i||e[1]!==o||e[2]!==c.id||e[3]!==c.slug||e[4]!==a||e[5]!==s.base||e[6]!==s.headSha||e[7]!==s.number||e[8]!==l||e[9]!==n?(d={orgSlug:c.slug,orgId:c.id,virtualMcpId:n,branch:i,base:s.base,headSha:s.headSha,pullNumber:s.number,connectionId:o,owner:a,repo:l},e[0]=i,e[1]=o,e[2]=c.id,e[3]=c.slug,e[4]=a,e[5]=s.base,e[6]=s.headSha,e[7]=s.number,e[8]=l,e[9]=n,e[10]=d):d=e[10];const h=tA(d);let u;e[11]!==h.data?(u=h.data?jg(h.data):void 0,e[11]=h.data,e[12]=u):u=e[12];const f=u,[m,p]=N.useState("changes");let g;e[13]!==s.title?(g=jr(s.title),e[13]=s.title,e[14]=g):g=e[14];let x;e[15]!==g?(x=r.jsx("h1",{className:"text-lg font-semibold leading-tight",children:g}),e[15]=g,e[16]=x):x=e[16];const v=`Open PR #${s.number} on GitHub`;let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx($n,{className:"h-3.5 w-3.5"}),e[17]=b):b=e[17];let _;e[18]!==s.htmlUrl||e[19]!==s.number||e[20]!==v?(_=r.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":v,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,b]}),e[18]=s.htmlUrl,e[19]=s.number,e[20]=v,e[21]=_):_=e[21];let y;e[22]!==s.author?(y=s.author?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"·"}),r.jsxs("span",{children:["@",s.author]})]}):null,e[22]=s.author,e[23]=y):y=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("span",{children:"·"}),e[24]=L):L=e[24];let w;e[25]!==s.base?(w=r.jsx("span",{className:"font-mono text-xs",children:s.base}),e[25]=s.base,e[26]=w):w=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("span",{children:"←"}),e[27]=j):j=e[27];let S;e[28]!==s.head?(S=r.jsx("span",{className:"font-mono text-xs",children:s.head}),e[28]=s.head,e[29]=S):S=e[29];let k;e[30]!==w||e[31]!==S||e[32]!==_||e[33]!==y?(k=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 text-sm text-muted-foreground",children:[_,y,L,w,j,S]}),e[30]=w,e[31]=S,e[32]=_,e[33]=y,e[34]=k):k=e[34];let C;e[35]!==k||e[36]!==x?(C=r.jsx("div",{className:"shrink-0 space-y-3 pb-4",children:r.jsxs("div",{className:"space-y-1",children:[x,k]})}),e[35]=k,e[36]=x,e[37]=C):C=e[37];let A;e[38]===Symbol.for("react.memo_cache_sentinel")?(A=z=>p(z),e[38]=A):A=e[38];let P;e[39]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(vn,{value:"description",className:"px-3 text-xs",children:"Description"}),e[39]=P):P=e[39];const V=f!==void 0?` ${f}`:"";let T;e[40]!==V?(T=r.jsxs(vn,{value:"changes",className:"px-3 text-xs",children:["Changes",V]}),e[40]=V,e[41]=T):T=e[41];let R;e[42]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(vn,{value:"checks",className:"px-3 text-xs",children:"Checks"}),e[42]=R):R=e[42];let E;e[43]!==T?(E=r.jsxs(oa,{className:"h-8 w-fit max-w-[600px] shrink-0",variant:"pill",children:[P,T,R]}),e[43]=T,e[44]=E):E=e[44];let I;e[45]!==o||e[46]!==a||e[47]!==s||e[48]!==l?(I=r.jsx(ji,{value:"description",className:"mt-0",children:r.jsx(DA,{pr:s,connectionId:o,owner:a,repo:l})}),e[45]=o,e[46]=a,e[47]=s,e[48]=l,e[49]=I):I=e[49];let D;e[50]!==h?(D=r.jsx(ji,{value:"changes",className:"mt-0",children:r.jsx(nA,{diffQuery:h})}),e[50]=h,e[51]=D):D=e[51];let M;e[52]!==o||e[53]!==a||e[54]!==s||e[55]!==l?(M=r.jsx(ji,{value:"checks",className:"mt-0",children:r.jsx(uA,{pr:s,connectionId:o,owner:a,repo:l})}),e[52]=o,e[53]=a,e[54]=s,e[55]=l,e[56]=M):M=e[56];let O;e[57]!==I||e[58]!==D||e[59]!==M?(O=r.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pt-5",children:[I,D,M]}),e[57]=I,e[58]=D,e[59]=M,e[60]=O):O=e[60];let $;e[61]!==m||e[62]!==E||e[63]!==O?($=r.jsxs(Er,{value:m,onValueChange:A,className:"flex min-h-0 flex-1 flex-col",children:[E,O]}),e[61]=m,e[62]=E,e[63]=O,e[64]=$):$=e[64];let B;return e[65]!==C||e[66]!==$?(B=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[C,$]}),e[65]=C,e[66]=$,e[67]=B):B=e[67],B}function MA(t){const e=F.c(11),{pr:s}=t,n=oe(),i=s.htmlUrl,o=String(s.number);let a;e[0]!==n||e[1]!==o?(a=n("thread.gitTab.openPrAriaLabel",{number:o}),e[0]=n,e[1]=o,e[2]=a):a=e[2];const l=String(s.number);let c;e[3]!==n||e[4]!==l?(c=n("thread.gitTab.prNumber",{number:l}),e[3]=n,e[4]=l,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx($n,{className:"h-4 w-4 text-muted-foreground"}),e[6]=d):d=e[6];let h;return e[7]!==s.htmlUrl||e[8]!==a||e[9]!==c?(h=r.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:r.jsxs("a",{href:i,target:"_blank",rel:"noreferrer","aria-label":a,className:"inline-flex items-center gap-1.5 text-base font-medium text-foreground hover:underline",children:[c,d]})}),e[7]=s.htmlUrl,e[8]=a,e[9]=c,e[10]=h):h=e[10],h}function OA(t){const e=F.c(24),{virtualMcpId:s}=t,n=oe(),{org:i}=ze(),o=ms(s),{currentBranch:a}=ls(),l=o?.metadata?.githubRepo??null;if(!l?.connectionId){let d;e[0]!==n?(d=n("thread.gitTab.notLinkedToGithub"),e[0]=n,e[1]=d):d=e[1];let h;return e[2]!==d?(h=r.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=h):h=e[3],h}if(!a){let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(en,{className:"h-6 w-6 text-muted-foreground"}),e[4]=d):d=e[4];let h;e[5]!==n?(h=n("thread.gitTab.noBranchSelected"),e[5]=n,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx("div",{className:"text-muted-foreground",children:h}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==n?(f=n("thread.gitTab.pickBranchForPrStatus"),e[9]=n,e[10]=f):f=e[10];let m;e[11]!==f?(m=r.jsx("div",{className:"text-xs text-muted-foreground",children:f}),e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==u||e[14]!==m?(p=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[d,u,m]}),e[13]=u,e[14]=m,e[15]=p):p=e[15],p}let c;return e[16]!==a||e[17]!==l.connectionId||e[18]!==l.name||e[19]!==l.owner||e[20]!==i.id||e[21]!==i.slug||e[22]!==s?(c=r.jsx($A,{orgId:i.id,orgSlug:i.slug,virtualMcpId:s,connectionId:l.connectionId,owner:l.owner,repo:l.name,branch:a}),e[16]=a,e[17]=l.connectionId,e[18]=l.name,e[19]=l.owner,e[20]=i.id,e[21]=i.slug,e[22]=s,e[23]=c):c=e[23],c}function $A(t){const e=F.c(69),s=oe(),{orgId:n,orgSlug:i,virtualMcpId:o,connectionId:a,owner:l,repo:c,branch:d}=t;let h;e[0]!==d||e[1]!==a||e[2]!==n||e[3]!==i||e[4]!==l||e[5]!==c?(h={orgId:n,orgSlug:i,connectionId:a,owner:l,repo:c,branch:d},e[0]=d,e[1]=a,e[2]=n,e[3]=i,e[4]=l,e[5]=c,e[6]=h):h=e[6];const{data:u,isLoading:f,isError:m}=O9(h),p=BA;if(f){let j;e[7]!==s?(j=s("thread.gitTab.loadingPrState"),e[7]=s,e[8]=j):j=e[8];let S;return e[9]!==j?(S=r.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:j}),e[9]=j,e[10]=S):S=e[10],S}if(m){let j;e[11]!==s?(j=s("thread.gitTab.couldNotLoadPrState"),e[11]=s,e[12]=j):j=e[12];let S;return e[13]!==j?(S=r.jsx("div",{className:"p-4 text-sm text-destructive",children:j}),e[13]=j,e[14]=S):S=e[14],S}const g=`https://github.com/${l}/${c}/tree/${d}`;if(u&&u.state==="closed"){let j;e[15]!==u?(j=r.jsx(MA,{pr:u}),e[15]=u,e[16]=j):j=e[16];let S;e[17]!==u.merged||e[18]!==s?(S=u.merged?s("thread.gitTab.merged"):s("thread.gitTab.closed"),e[17]=u.merged,e[18]=s,e[19]=S):S=e[19];let k;e[20]!==u.base||e[21]!==s?(k=s("thread.gitTab.into",{base:u.base}),e[20]=u.base,e[21]=s,e[22]=k):k=e[22];let C;e[23]!==u.mergedAt?(C=u.mergedAt&&r.jsxs(r.Fragment,{children:[" · ",new Date(u.mergedAt).toLocaleDateString()]}),e[23]=u.mergedAt,e[24]=C):C=e[24];let A;e[25]!==u.author||e[26]!==s?(A=u.author&&r.jsxs(r.Fragment,{children:[" · ",s("thread.gitTab.by",{author:u.author})]}),e[25]=u.author,e[26]=s,e[27]=A):A=e[27];let P;e[28]!==S||e[29]!==k||e[30]!==C||e[31]!==A?(P=r.jsxs("div",{className:"text-sm text-success",children:[S," ",k,C,A]}),e[28]=S,e[29]=k,e[30]=C,e[31]=A,e[32]=P):P=e[32];let V;e[33]!==u.title?(V=jr(u.title),e[33]=u.title,e[34]=V):V=e[34];let T;e[35]!==V?(T=r.jsx("h1",{className:"text-lg font-semibold",children:V}),e[35]=V,e[36]=T):T=e[36];let R;e[37]!==u.body||e[38]!==u.number?(R=u.body&&r.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:r.jsx(_9,{id:`pr-body-${u.number}`,text:jr(u.body)})}),e[37]=u.body,e[38]=u.number,e[39]=R):R=e[39];let E;e[40]!==P||e[41]!==T||e[42]!==R?(E=r.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[P,T,R]}),e[40]=P,e[41]=T,e[42]=R,e[43]=E):E=e[43];let I;return e[44]!==j||e[45]!==E?(I=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[j,E]}),e[44]=j,e[45]=E,e[46]=I):I=e[46],I}if(u&&u.state==="open"){let j;return e[47]!==d||e[48]!==a||e[49]!==l||e[50]!==u||e[51]!==c||e[52]!==o?(j=r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:r.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col px-6 py-5",children:r.jsx(IA,{pr:u,virtualMcpId:o,branch:d,connectionId:a,owner:l,repo:c})})}),e[47]=d,e[48]=a,e[49]=l,e[50]=u,e[51]=c,e[52]=o,e[53]=j):j=e[53],j}let x;e[54]!==s?(x=s("thread.gitTab.noPrYet"),e[54]=s,e[55]=x):x=e[55];let v;e[56]!==x?(v=r.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-4 text-sm",children:x}),e[56]=x,e[57]=v):v=e[57];let b;e[58]!==g?(b=()=>p(g),e[58]=g,e[59]=b):b=e[59];let _;e[60]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx($n,{className:"mr-1.5 h-4 w-4"}),e[60]=_):_=e[60];let y;e[61]!==s?(y=s("thread.gitTab.openBranchOnGithub"),e[61]=s,e[62]=y):y=e[62];let L;e[63]!==b||e[64]!==y?(L=r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(le,{size:"sm",variant:"outline",onClick:b,children:[_,y]})}),e[63]=b,e[64]=y,e[65]=L):L=e[65];let w;return e[66]!==v||e[67]!==L?(w=r.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[v,L]}),e[66]=v,e[67]=L,e[68]=w):w=e[68],w}function BA(t){window.open(t,"_blank","noopener,noreferrer")}const Pn={previewTab:"tour-tab-preview",dropdown:"tour-dropdown",edit:"tour-edit",visualEditor:"tour-visual-editor",device:"tour-device",branches:"tour-branches",submit:"tour-submit",publish:"tour-publish"};function Wg(t){return`[data-tour="${Pn[t]}"]`}const FA=[{anchor:"previewTab",titleKey:"cmsTour.preview.title",descKey:"cmsTour.preview.description",side:"bottom"},{anchor:"dropdown",titleKey:"cmsTour.dropdown.title",descKey:"cmsTour.dropdown.description",side:"bottom"},{anchor:"edit",titleKey:"cmsTour.edit.title",descKey:"cmsTour.edit.description",side:"bottom"},{anchor:"visualEditor",titleKey:"cmsTour.visualEditor.title",descKey:"cmsTour.visualEditor.description",side:"top"},{anchor:"device",titleKey:"cmsTour.device.title",descKey:"cmsTour.device.description",side:"top"},{anchor:"branches",titleKey:"cmsTour.branches.title",descKey:"cmsTour.branches.description",side:"bottom"},{anchor:"submit",titleKey:"cmsTour.submit.title",descKey:"cmsTour.submit.description",side:"bottom"},{anchor:"publish",titleKey:"cmsTour.publish.title",descKey:"cmsTour.publish.description",side:"bottom"}];function zA(t){return FA.map(e=>({element:Wg(e.anchor),popover:{title:t(e.titleKey),description:t(e.descKey),side:e.side,align:"center"}}))}const KA=Wg("edit"),Cf=t=>t6(Em.cmsTourSeen(t));function qg(t){const e=document.querySelector(t);return e instanceof HTMLElement&&e.offsetParent!==null}function UA(t){return zA(t).filter(e=>typeof e.element=="string"&&qg(e.element))}function HA(t,e){return{showProgress:!0,progressText:t("cmsTour.progress"),nextBtnText:t("cmsTour.next"),prevBtnText:t("cmsTour.prev"),doneBtnText:t("cmsTour.done"),showButtons:["next","previous"],smoothScroll:!0,allowClose:!0,disableActiveInteraction:!0,stagePadding:6,stageRadius:8,waitForElement:0,skipMissingElement:!0,popoverClass:"cms-tour-popover",onPopoverRender:(s,{driver:n})=>{if(s.footerButtons.querySelector(".cms-tour-skip"))return;const i=document.createElement("button");i.type="button",i.className="driver-popover-footer-btn cms-tour-skip",i.textContent=t("cmsTour.skip"),i.addEventListener("click",()=>n.destroy()),s.footerButtons.insertBefore(i,s.footerButtons.firstChild)},onDestroyed:()=>{ar=!1},steps:e}}let ar=!1;async function WA(){return(await Ns(()=>import("./driver.js-Dj4CfABu.js"),[])).driver}function Gg(t,e){if(ar)return;ar=!0;let s=0;const n=()=>{if(qg(KA)){const i=UA(t);if(i.length===0){ar=!1;return}e?.(),WA().then(o=>{o(HA(t,i)).drive()}).catch(()=>{ar=!1});return}s++<60?requestAnimationFrame(n):ar=!1};n()}function qA(t){Gg(t)}function GA(t){const{virtualMcpId:e}=t,s=oe(),n=ms(e),i=Ps(),{data:o}=ui.useSession(),a=o?.user?.id,l=$s(n?.metadata),c=i.lifecycle.phase==="running",d=l&&c&&!!a,[h,u]=N.useState(!1);return!h&&d&&a&&!Cf(a).has()&&(u(!0),queueMicrotask(()=>Gg(s,()=>Cf(a).mark()))),null}const YA={mode:"none",iframeBase:null,showBlockingOverlay:!1,showWakingPill:!1};function JA(t){const{previewState:e,progressStatus:s,productionUrl:n}=t;return e.kind==="suspended"||e.kind==="errored"||e.kind==="othersThread"?YA:e.kind==="iframe"&&s!=="doing"?{mode:"sandbox",iframeBase:e.previewUrl,showBlockingOverlay:!1,showWakingPill:!1}:n?{mode:"production",iframeBase:n,showBlockingOverlay:!1,showWakingPill:!0}:{mode:"none",iframeBase:null,showBlockingOverlay:!0,showWakingPill:!1}}function kf(t){const e=F.c(10);let s,n,i;e[0]!==t?({children:s,className:n,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i):(s=e[1],n=e[2],i=e[3]);let o;e[4]!==n?(o=ie("flex h-12 shrink-0 items-center gap-1 px-1.5",n),e[4]=n,e[5]=o):o=e[5];let a;return e[6]!==s||e[7]!==i||e[8]!==o?(a=r.jsx("div",{className:o,...i,children:s}),e[6]=s,e[7]=i,e[8]=o,e[9]=a):a=e[9],a}const Hr=N.createContext(null);function XA(t){const e=F.c(6),{children:s}=t,[n,i]=N.useState(null),[o,a]=N.useState(null);let l;e[0]!==o||e[1]!==n?(l={slotEl:n,setSlotEl:i,endActionsEl:o,setEndActionsEl:a},e[0]=o,e[1]=n,e[2]=l):l=e[2];let c;return e[3]!==s||e[4]!==l?(c=r.jsx(Hr,{value:l,children:s}),e[3]=s,e[4]=l,e[5]=c):c=e[5],c}function QA(t){const e=F.c(5),{className:s}=t,i=N.use(Hr)?.setSlotEl;let o;e[0]!==s?(o=ie("flex min-w-0 items-center",s),e[0]=s,e[1]=o):o=e[1];let a;return e[2]!==i||e[3]!==o?(a=r.jsx("div",{ref:i,className:o}),e[2]=i,e[3]=o,e[4]=a):a=e[4],a}function ZA(){const t=F.c(2),s=N.use(Hr)?.setEndActionsEl;let n;return t[0]!==s?(n=r.jsx("div",{ref:s,className:"contents"}),t[0]=s,t[1]=n):n=t[1],n}function eE({children:t}){const e=N.use(Hr);return e?.slotEl?Zs.createPortal(t,e.slotEl):null}function tE({children:t}){const e=N.use(Hr);return e?.endActionsEl?Zs.createPortal(t,e.endActionsEl):null}function sE(){return N.use(Hr)?.slotEl??null}const Yg=t=>`preview-terminal-visible:${t}`;function nE(t){try{const e=localStorage.getItem(Yg(t));return e?!!JSON.parse(e).visible:!1}catch{return!1}}function iE(t,e){try{localStorage.setItem(Yg(t),JSON.stringify({visible:e}))}catch{}}const Jg=N.createContext(null);function rE({virtualMcpId:t,children:e}){const s=t??"__no-vmcp__",[n,i]=N.useState(null),o=N.useRef(null);o.current!==s&&(o.current=s,i(nE(s)));const a=l=>{i(l),iE(s,l)};return r.jsx(Jg,{value:{visible:n??!1,setVisible:a},children:e})}function Xg(){return N.use(Jg)}const oE=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function aE(t){return t.includes("matchers")||t.includes("Match")}function Qg(t,e){const s=t.__resolveType;return typeof s!="string"||!s||oE.has(s)?!1:e?sw(e,s):aE(s)}function lE(t,e){const s=[];for(const[n,i]of Object.entries(e)){if(n.includes("/")||!_n(n)||fc(n)||!i||typeof i!="object"||Array.isArray(i))continue;const o=i;Qg(o,t)&&s.push({blockKey:n,matcherResolveType:o.__resolveType??"",name:typeof o.name=="string"?o.name:void 0})}return s.sort((n,i)=>(n.name??n.blockKey).localeCompare(i.name??i.blockKey))}function Wr(t,e,s){if(!t)return!1;const n=t.__resolveType;if(typeof n!="string"||!_n(n)||!Object.hasOwn(e,n))return!1;const i=e[n];return!i||typeof i!="object"||Array.isArray(i)?!1:Qg(i,s)}function cE(t,e,s){return Wr(t,e,s)?t?.__resolveType??null:null}function Zg(t,e,s){if(!t)return null;const n=t.__resolveType??"";if(!n)return null;if(Wr(t,e,s)){const a=e[n]??{},l=a.__resolveType??n,{__resolveType:c,name:d,...h}=a;return{resolveType:l,data:h,blockKey:n}}const{__resolveType:i,...o}=t;return{resolveType:n,data:o}}function e4(t,e,s){const n=Zg(t,e,s);return n?{__resolveType:n.resolveType,...n.data}:{__resolveType:""}}function Sq(t,e,s){if(t)return Wr(t,e,s)?e4(t,e,s):t}function dE(t,e,s,n){if(!t)return"Default";if(Wr(t,e,n)){const i=t.__resolveType??"",o=e[i];return pc(i,o)}return s(t)}function wq(t,e,s){return{__resolveType:t,...e,name:s}}function uE(t){return{__resolveType:t}}function jq(t,e,s){const n=Zg(t,e,s);return n?{resolveType:n.resolveType,formValue:n.data}:{resolveType:"",formValue:{}}}const Vf="x-deco-matchers-override";function t4({pageKey:t,prefix:e,variants:s,selectedIndex:n,decofile:i,meta:o}){if(!t||n<0||n>=s.length)return[];const a=[];for(let l=0;l<=n;l++){const c=s[l];if(!c)continue;const d=c.rule,h=l===n?"1":"0",f=(Wr(d,i,o)?cE(d,i,o):null)??`${t}@${e}.${l}.rule`;a.push(`${f}=${h}`)}return a}function Cq(t,e,s,n){return!e.multivariate||e.variants.length<=1?[]:t4({pageKey:t,prefix:"sections.variants",variants:e.variants,selectedIndex:e.index,decofile:s,meta:n})}function kq({pageKey:t,page:e,sectionIndex:s,sectionLazy:n,mvObj:i,selectedVariantIndex:o,decofile:a,meta:l}){if(s<0)return[];const d=`${e.multivariate?`sections.variants.${e.index}.value`:"sections"}.${s}${n?".section":""}.variants`,h=Array.isArray(i.variants)?i.variants:[];return t4({pageKey:t,prefix:d,variants:h,selectedIndex:o,decofile:a,meta:l})}function hE(t,e){if(e.length===0)return t;const s=new URL(t,"http://local");s.searchParams.delete(Vf);for(const n of e)s.searchParams.append(Vf,n);return t.startsWith("http")?s.toString():`${s.pathname}${s.search}${s.hash}`}function s4(t){return btoa(encodeURIComponent(t))}function Nf(t,e,s){const n=new URL(t).origin,i=new URL(`/live/previews/${encodeURIComponent(e)}`,n);return i.searchParams.set("path","/"),i.searchParams.set("pathTemplate","/"),i.searchParams.set("props",s4(JSON.stringify({path:"/",sections:[{__resolveType:s}]}))),i.searchParams.set("__cb",crypto.randomUUID()),i.toString()}function Vq(t,e,s,n){const i=new URL(t).origin,o=new URL(`/live/previews/${encodeURIComponent(e)}`,i);o.searchParams.set("__d","");const a=[{__resolveType:"preview",block:s}];return n&&a.push(n),o.searchParams.set("props",s4(JSON.stringify({sections:a}))),o.toString()}const Tf={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function yu(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function n4(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:Tf.seoResolveType},__resolveType:Tf.resolveType}}const fE=700;function kc(t){const e=F.c(22),{orgSlug:s,virtualMcpId:n,branch:i}=t,o=Ls(),a=ms(n)?.metadata?.runtime?.path??null;let l;e[0]!==i||e[1]!==s||e[2]!==a||e[3]!==n?(l=async f=>{const{blockKey:m,data:p}=f,g=Ir(a,j2(m)),x=JSON.stringify(p,null,2),v=await fetch(`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(i)}/write`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:g,content:x})});if(!v.ok){const b=await v.json().catch(mE);throw new Error(b.error??`Write failed (${v.status})`)}return v.json()},e[0]=i,e[1]=s,e[2]=a,e[3]=n,e[4]=l):l=e[4];let c;e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==n?(c=async f=>{const{blockKey:m,data:p}=f,g=`${s}/${n}/${i}`,x=Qe.decofile(g);await o.cancelQueries({queryKey:x});const v=o.getQueryData(x);return o.setQueryData(x,b=>({...b??{},[m]:p})),{previous:v,queryKey:x}},e[5]=i,e[6]=s,e[7]=o,e[8]=n,e[9]=c):c=e[9];let d;e[10]!==o?(d=(f,m,p)=>{p?.queryKey&&o.setQueryData(p.queryKey,p.previous)},e[10]=o,e[11]=d):d=e[11];let h;e[12]!==i||e[13]!==s||e[14]!==o||e[15]!==n?(h=(f,m)=>{const{blockKey:p,data:g}=m,x=`${s}/${n}/${i}`;o.setQueryData(Qe.decofile(x),v=>({...v??{},[p]:g}))},e[12]=i,e[13]=s,e[14]=o,e[15]=n,e[16]=h):h=e[16];let u;return e[17]!==l||e[18]!==c||e[19]!==d||e[20]!==h?(u={mutationFn:l,onMutate:c,onError:d,onSuccess:h},e[17]=l,e[18]=c,e[19]=d,e[20]=h,e[21]=u):u=e[21],Ys(u)}function mE(){return{}}function i4(t,e){const s=F.c(15),n=kc(t);let i;s[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Map,s[0]=i):i=s[0];const o=N.useRef(i);let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,s[1]=a):a=s[1];const l=N.useRef(a);let c;s[2]!==e||s[3]!==n?(c=v=>{const b=o.current.get(v);if(!b)return;const _=typeof b=="function"?b():b;o.current.delete(v),_&&n.mutate({blockKey:v,data:_},{onSuccess:()=>e?.onSaved?.(),onError:pE})},s[2]=e,s[3]=n,s[4]=c):c=s[4];const d=c;let h;s[5]!==d?(h=()=>{for(const v of l.current.values())clearTimeout(v);l.current.clear();for(const v of[...o.current.keys()])d(v)},s[5]=d,s[6]=h):h=s[6];const u=h;let f,m;s[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const v=l.current;return()=>{for(const b of v.values())clearTimeout(b)}},m=[],s[7]=f,s[8]=m):(f=s[7],m=s[8]),N.useEffect(f,m);let p;s[9]!==d?(p=(v,b)=>{o.current.set(v,b);const _=l.current.get(v);_&&clearTimeout(_),l.current.set(v,setTimeout(()=>{l.current.delete(v),d(v)},fE))},s[9]=d,s[10]=p):p=s[10];const g=p;let x;return s[11]!==u||s[12]!==g||s[13]!==n.isPending?(x={save:g,flush:u,isPending:n.isPending},s[11]=u,s[12]=g,s[13]=n.isPending,s[14]=x):x=s[14],x}function pE(t){return ve.error(`Save failed: ${t.message}`)}function gE(t){const e=F.c(5);let s;e[0]!==t?(s=t??{orgSlug:"",virtualMcpId:"",branch:""},e[0]=t,e[1]=s):s=e[1];const n=kc(s);let i;return e[2]!==t||e[3]!==n?(i={mutationFn:async o=>{const{name:a,path:l,template:c}=o;if(!t?.virtualMcpId||!t.branch)throw new Error("Sandbox not ready");const d=yu(a),h=c?{...c,name:a,path:l}:n4(a,l);return await n.mutateAsync({blockKey:d,data:h}),{key:d,name:a,path:l}}},e[2]=t,e[3]=n,e[4]=i):i=e[4],Ys(i)}const si="__blank__";function r4(t){const e=F.c(65),{id:s,value:n,onChange:i,templates:o,disabled:a}=t,l=oe(),[c,d]=N.useState(!1);let h;if(e[0]!==o||e[1]!==n){let M;e[3]!==n?(M=O=>O.key===n,e[3]=n,e[4]=M):M=e[4],h=o.find(M),e[0]=o,e[1]=n,e[2]=h}else h=e[2];const u=h;let f;e[5]!==u?.name||e[6]!==l?(f=u?.name??l("sectionsEditor.pageTemplateSelect.blankPageDefaultLabel"),e[5]=u?.name,e[6]=l,e[7]=f):f=e[7];let m;e[8]!==f?(m=r.jsx("span",{className:"truncate",children:f}),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==u?(p=u?.path?r.jsx("span",{className:"truncate text-muted-foreground",children:u.path}):null,e[10]=u,e[11]=p):p=e[11];let g;e[12]!==m||e[13]!==p?(g=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[m,p]}),e[12]=m,e[13]=p,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(k9,{className:"shrink-0 opacity-50"}),e[15]=x):x=e[15];let v;e[16]!==a||e[17]!==s||e[18]!==c||e[19]!==g?(v=r.jsx(Ts,{asChild:!0,children:r.jsxs(le,{id:s,type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:a,className:"w-full justify-between font-normal",children:[g,x]})}),e[16]=a,e[17]=s,e[18]=c,e[19]=g,e[20]=v):v=e[20];let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b={width:"var(--radix-popover-trigger-width)"},e[21]=b):b=e[21];let _;e[22]!==l?(_=l("sectionsEditor.pageTemplateSelect.searchPlaceholder"),e[22]=l,e[23]=_):_=e[23];let y;e[24]!==_?(y=r.jsx(Hi,{placeholder:_,className:"h-9"}),e[24]=_,e[25]=y):y=e[25];let L;e[26]!==l?(L=l("sectionsEditor.pageTemplateSelect.noPagesFoundMessage"),e[26]=l,e[27]=L):L=e[27];let w;e[28]!==L?(w=r.jsx(oi,{children:L}),e[28]=L,e[29]=w):w=e[29];let j;e[30]!==l?(j=l("sectionsEditor.pageTemplateSelect.blankPageLabel"),e[30]=l,e[31]=j):j=e[31];let S;e[32]!==i?(S=()=>{i(si),d(!1)},e[32]=i,e[33]=S):S=e[33];let k;e[34]!==l?(k=l("sectionsEditor.pageTemplateSelect.blankPageLabel"),e[34]=l,e[35]=k):k=e[35];const C=n===si?"opacity-100":"opacity-0";let A;e[36]!==C?(A=ie("ml-auto",C),e[36]=C,e[37]=A):A=e[37];let P;e[38]!==A?(P=r.jsx(ns,{className:A}),e[38]=A,e[39]=P):P=e[39];let V;e[40]!==j||e[41]!==S||e[42]!==k||e[43]!==P?(V=r.jsxs(ks,{value:j,onSelect:S,children:[k,P]}),e[40]=j,e[41]=S,e[42]=k,e[43]=P,e[44]=V):V=e[44];let T;if(e[45]!==i||e[46]!==o||e[47]!==n){let M;e[49]!==i||e[50]!==n?(M=O=>r.jsxs(ks,{value:`${O.name} ${O.path}`,onSelect:()=>{i(O.key),d(!1)},children:[r.jsxs("div",{className:"flex min-w-0 flex-col",children:[r.jsx("span",{className:"truncate",children:O.name}),r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:O.path})]}),r.jsx(ns,{className:ie("ml-auto",n===O.key?"opacity-100":"opacity-0")})]},O.key),e[49]=i,e[50]=n,e[51]=M):M=e[51],T=o.map(M),e[45]=i,e[46]=o,e[47]=n,e[48]=T}else T=e[48];let R;e[52]!==V||e[53]!==T?(R=r.jsxs(Os,{children:[V,T]}),e[52]=V,e[53]=T,e[54]=R):R=e[54];let E;e[55]!==w||e[56]!==R?(E=r.jsxs(Wi,{onWheel:xE,children:[w,R]}),e[55]=w,e[56]=R,e[57]=E):E=e[57];let I;e[58]!==y||e[59]!==E?(I=r.jsx(As,{className:"p-0",style:b,children:r.jsxs(Dr,{children:[y,E]})}),e[58]=y,e[59]=E,e[60]=I):I=e[60];let D;return e[61]!==c||e[62]!==I||e[63]!==v?(D=r.jsxs(Es,{open:c,onOpenChange:d,children:[v,I]}),e[61]=c,e[62]=I,e[63]=v,e[64]=D):D=e[64],D}function xE(t){const e=t.deltaMode===1?16:1;t.currentTarget.scrollTop=t.currentTarget.scrollTop+t.deltaY*e}function vE(t){const e=F.c(89),{open:s,onOpenChange:n,isPending:i,error:o,templates:a,onSubmit:l}=t,c=i===void 0?!1:i,d=oe();let h;e[0]!==d?(h=d("sectionsEditor.createPageModal.defaultPageName"),e[0]=d,e[1]=h):h=e[1];const[u,f]=N.useState(h);let m;e[2]!==d?(m=d("sectionsEditor.createPageModal.defaultPagePath"),e[2]=d,e[3]=m):m=e[3];const[p,g]=N.useState(m),[x,v]=N.useState(si),[b,_]=N.useState(null),[y,L]=N.useState(s);s!==y&&(L(s),s&&(f(d("sectionsEditor.createPageModal.defaultPageName")),g(d("sectionsEditor.createPageModal.defaultPagePath")),v(si),_(null)));const w=!!a?.length;let j;e[4]!==c||e[5]!==n?(j=re=>{!re&&!c&&(_(null),n(!1))},e[4]=c,e[5]=n,e[6]=j):j=e[6];const S=j;let k;e[7]!==c||e[8]!==u||e[9]!==l||e[10]!==p||e[11]!==w||e[12]!==x?(k=async re=>{re.preventDefault();const de=u.trim(),ce=p.trim();if(!de||!ce||c)return;const fe=U9(ce);if(fe){_(fe);return}_(null),await l({name:de,path:ce,templateKey:w&&x!==si?x:null})},e[7]=c,e[8]=u,e[9]=l,e[10]=p,e[11]=w,e[12]=x,e[13]=k):k=e[13];const C=k,A=b??o;let P;e[14]!==d?(P=d("sectionsEditor.createPageModal.title"),e[14]=d,e[15]=P):P=e[15];let V;e[16]!==P?(V=r.jsx(cs,{children:r.jsx(ds,{children:P})}),e[16]=P,e[17]=V):V=e[17];let T;e[18]!==d?(T=d("sectionsEditor.createPageModal.nameLabel"),e[18]=d,e[19]=T):T=e[19];let R;e[20]!==T?(R=r.jsx("label",{htmlFor:"new-page-name",className:"text-xs font-medium text-muted-foreground",children:T}),e[20]=T,e[21]=R):R=e[21];let E;e[22]===Symbol.for("react.memo_cache_sentinel")?(E=re=>f(re.target.value),e[22]=E):E=e[22];let I;e[23]!==d?(I=d("sectionsEditor.createPageModal.namePlaceholder"),e[23]=d,e[24]=I):I=e[24];let D;e[25]!==c||e[26]!==u||e[27]!==I?(D=r.jsx(et,{id:"new-page-name",value:u,onChange:E,placeholder:I,autoFocus:!0,disabled:c}),e[25]=c,e[26]=u,e[27]=I,e[28]=D):D=e[28];let M;e[29]!==D||e[30]!==R?(M=r.jsxs("div",{className:"space-y-1.5",children:[R,D]}),e[29]=D,e[30]=R,e[31]=M):M=e[31];let O;e[32]!==d?(O=d("sectionsEditor.createPageModal.pathLabel"),e[32]=d,e[33]=O):O=e[33];let $;e[34]!==O?($=r.jsx("label",{htmlFor:"new-page-path",className:"text-xs font-medium text-muted-foreground",children:O}),e[34]=O,e[35]=$):$=e[35];let B;e[36]===Symbol.for("react.memo_cache_sentinel")?(B=re=>g(re.target.value),e[36]=B):B=e[36];let z;e[37]!==d?(z=d("sectionsEditor.createPageModal.pathPlaceholder"),e[37]=d,e[38]=z):z=e[38];let K;e[39]!==c||e[40]!==p||e[41]!==z?(K=r.jsx(et,{id:"new-page-path",value:p,onChange:B,placeholder:z,disabled:c}),e[39]=c,e[40]=p,e[41]=z,e[42]=K):K=e[42];let Y;e[43]!==$||e[44]!==K?(Y=r.jsxs("div",{className:"space-y-1.5",children:[$,K]}),e[43]=$,e[44]=K,e[45]=Y):Y=e[45];let Q;e[46]!==c||e[47]!==w||e[48]!==d||e[49]!==x||e[50]!==a?(Q=w&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"new-page-template",className:"text-xs font-medium text-muted-foreground",children:d("sectionsEditor.createPageModal.templateLabel")}),r.jsx(r4,{id:"new-page-template",value:x,onChange:v,templates:a??[],disabled:c})]}),e[46]=c,e[47]=w,e[48]=d,e[49]=x,e[50]=a,e[51]=Q):Q=e[51];let q;e[52]!==A?(q=A&&r.jsx("p",{className:"text-xs text-destructive",children:A}),e[52]=A,e[53]=q):q=e[53];let H;e[54]!==M||e[55]!==Y||e[56]!==Q||e[57]!==q?(H=r.jsxs("div",{className:"space-y-4 py-4",children:[M,Y,Q,q]}),e[54]=M,e[55]=Y,e[56]=Q,e[57]=q,e[58]=H):H=e[58];let U;e[59]!==n?(U=()=>n(!1),e[59]=n,e[60]=U):U=e[60];let X;e[61]!==d?(X=d("sectionsEditor.createPageModal.cancelButton"),e[61]=d,e[62]=X):X=e[62];let J;e[63]!==c||e[64]!==U||e[65]!==X?(J=r.jsx(le,{type:"button",variant:"outline",onClick:U,disabled:c,children:X}),e[63]=c,e[64]=U,e[65]=X,e[66]=J):J=e[66];let ee;e[67]!==c||e[68]!==u||e[69]!==p?(ee=!u.trim()||!p.trim()||c,e[67]=c,e[68]=u,e[69]=p,e[70]=ee):ee=e[70];let W;e[71]!==c||e[72]!==d?(W=c?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{size:14,className:"animate-spin"}),d("sectionsEditor.createPageModal.creatingButton")]}):d("sectionsEditor.createPageModal.createButton"),e[71]=c,e[72]=d,e[73]=W):W=e[73];let Z;e[74]!==ee||e[75]!==W?(Z=r.jsx(le,{type:"submit",disabled:ee,children:W}),e[74]=ee,e[75]=W,e[76]=Z):Z=e[76];let G;e[77]!==J||e[78]!==Z?(G=r.jsxs(mi,{children:[J,Z]}),e[77]=J,e[78]=Z,e[79]=G):G=e[79];let te;e[80]!==C||e[81]!==H||e[82]!==G||e[83]!==V?(te=r.jsx(Yt,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:C,children:[V,H,G]})}),e[80]=C,e[81]=H,e[82]=G,e[83]=V,e[84]=te):te=e[84];let se;return e[85]!==S||e[86]!==s||e[87]!==te?(se=r.jsx(Jt,{open:s,onOpenChange:S,children:te}),e[85]=S,e[86]=s,e[87]=te,e[88]=se):se=e[88],se}const bE=sn({tag:os(),id:os(),classes:os(),text:os(),html:os(),manifestKey:os().nullable(),componentName:os().nullable(),parents:os(),url:os(),path:os(),viewport:sn({width:ho(),height:ho()}),position:sn({x:ho(),y:ho()})}),yE=`(function() {
17
- if (window.__visualEditorActive) return;
18
- window.__visualEditorActive = true;
19
-
20
- var cursorStyle = document.createElement("style");
21
- cursorStyle.textContent = "* { cursor: default !important; }";
22
- document.head.appendChild(cursorStyle);
23
-
24
- var highlight = document.createElement("div");
25
- highlight.style.cssText = "position:fixed;pointer-events:none;outline:2px solid #a855f7;background:rgba(168,85,247,0.08);border-radius:2px;z-index:2147483647;display:none;";
26
- document.body.appendChild(highlight);
27
-
28
- var badge = document.createElement("div");
29
- badge.style.cssText = "position:fixed;pointer-events:none;background:#a855f7;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
30
- document.body.appendChild(badge);
31
-
32
- var lastTarget = null;
33
- var rafPending = false;
34
- var moveHandler = function(e) {
35
- if (rafPending) return;
36
- rafPending = true;
37
- var target = e.target;
38
- requestAnimationFrame(function() {
39
- rafPending = false;
40
- var el = target;
41
- if (!el || el === highlight || el === badge) return;
42
- if (el === lastTarget) return;
43
- lastTarget = el;
44
- var r = el.getBoundingClientRect();
45
- highlight.style.display = "block";
46
- highlight.style.top = r.top + "px";
47
- highlight.style.left = r.left + "px";
48
- highlight.style.width = r.width + "px";
49
- highlight.style.height = r.height + "px";
50
- var tag = el.tagName.toLowerCase();
51
- var id = el.id ? "#" + el.id : "";
52
- var cls = el.className && typeof el.className === "string"
53
- ? "." + el.className.trim().split(/\\s+/).slice(0, 2).join(".")
54
- : "";
55
- badge.textContent = tag + id + cls;
56
- badge.style.display = "block";
57
- badge.style.top = Math.max(0, r.top - 20) + "px";
58
- badge.style.left = r.left + "px";
59
- });
60
- };
61
- document.addEventListener("mousemove", moveHandler, true);
62
-
63
- var outHandler = function(e) {
64
- if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
65
- highlight.style.display = "none";
66
- badge.style.display = "none";
67
- lastTarget = null;
68
- }
69
- };
70
- document.addEventListener("mouseout", outHandler, true);
71
-
72
- var clickHandler = function(e) {
73
- e.preventDefault();
74
- e.stopImmediatePropagation();
75
- var el = e.target;
76
- if (!el || el === highlight || el === badge) return;
77
-
78
- highlight.style.outline = "2px solid #a855f7";
79
- highlight.style.background = "rgba(168,85,247,0.15)";
80
- setTimeout(function() {
81
- highlight.style.outline = "2px solid #a855f7";
82
- highlight.style.background = "rgba(168,85,247,0.08)";
83
- }, 400);
84
-
85
- var tag = el.tagName.toLowerCase();
86
- var id = el.id || "";
87
- var classes = el.className && typeof el.className === "string" ? el.className.trim() : "";
88
- var text = (el.textContent || "").trim().slice(0, 200);
89
- var html = (el.outerHTML || "").slice(0, 800).replace(/\\svalue=("[^"]*"|'[^']*'|\\S+)/gi, "");
90
-
91
- var closestSection = el.closest("section[data-manifest-key]");
92
- var manifestKey = closestSection ? closestSection.getAttribute("data-manifest-key") : null;
93
-
94
- var ancestor = el;
95
- var componentName = null;
96
- for (var i = 0; i < 10 && ancestor; i++) {
97
- if (ancestor.dataset) componentName = ancestor.dataset.componentName || componentName;
98
- ancestor = ancestor.parentElement;
99
- }
100
-
101
- var parents = [];
102
- var p = el.parentElement;
103
- for (var j = 0; j < 4 && p && p !== document.body; j++) {
104
- var pTag = p.tagName ? p.tagName.toLowerCase() : "";
105
- var pId = p.id ? "#" + p.id : "";
106
- var pCls = p.className && typeof p.className === "string"
107
- ? "." + p.className.trim().split(/\\s+/)[0]
108
- : "";
109
- parents.unshift(pTag + pId + pCls);
110
- p = p.parentElement;
111
- }
112
-
113
- window.parent.postMessage({
114
- type: "visual-editor::element-clicked",
115
- payload: {
116
- tag: tag, id: id, classes: classes, text: text, html: html,
117
- manifestKey: manifestKey, componentName: componentName,
118
- parents: parents.join(" > "),
119
- url: window.location.href, path: window.location.pathname,
120
- viewport: { width: window.innerWidth, height: window.innerHeight },
121
- position: { x: Math.round(e.clientX), y: Math.round(e.clientY) }
122
- }
123
- }, "*");
124
- };
125
- document.addEventListener("click", clickHandler, true);
126
-
127
- window.addEventListener("message", function(e) {
128
- if (e.data && e.data.type === "visual-editor::deactivate") {
129
- highlight.remove();
130
- badge.remove();
131
- cursorStyle.remove();
132
- document.removeEventListener("mousemove", moveHandler, true);
133
- document.removeEventListener("mouseout", outHandler, true);
134
- document.removeEventListener("click", clickHandler, true);
135
- window.__visualEditorActive = false;
136
- }
137
- });
138
- })();`,_E=sn({sectionIndex:ho(),manifestKey:os()}),LE=`(function() {
139
- if (window.__cmsEditorActive) return;
140
- window.__cmsEditorActive = true;
141
-
142
- // Preserve scroll across variant-override navigations and save-reloads.
143
- // Selecting a variant rebuilds the iframe src (new x-deco-matchers-override)
144
- // or reloads it, which would otherwise jump to the top. We persist the scroll
145
- // offset to sessionStorage (survives reload, same-origin) keyed by pathname
146
- // (the override only changes the query, so the key is stable), then restore it
147
- // on the next load — retried for ~1s so it outlasts re-hydration and lazy
148
- // sections that grow the page after load. The recency guard avoids restoring a
149
- // stale offset on a genuinely fresh visit.
150
- var SCROLL_KEY = "__cms_preview_scroll:" + location.pathname;
151
- var saveScroll = function() {
152
- try {
153
- sessionStorage.setItem(SCROLL_KEY, JSON.stringify({
154
- x: window.scrollX, y: window.scrollY, t: Date.now()
155
- }));
156
- } catch (_) {}
157
- };
158
- var saveScrollPending = false;
159
- window.addEventListener("scroll", function() {
160
- if (saveScrollPending) return;
161
- saveScrollPending = true;
162
- requestAnimationFrame(function() { saveScrollPending = false; saveScroll(); });
163
- }, { passive: true });
164
- (function restoreScroll() {
165
- var raw = null;
166
- try { raw = sessionStorage.getItem(SCROLL_KEY); } catch (_) {}
167
- if (!raw) return;
168
- var saved = null;
169
- try { saved = JSON.parse(raw); } catch (_) { return; }
170
- if (!saved || (Date.now() - saved.t) > 10000) return;
171
- if (!saved.x && !saved.y) return;
172
- var attempts = 0;
173
- var apply = function() {
174
- attempts++;
175
- window.scrollTo(saved.x || 0, saved.y || 0);
176
- if (attempts < 8) setTimeout(apply, 120);
177
- };
178
- apply();
179
- })();
180
-
181
- var highlight = document.createElement("div");
182
- highlight.style.cssText = "position:absolute;pointer-events:none;outline:2px solid #06b6d4;background:rgba(6,182,212,0.06);border-radius:2px;z-index:2147483647;display:none;";
183
- document.body.appendChild(highlight);
184
-
185
- var badge = document.createElement("div");
186
- badge.style.cssText = "position:absolute;pointer-events:none;background:#06b6d4;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
187
- document.body.appendChild(badge);
188
-
189
- var isTopLevelSection = function(el) {
190
- return el && el.parentElement
191
- ? !el.parentElement.closest("section[data-manifest-key]")
192
- : true;
193
- };
194
-
195
- // All top-level page sections in DOM order (deco renders page sections as
196
- // <section data-manifest-key>; nested islands/sections carry the attribute
197
- // too, hence the top-level filter). This is the full DOM run, framework
198
- // sections included — getAllSections() narrows it to the editable window.
199
- var topLevelSections = function() {
200
- return Array.from(document.querySelectorAll("section[data-manifest-key]"))
201
- .filter(isTopLevelSection);
202
- };
203
-
204
- // Candidate manifest keys per editable section, sent by the editor. Each
205
- // entry is an array of acceptable DOM keys: [] = wildcard (e.g. multivariate,
206
- // whose rendered key we can't predict); null = renders NOTHING (hidden
207
- // section — multivariate whose variants are all gated by never), so the
208
- // alignment must not consume a DOM node for it; a Lazy lists both its loader
209
- // key and the inner section's key, since the classic runtime keeps the Lazy
210
- // wrapper at top level while TanStack renders the inner section directly.
211
- var sectionCandidates = [];
212
-
213
- // Best in-order assignment of editable sections to DOM sections, maximizing
214
- // key matches (DP / LCS-style). deco injects framework sections (SEO, Theme,
215
- // Session, …) that may lead, trail, OR interleave with the editable run; this
216
- // skips whichever don't match, on any runtime — no hardcoded list. Hidden
217
- // sections (null candidates) have no DOM node: only visible entries are
218
- // aligned, then scattered back to their decofile positions (null-filled), so
219
- // returned indexes still match the decofile array.
220
- var computeAlignment = function(tops) {
221
- var visible = [], k;
222
- for (k = 0; k < sectionCandidates.length; k++) {
223
- if (sectionCandidates[k] !== null) visible.push(k);
224
- }
225
- var N = visible.length, M = tops.length;
226
- var res = new Array(sectionCandidates.length).fill(null);
227
- if (!N) return res;
228
- if (M < N) return tops.slice();
229
- var domKeys = tops.map(function(s) { return s.getAttribute("data-manifest-key"); });
230
- var match = function(i, j) {
231
- var c = sectionCandidates[visible[i]];
232
- if (!c || !c.length) return 1;
233
- return c.indexOf(domKeys[j]) >= 0 ? 1 : 0;
234
- };
235
- var dp = [], bt = [], i, j;
236
- for (i = 0; i <= N; i++) { dp.push(new Array(M + 1).fill(0)); bt.push(new Array(M + 1).fill(0)); }
237
- for (i = 1; i <= N; i++) {
238
- for (j = i; j <= M; j++) {
239
- var assign = dp[i - 1][j - 1] + match(i - 1, j - 1);
240
- var skip = dp[i][j - 1];
241
- if (j - 1 >= i && skip >= assign) { dp[i][j] = skip; bt[i][j] = 0; }
242
- else { dp[i][j] = assign; bt[i][j] = 1; }
243
- }
244
- }
245
- i = N; j = M;
246
- while (i > 0) {
247
- if (bt[i][j] === 1) { res[visible[i - 1]] = tops[j - 1]; i--; j--; }
248
- else { j--; }
249
- }
250
- return res;
251
- };
252
-
253
- // Editable sections, indexed to match the decofile array the panel uses.
254
- // Recomputed from the live DOM each call (cheap, rAF-throttled) so it
255
- // self-heals as client-rendered/lazy sections mount. Until the editor sends
256
- // candidates, fall back to the full top-level run.
257
- var getAllSections = function() {
258
- var tops = topLevelSections();
259
- return sectionCandidates.length ? computeAlignment(tops) : tops;
260
- };
261
-
262
- // Resolve to the OUTERMOST page-level section (clicking nested content still
263
- // maps to the top-level section the panel indexes); null if it isn't in the
264
- // aligned editable set (a framework section deco injected).
265
- var findSection = function(el) {
266
- var node = el;
267
- var found = null;
268
- while (node && node !== document.body) {
269
- if (node.tagName === "SECTION" && node.hasAttribute && node.hasAttribute("data-manifest-key")) {
270
- found = node;
271
- }
272
- node = node.parentElement;
273
- }
274
- if (!found) return null;
275
- return getAllSections().indexOf(found) >= 0 ? found : null;
276
- };
277
-
278
- // Lazy sections async-render their real section inside a wrapper, so the
279
- // wrapper's key is just the loader. Show the inner section's key instead
280
- // (falling back to the wrapper while the content hasn't loaded yet).
281
- var LAZY_KEY = "website/sections/Rendering/Lazy.tsx";
282
- var displayKey = function(section) {
283
- var key = section.getAttribute("data-manifest-key") || "section";
284
- if (key === LAZY_KEY) {
285
- var inner = section.querySelector("section[data-manifest-key]");
286
- if (inner) return inner.getAttribute("data-manifest-key") || key;
287
- }
288
- return key;
289
- };
290
-
291
- // Per-section metadata sent by the editor, aligned by index with
292
- // getAllSections(). labels: names the DOM can't carry (a global section or a
293
- // global inside async rendering); kinds: section type that drives the color.
294
- var sectionLabels = [];
295
- var sectionKinds = [];
296
- var labelFor = function(section) {
297
- var idx = getAllSections().indexOf(section);
298
- if (idx >= 0 && sectionLabels[idx]) return sectionLabels[idx];
299
- return displayKey(section);
300
- };
301
- var kindFor = function(section) {
302
- var idx = getAllSections().indexOf(section);
303
- return (idx >= 0 && sectionKinds[idx]) || "normal";
304
- };
305
-
306
- // Highlight palette by section kind: global = light purple, variant = green,
307
- // normal = blue.
308
- var COLORS = {
309
- normal: { solid: "#06b6d4", bg: "rgba(6,182,212,0.06)", active: "rgba(6,182,212,0.18)" },
310
- global: { solid: "#c084fc", bg: "rgba(192,132,252,0.10)", active: "rgba(192,132,252,0.22)" },
311
- variant: { solid: "#22c55e", bg: "rgba(34,197,94,0.08)", active: "rgba(34,197,94,0.20)" }
312
- };
313
- var applyColor = function(kind) {
314
- var c = COLORS[kind] || COLORS.normal;
315
- highlight.style.outline = "2px solid " + c.solid;
316
- highlight.style.background = c.bg;
317
- badge.style.background = c.solid;
318
- };
319
-
320
- var lastSection = null;
321
- var lastLabel = "";
322
- var lastKind = "normal";
323
- var rafPending = false;
324
-
325
- // Document-relative coordinates (rect + scroll) on absolutely-positioned
326
- // nodes, so the browser scrolls the highlight together with the page
327
- // natively — no per-frame JS repositioning, no scroll lag.
328
- var positionHighlight = function(section) {
329
- var r = section.getBoundingClientRect();
330
- var top = r.top + window.scrollY;
331
- var left = r.left + window.scrollX;
332
- highlight.style.display = "block";
333
- highlight.style.top = top + "px";
334
- highlight.style.left = left + "px";
335
- highlight.style.width = r.width + "px";
336
- highlight.style.height = r.height + "px";
337
- badge.textContent = lastLabel || displayKey(section);
338
- badge.style.display = "block";
339
- badge.style.top = Math.max(0, top - 20) + "px";
340
- badge.style.left = left + "px";
341
- };
342
-
343
- var moveHandler = function(e) {
344
- if (rafPending) return;
345
- rafPending = true;
346
- var target = e.target;
347
- requestAnimationFrame(function() {
348
- rafPending = false;
349
- if (!target || target === highlight || target === badge) return;
350
- var section = findSection(target);
351
- if (section === lastSection) return;
352
- lastSection = section;
353
- if (!section) {
354
- highlight.style.display = "none";
355
- badge.style.display = "none";
356
- return;
357
- }
358
- lastLabel = labelFor(section);
359
- lastKind = kindFor(section);
360
- applyColor(lastKind);
361
- positionHighlight(section);
362
- });
363
- };
364
- document.addEventListener("mousemove", moveHandler, true);
365
-
366
- // Window scroll is handled natively by the absolute positioning above; this
367
- // only re-syncs on resize and on scrolls inside nested scroll containers
368
- // (capture=true catches those), where document coordinates do shift.
369
- var reposition = function() {
370
- if (!lastSection || highlight.style.display === "none") return;
371
- if (rafPending) return;
372
- rafPending = true;
373
- requestAnimationFrame(function() {
374
- rafPending = false;
375
- if (lastSection && highlight.style.display !== "none") positionHighlight(lastSection);
376
- });
377
- };
378
- window.addEventListener("scroll", reposition, { capture: true, passive: true });
379
- window.addEventListener("resize", reposition, { passive: true });
380
-
381
- var outHandler = function(e) {
382
- if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
383
- highlight.style.display = "none";
384
- badge.style.display = "none";
385
- lastSection = null;
386
- }
387
- };
388
- document.addEventListener("mouseout", outHandler, true);
389
-
390
- var clickHandler = function(e) {
391
- e.preventDefault();
392
- e.stopImmediatePropagation();
393
- var target = e.target;
394
- if (!target || target === highlight || target === badge) return;
395
- var section = findSection(target);
396
- if (!section) return;
397
-
398
- var sections = getAllSections();
399
- var sectionIndex = sections.indexOf(section);
400
- var manifestKey = section.getAttribute("data-manifest-key") || "";
401
-
402
- var c = COLORS[lastKind] || COLORS.normal;
403
- highlight.style.outline = "2px solid " + c.solid;
404
- highlight.style.background = c.active;
405
- setTimeout(function() {
406
- highlight.style.background = c.bg;
407
- }, 400);
408
-
409
- window.parent.postMessage({
410
- type: "cms-editor::section-clicked",
411
- payload: { sectionIndex: sectionIndex, manifestKey: manifestKey }
412
- }, "*");
413
- };
414
- document.addEventListener("click", clickHandler, true);
415
-
416
- window.addEventListener("message", function(e) {
417
- if (e.data && e.data.type === "cms-editor::set-labels" && Array.isArray(e.data.labels)) {
418
- sectionLabels = e.data.labels;
419
- if (Array.isArray(e.data.kinds)) sectionKinds = e.data.kinds;
420
- if (Array.isArray(e.data.keys)) sectionCandidates = e.data.keys;
421
- if (lastSection) {
422
- lastLabel = labelFor(lastSection);
423
- lastKind = kindFor(lastSection);
424
- applyColor(lastKind);
425
- if (highlight.style.display !== "none") positionHighlight(lastSection);
426
- }
427
- return;
428
- }
429
- if (e.data && e.data.type === "cms-editor::deactivate") {
430
- highlight.remove();
431
- badge.remove();
432
- document.removeEventListener("mousemove", moveHandler, true);
433
- document.removeEventListener("mouseout", outHandler, true);
434
- document.removeEventListener("click", clickHandler, true);
435
- window.removeEventListener("scroll", reposition, { capture: true });
436
- window.removeEventListener("resize", reposition);
437
- window.__cmsEditorActive = false;
438
- }
439
- });
440
- })();`;function o4(t,e){return t.map((s,n)=>{const i=s.__resolveType??"",o=fs(i);if(!o&&i!==""&&_n(i)&&i in e){const d=e[i],h=typeof d?.name=="string"&&d.name||i.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${n+1}`;return{index:n,resolveType:i,label:h,isLazy:!1,isSavedBlock:!0}}const a=o?s.section:void 0,l=o?a?.__resolveType??"":i;if(l===Gi||l===Or){const d=o?a:s,h=Array.isArray(d?.variants)?d.variants:[];if(h.length===1&&(h[0]?.rule?.__resolveType??"")===Mr){const m=h[0]?.value??{};let p=m.__resolveType??"";const g=fs(p);return g&&(p=m.section?.__resolveType??p),{index:n,resolveType:i,label:At(p)||`Section ${n+1}`,isHidden:!0,isLazy:g}}const u=h[0]?.value?.__resolveType,f=u?At(u):"Section";return{index:n,resolveType:i,label:`Variants of ${f}`,isMultivariate:!0,isLazy:o}}const c=o?s.section?.__resolveType??i:i;if(o&&c!==""&&_n(c)&&c in e){const d=e[c],h=typeof d?.name=="string"&&d.name||c.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${n+1}`;return{index:n,resolveType:i,label:h,isLazy:!0,isSavedBlock:!0}}return{index:n,resolveType:i,label:At(c)||`Section ${n+1}`,isLazy:o}})}const SE="website/sections/Rendering/Lazy.tsx";function i0(t,e){let s=t,n=typeof s?.__resolveType=="string"?s.__resolveType:"";for(let i=0;n&&i<5;i++){const o=e[n];if(o&&typeof o=="object"&&"__resolveType"in o){const a=o.__resolveType;if(typeof a=="string"&&a&&a!==n){s=o,n=a;continue}}break}if(!n)return[];if(n.includes("flags/multivariate")){const i=Array.isArray(s.variants)?s.variants:[];if(i.length===0||i.every(l=>l?.rule?.__resolveType===Mr))return null;const a=[];for(const l of i){const c=l?.value;if(c&&typeof c=="object")for(const d of i0(c,e)??[])a.includes(d)||a.push(d)}return a}if(n===SE){const i=s.section&&typeof s.section=="object"?i0(s.section,e):[];return i===null?null:i.length?[n,...i]:[n]}return[n]}function a4(t){const e=t.__resolveType??"";return fs(e)?t.section??t:t}function Ol(t){const i=(fs(t.__resolveType??"")?t.section:t)?.variants?.[0];return i?.rule?.__resolveType!==Mr?null:i?.value??null}function Nq(t){const e=a4(t);return{__resolveType:Or,variants:[{value:e,rule:{__resolveType:Mr}}]}}function Tq(t){const e=t.__resolveType??"";if(!e)return null;if(fs(e))return t.section??null;const s=Ol(t);return s?fs(s.__resolveType??"")?s:{__resolveType:Bh,section:a4(s)}:{__resolveType:Bh,section:t}}function Pa(t){const e=t.__resolveType??"";if(!e)return null;if(fs(e)){const s=t.section,n=s?.__resolveType??"";return!n||!s?null:{resolveType:n,data:s}}return{resolveType:e,data:t}}function Aq(t){const e=Ol(t);if(e)return Pa(e);if(fs(t.__resolveType??"")){const n=t.section;if(!n)return null;const i=Ol(n);return Pa(i||n)}return Pa(t)}function Eq(t){return Ol(t)}const wE=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function _u(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:wE.includes(e)||e.includes("always")}function jE(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(n=>_u(n.rule));return s!==-1?s:e.length-1}function Pq(t,e,s){const n=s.variants??[];if(n.length===0)return null;const i=jE(s),o=n[i]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function l4(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function Rq(t,e){return Array.isArray(t.variants)?t.variants.map((s,n)=>({label:e(s.rule)||`Variant ${n+1}`,value:s.value??{},rule:s.rule})):[]}function Dq(t,e){const s=t.__resolveType??"";if(!s)return null;if(fs(s)){const n=t.section??t,i=n.__resolveType??s;if(!i.includes("/")&&i in e){const o=e[i]??{};return{data:{...o},resolveType:o.__resolveType??i}}return{data:{...n},resolveType:i}}if(!s.includes("/")&&s in e){const n=e[s]??{};return{data:{...n},resolveType:n.__resolveType??s}}return{data:{...t},resolveType:s}}function CE(t,e){const s=t.__resolveType??"";return fs(s)?{...t,section:e}:e}function kE(t,e,s){return e.isLazy?{...t,section:s}:s}function Iq(t,e,s){const n=[...t.variants??[]],i=n[e];if(!i)return t;const o=i.value??{};return n[e]={...i,value:CE(o,s)},{...t,variants:n}}function Mq(t,e,s){const n=[...t.variants??[]];return n[e]?(n[e]={...n[e],rule:s},{...t,variants:n}):t}function Oq(t,e){const s=[...t.variants??[]],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function $q(t,e,s){const n=[...t.variants??[]];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[i]=n.splice(e,1);return i?(n.splice(s,0,i),{...t,variants:n}):t}function Bq(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}function r0(t){return{rule:Lr(),value:structuredClone(t)}}function c4(t,e){return{...e,__resolveType:Or,variants:t}}function Fq(t){return t.isHidden!==!0&&t.isSavedBlock!==!0}function VE(t,e){if(e.isHidden)return null;if(e.isMultivariate){const n=l4(t,e)?.variants??[],i=n[n.length-1]?.value;return i?structuredClone(i):null}if(e.isLazy){const s=t.section;return s?structuredClone(s):null}return structuredClone(t)}function NE(t,e,s){if(e.isMultivariate||e.isHidden)return null;const n=VE(t,e);if(!n)return null;const i=c4([r0(n),r0(n)]);return e.isLazy?{...t,section:i}:i}function zq(t,e,s){if(e.isHidden||e.isSavedBlock)return null;if(e.isMultivariate){const i=l4(t,e);if(!i)return null;const o=i.variants??[],a=o[o.length-1]?.value;if(!a)return null;const l=c4([...o,r0(a)],i);return{section:kE(t,e,l),newVariantIndex:o.length}}const n=NE(t,e);return n?{section:n,newVariantIndex:1}:null}const TE=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function Vc(t){return t.anyOfRefs?.some(e=>e.resolveType!==Gi?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function AE(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return e.__resolveType===Or&&Array.isArray(e.variants)}function $l(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===Gi}function EE(t){if(!$l(t))return null;const e=t.variants;if(!Array.isArray(e))return null;const s=e[0]?.value;return Array.isArray(s)?s:null}function PE(t,e){if(!$l(t))return e;const s=structuredClone(t),n=[...s.variants??[]];return n.length===0?n.push({rule:Lr(),value:e}):n[0]={...n[0],value:e},{...s,variants:n}}function RE(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&TE.has(e.__resolveType)&&typeof e.path=="string"}function d4(t,e){const n=t[e]?.sections;if(!n||Array.isArray(n))return 1;const i=n;return Array.isArray(i.variants)?i.variants.length:1}function u4(t,e,s){const i=t[e]?.sections;if(Array.isArray(i))return s===0?i:[];if(i&&typeof i=="object"){const o=i.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function Kq(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const n=t;if(Array.isArray(n.variants)){const i=n.variants,o=i.map(c=>dE(c.rule,e,s)),a=o.reduce((c,d)=>(c[d]=(c[d]??0)+1,c),{}),l={};return i.map((c,d)=>{const h=o[d]??`Variant ${d+1}`,u=a[h]??1;let f=h;return u>1&&(l[h]=(l[h]??0)+1,f=`${h} ${l[h]}`),{label:f||`Variant ${d+1}`,sections:Array.isArray(c.value)?c.value:[],rule:c.rule}})}}return[]}function Xr(t){return{rule:Lr(),value:t}}function pr(t,e){return{...e,__resolveType:Gi,variants:t}}function DE(t,e){const s=structuredClone(e);if(Array.isArray(t))return pr([Xr(t),Xr(s)]);if(t&&typeof t=="object"){const n=t;return Array.isArray(n.variants)?pr([...n.variants,Xr(s)],n):null}return pr([Xr([]),Xr(s)])}function Uq(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function Hq(t,e){const s=t[e];if(!s)return null;const n=[...t];return n.splice(e+1,0,structuredClone(s)),n}function Wq(t,e){if(e.length===0)return pr([],t);if(e.length===1){const s=e[0],n=s?.rule;if(!_u(n))return pr(e,t);if(Array.isArray(s?.value))return s.value}return pr(e,t)}function IE(t,e){for(const[s,n]of Object.entries(t)){if(!RE(n))continue;const i=n.sections;if(Array.isArray(i)){e(void 0,s,0);continue}if(!i||typeof i!="object")continue;const o=i.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function qq(t,e,s){let n=0;return IE(t,i=>{if(!i)return;(i.__resolveType??"")===e&&Wr(i,t,s)&&n++}),n}function sr(t){return t.replace(/[`*_]/g,"\\$&")}function ME(t,e){const s=[`The user selected an element on the live preview and asked: **"${sr(e.trim())}"**`,"","For text content changes, locate the correct source file and apply the change.","For code and CSS changes, understand which component the user is referring to and apply changes to the correct component.",""];t.manifestKey&&s.push(`**Section resolveType:** \`${sr(t.manifestKey)}\``,"","This is a Deco resolveType, not a literal file path. The leading segment is the app name, not a directory — the actual source file lives under a sections directory whose root varies by site (commonly `sections/`, `src/sections/`, or `site/sections/`). Locate the file by searching for the trailing path (e.g. the component filename), don't assume the resolveType is a valid path on disk.","");const n=`<${t.tag}${t.classes?` class="${sr(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${n}\``),t.parents&&s.push(`**DOM breadcrumb:** ${sr(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${sr(t.text)}"`),t.componentName&&s.push(`**Component name:** ${sr(t.componentName)}`);const i=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",i,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
441
- `)}function OE(t,e,s=320,n=44,i=12){const{x:o,y:a}=t,{width:l,height:c}=e,d=Math.max(i,Math.min(o-s/2,l-s-i)),u=a/c>.68?Math.max(i,a-n-18):Math.min(a+18,c-n-i);return{leftPct:d/l*100,topPct:u/c*100}}function $E(t){const e=F.c(45),{element:s,onDismiss:n}=t,[i,o]=N.useState(""),a=N.useRef(null),{sendMessage:l}=Js(),{openSidePanel:c}=ia(),d=oe();let h;e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==c||e[4]!==l?(h=()=>{if(!i.trim())return;const E=ME(s,i);c("chat"),l({parts:[{type:"text",text:E}]}),n()},e[0]=s,e[1]=i,e[2]=n,e[3]=c,e[4]=l,e[5]=h):h=e[5];const u=h;let f;e[6]!==s.position||e[7]!==s.viewport?(f=OE(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=f):f=e[8];const m=f,p=`${m.leftPct}%`,g=`${m.topPct}%`;let x;e[9]!==p||e[10]!==g?(x={left:p,top:g,width:"320px"},e[9]=p,e[10]=g,e[11]=x):x=e[11];let v;e[12]!==u?(v=E=>{E.preventDefault(),u()},e[12]=u,e[13]=v):v=e[13];let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=E=>o(E.target.value),e[14]=b):b=e[14];let _;e[15]!==n?(_=E=>{E.key==="Escape"&&n()},e[15]=n,e[16]=_):_=e[16];let y;e[17]!==d?(y=d("sandbox.visualEditorPrompt.inputPlaceholder"),e[17]=d,e[18]=y):y=e[18];let L;e[19]!==i||e[20]!==_||e[21]!==y?(L=r.jsx("input",{ref:a,autoFocus:!0,type:"text",value:i,onChange:b,onKeyDown:_,placeholder:y,className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[19]=i,e[20]=_,e[21]=y,e[22]=L):L=e[22];let w;e[23]!==i?(w=i.trim(),e[23]=i,e[24]=w):w=e[24];const j=!w;let S;e[25]!==d?(S=d("sandbox.visualEditorPrompt.sendButton"),e[25]=d,e[26]=S):S=e[26];let k;e[27]!==d?(k=d("sandbox.visualEditorPrompt.sendButton"),e[27]=d,e[28]=k):k=e[28];let C;e[29]!==k?(C=r.jsx("title",{children:k}),e[29]=k,e[30]=C):C=e[30];let A;e[31]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e[31]=A):A=e[31];let P;e[32]!==C?(P=r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[C,A]}),e[32]=C,e[33]=P):P=e[33];let V;e[34]!==j||e[35]!==S||e[36]!==P?(V=r.jsx("button",{type:"submit",disabled:j,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:S,children:P}),e[34]=j,e[35]=S,e[36]=P,e[37]=V):V=e[37];let T;e[38]!==L||e[39]!==V||e[40]!==v?(T=r.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:v,children:[L,V]}),e[38]=L,e[39]=V,e[40]=v,e[41]=T):T=e[41];let R;return e[42]!==T||e[43]!==x?(R=r.jsx("div",{className:"absolute z-30 pointer-events-none",style:x,children:T}),e[42]=T,e[43]=x,e[44]=R):R=e[44],R}const h4={claiming:{long:"Reserving sandbox",short:"Reserving sandbox"},"waiting-for-capacity":{long:"Waiting for cluster capacity",short:"Waiting for capacity"},"pulling-image":{long:"Downloading sandbox image",short:"Downloading image"},"starting-container":{long:"Starting your sandbox",short:"Starting container"},"warming-daemon":{long:"Connecting to your sandbox",short:"Connecting to sandbox"}},BE=["provision","cloning","install","dev"];function f4(t){switch(t.lifecycle.phase){case"cloning":case"checking-out":return{step:"cloning",status:"doing"};case"clone-failed":return{step:"cloning",status:"failed"};case"installing":return{step:"install",status:"doing"};case"install-failed":return{step:"install",status:"failed"};case"starting":return{step:"dev",status:"doing"};case"running":return{step:"dev",status:"done"};case"start-failed":return{step:"dev",status:"failed"};case"crashed":return{step:"dev",status:"failed"};case"idle":return t.claimPhase&&t.claimPhase.kind!=="ready"&&t.claimPhase.kind!=="failed"?{step:"provision",status:"doing"}:{step:"cloning",status:"doing"}}}function Af(t){switch(t){case"starting":return"Starting your sandbox";case"suspended":return"Sandbox is paused";case"errored":return"Couldn't start the sandbox"}}function FE(t){return BE.indexOf(t.step)}const Ef=48,m4=28,p4=3,zE=(()=>{const t=[];let e=0;for(let s=0;s<Ef;s++)s===m4?t.push(null):(t.push(e/(Ef-1)*p4),e++);return t})(),KE={provision:"Reserving sandbox",cloning:"Cloning your repo",install:"Installing packages",dev:"Starting your preview"};function UE(t,e){return t.step==="provision"&&e!=null&&e.kind!=="ready"&&e.kind!=="failed"?h4[e.kind].long:KE[t.step]}const mn="bg-foreground/[0.05]",Ws="bg-foreground/[0.09]",HE=Array.from({length:35},()=>Math.random()*1.8),WE=Array.from({length:35},()=>Math.random()<.4);function qE(t){const e=F.c(30),{progress:s,claimPhase:n}=t;let i;e[0]!==s?(i=FE(s),e[0]=s,e[1]=i):i=e[1];const o=i;let a;e[2]!==n||e[3]!==s?(a=UE(s,n),e[2]=n,e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(wv,{}),e[5]=c):c=e[5];const d=`${s.step}-${l}`;let h;e[6]!==l||e[7]!==d?(h=r.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-foreground/10 bg-background px-3.5 py-1.5 shadow-[0_4px_20px_-4px_rgb(0_0_0_/_0.12)]",children:[c,r.jsxs("span",{className:"animate-in fade-in text-[13px] font-medium text-foreground/85 duration-500",children:[l,"…"]},d)]}),e[6]=l,e[7]=d,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(GE,{}),e[9]=u):u=e[9];let f;e[10]!==o?(f=r.jsx(Ra,{phase:0,current:o,children:u}),e[10]=o,e[11]=f):f=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(JE,{}),e[12]=m):m=e[12];let p;e[13]!==o?(p=r.jsx(Ra,{phase:1,current:o,children:m}),e[13]=o,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(XE,{}),e[15]=g):g=e[15];let x;e[16]!==o?(x=r.jsx(Ra,{phase:2,current:o,children:g}),e[16]=o,e[17]=x):x=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(ZE,{}),e[18]=v):v=e[18];let b;e[19]!==o?(b=r.jsx(Ra,{phase:3,current:o,children:v}),e[19]=o,e[20]=b):b=e[20];let _;e[21]!==x||e[22]!==b||e[23]!==f||e[24]!==p?(_=r.jsxs("div",{className:"relative aspect-[4/3] w-[min(78%,560px)]",children:[f,p,x,b]}),e[21]=x,e[22]=b,e[23]=f,e[24]=p,e[25]=_):_=e[25];let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("style",{children:`
442
- @keyframes vm-pulse-soft {
443
- 0%, 100% { opacity: 0.25; }
444
- 50% { opacity: 1; }
445
- }
446
- @keyframes vm-breathe {
447
- 0%, 100% { opacity: 0.5; }
448
- 50% { opacity: 1; }
449
- }
450
- @keyframes vm-rack-scan {
451
- 0%, 100% { opacity: 0; }
452
- 8% { opacity: 1; }
453
- 22% { opacity: 0; }
454
- }
455
- `}),e[26]=y):y=e[26];let L;return e[27]!==_||e[28]!==h?(L=r.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,_,y]}),e[27]=_,e[28]=h,e[29]=L):L=e[29],L}function Ra(t){const e=F.c(10),{phase:s,current:n,children:i}=t,o=s-n,a=o<0,l=o===0,c=a?90:o*-22,d=a?.94:1-Math.max(o,0)*.04,h=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=ie("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${c}px) scale(${d})`,g=l?"auto":"none";let x;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(x={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=x):x=e[5];let v;return e[6]!==i||e[7]!==f||e[8]!==x?(v=r.jsx("div",{"aria-hidden":f,className:m,style:x,children:i}),e[6]=i,e[7]=f,e[8]=x,e[9]=v):v=e[9],v}function Nc(t){const e=F.c(7),{showUrl:s}=t,n=s===void 0?!1:s;let i,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:ie("size-2.5 rounded-full",Ws)}),o=r.jsx("div",{className:ie("size-2.5 rounded-full",Ws)}),a=r.jsx("div",{className:ie("size-2.5 rounded-full",Ws)}),e[0]=i,e[1]=o,e[2]=a):(i=e[0],o=e[1],a=e[2]);let l;e[3]!==n?(l=n&&r.jsx("div",{className:ie("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",mn)}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==l?(c=r.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[i,o,a,l]}),e[5]=l,e[6]=c):c=e[6],c}function GE(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Nc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsx("div",{className:"flex flex-1 px-8 py-5",children:r.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:zE.map(YE)})})]}),t[1]=s):s=t[1],s}function YE(t,e){if(e===m4)return r.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return r.jsx("div",{className:ie("relative rounded-md",Ws),children:r.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${p4}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function JE(){const t=F.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Nc,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:ie("w-[18%] rounded-md",mn),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=n):n=t[2];let i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=i):i=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[n,r.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[i,r.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[r.jsx("div",{className:ie("rounded-md",mn),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),r.jsx("div",{className:ie("rounded-md",mn),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function XE(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Nc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:r.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:HE.map(QE)})})]}),t[1]=s):s=t[1],s}function QE(t,e){return r.jsx("div",{className:ie("aspect-square rounded-md",WE[e]?"bg-chart-2/70":Ws),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function ZE(){const t=F.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Nc,{showUrl:!0}),t[0]=e):e=t[0];let s,n,i,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),n=r.jsx("div",{className:ie("h-1.5 w-[70%] rounded-sm",Ws)}),i=r.jsx("div",{className:ie("h-1.5 w-[55%] rounded-sm",Ws)}),o=r.jsx("div",{className:ie("h-1.5 w-[80%] rounded-sm",Ws)}),a=r.jsx("div",{className:ie("h-1.5 w-[50%] rounded-sm",Ws)}),t[1]=s,t[2]=n,t[3]=i,t[4]=o,t[5]=a):(s=t[1],n=t[2],i=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,n,i,o,a,r.jsx("div",{className:"mt-auto",children:r.jsx("div",{className:ie("h-4 rounded-md",Ws)})})]}),t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:r.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[r.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),r.jsx("div",{className:ie("h-1.5 w-[55%] rounded-sm",mn)})]})}),t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[r.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),r.jsx("div",{className:ie("h-4 w-10 rounded-full",mn)}),r.jsx("div",{className:ie("h-4 w-14 rounded-full",mn)})]}),t[8]=d):d=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsxs("div",{className:ie("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",mn),children:[r.jsx("div",{className:ie("h-1.5 w-[50%] rounded-sm",Ws)}),r.jsx("div",{className:ie("h-1 w-[75%] rounded-sm",Ws)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c,r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[d,r.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,r.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[r.jsx("div",{className:ie("rounded-md",mn)}),r.jsx("div",{className:ie("rounded-md",mn)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function _i(t){const e=F.c(71),s=oe();if(t.kind==="othersThread"){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ac,{className:"size-12 text-muted-foreground"}),e[0]=f):f=e[0];let m;e[1]!==s?(m=s("sandbox.stateCard.othersThreadTitle"),e[1]=s,e[2]=m):m=e[2];let p;e[3]!==m?(p=r.jsx("h3",{className:"text-lg font-medium",children:m}),e[3]=m,e[4]=p):p=e[4];let g;e[5]!==t.label||e[6]!==s?(g=s("sandbox.stateCard.othersThreadMessage",{label:t.label}),e[5]=t.label,e[6]=s,e[7]=g):g=e[7];let x;e[8]!==g?(x=r.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:g}),e[8]=g,e[9]=x):x=e[9];const v=t.onContinue;let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(T9,{className:"size-4"}),e[10]=b):b=e[10];let _;e[11]!==s?(_=s("sandbox.stateCard.othersThreadContinue"),e[11]=s,e[12]=_):_=e[12];let y;e[13]!==t.onContinue||e[14]!==_?(y=r.jsxs(le,{variant:"outline",onClick:v,children:[b," ",_]}),e[13]=t.onContinue,e[14]=_,e[15]=y):y=e[15];const L=t.onStartNewThread;let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(_t,{className:"size-4"}),e[16]=w):w=e[16];let j;e[17]!==s?(j=s("sandbox.stateCard.othersThreadNewChat"),e[17]=s,e[18]=j):j=e[18];let S;e[19]!==t.onStartNewThread||e[20]!==j?(S=r.jsxs(le,{onClick:L,children:[w," ",j]}),e[19]=t.onStartNewThread,e[20]=j,e[21]=S):S=e[21];let k;e[22]!==S||e[23]!==y?(k=r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[y,S]}),e[22]=S,e[23]=y,e[24]=k):k=e[24];let C;return e[25]!==k||e[26]!==p||e[27]!==x?(C=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[f,p,x,k]})}),e[25]=k,e[26]=p,e[27]=x,e[28]=C):C=e[28],C}if(t.kind==="starting"){let f;return e[29]!==t.claimPhase||e[30]!==t.progress?(f=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsx(qE,{progress:t.progress,claimPhase:t.claimPhase})}),e[29]=t.claimPhase,e[30]=t.progress,e[31]=f):f=e[31],f}if(t.kind==="errored"){const f=t.error.code===p3.githubNotAuthenticated;let m;e[32]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(kr,{className:"size-12 text-destructive"}),e[32]=m):m=e[32];let p;e[33]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("h3",{className:"text-lg font-medium",children:Af("errored")}),e[33]=p):p=e[33];let g;e[34]!==f||e[35]!==t.error.message||e[36]!==s?(g=f?s("sandbox.stateCard.githubNotAuthenticatedMessage"):t.error.message,e[34]=f,e[35]=t.error.message,e[36]=s,e[37]=g):g=e[37];let x;e[38]!==g?(x=r.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:g}),e[38]=g,e[39]=x):x=e[39];let v;e[40]!==f||e[41]!==t.connectionsHref||e[42]!==s?(v=f&&t.connectionsHref&&r.jsx(le,{asChild:!0,children:r.jsx("a",{href:t.connectionsHref,children:s("sandbox.stateCard.reconnectGithub")})}),e[40]=f,e[41]=t.connectionsHref,e[42]=s,e[43]=v):v=e[43];const b=t.onRetry;let _;e[44]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(gr,{className:"size-4"}),e[44]=_):_=e[44];let y;e[45]!==s?(y=s("sandbox.stateCard.retry"),e[45]=s,e[46]=y):y=e[46];let L;e[47]!==t.onRetry||e[48]!==y?(L=r.jsxs(le,{variant:"outline",onClick:b,children:[_," ",y]}),e[47]=t.onRetry,e[48]=y,e[49]=L):L=e[49];let w;e[50]!==v||e[51]!==L?(w=r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[v,L]}),e[50]=v,e[51]=L,e[52]=w):w=e[52];let j;return e[53]!==x||e[54]!==w?(j=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[m,p,x,w]})}),e[53]=x,e[54]=w,e[55]=j):j=e[55],j}let n;e[56]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(R6,{className:"size-12 text-blue-500"}),e[56]=n):n=e[56];let i;e[57]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("h3",{className:"text-lg font-medium",children:Af("suspended")}),e[57]=i):i=e[57];let o;e[58]!==s?(o=s("sandbox.stateCard.resumeToContinue"),e[58]=s,e[59]=o):o=e[59];let a;e[60]!==o?(a=r.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:o}),e[60]=o,e[61]=a):a=e[61];const l=t.onResume;let c;e[62]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Di,{className:"size-4"}),e[62]=c):c=e[62];let d;e[63]!==s?(d=s("sandbox.stateCard.resume"),e[63]=s,e[64]=d):d=e[64];let h;e[65]!==t.onResume||e[66]!==d?(h=r.jsxs(le,{onClick:l,className:"mt-2",children:[c," ",d]}),e[65]=t.onResume,e[66]=d,e[67]=h):h=e[67];let u;return e[68]!==a||e[69]!==h?(u=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[n,i,a,h]})}),e[68]=a,e[69]=h,e[70]=u):u=e[70],u}function g4(t,e,s){return`deco:preview:last-page:${t}:${e}:${s}`}function eP(t){if(!t)return null;try{const e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e)||typeof e.path!="string"||!e.path.startsWith("/"))return null;const s=typeof e.pageKey=="string"?e.pageKey:null,n={};if(e.params&&typeof e.params=="object")for(const[i,o]of Object.entries(e.params))typeof o=="string"&&(n[i]=o);return{path:e.path,pageKey:s,params:n}}catch{return null}}function x4(t){try{return eP(localStorage.getItem(t))}catch{return null}}function tP(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function Bl(t,e){const n=e.replace(/\\/g,"/").replace(/^(?!\/)/,"/").split("/").map(i=>encodeURIComponent(i).replace(/%3A/gi,":")).join("/");return`${t}://file${n}?windowId=_blank`}const Pf="site-links",sP=/details?page|\bpdp\b/i,nP=/listingpage|\bplp\b/i;function iP(t,e,s){const n=new Set;for(const l of s)sP.test(l)&&n.add("product"),nP.test(l)&&n.add("category");const i=Vl(ti(t)),o=i[i.length-1],a=i[i.length-2];return o?.type==="text"&&o.text==="/p"&&a?.type==="param"&&a.name===e&&n.add("product"),e==="*"&&i.some(l=>l.type==="param"&&l.name==="*")&&n.add("category"),n}const rP=["rosa","preto","pink","black"];function Da(t,e){const s=e.trim();return s?t(s):rP.flatMap(n=>t(n))}function oP(t,e){const s=e.trim(),n=[];/^\d+$/.test(s)&&n.push({resolveType:t,props:{ids:[s]}});const o=s.includes("-")&&!/\s/.test(s)?s.replace(/-+/g," "):s;return n.push({resolveType:t,props:{query:o,count:10}}),n}const v4=new Set(["vtex","shopify","shopify-mcp","magento","wake","linx","linx-impulse","nuvemshop","vnda","wap","salesforce"]);function Lu(t){return t.split("/")[0]??""}function aP(t){const e=new Set;for(const s of t){const n=Lu(s);v4.has(n)&&e.add(n)}return e}function lP(t,e){const s=Lu(t);return!v4.has(s)||e.size===0?!0:e.has(s)}const cP=[{kind:"product",test:t=>t==="vtex/loaders/intelligentSearch/productList.ts",clientFilter:!1,buildRequests:(t,e)=>Da(s=>oP(t,s),e),optionsFromPayload:Ia},{kind:"product",test:t=>/magento\/.*products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>Da(s=>[{resolveType:t,props:{props:{search:s,pageSize:10,currentPage:1}}}],e),optionsFromPayload:Ia},{kind:"product",test:t=>/algolia\/.*products?\/(list|suggestions)(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>Da(s=>[{resolveType:t,props:{term:s,hitsPerPage:10}}],e),optionsFromPayload:Ia},{kind:"product",test:t=>/products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>Da(s=>[{resolveType:t,props:{query:s,term:s,count:10,hitsPerPage:10}}],e),optionsFromPayload:Ia},{kind:"category",test:t=>t==="vtex/loaders/categories/tree.ts"||/categor(y|ies).*tree/i.test(t),clientFilter:!0,buildRequests:t=>[{resolveType:t,props:{}}],optionsFromPayload:gP}];function dP(t,e,s=new Set){const n=[...e],i=l=>{const c=[];for(const d of cP){if(d.kind!==l)continue;const h=n.find(u=>d.test(u)&&lP(u,s));h&&c.push({cand:d,resolveType:h})}return c.find(d=>s.has(Lu(d.resolveType)))??c[0]},o=(l,c,d)=>({kind:l.kind,id:`${l.kind}:${c}`,resolveType:c,clientFilter:l.clientFilter,isFallback:d,buildRequests:h=>l.buildRequests(c,h),optionsFromPayload:l.optionsFromPayload}),a=[];for(const l of["product","category"]){if(!t.has(l))continue;const c=i(l);c&&a.push(o(c.cand,c.resolveType,!1))}return t.size>0&&a.push(uP(t.has("category")?"category":"product")),a}function uP(t){return{kind:t,id:Pf,resolveType:Pf,clientFilter:!0,isFallback:!0,homepageLinks:!0,optionsFromPayload:(e,s)=>_P(e,s)}}function Li(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function hP(t,e,s){const n=new Set,i=new Set,o=a=>{if(Array.isArray(a)){for(const d of a)o(d);return}const l=Li(a);if(!l)return;const c=l.__resolveType;if(typeof c=="string"){if(s(c))n.add(c);else if(c in e&&!i.has(c)){i.add(c);const d=Li(e[c])?.__resolveType;typeof d=="string"&&s(d)&&n.add(c),o(e[c])}}for(const d of Object.values(l))o(d)};return o(t),n}function b4(t){const e=new Set,s=[];for(const n of t)for(const i of n)e.has(i.value)||(e.add(i.value),s.push(i));return s}function y4(t){try{return decodeURIComponent(t)}catch{return t}}function fP(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function mP(t){const e=[];let s="^";for(const n of t)n.type==="text"?s+=fP(n.text):(e.push(n.name),s+=n.name==="*"?"(.+)":"([^/]+)");return{pattern:new RegExp(`${s}$`),order:e}}function _4(t,e,s){if(typeof t!="string"||!t)return null;let n;try{n=new URL(t,"https://placeholder.invalid").pathname}catch{return null}n=n.replace(/\/+$/,"");const i=Vl(ti(e)),{pattern:o,order:a}=mP(i),l=a.indexOf(s);if(l===-1)return null;const c=n.match(o);if(!c)return null;const d=c[l+1]?.replace(/^\/+|\/+$/g,"");return d?y4(d):null}function Ia(t,e){const s=Li(t),n=Array.isArray(t)?t:Array.isArray(s?.products)?s.products:Array.isArray(s?.list)?s.list:[],i=[],o=new Set;for(const a of n){const l=Li(a);if(!l)continue;const c=_4(l.url,e.template,e.paramName);if(!c||o.has(c))continue;o.add(c);const d=Li(l.isVariantOf),h=typeof d?.name=="string"&&d.name||typeof l.name=="string"&&l.name||c,u=Array.isArray(l.image)?Li(l.image[0]):null,f=typeof u?.url=="string"?u.url:void 0;i.push({value:c,label:h,image:f})}return i}function pP(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.replace(/^\/+|\/+$/g,"");return s?y4(s):null}function gP(t){const e=[],s=new Set,n=(i,o)=>{const a=Li(i);if(!a)return;const l=typeof a.name=="string"&&a.name?a.name:"",c=l?[...o,l]:o,d=pP(a.url);if(d&&!s.has(d)&&(s.add(d),e.push({value:d,label:c.join(" › ")||d})),Array.isArray(a.children))for(const h of a.children)n(h,c)};if(Array.isArray(t))for(const i of t)n(i,[]);return e}const xP=new Set(["login","logout","signin","sign-in","signup","sign-up","register","account","myaccount","my-account","minha-conta","conta","cart","carrinho","checkout","wishlist","favoritos","favorites","orders","pedidos","help","hc","sac","atendimento","contato","contact","institucional","newsletter","customer","sales","catalogsearch","search","busca","privacy-policy-cookie-restriction-mode"]);function vP(t){return(t.split("/").filter(Boolean).pop()??t).replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,s=>s.toUpperCase())}function bP(t){if(typeof t!="string"||!t)return[];const e=[],s=/<a\b[^>]*?\bhref="([^"]+)"[^>]*>([\s\S]*?)<\/a>/gi;let n,i=0;for(;(n=s.exec(t))!==null&&i++<5e3;){const o=n[1]??"",a=(n[2]??"").replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();e.push({href:o,text:a})}return e}function yP(t){if(typeof t!="string"||!t)return[];const e=[],s=new Set,n=/"@type":"Product"[\s\S]{0,600}?(?:"url"|\burl):"([^"]+)"[\s\S]{0,300}?(?:"name"|\bname):"([^"]+)"/g,i=/(?:"image"|\bimage):\s*\[\s*\{[\s\S]{0,400}?(?:"url"|\burl):"([^"]+)"/;let o,a=0;for(;(o=n.exec(t))!==null&&a++<3e3;){const l=(o[1]??"").replace(/\\\//g,"/");if(!l||s.has(l))continue;s.add(l);const c=t.slice(o.index,o.index+900).match(i)?.[1]?.replace(/\\\//g,"/");e.push({url:l,name:o[2]??"",image:c||void 0})}return e}function _P(t,e){const s=[],n=new Set,i=(o,a,l,c)=>{if(s.length>=200)return;const d=_4(o,e.template,e.paramName);!d||n.has(d)||e.paramName==="*"&&/(^|\/)p$/.test(d)||l==="category"&&xP.has(d.split("/")[0]??"")||(n.add(d),s.push({value:d,label:a&&a.length<=80?a:vP(d),kind:l,image:c}))};for(const{url:o,name:a,image:l}of yP(t))i(o,a,"product",l);for(const{href:o,text:a}of bP(t))o.startsWith("/")&&!o.startsWith("//")&&i(o,a,"category");return s}function Qr(t,e,s=50){const n=e.trim().toLowerCase();return(n?t.filter(o=>o.label.toLowerCase().includes(n)||o.value.toLowerCase().includes(n)):t).slice(0,s)}const Rf=3e4;function L4(t){return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-invoke`}function LP(t,e){return`${`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch`}?path=${encodeURIComponent(e)}`}function SP(t,e,s,n){const i=new URL(`/deco/invoke/${e}`,t);return i.searchParams.set("__cb",n.toString(36)),i.searchParams.set("__decoFBT","0"),i.searchParams.set("__d",`run-${n.toString(36)}`),i.searchParams.set("props",btoa(encodeURIComponent(JSON.stringify(s)))),i.href}async function wP(t,{resolveType:e,props:s}){let n;try{n=await fetch(L4(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(Rf)})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(`Run timed out after ${Rf/1e3}s — the block may be slow or the preview unresponsive.`):l}const i=await n.text();let o=null,a=!1;try{o=i?JSON.parse(i):null,a=!0}catch{}if(!n.ok){const l=a&&o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"?o.error:i||`Run failed (${n.status})`;throw new Error(l)}return a?o:i}function jP(t){const e=F.c(2);let s;return e[0]!==t?(s={mutationFn:n=>wP(t,n)},e[0]=t,e[1]=s):s=e[1],Ys(s)}const S4=1e4;function CP(t){return{product:{noun:t("sandbox.pathParamPickerChip.kindProductNoun"),heading:t("sandbox.pathParamPickerChip.kindProductHeading")},category:{noun:t("sandbox.pathParamPickerChip.kindCategoryNoun"),heading:t("sandbox.pathParamPickerChip.kindCategoryHeading")}}}async function kP(t,{resolveType:e,props:s}){const n=await fetch(L4(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(S4)});if(!n.ok)throw new Error(`Failed to fetch options: ${n.status}`);return n.json()}async function Df(t,e){const s=await fetch(LP(t,e),{signal:AbortSignal.timeout(S4)});if(!s.ok)throw new Error(`Failed to fetch page: ${s.status}`);return s.text()}async function VP(t,e,s){const n=e.optionsFromPayload(await Df(t,"/"),s),i=n.find(a=>a.kind==="category");if(!i)return n;const o=Jn(s.template,{[s.paramName]:i.value});if(o==="/")return n;try{const a=e.optionsFromPayload(await Df(t,o),s).filter(l=>l.kind==="product");return b4([n,a])}catch{return n}}function NP(t,e,s){return Qe.sandboxInvoke(`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`,`path-param-${e.id}:${e.clientFilter?"":s}`)}async function TP(t,e,s,n){if(e.homepageLinks)return VP(t,e,n);const i=e.buildRequests?.(s)??[];if(i.length===0)return[];const o=await Promise.allSettled(i.map(l=>kP(t,l))),a=o.filter(l=>l.status==="fulfilled").map(l=>l.value);if(a.length===0){const l=o.find(c=>c.status==="rejected");throw l?l.reason:new Error("Failed to fetch options")}return b4(a.map(l=>e.optionsFromPayload(l,n)))}function o0(t,e,s,n,i){return{queryKey:NP(t,e,s),queryFn:()=>TP(t,e,s,n),enabled:i,staleTime:6e4,retry:1}}function Zr(t){const e=F.c(16),{heading:s,iconKind:n,options:i,template:o,paramName:a,keyPrefix:l,onSelect:c}=t;if(i.length===0)return null;let d;if(e[0]!==n||e[1]!==l||e[2]!==c||e[3]!==i||e[4]!==a||e[5]!==o){let u;e[7]!==n||e[8]!==l||e[9]!==c||e[10]!==a||e[11]!==o?(u=f=>r.jsxs(ks,{value:`${l}:${f.value}`,className:"gap-3 py-2",onSelect:()=>c(f.value),children:[n==="product"&&r.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:f.image?r.jsx("img",{src:f.image,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):r.jsx(a9,{size:14,className:"text-muted-foreground"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm",children:f.label}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:Jn(o,{[a]:f.value})})]})]},`${l}:${f.value}`),e[7]=n,e[8]=l,e[9]=c,e[10]=a,e[11]=o,e[12]=u):u=e[12],d=i.map(u),e[0]=n,e[1]=l,e[2]=c,e[3]=i,e[4]=a,e[5]=o,e[6]=d}else d=e[6];let h;return e[13]!==s||e[14]!==d?(h=r.jsx(Os,{heading:s,children:d}),e[13]=s,e[14]=d,e[15]=h):h=e[15],h}function If(t){const e=F.c(2),{text:s}=t;let n;return e[0]!==s?(n=r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:s}),e[0]=s,e[1]=n):n=e[1],n}function AP(t){const e=F.c(52),{sources:s,template:n,paramName:i,value:o,sandboxRef:a,onCommit:l}=t,c=oe(),[d,h]=N.useState(!1),[u,f]=N.useState(""),[m,p]=N.useState(""),g=N.useRef(null),x=i==="*"?c("sandbox.preview.catchAllParamLabel"):`:${i}`,v=CP(c),_=[...new Set(s.map(ge=>v[ge.kind].noun))].join(" or ");let y;e[0]!==c||e[1]!==_?(y=c("sandbox.pathParamPickerChip.searchPlaceholder",{options:_}),e[0]=c,e[1]=_,e[2]=y):y=e[2];const L=y,w={template:n,paramName:i};let j;e[3]!==u?(j=(ge,Le)=>({source:ge,query:Le,options:ge.clientFilter?Qr(Le.data??[],u):Le.data??[]}),e[3]=u,e[4]=j):j=e[4];const S=j,k=s.filter($P),C=s.filter(OP),A=Bd({queries:k.map(ge=>o0(a,ge,m,w,d))});let P;e[5]!==A||e[6]!==S?(P=(ge,Le)=>S(ge,A[Le]),e[5]=A,e[6]=S,e[7]=P):P=e[7];const V=k.map(P),T=V.length===0||V.every(MP),R=Bd({queries:C.map(ge=>o0(a,ge,m,w,d&&T))});let E;e[8]!==R||e[9]!==S?(E=(ge,Le)=>S(ge,R[Le]),e[8]=R,e[9]=S,e[10]=E):E=e[10];const I=C.map(E),D=T?I:V,M=D.length===1&&D[0]?.source.homepageLinks?D[0]:null,$=M&&!M.query.isLoading&&!M.query.isError?M?.query.data??[]:[],B=Qr($.filter(IP),u),z=Qr($.filter(DP),u),K=B.length>0&&z.length>0,Y=ge=>{h(ge),g.current&&clearTimeout(g.current),f(ge?o:""),p(ge?o:"")};let Q;e[11]===Symbol.for("react.memo_cache_sentinel")?(Q=ge=>{f(ge),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{p(ge)},300)},e[11]=Q):Q=e[11];const q=Q,H=ge=>{l(ge),Y(!1)},U=s3(u),X=Jn(n,{[i]:U}),J=Jt,ee=Yt,W="flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",Z=RP;let G;e[12]!==x||e[13]!==c?(G=c("sandbox.pathParamPickerChip.pickValueTitle",{paramLabel:x}),e[12]=x,e[13]=c,e[14]=G):G=e[14];let te;e[15]!==G?(te=r.jsx(cs,{className:"sr-only",children:r.jsx(ds,{children:G})}),e[15]=G,e[16]=te):te=e[16];let se;e[17]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(a9,{size:16,className:"shrink-0 text-foreground"}),e[17]=se):se=e[17];let re;e[18]!==c?(re=c("sandbox.pathParamPickerChip.pickValueHeading"),e[18]=c,e[19]=re):re=e[19];let de;e[20]!==x?(de=r.jsx("span",{className:"rounded-sm bg-violet-500/15 px-1 py-0.5 font-mono text-[12px] text-violet-600 dark:text-violet-400",children:x}),e[20]=x,e[21]=de):de=e[21];let ce;e[22]!==re||e[23]!==de?(ce=r.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[se,r.jsxs("span",{className:"text-sm font-medium text-foreground",children:[re," ",de]})]}),e[22]=re,e[23]=de,e[24]=ce):ce=e[24];const fe=Dr,ue=!1,ae="min-h-0 flex-1";let me;e[25]!==L||e[26]!==u?(me=r.jsx(Hi,{autoFocus:!0,placeholder:L,value:u,onValueChange:q}),e[25]=L,e[26]=u,e[27]=me):me=e[27];const xe=Wi,Se="flex max-h-none min-h-0 flex-1 flex-col overflow-hidden";let Ve;e[28]!==c?(Ve=c("sandbox.pathParamPickerChip.noResults"),e[28]=c,e[29]=Ve):Ve=e[29];let Ie;e[30]!==Ve?(Ie=r.jsx(oi,{children:Ve}),e[30]=Ve,e[31]=Ie):Ie=e[31];const Ne=U&&r.jsx(Os,{className:"shrink-0",children:r.jsxs(ks,{value:`__raw__:${U}`,className:"gap-3 py-2",onSelect:()=>H(U),children:[r.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted",children:r.jsx(Ar,{size:14,className:"text-muted-foreground"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm",children:c("sandbox.pathParamPickerChip.useRawValue",{rawTerm:U,paramLabel:x})}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:X})]})]})}),Ee=K?r.jsxs("div",{className:"flex min-h-0 flex-1",children:[r.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto border-r border-border",children:r.jsx(Zr,{heading:v.category.heading,iconKind:"category",options:B,template:n,paramName:i,keyPrefix:`${M?.source.id}:cat`,onSelect:H})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:r.jsx(Zr,{heading:v.product.heading,iconKind:"product",options:z,template:n,paramName:i,keyPrefix:`${M?.source.id}:prod`,onSelect:H})})]}):r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:D.map(ge=>{const{source:Le,query:ye,options:Ce}=ge,{noun:Me}=v[Le.kind];if(ye.isLoading)return r.jsx(If,{text:c("sandbox.pathParamPickerChip.loading",{noun:Me})},Le.id);if(ye.isError)return r.jsx(If,{text:c("sandbox.pathParamPickerChip.couldNotLoad")},Le.id);if(Le.homepageLinks){const Re=ye.data??[];return r.jsxs(N.Fragment,{children:[r.jsx(Zr,{heading:v.category.heading,iconKind:"category",options:Qr(Re.filter(PP),u),template:n,paramName:i,keyPrefix:`${Le.id}:cat`,onSelect:H}),r.jsx(Zr,{heading:v.product.heading,iconKind:"product",options:Qr(Re.filter(EP),u),template:n,paramName:i,keyPrefix:`${Le.id}:prod`,onSelect:H})]},Le.id)}return r.jsx(Zr,{heading:D.length>1?v[Le.kind].heading:void 0,iconKind:Le.kind,options:Ce,template:n,paramName:i,keyPrefix:Le.id,onSelect:H},Le.id)})});let we;e[32]!==xe||e[33]!==Ie||e[34]!==Ne||e[35]!==Ee?(we=r.jsxs(xe,{className:Se,children:[Ie,Ne,Ee]}),e[32]=xe,e[33]=Ie,e[34]=Ne,e[35]=Ee,e[36]=we):we=e[36];let Ae;e[37]!==fe||e[38]!==me||e[39]!==we?(Ae=r.jsxs(fe,{shouldFilter:ue,className:ae,children:[me,we]}),e[37]=fe,e[38]=me,e[39]=we,e[40]=Ae):Ae=e[40];let be;e[41]!==ee||e[42]!==te||e[43]!==ce||e[44]!==Ae||e[45]!==Z?(be=r.jsxs(ee,{className:W,onClick:Z,children:[te,ce,Ae]}),e[41]=ee,e[42]=te,e[43]=ce,e[44]=Ae,e[45]=Z,e[46]=be):be=e[46];let je;return e[47]!==J||e[48]!==Y||e[49]!==d||e[50]!==be?(je=r.jsx(J,{open:d,onOpenChange:Y,children:be}),e[47]=J,e[48]=Y,e[49]=d,e[50]=be,e[51]=je):je=e[51],r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",title:c("sandbox.pathParamPickerChip.buttonTitle",{paramLabel:x}),className:"max-w-64 shrink-0 cursor-pointer truncate rounded-sm bg-violet-500/15 px-1 py-0.5 text-[12px] text-violet-600 hover:bg-violet-500/25 dark:text-violet-400",onClick:ge=>{ge.stopPropagation(),Y(!0)},children:o||x}),je]})}function EP(t){return t.kind==="product"}function PP(t){return t.kind!=="product"}function RP(t){return t.stopPropagation()}function DP(t){return t.kind==="product"}function IP(t){return t.kind!=="product"}function MP(t){return!t.query.isLoading&&(t.query.isError||t.options.length===0)}function OP(t){return t.isFallback}function $P(t){return!t.isFallback}function BP(t){const e=F.c(8),{sources:s,template:n,paramName:i,sandboxRef:o,onFill:a}=t;let l,c;if(e[0]!==i||e[1]!==o||e[2]!==s||e[3]!==n){const m={template:n,paramName:i},p=s.filter(FP);c=Bd,l=p.map(g=>o0(o,g,"",m,!0)),e[0]=i,e[1]=o,e[2]=s,e[3]=n,e[4]=l,e[5]=c}else l=e[4],c=e[5];let d;e[6]!==l?(d={queries:l},e[6]=l,e[7]=d):d=e[7];const h=c(d),[u,f]=N.useState(!1);if(!u)for(const m of h){if(m.isLoading)break;const p=m.data?.[0];if(p){f(!0),queueMicrotask(()=>a(p.value));break}}return null}function FP(t){return!t.isFallback}function zP(t){const e=F.c(31),{name:s,value:n,onCommit:i}=t,o=oe(),[a,l]=N.useState(n),[c,d]=N.useState(!1),h=N.useRef(!1);let u;e[0]!==s||e[1]!==o?(u=s==="*"?o("sandbox.preview.catchAllParamLabel"):`:${s}`,e[0]=s,e[1]=o,e[2]=u):u=e[2];const f=u,m=a||f;let p;e[3]!==m?(p=r.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-[12px]",children:m}),e[3]=m,e[4]=p):p=e[4];let g;e[5]!==f||e[6]!==o?(g=o("sandbox.preview.valueForParam",{label:f}),e[5]=f,e[6]=o,e[7]=g):g=e[7];let x,v;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=S=>l(S.target.value),v=()=>d(!0),e[8]=x,e[9]=v):(x=e[8],v=e[9]);let b;e[10]!==n?(b=S=>{S.key==="Enter"&&S.currentTarget.blur(),S.key==="Escape"&&(h.current=!0,l(n),S.currentTarget.blur())},e[10]=n,e[11]=b):b=e[11];let _;e[12]!==a||e[13]!==i||e[14]!==n?(_=()=>{if(d(!1),h.current){h.current=!1;return}const S=s3(a);l(S),S!==n&&i(S)},e[12]=a,e[13]=i,e[14]=n,e[15]=_):_=e[15];let y;e[16]!==a||e[17]!==f||e[18]!==g||e[19]!==b||e[20]!==_?(y=r.jsx("input",{type:"text",value:a,placeholder:f,title:g,spellCheck:!1,className:"absolute inset-0 rounded-sm bg-violet-500/15 px-1 text-[12px] text-violet-600 outline-none placeholder:text-violet-500/60 focus:bg-violet-500/25 dark:text-violet-400",onClick:KP,onChange:x,onFocus:v,onKeyDown:b,onBlur:_}),e[16]=a,e[17]=f,e[18]=g,e[19]=b,e[20]=_,e[21]=y):y=e[21];let L;e[22]!==p||e[23]!==y?(L=r.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[p,y]}),e[22]=p,e[23]=y,e[24]=L):L=e[24];let w;e[25]!==c||e[26]!==o?(w=c&&r.jsxs("span",{className:"pointer-events-none ml-1.5 flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[r.jsx(D6,{size:10}),o("sandbox.preview.enterToGo")]}),e[25]=c,e[26]=o,e[27]=w):w=e[27];let j;return e[28]!==w||e[29]!==L?(j=r.jsxs(r.Fragment,{children:[L,w]}),e[28]=w,e[29]=L,e[30]=j):j=e[30],j}function KP(t){return t.stopPropagation()}const UP={loaders:"loader",actions:"action"},w4=new Set(["workflows"]);function j4(t){return UP[t]}function HP(t,e,s){const n=t.manifest?.blocks??{};for(const[i,o]of Object.entries(n))if(i.includes(s)&&e in o)return!0;return!1}function WP(t,e){const s=new Set,n=t.manifest?.blocks??{};for(const[i,o]of Object.entries(n))if(i.includes(e))for(const a of Object.keys(o))s.add(a);return s}function qP(t,e){return/\.tsx?$/.test(t)?!1:e.has(`${t}.ts`)||e.has(`${t}.tsx`)}function C4(t,e){const s=t.manifest?.blocks??{},n=[],i=new Set;for(const[o,a]of Object.entries(s))if(o.includes(e))for(const l of Object.keys(a))i.add(l);for(const o of i){if(o.toLowerCase().includes("preview")||l3.has(o)||w4.has(Su(o))||qP(o,i))continue;const a=gi(o,t);if(a.hidden)continue;const l=a.title&&a.title!==o?a.title:At(o);n.push({resolveType:o,title:l})}return n.sort((o,a)=>o.title.localeCompare(a.title))}function Mf(t,e){return C4(t,e).length}function Su(t){return t.startsWith("deco-sites/")?t.split("/")[1]||"site":t.startsWith("$live")||t.startsWith("deco/")?"deco":t.split("/")[0]||"other"}const GP={deco:"Deco",std:"Deco Standard",website:"Website"};function YP(t){return GP[t]??t}function k4(t){const e=Su(t);let n=t.split("/").filter(Boolean).slice(t.startsWith("deco-sites/")?2:1);return(n[0]==="loaders"||n[0]==="actions")&&(n=n.slice(1)),[e,...n.slice(0,-1)]}function JP(t,e,s){const n=[];for(const[i,o]of Object.entries(e)){if(i.includes("/")||fc(i)||!o||typeof o!="object"||Array.isArray(o))continue;const a=o,l=a.__resolveType;typeof l=="string"&&(l3.has(l)||w4.has(Su(l))||HP(t,l,s)&&n.push({key:i,resolveType:l,title:typeof a.name=="string"&&a.name?a.name:i}))}return n.sort((i,o)=>i.title.localeCompare(o.title))}function V4(t){const e=F.c(12),{orgSlug:s,virtualMcpId:n,branch:i,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==i||e[1]!==s||e[2]!==n?(l=Qe.sandboxRepoDir(s,n,i),e[0]=i,e[1]=s,e[2]=n,e[3]=l):l=e[3];let c;e[4]!==i||e[5]!==s||e[6]!==n?(c=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(i)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=i,e[5]=s,e[6]=n,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d={queryKey:l,queryFn:c,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],Pt(d).data??null}const XP={target:null,editSeoPageKey:null,variantOverride:null};function QP(t,e){switch(e.type){case"select":return{...t,target:e.target,variantOverride:null};case"edit-seo":return{...t,target:e.target,editSeoPageKey:e.target.key};case"consume-edit-seo":return{...t,editSeoPageKey:null};case"variant-override":return{...t,variantOverride:e.params}}}const N4=N.createContext(null);function ZP(t){const e=F.c(9),{children:s}=t,[n,i]=N.useReducer(QP,XP);let o,a,l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u=>i({type:"select",target:u}),a=u=>i({type:"edit-seo",target:u}),l=()=>i({type:"consume-edit-seo"}),c=u=>i({type:"variant-override",params:u}),e[0]=o,e[1]=a,e[2]=l,e[3]=c):(o=e[0],a=e[1],l=e[2],c=e[3]);let d;e[4]!==n?(d={state:n,selectTarget:o,editSeo:a,consumeEditSeo:l,setVariantOverride:c},e[4]=n,e[5]=d):d=e[5];let h;return e[6]!==s||e[7]!==d?(h=r.jsx(N4,{value:d,children:s}),e[6]=s,e[7]=d,e[8]=h):h=e[8],h}function wu(){const t=N.use(N4);if(!t)throw new Error("useBlocksPreviewWorkspace must be used inside BlocksPreviewWorkspaceProvider");return t}function eR(t){switch(t){case"clone-failed":case"install-failed":case"start-failed":return"terminal-error";case"idle":case"cloning":return"booting";case"checking-out":case"installing":case"starting":case"running":case"crashed":return"snapshot-readable"}}function tR(t){const e=eR(t.lifecyclePhase);return e==="terminal-error"?{kind:"error",source:"sandbox"}:e==="booting"?{kind:"loading"}:[t.decofile,t.meta].some(i=>i.status==="error"&&!i.hasData&&i.errorStatus===404)?{kind:"empty"}:t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData?t.lifecyclePhase==="running"||t.lifecyclePhase==="crashed"?{kind:"error",source:"data"}:{kind:"loading"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty"}}const sR="https://github.com/decocms/blocks";function nR(){const t=F.c(14),e=oe();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(I6,{size:48,className:"text-muted-foreground"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("mainPanelTabs.blocksTabStates.emptyStateTitle"),t[1]=e,t[2]=n):n=t[2];let i;t[3]!==e?(i=e("mainPanelTabs.blocksTabStates.emptyStateDescription"),t[3]=e,t[4]=i):i=t[4];let o;t[5]!==e?(o=e("mainPanelTabs.blocksTabStates.setupContentEditing"),t[5]=e,t[6]=o):o=t[6];let a;t[7]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx($n,{size:14}),t[7]=a):a=t[7];let l;t[8]!==o?(l=r.jsx(le,{size:"sm",asChild:!0,children:r.jsxs("a",{href:sR,target:"_blank",rel:"noreferrer",children:[o,a]})}),t[8]=o,t[9]=l):l=t[9];let c;return t[10]!==n||t[11]!==i||t[12]!==l?(c=r.jsx(Ei,{className:"h-full w-full",image:s,title:n,description:i,actions:l}),t[10]=n,t[11]=i,t[12]=l,t[13]=c):c=t[13],c}function iR(t){const e=F.c(15),{source:s,onRetry:n}=t,i=oe();let o;e[0]!==s||e[1]!==i?(o=i(s==="sandbox"?"mainPanelTabs.blocksTabStates.errorStateSandbox":"mainPanelTabs.blocksTabStates.errorStateData"),e[0]=s,e[1]=i,e[2]=o):o=e[2];const a=o;let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(jn,{size:48,className:"text-muted-foreground"}),e[3]=l):l=e[3];let c;e[4]!==i?(c=i("mainPanelTabs.blocksTabStates.errorStateTitle"),e[4]=i,e[5]=c):c=e[5];let d;e[6]!==i?(d=i("mainPanelTabs.blocksTabStates.retry"),e[6]=i,e[7]=d):d=e[7];let h;e[8]!==n||e[9]!==d?(h=r.jsx(le,{variant:"outline",size:"sm",onClick:n,children:d}),e[8]=n,e[9]=d,e[10]=h):h=e[10];let u;return e[11]!==a||e[12]!==c||e[13]!==h?(u=r.jsx(Ei,{image:l,title:c,description:a,actions:h}),e[11]=a,e[12]=c,e[13]=h,e[14]=u):u=e[14],u}function Mi(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:r.jsx(Ze,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const rR=N.lazy(()=>Ns(()=>import("./sections-editor-CK1krdST.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159])).then(t=>({default:t.SectionsEditor})));function Of(t){if(t instanceof Error&&"status"in t&&typeof t.status=="number")return t.status}function $f(t){const e=F.c(47),{virtualMcpId:s,externalSelectedIndex:n}=t,i=n===void 0?null:n,{org:o}=ze(),{currentBranch:a}=ls(),l=Ps(),c=Yi(),d=wu(),h=l.lifecycle.phase==="running",u=c.previewUrl;let f;e[0]!==a||e[1]!==o||e[2]!==u||e[3]!==s?(f=a?{orgSlug:o.slug,virtualMcpId:s,branch:a,previewUrl:u}:null,e[0]=a,e[1]=o,e[2]=u,e[3]=s,e[4]=f):f=e[4];const m=f;let p;e[5]!==h?(p={fetchEnabled:h},e[5]=h,e[6]=p):p=e[6];const g=uc(m,p);let x;e[7]!==h?(x={fetchEnabled:h},e[7]=h,e[8]=x):x=e[8];const v=hc(m,x),b=g.data!==void 0;let _;e[9]!==g.data||e[10]!==g.error||e[11]!==g.status||e[12]!==v.data||e[13]!==v.error||e[14]!==v.status||e[15]!==l.lifecycle.phase||e[16]!==b?(_=tR({lifecyclePhase:l.lifecycle.phase,decofile:{status:g.status,hasData:b,errorStatus:Of(g.error)},meta:{status:v.status,hasData:v.data!==void 0,errorStatus:Of(v.error)},hasEditableContent:q9(g.data,v.data)}),e[9]=g.data,e[10]=g.error,e[11]=g.status,e[12]=v.data,e[13]=v.error,e[14]=v.status,e[15]=l.lifecycle.phase,e[16]=b,e[17]=_):_=e[17];const y=_;if(y.kind==="loading"){let D;return e[18]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Mi,{}),e[18]=D):D=e[18],D}if(y.kind==="empty"){let D;return e[19]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(nR,{}),e[19]=D):D=e[19],D}if(y.kind==="error"){let D;e[20]!==g||e[21]!==c||e[22]!==v||e[23]!==y.source?(D=()=>{if(y.source==="sandbox"){c.retry();return}Promise.all([g.refetch(),v.refetch()])},e[20]=g,e[21]=c,e[22]=v,e[23]=y.source,e[24]=D):D=e[24];const M=D;let O;return e[25]!==M||e[26]!==y.source?(O=r.jsx(iR,{source:y.source,onRetry:M}),e[25]=M,e[26]=y.source,e[27]=O):O=e[27],O}const L=d.state.target;let w;e[28]!==a||e[29]!==o.slug||e[30]!==L||e[31]!==s?(w=L||!a?null:x4(g4(o.slug,s,a)),e[28]=a,e[29]=o.slug,e[30]=L,e[31]=s,e[32]=w):w=e[32];const j=w;let S="/",k=null,C=null;L?.kind==="page"?(S=L.path,k=L.key):L?.kind==="section"?C=L.key:j&&(S=j.path,k=j.pageKey);const A=k?`page:${k}`:C?`section:${C}`:`path:${S}`;let P;e[33]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(Ze,{size:20,className:"animate-spin text-muted-foreground"})}),e[33]=P):P=e[33];const V=a??"",T=u??void 0,R=C?null:i,E=!!k&&d.state.editSeoPageKey===k;let I;return e[34]!==C||e[35]!==k||e[36]!==S||e[37]!==A||e[38]!==o.slug||e[39]!==T||e[40]!==R||e[41]!==E||e[42]!==V||e[43]!==s||e[44]!==d.consumeEditSeo||e[45]!==d.setVariantOverride?(I=r.jsx("div",{"data-testid":"blocks-panel",className:"h-full min-h-0 overflow-hidden",children:r.jsx(N.Suspense,{fallback:P,children:r.jsx(rR,{orgSlug:o.slug,virtualMcpId:s,branch:V,previewReady:!0,previewUrl:T,currentPath:S,activePageBlockKey:k,activeGlobalBlockKey:C,externalSelectedIndex:R,initialEditSeo:E,onExitSeo:d.consumeEditSeo,onVariantPreviewOverride:d.setVariantOverride},A)})}),e[34]=C,e[35]=k,e[36]=S,e[37]=A,e[38]=o.slug,e[39]=T,e[40]=R,e[41]=E,e[42]=V,e[43]=s,e[44]=d.consumeEditSeo,e[45]=d.setVariantOverride,e[46]=I):I=e[46],I}function oR(t,e){return t===e?"preview":e}const aR="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",lR="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",cR=N.lazy(()=>Ns(()=>import("./page-seo-sheet-Cq6MSxcj.js"),__vite__mapDeps([160,1,2,63,32,64,51,55,53,54,17,3,19,56,57,58,59,60,61,62,65,66,67,68,69,5,16,20,4,6,7,8,9,10,11,12,13,14,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,52,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,105,106,108,109,110,111,112,113,114,115,116,117,118,119,104,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159])).then(t=>({default:t.SeoSheet}))),Bf=500,dR={mobile:375,tablet:768,desktop:null},ld=["desktop","mobile","tablet"],Ff={mobile:"sandbox.preview.deviceMobile",tablet:"sandbox.preview.deviceTablet",desktop:"sandbox.preview.deviceDesktop"};function zf(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function eo(t){if(!t)return null;try{return new URL(t,window.location.href).origin}catch{return null}}function Kf(t,e){try{t.contentWindow?.location.reload()}catch{e&&(t.src=e)}}function uR({virtualMcpId:t}){const e=oe(),s=Tr(),n=sE(),i=jt(),{currentBranch:o}=ls(),a=wu(),l=Xg(),c=he=>{i({to:".",search:Pe=>({...Pe,main:he}),replace:!0})},[d,h]=N.useState("preview"),[u,f]=N.useState("desktop"),[m,p]=N.useState(null),[g,x]=N.useState(null),v=N.useRef(null),b=N.useRef(null),[_,y]=N.useState(!1),[L,w]=N.useState(""),j=N.useRef(null),[S,k]=N.useState(!1),[C,A]=N.useState(),[P,V]=N.useState(null),[T,R]=N.useState(null),[E,I]=N.useState("/"),[D,M]=N.useState(null),[O,$]=N.useState({}),[B,z]=N.useState(!1),K=N.useRef(null),Y=()=>{z(!0),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>z(!1),15e3)},Q=()=>{K.current&&(clearTimeout(K.current),K.current=null),z(!1)},[q,H]=N.useState(!1),{org:U}=ze(),X=Ps(),J=Yi(),ee=J.vmEntry,W=J.previewUrl,Z=X.lifecycle.phase,G=Z==="running",te=ee?.sandboxProviderKind==="user-desktop",se=V4({orgSlug:U.slug,virtualMcpId:t??"",branch:o??"",enabled:te&&G&&!!t&&!!o}),re=te?se:null,de=t&&o?{orgSlug:U.slug,virtualMcpId:t,branch:o,previewUrl:W}:null,{data:ce}=uc(de,{fetchEnabled:G}),{data:fe}=hc(de,{fetchEnabled:G}),ue=t&&o?{orgSlug:U.slug,virtualMcpId:t,branch:o}:null,ae=gE(ue),me=ce?G9(ce).sort((he,Pe)=>he.name.localeCompare(Pe.name)):[],xe=ce&&fe?Y9(ce,fe):[],Se=ti,Ve=me.filter(he=>{if(!L)return!0;const Pe=L.toLowerCase();return he.name.toLowerCase().includes(Pe)||he.path.toLowerCase().includes(Pe)}),Ie=xe.filter(he=>{if(!L)return!0;const Pe=L.toLowerCase();return he.name.toLowerCase().includes(Pe)||he.key.toLowerCase().includes(Pe)||he.resolveType.toLowerCase().includes(Pe)}),Ne=P?null:ww(me,E,D),Ee=P?P.name:Ne?.name,we=Ne?.key??null,Ae=Ne?.path??null,be=(we?O[we]:void 0)??{},je=Jn(E,be),ge={};if(G&&W&&fe&&ce){const he=WP(fe,"loaders"),Pe=we?ce[we]:void 0,at=hP(Pe,ce,ps=>he.has(ps)),bt=aP(at);for(const ps of Vl(E)){if(ps.type!=="param")continue;const kn=iP(E,ps.name,at),Xs=dP(kn,he,bt);Xs.length>0&&(ge[ps.name]=Xs)}}const Le=t&&o?{orgSlug:U.slug,virtualMcpId:t,branch:o}:null,ye=ce&&we?u4(ce,we,0):[],Ce=ce?o4(ye,ce):[],Me=Ce.map(he=>he.isSavedBlock?he.label:""),Re=Ce.map(he=>he.isSavedBlock?"global":he.isMultivariate?"variant":"normal"),ke=ye.map(he=>i0(he,ce??{})),$e=N.useRef(null),qe=N.useRef(null),lt=X.status.state==="paused",ft=X.phase,dt=f4({claimPhase:ft,lifecycle:X.lifecycle}),it=J.previewState,xt=J.userStopped,vt=Kn(),pe=vt?.entity?.id===t?B2(vt.entity.metadata?.productionUrl):null,Be=JA({previewState:it,progressStatus:dt.status,productionUrl:pe}),Xe=Be.mode!=="none",gt=Be.showBlockingOverlay,Vt=Be.mode==="sandbox"?hE(zf(T??new URL(je,Be.iframeBase).href,u),a.state.variantOverride??[]):Be.mode==="production"?zf(new URL(je,Be.iframeBase).href,u):null,zt=t&&o?g4(U.slug,t,o):null,Nt=he=>{zt&&tP(zt,he)},ct=a.state.target;N.useEffect(()=>{if(!(!ct||!W||!fe))if(ct.kind==="page"){const he=O[ct.key]??{};qe.current=Jn(ct.path,he),V(null),R(null),M(ct.key),I(ct.path),Nt({path:ct.path,pageKey:ct.key,params:he})}else{const he=xe.find(Pe=>Pe.key===ct.key);if(he){qe.current=null;const Pe=Wd(fe);V(he),R(Nf(W,Pe,he.key))}}},[ct,W,fe,O]),N.useEffect(()=>{!we||Ae===null||ct?.kind==="page"&&ct.key===we&&ct.path===Ae||a.selectTarget({kind:"page",key:we,path:Ae})},[we,Ae,ct]);const[Rs,ne]=N.useState(null);if(it.kind==="iframe"&&Rs!==it.previewUrl){const he=Rs!==null;ne(it.previewUrl);const Pe=zt?x4(zt):null;if(Pe){if(qe.current=Jn(Pe.path,Pe.params),I(Pe.path),M(Pe.pageKey),R(null),V(null),Pe.pageKey&&Object.keys(Pe.params).length>0){const at=Pe.pageKey;$(bt=>({...bt,[at]:Pe.params}))}}else he&&(qe.current=null,I("/"),R(null),M(null),V(null))}$e.current=Vt;const De=!!t&&!!o&&!X.notFound&&!xt&&!lt&&(ft?.kind==="ready"||Z!=="idle"),Ke=Be.mode!=="sandbox"&&d==="visual"?"preview":d;N.useEffect(()=>{const he=eo(W);if(!he)return;const Pe=at=>{if(at.origin===he){if(at.data?.type==="visual-editor::element-clicked"){const bt=bE.safeParse(at.data.payload);bt.success&&p(bt.data)}else if(at.data?.type==="cms-editor::section-clicked"){const bt=_E.safeParse(at.data.payload);bt.success&&x(bt.data.sectionIndex)}}};return window.addEventListener("message",Pe),()=>window.removeEventListener("message",Pe)},[W]),N.useEffect(()=>{if(!_)return;const he=Pe=>{j.current?.contains(Pe.target)||(y(!1),w(""))};return document.addEventListener("pointerdown",he),()=>document.removeEventListener("pointerdown",he)},[_]);const Ge=()=>{const he=v.current?.contentWindow,Pe=eo(W);!he||!Pe||he.postMessage({type:"visual-editor::activate",script:yE},Pe)},mt=()=>{const he=v.current?.contentWindow,Pe=eo(W);!he||!Pe||he.postMessage({type:"visual-editor::deactivate"},Pe)},Lt=()=>{const he=v.current?.contentWindow,Pe=eo(W);!he||!Pe||(he.postMessage({type:"visual-editor::activate",script:LE},Pe),he.postMessage({type:"cms-editor::set-labels",labels:Me,kinds:Re,keys:ke},Pe))},Un=()=>{const he=v.current?.contentWindow,Pe=eo(W);!he||!Pe||he.postMessage({type:"cms-editor::deactivate"},Pe)},Cn=he=>{const Pe=d;!s&&he!==Pe&&(he==="blocks"?b.current?.resize(30):b.current?.collapse()),h(he),p(null),x(null),Pe==="visual"&&mt(),he==="visual"&&Ge(),Pe==="blocks"&&he!=="blocks"&&Un(),he==="blocks"&&Lt()},Gu=he=>{Cn(oR(d,he))},yx=()=>{if(!v.current||!Vt)return;const he=v.current;he.src=Vt},_x=()=>{const he=v.current;if(!he)return;Y();const Pe=document.activeElement,at=he.tabIndex;he.tabIndex=-1,he.style.pointerEvents="none",he.blur(),Kf(he,$e.current);let bt;const ps=()=>{clearTimeout(bt),he.tabIndex=at,he.style.pointerEvents="";const kn=document.activeElement;(!kn||kn===document.body||kn===he)&&Pe?.focus(),he.removeEventListener("load",ps)};he.addEventListener("load",ps),bt=setTimeout(ps,3e3)};Iw(()=>{_x()}),Mw(()=>{Y()});const Lx=()=>{const he=ld.indexOf(u);f(ld[(he+1)%ld.length])},Sx=async()=>{let he=null;try{he=v.current?.contentWindow?.location?.href??null}catch{}const Pe=he??Vt??W;if(Pe)try{await navigator.clipboard.writeText(Pe),ve.success(e("sandbox.preview.urlCopiedToClipboard"))}catch{ve.error(e("sandbox.preview.failedToCopyUrl"))}},wx=(()=>{if(!W)return e("sandbox.preview.noServerRunning");if(P)return P.name;try{const he=new URL(W),Pe=je==="/"?"":je;return`${he.host}${Pe}`}catch{return W}})(),Mc=he=>{const Pe=O[he.key]??{},at=Jn(he.path,Pe);(P||Se(at)!==Se(je))&&Y(),qe.current=at,V(null),R(null),x(null),M(he.key),I(he.path),Nt({path:he.path,pageKey:he.key,params:Pe}),a.selectTarget({kind:"page",key:he.key,path:he.path})},Oc=(he,Pe)=>{if(!we)return;const at=we,bt={...be,[he]:Pe};qe.current=Jn(E,bt),$(ps=>({...ps,[at]:bt})),Nt({path:E,pageKey:at,params:bt})},jx=he=>{if(!W||!fe){ve.error(e("sandbox.preview.previewMetadataNotReady"));return}Y(),qe.current=null;const Pe=Wd(fe),at=Nf(W,Pe,he.key);V(he),R(at),x(null),a.selectTarget({kind:"section",key:he.key})},Cx=async({name:he,path:Pe,templateKey:at})=>{if(!t||!o)return;const bt=U9(Pe);if(bt){A(bt);return}const ps=Pe.trim().startsWith("/")?Pe.trim():`/${Pe.trim()}`;if(me.some(Xs=>Se(Xs.path)===Se(ps))){A(e("sandbox.preview.pageAlreadyExists",{path:ps}));return}let kn;if(at&&(kn=ce?.[at],!kn)){A(e("sandbox.preview.templateNoLongerExists"));return}A(void 0);try{const Xs=await ae.mutateAsync({name:he,path:ps,template:kn});k(!1),ve.success(e("sandbox.preview.pageCreated",{name:he})),await Rr(Bf),Mc({key:Xs.key,name:Xs.name,path:Xs.path}),Cn("blocks")}catch(Xs){A(Xs instanceof Error?Xs.message:e("sandbox.preview.failedToCreatePage"))}},tr=Xe&&(De||Be.mode==="production"),Yu=d==="blocks",Ju=tr?r.jsxs("div",{className:"flex min-w-0 items-center gap-0.5",children:[r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(x9,{title:e("sandbox.preview.cms"),icon:{kind:"component",Component:f2},active:Yu,onClick:()=>Gu("blocks"),testId:"preview-blocks-toggle",dataTour:Pn.edit})}),r.jsx(He,{side:"bottom",children:e(Yu?"sandbox.preview.exitEditor":"sandbox.preview.editContent")})]}),r.jsx("div",{className:"mx-0.5 h-5 w-px shrink-0 bg-border"}),r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(fo,{onClick:yx,"aria-label":e("sandbox.preview.refresh"),children:r.jsx(gr,{size:16})})}),r.jsx(He,{side:"bottom",children:e("sandbox.preview.refresh")})]}),r.jsxs("div",{ref:j,className:"relative min-w-0 w-64 shrink",children:[r.jsxs("div",{className:"flex h-7 w-full min-w-0 items-center rounded-md border border-border bg-background transition-colors duration-200 hover:bg-accent",children:[r.jsxs("div",{className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1 pl-2 pr-1",onClick:()=>y(he=>!he),children:[P&&r.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[r.jsx(xn,{size:11}),"Global"]}),r.jsx("span",{className:ie("text-[13px] font-medium text-foreground",Ee==null?"min-w-0 flex-1 truncate":"min-w-0 shrink truncate"),children:Ee??wx}),!P&&Ee!=null&&E&&r.jsx("span",{className:"flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap text-[12px] text-muted-foreground",children:Vl(E).map((he,Pe)=>{if(he.type==="text")return r.jsx("span",{className:ie(Pe===0?"min-w-0 truncate":"shrink-0"),children:he.text},`text-${Pe}`);const at=ge[he.name];return at&&Le?r.jsx(AP,{sources:at,template:E,paramName:he.name,value:be[he.name]??"",sandboxRef:Le,onCommit:bt=>Oc(he.name,bt)},`${we}:${he.name}`):r.jsx(zP,{name:he.name,value:be[he.name]??"",onCommit:bt=>Oc(he.name,bt)},`${we}:${he.name}`)})})]}),r.jsx("button",{type:"button",className:"flex h-full shrink-0 items-center pl-1 pr-2",onClick:()=>y(he=>!he),"aria-label":e("sandbox.preview.choosePage"),children:r.jsx(is,{size:12,className:ie("shrink-0 text-muted-foreground transition-transform",_&&"rotate-180")})})]}),_&&r.jsxs("div",{className:"absolute left-1/2 top-full z-50 mt-1.5 w-[500px] max-w-[calc(100vw-2rem)] -translate-x-1/2 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[r.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[r.jsx(C9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),r.jsx("input",{type:"text",value:L,onChange:he=>w(he.target.value),onKeyDown:he=>{if(he.key!=="Enter")return;const Pe=L.trim();if(!Pe)return;const at=Ve.find(bt=>Se(bt.path)===Se(Pe));at&&(he.preventDefault(),y(!1),w(""),Mc(at))},placeholder:e("sandbox.preview.searchPagesAndComponents"),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),r.jsx("div",{className:"p-1.5 border-b",children:r.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:he=>{he.preventDefault(),y(!1),w(""),A(void 0),k(!0)},children:[r.jsx(_t,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"flex-1 font-medium",children:e("sandbox.preview.createNewPage")})]})}),Ve.length===0&&Ie.length===0?r.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:me.length===0&&xe.length===0?e("sandbox.preview.noPagesFound"):e("sandbox.preview.noSearchResults")}):r.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[Ve.length>0&&r.jsx("div",{className:"p-1.5",children:Ve.map(he=>r.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:Pe=>{Pe.preventDefault(),y(!1),w(""),Mc(he)},children:[r.jsx(An,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:he.name}),r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:he.path})]},he.key))}),Ie.length>0&&r.jsxs("div",{className:ie("p-1.5",Ve.length>0&&"border-t"),children:[r.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:e("sandbox.preview.globalComponents")}),Ie.map(he=>r.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:Pe=>{Pe.preventDefault(),y(!1),w(""),jx(he)},children:[r.jsx(xn,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:he.name}),r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:he.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},he.key))]})]})]})]}),r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(fo,{"aria-label":e("sandbox.preview.openInNewTab"),onClick:()=>{const he=Vt??Be.iframeBase;he&&window.open(he,"_blank","noopener")},children:r.jsx($n,{size:16})})}),r.jsx(He,{side:"bottom",children:e("sandbox.preview.openInNewTab")})]})]}):null,$c=tr||l?r.jsx("div",{className:"flex shrink-0 items-center",children:r.jsxs(vs,{children:[r.jsx(bs,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon-sm","aria-label":e("sandbox.preview.moreOptions"),children:r.jsx(Ki,{size:14})})}),r.jsxs(ys,{align:"end",className:"w-44",children:[l&&r.jsxs(Je,{onClick:()=>l.setVisible(!l.visible),children:[r.jsx(x2,{size:14}),l.visible?e("sandbox.preview.hideTerminal"):e("sandbox.preview.showTerminal")]}),tr&&r.jsxs(r.Fragment,{children:[l&&r.jsx(Xn,{}),r.jsxs(Je,{onClick:Sx,children:[r.jsx(Vs,{size:14}),e("sandbox.preview.copyCurrentUrl")]})]}),ce&&fe&&r.jsxs(r.Fragment,{children:[r.jsx(Xn,{}),we&&r.jsxs(Je,{onClick:()=>{a.editSeo({kind:"page",key:we,path:E}),Cn("blocks")},children:[r.jsx(ul,{size:14}),e("sandbox.preview.editSeo")]}),we&&r.jsxs(Je,{onClick:()=>{try{c(Jb(Vb(we)))}catch{ve.error(e("sandbox.preview.invalidPageBlockKey"))}},children:[r.jsx(ra,{size:14}),e("sandbox.preview.viewJson")]}),r.jsxs(Je,{onClick:()=>H(!0),children:[r.jsx(ul,{size:14}),e("sandbox.preview.siteSeo")]})]}),re&&r.jsxs(r.Fragment,{children:[r.jsx(Xn,{}),r.jsxs(Je,{onClick:()=>window.open(Bl("vscode",re)),children:[r.jsx("img",{src:aR,alt:"VSCode",width:14,height:14}),e("sandbox.preview.openInVscode")]}),r.jsxs(Je,{onClick:()=>window.open(Bl("cursor",re)),children:[r.jsx("img",{src:lR,alt:"Cursor",width:14,height:14}),e("sandbox.preview.openInCursor")]})]}),r.jsx(Xn,{}),r.jsxs(Je,{onClick:()=>qA(e),children:[r.jsx(M6,{size:14}),e("cmsTour.menuItem")]})]})]})}):null,Bc=Be.mode==="sandbox",Xu=Bc?r.jsx("div",{className:"absolute bottom-4 left-1/2 z-20 -translate-x-1/2 scale-125",children:r.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border bg-background/60 p-1 shadow-lg backdrop-blur-md",children:[r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(fo,{onClick:()=>Gu("visual"),"aria-pressed":d==="visual","aria-label":e("sandbox.preview.visualEditor"),active:d==="visual",disabled:!Bc,className:"rounded-full","data-tour":Pn.visualEditor,children:r.jsx(rh,{size:16})})}),r.jsx(He,{side:"top",children:e("sandbox.preview.visualEditor")})]}),r.jsx("div",{className:"mx-0.5 h-5 w-px bg-border"}),r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(fo,{onClick:Lx,"aria-label":e(Ff[u]),disabled:!Bc,className:"rounded-full","data-tour":Pn.device,children:r.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[u==="mobile"&&r.jsx(O6,{size:16}),u==="tablet"&&r.jsx($6,{size:16}),u==="desktop"&&r.jsx(B6,{size:16})]},u)})}),r.jsx(He,{side:"top",children:e(Ff[u])})]})]})}):null;return r.jsxs("div",{className:"flex flex-col w-full h-full",children:[Le&&Object.entries(ge).map(([he,Pe])=>(be[he]??"")===""?r.jsx(BP,{sources:Pe,template:E,paramName:he,sandboxRef:Le,onFill:at=>Oc(he,at)},`${we}:${he}`):null),n?r.jsxs(r.Fragment,{children:[tr&&r.jsx(eE,{children:Ju}),r.jsx(tE,{children:$c})]}):(tr||$c)&&r.jsxs("div",{className:"relative flex h-12 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 md:px-4",children:[tr?Ju:r.jsx("div",{}),$c]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:s&&Ke==="blocks"?r.jsxs("div",{className:"relative h-full min-h-0 overflow-hidden",children:[r.jsx($f,{virtualMcpId:t,externalSelectedIndex:g}),Xu]}):r.jsxs(C2,{direction:"horizontal",children:[r.jsx(fl,{ref:b,id:"preview-blocks-editor",order:1,defaultSize:Ke==="blocks"?30:0,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden",children:Ke==="blocks"&&r.jsx($f,{virtualMcpId:t,externalSelectedIndex:g})}),r.jsx(k2,{withHandle:!0,className:ie(Ke!=="blocks"&&"hidden")}),r.jsx(fl,{id:"preview-canvas",order:2,defaultSize:Ke==="blocks"?60:100,minSize:35,className:"min-w-0 overflow-hidden",children:r.jsxs("div",{className:ie("h-full relative overflow-hidden",u!=="desktop"&&Xe&&"flex justify-center bg-muted/30"),children:[B&&Xe&&r.jsx("div",{className:"absolute inset-x-0 top-0 z-40 h-0.5 overflow-hidden bg-primary/15",children:r.jsx("div",{className:"absolute inset-y-0 w-2/5 rounded-full bg-primary animate-preview-nav"})}),gt&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(_i,{kind:"starting",progress:dt,claimPhase:ft})}),it.kind==="othersThread"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(_i,{kind:"othersThread",label:it.label,onContinue:J.acknowledgeOthersThread,onStartNewThread:()=>i({to:"/$org/$taskId",params:{org:U.slug,taskId:crypto.randomUUID()},search:he=>({...he,sidepanel:"chat"})})})}),it.kind==="suspended"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(_i,{kind:"suspended",onResume:J.resume})}),it.kind==="errored"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(_i,{kind:"errored",error:it.error,onRetry:J.retry,connectionsHref:`/${U.slug}/settings/connections`})}),Be.showWakingPill&&r.jsxs("div",{className:"absolute top-4 left-1/2 z-20 flex max-w-md -translate-x-1/2 items-start gap-3 rounded-xl border border-border bg-muted px-4 py-3 shadow-lg pointer-events-none select-none",children:[r.jsx(Ze,{size:18,className:"mt-0.5 shrink-0 animate-spin text-muted-foreground"}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-sm font-medium text-foreground",children:e("sandbox.preview.startingPreview")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:e("sandbox.preview.startingPreviewHint")})]})]}),Ke==="visual"&&!m&&r.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[r.jsx(rh,{size:12}),e("sandbox.preview.clickElementToAsk")]}),Ke==="visual"&&m&&r.jsx($E,{element:m,onDismiss:()=>p(null)}),Xu,Xe&&Vt&&r.jsx("div",{className:ie("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",u!=="desktop"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:u==="desktop"?"100%":`${dR[u]}px`},children:r.jsx("iframe",{ref:v,src:Vt,className:"w-full h-full border-0",title:e("sandbox.preview.devServerPreviewTitle"),onLoad:()=>{if(Q(),Be.mode==="sandbox"){if(Fe("vm_preview_loaded",{view_mode:d,vm_id:ee?.sandboxHandle??null}),!P)try{const he=v.current?.contentWindow?.location?.pathname;if(!he)return;const Pe=qe.current;if(Pe!==null&&(qe.current=null,Se(he)!==Se(Pe))||Se(he)===Se(je))return;I(he),Nt({path:he,pageKey:D,params:be})}catch{}d==="visual"&&Ge(),d==="blocks"&&Lt()}}},Be.iframeBase)})]})})]})}),r.jsx(vE,{open:S,onOpenChange:k,isPending:ae.isPending,error:C,templates:me,onSubmit:Cx}),q&&ce&&fe&&r.jsx(N.Suspense,{fallback:null,children:r.jsx(cR,{open:q,onOpenChange:H,orgSlug:U.slug,virtualMcpId:t??"",branch:o??"",decofile:ce,meta:fe,onSaved:()=>{setTimeout(()=>{const he=v.current;he&&Kf(he,$e.current)},Bf)},target:{kind:"site"}})})]})}function hR(t){const e=F.c(22),{virtualMcpId:s}=t,n=oe(),i=ms(s),{activeTask:o}=ls(),[a,l]=N.useState(!1);if(!($s(i?.metadata)||$s(o?.metadata))){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"flex size-14 items-center justify-center rounded-full bg-muted",children:r.jsx(Uo,{className:"size-7 text-foreground"})}),e[0]=h):h=e[0];let u;e[1]!==n?(u=n("mainPanelTabs.previewTab.noSourceToPreview"),e[1]=n,e[2]=u):u=e[2];let f;e[3]!==n?(f=n("mainPanelTabs.previewTab.connectGithubDescription"),e[3]=n,e[4]=f):f=e[4];let m,p;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=()=>l(!0),p=r.jsx(Uo,{className:"size-4"}),e[5]=m,e[6]=p):(m=e[5],p=e[6]);let g;e[7]!==n?(g=n("mainPanelTabs.previewTab.connectGithub"),e[7]=n,e[8]=g):g=e[8];let x;e[9]!==g?(x=r.jsxs(le,{onClick:m,children:[p,g]}),e[9]=g,e[10]=x):x=e[10];let v;e[11]!==u||e[12]!==f||e[13]!==x?(v=r.jsx(Ei,{className:"h-full",image:h,title:u,description:f,actions:x}),e[11]=u,e[12]=f,e[13]=x,e[14]=v):v=e[14];let b;e[15]!==a?(b=r.jsx(W2,{open:a,onOpenChange:l,mode:"agent"}),e[15]=a,e[16]=b):b=e[16];let _;return e[17]!==v||e[18]!==b?(_=r.jsxs(r.Fragment,{children:[v,b]}),e[17]=v,e[18]=b,e[19]=_):_=e[19],_}let d;return e[20]!==s?(d=r.jsx(uR,{virtualMcpId:s}),e[20]=s,e[21]=d):d=e[21],d}const fR="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",mR="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",pR=N.lazy(()=>Ns(()=>import("./file-explorer-B6MpksVl.js"),__vite__mapDeps([161,1,2,91,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,92,93,94,95,96,97,98,99,100,101,102,103,126,145,146,130,128,136,112,104,108,109,110,111,113,114,115,116,117,118,119,120,121,122,123,124,125,127,129,131,132,133,134,135,137,138,139,140,141,142,143,144,147,148,149,150,151,152,153,154,155,106,156,157,158,159])).then(t=>({default:t.FileExplorer})));function gR(t){const e=F.c(21),{openPath:s}=t,n=oe(),i=Kn(),{org:o}=ze(),{currentBranch:a}=ls(),l=i?.entity?.id??null,c=Yi(),d=Ps(),h=c.vmEntry,u=d.lifecycle.phase==="running",f=h?.sandboxProviderKind==="user-desktop",m=l??"",p=a??"",g=f&&u&&!!l&&!!a;let x;e[0]!==o.slug||e[1]!==m||e[2]!==p||e[3]!==g?(x={orgSlug:o.slug,virtualMcpId:m,branch:p,enabled:g},e[0]=o.slug,e[1]=m,e[2]=p,e[3]=g,e[4]=x):x=e[4];const v=V4(x),b=f?v:null;if(!l||!a){let j;e[5]!==n?(j=n("mainPanelTabs.codeTab.noSandboxToBrowse"),e[5]=n,e[6]=j):j=e[6];let S;return e[7]!==j?(S=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:j}),e[7]=j,e[8]=S):S=e[8],S}let _;e[9]!==b||e[10]!==n?(_=b&&r.jsx("div",{className:"relative flex h-12 shrink-0 items-center border-b border-border/60 px-3 md:px-4",children:r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon","aria-label":n("mainPanelTabs.codeTab.openInVscode"),onClick:()=>window.open(Bl("vscode",b)),children:r.jsx("img",{src:fR,alt:"VSCode",width:14,height:14})})}),r.jsx(He,{side:"bottom",children:n("mainPanelTabs.codeTab.openInVscode")})]}),r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon","aria-label":n("mainPanelTabs.codeTab.openInCursor"),onClick:()=>window.open(Bl("cursor",b)),children:r.jsx("img",{src:mR,alt:"Cursor",width:14,height:14})})}),r.jsx(He,{side:"bottom",children:n("mainPanelTabs.codeTab.openInCursor")})]})]})}),e[9]=b,e[10]=n,e[11]=_):_=e[11];let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(Ze,{size:20,className:"animate-spin text-muted-foreground"})}),e[12]=y):y=e[12];let L;e[13]!==a||e[14]!==s||e[15]!==o.slug||e[16]!==l?(L=r.jsx("div",{className:"flex-1 relative overflow-hidden bg-background",children:r.jsx(N.Suspense,{fallback:y,children:r.jsx(pR,{orgSlug:o.slug,virtualMcpId:l,branch:a,openPath:s})})}),e[13]=a,e[14]=s,e[15]=o.slug,e[16]=l,e[17]=L):L=e[17];let w;return e[18]!==_||e[19]!==L?(w=r.jsxs("div",{className:"flex flex-col w-full h-full",children:[_,L]}),e[18]=_,e[19]=L,e[20]=w):w=e[20],w}function xR(t){return ms(t)?.metadata?.runtime?.path??null}function vR(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([n])=>!e.includes(n)));return Object.keys(s).length>0?{...t,properties:s}:t}function bR(t,e,s){return typeof t!="string"?null:vR(Ln(t,e),s)}function T4(t,e,s){if(!e||typeof t!="string")return!1;const n=bR(t,e,s);return!!n&&Object.keys(n.properties??{}).length>0}function yR({orgSlug:t,virtualMcpId:e,branch:s}){const n=Ls(),i=ms(e)?.metadata?.runtime?.path??null;return Ys({mutationFn:async({blockKey:o})=>{const a=Ir(i,j2(o)),l=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:a})});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error??`Delete failed (${l.status})`)}return l.json()},onMutate:async({blockKey:o})=>{const a=`${t}/${e}/${s}`,l=Qe.decofile(a);await n.cancelQueries({queryKey:l});const c=n.getQueryData(l);return n.setQueryData(l,d=>{if(!d)return d;const{[o]:h,...u}=d;return u}),{previous:c,queryKey:l}},onError:(o,a,l)=>{l?.queryKey&&n.setQueryData(l.queryKey,l.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:Qe.liveMeta(t,e,s)})}})}function nr(t){const e=F.c(6),{hasItems:s,emptyLabel:n,emptyHint:i}=t;let o;e[0]!==i||e[1]!==n||e[2]!==s?(o=s?"No results match your search.":r.jsxs(r.Fragment,{children:[r.jsx("div",{children:n}),r.jsx("div",{className:"mt-1 text-muted-foreground/80",children:i})]}),e[0]=i,e[1]=n,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function Tc(t,e){return`${t}-${e}`}function A4(t,e){return`site/apps/${t}/${e}.ts`}function E4(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);if(e)return{vendor:e[1],app:e[2]};const s=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return s?{vendor:s[1],app:s[2]}:null}function _R(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function LR(t){return t==="local"?"Custom":"Installed"}function P4(t,e,s){const n=new Set([Tc(t,e),e].map(o=>o.toLowerCase())),i=A4(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(n.has(o.toLowerCase())||l.__resolveType===i)return o}return null}function SR(t,e){const s=t.vendor.alias,n=t.name,i=P4(s,n,e);return{id:Tc(s,n),app:n,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:A4(s,n),blockKey:i,installed:i!==null}}function wR(t,e,s){if(t===W9)return null;const n=E4(t);if(!n)return null;const{vendor:i,app:o}=n,a=P4(i,o,s),l=gi(t,e);return{id:Tc(i,o),app:o,vendor:i,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function jR(t,e,s){const n=e.__resolveType;if(typeof n!="string"||Nl(t,e)||!t3(n))return null;const i=E4(n)??_R(t);if(!i)return null;const o=gi(n,s),{vendor:a,app:l}=i;return{id:Tc(a,l),app:l,vendor:a,title:o.title??Tl(t,e,s),description:o.description??"",category:LR(a),logo:o.logo??o.icon,resolveType:n,blockKey:t,installed:!0}}function CR(t,e,s){const n=new Map;for(const o of t){const a=SR(o,s);n.set(a.id,a)}const i=e.manifest?.blocks?.apps??{};for(const o of Object.keys(i)){const a=wR(o,e,s);!a||n.has(a.id)||n.set(a.id,a)}for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=jR(o,a,e);!l||n.has(l.id)||n.set(l.id,l)}return[...n.values()].sort(kR)}function kR(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function VR(){const t=await fetch("/api/deco-apps");if(!t.ok)throw new Error(`Failed to fetch deco apps: ${t.status}`);return(await t.json()).apps??[]}function NR(t,e,s){const n=F.c(12),i=s?.enabled??!0;let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=Qe.decoApps(),n[0]=o):o=n[0];let a;n[1]!==i?(a={queryKey:o,queryFn:VR,staleTime:3e5,retry:1,enabled:i},n[1]=i,n[2]=a):a=n[2];const l=Pt(a);let c;n[3]!==e||n[4]!==t||n[5]!==l.data?(c=t&&e?CR(l.data??[],t,e):[],n[3]=e,n[4]=t,n[5]=l.data,n[6]=c):c=n[6];const d=c,h=l.isLoading&&!l.isError;let u;return n[7]!==d||n[8]!==l.isError||n[9]!==l.refetch||n[10]!==h?(u={catalog:d,isLoading:h,isError:l.isError,refetch:l.refetch},n[7]=d,n[8]=l.isError,n[9]=l.refetch,n[10]=h,n[11]=u):u=n[11],u}function R4(t){return(e,s)=>{Nb(e),t(e,s)}}function TR(t){const e=F.c(86),{active:s,counts:n,showBlog:i,onSelect:o}=t,a=oe();let l;e[0]!==a?(l=a("sandbox.collectionsSidebar.content"),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:r.jsx("span",{className:"text-sm font-medium",children:l})}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==a?(d=a("sandbox.collectionsSidebar.pages"),e[4]=a,e[5]=d):d=e[5];const h=s==="pages";let u;e[6]!==n.pages||e[7]!==o||e[8]!==d||e[9]!==h?(u=r.jsx(zs,{id:"pages",icon:An,label:d,count:n.pages,active:h,onSelect:o}),e[6]=n.pages,e[7]=o,e[8]=d,e[9]=h,e[10]=u):u=e[10];let f;e[11]!==a?(f=a("sandbox.collectionsSidebar.sections"),e[11]=a,e[12]=f):f=e[12];const m=s==="sections";let p;e[13]!==n.sections||e[14]!==o||e[15]!==f||e[16]!==m?(p=r.jsx(zs,{id:"sections",icon:xn,label:f,count:n.sections,active:m,onSelect:o}),e[13]=n.sections,e[14]=o,e[15]=f,e[16]=m,e[17]=p):p=e[17];let g;e[18]!==a?(g=a("sandbox.collectionsSidebar.apps"),e[18]=a,e[19]=g):g=e[19];const x=s==="apps";let v;e[20]!==n.apps||e[21]!==o||e[22]!==x||e[23]!==g?(v=r.jsx(zs,{id:"apps",icon:Z2,label:g,count:n.apps,active:x,onSelect:o}),e[20]=n.apps,e[21]=o,e[22]=x,e[23]=g,e[24]=v):v=e[24];let b;e[25]!==a?(b=a("sandbox.collectionsSidebar.redirects"),e[25]=a,e[26]=b):b=e[26];const _=s==="redirects";let y;e[27]!==n.redirects||e[28]!==o||e[29]!==b||e[30]!==_?(y=r.jsx(zs,{id:"redirects",icon:v2,label:b,count:n.redirects,active:_,onSelect:o}),e[27]=n.redirects,e[28]=o,e[29]=b,e[30]=_,e[31]=y):y=e[31];let L;e[32]!==a?(L=a("sandbox.collectionsSidebar.loaders"),e[32]=a,e[33]=L):L=e[33];const w=s==="loaders";let j;e[34]!==n.loaders||e[35]!==o||e[36]!==L||e[37]!==w?(j=r.jsx(zs,{id:"loaders",icon:hl,label:L,count:n.loaders,active:w,onSelect:o}),e[34]=n.loaders,e[35]=o,e[36]=L,e[37]=w,e[38]=j):j=e[38];let S;e[39]!==a?(S=a("sandbox.collectionsSidebar.actions"),e[39]=a,e[40]=S):S=e[40];const k=s==="actions";let C;e[41]!==n.actions||e[42]!==o||e[43]!==S||e[44]!==k?(C=r.jsx(zs,{id:"actions",icon:Ii,label:S,count:n.actions,active:k,onSelect:o}),e[41]=n.actions,e[42]=o,e[43]=S,e[44]=k,e[45]=C):C=e[45];let A;e[46]!==a?(A=a("sandbox.collectionsSidebar.site"),e[46]=a,e[47]=A):A=e[47];const P=s==="site";let V;e[48]!==o||e[49]!==A||e[50]!==P?(V=r.jsx(zs,{id:"site",icon:g2,label:A,active:P,onSelect:o}),e[48]=o,e[49]=A,e[50]=P,e[51]=V):V=e[51];let T;e[52]!==a?(T=a("sandbox.collectionsSidebar.seo"),e[52]=a,e[53]=T):T=e[53];const R=s==="seo";let E;e[54]!==o||e[55]!==T||e[56]!==R?(E=r.jsx(zs,{id:"seo",icon:ul,label:T,active:R,onSelect:o}),e[54]=o,e[55]=T,e[56]=R,e[57]=E):E=e[57];let I;e[58]!==a?(I=a("sandbox.collectionsSidebar.calendar"),e[58]=a,e[59]=I):I=e[59];const D=s==="calendar";let M;e[60]!==o||e[61]!==I||e[62]!==D?(M=r.jsx(zs,{id:"calendar",icon:l9,label:I,active:D,onSelect:o}),e[60]=o,e[61]=I,e[62]=D,e[63]=M):M=e[63];let O;e[64]!==s||e[65]!==n.authors||e[66]!==n.categories||e[67]!==n.posts||e[68]!==o||e[69]!==i||e[70]!==a?(O=i&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[r.jsx(br,{size:13,className:"shrink-0"}),a("sandbox.collectionsSidebar.blog")]}),r.jsx(zs,{id:"posts",icon:Pi,label:a("sandbox.collectionsSidebar.posts"),count:n.posts,active:s==="posts",onSelect:o}),r.jsx(zs,{id:"authors",icon:ac,label:a("sandbox.collectionsSidebar.authors"),count:n.authors,active:s==="authors",onSelect:o}),r.jsx(zs,{id:"categories",icon:b2,label:a("sandbox.collectionsSidebar.categories"),count:n.categories,active:s==="categories",onSelect:o})]}),e[64]=s,e[65]=n.authors,e[66]=n.categories,e[67]=n.posts,e[68]=o,e[69]=i,e[70]=a,e[71]=O):O=e[71];let $;e[72]!==v||e[73]!==y||e[74]!==j||e[75]!==C||e[76]!==V||e[77]!==E||e[78]!==M||e[79]!==O||e[80]!==u||e[81]!==p?($=r.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[u,p,v,y,j,C,V,E,M,O]}),e[72]=v,e[73]=y,e[74]=j,e[75]=C,e[76]=V,e[77]=E,e[78]=M,e[79]=O,e[80]=u,e[81]=p,e[82]=$):$=e[82];let B;return e[83]!==c||e[84]!==$?(B=r.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[c,$]}),e[83]=c,e[84]=$,e[85]=B):B=e[85],B}function zs(t){const e=F.c(18),{id:s,icon:n,label:i,count:o,active:a,onSelect:l}=t;let c;e[0]!==s||e[1]!==l?(c=()=>l(s),e[0]=s,e[1]=l,e[2]=c):c=e[2];const d=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==d?(h=ie("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==n?(u=r.jsx(n,{size:16,className:"shrink-0"}),e[5]=n,e[6]=u):u=e[6];let f;e[7]!==i?(f=r.jsx("span",{className:"flex-1 truncate",children:i}),e[7]=i,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&r.jsx("span",{className:ie("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==c||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=r.jsxs("button",{type:"button",onClick:c,className:h,children:[u,f,m]}),e[12]=c,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function AR(t){const e=F.c(12),{state:s,claimPhase:n,lifecycle:i,onStart:o,connectionsHref:a}=t;switch(s.kind){case"starting":{let l;e[0]!==n||e[1]!==i?(l=f4({claimPhase:n,lifecycle:i}),e[0]=n,e[1]=i,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==l?(c=r.jsx(_i,{kind:"starting",progress:l,claimPhase:n}),e[3]=n,e[4]=l,e[5]=c):c=e[5],c}case"suspended":{let l;return e[6]!==o?(l=r.jsx(_i,{kind:"suspended",onResume:o}),e[6]=o,e[7]=l):l=e[7],l}case"errored":{let l;return e[8]!==a||e[9]!==o||e[10]!==s.error?(l=r.jsx(_i,{kind:"errored",error:s.error,onRetry:o,connectionsHref:a}),e[8]=a,e[9]=o,e[10]=s.error,e[11]=l):l=e[11],l}}}function Uf(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),n=`${s} (copy)`;if(!t.has(n))return n;for(let i=2;i<1e3;i++){const o=`${s} (copy ${i})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function ER(t,e){const s=ti,n=e.replace(/-copy(?:-\d+)?$/,""),i=`${n}-copy`;if(!t.has(s(i)))return i;for(let o=2;o<1e3;o++){const a=`${n}-copy-${o}`;if(!t.has(s(a)))return a}return`${n}-copy-${Date.now()}`}function PR(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),n=`${s}_copy`;if(!Object.hasOwn(t,n))return n;for(let i=2;i<1e3;i++){const o=`${s}_copy_${i}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function RR(t){const e=yu(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function DR(t,e){return n4(t,e)}const IR=1e3;function MR(t,e){for(let s=0;s<IR;s++){const n=yu(e);if(!Object.hasOwn(t,n))return n}throw new Error("Could not generate a unique page block key")}const OR={create:"sandbox.pageFormDialog.titleCreate",duplicate:"sandbox.pageFormDialog.titleDuplicate",rename:"sandbox.pageFormDialog.titleRename"},$R={create:"sandbox.pageFormDialog.submitCreate",duplicate:"sandbox.pageFormDialog.submitDuplicate",rename:"sandbox.pageFormDialog.submitSave"},BR={create:"sandbox.pageFormDialog.pendingCreate",duplicate:"sandbox.pageFormDialog.pendingDuplicate",rename:"sandbox.pageFormDialog.pendingSave"};function FR(t){const e=F.c(88),{open:s,mode:n,initialName:i,initialPath:o,isPending:a,error:l,templates:c,validate:d,onSubmit:h,onOpenChange:u}=t,f=a===void 0?!1:a,m=oe(),[p,g]=N.useState(i),[x,v]=N.useState(o),[b,_]=N.useState(si),[y,L]=N.useState(null),[w,j]=N.useState(s);s!==w&&(j(s),s&&(g(i),v(o),_(si),L(null)));const S=n==="create"&&!!c?.length;let k;e[0]!==f||e[1]!==u?(k=fe=>{!fe&&!f&&(L(null),u(!1))},e[0]=f,e[1]=u,e[2]=k):k=e[2];const C=k;let A;e[3]!==f||e[4]!==p||e[5]!==h||e[6]!==x||e[7]!==S||e[8]!==b||e[9]!==d?(A=async fe=>{fe.preventDefault();const ue=p.trim(),ae=x.trim();if(!ue||!ae||f)return;const me=U9(ae);if(me){L(me);return}const xe=d?.({name:ue,path:ae});if(xe){L(xe);return}L(null),await h({name:ue,path:ae,templateKey:S&&b!==si?b:null})},e[3]=f,e[4]=p,e[5]=h,e[6]=x,e[7]=S,e[8]=b,e[9]=d,e[10]=A):A=e[10];const P=A,V=y??l,T=OR[n];let R;e[11]!==m||e[12]!==T?(R=m(T),e[11]=m,e[12]=T,e[13]=R):R=e[13];let E;e[14]!==R?(E=r.jsx(cs,{children:r.jsx(ds,{children:R})}),e[14]=R,e[15]=E):E=e[15];let I;e[16]!==f||e[17]!==S||e[18]!==m||e[19]!==b||e[20]!==c?(I=S&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"page-form-template",className:"text-xs font-medium text-muted-foreground",children:m("sandbox.pageFormDialog.labelTemplate")}),r.jsx(r4,{id:"page-form-template",value:b,onChange:_,templates:c??[],disabled:f})]}),e[16]=f,e[17]=S,e[18]=m,e[19]=b,e[20]=c,e[21]=I):I=e[21];let D;e[22]!==m?(D=m("sandbox.pageFormDialog.labelName"),e[22]=m,e[23]=D):D=e[23];let M;e[24]!==D?(M=r.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:D}),e[24]=D,e[25]=M):M=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=fe=>g(fe.target.value),e[26]=O):O=e[26];let $;e[27]!==m?($=m("sandbox.pageFormDialog.placeholderName"),e[27]=m,e[28]=$):$=e[28];let B;e[29]!==f||e[30]!==p||e[31]!==$?(B=r.jsx(et,{id:"page-form-name",value:p,onChange:O,placeholder:$,autoFocus:!0,disabled:f}),e[29]=f,e[30]=p,e[31]=$,e[32]=B):B=e[32];let z;e[33]!==B||e[34]!==M?(z=r.jsxs("div",{className:"space-y-1.5",children:[M,B]}),e[33]=B,e[34]=M,e[35]=z):z=e[35];let K;e[36]!==m?(K=m("sandbox.pageFormDialog.labelPath"),e[36]=m,e[37]=K):K=e[37];let Y;e[38]!==K?(Y=r.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:K}),e[38]=K,e[39]=Y):Y=e[39];let Q;e[40]===Symbol.for("react.memo_cache_sentinel")?(Q=fe=>v(fe.target.value),e[40]=Q):Q=e[40];let q;e[41]!==m?(q=m("sandbox.pageFormDialog.placeholderPath"),e[41]=m,e[42]=q):q=e[42];let H;e[43]!==f||e[44]!==x||e[45]!==q?(H=r.jsx(et,{id:"page-form-path",value:x,onChange:Q,placeholder:q,disabled:f}),e[43]=f,e[44]=x,e[45]=q,e[46]=H):H=e[46];let U;e[47]!==Y||e[48]!==H?(U=r.jsxs("div",{className:"space-y-1.5",children:[Y,H]}),e[47]=Y,e[48]=H,e[49]=U):U=e[49];let X;e[50]!==V?(X=V&&r.jsx("p",{className:"text-xs text-destructive",children:V}),e[50]=V,e[51]=X):X=e[51];let J;e[52]!==z||e[53]!==U||e[54]!==X||e[55]!==I?(J=r.jsxs("div",{className:"space-y-4 py-4",children:[I,z,U,X]}),e[52]=z,e[53]=U,e[54]=X,e[55]=I,e[56]=J):J=e[56];let ee;e[57]!==u?(ee=()=>u(!1),e[57]=u,e[58]=ee):ee=e[58];let W;e[59]!==m?(W=m("sandbox.pageFormDialog.buttonCancel"),e[59]=m,e[60]=W):W=e[60];let Z;e[61]!==f||e[62]!==ee||e[63]!==W?(Z=r.jsx(le,{type:"button",variant:"outline",onClick:ee,disabled:f,children:W}),e[61]=f,e[62]=ee,e[63]=W,e[64]=Z):Z=e[64];let G;e[65]!==f||e[66]!==p||e[67]!==x?(G=!p.trim()||!x.trim()||f,e[65]=f,e[66]=p,e[67]=x,e[68]=G):G=e[68];let te;e[69]!==f||e[70]!==n||e[71]!==m?(te=f?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{size:14,className:"animate-spin"}),m(BR[n])]}):m($R[n]),e[69]=f,e[70]=n,e[71]=m,e[72]=te):te=e[72];let se;e[73]!==G||e[74]!==te?(se=r.jsx(le,{type:"submit",disabled:G,children:te}),e[73]=G,e[74]=te,e[75]=se):se=e[75];let re;e[76]!==Z||e[77]!==se?(re=r.jsxs(mi,{children:[Z,se]}),e[76]=Z,e[77]=se,e[78]=re):re=e[78];let de;e[79]!==P||e[80]!==J||e[81]!==re||e[82]!==E?(de=r.jsx(Yt,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:P,children:[E,J,re]})}),e[79]=P,e[80]=J,e[81]=re,e[82]=E,e[83]=de):de=e[83];let ce;return e[84]!==C||e[85]!==s||e[86]!==de?(ce=r.jsx(Jt,{open:s,onOpenChange:C,children:de}),e[84]=C,e[85]=s,e[86]=de,e[87]=ce):ce=e[87],ce}function zR(t){const e=F.c(70),{open:s,blockKey:n,initialName:i,isPending:o,onSubmit:a,onOpenChange:l}=t,c=o===void 0?!1:o,d=oe(),[h,u]=N.useState(i),[f,m]=N.useState(s);s!==f&&(m(s),s&&u(i));let p;e[0]!==c||e[1]!==l?(p=Q=>{!Q&&!c&&l(!1)},e[0]=c,e[1]=l,e[2]=p):p=e[2];const g=p;let x;e[3]!==c||e[4]!==h||e[5]!==a?(x=async Q=>{Q.preventDefault();const q=h.trim();!q||c||await a(q)},e[3]=c,e[4]=h,e[5]=a,e[6]=x):x=e[6];const v=x;let b;e[7]!==d?(b=d("sandbox.sectionRenameDialog.title"),e[7]=d,e[8]=b):b=e[8];let _;e[9]!==b?(_=r.jsx(ds,{children:b}),e[9]=b,e[10]=_):_=e[10];let y;e[11]!==d?(y=d("sandbox.sectionRenameDialog.description"),e[11]=d,e[12]=y):y=e[12];let L;e[13]!==y?(L=r.jsx(On,{children:y}),e[13]=y,e[14]=L):L=e[14];let w;e[15]!==_||e[16]!==L?(w=r.jsxs(cs,{children:[_,L]}),e[15]=_,e[16]=L,e[17]=w):w=e[17];let j;e[18]!==d?(j=d("sandbox.sectionRenameDialog.nameLabel"),e[18]=d,e[19]=j):j=e[19];let S;e[20]!==j?(S=r.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:j}),e[20]=j,e[21]=S):S=e[21];let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=Q=>u(Q.target.value),e[22]=k):k=e[22];let C;e[23]!==c||e[24]!==h?(C=r.jsx(et,{id:"section-rename-name",value:h,onChange:k,autoFocus:!0,disabled:c}),e[23]=c,e[24]=h,e[25]=C):C=e[25];let A;e[26]!==S||e[27]!==C?(A=r.jsxs("div",{className:"space-y-1.5",children:[S,C]}),e[26]=S,e[27]=C,e[28]=A):A=e[28];let P;e[29]!==d?(P=d("sandbox.sectionRenameDialog.keyLabel"),e[29]=d,e[30]=P):P=e[30];let V;e[31]!==P?(V=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:P}),e[31]=P,e[32]=V):V=e[32];let T;e[33]!==n?(T=r.jsx(et,{value:n,readOnly:!0,disabled:!0,className:"font-mono"}),e[33]=n,e[34]=T):T=e[34];let R;e[35]!==V||e[36]!==T?(R=r.jsxs("div",{className:"space-y-1.5",children:[V,T]}),e[35]=V,e[36]=T,e[37]=R):R=e[37];let E;e[38]!==A||e[39]!==R?(E=r.jsxs("div",{className:"space-y-4 py-4",children:[A,R]}),e[38]=A,e[39]=R,e[40]=E):E=e[40];let I;e[41]!==l?(I=()=>l(!1),e[41]=l,e[42]=I):I=e[42];let D;e[43]!==d?(D=d("sandbox.sectionRenameDialog.cancel"),e[43]=d,e[44]=D):D=e[44];let M;e[45]!==c||e[46]!==I||e[47]!==D?(M=r.jsx(le,{type:"button",variant:"outline",onClick:I,disabled:c,children:D}),e[45]=c,e[46]=I,e[47]=D,e[48]=M):M=e[48];let O;e[49]!==c||e[50]!==h?(O=!h.trim()||c,e[49]=c,e[50]=h,e[51]=O):O=e[51];let $;e[52]!==c||e[53]!==d?($=c?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{size:14,className:"animate-spin"}),d("sandbox.sectionRenameDialog.saving")]}):d("sandbox.sectionRenameDialog.save"),e[52]=c,e[53]=d,e[54]=$):$=e[54];let B;e[55]!==O||e[56]!==$?(B=r.jsx(le,{type:"submit",disabled:O,children:$}),e[55]=O,e[56]=$,e[57]=B):B=e[57];let z;e[58]!==M||e[59]!==B?(z=r.jsxs(mi,{children:[M,B]}),e[58]=M,e[59]=B,e[60]=z):z=e[60];let K;e[61]!==v||e[62]!==E||e[63]!==z||e[64]!==w?(K=r.jsx(Yt,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:v,children:[w,E,z]})}),e[61]=v,e[62]=E,e[63]=z,e[64]=w,e[65]=K):K=e[65];let Y;return e[66]!==g||e[67]!==s||e[68]!==K?(Y=r.jsx(Jt,{open:s,onOpenChange:g,children:K}),e[66]=g,e[67]=s,e[68]=K,e[69]=Y):Y=e[69],Y}function KR(t){const e=F.c(7),{type:s}=t,n=xw[s];let i;e[0]!==n?(i=r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground",children:n})}),e[0]=n,e[1]=i):i=e[1];const o=s==="permanent"?"Permanent":"Temporary";let a;e[2]!==o?(a=r.jsx(He,{side:"left",children:o}),e[2]=o,e[3]=a):a=e[3];let l;return e[4]!==i||e[5]!==a?(l=r.jsxs(We,{children:[i,a]}),e[4]=i,e[5]=a,e[6]=l):l=e[6],l}const cd={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},ju=["posts","authors","categories"],No={posts:"post",authors:"author",categories:"category"};function To(t){return ju.includes(t)}const Cu={posts:"post",authors:"author",categories:"category"},D4={posts:cd.post,authors:cd.author,categories:cd.category},UR=Object.fromEntries(Object.entries(D4).map(([t,e])=>[e,t]));function HR(t){return typeof t=="string"?UR[t]??null:null}function ci(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function It(t){return typeof t=="string"?t:""}function WR(t,e){switch(t){case"posts":return{label:It(e.title)||"Untitled post",subtitle:It(e.slug)};case"authors":return{label:It(e.name)||"Unnamed author",subtitle:It(e.email)};case"categories":return{label:It(e.name)||"Unnamed category",subtitle:It(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function I4(t){const e={posts:[],authors:[],categories:[]};for(const[s,n]of Object.entries(t)){const i=ci(n);if(!i)continue;const o=HR(i.__resolveType);if(!o)continue;const a=ci(i[Cu[o]])??{},{label:l,subtitle:c}=WR(o,a);e[o].push({key:s,kind:o,label:l,subtitle:c})}for(const s of ju)e[s].sort((n,i)=>n.label.localeCompare(i.label));return e}function qR(t,e){return I4(t)[e]}function Jo(t,e){return qR(t,e).map(s=>({key:s.key,payload:el(ci(t[s.key])??void 0,e)}))}const Hf=Object.freeze({});function el(t,e){return t?ci(t[Cu[e]])??Hf:Hf}function Ma(t,e,s){return{name:t,__resolveType:D4[e],[Cu[e]]:s}}function M4(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function Gq({records:t,selected:e,valueField:s,toRef:n}){const i=Array.isArray(e)?e:[],o=f=>typeof f=="string"?f:It(ci(f)?.[s]),a=f=>typeof f=="string"?f:It(ci(f)?.name),l=f=>{const m=o(f),p=m?t.find(({payload:x})=>It(x[s])===m):void 0;if(p)return p;const g=a(f);return g?t.find(({payload:x})=>It(x.name)===g):void 0},c=t.map(({key:f,payload:m})=>({value:f,label:It(m.name)||It(m[s])||f})),d=new Map,h=[];return i.forEach((f,m)=>{const p=l(f);if(p){h.includes(p.key)||h.push(p.key);return}const g=`unresolved:${m}`;d.set(g,f),h.push(g),c.push({value:g,label:a(f)||o(f)||"Unknown"})}),{options:c,selectedValues:h,refsForValues:f=>f.map(m=>{const p=t.find(g=>g.key===m);return p?n(p.payload):d.get(m)}).filter(m=>m!==void 0)}}function Oi(t){return Array.isArray(t)?t:[]}function Rn(t){if(typeof t=="string")return t;const e=ci(t);return e?It(e.slug):""}function GR(t){if(typeof t=="string")return t;const e=ci(t);return e?It(e.email):""}function YR(t){const e=[];return It(t.title).trim()||e.push("Title"),It(t.slug).trim()||e.push("Slug"),Oi(t.categories).map(Rn).filter(Boolean).length===0&&e.push("Category"),It(t.excerpt).trim()||e.push("Excerpt"),It(t.image).trim()||e.push("Cover image"),e}function O4(t){return Jo(t,"posts").map(({key:e,payload:s})=>({key:e,title:It(s.title)||"Untitled post",slug:It(s.slug),date:It(s.date),categorySlugs:Oi(s.categories).map(Rn).filter(Boolean),authorEmails:Oi(s.authors).map(GR).filter(Boolean),missing:YR(s)}))}function JR(t,e){const s=Oi(t.categories);return s.some(n=>Rn(n)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function XR(t,e){const s=Oi(t.categories);return s.length===1&&Rn(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function Yq(t,e,s){const n=Oi(t.categories);if(!n.some(l=>Rn(l)===e))return t;const i=n.map(l=>{const c=Rn(l);return c===e||c===s.slug?{name:s.name,slug:s.slug}:l}),o=new Set,a=i.filter(l=>{const c=Rn(l);return c?o.has(c)?!1:(o.add(c),!0):!0});return{...t,categories:a}}function QR(t,e){const s=Oi(t.categories);return s.some(n=>Rn(n)===e)?{...t,categories:s.filter(n=>Rn(n)!==e)}:t}function Wf(t){return{...t,dateModified:new Date().toISOString()}}function a0(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function qf(t,e){const s=`collections/blog/${e}/${a0(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function ZR(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${a0(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",type:"Person",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${a0(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const eD={Paragraph:{title:"Paragraph",description:"Rich text content",iconName:"Pilcrow01"},Heading:{title:"Heading",description:"Section title (H1–H6)",iconName:"HeadingSquare"},Quote:{title:"Quote",description:"Pull quote",iconName:"MessageTextSquare02"},Code:{title:"Code",description:"Code block with syntax highlighting",iconName:"Code02"},List:{title:"List",description:"Bulleted or numbered list",iconName:"List"},BlockImage:{title:"Image",description:"Image with optional caption",iconName:"Image01"},Video:{title:"Video",description:"Embedded video",iconName:"PlayCircle"},Divider:{title:"Divider",description:"Horizontal divider",iconName:"Divider"},Cta:{title:"Call to action",description:"Button linking to a URL",iconName:"CursorClick01"},Callout:{title:"Callout",description:"Highlighted note, tip or warning",iconName:"Lightbulb02"},Stat:{title:"Stat",description:"Single key metric",iconName:"BarChartSquareUp"},StatGroup:{title:"Stat group",description:"Row of metrics",iconName:"BarChartSquare02"},CardGroup:{title:"Card group",description:"Grid of cards",iconName:"LayoutGrid01"},Checklist:{title:"Checklist",description:"List of check items",iconName:"CheckSquare"},Steps:{title:"Steps",description:"Step-by-step guide",iconName:"LayersThree01"},Comparison:{title:"Comparison",description:"Side-by-side comparison",iconName:"Columns03"},Table:{title:"Table",description:"Rows and columns of structured data",iconName:"Table"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},Gf="Box";function tD(t){return t.startsWith("site/")?"site":"app"}function sD(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function to(...t){for(const e of t)if(e!==void 0)return e}function Jq(t){const e=new Set,s=[],n=t.manifest?.blocks??{};for(const i of Object.values(n))for(const o of Object.keys(i)){if(!rD(o)||e.has(o))continue;e.add(o);const a=gi(o,t),l=nD(o),c=eD[l],d=tD(o),h=(d==="site"?to(a.title,c?.title):to(c?.title,a.title))??l,u=d==="site"?to(a.description,c?.description):to(c?.description,a.description),f=d==="site"?a.icon:void 0,m=f&&sD(f)?f:void 0,p=m!==void 0?c?.iconName??Gf:to(f,c?.iconName)??Gf;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:d})}return s.sort((i,o)=>i.title.localeCompare(o.title))}function nD(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const iD=["blog/sections/blocks/","site/sections/Blog/Post/"];function rD(t){return iD.some(e=>t.startsWith(e))}function $4({orgSlug:t,virtualMcpId:e,branch:s}){return Qe.decofile(`${t}/${e}/${s}`)}function oD({orgSlug:t,virtualMcpId:e,branch:s}){return Qe.liveMeta(t,e,s)}function aD({orgSlug:t,virtualMcpId:e,branch:s},n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${n}`}async function B4(t,e,s,n){const i=await fetch(aD(t,e),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.error??`${n} (${i.status})`)}return i.json()}function lD(t){const e=F.c(11),s=Ls();let n;e[0]!==t?(n=l=>{const{blockKey:c,data:d}=l;return B4(t,"write",{path:Ir(t.packagePath,M4(c)),content:JSON.stringify(d,null,2)},"Write failed")},e[0]=t,e[1]=n):n=e[1];let i;e[2]!==t||e[3]!==s?(i=async l=>{const{blockKey:c,data:d}=l,h=$4(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[c]:d})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=i):i=e[4];let o;e[5]!==s?(o=(l,c,d)=>{d?.queryKey&&s.setQueryData(d.queryKey,d.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==n||e[8]!==i||e[9]!==o?(a={mutationFn:n,onMutate:i,onError:o},e[7]=n,e[8]=i,e[9]=o,e[10]=a):a=e[10],Ys(a)}function cD(t){const e=Ls();return Ys({mutationFn:({blockKey:s})=>B4(t,"unlink",{path:Ir(t.packagePath,M4(s))},"Delete failed"),onMutate:async({blockKey:s})=>{const n=$4(t);await e.cancelQueries({queryKey:n});const i=e.getQueryData(n);return e.setQueryData(n,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:i,queryKey:n}},onError:(s,n,i)=>{i?.queryKey&&e.setQueryData(i.queryKey,i.previous)},onSuccess:()=>{e.invalidateQueries({queryKey:oD(t)})}})}function dD({open:t,onOpenChange:e,pageKey:s,decofile:n,onSave:i}){const o=oe(),a=n[s],l=a===void 0,c=l?"":JSON.stringify(a,null,2),[d,h]=N.useState(!1),[u,f]=N.useState(c),[m,p]=N.useState(!1),g=!i||l,x=u!==c,v=()=>{navigator.clipboard.writeText(u).then(()=>{h(!0),setTimeout(()=>h(!1),2e3)})},b=async _=>{if(!i||m)return;let y;try{y=JSON.parse(_)}catch{ve.error(o("sectionsEditor.pageJsonDialog.invalidJsonError"));return}p(!0);try{await i(y),ve.success(o("sectionsEditor.pageJsonDialog.saveSuccess")),e(!1)}catch(L){ve.error(o("sectionsEditor.pageJsonDialog.saveError",{error:L instanceof Error?L.message:String(L)}))}finally{p(!1)}};return r.jsx(Jt,{open:t,onOpenChange:e,children:r.jsxs(Yt,{className:"max-w-3xl p-0 gap-0",children:[r.jsxs(cs,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[r.jsx(ds,{className:"text-sm font-semibold",children:o("sectionsEditor.pageJsonDialog.title")}),r.jsxs("div",{className:"flex items-center gap-2 mr-8",children:[r.jsxs(le,{variant:"ghost",size:"sm",onClick:v,className:"h-7 gap-1.5 text-xs",children:[d?r.jsx(ic,{size:12}):r.jsx(Vs,{size:12}),o(d?"sectionsEditor.pageJsonDialog.copied":"sectionsEditor.pageJsonDialog.copy")]}),!g&&r.jsx(le,{size:"sm",onClick:()=>b(u),disabled:!x||m,className:"h-7 text-xs",children:o(m?"sectionsEditor.pageJsonDialog.saving":"sectionsEditor.pageJsonDialog.save")})]})]}),l?r.jsxs("div",{className:"p-4 text-xs font-mono text-foreground/60",children:["// ",o("sectionsEditor.pageJsonDialog.pageNotFound")]}):r.jsx("div",{className:"h-[70vh]",children:r.jsx(ua,{code:c,language:"json",readOnly:g,height:"100%",onChange:_=>f(_??""),onSave:_=>{b(_)}})})]})})}function Qs(t){const e=F.c(45),{icon:s,logoUrl:n,title:i,subtitle:o,active:a,accent:l,variantCount:c,trailing:d,selectable:h,selectionActive:u,selected:f,invalid:m,invalidReason:p,onToggleSelect:g,onClick:x,menu:v}=t,b=l==="global";let _;e[0]!==s||e[1]!==a||e[2]!==b||e[3]!==n||e[4]!==c?(_=c&&c>1?r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(s,{size:16,className:"shrink-0 text-success"})}),r.jsxs(He,{side:"right",children:[c," variants"]})]})}):n?r.jsx("img",{src:n,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):r.jsx("span",{className:ie("flex size-8 shrink-0 items-center justify-center rounded-lg",b?"bg-global-section/15":"bg-muted"),children:r.jsx(s,{size:16,className:ie("shrink-0",!b&&(a?"text-accent-foreground":"text-muted-foreground")),style:b?{color:B9}:void 0})}),e[0]=s,e[1]=a,e[2]=b,e[3]=n,e[4]=c,e[5]=_):_=e[5];const y=_,L=a?b?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":b?"hover:bg-global-section/10":"hover:bg-muted";let w;e[6]!==L?(w=ie("group relative flex min-w-0 items-center rounded-md transition-colors",L),e[6]=L,e[7]=w):w=e[7];let j;e[8]!==g||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==i?(j=h&&r.jsx("span",{className:ie("flex shrink-0 items-center pl-2.5 transition-opacity",f||u?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"),onClick:uD,children:r.jsx(Pr,{checked:f,onCheckedChange:()=>g?.(),"aria-label":`Select ${i}`})}),e[8]=g,e[9]=h,e[10]=f,e[11]=u,e[12]=i,e[13]=j):j=e[13];const S=m&&!a&&"text-destructive";let k;e[14]!==S?(k=ie("block truncate text-sm font-medium",S),e[14]=S,e[15]=k):k=e[15];let C;e[16]!==k||e[17]!==i?(C=r.jsx("span",{className:k,children:i}),e[16]=k,e[17]=i,e[18]=C):C=e[18];const A=a?"text-accent-foreground/70":"text-muted-foreground";let P;e[19]!==A?(P=ie("block truncate text-xs",A),e[19]=A,e[20]=P):P=e[20];let V;e[21]!==o||e[22]!==P?(V=r.jsx("span",{className:P,children:o}),e[21]=o,e[22]=P,e[23]=V):V=e[23];let T;e[24]!==V||e[25]!==C?(T=r.jsxs("span",{className:"min-w-0 flex-1",children:[C,V]}),e[24]=V,e[25]=C,e[26]=T):T=e[26];let R;e[27]!==a||e[28]!==m||e[29]!==p?(R=m&&r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:ie("flex shrink-0 items-center",a?"text-accent-foreground":"text-destructive"),children:r.jsx(jn,{size:14})})}),p&&r.jsx(He,{side:"bottom",children:p})]}),e[27]=a,e[28]=m,e[29]=p,e[30]=R):R=e[30];let E;e[31]!==x||e[32]!==y||e[33]!==T||e[34]!==R||e[35]!==d?(E=r.jsxs("button",{type:"button",onClick:x,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[y,T,R,d]}),e[31]=x,e[32]=y,e[33]=T,e[34]=R,e[35]=d,e[36]=E):E=e[36];let I;e[37]!==a||e[38]!==v?(I=v&&r.jsx("div",{className:ie("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:v}),e[37]=a,e[38]=v,e[39]=I):I=e[39];let D;return e[40]!==E||e[41]!==I||e[42]!==w||e[43]!==j?(D=r.jsxs("div",{className:w,children:[j,E,I]}),e[40]=E,e[41]=I,e[42]=w,e[43]=j,e[44]=D):D=e[44],D}function uD(t){return t.stopPropagation()}function Qn(t){const e=F.c(10),{icon:s,title:n,description:i}=t;let o;e[0]!==s?(o=s&&r.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==n?(a=r.jsx("div",{children:n}),e[2]=n,e[3]=a):a=e[3];let l;e[4]!==i?(l=i&&r.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:i}),e[4]=i,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==a||e[8]!==l?(c=r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}var hD=Gv.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(s=>e.updateAttributes(s,{textAlign:t})).some(s=>s):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:s})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?s.unsetTextAlign():s.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),fD=hD;const mD=new Set(["http:","https:","mailto:","tel:","ftp:"]);function pD(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return mD.has(e.protocol)}catch{return!1}}function gD(t){const e=t.trim();return e?e.startsWith("/")||e.startsWith(".")||e.startsWith("#")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)?e:`https://${e}`:""}const xD="noopener noreferrer nofollow";function xs(t){const e=F.c(8),{active:s,label:n,onClick:i,children:o}=t,a=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let l;e[0]!==a?(l=ie("flex h-7 w-7 items-center justify-center rounded transition-colors cursor-pointer",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==s||e[3]!==o||e[4]!==n||e[5]!==i||e[6]!==l?(c=r.jsx("button",{type:"button","aria-label":n,"aria-pressed":s,onMouseDown:vD,onClick:i,className:l,children:o}),e[2]=s,e[3]=o,e[4]=n,e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function vD(t){return t.preventDefault()}function Yf(t){const e=F.c(7),{active:s,label:n,onSelect:i}=t,o=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let a;e[0]!==o?(a=ie("flex-1 rounded px-2 py-1 text-xs transition-colors cursor-pointer",o),e[0]=o,e[1]=a):a=e[1];let l;return e[2]!==s||e[3]!==n||e[4]!==i||e[5]!==a?(l=r.jsx("button",{type:"button","aria-pressed":s,onMouseDown:bD,onClick:i,className:a,children:n}),e[2]=s,e[3]=n,e[4]=i,e[5]=a,e[6]=l):l=e[6],l}function bD(t){return t.preventDefault()}function yD(t){const e=F.c(36),{editor:s,active:n,open:i,onOpenChange:o}=t,a=oe(),[l,c]=N.useState(""),[d,h]=N.useState(!0),[u,f]=N.useState(!1);let m;e[0]!==n||e[1]!==s||e[2]!==o?(m=()=>{const A=s.getAttributes("link");c(typeof A.href=="string"?A.href:""),h(n?A.target==="_blank":!0),f(!1),o(!0)},e[0]=n,e[1]=s,e[2]=o,e[3]=m):m=e[3];const p=m;let g;e[4]!==s||e[5]!==o?(g=()=>{o(!1),s.chain().focus().run()},e[4]=s,e[5]=o,e[6]=g):g=e[6];const x=g;let v;e[7]!==l||e[8]!==s||e[9]!==d||e[10]!==o?(v=()=>{const A=gD(l);if(A===""){s.chain().focus().extendMarkRange("link").unsetLink().run(),o(!1);return}if(!pD(A)){f(!0);return}s.chain().focus().extendMarkRange("link").setLink({href:A,target:d?"_blank":null,rel:d?xD:null}).run(),o(!1)},e[7]=l,e[8]=s,e[9]=d,e[10]=o,e[11]=v):v=e[11];const b=v;let _;e[12]!==s||e[13]!==o?(_=()=>{s.chain().focus().extendMarkRange("link").unsetLink().run(),o(!1)},e[12]=s,e[13]=o,e[14]=_):_=e[14];const y=_;let L;e[15]!==a?(L=a("sectionsEditor.richTextLinkControl.linkButtonLabel"),e[15]=a,e[16]=L):L=e[16];const w=i?x:p;let j;e[17]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(V2,{size:14}),e[17]=j):j=e[17];let S;e[18]!==n||e[19]!==L||e[20]!==w?(S=r.jsx(xs,{active:n,label:L,onClick:w,children:j}),e[18]=n,e[19]=L,e[20]=w,e[21]=S):S=e[21];let k;e[22]!==n||e[23]!==b||e[24]!==x||e[25]!==l||e[26]!==u||e[27]!==d||e[28]!==o||e[29]!==i||e[30]!==y||e[31]!==a?(k=i&&r.jsxs("div",{className:"absolute left-0 top-full z-20 mt-1.5 flex w-64 flex-col gap-1 rounded-md border bg-popover p-1 shadow-md",onBlur:A=>{A.currentTarget.contains(A.relatedTarget)||o(!1)},children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("input",{autoFocus:!0,type:"text","aria-label":a("sectionsEditor.richTextLinkControl.urlInputAriaLabel"),"aria-invalid":u,placeholder:a("sectionsEditor.richTextLinkControl.urlInputPlaceholder"),value:l,onChange:A=>{c(A.target.value),f(!1)},onKeyDown:A=>{A.key==="Enter"?(A.preventDefault(),b()):A.key==="Escape"&&(A.preventDefault(),x())},className:ie("h-7 flex-1 rounded bg-transparent px-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none",u&&"text-destructive")}),r.jsx(xs,{active:!1,label:a("sectionsEditor.richTextLinkControl.applyLinkLabel"),onClick:b,children:r.jsx(ns,{size:14})}),n&&r.jsx(xs,{active:!1,label:a("sectionsEditor.richTextLinkControl.removeLinkLabel"),onClick:y,children:r.jsx(_s,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-0.5 rounded bg-muted/40 p-0.5",children:[r.jsx(Yf,{active:!d,label:a("sectionsEditor.richTextLinkControl.sameTabLabel"),onSelect:()=>h(!1)}),r.jsx(Yf,{active:d,label:a("sectionsEditor.richTextLinkControl.newTabLabel"),onSelect:()=>h(!0)})]})]}),e[22]=n,e[23]=b,e[24]=x,e[25]=l,e[26]=u,e[27]=d,e[28]=o,e[29]=i,e[30]=y,e[31]=a,e[32]=k):k=e[32];let C;return e[33]!==S||e[34]!==k?(C=r.jsxs("div",{className:"relative",children:[S,k]}),e[33]=S,e[34]=k,e[35]=C):C=e[35],C}function _D({schema:t,value:e,onChange:s,path:n,label:i}){const o=typeof e=="string"?e:"",a=N.useRef(s);a.current=s;const[l,c]=N.useState(!1),d=Xm({extensions:[zm.configure({heading:{levels:[1,2,3]},link:{HTMLAttributes:{}}}),fD.configure({types:["heading","paragraph"]})],content:o||"",editorProps:{attributes:{class:ie("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:u})=>{const f=u.getHTML();a.current(f==="<p></p>"?"":f)}}),h=Yv({editor:d,selector:({editor:u})=>({bold:u?.isActive("bold")??!1,italic:u?.isActive("italic")??!1,underline:u?.isActive("underline")??!1,strike:u?.isActive("strike")??!1,h1:u?.isActive("heading",{level:1})??!1,h2:u?.isActive("heading",{level:2})??!1,bulletList:u?.isActive("bulletList")??!1,orderedList:u?.isActive("orderedList")??!1,link:u?.isActive("link")??!1,alignLeft:u?.isActive({textAlign:"left"})??!1,alignCenter:u?.isActive({textAlign:"center"})??!1,alignRight:u?.isActive({textAlign:"right"})??!1,alignJustify:u?.isActive({textAlign:"justify"})??!1})});return d?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(st,{htmlFor:n,children:i}),t.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),r.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border/60 bg-muted/30 px-1.5 py-1",children:[r.jsx(xs,{active:h.bold,label:"Bold",onClick:()=>d.chain().focus().toggleBold().run(),children:r.jsx(F6,{size:14})}),r.jsx(xs,{active:h.italic,label:"Italic",onClick:()=>d.chain().focus().toggleItalic().run(),children:r.jsx(z6,{size:14})}),r.jsx(xs,{active:h.underline,label:"Underline",onClick:()=>d.chain().focus().toggleUnderline().run(),children:r.jsx(K6,{size:14})}),r.jsx(xs,{active:h.strike,label:"Strikethrough",onClick:()=>d.chain().focus().toggleStrike().run(),children:r.jsx(U6,{size:14})}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(xs,{active:h.h1,label:"Heading 1",onClick:()=>d.chain().focus().toggleHeading({level:1}).run(),children:r.jsx(H6,{size:14})}),r.jsx(xs,{active:h.h2,label:"Heading 2",onClick:()=>d.chain().focus().toggleHeading({level:2}).run(),children:r.jsx(W6,{size:14})}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(xs,{active:h.bulletList,label:"Bullet list",onClick:()=>d.chain().focus().toggleBulletList().run(),children:r.jsx(I8,{size:14})}),r.jsx(xs,{active:h.orderedList,label:"Ordered list",onClick:()=>d.chain().focus().toggleOrderedList().run(),children:r.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(yD,{editor:d,active:h.link,open:l,onOpenChange:c}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(xs,{active:h.alignLeft,label:"Align left",onClick:()=>d.chain().focus().setTextAlign("left").run(),children:r.jsx(R8,{size:14})}),r.jsx(xs,{active:h.alignCenter,label:"Align center",onClick:()=>d.chain().focus().setTextAlign("center").run(),children:r.jsx(q6,{size:14})}),r.jsx(xs,{active:h.alignRight,label:"Align right",onClick:()=>d.chain().focus().setTextAlign("right").run(),children:r.jsx(G6,{size:14})}),r.jsx(xs,{active:h.alignJustify,label:"Justify",onClick:()=>d.chain().focus().setTextAlign("justify").run(),children:r.jsx(Y6,{size:14})})]}),r.jsx(Qm,{editor:d})]})]}):null}const cr=t=>String(t).padStart(2,"0"),LD="1900-01-01",SD="2099-12-31",wD="1900-01-01T00:00",jD="2099-12-31T23:59";function CD(t){if(!t)return"";const e=t.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;const s=new Date(t);return Number.isNaN(s.getTime())?"":`${s.getUTCFullYear()}-${cr(s.getUTCMonth()+1)}-${cr(s.getUTCDate())}`}function kD(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function VD(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${cr(e.getMonth()+1)}-${cr(e.getDate())}T${cr(e.getHours())}:${cr(e.getMinutes())}`}function ND(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function TD(t){const e=F.c(41),{id:s,withTime:n,value:i,onChange:o,calendarLabel:a}=t,[l,c]=N.useState(!1);let d;e[0]!==n?(d=M=>n?VD(M):CD(M),e[0]=n,e[1]=d):d=e[1];const h=d;let u;e[2]!==n?(u=M=>n?ND(M):kD(M),e[2]=n,e[3]=u):u=e[3];const f=u;let m;e[4]!==h||e[5]!==i?(m=()=>h(i),e[4]=h,e[5]=i,e[6]=m):m=e[6];const[p,g]=N.useState(m),[x,v]=N.useState(i);if(i!==x){v(i);const M=h(i);M!==p&&g(M)}let b;e[7]!==o||e[8]!==f?(b=M=>{g(M.target.value),o(f(M.target.value))},e[7]=o,e[8]=f,e[9]=b):b=e[9];const _=b;let y;if(e[10]!==i){const M=i?new Date(i):null;y=M&&!Number.isNaN(M.getTime())?M:null,e[10]=i,e[11]=y}else y=e[11];const L=y;let w;e[12]!==o||e[13]!==L||e[14]!==h||e[15]!==n?(w=M=>{if(!M)return;n&&L?M.setHours(L.getHours(),L.getMinutes(),0,0):M.setHours(0,0,0,0);const O=M.toISOString();g(h(O)),v(O),o(O),c(!1)},e[12]=o,e[13]=L,e[14]=h,e[15]=n,e[16]=w):w=e[16];const j=w,S=n?"datetime-local":"date",k=n?wD:LD,C=n?jD:SD;let A;e[17]!==h||e[18]!==i?(A=()=>g(h(i)),e[17]=h,e[18]=i,e[19]=A):A=e[19];let P;e[20]!==_||e[21]!==s||e[22]!==p||e[23]!==A||e[24]!==S||e[25]!==k||e[26]!==C?(P=r.jsx(et,{id:s,type:S,min:k,max:C,value:p,onChange:_,onBlur:A,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[20]=_,e[21]=s,e[22]=p,e[23]=A,e[24]=S,e[25]=k,e[26]=C,e[27]=P):P=e[27];let V;e[28]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(l9,{className:"h-4 w-4"}),e[28]=V):V=e[28];let T;e[29]!==a?(T=r.jsx(Ts,{asChild:!0,children:r.jsx(le,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":a,children:V})}),e[29]=a,e[30]=T):T=e[30];const R=L??void 0;let E;e[31]!==j||e[32]!==R?(E=r.jsx(As,{className:"w-auto p-0",align:"end",onCloseAutoFocus:AD,children:r.jsx(Jv,{mode:"single",selected:R,onSelect:j,initialFocus:!0})}),e[31]=j,e[32]=R,e[33]=E):E=e[33];let I;e[34]!==l||e[35]!==T||e[36]!==E?(I=r.jsxs(Es,{open:l,onOpenChange:c,children:[T,E]}),e[34]=l,e[35]=T,e[36]=E,e[37]=I):I=e[37];let D;return e[38]!==P||e[39]!==I?(D=r.jsxs("div",{className:"flex gap-1",children:[P,I]}),e[38]=P,e[39]=I,e[40]=D):D=e[40],D}function AD(t){return t.preventDefault()}function Oa(t){const e=F.c(8),{htmlFor:s,label:n,description:i}=t;let o;e[0]!==s||e[1]!==n?(o=r.jsx(st,{htmlFor:s,children:n}),e[0]=s,e[1]=n,e[2]=o):o=e[2];let a;e[3]!==i?(a=i&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:i}),e[3]=i,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=r.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function $a(t){const e=F.c(70),{schema:s,value:n,onChange:i,path:o,label:a}=t,l=oe(),c=typeof n=="string"?n:"",d=s.format;if(d==="rich-text"||d==="rich-text-inline"||d==="html"){let x;return e[0]!==a||e[1]!==i||e[2]!==o||e[3]!==s||e[4]!==n?(x=r.jsx(_D,{schema:s,value:n,onChange:i,path:o,label:a}),e[0]=a,e[1]=i,e[2]=o,e[3]=s,e[4]=n,e[5]=x):x=e[5],x}if(d==="textarea"||d==="markdown"){let x;e[6]!==a||e[7]!==o||e[8]!==s.description?(x=r.jsx(Oa,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=x):x=e[9];let v;e[10]!==i?(v=y=>i(y.target.value),e[10]=i,e[11]=v):v=e[11];let b;e[12]!==o||e[13]!==c||e[14]!==v?(b=r.jsx(Ri,{id:o,value:c,onChange:v,rows:4}),e[12]=o,e[13]=c,e[14]=v,e[15]=b):b=e[15];let _;return e[16]!==x||e[17]!==b?(_=r.jsxs("div",{className:"space-y-2",children:[x,b]}),e[16]=x,e[17]=b,e[18]=_):_=e[18],_}if(d==="date"||d==="date-time"){let x;e[19]!==a||e[20]!==o||e[21]!==s.description?(x=r.jsx(Oa,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=x):x=e[22];const v=d==="date-time";let b;e[23]!==l?(b=l("sectionsEditor.stringField.openCalendar"),e[23]=l,e[24]=b):b=e[24];let _;e[25]!==i||e[26]!==o||e[27]!==c||e[28]!==v||e[29]!==b?(_=r.jsx(TD,{id:o,withTime:v,value:c,onChange:i,calendarLabel:b}),e[25]=i,e[26]=o,e[27]=c,e[28]=v,e[29]=b,e[30]=_):_=e[30];let y;return e[31]!==x||e[32]!==_?(y=r.jsxs("div",{className:"space-y-2",children:[x,_]}),e[31]=x,e[32]=_,e[33]=y):y=e[33],y}if(d==="color-input"||d==="color"){let x;e[34]!==a||e[35]!==o||e[36]!==s.description?(x=r.jsx(Oa,{htmlFor:o,label:a,description:s.description}),e[34]=a,e[35]=o,e[36]=s.description,e[37]=x):x=e[37];const v=c||"#000000";let b;e[38]!==i?(b=S=>i(S.target.value),e[38]=i,e[39]=b):b=e[39];let _;e[40]!==v||e[41]!==b?(_=r.jsx("input",{type:"color",value:v,onChange:b,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[40]=v,e[41]=b,e[42]=_):_=e[42];let y;e[43]!==i?(y=S=>i(S.target.value),e[43]=i,e[44]=y):y=e[44];let L;e[45]!==o||e[46]!==c||e[47]!==y?(L=r.jsx(et,{id:o,value:c,onChange:y,placeholder:"#000000",className:"h-10 flex-1"}),e[45]=o,e[46]=c,e[47]=y,e[48]=L):L=e[48];let w;e[49]!==_||e[50]!==L?(w=r.jsxs("div",{className:"flex items-center gap-2",children:[_,L]}),e[49]=_,e[50]=L,e[51]=w):w=e[51];let j;return e[52]!==x||e[53]!==w?(j=r.jsxs("div",{className:"space-y-2",children:[x,w]}),e[52]=x,e[53]=w,e[54]=j):j=e[54],j}let h;e[55]!==a||e[56]!==o||e[57]!==s.description?(h=r.jsx(Oa,{htmlFor:o,label:a,description:s.description}),e[55]=a,e[56]=o,e[57]=s.description,e[58]=h):h=e[58];const u=d==="url"?"url":"text";let f;e[59]!==i?(f=x=>i(x.target.value),e[59]=i,e[60]=f):f=e[60];const m=s.default!=null?String(s.default):void 0;let p;e[61]!==o||e[62]!==c||e[63]!==u||e[64]!==f||e[65]!==m?(p=r.jsx(et,{id:o,type:u,value:c,onChange:f,placeholder:m,className:"h-10"}),e[61]=o,e[62]=c,e[63]=u,e[64]=f,e[65]=m,e[66]=p):p=e[66];let g;return e[67]!==h||e[68]!==p?(g=r.jsxs("div",{className:"space-y-2",children:[h,p]}),e[67]=h,e[68]=p,e[69]=g):g=e[69],g}const ED=/^[+-]?\d*\.?\d*(?:[eE][+-]?\d*)?$/;function PD(t){const e=F.c(18),{schema:s,value:n,onChange:i,path:o,label:a}=t,l=typeof n=="number"?String(n):"",[c,d]=N.useState(l),[h,u]=N.useState(l);l!==h&&(u(l),c!==""&&l!==""&&Number(c)===Number(l)||d(l));let f;e[0]!==a||e[1]!==o?(f=r.jsx(st,{htmlFor:o,children:a}),e[0]=a,e[1]=o,e[2]=f):f=e[2];let m;e[3]!==s.description?(m=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=m):m=e[4];let p;e[5]!==f||e[6]!==m?(p=r.jsxs("div",{className:"space-y-0.5",children:[f,m]}),e[5]=f,e[6]=m,e[7]=p):p=e[7];const g=s.type==="integer"?"numeric":"decimal";let x;e[8]!==i?(x=_=>{const y=_.target.value;if(y!==""&&!ED.test(y))return;d(y);const L=Number(y);i(y===""||Number.isNaN(L)?void 0:L)},e[8]=i,e[9]=x):x=e[9];let v;e[10]!==o||e[11]!==c||e[12]!==g||e[13]!==x?(v=r.jsx(et,{id:o,type:"text",inputMode:g,value:c,onChange:x,className:"h-10"}),e[10]=o,e[11]=c,e[12]=g,e[13]=x,e[14]=v):v=e[14];let b;return e[15]!==p||e[16]!==v?(b=r.jsxs("div",{className:"space-y-2",children:[p,v]}),e[15]=p,e[16]=v,e[17]=b):b=e[17],b}function RD(t){const e=F.c(17),{value:s,onChange:n,path:i,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let c;e[0]!==o||e[1]!==i?(c=r.jsx(st,{htmlFor:i,children:o}),e[0]=o,e[1]=i,e[2]=c):c=e[2];let d;e[3]!==a.description?(d=a.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a.description}),e[3]=a.description,e[4]=d):d=e[4];let h;e[5]!==c||e[6]!==d?(h=r.jsxs("div",{className:"space-y-0.5",children:[c,d]}),e[5]=c,e[6]=d,e[7]=h):h=e[7];let u;e[8]!==n?(u=p=>n(p),e[8]=n,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==i||e[12]!==u?(f=r.jsx(_r,{id:i,checked:l,onCheckedChange:u}),e[10]=l,e[11]=i,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}const ku="__enum_empty__";function Vu(t){return t===""?ku:String(t)}function DD(t,e){if(t===ku)return"";const s=e.find(n=>Vu(n)===t);return s!==void 0?s:t}function ID(t,e){return t==null?e.some(s=>s==="")?ku:void 0:Vu(t)}function MD(t){return t===""?"":String(t)}function OD(t){const e=F.c(32),{schema:s,value:n,onChange:i,path:o,label:a}=t,l=oe();let c;e[0]!==s.enum?(c=s.enum??[],e[0]=s.enum,e[1]=c):c=e[1];const d=c;let h;e[2]!==d||e[3]!==n?(h=ID(n,d),e[2]=d,e[3]=n,e[4]=h):h=e[4];const u=h;let f;e[5]!==a||e[6]!==o?(f=r.jsx(st,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=f):f=e[7];let m;e[8]!==s.description?(m=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=m):m=e[9];let p;e[10]!==f||e[11]!==m?(p=r.jsxs("div",{className:"space-y-0.5",children:[f,m]}),e[10]=f,e[11]=m,e[12]=p):p=e[12];let g;e[13]!==i||e[14]!==d?(g=w=>i(DD(w,d)),e[13]=i,e[14]=d,e[15]=g):g=e[15];let x;e[16]!==l?(x=l("sectionsEditor.enumField.selectPlaceholder"),e[16]=l,e[17]=x):x=e[17];let v;e[18]!==x?(v=r.jsx($t,{className:"h-10",children:r.jsx(qt,{placeholder:x})}),e[18]=x,e[19]=v):v=e[19];let b;e[20]!==d?(b=d.map($D),e[20]=d,e[21]=b):b=e[21];let _;e[22]!==b?(_=r.jsx(Bt,{children:b}),e[22]=b,e[23]=_):_=e[23];let y;e[24]!==u||e[25]!==_||e[26]!==g||e[27]!==v?(y=r.jsxs(Ft,{value:u,onValueChange:g,children:[v,_]}),e[24]=u,e[25]=_,e[26]=g,e[27]=v,e[28]=y):y=e[28];let L;return e[29]!==y||e[30]!==p?(L=r.jsxs("div",{className:"space-y-2",children:[p,y]}),e[29]=y,e[30]=p,e[31]=L):L=e[31],L}function $D(t){const e=Vu(t);return r.jsx(ut,{value:e,children:MD(t)},e)}const F4={duration:180,easing:"cubic-bezier(0.2, 0, 0, 1)",sideEffects:void 0};function z4(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return Array.isArray(e.variants)?e:null}function Ao(t){return z4(t)?.variants?.[0]?.rule?.__resolveType===Mr}function Jf(t){return{__resolveType:Gi,variants:[{value:t,rule:{__resolveType:Mr}}]}}function K4(t){return Ao(t)?z4(t)?.variants?.[0]?.value:t}function xo(t){return Ao(t)?K4(t):t}function Nu(t){const e=t.__resolveType;if(typeof e!="string")return null;if(fs(e)){const n=t.section?.__resolveType;return typeof n=="string"?n:e}return e}function BD(t){return t.includes("flags/multivariate")}function FD(t){return At(t)}function zD(t,e){const s=[...t],n=new Set(s.map(o=>o.resolveType)),i=(o,a)=>{!o||n.has(o)||(n.add(o),s.push({resolveType:o,title:a??FD(o)}))};if(e.savedBlockKey&&i(e.savedBlockKey,e.savedBlockKey),e.editorValue&&typeof e.editorValue=="object"&&!Array.isArray(e.editorValue)){const o=Nu(e.editorValue);o?.includes("/")&&i(o)}return s}function KD(t,e,s){const n=e[0]?.resolveType??"";if(s)return s;if(!t||typeof t!="object"||Array.isArray(t))return n;const i=t,o=i.__resolveType;if(typeof o=="string"){if(_n(o)){const u=e.find(f=>f.resolveType===o);return u?u.resolveType:o}const d=e.find(u=>$h(u.resolveType,o));if(d)return d.resolveType;const h=e.find(u=>u.resolveType===o);if(h)return h.resolveType;if(o.includes("/"))return o}const a=typeof i.type=="string"?i.type:void 0;if(a){const d=e.find(h=>h.discriminatorValue===a||h.resolveType===a||$h(h.resolveType,a));if(d)return d.resolveType}let l=n,c=-1;for(const d of e){if(!d.schema?.properties)continue;const u=Object.keys(d.schema.properties).filter(f=>!f.startsWith("__")&&f!=="@type"&&f!=="action"&&f!=="alt").filter(f=>i[f]!==void 0).length;u>0&&u>c&&(c=u,l=d.resolveType)}return c>0,l}function Xf(t,e,s){if(!t||typeof t!="object"||Array.isArray(t))return s??null;const n=Nu(t);if(!n)return s??null;if(!e)return n.includes("/")?null:s??null;const i=Ln(n,e);return i||(n.includes("/")?null:s??null)}function UD(t,e){if(!t?.properties||!e)return t??null;if(!(e in t.properties))return t;const s={...t.properties};return delete s[e],{...t,properties:s}}function U4(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;if(typeof e.__resolveType!="string"||!fs(e.__resolveType))return null;const s=e.section;return!s||typeof s!="object"||Array.isArray(s)?null:s}function HD(t,e){if(e)return!0;if(!t||typeof t!="object"||Array.isArray(t))return!1;const s=t,n=Nu(s);return n&&BD(n)?Array.isArray(s.variants)&&s.variants.length>0:Object.keys(s).some(i=>!i.startsWith("__")&&i!=="@type")}function Tu(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return"";const e=t;if(Array.isArray(e.variants)){const s=e.variants,n=s.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof n?.value=="string")return n.value;const i=s.find(o=>typeof o.value=="string");if(i)return i.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function WD(t){if(t?.trim())try{const e=new URL(t);return e.protocol!=="https:"?void 0:e.href}catch{return}}function qD(t){if(Array.isArray(t.variants)){const e=t.variants,s=e.find(i=>i.rule?.__resolveType?.includes("always"));if(typeof s?.value=="string")return s.value;const n=e.find(i=>typeof i.value=="string");if(n)return n.value}if(typeof t.src=="string")return t.src;if(typeof t.url=="string")return t.url;if(typeof t.value=="string")return t.value}function H4(t){if(typeof t=="string"||t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(H4);const e=t;return e.__resolveType?qD(e)??t:W4(e)}function W4(t){const e={};for(const[s,n]of Object.entries(t))e[s]=H4(n);return e}function GD(t,e){return e.split(".").reduce((s,n)=>{if(!(s==null||typeof s!="object"))return s[n]},t)}function q4(t){return t==null?"":Array.isArray(t)?t.map(q4).filter(Boolean).join(","):typeof t=="object"?"":String(t)}function Au(t,e){if(!t.includes("{"))return;const s=W4(e);return t.replace(/\{\{\{([^}]+)\}\}\}|\{\{([^}]+)\}\}/g,(i,o,a)=>{const l=(o??a??"").trim();return q4(GD(s,l))}).trim()||void 0}function YD(t){return t.replace(/<[^>]*>/g,"").trim()}function JD(t,e){if(e.includes("{"))return Au(e,t);const s=t[e];if(typeof s=="string"&&s)return s;if(Array.isArray(s)){const n=s.map(i=>i==null?"":String(i)).filter(Boolean).join(",");if(n)return n}}function Si(t,e,s){if(typeof t=="string")return t.trim()?t:`Item ${e+1}`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t&&typeof t=="object"&&!Array.isArray(t)){let n=xo(t);const i=U4(n);if(i&&(n=i),s?.titleBy){const a=JD(n,s.titleBy);if(a)return a}for(const a of["name","label","title","alt","text","href","id","key"]){const l=n[a];if(typeof l=="string"&&l.trim()){const c=s?.properties?.[a]?.format;if(c==="rich-text"||c==="html"){const d=YD(l);if(d)return d;continue}return l}if(Array.isArray(l)){const c=l.map(d=>d==null?"":String(d)).filter(Boolean).join(",");if(c)return c}}const o=n.__resolveType;if(typeof o=="string"&&o)return At(o);if(s?.title){const a=Au(s.title,n);if(a)return a;if(!s.title.includes("{"))return s.title}}return`Item ${e+1}`}function XD(t){if(!t)return;if(typeof t.image=="string"&&t.image.includes("{"))return t.image;const e=t.properties?.image;if(!e)return;if(e.format==="image-uri")return"{{{image}}}";const s=e.properties;return s?.mobile?"{{{image.mobile}}}":s?.desktop?"{{{image.desktop}}}":"{{{image}}}"}function Qf(t,e){if(!t||typeof t!="object"||Array.isArray(t))return;const s=XD(e);if(!s)return;const n=Au(s,t);if(!n)return;const i=Tu(n)||n;return WD(i)}function G4(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").replace(/^\w/,e=>e.toUpperCase())}function $i(t){return t.normalize("NFC").trim()}function Wt(t,e){return $i(t)===$i(e)}function Zf(t,e){return $i(t).replace(/\s+/g,"").toLowerCase()===$i(e).replace(/\s+/g,"").toLowerCase()}function QD(t,e,s){return(s?.hasSiblingDrillDownFields??!1)||Wt(e,t)||s?.arrayKey!=null&&Wt(e,s.arrayKey)}function Ba(t,e,s,n){const i=$i(s);if(t.some(a=>Wt(a,i)||Wt(a,s)))return t;const o=[...t];return QD(e,s,n)&&!o.some(a=>Wt(a,e))&&o.push(e),o.push(s),o}function ZD(t,e){return t.slice(0,t.length-e.length)}function eI(t,e,s){if(s.length===0)return s;const n=Eo(t,e),i=s[0];return Wt(i,n)||Wt(i,t)?s.slice(1):s}function Eo(t,e){return e.title??G4(t)}function Xq(t,e){return e.isMultivariateSectionTop?0:t-2}function Qq(t,e){return e<=0?[]:t.slice(0,e)}function e1(t,e){const s=$i(e);return t.findIndex(n=>$i(n)===s)}function l0(t,e){return t.type==="array"&&t.items||Vc(t)?!0:Array.isArray(e)}function tI(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Xo(t,e,s,n){if(n.length===0)return null;const i=n[0];for(const a of t){const l=e[a];if(!l||!l0(l,s[a]))continue;const c=Eo(a,l);if(Wt(i,c)||Wt(i,a)||n.some(d=>Wt(d,c)||Wt(d,a)))return a}for(const a of t){const l=e[a];if(!l||!l0(l,s[a]))continue;const c=s[a];if(!Array.isArray(c))continue;const d=l.items;for(let h=0;h<c.length;h++){const u=Si(c[h],h,d);if(Wt(u,i))return a}}for(const a of t){const l=e[a];if(l?.type!=="object"||!l.properties)continue;const c=Object.keys(l.properties),d=tI(s[a]),h=Eo(a,l);if(Xo(c,l.properties,d,n)||(Wt(i,h)||Wt(i,a))&&Xo(c,l.properties,d,n.slice(1)))return a}let o=null;for(const a of t){const l=e[a];if(l?.type!=="block-ref")continue;const c=Eo(a,l);if(!(i!==c&&i!==a)){if(n.length>1){const d=s[a];if(d&&typeof d=="object"&&!Array.isArray(d)){const h=n[1];if(Object.keys(d).some(f=>!f.startsWith("__")&&(Zf(G4(f),h)||Zf(f,h))))return a}}o||(o=a)}}return o||null}function sI(t,e,s,n){return Xo(t,e,s,n)}function nI(t,e,s,n,i){if(i.length===0||!s.properties)return!1;const o=Object.keys(s.properties);if(Xo(o,s.properties,n,i))return!0;const a=i[0];return!Wt(a,e)&&!Wt(a,t)?!1:i.length>1||Xo(o,s.properties,n,i.slice(1))!==null}function t1(t,e,s,n){return n!=null&&n>=0&&n<t.length&&Wt(Si(t[n],n,e),s)?n:t.findIndex((i,o)=>Wt(Si(i,o,e),s))}function iI(t,e,s,n,i){if(e.length===0)return null;for(let a=0;a<e.length;a++){const l=e[a],c=t1(s,n,l,i);if(c>=0)return{index:c,innerPath:e.slice(a+1)}}const o=e.findIndex(a=>Wt(a,t));if(o>=0&&e.length>o+1){const a=e[o+1],l=t1(s,n,a,i);if(l>=0)return{index:l,innerPath:e.slice(o+2)}}return null}function dd(t){return t.includes("/sections/")||t.includes("multivariate/section")||t===Or}function rI(t){if(t.type==="block-ref"&&t.anyOfRefs?.length)return t.anyOfRefs.some(s=>dd(s.resolveType));if(t.anyOfRefs?.length)return t.anyOfRefs.some(s=>dd(s.resolveType));const e=t.properties?.__resolveType;return e?.type==="block-ref"&&e.anyOfRefs?.length?e.anyOfRefs.some(s=>dd(s.resolveType)):!1}function oI(t,e){if(e==="global"||e==="sections"||Vc(t))return!0;const s=t.type==="array"?t.items:void 0;return s?rI(s):!1}function s1(t){return Array.from({length:t},(e,s)=>({id:crypto.randomUUID(),index:s}))}function Y4(t){return t.map((e,s)=>({...e,index:s}))}function aI(t,e){if(e===t.length)return t;if(e<t.length)return Y4(t.slice(0,e));const s=Array.from({length:e-t.length},(n,i)=>({id:crypto.randomUUID(),index:t.length+i}));return[...t,...s]}function lI(t,e){const s=t.findIndex(o=>o.index===e),n=t.map(o=>o.index>e?{...o,index:o.index+1}:o),i={id:crypto.randomUUID(),index:e+1};return s===-1?[...n,i]:[...n.slice(0,s+1),i,...n.slice(s+1)]}function cI(t,e){return t.filter(s=>s.index!==e).map(s=>s.index>e?{...s,index:s.index-1}:s)}function dI(t){const e=F.c(8),{labelText:s,imageSrc:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ca,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n&&r.jsx("img",{src:n,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==s?(a=r.jsx("span",{className:"min-w-0 truncate",children:s}),e[3]=s,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=r.jsxs(r.Fragment,{children:[i,r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-sm",children:[o,a]})]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function uI(t){const e=F.c(50),{sortableId:s,labelText:n,imageSrc:i,hidden:o,onToggleHidden:a,onOpen:l,onDuplicate:c,onRemove:d}=t;let h;e[0]!==s?(h={id:s,animateLayoutChanges:pI},e[0]=s,e[1]=h):h=e[1];const{attributes:u,listeners:f,setNodeRef:m,transform:p,isDragging:g}=hu(h);let x;e[2]!==p?(x=Sn.Transform.toString(p?{...p,x:0}:null),e[2]=p,e[3]=x):x=e[3];const v=g?0:void 0;let b;e[4]!==x||e[5]!==v?(b={transform:x,opacity:v},e[4]=x,e[5]=v,e[6]=b):b=e[6];const _=b;let y;e[7]!==l?(y=z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),l())},e[7]=l,e[8]=y):y=e[8];const L=g?"cursor-grabbing":"cursor-pointer";let w;e[9]!==L?(w=ie("group flex min-w-0 items-center gap-2.5 rounded-lg px-2 py-2.5 hover:bg-accent hover:text-accent-foreground touch-none",L),e[9]=L,e[10]=w):w=e[10];let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ca,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[11]=j):j=e[11];let S;e[12]!==i?(S=i&&r.jsx("img",{src:i,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[12]=i,e[13]=S):S=e[13];const k=o&&"line-through opacity-50";let C;e[14]!==k?(C=ie("min-w-0 flex-1 truncate text-sm",k),e[14]=k,e[15]=C):C=e[15];let A;e[16]!==n||e[17]!==C?(A=r.jsx("span",{className:C,children:n}),e[16]=n,e[17]=C,e[18]=A):A=e[18];let P;e[19]!==o||e[20]!==a?(P=a&&r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":o?"Show item":"Hide item",className:ie("size-6 shrink-0",o?"opacity-100":"opacity-0 transition-opacity group-hover:opacity-100"),onClick:z=>{z.stopPropagation(),a()},onPointerDown:mI,children:o?r.jsx(rb,{size:14}):r.jsx(T9,{size:14})})}),r.jsx(He,{side:"bottom",children:o?"Show item":"Hide item"})]}),e[19]=o,e[20]=a,e[21]=P):P=e[21];const V=`Open actions for ${n}`;let T;e[22]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Ki,{size:14}),e[22]=T):T=e[22];let R;e[23]!==V?(R=r.jsx(bs,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":V,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:fI,onPointerDown:hI,children:T})}),e[23]=V,e[24]=R):R=e[24];let E;e[25]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(Vs,{size:14}),e[25]=E):E=e[25];let I;e[26]!==c?(I=r.jsxs(Je,{onClick:c,children:[E,"Duplicate"]}),e[26]=c,e[27]=I):I=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(_s,{size:14}),e[28]=D):D=e[28];let M;e[29]!==d?(M=r.jsxs(Je,{className:"text-destructive focus:text-destructive",onClick:d,children:[D,"Delete"]}),e[29]=d,e[30]=M):M=e[30];let O;e[31]!==I||e[32]!==M?(O=r.jsxs(ys,{align:"end",children:[I,M]}),e[31]=I,e[32]=M,e[33]=O):O=e[33];let $;e[34]!==R||e[35]!==O?($=r.jsxs(vs,{children:[R,O]}),e[34]=R,e[35]=O,e[36]=$):$=e[36];let B;return e[37]!==u||e[38]!==n||e[39]!==f||e[40]!==l||e[41]!==m||e[42]!==_||e[43]!==A||e[44]!==P||e[45]!==$||e[46]!==y||e[47]!==w||e[48]!==S?(B=r.jsxs("div",{ref:m,style:_,...u,...f,role:"button",tabIndex:0,onClick:l,onKeyDown:y,className:w,title:n,children:[j,S,A,P,$]}),e[37]=u,e[38]=n,e[39]=f,e[40]=l,e[41]=m,e[42]=_,e[43]=A,e[44]=P,e[45]=$,e[46]=y,e[47]=w,e[48]=S,e[49]=B):B=e[49],B}function hI(t){return t.stopPropagation()}function fI(t){return t.stopPropagation()}function mI(t){return t.stopPropagation()}function pI(){return!1}function gI(t,e,s,n,i){if(e?.type==="object"&&e.properties&&Object.keys(e.properties).length>0||e?.type==="block-ref"&&e.anyOfRefs?.length)return e;if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const o=t.__resolveType;if(typeof o=="string"&&s){const a=Ln(o,s);if(a?.properties&&Object.keys(a.properties).length>0)return a}}if(s&&n&&i){const a=Ln(n,s)?.properties?.[i]?.items;if(a?.properties&&Object.keys(a.properties).length>0)return{...a,titleBy:a.titleBy??e?.titleBy}}return e}function xI(t){const e=t.split(".").filter(s=>!/^\d+$/.test(s));return e[e.length-1]??t}function Fa(t){const e=F.c(27),{schema:s,value:n,onChange:i,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,hasSiblingDrillDownFields:d,meta:h,decofile:u,onSaveReferencedBlock:f,containerResolveType:m,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}=t,b=l===void 0?[]:l,_=oe(),y=Array.isArray(n)?n:[],L=s.items,w=xI(o),j={arrayKey:w,hasSiblingDrillDownFields:d},S=oI(s,w),k=!S&&L?.type==="object",[C,A]=N.useState(null),P=iI(a,b,y,L,C),V=P?.index??null;P===null?C!==null&&A(null):P.index!==C&&A(P.index);const[T,R]=N.useState(()=>s1(y.length)),[E,I]=N.useState(null),[D,M]=N.useState(o),[O,$]=N.useState(y.length),B=N.useRef(!1);D!==o?(M(o),$(y.length),R(s1(y.length)),A(null)):O!==y.length&&($(y.length),R(ye=>aI(ye,y.length)));let z;e[0]!==L?(z=(ye,Ce)=>Si(xo(ye),Ce,L),e[0]=L,e[1]=z):z=e[1];const K=z,Y=ye=>{if(B.current)return;const Ce=K(y[ye],ye);A(ye),c?.(Ba(b,a,Ce,j))},Q=ye=>{const Ce=[...y,ye];i(Ce);const Me=Ce.length-1;A(Me);const Re=Si(ye,Me,L);c?.(Ba(b,a,Re,j))},q=()=>{const ye=L?.type,Ce=L?.default!==void 0?L.default:ye==="object"?{}:ye==="block-ref"?(()=>{const $e=L?.anyOfRefs?.[0]?.resolveType;return typeof $e!="string"||jo($e)?{}:{__resolveType:$e}})():ye==="number"||ye==="integer"?0:ye==="boolean"?!1:ye==="array"?[]:"",Me=[...y,Ce];i(Me);const Re=Me.length-1;A(Re);const ke=Si(Ce,Re,L);c?.(Ba(b,a,ke,j))},H=()=>{if(S){if(!p){ve.error(_("sectionsEditor.arrayField.startPreviewServer"));return}if(x){x({append:Q});return}ve.error(_("sectionsEditor.arrayField.sectionPickerNotAvailable"));return}q()},U=ye=>{const Ce=y[ye],Me=typeof structuredClone=="function"?structuredClone(Ce):JSON.parse(JSON.stringify(Ce??null)),Re=[...y.slice(0,ye+1),Me,...y.slice(ye+1)];i(Re),R(ke=>lI(ke,ye))},X=ye=>{const Ce=y[ye],Me=[...y];Me[ye]=Ao(Ce)?K4(Ce):Jf(Ce),i(Me)},J=ye=>{i(y.filter((Ce,Me)=>Me!==ye)),R(Ce=>cI(Ce,ye))},ee=(ye,Ce)=>{const Me=[...y];if(Me[ye]=Ao(y[ye])?Jf(Ce):Ce,i(Me),ye===V&&V!==null){const Re=K(y[ye],ye),ke=Si(Ce,ye,L);if(Re!==ke){const $e=e1(b,Re);if($e>=0){const qe=[...b];qe[$e]=ke,c?.(qe)}}}};let W;e[2]===Symbol.for("react.memo_cache_sentinel")?(W={activationConstraint:{distance:8}},e[2]=W):W=e[2];let Z;e[3]===Symbol.for("react.memo_cache_sentinel")?(Z={coordinateGetter:fu},e[3]=Z):Z=e[3];const G=bc(li(Kr,W),li(zr,Z)),te=T.map(vI);let se;e[4]===Symbol.for("react.memo_cache_sentinel")?(se=ye=>{I(String(ye.active.id))},e[4]=se):se=e[4];const re=se,de=ye=>{I(null);const{active:Ce,over:Me}=ye;if(!Me||Ce.id===Me.id)return;const Re=te.indexOf(String(Ce.id)),ke=te.indexOf(String(Me.id));Re===-1||ke===-1||(R($e=>Y4(wr([...$e],Re,ke))),i(wr([...y],Re,ke)),B.current=!0,requestAnimationFrame(()=>{B.current=!1}))};let ce;e[5]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{I(null)},e[5]=ce):ce=e[5];const fe=ce,ue=E?T.find(ye=>ye.id===E):null,ae=ue!=null?y[ue.index]:void 0,me=ue!=null&&ae!==void 0?K(ae,ue.index):null,xe=ue!=null&&ae!==void 0?Qf(xo(ae),L):void 0;if(V!==null&&V<y.length){const ye=xo(y[V]),Ce=gI(ye,L,h,m,w),Me=()=>{const Re=K(ye,V),ke=Ba(b,a,Re,j),$e=e1(ke,Re);return $e>=0?ke.slice(0,$e+1):ke};return r.jsx("div",{className:"min-w-0",children:Ce?.type==="object"&&Ce.properties?r.jsx(Bn,{schema:Ce,value:ye,onChange:Re=>ee(V,Re),basePath:`${o}.${V}`,breadcrumbPath:P?.innerPath??[],onBreadcrumbChange:Re=>{c?.([...Me(),...Re])},meta:h,decofile:u,onSaveReferencedBlock:f,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}):Ce?Qo({schema:Ce,value:ye,onChange:Re=>ee(V,Re),path:`${o}.${V}`,label:Ce.title&&!Ce.title.includes("{{")?Ce.title:K(ye,V),breadcrumbPath:P?.innerPath??[],onBreadcrumbChange:Re=>{c?.([...Me(),...Re])},meta:h,decofile:u,onSaveReferencedBlock:f,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}):null})}const Se="space-y-2";let Ve;e[6]!==a?(Ve=r.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[6]=a,e[7]=Ve):Ve=e[7];const Ie=y.length>0&&r.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:y.length});let Ne;e[8]!==Ve||e[9]!==Ie?(Ne=r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[Ve,Ie]}),e[8]=Ve,e[9]=Ie,e[10]=Ne):Ne=e[10];let Ee;e[11]!==s.description?(Ee=s.description&&r.jsx("p",{className:"break-words text-xs leading-normal text-muted-foreground",children:s.description}),e[11]=s.description,e[12]=Ee):Ee=e[12];let we;e[13]!==Ne||e[14]!==Ee?(we=r.jsxs("div",{className:"min-w-0 space-y-0.5",children:[Ne,Ee]}),e[13]=Ne,e[14]=Ee,e[15]=we):we=e[15];const Ae=y.length>0&&r.jsx("div",{className:ie(E&&"cursor-grabbing"),children:r.jsxs(Sc,{sensors:G,collisionDetection:su,onDragStart:re,onDragEnd:de,onDragCancel:fe,children:[r.jsx(uu,{items:te,strategy:du,children:r.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/50 p-1.5",children:T.map(ye=>{const Ce=y[ye.index];if(Ce===void 0)return null;const Me=K(Ce,ye.index),Re=Qf(xo(Ce),L);return r.jsx(uI,{sortableId:ye.id,labelText:Me,imageSrc:Re,hidden:Ao(Ce),onToggleHidden:k?()=>X(ye.index):void 0,onOpen:()=>Y(ye.index),onDuplicate:()=>U(ye.index),onRemove:()=>J(ye.index)},ye.id)})})}),Zs.createPortal(r.jsx(ou,{dropAnimation:F4,children:me?r.jsx("div",{className:"flex min-w-0 items-center gap-2.5 rounded-lg border border-border/60 bg-background px-2 py-2.5 shadow-lg ring-1 ring-border/60",children:r.jsx(dI,{labelText:me,imageSrc:xe})}):null}),document.body)]})});let be;e[16]===Symbol.for("react.memo_cache_sentinel")?(be=r.jsx(_t,{size:14}),e[16]=be):be=e[16];let je;e[17]!==_||e[18]!==S?(je=_(S?"sectionsEditor.arrayField.addSection":"sectionsEditor.arrayField.addItem"),e[17]=_,e[18]=S,e[19]=je):je=e[19];let ge;e[20]!==H||e[21]!==je?(ge=r.jsxs("button",{type:"button",onClick:H,className:"flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-border/60 py-2.5 text-sm text-muted-foreground transition-colors hover:border-border hover:bg-muted/30",children:[be,je]}),e[20]=H,e[21]=je,e[22]=ge):ge=e[22];let Le;return e[23]!==we||e[24]!==Ae||e[25]!==ge?(Le=r.jsxs("div",{className:Se,children:[we,Ae,ge]}),e[23]=we,e[24]=Ae,e[25]=ge,e[26]=Le):Le=e[26],Le}function vI(t){return t.id}function bI(t){const e=F.c(44),{schema:s,value:n,onChange:i,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g}=t;let x;e[0]!==l?(x=l===void 0?[]:l,e[0]=l,e[1]=x):x=e[1];const v=x,[b,_]=N.useState(!1);let y;e[2]!==n?(y=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},e[2]=n,e[3]=y):y=e[3];const L=y;if(!s.properties)return null;let w;e[4]!==o?(w=o.split(".").pop()??o,e[4]=o,e[5]=w):w=e[5];const j=w;let S;e[6]!==v||e[7]!==j||e[8]!==a||e[9]!==L||e[10]!==s?(S=nI(j,a,s,L,v),e[6]=v,e[7]=j,e[8]=a,e[9]=L,e[10]=s,e[11]=S):S=e[11];const C=b||S,A=`${o}-fields`;let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=()=>_(yI),e[12]=P):P=e[12];let V;e[13]!==C?(V=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors group-hover:text-accent-foreground",children:C?r.jsx(is,{size:16}):r.jsx(yn,{size:16})}),e[13]=C,e[14]=V):V=e[14];let T;e[15]!==a?(T=r.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[15]=a,e[16]=T):T=e[16];let R;e[17]!==A||e[18]!==C||e[19]!==V||e[20]!==T?(R=r.jsxs("button",{type:"button","aria-expanded":C,"aria-controls":A,onClick:P,className:"group flex w-full min-w-0 items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",children:[V,T]}),e[17]=A,e[18]=C,e[19]=V,e[20]=T,e[21]=R):R=e[21];let E;e[22]!==s.description?(E=s.description&&r.jsx("p",{className:"break-words pl-9 text-xs leading-normal text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=E):E=e[23];let I;e[24]!==v||e[25]!==A||e[26]!==h||e[27]!==C||e[28]!==d||e[29]!==L||e[30]!==m||e[31]!==c||e[32]!==i||e[33]!==p||e[34]!==u||e[35]!==o||e[36]!==f||e[37]!==g||e[38]!==s?(I=C&&r.jsx("div",{id:A,className:"ml-3 min-w-0 max-w-full overflow-hidden border-l border-border/80 pl-5",children:r.jsx(Bn,{schema:s,value:L,onChange:i,basePath:o,breadcrumbPath:v,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g})}),e[24]=v,e[25]=A,e[26]=h,e[27]=C,e[28]=d,e[29]=L,e[30]=m,e[31]=c,e[32]=i,e[33]=p,e[34]=u,e[35]=o,e[36]=f,e[37]=g,e[38]=s,e[39]=I):I=e[39];let D;return e[40]!==E||e[41]!==I||e[42]!==R?(D=r.jsxs("div",{className:"min-w-0 space-y-2",children:[R,E,I]}),e[40]=E,e[41]=I,e[42]=R,e[43]=D):D=e[43],D}function yI(t){return!t}function Zq(t,e,s,n,i){const o={...t[e]};if(i.length>1){const a=o.sections,l=[...a?.variants??[]];l[n]&&(l[n]={...l[n],value:s}),o.sections={...a,variants:l}}else o.sections=s;return o}function eG(t){return structuredClone(t)}function tG(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function J4(t){const e=t.replace(/[^A-Za-z0-9_ -]/g,"").replace(/\s+/g," ").trim();return/^[A-Za-z]/.test(e)?e:e?`Block ${e}`:""}function Eu(t,e){const s=t.trim();return s?s.includes("/")?"Block name cannot contain slashes.":Object.hasOwn(e,s)?"A block with this name already exists.":/^[A-Za-z][A-Za-z0-9_ -]*$/.test(s)?null:"Use letters, numbers, spaces, hyphens, or underscores. Must start with a letter.":"Block name is required."}function Pu(t){const e=F.c(61),{open:s,onOpenChange:n,defaultBlockId:i,isPending:o,onSubmit:a}=t,l=i===void 0?"":i,c=o===void 0?!1:o,[d,h]=N.useState(l),[u,f]=N.useState(s);s!==u&&(f(s),s&&h(l));let m;e[0]!==c||e[1]!==n?(m=B=>{!B&&!c&&n(!1)},e[0]=c,e[1]=n,e[2]=m):m=e[2];const p=m;let g;e[3]!==d||e[4]!==c||e[5]!==a?(g=async B=>{B.preventDefault();const z=d.trim();!z||c||await a(z)},e[3]=d,e[4]=c,e[5]=a,e[6]=g):g=e[6];const x=g,v=oe();let b;e[7]!==v?(b=v("sectionsEditor.makeReusableModal.title"),e[7]=v,e[8]=b):b=e[8];let _;e[9]!==b?(_=r.jsx(ds,{children:b}),e[9]=b,e[10]=_):_=e[10];let y;e[11]!==v?(y=v("sectionsEditor.makeReusableModal.description"),e[11]=v,e[12]=y):y=e[12];let L;e[13]!==y?(L=r.jsx(On,{children:y}),e[13]=y,e[14]=L):L=e[14];let w;e[15]!==_||e[16]!==L?(w=r.jsxs(cs,{children:[_,L]}),e[15]=_,e[16]=L,e[17]=w):w=e[17];let j;e[18]!==v?(j=v("sectionsEditor.makeReusableModal.blockNameLabel"),e[18]=v,e[19]=j):j=e[19];let S;e[20]!==j?(S=r.jsx("label",{htmlFor:"block-id",className:"text-sm font-medium",children:j}),e[20]=j,e[21]=S):S=e[21];let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=B=>h(B.target.value),e[22]=k):k=e[22];let C;e[23]!==v?(C=v("sectionsEditor.makeReusableModal.blockNamePlaceholder"),e[23]=v,e[24]=C):C=e[24];let A;e[25]!==d||e[26]!==c||e[27]!==C?(A=r.jsx(et,{id:"block-id",value:d,onChange:k,placeholder:C,autoFocus:!0,disabled:c}),e[25]=d,e[26]=c,e[27]=C,e[28]=A):A=e[28];let P;e[29]!==S||e[30]!==A?(P=r.jsxs("div",{className:"py-4 space-y-2",children:[S,A]}),e[29]=S,e[30]=A,e[31]=P):P=e[31];let V;e[32]!==n?(V=()=>n(!1),e[32]=n,e[33]=V):V=e[33];let T;e[34]!==v?(T=v("sectionsEditor.makeReusableModal.cancel"),e[34]=v,e[35]=T):T=e[35];let R;e[36]!==c||e[37]!==V||e[38]!==T?(R=r.jsx(le,{type:"button",variant:"outline",onClick:V,disabled:c,children:T}),e[36]=c,e[37]=V,e[38]=T,e[39]=R):R=e[39];let E;e[40]!==d||e[41]!==c?(E=!d.trim()||c,e[40]=d,e[41]=c,e[42]=E):E=e[42];let I;e[43]!==c||e[44]!==v?(I=c?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{size:14,className:"animate-spin"}),v("sectionsEditor.makeReusableModal.saving")]}):v("sectionsEditor.makeReusableModal.save"),e[43]=c,e[44]=v,e[45]=I):I=e[45];let D;e[46]!==E||e[47]!==I?(D=r.jsx(le,{type:"submit",disabled:E,children:I}),e[46]=E,e[47]=I,e[48]=D):D=e[48];let M;e[49]!==R||e[50]!==D?(M=r.jsxs(mi,{children:[R,D]}),e[49]=R,e[50]=D,e[51]=M):M=e[51];let O;e[52]!==x||e[53]!==P||e[54]!==M||e[55]!==w?(O=r.jsx(Yt,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:x,children:[w,P,M]})}),e[52]=x,e[53]=P,e[54]=M,e[55]=w,e[56]=O):O=e[56];let $;return e[57]!==p||e[58]!==s||e[59]!==O?($=r.jsx(Jt,{open:s,onOpenChange:p,children:O}),e[57]=p,e[58]=s,e[59]=O,e[60]=$):$=e[60],$}function X4(t){return t===Or||t===Gi}function Ac(t,e){if(!Object.hasOwn(e,t))return null;const s=e[t]??{},n=s.__resolveType??t;return{data:{...s},resolveType:n}}function Fl(t,e){const s=t.__resolveType??"";if(!s)return null;if(fs(s)){const n=t.section??{};return Q4(n,e)}if(X4(s)){const n=t.variants?.[0]?.value;return n?Fl(n,e):null}return!_n(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:Ac(s,e)}function Q4(t,e){const s=t.__resolveType??"";if(!s)return null;if(X4(s)){const n=t.variants?.[0]?.value;return n?Fl(n,e):null}return!_n(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:Ac(s,e)}function _I(t,e){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t.__resolveType;if(typeof n!="string"||!_n(n)||!Object.hasOwn(e,n))return null;const i=Ac(n,e);return i?{blockKey:n,...i}:null}function LI(t,e,s){if(e.isMultivariate)return null;if(e.isSavedBlock){const n=e.isLazy?t.section?.__resolveType??t.__resolveType:t.__resolveType;return Ac(n,s)}if(e.isHidden){const o=(fs(t.__resolveType)?t.section:t)?.variants?.[0]?.value??t;return Fl(o,s)}if(e.isLazy||fs(t.__resolveType)){const n=t.section??{};return Q4(n,s)}return Fl(t,s)}function SI(t){if(!t?.properties)return{};const e={};for(const[s,n]of Object.entries(t.properties))s.startsWith("__")||s==="@type"||(n.default!==void 0?e[s]=n.default:n.type==="boolean"?e[s]=!1:n.type==="string"?e[s]="":n.type==="number"||n.type==="integer"?e[s]=0:n.type==="object"&&(e[s]={}));return e}function wI(t){const e=F.c(13),{blockKey:s}=t,n=oe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(pi,{size:11}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sectionsEditor.anyOfField.global"),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==o?(a=r.jsx(Ue,{asChild:!0,children:r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[i,o]})}),e[3]=o,e[4]=a):a=e[4];let l;e[5]!==s||e[6]!==n?(l=n("sectionsEditor.anyOfField.globalLoaderTooltip",{blockKey:s}),e[5]=s,e[6]=n,e[7]=l):l=e[7];let c;e[8]!==l?(c=r.jsx(He,{side:"top",className:"max-w-[260px]",children:l}),e[8]=l,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==c?(d=r.jsxs(We,{children:[a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12],d}function jI(t){const e=F.c(36),{path:s,open:n,onOpenChange:i,title:o,nested:a,nestedBlockRef:l,globalBlockKey:c,onDetach:d,onMakeGlobal:h}=t,u=oe(),f=`${s}-loader-config`,m=l&&"ml-1";let p;e[0]!==m?(p=ie("rounded-lg border border-border/80 bg-muted/30",m),e[0]=m,e[1]=p):p=e[1];let g;e[2]!==i||e[3]!==n?(g=()=>i(!n),e[2]=i,e[3]=n,e[4]=g):g=e[4];let x;e[5]!==n?(x=r.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:n?r.jsx(is,{size:16}):r.jsx(yn,{size:16})}),e[5]=n,e[6]=x):x=e[6];let v;e[7]!==o?(v=r.jsx("span",{className:"truncate text-xs font-medium tracking-wide text-muted-foreground uppercase",children:o}),e[7]=o,e[8]=v):v=e[8];let b;e[9]!==c?(b=c&&r.jsx(wI,{blockKey:c}),e[9]=c,e[10]=b):b=e[10];let _;e[11]!==v||e[12]!==b?(_=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[v,b]}),e[11]=v,e[12]=b,e[13]=_):_=e[13];let y;e[14]!==f||e[15]!==n||e[16]!==g||e[17]!==x||e[18]!==_?(y=r.jsxs("button",{type:"button","aria-expanded":n,"aria-controls":f,onClick:g,className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg px-3 py-2.5 text-left",children:[x,_]}),e[14]=f,e[15]=n,e[16]=g,e[17]=x,e[18]=_,e[19]=y):y=e[19];let L;e[20]!==c||e[21]!==d||e[22]!==h||e[23]!==u?(L=(d||h)&&r.jsxs(vs,{children:[r.jsx(bs,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":u("sectionsEditor.anyOfField.loaderActions"),className:"h-7 w-7 shrink-0 text-muted-foreground",children:r.jsx(Ki,{size:16})})}),r.jsxs(ys,{align:"end",className:"w-48",children:[c&&d&&r.jsxs(Je,{onClick:d,children:[r.jsx(An,{className:"h-4 w-4"}),u("sectionsEditor.anyOfField.detach")]}),!c&&h&&r.jsxs(Je,{onClick:h,children:[r.jsx(pi,{className:"h-4 w-4"}),u("sectionsEditor.anyOfField.makeGlobal")]})]})]}),e[20]=c,e[21]=d,e[22]=h,e[23]=u,e[24]=L):L=e[24];let w;e[25]!==y||e[26]!==L?(w=r.jsxs("div",{className:"group flex w-full min-w-0 items-center gap-1 rounded-lg pr-2 transition-colors hover:bg-accent/50",children:[y,L]}),e[25]=y,e[26]=L,e[27]=w):w=e[27];let j;e[28]!==f||e[29]!==a||e[30]!==n?(j=n&&r.jsx("div",{id:f,className:"border-t border-border/60 px-4 pb-4 pt-3",children:r.jsx("div",{className:"border-l border-border/80 pl-4",children:a})}),e[28]=f,e[29]=a,e[30]=n,e[31]=j):j=e[31];let S;return e[32]!==w||e[33]!==j||e[34]!==p?(S=r.jsxs("div",{className:p,children:[w,j]}),e[32]=w,e[33]=j,e[34]=p,e[35]=S):S=e[35],S}function n1(t){const e=F.c(38),{schema:s,value:n,onChange:i,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}=t,m=oe(),p=(s.anyOfRefs??[]).filter(VI),g=h&&n?_I(n,h):null,x=g?.data??n,v=g?null:U4(x),b=v??x,_=zD(p,{savedBlockKey:g?.blockKey,editorValue:x}),y=_.length>0?KD(x,_,g?.blockKey):_[0]?.resolveType??"",w=s.type==="block-ref"&&_.some(kI);let j;e[0]!==a||e[1]!==o?(j=a??(o.includes(".")?o.split(".")[0]:o),e[0]=a,e[1]=o,e[2]=j):j=e[2];const S=j;let k;e[3]!==l?(k=l??[],e[3]=l,e[4]=k):k=e[4];const C=k,A=w&&C[0]===S,P=A?C.slice(1):C,V=A?U=>{c?.([S,...U])}:c,[T,R]=N.useState(y),[E,I]=N.useState(y);E!==y&&(I(y),R(y));const[D,M]=N.useState(()=>HD(x,g?.blockKey)),[O,$]=N.useState(!1);if(_.length>0){const U=T||y;let X;e[5]!==U?(X=Ne=>Ne.resolveType===U,e[5]=U,e[6]=X):X=e[6];const J=_.find(X),ee=Xf(x,d,J?.schema),W=UD(ee??J?.schema??null,s.discriminatorKey),Z=s.discriminatorKey,G=Ne=>{R(Ne);const Ee=_.find(Le=>Le.resolveType===Ne),we=Xf(x,d,Ee?.schema),Ae=new Set(Object.keys((we??Ee?.schema)?.properties??{})),be=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:{},je=Object.fromEntries(Object.entries(be).filter(Le=>{const[ye]=Le;return Ae.has(ye)})),ge={...SI(Ee?.schema),...je};if(Z){const Le=Ee?.discriminatorValue??Ne;i({...ge,[Z]:Le});return}if(jo(Ne)){i(ge);return}i({...ge,__resolveType:Ne})};let te;e[7]!==U||e[8]!==Z||e[9]!==i?(te=Ne=>{if(Z||!jo(U)||Ne===null||typeof Ne!="object"||Array.isArray(Ne)){i(Ne);return}const{__resolveType:Ee,...we}=Ne;i(we)},e[7]=U,e[8]=Z,e[9]=i,e[10]=te):te=e[10];const se=te,re=W?.properties?r.jsx(Bn,{schema:W,value:b,onChange:Ne=>{if(g&&u){u(g.blockKey,Ne);return}if(v){i({...x,section:Ne});return}se(Ne)},basePath:o,breadcrumbPath:P,onBreadcrumbChange:V,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}):null;let de;e[11]!==o?(de=o.includes("."),e[11]=o,e[12]=de):de=e[12];const ce=de,fe=g?()=>{const{name:Ne,...Ee}=g.data;i(Ee)}:void 0,ue=!g&&!v&&!!u&&w&&!jo(U)&&U.includes("/"),ae=b&&typeof b=="object"&&!Array.isArray(b)?b:{},me=Ne=>{if(!u)return;const Ee=Ne.trim(),we=h?Eu(Ee,h):null;if(we){ve.error(we);return}u(Ee,{...ae,__resolveType:U,name:Ee}),i({__resolveType:Ee}),$(!1),ve.success(m("sectionsEditor.anyOfField.globalBlockSaved",{name:Ee}))};let xe;e[13]!==a||e[14]!==o?(xe=r.jsx(st,{htmlFor:o,children:a}),e[13]=a,e[14]=o,e[15]=xe):xe=e[15];let Se;e[16]!==m?(Se=m("sectionsEditor.anyOfField.selectPlaceholder"),e[16]=m,e[17]=Se):Se=e[17];let Ve;e[18]!==Se?(Ve=r.jsx($t,{children:r.jsx(qt,{placeholder:Se})}),e[18]=Se,e[19]=Ve):Ve=e[19];let Ie;return e[20]!==s.description?(Ie=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[20]=s.description,e[21]=Ie):Ie=e[21],r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[xe,r.jsxs(Ft,{value:U||void 0,onValueChange:G,children:[Ve,r.jsx(Bt,{children:_.map(CI)})]}),Ie]}),re&&(w?r.jsx(jI,{path:o,open:D,onOpenChange:M,title:m(ce?"sectionsEditor.anyOfField.configuration":"sectionsEditor.anyOfField.loaderConfiguration"),nested:re,nestedBlockRef:ce,globalBlockKey:g?.blockKey,onDetach:fe,onMakeGlobal:ue?()=>$(!0):void 0}):re),ue&&r.jsx(Pu,{open:O,onOpenChange:$,defaultBlockId:J4(At(U)),onSubmit:me})]})}if(s.anyOfRefs&&s.anyOfRefs.length>0)return null;let B;e[22]!==a||e[23]!==o?(B=r.jsx(st,{htmlFor:o,children:a}),e[22]=a,e[23]=o,e[24]=B):B=e[24];const z=n!=null?String(n):"";let K;e[25]!==i?(K=U=>i(U.target.value),e[25]=i,e[26]=K):K=e[26];const Y=s.description??"";let Q;e[27]!==o||e[28]!==z||e[29]!==K||e[30]!==Y?(Q=r.jsx("input",{id:o,type:"text",value:z,onChange:K,className:"w-full rounded-md border bg-background px-3 py-1.5 text-sm",placeholder:Y}),e[27]=o,e[28]=z,e[29]=K,e[30]=Y,e[31]=Q):Q=e[31];let q;e[32]!==s.description?(q=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[32]=s.description,e[33]=q):q=e[33];let H;return e[34]!==B||e[35]!==Q||e[36]!==q?(H=r.jsxs("div",{className:"space-y-1.5",children:[B,Q,q]}),e[34]=B,e[35]=Q,e[36]=q,e[37]=H):H=e[37],H}function CI(t){const e=t.title&&!t.title.includes("/")?t.title:Hd(t.resolveType)??At(t.resolveType);return r.jsx(ut,{value:t.resolveType,children:e},t.resolveType)}function kI(t){return t.resolveType.includes("/")&&!jo(t.resolveType)}function VI(t){return t.resolveType!==""}const ud=(t,e)=>t.match(new RegExp(`\\b${e}\\s*=\\s*"([^"]*)"`,"i"))?.[1];function NI(t){const e={};if(typeof t!="string")return e;const s=/<symbol\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/symbol>/gi;for(const n of t.matchAll(s)){const i=n[1]??"",o=n[2]??"",a=ud(i,"id");if(!a)continue;const l=ud(i,"viewBox"),c=ud(i,"fill"),d=['xmlns="http://www.w3.org/2000/svg"',l?`viewBox="${l}"`:"",c?`fill="${c}"`:""].filter(Boolean).join(" ");e[a]=`<svg ${d}>${o}</svg>`}return e}async function TI(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch sprite sheet: ${e.status}`);return NI(await e.text())}function AI(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)if(typeof s=="string")e.push({value:s,label:s});else if(s&&typeof s=="object"&&"value"in s){const n=s;e.push({value:String(n.value),label:typeof n.label=="string"?n.label:String(n.value),image:typeof n.image=="string"?n.image:void 0,icon:typeof n.icon=="string"?n.icon:void 0})}return e}function EI(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)typeof s=="string"&&e.push({value:s,label:s});return e}function PI(t,e){return t.length>0?t:e}function RI(t,e){const s=e.trim().toLowerCase();return s?t.filter(n=>n.value.toLowerCase().includes(s)||(n.label??"").toLowerCase().includes(s)):t}function Z4(t,e){const n=`<style>${e?`svg{color:${e}}`:""}.fill-current{fill:currentColor}.stroke-current{stroke:currentColor}.text-current{color:currentColor}</style>`,i=t.replace(/(<svg[^>]*>)/i,`$1${n}`);return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function DI(){return getComputedStyle(document.documentElement).getPropertyValue("--foreground").trim()||void 0}function II(t,e){if(t.previewSrc)return t.previewSrc;if(t.image)return t.image;if(t.icon)return Z4(t.icon,e)}async function MI(t,e,s){const n={};s&&(n.term=s);const o=`${t.replace(/\/+$/,"")}/deco/invoke/${e}`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Failed to fetch dynamic options: ${a.status}`);const l=await a.json();return AI(l)}function i1(t){const e=F.c(9),{option:s,className:n,fg:i}=t;let o;e[0]!==i||e[1]!==s?(o=II(s,i),e[0]=i,e[1]=s,e[2]=o):o=e[2];const a=o;if(!a)return null;const l=s.image?"rounded object-cover":"object-contain";let c;e[3]!==n||e[4]!==l?(c=ie("shrink-0",l,n),e[3]=n,e[4]=l,e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==c?(d=r.jsx("img",{src:a,alt:"",referrerPolicy:"no-referrer",className:c}),e[6]=a,e[7]=c,e[8]=d):d=e[8],d}function r1(t){const e=F.c(8),{path:s,label:n,description:i}=t;let o;e[0]!==n||e[1]!==s?(o=r.jsx(st,{htmlFor:s,children:n}),e[0]=n,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==i?(a=i&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:i}),e[3]=i,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=r.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function OI(t){const e=F.c(79),{schema:s,value:n,onChange:i,path:o,label:a,sandbox:l}=t,c=oe(),d=s.options,h=l?.previewUrl,[u,f]=N.useState(!1),[m,p]=N.useState(""),[g,x]=N.useState(""),v=N.useRef(null);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=Ae=>{p(Ae),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{x(Ae)},300)},e[0]=b):b=e[0];const _=b,y=l?`${l.orgSlug}/${l.virtualMcpId}/${l.branch}`:"",L=typeof n=="string"?n:"",w=s.format==="icon-select";let j;e[1]!==g||e[2]!==d||e[3]!==y?(j=Qe.sandboxInvoke(y,`dynamic-options:${d??""}:${g}`),e[1]=g,e[2]=d,e[3]=y,e[4]=j):j=e[4];let S;e[5]!==g||e[6]!==d||e[7]!==h?(S=()=>MI(h,d,g||void 0),e[5]=g,e[6]=d,e[7]=h,e[8]=S):S=e[8];const k=!!h&&!!d&&(u||!!L);let C;e[9]!==j||e[10]!==S||e[11]!==k?(C={queryKey:j,queryFn:S,enabled:k,staleTime:6e4,retry:1},e[9]=j,e[10]=S,e[11]=k,e[12]=C):C=e[12];const A=Pt(C),P=A.data??[];let V;e[13]!==y?(V=Qe.sandboxSprite(y),e[13]=y,e[14]=V):V=e[14];let T;e[15]!==h||e[16]!==l?(T=()=>TI(Gp({orgSlug:l.orgSlug,virtualMcpId:l.virtualMcpId,branch:l.branch,previewUrl:h},"/sprites.svg")),e[15]=h,e[16]=l,e[17]=T):T=e[17];const R=w&&!!l&&(u||!!L)&&(!d||A.isFetched&&P.length===0);let E;e[18]!==V||e[19]!==T||e[20]!==R?(E={queryKey:V,queryFn:T,enabled:R,staleTime:3e5,retry:1},e[18]=V,e[19]=T,e[20]=R,e[21]=E):E=e[21];const I=Pt(E),D=EI(s.enum),M=I.data??{},O=DI(),$=Object.fromEntries(Object.entries(M).map(Ae=>{const[be,je]=Ae;return[be,Z4(je,O)]})),B=w&&Object.keys($).length>0?D.map(Ae=>({...Ae,previewSrc:$[Ae.value]})):D,z=PI(P,B),K=RI(z,m);let Y;e[22]!==L?(Y=Ae=>Ae.value===L,e[22]=L,e[23]=Y):Y=e[23];const Q=z.find(Y);if((!h||!d)&&D.length===0){let Ae;e[24]!==a||e[25]!==o||e[26]!==s.description?(Ae=r.jsx(r1,{path:o,label:a,description:s.description}),e[24]=a,e[25]=o,e[26]=s.description,e[27]=Ae):Ae=e[27];let be;e[28]!==i?(be=Le=>i(Le.target.value),e[28]=i,e[29]=be):be=e[29];let je;e[30]!==L||e[31]!==o||e[32]!==be?(je=r.jsx(et,{id:o,type:"text",value:L,onChange:be}),e[30]=L,e[31]=o,e[32]=be,e[33]=je):je=e[33];let ge;return e[34]!==Ae||e[35]!==je?(ge=r.jsxs("div",{className:"space-y-2",children:[Ae,je]}),e[34]=Ae,e[35]=je,e[36]=ge):ge=e[36],ge}const H="space-y-2";let U;e[37]!==a||e[38]!==o||e[39]!==s.description?(U=r.jsx(r1,{path:o,label:a,description:s.description}),e[37]=a,e[38]=o,e[39]=s.description,e[40]=U):U=e[40];const X=Es,J=Q?r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(i1,{option:Q,className:"h-6 w-6",fg:O}),r.jsx("span",{className:"truncate",children:Q.label??Q.value})]}):L?r.jsx("span",{className:"truncate",children:L}):r.jsx("span",{className:"text-muted-foreground",children:c("sectionsEditor.dynamicOptionsField.selectPlaceholder")});let ee;e[41]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx(k9,{className:"size-4 shrink-0 opacity-50"}),e[41]=ee):ee=e[41];let W;e[42]!==u||e[43]!==J?(W=r.jsx(Ts,{asChild:!0,children:r.jsxs(le,{variant:"outline",role:"combobox","aria-expanded":u,className:"h-10 w-full justify-between font-normal",children:[J,ee]})}),e[42]=u,e[43]=J,e[44]=W):W=e[44];const Z=As,G="p-0";let te;e[45]===Symbol.for("react.memo_cache_sentinel")?(te={width:"var(--radix-popover-trigger-width)"},e[45]=te):te=e[45];const se=Dr,re=!1;let de;e[46]!==c?(de=c("sectionsEditor.dynamicOptionsField.searchPlaceholder"),e[46]=c,e[47]=de):de=e[47];let ce;e[48]!==m||e[49]!==de?(ce=r.jsx(Hi,{placeholder:de,className:"h-9",value:m,onValueChange:_}),e[48]=m,e[49]=de,e[50]=ce):ce=e[50];const fe=Wi;let ue;e[51]!==A.isLoading||e[52]!==c?(ue=A.isLoading?c("sectionsEditor.dynamicOptionsField.loading"):c("sectionsEditor.dynamicOptionsField.noResults"),e[51]=A.isLoading,e[52]=c,e[53]=ue):ue=e[53];let ae;e[54]!==ue?(ae=r.jsx(oi,{children:ue}),e[54]=ue,e[55]=ae):ae=e[55];const me=Os,xe=K.map(Ae=>r.jsxs(ks,{value:Ae.value,onSelect:()=>{i(Ae.value===L?"":Ae.value),f(!1)},children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(i1,{option:Ae,className:ie(Ae.image?"h-9 w-9":"h-6 w-6"),fg:O}),r.jsx("span",{className:"truncate",children:Ae.label??Ae.value})]}),r.jsx(ns,{className:ie("ml-auto size-4 shrink-0",L===Ae.value?"opacity-100":"opacity-0")})]},Ae.value));let Se;e[56]!==me||e[57]!==xe?(Se=r.jsx(me,{children:xe}),e[56]=me,e[57]=xe,e[58]=Se):Se=e[58];let Ve;e[59]!==fe||e[60]!==ae||e[61]!==Se?(Ve=r.jsxs(fe,{children:[ae,Se]}),e[59]=fe,e[60]=ae,e[61]=Se,e[62]=Ve):Ve=e[62];let Ie;e[63]!==se||e[64]!==ce||e[65]!==Ve?(Ie=r.jsxs(se,{shouldFilter:re,children:[ce,Ve]}),e[63]=se,e[64]=ce,e[65]=Ve,e[66]=Ie):Ie=e[66];let Ne;e[67]!==Z||e[68]!==te||e[69]!==Ie?(Ne=r.jsx(Z,{className:G,style:te,children:Ie}),e[67]=Z,e[68]=te,e[69]=Ie,e[70]=Ne):Ne=e[70];let Ee;e[71]!==X||e[72]!==u||e[73]!==W||e[74]!==Ne?(Ee=r.jsxs(X,{open:u,onOpenChange:f,children:[W,Ne]}),e[71]=X,e[72]=u,e[73]=W,e[74]=Ne,e[75]=Ee):Ee=e[75];let we;return e[76]!==U||e[77]!==Ee?(we=r.jsxs("div",{className:H,children:[U,Ee]}),e[76]=U,e[77]=Ee,e[78]=we):we=e[78],we}function $I(t){const e=F.c(17),{org:s}=ze(),n=Fs();let i,o,a,l;e[0]!==s.id||e[1]!==t.configId||e[2]!==t.imageOnly||e[3]!==t.search?(o=t.search?.trim()||void 0,i=t.imageOnly??!1,l=tp,a=Qe.filePickerObjects(s.id,t.configId,o,i),e[0]=s.id,e[1]=t.configId,e[2]=t.imageOnly,e[3]=t.search,e[4]=i,e[5]=o,e[6]=a,e[7]=l):(i=e[4],o=e[5],a=e[6],l=e[7]);const c=t.enabled!==!1&&!!t.configId;let d;e[8]!==i||e[9]!==t.configId||e[10]!==o||e[11]!==n?(d=async u=>{const{pageParam:f}=u;return await n.call("FILE_OBJECTS_LIST",{configId:t.configId,cursor:f??void 0,search:o,imageOnly:i||void 0})},e[8]=i,e[9]=t.configId,e[10]=o,e[11]=n,e[12]=d):d=e[12];let h;return e[13]!==a||e[14]!==c||e[15]!==d?(h={queryKey:a,enabled:c,staleTime:3e4,initialPageParam:null,queryFn:d,getNextPageParam:BI},e[13]=a,e[14]=c,e[15]=d,e[16]=h):h=e[16],l(h)}function BI(t){return t.nextCursor??void 0}function Ru(){const t=F.c(2),{org:e}=ze();let s;return t[0]!==e?(s={mutationFn:async n=>{const i=n.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(n.configId)}/upload?filename=${encodeURIComponent(n.file.name)}`,{method:"POST",headers:{"Content-Type":i},body:n.file});if(!o.ok){const a=await o.text().catch(FI);let l=`${o.status} ${o.statusText}`;try{const c=JSON.parse(a);c.message&&(l=c.message)}catch{a&&(l=a.slice(0,200))}throw new Error(`Upload failed: ${l}`)}return await o.json()}},t[0]=e,t[1]=s):s=t[1],Ys(s)}function FI(){return""}const Ec="file-picker:last-config-id";function e5(t){const e=F.c(31),s=oe(),n=t.open,i=t.onOpenChange;let o;e[0]!==t.mode||e[1]!==s?(o=t.mode==="image"?s("filePicker.filePickerDialog.pickAnImage"):s("filePicker.filePickerDialog.pickAFile"),e[0]=t.mode,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==o?(a=r.jsx(ds,{children:o}),e[3]=o,e[4]=a):a=e[4];let l;e[5]!==s?(l=s("filePicker.filePickerDialog.description"),e[5]=s,e[6]=l):l=e[6];let c;e[7]!==l?(c=r.jsx(On,{children:l}),e[7]=l,e[8]=c):c=e[8];let d;e[9]!==a||e[10]!==c?(d=r.jsxs(cs,{children:[a,c]}),e[9]=a,e[10]=c,e[11]=d):d=e[11];let h;e[12]!==s?(h=v=>{const{error:b}=v;return r.jsx(zI,{error:b??new Error(s("filePicker.filePickerDialog.failedToLoadBuckets"))})},e[12]=s,e[13]=h):h=e[13];let u;e[14]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Et,{className:"h-64 w-full"}),e[14]=u):u=e[14];let f;e[15]!==t?(f=v=>{t.onSelect(v),t.onOpenChange(!1)},e[15]=t,e[16]=f):f=e[16];let m;e[17]!==t.lockedConfigId||e[18]!==t.mode||e[19]!==f?(m=r.jsx(N.Suspense,{fallback:u,children:r.jsx(KI,{mode:t.mode,lockedConfigId:t.lockedConfigId,onSelect:f})}),e[17]=t.lockedConfigId,e[18]=t.mode,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==m||e[22]!==h?(p=r.jsx(hs,{fallback:h,children:m}),e[21]=m,e[22]=h,e[23]=p):p=e[23];let g;e[24]!==p||e[25]!==d?(g=r.jsxs(Yt,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[d,p]}),e[24]=p,e[25]=d,e[26]=g):g=e[26];let x;return e[27]!==t.onOpenChange||e[28]!==t.open||e[29]!==g?(x=r.jsx(Jt,{open:n,onOpenChange:i,children:g}),e[27]=t.onOpenChange,e[28]=t.open,e[29]=g,e[30]=x):x=e[30],x}function zI(t){const e=F.c(3),{error:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(jn,{size:16}),e[0]=n):n=e[0];let i;return e[1]!==s.message?(i=r.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[n,r.jsx("span",{className:"text-sm font-medium",children:s.message})]}),e[1]=s.message,e[2]=i):i=e[2],i}function KI(t){const e=F.c(32),{mode:s,lockedConfigId:n,onSelect:i}=t,o=O8();if(o.length===0){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(WI,{}),e[0]=p):p=e[0],p}if(n){let p;if(e[1]!==o||e[2]!==n){let x;e[4]!==n?(x=v=>v.id===n,e[4]=n,e[5]=x):x=e[5],p=o.find(x),e[1]=o,e[2]=n,e[3]=p}else p=e[3];const g=p;if(g){let x;return e[6]!==g||e[7]!==s||e[8]!==i?(x=r.jsx(hd,{config:g,mode:s,onSelect:i}),e[6]=g,e[7]=s,e[8]=i,e[9]=x):x=e[9],x}}if(o.length===1){const p=o[0];let g;return e[10]!==p||e[11]!==s||e[12]!==i?(g=r.jsx(hd,{config:p,mode:s,onSelect:i}),e[10]=p,e[11]=s,e[12]=i,e[13]=g):g=e[13],g}let a;e[14]===Symbol.for("react.memo_cache_sentinel")?(a=typeof window<"u"?window.localStorage.getItem(Ec):null,e[14]=a):a=e[14];const l=a;let c;e[15]!==o?(c=o.find(p=>p.id===l)?.id??o[0].id,e[15]=o,e[16]=c):c=e[16];const d=c;let h;e[17]!==o?(h=o.map(UI),e[17]=o,e[18]=h):h=e[18];let u;e[19]!==h?(u=r.jsx(oa,{className:"self-start",children:h}),e[19]=h,e[20]=u):u=e[20];let f;if(e[21]!==o||e[22]!==s||e[23]!==i){let p;e[25]!==s||e[26]!==i?(p=g=>r.jsx(ji,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(hd,{config:g,mode:s,onSelect:i})},g.id),e[25]=s,e[26]=i,e[27]=p):p=e[27],f=o.map(p),e[21]=o,e[22]=s,e[23]=i,e[24]=f}else f=e[24];let m;return e[28]!==d||e[29]!==u||e[30]!==f?(m=r.jsxs(Er,{defaultValue:d,onValueChange:HI,className:"min-h-0 flex-1 flex flex-col",children:[u,f]}),e[28]=d,e[29]=u,e[30]=f,e[31]=m):m=e[31],m}function UI(t){return r.jsx(vn,{value:t.id,children:t.name},t.id)}function HI(t){typeof window<"u"&&window.localStorage.setItem(Ec,t)}function WI(){const t=F.c(22),{org:e}=ze(),s=oe();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:r.jsx(Ui,{size:20,className:"text-muted-foreground"})}),t[0]=n):n=t[0];let i;t[1]!==s?(i=s("filePicker.filePickerDialog.noBucketConfigured"),t[1]=s,t[2]=i):i=t[2];let o;t[3]!==i?(o=r.jsx("p",{className:"font-medium text-sm",children:i}),t[3]=i,t[4]=o):o=t[4];let a;t[5]!==s?(a=s("filePicker.filePickerDialog.noBucketDescription"),t[5]=s,t[6]=a):a=t[6];let l;t[7]!==a?(l=r.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:a}),t[7]=a,t[8]=l):l=t[8];let c;t[9]!==o||t[10]!==l?(c=r.jsxs("div",{children:[o,l]}),t[9]=o,t[10]=l,t[11]=c):c=t[11];let d;t[12]!==e.slug?(d={org:e.slug},t[12]=e.slug,t[13]=d):d=t[13];let h;t[14]!==s?(h=s("filePicker.filePickerDialog.configureABucket"),t[14]=s,t[15]=h):h=t[15];let u;t[16]!==d||t[17]!==h?(u=r.jsx(le,{asChild:!0,size:"sm",className:"mt-2",children:r.jsx(Rm,{to:"/$org/settings/files",params:d,children:h})}),t[16]=d,t[17]=h,t[18]=u):u=t[18];let f;return t[19]!==c||t[20]!==u?(f=r.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[n,c,u]}),t[19]=c,t[20]=u,t[21]=f):f=t[21],f}function hd({config:t,mode:e,onSelect:s}){const n=oe(),[i,o]=N.useState(""),a=M8(i,300),l=$I({configId:t.id,search:a,imageOnly:e==="image"}),c=Ru(),[d,h]=N.useState(!1),u=N.useRef(null),f=e==="image"?"image/*":void 0;async function m(j){if(!j)return;const S=Array.from(j);if(S.length===0)return;let k=null;const C=[];for(const A of S)try{const P=await c.mutateAsync({configId:t.id,file:A});k??=P.publicUrl}catch(P){C.push(`${A.name} (${P instanceof Error?P.message:"upload failed"})`)}await l.refetch(),C.length>0&&ve.error(C.length===S.length?n("filePicker.filePickerDialog.uploadFailedAll",{errors:C.join("; ")}):n("filePicker.filePickerDialog.uploadFailedSome",{errors:C.join("; ")})),k&&s(k)}function p(j){j.preventDefault(),h(!0)}function g(){h(!1)}function x(j){j.preventDefault(),h(!1),m(j.dataTransfer.files)}const b=(l.data?.pages??[]).flatMap(j=>j.items),_=b.filter(j=>e==="image"?t5(j.key):!0),y=a.trim(),L=b.length>0||i.trim().length>0,w=i!==a||l.isFetching&&!l.isFetchingNextPage;return r.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[r.jsxs("button",{type:"button",onClick:()=>u.current?.click(),onDragOver:p,onDragLeave:g,onDrop:x,className:ie("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",d&&"border-primary bg-primary/5",c.isPending&&"opacity-60 pointer-events-none"),children:[r.jsx(Ui,{size:18,className:"text-muted-foreground"}),r.jsx("p",{className:"text-sm font-medium",children:c.isPending?n("filePicker.filePickerDialog.uploading"):n("filePicker.filePickerDialog.dropFilesOrClick")}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[n("filePicker.filePickerDialog.uploadSizeLimit")," ",n(e==="image"?"filePicker.filePickerDialog.imagesOnlyTypes":"filePicker.filePickerDialog.commonMediaTypes")]}),r.jsx("input",{ref:u,type:"file",accept:f,multiple:!0,className:"hidden",onChange:j=>{const S=Array.from(j.target.files??[]);j.target.value="",m(S)}})]}),L?r.jsx(L9,{value:i,onChange:o,isSearching:w,placeholder:n(e==="image"?"filePicker.filePickerDialog.searchImagesPlaceholder":"filePicker.filePickerDialog.searchFilesPlaceholder"),className:"shrink-0"}):null,r.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[_.length===0?y?r.jsx(YI,{query:y}):e==="image"&&b.length>0?r.jsx(GI,{}):r.jsx(qI,{}):e==="image"?r.jsx(XI,{items:_,onSelect:s}):r.jsx(QI,{items:_,onSelect:s}),l.hasNextPage&&r.jsx("div",{className:"flex justify-center py-4",children:r.jsx(le,{type:"button",variant:"outline",size:"sm",disabled:l.isFetchingNextPage,onClick:()=>l.fetchNextPage(),children:l.isFetchingNextPage?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{size:14,className:"animate-spin"}),n("filePicker.filePickerDialog.loading")]}):n("filePicker.filePickerDialog.loadMore")})})]})]})}function qI(){const t=F.c(12),e=oe();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:r.jsx(Dn,{size:18,className:"text-muted-foreground"})}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("filePicker.filePickerDialog.noFilesYet"),t[1]=e,t[2]=n):n=t[2];let i;t[3]!==n?(i=r.jsx("p",{className:"text-sm font-medium",children:n}),t[3]=n,t[4]=i):i=t[4];let o;t[5]!==e?(o=e("filePicker.filePickerDialog.dropFileToGetStarted"),t[5]=e,t[6]=o):o=t[6];let a;t[7]!==o?(a=r.jsx("p",{className:"text-xs text-muted-foreground",children:o}),t[7]=o,t[8]=a):a=t[8];let l;return t[9]!==i||t[10]!==a?(l=r.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[s,i,a]}),t[9]=i,t[10]=a,t[11]=l):l=t[11],l}function GI(){const t=F.c(12),e=oe();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:r.jsx(Dn,{size:18,className:"text-muted-foreground"})}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("filePicker.filePickerDialog.noImagesYet"),t[1]=e,t[2]=n):n=t[2];let i;t[3]!==n?(i=r.jsx("p",{className:"text-sm font-medium",children:n}),t[3]=n,t[4]=i):i=t[4];let o;t[5]!==e?(o=e("filePicker.filePickerDialog.noImagesFormatDesc"),t[5]=e,t[6]=o):o=t[6];let a;t[7]!==o?(a=r.jsx("p",{className:"text-xs text-muted-foreground",children:o}),t[7]=o,t[8]=a):a=t[8];let l;return t[9]!==i||t[10]!==a?(l=r.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[s,i,a]}),t[9]=i,t[10]=a,t[11]=l):l=t[11],l}function YI(t){const e=F.c(13),{query:s}=t,n=oe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:r.jsx(Dn,{size:18,className:"text-muted-foreground"})}),e[0]=i):i=e[0];let o;e[1]!==s||e[2]!==n?(o=n("filePicker.filePickerDialog.noMatches",{query:s}),e[1]=s,e[2]=n,e[3]=o):o=e[3];let a;e[4]!==o?(a=r.jsx("p",{className:"text-sm font-medium",children:o}),e[4]=o,e[5]=a):a=e[5];let l;e[6]!==n?(l=n("filePicker.filePickerDialog.tryDifferentSearchOrLoadMore"),e[6]=n,e[7]=l):l=e[7];let c;e[8]!==l?(c=r.jsx("p",{className:"text-xs text-muted-foreground",children:l}),e[8]=l,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==c?(d=r.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[i,a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12],d}function t5(t){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(t)}function JI(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"file":t.slice(e+1).toLowerCase()}function XI(t){const e=F.c(7),{items:s,onSelect:n}=t;let i;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>r.jsx(s5,{item:l,variant:"image",onSelect:n},l.key),e[3]=n,e[4]=a):a=e[4],i=s.map(a),e[0]=s,e[1]=n,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=r.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:i}),e[5]=i,e[6]=o):o=e[6],o}function QI(t){const e=F.c(7),{items:s,onSelect:n}=t;let i;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>r.jsx("li",{children:r.jsx(s5,{item:l,variant:"row",onSelect:n})},l.key),e[3]=n,e[4]=a):a=e[4],i=s.map(a),e[0]=s,e[1]=n,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=r.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:i}),e[5]=i,e[6]=o):o=e[6],o}function s5(t){const e=F.c(58),{item:s,variant:n,onSelect:i}=t;let o;e[0]!==s.key?(o=JI(s.key),e[0]=s.key,e[1]=o):o=e[1];const a=o;if(n==="image"){let _;e[2]!==s.publicUrl||e[3]!==i?(_=()=>i(s.publicUrl),e[2]=s.publicUrl,e[3]=i,e[4]=_):_=e[4];let y;e[5]!==s.key||e[6]!==s.publicUrl?(y=r.jsx("img",{src:s.publicUrl,alt:s.key,loading:"lazy",className:"h-full w-full object-cover",onError:ZI}),e[5]=s.key,e[6]=s.publicUrl,e[7]=y):y=e[7];let L;e[8]!==s.key||e[9]!==_||e[10]!==y?(L=r.jsx("button",{type:"button",onClick:_,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:s.key,children:y}),e[8]=s.key,e[9]=_,e[10]=y,e[11]=L):L=e[11];let w;e[12]!==a?(w=r.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=w):w=e[13];let j;e[14]!==s||e[15]!==i?(j=r.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:r.jsx(o1,{item:s,onSelect:i})}),e[14]=s,e[15]=i,e[16]=j):j=e[16];let S;e[17]!==s.key?(S=a1(s.key),e[17]=s.key,e[18]=S):S=e[18];let k;e[19]!==S?(k=r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:r.jsx("p",{className:"truncate text-xs text-white",children:S})}),e[19]=S,e[20]=k):k=e[20];let C;return e[21]!==L||e[22]!==w||e[23]!==j||e[24]!==k?(C=r.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[L,w,j,k]}),e[21]=L,e[22]=w,e[23]=j,e[24]=k,e[25]=C):C=e[25],C}let l;e[26]!==s.publicUrl||e[27]!==i?(l=()=>i(s.publicUrl),e[26]=s.publicUrl,e[27]=i,e[28]=l):l=e[28];let c;e[29]!==s.key?(c=r.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:t5(s.key)?r.jsx(Dn,{size:16,className:"text-muted-foreground"}):r.jsx(Pi,{size:16,className:"text-muted-foreground"})}),e[29]=s.key,e[30]=c):c=e[30];let d;e[31]!==s.key?(d=a1(s.key),e[31]=s.key,e[32]=d):d=e[32];let h;e[33]!==d?(h=r.jsx("p",{className:"truncate text-sm font-medium",children:d}),e[33]=d,e[34]=h):h=e[34];let u;e[35]!==s.key?(u=r.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:s.key}),e[35]=s.key,e[36]=u):u=e[36];let f;e[37]!==h||e[38]!==u?(f=r.jsxs("div",{className:"min-w-0 flex-1",children:[h,u]}),e[37]=h,e[38]=u,e[39]=f):f=e[39];let m;e[40]!==a?(m=r.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=m):m=e[41];let p;e[42]!==s.size?(p=nM(s.size),e[42]=s.size,e[43]=p):p=e[43];let g;e[44]!==p?(g=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:p}),e[44]=p,e[45]=g):g=e[45];let x;e[46]!==g||e[47]!==l||e[48]!==c||e[49]!==f||e[50]!==m?(x=r.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[c,f,m,g]}),e[46]=g,e[47]=l,e[48]=c,e[49]=f,e[50]=m,e[51]=x):x=e[51];let v;e[52]!==s||e[53]!==i?(v=r.jsx(o1,{item:s,onSelect:i}),e[52]=s,e[53]=i,e[54]=v):v=e[54];let b;return e[55]!==x||e[56]!==v?(b=r.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[x,v]}),e[55]=x,e[56]=v,e[57]=b):b=e[57],b}function ZI(t){t.target.style.display="none"}function o1(t){const e=F.c(39),{item:s,onSelect:n}=t,i=oe(),[o,a]=N.useState(!1);let l;e[0]!==s.publicUrl||e[1]!==i?(l=async function(C){C.preventDefault(),C.stopPropagation();try{await navigator.clipboard.writeText(s.publicUrl),a(!0),window.setTimeout(()=>a(!1),1500)}catch{ve.error(i("filePicker.filePickerDialog.failedToCopyUrl"))}},e[0]=s.publicUrl,e[1]=i,e[2]=l):l=e[2];const c=l;let d;e[3]!==i?(d=i("filePicker.filePickerDialog.assetActions"),e[3]=i,e[4]=d):d=e[4];let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(K2,{size:14}),e[5]=h):h=e[5];let u;e[6]!==d?(u=r.jsx(bs,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:sM,"aria-label":d,children:h})}),e[6]=d,e[7]=u):u=e[7];let f;e[8]!==s.publicUrl||e[9]!==n?(f=()=>n(s.publicUrl),e[8]=s.publicUrl,e[9]=n,e[10]=f):f=e[10];let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(ns,{size:14}),e[11]=m):m=e[11];let p;e[12]!==i?(p=i("filePicker.filePickerDialog.useThis"),e[12]=i,e[13]=p):p=e[13];let g;e[14]!==f||e[15]!==p?(g=r.jsxs(Je,{onClick:f,children:[m,p]}),e[14]=f,e[15]=p,e[16]=g):g=e[16];let x;e[17]!==o?(x=o?r.jsx(ns,{size:14}):r.jsx(Vs,{size:14}),e[17]=o,e[18]=x):x=e[18];let v;e[19]!==o||e[20]!==i?(v=i(o?"filePicker.filePickerDialog.copied":"filePicker.filePickerDialog.copyUrl"),e[19]=o,e[20]=i,e[21]=v):v=e[21];let b;e[22]!==c||e[23]!==v||e[24]!==x?(b=r.jsxs(Je,{onClick:c,children:[x,v]}),e[22]=c,e[23]=v,e[24]=x,e[25]=b):b=e[25];const _=s.publicUrl;let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx($n,{size:14}),e[26]=y):y=e[26];let L;e[27]!==i?(L=i("filePicker.filePickerDialog.openInNewTab"),e[27]=i,e[28]=L):L=e[28];let w;e[29]!==s.publicUrl||e[30]!==L?(w=r.jsx(Je,{asChild:!0,children:r.jsxs("a",{href:_,target:"_blank",rel:"noreferrer",onClick:eM,children:[y,L]})}),e[29]=s.publicUrl,e[30]=L,e[31]=w):w=e[31];let j;e[32]!==b||e[33]!==w||e[34]!==g?(j=r.jsxs(ys,{align:"end",onClick:tM,children:[g,b,w]}),e[32]=b,e[33]=w,e[34]=g,e[35]=j):j=e[35];let S;return e[36]!==j||e[37]!==u?(S=r.jsxs(vs,{children:[u,j]}),e[36]=j,e[37]=u,e[38]=S):S=e[38],S}function eM(t){return t.stopPropagation()}function tM(t){return t.stopPropagation()}function sM(t){return t.stopPropagation()}function a1(t){const e=t.split("/");return e[e.length-1]??t}function nM(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function n5(t,e){if(!e)return null;const s=e.toLowerCase();return t.find(n=>{const i=n.bucket.toLowerCase();return n.siteSlug?.toLowerCase()===s||i===s||i===`deco-assets-${s}`})??null}function i5(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:r.jsxs("span",{className:"flex items-center gap-1.5 rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:[r.jsx(Ui,{size:14}),"Click to replace"]})}),t[0]=e):e=t[0],e}function r5(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function o5(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}const iM=["low","medium","high","original"];function a5(t){return t==="low"||t==="medium"||t==="high"||t==="original"}function l5(t,e){try{return new URL(t).searchParams.get(e)}catch{const s=rM(t);for(const n of s){const i=n.indexOf("=");if((i>=0?n.slice(0,i):n)===e)return i>=0?n.slice(i+1):""}return null}}function c5(t,e,s){const n=t.indexOf("#"),i=n>=0?t.slice(n):"",o=n>=0?t.slice(0,n):t,a=o.indexOf("?"),l=a>=0?o.slice(0,a):o,c=(a>=0?o.slice(a+1).split("&"):[]).filter(Boolean).filter(d=>{const h=d.indexOf("=");return(h>=0?d.slice(0,h):d)!==e});return s!==void 0&&c.push(`${e}=${s}`),`${l}${c.length?`?${c.join("&")}`:""}${i}`}function rM(t){const e=t.indexOf("#"),s=e>=0?t.slice(0,e):t,n=s.indexOf("?");return n<0?[]:s.slice(n+1).split("&").filter(Boolean)}function oM(t){if(!t)return;const e=l5(t,"quality");return a5(e)?e:void 0}function aM(t,e){return c5(t,"quality",e)}function lM(t){return t?l5(t,"muted")!=="false":!0}function cM(t,e){return c5(t,"muted",e?void 0:"false")}function d5(t){const e=F.c(36),{value:s,onChange:n,showMuted:i}=t,o=i===void 0?!1:i,a=oe(),l=N.useId();let c;e[0]!==s?(c=oM(s),e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==s?(h=lM(s),e[2]=s,e[3]=h):h=e[3];const u=h;let f;e[4]!==a?(f=a("sectionsEditor.mediaTransformControls.mediaOptionsLabel"),e[4]=a,e[5]=f):f=e[5];let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(K2,{size:14}),e[6]=m):m=e[6];let p;e[7]!==f?(p=r.jsx(Ts,{asChild:!0,children:r.jsx(le,{type:"button",variant:"outline",size:"sm",className:"h-9 shrink-0","aria-label":f,children:m})}),e[7]=f,e[8]=p):p=e[8];let g;e[9]!==a?(g=a("sectionsEditor.mediaTransformControls.qualityLabel"),e[9]=a,e[10]=g):g=e[10];let x;e[11]!==g?(x=r.jsx(st,{className:"text-xs text-muted-foreground",children:g}),e[11]=g,e[12]=x):x=e[12];const v=d??"";let b;e[13]!==n||e[14]!==s?(b=k=>n(aM(s,a5(k)?k:void 0)),e[13]=n,e[14]=s,e[15]=b):b=e[15];let _;e[16]===Symbol.for("react.memo_cache_sentinel")?(_=iM.map(dM),e[16]=_):_=e[16];let y;e[17]!==b||e[18]!==v?(y=r.jsx(h9,{type:"single",variant:"outline",size:"sm",value:v,onValueChange:b,children:_}),e[17]=b,e[18]=v,e[19]=y):y=e[19];let L;e[20]!==y||e[21]!==x?(L=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[x,y]}),e[20]=y,e[21]=x,e[22]=L):L=e[22];let w;e[23]!==u||e[24]!==l||e[25]!==n||e[26]!==o||e[27]!==a||e[28]!==s?(w=o&&r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx(st,{htmlFor:l,className:"text-xs text-muted-foreground",children:a("sectionsEditor.mediaTransformControls.mutedLabel")}),r.jsx(_r,{id:l,checked:u,onCheckedChange:k=>n(cM(s,k))})]}),e[23]=u,e[24]=l,e[25]=n,e[26]=o,e[27]=a,e[28]=s,e[29]=w):w=e[29];let j;e[30]!==L||e[31]!==w?(j=r.jsx(As,{align:"end",className:"w-auto min-w-52 p-3",children:r.jsxs("div",{className:"flex flex-col gap-3",children:[L,w]})}),e[30]=L,e[31]=w,e[32]=j):j=e[32];let S;return e[33]!==j||e[34]!==p?(S=r.jsxs(Es,{children:[p,j]}),e[33]=j,e[34]=p,e[35]=S):S=e[35],S}function dM(t){return r.jsx(Mo,{value:t,className:"h-8 px-3 text-xs capitalize",children:t},t)}function l1(t){const e=F.c(2),{ext:s}=t;if(!s)return null;let n;return e[0]!==s?(n=r.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:s}),e[0]=s,e[1]=n):n=e[1],n}function uM(t){const e=F.c(86),{schema:s,value:n,onChange:i,path:o,label:a,sandbox:l}=t,c=oe(),d=s.format==="video-uri",h=Tu(n),[u,f]=N.useState(!1),[m,p]=N.useState(!1),g=h?r5(h):"",x=g?o5(g):"",v=ep(),b=Ru();let _;e[0]!==v.data?.configs?(_=v.data?.configs??[],e[0]=v.data?.configs,e[1]=_):_=e[1];const y=l?.siteSlug;let L;e[2]!==_||e[3]!==y?(L=n5(_,y),e[2]=_,e[3]=y,e[4]=L):L=e[4];const w=L;let j;e[5]!==v.data?.configs||e[6]!==w?(j=function(){if(w)return w.id;const se=v.data?.configs??[];if(se.length===1)return se[0].id;if(se.length===0)return null;const re=typeof window<"u"?window.localStorage.getItem(Ec):null;return se.some(de=>de.id===re)?re:null},e[5]=v.data?.configs,e[6]=w,e[7]=j):j=e[7];const S=j;let k;e[8]!==d||e[9]!==i||e[10]!==S||e[11]!==f||e[12]!==c||e[13]!==b?(k=async function(se){if(!se)return;let re=Array.from(se);if(re.length===0)return;if(d&&(re=re.filter(hM),re.length===0)){ve.error(c("sectionsEditor.fileField.videoFileError"));return}const de=S();if(!de){f(!0);return}try{const ce=await b.mutateAsync({configId:de,file:re[0]});i(ce.publicUrl),re.length>1&&ve.info(c("sectionsEditor.fileField.multiFileWarning",{fileName:re[0].name}))}catch(ce){const fe=ce;ve.error(fe instanceof Error?fe.message:c("sectionsEditor.fileField.uploadFailed"))}},e[8]=d,e[9]=i,e[10]=S,e[11]=f,e[12]=c,e[13]=b,e[14]=k):k=e[14];const C=k;let A;e[15]!==p?(A=function(se){se.preventDefault(),se.dataTransfer.types.includes("Files")&&p(!0)},e[15]=p,e[16]=A):A=e[16];const P=A;let V;e[17]!==p?(V=function(se){se.currentTarget===se.target&&p(!1)},e[17]=p,e[18]=V):V=e[18];const T=V;let R;e[19]!==C||e[20]!==p?(R=function(se){se.preventDefault(),p(!1),C(se.dataTransfer.files)},e[19]=C,e[20]=p,e[21]=R):R=e[21];const E=R;let I;e[22]!==a||e[23]!==o?(I=r.jsx(st,{htmlFor:o,className:"text-muted-foreground",children:a}),e[22]=a,e[23]=o,e[24]=I):I=e[24];let D;e[25]!==s.description?(D=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[25]=s.description,e[26]=D):D=e[26];let M;e[27]!==D||e[28]!==I?(M=r.jsxs("div",{className:"min-w-0 space-y-0.5",children:[I,D]}),e[27]=D,e[28]=I,e[29]=M):M=e[29];const O=m&&"border-primary ring-2 ring-primary/30",$=b.isPending&&"pointer-events-none opacity-60";let B;e[30]!==O||e[31]!==$?(B=ie("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",O,$),e[30]=O,e[31]=$,e[32]=B):B=e[32];let z;e[33]!==x||e[34]!==g||e[35]!==d||e[36]!==f||e[37]!==h||e[38]!==c||e[39]!==b.isPending?(z=h?d?r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",onClick:()=>f(!0),"aria-label":c("sectionsEditor.fileField.replaceVideoLabel"),className:"relative block h-40 w-full cursor-pointer overflow-hidden bg-black",children:[r.jsx("video",{src:h,preload:"metadata",className:"h-full w-full object-contain"},h),r.jsx(i5,{})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[r.jsx(oh,{size:14,className:"shrink-0 text-muted-foreground"}),r.jsx("p",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:g}),r.jsx(l1,{ext:x})]})]}):r.jsxs("button",{type:"button",onClick:()=>f(!0),"aria-label":c("sectionsEditor.fileField.replaceFileLabel"),className:"flex w-full cursor-pointer items-center gap-3 px-3 py-2.5 text-left hover:bg-muted/60",children:[r.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-md bg-background",children:r.jsx(Pi,{size:18,className:"text-muted-foreground"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium",children:g}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:h})]}),r.jsx(l1,{ext:x})]}):r.jsxs("button",{type:"button",onClick:()=>f(!0),className:"flex w-full flex-col items-center justify-center gap-2 py-8 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[d?r.jsx(oh,{size:20}):r.jsx(Pi,{size:20}),r.jsx("span",{className:"text-sm font-medium",children:b.isPending?c("sectionsEditor.fileField.uploading"):c(d?"sectionsEditor.fileField.dropVideoHint":"sectionsEditor.fileField.dropFileHint")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:c("sectionsEditor.fileField.sizeLimit")})]}),e[33]=x,e[34]=g,e[35]=d,e[36]=f,e[37]=h,e[38]=c,e[39]=b.isPending,e[40]=z):z=e[40];let K;e[41]!==m||e[42]!==c?(K=m&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:r.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:c("sectionsEditor.fileField.dropToUpload")})}),e[41]=m,e[42]=c,e[43]=K):K=e[43];let Y;e[44]!==T||e[45]!==P||e[46]!==E||e[47]!==B||e[48]!==z||e[49]!==K?(Y=r.jsxs("div",{onDragOver:P,onDragLeave:T,onDrop:E,className:B,children:[z,K]}),e[44]=T,e[45]=P,e[46]=E,e[47]=B,e[48]=z,e[49]=K,e[50]=Y):Y=e[50];let Q;e[51]!==i?(Q=te=>i(te.target.value),e[51]=i,e[52]=Q):Q=e[52];let q;e[53]!==o||e[54]!==h||e[55]!==Q?(q=r.jsx(et,{id:o,type:"url",value:h,onChange:Q,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[53]=o,e[54]=h,e[55]=Q,e[56]=q):q=e[56];let H;e[57]!==f||e[58]!==h||e[59]!==c?(H=!h&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:()=>f(!0),className:"h-9 shrink-0",children:[r.jsx(Ui,{size:14}),c("sectionsEditor.fileField.browseButton")]}),e[57]=f,e[58]=h,e[59]=c,e[60]=H):H=e[60];let U;e[61]!==d||e[62]!==i||e[63]!==h?(U=d&&h&&r.jsx(d5,{value:h,onChange:i,showMuted:!0}),e[61]=d,e[62]=i,e[63]=h,e[64]=U):U=e[64];let X;e[65]!==i||e[66]!==h||e[67]!==c?(X=h&&r.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(""),className:"h-9 shrink-0","aria-label":c("sectionsEditor.fileField.removeFileLabel"),children:r.jsx(_s,{size:14})}),e[65]=i,e[66]=h,e[67]=c,e[68]=X):X=e[68];let J;e[69]!==q||e[70]!==H||e[71]!==U||e[72]!==X?(J=r.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[q,H,U,X]}),e[69]=q,e[70]=H,e[71]=U,e[72]=X,e[73]=J):J=e[73];let ee;e[74]!==i?(ee=te=>i(te),e[74]=i,e[75]=ee):ee=e[75];const W=w?.id??null;let Z;e[76]!==u||e[77]!==f||e[78]!==ee||e[79]!==W?(Z=r.jsx(e5,{open:u,onOpenChange:f,mode:"any",onSelect:ee,lockedConfigId:W}),e[76]=u,e[77]=f,e[78]=ee,e[79]=W,e[80]=Z):Z=e[80];let G;return e[81]!==M||e[82]!==Y||e[83]!==J||e[84]!==Z?(G=r.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[M,Y,J,Z]}),e[81]=M,e[82]=Y,e[83]=J,e[84]=Z,e[85]=G):G=e[85],G}function hM(t){return t.type.startsWith("video/")}const fM=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function mM(t){const e=F.c(91),{schema:s,value:n,onChange:i,path:o,label:a,sandbox:l}=t,c=oe(),d=Tu(n),[h,u]=N.useState(!1),[f,m]=N.useState(!1),[p,g]=N.useState(!1),[x,v]=N.useState(!1),b=d?r5(d):"",_=b?o5(b):"",y=ep(),L=Ru();let w;e[0]!==y.data?.configs?(w=y.data?.configs??[],e[0]=y.data?.configs,e[1]=w):w=e[1];const j=l?.siteSlug;let S;e[2]!==w||e[3]!==j?(S=n5(w,j),e[2]=w,e[3]=j,e[4]=S):S=e[4];const k=S;let C;e[5]!==i||e[6]!==v||e[7]!==g?(C=function(ue){g(!1),v(!1),i(ue)},e[5]=i,e[6]=v,e[7]=g,e[8]=C):C=e[8];const A=C;let P;e[9]!==y.data?.configs||e[10]!==k?(P=function(){if(k)return k.id;const ue=y.data?.configs??[];if(ue.length===1)return ue[0].id;if(ue.length===0)return null;const ae=typeof window<"u"?window.localStorage.getItem(Ec):null;return ue.some(me=>me.id===ae)?ae:null},e[9]=y.data?.configs,e[10]=k,e[11]=P):P=e[11];const V=P;let T;e[12]!==V||e[13]!==u||e[14]!==A||e[15]!==c||e[16]!==L?(T=async function(ue){if(!ue)return;const ae=Array.from(ue).filter(pM);if(ae.length===0){ve.error(c("sectionsEditor.imageField.onlyImageFilesAccepted"));return}const me=V();if(!me){u(!0);return}try{const xe=await L.mutateAsync({configId:me,file:ae[0]});A(xe.publicUrl),ae.length>1&&ve.info(c("sectionsEditor.imageField.uploadedWithExtraFilesIgnored",{fileName:ae[0].name}))}catch(xe){const Se=xe;ve.error(Se instanceof Error?Se.message:c("sectionsEditor.imageField.uploadFailed"))}},e[12]=V,e[13]=u,e[14]=A,e[15]=c,e[16]=L,e[17]=T):T=e[17];const R=T;let E;e[18]!==m?(E=function(ue){ue.preventDefault(),ue.dataTransfer.types.includes("Files")&&m(!0)},e[18]=m,e[19]=E):E=e[19];const I=E;let D;e[20]!==m?(D=function(ue){ue.currentTarget===ue.target&&m(!1)},e[20]=m,e[21]=D):D=e[21];const M=D;let O;e[22]!==R||e[23]!==m?(O=function(ue){ue.preventDefault(),m(!1),R(ue.dataTransfer.files)},e[22]=R,e[23]=m,e[24]=O):O=e[24];const $=O;let B;e[25]!==a||e[26]!==o?(B=r.jsx(st,{htmlFor:o,className:"text-muted-foreground",children:a}),e[25]=a,e[26]=o,e[27]=B):B=e[27];let z;e[28]!==s.description?(z=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[28]=s.description,e[29]=z):z=e[29];let K;e[30]!==B||e[31]!==z?(K=r.jsxs("div",{className:"min-w-0 space-y-0.5",children:[B,z]}),e[30]=B,e[31]=z,e[32]=K):K=e[32];const Y=f&&"border-primary ring-2 ring-primary/30",Q=L.isPending&&"pointer-events-none opacity-60";let q;e[33]!==Y||e[34]!==Q?(q=ie("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",Y,Q),e[33]=Y,e[34]=Q,e[35]=q):q=e[35];let H;e[36]!==_||e[37]!==b||e[38]!==x||e[39]!==p||e[40]!==a||e[41]!==v||e[42]!==g||e[43]!==u||e[44]!==d||e[45]!==c||e[46]!==L.isPending?(H=d?r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",onClick:()=>u(!0),"aria-label":c("sectionsEditor.imageField.replaceImage"),className:"relative block h-40 w-full cursor-pointer bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!x&&r.jsx("img",{src:d,alt:a,className:ie("h-full w-full object-contain transition-opacity",!p&&"opacity-0"),onLoad:()=>g(!0),onError:()=>v(!0)},d),x&&r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[r.jsx(Dn,{size:20}),r.jsx("p",{className:"text-xs",children:c("sectionsEditor.imageField.previewUnavailable")})]}),!p&&!x&&r.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"}),r.jsx(i5,{})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:b}),_&&r.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:_})]})]}):r.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[r.jsx(Dn,{size:20}),r.jsx("span",{className:"text-sm font-medium",children:L.isPending?c("sectionsEditor.imageField.uploading"):c("sectionsEditor.imageField.dropImageOrClickToBrowse")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:c("sectionsEditor.imageField.supportedFormatsAndSize")})]}),e[36]=_,e[37]=b,e[38]=x,e[39]=p,e[40]=a,e[41]=v,e[42]=g,e[43]=u,e[44]=d,e[45]=c,e[46]=L.isPending,e[47]=H):H=e[47];let U;e[48]!==f||e[49]!==c?(U=f&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:r.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:c("sectionsEditor.imageField.dropToUpload")})}),e[48]=f,e[49]=c,e[50]=U):U=e[50];let X;e[51]!==M||e[52]!==I||e[53]!==$||e[54]!==q||e[55]!==H||e[56]!==U?(X=r.jsxs("div",{onDragOver:I,onDragLeave:M,onDrop:$,className:q,children:[H,U]}),e[51]=M,e[52]=I,e[53]=$,e[54]=q,e[55]=H,e[56]=U,e[57]=X):X=e[57];let J;e[58]!==A?(J=fe=>A(fe.target.value),e[58]=A,e[59]=J):J=e[59];let ee;e[60]!==c?(ee=c("sectionsEditor.imageField.urlPlaceholder"),e[60]=c,e[61]=ee):ee=e[61];let W;e[62]!==o||e[63]!==d||e[64]!==J||e[65]!==ee?(W=r.jsx(et,{id:o,type:"url",value:d,onChange:J,placeholder:ee,className:"h-9 min-w-0 flex-1"}),e[62]=o,e[63]=d,e[64]=J,e[65]=ee,e[66]=W):W=e[66];let Z;e[67]!==u||e[68]!==d||e[69]!==c?(Z=!d&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:()=>u(!0),className:"h-9 shrink-0",children:[r.jsx(Ui,{size:14}),c("sectionsEditor.imageField.browse")]}),e[67]=u,e[68]=d,e[69]=c,e[70]=Z):Z=e[70];let G;e[71]!==A||e[72]!==d||e[73]!==c?(G=d&&r.jsxs(r.Fragment,{children:[r.jsx(d5,{value:d,onChange:A}),r.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:()=>A(""),className:"h-9 shrink-0","aria-label":c("sectionsEditor.imageField.removeImage"),children:r.jsx(_s,{size:14})})]}),e[71]=A,e[72]=d,e[73]=c,e[74]=G):G=e[74];let te;e[75]!==W||e[76]!==Z||e[77]!==G?(te=r.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[W,Z,G]}),e[75]=W,e[76]=Z,e[77]=G,e[78]=te):te=e[78];let se;e[79]!==A?(se=fe=>A(fe),e[79]=A,e[80]=se):se=e[80];const re=k?.id??null;let de;e[81]!==h||e[82]!==u||e[83]!==se||e[84]!==re?(de=r.jsx(e5,{open:h,onOpenChange:u,mode:"image",onSelect:se,lockedConfigId:re}),e[81]=h,e[82]=u,e[83]=se,e[84]=re,e[85]=de):de=e[85];let ce;return e[86]!==K||e[87]!==X||e[88]!==te||e[89]!==de?(ce=r.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[K,X,te,de]}),e[86]=K,e[87]=X,e[88]=te,e[89]=de,e[90]=ce):ce=e[90],ce}function pM(t){return fM.has(t.type||"")}function u5(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function gM(t,e){if(e.length===0)return 0;const s=u5(t);for(let o=0;o<e.length;o++){const a=e[o].discriminators;if(a&&Object.keys(a).length>0&&Object.entries(a).every(([c,d])=>s[c]===d))return o}let n=0,i=-1;for(let o=0;o<e.length;o++){const a=e[o],l=new Set(Object.keys(a.discriminators??{})),d=a.propertyKeys.filter(h=>!l.has(h)).filter(h=>s[h]!==void 0&&s[h]!==null&&s[h]!=="").length;d>i&&(i=d,n=o)}return n}function xM(t,e){const s=u5(t),n=new Set(e);return Object.fromEntries(Object.entries(s).filter(([i])=>!n.has(i)))}const vM="0 0 1080 1080",bM="matrix(1 0 0 1 540 540)",Du=[{code:"AC",name:"Acre",gTransform:"matrix(1 0 0 1 -248.53 -95.16)",pathTransform:"translate(-57.47, -224.1)",d:"M 30.47 237.77 L 28.39 237.73 L 28.93 235.92 L 28.72 235.09 L 28.47 234.6 L 27.22 233.9 L 27.08 233.45 L 27.35 232.3 L 26.58 230.35 L 25.49 229.71 L 19.89 228.46 L 12.55 228.27 L 12.82 227.71 L 15.31 225.45 L 16.2 224.22 L 16.49 223.02 L 16.27 221.79 L 15.59 220.88 L 14.76 220.44 L 13.08 217.49 L 12.31 217.05 L 11.41 216.86 L 10.28 215.73 L 9.36 213.35 L 7.36 211.82 L 6.38 208.2 L 5.51 206.56 L 3.63 205.48 L 3.55 204.31 L 4.36 204.41 L 4.78 203.89 L 4.85 203.22 L 4.65 202.8 L 2.53 201.87 L 2.17 201.21 L 0 199.32 L 0.04 198.95 L 0.66 198.9 L 1.16 197.58 L 1.15 196.27 L 4.16 195.88 L 4.66 195.49 L 4.44 194.14 L 3.27 192.57 L 3.27 192.57 L 21.22 200.05 L 44.88 205.71 L 57.02 208.85 L 83.46 223.02 L 111.97 235.15 L 111.97 235.15 L 114.94 236.41 L 114.94 236.41 L 114.64 236.89 L 113.07 237.55 L 110.98 239.14 L 108.12 241.93 L 106.47 242.79 L 105.81 242.61 L 104.28 242.79 L 104.23 243.35 L 102.31 244.65 L 100.23 245.64 L 98.79 247.47 L 98.35 248.65 L 97.74 248.93 L 96.57 248.18 L 95.81 248.05 L 93.44 248.1 L 92.76 248.36 L 92.13 248.81 L 91.77 249.67 L 89.33 253.15 L 85.56 254.4 L 84.72 255.09 L 82.78 255.6 L 81.75 255.63 L 81.83 253.52 L 80.47 253.72 L 76.92 252.95 L 71.68 252.48 L 66.59 252.86 L 65.93 252.28 L 63.66 252.11 L 60.1 253.94 L 57.37 254.56 L 55.69 253.89 L 54.29 252.45 L 52.65 253.61 L 52.69 236.06 L 52.74 234.96 L 53.21 234.25 L 53.28 231.9 L 53.02 231.02 L 53.99 229.84 L 54.47 228.7 L 53.31 228.9 L 50.34 231.49 L 48.74 232.5 L 46.68 234.88 L 44.73 235.55 L 44.08 236.63 L 42.27 237.62 z"},{code:"AL",name:"Alagoas",gTransform:"matrix(1 0 0 1 276.36 -86.82)",pathTransform:"translate(-582.36, -232.44)",d:"M 561.91 230.3 L 561.71 229.57 L 560.29 228.79 L 559.84 228.88 L 558.82 228.59 L 558.28 227.19 L 558.28 227.19 L 559.6 226.12 L 560.24 225.03 L 562.41 224.27 L 564.79 220.98 L 564.88 220.29 L 565.7 219.69 L 566.7 220.91 L 568.37 221.21 L 569.45 221.09 L 572 223.11 L 573.9 225.23 L 575.68 226.28 L 577.59 226.76 L 580.09 226.11 L 583.23 226.4 L 584.4 226.29 L 586.26 225.23 L 587.42 225.28 L 589.23 224.17 L 591.41 221.88 L 591.53 221.43 L 593.08 220.19 L 595.08 219.95 L 597.32 220.8 L 599.88 219.51 L 601.35 219.32 L 603.27 220.13 L 606.17 220.4 L 606.44 220.61 L 606.44 220.61 L 603.66 225.57 L 599.11 230.7 L 595.53 234.28 L 592.49 238.86 L 589.16 241.74 L 588.16 243.77 L 586.84 245.56 L 586.84 245.56 L 586.24 244.25 L 582.65 242.02 L 582.19 241.99 L 580.53 241.2 L 578.77 239.75 L 577.47 237.3 L 572.05 234.23 L 568.37 233.28 z"},{code:"AM",name:"Amazonas",gTransform:"matrix(1 0 0 1 -166.8 -178.05)",pathTransform:"translate(-139.2, -141.22)",d:"M 165.82 47.29 L 166.54 48.07 L 167.29 48.41 L 167.9 48.42 L 169.03 48 L 169.66 48.11 L 169.72 49.07 L 170.93 50.24 L 171.9 50.61 L 172.78 50.4 L 174.14 50.51 L 176.09 51.46 L 176.58 52.12 L 175.67 55.44 L 174.96 56.94 L 177.69 60.68 L 179.35 65.44 L 179.54 67.7 L 180.41 68.82 L 180.46 69.27 L 178.84 70.73 L 179.2 72.32 L 179.86 73.9 L 179.09 76.94 L 178.52 77.9 L 178.81 82.88 L 179.69 85.05 L 180.91 85.89 L 181.49 86.79 L 182.62 91.12 L 182.56 91.7 L 181.42 93.02 L 179.58 92.69 L 179.44 93.83 L 184.45 98.25 L 184.97 98.29 L 186.93 99.6 L 188.41 101.25 L 189.45 103.29 L 189.98 103.36 L 191.32 102.94 L 193.68 103.98 L 193.24 101.87 L 193.99 99.58 L 194.24 97.85 L 193.87 96.05 L 194.69 93.08 L 195.71 91.82 L 196.99 91.13 L 199.08 90.42 L 199.63 89.53 L 201.23 89.47 L 204.06 90.4 L 205.93 92.44 L 206.85 94.95 L 208.67 95.18 L 209.92 94.72 L 211.33 93.31 L 213.36 92.76 L 213.78 92.37 L 213.8 91.84 L 212.66 90.43 L 212.43 89.7 L 212.54 89.04 L 213.69 86.4 L 213.76 85.27 L 215.42 82.24 L 217.75 78.98 L 217.72 78.3 L 236.21 78.37 L 236.21 78.37 L 236.61 83.23 L 236.18 84.68 L 236.36 86.95 L 236.6 87.63 L 238.3 88.48 L 238.48 88.89 L 238.13 89.58 L 238.08 91.69 L 239.91 93.68 L 240.27 93.87 L 240.97 93.69 L 242.81 94.92 L 243.36 96.75 L 243.4 97.68 L 243.7 98.13 L 248.34 101.9 L 252.92 104.44 L 253.55 105.34 L 254.9 106.43 L 256.78 107.1 L 259.15 108.41 L 261.41 109.06 L 262.77 109.21 L 264.09 110.03 L 264.17 110.64 L 265.44 111.98 L 268.14 113.42 L 269.24 115.59 L 271.11 116.38 L 271.96 115.77 L 273.34 115.42 L 273.53 115.9 L 273.4 116.68 L 275.21 118.35 L 245.31 182.59 L 244.53 183.9 L 243.08 185.03 L 242.5 186 L 242.47 187.13 L 243.29 189.46 L 243.67 190.03 L 244.74 190.61 L 246.32 192.17 L 246.96 193.43 L 247.11 195.39 L 247.68 195.96 L 247.68 195.96 L 246.5 197.16 L 246.3 197.77 L 246.24 198.53 L 246.58 199.37 L 246.31 200.38 L 245.11 202.2 L 244.25 202.84 L 243.83 203.69 L 243.93 204.54 L 244.59 205.91 L 245.05 207.85 L 243.67 212.07 L 242.49 217.29 L 241.28 218.02 L 193.43 218.34 L 193.43 218.34 L 193.47 217.64 L 193.11 217.26 L 191.72 216.98 L 189.8 218.06 L 189.26 219.8 L 188.58 219.99 L 185.34 218.51 L 184.66 215.63 L 184.04 215.43 L 183.06 215.56 L 182.6 215.35 L 181.35 212.08 L 178.81 211.1 L 177.48 209.83 L 176.68 207.92 L 176.23 207.43 L 174.08 206.3 L 163.29 206.36 L 161.91 208.92 L 160.19 209.42 L 160.28 210.59 L 160.02 210.81 L 157.54 211.34 L 156.35 212.93 L 156.3 213.6 L 157.2 214.3 L 157.37 214.75 L 157.01 215.77 L 156.2 216.92 L 154.14 218.13 L 154.03 219.94 L 154.27 221.4 L 150.4 220.94 L 148.27 221.32 L 147.07 222.39 L 145.28 222.29 L 144.44 221.74 L 143.98 221.72 L 142.23 222.98 L 141.7 223.82 L 141.96 225.57 L 139.42 228.73 L 138.74 228.81 L 138.06 228.28 L 137.42 226.02 L 137.04 225.93 L 135.2 226.95 L 133.9 228.16 L 132.53 228.55 L 131.76 228.42 L 130.68 228.92 L 130.27 229.45 L 130.14 230.17 L 128.92 230.96 L 128.55 230.98 L 126.24 228.65 L 125.52 228.28 L 122.65 228.61 L 118.69 228.35 L 118.85 229.64 L 118.7 230.2 L 117.15 232.01 L 115.23 232.59 L 111.97 235.15 L 111.97 235.15 L 83.46 223.02 L 57.02 208.85 L 44.88 205.71 L 21.22 200.05 L 3.27 192.57 L 3.27 192.57 L 3.2 191.92 L 3.9 189 L 5.12 187.6 L 10.04 184.13 L 12.3 183.89 L 12.77 183.59 L 13.75 182.03 L 13.83 181 L 12.09 176.51 L 12.47 175.32 L 13.65 173.13 L 14.93 171.81 L 15.85 170.56 L 16.27 169.58 L 16.57 167.84 L 16.28 166.52 L 16.95 164.48 L 17.26 162.17 L 17.99 161.42 L 21.65 159.79 L 23.84 158.56 L 24.99 157.52 L 25.43 156.12 L 26.21 155.75 L 27.62 155.64 L 29.27 154.71 L 32.81 151.98 L 35.23 151.55 L 36.74 151.84 L 40.93 150.62 L 42.43 149.85 L 44.25 149.49 L 47.58 149.87 L 48.88 148.28 L 49.51 146.83 L 50.6 146.22 L 52.74 146.42 L 53.38 146.96 L 54.7 146.72 L 55.8 145.98 L 57.51 146.1 L 57.82 146.63 L 57.8 147.81 L 59.41 149.1 L 62.24 149.18 L 62.82 148.78 L 63.28 148 L 63.17 147.61 L 64.34 142.69 L 71.04 105.52 L 72.2 102.6 L 71.21 97.64 L 71.33 97.38 L 70.03 96.33 L 68.55 93.58 L 68.51 93.09 L 69.16 91.7 L 68.64 89.92 L 68.27 89.52 L 66.57 88.93 L 63.54 86.58 L 61.6 84.3 L 61.8 72.79 L 65.69 72.53 L 67.44 71.36 L 70.94 70.44 L 73.62 72.2 L 74.84 72.31 L 76.11 71.88 L 75.62 70.19 L 75.92 68.47 L 74.55 66.37 L 73.98 65.83 L 72.83 65.23 L 71.32 65.76 L 68.53 65.15 L 64.96 65.24 L 64.9 55.34 L 65.86 55.38 L 67.18 54.8 L 69.46 54.2 L 72.3 55.07 L 91.33 55.13 L 90.87 54.47 L 90.08 54.33 L 89.7 53.13 L 90.65 51.2 L 92.08 51.6 L 92.69 53.12 L 93.56 54.44 L 94.22 54.79 L 95.05 54.8 L 96.66 54.19 L 98.6 52.1 L 98.92 51.26 L 100.18 50.02 L 102.73 48.63 L 104.02 49.09 L 105.19 51.67 L 106.81 53.66 L 107.55 54.96 L 108.21 56.74 L 108.44 58.29 L 107.95 61.92 L 108.15 63.68 L 111.35 62.93 L 119.66 69.99 L 120.45 70.27 L 122.95 70.48 L 125.25 69.48 L 126.95 67.78 L 129.06 66.62 L 131.25 66.51 L 131.81 66.8 L 132.58 67.88 L 132.56 68.85 L 131.45 70.55 L 131.82 71.53 L 132.4 71.8 L 133.73 71.08 L 134.29 70.17 L 134.52 68.88 L 135.52 67.72 L 135.99 67.49 L 136.99 67.67 L 137.54 67.49 L 137.95 66.83 L 138.41 64.52 L 138.92 64.15 L 140.43 63.79 L 143.36 62.02 L 144.33 62.57 L 145.26 62.28 L 146.86 61.24 L 147.88 59.63 L 149.99 58.42 L 152.02 58.97 L 154.38 57.32 L 154.93 56.5 L 155.37 53.84 L 155.34 52.55 L 156.11 51.63 L 157.14 51.21 L 158.88 51.19 L 160.22 50.8 L 162.28 49.2 L 163.24 48.83 L 165.52 48.53 z"},{code:"AP",name:"Amapá",gTransform:"matrix(1 0 0 1 32.29 -262.31)",pathTransform:"translate(-338.29, -56.97)",d:"M 344.98 99.7 L 344.04 99.64 L 343.27000000000004 99.98 L 341.97 100.10000000000001 L 339.18 99.42 L 337.73 98.39 L 337.3 96.89 L 335.43 95.5 L 335.32 94.2 L 335.53 93.51 L 335.21999999999997 91.93 L 334.89 91.46000000000001 L 333.94 91.27000000000001 L 333.53 90.33000000000001 L 333.60999999999996 87.9 L 330.67999999999995 84.62 L 329.9 84.98 L 329.08 84.79 L 327.58 81.31 L 327.71 79.73 L 327.12 77.92 L 326.5 77.36 L 325.83 75.85 L 325.64 73.74 L 326.07 70.6 L 325.9 70.27 L 323.33 69.53999999999999 L 321.31 67.27999999999999 L 320.55 64.44999999999999 L 320.74 63.72999999999999 L 321.42 63.49999999999999 L 320.93 62.31999999999999 L 320.25 62.349999999999994 L 317.41 59.69 L 316.47 59.83 L 316.09000000000003 60.25 L 314.76000000000005 60.39 L 313.9200000000001 60.12 L 313.12000000000006 59.14 L 311.9800000000001 58.3 L 310.7900000000001 58.18 L 310.30000000000007 56.9 L 309.63000000000005 56.1 L 307.70000000000005 55.050000000000004 L 306.41 54.56 L 303.02000000000004 54.190000000000005 L 301.94000000000005 54.480000000000004 L 300.77000000000004 54.46 L 300.46000000000004 53.92 L 300.22 52.480000000000004 L 300.47 47.940000000000005 L 301.09000000000003 46.64000000000001 L 300.72 44.34000000000001 L 300.1 43.77000000000001 L 300.1 43.77000000000001 L 300.45000000000005 43.56000000000001 L 301.44000000000005 43.86000000000001 L 301.43000000000006 44.67000000000001 L 301.14000000000004 44.85000000000001 L 301.48 45.82000000000001 L 302.95000000000005 45.760000000000005 L 303.77000000000004 45.99 L 304.12000000000006 46.89 L 304.96000000000004 47.6 L 307.21000000000004 48.38 L 310.50000000000006 49.13 L 313.26000000000005 47.35 L 313.61000000000007 46.59 L 315.3400000000001 45.42 L 316.1700000000001 45.13 L 316.86000000000007 46.07 L 319.57000000000005 47.01 L 320.65000000000003 46.89 L 322.37000000000006 45.88 L 322.49000000000007 45.46 L 322.81000000000006 45.49 L 324.27000000000004 46.79 L 324.07000000000005 47.66 L 326.44000000000005 47.489999999999995 L 326.95000000000005 47.989999999999995 L 327.90000000000003 48.16 L 328.52000000000004 48.15 L 329.43000000000006 47.67 L 331.1000000000001 46.17 L 332.88000000000005 45.07 L 334.63000000000005 42.77 L 335.00000000000006 41.77 L 334.80000000000007 41.230000000000004 L 337.93000000000006 34.730000000000004 L 338.0400000000001 32.910000000000004 L 339.1500000000001 31.610000000000003 L 339.8800000000001 31.42 L 343.48000000000013 25.630000000000003 L 343.71000000000015 24.480000000000004 L 344.5500000000001 23.280000000000005 L 346.34000000000015 21.730000000000004 L 346.97000000000014 20.070000000000004 L 349.08000000000015 18.930000000000003 L 349.5500000000002 18.01 L 350.5900000000002 17.430000000000003 L 351.1500000000002 18.890000000000004 L 352.0300000000002 20.250000000000004 L 350.3600000000002 15.450000000000003 L 350.2900000000002 14.160000000000004 L 350.4700000000002 13.830000000000004 L 353.8400000000002 16.250000000000004 L 354.9800000000002 17.460000000000004 L 355.8900000000002 18.680000000000003 L 356.4100000000002 19.870000000000005 L 356.44000000000017 21.450000000000003 L 356.88000000000017 21.76 L 357.20000000000016 21.28 L 357.58000000000015 21.18 L 357.79000000000013 21.58 L 358.0000000000001 29.47 L 358.66000000000014 33.339999999999996 L 361.3700000000001 39.38999999999999 L 364.03000000000014 48.32999999999999 L 367.35000000000014 53.32999999999999 L 368.3600000000001 53.67999999999999 L 371.6300000000001 53.599999999999994 L 374.4100000000001 54.53999999999999 L 375.7000000000001 55.38999999999999 L 376.4700000000001 58.03999999999999 L 376.31000000000006 61.36999999999999 L 375.02000000000004 62.32999999999999 L 373.29 62.75999999999999 L 372.91 63.08999999999999 L 374.70000000000005 62.93999999999999 L 375.74000000000007 62.51999999999999 L 376.02000000000004 62.749999999999986 L 376.14000000000004 63.33999999999999 L 375.97 64.07 L 370.94000000000005 68.13 L 369.77000000000004 70.22999999999999 L 367.62000000000006 71.63999999999999 L 365.68000000000006 75.35999999999999 L 362.77000000000004 78.85999999999999 L 362.07000000000005 79.31999999999998 L 361.13000000000005 79.22999999999998 L 359.68000000000006 79.74999999999997 L 357.6000000000001 82.72999999999998 L 357.6000000000001 82.72999999999998 L 356.2600000000001 82.79999999999997 L 355.5100000000001 83.69999999999997 L 355.5100000000001 83.69999999999997 L 354.0400000000001 85.37999999999998 L 353.07000000000005 87.59999999999998 L 351.95000000000005 89.46999999999998 L 351.11000000000007 90.11999999999999 L 348.1000000000001 93.57 L 347.74000000000007 95.97 L 347.9100000000001 97.77 L 345.9600000000001 99.58 L 344.98 99.7 z M 368.34 52.71 L 367.89 52.38 L 366.78999999999996 50.52 L 366.85999999999996 49.64 L 367.09 49.230000000000004 L 368.75 48.78 L 369.18 49.17 L 370.01 51.440000000000005 L 369.02 52.540000000000006 L 368.34 52.71 z M 370.83 70.32 L 370.43 70.07 L 370.35 69.36 L 371.46000000000004 68.26 L 372.34000000000003 68.11 L 373.59000000000003 68.35 L 374.05 68.24 L 374.49 67.6 L 374.54 68.19 L 373.57 69.63 L 372.58 70.13 L 370.83 70.32 z M 374.27 67.45 L 373.49 67.22 L 373.49 66.66 L 374.21000000000004 65.61999999999999 L 375.46000000000004 65.52 L 375.64000000000004 65.86999999999999 L 375.54 66.38 L 374.27 67.45 z M 367.08 49.03 L 366.32 48.53 L 366.58 47.7 L 367.46 47.53 L 368.32 47.85 L 368.33 48.58 L 367.08 49.03 z"},{code:"BA",name:"Bahia",gTransform:"matrix(1 0 0 1 193.52 -26.39)",pathTransform:"translate(-499.52, -292.87)",d:"M 527.5 365.33 L 527.14 364.5 L 527.8199999999999 363.15 L 527.81 362.62 L 527.28 361.58 L 523.15 358.53 L 523 358.02 L 523.22 356.51 L 522.65 355.28 L 522 355.52 L 521.8 355.96999999999997 L 521.4599999999999 356.15 L 521.2399999999999 355.9 L 521.7699999999999 351.5 L 522.5899999999999 348.2 L 523.41 347.32 L 525.88 347.56 L 526.9 346.85 L 526.9 346.43 L 526.34 345.41 L 526.5 342.76000000000005 L 531.46 338.54 L 532.9300000000001 335.46000000000004 L 532.5100000000001 334.29 L 531.7300000000001 333.27000000000004 L 530.8400000000001 333.21000000000004 L 530.1100000000001 332.83000000000004 L 527.2800000000001 330.36 L 525.1600000000001 330.38 L 522.97 329.78 L 520.7 328.7 L 517.97 328.14 L 515.99 328 L 514.67 328.99 L 513.1999999999999 329.49 L 510.5899999999999 329.04 L 510.0199999999999 329.25 L 509.5799999999999 325.29 L 503.05999999999995 319.09000000000003 L 502.67999999999995 318.91 L 498.28999999999996 320.14000000000004 L 496.76 318.90000000000003 L 496.25 319.11 L 495.32 318.89 L 492.78 317.66999999999996 L 490.60999999999996 316.04999999999995 L 489.62999999999994 316.22999999999996 L 485.2799999999999 312.59999999999997 L 484.1799999999999 312.05999999999995 L 481.4499999999999 311.30999999999995 L 479.6799999999999 311.55999999999995 L 477.7999999999999 312.4599999999999 L 476.9899999999999 313.5799999999999 L 476.3499999999999 313.75999999999993 L 471.0199999999999 312.2899999999999 L 470.4099999999999 311.7999999999999 L 470.1499999999999 310.2999999999999 L 470.2899999999999 309.4099999999999 L 471.5799999999999 306.6699999999999 L 470.7199999999999 306.2099999999999 L 468.43999999999994 305.68999999999994 L 466.25999999999993 305.6499999999999 L 465.05999999999995 305.1499999999999 L 463.2699999999999 305.06999999999994 L 459.43999999999994 306.6499999999999 L 455.17999999999995 309.6799999999999 L 454.53999999999996 310.7899999999999 L 451.16999999999996 312.6599999999999 L 449.15 313.0599999999999 L 448.2 314.2399999999999 L 446.39 315.7899999999999 L 444.96 316.3099999999999 L 443.96 316.1599999999999 L 442.10999999999996 318.7399999999999 L 441.06999999999994 319.5099999999999 L 438.93999999999994 319.1299999999999 L 438.2199999999999 319.2599999999999 L 437.5299999999999 320.2599999999999 L 436.18999999999994 321.1799999999999 L 435.78999999999996 320.9399999999999 L 437.21999999999997 317.5099999999999 L 436.71 315.09999999999985 L 436.71 315.09999999999985 L 438.19 313.1299999999998 L 438.44 312.35999999999984 L 438.21 311.08999999999986 L 437.53999999999996 309.36999999999983 L 437.64 308.6999999999998 L 438.34999999999997 307.2799999999998 L 438.29999999999995 306.8199999999998 L 435.09 304.1999999999998 L 433.4 300.73999999999984 L 432.78 297.21999999999986 L 432.83 295.66999999999985 L 434.03 291.83999999999986 L 435.61999999999995 290.8099999999999 L 435.84999999999997 290.4299999999999 L 435.90999999999997 289.4899999999999 L 434.28 288.6499999999999 L 434.16999999999996 288.31999999999994 L 434.65 285.79999999999995 L 436.08 284.73999999999995 L 436.06 284.36999999999995 L 433.34 281.90999999999997 L 433.34 281.90999999999997 L 433.29999999999995 280.97999999999996 L 434.65999999999997 278.59999999999997 L 434.61999999999995 277.53 L 434.44999999999993 277.10999999999996 L 432.98999999999995 276.61999999999995 L 432.04999999999995 275.96999999999997 L 431.69999999999993 274.71 L 431.75999999999993 271.78999999999996 L 431.94999999999993 270.93999999999994 L 433.8999999999999 269.2699999999999 L 435.0399999999999 268.8499999999999 L 435.9999999999999 268.1299999999999 L 435.70999999999987 267.4999999999999 L 435.1299999999999 266.9799999999999 L 434.20999999999987 266.6899999999999 L 433.1799999999999 266.8699999999999 L 432.82999999999987 266.5399999999999 L 432.7399999999999 266.0399999999999 L 433.1599999999999 265.0799999999999 L 435.19999999999993 264.25999999999993 L 435.75999999999993 263.80999999999995 L 435.7199999999999 263.04999999999995 L 433.8399999999999 262.06999999999994 L 430.25999999999993 261.3999999999999 L 428.3999999999999 259.43999999999994 L 428.1699999999999 258.5199999999999 L 428.6699999999999 257.3599999999999 L 429.6799999999999 256.6299999999999 L 431.1999999999999 253.1499999999999 L 432.09999999999985 252.53999999999988 L 433.10999999999984 252.26999999999987 L 433.45999999999987 251.88999999999987 L 432.16999999999985 250.08999999999986 L 432.35999999999984 249.71999999999986 L 435.5699999999998 247.09999999999985 L 439.3899999999998 245.07999999999984 L 439.9499999999998 244.60999999999984 L 440.16999999999985 243.62999999999985 L 440.85999999999984 242.97999999999985 L 440.85999999999984 242.97999999999985 L 443.1899999999998 242.95999999999984 L 444.6299999999998 244.29999999999984 L 445.28999999999985 245.33999999999983 L 445.8199999999998 247.54999999999984 L 447.5799999999998 250.03999999999985 L 451.7599999999998 251.89999999999986 L 453.55999999999983 251.37999999999985 L 455.66999999999985 251.55999999999986 L 455.99999999999983 251.34999999999985 L 456.74999999999983 249.89999999999986 L 457.8899999999998 249.52999999999986 L 458.55999999999983 248.65999999999985 L 459.72999999999985 247.76999999999987 L 461.9399999999998 247.01999999999987 L 463.2699999999998 247.18999999999986 L 464.74999999999983 247.71999999999986 L 466.09999999999985 247.29999999999987 L 469.0699999999999 244.87999999999988 L 472.01999999999987 239.82999999999987 L 472.7399999999999 238.96999999999986 L 472.9799999999999 238.04999999999987 L 473.2799999999999 235.48999999999987 L 473.1599999999999 234.32999999999987 L 470.9199999999999 229.89999999999986 L 470.9699999999999 228.96999999999986 L 474.2099999999999 227.31999999999985 L 476.1599999999999 227.29999999999984 L 477.6599999999999 227.75999999999985 L 478.06999999999994 228.68999999999986 L 478.38999999999993 228.86999999999986 L 480.50999999999993 228.43999999999986 L 481.8999999999999 227.89999999999986 L 483.2299999999999 228.27999999999986 L 484.9399999999999 229.26999999999987 L 484.8099999999999 229.91999999999987 L 484.9999999999999 230.20999999999987 L 485.8199999999999 230.48999999999987 L 488.8199999999999 230.37999999999985 L 490.2899999999999 229.73999999999987 L 491.9899999999999 229.63999999999987 L 492.8099999999999 228.41999999999987 L 494.3199999999999 227.07999999999987 L 497.0499999999999 226.73999999999987 L 497.8199999999999 226.37999999999985 L 498.6299999999999 225.39999999999986 L 500.7999999999999 225.40999999999985 L 501.4199999999999 226.03999999999985 L 501.7299999999999 226.08999999999986 L 503.5899999999999 224.27999999999986 L 503.4899999999999 221.87999999999985 L 505.4799999999999 221.49999999999986 L 506.2699999999999 221.67999999999986 L 507.31999999999994 221.01999999999987 L 508.81999999999994 218.70999999999987 L 509.2799999999999 217.55999999999986 L 509.2799999999999 217.55999999999986 L 510.1699999999999 217.95999999999987 L 511.3299999999999 217.68999999999986 L 513.53 217.97999999999985 L 516.35 219.36999999999983 L 516.7900000000001 219.87999999999982 L 516.7300000000001 222.60999999999981 L 517.4500000000002 224.5499999999998 L 519.6600000000002 225.4599999999998 L 519.9300000000002 227.4599999999998 L 519.0100000000002 229.13999999999982 L 520.8400000000003 229.75999999999982 L 521.8000000000003 229.53999999999982 L 522.6200000000003 228.61999999999983 L 525.4900000000004 227.73999999999984 L 526.2600000000003 224.15999999999983 L 526.7600000000003 223.28999999999982 L 527.5100000000003 223.12999999999982 L 528.2900000000003 223.65999999999983 L 528.9200000000003 223.70999999999984 L 531.3100000000003 222.68999999999983 L 532.4100000000003 221.44999999999982 L 532.5800000000003 220.85999999999981 L 532.3300000000003 219.4999999999998 L 532.6200000000002 219.2499999999998 L 534.8600000000002 218.7999999999998 L 535.6300000000002 216.7499999999998 L 537.2800000000002 216.3099999999998 L 539.8100000000002 214.8499999999998 L 540.4000000000002 214.7499999999998 L 541.8900000000002 215.3099999999998 L 542.7200000000003 216.7499999999998 L 544.0800000000003 217.5599999999998 L 546.4400000000003 218.3399999999998 L 549.4300000000003 218.7399999999998 L 551.0100000000003 219.88999999999982 L 551.5500000000003 221.53999999999982 L 551.9400000000003 221.80999999999983 L 552.3700000000002 221.65999999999983 L 552.6600000000002 219.90999999999983 L 553.0900000000001 219.46999999999983 L 554.0900000000001 219.45999999999984 L 554.5400000000002 219.77999999999983 L 554.5600000000002 220.40999999999983 L 553.9400000000002 221.28999999999982 L 554.3900000000002 222.11999999999983 L 554.8900000000002 222.48999999999984 L 556.9900000000002 223.34999999999985 L 557.0100000000002 224.28999999999985 L 558.2300000000002 227.33999999999986 L 558.2300000000002 227.33999999999986 L 558.7700000000002 228.73999999999987 L 559.7900000000002 229.02999999999986 L 560.2400000000002 228.93999999999986 L 561.6700000000002 229.72999999999985 L 561.8700000000002 230.44999999999985 L 561.8700000000002 230.44999999999985 L 561.2000000000003 231.60999999999984 L 561.4100000000003 233.74999999999983 L 562.6900000000003 236.24999999999983 L 564.6800000000003 238.19999999999982 L 565.4300000000003 239.34999999999982 L 565.3500000000003 242.46999999999983 L 564.6900000000003 244.08999999999983 L 564.6000000000003 244.96999999999983 L 565.3600000000002 247.71999999999983 L 565.0600000000003 248.29999999999984 L 564.3700000000002 248.84999999999985 L 561.8200000000003 249.84999999999985 L 560.6900000000003 249.09999999999985 L 558.9800000000002 249.08999999999986 L 558.6600000000002 249.38999999999987 L 558.0700000000002 250.96999999999989 L 558.0900000000001 251.7399999999999 L 559.0400000000002 253.3399999999999 L 560.1400000000002 253.9999999999999 L 560.6600000000002 255.4899999999999 L 562.0900000000001 256.9999999999999 L 562.2400000000001 257.3899999999999 L 562.1100000000001 258.8099999999999 L 561.7700000000001 259.1999999999999 L 561.8900000000001 259.6199999999999 L 562.4800000000001 260.1399999999999 L 564.4100000000001 261.0599999999999 L 564.8900000000001 261.76999999999987 L 565.4300000000001 262.10999999999984 L 566.98 262.74999999999983 L 569.87 261.86999999999983 L 569.87 261.86999999999983 L 570.51 261.84999999999985 L 570.87 262.2599999999999 L 566.79 271.08999999999986 L 562.9599999999999 276.27999999999986 L 561.93 278.60999999999984 L 556.9 284.34999999999985 L 554.4499999999999 285.60999999999984 L 553.5799999999999 285.59999999999985 L 553.8799999999999 284.16999999999985 L 554.2499999999999 284.01999999999987 L 554.3899999999999 282.91999999999985 L 553.9399999999998 280.98999999999984 L 552.0699999999998 280.73999999999984 L 551.6399999999999 279.4399999999998 L 550.9599999999999 278.6899999999998 L 550.5899999999999 279.28999999999985 L 550.1299999999999 281.61999999999983 L 549.6299999999999 282.48999999999984 L 549.0799999999999 282.86999999999983 L 548.52 282.5799999999998 L 548.03 280.8399999999998 L 548.14 280.5199999999998 L 548.4499999999999 280.3899999999998 L 548.42 279.99999999999983 L 547.55 281.28999999999985 L 548.4799999999999 282.97999999999985 L 548.9399999999999 283.20999999999987 L 549.31 283.0599999999999 L 550.4599999999999 283.3199999999999 L 549.9999999999999 285.1299999999999 L 548.7899999999998 286.27999999999986 L 548.5399999999998 288.09999999999985 L 547.2899999999998 289.0699999999999 L 546.9399999999998 289.7399999999999 L 546.7399999999998 290.57999999999987 L 546.9199999999997 291.4299999999999 L 545.5699999999997 291.0399999999999 L 545.3599999999997 291.4299999999999 L 544.9999999999997 293.9499999999999 L 545.3599999999997 293.22999999999985 L 546.1099999999997 293.4399999999998 L 546.3499999999997 293.97999999999985 L 546.1199999999997 294.3899999999999 L 546.1799999999996 295.0099999999999 L 546.4799999999996 295.3099999999999 L 546.8099999999996 296.3099999999999 L 545.7699999999996 298.8199999999999 L 546.3399999999997 302.2599999999999 L 545.7899999999997 302.7499999999999 L 545.2199999999997 302.52999999999986 L 545.0799999999997 303.65999999999985 L 545.6699999999997 304.11999999999983 L 546.8799999999998 302.3999999999998 L 546.4099999999997 300.1899999999998 L 547.2299999999998 299.5799999999998 L 547.4799999999998 300.11999999999983 L 547.4199999999998 301.8799999999998 L 546.4599999999998 304.48999999999984 L 545.7199999999998 309.91999999999985 L 545.2099999999998 311.72999999999985 L 545.4099999999999 314.1999999999999 L 546.1899999999998 317.0499999999999 L 546.3799999999999 321.5899999999999 L 547.2499999999999 327.99999999999994 L 548.2399999999999 331.41999999999996 L 546.0299999999999 338.08 L 544.6799999999998 344.72999999999996 L 544.2099999999998 345.73999999999995 L 544.0499999999998 348.59999999999997 L 542.9899999999999 352.32 L 542.8999999999999 354.65 L 543.2899999999998 359.07 L 544.1799999999998 360.78 L 541.9399999999998 363.76 L 540.1299999999999 364.43 L 539.1899999999998 365.07 L 536.4699999999998 368.96 L 535.9 371 L 535.9 371 L 527.81 365.86 L 527.5 365.33 z M 549.78 287.33 L 549.55 286.13 L 550.29 285.71999999999997 L 551.3499999999999 284.67999999999995 L 551.5099999999999 284.03999999999996 L 551.1399999999999 283.30999999999995 L 551.8999999999999 283.44999999999993 L 552.7199999999999 284.49999999999994 L 552.67 285.0299999999999 L 549.78 287.33 z M 547.25 294.18 L 546.62 294.15000000000003 L 546.63 293.48 L 546.89 293.12 L 546.09 292.9 L 545.6700000000001 292.5 L 545.8000000000001 291.43 L 547.6700000000001 291.28000000000003 L 547.83 291.48 L 547.94 292.61 L 547.25 294.18 z"},{code:"CE",name:"Ceará",gTransform:"matrix(1 0 0 1 235.04 -154.64)",pathTransform:"translate(-541.04, -164.62)",d:"M 573.79 156.85 L 568.9 158.44 L 566.29 160.45 L 562.99 167.14 L 562.15 168.26 L 561.28 168.83 L 560.63 170.5 L 560.78 171.24 L 559.38 173.68 L 557.92 175.19 L 557.35 176.29 L 556.32 176.55 L 555.54 176.04 L 555.03 176.11 L 554.19 176.99 L 552.78 179.24 L 552.44 181.21 L 553.08 181.38 L 553.74 181 L 553.74 181 L 553.66 181.54 L 552.82 182.69 L 551.79 185.69 L 552.31 187 L 551.65 188.31 L 550.56 188.94 L 550.39 189.32 L 550.27 190.25 L 550.51 190.66 L 551.09 190.95 L 551.44 191.67 L 551.42 193.33 L 552.66 194.22 L 553.35 194.3 L 553.69 195.49 L 552.08 198.98 L 550.89 200.1 L 551.06 200.35 L 551.06 200.35 L 549.47 200.84 L 548.4 201.67 L 546.86 203.96 L 545.21 204.01 L 544.58 202.37 L 543.8 201.8 L 542.44 201.32 L 541.43 200.25 L 540.97 199.26 L 539.14 198.43 L 536.29 196.53 L 533.21 196.11 L 531.92 196.21 L 529.78 197.01 L 528.15 197.2 L 527.26 196.96 L 522.33 196.76 L 522.33 196.76 L 522.39 195.44 L 521.71 194.76 L 521.63 193.79 L 522.77 190.68 L 524.27 188.43 L 524.28 187.74 L 523.51 186.58 L 520.95 186.11 L 519.64 185.46 L 518.63 182.79 L 517.58 177.59 L 516.82 175.02 L 517.06 174.57 L 516.12 166.41 L 516.01 166.03 L 515.09 165.34 L 515.89 164.76 L 516.48 163.18 L 515.88 160.19 L 514.88 158.18 L 515.36 156.58 L 514.57 152.71 L 515.31 151.35 L 515.33 150.59 L 513.97 149 L 513.53 147.27 L 510.38 140.85 L 508.58 136.13 L 508.29 134.84 L 508.47 133.38 L 510.05 131.41 L 511.14 129.56 L 511.25 128.76 L 511.25 128.76 L 511.44 128.62 L 511.4 128 L 511 127.34 L 511.65 126.53 L 518.39 126.31 L 521.28 125.88 L 523.35 125.22 L 530.75 126.01 L 532.87 127.13 L 534.81 128.63 L 538.93 130.81 L 540.39 131.33 L 545.21 134.33 L 546.42 134.53 L 548.64 136.82 L 551.63 138.93 L 554.2 139.65 L 556.64 142.56 L 557.86 143.17 L 560.82 146.98 L 564.98 150.06 L 566.44 152.06 L 567.48 153.05 L 568.98 153.87 L 570.13 153.9 L 572.5 154.82 L 573.29 155.49 z"},{code:"DF",name:"Distrito Federal",gTransform:"matrix(1 0 0 1 103.1 10.18)",pathTransform:"translate(-409.11, -329.45)",d:"M 416.71 333.87 L 402.02 333.85 L 401.5 330.59 L 402.42 328.76 L 402.8 325.03 L 414.75 325.04 L 416.58 327.02 L 416.64 329.23 L 416.05 330.42 L 415.84 332.86 z"},{code:"ES",name:"Espírito Santo",gTransform:"matrix(1 0 0 1 212.62 72.56)",pathTransform:"translate(-518.62, -391.82)",d:"M 501.63 411.37 L 501.34 411.23 L 501.78 408.89 L 502.35 407.59 L 501.76 404.47 L 501.92 404.05 L 503.64 401.99 L 508.79 402.02 L 509.34 401.7 L 510.31 398.46 L 511.42 397.19 L 512.3 394.9 L 512.54 393.18 L 512.8 392.74 L 514.04 391.88 L 515.75 389.79 L 516.29 386.82 L 516 384.39 L 514.73 381.58 L 513.63 380.31 L 513.11 380.22 L 512.66 380.51 L 511.9 380.23 L 511.41 379.52 L 511.84 378.97 L 513.32 378.88 L 514.12 379.23 L 515.09 379.26 L 516.04 379.02 L 516.36 378.6 L 516.19 376.88 L 514.88 376.53 L 514.67 376.12 L 514.97 374.58 L 515 372.66 L 514.48 372 L 513.15 371.33 L 512.85 370.63 L 514.02 368.7 L 516.19 367.39 L 516.5 367.37 L 517.55 368.11 L 518.68 368.22 L 518.7 367.41 L 517.03 365.14 L 518.37 365.27 L 520.55 364.98 L 521.39 364.37 L 522.47 364.05 L 524.05 363.97 L 526.59 364.78 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.8 365.86 L 535.9 371 L 535.9 371 L 534.97 374.35 L 534.66 377.21 L 534.78 380.8 L 535.5 386.95 L 535.19 389.42 L 533.7 392.6 L 530.95 393.99 L 530.4 394.59 L 528.73 397.92 L 527.75 401.72 L 526.98 403.19 L 526.15 402.51 L 525.27 402.38 L 524.98 403.66 L 526.33 404.18 L 524.39 408.42 L 520.94 412.26 L 520.7 411.99 L 518.84 412.65 L 518.04 413.88 L 517.98 415.27 L 517.56 416.52 L 515.97 418.54 L 515.68 419.67 L 515.68 419.67 L 514.06 418.61 L 511.07 418.98 L 506.73 417.97 L 504.23 416.84 L 503.56 412.13 z"},{code:"GO",name:"Goiás",gTransform:"matrix(1 0 0 1 75.37 14.13)",pathTransform:"translate(-381.37, -333.38)",d:"M 416.71 333.87 L 415.84 332.86 L 416.05 330.42 L 416.64 329.23 L 416.58 327.02 L 414.75 325.04 L 402.8 325.03 L 402.42 328.76 L 401.5 330.59 L 402.02 333.85 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.18 335.39 L 416.49 336.96 L 415.81 338.55 L 414.77 339.8 L 414.36 341.27 L 415.21 342.48 L 416.06 342.82 L 417.48 343.85 L 419.13 348.41 L 419.13 349.01 L 416.81 351.72 L 413.57 354.73 L 413.14 356.87 L 414.23 357.98 L 415.13 357.51 L 416.71 358.08 L 417.18 358.69 L 417.36 359.69 L 417.19 360.4 L 416.46 361.3 L 415.95 363.19 L 417.14 366.65 L 414.05 368.71 L 412.89 368.91 L 412.03 369.81 L 411.55 370.93 L 406.66 373.67 L 405.96 372.9 L 401.61 371.04 L 401.06 371.52 L 400.48 371.61 L 398.73 371.62 L 397.25 371.34 L 393.39 371.5 L 391.38 370.61 L 387.25 373.25 L 384.34 376.17 L 384.01 376.17 L 382.7 374.75 L 381.18 374.45 L 377.99 376.09 L 374.28 375.47 L 371.8 376.43 L 369.57 376.97 L 368.16 379.07 L 366.95 381.53 L 367.01 382.53 L 366.17 383.83 L 365.35 384.11 L 364.51 383.95 L 364.06 384.09 L 363.12 384.83 L 361.48 386.93 L 360.91 388.83 L 361.47 389.44 L 361.46 389.78 L 361.1 390.01 L 360.24 389.55 L 360.24 389.55 L 360 389.1 L 357.34 386.86 L 354.19 386.25 L 352.57 384.7 L 350.67 384.27 L 349.18 384.23 L 345.83 382.89 L 345.15 382.04 L 342.08 380.48 L 341.41 379.87 L 339.97 379.16 L 338.83 378.99 L 336.13 377.31 L 333.35 377.47 L 329.55 376.77 L 329.42 376.44 L 329.68 375.6 L 330.25 374.43 L 331.56 372.67 L 331.48 372.25 L 329.23 371.35 L 328.09 372.02 L 327.43 371.83 L 327.15 371.42 L 326.92 370.31 L 327.18 367.73 L 326.99 365.96 L 326.99 365.96 L 326.04 363.76 L 325.86 360.33 L 324.45 358.14 L 324.29 357.43 L 324.69 354.02 L 327.24 350.17 L 327.62 347.26 L 328.32 346.49 L 330.34 345.65 L 332.26 343.88 L 333.51 341.86 L 333.84 339.91 L 334.34 338.9 L 335.62 337.86 L 336.44 336.43 L 336.52 334.89 L 338.27 333.92 L 339.67 331.3 L 342.32 331.17 L 345.04 330.31 L 345.36 330.03 L 347.34 325.84 L 348.05 324.88 L 348.69 320.78 L 349.07 320.04 L 350.99 318.1 L 352.64 317.09 L 353.71 316.83 L 354.94 317.51 L 356.15 316.78 L 357.54 315.35 L 358.38 312.42 L 359.55 309.55 L 359.54 308.75 L 359.06 307.61 L 359.64 304.87 L 361.24 301.78 L 361.12 296.6 L 362.33 295.82 L 363.36 293.19 L 365.36 290.02 L 365.75 288.95 L 365.59 286.23 L 365.94 285.33 L 366.91 284.47 L 367.18 283.34 L 367.1 282.71 L 367.1 282.71 L 367.44 282.26 L 367.64 280.38 L 368.3 279.15 L 370.11 277.06 L 370.67 276.76 L 370.64 278.47 L 369.42 280.35 L 368.9 282.69 L 371.3 283.09 L 373.5 284.12 L 377.43 284.52 L 380.52 286.23 L 384.59 287.66 L 385.22 287.43 L 386.85 281.49 L 388.32 279.1 L 389.5 278.13 L 390.65 279.44 L 391.69 281.32 L 392.8 285.03 L 393.41 288.13 L 394.55 288.18 L 395.3 287.43 L 395.6 286.43 L 396.16 285.89 L 398.92 286.23 L 403.45 285.7 L 403.67 286.44 L 403.11 288 L 406.24 289.47 L 409.59 290.15 L 410.28 290.07 L 410.79 286.77 L 411.34 286.8 L 412.85 289.42 L 413.31 289.66 L 415.09 288.76 L 417.61 286.68 L 422.14 285.68 L 423.69 285.68 L 426.25 284.58 L 427.99 283.24 L 433.35 281.82 L 433.35 281.82 L 436.07 284.28 L 436.09 284.66 L 434.66 285.72 L 434.18 288.24 L 434.28 288.57 L 435.91 289.41 L 435.85 290.35 L 435.62 290.73 L 434.03 291.76 L 432.84 295.59 L 432.79 297.14 L 433.41 300.66 L 435.11 304.12 L 438.32 306.74 L 438.37 307.21 L 437.65 308.63 L 437.55 309.3 L 438.22 311.02 L 438.45 312.3 L 438.2 313.07 L 436.72 315.04 L 436.72 315.04 L 435.72 316.05 L 432.49 315.71 L 431.59 313.95 L 429.17 312.47 L 428 313.96 L 428.58 317.73 L 428.01 318.27 L 427.61 318.4 L 424.83 317.26 L 423.66 317.49 L 423.29 317.77 L 422.57 320.95 L 423.29 321.05 L 423.78 322.21 L 423.21 323.15 L 422.48 323.85 L 422.52 325.75 L 422.94 326.36 L 423.47 326.55 L 424.16 330.81 L 423.63 331.34 L 420.27 332.24 L 417.98 333.75 z"},{code:"MA",name:"Maranhão",gTransform:"matrix(1 0 0 1 142.22 -148.63)",pathTransform:"translate(-448.22, -170.64)",d:"M 458.57 128.92 L 458.53 129.25 L 456.48999999999995 131.4 L 456.05999999999995 131.57 L 456.0199999999999 133.01 L 457.98999999999995 131.31 L 458.66999999999996 130.1 L 460.78999999999996 128.51999999999998 L 461.67999999999995 127.37999999999998 L 462.7099999999999 121.04999999999998 L 463.8599999999999 120.34999999999998 L 464.9699999999999 120.22999999999998 L 466.63999999999993 119.30999999999997 L 467.2899999999999 119.17999999999998 L 467.7499999999999 119.29999999999998 L 467.82999999999987 120.92999999999998 L 467.6299999999999 121.37999999999998 L 466.20999999999987 123.24999999999999 L 462.9999999999999 124.99999999999999 L 462.9699999999999 125.71999999999998 L 463.69999999999993 125.83999999999999 L 464.1499999999999 125.02999999999999 L 465.2999999999999 124.71999999999998 L 465.5199999999999 125.54999999999998 L 464.92999999999995 126.05999999999999 L 465.17999999999995 126.35999999999999 L 469.38999999999993 121.38999999999999 L 470.24999999999994 121.71999999999998 L 472.8299999999999 120.78999999999998 L 476.86999999999995 121.21999999999998 L 476.40999999999997 118.80999999999999 L 477.02 118.57999999999998 L 479.44 118.65999999999998 L 481.21999999999997 119.03999999999998 L 483.84999999999997 120.08999999999997 L 484.89 120.19999999999997 L 487.03999999999996 121.57999999999997 L 488.43999999999994 121.60999999999997 L 489.69999999999993 122.90999999999997 L 491.5899999999999 124.22999999999996 L 494.0899999999999 124.80999999999996 L 495.24999999999994 124.61999999999996 L 495.80999999999995 125.37999999999997 L 496.1499999999999 125.42999999999996 L 497.7399999999999 125.33999999999996 L 500.1999999999999 125.99999999999996 L 500.45999999999987 125.09999999999995 L 499.78999999999985 124.62999999999995 L 501.45999999999987 124.24999999999996 L 502.02999999999986 124.35999999999996 L 501.9399999999999 124.77999999999996 L 501.9399999999999 124.77999999999996 L 501.4799999999999 126.20999999999997 L 501.7099999999999 126.92999999999996 L 502.3399999999999 127.46999999999997 L 501.9599999999999 128.99999999999997 L 500.1699999999999 131.26999999999998 L 496.0399999999999 135.23999999999998 L 492.7199999999999 135.7 L 491.9199999999999 135.54 L 488.9999999999999 138.94 L 489.0399999999999 140.74 L 488.1599999999999 142.57000000000002 L 486.2699999999999 144.42000000000002 L 485.44999999999993 146.4 L 484.80999999999995 146.57 L 484.03999999999996 147.62 L 484.4 149.54 L 485.63 150.37 L 486.01 151.65 L 485.73 153.11 L 484.59000000000003 155.98000000000002 L 486.17 158.79000000000002 L 486.72 161.77 L 486.61 164.20000000000002 L 486.40000000000003 164.75000000000003 L 482.3 169.17000000000002 L 482.13 171.65 L 482.25 173.76000000000002 L 482.76 176.06000000000003 L 484.53999999999996 178.10000000000002 L 486.15 179.01000000000002 L 486.32 179.51000000000002 L 486.45 180.35000000000002 L 486.06 182.55 L 485.77 182.99 L 485.65 184.20000000000002 L 485.15 185.66000000000003 L 483.94 186.97000000000003 L 481.65 187.26000000000002 L 481 186.98000000000002 L 480.17 187.02 L 477.74 187.88000000000002 L 476.22 187.99000000000004 L 473.72 186.17000000000004 L 472.71000000000004 185.96000000000004 L 471.25000000000006 186.15000000000003 L 470.24000000000007 186.75000000000003 L 469.12000000000006 187.01000000000002 L 468.89000000000004 186.71 L 468.05000000000007 186.95000000000002 L 467.55000000000007 187.17000000000002 L 465.6500000000001 189.08 L 465.6600000000001 189.54000000000002 L 465.0300000000001 190.41000000000003 L 463.0200000000001 192.41000000000003 L 460.6800000000001 193.32000000000002 L 457.8100000000001 195.88000000000002 L 456.48000000000013 196.41000000000003 L 455.4300000000001 196.45000000000002 L 453.73000000000013 197.98000000000002 L 452.65000000000015 198.34000000000003 L 450.04000000000013 198.66000000000003 L 447.3200000000001 199.42000000000002 L 445.1900000000001 201.37 L 444.2100000000001 204.34 L 443.8200000000001 207.31 L 443.1900000000001 209.63 L 441.7400000000001 212.37 L 441.4400000000001 212.59 L 441.10000000000014 213.41 L 440.97000000000014 214.93 L 439.77000000000015 217.41 L 438.07000000000016 218.81 L 437.34000000000015 220.81 L 438.0500000000001 222.75 L 438.52000000000015 225.93 L 440.25000000000017 228.99 L 440.21000000000015 229.51000000000002 L 439.45000000000016 230.91000000000003 L 439.32000000000016 237.27000000000004 L 438.1700000000002 239.72000000000003 L 437.9100000000002 240.78000000000003 L 437.8600000000002 242.70000000000002 L 437.8600000000002 242.70000000000002 L 436.5800000000002 242.04000000000002 L 435.9700000000002 241.22000000000003 L 435.1500000000002 240.77000000000004 L 434.1600000000002 240.48000000000005 L 432.3800000000002 240.68000000000004 L 431.67000000000024 240.50000000000003 L 430.3200000000002 238.50000000000003 L 429.3300000000002 235.64000000000001 L 427.2000000000002 234.02 L 427.06000000000023 232.37 L 428.7000000000002 230.56 L 428.62000000000023 230.03 L 424.74000000000024 228.08 L 424.12000000000023 227.03 L 424.06000000000023 225.37 L 423.31000000000023 223.78 L 422.37000000000023 223.09 L 420.29000000000025 222.81 L 420.09000000000026 222.39000000000001 L 420.35000000000025 221.68 L 422.98000000000025 219.14000000000001 L 422.61000000000024 217.83 L 423.34000000000026 215.15 L 424.03000000000026 213.72 L 424.60000000000025 213.17 L 425.9400000000002 212.63 L 429.3300000000002 212.28 L 428.9400000000002 210.93 L 429.5800000000002 207.68 L 429.5000000000002 205.92000000000002 L 427.7000000000002 204.71 L 423.43000000000023 205.65 L 421.28000000000026 206.99 L 419.0100000000003 203.97 L 418.10000000000025 203.12 L 415.10000000000025 198.97 L 414.22000000000025 199.04 L 413.3800000000003 197.6 L 413.9900000000003 196.41 L 413.8800000000003 195.53 L 413.6300000000003 195.19 L 412.2600000000003 194.95 L 411.84000000000026 195.22 L 409.91000000000025 193.89 L 410.09000000000026 193.17999999999998 L 411.85000000000025 192.51999999999998 L 413.60000000000025 190.48 L 413.85000000000025 188.89 L 413.5700000000003 187.89 L 413.8800000000003 185.52999999999997 L 415.65000000000026 179.36999999999998 L 415.66000000000025 178.93999999999997 L 414.98000000000025 177.79999999999998 L 414.7500000000002 176.71999999999997 L 414.9600000000002 172.99999999999997 L 414.3200000000002 171.49999999999997 L 413.8500000000002 168.00999999999996 L 413.0100000000002 166.97999999999996 L 409.61000000000024 165.53999999999996 L 408.3900000000002 165.51999999999995 L 408.11000000000024 165.19999999999996 L 408.03000000000026 164.16999999999996 L 407.4400000000003 163.47999999999996 L 405.7000000000003 163.18999999999997 L 404.7400000000003 163.70999999999998 L 403.3400000000003 163.61999999999998 L 400.56000000000034 162.10999999999999 L 399.70000000000033 162.04999999999998 L 397.74000000000035 162.57999999999998 L 395.12000000000035 164.42999999999998 L 394.5900000000004 165.06999999999996 L 394.5900000000004 165.06999999999996 L 394.10000000000036 164.98999999999995 L 408.81000000000034 153.15999999999994 L 411.16000000000037 153.38999999999993 L 412.3300000000004 152.46999999999994 L 413.8800000000004 150.29999999999995 L 414.3100000000004 149.14999999999995 L 415.8600000000004 147.97999999999996 L 416.4800000000004 145.09999999999997 L 417.6000000000004 144.63999999999996 L 420.0400000000004 142.31999999999996 L 420.51000000000045 141.10999999999996 L 420.80000000000047 139.20999999999995 L 422.4000000000005 134.51999999999995 L 424.36000000000047 132.97999999999996 L 425.8400000000005 131.21999999999997 L 426.67000000000047 129.76999999999998 L 427.13000000000045 128.48999999999998 L 426.95000000000044 126.66999999999999 L 427.74000000000046 125.85999999999999 L 426.70000000000044 124.27999999999999 L 430.38000000000045 121.18999999999998 L 430.25000000000045 119.54999999999998 L 430.75000000000045 117.16999999999999 L 432.49000000000046 115.6 L 432.8500000000005 114.89 L 433.75000000000045 111.87 L 433.83000000000044 110.26 L 433.40000000000043 109.73 L 432.4100000000004 109.89 L 432.14000000000044 109.4 L 432.19000000000045 108.78 L 433.33000000000044 108.63 L 433.90000000000043 107.89 L 434.6100000000004 103.5 L 434.4500000000004 102.12 L 434.9200000000004 101.09 L 435.6900000000004 100.64 L 435.6900000000004 100.64 L 436.3200000000004 100.64 L 436.5600000000004 100.4 L 436.5000000000004 99.86 L 436.8400000000004 99.11 L 437.42000000000036 98.58 L 438.76000000000033 99.56 L 439.2100000000003 101.4 L 440.4000000000003 101.52000000000001 L 441.1700000000003 100.16000000000001 L 441.7800000000003 103.09000000000002 L 442.7700000000003 103.13000000000002 L 443.06000000000034 102.64000000000003 L 443.13000000000034 101.70000000000003 L 443.98000000000036 101.66000000000003 L 445.67000000000036 102.19000000000003 L 446.17000000000036 102.88000000000002 L 444.74000000000035 104.58000000000003 L 445.41000000000037 105.28000000000003 L 445.43000000000035 105.83000000000003 L 446.6400000000003 103.79000000000002 L 447.13000000000034 102.25000000000001 L 447.5800000000003 102.25000000000001 L 447.9800000000003 103.27000000000001 L 447.9800000000003 103.85000000000001 L 447.1100000000003 104.77000000000001 L 446.8400000000003 105.76 L 446.9200000000003 108.47 L 447.1800000000003 108.8 L 447.6500000000003 108.92 L 448.2300000000003 108.78 L 449.1900000000003 107.85 L 448.72000000000025 106.85 L 448.86000000000024 106.25 L 450.18000000000023 104.82 L 451.23000000000025 104.57 L 453.36000000000024 105.16 L 454.86000000000024 104.05 L 454.91000000000025 104.97 L 454.55000000000024 105.17999999999999 L 453.42000000000024 106.71 L 454.0100000000002 107.28999999999999 L 454.11000000000024 106.91999999999999 L 455.36000000000024 106.32 L 455.9400000000002 107.11 L 455.80000000000024 108.32 L 457.43000000000023 110.07 L 458.29000000000025 109.63 L 459.87000000000023 110.3 L 460.6400000000002 112.7 L 460.5300000000002 113.65 L 458.3400000000002 116.38000000000001 L 457.9600000000002 117.27000000000001 L 458.06000000000023 117.93 L 458.66000000000025 116.9 L 460.41000000000025 115.22 L 461.24000000000024 115.19 L 462.11000000000024 116 L 462.6300000000002 117.89 L 462.36000000000024 119.12 L 461.3900000000002 119.31 L 460.36000000000024 120.22 L 459.2000000000002 121.71 L 459.2700000000002 122.47999999999999 L 458.1100000000002 124.82999999999998 L 457.4900000000002 128.35 L 457.70000000000016 128.69 L 458.57 128.92 z M 459.09 129.37 L 459.03 128.58 L 459.55999999999995 127.05000000000001 L 459.1499999999999 125.98000000000002 L 459.2799999999999 125.32000000000002 L 460.18999999999994 124.08000000000003 L 460.73999999999995 123.89000000000003 L 460.78999999999996 126.24000000000002 L 460.56999999999994 127.58000000000003 L 459.7699999999999 128.18000000000004 L 459.09 129.37 z M 452.79 103.61 L 452.35 103.15 L 452.27000000000004 102.55000000000001 L 453.07000000000005 101.43 L 453.91 101.4 L 454.59000000000003 101.82000000000001 L 454.69000000000005 102.16000000000001 L 454.50000000000006 102.52000000000001 L 452.79 103.61 z M 456.29 107.79 L 456 107.49000000000001 L 456.06 106.96000000000001 L 457.12 106.07000000000001 L 457.6 106.14 L 458.1 106.99 L 457.96000000000004 107.6 L 457.56000000000006 107.42999999999999 L 456.29 107.79 z M 442.13 102.98 L 441.92 102.93 L 442.87 99.35000000000001 L 443.17 99.44000000000001 L 443.2 99.67000000000002 L 442.78999999999996 102.73000000000002 L 442.13 102.98 z"},{code:"MG",name:"Minas Gerais",gTransform:"matrix(1 0 0 1 139.79 56.66)",pathTransform:"translate(-445.79, -375.93)",d:"M 527.5 365.33 L 526.59 364.78 L 524.05 363.97 L 522.47 364.05 L 521.39 364.37 L 520.55 364.98 L 518.37 365.27 L 517.03 365.14 L 518.7 367.41 L 518.68 368.22 L 517.55 368.11 L 516.5 367.37 L 516.19 367.39 L 514.02 368.7 L 512.85 370.63 L 513.15 371.33 L 514.48 372 L 515 372.66 L 514.97 374.58 L 514.67 376.12 L 514.88 376.53 L 516.19 376.88 L 516.36 378.6 L 516.04 379.02 L 515.09 379.26 L 514.12 379.23 L 513.32 378.88 L 511.84 378.97 L 511.41 379.52 L 511.9 380.23 L 512.66 380.51 L 513.11 380.22 L 513.63 380.31 L 514.73 381.58 L 516 384.39 L 516.29 386.82 L 515.75 389.79 L 514.04 391.88 L 512.8 392.74 L 512.54 393.18 L 512.3 394.9 L 511.42 397.19 L 510.31 398.46 L 509.34 401.7 L 508.79 402.02 L 503.64 401.99 L 501.92 404.05 L 501.76 404.47 L 502.35 407.59 L 501.78 408.89 L 501.34 411.23 L 501.63 411.37 L 501.63 411.37 L 499.1 413.72 L 497.86 413.99 L 497.3 414.49 L 498.04 415.19 L 495.68 421.24 L 493.78 424.95 L 493.69 425.7 L 495.13 425.83 L 495.42 426.44 L 495.21 426.96 L 492.68 427.94 L 483.17 432.47 L 481.8 432.67 L 481.82 432.21 L 481.33 432.04 L 478.8 431.77 L 478.23 431.83 L 476.61 432.77 L 475.36 432.93 L 472.16 433.01 L 471.8 432.69 L 471.29 432.77 L 467.19 434.55 L 466.14 435.32 L 464.43 436.09 L 463.93 435.81 L 461.34 435.98 L 458.43 437.32 L 456.01 438.06 L 455.33 438.55 L 455.33 438.55 L 454.08 439.28 L 451.88 439.5 L 449.95 440.52 L 448.72 441.76 L 446.93 442.43 L 444.55 442.68 L 442.21 442.6 L 442.2 442.11 L 442.55 441.62 L 442.46 441.27 L 441.27 441.6 L 441.09 443.9 L 441.33 444.13 L 441.28 444.97 L 440.53 445.95 L 439.23 446.27 L 438.66 445.84 L 435.05 446.84 L 434.86 446.31 L 432.85 446.55 L 431.73 446.3 L 429.7 442.99 L 430.92 442.28 L 430.4 440.57 L 428.6 439.74 L 426.81 438.51 L 426.1 436.9 L 426.63 435.34 L 426.82 431.89 L 426.56 428.95 L 428.42 426.23 L 429.12 424.05 L 429.17 422.78 L 428.94 422.41 L 425.24 421.09 L 424.24 421.14 L 423.96 421.5 L 423.18 421.81 L 421.57 421.86 L 421.6 421.01 L 420.77 419.02 L 419.47 417.23 L 419.1 415.02 L 418.79 414.4 L 418 413.66 L 418.19 411.72 L 419.71 409.69 L 419.77 409.13 L 419.37 407.58 L 417.49 406.37 L 416.91 405.76 L 417.2 403.39 L 417.77 402.38 L 417.57 401.34 L 414.3 397.99 L 413 398.28 L 412.15 398.92 L 410.5 398.14 L 408.12 398.25 L 407.81 398.86 L 408.01 399.32 L 407.57 400.31 L 404.79 400.99 L 403.68 400.56 L 402.17 399.11 L 401.16 400.36 L 392.98 401.04 L 392.52 401.52 L 392.04 402.71 L 392.31 405.25 L 391.9 405.69 L 390.71 405.17 L 390.7 402.39 L 390.45 401.43 L 390.09 401.04 L 389.53 400.99 L 389.27 401.18 L 388.86 402.31 L 388.19 403.25 L 387.65 403.57 L 387.03 403.55 L 385.82 401.45 L 385.49 400.03 L 385.63 399.12 L 383.95 398.33 L 381.77 396.91 L 379.78 397.5 L 378.16 397.28 L 376.49 397.63 L 372.2 396.67 L 369.65 396.59 L 367.92 395.04 L 367.17 394.9 L 365.67 395.51 L 364.24 397.2 L 362.32 397.57 L 360.17 398.68 L 358.95 399.81 L 358.95 399.81 L 359.26 397.19 L 358.67 393.98 L 359.66 389.8 L 360.24 389.55 L 360.24 389.55 L 361.1 390.01 L 361.46 389.78 L 361.47 389.44 L 360.91 388.83 L 361.48 386.93 L 363.12 384.83 L 364.06 384.09 L 364.51 383.95 L 365.35 384.11 L 366.17 383.83 L 367.01 382.53 L 366.95 381.53 L 368.16 379.07 L 369.57 376.97 L 371.8 376.43 L 374.28 375.47 L 377.99 376.09 L 381.18 374.45 L 382.7 374.75 L 384.01 376.17 L 384.34 376.17 L 387.25 373.25 L 391.38 370.61 L 393.39 371.5 L 397.25 371.34 L 398.73 371.62 L 400.48 371.61 L 401.06 371.52 L 401.61 371.04 L 405.96 372.9 L 406.66 373.67 L 411.55 370.93 L 412.03 369.81 L 412.89 368.91 L 414.05 368.71 L 417.14 366.65 L 415.95 363.19 L 416.46 361.3 L 417.19 360.4 L 417.36 359.69 L 417.18 358.69 L 416.71 358.08 L 415.13 357.51 L 414.23 357.98 L 413.14 356.87 L 413.57 354.73 L 416.81 351.72 L 419.13 349.01 L 419.13 348.41 L 417.48 343.85 L 416.06 342.82 L 415.21 342.48 L 414.36 341.27 L 414.77 339.8 L 415.81 338.55 L 416.49 336.96 L 416.18 335.39 L 416.71 333.87 L 417.98 333.75 L 420.27 332.24 L 423.63 331.34 L 424.16 330.81 L 423.47 326.55 L 422.94 326.36 L 422.52 325.75 L 422.48 323.85 L 423.21 323.15 L 423.78 322.21 L 423.29 321.05 L 422.57 320.95 L 423.29 317.77 L 423.66 317.49 L 424.83 317.26 L 427.61 318.4 L 428.01 318.27 L 428.58 317.73 L 428 313.96 L 429.17 312.47 L 431.59 313.95 L 432.49 315.71 L 435.72 316.05 L 436.72 315.04 L 436.72 315.04 L 437.23 317.45 L 435.8 320.89 L 436.2 321.12 L 437.54 320.21 L 438.24 319.21 L 438.96 319.08 L 441.09 319.46 L 442.13 318.69 L 443.98 316.12 L 444.97 316.27 L 446.4 315.74 L 448.21 314.19 L 449.16 313.02 L 451.18 312.61 L 454.55 310.75 L 455.19 309.64 L 459.46 306.61 L 463.28 305.03 L 465.08 305.12 L 466.28 305.62 L 468.46 305.65 L 470.74 306.18 L 471.59 306.64 L 470.3 309.38 L 470.15 310.27 L 470.41 311.76 L 471.02 312.26 L 476.35 313.72 L 476.99 313.55 L 477.8 312.43 L 479.68 311.54 L 481.45 311.28 L 484.18 312.03 L 485.28 312.57 L 489.63 316.21 L 490.61 316.03 L 492.78 317.65 L 495.31 318.87 L 496.24 319.09 L 496.75 318.88 L 498.28 320.12 L 502.67 318.89 L 503.05 319.07 L 509.57 325.27 L 510.01 329.23 L 510.58 329.02 L 513.19 329.47 L 514.66 328.97 L 515.98 327.98 L 517.97 328.13 L 520.7 328.69 L 522.96 329.77 L 525.15 330.38 L 527.27 330.35 L 530.1 332.82 L 530.83 333.2 L 531.72 333.27 L 532.5 334.29 L 532.92 335.46 L 531.45 338.54 L 526.49 342.76 L 526.34 345.41 L 526.9 346.43 L 526.9 346.85 L 525.88 347.56 L 523.4 347.32 L 522.58 348.2 L 521.76 351.5 L 521.23 355.9 L 521.45 356.15 L 521.8 355.96 L 522 355.51 L 522.64 355.27 L 523.22 356.5 L 523 358.01 L 523.15 358.52 L 527.29 361.58 L 527.82 362.62 L 527.83 363.15 L 527.15 364.5 z"},{code:"MS",name:"Mato Grosso do Sul",gTransform:"matrix(1 0 0 1 -2.22 90.13)",pathTransform:"translate(-303.77, -409.4)",d:"M 358.95 399.81 L 358.55 402.27 L 358.27 402.67 L 356.77 403.45 L 355.45 403.49 L 354.98 403.71 L 353.76 404.74 L 351.77 407.42 L 351.04 408.07 L 350.03 408.37 L 349.41 410.05 L 349.25 412.98 L 346.66 416.62 L 345.7 417.14 L 345.47 417.52 L 345.78 419.45 L 345.7 420.4 L 344.49 422.74 L 342.49 425 L 342.84 425.85 L 342.56 427.06 L 341.12 428.09 L 340.72 429.3 L 338.99 430.99 L 337.73 433.43 L 335.78 435.3 L 328.22 439.83 L 326.96 440.97 L 326.22 442.51 L 325.38 443.59 L 325.38 443.59 L 319.97 445.86 L 318.86 446.68 L 317.93 449.01 L 317.95 450.16 L 316.5 453.72 L 315.83 454.4 L 314.17 455.41 L 313.06 455.73 L 312.73 456.08 L 311.16 464 L 310.8 464.82 L 308.42 466.38 L 308.42 466.38 L 305.87 464.05 L 302.46 462.16 L 298.47 464.13 L 297.79 464.88 L 296.13 465.37 L 293.55 465.8 L 291.19 465.34 L 290.18 464.69 L 289.71 460.42 L 289.39 459.72 L 288.49 458.77 L 288.26 456.3 L 288.77 454.96 L 288.13 454.17 L 288.04 453.73 L 288.04 450.86 L 287.15 448.89 L 286.55 446.15 L 286.5 445.43 L 287.09 444.07 L 287.11 442.46 L 285.54 441.37 L 285.16 440.57 L 285 438.41 L 283.35 436.59 L 281.18 436.33 L 279.67 436.64 L 277.84 436.35 L 275.38 434.39 L 274.82 432.9 L 273.28 433.23 L 271.11 435.97 L 270.11 435.37 L 268.39 436.18 L 267.31 436.34 L 265.57 435.65 L 263.01 435.16 L 259.55 435.39 L 255.89 434.68 L 255.41 433.77 L 253.42 433.64 L 252.53 434.16 L 250.03 433.28 L 250.94 426.01 L 250.51 423.63 L 251.11 422.21 L 252.09 420.75 L 252.69 414.72 L 252.03 412.39 L 251.98 410.66 L 251.22 409.7 L 250.79 409.61 L 250.3 410.26 L 249.66 407 L 248.87 405.13 L 247.66 403.11 L 247.31 401.28 L 251.34 398.98 L 252.1 398.1 L 247.9 394.24 L 253.28 382.82 L 254.4 382.76 L 254.12 380.63 L 253.38 380.5 L 256.61 370.17 L 257.27 369.01 L 254.18 363.16 L 254.21 361.25 L 254.21 361.25 L 254.91 361.45 L 255.93 362.55 L 258.08 364.07 L 263.7 362.1 L 265.75 360.1 L 267.77 357.15 L 267.86 355.98 L 269.26 354.53 L 271.85 354.56 L 273.41 354.34 L 274.18 354.68 L 275.84 354.17 L 277.19 352.92 L 279.21 352.43 L 280.48 352.63 L 281.24 353.78 L 284.03 355.03 L 286.65 355.5 L 287.3 355.85 L 287.57 356.71 L 288.35 357.73 L 291.38 358.89 L 292.64 360 L 293.88 360.57 L 298.4 359.94 L 299.66 359.14 L 300.15 358.29 L 301.58 357.68 L 304.02 357.75 L 305.61 358.79 L 305.91 360.16 L 306.15 360.41 L 307.14 360.45 L 309.27 359.57 L 310.28 359.63 L 315.9 353.62 L 317.24 353.49 L 316.01 360.1 L 314.21 360.8 L 312.55 363.63 L 312.36 364.09 L 312.51 364.62 L 313.81 364.73 L 315.55 366 L 320.17 366.27 L 320.74 365.7 L 323.4 365.62 L 324.27 365.7 L 325.44 366.27 L 326.99 365.96 L 326.99 365.96 L 327.18 367.73 L 326.92 370.31 L 327.15 371.42 L 327.43 371.83 L 328.09 372.02 L 329.23 371.35 L 331.48 372.25 L 331.56 372.67 L 330.25 374.43 L 329.68 375.6 L 329.42 376.44 L 329.55 376.77 L 333.35 377.47 L 336.13 377.31 L 338.83 378.99 L 339.97 379.16 L 341.41 379.87 L 342.08 380.48 L 345.15 382.04 L 345.83 382.89 L 349.18 384.23 L 350.67 384.27 L 352.57 384.7 L 354.19 386.25 L 357.34 386.86 L 360 389.1 L 360.24 389.55 L 360.24 389.55 L 359.66 389.8 L 358.67 393.98 L 359.26 397.19 z"},{code:"MT",name:"Mato Grosso",gTransform:"matrix(1 0 0 1 -23.8 -38.15)",pathTransform:"translate(-282.2, -281.12)",d:"M 206.96 296.05 L 208.43 294.62 L 212.54 292.05 L 213.06 289.6 L 214.49 285.82 L 215.42 284.74 L 217.06 284.21 L 217.49 283.8 L 218.07 282.96 L 218.59 280.71 L 220.25 278.7 L 220.81 276.46 L 220.88 274.75 L 220.3 273.26 L 220.34 271.21 L 218.81 267.87 L 217.91 267.9 L 217.33 267.39 L 216.9 264.14 L 217.04 262.82 L 218.4 261.74 L 219.8 259.99 L 219.97 259.24 L 218.56 255.65 L 217.49 255.22 L 216.38 255.11 L 212.88 255.2 L 211.66 254.09 L 211.9 253.53 L 194.74 253.48 L 195.64 244.48 L 194.14 241.73 L 193.87 239.97 L 193.9 239.17 L 194.9 235.65 L 194.52 233.72 L 195.46 232.05 L 194.63 229.78 L 194.48 228.39 L 194.22 227.78 L 193.44 227.31 L 193.38 226.96 L 194.67 221.97 L 195.43 220.55 L 194.83 219.31 L 193.43 218.34 L 193.43 218.34 L 241.28 218.02 L 242.49 217.29 L 243.67 212.07 L 245.05 207.85 L 244.59 205.91 L 243.93 204.54 L 243.83 203.69 L 244.25 202.84 L 245.11 202.2 L 246.31 200.38 L 246.58 199.37 L 246.24 198.53 L 246.3 197.77 L 246.5 197.16 L 247.68 195.96 L 247.68 195.96 L 248.85 197.04 L 251.3 201.1 L 251.7 202.86 L 253.07 206.82 L 254.39 208.75 L 255.16 210.37 L 254.93 212.81 L 255.41 215.21 L 256.14 217.41 L 257.67 218.52 L 260.67 221.27 L 264.05 222.97 L 264.28 223.91 L 264.24 225.01 L 264.47 225.5 L 265.42 225.9 L 266.24 225.73 L 267.87 226.18 L 268.41 226.9 L 268.61 227.98 L 268.96 228.3 L 270.33 227.85 L 274.02 229.34 L 308.06 231.76 L 371.03 235.24 L 371.03 235.24 L 370.38 236.26 L 369.82 238.15 L 368.72 239.4 L 368.28 242.54 L 367.85 243.39 L 367.48 243.66 L 365.54 248.95 L 365 251.92 L 364.96 254.87 L 363.08 260.86 L 363.14 261.72 L 364.53 263.06 L 364.37 263.93 L 363.55 264.82 L 363.5 265.32 L 364.6 267.57 L 364.13 270.88 L 364.14 272.45 L 364.66 273.03 L 365.1 276.08 L 364.36 278.84 L 365.34 282.18 L 366.3 282.69 L 367.1 282.71 L 367.1 282.71 L 367.18 283.34 L 366.91 284.47 L 365.94 285.33 L 365.59 286.23 L 365.75 288.95 L 365.36 290.02 L 363.36 293.19 L 362.33 295.82 L 361.12 296.6 L 361.24 301.78 L 359.64 304.87 L 359.06 307.61 L 359.54 308.75 L 359.55 309.55 L 358.38 312.42 L 357.54 315.35 L 356.15 316.78 L 354.94 317.51 L 353.71 316.83 L 352.64 317.09 L 350.99 318.1 L 349.07 320.04 L 348.69 320.78 L 348.05 324.88 L 347.34 325.84 L 345.36 330.03 L 345.04 330.31 L 342.32 331.17 L 339.67 331.3 L 338.27 333.92 L 336.52 334.89 L 336.44 336.43 L 335.62 337.86 L 334.34 338.9 L 333.84 339.91 L 333.51 341.86 L 332.26 343.88 L 330.34 345.65 L 328.32 346.49 L 327.62 347.26 L 327.24 350.17 L 324.69 354.02 L 324.29 357.43 L 324.45 358.14 L 325.86 360.33 L 326.04 363.76 L 326.99 365.96 L 326.99 365.96 L 325.44 366.27 L 324.27 365.7 L 323.4 365.62 L 320.74 365.7 L 320.17 366.27 L 315.55 366 L 313.81 364.73 L 312.51 364.62 L 312.36 364.09 L 312.55 363.63 L 314.21 360.8 L 316.01 360.1 L 317.24 353.49 L 315.9 353.62 L 310.28 359.63 L 309.27 359.57 L 307.14 360.45 L 306.15 360.41 L 305.91 360.16 L 305.61 358.79 L 304.02 357.75 L 301.58 357.68 L 300.15 358.29 L 299.66 359.14 L 298.4 359.94 L 293.88 360.57 L 292.64 360 L 291.38 358.89 L 288.35 357.73 L 287.57 356.71 L 287.3 355.85 L 286.65 355.5 L 284.03 355.03 L 281.24 353.78 L 280.48 352.63 L 279.21 352.43 L 277.19 352.92 L 275.84 354.17 L 274.18 354.68 L 273.41 354.34 L 271.85 354.56 L 269.26 354.53 L 267.86 355.98 L 267.77 357.15 L 265.75 360.1 L 263.7 362.1 L 258.08 364.07 L 255.93 362.55 L 254.91 361.45 L 254.21 361.25 L 254.21 361.25 L 253.55 360.58 L 253.23 359.78 L 253.77 359.07 L 251.33 356.92 L 250.05 357.55 L 249.53 357.5 L 248.36 356.82 L 247.91 356.12 L 245.89 354.71 L 244 353.95 L 243.7 353.63 L 243.4 352.51 L 243.17 349.58 L 242.56 347.81 L 242.37 344.15 L 243.25 342.51 L 244.39 341.42 L 244.73 339.64 L 244.68 337.75 L 243.72 337.81 L 243.32 338.41 L 242.94 338.57 L 216.08 337.49 L 215.03 324.84 L 209.66 318.71 L 214.54 318.65 L 214.19 311.1 L 211.55 305.78 L 211.06 303.81 L 211.32 302.75 L 211.93 302.2 L 212.58 300.92 L 211.14 297.99 L 208.03 296.95 z"},{code:"PA",name:"Pará",gTransform:"matrix(1 0 0 1 29.16 -180.48)",pathTransform:"translate(-335.15, -138.78)",d:"M 371.03 235.24 L 308.05999999999995 231.76000000000002 L 274.0199999999999 229.34000000000003 L 270.3299999999999 227.85000000000002 L 268.9599999999999 228.3 L 268.6099999999999 227.99 L 268.4099999999999 226.9 L 267.8599999999999 226.18 L 266.2299999999999 225.73000000000002 L 265.4099999999999 225.9 L 264.4599999999999 225.51000000000002 L 264.2299999999999 225.01000000000002 L 264.2699999999999 223.91000000000003 L 264.0399999999999 222.97000000000003 L 260.6599999999999 221.27000000000004 L 257.6599999999999 218.51000000000005 L 256.1199999999999 217.40000000000003 L 255.3999999999999 215.20000000000005 L 254.9199999999999 212.81000000000006 L 255.1499999999999 210.37000000000006 L 254.37999999999988 208.74000000000007 L 253.04999999999987 206.81000000000006 L 251.67999999999986 202.86000000000007 L 251.28999999999988 201.10000000000008 L 248.8399999999999 197.04000000000008 L 247.65999999999988 195.96000000000006 L 247.65999999999988 195.96000000000006 L 247.0899999999999 195.40000000000006 L 246.93999999999988 193.44000000000005 L 246.2999999999999 192.18000000000006 L 244.7099999999999 190.62000000000006 L 243.6399999999999 190.04000000000005 L 243.2699999999999 189.47000000000006 L 242.43999999999988 187.13000000000005 L 242.46999999999989 186.00000000000006 L 243.0499999999999 185.03000000000006 L 244.4999999999999 183.90000000000006 L 245.2799999999999 182.59000000000006 L 275.1799999999999 118.35000000000007 L 273.3699999999999 116.68000000000006 L 273.4999999999999 115.90000000000006 L 273.3099999999999 115.42000000000006 L 271.9199999999999 115.77000000000005 L 271.0699999999999 116.38000000000005 L 269.1999999999999 115.60000000000005 L 268.09999999999985 113.43000000000005 L 265.40999999999985 111.98000000000005 L 264.1399999999999 110.64000000000004 L 264.0599999999999 110.04000000000005 L 262.7399999999999 109.22000000000006 L 261.3699999999999 109.07000000000005 L 259.1199999999999 108.42000000000004 L 256.7399999999999 107.11000000000004 L 254.8599999999999 106.44000000000004 L 253.5099999999999 105.35000000000004 L 252.8799999999999 104.45000000000003 L 248.2999999999999 101.91000000000003 L 243.6599999999999 98.14000000000003 L 243.3599999999999 97.70000000000003 L 243.3199999999999 96.77000000000002 L 242.7699999999999 94.94000000000003 L 240.9299999999999 93.71000000000002 L 240.2299999999999 93.90000000000002 L 239.8699999999999 93.70000000000002 L 238.03999999999988 91.72000000000001 L 238.0899999999999 89.61000000000001 L 238.43999999999988 88.92000000000002 L 238.25999999999988 88.51000000000002 L 236.56999999999988 87.66000000000003 L 236.32999999999987 86.98000000000002 L 236.14999999999986 84.71000000000002 L 236.57999999999987 83.26000000000002 L 236.17999999999986 78.40000000000002 L 236.17999999999986 78.40000000000002 L 234.58999999999986 61.43000000000002 L 234.58999999999986 61.43000000000002 L 235.33999999999986 61.75000000000002 L 235.76999999999987 62.33000000000002 L 235.74999999999986 62.81000000000002 L 236.19999999999985 63.210000000000015 L 237.11999999999983 63.490000000000016 L 238.48999999999984 62.780000000000015 L 238.95999999999984 61.97000000000001 L 241.66999999999985 62.20000000000001 L 242.47999999999985 61.15000000000001 L 241.93999999999986 59.34000000000001 L 243.72999999999985 58.98000000000001 L 245.13999999999984 57.35000000000001 L 247.77999999999983 58.36000000000001 L 249.65999999999983 58.39000000000001 L 250.19999999999982 56.870000000000005 L 253.52999999999983 55.25000000000001 L 255.49999999999983 55.64000000000001 L 256.65999999999985 55.53000000000001 L 257.14999999999986 55.28000000000001 L 258.34999999999985 53.80000000000001 L 258.74999999999983 52.40000000000001 L 260.2099999999998 51.30000000000001 L 261.0699999999998 51.19000000000001 L 261.7199999999998 51.65000000000001 L 263.8299999999998 50.52000000000001 L 264.23999999999984 50.63000000000001 L 264.60999999999984 51.62000000000001 L 265.33999999999986 52.070000000000014 L 267.36999999999983 52.55000000000001 L 268.97999999999985 52.80000000000001 L 269.53999999999985 52.20000000000001 L 271.20999999999987 51.81000000000001 L 271.98999999999984 52.09000000000001 L 272.80999999999983 52.08000000000001 L 273.66999999999985 51.74000000000001 L 275.90999999999985 52.040000000000006 L 280.57999999999987 53.42000000000001 L 281.53999999999985 53.28000000000001 L 282.53999999999985 52.41000000000001 L 282.5099999999999 50.13000000000001 L 280.4399999999999 47.63000000000001 L 279.1999999999999 47.00000000000001 L 279.6899999999999 45.32000000000001 L 280.9999999999999 43.870000000000005 L 281.27999999999986 42.760000000000005 L 281.58999999999986 42.59 L 282.29999999999984 42.78 L 283.1299999999998 43.54 L 285.47999999999985 44.65 L 297.09999999999985 42.32 L 298.66999999999985 44.01 L 299.6899999999998 44.07 L 300.1299999999998 43.78 L 300.1299999999998 43.78 L 300.74999999999983 44.35 L 301.11999999999983 46.65 L 300.49999999999983 47.949999999999996 L 300.24999999999983 52.489999999999995 L 300.48999999999984 53.92999999999999 L 300.79999999999984 54.46999999999999 L 301.96999999999986 54.489999999999995 L 303.04999999999984 54.199999999999996 L 306.4399999999998 54.56999999999999 L 307.72999999999985 55.059999999999995 L 309.65999999999985 56.10999999999999 L 310.32999999999987 56.90999999999999 L 310.8199999999999 58.18999999999999 L 312.0099999999999 58.30999999999999 L 313.14999999999986 59.14999999999999 L 313.9499999999999 60.12999999999999 L 314.78999999999985 60.39999999999999 L 316.11999999999983 60.25999999999999 L 316.49999999999983 59.83999999999999 L 317.4399999999998 59.69999999999999 L 320.2799999999998 62.359999999999985 L 320.9599999999998 62.329999999999984 L 321.4499999999998 63.509999999999984 L 320.7699999999998 63.73999999999998 L 320.5799999999998 64.45999999999998 L 321.3399999999998 67.28999999999998 L 323.3599999999998 69.54999999999998 L 325.9299999999998 70.27999999999999 L 326.0999999999998 70.60999999999999 L 325.6699999999998 73.74999999999999 L 325.8599999999998 75.85999999999999 L 326.5299999999998 77.36999999999999 L 327.1499999999998 77.92999999999999 L 327.7399999999998 79.74 L 327.6099999999998 81.32 L 329.1099999999998 84.8 L 329.9299999999998 84.99 L 330.70999999999975 84.63 L 333.63999999999976 87.91 L 333.5599999999998 90.34 L 333.9699999999998 91.28 L 334.9199999999998 91.47 L 335.2499999999998 91.94 L 335.5599999999998 93.52 L 335.3499999999998 94.21 L 335.4599999999998 95.50999999999999 L 337.3299999999998 96.89999999999999 L 337.7599999999998 98.39999999999999 L 339.2099999999998 99.42999999999999 L 341.99999999999983 100.11 L 343.29999999999984 99.99 L 344.0699999999998 99.64999999999999 L 345.0099999999998 99.71 L 345.0099999999998 99.71 L 344.47999999999985 100.44999999999999 L 344.76999999999987 102.03999999999999 L 344.59999999999985 102.57 L 343.30999999999983 103.67999999999999 L 341.91999999999985 103.85 L 341.41999999999985 103.66999999999999 L 340.57999999999987 102.87999999999998 L 339.91999999999985 102.72999999999998 L 336.53999999999985 104.30999999999997 L 336.16999999999985 104.84999999999998 L 334.5699999999998 105.56999999999998 L 333.9399999999998 105.54999999999998 L 332.3899999999998 106.13999999999999 L 332.42999999999984 106.71999999999998 L 338.8899999999998 105.65999999999998 L 339.7699999999998 106.31999999999998 L 339.8999999999998 106.77999999999997 L 339.8999999999998 107.43999999999997 L 339.2799999999998 107.93999999999997 L 339.5799999999998 108.29999999999997 L 340.2099999999998 108.09999999999997 L 341.0699999999998 107.09999999999997 L 342.0899999999998 107.08999999999996 L 342.6199999999998 106.81999999999996 L 343.2199999999998 106.93999999999997 L 344.2899999999998 106.51999999999997 L 345.4299999999998 105.94999999999997 L 348.70999999999975 103.60999999999997 L 350.20999999999975 103.25999999999998 L 352.0499999999997 102.44999999999997 L 355.20999999999975 100.60999999999997 L 355.7499999999998 99.60999999999997 L 356.4199999999998 99.08999999999997 L 358.50999999999976 98.07999999999997 L 359.1699999999998 97.35999999999997 L 358.9199999999998 96.68999999999997 L 359.12999999999977 96.27999999999997 L 360.25999999999976 95.99999999999997 L 361.34999999999974 96.05999999999997 L 361.75999999999976 96.26999999999997 L 362.13999999999976 100.06999999999996 L 361.6199999999998 102.64999999999996 L 361.94999999999976 104.26999999999997 L 362.75999999999976 105.86999999999996 L 364.06999999999977 107.21999999999996 L 364.3699999999998 108.85999999999996 L 364.2499999999998 109.32999999999996 L 362.4099999999998 111.16999999999996 L 361.93999999999977 111.29999999999995 L 361.06999999999977 110.77999999999996 L 359.2499999999998 110.25999999999996 L 357.9899999999998 109.94999999999996 L 357.0599999999998 110.08999999999996 L 354.9299999999998 109.04999999999995 L 354.6699999999998 107.92999999999995 L 353.7899999999998 107.39999999999995 L 351.5099999999998 111.21999999999994 L 350.8999999999998 113.58999999999995 L 351.5799999999998 116.55999999999995 L 352.05999999999983 117.19999999999995 L 352.97999999999985 117.81999999999995 L 351.96999999999986 116.67999999999995 L 351.53999999999985 113.98999999999995 L 351.65999999999985 113.46999999999996 L 354.22999999999985 109.24999999999996 L 356.53999999999985 110.42999999999996 L 356.64999999999986 110.87999999999997 L 359.17999999999984 113.32999999999997 L 358.92999999999984 115.34999999999997 L 358.1899999999998 115.89999999999996 L 358.5899999999998 118.22999999999996 L 359.1099999999998 119.35999999999996 L 360.2299999999998 120.10999999999996 L 360.9699999999998 120.25999999999996 L 361.4899999999998 120.74999999999996 L 361.1499999999998 120.10999999999996 L 360.3799999999998 119.86999999999996 L 359.17999999999984 118.82999999999996 L 358.9599999999998 118.14999999999995 L 359.2999999999998 113.94999999999995 L 360.1199999999998 112.75999999999995 L 361.5499999999998 113.48999999999995 L 362.37999999999977 114.68999999999996 L 362.2899999999998 115.47999999999996 L 363.4899999999998 116.33999999999996 L 363.7399999999998 116.04999999999995 L 362.7399999999998 114.78999999999995 L 361.81999999999977 112.68999999999996 L 361.81999999999977 112.24999999999996 L 364.07999999999976 109.92999999999996 L 365.69999999999976 110.01999999999997 L 367.62999999999977 110.65999999999997 L 367.96999999999974 111.21999999999997 L 367.35999999999973 111.80999999999997 L 367.6799999999997 112.08999999999997 L 368.15999999999974 112.11999999999998 L 369.1899999999997 111.94999999999997 L 370.5199999999997 111.04999999999997 L 374.6099999999997 110.08999999999997 L 375.37999999999965 110.28999999999998 L 377.11999999999966 111.34999999999998 L 380.2899999999997 110.92999999999998 L 381.3599999999997 110.51999999999998 L 382.37999999999965 109.50999999999998 L 383.3599999999997 108.91999999999997 L 385.0999999999997 108.40999999999997 L 385.86999999999966 108.47999999999996 L 385.92999999999967 109.22999999999996 L 383.88999999999965 113.24999999999996 L 383.64999999999964 114.74999999999996 L 383.18999999999966 115.81999999999995 L 382.3599999999997 116.84999999999995 L 382.3499999999997 117.72999999999995 L 382.92999999999967 119.14999999999995 L 382.6099999999997 121.61999999999995 L 383.48999999999967 120.42999999999995 L 383.49999999999966 119.02999999999994 L 385.0399999999997 116.02999999999994 L 386.1699999999997 112.83999999999995 L 387.2899999999997 111.27999999999994 L 387.55999999999966 111.00999999999995 L 388.31999999999965 110.95999999999995 L 388.89999999999964 110.60999999999996 L 390.71999999999963 110.37999999999995 L 391.5999999999996 109.02999999999996 L 393.1099999999996 107.33999999999996 L 394.46999999999963 105.07999999999996 L 394.9899999999996 104.61999999999996 L 395.77999999999963 105.10999999999996 L 396.39999999999964 104.64999999999996 L 398.01999999999964 106.98999999999997 L 399.20999999999964 107.57999999999997 L 399.1599999999996 106.83999999999997 L 398.8099999999996 106.08999999999997 L 399.4299999999996 105.07999999999997 L 402.9399999999996 104.56999999999996 L 401.9099999999996 104.24999999999997 L 398.39999999999964 104.70999999999997 L 398.08999999999963 104.49999999999997 L 398.37999999999965 102.06999999999996 L 398.88999999999965 101.77999999999996 L 399.55999999999966 102.15999999999995 L 400.57999999999964 102.26999999999995 L 401.64999999999964 99.16999999999996 L 400.96999999999963 97.77999999999996 L 400.9999999999996 97.09999999999995 L 402.1699999999996 95.28999999999995 L 405.0099999999996 92.80999999999995 L 405.3699999999996 92.72999999999995 L 406.4799999999996 93.86999999999995 L 409.4099999999996 91.77999999999994 L 409.8699999999996 91.70999999999995 L 410.2699999999996 92.15999999999995 L 410.3699999999996 92.72999999999995 L 410.0499999999996 93.39999999999995 L 411.1199999999996 93.23999999999995 L 411.9299999999996 92.65999999999995 L 412.2899999999996 91.87999999999995 L 412.9199999999996 91.68999999999996 L 413.1999999999996 91.83999999999996 L 413.9399999999996 93.22999999999996 L 415.2699999999996 94.42999999999996 L 415.4699999999996 93.86999999999996 L 415.35999999999956 93.48999999999997 L 414.4 93 L 414.26 92.71 L 414.13 91.50999999999999 L 414.3 91.08999999999999 L 414.74 90.89999999999999 L 417.02 91.16 L 418.2 91.81 L 418.82 92.83 L 420.45 93.53999999999999 L 422.09999999999997 92.75999999999999 L 422.62999999999994 94.89999999999999 L 422.12999999999994 95.21 L 422.09999999999997 95.8 L 423.02 95.28 L 424.18 92.93 L 424.56 93.16000000000001 L 424.33 94.49000000000001 L 424.74 94.93 L 427.25 94.67 L 427.7 95.32000000000001 L 428.15999999999997 97.00000000000001 L 427.55999999999995 97.95000000000002 L 428.40999999999997 97.45000000000002 L 428.66999999999996 97.82000000000002 L 430.55999999999995 97.96000000000002 L 434.0899999999999 96.72000000000003 L 433.7799999999999 98.30000000000003 L 433.0299999999999 100.13000000000002 L 434.49999999999994 99.64000000000003 L 435.0899999999999 99.02000000000002 L 435.7199999999999 100.64000000000003 L 435.7199999999999 100.64000000000003 L 434.94999999999993 101.09000000000003 L 434.4799999999999 102.12000000000003 L 434.63999999999993 103.50000000000003 L 433.92999999999995 107.89000000000003 L 433.35999999999996 108.63000000000002 L 432.21999999999997 108.78000000000003 L 432.16999999999996 109.40000000000003 L 432.43999999999994 109.89000000000003 L 433.42999999999995 109.73000000000003 L 433.85999999999996 110.26000000000003 L 433.78 111.87000000000003 L 432.88 114.89000000000003 L 432.52 115.60000000000002 L 430.78 117.17000000000002 L 430.28 119.55000000000001 L 430.40999999999997 121.19000000000001 L 426.72999999999996 124.28000000000002 L 427.77 125.86000000000001 L 426.97999999999996 126.67000000000002 L 427.15999999999997 128.49 L 426.7 129.77 L 425.87 131.22 L 424.39 132.98 L 422.43 134.51999999999998 L 420.83 139.20999999999998 L 420.53999999999996 141.10999999999999 L 420.06999999999994 142.32 L 417.62999999999994 144.64 L 416.50999999999993 145.1 L 415.88999999999993 147.98 L 414.3399999999999 149.14999999999998 L 413.9099999999999 150.29999999999998 L 412.3599999999999 152.46999999999997 L 411.1899999999999 153.38999999999996 L 408.83999999999986 153.15999999999997 L 394.1299999999999 164.98999999999998 L 394.6199999999999 165.07 L 394.6199999999999 165.07 L 396.9099999999999 165.88 L 398.7799999999999 165.64 L 400.06999999999994 165.76 L 401.0899999999999 167.42 L 401.4799999999999 167.73 L 402.3499999999999 167.86999999999998 L 403.6099999999999 169.03999999999996 L 403.5699999999999 169.66999999999996 L 403.1999999999999 170.33999999999995 L 402.47999999999985 170.70999999999995 L 401.5099999999998 170.77999999999994 L 401.2199999999998 171.05999999999995 L 401.3099999999998 172.46999999999994 L 402.31999999999977 173.80999999999995 L 401.39999999999975 176.55999999999995 L 400.75999999999976 177.03999999999994 L 399.2999999999998 177.49999999999994 L 399.0499999999998 177.95999999999995 L 399.3399999999998 179.15999999999994 L 399.1499999999998 180.49999999999994 L 397.8499999999998 180.64999999999995 L 396.3399999999998 181.98999999999995 L 395.4899999999998 183.25999999999996 L 395.63999999999976 184.76999999999995 L 395.39999999999975 185.26999999999995 L 392.89999999999975 186.46999999999994 L 389.4899999999997 187.60999999999993 L 387.0199999999997 189.38999999999993 L 386.8299999999997 189.73999999999992 L 387.2599999999997 191.92999999999992 L 387.3199999999997 194.5999999999999 L 386.03999999999974 196.6999999999999 L 384.6299999999997 198.3799999999999 L 384.47999999999973 198.9499999999999 L 384.64999999999975 199.8299999999999 L 385.2399999999997 200.7899999999999 L 386.90999999999974 202.52999999999992 L 387.65999999999974 202.8499999999999 L 387.8099999999997 203.14999999999992 L 387.1499999999997 207.1899999999999 L 385.3899999999997 212.33999999999992 L 384.3099999999997 213.14999999999992 L 382.60999999999973 216.38999999999993 L 382.4299999999997 217.37999999999994 L 381.4899999999997 218.91999999999993 L 380.7499999999997 219.76999999999992 L 379.6999999999997 219.92999999999992 L 378.3299999999997 220.8499999999999 L 377.2999999999997 222.7699999999999 L 376.08999999999975 224.4499999999999 L 374.90999999999974 225.5399999999999 L 373.75999999999976 227.11999999999992 L 372.62999999999977 231.57999999999993 L 371.03 235.24 z M 392.19 104.93 L 387.67 106.89 L 384.28000000000003 107.41 L 382.26000000000005 107.1 L 381.61000000000007 108.22999999999999 L 379.7700000000001 109.41999999999999 L 379.05000000000007 108.80999999999999 L 378.44000000000005 107.27999999999999 L 378.21000000000004 107.55999999999999 L 378.63000000000005 108.78999999999999 L 378.2900000000001 109.6 L 377.5800000000001 110.00999999999999 L 373.8100000000001 108.36999999999999 L 373.0100000000001 109.08999999999999 L 368.8200000000001 110.35 L 365.6200000000001 109.78 L 364.8100000000001 109.17 L 364.5700000000001 107.32000000000001 L 364.3400000000001 106.91000000000001 L 363.2300000000001 105.89000000000001 L 362.1700000000001 104.29000000000002 L 361.9600000000001 102.51000000000002 L 362.4800000000001 99.76000000000002 L 363.1000000000001 99.38000000000002 L 364.86000000000007 99.74000000000002 L 365.7900000000001 98.99000000000002 L 365.87000000000006 98.43000000000002 L 364.57000000000005 98.86000000000003 L 363.35 98.73000000000003 L 362.41 98.02000000000004 L 362.23 96.97000000000004 L 362.57 91.89000000000004 L 363.3 91.13000000000004 L 363.65000000000003 91.88000000000004 L 365.41 92.48000000000003 L 365.96000000000004 92.42000000000003 L 365.50000000000006 92.00000000000003 L 364.2300000000001 91.78000000000003 L 363.3300000000001 89.62000000000003 L 363.6900000000001 87.94000000000003 L 364.5800000000001 85.97000000000003 L 365.9100000000001 84.64000000000003 L 366.87000000000006 84.07000000000004 L 368.21000000000004 83.58000000000004 L 369.53000000000003 83.45000000000005 L 372.99 83.97000000000004 L 380.2 85.74000000000004 L 383.9 85.28000000000004 L 384.01 84.98000000000005 L 385.15 84.36000000000004 L 387.31 83.99000000000004 L 390.2 84.28000000000004 L 393 85.10000000000004 L 399.48 85.95000000000003 L 400.11 86.42000000000003 L 400.06 87.65000000000003 L 399.36 88.39000000000003 L 398.68 89.89000000000003 L 398.32 92.54000000000003 L 397.46 95.84000000000003 L 396.16999999999996 96.52000000000004 L 395.81999999999994 97.21000000000004 L 396.04999999999995 98.40000000000003 L 394.06999999999994 100.98000000000003 L 392.67999999999995 104.48000000000003 L 392.19 104.93 z M 344.98 104.76 L 344.23 104.25 L 345.33000000000004 102 L 345.24000000000007 100.21 L 345.49000000000007 100 L 347.82000000000005 99.52 L 348.72 98.66 L 348.87 98.16 L 348.67 95.82 L 349.53000000000003 93.24 L 350.79 91.75 L 353.08000000000004 90.28 L 355.95000000000005 90.08 L 356.6700000000001 92.44 L 355.57000000000005 94.63 L 354.72 97.67 L 353.62 98.34 L 352.28000000000003 100.37 L 351.50000000000006 101.09 L 346.56000000000006 104.4 L 344.98 104.76 z M 373.46 81.86 L 372.43 81.61 L 369.98 81.69 L 369.19 81.53 L 368.9 81.27 L 368.52 80.17999999999999 L 368.53 78.94 L 370.03999999999996 78.52 L 371.92999999999995 78.56 L 374.11999999999995 77.27 L 378.92999999999995 76.67 L 379.69999999999993 76.93 L 380.37999999999994 77.61000000000001 L 380.19999999999993 78.63000000000001 L 377.63999999999993 80.02000000000001 L 375.85999999999996 82.50000000000001 L 374.76 83 L 373.46 81.86 z M 378.25 81.86 L 380.11 80.66 L 382.09000000000003 80.69 L 383.74 81.31 L 384.27 82.3 L 384.32 82.92 L 383.44 83.69 L 380.59 83.97 L 379.41999999999996 84.28999999999999 L 377.15999999999997 83.39999999999999 L 376.96 82.86999999999999 L 378.25 81.86 z M 361.27 86.25 L 360.77 85.99 L 360.15999999999997 86.03 L 358.61999999999995 85.34 L 358.8299999999999 84.18 L 359.4699999999999 83.26 L 361.38999999999993 82.86 L 363.74999999999994 81.96 L 365.06999999999994 82.03999999999999 L 365.86999999999995 82.72 L 365.9599999999999 82.85 L 364.0299999999999 84.46 L 362.9599999999999 84.8 L 361.27 86.25 z M 370.69 76.56 L 369.87 76.26 L 369.7 74.60000000000001 L 369.84999999999997 74.00000000000001 L 371.02 72.69000000000001 L 373.46999999999997 71.77000000000001 L 373.71999999999997 71.89000000000001 L 374.24999999999994 72.57000000000002 L 374.28999999999996 73.46000000000002 L 372.34 75.45000000000002 L 370.69 76.56 z M 356.86 96.78 L 356.72 96.37 L 356.91 95.44 L 357.95000000000005 92.63 L 360.54 90.94 L 361.26000000000005 90.66 L 361.95000000000005 90.8 L 361.79 92.59 L 360.23 93.03 L 358.61 95.22 L 356.86 96.78 z M 367.77 79.21 L 366.58 78.89999999999999 L 366.28 78.41999999999999 L 367.15999999999997 77.46 L 367.86999999999995 73.50999999999999 L 368.75999999999993 72.27999999999999 L 369.04999999999995 72.40999999999998 L 369.11999999999995 72.72999999999998 L 369.09999999999997 75.20999999999998 L 369.7 77.07999999999998 L 369.38 77.95999999999998 L 368.35 78.35999999999999 L 367.77 79.21 z M 352.96 89.4 L 352.69 89.21000000000001 L 352.81 88.60000000000001 L 353.36 88.24000000000001 L 354.55 86.53000000000002 L 355.31 84.99000000000001 L 356.04 84.33000000000001 L 357.49 83.79 L 357.29 85.28 L 356.89000000000004 86.28 L 355.17 87.94 L 352.96 89.4 z M 366.83 82.37 L 366.22999999999996 82.22 L 365.39 81.51 L 364.43 79.87 L 364.38 79.49000000000001 L 364.61 79.2 L 365.42 78.62 L 367.27000000000004 79.46000000000001 L 367.56000000000006 79.89000000000001 L 367.80000000000007 81.98000000000002 L 366.83 82.37 z M 361.45 112.93 L 360.8 112.82000000000001 L 359.92 112.30000000000001 L 359.23 112.76 L 358.48 112.48 L 356.8 110.74000000000001 L 356.8 110.13000000000001 L 358.08 110.12 L 361.14 111.44 L 361.45 112.93 z M 340.3 107.39 L 340.34000000000003 106.36 L 340.14000000000004 106.06 L 340.74000000000007 105.07000000000001 L 343.1000000000001 104.19000000000001 L 343.88000000000005 104.57000000000001 L 344.75000000000006 105.43 L 344.46000000000004 105.78 L 343.43000000000006 106.25 L 340.89000000000004 106.66 L 340.3 107.39 z M 353 100.7 L 352.82 100.67 L 352.83 100.32000000000001 L 353.37 99.38000000000001 L 355.16 97.76 L 355.58000000000004 96.52000000000001 L 355.63000000000005 95.22000000000001 L 355.87000000000006 94.92000000000002 L 356.19000000000005 95.36000000000001 L 356.19000000000005 96.87000000000002 L 355.30000000000007 99.60000000000002 L 354.68000000000006 100.25000000000003 L 353 100.7 z M 359.3 90.8 L 360.95 87.84 L 361.83 87.63000000000001 L 362.53999999999996 87.82000000000001 L 362.80999999999995 88.69000000000001 L 362.22999999999996 89.4 L 359.3 90.8 z M 390.72 109.77 L 389.88000000000005 109.42 L 389.5400000000001 108.36 L 390.5800000000001 106.64 L 391.6500000000001 106.31 L 391.8400000000001 106.41 L 391.8200000000001 107.14999999999999 L 391.0800000000001 109.38999999999999 L 390.72 109.77 z M 357.24 90.3 L 356.7 90.1 L 357.02 88.05999999999999 L 358.34999999999997 86.24999999999999 L 358.58 86.28999999999999 L 359.87 87.16999999999999 L 359.86 87.41999999999999 L 358.31 88.05999999999999 L 357.24 90.3 z M 359.47 95.33 L 360.19000000000005 95.36 L 359.7900000000001 95.81 L 358.8500000000001 96.12 L 358.74000000000007 97.24000000000001 L 357.95000000000005 97.95 L 356.26000000000005 98.79 L 356.1 98.61 L 356.37 97.78 L 356.84000000000003 97.15 L 358.57000000000005 95.48 L 359.47 95.33 z M 336.91 105.54 L 336.36 105.35000000000001 L 336.29 105.00000000000001 L 336.72 104.60000000000001 L 340.28000000000003 103.00000000000001 L 340.82000000000005 103.70000000000002 L 340.81000000000006 103.90000000000002 L 339.4100000000001 104.63000000000002 L 336.91 105.54 z M 400.44 100.76 L 399.41 100.57000000000001 L 398.59000000000003 99.78 L 399.46000000000004 98.53 L 400.8 98.52 L 400.99 99.71 L 400.89 100.3 L 400.44 100.76 z M 363.19 81.86 L 360.83 82.56 L 360.24 82.57000000000001 L 360.06 82.36000000000001 L 361.09 81.32000000000001 L 362.13 80.81 L 363.17 80.98 L 363.61 81.32000000000001 L 363.76 81.55000000000001 L 363.61 81.76 L 363.19 81.86 z M 357.92 90.45 L 357.84000000000003 89.69 L 358.09000000000003 89.19 L 360.57000000000005 87.73 L 359.6700000000001 89.73 L 358.86000000000007 90.36 L 357.92 90.45 z M 360.06 94.98 L 359.61 94.86 L 359.54 94.63 L 360.32 93.13 L 361.51 93.14999999999999 L 361.39 94.49999999999999 L 360.06 94.98 z M 388.1 110.81 L 387.82000000000005 110.58 L 388.72 108.98 L 389.40000000000003 108.58 L 389.63000000000005 109.33 L 390.14000000000004 109.7 L 389.88000000000005 110.22 L 389.45000000000005 110.56 L 388.82000000000005 110.38 L 388.1 110.81 z M 361.44 87.49 L 360.55 87.42 L 360.57 87.23 L 362.93 85.39 L 362.97 86.35 L 362.74 86.97999999999999 L 362.49 87.32 L 361.44 87.49 z M 428.9 97.71 L 428.52 97.17999999999999 L 428.71 96.41999999999999 L 429.72999999999996 95.50999999999999 L 429.97999999999996 95.66 L 430.21 97.41 L 428.9 97.71 z"},{code:"PB",name:"Paraíba",gTransform:"matrix(1 0 0 1 275.13 -126.21)",pathTransform:"translate(-581.13, -193.05)",d:"M 610.43 199.15 L 607.93 197.09 L 607.11 196.83 L 604.46 196.62 L 602.15 197.69 L 600.67 198.97 L 600.22 200.77 L 598.32 201.8 L 596.31 202.25 L 595.17 202.23 L 595.17 202.83 L 594.37 203.36 L 592.19 203.65 L 588.31 203.39 L 586.7 204.27 L 586.15 204.91 L 584.33 205.01 L 583.44 205.7 L 582.9 206.46 L 583.29 207.19 L 583.3 207.73 L 582.9 208.21 L 581.12 209.74 L 579.78 209.9 L 578.13 210.74 L 576.53 209.95 L 575.58 209.01 L 575.23 206.77 L 575.47 206.28 L 575.29 205.98 L 574.15 205.66 L 573.71 205.95 L 572.2 206.2 L 572.24 205.75 L 574.77 203.11 L 574.94 202.68 L 574.22 200.81 L 574.18 200.34 L 574.55 199.56 L 577.55 198.49 L 577.66 198.19 L 577.16 196.8 L 573.66 194.88 L 572.18 195.29 L 569.96 196.55 L 569.03 198.06 L 567.55 198.93 L 566.5 199.24 L 563.8 201.12 L 562.28 202.76 L 560.65 202.99 L 558.02 203.96 L 557.25 203.63 L 557.3 202.95 L 556.67 201.71 L 556.29 201.63 L 555.36 202.36 L 553.85 202.68 L 552.86 202.35 L 551.46 200.44 L 551.06 200.35 L 551.06 200.35 L 550.89 200.1 L 552.08 198.98 L 553.69 195.49 L 553.35 194.3 L 552.66 194.22 L 551.42 193.33 L 551.44 191.67 L 551.09 190.95 L 550.51 190.66 L 550.27 190.25 L 550.39 189.32 L 550.56 188.94 L 551.65 188.31 L 552.31 187 L 551.79 185.69 L 552.82 182.69 L 553.66 181.54 L 553.74 181 L 553.74 181 L 554.31 180.54 L 556.24 182.18 L 557.14 182.6 L 560.02 183.21 L 561.18 182.08 L 564.41 180.42 L 565.23 179.71 L 565.33 178.67 L 565.74 177.72 L 568.92 176.51 L 570.35 176.39 L 573.61 175.35 L 574.25 175.43 L 574.78 175.87 L 574.79 177.06 L 571.8 180.27 L 571.36 181.23 L 570.98 182.97 L 570.57 183.35 L 569.72 183.6 L 569.51 183.91 L 569.43 185.63 L 572.96 186.15 L 573.28 186.38 L 573.59 187.76 L 573.88 187.99 L 577.03 186.73 L 578.8 186.65 L 580.75 186.95 L 581.64 188.12 L 581.12 189.66 L 581.95 190.4 L 584.3 189.47 L 584.8 188.73 L 585.35 187.52 L 584.88 186.58 L 584.72 185.16 L 585.2 184.57 L 586.21 184.89 L 585.68 183.36 L 584.96 182.58 L 585.27 181.1 L 587.09 179.75 L 588.47 179.7 L 588.89 180.09 L 588.79 181.09 L 589.41 181.58 L 592.83 181.98 L 593.36 182.33 L 599.19 181.94 L 601.36 182.24 L 603.82 183.34 L 604.86 182.94 L 608.36 183.15 L 609.29 182.91 L 609.29 182.91 L 609.38 185.31 L 610.83 189.7 L 610.89 190.34 L 610.71 191.28 L 610.34 191.73 L 610.31 192.61 L 610.89 191.87 L 611.4 190.37 L 611.41 192.35 L 612 193.36 L 611.73 198.54 L 611.37 199.14 z"},{code:"PE",name:"Pernambuco",gTransform:"matrix(1 0 0 1 254.6 -106.99)",pathTransform:"translate(-560.6, -212.26)",d:"M 558.28 227.19 L 557.06 224.15 L 557.05 223.21 L 554.94 222.35 L 554.44 221.98 L 553.99 221.15 L 554.6 220.26 L 554.58 219.64 L 554.13 219.32 L 553.13 219.33 L 552.7 219.77 L 552.41 221.51 L 551.98 221.66 L 551.59 221.4 L 551.05 219.75 L 549.47 218.6 L 546.48 218.2 L 544.12 217.43 L 542.77 216.62 L 541.94 215.18 L 540.45 214.62 L 539.86 214.73 L 537.33 216.19 L 535.68 216.63 L 534.91 218.68 L 532.68 219.13 L 532.39 219.38 L 532.64 220.74 L 532.47 221.33 L 531.37 222.57 L 528.98 223.6 L 528.34 223.54 L 527.57 223.01 L 526.81 223.18 L 526.31 224.05 L 525.54 227.62 L 522.67 228.5 L 521.85 229.42 L 520.89 229.65 L 519.05 229.03 L 519.97 227.35 L 519.71 225.35 L 517.5 224.44 L 516.78 222.5 L 516.84 219.77 L 516.4 219.26 L 513.59 217.88 L 511.39 217.59 L 510.23 217.85 L 509.33 217.45 L 509.33 217.45 L 511.95 216.18 L 513.92 214.47 L 514.46 213.6 L 516.75 212.27 L 517.72 211.99 L 521.61 208.12 L 522.35 206.36 L 522.41 204.09 L 522.12 203.55 L 520.5 201.97 L 520.57 199.78 L 519.97 198.65 L 519.91 197.7 L 520.02 197.25 L 520.54 196.92 L 522.33 196.76 L 522.33 196.76 L 527.26 196.96 L 528.15 197.2 L 529.78 197.01 L 531.92 196.21 L 533.21 196.11 L 536.29 196.53 L 539.14 198.43 L 540.97 199.26 L 541.43 200.25 L 542.44 201.32 L 543.8 201.8 L 544.58 202.37 L 545.21 204.01 L 546.86 203.96 L 548.4 201.67 L 549.47 200.84 L 551.06 200.35 L 551.06 200.35 L 551.46 200.44 L 552.86 202.35 L 553.85 202.68 L 555.36 202.36 L 556.29 201.63 L 556.67 201.71 L 557.3 202.95 L 557.25 203.63 L 558.02 203.96 L 560.65 202.99 L 562.28 202.76 L 563.8 201.12 L 566.5 199.24 L 567.55 198.93 L 569.03 198.06 L 569.96 196.55 L 572.18 195.29 L 573.66 194.88 L 577.16 196.8 L 577.66 198.19 L 577.55 198.49 L 574.55 199.56 L 574.18 200.34 L 574.22 200.81 L 574.94 202.68 L 574.77 203.11 L 572.24 205.75 L 572.2 206.2 L 573.71 205.95 L 574.15 205.66 L 575.29 205.98 L 575.47 206.28 L 575.23 206.77 L 575.58 209.01 L 576.53 209.95 L 578.13 210.74 L 579.78 209.9 L 581.12 209.74 L 582.9 208.21 L 583.3 207.73 L 583.29 207.19 L 582.9 206.46 L 583.44 205.7 L 584.33 205.01 L 586.15 204.91 L 586.7 204.27 L 588.31 203.39 L 592.19 203.65 L 594.37 203.36 L 595.17 202.83 L 595.17 202.23 L 596.31 202.25 L 598.32 201.8 L 600.22 200.77 L 600.67 198.97 L 602.15 197.69 L 604.46 196.62 L 607.11 196.83 L 607.93 197.09 L 610.43 199.15 L 610.43 199.15 L 611.31 199.38 L 611.86 200.6 L 610.59 202.32 L 610.48 202.87 L 610.49 203.35 L 611.19 203.72 L 611.46 204.22 L 611.65 205.28 L 609.69 211.66 L 606.44 220.61 L 606.44 220.61 L 606.17 220.4 L 603.27 220.13 L 601.35 219.32 L 599.88 219.51 L 597.32 220.8 L 595.08 219.95 L 593.08 220.19 L 591.53 221.43 L 591.41 221.88 L 589.23 224.17 L 587.42 225.28 L 586.26 225.23 L 584.4 226.29 L 583.23 226.4 L 580.09 226.11 L 577.59 226.76 L 575.68 226.28 L 573.9 225.23 L 572 223.11 L 569.45 221.09 L 568.37 221.21 L 566.7 220.91 L 565.7 219.69 L 564.88 220.29 L 564.79 220.98 L 562.41 224.27 L 560.24 225.03 L 559.6 226.12 z"},{code:"PI",name:"Piauí",gTransform:"matrix(1 0 0 1 174.84 -130.97)",pathTransform:"translate(-480.85, -188.29)",d:"M 505.7 126.91 L 507.01 127.03 L 507.7 126.8 L 509.94 127.31 L 510.93 128.16 L 511.25 128.76 L 511.25 128.76 L 511.14 129.56 L 510.05 131.41 L 508.47 133.38 L 508.29 134.84 L 508.58 136.13 L 510.38 140.85 L 513.53 147.27 L 513.97 149 L 515.33 150.59 L 515.31 151.35 L 514.57 152.71 L 515.36 156.58 L 514.88 158.18 L 515.88 160.19 L 516.48 163.18 L 515.89 164.76 L 515.09 165.34 L 516.01 166.03 L 516.12 166.41 L 517.06 174.57 L 516.82 175.02 L 517.58 177.59 L 518.63 182.79 L 519.64 185.46 L 520.95 186.11 L 523.51 186.58 L 524.28 187.74 L 524.27 188.43 L 522.77 190.68 L 521.63 193.79 L 521.71 194.76 L 522.39 195.44 L 522.33 196.76 L 522.33 196.76 L 520.54 196.92 L 520.02 197.25 L 519.91 197.7 L 519.97 198.65 L 520.57 199.78 L 520.5 201.97 L 522.12 203.55 L 522.41 204.09 L 522.35 206.36 L 521.61 208.12 L 517.72 211.99 L 516.75 212.27 L 514.46 213.6 L 513.92 214.47 L 511.95 216.18 L 509.33 217.45 L 509.33 217.45 L 508.88 218.61 L 507.38 220.91 L 506.33 221.58 L 505.54 221.4 L 503.54 221.78 L 503.65 224.18 L 501.79 225.98 L 501.47 225.93 L 500.85 225.31 L 498.69 225.3 L 497.87 226.28 L 497.1 226.64 L 494.37 226.98 L 492.86 228.32 L 492.04 229.54 L 490.34 229.64 L 488.86 230.28 L 485.86 230.39 L 485.04 230.11 L 484.85 229.83 L 484.98 229.17 L 483.27 228.19 L 481.94 227.8 L 480.55 228.35 L 478.42 228.78 L 478.1 228.6 L 477.69 227.67 L 476.19 227.21 L 474.24 227.23 L 471 228.88 L 470.94 229.81 L 473.18 234.25 L 473.3 235.4 L 473.01 237.97 L 472.76 238.88 L 472.04 239.74 L 469.09 244.79 L 466.12 247.21 L 464.77 247.63 L 463.29 247.1 L 461.95 246.93 L 459.75 247.68 L 458.58 248.57 L 457.91 249.44 L 456.77 249.82 L 456.02 251.27 L 455.69 251.48 L 453.58 251.3 L 451.78 251.82 L 447.6 249.97 L 445.83 247.48 L 445.3 245.27 L 444.64 244.23 L 443.2 242.89 L 440.87 242.91 L 440.87 242.91 L 437.93 242.7 L 437.93 242.7 L 437.98 240.78 L 438.24 239.72 L 439.39 237.27 L 439.52 230.91 L 440.28 229.51 L 440.31 229 L 438.58 225.94 L 438.11 222.75 L 437.41 220.81 L 438.14 218.81 L 439.84 217.41 L 441.04 214.93 L 441.17 213.42 L 441.51 212.59 L 441.81 212.38 L 443.25 209.64 L 443.88 207.32 L 444.27 204.35 L 445.25 201.37 L 447.38 199.42 L 450.1 198.66 L 452.71 198.35 L 453.78 197.98 L 455.48 196.45 L 456.53 196.41 L 457.87 195.89 L 460.73 193.32 L 463.07 192.41 L 465.08 190.41 L 465.71 189.54 L 465.71 189.08 L 467.61 187.16 L 468.11 186.94 L 468.95 186.7 L 469.18 187 L 470.3 186.74 L 471.3 186.14 L 472.76 185.95 L 473.77 186.16 L 476.28 187.98 L 477.79 187.88 L 480.23 187.02 L 481.06 186.98 L 481.71 187.26 L 483.99 186.97 L 485.2 185.66 L 485.7 184.2 L 485.82 182.99 L 486.11 182.55 L 486.5 180.35 L 486.37 179.5 L 486.2 179 L 484.59 178.09 L 482.81 176.06 L 482.3 173.76 L 482.19 171.65 L 482.36 169.17 L 486.46 164.74 L 486.67 164.19 L 486.77 161.76 L 486.22 158.78 L 484.64 155.98 L 485.78 153.11 L 486.06 151.64 L 485.68 150.37 L 484.45 149.53 L 484.1 147.61 L 484.87 146.56 L 485.51 146.39 L 486.33 144.41 L 488.22 142.56 L 489.1 140.73 L 489.06 138.94 L 491.98 135.53 L 492.79 135.69 L 496.1 135.23 L 500.23 131.26 L 502.02 128.99 L 502.41 127.46 L 501.77 126.93 L 501.55 126.21 L 502.01 124.77 L 502.01 124.77 L 502.74 124.89 L 504.21 125.76 L 504.72 126.27 L 504.59 126.58 z"},{code:"PR",name:"Paraná",gTransform:"matrix(1 0 0 1 47.59 157)",pathTransform:"translate(-353.59, -476.27)",d:"M 396.75 499.4 L 391.51 499.37 L 391.18 499.81 L 389.44 500.05 L 388.68 499.98 L 388.57 499.59 L 387 500.16 L 385.65 501.59 L 382.3 503.72 L 380.86 503.56 L 379.63 502.94 L 376.5 500.34 L 375.47 499.95 L 374.71 499.94 L 371.87 500.67 L 369.54 500.84 L 368.73 500.81 L 367.31 500.05 L 366.2 500.19 L 364.67 500.84 L 364.08 502.31 L 363.35 503.18 L 361.48 504.16 L 357.91 503.75 L 355.91 504.9 L 355.19 505.67 L 354.5 507.26 L 355.35 510.25 L 354.48 511.11 L 353.56 511.13 L 352.81 511.51 L 352.64 512 L 351.31 510.11 L 347.06 510.24 L 343.3 509.81 L 341.72 508.63 L 341.56 508.22 L 340.53 507.59 L 336.27 507.23 L 330.98 505.55 L 328.64 506.12 L 325.95 506.09 L 323.93 504.68 L 323.61 504.17 L 322.55 503.93 L 322.02 503.92 L 321.31 504.29 L 317.68 504.27 L 317.68 504.27 L 317.46 503.06 L 314.93 498.88 L 314.95 496.29 L 313.96 493.41 L 310.54 491.04 L 309.45 492.17 L 307.33 492.06 L 306.23 492.49 L 305.16 493.39 L 303.7 492.31 L 302.88 492.37 L 302.6 490.17 L 303.26 488.6 L 304.33 487.33 L 305.55 485.15 L 305.61 484.81 L 305.12 484.06 L 305.14 482.82 L 306.04 479.18 L 307.3 476.16 L 307.05 473.86 L 308.33 471.48 L 308.12 470.46 L 307.28 469.58 L 306.97 467.98 L 307.63 466.92 L 308.42 466.38 L 308.42 466.38 L 310.8 464.82 L 311.16 464 L 312.73 456.08 L 313.06 455.73 L 314.17 455.41 L 315.83 454.4 L 316.5 453.72 L 317.95 450.16 L 317.93 449.01 L 318.86 446.68 L 319.97 445.86 L 325.38 443.59 L 325.38 443.59 L 328.64 441.3 L 332.47 441.95 L 336.48 441.84 L 339.75 442.13 L 340.96 441.51 L 341.31 440.91 L 342.04 440.54 L 343.21 440.83 L 344.69 441.61 L 347.21 442.07 L 349.85 443.16 L 351.16 443.29 L 352.23 442.75 L 354.81 442.74 L 355.59 443.74 L 357.34 444.58 L 360.85 445.38 L 361.48 445.89 L 362.19 447.21 L 363.92 447.28 L 364.34 446.94 L 365.99 447.09 L 366.65 447.63 L 371.96 447.76 L 374.93 446.91 L 376.06 448.46 L 379.65 451.29 L 380.54 453.05 L 380.55 455.79 L 380.16 456.37 L 380 457.18 L 380.38 459.02 L 381.68 460.53 L 381.6 462.29 L 381.24 462.85 L 382.73 465.85 L 383.94 467 L 384.61 467.28 L 385.11 467.96 L 385.06 468.85 L 385.98 470.82 L 386.58 471.11 L 386.83 471.55 L 386.58 472.6 L 385.31 474.73 L 385.63 476.77 L 386.23 477.15 L 387.24 477.36 L 389.62 477.24 L 393.04 476.71 L 393.54 477.1 L 395.12 476.91 L 396.71 477.04 L 398.32 478.3 L 398.18 478.71 L 397.29 479.36 L 396.6 482.66 L 396.95 483.44 L 398.02 483.97 L 398.67 483.12 L 399.77 480.36 L 400.53 480.19 L 402.67 480.77 L 402.27 482.72 L 403 486.02 L 404.42 486.6 L 404.58 487.92 L 404.58 487.92 L 403.23 488.94 L 402.62 490.42 L 402.07 490.3 L 402.34 488.36 L 403.78 487.41 L 402.37 487.69 L 401.48 488.18 L 400.61 488.16 L 400.27 487.77 L 399.7 487.6 L 399.16 487.97 L 398.88 488.9 L 399.4 489.7 L 398.67 490.66 L 398.37 490.76 L 395.89 490.23 L 395.1 489.69 L 394.65 489.81 L 394.47 490.71 L 394.81 491.08 L 396.42 491.64 L 397.82 491.39 L 399.95 491.99 L 400.22 492.47 L 399.25 493.15 L 397.71 495.93 L 396.47 496.7 L 394.05 497.27 L 393.85 497.72 L 396.8 497.52 L 396.95 498.71 z"},{code:"RJ",name:"Rio de Janeiro",gTransform:"matrix(1 0 0 1 179.27 113.69)",pathTransform:"translate(-485.28, -432.95)",d:"M 468.35 450.28 L 468.28000000000003 449.5 L 468.66 449.23 L 471.85 449.45000000000005 L 474.44 448.86000000000007 L 471.91 447.31000000000006 L 470.51000000000005 446.81000000000006 L 467.70000000000005 447.49000000000007 L 466.34000000000003 449.0900000000001 L 465.31000000000006 449.4100000000001 L 464.61000000000007 449.36000000000007 L 463.26000000000005 447.2100000000001 L 462.78000000000003 447.2100000000001 L 461.88000000000005 447.6300000000001 L 460.9200000000001 448.6900000000001 L 457.7700000000001 449.4900000000001 L 457.4300000000001 450.40000000000015 L 457.2400000000001 452.3000000000001 L 459.4300000000001 452.4300000000001 L 460.5000000000001 453.4400000000001 L 459.35000000000014 454.5200000000001 L 458.41000000000014 454.3500000000001 L 456.9900000000001 454.5200000000001 L 456.9900000000001 454.5200000000001 L 456.5100000000001 454.2600000000001 L 454.8800000000001 452.5300000000001 L 454.8300000000001 452.12000000000006 L 455.9200000000001 448.62000000000006 L 457.01000000000005 447.4700000000001 L 459.36000000000007 446.4600000000001 L 459.86000000000007 446.61000000000007 L 462.63000000000005 446.25000000000006 L 464.13000000000005 445.5400000000001 L 465.78000000000003 443.3900000000001 L 465.03000000000003 441.7500000000001 L 463.33000000000004 441.7400000000001 L 460.18000000000006 442.2700000000001 L 458.4100000000001 441.8800000000001 L 457.18000000000006 440.29000000000013 L 456.62000000000006 439.1200000000001 L 455.3500000000001 438.5800000000001 L 455.3500000000001 438.5800000000001 L 456.0300000000001 438.0900000000001 L 458.4500000000001 437.3500000000001 L 461.3600000000001 436.0100000000001 L 463.9400000000001 435.8400000000001 L 464.4400000000001 436.11000000000007 L 466.16000000000014 435.3400000000001 L 467.21000000000015 434.5700000000001 L 471.3000000000001 432.7800000000001 L 471.8200000000001 432.7100000000001 L 472.1800000000001 433.0200000000001 L 475.3800000000001 432.9500000000001 L 476.6300000000001 432.7800000000001 L 478.2600000000001 431.8400000000001 L 478.8300000000001 431.7800000000001 L 481.36000000000007 432.05000000000007 L 481.8500000000001 432.2200000000001 L 481.8300000000001 432.6900000000001 L 483.2100000000001 432.4900000000001 L 492.7200000000001 427.96000000000015 L 495.25000000000006 426.97000000000014 L 495.46000000000004 426.45000000000016 L 495.18000000000006 425.84000000000015 L 493.74000000000007 425.71000000000015 L 493.83000000000004 424.96000000000015 L 495.72 421.25000000000017 L 498.08000000000004 415.21000000000015 L 497.35 414.50000000000017 L 497.91 414.01000000000016 L 499.15000000000003 413.7400000000002 L 501.68 411.38000000000017 L 501.68 411.38000000000017 L 503.61 412.14000000000016 L 504.28000000000003 416.85000000000014 L 506.78000000000003 417.98000000000013 L 511.11 418.9900000000001 L 514.1 418.6200000000001 L 515.72 419.6800000000001 L 515.72 419.6800000000001 L 515.64 420.9500000000001 L 514.6999999999999 422.5600000000001 L 514.4799999999999 424.6900000000001 L 515.6199999999999 431.4700000000001 L 515.1199999999999 432.1500000000001 L 512.0399999999998 433.9000000000001 L 506.0699999999998 435.8400000000001 L 503.23999999999984 437.5600000000001 L 499.73999999999984 441.2500000000001 L 499.6299999999998 442.91000000000014 L 499.9399999999998 444.10000000000014 L 499.74999999999983 445.72000000000014 L 499.0199999999998 447.20000000000016 L 497.1999999999998 447.71000000000015 L 490.6499999999998 447.54000000000013 L 484.8599999999998 448.2400000000001 L 482.4699999999998 447.78000000000014 L 481.9799999999998 447.40000000000015 L 481.9199999999998 446.72000000000014 L 482.94999999999976 445.2400000000001 L 483.6199999999998 443.79000000000013 L 483.5299999999998 443.17000000000013 L 482.74999999999983 442.9900000000001 L 479.9599999999998 444.1400000000001 L 479.6999999999998 444.8300000000001 L 480.0099999999998 445.6200000000001 L 481.3899999999998 446.79000000000013 L 481.6399999999998 447.76000000000016 L 481.04999999999984 448.28000000000014 L 479.41999999999985 448.79000000000013 L 477.84999999999985 448.76000000000016 L 469.80999999999983 449.83000000000015 L 468.35 450.28 z M 463.24 452.27 L 462.57 451.29999999999995 L 464.68 449.74999999999994 L 466.54 450.68999999999994 L 466.97 451.38999999999993 L 464.51000000000005 451.88999999999993 L 464.1 451.5399999999999 L 463.63 451.5399999999999 L 463.24 452.27 z"},{code:"RN",name:"Rio Grande do Norte",gTransform:"matrix(1 0 0 1 274.86 -145.63)",pathTransform:"translate(-580.87, -173.63)",d:"M 609.29 182.91 L 608.36 183.15 L 604.86 182.94 L 603.82 183.34 L 601.36 182.24 L 599.19 181.94 L 593.36 182.33 L 592.83 181.98 L 589.41 181.58 L 588.79 181.09 L 588.89 180.09 L 588.47 179.7 L 587.09 179.75 L 585.27 181.1 L 584.96 182.58 L 585.68 183.36 L 586.21 184.89 L 585.2 184.57 L 584.72 185.16 L 584.88 186.58 L 585.35 187.52 L 584.8 188.73 L 584.3 189.47 L 581.95 190.4 L 581.12 189.66 L 581.64 188.12 L 580.75 186.95 L 578.8 186.65 L 577.03 186.73 L 573.88 187.99 L 573.59 187.76 L 573.28 186.38 L 572.96 186.15 L 569.43 185.63 L 569.51 183.91 L 569.72 183.6 L 570.57 183.35 L 570.98 182.97 L 571.36 181.23 L 571.8 180.27 L 574.79 177.06 L 574.78 175.87 L 574.25 175.43 L 573.61 175.35 L 570.35 176.39 L 568.92 176.51 L 565.74 177.72 L 565.33 178.67 L 565.23 179.71 L 564.41 180.42 L 561.18 182.08 L 560.02 183.21 L 557.14 182.6 L 556.24 182.18 L 554.31 180.54 L 553.74 181 L 553.74 181 L 553.08 181.38 L 552.44 181.21 L 552.78 179.24 L 554.19 176.99 L 555.03 176.11 L 555.54 176.04 L 556.32 176.55 L 557.35 176.29 L 557.92 175.19 L 559.38 173.68 L 560.78 171.24 L 560.63 170.5 L 561.28 168.83 L 562.15 168.26 L 562.99 167.14 L 566.29 160.45 L 568.9 158.44 L 573.79 156.85 L 573.79 156.85 L 574.26 157.61 L 575.12 158.36 L 578.25 158.35 L 579.47 158.76 L 581.16 160.51 L 582.48 161.01 L 585.81 160.69 L 588.69 161.21 L 591.23 160.97 L 593.56 160.24 L 598.06 161.16 L 599.33 161.2 L 601.28 162.06 L 602.3 162.88 L 602.94 163.82 L 605.25 168.56 L 605.75 170.35 L 605.71 171.1 L 607.19 176.48 L 607.4 178.16 L 608.12 178.7 L 609.08 181.39 z"},{code:"RO",name:"Rondônia",gTransform:"matrix(1 0 0 1 -139.57 -68.08)",pathTransform:"translate(-166.43, -251.18)",d:"M 187.32 290.95 L 186.03 289.5 L 185.59 287.62 L 184.03 287.1 L 183.17 287.42 L 181.36 287.5 L 177.29 285.69 L 177.28 285.29 L 176.62 284.68 L 175.35 285.27 L 173.37 283.59 L 171.85 282.62 L 170.99 281.16 L 170.71 279.77 L 169.67 279.38 L 167.9 280.5 L 166.68 280.47 L 165.27 279.67 L 164.4 278.34 L 161.27 276.76 L 159.31 276.59 L 158.17 277.13 L 157.27 277.98 L 155.84 277.81 L 155.53 277.51 L 153.39 277 L 150.33 276.72 L 149.57 276.29 L 148.39 275.1 L 148.09 273.13 L 146.51 272.64 L 144.62 271.67 L 143.8 269.95 L 143.51 269.75 L 140.79 269.47 L 140.41 269.12 L 139.57 265.41 L 138.69 264.52 L 138.21 265.68 L 137.55 265.36 L 137.28 264.72 L 137.9 263.19 L 137.06 261.67 L 135.7 261.28 L 134.44 257.81 L 134.27 256.15 L 135.82 253.24 L 135.61 251.58 L 134.45 249.61 L 133.7 247.45 L 133.64 245.16 L 134.26 244.66 L 134.64 243.29 L 135.68 242.24 L 136.04 240.77 L 135.8 239.28 L 135.38 238.39 L 135.29 236.86 L 135.83 235.21 L 134.66 233.03 L 133.64 232.65 L 132.55 233.63 L 132.49 234.14 L 131.65 235.1 L 131.08 235.1 L 128.9 234.08 L 123.72 234.16 L 118.11 235.94 L 116.42 235.93 L 114.94 236.41 L 114.94 236.41 L 111.97 235.15 L 111.97 235.15 L 115.23 232.59 L 117.15 232.01 L 118.7 230.2 L 118.85 229.64 L 118.69 228.35 L 122.65 228.61 L 125.52 228.28 L 126.24 228.65 L 128.55 230.98 L 128.92 230.96 L 130.14 230.17 L 130.27 229.45 L 130.68 228.92 L 131.76 228.42 L 132.53 228.55 L 133.9 228.16 L 135.2 226.95 L 137.04 225.93 L 137.42 226.02 L 138.06 228.28 L 138.74 228.81 L 139.42 228.73 L 141.96 225.57 L 141.7 223.82 L 142.23 222.98 L 143.98 221.72 L 144.44 221.74 L 145.28 222.29 L 147.07 222.39 L 148.27 221.32 L 150.4 220.94 L 154.27 221.4 L 154.03 219.94 L 154.14 218.13 L 156.2 216.92 L 157.01 215.77 L 157.37 214.75 L 157.2 214.3 L 156.3 213.6 L 156.35 212.93 L 157.54 211.34 L 160.02 210.81 L 160.28 210.59 L 160.19 209.42 L 161.91 208.92 L 163.29 206.36 L 174.08 206.3 L 176.23 207.43 L 176.68 207.92 L 177.48 209.83 L 178.81 211.1 L 181.35 212.08 L 182.6 215.35 L 183.06 215.56 L 184.04 215.43 L 184.66 215.63 L 185.34 218.51 L 188.58 219.99 L 189.26 219.8 L 189.8 218.06 L 191.72 216.98 L 193.11 217.26 L 193.47 217.64 L 193.43 218.34 L 193.43 218.34 L 194.83 219.31 L 195.43 220.55 L 194.67 221.97 L 193.38 226.96 L 193.44 227.31 L 194.22 227.78 L 194.48 228.39 L 194.63 229.78 L 195.46 232.05 L 194.52 233.72 L 194.9 235.65 L 193.9 239.17 L 193.87 239.97 L 194.14 241.73 L 195.64 244.48 L 194.74 253.48 L 211.9 253.53 L 211.66 254.09 L 212.88 255.2 L 216.38 255.11 L 217.49 255.22 L 218.56 255.65 L 219.97 259.24 L 219.8 259.99 L 218.4 261.74 L 217.04 262.82 L 216.9 264.14 L 217.33 267.39 L 217.91 267.9 L 218.81 267.87 L 220.34 271.21 L 220.3 273.26 L 220.88 274.75 L 220.81 276.46 L 220.25 278.7 L 218.59 280.71 L 218.07 282.96 L 217.49 283.8 L 217.06 284.21 L 215.42 284.74 L 214.49 285.82 L 213.06 289.6 L 212.54 292.05 L 208.43 294.62 L 206.96 296.05 L 206.96 296.05 L 206.22 296.01 L 203.63 294.46 L 202.36 293.03 L 195.28 293.99 L 193.96 293.56 L 193.71 293.26 L 190.33 293.92 L 189.85 293.76 L 189.33 292.41 z"},{code:"RR",name:"Roraima",gTransform:"matrix(1 0 0 1 -116.08 -267.27)",pathTransform:"translate(-189.92, -51.99)",d:"M 234.61 61.4 L 236.21 78.37 L 236.21 78.37 L 217.72 78.3 L 217.75 78.98 L 215.42 82.24 L 213.76 85.27 L 213.69 86.4 L 212.54 89.04 L 212.43 89.7 L 212.66 90.43 L 213.8 91.84 L 213.78 92.37 L 213.36 92.76 L 211.33 93.31 L 209.92 94.72 L 208.67 95.18 L 206.85 94.95 L 205.93 92.44 L 204.06 90.4 L 201.23 89.47 L 199.63 89.53 L 199.08 90.42 L 196.99 91.13 L 195.71 91.82 L 194.69 93.08 L 193.87 96.05 L 194.24 97.85 L 193.99 99.58 L 193.24 101.87 L 193.68 103.98 L 191.32 102.94 L 189.98 103.36 L 189.45 103.29 L 188.41 101.25 L 186.93 99.6 L 184.97 98.29 L 184.45 98.25 L 179.44 93.83 L 179.58 92.69 L 181.42 93.02 L 182.56 91.7 L 182.62 91.12 L 181.49 86.79 L 180.91 85.89 L 179.69 85.05 L 178.81 82.88 L 178.52 77.9 L 179.09 76.94 L 179.86 73.9 L 179.2 72.32 L 178.84 70.73 L 180.46 69.27 L 180.41 68.82 L 179.54 67.7 L 179.35 65.44 L 177.69 60.68 L 174.96 56.94 L 175.67 55.44 L 176.58 52.12 L 176.09 51.46 L 174.14 50.51 L 172.78 50.4 L 171.9 50.61 L 170.93 50.24 L 169.72 49.07 L 169.66 48.11 L 169.03 48 L 167.9 48.42 L 167.29 48.41 L 166.54 48.07 L 165.82 47.29 L 165.82 47.29 L 166.12 46.83 L 166.35 44.55 L 166.05 44.33 L 162.68 44.1 L 158.93 44.24 L 155.62 43.54 L 155.42 42.94 L 156.22 41.18 L 156.34 39.7 L 155.61 37.93 L 153.67 34.39 L 152.94 32.33 L 152.47 28.61 L 153.26 27.13 L 153.18 26.17 L 151.34 24.17 L 149.18 23.11 L 146.37 20.33 L 145.31 18.52 L 145.02 17.56 L 143.88 16.91 L 143.63 16.52 L 143.66 15.68 L 143.95 15.35 L 144.85 15.42 L 145.97 16.08 L 146.91 17.81 L 147.52 17.9 L 150.91 17.4 L 152.26 17.5 L 154.17 18.09 L 154.78 19.29 L 155.33 21.22 L 155.87 21.57 L 156.83 21.49 L 157.57 20.84 L 158.52 20.44 L 161.7 20.6 L 162.17 20.65 L 163.48 21.86 L 164.08 22.01 L 164.6 21.87 L 165.21 20.31 L 166.52 20.45 L 167.97 21.38 L 171.9 25.95 L 172.95 26.52 L 173.66 26.63 L 175.17 25.95 L 175.91 24.82 L 176.01 23.98 L 175.18 21.22 L 175.54 19.48 L 176 19.2 L 177.93 19.15 L 178.94 18.05 L 180.49 16.96 L 181.24 17.01 L 185.14 18.35 L 185.73 18.18 L 186.53 17.46 L 187.56 17.16 L 188.69 17.51 L 189.72 17.3 L 191.06 16.02 L 192.06 15.77 L 193.21 16 L 194.32 15.93 L 195 15.08 L 195.05 13.73 L 198.08 11.92 L 200.41 12.11 L 203.17 11.72 L 204.06 10.59 L 204.15 9.88 L 204.74 8.76 L 205.49 8.63 L 207.34 7.73 L 208.44 6.69 L 209.55 4.98 L 208.35 1.42 L 207.18 1.06 L 207.82 0.88 L 209.25 0.95 L 210.05 1.27 L 213.62 1.17 L 214.68 0.22 L 215.42 0 L 216.79 0.42 L 217.32 1.73 L 218.36 2.53 L 218.84 3.9 L 218.17 8.8 L 217.45 10.18 L 216.2 10.88 L 216.26 11.71 L 217.87 12.12 L 219.49 11.9 L 221.84 12.71 L 223.66 13.81 L 222.78 15.24 L 222.77 16.39 L 225.11 19.81 L 225.31 21.36 L 223.8 24.28 L 221.92 25.69 L 221.2 27.19 L 221.47 27.58 L 221.53 29.75 L 220.06 32.16 L 219.16 34.93 L 218.85 37.5 L 218.76 40.17 L 219.74 42.04 L 220.25 43.8 L 220.24 45.2 L 221.81 46.23 L 222.71 46.43 L 222.84 47.11 L 222.38 52.26 L 222.5 53 L 224.31 53.29 L 223.65 54.46 L 224.11 54.96 L 226.26 55.7 L 227.72 57.62 L 230.38 60.36 z"},{code:"RS",name:"Rio Grande do Sul",gTransform:"matrix(1 0 0 1 11.62 259.25)",pathTransform:"translate(-317.63, -578.5)",d:"M 321.99 638.52 L 321.63 638.53 L 319.69 637.42 L 319.49 636.96 L 320.01 632.69 L 319.55 628.44 L 319.7 627.37 L 320.33 626.13 L 323.17 623.75 L 324 622.19 L 326.3 619.63 L 324.84 617.98 L 323.77 617.36 L 321.52 616.76 L 319.2 614.51 L 317.99 612.89 L 317.89 611.3 L 317.46 610.12 L 316.23 608.09 L 314.17 605.85 L 313.5 605.26 L 311.11 604.05 L 309.66 604.26 L 307.76 602.75 L 306.24 601.12 L 304.99 600.34 L 304.85 598.64 L 302.95 596.48 L 299.63 596.02 L 298.71 595.55 L 296.98 593.89 L 295.22 594.02 L 293.05 592.64 L 291.14 588.93 L 290.03 587.44 L 287.5 585.32 L 286.8 585.4 L 286.13 587.19 L 283.54 589.43 L 280.87 589.55 L 280.97 586.69 L 281.37 585.41 L 280.98 584.41 L 277.33 580.12 L 274.96 578.35 L 272.78 576.29 L 271.03 574.18 L 268.34 571.97 L 266.44 571.83 L 264.29 572.04 L 263.15 573.4 L 263.09 574.36 L 262.06 575.33 L 260.95 575.35 L 260.37 574.87 L 257.21 575.01 L 256.56 574.53 L 256.4 573.62 L 255.91 573.4 L 256.76 573.18 L 257.8 572.46 L 260.32 569.69 L 260.43 567.85 L 261.03 566.6 L 261.85 566.15 L 263.14 566.08 L 263.78 565.82 L 264.7 564.82 L 270.15 558.34 L 270.78 556.92 L 270.95 555.81 L 271.77 554.74 L 272.97 553.89 L 274.34 553.48 L 276.3 549.26 L 276.4 548.65 L 276.71 548.28 L 278.35 547.42 L 279.98 545.62 L 280.83 544.47 L 281.34 543.18 L 282.68 541.08 L 283.61 540.79 L 285.18 540.97 L 285.73 541.76 L 286.2 540.48 L 285.99 539.9 L 284.64 539.08 L 284.59 538.72 L 284.94 538.39 L 286.02 538.01 L 286.84 537.05 L 289.63 536.1 L 290.68 535.03 L 290.78 534.11 L 291.6 533.2 L 293.81 532.05 L 296.28 531.65 L 298.05 529.84 L 298.2 528.78 L 299.52 526.42 L 299.85 526.38 L 299.9 526.74 L 300.19 526.94 L 301.52 526.77 L 303.96 525.64 L 306.64 525.05 L 307.85 524.48 L 309.95 522.13 L 310.45 522.14 L 311.12 521.75 L 312.13 520.4 L 314.44 519.67 L 314.74 520.05 L 314.74 520.05 L 318.26 520.44 L 321.52 519.29 L 322.08 518.48 L 323.43 519.06 L 323.28 519.98 L 326.36 519.95 L 327.99 520.94 L 330.55 520.57 L 332.47 521.72 L 335.05 521.31 L 336.59 521.49 L 339.39 521.33 L 341.65 522.25 L 344.13 523.65 L 345.13 526.09 L 346.72 526.28 L 346.81 525.8 L 348.62 525.45 L 354.18 528.99 L 355.55 530.54 L 356.26 530.51 L 357.82 531.49 L 360.85 534.98 L 362.49 537.19 L 362.97 538.67 L 365.14 541.33 L 366.31 541.88 L 373 542.94 L 375.11 542.54 L 378.46 542.88 L 379.34 545.22 L 377.26 546.8 L 375.99 547.21 L 375.26 549.07 L 375.48 551.26 L 375.1 552.82 L 374.58 554.12 L 373.4 554.32 L 372.11 556.01 L 372.08 557.42 L 373.88 558.59 L 374.15 558.39 L 373.87 557.42 L 373.88 556.46 L 375.37 555.64 L 376.95 556.28 L 377.68 557.19 L 378.85 558.04 L 379.3 558.01 L 379.3 558.01 L 377.9 559.74 L 374 566.78 L 369.79 578.38 L 363.49 588.86 L 358.05 595.52 L 351.54 601.48 L 345.45 605.16 L 342.35 609.47 L 342.17 609.04 L 342.82 607.46 L 343.16 605.28 L 341.98 603.57 L 342.08 603.15 L 343.01 602.98 L 344.02 603.38 L 344.58 603.96 L 345.6 604 L 348.18 602.59 L 349 601.91 L 351.85 598.2 L 352.6 597.51 L 353.05 597.7 L 354.07 597.51 L 355.12 596.67 L 356.05 595.4 L 356.42 593.92 L 356.6 592.99 L 356.37 590.89 L 356.57 589.52 L 358.14 589.45 L 358.88 589.75 L 359.15 590.58 L 359.5 590.32 L 359.21 588.92 L 359.72 586.85 L 360.2 586.28 L 362.94 584.69 L 363.67 583.61 L 364.14 580.86 L 363.93 578.58 L 364.49 577.9 L 364.99 578.7 L 365.36 578.73 L 365.79 578.31 L 366.26 575.23 L 366.16 574.79 L 365.21 573.57 L 364.54 573.54 L 364.28 574.23 L 364.45 574.62 L 364.31 575.19 L 363.96 575.39 L 362.45 575.37 L 360.44 575.77 L 360.1 577.38 L 359.57 577.43 L 358.76 576.99 L 358.86 575.28 L 358.04 574.39 L 357 574.72 L 356.4 574.24 L 355.67 572.98 L 355.27 571.53 L 355.39 570.96 L 354.75 570.27 L 354.14 572.98 L 354.58 575.23 L 355.83 577.34 L 355.26 578.15 L 354.52 580.69 L 354.9 583.72 L 354.72 584.49 L 354.24 584.12 L 354.5 583.88 L 354.47 583.17 L 354 581.89 L 353.55 581.5 L 353.02 582.16 L 352.99 583.53 L 351.58 586.8 L 351.53 588.69 L 351.75 589.21 L 351.03 589.91 L 349.42 590.55 L 348.81 592.13 L 344.72 593.7 L 344 594.23 L 343.47 595.82 L 343.37 598.09 L 342.4 600.36 L 340.04 601.66 L 339.93 603.42 L 340.41 604.25 L 340.66 605.27 L 339.71 605.83 L 339.46 607.34 L 339.89 607.94 L 340.57 607.8 L 341.87 608.43 L 342.02 609.34 L 339.89 610.99 L 337.57 615.51 L 335.64 622.39 L 333.63 626.88 L 331.95 629.4 L 324.16 636.93 z"},{code:"SC",name:"Santa Catarina",gTransform:"matrix(1 0 0 1 51.41 209.71)",pathTransform:"translate(-357.4, -528.97)",d:"M 379.3 558.01 L 378.85 558.04 L 377.68 557.1899999999999 L 376.95 556.27 L 375.36 555.64 L 373.88 556.46 L 373.87 557.4200000000001 L 374.15 558.3900000000001 L 373.88 558.5900000000001 L 372.08 557.4200000000002 L 372.12 556.0100000000002 L 373.4 554.3200000000002 L 374.58 554.1200000000001 L 375.10999999999996 552.8100000000002 L 375.47999999999996 551.2600000000002 L 375.25999999999993 549.0700000000002 L 375.98999999999995 547.2100000000002 L 377.25999999999993 546.7900000000002 L 379.3399999999999 545.2100000000002 L 378.4599999999999 542.8700000000001 L 375.1099999999999 542.5300000000001 L 372.9999999999999 542.9300000000001 L 366.3099999999999 541.8700000000001 L 365.14999999999986 541.3300000000002 L 362.97999999999985 538.6700000000002 L 362.48999999999984 537.1900000000002 L 360.85999999999984 534.9800000000001 L 357.82999999999987 531.4900000000001 L 356.2599999999999 530.5000000000001 L 355.5499999999999 530.5300000000001 L 354.1799999999999 528.9800000000001 L 348.6199999999999 525.4400000000002 L 346.8099999999999 525.7800000000002 L 346.7199999999999 526.2600000000002 L 345.1199999999999 526.0700000000002 L 344.1199999999999 523.6300000000001 L 341.64999999999986 522.2400000000001 L 339.3799999999999 521.3100000000002 L 336.58999999999986 521.4700000000001 L 335.04999999999984 521.2900000000002 L 332.45999999999987 521.7000000000002 L 330.54999999999984 520.5500000000002 L 327.97999999999985 520.9100000000002 L 326.34999999999985 519.9300000000002 L 323.26999999999987 519.9600000000002 L 323.41999999999985 519.0300000000002 L 322.0699999999998 518.4500000000002 L 321.5099999999998 519.2600000000001 L 318.24999999999983 520.4200000000001 L 314.72999999999985 520.0300000000001 L 314.72999999999985 520.0300000000001 L 316.17999999999984 517.1000000000001 L 316.90999999999985 515.0100000000001 L 316.32999999999987 511.7600000000001 L 316.7399999999999 508.5500000000001 L 316.6999999999999 506.0000000000001 L 317.65999999999985 504.2500000000001 L 317.65999999999985 504.2500000000001 L 321.28999999999985 504.2700000000001 L 321.99999999999983 503.8900000000001 L 322.5299999999998 503.9000000000001 L 323.5899999999998 504.1400000000001 L 323.8999999999998 504.6500000000001 L 325.9299999999998 506.0600000000001 L 328.6099999999998 506.0900000000001 L 330.94999999999976 505.5100000000001 L 336.2399999999998 507.1900000000001 L 340.4999999999998 507.5500000000001 L 341.51999999999975 508.1800000000001 L 341.68999999999977 508.59000000000015 L 343.25999999999976 509.77000000000015 L 347.02999999999975 510.19000000000017 L 351.27999999999975 510.0600000000002 L 352.60999999999973 511.96000000000015 L 352.78999999999974 511.46000000000015 L 353.52999999999975 511.08000000000015 L 354.44999999999976 511.0600000000002 L 355.31999999999977 510.20000000000016 L 354.46999999999974 507.21000000000015 L 355.15999999999974 505.63000000000017 L 355.87999999999977 504.8500000000002 L 357.87999999999977 503.7100000000002 L 361.44999999999976 504.1100000000002 L 363.31999999999977 503.14000000000016 L 364.0499999999998 502.27000000000015 L 364.63999999999976 500.79000000000013 L 366.16999999999973 500.14000000000016 L 367.27999999999975 500.00000000000017 L 368.69999999999976 500.76000000000016 L 369.50999999999976 500.79000000000013 L 371.83999999999975 500.6200000000001 L 374.6799999999997 499.8900000000001 L 375.4299999999997 499.9000000000001 L 376.46999999999974 500.30000000000007 L 379.58999999999975 502.9000000000001 L 380.81999999999977 503.5200000000001 L 382.25999999999976 503.6800000000001 L 385.6099999999998 501.5500000000001 L 386.9599999999998 500.1200000000001 L 388.5199999999998 499.5500000000001 L 388.6399999999998 499.9400000000001 L 389.3999999999998 500.0100000000001 L 391.1399999999998 499.7800000000001 L 391.4699999999998 499.3400000000001 L 396.7099999999998 499.37000000000006 L 396.7099999999998 499.37000000000006 L 396.3199999999998 500.69000000000005 L 396.8299999999998 502.34000000000003 L 396.7599999999998 502.73 L 395.2599999999998 503.87 L 394.2799999999998 503.39 L 393.4599999999998 500.86 L 393.4399999999998 501.98 L 394.0299999999998 504.70000000000005 L 395.7399999999998 506.36000000000007 L 396.2999999999998 507.31000000000006 L 395.2899999999998 509.6000000000001 L 395.12999999999977 511.9200000000001 L 395.2299999999998 512.35 L 395.9899999999998 513.08 L 396.2499999999998 518.94 L 396.5599999999998 519.49 L 396.9899999999998 519.69 L 397.75999999999976 519.1800000000001 L 398.1099999999998 519.9000000000001 L 398.2099999999998 520.7700000000001 L 397.7399999999998 520.83 L 397.3099999999998 520.5500000000001 L 396.1199999999998 521.1800000000001 L 395.7799999999998 525.0200000000001 L 396.3499999999998 527.6100000000001 L 395.7799999999998 528.3600000000001 L 396.0899999999998 530.2900000000001 L 396.99999999999983 532.1700000000001 L 396.1399999999998 534.5100000000001 L 395.61999999999983 538.5200000000001 L 393.90999999999985 543.2 L 393.5699999999999 543.1 L 393.20999999999987 542.34 L 393.41999999999985 541.37 L 392.49999999999983 540.19 L 392.23999999999984 540.5200000000001 L 392.41999999999985 542.95 L 393.57999999999987 543.7800000000001 L 392.65999999999985 545.44 L 391.01999999999987 546.09 L 386.8899999999999 549.13 L 384.08999999999986 551.6899999999999 L 380.33999999999986 556.13 L 379.3 558.01 z M 397.18 531.46 L 397.03000000000003 530.99 L 397.28000000000003 529.24 L 398.04 526.84 L 397.64000000000004 525.6600000000001 L 397.80000000000007 524.6400000000001 L 399.20000000000005 523.8800000000001 L 399.4200000000001 523.94 L 400.0800000000001 524.8800000000001 L 399.5400000000001 527.44 L 398.7200000000001 528.3000000000001 L 398.1300000000001 529.5200000000001 L 398.3300000000001 530.69 L 397.18 531.46 z M 396.73 507.09 L 394.86 505.07 L 397.41 502.63 L 397.66 502.67 L 398.31 503.72 L 397.45 505.04 L 396.73 507.09 z"},{code:"SE",name:"Sergipe",gTransform:"matrix(1 0 0 1 266.49 -72.82)",pathTransform:"translate(-572.49, -246.44)",d:"M 569.94 261.69 L 567.04 262.58 L 565.49 261.94 L 564.95 261.6 L 564.47 260.88 L 562.55 259.96 L 561.95 259.44 L 561.83 259.03 L 562.17 258.64 L 562.3 257.22 L 562.15 256.83 L 560.72 255.32 L 560.2 253.83 L 559.11 253.16 L 558.15 251.56 L 558.13 250.79 L 558.72 249.21 L 559.04 248.91 L 560.74 248.92 L 561.87 249.67 L 564.42 248.68 L 565.11 248.13 L 565.41 247.55 L 564.65 244.8 L 564.73 243.92 L 565.39 242.3 L 565.47 239.19 L 564.72 238.04 L 562.73 236.09 L 561.46 233.59 L 561.24 231.45 L 561.91 230.3 L 561.91 230.3 L 568.37 233.28 L 572.05 234.23 L 577.47 237.3 L 578.77 239.75 L 580.53 241.2 L 582.19 241.99 L 582.65 242.02 L 586.24 244.25 L 586.84 245.56 L 586.84 245.56 L 584.46 246.32 L 579.89 249.26 L 578.92 250.15 L 577.37 252.36 L 577.05 252.34 L 577.16 251.24 L 576.11 249.42 L 575.12 249.58 L 575.46 250.74 L 576.7 250.74 L 576.93 250.98 L 576.41 252.95 L 575.14 255.04 L 574.61 254.69 L 574.24 254.02 L 573.25 253.86 L 573.45 254.54 L 574.58 255.16 L 574.32 256.93 L 573.46 258.08 L 572.53 260.11 L 571.75 260.26 L 571.45 259.8 L 571.93 258.4 L 572.34 258.27 L 572.65 257.84 L 573.02 256.8 L 572.21 256.43 L 572.31 257.11 L 571.86 258.24 L 571.38 258.74 L 571.12 259.83 L 571.4 260.55 L 571.14 261.07 z"},{code:"SP",name:"São Paulo",gTransform:"matrix(1 0 0 1 89.6 122.15)",pathTransform:"translate(-395.6, -441.42)",d:"M 404.58 487.92 L 404.41999999999996 486.59000000000003 L 402.99999999999994 486.02000000000004 L 402.2699999999999 482.72 L 402.6699999999999 480.77000000000004 L 400.5299999999999 480.19000000000005 L 399.7699999999999 480.36000000000007 L 398.6699999999999 483.13000000000005 L 398.0099999999999 483.9800000000001 L 396.9499999999999 483.4500000000001 L 396.59999999999985 482.67000000000013 L 397.28999999999985 479.3700000000001 L 398.17999999999984 478.7100000000001 L 398.3199999999998 478.3100000000001 L 396.7099999999998 477.04000000000013 L 395.11999999999983 476.91000000000014 L 393.53999999999985 477.10000000000014 L 393.03999999999985 476.72000000000014 L 389.6299999999998 477.2500000000001 L 387.24999999999983 477.3700000000001 L 386.23999999999984 477.16000000000014 L 385.6399999999998 476.77000000000015 L 385.30999999999983 474.73000000000013 L 386.5899999999998 472.6100000000001 L 386.8399999999998 471.5600000000001 L 386.5899999999998 471.1200000000001 L 385.9899999999998 470.8200000000001 L 385.06999999999977 468.8500000000001 L 385.12999999999977 467.9600000000001 L 384.62999999999977 467.2800000000001 L 383.95999999999975 466.99000000000007 L 382.7499999999998 465.8500000000001 L 381.25999999999976 462.8400000000001 L 381.6199999999998 462.2900000000001 L 381.69999999999976 460.5300000000001 L 380.39999999999975 459.0100000000001 L 380.01999999999975 457.17000000000013 L 380.18999999999977 456.3600000000001 L 380.57999999999976 455.78000000000014 L 380.5599999999998 453.04000000000013 L 379.6699999999998 451.28000000000014 L 376.0799999999998 448.45000000000016 L 374.9499999999998 446.90000000000015 L 371.9799999999998 447.76000000000016 L 366.6699999999998 447.63000000000017 L 366.00999999999976 447.09000000000015 L 364.3599999999998 446.95000000000016 L 363.93999999999977 447.29000000000013 L 362.21999999999974 447.22000000000014 L 361.4999999999997 445.90000000000015 L 360.8699999999997 445.39000000000016 L 357.35999999999973 444.59000000000015 L 355.60999999999973 443.75000000000017 L 354.82999999999976 442.75000000000017 L 352.2499999999998 442.76000000000016 L 351.1799999999998 443.3000000000002 L 349.8599999999998 443.1700000000002 L 347.2199999999998 442.0800000000002 L 344.6899999999998 441.62000000000023 L 343.2099999999998 440.8300000000002 L 342.0399999999998 440.5400000000002 L 341.3099999999998 440.9100000000002 L 340.9699999999998 441.5100000000002 L 339.7599999999998 442.1300000000002 L 336.47999999999985 441.8400000000002 L 332.46999999999986 441.9500000000002 L 328.6399999999999 441.30000000000024 L 325.3899999999999 443.59000000000026 L 325.3899999999999 443.59000000000026 L 326.22999999999985 442.5100000000003 L 326.95999999999987 440.97000000000025 L 328.21999999999986 439.83000000000027 L 335.77999999999986 435.29000000000025 L 337.72999999999985 433.42000000000024 L 338.98999999999984 430.99000000000024 L 340.71999999999986 429.30000000000024 L 341.11999999999983 428.09000000000026 L 342.55999999999983 427.0600000000003 L 342.8399999999998 425.84000000000026 L 342.4899999999998 425.0000000000003 L 344.4899999999998 422.7400000000003 L 345.69999999999976 420.4000000000003 L 345.76999999999975 419.4600000000003 L 345.45999999999975 417.5300000000003 L 345.68999999999977 417.1400000000003 L 346.64999999999975 416.62000000000035 L 349.2499999999998 412.98000000000036 L 349.4099999999998 410.05000000000035 L 350.0299999999998 408.37000000000035 L 351.0399999999998 408.07000000000033 L 351.7699999999998 407.43000000000035 L 353.7599999999998 404.75000000000034 L 354.97999999999985 403.73000000000036 L 355.4499999999999 403.50000000000034 L 356.7599999999999 403.4600000000003 L 358.2599999999999 402.68000000000035 L 358.53999999999985 402.28000000000037 L 358.9399999999998 399.8200000000004 L 358.9399999999998 399.8200000000004 L 360.15999999999985 398.6900000000004 L 362.30999999999983 397.5800000000004 L 364.22999999999985 397.2100000000004 L 365.65999999999985 395.5200000000004 L 367.15999999999985 394.91000000000037 L 367.90999999999985 395.05000000000035 L 369.6399999999999 396.60000000000036 L 372.1899999999999 396.68000000000035 L 376.4799999999999 397.6400000000003 L 378.1499999999999 397.2800000000003 L 379.7699999999999 397.50000000000034 L 381.7699999999999 396.91000000000037 L 383.94999999999993 398.3300000000004 L 385.61999999999995 399.1200000000004 L 385.48999999999995 400.0400000000004 L 385.81999999999994 401.46000000000043 L 387.0299999999999 403.5500000000004 L 387.6599999999999 403.5800000000004 L 388.19999999999993 403.2600000000004 L 388.86999999999995 402.3200000000004 L 389.28 401.1900000000004 L 389.53999999999996 401.0000000000004 L 390.09 401.0500000000004 L 390.45 401.4400000000004 L 390.7 402.4000000000004 L 390.71 405.18000000000035 L 391.90999999999997 405.7100000000003 L 392.32 405.26000000000033 L 392.05 402.7200000000003 L 392.54 401.5300000000003 L 392.99 401.0500000000003 L 401.17 400.3800000000003 L 402.18 399.1300000000003 L 403.68 400.59000000000026 L 404.8 401.02000000000027 L 407.58 400.33000000000027 L 408.02 399.34000000000026 L 407.82 398.8800000000003 L 408.13 398.27000000000027 L 410.51 398.16000000000025 L 412.17 398.9400000000002 L 413.02000000000004 398.30000000000024 L 414.33000000000004 398.0100000000002 L 417.59000000000003 401.36000000000024 L 417.79 402.40000000000026 L 417.22 403.41000000000025 L 416.93 405.78000000000026 L 417.51 406.39000000000027 L 419.4 407.60000000000025 L 419.79999999999995 409.15000000000026 L 419.73999999999995 409.71000000000026 L 418.21999999999997 411.74000000000024 L 418.03999999999996 413.68000000000023 L 418.83 414.42000000000024 L 419.14 415.03000000000026 L 419.51 417.24000000000024 L 420.81 419.04000000000025 L 421.64 421.03000000000026 L 421.61 421.8800000000003 L 423.22 421.83000000000027 L 424 421.52000000000027 L 424.28 421.16000000000025 L 425.28 421.11000000000024 L 428.97999999999996 422.43000000000023 L 429.21 422.80000000000024 L 429.15999999999997 424.0700000000002 L 428.46 426.2500000000002 L 426.59999999999997 428.97000000000025 L 426.85999999999996 431.91000000000025 L 426.66999999999996 435.36000000000024 L 426.14 436.92000000000024 L 426.86 438.52000000000027 L 428.64 439.7600000000003 L 430.45 440.59000000000026 L 430.96 442.3100000000003 L 429.75 443.0100000000003 L 431.77 446.3200000000003 L 432.9 446.5700000000003 L 434.90999999999997 446.33000000000027 L 435.09 446.86000000000024 L 438.71 445.86000000000024 L 439.27 446.28000000000026 L 440.58 445.96000000000026 L 441.33 444.98000000000025 L 441.38 444.14000000000027 L 441.14 443.90000000000026 L 441.31 441.60000000000025 L 442.5 441.27000000000027 L 442.59 441.6200000000003 L 442.23999999999995 442.1100000000003 L 442.24999999999994 442.5900000000003 L 444.5899999999999 442.6700000000003 L 446.9799999999999 442.4200000000003 L 448.7699999999999 441.7500000000003 L 449.99999999999994 440.5100000000003 L 451.92999999999995 439.4900000000003 L 454.13999999999993 439.27000000000027 L 455.37999999999994 438.54000000000025 L 455.37999999999994 438.54000000000025 L 456.6499999999999 439.08000000000027 L 457.2099999999999 440.2500000000003 L 458.43999999999994 441.84000000000026 L 460.2099999999999 442.23000000000025 L 463.3599999999999 441.7000000000003 L 465.0599999999999 441.71000000000026 L 465.8099999999999 443.35000000000025 L 464.1599999999999 445.5000000000002 L 462.6599999999999 446.2100000000002 L 459.88999999999993 446.5700000000002 L 459.38999999999993 446.42000000000024 L 457.0399999999999 447.43000000000023 L 455.94999999999993 448.5800000000002 L 454.85999999999996 452.0800000000002 L 454.90999999999997 452.49000000000024 L 456.53999999999996 454.22000000000025 L 457.02 454.48000000000025 L 457.02 454.48000000000025 L 456.96 454.68000000000023 L 455.27 455.10000000000025 L 454.21 454.28000000000026 L 452.72999999999996 455.39000000000027 L 452.29999999999995 456.04000000000025 L 452.56999999999994 456.2600000000003 L 451.80999999999995 456.90000000000026 L 448.5899999999999 458.4500000000003 L 446.3399999999999 459.15000000000026 L 446.05999999999995 459.59000000000026 L 446.09999999999997 460.55000000000024 L 446.59999999999997 462.10000000000025 L 446.28 462.52000000000027 L 444.88 462.78000000000026 L 444.18 462.14000000000027 L 442.84000000000003 461.85000000000025 L 439.72 461.35000000000025 L 438.86 461.5000000000002 L 437.54 461.8400000000002 L 435.81 462.6600000000002 L 435.31 463.1700000000002 L 434.1 465.32000000000016 L 432.79 465.89000000000016 L 432.29 465.77000000000015 L 432.87 465.3000000000001 L 432.39 464.0800000000001 L 431.21999999999997 463.2300000000001 L 430.39 464.4600000000001 L 430.65 465.2100000000001 L 430.34999999999997 465.8200000000001 L 422.72999999999996 470.0600000000001 L 421.78 470.8800000000001 L 421.46999999999997 472.04000000000013 L 418.2 475.04000000000013 L 414.95 476.9900000000001 L 413.03 477.5200000000001 L 408.53 480.7300000000001 L 406.2 482.69000000000005 L 405.53 482.77000000000004 L 405.09 483.39000000000004 L 405.98999999999995 483.82000000000005 L 406.65 483.88000000000005 L 407.58 483.52000000000004 L 407.58 484.28000000000003 L 406.96 485.59000000000003 L 405.64 486.44000000000005 L 404.58 487.92 z M 448.89 464.91 L 447.34999999999997 464.26000000000005 L 446.18999999999994 464.44000000000005 L 445.69999999999993 464.06000000000006 L 445.79999999999995 463.2800000000001 L 446.74999999999994 462.6300000000001 L 447.8399999999999 460.7800000000001 L 448.55999999999995 461.0300000000001 L 449.21999999999997 461.68000000000006 L 449.34999999999997 464.5900000000001 L 448.89 464.91 z"},{code:"TO",name:"Tocantins",gTransform:"matrix(1 0 0 1 95.98 -93.17)",pathTransform:"translate(-401.98, -226.09)",d:"M 433.35 281.82 L 427.99 283.24 L 426.25 284.58 L 423.69 285.68 L 422.14 285.68 L 417.61 286.68 L 415.09 288.76 L 413.31 289.66 L 412.85 289.42 L 411.34 286.8 L 410.79 286.77 L 410.28 290.07 L 409.59 290.15 L 406.24 289.47 L 403.11 288 L 403.67 286.44 L 403.45 285.7 L 398.92 286.23 L 396.16 285.89 L 395.6 286.43 L 395.3 287.43 L 394.55 288.18 L 393.41 288.13 L 392.8 285.03 L 391.69 281.32 L 390.65 279.44 L 389.5 278.13 L 388.32 279.1 L 386.85 281.49 L 385.22 287.43 L 384.59 287.66 L 380.52 286.23 L 377.43 284.52 L 373.5 284.12 L 371.3 283.09 L 368.9 282.69 L 369.42 280.35 L 370.64 278.47 L 370.67 276.76 L 370.11 277.06 L 368.3 279.15 L 367.64 280.38 L 367.44 282.26 L 367.1 282.71 L 367.1 282.71 L 366.3 282.69 L 365.34 282.18 L 364.36 278.84 L 365.1 276.08 L 364.66 273.03 L 364.14 272.45 L 364.13 270.88 L 364.6 267.57 L 363.5 265.32 L 363.55 264.82 L 364.37 263.93 L 364.53 263.06 L 363.14 261.72 L 363.08 260.86 L 364.96 254.87 L 365 251.92 L 365.54 248.95 L 367.48 243.66 L 367.85 243.39 L 368.28 242.54 L 368.72 239.4 L 369.82 238.15 L 370.38 236.26 L 371.03 235.24 L 371.03 235.24 L 372.65 231.55 L 373.78 227.1 L 374.93 225.52 L 376.12 224.42 L 377.33 222.74 L 378.36 220.82 L 379.73 219.9 L 380.78 219.74 L 381.51 218.89 L 382.45 217.35 L 382.63 216.36 L 384.33 213.12 L 385.42 212.32 L 387.18 207.17 L 387.84 203.13 L 387.69 202.83 L 386.95 202.51 L 385.28 200.77 L 384.68 199.82 L 384.52 198.94 L 384.66 198.37 L 386.07 196.68 L 387.36 194.58 L 387.3 191.91 L 386.87 189.73 L 387.06 189.38 L 389.53 187.6 L 392.94 186.46 L 395.44 185.25 L 395.68 184.75 L 395.53 183.24 L 396.39 181.97 L 397.9 180.63 L 399.19 180.48 L 399.38 179.14 L 399.09 177.94 L 399.34 177.48 L 400.8 177.02 L 401.44 176.54 L 402.37 173.79 L 401.35 172.45 L 401.26 171.05 L 401.55 170.77 L 402.52 170.69 L 403.24 170.32 L 403.61 169.66 L 403.64 169.02 L 402.38 167.85 L 401.51 167.71 L 401.12 167.4 L 400.1 165.74 L 398.81 165.62 L 396.94 165.87 L 394.65 165.06 L 394.65 165.06 L 395.18 164.42 L 397.8 162.57 L 399.76 162.04 L 400.63 162.09 L 403.41 163.61 L 404.81 163.69 L 405.76 163.17 L 407.5 163.46 L 408.09 164.15 L 408.17 165.18 L 408.45 165.5 L 409.67 165.53 L 413.07 166.96 L 413.91 167.99 L 414.38 171.49 L 415.02 172.99 L 414.81 176.71 L 415.04 177.79 L 415.71 178.92 L 415.7 179.36 L 413.93 185.51 L 413.62 187.88 L 413.9 188.88 L 413.65 190.47 L 411.9 192.51 L 410.14 193.18 L 409.96 193.89 L 411.9 195.21 L 412.32 194.94 L 413.69 195.18 L 413.94 195.53 L 414.05 196.41 L 413.43 197.6 L 414.28 199.04 L 415.16 198.97 L 418.16 203.13 L 419.07 203.98 L 421.35 207 L 423.49 205.66 L 427.76 204.72 L 429.56 205.94 L 429.64 207.69 L 429 210.94 L 429.39 212.29 L 426 212.64 L 424.66 213.18 L 424.09 213.73 L 423.41 215.16 L 422.68 217.84 L 423.05 219.14 L 420.42 221.69 L 420.16 222.39 L 420.36 222.81 L 422.44 223.1 L 423.38 223.79 L 424.12 225.38 L 424.18 227.04 L 424.8 228.08 L 428.68 230.03 L 428.77 230.56 L 427.13 232.37 L 427.26 234.02 L 429.4 235.64 L 430.39 238.51 L 431.73 240.51 L 432.44 240.69 L 434.22 240.48 L 435.22 240.78 L 436.04 241.22 L 436.65 242.04 L 437.93 242.7 L 437.93 242.7 L 440.87 242.91 L 440.87 242.91 L 440.18 243.56 L 439.96 244.54 L 439.4 245.01 L 435.58 247.03 L 432.37 249.65 L 432.18 250.02 L 433.47 251.82 L 433.11 252.21 L 432.1 252.48 L 431.2 253.09 L 429.68 256.58 L 428.67 257.3 L 428.17 258.46 L 428.4 259.38 L 430.26 261.33 L 433.85 262 L 435.72 262.99 L 435.77 263.75 L 435.21 264.2 L 433.17 265.01 L 432.74 265.97 L 432.83 266.47 L 433.18 266.8 L 434.21 266.62 L 435.13 266.91 L 435.71 267.42 L 436 268.06 L 435.04 268.77 L 433.89 269.19 L 431.94 270.86 L 431.75 271.71 L 431.7 274.63 L 432.05 275.88 L 432.99 276.54 L 434.04 276.78 L 434.45 277.03 L 434.62 277.45 L 434.67 278.51 L 433.31 280.89 z"}];function yM({selected:t,onSelect:e}){const s=oe(),[n,i]=N.useState(vM),o=a=>{if(a)try{const l=a.getBBox();if(!l.width||!l.height)return;const c=Math.max(l.width,l.height)*.04,d=`${l.x-c} ${l.y-c} ${l.width+c*2} ${l.height+c*2}`;i(h=>h===d?h:d)}catch{}};return r.jsx("svg",{ref:o,viewBox:n,role:"group","aria-label":s("sectionsEditor.brazilMap.ariaLabel"),className:"h-72 w-full rounded-md border border-border/60 bg-muted/20",children:r.jsx("g",{transform:bM,children:Du.map(a=>{const l=a.code===t;return r.jsx("g",{transform:a.gTransform,children:r.jsx("path",{d:a.d,transform:a.pathTransform,role:"button",tabIndex:0,"aria-label":a.name,"aria-pressed":l,onClick:()=>e(a.code),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e(a.code))},className:ie("cursor-pointer stroke-background outline-none transition-colors [stroke-width:1] [vector-effect:non-scaling-stroke]","hover:fill-primary/50 focus-visible:fill-primary/50",l?"fill-primary":"fill-muted-foreground/40")})},a.code)})})})}const _M=[{code:"AF",name:"Afghanistan"},{code:"AX",name:"Åland Islands"},{code:"AL",name:"Albania"},{code:"DZ",name:"Algeria"},{code:"AS",name:"American Samoa"},{code:"AD",name:"Andorra"},{code:"AO",name:"Angola"},{code:"AI",name:"Anguilla"},{code:"AQ",name:"Antarctica"},{code:"AG",name:"Antigua & Barbuda"},{code:"AR",name:"Argentina"},{code:"AM",name:"Armenia"},{code:"AW",name:"Aruba"},{code:"AU",name:"Australia"},{code:"AT",name:"Austria"},{code:"AZ",name:"Azerbaijan"},{code:"BS",name:"Bahamas"},{code:"BH",name:"Bahrain"},{code:"BD",name:"Bangladesh"},{code:"BB",name:"Barbados"},{code:"BY",name:"Belarus"},{code:"BE",name:"Belgium"},{code:"BZ",name:"Belize"},{code:"BJ",name:"Benin"},{code:"BM",name:"Bermuda"},{code:"BT",name:"Bhutan"},{code:"BO",name:"Bolivia"},{code:"BA",name:"Bosnia & Herzegovina"},{code:"BW",name:"Botswana"},{code:"BV",name:"Bouvet Island"},{code:"BR",name:"Brazil"},{code:"VG",name:"British Virgin Islands"},{code:"BN",name:"Brunei"},{code:"BG",name:"Bulgaria"},{code:"BF",name:"Burkina Faso"},{code:"BI",name:"Burundi"},{code:"KH",name:"Cambodia"},{code:"CM",name:"Cameroon"},{code:"CA",name:"Canada"},{code:"CV",name:"Cape Verde"},{code:"BQ",name:"Caribbean Netherlands"},{code:"KY",name:"Cayman Islands"},{code:"CF",name:"Central African Republic"},{code:"TD",name:"Chad"},{code:"IO",name:"Chagos Archipelago"},{code:"CL",name:"Chile"},{code:"CN",name:"China mainland"},{code:"CX",name:"Christmas Island"},{code:"CC",name:"Cocos (Keeling) Islands"},{code:"CO",name:"Colombia"},{code:"KM",name:"Comoros"},{code:"CG",name:"Congo - Brazzaville"},{code:"CD",name:"Congo - Kinshasa"},{code:"CK",name:"Cook Islands"},{code:"CR",name:"Costa Rica"},{code:"CI",name:"Côte d’Ivoire"},{code:"HR",name:"Croatia"},{code:"CU",name:"Cuba"},{code:"CW",name:"Curaçao"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czechia"},{code:"DK",name:"Denmark"},{code:"DJ",name:"Djibouti"},{code:"DM",name:"Dominica"},{code:"DO",name:"Dominican Republic"},{code:"EC",name:"Ecuador"},{code:"EG",name:"Egypt"},{code:"SV",name:"El Salvador"},{code:"GQ",name:"Equatorial Guinea"},{code:"ER",name:"Eritrea"},{code:"EE",name:"Estonia"},{code:"SZ",name:"Eswatini"},{code:"ET",name:"Ethiopia"},{code:"FK",name:"Falkland Islands"},{code:"FO",name:"Faroe Islands"},{code:"FJ",name:"Fiji"},{code:"FI",name:"Finland"},{code:"FR",name:"France"},{code:"GF",name:"French Guiana"},{code:"PF",name:"French Polynesia"},{code:"TF",name:"French Southern Territories"},{code:"GA",name:"Gabon"},{code:"GM",name:"Gambia"},{code:"GE",name:"Georgia"},{code:"DE",name:"Germany"},{code:"GH",name:"Ghana"},{code:"GI",name:"Gibraltar"},{code:"GR",name:"Greece"},{code:"GL",name:"Greenland"},{code:"GD",name:"Grenada"},{code:"GP",name:"Guadeloupe"},{code:"GU",name:"Guam"},{code:"GT",name:"Guatemala"},{code:"GG",name:"Guernsey"},{code:"GN",name:"Guinea"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HT",name:"Haiti"},{code:"HM",name:"Heard & McDonald Islands"},{code:"HN",name:"Honduras"},{code:"HK",name:"Hong Kong"},{code:"HU",name:"Hungary"},{code:"IS",name:"Iceland"},{code:"IN",name:"India"},{code:"ID",name:"Indonesia"},{code:"IR",name:"Iran"},{code:"IQ",name:"Iraq"},{code:"IE",name:"Ireland"},{code:"IM",name:"Isle of Man"},{code:"IL",name:"Israel"},{code:"IT",name:"Italy"},{code:"JM",name:"Jamaica"},{code:"JP",name:"Japan"},{code:"JE",name:"Jersey"},{code:"JO",name:"Jordan"},{code:"KZ",name:"Kazakhstan"},{code:"KE",name:"Kenya"},{code:"KI",name:"Kiribati"},{code:"KW",name:"Kuwait"},{code:"KG",name:"Kyrgyzstan"},{code:"LA",name:"Laos"},{code:"LV",name:"Latvia"},{code:"LB",name:"Lebanon"},{code:"LS",name:"Lesotho"},{code:"LR",name:"Liberia"},{code:"LY",name:"Libya"},{code:"LI",name:"Liechtenstein"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"MO",name:"Macao"},{code:"MG",name:"Madagascar"},{code:"MW",name:"Malawi"},{code:"MY",name:"Malaysia"},{code:"MV",name:"Maldives"},{code:"ML",name:"Mali"},{code:"MT",name:"Malta"},{code:"MH",name:"Marshall Islands"},{code:"MQ",name:"Martinique"},{code:"MR",name:"Mauritania"},{code:"MU",name:"Mauritius"},{code:"YT",name:"Mayotte"},{code:"MX",name:"Mexico"},{code:"FM",name:"Micronesia"},{code:"MD",name:"Moldova"},{code:"MC",name:"Monaco"},{code:"MN",name:"Mongolia"},{code:"ME",name:"Montenegro"},{code:"MS",name:"Montserrat"},{code:"MA",name:"Morocco"},{code:"MZ",name:"Mozambique"},{code:"MM",name:"Myanmar (Burma)"},{code:"NA",name:"Namibia"},{code:"NR",name:"Nauru"},{code:"NP",name:"Nepal"},{code:"NL",name:"Netherlands"},{code:"NC",name:"New Caledonia"},{code:"NZ",name:"New Zealand"},{code:"NI",name:"Nicaragua"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NU",name:"Niue"},{code:"NF",name:"Norfolk Island"},{code:"KP",name:"North Korea"},{code:"MK",name:"North Macedonia"},{code:"MP",name:"Northern Mariana Islands"},{code:"NO",name:"Norway"},{code:"OM",name:"Oman"},{code:"PK",name:"Pakistan"},{code:"PW",name:"Palau"},{code:"PS",name:"Palestinian Territories"},{code:"PA",name:"Panama"},{code:"PG",name:"Papua New Guinea"},{code:"PY",name:"Paraguay"},{code:"PE",name:"Peru"},{code:"PH",name:"Philippines"},{code:"PN",name:"Pitcairn Islands"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PR",name:"Puerto Rico"},{code:"QA",name:"Qatar"},{code:"RE",name:"Réunion"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"WS",name:"Samoa"},{code:"SM",name:"San Marino"},{code:"ST",name:"São Tomé & Príncipe"},{code:"SA",name:"Saudi Arabia"},{code:"SN",name:"Senegal"},{code:"RS",name:"Serbia"},{code:"SC",name:"Seychelles"},{code:"SL",name:"Sierra Leone"},{code:"SG",name:"Singapore"},{code:"SX",name:"Sint Maarten"},{code:"SK",name:"Slovakia"},{code:"SI",name:"Slovenia"},{code:"GS",name:"So. Georgia & So. Sandwich Isl."},{code:"SB",name:"Solomon Islands"},{code:"SO",name:"Somalia"},{code:"ZA",name:"South Africa"},{code:"KR",name:"South Korea"},{code:"SS",name:"South Sudan"},{code:"ES",name:"Spain"},{code:"LK",name:"Sri Lanka"},{code:"BL",name:"St. Barthélemy"},{code:"SH",name:"St. Helena"},{code:"KN",name:"St. Kitts & Nevis"},{code:"LC",name:"St. Lucia"},{code:"MF",name:"St. Martin"},{code:"PM",name:"St. Pierre & Miquelon"},{code:"VC",name:"St. Vincent & Grenadines"},{code:"SD",name:"Sudan"},{code:"SR",name:"Suriname"},{code:"SJ",name:"Svalbard & Jan Mayen"},{code:"SE",name:"Sweden"},{code:"CH",name:"Switzerland"},{code:"SY",name:"Syria"},{code:"TW",name:"Taiwan"},{code:"TJ",name:"Tajikistan"},{code:"TZ",name:"Tanzania"},{code:"TH",name:"Thailand"},{code:"TL",name:"Timor-Leste"},{code:"TG",name:"Togo"},{code:"TK",name:"Tokelau"},{code:"TO",name:"Tonga"},{code:"T1",name:"Tor network (Cloudflare)"},{code:"TT",name:"Trinidad & Tobago"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Türkiye"},{code:"TM",name:"Turkmenistan"},{code:"TC",name:"Turks & Caicos Islands"},{code:"TV",name:"Tuvalu"},{code:"UM",name:"U.S. Outlying Islands"},{code:"VI",name:"U.S. Virgin Islands"},{code:"UG",name:"Uganda"},{code:"UA",name:"Ukraine"},{code:"AE",name:"United Arab Emirates"},{code:"GB",name:"United Kingdom"},{code:"US",name:"United States"},{code:"XX",name:"Unknown (Cloudflare could not determine)"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VU",name:"Vanuatu"},{code:"VA",name:"Vatican City"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"WF",name:"Wallis & Futuna"},{code:"EH",name:"Western Sahara"},{code:"YE",name:"Yemen"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}],LM="BR";function SM(t){if(!t)return!1;const e=Object.keys(t).sort();return e.length===3&&e[0]==="city"&&e[1]==="country"&&e[2]==="regionCode"}function wM(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{city:typeof e.city=="string"?e.city:"",regionCode:typeof e.regionCode=="string"?e.regionCode:"",country:typeof e.country=="string"?e.country:""}}function jM(t,e){const s={...t,...e},n={};for(const i of["city","regionCode","country"])s[i]&&(n[i]=s[i]);return n}function c1(t){const e=F.c(37),{id:s,options:n,value:i,placeholder:o,emptyMessage:a,onChange:l}=t,[c,d]=N.useState(!1);let h;if(e[0]!==n||e[1]!==i){let j;e[3]!==i?(j=S=>S.value===i,e[3]=i,e[4]=j):j=e[4],h=n.find(j),e[0]=n,e[1]=i,e[2]=h}else h=e[2];const u=h;let f;e[5]!==o||e[6]!==u?(f=u?r.jsx("span",{className:"truncate",children:u.label}):r.jsx("span",{className:"text-muted-foreground",children:o}),e[5]=o,e[6]=u,e[7]=f):f=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(k9,{className:"size-4 shrink-0 opacity-50"}),e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==c||e[11]!==f?(p=r.jsx(Ts,{asChild:!0,children:r.jsxs(le,{id:s,variant:"outline",role:"combobox","aria-expanded":c,className:"h-10 w-full justify-between font-normal",children:[f,m]})}),e[9]=s,e[10]=c,e[11]=f,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g={width:"var(--radix-popover-trigger-width)"},e[13]=g):g=e[13];let x;e[14]!==o?(x=r.jsx(Hi,{placeholder:o,className:"h-9"}),e[14]=o,e[15]=x):x=e[15];let v;e[16]!==a?(v=r.jsx(oi,{children:a}),e[16]=a,e[17]=v):v=e[17];let b;if(e[18]!==l||e[19]!==n||e[20]!==i){let j;e[22]!==l||e[23]!==i?(j=S=>r.jsxs(ks,{value:`${S.label} ${S.value}`,onSelect:()=>{l(S.value===i?"":S.value),d(!1)},children:[r.jsx("span",{className:"truncate",children:S.label}),r.jsx(ns,{className:ie("ml-auto size-4 shrink-0",i===S.value?"opacity-100":"opacity-0")})]},S.value),e[22]=l,e[23]=i,e[24]=j):j=e[24],b=n.map(j),e[18]=l,e[19]=n,e[20]=i,e[21]=b}else b=e[21];let _;e[25]!==b?(_=r.jsx(Os,{children:b}),e[25]=b,e[26]=_):_=e[26];let y;e[27]!==v||e[28]!==_?(y=r.jsxs(Wi,{children:[v,_]}),e[27]=v,e[28]=_,e[29]=y):y=e[29];let L;e[30]!==y||e[31]!==x?(L=r.jsx(As,{className:"p-0",style:g,children:r.jsxs(Dr,{children:[x,y]})}),e[30]=y,e[31]=x,e[32]=L):L=e[32];let w;return e[33]!==c||e[34]!==L||e[35]!==p?(w=r.jsxs(Es,{open:c,onOpenChange:d,children:[p,L]}),e[33]=c,e[34]=L,e[35]=p,e[36]=w):w=e[36],w}const CM=_M.map(t=>({value:t.code,label:`${t.name} (${t.code})`})),kM=Du.map(t=>({value:t.code,label:`${t.name} (${t.code})`}));function h5(t){const e=F.c(68),{schema:s,value:n,onChange:i,path:o}=t,a=oe();let l;e[0]!==n?(l=wM(n),e[0]=n,e[1]=l):l=e[1];const c=l,{city:d,regionCode:h,country:u}=c;let f;e[2]!==s.properties?(f=s.properties??{},e[2]=s.properties,e[3]=f):f=e[3];const m=f;let p;e[4]!==m.country?.title||e[5]!==a?(p=m.country?.title??a("sectionsEditor.locationField.countryDefault"),e[4]=m.country?.title,e[5]=a,e[6]=p):p=e[6];const g=p;let x;e[7]!==m.regionCode?.title||e[8]!==a?(x=m.regionCode?.title??a("sectionsEditor.locationField.regionDefault"),e[7]=m.regionCode?.title,e[8]=a,e[9]=x):x=e[9];const v=x;let b;e[10]!==m.city?.title||e[11]!==a?(b=m.city?.title??a("sectionsEditor.locationField.cityDefault"),e[10]=m.city?.title,e[11]=a,e[12]=b):b=e[12];const _=b;let y;e[13]!==c||e[14]!==i?(y=S=>{i(jM(c,S))},e[13]=c,e[14]=i,e[15]=y):y=e[15];const L=y,w=u===LM;let j;if(e[16]!==d||e[17]!==_||e[18]!==u||e[19]!==g||e[20]!==L||e[21]!==w||e[22]!==o||e[23]!==h||e[24]!==v||e[25]!==s.description||e[26]!==s.title||e[27]!==a){let S;e[29]!==h?(S=K=>K.code===h,e[29]=h,e[30]=S):S=e[30];const k=Du.find(S),C=`${o}.country`;let A;e[31]!==s.title||e[32]!==a?(A=s.title??a("sectionsEditor.locationField.locationDefault"),e[31]=s.title,e[32]=a,e[33]=A):A=e[33];let P;e[34]!==A||e[35]!==C?(P=r.jsx(st,{htmlFor:C,children:A}),e[34]=A,e[35]=C,e[36]=P):P=e[36];let V;e[37]!==s.description?(V=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[37]=s.description,e[38]=V):V=e[38];let T;e[39]!==P||e[40]!==V?(T=r.jsxs("div",{className:"space-y-0.5",children:[P,V]}),e[39]=P,e[40]=V,e[41]=T):T=e[41];const R=`${o}.country`;let E;e[42]!==g||e[43]!==R?(E=r.jsx(st,{htmlFor:R,className:"text-xs",children:g}),e[42]=g,e[43]=R,e[44]=E):E=e[44];const I=`${o}.country`;let D;e[45]!==a?(D=a("sectionsEditor.locationField.selectCountryPlaceholder"),e[45]=a,e[46]=D):D=e[46];let M;e[47]!==a?(M=a("sectionsEditor.locationField.noCountryFound"),e[47]=a,e[48]=M):M=e[48];let O;e[49]!==L?(O=K=>L({country:K,regionCode:"",city:""}),e[49]=L,e[50]=O):O=e[50];let $;e[51]!==u||e[52]!==I||e[53]!==D||e[54]!==M||e[55]!==O?($=r.jsx(c1,{id:I,options:CM,value:u,placeholder:D,emptyMessage:M,onChange:O}),e[51]=u,e[52]=I,e[53]=D,e[54]=M,e[55]=O,e[56]=$):$=e[56];let B;e[57]!==E||e[58]!==$?(B=r.jsxs("div",{className:"space-y-1.5",children:[E,$]}),e[57]=E,e[58]=$,e[59]=B):B=e[59];let z;e[60]!==u||e[61]!==L||e[62]!==w||e[63]!==o||e[64]!==h||e[65]!==v||e[66]!==a?(z=u&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:`${o}.regionCode`,className:"text-xs",children:v}),w?r.jsxs("div",{className:"space-y-2",children:[r.jsx(yM,{selected:h,onSelect:K=>L({regionCode:K===h?"":K,city:""})}),r.jsx(c1,{id:`${o}.regionCode`,options:kM,value:h,placeholder:a("sectionsEditor.locationField.selectStatePlaceholder"),emptyMessage:a("sectionsEditor.locationField.noStateFound"),onChange:K=>L({regionCode:K,city:""})})]}):r.jsxs(r.Fragment,{children:[r.jsx(et,{id:`${o}.regionCode`,type:"text",value:h,placeholder:a("sectionsEditor.locationField.regionCodePlaceholder"),onChange:K=>L({regionCode:K.target.value})}),r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a("sectionsEditor.locationField.regionCodeHelperText")})]})]}),e[60]=u,e[61]=L,e[62]=w,e[63]=o,e[64]=h,e[65]=v,e[66]=a,e[67]=z):z=e[67],j=r.jsxs("div",{className:"space-y-4",children:[T,B,z,u&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(st,{htmlFor:`${o}.city`,className:"text-xs",children:_}),r.jsx(et,{id:`${o}.city`,type:"text",value:d,placeholder:w&&k?a("sectionsEditor.locationField.cityPlaceholderWithState",{state:k.name}):a("sectionsEditor.locationField.cityPlaceholder"),onChange:K=>L({city:K.target.value})}),r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a("sectionsEditor.locationField.cityHelperText")})]})]}),e[16]=d,e[17]=_,e[18]=u,e[19]=g,e[20]=L,e[21]=w,e[22]=o,e[23]=h,e[24]=v,e[25]=s.description,e[26]=s.title,e[27]=a,e[28]=j}else j=e[28];return j}function VM(t){const e=t.schema;if(!e?.properties)return null;const s=new Set(Object.keys(t.discriminators??{}));if(s.size===0)return e;const n={};for(const[i,o]of Object.entries(e.properties))s.has(i)||(n[i]=o);return{...e,properties:n}}function NM(t){const e=F.c(50),s=oe(),{schema:n,value:i,onChange:o,path:a,label:l}=t;let c,d;e[0]!==n.inlineUnionBranches||e[1]!==i?(c=n.inlineUnionBranches??[],d=gM(i,c.map(AM)),e[0]=n.inlineUnionBranches,e[1]=i,e[2]=c,e[3]=d):(c=e[2],d=e[3]);const h=d,[u,f]=N.useState(h),[m,p]=N.useState(h);m!==h&&(p(h),f(h));const g=Math.min(u,c.length-1),x=c[g];let v;e[4]!==c||e[5]!==o?(v=M=>{const O=Number(M);f(O),o({...c[O]?.discriminators??{}})},e[4]=c,e[5]=o,e[6]=v):v=e[6];const b=v;if(c.length===0)return null;let _;e[7]!==x?(_=x?VM(x):null,e[7]=x,e[8]=_):_=e[8];const y=_;let L;if(e[9]!==x?.schema?.properties||e[10]!==i){let M;e[12]!==x?.schema?.properties?(M=x?.schema?.properties??{},e[12]=x?.schema?.properties,e[13]=M):M=e[13],L=xM(i,Object.keys(M)),e[9]=x?.schema?.properties,e[10]=i,e[11]=L}else L=e[11];const w=L;let j;e[14]!==l||e[15]!==a?(j=r.jsx(st,{htmlFor:a,children:l}),e[14]=l,e[15]=a,e[16]=j):j=e[16];const S=String(g);let k;e[17]!==s?(k=s("sectionsEditor.inlineUnionField.selectPlaceholder"),e[17]=s,e[18]=k):k=e[18];let C;e[19]!==k?(C=r.jsx(qt,{placeholder:k}),e[19]=k,e[20]=C):C=e[20];let A;e[21]!==a||e[22]!==C?(A=r.jsx($t,{id:a,children:C}),e[21]=a,e[22]=C,e[23]=A):A=e[23];let P;e[24]!==c?(P=c.map(TM),e[24]=c,e[25]=P):P=e[25];let V;e[26]!==P?(V=r.jsx(Bt,{children:P}),e[26]=P,e[27]=V):V=e[27];let T;e[28]!==b||e[29]!==V||e[30]!==S||e[31]!==A?(T=r.jsxs(Ft,{value:S,onValueChange:b,children:[A,V]}),e[28]=b,e[29]=V,e[30]=S,e[31]=A,e[32]=T):T=e[32];let R;e[33]!==n.description?(R=n.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:n.description}),e[33]=n.description,e[34]=R):R=e[34];let E;e[35]!==T||e[36]!==R||e[37]!==j?(E=r.jsxs("div",{className:"space-y-1.5",children:[j,T,R]}),e[35]=T,e[36]=R,e[37]=j,e[38]=E):E=e[38];let I;e[39]!==x||e[40]!==y||e[41]!==o||e[42]!==a||e[43]!==w||e[44]!==t||e[45]!==i?(I=x&&(SM(x.schema?.properties)?r.jsx(h5,{...t,schema:x.schema,onChange:M=>o({...w,...M,...x.discriminators??{}})}):y?r.jsx(Bn,{schema:y,value:i,onChange:M=>o({...M,...x.discriminators??{}}),basePath:a,breadcrumbPath:t.breadcrumbPath,onBreadcrumbChange:t.onBreadcrumbChange,meta:t.meta,decofile:t.decofile,onSaveReferencedBlock:t.onSaveReferencedBlock,sandbox:t.sandbox,previewBaseUrl:t.previewBaseUrl,onAddSectionItem:t.onAddSectionItem,onRequestAddSection:t.onRequestAddSection}):null),e[39]=x,e[40]=y,e[41]=o,e[42]=a,e[43]=w,e[44]=t,e[45]=i,e[46]=I):I=e[46];let D;return e[47]!==E||e[48]!==I?(D=r.jsxs("div",{className:"space-y-3",children:[E,I]}),e[47]=E,e[48]=I,e[49]=D):D=e[49],D}function TM(t,e){return r.jsx(ut,{value:String(e),children:t.title},t.title)}function AM(t){return{discriminators:t.discriminators,propertyKeys:Object.keys(t.schema?.properties??{})}}const EM={lat:-21.9,lng:-41.42},c0=1e5;let za=null;function PM(t){return za||(za=new Promise((e,s)=>{if(typeof window>"u"){s(new Error("Google Maps requires a browser environment"));return}const n=window;if(n.google?.maps){e(n.google.maps);return}const i=()=>{const l=window.google?.maps;l?e(l):s(new Error("Google Maps script loaded without google.maps"))},o=document.querySelector("script[data-google-maps-loader]");if(o){o.addEventListener("load",i),o.addEventListener("error",()=>s(new Error("Failed to load Google Maps")));return}const a=document.createElement("script");a.src=`https://maps.googleapis.com/maps/api/js?key=${t}&v=weekly&libraries=maps`,a.async=!0,a.defer=!0,a.dataset.googleMapsLoader="true",a.addEventListener("load",i),a.addEventListener("error",()=>s(new Error("Failed to load Google Maps"))),document.head.appendChild(a)}),za)}function RM(t){if(typeof t!="string"||!t)return null;const e=t.split(",").map(Number),[s,n,i]=e;return!Number.isFinite(s)||!Number.isFinite(n)?null:{lat:s,lng:n,radius:Number.isFinite(i)?i:c0}}function DM({schema:t,value:e,onChange:s,path:n,label:i}){const o=km().googleMapsApiKey,a=N.useRef(s);a.current=s;const l=N.useRef(RM(e)),[c,d]=N.useState(null),h=N.useRef(null),u=f=>{if(!f||!o)return;const m={disposed:!1,circle:null,listeners:[]};return PM(o).then(p=>{if(m.disposed)return;const g=l.current,x=g?{lat:g.lat,lng:g.lng}:EM,v=g?.radius??c0,b=new p.Map(f,{center:x,zoom:v?Math.round(Math.log2(768e4/v))+1:4,draggable:!0,streetViewControl:!1,mapTypeControl:!1}),_=new p.Circle({strokeColor:"#2E6ED9",strokeOpacity:.8,strokeWeight:2,fillColor:"#2E6ED9",fillOpacity:.35,editable:!0,draggable:!0,map:b,center:x,radius:v});m.circle=_;const y=()=>{const w=_.getCenter(),j=_.getRadius();w&&a.current(`${w.lat()},${w.lng()},${j}`)},L=w=>{w&&m.listeners.push(w)};L(b.addListener("click",w=>{w.latLng&&(_.setCenter({lat:w.latLng.lat(),lng:w.latLng.lng()}),_.getRadius()||_.setRadius(c0),y())})),L(_.addListener("radius_changed",y)),L(_.addListener("dragend",y))},p=>{m.disposed||d(p instanceof Error?p.message:"Failed to load map")}),()=>{m.disposed=!0;for(const p of m.listeners)try{p?.remove()}catch{}if(m.listeners=[],m.circle){try{m.circle.setMap(null)}catch{}m.circle=null}}};return h.current||(h.current=u),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(st,{htmlFor:n,children:i}),t.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),o?c?r.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:c}):r.jsx("div",{ref:h.current,id:n,className:"h-72 w-full rounded-md border border-border/60"}):r.jsxs("div",{className:"rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:["The map picker is unavailable — set"," ",r.jsx("code",{className:"font-mono",children:"GOOGLE_MAPS_API_KEY"})," on the server to enable it."]})]})}const IM="oklch(0.65 0.15 160)",MM="text-[oklch(0.45_0.15_160)] hover:bg-[oklch(0.65_0.15_160/0.12)] dark:text-[oklch(0.78_0.15_160)] dark:hover:bg-[oklch(0.65_0.15_160/0.15)]",f5="text-[oklch(0.45_0.15_160)] bg-[oklch(0.65_0.15_160/0.18)] dark:text-[oklch(0.78_0.15_160)] dark:bg-[oklch(0.65_0.15_160/0.2)]",sG="text-[oklch(0.45_0.15_160)] focus:bg-[oklch(0.65_0.15_160/0.12)] focus:text-[oklch(0.45_0.15_160)] dark:text-[oklch(0.78_0.15_160)] dark:focus:bg-[oklch(0.65_0.15_160/0.15)] dark:focus:text-[oklch(0.78_0.15_160)]";function d1(t){return t.map(e=>e.label).join(`
456
- `)}function fd(t){return t.map(e=>({id:crypto.randomUUID(),index:e.index,label:e.label}))}function OM(t){return t.map((e,s)=>({...e,index:s}))}function m5(t){const e=F.c(19),{label:s,canDelete:n,dragging:i,onRename:o,onDuplicate:a,onDelete:l}=t,c=oe(),d=i?"opacity-100":"opacity-0 group-hover:opacity-100";let h;e[0]!==d?(h=ie("h-4 w-4 shrink-0 text-muted-foreground/40 transition-opacity",d),e[0]=d,e[1]=h):h=e[1];let u;e[2]!==h?(u=r.jsx(ca,{className:h}),e[2]=h,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(An,{className:"h-4 w-4 shrink-0",style:{color:IM}}),e[4]=f):f=e[4];let m;e[5]!==s?(m=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:s}),e[5]=s,e[6]=m):m=e[6];let p;e[7]!==n||e[8]!==i||e[9]!==s||e[10]!==l||e[11]!==a||e[12]!==o||e[13]!==c?(p=!i&&r.jsxs(vs,{children:[r.jsx(bs,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":c("sectionsEditor.sectionVariantList.openActionsFor",{label:s}),className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",onClick:BM,onPointerDown:$M,children:r.jsx(Ki,{size:14})})}),r.jsxs(ys,{align:"end",children:[o&&r.jsxs(Je,{onClick:x=>{x.stopPropagation(),o()},children:[r.jsx(r8,{size:14}),c("sectionsEditor.sectionVariantList.rename")]}),r.jsxs(Je,{onClick:x=>{x.stopPropagation(),a?.()},children:[r.jsx(Vs,{size:14}),c("sectionsEditor.sectionVariantList.duplicate")]}),r.jsxs(Je,{variant:"destructive",disabled:!n,onClick:x=>{x.stopPropagation(),l?.()},children:[r.jsx(_s,{size:14}),c("sectionsEditor.sectionVariantList.delete")]})]})]}),e[7]=n,e[8]=i,e[9]=s,e[10]=l,e[11]=a,e[12]=o,e[13]=c,e[14]=p):p=e[14];let g;return e[15]!==u||e[16]!==m||e[17]!==p?(g=r.jsxs(r.Fragment,{children:[u,f,m,p]}),e[15]=u,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function $M(t){return t.stopPropagation()}function BM(t){return t.stopPropagation()}function FM(t){const e=F.c(27),{entry:s,selected:n,canDelete:i,onSelect:o,onRename:a,onDuplicate:l,onDelete:c}=t;let d;e[0]!==s.id?(d={id:s.id,animateLayoutChanges:zM},e[0]=s.id,e[1]=d):d=e[1];const{attributes:h,listeners:u,setNodeRef:f,transform:m,isDragging:p}=hu(d);let g;e[2]!==m?(g=Sn.Transform.toString(m?{...m,x:0}:null),e[2]=m,e[3]=g):g=e[3];const x=p?0:void 0;let v;e[4]!==g||e[5]!==x?(v={transform:g,opacity:x},e[4]=g,e[5]=x,e[6]=v):v=e[6];const b=v;let _;e[7]!==o?(_=k=>{k.target===k.currentTarget&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o())},e[7]=o,e[8]=_):_=e[8];const y=p?"cursor-grabbing":"cursor-grab",L=n?f5:MM;let w;e[9]!==y||e[10]!==L?(w=ie("group flex select-none items-center gap-2 rounded-md px-2 py-2.5 transition-colors touch-none",y,L),e[9]=y,e[10]=L,e[11]=w):w=e[11];let j;e[12]!==i||e[13]!==s.label||e[14]!==c||e[15]!==l||e[16]!==a?(j=r.jsx(m5,{label:s.label,canDelete:i,onRename:a,onDuplicate:l,onDelete:c}),e[12]=i,e[13]=s.label,e[14]=c,e[15]=l,e[16]=a,e[17]=j):j=e[17];let S;return e[18]!==h||e[19]!==u||e[20]!==o||e[21]!==f||e[22]!==b||e[23]!==_||e[24]!==w||e[25]!==j?(S=r.jsx("div",{ref:f,style:b,...h,...u,onClick:o,onKeyDown:_,className:w,children:j}),e[18]=h,e[19]=u,e[20]=o,e[21]=f,e[22]=b,e[23]=_,e[24]=w,e[25]=j,e[26]=S):S=e[26],S}function zM(){return!1}function KM(t){const e=F.c(103),{listKey:s,variants:n,selectedIndex:i,onSelect:o,onRename:a,onDuplicate:l,onDelete:c,onRemoveAll:d,onReorder:h,onAdd:u}=t,f=oe(),m=n.length>1;let p;e[0]!==n?(p=()=>fd(n),e[0]=n,e[1]=p):p=e[1];const[g,x]=N.useState(p),[v,b]=N.useState(null),[_,y]=N.useState(s),[L,w]=N.useState(n.length);let j;e[2]!==n?(j=()=>d1(n),e[2]=n,e[3]=j):j=e[3];const[S,k]=N.useState(j),C=N.useRef(!1),A=d1(n);_!==s?(y(s),w(n.length),k(A),x(fd(n))):L!==n.length?(w(n.length),k(A),x(fd(n))):S!==A&&(k(A),x(ue=>n.map((ae,me)=>({id:ue[me]?.id??crypto.randomUUID(),index:ae.index,label:ae.label}))));let P;e[4]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{distance:8}},e[4]=P):P=e[4];let V;e[5]===Symbol.for("react.memo_cache_sentinel")?(V={coordinateGetter:fu},e[5]=V):V=e[5];const T=bc(li(Kr,P),li(zr,V));let R;e[6]!==g?(R=g.map(UM),e[6]=g,e[7]=R):R=e[7];const E=R;let I;e[8]!==g?(I=ue=>{const ae=String(ue.active.id);b(g.find(me=>me.id===ae)??null)},e[8]=g,e[9]=I):I=e[9];const D=I;let M;e[10]!==E||e[11]!==h?(M=ue=>{b(null);const{active:ae,over:me}=ue;if(!me||ae.id===me.id)return;const xe=E.indexOf(String(ae.id)),Se=E.indexOf(String(me.id));xe===-1||Se===-1||(x(Ve=>OM(wr([...Ve],xe,Se))),C.current=!0,requestAnimationFrame(()=>{C.current=!1}),h(xe,Se))},e[10]=E,e[11]=h,e[12]=M):M=e[12];const O=M;let $;e[13]===Symbol.for("react.memo_cache_sentinel")?($=()=>{b(null)},e[13]=$):$=e[13];const B=$;let z,K,Y,Q,q,H,U,X,J,ee,W,Z,G;if(e[14]!==m||e[15]!==g||e[16]!==E||e[17]!==O||e[18]!==D||e[19]!==u||e[20]!==c||e[21]!==l||e[22]!==d||e[23]!==a||e[24]!==o||e[25]!==i||e[26]!==T||e[27]!==f){const ue=Ce=>{C.current||o(Ce)};W="space-y-1 border-b p-2";let ae;e[41]!==f?(ae=f("sectionsEditor.sectionVariantList.title"),e[41]=f,e[42]=ae):ae=e[42];let me;e[43]!==ae?(me=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:ae}),e[43]=ae,e[44]=me):me=e[44];let xe;e[45]!==f?(xe=f("sectionsEditor.sectionVariantList.addVariantAriaLabel"),e[45]=f,e[46]=xe):xe=e[46];let Se;e[47]===Symbol.for("react.memo_cache_sentinel")?(Se=r.jsx(_t,{size:14}),e[47]=Se):Se=e[47];let Ve;e[48]!==u||e[49]!==xe?(Ve=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":xe,className:"size-6",onClick:u,children:Se})}),e[48]=u,e[49]=xe,e[50]=Ve):Ve=e[50];let Ie;e[51]!==f?(Ie=f("sectionsEditor.sectionVariantList.addVariant"),e[51]=f,e[52]=Ie):Ie=e[52];let Ne;e[53]!==Ie?(Ne=r.jsx(He,{children:Ie}),e[53]=Ie,e[54]=Ne):Ne=e[54];let Ee;e[55]!==Ve||e[56]!==Ne?(Ee=r.jsxs(We,{children:[Ve,Ne]}),e[55]=Ve,e[56]=Ne,e[57]=Ee):Ee=e[57];let we;e[58]!==f?(we=f("sectionsEditor.sectionVariantList.removeAllVariantsAriaLabel"),e[58]=f,e[59]=we):we=e[59];let Ae;e[60]===Symbol.for("react.memo_cache_sentinel")?(Ae=r.jsx(_s,{size:14}),e[60]=Ae):Ae=e[60];let be;e[61]!==d||e[62]!==we?(be=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":we,className:"size-6 text-muted-foreground hover:text-destructive",onClick:d,children:Ae})}),e[61]=d,e[62]=we,e[63]=be):be=e[63];let je;e[64]!==f?(je=f("sectionsEditor.sectionVariantList.removeAllVariants"),e[64]=f,e[65]=je):je=e[65];let ge;e[66]!==je?(ge=r.jsx(He,{children:je}),e[66]=je,e[67]=ge):ge=e[67];let Le;e[68]!==be||e[69]!==ge?(Le=r.jsxs(We,{children:[be,ge]}),e[68]=be,e[69]=ge,e[70]=Le):Le=e[70];let ye;e[71]!==Ee||e[72]!==Le?(ye=r.jsxs("div",{className:"flex items-center gap-0.5",children:[Ee,Le]}),e[71]=Ee,e[72]=Le,e[73]=ye):ye=e[73],e[74]!==me||e[75]!==ye?(Z=r.jsxs("div",{className:"flex items-center justify-between",children:[me,ye]}),e[74]=me,e[75]=ye,e[76]=Z):Z=e[76],K=Sc,H=T,U=su,X=D,J=O,ee=B,z=uu,Q=E,q=du,G="space-y-0.5",Y=g.map(Ce=>r.jsx(FM,{entry:Ce,selected:Ce.index===i,canDelete:m,onSelect:()=>ue(Ce.index),onRename:a?()=>a(Ce.index):void 0,onDuplicate:()=>l(Ce.index),onDelete:()=>c(Ce.index)},Ce.id)),e[14]=m,e[15]=g,e[16]=E,e[17]=O,e[18]=D,e[19]=u,e[20]=c,e[21]=l,e[22]=d,e[23]=a,e[24]=o,e[25]=i,e[26]=T,e[27]=f,e[28]=z,e[29]=K,e[30]=Y,e[31]=Q,e[32]=q,e[33]=H,e[34]=U,e[35]=X,e[36]=J,e[37]=ee,e[38]=W,e[39]=Z,e[40]=G}else z=e[28],K=e[29],Y=e[30],Q=e[31],q=e[32],H=e[33],U=e[34],X=e[35],J=e[36],ee=e[37],W=e[38],Z=e[39],G=e[40];let te;e[77]!==Y||e[78]!==G?(te=r.jsx("div",{className:G,children:Y}),e[77]=Y,e[78]=G,e[79]=te):te=e[79];let se;e[80]!==z||e[81]!==Q||e[82]!==q||e[83]!==te?(se=r.jsx(z,{items:Q,strategy:q,children:te}),e[80]=z,e[81]=Q,e[82]=q,e[83]=te,e[84]=se):se=e[84];let re;e[85]!==v||e[86]!==m?(re=v?r.jsx("div",{className:ie("flex items-center gap-2 rounded-md px-2 py-2.5 shadow-lg ring-1 ring-border/60 cursor-grabbing",f5),children:r.jsx(m5,{label:v.label,canDelete:m,dragging:!0})}):null,e[85]=v,e[86]=m,e[87]=re):re=e[87];let de;e[88]!==re?(de=Zs.createPortal(r.jsx(ou,{dropAnimation:F4,children:re}),document.body),e[88]=re,e[89]=de):de=e[89];let ce;e[90]!==K||e[91]!==H||e[92]!==U||e[93]!==X||e[94]!==J||e[95]!==ee||e[96]!==se||e[97]!==de?(ce=r.jsxs(K,{sensors:H,collisionDetection:U,onDragStart:X,onDragEnd:J,onDragCancel:ee,children:[se,de]}),e[90]=K,e[91]=H,e[92]=U,e[93]=X,e[94]=J,e[95]=ee,e[96]=se,e[97]=de,e[98]=ce):ce=e[98];let fe;return e[99]!==W||e[100]!==Z||e[101]!==ce?(fe=r.jsxs("div",{className:W,children:[Z,ce]}),e[99]=W,e[100]=Z,e[101]=ce,e[102]=fe):fe=e[102],fe}function UM(t){return t.id}const HM=[[/always|matchalways/i,"Users03"],[/device|matchdevice/i,"Phone02"],[/date|matchdate/i,"Calendar"],[/random|matchrandom/i,"Shuffle01"],[/host|matchhost/i,"Globe02"],[/location|matchlocation/i,"MarkerPin01"],[/pathname/i,"Link03"],[/cron|matchcron/i,"Clock"],[/multi|matchmulti/i,"FilterLines"],[/never|matchnever/i,"EyeOff"],[/environment|matchenvironment/i,"Cloud01"],[/eq\.ts|\/eq$/i,"Brackets"],[/user|requser|isdecouser/i,"User01"],[/site|template/i,"LayoutAlt01"]],WM={"device-mobile":"Phone02","device-desktop":"Monitor01","device-tablet":"Tablet01","calendar-event":"Calendar","calendar-month":"Calendar",clock:"Clock","current-location":"MarkerPin01","map-2":"MarkerPin01","world-search":"Globe02",shuffle:"Shuffle01",filter:"FilterLines","eye-off":"EyeOff",flask:"Beaker02",link:"Link03","git-merge":"GitBranch01",users:"Users03",flag:"Flag01","cloud-storm":"Cloud01",campaign:"Announcement01",experiment:"Beaker02",language:"Globe02","hand-click":"CursorClick01"};function md(t){return zi(t)!==void 0}function Iu(t,e){if(e){if(md(e))return e;const s=WM[e];if(s&&md(s))return s}for(const[s,n]of HM)if(s.test(t)&&md(n))return n;return"FilterLines"}function qM(t){return zi(t)??$8}function pd(t){const e=F.c(11),{iconName:s,size:n,className:i}=t,o=n===void 0?"md":n;let a;e[0]!==s?(a=qM(s),e[0]=s,e[1]=a):a=e[1];const l=a,c=o==="sm"?"size-7":"size-9",d=o==="sm"?16:18;let h;e[2]!==c||e[3]!==i?(h=ie("flex shrink-0 items-center justify-center rounded-full bg-muted",c,i),e[2]=c,e[3]=i,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==d?(u=r.jsx(l,{size:d,className:"text-muted-foreground"}),e[5]=l,e[6]=d,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=r.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}const GM=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),YM=5,JM=new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"});function u1(t){const{start:e,end:s}=t,n=typeof e=="string"?e:"",i=typeof s=="string"?s:"";if(!n&&!i)return null;const o=c=>{if(!c)return null;const d=new Date(c);return Number.isNaN(d.getTime())?null:JM.format(d)},a=o(n),l=o(i);return a&&l?`${a} → ${l}`:a?`From ${a}`:l?`Until ${l}`:null}function zl(t,e=0){if(!t)return"Default";if(e>YM)return"...";const s=t.__resolveType??"";if(["website/matchers/always.ts","$live/matchers/MatchAlways.ts"].includes(s)||s==="")return"Default";switch(s){case"website/matchers/never.ts":return"Hidden";case"website/matchers/device.ts":case"$live/matchers/MatchDevice.ts":{const{mobile:i,tablet:o,desktop:a,devices:l=[]}=t,c=[...l];return i&&c.push("Mobile"),o&&c.push("Tablet"),a&&c.push("Desktop"),c.length>0?c.map(GM).join(" & "):At(s)}case"website/matchers/date.ts":case"$live/matchers/MatchDate.ts":return u1(t)??At(s);case"website/matchers/random.ts":case"$live/matchers/MatchRandom.ts":{const{traffic:i}=t;return typeof i=="number"?`${Math.ceil(i*100)}% of sessions`:At(s)}case"website/matchers/host.ts":case"$live/matchers/MatchHost.ts":{const{includes:i,match:o}=t,a=[];return i&&a.push(i),o&&a.push(o),a.length>0?a.join(" - "):At(s)}case"website/matchers/pathname.ts":{const i=t.case,{type:o,pathname:a}=i??{};return o&&a?`Pathname ${o} ${a}`:At(s)}case"website/matchers/location.ts":case"$live/matchers/MatchLocation.ts":{const{includeLocations:i,excludeLocations:o}=t,a=d=>[d.city,d.regionCode,d.country].filter(Boolean).join(" - "),l=i?.[0];if(l){const d=(i?.length??0)-1;return`${a(l)}${d>0?` +${d}`:""}`}const c=o?.[0];if(c){const d=(o?.length??0)-1;return`Except ${a(c)}${d>0?` +${d}`:""}`}return"Any location"}case"website/matchers/multi.ts":case"$live/matchers/MatchMulti.ts":{const{matchers:i,op:o="AND"}=t;if(i&&i.length>0){const a=o==="OR"?"OR":"AND";return i.map(l=>zl(l,e+1)).join(` ${a} `)}return At(s)}default:{const i=u1(t);return i||At(s)||"Default"}}}function nG(t,e){return lE(t,e).map(s=>{const n=e[s.blockKey]??{},i=e4(uE(s.blockKey),e,t);return{blockKey:s.blockKey,title:pc(s.blockKey,n),description:zl(i),iconName:Iu(s.matcherResolveType)}})}const p5="Users03";function XM(t){const e=t.manifest?.blocks??{},s=[];for(const[n,i]of Object.entries(e))if(n.includes("matchers"))for(const o of Object.keys(i)){if(o.includes("always"))continue;const a=gi(o,t);s.push({resolveType:o,title:a.title??At(o),description:a.description,iconName:Iu(o,a.icon)})}return s}function QM(t,e){if(!t)return p5;const s=e.find(n=>n.resolveType===t);return s?s.iconName:Iu(t)}function ZM(t){const e=F.c(80),{currentRt:s,currentLabel:n,currentGlobalKey:i,matchers:o,globals:a,onSelect:l,onSelectGlobal:c}=t,d=a===void 0?[]:a,[h,u]=N.useState(!1),f=oe(),p=(i?d.find(J=>J.blockKey===i):void 0)?.iconName??QM(s,o),g=zi(p);let x;e[0]!==l||e[1]!==u?(x=J=>{l(J),u(!1)},e[0]=l,e[1]=u,e[2]=x):x=e[2];const v=x;let b;e[3]!==c||e[4]!==u?(b=J=>{c?.(J),u(!1)},e[3]=c,e[4]=u,e[5]=b):b=e[5];const _=b;let y;e[6]!==u?(y=()=>u(!0),e[6]=u,e[7]=y):y=e[7];let L;e[8]!==g?(L=g&&r.jsx(g,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[8]=g,e[9]=L):L=e[9];let w;e[10]!==n?(w=r.jsx("span",{className:"flex-1 truncate",children:n}),e[10]=n,e[11]=w):w=e[11];let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(is,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[12]=j):j=e[12];let S;e[13]!==y||e[14]!==L||e[15]!==w?(S=r.jsxs("button",{type:"button",onClick:y,className:"flex h-10 w-full items-center gap-2 rounded-md border border-input bg-transparent px-3 text-left text-sm shadow-xs transition-colors hover:bg-accent/40 cursor-pointer",children:[L,w,j]}),e[13]=y,e[14]=L,e[15]=w,e[16]=S):S=e[16];let k;e[17]!==f?(k=f("sectionsEditor.matcherPicker.chooseRuleTitle"),e[17]=f,e[18]=k):k=e[18];let C;e[19]!==f?(C=f("sectionsEditor.matcherPicker.chooseRuleDescription"),e[19]=f,e[20]=C):C=e[20];let A;e[21]!==f?(A=f("sectionsEditor.matcherPicker.searchRulesPlaceholder"),e[21]=f,e[22]=A):A=e[22];let P;e[23]!==A?(P=r.jsx(Hi,{placeholder:A}),e[23]=A,e[24]=P):P=e[24];let V;e[25]!==f?(V=f("sectionsEditor.matcherPicker.noRulesFound"),e[25]=f,e[26]=V):V=e[26];let T;e[27]!==V?(T=r.jsx(oi,{children:V}),e[27]=V,e[28]=T):T=e[28];let R;e[29]!==v?(R=()=>v(""),e[29]=v,e[30]=R):R=e[30];const E=!s&&!i&&"bg-accent/60";let I;e[31]!==E?(I=ie("gap-2.5",E),e[31]=E,e[32]=I):I=e[32];let D;e[33]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(pd,{iconName:p5,size:"sm"}),e[33]=D):D=e[33];let M;e[34]!==f?(M=f("sectionsEditor.matcherPicker.alwaysLabel"),e[34]=f,e[35]=M):M=e[35];let O;e[36]!==M?(O=r.jsx("span",{className:"text-sm",children:M}),e[36]=M,e[37]=O):O=e[37];let $;e[38]!==f?($=f("sectionsEditor.matcherPicker.targetAllUsers"),e[38]=f,e[39]=$):$=e[39];let B;e[40]!==$?(B=r.jsx("span",{className:"text-xs text-muted-foreground",children:$}),e[40]=$,e[41]=B):B=e[41];let z;e[42]!==O||e[43]!==B?(z=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[O,B]}),e[42]=O,e[43]=B,e[44]=z):z=e[44];let K;e[45]!==R||e[46]!==I||e[47]!==z?(K=r.jsxs(ks,{value:"always Target all users",onSelect:R,className:I,children:[D,z]}),e[45]=R,e[46]=I,e[47]=z,e[48]=K):K=e[48];let Y;if(e[49]!==i||e[50]!==s||e[51]!==v||e[52]!==o){let J;e[54]!==i||e[55]!==s||e[56]!==v?(J=ee=>r.jsxs(ks,{value:`${ee.title} ${ee.resolveType} ${ee.description??""}`,onSelect:()=>v(ee.resolveType),className:ie("gap-2.5",!i&&s===ee.resolveType&&"bg-accent/60"),children:[r.jsx(pd,{iconName:ee.iconName,size:"sm"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"text-sm",children:ee.title}),ee.description&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:ee.description})]})]},ee.resolveType),e[54]=i,e[55]=s,e[56]=v,e[57]=J):J=e[57],Y=o.map(J),e[49]=i,e[50]=s,e[51]=v,e[52]=o,e[53]=Y}else Y=e[53];let Q;e[58]!==K||e[59]!==Y?(Q=r.jsxs(Os,{children:[K,Y]}),e[58]=K,e[59]=Y,e[60]=Q):Q=e[60];let q;e[61]!==i||e[62]!==d||e[63]!==_||e[64]!==f?(q=d.length>0&&r.jsx(Os,{heading:f("sectionsEditor.matcherPicker.savedRulesHeading"),children:d.map(J=>r.jsxs(ks,{value:`${J.title} ${J.blockKey} ${J.description??""}`,onSelect:()=>_(J.blockKey),className:ie("gap-2.5",i===J.blockKey&&"bg-accent/60"),children:[r.jsx(pd,{iconName:J.iconName,size:"sm"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate text-sm",children:J.title}),J.description&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:J.description})]})]},J.blockKey))}),e[61]=i,e[62]=d,e[63]=_,e[64]=f,e[65]=q):q=e[65];let H;e[66]!==T||e[67]!==Q||e[68]!==q?(H=r.jsxs(Wi,{children:[T,Q,q]}),e[66]=T,e[67]=Q,e[68]=q,e[69]=H):H=e[69];let U;e[70]!==h||e[71]!==u||e[72]!==C||e[73]!==P||e[74]!==H||e[75]!==k?(U=r.jsxs(D8,{open:h,onOpenChange:u,title:k,description:C,className:"sm:max-w-lg",children:[P,H]}),e[70]=h,e[71]=u,e[72]=C,e[73]=P,e[74]=H,e[75]=k,e[76]=U):U=e[76];let X;return e[77]!==U||e[78]!==S?(X=r.jsxs(r.Fragment,{children:[S,U]}),e[77]=U,e[78]=S,e[79]=X):X=e[79],X}const h1=new WeakMap;function eO(t,e){let s=h1.get(e);s||(s=new Map,h1.set(e,s));let n=s.get(t);return n===void 0&&(n=Ln(t,e),s.set(t,n)),n}function tO(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.__resolveType=="string"&&Array.isArray(e.variants)}function sO(t,e){return{__resolveType:e,variants:[{rule:Lr(),value:structuredClone(t)},{rule:Lr(),value:structuredClone(t)}]}}function nO(t){const e=t.variants;if(e.length===0)return;const s=e.find(n=>_u(n.rule));return s?s.value:e[e.length-1]?.value}function iO(t){const e=[...t.variants],s=e[e.length-1],n={rule:Lr(),value:s?structuredClone(s.value):void 0};return{...t,variants:[...e,n]}}function rO(t,e){if(t.variants.length<=1)return null;const s=[...t.variants];return s.splice(e,1),{...t,variants:s}}function oO(t,e){const s=[...t.variants],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function aO(t,e,s){const n=[...t.variants];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[i]=n.splice(e,1);return i?(n.splice(s,0,i),{...t,variants:n}):t}function lO(t,e,s){const n=[...t.variants],i=n[e];return i?(n[e]={...i,value:s},{...t,variants:n}):t}function f1(t,e,s){const n=[...t.variants],i=n[e];return i?(n[e]={...i,rule:s},{...t,variants:n}):t}const m1=new WeakMap;function cO(t){let e=m1.get(t);return e||(e=XM(t),m1.set(t,e)),e}function g5(t){const e=F.c(10),{multivariateResolveType:s,renderInnerField:n,...i}=t,o=oe(),{value:a,onChange:l,meta:c,path:d}=i,[h,u]=N.useState(0);if(!tO(a)){let M;e[0]!==o?(M=o("sectionsEditor.multivariateFieldWrapper.addVariant"),e[0]=o,e[1]=M):M=e[1];let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(j9,{size:14}),e[2]=O):O=e[2];let $;e[3]!==o?($=o("sectionsEditor.multivariateFieldWrapper.addVariant"),e[3]=o,e[4]=$):$=e[4];let B;return e[5]!==$?(B=r.jsx(He,{children:$}),e[5]=$,e[6]=B):B=e[6],r.jsxs("div",{className:"relative grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 size-6 text-muted-foreground hover:text-foreground","aria-label":M,onClick:()=>{l(sO(a,s)),u(0)},children:O})}),B]}),n(i)]})}const f=a,m=f.variants,p=Math.min(h,m.length-1);let g;e[7]!==o?(g=(M,O)=>({index:O,label:zl(M.rule)||o("sectionsEditor.multivariateFieldWrapper.variantN",{n:String(O+1)})}),e[7]=o,e[8]=g):g=e[8];const x=m.map(g),v=m[p],b=v?.rule??{},_=b.__resolveType??"",y=v?.value,L=c?cO(c):[],w=_&&c?eO(_,c):null,{__resolveType:j,...S}=b,k=()=>{l(nO(f)),u(0)},C=()=>{const M=iO(f);l(M),u(M.variants.length-1)},A=M=>{const O=rO(f,M);O&&(l(O),p>=O.variants.length&&u(O.variants.length-1))},P=M=>{const O=oO(f,M);l(O),u(M+1)},V=(M,O)=>{const $=aO(f,M,O);l($),p===M&&u(O)},T=M=>{l(f1(f,p,M?{__resolveType:M}:{__resolveType:Xp}))},R=M=>{const O=M,$=_?{...O,__resolveType:_}:{...O};l(f1(f,p,$))},E=M=>{l(lO(f,p,M))},I=`${d}-${f.__resolveType}`;let D;return e[9]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(st,{className:"text-xs text-muted-foreground",children:"Rule"}),e[9]=D):D=e[9],r.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-0",children:[r.jsx(KM,{listKey:I,variants:x,selectedIndex:p,onSelect:u,onDuplicate:P,onDelete:A,onRemoveAll:k,onReorder:V,onAdd:C}),r.jsxs("div",{className:"space-y-4 px-2 pt-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[D,r.jsx(ZM,{currentRt:_,currentLabel:zl(b),matchers:L,onSelect:T}),w&&r.jsx("div",{className:"pt-1",children:r.jsx(Bn,{schema:w,value:S,onChange:R,basePath:""})})]}),n({...i,value:y,onChange:E})]})]})}const dO="website/loaders/secret.ts";function Po(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t.__resolveType;return typeof e=="string"&&(e.endsWith("/secret.ts")||e.includes("loaders/secret"))}function uO(){return{__resolveType:dO,name:"",encrypted:""}}function hO(t){const{value:e,...s}=t;return s}function gd(t){const e=F.c(55),{schema:s,value:n,onChange:i,label:o,path:a}=t,l=oe();if(typeof n=="string"||n==null&&!Po(n)){const k=typeof n=="string"?n:"";let C;e[0]!==o||e[1]!==a?(C=r.jsx(st,{htmlFor:a,className:"text-sm font-medium",children:o}),e[0]=o,e[1]=a,e[2]=C):C=e[2];let A;e[3]!==s.description?(A=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=A):A=e[4];let P;e[5]!==l?(P=l("sectionsEditor.secretField.secretValuePlaceholder"),e[5]=l,e[6]=P):P=e[6];let V;e[7]!==i?(V=E=>i(E.target.value),e[7]=i,e[8]=V):V=e[8];let T;e[9]!==a||e[10]!==k||e[11]!==P||e[12]!==V?(T=r.jsx(et,{id:a,type:"password",value:k,autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:P,onChange:V,className:"h-10"}),e[9]=a,e[10]=k,e[11]=P,e[12]=V,e[13]=T):T=e[13];let R;return e[14]!==C||e[15]!==A||e[16]!==T?(R=r.jsxs("div",{className:"space-y-2",children:[C,A,T]}),e[14]=C,e[15]=A,e[16]=T,e[17]=R):R=e[17],R}let c;e[18]!==n?(c=Po(n)?n:uO(),e[18]=n,e[19]=c):c=e[19];const d=c,h=typeof d.name=="string"?d.name:"",u=typeof d.encrypted=="string"&&d.encrypted,f=`${a}-name`;let m;e[20]!==o||e[21]!==f?(m=r.jsx(st,{htmlFor:f,className:"text-sm font-medium",children:o}),e[20]=o,e[21]=f,e[22]=m):m=e[22];let p;e[23]!==s.description?(p=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[23]=s.description,e[24]=p):p=e[24];const g=`${a}-name`;let x;e[25]!==l?(x=l("sectionsEditor.secretField.secretNamePlaceholder"),e[25]=l,e[26]=x):x=e[26];let v;e[27]!==d||e[28]!==i?(v=k=>i({...d,name:k.target.value}),e[27]=d,e[28]=i,e[29]=v):v=e[29];let b;e[30]!==h||e[31]!==g||e[32]!==x||e[33]!==v?(b=r.jsx(et,{id:g,value:h,placeholder:x,onChange:v,className:"h-10"}),e[30]=h,e[31]=g,e[32]=x,e[33]=v,e[34]=b):b=e[34];const _=`${a}-value`;let y;e[35]!==u||e[36]!==l?(y=l(u?"sectionsEditor.secretField.leaveBlankPlaceholder":"sectionsEditor.secretField.secretValuePlaceholder"),e[35]=u,e[36]=l,e[37]=y):y=e[37];let L;e[38]!==d||e[39]!==u||e[40]!==i?(L=k=>{const C=k.target.value;if(!C){i(u?hO(d):d);return}i({...d,value:C})},e[38]=d,e[39]=u,e[40]=i,e[41]=L):L=e[41];let w;e[42]!==y||e[43]!==L||e[44]!==_?(w=r.jsx(et,{id:_,type:"password",autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:y,onChange:L,className:"h-10"}),e[42]=y,e[43]=L,e[44]=_,e[45]=w):w=e[45];let j;e[46]!==u||e[47]!==l?(j=u&&r.jsx("p",{className:"text-xs text-muted-foreground",children:l("sectionsEditor.secretField.storedSecretMessage")}),e[46]=u,e[47]=l,e[48]=j):j=e[48];let S;return e[49]!==w||e[50]!==j||e[51]!==m||e[52]!==p||e[53]!==b?(S=r.jsxs("div",{className:"space-y-2",children:[m,p,b,w,j]}),e[49]=w,e[50]=j,e[51]=m,e[52]=p,e[53]=b,e[54]=S):S=e[54],S}function fO(t,e){const s=t.anyOfRefs;if(!s?.length)return;const n=e.find(d=>d!=null&&typeof d=="object"&&!Array.isArray(d)),i=n?Object.keys(n).filter(d=>!d.startsWith("__")):[],o=[],a=d=>{d?.type==="object"&&d.properties&&o.push(d)};for(const d of s){const h=d.schema;if(h&&(h.type==="array"&&a(h.items),h.properties))for(const u of Object.values(h.properties))u?.type==="array"&&a(u.items)}if(o.length===0)return;if(i.length===0)return o.length===1?o[0]:void 0;let l,c=-1;for(const d of o){const h=d.properties??{},u=i.filter(f=>f in h).length*2+(d.titleBy?1:0);u>c&&(c=u,l=d)}return c>=2?l:void 0}function mO(t){const e=t.length>0?t[0]:void 0;if(e==null||typeof e!="object"||Array.isArray(e))return;const s={};for(const[n,i]of Object.entries(e))n.startsWith("__")||(typeof i=="string"?s[n]={type:"string"}:typeof i=="number"?s[n]={type:"number"}:typeof i=="boolean"&&(s[n]={type:"boolean"}));return Object.keys(s).length>0?{type:"object",properties:s}:void 0}const pO=new Set(["__resolveType","@type"]);function gO(t){if(t.type!=="block-ref"||!t.anyOfRefs?.length||t.anyOfRefs.length!==1)return!1;const e=t.anyOfRefs[0].schema;return!!(e?.properties?.variants||!e&&t.plainSchema)}function xO(t){if(Vc(t))for(const e of t.anyOfRefs??[]){const i=e.schema?.properties?.variants?.items?.properties?.value;if(i?.type==="array"&&i.items)return i.items}}function p1(t){if(t.type==="array"&&t.items)return t;const e=t.items??xO(t);return e?{...t,type:"array",items:e}:null}function vO(t,e){if(e!==void 0)return e;switch(t){case"string":return"";case"number":case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return null}}function Qo(t){const{schema:e,value:s}=t;if($l(s)){const a=EE(s),l=p1(e);if(a!==null&&l)return r.jsx(Fa,{...t,schema:l,value:a,onChange:c=>t.onChange(PE(s,c))},t.path)}if(Array.isArray(s)&&e.type==="block-ref"&&Vc(e)){const a=p1(e);if(a)return r.jsx(Fa,{...t,schema:a,value:s,onChange:t.onChange},t.path)}if(Array.isArray(s)&&!$l(s)&&e.type==="block-ref"){const a=fO(e,s)??mO(s);if(a){const l={...e,type:"array",items:a};return r.jsx(Fa,{...t,schema:l,value:s,onChange:t.onChange},t.path)}}if(e.type==="block-ref"||s!==null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&e.anyOfRefs){if(gO(e)){const a=e.anyOfRefs[0],l=a.schema?.properties?.variants?.items?.properties?.value,c=l&&l.type!=="block-ref"?l:e.plainSchema??l?.plainSchema??{type:"string"},d=h=>Qo({...h,schema:c});return r.jsx(g5,{...t,multivariateResolveType:a.resolveType,renderInnerField:d},t.path)}return e.anyOfRefs?r.jsx(n1,{...t},t.path):null}if(e.type==="inline-union")return r.jsx(NM,{...t},t.path);if(e.format==="image-uri")return r.jsx(mM,{...t},t.path);if(e.format==="file-uri"||e.format==="video-uri")return r.jsx(uM,{...t},t.path);if(e.format==="map")return r.jsx(DM,{...t},t.path);if(e.format==="icon-select"||e.format==="dynamic-options"&&e.options)return r.jsx(OI,{...t},t.path);if(e.format==="location")return r.jsx(h5,{...t},t.path);if(e.enum&&e.enum.length>0)return r.jsx(OD,{...t},t.path);if(e.type==="anyOf")return r.jsx(n1,{...t},t.path);if(Po(s)||e.format==="password"||s==null&&e.format==="password")return r.jsx(gd,{...t},t.path);const n=s??vO(e.type,e.default);if(n==null)return Po(s)?r.jsx(gd,{...t},t.path):null;if(Po(n))return r.jsx(gd,{...t,value:n},t.path);const i={...t,value:n},o=s==null?e.type??typeof n:Array.isArray(n)?"array":typeof n;if(o==="array"||Array.isArray(n))return r.jsx(Fa,{...i},t.path);switch(o){case"boolean":return r.jsx(RD,{...i},t.path);case"number":case"integer":return r.jsx(PD,{...i},t.path);case"string":{const a=e.format;return a==="color-input"||a==="color"?r.jsx($a,{...i},t.path):a==="textarea"||a==="rich-text"||a==="html"?r.jsx($a,{...i},t.path):r.jsx($a,{...i},t.path)}case"object":return n!==null&&typeof n=="object"&&!Array.isArray(n)?r.jsx(bI,{...i},t.path):null;default:return r.jsx($a,{...i},t.path)}}function bO(t,e){if(e&&(e.type==="block-ref"||e.anyOfRefs||e.properties))return Qo({...t,schema:e});const s=t.value;if(s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&t.meta){const n=Ln(s.__resolveType,t.meta);if(n)return r.jsx(Bn,{schema:n,value:s,onChange:t.onChange,basePath:t.path,breadcrumbPath:t.breadcrumbPath,onBreadcrumbChange:t.onBreadcrumbChange,meta:t.meta,decofile:t.decofile,onSaveReferencedBlock:t.onSaveReferencedBlock,sandbox:t.sandbox})}return Qo(e?{...t,schema:e}:t)}function Bn(t){const e=F.c(18),{schema:s,value:n,onChange:i,basePath:o,breadcrumbPath:a,onBreadcrumbChange:l,meta:c,decofile:d,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p}=t;let g,x;if(e[0]!==o||e[1]!==d||e[2]!==c||e[3]!==f||e[4]!==l||e[5]!==i||e[6]!==m||e[7]!==h||e[8]!==u||e[9]!==p||e[10]!==s||e[11]!==a||e[12]!==n){x=Symbol.for("react.early_return_sentinel");e:{const v=a===void 0?[]:a,b=s.properties;if(!b){x=null;break e}if(AE(n)&&b.variants){const T=b.variants.items?.properties?.value;let R;e[15]!==T?(R=E=>bO(E,T),e[15]=T,e[16]=R):R=e[16],x=r.jsx(g5,{schema:s,value:n,onChange:i,path:o,label:s.title??"",breadcrumbPath:v,onBreadcrumbChange:l,meta:c,decofile:d,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p,multivariateResolveType:n.__resolveType,renderInnerField:R},o);break e}const _=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},y=Object.keys(b).filter(T=>!pO.has(T)&&b[T]?.hidden!==!0);if(y.length===0){let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields on this section."}),e[17]=T):T=e[17],x=T;break e}const L=(T,R)=>{i({..._,[T]:R})},w=typeof _.__resolveType=="string"?_.__resolveType:void 0,j=y.filter(T=>{const R=b[T];return R!=null&&l0(R,_[T])}).length>1,S=v.length>0?sI(y,b,_,v):null,k=S?b[S]:null,C=S&&k?[S]:y,A=S&&k?eI(S,k,v):v,P=ZD(v,A),V=P.length>0&&l?T=>l([...P,...T]):l;g=r.jsx("div",{className:"min-w-0 space-y-6",children:C.map(T=>{const R=b[T];if(!R)return null;const E=o?`${o}.${T}`:T,I=Eo(T,R);return Qo({schema:R,value:_[T],onChange:D=>L(T,D),path:E,label:I,breadcrumbPath:A,onBreadcrumbChange:V,hasSiblingDrillDownFields:j,meta:c,decofile:d,onSaveReferencedBlock:h,containerResolveType:w,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p})})})}e[0]=o,e[1]=d,e[2]=c,e[3]=f,e[4]=l,e[5]=i,e[6]=m,e[7]=h,e[8]=u,e[9]=p,e[10]=s,e[11]=a,e[12]=n,e[13]=g,e[14]=x}else g=e[13],x=e[14];return x!==Symbol.for("react.early_return_sentinel")?x:g}function yO(t){const e=F.c(3),{isPending:s,isError:n}=t;if(n){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[r.jsx(jn,{size:13}),"Couldn't save"]}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(Ze,{size:13,className:"animate-spin"}),"Saving…"]}),e[1]=o):o=e[1],o}let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70",children:[r.jsx(ns,{size:13}),"Saved"]}),e[2]=i):i=e[2],i}function _O({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:i,decofile:o,kind:a,target:l,initialValue:c,isCreating:d,onCreate:h,onSaveReferencedBlock:u,onBack:f}){const m=oe(),p=Kn(),g=p?.entity?.id===e?p.entity.metadata?.siteSlug??null:null,x=Ln(l.resolveType,i),v=!x&&cw(l.resolveType,i),b=v?dw(c):null,_=x??b,[y,L]=N.useState(c),[w,j]=N.useState([]),[S,k]=N.useState(0),[C,A]=N.useState(!1),[P,V]=N.useState(null),[T,R]=N.useState(!1),[E,I]=N.useState(!1),[D,M]=N.useState(!1),O=P!==null,{save:$,flush:B,isPending:z}=i4({orgSlug:t,virtualMcpId:e,branch:s}),K=jP({orgSlug:t,virtualMcpId:e,branch:s});N.useEffect(()=>()=>{B()},[]);const Y=j4(a),Q=l.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")??l.resolveType,q={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:g},H=te=>{L(te),l.mode==="saved"&&$(l.blockKey,{__resolveType:l.resolveType,...te})},U=()=>{O?(V(null),A(!1),k(te=>te+1)):V(JSON.stringify(y,null,2))},X=te=>{const se=te??"";try{const re=JSON.parse(se);if(re&&typeof re=="object"&&!Array.isArray(re)){A(!1),H(re);return}A(!0)}catch{A(!0)}},J=async te=>{const se=Eu(te,o);if(se){ve.error(se);return}await h(te,{__resolveType:l.resolveType,...y}),R(!1)},ee=()=>{I(!0),K.mutate({resolveType:l.resolveType,props:y})},W=()=>{n&&window.open(SP(n,l.resolveType,y,Date.now()),"_blank","noopener")},Z=[l.title,...w],G=te=>{j(w.slice(0,te)),k(se=>se+1)};return r.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col",children:[r.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[f&&r.jsx(le,{variant:"ghost",size:"icon",className:"size-8 shrink-0",onClick:f,"aria-label":m("sandbox.runnableBlockEditor.backToList"),children:r.jsx(tc,{size:14})}),r.jsx("nav",{"aria-label":m("sandbox.runnableBlockEditor.editingBreadcrumb"),className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:Z.map((te,se)=>{const re=se===Z.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[se>0&&r.jsx(yn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>G(se),title:te,className:ie("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",re?"font-medium text-foreground":"text-muted-foreground"),children:te})]},`${te}-${se}`)})}),l.mode==="saved"&&r.jsx(yO,{isPending:z,isError:!1}),r.jsxs(le,{size:"sm",variant:"outline",className:"h-8 shrink-0 gap-1.5",onClick:ee,disabled:K.isPending,"aria-label":m("sandbox.runnableBlockEditor.runAriaLabel",{singular:Y}),children:[K.isPending?r.jsx(Ze,{size:14,className:"animate-spin"}):r.jsx(Di,{size:14}),m("sandbox.runnableBlockEditor.run")]}),l.mode==="available"&&r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{size:"icon",className:"size-8 shrink-0",disabled:d,onClick:()=>R(!0),"aria-label":m("sandbox.runnableBlockEditor.saveAsGlobalAriaLabel",{singular:Y}),children:r.jsx(r9,{size:14})})}),r.jsx(He,{side:"bottom",children:m("sandbox.runnableBlockEditor.saveAsGlobal",{singular:Y})})]}),r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:O?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:U,"aria-label":m(O?"sandbox.runnableBlockEditor.closeJsonEditor":"sandbox.runnableBlockEditor.editAsJson"),"aria-pressed":O,children:O?r.jsx(an,{size:14}):r.jsx(ra,{size:14})})}),r.jsx(He,{side:"bottom",children:m(O?"sandbox.runnableBlockEditor.closeJsonEditor":"sandbox.runnableBlockEditor.editAsJson")})]})]}),r.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:l.mode==="saved"?m("sandbox.runnableBlockEditor.savedModeDescription",{singular:Y}):m("sandbox.runnableBlockEditor.availableModeDescription",{typeLabel:Q,singular:Y})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:ie("relative min-h-0 flex-1",E&&D&&"hidden"),children:[r.jsx(fi,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:r.jsxs("div",{className:"mx-auto max-w-2xl",children:[b&&_===b&&r.jsx("p",{className:"mb-3 rounded-md bg-muted px-3 py-2 text-xs leading-snug text-muted-foreground",children:m("sandbox.runnableBlockEditor.inferredSchemaNotice",{singular:Y})}),_?r.jsx(Bn,{schema:_,value:y,onChange:te=>H(te),basePath:"",breadcrumbPath:w,onBreadcrumbChange:j,meta:i,decofile:o,onSaveReferencedBlock:u,sandbox:q},S):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:v?m("sandbox.runnableBlockEditor.freeformPropsEmptyState",{singular:Y}):m("sandbox.runnableBlockEditor.noInputEmptyState",{singular:Y})})]})})}),P!==null&&r.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[C&&r.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:m("sandbox.runnableBlockEditor.invalidJsonError")}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(ua,{language:"json",height:"100%",code:P,onChange:X,onSave:te=>{X(te),B()}})})]})]}),E&&r.jsx(LO,{singular:Y,result:{isPending:K.isPending,error:K.error,data:K.data,hasRun:K.status!=="idle"},expanded:D,onToggleExpand:()=>M(te=>!te),onOpenInNewTab:n?W:void 0,onClose:()=>{I(!1),M(!1)}})]}),r.jsx(Pu,{open:T,onOpenChange:R,defaultBlockId:"",isPending:d,onSubmit:J})]})}function LO(t){const e=F.c(54),{singular:s,result:n,expanded:i,onToggleExpand:o,onOpenInNewTab:a,onClose:l}=t,c=oe();let d;e[0]!==n.data?(d=typeof n.data=="string"?n.data:JSON.stringify(n.data??null,null,2),e[0]=n.data,e[1]=d):d=e[1];const h=d,u=i?"flex-1":"h-[45%] shrink-0";let f;e[2]!==u?(f=ie("flex min-h-0 flex-col border-t",u),e[2]=u,e[3]=f):f=e[3];let m;e[4]!==c?(m=c("sandbox.runnableBlockEditor.resultPanelTitle"),e[4]=c,e[5]=m):m=e[5];let p;e[6]!==m?(p=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:m}),e[6]=m,e[7]=p):p=e[7];let g;e[8]!==a||e[9]!==s||e[10]!==c?(g=a&&r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"size-7",onClick:a,"aria-label":c("sandbox.runnableBlockEditor.openResultInNewTabAriaLabel"),children:r.jsx($n,{size:14})})}),r.jsx(He,{side:"bottom",children:c("sandbox.runnableBlockEditor.openInNewTabTooltip",{singular:s})})]}),e[8]=a,e[9]=s,e[10]=c,e[11]=g):g=e[11];let x;e[12]!==i||e[13]!==c?(x=c(i?"sandbox.runnableBlockEditor.collapseResult":"sandbox.runnableBlockEditor.expandResult"),e[12]=i,e[13]=c,e[14]=x):x=e[14];let v;e[15]!==i?(v=i?r.jsx(J6,{size:14}):r.jsx(m2,{size:14}),e[15]=i,e[16]=v):v=e[16];let b;e[17]!==i||e[18]!==o||e[19]!==x||e[20]!==v?(b=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"size-7",onClick:o,"aria-label":x,"aria-pressed":i,children:v})}),e[17]=i,e[18]=o,e[19]=x,e[20]=v,e[21]=b):b=e[21];let _;e[22]!==i||e[23]!==c?(_=c(i?"sandbox.runnableBlockEditor.collapse":"sandbox.runnableBlockEditor.expand"),e[22]=i,e[23]=c,e[24]=_):_=e[24];let y;e[25]!==_?(y=r.jsx(He,{side:"bottom",children:_}),e[25]=_,e[26]=y):y=e[26];let L;e[27]!==y||e[28]!==b?(L=r.jsxs(We,{children:[b,y]}),e[27]=y,e[28]=b,e[29]=L):L=e[29];let w;e[30]!==c?(w=c("sandbox.runnableBlockEditor.closeResult"),e[30]=c,e[31]=w):w=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(an,{size:14}),e[32]=j):j=e[32];let S;e[33]!==l||e[34]!==w?(S=r.jsx(le,{variant:"ghost",size:"icon",className:"size-7",onClick:l,"aria-label":w,children:j}),e[33]=l,e[34]=w,e[35]=S):S=e[35];let k;e[36]!==L||e[37]!==S||e[38]!==g?(k=r.jsxs("div",{className:"flex items-center gap-0.5",children:[g,L,S]}),e[36]=L,e[37]=S,e[38]=g,e[39]=k):k=e[39];let C;e[40]!==k||e[41]!==p?(C=r.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[p,k]}),e[40]=k,e[41]=p,e[42]=C):C=e[42];let A;e[43]!==n.error||e[44]!==n.hasRun||e[45]!==n.isPending||e[46]!==h||e[47]!==s||e[48]!==c?(A=r.jsx("div",{className:"min-h-0 flex-1",children:n.isPending?r.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-muted-foreground",children:[r.jsx(Ze,{size:16,className:"animate-spin"}),c("sandbox.runnableBlockEditor.running",{singular:s})]}):n.error?r.jsxs("div",{className:"h-full overflow-auto px-4 py-3",children:[r.jsx("p",{className:"text-xs font-medium text-destructive",children:c("sandbox.runnableBlockEditor.failedToRun",{singular:s})}),r.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-destructive/90",children:n.error.message})]}):n.hasRun?r.jsx(ua,{language:"json",height:"100%",code:h,readOnly:!0}):r.jsx("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:c("sandbox.runnableBlockEditor.pressRunToInvoke",{singular:s})})}),e[43]=n.error,e[44]=n.hasRun,e[45]=n.isPending,e[46]=h,e[47]=s,e[48]=c,e[49]=A):A=e[49];let P;return e[50]!==C||e[51]!==A||e[52]!==f?(P=r.jsxs("div",{className:f,children:[C,A]}),e[50]=C,e[51]=A,e[52]=f,e[53]=P):P=e[53],P}const SO={loaders:hl,actions:Ii},wO={loaders:"Loaders",actions:"Actions"},jO={analytics:S8,blog:br,commerce:w9,site:o8,website:pi};function CO(t,e){return e===0?jO[t.toLowerCase()]??ri:ri}function Ka(t,e){return e===0?YP(t):t}function kO(t){const e=F.c(98),{orgSlug:s,virtualMcpId:n,branch:i,previewUrl:o,meta:a,decofile:l,kind:c}=t,d=oe();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[0]=h):h=e[0];const[u,f]=N.useState(h),[m,p]=N.useState(null),[g,x]=N.useState(""),[v,b]=N.useState(DO),[_,y]=N.useState(c);_!==c&&(y(c),f([]),p(null),x(""),b(new Set));let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L=K=>{b(Y=>{const Q=new Set(Y);return Q.has(K)?Q.delete(K):Q.add(K),Q})},e[1]=L):L=e[1];const w=L;let j;e[2]!==i||e[3]!==s||e[4]!==n?(j={orgSlug:s,virtualMcpId:n,branch:i},e[2]=i,e[3]=s,e[4]=n,e[5]=j):j=e[5];const S=kc(j);let k;e[6]!==S?(k=R4((K,Y)=>S.mutate({blockKey:K,data:Y})),e[6]=S,e[7]=k):k=e[7];const C=k;let A;e[8]!==c?(A=j4(c),e[8]=c,e[9]=A):A=e[9];const P=A,V=SO[c];let T,R,E,I,D,M,O;if(e[10]!==V||e[11]!==i||e[12]!==l||e[13]!==c||e[14]!==a||e[15]!==v||e[16]!==s||e[17]!==u||e[18]!==o||e[19]!==S||e[20]!==C||e[21]!==g||e[22]!==m||e[23]!==P||e[24]!==d||e[25]!==n){E=Symbol.for("react.early_return_sentinel");e:{const K=[...JP(a,l,c).map(RO),...C4(a,c).map(PO)],Y=g.trim().toLowerCase(),Q=Y.length>0,q=Q?K.filter(be=>be.title.toLowerCase().includes(Y)||be.resolveType.toLowerCase().includes(Y)):[],H=new Map,U=[],X=new Map;if(!Q){for(const be of K){const je=be.folderPath;if(!(je.length<u.length)&&u.every((ge,Le)=>je[Le]===ge))if(je.length===u.length)if(be.savedKey!==void 0){const ge=X.get(be.resolveType);ge?ge.push(be):X.set(be.resolveType,[be])}else U.push(be);else{const ge=je[u.length],Le=H.get(ge)??{count:0,savedCount:0};be.savedKey!==void 0?Le.savedCount=Le.savedCount+1:Le.count=Le.count+1,H.set(ge,Le)}}U.sort(EO);for(const be of X.values())be.sort(AO)}const J=[...X.entries()].filter(be=>{const[je]=be;return!U.some(ge=>ge.resolveType===je)}).flatMap(TO).sort(NO);let ee;e[33]!==u?(ee=(be,je)=>Ka(be.name,u.length).localeCompare(Ka(je.name,u.length)),e[33]=u,e[34]=ee):ee=e[34];const W=[...H.entries()].map(VO).sort(ee);let Z;e[35]===Symbol.for("react.memo_cache_sentinel")?(Z=be=>{p(be.savedKey!==void 0?{mode:"saved",key:be.savedKey}:{mode:"available",resolveType:be.resolveType,title:be.title})},e[35]=Z):Z=e[35];const G=Z;let te;e[36]!==S||e[37]!==P||e[38]!==d?(te=async(be,je)=>{await S.mutateAsync({blockKey:be,data:je}),ve.success(d("sandbox.runnableBlocksBrowser.savedBlockToast",{singular:P,blockId:be})),p({mode:"saved",key:be})},e[36]=S,e[37]=P,e[38]=d,e[39]=te):te=e[39];const se=te;let re;e[40]!==l||e[41]!==m?(re=IO(m,l),e[40]=l,e[41]=m,e[42]=re):re=e[42];const de=re;if(de){const be=`${de.mode}:${de.mode==="saved"?de.blockKey:de.resolveType}`;let je;e[43]===Symbol.for("react.memo_cache_sentinel")?(je=()=>p(null),e[43]=je):je=e[43];let ge;e[44]!==i||e[45]!==l||e[46]!==se||e[47]!==c||e[48]!==a||e[49]!==s||e[50]!==o||e[51]!==S.isPending||e[52]!==C||e[53]!==be||e[54]!==de.editorTarget||e[55]!==de.initialValue||e[56]!==n?(ge=r.jsx(_O,{orgSlug:s,virtualMcpId:n,branch:i,previewUrl:o,meta:a,decofile:l,kind:c,target:de.editorTarget,initialValue:de.initialValue,isCreating:S.isPending,onCreate:se,onSaveReferencedBlock:C,onBack:je},be),e[44]=i,e[45]=l,e[46]=se,e[47]=c,e[48]=a,e[49]=s,e[50]=o,e[51]=S.isPending,e[52]=C,e[53]=be,e[54]=de.editorTarget,e[55]=de.initialValue,e[56]=n,e[57]=ge):ge=e[57],E=ge;break e}O="flex h-full w-full min-w-0 flex-col";let ce;e[58]!==d?(ce=d("sandbox.runnableBlocksBrowser.folderBreadcrumb"),e[58]=d,e[59]=ce):ce=e[59];let fe;e[60]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>f([]),e[60]=fe):fe=e[60];const ue=u.length===0?"font-medium text-foreground":"text-muted-foreground";let ae;e[61]!==ue?(ae=ie("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",ue),e[61]=ue,e[62]=ae):ae=e[62];const me=wO[c];let xe;e[63]!==ae||e[64]!==me?(xe=r.jsx("button",{type:"button",onClick:fe,className:ae,children:me}),e[63]=ae,e[64]=me,e[65]=xe):xe=e[65];let Se;e[66]!==u?(Se=u.map((be,je)=>{const ge=je===u.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[r.jsx(yn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>f(u.slice(0,je+1)),className:ie("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",ge?"font-medium text-foreground":"text-muted-foreground"),children:Ka(be,je)})]},`${be}-${je}`)}),e[66]=u,e[67]=Se):Se=e[67];let Ve;e[68]!==ce||e[69]!==xe||e[70]!==Se?(Ve=r.jsxs("nav",{"aria-label":ce,className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:[xe,Se]}),e[68]=ce,e[69]=xe,e[70]=Se,e[71]=Ve):Ve=e[71];let Ie;e[72]===Symbol.for("react.memo_cache_sentinel")?(Ie=r.jsx(C9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[72]=Ie):Ie=e[72];let Ne;e[73]===Symbol.for("react.memo_cache_sentinel")?(Ne=be=>x(be.target.value),e[73]=Ne):Ne=e[73];let Ee;e[74]!==c||e[75]!==d?(Ee=d("sandbox.runnableBlocksBrowser.searchPlaceholder",{kind:c}),e[74]=c,e[75]=d,e[76]=Ee):Ee=e[76];let we;e[77]!==c||e[78]!==d?(we=d("sandbox.runnableBlocksBrowser.searchAriaLabel",{kind:c}),e[77]=c,e[78]=d,e[79]=we):we=e[79];let Ae;e[80]!==g||e[81]!==Ee||e[82]!==we?(Ae=r.jsxs("div",{className:"flex w-56 shrink-0 items-center gap-2",children:[Ie,r.jsx("input",{type:"text",value:g,onChange:Ne,placeholder:Ee,"aria-label":we,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[80]=g,e[81]=Ee,e[82]=we,e[83]=Ae):Ae=e[83],e[84]!==Ve||e[85]!==Ae?(R=r.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[Ve,Ae]}),e[84]=Ve,e[85]=Ae,e[86]=R):R=e[86],T=fi,M="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",I="mx-auto w-full max-w-4xl px-6 py-5",D=Q?q.length===0?r.jsx(Qn,{title:d("sandbox.runnableBlocksBrowser.noSearchResults",{kind:c,query:g.trim()}),description:d("sandbox.runnableBlocksBrowser.noSearchResultsDescription")}):r.jsx("div",{className:"flex flex-col gap-1",children:q.map(be=>r.jsx(Qs,{icon:V,accent:be.savedKey!==void 0?"global":void 0,title:be.title,subtitle:be.resolveType,active:!1,onClick:()=>G(be)},be.savedKey??be.resolveType))}):W.length===0&&U.length===0&&J.length===0?r.jsx(Qn,{title:d("sandbox.runnableBlocksBrowser.emptyFolderTitle",{kind:c}),description:u.length===0?d("sandbox.runnableBlocksBrowser.emptyFolderNoManifest"):d("sandbox.runnableBlocksBrowser.emptyFolder")}):r.jsxs(r.Fragment,{children:[W.length>0&&r.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2",children:W.map(be=>{const je=CO(be.name,u.length);return r.jsxs("button",{type:"button",onClick:()=>f([...u,be.name]),className:"flex items-center gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[r.jsx(je,{size:18,className:"shrink-0 text-muted-foreground"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm font-medium",children:Ka(be.name,u.length)}),r.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[be.count," ",be.count===1?P:c,be.savedCount>0&&r.jsxs(r.Fragment,{children:[" ","·"," ",d("sandbox.runnableBlocksBrowser.savedCountLabel",{count:be.savedCount})]})]})]})]},be.name)})}),(U.length>0||J.length>0)&&r.jsxs("div",{className:ie("flex flex-col gap-1",W.length>0&&"mt-4"),children:[U.map(be=>{const je=X.get(be.resolveType)??[],ge=v.has(be.resolveType);return r.jsxs("div",{className:"flex flex-col",children:[r.jsx(Qs,{icon:V,title:be.title,subtitle:be.resolveType,active:!1,onClick:()=>G(be)}),je.length>0&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",onClick:()=>w(be.resolveType),"aria-expanded":ge,className:"flex items-center gap-1 self-start rounded-md px-2.5 py-1 text-xs font-medium transition-colors hover:bg-global-section/10 cursor-pointer ml-11",style:{color:B9},children:[ge?r.jsx(is,{size:12,className:"shrink-0"}):r.jsx(yn,{size:12,className:"shrink-0"}),d(ge?"sandbox.runnableBlocksBrowser.hideSaved":"sandbox.runnableBlocksBrowser.seeSaved")," ","(",je.length,")"]}),ge&&r.jsx("div",{className:"ml-11 flex flex-col gap-1 pb-1",children:je.map(Le=>r.jsx(Qs,{icon:V,accent:"global",title:Le.title,subtitle:Le.resolveType,active:!1,onClick:()=>G(Le)},Le.savedKey))})]})]},be.resolveType)}),J.map(be=>r.jsx(Qs,{icon:V,accent:"global",title:be.title,subtitle:be.resolveType,active:!1,onClick:()=>G(be)},be.savedKey))]})]})}e[10]=V,e[11]=i,e[12]=l,e[13]=c,e[14]=a,e[15]=v,e[16]=s,e[17]=u,e[18]=o,e[19]=S,e[20]=C,e[21]=g,e[22]=m,e[23]=P,e[24]=d,e[25]=n,e[26]=T,e[27]=R,e[28]=E,e[29]=I,e[30]=D,e[31]=M,e[32]=O}else T=e[26],R=e[27],E=e[28],I=e[29],D=e[30],M=e[31],O=e[32];if(E!==Symbol.for("react.early_return_sentinel"))return E;let $;e[87]!==I||e[88]!==D?($=r.jsx("div",{className:I,children:D}),e[87]=I,e[88]=D,e[89]=$):$=e[89];let B;e[90]!==T||e[91]!==$||e[92]!==M?(B=r.jsx(T,{className:M,children:$}),e[90]=T,e[91]=$,e[92]=M,e[93]=B):B=e[93];let z;return e[94]!==R||e[95]!==B||e[96]!==O?(z=r.jsxs("div",{className:O,children:[R,B]}),e[94]=R,e[95]=B,e[96]=O,e[97]=z):z=e[97],z}function VO(t){const[e,s]=t;return{name:e,...s}}function NO(t,e){return t.title.localeCompare(e.title)}function TO(t){const[,e]=t;return e}function AO(t,e){return t.title.localeCompare(e.title)}function EO(t,e){return t.title.localeCompare(e.title)}function PO(t){return{resolveType:t.resolveType,title:t.title,folderPath:k4(t.resolveType)}}function RO(t){return{resolveType:t.resolveType,title:t.title,folderPath:k4(t.resolveType),savedKey:t.key}}function DO(){return new Set}function IO(t,e){if(!t)return null;if(t.mode==="available")return{mode:"available",resolveType:t.resolveType,editorTarget:{mode:"available",resolveType:t.resolveType,title:t.title},initialValue:{}};const s=e[t.key],n=s&&typeof s.__resolveType=="string"?s.__resolveType:"",{__resolveType:i,...o}=s??{},a=s&&typeof s.name=="string"&&s.name?s.name:t.key;return{mode:"saved",blockKey:t.key,resolveType:n,editorTarget:{mode:"saved",blockKey:t.key,resolveType:n,title:a},initialValue:o}}function MO(t){const e=F.c(96),{orgSlug:s,virtualMcpId:n,branch:i,previewUrl:o,meta:a,decofile:l,resolveType:c,title:d,defaultBlockId:h,isCreating:u,onCreate:f,onSaveReferencedBlock:m}=t,p=oe(),g=Kn(),x=g?.entity?.id===n?g.entity.metadata?.siteSlug??null:null;let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];const[b,_]=N.useState(v);let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[1]=y):y=e[1];const[L,w]=N.useState(y),[j,S]=N.useState(0),[k,C]=N.useState(!1);let A;e[2]!==a||e[3]!==c?(A=Ln(c,a),e[2]=a,e[3]=c,e[4]=A):A=e[4];const P=A;let V,T,R,E,I,D,M,O;if(e[5]!==x||e[6]!==i||e[7]!==l||e[8]!==L||e[9]!==b||e[10]!==u||e[11]!==f||e[12]!==s||e[13]!==o||e[14]!==c||e[15]!==p||e[16]!==d||e[17]!==n){const q=c.split("/").pop()?.replace(/\.tsx?$/,"")??c,H=o??void 0;let U;e[26]!==x||e[27]!==i||e[28]!==s||e[29]!==H||e[30]!==n?(U={orgSlug:s,virtualMcpId:n,branch:i,previewUrl:H,siteSlug:x},e[26]=x,e[27]=i,e[28]=s,e[29]=H,e[30]=n,e[31]=U):U=e[31],T=U;let X;e[32]!==L||e[33]!==d?(X=[d,...L],e[32]=L,e[33]=d,e[34]=X):X=e[34];const J=X;let ee;e[35]!==L?(ee=xe=>{w(L.slice(0,xe)),S(OO)},e[35]=L,e[36]=ee):ee=e[36];const W=ee;let Z;e[37]!==l||e[38]!==b||e[39]!==f?(Z=async xe=>{const Se=Eu(xe,l);if(Se){ve.error(Se);return}await f(xe,b),C(!1)},e[37]=l,e[38]=b,e[39]=f,e[40]=Z):Z=e[40],V=Z,O="flex h-full w-full min-w-0",M="flex min-w-0 flex-1 flex-col",I="shrink-0 border-b px-3 py-2.5";let G;e[41]!==p?(G=p("sandbox.availableSectionEditor.editingBreadcrumb"),e[41]=p,e[42]=G):G=e[42];let te;e[43]!==W||e[44]!==J?(te=J.map((xe,Se)=>{const Ve=Se===J.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[Se>0&&r.jsx(yn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>W(Se),title:xe,className:ie("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",Ve?"font-medium text-foreground":"text-muted-foreground"),children:xe})]},`${xe}-${Se}`)}),e[43]=W,e[44]=J,e[45]=te):te=e[45];let se;e[46]!==G||e[47]!==te?(se=r.jsx("nav",{"aria-label":G,className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:te}),e[46]=G,e[47]=te,e[48]=se):se=e[48];let re;e[49]===Symbol.for("react.memo_cache_sentinel")?(re=()=>C(!0),e[49]=re):re=e[49];let de;e[50]!==p?(de=p("sandbox.availableSectionEditor.saveAsGlobalSection"),e[50]=p,e[51]=de):de=e[51];let ce;e[52]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(r9,{size:14}),e[52]=ce):ce=e[52];let fe;e[53]!==u||e[54]!==de?(fe=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{size:"icon",className:"size-8 shrink-0",disabled:u,onClick:re,"aria-label":de,children:ce})}),e[53]=u,e[54]=de,e[55]=fe):fe=e[55];let ue;e[56]!==p?(ue=p("sandbox.availableSectionEditor.saveAsGlobalSection"),e[56]=p,e[57]=ue):ue=e[57];let ae;e[58]!==ue?(ae=r.jsx(He,{side:"bottom",children:ue}),e[58]=ue,e[59]=ae):ae=e[59];let me;e[60]!==fe||e[61]!==ae?(me=r.jsxs(We,{children:[fe,ae]}),e[60]=fe,e[61]=ae,e[62]=me):me=e[62],e[63]!==se||e[64]!==me?(D=r.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[se,me]}),e[63]=se,e[64]=me,e[65]=D):D=e[65],R="mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",E=p("sandbox.availableSectionEditor.localEditsHint",{typeLabel:q}),e[5]=x,e[6]=i,e[7]=l,e[8]=L,e[9]=b,e[10]=u,e[11]=f,e[12]=s,e[13]=o,e[14]=c,e[15]=p,e[16]=d,e[17]=n,e[18]=V,e[19]=T,e[20]=R,e[21]=E,e[22]=I,e[23]=D,e[24]=M,e[25]=O}else V=e[18],T=e[19],R=e[20],E=e[21],I=e[22],D=e[23],M=e[24],O=e[25];let $;e[66]!==R||e[67]!==E?($=r.jsx("p",{className:R,children:E}),e[66]=R,e[67]=E,e[68]=$):$=e[68];let B;e[69]!==$||e[70]!==I||e[71]!==D?(B=r.jsxs("div",{className:I,children:[D,$]}),e[69]=$,e[70]=I,e[71]=D,e[72]=B):B=e[72];let z;e[73]!==l||e[74]!==L||e[75]!==j||e[76]!==b||e[77]!==a||e[78]!==m||e[79]!==T||e[80]!==P||e[81]!==p?(z=r.jsx(fi,{className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:r.jsx("div",{className:"mx-auto max-w-2xl",children:P?r.jsx(Bn,{schema:P,value:b,onChange:q=>_(q),basePath:"",breadcrumbPath:L,onBreadcrumbChange:w,meta:a,decofile:l,onSaveReferencedBlock:m,sandbox:T},j):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:p("sandbox.availableSectionEditor.noEditableFields")})})})}),e[73]=l,e[74]=L,e[75]=j,e[76]=b,e[77]=a,e[78]=m,e[79]=T,e[80]=P,e[81]=p,e[82]=z):z=e[82];let K;e[83]!==B||e[84]!==z||e[85]!==M?(K=r.jsxs("div",{className:M,children:[B,z]}),e[83]=B,e[84]=z,e[85]=M,e[86]=K):K=e[86];let Y;e[87]!==h||e[88]!==V||e[89]!==u||e[90]!==k?(Y=r.jsx(Pu,{open:k,onOpenChange:C,defaultBlockId:h,isPending:u,onSubmit:V}),e[87]=h,e[88]=V,e[89]=u,e[90]=k,e[91]=Y):Y=e[91];let Q;return e[92]!==K||e[93]!==Y||e[94]!==O?(Q=r.jsxs("div",{className:O,children:[K,Y]}),e[92]=K,e[93]=Y,e[94]=O,e[95]=Q):Q=e[95],Q}function OO(t){return t+1}function $O(t,e){const s={__resolveType:t},n=o4([s],e)[0];return n?LI(s,n,e):null}function BO({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:i,decofile:o,blockKey:a,onSaveReferencedBlock:l}){const c=oe(),d=Kn(),h=d?.entity?.id===e?d.entity.metadata?.siteSlug??null:null,[u]=N.useState(()=>$O(a,o)),[f,m]=N.useState(u?.data??{}),[p,g]=N.useState([]),[x,v]=N.useState(0),[b,_]=N.useState(!1),[y,L]=N.useState(null),w=y!==null,{save:j,flush:S}=i4({orgSlug:t,virtualMcpId:e,branch:s}),k=u?.resolveType?Ln(u.resolveType,i):null,C=o[a],A=C?pc(a,C):a,P={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:h},V=D=>{m(D),j(a,D)},T=()=>{w?(L(null),_(!1),v(D=>D+1)):L(JSON.stringify(f,null,2))},R=D=>{const M=D??"";try{const O=JSON.parse(M);if(O&&typeof O=="object"&&!Array.isArray(O)){_(!1),V(O);return}_(!0)}catch{_(!0)}},E=[A,...p],I=D=>{g(p.slice(0,D)),v(M=>M+1)};return r.jsx("div",{className:"flex h-full w-full min-w-0",children:r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[r.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:B9},"aria-hidden":!0}),r.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:E.map((D,M)=>{const O=M===E.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[M>0&&r.jsx(yn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>I(M),title:D,className:ie("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",O?"font-medium text-foreground":"text-muted-foreground"),children:D})]},`${D}-${M}`)})}),r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:w?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:T,"aria-label":c(w?"sandbox.savedSectionEditor.closeJsonEditor":"sandbox.savedSectionEditor.editAsJson"),"aria-pressed":w,children:w?r.jsx(an,{size:14}):r.jsx(ra,{size:14})})}),r.jsx(He,{side:"bottom",children:c(w?"sandbox.savedSectionEditor.closeJsonEditor":"sandbox.savedSectionEditor.editAsJson")})]})]}),r.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:c("sandbox.savedSectionEditor.globalSectionDescription")})]}),r.jsxs("div",{className:"relative min-h-0 flex-1",children:[r.jsx(fi,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:r.jsx("div",{className:"mx-auto max-w-2xl",children:k?r.jsx(Bn,{schema:k,value:f,onChange:D=>V(D),basePath:"",breadcrumbPath:p,onBreadcrumbChange:g,meta:i,decofile:o,onSaveReferencedBlock:l,sandbox:P},x):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:c("sandbox.savedSectionEditor.noEditableFields")})})})}),y!==null&&r.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[b&&r.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:c("sandbox.savedSectionEditor.invalidJsonError")}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(ua,{language:"json",height:"100%",code:y,onChange:R,onSave:D=>{R(D),S()}})})]})]})]})})}function FO(t){const e=F.c(36),{selection:s,orgSlug:n,virtualMcpId:i,branch:o,previewUrl:a,meta:l,decofile:c,isCreating:d,onCreateAvailable:h,onSaveReferencedBlock:u}=t,f=oe();if(!s){let g;e[0]!==f?(g=f("sandbox.sectionsRightPane.selectSectionTitle"),e[0]=f,e[1]=g):g=e[1];let x;e[2]!==f?(x=f("sandbox.sectionsRightPane.selectSectionDescription"),e[2]=f,e[3]=x):x=e[3];let v;return e[4]!==g||e[5]!==x?(v=r.jsx(Qn,{title:g,description:x}),e[4]=g,e[5]=x,e[6]=v):v=e[6],v}if(s.collection==="available-section"){const g=`available:${s.resolveType}`,x=s.resolveType,v=s.title;let b;e[7]!==s.title?(b=J4(s.title),e[7]=s.title,e[8]=b):b=e[8];let _;e[9]!==h||e[10]!==s.resolveType?(_=(L,w)=>h(s.resolveType,L,w),e[9]=h,e[10]=s.resolveType,e[11]=_):_=e[11];let y;return e[12]!==o||e[13]!==c||e[14]!==d||e[15]!==l||e[16]!==u||e[17]!==n||e[18]!==a||e[19]!==s.resolveType||e[20]!==s.title||e[21]!==g||e[22]!==b||e[23]!==_||e[24]!==i?(y=r.jsx(MO,{orgSlug:n,virtualMcpId:i,branch:o,previewUrl:a,meta:l,decofile:c,resolveType:x,title:v,defaultBlockId:b,isCreating:d,onCreate:_,onSaveReferencedBlock:u},g),e[12]=o,e[13]=c,e[14]=d,e[15]=l,e[16]=u,e[17]=n,e[18]=a,e[19]=s.resolveType,e[20]=s.title,e[21]=g,e[22]=b,e[23]=_,e[24]=i,e[25]=y):y=e[25],y}const m=`saved:${s.key}`;let p;return e[26]!==o||e[27]!==c||e[28]!==l||e[29]!==u||e[30]!==n||e[31]!==a||e[32]!==s.key||e[33]!==m||e[34]!==i?(p=r.jsx(BO,{orgSlug:n,virtualMcpId:i,branch:o,previewUrl:a,meta:l,decofile:c,blockKey:s.key,onSaveReferencedBlock:u},m),e[26]=o,e[27]=c,e[28]=l,e[29]=u,e[30]=n,e[31]=a,e[32]=s.key,e[33]=m,e[34]=i,e[35]=p):p=e[35],p}const g1="__all__",x1={"date-desc":"sandbox.postToolbar.sortNewestFirst","date-asc":"sandbox.postToolbar.sortOldestFirst",az:"sandbox.postToolbar.sortTitleAZ",za:"sandbox.postToolbar.sortTitleZA"},zO={"date-desc":"sandbox.postToolbar.sortNewest","date-asc":"sandbox.postToolbar.sortOldest",az:"sandbox.postToolbar.sortAZ",za:"sandbox.postToolbar.sortZA"},v1=N.forwardRef(function(e,s){const n=F.c(20);let i,o,a,l,c;n[0]!==e?({icon:i,active:o,value:c,className:a,...l}=e,n[0]=e,n[1]=i,n[2]=o,n[3]=a,n[4]=l,n[5]=c):(i=n[1],o=n[2],a=n[3],l=n[4],c=n[5]);const d=o?"text-foreground":"text-muted-foreground";let h;n[6]!==a||n[7]!==d?(h=ie("h-7 gap-1 px-1.5 text-xs",d,a),n[6]=a,n[7]=d,n[8]=h):h=n[8];let u;n[9]!==i?(u=r.jsx(i,{size:14,className:"shrink-0"}),n[9]=i,n[10]=u):u=n[10];let f;n[11]!==c?(f=c&&r.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),n[11]=c,n[12]=f):f=n[12];let m;n[13]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(is,{size:12,className:"shrink-0 opacity-60"}),n[13]=m):m=n[13];let p;return n[14]!==l||n[15]!==s||n[16]!==h||n[17]!==u||n[18]!==f?(p=r.jsxs(le,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),n[14]=l,n[15]=s,n[16]=h,n[17]=u,n[18]=f,n[19]=p):p=n[19],p});function x5(t){const e=F.c(2),{count:s}=t;let n;return e[0]!==s?(n=r.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=n):n=e[1],n}function KO(t){const e=F.c(88),{categories:s,authors:n,categoryFilter:i,authorFilter:o,sort:a,onCategoryFilterChange:l,onAuthorFilterChange:c,onSortChange:d}=t,h=oe();let u;if(e[0]!==s||e[1]!==i){let ee;e[3]!==i?(ee=W=>W.slug===i,e[3]=i,e[4]=ee):ee=e[4],u=s.find(ee),e[0]=s,e[1]=i,e[2]=u}else u=e[2];const f=u;let m;if(e[5]!==o||e[6]!==n){let ee;e[8]!==o?(ee=W=>W.email===o,e[8]=o,e[9]=ee):ee=e[9],m=n.find(ee),e[5]=o,e[6]=n,e[7]=m}else m=e[7];const p=m,g=!!(i||o);let x;e[10]!==p?.name||e[11]!==f?.name||e[12]!==h?(x=f?.name??p?.name??h("sandbox.postToolbar.filterLabel"),e[10]=p?.name,e[11]=f?.name,e[12]=h,e[13]=x):x=e[13];const v=x,b=i?`cat:${i}`:o?`author:${o}`:g1;let _;e[14]!==c||e[15]!==l?(_=()=>{l(null),c(null)},e[14]=c,e[15]=l,e[16]=_):_=e[16];const y=_;let L;e[17]!==y||e[18]!==c||e[19]!==l?(L=ee=>{ee.startsWith("cat:")?(c(null),l(ee.slice(4))):ee.startsWith("author:")?(l(null),c(ee.slice(7))):y()},e[17]=y,e[18]=c,e[19]=l,e[20]=L):L=e[20];const w=L;let j;e[21]!==v||e[22]!==g?(j=r.jsx(bs,{asChild:!0,children:r.jsx(v1,{icon:X6,active:g,value:v,className:"min-w-0 shrink"})}),e[21]=v,e[22]=g,e[23]=j):j=e[23];let S;e[24]!==h?(S=h("sandbox.postToolbar.filterBy"),e[24]=h,e[25]=S):S=e[25];let k;e[26]!==S?(k=r.jsx(La,{children:S}),e[26]=S,e[27]=k):k=e[27];let C;e[28]!==h?(C=h("sandbox.postToolbar.allPosts"),e[28]=h,e[29]=C):C=e[29];let A;e[30]!==C?(A=r.jsx(Fo,{value:g1,children:C}),e[30]=C,e[31]=A):A=e[31];let P;e[32]!==s.length||e[33]!==h?(P=s.length>0&&r.jsx(La,{className:"text-muted-foreground/70",children:h("sandbox.postToolbar.categoryLabel")}),e[32]=s.length,e[33]=h,e[34]=P):P=e[34];let V;e[35]!==s?(V=s.map(HO),e[35]=s,e[36]=V):V=e[36];let T;e[37]!==n.length||e[38]!==h?(T=n.length>0&&r.jsx(La,{className:"text-muted-foreground/70",children:h("sandbox.postToolbar.authorLabel")}),e[37]=n.length,e[38]=h,e[39]=T):T=e[39];let R;e[40]!==n?(R=n.map(UO),e[40]=n,e[41]=R):R=e[41];let E;e[42]!==b||e[43]!==w||e[44]!==A||e[45]!==P||e[46]!==V||e[47]!==T||e[48]!==R?(E=r.jsxs($d,{value:b,onValueChange:w,children:[A,P,V,T,R]}),e[42]=b,e[43]=w,e[44]=A,e[45]=P,e[46]=V,e[47]=T,e[48]=R,e[49]=E):E=e[49];let I;e[50]!==E||e[51]!==k?(I=r.jsxs(ys,{align:"start",className:"max-h-96 w-60 overflow-y-auto",children:[k,E]}),e[50]=E,e[51]=k,e[52]=I):I=e[52];let D;e[53]!==I||e[54]!==j?(D=r.jsxs(vs,{children:[j,I]}),e[53]=I,e[54]=j,e[55]=D):D=e[55];let M;e[56]!==y||e[57]!==g||e[58]!==h?(M=g&&r.jsx(WO,{label:h("sandbox.postToolbar.clearFilter"),onClick:y}),e[56]=y,e[57]=g,e[58]=h,e[59]=M):M=e[59];const O=zO[a];let $;e[60]!==h||e[61]!==O?($=h(O),e[60]=h,e[61]=O,e[62]=$):$=e[62];let B;e[63]!==$?(B=r.jsx(bs,{asChild:!0,children:r.jsx(v1,{icon:Q6,active:!0,value:$})}),e[63]=$,e[64]=B):B=e[64];let z;e[65]!==h?(z=h("sandbox.postToolbar.sortBy"),e[65]=h,e[66]=z):z=e[66];let K;e[67]!==z?(K=r.jsx(La,{children:z}),e[67]=z,e[68]=K):K=e[68];let Y;e[69]!==d?(Y=ee=>d(ee),e[69]=d,e[70]=Y):Y=e[70];let Q;e[71]===Symbol.for("react.memo_cache_sentinel")?(Q=Object.keys(x1),e[71]=Q):Q=e[71];let q;e[72]!==h?(q=Q.map(ee=>r.jsx(Fo,{value:ee,children:h(x1[ee])},ee)),e[72]=h,e[73]=q):q=e[73];let H;e[74]!==a||e[75]!==Y||e[76]!==q?(H=r.jsx($d,{value:a,onValueChange:Y,children:q}),e[74]=a,e[75]=Y,e[76]=q,e[77]=H):H=e[77];let U;e[78]!==K||e[79]!==H?(U=r.jsxs(ys,{align:"end",className:"w-44",children:[K,H]}),e[78]=K,e[79]=H,e[80]=U):U=e[80];let X;e[81]!==B||e[82]!==U?(X=r.jsx("div",{className:"ml-auto shrink-0",children:r.jsxs(vs,{children:[B,U]})}),e[81]=B,e[82]=U,e[83]=X):X=e[83];let J;return e[84]!==D||e[85]!==M||e[86]!==X?(J=r.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden border-b px-2 py-1.5",children:[D,M,X]}),e[84]=D,e[85]=M,e[86]=X,e[87]=J):J=e[87],J}function UO(t){return r.jsxs(Fo,{value:`author:${t.email}`,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),r.jsx(x5,{count:t.count})]},`author:${t.email}`)}function HO(t){return r.jsxs(Fo,{value:`cat:${t.slug}`,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),r.jsx(x5,{count:t.count})]},`cat:${t.slug}`)}function WO(t){const e=F.c(4),{label:s,onClick:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(an,{size:12}),e[0]=i):i=e[0];let o;return e[1]!==s||e[2]!==n?(o=r.jsx("button",{type:"button","aria-label":s,onClick:n,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:i}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function qO(t){const e=F.c(18),{checked:s,disabled:n,onToggle:i}=t,o=oe();let a;e[0]!==i?(a=()=>i(),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==o?(l=o(s?"sandbox.postToolbar.deselectAllPosts":"sandbox.postToolbar.selectAllPosts"),e[2]=s,e[3]=o,e[4]=l):l=e[4];let c;e[5]!==s||e[6]!==n||e[7]!==a||e[8]!==l?(c=r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:GO,children:r.jsx(Pr,{checked:s,disabled:n,onCheckedChange:a,"aria-label":l})})}),e[5]=s,e[6]=n,e[7]=a,e[8]=l,e[9]=c):c=e[9];let d;e[10]!==s||e[11]!==o?(d=o(s?"sandbox.postToolbar.deselectAll":"sandbox.postToolbar.selectAll"),e[10]=s,e[11]=o,e[12]=d):d=e[12];let h;e[13]!==d?(h=r.jsx(He,{side:"bottom",children:d}),e[13]=d,e[14]=h):h=e[14];let u;return e[15]!==c||e[16]!==h?(u=r.jsxs(We,{children:[c,h]}),e[15]=c,e[16]=h,e[17]=u):u=e[17],u}function GO(t){return t.stopPropagation()}function YO(t){const e=F.c(42),{count:s,allSelected:n,onToggleSelectAll:i,onDelete:o,onExit:a}=t,l=oe();let c;e[0]!==n||e[1]!==i?(c=r.jsx(qO,{checked:n,onToggle:i}),e[0]=n,e[1]=i,e[2]=c):c=e[2];let d;e[3]!==s||e[4]!==l?(d=l("sandbox.postToolbar.itemsSelected",{count:s}),e[3]=s,e[4]=l,e[5]=d):d=e[5];let h;e[6]!==d?(h=r.jsx("span",{className:"text-xs font-medium tabular-nums",children:d}),e[6]=d,e[7]=h):h=e[7];const u=s===0;let f;e[8]!==l?(f=l("sandbox.postToolbar.deleteSelectedPosts"),e[8]=l,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(_s,{size:14}),e[10]=m):m=e[10];let p;e[11]!==o||e[12]!==u||e[13]!==f?(p=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:u,onClick:o,"aria-label":f,children:m})}),e[11]=o,e[12]=u,e[13]=f,e[14]=p):p=e[14];let g;e[15]!==l?(g=l("sandbox.postToolbar.deleteSelected"),e[15]=l,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(He,{side:"bottom",children:g}),e[17]=g,e[18]=x):x=e[18];let v;e[19]!==p||e[20]!==x?(v=r.jsxs(We,{children:[p,x]}),e[19]=p,e[20]=x,e[21]=v):v=e[21];let b;e[22]!==l?(b=l("sandbox.postToolbar.exitSelection"),e[22]=l,e[23]=b):b=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(an,{size:14}),e[24]=_):_=e[24];let y;e[25]!==a||e[26]!==b?(y=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,"aria-label":b,children:_})}),e[25]=a,e[26]=b,e[27]=y):y=e[27];let L;e[28]!==l?(L=l("sandbox.postToolbar.exitSelection"),e[28]=l,e[29]=L):L=e[29];let w;e[30]!==L?(w=r.jsx(He,{side:"bottom",children:L}),e[30]=L,e[31]=w):w=e[31];let j;e[32]!==y||e[33]!==w?(j=r.jsxs(We,{children:[y,w]}),e[32]=y,e[33]=w,e[34]=j):j=e[34];let S;e[35]!==v||e[36]!==j?(S=r.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[v,j]}),e[35]=v,e[36]=j,e[37]=S):S=e[37];let k;return e[38]!==c||e[39]!==S||e[40]!==h?(k=r.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[c,h,S]}),e[38]=c,e[39]=S,e[40]=h,e[41]=k):k=e[41],k}function so(t){const e=F.c(34),{onDuplicate:s,onRename:n,onAddVariant:i,onEditSeo:o,onViewJson:a,onDelete:l}=t,c=oe();let d;e[0]!==c?(d=c("sandbox.itemActions.moreActions"),e[0]=c,e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Ki,{size:14}),e[2]=h):h=e[2];let u;e[3]!==d?(u=r.jsx(bs,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":d,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:JO,children:h})}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==n||e[6]!==c?(f=n&&r.jsxs(Je,{onClick:n,children:[r.jsx(V9,{size:14}),c("sandbox.itemActions.rename")]}),e[5]=n,e[6]=c,e[7]=f):f=e[7];let m;e[8]!==s||e[9]!==c?(m=s&&r.jsxs(Je,{onClick:s,children:[r.jsx(Vs,{size:14}),c("sandbox.itemActions.duplicate")]}),e[8]=s,e[9]=c,e[10]=m):m=e[10];let p;e[11]!==i||e[12]!==c?(p=i&&r.jsxs(r.Fragment,{children:[r.jsx(Xn,{}),r.jsxs(Je,{onClick:i,className:"cursor-pointer text-success focus:text-success",children:[r.jsx(j9,{size:14}),c("sandbox.itemActions.addVariant")]})]}),e[11]=i,e[12]=c,e[13]=p):p=e[13];let g;e[14]!==o||e[15]!==a||e[16]!==c?(g=(o||a)&&r.jsxs(r.Fragment,{children:[r.jsx(Xn,{}),o&&r.jsxs(Je,{onClick:o,children:[r.jsx(ul,{size:14}),c("sandbox.itemActions.editSeo")]}),a&&r.jsxs(Je,{onClick:a,children:[r.jsx(ra,{size:14}),c("sandbox.itemActions.viewJson")]})]}),e[14]=o,e[15]=a,e[16]=c,e[17]=g):g=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Xn,{}),e[18]=x):x=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(_s,{size:14}),e[19]=v):v=e[19];let b;e[20]!==c?(b=c("sandbox.itemActions.delete"),e[20]=c,e[21]=b):b=e[21];let _;e[22]!==l||e[23]!==b?(_=r.jsxs(Je,{onClick:l,className:"text-destructive focus:text-destructive",children:[v,b]}),e[22]=l,e[23]=b,e[24]=_):_=e[24];let y;e[25]!==_||e[26]!==f||e[27]!==m||e[28]!==p||e[29]!==g?(y=r.jsxs(ys,{align:"end",className:"w-44",children:[f,m,p,g,x,_]}),e[25]=_,e[26]=f,e[27]=m,e[28]=p,e[29]=g,e[30]=y):y=e[30];let L;return e[31]!==y||e[32]!==u?(L=r.jsxs(vs,{children:[u,y]}),e[31]=y,e[32]=u,e[33]=L):L=e[33],L}function JO(t){return t.stopPropagation()}function XO(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function QO(t){const e=new Map;for(const s of t){const n=XO(s.resolveType),i=e.get(n);i?i.push(s):e.set(n,[s])}return[...e.entries()].map(([s,n])=>({label:s,sections:n})).sort((s,n)=>s.label.localeCompare(n.label))}function b1(t){const e=F.c(8),{icon:s,label:n,className:i}=t;let o;e[0]!==i?(o=ie("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",i),e[0]=i,e[1]=o):o=e[1];let a;e[2]!==s?(a=r.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==n||e[5]!==o||e[6]!==a?(l=r.jsxs("div",{className:o,children:[a,n]}),e[4]=n,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}const y1=N.lazy(()=>Ns(()=>import("./app-editor-B1reldMi.js"),__vite__mapDeps([162,1,2,18,53,54,55,17,3,19,56,57,58,59,60,61,62,63,32,64,51,65,66,67,68,69,5,16,20,4,6,7,8,9,10,11,12,13,14,15,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,52,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,107,108,109,110,111,112,113,114,115,116,117,118,119,104,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,106,156,157,158,159])).then(t=>({default:t.AppEditor}))),ZO=N.lazy(()=>Ns(()=>import("./post-editor-BaU667xO.js"),__vite__mapDeps([163,1,2,5,34,4,6,7,8,9,10,11,12,13,14,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,103,102,164,139,142,120,121,78,112,123,136,55,165,93,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,83,84,85,86,87,88,89,90,91,92,94,95,96,97,98,99,100,101,166,167,108,109,110,111,113,114,115,116,117,118,119,104,122,124,125,126,127,128,129,130,131,132,133,134,135,137,138,140,141,143,144,145,146,147,148,149,150,151,152,153,154,155,106,156,157,158,159])).then(t=>({default:t.PostEditor}))),e$=N.lazy(()=>Ns(()=>import("./record-editor-CyFKknlv.js"),__vite__mapDeps([168,1,2,103,102,54,55,17,3,19,136,166,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,167,84,85,80,59,60,81,82,83,71,61,86,87,79,88,89,53,56,57,58,62,63,64,65,66,67,68,69,70,72,73,74,75,76,77,78,90,91,92,93,94,95,96,97,98,99,100,101,108,109,110,111,112,113,114,115,116,117,118,119,104,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,106,156,157,158,159])).then(t=>({default:t.RecordEditor}))),t$=N.lazy(()=>Ns(()=>import("./category-editor-s0kMzuKL.js"),__vite__mapDeps([169,1,2,10,14,34,4,5,6,7,8,9,11,12,13,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,126,103,102,165,120,121,78,112,93,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,83,84,85,86,87,88,89,90,91,92,94,95,96,97,98,99,100,101,166,167,108,109,110,111,113,114,115,116,117,118,119,104,122,123,124,125,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,106,156,157,158,159])).then(t=>({default:t.CategoryEditor}))),s$=N.lazy(()=>Ns(()=>import("./bulk-category-panel-B1Gi9wUq.js"),__vite__mapDeps([170,1,2,14,51,102,54,55,17,3,19,7,84,85,80,59,60,81,82,83,71,61,86,87,79,88,89,53,56,57,58,62,63,32,64,65,66,67,68,69,5,16,20,4,6,8,9,10,11,12,13,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,52,70,72,73,74,75,76,77,78,90,91,92,93,94,95,96,97,98,99,100,101,103,108,109,110,111,112,113,114,115,116,117,118,119,104,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,106,156,157,158,159])).then(t=>({default:t.BulkCategoryPanel}))),n$=N.lazy(()=>Ns(()=>import("./sections-editor-CK1krdST.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159])).then(t=>({default:t.SectionsEditor}))),i$=N.lazy(()=>Ns(()=>import("./seo-editor-C_DByLik.js"),__vite__mapDeps([171,1,2,18,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,105,106,108,109,110,111,112,113,114,115,116,117,118,119,104,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159])).then(t=>({default:t.SeoEditor}))),r$=N.lazy(()=>Ns(()=>import("./variant-calendar-DqtEssYW.js"),__vite__mapDeps([172,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,102,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,103,106,173])).then(t=>({default:t.VariantCalendar}))),o$=N.lazy(()=>Ns(()=>import("./redirect-editor-fK_i-XfS.js"),__vite__mapDeps([174,1,2,142,17,103,102,54,55,3,19,167,7,84,85,80,59,60,81,82,83,71,61,86,87,79,88,89,53,56,57,58,62,63,32,64,51,65,66,67,68,69,5,16,20,4,6,8,9,10,11,12,13,14,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,52,70,72,73,74,75,76,77,78,90,91,92,93,94,95,96,97,98,99,100,101,108,109,110,111,112,113,114,115,116,117,118,119,104,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,143,144,145,146,147,148,149,150,151,152,153,154,155,106,156,157,158,159])).then(t=>({default:t.RedirectEditor})));function xd(t){return t?t.kind==="page"?{collection:"pages",key:t.key,path:t.path}:{collection:"sections",key:t.key}:null}function a$(t){return t?t.kind==="page"?`page:${t.key}:${t.path}`:`section:${t.key}`:null}function l$(t){const e=F.c(14),{mode:s}=t,n=s===void 0?"content":s,i=Kn(),{currentBranch:o}=ls(),{org:a}=ze(),l=i?.entity?.id??null,c=Ps(),d=Yi(),h=d.previewUrl,u=d.previewState;if(u.kind==="othersThread")return null;if(u.kind!=="iframe"){const p=`/${a.slug}/settings/connections`;let g;return e[0]!==d.start||e[1]!==u||e[2]!==p||e[3]!==c.lifecycle||e[4]!==c.phase?(g=r.jsx(AR,{state:u,claimPhase:c.phase,lifecycle:c.lifecycle,onStart:d.start,connectionsHref:p}),e[0]=d.start,e[1]=u,e[2]=p,e[3]=c.lifecycle,e[4]=c.phase,e[5]=g):g=e[5],g}if(!l||!o){let p;return e[6]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Qn,{title:"Waiting for sandbox context…"}),e[6]=p):p=e[6],p}const f=c.lifecycle.phase==="running";let m;return e[7]!==o||e[8]!==n||e[9]!==a.slug||e[10]!==h||e[11]!==f||e[12]!==l?(m=r.jsx(d$,{orgSlug:a.slug,virtualMcpId:l,branch:o,previewUrl:h,mode:n,devServerReady:f}),e[7]=o,e[8]=n,e[9]=a.slug,e[10]=h,e[11]=f,e[12]=l,e[13]=m):m=e[13],m}const _1=2e3,c$=15;function L1(t,e,s,n){return typeof e!="string"||s&&(T4(e,s,n)||t.state.dataUpdateCount>=c$)?!1:_1}function d$({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,mode:i,devServerReady:o}){const a=wu(),l={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n},c=xR(e),{data:d,isLoading:h}=uc(l,{fetchEnabled:o}),[u,f]=N.useState("pages"),[m,p]=N.useState(()=>i==="blocks"?xd(a.state.target):null),[g,x]=N.useState(()=>i==="blocks"?a.state.editSeoPageKey:null),v=a$(a.state.target),[b,_]=N.useState(v);if(i==="blocks"&&b!==v){_(v);const ne=xd(a.state.target);p(ne),(ne?.collection==="pages"||ne?.collection==="sections")&&f(ne.collection)}const[y,L]=N.useState(a.state.editSeoPageKey);if(i==="blocks"&&y!==a.state.editSeoPageKey&&(L(a.state.editSeoPageKey),a.state.editSeoPageKey)){const ne=a.state.target;ne?.kind==="page"&&(f("pages"),p(xd(ne)),x(ne.key))}const[w,j]=N.useState(""),[S,k]=N.useState(null),[C,A]=N.useState(null),[P,V]=N.useState("date-desc"),[T,R]=N.useState(()=>new Set),[E,I]=N.useState(null),D=()=>{R(new Set),I(null)},M=ne=>{p(ne),x(null),!(i!=="blocks"||!ne)&&(ne.collection==="pages"?a.selectTarget({kind:"page",key:ne.key,path:ne.path}):ne.collection==="sections"&&a.selectTarget({kind:"section",key:ne.key}))},[O,$]=N.useState(u);O!==u&&($(u),j(""),k(null),A(null),V("date-desc"),R(new Set),I(null));const{data:B,isLoading:z,isFetching:K}=hc(l,{fetchEnabled:o,refetchInterval:ne=>{const De=ne.state.data;if(u==="apps"&&m&&m.collection==="apps"){const Ke=d?.[m.key];return L1(ne,typeof Ke?.__resolveType=="string"?Ke.__resolveType:void 0,De)}if(u==="site"&&d){const Ke=De?Gd(d,De):null,Ge=d.site,mt=Ke?.resolveType??(typeof Ge?.__resolveType=="string"?Ge.__resolveType:void 0);return L1(ne,mt,De,["seo"])}return!1}}),Y=(ne,De)=>!T4(ne,B,De)&&(z||K),{catalog:Q,isLoading:q}=NR(B??void 0,d??void 0,{enabled:u==="apps"}),H=kc(l),U=yR(l),X=lD({...l,packagePath:c}),J=cD({...l,packagePath:c}),[ee,W]=N.useState(null),[Z,G]=N.useState(),[te,se]=N.useState(null),[re,de]=N.useState(null),[ce,fe]=N.useState(null);if(h||z)return r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ze,{size:20,className:"animate-spin text-muted-foreground"})});if(!d||!B)return r.jsx(Qn,{title:"Could not load site data."});const ue=G9(d).sort((ne,De)=>ne.name.localeCompare(De.name)),ae=d3(d).sort((ne,De)=>ne.from.localeCompare(De.from)),me=Y9(d,B),xe=u==="sections"?pw(B):[],Se=Gd(d,B),Ve=I4(d),Ie=ju.some(ne=>Ve[ne].length>0),Ne=To(u)?Ve[u]:[],Ee=(Ie?Jo(d,"categories"):[]).map(({key:ne,payload:De})=>{const Ke=typeof De.slug=="string"?De.slug:"",Ge=typeof De.name=="string"?De.name:"";return{slug:Ke||ne,name:Ge||Ke||ne}}).filter(ne=>ne.slug).sort((ne,De)=>ne.name.localeCompare(De.name)),we=u==="posts"&&(T.size>0||E!==null),Ae=we?O4(d).filter(ne=>T.has(ne.key)):[],be=Mf(B,"loaders"),je=Mf(B,"actions");if(!q9(d,B)&&!Ie&&be===0&&je===0)return r.jsx(Qn,{icon:jn,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, apps, loaders, or actions."});const ge={pages:ue.length,sections:me.length,apps:Q.length,loaders:be,actions:je,redirects:ae.length,posts:Ve.posts.length,authors:Ve.authors.length,categories:Ve.categories.length},Le=new Set(ue.map(ne=>ti(ne.path))),ye=new Set(ue.map(ne=>ne.name)),Ce=new Set(me.map(ne=>ne.name)),Me=async ne=>{const De=d[ne.key];if(!De)return;const Ke=d4(d,ne.key),Ge=u4(d,ne.key,Math.max(0,Ke-1)),mt=DE(De.sections,Ge);if(mt)try{await H.mutateAsync({blockKey:ne.key,data:{...De,sections:mt}}),ve.success(`Variant added to "${ne.name}"`),p({collection:"pages",key:ne.key,path:ne.path})}catch(Lt){ve.error(Lt instanceof Error?Lt.message:"Could not add variant")}},Re=()=>{G(void 0),W({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},ke=ne=>{G(void 0),W({mode:"duplicate",sourceKey:ne.key,initialName:Uf(ye,ne.name),initialPath:ER(Le,ne.path)})},$e=ne=>{G(void 0),W({mode:"rename",sourceKey:ne.key,initialName:ne.name,initialPath:ne.path})},qe=async ne=>{if(!ee)return;const{mode:De,sourceKey:Ke}=ee;try{if(De==="create"){let Ge;if(ne.templateKey){const Lt=d[ne.templateKey];if(!Lt)throw new Error("Selected template no longer exists.");Ge={...Lt,name:ne.name,path:ne.path}}else Ge=DR(ne.name,ne.path);const mt=MR(d,ne.name);await H.mutateAsync({blockKey:mt,data:Ge}),ve.success(`Created "${ne.name}"`),p({collection:"pages",key:mt,path:ne.path})}else if(De==="duplicate"&&Ke){const Ge=d[Ke];if(!Ge)throw new Error("Source page not found");const{key:mt,data:Lt}=RR({source:Ge,pages:ue,newName:ne.name,newPath:ne.path});await H.mutateAsync({blockKey:mt,data:Lt}),ve.success(`Duplicated as "${ne.name}"`),p({collection:"pages",key:mt,path:ne.path})}else if(De==="rename"&&Ke){const Ge=d[Ke];if(!Ge)throw new Error("Page not found");const mt={...Ge,name:ne.name,path:ne.path};await H.mutateAsync({blockKey:Ke,data:mt}),ve.success("Page updated"),m?.collection==="pages"&&m.key===Ke&&p({collection:"pages",key:Ke,path:ne.path})}W(null)}catch(Ge){G(Ge instanceof Error?Ge.message:"Save failed")}},lt=({path:ne})=>{if(!ee)return null;const De=ti(ne);return(ee.mode==="rename"?ti(ee.initialPath):null)!==De&&Le.has(De)?`A page with path "${ne}" already exists.`:null},ft=async(ne,De,Ke)=>{await H.mutateAsync({blockKey:De,data:{...Ke,name:De,__resolveType:ne}}),ve.success(`Created section "${De}"`),p({collection:"sections",key:De})},dt=R4((ne,De)=>H.mutate({blockKey:ne,data:De})),it=async ne=>{const De=d[ne.key];if(!De){ve.error("Section not found.");return}const Ke=PR(d,ne.key),Ge=Uf(Ce,ne.name),mt={...De,name:Ge};try{await H.mutateAsync({blockKey:Ke,data:mt}),ve.success(`Duplicated "${ne.name}"`),p({collection:"sections",key:Ke})}catch(Lt){ve.error(Lt instanceof Error?Lt.message:"Duplicate failed")}},xt=async ne=>{if(!te)return;const De=d[te];if(!De){ve.error("Section not found.");return}try{await H.mutateAsync({blockKey:te,data:{...De,name:ne}}),ve.success("Section renamed"),se(null)}catch(Ke){ve.error(Ke instanceof Error?Ke.message:"Rename failed")}},vt=async()=>{const ne="/redirect-from",De=Lw(d,ne),Ke=bw({from:ne,to:"/redirect-to",type:"temporary",discardQueryParameters:!1});try{await H.mutateAsync({blockKey:De,data:Ke}),ve.success("Created redirect"),p({collection:"redirects",key:De})}catch(Ge){ve.error(Ge instanceof Error?Ge.message:"Could not create redirect")}},pe=async ne=>{const De=qf(d,ne),Ke=Ma(De,ne,ZR(ne));try{await X.mutateAsync({blockKey:De,data:Ke}),ve.success(`Created ${No[ne]}`),p({collection:ne,key:De})}catch(Ge){ve.error(Ge instanceof Error?Ge.message:"Could not create")}},Be=async ne=>{const De=d[ne.key];if(!De){ve.error("Record not found.");return}const Ke=qf(d,ne.kind),Ge=ne.kind==="posts"?"title":"name",mt={...structuredClone(el(De,ne.kind)),[Ge]:`${ne.label} (copy)`};try{await X.mutateAsync({blockKey:Ke,data:Ma(Ke,ne.kind,mt)}),ve.success(`Duplicated "${ne.label}"`),p({collection:ne.kind,key:Ke})}catch(Lt){ve.error(Lt instanceof Error?Lt.message:"Duplicate failed")}},Xe=ne=>{R(De=>{const Ke=new Set(De);return Ke.has(ne)?Ke.delete(ne):Ke.add(ne),Ke})},gt=ne=>{f("posts"),$("posts"),p(null),x(null),j(""),k(null),A(null),V("date-desc"),R(new Set),I(ne||null)},Vt=async(ne,De)=>{const Ke=[...T];let Ge=0;for(const mt of Ke){const Lt=d[mt],Un=el(Lt,"posts"),Cn=ne==="add"?JR(Un,De):XR(Un,De);Cn!==Un&&(await X.mutateAsync({blockKey:mt,data:Ma(mt,"posts",Wf(Cn))}),Ge+=1)}return Ge},zt=async(ne,De)=>{const Ke=T.size;try{const Ge=await Vt(ne,De),mt=ne==="add"?"Added to":"Moved",Lt=Ke-Ge;ve.success(`${mt} ${Ge} ${Ge===1?"post":"posts"}`+(Lt>0?` (${Lt} already set)`:"")),D()}catch(Ge){ve.error(Ge instanceof Error?Ge.message:"Bulk update failed")}},Nt=async()=>{if(re)try{if(re.kind==="blog-bulk"){for(const Ge of re.keys)await J.mutateAsync({blockKey:Ge});ve.success(`Deleted ${re.count} ${re.count===1?"post":"posts"}`),m&&m.collection!=="available-section"&&re.keys.includes(m.key)&&p(null),D(),de(null);return}const{kind:ne,key:De,label:Ke}=re;if(ne==="blog"){if(re.blogKind==="categories"){const Ge=el(d[De],"categories").slug,mt=typeof Ge=="string"?Ge:"";if(mt)for(const{key:Lt,payload:Un}of Jo(d,"posts")){const Cn=QR(Un,mt);Cn!==Un&&await X.mutateAsync({blockKey:Lt,data:Ma(Lt,"posts",Wf(Cn))})}}await J.mutateAsync({blockKey:De})}else await U.mutateAsync({blockKey:De});ve.success(`Deleted "${Ke}"`),m&&m.collection!=="available-section"&&m.key===De&&p(null),de(null)}catch(ne){ve.error(ne instanceof Error?ne.message:"Delete failed")}},ct=U.isPending||J.isPending||X.isPending,Rs=re?.kind==="blog"?No[re.blogKind]:re?.kind==="blog-bulk"?`${re.count} ${re.count===1?"post":"posts"}`:re?.kind??"item";return r.jsxs("div",{className:"flex h-full w-full",children:[i==="content"&&r.jsx(TR,{active:u,counts:ge,showBlog:Ie,onSelect:ne=>{f(ne),p(null),x(null)}}),u!=="seo"&&u!=="site"&&u!=="calendar"&&u!=="loaders"&&u!=="actions"&&r.jsx(u$,{blocksMode:i==="blocks",activeCollection:u,pages:ue,redirects:ae,sections:me,availableSections:xe,appCatalog:Q,appCatalogLoading:q,blogEntries:Ne,decofile:d,searchQuery:w,onSearchChange:j,postCategoryFilter:S,postAuthorFilter:C,postSort:P,onPostCategoryFilterChange:ne=>{k(ne),R(new Set)},onPostAuthorFilterChange:ne=>{A(ne),R(new Set)},onPostSortChange:V,selectedPostKeys:T,postBulkPanelOpen:we,onTogglePostSelect:Xe,onSelectAllPosts:ne=>R(new Set(ne)),onClearPostSelection:()=>R(new Set),onExitPostSelection:D,onBulkDeletePosts:()=>de({kind:"blog-bulk",keys:[...T],count:T.size}),selection:m,onSelect:M,onCollectionSelect:ne=>{f(ne),p(null),x(null)},onCreate:()=>{u==="pages"?Re():u==="redirects"?vt():To(u)&&pe(u)},onDuplicatePage:ke,onRenamePage:$e,onAddPageVariant:Me,onDeletePage:ne=>de({kind:"page",key:ne.key,label:ne.name}),onEditPageSeo:ne=>{const De={collection:"pages",key:ne.key,path:ne.path};p(De),x(ne.key),i==="blocks"&&a.editSeo({kind:"page",key:ne.key,path:ne.path})},onViewPageJson:ne=>fe(ne.key),onDuplicateSection:it,onRenameSection:ne=>se(ne.key),onDeleteSection:ne=>de({kind:"section",key:ne.key,label:ne.name}),onDeleteRedirect:ne=>de({kind:"redirect",key:ne.key,label:ne.from||ne.key}),onDuplicateBlog:Be,onDeleteBlog:ne=>de({kind:"blog",blogKind:ne.kind,key:ne.key,label:ne.label})}),r.jsx("div",{className:"flex-1 min-w-0",children:u==="loaders"||u==="actions"?r.jsx(kO,{orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:B,decofile:d,kind:u}):r.jsx(N.Suspense,{fallback:r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(Ze,{size:20,className:"animate-spin text-muted-foreground"})}),children:u==="calendar"?r.jsx(r$,{decofile:d}):u==="site"?Se?r.jsx(y1,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:Se.key,block:d[Se.key],decofile:d,meta:B,title:"Site",excludeFields:["seo"],schemaPending:Y(Se.resolveType,["seo"]),previewBaseUrl:n},`site:${Se.key}`):r.jsx(Qn,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):u==="seo"?r.jsx(i$,{orgSlug:t,virtualMcpId:e,branch:s,decofile:d,meta:B,target:{kind:"site"},previewBaseUrl:n}):u==="sections"?r.jsx(FO,{selection:m?.collection==="sections"||m?.collection==="available-section"?m:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:B,decofile:d,isCreating:H.isPending,onCreateAvailable:ft,onSaveReferencedBlock:dt}):we?r.jsx(s$,{posts:Ae,categories:Ee,initialSlug:E,isPending:X.isPending,onApply:(ne,De)=>{zt(ne,De)},onClose:D},E??"selection"):m&&m.collection!=="available-section"?m.collection==="apps"?r.jsx(y1,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:B,previewBaseUrl:n,schemaPending:Y(typeof d[m.key]?.__resolveType=="string"?String(d[m.key].__resolveType):void 0)},`app:${m.key}`):m.collection==="posts"?r.jsx(ZO,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:B,previewBaseUrl:n},`post:${m.key}`):m.collection==="categories"?r.jsx(t$,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:B,onManagePosts:gt,onOpenPost:ne=>{f("posts"),$("posts"),p({collection:"posts",key:ne}),x(null)},previewBaseUrl:n},`category:${m.key}`):m.collection==="authors"?r.jsx(e$,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:m.key,block:d[m.key]},`authors:${m.key}`):m.collection==="redirects"?r.jsx(o$,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key]},`redirect:${m.key}`):r.jsx(n$,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:n??void 0,currentPath:m.collection==="pages"?m.path:"/",activePageBlockKey:m.collection==="pages"?m.key:null,activeGlobalBlockKey:m.collection==="sections"?m.key:null,initialEditSeo:m.collection==="pages"&&g===m.key,onExitSeo:()=>{x(null),i==="blocks"&&a.consumeEditSeo()}},m.collection==="pages"?`page:${m.key}`:`section:${m.key}`):r.jsx(Qn,{title:`Select ${To(u)?`a ${No[u]}`:u==="pages"?"a page":u==="apps"?"an app":u==="redirects"?"a redirect":"a section"} to edit`,description:u==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),ee&&r.jsx(FR,{open:!!ee,mode:ee.mode,initialName:ee.initialName,initialPath:ee.initialPath,isPending:H.isPending,error:Z,templates:ue,validate:lt,onSubmit:qe,onOpenChange:ne=>{ne||(W(null),G(void 0))}}),te&&r.jsx(zR,{open:!!te,blockKey:te,initialName:me.find(ne=>ne.key===te)?.name??te,isPending:H.isPending,onSubmit:xt,onOpenChange:ne=>{ne||se(null)}}),ce&&r.jsx(dD,{open:!!ce,onOpenChange:ne=>{ne||fe(null)},pageKey:ce,decofile:d,onSave:ne=>H.mutateAsync({blockKey:ce,data:ne})}),r.jsx(pl,{open:!!re,onOpenChange:ne=>{!ne&&!ct&&de(null)},children:r.jsxs(gl,{children:[r.jsxs(xl,{children:[r.jsx(vl,{children:`Delete ${Rs}?`}),r.jsx(bl,{children:re?.kind==="section"?`"${re.label}" will be removed. Pages that still reference it will lose this section.`:re?.kind==="blog-bulk"?`${re.count} ${re.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:re?`"${re.label}" will be removed permanently. This can't be undone.`:null})]}),r.jsxs(yl,{children:[r.jsx(_l,{disabled:ct,children:"Cancel"}),r.jsx(Ll,{onClick:ne=>{ne.preventDefault(),Nt()},disabled:ct,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:ct?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function u$(t){const e=F.c(88),{blocksMode:s,activeCollection:n,pages:i,redirects:o,sections:a,availableSections:l,appCatalog:c,appCatalogLoading:d,blogEntries:h,decofile:u,searchQuery:f,onSearchChange:m,postCategoryFilter:p,postAuthorFilter:g,postSort:x,onPostCategoryFilterChange:v,onPostAuthorFilterChange:b,onPostSortChange:_,selectedPostKeys:y,postBulkPanelOpen:L,onTogglePostSelect:w,onSelectAllPosts:j,onClearPostSelection:S,onExitPostSelection:k,onBulkDeletePosts:C,selection:A,onSelect:P,onCollectionSelect:V,onCreate:T,onDuplicatePage:R,onRenamePage:E,onAddPageVariant:I,onDeletePage:D,onEditPageSeo:M,onViewPageJson:O,onDuplicateSection:$,onRenameSection:B,onDeleteSection:z,onDeleteRedirect:K,onDuplicateBlog:Y,onDeleteBlog:Q}=t;let q,H,U,X,J,ee,W,Z;if(e[0]!==n||e[1]!==c||e[2]!==d||e[3]!==l||e[4]!==s||e[5]!==h||e[6]!==u||e[7]!==I||e[8]!==C||e[9]!==S||e[10]!==V||e[11]!==T||e[12]!==Q||e[13]!==D||e[14]!==K||e[15]!==z||e[16]!==Y||e[17]!==R||e[18]!==$||e[19]!==M||e[20]!==k||e[21]!==b||e[22]!==v||e[23]!==_||e[24]!==E||e[25]!==B||e[26]!==m||e[27]!==P||e[28]!==j||e[29]!==w||e[30]!==O||e[31]!==i||e[32]!==g||e[33]!==L||e[34]!==p||e[35]!==x||e[36]!==o||e[37]!==f||e[38]!==a||e[39]!==y||e[40]!==A){const re=f.toLowerCase(),de=i.filter(pe=>!re||pe.name.toLowerCase().includes(re)||pe.path.toLowerCase().includes(re)),ce=o.filter(pe=>!re||pe.from.toLowerCase().includes(re)||pe.to.toLowerCase().includes(re)),fe=a.filter(pe=>!re||pe.name.toLowerCase().includes(re)||pe.key.toLowerCase().includes(re)||pe.resolveType.toLowerCase().includes(re)),ue=l.filter(pe=>!re||pe.title.toLowerCase().includes(re)||pe.resolveType.toLowerCase().includes(re)||(pe.description?.toLowerCase().includes(re)??!1)),ae=QO(fe),me=c.filter(pe=>!re||pe.title.toLowerCase().includes(re)||pe.app.toLowerCase().includes(re)||pe.vendor.toLowerCase().includes(re)||pe.category.toLowerCase().includes(re)),xe=h.filter(pe=>!re||pe.label.toLowerCase().includes(re)||pe.subtitle.toLowerCase().includes(re)),Se=n==="posts",Ve=p$,Ie=Se?O4(u):[],Ne=new Map,Ee=new Map;for(const pe of Ie){for(const Be of pe.categorySlugs)Ne.set(Be,(Ne.get(Be)??0)+1);for(const Be of pe.authorEmails)Ee.set(Be,(Ee.get(Be)??0)+1)}const we=(Se?Jo(u,"categories"):[]).map(pe=>{const{key:Be,payload:Xe}=pe,gt=Ve(Xe.slug)||Be;return{slug:gt,name:Ve(Xe.name)||Ve(Xe.slug)||Be,count:Ne.get(gt)??0}}).filter(m$),Ae=(Se?Jo(u,"authors"):[]).map(pe=>{const{key:Be,payload:Xe}=pe,gt=Ve(Xe.email);return{email:gt,name:Ve(Xe.name)||Ve(Xe.email)||Be,count:Ee.get(gt)??0}}).filter(f$);let be;e[49]!==p?(be=pe=>!p||pe.categorySlugs.includes(p),e[49]=p,e[50]=be):be=e[50];let je;e[51]!==g?(je=pe=>!g||pe.authorEmails.includes(g),e[51]=g,e[52]=je):je=e[52];let ge;e[53]!==x?(ge=(pe,Be)=>{if(x==="az")return pe.title.localeCompare(Be.title);if(x==="za")return Be.title.localeCompare(pe.title);const Xe=pe.date.localeCompare(Be.date);return x==="date-asc"?Xe:-Xe},e[53]=x,e[54]=ge):ge=e[54];const Le=Ie.filter(pe=>!re||pe.title.toLowerCase().includes(re)||pe.slug.toLowerCase().includes(re)).filter(be).filter(je).sort(ge),ye=y.size,Ce=Le.map(h$),Me=Ce.length>0&&Ce.every(pe=>y.has(pe)),Re=ye>0||L,ke=()=>{Me?S():j(Ce)},$e=`Search ${n}…`,qe=To(n)?`Create new ${No[n]}`:n==="redirects"?"Create new redirect":"Create new page",lt=n!=="apps"&&n!=="sections",ft=s?"w-[240px]":"w-[300px]";e[55]!==ft?(J=ie("shrink-0 border-r flex flex-col min-h-0",ft),e[55]=ft,e[56]=J):J=e[56],e[57]!==n||e[58]!==s||e[59]!==V?(ee=s&&r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[r.jsxs(le,{variant:n==="pages"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>V("pages"),children:[r.jsx(An,{size:14}),"Pages"]}),r.jsxs(le,{variant:n==="sections"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>V("sections"),children:[r.jsx(xn,{size:14}),"Sections"]})]}),e[57]=n,e[58]=s,e[59]=V,e[60]=ee):ee=e[60];let dt;e[61]===Symbol.for("react.memo_cache_sentinel")?(dt=r.jsx(C9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[61]=dt):dt=e[61];let it;e[62]!==m?(it=pe=>m(pe.target.value),e[62]=m,e[63]=it):it=e[63];let xt;e[64]!==$e||e[65]!==f||e[66]!==it?(xt=r.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[dt,r.jsx("input",{type:"text",value:f,onChange:it,placeholder:$e,"aria-label":$e,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[64]=$e,e[65]=f,e[66]=it,e[67]=xt):xt=e[67];let vt;e[68]!==qe||e[69]!==T||e[70]!==lt?(vt=lt&&r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:T,"aria-label":qe,children:r.jsx(_t,{size:14})})}),r.jsx(He,{side:"bottom",children:qe})]}),e[68]=qe,e[69]=T,e[70]=lt,e[71]=vt):vt=e[71],e[72]!==xt||e[73]!==vt?(W=r.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[xt,vt]}),e[72]=xt,e[73]=vt,e[74]=W):W=e[74],Z=Se&&(Re?r.jsx(YO,{count:ye,allSelected:Me,onToggleSelectAll:ke,onDelete:C,onExit:k}):r.jsx(KO,{categories:we,authors:Ae,categoryFilter:p,authorFilter:g,sort:x,onCategoryFilterChange:v,onAuthorFilterChange:b,onSortChange:_})),q=fi,X="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",H="flex flex-col gap-1 p-1.5",U=n==="pages"?de.length===0?r.jsx(nr,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):de.map(pe=>{const Be=A?.collection==="pages"&&A.key===pe.key,Xe=d4(u,pe.key);return r.jsx(Qs,{icon:An,title:pe.name,subtitle:pe.path,active:Be,variantCount:Xe,onClick:()=>P({collection:"pages",key:pe.key,path:pe.path}),menu:r.jsx(so,{onDuplicate:()=>R(pe),onRename:()=>E(pe),onAddVariant:()=>I(pe),onEditSeo:()=>M(pe),onViewJson:()=>O(pe),onDelete:()=>D(pe)})},pe.key)}):n==="sections"?fe.length===0&&ue.length===0?r.jsx(nr,{hasItems:a.length>0||l.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):r.jsxs(r.Fragment,{children:[ae.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(b1,{icon:xn,label:"Saved sections"}),ae.map(pe=>r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:pe.label}),pe.sections.map(Be=>{const Xe=A?.collection==="sections"&&A.key===Be.key;return r.jsx(Qs,{icon:xn,accent:"global",title:Be.name,subtitle:pe.label,active:Xe,onClick:()=>P({collection:"sections",key:Be.key}),menu:r.jsx(so,{onDuplicate:()=>$(Be),onRename:()=>B(Be),onDelete:()=>z(Be)})},Be.key)})]},pe.label))]}),ue.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(b1,{icon:An,label:"Available sections",className:ie(ae.length>0&&"mt-3")}),ue.map(pe=>{const Be=A?.collection==="available-section"&&A.resolveType===pe.resolveType,Xe=pe.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return r.jsx(Qs,{icon:An,title:pe.title,subtitle:Xe??pe.resolveType,active:Be,onClick:()=>P({collection:"available-section",resolveType:pe.resolveType,title:pe.title})},pe.resolveType)})]})]}):n==="apps"?d?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Ze,{size:18,className:"animate-spin text-muted-foreground"})}):me.length===0?r.jsx(nr,{hasItems:c.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):me.map(pe=>{const Be=A?.collection==="apps"&&pe.blockKey!==null&&A.key===pe.blockKey;return r.jsx(Qs,{icon:Z2,logoUrl:pe.logo,title:pe.title,subtitle:pe.category,active:Be,trailing:pe.installed?r.jsx("span",{className:"shrink-0 rounded-full bg-success/15 px-1.5 py-0.5 text-[10px] font-medium text-success",children:"Installed"}):void 0,onClick:()=>{if(!pe.installed||!pe.blockKey){ve.message(`${pe.title} is not installed on this site.`);return}P({collection:"apps",key:pe.blockKey})}},pe.id)}):n==="redirects"?ce.length===0?r.jsx(nr,{hasItems:o.length>0,emptyLabel:"No redirects yet.",emptyHint:'Click "+" to create your first redirect.'}):ce.map(pe=>r.jsx(Qs,{icon:v2,title:pe.from||"(no source)",subtitle:`→ ${pe.to||"(no target)"}`,active:A?.collection==="redirects"&&A.key===pe.key,trailing:r.jsx(KR,{type:pe.type}),onClick:()=>P({collection:"redirects",key:pe.key}),menu:r.jsx(so,{onDelete:()=>K(pe)})},pe.key)):Se?Le.length===0?r.jsx(nr,{hasItems:Ie.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):Le.map(pe=>{const Be={key:pe.key,kind:"posts",label:pe.title,subtitle:pe.slug};return r.jsx(Qs,{icon:Pi,title:pe.title,subtitle:pe.slug||"no slug",invalid:pe.missing.length>0,invalidReason:`Missing: ${pe.missing.join(", ")}`,active:A?.collection==="posts"&&A.key===pe.key,selectable:!0,selectionActive:Re,selected:y.has(pe.key),onToggleSelect:()=>w(pe.key),onClick:()=>Re?w(pe.key):P({collection:"posts",key:pe.key}),menu:r.jsx(so,{onDuplicate:()=>Y(Be),onDelete:()=>Q(Be)})},pe.key)}):xe.length===0?r.jsx(nr,{hasItems:h.length>0,emptyLabel:`No ${n} yet.`,emptyHint:`Click "+" to create your first ${To(n)?No[n]:"item"}.`}):xe.map(pe=>{const Be=A?.collection===pe.kind&&A.key===pe.key;return r.jsx(Qs,{icon:pe.kind==="posts"?Pi:pe.kind==="authors"?ac:b2,title:pe.label,subtitle:pe.subtitle,active:Be,onClick:()=>P({collection:pe.kind,key:pe.key}),menu:r.jsx(so,{onDuplicate:()=>Y(pe),onDelete:()=>Q(pe)})},pe.key)}),e[0]=n,e[1]=c,e[2]=d,e[3]=l,e[4]=s,e[5]=h,e[6]=u,e[7]=I,e[8]=C,e[9]=S,e[10]=V,e[11]=T,e[12]=Q,e[13]=D,e[14]=K,e[15]=z,e[16]=Y,e[17]=R,e[18]=$,e[19]=M,e[20]=k,e[21]=b,e[22]=v,e[23]=_,e[24]=E,e[25]=B,e[26]=m,e[27]=P,e[28]=j,e[29]=w,e[30]=O,e[31]=i,e[32]=g,e[33]=L,e[34]=p,e[35]=x,e[36]=o,e[37]=f,e[38]=a,e[39]=y,e[40]=A,e[41]=q,e[42]=H,e[43]=U,e[44]=X,e[45]=J,e[46]=ee,e[47]=W,e[48]=Z}else q=e[41],H=e[42],U=e[43],X=e[44],J=e[45],ee=e[46],W=e[47],Z=e[48];let G;e[75]!==H||e[76]!==U?(G=r.jsx("div",{className:H,children:U}),e[75]=H,e[76]=U,e[77]=G):G=e[77];let te;e[78]!==q||e[79]!==X||e[80]!==G?(te=r.jsx(q,{className:X,children:G}),e[78]=q,e[79]=X,e[80]=G,e[81]=te):te=e[81];let se;return e[82]!==J||e[83]!==ee||e[84]!==W||e[85]!==Z||e[86]!==te?(se=r.jsxs("div",{className:J,children:[ee,W,Z,te]}),e[82]=J,e[83]=ee,e[84]=W,e[85]=Z,e[86]=te,e[87]=se):se=e[87],se}function h$(t){return t.key}function f$(t){return t.email}function m$(t){return t.slug}function p$(t){return typeof t=="string"?t:""}function g$(t){const e=F.c(13),{virtualMcpId:s}=t,n=oe(),i=ms(s),{activeTask:o}=ls();if(!($s(i?.metadata)||$s(o?.metadata))){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(jn,{size:24,className:"text-muted-foreground/60"}),e[0]=c):c=e[0];let d;e[1]!==n?(d=n("mainPanelTabs.contentTab.noContentToEdit"),e[1]=n,e[2]=d):d=e[2];let h;e[3]!==d?(h=r.jsx("div",{children:d}),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==n?(u=n("mainPanelTabs.contentTab.connectGithubDescription"),e[5]=n,e[6]=u):u=e[6];let f;e[7]!==u?(f=r.jsx("div",{className:"text-xs text-muted-foreground/80",children:u}),e[7]=u,e[8]=f):f=e[8];let m;return e[9]!==h||e[10]!==f?(m=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[c,h,f]}),e[9]=h,e[10]=f,e[11]=m):m=e[11],m}let l;return e[12]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(l$,{}),e[12]=l):l=e[12],l}const vd={fast:{labelKey:"automations.automationConfig.tierFast",subtitleKey:"automations.automationConfig.tierFastSubtitle",icon:n9},smart:{labelKey:"automations.automationConfig.tierSmart",subtitleKey:"automations.automationConfig.tierSmartSubtitle",icon:ei},thinking:{labelKey:"automations.automationConfig.tierThinking",subtitleKey:"automations.automationConfig.tierThinkingSubtitle",icon:o2}},x$=["fast","smart","thinking"];function v$(t){const e=F.c(19),{tier:s,onSelect:n}=t,i=oe(),[o,a]=N.useState(!1),l=vd[s].icon;let c;e[0]!==l?(c=r.jsx(l,{size:14,className:"text-muted-foreground"}),e[0]=l,e[1]=c):c=e[1];const d=vd[s];let h;e[2]!==i||e[3]!==d.labelKey?(h=i(d.labelKey),e[2]=i,e[3]=d.labelKey,e[4]=h):h=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(is,{size:14,className:"text-muted-foreground"}),e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==h?(f=r.jsx(Ts,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[c,h,u]})}),e[6]=c,e[7]=h,e[8]=f):f=e[8];let m;e[9]!==n||e[10]!==i||e[11]!==s?(m=x$.map(x=>{const v=vd[x],b=v.icon;return r.jsxs("button",{type:"button",onClick:()=>{n(x),a(!1)},className:ie("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[r.jsx(b,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-sm",children:i(v.labelKey)}),r.jsx("div",{className:"text-xs text-muted-foreground",children:i(v.subtitleKey)})]}),x===s&&r.jsx(ns,{size:14,className:"text-foreground mt-0.5"})]},x)}),e[9]=n,e[10]=i,e[11]=s,e[12]=m):m=e[12];let p;e[13]!==m?(p=r.jsx(As,{align:"start",className:"p-1 w-64",children:r.jsx("div",{className:"flex flex-col",children:m})}),e[13]=m,e[14]=p):p=e[14];let g;return e[15]!==o||e[16]!==f||e[17]!==p?(g=r.jsxs(Es,{open:o,onOpenChange:a,children:[f,p]}),e[15]=o,e[16]=f,e[17]=p,e[18]=g):g=e[18],g}function b$(t){const e=F.c(27),{tier:s,onTierChange:n,override:i,onOverrideChange:o}=t,a=oe(),[l,c]=N.useState(i!==null);let d;e[0]!==a?(d=a("automations.automationConfig.modelLabel"),e[0]=a,e[1]=d):d=e[1];let h;e[2]!==d?(h=r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:d}),e[2]=d,e[3]=h):h=e[3];let u;e[4]!==o||e[5]!==n||e[6]!==i||e[7]!==a||e[8]!==s||e[9]!==l?(u=l?r.jsx(N.Suspense,{fallback:r.jsx(le,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:a("automations.automationConfig.loadingModels")}),children:r.jsx(y$,{override:i,onOverrideChange:o})}):r.jsx(v$,{tier:s,onSelect:n}),e[4]=o,e[5]=n,e[6]=i,e[7]=a,e[8]=s,e[9]=l,e[10]=u):u=e[10];let f;e[11]!==o?(f=b=>{c(b),b||o(null)},e[11]=o,e[12]=f):f=e[12];let m;e[13]!==f||e[14]!==l?(m=r.jsx(_r,{checked:l,onCheckedChange:f,className:"cursor-pointer"}),e[13]=f,e[14]=l,e[15]=m):m=e[15];let p;e[16]!==a?(p=a("automations.automationConfig.specificModel"),e[16]=a,e[17]=p):p=e[17];let g;e[18]!==m||e[19]!==p?(g=r.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[m,p]}),e[18]=m,e[19]=p,e[20]=g):g=e[20];let x;e[21]!==u||e[22]!==g?(x=r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u,g]}),e[21]=u,e[22]=g,e[23]=x):x=e[23];let v;return e[24]!==h||e[25]!==x?(v=r.jsxs("div",{className:"flex flex-col gap-2",children:[h,x]}),e[24]=h,e[25]=x,e[26]=v):v=e[26],v}function y$(t){const e=F.c(16),{override:s,onOverrideChange:n}=t,i=oe(),o=N2(),a=o[0]?.id??null,[l,c]=N.useState(s?.credentialId??a);let d;e[0]!==s?(d=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=d):d=e[1];const h=d;if(o.length===0){let p;e[2]!==i?(p=i("automations.automationConfig.connectAiProviderHint"),e[2]=i,e[3]=p):p=e[3];let g;return e[4]!==p?(g=r.jsx("span",{className:"text-xs text-muted-foreground italic",children:p}),e[4]=p,e[5]=g):g=e[5],g}let u;e[6]!==i?(u=i("automations.automationConfig.pickModelPlaceholder"),e[6]=i,e[7]=u):u=e[7];let f;e[8]!==l||e[9]!==n?(f=p=>{const g=p.keyId??l??"";c(g),n({modelId:p.modelId,credentialId:g,title:p.title??p.modelId})},e[8]=l,e[9]=n,e[10]=f):f=e[10];let m;return e[11]!==l||e[12]!==h||e[13]!==u||e[14]!==f?(m=r.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:r.jsx(vb,{variant:"bordered",placeholder:u,model:h,credentialId:l,onCredentialChange:c,onModelChange:f})}),e[11]=l,e[12]=h,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}const v5=[{key:"capabilities",headingKey:"automations.automationConfig.builtinCapabilities",icon:N9,tools:[{name:"web_search",titleKey:"automations.automationConfig.toolWebSearch",descriptionKey:"automations.automationConfig.toolWebSearchDesc",icon:pi},{name:"generate_image",titleKey:"automations.automationConfig.toolGenerateImage",descriptionKey:"automations.automationConfig.toolGenerateImageDesc",icon:Dn},{name:"subtask",titleKey:"automations.automationConfig.toolSubtask",descriptionKey:"automations.automationConfig.toolSubtaskDesc",icon:en},{name:"user_ask",titleKey:"automations.automationConfig.toolAskUser",descriptionKey:"automations.automationConfig.toolAskUserDesc",icon:Z6}]},{key:"files",headingKey:"automations.automationConfig.filesCode",icon:ri,tools:[{name:"read",titleKey:"automations.automationConfig.toolReadFile",descriptionKey:"automations.automationConfig.toolReadFileDesc",icon:R2},{name:"write",titleKey:"automations.automationConfig.toolWriteFile",descriptionKey:"automations.automationConfig.toolWriteFileDesc",icon:V9},{name:"edit",titleKey:"automations.automationConfig.toolEditFile",descriptionKey:"automations.automationConfig.toolEditFileDesc",icon:s9},{name:"grep",titleKey:"automations.automationConfig.toolSearchContent",descriptionKey:"automations.automationConfig.toolSearchContentDesc",icon:Ko},{name:"glob",titleKey:"automations.automationConfig.toolFindFiles",descriptionKey:"automations.automationConfig.toolFindFilesDesc",icon:ri},{name:"bash",titleKey:"automations.automationConfig.toolRunCommand",descriptionKey:"automations.automationConfig.toolRunCommandDesc",icon:eb}]},{key:"context",headingKey:"automations.automationConfig.context",icon:hl,tools:[{name:"read_resource",titleKey:"automations.automationConfig.toolReadResource",descriptionKey:"automations.automationConfig.toolReadResourceDesc",icon:hl},{name:"read_prompt",titleKey:"automations.automationConfig.toolReadPrompt",descriptionKey:"automations.automationConfig.toolReadPromptDesc",icon:br},{name:"skill",titleKey:"automations.automationConfig.toolLoadSkill",descriptionKey:"automations.automationConfig.toolLoadSkillDesc",icon:br}]},{key:"browser",headingKey:"automations.automationConfig.browser",icon:xn,tools:[{name:"take_screenshot",titleKey:"automations.automationConfig.toolTakeScreenshot",descriptionKey:"automations.automationConfig.toolTakeScreenshotDesc",icon:sc},{name:"scrape_url",titleKey:"automations.automationConfig.toolScrapeUrl",descriptionKey:"automations.automationConfig.toolScrapeUrlDesc",icon:xn},{name:"inspect_page",titleKey:"automations.automationConfig.toolInspectPage",descriptionKey:"automations.automationConfig.toolInspectPageDesc",icon:ra}]}],_$=v5.flatMap(t=>t.tools.map(e=>e.name));function L$(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function S$(t){const e=F.c(12),{agentId:s,value:n,onChange:i}=t,o=oe();let a;e[0]!==o?(a=o("automations.automationConfig.toolsLabel"),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==a?(l=r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:a}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==s||e[5]!==i||e[6]!==o||e[7]!==n?(c=s?r.jsx(N.Suspense,{fallback:r.jsxs(le,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[r.jsx(N9,{size:14}),o("automations.automationConfig.loadingTools")]}),children:r.jsx(w$,{agentId:s,value:n,onChange:i})}):r.jsx("span",{className:"text-xs text-muted-foreground italic",children:o("automations.automationConfig.pickAgentFirst")}),e[4]=s,e[5]=i,e[6]=o,e[7]=n,e[8]=c):c=e[8];let d;return e[9]!==l||e[10]!==c?(d=r.jsxs("div",{className:"flex flex-col gap-2",children:[l,c]}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function S1(t){const e=F.c(17),{value:s,checked:n,onToggle:i,title:o,description:a,leading:l}=t;let c;e[0]!==n?(c=r.jsx(Pr,{checked:n,className:"pointer-events-none mt-0.5"}),e[0]=n,e[1]=c):c=e[1];let d;e[2]!==l?(d=l&&r.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=d):d=e[3];let h;e[4]!==o?(h=r.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&r.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=r.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==i||e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==s?(m=r.jsxs(ks,{value:s,onSelect:i,className:"items-start gap-2.5 py-2",children:[c,d,f]}),e[11]=i,e[12]=c,e[13]=d,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function w1(t){const e=F.c(27),{conn:s,label:n,icon:i,on:o,total:a,onToggle:l}=t,c=oe(),d=o===a;let h;e[0]!==i||e[1]!==s?(h=s?r.jsx(ln,{icon:s.icon,name:s.title,size:"2xs"}):i?r.jsx(i,{size:14,className:"text-muted-foreground"}):r.jsx(tb,{size:14,className:"text-muted-foreground"}),e[0]=i,e[1]=s,e[2]=h):h=e[2];let u;e[3]!==s?.title||e[4]!==n||e[5]!==c?(u=s?.title??n??c("automations.automationConfig.otherTools"),e[3]=s?.title,e[4]=n,e[5]=c,e[6]=u):u=e[6];let f;e[7]!==u?(f=r.jsx("span",{className:"truncate",children:u}),e[7]=u,e[8]=f):f=e[8];let m;e[9]!==o||e[10]!==a?(m=r.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[9]=o,e[10]=a,e[11]=m):m=e[11];let p;e[12]!==l?(p=_=>{_.stopPropagation(),l()},e[12]=l,e[13]=p):p=e[13];let g;e[14]!==d||e[15]!==c?(g=c(d?"automations.automationConfig.none":"automations.automationConfig.all"),e[14]=d,e[15]=c,e[16]=g):g=e[16];let x;e[17]!==p||e[18]!==g?(x=r.jsx("button",{type:"button",onClick:p,className:"text-[11px] font-medium text-primary hover:underline",children:g}),e[17]=p,e[18]=g,e[19]=x):x=e[19];let v;e[20]!==m||e[21]!==x?(v=r.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[m,x]}),e[20]=m,e[21]=x,e[22]=v):v=e[22];let b;return e[23]!==h||e[24]!==f||e[25]!==v?(b=r.jsxs("div",{className:"flex items-center gap-2",children:[h,f,v]}),e[23]=h,e[24]=f,e[25]=v,e[26]=b):b=e[26],b}function w$(t){const e=F.c(83),{agentId:s,value:n,onChange:i}=t,o=oe(),{org:a}=ze(),[l,c]=N.useState(!1);let d;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(d={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=d):d=e[3];const h=pt(d);let u;e[4]!==h?(u={client:h},e[4]=h,e[5]=u):u=e[5];const{data:f,isLoading:m}=y9(u),p=Mn();let g,x,v,b,_,y,L,w,j,S,k,C,A;if(e[6]!==p||e[7]!==f?.tools||e[8]!==m||e[9]!==i||e[10]!==l||e[11]!==o||e[12]!==n){const E=new Map(p.map(N$)),I=new Map;for(const ue of f?.tools??[]){const ae=gn(ue._meta)??"__other__",me=Nr(ue.name,ae==="__other__"?void 0:ae),xe=ue.title,Se=xe&&xe!==ue.name?xe:L$(me);I.has(ae)||I.set(ae,{clientId:ae,conn:E.get(ae),tools:[]}),I.get(ae).tools.push({name:ue.name,display:Se,description:ue.description})}const D=[...I.values()].sort(V$),M=(f?.tools??[]).map(k$),O=[..._$,...M],$=n===null?new Set(O):new Set(n),B=O.every(ue=>$.has(ue)),z=ue=>i(O.every(ae=>ue.has(ae))?null:[...ue]),K=ue=>{const ae=new Set($);ae.has(ue)?ae.delete(ue):ae.add(ue),z(ae)},Y=(ue,ae)=>{const me=new Set($);for(const xe of ue)ae?me.add(xe):me.delete(xe);z(me)};b=Es,A=l,_=c;let Q;e[26]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(N9,{size:14,className:"text-muted-foreground"}),e[26]=Q):Q=e[26];let q;e[27]!==B||e[28]!==o?(q=o(B?"automations.automationConfig.allTools":"automations.automationConfig.tools"),e[27]=B,e[28]=o,e[29]=q):q=e[29];const H=!B&&r.jsxs(B8,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[$.size,"/",O.length]});let U;e[30]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(is,{size:14,className:"text-muted-foreground"}),e[30]=U):U=e[30],e[31]!==q||e[32]!==H?(y=r.jsx(Ts,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[Q,q,H,U]})}),e[31]=q,e[32]=H,e[33]=y):y=e[33],v=As,k="p-0 w-80",C="start",x=Dr;let X;e[34]!==o?(X=o("automations.automationConfig.searchToolsPlaceholder"),e[34]=o,e[35]=X):X=e[35],e[36]!==X?(j=r.jsx(Hi,{placeholder:X}),e[36]=X,e[37]=j):j=e[37];const J=B?o("automations.automationConfig.allToolsEnabled",{count:O.length}):o("automations.automationConfig.toolsEnabledCount",{enabled:$.size,total:O.length});let ee;e[38]!==J?(ee=r.jsx("span",{className:"text-xs text-muted-foreground",children:J}),e[38]=J,e[39]=ee):ee=e[39];let W;e[40]!==i?(W=()=>i(null),e[40]=i,e[41]=W):W=e[41];let Z;e[42]!==o?(Z=o("automations.automationConfig.selectAll"),e[42]=o,e[43]=Z):Z=e[43];let G;e[44]!==B||e[45]!==W||e[46]!==Z?(G=r.jsx("button",{type:"button",onClick:W,disabled:B,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:Z}),e[44]=B,e[45]=W,e[46]=Z,e[47]=G):G=e[47];let te;e[48]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[48]=te):te=e[48];let se;e[49]!==i?(se=()=>i([]),e[49]=i,e[50]=se):se=e[50];const re=$.size===0;let de;e[51]!==o?(de=o("automations.automationConfig.clear"),e[51]=o,e[52]=de):de=e[52];let ce;e[53]!==se||e[54]!==re||e[55]!==de?(ce=r.jsx("button",{type:"button",onClick:se,disabled:re,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:de}),e[53]=se,e[54]=re,e[55]=de,e[56]=ce):ce=e[56];let fe;e[57]!==G||e[58]!==ce?(fe=r.jsxs("div",{className:"flex items-center gap-2",children:[G,te,ce]}),e[57]=G,e[58]=ce,e[59]=fe):fe=e[59],e[60]!==ee||e[61]!==fe?(S=r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[ee,fe]}),e[60]=ee,e[61]=fe,e[62]=S):S=e[62],g=Wi,L="max-h-80",w=m?r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("automations.automationConfig.loadingTools")}):r.jsxs(r.Fragment,{children:[r.jsx(oi,{children:o("automations.automationConfig.noToolsFound")}),v5.map(ue=>{const ae=ue.tools.map(C$),me=ae.filter(xe=>$.has(xe)).length;return r.jsx(Os,{heading:r.jsx(w1,{label:o(ue.headingKey),icon:ue.icon,on:me,total:ae.length,onToggle:()=>Y(ae,me!==ae.length)}),children:ue.tools.map(xe=>r.jsx(S1,{value:`${o(xe.titleKey)} ${xe.name}`,checked:$.has(xe.name),onToggle:()=>K(xe.name),title:o(xe.titleKey),description:o(xe.descriptionKey),leading:r.jsx(xe.icon,{size:16,className:"text-muted-foreground"})},xe.name))},ue.key)}),D.map(ue=>{const ae=ue.tools.map(j$),me=ae.filter(xe=>$.has(xe)).length;return r.jsx(Os,{heading:r.jsx(w1,{conn:ue.conn,on:me,total:ae.length,onToggle:()=>Y(ae,me!==ae.length)}),children:ue.tools.map(xe=>r.jsx(S1,{value:`${xe.display} ${xe.name} ${ue.conn?.title??""}`,checked:$.has(xe.name),onToggle:()=>K(xe.name),title:xe.display,description:xe.description},xe.name))},ue.clientId)})]}),e[6]=p,e[7]=f?.tools,e[8]=m,e[9]=i,e[10]=l,e[11]=o,e[12]=n,e[13]=g,e[14]=x,e[15]=v,e[16]=b,e[17]=_,e[18]=y,e[19]=L,e[20]=w,e[21]=j,e[22]=S,e[23]=k,e[24]=C,e[25]=A}else g=e[13],x=e[14],v=e[15],b=e[16],_=e[17],y=e[18],L=e[19],w=e[20],j=e[21],S=e[22],k=e[23],C=e[24],A=e[25];let P;e[63]!==g||e[64]!==L||e[65]!==w?(P=r.jsx(g,{className:L,children:w}),e[63]=g,e[64]=L,e[65]=w,e[66]=P):P=e[66];let V;e[67]!==x||e[68]!==P||e[69]!==j||e[70]!==S?(V=r.jsxs(x,{children:[j,S,P]}),e[67]=x,e[68]=P,e[69]=j,e[70]=S,e[71]=V):V=e[71];let T;e[72]!==v||e[73]!==V||e[74]!==k||e[75]!==C?(T=r.jsx(v,{className:k,align:C,children:V}),e[72]=v,e[73]=V,e[74]=k,e[75]=C,e[76]=T):T=e[76];let R;return e[77]!==b||e[78]!==_||e[79]!==y||e[80]!==T||e[81]!==A?(R=r.jsxs(b,{open:A,onOpenChange:_,children:[y,T]}),e[77]=b,e[78]=_,e[79]=y,e[80]=T,e[81]=A,e[82]=R):R=e[82],R}function j$(t){return t.name}function C$(t){return t.name}function k$(t){return t.name}function V$(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function N$(t){return[t.id,t]}function Ro(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function T$(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return`Every ${n[1]} hours`;const i=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(i){const l=parseInt(i[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),c=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${c} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",d=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${c} at ${d}:${h} UTC`}return t}function A$(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function E$(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return{count:parseInt(n[1]),unit:"hours"};const i=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);return i?{count:parseInt(i[1]),unit:"days"}:null}function P$(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const R$=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function D$({automationId:t,open:e,onOpenChange:s,onCustomSelect:n,onEventSelect:i,onWebhookCreated:o}){const a=oe(),{triggerAdd:l}=ha(),[c,d]=N.useState(!1),h=e??c,u=p=>{s?s(p):d(p)},f=async p=>{try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:p}),ve.success(a("automations.addStarterPopover.starterAdded")),u(!1)}catch(g){const x=g instanceof Error?g.message:a("automations.addStarterPopover.failedAddStarter");ve.error(x)}},m=async()=>{try{const p=await l.mutateAsync({automation_id:t,type:"webhook"});u(!1),p.webhook?o?.(p.webhook):ve.success(a("automations.addStarterPopover.webhookStarterAdded"))}catch(p){const g=p instanceof Error?p.message:a("automations.addStarterPopover.failedAddWebhookStarter");ve.error(g)}};return r.jsxs(vs,{open:h,onOpenChange:u,children:[r.jsx(bs,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",children:[r.jsx(_t,{size:14}),a("automations.addStarterPopover.addStarter")]})}),r.jsxs(ys,{align:"end",className:"w-[200px]",children:[r.jsxs(Oo,{children:[r.jsxs($o,{className:"gap-2.5",children:[r.jsx(wo,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.every")]}),r.jsx(Bo,{className:"w-[160px]",children:R$.map(p=>r.jsxs(Je,{className:"gap-2.5",onSelect:()=>f(p.cron),disabled:l.isPending,children:[r.jsx(wo,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.everyUnit",{unit:p.label})]},p.cron))})]}),r.jsxs(Je,{className:"gap-2.5",onSelect:()=>{u(!1),n?.()},children:[r.jsx(wo,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.customCron")]}),r.jsxs(Je,{className:"gap-2.5",onSelect:()=>{u(!1),i?.()},children:[r.jsx(Ii,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.event")]}),r.jsxs(Je,{className:"gap-2.5",onSelect:()=>{m()},disabled:l.isPending,children:[r.jsx(pi,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.webhook")]})]})]})}function b5(t){const e=F.c(39),{open:s,onOpenChange:n,url:i,token:o,title:a,description:l}=t,c=a===void 0?"Webhook ready":a,d=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,h=oe(),[u,f]=N.useState(null),[m,p]=N.useState("curl"),[g,x]=N.useState("header"),v=N.useId();let b;e[0]!==h?(b=async(D,M)=>{try{await navigator.clipboard.writeText(D),f(M),ve.success(h("automations.webhookSecretDialog.copied")),setTimeout(()=>f(null),1500)}catch{ve.error(h("automations.webhookSecretDialog.failedCopy"))}},e[0]=h,e[1]=b):b=e[1];const _=b;let y;e[2]!==g||e[3]!==o||e[4]!==i?(y=i&&o&&g==="url"?`${i.replace(/\/$/,"")}/${o}`:i??"",e[2]=g,e[3]=o,e[4]=i,e[5]=y):y=e[5];const L=y,w=i&&o?g==="header"?`curl -X POST "${L}" \\
457
- -H "Authorization: Bearer ${o}" \\
458
- -H "Content-Type: application/json" \\
459
- -d '{"hello":"world"}'`:`curl -X POST "${L}" \\
460
- -H "Content-Type: application/json" \\
461
- -d '{"hello":"world"}'`:"",j=i&&o?g==="header"?`await fetch("${L}", {
462
- method: "POST",
463
- headers: {
464
- Authorization: "Bearer ${o}",
465
- "Content-Type": "application/json",
466
- },
467
- body: JSON.stringify({ hello: "world" }),
468
- });`:`await fetch("${L}", {
469
- method: "POST",
470
- headers: {
471
- "Content-Type": "application/json",
472
- },
473
- body: JSON.stringify({ hello: "world" }),
474
- });`:"",S=m==="curl"?w:j;let k;e[6]!==c?(k=r.jsx(ds,{children:c}),e[6]=c,e[7]=k):k=e[7];let C;e[8]!==d?(C=r.jsx(On,{children:d}),e[8]=d,e[9]=C):C=e[9];let A;e[10]!==k||e[11]!==C?(A=r.jsxs(cs,{children:[k,C]}),e[10]=k,e[11]=C,e[12]=A):A=e[12];let P;e[13]!==g||e[14]!==u||e[15]!==_||e[16]!==L||e[17]!==m||e[18]!==S||e[19]!==h||e[20]!==o||e[21]!==v||e[22]!==i?(P=i&&o?r.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:h("automations.webhookSecretDialog.url")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:L}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>_(L,"url"),children:[r.jsx(Vs,{size:13}),h(u==="url"?"automations.webhookSecretDialog.copied":"automations.webhookSecretDialog.copy")]})]})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:h("automations.webhookSecretDialog.tokenLabel")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>_(o,"token"),children:[r.jsx(Vs,{size:13}),h(u==="token"?"automations.webhookSecretDialog.copied":"automations.webhookSecretDialog.copy")]})]})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:h("automations.webhookSecretDialog.snippet")}),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Er,{value:m,onValueChange:D=>p(D),children:r.jsxs(oa,{className:"h-8 p-[2px]",children:[r.jsx(vn,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),r.jsx(vn,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),r.jsxs("label",{htmlFor:v,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[r.jsx(Pr,{id:v,checked:g==="url",onCheckedChange:D=>x(D?"url":"header")}),h("automations.webhookSecretDialog.tokenInUrl")]})]}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>_(S,"example"),children:[r.jsx(Vs,{size:13}),h(u==="example"?"automations.webhookSecretDialog.copied":"automations.webhookSecretDialog.copy")]})]}),r.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:r.jsx(ua,{code:S,language:m==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[13]=g,e[14]=u,e[15]=_,e[16]=L,e[17]=m,e[18]=S,e[19]=h,e[20]=o,e[21]=v,e[22]=i,e[23]=P):P=e[23];let V;e[24]!==n?(V=()=>n(!1),e[24]=n,e[25]=V):V=e[25];let T;e[26]!==h?(T=h("automations.webhookSecretDialog.done"),e[26]=h,e[27]=T):T=e[27];let R;e[28]!==T||e[29]!==V?(R=r.jsx(mi,{children:r.jsx(le,{onClick:V,children:T})}),e[28]=T,e[29]=V,e[30]=R):R=e[30];let E;e[31]!==R||e[32]!==A||e[33]!==P?(E=r.jsxs(Yt,{className:"max-w-lg",children:[A,P,R]}),e[31]=R,e[32]=A,e[33]=P,e[34]=E):E=e[34];let I;return e[35]!==n||e[36]!==s||e[37]!==E?(I=r.jsx(Jt,{open:s,onOpenChange:n,children:E}),e[35]=n,e[36]=s,e[37]=E,e[38]=I):I=e[38],I}function I$(t){const e=F.c(137),{trigger:s,automationId:n,connectionName:i}=t,o=oe(),{triggerAdd:a,triggerRemove:l,triggerRotateToken:c}=ha(),[d,h]=N.useState(!1),[u,f]=N.useState(!1),[m,p]=N.useState(null);let g;e[0]!==s.cron_expression?(g=s.cron_expression?E$(s.cron_expression):null,e[0]=s.cron_expression,e[1]=g):g=e[1];const x=g,[v,b]=N.useState(x?.count??1),[_,y]=N.useState(!1),[L,w]=N.useState(s.cron_expression??""),j=l.isPending||a.isPending||c.isPending,S=s.type==="cron",k=s.type==="webhook";let C;e[2]!==n||e[3]!==l||e[4]!==o||e[5]!==s.id?(C=async()=>{try{await l.mutateAsync({trigger_id:s.id,automation_id:n}),ve.success(o("automations.triggerCard.starterRemoved"))}catch{ve.error(o("automations.triggerCard.failedToRemoveStarter"))}h(!1)},e[2]=n,e[3]=l,e[4]=o,e[5]=s.id,e[6]=C):C=e[6];const A=C;let P;e[7]!==a||e[8]!==n||e[9]!==l||e[10]!==s.id?(P=async Re=>{await a.mutateAsync({automation_id:n,type:"cron",cron_expression:Re}),await l.mutateAsync({trigger_id:s.id,automation_id:n})},e[7]=a,e[8]=n,e[9]=l,e[10]=s.id,e[11]=P):P=e[11];const V=P;let T;e[12]!==L||e[13]!==V||e[14]!==o||e[15]!==s.cron_expression?(T=async()=>{const Re=L.trim();if(!Re||!Ro(Re)||Re===s.cron_expression){y(!1),w(s.cron_expression??"");return}try{await V(Re),y(!1)}catch{ve.error(o("automations.triggerCard.failedToUpdateStarter")),w(s.cron_expression??""),y(!1)}},e[12]=L,e[13]=V,e[14]=o,e[15]=s.cron_expression,e[16]=T):T=e[16];const R=T;let E;e[17]!==n||e[18]!==c||e[19]!==s.id?(E=async()=>{f(!1);try{const Re=await c.mutateAsync({trigger_id:s.id,automation_id:n});p({url:Re.url,token:Re.token})}catch(Re){const ke=Re,$e=ke instanceof Error?ke.message:"Failed to rotate token";ve.error($e)}},e[17]=n,e[18]=c,e[19]=s.id,e[20]=E):E=e[20];const I=E;let D;e[21]!==x||e[22]!==V||e[23]!==o||e[24]!==s.cron_expression?(D=async Re=>{if(!x)return;const ke=x.unit==="minutes"?5:1,$e=Math.max(ke,Re);$e!==Re&&b($e);const qe=A$($e,x.unit);if(qe!==s.cron_expression)try{await V(qe)}catch{ve.error(o("automations.triggerCard.failedToUpdateStarter")),b(x.count)}},e[21]=x,e[22]=V,e[23]=o,e[24]=s.cron_expression,e[25]=D):D=e[25];const M=D;let O;e[26]!==S||e[27]!==k?(O=S?r.jsx(wo,{size:14,className:"text-muted-foreground shrink-0"}):k?r.jsx(pi,{size:14,className:"text-muted-foreground shrink-0"}):r.jsx(Ii,{size:14,className:"text-muted-foreground shrink-0"}),e[26]=S,e[27]=k,e[28]=O):O=e[28];let $;e[29]!==i||e[30]!==v||e[31]!==L||e[32]!==M||e[33]!==R||e[34]!==x||e[35]!==S||e[36]!==_||e[37]!==j||e[38]!==k||e[39]!==o||e[40]!==s.cron_expression||e[41]!==s.event_type||e[42]!==s.params?($=x&&S?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-sm text-muted-foreground",children:o("automations.triggerCard.every")}),r.jsx("input",{type:"number",min:x.unit==="minutes"?5:1,value:v,onChange:Re=>b(parseInt(Re.target.value)||1),onBlur:()=>M(v),onKeyDown:Re=>{Re.key==="Enter"&&Re.target.blur(),Re.key==="Escape"&&b(x.count)},disabled:j,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),r.jsx("span",{className:"text-sm",children:P$(x.unit,v)})]}):S&&_?r.jsxs(r.Fragment,{children:[r.jsx("input",{type:"text",value:L,onChange:Re=>w(Re.target.value),onBlur:R,onKeyDown:Re=>{Re.key==="Enter"&&Re.target.blur(),Re.key==="Escape"&&(y(!1),w(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),L&&!Ro(L)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:o("automations.triggerCard.invalid")})]}):r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:S?T$(s.cron_expression??""):k?o("automations.triggerCard.webhookPostToFire"):`${s.event_type}${i?` · ${i}`:""}`}),!S&&!k&&s.params&&Object.keys(s.params).length>0&&r.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(M$).join(", ")})]}),e[29]=i,e[30]=v,e[31]=L,e[32]=M,e[33]=R,e[34]=x,e[35]=S,e[36]=_,e[37]=j,e[38]=k,e[39]=o,e[40]=s.cron_expression,e[41]=s.event_type,e[42]=s.params,e[43]=$):$=e[43];let B;e[44]!==j?(B=j&&r.jsx(Ze,{size:13,className:"animate-spin text-muted-foreground"}),e[44]=j,e[45]=B):B=e[45];let z;e[46]!==x||e[47]!==S||e[48]!==_||e[49]!==s.cron_expression?(z=S&&!x&&!_&&r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{w(s.cron_expression??""),y(!0)},children:r.jsx(V9,{size:13,className:"text-muted-foreground"})}),e[46]=x,e[47]=S,e[48]=_,e[49]=s.cron_expression,e[50]=z):z=e[50];let K;e[51]!==k||e[52]!==o?(K=k&&r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:o("automations.triggerCard.rotateToken"),onClick:()=>f(!0),children:r.jsx(gr,{size:13,className:"text-muted-foreground"})}),e[51]=k,e[52]=o,e[53]=K):K=e[53];let Y;e[54]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:r.jsx(In,{size:13,className:"text-muted-foreground"})}),e[54]=Y):Y=e[54];let Q;e[55]!==z||e[56]!==K||e[57]!==B?(Q=r.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[B,z,K,Y]}),e[55]=z,e[56]=K,e[57]=B,e[58]=Q):Q=e[58];let q;e[59]!==Q||e[60]!==O||e[61]!==$?(q=r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[O,$,Q]}),e[59]=Q,e[60]=O,e[61]=$,e[62]=q):q=e[62];let H;e[63]!==o?(H=o("automations.triggerCard.removeStarter"),e[63]=o,e[64]=H):H=e[64];let U;e[65]!==H?(U=r.jsx(vl,{children:H}),e[65]=H,e[66]=U):U=e[66];let X;e[67]!==o?(X=o("automations.triggerCard.confirmRemoveStarter"),e[67]=o,e[68]=X):X=e[68];let J;e[69]!==X?(J=r.jsx(bl,{children:X}),e[69]=X,e[70]=J):J=e[70];let ee;e[71]!==U||e[72]!==J?(ee=r.jsxs(xl,{children:[U,J]}),e[71]=U,e[72]=J,e[73]=ee):ee=e[73];let W;e[74]!==o?(W=o("automations.triggerCard.cancel"),e[74]=o,e[75]=W):W=e[75];let Z;e[76]!==W?(Z=r.jsx(_l,{children:W}),e[76]=W,e[77]=Z):Z=e[77];let G;e[78]!==o?(G=o("automations.triggerCard.remove"),e[78]=o,e[79]=G):G=e[79];let te;e[80]!==A||e[81]!==G?(te=r.jsx(Ll,{onClick:A,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:G}),e[80]=A,e[81]=G,e[82]=te):te=e[82];let se;e[83]!==Z||e[84]!==te?(se=r.jsxs(yl,{children:[Z,te]}),e[83]=Z,e[84]=te,e[85]=se):se=e[85];let re;e[86]!==ee||e[87]!==se?(re=r.jsxs(gl,{children:[ee,se]}),e[86]=ee,e[87]=se,e[88]=re):re=e[88];let de;e[89]!==d||e[90]!==re?(de=r.jsx(pl,{open:d,onOpenChange:h,children:re}),e[89]=d,e[90]=re,e[91]=de):de=e[91];let ce;e[92]!==o?(ce=o("automations.triggerCard.rotateWebhookToken"),e[92]=o,e[93]=ce):ce=e[93];let fe;e[94]!==ce?(fe=r.jsx(vl,{children:ce}),e[94]=ce,e[95]=fe):fe=e[95];let ue;e[96]!==o?(ue=o("automations.triggerCard.rotateWebhookTokenDescription"),e[96]=o,e[97]=ue):ue=e[97];let ae;e[98]!==ue?(ae=r.jsx(bl,{children:ue}),e[98]=ue,e[99]=ae):ae=e[99];let me;e[100]!==fe||e[101]!==ae?(me=r.jsxs(xl,{children:[fe,ae]}),e[100]=fe,e[101]=ae,e[102]=me):me=e[102];let xe;e[103]!==o?(xe=o("automations.triggerCard.cancel"),e[103]=o,e[104]=xe):xe=e[104];let Se;e[105]!==xe?(Se=r.jsx(_l,{children:xe}),e[105]=xe,e[106]=Se):Se=e[106];let Ve;e[107]!==o?(Ve=o("automations.triggerCard.rotate"),e[107]=o,e[108]=Ve):Ve=e[108];let Ie;e[109]!==I||e[110]!==Ve?(Ie=r.jsx(Ll,{onClick:I,children:Ve}),e[109]=I,e[110]=Ve,e[111]=Ie):Ie=e[111];let Ne;e[112]!==Se||e[113]!==Ie?(Ne=r.jsxs(yl,{children:[Se,Ie]}),e[112]=Se,e[113]=Ie,e[114]=Ne):Ne=e[114];let Ee;e[115]!==me||e[116]!==Ne?(Ee=r.jsxs(gl,{children:[me,Ne]}),e[115]=me,e[116]=Ne,e[117]=Ee):Ee=e[117];let we;e[118]!==u||e[119]!==Ee?(we=r.jsx(pl,{open:u,onOpenChange:f,children:Ee}),e[118]=u,e[119]=Ee,e[120]=we):we=e[120];const Ae=m!==null;let be;e[121]===Symbol.for("react.memo_cache_sentinel")?(be=Re=>{Re||p(null)},e[121]=be):be=e[121];const je=m?.url??null,ge=m?.token??null;let Le;e[122]!==o?(Le=o("automations.triggerCard.newWebhookToken"),e[122]=o,e[123]=Le):Le=e[123];let ye;e[124]!==o?(ye=o("automations.triggerCard.newWebhookTokenDescription"),e[124]=o,e[125]=ye):ye=e[125];let Ce;e[126]!==Ae||e[127]!==je||e[128]!==ge||e[129]!==Le||e[130]!==ye?(Ce=r.jsx(b5,{open:Ae,onOpenChange:be,url:je,token:ge,title:Le,description:ye}),e[126]=Ae,e[127]=je,e[128]=ge,e[129]=Le,e[130]=ye,e[131]=Ce):Ce=e[131];let Me;return e[132]!==q||e[133]!==de||e[134]!==we||e[135]!==Ce?(Me=r.jsxs(r.Fragment,{children:[q,de,we,Ce]}),e[132]=q,e[133]=de,e[134]=we,e[135]=Ce,e[136]=Me):Me=e[136],Me}function M$(t){const[e,s]=t;return`${e}: ${s}`}function O$(t){const e=F.c(70),{automationId:s,onDone:n}=t,i=oe();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={binding:"TRIGGER"},e[0]=o):o=e[0];const a=Mn(o),[l,c]=N.useState(),[d,h]=N.useState();let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={},e[1]=u):u=e[1];const[f,m]=N.useState(u),{triggerAdd:p}=ha(),{data:g,isLoading:x}=F8(l);let v,b,_,y,L,w;if(e[2]!==p||e[3]!==s||e[4]!==l||e[5]!==d||e[6]!==x||e[7]!==n||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==g){const k=g?.find(B=>B.type===d);let C;e[18]!==p||e[19]!==s||e[20]!==l||e[21]!==d||e[22]!==n||e[23]!==f||e[24]!==i?(C=async()=>{if(!(!l||!d))try{await p.mutateAsync({automation_id:s,type:"event",event_type:d,connection_id:l,params:f}),Fe("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:l,event_type:d}),ve.success(i("automations.eventTriggerForm.successAdded")),n()}catch{ve.error(i("automations.eventTriggerForm.errorFailed"))}},e[18]=p,e[19]=s,e[20]=l,e[21]=d,e[22]=n,e[23]=f,e[24]=i,e[25]=C):C=e[25],v=C,b="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(Ii,{size:14,className:"text-muted-foreground shrink-0"}),e[26]=A):A=e[26];let P;e[27]!==i?(P=i("automations.eventTriggerForm.title"),e[27]=i,e[28]=P):P=e[28];let V;e[29]!==P?(V=r.jsx("span",{className:"text-sm font-medium",children:P}),e[29]=P,e[30]=V):V=e[30];let T;e[31]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(In,{size:13}),e[31]=T):T=e[31];let R;e[32]!==n?(R=r.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:n,children:T}),e[32]=n,e[33]=R):R=e[33],e[34]!==V||e[35]!==R?(_=r.jsxs("div",{className:"flex items-center gap-2",children:[A,V,R]}),e[34]=V,e[35]=R,e[36]=_):_=e[36];const E=l??"";let I;e[37]===Symbol.for("react.memo_cache_sentinel")?(I=B=>{c(B),h(void 0),m({})},e[37]=I):I=e[37];let D;e[38]!==i?(D=i("automations.eventTriggerForm.selectConnectionPlaceholder"),e[38]=i,e[39]=D):D=e[39];let M;e[40]!==D?(M=r.jsx($t,{className:"w-full",children:r.jsx(qt,{placeholder:D})}),e[40]=D,e[41]=M):M=e[41];let O;e[42]!==i||e[43]!==a?(O=a.length===0?r.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:i("automations.eventTriggerForm.noConnectionsWithTrigger")}):a.map(F$),e[42]=i,e[43]=a,e[44]=O):O=e[44];let $;e[45]!==O?($=r.jsx(Bt,{children:O}),e[45]=O,e[46]=$):$=e[46],e[47]!==E||e[48]!==M||e[49]!==$?(y=r.jsxs(Ft,{value:E,onValueChange:I,children:[M,$]}),e[47]=E,e[48]=M,e[49]=$,e[50]=y):y=e[50],e[51]!==l||e[52]!==d||e[53]!==x||e[54]!==i||e[55]!==g?(L=l&&r.jsxs(Ft,{value:d??"",onValueChange:B=>{h(B),m({})},children:[r.jsx($t,{className:"w-full",children:x?r.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[r.jsx(Ze,{size:13,className:"animate-spin"}),i("automations.eventTriggerForm.loadingEvents")]}):r.jsx(qt,{placeholder:i("automations.eventTriggerForm.selectEventTypePlaceholder"),children:d??i("automations.eventTriggerForm.selectEventTypePlaceholder")})}),r.jsx(Bt,{children:g?.map(B$)})]}),e[51]=l,e[52]=d,e[53]=x,e[54]=i,e[55]=g,e[56]=L):L=e[56],w=k?.paramsSchema&&Object.keys(k.paramsSchema).length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(k.paramsSchema).map(B=>{const[z,K]=B;return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("label",{className:"text-xs text-muted-foreground",children:[z,K.description&&r.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",K.description]})]}),K.enum?r.jsxs(Ft,{value:f[z]??"",onValueChange:Y=>m(Q=>({...Q,[z]:Y})),children:[r.jsx($t,{className:"w-full",children:r.jsx(qt,{placeholder:i("automations.eventTriggerForm.selectParamPlaceholder",{key:z})})}),r.jsx(Bt,{children:K.enum.map($$)})]}):r.jsx("input",{type:"text",value:f[z]??"",onChange:Y=>m(Q=>({...Q,[z]:Y.target.value})),placeholder:K.description??z,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},z)})}),e[2]=p,e[3]=s,e[4]=l,e[5]=d,e[6]=x,e[7]=n,e[8]=f,e[9]=i,e[10]=a,e[11]=g,e[12]=v,e[13]=b,e[14]=_,e[15]=y,e[16]=L,e[17]=w}else v=e[12],b=e[13],_=e[14],y=e[15],L=e[16],w=e[17];let j;e[57]!==p||e[58]!==l||e[59]!==d||e[60]!==v||e[61]!==i?(j=l&&d&&r.jsx(le,{size:"sm",onClick:v,disabled:p.isPending,children:p.isPending?r.jsx(Ze,{size:13,className:"animate-spin"}):i("automations.eventTriggerForm.addTriggerButton")}),e[57]=p,e[58]=l,e[59]=d,e[60]=v,e[61]=i,e[62]=j):j=e[62];let S;return e[63]!==b||e[64]!==_||e[65]!==y||e[66]!==L||e[67]!==w||e[68]!==j?(S=r.jsxs("div",{className:b,children:[_,y,L,w,j]}),e[63]=b,e[64]=_,e[65]=y,e[66]=L,e[67]=w,e[68]=j,e[69]=S):S=e[69],S}function $$(t){return r.jsx(ut,{value:t,children:t},t)}function B$(t){return r.jsx(ut,{value:t.type,children:r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{children:t.type}),r.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function F$(t){return r.jsx(ut,{value:t.id,children:t.title},t.id)}const z$=30;function K$(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},n=new Set(s.fields);for(const i of e.fields)n.add(i);return{...s,fields:n,saveCount:s.saveCount+1}}case"reset":return null}}function U$({automationId:t,automation:e,onBack:s,onDelete:n}){const i=oe(),o=e.virtual_mcp_id,{org:a}=ze(),{update:l,triggerAdd:c,run:d}=ha(),h=Mn(),u=new Map(h.map(G=>[G.id,G.title])),{openTask:f}=ls(),{openSidePanel:m}=ia(),{sendMessage:p}=Js(),g=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[x,v]=N.useState(g),[b,_]=N.useState(!1),[y,L]=N.useState(!1),[w,j]=N.useState(!1),[S,k]=N.useState(""),[C,A]=N.useState(!1),[P,V]=N.useState(null),[T,R]=N.useState(!1),[E,I]=N.useState(!1),[D,M]=N.useState(!1),O=async()=>{if(T)return;const te=lv(x).filter(se=>se.type==="text").map(se=>se.text).join(`
475
- `);if(te.trim()){R(!0);try{ee(),Fe("automation_improve_clicked",{automation_id:t,agent_id:o,instructions_length:te.length}),m("chat"),await p({tiptapDoc:y3({managerAgentId:Ym.AUTOMATION_MANAGER(a.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:te})})}finally{R(!1)}}},$=e.models?.tier??"smart",B=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,z=Y0({defaultValues:{name:e.name,active:e.active,tier:$,modelOverride:B,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),K=z.watch("active"),[Y,Q]=N.useReducer(K$,null),q=()=>{Y!==null&&(Fe("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(Y.fields),save_count:Y.saveCount,edit_duration_ms:Date.now()-Y.start}),Q({type:"reset"}))},H=async()=>{const G=z.control._formState.dirtyFields,te=Object.keys(G);if(te.length===0&&!D)return!0;const se=z.getValues(),re=z.control._defaultValues;z.reset(se,{keepValues:!0});const de=D;M(!1);const ce={tier:se.tier,...se.modelOverride?{modelId:se.modelOverride.modelId,credentialId:se.modelOverride.credentialId,modelTitle:se.modelOverride.title}:{}},fe={id:t,name:se.name,active:se.active,models:ce,tools:se.tools,maxAgentSteps:se.maxAgentSteps,messages:av(x),temperature:0};try{await l.mutateAsync(fe)}catch{return z.reset(re,{keepValues:!0}),de&&M(!0),!1}const ue=[...te];return de&&ue.push("messages"),Q({type:"accumulate",now:Date.now(),fields:ue}),J(),!0},{schedule:U,flush:X}=wl({save:H}),{schedule:J,flush:ee}=wl({delayMs:3e4,save:async()=>q()});N.useEffect(()=>{const G=z.watch(()=>U());return()=>G.unsubscribe()},[]);const W=G=>{if(v(G),!E){I(!0);return}M(!0),U()},Z=async()=>{Fe("automation_test_clicked",{automation_id:t,agent_id:o});const G=await X();if(ee(),!!G){if(!x){ve.error(i("automations.automationDetail.noInstructionsConfigured"));return}try{const te=await d.mutateAsync(t);te.threadId&&(m("chat"),f(te.threadId))}catch{}}};return r.jsxs(r.Fragment,{children:[s&&r.jsx("div",{className:"flex items-center pb-4 shrink-0",children:r.jsxs(le,{variant:"ghost",size:"sm",onClick:s,children:[r.jsx(tc,{size:14}),i("automations.automationDetail.backToList")]})}),r.jsxs("div",{className:"flex flex-col gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(ss,{control:z.control,name:"name",render:({field:G})=>r.jsx(et,{...G,placeholder:i("automations.automationDetail.automationNamePlaceholder"),className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),n&&r.jsx(le,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:r.jsx(_s,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ss,{control:z.control,name:"active",render:({field:G})=>r.jsx(_r,{checked:G.value,onCheckedChange:te=>{G.onChange(te),X()},className:"cursor-pointer"})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i(K?"automations.automationDetail.active":"automations.automationDetail.inactive")}),r.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),r.jsx(_3,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.starter")}),r.jsx(D$,{automationId:t,open:b,onOpenChange:_,onCustomSelect:()=>{j(!0),A(!1),k("")},onEventSelect:()=>{A(!0),j(!1)},onWebhookCreated:G=>{Fe("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),V(G)}})]}),e.triggers.length===0&&!w?r.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:[i("automations.automationDetail.whenShouldRun")," ",r.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>_(!0),children:i("automations.automationDetail.addStarter")})," ",i("automations.automationDetail.toGetGoing")]})}):r.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(G=>r.jsx(I$,{trigger:G,automationId:t,connectionName:G.connection_id?u.get(G.connection_id):void 0},G.id))}),w&&r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[r.jsx(wo,{size:14,className:"text-muted-foreground shrink-0"}),r.jsx("input",{type:"text",value:S,onChange:G=>k(G.target.value),onBlur:async()=>{const G=S.trim();if(!(!G||!Ro(G)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:G}),Fe("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ve.success(i("automations.automationDetail.starterAdded")),j(!1),k("")}catch{ve.error(i("automations.automationDetail.failedToAddStarter"))}},onKeyDown:async G=>{const te=S.trim();G.key==="Enter"&&te&&Ro(te)&&G.target.blur(),G.key==="Escape"&&(j(!1),k(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),S&&!Ro(S)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:i("automations.automationDetail.invalid")}),c.isPending&&r.jsx(Ze,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),r.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{j(!1),k("")},children:r.jsx(In,{size:13})})]}),C&&r.jsx(N.Suspense,{fallback:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[r.jsx(Ze,{size:13,className:"animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i("automations.automationDetail.loadingConnections")})]}),children:r.jsx(O$,{automationId:t,onDone:()=>A(!1)})}),r.jsx(b5,{open:P!==null,onOpenChange:G=>{G||V(null)},url:P?.url??null,token:P?.token??null})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.instructions")}),r.jsxs(le,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:T||!x,onClick:O,children:[r.jsx(ei,{size:13}),i("automations.automationDetail.improve")]})]}),r.jsx(Pp,{tiptapDoc:x,setTiptapDoc:W,placeholder:i("automations.automationDetail.instructionsPlaceholder"),children:r.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[r.jsx(Rp,{virtualMcpId:o||null,className:"max-h-[45vh]"}),r.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:r.jsxs(We,{children:[r.jsx(Ue,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Z,disabled:!o,children:[r.jsx(X0,{size:16}),i("automations.automationDetail.test")]})}),r.jsx(He,{children:i("automations.automationDetail.testAutomation")})]})})]})})]}),r.jsxs(jv,{open:y,onOpenChange:L,className:"flex flex-col gap-2.5",children:[r.jsxs(Cv,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.advanced")}),r.jsx(is,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),r.jsxs(kv,{className:"flex flex-col gap-5 pt-0.5",children:[r.jsx(b$,{tier:z.watch("tier"),onTierChange:G=>z.setValue("tier",G,{shouldDirty:!0}),override:z.watch("modelOverride"),onOverrideChange:G=>z.setValue("modelOverride",G,{shouldDirty:!0})}),r.jsx(S$,{agentId:o||null,value:z.watch("tools"),onChange:G=>z.setValue("tools",G,{shouldDirty:!0})}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.maxSteps")}),r.jsx(et,{type:"number",min:1,max:100,className:"w-40",placeholder:i("automations.automationDetail.maxStepsPlaceholder",{default:z$}),value:z.watch("maxAgentSteps")??"",onChange:G=>{const te=G.target.value.trim(),se=te===""?null:Number(te);z.setValue("maxAgentSteps",se===null||Number.isNaN(se)?null:se,{shouldDirty:!0})}})]})]})]})]})]})}const y5=[{key:"24h",labelKey:"mainPanelTabs.automationTab.last24hours",ms:1440*60*1e3},{key:"7d",labelKey:"mainPanelTabs.automationTab.last7days",ms:10080*60*1e3},{key:"30d",labelKey:"mainPanelTabs.automationTab.last30days",ms:720*60*60*1e3}];function _5(t){const e=y5.find(n=>n.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function H$(t){const e=F.c(16),{automationId:s,triggerIds:n}=t,i=oe(),[o,a]=N.useState("30d"),[l,c]=N.useState(W$);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=x=>{const v=x;a(v),c(_5(v))},e[0]=d):d=e[0];let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx($t,{className:"w-44",children:r.jsx(qt,{})}),e[1]=h):h=e[1];let u;e[2]!==i?(u=y5.map(x=>r.jsx(ut,{value:x.key,children:i(x.labelKey)},x.key)),e[2]=i,e[3]=u):u=e[3];let f;e[4]!==u?(f=r.jsx(Bt,{children:u}),e[4]=u,e[5]=f):f=e[5];let m;e[6]!==f||e[7]!==o?(m=r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs(Ft,{value:o,onValueChange:d,children:[h,f]})}),e[6]=f,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==l||e[11]!==n?(p=r.jsx(Vv,{automationId:s,triggerIds:n,range:l}),e[9]=s,e[10]=l,e[11]=n,e[12]=p):p=e[12];let g;return e[13]!==m||e[14]!==p?(g=r.jsxs("div",{className:"flex flex-col gap-5",children:[m,p]}),e[13]=m,e[14]=p,e[15]=g):g=e[15],g}function W$(){return _5("30d")}function q$(t){const e=F.c(5),{tabId:s}=t;let n;e[0]!==s?(n=T2(s),e[0]=s,e[1]=n):n=e[1];const i=n;if(!i)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Mi,{}),e[2]=o):o=e[2];let a;return e[3]!==i.id?(a=r.jsx(N.Suspense,{fallback:o,children:r.jsx(G$,{id:i.id})}),e[3]=i.id,e[4]=a):a=e[4],a}function G$(t){const e=F.c(41),{id:s}=t,n=oe(),i=jt(),{data:o,isLoading:a}=z8(s),[l,c]=N.useState("settings");let d;e[0]!==i?(d=()=>{i({to:".",search:J$,replace:!0})},e[0]=i,e[1]=d):d=e[1];const h=d;if(a){let C;return e[2]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Mi,{}),e[2]=C):C=e[2],C}if(!o){let C;e[3]!==n?(C=n("mainPanelTabs.automationTab.automationNotFound"),e[3]=n,e[4]=C):C=e[4];let A;return e[5]!==C?(A=r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:C}),e[5]=C,e[6]=A):A=e[6],A}let u;e[7]!==o.triggers?(u=o.triggers.map(Y$),e[7]=o.triggers,e[8]=u):u=e[8];const f=u;let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(tc,{size:14}),e[9]=m):m=e[9];let p;e[10]!==n?(p=n("mainPanelTabs.automationTab.backToList"),e[10]=n,e[11]=p):p=e[11];let g;e[12]!==h||e[13]!==p?(g=r.jsxs(le,{variant:"ghost",size:"sm",onClick:h,children:[m,p]}),e[12]=h,e[13]=p,e[14]=g):g=e[14];let x;e[15]!==n?(x=n("mainPanelTabs.automationTab.settings"),e[15]=n,e[16]=x):x=e[16];let v;e[17]!==x?(v={id:"settings",label:x},e[17]=x,e[18]=v):v=e[18];let b;e[19]!==n?(b=n("mainPanelTabs.automationTab.runs"),e[19]=n,e[20]=b):b=e[20];let _;e[21]!==b?(_={id:"runs",label:b},e[21]=b,e[22]=_):_=e[22];let y;e[23]!==v||e[24]!==_?(y=[v,_],e[23]=v,e[24]=_,e[25]=y):y=e[25];let L;e[26]===Symbol.for("react.memo_cache_sentinel")?(L=C=>c(C),e[26]=L):L=e[26];let w;e[27]!==y||e[28]!==l?(w=r.jsx(U2,{tabs:y,activeTab:l,onTabChange:L}),e[27]=y,e[28]=l,e[29]=w):w=e[29];let j;e[30]!==w||e[31]!==g?(j=r.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[g,w]}),e[30]=w,e[31]=g,e[32]=j):j=e[32];let S;e[33]!==o||e[34]!==s||e[35]!==l||e[36]!==f?(S=l==="settings"?r.jsx(U$,{automationId:s,automation:o}):r.jsx(H$,{automationId:s,triggerIds:f}),e[33]=o,e[34]=s,e[35]=l,e[36]=f,e[37]=S):S=e[37];let k;return e[38]!==j||e[39]!==S?(k=r.jsx(tn,{children:r.jsx(tn.Content,{children:r.jsxs(tn.Body,{children:[j,S]})})}),e[38]=j,e[39]=S,e[40]=k):k=e[40],k}function Y$(t){return t.id}function J$(t){return{...t,main:"automations"}}function X$(t){const e=F.c(29),{virtualMcpId:s}=t,n=oe(),i=jt(),{data:o}=K8(s),a=o===void 0?[]:o,{create:l}=ha(),[c,d]=N.useState(""),h=c.toLowerCase(),u=a.filter(E=>E.name.toLowerCase().includes(h));let f;e[0]!==i?(f=E=>i({to:".",search:I=>({...I,main:"automation:"+E}),replace:!0}),e[0]=i,e[1]=f):f=e[1];const m=f,p=async()=>{if(l.isPending)return;Fe("automation_new_clicked",{virtual_mcp_id:s,existing_count:a.length});const E=await l.mutateAsync(U8(s));m(E.id)},g=l.isPending;let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(_t,{size:14}),e[2]=x):x=e[2];let v;e[3]!==n?(v=n("automations.automationsList.newAutomation"),e[3]=n,e[4]=v):v=e[4];let b;e[5]!==l.isPending||e[6]!==p||e[7]!==v?(b=r.jsxs(le,{size:"sm",onClick:p,disabled:g,children:[x,v]}),e[5]=l.isPending,e[6]=p,e[7]=v,e[8]=b):b=e[8];const _=b,y=tn,L=tn,w=tn;let j;e[9]!==n?(j=n("automations.automationsList.title"),e[9]=n,e[10]=j):j=e[10];let S;e[11]!==j?(S=r.jsx(tn.Title,{children:j}),e[11]=j,e[12]=S):S=e[12];const k=a.length>0&&r.jsx(L9,{value:c,onChange:d,placeholder:n("automations.automationsList.searchPlaceholder"),className:"w-full md:w-[375px]"});let C;e[13]!==_||e[14]!==k?(C=r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[k,_]}),e[13]=_,e[14]=k,e[15]=C):C=e[15];let A;e[16]!==S||e[17]!==C?(A=r.jsxs("div",{className:"flex flex-col gap-6",children:[S,C]}),e[16]=S,e[17]=C,e[18]=A):A=e[18];const P=a.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Ei,{image:r.jsx(Ii,{size:48,className:"text-muted-foreground"}),title:n("automations.automationsList.emptyTitle"),description:n("automations.automationsList.emptyDescription"),actions:_})}):u.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Ei,{image:r.jsx(Ii,{size:48,className:"text-muted-foreground"}),title:n("automations.automationsList.noResultsTitle"),description:n("automations.automationsList.noResultsDescription",{search:c})})}):r.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(E=>r.jsx(H8,{automation:E,onClick:()=>m(E.id)},E.id))});let V;e[19]!==A||e[20]!==P||e[21]!==w.Body?(V=r.jsxs(w.Body,{children:[A,P]}),e[19]=A,e[20]=P,e[21]=w.Body,e[22]=V):V=e[22];let T;e[23]!==V||e[24]!==L.Content?(T=r.jsx(L.Content,{children:V}),e[23]=V,e[24]=L.Content,e[25]=T):T=e[25];let R;return e[26]!==y||e[27]!==T?(R=r.jsx(y,{children:T}),e[26]=y,e[27]=T,e[28]=R):R=e[28],R}function Q$(t){const e=F.c(3),{virtualMcpId:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Mi,{}),e[0]=n):n=e[0];let i;return e[1]!==s?(i=r.jsx(N.Suspense,{fallback:n,children:r.jsx(X$,{virtualMcpId:s})}),e[1]=s,e[2]=i):i=e[2],i}function Z$(t){const e=F.c(49),{file:s,onClose:n}=t,i=oe();let o,a;e[0]!==s.filename?(o=r.jsx(yr,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),a=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=o,e[2]=a):(o=e[1],a=e[2]);let l;e[3]!==s.size?(l=Eb(s.size),e[3]=s.size,e[4]=l):l=e[4];let c;e[5]!==l?(c=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=c):c=e[6];let d;e[7]!==o||e[8]!==a||e[9]!==c?(d=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[o,a,c]}),e[7]=o,e[8]=a,e[9]=c,e[10]=d):d=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(a8,{size:14}),e[11]=h):h=e[11];let u;e[12]!==s.downloadUrl||e[13]!==s.filename?(u=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",asChild:!0,children:r.jsx("a",{href:s.downloadUrl,download:s.filename,children:h})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=u):u=e[14];let f;e[15]!==i?(f=i("mainPanelTabs.fileTab.download"),e[15]=i,e[16]=f):f=e[16];let m;e[17]!==f?(m=r.jsx(He,{side:"bottom",children:f}),e[17]=f,e[18]=m):m=e[18];let p;e[19]!==u||e[20]!==m?(p=r.jsxs(We,{children:[u,m]}),e[19]=u,e[20]=m,e[21]=p):p=e[21];let g;e[22]!==s.downloadUrl?(g=()=>window.open(s.downloadUrl,"_blank","noopener"),e[22]=s.downloadUrl,e[23]=g):g=e[23];let x;e[24]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx($n,{size:14}),e[24]=x):x=e[24];let v;e[25]!==g?(v=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:g,children:x})}),e[25]=g,e[26]=v):v=e[26];let b;e[27]!==i?(b=i("mainPanelTabs.fileTab.openInNewTab"),e[27]=i,e[28]=b):b=e[28];let _;e[29]!==b?(_=r.jsx(He,{side:"bottom",children:b}),e[29]=b,e[30]=_):_=e[30];let y;e[31]!==v||e[32]!==_?(y=r.jsxs(We,{children:[v,_]}),e[31]=v,e[32]=_,e[33]=y):y=e[33];let L;e[34]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(In,{size:14}),e[34]=L):L=e[34];let w;e[35]!==n?(w=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:n,children:L})}),e[35]=n,e[36]=w):w=e[36];let j;e[37]!==i?(j=i("mainPanelTabs.fileTab.close"),e[37]=i,e[38]=j):j=e[38];let S;e[39]!==j?(S=r.jsx(He,{side:"bottom",children:j}),e[39]=j,e[40]=S):S=e[40];let k;e[41]!==w||e[42]!==S?(k=r.jsxs(We,{children:[w,S]}),e[41]=w,e[42]=S,e[43]=k):k=e[43];let C;return e[44]!==p||e[45]!==y||e[46]!==k||e[47]!==d?(C=r.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[d,p,y,k]}),e[44]=p,e[45]=y,e[46]=k,e[47]=d,e[48]=C):C=e[48],C}function eB(t){const e=F.c(31),{fileKey:s,taskId:n}=t,i=oe(),o=jt(),{data:a,isPending:l}=Um(n);let c;e[0]!==s||e[1]!==a?(c=a?.find(g=>g.key===s)??null,e[0]=s,e[1]=a,e[2]=c):c=e[2];const d=c;let h;e[3]!==o?(h=()=>o({to:".",search:tB,replace:!0}),e[3]=o,e[4]=h):h=e[4];const u=h;if(!d){if(l){let w;return e[5]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("div",{className:"h-full w-full bg-background",children:r.jsx(Tb,{})}),e[5]=w):w=e[5],w}let g;e[6]!==s?(g=s.split("/").pop()??s,e[6]=s,e[7]=g):g=e[7];let x;e[8]!==g?(x=r.jsx(yr,{filename:g,className:"h-7.5 w-6"}),e[8]=g,e[9]=x):x=e[9];let v;e[10]!==i?(v=i("mainPanelTabs.fileTab.fileNotAvailable"),e[10]=i,e[11]=v):v=e[11];let b;e[12]!==v?(b=r.jsx("span",{className:"text-sm text-muted-foreground",children:v}),e[12]=v,e[13]=b):b=e[13];let _;e[14]!==i?(_=i("mainPanelTabs.fileTab.close"),e[14]=i,e[15]=_):_=e[15];let y;e[16]!==u||e[17]!==_?(y=r.jsx(le,{variant:"ghost",size:"sm",onClick:u,children:_}),e[16]=u,e[17]=_,e[18]=y):y=e[18];let L;return e[19]!==x||e[20]!==b||e[21]!==y?(L=r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[x,b,y]}),e[19]=x,e[20]=b,e[21]=y,e[22]=L):L=e[22],L}let f;e[23]!==d||e[24]!==u?(f=r.jsx(Z$,{file:d,onClose:u}),e[23]=d,e[24]=u,e[25]=f):f=e[25];let m;e[26]!==d?(m=r.jsx("div",{className:"relative min-h-0 flex-1",children:r.jsx(Ab,{file:d})}),e[26]=d,e[27]=m):m=e[27];let p;return e[28]!==f||e[29]!==m?(p=r.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[f,m]}),e[28]=f,e[29]=m,e[30]=p):p=e[30],p}function tB(t){return{...t,main:0}}const bd="home";function sB(t){const e=F.c(5),{label:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Et,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=n):n=e[0];let i;e[1]!==s?(i=s&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=i):i=e[2];let o;return e[3]!==i?(o=r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[n,i]}),e[3]=i,e[4]=o):o=e[4],o}function nB(t){const e=F.c(15),{path:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={refetchIntervalWhenAbsent:2e3},e[0]=n):n=e[0];const i=Pb(bd,s,n),o=Rb(bd)(s);if(i.isPending||!i.data){const f=!i.isPending&&!i.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=r.jsx(sB,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==i.data?(a=Db(i.data),e[3]=i.data,e[4]=a):a=e[4];const l=i.data.shareMode??"private",c=i.data.effectivePublic??!1,d=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==d?(h=r.jsx(Ib,{volume:bd,path:s,shareMode:l,effectivePublic:c,url:d}),e[5]=s,e[6]=l,e[7]=c,e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=r.jsx(Mb,{readUrl:o,marker:a,title:s,savePath:s,trailing:h}),e[10]=s,e[11]=o,e[12]=a,e[13]=h,e[14]=u):u=e[14],u}function iB(t){const e=F.c(5),{path:s}=t,n=jt();let i;e[0]!==n?(i=()=>n({to:".",search:rB,replace:!0}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==o||e[3]!==s?(a=r.jsx(Ob,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function rB(t){return{...t,main:0}}function oB(){const t=F.c(12),e=jt(),[s,n]=N.useState(null),[i,o]=N.useState(null);let a;t[0]!==e?(a=f=>e({to:".",search:m=>({...m,main:f}),replace:!0}),t[0]=e,t[1]=a):a=t[1];const l=a;let c;t[2]!==l?(c=r.jsx($b,{onOpenFile:f=>l(Xb(f)),onOpenSkill:n,onOpenBrand:o}),t[2]=l,t[3]=c):c=t[3];let d;t[4]!==s?(d=s&&r.jsx(Bb,{skillPath:s,onClose:()=>n(null)},s),t[4]=s,t[5]=d):d=t[5];let h;t[6]!==i?(h=i&&r.jsx(Fb,{brandPath:i,onClose:()=>o(null)},i),t[6]=i,t[7]=h):h=t[7];let u;return t[8]!==c||t[9]!==d||t[10]!==h?(u=r.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[c,d,h]}),t[8]=c,t[9]=d,t[10]=h,t[11]=u):u=t[11],u}const j1=N.lazy(()=>Ns(()=>import("./project-app-view-B-ZNnyXW.js"),__vite__mapDeps([175,1,2,53,54,55,17,3,19,56,57,58,59,60,61,62,63,32,64,51,65,66,67,68,69,5,16,20,4,6,7,8,9,10,11,12,13,14,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,52,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,114,108,109,110,111,112,113,115,116,117,118,119,104,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,106,156,157,158,159])).then(t=>({default:t.AppViewContent})));function aB(t){const e=F.c(60),{activeTab:s,virtualMcpId:n,taskId:i,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(s==="overview"){let L;return e[0]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(PT,{}),e[0]=L):L=e[0],L}if(s==="board"){let L;return e[1]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:r.jsx(y6,{})}),e[1]=L):L=e[1],L}if(Qb(s)){let L;return e[2]!==n?(L=r.jsx(Zh,{virtualMcpId:n}),e[2]=n,e[3]=L):L=e[3],L}if(s==="git"){let L;return e[4]!==n?(L=r.jsx(OA,{virtualMcpId:n}),e[4]=n,e[5]=L):L=e[5],L}if(s==="automations"){let L;return e[6]!==n?(L=r.jsx(Q$,{virtualMcpId:n}),e[6]=n,e[7]=L):L=e[7],L}if(s==="preview"){let L;return e[8]!==n?(L=r.jsx(hR,{virtualMcpId:n}),e[8]=n,e[9]=L):L=e[9],L}let c;e[10]!==s?(c=Zb(s),e[10]=s,e[11]=c):c=e[11];const d=c;if(d){let L;return e[12]!==d.path?(L=r.jsx(gR,{openPath:d.path}),e[12]=d.path,e[13]=L):L=e[13],L}if(s==="content"){let L;return e[14]!==n?(L=r.jsx(g$,{virtualMcpId:n}),e[14]=n,e[15]=L):L=e[15],L}if(s==="files"){let L;return e[16]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(oB,{}),e[16]=L):L=e[16],L}if(l){let L;return e[17]!==s?(L=r.jsx(q$,{tabId:s}),e[17]=s,e[18]=L):L=e[18],L}let h;e[19]!==s?(h=E2(s),e[19]=s,e[20]=h):h=e[20];const u=h;if(u){let L;return e[21]!==u.path?(L=r.jsx(nB,{path:u.path},u.path),e[21]=u.path,e[22]=L):L=e[22],L}let f;e[23]!==s?(f=A2(s),e[23]=s,e[24]=f):f=e[24];const m=f;if(m){let L;return e[25]!==m.key||e[26]!==i?(L=r.jsx(eB,{fileKey:m.key,taskId:i}),e[25]=m.key,e[26]=i,e[27]=L):L=e[27],L}let p;e[28]!==s?(p=P2(s),e[28]=s,e[29]=p):p=e[29];const g=p;if(g){let L;return e[30]!==g.path?(L=r.jsx(iB,{path:g.path},g.path),e[30]=g.path,e[31]=L):L=e[31],L}let x;e[32]!==s?(x=e8(s),e[32]=s,e[33]=x):x=e[33];const v=x;if(v){let L;if(e[34]!==a||e[35]!==v.connectionId||e[36]!==v.toolName){let C;e[38]!==v.connectionId||e[39]!==v.toolName?(C=A=>A.appId===v.connectionId&&A.toolName===v.toolName,e[38]=v.connectionId,e[39]=v.toolName,e[40]=C):C=e[40],L=a.find(C),e[34]=a,e[35]=v.connectionId,e[36]=v.toolName,e[37]=L}else L=e[37];const w=L;let j;e[41]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Mi,{}),e[41]=j):j=e[41];const S=w?.args;let k;return e[42]!==s||e[43]!==v.connectionId||e[44]!==v.toolName||e[45]!==S?(k=r.jsx(N.Suspense,{fallback:j,children:r.jsx(j1,{connectionId:v.connectionId,toolName:v.toolName,args:S},s)}),e[42]=s,e[43]=v.connectionId,e[44]=v.toolName,e[45]=S,e[46]=k):k=e[46],k}let b;if(e[47]!==s||e[48]!==o){let L;e[50]!==s?(L=w=>w.id===s,e[50]=s,e[51]=L):L=e[51],b=o.find(L),e[47]=s,e[48]=o,e[49]=b}else b=e[49];const _=b;if(_){let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Mi,{}),e[52]=L):L=e[52];let w;return e[53]!==s||e[54]!==_.id||e[55]!==_.view.appId||e[56]!==_.view.args?(w=r.jsx(N.Suspense,{fallback:L,children:r.jsx(j1,{connectionId:_.view.appId,toolName:_.id,args:_.view.args},s)}),e[53]=s,e[54]=_.id,e[55]=_.view.appId,e[56]=_.view.args,e[57]=w):w=e[57],w}let y;return e[58]!==n?(y=r.jsx(Zh,{virtualMcpId:n}),e[58]=n,e[59]=y):y=e[59],y}function lB(t){const e=F.c(14),{taskId:s,virtualMcpId:n}=t;let i;e[0]!==s||e[1]!==n?(i={virtualMcpId:n,taskId:s},e[0]=s,e[1]=n,e[2]=i):i=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=J9(i);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Mi,{}),e[3]=d):d=e[3];let h;e[4]!==o||e[5]!==c||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==n?(h=r.jsx(N.Suspense,{fallback:d,children:r.jsx(aB,{activeTab:o,virtualMcpId:n,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:c})}),e[4]=o,e[5]=c,e[6]=l,e[7]=a,e[8]=s,e[9]=n,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=r.jsx(hs,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const ki="setup";function cB(t){const e=F.c(57),s=oe();let n;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let y;e[3]!==t.scriptTabs?(y=L=>!t.scriptTabs.includes(L),e[3]=t.scriptTabs,e[4]=y):y=e[4],n=t.scripts.filter(y),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=n}else n=e[2];const i=n;let o;e[5]!==t?(o=()=>{t.active===ki?t.onToggle():t.onSelectTab(ki)},e[5]=t,e[6]=o):o=e[6];const a=o;let l;e[7]!==t.open||e[8]!==s?(l=t.open?s("sandbox.preview.collapseTerminal"):s("sandbox.preview.expandTerminal"),e[7]=t.open,e[8]=s,e[9]=l):l=e[9];let c;e[10]!==t.open?(c=t.open?r.jsx(is,{className:"size-4"}):r.jsx(W8,{className:"size-4"}),e[10]=t.open,e[11]=c):c=e[11];let d;e[12]!==t.onToggle||e[13]!==t.open||e[14]!==l||e[15]!==c?(d=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon-sm",onClick:t.onToggle,"aria-label":l,"aria-expanded":t.open,className:"size-6 shrink-0",children:c})}),e[12]=t.onToggle,e[13]=t.open,e[14]=l,e[15]=c,e[16]=d):d=e[16];let h;e[17]!==t.open||e[18]!==s?(h=t.open?s("sandbox.preview.collapseTerminal"):s("sandbox.preview.expandTerminal"),e[17]=t.open,e[18]=s,e[19]=h):h=e[19];let u;e[20]!==h?(u=r.jsx(He,{children:h}),e[20]=h,e[21]=u):u=e[21];let f;e[22]!==d||e[23]!==u?(f=r.jsxs(We,{children:[d,u]}),e[22]=d,e[23]=u,e[24]=f):f=e[24];const m=t.active===ki;let p;e[25]!==a||e[26]!==t.open||e[27]!==s||e[28]!==m?(p=r.jsx(dB,{active:m,open:t.open,onClick:a,t:s}),e[25]=a,e[26]=t.open,e[27]=s,e[28]=m,e[29]=p):p=e[29];let g;e[30]!==t||e[31]!==s?(g=t.scriptTabs.map(y=>r.jsx(hB,{active:t.active===y,onClick:()=>{t.active===y?t.onToggle():t.onSelectTab(y)},onClose:()=>t.onCloseScript(y),t:s,children:y},y)),e[30]=t,e[31]=s,e[32]=g):g=e[32];let x;e[33]!==i||e[34]!==t.onAddScript?(x=r.jsx(fB,{scripts:i,onRun:t.onAddScript}),e[33]=i,e[34]=t.onAddScript,e[35]=x):x=e[35];let v;e[36]!==g||e[37]!==x||e[38]!==p?(v=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[p,g,x]}),e[36]=g,e[37]=x,e[38]=p,e[39]=v):v=e[39];let b;e[40]!==t.onRestart||e[41]!==t.onResume||e[42]!==t.onRetry||e[43]!==t.onRunActiveScript||e[44]!==t.onStart||e[45]!==t.onStop||e[46]!==t.onStopActiveScript||e[47]!==t.scriptIsKilling||e[48]!==t.scriptIsRunning||e[49]!==t.showScriptControls||e[50]!==t.status||e[51]!==s?(b=t.showScriptControls?r.jsx(mB,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript,t:s}):r.jsx(uB,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry,t:s}),e[40]=t.onRestart,e[41]=t.onResume,e[42]=t.onRetry,e[43]=t.onRunActiveScript,e[44]=t.onStart,e[45]=t.onStop,e[46]=t.onStopActiveScript,e[47]=t.scriptIsKilling,e[48]=t.scriptIsRunning,e[49]=t.showScriptControls,e[50]=t.status,e[51]=s,e[52]=b):b=e[52];let _;return e[53]!==v||e[54]!==b||e[55]!==f?(_=r.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-2",children:[f,v,b]}),e[53]=v,e[54]=b,e[55]=f,e[56]=_):_=e[56],_}function dB(t){const e=F.c(11),{active:s,open:n,onClick:i,t:o}=t,a=s&&n,l=s&&n,c=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let d;e[0]!==c?(d=ie("flex h-6 items-center gap-1.5 rounded-md border px-2 text-xs",c),e[0]=c,e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(x2,{className:"size-4"}),e[2]=h):h=e[2];let u;e[3]!==o?(u=o("sandbox.toolbar.setupTab"),e[3]=o,e[4]=u):u=e[4];let f;return e[5]!==i||e[6]!==a||e[7]!==l||e[8]!==d||e[9]!==u?(f=r.jsxs("button",{type:"button","aria-pressed":a,"aria-expanded":l,onClick:i,className:d,children:[h,u]}),e[5]=i,e[6]=a,e[7]=l,e[8]=d,e[9]=u,e[10]=f):f=e[10],f}function uB(t){const e=F.c(40),{status:s,onStart:n,onStop:i,onRestart:o,onResume:a,onRetry:l,t:c}=t;if(s==="idle"&&n){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Di,{className:"size-3.5"}),e[0]=d):d=e[0];let h;e[1]!==c?(h=c("sandbox.toolbar.start"),e[1]=c,e[2]=h):h=e[2];let u;return e[3]!==n||e[4]!==h?(u=r.jsxs(le,{variant:"outline",size:"xs",onClick:n,children:[d," ",h]}),e[3]=n,e[4]=h,e[5]=u):u=e[5],u}if(s==="suspended"&&a){let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Di,{className:"size-3.5"}),e[6]=d):d=e[6];let h;e[7]!==c?(h=c("sandbox.toolbar.resume"),e[7]=c,e[8]=h):h=e[8];let u;return e[9]!==a||e[10]!==h?(u=r.jsxs(le,{variant:"outline",size:"xs",onClick:a,children:[d," ",h]}),e[9]=a,e[10]=h,e[11]=u):u=e[11],u}if(s==="errored"&&l){let d;e[12]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(gr,{className:"size-3.5"}),e[12]=d):d=e[12];let h;e[13]!==c?(h=c("sandbox.toolbar.retry"),e[13]=c,e[14]=h):h=e[14];let u;return e[15]!==l||e[16]!==h?(u=r.jsxs(le,{variant:"outline",size:"xs",onClick:l,children:[d," ",h]}),e[15]=l,e[16]=h,e[17]=u):u=e[17],u}if(s==="starting"||s==="running"){const d=s==="running"&&!!o,h=d?"rounded-r-none border-r-0":void 0;let u;e[18]!==h?(u=ie(h),e[18]=h,e[19]=u):u=e[19];let f;e[20]!==c?(f=c("sandbox.toolbar.stop"),e[20]=c,e[21]=f):f=e[21];let m;e[22]!==i||e[23]!==u||e[24]!==f?(m=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"outline",size:"xs",onClick:i,className:u,children:f})}),e[22]=i,e[23]=u,e[24]=f,e[25]=m):m=e[25];let p;e[26]!==c?(p=c("sandbox.toolbar.stopSandboxTooltip"),e[26]=c,e[27]=p):p=e[27];let g;e[28]!==p?(g=r.jsx(He,{children:p}),e[28]=p,e[29]=g):g=e[29];let x;e[30]!==m||e[31]!==g?(x=r.jsxs(We,{children:[m,g]}),e[30]=m,e[31]=g,e[32]=x):x=e[32];let v;e[33]!==o||e[34]!==d||e[35]!==c?(v=d&&r.jsxs(vs,{children:[r.jsx(bs,{asChild:!0,children:r.jsx(le,{variant:"outline",size:"xs",className:"rounded-l-none px-1",children:r.jsx(is,{className:"size-3"})})}),r.jsx(ys,{align:"end",children:r.jsxs(Je,{onClick:o,children:[r.jsx(gr,{className:"size-3.5"})," ",c("sandbox.toolbar.restart")]})})]}),e[33]=o,e[34]=d,e[35]=c,e[36]=v):v=e[36];let b;return e[37]!==x||e[38]!==v?(b=r.jsxs("div",{className:"flex items-center",children:[x,v]}),e[37]=x,e[38]=v,e[39]=b):b=e[39],b}return null}function hB(t){const e=F.c(17),{active:s,onClick:n,onClose:i,children:o,t:a}=t,l=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let c;e[0]!==l?(c=ie("flex h-6 items-center rounded-md border text-xs",l),e[0]=l,e[1]=c):c=e[1];const d=i?"pl-2 pr-1":"px-2",h=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let u;e[2]!==d||e[3]!==h?(u=ie("flex h-full items-center",d,h),e[2]=d,e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==n||e[7]!==u?(f=r.jsx("button",{type:"button",onClick:n,className:u,children:o}),e[5]=o,e[6]=n,e[7]=u,e[8]=f):f=e[8];let m;e[9]!==o||e[10]!==i||e[11]!==a?(m=i&&r.jsx("button",{type:"button","aria-label":a("sandbox.toolbar.closeTab",{tab:String(o)}),onClick:i,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:r.jsx(an,{className:"size-3.5"})}),e[9]=o,e[10]=i,e[11]=a,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==f||e[15]!==m?(p=r.jsxs("div",{className:c,children:[f,m]}),e[13]=c,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function fB(t){const e=F.c(27),{scripts:s,onRun:n}=t,i=oe(),[o,a]=N.useState(!1);let l;e[0]!==i?(l=i("sandbox.toolbar.runScript"),e[0]=i,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(_t,{className:"size-4"}),e[2]=c):c=e[2];let d;e[3]!==l?(d=r.jsx(Ue,{asChild:!0,children:r.jsx(Ts,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"xs","aria-label":l,children:c})})}),e[3]=l,e[4]=d):d=e[4];let h;e[5]!==i?(h=i("sandbox.toolbar.runScript"),e[5]=i,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx(He,{children:h}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==d||e[10]!==u?(f=r.jsxs(We,{children:[d,u]}),e[9]=d,e[10]=u,e[11]=f):f=e[11];let m;e[12]!==i?(m=i("sandbox.toolbar.runAScript"),e[12]=i,e[13]=m):m=e[13];let p;e[14]!==m?(p=r.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:m}),e[14]=m,e[15]=p):p=e[15];let g;e[16]!==n||e[17]!==s||e[18]!==i?(g=s.length===0?r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:i("sandbox.toolbar.noScriptsFound")}):s.map(b=>r.jsxs("button",{type:"button",onClick:()=>{a(!1),n(b)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",b]},b)),e[16]=n,e[17]=s,e[18]=i,e[19]=g):g=e[19];let x;e[20]!==p||e[21]!==g?(x=r.jsxs(As,{align:"start",className:"p-1 w-56",children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22];let v;return e[23]!==o||e[24]!==x||e[25]!==f?(v=r.jsxs(Es,{open:o,onOpenChange:a,children:[f,x]}),e[23]=o,e[24]=x,e[25]=f,e[26]=v):v=e[26],v}function mB(t){const e=F.c(30),{isRunning:s,isKilling:n,onRun:i,onStop:o,t:a}=t;if(n){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Ze,{className:"size-3.5 animate-spin"}),e[0]=f):f=e[0];let m;e[1]!==a?(m=a("sandbox.toolbar.stopping"),e[1]=a,e[2]=m):m=e[2];let p;return e[3]!==m?(p=r.jsxs(le,{variant:"outline",size:"xs",disabled:!0,children:[f," ",m]}),e[3]=m,e[4]=p):p=e[4],p}if(!s){let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Di,{className:"size-3.5"}),e[5]=f):f=e[5];let m;e[6]!==a?(m=a("sandbox.toolbar.run"),e[6]=a,e[7]=m):m=e[7];let p;e[8]!==i||e[9]!==m?(p=r.jsx(Ue,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"xs",onClick:i,children:[f," ",m]})}),e[8]=i,e[9]=m,e[10]=p):p=e[10];let g;e[11]!==a?(g=a("sandbox.toolbar.startProcess"),e[11]=a,e[12]=g):g=e[12];let x;e[13]!==g?(x=r.jsx(He,{children:g}),e[13]=g,e[14]=x):x=e[14];let v;return e[15]!==p||e[16]!==x?(v=r.jsxs(We,{children:[p,x]}),e[15]=p,e[16]=x,e[17]=v):v=e[17],v}let l;e[18]!==a?(l=a("sandbox.toolbar.stop"),e[18]=a,e[19]=l):l=e[19];let c;e[20]!==o||e[21]!==l?(c=r.jsx(Ue,{asChild:!0,children:r.jsx(le,{variant:"outline",size:"xs",onClick:o,children:l})}),e[20]=o,e[21]=l,e[22]=c):c=e[22];let d;e[23]!==a?(d=a("sandbox.toolbar.stopProcess"),e[23]=a,e[24]=d):d=e[24];let h;e[25]!==d?(h=r.jsx(He,{children:d}),e[25]=d,e[26]=h):h=e[26];let u;return e[27]!==c||e[28]!==h?(u=r.jsxs(We,{children:[c,h]}),e[27]=c,e[28]=h,e[29]=u):u=e[29],u}var L5=Object.defineProperty,pB=Object.getOwnPropertyDescriptor,gB=(t,e)=>{for(var s in e)L5(t,s,{get:e[s],enumerable:!0})},Rt=(t,e,s,n)=>{for(var i=n>1?void 0:n?pB(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(i=(n?a(e,s,i):a(i))||i);return n&&i&&L5(e,s,i),i},Oe=(t,e)=>(s,n)=>e(s,n,t),C1="Terminal input",d0={get:()=>C1,set:t=>C1=t},k1="Too much output to announce, navigate to rows manually to read",u0={get:()=>k1,set:t=>k1=t};function xB(t){return t.replace(/\r?\n/g,"\r")}function vB(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function bB(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function yB(t,e,s,n){if(t.stopPropagation(),t.clipboardData){let i=t.clipboardData.getData("text/plain");S5(i,e,s,n)}}function S5(t,e,s,n){t=xB(t),t=vB(t,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function w5(t,e,s){let n=s.getBoundingClientRect(),i=t.clientX-n.left-10,o=t.clientY-n.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${i}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function V1(t,e,s,n,i){w5(t,e,s),i&&n.rightClickSelect(t),e.value=n.selectionText,e.select()}function Yn(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Pc(t,e=0,s=t.length){let n="";for(let i=e;i<s;++i){let o=t[i];o>65535?(o-=65536,n+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):n+=String.fromCharCode(o)}return n}var _B=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let n=0,i=0;if(this._interim){let o=t.charCodeAt(i++);56320<=o&&o<=57343?e[n++]=(this._interim-55296)*1024+o-56320+65536:(e[n++]=this._interim,e[n++]=o),this._interim=0}for(let o=i;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,n;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[n++]=(a-55296)*1024+l-56320+65536:(e[n++]=a,e[n++]=l);continue}a!==65279&&(e[n++]=a)}return n}},LB=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let n=0,i,o,a,l,c=0,d=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)m<<=6,m|=g;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=x-p;for(;d<v;){if(d>=s)return 0;if(g=t[d++],(g&192)!==128){d--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(x===2?m<128?d--:e[n++]=m:x===3?m<2048||m>=55296&&m<=57343||m===65279||(e[n++]=m):m<65536||m>1114111||(e[n++]=m)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!((i=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[n++]=i,e[n++]=o,e[n++]=a,e[n++]=l,u+=4;if(i=t[u++],i<128)e[n++]=i;else if((i&224)===192){if(u>=s)return this.interim[0]=i,n;if(o=t[u++],(o&192)!==128){u--;continue}if(c=(i&31)<<6|o&63,c<128){u--;continue}e[n++]=c}else if((i&240)===224){if(u>=s)return this.interim[0]=i,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=i,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(c=(i&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;e[n++]=c}else if((i&248)===240){if(u>=s)return this.interim[0]=i,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=i,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=i,this.interim[1]=o,this.interim[2]=a,n;if(l=t[u++],(l&192)!==128){u--;continue}if(c=(i&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;e[n++]=c}}return n}},j5="",Zn=" ",va=class C5{constructor(){this.fg=0,this.bg=0,this.extended=new Kl}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new C5;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Kl=class k5{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new k5(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Gs=class V5 extends va{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Kl,this.combinedData=""}static fromCharData(e){let s=new V5;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Yn(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(n-55296)*1024+i-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},N1="di$target",h0="di$dependencies",yd=new Map;function SB(t){return t[h0]||[]}function rs(t){if(yd.has(t))return yd.get(t);let e=function(s,n,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");wB(e,s,i)};return e._id=t,yd.set(t,e),e}function wB(t,e,s){e[N1]===e?e[h0].push({id:t,index:s}):(e[h0]=[{id:t,index:s}],e[N1]=e)}var ws=rs("BufferService"),N5=rs("CoreMouseService"),er=rs("CoreService"),jB=rs("CharsetService"),Mu=rs("InstantiationService"),T5=rs("LogService"),js=rs("OptionsService"),A5=rs("OscLinkService"),CB=rs("UnicodeService"),ba=rs("DecorationService"),f0=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let n=[],i=this._optionsService.rawOptions.linkHandler,o=new Gs,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let h=0;h<a;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else c!==-1&&(d=!0);if(d||c!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:c+1,y:t},end:{x:h+(!d&&h===a-1?1:0),y:t}},m=!1;if(!i?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||n.push({text:u,range:f,activate:(p,g)=>i?i.activate(p,g,f):kB(p,g),hover:(p,g)=>i?.hover?.(p,g,f),leave:(p,g)=>i?.leave?.(p,g,f)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,l=o.extended.urlId):(c=-1,l=-1)}}e(n)}};f0=Rt([Oe(0,ws),Oe(1,js),Oe(2,A5)],f0);function kB(t,e){if(confirm(`Do you want to navigate to ${e}?
476
-
477
- WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var Rc=rs("CharSizeService"),Fn=rs("CoreBrowserService"),Ou=rs("MouseService"),zn=rs("RenderService"),VB=rs("SelectionService"),E5=rs("CharacterJoinerService"),qr=rs("ThemeService"),P5=rs("LinkProviderService"),NB=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?T1.isErrorNoTelemetry(t)?new T1(t.message+`
478
-
479
- `+t.stack):new Error(t.message+`
480
-
481
- `+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},TB=new NB;function tl(t){AB(t)||TB.onUnexpectedError(t)}var m0="Canceled";function AB(t){return t instanceof EB?!0:t instanceof Error&&t.name===m0&&t.message===m0}var EB=class extends Error{constructor(){super(m0),this.name=this.message}};function PB(t){return new Error(`Illegal argument: ${t}`)}var T1=class p0 extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof p0)return e;let s=new p0;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},g0=class R5 extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,R5.prototype)}};function Ds(t,e=0){return t[t.length-(1+e)]}var RB;(t=>{function e(o){return o<0}t.isLessThan=e;function s(o){return o<=0}t.isLessThanOrEqual=s;function n(o){return o>0}t.isGreaterThan=n;function i(o){return o===0}t.isNeitherLessOrGreaterThan=i,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(RB||={});function DB(t,e){let s=this,n=!1,i;return function(){return n||(n=!0,e||(i=t.apply(s,arguments))),i}}var D5;(t=>{function e(y){return y&&typeof y=="object"&&typeof y[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function n(){return s}t.empty=n;function*i(y){yield y}t.single=i;function o(y){return e(y)?y:i(y)}t.wrap=o;function a(y){return y||s}t.from=a;function*l(y){for(let L=y.length-1;L>=0;L--)yield y[L]}t.reverse=l;function c(y){return!y||y[Symbol.iterator]().next().done===!0}t.isEmpty=c;function d(y){return y[Symbol.iterator]().next().value}t.first=d;function h(y,L){let w=0;for(let j of y)if(L(j,w++))return!0;return!1}t.some=h;function u(y,L){for(let w of y)if(L(w))return w}t.find=u;function*f(y,L){for(let w of y)L(w)&&(yield w)}t.filter=f;function*m(y,L){let w=0;for(let j of y)yield L(j,w++)}t.map=m;function*p(y,L){let w=0;for(let j of y)yield*L(j,w++)}t.flatMap=p;function*g(...y){for(let L of y)yield*L}t.concat=g;function x(y,L,w){let j=w;for(let S of y)j=L(j,S);return j}t.reduce=x;function*v(y,L,w=y.length){for(L<0&&(L+=y.length),w<0?w+=y.length:w>y.length&&(w=y.length);L<w;L++)yield y[L]}t.slice=v;function b(y,L=Number.POSITIVE_INFINITY){let w=[];if(L===0)return[w,y];let j=y[Symbol.iterator]();for(let S=0;S<L;S++){let k=j.next();if(k.done)return[w,t.empty()];w.push(k.value)}return[w,{[Symbol.iterator](){return j}}]}t.consume=b;async function _(y){let L=[];for await(let w of y)L.push(w);return Promise.resolve(L)}t.asyncToArray=_})(D5||={});function Bi(t){if(D5.is(t)){let e=[];for(let s of t)if(s)try{s.dispose()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function IB(...t){return wt(()=>Bi(t))}function wt(t){return{dispose:DB(()=>{t()})}}var I5=class M5{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Bi(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?M5.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};I5.DISABLE_DISPOSED_WARNING=!1;var ni=I5,nt=class{constructor(){this._store=new ni,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};nt.None=Object.freeze({dispose(){}});var Cr=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},En=typeof window=="object"?window:globalThis,x0=class v0{constructor(e){this.element=e,this.next=v0.Undefined,this.prev=v0.Undefined}};x0.Undefined=new x0(void 0);var Ct=x0,A1=class{constructor(){this._first=Ct.Undefined,this._last=Ct.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ct.Undefined}clear(){let t=this._first;for(;t!==Ct.Undefined;){let e=t.next;t.prev=Ct.Undefined,t.next=Ct.Undefined,t=e}this._first=Ct.Undefined,this._last=Ct.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new Ct(t);if(this._first===Ct.Undefined)this._first=s,this._last=s;else if(e){let i=this._last;this._last=s,s.prev=i,i.next=s}else{let i=this._first;this._first=s,s.next=i,i.prev=s}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(s))}}shift(){if(this._first!==Ct.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==Ct.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==Ct.Undefined&&t.next!==Ct.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===Ct.Undefined&&t.next===Ct.Undefined?(this._first=Ct.Undefined,this._last=Ct.Undefined):t.next===Ct.Undefined?(this._last=this._last.prev,this._last.next=Ct.Undefined):t.prev===Ct.Undefined&&(this._first=this._first.next,this._first.prev=Ct.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==Ct.Undefined;)yield t.element,t=t.next}},MB=globalThis.performance&&typeof globalThis.performance.now=="function",OB=class O5{static create(e){return new O5(e)}constructor(e){this._now=MB&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},as;(t=>{t.None=()=>nt.None;function e(P,V){return u(P,()=>{},0,void 0,!0,void 0,V)}t.defer=e;function s(P){return(V,T=null,R)=>{let E=!1,I;return I=P(D=>{if(!E)return I?I.dispose():E=!0,V.call(T,D)},null,R),E&&I.dispose(),I}}t.once=s;function n(P,V,T){return d((R,E=null,I)=>P(D=>R.call(E,V(D)),null,I),T)}t.map=n;function i(P,V,T){return d((R,E=null,I)=>P(D=>{V(D),R.call(E,D)},null,I),T)}t.forEach=i;function o(P,V,T){return d((R,E=null,I)=>P(D=>V(D)&&R.call(E,D),null,I),T)}t.filter=o;function a(P){return P}t.signal=a;function l(...P){return(V,T=null,R)=>{let E=IB(...P.map(I=>I(D=>V.call(T,D))));return h(E,R)}}t.any=l;function c(P,V,T,R){let E=T;return n(P,I=>(E=V(E,I),E),R)}t.reduce=c;function d(P,V){let T,R={onWillAddFirstListener(){T=P(E.fire,E)},onDidRemoveLastListener(){T?.dispose()}},E=new Te(R);return V?.add(E),E.event}function h(P,V){return V instanceof Array?V.push(P):V&&V.add(P),P}function u(P,V,T=100,R=!1,E=!1,I,D){let M,O,$,B=0,z,K={leakWarningThreshold:I,onWillAddFirstListener(){M=P(Q=>{B++,O=V(O,Q),R&&!$&&(Y.fire(O),O=void 0),z=()=>{let q=O;O=void 0,$=void 0,(!R||B>1)&&Y.fire(q),B=0},typeof T=="number"?(clearTimeout($),$=setTimeout(z,T)):$===void 0&&($=0,queueMicrotask(z))})},onWillRemoveListener(){E&&B>0&&z?.()},onDidRemoveLastListener(){z=void 0,M.dispose()}},Y=new Te(K);return D?.add(Y),Y.event}t.debounce=u;function f(P,V=0,T){return t.debounce(P,(R,E)=>R?(R.push(E),R):[E],V,void 0,!0,void 0,T)}t.accumulate=f;function m(P,V=(R,E)=>R===E,T){let R=!0,E;return o(P,I=>{let D=R||!V(I,E);return R=!1,E=I,D},T)}t.latch=m;function p(P,V,T){return[t.filter(P,V,T),t.filter(P,R=>!V(R),T)]}t.split=p;function g(P,V=!1,T=[],R){let E=T.slice(),I=P(O=>{E?E.push(O):M.fire(O)});R&&R.add(I);let D=()=>{E?.forEach(O=>M.fire(O)),E=null},M=new Te({onWillAddFirstListener(){I||(I=P(O=>M.fire(O)),R&&R.add(I))},onDidAddFirstListener(){E&&(V?setTimeout(D):D())},onDidRemoveLastListener(){I&&I.dispose(),I=null}});return R&&R.add(M),M.event}t.buffer=g;function x(P,V){return(T,R,E)=>{let I=V(new b);return P(function(D){let M=I.evaluate(D);M!==v&&T.call(R,M)},void 0,E)}}t.chain=x;let v=Symbol("HaltChainable");class b{constructor(){this.steps=[]}map(V){return this.steps.push(V),this}forEach(V){return this.steps.push(T=>(V(T),T)),this}filter(V){return this.steps.push(T=>V(T)?T:v),this}reduce(V,T){let R=T;return this.steps.push(E=>(R=V(R,E),R)),this}latch(V=(T,R)=>T===R){let T=!0,R;return this.steps.push(E=>{let I=T||!V(E,R);return T=!1,R=E,I?E:v}),this}evaluate(V){for(let T of this.steps)if(V=T(V),V===v)break;return V}}function _(P,V,T=R=>R){let R=(...M)=>D.fire(T(...M)),E=()=>P.on(V,R),I=()=>P.removeListener(V,R),D=new Te({onWillAddFirstListener:E,onDidRemoveLastListener:I});return D.event}t.fromNodeEventEmitter=_;function y(P,V,T=R=>R){let R=(...M)=>D.fire(T(...M)),E=()=>P.addEventListener(V,R),I=()=>P.removeEventListener(V,R),D=new Te({onWillAddFirstListener:E,onDidRemoveLastListener:I});return D.event}t.fromDOMEventEmitter=y;function L(P){return new Promise(V=>s(P)(V))}t.toPromise=L;function w(P){let V=new Te;return P.then(T=>{V.fire(T)},()=>{V.fire(void 0)}).finally(()=>{V.dispose()}),V.event}t.fromPromise=w;function j(P,V){return P(T=>V.fire(T))}t.forward=j;function S(P,V,T){return V(T),P(R=>V(R))}t.runAndSubscribe=S;class k{constructor(V,T){this._observable=V,this._counter=0,this._hasChanged=!1;let R={onWillAddFirstListener:()=>{V.addObserver(this)},onDidRemoveLastListener:()=>{V.removeObserver(this)}};this.emitter=new Te(R),T&&T.add(this.emitter)}beginUpdate(V){this._counter++}handlePossibleChange(V){}handleChange(V,T){this._hasChanged=!0}endUpdate(V){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function C(P,V){return new k(P,V).emitter.event}t.fromObservable=C;function A(P){return(V,T,R)=>{let E=0,I=!1,D={beginUpdate(){E++},endUpdate(){E--,E===0&&(P.reportChanges(),I&&(I=!1,V.call(T)))},handlePossibleChange(){},handleChange(){I=!0}};P.addObserver(D),P.reportChanges();let M={dispose(){P.removeObserver(D)}};return R instanceof ni?R.add(M):Array.isArray(R)&&R.push(M),M}}t.fromObservableLight=A})(as||={});var b0=class y0{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${y0._idPool++}`,y0.all.add(this)}start(e){this._stopWatch=new OB,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};b0.all=new Set,b0._idPool=0;var $B=b0,BB=-1,$5=class B5{constructor(e,s,n=(B5._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=s,this.name=n,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,s){let n=this.threshold;if(n<=0||s<n)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let c=new KB(l,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(e.value)||0;this._stacks.set(e.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,s=0;for(let[n,i]of this._stacks)(!e||s<i)&&(e=[n,i],s=i);return e}};$5._idPool=1;var FB=$5,zB=class F5{constructor(e){this.value=e}static create(){let e=new Error;return new F5(e.stack??"")}print(){console.warn(this.value.split(`
482
- `).slice(2).join(`
483
- `))}},KB=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},UB=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},HB=0,_d=class{constructor(t){this.value=t,this.id=HB++}},WB=2,qB,Te=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new FB(t?.onListenerError??tl,this._options?.leakWarningThreshold??BB):void 0,this._perfMon=this._options?._profName?new $B(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],c=new UB(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||tl)(c),nt.None}if(this._disposed)return nt.None;e&&(t=t.bind(e));let n=new _d(t),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=zB.create(),i=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof _d?(this._deliveryQueue??=new GB,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=wt(()=>{i?.(),this._removeListener(n)});return s instanceof ni?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,s=e.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[s]=void 0;let n=this._deliveryQueue.current===this;if(this._size*WB<=e.length){let i=0;for(let o=0;o<e.length;o++)e[o]?e[i++]=e[o]:n&&(this._deliveryQueue.end--,i<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=i}}_deliver(t,e){if(!t)return;let s=this._options?.onListenerError||tl;if(!s){t.value(e);return}try{t.value(e)}catch(n){s(n)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof _d)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},GB=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},_0=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,s){if(this.getZoomLevel(s)===e)return;let n=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),e)}setFullscreen(e,s){if(this.isFullscreen(s)===e)return;let n=this.getWindowId(s);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};_0.INSTANCE=new _0;var $u=_0;function YB(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}$u.INSTANCE.onDidChangeZoomLevel;function JB(t){return $u.INSTANCE.getZoomFactor(t)}$u.INSTANCE.onDidChangeFullscreen;var Gr=typeof navigator=="object"?navigator.userAgent:"",L0=Gr.indexOf("Firefox")>=0,XB=Gr.indexOf("AppleWebKit")>=0,Bu=Gr.indexOf("Chrome")>=0,QB=!Bu&&Gr.indexOf("Safari")>=0;Gr.indexOf("Electron/")>=0;Gr.indexOf("Android")>=0;var Ld=!1;if(typeof En.matchMedia=="function"){let t=En.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=En.matchMedia("(display-mode: fullscreen)");Ld=t.matches,YB(En,t,({matches:s})=>{Ld&&e.matches||(Ld=s)})}var dr="en",S0=!1,w0=!1,sl=!1,z5=!1,Ua,nl=dr,E1=dr,ZB,Nn,Vi=globalThis,Ms;typeof Vi.vscode<"u"&&typeof Vi.vscode.process<"u"?Ms=Vi.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Ms=process);var eF=typeof Ms?.versions?.electron=="string",tF=eF&&Ms?.type==="renderer";if(typeof Ms=="object"){S0=Ms.platform==="win32",w0=Ms.platform==="darwin",sl=Ms.platform==="linux",sl&&Ms.env.SNAP&&Ms.env.SNAP_REVISION,Ms.env.CI||Ms.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ua=dr,nl=dr;let t=Ms.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Ua=e.userLocale,E1=e.osLocale,nl=e.resolvedLanguage||dr,ZB=e.languagePack?.translationsConfigFile}catch{}z5=!0}else typeof navigator=="object"&&!tF?(Nn=navigator.userAgent,S0=Nn.indexOf("Windows")>=0,w0=Nn.indexOf("Macintosh")>=0,(Nn.indexOf("Macintosh")>=0||Nn.indexOf("iPad")>=0||Nn.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,sl=Nn.indexOf("Linux")>=0,Nn?.indexOf("Mobi")>=0,nl=globalThis._VSCODE_NLS_LANGUAGE||dr,Ua=navigator.language.toLowerCase(),E1=Ua):console.error("Unable to resolve platform.");var K5=S0,bn=w0,sF=sl,P1=z5,wn=Nn,Hn=nl,nF;(t=>{function e(){return Hn}t.value=e;function s(){return Hn.length===2?Hn==="en":Hn.length>=3?Hn[0]==="e"&&Hn[1]==="n"&&Hn[2]==="-":!1}t.isDefaultVariant=s;function n(){return Hn==="en"}t.isDefault=n})(nF||={});var iF=typeof Vi.postMessage=="function"&&!Vi.importScripts;(()=>{if(iF){let t=[];Vi.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let n=0,i=t.length;n<i;n++){let o=t[n];if(o.id===s.data.vscodeScheduleAsyncWork){t.splice(n,1),o.callback();return}}});let e=0;return s=>{let n=++e;t.push({id:n,callback:s}),Vi.postMessage({vscodeScheduleAsyncWork:n},"*")}}return t=>setTimeout(t)})();var rF=!!(wn&&wn.indexOf("Chrome")>=0);wn&&wn.indexOf("Firefox")>=0;!rF&&wn&&wn.indexOf("Safari")>=0;wn&&wn.indexOf("Edg/")>=0;wn&&wn.indexOf("Android")>=0;var ir=typeof navigator=="object"?navigator:{};P1||document.queryCommandSupported&&document.queryCommandSupported("copy")||ir&&ir.clipboard&&ir.clipboard.writeText,P1||ir&&ir.clipboard&&ir.clipboard.readText;var Fu=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},Sd=new Fu,R1=new Fu,D1=new Fu,oF=new Array(230),U5;(t=>{function e(l){return Sd.keyCodeToStr(l)}t.toString=e;function s(l){return Sd.strToKeyCode(l)}t.fromString=s;function n(l){return R1.keyCodeToStr(l)}t.toUserSettingsUS=n;function i(l){return D1.keyCodeToStr(l)}t.toUserSettingsGeneral=i;function o(l){return R1.strToKeyCode(l)||D1.strToKeyCode(l)}t.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Sd.keyCodeToStr(l)}t.toElectronAccelerator=a})(U5||={});var aF=class H5{constructor(e,s,n,i,o){this.ctrlKey=e,this.shiftKey=s,this.altKey=n,this.metaKey=i,this.keyCode=o}equals(e){return e instanceof H5&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",n=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${e}${s}${n}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new lF([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},lF=class{constructor(t){if(t.length===0)throw PB("chords");this.chords=t}getHashCode(){let t="";for(let e=0,s=this.chords.length;e<s;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function cF(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return U5.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(L0)switch(e){case 59:return 85;case 60:if(sF)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(bn)return 57;break}else if(XB&&(bn&&e===93||!bn&&e===92))return 57;return oF[e]||0}var dF=bn?256:2048,uF=512,hF=1024,fF=bn?2048:256,I1=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=cF(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=dF),this.altKey&&(e|=uF),this.shiftKey&&(e|=hF),this.metaKey&&(e|=fF),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new aF(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},M1=new WeakMap;function mF(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,s=t.parent.location;if(e.origin!=="null"&&s.origin!=="null"&&e.origin!==s.origin)return null}catch{return null}return t.parent}var pF=class{static getSameOriginWindowChain(t){let e=M1.get(t);if(!e){e=[],M1.set(t,e);let s=t,n;do n=mF(s),n?e.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):e.push({window:new WeakRef(s),iframeElement:null}),s=n;while(s)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let s=0,n=0,i=this.getSameOriginWindowChain(t);for(let o of i){let a=o.window.deref();if(s+=a?.scrollY??0,n+=a?.scrollX??0,a===e||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,n+=l.left}return{top:s,left:n}}},Ha=class{constructor(t,e){this.timestamp=Date.now(),this.browserEvent=e,this.leftButton=e.button===0,this.middleButton=e.button===1,this.rightButton=e.button===2,this.buttons=e.buttons,this.target=e.target,this.detail=e.detail||1,e.type==="dblclick"&&(this.detail=2),this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,typeof e.pageX=="number"?(this.posx=e.pageX,this.posy=e.pageY):(this.posx=e.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=e.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=pF.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},O1=class{constructor(t,e=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e;let n=!1;if(Bu){let i=navigator.userAgent.match(/Chrome\/(\d+)/);n=(i?parseInt(i[1]):123)<=122}if(t){let i=t,o=t,a=t.view?.devicePixelRatio||1;if(typeof i.wheelDeltaY<"u")n?this.deltaY=i.wheelDeltaY/(120*a):this.deltaY=i.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?L0&&!bn?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof i.wheelDeltaX<"u")QB&&K5?this.deltaX=-(i.wheelDeltaX/120):n?this.deltaX=i.wheelDeltaX/(120*a):this.deltaX=i.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?L0&&!bn?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}this.deltaY===0&&this.deltaX===0&&t.wheelDelta&&(n?this.deltaY=t.wheelDelta/(120*a):this.deltaY=t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},W5=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),gF;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof xF?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:as.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:W5})})(gF||={});var xF=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?W5:(this._emitter||(this._emitter=new Te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},zu=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new g0("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new g0("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},vF=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,e,s=globalThis){if(this.isDisposed)throw new g0("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=s.setInterval(()=>{t()},e);this.disposable=wt(()=>{s.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},bF;(t=>{async function e(n){let i,o=await Promise.all(n.map(a=>a.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return o}t.settled=e;function s(n){return new Promise(async(i,o)=>{try{await n(i,o)}catch(a){o(a)}})}t.withAsyncBody=s})(bF||={});var $1=class Us{static fromArray(e){return new Us(s=>{s.emitMany(e)})}static fromPromise(e){return new Us(async s=>{s.emitMany(await e)})}static fromPromises(e){return new Us(async s=>{await Promise.all(e.map(async n=>s.emitOne(await n)))})}static merge(e){return new Us(async s=>{await Promise.all(e.map(async n=>{for await(let i of n)s.emitOne(i)}))})}constructor(e,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new Te,queueMicrotask(async()=>{let n={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(e(n)),this.resolve()}catch(i){this.reject(i)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await as.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new Us(async n=>{for await(let i of e)n.emitOne(s(i))})}map(e){return Us.map(this,e)}static filter(e,s){return new Us(async n=>{for await(let i of e)s(i)&&n.emitOne(i)})}filter(e){return Us.filter(this,e)}static coalesce(e){return Us.filter(e,s=>!!s)}coalesce(){return Us.coalesce(this)}static async toPromise(e){let s=[];for await(let n of e)s.push(n);return s}toPromise(){return Us.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};$1.EMPTY=$1.fromArray([]);var{getWindow:pn,getWindowId:yF,onDidRegisterWindow:_F}=(function(){let t=new Map,e={window:En,disposables:new ni};t.set(En.vscodeWindowId,e);let s=new Te,n=new Te,i=new Te;function o(a,l){return(typeof a=="number"?t.get(a):void 0)??(l?e:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:n.event,registerWindow(a){if(t.has(a.vscodeWindowId))return nt.None;let l=new ni,c={window:a,disposables:l.add(new ni)};return t.set(a.vscodeWindowId,c),l.add(wt(()=>{t.delete(a.vscodeWindowId),n.fire(a)})),l.add(Ye(a,Xt.BEFORE_UNLOAD,()=>{i.fire(a)})),s.fire(c),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:o,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let c=a;return c?.view?c.view.window:En},getDocument(a){return pn(a).document}}})(),LF=class{constructor(t,e,s,n){this._node=t,this._type=e,this._handler=s,this._options=n||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ye(t,e,s,n){return new LF(t,e,s,n)}var B1=function(t,e,s,n){return Ye(t,e,s,n)},Ku,SF=class extends vF{constructor(t){super(),this.defaultTarget=t&&pn(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},F1=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){tl(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,s=new Map,n=new Map,i=o=>{s.set(o,!1);let a=t.get(o)??[];for(e.set(o,a),t.set(o,[]),n.set(o,!0);a.length>0;)a.sort(F1.sort),a.shift().execute();n.set(o,!1)};Ku=(o,a,l=0)=>{let c=yF(o),d=new F1(a,l),h=t.get(c);return h||(h=[],t.set(c,h)),h.push(d),s.get(c)||(s.set(c,!0),o.requestAnimationFrame(()=>i(c))),d}})();function wF(t){let e=t.getBoundingClientRect(),s=pn(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var Xt={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},jF=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=Cs(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Cs(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Cs(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Cs(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Cs(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Cs(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Cs(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Cs(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Cs(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Cs(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Cs(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=Cs(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=Cs(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Cs(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Cs(t){return typeof t=="number"?`${t}px`:t}function Do(t){return new jF(t)}var q5=class{constructor(){this._hooks=new ni,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,s,n,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=i;let o=t;try{t.setPointerCapture(e),this._hooks.add(wt(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{o=pn(t)}this._hooks.add(Ye(o,Xt.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Ye(o,Xt.POINTER_UP,a=>this.stopMonitoring(!0)))}};function CF(t,e,s){let n=null,i=null;if(typeof s.value=="function"?(n="value",i=s.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(n="get",i=s.get),!i)throw new Error("not supported");let o=`$memoize$${e}`;s[n]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,a)}),this[o]}}var hn;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(hn||={});var vo=class us extends nt{constructor(){super(),this.dispatched=!1,this.targets=new A1,this.ignoreTargets=new A1,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(as.runAndSubscribe(_F,({window:e,disposables:s})=>{s.add(Ye(e.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),s.add(Ye(e.document,"touchend",n=>this.onTouchEnd(e,n))),s.add(Ye(e.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:En,disposables:this._store}))}static addTarget(e){if(!us.isTouchDevice())return nt.None;us.INSTANCE||(us.INSTANCE=new us);let s=us.INSTANCE.targets.push(e);return wt(s)}static ignoreTarget(e){if(!us.isTouchDevice())return nt.None;us.INSTANCE||(us.INSTANCE=new us);let s=us.INSTANCE.ignoreTargets.push(e);return wt(s)}static isTouchDevice(){return"ontouchstart"in En||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,i=e.targetTouches.length;n<i;n++){let o=e.targetTouches.item(n);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(hn.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,s){let n=Date.now(),i=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],d=Date.now()-c.initialTimeStamp;if(d<us.HOLD_DELAY&&Math.abs(c.initialPageX-Ds(c.rollingPageX))<30&&Math.abs(c.initialPageY-Ds(c.rollingPageY))<30){let h=this.newGestureEvent(hn.Tap,c.initialTarget);h.pageX=Ds(c.rollingPageX),h.pageY=Ds(c.rollingPageY),this.dispatchEvent(h)}else if(d>=us.HOLD_DELAY&&Math.abs(c.initialPageX-Ds(c.rollingPageX))<30&&Math.abs(c.initialPageY-Ds(c.rollingPageY))<30){let h=this.newGestureEvent(hn.Contextmenu,c.initialTarget);h.pageX=Ds(c.rollingPageX),h.pageY=Ds(c.rollingPageY),this.dispatchEvent(h)}else if(i===1){let h=Ds(c.rollingPageX),u=Ds(c.rollingPageY),f=Ds(c.rollingTimestamps)-c.rollingTimestamps[0],m=h-c.rollingPageX[0],p=u-c.rollingPageY[0],g=[...this.targets].filter(x=>c.initialTarget instanceof Node&&x.contains(c.initialTarget));this.inertia(e,g,n,Math.abs(m)/f,m>0?1:-1,h,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(hn.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,s){let n=document.createEvent("CustomEvent");return n.initEvent(e,!1,!0),n.initialTarget=s,n.tapCount=0,n}dispatchEvent(e){if(e.type===hn.Tap){let s=new Date().getTime(),n=0;s-this._lastSetTapCountTime>us.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=s,e.tapCount=n}else(e.type===hn.Change||e.type===hn.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(e.initialTarget))return;let s=[];for(let n of this.targets)if(n.contains(e.initialTarget)){let i=0,o=e.initialTarget;for(;o&&o!==n;)i++,o=o.parentElement;s.push([i,n])}s.sort((n,i)=>n[0]-i[0]);for(let[n,i]of s)i.dispatchEvent(e),this.dispatched=!0}}inertia(e,s,n,i,o,a,l,c,d){this.handle=Ku(e,()=>{let h=Date.now(),u=h-n,f=0,m=0,p=!0;i+=us.SCROLL_FRICTION*u,l+=us.SCROLL_FRICTION*u,i>0&&(p=!1,f=o*i*u),l>0&&(p=!1,m=c*l*u);let g=this.newGestureEvent(hn.Change);g.translationX=f,g.translationY=m,s.forEach(x=>x.dispatchEvent(g)),p||this.inertia(e,s,h,i,o,a+f,l,c,d+m)})}onTouchMove(e){let s=Date.now();for(let n=0,i=e.changedTouches.length;n<i;n++){let o=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(hn.Change,a.initialTarget);l.translationX=o.pageX-Ds(a.rollingPageX),l.translationY=o.pageY-Ds(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};vo.SCROLL_FRICTION=-.005,vo.HOLD_DELAY=700,vo.CLEAR_TAP_COUNT_TIME=400,Rt([CF],vo,"isTouchDevice",1);var kF=vo,Uu=class extends nt{onclick(t,e){this._register(Ye(t,Xt.CLICK,s=>e(new Ha(pn(t),s))))}onmousedown(t,e){this._register(Ye(t,Xt.MOUSE_DOWN,s=>e(new Ha(pn(t),s))))}onmouseover(t,e){this._register(Ye(t,Xt.MOUSE_OVER,s=>e(new Ha(pn(t),s))))}onmouseleave(t,e){this._register(Ye(t,Xt.MOUSE_LEAVE,s=>e(new Ha(pn(t),s))))}onkeydown(t,e){this._register(Ye(t,Xt.KEY_DOWN,s=>e(new I1(s))))}onkeyup(t,e){this._register(Ye(t,Xt.KEY_UP,s=>e(new I1(s))))}oninput(t,e){this._register(Ye(t,Xt.INPUT,e))}onblur(t,e){this._register(Ye(t,Xt.BLUR,e))}onfocus(t,e){this._register(Ye(t,Xt.FOCUS,e))}onchange(t,e){this._register(Ye(t,Xt.CHANGE,e))}ignoreGesture(t){return kF.ignoreTarget(t)}},z1=11,VF=class extends Uu{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=z1+"px",this.domNode.style.height=z1+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new q5),this._register(B1(this.bgDomNode,Xt.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(B1(this.domNode,Xt.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new SF),this._pointerdownScheduleRepeatTimer=this._register(new zu)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,pn(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},NF=class j0{constructor(e,s,n,i,o,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,n=n|0,i=i|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,s<0&&(s=0),i+s>n&&(i=n-s),i<0&&(i=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=n,this.scrollLeft=i,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,s){return new j0(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new j0(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,s){let n=this.width!==e.width,i=this.scrollWidth!==e.scrollWidth,o=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,c=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:s,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:i,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:c}}},TF=class extends nt{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new NF(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let s=this._state.withScrollDimensions(t,e);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let s=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let n;e?n=new U1(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let s=this._state.withScrollPosition(t);this._smoothScrolling=U1.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,e)))}},K1=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function wd(t,e){let s=e-t;return function(n){return t+s*PF(n)}}function AF(t,e,s){return function(n){return n<s?t(n/s):e((n-s)/(1-s))}}var U1=class C0{constructor(e,s,n,i){this.from=e,this.to=s,this.duration=i,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,s,n){if(Math.abs(e-s)>2.5*n){let i,o;return e<s?(i=e+.75*n,o=s-.75*n):(i=e-.75*n,o=s+.75*n),AF(wd(e,i),wd(o,s),.33)}return wd(e,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let s=(e-this.startTime)/this.duration;if(s<1){let n=this.scrollLeft(s),i=this.scrollTop(s);return new K1(n,i,!1)}return new K1(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,n){return C0.start(e,s,n)}static start(e,s,n){n=n+10;let i=Date.now()-10;return new C0(e,s,i,n)}};function EF(t){return Math.pow(t,3)}function PF(t){return 1-EF(1-t)}var RF=class extends nt{constructor(t,e,s){super(),this._visibility=t,this._visibleClassName=e,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new zu)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},DF=140,G5=class extends Uu{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new RF(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new q5),this._shouldRender=!0,this.domNode=Do(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ye(this.domNode.domNode,Xt.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new VF(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,n){this.slider=Do(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof s=="number"&&this.slider.setWidth(s),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ye(this.slider.domNode,Xt.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,s=e+this._scrollbarState.getSliderPosition(),n=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(t);s<=i&&i<=n?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,s;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,s=t.offsetY;else{let i=wF(this.domNode.domNode);e=t.pageX-i.left,s=t.pageY-i.top}let n=this._pointerDownRelativePosition(e,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,i=>{let o=this._sliderOrthogonalPointerPosition(i),a=Math.abs(o-s);if(K5&&a>DF){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let l=this._sliderPointerPosition(i)-e;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Y5=class k0{constructor(e,s,n,i,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=i,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new k0(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let s=Math.round(e);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(e){let s=Math.round(e);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let s=Math.round(e);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,s,n,i,o){let a=Math.max(0,n-e),l=Math.max(0,a-2*s),c=i>0&&i>n;if(!c)return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let d=Math.round(Math.max(20,Math.floor(n*l/i))),h=(l-d)/(i-n),u=o*h;return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(d),computedSliderRatio:h,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=k0._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize,n=this._scrollPosition;return s<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+e;return Math.round(s/this._computedSliderRatio)}},IF=class extends G5{constructor(t,e,s){let n=t.getScrollDimensions(),i=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new Y5(e.horizontalHasArrows?e.arrowSize:0,e.horizontal===2?0:e.horizontalScrollbarSize,e.vertical===2?0:e.verticalScrollbarSize,n.width,n.scrollWidth,i.scrollLeft),visibility:e.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:e.scrollByPage}),e.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((e.horizontalScrollbarSize-e.horizontalSliderSize)/2),0,void 0,e.horizontalSliderSize)}_updateSlider(t,e){this.slider.setWidth(t),this.slider.setLeft(e)}_renderDomNode(t,e){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,e){t.scrollLeft=e}updateOptions(t){this.updateScrollbarSize(t.horizontal===2?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},MF=class extends G5{constructor(t,e,s){let n=t.getScrollDimensions(),i=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new Y5(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,n.height,n.scrollHeight,i.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},OF=500,H1=50,$F=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},V0=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,s=0,n=1,i=this._rear;do{let o=i===this._front?e:Math.pow(2,-n);if(e-=o,s+=this._memory[i].score*o,i===this._front)break;i=(this._capacity+i-1)%this._capacity,n++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(Bu){let s=pn(e.browserEvent),n=JB(s);this.accept(Date.now(),e.deltaX*n,e.deltaY*n)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,s,n){let i=null,o=new $F(e,s,n);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(i=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,i)}_computeScore(e,s){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),s){let i=Math.abs(e.deltaX),o=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),c=Math.max(Math.min(i,a),1),d=Math.max(Math.min(o,l),1),h=Math.max(i,a),u=Math.max(o,l);h%c===0&&u%d===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};V0.INSTANCE=new V0;var BF=V0,FF=class extends Uu{constructor(t,e,s){super(),this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Te),this.onWillScroll=this._onWillScroll.event,this._options=KF(e),this._scrollable=s,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let n={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new MF(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new IF(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Do(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Do(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Do(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new zu),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Bi(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,bn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new O1(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Bi(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new O1(s))};this._mouseWheelToDispose.push(Ye(this._listenOnDomNode,Xt.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=BF.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let i=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+i===0?o=i=0:Math.abs(i)>=Math.abs(o)?o=0:i=0),this._options.flipAxes&&([i,o]=[o,i]);let a=!bn&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=i,i=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,i=i*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),c={};if(i){let d=H1*i,h=l.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let d=H1*o,h=l.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(l.scrollLeft!==c.scrollLeft||l.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let n=s;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,s=t.scrollLeft>0,n=s?" left":"",i=e?" top":"",o=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${i}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),OF)}},zF=class extends FF{constructor(t,e,s){super(t,e,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function KF(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,bn&&(e.className+=" mac"),e}var N0=class extends nt{constructor(t,e,s,n,i,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new TF({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>Ku(n.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new zF(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(as.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(wt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(wt(()=>this._styleElement.remove())),this._register(as.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
484
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(d=>this._handleScroll(d)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=e-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};N0=Rt([Oe(2,ws),Oe(3,Fn),Oe(4,N5),Oe(5,qr),Oe(6,js),Oe(7,zn)],N0);var T0=class extends nt{constructor(t,e,s,n,i){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=s,this._decorationService=n,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(wt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",t?.options?.layer==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=t.options.x??0;return s&&s>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose(()=>{this._decorationElements.delete(t),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,e=t.element){if(!e)return;let s=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};T0=Rt([Oe(1,ws),Oe(2,Fn),Oe(3,ba),Oe(4,zn)],T0);var UF=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,e){return e>=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,s){return e>=t.startBufferLine-this._linePadding[s||"full"]&&e<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},dn={full:0,left:0,center:0,right:0},Wn={full:0,left:0,center:0,right:0},no={full:0,left:0,center:0,right:0},Ul=class extends nt{constructor(t,e,s,n,i,o,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=n,this._renderService=i,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new UF,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(wt(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);Wn.full=this._canvas.width,Wn.left=t,Wn.center=e,Wn.right=t,this._refreshDrawHeightConstants(),no.full=1,no.left=1,no.center=1+Wn.left,no.right=1+Wn.left+Wn.center}_refreshDrawHeightConstants(){dn.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);dn.left=e,dn.center=e,dn.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dn.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(no[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-dn[t.position||"full"]/2),Wn[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+dn[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ul=Rt([Oe(2,ws),Oe(3,ba),Oe(4,zn),Oe(5,js),Oe(6,qr),Oe(7,Fn)],Ul);var _e;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
485
- `,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(_e||={});var il;(t=>(t.PAD="€",t.HOP="",t.BPH="‚",t.NBH="ƒ",t.IND="„",t.NEL="…",t.SSA="†",t.ESA="‡",t.HTS="ˆ",t.HTJ="‰",t.VTS="Š",t.PLD="‹",t.PLU="Œ",t.RI="",t.SS2="Ž",t.SS3="",t.DCS="",t.PU1="‘",t.PU2="’",t.STS="“",t.CCH="”",t.MW="•",t.SPA="–",t.EPA="—",t.SOS="˜",t.SGCI="™",t.SCI="š",t.CSI="›",t.ST="œ",t.OSC="",t.PM="ž",t.APC="Ÿ"))(il||={});var J5;(t=>t.ST=`${_e.ESC}\\`)(J5||={});var A0=class{constructor(t,e,s,n,i,o){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=n,this._coreService=i,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;e.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(e.start,this._compositionPosition.start):s=this._textarea.value.substring(e.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,s=e.replace(t,"");this._dataAlreadySent=s,e.length>t.length?this._coreService.triggerDataEvent(s,!0):e.length<t.length?this._coreService.triggerDataEvent(`${_e.DEL}`,!0):e.length===t.length&&e!==t&&this._coreService.triggerDataEvent(e,!0)}},0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};A0=Rt([Oe(2,ws),Oe(3,js),Oe(4,er),Oe(5,zn)],A0);var Zt=0,es=0,ts=0,Tt=0,W1={css:"#00000000",rgba:0},Ot;(t=>{function e(i,o,a,l){return l!==void 0?`#${vi(i)}${vi(o)}${vi(a)}${vi(l)}`:`#${vi(i)}${vi(o)}${vi(a)}`}t.toCss=e;function s(i,o,a,l=255){return(i<<24|o<<16|a<<8|l)>>>0}t.toRgba=s;function n(i,o,a,l){return{css:t.toCss(i,o,a,l),rgba:t.toRgba(i,o,a,l)}}t.toColor=n})(Ot||={});var yt;(t=>{function e(c,d){if(Tt=(d.rgba&255)/255,Tt===1)return{css:d.css,rgba:d.rgba};let h=d.rgba>>24&255,u=d.rgba>>16&255,f=d.rgba>>8&255,m=c.rgba>>24&255,p=c.rgba>>16&255,g=c.rgba>>8&255;Zt=m+Math.round((h-m)*Tt),es=p+Math.round((u-p)*Tt),ts=g+Math.round((f-g)*Tt);let x=Ot.toCss(Zt,es,ts),v=Ot.toRgba(Zt,es,ts);return{css:x,rgba:v}}t.blend=e;function s(c){return(c.rgba&255)===255}t.isOpaque=s;function n(c,d,h){let u=rl.ensureContrastRatio(c.rgba,d.rgba,h);if(u)return Ot.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=n;function i(c){let d=(c.rgba|255)>>>0;return[Zt,es,ts]=rl.toChannels(d),{css:Ot.toCss(Zt,es,ts),rgba:d}}t.opaque=i;function o(c,d){return Tt=Math.round(d*255),[Zt,es,ts]=rl.toChannels(c.rgba),{css:Ot.toCss(Zt,es,ts,Tt),rgba:Ot.toRgba(Zt,es,ts,Tt)}}t.opacity=o;function a(c,d){return Tt=c.rgba&255,o(c,Tt*d/255)}t.multiplyOpacity=a;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}t.toColorRGB=l})(yt||={});var kt;(t=>{let e,s;try{let i=document.createElement("canvas");i.width=1,i.height=1;let o=i.getContext("2d",{willReadFrequently:!0});o&&(e=o,e.globalCompositeOperation="copy",s=e.createLinearGradient(0,0,1,1))}catch{}function n(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return Zt=parseInt(i.slice(1,2).repeat(2),16),es=parseInt(i.slice(2,3).repeat(2),16),ts=parseInt(i.slice(3,4).repeat(2),16),Ot.toColor(Zt,es,ts);case 5:return Zt=parseInt(i.slice(1,2).repeat(2),16),es=parseInt(i.slice(2,3).repeat(2),16),ts=parseInt(i.slice(3,4).repeat(2),16),Tt=parseInt(i.slice(4,5).repeat(2),16),Ot.toColor(Zt,es,ts,Tt);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let o=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Zt=parseInt(o[1]),es=parseInt(o[2]),ts=parseInt(o[3]),Tt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ot.toColor(Zt,es,ts,Tt);if(!e||!s)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=s,e.fillStyle=i,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Zt,es,ts,Tt]=e.getImageData(0,0,1,1).data,Tt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ot.toRgba(Zt,es,ts,Tt),css:i}}t.toColor=n})(kt||={});var gs;(t=>{function e(n){return s(n>>16&255,n>>8&255,n&255)}t.relativeLuminance=e;function s(n,i,o){let a=n/255,l=i/255,c=o/255,d=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return d*.2126+h*.7152+u*.0722}t.relativeLuminance2=s})(gs||={});var rl;(t=>{function e(a,l){if(Tt=(l&255)/255,Tt===1)return l;let c=l>>24&255,d=l>>16&255,h=l>>8&255,u=a>>24&255,f=a>>16&255,m=a>>8&255;return Zt=u+Math.round((c-u)*Tt),es=f+Math.round((d-f)*Tt),ts=m+Math.round((h-m)*Tt),Ot.toRgba(Zt,es,ts)}t.blend=e;function s(a,l,c){let d=gs.relativeLuminance(a>>8),h=gs.relativeLuminance(l>>8);if(Vn(d,h)<c){if(h<d){let m=n(a,l,c),p=Vn(d,gs.relativeLuminance(m>>8));if(p<c){let g=i(a,l,c),x=Vn(d,gs.relativeLuminance(g>>8));return p>x?m:g}return m}let u=i(a,l,c),f=Vn(d,gs.relativeLuminance(u>>8));if(f<c){let m=n(a,l,c),p=Vn(d,gs.relativeLuminance(m>>8));return f>p?u:m}return u}}t.ensureContrastRatio=s;function n(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=Vn(gs.relativeLuminance2(f,m,p),gs.relativeLuminance2(d,h,u));for(;g<c&&(f>0||m>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=Vn(gs.relativeLuminance2(f,m,p),gs.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.reduceLuminance=n;function i(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=Vn(gs.relativeLuminance2(f,m,p),gs.relativeLuminance2(d,h,u));for(;g<c&&(f<255||m<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=Vn(gs.relativeLuminance2(f,m,p),gs.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.increaseLuminance=i;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=o})(rl||={});function vi(t){let e=t.toString(16);return e.length<2?"0"+e:e}function Vn(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var HF=class extends va{constructor(t,e,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Hl=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Gs}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let s=[],n=e.translateToString(!0),i=0,o=0,a=0,l=e.getFg(0),c=e.getBg(0);for(let d=0;d<e.getTrimmedLength();d++)if(e.loadCell(d,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(d-i>1){let h=this._getJoinedRanges(n,a,o,e,i);for(let u=0;u<h.length;u++)s.push(h[u])}i=d,a=o,l=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||Zn.length}if(this._bufferService.cols-i>1){let d=this._getJoinedRanges(n,a,o,e,i);for(let h=0;h<d.length;h++)s.push(d[h])}return s}_getJoinedRanges(t,e,s,n,i){let o=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(o);for(let d=0;d<c.length;d++)Hl._mergeRanges(a,c[d])}catch(c){console.error(c)}return this._stringRangesToCellRanges(a,n,i),a}_stringRangesToCellRanges(t,e,s){let n=0,i=!1,o=0,a=t[n];if(a){for(let l=s;l<this._bufferService.cols;l++){let c=e.getWidth(l),d=e.getString(l).length||Zn.length;if(c!==0){if(!i&&a[0]<=o&&(a[0]=l,i=!0),a[1]<=o){if(a[1]=l,a=t[++n],!a)break;a[0]<=o?(a[0]=l,i=!0):i=!1}o+=d}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let s=!1;for(let n=0;n<t.length;n++){let i=t[n];if(s){if(e[1]<=i[0])return t[n-1][1]=e[1],t;if(e[1]<=i[1])return t[n-1][1]=Math.max(e[1],i[1]),t.splice(n,1),t;t.splice(n,1),n--}else{if(e[1]<=i[0])return t.splice(n,0,e),t;if(e[1]<=i[1])return i[0]=Math.min(e[0],i[0]),t;e[0]<i[1]&&(i[0]=Math.min(e[0],i[0]),s=!0);continue}}return s?t[t.length-1][1]=e[1]:t.push(e),t}};Hl=Rt([Oe(0,ws)],Hl);function WF(t){return 57508<=t&&t<=57558}function qF(t){return 9472<=t&&t<=9631}function GF(t){return WF(t)||qF(t)}function YF(){return{css:{canvas:Wa(),cell:Wa()},device:{canvas:Wa(),cell:Wa(),char:{width:0,height:0,left:0,top:0}}}}function Wa(){return{width:0,height:0}}var E0=class{constructor(t,e,s,n,i,o,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=n,this._coreService=i,this._decorationService=o,this._themeService=a,this._workCell=new Gs,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,e,s){this._selectionStart=t,this._selectionEnd=e,this._columnSelectMode=s}createRow(t,e,s,n,i,o,a,l,c,d,h){let u=[],f=this._characterJoinerService.getJoinedCharacters(e),m=this._themeService.colors,p=t.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,x=0,v="",b=0,_=0,y=0,L=0,w=!1,j=0,S=!1,k=0,C=0,A=[],P=d!==-1&&h!==-1;for(let V=0;V<p;V++){t.loadCell(V,this._workCell);let T=this._workCell.getWidth();if(T===0)continue;let R=!1,E=V>=C,I=V,D=this._workCell;if(f.length>0&&V===f[0][0]&&E){let W=f.shift(),Z=this._isCellInSelection(W[0],e);for(b=W[0]+1;b<W[1];b++)E&&=Z===this._isCellInSelection(b,e);E&&=!s||o<W[0]||o>=W[1],E?(R=!0,D=new HF(this._workCell,t.translateToString(!0,W[0],W[1]),W[1]-W[0]),I=W[1]-1,T=D.getWidth()):C=W[1]}let M=this._isCellInSelection(V,e),O=s&&V===o,$=P&&V>=d&&V<=h,B=!1;this._decorationService.forEachDecorationAtCell(V,e,void 0,W=>{B=!0});let z=D.getChars()||Zn;if(z===" "&&(D.isUnderline()||D.isOverline())&&(z=" "),k=T*l-c.get(z,D.isBold(),D.isItalic()),!g)g=this._document.createElement("span");else if(x&&(M&&S||!M&&!S&&D.bg===_)&&(M&&S&&m.selectionForeground||D.fg===y)&&D.extended.ext===L&&$===w&&k===j&&!O&&!R&&!B&&E){D.isInvisible()?v+=Zn:v+=z,x++;continue}else x&&(g.textContent=v),g=this._document.createElement("span"),x=0,v="";if(_=D.bg,y=D.fg,L=D.extended.ext,w=$,j=k,S=M,R&&o>=V&&o<=I&&(o=V),!this._coreService.isCursorHidden&&O&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&A.push("xterm-cursor-blink"),A.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(D.isBold()&&A.push("xterm-bold"),D.isItalic()&&A.push("xterm-italic"),D.isDim()&&A.push("xterm-dim"),D.isInvisible()?v=Zn:v=D.getChars()||Zn,D.isUnderline()&&(A.push(`xterm-underline-${D.extended.underlineStyle}`),v===" "&&(v=" "),!D.isUnderlineColorDefault()))if(D.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${va.toColorRGB(D.getUnderlineColor()).join(",")})`;else{let W=D.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&D.isBold()&&W<8&&(W+=8),g.style.textDecorationColor=m.ansi[W].css}D.isOverline()&&(A.push("xterm-overline"),v===" "&&(v=" ")),D.isStrikethrough()&&A.push("xterm-strikethrough"),$&&(g.style.textDecoration="underline");let K=D.getFgColor(),Y=D.getFgColorMode(),Q=D.getBgColor(),q=D.getBgColorMode(),H=!!D.isInverse();if(H){let W=K;K=Q,Q=W;let Z=Y;Y=q,q=Z}let U,X,J=!1;this._decorationService.forEachDecorationAtCell(V,e,void 0,W=>{W.options.layer!=="top"&&J||(W.backgroundColorRGB&&(q=50331648,Q=W.backgroundColorRGB.rgba>>8&16777215,U=W.backgroundColorRGB),W.foregroundColorRGB&&(Y=50331648,K=W.foregroundColorRGB.rgba>>8&16777215,X=W.foregroundColorRGB),J=W.options.layer==="top")}),!J&&M&&(U=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,Q=U.rgba>>8&16777215,q=50331648,J=!0,m.selectionForeground&&(Y=50331648,K=m.selectionForeground.rgba>>8&16777215,X=m.selectionForeground)),J&&A.push("xterm-decoration-top");let ee;switch(q){case 16777216:case 33554432:ee=m.ansi[Q],A.push(`xterm-bg-${Q}`);break;case 50331648:ee=Ot.toColor(Q>>16,Q>>8&255,Q&255),this._addStyle(g,`background-color:#${q1((Q>>>0).toString(16),"0",6)}`);break;default:H?(ee=m.foreground,A.push("xterm-bg-257")):ee=m.background}switch(U||D.isDim()&&(U=yt.multiplyOpacity(ee,.5)),Y){case 16777216:case 33554432:D.isBold()&&K<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(K+=8),this._applyMinimumContrast(g,ee,m.ansi[K],D,U,void 0)||A.push(`xterm-fg-${K}`);break;case 50331648:let W=Ot.toColor(K>>16&255,K>>8&255,K&255);this._applyMinimumContrast(g,ee,W,D,U,X)||this._addStyle(g,`color:#${q1(K.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,ee,m.foreground,D,U,X)||H&&A.push("xterm-fg-257")}A.length&&(g.className=A.join(" "),A.length=0),!O&&!R&&!B&&E?x++:g.textContent=v,k!==this.defaultSpacing&&(g.style.letterSpacing=`${k}px`),u.push(g),V=I}return g&&x&&(g.textContent=v),u}_applyMinimumContrast(t,e,s,n,i,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||GF(n.getCode()))return!1;let a=this._getContrastCache(n),l;if(!i&&!o&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);l=yt.ensureContrastRatio(i||e,o||s,c),a.setColor((i||e).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(t,`color:${l.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let s=this._selectionStart,n=this._selectionEnd;return!s||!n?!1:this._columnSelectMode?s[0]<=n[0]?t>=s[0]&&e>=s[1]&&t<n[0]&&e<=n[1]:t<s[0]&&e>=s[1]&&t>=n[0]&&e<=n[1]:e>s[1]&&e<n[1]||s[1]===n[1]&&e===s[1]&&t>=s[0]&&t<n[0]||s[1]<n[1]&&e===n[1]&&t<n[0]||s[1]<n[1]&&e===s[1]&&t>=s[0]}};E0=Rt([Oe(1,E5),Oe(2,js),Oe(3,Fn),Oe(4,er),Oe(5,ba),Oe(6,qr)],E0);function q1(t,e,s){for(;t.length<s;)t=e+t;return t}var JF=class{constructor(t,e){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=t.createElement("span");s.classList.add("xterm-char-measure-element");let n=t.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let i=t.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontStyle="italic";let o=t.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,n,i,o],this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(i),this._container.appendChild(o),e.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(t,e,s,n){t===this._font&&e===this._fontSize&&s===this._weight&&n===this._weightBold||(this._font=t,this._fontSize=e,this._weight=s,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(t,e,s){let n=0;if(!e&&!s&&t.length===1&&(n=t.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let a=this._measure(t,0);return a>0&&(this._flat[n]=a),a}let i=t;e&&(i+="B"),s&&(i+="I");let o=this._holey.get(i);if(o===void 0){let a=0;e&&(a|=1),s&&(a|=2),o=this._measure(t,a),o>0&&this._holey.set(i,o)}return o}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},XF=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,s,n=!1){if(this.selectionStart=e,this.selectionEnd=s,!e||!s||e[0]===s[0]&&e[1]===s[1]){this.clear();return}let i=t.buffers.active.ydisp,o=e[1]-i,a=s[1]-i,l=Math.max(o,0),c=Math.min(a,t.rows-1);if(l>=t.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=e[0],this.endCol=s[0]}isCellSelected(t,e,s){return this.hasSelection?(s-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&s>=this.viewportCappedStartRow&&e<this.endCol&&s<=this.viewportCappedEndRow:e<this.startCol&&s>=this.viewportCappedStartRow&&e>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol):!1}};function QF(){return new XF}var jd="xterm-dom-renderer-owner-",Ks="xterm-rows",qa="xterm-fg-",G1="xterm-bg-",io="xterm-focus",Ga="xterm-selection",ZF=1,P0=class extends nt{constructor(t,e,s,n,i,o,a,l,c,d,h,u,f,m){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=n,this._viewportElement=i,this._helperContainer=o,this._linkifier2=a,this._charSizeService=c,this._optionsService=d,this._bufferService=h,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=ZF++,this._rowElements=[],this._selectionRenderModel=QF(),this.onRequestRedraw=this._register(new Te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ks),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ga),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=YF(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(E0,document),this._element.classList.add(jd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(wt(()=>{this._element.classList.remove(jd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new JF(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${Ks} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${Ks} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${Ks} .xterm-dim { color: ${yt.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;e+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${n} { 50% { box-shadow: none; }}`,e+=`@keyframes ${i} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${Ks}.${io} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ks}.${io} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ks}.${io} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${Ga} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ga} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ga} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of t.ansi.entries())e+=`${this._terminalSelector} .${qa}${o} { color: ${a.css}; }${this._terminalSelector} .${qa}${o}.xterm-dim { color: ${yt.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${G1}${o} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${qa}257 { color: ${yt.opaque(t.background).css}; }${this._terminalSelector} .${qa}257.xterm-dim { color: ${yt.multiplyOpacity(yt.opaque(t.background),.5).css}; }${this._terminalSelector} .${G1}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let s=this._rowElements.length;s<=e;s++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(io),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(io),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,s),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,s),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let c=t[0]>e[0];l.appendChild(this._createSelectionElement(o,c?e[0]:t[0],c?t[0]:e[0],a-o+1))}else{let c=n===o?t[0]:0,d=o===i?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,c,d));let h=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==a){let u=i===a?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(t,e,s,n=1){let i=this._document.createElement("div"),o=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),i.style.height=`${n*this.dimensions.css.cell.height}px`,i.style.top=`${t*this.dimensions.css.cell.height}px`,i.style.left=`${o}px`,i.style.width=`${a}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let s=this._bufferService.buffer,n=s.ybase+s.y,i=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=t;c<=e;c++){let d=c+s.ydisp,h=this._rowElements[c],u=s.lines.get(d);if(!h||!u)break;h.replaceChildren(...this._rowFactory.createRow(u,d,d===n,a,l,i,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${jd}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,s,n,i,o){s<0&&(t=0),n<0&&(e=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),n=Math.max(Math.min(n,a),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,i-1),h=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=s;m<=n;++m){let p=m+l.ydisp,g=this._rowElements[m],x=l.lines.get(p);if(!g||!x)break;g.replaceChildren(...this._rowFactory.createRow(x,p,p===c,u,f,d,h,this.dimensions.css.cell.width,this._widthCache,o?m===s?t:0:-1,o?(m===n?e:i)-1:-1))}}};P0=Rt([Oe(7,Mu),Oe(8,Rc),Oe(9,js),Oe(10,ws),Oe(11,er),Oe(12,Fn),Oe(13,qr)],P0);var R0=class extends nt{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new tz(this._optionsService))}catch{this._measureStrategy=this._register(new ez(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};R0=Rt([Oe(2,js)],R0);var X5=class extends nt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},ez=class extends X5{constructor(t,e,s){super(),this._document=t,this._parentElement=e,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},tz=class extends X5{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},sz=class extends nt{constructor(t,e,s){super(),this._textarea=t,this._window=e,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new nz(this._window)),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(as.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ye(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ye(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},nz=class extends nt{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new Cr),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(wt(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ye(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},iz=class extends nt{constructor(){super(),this.linkProviders=[],this._register(wt(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function Hu(t,e,s){let n=s.getBoundingClientRect(),i=t.getComputedStyle(s),o=parseInt(i.getPropertyValue("padding-left")),a=parseInt(i.getPropertyValue("padding-top"));return[e.clientX-n.left-o,e.clientY-n.top-a]}function rz(t,e,s,n,i,o,a,l,c){if(!o)return;let d=Hu(t,e,s);if(d)return d[0]=Math.ceil((d[0]+(c?a/2:0))/a),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),n+(c?1:0)),d[1]=Math.min(Math.max(d[1],1),i),d}var D0=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,n,i){return rz(window,t,e,s,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(t,e){let s=Hu(window,t,e);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};D0=Rt([Oe(0,zn),Oe(1,Rc)],D0);var oz=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},Q5={};gB(Q5,{getSafariVersion:()=>lz,isChromeOS:()=>sx,isFirefox:()=>Z5,isIpad:()=>cz,isIphone:()=>dz,isLegacyEdge:()=>az,isLinux:()=>Wu,isMac:()=>Wl,isNode:()=>Dc,isSafari:()=>ex,isWindows:()=>tx});var Dc=typeof process<"u"&&"title"in process,ya=Dc?"node":navigator.userAgent,_a=Dc?"node":navigator.platform,Z5=ya.includes("Firefox"),az=ya.includes("Edge"),ex=/^((?!chrome|android).)*safari/i.test(ya);function lz(){if(!ex)return 0;let t=ya.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var Wl=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(_a),cz=_a==="iPad",dz=_a==="iPhone",tx=["Windows","Win16","Win32","WinCE"].includes(_a),Wu=_a.indexOf("Linux")>=0,sx=/\bCrOS\b/.test(ya),nx=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,s=0,n=t.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),s=Math.max(e,s),i=t.timeRemaining(),s*1.5>i){n-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-e))}ms`),this._start();return}n=i}this.clear()}},uz=class extends nx{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},hz=class extends nx{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},ql=!Dc&&"requestIdleCallback"in window?hz:uz,fz=class{constructor(){this._queue=new ql}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},I0=class extends nt{constructor(t,e,s,n,i,o,a,l,c){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=n,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new Cr),this._pausedResizeTask=new fz,this._observerDisposable=this._register(new Cr),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new oz((d,h)=>this._renderRows(d,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new mz(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(wt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let s=new t.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});s.observe(e),this._observerDisposable.value=wt(()=>s.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(t,e,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let n=this._syncOutputHandler.flush();n&&(t=Math.min(t,n.start),e=Math.max(e,n.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(t,e)):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,e,s){this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,e,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};I0=Rt([Oe(2,js),Oe(3,Rc),Oe(4,er),Oe(5,ba),Oe(6,ws),Oe(7,Fn),Oe(8,qr)],I0);var mz=class{constructor(t,e,s){this._coreBrowserService=t,this._coreService=e,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function pz(t,e,s,n){let i=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return vz(i,o,t,e,s,n)+Ic(o,e,s,n)+bz(i,o,t,e,s,n);let a;if(o===e)return a=i>t?"D":"C",ea(Math.abs(i-t),Zo(a,n));a=o>e?"D":"C";let l=Math.abs(o-e),c=xz(o>e?t:i,s)+(l-1)*s.cols+1+gz(o>e?i:t);return ea(c,Zo(a,n))}function gz(t,e){return t-1}function xz(t,e){return e.cols-t}function vz(t,e,s,n,i,o){return Ic(e,n,i,o).length===0?"":ea(rx(t,e,t,e-Fi(e,i),!1,i).length,Zo("D",o))}function Ic(t,e,s,n){let i=t-Fi(t,s),o=e-Fi(e,s),a=Math.abs(i-o)-yz(t,e,s);return ea(a,Zo(ix(t,e),n))}function bz(t,e,s,n,i,o){let a;Ic(e,n,i,o).length>0?a=n-Fi(n,i):a=e;let l=n,c=_z(t,e,s,n,i,o);return ea(rx(t,a,s,l,c==="C",i).length,Zo(c,o))}function yz(t,e,s){let n=0,i=t-Fi(t,s),o=e-Fi(e,s);for(let a=0;a<Math.abs(i-o);a++){let l=ix(t,e)==="A"?-1:1;s.buffer.lines.get(i+l*a)?.isWrapped&&n++}return n}function Fi(t,e){let s=0,n=e.buffer.lines.get(t),i=n?.isWrapped;for(;i&&t>=0&&t<e.rows;)s++,n=e.buffer.lines.get(--t),i=n?.isWrapped;return s}function _z(t,e,s,n,i,o){let a;return Ic(s,n,i,o).length>0?a=n-Fi(n,i):a=e,t<s&&a<=n||t>=s&&a<n?"C":"D"}function ix(t,e){return t>e?"A":"B"}function rx(t,e,s,n,i,o){let a=t,l=e,c="";for(;(a!==s||l!==n)&&l>=0&&l<o.buffer.lines.length;)a+=i?1:-1,i&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!i&&a<0&&(c+=o.buffer.translateBufferLineToString(l,!1,0,t+1),a=o.cols-1,t=a,l--);return c+o.buffer.translateBufferLineToString(l,!1,t,a)}function Zo(t,e){let s=e?"O":"[";return _e.ESC+s+t}function ea(t,e){t=Math.floor(t);let s="";for(let n=0;n<t;n++)s+=e;return s}var Lz=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Y1(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Cd=50,Sz=15,wz=50,jz=500,Cz=" ",kz=new RegExp(Cz,"g"),M0=class extends nt{constructor(t,e,s,n,i,o,a,l,c){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=n,this._coreService=i,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Gs,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new Lz(this._bufferService),this._activeSelectionMode=0,this._register(wt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let s=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let i=t[0]<e[0]?t[0]:e[0],o=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,i,o);n.push(l)}}else{let i=t[1]===e[1]?e[0]:void 0;n.push(s.translateBufferLineToString(t[1],!0,t[0],i));for(let o=t[1]+1;o<=e[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?n[n.length-1]+=l:n.push(l)}if(t[1]!==e[1]){let o=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);o&&o.isWrapped?n[n.length-1]+=a:n.push(a)}}return n.map(i=>i.replace(kz," ")).join(tx?`\r
486
- `:`
487
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Wu&&t&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(t){let e=this._getMouseBufferCoords(t),s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n||!e?!1:this._areCoordsInSelection(e,s,n)}isCellInSelection(t,e){let s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n?!1:this._areCoordsInSelection([t,e],s,n)}_areCoordsInSelection(t,e,s){return t[1]>e[1]&&t[1]<s[1]||e[1]===s[1]&&t[1]===e[1]&&t[0]>=e[0]&&t[0]<s[0]||e[1]<s[1]&&t[1]===s[1]&&t[0]<s[0]||e[1]<s[1]&&t[1]===e[1]&&t[0]>=e[0]}_selectWordAtCursor(t,e){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Y1(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(t);return n?(this._selectWordAt(n,e),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,e){this._model.clearSelection(),t=Math.max(t,0),e=Math.min(e,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,e],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let e=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(e)return e[0]--,e[1]--,e[1]+=this._bufferService.buffer.ydisp,e}_getMouseEventScrollAmount(t){let e=Hu(this._coreBrowserService.window,t,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return e>=0&&e<=s?0:(e>s&&(e-=s),e=Math.min(Math.max(e,-Cd),Cd),e/=Cd,e/Math.abs(e)+Math.round(e*(Sz-1)))}shouldForceSelection(t){return Wl?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,!(t.button===2&&this.hasSelection)&&t.button===0){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):t.detail===1?this._handleSingleClick(t):t.detail===2?this._handleDoubleClick(t):t.detail===3&&this._handleTripleClick(t),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),wz)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let e=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);e&&e.length!==this._model.selectionStart[0]&&e.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let e=this._getMouseBufferCoords(t);e&&(this._activeSelectionMode=2,this._selectLineAt(e[1]))}shouldColumnSelect(t){return t.altKey&&!(Wl&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.stopImmediatePropagation(),!this._model.selectionStart)return;let e=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(t),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(t),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let n=s.lines.get(this._model.selectionEnd[1]);n&&n.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!e||e[0]!==this._model.selectionEnd[0]||e[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let t=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let e=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&e<jz&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let n=pz(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd,s=!!t&&!!e&&(t[0]!==e[0]||t[1]!==e[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(t,e,s);return}!t||!e||(!this._oldSelectionStart||!this._oldSelectionEnd||t[0]!==this._oldSelectionStart[0]||t[1]!==this._oldSelectionStart[1]||e[0]!==this._oldSelectionEnd[0]||e[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(t,e,s)}_fireOnSelectionChange(t,e,s){this._oldSelectionStart=t,this._oldSelectionEnd=e,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(t,e){let s=e;for(let n=0;e>=n;n++){let i=t.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:i>1&&e!==n&&(s+=i-1)}return s}setSelection(t,e,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,e],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,e,s=!0,n=!0){if(t[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,o=i.lines.get(t[1]);if(!o)return;let a=i.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(o,t[0]),c=l,d=t[0]-l,h=0,u=0,f=0,m=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;c<a.length&&a.charAt(c+1)===" ";)c++}else{let x=t[0],v=t[0];o.getWidth(x)===0&&(h++,x--),o.getWidth(v)===2&&(u++,v++);let b=o.getString(v).length;for(b>1&&(m+=b-1,c+=b-1);x>0&&l>0&&!this._isCharWordSeparator(o.loadCell(x-1,this._workCell));){o.loadCell(x-1,this._workCell);let _=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,x--):_>1&&(f+=_-1,l-=_-1),l--,x--}for(;v<o.length&&c+1<a.length&&!this._isCharWordSeparator(o.loadCell(v+1,this._workCell));){o.loadCell(v+1,this._workCell);let _=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,v++):_>1&&(m+=_-1,c+=_-1),c++,v++}}c++;let p=l+d-h+f,g=Math.min(this._bufferService.cols,c-l+h+u-f-m);if(!(!e&&a.slice(l,c).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let x=i.lines.get(t[1]-1);if(x&&o.isWrapped&&x.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let b=this._bufferService.cols-v.start;p-=b,g+=b}}}if(n&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let x=i.lines.get(t[1]+1);if(x?.isWrapped&&x.getCodePoint(0)!==32){let v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(g+=v.length)}}return{start:p,length:g}}}_selectWordAt(t,e){let s=this._getWordAt(t,e);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let s=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,s]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),s={start:{x:0,y:e.first},end:{x:this._bufferService.cols-1,y:e.last}};this._model.selectionStart=[0,e.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Y1(s,this._bufferService.cols)}};M0=Rt([Oe(3,ws),Oe(4,er),Oe(5,Ou),Oe(6,js),Oe(7,zn),Oe(8,Fn)],M0);var J1=class{constructor(){this._data={}}set(t,e,s){this._data[t]||(this._data[t]={}),this._data[t][e]=s}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},X1=class{constructor(){this._color=new J1,this._css=new J1}setCss(t,e,s){this._css.set(t,e,s)}getCss(t,e){return this._css.get(t,e)}setColor(t,e,s){this._color.set(t,e,s)}getColor(t,e){return this._color.get(t,e)}clear(){this._color.clear(),this._css.clear()}},Kt=Object.freeze((()=>{let t=[kt.toColor("#2e3436"),kt.toColor("#cc0000"),kt.toColor("#4e9a06"),kt.toColor("#c4a000"),kt.toColor("#3465a4"),kt.toColor("#75507b"),kt.toColor("#06989a"),kt.toColor("#d3d7cf"),kt.toColor("#555753"),kt.toColor("#ef2929"),kt.toColor("#8ae234"),kt.toColor("#fce94f"),kt.toColor("#729fcf"),kt.toColor("#ad7fa8"),kt.toColor("#34e2e2"),kt.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){let n=e[s/36%6|0],i=e[s/6%6|0],o=e[s%6];t.push({css:Ot.toCss(n,i,o),rgba:Ot.toRgba(n,i,o)})}for(let s=0;s<24;s++){let n=8+s*10;t.push({css:Ot.toCss(n,n,n),rgba:Ot.toRgba(n,n,n)})}return t})()),bi=kt.toColor("#ffffff"),bo=kt.toColor("#000000"),Q1=kt.toColor("#ffffff"),Z1=bo,ro={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Vz=bi,O0=class extends nt{constructor(t){super(),this._optionsService=t,this._contrastCache=new X1,this._halfContrastCache=new X1,this._onChangeColors=this._register(new Te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:bi,background:bo,cursor:Q1,cursorAccent:Z1,selectionForeground:void 0,selectionBackgroundTransparent:ro,selectionBackgroundOpaque:yt.blend(bo,ro),selectionInactiveBackgroundTransparent:ro,selectionInactiveBackgroundOpaque:yt.blend(bo,ro),scrollbarSliderBackground:yt.opacity(bi,.2),scrollbarSliderHoverBackground:yt.opacity(bi,.4),scrollbarSliderActiveBackground:yt.opacity(bi,.5),overviewRulerBorder:bi,ansi:Kt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(t={}){let e=this._colors;if(e.foreground=ht(t.foreground,bi),e.background=ht(t.background,bo),e.cursor=yt.blend(e.background,ht(t.cursor,Q1)),e.cursorAccent=yt.blend(e.background,ht(t.cursorAccent,Z1)),e.selectionBackgroundTransparent=ht(t.selectionBackground,ro),e.selectionBackgroundOpaque=yt.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=ht(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=yt.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?ht(t.selectionForeground,W1):void 0,e.selectionForeground===W1&&(e.selectionForeground=void 0),yt.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=yt.opacity(e.selectionBackgroundTransparent,.3)),yt.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=yt.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=ht(t.scrollbarSliderBackground,yt.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=ht(t.scrollbarSliderHoverBackground,yt.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=ht(t.scrollbarSliderActiveBackground,yt.opacity(e.foreground,.5)),e.overviewRulerBorder=ht(t.overviewRulerBorder,Vz),e.ansi=Kt.slice(),e.ansi[0]=ht(t.black,Kt[0]),e.ansi[1]=ht(t.red,Kt[1]),e.ansi[2]=ht(t.green,Kt[2]),e.ansi[3]=ht(t.yellow,Kt[3]),e.ansi[4]=ht(t.blue,Kt[4]),e.ansi[5]=ht(t.magenta,Kt[5]),e.ansi[6]=ht(t.cyan,Kt[6]),e.ansi[7]=ht(t.white,Kt[7]),e.ansi[8]=ht(t.brightBlack,Kt[8]),e.ansi[9]=ht(t.brightRed,Kt[9]),e.ansi[10]=ht(t.brightGreen,Kt[10]),e.ansi[11]=ht(t.brightYellow,Kt[11]),e.ansi[12]=ht(t.brightBlue,Kt[12]),e.ansi[13]=ht(t.brightMagenta,Kt[13]),e.ansi[14]=ht(t.brightCyan,Kt[14]),e.ansi[15]=ht(t.brightWhite,Kt[15]),t.extendedAnsi){let s=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let n=0;n<s;n++)e.ansi[n+16]=ht(t.extendedAnsi[n],Kt[n+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(t){this._restoreColor(t),this._onChangeColors.fire(this.colors)}_restoreColor(t){if(t===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(t){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[t]=this._restoreColors.ansi[t]}}modifyColors(t){t(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};O0=Rt([Oe(0,js)],O0);function ht(t,e){if(t!==void 0)try{return kt.toColor(t)}catch{}return e}var Nz=class{constructor(...t){this._entries=new Map;for(let[e,s]of t)this.set(e,s)}set(t,e){let s=this._entries.get(t);return this._entries.set(t,e),s}forEach(t){for(let[e,s]of this._entries.entries())t(e,s)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},Tz=class{constructor(){this._services=new Nz,this._services.set(Mu,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=SB(t).sort((o,a)=>o.index-a.index),n=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${o.id._id}.`);n.push(a)}let i=s.length>0?s[0].index:e.length;if(e.length!==i)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${i+1} conflicts with ${e.length} static arguments`);return new t(...e,...n)}},Az={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ez="xterm.js: ",$0=class extends nt{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Az[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":Ez)+e,...s)}trace(t,...e){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,e)}debug(t,...e){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,e)}info(t,...e){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,e)}warn(t,...e){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,e)}error(t,...e){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,e)}};$0=Rt([Oe(0,js)],$0);var em=class extends nt{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new Te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Te),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let e=new Array(t);for(let s=0;s<Math.min(t,this.length);s++)e[s]=this._array[this._getCyclicIndex(s)];this._array=e,this._maxLength=t,this._startIndex=0}get length(){return this._length}set length(t){if(t>this._length)for(let e=this._length;e<t;e++)this._array[e]=void 0;this._length=t}get(t){return this._array[this._getCyclicIndex(t)]}set(t,e){this._array[this._getCyclicIndex(t)]=e}push(t){this._array[this._getCyclicIndex(this._length)]=t,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(t,e,...s){if(e){for(let n=t;n<this._length-e;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let n=this._length-1;n>=t;n--)this._array[this._getCyclicIndex(n+s.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<s.length;n++)this._array[this._getCyclicIndex(t+n)]=s[n];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let n=this._length+s.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=s.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,e,s){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=e-1;i>=0;i--)this.set(t+i+s,this.get(t+i));let n=t+e+s-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<e;n++)this.set(t+n+s,this.get(t+n))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},tt=3,Mt=Object.freeze(new va),Ya=0,kd=2,yo=class ox{constructor(e,s,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*tt);let i=s||Gs.fromCharData([0,j5,1,0]);for(let o=0;o<e;++o)this.setCell(o,i);this.length=e}get(e){let s=this._data[e*tt+0],n=s&2097151;return[this._data[e*tt+1],s&2097152?this._combined[e]:n?Yn(n):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,s){this._data[e*tt+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*tt+0]=e|2097152|s[2]<<22):this._data[e*tt+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*tt+0]>>22}hasWidth(e){return this._data[e*tt+0]&12582912}getFg(e){return this._data[e*tt+1]}getBg(e){return this._data[e*tt+2]}hasContent(e){return this._data[e*tt+0]&4194303}getCodePoint(e){let s=this._data[e*tt+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*tt+0]&2097152}getString(e){let s=this._data[e*tt+0];return s&2097152?this._combined[e]:s&2097151?Yn(s&2097151):""}isProtected(e){return this._data[e*tt+2]&536870912}loadCell(e,s){return Ya=e*tt,s.content=this._data[Ya+0],s.fg=this._data[Ya+1],s.bg=this._data[Ya+2],s.content&2097152&&(s.combinedData=this._combined[e]),s.bg&268435456&&(s.extended=this._extendedAttrs[e]),s}setCell(e,s){s.content&2097152&&(this._combined[e]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*tt+0]=s.content,this._data[e*tt+1]=s.fg,this._data[e*tt+2]=s.bg}setCellFromCodepoint(e,s,n,i){i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*tt+0]=s|n<<22,this._data[e*tt+1]=i.fg,this._data[e*tt+2]=i.bg}addCodepointToCell(e,s,n){let i=this._data[e*tt+0];i&2097152?this._combined[e]+=Yn(s):i&2097151?(this._combined[e]=Yn(i&2097151)+Yn(s),i&=-2097152,i|=2097152):i=s|1<<22,n&&(i&=-12582913,i|=n<<22),this._data[e*tt+0]=i}insertCells(e,s,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length-e){let i=new Gs;for(let o=this.length-e-s-1;o>=0;--o)this.setCell(e+s+o,this.loadCell(e+o,i));for(let o=0;o<s;++o)this.setCell(e+o,n)}else for(let i=e;i<this.length;++i)this.setCell(i,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,s,n){if(e%=this.length,s<this.length-e){let i=new Gs;for(let o=0;o<this.length-e-s;++o)this.setCell(e+o,this.loadCell(e+s+o,i));for(let o=this.length-s;o<this.length;++o)this.setCell(o,n)}else for(let i=e;i<this.length;++i)this.setCell(i,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,s,n,i=!1){if(i){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,n);e<s&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,n);e<s&&e<this.length;)this.setCell(e++,n)}resize(e,s){if(e===this.length)return this._data.length*4*kd<this._data.buffer.byteLength;let n=e*tt;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let i=new Uint32Array(n);i.set(this._data),this._data=i}for(let i=this.length;i<e;++i)this.setCell(i,s)}else{this._data=this._data.subarray(0,n);let i=Object.keys(this._combined);for(let a=0;a<i.length;a++){let l=parseInt(i[a],10);l>=e&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,n*4*kd<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*kd<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,s=!1){if(s){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,e);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let s in e._combined)this._combined[s]=e._combined[s];this._extendedAttrs={};for(let s in e._extendedAttrs)this._extendedAttrs[s]=e._extendedAttrs[s];this.isWrapped=e.isWrapped}clone(){let e=new ox(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let s in this._combined)e._combined[s]=this._combined[s];for(let s in this._extendedAttrs)e._extendedAttrs[s]=this._extendedAttrs[s];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*tt+0]&4194303)return e+(this._data[e*tt+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*tt+0]&4194303||this._data[e*tt+2]&50331648)return e+(this._data[e*tt+0]>>22);return 0}copyCellsFrom(e,s,n,i,o){let a=e._data;if(o)for(let c=i-1;c>=0;c--){for(let d=0;d<tt;d++)this._data[(n+c)*tt+d]=a[(s+c)*tt+d];a[(s+c)*tt+2]&268435456&&(this._extendedAttrs[n+c]=e._extendedAttrs[s+c])}else for(let c=0;c<i;c++){for(let d=0;d<tt;d++)this._data[(n+c)*tt+d]=a[(s+c)*tt+d];a[(s+c)*tt+2]&268435456&&(this._extendedAttrs[n+c]=e._extendedAttrs[s+c])}let l=Object.keys(e._combined);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=s&&(this._combined[d-s+n]=e._combined[d])}}translateToString(e,s,n,i){s=s??0,n=n??this.length,e&&(n=Math.min(n,this.getTrimmedLength())),i&&(i.length=0);let o="";for(;s<n;){let a=this._data[s*tt+0],l=a&2097151,c=a&2097152?this._combined[s]:l?Yn(l):Zn;if(o+=c,i)for(let d=0;d<c.length;++d)i.push(s);s+=a>>22||1}return i&&i.push(s),o}};function Pz(t,e,s,n,i,o){let a=[];for(let l=0;l<t.length-1;l++){let c=l,d=t.get(++c);if(!d.isWrapped)continue;let h=[t.get(l)];for(;c<t.length&&d.isWrapped;)h.push(d),d=t.get(++c);if(!o&&n>=l&&n<c){l+=h.length-1;continue}let u=0,f=ta(h,u,e),m=1,p=0;for(;m<h.length;){let x=ta(h,m,e),v=x-p,b=s-f,_=Math.min(v,b);h[u].copyCellsFrom(h[m],p,f,_,!1),f+=_,f===s&&(u++,f=0),p+=_,p===x&&(m++,p=0),f===0&&u!==0&&h[u-1].getWidth(s-1)===2&&(h[u].copyCellsFrom(h[u-1],s-1,f++,1,!1),h[u-1].setCell(s-1,i))}h[u].replaceCells(f,s,i);let g=0;for(let x=h.length-1;x>0&&(x>u||h[x].getTrimmedLength()===0);x--)g++;g>0&&(a.push(l+h.length-g),a.push(g)),l+=h.length-1}return a}function Rz(t,e){let s=[],n=0,i=e[n],o=0;for(let a=0;a<t.length;a++)if(i===a){let l=e[++n];t.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,i=e[++n]}else s.push(a);return{layout:s,countRemoved:o}}function Dz(t,e){let s=[];for(let n=0;n<e.length;n++)s.push(t.get(e[n]));for(let n=0;n<s.length;n++)t.set(n,s[n]);t.length=e.length}function Iz(t,e,s){let n=[],i=t.map((c,d)=>ta(t,d,e)).reduce((c,d)=>c+d),o=0,a=0,l=0;for(;l<i;){if(i-l<s){n.push(i-l);break}o+=s;let c=ta(t,a,e);o>c&&(o-=c,a++);let d=t[a].getWidth(o-1)===2;d&&o--;let h=d?s-1:s;n.push(h),l+=h}return n}function ta(t,e,s){if(e===t.length-1)return t[e].getTrimmedLength();let n=!t[e].hasContent(s-1)&&t[e].getWidth(s-1)===1,i=t[e+1].getWidth(0)===2;return n&&i?s-1:s}var ax=class lx{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=lx._nextId++,this._onDispose=this.register(new Te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Bi(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};ax._nextId=1;var Mz=ax,Gt={},yi=Gt.B;Gt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Gt.A={"#":"£"};Gt.B=void 0;Gt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Gt.C=Gt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Gt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Gt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Gt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Gt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Gt.E=Gt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Gt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Gt.H=Gt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Gt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var tm=4294967295,sm=class{constructor(t,e,s){this._hasScrollback=t,this._optionsService=e,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Mt.clone(),this.savedCharset=yi,this.markers=[],this._nullCell=Gs.fromCharData([0,j5,1,0]),this._whitespaceCell=Gs.fromCharData([0,Zn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ql,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new em(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Kl),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Kl),this._whitespaceCell}getBlankLine(t,e){return new yo(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>tm?tm:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Mt);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new em(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Mt),n=0,i=this._getCorrectBufferLength(e);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<t)for(let a=0;a<this.lines.length;a++)n+=+this.lines.get(a).resize(t,s);let o=0;if(this._rows<e)for(let a=this._rows;a<e;a++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new yo(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new yo(t,s)));else for(let a=this._rows;a>e;a--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let a=this.lines.length-i;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=i}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let o=0;o<this.lines.length;o++)n+=+this.lines.get(o).resize(t,s);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,n=Pz(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Mt),s);if(n.length>0){let i=Rz(this.lines,n);Dz(this.lines,i.layout),this._reflowLargerAdjustViewport(t,e,i.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let n=this.getNullCell(Mt),i=s;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new yo(t,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(Mt),i=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=t)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!s){let _=this.ybase+this.y;if(_>=a&&_<a+c.length)continue}let d=c[c.length-1].getTrimmedLength(),h=Iz(c,this._cols,t),u=h.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let m=[];for(let _=0;_<u;_++){let y=this.getBlankLine(Mt,!0);m.push(y)}m.length>0&&(i.push({start:a+c.length+o,newLines:m}),o+=m.length),c.push(...m);let p=h.length-1,g=h[p];g===0&&(p--,g=h[p]);let x=c.length-u-1,v=d;for(;x>=0;){let _=Math.min(v,g);if(c[p]===void 0)break;if(c[p].copyCellsFrom(c[x],v-_,g-_,_,!0),g-=_,g===0&&(p--,g=h[p]),v-=_,v===0){x--;let y=Math.max(x,0);v=ta(c,y,this._cols)}}for(let _=0;_<c.length;_++)h[_]<t&&c[_].setCell(h[_],n);let b=u-f;for(;b-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+e-1)}if(i.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let c=this.lines.length,d=c-1,h=0,u=i[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,c+o-1);g>=0;g--)if(u&&u.start>d+f){for(let x=u.newLines.length-1;x>=0;x--)this.lines.set(g--,u.newLines[x]);g++,a.push({index:d+1,amount:u.newLines.length}),f+=u.newLines.length,u=i[++h]}else this.lines.set(g,l[d--]);let m=0;for(let g=a.length-1;g>=0;g--)a[g].index+=m,this.lines.onInsertEmitter.fire(a[g]),m+=a[g].amount;let p=Math.max(0,c+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(t,e,s=0,n){let i=this.lines.get(t);return i?i.translateToString(e,s,n):""}getWrappedRangeForLine(t){let e=t,s=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:e,last:s}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new Mz(t);return this.markers.push(e),e.register(this.lines.onTrim(s=>{e.line-=s,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(s=>{e.line>=s.index&&(e.line+=s.amount)})),e.register(this.lines.onDelete(s=>{e.line>=s.index&&e.line<s.index+s.amount&&e.dispose(),e.line>s.index&&(e.line-=s.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},Oz=class extends nt{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new Te),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new sm(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new sm(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(t,e){this._normal.resize(t,e),this._alt.resize(t,e),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},cx=2,dx=1,B0=class extends nt{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,cx),this.rows=Math.max(t.rawOptions.rows||0,dx),this.buffers=this._register(new Oz(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let s=this.cols!==t,n=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:s,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let s=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==t.fg||n.getBg(0)!==t.bg)&&(n=s.getBlankLine(t,e),this._cachedBlankLine=n),n.isWrapped=e;let i=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(n):s.lines.push(n.clone()):s.lines.splice(o+1,0,n.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-i+1;s.lines.shiftElements(i+1,a-1,-1),s.lines.set(o,n.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(t,e){let s=this.buffer;if(t<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else t+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let n=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),n!==s.ydisp&&(e||this._onScroll.fire(s.ydisp))}};B0=Rt([Oe(0,js)],B0);var rr={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Wl,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},$z=["normal","bold","100","200","300","400","500","600","700","800","900"],Bz=class extends nt{constructor(t){super(),this._onOptionChange=this._register(new Te),this.onOptionChange=this._onOptionChange.event;let e={...rr};for(let s in t)if(s in e)try{let n=t[s];e[s]=this._sanitizeAndValidateOption(s,n)}catch(n){console.error(n)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(wt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(t,e){return this.onOptionChange(s=>{s===t&&e(this.rawOptions[t])})}onMultipleOptionChange(t,e){return this.onOptionChange(s=>{t.indexOf(s)!==-1&&e()})}_setupOptions(){let t=s=>{if(!(s in rr))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,n)=>{if(!(s in rr))throw new Error(`No option with key "${s}"`);n=this._sanitizeAndValidateOption(s,n),this.rawOptions[s]!==n&&(this.rawOptions[s]=n,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let n={get:t.bind(this,s),set:e.bind(this,s)};Object.defineProperty(this.options,s,n)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=rr[t]),!Fz(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=rr[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=$z.includes(e)?e:rr[t];break;case"cursorWidth":e=Math.floor(e);case"lineHeight":case"tabStopWidth":if(e<1)throw new Error(`${t} cannot be less than 1, value: ${e}`);break;case"minimumContrastRatio":e=Math.max(1,Math.min(21,Math.round(e*10)/10));break;case"scrollback":if(e=Math.min(e,4294967295),e<0)throw new Error(`${t} cannot be less than 0, value: ${e}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(e<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${e}`);break;case"rows":case"cols":if(!e&&e!==0)throw new Error(`${t} must be numeric, value: ${e}`);break;case"windowsPty":e=e??{};break}return e}};function Fz(t){return t==="block"||t==="underline"||t==="bar"}function _o(t,e=5){if(typeof t!="object")return t;let s=Array.isArray(t)?[]:{};for(let n in t)s[n]=e<=1?t[n]:t[n]&&_o(t[n],e-1);return s}var nm=Object.freeze({insertMode:!1}),im=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),F0=class extends nt{constructor(t,e,s){super(),this._bufferService=t,this._logService=e,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Te),this.onData=this._onData.event,this._onUserInput=this._register(new Te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=_o(nm),this.decPrivateModes=_o(im)}reset(){this.modes=_o(nm),this.decPrivateModes=_o(im)}triggerDataEvent(t,e=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;e&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),e&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(n=>n.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(t))}};F0=Rt([Oe(0,ws),Oe(1,T5),Oe(2,js)],F0);var rm={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function Vd(t,e){let s=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(s|=64,s|=t.action):(s|=t.button&3,t.button&4&&(s|=64),t.button&8&&(s|=128),t.action===32?s|=32:t.action===0&&!e&&(s|=3)),s}var Nd=String.fromCharCode,om={DEFAULT:t=>{let e=[Vd(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Nd(e[0])}${Nd(e[1])}${Nd(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Vd(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Vd(t,!0)};${t.x};${t.y}${e}`}},z0=class extends nt{constructor(t,e,s){super(),this._bufferService=t,this._coreService=e,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Te),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(rm))this.addProtocol(n,rm[n]);for(let n of Object.keys(om))this.addEncoding(n,om[n]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,s){if(t.deltaY===0||t.shiftKey||e===void 0||s===void 0)return 0;let n=e/s,i=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=n+0,Math.abs(t.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,s){if(s){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};z0=Rt([Oe(0,ws),Oe(1,er),Oe(2,js)],z0);var Td=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],zz=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Ut;function Kz(t,e){let s=0,n=e.length-1,i;if(t<e[0][0]||t>e[n][1])return!1;for(;n>=s;)if(i=s+n>>1,t>e[i][1])s=i+1;else if(t<e[i][0])n=i-1;else return!0;return!1}var Uz=class{constructor(){if(this.version="6",!Ut){Ut=new Uint8Array(65536),Ut.fill(1),Ut[0]=0,Ut.fill(0,1,32),Ut.fill(0,127,160),Ut.fill(2,4352,4448),Ut[9001]=2,Ut[9002]=2,Ut.fill(2,11904,42192),Ut[12351]=1,Ut.fill(2,44032,55204),Ut.fill(2,63744,64256),Ut.fill(2,65040,65050),Ut.fill(2,65072,65136),Ut.fill(2,65280,65377),Ut.fill(2,65504,65511);for(let t=0;t<Td.length;++t)Ut.fill(0,Td[t][0],Td[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Ut[t]:Kz(t,zz)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let s=this.wcwidth(t),n=s===0&&e!==0;if(n){let i=wi.extractWidth(e);i===0?n=!1:i>s&&(s=i)}return wi.createPropertyValue(0,s,n)}},wi=class ol{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Te,this.onChange=this._onChange.event;let e=new Uz;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,s,n=!1){return(e&16777215)<<3|(s&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let s=0,n=0,i=e.length;for(let o=0;o<i;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=i)return s+this.wcwidth(a);let d=e.charCodeAt(o);56320<=d&&d<=57343?a=(a-55296)*1024+d-56320+65536:s+=this.wcwidth(d)}let l=this.charProperties(a,n),c=ol.extractWidth(l);ol.extractShouldJoin(l)&&(c-=ol.extractWidth(n)),s+=c,n=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},Hz=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,e){this._charsets[t]=e,this.glevel===t&&(this.charset=e)}};function am(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);s&&e&&(s.isWrapped=e[3]!==0&&e[3]!==32)}var oo=2147483647,Wz=256,ux=class K0{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>Wz)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let s=new K0;if(!e.length)return s;for(let n=Array.isArray(e[0])?1:0;n<e.length;++n){let i=e[n];if(Array.isArray(i))for(let o=0;o<i.length;++o)s.addSubParam(i[o]);else s.addParam(i)}return s}clone(){let e=new K0(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let s=0;s<this.length;++s){e.push(this.params[s]);let n=this._subParamsIdx[s]>>8,i=this._subParamsIdx[s]&255;i-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,i))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>oo?oo:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>oo?oo:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let s=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-s>0?this._subParams.subarray(s,n):null}getSubParamsAll(){let e={};for(let s=0;s<this.length;++s){let n=this._subParamsIdx[s]>>8,i=this._subParamsIdx[s]&255;i-n>0&&(e[s]=this._subParams.slice(n,i))}return e}addDigit(e){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,i=n[s-1];n[s-1]=~i?Math.min(i*10+e,oo):e}},ao=[],qz=class{constructor(){this._state=0,this._active=ao,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let n=s.indexOf(e);n!==-1&&s.splice(n,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ao}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=ao,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ao,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Pc(t,e,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(t,e,s)}start(){this.reset(),this._state=1}put(t,e,s){if(this._state!==3){if(this._state===1)for(;e<s;){let n=t[e++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&s-e>0&&this._put(t,e,s)}}end(t,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",t);else{let s=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=e,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;n>=0&&(s=this._active[n].end(t),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=ao,this._id=-1,this._state=0}}},Is=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Pc(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,e}},lo=[],Gz=class{constructor(){this._handlers=Object.create(null),this._active=lo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=lo}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let n=s.indexOf(e);n!==-1&&s.splice(n,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=lo,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||lo,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(e)}put(t,e,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Pc(t,e,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(t,e,s)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let s=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=e,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;n>=0&&(s=this._active[n].unhook(t),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=lo,this._ident=0}},Lo=new ux;Lo.addParam(0);var lm=class{constructor(t){this._handler=t,this._data="",this._params=Lo,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Lo,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Pc(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(s=>(this._params=Lo,this._data="",this._hitLimit=!1,s));return this._params=Lo,this._data="",this._hitLimit=!1,e}},Yz=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,n){this.table[e<<8|t]=s<<4|n}addMany(t,e,s,n){for(let i=0;i<t.length;i++)this.table[e<<8|t[i]]=s<<4|n}},qs=160,Jz=(function(){let t=new Yz(4095),e=Array.apply(null,Array(256)).map((l,c)=>c),s=(l,c)=>e.slice(l,c),n=s(32,127),i=s(0,24);i.push(25),i.push.apply(i,s(28,32));let o=s(0,14),a;t.setDefault(1,0),t.addMany(n,0,2,0);for(a in o)t.addMany([24,26,153,154],a,3,0),t.addMany(s(128,144),a,3,0),t.addMany(s(144,152),a,3,0),t.add(156,a,0,0),t.add(27,a,11,1),t.add(157,a,4,8),t.addMany([152,158,159],a,0,7),t.add(155,a,11,3),t.add(144,a,11,9);return t.addMany(i,0,3,0),t.addMany(i,1,3,1),t.add(127,1,0,1),t.addMany(i,8,0,8),t.addMany(i,3,3,3),t.add(127,3,0,3),t.addMany(i,4,3,4),t.add(127,4,0,4),t.addMany(i,6,3,6),t.addMany(i,5,3,5),t.add(127,5,0,5),t.addMany(i,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(n,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(s(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(n,7,0,7),t.addMany(i,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(s(64,127),3,7,0),t.addMany(s(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(s(48,60),4,8,4),t.addMany(s(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(s(32,64),6,0,6),t.add(127,6,0,6),t.addMany(s(64,127),6,0,0),t.addMany(s(32,48),3,9,5),t.addMany(s(32,48),5,9,5),t.addMany(s(48,64),5,0,6),t.addMany(s(64,127),5,7,0),t.addMany(s(32,48),4,9,5),t.addMany(s(32,48),1,9,2),t.addMany(s(32,48),2,9,2),t.addMany(s(48,127),2,10,0),t.addMany(s(48,80),1,10,0),t.addMany(s(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(s(96,127),1,10,0),t.add(80,1,11,9),t.addMany(i,9,0,9),t.add(127,9,0,9),t.addMany(s(28,32),9,0,9),t.addMany(s(32,48),9,9,12),t.addMany(s(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(i,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(i,10,0,10),t.add(127,10,0,10),t.addMany(s(28,32),10,0,10),t.addMany(s(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(s(32,48),10,9,12),t.addMany(i,12,0,12),t.add(127,12,0,12),t.addMany(s(28,32),12,0,12),t.addMany(s(32,48),12,9,12),t.addMany(s(48,64),12,0,11),t.addMany(s(64,127),12,12,13),t.addMany(s(64,127),10,12,13),t.addMany(s(64,127),9,12,13),t.addMany(i,13,13,13),t.addMany(n,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(qs,0,2,0),t.add(qs,8,5,8),t.add(qs,6,0,6),t.add(qs,11,0,11),t.add(qs,13,13,13),t})(),Xz=class extends nt{constructor(t=Jz){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new ux,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,s)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(wt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new qz),this._dcsParser=this._register(new Gz),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(t,e=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let i=0;i<t.intermediates.length;++i){let o=t.intermediates.charCodeAt(i);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(t.final.length!==1)throw new Error("final must be a single byte");let n=t.final.charCodeAt(0);if(e[0]>n||n>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=n,s}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(t&255)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let s=this._identifier(t,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let n=this._escHandlers[s];return n.push(e),{dispose:()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let s=this._identifier(t);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let n=this._csiHandlers[s];return n.push(e),{dispose:()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(t,e,s,n,i){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=n,this._parseStack.chunkPos=i}parse(t,e,s){let n=0,i=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 6:if(n=t[this._parseStack.chunkPos],a=this._dcsParser.unhook(n!==24&&n!==26,s),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=t[this._parseStack.chunkPos],a=this._oscParser.end(n!==24&&n!==26,s),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<e;++l){switch(n=t[l],i=this._transitions.table[this.currentState<<8|(n<160?n:qs)],i>>4){case 2:for(let f=l+1;;++f){if(f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|n],d=c?c.length-1:-1;for(;d>=0&&(a=c[d](this._params),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(3,c,d,i,l),a;d<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++l<e&&(n=t[l])>47&&n<60);l--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let h=this._escHandlers[this._collect<<8|n],u=h?h.length-1:-1;for(;u>=0&&(a=h[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,h,u,i,l),a;u<0&&this._escHandlerFb(this._collect<<8|n),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|n,this._params);break;case 13:for(let f=l+1;;++f)if(f>=e||(n=t[f])===24||n===26||n===27||n>127&&n<qs){this._dcsParser.put(t,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(n!==24&&n!==26),a)return this._preserveStack(6,[],0,i,l),a;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=e||(n=t[f])<32||n>127&&n<qs){this._oscParser.put(t,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(n!==24&&n!==26),a)return this._preserveStack(5,[],0,i,l),a;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},Qz=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,Zz=/^[\da-f]+$/;function cm(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=Qz.exec(e);if(s){let n=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/n*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/n*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/n*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),Zz.exec(e)&&[3,6,9,12].includes(e.length))){let s=e.length/3,n=[0,0,0];for(let i=0;i<3;++i){let o=parseInt(e.slice(s*i,s*i+s),16);n[i]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return n}}function Ad(t,e){let s=t.toString(16),n=s.length<2?"0"+s:s;switch(e){case 4:return s[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function eK(t,e=16){let[s,n,i]=t;return`rgb:${Ad(s,e)}/${Ad(n,e)}/${Ad(i,e)}`}var tK={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qn=131072,dm=10;function um(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var hm=5e3,fm=0,sK=class extends nt{constructor(t,e,s,n,i,o,a,l,c=new Xz){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=n,this._optionsService=i,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _B,this._utf8Decoder=new LB,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Mt.clone(),this._eraseAttrDataInternal=Mt.clone(),this._onRequestBell=this._register(new Te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Te),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new U0(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(d=>this._activeBuffer=d.activeBuffer)),this._parser.setCsiHandlerFallback((d,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(d),params:h.toArray()})}),this._parser.setEscHandlerFallback(d=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(d)})}),this._parser.setExecuteHandlerFallback(d=>{this._logService.debug("Unknown EXECUTE code: ",{code:d})}),this._parser.setOscHandlerFallback((d,h,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:d,action:h,data:u})}),this._parser.setDcsHandlerFallback((d,h,u)=>{h==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(d),action:h,payload:u})}),this._parser.setPrintHandler((d,h,u)=>this.print(d,h,u)),this._parser.registerCsiHandler({final:"@"},d=>this.insertChars(d)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},d=>this.scrollLeft(d)),this._parser.registerCsiHandler({final:"A"},d=>this.cursorUp(d)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},d=>this.scrollRight(d)),this._parser.registerCsiHandler({final:"B"},d=>this.cursorDown(d)),this._parser.registerCsiHandler({final:"C"},d=>this.cursorForward(d)),this._parser.registerCsiHandler({final:"D"},d=>this.cursorBackward(d)),this._parser.registerCsiHandler({final:"E"},d=>this.cursorNextLine(d)),this._parser.registerCsiHandler({final:"F"},d=>this.cursorPrecedingLine(d)),this._parser.registerCsiHandler({final:"G"},d=>this.cursorCharAbsolute(d)),this._parser.registerCsiHandler({final:"H"},d=>this.cursorPosition(d)),this._parser.registerCsiHandler({final:"I"},d=>this.cursorForwardTab(d)),this._parser.registerCsiHandler({final:"J"},d=>this.eraseInDisplay(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},d=>this.eraseInDisplay(d,!0)),this._parser.registerCsiHandler({final:"K"},d=>this.eraseInLine(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},d=>this.eraseInLine(d,!0)),this._parser.registerCsiHandler({final:"L"},d=>this.insertLines(d)),this._parser.registerCsiHandler({final:"M"},d=>this.deleteLines(d)),this._parser.registerCsiHandler({final:"P"},d=>this.deleteChars(d)),this._parser.registerCsiHandler({final:"S"},d=>this.scrollUp(d)),this._parser.registerCsiHandler({final:"T"},d=>this.scrollDown(d)),this._parser.registerCsiHandler({final:"X"},d=>this.eraseChars(d)),this._parser.registerCsiHandler({final:"Z"},d=>this.cursorBackwardTab(d)),this._parser.registerCsiHandler({final:"`"},d=>this.charPosAbsolute(d)),this._parser.registerCsiHandler({final:"a"},d=>this.hPositionRelative(d)),this._parser.registerCsiHandler({final:"b"},d=>this.repeatPrecedingCharacter(d)),this._parser.registerCsiHandler({final:"c"},d=>this.sendDeviceAttributesPrimary(d)),this._parser.registerCsiHandler({prefix:">",final:"c"},d=>this.sendDeviceAttributesSecondary(d)),this._parser.registerCsiHandler({final:"d"},d=>this.linePosAbsolute(d)),this._parser.registerCsiHandler({final:"e"},d=>this.vPositionRelative(d)),this._parser.registerCsiHandler({final:"f"},d=>this.hVPosition(d)),this._parser.registerCsiHandler({final:"g"},d=>this.tabClear(d)),this._parser.registerCsiHandler({final:"h"},d=>this.setMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"h"},d=>this.setModePrivate(d)),this._parser.registerCsiHandler({final:"l"},d=>this.resetMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"l"},d=>this.resetModePrivate(d)),this._parser.registerCsiHandler({final:"m"},d=>this.charAttributes(d)),this._parser.registerCsiHandler({final:"n"},d=>this.deviceStatus(d)),this._parser.registerCsiHandler({prefix:"?",final:"n"},d=>this.deviceStatusPrivate(d)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},d=>this.softReset(d)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},d=>this.setCursorStyle(d)),this._parser.registerCsiHandler({final:"r"},d=>this.setScrollRegion(d)),this._parser.registerCsiHandler({final:"s"},d=>this.saveCursor(d)),this._parser.registerCsiHandler({final:"t"},d=>this.windowOptions(d)),this._parser.registerCsiHandler({final:"u"},d=>this.restoreCursor(d)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},d=>this.insertColumns(d)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},d=>this.deleteColumns(d)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},d=>this.selectProtected(d)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},d=>this.requestMode(d,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},d=>this.requestMode(d,!1)),this._parser.setExecuteHandler(_e.BEL,()=>this.bell()),this._parser.setExecuteHandler(_e.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(_e.BS,()=>this.backspace()),this._parser.setExecuteHandler(_e.HT,()=>this.tab()),this._parser.setExecuteHandler(_e.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(_e.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(il.IND,()=>this.index()),this._parser.setExecuteHandler(il.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(il.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Is(d=>(this.setTitle(d),this.setIconName(d),!0))),this._parser.registerOscHandler(1,new Is(d=>this.setIconName(d))),this._parser.registerOscHandler(2,new Is(d=>this.setTitle(d))),this._parser.registerOscHandler(4,new Is(d=>this.setOrReportIndexedColor(d))),this._parser.registerOscHandler(8,new Is(d=>this.setHyperlink(d))),this._parser.registerOscHandler(10,new Is(d=>this.setOrReportFgColor(d))),this._parser.registerOscHandler(11,new Is(d=>this.setOrReportBgColor(d))),this._parser.registerOscHandler(12,new Is(d=>this.setOrReportCursorColor(d))),this._parser.registerOscHandler(104,new Is(d=>this.restoreIndexedColor(d))),this._parser.registerOscHandler(110,new Is(d=>this.restoreFgColor(d))),this._parser.registerOscHandler(111,new Is(d=>this.restoreBgColor(d))),this._parser.registerOscHandler(112,new Is(d=>this.restoreCursorColor(d))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let d in Gt)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(d=>(this._logService.error("Parsing error: ",d),d)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new lm((d,h)=>this.requestStatusString(d,h)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,s,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=s,this._parseStack.position=n}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),hm))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${hm} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,n=this._activeBuffer.x,i=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(s),s;n=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>qn&&(o=this._parseStack.position+qn)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,d=>String.fromCharCode(d)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(d=>d.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<qn&&(this._parseBuffer=new Uint32Array(Math.min(t.length,qn))),a||this._dirtyRowTracker.clearRange(),t.length>qn)for(let d=o;d<t.length;d+=qn){let h=d+qn<t.length?d+qn:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(d,h),this._parseBuffer):this._utf8Decoder.decode(t.subarray(d,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(n,i,u,d),this._logSlowResolvingAsync(s),s}else if(!a){let d=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(n,i,d,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==n||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(t,e,s){let n,i,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,h=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-e>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let m=e;m<s;++m){if(n=t[m],n<127&&o){let v=o[String.fromCharCode(n)];v&&(n=v.charCodeAt(0))}let p=this._unicodeService.charProperties(n,f);i=wi.extractWidth(p);let g=wi.extractShouldJoin(p),x=g?wi.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Yn(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-x>l){if(c){let v=u,b=this._activeBuffer.x-x;for(this._activeBuffer.x=x,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&u instanceof yo&&u.copyCellsFrom(v,b,0,x,!1);b<l;)v.setCellFromCodepoint(b++,0,1,h)}else if(this._activeBuffer.x=l-1,i===2)continue}if(g&&this._activeBuffer.x){let v=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-v,n,i);for(let b=i-x;--b>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(d&&(u.insertCells(this._activeBuffer.x,i-x,this._activeBuffer.getNullCell(h)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,h)),u.setCellFromCodepoint(this._activeBuffer.x++,n,i,h),i>0)for(;--i;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-e>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>um(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new lm(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Is(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,s,n=!1,i=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);o.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),i),n&&(o.isWrapped=!1)}_resetBufferLine(t,e=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),s.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let s;switch(t.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);s<this._bufferService.rows;s++)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;e--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;e--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Mt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let s=t.params[0]||1,n=wi.extractWidth(e),i=this._activeBuffer.x-n,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),a=new Uint32Array(o.length*s),l=0;for(let d=0;d<o.length;){let h=o.codePointAt(d)||0;a[l++]=h,d+=h>65535?2:1}let c=l;for(let d=1;d<s;++d)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(_e.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(_e.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(_e.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(_e.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(_e.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,yi),this._charsetService.setgCharset(1,yi),this._charsetService.setgCharset(2,yi),this._charsetService.setgCharset(3,yi);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){let s;(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let n=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:d,alt:h}=l,u=this._optionsService.rawOptions,f=(g,x)=>(a.triggerDataEvent(`${_e.ESC}[${e?"":"?"}${g};${x}$y`),!0),m=g=>g?1:2,p=t.params[0];return e?p===2?f(p,4):p===4?f(p,m(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,m(u.convertEol)):f(p,0):p===1?f(p,m(n.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):p===6?f(p,m(n.origin)):p===7?f(p,m(n.wraparound)):p===8?f(p,3):p===9?f(p,m(i==="X10")):p===12?f(p,m(u.cursorBlink)):p===25?f(p,m(!a.isCursorHidden)):p===45?f(p,m(n.reverseWraparound)):p===66?f(p,m(n.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,m(i==="VT200")):p===1002?f(p,m(i==="DRAG")):p===1003?f(p,m(i==="ANY")):p===1004?f(p,m(n.sendFocus)):p===1005?f(p,4):p===1006?f(p,m(o==="SGR")):p===1015?f(p,4):p===1016?f(p,m(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,m(d===h)):p===2004?f(p,m(n.bracketedPasteMode)):p===2026?f(p,m(n.synchronizedOutput)):f(p,0)}_updateAttrColor(t,e,s,n,i){return e===2?(t|=50331648,t&=-16777216,t|=va.fromColorRGB([s,n,i])):e===5&&(t&=-50331904,t|=33554432|s&255),t}_extractColor(t,e,s){let n=[0,0,-1,0,0,0],i=0,o=0;do{if(n[o+i]=t.params[e+o],t.hasSubParams(e+o)){let a=t.getSubParams(e+o),l=0;do n[1]===5&&(i=1),n[o+l+1+i]=a[l];while(++l<a.length&&l+o+1+i<n.length);break}if(n[1]===5&&o+i>=2||n[1]===2&&o+i>=5)break;n[1]&&(i=1)}while(++o+e<t.length&&o+i<n.length);for(let a=2;a<n.length;++a)n[a]===-1&&(n[a]=0);switch(n[0]){case 38:s.fg=this._updateAttrColor(s.fg,n[1],n[3],n[4],n[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,n[1],n[3],n[4],n[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,n[1],n[3],n[4],n[5])}return o}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=Mt.fg,t.bg=Mt.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,s,n=this._curAttrData;for(let i=0;i<e;i++)s=t.params[i],s>=30&&s<=37?(n.fg&=-50331904,n.fg|=16777216|s-30):s>=40&&s<=47?(n.bg&=-50331904,n.bg|=16777216|s-40):s>=90&&s<=97?(n.fg&=-50331904,n.fg|=16777216|s-90|8):s>=100&&s<=107?(n.bg&=-50331904,n.bg|=16777216|s-100|8):s===0?this._processSGR0(n):s===1?n.fg|=134217728:s===3?n.bg|=67108864:s===4?(n.fg|=268435456,this._processUnderline(t.hasSubParams(i)?t.getSubParams(i)[0]:1,n)):s===5?n.fg|=536870912:s===7?n.fg|=67108864:s===8?n.fg|=1073741824:s===9?n.fg|=2147483648:s===2?n.bg|=134217728:s===21?this._processUnderline(2,n):s===22?(n.fg&=-134217729,n.bg&=-134217729):s===23?n.bg&=-67108865:s===24?(n.fg&=-268435457,this._processUnderline(0,n)):s===25?n.fg&=-536870913:s===27?n.fg&=-67108865:s===28?n.fg&=-1073741825:s===29?n.fg&=2147483647:s===39?(n.fg&=-67108864,n.fg|=Mt.fg&16777215):s===49?(n.bg&=-67108864,n.bg|=Mt.bg&16777215):s===38||s===48||s===58?i+=this._extractColor(t,i,n):s===53?n.bg|=1073741824:s===55?n.bg&=-1073741825:s===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):s===100?(n.fg&=-67108864,n.fg|=Mt.fg&16777215,n.bg&=-67108864,n.bg|=Mt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${_e.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${_e.ESC}[${e};${s}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${_e.ESC}[?${e};${s}R`)}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Mt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=e%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(t){let e=t.params[0]||1,s;return(t.length<2||(s=t.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(t){if(!um(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${_e.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>dm&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>dm&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(t){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],s=t.split(";");for(;s.length>1;){let n=s.shift(),i=s.shift();if(/^\d+$/.exec(n)){let o=parseInt(n);if(mm(o))if(i==="?")e.push({type:0,index:o});else{let a=cm(i);a&&e.push({type:1,index:o,color:a})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let s=t.slice(0,e).trim(),n=t.slice(e+1);return n?this._createHyperlink(s,n):s.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let s=t.split(":"),n,i=s.findIndex(o=>o.startsWith("id="));return i!==-1&&(n=s[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let s=t.split(";");for(let n=0;n<s.length&&!(e>=this._specialColors.length);++n,++e)if(s[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let i=cm(s[n]);i&&this._onColor.fire([{type:1,index:this._specialColors[e],color:i}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],s=t.split(";");for(let n=0;n<s.length;++n)if(/^\d+$/.exec(s[n])){let i=parseInt(s[n]);mm(i)&&e.push({type:2,index:i})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,yi),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(tK[t[0]],Gt[t[1]]||yi),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Mt.clone(),this._eraseAttrDataInternal=Mt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new Gs;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let s=this._activeBuffer.ybase+this._activeBuffer.y+e,n=this._activeBuffer.lines.get(s);n&&(n.fill(t),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let s=a=>(this._coreService.triggerDataEvent(`${_e.ESC}${a}${_e.ESC}\\`),!0),n=this._bufferService.buffer,i=this._optionsService.rawOptions;return s(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},U0=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(fm=t,t=e,e=fm),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};U0=Rt([Oe(0,ws)],U0);function mm(t){return 0<=t&&t<256}var nK=5e7,pm=12,iK=50,rK=class extends nt{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Te),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,e){if(e!==void 0&&this._syncCalls>e){this._syncCalls=0;return}if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>nK)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e)}_innerWrite(t=0,e=!0){let s=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],i=this._action(n,e);if(i){let a=l=>performance.now()-s>=pm?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-s>=pm)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>iK&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},H0=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let l=e.addMarker(e.ybase+e.y),c={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._dataByLinkId.set(c.id,c),c.id}let s=t,n=this._getEntryIdKey(s),i=this._entriesWithId.get(n);if(i)return this.addLineToLink(i.id,e.ybase+e.y),i.id;let o=e.addMarker(e.ybase+e.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(t,e){let s=this._dataByLinkId.get(t);if(s&&s.lines.every(n=>n.line!==e)){let n=this._bufferService.buffer.addMarker(e);s.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(s,n))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let s=t.lines.indexOf(e);s!==-1&&(t.lines.splice(s,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};H0=Rt([Oe(0,ws)],H0);var gm=!1,oK=class extends nt{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new Cr),this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onData=this._register(new Te),this.onData=this._onData.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Te),this._instantiationService=new Tz,this.optionsService=this._register(new Bz(t)),this._instantiationService.setService(js,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(B0)),this._instantiationService.setService(ws,this._bufferService),this._logService=this._register(this._instantiationService.createInstance($0)),this._instantiationService.setService(T5,this._logService),this.coreService=this._register(this._instantiationService.createInstance(F0)),this._instantiationService.setService(er,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(z0)),this._instantiationService.setService(N5,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(wi)),this._instantiationService.setService(CB,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Hz),this._instantiationService.setService(jB,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(H0),this._instantiationService.setService(A5,this._oscLinkService),this._inputHandler=this._register(new sK(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(as.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(as.forward(this._bufferService.onResize,this._onResize)),this._register(as.forward(this.coreService.onData,this._onData)),this._register(as.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new rK((e,s)=>this._inputHandler.parse(e,s))),this._register(as.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Te),this._onScroll.event(t=>{this._onScrollApi?.fire(t.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(t){for(let e in t)this.optionsService.options[e]=t[e]}write(t,e){this._writeBuffer.write(t,e)}writeSync(t,e){this._logService.logLevel<=3&&!gm&&(this._logService.warn("writeSync is unreliable and will be removed soon."),gm=!0),this._writeBuffer.writeSync(t,e)}input(t,e=!0){this.coreService.triggerDataEvent(t,e)}resize(t,e){isNaN(t)||isNaN(e)||(t=Math.max(t,cx),e=Math.max(e,dx),this._bufferService.resize(t,e))}scroll(t,e=!1){this._bufferService.scroll(t,e)}scrollLines(t,e){this._bufferService.scrollLines(t,e)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}registerEscHandler(t,e){return this._inputHandler.registerEscHandler(t,e)}registerDcsHandler(t,e){return this._inputHandler.registerDcsHandler(t,e)}registerCsiHandler(t,e){return this._inputHandler.registerCsiHandler(t,e)}registerOscHandler(t,e){return this._inputHandler.registerOscHandler(t,e)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,e=this.optionsService.rawOptions.windowsPty;e&&e.buildNumber!==void 0&&e.buildNumber!==void 0?t=e.backend==="conpty"&&e.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(am.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(am(this._bufferService),!1))),this._windowsWrappingHeuristics.value=wt(()=>{for(let e of t)e.dispose()})}}},aK={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function lK(t,e,s,n){let i={type:0,cancel:!1,key:void 0},o=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?i.key=_e.ESC+"OA":i.key=_e.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?i.key=_e.ESC+"OD":i.key=_e.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?i.key=_e.ESC+"OC":i.key=_e.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?i.key=_e.ESC+"OB":i.key=_e.ESC+"[B");break;case 8:i.key=t.ctrlKey?"\b":_e.DEL,t.altKey&&(i.key=_e.ESC+i.key);break;case 9:if(t.shiftKey){i.key=_e.ESC+"[Z";break}i.key=_e.HT,i.cancel=!0;break;case 13:i.key=t.altKey?_e.ESC+_e.CR:_e.CR,i.cancel=!0;break;case 27:i.key=_e.ESC,t.altKey&&(i.key=_e.ESC+_e.ESC),i.cancel=!0;break;case 37:if(t.metaKey)break;o?i.key=_e.ESC+"[1;"+(o+1)+"D":e?i.key=_e.ESC+"OD":i.key=_e.ESC+"[D";break;case 39:if(t.metaKey)break;o?i.key=_e.ESC+"[1;"+(o+1)+"C":e?i.key=_e.ESC+"OC":i.key=_e.ESC+"[C";break;case 38:if(t.metaKey)break;o?i.key=_e.ESC+"[1;"+(o+1)+"A":e?i.key=_e.ESC+"OA":i.key=_e.ESC+"[A";break;case 40:if(t.metaKey)break;o?i.key=_e.ESC+"[1;"+(o+1)+"B":e?i.key=_e.ESC+"OB":i.key=_e.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(i.key=_e.ESC+"[2~");break;case 46:o?i.key=_e.ESC+"[3;"+(o+1)+"~":i.key=_e.ESC+"[3~";break;case 36:o?i.key=_e.ESC+"[1;"+(o+1)+"H":e?i.key=_e.ESC+"OH":i.key=_e.ESC+"[H";break;case 35:o?i.key=_e.ESC+"[1;"+(o+1)+"F":e?i.key=_e.ESC+"OF":i.key=_e.ESC+"[F";break;case 33:t.shiftKey?i.type=2:t.ctrlKey?i.key=_e.ESC+"[5;"+(o+1)+"~":i.key=_e.ESC+"[5~";break;case 34:t.shiftKey?i.type=3:t.ctrlKey?i.key=_e.ESC+"[6;"+(o+1)+"~":i.key=_e.ESC+"[6~";break;case 112:o?i.key=_e.ESC+"[1;"+(o+1)+"P":i.key=_e.ESC+"OP";break;case 113:o?i.key=_e.ESC+"[1;"+(o+1)+"Q":i.key=_e.ESC+"OQ";break;case 114:o?i.key=_e.ESC+"[1;"+(o+1)+"R":i.key=_e.ESC+"OR";break;case 115:o?i.key=_e.ESC+"[1;"+(o+1)+"S":i.key=_e.ESC+"OS";break;case 116:o?i.key=_e.ESC+"[15;"+(o+1)+"~":i.key=_e.ESC+"[15~";break;case 117:o?i.key=_e.ESC+"[17;"+(o+1)+"~":i.key=_e.ESC+"[17~";break;case 118:o?i.key=_e.ESC+"[18;"+(o+1)+"~":i.key=_e.ESC+"[18~";break;case 119:o?i.key=_e.ESC+"[19;"+(o+1)+"~":i.key=_e.ESC+"[19~";break;case 120:o?i.key=_e.ESC+"[20;"+(o+1)+"~":i.key=_e.ESC+"[20~";break;case 121:o?i.key=_e.ESC+"[21;"+(o+1)+"~":i.key=_e.ESC+"[21~";break;case 122:o?i.key=_e.ESC+"[23;"+(o+1)+"~":i.key=_e.ESC+"[23~";break;case 123:o?i.key=_e.ESC+"[24;"+(o+1)+"~":i.key=_e.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?i.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?i.key=_e.NUL:t.keyCode>=51&&t.keyCode<=55?i.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?i.key=_e.DEL:t.keyCode===219?i.key=_e.ESC:t.keyCode===220?i.key=_e.FS:t.keyCode===221&&(i.key=_e.GS);else if((!s||n)&&t.altKey&&!t.metaKey){let a=aK[t.keyCode]?.[t.shiftKey?1:0];if(a)i.key=_e.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,c=String.fromCharCode(l);t.shiftKey&&(c=c.toUpperCase()),i.key=_e.ESC+c}else if(t.keyCode===32)i.key=_e.ESC+(t.ctrlKey?_e.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),i.key=_e.ESC+l,i.cancel=!0}}else s&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(i.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?i.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(i.key=_e.US),t.key==="@"&&(i.key=_e.NUL));break}return i}var Dt=0,cK=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ql,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ql,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(t){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort((i,o)=>this._getKey(i)-this._getKey(o)),e=0,s=0,n=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<n.length;i++)s>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[s])?(n[i]=t[e],e++):n[i]=this._array[s++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),this._array.length===0)return!1;let e=this._getKey(t);if(e===void 0||(Dt=this._search(e),Dt===-1)||this._getKey(this._array[Dt])!==e)return!1;do if(this._array[Dt]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Dt),!0;while(++Dt<this._array.length&&this._getKey(this._array[Dt])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((i,o)=>i-o),e=0,s=new Array(this._array.length-t.length),n=0;for(let i=0;i<this._array.length;i++)t[e]===i?e++:s[n++]=this._array[i];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Dt=this._search(t),!(Dt<0||Dt>=this._array.length)&&this._getKey(this._array[Dt])===t))do yield this._array[Dt];while(++Dt<this._array.length&&this._getKey(this._array[Dt])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Dt=this._search(t),!(Dt<0||Dt>=this._array.length)&&this._getKey(this._array[Dt])===t))do e(this._array[Dt]);while(++Dt<this._array.length&&this._getKey(this._array[Dt])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,s=this._array.length-1;for(;s>=e;){let n=e+s>>1,i=this._getKey(this._array[n]);if(i>t)s=n-1;else if(i<t)e=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===t;)n--;return n}}return e}},Ed=0,xm=0,dK=class extends nt{constructor(){super(),this._decorations=new cK(t=>t?.marker.line),this._onDecorationRegistered=this._register(new Te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(wt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new uK(t);if(e){let s=e.marker.onDispose(()=>e.dispose()),n=e.onDispose(()=>{n.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),s.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,s){let n=0,i=0;for(let o of this._decorations.getKeyIterator(e))n=o.options.x??0,i=n+(o.options.width??1),t>=n&&t<i&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(t,e,s,n){this._decorations.forEachByKey(e,i=>{Ed=i.options.x??0,xm=Ed+(i.options.width??1),t>=Ed&&t<xm&&(!s||(i.options.layer??"bottom")===s)&&n(i)})}},uK=class extends ni{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Te),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=kt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=kt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},hK=1e3,fK=class{constructor(t,e=hK){this._renderCallback=t,this._debounceThresholdMS=e,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e;let n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=n-this._lastRefreshMs,o=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e)}},vm=20,Gl=class extends nt{constructor(t,e,s,n){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new fK(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
488
- `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ye(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(wt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<vm+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
489
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===vm+1&&(this._liveRegion.textContent+=u0.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let s=this._terminal.buffer,n=s.lines.length.toString();for(let i=t;i<=e;i++){let o=s.lines.get(s.ydisp+i),a=[],l=o?.translateToString(!0,void 0,void 0,a)||"",c=(s.ydisp+i+1).toString(),d=this._rowElements[i];d&&(l.length===0?(d.textContent=" ",this._rowColumns.set(d,[0,1])):(d.textContent=l,this._rowColumns.set(d,a)),d.setAttribute("aria-posinset",c),d.setAttribute("aria-setsize",n),this._alignRowWidth(d))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let s=t.target,n=this._rowElements[e===0?1:this._rowElements.length-2],i=s.getAttribute("aria-posinset"),o=e===0?"1":`${this._terminal.buffer.lines.length}`;if(i===o||t.relatedTarget!==n)return;let a,l;if(e===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===s.node&&e.offset>s.offset)&&([e,s]=[s,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let n=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let i=({node:l,offset:c})=>{let d=l instanceof Text?l.parentNode:l,h=parseInt(d?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(d);if(!u)return console.warn("columns is null. Race condition?"),null;let f=c<u.length?u[c]:u.slice(-1)[0]+1;return f>=this._terminal.cols&&(++h,f=0),{row:h,column:f}},o=i(e),a=i(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){t.style.transform="";let e=t.getBoundingClientRect().width,s=this._rowColumns.get(t)?.slice(-1)?.[0];if(!s)return;let n=s*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${n/e})`}};Gl=Rt([Oe(1,Mu),Oe(2,Fn),Oe(3,zn)],Gl);var W0=class extends nt{constructor(t,e,s,n,i){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=n,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(wt(()=>{Bi(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ye(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ye(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ye(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ye(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let s=t.composedPath();for(let n=0;n<s.length;n++){let i=s[n];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){(!this._activeProviderReplies||!e)&&(this._activeProviderReplies?.forEach(n=>{n?.forEach(i=>{i.link.dispose&&i.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[n,i]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(n)&&(s=this._checkLinkProviderResult(n,t,s)):i.provideLinks(t.y,o=>{if(this._isMouseOut)return;let a=o?.map(l=>({link:l}));this._activeProviderReplies?.set(n,a),s=this._checkLinkProviderResult(n,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let s=new Set;for(let n=0;n<e.size;n++){let i=e.get(n);if(i)for(let o=0;o<i.length;o++){let a=i[o],l=a.link.range.start.y<t?0:a.link.range.start.x,c=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let d=l;d<=c;d++){if(s.has(d)){i.splice(o--,1);break}s.add(d)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let n=this._activeProviderReplies.get(t),i=!1;for(let o=0;o<t;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(i=!0);if(!i&&n){let o=n.find(a=>this._linkAtPosition(a.link,e));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let a=this._activeProviderReplies.get(o)?.find(l=>this._linkAtPosition(l.link,e));if(a){s=!0,this._handleNewLink(a);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&mK(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Bi(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let n=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(n,i),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(s,e.text)}_fireUnderlineEvent(t,e){let s=t.range,n=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-n-1,s.end.x,s.end.y-n-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(s,e.text)}_linkAtPosition(t,e){let s=t.range.start.y*this._bufferService.cols+t.range.start.x,n=t.range.end.y*this._bufferService.cols+t.range.end.x,i=e.y*this._bufferService.cols+e.x;return s<=i&&i<=n}_positionFromMouseEvent(t,e,s){let n=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,n,i){return{x1:t,y1:e,x2:s,y2:n,cols:this._bufferService.cols,fg:i}}};W0=Rt([Oe(1,Ou),Oe(2,zn),Oe(3,ws),Oe(4,P5)],W0);function mK(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var pK=class extends oK{constructor(t={}){super(t),this._linkifier=this._register(new Cr),this.browser=Q5,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Cr),this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Te),this.onKey=this._onKey.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Te),this.onBell=this._onBell.event,this._onFocus=this._register(new Te),this._onBlur=this._register(new Te),this._onA11yCharEmitter=this._register(new Te),this._onA11yTabEmitter=this._register(new Te),this._onWillOpen=this._register(new Te),this._setup(),this._decorationService=this._instantiationService.createInstance(dK),this._instantiationService.setService(ba,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(iz),this._instantiationService.setService(P5,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(f0)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(as.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(as.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(as.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(as.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(wt(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(t){if(this._themeService)for(let e of t){let s,n="";switch(e.index){case 256:s="foreground",n="10";break;case 257:s="background",n="11";break;case 258:s="cursor",n="12";break;default:s="ansi",n="4;"+e.index}switch(e.type){case 0:let i=yt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${_e.ESC}]${n};${eK(i)}${J5.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=Ot.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ot.toColor(...e.color))}break;case 2:this._themeService.restoreColor(e.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Gl,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(_e.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(_e.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.ybase+this.buffer.y,e=this.buffer.lines.get(t);if(!e)return;let s=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,i=e.getWidth(s),o=this._renderService.dimensions.css.cell.width*i,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ye(this.element,"copy",e=>{this.hasSelection()&&bB(e,this._selectionService)}));let t=e=>yB(e,this.textarea,this.coreService,this.optionsService);this._register(Ye(this.textarea,"paste",t)),this._register(Ye(this.element,"paste",t)),Z5?this._register(Ye(this.element,"mousedown",e=>{e.button===2&&V1(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ye(this.element,"contextmenu",e=>{V1(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Wu&&this._register(Ye(this.element,"auxclick",e=>{e.button===1&&w5(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ye(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(Ye(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(Ye(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(Ye(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ye(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(Ye(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ye(this.textarea,"input",t=>this._inputEvent(t),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(t){if(!t)throw new Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=t.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),t.appendChild(this.element);let e=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),e.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ye(this.screenElement,"mousemove",i=>this.updateCursorStyle(i))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),e.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",d0.get()),sx||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(sz,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Fn,this._coreBrowserService),this._register(Ye(this.textarea,"focus",i=>this._handleTextAreaFocus(i))),this._register(Ye(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(R0,this._document,this._helperContainer),this._instantiationService.setService(Rc,this._charSizeService),this._themeService=this._instantiationService.createInstance(O0),this._instantiationService.setService(qr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Hl),this._instantiationService.setService(E5,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(I0,this.rows,this.screenElement)),this._instantiationService.setService(zn,this._renderService),this._register(this._renderService.onRenderedViewportChange(i=>this._onRender.fire(i))),this.onResize(i=>this._renderService.resize(i.cols,i.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(A0,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(D0),this._instantiationService.setService(Ou,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(W0,this.screenElement));this.element.appendChild(e);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(N0,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(i=>{super.scrollLines(i,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(M0,this.element,this.screenElement,n)),this._instantiationService.setService(VB,this._selectionService),this._register(this._selectionService.onRequestScrollLines(i=>this.scrollLines(i.amount,i.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(i=>this._renderService.handleSelectionChanged(i.start,i.end,i.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(i=>{this.textarea.value=i,this.textarea.focus(),this.textarea.select()})),this._register(as.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(T0,this.screenElement)),this._register(Ye(this.element,"mousedown",i=>this._selectionService.handleMouseDown(i))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Gl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",i=>this._handleScreenReaderModeOptionChange(i))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ul,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",i=>{!this._overviewRulerRenderer&&i&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ul,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(P0,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(o){let a=t._mouseService.getMouseReportCoords(o,t.screenElement);if(!a)return!1;let l,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,l=o.button<3?o.button:3;break;case"mousedown":c=1,l=o.button<3?o.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(o)===!1)return!1;let d=o.deltaY;if(d===0||t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;c=d<0?0:1,l=4;break;default:return!1}return c===void 0||l===void 0||l>4?!1:t.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?n.mousemove||(e.addEventListener("mousemove",i.mousemove),n.mousemove=i.mousemove):(e.removeEventListener("mousemove",n.mousemove),n.mousemove=null),o&16?n.wheel||(e.addEventListener("wheel",i.wheel,{passive:!1}),n.wheel=i.wheel):(e.removeEventListener("wheel",n.wheel),n.wheel=null),o&2?n.mouseup||(n.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),o&4?n.mousedrag||(n.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ye(e,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(o)})),this._register(Ye(e,"wheel",o=>{if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=_e.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(t,e){this._renderService?.refreshRows(t,e)}updateCursorStyle(t){this._selectionService?.shouldColumnSelect(t)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(t,e){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,e),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}paste(t){S5(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let e=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),e}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(t,e,s){this._selectionService.setSelection(t,e,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(t,e){this._selectionService?.selectLines(t,e)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;let e=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!e&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!e&&(t.key==="Dead"||t.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=lK(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),s.type===3||s.type===2){let n=this.rows-1;return this.scrollLines(s.type===2?-n:n),this.cancel(t,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,t)||(s.cancel&&this.cancel(t,!0),!s.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.key.length===1&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===_e.ETX||s.key===_e.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey)return this.cancel(t,!0);this._keyDownHandled=!0}_isThirdLevelShift(t,e){let s=t.isMac&&!this.options.macOptionIsMeta&&e.altKey&&!e.ctrlKey&&!e.metaKey||t.isWindows&&e.altKey&&e.ctrlKey&&!e.metaKey||t.isWindows&&e.getModifierState("AltGraph");return e.type==="keypress"?s:s&&(!e.keyCode||e.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)&&(gK(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let e;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;if(this.cancel(t),t.charCode)e=t.charCode;else if(t.which===null||t.which===void 0)e=t.keyCode;else if(t.which!==0&&t.charCode!==0)e=t.which;else return!1;return!e||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)?!1:(e=String.fromCharCode(e),this._onKey.fire({key:e,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(e,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(t){if(t.data&&t.inputType==="insertText"&&(!t.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let e=t.data;return this.coreService.triggerDataEvent(e,!0),this.cancel(t),!0}return!1}resize(t,e){if(t===this.cols&&e===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(t,e)}_afterResize(t,e){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t<this.rows;t++)this.buffer.lines.push(this.buffer.getBlankLine(Mt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let t=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(_e.ESC+"[I"):this.coreService.triggerDataEvent(_e.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${_e.ESC}[4;${s};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${_e.ESC}[6;${i};${n}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function gK(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var xK=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let s={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(s),e.dispose=()=>this._wrappedAddonDispose(s),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===t){e=s;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(e,1)}},vK=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,e){if(!(t<0||t>=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new Gs)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},bm=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(t){let e=this._buffer.lines.get(t);if(e)return new vK(e)}getNullCell(){return new Gs}},bK=class extends nt{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Te),this.onBufferChange=this._onBufferChange.event,this._normal=new bm(this._core.buffers.normal,"normal"),this._alternate=new bm(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},yK=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,s=>e(s.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(s,n)=>e(s,n.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},_K=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},LK=["cols","rows"],un=0,SK=class extends nt{constructor(t){super(),this._core=this._register(new pK(t)),this._addonManager=this._register(new xK),this._publicOptions={...this._core.options};let e=n=>this._core.options[n],s=(n,i)=>{this._checkReadonlyOptions(n),this._core.options[n]=i};for(let n in this._core.options){let i={get:e.bind(this,n),set:s.bind(this,n)};Object.defineProperty(this._publicOptions,n,i)}}_checkReadonlyOptions(t){if(LK.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new yK(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new _K(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new bK(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,s){this._verifyIntegers(t,e,s),this._core.select(t,e,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
490
- `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return d0.get()},set promptLabel(t){d0.set(t)},get tooMuchOutput(){return u0.get()},set tooMuchOutput(t){u0.set(t)}}}_verifyIntegers(...t){for(un of t)if(un===1/0||isNaN(un)||un%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(un of t)if(un&&(un===1/0||isNaN(un)||un%1!==0||un<0))throw new Error("This API only accepts positive integers")}};var wK=2,jK=1,CK=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(s.getPropertyValue("height")),i=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,c=a.right+a.left,d=n-l,h=i-c-e;return{cols:Math.max(wK,Math.floor(h/t.css.cell.width)),rows:Math.max(jK,Math.floor(d/t.css.cell.height))}}};function kK({source:t,onReady:e,onSelectionChange:s,className:n}){const i=N.useRef(null),o=N.useRef(null),a=N.useRef(s);a.current=s;const l=Ps(),c=N.useRef(t);return c.current=t,f3((d,h)=>{d===c.current&&o.current?.write(h)}),N.useEffect(()=>{const d=i.current;if(!d)return;const h=getComputedStyle(document.documentElement),u=v=>h.getPropertyValue(v).trim()||void 0,f=new SK({allowTransparency:!1,fontFamily:u("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:u("--sidebar")||u("--card")||u("--background")||"#1e1e1e",cursor:"transparent",foreground:u("--foreground")||"#d4d4d4",selectionBackground:u("--accent"),selectionForeground:u("--accent-foreground"),black:u("--muted"),red:u("--destructive"),green:u("--success"),yellow:u("--warning"),blue:u("--chart-1"),magenta:u("--chart-3"),cyan:u("--chart-5"),white:u("--foreground"),brightBlack:u("--muted-foreground"),brightRed:u("--destructive"),brightGreen:u("--success"),brightYellow:u("--warning"),brightBlue:u("--chart-1"),brightMagenta:u("--chart-3"),brightCyan:u("--chart-5"),brightWhite:u("--foreground")}}),m=new CK;f.loadAddon(m),f.open(d),m.fit();const p=l.getBuffer(t);p&&f.write(p),o.current=f,e?.(f);const g=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),x=new ResizeObserver(()=>{m.fit()});return x.observe(d),()=>{g.dispose(),x.disconnect(),o.current=null,f.dispose()}},[]),r.jsx("div",{className:ie("h-full bg-sidebar p-3",n),children:r.jsx("div",{ref:i,className:"h-full"})})}function VK(t){const e=oe(),s=Ps(),[n,i]=N.useState(ki),[o,a]=N.useState([]),[l,c]=N.useState(new Set),d=N.useRef(!1);if(!d.current&&s.scripts.length>0){const w=CS.find(j=>s.scripts.includes(j));w&&(d.current=!0,a(j=>j.includes(w)?j:[...j,w]),i(w))}if(l.size>0){let w=!1;const j=new Set(l);for(const S of l)s.activeProcesses.includes(S)||(j.delete(S),w=!0);w&&c(j)}const h=()=>t.onOpenChange(!t.open),u=w=>{i(w),t.open||t.onOpenChange(!0)},f=w=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(w)}`,{method:"POST"}),m=w=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(w)}/kill`,{method:"POST"}),p=async(w,j)=>{try{const S=await f(w);if(S===null)return;if(!S.ok)throw new Error(`Exec failed: ${S.statusText}`)}catch{ve.error(j)}},g=async w=>{a(j=>j.includes(w)?j:[...j,w]),i(w),t.onOpenChange(!0),await p(w,e("sandbox.drawer.failedToRun",{name:w}))},x=async w=>{await m(w),a(j=>j.filter(S=>S!==w)),n===w&&i(ki)},v=async()=>{const j=s.activeProcesses.includes(n)?e("sandbox.drawer.failedToRestart",{name:n}):e("sandbox.drawer.failedToRun",{name:n});await p(n,j)},b=async()=>{if(!l.has(n)){c(w=>new Set(w).add(n));try{const w=await m(n);if(w===null){c(j=>{const S=new Set(j);return S.delete(n),S});return}if(!w.ok)throw new Error(`Kill failed: ${w.statusText}`)}catch{c(w=>{const j=new Set(w);return j.delete(n),j}),ve.error(e("sandbox.drawer.failedToStop",{name:n}))}}},_=n!==ki&&o.includes(n),y=_&&s.activeProcesses.includes(n),L=_&&l.has(n);return r.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[r.jsx(cB,{status:t.status,open:t.open,onToggle:h,onStart:t.status==="idle"?t.onStart:void 0,onStop:t.status==="running"||t.status==="starting"?t.onStop:void 0,onRestart:t.status==="running"?t.onRestart:void 0,onResume:t.status==="suspended"?t.onResume:void 0,onRetry:t.status==="errored"?t.onRetry:void 0,scripts:t.scripts,active:n,scriptTabs:o,onSelectTab:u,onAddScript:g,onCloseScript:x,showScriptControls:_,scriptIsRunning:y,scriptIsKilling:L,onRunActiveScript:v,onStopActiveScript:b}),t.open&&r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(NK,{vmId:t.vmId,active:n,hasData:s.hasData(n),onRunActive:v})})]})}function NK(t){const e=F.c(16),{vmId:s,active:n,hasData:i,onRunActive:o}=t,a=oe();if(!s)return null;if(n===ki||i){let m;return e[0]!==n?(m=r.jsx(kK,{source:n,className:"h-full"},n),e[0]=n,e[1]=m):m=e[1],m}let l;e[2]!==n||e[3]!==a?(l=a("sandbox.drawer.scriptNotRunning",{name:n}),e[2]=n,e[3]=a,e[4]=l):l=e[4];let c;e[5]!==l?(c=r.jsx("p",{children:l}),e[5]=l,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Di,{className:"size-3.5"}),e[7]=d):d=e[7];let h;e[8]!==a?(h=a("sandbox.drawer.run"),e[8]=a,e[9]=h):h=e[9];let u;e[10]!==o||e[11]!==h?(u=r.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground hover:bg-accent",children:[d," ",h]}),e[10]=o,e[11]=h,e[12]=u):u=e[12];let f;return e[13]!==c||e[14]!==u?(f=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[c,u]}),e[13]=c,e[14]=u,e[15]=f):f=e[15],f}const hx=t=>`preview-drawer:${t}`,TK=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function AK(t){try{const e=localStorage.getItem(hx(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function EK(t,e){try{localStorage.setItem(hx(t),JSON.stringify({open:e}))}catch{}}function PK(){const t=F.c(21),e=Kn(),{org:s}=ze(),n=e?.virtualMcpId??null,i=Yi(),o=Ps(),a=N.useRef(null);let l;t[0]!==o||t[1]!==i||t[2]!==n?(l=b=>{b!=="setup"||!n||a.current!==n&&TK.test(o.getBuffer("setup"))&&(a.current=n,i.restart())},t[0]=o,t[1]=i,t[2]=n,t[3]=l):l=t[3],f3(l);const c=n??"__no-vmcp__",[d,h]=N.useState(null),u=N.useRef(null);u.current!==c&&(u.current=c,h(AK(c)));const f=d??!1;let m;t[4]!==c?(m=b=>{h(b),EK(c,b)},t[4]=c,t[5]=m):m=t[5];const p=m,g=i.vmEntry?.sandboxHandle??"no-vm",x=i.vmEntry?.sandboxHandle??null;let v;return t[6]!==o.scripts||t[7]!==p||t[8]!==i.branch||t[9]!==i.restart||t[10]!==i.resume||t[11]!==i.retry||t[12]!==i.start||t[13]!==i.status||t[14]!==i.stop||t[15]!==f||t[16]!==s.slug||t[17]!==g||t[18]!==x||t[19]!==n?(v=r.jsx(VK,{vmId:x,orgSlug:s.slug,virtualMcpId:n,branch:i.branch,status:i.status,scripts:o.scripts,open:f,onOpenChange:p,onStart:i.start,onStop:i.stop,onRestart:i.restart,onResume:i.resume,onRetry:i.retry},g),t[6]=o.scripts,t[7]=p,t[8]=i.branch,t[9]=i.restart,t[10]=i.resume,t[11]=i.retry,t[12]=i.start,t[13]=i.status,t[14]=i.stop,t[15]=f,t[16]=s.slug,t[17]=g,t[18]=x,t[19]=n,t[20]=v):v=t[20],v}function RK(){const t=F.c(1);if(!Xg()?.visible)return null;let s;return t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(PK,{}),t[0]=s):s=t[0],s}function fx(t){const e=F.c(18),{virtualMcpId:s,taskId:n}=t,i=Kn(),{activeTask:o}=ls();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const{main:l}=Vr(a);let c;e[1]!==o?.metadata||e[2]!==i?.entity?.metadata?(c=$s(i?.entity?.metadata)||$s(o?.metadata),e[1]=o?.metadata,e[2]=i?.entity?.metadata,e[3]=c):c=e[3];const d=c;let h;e[4]!==d||e[5]!==l?(h=d&&!(typeof l=="string"&&t8.has(l)),e[4]=d,e[5]=l,e[6]=h):h=e[6];const u=h;let f;e[7]!==n||e[8]!==s?(f=r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(lB,{taskId:n,virtualMcpId:s})}),e[7]=n,e[8]=s,e[9]=f):f=e[9];let m;e[10]!==u?(m=u&&r.jsx(RK,{}),e[10]=u,e[11]=m):m=e[11];let p;e[12]!==f||e[13]!==m?(p=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[f,m]}),e[12]=f,e[13]=m,e[14]=p):p=e[14];let g;return e[15]!==p||e[16]!==s?(g=r.jsx(rE,{virtualMcpId:s,children:p}),e[15]=p,e[16]=s,e[17]=g):g=e[17],g}function DK(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const n=t.slice(0,s),i=t.slice(s);if(e==null)return{visible:n,overflow:i};if(n.some(u=>u.id===e))return{visible:n,overflow:i};const a=i.findIndex(u=>u.id===e);if(a===-1)return{visible:n,overflow:i};const l=n[n.length-1],c=i[a],d=[...n.slice(0,-1),c],h=[l,...i.slice(0,a),...i.slice(a+1)];return{visible:d,overflow:h}}const q0=3,ym=["overview","preview","content","files"];function IK(t){const{items:e,persisted:s,maxVisible:n,isCodeAgent:i}=t,o=m=>{const p=ym.indexOf(m);return p===-1?ym.length:p},a=[...e].sort((m,p)=>o(m.id)-o(p.id)),l=new Map(a.map(m=>[m.id,m])),c=s.filter(m=>l.has(m)),d=new Set(c),h=[...c.map(m=>l.get(m)),...a.filter(m=>!d.has(m.id))],u=Math.max(1,Math.min(n,q0)),f=e.find(m=>m.active);if(i){const m=h.find(_=>_.id==="preview"),p=m?[m]:[],g=f&&!p.some(_=>_.id===f.id)?[f]:[],x=[...p,...g],v=new Set(x.map(_=>_.id)),b=h.filter(_=>!v.has(_.id));return{visible:x,overflow:b}}return DK(h,f?.id??null,u)}function MK(t){const e=F.c(24),{overflow:s,onSelect:n}=t,i=oe(),[o,a]=N.useState(!1);let l;e[0]!==n?(l=b=>{a(!1),n(b)},e[0]=n,e[1]=l):l=e[1];const c=l;let d;e[2]!==i?(d=i("mainPanelTabs.tabOverflowMenu.moreTabs"),e[2]=i,e[3]=d):d=e[3];let h;e[4]!==i?(h=i("mainPanelTabs.tabOverflowMenu.moreTabs"),e[4]=i,e[5]=h):h=e[5];const u=o?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let f;e[6]!==u?(f=ie("shrink-0 flex size-7 items-center justify-center rounded-md","[transition:background-color_180ms_ease,color_180ms_ease]",u),e[6]=u,e[7]=f):f=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(sb,{className:"size-4"}),e[8]=m):m=e[8];let p;e[9]!==d||e[10]!==h||e[11]!==f?(p=r.jsx(Ts,{asChild:!0,children:r.jsx("button",{type:"button","data-tour":Pn.dropdown,title:d,"aria-label":h,className:f,children:m})}),e[9]=d,e[10]=h,e[11]=f,e[12]=p):p=e[12];let g;if(e[13]!==c||e[14]!==s){let b;e[16]!==c?(b=_=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>c(_.id),className:ie("w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm",_.active?"bg-sidebar-accent text-sidebar-foreground":"text-foreground hover:bg-accent"),children:[r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(v9,{icon:_.icon})}),r.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[16]=c,e[17]=b):b=e[17],g=s.map(b),e[13]=c,e[14]=s,e[15]=g}else g=e[15];let x;e[18]!==g?(x=r.jsx(As,{align:"start",className:"w-56 p-1",children:r.jsx("ul",{className:"flex flex-col",children:g})}),e[18]=g,e[19]=x):x=e[19];let v;return e[20]!==o||e[21]!==p||e[22]!==x?(v=r.jsxs(Es,{open:o,onOpenChange:a,children:[p,x]}),e[20]=o,e[21]=p,e[22]=x,e[23]=v):v=e[23],v}function _m(t){const e=F.c(13),s=jt();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},e[0]=n):n=e[0];const i=Yl(n);let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},e[1]=o):o=e[1];const a=Vr(o),l=a.main===t,c=N.useRef(void 0),d=!!(i.org&&i.taskId);let h;e[2]!==l||e[3]!==s||e[4]!==t||e[5]!==i.org||e[6]!==i.taskId||e[7]!==a.main?(h=()=>{if(!i.org||!i.taskId)return;const m=i.org,p=i.taskId;s({to:"/$org/$taskId",params:{org:m,taskId:p},search:g=>{const x={...g};if(l){const v=c.current;v&&v!==t?x.main=v:delete x.main}else c.current=a.main===0?void 0:a.main,x.main=t;return x},replace:!0})},e[2]=l,e[3]=s,e[4]=t,e[5]=i.org,e[6]=i.taskId,e[7]=a.main,e[8]=h):h=e[8];const u=h;let f;return e[9]!==l||e[10]!==d||e[11]!==u?(f={active:l,enabled:d,toggle:u},e[9]=l,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function OK(t){const e=F.c(29),{virtualMcpId:s,taskId:n,disableActiveMainToggle:i,maxVisible:o}=t,a=i===void 0?!1:i,l=o===void 0?q0:o,c=jt();let d;e[0]!==n||e[1]!==s?(d={virtualMcpId:s,taskId:n},e[0]=n,e[1]=s,e[2]=d):d=e[2];const{tabs:h,activeTab:u,mainOpen:f,setActiveTab:m}=J9(d),p=oe(),g=_m("files"),x=_m("board"),v=rc();let b;e[3]===Symbol.for("react.memo_cache_sentinel")?(b=[],e[3]=b):b=e[3];const[_,y]=Am(`main-tab-bar:v2:${s}`,b);let L,w,j;if(e[4]!==u||e[5]!==a||e[6]!==g||e[7]!==f||e[8]!==l||e[9]!==c||e[10]!==_||e[11]!==v||e[12]!==m||e[13]!==y||e[14]!==p||e[15]!==h||e[16]!==x||e[17]!==s){const k=s8({activeTab:u,mainOpen:f}),C=$=>$.id==="automations"?k:f&&$.id===u,A=$=>{const B=h.find(K=>K.id===$);if(a&&B&&C(B))return;const z=f&&u===$;if(Fe("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:$,tab_kind:B?.kind??null,was_active:z}),$==="automations"){const K=n8({activeTab:u,mainOpen:f});c({to:".",search:Y=>({...Y,main:K}),replace:!0});return}m($)},P=[];if(g.enabled&&!v){let $;e[21]!==g?($=()=>{Fe("agent_toolbar_toggled",{button:"library",next_state:g.active?"closed":"open"}),g.toggle()},e[21]=g,e[22]=$):$=e[22],P.push({id:"files",title:p("agentShellLayout.libraryToggle.library"),icon:{kind:"component",Component:ri},active:g.active,locked:!1,onSelect:$})}if(x.enabled){let $;e[23]!==x?($=()=>{Fe("agent_toolbar_toggled",{button:"tasks",next_state:x.active?"closed":"open"}),x.toggle()},e[23]=x,e[24]=$):$=e[24],P.push({id:"board",title:p("agentShellLayout.tasksToggle.tasks"),icon:{kind:"component",Component:y2},active:x.active,locked:!1,onSelect:$})}const T=[...h.map($=>({id:$.id,title:$.title,icon:$.icon,active:C($),locked:a&&C($),onSelect:()=>A($.id)})),...P],R=!v&&T.some(KK),{visible:E,overflow:I}=IK({items:T,persisted:_,maxVisible:l,isCodeAgent:R}),D=new Map(T.map(zK)),M=Math.max(1,Math.min(l,q0)),O=$=>{if(!R){const B=E.slice(0,M-1).map(FK);y([...B,$])}D.get($)?.onSelect()};L="flex items-center min-w-0 gap-0.5",w=E.map(BK),j=I.length>0&&r.jsx(MK,{overflow:I.map($K),onSelect:O}),e[4]=u,e[5]=a,e[6]=g,e[7]=f,e[8]=l,e[9]=c,e[10]=_,e[11]=v,e[12]=m,e[13]=y,e[14]=p,e[15]=h,e[16]=x,e[17]=s,e[18]=L,e[19]=w,e[20]=j}else L=e[18],w=e[19],j=e[20];let S;return e[25]!==L||e[26]!==w||e[27]!==j?(S=r.jsxs("div",{className:L,children:[w,j]}),e[25]=L,e[26]=w,e[27]=j,e[28]=S):S=e[28],S}function $K(t){return{id:t.id,title:t.title,icon:t.icon,active:t.active}}function BK(t){return r.jsx(x9,{title:t.title,icon:t.icon,active:t.active,locked:t.locked,onClick:t.onSelect,dataTour:`tour-tab-${t.id}`},t.id)}function FK(t){return t.id}function zK(t){return[t.id,t]}function KK(t){return t.id==="code"}const UK={lead:70,tab:132,middle:232};function HK(t,e){if(t<0||e<0)return{maxTabs:3,showPageSelector:!0};const s=t-e,{lead:n,tab:i,middle:o}=UK;return s>=n+3*i+o?{maxTabs:3,showPageSelector:!0}:s>=n+2*i+o?{maxTabs:2,showPageSelector:!0}:s>=n+1*i+o?{maxTabs:1,showPageSelector:!0}:{maxTabs:1,showPageSelector:!1}}function mx(t){return fa({userName:t?.name,userEmail:t?.email})??void 0}const WK=new Set(["main","master"]);function qu(t,e){return WK.has(t.trim().toLowerCase())?e("thread.headerActions.publishToProduction"):e("thread.headerActions.publish")}function qK(t){const e=F.c(29),{baseBranch:s,disabled:n,loading:i,onPublish:o,onReview:a}=t,l=i===void 0?!1:i,c=oe();let d;e[0]!==s||e[1]!==c?(d=qu(s,c),e[0]=s,e[1]=c,e[2]=d):d=e[2];const h=d;let u;e[3]!==o?(u=()=>{o()},e[3]=o,e[4]=u):u=e[4];let f;e[5]!==l?(f=l?r.jsx(Ni,{size:"xs",variant:"default"}):null,e[5]=l,e[6]=f):f=e[6];let m;e[7]!==n||e[8]!==h||e[9]!==u||e[10]!==f?(m=r.jsxs(le,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:n,"data-tour":Pn.publish,onClick:u,children:[f,h]}),e[7]=n,e[8]=h,e[9]=u,e[10]=f,e[11]=m):m=e[11];let p;e[12]!==c?(p=c("thread.mergeSplitButton.moreActionsAriaLabel"),e[12]=c,e[13]=p):p=e[13];let g;e[14]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(is,{className:"h-3.5 w-3.5"}),e[14]=g):g=e[14];let x;e[15]!==n||e[16]!==p?(x=r.jsx(bs,{asChild:!0,children:r.jsx(le,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:n,"aria-label":p,children:g})}),e[15]=n,e[16]=p,e[17]=x):x=e[17];let v;e[18]!==a||e[19]!==c?(v=a?r.jsx(Je,{onClick:a,children:c("thread.mergeSplitButton.review")}):null,e[18]=a,e[19]=c,e[20]=v):v=e[20];let b;e[21]!==v?(b=r.jsx(ys,{align:"end",children:v}),e[21]=v,e[22]=b):b=e[22];let _;e[23]!==b||e[24]!==x?(_=r.jsxs(vs,{children:[x,b]}),e[23]=b,e[24]=x,e[25]=_):_=e[25];let y;return e[26]!==_||e[27]!==m?(y=r.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[m,_]}),e[26]=_,e[27]=m,e[28]=y):y=e[28],y}function GK(t,e,s,n,i){return["smart-review-verdict",t,e,s,n,i]}function YK(t){const e=F.c(24),{orgSlug:s,virtualMcpId:n,branch:i,status:o,diff:a,enabled:l}=t,[c]=di(),{language:d}=c;let h,u,f;if(e[0]!==i||e[1]!==a||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==o||e[6]!==n){const _=a?HT(a):"";h=l&&!!i&&!!o&&!!a&&_!=="",f=Pt,u=GK(s,n,i,_,d),e[0]=i,e[1]=a,e[2]=l,e[3]=d,e[4]=s,e[5]=o,e[6]=n,e[7]=h,e[8]=u,e[9]=f}else h=e[7],u=e[8],f=e[9];let m;e[10]!==i||e[11]!==a||e[12]!==d||e[13]!==s||e[14]!==o||e[15]!==n?(m=()=>WT(s,n,i,{status:o,diff:a,language:d}),e[10]=i,e[11]=a,e[12]=d,e[13]=s,e[14]=o,e[15]=n,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==u||e[19]!==m?(p={queryKey:u,queryFn:m,enabled:h,staleTime:1/0,gcTime:6e5,retry:JK},e[17]=h,e[18]=u,e[19]=m,e[20]=p):p=e[20];const g=f(p),x=g.data??null,v=h&&g.isFetching&&!g.data;let b;return e[21]!==x||e[22]!==v?(b={verdict:x,loading:v},e[21]=x,e[22]=v,e[23]=b):b=e[23],b}function JK(t,e){return!gu(e)&&t<1}function XK(t,e,s,n,i){return["publish-gate",t,e,s,n,i]}function QK(t){const e=F.c(23),{orgSlug:s,virtualMcpId:n,branch:i,base:o,headSha:a,signature:l,policy:c,enabled:d}=t,h=d===void 0?!0:d;let u;e[0]!==o||e[1]!==i||e[2]!==s||e[3]!==l||e[4]!==n?(u=XK(s,n,i,o,l),e[0]=o,e[1]=i,e[2]=s,e[3]=l,e[4]=n,e[5]=u):u=e[5];let f;e[6]!==o||e[7]!==i||e[8]!==a||e[9]!==s||e[10]!==n?(f=async()=>{const _=await Za(s,n,i),y=(_.aheadOfBase??0)>0?await mr(s,n,i,{base:o,...a?{headSha:a}:{}}):null,L=wc(_)?await mr(s,n,i):null;return{status:_,diff:Pg(y,L)}},e[6]=o,e[7]=i,e[8]=a,e[9]=s,e[10]=n,e[11]=f):f=e[11];const m=h&&!!i;let p;e[12]!==u||e[13]!==f||e[14]!==m?(p={queryKey:u,queryFn:f,enabled:m,refetchInterval:1e4,staleTime:5e3,retry:ZK},e[12]=u,e[13]=f,e[14]=m,e[15]=p):p=e[15];const g=Pt(p),x=g.data?.status??null,v=g.data?.diff??null;let b;return e[16]!==i||e[17]!==s||e[18]!==c||e[19]!==x||e[20]!==v||e[21]!==n?(b={orgSlug:s,virtualMcpId:n,branch:i,status:x,diff:v,policy:c},e[16]=i,e[17]=s,e[18]=c,e[19]=x,e[20]=v,e[21]=n,e[22]=b):b=e[22],px(b)}function ZK(t,e){return!gu(e)&&t<2}function px(t){const e=F.c(23),{orgSlug:s,virtualMcpId:n,branch:i,status:o,diff:a,policy:l,judgeEnabled:c}=t,d=c===void 0?!0:c;let h;e[0]!==a||e[1]!==d||e[2]!==l?(h=d&&QT(a,l),e[0]=a,e[1]=d,e[2]=l,e[3]=h):h=e[3];const u=h;let f;e[4]!==i||e[5]!==a||e[6]!==u||e[7]!==s||e[8]!==o||e[9]!==n?(f={orgSlug:s,virtualMcpId:n,branch:i,status:o,diff:a,enabled:u},e[4]=i,e[5]=a,e[6]=u,e[7]=s,e[8]=o,e[9]=n,e[10]=f):f=e[10];const{verdict:m,loading:p}=YK(f);if(!a){let b;return e[11]===Symbol.for("react.memo_cache_sentinel")?(b={gate:{allowed:!0,reason:null},ready:!1},e[11]=b):b=e[11],b}if(!u){let b;e[12]!==a||e[13]!==l?(b=XT(a,l),e[12]=a,e[13]=l,e[14]=b):b=e[14];let _;return e[15]!==b?(_={gate:b,ready:!0},e[15]=b,e[16]=_):_=e[16],_}let g;e[17]!==p||e[18]!==m?(g=ZT(m,p),e[17]=p,e[18]=m,e[19]=g):g=e[19];const x=!p;let v;return e[20]!==g||e[21]!==x?(v={gate:g,ready:x},e[20]=g,e[21]=x,e[22]=v):v=e[22],v}class co extends Error{constructor(e,s,n){super(e),this.step=s,this.pr=n,this.name="PublishFlowError"}step;pr}function eU(t){const e=F.c(10),[s,n]=N.useState(0);let i;e[0]!==t?(i=c=>{c&&n(tU),t.onOpenChange(c)},e[0]=t,e[1]=i):i=e[1];const o=i;let a;e[2]!==o||e[3]!==t||e[4]!==s?(a=t.open?r.jsx(sU,{...t,onOpenChange:o},s):null,e[2]=o,e[3]=t,e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==t.open||e[8]!==a?(l=r.jsx(Jt,{open:t.open,onOpenChange:o,children:a}),e[6]=o,e[7]=t.open,e[8]=a,e[9]=l):l=e[9],l}function tU(t){return t+1}function sU({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:n,branch:i,baseBranch:o,githubConnectionId:a,owner:l,repo:c,previewUrl:d,publishPolicy:h,dialogIntent:u="open-pr",headSha:f=null,openPullRequest:m=null,onPullRequestChanged:p}){const g=oe(),x=pt({connectionId:a,orgId:s,orgSlug:e}),v=pt({connectionId:Xl,orgId:s,orgSlug:e}),{data:b}=ui.useSession(),_=$p(v),y=mx(b?.user),L=m?.state==="open",w=u==="open-pr"&&!L,j=u==="publish-only",[S,k]=N.useState(null),[C,A]=N.useState(null),[P,V]=N.useState(!0),[T,R]=N.useState(!1),[E,I]=N.useState(""),[D,M]=N.useState(""),[O,$]=N.useState(),[B,z]=N.useState(!1),[K,Y]=N.useState(),[Q,q]=N.useState(!1),[H,U]=N.useState(!1),[X,J]=N.useState(!1),ee=N.useRef(!1),W=N.useRef(!1),Z={base:o,...f?{headSha:f}:{}},G=async ge=>{const Le=(ge.aheadOfBase??0)>0?await mr(e,n,i,Z):null,ye=wc(ge)?await mr(e,n,i):null;return Pg(Le,ye)},te=async()=>{const ge=await Za(e,n,i),Le=j?await G(ge):await mr(e,n,i,JT(ge,{openPrFromCommits:w,commitToOpenPr:L})?Z:void 0);k(ge),A(Le),I(g("thread.publishDialog.changesFrom",{branch:ge.current??i})),J(!0),Sf(e,n,i,{status:ge,diff:Le}).then(ye=>{I(ye.title),M(ye.body)}).catch(()=>{}).finally(()=>J(!1))};ee.current||(ee.current=!0,(async()=>{V(!0),$(void 0),A(null),I(""),M(""),Y(void 0);try{await te()}catch(ge){if(gu(ge)&&!W.current){W.current=!0;try{await _.mutateAsync({virtualMcpId:n,branch:i}),await te();return}catch(Le){$(Le instanceof Error?Le.message:g("thread.publishDialog.failedLoadAfterReprovision"));return}}$(ge instanceof Error?ge.message:g("thread.publishDialog.failedLoad"))}finally{V(!1)}})());const se=GT(S)??i,re=qu(o,g),de=()=>{!S||!C||(J(!0),Sf(e,n,i,{status:S,diff:C}).then(ge=>{I(ge.title),M(ge.body)}).catch(()=>{}).finally(()=>J(!1)))},ce=Ag(S),fe=C?Object.keys(C.diffs).length:ce,{gate:ue}=px({orgSlug:e,virtualMcpId:n,branch:i,status:S,diff:C,policy:h,judgeEnabled:j}),ae=w?Eg(S):YT(S,C),me=!P&&(ae||w),xe=me&&ue.allowed,Se=!me||ue.allowed?null:ue.pending?g("thread.publishDialog.reviewingChanges"):ue.reason??g("thread.publishDialog.publishNeedsReview"),Ve=w||!L&&(S?.aheadOfBase??0)>0,Ie=!P&&(Ve||ae)&&(fe>0||ae),Ne=()=>[E.trim(),D.trim()].filter(Boolean).join(`
491
-
492
- `),Ee=ge=>{T||B||t(ge)},we=async()=>{R(!0),$(void 0);let ge;try{const Le=E.trim()||g("thread.publishDialog.changesFrom",{branch:se}),ye=D.trim()||void 0,Ce=Ne()||Le;try{await wf(e,n,i,Ce)}catch(Me){throw new co(Me instanceof Error?Me.message:g("thread.publishDialog.failedPushChanges"),"push")}try{await FT(e,n,i,o)}catch(Me){throw new co(Me instanceof Error?Me.message:g("thread.publishDialog.failedRebase"),"rebase")}try{ge=await Mh(x,{owner:l,repo:c,branch:se,title:Le,body:ye,base:o,coAuthor:y})}catch(Me){throw new co(Me instanceof Error?Me.message:g("thread.publishDialog.failedOpenPullRequest"),"open-pr")}try{await Up(x,{owner:l,repo:c,pullNumber:ge.number,commitTitle:Le,commitMessage:ye,coAuthor:y})}catch(Me){throw new co(Me instanceof Error?Me.message:g("thread.publishDialog.failedMergePullRequest"),"merge",ge)}ve.success(g("thread.publishDialog.publishedTo",{baseBranch:o})),Ee(!1),A(null),I(""),M(""),await p?.()}catch(Le){if(Le instanceof co&&Le.step==="merge"&&Le.pr){const ye=g("thread.publishDialog.mergeFailed",{prNumber:Le.pr.number,message:Le.message});$(ye),ve.error(ye,{action:{label:g("thread.publishDialog.viewPr"),onClick:()=>window.open(Le.pr.htmlUrl,"_blank","noopener,noreferrer")}}),await p?.();return}$(Le instanceof Error?Le.message:g("thread.publishDialog.failedPublish"))}finally{R(!1)}},Ae=async ge=>{try{await jf(e,n,i,[ge]),ve.success(g("thread.publishDialog.discardedChanges",{filepath:ge})),A(ye=>{if(!ye)return ye;const Ce={...ye,diffs:{...ye.diffs}};return delete Ce.diffs[ge],Ce});const Le=await Za(e,n,i);k(Le)}catch(Le){ve.error(Le instanceof Error?Le.message:g("thread.publishDialog.failedDiscardChanges"))}},be=async()=>{if(C){q(!1),U(!0);try{const ge=Object.keys(C.diffs);if(ge.length===0)return;await jf(e,n,i,ge),ve.success(g("thread.publishDialog.allChangesDiscarded")),A(null);const Le=await Za(e,n,i);k(Le),Ee(!1)}catch(ge){ve.error(ge instanceof Error?ge.message:g("thread.publishDialog.failedDiscardChanges"))}finally{U(!1)}}},je=async()=>{z(!0),Y(void 0);try{const ge=E.trim()||g("thread.publishDialog.changesFrom",{branch:se}),Le=D.trim()||void 0,ye=Ne()||ge;await wf(e,n,i,ye);const Ce=await Mh(x,{owner:l,repo:c,branch:se,title:ge,body:Le,base:o,coAuthor:y});ve.success(g("thread.publishDialog.submittedForReview",{prNumber:Ce.number}),{action:{label:g("thread.publishDialog.viewOnGithub"),onClick:()=>window.open(Ce.htmlUrl,"_blank","noopener,noreferrer")}}),Ee(!1),await p?.()}catch(ge){Y(ge instanceof Error?ge.message:g("thread.publishDialog.failedSubmitForReview"))}finally{z(!1)}};return r.jsx(Yt,{className:"top-14 left-auto right-4 flex h-[90%] max-h-[85vh] w-[90vw] max-w-[600px] translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden p-0",children:r.jsxs(Er,{defaultValue:"description",className:"flex h-full flex-col gap-0",children:[r.jsxs("div",{className:"shrink-0 space-y-3 px-6 pt-5 pb-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:w?g("thread.publishDialog.submitForReview"):re}),r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full bg-success"}),fe," ",g(fe===1?"thread.publishDialog.change":"thread.publishDialog.changes")," ",g(w?"thread.publishDialog.inThisPr":"thread.publishDialog.toPublish")]})]}),Q?r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-destructive/5 px-3 py-2",children:[r.jsx("span",{className:"text-xs text-destructive",children:g("thread.publishDialog.discardConfirmMessage")}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>q(!1),children:g("thread.publishDialog.cancel")}),r.jsxs(le,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:be,disabled:H,children:[H?r.jsx(Ze,{className:"h-3 w-3 animate-spin"}):null,g("thread.publishDialog.discardAll")]})]})]}):r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(oa,{className:"h-8 w-auto",variant:"pill",children:[r.jsx(vn,{value:"description",className:"px-3 text-xs",children:g("thread.publishDialog.description")}),r.jsx(vn,{value:"changes",className:"px-3 text-xs",children:g("thread.publishDialog.changesTab")})]}),fe>0&&!w&&r.jsx("button",{type:"button",className:"text-xs text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>q(!0),disabled:T||H,children:g("thread.publishDialog.discardAll")})]})]}),r.jsx("div",{className:"border-t"}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:P?r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[r.jsx(Ze,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{className:"text-sm",children:g("thread.publishDialog.loadingChanges")})]}):r.jsxs(r.Fragment,{children:[r.jsx(ji,{value:"description",className:"mt-0 px-6 py-5",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("p",{className:"text-sm font-medium",children:g(w?"thread.publishDialog.pullRequest":"thread.publishDialog.commitMessage")}),r.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",disabled:X||T||B,onClick:de,children:[X?r.jsx(Ze,{className:"h-3 w-3 animate-spin"}):r.jsx(ei,{className:"h-3 w-3"}),g(X?"thread.publishDialog.generating":"thread.publishDialog.regenerate")]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"publish-title",className:"text-xs font-medium text-muted-foreground",children:g("thread.publishDialog.title")}),r.jsx(et,{id:"publish-title",value:E,onChange:ge=>I(ge.target.value),placeholder:g(X?"thread.publishDialog.generating":"thread.publishDialog.commitTitlePlaceholder"),disabled:T||B||X,className:"text-sm"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"publish-body",className:"text-xs font-medium text-muted-foreground",children:g("thread.publishDialog.descriptionLabel")}),r.jsx(Ri,{id:"publish-body",value:D,onChange:ge=>M(ge.target.value),placeholder:g(X?"thread.publishDialog.generating":"thread.publishDialog.descriptionPlaceholder"),disabled:T||B||X,rows:5,className:"resize-none text-sm"})]}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[g("thread.publishDialog.branchLabel")," ",r.jsx("span",{className:"font-mono",children:i})," → ",r.jsx("span",{className:"font-mono",children:o})," · ",r.jsx("span",{className:"text-foreground/80",children:j?g("thread.publishDialog.squashMergesInto",{publishLabel:re,baseBranch:o}):g("thread.publishDialog.opensPullRequestInto",{baseBranch:o})})]})]})}),r.jsx(ji,{value:"changes",className:"mt-0",children:r.jsx(Rg,{diff:C,onDiscardFile:Ae})})]})}),r.jsx("div",{className:"shrink-0 border-t",children:r.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-6 py-3.5 text-sm transition-colors hover:bg-muted/50 disabled:opacity-50",onClick:()=>{d&&window.open(d,"_blank","noopener,noreferrer")},disabled:!d,children:[r.jsxs("span",{className:"flex items-center gap-3",children:[r.jsx(T9,{className:"h-4 w-4 text-muted-foreground"}),g("thread.publishDialog.visitPreview")]}),r.jsx(Ar,{className:"h-4 w-4 text-muted-foreground"})]})}),r.jsx("div",{className:"shrink-0 border-t px-6 py-3",children:j?r.jsxs(r.Fragment,{children:[r.jsx(nU,{label:re,canPublish:xe,disabledReason:Se,isPublishing:T,onPublish:we}),O&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:O})]}):r.jsxs(r.Fragment,{children:[r.jsxs(le,{type:"button",className:"w-full",onClick:je,disabled:!Ie||B,children:[B?r.jsx(Ze,{className:"h-4 w-4 animate-spin"}):r.jsx(en,{className:"h-4 w-4"}),g("thread.publishDialog.submitForReviewButton")]}),K&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:K})]})})]})})}function nU(t){const e=F.c(14),{label:s,canPublish:n,disabledReason:i,isPublishing:o,onPublish:a}=t,l=!n||o;let c;e[0]!==o?(c=o?r.jsx(Ze,{className:"h-4 w-4 animate-spin"}):null,e[0]=o,e[1]=c):c=e[1];let d;e[2]!==s||e[3]!==a||e[4]!==l||e[5]!==c?(d=r.jsxs(le,{type:"button",variant:"success",className:"w-full",onClick:a,disabled:l,children:[c,s]}),e[2]=s,e[3]=a,e[4]=l,e[5]=c,e[6]=d):d=e[6];const h=d;if(!i)return h;let u;e[7]!==h?(u=r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"flex w-full",children:h})}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==i?(f=r.jsx(He,{children:i}),e[9]=i,e[10]=f):f=e[10];let m;return e[11]!==u||e[12]!==f?(m=r.jsx(Ti,{children:r.jsxs(We,{children:[u,f]})}),e[11]=u,e[12]=f,e[13]=m):m=e[13],m}function iU(){return!1}function gx(t,e){iU()&&console.log(`[github-header] ${t}`,e??"")}function rU(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return h4[t].short}const oU=new Set(["failure","timed_out","cancelled","action_required"]);function aU(t){return t.status==="completed"&&oU.has(t.conclusion)}function lU(t){return t.status==="queued"||t.status==="in_progress"}function cU(t){return t.isPending&&t.fetchStatus!=="idle"}function dU(t){const{lifecycle:e,branch:s,pr:n,checks:i,reviews:o,loading:a,t:l}=t;if(a)return{label:l("thread.headerActions.loading"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.loadingBranchTooltip")};switch(e.phase){case"idle":return{label:t.claimPhase&&rU(t.claimPhase.kind)||l("thread.headerActions.startingSandbox"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.waitingForDaemonTooltip")};case"cloning":return{label:l("thread.headerActions.cloningRepo"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.cloningRepoTooltip")};case"clone-failed":return{label:l("thread.headerActions.cloneFailed"),disabled:!0,variant:"outline",tooltip:e.error||l("thread.headerActions.cloneFailedDefaultTooltip")};case"checking-out":return{label:l("thread.headerActions.switchingTo",{branch:e.to}),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.checkingOutTooltip",{branch:e.to})}}if(s.kind!=="ready")return{label:l("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.waitingForBranchTooltip")};const c=s;if(c.workingTreeDirty)return{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.pushAndOpenPrTooltip",{branch:c.branch,base:c.base}),showPublishSide:!0};if(c.unpushed>0&&!(n&&c.headSha&&n.headSha&&c.headSha===n.headSha))return n?{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.pushLocalCommitsTooltip",{prNumber:String(n.number)}),showPublishSide:!0}:{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.pushAndOpenPrTooltip",{branch:c.branch,base:c.base}),showPublishSide:!0};if(gx("no local work — checking PR/sync state",{workingTreeDirty:c.workingTreeDirty,unpushed:c.unpushed,aheadOfBase:c.aheadOfBase,behindBase:c.behindBase,branch:c.branch,base:c.base,prMerged:n?.merged??null,prState:n?.state??null}),n?.merged)return!!c.headSha&&!!n.headSha&&c.headSha!==n.headSha?{label:l("thread.headerActions.continue"),action:"create-pr",variant:"special",tooltip:l("thread.headerActions.openNewPrTooltip"),showPublishSide:!0}:{label:l("thread.headerActions.published"),disabled:!0,variant:"outline",tooltip:l("thread.headerActions.prMergedTooltip",{prNumber:String(n.number),base:n.base})};if(c.aheadOfBase>0){if(n&&n.state==="closed"&&!n.merged)return{label:l("thread.headerActions.reopen"),action:"reopen",variant:"default",tooltip:l("thread.headerActions.reopenPrTooltip",{prNumber:String(n.number)})};if(!n)return{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.openPrForBranchTooltip",{branch:c.branch,base:c.base}),showPublishSide:!0};if((o?.mergeableState??"unknown")==="dirty")return{label:l("thread.headerActions.syncWith",{base:n.base}),action:"rebase",variant:"default",tooltip:l("thread.headerActions.resolveConflictsTooltip",{base:n.base})};const u=i.filter(aU).map(p=>p.name);if(u.length>0)return{label:l("thread.headerActions.fixTests"),action:"fix-checks",variant:"default",tooltip:l("thread.headerActions.failingChecksTooltip",{checks:u.join(", ")}),meta:{failingChecks:u}};const f=i.filter(lU);if(f.length>0)return{label:l("thread.headerActions.runningTests"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.waitingOnChecksTooltip",{count:String(f.length)})};if(o?.draft)return{label:l("thread.headerActions.markReady"),action:"mark-ready",variant:"default",tooltip:l("thread.headerActions.markDraftReadyTooltip")};const m=o?.unresolvedConversations??0;return m>0?{label:l("thread.headerActions.addressFeedback"),action:"resolve-comments",variant:"default",tooltip:l("thread.headerActions.unresolvedConversationsTooltip",{count:String(m)})}:o?.missingRequiredApprovals?{label:l("thread.headerActions.awaitingReview"),disabled:!0,variant:"outline",tooltip:l("thread.headerActions.waitingForApprovalsTooltip")}:{label:qu(n.base,l),action:"merge-split",variant:"success",tooltip:l("thread.headerActions.squashMergeTooltip",{prNumber:String(n.number),base:n.base})}}return{label:l("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:l("thread.headerActions.branchInSyncTooltip",{base:c.base})}}function uU(t,e,s){if(!e)return s??null;const n=t?.[e];if(!n)return s??null;if(s&&n[s])return s;for(const[i,o]of Object.entries(n))if(o&&Object.keys(o).length>0)return i;return s??null}const hU=6e4,fU=3e4;function mU(t){const e=F.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=pt(s),i=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==i?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:i},e[4]=t.owner,e[5]=t.repo,e[6]=i,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:hU,refetchIntervalInBackground:!1,staleTime:fU,select:pU},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],da(l)}function pU(t){const e=qi(t);if(!e)return null;const s=e.mergeable_state??"unknown",n=!!(e.draft??!1),i=Number(e.review_comments??0),o=s==="blocked"&&i>0?i:0;return{draft:n,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function gU(t){return{label:t("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:t("thread.headerActions.waitingForSandboxBranchTooltip")}}function xU({virtualMcpId:t}){const e=oe(),{org:s}=ze(),{data:n}=ui.useSession(),i=ms(t),{currentBranch:o}=ls(),a=Js(),[l,c]=N.useState(!1),[d,h]=N.useState("open-pr"),[u,f]=N.useState(!1),m=N.useRef(""),p=ob(i),g=p.status==="attached"||p.status==="public-clone"?p.repo:null,x=n?.user?.id,v=pt({connectionId:g?.connectionId??"",orgId:s.id,orgSlug:s.slug}),{lifecycle:b,branch:_,phase:y}=Ps(),L=_.kind==="ready"?_.branch:null,w=uU(i?.metadata?.sandboxMap,x,o??L),j=o??L??w??void 0,S=(_.kind==="ready"?_.branch:null)??j??null,k=O9({orgId:s.id,orgSlug:s.slug,connectionId:g?.connectionId??"",owner:g?.owner??"",repo:g?.name??"",branch:S}),C=k.data??null,A=Wp({orgId:s.id,orgSlug:s.slug,connectionId:g?.connectionId??"",owner:g?.owner??"",repo:g?.name??"",prNumber:C&&C.state==="open"?C.number:null}),P=mU({orgId:s.id,orgSlug:s.slug,connectionId:g?.connectionId??"",owner:g?.owner??"",repo:g?.name??"",prNumber:C&&C.state==="open"?C.number:null}),V=_,T=V.kind==="ready"?V.base:"main",R=V.kind==="ready"&&!!j&&(V.workingTreeDirty||V.unpushed>0||V.aheadOfBase>0),E=V.kind==="ready"?`${V.headSha}:${V.workingTreeDirty}:${V.unpushed}:${V.aheadOfBase}`:"unknown",I=UT(i?.metadata?.publishPolicy),{gate:D}=QK({orgSlug:s.slug,virtualMcpId:t,branch:j??"",base:T,headSha:V.kind==="ready"?V.headSha:null,signature:E,policy:I,enabled:R});if(p.status==="detached")return r.jsx(al,{label:e("thread.headerActions.githubConnectionRemoved"),children:r.jsx(le,{size:"sm",variant:"outline",disabled:!0,children:e("thread.headerActions.reconnectGithub")})});if(!g)return null;const{previewUrl:M}=Yi(),O=S?dU({lifecycle:b,branch:V,claimPhase:y,pr:C,checks:A.data??[],reviews:P.data??null,loading:cU(k),t:e}):gU(e),$=JSON.stringify({label:O.label,branchKind:V.kind,workingTreeDirty:V.kind==="ready"?V.workingTreeDirty:null,unpushed:V.kind==="ready"?V.unpushed:null,aheadOfBase:V.kind==="ready"?V.aheadOfBase:null,lifecycle:b.phase,githubHeadBranch:S});m.current!==$&&(m.current=$,gx("header button",{label:O.label,tooltip:O.tooltip,action:O.action,chatBranch:o,sandboxBranch:L,sandboxMapBranch:w,sandboxRouteBranch:j,githubHeadBranch:S,branchMeta:_,effectiveBranchMeta:V,lifecyclePhase:b.phase,prNumber:C?.number??null,prState:C?.state??null}));const B=J=>a.sendMessage({parts:[{type:"text",text:J}]}),z=a.isStreaming,K=V.kind==="ready"?V.base:"main",Y=async()=>{await Promise.all([k.refetch(),A.refetch(),P.refetch()])},Q=async J=>{if(!(!g?.connectionId||u)){f(!0);try{const ee=mx(n?.user);await Up(v,{owner:g.owner,repo:g.name,pullNumber:J,coAuthor:ee}),ve.success(e("thread.headerActions.publishedPr",{prNumber:String(J)})),await Y()}catch(ee){ve.error(ee instanceof Error?ee.message:e("thread.headerActions.failedToMergePullRequest"))}finally{f(!1)}}},q=J=>{if(!(!J||!S))switch(J){case"create-pr":h("open-pr"),c(!0);return;case"reopen":if(z)return;C&&B(iA({prNumber:C.number}));return;case"rebase":if(z)return;B(rA({branch:S}));return;case"fix-checks":if(z)return;C&&B(aA({prNumber:C.number,failingChecks:O.meta?.failingChecks??[]}));return;case"mark-ready":if(z)return;C&&B(lA({prNumber:C.number}));return;case"resolve-comments":if(z)return;C&&B(cA({prNumber:C.number}));return;case"merge-split":return}},H=()=>{h("publish-only"),c(!0)},U=O.showPublishSide??!1,X=u||z;return r.jsxs(r.Fragment,{children:[r.jsx(vU,{t:e,button:O,actionBusy:X,githubActionPending:u,onActivate:q,showPublishSide:U,onPublishSide:H,publishGate:D,prNumber:C?.number,prBase:C?.base,onSquashMerge:Q,onReview:C?()=>{z||B(dA({prNumber:C.number}))}:void 0}),j&&r.jsx(eU,{open:l,onOpenChange:c,orgSlug:s.slug,orgId:s.id,virtualMcpId:t,branch:j,baseBranch:K,githubConnectionId:g.connectionId??"",owner:g.owner,repo:g.name,previewUrl:M,publishPolicy:I,dialogIntent:d,headSha:V.kind==="ready"?V.headSha:null,openPullRequest:d==="publish-only"?null:C?.state==="open"?C:null,onPullRequestChanged:Y})]})}function vU(t){const e=F.c(39),{t:s,button:n,actionBusy:i,githubActionPending:o}=t,a=i&&n.action!=="create-pr"&&n.action!=="merge-split",l=!!n.disabled||a||o&&n.action==="merge-split",c=!!n.loading||o&&n.action==="merge-split";let d;e[0]!==n.tooltip||e[1]!==a||e[2]!==s?(d=a?s("thread.headerActions.chatIsRunning"):n.tooltip??null,e[0]=n.tooltip,e[1]=a,e[2]=s,e[3]=d):d=e[3];const h=d;if(n.action==="merge-split"&&t.prNumber!=null&&t.prBase!=null){let b;e[4]!==t?(b=()=>t.onSquashMerge(t.prNumber),e[4]=t,e[5]=b):b=e[5];let _;e[6]!==l||e[7]!==c||e[8]!==t.onReview||e[9]!==t.prBase||e[10]!==b?(_=r.jsx(qK,{baseBranch:t.prBase,disabled:l,loading:c,onPublish:b,onReview:t.onReview}),e[6]=l,e[7]=c,e[8]=t.onReview,e[9]=t.prBase,e[10]=b,e[11]=_):_=e[11];let y;return e[12]!==_||e[13]!==h?(y=r.jsx(al,{label:h,children:_}),e[12]=_,e[13]=h,e[14]=y):y=e[14],y}const u=n.action==="create-pr"?Pn.submit:void 0;let f;e[15]!==n.action||e[16]!==t?(f=()=>{n.action&&t.onActivate(n.action)},e[15]=n.action,e[16]=t,e[17]=f):f=e[17];let m;e[18]!==c?(m=c?r.jsx(Ni,{size:"xs",variant:"default"}):null,e[18]=c,e[19]=m):m=e[19];let p;e[20]!==n.label||e[21]!==n.variant||e[22]!==l||e[23]!==u||e[24]!==f||e[25]!==m?(p=r.jsxs(le,{size:"sm",variant:n.variant,disabled:l,"data-tour":u,onClick:f,children:[m,n.label]}),e[20]=n.label,e[21]=n.variant,e[22]=l,e[23]=u,e[24]=f,e[25]=m,e[26]=p):p=e[26];let g;e[27]!==p||e[28]!==h?(g=r.jsx(al,{label:h,children:p}),e[27]=p,e[28]=h,e[29]=g):g=e[29];let x;e[30]!==t.githubActionPending||e[31]!==t.onPublishSide||e[32]!==t.publishGate||e[33]!==t.showPublishSide||e[34]!==s?(x=t.showPublishSide?r.jsx(al,{label:t.publishGate.pending?s("thread.headerActions.reviewingChanges"):t.publishGate.allowed?s("thread.headerActions.publishDirectlySkipReview"):t.publishGate.reason??s("thread.headerActions.publishNeedsReview"),children:r.jsxs(le,{size:"sm",variant:"success","data-tour":Pn.publish,disabled:t.githubActionPending||!t.publishGate.allowed,onClick:t.onPublishSide,children:[t.publishGate.pending?r.jsx(Ni,{size:"xs",variant:"default"}):null,s("thread.headerActions.publish")]})}):null,e[30]=t.githubActionPending,e[31]=t.onPublishSide,e[32]=t.publishGate,e[33]=t.showPublishSide,e[34]=s,e[35]=x):x=e[35];let v;return e[36]!==g||e[37]!==x?(v=r.jsxs("div",{className:"flex items-center gap-2",children:[g,x]}),e[36]=g,e[37]=x,e[38]=v):v=e[38],v}function al(t){const e=F.c(9),{label:s,children:n}=t;if(!s){let l;return e[0]!==n?(l=r.jsx(r.Fragment,{children:n}),e[0]=n,e[1]=l):l=e[1],l}let i;e[2]!==n?(i=r.jsx(Ue,{asChild:!0,children:r.jsx("span",{children:n})}),e[2]=n,e[3]=i):i=e[3];let o;e[4]!==s?(o=r.jsx(He,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==i||e[7]!==o?(a=r.jsx(Ti,{children:r.jsxs(We,{children:[i,o]})}),e[6]=i,e[7]=o,e[8]=a):a=e[8],a}function bU(t){const e=F.c(9),{virtualMcp:s}=t,n=la(),{navigateToTask:i}=cv(),{create:o}=Ql();let a,l;if(e[0]!==n||e[1]!==o||e[2]!==i||e[3]!==s){l=Symbol.for("react.early_return_sentinel");e:{const c=ab(s,n);if(!c){l=null;break e}const d=c.mode==="dev";let h;e[6]!==o||e[7]!==i?(h=async m=>{const p=crypto.randomUUID();try{await o({id:p,virtual_mcp_id:m})}catch{}i(p,{virtualMcpId:m})},e[6]=o,e[7]=i,e[8]=h):h=e[8];const u=h,f=(m,p)=>r.jsx("button",{type:"button","aria-pressed":p,onClick:()=>{p||u(c.targetId)},className:ie("px-2.5 py-1 rounded-md transition-colors",p?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:m});a=r.jsxs("div",{className:"inline-flex items-center rounded-lg border border-border bg-muted p-0.5 text-xs font-medium",children:[f("Develop",d),f("Live",!d)]})}e[0]=n,e[1]=o,e[2]=i,e[3]=s,e[4]=a,e[5]=l}else a=e[4],l=e[5];return l!==Symbol.for("react.early_return_sentinel")?l:a}function yU(t){const e=F.c(10),{locator:s}=ze(),n=Fs();let i;e[0]!==s?(i=Qe.taskBoardItems(s),e[0]=s,e[1]=i):i=e[1];let o;e[2]!==n?(o=async()=>(await n.call("TASK_BOARD_ITEM_LIST",{})).items,e[2]=n,e[3]=o):o=e[3];let a;e[4]!==i||e[5]!==o?(a={queryKey:i,queryFn:o},e[4]=i,e[5]=o,e[6]=a):a=e[6];const{data:l}=Pt(a);if(!t||!l)return null;let c;return e[7]!==l||e[8]!==t?(c=l.find(d=>d.threads.some(h=>h.threadId===t))?.id??null,e[7]=l,e[8]=t,e[9]=c):c=e[9],c}function _U(){const t=F.c(17),e=oe(),{org:s}=ze(),{taskId:n}=ls(),i=jt(),o=yU(n);if(!o)return null;let a;t[0]!==e?(a=e("thread.openInBoardButton.openTaskAriaLabel"),t[0]=e,t[1]=a):a=t[1];let l;t[2]!==o||t[3]!==i||t[4]!==s.slug?(l=()=>i({to:"/$org/board",params:{org:s.slug},search:{task:o}}),t[2]=o,t[3]=i,t[4]=s.slug,t[5]=l):l=t[5];let c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(An,{size:16}),t[6]=c):c=t[6];let d;t[7]!==a||t[8]!==l?(d=r.jsx(Ue,{asChild:!0,children:r.jsx(fo,{"aria-label":a,onClick:l,children:c})}),t[7]=a,t[8]=l,t[9]=d):d=t[9];let h;t[10]!==e?(h=e("thread.openInBoardButton.openTaskInBoard"),t[10]=e,t[11]=h):h=t[11];let u;t[12]!==h?(u=r.jsx(He,{children:h}),t[12]=h,t[13]=u):u=t[13];let f;return t[14]!==d||t[15]!==u?(f=r.jsx(Ti,{children:r.jsxs(We,{children:[d,u]})}),t[14]=d,t[15]=u,t[16]=f):f=t[16],f}function LU(t){const e=F.c(7),{virtualMcp:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(_U,{}),e[0]=n):n=e[0];let i,o;e[1]!==s?(i=r.jsx(bU,{virtualMcp:s}),o=lb(s)?r.jsx(xU,{virtualMcpId:s.id}):null,e[1]=s,e[2]=i,e[3]=o):(i=e[2],o=e[3]);let a;return e[4]!==i||e[5]!==o?(a=r.jsxs("div",{className:"flex items-center gap-2",children:[n,i,o]}),e[4]=i,e[5]=o,e[6]=a):a=e[6],a}function SU(t){return(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"user"}function wU(t){const e=SU(t),s=Date.now().toString(36).split("").reverse().join("");return`${e}-${s}`}const jU=10080*60*1e3;function CU({sandboxMap:t,userId:e,rawBranches:s,now:n}){const i=new Map;for(const[u,f]of Object.entries(t??{}))for(const[m,p]of Object.entries(f??{})){let g=i.get(m);g||(g={userIds:new Set,lastActiveAt:0},i.set(m,g)),g.userIds.add(u);for(const x of Object.values(p??{})){const v=x?.createdAt??0;v>g.lastActiveAt&&(g.lastActiveAt=v)}}const o=n-jU,a=[...i.entries()].filter(([,u])=>u.lastActiveAt>=o).sort((u,f)=>f[1].lastActiveAt-u[1].lastActiveAt).map(([u,f])=>({name:u,source:"recent",contributors:[...f.userIds],lastActiveAt:f.lastActiveAt})),l=new Set(a.map(u=>u.name)),c=new Set(Object.keys(t?.[e]??{})),d=[...c].filter(u=>!l.has(u)).sort().map(u=>({name:u,source:"yours"})),h=s.filter(u=>!c.has(u.name)&&!l.has(u.name)).map(u=>({name:u.name,source:"other",author:u.author??null}));return{recent:a,yours:d,others:h}}const ll=100;function kU(t,e,s){const n=e.trim().toLowerCase();return n?(t??[]).some(i=>i.branches.some(o=>typeof o.name=="string"&&!s.has(o.name)&&o.name.toLowerCase().includes(n))):!0}function VU(t,e){const s=e.trim().toLowerCase();return s?[...t].some(n=>n.toLowerCase().includes(s)):!0}function NU(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(n=>n.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function TU(t){const e=F.c(43),{orgId:s,orgSlug:n,virtualMcpId:i,userId:o,connectionId:a,sandboxMap:l,owner:c,repo:d,enabled:h}=t,u=h===void 0?!0:h,{data:f}=V3(n,i,u),m=f===void 0?[]:f,p=a??null;let g;e[0]!==s||e[1]!==n||e[2]!==p?(g={connectionId:p,orgId:s,orgSlug:n},e[0]=s,e[1]=n,e[2]=p,e[3]=g):g=e[3];const x=pt(g);let v;e[4]!==a||e[5]!==s||e[6]!==n||e[7]!==c||e[8]!==d?(v=Qe.githubBranches(s,n,a,c,d),e[4]=a,e[5]=s,e[6]=n,e[7]=c,e[8]=d,e[9]=v):v=e[9];const b=u&&!!a&&!!c&&!!d;let _;e[10]!==x||e[11]!==c||e[12]!==d?(_=async H=>{const{pageParam:U,signal:X}=H,J=Number(U),ee=await x.callTool({name:"list_branches",arguments:{owner:c,repo:d,page:J,perPage:ll}},void 0,{signal:X}),W=NU(ee);return{branches:Array.isArray(W)?W:W.branches??[],default_branch:Array.isArray(W)?null:W.default_branch??null,page:J}},e[10]=x,e[11]=c,e[12]=d,e[13]=_):_=e[13];let y;e[14]!==v||e[15]!==b||e[16]!==_?(y={queryKey:v,enabled:b,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:_,getNextPageParam:IU},e[14]=v,e[15]=b,e[16]=_,e[17]=y):y=e[17];const{data:L,isLoading:w,isError:j,hasNextPage:S,isFetchingNextPage:k,fetchNextPage:C}=tp(y),A=new Map;for(const H of L?.pages??[])for(const U of H.branches)typeof U.name=="string"&&A.set(U.name,U);const P=[...A.values()].filter(DU).map(RU);let V=l;for(const H of m)H.desiredState!=="running"||H.status!=="ready"||!H.sandboxHandle||(V={...V??{},[o]:{...V?.[o]??{},[H.branch]:{...V?.[o]?.[H.branch]??{},"agent-sandbox":{sandboxHandle:H.sandboxHandle,previewUrl:H.previewUrl,sandboxApiUrl:H.sandboxApiUrl,sandboxProviderKind:"agent-sandbox",createdAt:Date.parse(H.updatedAt)}}}});const{recent:T,yours:R,others:E}=CU({sandboxMap:V,userId:o,rawBranches:P,now:Date.now()}),I=Set,D=[...T,...R].map(PU);let M;e[18]!==D||e[19]!==I?(M=new I(D),e[18]=D,e[19]=I,e[20]=M):M=e[20];const O=M;let $;e[21]!==L?.pages?($=L?.pages.find(EU)?.default_branch??null,e[21]=L?.pages,e[22]=$):$=e[22];const B=$;let z;e[23]!==L?.pages||e[24]!==C||e[25]!==k||e[26]!==O?(z=async(H,U)=>{const X=U===void 0?AU:U;if(!X()||VU(O,H)||k)return;let J=L?.pages??[];for(;X()&&!kU(J,H,O)&&(J.at(-1)?.branches.length??ll)>=ll;){const ee=await C();if(!X())break;const W=ee.data?.pages??J;if(W.length===J.length)break;J=W}},e[23]=L?.pages,e[24]=C,e[25]=k,e[26]=O,e[27]=z):z=e[27];const K=z,Y=S??!1;let Q;e[28]!==C||e[29]!==S||e[30]!==k?(Q=()=>{S&&!k&&C()},e[28]=C,e[29]=S,e[30]=k,e[31]=Q):Q=e[31];let q;return e[32]!==B||e[33]!==K||e[34]!==j||e[35]!==k||e[36]!==w||e[37]!==E||e[38]!==T||e[39]!==Y||e[40]!==Q||e[41]!==R?(q={recent:T,yours:R,others:E,defaultBase:B,isLoading:w,isError:j,hasMore:Y,isFetchingMore:k,fetchMore:Q,fetchUntilMatch:K},e[32]=B,e[33]=K,e[34]=j,e[35]=k,e[36]=w,e[37]=E,e[38]=T,e[39]=Y,e[40]=Q,e[41]=R,e[42]=q):q=e[42],q}function AU(){return!0}function EU(t){return t.default_branch}function PU(t){return t.name}function RU(t){return{name:t.name,author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function DU(t){return typeof t.name=="string"}function IU(t){if(!(t.branches.length<ll))return t.page+1}function MU(t){const e=F.c(138),{orgId:s,orgSlug:n,userId:i,userLabel:o,virtualMcpId:a,connectionId:l,owner:c,repo:d,sandboxMap:h,value:u,onChange:f,disabled:m,placement:p}=t,g=m===void 0?!1:m,x=p===void 0?"chat":p,v=oe(),b=x==="header",[_,y]=N.useState(!1),[L,w]=N.useState("branches"),[j,S]=N.useState(""),[k,C]=N.useState(!1),A=N.useRef(0);let P;e[0]!==l||e[1]!==_||e[2]!==s||e[3]!==n||e[4]!==c||e[5]!==d||e[6]!==h||e[7]!==i||e[8]!==a?(P={orgId:s,orgSlug:n,virtualMcpId:a,userId:i,connectionId:l,sandboxMap:h,owner:c,repo:d,enabled:_},e[0]=l,e[1]=_,e[2]=s,e[3]=n,e[4]=c,e[5]=d,e[6]=h,e[7]=i,e[8]=a,e[9]=P):P=e[9];const{recent:V,yours:T,others:R,isLoading:E,isError:I,hasMore:D,isFetchingMore:M,fetchMore:O,fetchUntilMatch:$}=TU(P);let B;e[10]!==_?(B={enabled:_},e[10]=_,e[11]=B):B=e[11];const{data:z}=j8(B);let K;e[12]!==z?.data?.members?(K=new Map((z?.data?.members??[]).map(OU)),e[12]=z?.data?.members,e[13]=K):K=e[13];const Y=K,Q=l??"",q=_&&L==="prs";let H;e[14]!==s||e[15]!==n||e[16]!==c||e[17]!==d||e[18]!==Q||e[19]!==q?(H={orgId:s,orgSlug:n,connectionId:Q,owner:c,repo:d,enabled:q},e[14]=s,e[15]=n,e[16]=c,e[17]=d,e[18]=Q,e[19]=q,e[20]=H):H=e[20];const{data:U,isLoading:X,isError:J}=OS(H);let ee,W,Z,G,te,se,re,de,ce,fe,ue,ae,me;if(e[21]!==g||e[22]!==O||e[23]!==$||e[24]!==D||e[25]!==I||e[26]!==M||e[27]!==b||e[28]!==E||e[29]!==k||e[30]!==Y||e[31]!==f||e[32]!==_||e[33]!==R||e[34]!==c||e[35]!==J||e[36]!==X||e[37]!==V||e[38]!==d||e[39]!==j||e[40]!==v||e[41]!==U||e[42]!==L||e[43]!==o||e[44]!==u||e[45]!==T){const Ne=U===void 0?[]:U,Ee=`${c}/${d}`;let we;e[59]!==Ee?(we=Ee.toLowerCase(),e[59]=Ee,e[60]=we):we=e[60];const Ae=we;let be;e[61]!==Ae?(be=ne=>ne.headRepoFullName?.toLowerCase()===Ae,e[61]=Ae,e[62]=be):be=e[62];const je=Ne.filter(be),ge=Ne.length-je.length;let Le;e[63]!==f?(Le=ne=>{f(ne),y(!1)},e[63]=f,e[64]=Le):Le=e[64];const ye=Le;let Ce;e[65]!==v||e[66]!==u?(Ce=u??v("thread.branchPicker.selectBranch"),e[65]=v,e[66]=u,e[67]=Ce):Ce=e[67];const Me=Ce;let Re;e[68]!==$||e[69]!==L?(Re=ne=>{S(ne),A.current=A.current+1;const De=A.current,Ke=ne.trim();if(!Ke||L!=="branches"){C(!1);return}C(!0),$(Ke,()=>De===A.current).finally(()=>{De===A.current&&C(!1)})},e[68]=$,e[69]=L,e[70]=Re):Re=e[70];const ke=Re;let $e;e[71]!==O||e[72]!==L?($e=ne=>{const De=ne.currentTarget,Ke=De.scrollHeight-De.scrollTop-De.clientHeight;L==="branches"&&Ke<48&&O()},e[71]=O,e[72]=L,e[73]=$e):$e=e[73];const qe=$e;G=Es,ue=_,ae=g?void 0:y;const lt=b?"outline":"ghost",ft=b?"sm":"default";let dt;e[74]!==g||e[75]!==b?(dt=ie("font-mono shrink min-w-0 max-w-[200px]",b?"gap-1.5 text-xs":ie("text-xs text-muted-foreground hover:text-foreground transition-[gap] duration-200",g?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5")),e[74]=g,e[75]=b,e[76]=dt):dt=e[76];let it;e[77]===Symbol.for("react.memo_cache_sentinel")?(it=r.jsx(en,{className:"h-3.5 w-3.5 shrink-0"}),e[77]=it):it=e[77];const xt=b?"":"transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[200px] @[320px]/chat-bottom:opacity-100";let vt;e[78]!==xt?(vt=ie("min-w-0 truncate",xt),e[78]=xt,e[79]=vt):vt=e[79];let pe;e[80]!==Me||e[81]!==vt?(pe=r.jsx("span",{className:vt,children:Me}),e[80]=Me,e[81]=vt,e[82]=pe):pe=e[82];let Be;e[83]!==g||e[84]!==b?(Be=!g&&r.jsx(is,{size:12,className:ie("opacity-60 shrink-0",b?"":"hidden @[320px]/chat-bottom:inline-block")}),e[83]=g,e[84]=b,e[85]=Be):Be=e[85];let Xe;e[86]!==g||e[87]!==Me||e[88]!==lt||e[89]!==ft||e[90]!==dt||e[91]!==pe||e[92]!==Be?(Xe=r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"inline-flex min-w-0 shrink","data-tour":Pn.branches,children:r.jsx(Ts,{asChild:!0,children:r.jsxs(le,{variant:lt,size:ft,"aria-label":Me,disabled:g,className:dt,children:[it,pe,Be]})})})}),e[86]=g,e[87]=Me,e[88]=lt,e[89]=ft,e[90]=dt,e[91]=pe,e[92]=Be,e[93]=Xe):Xe=e[93];let gt;e[94]!==Me?(gt=r.jsx(He,{children:Me}),e[94]=Me,e[95]=gt):gt=e[95],e[96]!==Xe||e[97]!==gt?(me=r.jsxs(We,{children:[Xe,gt]}),e[96]=Xe,e[97]=gt,e[98]=me):me=e[98],Z=As,ce="w-[min(420px,calc(100vw-2rem))] p-0",fe="start",W=Dr;let Vt;e[99]!==v||e[100]!==L?(Vt=L==="branches"?v("thread.branchPicker.searchLoadedBranches"):"Search pull requests…",e[99]=v,e[100]=L,e[101]=Vt):Vt=e[101];let zt;e[102]!==ke||e[103]!==j||e[104]!==Vt?(zt=r.jsx(Hi,{placeholder:Vt,value:j,onValueChange:ke}),e[102]=ke,e[103]=j,e[104]=Vt,e[105]=zt):zt=e[105];let Nt;e[106]!==ye||e[107]!==v||e[108]!==L||e[109]!==o?(Nt=L==="branches"&&r.jsx(le,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>ye(wU(o)),children:v("thread.branchPicker.new")}),e[106]=ye,e[107]=v,e[108]=L,e[109]=o,e[110]=Nt):Nt=e[110],e[111]!==zt||e[112]!==Nt?(re=r.jsxs("div",{className:"*:data-[slot=command-input-wrapper]:flex-1 *:data-[slot=command-input-wrapper]:border-b-0 flex items-center border-b pr-2",children:[zt,Nt]}),e[111]=zt,e[112]=Nt,e[113]=re):re=e[113];let ct;e[114]===Symbol.for("react.memo_cache_sentinel")?(ct=ne=>{w(ne),S("")},e[114]=ct):ct=e[114];let Rs;e[115]===Symbol.for("react.memo_cache_sentinel")?(Rs=r.jsxs(oa,{className:"h-auto w-fit justify-start gap-1 bg-accent p-1",variant:"pill",children:[r.jsx(vn,{value:"branches",className:"h-6 px-2.5 text-xs",children:"Branches"}),r.jsx(vn,{value:"prs",className:"h-6 px-2.5 text-xs",children:"PRs"})]}),e[115]=Rs):Rs=e[115],e[116]!==L?(de=r.jsx(Er,{className:"px-2 pt-2 pb-1",value:L,onValueChange:ct,children:Rs}),e[116]=L,e[117]=de):de=e[117],ee=Wi,te=qe,se=L==="prs"?r.jsxs(r.Fragment,{children:[J&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load pull requests from GitHub."}),X&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Loading pull requests…"}),!J&&!X&&r.jsx(oi,{children:j.trim()?"No pull requests match your search.":"No open pull requests."}),je.length>0&&r.jsx(Os,{heading:"Open pull requests",children:je.map(ne=>r.jsxs(ks,{value:`#${ne.number} ${ne.title} ${ne.head}`,className:"cursor-pointer",onSelect:()=>ye(ne.head),children:[r.jsx(nb,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate",children:jr(ne.title)}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["#",ne.number," · ",ne.head,ne.author?` · @${ne.author}`:""]})]})]},ne.number))}),ge>0&&r.jsxs("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:[ge," PR",ge>1?"s":""," from forks hidden — open on a branch in this repo"]})]}):r.jsxs(r.Fragment,{children:[I&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:v("thread.branchPicker.couldntLoadBranches")}),!I&&!E&&r.jsx(oi,{children:v(D?"thread.branchPicker.lookingThroughMoreBranches":"thread.branchPicker.noBranchesFound")}),V.length>0&&r.jsx(Os,{heading:"Last 7 days",children:V.map(ne=>r.jsxs(ks,{value:ne.name,className:"cursor-pointer",onSelect:()=>ye(ne.name),children:[r.jsx(en,{className:"mr-2 h-4 w-4 shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:ne.name}),r.jsx($U,{userIds:ne.contributors??[],memberById:Y})]},ne.name))}),T.length>0&&r.jsxs(r.Fragment,{children:[V.length>0&&r.jsx(lh,{}),r.jsx(Os,{heading:v("thread.branchPicker.yourBranches"),children:T.map(ne=>r.jsxs(ks,{value:ne.name,className:"cursor-pointer",onSelect:()=>ye(ne.name),children:[r.jsx(en,{className:"mr-2 h-4 w-4 shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:ne.name})]},ne.name))})]}),R.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(lh,{}),r.jsx(Os,{heading:v("thread.branchPicker.otherBranchesInRepo"),children:R.map(ne=>r.jsxs(ks,{value:ne.name,className:"cursor-pointer",onSelect:()=>ye(ne.name),children:[r.jsx(en,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:ne.name}),ne.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",ne.author]})]},ne.name))})]}),D&&r.jsx("div",{className:"border-t p-2",children:r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:M,onClick:O,children:v(M||k?"thread.branchPicker.loadingMore":"thread.branchPicker.loadMoreBranches")})}),!D&&R.length>0&&r.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:v("thread.branchPicker.allLoaded")})]}),e[21]=g,e[22]=O,e[23]=$,e[24]=D,e[25]=I,e[26]=M,e[27]=b,e[28]=E,e[29]=k,e[30]=Y,e[31]=f,e[32]=_,e[33]=R,e[34]=c,e[35]=J,e[36]=X,e[37]=V,e[38]=d,e[39]=j,e[40]=v,e[41]=U,e[42]=L,e[43]=o,e[44]=u,e[45]=T,e[46]=ee,e[47]=W,e[48]=Z,e[49]=G,e[50]=te,e[51]=se,e[52]=re,e[53]=de,e[54]=ce,e[55]=fe,e[56]=ue,e[57]=ae,e[58]=me}else ee=e[46],W=e[47],Z=e[48],G=e[49],te=e[50],se=e[51],re=e[52],de=e[53],ce=e[54],fe=e[55],ue=e[56],ae=e[57],me=e[58];let xe;e[118]!==ee||e[119]!==te||e[120]!==se?(xe=r.jsx(ee,{onScroll:te,children:se}),e[118]=ee,e[119]=te,e[120]=se,e[121]=xe):xe=e[121];let Se;e[122]!==W||e[123]!==re||e[124]!==de||e[125]!==xe?(Se=r.jsxs(W,{children:[re,de,xe]}),e[122]=W,e[123]=re,e[124]=de,e[125]=xe,e[126]=Se):Se=e[126];let Ve;e[127]!==Z||e[128]!==ce||e[129]!==fe||e[130]!==Se?(Ve=r.jsx(Z,{className:ce,align:fe,children:Se}),e[127]=Z,e[128]=ce,e[129]=fe,e[130]=Se,e[131]=Ve):Ve=e[131];let Ie;return e[132]!==G||e[133]!==ue||e[134]!==ae||e[135]!==me||e[136]!==Ve?(Ie=r.jsxs(G,{open:ue,onOpenChange:ae,children:[me,Ve]}),e[132]=G,e[133]=ue,e[134]=ae,e[135]=me,e[136]=Ve,e[137]=Ie):Ie=e[137],Ie}function OU(t){return[t.userId,t.user]}function $U(t){const e=F.c(13),{userIds:s,memberById:n}=t;if(s.length===0)return null;let i,o,a;if(e[0]!==n||e[1]!==s){const d=s.slice(0,3);i=s.length-d.length,o="ml-2 flex shrink-0 items-center -space-x-1.5";let h;e[5]!==n?(h=u=>{const f=n.get(u);return r.jsx(ur,{url:f?.image??void 0,fallback:q8(f?.name??void 0),shape:"circle",size:"xs",className:"ring-2 ring-background"},u)},e[5]=n,e[6]=h):h=e[6],a=d.map(h),e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=a}else i=e[2],o=e[3],a=e[4];let l;e[7]!==i?(l=i>0&&r.jsxs("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-[9px] font-semibold text-muted-foreground ring-2 ring-background",children:["+",i]}),e[7]=i,e[8]=l):l=e[8];let c;return e[9]!==o||e[10]!==a||e[11]!==l?(c=r.jsxs("span",{className:o,children:[a,l]}),e[9]=o,e[10]=a,e[11]=l,e[12]=c):c=e[12],c}function BU(t){const e=F.c(25);let s,n,i,o;e[0]!==t?({locked:s,placement:n,value:o,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i,e[4]=o):(s=e[1],n=e[2],i=e[3],o=e[4]);const a=n==="header";if(s){const c=o??"(no branch)",d=a?"h-8 gap-1.5 border border-input bg-background px-2.5":"h-9 gap-0 px-2";let h;e[5]!==d?(h=ie("inline-flex items-center rounded-md font-mono text-xs","text-muted-foreground cursor-default min-w-0 max-w-[200px]",d),e[5]=d,e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(en,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e[7]=u):u=e[7];const f=a?"":"max-w-0 opacity-0";let m;e[8]!==f?(m=ie("min-w-0 truncate",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==m?(p=r.jsx("span",{className:m,children:c}),e[10]=c,e[11]=m,e[12]=p):p=e[12];let g;e[13]!==h||e[14]!==p?(g=r.jsx(Ue,{asChild:!0,children:r.jsxs("span",{"data-testid":"branch-picker-locked","aria-disabled":"true",className:h,children:[u,p]})}),e[13]=h,e[14]=p,e[15]=g):g=e[15];let x;e[16]!==c?(x=r.jsxs(He,{children:["This chat is using branch ",c,". Start a new chat to use a different branch."]}),e[16]=c,e[17]=x):x=e[17];let v;return e[18]!==g||e[19]!==x?(v=r.jsxs(We,{children:[g,x]}),e[18]=g,e[19]=x,e[20]=v):v=e[20],v}let l;return e[21]!==n||e[22]!==i||e[23]!==o?(l=r.jsx(MU,{...i,value:o,placement:n}),e[21]=n,e[22]=i,e[23]=o,e[24]=l):l=e[24],l}function FU(t){const e=F.c(2),{branchPill:s}=t;if(!s)return null;let n;return e[0]!==s?(n=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=n):n=e[1],n}function zU(t){const e=F.c(21),{virtualMcp:s,currentBranch:n}=t,i=Q0(),o=hi();let a;e[0]!==i?.messages||e[1]!==o?.isThreadLocked?(a=(i?.messages??[]).length>0||(o?.isThreadLocked??!1),e[0]=i?.messages,e[1]=o?.isThreadLocked,e[2]=a):a=e[2];const l=a,c=o?.setCurrentTaskBranch;let d;e[3]!==s?(d=aa(s),e[3]=s,e[4]=d):d=e[4];const h=d,u=h?.connectionId,{data:f}=ui.useSession(),m=f?.user?.id??"";let p;e[5]!==f?.user?.email||e[6]!==f?.user?.name?(p=f?.user?.name??f?.user?.email?.split("@")[0],e[5]=f?.user?.email,e[6]=f?.user?.name,e[7]=p):p=e[7];const g=p,{org:x}=ze();let v;e[8]!==u||e[9]!==n||e[10]!==h||e[11]!==l||e[12]!==x||e[13]!==c||e[14]!==m||e[15]!==g||e[16]!==s?.id||e[17]!==s?.metadata?.sandboxMap?(v=h&&u?r.jsx(BU,{orgId:x.id,orgSlug:x.slug,userId:m,userLabel:g,virtualMcpId:s?.id??"",connectionId:u,owner:h.owner,repo:h.name,sandboxMap:s?.metadata?.sandboxMap,value:n,onChange:y=>{c&&c(y)},locked:l,placement:"chat"}):null,e[8]=u,e[9]=n,e[10]=h,e[11]=l,e[12]=x,e[13]=c,e[14]=m,e[15]=g,e[16]=s?.id,e[17]=s?.metadata?.sandboxMap,e[18]=v):v=e[18];const b=v;let _;return e[19]!==b?(_=r.jsx(FU,{branchPill:b}),e[19]=b,e[20]=_):_=e[20],_}function xx(t){const e=F.c(4),{chatContent:s}=t;let n;e[0]!==s?(n=s??r.jsx(Mp,{}),e[0]=s,e[1]=n):n=e[1];let i;return e[2]!==n?(i=r.jsx("div",{"data-testid":"chat-panel",className:"h-full min-h-0",children:n}),e[2]=n,e[3]=i):i=e[3],i}function Lm(t){const e=F.c(11),{sidePanel:s,toggleSidePanel:n,disableActiveSidePanelToggle:i}=t,o=i===void 0?!1:i,a=oe();let l;e[0]!==a?(l=a("agentShellLayout.toggleButtons.chat"),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={kind:"component",Component:_2},e[2]=c):c=e[2];const d=s==="chat",h=o&&s==="chat";let u;e[3]!==s||e[4]!==n?(u=()=>{Fe("agent_toolbar_toggled",{button:"chat",next_state:s==="chat"?"closed":"open"}),n("chat")},e[3]=s,e[4]=n,e[5]=u):u=e[5];let f;return e[6]!==l||e[7]!==d||e[8]!==h||e[9]!==u?(f=r.jsx(x9,{title:l,icon:c,active:d,disabled:h,className:"wco-no-drag h-10 md:h-7 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50",onClick:u}),e[6]=l,e[7]=d,e[8]=h,e[9]=u,e[10]=f):f=e[10],f}function Sm(t){const e=F.c(6),{children:s,header:n,testId:i}=t;let o;e[0]!==s||e[1]!==i?(o=r.jsx("div",{"data-testid":i,className:"min-h-0 flex-1 overflow-hidden rounded-[0.75rem] bg-background card-shadow [transform:translateZ(0)]",children:s}),e[0]=s,e[1]=i,e[2]=o):o=e[2];let a;return e[3]!==n||e[4]!==o?(a=r.jsxs("div",{className:"flex h-full min-h-0 flex-col p-0.5 pt-0.25",children:[n,o]}),e[3]=n,e[4]=o,e[5]=a):a=e[5],a}function wm(t){const e=F.c(5),{virtualMcpId:s,taskId:n,disableActiveMainToggle:i,maxVisible:o}=t;let a;return e[0]!==i||e[1]!==o||e[2]!==n||e[3]!==s?(a=r.jsx(OK,{virtualMcpId:s,taskId:n,disableActiveMainToggle:i,maxVisible:o}),e[0]=i,e[1]=o,e[2]=n,e[3]=s,e[4]=a):a=e[4],a}function KU(t){const e=F.c(104),{virtualMcpId:s,taskId:n,entity:i,sidePanel:o,mainOpen:a,toggleSidePanel:l,chatContent:c}=t,[,d]=N.useTransition(),[h,u]=bS(),f=N.useRef(null);let m;e[0]!==a||e[1]!==o?(m=fS({sidePanel:o,mainOpen:a}),e[0]=a,e[1]=o,e[2]=m):m=e[2];const p=m,g=o!==null&&a?h:p.side,x=100-g,v=o!==null,b=v&&!a,[_,y]=Rh(),[L,w]=Rh();let j;e[3]!==_||e[4]!==L?(j=HK(_,L),e[3]=_,e[4]=L,e[5]=j):j=e[5];const{maxTabs:S,showPageSelector:k}=j,{state:C}=A8(),A=C==="collapsed";let P;e[6]!==A?(P=A?r.jsx(cb,{}):null,e[6]=A,e[7]=P):P=e[7];const V=P;let T;e[8]!==A?(T=A?r.jsx(db,{}):null,e[8]=A,e[9]=T):T=e[9];const R=T;let E;e[10]!==i?(E=r.jsx(LU,{virtualMcp:i}),e[10]=i,e[11]=E):E=e[11];const I=E,D=hi()?.currentBranch??null;let M;e[12]!==D||e[13]!==i?(M=r.jsx(zU,{virtualMcp:i,currentBranch:D}),e[12]=D,e[13]=i,e[14]=M):M=e[14];const O=M;let $,B;e[15]!==x||e[16]!==g?($=()=>{f.current?.setLayout([g,x])},B=[g,x],e[15]=x,e[16]=g,e[17]=$,e[18]=B):($=e[17],B=e[18]),N.useEffect($,B);const z=!a;let K;e[19]!==o||e[20]!==z||e[21]!==l?(K=r.jsx(Lm,{sidePanel:o,toggleSidePanel:l,disableActiveSidePanelToggle:z}),e[19]=o,e[20]=z,e[21]=l,e[22]=K):K=e[22];let Y;e[23]!==b||e[24]!==n||e[25]!==s?(Y=b&&r.jsx(wm,{virtualMcpId:s,taskId:n,disableActiveMainToggle:!0}),e[23]=b,e[24]=n,e[25]=s,e[26]=Y):Y=e[26];const Q=b&&O,q=b&&I;let H;e[27]!==R||e[28]!==Q||e[29]!==q?(H=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[Q,q,R]}),e[27]=R,e[28]=Q,e[29]=q,e[30]=H):H=e[30];let U;e[31]!==V||e[32]!==K||e[33]!==Y||e[34]!==H?(U=r.jsxs(kf,{children:[V,K,Y,H]}),e[31]=V,e[32]=K,e[33]=Y,e[34]=H,e[35]=U):U=e[35];const X=U,J=!v&&V;let ee;e[36]!==v||e[37]!==o||e[38]!==l?(ee=!v&&r.jsx(Lm,{sidePanel:o,toggleSidePanel:l}),e[36]=v,e[37]=o,e[38]=l,e[39]=ee):ee=e[39];const W=!v;let Z;e[40]!==S||e[41]!==W||e[42]!==n||e[43]!==s?(Z=r.jsx(wm,{virtualMcpId:s,taskId:n,disableActiveMainToggle:W,maxVisible:S}),e[40]=S,e[41]=W,e[42]=n,e[43]=s,e[44]=Z):Z=e[44];let G;e[45]!==J||e[46]!==ee||e[47]!==Z?(G=r.jsxs("div",{className:"flex min-w-0 shrink items-center gap-0.5 overflow-hidden",children:[J,ee,Z]}),e[45]=J,e[46]=ee,e[47]=Z,e[48]=G):G=e[48];const te=!k&&"hidden";let se;e[49]!==te?(se=ie(te),e[49]=te,e[50]=se):se=e[50];let re;e[51]!==se?(re=r.jsx("div",{className:"flex min-w-0 flex-1 items-center justify-center",children:r.jsx(QA,{className:se})}),e[51]=se,e[52]=re):re=e[52];const de=!v&&R;let ce;e[53]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(ZA,{}),e[53]=ce):ce=e[53];let fe;e[54]!==O||e[55]!==I||e[56]!==w||e[57]!==de?(fe=r.jsxs("div",{ref:w,className:"flex shrink-0 items-center justify-end gap-1",children:[de,O,ce,I]}),e[54]=O,e[55]=I,e[56]=w,e[57]=de,e[58]=fe):fe=e[58];let ue;e[59]!==y||e[60]!==G||e[61]!==re||e[62]!==fe?(ue=r.jsxs(kf,{ref:y,className:"justify-between gap-2",children:[G,re,fe]}),e[59]=y,e[60]=G,e[61]=re,e[62]=fe,e[63]=ue):ue=e[63];const ae=ue;let me;e[64]!==s?(me=r.jsx(GA,{virtualMcpId:s}),e[64]=s,e[65]=me):me=e[65];const xe=`${s}-${n}`;let Se;e[66]===Symbol.for("react.memo_cache_sentinel")?(Se={overflow:"visible"},e[66]=Se):Se=e[66];const Ve=p.side,Ie=o!==null?"min-w-[320px]":"min-w-0";let Ne;e[67]!==Ie?(Ne=ie("overflow-hidden bg-sidebar",Ie),e[67]=Ie,e[68]=Ne):Ne=e[68];let Ee;e[69]!==a||e[70]!==u||e[71]!==o?(Ee=ft=>d(()=>{o!==null&&a&&ft>0&&ft<100&&u(ft)}),e[69]=a,e[70]=u,e[71]=o,e[72]=Ee):Ee=e[72];const we=v?X:null;let Ae;e[73]!==c||e[74]!==v?(Ae=v&&r.jsx(xx,{chatContent:c}),e[73]=c,e[74]=v,e[75]=Ae):Ae=e[75];let be;e[76]!==we||e[77]!==Ae?(be=r.jsx(Sm,{testId:"side-panel",header:we,children:Ae}),e[76]=we,e[77]=Ae,e[78]=be):be=e[78];let je;e[79]!==p.side||e[80]!==Ne||e[81]!==Ee||e[82]!==be?(je=r.jsx(fl,{order:1,defaultSize:Ve,minSize:20,collapsible:!0,collapsedSize:0,className:Ne,onResize:Ee,children:be}),e[79]=p.side,e[80]=Ne,e[81]=Ee,e[82]=be,e[83]=je):je=e[83];let ge;e[84]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsx(k2,{className:"bg-sidebar"}),e[84]=ge):ge=e[84];const Le=p.main,ye=a?"min-w-[320px]":"min-w-0";let Ce;e[85]!==ye?(Ce=ie("min-w-0 overflow-hidden bg-sidebar",ye),e[85]=ye,e[86]=Ce):Ce=e[86];const Me=a?ae:null;let Re;e[87]!==n||e[88]!==s?(Re=r.jsx(fx,{taskId:n,virtualMcpId:s}),e[87]=n,e[88]=s,e[89]=Re):Re=e[89];let ke;e[90]!==Me||e[91]!==Re?(ke=r.jsx(Sm,{testId:"main-panel",header:Me,children:Re}),e[90]=Me,e[91]=Re,e[92]=ke):ke=e[92];let $e;e[93]!==p.main||e[94]!==Ce||e[95]!==ke?($e=r.jsx(fl,{order:2,defaultSize:Le,minSize:20,collapsible:!0,collapsedSize:0,className:Ce,children:ke}),e[93]=p.main,e[94]=Ce,e[95]=ke,e[96]=$e):$e=e[96];let qe;e[97]!==xe||e[98]!==je||e[99]!==$e?(qe=r.jsxs(C2,{ref:f,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:Se,children:[je,ge,$e]},xe),e[97]=xe,e[98]=je,e[99]=$e,e[100]=qe):qe=e[100];let lt;return e[101]!==me||e[102]!==qe?(lt=r.jsxs(XA,{children:[me,qe]}),e[101]=me,e[102]=qe,e[103]=lt):lt=e[103],lt}const Pd="__mobile-main-panel-tab-select__";function UU({tabs:t,activeTab:e,mainOpen:s,t:n}){const i=t.find(a=>a.id===e),o=n("mainPanelTabs.mobileMainPanelTabSelect.mainView");return s?i?.title??o:i?.title??t[0]?.title??o}const HU={kind:"component",Component:_2},WU={kind:"component",Component:y2},qU={kind:"component",Component:ri};function GU(t){const e=F.c(62),{virtualMcpId:s,taskId:n}=t,i=oe(),o=jt();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const l=Yl(a);let c;e[1]!==n||e[2]!==s?(c={virtualMcpId:s,taskId:n},e[1]=n,e[2]=s,e[3]=c):c=e[3];const{tabs:d,activeTab:h,mainOpen:u}=J9(c),{org:f}=ze(),m=rc();let p;e[4]!==f.id?(p=dl(f.id),e[4]=f.id,e[5]=p):p=e[5];const g=s===p,x=!!(l.org&&l.taskId);let v;e[6]!==i?(v=i("mainPanelTabs.mobileMainPanelTabSelect.chat"),e[6]=i,e[7]=v):v=e[7];let b;e[8]!==v?(b={value:"chat",title:v,icon:HU},e[8]=v,e[9]=b):b=e[9];let _;if(e[10]!==x||e[11]!==i||e[12]!==b||e[13]!==d){let B,z;e[15]!==x||e[16]!==i?(B=x?[{value:"board",title:i("mainPanelTabs.mobileMainPanelTabSelect.tasks"),icon:WU}]:[],z=x?[{value:"files",title:i("mainPanelTabs.mobileMainPanelTabSelect.library"),icon:qU}]:[],e[15]=x,e[16]=i,e[17]=B,e[18]=z):(B=e[17],z=e[18]),_=[b,...d.map(JU),...B,...z],e[10]=x,e[11]=i,e[12]=b,e[13]=d,e[14]=_}else _=e[14];const y=_;let L;e[19]!==h||e[20]!==u||e[21]!==y?(L=u?y.find(B=>B.value===h)?.value??h:"chat",e[19]=h,e[20]=u,e[21]=y,e[22]=L):L=e[22];const w=L;let j;e[23]!==w||e[24]!==y?(j=y.find(B=>B.value===w),e[23]=w,e[24]=y,e[25]=j):j=e[25];const S=j;let k;e[26]!==h||e[27]!==u||e[28]!==S?.title||e[29]!==i||e[30]!==d?(k=S?.title??UU({tabs:d,activeTab:h,mainOpen:u,t:i}),e[26]=h,e[27]=u,e[28]=S?.title,e[29]=i,e[30]=d,e[31]=k):k=e[31];const C=k;let A;e[32]!==o||e[33]!==g||e[34]!==f.id||e[35]!==f.slug||e[36]!==m||e[37]!==s?(A=B=>{if(B!==Pd){if(Fe("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:B,source:"mobile_select"}),b3({reportsOnly:m,onReportAgent:g,tabId:B})){o({to:"/$org/$taskId",params:{org:f.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:dl(f.id),main:B}});return}o({to:".",search:z=>B==="chat"?{...z,sidepanel:"chat",main:0}:{...z,sidepanel:0,main:B},replace:!0})}},e[32]=o,e[33]=g,e[34]=f.id,e[35]=f.slug,e[36]=m,e[37]=s,e[38]=A):A=e[38];const P=A;let V;e[39]!==i?(V=i("mainPanelTabs.mobileMainPanelTabSelect.view"),e[39]=i,e[40]=V):V=e[40];let T;e[41]!==S?(T=S&&r.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:r.jsx(v9,{icon:S.icon,className:"size-5"})}),e[41]=S,e[42]=T):T=e[42];let R;e[43]!==C?(R=r.jsx("span",{className:"min-w-0 truncate",children:C}),e[43]=C,e[44]=R):R=e[44];let E;e[45]!==T||e[46]!==R?(E=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[T,R]}),e[45]=T,e[46]=R,e[47]=E):E=e[47];let I;e[48]!==V||e[49]!==E?(I=r.jsx($t,{"aria-label":V,className:"h-10! w-full min-w-0 max-w-[7.5rem] rounded-md border-0 bg-transparent px-1.5 text-xs shadow-none [--card-shadow:none]",children:E}),e[48]=V,e[49]=E,e[50]=I):I=e[50];let D;e[51]!==C?(D=r.jsx(ut,{value:Pd,disabled:!0,hideCheck:!0,className:"hidden",children:C}),e[51]=C,e[52]=D):D=e[52];let M;e[53]!==y?(M=y.map(YU),e[53]=y,e[54]=M):M=e[54];let O;e[55]!==D||e[56]!==M?(O=r.jsxs(Bt,{align:"end",className:"w-56",children:[D,M]}),e[55]=D,e[56]=M,e[57]=O):O=e[57];let $;return e[58]!==P||e[59]!==I||e[60]!==O?($=r.jsxs(Ft,{value:Pd,onValueChange:P,children:[I,O]}),e[58]=P,e[59]=I,e[60]=O,e[61]=$):$=e[61],$}function YU(t){return r.jsx(ut,{value:t.value,children:r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:r.jsx(v9,{icon:t.icon})}),r.jsx("span",{className:"min-w-0 truncate",children:t.title})]})},t.value)}function JU(t){return{value:t.id,title:t.title,icon:t.icon}}function XU(t,e){const s=F.c(34),n=Zm(),i=N.useSyncExternalStore(n.threads.subscribe,n.threads.get),o=N.useSyncExternalStore(n.threadsStatus.subscribe,n.threadsStatus.get);let a;s[0]!==t||s[1]!==i?(a=t?i.find(_=>_.id===t)??null:null,s[0]=t,s[1]=i,s[2]=a):a=s[2];const l=a,[c,d]=N.useState(void 0);let h;s[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{d(void 0)},s[3]=h):h=s[3];let u;s[4]!==t?(u=[t],s[4]=t,s[5]=u):u=s[5],N.useEffect(h,u);let f,m;s[6]!==c||s[7]!==t||s[8]!==l||s[9]!==n||s[10]!==o.kind?(f=()=>{t&&(l||o.kind!=="loading"&&c===void 0&&(d("pending"),n.fetchThread(t).then(_=>{d(_)})))},m=[t,l,o.kind,c,n],s[6]=c,s[7]=t,s[8]=l,s[9]=n,s[10]=o.kind,s[11]=f,s[12]=m):(f=s[11],m=s[12]),N.useEffect(f,m);let p;s[13]!==n||s[14]!==e?(p={mutationFn:async _=>n.create({id:_,virtual_mcp_id:e})},s[13]=n,s[14]=e,s[15]=p):p=s[15];const g=Ys(p);let x,v;if(s[16]!==g||s[17]!==c||s[18]!==t||s[19]!==l||s[20]!==o.kind?(x=()=>{t&&(l||c===null&&o.kind!=="loading"&&(g.isPending||g.variables!==t&&g.mutate(t)))},v=[t,l,c,o.kind,g],s[16]=g,s[17]=c,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=x,s[22]=v):(x=s[21],v=s[22]),N.useEffect(x,v),!t){let _;return s[23]===Symbol.for("react.memo_cache_sentinel")?(_={status:"ready",task:null},s[23]=_):_=s[23],_}if(l){let _;return s[24]!==l?(_={status:"ready",task:l},s[24]=l,s[25]=_):_=s[25],_}if(c&&typeof c=="object"){let _;return s[26]!==c?(_={status:"ready",task:c},s[26]=c,s[27]=_):_=s[27],_}if(g.data){let _;return s[28]!==g.data?(_={status:"ready",task:g.data},s[28]=g.data,s[29]=_):_=s[29],_}if(g.isError){let _;return s[30]!==g.error?(_={status:"error",error:g.error},s[30]=g.error,s[31]=_):_=s[31],_}if(g.isPending||o.kind!=="loading"){let _;return s[32]===Symbol.for("react.memo_cache_sentinel")?(_={status:"creating"},s[32]=_):_=s[32],_}let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[33]=b):b=s[33],b}function QU(){const t=F.c(6),e=Tr(),s=jt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const{preview:i}=Vr(n);if(!e||!i)return null;let o;t[1]!==s?(o=()=>s({to:".",search:ZU}),t[1]=s,t[2]=o):o=t[2];let a;return t[3]!==i||t[4]!==o?(a=r.jsx(zb,{previewPath:i,showSeeInLibrary:!0,onClose:o}),t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function ZU(t){const{preview:e,...s}=t;return s}const lr=N.createContext(null);function Kn(){return N.use(lr)}function vx(t){const e=F.c(12),{children:s}=t,n=oe();let i;e[0]!==n?(i=n("agentShellLayout.agentShellLayout.chatLoadingError"),e[0]=n,e[1]=i):i=e[1];let o;e[2]!==i?(o=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:i}),e[2]=i,e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(St.Skeleton,{}),e[4]=a):a=e[4];let l;e[5]!==s?(l=s??r.jsx(Mp,{}),e[5]=s,e[6]=l):l=e[6];let c;e[7]!==l?(c=r.jsx(N.Suspense,{fallback:a,children:l}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==o||e[10]!==c?(d=r.jsx(hs,{fallback:o,children:c}),e[9]=o,e[10]=c,e[11]=d):d=e[11],d}function bx(t){const e=F.c(3),{onNewTaskRef:s,createNewTask:n}=t;let i;return e[0]!==n||e[1]!==s?(i=()=>(s.current=n,()=>{s.current=null}),e[0]=n,e[1]=s,e[2]=i):i=e[2],N.useLayoutEffect(i),null}function jm(t){const e=F.c(33),{virtualMcpId:s,hasActiveGithubRepo:n,sandboxMap:i,children:o}=t,{currentBranch:a,activeTask:l}=ls(),{org:c}=ze(),{pendingSandboxProviderKind:d}=Bs(),{data:h}=ui.useSession(),u=h?.user?.id,{data:f}=uC(c.slug,s,a),m=l?.metadata?.sandboxMap,p=l?.created_by??u,g=p&&a?m?.[p]?.[a]:void 0,x=u&&a&&g?{...i??{},[u]:{...i?.[u]??{},[a]:g}}:i,v=u&&a&&f?.desiredState==="running"&&f.status==="ready"&&f.sandboxHandle?{...x??{},[u]:{...x?.[u]??{},[a]:{...Rd(x?.[u]?.[a]),"agent-sandbox":{sandboxHandle:f.sandboxHandle,previewUrl:f.previewUrl,sandboxApiUrl:f.sandboxApiUrl,sandboxProviderKind:"agent-sandbox",startedWith:f.startedWith??void 0}}}}:x;let b;e[0]!==l?.metadata||e[1]!==n?(b=n||$s(l?.metadata),e[0]=l?.metadata,e[1]=n,e[2]=b):b=e[2];const _=b,y=u??null,L=l?.created_by,w=l?.branch,j=l?.title;let S;e[3]!==y||e[4]!==L||e[5]!==w||e[6]!==j?(S=zw({userId:y,createdBy:L,branch:w,title:j}),e[3]=y,e[4]=L,e[5]=w,e[6]=j,e[7]=S):S=e[7];const k=S,C=dS(s,a??void 0),A=u&&a?Rd(v?.[u]?.[a]):{},V=(d?A[d]??null:m3(A))?.previewUrl??null;let T;e[8]!==f?.status||e[9]!==A||e[10]!==C?(T=Object.keys(A).length>0||C||f?.status==="provisioning"||f?.status==="reaping",e[8]=f?.status,e[9]=A,e[10]=C,e[11]=T):T=e[11];const R=T,E=a??null,I=a??null,D=u??null,M=f?.desiredState??null,O=f?.status==="provisioning"||f?.status==="reaping",$=l?.id??null,B=`${s}:${a??"no-branch"}`;let z;e[12]!==o||e[13]!==B?(z=r.jsx(ZP,{children:o},B),e[12]=o,e[13]=B,e[14]=z):z=e[14];let K;e[15]!==_||e[16]!==v||e[17]!==k||e[18]!==d||e[19]!==D||e[20]!==M||e[21]!==O||e[22]!==$||e[23]!==z||e[24]!==I||e[25]!==s?(K=r.jsx(Yw,{virtualMcpId:s,branch:I,userId:D,hasActiveGithubRepo:_,sandboxMap:v,sandboxProviderKind:d,sharedDesiredState:M,sharedLifecyclePending:O,othersThreadLabel:k,othersThreadId:$,children:z}),e[15]=_,e[16]=v,e[17]=k,e[18]=d,e[19]=D,e[20]=M,e[21]=O,e[22]=$,e[23]=z,e[24]=I,e[25]=s,e[26]=K):K=e[26];let Y;return e[27]!==V||e[28]!==R||e[29]!==K||e[30]!==E||e[31]!==s?(Y=r.jsx(Dw,{virtualMcpId:s,branch:E,previewUrl:V,enabled:R,children:K}),e[27]=V,e[28]=R,e[29]=K,e[30]=E,e[31]=s,e[32]=Y):Y=e[32],Y}function eH(t){const e=F.c(15),{entity:s,virtualMcpId:n,layout:i,onNewTaskRef:o}=t;let a;e[0]!==i.createNewTask||e[1]!==o?(a=r.jsx(bx,{onNewTaskRef:o,createNewTask:i.createNewTask}),e[0]=i.createNewTask,e[1]=o,e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(St.Skeleton,{}),e[3]=l):l=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(vx,{}),e[4]=c):c=e[4];let d;e[5]!==s||e[6]!==i.mainOpen||e[7]!==i.sidePanel||e[8]!==i.taskId||e[9]!==i.toggleSidePanel||e[10]!==n?(d=r.jsx(N.Suspense,{fallback:l,children:r.jsx(KU,{virtualMcpId:n,taskId:i.taskId,entity:s,sidePanel:i.sidePanel,mainOpen:i.mainOpen,toggleSidePanel:i.toggleSidePanel,chatContent:c})}),e[5]=s,e[6]=i.mainOpen,e[7]=i.sidePanel,e[8]=i.taskId,e[9]=i.toggleSidePanel,e[10]=n,e[11]=d):d=e[11];let h;return e[12]!==a||e[13]!==d?(h=r.jsxs(r.Fragment,{children:[a,d]}),e[12]=a,e[13]=d,e[14]=h):h=e[14],h}function tH(t){const e=F.c(16),{virtualMcpId:s,layout:n,onNewTaskRef:i}=t,o=oe(),a=n.mainOpen?"main":n.sidePanel??"chat";let l;e[0]!==n.taskId||e[1]!==s?(l=r.jsx(i8.Tabs,{children:r.jsx(GU,{virtualMcpId:s,taskId:n.taskId})}),e[0]=n.taskId,e[1]=s,e[2]=l):l=e[2];let c;e[3]!==n.createNewTask||e[4]!==i?(c=r.jsx(bx,{onNewTaskRef:i,createNewTask:n.createNewTask}),e[3]=n.createNewTask,e[4]=i,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(St.Skeleton,{}),e[6]=d):d=e[6];let h;e[7]!==n.taskId||e[8]!==a||e[9]!==o||e[10]!==s?(h=r.jsx(N.Suspense,{fallback:d,children:r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:a==="main"?r.jsx(hs,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:o("agentShellLayout.agentShellLayout.somethingWentWrong")}),children:r.jsx(N.Suspense,{fallback:r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(Ze,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx("div",{"data-testid":"main-panel",className:"h-full",children:r.jsx(fx,{taskId:n.taskId,virtualMcpId:s})})})}):r.jsx(xx,{chatContent:r.jsx(vx,{})})})}),e[7]=n.taskId,e[8]=a,e[9]=o,e[10]=s,e[11]=h):h=e[11];let u;return e[12]!==l||e[13]!==c||e[14]!==h?(u=r.jsxs(r.Fragment,{children:[l,c,h]}),e[12]=l,e[13]=c,e[14]=h,e[15]=u):u=e[15],u}function sH(){const t=F.c(97),e=oe(),s=Tr(),n=jt(),{org:i}=ze();Wb(i.slug);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=Yl(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=Vr(c);let h;t[2]!==i.id||t[3]!==d.virtualmcpid?(h=d.virtualmcpid??sa(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=h):h=t[4];const u=h,f=XU(a.taskId??"",u);gS(f.status==="ready"?f.task:null);const m=ms(u),p=m?.metadata?.ui?.layout??null;let g;t[5]!==p?(g=p?{defaultMainView:p.defaultMainView??null,chatDefaultOpen:p.chatDefaultOpen??null}:null,t[5]=p,t[6]=g):g=t[6];const x=g;let v;t[7]!==m?(v=m&&aa(m),t[7]=m,t[8]=v):v=t[8];const b=!!v;let _;t[9]!==l||t[10]!==u?(_={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=_):_=t[11];const y=pS(x,_),L=N.useRef(null);let w,j;t[12]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{const M=O=>{e2(O)&&O.shiftKey&&O.code==="KeyS"&&!O.repeat&&(O.preventDefault(),L.current?.())};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},j=[],t[12]=w,t[13]=j):(w=t[12],j=t[13]),N.useEffect(w,j);const S=u;let k;t[14]!==m||t[15]!==u?(k={virtualMcpId:u,entity:m},t[14]=m,t[15]=u,t[16]=k):k=t[16];const C=k;if(f.status==="creating"||f.status==="loading"){let M;t[17]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Ze,{className:"size-4 animate-spin mr-2"}),t[17]=M):M=t[17];let O;t[18]!==e?(O=e("agentShellLayout.agentShellLayout.creatingTask"),t[18]=e,t[19]=O):O=t[19];let $;t[20]!==O?($=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[M,O]})}),t[20]=O,t[21]=$):$=t[21];let B;return t[22]!==C||t[23]!==$?(B=r.jsx(lr,{value:C,children:$}),t[22]=C,t[23]=$,t[24]=B):B=t[24],B}if(f.status==="error"){let M;t[25]!==e?(M=e("agentShellLayout.agentShellLayout.taskUnavailable"),t[25]=e,t[26]=M):M=t[26];let O;t[27]!==M?(O=r.jsx("div",{className:"font-medium",children:M}),t[27]=M,t[28]=O):O=t[28];let $;t[29]!==f.error.message?($=r.jsx("div",{className:"text-muted-foreground",children:f.error.message}),t[29]=f.error.message,t[30]=$):$=t[30];let B;t[31]!==O||t[32]!==$?(B=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[O,$]})}),t[31]=O,t[32]=$,t[33]=B):B=t[33];let z;return t[34]!==C||t[35]!==B?(z=r.jsx(lr,{value:C,children:B}),t[34]=C,t[35]=B,t[36]=z):z=t[36],z}if(!m){let M;t[37]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(jn,{size:48,className:"text-muted-foreground"}),t[37]=M):M=t[37];let O;t[38]!==e?(O=e("agentShellLayout.agentShellLayout.agentNotFound"),t[38]=e,t[39]=O):O=t[39];let $;t[40]!==e||t[41]!==u?($=e("agentShellLayout.agentShellLayout.agentNotFoundDescription",{virtualMcpId:u}),t[40]=e,t[41]=u,t[42]=$):$=t[42];let B;t[43]!==n||t[44]!==l?(B=()=>n({to:"/$org",params:{org:l}}),t[43]=n,t[44]=l,t[45]=B):B=t[45];let z;t[46]!==e?(z=e("agentShellLayout.agentShellLayout.goToOrgHome"),t[46]=e,t[47]=z):z=t[47];let K;t[48]!==B||t[49]!==z?(K=r.jsx(le,{variant:"outline",onClick:B,children:z}),t[48]=B,t[49]=z,t[50]=K):K=t[50];let Y;t[51]!==O||t[52]!==$||t[53]!==K?(Y=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:r.jsx(Ei,{image:M,title:O,description:$,actions:K})})}),t[51]=O,t[52]=$,t[53]=K,t[54]=Y):Y=t[54];let Q;return t[55]!==C||t[56]!==Y?(Q=r.jsx(lr,{value:C,children:Y}),t[55]=C,t[56]=Y,t[57]=Q):Q=t[57],Q}if(s){const M=f.status==="ready"?f.task:null,O=m?.metadata?.sandboxMap;let $;t[58]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(St.Skeleton,{}),t[58]=$):$=t[58];let B;t[59]!==S||t[60]!==y?(B=r.jsx(N.Suspense,{fallback:$,children:r.jsx(tH,{virtualMcpId:S,layout:y,onNewTaskRef:L})}),t[59]=S,t[60]=y,t[61]=B):B=t[61];let z;t[62]!==y.taskId||t[63]!==B?(z=r.jsx(St.ActiveTaskProvider,{taskId:y.taskId,children:B},y.taskId),t[62]=y.taskId,t[63]=B,t[64]=z):z=t[64];let K;t[65]!==b||t[66]!==O||t[67]!==z||t[68]!==u?(K=r.jsx(jm,{virtualMcpId:u,hasActiveGithubRepo:b,sandboxMap:O,children:z}),t[65]=b,t[66]=O,t[67]=z,t[68]=u,t[69]=K):K=t[69];let Y;t[70]!==S||t[71]!==K||t[72]!==M?(Y=r.jsx("div",{className:"flex flex-col flex-1 min-w-0 bg-background min-h-0",children:r.jsx(St.Provider,{virtualMcpId:S,task:M,children:K},S)}),t[70]=S,t[71]=K,t[72]=M,t[73]=Y):Y=t[73];let Q;return t[74]!==C||t[75]!==Y?(Q=r.jsx(lr,{value:C,children:Y}),t[74]=C,t[75]=Y,t[76]=Q):Q=t[76],Q}const A=f.status==="ready"?f.task:null,P=m?.metadata?.sandboxMap;let V;t[77]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(St.Skeleton,{}),t[77]=V):V=t[77];let T;t[78]!==m||t[79]!==y||t[80]!==u?(T=r.jsx(N.Suspense,{fallback:V,children:r.jsx(eH,{entity:m,virtualMcpId:u,layout:y,onNewTaskRef:L})}),t[78]=m,t[79]=y,t[80]=u,t[81]=T):T=t[81];let R;t[82]!==y.taskId||t[83]!==T?(R=r.jsx(St.ActiveTaskProvider,{taskId:y.taskId,children:T},y.taskId),t[82]=y.taskId,t[83]=T,t[84]=R):R=t[84];let E;t[85]!==b||t[86]!==P||t[87]!==R||t[88]!==u?(E=r.jsx(jm,{virtualMcpId:u,hasActiveGithubRepo:b,sandboxMap:P,children:R}),t[85]=b,t[86]=P,t[87]=R,t[88]=u,t[89]=E):E=t[89];let I;t[90]!==S||t[91]!==E||t[92]!==A?(I=r.jsx(St.Provider,{virtualMcpId:S,task:A,children:E},S),t[90]=S,t[91]=E,t[92]=A,t[93]=I):I=t[93];let D;return t[94]!==C||t[95]!==I?(D=r.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:r.jsx(lr,{value:C,children:I})}),t[94]=C,t[95]=I,t[96]=D):D=t[96],D}function nH(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Xx,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(N.Suspense,{fallback:e,children:r.jsxs(d8,{children:[r.jsx(sH,{}),r.jsx(QU,{})]})}),t[1]=s):s=t[1],s}const oG=Object.freeze(Object.defineProperty({__proto__:null,default:nH,useInsetContext:Kn},Symbol.toStringTag,{value:"Module"}));export{O4 as $,Wf as A,Gq as B,Jo as C,$a as D,E_ as E,L4 as F,B9 as G,bc as H,mM as I,li as J,zr as K,fu as L,wr as M,uu as N,gg as O,Kr as P,Sc as Q,yD as R,Bn as S,xs as T,su as U,hu as V,Sn as W,nD as X,rD as Y,Jq as Z,du as _,Lq as a,Wq as a$,Yq as a0,rj as a1,ij as a2,Aq as a3,Au as a4,WD as a5,ou as a6,F4 as a7,Fq as a8,tG as a9,dD as aA,Wr as aB,Dq as aC,zq as aD,DE as aE,Uq as aF,$q as aG,kE as aH,Pq as aI,Bq as aJ,Oq as aK,Mq as aL,Zq as aM,Tq as aN,Eq as aO,Nq as aP,eG as aQ,Eu as aR,e4 as aS,Zg as aT,wq as aU,uE as aV,Cq as aW,kq as aX,fE as aY,qq as aZ,Iq as a_,sG as aa,Iu as ab,Sq as ac,Kq as ad,zl as ae,ZM as af,uc as ag,hc as ah,Kn as ai,yR as aj,G9 as ak,ww as al,pc as am,o4 as an,$l as ao,LI as ap,jq as aq,XM as ar,nG as as,l4 as at,Rq as au,KM as av,cE as aw,dE as ax,Pu as ay,J4 as az,Wd as b,Xp as b0,Hq as b1,Xq as b2,_q as b3,xw as b4,bw as b5,oG as b6,qd as c,_n as d,i4 as e,Za as f,Qo as g,bR as h,fs as i,Tl as j,kc as k,Qq as l,R4 as m,PR as n,yO as o,bq as p,yq as q,Ln as r,gx as s,Vq as t,Yi as u,xR as v,lD as w,el as x,YR as y,Ma as z};