decocms 4.491.2 → 4.492.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (507) hide show
  1. package/dist/client/assets/{ActiveShapeUtils-O3KzxQKu.js → ActiveShapeUtils-QC-80JaD.js} +1 -1
  2. package/dist/client/assets/{AlertCircle-DxGlheNv.js → AlertCircle--xQnBD7d.js} +1 -1
  3. package/dist/client/assets/{AreaChart-DAZPqqE4.js → AreaChart-DcLcpJwq.js} +1 -1
  4. package/dist/client/assets/{ArrowLeft-C5TDkvfy.js → ArrowLeft-CYC7J9yW.js} +1 -1
  5. package/dist/client/assets/{ArrowUp-B_1yzk0u.js → ArrowUp-U1ggjjLO.js} +1 -1
  6. package/dist/client/assets/{BarChart-BQ3lemjs.js → BarChart-C6ZU6W4p.js} +1 -1
  7. package/dist/client/assets/{Building02-aupVb9bk.js → Building02-HV2PP9yH.js} +1 -1
  8. package/dist/client/assets/{CategoricalChart-Cbg52QF6.js → CategoricalChart-BlJZ99ma.js} +1 -1
  9. package/dist/client/assets/{CheckCircle-Ck2nYEsD.js → CheckCircle-drYdikgt.js} +1 -1
  10. package/dist/client/assets/{ChevronSelectorVertical-vEYxYM2o.js → ChevronSelectorVertical-DFKb4uq6.js} +1 -1
  11. package/dist/client/assets/{ChevronUp-CiQJnmx3.js → ChevronUp-DZuLpYB1.js} +1 -1
  12. package/dist/client/assets/{Copy01-CSQiL-8m.js → Copy01-D4AqaFnb.js} +1 -1
  13. package/dist/client/assets/{CreditCard01-Dbsq9vqA.js → CreditCard01-BsSJIpnP.js} +1 -1
  14. package/dist/client/assets/{DotsVertical-D5VxjRuG.js → DotsVertical-BRQyK86q.js} +1 -1
  15. package/dist/client/assets/{ErrorBarContext-C93DPBOn.js → ErrorBarContext-Du4zoKdZ.js} +1 -1
  16. package/dist/client/assets/{Globe04-BYAnRXKE.js → Globe04-CHyEXekU.js} +1 -1
  17. package/dist/client/assets/{Image01-CRH49dh2.js → Image01-iHUacVtP.js} +1 -1
  18. package/dist/client/assets/{Key01-DlUQl2kb.js → Key01-CZzgEM3b.js} +1 -1
  19. package/dist/client/assets/{Link01-CZ9mTgFL.js → Link01-CLZO7iiX.js} +1 -1
  20. package/dist/client/assets/{LinkBroken01-aiXtOyEy.js → LinkBroken01-B1PEGLti.js} +1 -1
  21. package/dist/client/assets/{Monitor01-Dibe2H0E.js → Monitor01-Cp_HdXFf.js} +1 -1
  22. package/dist/client/assets/{Play-JhD_8p9T.js → Play-CFzbBn-6.js} +1 -1
  23. package/dist/client/assets/{Plus-B-VohzJ4.js → Plus-BjGOOPj6.js} +1 -1
  24. package/dist/client/assets/{SearchMd-B4A8PIUy.js → SearchMd-8jxREbgM.js} +1 -1
  25. package/dist/client/assets/{Sector-07CUaZqh.js → Sector-AZp03vzg.js} +1 -1
  26. package/dist/client/assets/{ShoppingBag01-CZ0mlBHZ.js → ShoppingBag01-C_Zwelnq.js} +1 -1
  27. package/dist/client/assets/{Sun-aaILGBFQ.js → Sun-VfgIFUUc.js} +1 -1
  28. package/dist/client/assets/{SwitchHorizontal01-CUO4Tr7k.js → SwitchHorizontal01-f_6gEt2c.js} +1 -1
  29. package/dist/client/assets/{Tool01-B-ugA2BM.js → Tool01-BD6R-D4L.js} +1 -1
  30. package/dist/client/assets/{Trash01--ZO2TG0s.js → Trash01-BuqURrgl.js} +1 -1
  31. package/dist/client/assets/{Upload01-CNXMP8gQ.js → Upload01-CbIQEt1I.js} +1 -1
  32. package/dist/client/assets/{User01-DqG0FbTZ.js → User01-CHX0WSlv.js} +1 -1
  33. package/dist/client/assets/{UserSquare-Dbdn52Lc.js → UserSquare-v2Vi63lF.js} +1 -1
  34. package/dist/client/assets/{Users01-Co0Q_ns9.js → Users01-WUyPxnjn.js} +1 -1
  35. package/dist/client/assets/{XAxis-CjFRctRT.js → XAxis-DnYEgdBg.js} +1 -1
  36. package/dist/client/assets/{XClose-BHLC9coi.js → XClose-Dz5Xu4ap.js} +1 -1
  37. package/dist/client/assets/{ZoomOut-DtT7NZBX.js → ZoomOut-BMJlPGPs.js} +1 -1
  38. package/dist/client/assets/{access-gate-ChYKF6hW.js → access-gate-t5XdpP7o.js} +1 -1
  39. package/dist/client/assets/add-connection-dialog-DRVvTqsY.js +1 -0
  40. package/dist/client/assets/agent-analytics-CcVnAkkt.js +2 -0
  41. package/dist/client/assets/agent-app-BkQm9oem.js +1 -0
  42. package/dist/client/assets/agent-assets-Czl2J78n.js +1 -0
  43. package/dist/client/assets/agent-automation-Ci4UFwzb.js +20 -0
  44. package/dist/client/assets/agent-automations-Bz7d9DBh.js +1 -0
  45. package/dist/client/assets/agent-connect-sources-DIyj1Rir.js +1 -0
  46. package/dist/client/assets/agent-deck-3-EO6Xhr.js +1 -0
  47. package/dist/client/assets/agent-e2e-DIxhjk62.js +1 -0
  48. package/dist/client/assets/agent-experiments-Dn8tNUUB.js +1 -0
  49. package/dist/client/assets/agent-file-CZOQf9Yc.js +1 -0
  50. package/dist/client/assets/agent-hosting-BsE9QUz1.js +1 -0
  51. package/dist/client/assets/agent-icon-V8lPNv7A.js +1 -0
  52. package/dist/client/assets/agent-library-DkCo-Ode.js +1 -0
  53. package/dist/client/assets/agent-library-file-D3g_rHVL.js +1 -0
  54. package/dist/client/assets/agent-monitor-pph3rxpK.js +1 -0
  55. package/dist/client/assets/agent-overview-DW2iu_qJ.js +1 -0
  56. package/dist/client/assets/agent-settings-DW_a2Oeo.js +1 -0
  57. package/dist/client/assets/{agent-site-editor-Cgd_VIhY.js → agent-site-editor--h_d0ri-.js} +5 -5
  58. package/dist/client/assets/agent-site-editor-code-DTMSEaFy.js +2 -0
  59. package/dist/client/assets/{agent-site-editor-content-hTgzjtkp.js → agent-site-editor-content-B0U6dbmd.js} +6 -6
  60. package/dist/client/assets/{agent-site-editor-preview-yX5vZUh0.js → agent-site-editor-preview-DHCTEFq_.js} +4 -4
  61. package/dist/client/assets/agent-view-BVT0tnMS.js +1 -0
  62. package/dist/client/assets/{agent-view-guard-WwLdd03P.js → agent-view-guard-CiQwzIBH.js} +1 -1
  63. package/dist/client/assets/agents-list-D6RNu5TG.js +1 -0
  64. package/dist/client/assets/{ai-providers-CJqVOOjj.js → ai-providers-CmqZsPDb.js} +2 -2
  65. package/dist/client/assets/{alert-C7GKQkEa.js → alert-BsNaBF81.js} +1 -1
  66. package/dist/client/assets/{alert-dialog-D_aRnY2J.js → alert-dialog-BTzKubzN.js} +2 -2
  67. package/dist/client/assets/{analytics-sections-B_0ylm-F.js → analytics-sections-s9PmHD7K.js} +1 -1
  68. package/dist/client/assets/api-keys-BNHCLXyO.js +1 -0
  69. package/dist/client/assets/api-keys-CplXRVbk.js +1 -0
  70. package/dist/client/assets/app-editor-C2lg73cH.js +1 -0
  71. package/dist/client/assets/asset-utils-Cba9XUPE.js +1 -0
  72. package/dist/client/assets/{auth-DK9f1ZTH.js → auth-C364y6MM.js} +1 -1
  73. package/dist/client/assets/{auth-catchall-ymAvaIfq.js → auth-catchall-Fu5UnD3F.js} +1 -1
  74. package/dist/client/assets/auth-entry-TtvThk9b.js +1 -0
  75. package/dist/client/assets/{auth-split-layout-BIJktSXr.js → auth-split-layout-DSLQPMD9.js} +1 -1
  76. package/dist/client/assets/authenticate-and-persist-oauth-BKg7tWBc.js +1 -0
  77. package/dist/client/assets/{automation-list-row-DEJdl0i5.js → automation-list-row-DlIRdIvL.js} +1 -1
  78. package/dist/client/assets/automation-runs-D7YzXLl4.js +1 -0
  79. package/dist/client/assets/automations-nTgDp9lT.js +1 -0
  80. package/dist/client/assets/autosend-CezXEQCq.js +1 -0
  81. package/dist/client/assets/{avatar-CYsgyDk8.js → avatar-DbpOZfYL.js} +1 -1
  82. package/dist/client/assets/{badge-80v1nRPK.js → badge-BgcNCpYt.js} +1 -1
  83. package/dist/client/assets/{block-document-Cz2P_vpn.js → block-document-iTsyUX-a.js} +3 -3
  84. package/dist/client/assets/{blocks-preview-workspace-context-BtM79Kvx.js → blocks-preview-workspace-context-BXKULFqX.js} +1 -1
  85. package/dist/client/assets/{blog-schema-STc-KePE.js → blog-schema-DD23vovf.js} +1 -1
  86. package/dist/client/assets/{board-analytics-Kq5_7Oyo.js → board-analytics-Cwy2ZAGo.js} +1 -1
  87. package/dist/client/assets/buckets-BSK6ehlm.js +1 -0
  88. package/dist/client/assets/{build-improve-prompt-doc-CbyMBFhr.js → build-improve-prompt-doc-Y3OzCwPY.js} +1 -1
  89. package/dist/client/assets/{calendar-7itqlUGW.js → calendar-CEOFJdzz.js} +1 -1
  90. package/dist/client/assets/capability-load-error-BCbiiwNK.js +1 -0
  91. package/dist/client/assets/category-editor-CVM9Agvl.js +1 -0
  92. package/dist/client/assets/{chart-ohHxB0r5.js → chart-BirAG0oj.js} +1 -1
  93. package/dist/client/assets/{chat-context-BEKkV-Ll.js → chat-context-By_4gW6u.js} +8 -8
  94. package/dist/client/assets/chat-draft-CjxNTkoz.js +1 -0
  95. package/dist/client/assets/{checkbox-CvWHs1zK.js → checkbox-C1PTdkvC.js} +1 -1
  96. package/dist/client/assets/choose-editor-D5Z-yVXB.js +1 -0
  97. package/dist/client/assets/claim-phase-copy-DjK7-Dlj.js +1 -0
  98. package/dist/client/assets/{cli-auth-success-CYBiu7ru.js → cli-auth-success-DPNe5AnC.js} +1 -1
  99. package/dist/client/assets/{client-icons-5hQaeIu1.js → client-icons-gmrQyeik.js} +1 -1
  100. package/dist/client/assets/{collapsible-jaPP2OhC.js → collapsible-B4tt-A-a.js} +1 -1
  101. package/dist/client/assets/collection-detail-CRZTOFcZ.js +1 -0
  102. package/dist/client/assets/collection-display-button-iFLNUDt5.js +1 -0
  103. package/dist/client/assets/{collection-search-BMeq1F4t.js → collection-search-6N7Rez-8.js} +1 -1
  104. package/dist/client/assets/{collection-table-wrapper-B_m86D_K.js → collection-table-wrapper-CfCYWslA.js} +1 -1
  105. package/dist/client/assets/{collection-tabs-Ba1MLgdh.js → collection-tabs-CKHgPBCn.js} +1 -1
  106. package/dist/client/assets/column-rules-2VSan5Bc.js +3 -0
  107. package/dist/client/assets/{combobox-AP2SQ_RO.js → combobox-DaqRmpnO.js} +1 -1
  108. package/dist/client/assets/command-Y5_oacWW.js +1 -0
  109. package/dist/client/assets/{companion-mcps-section-BJx9eTFU.js → companion-mcps-section-B-ijJ6Yp.js} +1 -1
  110. package/dist/client/assets/config-BokZbmON.js +1 -0
  111. package/dist/client/assets/{connect-Cw4wL4Mo.js → connect-CRGqUZ7U.js} +3 -3
  112. package/dist/client/assets/connect-layout-D4PD9y64.js +1 -0
  113. package/dist/client/assets/{connection-CeKZpSJo.js → connection-CRPvojqI.js} +1 -1
  114. package/dist/client/assets/connection-card-KyCZsDMq.js +1 -0
  115. package/dist/client/assets/connection-detail-BcuPo63c.js +1 -0
  116. package/dist/client/assets/connection-form-helpers-DHRB6y9q.js +1 -0
  117. package/dist/client/assets/connections-BsYVOIWF.js +1 -0
  118. package/dist/client/assets/context-TgkInbqd.js +1 -0
  119. package/dist/client/assets/{context-menu-C5PIf9Ud.js → context-menu-BcvT-xNL.js} +1 -1
  120. package/dist/client/assets/{core.esm-CFyPPg_k.js → core.esm-BCt5zzlL.js} +1 -1
  121. package/dist/client/assets/create-organization-dialog-DA_Cpcir.js +1 -0
  122. package/dist/client/assets/daily-pulse-DL2RQNPh.js +1 -0
  123. package/dist/client/assets/{device-hint-CTUpl3CG.js → device-hint-C-6GVgyh.js} +1 -1
  124. package/dist/client/assets/discover-DMYUdkQJ.js +1 -0
  125. package/dist/client/assets/domain-settings-Bw-4hQ9O.js +1 -0
  126. package/dist/client/assets/{drawer-Cn362UbS.js → drawer-Mq2IQ1xB.js} +1 -1
  127. package/dist/client/assets/{editor-B-nIGllj.js → editor-4gGGw1LX.js} +3 -3
  128. package/dist/client/assets/{empty-state-DfNAbSXk.js → empty-state-Z7KZaCgr.js} +1 -1
  129. package/dist/client/assets/{empty-state-C3-ZBqZ7.js → empty-state-pDkjxQ9v.js} +1 -1
  130. package/dist/client/assets/{extract-connection-data-WKz3D__i.js → extract-connection-data-DmRZ30Aj.js} +1 -1
  131. package/dist/client/assets/{feature-gate-CQMKDgiz.js → feature-gate-Dejbstp-.js} +1 -1
  132. package/dist/client/assets/feature-paywall-BatvuaQK.js +1 -0
  133. package/dist/client/assets/file-explorer-DoxI5WYH.js +2 -0
  134. package/dist/client/assets/{file-preview-kacuDdK5.js → file-preview-BKQ9z_Zk.js} +1 -1
  135. package/dist/client/assets/file-share-button-E78-t03V.js +3 -0
  136. package/dist/client/assets/{file-type-icon-CDG1qAi8.js → file-type-icon-BIQRdF9B.js} +1 -1
  137. package/dist/client/assets/flat-project-DcECHGX3.js +1 -0
  138. package/dist/client/assets/{folder-icon-Dt1GSdhj.js → folder-icon-BeWIM1Mh.js} +2 -2
  139. package/dist/client/assets/{form-CpErFrQ1.js → form-ClLZmF-x.js} +1 -1
  140. package/dist/client/assets/general-CQandLDD.js +1 -0
  141. package/dist/client/assets/home-DVyZY-sa.js +1 -0
  142. package/dist/client/assets/{icon-button-BZdEBEfj.js → icon-button-BflDTZbH.js} +1 -1
  143. package/dist/client/assets/{index-CnLkSXZ0.js → index-0YmFgk-4.js} +1 -1
  144. package/dist/client/assets/{index-W5Uv1gFu.js → index-BRB9eRek.js} +2 -2
  145. package/dist/client/assets/{index-QSc3eGTu.js → index-BRHoVQcU.js} +1 -1
  146. package/dist/client/assets/{index-D1cfaJ2t.js → index-BgOyhevJ.js} +2 -2
  147. package/dist/client/assets/{index-ikDsOzpt.js → index-BhOWNPjr.js} +6 -6
  148. package/dist/client/assets/{index-BygP9YwT.js → index-C8DfgSPy.js} +5 -5
  149. package/dist/client/assets/{index-BYizWVl-.js → index-CbgPEOCa.js} +2 -2
  150. package/dist/client/assets/index-CkPHS5Dh.js +1 -0
  151. package/dist/client/assets/{index-BfjkKzIS.js → index-D7iHvf3D.js} +1 -1
  152. package/dist/client/assets/index-DAmEDD4z.js +1 -0
  153. package/dist/client/assets/{index-BCgTVQy6.js → index-DHrUbuPD.js} +1 -1
  154. package/dist/client/assets/{index-dB_1XyGB.js → index-DQmyVRcq.js} +1 -1
  155. package/dist/client/assets/{index-D6ZKj0d3.js → index-P5CXrVFm.js} +43 -43
  156. package/dist/client/assets/{index-redirect-BikVIQHZ.js → index-redirect-CG5FAh2K.js} +1 -1
  157. package/dist/client/assets/{infiniteQueryObserver-kLjXQrHB.js → infiniteQueryObserver-DozMisCD.js} +1 -1
  158. package/dist/client/assets/infra-billing-DfiPMKeD.js +1 -0
  159. package/dist/client/assets/input-CeiEotQg.js +1 -0
  160. package/dist/client/assets/{input-DWfiFAhX.js → input-ykei6Cwl.js} +5 -5
  161. package/dist/client/assets/{integration-icon-BXBLtmJk.js → integration-icon-67Xzvyfa.js} +1 -1
  162. package/dist/client/assets/jira-icon-B2BuyBB4.js +1 -0
  163. package/dist/client/assets/{label-SS4h69R5.js → label-BFTsWxRX.js} +1 -1
  164. package/dist/client/assets/{layout-C4L4n6Lc.js → layout-C1lXfV0M.js} +1 -1
  165. package/dist/client/assets/legacy-agents-deep-biwbtqII.js +1 -0
  166. package/dist/client/assets/{legacy-main-redirect-hF1zoiVf.js → legacy-main-redirect-DddC7e1C.js} +1 -1
  167. package/dist/client/assets/library-Cof5sIHl.js +1 -0
  168. package/dist/client/assets/{library-tab-l_VVRZXX.js → library-tab-NRFXm3NX.js} +3 -3
  169. package/dist/client/assets/login-DgVB-KHS.js +1 -0
  170. package/dist/client/assets/{markdown-29HM3kkf.js → markdown-DsXUd5ra.js} +3 -3
  171. package/dist/client/assets/{mcp-app-renderer-DXGnetCy.js → mcp-app-renderer-Cbidp8HH.js} +1 -1
  172. package/dist/client/assets/mcp-oauth-Bvbum4TV.js +1 -0
  173. package/dist/client/assets/mcp-oauth-Em69Rf1Z.js +1 -0
  174. package/dist/client/assets/members-D8MOsQpb.js +1 -0
  175. package/dist/client/assets/{memory-CGswqj8y.js → memory-KM-sFXxK.js} +2 -2
  176. package/dist/client/assets/{mini-report-page-Da7eznro.js → mini-report-page-D6-Sz9FL.js} +1 -1
  177. package/dist/client/assets/{mock-board-DXthXijU.js → mock-board-CjxyB2zF.js} +1 -1
  178. package/dist/client/assets/{monaco-editor-DvydENcY.js → monaco-editor-dzebtzJe.js} +2 -2
  179. package/dist/client/assets/{monitoring-stats-row-C3CaqX-m.js → monitoring-stats-row-Br92KCz7.js} +1 -1
  180. package/dist/client/assets/{multi-select-DwlQIhXq.js → multi-select-OMY7Ad0D.js} +1 -1
  181. package/dist/client/assets/mustache-mZQO-vIe.js +4 -0
  182. package/dist/client/assets/new-project-dialog-c2qIcucJ.js +1 -0
  183. package/dist/client/assets/{oauth-callback-BMrgEZxm.js → oauth-callback-CbK8qs_l.js} +1 -1
  184. package/dist/client/assets/{oauth-callback-ai-provider-CspcIUB4.js → oauth-callback-ai-provider-DeX6N2Kr.js} +1 -1
  185. package/dist/client/assets/onboarding-BW2HKXvH.js +1 -0
  186. package/dist/client/assets/openai-conversation-D8EGaB-O.js +3 -0
  187. package/dist/client/assets/optimistic-project-sidebar-views-BfSXwHy1.js +1 -0
  188. package/dist/client/assets/{organization-choice-CHmTDpwe.js → organization-choice-D26FpHn1.js} +1 -1
  189. package/dist/client/assets/orgs-DOgJxZAX.js +1 -0
  190. package/dist/client/assets/{page-seo-form-CVheom0z.js → page-seo-form-DKPmGeGi.js} +1 -1
  191. package/dist/client/assets/pair-tkynKLUn.js +48 -0
  192. package/dist/client/assets/plan-ladder-DK8XbnR2.js +1 -0
  193. package/dist/client/assets/{popover-B69wnZ0x.js → popover-BEaGTFER.js} +1 -1
  194. package/dist/client/assets/post-calendar-BNSAMYq7.js +1 -0
  195. package/dist/client/assets/post-editor-COrT_mtL.js +2 -0
  196. package/dist/client/assets/preview-content-BDIAdwAe.js +1 -0
  197. package/dist/client/assets/preview-dialog-lyZyRYbk.js +1 -0
  198. package/dist/client/assets/{preview-panel-C2DKjThP.js → preview-panel-CAmSZPFR.js} +1 -1
  199. package/dist/client/assets/product-picker-dialog-DsW2hIqG.js +1 -0
  200. package/dist/client/assets/profile-8rq0jv1t.js +1 -0
  201. package/dist/client/assets/project-app-view-BATWfA47.js +1 -0
  202. package/dist/client/assets/project-feed-D-Njb4Fa.js +1 -0
  203. package/dist/client/assets/{project-icon-C0Nw8mPG.js → project-icon-CVjxspby.js} +1 -1
  204. package/dist/client/assets/project-reports-BkzVwq7y.js +1 -0
  205. package/dist/client/assets/project-tasks-B54X-ADA.js +1 -0
  206. package/dist/client/assets/projects-Ci0VMAti.js +1 -0
  207. package/dist/client/assets/{projects-empty-state-BpTZWKkI.js → projects-empty-state-DqLxqHkr.js} +1 -1
  208. package/dist/client/assets/prompts-CcDUo4xE.js +1 -0
  209. package/dist/client/assets/record-editor-CsrZJ7eU.js +1 -0
  210. package/dist/client/assets/redirect-editor-CeRRUF_Y.js +1 -0
  211. package/dist/client/assets/{reports-B5U9tB3f.js → reports-BKEK9PjO.js} +2 -2
  212. package/dist/client/assets/reports-TUXU0eWQ.js +1 -0
  213. package/dist/client/assets/reports-onboarding-BWPW_861.js +1 -0
  214. package/dist/client/assets/reports-tab-MTJjgnyg.js +2 -0
  215. package/dist/client/assets/repositories-COdTxGIM.js +1 -0
  216. package/dist/client/assets/repository-binding-DgstszW0.js +1 -0
  217. package/dist/client/assets/repository-import-picker-C4LOW7uq.js +1 -0
  218. package/dist/client/assets/repository-picker-iVChzqUi.js +1 -0
  219. package/dist/client/assets/require-capability-CIonrRSM.js +1 -0
  220. package/dist/client/assets/{required-auth-layout-UMnYz1o3.js → required-auth-layout-Docb5mc1.js} +1 -1
  221. package/dist/client/assets/reset-password-D-Uff2pm.js +1 -0
  222. package/dist/client/assets/{resizable-CMUQk1zK.js → resizable-DQkQHFqP.js} +1 -1
  223. package/dist/client/assets/{resolve-tab-icon-sUoI4LWt.js → resolve-tab-icon-BJCQiMAG.js} +1 -1
  224. package/dist/client/assets/review-settings-CQUW-c0y.js +1 -0
  225. package/dist/client/assets/{rich-text-link-control-BloybQa2.js → rich-text-link-control-BtAN4nTK.js} +1 -1
  226. package/dist/client/assets/roles-B5x0qKiF.js +1 -0
  227. package/dist/client/assets/route-B3BzuLT3.js +1 -0
  228. package/dist/client/assets/route-CV820oik.js +1 -0
  229. package/dist/client/assets/route-DkvQrfxW.js +1 -0
  230. package/dist/client/assets/{runnable-block-editor-aiNmn7uQ.js → runnable-block-editor-COF6SwRV.js} +4 -4
  231. package/dist/client/assets/sandbox-lifecycle-context-CZJ_j0np.js +1 -0
  232. package/dist/client/assets/{schema-DBi1obJz.js → schema-DPby9xN_.js} +1 -1
  233. package/dist/client/assets/{scroll-area-DrC4kFvC.js → scroll-area-BaXoWTc0.js} +1 -1
  234. package/dist/client/assets/{search-input-IgJHEtUf.js → search-input-zIdNkZIZ.js} +1 -1
  235. package/dist/client/assets/search-toggle-Dd74zbFD.js +1 -0
  236. package/dist/client/assets/{secret-picker-1felyUvp.js → secret-picker-BNQiMdJy.js} +1 -1
  237. package/dist/client/assets/secrets-DYrvzDcq.js +1 -0
  238. package/dist/client/assets/sections-editor-CWdxzvx_.js +1 -0
  239. package/dist/client/assets/{select-BimoKSOp.js → select-BTTyWh-3.js} +1 -1
  240. package/dist/client/assets/select-model-_gJCiq6c.js +1 -0
  241. package/dist/client/assets/seo-editor-D2aPe-YC.js +1 -0
  242. package/dist/client/assets/{separator-BDE3I0fn.js → separator-DjDQYMtn.js} +1 -1
  243. package/dist/client/assets/settings-tab-B0TsEFTt.js +4 -0
  244. package/dist/client/assets/sheet-eZJW88LV.js +1 -0
  245. package/dist/client/assets/shell-layout-OtP14C-y.js +1 -0
  246. package/dist/client/assets/skills-CyhJcNik.js +1 -0
  247. package/dist/client/assets/{slider-FhNC3fVS.js → slider-C2iod3T6.js} +1 -1
  248. package/dist/client/assets/{sortable.esm-BW2r2TQ5.js → sortable.esm-B2cNTSsr.js} +1 -1
  249. package/dist/client/assets/sso-BSD5EMNY.js +1 -0
  250. package/dist/client/assets/{suggestion-CO1eCyUL.js → suggestion-CEZpMvzO.js} +2 -2
  251. package/dist/client/assets/{switch-DbiylKGt.js → switch-BJJ-2yIv.js} +1 -1
  252. package/dist/client/assets/{symbol-jxhImUCd.js → symbol-DQiTO71i.js} +1 -1
  253. package/dist/client/assets/synced-repos-19fjd8br.js +1 -0
  254. package/dist/client/assets/{tab-icon-glyph-CASAQt8G.js → tab-icon-glyph-B8UDsLej.js} +1 -1
  255. package/dist/client/assets/{table-D0TLPmnq.js → table-B9C_mOX3.js} +1 -1
  256. package/dist/client/assets/{tabs-BwctFHZr.js → tabs-9di2Neit.js} +1 -1
  257. package/dist/client/assets/{task-board-DFP-fne3.js → task-board-DsgdOWHQ.js} +1 -1
  258. package/dist/client/assets/{task-route-BierUG4Q.js → task-route-_EeI73mv.js} +1 -1
  259. package/dist/client/assets/{task-status-cNdQKcCz.js → task-status-B--cbdkz.js} +1 -1
  260. package/dist/client/assets/taskboard-analytics-C8fUYGcQ.js +1 -0
  261. package/dist/client/assets/{tasks-CEP9Drl2.js → tasks-Bd7TbgaV.js} +3 -3
  262. package/dist/client/assets/tasks-RI02vBG9.js +1 -0
  263. package/dist/client/assets/{textarea-DncV9TJN.js → textarea-BqIcQ24a.js} +1 -1
  264. package/dist/client/assets/thread-analytics-CsSdT5az.js +1 -0
  265. package/dist/client/assets/thread-button-CycuvBQ2.js +1 -0
  266. package/dist/client/assets/{thread-intent-o4o-MA3S.js → thread-intent-Dkew51FR.js} +4 -4
  267. package/dist/client/assets/thread-route-BhC2i0VX.js +1 -0
  268. package/dist/client/assets/thread-route-VDZP73-c.js +1 -0
  269. package/dist/client/assets/thread-sheet-body-D66PmCTc.js +1 -0
  270. package/dist/client/assets/time-range-picker-PWsm0WiC.js +1 -0
  271. package/dist/client/assets/{toggle-group-Be2zaRQe.js → toggle-group-DlaKauZK.js} +1 -1
  272. package/dist/client/assets/{tool-namespace-BaO4I7fR.js → tool-namespace-BqgKCylT.js} +1 -1
  273. package/dist/client/assets/{toolbar-icon-button-DnfVpnpi.js → toolbar-icon-button-uADDhC14.js} +1 -1
  274. package/dist/client/assets/{tooltip-ud1E4lWe.js → tooltip-K3E8D0ro.js} +1 -1
  275. package/dist/client/assets/{tooltipContext-Bn73mb9f.js → tooltipContext-BRcqEDXN.js} +1 -1
  276. package/dist/client/assets/{track-D9xSFomP.js → track-CP2DG_55.js} +1 -1
  277. package/dist/client/assets/{types-C52Y_JT0.js → types-DcgxOiad.js} +3 -3
  278. package/dist/client/assets/{url-slug-DA14zDBr.js → url-slug-DhfDl2ps.js} +1 -1
  279. package/dist/client/assets/{usage-stats-qYCfmoBc.js → usage-stats-BxwGMEO8.js} +8 -8
  280. package/dist/client/assets/use-ai-providers-RQRNdq_e.js +1 -0
  281. package/dist/client/assets/use-automations-Ca5X-jRM.js +1 -0
  282. package/dist/client/assets/{use-autosave-DwWGqeny.js → use-autosave-CJc5IdX2.js} +1 -1
  283. package/dist/client/assets/use-chat-layout-state-DtHzBS8D.js +1 -0
  284. package/dist/client/assets/use-chat-navigation-CVp0n3Im.js +1 -0
  285. package/dist/client/assets/{use-clock-tick-Byjn6Ipz.js → use-clock-tick-DpFEAg9e.js} +1 -1
  286. package/dist/client/assets/use-connect-companion-CtkvmHzJ.js +1 -0
  287. package/dist/client/assets/use-connection-Bt-E6mI8.js +1 -0
  288. package/dist/client/assets/{use-copy-Dg2-hZvb.js → use-copy-CnGdfZZq.js} +1 -1
  289. package/dist/client/assets/{use-create-virtual-mcp-DaSHuVdx.js → use-create-virtual-mcp-DSPEp1ij.js} +1 -1
  290. package/dist/client/assets/{use-date-fns-locale-yEAg4rlf.js → use-date-fns-locale-CoQZHHDk.js} +1 -1
  291. package/dist/client/assets/{use-debounced-autosave-BbQxm-LP.js → use-debounced-autosave-D9QlyCIh.js} +1 -1
  292. package/dist/client/assets/{use-debounced-value-DkB41yRZ.js → use-debounced-value-BUXOxoNR.js} +1 -1
  293. package/dist/client/assets/use-deco-credits-D1Zzfqcx.js +1 -0
  294. package/dist/client/assets/{use-decopilot-events-C_UyGftl.js → use-decopilot-events-BlbrCauc.js} +1 -1
  295. package/dist/client/assets/use-delete-connection-BHcEA-CR.js +1 -0
  296. package/dist/client/assets/{use-deployment-admin-LfJmve5n.js → use-deployment-admin-Bep6HJdp.js} +1 -1
  297. package/dist/client/assets/use-ensure-project-folder-CqnXJXRD.js +1 -0
  298. package/dist/client/assets/{use-fast-preview-draft-url-DfCPo5oA.js → use-fast-preview-draft-url-CGzNCC1A.js} +1 -1
  299. package/dist/client/assets/use-file-configs-BPwg0FRs.js +1 -0
  300. package/dist/client/assets/{use-infinite-scroll-979kKqgG.js → use-infinite-scroll-DGijCA4m.js} +1 -1
  301. package/dist/client/assets/use-join-requests-DSEFov6n.js +1 -0
  302. package/dist/client/assets/use-main-panel-tabs-OrkHtB0p.js +1 -0
  303. package/dist/client/assets/use-mcp-auth-status-DQxUdxan.js +1 -0
  304. package/dist/client/assets/{use-mcp-client-BhAo2QDs.js → use-mcp-client-BzoSbdXu.js} +4 -4
  305. package/dist/client/assets/{use-mcp-prompts-DPLwYnKg.js → use-mcp-prompts-C6OXhadi.js} +1 -1
  306. package/dist/client/assets/{use-mcp-tools-Bv_07i-f.js → use-mcp-tools-D_8Ajj_N.js} +1 -1
  307. package/dist/client/assets/use-members-BuywckX1.js +1 -0
  308. package/dist/client/assets/{use-mobile-DsXG93j_.js → use-mobile-C8-RuCPF.js} +1 -1
  309. package/dist/client/assets/use-navigate-to-agent-DLNrFLDT.js +1 -0
  310. package/dist/client/assets/use-new-blocks-editor-Jqd7-2D9.js +1 -0
  311. package/dist/client/assets/{use-open-billing-url-CUDSWbJf.js → use-open-billing-url-xKTM1AUW.js} +1 -1
  312. package/dist/client/assets/use-org-auth-client-B6LnSeUd.js +1 -0
  313. package/dist/client/assets/use-org-fs-DErltq5P.js +1 -0
  314. package/dist/client/assets/use-org-repo-syncs-DMFEDOzK.js +1 -0
  315. package/dist/client/assets/{use-org-sso-IZ5t5non.js → use-org-sso-sw3on3hq.js} +1 -1
  316. package/dist/client/assets/use-organization-roles-DjUuzQZu.js +1 -0
  317. package/dist/client/assets/use-organization-settings-BHelWCQF.js +1 -0
  318. package/dist/client/assets/{use-panel-navigate-vbXDgGYl.js → use-panel-navigate-BLjJq7A_.js} +1 -1
  319. package/dist/client/assets/{use-project-scope-KzlP3xju.js → use-project-scope-B9l8p85i.js} +1 -1
  320. package/dist/client/assets/use-releases-CsZsJd__.js +1 -0
  321. package/dist/client/assets/use-reports-diagnostic-CA8bVs4C.js +1 -0
  322. package/dist/client/assets/use-sandbox-events-C41kLIF6.js +2 -0
  323. package/dist/client/assets/use-secrets-Od0f7P_4.js +1 -0
  324. package/dist/client/assets/use-section-preview-base-CtsulJXk.js +1 -0
  325. package/dist/client/assets/use-tags-Df3tX30j.js +1 -0
  326. package/dist/client/assets/use-task-board-analytics-D3QeGKDt.js +1 -0
  327. package/dist/client/assets/{use-task-board-events-Bsmaoj96.js → use-task-board-events-DgHn2yeU.js} +1 -1
  328. package/dist/client/assets/use-task-board-item-prs-C9TWjRE5.js +1 -0
  329. package/dist/client/assets/use-task-board-items-DqDMBUiA.js +1 -0
  330. package/dist/client/assets/use-task-metadata-BGZgwqEP.js +1 -0
  331. package/dist/client/assets/{use-thread-analytics-BNWVClHo.js → use-thread-analytics-DpRLYYMv.js} +1 -1
  332. package/dist/client/assets/use-thread-outputs-Bd93hD9n.js +1 -0
  333. package/dist/client/assets/useInfiniteQuery-DCtX1Z2b.js +1 -0
  334. package/dist/client/assets/{useQueries-BAV2VQJS.js → useQueries-FiLem-Cr.js} +1 -1
  335. package/dist/client/assets/useSuspenseInfiniteQuery-BY9PV9K3.js +1 -0
  336. package/dist/client/assets/{users-D6p7l9Qo.js → users-DDcsQE52.js} +1 -1
  337. package/dist/client/assets/{utils-Cp3D7BS-.js → utils-D-s8UffD.js} +1 -1
  338. package/dist/client/assets/variant-calendar-A2za84Mi.js +1 -0
  339. package/dist/client/assets/{variant-matcher-override-BPr4phd8.js → variant-matcher-override-BQT0OBiv.js} +1 -1
  340. package/dist/client/assets/{view-mode-toggle-rvdqWR_F.js → view-mode-toggle-CLajaG70.js} +1 -1
  341. package/dist/client/assets/{virtual-mcp-y87s1o4x.js → virtual-mcp-BsaYLZxR.js} +1 -1
  342. package/dist/client/assets/{watch-sse-pool-HwFSe36n.js → watch-sse-pool-Ckvo_uxI.js} +1 -1
  343. package/dist/client/index.html +1 -1
  344. package/dist/server/server.js +633 -633
  345. package/package.json +1 -1
  346. package/dist/client/assets/LinkExternal01-BNOHDQ-X.js +0 -1
  347. package/dist/client/assets/X-CGpWJ0hX.js +0 -1
  348. package/dist/client/assets/add-connection-dialog-Bs6jGGvh.js +0 -1
  349. package/dist/client/assets/agent-analytics-BnLptKbu.js +0 -2
  350. package/dist/client/assets/agent-app-QHYDv9wm.js +0 -1
  351. package/dist/client/assets/agent-assets-CRarjbts.js +0 -1
  352. package/dist/client/assets/agent-automation-33aqaKe4.js +0 -20
  353. package/dist/client/assets/agent-automations-CQKB-t_S.js +0 -1
  354. package/dist/client/assets/agent-connect-sources-COzXkalQ.js +0 -1
  355. package/dist/client/assets/agent-deck-CFpEgiHW.js +0 -1
  356. package/dist/client/assets/agent-e2e-Chyzilo0.js +0 -1
  357. package/dist/client/assets/agent-experiments-DHKzrPTl.js +0 -1
  358. package/dist/client/assets/agent-file-rvuSnAm8.js +0 -1
  359. package/dist/client/assets/agent-hosting-D8LVdRAw.js +0 -1
  360. package/dist/client/assets/agent-icon-CqZASRJE.js +0 -1
  361. package/dist/client/assets/agent-library-D4uAz-Gm.js +0 -1
  362. package/dist/client/assets/agent-library-file-Cm-5j5_Q.js +0 -1
  363. package/dist/client/assets/agent-monitor-BzlCINOe.js +0 -1
  364. package/dist/client/assets/agent-overview-DUFMWxEU.js +0 -1
  365. package/dist/client/assets/agent-settings-DHaR6tV_.js +0 -1
  366. package/dist/client/assets/agent-site-editor-code-BOVBRJg8.js +0 -2
  367. package/dist/client/assets/agent-view-DhvgMtwi.js +0 -1
  368. package/dist/client/assets/agents-list-Dd_HwOB5.js +0 -1
  369. package/dist/client/assets/api-keys-BQyxoF0G.js +0 -1
  370. package/dist/client/assets/api-keys-CTrR4NLT.js +0 -1
  371. package/dist/client/assets/app-editor-CdpSejbG.js +0 -1
  372. package/dist/client/assets/asset-utils-DPFCQacY.js +0 -1
  373. package/dist/client/assets/auth-entry-Bipf-3As.js +0 -1
  374. package/dist/client/assets/authenticate-and-persist-oauth-JHbhZWlI.js +0 -1
  375. package/dist/client/assets/automation-runs-BvXAH6Zy.js +0 -1
  376. package/dist/client/assets/automations-CqeboptP.js +0 -1
  377. package/dist/client/assets/autosend-BV2PsimL.js +0 -1
  378. package/dist/client/assets/buckets-CjScpz_6.js +0 -1
  379. package/dist/client/assets/capability-load-error-BwUoLzKX.js +0 -1
  380. package/dist/client/assets/category-editor-Cad32exX.js +0 -1
  381. package/dist/client/assets/chat-draft-B0NTSRWz.js +0 -1
  382. package/dist/client/assets/choose-editor-BwfUJgeg.js +0 -1
  383. package/dist/client/assets/claim-phase-copy-BL3WW58c.js +0 -1
  384. package/dist/client/assets/collection-detail-BBvtaNRJ.js +0 -1
  385. package/dist/client/assets/collection-display-button-DVNQgzNC.js +0 -1
  386. package/dist/client/assets/column-rules-DqbtcnMo.js +0 -3
  387. package/dist/client/assets/command-Bvxnety0.js +0 -1
  388. package/dist/client/assets/config-JsgNFdSm.js +0 -1
  389. package/dist/client/assets/connect-layout-C8etZ06x.js +0 -1
  390. package/dist/client/assets/connection-card-BBsdybH0.js +0 -1
  391. package/dist/client/assets/connection-detail-Zij0KKeD.js +0 -1
  392. package/dist/client/assets/connection-form-helpers-DTld_nTJ.js +0 -1
  393. package/dist/client/assets/connections-C78U2QWF.js +0 -1
  394. package/dist/client/assets/context-D4huQsCX.js +0 -1
  395. package/dist/client/assets/create-organization-dialog-BfiRTIkh.js +0 -1
  396. package/dist/client/assets/daily-pulse-CCzRbH3i.js +0 -1
  397. package/dist/client/assets/dialog-CaizaKQW.js +0 -1
  398. package/dist/client/assets/discover-BZ1M_pJS.js +0 -1
  399. package/dist/client/assets/domain-settings-TcnTgsTU.js +0 -1
  400. package/dist/client/assets/feature-paywall-DnC43PTT.js +0 -1
  401. package/dist/client/assets/file-explorer-BEX4Rc_N.js +0 -2
  402. package/dist/client/assets/file-share-button-BWY-7IZa.js +0 -3
  403. package/dist/client/assets/flat-project-BJHdKc4J.js +0 -1
  404. package/dist/client/assets/general-DfGmywaK.js +0 -1
  405. package/dist/client/assets/home-CND3Dkfc.js +0 -1
  406. package/dist/client/assets/index-CiUGtn_W.js +0 -1
  407. package/dist/client/assets/index-ClRj6-3N.js +0 -1
  408. package/dist/client/assets/infra-billing-UCBSl2oy.js +0 -1
  409. package/dist/client/assets/input-BR2ZOmYv.js +0 -1
  410. package/dist/client/assets/input-CEMJ7uPy.js +0 -1
  411. package/dist/client/assets/jira-icon-BHqtDmCA.js +0 -1
  412. package/dist/client/assets/legacy-agents-deep-C7aZ6oEJ.js +0 -1
  413. package/dist/client/assets/library-BilS1-Q5.js +0 -1
  414. package/dist/client/assets/login-CKMvHvtg.js +0 -1
  415. package/dist/client/assets/mcp-oauth-3A9tYRyL.js +0 -1
  416. package/dist/client/assets/members-BcUrZyS-.js +0 -1
  417. package/dist/client/assets/mustache-Brnm_dXD.js +0 -4
  418. package/dist/client/assets/new-project-dialog-pM62WBis.js +0 -1
  419. package/dist/client/assets/onboarding-iQ3xdqhh.js +0 -1
  420. package/dist/client/assets/openai-conversation-Bo92iq4Z.js +0 -3
  421. package/dist/client/assets/optimistic-project-sidebar-views-Bui3Aln1.js +0 -1
  422. package/dist/client/assets/orgs-DccGLnZP.js +0 -1
  423. package/dist/client/assets/pair-H2ebpVnC.js +0 -47
  424. package/dist/client/assets/plan-ladder-D3lWJLFO.js +0 -1
  425. package/dist/client/assets/post-calendar-BmLvpLiq.js +0 -1
  426. package/dist/client/assets/post-editor-C2IWsxcW.js +0 -2
  427. package/dist/client/assets/preview-content-dlihu8Yt.js +0 -1
  428. package/dist/client/assets/preview-dialog-WrHsjHqZ.js +0 -1
  429. package/dist/client/assets/product-picker-dialog-CvuFuDIB.js +0 -1
  430. package/dist/client/assets/profile-CkXUOnP1.js +0 -1
  431. package/dist/client/assets/project-app-view-4F1NzKg3.js +0 -1
  432. package/dist/client/assets/project-feed-Cno5cSVS.js +0 -1
  433. package/dist/client/assets/project-reports-hao_xuVG.js +0 -1
  434. package/dist/client/assets/project-tasks-0iRMtR_B.js +0 -1
  435. package/dist/client/assets/projects-DQhNR69M.js +0 -1
  436. package/dist/client/assets/prompts-CigibTM9.js +0 -1
  437. package/dist/client/assets/record-editor-D01ICPr8.js +0 -1
  438. package/dist/client/assets/redirect-editor-BptL49e1.js +0 -1
  439. package/dist/client/assets/reports-CTOZc-B3.js +0 -1
  440. package/dist/client/assets/reports-onboarding-CTVsl5Md.js +0 -1
  441. package/dist/client/assets/reports-tab-M9rEzg5O.js +0 -2
  442. package/dist/client/assets/repositories-rhEkEXbS.js +0 -1
  443. package/dist/client/assets/repository-binding-DU5xCC2f.js +0 -1
  444. package/dist/client/assets/repository-import-picker-DbT-KPfC.js +0 -1
  445. package/dist/client/assets/repository-picker-CbM65WpS.js +0 -1
  446. package/dist/client/assets/require-capability-Dn-PxZ0M.js +0 -1
  447. package/dist/client/assets/reset-password-Db0Wagvh.js +0 -1
  448. package/dist/client/assets/review-settings-CyyTBWak.js +0 -1
  449. package/dist/client/assets/roles-BI264iFV.js +0 -1
  450. package/dist/client/assets/route-6SYGGrOe.js +0 -1
  451. package/dist/client/assets/route-DRK1Yrag.js +0 -1
  452. package/dist/client/assets/route-Dqvws1eb.js +0 -1
  453. package/dist/client/assets/sandbox-lifecycle-context-KvsIkNFN.js +0 -1
  454. package/dist/client/assets/search-toggle-CQpL269o.js +0 -1
  455. package/dist/client/assets/secrets-B-VUMA_J.js +0 -1
  456. package/dist/client/assets/sections-editor-BHfMW6Ts.js +0 -1
  457. package/dist/client/assets/select-model-DuC12JIh.js +0 -1
  458. package/dist/client/assets/seo-editor-DmSwADHy.js +0 -1
  459. package/dist/client/assets/settings-tab-BbBuUb6A.js +0 -4
  460. package/dist/client/assets/sheet-BF6gLW4J.js +0 -1
  461. package/dist/client/assets/shell-layout-_Pn7cxIp.js +0 -1
  462. package/dist/client/assets/skills-Cdwff9-N.js +0 -1
  463. package/dist/client/assets/sso-BwV31EHP.js +0 -1
  464. package/dist/client/assets/synced-repos-BC8M1bWl.js +0 -1
  465. package/dist/client/assets/taskboard-analytics-yjyawLTO.js +0 -1
  466. package/dist/client/assets/tasks-C5vDjoxa.js +0 -1
  467. package/dist/client/assets/thread-analytics-BSQZhWFS.js +0 -1
  468. package/dist/client/assets/thread-button-3YyJ_qZE.js +0 -1
  469. package/dist/client/assets/thread-route-BasyELse.js +0 -1
  470. package/dist/client/assets/thread-route-CaKdVoOw.js +0 -1
  471. package/dist/client/assets/thread-sheet-body-C6mBvsIL.js +0 -1
  472. package/dist/client/assets/time-range-picker-C3YgWELe.js +0 -1
  473. package/dist/client/assets/use-ai-providers-BLkItyxK.js +0 -1
  474. package/dist/client/assets/use-automations-wOelP2bP.js +0 -1
  475. package/dist/client/assets/use-chat-layout-state-BXUQI_Uj.js +0 -1
  476. package/dist/client/assets/use-chat-navigation-0CERUZel.js +0 -1
  477. package/dist/client/assets/use-connect-companion-CJUuykr1.js +0 -1
  478. package/dist/client/assets/use-connection-BLNfspiw.js +0 -1
  479. package/dist/client/assets/use-deco-credits-ODPDFKit.js +0 -1
  480. package/dist/client/assets/use-delete-connection-DtNaJnIN.js +0 -1
  481. package/dist/client/assets/use-ensure-project-folder-i0uoPVJF.js +0 -1
  482. package/dist/client/assets/use-file-configs-CGY_ert6.js +0 -1
  483. package/dist/client/assets/use-join-requests-BVEasBlK.js +0 -1
  484. package/dist/client/assets/use-main-panel-tabs-H7fQ4i6B.js +0 -1
  485. package/dist/client/assets/use-mcp-auth-status-D2S8OUYy.js +0 -1
  486. package/dist/client/assets/use-members-BA82esMl.js +0 -1
  487. package/dist/client/assets/use-navigate-to-agent-_Fy5-uKx.js +0 -1
  488. package/dist/client/assets/use-new-blocks-editor-BEuQmWCf.js +0 -1
  489. package/dist/client/assets/use-org-auth-client-hM9___IR.js +0 -1
  490. package/dist/client/assets/use-org-fs-Df2-ebn-.js +0 -1
  491. package/dist/client/assets/use-org-repo-syncs-RpIgueH5.js +0 -1
  492. package/dist/client/assets/use-organization-roles-CHRytV-b.js +0 -1
  493. package/dist/client/assets/use-organization-settings-XOD9ESkO.js +0 -1
  494. package/dist/client/assets/use-releases-DMtt37HC.js +0 -1
  495. package/dist/client/assets/use-reports-diagnostic-B2l9rZ7n.js +0 -1
  496. package/dist/client/assets/use-sandbox-events-nw0-bXbS.js +0 -2
  497. package/dist/client/assets/use-secrets-DcZKciGM.js +0 -1
  498. package/dist/client/assets/use-section-preview-base-BSDyoSl7.js +0 -1
  499. package/dist/client/assets/use-tags-fdcoiGJW.js +0 -1
  500. package/dist/client/assets/use-task-board-analytics-DNKYjvsI.js +0 -1
  501. package/dist/client/assets/use-task-board-item-prs-h7cdMLQu.js +0 -1
  502. package/dist/client/assets/use-task-board-items-D9AUaVNI.js +0 -1
  503. package/dist/client/assets/use-task-metadata-BhK_QNSv.js +0 -1
  504. package/dist/client/assets/use-thread-outputs-714c96C6.js +0 -1
  505. package/dist/client/assets/useInfiniteQuery-jncr8EKF.js +0 -1
  506. package/dist/client/assets/useSuspenseInfiniteQuery-rmy_OGLk.js +0 -1
  507. package/dist/client/assets/variant-calendar-ClgUoajU.js +0 -1
@@ -1,13 +1,13 @@
1
- import{c as U,K as An,ag as Tn,b as Be,r as X,l as le,j as c,al as Ea,ap as Nh,B as pe,G as Ai,t as Xe,F as cs,H as ds,I as us,a as sr,X as rr,aH as Oh,h as rs,ah as Ih,D as jh,m as zi,aI as Hh,x as Fh,Q as zh,E as Wh,Z as Pa,aJ as ns,o as $h,e as io,q as Uh,z as Kh,O as qh}from"./index-D6ZKj0d3.js";import{S as Vh}from"./separator-BDE3I0fn.js";import{e as Yh,u as Wi,b as Ra,a as Gh}from"./chat-context-BEKkV-Ll.js";import{L as Xh,a as Jh}from"./shell-layout-_Pn7cxIp.js";import{I as Ba}from"./toolbar-icon-button-DnfVpnpi.js";import{P as Da,a as Aa,b as Ta}from"./popover-B69wnZ0x.js";import{b as bt,T as St,a as wt,c as nr}from"./tooltip-ud1E4lWe.js";import{A as Ma,a as La,b as Na,c as Oa,g as Ia,d as ja,e as Ha,f as Fa}from"./alert-dialog-D_aRnY2J.js";import{f as Zh,C as Qh,c as ec,a as so,e as ro,b as no}from"./command-Bvxnety0.js";import{T as Pi,a as za,b as Wa}from"./tabs-BwctFHZr.js";import{t as or,n as tc}from"./ChevronUp-CiQJnmx3.js";import{O as ar,C as ic,b as $a,P as sc,d as rc,Q as Ua,L as nc}from"./agent-icon-CqZASRJE.js";import{i as Ka}from"./DotsVertical-D5VxjRuG.js";import{b as qa}from"./Tool01-B-ugA2BM.js";import{s as Mn}from"./Plus-B-VohzJ4.js";import{s as lr}from"./Trash01--ZO2TG0s.js";import{u as Ln,r as br,a as oo,n as Sr,g as Nn,b as On}from"./use-releases-DMtt37HC.js";import{p as oc,d as ac,r as lc}from"./thread-intent-o4o-MA3S.js";import{u as hc}from"./use-members-BA82esMl.js";import{u as In,p as Hr,a as cc,g as Fr,i as Va,e as os,f as Ya,b as dc,D as uc,C as fc}from"./claim-phase-copy-BL3WW58c.js";import{h as Ga,r as Xa,g as _c,d as Bt,a as hr,e as Ja}from"./repository-binding-DU5xCC2f.js";import{u as pc}from"./use-debounced-value-DkB41yRZ.js";import{u as mc}from"./use-clock-tick-Byjn6Ipz.js";import{u as gc}from"./useInfiniteQuery-jncr8EKF.js";import{d as vc,b as bc,p as Sc,e as Za,g as Qa,h as el}from"./use-navigate-to-agent-_Fy5-uKx.js";import{R as ao}from"./virtual-mcp-y87s1o4x.js";import{G as tl}from"./repository-picker-CbM65WpS.js";import{a as cr}from"./input-DWfiFAhX.js";import{w as wc,r as il,l as sl,u as rl}from"./device-hint-CTUpl3CG.js";import{u as yc,a as xc}from"./use-fast-preview-draft-url-DfCPo5oA.js";import{u as dr,a as nl}from"./use-sandbox-events-nw0-bXbS.js";import{D as Cc,d as kc,b as Ec}from"./dialog-CaizaKQW.js";import{T as Pc}from"./textarea-DncV9TJN.js";import{i as ol}from"./CheckCircle-Ck2nYEsD.js";import{s as al}from"./Image01-CRH49dh2.js";import{a as Rc}from"./format-time-CjIPQhCN.js";import{a as Bc,b as Dc,c as Ac}from"./UserSquare-Dbdn52Lc.js";import{f as jn,a as ll,r as Hn,p as Tc,b as hl,i as cl,d as Mc,s as dl,m as Lc,h as Nc,c as ul,e as Oc,n as Ic,g as jc,j as Hc,k as Fc,l as fl,o as zc,q as _l,t as pl,u as wr}from"./sandbox-git-api-C7JbVL7R.js";import{d as Wc,g as $c}from"./utils-Cp3D7BS-.js";import{I as Uc}from"./input-BR2ZOmYv.js";import{n as Kc}from"./LinkExternal01-BNOHDQ-X.js";import{i as qc}from"./Monitor01-Dibe2H0E.js";import{g as Vc,w as ml,D as Yc}from"./section-preview-url-7zfngvgW.js";import{w as lo}from"./editor-B-nIGllj.js";import{s as gl}from"./save-changes-debug-nBi-n9eV.js";import{u as Gc}from"./use-mcp-client-BhAo2QDs.js";import{a as Xc,b as vl}from"./sandbox-lifecycle-context-KvsIkNFN.js";import{a as ho,c as Jc}from"./use-chat-layout-state-BXUQI_Uj.js";import{u as Zc}from"./use-panel-navigate-vbXDgGYl.js";import{b as co}from"./sandbox-url-D3mC8qhT.js";import{i as Ks}from"./Play-JhD_8p9T.js";import{i as Qc}from"./X-CGpWJ0hX.js";import{C as ed}from"./index-ClRj6-3N.js";import"./autosend-BV2PsimL.js";import"./use-decopilot-events-C_UyGftl.js";import"./watch-sse-pool-HwFSe36n.js";import"./task-board-DFP-fne3.js";import"./schema-DBi1obJz.js";import"./backoff-CrEUbyZT.js";import"./use-ai-providers-BLkItyxK.js";import"./use-chat-navigation-0CERUZel.js";import"./thread-route-CaKdVoOw.js";import"./location-BjlyegC2.js";import"./use-organization-settings-XOD9ESkO.js";import"./avatar-CYsgyDk8.js";import"./User01-DqG0FbTZ.js";import"./Building02-aupVb9bk.js";import"./XClose-BHLC9coi.js";import"./use-project-scope-KzlP3xju.js";import"./ZoomOut-DtT7NZBX.js";import"./integration-icon-BXBLtmJk.js";import"./LinkBroken01-aiXtOyEy.js";import"./project-icon-C0Nw8mPG.js";import"./new-project-dialog-pM62WBis.js";import"./ArrowLeft-C5TDkvfy.js";import"./label-SS4h69R5.js";import"./repository-import-picker-DbT-KPfC.js";import"./required-auth-layout-UMnYz1o3.js";import"./use-org-sso-IZ5t5non.js";import"./index-QSc3eGTu.js";import"./index-CnLkSXZ0.js";import"./SearchMd-B4A8PIUy.js";import"./AlertCircle-DxGlheNv.js";import"./ArrowUp-B_1yzk0u.js";import"./ShoppingBag01-CZ0mlBHZ.js";import"./ChevronSelectorVertical-vEYxYM2o.js";import"./Copy01-CSQiL-8m.js";import"./CreditCard01-Dbsq9vqA.js";import"./Globe04-BYAnRXKE.js";import"./SwitchHorizontal01-CUO4Tr7k.js";import"./Key01-DlUQl2kb.js";import"./Link01-CZ9mTgFL.js";import"./Sun-aaILGBFQ.js";import"./Upload01-CNXMP8gQ.js";import"./Users01-Co0Q_ns9.js";import"./serial-task-queue-CGOeQgpr.js";import"./delay-CnY5UFtP.js";import"./slugify-CEUa2lfQ.js";import"./use-org-auth-client-hM9___IR.js";import"./infiniteQueryObserver-kLjXQrHB.js";import"./url-slug-DA14zDBr.js";import"./collection-search-BMeq1F4t.js";import"./usage-stats-qYCfmoBc.js";import"./tool-namespace-BaO4I7fR.js";import"./form-CpErFrQ1.js";import"./utils-CVEq3hMx.js";import"./markdown-29HM3kkf.js";import"./use-copy-Dg2-hZvb.js";import"./use-mobile-DsXG93j_.js";import"./icon-button-BZdEBEfj.js";import"./file-type-icon-CDG1qAi8.js";import"./chat-draft-B0NTSRWz.js";import"./select-BimoKSOp.js";import"./index-BdQq_4o_.js";import"./use-deco-credits-ODPDFKit.js";import"./toggle-group-Be2zaRQe.js";import"./use-open-billing-url-CUDSWbJf.js";import"./index-BYizWVl-.js";import"./checkbox-CvWHs1zK.js";import"./ai-providers-logos-DD3qZ33J.js";import"./drawer-Cn362UbS.js";import"./input-CEMJ7uPy.js";import"./suggestion-CO1eCyUL.js";import"./use-mcp-prompts-DPLwYnKg.js";import"./use-org-fs-Df2-ebn-.js";import"./question-004-sINsf4GQ.js";import"./feature-paywall-DnC43PTT.js";import"./plan-ladder-D3lWJLFO.js";import"./add-connection-dialog-Bs6jGGvh.js";import"./extract-connection-data-WKz3D__i.js";import"./metadata-D72DunRR.js";import"./connection-CeKZpSJo.js";import"./connection-card-BBsdybH0.js";import"./connection-slug-CITJ0kGN.js";import"./use-connection-BLNfspiw.js";import"./connection-form-helpers-DTld_nTJ.js";import"./authenticate-and-persist-oauth-JHbhZWlI.js";import"./mcp-oauth-3A9tYRyL.js";import"./auth-DK9f1ZTH.js";import"./collection-tabs-Ba1MLgdh.js";import"./badge-80v1nRPK.js";import"./use-infinite-scroll-979kKqgG.js";import"./useSuspenseInfiniteQuery-rmy_OGLk.js";import"./use-task-board-events-Bsmaoj96.js";import"./pair-H2ebpVnC.js";import"./collapsible-jaPP2OhC.js";import"./content-blocks-o63cs2vh.js";import"./mcp-app-renderer-DXGnetCy.js";import"./types-C52Y_JT0.js";import"./omit-sandbox-map-jj4lCB2U.js";import"./sheet-BF6gLW4J.js";import"./use-thread-outputs-714c96C6.js";import"./differenceInSeconds-C3x8sHUj.js";import"./sandbox-start-errors-BK_aDCyt.js";import"./use-file-configs-CGY_ert6.js";import"./site-slug-DebpOoQq.js";import"./thread-button-3YyJ_qZE.js";import"./resizable-CMUQk1zK.js";const uo=/[\r\n<>]/,td=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function ur(t){const e=t?.userName?.trim();if(!e||uo.test(e))return null;const i=t?.userEmail?.trim();return!i||uo.test(i)?{userName:e}:td.test(i)?{userName:e,userEmail:i}:{userName:e}}function id(t){return t.split(`
1
+ import{c as U,K as An,ao as Tn,b as Be,r as X,l as le,j as c,at as Ea,ax as Nh,B as pe,U as Ai,t as Xe,T as cs,V as ds,X as us,a as sr,a2 as rr,aS as Oh,h as rs,ap as Ih,I as jh,a6 as Hh,R as Fh,m as zi,aT as zh,F as Wh,D as $h,v as Uh,q as Kh,Q as qh,H as Vh,a4 as Pa,aU as ns,o as Yh,e as io,y as Gh,J as Xh,aV as Jh,O as Zh}from"./index-P5CXrVFm.js";import{S as Qh}from"./separator-DjDQYMtn.js";import{e as ec,u as Wi,b as Ra,a as tc}from"./chat-context-By_4gW6u.js";import{L as ic,a as sc}from"./shell-layout-OtP14C-y.js";import{I as Ba}from"./toolbar-icon-button-uADDhC14.js";import{P as Da,a as Aa,b as Ta}from"./popover-BEaGTFER.js";import{b as bt,T as St,a as wt,c as nr}from"./tooltip-K3E8D0ro.js";import{A as Ma,a as La,b as Na,c as Oa,g as Ia,d as ja,e as Ha,f as Fa}from"./alert-dialog-BTzKubzN.js";import{f as rc,C as nc,c as oc,a as so,e as ro,b as no}from"./command-Y5_oacWW.js";import{T as Pi,a as za,b as Wa}from"./tabs-9di2Neit.js";import{t as or,n as ac}from"./ChevronUp-DZuLpYB1.js";import{O as ar,C as lc,b as $a,P as hc,d as cc,Q as Ua,L as dc}from"./agent-icon-V8lPNv7A.js";import{i as Ka}from"./DotsVertical-BRQyK86q.js";import{b as qa}from"./Tool01-BD6R-D4L.js";import{s as Mn}from"./Plus-BjGOOPj6.js";import{s as lr}from"./Trash01-BuqURrgl.js";import{u as Ln,r as br,a as oo,n as Sr,g as Nn,b as On}from"./use-releases-CsZsJd__.js";import{p as uc,d as fc,r as _c}from"./thread-intent-Dkew51FR.js";import{u as pc}from"./use-members-BuywckX1.js";import{u as In,p as Hr,a as mc,g as Fr,i as Va,e as os,f as Ya,b as gc,D as vc,C as bc}from"./claim-phase-copy-DjK7-Dlj.js";import{h as Ga,r as Xa,g as Sc,d as Bt,a as hr,e as Ja}from"./repository-binding-DgstszW0.js";import{u as wc}from"./use-debounced-value-BUXOxoNR.js";import{u as yc}from"./use-clock-tick-DpFEAg9e.js";import{u as xc}from"./useInfiniteQuery-DCtX1Z2b.js";import{d as Cc,b as kc,p as Ec,e as Za,g as Qa,h as el}from"./use-navigate-to-agent-DLNrFLDT.js";import{R as ao}from"./virtual-mcp-BsaYLZxR.js";import{G as tl}from"./repository-picker-iVChzqUi.js";import{a as cr}from"./input-ykei6Cwl.js";import{w as Pc,r as il,l as sl,u as rl}from"./device-hint-C-6GVgyh.js";import{u as Rc,a as Bc}from"./use-fast-preview-draft-url-CGzNCC1A.js";import{u as dr,a as nl}from"./use-sandbox-events-C41kLIF6.js";import{T as Dc}from"./textarea-BqIcQ24a.js";import{i as ol}from"./CheckCircle-drYdikgt.js";import{s as al}from"./Image01-iHUacVtP.js";import{a as Ac}from"./format-time-CjIPQhCN.js";import{a as Tc,b as Mc,c as Lc}from"./UserSquare-v2Vi63lF.js";import{f as jn,a as ll,r as Hn,p as Nc,b as hl,i as cl,d as Oc,s as dl,m as Ic,h as jc,c as ul,e as Hc,n as Fc,g as zc,j as Wc,k as $c,l as fl,o as Uc,q as _l,t as pl,u as wr}from"./sandbox-git-api-C7JbVL7R.js";import{d as Kc,g as qc}from"./utils-D-s8UffD.js";import{i as Vc}from"./Monitor01-Cp_HdXFf.js";import{g as Yc,w as ml,D as Gc}from"./section-preview-url-7zfngvgW.js";import{w as lo}from"./editor-4gGGw1LX.js";import{s as gl}from"./save-changes-debug-nBi-n9eV.js";import{u as Xc}from"./use-mcp-client-BzoSbdXu.js";import{a as Jc,b as vl}from"./sandbox-lifecycle-context-CZJ_j0np.js";import{a as ho,c as Zc}from"./use-chat-layout-state-DtHzBS8D.js";import{u as Qc}from"./use-panel-navigate-BLjJq7A_.js";import{b as co}from"./sandbox-url-D3mC8qhT.js";import{i as Ks}from"./Play-CFzbBn-6.js";import{C as ed}from"./index-DAmEDD4z.js";import"./autosend-CezXEQCq.js";import"./use-decopilot-events-BlbrCauc.js";import"./watch-sse-pool-Ckvo_uxI.js";import"./task-board-DsgdOWHQ.js";import"./schema-DPby9xN_.js";import"./backoff-CrEUbyZT.js";import"./use-ai-providers-RQRNdq_e.js";import"./use-chat-navigation-CVp0n3Im.js";import"./thread-route-VDZP73-c.js";import"./location-BjlyegC2.js";import"./use-organization-settings-BHelWCQF.js";import"./avatar-DbpOZfYL.js";import"./User01-CHX0WSlv.js";import"./Building02-HV2PP9yH.js";import"./XClose-Dz5Xu4ap.js";import"./use-project-scope-B9l8p85i.js";import"./ZoomOut-BMJlPGPs.js";import"./integration-icon-67Xzvyfa.js";import"./LinkBroken01-B1PEGLti.js";import"./project-icon-CVjxspby.js";import"./new-project-dialog-c2qIcucJ.js";import"./ArrowLeft-CYC7J9yW.js";import"./label-BFTsWxRX.js";import"./repository-import-picker-C4LOW7uq.js";import"./required-auth-layout-Docb5mc1.js";import"./use-org-sso-sw3on3hq.js";import"./index-BRHoVQcU.js";import"./index-0YmFgk-4.js";import"./SearchMd-8jxREbgM.js";import"./AlertCircle--xQnBD7d.js";import"./ArrowUp-U1ggjjLO.js";import"./ShoppingBag01-C_Zwelnq.js";import"./ChevronSelectorVertical-DFKb4uq6.js";import"./Copy01-D4AqaFnb.js";import"./CreditCard01-BsSJIpnP.js";import"./Globe04-CHyEXekU.js";import"./SwitchHorizontal01-f_6gEt2c.js";import"./Key01-CZzgEM3b.js";import"./Link01-CLZO7iiX.js";import"./Sun-VfgIFUUc.js";import"./Upload01-CbIQEt1I.js";import"./Users01-WUyPxnjn.js";import"./serial-task-queue-CGOeQgpr.js";import"./delay-CnY5UFtP.js";import"./slugify-CEUa2lfQ.js";import"./use-org-auth-client-B6LnSeUd.js";import"./infiniteQueryObserver-DozMisCD.js";import"./url-slug-DhfDl2ps.js";import"./collection-search-6N7Rez-8.js";import"./usage-stats-BxwGMEO8.js";import"./tool-namespace-BqgKCylT.js";import"./form-ClLZmF-x.js";import"./utils-CVEq3hMx.js";import"./markdown-DsXUd5ra.js";import"./use-copy-CnGdfZZq.js";import"./use-mobile-C8-RuCPF.js";import"./icon-button-BflDTZbH.js";import"./file-type-icon-BIQRdF9B.js";import"./chat-draft-CjxNTkoz.js";import"./select-BTTyWh-3.js";import"./index-BdQq_4o_.js";import"./use-deco-credits-D1Zzfqcx.js";import"./toggle-group-DlaKauZK.js";import"./use-open-billing-url-xKTM1AUW.js";import"./index-CbgPEOCa.js";import"./checkbox-C1PTdkvC.js";import"./ai-providers-logos-DD3qZ33J.js";import"./drawer-Mq2IQ1xB.js";import"./input-CeiEotQg.js";import"./suggestion-CEZpMvzO.js";import"./use-mcp-prompts-C6OXhadi.js";import"./use-org-fs-DErltq5P.js";import"./question-004-sINsf4GQ.js";import"./feature-paywall-BatvuaQK.js";import"./plan-ladder-DK8XbnR2.js";import"./add-connection-dialog-DRVvTqsY.js";import"./extract-connection-data-DmRZ30Aj.js";import"./metadata-D72DunRR.js";import"./connection-CRPvojqI.js";import"./connection-card-KyCZsDMq.js";import"./connection-slug-CITJ0kGN.js";import"./use-connection-Bt-E6mI8.js";import"./connection-form-helpers-DHRB6y9q.js";import"./authenticate-and-persist-oauth-BKg7tWBc.js";import"./mcp-oauth-Bvbum4TV.js";import"./mcp-oauth-Em69Rf1Z.js";import"./auth-C364y6MM.js";import"./collection-tabs-CKHgPBCn.js";import"./badge-BgcNCpYt.js";import"./use-infinite-scroll-DGijCA4m.js";import"./useSuspenseInfiniteQuery-BY9PV9K3.js";import"./use-task-board-events-DgHn2yeU.js";import"./pair-tkynKLUn.js";import"./collapsible-B4tt-A-a.js";import"./content-blocks-o63cs2vh.js";import"./mcp-app-renderer-Cbidp8HH.js";import"./types-DcgxOiad.js";import"./omit-sandbox-map-jj4lCB2U.js";import"./sheet-eZJW88LV.js";import"./use-thread-outputs-Bd93hD9n.js";import"./differenceInSeconds-C3x8sHUj.js";import"./sandbox-start-errors-BK_aDCyt.js";import"./use-file-configs-BPwg0FRs.js";import"./site-slug-DebpOoQq.js";import"./thread-button-CycuvBQ2.js";import"./resizable-DQkQHFqP.js";const uo=/[\r\n<>]/,td=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function ur(t){const e=t?.userName?.trim();if(!e||uo.test(e))return null;const i=t?.userEmail?.trim();return!i||uo.test(i)?{userName:e}:td.test(i)?{userName:e,userEmail:i}:{userName:e}}function id(t){return t.split(`
2
2
  `).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
3
3
  `).trimEnd()}function sd(t){const e=t.userName.trim(),i=t.userEmail?.trim();return i?`Co-authored-by: ${e} <${i}>`:`Co-authored-by: ${e}`}function bl(t,e){const i=ur(e);if(!i)return t;const s=id(t),r=sd(i);if(s.includes(r))return s;const n=s.trimEnd();return n.length>0?`${n}
4
4
 
5
- ${r}`:r}function rd(t,e){const i=t?.trim();return i?bl(i,e):i||void 0}const nd=["dev","start"],od={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},fo=1114111;function _o(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,i)=>{if(i.startsWith("#x")||i.startsWith("#X")){const s=Number.parseInt(i.slice(2),16);return!Number.isFinite(s)||s>fo?e:String.fromCodePoint(s)}if(i.startsWith("#")){const s=Number.parseInt(i.slice(1),10);return!Number.isFinite(s)||s>fo?e:String.fromCodePoint(s)}return od[i]??e}):""}const ad=10080*60*1e3;function ld({sandboxMap:t,userId:e,rawBranches:i,now:s}){const r=new Map;for(const[d,f]of Object.entries(t??{}))for(const[_,p]of Object.entries(f??{})){let m=r.get(_);m||(m={userIds:new Set,lastActiveAt:0},r.set(_,m)),m.userIds.add(d);for(const g of Object.values(p??{})){const v=g?.createdAt??0;v>m.lastActiveAt&&(m.lastActiveAt=v)}}const n=s-ad,o=[...r.entries()].filter(([,d])=>d.lastActiveAt>=n).sort((d,f)=>f[1].lastActiveAt-d[1].lastActiveAt).map(([d,f])=>({name:d,source:"recent",contributors:[...f.userIds],lastActiveAt:f.lastActiveAt})),a=new Set(o.map(d=>d.name)),h=new Set(Object.keys(t?.[e]??{})),l=[...h].filter(d=>!a.has(d)).sort().map(d=>({name:d,source:"yours"})),u=i.filter(d=>!h.has(d.name)&&!a.has(d.name)).map(d=>({name:d.name,source:"other",author:d.author??null}));return{recent:o,yours:l,others:u}}const hd=100,cd=50,dd=300;function zr(t,e){const i=e.trim().toLowerCase();return i?t.toLowerCase().includes(i):!0}function ud(t){const e=U.c(39),{orgId:i,orgSlug:s,userId:r,target:n,sandboxMap:o,owner:a,repo:h,search:l,enabled:u}=t,d=l===void 0?"":l,f=u===void 0?!0:u;let _;e[0]!==d?(_=d.trim(),e[0]=d,e[1]=_):_=e[1];const p=_,m=pc(p,dd);let g;e[2]!==n?(g=Ga(n),e[2]=n,e[3]=g):g=e[3];const v=g,k=p.length>0;let b;e[4]!==m||e[5]!==i||e[6]!==s||e[7]!==a||e[8]!==h||e[9]!==n?(b=An.githubBranchSearch(i,s,Xa(n),a,h,m),e[4]=m,e[5]=i,e[6]=s,e[7]=a,e[8]=h,e[9]=n,e[10]=b):b=e[10];const w=f&&v;let C;e[11]!==m||e[12]!==s||e[13]!==n?(C=ee=>{const{pageParam:ue}=ee;return Tn(s,"REPOSITORY_SEARCH_BRANCHES",{...n,query:m,limit:m?cd:hd,cursor:ue})},e[11]=m,e[12]=s,e[13]=n,e[14]=C):C=e[14];let S;e[15]!==m?(S=ee=>m?void 0:ee.nextCursor??void 0,e[15]=m,e[16]=S):S=e[16];let R;e[17]!==b||e[18]!==w||e[19]!==C||e[20]!==S?(R={queryKey:b,enabled:w,staleTime:3e4,retry:!1,initialPageParam:null,queryFn:C,getNextPageParam:S},e[17]=b,e[18]=w,e[19]=C,e[20]=S,e[21]=R):R=e[21];const{data:N,isLoading:I,isError:L,isFetching:y,hasNextPage:E,isFetchingNextPage:x,fetchNextPage:A}=gc(R),D=k&&(m!==p||y),P=(N?.pages??[]).flatMap(fd),B=mc(6e4),M=ld({sandboxMap:o,userId:r,rawBranches:P,now:B});let K;e[22]!==p?(K=ee=>zr(ee.name,p),e[22]=p,e[23]=K):K=e[23];const F=M.recent.filter(K);let H;e[24]!==p?(H=ee=>zr(ee.name,p),e[24]=p,e[25]=H):H=e[25];const Y=M.yours.filter(H),q=M.others,te=N?.pages[0],J=k&&te&&!D?Math.max(0,te.totalCount-te.branches.length):0,Q=!k&&E;let W;e[26]!==A?(W=()=>{A()},e[26]=A,e[27]=W):W=e[27];let G;return e[28]!==J||e[29]!==L||e[30]!==x||e[31]!==I||e[32]!==D||e[33]!==q||e[34]!==F||e[35]!==Q||e[36]!==W||e[37]!==Y?(G={recent:F,yours:Y,others:q,isLoading:I,isError:L,isSearching:D,hiddenMatchCount:J,hasMore:Q,isFetchingMore:x,fetchMore:W},e[28]=J,e[29]=L,e[30]=x,e[31]=I,e[32]=D,e[33]=q,e[34]=F,e[35]=Q,e[36]=W,e[37]=Y,e[38]=G):G=e[38],G}function fd(t){return t.branches}function _d(t){const e=U.c(231),{virtualMcpId:i,userLabel:s,value:r,baseBranch:n,orgId:o,orgSlug:a,userId:h,target:l,owner:u,repo:d,sandboxMap:f,onChange:_,onCreateBranch:p,onAdoptBranch:m,disabled:g,spawnsNewChat:v,placement:k}=t,b=g===void 0?!1:g,w=v===void 0?!1:v,C=k===void 0?"chat":k,S=Be(),R=C==="header",[N,I]=X.useState(!1),[L,y]=X.useState(!1),[E,x]=X.useState("branches"),[A,D]=X.useState(null),[P,B]=X.useState(""),[M,K]=X.useState(null),F=X.useRef(null),{releases:H,createRelease:Y,renameRelease:q,deleteRelease:te}=Ln(i),{url:J,setUrl:Q,clear:W}=In(i),G=!!J;let ee;e[0]!==N?(ee={enabled:N},e[0]=N,e[1]=ee):ee=e[1];const{data:ue}=hc(ee);let ie;e[2]!==ue?.data?.members?(ie=se=>se?ue?.data?.members?.find(st=>st.userId===se)?.user?.name??void 0:void 0,e[2]=ue?.data?.members,e[3]=ie):ie=e[3];const de=ie,z=H.length>=ao;let ge;e[4]!==S?(ge=S("thread.branchPicker.capReached",{max:ao}),e[4]=S,e[5]=ge):ge=e[5];const fe=ge,Le=!!r&&r===n;let oe,$,De,At,Ye,He,it,Ne,yt,Wt,ce,Ke,qe,V,_e,Ae,ye,Je,nt,xt,ot,Tt,$t,Mt,ke,Ct,Lt,Ut,ni;if(e[6]!==z||e[7]!==n||e[8]!==fe||e[9]!==W||e[10]!==Y||e[11]!==te||e[12]!==b||e[13]!==P||e[14]!==Le||e[15]!==R||e[16]!==G||e[17]!==m||e[18]!==_||e[19]!==p||e[20]!==N||e[21]!==M||e[22]!==H||e[23]!==q||e[24]!==Q||e[25]!==S||e[26]!==h||e[27]!==s||e[28]!==r){let se;e[58]!==r?(se=he=>he.branch===r,e[58]=r,e[59]=se):se=e[59];const st=H.find(se);ni=!Le&&!st&&!!r;const Oi=Le?S("thread.branchPicker.live"):st?.name??S("thread.branchPicker.defaultVersionName");ce=G?S("thread.branchPicker.localLabel"):r?Oi:S("thread.branchPicker.selectVersion");const Mh=G?"bg-special":Le?"bg-success":br(st?.color??"orange");let gs;e[60]!==W||e[61]!==_?(gs=he=>{W(),_(he),I(!1)},e[60]=W,e[61]=_,e[62]=gs):gs=e[62],qe=gs;let vs;e[63]!==S?(vs=he=>{Xe.error(he instanceof Error?he.message:S("thread.branchPicker.saveError"))},e[63]=S,e[64]=vs):vs=e[64];const Ze=vs;let bs;e[65]!==Q?(bs=he=>{Q(he),y(!1),I(!1)},e[65]=Q,e[66]=bs):bs=e[66],He=bs;let Ss;e[67]!==z||e[68]!==fe||e[69]!==W||e[70]!==Y||e[71]!==m||e[72]!==_||e[73]!==H||e[74]!==Ze||e[75]!==h?(Ss=(he,xi)=>{if(W(),m){m(he),y(!1),I(!1);return}if(!H.some(vr=>vr.branch===he)){if(z){Xe.error(fe);return}Y({branch:he,name:xi.trim()||he,color:Sr(H.length),createdBy:h,createdAt:new Date().toISOString()}).catch(Ze)}_(he),y(!1),I(!1)},e[67]=z,e[68]=fe,e[69]=W,e[70]=Y,e[71]=m,e[72]=_,e[73]=H,e[74]=Ze,e[75]=h,e[76]=Ss):Ss=e[76],it=Ss;let ws;e[77]!==z||e[78]!==fe||e[79]!==W||e[80]!==Y||e[81]!==_||e[82]!==p||e[83]!==H||e[84]!==Ze||e[85]!==S||e[86]!==h||e[87]!==s?(ws=()=>{if(z){Xe.error(fe);return}W();const he=Nn(s);Y({branch:he,name:oo(H,S("thread.branchPicker.defaultVersionName")),color:Sr(H.length),createdBy:h,createdAt:new Date().toISOString()}).catch(Ze),(p??_)(he),I(!1)},e[77]=z,e[78]=fe,e[79]=W,e[80]=Y,e[81]=_,e[82]=p,e[83]=H,e[84]=Ze,e[85]=S,e[86]=h,e[87]=s,e[88]=ws):ws=e[88],Wt=ws;let ys;e[89]===Symbol.for("react.memo_cache_sentinel")?(ys=()=>{D(null),B(""),y(!1),x("branches")},e[89]=ys):ys=e[89];const Lh=ys;let xs;e[90]===Symbol.for("react.memo_cache_sentinel")?(xs=he=>{x(he),y(!0)},e[90]=xs):xs=e[90],Ke=xs;let Cs;e[91]===Symbol.for("react.memo_cache_sentinel")?(Cs=he=>{D(he.branch),B(he.name)},e[91]=Cs):Cs=e[91],Ae=Cs;let ks;e[92]!==P||e[93]!==q||e[94]!==Ze?(ks=he=>{const xi=P.trim();xi&&q(he,xi).catch(Ze),D(null),B("")},e[92]=P,e[93]=q,e[94]=Ze,e[95]=ks):ks=e[95],V=ks;let Es;e[96]!==z||e[97]!==fe||e[98]!==Y||e[99]!==P||e[100]!==H.length||e[101]!==Ze||e[102]!==h||e[103]!==r?(Es=()=>{const he=P.trim();if(he&&r){if(z){Xe.error(fe),D(null),B("");return}Y({branch:r,name:he,color:Sr(H.length),createdBy:h,createdAt:new Date().toISOString()}).catch(Ze)}D(null),B("")},e[96]=z,e[97]=fe,e[98]=Y,e[99]=P,e[100]=H.length,e[101]=Ze,e[102]=h,e[103]=r,e[104]=Es):Es=e[104],_e=Es;let Ps;e[105]===Symbol.for("react.memo_cache_sentinel")?(Ps=()=>{D(null),B("")},e[105]=Ps):Ps=e[105],Ne=Ps;let Rs;e[106]!==n||e[107]!==te||e[108]!==M||e[109]!==qe||e[110]!==H||e[111]!==Ze||e[112]!==r?(Rs=()=>{const he=M;if(K(null),!!he){if(he.branch===r){const xi=H.find(vr=>vr.branch!==he.branch);xi?qe(xi.branch):n?qe(n):I(!1)}else I(!1);te(he.branch).catch(Ze)}},e[106]=n,e[107]=te,e[108]=M,e[109]=qe,e[110]=H,e[111]=Ze,e[112]=r,e[113]=Rs):Rs=e[113],yt=Rs,Ye=Da,Mt=N,e[114]!==b?(ke=b?void 0:he=>{he||Lh(),I(he)},e[114]=b,e[115]=ke):ke=e[115],At=bt,De=St,$t=!0,Tt="inline-flex min-w-0 shrink",$=Aa,ot=!0,oe=pe,Lt=Xh.branchPicker,Ut=R?"outline":"ghost",ye=R?"sm":"default",Je=ce,nt=b;const gr=R?"text-xs":"text-xs text-muted-foreground hover:text-foreground";e[116]!==gr?(xt=le("shrink min-w-0 max-w-[220px] gap-2",gr,Ba),e[116]=gr,e[117]=xt):xt=e[117],Ct=le("h-2 w-2 shrink-0 rounded-full",r||G?Mh:"bg-muted-foreground"),e[6]=z,e[7]=n,e[8]=fe,e[9]=W,e[10]=Y,e[11]=te,e[12]=b,e[13]=P,e[14]=Le,e[15]=R,e[16]=G,e[17]=m,e[18]=_,e[19]=p,e[20]=N,e[21]=M,e[22]=H,e[23]=q,e[24]=Q,e[25]=S,e[26]=h,e[27]=s,e[28]=r,e[29]=oe,e[30]=$,e[31]=De,e[32]=At,e[33]=Ye,e[34]=He,e[35]=it,e[36]=Ne,e[37]=yt,e[38]=Wt,e[39]=ce,e[40]=Ke,e[41]=qe,e[42]=V,e[43]=_e,e[44]=Ae,e[45]=ye,e[46]=Je,e[47]=nt,e[48]=xt,e[49]=ot,e[50]=Tt,e[51]=$t,e[52]=Mt,e[53]=ke,e[54]=Ct,e[55]=Lt,e[56]=Ut,e[57]=ni}else oe=e[29],$=e[30],De=e[31],At=e[32],Ye=e[33],He=e[34],it=e[35],Ne=e[36],yt=e[37],Wt=e[38],ce=e[39],Ke=e[40],qe=e[41],V=e[42],_e=e[43],Ae=e[44],ye=e[45],Je=e[46],nt=e[47],xt=e[48],ot=e[49],Tt=e[50],$t=e[51],Mt=e[52],ke=e[53],Ct=e[54],Lt=e[55],Ut=e[56],ni=e[57];let Kt;e[118]!==Ct?(Kt=c.jsx("span",{className:Ct}),e[118]=Ct,e[119]=Kt):Kt=e[119];let Nt;e[120]!==ce?(Nt=c.jsx("span",{className:"min-w-0 truncate @max-3xl/panel-header:hidden",children:ce}),e[120]=ce,e[121]=Nt):Nt=e[121];let Ot;e[122]!==b?(Ot=!b&&c.jsx(or,{size:12,className:"opacity-60 shrink-0"}),e[122]=b,e[123]=Ot):Ot=e[123];let qt;e[124]!==oe||e[125]!==ye||e[126]!==Je||e[127]!==nt||e[128]!==xt||e[129]!==Kt||e[130]!==Nt||e[131]!==Ot||e[132]!==Lt||e[133]!==Ut?(qt=c.jsxs(oe,{"data-tour":Lt,variant:Ut,size:ye,"aria-label":Je,disabled:nt,className:xt,children:[Kt,Nt,Ot]}),e[124]=oe,e[125]=ye,e[126]=Je,e[127]=nt,e[128]=xt,e[129]=Kt,e[130]=Nt,e[131]=Ot,e[132]=Lt,e[133]=Ut,e[134]=qt):qt=e[134];let It;e[135]!==$||e[136]!==ot||e[137]!==qt?(It=c.jsx($,{asChild:ot,children:qt}),e[135]=$,e[136]=ot,e[137]=qt,e[138]=It):It=e[138];let Vt;e[139]!==Tt||e[140]!==It?(Vt=c.jsx("span",{className:Tt,children:It}),e[139]=Tt,e[140]=It,e[141]=Vt):Vt=e[141];let jt;e[142]!==De||e[143]!==$t||e[144]!==Vt?(jt=c.jsx(De,{asChild:$t,children:Vt}),e[142]=De,e[143]=$t,e[144]=Vt,e[145]=jt):jt=e[145];let Yt;e[146]!==ce?(Yt=c.jsx(wt,{children:ce}),e[146]=ce,e[147]=Yt):Yt=e[147];let Ht;e[148]!==At||e[149]!==jt||e[150]!==Yt?(Ht=c.jsxs(At,{children:[jt,Yt]}),e[148]=At,e[149]=jt,e[150]=Yt,e[151]=Ht):Ht=e[151];let fi;e[152]===Symbol.for("react.memo_cache_sentinel")?(fi=se=>{se.preventDefault(),F.current?.scrollIntoView({block:"nearest"})},e[152]=fi):fi=e[152];let Gt;e[153]!==w||e[154]!==S?(Gt=w&&c.jsx("p",{className:"px-2 pb-1.5 pt-1 text-xs text-muted-foreground",children:S("thread.branchPicker.newChatHint")}),e[153]=w,e[154]=S,e[155]=Gt):Gt=e[155];let kt;e[156]!==He||e[157]!==it||e[158]!==L||e[159]!==E||e[160]!==z||e[161]!==Ne||e[162]!==fe||e[163]!==W||e[164]!==Wt||e[165]!==de||e[166]!==P||e[167]!==A||e[168]!==G||e[169]!==J||e[170]!==N||e[171]!==Ke||e[172]!==o||e[173]!==a||e[174]!==u||e[175]!==qe||e[176]!==H||e[177]!==d||e[178]!==f||e[179]!==V||e[180]!==_e||e[181]!==Ae||e[182]!==S||e[183]!==l||e[184]!==ni||e[185]!==h||e[186]!==r?(kt=L?c.jsx(md,{orgId:o,orgSlug:a,userId:h,target:l,owner:u,repo:d,sandboxMap:f,enabled:N,tab:E,onTabChange:x,localUrl:J,onSaveLocal:He,onBack:()=>y(!1),onAdopt:it}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"always-scrollbar flex max-h-[min(50vh,20rem)] flex-col overflow-y-auto",children:[G&&J&&c.jsx(pd,{rowRef:F,url:J,onSelect:()=>Ke("local"),onEdit:()=>Ke("local"),onTurnOff:()=>W()}),ni&&r&&(A===r?c.jsx(po,{value:P,onChange:B,onSave:_e,onCancel:Ne}):c.jsx(mo,{rowRef:G?void 0:F,dot:br("orange"),label:S("thread.branchPicker.defaultVersionName"),branch:r,selected:!G,onSelect:()=>qe(r),onRename:()=>{D(r),B(oo(H,S("thread.branchPicker.defaultVersionName")))}})),H.map(se=>A===se.branch?c.jsx(po,{value:P,onChange:B,onSave:()=>V(se.branch),onCancel:Ne},se.branch):c.jsx(mo,{rowRef:!G&&se.branch===r?F:void 0,dot:br(se.color),label:se.name,creator:de(se.createdBy),branch:se.branch,selected:!G&&se.branch===r,onSelect:()=>qe(se.branch),onRename:()=>Ae(se),onDelete:()=>K(se)},se.branch))]}),(ni||H.length>0)&&c.jsx("div",{className:"my-1 border-t"}),c.jsxs("button",{type:"button",onClick:()=>{Wt()},disabled:z,className:"flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-sm text-muted-foreground hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[c.jsx(Mn,{className:"h-4 w-4 shrink-0"}),S("thread.branchPicker.newVersion")]}),z&&c.jsx("p",{className:"px-2 pb-1 pt-0.5 text-xs text-warning",children:fe}),c.jsxs("button",{type:"button",onClick:()=>Ke("branches"),className:"flex w-full items-center justify-between gap-2 rounded-lg px-2 py-2 text-left text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[S("thread.branchPicker.advanced"),c.jsx(Ea,{className:"h-4 w-4 shrink-0"})]})]}),e[156]=He,e[157]=it,e[158]=L,e[159]=E,e[160]=z,e[161]=Ne,e[162]=fe,e[163]=W,e[164]=Wt,e[165]=de,e[166]=P,e[167]=A,e[168]=G,e[169]=J,e[170]=N,e[171]=Ke,e[172]=o,e[173]=a,e[174]=u,e[175]=qe,e[176]=H,e[177]=d,e[178]=f,e[179]=V,e[180]=_e,e[181]=Ae,e[182]=S,e[183]=l,e[184]=ni,e[185]=h,e[186]=r,e[187]=kt):kt=e[187];let Xt;e[188]!==Gt||e[189]!==kt?(Xt=c.jsxs(Ta,{className:"w-[min(300px,calc(100vw-2rem))] p-1.5",align:"start",onOpenAutoFocus:fi,children:[Gt,kt]}),e[188]=Gt,e[189]=kt,e[190]=Xt):Xt=e[190];let oi;e[191]!==Ye||e[192]!==Mt||e[193]!==ke||e[194]!==Ht||e[195]!==Xt?(oi=c.jsxs(Ye,{open:Mt,onOpenChange:ke,children:[Ht,Xt]}),e[191]=Ye,e[192]=Mt,e[193]=ke,e[194]=Ht,e[195]=Xt,e[196]=oi):oi=e[196];const wi=oi,yi=M!==null;let _i;e[197]===Symbol.for("react.memo_cache_sentinel")?(_i=se=>{se||K(null)},e[197]=_i):_i=e[197];let at;e[198]!==S?(at=S("thread.branchPicker.deleteTitle"),e[198]=S,e[199]=at):at=e[199];let lt;e[200]!==at?(lt=c.jsx(Ma,{children:at}),e[200]=at,e[201]=lt):lt=e[201];let ht;e[202]!==M||e[203]!==S?(ht=M&&S("thread.branchPicker.deleteConfirm",{name:M.name}),e[202]=M,e[203]=S,e[204]=ht):ht=e[204];let ct;e[205]!==ht?(ct=c.jsx(La,{children:ht}),e[205]=ht,e[206]=ct):ct=e[206];let dt;e[207]!==lt||e[208]!==ct?(dt=c.jsxs(Na,{children:[lt,ct]}),e[207]=lt,e[208]=ct,e[209]=dt):dt=e[209];let ut;e[210]!==S?(ut=S("thread.branchPicker.cancel"),e[210]=S,e[211]=ut):ut=e[211];let ft;e[212]!==ut?(ft=c.jsx(Oa,{children:ut}),e[212]=ut,e[213]=ft):ft=e[213];let _t;e[214]!==S?(_t=S("thread.branchPicker.delete"),e[214]=S,e[215]=_t):_t=e[215];let pt;e[216]!==yt||e[217]!==_t?(pt=c.jsx(Ia,{onClick:yt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:_t}),e[216]=yt,e[217]=_t,e[218]=pt):pt=e[218];let Ft;e[219]!==ft||e[220]!==pt?(Ft=c.jsxs(ja,{children:[ft,pt]}),e[219]=ft,e[220]=pt,e[221]=Ft):Ft=e[221];let ae;e[222]!==dt||e[223]!==Ft?(ae=c.jsxs(Ha,{children:[dt,Ft]}),e[222]=dt,e[223]=Ft,e[224]=ae):ae=e[224];let ve;e[225]!==yi||e[226]!==ae?(ve=c.jsx(Fa,{open:yi,onOpenChange:_i,children:ae}),e[225]=yi,e[226]=ae,e[227]=ve):ve=e[227];let Se;return e[228]!==wi||e[229]!==ve?(Se=c.jsxs(c.Fragment,{children:[wi,ve]}),e[228]=wi,e[229]=ve,e[230]=Se):Se=e[230],Se}function po(t){const e=U.c(20),{value:i,onChange:s,onSave:r,onCancel:n}=t,o=Be();let a;e[0]!==o?(a=o("thread.branchPicker.rename"),e[0]=o,e[1]=a):a=e[1];let h;e[2]!==s?(h=p=>s(p.target.value),e[2]=s,e[3]=h):h=e[3];let l;e[4]!==n||e[5]!==r?(l=p=>{p.key==="Enter"&&r(),p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),n())},e[4]=n,e[5]=r,e[6]=l):l=e[6];let u;e[7]!==a||e[8]!==h||e[9]!==l||e[10]!==i?(u=c.jsx("input",{autoFocus:!0,"aria-label":a,value:i,onChange:h,onKeyDown:l,className:"h-8 flex-1 rounded-md border bg-transparent px-2 text-sm outline-none focus:ring-1 focus:ring-ring"}),e[7]=a,e[8]=h,e[9]=l,e[10]=i,e[11]=u):u=e[11];let d;e[12]!==o?(d=o("thread.branchPicker.save"),e[12]=o,e[13]=d):d=e[13];let f;e[14]!==r||e[15]!==d?(f=c.jsx(pe,{size:"sm",onClick:r,children:d}),e[14]=r,e[15]=d,e[16]=f):f=e[16];let _;return e[17]!==u||e[18]!==f?(_=c.jsxs("div",{className:"flex items-center gap-1.5 p-1",children:[u,f]}),e[17]=u,e[18]=f,e[19]=_):_=e[19],_}function mo(t){const e=U.c(49),{rowRef:i,dot:s,label:r,creator:n,branch:o,selected:a,onSelect:h,onRename:l,onDelete:u}=t,d=Be(),f=a?"bg-accent":"hover:bg-accent/60";let _;e[0]!==f?(_=le("group flex items-center rounded-lg",f),e[0]=f,e[1]=_):_=e[1];let p;e[2]!==s?(p=le("h-2 w-2 shrink-0 rounded-full",s),e[2]=s,e[3]=p):p=e[3];let m;e[4]!==p?(m=c.jsx("span",{className:p}),e[4]=p,e[5]=m):m=e[5];let g;e[6]!==n?(g=n&&c.jsx("span",{className:"ml-1.5 text-xs font-normal text-muted-foreground/70",children:n}),e[6]=n,e[7]=g):g=e[7];let v;e[8]!==r||e[9]!==g?(v=c.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r,g]}),e[8]=r,e[9]=g,e[10]=v):v=e[10];let k;e[11]!==h||e[12]!==a||e[13]!==m||e[14]!==v?(k=c.jsx(St,{asChild:!0,children:c.jsxs("button",{type:"button","aria-pressed":a,onClick:h,className:"flex min-w-0 flex-1 items-center gap-2.5 px-2 py-2 text-left text-sm",children:[m,v]})}),e[11]=h,e[12]=a,e[13]=m,e[14]=v,e[15]=k):k=e[15];let b;e[16]!==o||e[17]!==d?(b=d("thread.branchPicker.branchTooltip",{branch:o}),e[16]=o,e[17]=d,e[18]=b):b=e[18];let w;e[19]!==b?(w=c.jsx(wt,{side:"bottom",className:"font-mono text-xs",children:b}),e[19]=b,e[20]=w):w=e[20];let C;e[21]!==k||e[22]!==w?(C=c.jsxs(bt,{children:[k,w]}),e[21]=k,e[22]=w,e[23]=C):C=e[23];let S;e[24]!==d?(S=d("thread.branchPicker.moreActions"),e[24]=d,e[25]=S):S=e[25];let R;e[26]===Symbol.for("react.memo_cache_sentinel")?(R=c.jsx(Ka,{className:"h-4 w-4"}),e[26]=R):R=e[26];let N;e[27]!==S?(N=c.jsx(cs,{asChild:!0,children:c.jsx(pe,{variant:"ghost",size:"icon","aria-label":S,className:"mr-1 h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100",children:R})}),e[27]=S,e[28]=N):N=e[28];let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=c.jsx(qa,{className:"h-4 w-4"}),e[29]=I):I=e[29];let L;e[30]!==d?(L=d("thread.branchPicker.rename"),e[30]=d,e[31]=L):L=e[31];let y;e[32]!==l||e[33]!==L?(y=c.jsxs(Ai,{onSelect:l,children:[I,L]}),e[32]=l,e[33]=L,e[34]=y):y=e[34];let E;e[35]!==u||e[36]!==d?(E=u&&c.jsxs(Ai,{onSelect:u,className:"text-destructive focus:text-destructive",children:[c.jsx(lr,{className:"h-4 w-4"}),d("thread.branchPicker.delete")]}),e[35]=u,e[36]=d,e[37]=E):E=e[37];let x;e[38]!==y||e[39]!==E?(x=c.jsxs(ds,{align:"end",children:[y,E]}),e[38]=y,e[39]=E,e[40]=x):x=e[40];let A;e[41]!==N||e[42]!==x?(A=c.jsxs(us,{children:[N,x]}),e[41]=N,e[42]=x,e[43]=A):A=e[43];let D;return e[44]!==i||e[45]!==C||e[46]!==A||e[47]!==_?(D=c.jsxs("div",{ref:i,className:_,children:[C,A]}),e[44]=i,e[45]=C,e[46]=A,e[47]=_,e[48]=D):D=e[48],D}function pd(t){const e=U.c(40),{rowRef:i,url:s,onSelect:r,onEdit:n,onTurnOff:o}=t,a=Be();let h;try{let y;e[0]!==s?(y=new URL(s),e[0]=s,e[1]=y):y=e[1],h=y.host}catch{h=s}const l=h;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-special"}),e[2]=u):u=e[2];let d;e[3]!==a?(d=a("thread.branchPicker.localLabel"),e[3]=a,e[4]=d):d=e[4];let f;e[5]!==l?(f=c.jsx("span",{className:"ml-1.5 text-xs font-normal text-muted-foreground/70",children:l}),e[5]=l,e[6]=f):f=e[6];let _;e[7]!==d||e[8]!==f?(_=c.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[d,f]}),e[7]=d,e[8]=f,e[9]=_):_=e[9];let p;e[10]!==r||e[11]!==_?(p=c.jsxs("button",{type:"button","aria-pressed":!0,onClick:r,className:"flex min-w-0 flex-1 items-center gap-2.5 px-2 py-2 text-left text-sm",children:[u,_]}),e[10]=r,e[11]=_,e[12]=p):p=e[12];let m;e[13]!==a?(m=a("thread.branchPicker.moreActions"),e[13]=a,e[14]=m):m=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx(Ka,{className:"h-4 w-4"}),e[15]=g):g=e[15];let v;e[16]!==m?(v=c.jsx(cs,{asChild:!0,children:c.jsx(pe,{variant:"ghost",size:"icon","aria-label":m,className:"mr-1 h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100",children:g})}),e[16]=m,e[17]=v):v=e[17];let k;e[18]===Symbol.for("react.memo_cache_sentinel")?(k=c.jsx(qa,{className:"h-4 w-4"}),e[18]=k):k=e[18];let b;e[19]!==a?(b=a("thread.branchPicker.rename"),e[19]=a,e[20]=b):b=e[20];let w;e[21]!==n||e[22]!==b?(w=c.jsxs(Ai,{onSelect:n,children:[k,b]}),e[21]=n,e[22]=b,e[23]=w):w=e[23];let C;e[24]===Symbol.for("react.memo_cache_sentinel")?(C=c.jsx(lr,{className:"h-4 w-4"}),e[24]=C):C=e[24];let S;e[25]!==a?(S=a("thread.branchPicker.localTurnOff"),e[25]=a,e[26]=S):S=e[26];let R;e[27]!==o||e[28]!==S?(R=c.jsxs(Ai,{onSelect:o,className:"text-destructive focus:text-destructive",children:[C,S]}),e[27]=o,e[28]=S,e[29]=R):R=e[29];let N;e[30]!==w||e[31]!==R?(N=c.jsxs(ds,{align:"end",children:[w,R]}),e[30]=w,e[31]=R,e[32]=N):N=e[32];let I;e[33]!==N||e[34]!==v?(I=c.jsxs(us,{children:[v,N]}),e[33]=N,e[34]=v,e[35]=I):I=e[35];let L;return e[36]!==i||e[37]!==I||e[38]!==p?(L=c.jsxs("div",{ref:i,className:"group flex items-center rounded-lg bg-accent",children:[p,I]}),e[36]=i,e[37]=I,e[38]=p,e[39]=L):L=e[39],L}function md(t){const e=U.c(73),{orgId:i,orgSlug:s,userId:r,target:n,owner:o,repo:a,sandboxMap:h,enabled:l,tab:u,onTabChange:d,localUrl:f,onSaveLocal:_,onBack:p,onAdopt:m}=t,g=Be(),[v,k]=X.useState(""),b=u==="branches"?v:"",w=l&&u==="branches";let C;e[0]!==i||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==h||e[5]!==b||e[6]!==w||e[7]!==n||e[8]!==r?(C={orgId:i,orgSlug:s,userId:r,target:n,sandboxMap:h,owner:o,repo:a,search:b,enabled:w},e[0]=i,e[1]=s,e[2]=o,e[3]=a,e[4]=h,e[5]=b,e[6]=w,e[7]=n,e[8]=r,e[9]=C):C=e[9];const{recent:S,yours:R,others:N,isLoading:I,hasMore:L,isFetchingMore:y,fetchMore:E}=ud(C),x=l&&u==="prs";let A;e[10]!==i||e[11]!==s||e[12]!==o||e[13]!==a||e[14]!==x||e[15]!==n?(A={orgId:i,orgSlug:s,target:n,owner:o,repo:a,enabled:x},e[10]=i,e[11]=s,e[12]=o,e[13]=a,e[14]=x,e[15]=n,e[16]=A):A=e[16];const{data:D,isLoading:P}=vc(A);let B;if(e[17]!==E||e[18]!==L||e[19]!==y||e[20]!==I||e[21]!==f||e[22]!==m||e[23]!==p||e[24]!==_||e[25]!==d||e[26]!==N||e[27]!==o||e[28]!==P||e[29]!==S||e[30]!==a||e[31]!==v||e[32]!==g||e[33]!==D||e[34]!==u||e[35]!==R){const M=D===void 0?[]:D,K=`${o}/${a}`;let F;e[37]!==K?(F=K.toLowerCase(),e[37]=K,e[38]=F):F=e[38];const H=F;let Y;e[39]!==H?(Y=$=>$.headRepoFullName?.toLowerCase()===H,e[39]=H,e[40]=Y):Y=e[40];const q=M.filter(Y);let te;if(e[41]!==N||e[42]!==S||e[43]!==R){const $=new Set;te=[...S,...R,...N].filter(De=>$.has(De.name)?!1:($.add(De.name),!0)),e[41]=N,e[42]=S,e[43]=R,e[44]=te}else te=e[44];const J=te;let Q;e[45]===Symbol.for("react.memo_cache_sentinel")?(Q=c.jsx(ic,{className:"h-4 w-4 shrink-0"}),e[45]=Q):Q=e[45];let W;e[46]!==g?(W=g("thread.branchPicker.advancedBack"),e[46]=g,e[47]=W):W=e[47];let G;e[48]!==p||e[49]!==W?(G=c.jsxs("button",{type:"button",onClick:p,className:"flex items-center gap-1.5 px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground",children:[Q,W]}),e[48]=p,e[49]=W,e[50]=G):G=e[50];let ee;e[51]!==d?(ee=$=>{d($),k("")},e[51]=d,e[52]=ee):ee=e[52];let ue;e[53]!==g?(ue=g("thread.branchPicker.branchesTab"),e[53]=g,e[54]=ue):ue=e[54];let ie;e[55]!==ue?(ie=c.jsx(Pi,{value:"branches",className:"h-6 px-2.5 text-xs",children:ue}),e[55]=ue,e[56]=ie):ie=e[56];let de;e[57]!==g?(de=g("thread.branchPicker.prsTab"),e[57]=g,e[58]=de):de=e[58];let z;e[59]!==de?(z=c.jsx(Pi,{value:"prs",className:"h-6 px-2.5 text-xs",children:de}),e[59]=de,e[60]=z):z=e[60];let ge;e[61]!==g?(ge=g("thread.branchPicker.localTab"),e[61]=g,e[62]=ge):ge=e[62];let fe;e[63]!==ge?(fe=c.jsx(Pi,{value:"local",className:"h-6 px-2.5 text-xs",children:ge}),e[63]=ge,e[64]=fe):fe=e[64];let Le;e[65]!==ie||e[66]!==z||e[67]!==fe?(Le=c.jsxs(za,{className:"h-auto w-fit justify-start gap-1 bg-accent p-1",variant:"pill",children:[ie,z,fe]}),e[65]=ie,e[66]=z,e[67]=fe,e[68]=Le):Le=e[68];let oe;e[69]!==ee||e[70]!==Le||e[71]!==u?(oe=c.jsx(Wa,{className:"px-2 pt-2 pb-1",value:u,onValueChange:ee,children:Le}),e[69]=ee,e[70]=Le,e[71]=u,e[72]=oe):oe=e[72],B=c.jsxs("div",{className:"flex flex-col",children:[G,oe,u==="local"?c.jsx(vd,{url:f,onSave:_}):c.jsxs(Zh,{filter:u==="branches"?gd:void 0,children:[c.jsx(Qh,{placeholder:g(u==="branches"?"thread.branchPicker.searchBranches":"thread.branchPicker.searchPullRequests"),value:v,onValueChange:k}),c.jsx(ec,{onScroll:$=>{const De=$.currentTarget;u==="branches"&&De.scrollHeight-De.scrollTop-De.clientHeight<48&&E()},children:u==="branches"?c.jsxs(c.Fragment,{children:[I&&c.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:g("thread.branchPicker.loadingMore")}),!I&&J.length===0&&c.jsx(so,{children:g("thread.branchPicker.noBranchesFound")}),J.length>0&&c.jsx(ro,{children:J.map($=>c.jsxs(no,{value:$.name,className:"cursor-pointer",onSelect:()=>m($.name,$.name),children:[c.jsx(Nh,{className:"mr-2 h-4 w-4 shrink-0"}),c.jsx("span",{className:"flex-1 truncate",children:$.name})]},$.name))}),L&&c.jsx("div",{className:"p-2",children:c.jsx(pe,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:y,onClick:E,children:g(y?"thread.branchPicker.loadingMore":"thread.branchPicker.loadMoreBranches")})})]}):c.jsxs(c.Fragment,{children:[P&&c.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:g("thread.branchPicker.loadingPullRequests")}),!P&&q.length===0&&c.jsx(so,{children:g("thread.branchPicker.noOpenPullRequests")}),q.length>0&&c.jsx(ro,{children:q.map($=>c.jsxs(no,{value:`#${$.number} ${$.title} ${$.head}`,className:"cursor-pointer",onSelect:()=>m($.head,_o($.title)),children:[c.jsx(ar,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground"}),c.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c.jsx("span",{className:"truncate",children:_o($.title)}),c.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["#",$.number," · ",$.head]})]})]},$.number))})]})})]})]}),e[17]=E,e[18]=L,e[19]=y,e[20]=I,e[21]=f,e[22]=m,e[23]=p,e[24]=_,e[25]=d,e[26]=N,e[27]=o,e[28]=P,e[29]=S,e[30]=a,e[31]=v,e[32]=g,e[33]=D,e[34]=u,e[35]=R,e[36]=B}else B=e[36];return B}function gd(t,e){return zr(t,e)?1:0}function vd(t){const e=U.c(39),{url:i,onSave:s}=t,r=Be(),[n,o]=X.useState(i??"");let a;e[0]!==n?(a=n.trim(),e[0]=n,e[1]=a):a=e[1];const h=a;let l;e[2]!==s||e[3]!==h?(l=()=>s(h?oc(h):null),e[2]=s,e[3]=h,e[4]=l):l=e[4];const u=l;let d;e[5]!==r?(d=r("thread.branchPicker.localHint"),e[5]=r,e[6]=d):d=e[6];let f;e[7]!==d?(f=c.jsx("p",{className:"text-xs text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let _;e[9]!==r?(_=r("thread.branchPicker.localUrlLabel"),e[9]=r,e[10]=_):_=e[10];let p;e[11]!==r?(p=r("thread.branchPicker.localUrlPlaceholder"),e[11]=r,e[12]=p):p=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=N=>o(N.target.value),e[13]=m):m=e[13];let g;e[14]!==u||e[15]!==h?(g=N=>{N.key==="Enter"&&h&&u()},e[14]=u,e[15]=h,e[16]=g):g=e[16];let v;e[17]!==_||e[18]!==p||e[19]!==g||e[20]!==n?(v=c.jsx("input",{type:"url",inputMode:"url","aria-label":_,placeholder:p,value:n,onChange:m,onKeyDown:g,className:"h-8 w-full rounded-md border bg-transparent px-2 text-sm outline-none focus:ring-1 focus:ring-ring"}),e[17]=_,e[18]=p,e[19]=g,e[20]=n,e[21]=v):v=e[21];let k;e[22]!==s||e[23]!==r||e[24]!==i?(k=i?c.jsx(pe,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:()=>s(null),children:r("thread.branchPicker.localTurnOff")}):c.jsx("span",{}),e[22]=s,e[23]=r,e[24]=i,e[25]=k):k=e[25];const b=!h;let w;e[26]!==r?(w=r("thread.branchPicker.save"),e[26]=r,e[27]=w):w=e[27];let C;e[28]!==u||e[29]!==b||e[30]!==w?(C=c.jsx(pe,{size:"sm",disabled:b,onClick:u,children:w}),e[28]=u,e[29]=b,e[30]=w,e[31]=C):C=e[31];let S;e[32]!==k||e[33]!==C?(S=c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[k,C]}),e[32]=k,e[33]=C,e[34]=S):S=e[34];let R;return e[35]!==S||e[36]!==f||e[37]!==v?(R=c.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[f,v,S]}),e[35]=S,e[36]=f,e[37]=v,e[38]=R):R=e[38],R}function bd(t){const e=U.c(17),{locked:i,placement:s,value:r,virtualMcpId:n,userLabel:o,baseBranch:a,onChange:h,onCreateBranch:l,onAdoptBranch:u,orgId:d,orgSlug:f,userId:_,target:p,owner:m,repo:g,sandboxMap:v}=t;let k;return e[0]!==a||e[1]!==i||e[2]!==u||e[3]!==h||e[4]!==l||e[5]!==d||e[6]!==f||e[7]!==m||e[8]!==s||e[9]!==g||e[10]!==v||e[11]!==p||e[12]!==_||e[13]!==o||e[14]!==r||e[15]!==n?(k=c.jsx(_d,{virtualMcpId:n,userLabel:o,value:r,baseBranch:a,orgId:d,orgSlug:f,userId:_,target:p,owner:m,repo:g,sandboxMap:v,onChange:h,onCreateBranch:l,onAdoptBranch:u,spawnsNewChat:i,placement:s}),e[0]=a,e[1]=i,e[2]=u,e[3]=h,e[4]=l,e[5]=d,e[6]=f,e[7]=m,e[8]=s,e[9]=g,e[10]=v,e[11]=p,e[12]=_,e[13]=o,e[14]=r,e[15]=n,e[16]=k):k=e[16],k}function Sd(t){const e=U.c(2),{branchPill:i}=t;if(!i)return null;let s;return e[0]!==i?(s=c.jsx(c.Fragment,{children:i}),e[0]=i,e[1]=s):s=e[1],s}function wd(t){const e=U.c(21),{virtualMcp:i,currentBranch:s}=t,r=Yh(),n=Wi();let o;e[0]!==r?.messages||e[1]!==n?.isThreadLocked?(o=(r?.messages??[]).length>0||(n?.isThreadLocked??!1),e[0]=r?.messages,e[1]=n?.isThreadLocked,e[2]=o):o=e[2];const a=o,h=n?.setCurrentTaskBranch,l=n?.createTask;let u;e[3]!==n?.activeTask?.metadata||e[4]!==i?.metadata?(u=ac(i?.metadata)==="cms"&&lc(n?.activeTask?.metadata,i?.metadata)==="sandbox",e[3]=n?.activeTask?.metadata,e[4]=i?.metadata,e[5]=u):u=e[5];const d=u,f=_c(i),_=Bt(f),{data:p}=sr.useSession(),m=p?.user;let g;e[6]!==m?(g=On(m),e[6]=m,e[7]=g):g=e[7];const v=g,k=p?.user?.id??"",{org:b}=rr(),w=bc(i,s);let C;e[8]!==l||e[9]!==a||e[10]!==h?(C=x=>{a&&l?l({branch:x}):h&&h(x)},e[8]=l,e[9]=a,e[10]=h,e[11]=C):C=e[11];const S=C;let R;e[12]!==d||e[13]!==l||e[14]!==a||e[15]!==h?(R=x=>{(a||d)&&l?l({branch:x}):h&&h(x)},e[12]=d,e[13]=l,e[14]=a,e[15]=h,e[16]=R):R=e[16];const N=R;let I;e[17]!==l?(I=l?x=>l({runtime:"sandbox",branch:x}):void 0,e[17]=l,e[18]=I):I=e[18];const L=I,y=f&&Ga(_)?c.jsx(bd,{userLabel:v,virtualMcpId:i?.id??"",value:s,baseBranch:w,orgId:b.id,orgSlug:b.slug,userId:k,target:_,owner:f.owner,repo:f.name,sandboxMap:i?.metadata?.sandboxMap,onChange:S,onCreateBranch:N,onAdoptBranch:L,locked:a,placement:"chat"},`${Xa(_)}:${f.owner}/${f.name}`):null;let E;return e[19]!==y?(E=c.jsx(Sd,{branchPill:y}),e[19]=y,e[20]=E):E=e[20],E}const yd=Oh("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function xd(t){const e=U.c(11);let i,s,r;e[0]!==t?({className:i,orientation:s,...r}=t,e[0]=t,e[1]=i,e[2]=s,e[3]=r):(i=e[1],s=e[2],r=e[3]);let n;e[4]!==i||e[5]!==s?(n=le(yd({orientation:s}),i),e[4]=i,e[5]=s,e[6]=n):n=e[6];let o;return e[7]!==s||e[8]!==r||e[9]!==n?(o=c.jsx("div",{role:"group","data-slot":"button-group","data-orientation":s,className:n,...r}),e[7]=s,e[8]=r,e[9]=n,e[10]=o):o=e[10],o}function Cd(t){const e=U.c(14),{item:i}=t;let s;e[0]!==i?(s=()=>{i.onSelect()},e[0]=i,e[1]=s):s=e[1];let r;e[2]!==i.disabled||e[3]!==i.icon||e[4]!==i.label||e[5]!==s?(r=c.jsxs(Ai,{disabled:i.disabled,onSelect:s,children:[i.icon,i.label]}),e[2]=i.disabled,e[3]=i.icon,e[4]=i.label,e[5]=s,e[6]=r):r=e[6];const n=r;if(!i.tooltip)return n;let o;e[7]!==n?(o=c.jsx(St,{asChild:!0,children:n}),e[7]=n,e[8]=o):o=e[8];let a;e[9]!==i.tooltip?(a=c.jsx(wt,{side:"right",children:i.tooltip}),e[9]=i.tooltip,e[10]=a):a=e[10];let h;return e[11]!==o||e[12]!==a?(h=c.jsxs(bt,{children:[o,a]}),e[11]=o,e[12]=a,e[13]=h):h=e[13],h}function Sl(t){const e=U.c(20),{label:i,onClick:s,variant:r,size:n,disabled:o,loading:a,pulse:h,tooltip:l,icon:u,items:d,menuAriaLabel:f,className:_}=t,p=r===void 0?"default":r,m=n===void 0?"default":n,g=o===void 0?!1:o,v=a===void 0?!1:a,k=h===void 0?!1:h,b=(d?.length??0)>0;let w;if(e[0]!==_||e[1]!==g||e[2]!==b||e[3]!==u||e[4]!==d||e[5]!==i||e[6]!==v||e[7]!==f||e[8]!==s||e[9]!==k||e[10]!==m||e[11]!==l||e[12]!==p){const C=le(Ba,p==="default"&&"focus-visible:inset-ring-current");let S;e[14]!==u||e[15]!==v?(S=v?c.jsx(rs,{size:"xs"}):u,e[14]=u,e[15]=v,e[16]=S):S=e[16];const R=c.jsxs(pe,{type:"button",variant:p,size:m,disabled:g,"aria-busy":v||void 0,onClick:v?void 0:s,className:le(C,b&&"rounded-r-none border-r border-current/20"),children:[S,i]}),N=k&&"animate-pulse-brightness motion-reduce:animate-none motion-reduce:opacity-80";let I;e[17]!==_||e[18]!==N?(I=le(N,_),e[17]=_,e[18]=N,e[19]=I):I=e[19],w=c.jsxs(xd,{className:I,children:[l?c.jsxs(bt,{children:[c.jsx(St,{asChild:!0,children:c.jsx("span",{className:le("inline-flex rounded-lg outline-none",C,g&&"cursor-not-allowed"),tabIndex:g?0:void 0,role:g?"button":void 0,"aria-disabled":g||void 0,children:R})}),c.jsx(wt,{children:l})]}):R,b?c.jsxs(us,{children:[c.jsx(cs,{asChild:!0,children:c.jsx(pe,{type:"button",variant:p,size:m,"aria-label":f,className:le("has-[>svg]:px-2",C),children:c.jsx(or,{className:"size-3.5"})})}),c.jsx(ds,{align:"end",children:d?.map(kd)})]}):null]}),e[0]=_,e[1]=g,e[2]=b,e[3]=u,e[4]=d,e[5]=i,e[6]=v,e[7]=f,e[8]=s,e[9]=k,e[10]=m,e[11]=l,e[12]=p,e[13]=w}else w=e[13];return w}function kd(t){return c.jsx(Cd,{item:t},t.key)}function wl(t){return ur({userName:t?.name,userEmail:t?.email})??void 0}function Fn(t){const e=U.c(18),{state:i,header:s,body:r,note:n,gate:o,footer:a}=t,h=i!=="ready";let l;e[0]!==s?(l=c.jsx("div",{className:"space-y-0.5 px-4 py-3",children:s}),e[0]=s,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx("div",{className:"border-t"}),e[2]=u):u=e[2];let d;e[3]!==n?(d=n?c.jsx("div",{className:"space-y-1.5 border-t px-4 py-3",children:n}):null,e[3]=n,e[4]=d):d=e[4];let f;e[5]!==r||e[6]!==d?(f=c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r,d]}),e[5]=r,e[6]=d,e[7]=f):f=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsx("div",{className:"border-t"}),e[8]=_):_=e[8];let p;e[9]!==a?(p=c.jsx("div",{className:"space-y-2 px-4 py-3",children:a}),e[9]=a,e[10]=p):p=e[10];let m;return e[11]!==o||e[12]!==i||e[13]!==h||e[14]!==l||e[15]!==f||e[16]!==p?(m=c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-publish-state":i,"aria-busy":h,children:[l,u,f,o,_,p]}),e[11]=o,e[12]=i,e[13]=h,e[14]=l,e[15]=f,e[16]=p,e[17]=m):m=e[17],m}function Wr(t){const e=U.c(2),{children:i}=t;let s;return e[0]!==i?(s=c.jsx("div",{className:"scroll-fade min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 pt-3 pb-2 [scrollbar-width:thin]",children:i}),e[0]=i,e[1]=s):s=e[1],s}function yl(t){const e=U.c(10);let i,s,r;e[0]!==t?({className:s,children:i,...r}=t,e[0]=t,e[1]=i,e[2]=s,e[3]=r):(i=e[1],s=e[2],r=e[3]);let n;e[4]!==s?(n=le("rounded-lg border bg-card px-3 py-2.5",s),e[4]=s,e[5]=n):n=e[5];let o;return e[6]!==i||e[7]!==r||e[8]!==n?(o=c.jsx("div",{className:n,...r,children:i}),e[6]=i,e[7]=r,e[8]=n,e[9]=o):o=e[9],o}function ti(t){const e=U.c(4),{className:i}=t;let s;e[0]!==i?(s=le("animate-pulse rounded bg-muted motion-reduce:animate-none",i),e[0]=i,e[1]=s):s=e[1];let r;return e[2]!==s?(r=c.jsx("div",{className:s}),e[2]=s,e[3]=r):r=e[3],r}function is(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(yl,{children:c.jsxs("div",{className:"flex items-center gap-2.5",children:[c.jsx(ti,{className:"size-4 rounded-md"}),c.jsx(ti,{className:"h-3 w-24"}),c.jsx(ti,{className:"h-2.5 w-16"}),c.jsx(ti,{className:"ml-auto size-6 rounded"})]})}),t[0]=e):e=t[0],e}async function Ed(t,e,i){const s=ur(i.coAuthor),{changeRequest:r}=await Tn(t,"CHANGE_REQUEST_OPEN",{...e,head:i.branch,base:i.base,title:i.title,body:rd(i.body,s)||void 0});return{number:r.number,htmlUrl:r.url}}class xl extends Error{reason;detail;constructor(e,i){super(i||`Merge refused: ${e}`),this.name="ChangeRequestMergeRefused",this.reason=e,this.detail=i}}async function Cl(t,e,i){const s=ur(i.coAuthor),r=s?bl(i.commitMessage?.trim()??"",s):i.commitMessage?.trim()||void 0,n=await Tn(t,"CHANGE_REQUEST_MERGE",{...e,number:i.number,strategy:"squash",commitTitle:i.commitTitle,commitMessage:r});if(!n.merged)throw new xl(n.reason??"error",n.detail)}function Pd(t,e){switch(t){case"conflict":return e("thread.mergeRefused.conflict");case"blocked":return e("thread.mergeRefused.blocked");case"rate_limited":return e("thread.mergeRefused.rateLimited");case"not_found":return e("thread.mergeRefused.notFound");default:return e("thread.mergeRefused.error")}}class $r extends Error{constructor(){super("The branch changed since these changes were shown"),this.name="PublishHeadMovedError"}}class zn extends Error{constructor(e,i,s){super(e),this.step=i,this.pr=s,this.name="PublishStepError"}step;pr}const qs=255;function kl(t){if(t.length<=qs)return t;const e=t.slice(0,qs-1),i=e.lastIndexOf(" ");return`${(i>0?e.slice(0,i):e).trimEnd()}…`}function Rd(t){const e=t.title.trim(),i=t.body.trim(),s=[e,i].filter(Boolean).join(`
5
+ ${r}`:r}function rd(t,e){const i=t?.trim();return i?bl(i,e):i||void 0}const nd=["dev","start"],od={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},fo=1114111;function _o(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,i)=>{if(i.startsWith("#x")||i.startsWith("#X")){const s=Number.parseInt(i.slice(2),16);return!Number.isFinite(s)||s>fo?e:String.fromCodePoint(s)}if(i.startsWith("#")){const s=Number.parseInt(i.slice(1),10);return!Number.isFinite(s)||s>fo?e:String.fromCodePoint(s)}return od[i]??e}):""}const ad=10080*60*1e3;function ld({sandboxMap:t,userId:e,rawBranches:i,now:s}){const r=new Map;for(const[d,f]of Object.entries(t??{}))for(const[_,p]of Object.entries(f??{})){let m=r.get(_);m||(m={userIds:new Set,lastActiveAt:0},r.set(_,m)),m.userIds.add(d);for(const g of Object.values(p??{})){const v=g?.createdAt??0;v>m.lastActiveAt&&(m.lastActiveAt=v)}}const n=s-ad,o=[...r.entries()].filter(([,d])=>d.lastActiveAt>=n).sort((d,f)=>f[1].lastActiveAt-d[1].lastActiveAt).map(([d,f])=>({name:d,source:"recent",contributors:[...f.userIds],lastActiveAt:f.lastActiveAt})),a=new Set(o.map(d=>d.name)),h=new Set(Object.keys(t?.[e]??{})),l=[...h].filter(d=>!a.has(d)).sort().map(d=>({name:d,source:"yours"})),u=i.filter(d=>!h.has(d.name)&&!a.has(d.name)).map(d=>({name:d.name,source:"other",author:d.author??null}));return{recent:o,yours:l,others:u}}const hd=100,cd=50,dd=300;function zr(t,e){const i=e.trim().toLowerCase();return i?t.toLowerCase().includes(i):!0}function ud(t){const e=U.c(39),{orgId:i,orgSlug:s,userId:r,target:n,sandboxMap:o,owner:a,repo:h,search:l,enabled:u}=t,d=l===void 0?"":l,f=u===void 0?!0:u;let _;e[0]!==d?(_=d.trim(),e[0]=d,e[1]=_):_=e[1];const p=_,m=wc(p,dd);let g;e[2]!==n?(g=Ga(n),e[2]=n,e[3]=g):g=e[3];const v=g,k=p.length>0;let b;e[4]!==m||e[5]!==i||e[6]!==s||e[7]!==a||e[8]!==h||e[9]!==n?(b=An.githubBranchSearch(i,s,Xa(n),a,h,m),e[4]=m,e[5]=i,e[6]=s,e[7]=a,e[8]=h,e[9]=n,e[10]=b):b=e[10];const w=f&&v;let C;e[11]!==m||e[12]!==s||e[13]!==n?(C=ee=>{const{pageParam:ue}=ee;return Tn(s,"REPOSITORY_SEARCH_BRANCHES",{...n,query:m,limit:m?cd:hd,cursor:ue})},e[11]=m,e[12]=s,e[13]=n,e[14]=C):C=e[14];let S;e[15]!==m?(S=ee=>m?void 0:ee.nextCursor??void 0,e[15]=m,e[16]=S):S=e[16];let R;e[17]!==b||e[18]!==w||e[19]!==C||e[20]!==S?(R={queryKey:b,enabled:w,staleTime:3e4,retry:!1,initialPageParam:null,queryFn:C,getNextPageParam:S},e[17]=b,e[18]=w,e[19]=C,e[20]=S,e[21]=R):R=e[21];const{data:N,isLoading:I,isError:L,isFetching:y,hasNextPage:E,isFetchingNextPage:x,fetchNextPage:A}=xc(R),D=k&&(m!==p||y),P=(N?.pages??[]).flatMap(fd),B=yc(6e4),M=ld({sandboxMap:o,userId:r,rawBranches:P,now:B});let K;e[22]!==p?(K=ee=>zr(ee.name,p),e[22]=p,e[23]=K):K=e[23];const F=M.recent.filter(K);let H;e[24]!==p?(H=ee=>zr(ee.name,p),e[24]=p,e[25]=H):H=e[25];const Y=M.yours.filter(H),q=M.others,te=N?.pages[0],J=k&&te&&!D?Math.max(0,te.totalCount-te.branches.length):0,Q=!k&&E;let W;e[26]!==A?(W=()=>{A()},e[26]=A,e[27]=W):W=e[27];let G;return e[28]!==J||e[29]!==L||e[30]!==x||e[31]!==I||e[32]!==D||e[33]!==q||e[34]!==F||e[35]!==Q||e[36]!==W||e[37]!==Y?(G={recent:F,yours:Y,others:q,isLoading:I,isError:L,isSearching:D,hiddenMatchCount:J,hasMore:Q,isFetchingMore:x,fetchMore:W},e[28]=J,e[29]=L,e[30]=x,e[31]=I,e[32]=D,e[33]=q,e[34]=F,e[35]=Q,e[36]=W,e[37]=Y,e[38]=G):G=e[38],G}function fd(t){return t.branches}function _d(t){const e=U.c(231),{virtualMcpId:i,userLabel:s,value:r,baseBranch:n,orgId:o,orgSlug:a,userId:h,target:l,owner:u,repo:d,sandboxMap:f,onChange:_,onCreateBranch:p,onAdoptBranch:m,disabled:g,spawnsNewChat:v,placement:k}=t,b=g===void 0?!1:g,w=v===void 0?!1:v,C=k===void 0?"chat":k,S=Be(),R=C==="header",[N,I]=X.useState(!1),[L,y]=X.useState(!1),[E,x]=X.useState("branches"),[A,D]=X.useState(null),[P,B]=X.useState(""),[M,K]=X.useState(null),F=X.useRef(null),{releases:H,createRelease:Y,renameRelease:q,deleteRelease:te}=Ln(i),{url:J,setUrl:Q,clear:W}=In(i),G=!!J;let ee;e[0]!==N?(ee={enabled:N},e[0]=N,e[1]=ee):ee=e[1];const{data:ue}=pc(ee);let ie;e[2]!==ue?.data?.members?(ie=se=>se?ue?.data?.members?.find(st=>st.userId===se)?.user?.name??void 0:void 0,e[2]=ue?.data?.members,e[3]=ie):ie=e[3];const de=ie,z=H.length>=ao;let ge;e[4]!==S?(ge=S("thread.branchPicker.capReached",{max:ao}),e[4]=S,e[5]=ge):ge=e[5];const fe=ge,Le=!!r&&r===n;let oe,$,De,At,Ye,He,it,Ne,yt,Wt,ce,Ke,qe,V,_e,Ae,ye,Je,nt,xt,ot,Tt,$t,Mt,ke,Ct,Lt,Ut,ni;if(e[6]!==z||e[7]!==n||e[8]!==fe||e[9]!==W||e[10]!==Y||e[11]!==te||e[12]!==b||e[13]!==P||e[14]!==Le||e[15]!==R||e[16]!==G||e[17]!==m||e[18]!==_||e[19]!==p||e[20]!==N||e[21]!==M||e[22]!==H||e[23]!==q||e[24]!==Q||e[25]!==S||e[26]!==h||e[27]!==s||e[28]!==r){let se;e[58]!==r?(se=he=>he.branch===r,e[58]=r,e[59]=se):se=e[59];const st=H.find(se);ni=!Le&&!st&&!!r;const Oi=Le?S("thread.branchPicker.live"):st?.name??S("thread.branchPicker.defaultVersionName");ce=G?S("thread.branchPicker.localLabel"):r?Oi:S("thread.branchPicker.selectVersion");const Mh=G?"bg-special":Le?"bg-success":br(st?.color??"orange");let gs;e[60]!==W||e[61]!==_?(gs=he=>{W(),_(he),I(!1)},e[60]=W,e[61]=_,e[62]=gs):gs=e[62],qe=gs;let vs;e[63]!==S?(vs=he=>{Xe.error(he instanceof Error?he.message:S("thread.branchPicker.saveError"))},e[63]=S,e[64]=vs):vs=e[64];const Ze=vs;let bs;e[65]!==Q?(bs=he=>{Q(he),y(!1),I(!1)},e[65]=Q,e[66]=bs):bs=e[66],He=bs;let Ss;e[67]!==z||e[68]!==fe||e[69]!==W||e[70]!==Y||e[71]!==m||e[72]!==_||e[73]!==H||e[74]!==Ze||e[75]!==h?(Ss=(he,xi)=>{if(W(),m){m(he),y(!1),I(!1);return}if(!H.some(vr=>vr.branch===he)){if(z){Xe.error(fe);return}Y({branch:he,name:xi.trim()||he,color:Sr(H.length),createdBy:h,createdAt:new Date().toISOString()}).catch(Ze)}_(he),y(!1),I(!1)},e[67]=z,e[68]=fe,e[69]=W,e[70]=Y,e[71]=m,e[72]=_,e[73]=H,e[74]=Ze,e[75]=h,e[76]=Ss):Ss=e[76],it=Ss;let ws;e[77]!==z||e[78]!==fe||e[79]!==W||e[80]!==Y||e[81]!==_||e[82]!==p||e[83]!==H||e[84]!==Ze||e[85]!==S||e[86]!==h||e[87]!==s?(ws=()=>{if(z){Xe.error(fe);return}W();const he=Nn(s);Y({branch:he,name:oo(H,S("thread.branchPicker.defaultVersionName")),color:Sr(H.length),createdBy:h,createdAt:new Date().toISOString()}).catch(Ze),(p??_)(he),I(!1)},e[77]=z,e[78]=fe,e[79]=W,e[80]=Y,e[81]=_,e[82]=p,e[83]=H,e[84]=Ze,e[85]=S,e[86]=h,e[87]=s,e[88]=ws):ws=e[88],Wt=ws;let ys;e[89]===Symbol.for("react.memo_cache_sentinel")?(ys=()=>{D(null),B(""),y(!1),x("branches")},e[89]=ys):ys=e[89];const Lh=ys;let xs;e[90]===Symbol.for("react.memo_cache_sentinel")?(xs=he=>{x(he),y(!0)},e[90]=xs):xs=e[90],Ke=xs;let Cs;e[91]===Symbol.for("react.memo_cache_sentinel")?(Cs=he=>{D(he.branch),B(he.name)},e[91]=Cs):Cs=e[91],Ae=Cs;let ks;e[92]!==P||e[93]!==q||e[94]!==Ze?(ks=he=>{const xi=P.trim();xi&&q(he,xi).catch(Ze),D(null),B("")},e[92]=P,e[93]=q,e[94]=Ze,e[95]=ks):ks=e[95],V=ks;let Es;e[96]!==z||e[97]!==fe||e[98]!==Y||e[99]!==P||e[100]!==H.length||e[101]!==Ze||e[102]!==h||e[103]!==r?(Es=()=>{const he=P.trim();if(he&&r){if(z){Xe.error(fe),D(null),B("");return}Y({branch:r,name:he,color:Sr(H.length),createdBy:h,createdAt:new Date().toISOString()}).catch(Ze)}D(null),B("")},e[96]=z,e[97]=fe,e[98]=Y,e[99]=P,e[100]=H.length,e[101]=Ze,e[102]=h,e[103]=r,e[104]=Es):Es=e[104],_e=Es;let Ps;e[105]===Symbol.for("react.memo_cache_sentinel")?(Ps=()=>{D(null),B("")},e[105]=Ps):Ps=e[105],Ne=Ps;let Rs;e[106]!==n||e[107]!==te||e[108]!==M||e[109]!==qe||e[110]!==H||e[111]!==Ze||e[112]!==r?(Rs=()=>{const he=M;if(K(null),!!he){if(he.branch===r){const xi=H.find(vr=>vr.branch!==he.branch);xi?qe(xi.branch):n?qe(n):I(!1)}else I(!1);te(he.branch).catch(Ze)}},e[106]=n,e[107]=te,e[108]=M,e[109]=qe,e[110]=H,e[111]=Ze,e[112]=r,e[113]=Rs):Rs=e[113],yt=Rs,Ye=Da,Mt=N,e[114]!==b?(ke=b?void 0:he=>{he||Lh(),I(he)},e[114]=b,e[115]=ke):ke=e[115],At=bt,De=St,$t=!0,Tt="inline-flex min-w-0 shrink",$=Aa,ot=!0,oe=pe,Lt=ic.branchPicker,Ut=R?"outline":"ghost",ye=R?"sm":"default",Je=ce,nt=b;const gr=R?"text-xs":"text-xs text-muted-foreground hover:text-foreground";e[116]!==gr?(xt=le("shrink min-w-0 max-w-[220px] gap-2",gr,Ba),e[116]=gr,e[117]=xt):xt=e[117],Ct=le("h-2 w-2 shrink-0 rounded-full",r||G?Mh:"bg-muted-foreground"),e[6]=z,e[7]=n,e[8]=fe,e[9]=W,e[10]=Y,e[11]=te,e[12]=b,e[13]=P,e[14]=Le,e[15]=R,e[16]=G,e[17]=m,e[18]=_,e[19]=p,e[20]=N,e[21]=M,e[22]=H,e[23]=q,e[24]=Q,e[25]=S,e[26]=h,e[27]=s,e[28]=r,e[29]=oe,e[30]=$,e[31]=De,e[32]=At,e[33]=Ye,e[34]=He,e[35]=it,e[36]=Ne,e[37]=yt,e[38]=Wt,e[39]=ce,e[40]=Ke,e[41]=qe,e[42]=V,e[43]=_e,e[44]=Ae,e[45]=ye,e[46]=Je,e[47]=nt,e[48]=xt,e[49]=ot,e[50]=Tt,e[51]=$t,e[52]=Mt,e[53]=ke,e[54]=Ct,e[55]=Lt,e[56]=Ut,e[57]=ni}else oe=e[29],$=e[30],De=e[31],At=e[32],Ye=e[33],He=e[34],it=e[35],Ne=e[36],yt=e[37],Wt=e[38],ce=e[39],Ke=e[40],qe=e[41],V=e[42],_e=e[43],Ae=e[44],ye=e[45],Je=e[46],nt=e[47],xt=e[48],ot=e[49],Tt=e[50],$t=e[51],Mt=e[52],ke=e[53],Ct=e[54],Lt=e[55],Ut=e[56],ni=e[57];let Kt;e[118]!==Ct?(Kt=c.jsx("span",{className:Ct}),e[118]=Ct,e[119]=Kt):Kt=e[119];let Nt;e[120]!==ce?(Nt=c.jsx("span",{className:"min-w-0 truncate @max-3xl/panel-header:hidden",children:ce}),e[120]=ce,e[121]=Nt):Nt=e[121];let Ot;e[122]!==b?(Ot=!b&&c.jsx(or,{size:12,className:"opacity-60 shrink-0"}),e[122]=b,e[123]=Ot):Ot=e[123];let qt;e[124]!==oe||e[125]!==ye||e[126]!==Je||e[127]!==nt||e[128]!==xt||e[129]!==Kt||e[130]!==Nt||e[131]!==Ot||e[132]!==Lt||e[133]!==Ut?(qt=c.jsxs(oe,{"data-tour":Lt,variant:Ut,size:ye,"aria-label":Je,disabled:nt,className:xt,children:[Kt,Nt,Ot]}),e[124]=oe,e[125]=ye,e[126]=Je,e[127]=nt,e[128]=xt,e[129]=Kt,e[130]=Nt,e[131]=Ot,e[132]=Lt,e[133]=Ut,e[134]=qt):qt=e[134];let It;e[135]!==$||e[136]!==ot||e[137]!==qt?(It=c.jsx($,{asChild:ot,children:qt}),e[135]=$,e[136]=ot,e[137]=qt,e[138]=It):It=e[138];let Vt;e[139]!==Tt||e[140]!==It?(Vt=c.jsx("span",{className:Tt,children:It}),e[139]=Tt,e[140]=It,e[141]=Vt):Vt=e[141];let jt;e[142]!==De||e[143]!==$t||e[144]!==Vt?(jt=c.jsx(De,{asChild:$t,children:Vt}),e[142]=De,e[143]=$t,e[144]=Vt,e[145]=jt):jt=e[145];let Yt;e[146]!==ce?(Yt=c.jsx(wt,{children:ce}),e[146]=ce,e[147]=Yt):Yt=e[147];let Ht;e[148]!==At||e[149]!==jt||e[150]!==Yt?(Ht=c.jsxs(At,{children:[jt,Yt]}),e[148]=At,e[149]=jt,e[150]=Yt,e[151]=Ht):Ht=e[151];let fi;e[152]===Symbol.for("react.memo_cache_sentinel")?(fi=se=>{se.preventDefault(),F.current?.scrollIntoView({block:"nearest"})},e[152]=fi):fi=e[152];let Gt;e[153]!==w||e[154]!==S?(Gt=w&&c.jsx("p",{className:"px-2 pb-1.5 pt-1 text-xs text-muted-foreground",children:S("thread.branchPicker.newChatHint")}),e[153]=w,e[154]=S,e[155]=Gt):Gt=e[155];let kt;e[156]!==He||e[157]!==it||e[158]!==L||e[159]!==E||e[160]!==z||e[161]!==Ne||e[162]!==fe||e[163]!==W||e[164]!==Wt||e[165]!==de||e[166]!==P||e[167]!==A||e[168]!==G||e[169]!==J||e[170]!==N||e[171]!==Ke||e[172]!==o||e[173]!==a||e[174]!==u||e[175]!==qe||e[176]!==H||e[177]!==d||e[178]!==f||e[179]!==V||e[180]!==_e||e[181]!==Ae||e[182]!==S||e[183]!==l||e[184]!==ni||e[185]!==h||e[186]!==r?(kt=L?c.jsx(md,{orgId:o,orgSlug:a,userId:h,target:l,owner:u,repo:d,sandboxMap:f,enabled:N,tab:E,onTabChange:x,localUrl:J,onSaveLocal:He,onBack:()=>y(!1),onAdopt:it}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"always-scrollbar flex max-h-[min(50vh,20rem)] flex-col overflow-y-auto",children:[G&&J&&c.jsx(pd,{rowRef:F,url:J,onSelect:()=>Ke("local"),onEdit:()=>Ke("local"),onTurnOff:()=>W()}),ni&&r&&(A===r?c.jsx(po,{value:P,onChange:B,onSave:_e,onCancel:Ne}):c.jsx(mo,{rowRef:G?void 0:F,dot:br("orange"),label:S("thread.branchPicker.defaultVersionName"),branch:r,selected:!G,onSelect:()=>qe(r),onRename:()=>{D(r),B(oo(H,S("thread.branchPicker.defaultVersionName")))}})),H.map(se=>A===se.branch?c.jsx(po,{value:P,onChange:B,onSave:()=>V(se.branch),onCancel:Ne},se.branch):c.jsx(mo,{rowRef:!G&&se.branch===r?F:void 0,dot:br(se.color),label:se.name,creator:de(se.createdBy),branch:se.branch,selected:!G&&se.branch===r,onSelect:()=>qe(se.branch),onRename:()=>Ae(se),onDelete:()=>K(se)},se.branch))]}),(ni||H.length>0)&&c.jsx("div",{className:"my-1 border-t"}),c.jsxs("button",{type:"button",onClick:()=>{Wt()},disabled:z,className:"flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-sm text-muted-foreground hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[c.jsx(Mn,{className:"h-4 w-4 shrink-0"}),S("thread.branchPicker.newVersion")]}),z&&c.jsx("p",{className:"px-2 pb-1 pt-0.5 text-xs text-warning",children:fe}),c.jsxs("button",{type:"button",onClick:()=>Ke("branches"),className:"flex w-full items-center justify-between gap-2 rounded-lg px-2 py-2 text-left text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[S("thread.branchPicker.advanced"),c.jsx(Ea,{className:"h-4 w-4 shrink-0"})]})]}),e[156]=He,e[157]=it,e[158]=L,e[159]=E,e[160]=z,e[161]=Ne,e[162]=fe,e[163]=W,e[164]=Wt,e[165]=de,e[166]=P,e[167]=A,e[168]=G,e[169]=J,e[170]=N,e[171]=Ke,e[172]=o,e[173]=a,e[174]=u,e[175]=qe,e[176]=H,e[177]=d,e[178]=f,e[179]=V,e[180]=_e,e[181]=Ae,e[182]=S,e[183]=l,e[184]=ni,e[185]=h,e[186]=r,e[187]=kt):kt=e[187];let Xt;e[188]!==Gt||e[189]!==kt?(Xt=c.jsxs(Ta,{className:"w-[min(300px,calc(100vw-2rem))] p-1.5",align:"start",onOpenAutoFocus:fi,children:[Gt,kt]}),e[188]=Gt,e[189]=kt,e[190]=Xt):Xt=e[190];let oi;e[191]!==Ye||e[192]!==Mt||e[193]!==ke||e[194]!==Ht||e[195]!==Xt?(oi=c.jsxs(Ye,{open:Mt,onOpenChange:ke,children:[Ht,Xt]}),e[191]=Ye,e[192]=Mt,e[193]=ke,e[194]=Ht,e[195]=Xt,e[196]=oi):oi=e[196];const wi=oi,yi=M!==null;let _i;e[197]===Symbol.for("react.memo_cache_sentinel")?(_i=se=>{se||K(null)},e[197]=_i):_i=e[197];let at;e[198]!==S?(at=S("thread.branchPicker.deleteTitle"),e[198]=S,e[199]=at):at=e[199];let lt;e[200]!==at?(lt=c.jsx(Ma,{children:at}),e[200]=at,e[201]=lt):lt=e[201];let ht;e[202]!==M||e[203]!==S?(ht=M&&S("thread.branchPicker.deleteConfirm",{name:M.name}),e[202]=M,e[203]=S,e[204]=ht):ht=e[204];let ct;e[205]!==ht?(ct=c.jsx(La,{children:ht}),e[205]=ht,e[206]=ct):ct=e[206];let dt;e[207]!==lt||e[208]!==ct?(dt=c.jsxs(Na,{children:[lt,ct]}),e[207]=lt,e[208]=ct,e[209]=dt):dt=e[209];let ut;e[210]!==S?(ut=S("thread.branchPicker.cancel"),e[210]=S,e[211]=ut):ut=e[211];let ft;e[212]!==ut?(ft=c.jsx(Oa,{children:ut}),e[212]=ut,e[213]=ft):ft=e[213];let _t;e[214]!==S?(_t=S("thread.branchPicker.delete"),e[214]=S,e[215]=_t):_t=e[215];let pt;e[216]!==yt||e[217]!==_t?(pt=c.jsx(Ia,{onClick:yt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:_t}),e[216]=yt,e[217]=_t,e[218]=pt):pt=e[218];let Ft;e[219]!==ft||e[220]!==pt?(Ft=c.jsxs(ja,{children:[ft,pt]}),e[219]=ft,e[220]=pt,e[221]=Ft):Ft=e[221];let ae;e[222]!==dt||e[223]!==Ft?(ae=c.jsxs(Ha,{children:[dt,Ft]}),e[222]=dt,e[223]=Ft,e[224]=ae):ae=e[224];let ve;e[225]!==yi||e[226]!==ae?(ve=c.jsx(Fa,{open:yi,onOpenChange:_i,children:ae}),e[225]=yi,e[226]=ae,e[227]=ve):ve=e[227];let Se;return e[228]!==wi||e[229]!==ve?(Se=c.jsxs(c.Fragment,{children:[wi,ve]}),e[228]=wi,e[229]=ve,e[230]=Se):Se=e[230],Se}function po(t){const e=U.c(20),{value:i,onChange:s,onSave:r,onCancel:n}=t,o=Be();let a;e[0]!==o?(a=o("thread.branchPicker.rename"),e[0]=o,e[1]=a):a=e[1];let h;e[2]!==s?(h=p=>s(p.target.value),e[2]=s,e[3]=h):h=e[3];let l;e[4]!==n||e[5]!==r?(l=p=>{p.key==="Enter"&&r(),p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),n())},e[4]=n,e[5]=r,e[6]=l):l=e[6];let u;e[7]!==a||e[8]!==h||e[9]!==l||e[10]!==i?(u=c.jsx("input",{autoFocus:!0,"aria-label":a,value:i,onChange:h,onKeyDown:l,className:"h-8 flex-1 rounded-md border bg-transparent px-2 text-sm outline-none focus:ring-1 focus:ring-ring"}),e[7]=a,e[8]=h,e[9]=l,e[10]=i,e[11]=u):u=e[11];let d;e[12]!==o?(d=o("thread.branchPicker.save"),e[12]=o,e[13]=d):d=e[13];let f;e[14]!==r||e[15]!==d?(f=c.jsx(pe,{size:"sm",onClick:r,children:d}),e[14]=r,e[15]=d,e[16]=f):f=e[16];let _;return e[17]!==u||e[18]!==f?(_=c.jsxs("div",{className:"flex items-center gap-1.5 p-1",children:[u,f]}),e[17]=u,e[18]=f,e[19]=_):_=e[19],_}function mo(t){const e=U.c(49),{rowRef:i,dot:s,label:r,creator:n,branch:o,selected:a,onSelect:h,onRename:l,onDelete:u}=t,d=Be(),f=a?"bg-accent":"hover:bg-accent/60";let _;e[0]!==f?(_=le("group flex items-center rounded-lg",f),e[0]=f,e[1]=_):_=e[1];let p;e[2]!==s?(p=le("h-2 w-2 shrink-0 rounded-full",s),e[2]=s,e[3]=p):p=e[3];let m;e[4]!==p?(m=c.jsx("span",{className:p}),e[4]=p,e[5]=m):m=e[5];let g;e[6]!==n?(g=n&&c.jsx("span",{className:"ml-1.5 text-xs font-normal text-muted-foreground/70",children:n}),e[6]=n,e[7]=g):g=e[7];let v;e[8]!==r||e[9]!==g?(v=c.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r,g]}),e[8]=r,e[9]=g,e[10]=v):v=e[10];let k;e[11]!==h||e[12]!==a||e[13]!==m||e[14]!==v?(k=c.jsx(St,{asChild:!0,children:c.jsxs("button",{type:"button","aria-pressed":a,onClick:h,className:"flex min-w-0 flex-1 items-center gap-2.5 px-2 py-2 text-left text-sm",children:[m,v]})}),e[11]=h,e[12]=a,e[13]=m,e[14]=v,e[15]=k):k=e[15];let b;e[16]!==o||e[17]!==d?(b=d("thread.branchPicker.branchTooltip",{branch:o}),e[16]=o,e[17]=d,e[18]=b):b=e[18];let w;e[19]!==b?(w=c.jsx(wt,{side:"bottom",className:"font-mono text-xs",children:b}),e[19]=b,e[20]=w):w=e[20];let C;e[21]!==k||e[22]!==w?(C=c.jsxs(bt,{children:[k,w]}),e[21]=k,e[22]=w,e[23]=C):C=e[23];let S;e[24]!==d?(S=d("thread.branchPicker.moreActions"),e[24]=d,e[25]=S):S=e[25];let R;e[26]===Symbol.for("react.memo_cache_sentinel")?(R=c.jsx(Ka,{className:"h-4 w-4"}),e[26]=R):R=e[26];let N;e[27]!==S?(N=c.jsx(cs,{asChild:!0,children:c.jsx(pe,{variant:"ghost",size:"icon","aria-label":S,className:"mr-1 h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100",children:R})}),e[27]=S,e[28]=N):N=e[28];let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=c.jsx(qa,{className:"h-4 w-4"}),e[29]=I):I=e[29];let L;e[30]!==d?(L=d("thread.branchPicker.rename"),e[30]=d,e[31]=L):L=e[31];let y;e[32]!==l||e[33]!==L?(y=c.jsxs(Ai,{onSelect:l,children:[I,L]}),e[32]=l,e[33]=L,e[34]=y):y=e[34];let E;e[35]!==u||e[36]!==d?(E=u&&c.jsxs(Ai,{onSelect:u,className:"text-destructive focus:text-destructive",children:[c.jsx(lr,{className:"h-4 w-4"}),d("thread.branchPicker.delete")]}),e[35]=u,e[36]=d,e[37]=E):E=e[37];let x;e[38]!==y||e[39]!==E?(x=c.jsxs(ds,{align:"end",children:[y,E]}),e[38]=y,e[39]=E,e[40]=x):x=e[40];let A;e[41]!==N||e[42]!==x?(A=c.jsxs(us,{children:[N,x]}),e[41]=N,e[42]=x,e[43]=A):A=e[43];let D;return e[44]!==i||e[45]!==C||e[46]!==A||e[47]!==_?(D=c.jsxs("div",{ref:i,className:_,children:[C,A]}),e[44]=i,e[45]=C,e[46]=A,e[47]=_,e[48]=D):D=e[48],D}function pd(t){const e=U.c(40),{rowRef:i,url:s,onSelect:r,onEdit:n,onTurnOff:o}=t,a=Be();let h;try{let y;e[0]!==s?(y=new URL(s),e[0]=s,e[1]=y):y=e[1],h=y.host}catch{h=s}const l=h;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-special"}),e[2]=u):u=e[2];let d;e[3]!==a?(d=a("thread.branchPicker.localLabel"),e[3]=a,e[4]=d):d=e[4];let f;e[5]!==l?(f=c.jsx("span",{className:"ml-1.5 text-xs font-normal text-muted-foreground/70",children:l}),e[5]=l,e[6]=f):f=e[6];let _;e[7]!==d||e[8]!==f?(_=c.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[d,f]}),e[7]=d,e[8]=f,e[9]=_):_=e[9];let p;e[10]!==r||e[11]!==_?(p=c.jsxs("button",{type:"button","aria-pressed":!0,onClick:r,className:"flex min-w-0 flex-1 items-center gap-2.5 px-2 py-2 text-left text-sm",children:[u,_]}),e[10]=r,e[11]=_,e[12]=p):p=e[12];let m;e[13]!==a?(m=a("thread.branchPicker.moreActions"),e[13]=a,e[14]=m):m=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx(Ka,{className:"h-4 w-4"}),e[15]=g):g=e[15];let v;e[16]!==m?(v=c.jsx(cs,{asChild:!0,children:c.jsx(pe,{variant:"ghost",size:"icon","aria-label":m,className:"mr-1 h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100",children:g})}),e[16]=m,e[17]=v):v=e[17];let k;e[18]===Symbol.for("react.memo_cache_sentinel")?(k=c.jsx(qa,{className:"h-4 w-4"}),e[18]=k):k=e[18];let b;e[19]!==a?(b=a("thread.branchPicker.rename"),e[19]=a,e[20]=b):b=e[20];let w;e[21]!==n||e[22]!==b?(w=c.jsxs(Ai,{onSelect:n,children:[k,b]}),e[21]=n,e[22]=b,e[23]=w):w=e[23];let C;e[24]===Symbol.for("react.memo_cache_sentinel")?(C=c.jsx(lr,{className:"h-4 w-4"}),e[24]=C):C=e[24];let S;e[25]!==a?(S=a("thread.branchPicker.localTurnOff"),e[25]=a,e[26]=S):S=e[26];let R;e[27]!==o||e[28]!==S?(R=c.jsxs(Ai,{onSelect:o,className:"text-destructive focus:text-destructive",children:[C,S]}),e[27]=o,e[28]=S,e[29]=R):R=e[29];let N;e[30]!==w||e[31]!==R?(N=c.jsxs(ds,{align:"end",children:[w,R]}),e[30]=w,e[31]=R,e[32]=N):N=e[32];let I;e[33]!==N||e[34]!==v?(I=c.jsxs(us,{children:[v,N]}),e[33]=N,e[34]=v,e[35]=I):I=e[35];let L;return e[36]!==i||e[37]!==I||e[38]!==p?(L=c.jsxs("div",{ref:i,className:"group flex items-center rounded-lg bg-accent",children:[p,I]}),e[36]=i,e[37]=I,e[38]=p,e[39]=L):L=e[39],L}function md(t){const e=U.c(73),{orgId:i,orgSlug:s,userId:r,target:n,owner:o,repo:a,sandboxMap:h,enabled:l,tab:u,onTabChange:d,localUrl:f,onSaveLocal:_,onBack:p,onAdopt:m}=t,g=Be(),[v,k]=X.useState(""),b=u==="branches"?v:"",w=l&&u==="branches";let C;e[0]!==i||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==h||e[5]!==b||e[6]!==w||e[7]!==n||e[8]!==r?(C={orgId:i,orgSlug:s,userId:r,target:n,sandboxMap:h,owner:o,repo:a,search:b,enabled:w},e[0]=i,e[1]=s,e[2]=o,e[3]=a,e[4]=h,e[5]=b,e[6]=w,e[7]=n,e[8]=r,e[9]=C):C=e[9];const{recent:S,yours:R,others:N,isLoading:I,hasMore:L,isFetchingMore:y,fetchMore:E}=ud(C),x=l&&u==="prs";let A;e[10]!==i||e[11]!==s||e[12]!==o||e[13]!==a||e[14]!==x||e[15]!==n?(A={orgId:i,orgSlug:s,target:n,owner:o,repo:a,enabled:x},e[10]=i,e[11]=s,e[12]=o,e[13]=a,e[14]=x,e[15]=n,e[16]=A):A=e[16];const{data:D,isLoading:P}=Cc(A);let B;if(e[17]!==E||e[18]!==L||e[19]!==y||e[20]!==I||e[21]!==f||e[22]!==m||e[23]!==p||e[24]!==_||e[25]!==d||e[26]!==N||e[27]!==o||e[28]!==P||e[29]!==S||e[30]!==a||e[31]!==v||e[32]!==g||e[33]!==D||e[34]!==u||e[35]!==R){const M=D===void 0?[]:D,K=`${o}/${a}`;let F;e[37]!==K?(F=K.toLowerCase(),e[37]=K,e[38]=F):F=e[38];const H=F;let Y;e[39]!==H?(Y=$=>$.headRepoFullName?.toLowerCase()===H,e[39]=H,e[40]=Y):Y=e[40];const q=M.filter(Y);let te;if(e[41]!==N||e[42]!==S||e[43]!==R){const $=new Set;te=[...S,...R,...N].filter(De=>$.has(De.name)?!1:($.add(De.name),!0)),e[41]=N,e[42]=S,e[43]=R,e[44]=te}else te=e[44];const J=te;let Q;e[45]===Symbol.for("react.memo_cache_sentinel")?(Q=c.jsx(lc,{className:"h-4 w-4 shrink-0"}),e[45]=Q):Q=e[45];let W;e[46]!==g?(W=g("thread.branchPicker.advancedBack"),e[46]=g,e[47]=W):W=e[47];let G;e[48]!==p||e[49]!==W?(G=c.jsxs("button",{type:"button",onClick:p,className:"flex items-center gap-1.5 px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground",children:[Q,W]}),e[48]=p,e[49]=W,e[50]=G):G=e[50];let ee;e[51]!==d?(ee=$=>{d($),k("")},e[51]=d,e[52]=ee):ee=e[52];let ue;e[53]!==g?(ue=g("thread.branchPicker.branchesTab"),e[53]=g,e[54]=ue):ue=e[54];let ie;e[55]!==ue?(ie=c.jsx(Pi,{value:"branches",className:"h-6 px-2.5 text-xs",children:ue}),e[55]=ue,e[56]=ie):ie=e[56];let de;e[57]!==g?(de=g("thread.branchPicker.prsTab"),e[57]=g,e[58]=de):de=e[58];let z;e[59]!==de?(z=c.jsx(Pi,{value:"prs",className:"h-6 px-2.5 text-xs",children:de}),e[59]=de,e[60]=z):z=e[60];let ge;e[61]!==g?(ge=g("thread.branchPicker.localTab"),e[61]=g,e[62]=ge):ge=e[62];let fe;e[63]!==ge?(fe=c.jsx(Pi,{value:"local",className:"h-6 px-2.5 text-xs",children:ge}),e[63]=ge,e[64]=fe):fe=e[64];let Le;e[65]!==ie||e[66]!==z||e[67]!==fe?(Le=c.jsxs(za,{className:"h-auto w-fit justify-start gap-1 bg-accent p-1",variant:"pill",children:[ie,z,fe]}),e[65]=ie,e[66]=z,e[67]=fe,e[68]=Le):Le=e[68];let oe;e[69]!==ee||e[70]!==Le||e[71]!==u?(oe=c.jsx(Wa,{className:"px-2 pt-2 pb-1",value:u,onValueChange:ee,children:Le}),e[69]=ee,e[70]=Le,e[71]=u,e[72]=oe):oe=e[72],B=c.jsxs("div",{className:"flex flex-col",children:[G,oe,u==="local"?c.jsx(vd,{url:f,onSave:_}):c.jsxs(rc,{filter:u==="branches"?gd:void 0,children:[c.jsx(nc,{placeholder:g(u==="branches"?"thread.branchPicker.searchBranches":"thread.branchPicker.searchPullRequests"),value:v,onValueChange:k}),c.jsx(oc,{onScroll:$=>{const De=$.currentTarget;u==="branches"&&De.scrollHeight-De.scrollTop-De.clientHeight<48&&E()},children:u==="branches"?c.jsxs(c.Fragment,{children:[I&&c.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:g("thread.branchPicker.loadingMore")}),!I&&J.length===0&&c.jsx(so,{children:g("thread.branchPicker.noBranchesFound")}),J.length>0&&c.jsx(ro,{children:J.map($=>c.jsxs(no,{value:$.name,className:"cursor-pointer",onSelect:()=>m($.name,$.name),children:[c.jsx(Nh,{className:"mr-2 h-4 w-4 shrink-0"}),c.jsx("span",{className:"flex-1 truncate",children:$.name})]},$.name))}),L&&c.jsx("div",{className:"p-2",children:c.jsx(pe,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:y,onClick:E,children:g(y?"thread.branchPicker.loadingMore":"thread.branchPicker.loadMoreBranches")})})]}):c.jsxs(c.Fragment,{children:[P&&c.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:g("thread.branchPicker.loadingPullRequests")}),!P&&q.length===0&&c.jsx(so,{children:g("thread.branchPicker.noOpenPullRequests")}),q.length>0&&c.jsx(ro,{children:q.map($=>c.jsxs(no,{value:`#${$.number} ${$.title} ${$.head}`,className:"cursor-pointer",onSelect:()=>m($.head,_o($.title)),children:[c.jsx(ar,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground"}),c.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c.jsx("span",{className:"truncate",children:_o($.title)}),c.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["#",$.number," · ",$.head]})]})]},$.number))})]})})]})]}),e[17]=E,e[18]=L,e[19]=y,e[20]=I,e[21]=f,e[22]=m,e[23]=p,e[24]=_,e[25]=d,e[26]=N,e[27]=o,e[28]=P,e[29]=S,e[30]=a,e[31]=v,e[32]=g,e[33]=D,e[34]=u,e[35]=R,e[36]=B}else B=e[36];return B}function gd(t,e){return zr(t,e)?1:0}function vd(t){const e=U.c(39),{url:i,onSave:s}=t,r=Be(),[n,o]=X.useState(i??"");let a;e[0]!==n?(a=n.trim(),e[0]=n,e[1]=a):a=e[1];const h=a;let l;e[2]!==s||e[3]!==h?(l=()=>s(h?uc(h):null),e[2]=s,e[3]=h,e[4]=l):l=e[4];const u=l;let d;e[5]!==r?(d=r("thread.branchPicker.localHint"),e[5]=r,e[6]=d):d=e[6];let f;e[7]!==d?(f=c.jsx("p",{className:"text-xs text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let _;e[9]!==r?(_=r("thread.branchPicker.localUrlLabel"),e[9]=r,e[10]=_):_=e[10];let p;e[11]!==r?(p=r("thread.branchPicker.localUrlPlaceholder"),e[11]=r,e[12]=p):p=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=N=>o(N.target.value),e[13]=m):m=e[13];let g;e[14]!==u||e[15]!==h?(g=N=>{N.key==="Enter"&&h&&u()},e[14]=u,e[15]=h,e[16]=g):g=e[16];let v;e[17]!==_||e[18]!==p||e[19]!==g||e[20]!==n?(v=c.jsx("input",{type:"url",inputMode:"url","aria-label":_,placeholder:p,value:n,onChange:m,onKeyDown:g,className:"h-8 w-full rounded-md border bg-transparent px-2 text-sm outline-none focus:ring-1 focus:ring-ring"}),e[17]=_,e[18]=p,e[19]=g,e[20]=n,e[21]=v):v=e[21];let k;e[22]!==s||e[23]!==r||e[24]!==i?(k=i?c.jsx(pe,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:()=>s(null),children:r("thread.branchPicker.localTurnOff")}):c.jsx("span",{}),e[22]=s,e[23]=r,e[24]=i,e[25]=k):k=e[25];const b=!h;let w;e[26]!==r?(w=r("thread.branchPicker.save"),e[26]=r,e[27]=w):w=e[27];let C;e[28]!==u||e[29]!==b||e[30]!==w?(C=c.jsx(pe,{size:"sm",disabled:b,onClick:u,children:w}),e[28]=u,e[29]=b,e[30]=w,e[31]=C):C=e[31];let S;e[32]!==k||e[33]!==C?(S=c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[k,C]}),e[32]=k,e[33]=C,e[34]=S):S=e[34];let R;return e[35]!==S||e[36]!==f||e[37]!==v?(R=c.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[f,v,S]}),e[35]=S,e[36]=f,e[37]=v,e[38]=R):R=e[38],R}function bd(t){const e=U.c(17),{locked:i,placement:s,value:r,virtualMcpId:n,userLabel:o,baseBranch:a,onChange:h,onCreateBranch:l,onAdoptBranch:u,orgId:d,orgSlug:f,userId:_,target:p,owner:m,repo:g,sandboxMap:v}=t;let k;return e[0]!==a||e[1]!==i||e[2]!==u||e[3]!==h||e[4]!==l||e[5]!==d||e[6]!==f||e[7]!==m||e[8]!==s||e[9]!==g||e[10]!==v||e[11]!==p||e[12]!==_||e[13]!==o||e[14]!==r||e[15]!==n?(k=c.jsx(_d,{virtualMcpId:n,userLabel:o,value:r,baseBranch:a,orgId:d,orgSlug:f,userId:_,target:p,owner:m,repo:g,sandboxMap:v,onChange:h,onCreateBranch:l,onAdoptBranch:u,spawnsNewChat:i,placement:s}),e[0]=a,e[1]=i,e[2]=u,e[3]=h,e[4]=l,e[5]=d,e[6]=f,e[7]=m,e[8]=s,e[9]=g,e[10]=v,e[11]=p,e[12]=_,e[13]=o,e[14]=r,e[15]=n,e[16]=k):k=e[16],k}function Sd(t){const e=U.c(2),{branchPill:i}=t;if(!i)return null;let s;return e[0]!==i?(s=c.jsx(c.Fragment,{children:i}),e[0]=i,e[1]=s):s=e[1],s}function wd(t){const e=U.c(21),{virtualMcp:i,currentBranch:s}=t,r=ec(),n=Wi();let o;e[0]!==r?.messages||e[1]!==n?.isThreadLocked?(o=(r?.messages??[]).length>0||(n?.isThreadLocked??!1),e[0]=r?.messages,e[1]=n?.isThreadLocked,e[2]=o):o=e[2];const a=o,h=n?.setCurrentTaskBranch,l=n?.createTask;let u;e[3]!==n?.activeTask?.metadata||e[4]!==i?.metadata?(u=fc(i?.metadata)==="cms"&&_c(n?.activeTask?.metadata,i?.metadata)==="sandbox",e[3]=n?.activeTask?.metadata,e[4]=i?.metadata,e[5]=u):u=e[5];const d=u,f=Sc(i),_=Bt(f),{data:p}=sr.useSession(),m=p?.user;let g;e[6]!==m?(g=On(m),e[6]=m,e[7]=g):g=e[7];const v=g,k=p?.user?.id??"",{org:b}=rr(),w=kc(i,s);let C;e[8]!==l||e[9]!==a||e[10]!==h?(C=x=>{a&&l?l({branch:x}):h&&h(x)},e[8]=l,e[9]=a,e[10]=h,e[11]=C):C=e[11];const S=C;let R;e[12]!==d||e[13]!==l||e[14]!==a||e[15]!==h?(R=x=>{(a||d)&&l?l({branch:x}):h&&h(x)},e[12]=d,e[13]=l,e[14]=a,e[15]=h,e[16]=R):R=e[16];const N=R;let I;e[17]!==l?(I=l?x=>l({runtime:"sandbox",branch:x}):void 0,e[17]=l,e[18]=I):I=e[18];const L=I,y=f&&Ga(_)?c.jsx(bd,{userLabel:v,virtualMcpId:i?.id??"",value:s,baseBranch:w,orgId:b.id,orgSlug:b.slug,userId:k,target:_,owner:f.owner,repo:f.name,sandboxMap:i?.metadata?.sandboxMap,onChange:S,onCreateBranch:N,onAdoptBranch:L,locked:a,placement:"chat"},`${Xa(_)}:${f.owner}/${f.name}`):null;let E;return e[19]!==y?(E=c.jsx(Sd,{branchPill:y}),e[19]=y,e[20]=E):E=e[20],E}const yd=Oh("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function xd(t){const e=U.c(11);let i,s,r;e[0]!==t?({className:i,orientation:s,...r}=t,e[0]=t,e[1]=i,e[2]=s,e[3]=r):(i=e[1],s=e[2],r=e[3]);let n;e[4]!==i||e[5]!==s?(n=le(yd({orientation:s}),i),e[4]=i,e[5]=s,e[6]=n):n=e[6];let o;return e[7]!==s||e[8]!==r||e[9]!==n?(o=c.jsx("div",{role:"group","data-slot":"button-group","data-orientation":s,className:n,...r}),e[7]=s,e[8]=r,e[9]=n,e[10]=o):o=e[10],o}function Cd(t){const e=U.c(14),{item:i}=t;let s;e[0]!==i?(s=()=>{i.onSelect()},e[0]=i,e[1]=s):s=e[1];let r;e[2]!==i.disabled||e[3]!==i.icon||e[4]!==i.label||e[5]!==s?(r=c.jsxs(Ai,{disabled:i.disabled,onSelect:s,children:[i.icon,i.label]}),e[2]=i.disabled,e[3]=i.icon,e[4]=i.label,e[5]=s,e[6]=r):r=e[6];const n=r;if(!i.tooltip)return n;let o;e[7]!==n?(o=c.jsx(St,{asChild:!0,children:n}),e[7]=n,e[8]=o):o=e[8];let a;e[9]!==i.tooltip?(a=c.jsx(wt,{side:"right",children:i.tooltip}),e[9]=i.tooltip,e[10]=a):a=e[10];let h;return e[11]!==o||e[12]!==a?(h=c.jsxs(bt,{children:[o,a]}),e[11]=o,e[12]=a,e[13]=h):h=e[13],h}function Sl(t){const e=U.c(20),{label:i,onClick:s,variant:r,size:n,disabled:o,loading:a,pulse:h,tooltip:l,icon:u,items:d,menuAriaLabel:f,className:_}=t,p=r===void 0?"default":r,m=n===void 0?"default":n,g=o===void 0?!1:o,v=a===void 0?!1:a,k=h===void 0?!1:h,b=(d?.length??0)>0;let w;if(e[0]!==_||e[1]!==g||e[2]!==b||e[3]!==u||e[4]!==d||e[5]!==i||e[6]!==v||e[7]!==f||e[8]!==s||e[9]!==k||e[10]!==m||e[11]!==l||e[12]!==p){const C=le(Ba,p==="default"&&"focus-visible:inset-ring-current");let S;e[14]!==u||e[15]!==v?(S=v?c.jsx(rs,{size:"xs"}):u,e[14]=u,e[15]=v,e[16]=S):S=e[16];const R=c.jsxs(pe,{type:"button",variant:p,size:m,disabled:g,"aria-busy":v||void 0,onClick:v?void 0:s,className:le(C,b&&"rounded-r-none border-r border-current/20"),children:[S,i]}),N=k&&"animate-pulse-brightness motion-reduce:animate-none motion-reduce:opacity-80";let I;e[17]!==_||e[18]!==N?(I=le(N,_),e[17]=_,e[18]=N,e[19]=I):I=e[19],w=c.jsxs(xd,{className:I,children:[l?c.jsxs(bt,{children:[c.jsx(St,{asChild:!0,children:c.jsx("span",{className:le("inline-flex rounded-lg outline-none",C,g&&"cursor-not-allowed"),tabIndex:g?0:void 0,role:g?"button":void 0,"aria-disabled":g||void 0,children:R})}),c.jsx(wt,{children:l})]}):R,b?c.jsxs(us,{children:[c.jsx(cs,{asChild:!0,children:c.jsx(pe,{type:"button",variant:p,size:m,"aria-label":f,className:le("has-[>svg]:px-2",C),children:c.jsx(or,{className:"size-3.5"})})}),c.jsx(ds,{align:"end",children:d?.map(kd)})]}):null]}),e[0]=_,e[1]=g,e[2]=b,e[3]=u,e[4]=d,e[5]=i,e[6]=v,e[7]=f,e[8]=s,e[9]=k,e[10]=m,e[11]=l,e[12]=p,e[13]=w}else w=e[13];return w}function kd(t){return c.jsx(Cd,{item:t},t.key)}function wl(t){return ur({userName:t?.name,userEmail:t?.email})??void 0}function Fn(t){const e=U.c(18),{state:i,header:s,body:r,note:n,gate:o,footer:a}=t,h=i!=="ready";let l;e[0]!==s?(l=c.jsx("div",{className:"space-y-0.5 px-4 py-3",children:s}),e[0]=s,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx("div",{className:"border-t"}),e[2]=u):u=e[2];let d;e[3]!==n?(d=n?c.jsx("div",{className:"space-y-1.5 border-t px-4 py-3",children:n}):null,e[3]=n,e[4]=d):d=e[4];let f;e[5]!==r||e[6]!==d?(f=c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r,d]}),e[5]=r,e[6]=d,e[7]=f):f=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsx("div",{className:"border-t"}),e[8]=_):_=e[8];let p;e[9]!==a?(p=c.jsx("div",{className:"space-y-2 px-4 py-3",children:a}),e[9]=a,e[10]=p):p=e[10];let m;return e[11]!==o||e[12]!==i||e[13]!==h||e[14]!==l||e[15]!==f||e[16]!==p?(m=c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-publish-state":i,"aria-busy":h,children:[l,u,f,o,_,p]}),e[11]=o,e[12]=i,e[13]=h,e[14]=l,e[15]=f,e[16]=p,e[17]=m):m=e[17],m}function Wr(t){const e=U.c(2),{children:i}=t;let s;return e[0]!==i?(s=c.jsx("div",{className:"scroll-fade min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 pt-3 pb-2 [scrollbar-width:thin]",children:i}),e[0]=i,e[1]=s):s=e[1],s}function yl(t){const e=U.c(10);let i,s,r;e[0]!==t?({className:s,children:i,...r}=t,e[0]=t,e[1]=i,e[2]=s,e[3]=r):(i=e[1],s=e[2],r=e[3]);let n;e[4]!==s?(n=le("rounded-lg border bg-card px-3 py-2.5",s),e[4]=s,e[5]=n):n=e[5];let o;return e[6]!==i||e[7]!==r||e[8]!==n?(o=c.jsx("div",{className:n,...r,children:i}),e[6]=i,e[7]=r,e[8]=n,e[9]=o):o=e[9],o}function ti(t){const e=U.c(4),{className:i}=t;let s;e[0]!==i?(s=le("animate-pulse rounded bg-muted motion-reduce:animate-none",i),e[0]=i,e[1]=s):s=e[1];let r;return e[2]!==s?(r=c.jsx("div",{className:s}),e[2]=s,e[3]=r):r=e[3],r}function is(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(yl,{children:c.jsxs("div",{className:"flex items-center gap-2.5",children:[c.jsx(ti,{className:"size-4 rounded-md"}),c.jsx(ti,{className:"h-3 w-24"}),c.jsx(ti,{className:"h-2.5 w-16"}),c.jsx(ti,{className:"ml-auto size-6 rounded"})]})}),t[0]=e):e=t[0],e}async function Ed(t,e,i){const s=ur(i.coAuthor),{changeRequest:r}=await Tn(t,"CHANGE_REQUEST_OPEN",{...e,head:i.branch,base:i.base,title:i.title,body:rd(i.body,s)||void 0});return{number:r.number,htmlUrl:r.url}}class xl extends Error{reason;detail;constructor(e,i){super(i||`Merge refused: ${e}`),this.name="ChangeRequestMergeRefused",this.reason=e,this.detail=i}}async function Cl(t,e,i){const s=ur(i.coAuthor),r=s?bl(i.commitMessage?.trim()??"",s):i.commitMessage?.trim()||void 0,n=await Tn(t,"CHANGE_REQUEST_MERGE",{...e,number:i.number,strategy:"squash",commitTitle:i.commitTitle,commitMessage:r});if(!n.merged)throw new xl(n.reason??"error",n.detail)}function Pd(t,e){switch(t){case"conflict":return e("thread.mergeRefused.conflict");case"blocked":return e("thread.mergeRefused.blocked");case"rate_limited":return e("thread.mergeRefused.rateLimited");case"not_found":return e("thread.mergeRefused.notFound");default:return e("thread.mergeRefused.error")}}class $r extends Error{constructor(){super("The branch changed since these changes were shown"),this.name="PublishHeadMovedError"}}class zn extends Error{constructor(e,i,s){super(e),this.step=i,this.pr=s,this.name="PublishStepError"}step;pr}const qs=255;function kl(t){if(t.length<=qs)return t;const e=t.slice(0,qs-1),i=e.lastIndexOf(" ");return`${(i>0?e.slice(0,i):e).trimEnd()}…`}function Rd(t){const e=t.title.trim(),i=t.body.trim(),s=[e,i].filter(Boolean).join(`
6
6
 
7
7
  `);if(e.length>qs)return{title:kl(e),body:s,message:s};const r=e||t.fallbackTitle;return{title:r,body:i||void 0,message:s||r}}function Bd(t,e){const i=t.trim().split(`
8
8
  `);return Rd({title:i[0]??"",body:i.slice(1).join(`
9
- `),fallbackTitle:e})}function Vs(t){return{orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch,threadId:t.threadId}}function Dd(t){return t.fastPreview?{fastPreview:!0}:void 0}async function yr(t,e,i){try{return await i()}catch(s){throw new zn(s instanceof Error?s.message:e,t)}}async function El(t){const{expectedHeadSha:e,expectedDiffSignature:i}=t;if(!e&&!i)return;const s=await jn(Vs(t)).catch(()=>null);if(!s)return;if(e&&s.headSha&&s.headSha!==e)throw new $r;if(!i)return;const r=await ll(Vs(t),s,t.baseBranch,Dd(t)).catch(()=>null);if(r&&Hn(r)!==i)throw new $r}function Pl(t,e){return Tc(Vs(t),e)}function Rl(t,e){return Ed(t.orgSlug,t.target,{branch:t.headBranch,title:e.title,body:e.body,base:t.baseBranch,coAuthor:t.coAuthor})}async function Ad(t,e,i){await El(t),await yr("push",i("thread.publishDialog.failedPushChanges"),()=>Pl(t,e.message)),await yr("sync",i("thread.publishDialog.failedRebase"),()=>hl(Vs(t),t.baseBranch));const s=await yr("open-pr",i("thread.publishDialog.failedOpenPullRequest"),()=>Rl(t,e));try{await Cl(t.orgSlug,t.target,{number:s.number,commitTitle:e.title,commitMessage:e.body,coAuthor:t.coAuthor})}catch(r){throw new zn(r instanceof Error?r.message:i("thread.publishDialog.failedMergePullRequest"),"merge",s)}return s}async function Td(t,e){return await El(t),await Pl(t,e.message),Rl(t,e)}function Md(t,e){return t instanceof $r?{message:e("thread.publishPopover.branchMoved"),pullRequest:null,headMoved:!0}:t instanceof zn&&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 go(t,e){const i=Md(t,e),s=i.pullRequest;return s&&Xe.error(i.message,{action:{label:e("thread.publishDialog.viewPr"),onClick:()=>window.open(s.htmlUrl,"_blank","noopener,noreferrer")}}),{message:i.message,pullRequestOpened:s!==null,headMoved:i.headMoved}}function Ld(t,e){Xe.success(e("thread.publishDialog.submittedForReview",{prNumber:t.number}),{action:{label:e("thread.publishDialog.viewOnProvider"),onClick:()=>window.open(t.htmlUrl,"_blank","noopener,noreferrer")}})}const Nd=/(?:^|\/)\.deco\/blocks\/([^/]+)\.json$/;function Bl(t){const e=Nd.exec(t)?.[1];return e?Wc(e):null}function Ys(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 Od(t,e){return t===null?"new":e===null?"removed":"edited"}function Dl(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,i=>i.toLowerCase()):t}function xr(t,e){if(t&&typeof t=="object"&&!Array.isArray(t)){const i=t.__resolveType;if(typeof i=="string"&&i.trim()){const r=(i.split("/").pop()??i).replace(/\.[jt]sx?$/,"");return Dl(r)||r}}return`Section ${e+1}`}function Ur(t){const e=t.sections;if(Array.isArray(e))return e.flatMap((i,s)=>i&&typeof i=="object"&&!Array.isArray(i)?[{section:i,basePath:["sections",s]}]:[]);if(e&&typeof e=="object"){const i=e.variants;if(Array.isArray(i))return i.flatMap((s,r)=>{const n=s&&typeof s=="object"&&!Array.isArray(s)?s.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 vo(t){return JSON.stringify(t,(e,i)=>{if(i&&typeof i=="object"&&!Array.isArray(i)){const s=i;return Object.keys(s).sort().reduce((r,n)=>(r[n]=s[n],r),{})}return i})}function Al(t,e){return t===void 0&&e===void 0?!0:vo(t)===vo(e)}function Gs(t,e,i,s=new Set){const r=new Set([...Object.keys(t??{}),...Object.keys(e??{})]),n=[];for(const o of r){if(o.startsWith("__")||s.has(o))continue;const a=t?t[o]:void 0,h=e?e[o]:void 0;Al(a,h)||n.push({label:Dl(o),path:[...i,o],from:a,to:h})}return n}const Id=new Set(["sections"]);function Tl(t,e){const i=t?Ur(t):[],s=e?Ur(e):[],r=[],n=Math.max(i.length,s.length);for(let a=0;a<n;a++){const h=i[a],l=s[a];if(h&&l){if(Al(h.section,l.section))continue;r.push({name:xr(l.section,a),kind:"section",status:"edited",fields:Gs(h.section,l.section,l.basePath)})}else l?r.push({name:xr(l.section,a),kind:"section",status:"new",fields:[]}):h&&r.push({name:xr(h.section,a),kind:"section",status:"removed",fields:[]})}const o=Gs(t,e,[],Id);return o.length>0&&r.push({name:"Page settings",kind:"settings",status:"edited",fields:o}),r}function Kr(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 jd(t){const e=[],i=[],s=[],r=[];for(const[n,o]of Object.entries(t?.diffs??{})){if(cl(n)){r.push(n);continue}const a=Od(o.from,o.to),h=Bl(n);if(!h){s.push(Kr(n,a));continue}const l=Ys(o.from),u=Ys(o.to),d=u??l;if(!d){s.push(Kr(n,a));continue}const f=Hr(h,d);if(f){e.push({kind:"page",blockKey:h,name:f.name,pagePath:f.path,isSiteApp:!1,status:a,filepaths:[n],sections:a==="edited"?Tl(l,u):[],fromJson:l,toJson:u});continue}const _=Va(h,d);i.push({kind:"block",blockKey:h,name:Fr(h,d),pagePath:null,isSiteApp:_,status:a,filepaths:[n],sections:a==="edited"?[{name:Fr(h,d),kind:"section",status:"edited",fields:Gs(l,u,[])}].filter(p=>p.fields.length>0):[],fromJson:l,toJson:u})}return Ml({pages:e,blocks:i,other:s,generated:r})}function Cr(t,e){return(t.filepaths[0]??"").localeCompare(e.filepaths[0]??"")}function Ml(t){const{pages:e,blocks:i,other:s,generated:r}=t;return e.sort(Cr),i.sort(Cr),s.sort(Cr),{pages:e,blocks:i,other:s,generated:r,count:e.length+i.length+s.length}}function Hd(t){return t==="added"?"new":t==="removed"?"removed":"edited"}function Fd(t){return t.startsWith("pages-")}function Ll(t){const{files:e,lookup:i,diff:s}=t,r=[],n=[],o=[],a=[];for(const h of e){const l=h.path;if(cl(l)){a.push(l);continue}const u=Hd(h.status),d=Bl(l);if(!d){o.push(Kr(l,u));continue}const f=s?.diffs[l],_=Ys(f?.from??null),p=Ys(f?.to??null),m=zd(i,d),g=m??p??_;if((m?Hr(d,m):null)??(!m&&Fd(d))){const b=g?Hr(d,g):null;r.push({kind:"page",blockKey:d,name:b?.name??cc(d),pagePath:b?.path??null,isSiteApp:!1,status:u,filepaths:[l],sections:u==="edited"?Tl(_,p):[],fromJson:_,toJson:p??(u==="new"?m:null)});continue}const k=Fr(d,g??{});n.push({kind:"block",blockKey:d,name:k,pagePath:null,isSiteApp:Va(d,m??{}),status:u,filepaths:[l],sections:u==="edited"?[{name:k,kind:"section",status:"edited",fields:Gs(_,p,[])}].filter(b=>b.fields.length>0):[],fromJson:_,toJson:p})}return Ml({pages:r,blocks:n,other:o,generated:a})}function zd(t,e){const i=t?.[e];return i&&typeof i=="object"&&!Array.isArray(i)?i:null}function Wd(t,e){return t??e}function Nl(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}const kr=3;function Bs(t){if(t.length<=kr)return Nl(t);const e=t.length-kr;return`${t.slice(0,kr).join(", ")} and ${e} more`}function $d(t){const e=t.sections.filter(i=>i.kind==="section").map(i=>i.name).slice(0,3);return e.length>0?`${t.name} (${e.join(", ")})`:t.name}function Ud(t){const e=[],i=t.pages.filter(a=>a.status==="edited"),s=t.pages.filter(a=>a.status==="new"),r=t.pages.filter(a=>a.status==="removed");if(i.length>0&&e.push(`updated ${Bs(i.map($d))}`),s.length>0){const a=s.length===1?"page":"pages";e.push(`added the ${Bs(s.map(h=>h.name))} ${a}`)}if(r.length>0){const a=r.length===1?"page":"pages";e.push(`removed the ${Bs(r.map(h=>h.name))} ${a}`)}const n=t.blocks.map(a=>a.name);if(n.length>0&&e.push(`changed ${Bs(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=Nl(e);return kl(o.charAt(0).toUpperCase()+o.slice(1))}function Kd(t){return t?Ur(t).length:0}function qd(t){const e={newPageSections:t.kind==="page"&&t.status==="new"?Kd(t.toJson):null,sections:0,settings:!1,fields:0};if(e.newPageSections!==null)return e;for(const i of t.sections){if(i.kind==="settings"){e.settings=!0;continue}t.kind==="page"?e.sections+=1:e.fields+=i.fields.length}return e}function Qt(t){return t.filepaths[0]??t.blockKey??t.name}function Vd(t,e){return e(t==="new"?"thread.publishPopover.chipNew":t==="removed"?"thread.publishPopover.chipRemoved":"thread.publishPopover.chipEdited")}function Yd(t,e){const i=t.kind==="block"?Bc:$a;return c.jsx("span",{title:Vd(t.status,e),className:"flex shrink-0",children:c.jsx(i,{className:le("size-4",t.status==="new"&&"text-brand",t.status==="edited"&&"text-warning",t.status==="removed"&&"text-destructive")})})}function Gd(t,e){return t.kind==="page"?t.pagePath:t.kind!=="block"?null:t.isSiteApp?e("thread.publishPopover.siteConfiguration"):e("thread.publishPopover.globalSection")}function Xd(t,e){const i=qd(t);if(i.newPageSections!==null)return[i.newPageSections===1?e("thread.publishPopover.newPageSectionOne"):e("thread.publishPopover.newPageSections",{count:i.newPageSections})];const s=[];return i.sections===1?s.push(e("thread.publishPopover.sectionChangedOne")):i.sections>1&&s.push(e("thread.publishPopover.sectionsChanged",{count:i.sections})),i.fields===1?s.push(e("thread.publishPopover.fieldChangedOne")):i.fields>1&&s.push(e("thread.publishPopover.fieldsChanged",{count:i.fields})),i.settings&&s.push(e("thread.publishPopover.pageSettingsChanged")),s}function Jd(t){const e=U.c(41),{change:i,bodyPending:s,selected:r,onSelect:n,confirming:o,onConfirmingChange:a,onDiscard:h,isPublishing:l,isDiscarding:u}=t,d=s===void 0?!1:s,f=Be();let _;e[0]!==i||e[1]!==f?(_=Gd(i,f),e[0]=i,e[1]=f,e[2]=_):_=e[2];const p=_;let m;if(e[3]!==d||e[4]!==i||e[5]!==o||e[6]!==p||e[7]!==u||e[8]!==l||e[9]!==a||e[10]!==h||e[11]!==n||e[12]!==r||e[13]!==f){const g=Xd(i,f),v=d&&g.length===0&&i.status==="edited",k=r&&"border-foreground/30 bg-accent hover:bg-accent";let b;e[15]!==k?(b=le("cursor-pointer transition-colors hover:bg-accent/50",k),e[15]=k,e[16]=b):b=e[16];let w;e[17]!==i?(w=Qt(i),e[17]=i,e[18]=w):w=e[18];let C;e[19]!==i||e[20]!==f?(C=Yd(i,f),e[19]=i,e[20]=f,e[21]=C):C=e[21];let S;e[22]!==i.name?(S=c.jsx("span",{className:"truncate text-sm font-medium",children:i.name}),e[22]=i.name,e[23]=S):S=e[23];let R;e[24]!==p?(R=p?c.jsx("span",{className:"truncate text-xs text-muted-foreground",children:p}):null,e[24]=p,e[25]=R):R=e[25];let N;e[26]!==r||e[27]!==S||e[28]!==R?(N=c.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left","aria-pressed":r,children:[S,R]}),e[26]=r,e[27]=S,e[28]=R,e[29]=N):N=e[29];let I;e[30]!==o||e[31]!==u||e[32]!==l||e[33]!==a||e[34]!==h||e[35]!==f?(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:y=>{y.stopPropagation(),a(!1)},children:f("thread.publishDialog.cancel")}),c.jsx("button",{type:"button",className:"text-xs font-medium text-destructive disabled:opacity-50",onClick:y=>{y.stopPropagation(),a(!1),h?.()},disabled:u,children:f("thread.publishPopover.discard")})]}):h?c.jsx(nr,{children:c.jsxs(bt,{children:[c.jsx(St,{asChild:!0,children:c.jsx("button",{type:"button","aria-label":f("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:y=>{y.stopPropagation(),a(!0)},disabled:l||u,children:c.jsx(lr,{className:"size-3.5"})})}),c.jsx(wt,{children:f("thread.publishPopover.discard")})]})}):null,e[30]=o,e[31]=u,e[32]=l,e[33]=a,e[34]=h,e[35]=f,e[36]=I):I=e[36];let L;e[37]!==N||e[38]!==I||e[39]!==C?(L=c.jsxs("div",{className:"flex items-center gap-2.5",children:[C,N,I]}),e[37]=N,e[38]=I,e[39]=C,e[40]=L):L=e[40],m=c.jsxs(yl,{className:b,"data-change-id":w,onClick:n,children:[L,g.length>0?c.jsx("div",{className:"mt-1 space-y-0.5 pl-[26px] text-xs text-muted-foreground",children:g.map(Zd)}):v?c.jsx("div",{className:"mt-1 space-y-0.5 pl-[26px]",children:c.jsx(ti,{className:"h-4 w-2/3"})}):null]}),e[3]=d,e[4]=i,e[5]=o,e[6]=p,e[7]=u,e[8]=l,e[9]=a,e[10]=h,e[11]=n,e[12]=r,e[13]=f,e[14]=m}else m=e[14];return m}function Zd(t,e){return c.jsx("div",{className:"truncate",children:t},`${e}-${t}`)}function Qd(){const t=U.c(4);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={width:-1,height:-1},t[0]=e):e=t[0];const[i,s]=X.useState(e);let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=a=>{if(!a)return;const h=()=>s(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]!==i?(o=[i,n],t[2]=i,t[3]=o):o=t[3],o}function eu(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}const tu=[{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 bo(t){const e=U.c(10),{height:i}=t,s=Be();let r;e[0]!==i?(r={height:i},e[0]=i,e[1]=r):r=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=tu.map(iu),e[2]=n):n=e[2];let o;e[3]!==s?(o=s("thread.publishDialog.openingComparison"),e[3]=s,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 iu(t,e){return c.jsxs("div",{className:le("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:le("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:le("h-2 animate-pulse rounded-sm bg-muted",t.width,t.tone==="del"&&"bg-destructive/20",t.tone==="add"&&"bg-success/25")})]},e)}const Ol={readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12},su={...Ol,lineNumbersMinChars:3,lineDecorationsWidth:4,folding:!1,glyphMargin:!1,renderOverviewRuler:!1};function ru(t){const e=U.c(11),{diff:i,emptyMessage:s,rowClassName:r,onDiscardFile:n,hideFileRows:o,editorHeight:a}=t,h=s===void 0?"No file changes in the working tree":s,l=r===void 0?"px-6":r,u=o===void 0?!1:o,d=a===void 0?"380px":a,[f,_]=X.useState(null),[p,m]=X.useState(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=eu(),e[0]=g):g=e[0];const v=g;if(!i||Object.keys(i.diffs).length===0){let b;return e[1]!==h?(b=c.jsx("div",{className:"flex items-center justify-center py-10 text-sm text-muted-foreground",children:h}),e[1]=h,e[2]=b):b=e[2],b}let k;return e[3]!==i.diffs||e[4]!==p||e[5]!==d||e[6]!==f||e[7]!==u||e[8]!==n||e[9]!==l?(k=c.jsx("div",{className:"divide-y",children:Object.entries(i.diffs).map(b=>{const[w,C]=b,{from:S,to:R}=C,N=f===w,I=S===null,L=R===null,y=w.startsWith("/")?w.slice(1):w,E=y.lastIndexOf("/"),x=E>=0?y.slice(E+1):y,A=E>=0?y.slice(0,E):null,D=$c(w),P=I?"bg-success":L?"bg-destructive":"bg-warning";return u?c.jsx("div",{children:c.jsx(lo,{original:S??"",modified:R??"",language:D,theme:v,height:d,loading:c.jsx(bo,{height:d}),options:su})},w):c.jsxs("div",{children:[c.jsxs("div",{className:le("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:()=>_(N?null:w),children:c.jsx(Ea,{className:le("h-3.5 w-3.5 transition-transform",N&&"rotate-90")})}),c.jsx("div",{className:le("h-2.5 w-2.5 shrink-0 rounded-full",P)}),c.jsx($a,{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:x}),A&&c.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:A}),n?c.jsxs(us,{children:[c.jsx(cs,{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(Ih,{className:"h-3.5 w-3.5"})})}),c.jsx(ds,{align:"end",children:c.jsx(Ai,{className:"text-destructive focus:text-destructive",onSelect:()=>m(w),children:"Discard changes"})})]}):null]}),p===w&&n?c.jsxs("div",{className:le("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:x}),"? This cannot be undone."]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[c.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>m(null),children:"Cancel"}),c.jsx(pe,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:()=>{m(null),n(w)},children:"Discard"})]})]}):null,N&&c.jsx("div",{className:"border-t",children:c.jsx(lo,{original:S??"",modified:R??"",language:D,theme:v,height:d,loading:c.jsx(bo,{height:d}),options:Ol})})]},w)})}),e[3]=i.diffs,e[4]=p,e[5]=d,e[6]=f,e[7]=u,e[8]=n,e[9]=l,e[10]=k):k=e[10],k}function nu(t){if(t.kind!=="block"||t.isSiteApp||!t.blockKey)return null;const e=(t.toJson??t.fromJson)?.__resolveType;return typeof e=="string"&&dc(e)?t.blockKey:null}function ou(t){return t.kind!=="page"?!0:!t.pagePath||os(t.pagePath).length>0}function au(t,e){try{return Vc(t,uc,e)}catch{return null}}function lu(t,e){if(t.kind!=="page")return"/";const i=t.pagePath;if(!i)return"";if(os(i).length===0)return i;if(e?.path!==i)return"";const s=Ya(i,e.params);return os(s).length===0?s:""}function hu(t,e){const i=e.trim();if(!i||os(i).length>0)return null;try{const s=new URL(t),r=new URL(i.startsWith("/")?i:`/${i}`,s);return r.origin===s.origin?r:null}catch{return null}}function cu(t,e){if(!e)return null;if(e.kind==="pointer")return ml(t.toString(),e.pointer);try{return new URL(`${t.pathname}${t.search}`,e.previewUrl).href}catch{return null}}function du(t,e,i){return e===null?!1:t!=="other"||i?.kind==="sandbox"}const uu=["split","before","after","code"];function fu(t){return uu.includes(t)}const _u={desktop:1280,mobile:412};function pu(t){const e=U.c(90),{change:i,diff:s,bodyPending:r,previewServerUrl:n,draft:o,lastPage:a}=t,h=Be();let l;e[0]!==i.kind||e[1]!==o||e[2]!==n?(l=du(i.kind,n,o),e[0]=i.kind,e[1]=o,e[2]=n,e[3]=l):l=e[3];const u=l,[d,f]=X.useState(null),_=u?d??"split":"code",[p,m]=X.useState("desktop"),[g,v]=X.useState(null);let k,b,w,C,S,R;if(e[4]!==i||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==g){b=g??lu(i,a),C=nu(i);let ie;e[15]!==i?(ie=ou(i),e[15]=i,e[16]=ie):ie=e[16],w=ie,R=n?C?au(n,C):hu(n,b):null,k=R?ml(R.toString(),Yc):null,S=R?cu(R,o):null,e[4]=i,e[5]=o,e[6]=a,e[7]=n,e[8]=g,e[9]=k,e[10]=b,e[11]=w,e[12]=C,e[13]=S,e[14]=R}else k=e[9],b=e[10],w=e[11],C=e[12],S=e[13],R=e[14];const N=S;let I;if(e[17]!==i.filepaths||e[18]!==s?.diffs){let ie;e[20]!==s?.diffs?(ie=de=>{const z=s?.diffs[de];return z?[[de,z]]:[]},e[20]=s?.diffs,e[21]=ie):ie=e[21],I={diffs:Object.fromEntries(i.filepaths.flatMap(ie))},e[17]=i.filepaths,e[18]=s?.diffs,e[19]=I}else I=e[19];const L=I;let y;e[22]!==L.diffs?(y=Object.keys(L.diffs),e[22]=L.diffs,e[23]=y):y=e[23];const E=y.length>0;let x;e[24]!==i.kind||e[25]!==i.pagePath||e[26]!==C||e[27]!==h?(x=C!==null?null:i.kind!=="page"?h("thread.publishCompare.globalHint"):i.pagePath&&os(i.pagePath).length>0?h("thread.publishCompare.dynamicHint",{template:i.pagePath}):null,e[24]=i.kind,e[25]=i.pagePath,e[26]=C,e[27]=h,e[28]=x):x=e[28];const A=x;let D;e[29]!==k||e[30]!==i.kind||e[31]!==i.status||e[32]!==p||e[33]!==h?(D=i.status==="new"&&i.kind!=="other"?c.jsx(yo,{icon:c.jsx(Mn,{className:"size-5 text-brand"}),title:h("thread.publishCompare.newTitle"),description:h("thread.publishCompare.newDescription")}):c.jsx(xo,{url:k,device:p,title:h("thread.publishCompare.before"),missing:h("thread.publishCompare.enterPath")}),e[29]=k,e[30]=i.kind,e[31]=i.status,e[32]=p,e[33]=h,e[34]=D):D=e[34];const P=D;let B;e[35]!==N||e[36]!==i.kind||e[37]!==i.status||e[38]!==p||e[39]!==h||e[40]!==R?(B=i.status==="removed"&&i.kind!=="other"?c.jsx(yo,{icon:c.jsx(lr,{className:"size-5 text-destructive"}),title:h("thread.publishCompare.removedTitle"),description:h("thread.publishCompare.removedDescription")}):c.jsx(xo,{url:N,device:p,title:h("thread.publishCompare.after"),missing:h(R?"thread.publishCompare.draftUnavailable":"thread.publishCompare.enterPath")}),e[35]=N,e[36]=i.kind,e[37]=i.status,e[38]=p,e[39]=h,e[40]=R,e[41]=B):B=e[41];const M=B;let K;e[42]===Symbol.for("react.memo_cache_sentinel")?(K=ie=>{fu(ie)&&f(ie)},e[42]=K):K=e[42];let F;e[43]!==u||e[44]!==h?(F=u?c.jsxs(c.Fragment,{children:[c.jsx(Pi,{value:"split",className:"px-3 text-xs",children:h("thread.publishCompare.sideBySide")}),c.jsx(Pi,{value:"before",className:"px-3 text-xs",children:h("thread.publishCompare.before")}),c.jsx(Pi,{value:"after",className:"px-3 text-xs",children:h("thread.publishCompare.after")})]}):null,e[43]=u,e[44]=h,e[45]=F):F=e[45];let H;e[46]!==h?(H=h("thread.publishCompare.code"),e[46]=h,e[47]=H):H=e[47];let Y;e[48]!==H?(Y=c.jsx(Pi,{value:"code",className:"px-3 text-xs",children:H}),e[48]=H,e[49]=Y):Y=e[49];let q;e[50]!==Y||e[51]!==F?(q=c.jsxs(za,{className:"h-8 w-auto",variant:"pill",children:[F,Y]}),e[50]=Y,e[51]=F,e[52]=q):q=e[52];let te;e[53]!==q||e[54]!==_?(te=c.jsx(Wa,{value:_,onValueChange:K,children:q}),e[53]=q,e[54]=_,e[55]=te):te=e[55];let J;e[56]!==N||e[57]!==u||e[58]!==i.pagePath||e[59]!==p||e[60]!==b||e[61]!==w||e[62]!==C||e[63]!==h||e[64]!==_?(J=u&&_!=="code"?c.jsxs(c.Fragment,{children:[C?null:w?c.jsx(Uc,{value:b,onChange:ie=>v(ie.target.value),placeholder:i.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:b}),c.jsxs("div",{className:"flex items-center rounded-lg border p-0.5",children:[c.jsx(So,{active:p==="desktop",label:h("thread.publishCompare.desktop"),onClick:()=>m("desktop"),children:c.jsx(qc,{className:"size-3.5"})}),c.jsx(So,{active:p==="mobile",label:h("thread.publishCompare.mobile"),onClick:()=>m("mobile"),children:c.jsx(sc,{className:"size-3.5"})})]}),N?c.jsxs("a",{href:N,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(Kc,{className:"size-3.5"}),h("thread.publishCompare.openDraft")]}):null]}):null,e[56]=N,e[57]=u,e[58]=i.pagePath,e[59]=p,e[60]=b,e[61]=w,e[62]=C,e[63]=h,e[64]=_,e[65]=J):J=e[65];let Q;e[66]!==te||e[67]!==J?(Q=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:[te,J]}),e[66]=te,e[67]=J,e[68]=Q):Q=e[68];let W;e[69]!==u||e[70]!==A||e[71]!==_?(W=A&&u&&_!=="code"?c.jsx("p",{className:"border-b bg-background px-4 py-1.5 text-[11px] text-muted-foreground",children:A}):null,e[69]=u,e[70]=A,e[71]=_,e[72]=W):W=e[72];let G;e[73]!==r||e[74]!==E||e[75]!==L||e[76]!==h||e[77]!==_?(G=_==="code"?c.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto bg-background [scrollbar-width:thin]",children:E?c.jsx(ru,{diff:L,hideFileRows:!0,editorHeight:"70vh"}):r?c.jsx(ti,{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[73]=r,e[74]=E,e[75]=L,e[76]=h,e[77]=_,e[78]=G):G=e[78];let ee;e[79]!==M||e[80]!==P||e[81]!==u||e[82]!==h||e[83]!==_?(ee=u?c.jsxs("div",{className:le("flex min-h-0 flex-1 gap-3 p-3",_==="code"&&"hidden"),children:[c.jsx(wo,{label:h("thread.publishCompare.before"),hidden:_==="after",children:P}),c.jsx(wo,{label:h("thread.publishCompare.after"),highlight:!0,hidden:_==="before",children:M})]}):null,e[79]=M,e[80]=P,e[81]=u,e[82]=h,e[83]=_,e[84]=ee):ee=e[84];let ue;return e[85]!==Q||e[86]!==W||e[87]!==G||e[88]!==ee?(ue=c.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/40",children:[Q,W,G,ee]}),e[85]=Q,e[86]=W,e[87]=G,e[88]=ee,e[89]=ue):ue=e[89],ue}function So(t){const e=U.c(8),{active:i,label:s,onClick:r,children:n}=t,o=i&&"bg-accent text-foreground";let a;e[0]!==o?(a=le("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]!==i||e[3]!==n||e[4]!==s||e[5]!==r||e[6]!==a?(h=c.jsx("button",{type:"button","aria-label":s,"aria-pressed":i,title:s,onClick:r,className:a,children:n}),e[2]=i,e[3]=n,e[4]=s,e[5]=r,e[6]=a,e[7]=h):h=e[7],h}function wo(t){const e=U.c(18),{label:i,highlight:s,hidden:r,children:n}=t,o=s===void 0?!1:s,h=(r===void 0?!1:r)&&"hidden";let l;e[0]!==h?(l=le("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=le("size-1.5 rounded-full bg-muted-foreground/50",u),e[2]=u,e[3]=d):d=e[3];let f;e[4]!==d?(f=c.jsx("span",{className:d}),e[4]=d,e[5]=f):f=e[5];let _;e[6]!==i||e[7]!==f?(_=c.jsxs("div",{className:"flex items-center gap-1.5 px-0.5 text-[11px] font-medium tracking-wider text-muted-foreground uppercase",children:[f,i]}),e[6]=i,e[7]=f,e[8]=_):_=e[8];const p=o&&"border-brand/60";let m;e[9]!==p?(m=le("relative min-h-0 flex-1 overflow-hidden rounded-lg border bg-background",p),e[9]=p,e[10]=m):m=e[10];let g;e[11]!==n||e[12]!==m?(g=c.jsx("div",{className:m,children:n}),e[11]=n,e[12]=m,e[13]=g):g=e[13];let v;return e[14]!==g||e[15]!==l||e[16]!==_?(v=c.jsxs("div",{className:l,children:[_,g]}),e[14]=g,e[15]=l,e[16]=_,e[17]=v):v=e[17],v}function yo(t){const e=U.c(10),{icon:i,title:s,description:r}=t;let n;e[0]!==i?(n=c.jsx("div",{className:"mb-1",children:i}),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==s?(o=c.jsx("p",{className:"text-sm font-medium",children:s}),e[2]=s,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 xo(t){const e=U.c(24),{url:i,device:s,title:r,missing:n}=t,[o,a]=Qd(),[h,l]=X.useState(null);if(!i){let S;return e[0]!==n?(S=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]=S):S=e[1],S}let u;e[2]!==s||e[3]!==i?(u=wc(i,s),e[2]=s,e[3]=i,e[4]=u):u=e[4];const d=u,f=_u[s],_=o.width>0?Math.min(o.width/f,1):1,p=o.width>0?Math.max((o.width-f*_)/2,0):0;let m;e[5]!==d?(m=()=>l(d),e[5]=d,e[6]=m):m=e[6];const g=o.height>0?o.height/_:"100%",v=`scale(${_})`;let k;e[7]!==f||e[8]!==p||e[9]!==g||e[10]!==v?(k={left:p,width:f,height:g,transform:v,transformOrigin:"top left"},e[7]=f,e[8]=p,e[9]=g,e[10]=v,e[11]=k):k=e[11];let b;e[12]!==d||e[13]!==m||e[14]!==k||e[15]!==r?(b=c.jsx("iframe",{src:d,title:r,sandbox:"allow-scripts allow-same-origin",onLoad:m,className:"absolute top-0 border-0 bg-white",style:k},d),e[12]=d,e[13]=m,e[14]=k,e[15]=r,e[16]=b):b=e[16];let w;e[17]!==h||e[18]!==d?(w=h!==d?c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/60",children:c.jsx(rs,{className:"size-5 motion-reduce:animate-none"})}):null,e[17]=h,e[18]=d,e[19]=w):w=e[19];let C;return e[20]!==a||e[21]!==b||e[22]!==w?(C=c.jsxs("div",{ref:a,className:"absolute inset-0",children:[b,w]}),e[20]=a,e[21]=b,e[22]=w,e[23]=C):C=e[23],C}const mu=/^Co-authored-by:\s*([^<\r\n]+?)(?:\s*<[^>\r\n]*>)?\s*$/im;function gu(t){if(!t)return null;const e=mu.exec(t)?.[1]?.trim();return e||null}function vu(t){return/\[bot\]$/i.test(t)||/-bot$/i.test(t)}function bu(t){const e=gu(t.body);if(e)return e;const i=t.author.trim();return!i||vu(i)?null:i}function Su(t){const{mode:e,target:i,note:s,allPaths:r,destinationHost:n,publishLockRef:o,onOpenChange:a,refresh:h,onPullRequestChanged:l,onPublished:u}=t,d=Be(),[f,_]=X.useState(!1),[p,m]=X.useState(!1),[g,v]=X.useState(),k=()=>Bd(s,d("thread.publishDialog.changesFrom",{branch:i.headBranch})),b=async()=>{o.current=!0,_(!0),v(void 0);try{await Ad(i,k(),d),Xe.success(n?d("thread.publishPopover.publishedTo",{host:n}):d("thread.publishDialog.publishedTo",{baseBranch:i.baseBranch})),a(!1),await Promise.all([l?.(),u?.()])}catch(S){const R=go(S,d);v(R.message),R.pullRequestOpened&&await l?.(),R.headMoved&&await h()}finally{o.current=!1,_(!1)}},w=async()=>{o.current=!0,_(!0),v(void 0);try{const S=await Td(i,k());Ld(S,d),a(!1),await l?.()}catch(S){const R=go(S,d);v(R.message||d("thread.publishDialog.failedSubmitForReview")),R.headMoved&&await h()}finally{o.current=!1,_(!1)}},C=async(S,R)=>{m(!0);try{await Mc({orgSlug:i.orgSlug,virtualMcpId:i.virtualMcpId,branch:i.branch,threadId:i.threadId},S),Xe.success(R),await h()}catch(N){Xe.error(N instanceof Error?N.message:d("thread.publishPopover.failedDiscard"))}finally{m(!1)}};return{isPublishing:f,isDiscarding:p,publishError:g,submit:e==="review"?w:b,discardChange:S=>C(S.filepaths,d("thread.publishPopover.discarded",{name:S.name})),discardAll:async()=>{r.length!==0&&await C(r,d("thread.publishDialog.allChangesDiscarded"))}}}function wu(t,e,i,s,r,n){return["cms-publish-bodies",t,e,i,s,r,n]}const yu=6e4;function xu(t,e){return e?null:t.files.map(i=>`${i.index}${i.working_dir} ${i.path}`).sort().join(`
10
- `)}function Cu(t,e,i){const s=U.c(6);let r;s[0]!==i||s[1]!==t||s[2]!==e?(r=An.decofile(`${t}/${e}/${i}`),s[0]=i,s[1]=t,s[2]=e,s[3]=r):r=s[3];let n;s[4]!==r?(n={queryKey:r,queryFn:Hh},s[4]=r,s[5]=n):n=s[5];const{data:o}=zi(n);return o}function ku(t){const{orgSlug:e,virtualMcpId:i,branch:s,threadId:r,baseBranch:n,fastPreview:o,recoverSandbox:a}=t,h={orgSlug:e,virtualMcpId:i,branch:s,threadId:r},l=o?{fastPreview:!0}:void 0,u=X.useRef(null),d=async C=>{try{return await C()}catch(S){if(!a||!ul(S))throw S;return u.current??=a(),await u.current,C()}},f=jh({...dl(h),queryFn:()=>d(()=>jn(h))}),_=f.data,p=_.changedFiles??null,m=_.headSha??null,g=p?p.length>0:Lc(_)||Nc(_),v=zi({queryKey:wu(e,i,s,n,m,xu(_,o)),queryFn:()=>d(()=>ll(h,_,n,l)),enabled:g,staleTime:o?yu:0,gcTime:o?void 0:0,throwOnError:(C,S)=>!p&&S.state.data===void 0}),k=Cu(e,i,s),b=v.data??null,w=p?Ll({files:p,lookup:k,diff:b}):jd(b);return{status:_,summary:w,allPaths:p?p.map(C=>C.path):Object.keys(b?.diffs??{}),discardablePaths:o?null:new Set(_.files.map(C=>C.path)),changedFilesTotal:_.changedFilesTotal??w.count,changedFilesTruncated:_.changedFilesTruncated??!1,headSha:m,diff:b,bodiesPending:g&&v.isPending,bodiesFailed:v.isError,cardsPending:!p&&g&&v.isPending,refresh:()=>Promise.all([f.refetch(),o?null:v.refetch()])}}function Eu(t){return["smart-review-verdict",t.orgSlug,t.virtualMcpId,t.branch,t.threadId,t.fastPreview?"fast-preview-upstream":"sandbox",t.signature,t.language]}function Pu(t){const e=U.c(27),{orgSlug:i,virtualMcpId:s,branch:r,threadId:n,fastPreview:o,status:a,diff:h,enabled:l}=t,[u]=Fh(),{language:d}=u;let f,_,p;if(e[0]!==r||e[1]!==h||e[2]!==l||e[3]!==o||e[4]!==d||e[5]!==i||e[6]!==a||e[7]!==n||e[8]!==s){const C=h?Hn(h):"";f=l&&!!r&&!!a&&!!h&&C!=="",p=zi,_=Eu({orgSlug:i,virtualMcpId:s,branch:r,threadId:n,fastPreview:o,signature:C,language:d}),e[0]=r,e[1]=h,e[2]=l,e[3]=o,e[4]=d,e[5]=i,e[6]=a,e[7]=n,e[8]=s,e[9]=f,e[10]=_,e[11]=p}else f=e[9],_=e[10],p=e[11];let m;e[12]!==r||e[13]!==h||e[14]!==d||e[15]!==i||e[16]!==a||e[17]!==n||e[18]!==s?(m=()=>Oc({orgSlug:i,virtualMcpId:s,branch:r,threadId:n},{status:a,diff:h,language:d}),e[12]=r,e[13]=h,e[14]=d,e[15]=i,e[16]=a,e[17]=n,e[18]=s,e[19]=m):m=e[19];let g;e[20]!==f||e[21]!==_||e[22]!==m?(g={queryKey:_,queryFn:m,enabled:f,staleTime:1/0,gcTime:6e5,retry:Ru},e[20]=f,e[21]=_,e[22]=m,e[23]=g):g=e[23];const v=p(g),k=v.data??null,b=f&&v.isFetching&&!v.data;let w;return e[24]!==k||e[25]!==b?(w={verdict:k,loading:b},e[24]=k,e[25]=b,e[26]=w):w=e[26],w}function Ru(t,e){return!ul(e)&&t<1}function Bu(t){const e=U.c(30),{orgSlug:i,virtualMcpId:s,branch:r,threadId:n,fastPreview:o,status:a,diff:h,policy:l,judgeEnabled:u,paths:d}=t,f=u===void 0?!0:u,_=d===void 0?null:d;let p;e[0]!==h||e[1]!==f||e[2]!==l?(p=f&&Ic(h,l),e[0]=h,e[1]=f,e[2]=l,e[3]=p):p=e[3];const m=p;let g;e[4]!==r||e[5]!==h||e[6]!==o||e[7]!==m||e[8]!==i||e[9]!==a||e[10]!==n||e[11]!==s?(g={orgSlug:i,virtualMcpId:s,branch:r,threadId:n,fastPreview:o,status:a,diff:h,enabled:m},e[4]=r,e[5]=h,e[6]=o,e[7]=m,e[8]=i,e[9]=a,e[10]=n,e[11]=s,e[12]=g):g=e[12];const{verdict:v,loading:k}=Pu(g);if(!h&&_){let S;e[13]!==_||e[14]!==l?(S=jc(_,l),e[13]=_,e[14]=l,e[15]=S):S=e[15];let R;return e[16]!==S?(R={gate:S,ready:!1},e[16]=S,e[17]=R):R=e[17],R}if(!h){let S;return e[18]===Symbol.for("react.memo_cache_sentinel")?(S={gate:{allowed:!0,reason:null},ready:!1},e[18]=S):S=e[18],S}if(!m){let S;e[19]!==h||e[20]!==l?(S=Hc(h,l),e[19]=h,e[20]=l,e[21]=S):S=e[21];let R;return e[22]!==S?(R={gate:S,ready:!0},e[22]=S,e[23]=R):R=e[23],R}let b;e[24]!==k||e[25]!==v?(b=Fc(v,k),e[24]=k,e[25]=v,e[26]=b):b=e[26];const w=!k;let C;return e[27]!==b||e[28]!==w?(C={gate:b,ready:w},e[27]=b,e[28]=w,e[29]=C):C=e[29],C}function Il(t){const e=U.c(16),i=X.useRef(!1),s=Be();let r;e[0]!==t?(r=d=>{!d&&i.current||t.onOpenChange(d)},e[0]=t,e[1]=r):r=e[1];const n=r;let o;e[2]!==t.mode||e[3]!==s?(o=t.mode==="review"?s("thread.publishPopover.submitForReview"):s("thread.publishPopover.publish"),e[2]=t.mode,e[3]=s,e[4]=o):o=e[4];let a;e[5]!==o?(a=c.jsx(kc,{className:"sr-only",children:o}),e[5]=o,e[6]=a):a=e[6];let h;e[7]!==t?(h=t.open?c.jsx(Lu,{...t,publishLockRef:i}):null,e[7]=t,e[8]=h):h=e[8];let l;e[9]!==a||e[10]!==h?(l=c.jsxs(Ec,{"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(Cc,{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 Du(t){return["main","master"].includes(t.trim().toLowerCase())}const Au=4,Xs="flex h-[45%] min-h-0 min-w-0 shrink-0 md:h-auto md:flex-1";function Wn(t){const e=U.c(5),{list:i,pane:s}=t;let r;e[0]!==i?(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:i}),e[0]=i,e[1]=r):r=e[1];let n;return e[2]!==s||e[3]!==r?(n=c.jsxs(c.Fragment,{children:[s,r]}),e[2]=s,e[3]=r,e[4]=n):n=e[4],n}function jl(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx("div",{className:le(Xs,"bg-muted/40 p-3"),children:c.jsx(ti,{className:"h-full w-full rounded-lg"})}),t[0]=e):e=t[0],e}function $n(t){const e=U.c(11),{mode:i,title:s,subLine:r,trailing:n}=t,o=i==="review"?ar:rc;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]!==s||e[4]!==n?(h=c.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a,s,n]}),e[2]=a,e[3]=s,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 Un(t){const e=U.c(9),{draftPreviewUrl:i,t:s}=t;let r;e[0]!==i?(r=()=>{i&&window.open(i,"_blank","noopener,noreferrer")},e[0]=i,e[1]=r):r=e[1];const n=!i;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(al,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==s?(a=s("thread.publishPopover.preview"),e[3]=s,e[4]=a):a=e[4];let h;return e[5]!==r||e[6]!==n||e[7]!==a?(h=c.jsxs(pe,{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 Tu(t){const e=U.c(21),{mode:i,draftPreviewUrl:s}=t,r=Be();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=c.jsx(jl,{}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(ti,{className:"h-3.5 w-48"}),e[1]=o):o=e[1];let a;e[2]!==i?(a=c.jsx($n,{mode:i,title:o}),e[2]=i,e[3]=a):a=e[3];let h,l;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(Wr,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(is,{}),c.jsx(is,{}),c.jsx(is,{})]})}),l=c.jsxs(c.Fragment,{children:[c.jsx(ti,{className:"h-3 w-20"}),c.jsx(ti,{className:"h-14 w-full rounded-lg"})]}),e[4]=h,e[5]=l):(h=e[4],l=e[5]);let u;e[6]!==s||e[7]!==r?(u=c.jsx(Un,{draftPreviewUrl:s,t:r}),e[6]=s,e[7]=r,e[8]=u):u=e[8];const d=i==="review"?"default":"brand";let f;e[9]!==i||e[10]!==r?(f=r(i==="review"?"thread.publishPopover.submitForReview":"thread.publishPopover.publish"),e[9]=i,e[10]=r,e[11]=f):f=e[11];let _;e[12]!==d||e[13]!==f?(_=c.jsx(pe,{type:"button",variant:d,className:"flex-1",disabled:!0,children:f}),e[12]=d,e[13]=f,e[14]=_):_=e[14];let p;e[15]!==u||e[16]!==_?(p=c.jsxs("div",{className:"flex gap-2",children:[u,_]}),e[15]=u,e[16]=_,e[17]=p):p=e[17];let m;return e[18]!==p||e[19]!==a?(m=c.jsx(Wn,{pane:n,list:c.jsx(Fn,{state:"loading",header:a,body:h,note:l,footer:p})}),e[18]=p,e[19]=a,e[20]=m):m=e[20],m}function Mu(t){const e=U.c(26),{mode:i,draftPreviewUrl:s,message:r,onRetry:n}=t,o=Be();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx("div",{className:le(Xs,"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]!==i||e[6]!==l?(u=c.jsx($n,{mode:i,title:l}),e[5]=i,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 f;e[10]!==s||e[11]!==o?(f=c.jsx(Un,{draftPreviewUrl:s,t:o}),e[10]=s,e[11]=o,e[12]=f):f=e[12];let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsx(ns,{className:"size-4"}),e[13]=_):_=e[13];let p;e[14]!==o?(p=o("thread.publishPopover.retry"),e[14]=o,e[15]=p):p=e[15];let m;e[16]!==n||e[17]!==p?(m=c.jsxs(pe,{type:"button",variant:"outline",className:"flex-1",onClick:n,children:[_,p]}),e[16]=n,e[17]=p,e[18]=m):m=e[18];let g;e[19]!==f||e[20]!==m?(g=c.jsxs("div",{className:"flex gap-2",children:[f,m]}),e[19]=f,e[20]=m,e[21]=g):g=e[21];let v;return e[22]!==g||e[23]!==u||e[24]!==d?(v=c.jsx(Wn,{pane:a,list:c.jsx(Fn,{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 Lu(t){const e=U.c(3),i=t.mode??"publish";let s;return e[0]!==i||e[1]!==t?(s=c.jsx(zh,{children:r=>{const{reset:n}=r;return c.jsx(Wh,{fallback:o=>{const{error:a,resetError:h}=o;return c.jsx(Mu,{mode:i,draftPreviewUrl:t.draftPreviewUrl,message:a?.message??"",onRetry:()=>{n(),h()}})},children:c.jsx(X.Suspense,{fallback:c.jsx(Tu,{mode:i,draftPreviewUrl:t.draftPreviewUrl}),children:c.jsx(Nu,{...t})})})}}),e[0]=i,e[1]=t,e[2]=s):s=e[2],s}function Nu(t){const e=U.c(139),{publishLockRef:i,onOpenChange:s,mode:r,fastPreview:n,recoverSandbox:o,orgSlug:a,virtualMcpId:h,branch:l,baseBranch:u,repoTarget:d,owner:f,repo:_,publishPolicy:p,draftPreviewUrl:m,destinationHost:g,previewServerUrl:v,compareDraft:k,lastPublishedPr:b,onRequestApproval:w,openPullRequest:C,onPullRequestChanged:S,onPublished:R}=t,N=r===void 0?"publish":r,I=b===void 0?null:b,L=C===void 0?null:C,y=Be(),E=Wi()?.taskId??null,{data:x}=sr.useSession(),A=il(sl(a,h,l));let D;e[0]!==u||e[1]!==l||e[2]!==n||e[3]!==a||e[4]!==o||e[5]!==E||e[6]!==h?(D={orgSlug:a,virtualMcpId:h,branch:l,threadId:E,baseBranch:u,fastPreview:n,recoverSandbox:o},e[0]=u,e[1]=l,e[2]=n,e[3]=a,e[4]=o,e[5]=E,e[6]=h,e[7]=D):D=e[7];const{status:P,summary:B,allPaths:M,discardablePaths:K,changedFilesTotal:F,changedFilesTruncated:H,headSha:Y,diff:q,bodiesPending:te,bodiesFailed:J,cardsPending:Q,refresh:W}=ku(D),[G,ee]=X.useState(null),[ue,ie]=X.useState(!1),[de,z]=X.useState(null);let ge;e[8]===Symbol.for("react.memo_cache_sentinel")?(ge=[],e[8]=ge):ge=e[8];const[fe,Le]=X.useState(ge);let oe;e[9]===Symbol.for("react.memo_cache_sentinel")?(oe=ae=>{z(ae),Le(ve=>[ae,...ve.filter(Se=>Se!==ae)])},e[9]=oe):oe=e[9];const $=oe,[De,At]=X.useState(null);let Ye;e[10]!==G||e[11]!==B?(Ye=Wd(G,Ud(B)),e[10]=G,e[11]=B,e[12]=Ye):Ye=e[12];const He=Ye,it=[...B.pages,...B.blocks,...B.other],Ne=it.find(ae=>Qt(ae)===de)??it[0]??null,yt=Ne?Qt(Ne):null,Wt=[...new Set([...yt?[yt]:[],...fe,...it.map(Qt)])].filter(ae=>it.some(ve=>Qt(ve)===ae)).slice(0,Au),ce=N==="review",Ke=Q?"loading":te?"manifest":"ready",qe=!ce;let V;e[13]!==M||e[14]!==l||e[15]!==n||e[16]!==q||e[17]!==P||e[18]!==a||e[19]!==p||e[20]!==qe||e[21]!==E||e[22]!==h?(V={orgSlug:a,virtualMcpId:h,branch:l,threadId:E,fastPreview:n,status:P,diff:q,paths:M,policy:p,judgeEnabled:qe},e[13]=M,e[14]=l,e[15]=n,e[16]=q,e[17]=P,e[18]=a,e[19]=p,e[20]=qe,e[21]=E,e[22]=h,e[23]=V):V=e[23];const{gate:_e}=Bu(V),Ae=L?.state==="open";let ye;e[24]!==l||e[25]!==P?(ye=fl(P)??l,e[24]=l,e[25]=P,e[26]=ye):ye=e[26];const Je=x?.user;let nt;e[27]!==Je?(nt=wl(Je),e[27]=Je,e[28]=nt):nt=e[28];const xt=Y??void 0;let ot;e[29]!==n||e[30]!==q?(ot=!n&&q?{expectedDiffSignature:Hn(q)}:{},e[29]=n,e[30]=q,e[31]=ot):ot=e[31];let Tt;e[32]!==u||e[33]!==l||e[34]!==n||e[35]!==a||e[36]!==f||e[37]!==_||e[38]!==d||e[39]!==ye||e[40]!==nt||e[41]!==xt||e[42]!==ot||e[43]!==E||e[44]!==h?(Tt={orgSlug:a,virtualMcpId:h,branch:l,threadId:E,fastPreview:n,baseBranch:u,target:d,owner:f,repo:_,headBranch:ye,coAuthor:nt,expectedHeadSha:xt,...ot},e[32]=u,e[33]=l,e[34]=n,e[35]=a,e[36]=f,e[37]=_,e[38]=d,e[39]=ye,e[40]=nt,e[41]=xt,e[42]=ot,e[43]=E,e[44]=h,e[45]=Tt):Tt=e[45];const $t=Tt;let Mt;e[46]!==M||e[47]!==g||e[48]!==N||e[49]!==He||e[50]!==s||e[51]!==R||e[52]!==S||e[53]!==i||e[54]!==W||e[55]!==$t?(Mt={mode:N,target:$t,note:He,allPaths:M,destinationHost:g,publishLockRef:i,onOpenChange:s,refresh:W,onPullRequestChanged:S,onPublished:R},e[46]=M,e[47]=g,e[48]=N,e[49]=He,e[50]=s,e[51]=R,e[52]=S,e[53]=i,e[54]=W,e[55]=$t,e[56]=Mt):Mt=e[56];const{isPublishing:ke,isDiscarding:Ct,publishError:Lt,submit:Ut,discardChange:ni,discardAll:Kt}=Su(Mt);let Nt;e[57]!==K?(Nt=ae=>K===null||ae.every(ve=>K.has(ve)),e[57]=K,e[58]=Nt):Nt=e[58];const Ot=Nt,qt=!ke&&B.count>0&&(ce||_e.allowed);let It;e[59]!==u||e[60]!==ce||e[61]!==B.count||e[62]!==y?(It=ce?B.count===0?y("thread.publishPopover.submitForReview"):B.count===1?y("thread.publishPopover.submitOneForReview"):y("thread.publishPopover.submitCountForReview",{count:B.count}):B.count===0?y("thread.publishPopover.publish"):Du(u)?B.count===1?y("thread.publishPopover.publishOneInProduction"):y("thread.publishPopover.publishCountInProduction",{count:B.count}):B.count===1?y("thread.publishPopover.publishOne"):y("thread.publishPopover.publishCount",{count:B.count}),e[59]=u,e[60]=ce,e[61]=B.count,e[62]=y,e[63]=It):It=e[63];const Vt=It;let jt;e:{if(ce&&Ae){let Se;e[64]!==L.number||e[65]!==y?(Se=y("thread.publishPopover.updatesPullRequest",{number:L.number}),e[64]=L.number,e[65]=y,e[66]=Se):Se=e[66],jt=Se;break e}const ae=I;if(!ae?.mergedAt){jt=null;break e}let ve;if(e[67]!==ae||e[68]!==y){const Se=Rc(new Date(ae.mergedAt)),se=bu(ae);ve=se?y("thread.publishPopover.lastPublishedBy",{when:Se,name:se}):y("thread.publishPopover.lastPublished",{when:Se}),e[67]=ae,e[68]=y,e[69]=ve}else ve=e[69];jt=ve}const Yt=jt;let Ht;e[70]!==ce||e[71]!==B.count||e[72]!==y?(Ht=ce?y("thread.publishPopover.submitForReview"):B.count===1?y("thread.publishPopover.publishOne"):B.count>1?y("thread.publishPopover.publishCount",{count:B.count}):y("thread.publishPopover.publish"),e[70]=ce,e[71]=B.count,e[72]=y,e[73]=Ht):Ht=e[73];const fi=Ht,Gt=(ae,ve)=>ve.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:ae}),ve.map(Se=>{const se=Qt(Se);return c.jsx(Jd,{change:Se,bodyPending:te,selected:Ne!==null&&Qt(Ne)===se,onSelect:()=>$(se),confirming:De===se,onConfirmingChange:st=>At(st?se:null),onDiscard:Ot(Se.filepaths)?()=>{ni(Se)}:void 0,isPublishing:ke,isDiscarding:Ct},se)})]});let kt;e:{if(ce||B.count===0){kt=null;break e}if(_e.pending){let se;e[74]===Symbol.for("react.memo_cache_sentinel")?(se=c.jsx(rs,{className:"size-3.5 motion-reduce:animate-none"}),e[74]=se):se=e[74];let st;e[75]!==y?(st=y("thread.publishPopover.reviewing"),e[75]=y,e[76]=st):st=e[76];let Oi;e[77]!==st?(Oi=c.jsxs("div",{className:"flex items-center gap-2 border-t px-4 py-2.5 text-xs text-muted-foreground",children:[se,st]}),e[77]=st,e[78]=Oi):Oi=e[78],kt=Oi;break e}if(_e.allowed){kt=null;break e}let ae;e[79]===Symbol.for("react.memo_cache_sentinel")?(ae=c.jsx(Pa,{className:"mt-0.5 size-3.5 shrink-0"}),e[79]=ae):ae=e[79];let ve;e[80]!==_e.reason||e[81]!==y?(ve=_e.reason??y("thread.publishPopover.needsReviewGeneric"),e[80]=_e.reason,e[81]=y,e[82]=ve):ve=e[82];let Se;e[83]!==ve?(Se=c.jsxs("div",{className:"flex items-start gap-2 border-t px-4 py-2.5 text-xs text-warning",children:[ae,c.jsx("span",{children:ve})]}),e[83]=ve,e[84]=Se):Se=e[84],kt=Se}const Xt=kt;let oi;e[85]!==M||e[86]!==Ot||e[87]!==H||e[88]!==Kt||e[89]!==ue||e[90]!==Ct||e[91]!==ke||e[92]!==B.count||e[93]!==y?(oi=B.count<=1||H||!Ot(M)?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:()=>ie(!0),disabled:ke||Ct,children:y("thread.publishPopover.discardAll")}),c.jsx(Fa,{open:ue,onOpenChange:ie,children:c.jsxs(Ha,{children:[c.jsxs(Na,{children:[c.jsx(Ma,{children:y("thread.publishPopover.discardAllTitle")}),c.jsx(La,{children:y("thread.publishPopover.discardAllConfirm")})]}),c.jsxs(ja,{children:[c.jsx(Oa,{children:y("thread.publishDialog.cancel")}),c.jsx(Ia,{onClick:()=>{Kt()},disabled:Ct,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:y("thread.publishPopover.discardAll")})]})]})})]}),e[85]=M,e[86]=Ot,e[87]=H,e[88]=Kt,e[89]=ue,e[90]=Ct,e[91]=ke,e[92]=B.count,e[93]=y,e[94]=oi):oi=e[94];const wi=oi,yi=Q?c.jsx(Wr,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(is,{}),c.jsx(is,{})]})}):B.count===0?c.jsxs("div",{className:"flex flex-col items-center gap-1 py-10 text-center",children:[c.jsx(ol,{className:"mb-1 size-5 text-success"}),c.jsx("p",{className:"text-sm font-medium",children:y(ce?"thread.publishPopover.nothingToSubmit":"thread.publishPopover.everythingLive")}),c.jsx("p",{className:"text-xs text-muted-foreground",children:y(ce?"thread.publishPopover.submitEmptyHint":"thread.publishPopover.emptyHint")})]}):c.jsxs(Wr,{children:[H?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.showingFirst",{shown:B.count,total:F})}):null,Gt(y("thread.publishPopover.pagesGroup"),B.pages),Gt(y("thread.publishPopover.blocksGroup"),B.blocks),Gt(y("thread.publishPopover.otherGroup"),B.other),J?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.detailsUnavailable")}):null]}),_i=Q?c.jsx(jl,{}):Ne?c.jsx("div",{className:le(Xs,"relative"),children:it.filter(ae=>Wt.includes(Qt(ae))).map(ae=>c.jsx("div",{className:le("absolute inset-0 flex",Qt(ae)!==yt&&"hidden"),children:c.jsx(pu,{change:ae,diff:q,bodyPending:te,previewServerUrl:v,draft:k,lastPage:A})},Qt(ae)))}):c.jsx("div",{className:le(Xs,"bg-muted/40")});let at;e[95]!==Vt?(at=c.jsx("span",{className:"truncate",children:Vt}),e[95]=Vt,e[96]=at):at=e[96];let lt;e[97]!==wi||e[98]!==N||e[99]!==Yt||e[100]!==at?(lt=c.jsx($n,{mode:N,title:at,subLine:Yt,trailing:wi}),e[97]=wi,e[98]=N,e[99]=Yt,e[100]=at,e[101]=lt):lt=e[101];let ht;e[102]!==ke||e[103]!==ce||e[104]!==He||e[105]!==B.count||e[106]!==y?(ht=B.count===0?null:c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-[13px] font-medium",children:y(ce?"thread.publishPopover.reviewNote":"thread.publishPopover.versionNote")}),c.jsx(Pc,{value:He,onChange:ae=>ee(ae.target.value),placeholder:y(ce?"thread.publishPopover.reviewNotePlaceholder":"thread.publishPopover.versionNotePlaceholder"),rows:2,maxLength:qs,className:"resize-none text-[13px]",disabled:ke})]}),e[102]=ke,e[103]=ce,e[104]=He,e[105]=B.count,e[106]=y,e[107]=ht):ht=e[107];let ct;e[108]!==m||e[109]!==y?(ct=c.jsx(Un,{draftPreviewUrl:m,t:y}),e[108]=m,e[109]=y,e[110]=ct):ct=e[110];let dt;e[111]!==qt||e[112]!==_e||e[113]!==ke||e[114]!==ce||e[115]!==w||e[116]!==fi||e[117]!==Ut||e[118]!==B.count||e[119]!==y?(dt=!ce&&B.count>0&&!_e.allowed&&!_e.pending?c.jsx(pe,{type:"button",className:"flex-1",onClick:w,disabled:ke,children:y("thread.publishPopover.requestApproval")}):c.jsxs(pe,{type:"button",variant:ce?"default":"brand",className:"flex-1",onClick:()=>{Ut()},disabled:!qt,children:[ke?c.jsx(rs,{className:"size-4 motion-reduce:animate-none"}):null,ke?y(ce?"thread.publishPopover.submitting":"thread.publishPopover.publishing"):fi]}),e[111]=qt,e[112]=_e,e[113]=ke,e[114]=ce,e[115]=w,e[116]=fi,e[117]=Ut,e[118]=B.count,e[119]=y,e[120]=dt):dt=e[120];let ut;e[121]!==ct||e[122]!==dt?(ut=c.jsxs("div",{className:"flex gap-2",children:[ct,dt]}),e[121]=ct,e[122]=dt,e[123]=ut):ut=e[123];let ft;e[124]!==Lt?(ft=Lt?c.jsx("p",{className:"text-xs text-destructive",children:Lt}):null,e[124]=Lt,e[125]=ft):ft=e[125];let _t;e[126]!==ut||e[127]!==ft?(_t=c.jsxs(c.Fragment,{children:[ut,ft]}),e[126]=ut,e[127]=ft,e[128]=_t):_t=e[128];let pt;e[129]!==yi||e[130]!==Xt||e[131]!==Ke||e[132]!==lt||e[133]!==ht||e[134]!==_t?(pt=c.jsx(Fn,{state:Ke,header:lt,body:yi,note:ht,gate:Xt,footer:_t}),e[129]=yi,e[130]=Xt,e[131]=Ke,e[132]=lt,e[133]=ht,e[134]=_t,e[135]=pt):pt=e[135];let Ft;return e[136]!==_i||e[137]!==pt?(Ft=c.jsx(Wn,{pane:_i,list:pt}),e[136]=_i,e[137]=pt,e[138]=Ft):Ft=e[138],Ft}function Ou(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return fc[t].short}const Iu=new Set(["failure","timed_out","cancelled","action_required"]);function Hl(t){return t.status==="completed"&&Iu.has(t.conclusion)}function Kn(t){return t.status==="queued"||t.status==="in_progress"}function js(t){return t.isPending&&t.fetchStatus!=="idle"}function ju(t){return{key:"view-change-request",label:t("thread.cmsActions.viewOnProvider"),action:"open-pr-page"}}function ai(t,e,i){return e?[...t,ju(i)]:t}function zt(t,e,i){return e.kind!=="ready"||e.behindBase<=0?t:[...t,{key:"get-latest",label:i("thread.cmsActions.getLatest"),action:"sync",tooltip:i("thread.cmsActions.getLatestTooltip")}]}function Co(t){return{key:"submit-for-review",label:t("thread.headerActions.submitForReview"),action:"create-pr"}}function Ds(t,e,i){if(e.filter(Kn).length===0)return t;const r=e.filter(n=>n.status==="completed").length;return{...t,tooltip:i("thread.cmsActions.checksRunning",{done:r,total:e.length})}}function Hu(t){const{lifecycle:e,branch:i,pr:s,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&&Ou(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(!(i.kind==="ready"&&(i.workingTreeDirty||i.aheadOfBase>0||i.unpushed>0))&&!t.noReviewableDiff)return{label:a("thread.headerActions.startingApp"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.startingAppTooltip"),menu:[]};break}}if(i.kind!=="ready")return{label:a("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.waitingForBranchTooltip"),menu:[]};const h=i,l=h.unpushed>0&&!(s&&h.headSha&&s.headSha&&h.headSha===s.headSha);if(t.noReviewableDiff&&!s)return{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.branchInSyncTooltip",{base:h.base}),menu:zt([],h,a)};if(h.workingTreeDirty||l)return{label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:zt(ai([Co(a)],s,a),h,a)};if(gl("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:s?.merged??null,prState:s?.state??null}),s?.merged)return!!h.headSha&&!!s.headSha&&h.headSha!==s.headSha?{label:a("thread.headerActions.continue"),action:"create-pr",variant:"special",tooltip:a("thread.headerActions.openNewPrTooltip"),menu:zt(ai([],s,a),h,a)}:{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.prMergedTooltip",{prNumber:String(s.number),base:s.base}),menu:zt(ai([],s,a),h,a)};if(h.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:a("thread.headerActions.reopenPr"),action:"reopen",variant:"default",tooltip:a("thread.headerActions.reopenPrTooltip",{prNumber:String(s.number)}),menu:zt(ai([],s,a),h,a)};if(!s)return{label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:zt([Co(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(Kn).length,f=r.filter(Hl).map(p=>p.name);if(d===0&&f.length>0)return{label:a("thread.headerActions.fixChecks"),action:"fix-checks",variant:"default",tooltip:a("thread.headerActions.failingChecksTooltip",{checks:f.join(", ")}),meta:{failingChecks:f},menu:zt(ai([{key:"publish-anyway",label:a("thread.headerActions.publishAnyway"),action:"merge",tooltip:a("thread.headerActions.squashMergeTooltip",{prNumber:String(s.number),base:s.base})}],s,a),h,a)};if(n?.draft)return Ds({label:a("thread.headerActions.markReady"),action:"mark-ready",variant:"default",tooltip:a("thread.headerActions.markDraftReadyTooltip"),menu:zt(ai([],s,a),h,a)},r,a);const _=n?.unresolvedConversations??0;return _>0?Ds({label:a("thread.headerActions.addressFeedback"),action:"resolve-comments",variant:"default",tooltip:a("thread.headerActions.unresolvedConversationsTooltip",{count:String(_)}),menu:zt(ai([],s,a),h,a)},r,a):n?.missingRequiredApprovals?Ds({label:a("thread.cmsActions.waitingForReview"),action:"open-pr-page",variant:"outline",tooltip:a("thread.headerActions.waitingForApprovalsTooltip"),menu:zt(ai([],s,a),h,a)},r,a):Ds({label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",meta:{publishPolicyOverride:"open"},menu:zt(ai([{key:"review",label:a("thread.headerActions.review"),action:"review"}],s,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 ko(t){return{key:"view-change-request",label:t("thread.cmsActions.viewOnProvider"),action:"open-pr"}}function As(t,e,i){return e.kind!=="ready"||e.behindBase<=0?t:[...t,{key:"get-latest",label:i("thread.cmsActions.getLatest"),action:"get-latest",tooltip:i("thread.cmsActions.getLatestTooltip")}]}function Eo(t,e,i,s){const r=e.length;if(r===0)return t;if(e.filter(Kn).length>0){const a=e.filter(l=>l.status==="completed").length,h=s("thread.cmsActions.checksRunning",{done:a,total:r});return i==="loading"?{...t,loading:!0,tooltip:h}:{...t,tooltip:h}}const o=e.filter(Hl).length;return o>0?{...t,variant:"warning",tooltip:s("thread.cmsActions.checksFailing",{failed:o,total:r})}:t}function Fu(t,e){return!!(t?.merged&&t.headSha&&e.kind==="ready"&&!e.workingTreeDirty&&e.headSha===t.headSha)}function zu(t){return js(t.prQuery)?!0:t.pr?.state!=="open"||t.pr.merged?!1:js(t.checksQuery)||js(t.reviewsQuery)}function Wu(t,e){return t.workingTreeDirty?!0:e!==null?e>0:t.aheadOfBase>0}function $u(t){const{branch:e,pr:i,checks:s,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(i&&i.state==="open"&&!i.merged?i: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?Eo({label:l("thread.cmsActions.waitingForReview"),action:"open-pr",variant:"outline",menu:As([ko(l)],e,l)},s,"loading",l):Eo({label:l("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:As([ko(l)],e,l)},s,"none",l)}return Fu(i,e)?{label:l("thread.headerActions.upToDate"),variant:"outline",disabled:!0,menu:As([],e,l)}:Wu(e,h)?{label:l("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:As([{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 Uu(t){return t.conflicting===!0?"dirty":t.conflicting===null?"unknown":t.reviewBlocked||t.unresolvedConversations>0?"blocked":"clean"}function Fl(t){const e=U.c(4);let i;e[0]!==t?(i=Sc(t),e[0]=t,e[1]=i):i=e[1];let s;return e[2]!==i?(s={...i,select:Ku},e[2]=i,e[3]=s):s=e[3],zi(s)}function Ku(t){const e=t.changeRequest;return e?{draft:e.draft,mergeableState:Uu(e),unresolvedConversations:e.unresolvedConversations,missingRequiredApprovals:e.reviewBlocked}:null}function Po(t,e){return t==="open-pr"||e==="resolve-on-provider"?c.jsx(tl,{size:16}):t==="publish"?c.jsx(Ua,{className:"size-4"}):t==="get-latest"||t==="retry-status"?c.jsx(ns,{className:"size-4"}):c.jsx(ar,{className:"size-4"})}function qu(t){const e=U.c(66),{virtualMcpId:i}=t,s=Be(),{org:r}=rr(),n=$h(),o=hr(i),{data:a}=sr.useSession(),{deleteRelease:h}=Ln(i),{currentBranch:l,setCurrentTaskBranch:u,taskId:d,createTask:f}=Ra();let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={open:!1,mode:"publish"},e[0]=_):_=e[0];const[p,m]=X.useState(_);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=V=>m({open:!0,mode:V}),e[1]=g):g=e[1];const v=g,k=Ja(o),b=k.status==="attached"||k.status==="public-clone"?k.repo:null,{previewServerUrl:w}=cr(i);let C;if(e[2]!==l||e[3]!==r.slug||e[4]!==i){const V=l?il(sl(r.slug,i,l)):null;C=V?Ya(V.path,V.params):"/",e[2]=l,e[3]=r.slug,e[4]=i,e[5]=C}else C=e[5];const S=C;let R;e[6]!==l||e[7]!==S||e[8]!==r.slug||e[9]!==w||e[10]!==i?(R=l?{orgSlug:r.slug,virtualMcpId:i,branch:l,previewServerUrl:w,path:S}:null,e[6]=l,e[7]=S,e[8]=r.slug,e[9]=w,e[10]=i,e[11]=R):R=e[11];const N=yc(R);let I;e[12]!==l||e[13]!==r.slug||e[14]!==i?(I=l?{orgSlug:r.slug,virtualMcpId:i,branch:l}:null,e[12]=l,e[13]=r.slug,e[14]=i,e[15]=I):I=e[15];const L=xc(I),y=l??"",E=d??null;let x;e[16]!==r.slug||e[17]!==y||e[18]!==E||e[19]!==i?(x=dl({orgSlug:r.slug,virtualMcpId:i,branch:y,threadId:E}),e[16]=r.slug,e[17]=y,e[18]=E,e[19]=i,e[20]=x):x=e[20];const A=!!l;let D;e[21]!==x||e[22]!==A?(D={...x,enabled:A},e[21]=x,e[22]=A,e[23]=D):D=e[23];const P=zi(D),B=P.data??null,M=B?{kind:"ready",branch:fl(B)??l??"",base:B.base??"main",workingTreeDirty:zc(B),unpushed:B.unpushed??0,aheadOfBase:B.aheadOfBase??0,behindBase:B.behindBase??0,headSha:B.headSha??""}:{kind:"unknown"},K=B?.changedFiles?Ll({files:B.changedFiles}).count:null,F=(M.kind==="ready"?M.branch:null)??l??null,H=M.kind==="ready"?M.base:"main",Y=Za({orgId:r.id,orgSlug:r.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:F}),q=Y.data??null,te=Qa({orgId:r.id,orgSlug:r.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",base:H}),J=el({orgId:r.id,orgSlug:r.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:F}),Q=Fl({orgId:r.id,orgSlug:r.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:F});let W;e[24]!==J||e[25]!==q||e[26]!==Y||e[27]!==Q?(W=zu({pr:q,prQuery:Y,checksQuery:J,reviewsQuery:Q}),e[24]=J,e[25]=q,e[26]=Y,e[27]=Q,e[28]=W):W=e[28];const G=W;let ee;e[29]!==Y?(ee=async()=>{await Y.refetch()},e[29]=Y,e[30]=ee):ee=e[30];const ue=ee,ie=io({mutationFn:async()=>{const V=l;await u(Nn(On(a?.user))),V&&V!==H&&await h(V)},onError:Gu});let de;e[31]!==r.slug||e[32]!==d||e[33]!==i?(de=async V=>(await hl({orgSlug:r.slug,virtualMcpId:i,branch:V.branch,threadId:d??null},V.base),V),e[31]=r.slug,e[32]=d,e[33]=i,e[34]=de):de=e[34];let z;e[35]!==l||e[36]!==r.slug||e[37]!==n||e[38]!==s||e[39]!==d||e[40]!==i?(z=async V=>{Xe.success(s("thread.headerActions.syncedWithBase",{base:V.base})),await Promise.all([n.invalidateQueries({queryKey:pl({orgSlug:r.slug,virtualMcpId:i,branch:l??V.branch,threadId:d??null})}),n.invalidateQueries({queryKey:An.decofile(`${r.slug}/${i}/${V.branch}`)})])},e[35]=l,e[36]=r.slug,e[37]=n,e[38]=s,e[39]=d,e[40]=i,e[41]=z):z=e[41];let ge;e[42]!==de||e[43]!==z?(ge={mutationFn:de,onSuccess:z,onError:Yu},e[42]=de,e[43]=z,e[44]=ge):ge=e[44];const fe=io(ge),Le=rl(r.slug,i,l??""),oe=ie.isPending,$=$u({branch:M,pr:q,checks:J.data??[],reviews:Q.data??null,publishing:oe,saving:Le,syncing:fe.isPending,statusRetrying:P.isFetching&&!!P.error,statusError:P.error instanceof Error?P.error.message:P.error?String(P.error):null,loading:!!G,publishableChangeCount:K,t:s}),De=$.autoRun&&M.kind==="ready"&&b&&w?`${F}@${M.headSha}`:null,At=X.useRef(null);if(X.useEffect(()=>{!De||!F||At.current!==De&&(At.current=De,fe.mutate({branch:F,base:H}))},[De,F,H,fe]),k.status==="detached"){let V;e[45]!==s?(V=s("thread.headerActions.reconnectGithub"),e[45]=s,e[46]=V):V=e[46];let _e;e[47]!==V?(_e=c.jsx(St,{asChild:!0,children:c.jsx("span",{children:c.jsx(pe,{size:"sm",variant:"outline",disabled:!0,children:V})})}),e[47]=V,e[48]=_e):_e=e[48];let Ae;e[49]!==s?(Ae=s("thread.headerActions.githubConnectionRemoved"),e[49]=s,e[50]=Ae):Ae=e[50];let ye;e[51]!==Ae?(ye=c.jsx(wt,{children:Ae}),e[51]=Ae,e[52]=ye):ye=e[52];let Je;return e[53]!==_e||e[54]!==ye?(Je=c.jsx(nr,{children:c.jsxs(bt,{children:[_e,ye]})}),e[53]=_e,e[54]=ye,e[55]=Je):Je=e[55],Je}if(!o)return null;if(!b||!w){const V=b?"noPreviewServer":"noRepo";let _e;e[56]!==l||e[57]!==f?(_e=l?()=>{const ye=f?.({runtime:"sandbox",branch:l});ye&&Uh("coding_session_started",{thread_id:ye})}:void 0,e[56]=l,e[57]=f,e[58]=_e):_e=e[58];let Ae;return e[59]!==V||e[60]!==_e?(Ae=c.jsx(Xu,{reason:V,onStartCodingSession:_e}),e[59]=V,e[60]=_e,e[61]=Ae):Ae=e[61],Ae}if(!l)return null;const Ye=V=>{switch(V){case"publish":{v("publish");return}case"request-approval":{v("review");return}case"get-latest":{if(!F||fe.isPending)return;fe.mutate({branch:F,base:H});return}case"retry-status":{P.refetch();return}case"open-pr":{q?.htmlUrl&&window.open(q.htmlUrl,"_blank","noopener,noreferrer");return}}};let He;e[62]!==Ye?(He=V=>({key:V.key,label:V.label,icon:Po(V.action,V.key),...V.tooltip?{tooltip:V.tooltip}:{},onSelect:()=>Ye(V.action)}),e[62]=Ye,e[63]=He):He=e[63];const it=$.menu.map(He),Ne=$.action,yt=$.label,Wt=$.variant,ce=!!$.loading;let Ke;e[64]!==s?(Ke=s("thread.cmsActions.moreActionsAriaLabel"),e[64]=s,e[65]=Ke):Ke=e[65];const qe=c.jsx(Sl,{size:"sm",label:yt,variant:Wt,disabled:!!$.disabled||!Ne,loading:ce,...Ne&&!$.loading?{icon:Po(Ne)}:{},...$.tooltip?{tooltip:$.tooltip}:{},items:it,menuAriaLabel:Ke,onClick:Ne?()=>Ye(Ne):void 0});return c.jsxs(c.Fragment,{children:[qe,l?c.jsx(Il,{open:p.open,mode:p.mode,fastPreview:!0,onOpenChange:V=>{V||m(Vu)},orgSlug:r.slug,virtualMcpId:i,branch:l,baseBranch:H,repoTarget:Bt(b),owner:b.owner,repo:b.name,publishPolicy:_l(o?.metadata?.publishPolicy),draftPreviewUrl:N.url,destinationHost:N.host,previewServerUrl:w,compareDraft:L?{kind:"pointer",pointer:L}:null,lastPublishedPr:te.data??null,onRequestApproval:()=>v("review"),openPullRequest:q?.state==="open"?q:null,onPullRequestChanged:ue,onPublished:()=>ie.mutateAsync()}):null]})}function Vu(t){return{...t,open:!1}}function Yu(t){Xe.error(t instanceof Error?t.message:String(t))}function Gu(t){Xe.error(t instanceof Error?t.message:String(t))}function Xu(t){const e=U.c(14),{reason:i,onStartCodingSession:s}=t,r=Be(),n=!s;let o;e[0]!==r?(o=r("sandbox.cmsUnavailable.startCodingSession"),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==n||e[4]!==o?(a=c.jsx(St,{asChild:!0,children:c.jsx("span",{children:c.jsx(pe,{size:"sm",variant:"outline",disabled:n,onClick:s,children:o})})}),e[2]=s,e[3]=n,e[4]=o,e[5]=a):a=e[5];let h;e[6]!==i||e[7]!==r?(h=r(i==="noPreviewServer"?"sandbox.cmsUnavailable.noPreviewServer":"sandbox.cmsUnavailable.noRepo"),e[6]=i,e[7]=r,e[8]=h):h=e[8];let l;e[9]!==h?(l=c.jsx(wt,{children:h}),e[9]=h,e[10]=l):l=e[10];let u;return e[11]!==a||e[12]!==l?(u=c.jsx(nr,{children:c.jsxs(bt,{children:[a,l]})}),e[11]=a,e[12]=l,e[13]=u):u=e[13],u}const Li="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 Ju(t){return`Reopen PR #${t.prNumber}. ${Li}`}function Zu(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${Li}`}function Qu(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). ${Li}`}function ef(t){const e=(t.failingChecks??[]).map(i=>`\`${i}\``).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. ${Li}`}function tf(t){return`Mark PR #${t.prNumber} ready for review. ${Li}`}function sf(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. ${Li}`}function rf(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. ${Li}`}function Ro(t){switch(t){case"publish":return c.jsx(Ua,{className:"size-4"});case"create-pr":case"reopen":return c.jsx(ar,{className:"size-4"});case"rebase":case"sync":return c.jsx(ns,{className:"size-4"});case"fix-checks":return c.jsx(Pa,{className:"size-4"});case"mark-ready":return c.jsx(ol,{className:"size-4"});case"resolve-comments":return c.jsx(nc,{className:"size-4"});case"merge":return c.jsx(Dc,{className:"size-4"});case"review":return c.jsx(al,{className:"size-4"});case"open-pr-page":return c.jsx(tl,{size:16})}}const Bo=new Set(["reopen","rebase","fix-checks","mark-ready","resolve-comments","review","sync"]),Do=new Set(["publish","create-pr"]);function nf(t){return{label:t("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:t("thread.headerActions.waitingForSandboxBranchTooltip"),menu:[]}}function of({virtualMcpId:t}){const e=Be(),{org:i}=rr(),{data:s}=sr.useSession(),r=hr(t),{deleteRelease:n}=Ln(t),{currentBranch:o,setCurrentTaskBranch:a,taskId:h}=Ra(),l=Gh(),{openSidePanel:u}=Jh(),[d,f]=X.useState({open:!1,mode:"publish",policyOverride:null}),_=Gc({connectionId:Kh,orgId:i.id,orgSlug:i.slug}),p=Xc(_),[m,g]=X.useState(!1),v=X.useRef(""),k=Ja(r),b=k.status==="attached"||k.status==="public-clone"?k.repo:null,{lifecycle:w,branch:C,phase:S}=dr(),R={orgSlug:i.slug,virtualMcpId:t,branch:o??"",threadId:h??null},I=zi({queryKey:pl(R),queryFn:()=>jn(R),enabled:!!o,staleTime:15e3,refetchInterval:oe=>wr(oe.state.data)?5e3:!1}).data??null,L=C,y=w,E=L.kind==="ready"?L.branch:null,x=o??E??void 0,A=(L.kind==="ready"?L.branch:null)??x??null,D=Za({orgId:i.id,orgSlug:i.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:A}),P=D.data??null,B=el({orgId:i.id,orgSlug:i.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:A}),M=Fl({orgId:i.id,orgSlug:i.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:A}),K=Qa({orgId:i.id,orgSlug:i.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",base:L.kind==="ready"?L.base:null}),F=L,H=_l(r?.metadata?.publishPolicy),Y=rl(i.slug,t,o??x??""),{previewUrl:q}=vl(),{previewServerUrl:te}=cr(t);if(k.status==="detached")return c.jsx(lf,{label:e("thread.headerActions.githubConnectionRemoved"),children:c.jsx(pe,{size:"sm",variant:"outline",disabled:!0,children:e("thread.headerActions.reconnectGithub")})});if(!b)return null;const J=A?Hu({lifecycle:y,branch:F,claimPhase:S,pr:P,checks:B.data??[],reviews:M.data??null,noReviewableDiff:wr(I),loading:js(D),t:e}):nf(e),Q=JSON.stringify({label:J.label,branchKind:F.kind,workingTreeDirty:F.kind==="ready"?F.workingTreeDirty:null,unpushed:F.kind==="ready"?F.unpushed:null,aheadOfBase:F.kind==="ready"?F.aheadOfBase:null,lifecycle:y.phase,headBranch:A,noReviewableDiff:wr(I)});v.current!==Q&&(v.current=Q,gl("header button",{label:J.label,tooltip:J.tooltip,action:J.action,chatBranch:o,sandboxBranch:E,sandboxRouteBranch:x,headBranch:A,branchMeta:L,effectiveBranchMeta:F,lifecyclePhase:y.phase,prNumber:P?.number??null,prState:P?.state??null}));const W=oe=>(u(),l.sendMessage({parts:[{type:"text",text:oe}]})),G=l.isStreaming,ee=F.kind==="ready"?F.base:"main",ue=async()=>{await D.refetch()},ie=async()=>{const oe=o,$=Nn(On(s?.user));await a($),oe&&oe!==ee&&await n(oe)},de=async oe=>{if(!(!b||m)){g(!0);try{const $=wl(s?.user);await Cl(i.slug,Bt(b),{number:oe,coAuthor:$}),Xe.success(e("thread.headerActions.publishedPr",{prNumber:String(oe)})),await ue(),await ie()}catch($){Xe.error($ instanceof xl?$.detail??Pd($.reason,e):$ instanceof Error?$.message:e("thread.headerActions.failedToMergePullRequest"))}finally{g(!1)}}},z=(oe,$)=>f({open:!0,mode:oe,policyOverride:$}),ge=oe=>{if(A)switch(oe){case"publish":z("publish",J.meta?.publishPolicyOverride??null);return;case"create-pr":z("review",null);return;case"merge":P&&de(P.number);return;case"sync":if(G)return;W(Qu({branch:A,base:ee}));return;case"open-pr-page":P?.htmlUrl&&window.open(P.htmlUrl,"_blank","noopener,noreferrer");return;case"review":if(G)return;P&&W(rf({prNumber:P.number}));return;case"reopen":if(G)return;P&&W(Ju({prNumber:P.number}));return;case"rebase":if(G)return;W(Zu({branch:A}));return;case"fix-checks":if(G)return;P&&W(ef({prNumber:P.number,failingChecks:J.meta?.failingChecks??[]}));return;case"mark-ready":if(G)return;P&&W(tf({prNumber:P.number}));return;case"resolve-comments":if(G)return;P&&W(sf({prNumber:P.number}));return}},fe=m||G,Le=c.jsx(af,{t:e,button:J,actionBusy:fe,changeRequestPending:m,savePending:Y,onAction:ge});return x?c.jsxs(c.Fragment,{children:[Le,c.jsx(Il,{open:d.open,mode:d.mode,fastPreview:!1,recoverSandbox:()=>p.mutateAsync({virtualMcpId:t,branch:x,...h?{threadId:h}:{}}),onOpenChange:oe=>{oe||f($=>({...$,open:!1}))},orgSlug:i.slug,virtualMcpId:t,branch:x,baseBranch:ee,repoTarget:Bt(b),owner:b.owner,repo:b.name,publishPolicy:d.policyOverride??H,draftPreviewUrl:q,destinationHost:null,previewServerUrl:te,compareDraft:q?{kind:"sandbox",previewUrl:q}:null,lastPublishedPr:K.data??null,onRequestApproval:()=>f(oe=>({...oe,open:!0,mode:"review"})),openPullRequest:P?.state==="open"?P:null,onPullRequestChanged:ue,onPublished:ie})]}):Le}function af(t){const e=U.c(44),{t:i,button:s,actionBusy:r,changeRequestPending:n,savePending:o,onAction:a}=t,h=s.action;let l;e[0]!==h||e[1]!==r?(l=r&&h!==void 0&&Bo.has(h),e[0]=h,e[1]=r,e[2]=l):l=e[2];const u=l,d=n&&h==="merge";let f;e[3]!==h||e[4]!==o?(f=o&&h!==void 0&&Do.has(h),e[3]=h,e[4]=o,e[5]=f):f=e[5];const _=f,p=!!s.disabled||u||d||_||!h,m=!!s.loading||d;let g;e[6]!==s.tooltip||e[7]!==u||e[8]!==_||e[9]!==i?(g=u?i("thread.headerActions.chatIsRunning"):_?i("thread.headerActions.saving"):s.tooltip,e[6]=s.tooltip,e[7]=u,e[8]=_,e[9]=i,e[10]=g):g=e[10];const v=g;let k;if(e[11]!==r||e[12]!==s.menu||e[13]!==n||e[14]!==a||e[15]!==o||e[16]!==i){let y;e[18]!==r||e[19]!==n||e[20]!==a||e[21]!==o||e[22]!==i?(y=E=>{const x=r&&Bo.has(E.action),A=o&&Do.has(E.action),D=E.action==="merge"&&n,P=A?i("thread.headerActions.saving"):x?i("thread.headerActions.chatIsRunning"):E.tooltip;return{key:E.key,label:E.label,icon:Ro(E.action),disabled:!!(x||A||D),...P?{tooltip:P}:{},onSelect:()=>a(E.action)}},e[18]=r,e[19]=n,e[20]=a,e[21]=o,e[22]=i,e[23]=y):y=e[23],k=s.menu.map(y),e[11]=r,e[12]=s.menu,e[13]=n,e[14]=a,e[15]=o,e[16]=i,e[17]=k}else k=e[17];const b=k,w=s.label,C=s.variant;let S;e[24]!==h||e[25]!==m?(S=h&&!m?{icon:Ro(h)}:{},e[24]=h,e[25]=m,e[26]=S):S=e[26];let R;e[27]!==v?(R=v?{tooltip:v}:{},e[27]=v,e[28]=R):R=e[28];let N;e[29]!==i?(N=i("thread.headerActions.moreActionsAriaLabel"),e[29]=i,e[30]=N):N=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 L;return e[34]!==s.label||e[35]!==s.variant||e[36]!==p||e[37]!==b||e[38]!==m||e[39]!==S||e[40]!==R||e[41]!==N||e[42]!==I?(L=c.jsx(Sl,{size:"sm",label:w,variant:C,disabled:p,loading:m,...S,...R,items:b,menuAriaLabel:N,onClick:I}),e[34]=s.label,e[35]=s.variant,e[36]=p,e[37]=b,e[38]=m,e[39]=S,e[40]=R,e[41]=N,e[42]=I,e[43]=L):L=e[43],L}function lf(t){const e=U.c(9),{label:i,children:s}=t;if(!i){let a;return e[0]!==s?(a=c.jsx(c.Fragment,{children:s}),e[0]=s,e[1]=a):a=e[1],a}let r;e[2]!==s?(r=c.jsx(St,{asChild:!0,children:c.jsx("span",{children:s})}),e[2]=s,e[3]=r):r=e[3];let n;e[4]!==i?(n=c.jsx(wt,{children:i}),e[4]=i,e[5]=n):n=e[5];let o;return e[6]!==r||e[7]!==n?(o=c.jsx(nr,{children:c.jsxs(bt,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=o):o=e[8],o}const hf=new Set(["site-editor","content"]);function cf(t){return t.hasClonableSource&&!t.fastPreviewActive&&t.mainTab!==null&&hf.has(t.mainTab)}const Bi="setup";function df(t){const e=U.c(57),i=Be();let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let w;e[3]!==t.scriptTabs?(w=C=>!t.scriptTabs.includes(C),e[3]=t.scriptTabs,e[4]=w):w=e[4],s=t.scripts.filter(w),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const r=s;let n;e[5]!==t?(n=()=>{t.active===Bi?t.onToggle():t.onSelectTab(Bi)},e[5]=t,e[6]=n):n=e[6];const o=n;let a;e[7]!==t.open||e[8]!==i?(a=t.open?i("sandbox.preview.collapseTerminal"):i("sandbox.preview.expandTerminal"),e[7]=t.open,e[8]=i,e[9]=a):a=e[9];let h;e[10]!==t.open?(h=t.open?c.jsx(or,{className:"size-4"}):c.jsx(tc,{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(St,{asChild:!0,children:c.jsx(pe,{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]!==i?(u=t.open?i("sandbox.preview.collapseTerminal"):i("sandbox.preview.expandTerminal"),e[17]=t.open,e[18]=i,e[19]=u):u=e[19];let d;e[20]!==u?(d=c.jsx(wt,{children:u}),e[20]=u,e[21]=d):d=e[21];let f;e[22]!==l||e[23]!==d?(f=c.jsxs(bt,{children:[l,d]}),e[22]=l,e[23]=d,e[24]=f):f=e[24];const _=t.active===Bi;let p;e[25]!==o||e[26]!==t.open||e[27]!==i||e[28]!==_?(p=c.jsx(uf,{active:_,open:t.open,onClick:o,t:i}),e[25]=o,e[26]=t.open,e[27]=i,e[28]=_,e[29]=p):p=e[29];let m;e[30]!==t||e[31]!==i?(m=t.scriptTabs.map(w=>c.jsx(_f,{active:t.active===w,onClick:()=>{t.active===w?t.onToggle():t.onSelectTab(w)},onClose:()=>t.onCloseScript(w),t:i,children:w},w)),e[30]=t,e[31]=i,e[32]=m):m=e[32];let g;e[33]!==r||e[34]!==t.onAddScript?(g=c.jsx(pf,{scripts:r,onRun:t.onAddScript}),e[33]=r,e[34]=t.onAddScript,e[35]=g):g=e[35];let v;e[36]!==m||e[37]!==g||e[38]!==p?(v=c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[p,m,g]}),e[36]=m,e[37]=g,e[38]=p,e[39]=v):v=e[39];let k;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]!==i?(k=t.showScriptControls?c.jsx(mf,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript,t:i}):c.jsx(ff,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry,t:i}),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]=i,e[52]=k):k=e[52];let b;return e[53]!==v||e[54]!==k||e[55]!==f?(b=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:[f,v,k]}),e[53]=v,e[54]=k,e[55]=f,e[56]=b):b=e[56],b}function uf(t){const e=U.c(11),{active:i,open:s,onClick:r,t:n}=t,o=i&&s,a=i&&s,h=i?"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=le("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(Ac,{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 f;return e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==l||e[9]!==d?(f=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]=f):f=e[10],f}function ff(t){const e=U.c(40),{status:i,onStart:s,onStop:r,onRestart:n,onResume:o,onRetry:a,t:h}=t;if(i==="idle"&&s){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(Ks,{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]!==s||e[4]!==u?(d=c.jsxs(pe,{variant:"outline",size:"xs",onClick:s,children:[l," ",u]}),e[3]=s,e[4]=u,e[5]=d):d=e[5],d}if(i==="suspended"&&o){let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(Ks,{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(pe,{variant:"outline",size:"xs",onClick:o,children:[l," ",u]}),e[9]=o,e[10]=u,e[11]=d):d=e[11],d}if(i==="errored"&&a){let l;e[12]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(ns,{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(pe,{variant:"outline",size:"xs",onClick:a,children:[l," ",u]}),e[15]=a,e[16]=u,e[17]=d):d=e[17],d}if(i==="starting"||i==="running"){const l=i==="running"&&!!n,u=l?"rounded-r-none border-r-0":void 0;let d;e[18]!==u?(d=le(u),e[18]=u,e[19]=d):d=e[19];let f;e[20]!==h?(f=h("sandbox.toolbar.stop"),e[20]=h,e[21]=f):f=e[21];let _;e[22]!==r||e[23]!==d||e[24]!==f?(_=c.jsx(St,{asChild:!0,children:c.jsx(pe,{variant:"outline",size:"xs",onClick:r,className:d,children:f})}),e[22]=r,e[23]=d,e[24]=f,e[25]=_):_=e[25];let p;e[26]!==h?(p=h("sandbox.toolbar.stopSandboxTooltip"),e[26]=h,e[27]=p):p=e[27];let m;e[28]!==p?(m=c.jsx(wt,{children:p}),e[28]=p,e[29]=m):m=e[29];let g;e[30]!==_||e[31]!==m?(g=c.jsxs(bt,{children:[_,m]}),e[30]=_,e[31]=m,e[32]=g):g=e[32];let v;e[33]!==n||e[34]!==l||e[35]!==h?(v=l&&c.jsxs(us,{children:[c.jsx(cs,{asChild:!0,children:c.jsx(pe,{variant:"outline",size:"xs",className:"rounded-l-none px-1","aria-label":h("sandbox.toolbar.moreActions"),children:c.jsx(or,{className:"size-3"})})}),c.jsx(ds,{align:"end",children:c.jsxs(Ai,{onClick:n,children:[c.jsx(ns,{className:"size-3.5"})," ",h("sandbox.toolbar.restart")]})})]}),e[33]=n,e[34]=l,e[35]=h,e[36]=v):v=e[36];let k;return e[37]!==g||e[38]!==v?(k=c.jsxs("div",{className:"flex items-center",children:[g,v]}),e[37]=g,e[38]=v,e[39]=k):k=e[39],k}return null}function _f(t){const e=U.c(17),{active:i,onClick:s,onClose:r,children:n,t:o}=t,a=i?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let h;e[0]!==a?(h=le("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=i?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==l||e[3]!==u?(d=le("flex h-full items-center",l,u),e[2]=l,e[3]=u,e[4]=d):d=e[4];let f;e[5]!==n||e[6]!==s||e[7]!==d?(f=c.jsx("button",{type:"button",onClick:s,className:d,children:n}),e[5]=n,e[6]=s,e[7]=d,e[8]=f):f=e[8];let _;e[9]!==n||e[10]!==r||e[11]!==o?(_=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(Qc,{className:"size-3.5"})}),e[9]=n,e[10]=r,e[11]=o,e[12]=_):_=e[12];let p;return e[13]!==h||e[14]!==f||e[15]!==_?(p=c.jsxs("div",{className:h,children:[f,_]}),e[13]=h,e[14]=f,e[15]=_,e[16]=p):p=e[16],p}function pf(t){const e=U.c(27),{scripts:i,onRun:s}=t,r=Be(),[n,o]=X.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(Mn,{className:"size-4"}),e[2]=h):h=e[2];let l;e[3]!==a?(l=c.jsx(St,{asChild:!0,children:c.jsx(Aa,{asChild:!0,children:c.jsx(pe,{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(wt,{children:u}),e[7]=u,e[8]=d):d=e[8];let f;e[9]!==l||e[10]!==d?(f=c.jsxs(bt,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=f):f=e[11];let _;e[12]!==r?(_=r("sandbox.toolbar.runAScript"),e[12]=r,e[13]=_):_=e[13];let p;e[14]!==_?(p=c.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:_}),e[14]=_,e[15]=p):p=e[15];let m;e[16]!==s||e[17]!==i||e[18]!==r?(m=i.length===0?c.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:r("sandbox.toolbar.noScriptsFound")}):i.map(k=>c.jsxs("button",{type:"button",onClick:()=>{o(!1),s(k)},className:"w-full rounded-lg px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",k]},k)),e[16]=s,e[17]=i,e[18]=r,e[19]=m):m=e[19];let g;e[20]!==p||e[21]!==m?(g=c.jsxs(Ta,{align:"start",className:"p-1 w-56",children:[p,m]}),e[20]=p,e[21]=m,e[22]=g):g=e[22];let v;return e[23]!==n||e[24]!==g||e[25]!==f?(v=c.jsxs(Da,{open:n,onOpenChange:o,children:[f,g]}),e[23]=n,e[24]=g,e[25]=f,e[26]=v):v=e[26],v}function mf(t){const e=U.c(30),{isRunning:i,isKilling:s,onRun:r,onStop:n,t:o}=t;if(s){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(rs,{className:"size-3.5"}),e[0]=f):f=e[0];let _;e[1]!==o?(_=o("sandbox.toolbar.stopping"),e[1]=o,e[2]=_):_=e[2];let p;return e[3]!==_?(p=c.jsxs(pe,{variant:"outline",size:"xs",disabled:!0,children:[f," ",_]}),e[3]=_,e[4]=p):p=e[4],p}if(!i){let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(Ks,{className:"size-3.5"}),e[5]=f):f=e[5];let _;e[6]!==o?(_=o("sandbox.toolbar.run"),e[6]=o,e[7]=_):_=e[7];let p;e[8]!==r||e[9]!==_?(p=c.jsx(St,{asChild:!0,children:c.jsxs(pe,{variant:"outline",size:"xs",onClick:r,children:[f," ",_]})}),e[8]=r,e[9]=_,e[10]=p):p=e[10];let m;e[11]!==o?(m=o("sandbox.toolbar.startProcess"),e[11]=o,e[12]=m):m=e[12];let g;e[13]!==m?(g=c.jsx(wt,{children:m}),e[13]=m,e[14]=g):g=e[14];let v;return e[15]!==p||e[16]!==g?(v=c.jsxs(bt,{children:[p,g]}),e[15]=p,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(St,{asChild:!0,children:c.jsx(pe,{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(wt,{children:l}),e[25]=l,e[26]=u):u=e[26];let d;return e[27]!==h||e[28]!==u?(d=c.jsxs(bt,{children:[h,u]}),e[27]=h,e[28]=u,e[29]=d):d=e[29],d}var zl=Object.defineProperty,gf=Object.getOwnPropertyDescriptor,vf=(t,e)=>{for(var i in e)zl(t,i,{get:e[i],enumerable:!0})},Pe=(t,e,i,s)=>{for(var r=s>1?void 0:s?gf(e,i):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(r=(s?o(e,i,r):o(r))||r);return s&&r&&zl(e,i,r),r},j=(t,e)=>(i,s)=>e(i,s,t),Ao="Terminal input",qr={get:()=>Ao,set:t=>Ao=t},To="Too much output to announce, navigate to rows manually to read",Vr={get:()=>To,set:t=>To=t};function bf(t){return t.replace(/\r?\n/g,"\r")}function Sf(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function wf(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function yf(t,e,i,s){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Wl(r,e,i,s)}}function Wl(t,e,i,s){t=bf(t),t=Sf(t,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(t,!0),e.value=""}function $l(t,e,i){let s=i.getBoundingClientRect(),r=t.clientX-s.left-10,n=t.clientY-s.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 Mo(t,e,i,s,r){$l(t,e,i),r&&s.rightClickSelect(t),e.value=s.selectionText,e.select()}function vi(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function fr(t,e=0,i=t.length){let s="";for(let r=e;r<i;++r){let n=t[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var xf=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let i=t.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=t.charCodeAt(r++);56320<=n&&n<=57343?e[s++]=(this._interim-55296)*1024+n-56320+65536:(e[s++]=this._interim,e[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=t.charCodeAt(n);56320<=a&&a<=57343?e[s++]=(o-55296)*1024+a-56320+65536:(e[s++]=o,e[s++]=a);continue}o!==65279&&(e[s++]=o)}return s}},Cf=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let i=t.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let f=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let p=0,m;for(;(m=this.interim[++p]&63)&&p<4;)_<<=6,_|=m;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-p;for(;l<v;){if(l>=i)return 0;if(m=t[l++],(m&192)!==128){l--,f=!0;break}else this.interim[p++]=m,_<<=6,_|=m&63}f||(g===2?_<128?l--:e[s++]=_:g===3?_<2048||_>=55296&&_<=57343||_===65279||(e[s++]=_):_<65536||_>1114111||(e[s++]=_)),this.interim.fill(0)}let u=i-4,d=l;for(;d<i;){for(;d<u&&!((r=t[d])&128)&&!((n=t[d+1])&128)&&!((o=t[d+2])&128)&&!((a=t[d+3])&128);)e[s++]=r,e[s++]=n,e[s++]=o,e[s++]=a,d+=4;if(r=t[d++],r<128)e[s++]=r;else if((r&224)===192){if(d>=i)return this.interim[0]=r,s;if(n=t[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}e[s++]=h}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;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[s++]=h}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=t[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;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[s++]=h}}return s}},Ul="",bi=" ",fs=class Kl{constructor(){this.fg=0,this.bg=0,this.extended=new Js}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 Kl;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}},Js=class ql{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}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 ql(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Dt=class Vl extends fs{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Js,this.combinedData=""}static fromCharData(e){let i=new Vl;return i.setFromCharData(e),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?vi(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 i=!1;if(e[1].length>2)i=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Lo="di$target",Yr="di$dependencies",Er=new Map;function kf(t){return t[Yr]||[]}function Ue(t){if(Er.has(t))return Er.get(t);let e=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Ef(e,i,r)};return e._id=t,Er.set(t,e),e}function Ef(t,e,i){e[Lo]===e?e[Yr].push({id:t,index:i}):(e[Yr]=[{id:t,index:i}],e[Lo]=e)}var et=Ue("BufferService"),Yl=Ue("CoreMouseService"),Ni=Ue("CoreService"),Pf=Ue("CharsetService"),qn=Ue("InstantiationService"),Gl=Ue("LogService"),tt=Ue("OptionsService"),Xl=Ue("OscLinkService"),Rf=Ue("UnicodeService"),_s=Ue("DecorationService"),Gr=class{constructor(t,e,i){this._bufferService=t,this._optionsService=e,this._oscLinkService=i}provideLinks(t,e){let i=this._bufferService.buffer.lines.get(t-1);if(!i){e(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Dt,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let u=0;u<o;u++)if(!(h===-1&&!i.hasContent(u))){if(i.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 f={start:{x:h+1,y:t},end:{x:u+(!l&&u===o-1?1:0),y:t}},_=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(d);["http:","https:"].includes(p.protocol)||(_=!0)}catch{_=!0}_||s.push({text:d,range:f,activate:(p,m)=>r?r.activate(p,m,f):Bf(p,m),hover:(p,m)=>r?.hover?.(p,m,f),leave:(p,m)=>r?.leave?.(p,m,f)})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=u,a=n.extended.urlId):(h=-1,a=-1)}}e(s)}};Gr=Pe([j(0,et),j(1,tt),j(2,Xl)],Gr);function Bf(t,e){if(confirm(`Do you want to navigate to ${e}?
9
+ `),fallbackTitle:e})}function Vs(t){return{orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId,branch:t.branch,threadId:t.threadId}}function Dd(t){return t.fastPreview?{fastPreview:!0}:void 0}async function yr(t,e,i){try{return await i()}catch(s){throw new zn(s instanceof Error?s.message:e,t)}}async function El(t){const{expectedHeadSha:e,expectedDiffSignature:i}=t;if(!e&&!i)return;const s=await jn(Vs(t)).catch(()=>null);if(!s)return;if(e&&s.headSha&&s.headSha!==e)throw new $r;if(!i)return;const r=await ll(Vs(t),s,t.baseBranch,Dd(t)).catch(()=>null);if(r&&Hn(r)!==i)throw new $r}function Pl(t,e){return Nc(Vs(t),e)}function Rl(t,e){return Ed(t.orgSlug,t.target,{branch:t.headBranch,title:e.title,body:e.body,base:t.baseBranch,coAuthor:t.coAuthor})}async function Ad(t,e,i){await El(t),await yr("push",i("thread.publishDialog.failedPushChanges"),()=>Pl(t,e.message)),await yr("sync",i("thread.publishDialog.failedRebase"),()=>hl(Vs(t),t.baseBranch));const s=await yr("open-pr",i("thread.publishDialog.failedOpenPullRequest"),()=>Rl(t,e));try{await Cl(t.orgSlug,t.target,{number:s.number,commitTitle:e.title,commitMessage:e.body,coAuthor:t.coAuthor})}catch(r){throw new zn(r instanceof Error?r.message:i("thread.publishDialog.failedMergePullRequest"),"merge",s)}return s}async function Td(t,e){return await El(t),await Pl(t,e.message),Rl(t,e)}function Md(t,e){return t instanceof $r?{message:e("thread.publishPopover.branchMoved"),pullRequest:null,headMoved:!0}:t instanceof zn&&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 go(t,e){const i=Md(t,e),s=i.pullRequest;return s&&Xe.error(i.message,{action:{label:e("thread.publishDialog.viewPr"),onClick:()=>window.open(s.htmlUrl,"_blank","noopener,noreferrer")}}),{message:i.message,pullRequestOpened:s!==null,headMoved:i.headMoved}}function Ld(t,e){Xe.success(e("thread.publishDialog.submittedForReview",{prNumber:t.number}),{action:{label:e("thread.publishDialog.viewOnProvider"),onClick:()=>window.open(t.htmlUrl,"_blank","noopener,noreferrer")}})}const Nd=/(?:^|\/)\.deco\/blocks\/([^/]+)\.json$/;function Bl(t){const e=Nd.exec(t)?.[1];return e?Kc(e):null}function Ys(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 Od(t,e){return t===null?"new":e===null?"removed":"edited"}function Dl(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,i=>i.toLowerCase()):t}function xr(t,e){if(t&&typeof t=="object"&&!Array.isArray(t)){const i=t.__resolveType;if(typeof i=="string"&&i.trim()){const r=(i.split("/").pop()??i).replace(/\.[jt]sx?$/,"");return Dl(r)||r}}return`Section ${e+1}`}function Ur(t){const e=t.sections;if(Array.isArray(e))return e.flatMap((i,s)=>i&&typeof i=="object"&&!Array.isArray(i)?[{section:i,basePath:["sections",s]}]:[]);if(e&&typeof e=="object"){const i=e.variants;if(Array.isArray(i))return i.flatMap((s,r)=>{const n=s&&typeof s=="object"&&!Array.isArray(s)?s.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 vo(t){return JSON.stringify(t,(e,i)=>{if(i&&typeof i=="object"&&!Array.isArray(i)){const s=i;return Object.keys(s).sort().reduce((r,n)=>(r[n]=s[n],r),{})}return i})}function Al(t,e){return t===void 0&&e===void 0?!0:vo(t)===vo(e)}function Gs(t,e,i,s=new Set){const r=new Set([...Object.keys(t??{}),...Object.keys(e??{})]),n=[];for(const o of r){if(o.startsWith("__")||s.has(o))continue;const a=t?t[o]:void 0,h=e?e[o]:void 0;Al(a,h)||n.push({label:Dl(o),path:[...i,o],from:a,to:h})}return n}const Id=new Set(["sections"]);function Tl(t,e){const i=t?Ur(t):[],s=e?Ur(e):[],r=[],n=Math.max(i.length,s.length);for(let a=0;a<n;a++){const h=i[a],l=s[a];if(h&&l){if(Al(h.section,l.section))continue;r.push({name:xr(l.section,a),kind:"section",status:"edited",fields:Gs(h.section,l.section,l.basePath)})}else l?r.push({name:xr(l.section,a),kind:"section",status:"new",fields:[]}):h&&r.push({name:xr(h.section,a),kind:"section",status:"removed",fields:[]})}const o=Gs(t,e,[],Id);return o.length>0&&r.push({name:"Page settings",kind:"settings",status:"edited",fields:o}),r}function Kr(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 jd(t){const e=[],i=[],s=[],r=[];for(const[n,o]of Object.entries(t?.diffs??{})){if(cl(n)){r.push(n);continue}const a=Od(o.from,o.to),h=Bl(n);if(!h){s.push(Kr(n,a));continue}const l=Ys(o.from),u=Ys(o.to),d=u??l;if(!d){s.push(Kr(n,a));continue}const f=Hr(h,d);if(f){e.push({kind:"page",blockKey:h,name:f.name,pagePath:f.path,isSiteApp:!1,status:a,filepaths:[n],sections:a==="edited"?Tl(l,u):[],fromJson:l,toJson:u});continue}const _=Va(h,d);i.push({kind:"block",blockKey:h,name:Fr(h,d),pagePath:null,isSiteApp:_,status:a,filepaths:[n],sections:a==="edited"?[{name:Fr(h,d),kind:"section",status:"edited",fields:Gs(l,u,[])}].filter(p=>p.fields.length>0):[],fromJson:l,toJson:u})}return Ml({pages:e,blocks:i,other:s,generated:r})}function Cr(t,e){return(t.filepaths[0]??"").localeCompare(e.filepaths[0]??"")}function Ml(t){const{pages:e,blocks:i,other:s,generated:r}=t;return e.sort(Cr),i.sort(Cr),s.sort(Cr),{pages:e,blocks:i,other:s,generated:r,count:e.length+i.length+s.length}}function Hd(t){return t==="added"?"new":t==="removed"?"removed":"edited"}function Fd(t){return t.startsWith("pages-")}function Ll(t){const{files:e,lookup:i,diff:s}=t,r=[],n=[],o=[],a=[];for(const h of e){const l=h.path;if(cl(l)){a.push(l);continue}const u=Hd(h.status),d=Bl(l);if(!d){o.push(Kr(l,u));continue}const f=s?.diffs[l],_=Ys(f?.from??null),p=Ys(f?.to??null),m=zd(i,d),g=m??p??_;if((m?Hr(d,m):null)??(!m&&Fd(d))){const b=g?Hr(d,g):null;r.push({kind:"page",blockKey:d,name:b?.name??mc(d),pagePath:b?.path??null,isSiteApp:!1,status:u,filepaths:[l],sections:u==="edited"?Tl(_,p):[],fromJson:_,toJson:p??(u==="new"?m:null)});continue}const k=Fr(d,g??{});n.push({kind:"block",blockKey:d,name:k,pagePath:null,isSiteApp:Va(d,m??{}),status:u,filepaths:[l],sections:u==="edited"?[{name:k,kind:"section",status:"edited",fields:Gs(_,p,[])}].filter(b=>b.fields.length>0):[],fromJson:_,toJson:p})}return Ml({pages:r,blocks:n,other:o,generated:a})}function zd(t,e){const i=t?.[e];return i&&typeof i=="object"&&!Array.isArray(i)?i:null}function Wd(t,e){return t??e}function Nl(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}const kr=3;function Bs(t){if(t.length<=kr)return Nl(t);const e=t.length-kr;return`${t.slice(0,kr).join(", ")} and ${e} more`}function $d(t){const e=t.sections.filter(i=>i.kind==="section").map(i=>i.name).slice(0,3);return e.length>0?`${t.name} (${e.join(", ")})`:t.name}function Ud(t){const e=[],i=t.pages.filter(a=>a.status==="edited"),s=t.pages.filter(a=>a.status==="new"),r=t.pages.filter(a=>a.status==="removed");if(i.length>0&&e.push(`updated ${Bs(i.map($d))}`),s.length>0){const a=s.length===1?"page":"pages";e.push(`added the ${Bs(s.map(h=>h.name))} ${a}`)}if(r.length>0){const a=r.length===1?"page":"pages";e.push(`removed the ${Bs(r.map(h=>h.name))} ${a}`)}const n=t.blocks.map(a=>a.name);if(n.length>0&&e.push(`changed ${Bs(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=Nl(e);return kl(o.charAt(0).toUpperCase()+o.slice(1))}function Kd(t){return t?Ur(t).length:0}function qd(t){const e={newPageSections:t.kind==="page"&&t.status==="new"?Kd(t.toJson):null,sections:0,settings:!1,fields:0};if(e.newPageSections!==null)return e;for(const i of t.sections){if(i.kind==="settings"){e.settings=!0;continue}t.kind==="page"?e.sections+=1:e.fields+=i.fields.length}return e}function Qt(t){return t.filepaths[0]??t.blockKey??t.name}function Vd(t,e){return e(t==="new"?"thread.publishPopover.chipNew":t==="removed"?"thread.publishPopover.chipRemoved":"thread.publishPopover.chipEdited")}function Yd(t,e){const i=t.kind==="block"?Tc:$a;return c.jsx("span",{title:Vd(t.status,e),className:"flex shrink-0",children:c.jsx(i,{className:le("size-4",t.status==="new"&&"text-brand",t.status==="edited"&&"text-warning",t.status==="removed"&&"text-destructive")})})}function Gd(t,e){return t.kind==="page"?t.pagePath:t.kind!=="block"?null:t.isSiteApp?e("thread.publishPopover.siteConfiguration"):e("thread.publishPopover.globalSection")}function Xd(t,e){const i=qd(t);if(i.newPageSections!==null)return[i.newPageSections===1?e("thread.publishPopover.newPageSectionOne"):e("thread.publishPopover.newPageSections",{count:i.newPageSections})];const s=[];return i.sections===1?s.push(e("thread.publishPopover.sectionChangedOne")):i.sections>1&&s.push(e("thread.publishPopover.sectionsChanged",{count:i.sections})),i.fields===1?s.push(e("thread.publishPopover.fieldChangedOne")):i.fields>1&&s.push(e("thread.publishPopover.fieldsChanged",{count:i.fields})),i.settings&&s.push(e("thread.publishPopover.pageSettingsChanged")),s}function Jd(t){const e=U.c(41),{change:i,bodyPending:s,selected:r,onSelect:n,confirming:o,onConfirmingChange:a,onDiscard:h,isPublishing:l,isDiscarding:u}=t,d=s===void 0?!1:s,f=Be();let _;e[0]!==i||e[1]!==f?(_=Gd(i,f),e[0]=i,e[1]=f,e[2]=_):_=e[2];const p=_;let m;if(e[3]!==d||e[4]!==i||e[5]!==o||e[6]!==p||e[7]!==u||e[8]!==l||e[9]!==a||e[10]!==h||e[11]!==n||e[12]!==r||e[13]!==f){const g=Xd(i,f),v=d&&g.length===0&&i.status==="edited",k=r&&"border-foreground/30 bg-accent hover:bg-accent";let b;e[15]!==k?(b=le("cursor-pointer transition-colors hover:bg-accent/50",k),e[15]=k,e[16]=b):b=e[16];let w;e[17]!==i?(w=Qt(i),e[17]=i,e[18]=w):w=e[18];let C;e[19]!==i||e[20]!==f?(C=Yd(i,f),e[19]=i,e[20]=f,e[21]=C):C=e[21];let S;e[22]!==i.name?(S=c.jsx("span",{className:"truncate text-sm font-medium",children:i.name}),e[22]=i.name,e[23]=S):S=e[23];let R;e[24]!==p?(R=p?c.jsx("span",{className:"truncate text-xs text-muted-foreground",children:p}):null,e[24]=p,e[25]=R):R=e[25];let N;e[26]!==r||e[27]!==S||e[28]!==R?(N=c.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left","aria-pressed":r,children:[S,R]}),e[26]=r,e[27]=S,e[28]=R,e[29]=N):N=e[29];let I;e[30]!==o||e[31]!==u||e[32]!==l||e[33]!==a||e[34]!==h||e[35]!==f?(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:y=>{y.stopPropagation(),a(!1)},children:f("thread.publishDialog.cancel")}),c.jsx("button",{type:"button",className:"text-xs font-medium text-destructive disabled:opacity-50",onClick:y=>{y.stopPropagation(),a(!1),h?.()},disabled:u,children:f("thread.publishPopover.discard")})]}):h?c.jsx(nr,{children:c.jsxs(bt,{children:[c.jsx(St,{asChild:!0,children:c.jsx("button",{type:"button","aria-label":f("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:y=>{y.stopPropagation(),a(!0)},disabled:l||u,children:c.jsx(lr,{className:"size-3.5"})})}),c.jsx(wt,{children:f("thread.publishPopover.discard")})]})}):null,e[30]=o,e[31]=u,e[32]=l,e[33]=a,e[34]=h,e[35]=f,e[36]=I):I=e[36];let L;e[37]!==N||e[38]!==I||e[39]!==C?(L=c.jsxs("div",{className:"flex items-center gap-2.5",children:[C,N,I]}),e[37]=N,e[38]=I,e[39]=C,e[40]=L):L=e[40],m=c.jsxs(yl,{className:b,"data-change-id":w,onClick:n,children:[L,g.length>0?c.jsx("div",{className:"mt-1 space-y-0.5 pl-[26px] text-xs text-muted-foreground",children:g.map(Zd)}):v?c.jsx("div",{className:"mt-1 space-y-0.5 pl-[26px]",children:c.jsx(ti,{className:"h-4 w-2/3"})}):null]}),e[3]=d,e[4]=i,e[5]=o,e[6]=p,e[7]=u,e[8]=l,e[9]=a,e[10]=h,e[11]=n,e[12]=r,e[13]=f,e[14]=m}else m=e[14];return m}function Zd(t,e){return c.jsx("div",{className:"truncate",children:t},`${e}-${t}`)}function Qd(){const t=U.c(4);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={width:-1,height:-1},t[0]=e):e=t[0];const[i,s]=X.useState(e);let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=a=>{if(!a)return;const h=()=>s(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]!==i?(o=[i,n],t[2]=i,t[3]=o):o=t[3],o}function eu(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}const tu=[{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 bo(t){const e=U.c(10),{height:i}=t,s=Be();let r;e[0]!==i?(r={height:i},e[0]=i,e[1]=r):r=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=tu.map(iu),e[2]=n):n=e[2];let o;e[3]!==s?(o=s("thread.publishDialog.openingComparison"),e[3]=s,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 iu(t,e){return c.jsxs("div",{className:le("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:le("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:le("h-2 animate-pulse rounded-sm bg-muted",t.width,t.tone==="del"&&"bg-destructive/20",t.tone==="add"&&"bg-success/25")})]},e)}const Ol={readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12},su={...Ol,lineNumbersMinChars:3,lineDecorationsWidth:4,folding:!1,glyphMargin:!1,renderOverviewRuler:!1};function ru(t){const e=U.c(11),{diff:i,emptyMessage:s,rowClassName:r,onDiscardFile:n,hideFileRows:o,editorHeight:a}=t,h=s===void 0?"No file changes in the working tree":s,l=r===void 0?"px-6":r,u=o===void 0?!1:o,d=a===void 0?"380px":a,[f,_]=X.useState(null),[p,m]=X.useState(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=eu(),e[0]=g):g=e[0];const v=g;if(!i||Object.keys(i.diffs).length===0){let b;return e[1]!==h?(b=c.jsx("div",{className:"flex items-center justify-center py-10 text-sm text-muted-foreground",children:h}),e[1]=h,e[2]=b):b=e[2],b}let k;return e[3]!==i.diffs||e[4]!==p||e[5]!==d||e[6]!==f||e[7]!==u||e[8]!==n||e[9]!==l?(k=c.jsx("div",{className:"divide-y",children:Object.entries(i.diffs).map(b=>{const[w,C]=b,{from:S,to:R}=C,N=f===w,I=S===null,L=R===null,y=w.startsWith("/")?w.slice(1):w,E=y.lastIndexOf("/"),x=E>=0?y.slice(E+1):y,A=E>=0?y.slice(0,E):null,D=qc(w),P=I?"bg-success":L?"bg-destructive":"bg-warning";return u?c.jsx("div",{children:c.jsx(lo,{original:S??"",modified:R??"",language:D,theme:v,height:d,loading:c.jsx(bo,{height:d}),options:su})},w):c.jsxs("div",{children:[c.jsxs("div",{className:le("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:()=>_(N?null:w),children:c.jsx(Ea,{className:le("h-3.5 w-3.5 transition-transform",N&&"rotate-90")})}),c.jsx("div",{className:le("h-2.5 w-2.5 shrink-0 rounded-full",P)}),c.jsx($a,{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:x}),A&&c.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:A}),n?c.jsxs(us,{children:[c.jsx(cs,{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(Ih,{className:"h-3.5 w-3.5"})})}),c.jsx(ds,{align:"end",children:c.jsx(Ai,{className:"text-destructive focus:text-destructive",onSelect:()=>m(w),children:"Discard changes"})})]}):null]}),p===w&&n?c.jsxs("div",{className:le("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:x}),"? This cannot be undone."]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[c.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>m(null),children:"Cancel"}),c.jsx(pe,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:()=>{m(null),n(w)},children:"Discard"})]})]}):null,N&&c.jsx("div",{className:"border-t",children:c.jsx(lo,{original:S??"",modified:R??"",language:D,theme:v,height:d,loading:c.jsx(bo,{height:d}),options:Ol})})]},w)})}),e[3]=i.diffs,e[4]=p,e[5]=d,e[6]=f,e[7]=u,e[8]=n,e[9]=l,e[10]=k):k=e[10],k}function nu(t){if(t.kind!=="block"||t.isSiteApp||!t.blockKey)return null;const e=(t.toJson??t.fromJson)?.__resolveType;return typeof e=="string"&&gc(e)?t.blockKey:null}function ou(t){return t.kind!=="page"?!0:!t.pagePath||os(t.pagePath).length>0}function au(t,e){try{return Yc(t,vc,e)}catch{return null}}function lu(t,e){if(t.kind!=="page")return"/";const i=t.pagePath;if(!i)return"";if(os(i).length===0)return i;if(e?.path!==i)return"";const s=Ya(i,e.params);return os(s).length===0?s:""}function hu(t,e){const i=e.trim();if(!i||os(i).length>0)return null;try{const s=new URL(t),r=new URL(i.startsWith("/")?i:`/${i}`,s);return r.origin===s.origin?r:null}catch{return null}}function cu(t,e){if(!e)return null;if(e.kind==="pointer")return ml(t.toString(),e.pointer);try{return new URL(`${t.pathname}${t.search}`,e.previewUrl).href}catch{return null}}function du(t,e,i){return e===null?!1:t!=="other"||i?.kind==="sandbox"}const uu=["split","before","after","code"];function fu(t){return uu.includes(t)}const _u={desktop:1280,mobile:412};function pu(t){const e=U.c(90),{change:i,diff:s,bodyPending:r,previewServerUrl:n,draft:o,lastPage:a}=t,h=Be();let l;e[0]!==i.kind||e[1]!==o||e[2]!==n?(l=du(i.kind,n,o),e[0]=i.kind,e[1]=o,e[2]=n,e[3]=l):l=e[3];const u=l,[d,f]=X.useState(null),_=u?d??"split":"code",[p,m]=X.useState("desktop"),[g,v]=X.useState(null);let k,b,w,C,S,R;if(e[4]!==i||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==g){b=g??lu(i,a),C=nu(i);let ie;e[15]!==i?(ie=ou(i),e[15]=i,e[16]=ie):ie=e[16],w=ie,R=n?C?au(n,C):hu(n,b):null,k=R?ml(R.toString(),Gc):null,S=R?cu(R,o):null,e[4]=i,e[5]=o,e[6]=a,e[7]=n,e[8]=g,e[9]=k,e[10]=b,e[11]=w,e[12]=C,e[13]=S,e[14]=R}else k=e[9],b=e[10],w=e[11],C=e[12],S=e[13],R=e[14];const N=S;let I;if(e[17]!==i.filepaths||e[18]!==s?.diffs){let ie;e[20]!==s?.diffs?(ie=de=>{const z=s?.diffs[de];return z?[[de,z]]:[]},e[20]=s?.diffs,e[21]=ie):ie=e[21],I={diffs:Object.fromEntries(i.filepaths.flatMap(ie))},e[17]=i.filepaths,e[18]=s?.diffs,e[19]=I}else I=e[19];const L=I;let y;e[22]!==L.diffs?(y=Object.keys(L.diffs),e[22]=L.diffs,e[23]=y):y=e[23];const E=y.length>0;let x;e[24]!==i.kind||e[25]!==i.pagePath||e[26]!==C||e[27]!==h?(x=C!==null?null:i.kind!=="page"?h("thread.publishCompare.globalHint"):i.pagePath&&os(i.pagePath).length>0?h("thread.publishCompare.dynamicHint",{template:i.pagePath}):null,e[24]=i.kind,e[25]=i.pagePath,e[26]=C,e[27]=h,e[28]=x):x=e[28];const A=x;let D;e[29]!==k||e[30]!==i.kind||e[31]!==i.status||e[32]!==p||e[33]!==h?(D=i.status==="new"&&i.kind!=="other"?c.jsx(yo,{icon:c.jsx(Mn,{className:"size-5 text-brand"}),title:h("thread.publishCompare.newTitle"),description:h("thread.publishCompare.newDescription")}):c.jsx(xo,{url:k,device:p,title:h("thread.publishCompare.before"),missing:h("thread.publishCompare.enterPath")}),e[29]=k,e[30]=i.kind,e[31]=i.status,e[32]=p,e[33]=h,e[34]=D):D=e[34];const P=D;let B;e[35]!==N||e[36]!==i.kind||e[37]!==i.status||e[38]!==p||e[39]!==h||e[40]!==R?(B=i.status==="removed"&&i.kind!=="other"?c.jsx(yo,{icon:c.jsx(lr,{className:"size-5 text-destructive"}),title:h("thread.publishCompare.removedTitle"),description:h("thread.publishCompare.removedDescription")}):c.jsx(xo,{url:N,device:p,title:h("thread.publishCompare.after"),missing:h(R?"thread.publishCompare.draftUnavailable":"thread.publishCompare.enterPath")}),e[35]=N,e[36]=i.kind,e[37]=i.status,e[38]=p,e[39]=h,e[40]=R,e[41]=B):B=e[41];const M=B;let K;e[42]===Symbol.for("react.memo_cache_sentinel")?(K=ie=>{fu(ie)&&f(ie)},e[42]=K):K=e[42];let F;e[43]!==u||e[44]!==h?(F=u?c.jsxs(c.Fragment,{children:[c.jsx(Pi,{value:"split",className:"px-3 text-xs",children:h("thread.publishCompare.sideBySide")}),c.jsx(Pi,{value:"before",className:"px-3 text-xs",children:h("thread.publishCompare.before")}),c.jsx(Pi,{value:"after",className:"px-3 text-xs",children:h("thread.publishCompare.after")})]}):null,e[43]=u,e[44]=h,e[45]=F):F=e[45];let H;e[46]!==h?(H=h("thread.publishCompare.code"),e[46]=h,e[47]=H):H=e[47];let Y;e[48]!==H?(Y=c.jsx(Pi,{value:"code",className:"px-3 text-xs",children:H}),e[48]=H,e[49]=Y):Y=e[49];let q;e[50]!==Y||e[51]!==F?(q=c.jsxs(za,{className:"h-8 w-auto",variant:"pill",children:[F,Y]}),e[50]=Y,e[51]=F,e[52]=q):q=e[52];let te;e[53]!==q||e[54]!==_?(te=c.jsx(Wa,{value:_,onValueChange:K,children:q}),e[53]=q,e[54]=_,e[55]=te):te=e[55];let J;e[56]!==N||e[57]!==u||e[58]!==i.pagePath||e[59]!==p||e[60]!==b||e[61]!==w||e[62]!==C||e[63]!==h||e[64]!==_?(J=u&&_!=="code"?c.jsxs(c.Fragment,{children:[C?null:w?c.jsx(jh,{value:b,onChange:ie=>v(ie.target.value),placeholder:i.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:b}),c.jsxs("div",{className:"flex items-center rounded-lg border p-0.5",children:[c.jsx(So,{active:p==="desktop",label:h("thread.publishCompare.desktop"),onClick:()=>m("desktop"),children:c.jsx(Vc,{className:"size-3.5"})}),c.jsx(So,{active:p==="mobile",label:h("thread.publishCompare.mobile"),onClick:()=>m("mobile"),children:c.jsx(hc,{className:"size-3.5"})})]}),N?c.jsxs("a",{href:N,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(Hh,{className:"size-3.5"}),h("thread.publishCompare.openDraft")]}):null]}):null,e[56]=N,e[57]=u,e[58]=i.pagePath,e[59]=p,e[60]=b,e[61]=w,e[62]=C,e[63]=h,e[64]=_,e[65]=J):J=e[65];let Q;e[66]!==te||e[67]!==J?(Q=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:[te,J]}),e[66]=te,e[67]=J,e[68]=Q):Q=e[68];let W;e[69]!==u||e[70]!==A||e[71]!==_?(W=A&&u&&_!=="code"?c.jsx("p",{className:"border-b bg-background px-4 py-1.5 text-[11px] text-muted-foreground",children:A}):null,e[69]=u,e[70]=A,e[71]=_,e[72]=W):W=e[72];let G;e[73]!==r||e[74]!==E||e[75]!==L||e[76]!==h||e[77]!==_?(G=_==="code"?c.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto bg-background [scrollbar-width:thin]",children:E?c.jsx(ru,{diff:L,hideFileRows:!0,editorHeight:"70vh"}):r?c.jsx(ti,{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[73]=r,e[74]=E,e[75]=L,e[76]=h,e[77]=_,e[78]=G):G=e[78];let ee;e[79]!==M||e[80]!==P||e[81]!==u||e[82]!==h||e[83]!==_?(ee=u?c.jsxs("div",{className:le("flex min-h-0 flex-1 gap-3 p-3",_==="code"&&"hidden"),children:[c.jsx(wo,{label:h("thread.publishCompare.before"),hidden:_==="after",children:P}),c.jsx(wo,{label:h("thread.publishCompare.after"),highlight:!0,hidden:_==="before",children:M})]}):null,e[79]=M,e[80]=P,e[81]=u,e[82]=h,e[83]=_,e[84]=ee):ee=e[84];let ue;return e[85]!==Q||e[86]!==W||e[87]!==G||e[88]!==ee?(ue=c.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/40",children:[Q,W,G,ee]}),e[85]=Q,e[86]=W,e[87]=G,e[88]=ee,e[89]=ue):ue=e[89],ue}function So(t){const e=U.c(8),{active:i,label:s,onClick:r,children:n}=t,o=i&&"bg-accent text-foreground";let a;e[0]!==o?(a=le("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]!==i||e[3]!==n||e[4]!==s||e[5]!==r||e[6]!==a?(h=c.jsx("button",{type:"button","aria-label":s,"aria-pressed":i,title:s,onClick:r,className:a,children:n}),e[2]=i,e[3]=n,e[4]=s,e[5]=r,e[6]=a,e[7]=h):h=e[7],h}function wo(t){const e=U.c(18),{label:i,highlight:s,hidden:r,children:n}=t,o=s===void 0?!1:s,h=(r===void 0?!1:r)&&"hidden";let l;e[0]!==h?(l=le("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=le("size-1.5 rounded-full bg-muted-foreground/50",u),e[2]=u,e[3]=d):d=e[3];let f;e[4]!==d?(f=c.jsx("span",{className:d}),e[4]=d,e[5]=f):f=e[5];let _;e[6]!==i||e[7]!==f?(_=c.jsxs("div",{className:"flex items-center gap-1.5 px-0.5 text-[11px] font-medium tracking-wider text-muted-foreground uppercase",children:[f,i]}),e[6]=i,e[7]=f,e[8]=_):_=e[8];const p=o&&"border-brand/60";let m;e[9]!==p?(m=le("relative min-h-0 flex-1 overflow-hidden rounded-lg border bg-background",p),e[9]=p,e[10]=m):m=e[10];let g;e[11]!==n||e[12]!==m?(g=c.jsx("div",{className:m,children:n}),e[11]=n,e[12]=m,e[13]=g):g=e[13];let v;return e[14]!==g||e[15]!==l||e[16]!==_?(v=c.jsxs("div",{className:l,children:[_,g]}),e[14]=g,e[15]=l,e[16]=_,e[17]=v):v=e[17],v}function yo(t){const e=U.c(10),{icon:i,title:s,description:r}=t;let n;e[0]!==i?(n=c.jsx("div",{className:"mb-1",children:i}),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==s?(o=c.jsx("p",{className:"text-sm font-medium",children:s}),e[2]=s,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 xo(t){const e=U.c(24),{url:i,device:s,title:r,missing:n}=t,[o,a]=Qd(),[h,l]=X.useState(null);if(!i){let S;return e[0]!==n?(S=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]=S):S=e[1],S}let u;e[2]!==s||e[3]!==i?(u=Pc(i,s),e[2]=s,e[3]=i,e[4]=u):u=e[4];const d=u,f=_u[s],_=o.width>0?Math.min(o.width/f,1):1,p=o.width>0?Math.max((o.width-f*_)/2,0):0;let m;e[5]!==d?(m=()=>l(d),e[5]=d,e[6]=m):m=e[6];const g=o.height>0?o.height/_:"100%",v=`scale(${_})`;let k;e[7]!==f||e[8]!==p||e[9]!==g||e[10]!==v?(k={left:p,width:f,height:g,transform:v,transformOrigin:"top left"},e[7]=f,e[8]=p,e[9]=g,e[10]=v,e[11]=k):k=e[11];let b;e[12]!==d||e[13]!==m||e[14]!==k||e[15]!==r?(b=c.jsx("iframe",{src:d,title:r,sandbox:"allow-scripts allow-same-origin",onLoad:m,className:"absolute top-0 border-0 bg-white",style:k},d),e[12]=d,e[13]=m,e[14]=k,e[15]=r,e[16]=b):b=e[16];let w;e[17]!==h||e[18]!==d?(w=h!==d?c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/60",children:c.jsx(rs,{className:"size-5 motion-reduce:animate-none"})}):null,e[17]=h,e[18]=d,e[19]=w):w=e[19];let C;return e[20]!==a||e[21]!==b||e[22]!==w?(C=c.jsxs("div",{ref:a,className:"absolute inset-0",children:[b,w]}),e[20]=a,e[21]=b,e[22]=w,e[23]=C):C=e[23],C}const mu=/^Co-authored-by:\s*([^<\r\n]+?)(?:\s*<[^>\r\n]*>)?\s*$/im;function gu(t){if(!t)return null;const e=mu.exec(t)?.[1]?.trim();return e||null}function vu(t){return/\[bot\]$/i.test(t)||/-bot$/i.test(t)}function bu(t){const e=gu(t.body);if(e)return e;const i=t.author.trim();return!i||vu(i)?null:i}function Su(t){const{mode:e,target:i,note:s,allPaths:r,destinationHost:n,publishLockRef:o,onOpenChange:a,refresh:h,onPullRequestChanged:l,onPublished:u}=t,d=Be(),[f,_]=X.useState(!1),[p,m]=X.useState(!1),[g,v]=X.useState(),k=()=>Bd(s,d("thread.publishDialog.changesFrom",{branch:i.headBranch})),b=async()=>{o.current=!0,_(!0),v(void 0);try{await Ad(i,k(),d),Xe.success(n?d("thread.publishPopover.publishedTo",{host:n}):d("thread.publishDialog.publishedTo",{baseBranch:i.baseBranch})),a(!1),await Promise.all([l?.(),u?.()])}catch(S){const R=go(S,d);v(R.message),R.pullRequestOpened&&await l?.(),R.headMoved&&await h()}finally{o.current=!1,_(!1)}},w=async()=>{o.current=!0,_(!0),v(void 0);try{const S=await Td(i,k());Ld(S,d),a(!1),await l?.()}catch(S){const R=go(S,d);v(R.message||d("thread.publishDialog.failedSubmitForReview")),R.headMoved&&await h()}finally{o.current=!1,_(!1)}},C=async(S,R)=>{m(!0);try{await Oc({orgSlug:i.orgSlug,virtualMcpId:i.virtualMcpId,branch:i.branch,threadId:i.threadId},S),Xe.success(R),await h()}catch(N){Xe.error(N instanceof Error?N.message:d("thread.publishPopover.failedDiscard"))}finally{m(!1)}};return{isPublishing:f,isDiscarding:p,publishError:g,submit:e==="review"?w:b,discardChange:S=>C(S.filepaths,d("thread.publishPopover.discarded",{name:S.name})),discardAll:async()=>{r.length!==0&&await C(r,d("thread.publishDialog.allChangesDiscarded"))}}}function wu(t,e,i,s,r,n){return["cms-publish-bodies",t,e,i,s,r,n]}const yu=6e4;function xu(t,e){return e?null:t.files.map(i=>`${i.index}${i.working_dir} ${i.path}`).sort().join(`
10
+ `)}function Cu(t,e,i){const s=U.c(6);let r;s[0]!==i||s[1]!==t||s[2]!==e?(r=An.decofile(`${t}/${e}/${i}`),s[0]=i,s[1]=t,s[2]=e,s[3]=r):r=s[3];let n;s[4]!==r?(n={queryKey:r,queryFn:zh},s[4]=r,s[5]=n):n=s[5];const{data:o}=zi(n);return o}function ku(t){const{orgSlug:e,virtualMcpId:i,branch:s,threadId:r,baseBranch:n,fastPreview:o,recoverSandbox:a}=t,h={orgSlug:e,virtualMcpId:i,branch:s,threadId:r},l=o?{fastPreview:!0}:void 0,u=X.useRef(null),d=async C=>{try{return await C()}catch(S){if(!a||!ul(S))throw S;return u.current??=a(),await u.current,C()}},f=Fh({...dl(h),queryFn:()=>d(()=>jn(h))}),_=f.data,p=_.changedFiles??null,m=_.headSha??null,g=p?p.length>0:Ic(_)||jc(_),v=zi({queryKey:wu(e,i,s,n,m,xu(_,o)),queryFn:()=>d(()=>ll(h,_,n,l)),enabled:g,staleTime:o?yu:0,gcTime:o?void 0:0,throwOnError:(C,S)=>!p&&S.state.data===void 0}),k=Cu(e,i,s),b=v.data??null,w=p?Ll({files:p,lookup:k,diff:b}):jd(b);return{status:_,summary:w,allPaths:p?p.map(C=>C.path):Object.keys(b?.diffs??{}),discardablePaths:o?null:new Set(_.files.map(C=>C.path)),changedFilesTotal:_.changedFilesTotal??w.count,changedFilesTruncated:_.changedFilesTruncated??!1,headSha:m,diff:b,bodiesPending:g&&v.isPending,bodiesFailed:v.isError,cardsPending:!p&&g&&v.isPending,refresh:()=>Promise.all([f.refetch(),o?null:v.refetch()])}}function Eu(t){return["smart-review-verdict",t.orgSlug,t.virtualMcpId,t.branch,t.threadId,t.fastPreview?"fast-preview-upstream":"sandbox",t.signature,t.language]}function Pu(t){const e=U.c(27),{orgSlug:i,virtualMcpId:s,branch:r,threadId:n,fastPreview:o,status:a,diff:h,enabled:l}=t,[u]=Wh(),{language:d}=u;let f,_,p;if(e[0]!==r||e[1]!==h||e[2]!==l||e[3]!==o||e[4]!==d||e[5]!==i||e[6]!==a||e[7]!==n||e[8]!==s){const C=h?Hn(h):"";f=l&&!!r&&!!a&&!!h&&C!=="",p=zi,_=Eu({orgSlug:i,virtualMcpId:s,branch:r,threadId:n,fastPreview:o,signature:C,language:d}),e[0]=r,e[1]=h,e[2]=l,e[3]=o,e[4]=d,e[5]=i,e[6]=a,e[7]=n,e[8]=s,e[9]=f,e[10]=_,e[11]=p}else f=e[9],_=e[10],p=e[11];let m;e[12]!==r||e[13]!==h||e[14]!==d||e[15]!==i||e[16]!==a||e[17]!==n||e[18]!==s?(m=()=>Hc({orgSlug:i,virtualMcpId:s,branch:r,threadId:n},{status:a,diff:h,language:d}),e[12]=r,e[13]=h,e[14]=d,e[15]=i,e[16]=a,e[17]=n,e[18]=s,e[19]=m):m=e[19];let g;e[20]!==f||e[21]!==_||e[22]!==m?(g={queryKey:_,queryFn:m,enabled:f,staleTime:1/0,gcTime:6e5,retry:Ru},e[20]=f,e[21]=_,e[22]=m,e[23]=g):g=e[23];const v=p(g),k=v.data??null,b=f&&v.isFetching&&!v.data;let w;return e[24]!==k||e[25]!==b?(w={verdict:k,loading:b},e[24]=k,e[25]=b,e[26]=w):w=e[26],w}function Ru(t,e){return!ul(e)&&t<1}function Bu(t){const e=U.c(30),{orgSlug:i,virtualMcpId:s,branch:r,threadId:n,fastPreview:o,status:a,diff:h,policy:l,judgeEnabled:u,paths:d}=t,f=u===void 0?!0:u,_=d===void 0?null:d;let p;e[0]!==h||e[1]!==f||e[2]!==l?(p=f&&Fc(h,l),e[0]=h,e[1]=f,e[2]=l,e[3]=p):p=e[3];const m=p;let g;e[4]!==r||e[5]!==h||e[6]!==o||e[7]!==m||e[8]!==i||e[9]!==a||e[10]!==n||e[11]!==s?(g={orgSlug:i,virtualMcpId:s,branch:r,threadId:n,fastPreview:o,status:a,diff:h,enabled:m},e[4]=r,e[5]=h,e[6]=o,e[7]=m,e[8]=i,e[9]=a,e[10]=n,e[11]=s,e[12]=g):g=e[12];const{verdict:v,loading:k}=Pu(g);if(!h&&_){let S;e[13]!==_||e[14]!==l?(S=zc(_,l),e[13]=_,e[14]=l,e[15]=S):S=e[15];let R;return e[16]!==S?(R={gate:S,ready:!1},e[16]=S,e[17]=R):R=e[17],R}if(!h){let S;return e[18]===Symbol.for("react.memo_cache_sentinel")?(S={gate:{allowed:!0,reason:null},ready:!1},e[18]=S):S=e[18],S}if(!m){let S;e[19]!==h||e[20]!==l?(S=Wc(h,l),e[19]=h,e[20]=l,e[21]=S):S=e[21];let R;return e[22]!==S?(R={gate:S,ready:!0},e[22]=S,e[23]=R):R=e[23],R}let b;e[24]!==k||e[25]!==v?(b=$c(v,k),e[24]=k,e[25]=v,e[26]=b):b=e[26];const w=!k;let C;return e[27]!==b||e[28]!==w?(C={gate:b,ready:w},e[27]=b,e[28]=w,e[29]=C):C=e[29],C}function Il(t){const e=U.c(16),i=X.useRef(!1),s=Be();let r;e[0]!==t?(r=d=>{!d&&i.current||t.onOpenChange(d)},e[0]=t,e[1]=r):r=e[1];const n=r;let o;e[2]!==t.mode||e[3]!==s?(o=t.mode==="review"?s("thread.publishPopover.submitForReview"):s("thread.publishPopover.publish"),e[2]=t.mode,e[3]=s,e[4]=o):o=e[4];let a;e[5]!==o?(a=c.jsx(Uh,{className:"sr-only",children:o}),e[5]=o,e[6]=a):a=e[6];let h;e[7]!==t?(h=t.open?c.jsx(Lu,{...t,publishLockRef:i}):null,e[7]=t,e[8]=h):h=e[8];let l;e[9]!==a||e[10]!==h?(l=c.jsxs(Kh,{"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($h,{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 Du(t){return["main","master"].includes(t.trim().toLowerCase())}const Au=4,Xs="flex h-[45%] min-h-0 min-w-0 shrink-0 md:h-auto md:flex-1";function Wn(t){const e=U.c(5),{list:i,pane:s}=t;let r;e[0]!==i?(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:i}),e[0]=i,e[1]=r):r=e[1];let n;return e[2]!==s||e[3]!==r?(n=c.jsxs(c.Fragment,{children:[s,r]}),e[2]=s,e[3]=r,e[4]=n):n=e[4],n}function jl(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx("div",{className:le(Xs,"bg-muted/40 p-3"),children:c.jsx(ti,{className:"h-full w-full rounded-lg"})}),t[0]=e):e=t[0],e}function $n(t){const e=U.c(11),{mode:i,title:s,subLine:r,trailing:n}=t,o=i==="review"?ar:cc;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]!==s||e[4]!==n?(h=c.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a,s,n]}),e[2]=a,e[3]=s,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 Un(t){const e=U.c(9),{draftPreviewUrl:i,t:s}=t;let r;e[0]!==i?(r=()=>{i&&window.open(i,"_blank","noopener,noreferrer")},e[0]=i,e[1]=r):r=e[1];const n=!i;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(al,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==s?(a=s("thread.publishPopover.preview"),e[3]=s,e[4]=a):a=e[4];let h;return e[5]!==r||e[6]!==n||e[7]!==a?(h=c.jsxs(pe,{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 Tu(t){const e=U.c(21),{mode:i,draftPreviewUrl:s}=t,r=Be();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=c.jsx(jl,{}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(ti,{className:"h-3.5 w-48"}),e[1]=o):o=e[1];let a;e[2]!==i?(a=c.jsx($n,{mode:i,title:o}),e[2]=i,e[3]=a):a=e[3];let h,l;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(Wr,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(is,{}),c.jsx(is,{}),c.jsx(is,{})]})}),l=c.jsxs(c.Fragment,{children:[c.jsx(ti,{className:"h-3 w-20"}),c.jsx(ti,{className:"h-14 w-full rounded-lg"})]}),e[4]=h,e[5]=l):(h=e[4],l=e[5]);let u;e[6]!==s||e[7]!==r?(u=c.jsx(Un,{draftPreviewUrl:s,t:r}),e[6]=s,e[7]=r,e[8]=u):u=e[8];const d=i==="review"?"default":"brand";let f;e[9]!==i||e[10]!==r?(f=r(i==="review"?"thread.publishPopover.submitForReview":"thread.publishPopover.publish"),e[9]=i,e[10]=r,e[11]=f):f=e[11];let _;e[12]!==d||e[13]!==f?(_=c.jsx(pe,{type:"button",variant:d,className:"flex-1",disabled:!0,children:f}),e[12]=d,e[13]=f,e[14]=_):_=e[14];let p;e[15]!==u||e[16]!==_?(p=c.jsxs("div",{className:"flex gap-2",children:[u,_]}),e[15]=u,e[16]=_,e[17]=p):p=e[17];let m;return e[18]!==p||e[19]!==a?(m=c.jsx(Wn,{pane:n,list:c.jsx(Fn,{state:"loading",header:a,body:h,note:l,footer:p})}),e[18]=p,e[19]=a,e[20]=m):m=e[20],m}function Mu(t){const e=U.c(26),{mode:i,draftPreviewUrl:s,message:r,onRetry:n}=t,o=Be();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx("div",{className:le(Xs,"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]!==i||e[6]!==l?(u=c.jsx($n,{mode:i,title:l}),e[5]=i,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 f;e[10]!==s||e[11]!==o?(f=c.jsx(Un,{draftPreviewUrl:s,t:o}),e[10]=s,e[11]=o,e[12]=f):f=e[12];let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsx(ns,{className:"size-4"}),e[13]=_):_=e[13];let p;e[14]!==o?(p=o("thread.publishPopover.retry"),e[14]=o,e[15]=p):p=e[15];let m;e[16]!==n||e[17]!==p?(m=c.jsxs(pe,{type:"button",variant:"outline",className:"flex-1",onClick:n,children:[_,p]}),e[16]=n,e[17]=p,e[18]=m):m=e[18];let g;e[19]!==f||e[20]!==m?(g=c.jsxs("div",{className:"flex gap-2",children:[f,m]}),e[19]=f,e[20]=m,e[21]=g):g=e[21];let v;return e[22]!==g||e[23]!==u||e[24]!==d?(v=c.jsx(Wn,{pane:a,list:c.jsx(Fn,{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 Lu(t){const e=U.c(3),i=t.mode??"publish";let s;return e[0]!==i||e[1]!==t?(s=c.jsx(qh,{children:r=>{const{reset:n}=r;return c.jsx(Vh,{fallback:o=>{const{error:a,resetError:h}=o;return c.jsx(Mu,{mode:i,draftPreviewUrl:t.draftPreviewUrl,message:a?.message??"",onRetry:()=>{n(),h()}})},children:c.jsx(X.Suspense,{fallback:c.jsx(Tu,{mode:i,draftPreviewUrl:t.draftPreviewUrl}),children:c.jsx(Nu,{...t})})})}}),e[0]=i,e[1]=t,e[2]=s):s=e[2],s}function Nu(t){const e=U.c(139),{publishLockRef:i,onOpenChange:s,mode:r,fastPreview:n,recoverSandbox:o,orgSlug:a,virtualMcpId:h,branch:l,baseBranch:u,repoTarget:d,owner:f,repo:_,publishPolicy:p,draftPreviewUrl:m,destinationHost:g,previewServerUrl:v,compareDraft:k,lastPublishedPr:b,onRequestApproval:w,openPullRequest:C,onPullRequestChanged:S,onPublished:R}=t,N=r===void 0?"publish":r,I=b===void 0?null:b,L=C===void 0?null:C,y=Be(),E=Wi()?.taskId??null,{data:x}=sr.useSession(),A=il(sl(a,h,l));let D;e[0]!==u||e[1]!==l||e[2]!==n||e[3]!==a||e[4]!==o||e[5]!==E||e[6]!==h?(D={orgSlug:a,virtualMcpId:h,branch:l,threadId:E,baseBranch:u,fastPreview:n,recoverSandbox:o},e[0]=u,e[1]=l,e[2]=n,e[3]=a,e[4]=o,e[5]=E,e[6]=h,e[7]=D):D=e[7];const{status:P,summary:B,allPaths:M,discardablePaths:K,changedFilesTotal:F,changedFilesTruncated:H,headSha:Y,diff:q,bodiesPending:te,bodiesFailed:J,cardsPending:Q,refresh:W}=ku(D),[G,ee]=X.useState(null),[ue,ie]=X.useState(!1),[de,z]=X.useState(null);let ge;e[8]===Symbol.for("react.memo_cache_sentinel")?(ge=[],e[8]=ge):ge=e[8];const[fe,Le]=X.useState(ge);let oe;e[9]===Symbol.for("react.memo_cache_sentinel")?(oe=ae=>{z(ae),Le(ve=>[ae,...ve.filter(Se=>Se!==ae)])},e[9]=oe):oe=e[9];const $=oe,[De,At]=X.useState(null);let Ye;e[10]!==G||e[11]!==B?(Ye=Wd(G,Ud(B)),e[10]=G,e[11]=B,e[12]=Ye):Ye=e[12];const He=Ye,it=[...B.pages,...B.blocks,...B.other],Ne=it.find(ae=>Qt(ae)===de)??it[0]??null,yt=Ne?Qt(Ne):null,Wt=[...new Set([...yt?[yt]:[],...fe,...it.map(Qt)])].filter(ae=>it.some(ve=>Qt(ve)===ae)).slice(0,Au),ce=N==="review",Ke=Q?"loading":te?"manifest":"ready",qe=!ce;let V;e[13]!==M||e[14]!==l||e[15]!==n||e[16]!==q||e[17]!==P||e[18]!==a||e[19]!==p||e[20]!==qe||e[21]!==E||e[22]!==h?(V={orgSlug:a,virtualMcpId:h,branch:l,threadId:E,fastPreview:n,status:P,diff:q,paths:M,policy:p,judgeEnabled:qe},e[13]=M,e[14]=l,e[15]=n,e[16]=q,e[17]=P,e[18]=a,e[19]=p,e[20]=qe,e[21]=E,e[22]=h,e[23]=V):V=e[23];const{gate:_e}=Bu(V),Ae=L?.state==="open";let ye;e[24]!==l||e[25]!==P?(ye=fl(P)??l,e[24]=l,e[25]=P,e[26]=ye):ye=e[26];const Je=x?.user;let nt;e[27]!==Je?(nt=wl(Je),e[27]=Je,e[28]=nt):nt=e[28];const xt=Y??void 0;let ot;e[29]!==n||e[30]!==q?(ot=!n&&q?{expectedDiffSignature:Hn(q)}:{},e[29]=n,e[30]=q,e[31]=ot):ot=e[31];let Tt;e[32]!==u||e[33]!==l||e[34]!==n||e[35]!==a||e[36]!==f||e[37]!==_||e[38]!==d||e[39]!==ye||e[40]!==nt||e[41]!==xt||e[42]!==ot||e[43]!==E||e[44]!==h?(Tt={orgSlug:a,virtualMcpId:h,branch:l,threadId:E,fastPreview:n,baseBranch:u,target:d,owner:f,repo:_,headBranch:ye,coAuthor:nt,expectedHeadSha:xt,...ot},e[32]=u,e[33]=l,e[34]=n,e[35]=a,e[36]=f,e[37]=_,e[38]=d,e[39]=ye,e[40]=nt,e[41]=xt,e[42]=ot,e[43]=E,e[44]=h,e[45]=Tt):Tt=e[45];const $t=Tt;let Mt;e[46]!==M||e[47]!==g||e[48]!==N||e[49]!==He||e[50]!==s||e[51]!==R||e[52]!==S||e[53]!==i||e[54]!==W||e[55]!==$t?(Mt={mode:N,target:$t,note:He,allPaths:M,destinationHost:g,publishLockRef:i,onOpenChange:s,refresh:W,onPullRequestChanged:S,onPublished:R},e[46]=M,e[47]=g,e[48]=N,e[49]=He,e[50]=s,e[51]=R,e[52]=S,e[53]=i,e[54]=W,e[55]=$t,e[56]=Mt):Mt=e[56];const{isPublishing:ke,isDiscarding:Ct,publishError:Lt,submit:Ut,discardChange:ni,discardAll:Kt}=Su(Mt);let Nt;e[57]!==K?(Nt=ae=>K===null||ae.every(ve=>K.has(ve)),e[57]=K,e[58]=Nt):Nt=e[58];const Ot=Nt,qt=!ke&&B.count>0&&(ce||_e.allowed);let It;e[59]!==u||e[60]!==ce||e[61]!==B.count||e[62]!==y?(It=ce?B.count===0?y("thread.publishPopover.submitForReview"):B.count===1?y("thread.publishPopover.submitOneForReview"):y("thread.publishPopover.submitCountForReview",{count:B.count}):B.count===0?y("thread.publishPopover.publish"):Du(u)?B.count===1?y("thread.publishPopover.publishOneInProduction"):y("thread.publishPopover.publishCountInProduction",{count:B.count}):B.count===1?y("thread.publishPopover.publishOne"):y("thread.publishPopover.publishCount",{count:B.count}),e[59]=u,e[60]=ce,e[61]=B.count,e[62]=y,e[63]=It):It=e[63];const Vt=It;let jt;e:{if(ce&&Ae){let Se;e[64]!==L.number||e[65]!==y?(Se=y("thread.publishPopover.updatesPullRequest",{number:L.number}),e[64]=L.number,e[65]=y,e[66]=Se):Se=e[66],jt=Se;break e}const ae=I;if(!ae?.mergedAt){jt=null;break e}let ve;if(e[67]!==ae||e[68]!==y){const Se=Ac(new Date(ae.mergedAt)),se=bu(ae);ve=se?y("thread.publishPopover.lastPublishedBy",{when:Se,name:se}):y("thread.publishPopover.lastPublished",{when:Se}),e[67]=ae,e[68]=y,e[69]=ve}else ve=e[69];jt=ve}const Yt=jt;let Ht;e[70]!==ce||e[71]!==B.count||e[72]!==y?(Ht=ce?y("thread.publishPopover.submitForReview"):B.count===1?y("thread.publishPopover.publishOne"):B.count>1?y("thread.publishPopover.publishCount",{count:B.count}):y("thread.publishPopover.publish"),e[70]=ce,e[71]=B.count,e[72]=y,e[73]=Ht):Ht=e[73];const fi=Ht,Gt=(ae,ve)=>ve.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:ae}),ve.map(Se=>{const se=Qt(Se);return c.jsx(Jd,{change:Se,bodyPending:te,selected:Ne!==null&&Qt(Ne)===se,onSelect:()=>$(se),confirming:De===se,onConfirmingChange:st=>At(st?se:null),onDiscard:Ot(Se.filepaths)?()=>{ni(Se)}:void 0,isPublishing:ke,isDiscarding:Ct},se)})]});let kt;e:{if(ce||B.count===0){kt=null;break e}if(_e.pending){let se;e[74]===Symbol.for("react.memo_cache_sentinel")?(se=c.jsx(rs,{className:"size-3.5 motion-reduce:animate-none"}),e[74]=se):se=e[74];let st;e[75]!==y?(st=y("thread.publishPopover.reviewing"),e[75]=y,e[76]=st):st=e[76];let Oi;e[77]!==st?(Oi=c.jsxs("div",{className:"flex items-center gap-2 border-t px-4 py-2.5 text-xs text-muted-foreground",children:[se,st]}),e[77]=st,e[78]=Oi):Oi=e[78],kt=Oi;break e}if(_e.allowed){kt=null;break e}let ae;e[79]===Symbol.for("react.memo_cache_sentinel")?(ae=c.jsx(Pa,{className:"mt-0.5 size-3.5 shrink-0"}),e[79]=ae):ae=e[79];let ve;e[80]!==_e.reason||e[81]!==y?(ve=_e.reason??y("thread.publishPopover.needsReviewGeneric"),e[80]=_e.reason,e[81]=y,e[82]=ve):ve=e[82];let Se;e[83]!==ve?(Se=c.jsxs("div",{className:"flex items-start gap-2 border-t px-4 py-2.5 text-xs text-warning",children:[ae,c.jsx("span",{children:ve})]}),e[83]=ve,e[84]=Se):Se=e[84],kt=Se}const Xt=kt;let oi;e[85]!==M||e[86]!==Ot||e[87]!==H||e[88]!==Kt||e[89]!==ue||e[90]!==Ct||e[91]!==ke||e[92]!==B.count||e[93]!==y?(oi=B.count<=1||H||!Ot(M)?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:()=>ie(!0),disabled:ke||Ct,children:y("thread.publishPopover.discardAll")}),c.jsx(Fa,{open:ue,onOpenChange:ie,children:c.jsxs(Ha,{children:[c.jsxs(Na,{children:[c.jsx(Ma,{children:y("thread.publishPopover.discardAllTitle")}),c.jsx(La,{children:y("thread.publishPopover.discardAllConfirm")})]}),c.jsxs(ja,{children:[c.jsx(Oa,{children:y("thread.publishDialog.cancel")}),c.jsx(Ia,{onClick:()=>{Kt()},disabled:Ct,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:y("thread.publishPopover.discardAll")})]})]})})]}),e[85]=M,e[86]=Ot,e[87]=H,e[88]=Kt,e[89]=ue,e[90]=Ct,e[91]=ke,e[92]=B.count,e[93]=y,e[94]=oi):oi=e[94];const wi=oi,yi=Q?c.jsx(Wr,{children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(is,{}),c.jsx(is,{})]})}):B.count===0?c.jsxs("div",{className:"flex flex-col items-center gap-1 py-10 text-center",children:[c.jsx(ol,{className:"mb-1 size-5 text-success"}),c.jsx("p",{className:"text-sm font-medium",children:y(ce?"thread.publishPopover.nothingToSubmit":"thread.publishPopover.everythingLive")}),c.jsx("p",{className:"text-xs text-muted-foreground",children:y(ce?"thread.publishPopover.submitEmptyHint":"thread.publishPopover.emptyHint")})]}):c.jsxs(Wr,{children:[H?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.showingFirst",{shown:B.count,total:F})}):null,Gt(y("thread.publishPopover.pagesGroup"),B.pages),Gt(y("thread.publishPopover.blocksGroup"),B.blocks),Gt(y("thread.publishPopover.otherGroup"),B.other),J?c.jsx("p",{className:"text-[11px] text-muted-foreground",children:y("thread.publishPopover.detailsUnavailable")}):null]}),_i=Q?c.jsx(jl,{}):Ne?c.jsx("div",{className:le(Xs,"relative"),children:it.filter(ae=>Wt.includes(Qt(ae))).map(ae=>c.jsx("div",{className:le("absolute inset-0 flex",Qt(ae)!==yt&&"hidden"),children:c.jsx(pu,{change:ae,diff:q,bodyPending:te,previewServerUrl:v,draft:k,lastPage:A})},Qt(ae)))}):c.jsx("div",{className:le(Xs,"bg-muted/40")});let at;e[95]!==Vt?(at=c.jsx("span",{className:"truncate",children:Vt}),e[95]=Vt,e[96]=at):at=e[96];let lt;e[97]!==wi||e[98]!==N||e[99]!==Yt||e[100]!==at?(lt=c.jsx($n,{mode:N,title:at,subLine:Yt,trailing:wi}),e[97]=wi,e[98]=N,e[99]=Yt,e[100]=at,e[101]=lt):lt=e[101];let ht;e[102]!==ke||e[103]!==ce||e[104]!==He||e[105]!==B.count||e[106]!==y?(ht=B.count===0?null:c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-[13px] font-medium",children:y(ce?"thread.publishPopover.reviewNote":"thread.publishPopover.versionNote")}),c.jsx(Dc,{value:He,onChange:ae=>ee(ae.target.value),placeholder:y(ce?"thread.publishPopover.reviewNotePlaceholder":"thread.publishPopover.versionNotePlaceholder"),rows:2,maxLength:qs,className:"resize-none text-[13px]",disabled:ke})]}),e[102]=ke,e[103]=ce,e[104]=He,e[105]=B.count,e[106]=y,e[107]=ht):ht=e[107];let ct;e[108]!==m||e[109]!==y?(ct=c.jsx(Un,{draftPreviewUrl:m,t:y}),e[108]=m,e[109]=y,e[110]=ct):ct=e[110];let dt;e[111]!==qt||e[112]!==_e||e[113]!==ke||e[114]!==ce||e[115]!==w||e[116]!==fi||e[117]!==Ut||e[118]!==B.count||e[119]!==y?(dt=!ce&&B.count>0&&!_e.allowed&&!_e.pending?c.jsx(pe,{type:"button",className:"flex-1",onClick:w,disabled:ke,children:y("thread.publishPopover.requestApproval")}):c.jsxs(pe,{type:"button",variant:ce?"default":"brand",className:"flex-1",onClick:()=>{Ut()},disabled:!qt,children:[ke?c.jsx(rs,{className:"size-4 motion-reduce:animate-none"}):null,ke?y(ce?"thread.publishPopover.submitting":"thread.publishPopover.publishing"):fi]}),e[111]=qt,e[112]=_e,e[113]=ke,e[114]=ce,e[115]=w,e[116]=fi,e[117]=Ut,e[118]=B.count,e[119]=y,e[120]=dt):dt=e[120];let ut;e[121]!==ct||e[122]!==dt?(ut=c.jsxs("div",{className:"flex gap-2",children:[ct,dt]}),e[121]=ct,e[122]=dt,e[123]=ut):ut=e[123];let ft;e[124]!==Lt?(ft=Lt?c.jsx("p",{className:"text-xs text-destructive",children:Lt}):null,e[124]=Lt,e[125]=ft):ft=e[125];let _t;e[126]!==ut||e[127]!==ft?(_t=c.jsxs(c.Fragment,{children:[ut,ft]}),e[126]=ut,e[127]=ft,e[128]=_t):_t=e[128];let pt;e[129]!==yi||e[130]!==Xt||e[131]!==Ke||e[132]!==lt||e[133]!==ht||e[134]!==_t?(pt=c.jsx(Fn,{state:Ke,header:lt,body:yi,note:ht,gate:Xt,footer:_t}),e[129]=yi,e[130]=Xt,e[131]=Ke,e[132]=lt,e[133]=ht,e[134]=_t,e[135]=pt):pt=e[135];let Ft;return e[136]!==_i||e[137]!==pt?(Ft=c.jsx(Wn,{pane:_i,list:pt}),e[136]=_i,e[137]=pt,e[138]=Ft):Ft=e[138],Ft}function Ou(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return bc[t].short}const Iu=new Set(["failure","timed_out","cancelled","action_required"]);function Hl(t){return t.status==="completed"&&Iu.has(t.conclusion)}function Kn(t){return t.status==="queued"||t.status==="in_progress"}function js(t){return t.isPending&&t.fetchStatus!=="idle"}function ju(t){return{key:"view-change-request",label:t("thread.cmsActions.viewOnProvider"),action:"open-pr-page"}}function ai(t,e,i){return e?[...t,ju(i)]:t}function zt(t,e,i){return e.kind!=="ready"||e.behindBase<=0?t:[...t,{key:"get-latest",label:i("thread.cmsActions.getLatest"),action:"sync",tooltip:i("thread.cmsActions.getLatestTooltip")}]}function Co(t){return{key:"submit-for-review",label:t("thread.headerActions.submitForReview"),action:"create-pr"}}function Ds(t,e,i){if(e.filter(Kn).length===0)return t;const r=e.filter(n=>n.status==="completed").length;return{...t,tooltip:i("thread.cmsActions.checksRunning",{done:r,total:e.length})}}function Hu(t){const{lifecycle:e,branch:i,pr:s,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&&Ou(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(!(i.kind==="ready"&&(i.workingTreeDirty||i.aheadOfBase>0||i.unpushed>0))&&!t.noReviewableDiff)return{label:a("thread.headerActions.startingApp"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.startingAppTooltip"),menu:[]};break}}if(i.kind!=="ready")return{label:a("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:a("thread.headerActions.waitingForBranchTooltip"),menu:[]};const h=i,l=h.unpushed>0&&!(s&&h.headSha&&s.headSha&&h.headSha===s.headSha);if(t.noReviewableDiff&&!s)return{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.branchInSyncTooltip",{base:h.base}),menu:zt([],h,a)};if(h.workingTreeDirty||l)return{label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:zt(ai([Co(a)],s,a),h,a)};if(gl("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:s?.merged??null,prState:s?.state??null}),s?.merged)return!!h.headSha&&!!s.headSha&&h.headSha!==s.headSha?{label:a("thread.headerActions.continue"),action:"create-pr",variant:"special",tooltip:a("thread.headerActions.openNewPrTooltip"),menu:zt(ai([],s,a),h,a)}:{label:a("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:a("thread.headerActions.prMergedTooltip",{prNumber:String(s.number),base:s.base}),menu:zt(ai([],s,a),h,a)};if(h.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:a("thread.headerActions.reopenPr"),action:"reopen",variant:"default",tooltip:a("thread.headerActions.reopenPrTooltip",{prNumber:String(s.number)}),menu:zt(ai([],s,a),h,a)};if(!s)return{label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:zt([Co(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(Kn).length,f=r.filter(Hl).map(p=>p.name);if(d===0&&f.length>0)return{label:a("thread.headerActions.fixChecks"),action:"fix-checks",variant:"default",tooltip:a("thread.headerActions.failingChecksTooltip",{checks:f.join(", ")}),meta:{failingChecks:f},menu:zt(ai([{key:"publish-anyway",label:a("thread.headerActions.publishAnyway"),action:"merge",tooltip:a("thread.headerActions.squashMergeTooltip",{prNumber:String(s.number),base:s.base})}],s,a),h,a)};if(n?.draft)return Ds({label:a("thread.headerActions.markReady"),action:"mark-ready",variant:"default",tooltip:a("thread.headerActions.markDraftReadyTooltip"),menu:zt(ai([],s,a),h,a)},r,a);const _=n?.unresolvedConversations??0;return _>0?Ds({label:a("thread.headerActions.addressFeedback"),action:"resolve-comments",variant:"default",tooltip:a("thread.headerActions.unresolvedConversationsTooltip",{count:String(_)}),menu:zt(ai([],s,a),h,a)},r,a):n?.missingRequiredApprovals?Ds({label:a("thread.cmsActions.waitingForReview"),action:"open-pr-page",variant:"outline",tooltip:a("thread.headerActions.waitingForApprovalsTooltip"),menu:zt(ai([],s,a),h,a)},r,a):Ds({label:a("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",meta:{publishPolicyOverride:"open"},menu:zt(ai([{key:"review",label:a("thread.headerActions.review"),action:"review"}],s,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 ko(t){return{key:"view-change-request",label:t("thread.cmsActions.viewOnProvider"),action:"open-pr"}}function As(t,e,i){return e.kind!=="ready"||e.behindBase<=0?t:[...t,{key:"get-latest",label:i("thread.cmsActions.getLatest"),action:"get-latest",tooltip:i("thread.cmsActions.getLatestTooltip")}]}function Eo(t,e,i,s){const r=e.length;if(r===0)return t;if(e.filter(Kn).length>0){const a=e.filter(l=>l.status==="completed").length,h=s("thread.cmsActions.checksRunning",{done:a,total:r});return i==="loading"?{...t,loading:!0,tooltip:h}:{...t,tooltip:h}}const o=e.filter(Hl).length;return o>0?{...t,variant:"warning",tooltip:s("thread.cmsActions.checksFailing",{failed:o,total:r})}:t}function Fu(t,e){return!!(t?.merged&&t.headSha&&e.kind==="ready"&&!e.workingTreeDirty&&e.headSha===t.headSha)}function zu(t){return js(t.prQuery)?!0:t.pr?.state!=="open"||t.pr.merged?!1:js(t.checksQuery)||js(t.reviewsQuery)}function Wu(t,e){return t.workingTreeDirty?!0:e!==null?e>0:t.aheadOfBase>0}function $u(t){const{branch:e,pr:i,checks:s,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(i&&i.state==="open"&&!i.merged?i: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?Eo({label:l("thread.cmsActions.waitingForReview"),action:"open-pr",variant:"outline",menu:As([ko(l)],e,l)},s,"loading",l):Eo({label:l("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:As([ko(l)],e,l)},s,"none",l)}return Fu(i,e)?{label:l("thread.headerActions.upToDate"),variant:"outline",disabled:!0,menu:As([],e,l)}:Wu(e,h)?{label:l("thread.cmsActions.reviewAndPublish"),action:"publish",variant:"brand",menu:As([{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 Uu(t){return t.conflicting===!0?"dirty":t.conflicting===null?"unknown":t.reviewBlocked||t.unresolvedConversations>0?"blocked":"clean"}function Fl(t){const e=U.c(4);let i;e[0]!==t?(i=Ec(t),e[0]=t,e[1]=i):i=e[1];let s;return e[2]!==i?(s={...i,select:Ku},e[2]=i,e[3]=s):s=e[3],zi(s)}function Ku(t){const e=t.changeRequest;return e?{draft:e.draft,mergeableState:Uu(e),unresolvedConversations:e.unresolvedConversations,missingRequiredApprovals:e.reviewBlocked}:null}function Po(t,e){return t==="open-pr"||e==="resolve-on-provider"?c.jsx(tl,{size:16}):t==="publish"?c.jsx(Ua,{className:"size-4"}):t==="get-latest"||t==="retry-status"?c.jsx(ns,{className:"size-4"}):c.jsx(ar,{className:"size-4"})}function qu(t){const e=U.c(66),{virtualMcpId:i}=t,s=Be(),{org:r}=rr(),n=Yh(),o=hr(i),{data:a}=sr.useSession(),{deleteRelease:h}=Ln(i),{currentBranch:l,setCurrentTaskBranch:u,taskId:d,createTask:f}=Ra();let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={open:!1,mode:"publish"},e[0]=_):_=e[0];const[p,m]=X.useState(_);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=V=>m({open:!0,mode:V}),e[1]=g):g=e[1];const v=g,k=Ja(o),b=k.status==="attached"||k.status==="public-clone"?k.repo:null,{previewServerUrl:w}=cr(i);let C;if(e[2]!==l||e[3]!==r.slug||e[4]!==i){const V=l?il(sl(r.slug,i,l)):null;C=V?Ya(V.path,V.params):"/",e[2]=l,e[3]=r.slug,e[4]=i,e[5]=C}else C=e[5];const S=C;let R;e[6]!==l||e[7]!==S||e[8]!==r.slug||e[9]!==w||e[10]!==i?(R=l?{orgSlug:r.slug,virtualMcpId:i,branch:l,previewServerUrl:w,path:S}:null,e[6]=l,e[7]=S,e[8]=r.slug,e[9]=w,e[10]=i,e[11]=R):R=e[11];const N=Rc(R);let I;e[12]!==l||e[13]!==r.slug||e[14]!==i?(I=l?{orgSlug:r.slug,virtualMcpId:i,branch:l}:null,e[12]=l,e[13]=r.slug,e[14]=i,e[15]=I):I=e[15];const L=Bc(I),y=l??"",E=d??null;let x;e[16]!==r.slug||e[17]!==y||e[18]!==E||e[19]!==i?(x=dl({orgSlug:r.slug,virtualMcpId:i,branch:y,threadId:E}),e[16]=r.slug,e[17]=y,e[18]=E,e[19]=i,e[20]=x):x=e[20];const A=!!l;let D;e[21]!==x||e[22]!==A?(D={...x,enabled:A},e[21]=x,e[22]=A,e[23]=D):D=e[23];const P=zi(D),B=P.data??null,M=B?{kind:"ready",branch:fl(B)??l??"",base:B.base??"main",workingTreeDirty:Uc(B),unpushed:B.unpushed??0,aheadOfBase:B.aheadOfBase??0,behindBase:B.behindBase??0,headSha:B.headSha??""}:{kind:"unknown"},K=B?.changedFiles?Ll({files:B.changedFiles}).count:null,F=(M.kind==="ready"?M.branch:null)??l??null,H=M.kind==="ready"?M.base:"main",Y=Za({orgId:r.id,orgSlug:r.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:F}),q=Y.data??null,te=Qa({orgId:r.id,orgSlug:r.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",base:H}),J=el({orgId:r.id,orgSlug:r.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:F}),Q=Fl({orgId:r.id,orgSlug:r.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:F});let W;e[24]!==J||e[25]!==q||e[26]!==Y||e[27]!==Q?(W=zu({pr:q,prQuery:Y,checksQuery:J,reviewsQuery:Q}),e[24]=J,e[25]=q,e[26]=Y,e[27]=Q,e[28]=W):W=e[28];const G=W;let ee;e[29]!==Y?(ee=async()=>{await Y.refetch()},e[29]=Y,e[30]=ee):ee=e[30];const ue=ee,ie=io({mutationFn:async()=>{const V=l;await u(Nn(On(a?.user))),V&&V!==H&&await h(V)},onError:Gu});let de;e[31]!==r.slug||e[32]!==d||e[33]!==i?(de=async V=>(await hl({orgSlug:r.slug,virtualMcpId:i,branch:V.branch,threadId:d??null},V.base),V),e[31]=r.slug,e[32]=d,e[33]=i,e[34]=de):de=e[34];let z;e[35]!==l||e[36]!==r.slug||e[37]!==n||e[38]!==s||e[39]!==d||e[40]!==i?(z=async V=>{Xe.success(s("thread.headerActions.syncedWithBase",{base:V.base})),await Promise.all([n.invalidateQueries({queryKey:pl({orgSlug:r.slug,virtualMcpId:i,branch:l??V.branch,threadId:d??null})}),n.invalidateQueries({queryKey:An.decofile(`${r.slug}/${i}/${V.branch}`)})])},e[35]=l,e[36]=r.slug,e[37]=n,e[38]=s,e[39]=d,e[40]=i,e[41]=z):z=e[41];let ge;e[42]!==de||e[43]!==z?(ge={mutationFn:de,onSuccess:z,onError:Yu},e[42]=de,e[43]=z,e[44]=ge):ge=e[44];const fe=io(ge),Le=rl(r.slug,i,l??""),oe=ie.isPending,$=$u({branch:M,pr:q,checks:J.data??[],reviews:Q.data??null,publishing:oe,saving:Le,syncing:fe.isPending,statusRetrying:P.isFetching&&!!P.error,statusError:P.error instanceof Error?P.error.message:P.error?String(P.error):null,loading:!!G,publishableChangeCount:K,t:s}),De=$.autoRun&&M.kind==="ready"&&b&&w?`${F}@${M.headSha}`:null,At=X.useRef(null);if(X.useEffect(()=>{!De||!F||At.current!==De&&(At.current=De,fe.mutate({branch:F,base:H}))},[De,F,H,fe]),k.status==="detached"){let V;e[45]!==s?(V=s("thread.headerActions.reconnectGithub"),e[45]=s,e[46]=V):V=e[46];let _e;e[47]!==V?(_e=c.jsx(St,{asChild:!0,children:c.jsx("span",{children:c.jsx(pe,{size:"sm",variant:"outline",disabled:!0,children:V})})}),e[47]=V,e[48]=_e):_e=e[48];let Ae;e[49]!==s?(Ae=s("thread.headerActions.githubConnectionRemoved"),e[49]=s,e[50]=Ae):Ae=e[50];let ye;e[51]!==Ae?(ye=c.jsx(wt,{children:Ae}),e[51]=Ae,e[52]=ye):ye=e[52];let Je;return e[53]!==_e||e[54]!==ye?(Je=c.jsx(nr,{children:c.jsxs(bt,{children:[_e,ye]})}),e[53]=_e,e[54]=ye,e[55]=Je):Je=e[55],Je}if(!o)return null;if(!b||!w){const V=b?"noPreviewServer":"noRepo";let _e;e[56]!==l||e[57]!==f?(_e=l?()=>{const ye=f?.({runtime:"sandbox",branch:l});ye&&Gh("coding_session_started",{thread_id:ye})}:void 0,e[56]=l,e[57]=f,e[58]=_e):_e=e[58];let Ae;return e[59]!==V||e[60]!==_e?(Ae=c.jsx(Xu,{reason:V,onStartCodingSession:_e}),e[59]=V,e[60]=_e,e[61]=Ae):Ae=e[61],Ae}if(!l)return null;const Ye=V=>{switch(V){case"publish":{v("publish");return}case"request-approval":{v("review");return}case"get-latest":{if(!F||fe.isPending)return;fe.mutate({branch:F,base:H});return}case"retry-status":{P.refetch();return}case"open-pr":{q?.htmlUrl&&window.open(q.htmlUrl,"_blank","noopener,noreferrer");return}}};let He;e[62]!==Ye?(He=V=>({key:V.key,label:V.label,icon:Po(V.action,V.key),...V.tooltip?{tooltip:V.tooltip}:{},onSelect:()=>Ye(V.action)}),e[62]=Ye,e[63]=He):He=e[63];const it=$.menu.map(He),Ne=$.action,yt=$.label,Wt=$.variant,ce=!!$.loading;let Ke;e[64]!==s?(Ke=s("thread.cmsActions.moreActionsAriaLabel"),e[64]=s,e[65]=Ke):Ke=e[65];const qe=c.jsx(Sl,{size:"sm",label:yt,variant:Wt,disabled:!!$.disabled||!Ne,loading:ce,...Ne&&!$.loading?{icon:Po(Ne)}:{},...$.tooltip?{tooltip:$.tooltip}:{},items:it,menuAriaLabel:Ke,onClick:Ne?()=>Ye(Ne):void 0});return c.jsxs(c.Fragment,{children:[qe,l?c.jsx(Il,{open:p.open,mode:p.mode,fastPreview:!0,onOpenChange:V=>{V||m(Vu)},orgSlug:r.slug,virtualMcpId:i,branch:l,baseBranch:H,repoTarget:Bt(b),owner:b.owner,repo:b.name,publishPolicy:_l(o?.metadata?.publishPolicy),draftPreviewUrl:N.url,destinationHost:N.host,previewServerUrl:w,compareDraft:L?{kind:"pointer",pointer:L}:null,lastPublishedPr:te.data??null,onRequestApproval:()=>v("review"),openPullRequest:q?.state==="open"?q:null,onPullRequestChanged:ue,onPublished:()=>ie.mutateAsync()}):null]})}function Vu(t){return{...t,open:!1}}function Yu(t){Xe.error(t instanceof Error?t.message:String(t))}function Gu(t){Xe.error(t instanceof Error?t.message:String(t))}function Xu(t){const e=U.c(14),{reason:i,onStartCodingSession:s}=t,r=Be(),n=!s;let o;e[0]!==r?(o=r("sandbox.cmsUnavailable.startCodingSession"),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==n||e[4]!==o?(a=c.jsx(St,{asChild:!0,children:c.jsx("span",{children:c.jsx(pe,{size:"sm",variant:"outline",disabled:n,onClick:s,children:o})})}),e[2]=s,e[3]=n,e[4]=o,e[5]=a):a=e[5];let h;e[6]!==i||e[7]!==r?(h=r(i==="noPreviewServer"?"sandbox.cmsUnavailable.noPreviewServer":"sandbox.cmsUnavailable.noRepo"),e[6]=i,e[7]=r,e[8]=h):h=e[8];let l;e[9]!==h?(l=c.jsx(wt,{children:h}),e[9]=h,e[10]=l):l=e[10];let u;return e[11]!==a||e[12]!==l?(u=c.jsx(nr,{children:c.jsxs(bt,{children:[a,l]})}),e[11]=a,e[12]=l,e[13]=u):u=e[13],u}const Li="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 Ju(t){return`Reopen PR #${t.prNumber}. ${Li}`}function Zu(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${Li}`}function Qu(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). ${Li}`}function ef(t){const e=(t.failingChecks??[]).map(i=>`\`${i}\``).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. ${Li}`}function tf(t){return`Mark PR #${t.prNumber} ready for review. ${Li}`}function sf(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. ${Li}`}function rf(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. ${Li}`}function Ro(t){switch(t){case"publish":return c.jsx(Ua,{className:"size-4"});case"create-pr":case"reopen":return c.jsx(ar,{className:"size-4"});case"rebase":case"sync":return c.jsx(ns,{className:"size-4"});case"fix-checks":return c.jsx(Pa,{className:"size-4"});case"mark-ready":return c.jsx(ol,{className:"size-4"});case"resolve-comments":return c.jsx(dc,{className:"size-4"});case"merge":return c.jsx(Mc,{className:"size-4"});case"review":return c.jsx(al,{className:"size-4"});case"open-pr-page":return c.jsx(tl,{size:16})}}const Bo=new Set(["reopen","rebase","fix-checks","mark-ready","resolve-comments","review","sync"]),Do=new Set(["publish","create-pr"]);function nf(t){return{label:t("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:t("thread.headerActions.waitingForSandboxBranchTooltip"),menu:[]}}function of({virtualMcpId:t}){const e=Be(),{org:i}=rr(),{data:s}=sr.useSession(),r=hr(t),{deleteRelease:n}=Ln(t),{currentBranch:o,setCurrentTaskBranch:a,taskId:h}=Ra(),l=tc(),{openSidePanel:u}=sc(),[d,f]=X.useState({open:!1,mode:"publish",policyOverride:null}),_=Xc({connectionId:Xh,orgId:i.id,orgSlug:i.slug}),p=Jc(_),[m,g]=X.useState(!1),v=X.useRef(""),k=Ja(r),b=k.status==="attached"||k.status==="public-clone"?k.repo:null,{lifecycle:w,branch:C,phase:S}=dr(),R={orgSlug:i.slug,virtualMcpId:t,branch:o??"",threadId:h??null},I=zi({queryKey:pl(R),queryFn:()=>jn(R),enabled:!!o,staleTime:15e3,refetchInterval:oe=>wr(oe.state.data)?5e3:!1}).data??null,L=C,y=w,E=L.kind==="ready"?L.branch:null,x=o??E??void 0,A=(L.kind==="ready"?L.branch:null)??x??null,D=Za({orgId:i.id,orgSlug:i.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:A}),P=D.data??null,B=el({orgId:i.id,orgSlug:i.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:A}),M=Fl({orgId:i.id,orgSlug:i.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",branch:A}),K=Qa({orgId:i.id,orgSlug:i.slug,target:Bt(b),owner:b?.owner??"",repo:b?.name??"",base:L.kind==="ready"?L.base:null}),F=L,H=_l(r?.metadata?.publishPolicy),Y=rl(i.slug,t,o??x??""),{previewUrl:q}=vl(),{previewServerUrl:te}=cr(t);if(k.status==="detached")return c.jsx(lf,{label:e("thread.headerActions.githubConnectionRemoved"),children:c.jsx(pe,{size:"sm",variant:"outline",disabled:!0,children:e("thread.headerActions.reconnectGithub")})});if(!b)return null;const J=A?Hu({lifecycle:y,branch:F,claimPhase:S,pr:P,checks:B.data??[],reviews:M.data??null,noReviewableDiff:wr(I),loading:js(D),t:e}):nf(e),Q=JSON.stringify({label:J.label,branchKind:F.kind,workingTreeDirty:F.kind==="ready"?F.workingTreeDirty:null,unpushed:F.kind==="ready"?F.unpushed:null,aheadOfBase:F.kind==="ready"?F.aheadOfBase:null,lifecycle:y.phase,headBranch:A,noReviewableDiff:wr(I)});v.current!==Q&&(v.current=Q,gl("header button",{label:J.label,tooltip:J.tooltip,action:J.action,chatBranch:o,sandboxBranch:E,sandboxRouteBranch:x,headBranch:A,branchMeta:L,effectiveBranchMeta:F,lifecyclePhase:y.phase,prNumber:P?.number??null,prState:P?.state??null}));const W=oe=>(u(),l.sendMessage({parts:[{type:"text",text:oe}]})),G=l.isStreaming,ee=F.kind==="ready"?F.base:"main",ue=async()=>{await D.refetch()},ie=async()=>{const oe=o,$=Nn(On(s?.user));await a($),oe&&oe!==ee&&await n(oe)},de=async oe=>{if(!(!b||m)){g(!0);try{const $=wl(s?.user);await Cl(i.slug,Bt(b),{number:oe,coAuthor:$}),Xe.success(e("thread.headerActions.publishedPr",{prNumber:String(oe)})),await ue(),await ie()}catch($){Xe.error($ instanceof xl?$.detail??Pd($.reason,e):$ instanceof Error?$.message:e("thread.headerActions.failedToMergePullRequest"))}finally{g(!1)}}},z=(oe,$)=>f({open:!0,mode:oe,policyOverride:$}),ge=oe=>{if(A)switch(oe){case"publish":z("publish",J.meta?.publishPolicyOverride??null);return;case"create-pr":z("review",null);return;case"merge":P&&de(P.number);return;case"sync":if(G)return;W(Qu({branch:A,base:ee}));return;case"open-pr-page":P?.htmlUrl&&window.open(P.htmlUrl,"_blank","noopener,noreferrer");return;case"review":if(G)return;P&&W(rf({prNumber:P.number}));return;case"reopen":if(G)return;P&&W(Ju({prNumber:P.number}));return;case"rebase":if(G)return;W(Zu({branch:A}));return;case"fix-checks":if(G)return;P&&W(ef({prNumber:P.number,failingChecks:J.meta?.failingChecks??[]}));return;case"mark-ready":if(G)return;P&&W(tf({prNumber:P.number}));return;case"resolve-comments":if(G)return;P&&W(sf({prNumber:P.number}));return}},fe=m||G,Le=c.jsx(af,{t:e,button:J,actionBusy:fe,changeRequestPending:m,savePending:Y,onAction:ge});return x?c.jsxs(c.Fragment,{children:[Le,c.jsx(Il,{open:d.open,mode:d.mode,fastPreview:!1,recoverSandbox:()=>p.mutateAsync({virtualMcpId:t,branch:x,...h?{threadId:h}:{}}),onOpenChange:oe=>{oe||f($=>({...$,open:!1}))},orgSlug:i.slug,virtualMcpId:t,branch:x,baseBranch:ee,repoTarget:Bt(b),owner:b.owner,repo:b.name,publishPolicy:d.policyOverride??H,draftPreviewUrl:q,destinationHost:null,previewServerUrl:te,compareDraft:q?{kind:"sandbox",previewUrl:q}:null,lastPublishedPr:K.data??null,onRequestApproval:()=>f(oe=>({...oe,open:!0,mode:"review"})),openPullRequest:P?.state==="open"?P:null,onPullRequestChanged:ue,onPublished:ie})]}):Le}function af(t){const e=U.c(44),{t:i,button:s,actionBusy:r,changeRequestPending:n,savePending:o,onAction:a}=t,h=s.action;let l;e[0]!==h||e[1]!==r?(l=r&&h!==void 0&&Bo.has(h),e[0]=h,e[1]=r,e[2]=l):l=e[2];const u=l,d=n&&h==="merge";let f;e[3]!==h||e[4]!==o?(f=o&&h!==void 0&&Do.has(h),e[3]=h,e[4]=o,e[5]=f):f=e[5];const _=f,p=!!s.disabled||u||d||_||!h,m=!!s.loading||d;let g;e[6]!==s.tooltip||e[7]!==u||e[8]!==_||e[9]!==i?(g=u?i("thread.headerActions.chatIsRunning"):_?i("thread.headerActions.saving"):s.tooltip,e[6]=s.tooltip,e[7]=u,e[8]=_,e[9]=i,e[10]=g):g=e[10];const v=g;let k;if(e[11]!==r||e[12]!==s.menu||e[13]!==n||e[14]!==a||e[15]!==o||e[16]!==i){let y;e[18]!==r||e[19]!==n||e[20]!==a||e[21]!==o||e[22]!==i?(y=E=>{const x=r&&Bo.has(E.action),A=o&&Do.has(E.action),D=E.action==="merge"&&n,P=A?i("thread.headerActions.saving"):x?i("thread.headerActions.chatIsRunning"):E.tooltip;return{key:E.key,label:E.label,icon:Ro(E.action),disabled:!!(x||A||D),...P?{tooltip:P}:{},onSelect:()=>a(E.action)}},e[18]=r,e[19]=n,e[20]=a,e[21]=o,e[22]=i,e[23]=y):y=e[23],k=s.menu.map(y),e[11]=r,e[12]=s.menu,e[13]=n,e[14]=a,e[15]=o,e[16]=i,e[17]=k}else k=e[17];const b=k,w=s.label,C=s.variant;let S;e[24]!==h||e[25]!==m?(S=h&&!m?{icon:Ro(h)}:{},e[24]=h,e[25]=m,e[26]=S):S=e[26];let R;e[27]!==v?(R=v?{tooltip:v}:{},e[27]=v,e[28]=R):R=e[28];let N;e[29]!==i?(N=i("thread.headerActions.moreActionsAriaLabel"),e[29]=i,e[30]=N):N=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 L;return e[34]!==s.label||e[35]!==s.variant||e[36]!==p||e[37]!==b||e[38]!==m||e[39]!==S||e[40]!==R||e[41]!==N||e[42]!==I?(L=c.jsx(Sl,{size:"sm",label:w,variant:C,disabled:p,loading:m,...S,...R,items:b,menuAriaLabel:N,onClick:I}),e[34]=s.label,e[35]=s.variant,e[36]=p,e[37]=b,e[38]=m,e[39]=S,e[40]=R,e[41]=N,e[42]=I,e[43]=L):L=e[43],L}function lf(t){const e=U.c(9),{label:i,children:s}=t;if(!i){let a;return e[0]!==s?(a=c.jsx(c.Fragment,{children:s}),e[0]=s,e[1]=a):a=e[1],a}let r;e[2]!==s?(r=c.jsx(St,{asChild:!0,children:c.jsx("span",{children:s})}),e[2]=s,e[3]=r):r=e[3];let n;e[4]!==i?(n=c.jsx(wt,{children:i}),e[4]=i,e[5]=n):n=e[5];let o;return e[6]!==r||e[7]!==n?(o=c.jsx(nr,{children:c.jsxs(bt,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=o):o=e[8],o}const hf=new Set(["site-editor","content"]);function cf(t){return t.hasClonableSource&&!t.fastPreviewActive&&t.mainTab!==null&&hf.has(t.mainTab)}const Bi="setup";function df(t){const e=U.c(57),i=Be();let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let w;e[3]!==t.scriptTabs?(w=C=>!t.scriptTabs.includes(C),e[3]=t.scriptTabs,e[4]=w):w=e[4],s=t.scripts.filter(w),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const r=s;let n;e[5]!==t?(n=()=>{t.active===Bi?t.onToggle():t.onSelectTab(Bi)},e[5]=t,e[6]=n):n=e[6];const o=n;let a;e[7]!==t.open||e[8]!==i?(a=t.open?i("sandbox.preview.collapseTerminal"):i("sandbox.preview.expandTerminal"),e[7]=t.open,e[8]=i,e[9]=a):a=e[9];let h;e[10]!==t.open?(h=t.open?c.jsx(or,{className:"size-4"}):c.jsx(ac,{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(St,{asChild:!0,children:c.jsx(pe,{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]!==i?(u=t.open?i("sandbox.preview.collapseTerminal"):i("sandbox.preview.expandTerminal"),e[17]=t.open,e[18]=i,e[19]=u):u=e[19];let d;e[20]!==u?(d=c.jsx(wt,{children:u}),e[20]=u,e[21]=d):d=e[21];let f;e[22]!==l||e[23]!==d?(f=c.jsxs(bt,{children:[l,d]}),e[22]=l,e[23]=d,e[24]=f):f=e[24];const _=t.active===Bi;let p;e[25]!==o||e[26]!==t.open||e[27]!==i||e[28]!==_?(p=c.jsx(uf,{active:_,open:t.open,onClick:o,t:i}),e[25]=o,e[26]=t.open,e[27]=i,e[28]=_,e[29]=p):p=e[29];let m;e[30]!==t||e[31]!==i?(m=t.scriptTabs.map(w=>c.jsx(_f,{active:t.active===w,onClick:()=>{t.active===w?t.onToggle():t.onSelectTab(w)},onClose:()=>t.onCloseScript(w),t:i,children:w},w)),e[30]=t,e[31]=i,e[32]=m):m=e[32];let g;e[33]!==r||e[34]!==t.onAddScript?(g=c.jsx(pf,{scripts:r,onRun:t.onAddScript}),e[33]=r,e[34]=t.onAddScript,e[35]=g):g=e[35];let v;e[36]!==m||e[37]!==g||e[38]!==p?(v=c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[p,m,g]}),e[36]=m,e[37]=g,e[38]=p,e[39]=v):v=e[39];let k;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]!==i?(k=t.showScriptControls?c.jsx(mf,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript,t:i}):c.jsx(ff,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry,t:i}),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]=i,e[52]=k):k=e[52];let b;return e[53]!==v||e[54]!==k||e[55]!==f?(b=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:[f,v,k]}),e[53]=v,e[54]=k,e[55]=f,e[56]=b):b=e[56],b}function uf(t){const e=U.c(11),{active:i,open:s,onClick:r,t:n}=t,o=i&&s,a=i&&s,h=i?"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=le("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(Lc,{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 f;return e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==l||e[9]!==d?(f=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]=f):f=e[10],f}function ff(t){const e=U.c(40),{status:i,onStart:s,onStop:r,onRestart:n,onResume:o,onRetry:a,t:h}=t;if(i==="idle"&&s){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(Ks,{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]!==s||e[4]!==u?(d=c.jsxs(pe,{variant:"outline",size:"xs",onClick:s,children:[l," ",u]}),e[3]=s,e[4]=u,e[5]=d):d=e[5],d}if(i==="suspended"&&o){let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(Ks,{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(pe,{variant:"outline",size:"xs",onClick:o,children:[l," ",u]}),e[9]=o,e[10]=u,e[11]=d):d=e[11],d}if(i==="errored"&&a){let l;e[12]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(ns,{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(pe,{variant:"outline",size:"xs",onClick:a,children:[l," ",u]}),e[15]=a,e[16]=u,e[17]=d):d=e[17],d}if(i==="starting"||i==="running"){const l=i==="running"&&!!n,u=l?"rounded-r-none border-r-0":void 0;let d;e[18]!==u?(d=le(u),e[18]=u,e[19]=d):d=e[19];let f;e[20]!==h?(f=h("sandbox.toolbar.stop"),e[20]=h,e[21]=f):f=e[21];let _;e[22]!==r||e[23]!==d||e[24]!==f?(_=c.jsx(St,{asChild:!0,children:c.jsx(pe,{variant:"outline",size:"xs",onClick:r,className:d,children:f})}),e[22]=r,e[23]=d,e[24]=f,e[25]=_):_=e[25];let p;e[26]!==h?(p=h("sandbox.toolbar.stopSandboxTooltip"),e[26]=h,e[27]=p):p=e[27];let m;e[28]!==p?(m=c.jsx(wt,{children:p}),e[28]=p,e[29]=m):m=e[29];let g;e[30]!==_||e[31]!==m?(g=c.jsxs(bt,{children:[_,m]}),e[30]=_,e[31]=m,e[32]=g):g=e[32];let v;e[33]!==n||e[34]!==l||e[35]!==h?(v=l&&c.jsxs(us,{children:[c.jsx(cs,{asChild:!0,children:c.jsx(pe,{variant:"outline",size:"xs",className:"rounded-l-none px-1","aria-label":h("sandbox.toolbar.moreActions"),children:c.jsx(or,{className:"size-3"})})}),c.jsx(ds,{align:"end",children:c.jsxs(Ai,{onClick:n,children:[c.jsx(ns,{className:"size-3.5"})," ",h("sandbox.toolbar.restart")]})})]}),e[33]=n,e[34]=l,e[35]=h,e[36]=v):v=e[36];let k;return e[37]!==g||e[38]!==v?(k=c.jsxs("div",{className:"flex items-center",children:[g,v]}),e[37]=g,e[38]=v,e[39]=k):k=e[39],k}return null}function _f(t){const e=U.c(17),{active:i,onClick:s,onClose:r,children:n,t:o}=t,a=i?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let h;e[0]!==a?(h=le("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=i?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==l||e[3]!==u?(d=le("flex h-full items-center",l,u),e[2]=l,e[3]=u,e[4]=d):d=e[4];let f;e[5]!==n||e[6]!==s||e[7]!==d?(f=c.jsx("button",{type:"button",onClick:s,className:d,children:n}),e[5]=n,e[6]=s,e[7]=d,e[8]=f):f=e[8];let _;e[9]!==n||e[10]!==r||e[11]!==o?(_=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(Jh,{className:"size-3.5"})}),e[9]=n,e[10]=r,e[11]=o,e[12]=_):_=e[12];let p;return e[13]!==h||e[14]!==f||e[15]!==_?(p=c.jsxs("div",{className:h,children:[f,_]}),e[13]=h,e[14]=f,e[15]=_,e[16]=p):p=e[16],p}function pf(t){const e=U.c(27),{scripts:i,onRun:s}=t,r=Be(),[n,o]=X.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(Mn,{className:"size-4"}),e[2]=h):h=e[2];let l;e[3]!==a?(l=c.jsx(St,{asChild:!0,children:c.jsx(Aa,{asChild:!0,children:c.jsx(pe,{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(wt,{children:u}),e[7]=u,e[8]=d):d=e[8];let f;e[9]!==l||e[10]!==d?(f=c.jsxs(bt,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=f):f=e[11];let _;e[12]!==r?(_=r("sandbox.toolbar.runAScript"),e[12]=r,e[13]=_):_=e[13];let p;e[14]!==_?(p=c.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:_}),e[14]=_,e[15]=p):p=e[15];let m;e[16]!==s||e[17]!==i||e[18]!==r?(m=i.length===0?c.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:r("sandbox.toolbar.noScriptsFound")}):i.map(k=>c.jsxs("button",{type:"button",onClick:()=>{o(!1),s(k)},className:"w-full rounded-lg px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",k]},k)),e[16]=s,e[17]=i,e[18]=r,e[19]=m):m=e[19];let g;e[20]!==p||e[21]!==m?(g=c.jsxs(Ta,{align:"start",className:"p-1 w-56",children:[p,m]}),e[20]=p,e[21]=m,e[22]=g):g=e[22];let v;return e[23]!==n||e[24]!==g||e[25]!==f?(v=c.jsxs(Da,{open:n,onOpenChange:o,children:[f,g]}),e[23]=n,e[24]=g,e[25]=f,e[26]=v):v=e[26],v}function mf(t){const e=U.c(30),{isRunning:i,isKilling:s,onRun:r,onStop:n,t:o}=t;if(s){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(rs,{className:"size-3.5"}),e[0]=f):f=e[0];let _;e[1]!==o?(_=o("sandbox.toolbar.stopping"),e[1]=o,e[2]=_):_=e[2];let p;return e[3]!==_?(p=c.jsxs(pe,{variant:"outline",size:"xs",disabled:!0,children:[f," ",_]}),e[3]=_,e[4]=p):p=e[4],p}if(!i){let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(Ks,{className:"size-3.5"}),e[5]=f):f=e[5];let _;e[6]!==o?(_=o("sandbox.toolbar.run"),e[6]=o,e[7]=_):_=e[7];let p;e[8]!==r||e[9]!==_?(p=c.jsx(St,{asChild:!0,children:c.jsxs(pe,{variant:"outline",size:"xs",onClick:r,children:[f," ",_]})}),e[8]=r,e[9]=_,e[10]=p):p=e[10];let m;e[11]!==o?(m=o("sandbox.toolbar.startProcess"),e[11]=o,e[12]=m):m=e[12];let g;e[13]!==m?(g=c.jsx(wt,{children:m}),e[13]=m,e[14]=g):g=e[14];let v;return e[15]!==p||e[16]!==g?(v=c.jsxs(bt,{children:[p,g]}),e[15]=p,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(St,{asChild:!0,children:c.jsx(pe,{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(wt,{children:l}),e[25]=l,e[26]=u):u=e[26];let d;return e[27]!==h||e[28]!==u?(d=c.jsxs(bt,{children:[h,u]}),e[27]=h,e[28]=u,e[29]=d):d=e[29],d}var zl=Object.defineProperty,gf=Object.getOwnPropertyDescriptor,vf=(t,e)=>{for(var i in e)zl(t,i,{get:e[i],enumerable:!0})},Pe=(t,e,i,s)=>{for(var r=s>1?void 0:s?gf(e,i):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(r=(s?o(e,i,r):o(r))||r);return s&&r&&zl(e,i,r),r},j=(t,e)=>(i,s)=>e(i,s,t),Ao="Terminal input",qr={get:()=>Ao,set:t=>Ao=t},To="Too much output to announce, navigate to rows manually to read",Vr={get:()=>To,set:t=>To=t};function bf(t){return t.replace(/\r?\n/g,"\r")}function Sf(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function wf(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function yf(t,e,i,s){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Wl(r,e,i,s)}}function Wl(t,e,i,s){t=bf(t),t=Sf(t,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(t,!0),e.value=""}function $l(t,e,i){let s=i.getBoundingClientRect(),r=t.clientX-s.left-10,n=t.clientY-s.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 Mo(t,e,i,s,r){$l(t,e,i),r&&s.rightClickSelect(t),e.value=s.selectionText,e.select()}function vi(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function fr(t,e=0,i=t.length){let s="";for(let r=e;r<i;++r){let n=t[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var xf=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let i=t.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=t.charCodeAt(r++);56320<=n&&n<=57343?e[s++]=(this._interim-55296)*1024+n-56320+65536:(e[s++]=this._interim,e[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=t.charCodeAt(n);56320<=a&&a<=57343?e[s++]=(o-55296)*1024+a-56320+65536:(e[s++]=o,e[s++]=a);continue}o!==65279&&(e[s++]=o)}return s}},Cf=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let i=t.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let f=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let p=0,m;for(;(m=this.interim[++p]&63)&&p<4;)_<<=6,_|=m;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-p;for(;l<v;){if(l>=i)return 0;if(m=t[l++],(m&192)!==128){l--,f=!0;break}else this.interim[p++]=m,_<<=6,_|=m&63}f||(g===2?_<128?l--:e[s++]=_:g===3?_<2048||_>=55296&&_<=57343||_===65279||(e[s++]=_):_<65536||_>1114111||(e[s++]=_)),this.interim.fill(0)}let u=i-4,d=l;for(;d<i;){for(;d<u&&!((r=t[d])&128)&&!((n=t[d+1])&128)&&!((o=t[d+2])&128)&&!((a=t[d+3])&128);)e[s++]=r,e[s++]=n,e[s++]=o,e[s++]=a,d+=4;if(r=t[d++],r<128)e[s++]=r;else if((r&224)===192){if(d>=i)return this.interim[0]=r,s;if(n=t[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}e[s++]=h}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;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[s++]=h}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(n=t[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=t[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;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[s++]=h}}return s}},Ul="",bi=" ",fs=class Kl{constructor(){this.fg=0,this.bg=0,this.extended=new Js}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 Kl;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}},Js=class ql{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}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 ql(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Dt=class Vl extends fs{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Js,this.combinedData=""}static fromCharData(e){let i=new Vl;return i.setFromCharData(e),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?vi(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 i=!1;if(e[1].length>2)i=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Lo="di$target",Yr="di$dependencies",Er=new Map;function kf(t){return t[Yr]||[]}function Ue(t){if(Er.has(t))return Er.get(t);let e=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Ef(e,i,r)};return e._id=t,Er.set(t,e),e}function Ef(t,e,i){e[Lo]===e?e[Yr].push({id:t,index:i}):(e[Yr]=[{id:t,index:i}],e[Lo]=e)}var et=Ue("BufferService"),Yl=Ue("CoreMouseService"),Ni=Ue("CoreService"),Pf=Ue("CharsetService"),qn=Ue("InstantiationService"),Gl=Ue("LogService"),tt=Ue("OptionsService"),Xl=Ue("OscLinkService"),Rf=Ue("UnicodeService"),_s=Ue("DecorationService"),Gr=class{constructor(t,e,i){this._bufferService=t,this._optionsService=e,this._oscLinkService=i}provideLinks(t,e){let i=this._bufferService.buffer.lines.get(t-1);if(!i){e(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Dt,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let u=0;u<o;u++)if(!(h===-1&&!i.hasContent(u))){if(i.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 f={start:{x:h+1,y:t},end:{x:u+(!l&&u===o-1?1:0),y:t}},_=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(d);["http:","https:"].includes(p.protocol)||(_=!0)}catch{_=!0}_||s.push({text:d,range:f,activate:(p,m)=>r?r.activate(p,m,f):Bf(p,m),hover:(p,m)=>r?.hover?.(p,m,f),leave:(p,m)=>r?.leave?.(p,m,f)})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=u,a=n.extended.urlId):(h=-1,a=-1)}}e(s)}};Gr=Pe([j(0,et),j(1,tt),j(2,Xl)],Gr);function Bf(t,e){if(confirm(`Do you want to navigate to ${e}?
11
11
 
12
12
  WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var _r=Ue("CharSizeService"),di=Ue("CoreBrowserService"),Vn=Ue("MouseService"),ui=Ue("RenderService"),Df=Ue("SelectionService"),Jl=Ue("CharacterJoinerService"),$i=Ue("ThemeService"),Zl=Ue("LinkProviderService"),Af=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?No.isErrorNoTelemetry(t)?new No(t.message+`
13
13
 
@@ -22,4 +22,4 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
22
22
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),to&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!e?!1:this._areCoordsInSelection(e,i,s)}isCellInSelection(t,e){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([t,e],i,s)}_areCoordsInSelection(t,e,i){return t[1]>e[1]&&t[1]<i[1]||e[1]===i[1]&&t[1]===e[1]&&t[0]>=e[0]&&t[0]<i[0]||e[1]<i[1]&&t[1]===i[1]&&t[0]<i[0]||e[1]<i[1]&&t[1]===e[1]&&t[0]>=e[0]}_selectWordAtCursor(t,e){let i=this._linkifier.currentLink?.link?.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=ea(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(t);return s?(this._selectWordAt(s,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=eo(this._coreBrowserService.window,t,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return e>=0&&e<=i?0:(e>i&&(e-=i),e=Math.min(Math.max(e,-Tr),Tr),e/=Tr,e/Math.abs(e)+Math.round(e*(kp-1)))}shouldForceSelection(t){return er?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(),Ep)}_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&&!(er&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.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<Pp&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=gp(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd,i=!!t&&!!e&&(t[0]!==e[0]||t[1]!==e[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(t,e,i);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,i)}_fireOnSelectionChange(t,e,i){this._oldSelectionStart=t,this._oldSelectionEnd=e,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(t,e){let i=e;for(let s=0;e>=s;s++){let r=t.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&e!==s&&(i+=r-1)}return i}setSelection(t,e,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,e],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,e,i=!0,s=!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,f=0,_=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 k=n.getString(v).length;for(k>1&&(_+=k-1,h+=k-1);g>0&&a>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,g--):b>1&&(f+=b-1,a-=b-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 b=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,v++):b>1&&(_+=b-1,h+=b-1),h++,v++}}h++;let p=a+l-u+f,m=Math.min(this._bufferService.cols,h-a+u+d-f-_);if(!(!e&&o.slice(a,h).trim()==="")){if(i&&p===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 k=this._bufferService.cols-v.start;p-=k,m+=k}}}if(s&&p+m===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&&(m+=v.length)}}return{start:p,length:m}}}_selectWordAt(t,e){let i=this._getWordAt(t,e);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[i.start,t[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let i=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,i]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),i={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=ea(i,this._bufferService.cols)}};Sn=Pe([j(3,et),j(4,Ni),j(5,Vn),j(6,tt),j(7,ui),j(8,di)],Sn);var ta=class{constructor(){this._data={}}set(t,e,i){this._data[t]||(this._data[t]={}),this._data[t][e]=i}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},ia=class{constructor(){this._color=new ta,this._css=new ta}setCss(t,e,i){this._css.set(t,e,i)}getCss(t,e){return this._css.get(t,e)}setColor(t,e,i){this._color.set(t,e,i)}getColor(t,e){return this._color.get(t,e)}clear(){this._color.clear(),this._css.clear()}},Oe=Object.freeze((()=>{let t=[Ce.toColor("#2e3436"),Ce.toColor("#cc0000"),Ce.toColor("#4e9a06"),Ce.toColor("#c4a000"),Ce.toColor("#3465a4"),Ce.toColor("#75507b"),Ce.toColor("#06989a"),Ce.toColor("#d3d7cf"),Ce.toColor("#555753"),Ce.toColor("#ef2929"),Ce.toColor("#8ae234"),Ce.toColor("#fce94f"),Ce.toColor("#729fcf"),Ce.toColor("#ad7fa8"),Ce.toColor("#34e2e2"),Ce.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=e[i/36%6|0],r=e[i/6%6|0],n=e[i%6];t.push({css:Me.toCss(s,r,n),rgba:Me.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;t.push({css:Me.toCss(s,s,s),rgba:Me.toRgba(s,s,s)})}return t})()),ki=Ce.toColor("#ffffff"),Zi=Ce.toColor("#000000"),sa=Ce.toColor("#ffffff"),ra=Zi,Vi={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Dp=ki,wn=class extends ne{constructor(t){super(),this._optionsService=t,this._contrastCache=new ia,this._halfContrastCache=new ia,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ki,background:Zi,cursor:sa,cursorAccent:ra,selectionForeground:void 0,selectionBackgroundTransparent:Vi,selectionBackgroundOpaque:be.blend(Zi,Vi),selectionInactiveBackgroundTransparent:Vi,selectionInactiveBackgroundOpaque:be.blend(Zi,Vi),scrollbarSliderBackground:be.opacity(ki,.2),scrollbarSliderHoverBackground:be.opacity(ki,.4),scrollbarSliderActiveBackground:be.opacity(ki,.5),overviewRulerBorder:ki,ansi:Oe.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=me(t.foreground,ki),e.background=me(t.background,Zi),e.cursor=be.blend(e.background,me(t.cursor,sa)),e.cursorAccent=be.blend(e.background,me(t.cursorAccent,ra)),e.selectionBackgroundTransparent=me(t.selectionBackground,Vi),e.selectionBackgroundOpaque=be.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=me(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=be.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?me(t.selectionForeground,Jo):void 0,e.selectionForeground===Jo&&(e.selectionForeground=void 0),be.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=be.opacity(e.selectionBackgroundTransparent,.3)),be.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=be.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=me(t.scrollbarSliderBackground,be.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=me(t.scrollbarSliderHoverBackground,be.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=me(t.scrollbarSliderActiveBackground,be.opacity(e.foreground,.5)),e.overviewRulerBorder=me(t.overviewRulerBorder,Dp),e.ansi=Oe.slice(),e.ansi[0]=me(t.black,Oe[0]),e.ansi[1]=me(t.red,Oe[1]),e.ansi[2]=me(t.green,Oe[2]),e.ansi[3]=me(t.yellow,Oe[3]),e.ansi[4]=me(t.blue,Oe[4]),e.ansi[5]=me(t.magenta,Oe[5]),e.ansi[6]=me(t.cyan,Oe[6]),e.ansi[7]=me(t.white,Oe[7]),e.ansi[8]=me(t.brightBlack,Oe[8]),e.ansi[9]=me(t.brightRed,Oe[9]),e.ansi[10]=me(t.brightGreen,Oe[10]),e.ansi[11]=me(t.brightYellow,Oe[11]),e.ansi[12]=me(t.brightBlue,Oe[12]),e.ansi[13]=me(t.brightMagenta,Oe[13]),e.ansi[14]=me(t.brightCyan,Oe[14]),e.ansi[15]=me(t.brightWhite,Oe[15]),t.extendedAnsi){let i=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let s=0;s<i;s++)e.ansi[s+16]=me(t.extendedAnsi[s],Oe[s+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()}}};wn=Pe([j(0,tt)],wn);function me(t,e){if(t!==void 0)try{return Ce.toColor(t)}catch{}return e}var Ap=class{constructor(...t){this._entries=new Map;for(let[e,i]of t)this.set(e,i)}set(t,e){let i=this._entries.get(t);return this._entries.set(t,e),i}forEach(t){for(let[e,i]of this._entries.entries())t(e,i)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},Tp=class{constructor(){this._services=new Ap,this._services.set(qn,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let i=kf(t).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[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,...s)}},Mp={trace:0,debug:1,info:2,warn:3,error:4,off:5},Lp="xterm.js: ",yn=class extends ne{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=Mp[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,i){this._evalLazyOptionalParams(i),t.call(console,(this._optionsService.options.logger?"":Lp)+e,...i)}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)}};yn=Pe([j(0,tt)],yn);var na=class extends ne{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 i=0;i<Math.min(t,this.length);i++)e[i]=this._array[this._getCyclicIndex(i)];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,...i){if(e){for(let s=t;s<this._length-e;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let s=this._length-1;s>=t;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(t+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:t,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,e,i){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=e-1;r>=0;r--)this.set(t+r+i,this.get(t+r));let s=t+e+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<e;s++)this.set(t+s+i,this.get(t+s))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},re=3,Te=Object.freeze(new fs),Is=0,Mr=2,Qi=class kh{constructor(e,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*re);let r=i||Dt.fromCharData([0,Ul,1,0]);for(let n=0;n<e;++n)this.setCell(n,r);this.length=e}get(e){let i=this._data[e*re+0],s=i&2097151;return[this._data[e*re+1],i&2097152?this._combined[e]:s?vi(s):"",i>>22,i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,i){this._data[e*re+1]=i[0],i[1].length>1?(this._combined[e]=i[1],this._data[e*re+0]=e|2097152|i[2]<<22):this._data[e*re+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(e){return this._data[e*re+0]>>22}hasWidth(e){return this._data[e*re+0]&12582912}getFg(e){return this._data[e*re+1]}getBg(e){return this._data[e*re+2]}hasContent(e){return this._data[e*re+0]&4194303}getCodePoint(e){let i=this._data[e*re+0];return i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i&2097151}isCombined(e){return this._data[e*re+0]&2097152}getString(e){let i=this._data[e*re+0];return i&2097152?this._combined[e]:i&2097151?vi(i&2097151):""}isProtected(e){return this._data[e*re+2]&536870912}loadCell(e,i){return Is=e*re,i.content=this._data[Is+0],i.fg=this._data[Is+1],i.bg=this._data[Is+2],i.content&2097152&&(i.combinedData=this._combined[e]),i.bg&268435456&&(i.extended=this._extendedAttrs[e]),i}setCell(e,i){i.content&2097152&&(this._combined[e]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*re+0]=i.content,this._data[e*re+1]=i.fg,this._data[e*re+2]=i.bg}setCellFromCodepoint(e,i,s,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*re+0]=i|s<<22,this._data[e*re+1]=r.fg,this._data[e*re+2]=r.bg}addCodepointToCell(e,i,s){let r=this._data[e*re+0];r&2097152?this._combined[e]+=vi(i):r&2097151?(this._combined[e]=vi(r&2097151)+vi(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[e*re+0]=r}insertCells(e,i,s){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length-e){let r=new Dt;for(let n=this.length-e-i-1;n>=0;--n)this.setCell(e+i+n,this.loadCell(e+n,r));for(let n=0;n<i;++n)this.setCell(e+n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,i,s){if(e%=this.length,i<this.length-e){let r=new Dt;for(let n=0;n<this.length-e-i;++n)this.setCell(e+n,this.loadCell(e+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,i,s,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);e<i&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);e<i&&e<this.length;)this.setCell(e++,s)}resize(e,i){if(e===this.length)return this._data.length*4*Mr<this._data.buffer.byteLength;let s=e*re;if(e>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);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,s*4*Mr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Mr<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,e);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 i in e._combined)this._combined[i]=e._combined[i];this._extendedAttrs={};for(let i in e._extendedAttrs)this._extendedAttrs[i]=e._extendedAttrs[i];this.isWrapped=e.isWrapped}clone(){let e=new kh(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let i in this._combined)e._combined[i]=this._combined[i];for(let i in this._extendedAttrs)e._extendedAttrs[i]=this._extendedAttrs[i];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*re+0]&4194303)return e+(this._data[e*re+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*re+0]&4194303||this._data[e*re+2]&50331648)return e+(this._data[e*re+0]>>22);return 0}copyCellsFrom(e,i,s,r,n){let o=e._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l<re;l++)this._data[(s+h)*re+l]=o[(i+h)*re+l];o[(i+h)*re+2]&268435456&&(this._extendedAttrs[s+h]=e._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let l=0;l<re;l++)this._data[(s+h)*re+l]=o[(i+h)*re+l];o[(i+h)*re+2]&268435456&&(this._extendedAttrs[s+h]=e._extendedAttrs[i+h])}let a=Object.keys(e._combined);for(let h=0;h<a.length;h++){let l=parseInt(a[h],10);l>=i&&(this._combined[l-i+s]=e._combined[l])}}translateToString(e,i,s,r){i=i??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*re+0],a=o&2097151,h=o&2097152?this._combined[i]:a?vi(a):bi;if(n+=h,r)for(let l=0;l<h.length;++l)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function Np(t,e,i,s,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&&s>=a&&s<h){a+=u.length-1;continue}let d=0,f=hs(u,d,e),_=1,p=0;for(;_<u.length;){let g=hs(u,_,e),v=g-p,k=i-f,b=Math.min(v,k);u[d].copyCellsFrom(u[_],p,f,b,!1),f+=b,f===i&&(d++,f=0),p+=b,p===g&&(_++,p=0),f===0&&d!==0&&u[d-1].getWidth(i-1)===2&&(u[d].copyCellsFrom(u[d-1],i-1,f++,1,!1),u[d-1].setCell(i-1,r))}u[d].replaceCells(f,i,r);let m=0;for(let g=u.length-1;g>0&&(g>d||u[g].getTrimmedLength()===0);g--)m++;m>0&&(o.push(a+u.length-m),o.push(m)),a+=u.length-1}return o}function Op(t,e){let i=[],s=0,r=e[s],n=0;for(let o=0;o<t.length;o++)if(r===o){let a=e[++s];t.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=e[++s]}else i.push(o);return{layout:i,countRemoved:n}}function Ip(t,e){let i=[];for(let s=0;s<e.length;s++)i.push(t.get(e[s]));for(let s=0;s<i.length;s++)t.set(s,i[s]);t.length=e.length}function jp(t,e,i){let s=[],r=t.map((h,l)=>hs(t,l,e)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let h=hs(t,o,e);n>h&&(n-=h,o++);let l=t[o].getWidth(n-1)===2;l&&n--;let u=l?i-1:i;s.push(u),a+=u}return s}function hs(t,e,i){if(e===t.length-1)return t[e].getTrimmedLength();let s=!t[e].hasContent(i-1)&&t[e].getWidth(i-1)===1,r=t[e+1].getWidth(0)===2;return s&&r?i-1:i}var Eh=class Ph{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Ph._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(),Ti(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Eh._nextId=1;var Hp=Eh,je={},Ei=je.B;je[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:"≥","{":"π","|":"≠","}":"£","~":"·"};je.A={"#":"£"};je.B=void 0;je[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};je.C=je[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};je.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};je.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};je.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};je.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};je.E=je[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};je.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};je.H=je[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};je["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var oa=4294967295,aa=class{constructor(t,e,i){this._hasScrollback=t,this._optionsService=e,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Te.clone(),this.savedCharset=Ei,this.markers=[],this._nullCell=Dt.fromCharData([0,Ul,1,0]),this._whitespaceCell=Dt.fromCharData([0,bi,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new tr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new na(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 Js),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 Js),this._whitespaceCell}getBlankLine(t,e){return new Qi(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>oa?oa:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Te);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 na(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let i=this.getNullCell(Te),s=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++)s+=+this.lines.get(o).resize(t,i);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 Qi(t,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Qi(t,i)));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++)s+=+this.lines.get(n).resize(t,i);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),s>.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 i=this._optionsService.rawOptions.reflowCursorLine,s=Np(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Te),i);if(s.length>0){let r=Op(this.lines,s);Ip(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,i){let s=this.getNullCell(Te),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new Qi(t,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(t,e){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Te),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(!i){let b=this.ybase+this.y;if(b>=o&&b<o+h.length)continue}let l=h[h.length-1].getTrimmedLength(),u=jp(h,this._cols,t),d=u.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+d):f=Math.max(0,this.lines.length-this.lines.maxLength+d);let _=[];for(let b=0;b<d;b++){let w=this.getBlankLine(Te,!0);_.push(w)}_.length>0&&(r.push({start:o+h.length+n,newLines:_}),n+=_.length),h.push(..._);let p=u.length-1,m=u[p];m===0&&(p--,m=u[p]);let g=h.length-d-1,v=l;for(;g>=0;){let b=Math.min(v,m);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[g],v-b,m-b,b,!0),m-=b,m===0&&(p--,m=u[p]),v-=b,v===0){g--;let w=Math.max(g,0);v=hs(h,w,this._cols)}}for(let b=0;b<h.length;b++)u[b]<t&&h[b].setCell(u[b],s);let k=d-f;for(;k-- >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 m=0;m<this.lines.length;m++)a.push(this.lines.get(m));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 f=0;for(let m=Math.min(this.lines.maxLength-1,h+n-1);m>=0;m--)if(d&&d.start>l+f){for(let g=d.newLines.length-1;g>=0;g--)this.lines.set(m--,d.newLines[g]);m++,o.push({index:l+1,amount:d.newLines.length}),f+=d.newLines.length,d=r[++u]}else this.lines.set(m,a[l--]);let _=0;for(let m=o.length-1;m>=0;m--)o[m].index+=_,this.lines.onInsertEmitter.fire(o[m]),_+=o[m].amount;let p=Math.max(0,h+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(t,e,i=0,s){let r=this.lines.get(t);return r?r.translateToString(e,i,s):""}getWrappedRangeForLine(t){let e=t,i=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:e,last:i}}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 Hp(t);return this.markers.push(e),e.register(this.lines.onTrim(i=>{e.line-=i,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(i=>{e.line>=i.index&&(e.line+=i.amount)})),e.register(this.lines.onDelete(i=>{e.line>=i.index&&e.line<i.index+i.amount&&e.dispose(),e.line>i.index&&(e.line-=i.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},Fp=class extends ne{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 aa(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new aa(!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)}},Rh=2,Bh=1,xn=class extends ne{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,Rh),this.rows=Math.max(t.rawOptions.rows||0,Bh),this.buffers=this._register(new Fp(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let i=this.cols!==t,s=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==t.fg||s.getBg(0)!==t.bg)&&(s=i.getBlankLine(t,e),this._cachedBlankLine=s),s.isWrapped=e;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(t,e){let i=this.buffer;if(t<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else t+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+t,i.ybase),0),s!==i.ydisp&&(e||this._onScroll.fire(i.ydisp))}};xn=Pe([j(0,tt)],xn);var ji={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:er,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},zp=["normal","bold","100","200","300","400","500","600","700","800","900"],Wp=class extends ne{constructor(t){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let e={...ji};for(let i in t)if(i in e)try{let s=t[i];e[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(we(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(t,e){return this.onOptionChange(i=>{i===t&&e(this.rawOptions[t])})}onMultipleOptionChange(t,e){return this.onOptionChange(i=>{t.indexOf(i)!==-1&&e()})}_setupOptions(){let t=i=>{if(!(i in ji))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},e=(i,s)=>{if(!(i in ji))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:t.bind(this,i),set:e.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=ji[t]),!$p(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=ji[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=zp.includes(e)?e:ji[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 $p(t){return t==="block"||t==="underline"||t==="bar"}function es(t,e=5){if(typeof t!="object")return t;let i=Array.isArray(t)?[]:{};for(let s in t)i[s]=e<=1?t[s]:t[s]&&es(t[s],e-1);return i}var la=Object.freeze({insertMode:!1}),ha=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Cn=class extends ne{constructor(t,e,i){super(),this._bufferService=t,this._logService=e,this._optionsService=i,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=es(la),this.decPrivateModes=es(ha)}reset(){this.modes=es(la),this.decPrivateModes=es(ha)}triggerDataEvent(t,e=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;e&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),e&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(s=>s.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))}};Cn=Pe([j(0,et),j(1,Gl),j(2,tt)],Cn);var ca={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 Lr(t,e){let i=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(i|=64,i|=t.action):(i|=t.button&3,t.button&4&&(i|=64),t.button&8&&(i|=128),t.action===32?i|=32:t.action===0&&!e&&(i|=3)),i}var Nr=String.fromCharCode,da={DEFAULT:t=>{let e=[Lr(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Nr(e[0])}${Nr(e[1])}${Nr(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Lr(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Lr(t,!0)};${t.x};${t.y}${e}`}},kn=class extends ne{constructor(t,e,i){super(),this._bufferService=t,this._coreService=e,this._optionsService=i,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 s of Object.keys(ca))this.addProtocol(s,ca[s]);for(let s of Object.keys(da))this.addEncoding(s,da[s]);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,i){if(t.deltaY===0||t.shiftKey||e===void 0||i===void 0)return 0;let s=e/i,r=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+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,i){if(i){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)}};kn=Pe([j(0,et),j(1,Ni),j(2,tt)],kn);var Or=[[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]],Up=[[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]],Ie;function Kp(t,e){let i=0,s=e.length-1,r;if(t<e[0][0]||t>e[s][1])return!1;for(;s>=i;)if(r=i+s>>1,t>e[r][1])i=r+1;else if(t<e[r][0])s=r-1;else return!0;return!1}var qp=class{constructor(){if(this.version="6",!Ie){Ie=new Uint8Array(65536),Ie.fill(1),Ie[0]=0,Ie.fill(0,1,32),Ie.fill(0,127,160),Ie.fill(2,4352,4448),Ie[9001]=2,Ie[9002]=2,Ie.fill(2,11904,42192),Ie[12351]=1,Ie.fill(2,44032,55204),Ie.fill(2,63744,64256),Ie.fill(2,65040,65050),Ie.fill(2,65072,65136),Ie.fill(2,65280,65377),Ie.fill(2,65504,65511);for(let t=0;t<Or.length;++t)Ie.fill(0,Or[t][0],Or[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Ie[t]:Kp(t,Up)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let i=this.wcwidth(t),s=i===0&&e!==0;if(s){let r=Ri.extractWidth(e);r===0?s=!1:r>i&&(i=r)}return Ri.createPropertyValue(0,i,s)}},Ri=class Us{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,i,s=!1){return(e&16777215)<<3|(i&3)<<1|(s?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 i=0,s=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 i+this.wcwidth(o);let l=e.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=Us.extractWidth(a);Us.extractShouldJoin(a)&&(h-=Us.extractWidth(s)),i+=h,s=a}return i}charProperties(e,i){return this._activeProvider.charProperties(e,i)}},Vp=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 ua(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);i&&e&&(i.isWrapped=e[3]!==0&&e[3]!==32)}var Yi=2147483647,Yp=256,Dh=class En{constructor(e=32,i=32){if(this.maxLength=e,this.maxSubParamsLength=i,i>Yp)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let i=new En;if(!e.length)return i;for(let s=Array.isArray(e[0])?1:0;s<e.length;++s){let r=e[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let e=new En(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 i=0;i<this.length;++i){e.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,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>Yi?Yi: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>Yi?Yi:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let i=this._subParamsIdx[e]>>8,s=this._subParamsIdx[e]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let e={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(e[i]=this._subParams.slice(s,r))}return e}addDigit(e){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+e,Yi):e}},Gi=[],Gp=class{constructor(){this._state=0,this._active=Gi,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 i=this._handlers[t];return i.push(e),{dispose:()=>{let s=i.indexOf(e);s!==-1&&i.splice(s,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=Gi}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=Gi,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Gi,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",fr(t,e,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(t,e,i)}start(){this.reset(),this._state=1}put(t,e,i){if(this._state!==3){if(this._state===1)for(;e<i;){let s=t[e++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-e>0&&this._put(t,e,i)}}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 i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(t),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Gi,this._id=-1,this._state=0}}},gt=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,i){this._hitLimit||(this._data+=fr(t,e,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,e}},Xi=[],Xp=class{constructor(){this._handlers=Object.create(null),this._active=Xi,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xi}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let i=this._handlers[t];return i.push(e),{dispose:()=>{let s=i.indexOf(e);s!==-1&&i.splice(s,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=Xi,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Xi,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(e)}put(t,e,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",fr(t,e,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(t,e,i)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(t),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Xi,this._ident=0}},ts=new Dh;ts.addParam(0);var fa=class{constructor(t){this._handler=t,this._data="",this._params=ts,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():ts,this._data="",this._hitLimit=!1}put(t,e,i){this._hitLimit||(this._data+=fr(t,e,i),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(i=>(this._params=ts,this._data="",this._hitLimit=!1,i));return this._params=ts,this._data="",this._hitLimit=!1,e}},Jp=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,i,s){this.table[e<<8|t]=i<<4|s}addMany(t,e,i,s){for(let r=0;r<t.length;r++)this.table[e<<8|t[r]]=i<<4|s}},Rt=160,Zp=(function(){let t=new Jp(4095),e=Array.apply(null,Array(256)).map((a,h)=>h),i=(a,h)=>e.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;t.setDefault(1,0),t.addMany(s,0,2,0);for(o in n)t.addMany([24,26,153,154],o,3,0),t.addMany(i(128,144),o,3,0),t.addMany(i(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(s,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(i(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(s,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(i(64,127),3,7,0),t.addMany(i(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(i(48,60),4,8,4),t.addMany(i(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(i(32,64),6,0,6),t.add(127,6,0,6),t.addMany(i(64,127),6,0,0),t.addMany(i(32,48),3,9,5),t.addMany(i(32,48),5,9,5),t.addMany(i(48,64),5,0,6),t.addMany(i(64,127),5,7,0),t.addMany(i(32,48),4,9,5),t.addMany(i(32,48),1,9,2),t.addMany(i(32,48),2,9,2),t.addMany(i(48,127),2,10,0),t.addMany(i(48,80),1,10,0),t.addMany(i(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(i(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(i(28,32),9,0,9),t.addMany(i(32,48),9,9,12),t.addMany(i(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(r,11,0,11),t.addMany(i(32,128),11,0,11),t.addMany(i(28,32),11,0,11),t.addMany(r,10,0,10),t.add(127,10,0,10),t.addMany(i(28,32),10,0,10),t.addMany(i(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(i(32,48),10,9,12),t.addMany(r,12,0,12),t.add(127,12,0,12),t.addMany(i(28,32),12,0,12),t.addMany(i(32,48),12,9,12),t.addMany(i(48,64),12,0,11),t.addMany(i(64,127),12,12,13),t.addMany(i(64,127),10,12,13),t.addMany(i(64,127),9,12,13),t.addMany(r,13,13,13),t.addMany(s,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Rt,0,2,0),t.add(Rt,8,5,8),t.add(Rt,6,0,6),t.add(Rt,11,0,11),t.add(Rt,13,13,13),t})(),Qp=class extends ne{constructor(t=Zp){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 Dh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,i,s)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,i)=>{},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(we(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Gp),this._dcsParser=this._register(new Xp),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(t,e=[64,126]){let i=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=t.prefix.charCodeAt(0),i&&60>i||i>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");i<<=8,i|=n}}if(t.final.length!==1)throw new Error("final must be a single byte");let s=t.final.charCodeAt(0);if(e[0]>s||s>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return i<<=8,i|=s,i}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 i=this._identifier(t,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(e),{dispose:()=>{let r=s.indexOf(e);r!==-1&&s.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 i=this._identifier(t);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(e),{dispose:()=>{let r=s.indexOf(e);r!==-1&&s.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,i,s,r){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(t,e,i){let s=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(i===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(i===!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(i===!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(s=t[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=t[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===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(s=t[a],r=this._transitions.table[this.currentState<<8|(s<160?s:Rt)],r>>4){case 2:for(let f=a+1;;++f){if(f>=e||(s=t[f])<32||s>126&&s<Rt){this._printHandler(t,a,f),a=f-1;break}if(++f>=e||(s=t[f])<32||s>126&&s<Rt){this._printHandler(t,a,f),a=f-1;break}if(++f>=e||(s=t[f])<32||s>126&&s<Rt){this._printHandler(t,a,f),a=f-1;break}if(++f>=e||(s=t[f])<32||s>126&&s<Rt){this._printHandler(t,a,f),a=f-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],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|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<e&&(s=t[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let u=this._escHandlers[this._collect<<8|s],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|s),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|s,this._params);break;case 13:for(let f=a+1;;++f)if(f>=e||(s=t[f])===24||s===26||s===27||s>127&&s<Rt){this._dcsParser.put(t,a,f),a=f-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===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 f=a+1;;f++)if(f>=e||(s=t[f])<32||s>127&&s<Rt){this._oscParser.put(t,a,f),a=f-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},em=/^([\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})$/,tm=/^[\da-f]+$/;function _a(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let i=em.exec(e);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),tm.exec(e)&&[3,6,9,12].includes(e.length))){let i=e.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(e.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Ir(t,e){let i=t.toString(16),s=i.length<2?"0"+i:i;switch(e){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function im(t,e=16){let[i,s,r]=t;return`rgb:${Ir(i,e)}/${Ir(s,e)}/${Ir(r,e)}`}var sm={"(":0,")":1,"*":2,"+":3,"-":1,".":2},gi=131072,pa=10;function ma(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 ga=5e3,va=0,rm=class extends ne{constructor(t,e,i,s,r,n,o,a,h=new Qp){super(),this._bufferService=t,this._charsetService=e,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new xf,this._utf8Decoder=new Cf,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Te.clone(),this._eraseAttrDataInternal=Te.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 Pn(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(T.BEL,()=>this.bell()),this._parser.setExecuteHandler(T.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(T.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(T.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(T.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(T.BS,()=>this.backspace()),this._parser.setExecuteHandler(T.HT,()=>this.tab()),this._parser.setExecuteHandler(T.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(T.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ws.IND,()=>this.index()),this._parser.setExecuteHandler(Ws.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ws.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new gt(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new gt(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new gt(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new gt(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new gt(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new gt(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new gt(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new gt(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new gt(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new gt(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new gt(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new gt(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 je)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 fa((l,u)=>this.requestStatusString(l,u)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),ga))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${ga} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>gi&&(n=this._parseStack.position+gi)}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<gi&&(this._parseBuffer=new Uint32Array(Math.min(t.length,gi))),o||this._dirtyRowTracker.clearRange(),t.length>gi)for(let l=n;l<t.length;l+=gi){let u=l+gi<t.length?l+gi: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(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,r,d,l),this._logSlowResolvingAsync(i),i}else if(!o){let l=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,l))return this._preserveStack(s,r,l,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||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,i){let s,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&&i-e>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let _=e;_<i;++_){if(s=t[_],s<127&&n){let v=n[String.fromCharCode(s)];v&&(s=v.charCodeAt(0))}let p=this._unicodeService.charProperties(s,f);r=Ri.extractWidth(p);let m=Ri.extractShouldJoin(p),g=m?Ri.extractWidth(f):0;if(f=p,o&&this._onA11yChar.fire(vi(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>a){if(h){let v=d,k=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 Qi&&d.copyCellsFrom(v,k,0,g,!1);k<a;)v.setCellFromCodepoint(k++,0,1,u)}else if(this._activeBuffer.x=a-1,r===2)continue}if(m&&this._activeBuffer.x){let v=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-v,s,r);for(let k=r-g;--k>=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++,s,r,u),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<a&&i-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,i=>ma(i.params[0],this._optionsService.rawOptions.windowOptions)?e(i):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new fa(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new gt(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,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n.replaceCells(e,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(t,e=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),i.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let i;switch(t.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);i<this._bufferService.rows;i++)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+i)?.getTrimmedLength(););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,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 i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;e--;)this._activeBuffer.lines.splice(r-1,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}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 i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;e--;)this._activeBuffer.lines.splice(i,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}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(Te));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=t.params[0]||1,s=Ri.extractWidth(e),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),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<i;++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(T.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(T.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(T.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(T.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(T.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,Ei),this._charsetService.setgCharset(1,Ei),this._charsetService.setgCharset(2,Ei),this._charsetService.setgCharset(3,Ei);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 i;(m=>(m[m.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",m[m.SET=1]="SET",m[m.RESET=2]="RESET",m[m.PERMANENTLY_SET=3]="PERMANENTLY_SET",m[m.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(i||={});let s=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,f=(m,g)=>(o.triggerDataEvent(`${T.ESC}[${e?"":"?"}${m};${g}$y`),!0),_=m=>m?1:2,p=t.params[0];return e?p===2?f(p,4):p===4?f(p,_(o.modes.insertMode)):p===12?f(p,3):p===20?f(p,_(d.convertEol)):f(p,0):p===1?f(p,_(s.applicationCursorKeys)):p===3?f(p,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?f(p,_(s.origin)):p===7?f(p,_(s.wraparound)):p===8?f(p,3):p===9?f(p,_(r==="X10")):p===12?f(p,_(d.cursorBlink)):p===25?f(p,_(!o.isCursorHidden)):p===45?f(p,_(s.reverseWraparound)):p===66?f(p,_(s.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,_(r==="VT200")):p===1002?f(p,_(r==="DRAG")):p===1003?f(p,_(r==="ANY")):p===1004?f(p,_(s.sendFocus)):p===1005?f(p,4):p===1006?f(p,_(n==="SGR")):p===1015?f(p,4):p===1016?f(p,_(n==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,_(l===u)):p===2004?f(p,_(s.bracketedPasteMode)):p===2026?f(p,_(s.synchronizedOutput)):f(p,0)}_updateAttrColor(t,e,i,s,r){return e===2?(t|=50331648,t&=-16777216,t|=fs.fromColorRGB([i,s,r])):e===5&&(t&=-50331904,t|=33554432|i&255),t}_extractColor(t,e,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=t.params[e+n],t.hasSubParams(e+n)){let o=t.getSubParams(e+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+e<t.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[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=Te.fg,t.bg=Te.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,i,s=this._curAttrData;for(let r=0;r<e;r++)i=t.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(t.hasSubParams(r)?t.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Te.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Te.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(t,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Te.fg&16777215,s.bg&=-67108864,s.bg|=Te.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${T.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${T.ESC}[${e};${i}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${T.ESC}[?${e};${i}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=Te.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 i=e%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(t){let e=t.params[0]||1,i;return(t.length<2||(i=t.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(t){if(!ma(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(`${T.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>pa&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>pa&&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=[],i=t.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(ba(n))if(r==="?")e.push({type:0,index:n});else{let o=_a(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 i=t.slice(0,e).trim(),s=t.slice(e+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let i=t.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 i=t.split(";");for(let s=0;s<i.length&&!(e>=this._specialColors.length);++s,++e)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=_a(i[s]);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=[],i=t.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);ba(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,Ei),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(sm[t[0]],je[t[1]]||Ei),!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=Te.clone(),this._eraseAttrDataInternal=Te.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 Dt;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 i=this._activeBuffer.ybase+this._activeBuffer.y+e,s=this._activeBuffer.lines.get(i);s&&(s.fill(t),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let i=o=>(this._coreService.triggerDataEvent(`${T.ESC}${o}${T.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${s.scrollTop+1};${s.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)}},Pn=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&&(va=t,t=e,e=va),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Pn=Pe([j(0,et)],Pn);function ba(t){return 0<=t&&t<256}var nm=5e7,Sa=12,om=50,am=class extends ne{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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>nm)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 i=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,e);if(r){let o=a=>performance.now()-i>=Sa?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,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-=s.length,performance.now()-i>=Sa)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>om&&(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()}},Rn=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 i=t,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);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(i),data:i,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 i=this._dataByLinkId.get(t);if(i&&i.lines.every(s=>s.line!==e)){let s=this._bufferService.buffer.addMarker(e);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let i=t.lines.indexOf(e);i!==-1&&(t.lines.splice(i,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};Rn=Pe([j(0,et)],Rn);var wa=!1,lm=class extends ne{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new Fi),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 Tp,this.optionsService=this._register(new Wp(t)),this._instantiationService.setService(tt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(xn)),this._instantiationService.setService(et,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(yn)),this._instantiationService.setService(Gl,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Cn)),this._instantiationService.setService(Ni,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(kn)),this._instantiationService.setService(Yl,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ri)),this._instantiationService.setService(Rf,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Vp),this._instantiationService.setService(Pf,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Rn),this._instantiationService.setService(Xl,this._oscLinkService),this._inputHandler=this._register(new rm(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ve.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ve.forward(this._bufferService.onResize,this._onResize)),this._register(Ve.forward(this.coreService.onData,this._onData)),this._register(Ve.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 am((e,i)=>this._inputHandler.parse(e,i))),this._register(Ve.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&&!wa&&(this._logService.warn("writeSync is unreliable and will be removed soon."),wa=!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,Rh),e=Math.max(e,Bh),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(ua.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(ua(this._bufferService),!1))),this._windowsWrappingHeuristics.value=we(()=>{for(let e of t)e.dispose()})}}},hm={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 cm(t,e,i,s){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=T.ESC+"OA":r.key=T.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=T.ESC+"OD":r.key=T.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=T.ESC+"OC":r.key=T.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=T.ESC+"OB":r.key=T.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":T.DEL,t.altKey&&(r.key=T.ESC+r.key);break;case 9:if(t.shiftKey){r.key=T.ESC+"[Z";break}r.key=T.HT,r.cancel=!0;break;case 13:r.key=t.altKey?T.ESC+T.CR:T.CR,r.cancel=!0;break;case 27:r.key=T.ESC,t.altKey&&(r.key=T.ESC+T.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;n?r.key=T.ESC+"[1;"+(n+1)+"D":e?r.key=T.ESC+"OD":r.key=T.ESC+"[D";break;case 39:if(t.metaKey)break;n?r.key=T.ESC+"[1;"+(n+1)+"C":e?r.key=T.ESC+"OC":r.key=T.ESC+"[C";break;case 38:if(t.metaKey)break;n?r.key=T.ESC+"[1;"+(n+1)+"A":e?r.key=T.ESC+"OA":r.key=T.ESC+"[A";break;case 40:if(t.metaKey)break;n?r.key=T.ESC+"[1;"+(n+1)+"B":e?r.key=T.ESC+"OB":r.key=T.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=T.ESC+"[2~");break;case 46:n?r.key=T.ESC+"[3;"+(n+1)+"~":r.key=T.ESC+"[3~";break;case 36:n?r.key=T.ESC+"[1;"+(n+1)+"H":e?r.key=T.ESC+"OH":r.key=T.ESC+"[H";break;case 35:n?r.key=T.ESC+"[1;"+(n+1)+"F":e?r.key=T.ESC+"OF":r.key=T.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=T.ESC+"[5;"+(n+1)+"~":r.key=T.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=T.ESC+"[6;"+(n+1)+"~":r.key=T.ESC+"[6~";break;case 112:n?r.key=T.ESC+"[1;"+(n+1)+"P":r.key=T.ESC+"OP";break;case 113:n?r.key=T.ESC+"[1;"+(n+1)+"Q":r.key=T.ESC+"OQ";break;case 114:n?r.key=T.ESC+"[1;"+(n+1)+"R":r.key=T.ESC+"OR";break;case 115:n?r.key=T.ESC+"[1;"+(n+1)+"S":r.key=T.ESC+"OS";break;case 116:n?r.key=T.ESC+"[15;"+(n+1)+"~":r.key=T.ESC+"[15~";break;case 117:n?r.key=T.ESC+"[17;"+(n+1)+"~":r.key=T.ESC+"[17~";break;case 118:n?r.key=T.ESC+"[18;"+(n+1)+"~":r.key=T.ESC+"[18~";break;case 119:n?r.key=T.ESC+"[19;"+(n+1)+"~":r.key=T.ESC+"[19~";break;case 120:n?r.key=T.ESC+"[20;"+(n+1)+"~":r.key=T.ESC+"[20~";break;case 121:n?r.key=T.ESC+"[21;"+(n+1)+"~":r.key=T.ESC+"[21~";break;case 122:n?r.key=T.ESC+"[23;"+(n+1)+"~":r.key=T.ESC+"[23~";break;case 123:n?r.key=T.ESC+"[24;"+(n+1)+"~":r.key=T.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=T.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=T.DEL:t.keyCode===219?r.key=T.ESC:t.keyCode===220?r.key=T.FS:t.keyCode===221&&(r.key=T.GS);else if((!i||s)&&t.altKey&&!t.metaKey){let o=hm[t.keyCode]?.[t.shiftKey?1:0];if(o)r.key=T.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=T.ESC+h}else if(t.keyCode===32)r.key=T.ESC+(t.ctrlKey?T.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let a=t.code.slice(3,4);t.shiftKey||(a=a.toLowerCase()),r.key=T.ESC+a,r.cancel=!0}}else i&&!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=T.US),t.key==="@"&&(r.key=T.NUL));break}return r}var Re=0,dm=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new tr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new tr,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,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[i])?(s[r]=t[e],e++):s[r]=this._array[i++];this._array=s,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||(Re=this._search(e),Re===-1)||this._getKey(this._array[Re])!==e)return!1;do if(this._array[Re]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Re),!0;while(++Re<this._array.length&&this._getKey(this._array[Re])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,n)=>r-n),e=0,i=new Array(this._array.length-t.length),s=0;for(let r=0;r<this._array.length;r++)t[e]===r?e++:i[s++]=this._array[r];this._array=i,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&&(Re=this._search(t),!(Re<0||Re>=this._array.length)&&this._getKey(this._array[Re])===t))do yield this._array[Re];while(++Re<this._array.length&&this._getKey(this._array[Re])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Re=this._search(t),!(Re<0||Re>=this._array.length)&&this._getKey(this._array[Re])===t))do e(this._array[Re]);while(++Re<this._array.length&&this._getKey(this._array[Re])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,i=this._array.length-1;for(;i>=e;){let s=e+i>>1,r=this._getKey(this._array[s]);if(r>t)i=s-1;else if(r<t)e=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===t;)s--;return s}}return e}},jr=0,ya=0,um=class extends ne{constructor(){super(),this._decorations=new dm(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(we(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new fm(t);if(e){let i=e.marker.onDispose(()=>e.dispose()),s=e.onDispose(()=>{s.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),i.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,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(e))s=n.options.x??0,r=s+(n.options.width??1),t>=s&&t<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(t,e,i,s){this._decorations.forEachByKey(e,r=>{jr=r.options.x??0,ya=jr+(r.options.width??1),t>=jr&&t<ya&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},fm=class extends Si{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=Ce.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ce.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},_m=1e3,pm=class{constructor(t,e=_m){this._renderCallback=t,this._debounceThresholdMS=e,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,e,i){this._rowCount=i,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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-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)}},xa=20,ir=class extends ne{constructor(t,e,i,s){super(),this._terminal=t,this._coreBrowserService=i,this._renderService=s,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 pm(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(`
23
23
  `))),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(Z(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(we(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<xa+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
24
24
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===xa+1&&(this._liveRegion.textContent+=Vr.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 i=this._terminal.buffer,s=i.lines.length.toString();for(let r=t;r<=e;r++){let n=i.lines.get(i.ydisp+r),o=[],a=n?.translateToString(!0,void 0,void 0,o)||"",h=(i.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",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let i=t.target,s=this._rowElements[e===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||t.relatedTarget!==s)return;let o,a;if(e===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,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},i={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===i.node&&e.offset>i.offset)&&([e,i]=[i,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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(i.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 f=h<d.length?d[h]:d.slice(-1)[0]+1;return f>=this._terminal.cols&&(++u,f=0),{row:u,column:f}},n=r(e),o=r(i);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,i=this._rowColumns.get(t)?.slice(-1)?.[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${s/e})`}};ir=Pe([j(1,qn),j(2,di),j(3,ui)],ir);var Bn=class extends ne{constructor(t,e,i,s,r){super(),this._element=t,this._mouseService=e,this._renderService=i,this._bufferService=s,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(we(()=>{Ti(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(Z(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Z(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Z(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Z(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 i=t.composedPath();for(let s=0;s<i.length;s++){let r=i[s];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(s=>{s?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let i=!1;for(let[s,r]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(s)&&(i=this._checkLinkProviderResult(s,t,i)):r.provideLinks(t.y,n=>{if(this._isMouseOut)return;let o=n?.map(a=>({link:a}));this._activeProviderReplies?.set(s,o),i=this._checkLinkProviderResult(s,t,i),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let i=new Set;for(let s=0;s<e.size;s++){let r=e.get(s);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(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_checkLinkProviderResult(t,e,i){if(!this._activeProviderReplies)return i;let s=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&&s){let n=s.find(o=>this._linkAtPosition(o.link,e));n&&(i=!0,this._handleNewLink(n))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let n=0;n<this._activeProviderReplies.size;n++){let o=this._activeProviderReplies.get(n)?.find(a=>this._linkAtPosition(a.link,e));if(o){i=!0,this._handleNewLink(o);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&mm(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,Ti(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:i=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(t,e,i){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(i,e.text)}_fireUnderlineEvent(t,e){let i=t.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(t,e,i){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(i,e.text)}_linkAtPosition(t,e){let i=t.range.start.y*this._bufferService.cols+t.range.start.x,s=t.range.end.y*this._bufferService.cols+t.range.end.x,r=e.y*this._bufferService.cols+e.x;return i<=r&&r<=s}_positionFromMouseEvent(t,e,i){let s=i.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,i,s,r){return{x1:t,y1:e,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Bn=Pe([j(1,Vn),j(2,ui),j(3,et),j(4,Zl)],Bn);function mm(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 gm=class extends lm{constructor(t={}){super(t),this._linkifier=this._register(new Fi),this.browser=gh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Fi),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(um),this._instantiationService.setService(_s,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(op),this._instantiationService.setService(Zl,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Gr)),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(Ve.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ve.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ve.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ve.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(we(()=>{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 i,s="";switch(e.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+e.index}switch(e.type){case 0:let r=be.toColorRGB(i==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${T.ESC}]${s};${im(r)}${ph.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[e.index]=Me.toColor(...e.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=Me.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(ir,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(T.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(T.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=e.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*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=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Z(this.element,"copy",e=>{this.hasSelection()&&wf(e,this._selectionService)}));let t=e=>yf(e,this.textarea,this.coreService,this.optionsService);this._register(Z(this.textarea,"paste",t)),this._register(Z(this.element,"paste",t)),vh?this._register(Z(this.element,"mousedown",e=>{e.button===2&&Mo(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Z(this.element,"contextmenu",e=>{Mo(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),to&&this._register(Z(this.element,"auxclick",e=>{e.button===1&&$l(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Z(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(Z(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(Z(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(Z(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Z(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(Z(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Z(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(Z(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 i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",qr.get()),wh||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(rp,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(di,this._coreBrowserService),this._register(Z(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(Z(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(gn,this._document,this._helperContainer),this._instantiationService.setService(_r,this._charSizeService),this._themeService=this._instantiationService.createInstance(wn),this._instantiationService.setService($i,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Qs),this._instantiationService.setService(Jl,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(bn,this.rows,this.screenElement)),this._instantiationService.setService(ui,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(_n,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(vn),this._instantiationService.setService(Vn,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Bn,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(un,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(Sn,this.element,this.screenElement,s)),this._instantiationService.setService(Df,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(Ve.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(fn,this.screenElement)),this._register(Z(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(ir,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Zs,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Zs,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(mn,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function i(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 s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(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?s.mousemove||(e.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(e.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(e.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Z(e,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(Z(e,"wheel",n=>{if(!s.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=T.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){Wl(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,i){this._selectionService.setSelection(t,e,i)}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 i=cm(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(t,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,t)||(i.cancel&&this.cancel(t,!0),!i.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((i.key===T.ETX||i.key===T.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey)return this.cancel(t,!0);this._keyDownHandled=!0}_isThirdLevelShift(t,e){let i=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"?i:i&&(!e.keyCode||e.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)&&(vm(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(Te));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(T.ESC+"[I"):this.coreService.triggerDataEvent(T.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${T.ESC}[4;${i};${e}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${T.ESC}[6;${r};${s}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function vm(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var bm=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let i={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(i),e.dispose=()=>this._wrappedAddonDispose(i),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===t){e=i;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)}},Sm=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 Dt)}translateToString(t,e,i){return this._line.translateToString(t,e,i)}},Ca=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 Sm(e)}getNullCell(){return new Dt}},wm=class extends ne{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new Ca(this._core.buffers.normal,"normal"),this._alternate=new Ca(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)}},ym=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,i=>e(i.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(i,s)=>e(i,s.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)}},xm=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}},Cm=["cols","rows"],Zt=0,km=class extends ne{constructor(t){super(),this._core=this._register(new gm(t)),this._addonManager=this._register(new bm),this._publicOptions={...this._core.options};let e=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:e.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(t){if(Cm.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 ym(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new xm(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 wm(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,i){this._verifyIntegers(t,e,i),this._core.select(t,e,i)}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
25
- `,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 qr.get()},set promptLabel(t){qr.set(t)},get tooMuchOutput(){return Vr.get()},set tooMuchOutput(t){Vr.set(t)}}}_verifyIntegers(...t){for(Zt of t)if(Zt===1/0||isNaN(Zt)||Zt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Zt of t)if(Zt&&(Zt===1/0||isNaN(Zt)||Zt%1!==0||Zt<0))throw new Error("This API only accepts positive integers")}};var Em=2,Pm=1,Rm=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,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.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=s-a,u=r-h-e;return{cols:Math.max(Em,Math.floor(u/t.css.cell.width)),rows:Math.max(Pm,Math.floor(l/t.css.cell.height))}}};function Bm({source:t,onReady:e,onSelectionChange:i,className:s}){const r=X.useRef(null),n=X.useRef(null),o=X.useRef(i);o.current=i;const a=dr(),h=X.useRef(t);return h.current=t,nl((l,u)=>{l===h.current&&n.current?.write(u)}),X.useEffect(()=>{const l=r.current;if(!l)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,f=new km({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")}}),_=new Rm;f.loadAddon(_),f.open(l),_.fit();const p=a.getBuffer(t);p&&f.write(p),n.current=f,e?.(f);const m=f.onSelectionChange(()=>{const v=!!f.getSelection();o.current?.(v,()=>f.getSelection())}),g=new ResizeObserver(()=>{_.fit()});return g.observe(l),()=>{m.dispose(),g.disconnect(),n.current=null,f.dispose()}},[]),c.jsx("div",{className:le("h-full bg-sidebar p-3",s),children:c.jsx("div",{ref:r,className:"h-full"})})}const Dn=120,Ah=160;function Dm(t,e,i=Ah){const s=Math.max(Dn,e-i);return Math.min(Math.max(t,Dn),s)}function Am(t){const e=Be(),i=dr(),[s,r]=X.useState(Bi),[n,o]=X.useState([]),[a,h]=X.useState(new Set),l=X.useRef(!1);if(!l.current&&i.scripts.length>0){const L=nd.find(y=>i.scripts.includes(y));L&&(l.current=!0,o(y=>y.includes(L)?y:[...y,L]),r(L))}if(a.size>0){let L=!1;const y=new Set(a);for(const E of a)i.activeProcesses.includes(E)||(y.delete(E),L=!0);L&&h(y)}const u=()=>t.onOpenChange(!t.open),d=L=>{r(L),t.open||t.onOpenChange(!0)},f=Wi()?.taskId??null,_={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId??"",branch:t.branch??"",threadId:f??null},p=L=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(co(_,`exec/${encodeURIComponent(L)}`),{method:"POST"}),m=L=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(co(_,`exec/${encodeURIComponent(L)}/kill`),{method:"POST"}),g=async(L,y)=>{try{const E=await p(L);if(E===null)return;if(!E.ok)throw new Error(`Exec failed: ${E.statusText}`)}catch{Xe.error(y)}},v=async L=>{o(y=>y.includes(L)?y:[...y,L]),r(L),t.onOpenChange(!0),await g(L,e("sandbox.drawer.failedToRun",{name:L}))},k=async L=>{await m(L),o(y=>y.filter(E=>E!==L)),s===L&&r(Bi)},b=async()=>{const y=i.activeProcesses.includes(s)?e("sandbox.drawer.failedToRestart",{name:s}):e("sandbox.drawer.failedToRun",{name:s});await g(s,y)},w=async()=>{if(!a.has(s)){h(L=>new Set(L).add(s));try{const L=await m(s);if(L===null){h(y=>{const E=new Set(y);return E.delete(s),E});return}if(!L.ok)throw new Error(`Kill failed: ${L.statusText}`)}catch{h(L=>{const y=new Set(L);return y.delete(s),y}),Xe.error(e("sandbox.drawer.failedToStop",{name:s}))}}},C=s!==Bi&&n.includes(s),S=C&&i.activeProcesses.includes(s),R=C&&a.has(s),N=X.useRef(null),I=L=>{if(!t.open)return;const y=N.current,E=y?.parentElement;if(!y||!E)return;L.preventDefault();const x=L.currentTarget,{pointerId:A}=L;x.setPointerCapture(A);const D=L.clientY,P=y.getBoundingClientRect().height,B=E.getBoundingClientRect().height;let M=P;const K=H=>{H.pointerId===A&&(M=Dm(P+(D-H.clientY),B),y.style.height=`${M}px`)},F=H=>{H.pointerId===A&&(x.removeEventListener("pointermove",K),x.removeEventListener("pointerup",F),x.removeEventListener("pointercancel",F),document.body.style.userSelect="",document.body.style.cursor="",t.onHeightChange(M))};document.body.style.userSelect="none",document.body.style.cursor="row-resize",x.addEventListener("pointermove",K),x.addEventListener("pointerup",F),x.addEventListener("pointercancel",F)};return c.jsxs("div",{ref:N,className:"flex shrink-0 flex-col",style:{height:t.open?t.height??"50%":"auto",maxHeight:t.open?`max(${Dn}px, calc(100% - ${Ah}px))`:void 0},children:[t.open&&c.jsx(Mm,{onPointerDown:I,label:e("sandbox.preview.resizeTerminal")}),c.jsx(df,{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:s,scriptTabs:n,onSelectTab:d,onAddScript:v,onCloseScript:k,showScriptControls:C,scriptIsRunning:S,scriptIsKilling:R,onRunActiveScript:b,onStopActiveScript:w}),t.open&&c.jsx("div",{className:"flex-1 overflow-hidden",children:c.jsx(Tm,{vmId:t.vmId,active:s,hasData:i.hasData(s),onRunActive:b})})]})}function Tm(t){const e=U.c(16),{vmId:i,active:s,hasData:r,onRunActive:n}=t,o=Be();if(!i)return null;if(s===Bi||r){let _;return e[0]!==s?(_=c.jsx(Bm,{source:s,className:"h-full"},s),e[0]=s,e[1]=_):_=e[1],_}let a;e[2]!==s||e[3]!==o?(a=o("sandbox.drawer.scriptNotRunning",{name:s}),e[2]=s,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(Ks,{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 f;return e[13]!==h||e[14]!==d?(f=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]=f):f=e[15],f}function Mm(t){const e=U.c(4),{onPointerDown:i,label:s}=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]!==s||e[2]!==i?(n=c.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":s,onPointerDown:i,className:"group relative -mb-px h-1.5 shrink-0 cursor-row-resize",children:r}),e[1]=s,e[2]=i,e[3]=n):n=e[3],n}function Lm(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 Th=t=>`preview-drawer:${t}`,Nm=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function Om(t){try{return Lm(localStorage.getItem(Th(t)))}catch{return{open:!1,height:null}}}function ka(t,e){try{localStorage.setItem(Th(t),JSON.stringify(e))}catch{}}function Im(){const t=U.c(27),{org:e}=rr(),i=Wi()?.virtualMcpId??null,s=vl(),r=dr(),n=X.useRef(null);let o;t[0]!==r||t[1]!==s||t[2]!==i?(o=C=>{C!=="setup"||!i||n.current!==i&&Nm.test(r.getBuffer("setup"))&&(n.current=i,s.restart())},t[0]=r,t[1]=s,t[2]=i,t[3]=o):o=t[3],nl(o);const a=i??"__no-vmcp__",[h,l]=X.useState(null),[u,d]=X.useState(null),f=X.useRef(null);if(f.current!==a){f.current=a;const C=Om(a);l(C.open),d(C.height)}const _=h??!1;let p;t[4]!==u||t[5]!==a?(p=C=>{l(C),ka(a,{open:C,height:u})},t[4]=u,t[5]=a,t[6]=p):p=t[6];const m=p;let g;t[7]!==_||t[8]!==a?(g=C=>{d(C),ka(a,{open:_,height:C})},t[7]=_,t[8]=a,t[9]=g):g=t[9];const v=g,k=s.vmEntry?.sandboxHandle??"no-vm",b=s.vmEntry?.sandboxHandle??null;let w;return t[10]!==u||t[11]!==r.scripts||t[12]!==v||t[13]!==m||t[14]!==s.branch||t[15]!==s.restart||t[16]!==s.resume||t[17]!==s.retry||t[18]!==s.start||t[19]!==s.status||t[20]!==s.stop||t[21]!==_||t[22]!==e.slug||t[23]!==k||t[24]!==b||t[25]!==i?(w=c.jsx(Am,{vmId:b,orgSlug:e.slug,virtualMcpId:i,branch:s.branch,status:s.status,scripts:r.scripts,open:_,onOpenChange:m,height:u,onHeightChange:v,onStart:s.start,onStop:s.stop,onRestart:s.restart,onResume:s.resume,onRetry:s.retry},k),t[10]=u,t[11]=r.scripts,t[12]=v,t[13]=m,t[14]=s.branch,t[15]=s.restart,t[16]=s.resume,t[17]=s.retry,t[18]=s.start,t[19]=s.status,t[20]=s.stop,t[21]=_,t[22]=e.slug,t[23]=k,t[24]=b,t[25]=i,t[26]=w):w=t[26],w}function jm(){const t=U.c(10),e=Wi(),i=hr(e?.virtualMcpId),s=e?.currentBranch??null,r=cr(i?.id).runtime,{url:n}=In(i?.id);if(!i)return null;let o;t[0]!==s||t[1]!==i?(o=c.jsx("div",{className:"flex min-w-0 shrink items-center justify-end",children:c.jsx(wd,{virtualMcp:i,currentBranch:s})}),t[0]=s,t[1]=i,t[2]=o):o=t[2];let a;t[3]!==i||t[4]!==n||t[5]!==r?(a=!n&&Jc(i)&&c.jsxs(c.Fragment,{children:[c.jsx(Vh,{orientation:"vertical",className:"mx-1 data-[orientation=vertical]:h-4"}),c.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:r==="cms"?c.jsx(qu,{virtualMcpId:i.id}):c.jsx(of,{virtualMcpId:i.id})})]}),t[3]=i,t[4]=n,t[5]=r,t[6]=a):a=t[6];let h;return t[7]!==o||t[8]!==a?(h=c.jsxs(c.Fragment,{children:[o,a]}),t[7]=o,t[8]=a,t[9]=h):h=t[9],h}function Hm(){const t=U.c(8),e=Wi(),i=hr(e?.virtualMcpId),s=e?.activeTask,r=Zc(),n=cr(i?.id).runtime,{url:o}=In(i?.id);let a;t[0]!==r||t[1]!==s?.metadata||t[2]!==i?.metadata||t[3]!==o||t[4]!==n?(a=!o&&cf({hasClonableSource:ho(i?.metadata)||ho(s?.metadata),fastPreviewActive:n==="cms",mainTab:r??null}),t[0]=r,t[1]=s?.metadata,t[2]=i?.metadata,t[3]=o,t[4]=n,t[5]=a):a=t[5];const h=a;let l;return t[6]!==h?(l=h?c.jsx(Im,{}):null,t[6]=h,t[7]=l):l=t[7],l}function j1(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(ed.Content,{actions:c.jsx(jm,{}),drawer:c.jsx(Hm,{}),children:c.jsx(qh,{})}),t[0]=e):e=t[0],e}export{j1 as default};
25
+ `,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 qr.get()},set promptLabel(t){qr.set(t)},get tooMuchOutput(){return Vr.get()},set tooMuchOutput(t){Vr.set(t)}}}_verifyIntegers(...t){for(Zt of t)if(Zt===1/0||isNaN(Zt)||Zt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Zt of t)if(Zt&&(Zt===1/0||isNaN(Zt)||Zt%1!==0||Zt<0))throw new Error("This API only accepts positive integers")}};var Em=2,Pm=1,Rm=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,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.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=s-a,u=r-h-e;return{cols:Math.max(Em,Math.floor(u/t.css.cell.width)),rows:Math.max(Pm,Math.floor(l/t.css.cell.height))}}};function Bm({source:t,onReady:e,onSelectionChange:i,className:s}){const r=X.useRef(null),n=X.useRef(null),o=X.useRef(i);o.current=i;const a=dr(),h=X.useRef(t);return h.current=t,nl((l,u)=>{l===h.current&&n.current?.write(u)}),X.useEffect(()=>{const l=r.current;if(!l)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,f=new km({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")}}),_=new Rm;f.loadAddon(_),f.open(l),_.fit();const p=a.getBuffer(t);p&&f.write(p),n.current=f,e?.(f);const m=f.onSelectionChange(()=>{const v=!!f.getSelection();o.current?.(v,()=>f.getSelection())}),g=new ResizeObserver(()=>{_.fit()});return g.observe(l),()=>{m.dispose(),g.disconnect(),n.current=null,f.dispose()}},[]),c.jsx("div",{className:le("h-full bg-sidebar p-3",s),children:c.jsx("div",{ref:r,className:"h-full"})})}const Dn=120,Ah=160;function Dm(t,e,i=Ah){const s=Math.max(Dn,e-i);return Math.min(Math.max(t,Dn),s)}function Am(t){const e=Be(),i=dr(),[s,r]=X.useState(Bi),[n,o]=X.useState([]),[a,h]=X.useState(new Set),l=X.useRef(!1);if(!l.current&&i.scripts.length>0){const L=nd.find(y=>i.scripts.includes(y));L&&(l.current=!0,o(y=>y.includes(L)?y:[...y,L]),r(L))}if(a.size>0){let L=!1;const y=new Set(a);for(const E of a)i.activeProcesses.includes(E)||(y.delete(E),L=!0);L&&h(y)}const u=()=>t.onOpenChange(!t.open),d=L=>{r(L),t.open||t.onOpenChange(!0)},f=Wi()?.taskId??null,_={orgSlug:t.orgSlug,virtualMcpId:t.virtualMcpId??"",branch:t.branch??"",threadId:f??null},p=L=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(co(_,`exec/${encodeURIComponent(L)}`),{method:"POST"}),m=L=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(co(_,`exec/${encodeURIComponent(L)}/kill`),{method:"POST"}),g=async(L,y)=>{try{const E=await p(L);if(E===null)return;if(!E.ok)throw new Error(`Exec failed: ${E.statusText}`)}catch{Xe.error(y)}},v=async L=>{o(y=>y.includes(L)?y:[...y,L]),r(L),t.onOpenChange(!0),await g(L,e("sandbox.drawer.failedToRun",{name:L}))},k=async L=>{await m(L),o(y=>y.filter(E=>E!==L)),s===L&&r(Bi)},b=async()=>{const y=i.activeProcesses.includes(s)?e("sandbox.drawer.failedToRestart",{name:s}):e("sandbox.drawer.failedToRun",{name:s});await g(s,y)},w=async()=>{if(!a.has(s)){h(L=>new Set(L).add(s));try{const L=await m(s);if(L===null){h(y=>{const E=new Set(y);return E.delete(s),E});return}if(!L.ok)throw new Error(`Kill failed: ${L.statusText}`)}catch{h(L=>{const y=new Set(L);return y.delete(s),y}),Xe.error(e("sandbox.drawer.failedToStop",{name:s}))}}},C=s!==Bi&&n.includes(s),S=C&&i.activeProcesses.includes(s),R=C&&a.has(s),N=X.useRef(null),I=L=>{if(!t.open)return;const y=N.current,E=y?.parentElement;if(!y||!E)return;L.preventDefault();const x=L.currentTarget,{pointerId:A}=L;x.setPointerCapture(A);const D=L.clientY,P=y.getBoundingClientRect().height,B=E.getBoundingClientRect().height;let M=P;const K=H=>{H.pointerId===A&&(M=Dm(P+(D-H.clientY),B),y.style.height=`${M}px`)},F=H=>{H.pointerId===A&&(x.removeEventListener("pointermove",K),x.removeEventListener("pointerup",F),x.removeEventListener("pointercancel",F),document.body.style.userSelect="",document.body.style.cursor="",t.onHeightChange(M))};document.body.style.userSelect="none",document.body.style.cursor="row-resize",x.addEventListener("pointermove",K),x.addEventListener("pointerup",F),x.addEventListener("pointercancel",F)};return c.jsxs("div",{ref:N,className:"flex shrink-0 flex-col",style:{height:t.open?t.height??"50%":"auto",maxHeight:t.open?`max(${Dn}px, calc(100% - ${Ah}px))`:void 0},children:[t.open&&c.jsx(Mm,{onPointerDown:I,label:e("sandbox.preview.resizeTerminal")}),c.jsx(df,{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:s,scriptTabs:n,onSelectTab:d,onAddScript:v,onCloseScript:k,showScriptControls:C,scriptIsRunning:S,scriptIsKilling:R,onRunActiveScript:b,onStopActiveScript:w}),t.open&&c.jsx("div",{className:"flex-1 overflow-hidden",children:c.jsx(Tm,{vmId:t.vmId,active:s,hasData:i.hasData(s),onRunActive:b})})]})}function Tm(t){const e=U.c(16),{vmId:i,active:s,hasData:r,onRunActive:n}=t,o=Be();if(!i)return null;if(s===Bi||r){let _;return e[0]!==s?(_=c.jsx(Bm,{source:s,className:"h-full"},s),e[0]=s,e[1]=_):_=e[1],_}let a;e[2]!==s||e[3]!==o?(a=o("sandbox.drawer.scriptNotRunning",{name:s}),e[2]=s,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(Ks,{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 f;return e[13]!==h||e[14]!==d?(f=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]=f):f=e[15],f}function Mm(t){const e=U.c(4),{onPointerDown:i,label:s}=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]!==s||e[2]!==i?(n=c.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":s,onPointerDown:i,className:"group relative -mb-px h-1.5 shrink-0 cursor-row-resize",children:r}),e[1]=s,e[2]=i,e[3]=n):n=e[3],n}function Lm(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 Th=t=>`preview-drawer:${t}`,Nm=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function Om(t){try{return Lm(localStorage.getItem(Th(t)))}catch{return{open:!1,height:null}}}function ka(t,e){try{localStorage.setItem(Th(t),JSON.stringify(e))}catch{}}function Im(){const t=U.c(27),{org:e}=rr(),i=Wi()?.virtualMcpId??null,s=vl(),r=dr(),n=X.useRef(null);let o;t[0]!==r||t[1]!==s||t[2]!==i?(o=C=>{C!=="setup"||!i||n.current!==i&&Nm.test(r.getBuffer("setup"))&&(n.current=i,s.restart())},t[0]=r,t[1]=s,t[2]=i,t[3]=o):o=t[3],nl(o);const a=i??"__no-vmcp__",[h,l]=X.useState(null),[u,d]=X.useState(null),f=X.useRef(null);if(f.current!==a){f.current=a;const C=Om(a);l(C.open),d(C.height)}const _=h??!1;let p;t[4]!==u||t[5]!==a?(p=C=>{l(C),ka(a,{open:C,height:u})},t[4]=u,t[5]=a,t[6]=p):p=t[6];const m=p;let g;t[7]!==_||t[8]!==a?(g=C=>{d(C),ka(a,{open:_,height:C})},t[7]=_,t[8]=a,t[9]=g):g=t[9];const v=g,k=s.vmEntry?.sandboxHandle??"no-vm",b=s.vmEntry?.sandboxHandle??null;let w;return t[10]!==u||t[11]!==r.scripts||t[12]!==v||t[13]!==m||t[14]!==s.branch||t[15]!==s.restart||t[16]!==s.resume||t[17]!==s.retry||t[18]!==s.start||t[19]!==s.status||t[20]!==s.stop||t[21]!==_||t[22]!==e.slug||t[23]!==k||t[24]!==b||t[25]!==i?(w=c.jsx(Am,{vmId:b,orgSlug:e.slug,virtualMcpId:i,branch:s.branch,status:s.status,scripts:r.scripts,open:_,onOpenChange:m,height:u,onHeightChange:v,onStart:s.start,onStop:s.stop,onRestart:s.restart,onResume:s.resume,onRetry:s.retry},k),t[10]=u,t[11]=r.scripts,t[12]=v,t[13]=m,t[14]=s.branch,t[15]=s.restart,t[16]=s.resume,t[17]=s.retry,t[18]=s.start,t[19]=s.status,t[20]=s.stop,t[21]=_,t[22]=e.slug,t[23]=k,t[24]=b,t[25]=i,t[26]=w):w=t[26],w}function jm(){const t=U.c(10),e=Wi(),i=hr(e?.virtualMcpId),s=e?.currentBranch??null,r=cr(i?.id).runtime,{url:n}=In(i?.id);if(!i)return null;let o;t[0]!==s||t[1]!==i?(o=c.jsx("div",{className:"flex min-w-0 shrink items-center justify-end",children:c.jsx(wd,{virtualMcp:i,currentBranch:s})}),t[0]=s,t[1]=i,t[2]=o):o=t[2];let a;t[3]!==i||t[4]!==n||t[5]!==r?(a=!n&&Zc(i)&&c.jsxs(c.Fragment,{children:[c.jsx(Qh,{orientation:"vertical",className:"mx-1 data-[orientation=vertical]:h-4"}),c.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:r==="cms"?c.jsx(qu,{virtualMcpId:i.id}):c.jsx(of,{virtualMcpId:i.id})})]}),t[3]=i,t[4]=n,t[5]=r,t[6]=a):a=t[6];let h;return t[7]!==o||t[8]!==a?(h=c.jsxs(c.Fragment,{children:[o,a]}),t[7]=o,t[8]=a,t[9]=h):h=t[9],h}function Hm(){const t=U.c(8),e=Wi(),i=hr(e?.virtualMcpId),s=e?.activeTask,r=Qc(),n=cr(i?.id).runtime,{url:o}=In(i?.id);let a;t[0]!==r||t[1]!==s?.metadata||t[2]!==i?.metadata||t[3]!==o||t[4]!==n?(a=!o&&cf({hasClonableSource:ho(i?.metadata)||ho(s?.metadata),fastPreviewActive:n==="cms",mainTab:r??null}),t[0]=r,t[1]=s?.metadata,t[2]=i?.metadata,t[3]=o,t[4]=n,t[5]=a):a=t[5];const h=a;let l;return t[6]!==h?(l=h?c.jsx(Im,{}):null,t[6]=h,t[7]=l):l=t[7],l}function N1(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(ed.Content,{actions:c.jsx(jm,{}),drawer:c.jsx(Hm,{}),children:c.jsx(Zh,{})}),t[0]=e):e=t[0],e}export{N1 as default};