decocms 4.502.2 → 4.502.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 (376) hide show
  1. package/dist/client/assets/{ActiveShapeUtils-BmpX0aJ4.js → ActiveShapeUtils-BBqxbo_b.js} +1 -1
  2. package/dist/client/assets/{AlertCircle-BugQG9bV.js → AlertCircle-B1K4xFWw.js} +1 -1
  3. package/dist/client/assets/{AreaChart-C2JGxQiA.js → AreaChart-Djb2aLuM.js} +1 -1
  4. package/dist/client/assets/{ArrowLeft-BsOtfvqw.js → ArrowLeft-Cndk_wxI.js} +1 -1
  5. package/dist/client/assets/{ArrowUp-BM60-fZY.js → ArrowUp-RNWLmEvk.js} +1 -1
  6. package/dist/client/assets/{BarChart-B7UShXEl.js → BarChart-BLceipFp.js} +1 -1
  7. package/dist/client/assets/{Building02-DqK4SREZ.js → Building02-uWsB2mfH.js} +1 -1
  8. package/dist/client/assets/{CategoricalChart-B4irlNQB.js → CategoricalChart-N6OOlxlC.js} +1 -1
  9. package/dist/client/assets/{CheckCircle-DIUFnJQp.js → CheckCircle-DHs2hGe9.js} +1 -1
  10. package/dist/client/assets/{ChevronSelectorVertical-CRMiEVEY.js → ChevronSelectorVertical-DviKGPlb.js} +1 -1
  11. package/dist/client/assets/{ChevronUp-C9gm2RHA.js → ChevronUp-DRQp-Xgt.js} +1 -1
  12. package/dist/client/assets/{Copy01-BrqDGrTX.js → Copy01-v7NhM9oA.js} +1 -1
  13. package/dist/client/assets/{CreditCard01-C7MhbtAI.js → CreditCard01-Dtw0unEW.js} +1 -1
  14. package/dist/client/assets/{DotsVertical-DjBJNxxU.js → DotsVertical-Drkb0dMp.js} +1 -1
  15. package/dist/client/assets/{ErrorBarContext-Duc4DanJ.js → ErrorBarContext-BrN3wymZ.js} +1 -1
  16. package/dist/client/assets/{Globe04-Bi1qDXFD.js → Globe04-Dn8iGQE6.js} +1 -1
  17. package/dist/client/assets/{Image01-LmX-9DTg.js → Image01-qnXYF9Lx.js} +1 -1
  18. package/dist/client/assets/{Key01-D7fc2of0.js → Key01-BylVHZZg.js} +1 -1
  19. package/dist/client/assets/{Link01-UOxGnkqg.js → Link01-CH8d8vV_.js} +1 -1
  20. package/dist/client/assets/{LinkBroken01-D4fcNp0y.js → LinkBroken01-BRTnEcyu.js} +1 -1
  21. package/dist/client/assets/{Monitor01-zCUpqs5C.js → Monitor01-7E6lWSm8.js} +1 -1
  22. package/dist/client/assets/{Play-BaMMHzUS.js → Play-NXc3jRj5.js} +1 -1
  23. package/dist/client/assets/{Plus-DBwsZRbL.js → Plus-CpsuuelG.js} +1 -1
  24. package/dist/client/assets/{SearchMd-Cz9CjV4u.js → SearchMd-DJhWmDye.js} +1 -1
  25. package/dist/client/assets/{Sector-DRzP1YgK.js → Sector-Blss1CPV.js} +1 -1
  26. package/dist/client/assets/{ShoppingBag01-FE4oAEwY.js → ShoppingBag01-C5te0Nzh.js} +1 -1
  27. package/dist/client/assets/{Sun-lUDK8Dny.js → Sun-DKM-uJFR.js} +1 -1
  28. package/dist/client/assets/{SwitchHorizontal01-BLoNOmQx.js → SwitchHorizontal01-lG9ssyHa.js} +1 -1
  29. package/dist/client/assets/{Tool01-BYtrXXg0.js → Tool01-DgnrifZ2.js} +1 -1
  30. package/dist/client/assets/{Trash01-DmGIq4LE.js → Trash01-nUIoghkK.js} +1 -1
  31. package/dist/client/assets/{Upload01-B1KubIEG.js → Upload01-UvdGjs0c.js} +1 -1
  32. package/dist/client/assets/{User01-DxYW6D1x.js → User01-CNvDoTpL.js} +1 -1
  33. package/dist/client/assets/{UserSquare-B3hi5v4G.js → UserSquare-D-nNMLFe.js} +1 -1
  34. package/dist/client/assets/{Users01-Dg9yGM1q.js → Users01-CM2CFJbp.js} +1 -1
  35. package/dist/client/assets/{XAxis-BriqOO10.js → XAxis-C3n2xuvM.js} +1 -1
  36. package/dist/client/assets/{XClose-D_NlSxSm.js → XClose-CYU9Adi9.js} +1 -1
  37. package/dist/client/assets/{ZoomOut-BpMDqvoU.js → ZoomOut-BNxfvkQ2.js} +1 -1
  38. package/dist/client/assets/{access-gate-DawpkWaC.js → access-gate-DChf4TlT.js} +1 -1
  39. package/dist/client/assets/{add-connection-dialog-lyugU_mj.js → add-connection-dialog-CMCPQ8st.js} +1 -1
  40. package/dist/client/assets/{agent-analytics-DEQNBU8x.js → agent-analytics-CMphiXHg.js} +1 -1
  41. package/dist/client/assets/agent-app-DDq-NWeD.js +1 -0
  42. package/dist/client/assets/{agent-assets-DpD_FYPJ.js → agent-assets-CS_FbjpB.js} +1 -1
  43. package/dist/client/assets/{agent-automation-y8Q_blPP.js → agent-automation-CvUyyLm0.js} +1 -1
  44. package/dist/client/assets/{agent-automations-G_wOHGxQ.js → agent-automations-BQjyuCJc.js} +1 -1
  45. package/dist/client/assets/{agent-connect-sources-0w-hFhuF.js → agent-connect-sources-BYtJeT9W.js} +1 -1
  46. package/dist/client/assets/agent-deck-CKdyQI6O.js +1 -0
  47. package/dist/client/assets/{agent-e2e-DDS2OBYo.js → agent-e2e-zMnqeTHZ.js} +1 -1
  48. package/dist/client/assets/{agent-experiments-CDaNVjiN.js → agent-experiments-CgXCadUT.js} +1 -1
  49. package/dist/client/assets/{agent-file-CZwBMDPX.js → agent-file-Bz_q7KHJ.js} +1 -1
  50. package/dist/client/assets/{agent-hosting-CDM9c3HL.js → agent-hosting-1wdlDlYm.js} +1 -1
  51. package/dist/client/assets/{agent-icon-Cwi3uRdu.js → agent-icon-DYK_xLct.js} +1 -1
  52. package/dist/client/assets/agent-library-DBIXRUpp.js +1 -0
  53. package/dist/client/assets/agent-library-file-BbK0vYjR.js +1 -0
  54. package/dist/client/assets/{agent-monitor-DgbGzFfm.js → agent-monitor-DeK1RlJZ.js} +1 -1
  55. package/dist/client/assets/{agent-overview-D7sXtedV.js → agent-overview-Cw2DaV93.js} +1 -1
  56. package/dist/client/assets/{agent-releases-DBGhKiDv.js → agent-releases-C8sSyB4B.js} +1 -1
  57. package/dist/client/assets/agent-settings-Dg4Dn9Vg.js +1 -0
  58. package/dist/client/assets/{agent-site-editor-CPneBPX9.js → agent-site-editor-Dg_Jee-d.js} +3 -3
  59. package/dist/client/assets/agent-site-editor-code-BXGDjGRt.js +2 -0
  60. package/dist/client/assets/agent-site-editor-content-D1xjYGGU.js +1 -0
  61. package/dist/client/assets/agent-site-editor-preview-B-Mk9XF6.js +1 -0
  62. package/dist/client/assets/agent-view-D34y5B01.js +1 -0
  63. package/dist/client/assets/{agent-view-guard-B7DCW97m.js → agent-view-guard-DR-CGb94.js} +1 -1
  64. package/dist/client/assets/{agents-list-WKtrnsCY.js → agents-list-DSuLCqX-.js} +1 -1
  65. package/dist/client/assets/{ai-providers-gwsES712.js → ai-providers-D0sk0Nd0.js} +1 -1
  66. package/dist/client/assets/{alert-DD0xrZ6s.js → alert-Be-y-N9r.js} +1 -1
  67. package/dist/client/assets/{alert-dialog-Cww2cCKj.js → alert-dialog-BmunadUc.js} +1 -1
  68. package/dist/client/assets/{analytics-sections-fsDdSYtz.js → analytics-sections-CyAYPDUg.js} +1 -1
  69. package/dist/client/assets/{api-keys-C4RupExd.js → api-keys-Bi8Gwgeq.js} +1 -1
  70. package/dist/client/assets/api-keys-DiZ0hqZ9.js +1 -0
  71. package/dist/client/assets/{app-editor-BunD9Cep.js → app-editor-CPwO43bG.js} +1 -1
  72. package/dist/client/assets/{asset-utils-B7vSk_IG.js → asset-utils-DDAhoO4p.js} +1 -1
  73. package/dist/client/assets/{auth-d1Zn25hw.js → auth-BvBcXr-J.js} +1 -1
  74. package/dist/client/assets/{auth-catchall-DXOnI1Dn.js → auth-catchall-BIZRsJj-.js} +1 -1
  75. package/dist/client/assets/{auth-entry-QKE13w72.js → auth-entry-PpaoZs5u.js} +1 -1
  76. package/dist/client/assets/{auth-split-layout-BOn9jzuY.js → auth-split-layout-D_CovWnG.js} +1 -1
  77. package/dist/client/assets/{authenticate-and-persist-oauth-p8iXxMbw.js → authenticate-and-persist-oauth-DolvVBs8.js} +1 -1
  78. package/dist/client/assets/{automation-list-row-aeiODfl-.js → automation-list-row-lJOFTOFS.js} +1 -1
  79. package/dist/client/assets/{automation-runs-gnGbUEYl.js → automation-runs-kwyLuzzx.js} +1 -1
  80. package/dist/client/assets/{automations-D6uaxrsR.js → automations-BX6dnu8k.js} +1 -1
  81. package/dist/client/assets/{autosend-DkgNxXhw.js → autosend-CG2VxFoj.js} +1 -1
  82. package/dist/client/assets/{avatar-Bp-EkB-V.js → avatar-DXy0LAdF.js} +1 -1
  83. package/dist/client/assets/{badge-BIePf0xK.js → badge-4cemB70d.js} +1 -1
  84. package/dist/client/assets/{block-document-D9afNZe_.js → block-document-C0CmmVhS.js} +1 -1
  85. package/dist/client/assets/{blocks-preview-workspace-context-CVDMxLIY.js → blocks-preview-workspace-context-C48UHCra.js} +1 -1
  86. package/dist/client/assets/{blocks-tab-states-Dgf9O_BB.js → blocks-tab-states-wdRtP3l6.js} +3 -3
  87. package/dist/client/assets/{blog-schema-D_8LQntk.js → blog-schema-CWTrWzZc.js} +1 -1
  88. package/dist/client/assets/{board-analytics-QsikkAwD.js → board-analytics-M14DUUuU.js} +1 -1
  89. package/dist/client/assets/{buckets-CELYezv2.js → buckets-DZliR7ww.js} +1 -1
  90. package/dist/client/assets/{build-improve-prompt-doc-d10qBCA_.js → build-improve-prompt-doc-BBWpQlBd.js} +1 -1
  91. package/dist/client/assets/{calendar-BnpyhDmY.js → calendar-BL4SuwJf.js} +1 -1
  92. package/dist/client/assets/{capability-load-error-D8PnCnVx.js → capability-load-error-CYm7LG_1.js} +1 -1
  93. package/dist/client/assets/{category-editor-BosHSdme.js → category-editor-C-m0Dvhp.js} +1 -1
  94. package/dist/client/assets/{chart-Bv9NYntf.js → chart-WTrazddz.js} +1 -1
  95. package/dist/client/assets/{chat-context-CKK4nwlA.js → chat-context-BnOeJwbx.js} +1 -1
  96. package/dist/client/assets/{chat-draft-BMAMpVi3.js → chat-draft-BOY5Y2Ci.js} +1 -1
  97. package/dist/client/assets/{checkbox-Dwjm_TLd.js → checkbox-Bl1Mjt0r.js} +1 -1
  98. package/dist/client/assets/{choose-editor-CZoejY4P.js → choose-editor-PLaofTga.js} +1 -1
  99. package/dist/client/assets/{cli-auth-success-B_GTleKO.js → cli-auth-success-BgTTrcCf.js} +1 -1
  100. package/dist/client/assets/{client-icons-rqhSDiCg.js → client-icons-Do5j8ecM.js} +1 -1
  101. package/dist/client/assets/cms-settings-editor-CCG7L232.js +1 -0
  102. package/dist/client/assets/{collapsible-BEHE2idT.js → collapsible-odbldk6G.js} +1 -1
  103. package/dist/client/assets/{collection-detail-CEB1twCS.js → collection-detail-TYkmj7Zf.js} +1 -1
  104. package/dist/client/assets/{collection-display-button-CZETvC3F.js → collection-display-button-BQ3G_kyE.js} +1 -1
  105. package/dist/client/assets/{collection-search-mDMHjO22.js → collection-search-BDkQDOp5.js} +1 -1
  106. package/dist/client/assets/{collection-table-wrapper-BTz_B-8u.js → collection-table-wrapper-XeuMSkE7.js} +1 -1
  107. package/dist/client/assets/{collection-tabs-C8f6Only.js → collection-tabs-LE_ipkrD.js} +1 -1
  108. package/dist/client/assets/{column-rules-CHHzpXer.js → column-rules-Ds0a7yZM.js} +1 -1
  109. package/dist/client/assets/{combobox-DsvKNdY8.js → combobox-BTpIYCoT.js} +1 -1
  110. package/dist/client/assets/{command-D2C8egnH.js → command-CzrMHXxb.js} +1 -1
  111. package/dist/client/assets/{companion-mcps-section-980W-E9y.js → companion-mcps-section-BLH6tyoC.js} +1 -1
  112. package/dist/client/assets/{config-Df4GVvvj.js → config-DBGOkyDW.js} +1 -1
  113. package/dist/client/assets/{connect-BCz-doDt.js → connect-hiRmX08y.js} +1 -1
  114. package/dist/client/assets/{connect-layout-dj6lGUOP.js → connect-layout-BAu7pqjE.js} +1 -1
  115. package/dist/client/assets/{connection-CXmYeQRu.js → connection-C1Ch9D0_.js} +1 -1
  116. package/dist/client/assets/{connection-card-BnbrpDH3.js → connection-card-DbSwpeYP.js} +1 -1
  117. package/dist/client/assets/{connection-detail-DgPXb5ec.js → connection-detail-BuQ2_k9w.js} +1 -1
  118. package/dist/client/assets/{connection-form-helpers-a4JD1Ns8.js → connection-form-helpers-Q8DdmcgV.js} +1 -1
  119. package/dist/client/assets/{connections-Cywtpg_p.js → connections-BrBLD9-l.js} +1 -1
  120. package/dist/client/assets/{content-tab-DJpFcjvc.js → content-tab-vJi3Magb.js} +3 -3
  121. package/dist/client/assets/{context-D3qk5qiN.js → context-CKB_U2ky.js} +1 -1
  122. package/dist/client/assets/{context-menu-BAv_ihvH.js → context-menu-CEYq5O6i.js} +1 -1
  123. package/dist/client/assets/{core.esm-D0fLNP6n.js → core.esm-UUsVrNGL.js} +1 -1
  124. package/dist/client/assets/{create-organization-dialog-Dz2w339w.js → create-organization-dialog-Bba6tj_u.js} +1 -1
  125. package/dist/client/assets/{daily-pulse-BvFEfYSA.js → daily-pulse-Bh3N_ghm.js} +1 -1
  126. package/dist/client/assets/{discover-LQfpS4xG.js → discover-CPo4VM-G.js} +1 -1
  127. package/dist/client/assets/{domain-settings-B0WV9_Uz.js → domain-settings-DgvSu-YV.js} +1 -1
  128. package/dist/client/assets/{drawer-C7TJoqXz.js → drawer-DbH0dp7b.js} +1 -1
  129. package/dist/client/assets/{editor-r9_MTJH5.js → editor-CGejMM_z.js} +1 -1
  130. package/dist/client/assets/{editor-classes-B9HFPeRc.js → editor-classes-Bdutb5n3.js} +1 -1
  131. package/dist/client/assets/{empty-state-ChkfcEnf.js → empty-state-BPzmSif1.js} +1 -1
  132. package/dist/client/assets/{empty-state-DXyqmsSi.js → empty-state-CYf2HroE.js} +1 -1
  133. package/dist/client/assets/{extract-connection-data-B2gWRdBp.js → extract-connection-data-Djn2ZuE9.js} +1 -1
  134. package/dist/client/assets/{feature-gate-B6qb42zy.js → feature-gate-CVptuhNf.js} +1 -1
  135. package/dist/client/assets/{feature-paywall-DXx7v-jJ.js → feature-paywall-Yxq9HHQa.js} +1 -1
  136. package/dist/client/assets/{file-explorer-B67HF6Wo.js → file-explorer-CyOrMkRD.js} +1 -1
  137. package/dist/client/assets/{file-preview-Baou4Z0N.js → file-preview-B0DGgNJq.js} +1 -1
  138. package/dist/client/assets/{file-share-button-DtVBXYxU.js → file-share-button-C4SdgU84.js} +1 -1
  139. package/dist/client/assets/{file-type-icon-C2mdy7vI.js → file-type-icon-B2QIIVAh.js} +1 -1
  140. package/dist/client/assets/flat-project-Br5UwvU6.js +1 -0
  141. package/dist/client/assets/{folder-icon-Bqx-rRTJ.js → folder-icon-bV2CKNXW.js} +1 -1
  142. package/dist/client/assets/{form-DDdiF5DN.js → form-DmRVhMTU.js} +1 -1
  143. package/dist/client/assets/{general-JuFqcNqn.js → general-DTTK08TF.js} +1 -1
  144. package/dist/client/assets/{home-UcHgTtiG.js → home--Lrk1V2V.js} +1 -1
  145. package/dist/client/assets/{hosted-publish-feedback-5DTVDnQ-.js → hosted-publish-feedback-Dmtx9jpJ.js} +1 -1
  146. package/dist/client/assets/{icon-button-DfjCa6Mk.js → icon-button-9xlK2XKp.js} +1 -1
  147. package/dist/client/assets/{index-BlWeDA0T.js → index-6Ng0tT_w.js} +3 -3
  148. package/dist/client/assets/{index-CYLF_RCH.js → index-B5_VofEJ.js} +1 -1
  149. package/dist/client/assets/{index-LPxqYo8X.js → index-Bh7SvVdg.js} +1 -1
  150. package/dist/client/assets/{index-CCq4aC_-.js → index-BpPUyVmm.js} +3 -3
  151. package/dist/client/assets/{index-sLNiMwXT.js → index-C-YzI0Se.js} +1 -1
  152. package/dist/client/assets/{index-BuXV8w2T.js → index-Cha-G5F1.js} +1 -1
  153. package/dist/client/assets/{index-Cb4Qh-54.js → index-CmAR63BL.js} +1 -1
  154. package/dist/client/assets/{index-BOey0PQ3.js → index-Cw88wj2L.js} +1 -1
  155. package/dist/client/assets/{index-DrHP_BcE.js → index-Cx3zRpVQ.js} +1 -1
  156. package/dist/client/assets/{index-D1I5UKBv.js → index-FZ9hfkIs.js} +1 -1
  157. package/dist/client/assets/{index-D5I6z1z8.js → index-FjW_PrQL.js} +1 -1
  158. package/dist/client/assets/{index-2M41MwRq.js → index-ghZnGaFW.js} +1 -1
  159. package/dist/client/assets/{index-BVXKUS4M.js → index-hkiYH0EW.js} +1 -1
  160. package/dist/client/assets/{index-redirect-BL8ikpY8.js → index-redirect-CKnh56nM.js} +1 -1
  161. package/dist/client/assets/{index-BHzdhQYD.js → index-xa9ZKf5B.js} +1 -1
  162. package/dist/client/assets/{index-DCg7x8H-.js → index-yDqIeCeK.js} +1 -1
  163. package/dist/client/assets/{infiniteQueryObserver-C9osZa8h.js → infiniteQueryObserver-eO9zOabS.js} +1 -1
  164. package/dist/client/assets/{infra-billing-Cs3idU5N.js → infra-billing-CQJrvgJ7.js} +1 -1
  165. package/dist/client/assets/{input-BSKhVE-B.js → input-Cn9XurDr.js} +1 -1
  166. package/dist/client/assets/{input-3uLsKqBB.js → input-DvkV2rhp.js} +3 -3
  167. package/dist/client/assets/{integration-icon-BRfynNZ5.js → integration-icon-DkW9ztwd.js} +1 -1
  168. package/dist/client/assets/{jira-icon-KByV_Mf3.js → jira-icon-LNNLPe3p.js} +1 -1
  169. package/dist/client/assets/{label-CCf767lm.js → label-BjcPiOzG.js} +1 -1
  170. package/dist/client/assets/{layout-COMw43Ge.js → layout-Dbw4HkUI.js} +1 -1
  171. package/dist/client/assets/{legacy-agents-deep-bTO0GYdo.js → legacy-agents-deep-DKOhoxSs.js} +1 -1
  172. package/dist/client/assets/{legacy-main-redirect-TCc947lk.js → legacy-main-redirect-S_bVP2tl.js} +1 -1
  173. package/dist/client/assets/library-B13cvtAr.js +1 -0
  174. package/dist/client/assets/{library-tab-BGwlABCU.js → library-tab-B5LhknJX.js} +1 -1
  175. package/dist/client/assets/{login-Cs3tkGZ_.js → login-DhEfACJc.js} +1 -1
  176. package/dist/client/assets/{markdown-BRIlR7nZ.js → markdown-DpIn9foG.js} +1 -1
  177. package/dist/client/assets/{mcp-app-renderer-BdWVQtZT.js → mcp-app-renderer-COiGcRXa.js} +1 -1
  178. package/dist/client/assets/{mcp-oauth-Wpa3RhmZ.js → mcp-oauth-JuThqha-.js} +1 -1
  179. package/dist/client/assets/{mcp-oauth-CbRV1ySf.js → mcp-oauth-j-V6G83N.js} +1 -1
  180. package/dist/client/assets/{members-D2nKnBqd.js → members-BHJlSwkD.js} +1 -1
  181. package/dist/client/assets/{memory-BOidyMfA.js → memory-au_4A5ge.js} +1 -1
  182. package/dist/client/assets/{mini-report-page-Dvm9KZA4.js → mini-report-page-C599N38K.js} +1 -1
  183. package/dist/client/assets/{mock-board-D7x3oR1J.js → mock-board-DzU17Sx2.js} +1 -1
  184. package/dist/client/assets/{monaco-editor-CGec7a_K.js → monaco-editor-CKTrX50D.js} +1 -1
  185. package/dist/client/assets/{monitoring-stats-row-BBfe42aa.js → monitoring-stats-row-BsHJBRWM.js} +1 -1
  186. package/dist/client/assets/{multi-select-CWeD2kOU.js → multi-select-BAKgEjCD.js} +1 -1
  187. package/dist/client/assets/{mustache-CwHM8aj-.js → mustache-DyoG5f91.js} +1 -1
  188. package/dist/client/assets/{new-project-dialog-D9WaXvgl.js → new-project-dialog-WJlnuE7i.js} +1 -1
  189. package/dist/client/assets/{oauth-callback-BdiwSco0.js → oauth-callback-CmCjE2Th.js} +1 -1
  190. package/dist/client/assets/{oauth-callback-ai-provider-CgO92uMO.js → oauth-callback-ai-provider-CakC-L1m.js} +1 -1
  191. package/dist/client/assets/{onboarding-C0FoRXam.js → onboarding-E3DT6bLo.js} +1 -1
  192. package/dist/client/assets/{openai-conversation-DScTerkb.js → openai-conversation-Dez5IUQ-.js} +1 -1
  193. package/dist/client/assets/{optimistic-project-sidebar-views--iSxVboR.js → optimistic-project-sidebar-views-CcuuVuxi.js} +1 -1
  194. package/dist/client/assets/{organization-choice-BfKg9bh6.js → organization-choice-CtdIQd6N.js} +1 -1
  195. package/dist/client/assets/{orgs-DuBdGAZM.js → orgs-CJdo_0Oq.js} +1 -1
  196. package/dist/client/assets/{page-seo-form-DobjM56n.js → page-seo-form-hwhWimPN.js} +1 -1
  197. package/dist/client/assets/{pair-Boroas12.js → pair-DJltcVoF.js} +1 -1
  198. package/dist/client/assets/{plan-ladder-DRlbA6Oe.js → plan-ladder-sdrPy_gR.js} +1 -1
  199. package/dist/client/assets/{popover-C86-20Mm.js → popover-7WD7U7Ag.js} +1 -1
  200. package/dist/client/assets/{post-calendar-BCVyphrd.js → post-calendar-A1jQFpNI.js} +1 -1
  201. package/dist/client/assets/{post-editor-BcCUjE05.js → post-editor-CMrfvs9p.js} +1 -1
  202. package/dist/client/assets/{preview-content-Dk4Scdb5.js → preview-content-GmoHPzQv.js} +1 -1
  203. package/dist/client/assets/{preview-dialog-BP2Zt8Py.js → preview-dialog-CkD7RTOD.js} +1 -1
  204. package/dist/client/assets/{preview-panel-BGjEJtqj.js → preview-panel-UYyMDqP6.js} +1 -1
  205. package/dist/client/assets/{preview-tab-DJ2raYQ6.js → preview-tab-zM_tT7Rs.js} +3 -3
  206. package/dist/client/assets/{product-picker-dialog-g66EoJ_T.js → product-picker-dialog-DlRkc65y.js} +1 -1
  207. package/dist/client/assets/{profile-BT5VjyCv.js → profile-CXPboSwt.js} +1 -1
  208. package/dist/client/assets/{project-app-view-DmFCm9cm.js → project-app-view-2j1x0EsF.js} +1 -1
  209. package/dist/client/assets/{project-feed-B4yf-56T.js → project-feed-DPdmLS8w.js} +1 -1
  210. package/dist/client/assets/{project-icon-CJp8KUWK.js → project-icon-Dk5277oF.js} +1 -1
  211. package/dist/client/assets/project-reports-CEHFTuga.js +1 -0
  212. package/dist/client/assets/project-tasks-JRH_69f7.js +1 -0
  213. package/dist/client/assets/{projects-7LPBT4kF.js → projects-Cu9Ygw-a.js} +1 -1
  214. package/dist/client/assets/{projects-empty-state-Bwas41PR.js → projects-empty-state-CGqEEr8b.js} +1 -1
  215. package/dist/client/assets/{prompts-BVvVWZvL.js → prompts-BcjqSshs.js} +1 -1
  216. package/dist/client/assets/record-editor-C3nhyK7Q.js +1 -0
  217. package/dist/client/assets/{redirect-editor-CBUBt5If.js → redirect-editor-Cppl6A47.js} +1 -1
  218. package/dist/client/assets/reports-BEXeC5o1.js +1 -0
  219. package/dist/client/assets/{reports-BEw3YAN9.js → reports-JjEeZ9TG.js} +1 -1
  220. package/dist/client/assets/{reports-onboarding-C2RC2ok9.js → reports-onboarding-BGo_w7A-.js} +1 -1
  221. package/dist/client/assets/{reports-tab-cAMVw7Rk.js → reports-tab-DVjWlhLA.js} +2 -2
  222. package/dist/client/assets/{repositories-C9isGzNA.js → repositories-wI_lXfOY.js} +1 -1
  223. package/dist/client/assets/{repository-binding-Ds0zXEVH.js → repository-binding-BaMWuPiD.js} +1 -1
  224. package/dist/client/assets/{repository-import-picker-CJrt2Qyf.js → repository-import-picker-B4IvUqwn.js} +1 -1
  225. package/dist/client/assets/{repository-picker-DoUZKYGY.js → repository-picker-CZRoSABc.js} +1 -1
  226. package/dist/client/assets/{require-capability-Canamm7b.js → require-capability-CZBkoHDW.js} +1 -1
  227. package/dist/client/assets/{required-auth-layout-CoQlG-uh.js → required-auth-layout-BFsMU6XE.js} +1 -1
  228. package/dist/client/assets/{reset-password-BIKAyV8Z.js → reset-password-hmrTPpuc.js} +1 -1
  229. package/dist/client/assets/{resizable-Bu_8_8YG.js → resizable-NiAykzba.js} +1 -1
  230. package/dist/client/assets/{resolve-tab-icon-BYZBv0qd.js → resolve-tab-icon-DXmjb3WD.js} +1 -1
  231. package/dist/client/assets/{review-settings-dkP8FuZW.js → review-settings-F7gy4bLN.js} +1 -1
  232. package/dist/client/assets/{roles-B5cvsmrd.js → roles-w_a8ZD0U.js} +1 -1
  233. package/dist/client/assets/route-B9hWyQaJ.js +1 -0
  234. package/dist/client/assets/{route-BhzRlDpl.js → route-CNadV1lR.js} +1 -1
  235. package/dist/client/assets/{route-1w9x4x4x.js → route-rGCoRj1-.js} +1 -1
  236. package/dist/client/assets/{sandbox-lifecycle-context-DHjDdwbp.js → sandbox-lifecycle-context-DA-DHHDl.js} +1 -1
  237. package/dist/client/assets/{schema-D-34ICTJ.js → schema-BJXub_FG.js} +1 -1
  238. package/dist/client/assets/{schema-DO5D2eCO.js → schema-CB-lS3_k.js} +1 -1
  239. package/dist/client/assets/{scroll-area-BjUjV0Z5.js → scroll-area-CzsalLJW.js} +1 -1
  240. package/dist/client/assets/{search-input-BaljBVL8.js → search-input-SR5HfbbM.js} +1 -1
  241. package/dist/client/assets/{search-toggle-BagUH5ou.js → search-toggle-WpwB9NTm.js} +1 -1
  242. package/dist/client/assets/{secret-ciphertext-B8vjXVJK.js → secret-ciphertext-Czf9O-1T.js} +1 -1
  243. package/dist/client/assets/{secret-picker-CNgtWTyP.js → secret-picker-BXCAUVAP.js} +1 -1
  244. package/dist/client/assets/{secrets-Bgw4Vhpc.js → secrets-BcmIqFKn.js} +1 -1
  245. package/dist/client/assets/{sections-editor-DrdT1MI7.js → sections-editor-BHyoHxle.js} +1 -1
  246. package/dist/client/assets/{select-B54nmexC.js → select-DNg7bbDH.js} +1 -1
  247. package/dist/client/assets/{select-model-BoCP7Le0.js → select-model-BZiXjL_9.js} +1 -1
  248. package/dist/client/assets/{seo-editor-CReMwULk.js → seo-editor-Bl-BPaQh.js} +1 -1
  249. package/dist/client/assets/{separator-BeOkUBr0.js → separator-Cm_HO0Z9.js} +1 -1
  250. package/dist/client/assets/{settings-tab-D75yr9EZ.js → settings-tab-HtMa3j_H.js} +1 -1
  251. package/dist/client/assets/{sheet-2W5SODwA.js → sheet-BkPP8AZK.js} +1 -1
  252. package/dist/client/assets/{shell-layout-xMF7zZJW.js → shell-layout-DN47bnKe.js} +1 -1
  253. package/dist/client/assets/site-editor-C2IV8-R4.js +1 -0
  254. package/dist/client/assets/{site-editor-toast-B6rO5nP0.js → site-editor-toast-CyaF105p.js} +1 -1
  255. package/dist/client/assets/{skills-C1sp0eJN.js → skills-DGdoyYGt.js} +1 -1
  256. package/dist/client/assets/{slider-BpixRq8v.js → slider-_zRkS4wM.js} +1 -1
  257. package/dist/client/assets/{sortable.esm-B1VIDqmY.js → sortable.esm-CmDrPnmK.js} +1 -1
  258. package/dist/client/assets/{sso-B50YHclH.js → sso-DTG3Lp1u.js} +1 -1
  259. package/dist/client/assets/{suggestion-DjstHMLc.js → suggestion-lgC5D-K9.js} +1 -1
  260. package/dist/client/assets/{switch-ZvhKKFCY.js → switch-DfaNPdpc.js} +1 -1
  261. package/dist/client/assets/{symbol-CRqLTukg.js → symbol-Dn_nlM9r.js} +1 -1
  262. package/dist/client/assets/{synced-repos-D0e12nej.js → synced-repos-BjRD-t52.js} +1 -1
  263. package/dist/client/assets/{tab-icon-glyph-By9Irlxn.js → tab-icon-glyph-CG7Es1mP.js} +1 -1
  264. package/dist/client/assets/{table-iG31aWmE.js → table-yUubbfxv.js} +1 -1
  265. package/dist/client/assets/{tabs-CtKgNHMr.js → tabs-CYflymdB.js} +1 -1
  266. package/dist/client/assets/{task-board-C00mxWAh.js → task-board-DECqJdXT.js} +1 -1
  267. package/dist/client/assets/{task-route-BCPomVVQ.js → task-route-ohRbH-Kc.js} +1 -1
  268. package/dist/client/assets/{task-status-BDiexprl.js → task-status-BZCg3COp.js} +1 -1
  269. package/dist/client/assets/taskboard-analytics-Bn8pDGxt.js +1 -0
  270. package/dist/client/assets/{tasks-AIRARaPK.js → tasks-1iNvv5oa.js} +1 -1
  271. package/dist/client/assets/tasks-DLf_VBTK.js +1 -0
  272. package/dist/client/assets/{textarea-BLu1V32o.js → textarea-kGC3sYWt.js} +1 -1
  273. package/dist/client/assets/{thread-analytics-BMKFoeky.js → thread-analytics-B-EKbQmw.js} +1 -1
  274. package/dist/client/assets/{thread-intent-9GHukD-s.js → thread-intent-Di5tepkH.js} +1 -1
  275. package/dist/client/assets/{thread-route-B1NXGQXt.js → thread-route-CfaZCpix.js} +1 -1
  276. package/dist/client/assets/{thread-route-CW7xmu6G.js → thread-route-DgDZ2Nyz.js} +1 -1
  277. package/dist/client/assets/{thread-sheet-body-rJHE2tap.js → thread-sheet-body-DL6wzTfI.js} +1 -1
  278. package/dist/client/assets/{time-range-picker-CNeKIOXx.js → time-range-picker-B9oit3Mc.js} +1 -1
  279. package/dist/client/assets/{toggle-group-BLxmrLuD.js → toggle-group-DYPCj1D0.js} +1 -1
  280. package/dist/client/assets/{tool-namespace-Cu-DNTic.js → tool-namespace-dskclO-L.js} +1 -1
  281. package/dist/client/assets/{toolbar-icon-button-670IDOJM.js → toolbar-icon-button-D_fIQA2U.js} +1 -1
  282. package/dist/client/assets/{tooltip-B6W7NpVz.js → tooltip-BeXZztJN.js} +1 -1
  283. package/dist/client/assets/{tooltipContext-BWgKo-Vc.js → tooltipContext-BIPSHJCT.js} +1 -1
  284. package/dist/client/assets/{track-j7cOVNc5.js → track-D-gmwUsl.js} +1 -1
  285. package/dist/client/assets/{types-C4NGZqb0.js → types-DU_MHXlS.js} +1 -1
  286. package/dist/client/assets/{url-slug-CCgQongS.js → url-slug-CsT_ycRV.js} +1 -1
  287. package/dist/client/assets/{usage-stats-2c6yVTyC.js → usage-stats-Cz9g0-GH.js} +1 -1
  288. package/dist/client/assets/{use-ai-providers-BWqKJRmf.js → use-ai-providers-pVwPHd2p.js} +1 -1
  289. package/dist/client/assets/{use-app-takeover-DUugSHjQ.js → use-app-takeover-DGuaeK1E.js} +1 -1
  290. package/dist/client/assets/{use-automations-DOCjbfCs.js → use-automations-Ddr0h16-.js} +1 -1
  291. package/dist/client/assets/{use-autosave-BpEFoeBr.js → use-autosave-Gmm6hqXA.js} +1 -1
  292. package/dist/client/assets/{use-chat-navigation-CmNsxQBq.js → use-chat-navigation-BZPwAIJp.js} +1 -1
  293. package/dist/client/assets/{use-clock-tick-B2MqiplU.js → use-clock-tick-CRJBDWAc.js} +1 -1
  294. package/dist/client/assets/{use-connect-companion-DCgJdQ-W.js → use-connect-companion-Bh8n_8YE.js} +1 -1
  295. package/dist/client/assets/{use-connection-BDpvwZcn.js → use-connection-8BmhYkq4.js} +1 -1
  296. package/dist/client/assets/{use-copy-_ycKA-XN.js → use-copy-C4cSqwDf.js} +1 -1
  297. package/dist/client/assets/{use-create-virtual-mcp-CXKmymqn.js → use-create-virtual-mcp-BPPno1wa.js} +1 -1
  298. package/dist/client/assets/{use-date-fns-locale-fMKfOMsB.js → use-date-fns-locale-B8dgP0v5.js} +1 -1
  299. package/dist/client/assets/{use-debounced-autosave-B9xt5l_2.js → use-debounced-autosave-CG-eF9TW.js} +1 -1
  300. package/dist/client/assets/{use-debounced-value-ByyoTH63.js → use-debounced-value-mzFrr48B.js} +1 -1
  301. package/dist/client/assets/{use-deco-credits-CT_j_qxS.js → use-deco-credits-9bRoJ2ie.js} +1 -1
  302. package/dist/client/assets/{use-decopilot-events-Bd-4vex6.js → use-decopilot-events-BFo3Q85g.js} +1 -1
  303. package/dist/client/assets/{use-delete-connection-DJ4nDOEg.js → use-delete-connection-C0-u8Foh.js} +1 -1
  304. package/dist/client/assets/{use-deployment-admin-BoLt0KCx.js → use-deployment-admin-7TS6EUhU.js} +1 -1
  305. package/dist/client/assets/{use-ensure-project-folder-Dd1Qlz-V.js → use-ensure-project-folder-B6rb5Sqn.js} +1 -1
  306. package/dist/client/assets/{use-fast-preview-draft-url-DZRNnF9t.js → use-fast-preview-draft-url-CF_ZEIjv.js} +1 -1
  307. package/dist/client/assets/{use-file-configs-DgLGloNq.js → use-file-configs-lb5n-Kst.js} +1 -1
  308. package/dist/client/assets/{use-infinite-scroll-F7T2FF-S.js → use-infinite-scroll-CHPS9GSS.js} +1 -1
  309. package/dist/client/assets/{use-join-requests-DqXVwXAp.js → use-join-requests-D39tbNJ-.js} +1 -1
  310. package/dist/client/assets/{use-main-panel-tabs-CAJkn_vg.js → use-main-panel-tabs-hQnJLmPW.js} +1 -1
  311. package/dist/client/assets/{use-mcp-auth-status-2eKyky0r.js → use-mcp-auth-status-B5xnkLNa.js} +1 -1
  312. package/dist/client/assets/{use-mcp-client-B333X4fs.js → use-mcp-client-BVuelL6o.js} +1 -1
  313. package/dist/client/assets/{use-mcp-prompts-P2KMjN9W.js → use-mcp-prompts-CS-oGl4K.js} +1 -1
  314. package/dist/client/assets/{use-mcp-tools-56vayh3K.js → use-mcp-tools-Bg8S_--P.js} +1 -1
  315. package/dist/client/assets/{use-members-DfdZqgw8.js → use-members-ZmrZXdxt.js} +1 -1
  316. package/dist/client/assets/{use-mobile-hkvDmO1w.js → use-mobile-c8CmS6Ky.js} +1 -1
  317. package/dist/client/assets/{use-navigate-to-agent-Dzg43OKn.js → use-navigate-to-agent-CS6PZDRo.js} +1 -1
  318. package/dist/client/assets/{use-open-billing-url-DJYL8W0U.js → use-open-billing-url-CvJGkWPa.js} +1 -1
  319. package/dist/client/assets/{use-org-auth-client-DROvF2zH.js → use-org-auth-client-7uiMaX9m.js} +1 -1
  320. package/dist/client/assets/{use-org-fs-D6VAaLCr.js → use-org-fs-DxaNIxHS.js} +1 -1
  321. package/dist/client/assets/{use-org-repo-syncs-DlDJxigu.js → use-org-repo-syncs-DvcMfmsf.js} +1 -1
  322. package/dist/client/assets/{use-org-sso-CH28wOEA.js → use-org-sso-tYTwt4JX.js} +1 -1
  323. package/dist/client/assets/{use-organization-roles-BQ-3VnZ-.js → use-organization-roles-Bqi3_NP9.js} +1 -1
  324. package/dist/client/assets/{use-organization-settings-DxTssZLI.js → use-organization-settings-DIDu23VE.js} +1 -1
  325. package/dist/client/assets/{use-panel-navigate-C2cHRlDL.js → use-panel-navigate-D29J1g8E.js} +1 -1
  326. package/dist/client/assets/{use-project-native-view-presence-bO2szMt1.js → use-project-native-view-presence-28zFpJOc.js} +1 -1
  327. package/dist/client/assets/{use-project-scope-BROCSZWk.js → use-project-scope-BwqFxpga.js} +1 -1
  328. package/dist/client/assets/{use-recent-apps-DhLr7_TT.js → use-recent-apps-I5QNk-rw.js} +1 -1
  329. package/dist/client/assets/{use-releases-D6ba4LWy.js → use-releases-gYorfDgo.js} +1 -1
  330. package/dist/client/assets/{use-reports-diagnostic-BYrSJ1-D.js → use-reports-diagnostic-BMXByYS1.js} +1 -1
  331. package/dist/client/assets/{use-secrets-znuJNv0F.js → use-secrets-3msHfIaI.js} +1 -1
  332. package/dist/client/assets/{use-section-preview-base-CDeugTlj.js → use-section-preview-base-B2-7stWU.js} +1 -1
  333. package/dist/client/assets/{use-tags-frFveynu.js → use-tags-BazP7fHR.js} +1 -1
  334. package/dist/client/assets/{use-task-board-analytics-BLvo5Ioy.js → use-task-board-analytics-D6OoPTVm.js} +1 -1
  335. package/dist/client/assets/{use-task-board-events-BNCUuZ7v.js → use-task-board-events-Bi_ccnlg.js} +1 -1
  336. package/dist/client/assets/{use-task-board-item-prs-C03gSLLs.js → use-task-board-item-prs-CXeLuDC6.js} +1 -1
  337. package/dist/client/assets/{use-task-board-items-gTQZEpDz.js → use-task-board-items-d6JQ3Bl4.js} +1 -1
  338. package/dist/client/assets/{use-task-metadata-D3ZyQdu3.js → use-task-metadata-BHGZc8_0.js} +1 -1
  339. package/dist/client/assets/{use-thread-analytics-pc4Cx2fq.js → use-thread-analytics-CGDKhbwi.js} +1 -1
  340. package/dist/client/assets/{use-thread-outputs-BwFYAN97.js → use-thread-outputs-D_k9lfJL.js} +1 -1
  341. package/dist/client/assets/useInfiniteQuery-CMeX9PQf.js +1 -0
  342. package/dist/client/assets/{useQueries-6AB3hL0G.js → useQueries-BpKrI8ET.js} +1 -1
  343. package/dist/client/assets/useSuspenseInfiniteQuery-B2-UZELM.js +1 -0
  344. package/dist/client/assets/{users-DsZm3Nkx.js → users-Bv1mI4MP.js} +1 -1
  345. package/dist/client/assets/{utils-D-T02kS4.js → utils-BeuJsXPr.js} +1 -1
  346. package/dist/client/assets/{variant-calendar-DoUmbH6Q.js → variant-calendar-BRenWIH6.js} +1 -1
  347. package/dist/client/assets/{variant-draft-pointer-CGTqYMj8.js → variant-draft-pointer-CzGFLwwv.js} +1 -1
  348. package/dist/client/assets/{view-mode-toggle-BM2WBWnv.js → view-mode-toggle-Cob2WQfe.js} +1 -1
  349. package/dist/client/assets/{virtual-mcp-CM_cNcV_.js → virtual-mcp-DEbou0MI.js} +1 -1
  350. package/dist/client/assets/{watch-sse-pool-C1f9T3Cq.js → watch-sse-pool-R4orcIOc.js} +1 -1
  351. package/dist/client/index.html +1 -1
  352. package/dist/server/server.js +1 -1
  353. package/package.json +1 -1
  354. package/dist/client/assets/agent-app-B_p1zClu.js +0 -1
  355. package/dist/client/assets/agent-deck-Bv4Ea3n5.js +0 -1
  356. package/dist/client/assets/agent-library-B8Kx2dH6.js +0 -1
  357. package/dist/client/assets/agent-library-file-D6BfiqFR.js +0 -1
  358. package/dist/client/assets/agent-settings-CYtLsqfY.js +0 -1
  359. package/dist/client/assets/agent-site-editor-code-CoA0Y8Pm.js +0 -2
  360. package/dist/client/assets/agent-site-editor-content-B6s0vW0K.js +0 -1
  361. package/dist/client/assets/agent-site-editor-preview-Deycj8Hn.js +0 -1
  362. package/dist/client/assets/agent-view-DKBEZHZf.js +0 -1
  363. package/dist/client/assets/api-keys-DIX6Wq_J.js +0 -1
  364. package/dist/client/assets/cms-settings-editor-B950DCbJ.js +0 -1
  365. package/dist/client/assets/flat-project-CqneD8tb.js +0 -1
  366. package/dist/client/assets/library-D9_ShewK.js +0 -1
  367. package/dist/client/assets/project-reports-D8ocu1pR.js +0 -1
  368. package/dist/client/assets/project-tasks-DJVmaqrl.js +0 -1
  369. package/dist/client/assets/record-editor-DywGKfn_.js +0 -1
  370. package/dist/client/assets/reports-wAXvk8Rj.js +0 -1
  371. package/dist/client/assets/route-y_BiPuKo.js +0 -1
  372. package/dist/client/assets/site-editor-BpVflMAH.js +0 -1
  373. package/dist/client/assets/taskboard-analytics-dOoDSrcB.js +0 -1
  374. package/dist/client/assets/tasks-D17PyrkT.js +0 -1
  375. package/dist/client/assets/useInfiniteQuery-Z8R3F4Sd.js +0 -1
  376. package/dist/client/assets/useSuspenseInfiniteQuery-CccYtrDO.js +0 -1
@@ -1,4 +1,4 @@
1
- import{c as F,b as ge,r as V,j as c,B as _e,l as ie,K as Js,ao as Vn,au as ll,az as kc,U as Ts,t as Je,T as yi,V as xi,X as Ci,a as vr,a2 as ki,aU as Pc,h as _i,ap as Ec,I as Rc,a5 as Bc,o as br,R as hl,m as Is,aV as cl,F as dl,D as ul,v as fl,q as _l,Q as ml,H as pl,a3 as gl,aW as mi,e as Lo,y as Dc,J as Ac,aX as Mc,O as Tc}from"./index-BlWeDA0T.js";import{S as Nc}from"./separator-BeOkUBr0.js";import{f as Lc,u as xs,r as vl,l as bl,c as Sl,b as Ic}from"./chat-context-CKK4nwlA.js";import{u as Zs,D as Oc,c as Yn,b as Gn,d as Xn,f as or,g as Io,h as jc,i as Fc,j as Ir,k as Hc,t as Oo,l as zc,m as Wc,n as $c,o as Uc,q as Kc,v as qc,w as Jn,x as wl,E as Vc,y as yl,z as xl}from"./site-editor-toast-B6rO5nP0.js";import{L as Yc,a as Gc}from"./shell-layout-xMF7zZJW.js";import{I as Cl}from"./toolbar-icon-button-670IDOJM.js";import{P as kl,a as Pl,b as El}from"./popover-C86-20Mm.js";import{c as it,T as rt,a as nt,b as Sr}from"./tooltip-B6W7NpVz.js";import{A as Zn,a as Qn,b as eo,c as to,g as so,d as io,e as ro,f as no}from"./alert-dialog-Cww2cCKj.js";import{d as Xc,e as Jc,c as Zc,C as jo,a as Fo,b as Ho}from"./command-D2C8egnH.js";import{T as Rs,a as Rl,b as Bl}from"./tabs-CtKgNHMr.js";import{t as wr,n as Qc}from"./ChevronUp-C9gm2RHA.js";import{P as yr,D as ed,a as Dl,Q as td,b as sd,R as Al,M as id}from"./agent-icon-Cwi3uRdu.js";import{i as Ml}from"./DotsVertical-DjBJNxxU.js";import{b as Tl}from"./Tool01-BYtrXXg0.js";import{s as oo}from"./Plus-DBwsZRbL.js";import{s as xr}from"./Trash01-DmGIq4LE.js";import{u as ao,r as Or,a as zo,n as jr,g as lo,b as ho}from"./use-releases-D6ba4LWy.js";import{u as rd}from"./use-members-DfdZqgw8.js";import{p as nd,d as od,r as ad,M as ld}from"./thread-intent-9GHukD-s.js";import{h as Nl,r as Ll,g as hd,d as Lt,a as Cr,e as Il}from"./repository-binding-Ds0zXEVH.js";import{u as cd}from"./use-debounced-value-ByyoTH63.js";import{u as dd}from"./use-clock-tick-B2MqiplU.js";import{u as ud}from"./useInfiniteQuery-Z8R3F4Sd.js";import{d as fd,b as _d,p as md,e as Ol,g as jl,h as Fl}from"./use-navigate-to-agent-Dzg43OKn.js";import{R as Wo}from"./virtual-mcp-CM_cNcV_.js";import{c as pd,a as $o,d as gd}from"./use-project-native-view-presence-bO2szMt1.js";import{G as Hl}from"./repository-picker-DoUZKYGY.js";import{a as kr}from"./input-3uLsKqBB.js";import{u as vd,a as bd}from"./use-fast-preview-draft-url-DZRNnF9t.js";import{p as Vs,a as zl,g as ar,i as co,S as Sd,b as wd,e as pi,f as Wl,c as yd,D as xd,C as Cd,R as $l}from"./secret-ciphertext-B8vjXVJK.js";import{u as Pr,a as Ul}from"./index-BVXKUS4M.js";import{T as kd}from"./textarea-BLu1V32o.js";import{i as uo}from"./CheckCircle-DIUFnJQp.js";import{s as Kl}from"./Image01-LmX-9DTg.js";import{b as Pd}from"./format-time-CAj8AQXM.js";import{a as Ed,b as Rd,c as Bd}from"./UserSquare-B3hi5v4G.js";import{f as fo,a as ql,r as Er,p as Dd,b as Vl,i as _o,d as Ad,s as Yl,m as Md,h as Td,c as Gl,e as Nd,n as Ld,g as Id,j as Od,k as jd,l as mo,o as Fd,q as Xl,t as Jl,u as Fr}from"./sandbox-git-api-CRxdlhrN.js";import{d as Hd,g as zd}from"./utils-D-T02kS4.js";import{i as Wd}from"./Monitor01-zCUpqs5C.js";import{g as $d,w as Zl,D as Ud}from"./section-preview-url-7zfngvgW.js";import{w as Kd}from"./device-hint-SeLRi17j.js";import{w as Uo}from"./editor-r9_MTJH5.js";import{u as Ql,p as qd,H as Vd,h as Yd,n as Gd,r as Xd,a as Jd}from"./hosted-publish-feedback-5DTVDnQ-.js";import{s as eh}from"./save-changes-debug-nBi-n9eV.js";import{u as Zd}from"./use-mcp-client-B333X4fs.js";import{a as Qd,b as th}from"./sandbox-lifecycle-context-DHjDdwbp.js";import{u as eu}from"./use-panel-navigate-C2cHRlDL.js";import{b as Ko}from"./sandbox-url-D3mC8qhT.js";import{i as lr}from"./Play-BaMMHzUS.js";import{C as tu}from"./index-Cb4Qh-54.js";import"./autosend-DkgNxXhw.js";import"./use-decopilot-events-Bd-4vex6.js";import"./watch-sse-pool-C1f9T3Cq.js";import"./task-board-C00mxWAh.js";import"./schema-DO5D2eCO.js";import"./backoff-CrEUbyZT.js";import"./use-ai-providers-BWqKJRmf.js";import"./use-chat-navigation-CmNsxQBq.js";import"./thread-route-CW7xmu6G.js";import"./location-BjlyegC2.js";import"./use-organization-settings-DxTssZLI.js";import"./avatar-Bp-EkB-V.js";import"./User01-DxYW6D1x.js";import"./Building02-DqK4SREZ.js";import"./XClose-D_NlSxSm.js";import"./use-project-scope-BROCSZWk.js";import"./ZoomOut-BpMDqvoU.js";import"./integration-icon-BRfynNZ5.js";import"./LinkBroken01-D4fcNp0y.js";import"./project-icon-CJp8KUWK.js";import"./new-project-dialog-D9WaXvgl.js";import"./ArrowLeft-BsOtfvqw.js";import"./label-CCf767lm.js";import"./repository-import-picker-CJrt2Qyf.js";import"./required-auth-layout-CoQlG-uh.js";import"./use-org-sso-CH28wOEA.js";import"./index-DrHP_BcE.js";import"./index-BHzdhQYD.js";import"./SearchMd-Cz9CjV4u.js";import"./AlertCircle-BugQG9bV.js";import"./ArrowUp-BM60-fZY.js";import"./ShoppingBag01-FE4oAEwY.js";import"./ChevronSelectorVertical-CRMiEVEY.js";import"./Copy01-BrqDGrTX.js";import"./CreditCard01-C7MhbtAI.js";import"./Globe04-Bi1qDXFD.js";import"./SwitchHorizontal01-BLoNOmQx.js";import"./Key01-D7fc2of0.js";import"./Link01-UOxGnkqg.js";import"./Sun-lUDK8Dny.js";import"./Upload01-B1KubIEG.js";import"./Users01-Dg9yGM1q.js";import"./serial-task-queue-CGOeQgpr.js";import"./use-org-auth-client-DROvF2zH.js";import"./delay-CnY5UFtP.js";import"./slugify-CEUa2lfQ.js";import"./infiniteQueryObserver-C9osZa8h.js";import"./url-slug-CCgQongS.js";import"./use-file-configs-DgLGloNq.js";import"./site-slug-DebpOoQq.js";import"./collection-search-mDMHjO22.js";import"./usage-stats-2c6yVTyC.js";import"./tool-namespace-Cu-DNTic.js";import"./form-DDdiF5DN.js";import"./utils-CVEq3hMx.js";import"./markdown-BRIlR7nZ.js";import"./use-copy-_ycKA-XN.js";import"./use-mobile-hkvDmO1w.js";import"./icon-button-DfjCa6Mk.js";import"./file-type-icon-C2mdy7vI.js";import"./chat-draft-BMAMpVi3.js";import"./select-B54nmexC.js";import"./index-BdQq_4o_.js";import"./use-deco-credits-CT_j_qxS.js";import"./toggle-group-BLxmrLuD.js";import"./use-open-billing-url-DJYL8W0U.js";import"./index-sLNiMwXT.js";import"./checkbox-Dwjm_TLd.js";import"./ai-providers-logos-DD3qZ33J.js";import"./drawer-C7TJoqXz.js";import"./input-BSKhVE-B.js";import"./suggestion-DjstHMLc.js";import"./use-mcp-prompts-P2KMjN9W.js";import"./use-org-fs-D6VAaLCr.js";import"./question-004-sINsf4GQ.js";import"./feature-paywall-DXx7v-jJ.js";import"./plan-ladder-DRlbA6Oe.js";import"./add-connection-dialog-lyugU_mj.js";import"./extract-connection-data-B2gWRdBp.js";import"./metadata-D72DunRR.js";import"./connection-CXmYeQRu.js";import"./connection-card-BnbrpDH3.js";import"./connection-slug-CITJ0kGN.js";import"./use-connection-BDpvwZcn.js";import"./schema-D-34ICTJ.js";import"./connection-form-helpers-a4JD1Ns8.js";import"./authenticate-and-persist-oauth-p8iXxMbw.js";import"./mcp-oauth-Wpa3RhmZ.js";import"./mcp-oauth-CbRV1ySf.js";import"./auth-d1Zn25hw.js";import"./collection-tabs-C8f6Only.js";import"./badge-BIePf0xK.js";import"./use-infinite-scroll-F7T2FF-S.js";import"./useSuspenseInfiniteQuery-CccYtrDO.js";import"./use-task-board-events-BNCUuZ7v.js";import"./alert-DD0xrZ6s.js";import"./pair-Boroas12.js";import"./collapsible-BEHE2idT.js";import"./content-blocks-o63cs2vh.js";import"./mcp-app-renderer-BdWVQtZT.js";import"./types-C4NGZqb0.js";import"./omit-sandbox-map-jj4lCB2U.js";import"./sheet-2W5SODwA.js";import"./use-thread-outputs-BwFYAN97.js";import"./differenceInSeconds-C3x8sHUj.js";import"./sandbox-start-errors-BK_aDCyt.js";import"./use-app-takeover-DUugSHjQ.js";import"./resizable-Bu_8_8YG.js";const qo=/[\r\n<>]/,su=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Rr(t){const e=t?.userName?.trim();if(!e||qo.test(e))return null;const s=t?.userEmail?.trim();return!s||qo.test(s)?{userName:e}:su.test(s)?{userName:e,userEmail:s}:{userName:e}}function iu(t){return t.split(`
1
+ import{c as F,b as ge,r as V,j as c,B as _e,l as ie,K as Js,ao as Vn,au as ll,az as kc,U as Ts,t as Je,T as yi,V as xi,X as Ci,a as vr,a2 as ki,aU as Pc,h as _i,ap as Ec,I as Rc,a5 as Bc,o as br,R as hl,m as Is,aV as cl,F as dl,D as ul,v as fl,q as _l,Q as ml,H as pl,a3 as gl,aW as mi,e as Lo,y as Dc,J as Ac,aX as Mc,O as Tc}from"./index-6Ng0tT_w.js";import{S as Nc}from"./separator-Cm_HO0Z9.js";import{f as Lc,u as xs,r as vl,l as bl,c as Sl,b as Ic}from"./chat-context-BnOeJwbx.js";import{u as Zs,D as Oc,c as Yn,b as Gn,d as Xn,f as or,g as Io,h as jc,i as Fc,j as Ir,k as Hc,t as Oo,l as zc,m as Wc,n as $c,o as Uc,q as Kc,v as qc,w as Jn,x as wl,E as Vc,y as yl,z as xl}from"./site-editor-toast-CyaF105p.js";import{L as Yc,a as Gc}from"./shell-layout-DN47bnKe.js";import{I as Cl}from"./toolbar-icon-button-D_fIQA2U.js";import{P as kl,a as Pl,b as El}from"./popover-7WD7U7Ag.js";import{c as it,T as rt,a as nt,b as Sr}from"./tooltip-BeXZztJN.js";import{A as Zn,a as Qn,b as eo,c as to,g as so,d as io,e as ro,f as no}from"./alert-dialog-BmunadUc.js";import{d as Xc,e as Jc,c as Zc,C as jo,a as Fo,b as Ho}from"./command-CzrMHXxb.js";import{T as Rs,a as Rl,b as Bl}from"./tabs-CYflymdB.js";import{t as wr,n as Qc}from"./ChevronUp-DRQp-Xgt.js";import{P as yr,D as ed,a as Dl,Q as td,b as sd,R as Al,M as id}from"./agent-icon-DYK_xLct.js";import{i as Ml}from"./DotsVertical-Drkb0dMp.js";import{b as Tl}from"./Tool01-DgnrifZ2.js";import{s as oo}from"./Plus-CpsuuelG.js";import{s as xr}from"./Trash01-nUIoghkK.js";import{u as ao,r as Or,a as zo,n as jr,g as lo,b as ho}from"./use-releases-gYorfDgo.js";import{u as rd}from"./use-members-ZmrZXdxt.js";import{p as nd,d as od,r as ad,M as ld}from"./thread-intent-Di5tepkH.js";import{h as Nl,r as Ll,g as hd,d as Lt,a as Cr,e as Il}from"./repository-binding-BaMWuPiD.js";import{u as cd}from"./use-debounced-value-mzFrr48B.js";import{u as dd}from"./use-clock-tick-CRJBDWAc.js";import{u as ud}from"./useInfiniteQuery-CMeX9PQf.js";import{d as fd,b as _d,p as md,e as Ol,g as jl,h as Fl}from"./use-navigate-to-agent-CS6PZDRo.js";import{R as Wo}from"./virtual-mcp-DEbou0MI.js";import{c as pd,a as $o,d as gd}from"./use-project-native-view-presence-28zFpJOc.js";import{G as Hl}from"./repository-picker-CZRoSABc.js";import{a as kr}from"./input-DvkV2rhp.js";import{u as vd,a as bd}from"./use-fast-preview-draft-url-CF_ZEIjv.js";import{p as Vs,a as zl,g as ar,i as co,S as Sd,b as wd,e as pi,f as Wl,c as yd,D as xd,C as Cd,R as $l}from"./secret-ciphertext-Czf9O-1T.js";import{u as Pr,a as Ul}from"./index-hkiYH0EW.js";import{T as kd}from"./textarea-kGC3sYWt.js";import{i as uo}from"./CheckCircle-DHs2hGe9.js";import{s as Kl}from"./Image01-qnXYF9Lx.js";import{b as Pd}from"./format-time-CAj8AQXM.js";import{a as Ed,b as Rd,c as Bd}from"./UserSquare-D-nNMLFe.js";import{f as fo,a as ql,r as Er,p as Dd,b as Vl,i as _o,d as Ad,s as Yl,m as Md,h as Td,c as Gl,e as Nd,n as Ld,g as Id,j as Od,k as jd,l as mo,o as Fd,q as Xl,t as Jl,u as Fr}from"./sandbox-git-api-CRxdlhrN.js";import{d as Hd,g as zd}from"./utils-BeuJsXPr.js";import{i as Wd}from"./Monitor01-7E6lWSm8.js";import{g as $d,w as Zl,D as Ud}from"./section-preview-url-7zfngvgW.js";import{w as Kd}from"./device-hint-SeLRi17j.js";import{w as Uo}from"./editor-CGejMM_z.js";import{u as Ql,p as qd,H as Vd,h as Yd,n as Gd,r as Xd,a as Jd}from"./hosted-publish-feedback-Dmtx9jpJ.js";import{s as eh}from"./save-changes-debug-nBi-n9eV.js";import{u as Zd}from"./use-mcp-client-BVuelL6o.js";import{a as Qd,b as th}from"./sandbox-lifecycle-context-DA-DHHDl.js";import{u as eu}from"./use-panel-navigate-D29J1g8E.js";import{b as Ko}from"./sandbox-url-D3mC8qhT.js";import{i as lr}from"./Play-NXc3jRj5.js";import{C as tu}from"./index-CmAR63BL.js";import"./autosend-CG2VxFoj.js";import"./use-decopilot-events-BFo3Q85g.js";import"./watch-sse-pool-R4orcIOc.js";import"./task-board-DECqJdXT.js";import"./schema-CB-lS3_k.js";import"./backoff-CrEUbyZT.js";import"./use-ai-providers-pVwPHd2p.js";import"./use-chat-navigation-BZPwAIJp.js";import"./thread-route-DgDZ2Nyz.js";import"./location-BjlyegC2.js";import"./use-organization-settings-DIDu23VE.js";import"./avatar-DXy0LAdF.js";import"./User01-CNvDoTpL.js";import"./Building02-uWsB2mfH.js";import"./XClose-CYU9Adi9.js";import"./use-project-scope-BwqFxpga.js";import"./ZoomOut-BNxfvkQ2.js";import"./integration-icon-DkW9ztwd.js";import"./LinkBroken01-BRTnEcyu.js";import"./project-icon-Dk5277oF.js";import"./new-project-dialog-WJlnuE7i.js";import"./ArrowLeft-Cndk_wxI.js";import"./label-BjcPiOzG.js";import"./repository-import-picker-B4IvUqwn.js";import"./required-auth-layout-BFsMU6XE.js";import"./use-org-sso-tYTwt4JX.js";import"./index-Cx3zRpVQ.js";import"./index-xa9ZKf5B.js";import"./SearchMd-DJhWmDye.js";import"./AlertCircle-B1K4xFWw.js";import"./ArrowUp-RNWLmEvk.js";import"./ShoppingBag01-C5te0Nzh.js";import"./ChevronSelectorVertical-DviKGPlb.js";import"./Copy01-v7NhM9oA.js";import"./CreditCard01-Dtw0unEW.js";import"./Globe04-Dn8iGQE6.js";import"./SwitchHorizontal01-lG9ssyHa.js";import"./Key01-BylVHZZg.js";import"./Link01-CH8d8vV_.js";import"./Sun-DKM-uJFR.js";import"./Upload01-UvdGjs0c.js";import"./Users01-CM2CFJbp.js";import"./serial-task-queue-CGOeQgpr.js";import"./use-org-auth-client-7uiMaX9m.js";import"./delay-CnY5UFtP.js";import"./slugify-CEUa2lfQ.js";import"./infiniteQueryObserver-eO9zOabS.js";import"./url-slug-CsT_ycRV.js";import"./use-file-configs-lb5n-Kst.js";import"./site-slug-DebpOoQq.js";import"./collection-search-BDkQDOp5.js";import"./usage-stats-Cz9g0-GH.js";import"./tool-namespace-dskclO-L.js";import"./form-DmRVhMTU.js";import"./utils-CVEq3hMx.js";import"./markdown-DpIn9foG.js";import"./use-copy-C4cSqwDf.js";import"./use-mobile-c8CmS6Ky.js";import"./icon-button-9xlK2XKp.js";import"./file-type-icon-B2QIIVAh.js";import"./chat-draft-BOY5Y2Ci.js";import"./select-DNg7bbDH.js";import"./index-BdQq_4o_.js";import"./use-deco-credits-9bRoJ2ie.js";import"./toggle-group-DYPCj1D0.js";import"./use-open-billing-url-CvJGkWPa.js";import"./index-C-YzI0Se.js";import"./checkbox-Bl1Mjt0r.js";import"./ai-providers-logos-DD3qZ33J.js";import"./drawer-DbH0dp7b.js";import"./input-Cn9XurDr.js";import"./suggestion-lgC5D-K9.js";import"./use-mcp-prompts-CS-oGl4K.js";import"./use-org-fs-DxaNIxHS.js";import"./question-004-sINsf4GQ.js";import"./feature-paywall-Yxq9HHQa.js";import"./plan-ladder-sdrPy_gR.js";import"./add-connection-dialog-CMCPQ8st.js";import"./extract-connection-data-Djn2ZuE9.js";import"./metadata-D72DunRR.js";import"./connection-C1Ch9D0_.js";import"./connection-card-DbSwpeYP.js";import"./connection-slug-CITJ0kGN.js";import"./use-connection-8BmhYkq4.js";import"./schema-BJXub_FG.js";import"./connection-form-helpers-Q8DdmcgV.js";import"./authenticate-and-persist-oauth-DolvVBs8.js";import"./mcp-oauth-JuThqha-.js";import"./mcp-oauth-j-V6G83N.js";import"./auth-BvBcXr-J.js";import"./collection-tabs-LE_ipkrD.js";import"./badge-4cemB70d.js";import"./use-infinite-scroll-CHPS9GSS.js";import"./useSuspenseInfiniteQuery-B2-UZELM.js";import"./use-task-board-events-Bi_ccnlg.js";import"./alert-Be-y-N9r.js";import"./pair-DJltcVoF.js";import"./collapsible-odbldk6G.js";import"./content-blocks-o63cs2vh.js";import"./mcp-app-renderer-COiGcRXa.js";import"./types-DU_MHXlS.js";import"./omit-sandbox-map-jj4lCB2U.js";import"./sheet-BkPP8AZK.js";import"./use-thread-outputs-D_k9lfJL.js";import"./differenceInSeconds-C3x8sHUj.js";import"./sandbox-start-errors-BK_aDCyt.js";import"./use-app-takeover-DGuaeK1E.js";import"./resizable-NiAykzba.js";const qo=/[\r\n<>]/,su=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Rr(t){const e=t?.userName?.trim();if(!e||qo.test(e))return null;const s=t?.userEmail?.trim();return!s||qo.test(s)?{userName:e}:su.test(s)?{userName:e,userEmail:s}:{userName:e}}function iu(t){return t.split(`
2
2
  `).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
3
3
  `).trimEnd()}function ru(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function sh(t,e){const s=Rr(e);if(!s)return t;const i=iu(t),r=ru(s);if(i.includes(r))return i;const n=i.trimEnd();return n.length>0?`${n}
4
4
 
@@ -9,7 +9,7 @@ ${r}`:r}function nu(t,e){const s=t?.trim();return s?sh(s,e):s||void 0}const ou=[
9
9
  `),fallbackTitle:e})}function cr(t){return{orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch,threadId:t.threadId}}function Nu(t){return t.fastPreview?{fastPreview:!0}:void 0}async function Hr(t,e,s){try{return await s()}catch(i){throw new po(i instanceof Error?i.message:e,t)}}async function hh(t){const{expectedHeadSha:e,expectedDiffSignature:s}=t;if(!e&&!s)return;const i=await fo(cr(t)).catch(()=>null);if(!i)return;if(e&&i.headSha&&i.headSha!==e)throw new nn;if(!s)return;const r=await ql(cr(t),i,t.baseBranch,Nu(t)).catch(()=>null);if(r&&Er(r)!==s)throw new nn}function ch(t,e){return Dd(cr(t),e)}function dh(t,e){return Du(t.orgSlug,t.target,{branch:t.headBranch,title:e.title,body:e.body,base:t.baseBranch,coAuthor:t.coAuthor})}async function Lu(t,e,s){await hh(t),await Hr("push",s("thread.publishDialog.failedPushChanges"),()=>ch(t,e.message)),await Hr("sync",s("thread.publishDialog.failedRebase"),()=>Vl(cr(t),t.baseBranch));const i=await Hr("open-pr",s("thread.publishDialog.failedOpenPullRequest"),()=>dh(t,e));try{await ah(t.orgSlug,t.target,{number:i.number,commitTitle:e.title,commitMessage:e.body,coAuthor:t.coAuthor})}catch(r){throw new po(r instanceof Error?r.message:s("thread.publishDialog.failedMergePullRequest"),"merge",i)}return i}async function Iu(t,e){return await hh(t),await ch(t,e.message),dh(t,e)}function Jo(t,e){return t instanceof nn?{message:e("siteEditor.publish.changedMeanwhile"),pullRequest:null,headMoved:!0}:t instanceof po&&t.step==="merge"&&t.pr?{message:e("thread.publishDialog.mergeFailed",{prNumber:t.pr.number,message:t.message}),pullRequest:t.pr,headMoved:!1}:{message:t instanceof Error?t.message:e("thread.publishDialog.failedPublish"),pullRequest:null,headMoved:!1}}function Ou(t,e){Je.success(e("thread.publishDialog.submittedForReview",{prNumber:t.number}),{action:{label:e("thread.publishDialog.viewOnProvider"),onClick:()=>window.open(t.htmlUrl,"_blank","noopener,noreferrer")}})}const ju=/(?:^|\/)\.deco\/blocks\/([^/]+)\.json$/;function go(t){const e=ju.exec(t)?.[1];return e?Hd(e):null}function dr(t){if(!t)return null;try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return null}function Fu(t,e){return t===null?"new":e===null?"removed":"edited"}function uh(t){const e=t.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim();return e?(e.charAt(0).toUpperCase()+e.slice(1)).replace(/\s+[A-Z](?=[a-z])/g,s=>s.toLowerCase()):t}function zr(t,e){if(t&&typeof t=="object"&&!Array.isArray(t)){const s=t.__resolveType;if(typeof s=="string"&&s.trim()){const r=(s.split("/").pop()??s).replace(/\.[jt]sx?$/,"");return uh(r)||r}}return`Section ${e+1}`}function on(t){const e=t.sections;if(Array.isArray(e))return e.flatMap((s,i)=>s&&typeof s=="object"&&!Array.isArray(s)?[{section:s,basePath:["sections",i]}]:[]);if(e&&typeof e=="object"){const s=e.variants;if(Array.isArray(s))return s.flatMap((i,r)=>{const n=i&&typeof i=="object"&&!Array.isArray(i)?i.value:null;return Array.isArray(n)?n.flatMap((o,a)=>o&&typeof o=="object"&&!Array.isArray(o)?[{section:o,basePath:["sections","variants",r,"value",a]}]:[]):[]})}return[]}function Zo(t){return JSON.stringify(t,(e,s)=>{if(s&&typeof s=="object"&&!Array.isArray(s)){const i=s;return Object.keys(i).sort().reduce((r,n)=>(r[n]=i[n],r),{})}return s})}function fh(t,e){return t===void 0&&e===void 0?!0:Zo(t)===Zo(e)}function vi(t,e,s,i=new Set){const r=new Set([...Object.keys(t??{}),...Object.keys(e??{})]),n=[];for(const o of r){if(o.startsWith("__")||i.has(o))continue;const a=t?t[o]:void 0,h=e?e[o]:void 0;fh(a,h)||n.push({label:uh(o),path:[...s,o],from:a,to:h})}return n}const Hu=new Set(["sections"]);function vo(t,e){const s=t?on(t):[],i=e?on(e):[],r=[],n=Math.max(s.length,i.length);for(let a=0;a<n;a++){const h=s[a],l=i[a];if(h&&l){if(fh(h.section,l.section))continue;r.push({name:zr(l.section,a),kind:"section",status:"edited",fields:vi(h.section,l.section,l.basePath)})}else l?r.push({name:zr(l.section,a),kind:"section",status:"new",fields:[]}):h&&r.push({name:zr(h.section,a),kind:"section",status:"removed",fields:[]})}const o=vi(t,e,[],Hu);return o.length>0&&r.push({name:"Page settings",kind:"settings",status:"edited",fields:o}),r}function an(t,e){return{kind:"other",blockKey:null,name:t.split("/").pop()??t,pagePath:null,isSiteApp:!1,status:e,filepaths:[t],sections:[],fromJson:null,toJson:null}}function zu(t){const e=[],s=[],i=[],r=[];for(const[n,o]of Object.entries(t?.diffs??{})){if(_o(n)){r.push(n);continue}const a=Fu(o.from,o.to),h=go(n);if(!h){i.push(an(n,a));continue}const l=dr(o.from),u=dr(o.to),d=u??l;if(!d){i.push(an(n,a));continue}const _=Vs(h,d);if(_){e.push({kind:"page",blockKey:h,name:_.name,pagePath:_.path,isSiteApp:!1,status:a,filepaths:[n],sections:a==="edited"?vo(l,u):[],fromJson:l,toJson:u});continue}const m=co(h,d);s.push({kind:"block",blockKey:h,name:ar(h,d),pagePath:null,isSiteApp:m,status:a,filepaths:[n],sections:a==="edited"?[{name:ar(h,d),kind:"section",status:"edited",fields:vi(l,u,[])}].filter(f=>f.fields.length>0):[],fromJson:l,toJson:u})}return _h({pages:e,blocks:s,other:i,generated:r})}function Wr(t,e){return(t.filepaths[0]??"").localeCompare(e.filepaths[0]??"")}function _h(t){const{pages:e,blocks:s,other:i,generated:r}=t;return e.sort(Wr),s.sort(Wr),i.sort(Wr),{pages:e,blocks:s,other:i,generated:r,count:e.length+s.length+i.length}}function Wu(t){return t==="added"?"new":t==="removed"?"removed":"edited"}function mh(t){return t.startsWith("pages-")}function ph(t){const{files:e,lookup:s,diff:i}=t,r=[],n=[],o=[],a=[];for(const h of e){const l=h.path;if(_o(l)){a.push(l);continue}const u=Wu(h.status),d=go(l);if(!d){o.push(an(l,u));continue}const _=i?.diffs[l],m=dr(_?.from??null),f=dr(_?.to??null),p=gh(s,d),g=p??f??m;if((p?Vs(d,p):null)??(!p&&mh(d))){const S=g?Vs(d,g):null;r.push({kind:"page",blockKey:d,name:S?.name??zl(d),pagePath:S?.path??null,isSiteApp:!1,status:u,filepaths:[l],sections:u==="edited"?vo(m,f):[],fromJson:m,toJson:f??(u==="new"?p:null)});continue}const C=ar(d,g??{});n.push({kind:"block",blockKey:d,name:C,pagePath:null,isSiteApp:co(d,p??{}),status:u,filepaths:[l],sections:u==="edited"?[{name:C,kind:"section",status:"edited",fields:vi(m,f,[])}].filter(S=>S.fields.length>0):[],fromJson:m,toJson:f})}return _h({pages:r,blocks:n,other:o,generated:a})}function gh(t,e){const s=t?.[e];return s&&typeof s=="object"&&!Array.isArray(s)?s:null}function $u(t,e){return t??e}function vh(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}const $r=3;function Ui(t){if(t.length<=$r)return vh(t);const e=t.length-$r;return`${t.slice(0,$r).join(", ")} and ${e} more`}function Uu(t){const e=t.sections.filter(s=>s.kind==="section").map(s=>s.name).slice(0,3);return e.length>0?`${t.name} (${e.join(", ")})`:t.name}function Ku(t){const e=[],s=t.pages.filter(a=>a.status==="edited"),i=t.pages.filter(a=>a.status==="new"),r=t.pages.filter(a=>a.status==="removed");if(s.length>0&&e.push(`updated ${Ui(s.map(Uu))}`),i.length>0){const a=i.length===1?"page":"pages";e.push(`added the ${Ui(i.map(h=>h.name))} ${a}`)}if(r.length>0){const a=r.length===1?"page":"pages";e.push(`removed the ${Ui(r.map(h=>h.name))} ${a}`)}const n=t.blocks.map(a=>a.name);if(n.length>0&&e.push(`changed ${Ui(n)}`),t.other.length>0){const a=t.other.length===1?"file":"files";e.push(`changed ${t.other.length} ${a}`)}if(e.length===0)return"";const o=vh(e);return lh(o.charAt(0).toUpperCase()+o.slice(1))}function qu(t){return t?on(t).length:0}function Vu(t){const e={newPageSections:t.kind==="page"&&t.status==="new"?qu(t.toJson):null,sections:0,settings:!1,fields:0};if(e.newPageSections!==null)return e;for(const s of t.sections){if(s.kind==="settings"){e.settings=!0;continue}t.kind==="page"?e.sections+=1:e.fields+=s.fields.length}return e}const Qo="••••••";function Ys(t){if(Array.isArray(t))return t.map(Ys);if(!t||typeof t!="object")return t;const e=t,s={};for(const[i,r]of Object.entries(e))s[i]=Ys(r);return e.__resolveType===Sd&&"ciphertext"in e&&(s.ciphertext=Qo),wd(e)&&"encrypted"in e&&(s.encrypted=Qo),s}function ea(t){return t.map(e=>({...e,from:Ys(e.from),to:Ys(e.to)}))}function Yu(t){const{changes:e,sides:s,lookup:i}=t,r=[],n=[],o=h=>[...new Set((s?.diagnostics??[]).filter(l=>Io(jc(l.file))===Io(h)).map(l=>l.side))],a=Object.keys(e).sort((h,l)=>h<l?-1:h>l?1:0);for(const h of a){const l=e[h],u=l.kind==="delete"?"removed":l.baseVersion===null?"new":"edited",d=s?.entries[h],_=d?.before??null,m=d?.after??null,f=gh(i,h),p=f??m??_,g=o(h),v={blockKey:h,status:u,filepaths:[],entry:{name:h,version:l.version},...g.length>0?{unreadable:g}:{},fromJson:Ys(_),toJson:Ys(m??(u==="new"?f:null))},C=f?Vs(h,f):null,S=!f&&p?Vs(h,p):null;if(C??S??(!p&&mh(h))){const w=p?Vs(h,p):null;r.push({...v,kind:"page",name:w?.name??zl(h),pagePath:w?.path??null,isSiteApp:!1,sections:u==="edited"?vo(_,m).map(x=>({...x,fields:ea(x.fields)})):[]});continue}const b=ar(h,p??{});n.push({...v,kind:"block",name:b,pagePath:null,isSiteApp:co(h,f??p??{}),sections:u==="edited"?[{name:b,kind:"section",status:"edited",fields:ea(vi(_,m,[]))}].filter(w=>w.fields.length>0):[]})}return{pages:r,blocks:n,other:[],generated:[],count:r.length+n.length}}function ft(t){return t.filepaths[0]??t.blockKey??t.name}function Gu(t,e){return e(t==="new"?"thread.publishPopover.chipNew":t==="removed"?"thread.publishPopover.chipRemoved":"thread.publishPopover.chipEdited")}function Xu(t,e){const s=t.kind==="block"?Ed:Dl;return c.jsx("span",{title:Gu(t.status,e),className:"flex shrink-0",children:c.jsx(s,{className:ie("size-4",t.status==="new"&&"text-brand",t.status==="edited"&&"text-warning",t.status==="removed"&&"text-destructive")})})}function Ju(t,e){return t.kind==="page"?t.pagePath:t.kind!=="block"?null:t.isSiteApp?e("thread.publishPopover.siteConfiguration"):e("thread.publishPopover.globalSection")}function Zu(t,e){const s=Vu(t);if(s.newPageSections!==null)return[s.newPageSections===1?e("thread.publishPopover.newPageSectionOne"):e("thread.publishPopover.newPageSections",{count:s.newPageSections})];const i=[];return s.sections===1?i.push(e("thread.publishPopover.sectionChangedOne")):s.sections>1&&i.push(e("thread.publishPopover.sectionsChanged",{count:s.sections})),s.fields===1?i.push(e("thread.publishPopover.fieldChangedOne")):s.fields>1&&i.push(e("thread.publishPopover.fieldsChanged",{count:s.fields})),s.settings&&i.push(e("thread.publishPopover.pageSettingsChanged")),i}function bh(t){const e=F.c(41),{change:s,bodyPending:i,selected:r,onSelect:n,confirming:o,onConfirmingChange:a,onDiscard:h,isPublishing:l,isDiscarding:u}=t,d=i===void 0?!1:i,_=ge();let m;e[0]!==s||e[1]!==_?(m=Ju(s,_),e[0]=s,e[1]=_,e[2]=m):m=e[2];const f=m;let p;if(e[3]!==d||e[4]!==s||e[5]!==o||e[6]!==f||e[7]!==u||e[8]!==l||e[9]!==a||e[10]!==h||e[11]!==n||e[12]!==r||e[13]!==_){const g=Zu(s,_),v=d&&g.length===0&&s.status==="edited",C=r&&"border-foreground/30 bg-accent hover:bg-accent";let S;e[15]!==C?(S=ie("cursor-pointer transition-colors hover:bg-accent/50",C),e[15]=C,e[16]=S):S=e[16];let b;e[17]!==s?(b=ft(s),e[17]=s,e[18]=b):b=e[18];let w;e[19]!==s||e[20]!==_?(w=Xu(s,_),e[19]=s,e[20]=_,e[21]=w):w=e[21];let x;e[22]!==s.name?(x=c.jsx("span",{className:"truncate text-sm font-medium",children:s.name}),e[22]=s.name,e[23]=x):x=e[23];let D;e[24]!==f?(D=f?c.jsx("span",{className:"truncate text-xs text-muted-foreground",children:f}):null,e[24]=f,e[25]=D):D=e[25];let E;e[26]!==r||e[27]!==x||e[28]!==D?(E=c.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left","aria-pressed":r,children:[x,D]}),e[26]=r,e[27]=x,e[28]=D,e[29]=E):E=e[29];let I;e[30]!==o||e[31]!==u||e[32]!==l||e[33]!==a||e[34]!==h||e[35]!==_?(I=o?c.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground",onClick:B=>{B.stopPropagation(),a(!1)},children:_("thread.publishDialog.cancel")}),c.jsx("button",{type:"button",className:"text-xs font-medium text-destructive disabled:opacity-50",onClick:B=>{B.stopPropagation(),a(!1),h?.()},disabled:u,children:_("thread.publishPopover.discard")})]}):h?c.jsx(Sr,{children:c.jsxs(it,{children:[c.jsx(rt,{asChild:!0,children:c.jsx("button",{type:"button","aria-label":_("thread.publishPopover.discard"),className:"flex size-6 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:bg-accent hover:text-destructive disabled:opacity-50 rounded-lg",onClick:B=>{B.stopPropagation(),a(!0)},disabled:l||u,children:c.jsx(xr,{className:"size-3.5"})})}),c.jsx(nt,{children:_("thread.publishPopover.discard")})]})}):null,e[30]=o,e[31]=u,e[32]=l,e[33]=a,e[34]=h,e[35]=_,e[36]=I):I=e[36];let y;e[37]!==E||e[38]!==I||e[39]!==w?(y=c.jsxs("div",{className:"flex items-center gap-2.5",children:[w,E,I]}),e[37]=E,e[38]=I,e[39]=w,e[40]=y):y=e[40],p=c.jsxs(nh,{className:S,"data-change-id":b,onClick:n,children:[y,g.length>0?c.jsx("div",{className:"mt-1 space-y-0.5 pl-[26px] text-xs text-muted-foreground",children:g.map(Qu)}):v?c.jsx("div",{className:"mt-1 space-y-0.5 pl-[26px]",children:c.jsx(os,{className:"h-4 w-2/3"})}):null]}),e[3]=d,e[4]=s,e[5]=o,e[6]=f,e[7]=u,e[8]=l,e[9]=a,e[10]=h,e[11]=n,e[12]=r,e[13]=_,e[14]=p}else p=e[14];return p}function Qu(t,e){return c.jsx("div",{className:"truncate",children:t},`${e}-${t}`)}function ef(){const t=F.c(4);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={width:-1,height:-1},t[0]=e):e=t[0];const[s,i]=V.useState(e);let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=a=>{if(!a)return;const h=()=>i(u=>u.width===a.clientWidth&&u.height===a.clientHeight?u:{width:a.clientWidth,height:a.clientHeight});h();const l=new ResizeObserver(h);return l.observe(a),()=>l.disconnect()},t[1]=r):r=t[1];const n=r;let o;return t[2]!==s?(o=[s,n],t[2]=s,t[3]=o):o=t[3],o}function tf(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}const sf=[{width:"w-3/4",tone:"ctx"},{width:"w-1/2",tone:"del"},{width:"w-3/5",tone:"add"},{width:"w-2/5",tone:"ctx"},{width:"w-4/5",tone:"add"},{width:"w-1/2",tone:"ctx"}];function ta(t){const e=F.c(10),{height:s}=t,i=ge();let r;e[0]!==s?(r={height:s},e[0]=s,e[1]=r):r=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=sf.map(rf),e[2]=n):n=e[2];let o;e[3]!==i?(o=i("thread.publishDialog.openingComparison"),e[3]=i,e[4]=o):o=e[4];let a;e[5]!==o?(a=c.jsx("div",{className:"flex items-center justify-center pt-1 text-[11px] text-muted-foreground",children:o}),e[5]=o,e[6]=a):a=e[6];let h;return e[7]!==r||e[8]!==a?(h=c.jsxs("div",{style:r,className:"flex w-full flex-col gap-1.5 overflow-hidden px-3 py-2",children:[n,a]}),e[7]=r,e[8]=a,e[9]=h):h=e[9],h}function rf(t,e){return c.jsxs("div",{className:ie("flex items-center gap-2 rounded px-1 py-0.5",t.tone==="del"&&"bg-destructive/5",t.tone==="add"&&"bg-success/5"),children:[c.jsx("div",{className:ie("h-2 w-4 shrink-0 animate-pulse rounded-sm bg-muted",t.tone==="del"&&"bg-destructive/20",t.tone==="add"&&"bg-success/25")}),c.jsx("div",{className:ie("h-2 animate-pulse rounded-sm bg-muted",t.width,t.tone==="del"&&"bg-destructive/20",t.tone==="add"&&"bg-success/25")})]},e)}const Sh={readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12},nf={...Sh,lineNumbersMinChars:3,lineDecorationsWidth:4,folding:!1,glyphMargin:!1,renderOverviewRuler:!1};function of(t){const e=F.c(11),{diff:s,emptyMessage:i,rowClassName:r,onDiscardFile:n,hideFileRows:o,editorHeight:a}=t,h=i===void 0?"No file changes in the working tree":i,l=r===void 0?"px-6":r,u=o===void 0?!1:o,d=a===void 0?"380px":a,[_,m]=V.useState(null),[f,p]=V.useState(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=tf(),e[0]=g):g=e[0];const v=g;if(!s||Object.keys(s.diffs).length===0){let S;return e[1]!==h?(S=c.jsx("div",{className:"flex items-center justify-center py-10 text-sm text-muted-foreground",children:h}),e[1]=h,e[2]=S):S=e[2],S}let C;return e[3]!==s.diffs||e[4]!==f||e[5]!==d||e[6]!==_||e[7]!==u||e[8]!==n||e[9]!==l?(C=c.jsx("div",{className:"divide-y",children:Object.entries(s.diffs).map(S=>{const[b,w]=S,{from:x,to:D}=w,E=_===b,I=x===null,y=D===null,B=b.startsWith("/")?b.slice(1):b,R=B.lastIndexOf("/"),k=R>=0?B.slice(R+1):B,A=R>=0?B.slice(0,R):null,M=zd(b),P=I?"bg-success":y?"bg-destructive":"bg-warning";return u?c.jsx("div",{children:c.jsx(Uo,{original:x??"",modified:D??"",language:M,theme:v,height:d,loading:c.jsx(ta,{height:d}),options:nf})},b):c.jsxs("div",{children:[c.jsxs("div",{className:ie("flex items-center gap-3 py-3 hover:bg-muted/30",l),children:[c.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:()=>m(E?null:b),children:c.jsx(ll,{className:ie("h-3.5 w-3.5 transition-transform",E&&"rotate-90")})}),c.jsx("div",{className:ie("h-2.5 w-2.5 shrink-0 rounded-full",P)}),c.jsx(Dl,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:k}),A&&c.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:A}),n?c.jsxs(Ci,{children:[c.jsx(yi,{asChild:!0,children:c.jsx("button",{type:"button",className:"flex h-6 w-6 shrink-0 items-center justify-center text-muted-foreground hover:bg-accent hover:text-foreground rounded-lg",children:c.jsx(Ec,{className:"h-3.5 w-3.5"})})}),c.jsx(xi,{align:"end",children:c.jsx(Ts,{className:"text-destructive focus:text-destructive",onSelect:()=>p(b),children:"Discard changes"})})]}):null]}),f===b&&n?c.jsxs("div",{className:ie("flex items-center justify-between gap-3 border-t bg-destructive/5 py-2.5",l),children:[c.jsxs("span",{className:"text-xs text-destructive",children:["Discard all changes to"," ",c.jsx("span",{className:"font-medium",children:k}),"? This cannot be undone."]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[c.jsx(_e,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>p(null),children:"Cancel"}),c.jsx(_e,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:()=>{p(null),n(b)},children:"Discard"})]})]}):null,E&&c.jsx("div",{className:"border-t",children:c.jsx(Uo,{original:x??"",modified:D??"",language:M,theme:v,height:d,loading:c.jsx(ta,{height:d}),options:Sh})})]},b)})}),e[3]=s.diffs,e[4]=f,e[5]=d,e[6]=_,e[7]=u,e[8]=n,e[9]=l,e[10]=C):C=e[10],C}function af(t){if(t.kind!=="block"||t.isSiteApp||!t.blockKey)return null;const e=(t.toJson??t.fromJson)?.__resolveType;return typeof e=="string"&&yd(e)?t.blockKey:null}function lf(t){return t.kind!=="page"?!0:!t.pagePath||pi(t.pagePath).length>0}function hf(t,e){try{return $d(t,xd,e)}catch{return null}}function cf(t,e){if(t.kind!=="page")return"/";const s=t.pagePath;if(!s)return"";if(pi(s).length===0)return s;if(e?.path!==s)return"";const i=Wl(s,e.params);return pi(i).length===0?i:""}function df(t,e){const s=e.trim();if(!s||pi(s).length>0)return null;try{const i=new URL(t),r=new URL(s.startsWith("/")?s:`/${s}`,i);return r.origin===i.origin?r:null}catch{return null}}function uf(t,e){if(!e)return null;if(e.kind==="pointer")return Zl(t.toString(),e.pointer);try{return new URL(`${t.pathname}${t.search}`,e.previewUrl).href}catch{return null}}function ff(t,e,s){return e===null?!1:t!=="other"||s?.kind==="sandbox"}const _f=["split","before","after","code"];function mf(t){return _f.includes(t)}const pf={desktop:1280,mobile:412};function gf(t,e){const s=(n,o)=>t.unreadable?.includes(o)?e:n?`${JSON.stringify(n,null,2)}
10
10
  `:null,i=t.status==="new"?null:s(t.fromJson,"before"),r=t.status==="removed"?null:s(t.toJson,"after");return i===null&&r===null?{diffs:{}}:t.status==="edited"&&(i===null||r===null)?{diffs:{}}:{diffs:{[Fc(t.entry.name)]:{from:i,to:r}}}}function wh(t){const e=F.c(89),{change:s,diff:i,bodyPending:r,previewServerUrl:n,draft:o,lastPage:a}=t,h=ge();let l;e[0]!==s.kind||e[1]!==o||e[2]!==n?(l=ff(s.kind,n,o),e[0]=s.kind,e[1]=o,e[2]=n,e[3]=l):l=e[3];const u=l,[d,_]=V.useState(null),m=u?d??"split":"code",[f,p]=V.useState("desktop"),[g,v]=V.useState(null);let C,S,b,w,x,D;if(e[4]!==s||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==g){S=g??cf(s,a),w=af(s);let se;e[15]!==s?(se=lf(s),e[15]=s,e[16]=se):se=e[16],b=se,D=n?w?hf(n,w):df(n,S):null,C=D?Zl(D.toString(),Ud):null,x=D?uf(D,o):null,e[4]=s,e[5]=o,e[6]=a,e[7]=n,e[8]=g,e[9]=C,e[10]=S,e[11]=b,e[12]=w,e[13]=x,e[14]=D}else C=e[9],S=e[10],b=e[11],w=e[12],x=e[13],D=e[14];const E=x;let I;e[17]!==s||e[18]!==i?.diffs||e[19]!==h?(I=s.entry?gf(s,h("thread.publishCompare.sideUnreadable")):{diffs:Object.fromEntries(s.filepaths.flatMap(se=>{const ce=i?.diffs[se];return ce?[[se,ce]]:[]}))},e[17]=s,e[18]=i?.diffs,e[19]=h,e[20]=I):I=e[20];const y=I;let B;e[21]!==y.diffs?(B=Object.keys(y.diffs),e[21]=y.diffs,e[22]=B):B=e[22];const R=B.length>0;let k;e[23]!==s.kind||e[24]!==s.pagePath||e[25]!==w||e[26]!==h?(k=w!==null?null:s.kind!=="page"?h("thread.publishCompare.globalHint"):s.pagePath&&pi(s.pagePath).length>0?h("thread.publishCompare.dynamicHint",{template:s.pagePath}):null,e[23]=s.kind,e[24]=s.pagePath,e[25]=w,e[26]=h,e[27]=k):k=e[27];const A=k;let M;e[28]!==C||e[29]!==s.kind||e[30]!==s.status||e[31]!==f||e[32]!==h?(M=s.status==="new"&&s.kind!=="other"?c.jsx(ra,{icon:c.jsx(oo,{className:"size-5 text-brand"}),title:h("thread.publishCompare.newTitle"),description:h("thread.publishCompare.newDescription")}):c.jsx(na,{url:C,device:f,title:h("thread.publishCompare.before"),missing:h("thread.publishCompare.enterPath")}),e[28]=C,e[29]=s.kind,e[30]=s.status,e[31]=f,e[32]=h,e[33]=M):M=e[33];const P=M;let T;e[34]!==E||e[35]!==s.kind||e[36]!==s.status||e[37]!==f||e[38]!==h||e[39]!==D?(T=s.status==="removed"&&s.kind!=="other"?c.jsx(ra,{icon:c.jsx(xr,{className:"size-5 text-destructive"}),title:h("thread.publishCompare.removedTitle"),description:h("thread.publishCompare.removedDescription")}):c.jsx(na,{url:E,device:f,title:h("thread.publishCompare.after"),missing:h(D?"thread.publishCompare.draftUnavailable":"thread.publishCompare.enterPath")}),e[34]=E,e[35]=s.kind,e[36]=s.status,e[37]=f,e[38]=h,e[39]=D,e[40]=T):T=e[40];const N=T;let z;e[41]===Symbol.for("react.memo_cache_sentinel")?(z=se=>{mf(se)&&_(se)},e[41]=z):z=e[41];let H;e[42]!==u||e[43]!==h?(H=u?c.jsxs(c.Fragment,{children:[c.jsx(Rs,{value:"split",className:"px-3 text-xs",children:h("thread.publishCompare.sideBySide")}),c.jsx(Rs,{value:"before",className:"px-3 text-xs",children:h("thread.publishCompare.before")}),c.jsx(Rs,{value:"after",className:"px-3 text-xs",children:h("thread.publishCompare.after")})]}):null,e[42]=u,e[43]=h,e[44]=H):H=e[44];let W;e[45]!==h?(W=h("thread.publishCompare.code"),e[45]=h,e[46]=W):W=e[46];let ee;e[47]!==W?(ee=c.jsx(Rs,{value:"code",className:"px-3 text-xs",children:W}),e[47]=W,e[48]=ee):ee=e[48];let $;e[49]!==ee||e[50]!==H?($=c.jsxs(Rl,{className:"h-8 w-auto",variant:"pill",children:[H,ee]}),e[49]=ee,e[50]=H,e[51]=$):$=e[51];let K;e[52]!==$||e[53]!==m?(K=c.jsx(Bl,{value:m,onValueChange:z,children:$}),e[52]=$,e[53]=m,e[54]=K):K=e[54];let Z;e[55]!==E||e[56]!==u||e[57]!==s.pagePath||e[58]!==f||e[59]!==S||e[60]!==b||e[61]!==w||e[62]!==h||e[63]!==m?(Z=u&&m!=="code"?c.jsxs(c.Fragment,{children:[w?null:b?c.jsx(Rc,{value:S,onChange:se=>v(se.target.value),placeholder:s.pagePath??"/","aria-label":h("thread.publishCompare.pathLabel"),className:"h-8 w-56 font-mono text-xs"}):c.jsx("span",{className:"max-w-56 truncate px-1 font-mono text-xs text-muted-foreground",children:S}),c.jsxs("div",{className:"flex items-center rounded-lg border p-0.5",children:[c.jsx(sa,{active:f==="desktop",label:h("thread.publishCompare.desktop"),onClick:()=>p("desktop"),children:c.jsx(Wd,{className:"size-3.5"})}),c.jsx(sa,{active:f==="mobile",label:h("thread.publishCompare.mobile"),onClick:()=>p("mobile"),children:c.jsx(td,{className:"size-3.5"})})]}),E?c.jsxs("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[c.jsx(Bc,{className:"size-3.5"}),h("thread.publishCompare.openDraft")]}):null]}):null,e[55]=E,e[56]=u,e[57]=s.pagePath,e[58]=f,e[59]=S,e[60]=b,e[61]=w,e[62]=h,e[63]=m,e[64]=Z):Z=e[64];let G;e[65]!==K||e[66]!==Z?(G=c.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b bg-background px-4 py-2.5 max-md:pr-12",children:[K,Z]}),e[65]=K,e[66]=Z,e[67]=G):G=e[67];let q;e[68]!==u||e[69]!==A||e[70]!==m?(q=A&&u&&m!=="code"?c.jsx("p",{className:"border-b bg-background px-4 py-1.5 text-[11px] text-muted-foreground",children:A}):null,e[68]=u,e[69]=A,e[70]=m,e[71]=q):q=e[71];let te;e[72]!==r||e[73]!==R||e[74]!==y||e[75]!==h||e[76]!==m?(te=m==="code"?c.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto bg-background [scrollbar-width:thin]",children:R?c.jsx(of,{diff:y,hideFileRows:!0,editorHeight:"70vh"}):r?c.jsx(os,{className:"m-4 h-64 rounded"}):c.jsx("p",{className:"px-4 py-6 text-xs text-muted-foreground",children:h("thread.publishPopover.detailsUnavailable")})}):null,e[72]=r,e[73]=R,e[74]=y,e[75]=h,e[76]=m,e[77]=te):te=e[77];let X;e[78]!==N||e[79]!==P||e[80]!==u||e[81]!==h||e[82]!==m?(X=u?c.jsxs("div",{className:ie("flex min-h-0 flex-1 gap-3 p-3",m==="code"&&"hidden"),children:[c.jsx(ia,{label:h("thread.publishCompare.before"),hidden:m==="after",children:P}),c.jsx(ia,{label:h("thread.publishCompare.after"),highlight:!0,hidden:m==="before",children:N})]}):null,e[78]=N,e[79]=P,e[80]=u,e[81]=h,e[82]=m,e[83]=X):X=e[83];let J;return e[84]!==G||e[85]!==q||e[86]!==te||e[87]!==X?(J=c.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/40",children:[G,q,te,X]}),e[84]=G,e[85]=q,e[86]=te,e[87]=X,e[88]=J):J=e[88],J}function sa(t){const e=F.c(8),{active:s,label:i,onClick:r,children:n}=t,o=s&&"bg-accent text-foreground";let a;e[0]!==o?(a=ie("flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",o),e[0]=o,e[1]=a):a=e[1];let h;return e[2]!==s||e[3]!==n||e[4]!==i||e[5]!==r||e[6]!==a?(h=c.jsx("button",{type:"button","aria-label":i,"aria-pressed":s,title:i,onClick:r,className:a,children:n}),e[2]=s,e[3]=n,e[4]=i,e[5]=r,e[6]=a,e[7]=h):h=e[7],h}function ia(t){const e=F.c(18),{label:s,highlight:i,hidden:r,children:n}=t,o=i===void 0?!1:i,h=(r===void 0?!1:r)&&"hidden";let l;e[0]!==h?(l=ie("flex min-h-0 min-w-0 flex-1 flex-col gap-1.5",h),e[0]=h,e[1]=l):l=e[1];const u=o&&"bg-brand";let d;e[2]!==u?(d=ie("size-1.5 rounded-full bg-muted-foreground/50",u),e[2]=u,e[3]=d):d=e[3];let _;e[4]!==d?(_=c.jsx("span",{className:d}),e[4]=d,e[5]=_):_=e[5];let m;e[6]!==s||e[7]!==_?(m=c.jsxs("div",{className:"flex items-center gap-1.5 px-0.5 text-[11px] font-medium tracking-wider text-muted-foreground uppercase",children:[_,s]}),e[6]=s,e[7]=_,e[8]=m):m=e[8];const f=o&&"border-brand/60";let p;e[9]!==f?(p=ie("relative min-h-0 flex-1 overflow-hidden rounded-lg border bg-background",f),e[9]=f,e[10]=p):p=e[10];let g;e[11]!==n||e[12]!==p?(g=c.jsx("div",{className:p,children:n}),e[11]=n,e[12]=p,e[13]=g):g=e[13];let v;return e[14]!==g||e[15]!==l||e[16]!==m?(v=c.jsxs("div",{className:l,children:[m,g]}),e[14]=g,e[15]=l,e[16]=m,e[17]=v):v=e[17],v}function ra(t){const e=F.c(10),{icon:s,title:i,description:r}=t;let n;e[0]!==s?(n=c.jsx("div",{className:"mb-1",children:s}),e[0]=s,e[1]=n):n=e[1];let o;e[2]!==i?(o=c.jsx("p",{className:"text-sm font-medium",children:i}),e[2]=i,e[3]=o):o=e[3];let a;e[4]!==r?(a=c.jsx("p",{className:"text-xs text-muted-foreground",children:r}),e[4]=r,e[5]=a):a=e[5];let h;return e[6]!==n||e[7]!==o||e[8]!==a?(h=c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 px-6 text-center",children:[n,o,a]}),e[6]=n,e[7]=o,e[8]=a,e[9]=h):h=e[9],h}function na(t){const e=F.c(24),{url:s,device:i,title:r,missing:n}=t,[o,a]=ef(),[h,l]=V.useState(null);if(!s){let x;return e[0]!==n?(x=c.jsx("p",{className:"flex h-full items-center justify-center px-6 text-center text-xs text-muted-foreground",children:n}),e[0]=n,e[1]=x):x=e[1],x}let u;e[2]!==i||e[3]!==s?(u=Kd(s,i),e[2]=i,e[3]=s,e[4]=u):u=e[4];const d=u,_=pf[i],m=o.width>0?Math.min(o.width/_,1):1,f=o.width>0?Math.max((o.width-_*m)/2,0):0;let p;e[5]!==d?(p=()=>l(d),e[5]=d,e[6]=p):p=e[6];const g=o.height>0?o.height/m:"100%",v=`scale(${m})`;let C;e[7]!==_||e[8]!==f||e[9]!==g||e[10]!==v?(C={left:f,width:_,height:g,transform:v,transformOrigin:"top left"},e[7]=_,e[8]=f,e[9]=g,e[10]=v,e[11]=C):C=e[11];let S;e[12]!==d||e[13]!==p||e[14]!==C||e[15]!==r?(S=c.jsx("iframe",{src:d,title:r,sandbox:"allow-scripts allow-same-origin",onLoad:p,className:"absolute top-0 border-0 bg-white",style:C},d),e[12]=d,e[13]=p,e[14]=C,e[15]=r,e[16]=S):S=e[16];let b;e[17]!==h||e[18]!==d?(b=h!==d?c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/60",children:c.jsx(_i,{className:"size-5 motion-reduce:animate-none"})}):null,e[17]=h,e[18]=d,e[19]=b):b=e[19];let w;return e[20]!==a||e[21]!==S||e[22]!==b?(w=c.jsxs("div",{ref:a,className:"absolute inset-0",children:[S,b]}),e[20]=a,e[21]=S,e[22]=b,e[23]=w):w=e[23],w}const vf=/^Co-authored-by:\s*([^<\r\n]+?)(?:\s*<[^>\r\n]*>)?\s*$/im;function bf(t){if(!t)return null;const e=vf.exec(t)?.[1]?.trim();return e||null}function Sf(t){return/\[bot\]$/i.test(t)||/-bot$/i.test(t)}function wf(t){const e=bf(t.body);if(e)return e;const s=t.author.trim();return!s||Sf(s)?null:s}function yh(t){const e=F.c(9),s=ge(),i=br();let r;e[0]!==t.branch||e[1]!==t.orgSlug||e[2]!==t.virtualMcpId?(r={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch},e[0]=t.branch,e[1]=t.orgSlug,e[2]=t.virtualMcpId,e[3]=r):r=e[3];const n=Ql(r);let o;return e[4]!==t||e[5]!==n||e[6]!==i||e[7]!==s?(o=async(a,h,l)=>{try{await zc(n,{blockKeys:h.map(xf),write:()=>Wc(a.client,h)}),Je.success(l)}catch(u){const d=u;if($c(d)){Je.info(s("siteEditor.discard.changedMeanwhile")),await t.refresh().catch(yf);return}a.source==="local"&&Uc(d)&&i.resetQueries({queryKey:Js.contentBackend(t.orgSlug,t.virtualMcpId,"local")}),Je.error(s("siteEditor.discard.failed"),{description:Xn(s,or(d))})}},e[4]=t,e[5]=n,e[6]=i,e[7]=s,e[8]=o):o=e[8],o}function yf(){}function xf(t){return t.name}function Cf(t){const{mode:e,target:s,note:i,allPaths:r,destinationHost:n,publishLockRef:o,onOpenChange:a,refresh:h,onPullRequestChanged:l,onPublished:u,hosted:d=!1,authorName:_,protocol:m}=t,f=ge(),p=br(),[g,v]=V.useState(!1),[C,S]=V.useState(),[b,w]=V.useState(null),x=()=>Tu(i,d?_?f("siteEditor.publish.defaultNote",{name:_}):f("siteEditor.publish.defaultNoteAnonymous"):f("thread.publishDialog.changesFrom",{branch:s.headBranch})),D=async P=>{try{await P?.()}catch{}},E=Ql({orgSlug:s.orgSlug,virtualMcpId:s.virtualMcpId,branch:s.branch}),I=async()=>{try{await Ir(E,{kind:"publish",refreshOnError:!0,write:()=>Xd(s)}),Oo(f)}catch(P){Jd(f,P,()=>{I()})}},y=async P=>{Gd(f,P,()=>{I()}),a(!1),await D(u)},B=async()=>{o.current=!0,v(!0),S(void 0),w(null);try{const P=await Ir(E,{kind:"publish",reread:!0,refreshOnError:!0,write:()=>qd(s,x().message)});await y(P)}catch(P){P instanceof Vd&&P.code===ld&&Hc(p,s.orgSlug,s.virtualMcpId);const T=Yd(f,P);S(T.message),w(T.detail)}finally{o.current=!1,v(!1)}},R=async()=>{o.current=!0,v(!0),S(void 0),w(null);try{await Lu(s,x(),f),Oo(f,n),a(!1),await Promise.all([D(l),D(u)])}catch(P){const T=Jo(P,f);S(T.headMoved?T.message:f("siteEditor.publish.failed")),w(T.headMoved?null:[T.pullRequest?`#${T.pullRequest.number} ${T.pullRequest.htmlUrl}`:null,or(P)].filter(Boolean).join(`
11
11
  `)||null),T.pullRequest&&await D(l),T.headMoved&&await h()}finally{o.current=!1,v(!1)}},k=async()=>{o.current=!0,v(!0),S(void 0),w(null);try{const P=await Iu(s,x());Ou(P,f),a(!1),await l?.()}catch(P){const T=Jo(P,f);S(T.message||f("thread.publishDialog.failedSubmitForReview")),T.headMoved&&await h()}finally{o.current=!1,v(!1)}},A=yh({orgSlug:s.orgSlug,virtualMcpId:s.virtualMcpId,branch:s.branch,refresh:h}),M=async(P,T)=>{try{await Ir(E,{kind:"discard",reread:!0,write:()=>Ad({orgSlug:s.orgSlug,virtualMcpId:s.virtualMcpId,branch:s.branch,threadId:s.threadId},P)}),Je.success(T),await h()}catch(N){Je.error(f("siteEditor.discard.failed"),{description:Xn(f,or(N))})}};return{isPublishing:g,publishError:C,publishErrorDetail:b,submit:e==="review"?k:d?B:R,discardChange:P=>{const T=f("thread.publishPopover.discarded",{name:P.name});return m&&P.entry?A(m.backend,[P.entry],T):M(P.filepaths,T)},discardAll:async()=>{const P=f("thread.publishDialog.allChangesDiscarded");if(m){if(m.entries.length===0)return;await A(m.backend,m.entries,P);return}r.length!==0&&await M(r,P)}}}function kf(t,e,s,i,r,n){return["cms-publish-bodies",t,e,s,i,r,n]}const Pf=6e4;function Ef(t,e){return e?null:t.files.map(s=>`${s.index}${s.working_dir} ${s.path}`).sort().join(`
12
- `)}function Rf(t,e,s){const i=F.c(6);let r;i[0]!==s||i[1]!==t||i[2]!==e?(r=Js.decofile(`${t}/${e}/${s}`),i[0]=s,i[1]=t,i[2]=e,i[3]=r):r=i[3];let n;i[4]!==r?(n={queryKey:r,queryFn:cl},i[4]=r,i[5]=n):n=i[5];const{data:o}=Is(n);return o}function xh(t){const{orgSlug:e,virtualMcpId:s,branch:i,threadId:r,baseBranch:n,fastPreview:o,recoverSandbox:a}=t,h={orgSlug:e,virtualMcpId:s,branch:i,threadId:r},l=o?{fastPreview:!0}:void 0,u=V.useRef(null),d=async w=>{try{return await w()}catch(x){if(!a||!Gl(x))throw x;return u.current??=a(),await u.current,w()}},_=hl({...Yl(h),queryFn:()=>d(()=>fo(h))}),m=_.data,f=m.changedFiles??null,p=m.headSha??null,g=f?f.length>0:Md(m)||Td(m),v=Is({queryKey:kf(e,s,i,n,p,Ef(m,o)),queryFn:()=>d(()=>ql(h,m,n,l)),enabled:g,staleTime:o?Pf:0,gcTime:o?void 0:0,throwOnError:(w,x)=>!f&&x.state.data===void 0}),C=Rf(e,s,i),S=v.data??null,b=f?ph({files:f,lookup:C,diff:S}):zu(S);return{status:m,summary:b,allPaths:f?f.map(w=>w.path):Object.keys(S?.diffs??{}),discardablePaths:o?null:new Set(m.files.map(w=>w.path)),changedFilesTotal:m.changedFilesTotal??b.count,changedFilesTruncated:m.changedFilesTruncated??!1,headSha:p,diff:S,bodiesPending:g&&v.isPending,bodiesFailed:v.isError,cardsPending:!f&&g&&v.isPending,refresh:()=>Promise.all([_.refetch(),o?null:v.refetch()])}}function Bf(t){const e=F.c(4);let s;e[0]!==t?(s=Js.decofile(t),e[0]=t,e[1]=s):s=e[1];let i;e[2]!==s?(i={queryKey:s,queryFn:cl},e[2]=s,e[3]=i):i=e[3];const{data:r}=Is(i);return r}function bo(t){const e=F.c(24),{backend:s,cacheKey:i}=t,r=br();let n;e[0]!==i?(n=Js.contentChanges(i),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==s||e[3]!==i||e[4]!==r?(o=()=>qc(r,s.client,i),e[2]=s,e[3]=i,e[4]=r,e[5]=o):o=e[5];let a;e[6]!==n||e[7]!==o?(a={queryKey:n,queryFn:o,staleTime:0},e[6]=n,e[7]=o,e[8]=a):a=e[8];const h=hl(a),l=h.data,u=Kc(s,i,l),d=Bf(i),_=u.data??null;let m;e[9]!==l.changes||e[10]!==d||e[11]!==_?(m=Yu({changes:l.changes,sides:_,lookup:d}),e[9]=l.changes,e[10]=d,e[11]=_,e[12]=m):m=e[12];const f=m;let p;e[13]!==l.changes?(p=Object.entries(l.changes).map(Df),e[13]=l.changes,e[14]=p):p=e[14];const g=f.count>0&&u.isPending;let v;e[15]!==h?(v=()=>h.refetch(),e[15]=h,e[16]=v):v=e[16];let C;return e[17]!==l||e[18]!==u.isError||e[19]!==f||e[20]!==p||e[21]!==g||e[22]!==v?(C={changes:l,summary:f,entries:p,sidesPending:g,sidesFailed:u.isError,refresh:v},e[17]=l,e[18]=u.isError,e[19]=f,e[20]=p,e[21]=g,e[22]=v,e[23]=C):C=e[23],C}function Df(t){const[e,s]=t;return{name:e,version:s.version}}function Af(t){return["smart-review-verdict",t.orgSlug,t.virtualMcpId,t.branch,t.threadId,t.fastPreview?"fast-preview-upstream":"sandbox",t.signature,t.language]}function Mf(t){const e=F.c(27),{orgSlug:s,virtualMcpId:i,branch:r,threadId:n,fastPreview:o,status:a,diff:h,enabled:l}=t,[u]=dl(),{language:d}=u;let _,m,f;if(e[0]!==r||e[1]!==h||e[2]!==l||e[3]!==o||e[4]!==d||e[5]!==s||e[6]!==a||e[7]!==n||e[8]!==i){const w=h?Er(h):"";_=l&&!!r&&!!a&&!!h&&w!=="",f=Is,m=Af({orgSlug:s,virtualMcpId:i,branch:r,threadId:n,fastPreview:o,signature:w,language:d}),e[0]=r,e[1]=h,e[2]=l,e[3]=o,e[4]=d,e[5]=s,e[6]=a,e[7]=n,e[8]=i,e[9]=_,e[10]=m,e[11]=f}else _=e[9],m=e[10],f=e[11];let p;e[12]!==r||e[13]!==h||e[14]!==d||e[15]!==s||e[16]!==a||e[17]!==n||e[18]!==i?(p=()=>Nd({orgSlug:s,virtualMcpId:i,branch:r,threadId:n},{status:a,diff:h,language:d}),e[12]=r,e[13]=h,e[14]=d,e[15]=s,e[16]=a,e[17]=n,e[18]=i,e[19]=p):p=e[19];let g;e[20]!==_||e[21]!==m||e[22]!==p?(g={queryKey:m,queryFn:p,enabled:_,staleTime:1/0,gcTime:6e5,retry:Tf},e[20]=_,e[21]=m,e[22]=p,e[23]=g):g=e[23];const v=f(g),C=v.data??null,S=_&&v.isFetching&&!v.data;let b;return e[24]!==C||e[25]!==S?(b={verdict:C,loading:S},e[24]=C,e[25]=S,e[26]=b):b=e[26],b}function Tf(t,e){return!Gl(e)&&t<1}function Ch(t){const e=F.c(30),{orgSlug:s,virtualMcpId:i,branch:r,threadId:n,fastPreview:o,status:a,diff:h,policy:l,judgeEnabled:u,paths:d}=t,_=u===void 0?!0:u,m=d===void 0?null:d;let f;e[0]!==h||e[1]!==_||e[2]!==l?(f=_&&Ld(h,l),e[0]=h,e[1]=_,e[2]=l,e[3]=f):f=e[3];const p=f;let g;e[4]!==r||e[5]!==h||e[6]!==o||e[7]!==p||e[8]!==s||e[9]!==a||e[10]!==n||e[11]!==i?(g={orgSlug:s,virtualMcpId:i,branch:r,threadId:n,fastPreview:o,status:a,diff:h,enabled:p},e[4]=r,e[5]=h,e[6]=o,e[7]=p,e[8]=s,e[9]=a,e[10]=n,e[11]=i,e[12]=g):g=e[12];const{verdict:v,loading:C}=Mf(g);if(!h&&m){let x;e[13]!==m||e[14]!==l?(x=Id(m,l),e[13]=m,e[14]=l,e[15]=x):x=e[15];let D;return e[16]!==x?(D={gate:x,ready:!1},e[16]=x,e[17]=D):D=e[17],D}if(!h){let x;return e[18]===Symbol.for("react.memo_cache_sentinel")?(x={gate:{allowed:!0,reason:null},ready:!1},e[18]=x):x=e[18],x}if(!p){let x;e[19]!==h||e[20]!==l?(x=Od(h,l),e[19]=h,e[20]=l,e[21]=x):x=e[21];let D;return e[22]!==x?(D={gate:x,ready:!0},e[22]=x,e[23]=D):D=e[23],D}let S;e[24]!==C||e[25]!==v?(S=jd(v,C),e[24]=C,e[25]=v,e[26]=S):S=e[26];const b=!C;let w;return e[27]!==S||e[28]!==b?(w={gate:S,ready:b},e[27]=S,e[28]=b,e[29]=w):w=e[29],w}function kh(t){const e=F.c(16),s=V.useRef(!1),i=ge();let r;e[0]!==t?(r=d=>{!d&&s.current||t.onOpenChange(d)},e[0]=t,e[1]=r):r=e[1];const n=r;let o;e[2]!==t.mode||e[3]!==i?(o=t.mode==="review"?i("thread.publishPopover.submitForReview"):i("thread.publishPopover.publish"),e[2]=t.mode,e[3]=i,e[4]=o):o=e[4];let a;e[5]!==o?(a=c.jsx(fl,{className:"sr-only",children:o}),e[5]=o,e[6]=a):a=e[6];let h;e[7]!==t?(h=t.open?c.jsx(Of,{...t,publishLockRef:s}):null,e[7]=t,e[8]=h):h=e[8];let l;e[9]!==a||e[10]!==h?(l=c.jsxs(_l,{"aria-describedby":void 0,className:"flex h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-none flex-col md:flex-row md:h-[calc(100dvh-6rem)] md:w-[calc(100vw-6rem)] gap-0 overflow-hidden p-0 sm:max-w-none",closeButtonClassName:"top-3.5 right-3.5",children:[a,h]}),e[9]=a,e[10]=h,e[11]=l):l=e[11];let u;return e[12]!==n||e[13]!==t.open||e[14]!==l?(u=c.jsx(ul,{open:t.open,onOpenChange:n,children:l}),e[12]=n,e[13]=t.open,e[14]=l,e[15]=u):u=e[15],u}function Nf(t){return["main","master"].includes(t.trim().toLowerCase())}const Lf=4,Gs="flex h-[45%] min-h-0 min-w-0 shrink-0 md:h-auto md:flex-1";function Pi(t){const e=F.c(5),{list:s,pane:i}=t;let r;e[0]!==s?(r=c.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col max-md:border-t md:w-[380px] md:flex-none md:shrink-0 md:border-l md:[&>[data-publish-state]>:first-child]:pr-12",children:s}),e[0]=s,e[1]=r):r=e[1];let n;return e[2]!==i||e[3]!==r?(n=c.jsxs(c.Fragment,{children:[i,r]}),e[2]=i,e[3]=r,e[4]=n):n=e[4],n}function So(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx("div",{className:ie(Gs,"bg-muted/40 p-3"),children:c.jsx(os,{className:"h-full w-full rounded-lg"})}),t[0]=e):e=t[0],e}function wo(t){const e=F.c(11),{mode:s,title:i,subLine:r,trailing:n}=t,o=s==="review"?yr:sd;let a;e[0]!==o?(a=c.jsx(o,{className:"size-4 shrink-0 text-muted-foreground"}),e[0]=o,e[1]=a):a=e[1];let h;e[2]!==a||e[3]!==i||e[4]!==n?(h=c.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a,i,n]}),e[2]=a,e[3]=i,e[4]=n,e[5]=h):h=e[5];let l;e[6]!==r?(l=r?c.jsx("div",{className:"pl-6 text-xs text-muted-foreground",children:r}):null,e[6]=r,e[7]=l):l=e[7];let u;return e[8]!==h||e[9]!==l?(u=c.jsxs(c.Fragment,{children:[h,l]}),e[8]=h,e[9]=l,e[10]=u):u=e[10],u}function yo(t){const e=F.c(9),{draftPreviewUrl:s,t:i}=t;let r;e[0]!==s?(r=()=>{s&&window.open(s,"_blank","noopener,noreferrer")},e[0]=s,e[1]=r):r=e[1];const n=!s;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(Kl,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==i?(a=i("thread.publishPopover.preview"),e[3]=i,e[4]=a):a=e[4];let h;return e[5]!==r||e[6]!==n||e[7]!==a?(h=c.jsxs(_e,{type:"button",variant:"outline",onClick:r,disabled:n,children:[o,a]}),e[5]=r,e[6]=n,e[7]=a,e[8]=h):h=e[8],h}function Ph(t){const e=F.c(21),{mode:s,draftPreviewUrl:i}=t,r=ge();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=c.jsx(So,{}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(os,{className:"h-3.5 w-48"}),e[1]=o):o=e[1];let a;e[2]!==s?(a=c.jsx(wo,{mode:s,title:o}),e[2]=s,e[3]=a):a=e[3];let h,l;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(gi,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Ds,{}),c.jsx(Ds,{}),c.jsx(Ds,{})]})}),l=c.jsxs(c.Fragment,{children:[c.jsx(os,{className:"h-3 w-20"}),c.jsx(os,{className:"h-14 w-full rounded-lg"})]}),e[4]=h,e[5]=l):(h=e[4],l=e[5]);let u;e[6]!==i||e[7]!==r?(u=c.jsx(yo,{draftPreviewUrl:i,t:r}),e[6]=i,e[7]=r,e[8]=u):u=e[8];const d=s==="review"?"default":"brand";let _;e[9]!==s||e[10]!==r?(_=r(s==="review"?"thread.publishPopover.submitForReview":"thread.publishPopover.publish"),e[9]=s,e[10]=r,e[11]=_):_=e[11];let m;e[12]!==d||e[13]!==_?(m=c.jsx(_e,{type:"button",variant:d,className:"flex-1",disabled:!0,children:_}),e[12]=d,e[13]=_,e[14]=m):m=e[14];let f;e[15]!==u||e[16]!==m?(f=c.jsxs("div",{className:"flex gap-2",children:[u,m]}),e[15]=u,e[16]=m,e[17]=f):f=e[17];let p;return e[18]!==f||e[19]!==a?(p=c.jsx(Pi,{pane:n,list:c.jsx(Br,{state:"loading",header:a,body:h,note:l,footer:f})}),e[18]=f,e[19]=a,e[20]=p):p=e[20],p}function If(t){const e=F.c(26),{mode:s,draftPreviewUrl:i,message:r,onRetry:n}=t,o=ge();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx("div",{className:ie(Gs,"bg-muted/40")}),e[0]=a):a=e[0];let h;e[1]!==o?(h=o("thread.publishPopover.loadFailed"),e[1]=o,e[2]=h):h=e[2];let l;e[3]!==h?(l=c.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=l):l=e[4];let u;e[5]!==s||e[6]!==l?(u=c.jsx(wo,{mode:s,title:l}),e[5]=s,e[6]=l,e[7]=u):u=e[7];let d;e[8]!==r?(d=c.jsx("p",{className:"px-4 py-6 text-xs text-destructive",children:r}),e[8]=r,e[9]=d):d=e[9];let _;e[10]!==i||e[11]!==o?(_=c.jsx(yo,{draftPreviewUrl:i,t:o}),e[10]=i,e[11]=o,e[12]=_):_=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=c.jsx(mi,{className:"size-4"}),e[13]=m):m=e[13];let f;e[14]!==o?(f=o("thread.publishPopover.retry"),e[14]=o,e[15]=f):f=e[15];let p;e[16]!==n||e[17]!==f?(p=c.jsxs(_e,{type:"button",variant:"outline",className:"flex-1",onClick:n,children:[m,f]}),e[16]=n,e[17]=f,e[18]=p):p=e[18];let g;e[19]!==_||e[20]!==p?(g=c.jsxs("div",{className:"flex gap-2",children:[_,p]}),e[19]=_,e[20]=p,e[21]=g):g=e[21];let v;return e[22]!==g||e[23]!==u||e[24]!==d?(v=c.jsx(Pi,{pane:a,list:c.jsx(Br,{state:"ready",header:u,body:d,footer:g})}),e[22]=g,e[23]=u,e[24]=d,e[25]=v):v=e[25],v}function Of(t){const e=F.c(3),s=t.mode??"publish";let i;return e[0]!==s||e[1]!==t?(i=c.jsx(ml,{children:r=>{const{reset:n}=r;return c.jsx(pl,{fallback:o=>{const{error:a,resetError:h}=o;return c.jsx(If,{mode:s,draftPreviewUrl:t.draftPreviewUrl,message:a?.message??"",onRetry:()=>{n(),h()}})},children:c.jsx(V.Suspense,{fallback:c.jsx(Ph,{mode:s,draftPreviewUrl:t.draftPreviewUrl}),children:c.jsx(jf,{...t})})})}}),e[0]=s,e[1]=t,e[2]=i):i=e[2],i}function jf(t){const e=F.c(13),s=Zs(t.virtualMcpId,t.branch);let i;e[0]!==t.branch||e[1]!==t.orgSlug||e[2]!==t.virtualMcpId?(i={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch},e[0]=t.branch,e[1]=t.orgSlug,e[2]=t.virtualMcpId,e[3]=i):i=e[3];const r=Jn(i);if(s.kind==="protocol"&&r){let o;return e[4]!==s||e[5]!==r||e[6]!==t?(o=s.source==="sandbox"?c.jsx(zf,{...t,backend:s,cacheKey:r}):c.jsx(Hf,{...t,backend:s,cacheKey:r}),e[4]=s,e[5]=r,e[6]=t,e[7]=o):o=e[7],o}if(s.kind!=="legacy"){const o=t.mode??"publish";let a;return e[8]!==t.draftPreviewUrl||e[9]!==o?(a=c.jsx(Ph,{mode:o,draftPreviewUrl:t.draftPreviewUrl}),e[8]=t.draftPreviewUrl,e[9]=o,e[10]=a):a=e[10],a}let n;return e[11]!==t?(n=c.jsx(Ff,{...t}),e[11]=t,e[12]=n):n=e[12],n}function Ff(t){const e=F.c(52),s=xs()?.taskId??null;let i;e[0]!==t.baseBranch||e[1]!==t.branch||e[2]!==t.fastPreview||e[3]!==t.orgSlug||e[4]!==t.recoverSandbox||e[5]!==t.virtualMcpId||e[6]!==s?(i={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch,threadId:s,baseBranch:t.baseBranch,fastPreview:t.fastPreview,recoverSandbox:t.recoverSandbox},e[0]=t.baseBranch,e[1]=t.branch,e[2]=t.fastPreview,e[3]=t.orgSlug,e[4]=t.recoverSandbox,e[5]=t.virtualMcpId,e[6]=s,e[7]=i):i=e[7];const r=xh(i),n=t.mode!=="review";let o;e[8]!==t.branch||e[9]!==t.fastPreview||e[10]!==t.orgSlug||e[11]!==t.publishPolicy||e[12]!==t.virtualMcpId||e[13]!==r.allPaths||e[14]!==r.diff||e[15]!==r.status||e[16]!==n||e[17]!==s?(o={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch,threadId:s,fastPreview:t.fastPreview,status:r.status,diff:r.diff,paths:r.allPaths,policy:t.publishPolicy,judgeEnabled:n},e[8]=t.branch,e[9]=t.fastPreview,e[10]=t.orgSlug,e[11]=t.publishPolicy,e[12]=t.virtualMcpId,e[13]=r.allPaths,e[14]=r.diff,e[15]=r.status,e[16]=n,e[17]=s,e[18]=o):o=e[18];const{gate:a}=Ch(o),h=r.discardablePaths;let l;e[19]!==h?(l=C=>h===null||C.every(S=>h.has(S)),e[19]=h,e[20]=l):l=e[20];const u=l;let d;e[21]!==u?(d=C=>u(C.filepaths),e[21]=u,e[22]=d):d=e[22];let _;e[23]!==u||e[24]!==r.allPaths||e[25]!==r.changedFilesTruncated?(_=!r.changedFilesTruncated&&u(r.allPaths),e[23]=u,e[24]=r.allPaths,e[25]=r.changedFilesTruncated,e[26]=_):_=e[26];let m;e[27]!==t.branch||e[28]!==r.status?(m=mo(r.status)??t.branch,e[27]=t.branch,e[28]=r.status,e[29]=m):m=e[29];const f=r.headSha??void 0;let p;e[30]!==t.fastPreview||e[31]!==r.diff?(p=!t.fastPreview&&r.diff?{expectedDiffSignature:Er(r.diff)}:{},e[30]=t.fastPreview,e[31]=r.diff,e[32]=p):p=e[32];let g;e[33]!==a||e[34]!==r.allPaths||e[35]!==r.bodiesFailed||e[36]!==r.bodiesPending||e[37]!==r.cardsPending||e[38]!==r.changedFilesTotal||e[39]!==r.changedFilesTruncated||e[40]!==r.diff||e[41]!==r.refresh||e[42]!==r.summary||e[43]!==d||e[44]!==_||e[45]!==m||e[46]!==f||e[47]!==p?(g={summary:r.summary,allPaths:r.allPaths,canDiscard:d,canDiscardAll:_,changedFilesTotal:r.changedFilesTotal,changedFilesTruncated:r.changedFilesTruncated,diff:r.diff,bodiesPending:r.bodiesPending,bodiesFailed:r.bodiesFailed,cardsPending:r.cardsPending,refresh:r.refresh,gate:a,headBranch:m,expectedHeadSha:f,...p,hosted:!1,otherWork:!1},e[33]=a,e[34]=r.allPaths,e[35]=r.bodiesFailed,e[36]=r.bodiesPending,e[37]=r.cardsPending,e[38]=r.changedFilesTotal,e[39]=r.changedFilesTruncated,e[40]=r.diff,e[41]=r.refresh,e[42]=r.summary,e[43]=d,e[44]=_,e[45]=m,e[46]=f,e[47]=p,e[48]=g):g=e[48];let v;return e[49]!==t||e[50]!==g?(v=c.jsx(xo,{...t,source:g}),e[49]=t,e[50]=g,e[51]=v):v=e[51],v}function Eh(t,e){return{summary:t.summary,allPaths:[],canDiscard:()=>!0,canDiscardAll:!0,changedFilesTotal:t.summary.count,changedFilesTruncated:!1,diff:null,bodiesPending:t.sidesPending,bodiesFailed:t.sidesFailed,cardsPending:!1,refresh:t.refresh,protocol:{backend:e,entries:t.entries}}}function Hf(t){const e=F.c(18);let s,i,r;e[0]!==t?({backend:s,cacheKey:i,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let n;e[4]!==s||e[5]!==i?(n={backend:s,cacheKey:i},e[4]=s,e[5]=i,e[6]=n):n=e[6];const o=bo(n);let a;e[7]!==s||e[8]!==o?(a=Eh(o,s),e[7]=s,e[8]=o,e[9]=a):a=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h={allowed:!0,reason:null},e[10]=h):h=e[10];const l=s.source==="github";let u;e[11]!==r.branch||e[12]!==a||e[13]!==l?(u={...a,gate:h,headBranch:r.branch,hosted:l,otherWork:!1},e[11]=r.branch,e[12]=a,e[13]=l,e[14]=u):u=e[14];let d;return e[15]!==r||e[16]!==u?(d=c.jsx(xo,{...r,source:u}),e[15]=r,e[16]=u,e[17]=d):d=e[17],d}function zf(t){const e=F.c(53);let s,i,r;e[0]!==t?({backend:s,cacheKey:i,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);const n=xs()?.taskId??null;let o;e[4]!==s||e[5]!==i?(o={backend:s,cacheKey:i},e[4]=s,e[5]=i,e[6]=o):o=e[6];const a=bo(o);let h;e[7]!==r.baseBranch||e[8]!==r.branch||e[9]!==r.fastPreview||e[10]!==r.orgSlug||e[11]!==r.recoverSandbox||e[12]!==r.virtualMcpId||e[13]!==n?(h={orgSlug:r.orgSlug,virtualMcpId:r.virtualMcpId,branch:r.branch,threadId:n,baseBranch:r.baseBranch,fastPreview:r.fastPreview,recoverSandbox:r.recoverSandbox},e[7]=r.baseBranch,e[8]=r.branch,e[9]=r.fastPreview,e[10]=r.orgSlug,e[11]=r.recoverSandbox,e[12]=r.virtualMcpId,e[13]=n,e[14]=h):h=e[14];const l=xh(h),u=r.mode!=="review";let d;e[15]!==l.allPaths||e[16]!==l.diff||e[17]!==l.status||e[18]!==r.branch||e[19]!==r.fastPreview||e[20]!==r.orgSlug||e[21]!==r.publishPolicy||e[22]!==r.virtualMcpId||e[23]!==u||e[24]!==n?(d={orgSlug:r.orgSlug,virtualMcpId:r.virtualMcpId,branch:r.branch,threadId:n,fastPreview:r.fastPreview,status:l.status,diff:l.diff,paths:l.allPaths,policy:r.publishPolicy,judgeEnabled:u},e[15]=l.allPaths,e[16]=l.diff,e[17]=l.status,e[18]=r.branch,e[19]=r.fastPreview,e[20]=r.orgSlug,e[21]=r.publishPolicy,e[22]=r.virtualMcpId,e[23]=u,e[24]=n,e[25]=d):d=e[25];const{gate:_}=Ch(d);let m;if(e[26]!==l.allPaths||e[27]!==a){let x;e[29]!==a?(x=D=>{const E=go(D);return E===null?!_o(D):!Object.hasOwn(a.changes.changes,E)},e[29]=a,e[30]=x):x=e[30],m=l.allPaths.some(x),e[26]=l.allPaths,e[27]=a,e[28]=m}else m=e[28];const f=m;let p;e[31]!==s||e[32]!==a?(p=Eh(a,s),e[31]=s,e[32]=a,e[33]=p):p=e[33];let g;e[34]!==l||e[35]!==a?(g=()=>Promise.all([a.refresh(),l.refresh()]),e[34]=l,e[35]=a,e[36]=g):g=e[36];let v;e[37]!==l.status||e[38]!==r.branch?(v=mo(l.status)??r.branch,e[37]=l.status,e[38]=r.branch,e[39]=v):v=e[39];const C=l.headSha??void 0;let S;e[40]!==l.diff?(S=l.diff?{expectedDiffSignature:Er(l.diff)}:{},e[40]=l.diff,e[41]=S):S=e[41];let b;e[42]!==_||e[43]!==f||e[44]!==S||e[45]!==p||e[46]!==g||e[47]!==v||e[48]!==C?(b={...p,refresh:g,gate:_,headBranch:v,expectedHeadSha:C,...S,hosted:!1,otherWork:f},e[42]=_,e[43]=f,e[44]=S,e[45]=p,e[46]=g,e[47]=v,e[48]=C,e[49]=b):b=e[49];let w;return e[50]!==r||e[51]!==b?(w=c.jsx(xo,{...r,source:b}),e[50]=r,e[51]=b,e[52]=w):w=e[52],w}function xo(t){const e=F.c(119),{source:s,publishLockRef:i,onOpenChange:r,mode:n,fastPreview:o,orgSlug:a,virtualMcpId:h,branch:l,baseBranch:u,repoTarget:d,owner:_,repo:m,draftPreviewUrl:f,destinationHost:p,previewServerUrl:g,compareDraft:v,lastPublishedPr:C,onRequestApproval:S,openPullRequest:b,onPullRequestChanged:w,onPublished:x}=t,D=n===void 0?"publish":n,E=C===void 0?null:C,I=b===void 0?null:b,y=ge(),[B]=dl(),{language:R}=B,k=xs()?.taskId??null,{data:A}=vr.useSession(),M=vl(bl(a,h,l)),{summary:P,allPaths:T,changedFilesTotal:N,changedFilesTruncated:z,diff:H,bodiesPending:W,bodiesFailed:ee,cardsPending:$,refresh:K,gate:Z,hosted:G,otherWork:q}=s,[te,X]=V.useState(null),[J,se]=V.useState(!1),[ce,U]=V.useState(null);let ve;e[0]===Symbol.for("react.memo_cache_sentinel")?(ve=[],e[0]=ve):ve=e[0];const[me,Me]=V.useState(ve);let Ve;e[1]===Symbol.for("react.memo_cache_sentinel")?(Ve=he=>{U(he),Me(we=>[he,...we.filter(Se=>Se!==he)])},e[1]=Ve):Ve=e[1];const le=Ve,[ae,re]=V.useState(null);let lt;e[2]!==te||e[3]!==P?(lt=$u(te,Ku(P)),e[2]=te,e[3]=P,e[4]=lt):lt=e[4];const be=lt,_t=[...P.pages,...P.blocks,...P.other],ht=_t.find(he=>ft(he)===ce)??_t[0]??null,mt=ht?ft(ht):null,Oe=[...new Set([...mt?[mt]:[],...me,..._t.map(ft)])].filter(he=>_t.some(we=>ft(we)===he)).slice(0,Lf),fe=D==="review"&&!G,pt=$?"loading":W?"manifest":"ready",gt=I?.state==="open",vt=s.headBranch,bt=A?.user;let je;e[5]!==bt?(je=rh(bt),e[5]=bt,e[6]=je):je=e[6];let Ze;e[7]!==s.expectedDiffSignature?(Ze=s.expectedDiffSignature?{expectedDiffSignature:s.expectedDiffSignature}:{},e[7]=s.expectedDiffSignature,e[8]=Ze):Ze=e[8];let Ye;e[9]!==u||e[10]!==l||e[11]!==o||e[12]!==a||e[13]!==_||e[14]!==m||e[15]!==d||e[16]!==s.expectedHeadSha||e[17]!==s.headBranch||e[18]!==je||e[19]!==Ze||e[20]!==k||e[21]!==h?(Ye={orgSlug:a,virtualMcpId:h,branch:l,threadId:k,fastPreview:o,baseBranch:u,target:d,owner:_,repo:m,headBranch:vt,coAuthor:je,expectedHeadSha:s.expectedHeadSha,...Ze},e[9]=u,e[10]=l,e[11]=o,e[12]=a,e[13]=_,e[14]=m,e[15]=d,e[16]=s.expectedHeadSha,e[17]=s.headBranch,e[18]=je,e[19]=Ze,e[20]=k,e[21]=h,e[22]=Ye):Ye=e[22];const ct=Ye,Te=fe?"review":"publish",Rt=A?.user?.name;let Y;e[23]!==T||e[24]!==p||e[25]!==G||e[26]!==be||e[27]!==r||e[28]!==x||e[29]!==w||e[30]!==i||e[31]!==K||e[32]!==s.protocol||e[33]!==Te||e[34]!==Rt||e[35]!==ct?(Y={mode:Te,target:ct,note:be,allPaths:T,destinationHost:p,publishLockRef:i,onOpenChange:r,refresh:K,onPullRequestChanged:w,onPublished:x,hosted:G,authorName:Rt,protocol:s.protocol},e[23]=T,e[24]=p,e[25]=G,e[26]=be,e[27]=r,e[28]=x,e[29]=w,e[30]=i,e[31]=K,e[32]=s.protocol,e[33]=Te,e[34]=Rt,e[35]=ct,e[36]=Y):Y=e[36];const{isPublishing:de,publishError:ke,publishErrorDetail:De,submit:Qe,discardChange:ps,discardAll:Kt}=Cf(Y),dt=wl(a,h).phase==="saving",Bt=P.count>0||q,qt=!de&&Bt&&(fe||Z.allowed);let Ot;e[37]!==u||e[38]!==fe||e[39]!==P.count||e[40]!==y?(Ot=fe?P.count===0?y("thread.publishPopover.submitForReview"):P.count===1?y("thread.publishPopover.submitOneForReview"):y("thread.publishPopover.submitCountForReview",{count:P.count}):P.count===0?y("thread.publishPopover.publish"):Nf(u)?P.count===1?y("thread.publishPopover.publishOneInProduction"):y("thread.publishPopover.publishCountInProduction",{count:P.count}):P.count===1?y("thread.publishPopover.publishOne"):y("thread.publishPopover.publishCount",{count:P.count}),e[37]=u,e[38]=fe,e[39]=P.count,e[40]=y,e[41]=Ot):Ot=e[41];const Vt=Ot;let St;e:{if(fe&&gt){let Se;e[42]!==I.number||e[43]!==y?(Se=y("thread.publishPopover.updatesPullRequest",{number:I.number}),e[42]=I.number,e[43]=y,e[44]=Se):Se=e[44],St=Se;break e}const he=E;if(!he?.mergedAt){St=null;break e}let we;if(e[45]!==R||e[46]!==he||e[47]!==y){const Se=Pd(new Date(he.mergedAt),R),Ne=wf(he);we=Ne?y("thread.publishPopover.lastPublishedBy",{when:Se,name:Ne}):y("thread.publishPopover.lastPublished",{when:Se}),e[45]=R,e[46]=he,e[47]=y,e[48]=we}else we=e[48];St=we}const Yt=St;let Dt;e[49]!==fe||e[50]!==P.count||e[51]!==y?(Dt=fe?y("thread.publishPopover.submitForReview"):P.count===1?y("thread.publishPopover.publishOne"):P.count>1?y("thread.publishPopover.publishCount",{count:P.count}):y("thread.publishPopover.publish"),e[49]=fe,e[50]=P.count,e[51]=y,e[52]=Dt):Dt=e[52];const Gt=Dt,Xt=(he,we)=>we.length===0?null:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("div",{className:"px-0.5 text-[11px] font-medium tracking-wider text-muted-foreground uppercase",children:he}),we.map(Se=>{const Ne=ft(Se);return c.jsx(bh,{change:Se,bodyPending:W,selected:ht!==null&&ft(ht)===Ne,onSelect:()=>le(Ne),confirming:ae===Ne,onConfirmingChange:et=>re(et?Ne:null),onDiscard:s.canDiscard(Se)?()=>{ps(Se)}:void 0,isPublishing:de,isDiscarding:dt},Ne)})]});let At;e:{if(fe||!Bt){At=null;break e}if(Z.pending){let Ne;e[53]===Symbol.for("react.memo_cache_sentinel")?(Ne=c.jsx(_i,{className:"size-3.5 motion-reduce:animate-none"}),e[53]=Ne):Ne=e[53];let et;e[54]!==y?(et=y("thread.publishPopover.reviewing"),e[54]=y,e[55]=et):et=e[55];let $t;e[56]!==et?($t=c.jsxs("div",{className:"flex items-center gap-2 border-t px-4 py-2.5 text-xs text-muted-foreground",children:[Ne,et]}),e[56]=et,e[57]=$t):$t=e[57],At=$t;break e}if(Z.allowed){At=null;break e}let he;e[58]===Symbol.for("react.memo_cache_sentinel")?(he=c.jsx(gl,{className:"mt-0.5 size-3.5 shrink-0"}),e[58]=he):he=e[58];let we;e[59]!==Z.reason||e[60]!==y?(we=Z.reason??y("thread.publishPopover.needsReviewGeneric"),e[59]=Z.reason,e[60]=y,e[61]=we):we=e[61];let Se;e[62]!==we?(Se=c.jsxs("div",{className:"flex items-start gap-2 border-t px-4 py-2.5 text-xs text-warning",children:[he,c.jsx("span",{children:we})]}),e[62]=we,e[63]=Se):Se=e[63],At=Se}const Jt=At;let jt;e[64]!==Kt||e[65]!==J||e[66]!==dt||e[67]!==de||e[68]!==s.canDiscardAll||e[69]!==P.count||e[70]!==y?(jt=P.count<=1||!s.canDiscardAll?null:c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"ml-auto shrink-0 text-[11px] text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>se(!0),disabled:de||dt,children:y("thread.publishPopover.discardAll")}),c.jsx(no,{open:J,onOpenChange:se,children:c.jsxs(ro,{children:[c.jsxs(eo,{children:[c.jsx(Zn,{children:y("thread.publishPopover.discardAllTitle")}),c.jsx(Qn,{children:y("thread.publishPopover.discardAllConfirm")})]}),c.jsxs(io,{children:[c.jsx(to,{children:y("thread.publishDialog.cancel")}),c.jsx(so,{onClick:()=>{Kt()},disabled:dt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:y("thread.publishPopover.discardAll")})]})]})})]}),e[64]=Kt,e[65]=J,e[66]=dt,e[67]=de,e[68]=s.canDiscardAll,e[69]=P.count,e[70]=y,e[71]=jt):jt=e[71];const Zt=jt,Qt=$?c.jsx(gi,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Ds,{}),c.jsx(Ds,{})]})}):P.count===0&&q?c.jsx("p",{className:"px-4 py-6 text-xs text-muted-foreground",children:y("thread.publishPopover.onlyOtherWork")}):P.count===0?c.jsxs("div",{className:"flex flex-col items-center gap-1 py-10 text-center",children:[c.jsx(uo,{className:"mb-1 size-5 text-success"}),c.jsx("p",{className:"text-sm font-medium",children:y(fe?"thread.publishPopover.nothingToSubmit":"thread.publishPopover.everythingLive")}),c.jsx("p",{className:"text-xs text-muted-foreground",children:y(fe?"thread.publishPopover.submitEmptyHint":"thread.publishPopover.emptyHint")})]}):c.jsxs(gi,{children:[z?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.showingFirst",{shown:P.count,total:N})}):null,Xt(y("thread.publishPopover.pagesGroup"),P.pages),Xt(y("thread.publishPopover.blocksGroup"),P.blocks),Xt(y("thread.publishPopover.otherGroup"),P.other),ee?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.detailsUnavailable")}):null,q?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.alsoOtherWork")}):null]}),es=$?c.jsx(So,{}):ht?c.jsx("div",{className:ie(Gs,"relative"),children:_t.filter(he=>Oe.includes(ft(he))).map(he=>c.jsx("div",{className:ie("absolute inset-0 flex",ft(he)!==mt&&"hidden"),children:c.jsx(wh,{change:he,diff:H,bodyPending:W,previewServerUrl:g,draft:v,lastPage:M})},ft(he)))}):c.jsx("div",{className:ie(Gs,"bg-muted/40")});let wt;e[72]!==Vt?(wt=c.jsx("span",{className:"truncate",children:Vt}),e[72]=Vt,e[73]=wt):wt=e[73];let Ft;e[74]!==Zt||e[75]!==D||e[76]!==Yt||e[77]!==wt?(Ft=c.jsx(wo,{mode:D,title:wt,subLine:Yt,trailing:Zt}),e[74]=Zt,e[75]=D,e[76]=Yt,e[77]=wt,e[78]=Ft):Ft=e[78];let yt;e[79]!==de||e[80]!==fe||e[81]!==be||e[82]!==P.count||e[83]!==y?(yt=P.count===0?null:c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-[13px] font-medium",children:y(fe?"thread.publishPopover.reviewNote":"thread.publishPopover.versionNote")}),c.jsx(kd,{value:be,onChange:he=>X(he.target.value),placeholder:y(fe?"thread.publishPopover.reviewNotePlaceholder":"thread.publishPopover.versionNotePlaceholder"),rows:2,maxLength:hr,className:"resize-none text-[13px]",disabled:de})]}),e[79]=de,e[80]=fe,e[81]=be,e[82]=P.count,e[83]=y,e[84]=yt):yt=e[84];let xt;e[85]!==f||e[86]!==y?(xt=c.jsx(yo,{draftPreviewUrl:f,t:y}),e[85]=f,e[86]=y,e[87]=xt):xt=e[87];let Ct;e[88]!==qt||e[89]!==Z||e[90]!==Bt||e[91]!==G||e[92]!==de||e[93]!==fe||e[94]!==S||e[95]!==Gt||e[96]!==Qe||e[97]!==y?(Ct=!fe&&!G&&Bt&&!Z.allowed&&!Z.pending?c.jsx(_e,{type:"button",className:"flex-1",onClick:S,disabled:de,children:y("thread.publishPopover.requestApproval")}):c.jsxs(_e,{type:"button",variant:fe?"default":"brand",className:"flex-1",onClick:()=>{Qe()},disabled:!qt,children:[de?c.jsx(_i,{className:"size-4 motion-reduce:animate-none"}):null,de?y(fe?"thread.publishPopover.submitting":"thread.publishPopover.publishing"):Gt]}),e[88]=qt,e[89]=Z,e[90]=Bt,e[91]=G,e[92]=de,e[93]=fe,e[94]=S,e[95]=Gt,e[96]=Qe,e[97]=y,e[98]=Ct):Ct=e[98];let Ht;e[99]!==xt||e[100]!==Ct?(Ht=c.jsxs("div",{className:"flex gap-2",children:[xt,Ct]}),e[99]=xt,e[100]=Ct,e[101]=Ht):Ht=e[101];let ts;e[102]!==ke||e[103]!==De||e[104]!==y?(ts=ke?c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-destructive",children:ke}),De?c.jsx(Vc,{label:y("siteEditor.details"),detail:De}):null]}):null,e[102]=ke,e[103]=De,e[104]=y,e[105]=ts):ts=e[105];let ss;e[106]!==Ht||e[107]!==ts?(ss=c.jsxs(c.Fragment,{children:[Ht,ts]}),e[106]=Ht,e[107]=ts,e[108]=ss):ss=e[108];let zt;e[109]!==Qt||e[110]!==Jt||e[111]!==pt||e[112]!==Ft||e[113]!==yt||e[114]!==ss?(zt=c.jsx(Br,{state:pt,header:Ft,body:Qt,note:yt,gate:Jt,footer:ss}),e[109]=Qt,e[110]=Jt,e[111]=pt,e[112]=Ft,e[113]=yt,e[114]=ss,e[115]=zt):zt=e[115];let Wt;return e[116]!==es||e[117]!==zt?(Wt=c.jsx(Pi,{pane:es,list:zt}),e[116]=es,e[117]=zt,e[118]=Wt):Wt=e[118],Wt}function Wf(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return Cd[t].short}const $f=new Set(["failure","timed_out","cancelled","action_required"]);function Rh(t){return t.status==="completed"&&$f.has(t.conclusion)}function Co(t){return t.status==="queued"||t.status==="in_progress"}function Qi(t){return t.isPending&&t.fetchStatus!=="idle"}function Uf(t){return{key:"view-change-request",label:t("thread.cmsActions.viewOnProvider"),action:"open-pr-page"}}function cs(t,e,s){return e?[...t,Uf(s)]:t}function Ut(t,e,s){return e.kind!=="ready"||e.behindBase<=0?t:[...t,{key:"get-latest",label:s("thread.cmsActions.getLatest"),action:"sync",tooltip:s("thread.cmsActions.getLatestTooltip")}]}function oa(t){return{key:"submit-for-review",label:t("thread.headerActions.submitForReview"),action:"create-pr"}}function Ki(t,e,s){if(e.filter(Co).length===0)return t;const r=e.filter(n=>n.status==="completed").length;return{...t,tooltip:s("thread.cmsActions.checksRunning",{done:r,total:e.length})}}function Kf(t){const{lifecycle:e,branch:s,pr:i,checks:r,reviews:n,loading:o,t:a}=t;if(o)return{label:a("thread.headerActions.loading"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.loadingBranchTooltip"),menu:[]};switch(e.phase){case"idle":return{label:t.claimPhase&&Wf(t.claimPhase.kind)||a("thread.headerActions.startingSandbox"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.waitingForDaemonTooltip"),menu:[]};case"cloning":return{label:a("thread.headerActions.cloningRepo"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.cloningRepoTooltip"),menu:[]};case"clone-failed":return{label:a("thread.headerActions.cloneFailed"),disabled:!0,variant:"outline",tooltip:e.error||a("thread.headerActions.cloneFailedDefaultTooltip"),menu:[]};case"checking-out":return{label:a("thread.headerActions.switchingTo",{branch:e.to}),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.checkingOutTooltip",{branch:e.to}),menu:[]};case"installing":return{label:a("thread.headerActions.installingPackages"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.installingPackagesTooltip"),menu:[]};case"starting":{if(!(s.kind==="ready"&&(s.workingTreeDirty||s.aheadOfBase>0||s.unpushed>0))&&!t.noReviewableDiff)return{label:a("thread.headerActions.startingApp"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.startingAppTooltip"),menu:[]};break}}if(s.kind!=="ready")return{label:a("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.waitingForBranchTooltip"),menu:[]};const h=s,l=h.unpushed>0&&!(i&&h.headSha&&i.headSha&&h.headSha===i.headSha);if(t.noReviewableDiff&&!i)return{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.branchInSyncTooltip",{base:h.base}),menu:Ut([],h,a)};if(h.workingTreeDirty||l)return{label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:Ut(cs([oa(a)],i,a),h,a)};if(eh("no local work — checking PR/sync state",{workingTreeDirty:h.workingTreeDirty,unpushed:h.unpushed,aheadOfBase:h.aheadOfBase,behindBase:h.behindBase,branch:h.branch,base:h.base,prMerged:i?.merged??null,prState:i?.state??null}),i?.merged)return!!h.headSha&&!!i.headSha&&h.headSha!==i.headSha?{label:a("thread.headerActions.continue"),action:"create-pr",variant:"special",tooltip:a("thread.headerActions.openNewPrTooltip"),menu:Ut(cs([],i,a),h,a)}:{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.prMergedTooltip",{prNumber:String(i.number),base:i.base}),menu:Ut(cs([],i,a),h,a)};if(h.aheadOfBase>0){if(i&&i.state==="closed"&&!i.merged)return{label:a("thread.headerActions.reopenPr"),action:"reopen",variant:"default",tooltip:a("thread.headerActions.reopenPrTooltip",{prNumber:String(i.number)}),menu:Ut(cs([],i,a),h,a)};if(!i)return{label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:Ut([oa(a)],h,a)};if((n?.mergeableState??"unknown")==="dirty")return{label:a("thread.cmsActions.getLatest"),action:"rebase",variant:"default",tooltip:a("thread.cmsActions.getLatestTooltip"),menu:[{key:"resolve-on-provider",label:a("thread.cmsActions.resolveOnProvider"),action:"open-pr-page"}]};const d=r.filter(Co).length,_=r.filter(Rh).map(f=>f.name);if(d===0&&_.length>0)return{label:a("thread.headerActions.fixChecks"),action:"fix-checks",variant:"default",tooltip:a("thread.headerActions.failingChecksTooltip",{checks:_.join(", ")}),meta:{failingChecks:_},menu:Ut(cs([{key:"publish-anyway",label:a("thread.headerActions.publishAnyway"),action:"merge",tooltip:a("thread.headerActions.squashMergeTooltip",{prNumber:String(i.number),base:i.base})}],i,a),h,a)};if(n?.draft)return Ki({label:a("thread.headerActions.markReady"),action:"mark-ready",variant:"default",tooltip:a("thread.headerActions.markDraftReadyTooltip"),menu:Ut(cs([],i,a),h,a)},r,a);const m=n?.unresolvedConversations??0;return m>0?Ki({label:a("thread.headerActions.addressFeedback"),action:"resolve-comments",variant:"default",tooltip:a("thread.headerActions.unresolvedConversationsTooltip",{count:String(m)}),menu:Ut(cs([],i,a),h,a)},r,a):n?.missingRequiredApprovals?Ki({label:a("thread.cmsActions.waitingForReview"),action:"open-pr-page",variant:"outline",tooltip:a("thread.headerActions.waitingForApprovalsTooltip"),menu:Ut(cs([],i,a),h,a)},r,a):Ki({label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",meta:{publishPolicyOverride:"open"},menu:Ut(cs([{key:"review",label:a("thread.headerActions.review"),action:"review"}],i,a),h,a)},r,a)}return h.behindBase>0?{label:a("thread.cmsActions.getLatest"),action:"sync",variant:"default",tooltip:a("thread.cmsActions.getLatestTooltip"),menu:[]}:{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.branchInSyncTooltip",{base:h.base}),menu:[]}}function aa(t){return{key:"view-change-request",label:t("thread.cmsActions.viewOnProvider"),action:"open-pr"}}function qi(t,e,s){return e.kind!=="ready"||e.behindBase<=0?t:[...t,{key:"get-latest",label:s("thread.cmsActions.getLatest"),action:"get-latest",tooltip:s("thread.cmsActions.getLatestTooltip")}]}function la(t,e,s,i){const r=e.length;if(r===0)return t;if(e.filter(Co).length>0){const a=e.filter(l=>l.status==="completed").length,h=i("thread.cmsActions.checksRunning",{done:a,total:r});return s==="loading"?{...t,loading:!0,tooltip:h}:{...t,tooltip:h}}const o=e.filter(Rh).length;return o>0?{...t,variant:"warning",tooltip:i("thread.cmsActions.checksFailing",{failed:o,total:r})}:t}function qf(t,e){return!!(t?.merged&&t.headSha&&e.kind==="ready"&&!e.workingTreeDirty&&e.headSha===t.headSha)}function Vf(t){return Qi(t.prQuery)?!0:t.pr?.state!=="open"||t.pr.merged?!1:Qi(t.checksQuery)||Qi(t.reviewsQuery)}function Yf(t,e){return t.workingTreeDirty?!0:e!==null?e>0:t.aheadOfBase>0}function Gf(t,e){if(!t)return{branchMeta:{kind:"unknown"},publishableChangeCount:null};const s=Object.keys(t.changes).length;return{branchMeta:{kind:"ready",branch:e,base:t.base.resolvedRef??"main",workingTreeDirty:!1,unpushed:0,aheadOfBase:s,behindBase:0,headSha:t.revision},publishableChangeCount:s}}function Xf(t){return{...t,menu:[]}}function Jf(t){const{branch:e,pr:s,checks:i,reviews:r,publishing:n,saving:o,loading:a,publishableChangeCount:h,t:l}=t;if(e.kind!=="ready"&&t.statusError)return{label:l("thread.cmsActions.retry"),action:"retry-status",variant:"outline",disabled:t.statusRetrying,loading:t.statusRetrying,tooltip:t.statusError,menu:[]};if(a||e.kind!=="ready")return{label:l("thread.headerActions.loading"),variant:"outline",disabled:!0,loading:!0,menu:[]};if(n)return{label:l("thread.cmsActions.publishing"),variant:"outline",disabled:!0,loading:!0,menu:[]};if(t.syncing)return{label:l("thread.cmsActions.gettingLatest"),variant:"outline",disabled:!0,loading:!0,menu:[]};if(o)return{label:l("thread.headerActions.saving"),variant:"outline",disabled:!0,loading:!0,menu:[]};if(s&&s.state==="open"&&!s.merged?s:null){const d=r?.mergeableState??"unknown";return d==="dirty"?{label:l("thread.cmsActions.getLatest"),action:"get-latest",variant:"default",tooltip:l("thread.cmsActions.getLatestTooltip"),menu:[{key:"resolve-on-provider",label:l("thread.cmsActions.resolveOnProvider"),action:"open-pr"}]}:d==="blocked"||r?.draft?la({label:l("thread.cmsActions.waitingForReview"),action:"open-pr",variant:"outline",menu:qi([aa(l)],e,l)},i,"loading",l):la({label:l("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:qi([aa(l)],e,l)},i,"none",l)}return qf(s,e)?{label:l("thread.headerActions.upToDate"),variant:"outline",disabled:!0,menu:qi([],e,l)}:Yf(e,h)?{label:l("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:qi([{key:"request-approval",label:l("thread.headerActions.submitForReview"),action:"request-approval"}],e,l)}:e.behindBase>0?{label:l("thread.cmsActions.getLatest"),action:"get-latest",variant:"default",tooltip:l("thread.cmsActions.getLatestTooltip"),menu:[],autoRun:e.aheadOfBase===0}:{label:l("thread.headerActions.upToDate"),variant:"outline",disabled:!0,menu:[]}}function Zf(t){return t.conflicting===!0?"dirty":t.conflicting===null?"unknown":t.reviewBlocked||t.unresolvedConversations>0?"blocked":"clean"}function Bh(t){const e=F.c(4);let s;e[0]!==t?(s=md(t),e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i={...s,select:Qf},e[2]=s,e[3]=i):i=e[3],Is(i)}function Qf(t){const e=t.changeRequest;return e?{draft:e.draft,mergeableState:Zf(e),unresolvedConversations:e.unresolvedConversations,missingRequiredApprovals:e.reviewBlocked}:null}function ha(t,e){return t==="open-pr"||e==="resolve-on-provider"?c.jsx(Hl,{size:16}):t==="publish"?c.jsx(Al,{className:"size-4"}):t==="get-latest"||t==="retry-status"?c.jsx(mi,{className:"size-4"}):c.jsx(yr,{className:"size-4"})}function e_(t){const e=F.c(70),{virtualMcpId:s}=t,i=ge(),{org:r}=ki(),n=br(),o=Cr(s),{data:a}=vr.useSession(),{deleteRelease:h}=ao(s),{currentBranch:l,setCurrentTaskBranch:u,taskId:d,createTask:_}=Sl();let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={open:!1,mode:"publish"},e[0]=m):m=e[0];const[f,p]=V.useState(m);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=Y=>p({open:!0,mode:Y}),e[1]=g):g=e[1];const v=g,C=Il(o),S=C.status==="attached"||C.status==="public-clone"?C.repo:null,{previewServerUrl:b}=kr(s);let w;if(e[2]!==l||e[3]!==r.slug||e[4]!==s){const Y=l?vl(bl(r.slug,s,l)):null;w=Y?Wl(Y.path,Y.params):"/",e[2]=l,e[3]=r.slug,e[4]=s,e[5]=w}else w=e[5];const x=w;let D;e[6]!==l||e[7]!==x||e[8]!==r.slug||e[9]!==b||e[10]!==s?(D=l?{orgSlug:r.slug,virtualMcpId:s,branch:l,previewServerUrl:b,path:x}:null,e[6]=l,e[7]=x,e[8]=r.slug,e[9]=b,e[10]=s,e[11]=D):D=e[11];const E=vd(D);let I;e[12]!==l||e[13]!==r.slug||e[14]!==s?(I=l?{orgSlug:r.slug,virtualMcpId:s,branch:l}:null,e[12]=l,e[13]=r.slug,e[14]=s,e[15]=I):I=e[15];const y=bd(I),B=Zs(s,l),R=B.kind==="protocol"&&B.source==="github";let k;e[16]!==l||e[17]!==r.slug||e[18]!==s?(k=l?{orgSlug:r.slug,virtualMcpId:s,branch:l}:null,e[16]=l,e[17]=r.slug,e[18]=s,e[19]=k):k=e[19];const A=Jn(k),M=yl(R?B:null,A),P=l??"",T=d??null;let N;e[20]!==r.slug||e[21]!==P||e[22]!==T||e[23]!==s?(N=Yl({orgSlug:r.slug,virtualMcpId:s,branch:P,threadId:T}),e[20]=r.slug,e[21]=P,e[22]=T,e[23]=s,e[24]=N):N=e[24];const z=!!l&&B.kind!=="pending"&&!R;let H;e[25]!==z||e[26]!==N?(H={...N,enabled:z},e[25]=z,e[26]=N,e[27]=H):H=e[27];const W=Is(H),ee=R?null:W.data??null,$=R?Gf(M.data,l??""):null,K=$?$.branchMeta:ee?{kind:"ready",branch:mo(ee)??l??"",base:ee.base??"main",workingTreeDirty:Fd(ee),unpushed:ee.unpushed??0,aheadOfBase:ee.aheadOfBase??0,behindBase:ee.behindBase??0,headSha:ee.headSha??""}:{kind:"unknown"},Z=$?$.publishableChangeCount:ee?.changedFiles?ph({files:ee.changedFiles}).count:null,G=R?M:W,q=(K.kind==="ready"?K.branch:null)??l??null,te=K.kind==="ready"?K.base:"main",X=Ol({orgId:r.id,orgSlug:r.slug,target:Lt(S),owner:S?.owner??"",repo:S?.name??"",branch:q}),J=X.data??null,se=jl({orgId:r.id,orgSlug:r.slug,target:Lt(S),owner:S?.owner??"",repo:S?.name??"",base:te}),ce=Fl({orgId:r.id,orgSlug:r.slug,target:Lt(S),owner:S?.owner??"",repo:S?.name??"",branch:q}),U=Bh({orgId:r.id,orgSlug:r.slug,target:Lt(S),owner:S?.owner??"",repo:S?.name??"",branch:q});let ve;e[28]!==ce||e[29]!==J||e[30]!==X||e[31]!==U?(ve=Vf({pr:J,prQuery:X,checksQuery:ce,reviewsQuery:U}),e[28]=ce,e[29]=J,e[30]=X,e[31]=U,e[32]=ve):ve=e[32];const me=ve;let Me;e[33]!==X?(Me=async()=>{await X.refetch()},e[33]=X,e[34]=Me):Me=e[34];const Ve=Me,le=Lo({mutationFn:async()=>{const Y=l;await u(lo(ho(a?.user))),Y&&Y!==te&&await h(Y)},onError:i_});let ae;e[35]!==r.slug||e[36]!==d||e[37]!==s?(ae=async Y=>(await Vl({orgSlug:r.slug,virtualMcpId:s,branch:Y.branch,threadId:d??null},Y.base),Y),e[35]=r.slug,e[36]=d,e[37]=s,e[38]=ae):ae=e[38];let re;e[39]!==l||e[40]!==r.slug||e[41]!==n||e[42]!==i||e[43]!==d||e[44]!==s?(re=async Y=>{Je.success(i("thread.headerActions.syncedWithBase",{base:Y.base})),await Promise.all([n.invalidateQueries({queryKey:Jl({orgSlug:r.slug,virtualMcpId:s,branch:l??Y.branch,threadId:d??null})}),n.invalidateQueries({queryKey:Js.decofile(`${r.slug}/${s}/${Y.branch}`)})])},e[39]=l,e[40]=r.slug,e[41]=n,e[42]=i,e[43]=d,e[44]=s,e[45]=re):re=e[45];let lt;e[46]!==ae||e[47]!==re?(lt={mutationFn:ae,onSuccess:re,onError:s_},e[46]=ae,e[47]=re,e[48]=lt):lt=e[48];const be=Lo(lt),_t=xl(r.slug,s),ht=le.isPending,mt=Jf({branch:K,pr:J,checks:ce.data??[],reviews:U.data??null,publishing:ht,saving:_t,syncing:be.isPending,statusRetrying:G.isFetching&&!!G.error,statusError:G.error instanceof Error?G.error.message:G.error?String(G.error):null,loading:!!me,publishableChangeCount:Z,t:i}),Oe=R?Xf(mt):mt,fe=Oe.autoRun&&K.kind==="ready"&&S&&b?`${q}@${K.headSha}`:null,pt=V.useRef(null);if(V.useEffect(()=>{!fe||!q||pt.current!==fe&&(pt.current=fe,be.mutate({branch:q,base:te}))},[fe,q,te,be]),C.status==="detached"){let Y;e[49]!==i?(Y=i("thread.headerActions.reconnectGithub"),e[49]=i,e[50]=Y):Y=e[50];let de;e[51]!==Y?(de=c.jsx(rt,{asChild:!0,children:c.jsx("span",{children:c.jsx(_e,{size:"sm",variant:"outline",disabled:!0,children:Y})})}),e[51]=Y,e[52]=de):de=e[52];let ke;e[53]!==i?(ke=i("thread.headerActions.githubConnectionRemoved"),e[53]=i,e[54]=ke):ke=e[54];let De;e[55]!==ke?(De=c.jsx(nt,{children:ke}),e[55]=ke,e[56]=De):De=e[56];let Qe;return e[57]!==de||e[58]!==De?(Qe=c.jsx(Sr,{children:c.jsxs(it,{children:[de,De]})}),e[57]=de,e[58]=De,e[59]=Qe):Qe=e[59],Qe}if(!o)return null;if(!S||!b){const Y=S?"noPreviewServer":"noRepo";let de;e[60]!==l||e[61]!==_?(de=l?()=>{const De=_?.({runtime:"sandbox",branch:l});De&&Dc("coding_session_started",{thread_id:De})}:void 0,e[60]=l,e[61]=_,e[62]=de):de=e[62];let ke;return e[63]!==Y||e[64]!==de?(ke=c.jsx(r_,{reason:Y,onStartCodingSession:de}),e[63]=Y,e[64]=de,e[65]=ke):ke=e[65],ke}if(!l)return null;const gt=Y=>{switch(Y){case"publish":{v("publish");return}case"request-approval":{v("review");return}case"get-latest":{if(!q||be.isPending)return;be.mutate({branch:q,base:te});return}case"retry-status":{G.refetch();return}case"open-pr":{J?.htmlUrl&&window.open(J.htmlUrl,"_blank","noopener,noreferrer");return}}};let vt;e[66]!==gt?(vt=Y=>({key:Y.key,label:Y.label,icon:ha(Y.action,Y.key),...Y.tooltip?{tooltip:Y.tooltip}:{},onSelect:()=>gt(Y.action)}),e[66]=gt,e[67]=vt):vt=e[67];const bt=Oe.menu.map(vt),je=Oe.action,Ze=Oe.label,Ye=Oe.variant,ct=!!Oe.loading;let Te;e[68]!==i?(Te=i("thread.cmsActions.moreActionsAriaLabel"),e[68]=i,e[69]=Te):Te=e[69];const Rt=c.jsx(ih,{size:"sm",label:Ze,variant:Ye,disabled:!!Oe.disabled||!je,loading:ct,...je&&!Oe.loading?{icon:ha(je)}:{},...Oe.tooltip?{tooltip:Oe.tooltip}:{},items:bt,menuAriaLabel:Te,onClick:je?()=>gt(je):void 0});return c.jsxs(c.Fragment,{children:[Rt,l?c.jsx(kh,{open:f.open,mode:f.mode,fastPreview:!0,onOpenChange:Y=>{Y||p(t_)},orgSlug:r.slug,virtualMcpId:s,branch:l,baseBranch:te,repoTarget:Lt(S),owner:S.owner,repo:S.name,publishPolicy:Xl(o?.metadata?.publishPolicy),draftPreviewUrl:E.url,destinationHost:E.host,previewServerUrl:b,compareDraft:y?{kind:"pointer",pointer:y}:null,lastPublishedPr:se.data??null,onRequestApproval:()=>v("review"),openPullRequest:J?.state==="open"?J:null,onPullRequestChanged:Ve,onPublished:()=>le.mutateAsync()}):null]})}function t_(t){return{...t,open:!1}}function s_(t){Je.error(t instanceof Error?t.message:String(t))}function i_(t){console.error("site editor: settling after publish failed",t)}function r_(t){const e=F.c(14),{reason:s,onStartCodingSession:i}=t,r=ge(),n=!i;let o;e[0]!==r?(o=r("sandbox.cmsUnavailable.startCodingSession"),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==o?(a=c.jsx(rt,{asChild:!0,children:c.jsx("span",{children:c.jsx(_e,{size:"sm",variant:"outline",disabled:n,onClick:i,children:o})})}),e[2]=i,e[3]=n,e[4]=o,e[5]=a):a=e[5];let h;e[6]!==s||e[7]!==r?(h=r(s==="noPreviewServer"?"sandbox.cmsUnavailable.noPreviewServer":"sandbox.cmsUnavailable.noRepo"),e[6]=s,e[7]=r,e[8]=h):h=e[8];let l;e[9]!==h?(l=c.jsx(nt,{children:h}),e[9]=h,e[10]=l):l=e[10];let u;return e[11]!==a||e[12]!==l?(u=c.jsx(Sr,{children:c.jsxs(it,{children:[a,l]})}),e[11]=a,e[12]=l,e[13]=u):u=e[13],u}const Os="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 n_(t){return`Reopen PR #${t.prNumber}. ${Os}`}function o_(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${Os}`}function a_(t){return`Sync \`${t.branch}\` with everyone else's work: \`git add -A\`, commit any pending local changes with a concise conventional-commit message (skip if the working tree is clean), \`git pull --rebase\` to bring in anything pushed directly to \`origin/${t.branch}\`, then \`git rebase origin/${t.base}\` to catch up with the base branch. Resolve any conflicts that come up, then push the result (force-with-lease only if the rebase rewrote commits already on the remote). ${Os}`}function l_(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. ${Os}`}function h_(t){return`Mark PR #${t.prNumber} ready for review. ${Os}`}function c_(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. ${Os}`}function d_(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. ${Os}`}function ca(t){switch(t){case"publish":return c.jsx(Al,{className:"size-4"});case"create-pr":case"reopen":return c.jsx(yr,{className:"size-4"});case"rebase":case"sync":return c.jsx(mi,{className:"size-4"});case"fix-checks":return c.jsx(gl,{className:"size-4"});case"mark-ready":return c.jsx(uo,{className:"size-4"});case"resolve-comments":return c.jsx(id,{className:"size-4"});case"merge":return c.jsx(Rd,{className:"size-4"});case"review":return c.jsx(Kl,{className:"size-4"});case"open-pr-page":return c.jsx(Hl,{size:16})}}const da=new Set(["reopen","rebase","fix-checks","mark-ready","resolve-comments","review","sync"]),ua=new Set(["publish","create-pr"]);function u_(t){return{label:t("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:t("thread.headerActions.waitingForSandboxBranchTooltip"),menu:[]}}function f_({virtualMcpId:t}){const e=ge(),{org:s}=ki(),{data:i}=vr.useSession(),r=Cr(t),{deleteRelease:n}=ao(t),{currentBranch:o,setCurrentTaskBranch:a,createTask:h,taskId:l}=Sl(),u=Ic(),{openSidePanel:d}=Gc(),[_,m]=V.useState({open:!1,mode:"publish",policyOverride:null}),f=Zd({connectionId:Ac,orgId:s.id,orgSlug:s.slug}),p=Qd(f),[g,v]=V.useState(!1),C=V.useRef(""),S=Il(r),b=S.status==="attached"||S.status==="public-clone"?S.repo:null,{lifecycle:w,branch:x,phase:D}=Pr(),E={orgSlug:s.slug,virtualMcpId:t,branch:o??"",threadId:l??null},y=Is({queryKey:Jl(E),queryFn:()=>fo(E),enabled:!!o,staleTime:15e3,refetchInterval:ae=>Fr(ae.state.data)?5e3:!1}).data??null,B=x,R=w,k=B.kind==="ready"?B.branch:null,A=o??k??void 0,M=(B.kind==="ready"?B.branch:null)??A??null,P=Ol({orgId:s.id,orgSlug:s.slug,target:Lt(b),owner:b?.owner??"",repo:b?.name??"",branch:M}),T=P.data??null,N=Fl({orgId:s.id,orgSlug:s.slug,target:Lt(b),owner:b?.owner??"",repo:b?.name??"",branch:M}),z=Bh({orgId:s.id,orgSlug:s.slug,target:Lt(b),owner:b?.owner??"",repo:b?.name??"",branch:M}),H=jl({orgId:s.id,orgSlug:s.slug,target:Lt(b),owner:b?.owner??"",repo:b?.name??"",base:B.kind==="ready"?B.base:null}),W=B,ee=Xl(r?.metadata?.publishPolicy),$=xl(s.slug,t),{previewUrl:K}=th(),{previewServerUrl:Z,projectDefault:G}=kr(t);if(S.status==="detached")return c.jsx(m_,{label:e("thread.headerActions.githubConnectionRemoved"),children:c.jsx(_e,{size:"sm",variant:"outline",disabled:!0,children:e("thread.headerActions.reconnectGithub")})});if(!b)return null;const q=M?Kf({lifecycle:R,branch:W,claimPhase:D,pr:T,checks:N.data??[],reviews:z.data??null,noReviewableDiff:Fr(y),loading:Qi(P),t:e}):u_(e),te=JSON.stringify({label:q.label,branchKind:W.kind,workingTreeDirty:W.kind==="ready"?W.workingTreeDirty:null,unpushed:W.kind==="ready"?W.unpushed:null,aheadOfBase:W.kind==="ready"?W.aheadOfBase:null,lifecycle:R.phase,headBranch:M,noReviewableDiff:Fr(y)});C.current!==te&&(C.current=te,eh("header button",{label:q.label,tooltip:q.tooltip,action:q.action,chatBranch:o,sandboxBranch:k,sandboxRouteBranch:A,headBranch:M,branchMeta:B,effectiveBranchMeta:W,lifecyclePhase:R.phase,prNumber:T?.number??null,prState:T?.state??null}));const X=ae=>(d(),u.sendMessage({parts:[{type:"text",text:ae}]})),J=u.isStreaming,se=W.kind==="ready"?W.base:"main",ce=async()=>{await P.refetch()},U=async()=>{const ae=o,re=lo(ho(i?.user));G==="cms"?h({runtime:"cms",branch:re}):await a(re),ae&&ae!==se&&await n(ae)},ve=async ae=>{if(!(!b||g)){v(!0);try{const re=rh(i?.user);await ah(s.slug,Lt(b),{number:ae,coAuthor:re}),Je.success(e("thread.headerActions.publishedPr",{prNumber:String(ae)})),await ce(),await U()}catch(re){Je.error(re instanceof oh?re.detail??Au(re.reason,e):re instanceof Error?re.message:e("thread.headerActions.failedToMergePullRequest"))}finally{v(!1)}}},me=(ae,re)=>m({open:!0,mode:ae,policyOverride:re}),Me=ae=>{if(M)switch(ae){case"publish":me("publish",q.meta?.publishPolicyOverride??null);return;case"create-pr":me("review",null);return;case"merge":T&&ve(T.number);return;case"sync":if(J)return;X(a_({branch:M,base:se}));return;case"open-pr-page":T?.htmlUrl&&window.open(T.htmlUrl,"_blank","noopener,noreferrer");return;case"review":if(J)return;T&&X(d_({prNumber:T.number}));return;case"reopen":if(J)return;T&&X(n_({prNumber:T.number}));return;case"rebase":if(J)return;X(o_({branch:M}));return;case"fix-checks":if(J)return;T&&X(l_({prNumber:T.number,failingChecks:q.meta?.failingChecks??[]}));return;case"mark-ready":if(J)return;T&&X(h_({prNumber:T.number}));return;case"resolve-comments":if(J)return;T&&X(c_({prNumber:T.number}));return}},Ve=g||J,le=c.jsx(__,{t:e,button:q,actionBusy:Ve,changeRequestPending:g,savePending:$,onAction:Me});return A?c.jsxs(c.Fragment,{children:[le,c.jsx(kh,{open:_.open,mode:_.mode,fastPreview:!1,recoverSandbox:()=>p.mutateAsync({virtualMcpId:t,branch:A,...l?{threadId:l}:{}}),onOpenChange:ae=>{ae||m(re=>({...re,open:!1}))},orgSlug:s.slug,virtualMcpId:t,branch:A,baseBranch:se,repoTarget:Lt(b),owner:b.owner,repo:b.name,publishPolicy:_.policyOverride??ee,draftPreviewUrl:K,destinationHost:null,previewServerUrl:Z,compareDraft:K?{kind:"sandbox",previewUrl:K}:null,lastPublishedPr:H.data??null,onRequestApproval:()=>m(ae=>({...ae,open:!0,mode:"review"})),openPullRequest:T?.state==="open"?T:null,onPullRequestChanged:ce,onPublished:U})]}):le}function __(t){const e=F.c(44),{t:s,button:i,actionBusy:r,changeRequestPending:n,savePending:o,onAction:a}=t,h=i.action;let l;e[0]!==h||e[1]!==r?(l=r&&h!==void 0&&da.has(h),e[0]=h,e[1]=r,e[2]=l):l=e[2];const u=l,d=n&&h==="merge";let _;e[3]!==h||e[4]!==o?(_=o&&h!==void 0&&ua.has(h),e[3]=h,e[4]=o,e[5]=_):_=e[5];const m=_,f=!!i.disabled||u||d||m||!h,p=!!i.loading||d;let g;e[6]!==i.tooltip||e[7]!==u||e[8]!==m||e[9]!==s?(g=u?s("thread.headerActions.chatIsRunning"):m?s("thread.headerActions.saving"):i.tooltip,e[6]=i.tooltip,e[7]=u,e[8]=m,e[9]=s,e[10]=g):g=e[10];const v=g;let C;if(e[11]!==r||e[12]!==i.menu||e[13]!==n||e[14]!==a||e[15]!==o||e[16]!==s){let B;e[18]!==r||e[19]!==n||e[20]!==a||e[21]!==o||e[22]!==s?(B=R=>{const k=r&&da.has(R.action),A=o&&ua.has(R.action),M=R.action==="merge"&&n,P=A?s("thread.headerActions.saving"):k?s("thread.headerActions.chatIsRunning"):R.tooltip;return{key:R.key,label:R.label,icon:ca(R.action),disabled:!!(k||A||M),...P?{tooltip:P}:{},onSelect:()=>a(R.action)}},e[18]=r,e[19]=n,e[20]=a,e[21]=o,e[22]=s,e[23]=B):B=e[23],C=i.menu.map(B),e[11]=r,e[12]=i.menu,e[13]=n,e[14]=a,e[15]=o,e[16]=s,e[17]=C}else C=e[17];const S=C,b=i.label,w=i.variant;let x;e[24]!==h||e[25]!==p?(x=h&&!p?{icon:ca(h)}:{},e[24]=h,e[25]=p,e[26]=x):x=e[26];let D;e[27]!==v?(D=v?{tooltip:v}:{},e[27]=v,e[28]=D):D=e[28];let E;e[29]!==s?(E=s("thread.headerActions.moreActionsAriaLabel"),e[29]=s,e[30]=E):E=e[30];let I;e[31]!==h||e[32]!==a?(I=h?()=>a(h):void 0,e[31]=h,e[32]=a,e[33]=I):I=e[33];let y;return e[34]!==i.label||e[35]!==i.variant||e[36]!==f||e[37]!==S||e[38]!==p||e[39]!==x||e[40]!==D||e[41]!==E||e[42]!==I?(y=c.jsx(ih,{size:"sm",label:b,variant:w,disabled:f,loading:p,...x,...D,items:S,menuAriaLabel:E,onClick:I}),e[34]=i.label,e[35]=i.variant,e[36]=f,e[37]=S,e[38]=p,e[39]=x,e[40]=D,e[41]=E,e[42]=I,e[43]=y):y=e[43],y}function m_(t){const e=F.c(9),{label:s,children:i}=t;if(!s){let a;return e[0]!==i?(a=c.jsx(c.Fragment,{children:i}),e[0]=i,e[1]=a):a=e[1],a}let r;e[2]!==i?(r=c.jsx(rt,{asChild:!0,children:c.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=c.jsx(nt,{children:s}),e[4]=s,e[5]=n):n=e[5];let o;return e[6]!==r||e[7]!==n?(o=c.jsx(Sr,{children:c.jsxs(it,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=o):o=e[8],o}const p_=new Set(["site-editor","content"]);function g_(t){return t.hasClonableSource&&!t.fastPreviewActive&&t.mainTab!==null&&p_.has(t.mainTab)}const As="setup";function v_(t){const e=F.c(57),s=ge();let i;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let b;e[3]!==t.scriptTabs?(b=w=>!t.scriptTabs.includes(w),e[3]=t.scriptTabs,e[4]=b):b=e[4],i=t.scripts.filter(b),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=i}else i=e[2];const r=i;let n;e[5]!==t?(n=()=>{t.active===As?t.onToggle():t.onSelectTab(As)},e[5]=t,e[6]=n):n=e[6];const o=n;let a;e[7]!==t.open||e[8]!==s?(a=t.open?s("sandbox.preview.collapseTerminal"):s("sandbox.preview.expandTerminal"),e[7]=t.open,e[8]=s,e[9]=a):a=e[9];let h;e[10]!==t.open?(h=t.open?c.jsx(wr,{className:"size-4"}):c.jsx(Qc,{className:"size-4"}),e[10]=t.open,e[11]=h):h=e[11];let l;e[12]!==t.onToggle||e[13]!==t.open||e[14]!==a||e[15]!==h?(l=c.jsx(rt,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon-sm",onClick:t.onToggle,"aria-label":a,"aria-expanded":t.open,className:"size-6 shrink-0",children:h})}),e[12]=t.onToggle,e[13]=t.open,e[14]=a,e[15]=h,e[16]=l):l=e[16];let u;e[17]!==t.open||e[18]!==s?(u=t.open?s("sandbox.preview.collapseTerminal"):s("sandbox.preview.expandTerminal"),e[17]=t.open,e[18]=s,e[19]=u):u=e[19];let d;e[20]!==u?(d=c.jsx(nt,{children:u}),e[20]=u,e[21]=d):d=e[21];let _;e[22]!==l||e[23]!==d?(_=c.jsxs(it,{children:[l,d]}),e[22]=l,e[23]=d,e[24]=_):_=e[24];const m=t.active===As;let f;e[25]!==o||e[26]!==t.open||e[27]!==s||e[28]!==m?(f=c.jsx(b_,{active:m,open:t.open,onClick:o,t:s}),e[25]=o,e[26]=t.open,e[27]=s,e[28]=m,e[29]=f):f=e[29];let p;e[30]!==t||e[31]!==s?(p=t.scriptTabs.map(b=>c.jsx(w_,{active:t.active===b,onClick:()=>{t.active===b?t.onToggle():t.onSelectTab(b)},onClose:()=>t.onCloseScript(b),t:s,children:b},b)),e[30]=t,e[31]=s,e[32]=p):p=e[32];let g;e[33]!==r||e[34]!==t.onAddScript?(g=c.jsx(y_,{scripts:r,onRun:t.onAddScript}),e[33]=r,e[34]=t.onAddScript,e[35]=g):g=e[35];let v;e[36]!==p||e[37]!==g||e[38]!==f?(v=c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[f,p,g]}),e[36]=p,e[37]=g,e[38]=f,e[39]=v):v=e[39];let C;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?(C=t.showScriptControls?c.jsx(x_,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript,t:s}):c.jsx(S_,{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]=C):C=e[52];let S;return e[53]!==v||e[54]!==C||e[55]!==_?(S=c.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-2",children:[_,v,C]}),e[53]=v,e[54]=C,e[55]=_,e[56]=S):S=e[56],S}function b_(t){const e=F.c(11),{active:s,open:i,onClick:r,t:n}=t,o=s&&i,a=s&&i,h=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let l;e[0]!==h?(l=ie("flex h-6 items-center gap-1.5 rounded-lg border px-2 text-xs",h),e[0]=h,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx(Bd,{className:"size-4"}),e[2]=u):u=e[2];let d;e[3]!==n?(d=n("sandbox.toolbar.setupTab"),e[3]=n,e[4]=d):d=e[4];let _;return e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==l||e[9]!==d?(_=c.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:l,children:[u,d]}),e[5]=r,e[6]=o,e[7]=a,e[8]=l,e[9]=d,e[10]=_):_=e[10],_}function S_(t){const e=F.c(40),{status:s,onStart:i,onStop:r,onRestart:n,onResume:o,onRetry:a,t:h}=t;if(s==="idle"&&i){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(lr,{className:"size-3.5"}),e[0]=l):l=e[0];let u;e[1]!==h?(u=h("sandbox.toolbar.start"),e[1]=h,e[2]=u):u=e[2];let d;return e[3]!==i||e[4]!==u?(d=c.jsxs(_e,{variant:"outline",size:"xs",onClick:i,children:[l," ",u]}),e[3]=i,e[4]=u,e[5]=d):d=e[5],d}if(s==="suspended"&&o){let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(lr,{className:"size-3.5"}),e[6]=l):l=e[6];let u;e[7]!==h?(u=h("sandbox.toolbar.resume"),e[7]=h,e[8]=u):u=e[8];let d;return e[9]!==o||e[10]!==u?(d=c.jsxs(_e,{variant:"outline",size:"xs",onClick:o,children:[l," ",u]}),e[9]=o,e[10]=u,e[11]=d):d=e[11],d}if(s==="errored"&&a){let l;e[12]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(mi,{className:"size-3.5"}),e[12]=l):l=e[12];let u;e[13]!==h?(u=h("sandbox.toolbar.retry"),e[13]=h,e[14]=u):u=e[14];let d;return e[15]!==a||e[16]!==u?(d=c.jsxs(_e,{variant:"outline",size:"xs",onClick:a,children:[l," ",u]}),e[15]=a,e[16]=u,e[17]=d):d=e[17],d}if(s==="starting"||s==="running"){const l=s==="running"&&!!n,u=l?"rounded-r-none border-r-0":void 0;let d;e[18]!==u?(d=ie(u),e[18]=u,e[19]=d):d=e[19];let _;e[20]!==h?(_=h("sandbox.toolbar.stop"),e[20]=h,e[21]=_):_=e[21];let m;e[22]!==r||e[23]!==d||e[24]!==_?(m=c.jsx(rt,{asChild:!0,children:c.jsx(_e,{variant:"outline",size:"xs",onClick:r,className:d,children:_})}),e[22]=r,e[23]=d,e[24]=_,e[25]=m):m=e[25];let f;e[26]!==h?(f=h("sandbox.toolbar.stopSandboxTooltip"),e[26]=h,e[27]=f):f=e[27];let p;e[28]!==f?(p=c.jsx(nt,{children:f}),e[28]=f,e[29]=p):p=e[29];let g;e[30]!==m||e[31]!==p?(g=c.jsxs(it,{children:[m,p]}),e[30]=m,e[31]=p,e[32]=g):g=e[32];let v;e[33]!==n||e[34]!==l||e[35]!==h?(v=l&&c.jsxs(Ci,{children:[c.jsx(yi,{asChild:!0,children:c.jsx(_e,{variant:"outline",size:"xs",className:"rounded-l-none px-1","aria-label":h("sandbox.toolbar.moreActions"),children:c.jsx(wr,{className:"size-3"})})}),c.jsx(xi,{align:"end",children:c.jsxs(Ts,{onClick:n,children:[c.jsx(mi,{className:"size-3.5"})," ",h("sandbox.toolbar.restart")]})})]}),e[33]=n,e[34]=l,e[35]=h,e[36]=v):v=e[36];let C;return e[37]!==g||e[38]!==v?(C=c.jsxs("div",{className:"flex items-center",children:[g,v]}),e[37]=g,e[38]=v,e[39]=C):C=e[39],C}return null}function w_(t){const e=F.c(17),{active:s,onClick:i,onClose:r,children:n,t:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let h;e[0]!==a?(h=ie("flex h-6 items-center rounded-lg border text-xs",a),e[0]=a,e[1]=h):h=e[1];const l=r?"pl-2 pr-1":"px-2",u=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==l||e[3]!==u?(d=ie("flex h-full items-center",l,u),e[2]=l,e[3]=u,e[4]=d):d=e[4];let _;e[5]!==n||e[6]!==i||e[7]!==d?(_=c.jsx("button",{type:"button",onClick:i,className:d,children:n}),e[5]=n,e[6]=i,e[7]=d,e[8]=_):_=e[8];let m;e[9]!==n||e[10]!==r||e[11]!==o?(m=r&&c.jsx("button",{type:"button","aria-label":o("sandbox.toolbar.closeTab",{tab:String(n)}),onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:c.jsx(Mc,{className:"size-3.5"})}),e[9]=n,e[10]=r,e[11]=o,e[12]=m):m=e[12];let f;return e[13]!==h||e[14]!==_||e[15]!==m?(f=c.jsxs("div",{className:h,children:[_,m]}),e[13]=h,e[14]=_,e[15]=m,e[16]=f):f=e[16],f}function y_(t){const e=F.c(27),{scripts:s,onRun:i}=t,r=ge(),[n,o]=V.useState(!1);let a;e[0]!==r?(a=r("sandbox.toolbar.runScript"),e[0]=r,e[1]=a):a=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(oo,{className:"size-4"}),e[2]=h):h=e[2];let l;e[3]!==a?(l=c.jsx(rt,{asChild:!0,children:c.jsx(Pl,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"xs","aria-label":a,children:h})})}),e[3]=a,e[4]=l):l=e[4];let u;e[5]!==r?(u=r("sandbox.toolbar.runScript"),e[5]=r,e[6]=u):u=e[6];let d;e[7]!==u?(d=c.jsx(nt,{children:u}),e[7]=u,e[8]=d):d=e[8];let _;e[9]!==l||e[10]!==d?(_=c.jsxs(it,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=_):_=e[11];let m;e[12]!==r?(m=r("sandbox.toolbar.runAScript"),e[12]=r,e[13]=m):m=e[13];let f;e[14]!==m?(f=c.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:m}),e[14]=m,e[15]=f):f=e[15];let p;e[16]!==i||e[17]!==s||e[18]!==r?(p=s.length===0?c.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:r("sandbox.toolbar.noScriptsFound")}):s.map(C=>c.jsxs("button",{type:"button",onClick:()=>{o(!1),i(C)},className:"w-full rounded-lg px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",C]},C)),e[16]=i,e[17]=s,e[18]=r,e[19]=p):p=e[19];let g;e[20]!==f||e[21]!==p?(g=c.jsxs(El,{align:"start",className:"p-1 w-56",children:[f,p]}),e[20]=f,e[21]=p,e[22]=g):g=e[22];let v;return e[23]!==n||e[24]!==g||e[25]!==_?(v=c.jsxs(kl,{open:n,onOpenChange:o,children:[_,g]}),e[23]=n,e[24]=g,e[25]=_,e[26]=v):v=e[26],v}function x_(t){const e=F.c(30),{isRunning:s,isKilling:i,onRun:r,onStop:n,t:o}=t;if(i){let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsx(_i,{className:"size-3.5"}),e[0]=_):_=e[0];let m;e[1]!==o?(m=o("sandbox.toolbar.stopping"),e[1]=o,e[2]=m):m=e[2];let f;return e[3]!==m?(f=c.jsxs(_e,{variant:"outline",size:"xs",disabled:!0,children:[_," ",m]}),e[3]=m,e[4]=f):f=e[4],f}if(!s){let _;e[5]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsx(lr,{className:"size-3.5"}),e[5]=_):_=e[5];let m;e[6]!==o?(m=o("sandbox.toolbar.run"),e[6]=o,e[7]=m):m=e[7];let f;e[8]!==r||e[9]!==m?(f=c.jsx(rt,{asChild:!0,children:c.jsxs(_e,{variant:"outline",size:"xs",onClick:r,children:[_," ",m]})}),e[8]=r,e[9]=m,e[10]=f):f=e[10];let p;e[11]!==o?(p=o("sandbox.toolbar.startProcess"),e[11]=o,e[12]=p):p=e[12];let g;e[13]!==p?(g=c.jsx(nt,{children:p}),e[13]=p,e[14]=g):g=e[14];let v;return e[15]!==f||e[16]!==g?(v=c.jsxs(it,{children:[f,g]}),e[15]=f,e[16]=g,e[17]=v):v=e[17],v}let a;e[18]!==o?(a=o("sandbox.toolbar.stop"),e[18]=o,e[19]=a):a=e[19];let h;e[20]!==n||e[21]!==a?(h=c.jsx(rt,{asChild:!0,children:c.jsx(_e,{variant:"outline",size:"xs",onClick:n,children:a})}),e[20]=n,e[21]=a,e[22]=h):h=e[22];let l;e[23]!==o?(l=o("sandbox.toolbar.stopProcess"),e[23]=o,e[24]=l):l=e[24];let u;e[25]!==l?(u=c.jsx(nt,{children:l}),e[25]=l,e[26]=u):u=e[26];let d;return e[27]!==h||e[28]!==u?(d=c.jsxs(it,{children:[h,u]}),e[27]=h,e[28]=u,e[29]=d):d=e[29],d}var Dh=Object.defineProperty,C_=Object.getOwnPropertyDescriptor,k_=(t,e)=>{for(var s in e)Dh(t,s,{get:e[s],enumerable:!0})},Be=(t,e,s,i)=>{for(var r=i>1?void 0:i?C_(e,s):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(r=(i?o(e,s,r):o(r))||r);return i&&r&&Dh(e,s,r),r},j=(t,e)=>(s,i)=>e(s,i,t),fa="Terminal input",ln={get:()=>fa,set:t=>fa=t},_a="Too much output to announce, navigate to rows manually to read",hn={get:()=>_a,set:t=>_a=t};function P_(t){return t.replace(/\r?\n/g,"\r")}function E_(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function R_(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function B_(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Ah(r,e,s,i)}}function Ah(t,e,s,i){t=P_(t),t=E_(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Mh(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,n=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function ma(t,e,s,i,r){Mh(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Ss(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Dr(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let n=t[r];n>65535?(n-=65536,i+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):i+=String.fromCharCode(n)}return i}var D_=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let n=t.charCodeAt(r++);56320<=n&&n<=57343?e[i++]=(this._interim-55296)*1024+n-56320+65536:(e[i++]=this._interim,e[i++]=n),this._interim=0}for(let n=r;n<s;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=s)return this._interim=o,i;let a=t.charCodeAt(n);56320<=a&&a<=57343?e[i++]=(o-55296)*1024+a-56320+65536:(e[i++]=o,e[i++]=a);continue}o!==65279&&(e[i++]=o)}return i}},A_=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let _=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let f=0,p;for(;(p=this.interim[++f]&63)&&f<4;)m<<=6,m|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-f;for(;l<v;){if(l>=s)return 0;if(p=t[l++],(p&192)!==128){l--,_=!0;break}else this.interim[f++]=p,m<<=6,m|=p&63}_||(g===2?m<128?l--:e[i++]=m:g===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let u=s-4,d=l;for(;d<s;){for(;d<u&&!((r=t[d])&128)&&!((n=t[d+1])&128)&&!((o=t[d+2])&128)&&!((a=t[d+3])&128);)e[i++]=r,e[i++]=n,e[i++]=o,e[i++]=a,d+=4;if(r=t[d++],r<128)e[i++]=r;else if((r&224)===192){if(d>=s)return this.interim[0]=r,i;if(n=t[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}e[i++]=h}else if((r&240)===224){if(d>=s)return this.interim[0]=r,i;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=t[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;e[i++]=h}else if((r&248)===240){if(d>=s)return this.interim[0]=r,i;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=t[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,i;if(a=t[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;e[i++]=h}}return i}},Th="",ws=" ",Ei=class Nh{constructor(){this.fg=0,this.bg=0,this.extended=new ur}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 Nh;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}},ur=class Lh{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 Lh(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},It=class Ih extends Ei{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ur,this.combinedData=""}static fromCharData(e){let s=new Ih;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?Ss(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 i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-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()]}},pa="di$target",cn="di$dependencies",Ur=new Map;function M_(t){return t[cn]||[]}function qe(t){if(Ur.has(t))return Ur.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");T_(e,s,r)};return e._id=t,Ur.set(t,e),e}function T_(t,e,s){e[pa]===e?e[cn].push({id:t,index:s}):(e[cn]=[{id:t,index:s}],e[pa]=e)}var ot=qe("BufferService"),Oh=qe("CoreMouseService"),js=qe("CoreService"),N_=qe("CharsetService"),ko=qe("InstantiationService"),jh=qe("LogService"),at=qe("OptionsService"),Fh=qe("OscLinkService"),L_=qe("UnicodeService"),Ri=qe("DecorationService"),dn=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 i=[],r=this._optionsService.rawOptions.linkHandler,n=new It,o=s.getTrimmedLength(),a=-1,h=-1,l=!1;for(let u=0;u<o;u++)if(!(h===-1&&!s.hasContent(u))){if(s.loadCell(u,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=u,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&u===o-1){let d=this._oscLinkService.getLinkData(a)?.uri;if(d){let _={start:{x:h+1,y:t},end:{x:u+(!l&&u===o-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let f=new URL(d);["http:","https:"].includes(f.protocol)||(m=!0)}catch{m=!0}m||i.push({text:d,range:_,activate:(f,p)=>r?r.activate(f,p,_):I_(f,p),hover:(f,p)=>r?.hover?.(f,p,_),leave:(f,p)=>r?.leave?.(f,p,_)})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=u,a=n.extended.urlId):(h=-1,a=-1)}}e(i)}};dn=Be([j(0,ot),j(1,at),j(2,Fh)],dn);function I_(t,e){if(confirm(`Do you want to navigate to ${e}?
12
+ `)}function Rf(t,e,s){const i=F.c(6);let r;i[0]!==s||i[1]!==t||i[2]!==e?(r=Js.decofile(`${t}/${e}/${s}`),i[0]=s,i[1]=t,i[2]=e,i[3]=r):r=i[3];let n;i[4]!==r?(n={queryKey:r,queryFn:cl},i[4]=r,i[5]=n):n=i[5];const{data:o}=Is(n);return o}function xh(t){const{orgSlug:e,virtualMcpId:s,branch:i,threadId:r,baseBranch:n,fastPreview:o,recoverSandbox:a}=t,h={orgSlug:e,virtualMcpId:s,branch:i,threadId:r},l=o?{fastPreview:!0}:void 0,u=V.useRef(null),d=async w=>{try{return await w()}catch(x){if(!a||!Gl(x))throw x;return u.current??=a(),await u.current,w()}},_=hl({...Yl(h),queryFn:()=>d(()=>fo(h))}),m=_.data,f=m.changedFiles??null,p=m.headSha??null,g=f?f.length>0:Md(m)||Td(m),v=Is({queryKey:kf(e,s,i,n,p,Ef(m,o)),queryFn:()=>d(()=>ql(h,m,n,l)),enabled:g,staleTime:o?Pf:0,gcTime:o?void 0:0,throwOnError:(w,x)=>!f&&x.state.data===void 0}),C=Rf(e,s,i),S=v.data??null,b=f?ph({files:f,lookup:C,diff:S}):zu(S);return{status:m,summary:b,allPaths:f?f.map(w=>w.path):Object.keys(S?.diffs??{}),discardablePaths:o?null:new Set(m.files.map(w=>w.path)),changedFilesTotal:m.changedFilesTotal??b.count,changedFilesTruncated:m.changedFilesTruncated??!1,headSha:p,diff:S,bodiesPending:g&&v.isPending,bodiesFailed:v.isError,cardsPending:!f&&g&&v.isPending,refresh:()=>Promise.all([_.refetch(),o?null:v.refetch()])}}function Bf(t){const e=F.c(4);let s;e[0]!==t?(s=Js.decofile(t),e[0]=t,e[1]=s):s=e[1];let i;e[2]!==s?(i={queryKey:s,queryFn:cl},e[2]=s,e[3]=i):i=e[3];const{data:r}=Is(i);return r}function bo(t){const e=F.c(24),{backend:s,cacheKey:i}=t,r=br();let n;e[0]!==i?(n=Js.contentChanges(i),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==s||e[3]!==i||e[4]!==r?(o=()=>qc(r,s.client,i),e[2]=s,e[3]=i,e[4]=r,e[5]=o):o=e[5];let a;e[6]!==n||e[7]!==o?(a={queryKey:n,queryFn:o,staleTime:0},e[6]=n,e[7]=o,e[8]=a):a=e[8];const h=hl(a),l=h.data,u=Kc(s,i,l),d=Bf(i),_=u.data??null;let m;e[9]!==l.changes||e[10]!==d||e[11]!==_?(m=Yu({changes:l.changes,sides:_,lookup:d}),e[9]=l.changes,e[10]=d,e[11]=_,e[12]=m):m=e[12];const f=m;let p;e[13]!==l.changes?(p=Object.entries(l.changes).map(Df),e[13]=l.changes,e[14]=p):p=e[14];const g=f.count>0&&u.isPending;let v;e[15]!==h?(v=()=>h.refetch(),e[15]=h,e[16]=v):v=e[16];let C;return e[17]!==l||e[18]!==u.isError||e[19]!==f||e[20]!==p||e[21]!==g||e[22]!==v?(C={changes:l,summary:f,entries:p,sidesPending:g,sidesFailed:u.isError,refresh:v},e[17]=l,e[18]=u.isError,e[19]=f,e[20]=p,e[21]=g,e[22]=v,e[23]=C):C=e[23],C}function Df(t){const[e,s]=t;return{name:e,version:s.version}}function Af(t){return["smart-review-verdict",t.orgSlug,t.virtualMcpId,t.branch,t.threadId,t.fastPreview?"fast-preview-upstream":"sandbox",t.signature,t.language]}function Mf(t){const e=F.c(27),{orgSlug:s,virtualMcpId:i,branch:r,threadId:n,fastPreview:o,status:a,diff:h,enabled:l}=t,[u]=dl(),{language:d}=u;let _,m,f;if(e[0]!==r||e[1]!==h||e[2]!==l||e[3]!==o||e[4]!==d||e[5]!==s||e[6]!==a||e[7]!==n||e[8]!==i){const w=h?Er(h):"";_=l&&!!r&&!!a&&!!h&&w!=="",f=Is,m=Af({orgSlug:s,virtualMcpId:i,branch:r,threadId:n,fastPreview:o,signature:w,language:d}),e[0]=r,e[1]=h,e[2]=l,e[3]=o,e[4]=d,e[5]=s,e[6]=a,e[7]=n,e[8]=i,e[9]=_,e[10]=m,e[11]=f}else _=e[9],m=e[10],f=e[11];let p;e[12]!==r||e[13]!==h||e[14]!==d||e[15]!==s||e[16]!==a||e[17]!==n||e[18]!==i?(p=()=>Nd({orgSlug:s,virtualMcpId:i,branch:r,threadId:n},{status:a,diff:h,language:d}),e[12]=r,e[13]=h,e[14]=d,e[15]=s,e[16]=a,e[17]=n,e[18]=i,e[19]=p):p=e[19];let g;e[20]!==_||e[21]!==m||e[22]!==p?(g={queryKey:m,queryFn:p,enabled:_,staleTime:1/0,gcTime:6e5,retry:Tf},e[20]=_,e[21]=m,e[22]=p,e[23]=g):g=e[23];const v=f(g),C=v.data??null,S=_&&v.isFetching&&!v.data;let b;return e[24]!==C||e[25]!==S?(b={verdict:C,loading:S},e[24]=C,e[25]=S,e[26]=b):b=e[26],b}function Tf(t,e){return!Gl(e)&&t<1}function Ch(t){const e=F.c(30),{orgSlug:s,virtualMcpId:i,branch:r,threadId:n,fastPreview:o,status:a,diff:h,policy:l,judgeEnabled:u,paths:d}=t,_=u===void 0?!0:u,m=d===void 0?null:d;let f;e[0]!==h||e[1]!==_||e[2]!==l?(f=_&&Ld(h,l),e[0]=h,e[1]=_,e[2]=l,e[3]=f):f=e[3];const p=f;let g;e[4]!==r||e[5]!==h||e[6]!==o||e[7]!==p||e[8]!==s||e[9]!==a||e[10]!==n||e[11]!==i?(g={orgSlug:s,virtualMcpId:i,branch:r,threadId:n,fastPreview:o,status:a,diff:h,enabled:p},e[4]=r,e[5]=h,e[6]=o,e[7]=p,e[8]=s,e[9]=a,e[10]=n,e[11]=i,e[12]=g):g=e[12];const{verdict:v,loading:C}=Mf(g);if(!h&&m){let x;e[13]!==m||e[14]!==l?(x=Id(m,l),e[13]=m,e[14]=l,e[15]=x):x=e[15];let D;return e[16]!==x?(D={gate:x,ready:!1},e[16]=x,e[17]=D):D=e[17],D}if(!h){let x;return e[18]===Symbol.for("react.memo_cache_sentinel")?(x={gate:{allowed:!0,reason:null},ready:!1},e[18]=x):x=e[18],x}if(!p){let x;e[19]!==h||e[20]!==l?(x=Od(h,l),e[19]=h,e[20]=l,e[21]=x):x=e[21];let D;return e[22]!==x?(D={gate:x,ready:!0},e[22]=x,e[23]=D):D=e[23],D}let S;e[24]!==C||e[25]!==v?(S=jd(v,C),e[24]=C,e[25]=v,e[26]=S):S=e[26];const b=!C;let w;return e[27]!==S||e[28]!==b?(w={gate:S,ready:b},e[27]=S,e[28]=b,e[29]=w):w=e[29],w}function kh(t){const e=F.c(16),s=V.useRef(!1),i=ge();let r;e[0]!==t?(r=d=>{!d&&s.current||t.onOpenChange(d)},e[0]=t,e[1]=r):r=e[1];const n=r;let o;e[2]!==t.mode||e[3]!==i?(o=t.mode==="review"?i("thread.publishPopover.submitForReview"):i("thread.publishPopover.publish"),e[2]=t.mode,e[3]=i,e[4]=o):o=e[4];let a;e[5]!==o?(a=c.jsx(fl,{className:"sr-only",children:o}),e[5]=o,e[6]=a):a=e[6];let h;e[7]!==t?(h=t.open?c.jsx(Of,{...t,publishLockRef:s}):null,e[7]=t,e[8]=h):h=e[8];let l;e[9]!==a||e[10]!==h?(l=c.jsxs(_l,{"aria-describedby":void 0,className:"flex h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-none flex-col md:flex-row md:h-[calc(100dvh-6rem)] md:w-[calc(100vw-6rem)] gap-0 overflow-hidden p-0 sm:max-w-none",closeButtonClassName:"top-3.5 right-3.5",children:[a,h]}),e[9]=a,e[10]=h,e[11]=l):l=e[11];let u;return e[12]!==n||e[13]!==t.open||e[14]!==l?(u=c.jsx(ul,{open:t.open,onOpenChange:n,children:l}),e[12]=n,e[13]=t.open,e[14]=l,e[15]=u):u=e[15],u}function Nf(t){return["main","master"].includes(t.trim().toLowerCase())}const Lf=4,Gs="flex h-[45%] min-h-0 min-w-0 shrink-0 md:h-auto md:flex-1";function Pi(t){const e=F.c(5),{list:s,pane:i}=t;let r;e[0]!==s?(r=c.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col max-md:border-t md:w-[380px] md:flex-none md:shrink-0 md:border-l md:[&>[data-publish-state]>:first-child]:pr-12",children:s}),e[0]=s,e[1]=r):r=e[1];let n;return e[2]!==i||e[3]!==r?(n=c.jsxs(c.Fragment,{children:[i,r]}),e[2]=i,e[3]=r,e[4]=n):n=e[4],n}function So(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx("div",{className:ie(Gs,"bg-muted/40 p-3"),children:c.jsx(os,{className:"h-full w-full rounded-lg"})}),t[0]=e):e=t[0],e}function wo(t){const e=F.c(11),{mode:s,title:i,subLine:r,trailing:n}=t,o=s==="review"?yr:sd;let a;e[0]!==o?(a=c.jsx(o,{className:"size-4 shrink-0 text-muted-foreground"}),e[0]=o,e[1]=a):a=e[1];let h;e[2]!==a||e[3]!==i||e[4]!==n?(h=c.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a,i,n]}),e[2]=a,e[3]=i,e[4]=n,e[5]=h):h=e[5];let l;e[6]!==r?(l=r?c.jsx("div",{className:"pl-6 text-xs text-muted-foreground",children:r}):null,e[6]=r,e[7]=l):l=e[7];let u;return e[8]!==h||e[9]!==l?(u=c.jsxs(c.Fragment,{children:[h,l]}),e[8]=h,e[9]=l,e[10]=u):u=e[10],u}function yo(t){const e=F.c(9),{draftPreviewUrl:s,t:i}=t;let r;e[0]!==s?(r=()=>{s&&window.open(s,"_blank","noopener,noreferrer")},e[0]=s,e[1]=r):r=e[1];const n=!s;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(Kl,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==i?(a=i("thread.publishPopover.preview"),e[3]=i,e[4]=a):a=e[4];let h;return e[5]!==r||e[6]!==n||e[7]!==a?(h=c.jsxs(_e,{type:"button",variant:"outline",onClick:r,disabled:n,children:[o,a]}),e[5]=r,e[6]=n,e[7]=a,e[8]=h):h=e[8],h}function Ph(t){const e=F.c(21),{mode:s,draftPreviewUrl:i}=t,r=ge();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=c.jsx(So,{}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(os,{className:"h-3.5 w-48"}),e[1]=o):o=e[1];let a;e[2]!==s?(a=c.jsx(wo,{mode:s,title:o}),e[2]=s,e[3]=a):a=e[3];let h,l;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(gi,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Ds,{}),c.jsx(Ds,{}),c.jsx(Ds,{})]})}),l=c.jsxs(c.Fragment,{children:[c.jsx(os,{className:"h-3 w-20"}),c.jsx(os,{className:"h-14 w-full rounded-lg"})]}),e[4]=h,e[5]=l):(h=e[4],l=e[5]);let u;e[6]!==i||e[7]!==r?(u=c.jsx(yo,{draftPreviewUrl:i,t:r}),e[6]=i,e[7]=r,e[8]=u):u=e[8];const d=s==="review"?"default":"brand";let _;e[9]!==s||e[10]!==r?(_=r(s==="review"?"thread.publishPopover.submitForReview":"thread.publishPopover.publish"),e[9]=s,e[10]=r,e[11]=_):_=e[11];let m;e[12]!==d||e[13]!==_?(m=c.jsx(_e,{type:"button",variant:d,className:"flex-1",disabled:!0,children:_}),e[12]=d,e[13]=_,e[14]=m):m=e[14];let f;e[15]!==u||e[16]!==m?(f=c.jsxs("div",{className:"flex gap-2",children:[u,m]}),e[15]=u,e[16]=m,e[17]=f):f=e[17];let p;return e[18]!==f||e[19]!==a?(p=c.jsx(Pi,{pane:n,list:c.jsx(Br,{state:"loading",header:a,body:h,note:l,footer:f})}),e[18]=f,e[19]=a,e[20]=p):p=e[20],p}function If(t){const e=F.c(26),{mode:s,draftPreviewUrl:i,message:r,onRetry:n}=t,o=ge();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx("div",{className:ie(Gs,"bg-muted/40")}),e[0]=a):a=e[0];let h;e[1]!==o?(h=o("thread.publishPopover.loadFailed"),e[1]=o,e[2]=h):h=e[2];let l;e[3]!==h?(l=c.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=l):l=e[4];let u;e[5]!==s||e[6]!==l?(u=c.jsx(wo,{mode:s,title:l}),e[5]=s,e[6]=l,e[7]=u):u=e[7];let d;e[8]!==r?(d=c.jsx("p",{className:"px-4 py-6 text-xs text-destructive",children:r}),e[8]=r,e[9]=d):d=e[9];let _;e[10]!==i||e[11]!==o?(_=c.jsx(yo,{draftPreviewUrl:i,t:o}),e[10]=i,e[11]=o,e[12]=_):_=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=c.jsx(mi,{className:"size-4"}),e[13]=m):m=e[13];let f;e[14]!==o?(f=o("thread.publishPopover.retry"),e[14]=o,e[15]=f):f=e[15];let p;e[16]!==n||e[17]!==f?(p=c.jsxs(_e,{type:"button",variant:"outline",className:"flex-1",onClick:n,children:[m,f]}),e[16]=n,e[17]=f,e[18]=p):p=e[18];let g;e[19]!==_||e[20]!==p?(g=c.jsxs("div",{className:"flex gap-2",children:[_,p]}),e[19]=_,e[20]=p,e[21]=g):g=e[21];let v;return e[22]!==g||e[23]!==u||e[24]!==d?(v=c.jsx(Pi,{pane:a,list:c.jsx(Br,{state:"ready",header:u,body:d,footer:g})}),e[22]=g,e[23]=u,e[24]=d,e[25]=v):v=e[25],v}function Of(t){const e=F.c(3),s=t.mode??"publish";let i;return e[0]!==s||e[1]!==t?(i=c.jsx(ml,{children:r=>{const{reset:n}=r;return c.jsx(pl,{fallback:o=>{const{error:a,resetError:h}=o;return c.jsx(If,{mode:s,draftPreviewUrl:t.draftPreviewUrl,message:a?.message??"",onRetry:()=>{n(),h()}})},children:c.jsx(V.Suspense,{fallback:c.jsx(Ph,{mode:s,draftPreviewUrl:t.draftPreviewUrl}),children:c.jsx(jf,{...t})})})}}),e[0]=s,e[1]=t,e[2]=i):i=e[2],i}function jf(t){const e=F.c(13),s=Zs(t.virtualMcpId,t.branch);let i;e[0]!==t.branch||e[1]!==t.orgSlug||e[2]!==t.virtualMcpId?(i={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch},e[0]=t.branch,e[1]=t.orgSlug,e[2]=t.virtualMcpId,e[3]=i):i=e[3];const r=Jn(i);if(s.kind==="protocol"&&r){let o;return e[4]!==s||e[5]!==r||e[6]!==t?(o=s.source==="sandbox"?c.jsx(zf,{...t,backend:s,cacheKey:r}):c.jsx(Hf,{...t,backend:s,cacheKey:r}),e[4]=s,e[5]=r,e[6]=t,e[7]=o):o=e[7],o}if(s.kind!=="legacy"){const o=t.mode??"publish";let a;return e[8]!==t.draftPreviewUrl||e[9]!==o?(a=c.jsx(Ph,{mode:o,draftPreviewUrl:t.draftPreviewUrl}),e[8]=t.draftPreviewUrl,e[9]=o,e[10]=a):a=e[10],a}let n;return e[11]!==t?(n=c.jsx(Ff,{...t}),e[11]=t,e[12]=n):n=e[12],n}function Ff(t){const e=F.c(52),s=xs()?.taskId??null;let i;e[0]!==t.baseBranch||e[1]!==t.branch||e[2]!==t.fastPreview||e[3]!==t.orgSlug||e[4]!==t.recoverSandbox||e[5]!==t.virtualMcpId||e[6]!==s?(i={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch,threadId:s,baseBranch:t.baseBranch,fastPreview:t.fastPreview,recoverSandbox:t.recoverSandbox},e[0]=t.baseBranch,e[1]=t.branch,e[2]=t.fastPreview,e[3]=t.orgSlug,e[4]=t.recoverSandbox,e[5]=t.virtualMcpId,e[6]=s,e[7]=i):i=e[7];const r=xh(i),n=t.mode!=="review";let o;e[8]!==t.branch||e[9]!==t.fastPreview||e[10]!==t.orgSlug||e[11]!==t.publishPolicy||e[12]!==t.virtualMcpId||e[13]!==r.allPaths||e[14]!==r.diff||e[15]!==r.status||e[16]!==n||e[17]!==s?(o={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch,threadId:s,fastPreview:t.fastPreview,status:r.status,diff:r.diff,paths:r.allPaths,policy:t.publishPolicy,judgeEnabled:n},e[8]=t.branch,e[9]=t.fastPreview,e[10]=t.orgSlug,e[11]=t.publishPolicy,e[12]=t.virtualMcpId,e[13]=r.allPaths,e[14]=r.diff,e[15]=r.status,e[16]=n,e[17]=s,e[18]=o):o=e[18];const{gate:a}=Ch(o),h=r.discardablePaths;let l;e[19]!==h?(l=C=>h===null||C.every(S=>h.has(S)),e[19]=h,e[20]=l):l=e[20];const u=l;let d;e[21]!==u?(d=C=>u(C.filepaths),e[21]=u,e[22]=d):d=e[22];let _;e[23]!==u||e[24]!==r.allPaths||e[25]!==r.changedFilesTruncated?(_=!r.changedFilesTruncated&&u(r.allPaths),e[23]=u,e[24]=r.allPaths,e[25]=r.changedFilesTruncated,e[26]=_):_=e[26];let m;e[27]!==t.branch||e[28]!==r.status?(m=mo(r.status)??t.branch,e[27]=t.branch,e[28]=r.status,e[29]=m):m=e[29];const f=r.headSha??void 0;let p;e[30]!==t.fastPreview||e[31]!==r.diff?(p=!t.fastPreview&&r.diff?{expectedDiffSignature:Er(r.diff)}:{},e[30]=t.fastPreview,e[31]=r.diff,e[32]=p):p=e[32];let g;e[33]!==a||e[34]!==r.allPaths||e[35]!==r.bodiesFailed||e[36]!==r.bodiesPending||e[37]!==r.cardsPending||e[38]!==r.changedFilesTotal||e[39]!==r.changedFilesTruncated||e[40]!==r.diff||e[41]!==r.refresh||e[42]!==r.summary||e[43]!==d||e[44]!==_||e[45]!==m||e[46]!==f||e[47]!==p?(g={summary:r.summary,allPaths:r.allPaths,canDiscard:d,canDiscardAll:_,changedFilesTotal:r.changedFilesTotal,changedFilesTruncated:r.changedFilesTruncated,diff:r.diff,bodiesPending:r.bodiesPending,bodiesFailed:r.bodiesFailed,cardsPending:r.cardsPending,refresh:r.refresh,gate:a,headBranch:m,expectedHeadSha:f,...p,hosted:!1,otherWork:!1},e[33]=a,e[34]=r.allPaths,e[35]=r.bodiesFailed,e[36]=r.bodiesPending,e[37]=r.cardsPending,e[38]=r.changedFilesTotal,e[39]=r.changedFilesTruncated,e[40]=r.diff,e[41]=r.refresh,e[42]=r.summary,e[43]=d,e[44]=_,e[45]=m,e[46]=f,e[47]=p,e[48]=g):g=e[48];let v;return e[49]!==t||e[50]!==g?(v=c.jsx(xo,{...t,source:g}),e[49]=t,e[50]=g,e[51]=v):v=e[51],v}function Eh(t,e){return{summary:t.summary,allPaths:[],canDiscard:()=>!0,canDiscardAll:!0,changedFilesTotal:t.summary.count,changedFilesTruncated:!1,diff:null,bodiesPending:t.sidesPending,bodiesFailed:t.sidesFailed,cardsPending:!1,refresh:t.refresh,protocol:{backend:e,entries:t.entries}}}function Hf(t){const e=F.c(18);let s,i,r;e[0]!==t?({backend:s,cacheKey:i,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let n;e[4]!==s||e[5]!==i?(n={backend:s,cacheKey:i},e[4]=s,e[5]=i,e[6]=n):n=e[6];const o=bo(n);let a;e[7]!==s||e[8]!==o?(a=Eh(o,s),e[7]=s,e[8]=o,e[9]=a):a=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h={allowed:!0,reason:null},e[10]=h):h=e[10];const l=s.source==="github";let u;e[11]!==r.branch||e[12]!==a||e[13]!==l?(u={...a,gate:h,headBranch:r.branch,hosted:l,otherWork:!1},e[11]=r.branch,e[12]=a,e[13]=l,e[14]=u):u=e[14];let d;return e[15]!==r||e[16]!==u?(d=c.jsx(xo,{...r,source:u}),e[15]=r,e[16]=u,e[17]=d):d=e[17],d}function zf(t){const e=F.c(53);let s,i,r;e[0]!==t?({backend:s,cacheKey:i,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);const n=xs()?.taskId??null;let o;e[4]!==s||e[5]!==i?(o={backend:s,cacheKey:i},e[4]=s,e[5]=i,e[6]=o):o=e[6];const a=bo(o);let h;e[7]!==r.baseBranch||e[8]!==r.branch||e[9]!==r.fastPreview||e[10]!==r.orgSlug||e[11]!==r.recoverSandbox||e[12]!==r.virtualMcpId||e[13]!==n?(h={orgSlug:r.orgSlug,virtualMcpId:r.virtualMcpId,branch:r.branch,threadId:n,baseBranch:r.baseBranch,fastPreview:r.fastPreview,recoverSandbox:r.recoverSandbox},e[7]=r.baseBranch,e[8]=r.branch,e[9]=r.fastPreview,e[10]=r.orgSlug,e[11]=r.recoverSandbox,e[12]=r.virtualMcpId,e[13]=n,e[14]=h):h=e[14];const l=xh(h),u=r.mode!=="review";let d;e[15]!==l.allPaths||e[16]!==l.diff||e[17]!==l.status||e[18]!==r.branch||e[19]!==r.fastPreview||e[20]!==r.orgSlug||e[21]!==r.publishPolicy||e[22]!==r.virtualMcpId||e[23]!==u||e[24]!==n?(d={orgSlug:r.orgSlug,virtualMcpId:r.virtualMcpId,branch:r.branch,threadId:n,fastPreview:r.fastPreview,status:l.status,diff:l.diff,paths:l.allPaths,policy:r.publishPolicy,judgeEnabled:u},e[15]=l.allPaths,e[16]=l.diff,e[17]=l.status,e[18]=r.branch,e[19]=r.fastPreview,e[20]=r.orgSlug,e[21]=r.publishPolicy,e[22]=r.virtualMcpId,e[23]=u,e[24]=n,e[25]=d):d=e[25];const{gate:_}=Ch(d);let m;if(e[26]!==l.allPaths||e[27]!==a){let x;e[29]!==a?(x=D=>{const E=go(D);return E===null?!_o(D):!Object.hasOwn(a.changes.changes,E)},e[29]=a,e[30]=x):x=e[30],m=l.allPaths.some(x),e[26]=l.allPaths,e[27]=a,e[28]=m}else m=e[28];const f=m;let p;e[31]!==s||e[32]!==a?(p=Eh(a,s),e[31]=s,e[32]=a,e[33]=p):p=e[33];let g;e[34]!==l||e[35]!==a?(g=()=>Promise.all([a.refresh(),l.refresh()]),e[34]=l,e[35]=a,e[36]=g):g=e[36];let v;e[37]!==l.status||e[38]!==r.branch?(v=mo(l.status)??r.branch,e[37]=l.status,e[38]=r.branch,e[39]=v):v=e[39];const C=l.headSha??void 0;let S;e[40]!==l.diff?(S=l.diff?{expectedDiffSignature:Er(l.diff)}:{},e[40]=l.diff,e[41]=S):S=e[41];let b;e[42]!==_||e[43]!==f||e[44]!==S||e[45]!==p||e[46]!==g||e[47]!==v||e[48]!==C?(b={...p,refresh:g,gate:_,headBranch:v,expectedHeadSha:C,...S,hosted:!1,otherWork:f},e[42]=_,e[43]=f,e[44]=S,e[45]=p,e[46]=g,e[47]=v,e[48]=C,e[49]=b):b=e[49];let w;return e[50]!==r||e[51]!==b?(w=c.jsx(xo,{...r,source:b}),e[50]=r,e[51]=b,e[52]=w):w=e[52],w}function xo(t){const e=F.c(119),{source:s,publishLockRef:i,onOpenChange:r,mode:n,fastPreview:o,orgSlug:a,virtualMcpId:h,branch:l,baseBranch:u,repoTarget:d,owner:_,repo:m,draftPreviewUrl:f,destinationHost:p,previewServerUrl:g,compareDraft:v,lastPublishedPr:C,onRequestApproval:S,openPullRequest:b,onPullRequestChanged:w,onPublished:x}=t,D=n===void 0?"publish":n,E=C===void 0?null:C,I=b===void 0?null:b,y=ge(),[B]=dl(),{language:R}=B,k=xs()?.taskId??null,{data:A}=vr.useSession(),M=vl(bl(a,h,l)),{summary:P,allPaths:T,changedFilesTotal:N,changedFilesTruncated:z,diff:H,bodiesPending:W,bodiesFailed:ee,cardsPending:$,refresh:K,gate:Z,hosted:G,otherWork:q}=s,[te,X]=V.useState(null),[J,se]=V.useState(!1),[ce,U]=V.useState(null);let ve;e[0]===Symbol.for("react.memo_cache_sentinel")?(ve=[],e[0]=ve):ve=e[0];const[me,Me]=V.useState(ve);let Ve;e[1]===Symbol.for("react.memo_cache_sentinel")?(Ve=he=>{U(he),Me(we=>[he,...we.filter(Se=>Se!==he)])},e[1]=Ve):Ve=e[1];const le=Ve,[ae,re]=V.useState(null);let lt;e[2]!==te||e[3]!==P?(lt=$u(te,Ku(P)),e[2]=te,e[3]=P,e[4]=lt):lt=e[4];const be=lt,_t=[...P.pages,...P.blocks,...P.other],ht=_t.find(he=>ft(he)===ce)??_t[0]??null,mt=ht?ft(ht):null,Oe=[...new Set([...mt?[mt]:[],...me,..._t.map(ft)])].filter(he=>_t.some(we=>ft(we)===he)).slice(0,Lf),fe=D==="review"&&!G,pt=$?"loading":W?"manifest":"ready",gt=I?.state==="open",vt=s.headBranch,bt=A?.user;let je;e[5]!==bt?(je=rh(bt),e[5]=bt,e[6]=je):je=e[6];let Ze;e[7]!==s.expectedDiffSignature?(Ze=s.expectedDiffSignature?{expectedDiffSignature:s.expectedDiffSignature}:{},e[7]=s.expectedDiffSignature,e[8]=Ze):Ze=e[8];let Ye;e[9]!==u||e[10]!==l||e[11]!==o||e[12]!==a||e[13]!==_||e[14]!==m||e[15]!==d||e[16]!==s.expectedHeadSha||e[17]!==s.headBranch||e[18]!==je||e[19]!==Ze||e[20]!==k||e[21]!==h?(Ye={orgSlug:a,virtualMcpId:h,branch:l,threadId:k,fastPreview:o,baseBranch:u,target:d,owner:_,repo:m,headBranch:vt,coAuthor:je,expectedHeadSha:s.expectedHeadSha,...Ze},e[9]=u,e[10]=l,e[11]=o,e[12]=a,e[13]=_,e[14]=m,e[15]=d,e[16]=s.expectedHeadSha,e[17]=s.headBranch,e[18]=je,e[19]=Ze,e[20]=k,e[21]=h,e[22]=Ye):Ye=e[22];const ct=Ye,Te=fe?"review":"publish",Rt=A?.user?.name;let Y;e[23]!==T||e[24]!==p||e[25]!==G||e[26]!==be||e[27]!==r||e[28]!==x||e[29]!==w||e[30]!==i||e[31]!==K||e[32]!==s.protocol||e[33]!==Te||e[34]!==Rt||e[35]!==ct?(Y={mode:Te,target:ct,note:be,allPaths:T,destinationHost:p,publishLockRef:i,onOpenChange:r,refresh:K,onPullRequestChanged:w,onPublished:x,hosted:G,authorName:Rt,protocol:s.protocol},e[23]=T,e[24]=p,e[25]=G,e[26]=be,e[27]=r,e[28]=x,e[29]=w,e[30]=i,e[31]=K,e[32]=s.protocol,e[33]=Te,e[34]=Rt,e[35]=ct,e[36]=Y):Y=e[36];const{isPublishing:de,publishError:ke,publishErrorDetail:De,submit:Qe,discardChange:ps,discardAll:Kt}=Cf(Y),dt=wl(a,h).phase==="saving",Bt=P.count>0||q,qt=!de&&Bt&&(fe||Z.allowed);let Ot;e[37]!==u||e[38]!==fe||e[39]!==P.count||e[40]!==y?(Ot=fe?P.count===0?y("thread.publishPopover.submitForReview"):P.count===1?y("thread.publishPopover.submitOneForReview"):y("thread.publishPopover.submitCountForReview",{count:P.count}):P.count===0?y("thread.publishPopover.publish"):Nf(u)?P.count===1?y("thread.publishPopover.publishOneInProduction"):y("thread.publishPopover.publishCountInProduction",{count:P.count}):P.count===1?y("thread.publishPopover.publishOne"):y("thread.publishPopover.publishCount",{count:P.count}),e[37]=u,e[38]=fe,e[39]=P.count,e[40]=y,e[41]=Ot):Ot=e[41];const Vt=Ot;let St;e:{if(fe&&gt){let Se;e[42]!==I.number||e[43]!==y?(Se=y("thread.publishPopover.updatesPullRequest",{number:I.number}),e[42]=I.number,e[43]=y,e[44]=Se):Se=e[44],St=Se;break e}const he=E;if(!he?.mergedAt){St=null;break e}let we;if(e[45]!==R||e[46]!==he||e[47]!==y){const Se=Pd(new Date(he.mergedAt),R),Ne=wf(he);we=Ne?y("thread.publishPopover.lastPublishedBy",{when:Se,name:Ne}):y("thread.publishPopover.lastPublished",{when:Se}),e[45]=R,e[46]=he,e[47]=y,e[48]=we}else we=e[48];St=we}const Yt=St;let Dt;e[49]!==fe||e[50]!==P.count||e[51]!==y?(Dt=fe?y("thread.publishPopover.submitForReview"):P.count===1?y("thread.publishPopover.publishOne"):P.count>1?y("thread.publishPopover.publishCount",{count:P.count}):y("thread.publishPopover.publish"),e[49]=fe,e[50]=P.count,e[51]=y,e[52]=Dt):Dt=e[52];const Gt=Dt,Xt=(he,we)=>we.length===0?null:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("div",{className:"px-0.5 text-[11px] font-medium tracking-wider text-muted-foreground uppercase",children:he}),we.map(Se=>{const Ne=ft(Se);return c.jsx(bh,{change:Se,bodyPending:W,selected:ht!==null&&ft(ht)===Ne,onSelect:()=>le(Ne),confirming:ae===Ne,onConfirmingChange:et=>re(et?Ne:null),onDiscard:s.canDiscard(Se)?()=>{ps(Se)}:void 0,isPublishing:de,isDiscarding:dt},Ne)})]});let At;e:{if(fe||!Bt){At=null;break e}if(Z.pending){let Ne;e[53]===Symbol.for("react.memo_cache_sentinel")?(Ne=c.jsx(_i,{className:"size-3.5 motion-reduce:animate-none"}),e[53]=Ne):Ne=e[53];let et;e[54]!==y?(et=y("thread.publishPopover.reviewing"),e[54]=y,e[55]=et):et=e[55];let $t;e[56]!==et?($t=c.jsxs("div",{className:"flex items-center gap-2 border-t px-4 py-2.5 text-xs text-muted-foreground",children:[Ne,et]}),e[56]=et,e[57]=$t):$t=e[57],At=$t;break e}if(Z.allowed){At=null;break e}let he;e[58]===Symbol.for("react.memo_cache_sentinel")?(he=c.jsx(gl,{className:"mt-0.5 size-3.5 shrink-0"}),e[58]=he):he=e[58];let we;e[59]!==Z.reason||e[60]!==y?(we=Z.reason??y("thread.publishPopover.needsReviewGeneric"),e[59]=Z.reason,e[60]=y,e[61]=we):we=e[61];let Se;e[62]!==we?(Se=c.jsxs("div",{className:"flex items-start gap-2 border-t px-4 py-2.5 text-xs text-warning",children:[he,c.jsx("span",{children:we})]}),e[62]=we,e[63]=Se):Se=e[63],At=Se}const Jt=At;let jt;e[64]!==Kt||e[65]!==J||e[66]!==dt||e[67]!==de||e[68]!==s.canDiscardAll||e[69]!==P.count||e[70]!==y?(jt=P.count<=1||!s.canDiscardAll?null:c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"ml-auto shrink-0 text-[11px] text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>se(!0),disabled:de||dt,children:y("thread.publishPopover.discardAll")}),c.jsx(no,{open:J,onOpenChange:se,children:c.jsxs(ro,{children:[c.jsxs(eo,{children:[c.jsx(Zn,{children:y("thread.publishPopover.discardAllTitle")}),c.jsx(Qn,{children:y("thread.publishPopover.discardAllConfirm")})]}),c.jsxs(io,{children:[c.jsx(to,{children:y("thread.publishDialog.cancel")}),c.jsx(so,{onClick:()=>{Kt()},disabled:dt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:y("thread.publishPopover.discardAll")})]})]})})]}),e[64]=Kt,e[65]=J,e[66]=dt,e[67]=de,e[68]=s.canDiscardAll,e[69]=P.count,e[70]=y,e[71]=jt):jt=e[71];const Zt=jt,Qt=$?c.jsx(gi,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Ds,{}),c.jsx(Ds,{})]})}):P.count===0&&q?c.jsx("p",{className:"px-4 py-6 text-xs text-muted-foreground",children:y("thread.publishPopover.onlyOtherWork")}):P.count===0?c.jsxs("div",{className:"flex flex-col items-center gap-1 py-10 text-center",children:[c.jsx(uo,{className:"mb-1 size-5 text-success"}),c.jsx("p",{className:"text-sm font-medium",children:y(fe?"thread.publishPopover.nothingToSubmit":"thread.publishPopover.everythingLive")}),c.jsx("p",{className:"text-xs text-muted-foreground",children:y(fe?"thread.publishPopover.submitEmptyHint":"thread.publishPopover.emptyHint")})]}):c.jsxs(gi,{children:[z?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.showingFirst",{shown:P.count,total:N})}):null,Xt(y("thread.publishPopover.pagesGroup"),P.pages),Xt(y("thread.publishPopover.blocksGroup"),P.blocks),Xt(y("thread.publishPopover.otherGroup"),P.other),ee?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.detailsUnavailable")}):null,q?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.alsoOtherWork")}):null]}),es=$?c.jsx(So,{}):ht?c.jsx("div",{className:ie(Gs,"relative"),children:_t.filter(he=>Oe.includes(ft(he))).map(he=>c.jsx("div",{className:ie("absolute inset-0 flex",ft(he)!==mt&&"hidden"),children:c.jsx(wh,{change:he,diff:H,bodyPending:W,previewServerUrl:g,draft:v,lastPage:M})},ft(he)))}):c.jsx("div",{className:ie(Gs,"bg-muted/40")});let wt;e[72]!==Vt?(wt=c.jsx("span",{className:"truncate",children:Vt}),e[72]=Vt,e[73]=wt):wt=e[73];let Ft;e[74]!==Zt||e[75]!==D||e[76]!==Yt||e[77]!==wt?(Ft=c.jsx(wo,{mode:D,title:wt,subLine:Yt,trailing:Zt}),e[74]=Zt,e[75]=D,e[76]=Yt,e[77]=wt,e[78]=Ft):Ft=e[78];let yt;e[79]!==de||e[80]!==fe||e[81]!==be||e[82]!==P.count||e[83]!==y?(yt=P.count===0?null:c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-[13px] font-medium",children:y(fe?"thread.publishPopover.reviewNote":"thread.publishPopover.versionNote")}),c.jsx(kd,{value:be,onChange:he=>X(he.target.value),placeholder:y(fe?"thread.publishPopover.reviewNotePlaceholder":"thread.publishPopover.versionNotePlaceholder"),rows:2,maxLength:hr,className:"resize-none text-[13px]",disabled:de})]}),e[79]=de,e[80]=fe,e[81]=be,e[82]=P.count,e[83]=y,e[84]=yt):yt=e[84];let xt;e[85]!==f||e[86]!==y?(xt=c.jsx(yo,{draftPreviewUrl:f,t:y}),e[85]=f,e[86]=y,e[87]=xt):xt=e[87];let Ct;e[88]!==qt||e[89]!==Z||e[90]!==Bt||e[91]!==G||e[92]!==de||e[93]!==fe||e[94]!==S||e[95]!==Gt||e[96]!==Qe||e[97]!==y?(Ct=!fe&&!G&&Bt&&!Z.allowed&&!Z.pending?c.jsx(_e,{type:"button",className:"flex-1",onClick:S,disabled:de,children:y("thread.publishPopover.requestApproval")}):c.jsxs(_e,{type:"button",variant:fe?"default":"brand",className:"flex-1",onClick:()=>{Qe()},disabled:!qt,children:[de?c.jsx(_i,{className:"size-4 motion-reduce:animate-none"}):null,de?y(fe?"thread.publishPopover.submitting":"thread.publishPopover.publishing"):Gt]}),e[88]=qt,e[89]=Z,e[90]=Bt,e[91]=G,e[92]=de,e[93]=fe,e[94]=S,e[95]=Gt,e[96]=Qe,e[97]=y,e[98]=Ct):Ct=e[98];let Ht;e[99]!==xt||e[100]!==Ct?(Ht=c.jsxs("div",{className:"flex gap-2",children:[xt,Ct]}),e[99]=xt,e[100]=Ct,e[101]=Ht):Ht=e[101];let ts;e[102]!==ke||e[103]!==De||e[104]!==y?(ts=ke?c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-destructive",children:ke}),De?c.jsx(Vc,{label:y("siteEditor.details"),detail:De}):null]}):null,e[102]=ke,e[103]=De,e[104]=y,e[105]=ts):ts=e[105];let ss;e[106]!==Ht||e[107]!==ts?(ss=c.jsxs(c.Fragment,{children:[Ht,ts]}),e[106]=Ht,e[107]=ts,e[108]=ss):ss=e[108];let zt;e[109]!==Qt||e[110]!==Jt||e[111]!==pt||e[112]!==Ft||e[113]!==yt||e[114]!==ss?(zt=c.jsx(Br,{state:pt,header:Ft,body:Qt,note:yt,gate:Jt,footer:ss}),e[109]=Qt,e[110]=Jt,e[111]=pt,e[112]=Ft,e[113]=yt,e[114]=ss,e[115]=zt):zt=e[115];let Wt;return e[116]!==es||e[117]!==zt?(Wt=c.jsx(Pi,{pane:es,list:zt}),e[116]=es,e[117]=zt,e[118]=Wt):Wt=e[118],Wt}function Wf(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return Cd[t].short}const $f=new Set(["failure","timed_out","cancelled","action_required"]);function Rh(t){return t.status==="completed"&&$f.has(t.conclusion)}function Co(t){return t.status==="queued"||t.status==="in_progress"}function Qi(t){return t.isPending&&t.fetchStatus!=="idle"}function Uf(t){return{key:"view-change-request",label:t("thread.cmsActions.viewOnProvider"),action:"open-pr-page"}}function cs(t,e,s){return e?[...t,Uf(s)]:t}function Ut(t,e,s){return e.kind!=="ready"||e.behindBase<=0?t:[...t,{key:"get-latest",label:s("thread.cmsActions.getLatest"),action:"sync",tooltip:s("thread.cmsActions.getLatestTooltip")}]}function oa(t){return{key:"submit-for-review",label:t("thread.headerActions.submitForReview"),action:"create-pr"}}function Ki(t,e,s){if(e.filter(Co).length===0)return t;const r=e.filter(n=>n.status==="completed").length;return{...t,tooltip:s("thread.cmsActions.checksRunning",{done:r,total:e.length})}}function Kf(t){const{lifecycle:e,branch:s,pr:i,checks:r,reviews:n,loading:o,t:a}=t;if(o)return{label:a("thread.headerActions.loading"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.loadingBranchTooltip"),menu:[]};switch(e.phase){case"idle":return{label:t.claimPhase&&Wf(t.claimPhase.kind)||a("thread.headerActions.startingSandbox"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.waitingForDaemonTooltip"),menu:[]};case"cloning":return{label:a("thread.headerActions.cloningRepo"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.cloningRepoTooltip"),menu:[]};case"clone-failed":return{label:a("thread.headerActions.cloneFailed"),disabled:!0,variant:"outline",tooltip:e.error||a("thread.headerActions.cloneFailedDefaultTooltip"),menu:[]};case"checking-out":return{label:a("thread.headerActions.switchingTo",{branch:e.to}),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.checkingOutTooltip",{branch:e.to}),menu:[]};case"installing":return{label:a("thread.headerActions.installingPackages"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.installingPackagesTooltip"),menu:[]};case"starting":{if(!(s.kind==="ready"&&(s.workingTreeDirty||s.aheadOfBase>0||s.unpushed>0))&&!t.noReviewableDiff)return{label:a("thread.headerActions.startingApp"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.startingAppTooltip"),menu:[]};break}}if(s.kind!=="ready")return{label:a("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.waitingForBranchTooltip"),menu:[]};const h=s,l=h.unpushed>0&&!(i&&h.headSha&&i.headSha&&h.headSha===i.headSha);if(t.noReviewableDiff&&!i)return{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.branchInSyncTooltip",{base:h.base}),menu:Ut([],h,a)};if(h.workingTreeDirty||l)return{label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:Ut(cs([oa(a)],i,a),h,a)};if(eh("no local work — checking PR/sync state",{workingTreeDirty:h.workingTreeDirty,unpushed:h.unpushed,aheadOfBase:h.aheadOfBase,behindBase:h.behindBase,branch:h.branch,base:h.base,prMerged:i?.merged??null,prState:i?.state??null}),i?.merged)return!!h.headSha&&!!i.headSha&&h.headSha!==i.headSha?{label:a("thread.headerActions.continue"),action:"create-pr",variant:"special",tooltip:a("thread.headerActions.openNewPrTooltip"),menu:Ut(cs([],i,a),h,a)}:{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.prMergedTooltip",{prNumber:String(i.number),base:i.base}),menu:Ut(cs([],i,a),h,a)};if(h.aheadOfBase>0){if(i&&i.state==="closed"&&!i.merged)return{label:a("thread.headerActions.reopenPr"),action:"reopen",variant:"default",tooltip:a("thread.headerActions.reopenPrTooltip",{prNumber:String(i.number)}),menu:Ut(cs([],i,a),h,a)};if(!i)return{label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:Ut([oa(a)],h,a)};if((n?.mergeableState??"unknown")==="dirty")return{label:a("thread.cmsActions.getLatest"),action:"rebase",variant:"default",tooltip:a("thread.cmsActions.getLatestTooltip"),menu:[{key:"resolve-on-provider",label:a("thread.cmsActions.resolveOnProvider"),action:"open-pr-page"}]};const d=r.filter(Co).length,_=r.filter(Rh).map(f=>f.name);if(d===0&&_.length>0)return{label:a("thread.headerActions.fixChecks"),action:"fix-checks",variant:"default",tooltip:a("thread.headerActions.failingChecksTooltip",{checks:_.join(", ")}),meta:{failingChecks:_},menu:Ut(cs([{key:"publish-anyway",label:a("thread.headerActions.publishAnyway"),action:"merge",tooltip:a("thread.headerActions.squashMergeTooltip",{prNumber:String(i.number),base:i.base})}],i,a),h,a)};if(n?.draft)return Ki({label:a("thread.headerActions.markReady"),action:"mark-ready",variant:"default",tooltip:a("thread.headerActions.markDraftReadyTooltip"),menu:Ut(cs([],i,a),h,a)},r,a);const m=n?.unresolvedConversations??0;return m>0?Ki({label:a("thread.headerActions.addressFeedback"),action:"resolve-comments",variant:"default",tooltip:a("thread.headerActions.unresolvedConversationsTooltip",{count:String(m)}),menu:Ut(cs([],i,a),h,a)},r,a):n?.missingRequiredApprovals?Ki({label:a("thread.cmsActions.waitingForReview"),action:"open-pr-page",variant:"outline",tooltip:a("thread.headerActions.waitingForApprovalsTooltip"),menu:Ut(cs([],i,a),h,a)},r,a):Ki({label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",meta:{publishPolicyOverride:"open"},menu:Ut(cs([{key:"review",label:a("thread.headerActions.review"),action:"review"}],i,a),h,a)},r,a)}return h.behindBase>0?{label:a("thread.cmsActions.getLatest"),action:"sync",variant:"default",tooltip:a("thread.cmsActions.getLatestTooltip"),menu:[]}:{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.branchInSyncTooltip",{base:h.base}),menu:[]}}function aa(t){return{key:"view-change-request",label:t("thread.cmsActions.viewOnProvider"),action:"open-pr"}}function qi(t,e,s){return e.kind!=="ready"||e.behindBase<=0?t:[...t,{key:"get-latest",label:s("thread.cmsActions.getLatest"),action:"get-latest",tooltip:s("thread.cmsActions.getLatestTooltip")}]}function la(t,e,s,i){const r=e.length;if(r===0)return t;if(e.filter(Co).length>0){const a=e.filter(l=>l.status==="completed").length,h=i("thread.cmsActions.checksRunning",{done:a,total:r});return s==="loading"?{...t,loading:!0,tooltip:h}:{...t,tooltip:h}}const o=e.filter(Rh).length;return o>0?{...t,variant:"warning",tooltip:i("thread.cmsActions.checksFailing",{failed:o,total:r})}:t}function qf(t,e){return!!(t?.merged&&t.headSha&&e.kind==="ready"&&!e.workingTreeDirty&&e.headSha===t.headSha)}function Vf(t){return Qi(t.prQuery)?!0:t.pr?.state!=="open"||t.pr.merged?!1:Qi(t.checksQuery)||Qi(t.reviewsQuery)}function Yf(t,e){return t.workingTreeDirty?!0:e!==null?e>0:t.aheadOfBase>0}function Gf(t,e){if(!t)return{branchMeta:{kind:"unknown"},publishableChangeCount:null};const s=Object.keys(t.changes).length;return{branchMeta:{kind:"ready",branch:e,base:t.base.resolvedRef??"main",workingTreeDirty:!1,unpushed:0,aheadOfBase:s,behindBase:0,headSha:t.revision},publishableChangeCount:s}}function Xf(t){return{...t,menu:[]}}function Jf(t){const{branch:e,pr:s,checks:i,reviews:r,publishing:n,saving:o,loading:a,publishableChangeCount:h,t:l}=t;if(e.kind!=="ready"&&t.statusError)return{label:l("thread.cmsActions.retry"),action:"retry-status",variant:"outline",disabled:t.statusRetrying,loading:t.statusRetrying,tooltip:t.statusError,menu:[]};if(a||e.kind!=="ready")return{label:l("thread.headerActions.loading"),variant:"outline",disabled:!0,loading:!0,menu:[]};if(n)return{label:l("thread.cmsActions.publishing"),variant:"outline",disabled:!0,loading:!0,menu:[]};if(t.syncing)return{label:l("thread.cmsActions.gettingLatest"),variant:"outline",disabled:!0,loading:!0,menu:[]};if(o)return{label:l("thread.headerActions.saving"),variant:"outline",disabled:!0,loading:!0,menu:[]};if(s&&s.state==="open"&&!s.merged?s:null){const d=r?.mergeableState??"unknown";return d==="dirty"?{label:l("thread.cmsActions.getLatest"),action:"get-latest",variant:"default",tooltip:l("thread.cmsActions.getLatestTooltip"),menu:[{key:"resolve-on-provider",label:l("thread.cmsActions.resolveOnProvider"),action:"open-pr"}]}:d==="blocked"||r?.draft?la({label:l("thread.cmsActions.waitingForReview"),action:"open-pr",variant:"outline",menu:qi([aa(l)],e,l)},i,"loading",l):la({label:l("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:qi([aa(l)],e,l)},i,"none",l)}return qf(s,e)?{label:l("thread.headerActions.upToDate"),variant:"outline",disabled:!0,menu:qi([],e,l)}:Yf(e,h)?{label:l("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:qi([{key:"request-approval",label:l("thread.headerActions.submitForReview"),action:"request-approval"}],e,l)}:e.behindBase>0?{label:l("thread.cmsActions.getLatest"),action:"get-latest",variant:"default",tooltip:l("thread.cmsActions.getLatestTooltip"),menu:[],autoRun:e.aheadOfBase===0}:{label:l("thread.headerActions.upToDate"),variant:"outline",disabled:!0,menu:[]}}function Zf(t){return t.conflicting===!0?"dirty":t.conflicting===null?"unknown":t.reviewBlocked||t.unresolvedConversations>0?"blocked":"clean"}function Bh(t){const e=F.c(4);let s;e[0]!==t?(s=md(t),e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i={...s,select:Qf},e[2]=s,e[3]=i):i=e[3],Is(i)}function Qf(t){const e=t.changeRequest;return e?{draft:e.draft,mergeableState:Zf(e),unresolvedConversations:e.unresolvedConversations,missingRequiredApprovals:e.reviewBlocked}:null}function ha(t,e){return t==="open-pr"||e==="resolve-on-provider"?c.jsx(Hl,{size:16}):t==="publish"?c.jsx(Al,{className:"size-4"}):t==="get-latest"||t==="retry-status"?c.jsx(mi,{className:"size-4"}):c.jsx(yr,{className:"size-4"})}function e_(t){const e=F.c(70),{virtualMcpId:s}=t,i=ge(),{org:r}=ki(),n=br(),o=Cr(s),{data:a}=vr.useSession(),{deleteRelease:h}=ao(s),{currentBranch:l,setCurrentTaskBranch:u,taskId:d,createTask:_}=Sl();let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={open:!1,mode:"publish"},e[0]=m):m=e[0];const[f,p]=V.useState(m);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=Y=>p({open:!0,mode:Y}),e[1]=g):g=e[1];const v=g,C=Il(o),S=C.status==="attached"||C.status==="public-clone"?C.repo:null,{previewServerUrl:b}=kr(s);let w;if(e[2]!==l||e[3]!==r.slug||e[4]!==s){const Y=l?vl(bl(r.slug,s,l)):null;w=Y?Wl(Y.path,Y.params):"/",e[2]=l,e[3]=r.slug,e[4]=s,e[5]=w}else w=e[5];const x=w;let D;e[6]!==l||e[7]!==x||e[8]!==r.slug||e[9]!==b||e[10]!==s?(D=l?{orgSlug:r.slug,virtualMcpId:s,branch:l,previewServerUrl:b,path:x}:null,e[6]=l,e[7]=x,e[8]=r.slug,e[9]=b,e[10]=s,e[11]=D):D=e[11];const E=vd(D);let I;e[12]!==l||e[13]!==r.slug||e[14]!==s?(I=l?{orgSlug:r.slug,virtualMcpId:s,branch:l}:null,e[12]=l,e[13]=r.slug,e[14]=s,e[15]=I):I=e[15];const y=bd(I),B=Zs(s,l),R=B.kind==="protocol"&&B.source==="github";let k;e[16]!==l||e[17]!==r.slug||e[18]!==s?(k=l?{orgSlug:r.slug,virtualMcpId:s,branch:l}:null,e[16]=l,e[17]=r.slug,e[18]=s,e[19]=k):k=e[19];const A=Jn(k),M=yl(R?B:null,A),P=l??"",T=d??null;let N;e[20]!==r.slug||e[21]!==P||e[22]!==T||e[23]!==s?(N=Yl({orgSlug:r.slug,virtualMcpId:s,branch:P,threadId:T}),e[20]=r.slug,e[21]=P,e[22]=T,e[23]=s,e[24]=N):N=e[24];const z=!!l&&B.kind!=="pending"&&!R;let H;e[25]!==z||e[26]!==N?(H={...N,enabled:z},e[25]=z,e[26]=N,e[27]=H):H=e[27];const W=Is(H),ee=R?null:W.data??null,$=R?Gf(M.data,l??""):null,K=$?$.branchMeta:ee?{kind:"ready",branch:mo(ee)??l??"",base:ee.base??"main",workingTreeDirty:Fd(ee),unpushed:ee.unpushed??0,aheadOfBase:ee.aheadOfBase??0,behindBase:ee.behindBase??0,headSha:ee.headSha??""}:{kind:"unknown"},Z=$?$.publishableChangeCount:ee?.changedFiles?ph({files:ee.changedFiles}).count:null,G=R?M:W,q=(K.kind==="ready"?K.branch:null)??l??null,te=K.kind==="ready"?K.base:"main",X=Ol({orgId:r.id,orgSlug:r.slug,target:Lt(S),owner:S?.owner??"",repo:S?.name??"",branch:q}),J=X.data??null,se=jl({orgId:r.id,orgSlug:r.slug,target:Lt(S),owner:S?.owner??"",repo:S?.name??"",base:te}),ce=Fl({orgId:r.id,orgSlug:r.slug,target:Lt(S),owner:S?.owner??"",repo:S?.name??"",branch:q}),U=Bh({orgId:r.id,orgSlug:r.slug,target:Lt(S),owner:S?.owner??"",repo:S?.name??"",branch:q});let ve;e[28]!==ce||e[29]!==J||e[30]!==X||e[31]!==U?(ve=Vf({pr:J,prQuery:X,checksQuery:ce,reviewsQuery:U}),e[28]=ce,e[29]=J,e[30]=X,e[31]=U,e[32]=ve):ve=e[32];const me=ve;let Me;e[33]!==X?(Me=async()=>{await X.refetch()},e[33]=X,e[34]=Me):Me=e[34];const Ve=Me,le=Lo({mutationFn:async()=>{const Y=l;await u(lo(ho(a?.user))),Y&&Y!==te&&await h(Y)},onError:i_});let ae;e[35]!==r.slug||e[36]!==d||e[37]!==s?(ae=async Y=>(await Vl({orgSlug:r.slug,virtualMcpId:s,branch:Y.branch,threadId:d??null},Y.base),Y),e[35]=r.slug,e[36]=d,e[37]=s,e[38]=ae):ae=e[38];let re;e[39]!==l||e[40]!==r.slug||e[41]!==n||e[42]!==i||e[43]!==d||e[44]!==s?(re=async Y=>{Je.success(i("thread.headerActions.syncedWithBase",{base:Y.base})),await Promise.all([n.invalidateQueries({queryKey:Jl({orgSlug:r.slug,virtualMcpId:s,branch:l??Y.branch,threadId:d??null})}),n.invalidateQueries({queryKey:Js.decofile(`${r.slug}/${s}/${Y.branch}`)})])},e[39]=l,e[40]=r.slug,e[41]=n,e[42]=i,e[43]=d,e[44]=s,e[45]=re):re=e[45];let lt;e[46]!==ae||e[47]!==re?(lt={mutationFn:ae,onSuccess:re,onError:s_},e[46]=ae,e[47]=re,e[48]=lt):lt=e[48];const be=Lo(lt),_t=xl(r.slug,s),ht=le.isPending,mt=Jf({branch:K,pr:J,checks:ce.data??[],reviews:U.data??null,publishing:ht,saving:_t,syncing:be.isPending,statusRetrying:G.isFetching&&!!G.error,statusError:G.error instanceof Error?G.error.message:G.error?String(G.error):null,loading:!!me,publishableChangeCount:Z,t:i}),Oe=R?Xf(mt):mt,fe=Oe.autoRun&&K.kind==="ready"&&S&&b?`${q}@${K.headSha}`:null,pt=V.useRef(null);if(V.useEffect(()=>{!fe||!q||pt.current!==fe&&(pt.current=fe,be.mutate({branch:q,base:te}))},[fe,q,te,be]),C.status==="detached"){let Y;e[49]!==i?(Y=i("thread.headerActions.reconnectGithub"),e[49]=i,e[50]=Y):Y=e[50];let de;e[51]!==Y?(de=c.jsx(rt,{asChild:!0,children:c.jsx("span",{children:c.jsx(_e,{size:"sm",variant:"outline",disabled:!0,children:Y})})}),e[51]=Y,e[52]=de):de=e[52];let ke;e[53]!==i?(ke=i("thread.headerActions.githubConnectionRemoved"),e[53]=i,e[54]=ke):ke=e[54];let De;e[55]!==ke?(De=c.jsx(nt,{children:ke}),e[55]=ke,e[56]=De):De=e[56];let Qe;return e[57]!==de||e[58]!==De?(Qe=c.jsx(Sr,{children:c.jsxs(it,{children:[de,De]})}),e[57]=de,e[58]=De,e[59]=Qe):Qe=e[59],Qe}if(!o)return null;if(!S||!b){const Y=S?"noPreviewServer":"noRepo";let de;e[60]!==l||e[61]!==_?(de=l?()=>{const De=_?.({runtime:"sandbox",branch:l});De&&Dc("coding_session_started",{thread_id:De})}:void 0,e[60]=l,e[61]=_,e[62]=de):de=e[62];let ke;return e[63]!==Y||e[64]!==de?(ke=c.jsx(r_,{reason:Y,onStartCodingSession:de}),e[63]=Y,e[64]=de,e[65]=ke):ke=e[65],ke}if(!l)return null;const gt=Y=>{switch(Y){case"publish":{v("publish");return}case"request-approval":{v("review");return}case"get-latest":{if(!q||be.isPending)return;be.mutate({branch:q,base:te});return}case"retry-status":{G.refetch();return}case"open-pr":{J?.htmlUrl&&window.open(J.htmlUrl,"_blank","noopener,noreferrer");return}}};let vt;e[66]!==gt?(vt=Y=>({key:Y.key,label:Y.label,icon:ha(Y.action,Y.key),...Y.tooltip?{tooltip:Y.tooltip}:{},onSelect:()=>gt(Y.action)}),e[66]=gt,e[67]=vt):vt=e[67];const bt=Oe.menu.map(vt),je=Oe.action,Ze=Oe.label,Ye=Oe.variant,ct=!!Oe.loading;let Te;e[68]!==i?(Te=i("thread.cmsActions.moreActionsAriaLabel"),e[68]=i,e[69]=Te):Te=e[69];const Rt=c.jsx(ih,{size:"sm",label:Ze,variant:Ye,disabled:!!Oe.disabled||!je,loading:ct,...je&&!Oe.loading?{icon:ha(je)}:{},...Oe.tooltip?{tooltip:Oe.tooltip}:{},items:bt,menuAriaLabel:Te,onClick:je?()=>gt(je):void 0});return c.jsxs(c.Fragment,{children:[Rt,l?c.jsx(kh,{open:f.open,mode:f.mode,fastPreview:!0,onOpenChange:Y=>{Y||p(t_)},orgSlug:r.slug,virtualMcpId:s,branch:l,baseBranch:te,repoTarget:Lt(S),owner:S.owner,repo:S.name,publishPolicy:Xl(o?.metadata?.publishPolicy),draftPreviewUrl:E.url,destinationHost:E.host,previewServerUrl:b,compareDraft:y?{kind:"pointer",pointer:y}:null,lastPublishedPr:se.data??null,onRequestApproval:()=>v("review"),openPullRequest:J?.state==="open"?J:null,onPullRequestChanged:Ve,onPublished:()=>le.mutateAsync()}):null]})}function t_(t){return{...t,open:!1}}function s_(t){Je.error(t instanceof Error?t.message:String(t))}function i_(t){console.error("site editor: settling after publish failed",t)}function r_(t){const e=F.c(14),{reason:s,onStartCodingSession:i}=t,r=ge(),n=!i;let o;e[0]!==r?(o=r("sandbox.cmsUnavailable.startCodingSession"),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==o?(a=c.jsx(rt,{asChild:!0,children:c.jsx("span",{children:c.jsx(_e,{size:"sm",variant:"outline",disabled:n,onClick:i,children:o})})}),e[2]=i,e[3]=n,e[4]=o,e[5]=a):a=e[5];let h;e[6]!==s||e[7]!==r?(h=r(s==="noPreviewServer"?"sandbox.cmsUnavailable.noPreviewServer":"sandbox.cmsUnavailable.noRepo"),e[6]=s,e[7]=r,e[8]=h):h=e[8];let l;e[9]!==h?(l=c.jsx(nt,{children:h}),e[9]=h,e[10]=l):l=e[10];let u;return e[11]!==a||e[12]!==l?(u=c.jsx(Sr,{children:c.jsxs(it,{children:[a,l]})}),e[11]=a,e[12]=l,e[13]=u):u=e[13],u}const Os="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 n_(t){return`Reopen PR #${t.prNumber}. ${Os}`}function o_(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${Os}`}function a_(t){return`Sync \`${t.branch}\` with everyone else's work: \`git add -A\`, commit any pending local changes with a concise conventional-commit message (skip if the working tree is clean), \`git pull --rebase\` to bring in anything pushed directly to \`origin/${t.branch}\`, then \`git rebase origin/${t.base}\` to catch up with the base branch. Resolve any conflicts that come up, then push the result (force-with-lease only if the rebase rewrote commits already on the remote). ${Os}`}function l_(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. ${Os}`}function h_(t){return`Mark PR #${t.prNumber} ready for review. ${Os}`}function c_(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. ${Os}`}function d_(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. ${Os}`}function ca(t){switch(t){case"publish":return c.jsx(Al,{className:"size-4"});case"create-pr":case"reopen":return c.jsx(yr,{className:"size-4"});case"rebase":case"sync":return c.jsx(mi,{className:"size-4"});case"fix-checks":return c.jsx(gl,{className:"size-4"});case"mark-ready":return c.jsx(uo,{className:"size-4"});case"resolve-comments":return c.jsx(id,{className:"size-4"});case"merge":return c.jsx(Rd,{className:"size-4"});case"review":return c.jsx(Kl,{className:"size-4"});case"open-pr-page":return c.jsx(Hl,{size:16})}}const da=new Set(["reopen","rebase","fix-checks","mark-ready","resolve-comments","review","sync"]),ua=new Set(["publish","create-pr"]);function u_(t){const e=F.c(44),{t:s,button:i,actionBusy:r,changeRequestPending:n,savePending:o,onAction:a}=t,h=i.action;let l;e[0]!==h||e[1]!==r?(l=r&&h!==void 0&&da.has(h),e[0]=h,e[1]=r,e[2]=l):l=e[2];const u=l,d=n&&h==="merge";let _;e[3]!==h||e[4]!==o?(_=o&&h!==void 0&&ua.has(h),e[3]=h,e[4]=o,e[5]=_):_=e[5];const m=_,f=!!i.disabled||u||d||m||!h,p=!!i.loading||d;let g;e[6]!==i.tooltip||e[7]!==u||e[8]!==m||e[9]!==s?(g=u?s("thread.headerActions.chatIsRunning"):m?s("thread.headerActions.saving"):i.tooltip,e[6]=i.tooltip,e[7]=u,e[8]=m,e[9]=s,e[10]=g):g=e[10];const v=g;let C;if(e[11]!==r||e[12]!==i.menu||e[13]!==n||e[14]!==a||e[15]!==o||e[16]!==s){let B;e[18]!==r||e[19]!==n||e[20]!==a||e[21]!==o||e[22]!==s?(B=R=>{const k=r&&da.has(R.action),A=o&&ua.has(R.action),M=R.action==="merge"&&n,P=A?s("thread.headerActions.saving"):k?s("thread.headerActions.chatIsRunning"):R.tooltip;return{key:R.key,label:R.label,icon:ca(R.action),disabled:!!(k||A||M),...P?{tooltip:P}:{},onSelect:()=>a(R.action)}},e[18]=r,e[19]=n,e[20]=a,e[21]=o,e[22]=s,e[23]=B):B=e[23],C=i.menu.map(B),e[11]=r,e[12]=i.menu,e[13]=n,e[14]=a,e[15]=o,e[16]=s,e[17]=C}else C=e[17];const S=C,b=i.label,w=i.variant;let x;e[24]!==h||e[25]!==p?(x=h&&!p?{icon:ca(h)}:{},e[24]=h,e[25]=p,e[26]=x):x=e[26];let D;e[27]!==v?(D=v?{tooltip:v}:{},e[27]=v,e[28]=D):D=e[28];let E;e[29]!==s?(E=s("thread.headerActions.moreActionsAriaLabel"),e[29]=s,e[30]=E):E=e[30];let I;e[31]!==h||e[32]!==a?(I=h?()=>a(h):void 0,e[31]=h,e[32]=a,e[33]=I):I=e[33];let y;return e[34]!==i.label||e[35]!==i.variant||e[36]!==f||e[37]!==S||e[38]!==p||e[39]!==x||e[40]!==D||e[41]!==E||e[42]!==I?(y=c.jsx(ih,{size:"sm",label:b,variant:w,disabled:f,loading:p,...x,...D,items:S,menuAriaLabel:E,onClick:I}),e[34]=i.label,e[35]=i.variant,e[36]=f,e[37]=S,e[38]=p,e[39]=x,e[40]=D,e[41]=E,e[42]=I,e[43]=y):y=e[43],y}function f_(t){const e=F.c(9),{label:s,children:i}=t;if(!s){let a;return e[0]!==i?(a=c.jsx(c.Fragment,{children:i}),e[0]=i,e[1]=a):a=e[1],a}let r;e[2]!==i?(r=c.jsx(rt,{asChild:!0,children:c.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=c.jsx(nt,{children:s}),e[4]=s,e[5]=n):n=e[5];let o;return e[6]!==r||e[7]!==n?(o=c.jsx(Sr,{children:c.jsxs(it,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=o):o=e[8],o}function __(t){return{label:t("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:t("thread.headerActions.waitingForSandboxBranchTooltip"),menu:[]}}function m_({virtualMcpId:t}){const e=ge(),{org:s}=ki(),{data:i}=vr.useSession(),r=Cr(t),{deleteRelease:n}=ao(t),{currentBranch:o,setCurrentTaskBranch:a,createTask:h,taskId:l}=Sl(),u=Ic(),{openSidePanel:d}=Gc(),[_,m]=V.useState({open:!1,mode:"publish",policyOverride:null}),f=Zd({connectionId:Ac,orgId:s.id,orgSlug:s.slug}),p=Qd(f),[g,v]=V.useState(!1),C=V.useRef(""),S=Il(r),b=S.status==="attached"||S.status==="public-clone"?S.repo:null,{lifecycle:w,branch:x,phase:D}=Pr(),E={orgSlug:s.slug,virtualMcpId:t,branch:o??"",threadId:l??null},y=Is({queryKey:Jl(E),queryFn:()=>fo(E),enabled:!!o,staleTime:15e3,refetchInterval:ae=>Fr(ae.state.data)?5e3:!1}).data??null,B=x,R=w,k=B.kind==="ready"?B.branch:null,A=o??k??void 0,M=(B.kind==="ready"?B.branch:null)??A??null,P=Ol({orgId:s.id,orgSlug:s.slug,target:Lt(b),owner:b?.owner??"",repo:b?.name??"",branch:M}),T=P.data??null,N=Fl({orgId:s.id,orgSlug:s.slug,target:Lt(b),owner:b?.owner??"",repo:b?.name??"",branch:M}),z=Bh({orgId:s.id,orgSlug:s.slug,target:Lt(b),owner:b?.owner??"",repo:b?.name??"",branch:M}),H=jl({orgId:s.id,orgSlug:s.slug,target:Lt(b),owner:b?.owner??"",repo:b?.name??"",base:B.kind==="ready"?B.base:null}),W=B,ee=Xl(r?.metadata?.publishPolicy),$=xl(s.slug,t),{previewUrl:K}=th(),{previewServerUrl:Z,projectDefault:G}=kr(t);if(S.status==="detached")return c.jsx(f_,{label:e("thread.headerActions.githubConnectionRemoved"),children:c.jsx(_e,{size:"sm",variant:"outline",disabled:!0,children:e("thread.headerActions.reconnectGithub")})});if(!b)return null;const q=M?Kf({lifecycle:R,branch:W,claimPhase:D,pr:T,checks:N.data??[],reviews:z.data??null,noReviewableDiff:Fr(y),loading:Qi(P),t:e}):__(e),te=JSON.stringify({label:q.label,branchKind:W.kind,workingTreeDirty:W.kind==="ready"?W.workingTreeDirty:null,unpushed:W.kind==="ready"?W.unpushed:null,aheadOfBase:W.kind==="ready"?W.aheadOfBase:null,lifecycle:R.phase,headBranch:M,noReviewableDiff:Fr(y)});C.current!==te&&(C.current=te,eh("header button",{label:q.label,tooltip:q.tooltip,action:q.action,chatBranch:o,sandboxBranch:k,sandboxRouteBranch:A,headBranch:M,branchMeta:B,effectiveBranchMeta:W,lifecyclePhase:R.phase,prNumber:T?.number??null,prState:T?.state??null}));const X=ae=>(d(),u.sendMessage({parts:[{type:"text",text:ae}]})),J=u.isStreaming,se=W.kind==="ready"?W.base:"main",ce=async()=>{await P.refetch()},U=async()=>{const ae=o,re=lo(ho(i?.user));G==="cms"?h({runtime:"cms",branch:re}):await a(re),ae&&ae!==se&&await n(ae)},ve=async ae=>{if(!(!b||g)){v(!0);try{const re=rh(i?.user);await ah(s.slug,Lt(b),{number:ae,coAuthor:re}),Je.success(e("thread.headerActions.publishedPr",{prNumber:String(ae)})),await ce(),await U()}catch(re){Je.error(re instanceof oh?re.detail??Au(re.reason,e):re instanceof Error?re.message:e("thread.headerActions.failedToMergePullRequest"))}finally{v(!1)}}},me=(ae,re)=>m({open:!0,mode:ae,policyOverride:re}),Me=ae=>{if(M)switch(ae){case"publish":me("publish",q.meta?.publishPolicyOverride??null);return;case"create-pr":me("review",null);return;case"merge":T&&ve(T.number);return;case"sync":if(J)return;X(a_({branch:M,base:se}));return;case"open-pr-page":T?.htmlUrl&&window.open(T.htmlUrl,"_blank","noopener,noreferrer");return;case"review":if(J)return;T&&X(d_({prNumber:T.number}));return;case"reopen":if(J)return;T&&X(n_({prNumber:T.number}));return;case"rebase":if(J)return;X(o_({branch:M}));return;case"fix-checks":if(J)return;T&&X(l_({prNumber:T.number,failingChecks:q.meta?.failingChecks??[]}));return;case"mark-ready":if(J)return;T&&X(h_({prNumber:T.number}));return;case"resolve-comments":if(J)return;T&&X(c_({prNumber:T.number}));return}},Ve=g||J,le=c.jsx(u_,{t:e,button:q,actionBusy:Ve,changeRequestPending:g,savePending:$,onAction:Me});return A?c.jsxs(c.Fragment,{children:[le,c.jsx(kh,{open:_.open,mode:_.mode,fastPreview:!1,recoverSandbox:()=>p.mutateAsync({virtualMcpId:t,branch:A,...l?{threadId:l}:{}}),onOpenChange:ae=>{ae||m(re=>({...re,open:!1}))},orgSlug:s.slug,virtualMcpId:t,branch:A,baseBranch:se,repoTarget:Lt(b),owner:b.owner,repo:b.name,publishPolicy:_.policyOverride??ee,draftPreviewUrl:K,destinationHost:null,previewServerUrl:Z,compareDraft:K?{kind:"sandbox",previewUrl:K}:null,lastPublishedPr:H.data??null,onRequestApproval:()=>m(ae=>({...ae,open:!0,mode:"review"})),openPullRequest:T?.state==="open"?T:null,onPullRequestChanged:ce,onPublished:U})]}):le}const p_=new Set(["site-editor","content"]);function g_(t){return t.hasClonableSource&&!t.fastPreviewActive&&t.mainTab!==null&&p_.has(t.mainTab)}const As="setup";function v_(t){const e=F.c(57),s=ge();let i;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let b;e[3]!==t.scriptTabs?(b=w=>!t.scriptTabs.includes(w),e[3]=t.scriptTabs,e[4]=b):b=e[4],i=t.scripts.filter(b),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=i}else i=e[2];const r=i;let n;e[5]!==t?(n=()=>{t.active===As?t.onToggle():t.onSelectTab(As)},e[5]=t,e[6]=n):n=e[6];const o=n;let a;e[7]!==t.open||e[8]!==s?(a=t.open?s("sandbox.preview.collapseTerminal"):s("sandbox.preview.expandTerminal"),e[7]=t.open,e[8]=s,e[9]=a):a=e[9];let h;e[10]!==t.open?(h=t.open?c.jsx(wr,{className:"size-4"}):c.jsx(Qc,{className:"size-4"}),e[10]=t.open,e[11]=h):h=e[11];let l;e[12]!==t.onToggle||e[13]!==t.open||e[14]!==a||e[15]!==h?(l=c.jsx(rt,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon-sm",onClick:t.onToggle,"aria-label":a,"aria-expanded":t.open,className:"size-6 shrink-0",children:h})}),e[12]=t.onToggle,e[13]=t.open,e[14]=a,e[15]=h,e[16]=l):l=e[16];let u;e[17]!==t.open||e[18]!==s?(u=t.open?s("sandbox.preview.collapseTerminal"):s("sandbox.preview.expandTerminal"),e[17]=t.open,e[18]=s,e[19]=u):u=e[19];let d;e[20]!==u?(d=c.jsx(nt,{children:u}),e[20]=u,e[21]=d):d=e[21];let _;e[22]!==l||e[23]!==d?(_=c.jsxs(it,{children:[l,d]}),e[22]=l,e[23]=d,e[24]=_):_=e[24];const m=t.active===As;let f;e[25]!==o||e[26]!==t.open||e[27]!==s||e[28]!==m?(f=c.jsx(b_,{active:m,open:t.open,onClick:o,t:s}),e[25]=o,e[26]=t.open,e[27]=s,e[28]=m,e[29]=f):f=e[29];let p;e[30]!==t||e[31]!==s?(p=t.scriptTabs.map(b=>c.jsx(w_,{active:t.active===b,onClick:()=>{t.active===b?t.onToggle():t.onSelectTab(b)},onClose:()=>t.onCloseScript(b),t:s,children:b},b)),e[30]=t,e[31]=s,e[32]=p):p=e[32];let g;e[33]!==r||e[34]!==t.onAddScript?(g=c.jsx(y_,{scripts:r,onRun:t.onAddScript}),e[33]=r,e[34]=t.onAddScript,e[35]=g):g=e[35];let v;e[36]!==p||e[37]!==g||e[38]!==f?(v=c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[f,p,g]}),e[36]=p,e[37]=g,e[38]=f,e[39]=v):v=e[39];let C;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?(C=t.showScriptControls?c.jsx(x_,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript,t:s}):c.jsx(S_,{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]=C):C=e[52];let S;return e[53]!==v||e[54]!==C||e[55]!==_?(S=c.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-2",children:[_,v,C]}),e[53]=v,e[54]=C,e[55]=_,e[56]=S):S=e[56],S}function b_(t){const e=F.c(11),{active:s,open:i,onClick:r,t:n}=t,o=s&&i,a=s&&i,h=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let l;e[0]!==h?(l=ie("flex h-6 items-center gap-1.5 rounded-lg border px-2 text-xs",h),e[0]=h,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx(Bd,{className:"size-4"}),e[2]=u):u=e[2];let d;e[3]!==n?(d=n("sandbox.toolbar.setupTab"),e[3]=n,e[4]=d):d=e[4];let _;return e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==l||e[9]!==d?(_=c.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:l,children:[u,d]}),e[5]=r,e[6]=o,e[7]=a,e[8]=l,e[9]=d,e[10]=_):_=e[10],_}function S_(t){const e=F.c(40),{status:s,onStart:i,onStop:r,onRestart:n,onResume:o,onRetry:a,t:h}=t;if(s==="idle"&&i){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(lr,{className:"size-3.5"}),e[0]=l):l=e[0];let u;e[1]!==h?(u=h("sandbox.toolbar.start"),e[1]=h,e[2]=u):u=e[2];let d;return e[3]!==i||e[4]!==u?(d=c.jsxs(_e,{variant:"outline",size:"xs",onClick:i,children:[l," ",u]}),e[3]=i,e[4]=u,e[5]=d):d=e[5],d}if(s==="suspended"&&o){let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(lr,{className:"size-3.5"}),e[6]=l):l=e[6];let u;e[7]!==h?(u=h("sandbox.toolbar.resume"),e[7]=h,e[8]=u):u=e[8];let d;return e[9]!==o||e[10]!==u?(d=c.jsxs(_e,{variant:"outline",size:"xs",onClick:o,children:[l," ",u]}),e[9]=o,e[10]=u,e[11]=d):d=e[11],d}if(s==="errored"&&a){let l;e[12]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(mi,{className:"size-3.5"}),e[12]=l):l=e[12];let u;e[13]!==h?(u=h("sandbox.toolbar.retry"),e[13]=h,e[14]=u):u=e[14];let d;return e[15]!==a||e[16]!==u?(d=c.jsxs(_e,{variant:"outline",size:"xs",onClick:a,children:[l," ",u]}),e[15]=a,e[16]=u,e[17]=d):d=e[17],d}if(s==="starting"||s==="running"){const l=s==="running"&&!!n,u=l?"rounded-r-none border-r-0":void 0;let d;e[18]!==u?(d=ie(u),e[18]=u,e[19]=d):d=e[19];let _;e[20]!==h?(_=h("sandbox.toolbar.stop"),e[20]=h,e[21]=_):_=e[21];let m;e[22]!==r||e[23]!==d||e[24]!==_?(m=c.jsx(rt,{asChild:!0,children:c.jsx(_e,{variant:"outline",size:"xs",onClick:r,className:d,children:_})}),e[22]=r,e[23]=d,e[24]=_,e[25]=m):m=e[25];let f;e[26]!==h?(f=h("sandbox.toolbar.stopSandboxTooltip"),e[26]=h,e[27]=f):f=e[27];let p;e[28]!==f?(p=c.jsx(nt,{children:f}),e[28]=f,e[29]=p):p=e[29];let g;e[30]!==m||e[31]!==p?(g=c.jsxs(it,{children:[m,p]}),e[30]=m,e[31]=p,e[32]=g):g=e[32];let v;e[33]!==n||e[34]!==l||e[35]!==h?(v=l&&c.jsxs(Ci,{children:[c.jsx(yi,{asChild:!0,children:c.jsx(_e,{variant:"outline",size:"xs",className:"rounded-l-none px-1","aria-label":h("sandbox.toolbar.moreActions"),children:c.jsx(wr,{className:"size-3"})})}),c.jsx(xi,{align:"end",children:c.jsxs(Ts,{onClick:n,children:[c.jsx(mi,{className:"size-3.5"})," ",h("sandbox.toolbar.restart")]})})]}),e[33]=n,e[34]=l,e[35]=h,e[36]=v):v=e[36];let C;return e[37]!==g||e[38]!==v?(C=c.jsxs("div",{className:"flex items-center",children:[g,v]}),e[37]=g,e[38]=v,e[39]=C):C=e[39],C}return null}function w_(t){const e=F.c(17),{active:s,onClick:i,onClose:r,children:n,t:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let h;e[0]!==a?(h=ie("flex h-6 items-center rounded-lg border text-xs",a),e[0]=a,e[1]=h):h=e[1];const l=r?"pl-2 pr-1":"px-2",u=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==l||e[3]!==u?(d=ie("flex h-full items-center",l,u),e[2]=l,e[3]=u,e[4]=d):d=e[4];let _;e[5]!==n||e[6]!==i||e[7]!==d?(_=c.jsx("button",{type:"button",onClick:i,className:d,children:n}),e[5]=n,e[6]=i,e[7]=d,e[8]=_):_=e[8];let m;e[9]!==n||e[10]!==r||e[11]!==o?(m=r&&c.jsx("button",{type:"button","aria-label":o("sandbox.toolbar.closeTab",{tab:String(n)}),onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:c.jsx(Mc,{className:"size-3.5"})}),e[9]=n,e[10]=r,e[11]=o,e[12]=m):m=e[12];let f;return e[13]!==h||e[14]!==_||e[15]!==m?(f=c.jsxs("div",{className:h,children:[_,m]}),e[13]=h,e[14]=_,e[15]=m,e[16]=f):f=e[16],f}function y_(t){const e=F.c(27),{scripts:s,onRun:i}=t,r=ge(),[n,o]=V.useState(!1);let a;e[0]!==r?(a=r("sandbox.toolbar.runScript"),e[0]=r,e[1]=a):a=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(oo,{className:"size-4"}),e[2]=h):h=e[2];let l;e[3]!==a?(l=c.jsx(rt,{asChild:!0,children:c.jsx(Pl,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"xs","aria-label":a,children:h})})}),e[3]=a,e[4]=l):l=e[4];let u;e[5]!==r?(u=r("sandbox.toolbar.runScript"),e[5]=r,e[6]=u):u=e[6];let d;e[7]!==u?(d=c.jsx(nt,{children:u}),e[7]=u,e[8]=d):d=e[8];let _;e[9]!==l||e[10]!==d?(_=c.jsxs(it,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=_):_=e[11];let m;e[12]!==r?(m=r("sandbox.toolbar.runAScript"),e[12]=r,e[13]=m):m=e[13];let f;e[14]!==m?(f=c.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:m}),e[14]=m,e[15]=f):f=e[15];let p;e[16]!==i||e[17]!==s||e[18]!==r?(p=s.length===0?c.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:r("sandbox.toolbar.noScriptsFound")}):s.map(C=>c.jsxs("button",{type:"button",onClick:()=>{o(!1),i(C)},className:"w-full rounded-lg px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",C]},C)),e[16]=i,e[17]=s,e[18]=r,e[19]=p):p=e[19];let g;e[20]!==f||e[21]!==p?(g=c.jsxs(El,{align:"start",className:"p-1 w-56",children:[f,p]}),e[20]=f,e[21]=p,e[22]=g):g=e[22];let v;return e[23]!==n||e[24]!==g||e[25]!==_?(v=c.jsxs(kl,{open:n,onOpenChange:o,children:[_,g]}),e[23]=n,e[24]=g,e[25]=_,e[26]=v):v=e[26],v}function x_(t){const e=F.c(30),{isRunning:s,isKilling:i,onRun:r,onStop:n,t:o}=t;if(i){let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsx(_i,{className:"size-3.5"}),e[0]=_):_=e[0];let m;e[1]!==o?(m=o("sandbox.toolbar.stopping"),e[1]=o,e[2]=m):m=e[2];let f;return e[3]!==m?(f=c.jsxs(_e,{variant:"outline",size:"xs",disabled:!0,children:[_," ",m]}),e[3]=m,e[4]=f):f=e[4],f}if(!s){let _;e[5]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsx(lr,{className:"size-3.5"}),e[5]=_):_=e[5];let m;e[6]!==o?(m=o("sandbox.toolbar.run"),e[6]=o,e[7]=m):m=e[7];let f;e[8]!==r||e[9]!==m?(f=c.jsx(rt,{asChild:!0,children:c.jsxs(_e,{variant:"outline",size:"xs",onClick:r,children:[_," ",m]})}),e[8]=r,e[9]=m,e[10]=f):f=e[10];let p;e[11]!==o?(p=o("sandbox.toolbar.startProcess"),e[11]=o,e[12]=p):p=e[12];let g;e[13]!==p?(g=c.jsx(nt,{children:p}),e[13]=p,e[14]=g):g=e[14];let v;return e[15]!==f||e[16]!==g?(v=c.jsxs(it,{children:[f,g]}),e[15]=f,e[16]=g,e[17]=v):v=e[17],v}let a;e[18]!==o?(a=o("sandbox.toolbar.stop"),e[18]=o,e[19]=a):a=e[19];let h;e[20]!==n||e[21]!==a?(h=c.jsx(rt,{asChild:!0,children:c.jsx(_e,{variant:"outline",size:"xs",onClick:n,children:a})}),e[20]=n,e[21]=a,e[22]=h):h=e[22];let l;e[23]!==o?(l=o("sandbox.toolbar.stopProcess"),e[23]=o,e[24]=l):l=e[24];let u;e[25]!==l?(u=c.jsx(nt,{children:l}),e[25]=l,e[26]=u):u=e[26];let d;return e[27]!==h||e[28]!==u?(d=c.jsxs(it,{children:[h,u]}),e[27]=h,e[28]=u,e[29]=d):d=e[29],d}var Dh=Object.defineProperty,C_=Object.getOwnPropertyDescriptor,k_=(t,e)=>{for(var s in e)Dh(t,s,{get:e[s],enumerable:!0})},Be=(t,e,s,i)=>{for(var r=i>1?void 0:i?C_(e,s):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(r=(i?o(e,s,r):o(r))||r);return i&&r&&Dh(e,s,r),r},j=(t,e)=>(s,i)=>e(s,i,t),fa="Terminal input",ln={get:()=>fa,set:t=>fa=t},_a="Too much output to announce, navigate to rows manually to read",hn={get:()=>_a,set:t=>_a=t};function P_(t){return t.replace(/\r?\n/g,"\r")}function E_(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function R_(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function B_(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Ah(r,e,s,i)}}function Ah(t,e,s,i){t=P_(t),t=E_(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Mh(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,n=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function ma(t,e,s,i,r){Mh(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Ss(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Dr(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let n=t[r];n>65535?(n-=65536,i+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):i+=String.fromCharCode(n)}return i}var D_=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let n=t.charCodeAt(r++);56320<=n&&n<=57343?e[i++]=(this._interim-55296)*1024+n-56320+65536:(e[i++]=this._interim,e[i++]=n),this._interim=0}for(let n=r;n<s;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=s)return this._interim=o,i;let a=t.charCodeAt(n);56320<=a&&a<=57343?e[i++]=(o-55296)*1024+a-56320+65536:(e[i++]=o,e[i++]=a);continue}o!==65279&&(e[i++]=o)}return i}},A_=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let _=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let f=0,p;for(;(p=this.interim[++f]&63)&&f<4;)m<<=6,m|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-f;for(;l<v;){if(l>=s)return 0;if(p=t[l++],(p&192)!==128){l--,_=!0;break}else this.interim[f++]=p,m<<=6,m|=p&63}_||(g===2?m<128?l--:e[i++]=m:g===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let u=s-4,d=l;for(;d<s;){for(;d<u&&!((r=t[d])&128)&&!((n=t[d+1])&128)&&!((o=t[d+2])&128)&&!((a=t[d+3])&128);)e[i++]=r,e[i++]=n,e[i++]=o,e[i++]=a,d+=4;if(r=t[d++],r<128)e[i++]=r;else if((r&224)===192){if(d>=s)return this.interim[0]=r,i;if(n=t[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}e[i++]=h}else if((r&240)===224){if(d>=s)return this.interim[0]=r,i;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=t[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;e[i++]=h}else if((r&248)===240){if(d>=s)return this.interim[0]=r,i;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,i;if(o=t[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,i;if(a=t[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;e[i++]=h}}return i}},Th="",ws=" ",Ei=class Nh{constructor(){this.fg=0,this.bg=0,this.extended=new ur}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 Nh;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}},ur=class Lh{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 Lh(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},It=class Ih extends Ei{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ur,this.combinedData=""}static fromCharData(e){let s=new Ih;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?Ss(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 i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-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()]}},pa="di$target",cn="di$dependencies",Ur=new Map;function M_(t){return t[cn]||[]}function qe(t){if(Ur.has(t))return Ur.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");T_(e,s,r)};return e._id=t,Ur.set(t,e),e}function T_(t,e,s){e[pa]===e?e[cn].push({id:t,index:s}):(e[cn]=[{id:t,index:s}],e[pa]=e)}var ot=qe("BufferService"),Oh=qe("CoreMouseService"),js=qe("CoreService"),N_=qe("CharsetService"),ko=qe("InstantiationService"),jh=qe("LogService"),at=qe("OptionsService"),Fh=qe("OscLinkService"),L_=qe("UnicodeService"),Ri=qe("DecorationService"),dn=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 i=[],r=this._optionsService.rawOptions.linkHandler,n=new It,o=s.getTrimmedLength(),a=-1,h=-1,l=!1;for(let u=0;u<o;u++)if(!(h===-1&&!s.hasContent(u))){if(s.loadCell(u,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=u,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&u===o-1){let d=this._oscLinkService.getLinkData(a)?.uri;if(d){let _={start:{x:h+1,y:t},end:{x:u+(!l&&u===o-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let f=new URL(d);["http:","https:"].includes(f.protocol)||(m=!0)}catch{m=!0}m||i.push({text:d,range:_,activate:(f,p)=>r?r.activate(f,p,_):I_(f,p),hover:(f,p)=>r?.hover?.(f,p,_),leave:(f,p)=>r?.leave?.(f,p,_)})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=u,a=n.extended.urlId):(h=-1,a=-1)}}e(i)}};dn=Be([j(0,ot),j(1,at),j(2,Fh)],dn);function I_(t,e){if(confirm(`Do you want to navigate to ${e}?
13
13
 
14
14
  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 Ar=qe("CharSizeService"),_s=qe("CoreBrowserService"),Po=qe("MouseService"),ms=qe("RenderService"),O_=qe("SelectionService"),Hh=qe("CharacterJoinerService"),Qs=qe("ThemeService"),zh=qe("LinkProviderService"),j_=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?ga.isErrorNoTelemetry(t)?new ga(t.message+`
15
15
 
@@ -24,4 +24,4 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
24
24
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),No&&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,i=this._model.finalSelectionEnd;return!s||!i||!e?!1:this._areCoordsInSelection(e,s,i)}isCellInSelection(t,e){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([t,e],s,i)}_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=Ia(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(t);return i?(this._selectWordAt(i,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=To(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,-Xr),Xr),e/=Xr,e/Math.abs(e)+Math.round(e*(Mp-1)))}shouldForceSelection(t){return mr?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(),Tp)}_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&&!(mr&&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 i=s.lines.get(this._model.selectionEnd[1]);i&&i.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<Np&&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 i=Cp(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!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 i=0;e>=i;i++){let r=t.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&e!==i&&(s+=r-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,i=!0){if(t[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(t[1]);if(!n)return;let o=r.translateBufferLineToString(t[1],!1),a=this._convertViewportColToCharacterIndex(n,t[0]),h=a,l=t[0]-a,u=0,d=0,_=0,m=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let g=t[0],v=t[0];n.getWidth(g)===0&&(u++,g--),n.getWidth(v)===2&&(d++,v++);let C=n.getString(v).length;for(C>1&&(m+=C-1,h+=C-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let S=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,g--):S>1&&(_+=S-1,a-=S-1),a--,g--}for(;v<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(v+1,this._workCell));){n.loadCell(v+1,this._workCell);let S=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,v++):S>1&&(m+=S-1,h+=S-1),h++,v++}}h++;let f=a+l-u+_,p=Math.min(this._bufferService.cols,h-a+u+d-_-m);if(!(!e&&o.slice(a,h).trim()==="")){if(s&&f===0&&n.getCodePoint(0)!==32){let g=r.lines.get(t[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let C=this._bufferService.cols-v.start;f-=C,p+=C}}}if(i&&f+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(t[1]+1);if(g?.isWrapped&&g.getCodePoint(0)!==32){let v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(p+=v.length)}}return{start:f,length:p}}}_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=Ia(s,this._bufferService.cols)}};Ln=Be([j(3,ot),j(4,js),j(5,Po),j(6,at),j(7,ms),j(8,_s)],Ln);var Oa=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={}}},ja=class{constructor(){this._color=new Oa,this._css=new Oa}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()}},Fe=Object.freeze((()=>{let t=[Ee.toColor("#2e3436"),Ee.toColor("#cc0000"),Ee.toColor("#4e9a06"),Ee.toColor("#c4a000"),Ee.toColor("#3465a4"),Ee.toColor("#75507b"),Ee.toColor("#06989a"),Ee.toColor("#d3d7cf"),Ee.toColor("#555753"),Ee.toColor("#ef2929"),Ee.toColor("#8ae234"),Ee.toColor("#fce94f"),Ee.toColor("#729fcf"),Ee.toColor("#ad7fa8"),Ee.toColor("#34e2e2"),Ee.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=e[s/36%6|0],r=e[s/6%6|0],n=e[s%6];t.push({css:Ie.toCss(i,r,n),rgba:Ie.toRgba(i,r,n)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:Ie.toCss(i,i,i),rgba:Ie.toRgba(i,i,i)})}return t})()),Ps=Ee.toColor("#ffffff"),hi=Ee.toColor("#000000"),Fa=Ee.toColor("#ffffff"),Ha=hi,ri={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Op=Ps,In=class extends oe{constructor(t){super(),this._optionsService=t,this._contrastCache=new ja,this._halfContrastCache=new ja,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ps,background:hi,cursor:Fa,cursorAccent:Ha,selectionForeground:void 0,selectionBackgroundTransparent:ri,selectionBackgroundOpaque:xe.blend(hi,ri),selectionInactiveBackgroundTransparent:ri,selectionInactiveBackgroundOpaque:xe.blend(hi,ri),scrollbarSliderBackground:xe.opacity(Ps,.2),scrollbarSliderHoverBackground:xe.opacity(Ps,.4),scrollbarSliderActiveBackground:xe.opacity(Ps,.5),overviewRulerBorder:Ps,ansi:Fe.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=pe(t.foreground,Ps),e.background=pe(t.background,hi),e.cursor=xe.blend(e.background,pe(t.cursor,Fa)),e.cursorAccent=xe.blend(e.background,pe(t.cursorAccent,Ha)),e.selectionBackgroundTransparent=pe(t.selectionBackground,ri),e.selectionBackgroundOpaque=xe.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=pe(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=xe.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?pe(t.selectionForeground,Ta):void 0,e.selectionForeground===Ta&&(e.selectionForeground=void 0),xe.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=xe.opacity(e.selectionBackgroundTransparent,.3)),xe.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=xe.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=pe(t.scrollbarSliderBackground,xe.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=pe(t.scrollbarSliderHoverBackground,xe.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=pe(t.scrollbarSliderActiveBackground,xe.opacity(e.foreground,.5)),e.overviewRulerBorder=pe(t.overviewRulerBorder,Op),e.ansi=Fe.slice(),e.ansi[0]=pe(t.black,Fe[0]),e.ansi[1]=pe(t.red,Fe[1]),e.ansi[2]=pe(t.green,Fe[2]),e.ansi[3]=pe(t.yellow,Fe[3]),e.ansi[4]=pe(t.blue,Fe[4]),e.ansi[5]=pe(t.magenta,Fe[5]),e.ansi[6]=pe(t.cyan,Fe[6]),e.ansi[7]=pe(t.white,Fe[7]),e.ansi[8]=pe(t.brightBlack,Fe[8]),e.ansi[9]=pe(t.brightRed,Fe[9]),e.ansi[10]=pe(t.brightGreen,Fe[10]),e.ansi[11]=pe(t.brightYellow,Fe[11]),e.ansi[12]=pe(t.brightBlue,Fe[12]),e.ansi[13]=pe(t.brightMagenta,Fe[13]),e.ansi[14]=pe(t.brightCyan,Fe[14]),e.ansi[15]=pe(t.brightWhite,Fe[15]),t.extendedAnsi){let s=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let i=0;i<s;i++)e.ansi[i+16]=pe(t.extendedAnsi[i],Fe[i+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()}}};In=Be([j(0,at)],In);function pe(t,e){if(t!==void 0)try{return Ee.toColor(t)}catch{}return e}var jp=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)}},Fp=class{constructor(){this._services=new jp,this._services.set(ko,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=M_(t).sort((n,o)=>n.index-o.index),i=[];for(let n of s){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${n.id._id}.`);i.push(o)}let r=s.length>0?s[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new t(...e,...i)}},Hp={trace:0,debug:1,info:2,warn:3,error:4,off:5},zp="xterm.js: ",On=class extends oe{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=Hp[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?"":zp)+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)}};On=Be([j(0,at)],On);var za=class extends oe{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new O),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new O),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new O),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 i=t;i<this._length-e;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let i=this._length-1;i>=t;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(t+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}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 r=e-1;r>=0;r--)this.set(t+r+s,this.get(t+r));let i=t+e+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<e;i++)this.set(t+i+s,this.get(t+i))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},ne=3,Le=Object.freeze(new Ei),Zi=0,Jr=2,ci=class _c{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*ne);let r=s||It.fromCharData([0,Th,1,0]);for(let n=0;n<e;++n)this.setCell(n,r);this.length=e}get(e){let s=this._data[e*ne+0],i=s&2097151;return[this._data[e*ne+1],s&2097152?this._combined[e]:i?Ss(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*ne+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*ne+0]=e|2097152|s[2]<<22):this._data[e*ne+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*ne+0]>>22}hasWidth(e){return this._data[e*ne+0]&12582912}getFg(e){return this._data[e*ne+1]}getBg(e){return this._data[e*ne+2]}hasContent(e){return this._data[e*ne+0]&4194303}getCodePoint(e){let s=this._data[e*ne+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*ne+0]&2097152}getString(e){let s=this._data[e*ne+0];return s&2097152?this._combined[e]:s&2097151?Ss(s&2097151):""}isProtected(e){return this._data[e*ne+2]&536870912}loadCell(e,s){return Zi=e*ne,s.content=this._data[Zi+0],s.fg=this._data[Zi+1],s.bg=this._data[Zi+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*ne+0]=s.content,this._data[e*ne+1]=s.fg,this._data[e*ne+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*ne+0]=s|i<<22,this._data[e*ne+1]=r.fg,this._data[e*ne+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*ne+0];r&2097152?this._combined[e]+=Ss(s):r&2097151?(this._combined[e]=Ss(r&2097151)+Ss(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*ne+0]=r}insertCells(e,s,i){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length-e){let r=new It;for(let n=this.length-e-s-1;n>=0;--n)this.setCell(e+s+n,this.loadCell(e+n,r));for(let n=0;n<s;++n)this.setCell(e+n,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,s,i){if(e%=this.length,s<this.length-e){let r=new It;for(let n=0;n<this.length-e-s;++n)this.setCell(e+n,this.loadCell(e+s+n,r));for(let n=this.length-s;n<this.length;++n)this.setCell(n,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,s,i,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.setCell(e++,i)}resize(e,s){if(e===this.length)return this._data.length*4*Jr<this._data.buffer.byteLength;let i=e*ne;if(e>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=e&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=e&&delete this._extendedAttrs[a]}}return this.length=e,i*4*Jr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Jr<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 i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,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 _c(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*ne+0]&4194303)return e+(this._data[e*ne+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ne+0]&4194303||this._data[e*ne+2]&50331648)return e+(this._data[e*ne+0]>>22);return 0}copyCellsFrom(e,s,i,r,n){let o=e._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l<ne;l++)this._data[(i+h)*ne+l]=o[(s+h)*ne+l];o[(s+h)*ne+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let l=0;l<ne;l++)this._data[(i+h)*ne+l]=o[(s+h)*ne+l];o[(s+h)*ne+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}let a=Object.keys(e._combined);for(let h=0;h<a.length;h++){let l=parseInt(a[h],10);l>=s&&(this._combined[l-s+i]=e._combined[l])}}translateToString(e,s,i,r){s=s??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;s<i;){let o=this._data[s*ne+0],a=o&2097151,h=o&2097152?this._combined[s]:a?Ss(a):ws;if(n+=h,r)for(let l=0;l<h.length;++l)r.push(s);s+=o>>22||1}return r&&r.push(s),n}};function Wp(t,e,s,i,r,n){let o=[];for(let a=0;a<t.length-1;a++){let h=a,l=t.get(++h);if(!l.isWrapped)continue;let u=[t.get(a)];for(;h<t.length&&l.isWrapped;)u.push(l),l=t.get(++h);if(!n&&i>=a&&i<h){a+=u.length-1;continue}let d=0,_=wi(u,d,e),m=1,f=0;for(;m<u.length;){let g=wi(u,m,e),v=g-f,C=s-_,S=Math.min(v,C);u[d].copyCellsFrom(u[m],f,_,S,!1),_+=S,_===s&&(d++,_=0),f+=S,f===g&&(m++,f=0),_===0&&d!==0&&u[d-1].getWidth(s-1)===2&&(u[d].copyCellsFrom(u[d-1],s-1,_++,1,!1),u[d-1].setCell(s-1,r))}u[d].replaceCells(_,s,r);let p=0;for(let g=u.length-1;g>0&&(g>d||u[g].getTrimmedLength()===0);g--)p++;p>0&&(o.push(a+u.length-p),o.push(p)),a+=u.length-1}return o}function $p(t,e){let s=[],i=0,r=e[i],n=0;for(let o=0;o<t.length;o++)if(r===o){let a=e[++i];t.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=e[++i]}else s.push(o);return{layout:s,countRemoved:n}}function Up(t,e){let s=[];for(let i=0;i<e.length;i++)s.push(t.get(e[i]));for(let i=0;i<s.length;i++)t.set(i,s[i]);t.length=e.length}function Kp(t,e,s){let i=[],r=t.map((h,l)=>wi(t,l,e)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;a<r;){if(r-a<s){i.push(r-a);break}n+=s;let h=wi(t,o,e);n>h&&(n-=h,o++);let l=t[o].getWidth(n-1)===2;l&&n--;let u=l?s-1:s;i.push(u),a+=u}return i}function wi(t,e,s){if(e===t.length-1)return t[e].getTrimmedLength();let i=!t[e].hasContent(s-1)&&t[e].getWidth(s-1)===1,r=t[e+1].getWidth(0)===2;return i&&r?s-1:s}var mc=class pc{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=pc._nextId++,this._onDispose=this.register(new O),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ns(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};mc._nextId=1;var qp=mc,ze={},Es=ze.B;ze[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:"≥","{":"π","|":"≠","}":"£","~":"·"};ze.A={"#":"£"};ze.B=void 0;ze[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ze.C=ze[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ze.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ze.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ze.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ze.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ze.E=ze[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ze.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ze.H=ze[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ze["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Wa=4294967295,$a=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=Le.clone(),this.savedCharset=Es,this.markers=[],this._nullCell=It.fromCharData([0,Th,1,0]),this._whitespaceCell=It.fromCharData([0,ws,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new pr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new za(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 ur),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 ur),this._whitespaceCell}getBlankLine(t,e){return new ci(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>Wa?Wa:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Le);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 za(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Le),i=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<t)for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(t,s);let n=0;if(this._rows<e)for(let o=this._rows;o<e;o++)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 ci(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new ci(t,s)));else for(let o=this._rows;o>e;o--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),n&&(this.y+=n),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 n=0;n<this.lines.length;n++)i+=+this.lines.get(n).resize(t,s);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),i>.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,i=Wp(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Le),s);if(i.length>0){let r=$p(this.lines,i);Up(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(Le),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new ci(t,i))):(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,i=this.getNullCell(Le),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=t)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!s){let S=this.ybase+this.y;if(S>=o&&S<o+h.length)continue}let l=h[h.length-1].getTrimmedLength(),u=Kp(h,this._cols,t),d=u.length-h.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+d):_=Math.max(0,this.lines.length-this.lines.maxLength+d);let m=[];for(let S=0;S<d;S++){let b=this.getBlankLine(Le,!0);m.push(b)}m.length>0&&(r.push({start:o+h.length+n,newLines:m}),n+=m.length),h.push(...m);let f=u.length-1,p=u[f];p===0&&(f--,p=u[f]);let g=h.length-d-1,v=l;for(;g>=0;){let S=Math.min(v,p);if(h[f]===void 0)break;if(h[f].copyCellsFrom(h[g],v-S,p-S,S,!0),p-=S,p===0&&(f--,p=u[f]),v-=S,v===0){g--;let b=Math.max(g,0);v=wi(h,b,this._cols)}}for(let S=0;S<h.length;S++)u[S]<t&&h[S].setCell(u[S],i);let C=d-_;for(;C-- >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+n)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+e-1)}if(r.length>0){let o=[],a=[];for(let p=0;p<this.lines.length;p++)a.push(this.lines.get(p));let h=this.lines.length,l=h-1,u=0,d=r[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let _=0;for(let p=Math.min(this.lines.maxLength-1,h+n-1);p>=0;p--)if(d&&d.start>l+_){for(let g=d.newLines.length-1;g>=0;g--)this.lines.set(p--,d.newLines[g]);p++,o.push({index:l+1,amount:d.newLines.length}),_+=d.newLines.length,d=r[++u]}else this.lines.set(p,a[l--]);let m=0;for(let p=o.length-1;p>=0;p--)o[p].index+=m,this.lines.onInsertEmitter.fire(o[p]),m+=o[p].amount;let f=Math.max(0,h+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(t,e,s=0,i){let r=this.lines.get(t);return r?r.translateToString(e,s,i):""}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 qp(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)}},Vp=class extends oe{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new O),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 $a(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new $a(!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)}},gc=2,vc=1,jn=class extends oe{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,gc),this.rows=Math.max(t.rawOptions.rows||0,vc),this.buffers=this._register(new Vp(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,i=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==t.fg||i.getBg(0)!==t.bg)&&(i=s.getBlankLine(t,e),this._cachedBlankLine=i),i.isWrapped=e;let r=s.ybase+s.scrollTop,n=s.ybase+s.scrollBottom;if(s.scrollTop===0){let o=s.lines.isFull;n===s.lines.length-1?o?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),o?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let o=n-r+1;s.lines.shiftElements(r+1,o-1,-1),s.lines.set(n,i.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 i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),i!==s.ydisp&&(e||this._onScroll.fire(s.ydisp))}};jn=Be([j(0,at)],jn);var Ks={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:mr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Yp=["normal","bold","100","200","300","400","500","600","700","800","900"],Gp=class extends oe{constructor(t){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let e={...Ks};for(let s in t)if(s in e)try{let i=t[s];e[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(Ce(()=>{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 Ks))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in Ks))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:t.bind(this,s),set:e.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=Ks[t]),!Xp(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Ks[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=Yp.includes(e)?e:Ks[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 Xp(t){return t==="block"||t==="underline"||t==="bar"}function di(t,e=5){if(typeof t!="object")return t;let s=Array.isArray(t)?[]:{};for(let i in t)s[i]=e<=1?t[i]:t[i]&&di(t[i],e-1);return s}var Ua=Object.freeze({insertMode:!1}),Ka=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Fn=class extends oe{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 O),this.onData=this._onData.event,this._onUserInput=this._register(new O),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new O),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=di(Ua),this.decPrivateModes=di(Ka)}reset(){this.modes=di(Ua),this.decPrivateModes=di(Ka)}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(i=>i.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))}};Fn=Be([j(0,ot),j(1,jh),j(2,at)],Fn);var qa={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 Zr(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 Qr=String.fromCharCode,Va={DEFAULT:t=>{let e=[Zr(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Qr(e[0])}${Qr(e[1])}${Qr(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Zr(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Zr(t,!0)};${t.x};${t.y}${e}`}},Hn=class extends oe{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 O),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(qa))this.addProtocol(i,qa[i]);for(let i of Object.keys(Va))this.addEncoding(i,Va[i]);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 i=e/s,r=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(t.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_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)}};Hn=Be([j(0,ot),j(1,js),j(2,at)],Hn);var en=[[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]],Jp=[[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]],He;function Zp(t,e){let s=0,i=e.length-1,r;if(t<e[0][0]||t>e[i][1])return!1;for(;i>=s;)if(r=s+i>>1,t>e[r][1])s=r+1;else if(t<e[r][0])i=r-1;else return!0;return!1}var Qp=class{constructor(){if(this.version="6",!He){He=new Uint8Array(65536),He.fill(1),He[0]=0,He.fill(0,1,32),He.fill(0,127,160),He.fill(2,4352,4448),He[9001]=2,He[9002]=2,He.fill(2,11904,42192),He[12351]=1,He.fill(2,44032,55204),He.fill(2,63744,64256),He.fill(2,65040,65050),He.fill(2,65072,65136),He.fill(2,65280,65377),He.fill(2,65504,65511);for(let t=0;t<en.length;++t)He.fill(0,en[t][0],en[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?He[t]:Zp(t,Jp)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let s=this.wcwidth(t),i=s===0&&e!==0;if(i){let r=Bs.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return Bs.createPropertyValue(0,s,i)}},Bs=class nr{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let e=new Qp;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,i=!1){return(e&16777215)<<3|(s&3)<<1|(i?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,i=0,r=e.length;for(let n=0;n<r;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return s+this.wcwidth(o);let l=e.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:s+=this.wcwidth(l)}let a=this.charProperties(o,i),h=nr.extractWidth(a);nr.extractShouldJoin(a)&&(h-=nr.extractWidth(i)),s+=h,i=a}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},eg=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 Ya(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 ni=2147483647,tg=256,bc=class zn{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>tg)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 zn;if(!e.length)return s;for(let i=Array.isArray(e[0])?1:0;i<e.length;++i){let r=e[i];if(Array.isArray(r))for(let n=0;n<r.length;++n)s.addSubParam(r[n]);else s.addParam(r)}return s}clone(){let e=new zn(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 i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,r))}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>ni?ni: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>ni?ni: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,i=this._subParamsIdx[e]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let e={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(e[s]=this._subParams.slice(i,r))}return e}addDigit(e){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+e,ni):e}},oi=[],sg=class{constructor(){this._state=0,this._active=oi,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 i=s.indexOf(e);i!==-1&&s.splice(i,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=oi}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=oi,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||oi,!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",Dr(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].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 i=t[e++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-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,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=oi,this._id=-1,this._state=0}}},Pt=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+=Dr(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}},ai=[],ig=class{constructor(){this._handlers=Object.create(null),this._active=ai,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ai}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let i=s.indexOf(e);i!==-1&&s.splice(i,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=ai,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||ai,!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",Dr(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,s)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=ai,this._ident=0}},ui=new bc;ui.addParam(0);var Ga=class{constructor(t){this._handler=t,this._data="",this._params=ui,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():ui,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Dr(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=ui,this._data="",this._hitLimit=!1,s));return this._params=ui,this._data="",this._hitLimit=!1,e}},rg=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,i){this.table[e<<8|t]=s<<4|i}addMany(t,e,s,i){for(let r=0;r<t.length;r++)this.table[e<<8|t[r]]=s<<4|i}},Nt=160,ng=(function(){let t=new rg(4095),e=Array.apply(null,Array(256)).map((a,h)=>h),s=(a,h)=>e.slice(a,h),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let n=s(0,14),o;t.setDefault(1,0),t.addMany(i,0,2,0);for(o in n)t.addMany([24,26,153,154],o,3,0),t.addMany(s(128,144),o,3,0),t.addMany(s(144,152),o,3,0),t.add(156,o,0,0),t.add(27,o,11,1),t.add(157,o,4,8),t.addMany([152,158,159],o,0,7),t.add(155,o,11,3),t.add(144,o,11,9);return t.addMany(r,0,3,0),t.addMany(r,1,3,1),t.add(127,1,0,1),t.addMany(r,8,0,8),t.addMany(r,3,3,3),t.add(127,3,0,3),t.addMany(r,4,3,4),t.add(127,4,0,4),t.addMany(r,6,3,6),t.addMany(r,5,3,5),t.add(127,5,0,5),t.addMany(r,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(i,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(i,7,0,7),t.addMany(r,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(r,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(r,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(r,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(r,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(r,13,13,13),t.addMany(i,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Nt,0,2,0),t.add(Nt,8,5,8),t.add(Nt,6,0,6),t.add(Nt,11,0,11),t.add(Nt,13,13,13),t})(),og=class extends oe{constructor(t=ng){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 bc,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,i)=>{},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(Ce(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new sg),this._dcsParser=this._register(new ig),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 r=0;r<t.intermediates.length;++r){let n=t.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=n}}if(t.final.length!==1)throw new Error("final must be a single byte");let i=t.final.charCodeAt(0);if(e[0]>i||i>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=i,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 i=this._escHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,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 i=this._csiHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,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,i,r){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(t,e,s){let i=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=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 a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(i=t[this._parseStack.chunkPos],o=this._dcsParser.unhook(i!==24&&i!==26,s),o)return o;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=t[this._parseStack.chunkPos],o=this._oscParser.end(i!==24&&i!==26,s),o)return o;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a<e;++a){switch(i=t[a],r=this._transitions.table[this.currentState<<8|(i<160?i:Nt)],r>>4){case 2:for(let _=a+1;;++_){if(_>=e||(i=t[_])<32||i>126&&i<Nt){this._printHandler(t,a,_),a=_-1;break}if(++_>=e||(i=t[_])<32||i>126&&i<Nt){this._printHandler(t,a,_),a=_-1;break}if(++_>=e||(i=t[_])<32||i>126&&i<Nt){this._printHandler(t,a,_),a=_-1;break}if(++_>=e||(i=t[_])<32||i>126&&i<Nt){this._printHandler(t,a,_),a=_-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],l=h?h.length-1:-1;for(;l>=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++a<e&&(i=t[a])>47&&i<60);a--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let u=this._escHandlers[this._collect<<8|i],d=u?u.length-1:-1;for(;d>=0&&(o=u[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,u,d,r,a),o;d<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let _=a+1;;++_)if(_>=e||(i=t[_])===24||i===26||i===27||i>127&&i<Nt){this._dcsParser.put(t,a,_),a=_-1;break}break;case 14:if(o=this._dcsParser.unhook(i!==24&&i!==26),o)return this._preserveStack(6,[],0,r,a),o;i===27&&(r|=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 _=a+1;;_++)if(_>=e||(i=t[_])<32||i>127&&i<Nt){this._oscParser.put(t,a,_),a=_-1;break}break;case 6:if(o=this._oscParser.end(i!==24&&i!==26),o)return this._preserveStack(5,[],0,r,a),o;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},ag=/^([\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})$/,lg=/^[\da-f]+$/;function Xa(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=ag.exec(e);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),lg.exec(e)&&[3,6,9,12].includes(e.length))){let s=e.length/3,i=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(e.slice(s*r,s*r+s),16);i[r]=s===1?n<<4:s===2?n:s===3?n>>4:n>>8}return i}}function tn(t,e){let s=t.toString(16),i=s.length<2?"0"+s:s;switch(e){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function hg(t,e=16){let[s,i,r]=t;return`rgb:${tn(s,e)}/${tn(i,e)}/${tn(r,e)}`}var cg={"(":0,")":1,"*":2,"+":3,"-":1,".":2},bs=131072,Ja=10;function Za(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 Qa=5e3,el=0,dg=class extends oe{constructor(t,e,s,i,r,n,o,a,h=new og){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new D_,this._utf8Decoder=new A_,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Le.clone(),this._eraseAttrDataInternal=Le.clone(),this._onRequestBell=this._register(new O),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O),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 Wn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:u.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:u,data:d})}),this._parser.setDcsHandlerFallback((l,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:u,payload:d})}),this._parser.setPrintHandler((l,u,d)=>this.print(l,u,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(L.BEL,()=>this.bell()),this._parser.setExecuteHandler(L.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(L.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(L.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(L.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(L.BS,()=>this.backspace()),this._parser.setExecuteHandler(L.HT,()=>this.tab()),this._parser.setExecuteHandler(L.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(L.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ir.IND,()=>this.index()),this._parser.setExecuteHandler(ir.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ir.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Pt(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new Pt(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new Pt(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new Pt(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new Pt(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new Pt(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new Pt(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new Pt(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new Pt(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new Pt(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new Pt(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new Pt(l=>this.restoreCursorColor(l))),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 l in ze)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Ga((l,u)=>this.requestStatusString(l,u)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),Qa))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Qa} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>bs&&(n=this._parseStack.position+bs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(l=>l.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<bs&&(this._parseBuffer=new Uint32Array(Math.min(t.length,bs))),o||this._dirtyRowTracker.clearRange(),t.length>bs)for(let l=n;l<t.length;l+=bs){let u=l+bs<t.length?l+bs:t.length,d=typeof t=="string"?this._stringDecoder.decode(t.substring(l,u),this._parseBuffer):this._utf8Decoder.decode(t.subarray(l,u),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(i,r,d,l),this._logSlowResolvingAsync(s),s}else if(!o){let l=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,l))return this._preserveStack(i,r,l,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(t,e,s){let i,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-e>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let _=this._parser.precedingJoinState;for(let m=e;m<s;++m){if(i=t[m],i<127&&n){let v=n[String.fromCharCode(i)];v&&(i=v.charCodeAt(0))}let f=this._unicodeService.charProperties(i,_);r=Bs.extractWidth(f);let p=Bs.extractShouldJoin(f),g=p?Bs.extractWidth(_):0;if(_=f,o&&this._onA11yChar.fire(Ss(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>a){if(h){let v=d,C=this._activeBuffer.x-g;for(this._activeBuffer.x=g,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),g>0&&d instanceof ci&&d.copyCellsFrom(v,C,0,g,!1);C<a;)v.setCellFromCodepoint(C++,0,1,u)}else if(this._activeBuffer.x=a-1,r===2)continue}if(p&&this._activeBuffer.x){let v=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-v,i,r);for(let C=r-g;--C>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(u)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,i,r,u),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=_,this._activeBuffer.x<a&&s-e>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>Za(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Ga(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Pt(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,i=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(n.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 i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;e--;)this._activeBuffer.lines.splice(r-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,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;e--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,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(Le));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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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,i=Bs.extractWidth(e),r=this._activeBuffer.x-i,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*s),a=0;for(let l=0;l<n.length;){let u=n.codePointAt(l)||0;o[a++]=u,l+=u>65535?2:1}let h=a;for(let l=1;l<s;++l)o.copyWithin(h,0,a),h+=a;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(L.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(L.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(L.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(L.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(L.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,Es),this._charsetService.setgCharset(1,Es),this._charsetService.setgCharset(2,Es),this._charsetService.setgCharset(3,Es);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;(p=>(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:u}=a,d=this._optionsService.rawOptions,_=(p,g)=>(o.triggerDataEvent(`${L.ESC}[${e?"":"?"}${p};${g}$y`),!0),m=p=>p?1:2,f=t.params[0];return e?f===2?_(f,4):f===4?_(f,m(o.modes.insertMode)):f===12?_(f,3):f===20?_(f,m(d.convertEol)):_(f,0):f===1?_(f,m(i.applicationCursorKeys)):f===3?_(f,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):f===6?_(f,m(i.origin)):f===7?_(f,m(i.wraparound)):f===8?_(f,3):f===9?_(f,m(r==="X10")):f===12?_(f,m(d.cursorBlink)):f===25?_(f,m(!o.isCursorHidden)):f===45?_(f,m(i.reverseWraparound)):f===66?_(f,m(i.applicationKeypad)):f===67?_(f,4):f===1e3?_(f,m(r==="VT200")):f===1002?_(f,m(r==="DRAG")):f===1003?_(f,m(r==="ANY")):f===1004?_(f,m(i.sendFocus)):f===1005?_(f,4):f===1006?_(f,m(n==="SGR")):f===1015?_(f,4):f===1016?_(f,m(n==="SGR_PIXELS")):f===1048?_(f,1):f===47||f===1047||f===1049?_(f,m(l===u)):f===2004?_(f,m(i.bracketedPasteMode)):f===2026?_(f,m(i.synchronizedOutput)):_(f,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=Ei.fromColorRGB([s,i,r])):e===5&&(t&=-50331904,t|=33554432|s&255),t}_extractColor(t,e,s){let i=[0,0,-1,0,0,0],r=0,n=0;do{if(i[n+r]=t.params[e+n],t.hasSubParams(e+n)){let o=t.getSubParams(e+n),a=0;do i[1]===5&&(r=1),i[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<i.length);break}if(i[1]===5&&n+r>=2||i[1]===2&&n+r>=5)break;i[1]&&(r=1)}while(++n+e<t.length&&n+r<i.length);for(let o=2;o<i.length;++o)i[o]===-1&&(i[o]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return n}_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=Le.fg,t.bg=Le.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,i=this._curAttrData;for(let r=0;r<e;r++)s=t.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(t.hasSubParams(r)?t.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Le.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Le.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(t,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Le.fg&16777215,i.bg&=-67108864,i.bg|=Le.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${L.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${L.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(`${L.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=Le.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(!Za(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(`${L.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ja&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ja&&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 i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let n=parseInt(i);if(tl(n))if(r==="?")e.push({type:0,index:n});else{let o=Xa(r);o&&e.push({type:1,index:n,color:o})}}}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(),i=t.slice(e+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let s=t.split(":"),i,r=s.findIndex(n=>n.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,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 i=0;i<s.length&&!(e>=this._specialColors.length);++i,++e)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=Xa(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}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 i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);tl(r)&&e.push({type:2,index:r})}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,Es),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(cg[t[0]],ze[t[1]]||Es),!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=Le.clone(),this._eraseAttrDataInternal=Le.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 It;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,i=this._activeBuffer.lines.get(s);i&&(i.fill(t),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let s=o=>(this._coreService.triggerDataEvent(`${L.ESC}${o}${L.ESC}\\`),!0),i=this._bufferService.buffer,r=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${i.scrollTop+1};${i.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},Wn=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&&(el=t,t=e,e=el),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Wn=Be([j(0,ot)],Wn);function tl(t){return 0<=t&&t<256}var ug=5e7,sl=12,fg=50,_g=class extends oe{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 O),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 i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>ug)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 i=this._writeBuffer[this._bufferOffset],r=this._action(i,e);if(r){let o=a=>performance.now()-s>=sl?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(s,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=sl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>fg&&(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()}},$n=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 a=e.addMarker(e.ybase+e.y),h={data:t,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let s=t,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,e.ybase+e.y),r.id;let n=e.addMarker(e.ybase+e.y),o={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(t,e){let s=this._dataByLinkId.get(t);if(s&&s.lines.every(i=>i.line!==e)){let i=this._bufferService.buffer.addMarker(e);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}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)))}};$n=Be([j(0,ot)],$n);var il=!1,mg=class extends oe{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new Xs),this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onData=this._register(new O),this.onData=this._onData.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new O),this._instantiationService=new Fp,this.optionsService=this._register(new Gp(t)),this._instantiationService.setService(at,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(jn)),this._instantiationService.setService(ot,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(On)),this._instantiationService.setService(jh,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Fn)),this._instantiationService.setService(js,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Hn)),this._instantiationService.setService(Oh,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Bs)),this._instantiationService.setService(L_,this.unicodeService),this._charsetService=this._instantiationService.createInstance(eg),this._instantiationService.setService(N_,this._charsetService),this._oscLinkService=this._instantiationService.createInstance($n),this._instantiationService.setService(Fh,this._oscLinkService),this._inputHandler=this._register(new dg(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ge.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ge.forward(this._bufferService.onResize,this._onResize)),this._register(Ge.forward(this.coreService.onData,this._onData)),this._register(Ge.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 _g((e,s)=>this._inputHandler.parse(e,s))),this._register(Ge.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new O),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&&!il&&(this._logService.warn("writeSync is unreliable and will be removed soon."),il=!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,gc),e=Math.max(e,vc),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(Ya.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(Ya(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ce(()=>{for(let e of t)e.dispose()})}}},pg={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 gg(t,e,s,i){let r={type:0,cancel:!1,key:void 0},n=(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?r.key=L.ESC+"OA":r.key=L.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=L.ESC+"OD":r.key=L.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=L.ESC+"OC":r.key=L.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=L.ESC+"OB":r.key=L.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":L.DEL,t.altKey&&(r.key=L.ESC+r.key);break;case 9:if(t.shiftKey){r.key=L.ESC+"[Z";break}r.key=L.HT,r.cancel=!0;break;case 13:r.key=t.altKey?L.ESC+L.CR:L.CR,r.cancel=!0;break;case 27:r.key=L.ESC,t.altKey&&(r.key=L.ESC+L.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;n?r.key=L.ESC+"[1;"+(n+1)+"D":e?r.key=L.ESC+"OD":r.key=L.ESC+"[D";break;case 39:if(t.metaKey)break;n?r.key=L.ESC+"[1;"+(n+1)+"C":e?r.key=L.ESC+"OC":r.key=L.ESC+"[C";break;case 38:if(t.metaKey)break;n?r.key=L.ESC+"[1;"+(n+1)+"A":e?r.key=L.ESC+"OA":r.key=L.ESC+"[A";break;case 40:if(t.metaKey)break;n?r.key=L.ESC+"[1;"+(n+1)+"B":e?r.key=L.ESC+"OB":r.key=L.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=L.ESC+"[2~");break;case 46:n?r.key=L.ESC+"[3;"+(n+1)+"~":r.key=L.ESC+"[3~";break;case 36:n?r.key=L.ESC+"[1;"+(n+1)+"H":e?r.key=L.ESC+"OH":r.key=L.ESC+"[H";break;case 35:n?r.key=L.ESC+"[1;"+(n+1)+"F":e?r.key=L.ESC+"OF":r.key=L.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=L.ESC+"[5;"+(n+1)+"~":r.key=L.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=L.ESC+"[6;"+(n+1)+"~":r.key=L.ESC+"[6~";break;case 112:n?r.key=L.ESC+"[1;"+(n+1)+"P":r.key=L.ESC+"OP";break;case 113:n?r.key=L.ESC+"[1;"+(n+1)+"Q":r.key=L.ESC+"OQ";break;case 114:n?r.key=L.ESC+"[1;"+(n+1)+"R":r.key=L.ESC+"OR";break;case 115:n?r.key=L.ESC+"[1;"+(n+1)+"S":r.key=L.ESC+"OS";break;case 116:n?r.key=L.ESC+"[15;"+(n+1)+"~":r.key=L.ESC+"[15~";break;case 117:n?r.key=L.ESC+"[17;"+(n+1)+"~":r.key=L.ESC+"[17~";break;case 118:n?r.key=L.ESC+"[18;"+(n+1)+"~":r.key=L.ESC+"[18~";break;case 119:n?r.key=L.ESC+"[19;"+(n+1)+"~":r.key=L.ESC+"[19~";break;case 120:n?r.key=L.ESC+"[20;"+(n+1)+"~":r.key=L.ESC+"[20~";break;case 121:n?r.key=L.ESC+"[21;"+(n+1)+"~":r.key=L.ESC+"[21~";break;case 122:n?r.key=L.ESC+"[23;"+(n+1)+"~":r.key=L.ESC+"[23~";break;case 123:n?r.key=L.ESC+"[24;"+(n+1)+"~":r.key=L.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?r.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?r.key=L.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=L.DEL:t.keyCode===219?r.key=L.ESC:t.keyCode===220?r.key=L.FS:t.keyCode===221&&(r.key=L.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let o=pg[t.keyCode]?.[t.shiftKey?1:0];if(o)r.key=L.ESC+o;else if(t.keyCode>=65&&t.keyCode<=90){let a=t.ctrlKey?t.keyCode-64:t.keyCode+32,h=String.fromCharCode(a);t.shiftKey&&(h=h.toUpperCase()),r.key=L.ESC+h}else if(t.keyCode===32)r.key=L.ESC+(t.ctrlKey?L.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let a=t.code.slice(3,4);t.shiftKey||(a=a.toLowerCase()),r.key=L.ESC+a,r.cancel=!0}}else s&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(r.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?r.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(r.key=L.US),t.key==="@"&&(r.key=L.NUL));break}return r}var Ae=0,vg=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new pr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new pr,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((r,n)=>this._getKey(r)-this._getKey(n)),e=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[s])?(i[r]=t[e],e++):i[r]=this._array[s++];this._array=i,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||(Ae=this._search(e),Ae===-1)||this._getKey(this._array[Ae])!==e)return!1;do if(this._array[Ae]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ae),!0;while(++Ae<this._array.length&&this._getKey(this._array[Ae])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,n)=>r-n),e=0,s=new Array(this._array.length-t.length),i=0;for(let r=0;r<this._array.length;r++)t[e]===r?e++:s[i++]=this._array[r];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&&(Ae=this._search(t),!(Ae<0||Ae>=this._array.length)&&this._getKey(this._array[Ae])===t))do yield this._array[Ae];while(++Ae<this._array.length&&this._getKey(this._array[Ae])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ae=this._search(t),!(Ae<0||Ae>=this._array.length)&&this._getKey(this._array[Ae])===t))do e(this._array[Ae]);while(++Ae<this._array.length&&this._getKey(this._array[Ae])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,s=this._array.length-1;for(;s>=e;){let i=e+s>>1,r=this._getKey(this._array[i]);if(r>t)s=i-1;else if(r<t)e=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===t;)i--;return i}}return e}},sn=0,rl=0,bg=class extends oe{constructor(){super(),this._decorations=new vg(t=>t?.marker.line),this._onDecorationRegistered=this._register(new O),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new O),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ce(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new Sg(t);if(e){let s=e.marker.onDispose(()=>e.dispose()),i=e.onDispose(()=>{i.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 i=0,r=0;for(let n of this._decorations.getKeyIterator(e))i=n.options.x??0,r=i+(n.options.width??1),t>=i&&t<r&&(!s||(n.options.layer??"bottom")===s)&&(yield n)}forEachDecorationAtCell(t,e,s,i){this._decorations.forEachByKey(e,r=>{sn=r.options.x??0,rl=sn+(r.options.width??1),t>=sn&&t<rl&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},Sg=class extends ys{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new O),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new O),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=Ee.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ee.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},wg=1e3,yg=class{constructor(t,e=wg){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 i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_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)}},nl=20,gr=class extends oe{constructor(t,e,s,i){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,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=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new yg(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(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
25
25
  `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Q(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ce(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<nl+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
26
26
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===nl+1&&(this._liveRegion.textContent+=hn.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,i=s.lines.length.toString();for(let r=t;r<=e;r++){let n=s.lines.get(s.ydisp+r),o=[],a=n?.translateToString(!0,void 0,void 0,o)||"",h=(s.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let s=t.target,i=this._rowElements[e===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||t.relatedTarget!==i)return;let o,a;if(e===0?(o=s,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=s,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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 i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let r=({node:a,offset:h})=>{let l=a instanceof Text?a.parentNode:a,u=parseInt(l?.getAttribute("aria-posinset"),10)-1;if(isNaN(u))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(l);if(!d)return console.warn("columns is null. Race condition?"),null;let _=h<d.length?d[h]:d.slice(-1)[0]+1;return _>=this._terminal.cols&&(++u,_=0),{row:u,column:_}},n=r(e),o=r(s);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.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 i=s*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${i/e})`}};gr=Be([j(1,ko),j(2,_s),j(3,ms)],gr);var Un=class extends oe{constructor(t,e,s,i,r){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new O),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new O),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ce(()=>{Ns(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(Q(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Q(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Q(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Q(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 i=0;i<s.length;i++){let r=s[i];if(r.classList.contains("xterm"))break;if(r.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(i=>{i?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[i,r]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,t,s)):r.provideLinks(t.y,n=>{if(this._isMouseOut)return;let o=n?.map(a=>({link:a}));this._activeProviderReplies?.set(i,o),s=this._checkLinkProviderResult(i,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let s=new Set;for(let i=0;i<e.size;i++){let r=e.get(i);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<t?0:o.link.range.start.x,h=o.link.range.end.y>t?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(s.has(l)){r.splice(n--,1);break}s.add(l)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(t),r=!1;for(let n=0;n<t;n++)(!this._activeProviderReplies.has(n)||this._activeProviderReplies.get(n))&&(r=!0);if(!r&&i){let n=i.find(o=>this._linkAtPosition(o.link,e));n&&(s=!0,this._handleNewLink(n))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let n=0;n<this._activeProviderReplies.size;n++){let o=this._activeProviderReplies.get(n)?.find(a=>this._linkAtPosition(a.link,e));if(o){s=!0,this._handleNewLink(o);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&&xg(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,Ns(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 i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!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,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_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,i=t.range.end.y*this._bufferService.cols+t.range.end.x,r=e.y*this._bufferService.cols+e.x;return s<=r&&r<=i}_positionFromMouseEvent(t,e,s){let i=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,i,r){return{x1:t,y1:e,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};Un=Be([j(1,Po),j(2,ms),j(3,ot),j(4,zh)],Un);function xg(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 Cg=class extends mg{constructor(t={}){super(t),this._linkifier=this._register(new Xs),this.browser=oc,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Xs),this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new O),this.onKey=this._onKey.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new O),this.onBell=this._onBell.event,this._onFocus=this._register(new O),this._onBlur=this._register(new O),this._onA11yCharEmitter=this._register(new O),this._onA11yTabEmitter=this._register(new O),this._onWillOpen=this._register(new O),this._setup(),this._decorationService=this._instantiationService.createInstance(bg),this._instantiationService.setService(Ri,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(fp),this._instantiationService.setService(zh,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(dn)),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(Ge.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ge.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ge.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ge.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Ce(()=>{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,i="";switch(e.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+e.index}switch(e.type){case 0:let r=xe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${L.ESC}]${i};${hg(r)}${rc.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(n=>n.ansi[e.index]=Ie.toColor(...e.color));else{let n=s;this._themeService.modifyColors(o=>o[n]=Ie.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(gr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(L.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(L.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),i=this._renderService.dimensions.css.cell.height,r=e.getWidth(s),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Q(this.element,"copy",e=>{this.hasSelection()&&R_(e,this._selectionService)}));let t=e=>B_(e,this.textarea,this.coreService,this.optionsService);this._register(Q(this.textarea,"paste",t)),this._register(Q(this.element,"paste",t)),ac?this._register(Q(this.element,"mousedown",e=>{e.button===2&&ma(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Q(this.element,"contextmenu",e=>{ma(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),No&&this._register(Q(this.element,"auxclick",e=>{e.button===1&&Mh(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Q(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(Q(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(Q(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(Q(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Q(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(Q(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Q(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(Q(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),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",ln.get()),cc||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(dp,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(_s,this._coreBrowserService),this._register(Q(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(Q(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Mn,this._document,this._helperContainer),this._instantiationService.setService(Ar,this._charSizeService),this._themeService=this._instantiationService.createInstance(In),this._instantiationService.setService(Qs,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_r),this._instantiationService.setService(Hh,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Nn,this.rows,this.screenElement)),this._instantiationService.setService(ms,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Bn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Tn),this._instantiationService.setService(Po,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Un,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(En,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Ln,this.element,this.screenElement,i)),this._instantiationService.setService(O_,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(Ge.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Rn,this.screenElement)),this._register(Q(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),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(gr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(An,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(n){let o=t._mouseService.getMouseReportCoords(n,t.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=n.button<3?n.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(n)===!1)return!1;let l=n.deltaY;if(l===0||t.coreMouseService.consumeWheelEvent(n,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;h=l<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:t.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(s(n),n.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(n)),wheel:n=>(s(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&s(n)},mousemove:n=>{n.buttons||s(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?i.mousemove||(e.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(e.removeEventListener("mousemove",i.mousemove),i.mousemove=null),n&16?i.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(e.removeEventListener("wheel",i.wheel),i.wheel=null),n&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),n&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Q(e,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return s(n),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(n)})),this._register(Q(e,"wheel",n=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(n,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(n,!0);let o=L.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(o,!0),this.cancel(n,!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){Ah(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=gg(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),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===L.ETX||s.key===L.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)&&(kg(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(Le));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(L.ESC+"[I"):this.coreService.triggerDataEvent(L.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(`${L.ESC}[4;${s};${e}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${L.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function kg(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var Pg=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)}},Eg=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 It)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},ol=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 Eg(e)}getNullCell(){return new It}},Rg=class extends oe{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new ol(this._core.buffers.normal,"normal"),this._alternate=new ol(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)}},Bg=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,i)=>e(s,i.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)}},Dg=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}},Ag=["cols","rows"],rs=0,Mg=class extends oe{constructor(t){super(),this._core=this._register(new Cg(t)),this._addonManager=this._register(new Pg),this._publicOptions={...this._core.options};let e=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:e.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(t){if(Ag.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 Bg(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Dg(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 Rg(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
27
- `,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 ln.get()},set promptLabel(t){ln.set(t)},get tooMuchOutput(){return hn.get()},set tooMuchOutput(t){hn.set(t)}}}_verifyIntegers(...t){for(rs of t)if(rs===1/0||isNaN(rs)||rs%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(rs of t)if(rs&&(rs===1/0||isNaN(rs)||rs%1!==0||rs<0))throw new Error("This API only accepts positive integers")}};var Tg=2,Ng=1,Lg=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),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=i-a,u=r-h-e;return{cols:Math.max(Tg,Math.floor(u/t.css.cell.width)),rows:Math.max(Ng,Math.floor(l/t.css.cell.height))}}};function Ig({source:t,onReady:e,onSelectionChange:s,className:i}){const r=V.useRef(null),n=V.useRef(null),o=V.useRef(s);o.current=s;const a=Pr(),h=V.useRef(t);return h.current=t,Ul((l,u)=>{l===h.current&&n.current?.write(u)}),V.useEffect(()=>{const l=r.current;if(!l)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,_=new Mg({allowTransparency:!1,fontFamily:d("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:d("--sidebar")||d("--card")||d("--background")||"#1e1e1e",cursor:"transparent",foreground:d("--foreground")||"#d4d4d4",selectionBackground:d("--accent"),selectionForeground:d("--accent-foreground"),black:d("--muted"),red:d("--destructive"),green:d("--success"),yellow:d("--warning"),blue:d("--chart-1"),magenta:d("--chart-3"),cyan:d("--chart-5"),white:d("--foreground"),brightBlack:d("--muted-foreground"),brightRed:d("--destructive"),brightGreen:d("--success"),brightYellow:d("--warning"),brightBlue:d("--chart-1"),brightMagenta:d("--chart-3"),brightCyan:d("--chart-5"),brightWhite:d("--foreground")}}),m=new Lg;_.loadAddon(m),_.open(l),m.fit();const f=a.getBuffer(t);f&&_.write(f),n.current=_,e?.(_);const p=_.onSelectionChange(()=>{const v=!!_.getSelection();o.current?.(v,()=>_.getSelection())}),g=new ResizeObserver(()=>{m.fit()});return g.observe(l),()=>{p.dispose(),g.disconnect(),n.current=null,_.dispose()}},[]),c.jsx("div",{className:ie("h-full bg-sidebar p-3",i),children:c.jsx("div",{ref:r,className:"h-full"})})}const Kn=120,Sc=160;function Og(t,e,s=Sc){const i=Math.max(Kn,e-s);return Math.min(Math.max(t,Kn),i)}function jg(t){const e=ge(),s=Pr(),[i,r]=V.useState(As),[n,o]=V.useState([]),[a,h]=V.useState(new Set),l=V.useRef(!1);if(!l.current&&s.scripts.length>0){const y=ou.find(B=>s.scripts.includes(B));y&&(l.current=!0,o(B=>B.includes(y)?B:[...B,y]),r(y))}if(a.size>0){let y=!1;const B=new Set(a);for(const R of a)s.activeProcesses.includes(R)||(B.delete(R),y=!0);y&&h(B)}const u=()=>t.onOpenChange(!t.open),d=y=>{r(y),t.open||t.onOpenChange(!0)},_=xs()?.taskId??null,m={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId??"",branch:t.branch??"",threadId:_??null},f=y=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(Ko(m,`exec/${encodeURIComponent(y)}`),{method:"POST"}),p=y=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(Ko(m,`exec/${encodeURIComponent(y)}/kill`),{method:"POST"}),g=async(y,B)=>{try{const R=await f(y);if(R===null)return;if(!R.ok)throw new Error(`Exec failed: ${R.statusText}`)}catch{Je.error(B)}},v=async y=>{o(B=>B.includes(y)?B:[...B,y]),r(y),t.onOpenChange(!0),await g(y,e("sandbox.drawer.failedToRun",{name:y}))},C=async y=>{await p(y),o(B=>B.filter(R=>R!==y)),i===y&&r(As)},S=async()=>{const B=s.activeProcesses.includes(i)?e("sandbox.drawer.failedToRestart",{name:i}):e("sandbox.drawer.failedToRun",{name:i});await g(i,B)},b=async()=>{if(!a.has(i)){h(y=>new Set(y).add(i));try{const y=await p(i);if(y===null){h(B=>{const R=new Set(B);return R.delete(i),R});return}if(!y.ok)throw new Error(`Kill failed: ${y.statusText}`)}catch{h(y=>{const B=new Set(y);return B.delete(i),B}),Je.error(e("sandbox.drawer.failedToStop",{name:i}))}}},w=i!==As&&n.includes(i),x=w&&s.activeProcesses.includes(i),D=w&&a.has(i),E=V.useRef(null),I=y=>{if(!t.open)return;const B=E.current,R=B?.parentElement;if(!B||!R)return;y.preventDefault();const k=y.currentTarget,{pointerId:A}=y;k.setPointerCapture(A);const M=y.clientY,P=B.getBoundingClientRect().height,T=R.getBoundingClientRect().height;let N=P;const z=W=>{W.pointerId===A&&(N=Og(P+(M-W.clientY),T),B.style.height=`${N}px`)},H=W=>{W.pointerId===A&&(k.removeEventListener("pointermove",z),k.removeEventListener("pointerup",H),k.removeEventListener("pointercancel",H),document.body.style.userSelect="",document.body.style.cursor="",t.onHeightChange(N))};document.body.style.userSelect="none",document.body.style.cursor="row-resize",k.addEventListener("pointermove",z),k.addEventListener("pointerup",H),k.addEventListener("pointercancel",H)};return c.jsxs("div",{ref:E,className:"flex shrink-0 flex-col",style:{height:t.open?t.height??"50%":"auto",maxHeight:t.open?`max(${Kn}px, calc(100% - ${Sc}px))`:void 0},children:[t.open&&c.jsx(Hg,{onPointerDown:I,label:e("sandbox.preview.resizeTerminal")}),c.jsx(v_,{status:t.status,open:t.open,onToggle:u,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:i,scriptTabs:n,onSelectTab:d,onAddScript:v,onCloseScript:C,showScriptControls:w,scriptIsRunning:x,scriptIsKilling:D,onRunActiveScript:S,onStopActiveScript:b}),t.open&&c.jsx("div",{className:"flex-1 overflow-hidden",children:c.jsx(Fg,{vmId:t.vmId,active:i,hasData:s.hasData(i),onRunActive:S})})]})}function Fg(t){const e=F.c(16),{vmId:s,active:i,hasData:r,onRunActive:n}=t,o=ge();if(!s)return null;if(i===As||r){let m;return e[0]!==i?(m=c.jsx(Ig,{source:i,className:"h-full"},i),e[0]=i,e[1]=m):m=e[1],m}let a;e[2]!==i||e[3]!==o?(a=o("sandbox.drawer.scriptNotRunning",{name:i}),e[2]=i,e[3]=o,e[4]=a):a=e[4];let h;e[5]!==a?(h=c.jsx("p",{children:a}),e[5]=a,e[6]=h):h=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(lr,{className:"size-3.5"}),e[7]=l):l=e[7];let u;e[8]!==o?(u=o("sandbox.drawer.run"),e[8]=o,e[9]=u):u=e[9];let d;e[10]!==n||e[11]!==u?(d=c.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-accent",children:[l," ",u]}),e[10]=n,e[11]=u,e[12]=d):d=e[12];let _;return e[13]!==h||e[14]!==d?(_=c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[h,d]}),e[13]=h,e[14]=d,e[15]=_):_=e[15],_}function Hg(t){const e=F.c(4),{onPointerDown:s,label:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx("div",{className:"absolute inset-x-0 bottom-0 h-px bg-transparent transition-colors group-hover:bg-primary"}),e[0]=r):r=e[0];let n;return e[1]!==i||e[2]!==s?(n=c.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":i,onPointerDown:s,className:"group relative -mb-px h-1.5 shrink-0 cursor-row-resize",children:r}),e[1]=i,e[2]=s,e[3]=n):n=e[3],n}function zg(t){if(!t)return{open:!1,height:null};try{const e=JSON.parse(t);return{open:!!e.open,height:typeof e.height=="number"?e.height:null}}catch{return{open:!1,height:null}}}const wc=t=>`preview-drawer:${t}`,Wg=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function $g(t){try{return zg(localStorage.getItem(wc(t)))}catch{return{open:!1,height:null}}}function al(t,e){try{localStorage.setItem(wc(t),JSON.stringify(e))}catch{}}function Ug(){const t=F.c(27),{org:e}=ki(),s=xs()?.virtualMcpId??null,i=th(),r=Pr(),n=V.useRef(null);let o;t[0]!==r||t[1]!==i||t[2]!==s?(o=w=>{w!=="setup"||!s||n.current!==s&&Wg.test(r.getBuffer("setup"))&&(n.current=s,i.restart())},t[0]=r,t[1]=i,t[2]=s,t[3]=o):o=t[3],Ul(o);const a=s??"__no-vmcp__",[h,l]=V.useState(null),[u,d]=V.useState(null),_=V.useRef(null);if(_.current!==a){_.current=a;const w=$g(a);l(w.open),d(w.height)}const m=h??!1;let f;t[4]!==u||t[5]!==a?(f=w=>{l(w),al(a,{open:w,height:u})},t[4]=u,t[5]=a,t[6]=f):f=t[6];const p=f;let g;t[7]!==m||t[8]!==a?(g=w=>{d(w),al(a,{open:m,height:w})},t[7]=m,t[8]=a,t[9]=g):g=t[9];const v=g,C=i.vmEntry?.sandboxHandle??"no-vm",S=i.vmEntry?.sandboxHandle??null;let b;return t[10]!==u||t[11]!==r.scripts||t[12]!==v||t[13]!==p||t[14]!==i.branch||t[15]!==i.restart||t[16]!==i.resume||t[17]!==i.retry||t[18]!==i.start||t[19]!==i.status||t[20]!==i.stop||t[21]!==m||t[22]!==e.slug||t[23]!==C||t[24]!==S||t[25]!==s?(b=c.jsx(jg,{vmId:S,orgSlug:e.slug,virtualMcpId:s,branch:i.branch,status:i.status,scripts:r.scripts,open:m,onOpenChange:p,height:u,onHeightChange:v,onStart:i.start,onStop:i.stop,onRestart:i.restart,onResume:i.resume,onRetry:i.retry},C),t[10]=u,t[11]=r.scripts,t[12]=v,t[13]=p,t[14]=i.branch,t[15]=i.restart,t[16]=i.resume,t[17]=i.retry,t[18]=i.start,t[19]=i.status,t[20]=i.stop,t[21]=m,t[22]=e.slug,t[23]=C,t[24]=S,t[25]=s,t[26]=b):b=t[26],b}function Kg(t){const e=F.c(33),{orgSlug:s,virtualMcpId:i,branch:r}=t,n=ge(),[o,a]=V.useState(!1),h=Zs(i,r),l=h.kind==="protocol"&&h.source==="local"?h:null;let u;e[0]!==r||e[1]!==s||e[2]!==i?(u=r?{orgSlug:s,virtualMcpId:i,branch:r}:null,e[0]=r,e[1]=s,e[2]=i,e[3]=u):u=e[3];const d=Jn(u),{data:_}=yl(l,d);if(!l||!d||!r)return null;let m;e[4]!==_?(m=_?Object.keys(_.changes).length:0,e[4]=_,e[5]=m):m=e[5];const f=m;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>a(!0),e[6]=p):p=e[6];let g;e[7]!==f||e[8]!==n?(g=f>0?n("decoServe.changes.buttonCount",{count:f}):n("decoServe.changes.button"),e[7]=f,e[8]=n,e[9]=g):g=e[9];let v;e[10]!==g?(v=c.jsx(_e,{size:"sm",variant:"outline","data-testid":"local-changes-button",onClick:p,children:g}),e[10]=g,e[11]=v):v=e[11];let C;e[12]!==n?(C=n("decoServe.changes.title"),e[12]=n,e[13]=C):C=e[13];let S;e[14]!==C?(S=c.jsx(fl,{className:"sr-only",children:C}),e[14]=C,e[15]=S):S=e[15];let b;e[16]!==r||e[17]!==d||e[18]!==l||e[19]!==o||e[20]!==s||e[21]!==n||e[22]!==i?(b=o?c.jsx(ml,{children:E=>{const{reset:I}=E;return c.jsx(pl,{fallback:y=>{const{resetError:B}=y;return c.jsx(qn,{title:n("decoServe.changes.title"),body:c.jsx("p",{className:"px-4 py-6 text-xs text-muted-foreground",children:n("decoServe.changes.loadFailed")}),onClose:()=>{I(),B(),a(!1)}})},children:c.jsx(V.Suspense,{fallback:c.jsx(Pi,{pane:c.jsx(So,{}),list:c.jsx(qn,{title:n("decoServe.changes.title"),loading:!0,body:c.jsx(gi,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Ds,{}),c.jsx(Ds,{})]})}),onClose:()=>a(!1)})}),children:c.jsx(qg,{orgSlug:s,virtualMcpId:i,branch:r,backend:l,cacheKey:d,onClose:()=>a(!1)})})})}}):null,e[16]=r,e[17]=d,e[18]=l,e[19]=o,e[20]=s,e[21]=n,e[22]=i,e[23]=b):b=e[23];let w;e[24]!==S||e[25]!==b?(w=c.jsxs(_l,{"aria-describedby":void 0,className:"flex h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-none flex-col md:flex-row md:h-[calc(100dvh-6rem)] md:w-[calc(100vw-6rem)] gap-0 overflow-hidden p-0 sm:max-w-none",closeButtonClassName:"top-3.5 right-3.5",children:[S,b]}),e[24]=S,e[25]=b,e[26]=w):w=e[26];let x;e[27]!==o||e[28]!==w?(x=c.jsx(ul,{open:o,onOpenChange:a,children:w}),e[27]=o,e[28]=w,e[29]=x):x=e[29];let D;return e[30]!==x||e[31]!==v?(D=c.jsxs(c.Fragment,{children:[v,x]}),e[30]=x,e[31]=v,e[32]=D):D=e[32],D}function qn(t){const e=F.c(22),{title:s,trailing:i,body:r,loading:n,onClose:o}=t,a=n===void 0?!1:n,h=ge(),l=a?"loading":"ready";let u;e[0]!==s?(u=c.jsx("span",{className:"truncate",children:s}),e[0]=s,e[1]=u):u=e[1];let d;e[2]!==u||e[3]!==i?(d=c.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[u,i]}),e[2]=u,e[3]=i,e[4]=d):d=e[4];let _;e[5]!==h?(_=h("decoServe.changes.hint"),e[5]=h,e[6]=_):_=e[6];let m;e[7]!==_?(m=c.jsx("p",{className:"text-[11px] text-muted-foreground",children:c.jsx($l,{text:_})}),e[7]=_,e[8]=m):m=e[8];let f;e[9]!==h?(f=h("decoServe.changes.close"),e[9]=h,e[10]=f):f=e[10];let p;e[11]!==o||e[12]!==f?(p=c.jsx(_e,{type:"button",variant:"outline",className:"w-full",onClick:o,children:f}),e[11]=o,e[12]=f,e[13]=p):p=e[13];let g;e[14]!==m||e[15]!==p?(g=c.jsxs(c.Fragment,{children:[m,p]}),e[14]=m,e[15]=p,e[16]=g):g=e[16];let v;return e[17]!==r||e[18]!==l||e[19]!==d||e[20]!==g?(v=c.jsx(Br,{state:l,header:d,body:r,footer:g}),e[17]=r,e[18]=l,e[19]=d,e[20]=g,e[21]=v):v=e[21],v}function qg(t){const e=F.c(48),{orgSlug:s,virtualMcpId:i,branch:r,backend:n,cacheKey:o,onClose:a}=t,h=ge();let l;e[0]!==n||e[1]!==o?(l={backend:n,cacheKey:o},e[0]=n,e[1]=o,e[2]=l):l=e[2];const u=bo(l);let d;e[3]!==r||e[4]!==s||e[5]!==u.refresh||e[6]!==i?(d={orgSlug:s,virtualMcpId:i,branch:r,refresh:u.refresh},e[3]=r,e[4]=s,e[5]=u.refresh,e[6]=i,e[7]=d):d=e[7];const _=yh(d),m=wl(s,i).phase==="saving",f=n.describe.readOnly,[p,g]=V.useState(null),[v,C]=V.useState(null),[S,b]=V.useState(!1),{summary:w}=u;let x,D,E,I,y;if(e[8]!==p||e[9]!==n||e[10]!==v||e[11]!==_||e[12]!==S||e[13]!==m||e[14]!==f||e[15]!==u.entries||e[16]!==u.sidesFailed||e[17]!==u.sidesPending||e[18]!==w.blocks||e[19]!==w.count||e[20]!==w.pages||e[21]!==h){const k=[...w.pages,...w.blocks],A=k.find(N=>ft(N)===p)??k[0]??null;let M;e[27]!==w.count||e[28]!==h?(M=w.count===0?h("decoServe.changes.title"):w.count===1?h("decoServe.changes.titleOne"):h("decoServe.changes.titleCount",{count:w.count}),e[27]=w.count,e[28]=h,e[29]=M):M=e[29],y=M;const P=(N,z)=>z.length===0?null:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("div",{className:"px-0.5 text-[11px] font-medium tracking-wider text-muted-foreground uppercase",children:N}),z.map(H=>{const W=ft(H);return c.jsx(bh,{change:H,bodyPending:u.sidesPending,selected:A!==null&&ft(A)===W,onSelect:()=>g(W),confirming:v===W,onConfirmingChange:ee=>C(ee?W:null),onDiscard:f||!H.entry?void 0:()=>{_(n,[H.entry],h("thread.publishPopover.discarded",{name:H.name}))},isPublishing:!1,isDiscarding:m},W)})]});let T;e[30]!==n||e[31]!==_||e[32]!==S||e[33]!==m||e[34]!==f||e[35]!==u.entries||e[36]!==w.count||e[37]!==h?(T=f||w.count<=1?null:c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"ml-auto shrink-0 text-[11px] text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>b(!0),disabled:m,children:h("thread.publishPopover.discardAll")}),c.jsx(no,{open:S,onOpenChange:b,children:c.jsxs(ro,{children:[c.jsxs(eo,{children:[c.jsx(Zn,{children:h("thread.publishPopover.discardAllTitle")}),c.jsx(Qn,{children:h("thread.publishPopover.discardAllConfirm")})]}),c.jsxs(io,{children:[c.jsx(to,{children:h("thread.publishDialog.cancel")}),c.jsx(so,{onClick:()=>{_(n,u.entries,h("thread.publishDialog.allChangesDiscarded"))},disabled:m,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:h("thread.publishPopover.discardAll")})]})]})})]}),e[30]=n,e[31]=_,e[32]=S,e[33]=m,e[34]=f,e[35]=u.entries,e[36]=w.count,e[37]=h,e[38]=T):T=e[38],E=T,D=w.count===0?c.jsxs("div",{className:"flex flex-col items-center gap-1 py-10 text-center",children:[c.jsx(uo,{className:"mb-1 size-5 text-success"}),c.jsx("p",{className:"text-sm font-medium",children:h("decoServe.changes.empty")})]}):c.jsxs(gi,{children:[P(h("thread.publishPopover.pagesGroup"),w.pages),P(h("thread.publishPopover.blocksGroup"),w.blocks),u.sidesFailed?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:h("thread.publishPopover.detailsUnavailable")}):null]}),x=Pi,I=A?c.jsx("div",{className:ie(Gs,"relative flex"),children:c.jsx(wh,{change:A,diff:null,bodyPending:u.sidesPending,previewServerUrl:null,draft:null,lastPage:null},ft(A))}):c.jsx("div",{className:ie(Gs,"bg-muted/40")}),e[8]=p,e[9]=n,e[10]=v,e[11]=_,e[12]=S,e[13]=m,e[14]=f,e[15]=u.entries,e[16]=u.sidesFailed,e[17]=u.sidesPending,e[18]=w.blocks,e[19]=w.count,e[20]=w.pages,e[21]=h,e[22]=x,e[23]=D,e[24]=E,e[25]=I,e[26]=y}else x=e[22],D=e[23],E=e[24],I=e[25],y=e[26];let B;e[39]!==D||e[40]!==E||e[41]!==a||e[42]!==y?(B=c.jsx(qn,{title:y,trailing:E,body:D,onClose:a}),e[39]=D,e[40]=E,e[41]=a,e[42]=y,e[43]=B):B=e[43];let R;return e[44]!==x||e[45]!==I||e[46]!==B?(R=c.jsx(x,{pane:I,list:B}),e[44]=x,e[45]=I,e[46]=B,e[47]=R):R=e[47],R}function Vg(t){const e=F.c(11),{virtualMcpId:s,branch:i}=t,r=ge(),n=Zs(s,i);if(!(n.kind==="protocol"&&n.source==="local"&&n.describe.readOnly))return null;let a;e[0]!==r?(a=r("decoServe.readOnly.label"),e[0]=r,e[1]=a):a=e[1];let h;e[2]!==a?(h=c.jsx(rt,{asChild:!0,children:c.jsx("span",{tabIndex:0,"data-testid":"deco-serve-read-only",className:"shrink-0 rounded-full bg-warning/10 px-2 py-0.5 text-xs font-medium text-foreground",children:a})}),e[2]=a,e[3]=h):h=e[3];let l;e[4]!==r?(l=r("decoServe.readOnly.tooltip"),e[4]=r,e[5]=l):l=e[5];let u;e[6]!==l?(u=c.jsx(nt,{side:"bottom",className:"max-w-xs",children:c.jsx($l,{text:l})}),e[6]=l,e[7]=u):u=e[7];let d;return e[8]!==h||e[9]!==u?(d=c.jsxs(it,{children:[h,u]}),e[8]=h,e[9]=u,e[10]=d):d=e[10],d}function Yg(t){const e=F.c(5),{virtualMcpId:s,branch:i}=t,r=ge(),n=Zs(s,i);if(!Gg(n))return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(rt,{asChild:!0,children:c.jsx("span",{"data-testid":"content-version-badge",className:"shrink-0 rounded border border-border px-1.5 py-px font-mono text-[11px] leading-4 text-muted-foreground",children:"v8"})}),e[0]=o):o=e[0];let a;e[1]!==r?(a=r("decoServe.version.v8"),e[1]=r,e[2]=a):a=e[2];let h;return e[3]!==a?(h=c.jsxs(it,{children:[o,c.jsx(nt,{side:"bottom",className:"max-w-xs",children:a})]}),e[3]=a,e[4]=h):h=e[4],h}function Gg(t){return t.kind==="protocol"?t.hasSchema!==!1:t.kind==="unavailable"&&t.source!=="local"}function Xg(){const t=F.c(27),e=xs(),{org:s}=ki(),i=Cr(e?.virtualMcpId),r=e?.currentBranch??null,n=kr(i?.id).runtime,{url:o,undecided:a}=Yn(i?.id),{connection:h}=Gn(i?.id??e?.virtualMcpId),l=!!h,u=i?.id??e?.virtualMcpId;if(!u||!i&&!l)return null;let d;t[0]!==r||t[1]!==u?(d=c.jsx(Yg,{virtualMcpId:u,branch:r}),t[0]=r,t[1]=u,t[2]=d):d=t[2];let _;t[3]!==r||t[4]!==l||t[5]!==u?(_=l&&c.jsx(Vg,{virtualMcpId:u,branch:r}),t[3]=r,t[4]=l,t[5]=u,t[6]=_):_=t[6];let m;t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==u?(m=l&&c.jsx(Kg,{orgSlug:s.slug,virtualMcpId:u,branch:r}),t[7]=r,t[8]=s,t[9]=l,t[10]=u,t[11]=m):m=t[11];let f;t[12]!==r||t[13]!==i?(f=i&&c.jsx("div",{className:"flex min-w-0 shrink items-center justify-end",children:c.jsx(ku,{virtualMcp:i,currentBranch:r})}),t[12]=r,t[13]=i,t[14]=f):f=t[14];let p;t[15]!==i||t[16]!==o||t[17]!==n||t[18]!==l||t[19]!==a?(p=i&&!o&&!a&&!l&&gd(i)&&c.jsxs(c.Fragment,{children:[c.jsx(Nc,{orientation:"vertical",className:"mx-1 data-[orientation=vertical]:h-4"}),c.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:n==="cms"?c.jsx(e_,{virtualMcpId:i.id}):c.jsx(f_,{virtualMcpId:i.id})})]}),t[15]=i,t[16]=o,t[17]=n,t[18]=l,t[19]=a,t[20]=p):p=t[20];let g;return t[21]!==d||t[22]!==_||t[23]!==m||t[24]!==f||t[25]!==p?(g=c.jsxs(c.Fragment,{children:[d,_,m,f,p]}),t[21]=d,t[22]=_,t[23]=m,t[24]=f,t[25]=p,t[26]=g):g=t[26],g}function Jg(){const t=F.c(10),e=xs(),s=Cr(e?.virtualMcpId),i=e?.activeTask,r=eu(),n=kr(s?.id).runtime,{url:o,undecided:a}=Yn(s?.id),{connection:h}=Gn(s?.id??e?.virtualMcpId),l=!!h;let u;t[0]!==r||t[1]!==i?.metadata||t[2]!==s?.metadata||t[3]!==o||t[4]!==l||t[5]!==n||t[6]!==a?(u=!o&&!a&&!l&&g_({hasClonableSource:$o(s?.metadata)||$o(i?.metadata),fastPreviewActive:n==="cms",mainTab:r??null}),t[0]=r,t[1]=i?.metadata,t[2]=s?.metadata,t[3]=o,t[4]=l,t[5]=n,t[6]=a,t[7]=u):u=t[7];const d=u;let _;return t[8]!==d?(_=d?c.jsx(Ug,{}):null,t[8]=d,t[9]=_):_=t[9],_}function Jb(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(tu.Content,{actions:c.jsx(Xg,{}),drawer:c.jsx(Jg,{}),children:c.jsx(Tc,{})}),t[0]=e):e=t[0],e}export{Jb as default};
27
+ `,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 ln.get()},set promptLabel(t){ln.set(t)},get tooMuchOutput(){return hn.get()},set tooMuchOutput(t){hn.set(t)}}}_verifyIntegers(...t){for(rs of t)if(rs===1/0||isNaN(rs)||rs%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(rs of t)if(rs&&(rs===1/0||isNaN(rs)||rs%1!==0||rs<0))throw new Error("This API only accepts positive integers")}};var Tg=2,Ng=1,Lg=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),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=i-a,u=r-h-e;return{cols:Math.max(Tg,Math.floor(u/t.css.cell.width)),rows:Math.max(Ng,Math.floor(l/t.css.cell.height))}}};function Ig({source:t,onReady:e,onSelectionChange:s,className:i}){const r=V.useRef(null),n=V.useRef(null),o=V.useRef(s);o.current=s;const a=Pr(),h=V.useRef(t);return h.current=t,Ul((l,u)=>{l===h.current&&n.current?.write(u)}),V.useEffect(()=>{const l=r.current;if(!l)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,_=new Mg({allowTransparency:!1,fontFamily:d("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:d("--sidebar")||d("--card")||d("--background")||"#1e1e1e",cursor:"transparent",foreground:d("--foreground")||"#d4d4d4",selectionBackground:d("--accent"),selectionForeground:d("--accent-foreground"),black:d("--muted"),red:d("--destructive"),green:d("--success"),yellow:d("--warning"),blue:d("--chart-1"),magenta:d("--chart-3"),cyan:d("--chart-5"),white:d("--foreground"),brightBlack:d("--muted-foreground"),brightRed:d("--destructive"),brightGreen:d("--success"),brightYellow:d("--warning"),brightBlue:d("--chart-1"),brightMagenta:d("--chart-3"),brightCyan:d("--chart-5"),brightWhite:d("--foreground")}}),m=new Lg;_.loadAddon(m),_.open(l),m.fit();const f=a.getBuffer(t);f&&_.write(f),n.current=_,e?.(_);const p=_.onSelectionChange(()=>{const v=!!_.getSelection();o.current?.(v,()=>_.getSelection())}),g=new ResizeObserver(()=>{m.fit()});return g.observe(l),()=>{p.dispose(),g.disconnect(),n.current=null,_.dispose()}},[]),c.jsx("div",{className:ie("h-full bg-sidebar p-3",i),children:c.jsx("div",{ref:r,className:"h-full"})})}const Kn=120,Sc=160;function Og(t,e,s=Sc){const i=Math.max(Kn,e-s);return Math.min(Math.max(t,Kn),i)}function jg(t){const e=ge(),s=Pr(),[i,r]=V.useState(As),[n,o]=V.useState([]),[a,h]=V.useState(new Set),l=V.useRef(!1);if(!l.current&&s.scripts.length>0){const y=ou.find(B=>s.scripts.includes(B));y&&(l.current=!0,o(B=>B.includes(y)?B:[...B,y]),r(y))}if(a.size>0){let y=!1;const B=new Set(a);for(const R of a)s.activeProcesses.includes(R)||(B.delete(R),y=!0);y&&h(B)}const u=()=>t.onOpenChange(!t.open),d=y=>{r(y),t.open||t.onOpenChange(!0)},_=xs()?.taskId??null,m={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId??"",branch:t.branch??"",threadId:_??null},f=y=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(Ko(m,`exec/${encodeURIComponent(y)}`),{method:"POST"}),p=y=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(Ko(m,`exec/${encodeURIComponent(y)}/kill`),{method:"POST"}),g=async(y,B)=>{try{const R=await f(y);if(R===null)return;if(!R.ok)throw new Error(`Exec failed: ${R.statusText}`)}catch{Je.error(B)}},v=async y=>{o(B=>B.includes(y)?B:[...B,y]),r(y),t.onOpenChange(!0),await g(y,e("sandbox.drawer.failedToRun",{name:y}))},C=async y=>{await p(y),o(B=>B.filter(R=>R!==y)),i===y&&r(As)},S=async()=>{const B=s.activeProcesses.includes(i)?e("sandbox.drawer.failedToRestart",{name:i}):e("sandbox.drawer.failedToRun",{name:i});await g(i,B)},b=async()=>{if(!a.has(i)){h(y=>new Set(y).add(i));try{const y=await p(i);if(y===null){h(B=>{const R=new Set(B);return R.delete(i),R});return}if(!y.ok)throw new Error(`Kill failed: ${y.statusText}`)}catch{h(y=>{const B=new Set(y);return B.delete(i),B}),Je.error(e("sandbox.drawer.failedToStop",{name:i}))}}},w=i!==As&&n.includes(i),x=w&&s.activeProcesses.includes(i),D=w&&a.has(i),E=V.useRef(null),I=y=>{if(!t.open)return;const B=E.current,R=B?.parentElement;if(!B||!R)return;y.preventDefault();const k=y.currentTarget,{pointerId:A}=y;k.setPointerCapture(A);const M=y.clientY,P=B.getBoundingClientRect().height,T=R.getBoundingClientRect().height;let N=P;const z=W=>{W.pointerId===A&&(N=Og(P+(M-W.clientY),T),B.style.height=`${N}px`)},H=W=>{W.pointerId===A&&(k.removeEventListener("pointermove",z),k.removeEventListener("pointerup",H),k.removeEventListener("pointercancel",H),document.body.style.userSelect="",document.body.style.cursor="",t.onHeightChange(N))};document.body.style.userSelect="none",document.body.style.cursor="row-resize",k.addEventListener("pointermove",z),k.addEventListener("pointerup",H),k.addEventListener("pointercancel",H)};return c.jsxs("div",{ref:E,className:"flex shrink-0 flex-col",style:{height:t.open?t.height??"50%":"auto",maxHeight:t.open?`max(${Kn}px, calc(100% - ${Sc}px))`:void 0},children:[t.open&&c.jsx(Hg,{onPointerDown:I,label:e("sandbox.preview.resizeTerminal")}),c.jsx(v_,{status:t.status,open:t.open,onToggle:u,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:i,scriptTabs:n,onSelectTab:d,onAddScript:v,onCloseScript:C,showScriptControls:w,scriptIsRunning:x,scriptIsKilling:D,onRunActiveScript:S,onStopActiveScript:b}),t.open&&c.jsx("div",{className:"flex-1 overflow-hidden",children:c.jsx(Fg,{vmId:t.vmId,active:i,hasData:s.hasData(i),onRunActive:S})})]})}function Fg(t){const e=F.c(16),{vmId:s,active:i,hasData:r,onRunActive:n}=t,o=ge();if(!s)return null;if(i===As||r){let m;return e[0]!==i?(m=c.jsx(Ig,{source:i,className:"h-full"},i),e[0]=i,e[1]=m):m=e[1],m}let a;e[2]!==i||e[3]!==o?(a=o("sandbox.drawer.scriptNotRunning",{name:i}),e[2]=i,e[3]=o,e[4]=a):a=e[4];let h;e[5]!==a?(h=c.jsx("p",{children:a}),e[5]=a,e[6]=h):h=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(lr,{className:"size-3.5"}),e[7]=l):l=e[7];let u;e[8]!==o?(u=o("sandbox.drawer.run"),e[8]=o,e[9]=u):u=e[9];let d;e[10]!==n||e[11]!==u?(d=c.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-accent",children:[l," ",u]}),e[10]=n,e[11]=u,e[12]=d):d=e[12];let _;return e[13]!==h||e[14]!==d?(_=c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[h,d]}),e[13]=h,e[14]=d,e[15]=_):_=e[15],_}function Hg(t){const e=F.c(4),{onPointerDown:s,label:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx("div",{className:"absolute inset-x-0 bottom-0 h-px bg-transparent transition-colors group-hover:bg-primary"}),e[0]=r):r=e[0];let n;return e[1]!==i||e[2]!==s?(n=c.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":i,onPointerDown:s,className:"group relative -mb-px h-1.5 shrink-0 cursor-row-resize",children:r}),e[1]=i,e[2]=s,e[3]=n):n=e[3],n}function zg(t){if(!t)return{open:!1,height:null};try{const e=JSON.parse(t);return{open:!!e.open,height:typeof e.height=="number"?e.height:null}}catch{return{open:!1,height:null}}}const wc=t=>`preview-drawer:${t}`,Wg=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function $g(t){try{return zg(localStorage.getItem(wc(t)))}catch{return{open:!1,height:null}}}function al(t,e){try{localStorage.setItem(wc(t),JSON.stringify(e))}catch{}}function Ug(){const t=F.c(27),{org:e}=ki(),s=xs()?.virtualMcpId??null,i=th(),r=Pr(),n=V.useRef(null);let o;t[0]!==r||t[1]!==i||t[2]!==s?(o=w=>{w!=="setup"||!s||n.current!==s&&Wg.test(r.getBuffer("setup"))&&(n.current=s,i.restart())},t[0]=r,t[1]=i,t[2]=s,t[3]=o):o=t[3],Ul(o);const a=s??"__no-vmcp__",[h,l]=V.useState(null),[u,d]=V.useState(null),_=V.useRef(null);if(_.current!==a){_.current=a;const w=$g(a);l(w.open),d(w.height)}const m=h??!1;let f;t[4]!==u||t[5]!==a?(f=w=>{l(w),al(a,{open:w,height:u})},t[4]=u,t[5]=a,t[6]=f):f=t[6];const p=f;let g;t[7]!==m||t[8]!==a?(g=w=>{d(w),al(a,{open:m,height:w})},t[7]=m,t[8]=a,t[9]=g):g=t[9];const v=g,C=i.vmEntry?.sandboxHandle??"no-vm",S=i.vmEntry?.sandboxHandle??null;let b;return t[10]!==u||t[11]!==r.scripts||t[12]!==v||t[13]!==p||t[14]!==i.branch||t[15]!==i.restart||t[16]!==i.resume||t[17]!==i.retry||t[18]!==i.start||t[19]!==i.status||t[20]!==i.stop||t[21]!==m||t[22]!==e.slug||t[23]!==C||t[24]!==S||t[25]!==s?(b=c.jsx(jg,{vmId:S,orgSlug:e.slug,virtualMcpId:s,branch:i.branch,status:i.status,scripts:r.scripts,open:m,onOpenChange:p,height:u,onHeightChange:v,onStart:i.start,onStop:i.stop,onRestart:i.restart,onResume:i.resume,onRetry:i.retry},C),t[10]=u,t[11]=r.scripts,t[12]=v,t[13]=p,t[14]=i.branch,t[15]=i.restart,t[16]=i.resume,t[17]=i.retry,t[18]=i.start,t[19]=i.status,t[20]=i.stop,t[21]=m,t[22]=e.slug,t[23]=C,t[24]=S,t[25]=s,t[26]=b):b=t[26],b}function Kg(t){const e=F.c(33),{orgSlug:s,virtualMcpId:i,branch:r}=t,n=ge(),[o,a]=V.useState(!1),h=Zs(i,r),l=h.kind==="protocol"&&h.source==="local"?h:null;let u;e[0]!==r||e[1]!==s||e[2]!==i?(u=r?{orgSlug:s,virtualMcpId:i,branch:r}:null,e[0]=r,e[1]=s,e[2]=i,e[3]=u):u=e[3];const d=Jn(u),{data:_}=yl(l,d);if(!l||!d||!r)return null;let m;e[4]!==_?(m=_?Object.keys(_.changes).length:0,e[4]=_,e[5]=m):m=e[5];const f=m;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>a(!0),e[6]=p):p=e[6];let g;e[7]!==f||e[8]!==n?(g=f>0?n("decoServe.changes.buttonCount",{count:f}):n("decoServe.changes.button"),e[7]=f,e[8]=n,e[9]=g):g=e[9];let v;e[10]!==g?(v=c.jsx(_e,{size:"sm",variant:"outline","data-testid":"local-changes-button",onClick:p,children:g}),e[10]=g,e[11]=v):v=e[11];let C;e[12]!==n?(C=n("decoServe.changes.title"),e[12]=n,e[13]=C):C=e[13];let S;e[14]!==C?(S=c.jsx(fl,{className:"sr-only",children:C}),e[14]=C,e[15]=S):S=e[15];let b;e[16]!==r||e[17]!==d||e[18]!==l||e[19]!==o||e[20]!==s||e[21]!==n||e[22]!==i?(b=o?c.jsx(ml,{children:E=>{const{reset:I}=E;return c.jsx(pl,{fallback:y=>{const{resetError:B}=y;return c.jsx(qn,{title:n("decoServe.changes.title"),body:c.jsx("p",{className:"px-4 py-6 text-xs text-muted-foreground",children:n("decoServe.changes.loadFailed")}),onClose:()=>{I(),B(),a(!1)}})},children:c.jsx(V.Suspense,{fallback:c.jsx(Pi,{pane:c.jsx(So,{}),list:c.jsx(qn,{title:n("decoServe.changes.title"),loading:!0,body:c.jsx(gi,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Ds,{}),c.jsx(Ds,{})]})}),onClose:()=>a(!1)})}),children:c.jsx(qg,{orgSlug:s,virtualMcpId:i,branch:r,backend:l,cacheKey:d,onClose:()=>a(!1)})})})}}):null,e[16]=r,e[17]=d,e[18]=l,e[19]=o,e[20]=s,e[21]=n,e[22]=i,e[23]=b):b=e[23];let w;e[24]!==S||e[25]!==b?(w=c.jsxs(_l,{"aria-describedby":void 0,className:"flex h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-none flex-col md:flex-row md:h-[calc(100dvh-6rem)] md:w-[calc(100vw-6rem)] gap-0 overflow-hidden p-0 sm:max-w-none",closeButtonClassName:"top-3.5 right-3.5",children:[S,b]}),e[24]=S,e[25]=b,e[26]=w):w=e[26];let x;e[27]!==o||e[28]!==w?(x=c.jsx(ul,{open:o,onOpenChange:a,children:w}),e[27]=o,e[28]=w,e[29]=x):x=e[29];let D;return e[30]!==x||e[31]!==v?(D=c.jsxs(c.Fragment,{children:[v,x]}),e[30]=x,e[31]=v,e[32]=D):D=e[32],D}function qn(t){const e=F.c(22),{title:s,trailing:i,body:r,loading:n,onClose:o}=t,a=n===void 0?!1:n,h=ge(),l=a?"loading":"ready";let u;e[0]!==s?(u=c.jsx("span",{className:"truncate",children:s}),e[0]=s,e[1]=u):u=e[1];let d;e[2]!==u||e[3]!==i?(d=c.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[u,i]}),e[2]=u,e[3]=i,e[4]=d):d=e[4];let _;e[5]!==h?(_=h("decoServe.changes.hint"),e[5]=h,e[6]=_):_=e[6];let m;e[7]!==_?(m=c.jsx("p",{className:"text-[11px] text-muted-foreground",children:c.jsx($l,{text:_})}),e[7]=_,e[8]=m):m=e[8];let f;e[9]!==h?(f=h("decoServe.changes.close"),e[9]=h,e[10]=f):f=e[10];let p;e[11]!==o||e[12]!==f?(p=c.jsx(_e,{type:"button",variant:"outline",className:"w-full",onClick:o,children:f}),e[11]=o,e[12]=f,e[13]=p):p=e[13];let g;e[14]!==m||e[15]!==p?(g=c.jsxs(c.Fragment,{children:[m,p]}),e[14]=m,e[15]=p,e[16]=g):g=e[16];let v;return e[17]!==r||e[18]!==l||e[19]!==d||e[20]!==g?(v=c.jsx(Br,{state:l,header:d,body:r,footer:g}),e[17]=r,e[18]=l,e[19]=d,e[20]=g,e[21]=v):v=e[21],v}function qg(t){const e=F.c(48),{orgSlug:s,virtualMcpId:i,branch:r,backend:n,cacheKey:o,onClose:a}=t,h=ge();let l;e[0]!==n||e[1]!==o?(l={backend:n,cacheKey:o},e[0]=n,e[1]=o,e[2]=l):l=e[2];const u=bo(l);let d;e[3]!==r||e[4]!==s||e[5]!==u.refresh||e[6]!==i?(d={orgSlug:s,virtualMcpId:i,branch:r,refresh:u.refresh},e[3]=r,e[4]=s,e[5]=u.refresh,e[6]=i,e[7]=d):d=e[7];const _=yh(d),m=wl(s,i).phase==="saving",f=n.describe.readOnly,[p,g]=V.useState(null),[v,C]=V.useState(null),[S,b]=V.useState(!1),{summary:w}=u;let x,D,E,I,y;if(e[8]!==p||e[9]!==n||e[10]!==v||e[11]!==_||e[12]!==S||e[13]!==m||e[14]!==f||e[15]!==u.entries||e[16]!==u.sidesFailed||e[17]!==u.sidesPending||e[18]!==w.blocks||e[19]!==w.count||e[20]!==w.pages||e[21]!==h){const k=[...w.pages,...w.blocks],A=k.find(N=>ft(N)===p)??k[0]??null;let M;e[27]!==w.count||e[28]!==h?(M=w.count===0?h("decoServe.changes.title"):w.count===1?h("decoServe.changes.titleOne"):h("decoServe.changes.titleCount",{count:w.count}),e[27]=w.count,e[28]=h,e[29]=M):M=e[29],y=M;const P=(N,z)=>z.length===0?null:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("div",{className:"px-0.5 text-[11px] font-medium tracking-wider text-muted-foreground uppercase",children:N}),z.map(H=>{const W=ft(H);return c.jsx(bh,{change:H,bodyPending:u.sidesPending,selected:A!==null&&ft(A)===W,onSelect:()=>g(W),confirming:v===W,onConfirmingChange:ee=>C(ee?W:null),onDiscard:f||!H.entry?void 0:()=>{_(n,[H.entry],h("thread.publishPopover.discarded",{name:H.name}))},isPublishing:!1,isDiscarding:m},W)})]});let T;e[30]!==n||e[31]!==_||e[32]!==S||e[33]!==m||e[34]!==f||e[35]!==u.entries||e[36]!==w.count||e[37]!==h?(T=f||w.count<=1?null:c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"ml-auto shrink-0 text-[11px] text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>b(!0),disabled:m,children:h("thread.publishPopover.discardAll")}),c.jsx(no,{open:S,onOpenChange:b,children:c.jsxs(ro,{children:[c.jsxs(eo,{children:[c.jsx(Zn,{children:h("thread.publishPopover.discardAllTitle")}),c.jsx(Qn,{children:h("thread.publishPopover.discardAllConfirm")})]}),c.jsxs(io,{children:[c.jsx(to,{children:h("thread.publishDialog.cancel")}),c.jsx(so,{onClick:()=>{_(n,u.entries,h("thread.publishDialog.allChangesDiscarded"))},disabled:m,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:h("thread.publishPopover.discardAll")})]})]})})]}),e[30]=n,e[31]=_,e[32]=S,e[33]=m,e[34]=f,e[35]=u.entries,e[36]=w.count,e[37]=h,e[38]=T):T=e[38],E=T,D=w.count===0?c.jsxs("div",{className:"flex flex-col items-center gap-1 py-10 text-center",children:[c.jsx(uo,{className:"mb-1 size-5 text-success"}),c.jsx("p",{className:"text-sm font-medium",children:h("decoServe.changes.empty")})]}):c.jsxs(gi,{children:[P(h("thread.publishPopover.pagesGroup"),w.pages),P(h("thread.publishPopover.blocksGroup"),w.blocks),u.sidesFailed?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:h("thread.publishPopover.detailsUnavailable")}):null]}),x=Pi,I=A?c.jsx("div",{className:ie(Gs,"relative flex"),children:c.jsx(wh,{change:A,diff:null,bodyPending:u.sidesPending,previewServerUrl:null,draft:null,lastPage:null},ft(A))}):c.jsx("div",{className:ie(Gs,"bg-muted/40")}),e[8]=p,e[9]=n,e[10]=v,e[11]=_,e[12]=S,e[13]=m,e[14]=f,e[15]=u.entries,e[16]=u.sidesFailed,e[17]=u.sidesPending,e[18]=w.blocks,e[19]=w.count,e[20]=w.pages,e[21]=h,e[22]=x,e[23]=D,e[24]=E,e[25]=I,e[26]=y}else x=e[22],D=e[23],E=e[24],I=e[25],y=e[26];let B;e[39]!==D||e[40]!==E||e[41]!==a||e[42]!==y?(B=c.jsx(qn,{title:y,trailing:E,body:D,onClose:a}),e[39]=D,e[40]=E,e[41]=a,e[42]=y,e[43]=B):B=e[43];let R;return e[44]!==x||e[45]!==I||e[46]!==B?(R=c.jsx(x,{pane:I,list:B}),e[44]=x,e[45]=I,e[46]=B,e[47]=R):R=e[47],R}function Vg(t){const e=F.c(11),{virtualMcpId:s,branch:i}=t,r=ge(),n=Zs(s,i);if(!(n.kind==="protocol"&&n.source==="local"&&n.describe.readOnly))return null;let a;e[0]!==r?(a=r("decoServe.readOnly.label"),e[0]=r,e[1]=a):a=e[1];let h;e[2]!==a?(h=c.jsx(rt,{asChild:!0,children:c.jsx("span",{tabIndex:0,"data-testid":"deco-serve-read-only",className:"shrink-0 rounded-full bg-warning/10 px-2 py-0.5 text-xs font-medium text-foreground",children:a})}),e[2]=a,e[3]=h):h=e[3];let l;e[4]!==r?(l=r("decoServe.readOnly.tooltip"),e[4]=r,e[5]=l):l=e[5];let u;e[6]!==l?(u=c.jsx(nt,{side:"bottom",className:"max-w-xs",children:c.jsx($l,{text:l})}),e[6]=l,e[7]=u):u=e[7];let d;return e[8]!==h||e[9]!==u?(d=c.jsxs(it,{children:[h,u]}),e[8]=h,e[9]=u,e[10]=d):d=e[10],d}function Yg(t){const e=F.c(5),{virtualMcpId:s,branch:i}=t,r=ge(),n=Zs(s,i);if(!Gg(n))return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(rt,{asChild:!0,children:c.jsx("span",{"data-testid":"content-version-badge",className:"shrink-0 rounded border border-border px-1.5 py-px font-mono text-[11px] leading-4 text-muted-foreground",children:"v8"})}),e[0]=o):o=e[0];let a;e[1]!==r?(a=r("decoServe.version.v8"),e[1]=r,e[2]=a):a=e[2];let h;return e[3]!==a?(h=c.jsxs(it,{children:[o,c.jsx(nt,{side:"bottom",className:"max-w-xs",children:a})]}),e[3]=a,e[4]=h):h=e[4],h}function Gg(t){return t.kind==="protocol"?t.hasSchema!==!1:t.kind==="unavailable"&&t.source!=="local"}function Xg(){const t=F.c(27),e=xs(),{org:s}=ki(),i=Cr(e?.virtualMcpId),r=e?.currentBranch??null,n=kr(i?.id).runtime,{url:o,undecided:a}=Yn(i?.id),{connection:h}=Gn(i?.id??e?.virtualMcpId),l=!!h,u=i?.id??e?.virtualMcpId;if(!u||!i&&!l)return null;let d;t[0]!==r||t[1]!==u?(d=c.jsx(Yg,{virtualMcpId:u,branch:r}),t[0]=r,t[1]=u,t[2]=d):d=t[2];let _;t[3]!==r||t[4]!==l||t[5]!==u?(_=l&&c.jsx(Vg,{virtualMcpId:u,branch:r}),t[3]=r,t[4]=l,t[5]=u,t[6]=_):_=t[6];let m;t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==u?(m=l&&c.jsx(Kg,{orgSlug:s.slug,virtualMcpId:u,branch:r}),t[7]=r,t[8]=s,t[9]=l,t[10]=u,t[11]=m):m=t[11];let f;t[12]!==r||t[13]!==i?(f=i&&c.jsx("div",{className:"flex min-w-0 shrink items-center justify-end",children:c.jsx(ku,{virtualMcp:i,currentBranch:r})}),t[12]=r,t[13]=i,t[14]=f):f=t[14];let p;t[15]!==i||t[16]!==o||t[17]!==n||t[18]!==l||t[19]!==a?(p=i&&!o&&!a&&!l&&gd(i)&&c.jsxs(c.Fragment,{children:[c.jsx(Nc,{orientation:"vertical",className:"mx-1 data-[orientation=vertical]:h-4"}),c.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:n==="cms"?c.jsx(e_,{virtualMcpId:i.id}):c.jsx(m_,{virtualMcpId:i.id})})]}),t[15]=i,t[16]=o,t[17]=n,t[18]=l,t[19]=a,t[20]=p):p=t[20];let g;return t[21]!==d||t[22]!==_||t[23]!==m||t[24]!==f||t[25]!==p?(g=c.jsxs(c.Fragment,{children:[d,_,m,f,p]}),t[21]=d,t[22]=_,t[23]=m,t[24]=f,t[25]=p,t[26]=g):g=t[26],g}function Jg(){const t=F.c(10),e=xs(),s=Cr(e?.virtualMcpId),i=e?.activeTask,r=eu(),n=kr(s?.id).runtime,{url:o,undecided:a}=Yn(s?.id),{connection:h}=Gn(s?.id??e?.virtualMcpId),l=!!h;let u;t[0]!==r||t[1]!==i?.metadata||t[2]!==s?.metadata||t[3]!==o||t[4]!==l||t[5]!==n||t[6]!==a?(u=!o&&!a&&!l&&g_({hasClonableSource:$o(s?.metadata)||$o(i?.metadata),fastPreviewActive:n==="cms",mainTab:r??null}),t[0]=r,t[1]=i?.metadata,t[2]=s?.metadata,t[3]=o,t[4]=l,t[5]=n,t[6]=a,t[7]=u):u=t[7];const d=u;let _;return t[8]!==d?(_=d?c.jsx(Ug,{}):null,t[8]=d,t[9]=_):_=t[9],_}function Jb(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(tu.Content,{actions:c.jsx(Xg,{}),drawer:c.jsx(Jg,{}),children:c.jsx(Tc,{})}),t[0]=e):e=t[0],e}export{Jb as default};