@p4code/cli 0.9.14 → 0.9.15

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 (378) hide show
  1. package/dist/{AcpMcpStdioBridge-z_p02VlR.mjs → AcpMcpStdioBridge-BPNHFfTr.mjs} +11 -4
  2. package/dist/AcpMcpStdioBridge-CtXfvrFO.mjs +3 -0
  3. package/dist/{Effect-Bwkv2ifD.mjs → Effect-COOccdaU.mjs} +2 -2
  4. package/dist/{Schema-CFgoTmE6.mjs → Schema-BXiVImR2.mjs} +2 -2
  5. package/dist/{Stream-B4Gds95A.mjs → Stream-D2XZdzH6.mjs} +45 -3
  6. package/dist/bin.mjs +15 -2
  7. package/dist/{binCli-BGRfVnO9.mjs → binCli-06acKUH_.mjs} +4146 -2094
  8. package/dist/claude-history-worker.mjs +1 -1
  9. package/dist/{claudeHistoryWorker-DVpahhef.mjs → claudeHistoryWorker-BJKXFgWC.mjs} +4 -4
  10. package/dist/client/.vite/manifest.json +2064 -2089
  11. package/dist/client/assets/{2NI2N5EU-Bk2qNhha.js → 2NI2N5EU-CzVcbH89.js} +2 -2
  12. package/dist/client/assets/{4UO7MD6I-CPV9277r.js → 4UO7MD6I-DS3UFSUE.js} +2 -2
  13. package/dist/client/assets/{5B3SVYGG-LgRjxbnj.js → 5B3SVYGG-lbor_c4_.js} +2 -2
  14. package/dist/client/assets/{5GK6JWQ2-9ndiKpIs.js → 5GK6JWQ2-DufacBFC.js} +2 -2
  15. package/dist/client/assets/{5N7A7DKN-DnUhiayz.js → 5N7A7DKN-B3iWX-TC.js} +2 -2
  16. package/dist/client/assets/{5OC2THR4-DxmpZihk.js → 5OC2THR4-DoDDWXtD.js} +2 -2
  17. package/dist/client/assets/{5S6HY5KT-C4cUz8RB.js → 5S6HY5KT-7n94quvm.js} +2 -2
  18. package/dist/client/assets/{6IMQ5BUJ-2G8Rrp9t.js → 6IMQ5BUJ-CqcR9lZq.js} +2 -2
  19. package/dist/client/assets/{6OLKWJ4F-CW3F_AM6.js → 6OLKWJ4F-BeCI6be_.js} +2 -2
  20. package/dist/client/assets/{74OO7NKP-z5ujM5KH.js → 74OO7NKP-XWvi4Kgp.js} +2 -2
  21. package/dist/client/assets/{75O6YZUN-CSeaYNtt.js → 75O6YZUN-BbbGiqdI.js} +2 -2
  22. package/dist/client/assets/{77XECAW3-DxL0AHyZ.js → 77XECAW3-BVGMXOi_.js} +2 -2
  23. package/dist/client/assets/{ABYRPUBD-DvBcJj7G.js → ABYRPUBD-D4oehH5y.js} +2 -2
  24. package/dist/client/assets/AlertDialogRoot-BI19p1Pb.js +2 -0
  25. package/dist/client/assets/{AnimatedHeight-DChvigzz.js → AnimatedHeight-DT585xP0.js} +2 -2
  26. package/dist/client/assets/{AuthSurfaceShell-29ykag3m.js → AuthSurfaceShell-C312CXz7.js} +2 -2
  27. package/dist/client/assets/{BB2UYUI2-Cun87LIm.js → BB2UYUI2-BkFcdWkE.js} +2 -2
  28. package/dist/client/assets/{BUM34MOA-D6aIFnwf.js → BUM34MOA-DK6xDbTB.js} +2 -2
  29. package/dist/client/assets/{CEQABKGZ-DYzEk-9p.js → CEQABKGZ-rLn9wSBN.js} +2 -2
  30. package/dist/client/assets/{CXAC5362-CdQgNtpk.js → CXAC5362-C1eQCQMX.js} +2 -2
  31. package/dist/client/assets/ChatGptUsageButton-BldpBXxU.js +2 -0
  32. package/dist/client/assets/ChatMarkdown-BUoR67CT.js +49 -0
  33. package/dist/client/assets/CheckboxIndicator-C4iAbUMh.js +2 -0
  34. package/dist/client/assets/ClippedText-TtLeyAVc.js +2 -0
  35. package/dist/client/assets/CodexSetupSection.logic-BO6ZAijp.js +2 -0
  36. package/dist/client/assets/ComboboxClear-CtNsa8Al.js +2 -0
  37. package/dist/client/assets/ComboboxGroupLabel-vQ7y8c50.js +2 -0
  38. package/dist/client/assets/{CommandBlock-DBGDwDRu.js → CommandBlock-40eSIrOe.js} +2 -2
  39. package/dist/client/assets/CompositeRoot-CL7X20MU.js +2 -0
  40. package/dist/client/assets/ConnectAgentSurface-B_AYPHWs.js +2 -0
  41. package/dist/client/assets/{ConnectionStatusDot-C_9jtSee.js → ConnectionStatusDot-7Tjfknn6.js} +2 -2
  42. package/dist/client/assets/{DRLTVNUE-CftE6Aa3.js → DRLTVNUE-BPoomdQn.js} +2 -2
  43. package/dist/client/assets/{DYY6UVD2-DezK9sBO.js → DYY6UVD2-BVvdA84B.js} +2 -2
  44. package/dist/client/assets/DevicePanel-Cqexcbm2.js +2 -0
  45. package/dist/client/assets/DeviceSetup-Cdyw5Z9a.js +2 -0
  46. package/dist/client/assets/DialogTitle-CFYK6V6-.js +2 -0
  47. package/dist/client/assets/{DiffCommentAnnotation-QtrnUuSs.js → DiffCommentAnnotation-C28NAT6f.js} +3 -3
  48. package/dist/client/assets/{DiffFileTree-B_4bn5J8.js → DiffFileTree-DNP9E3To.js} +2 -2
  49. package/dist/client/assets/DiffPanel-CrswOKS6.js +2 -0
  50. package/dist/client/assets/{DiffWorkerPoolProvider-CtpHksSf.js → DiffWorkerPoolProvider-TgqbZJCv.js} +3 -3
  51. package/dist/client/assets/{EmbeddedDesign-BU5m6_ou.js → EmbeddedDesign-Bdq5oAfI.js} +8 -8
  52. package/dist/client/assets/{EnvironmentMachineIcon-DTUBsEaI.js → EnvironmentMachineIcon-B81Bujkx.js} +2 -2
  53. package/dist/client/assets/{ExpandableText-Wij8nL6W.js → ExpandableText-CViqRFUp.js} +2 -2
  54. package/dist/client/assets/{FNOVOB4O-DHCmE6LN.js → FNOVOB4O-CmMgcKnc.js} +2 -2
  55. package/dist/client/assets/FieldControl-95mCsa0m.js +2 -0
  56. package/dist/client/assets/{FileDiff-CAtJtUC5.js → FileDiff-BnZVGRTP.js} +2 -2
  57. package/dist/client/assets/{FilePreviewPanel-CjKP3Q7G.js → FilePreviewPanel-BUTTBdpa.js} +5 -5
  58. package/dist/client/assets/{FoldedSettingsSection-CAZumPht.js → FoldedSettingsSection-CioXtXIT.js} +2 -2
  59. package/dist/client/assets/FormContext-BcA1kdFD.js +2 -0
  60. package/dist/client/assets/{HDGCDEEZ-DNHIctoG.js → HDGCDEEZ-BsN0BbNt.js} +2 -2
  61. package/dist/client/assets/{HSJLKHB7-BfNhUjhw.js → HSJLKHB7-Bn8VFRt5.js} +2 -2
  62. package/dist/client/assets/{Icons-DYaY7Otq.js → Icons-D_LFMxsj.js} +2 -2
  63. package/dist/client/assets/Input-C9KIhPlP.js +2 -0
  64. package/dist/client/assets/JZOYTAAL-B8H2VC7A.js +1 -0
  65. package/dist/client/assets/{K3MD6TGW-D-q4Z_68.js → K3MD6TGW-BEaTend7.js} +2 -2
  66. package/dist/client/assets/{K7RP3OMA-C5AEGeo9.js → K7RP3OMA-Ca837W6z.js} +2 -2
  67. package/dist/client/assets/KeybindingsSettings.logic-DwMUZYvv.js +2 -0
  68. package/dist/client/assets/{LHDIQX7Q-CY4nmSyZ.js → LHDIQX7Q-kLYZmy22.js} +2 -2
  69. package/dist/client/assets/{LUXOKEGN-BHmzrQMD.js → LUXOKEGN-C6-9ARpy.js} +2 -2
  70. package/dist/client/assets/LinkMachineSelect-BVNnYUBb.js +2 -0
  71. package/dist/client/assets/{MathTypeset-C1sAcsZE.js → MathTypeset-CO0wlzDm.js} +2 -2
  72. package/dist/client/assets/{N3JZAHOW-D1VvHXNc.js → N3JZAHOW-BFAKVTw8.js} +2 -2
  73. package/dist/client/assets/{NUIALGQ3-DKQw5Xvm.js → NUIALGQ3-DJg3tvBl.js} +2 -2
  74. package/dist/client/assets/{NoProjectsHero-DVJOMY01.js → NoProjectsHero-ClDVFY0-.js} +2 -2
  75. package/dist/client/assets/{O65XPQGZ-B7xlpxd0.js → O65XPQGZ-C5dkxqix.js} +2 -2
  76. package/dist/client/assets/{O7XIQ6OM-D_yohKEz.js → O7XIQ6OM-BUT403yQ.js} +2 -2
  77. package/dist/client/assets/{OFQON5FD-Eb1UafMJ.js → OFQON5FD-BPK3FXUG.js} +2 -2
  78. package/dist/client/assets/P4ConnectAccountPages-ChT866qO.js +2 -0
  79. package/dist/client/assets/{P4ConnectSidebarSignIn-BarFXVdD.js → P4ConnectSidebarSignIn-D7BBbl_u.js} +2 -2
  80. package/dist/client/assets/{PJQHF43J-xu8MNrTl.js → PJQHF43J-DrfICuu-.js} +2 -2
  81. package/dist/client/assets/PanelLayoutControls-DMUv135M.js +216 -0
  82. package/dist/client/assets/PierreEntryIcon-DLXDEcqA.js +2 -0
  83. package/dist/client/assets/PopoverHandle-D8JhsX32.js +2 -0
  84. package/dist/client/assets/PreviewPanel-D7YWnWZS.js +2 -0
  85. package/dist/client/assets/ProjectDefaultsSettings-BZSw74tU.js +2 -0
  86. package/dist/client/assets/ProjectFavicon-BbtNdeB8.js +3 -0
  87. package/dist/client/assets/{ProjectIconPickerDialog-Ccwf3eo1.js → ProjectIconPickerDialog-7vur_TCX.js} +2 -2
  88. package/dist/client/assets/{ProjectMonogram-Bui44V7z.js → ProjectMonogram-CjAGnMXr.js} +2 -2
  89. package/dist/client/assets/{ProviderAuthTerminal-DjIpg2-V.js → ProviderAuthTerminal-83vDClUK.js} +2 -2
  90. package/dist/client/assets/ProviderModelPicker-af7MWLPO.js +2 -0
  91. package/dist/client/assets/{ProviderSettingsForm-sjzQFb8p.js → ProviderSettingsForm-B4N4tsxv.js} +2 -2
  92. package/dist/client/assets/PullRequestCodeTab-B07M_QW4.js +6 -0
  93. package/dist/client/assets/{RHNBAITX-DWaFNhmX.js → RHNBAITX-CzAdLNMd.js} +2 -2
  94. package/dist/client/assets/{ReadOnlySourcePreview-DDDARz8g.js → ReadOnlySourcePreview-CRy5hHfx.js} +2 -2
  95. package/dist/client/assets/{RedactedSensitiveText-BFwVjGRJ.js → RedactedSensitiveText-B-u4PB3I.js} +2 -2
  96. package/dist/client/assets/RenderErrorBoundary-BbxLD-66.js +23 -0
  97. package/dist/client/assets/{RightPanelResizeHandle-DstJn39I.js → RightPanelResizeHandle-BODMyZa6.js} +2 -2
  98. package/dist/client/assets/{SLD4V6NK-kuRIO20K.js → SLD4V6NK-DIFaAadw.js} +2 -2
  99. package/dist/client/assets/ScheduledTasksSettings-BTi69FRq.js +6 -0
  100. package/dist/client/assets/{ScopedSwitch-B7HEwool.js → ScopedSwitch-sSIKDf2q.js} +2 -2
  101. package/dist/client/assets/ScrollAreaCorner-CsKGemsf.js +2 -0
  102. package/dist/client/assets/{SecretInput-CxRazSuj.js → SecretInput-DxjaAnSE.js} +2 -2
  103. package/dist/client/assets/SelectScrollUpArrow-BMZtcPXM.js +2 -0
  104. package/dist/client/assets/{SelfImproveSettingsSection-BxPUr-AT.js → SelfImproveSettingsSection-Dx6spJXh.js} +2 -2
  105. package/dist/client/assets/SettingsPanels-DhuEF0_Y.js +46 -0
  106. package/dist/client/assets/{SettingsPanels.logic-B406HX50.js → SettingsPanels.logic-D5Fnq4gS.js} +2 -2
  107. package/dist/client/assets/{SettingsScopeNotice-Dt7vuLO5.js → SettingsScopeNotice-B1JDmqM6.js} +2 -2
  108. package/dist/client/assets/{SidebarStageBackdrop-BzsUCj2G.js → SidebarStageBackdrop-Bbv3JBlJ.js} +2 -2
  109. package/dist/client/assets/{T3PCR2KE-C14xVwSj.js → T3PCR2KE-CACWvOHn.js} +2 -2
  110. package/dist/client/assets/{TKWO2OVW-CC_4uZad.js → TKWO2OVW-DpiGaVko.js} +2 -2
  111. package/dist/client/assets/{TSHNXIZL-Kizqv5oh.js → TSHNXIZL-Cs6g4gXN.js} +2 -2
  112. package/dist/client/assets/ThemeEditorPanel-w-RJEK3t.js +5 -0
  113. package/dist/client/assets/{ThreadDetailsItemsMenu-CSCIFtTP.js → ThreadDetailsItemsMenu-DEwUOoLt.js} +60 -60
  114. package/dist/client/assets/ThreadTerminalDrawer-CY2qHldP.js +5 -0
  115. package/dist/client/assets/TooltipProvider-Czzm7ro-.js +2 -0
  116. package/dist/client/assets/{UQJE5E4I-KUX5qtvS.js → UQJE5E4I-C2gKDRv_.js} +2 -2
  117. package/dist/client/assets/{USNYFO5S-XMF6TRXj.js → USNYFO5S-CQ8LfY6F.js} +2 -2
  118. package/dist/client/assets/{Virtualizer-CqFZ9IgG.js → Virtualizer-DsEq6qUF.js} +2 -2
  119. package/dist/client/assets/{WEVWDWVA-BNUvxLQd.js → WEVWDWVA-DK2GTAKk.js} +2 -2
  120. package/dist/client/assets/{WorkspaceBreadcrumb-DyZsM9TF.js → WorkspaceBreadcrumb-BImJJpuo.js} +2 -2
  121. package/dist/client/assets/{WorkspacePageContainer-DFXSkFyh.js → WorkspacePageContainer-BlYFBUKE.js} +2 -2
  122. package/dist/client/assets/{WorkspacePageHeader-FTc6UfB-.js → WorkspacePageHeader-B7O16593.js} +2 -2
  123. package/dist/client/assets/{X5RFHQXM-BtifjFQb.js → X5RFHQXM-sPxDCIwv.js} +2 -2
  124. package/dist/client/assets/{X62E3GBT-DT_qCIPw.js → X62E3GBT-DVWr270S.js} +2 -2
  125. package/dist/client/assets/{XBNEOJTC-7FdMX9IP.js → XBNEOJTC-C4ZNtSrU.js} +2 -2
  126. package/dist/client/assets/{YHV2MVVZ-D6KCo9Qp.js → YHV2MVVZ-aSYUfq9n.js} +2 -2
  127. package/dist/client/assets/{YURCZMG2-D0_CST6F.js → YURCZMG2-fnxZxUja.js} +2 -2
  128. package/dist/client/assets/{YVG2LODB-CRU4fKD2.js → YVG2LODB-DxaZKaXT.js} +2 -2
  129. package/dist/client/assets/_chat-BeJoXsdK.js +47 -0
  130. package/dist/client/assets/_chat.design-AJz30uXq.js +2 -0
  131. package/dist/client/assets/_chat.index-D1csjyRQ.js +2 -0
  132. package/dist/client/assets/_chat.new-IhhWgwNo.js +4 -0
  133. package/dist/client/assets/_chat.pull-requests-B84LUHIv.js +2 -0
  134. package/dist/client/assets/{alert-D0u2-4Zh.js → alert-D6MFRWZv.js} +2 -2
  135. package/dist/client/assets/{alert-dialog-DK40IDMO.js → alert-dialog-BCq0Qme9.js} +2 -2
  136. package/dist/client/assets/assetUrls-CpRsTTqn.js +2 -0
  137. package/dist/client/assets/assets-Dh1LFwqL.js +2 -0
  138. package/dist/client/assets/browserHistoryStore-BVEWgOnh.js +2 -0
  139. package/dist/client/assets/{browserLinkTarget-BOF3rlV5.js → browserLinkTarget-IOprEiHF.js} +2 -2
  140. package/dist/client/assets/{checkbox-bsJs8Zu-.js → checkbox-CGhJug34.js} +2 -2
  141. package/dist/client/assets/{color-picker-W4KTEgfL.js → color-picker-CRaqqL5F.js} +2 -2
  142. package/dist/client/assets/{combobox-UDn50qHb.js → combobox-5RzytEjd.js} +2 -2
  143. package/dist/client/assets/{command-C7CgDZ25.js → command-06bu9QoQ.js} +2 -2
  144. package/dist/client/assets/{connect-CguaBRtJ.js → connect-7OV1IEwO.js} +2 -2
  145. package/dist/client/assets/connect-agent-B6pgZuy8.js +2 -0
  146. package/dist/client/assets/design-DSoix9e1.js +2 -0
  147. package/dist/client/assets/device-DQmQm4GC.js +2 -0
  148. package/dist/client/assets/{dialog-BEXthTAp.js → dialog-DTVhbEqi.js} +2 -2
  149. package/dist/client/assets/{diffRendering-DosiBwUN.js → diffRendering-DAzPanqh.js} +3 -3
  150. package/dist/client/assets/{dist-p5OtQFc9.js → dist-BuxsAlG0.js} +3 -3
  151. package/dist/client/assets/draft-input-BTetoXSt.js +2 -0
  152. package/dist/client/assets/{duoViewer-BcsodgGy.js → duoViewer-DxmaOmHS.js} +2 -2
  153. package/dist/client/assets/{dynamic-XOmtS0-B.js → dynamic-wBSCLNxy.js} +2 -2
  154. package/dist/client/assets/{embeddedScripts-BQl_ld6u.js → embeddedScripts-ZebptRJ0.js} +2 -2
  155. package/dist/client/assets/{empty-CTv2Unxd.js → empty-B4h5DyMQ.js} +2 -2
  156. package/dist/client/assets/entities-CWtNgawi.js +2 -0
  157. package/dist/client/assets/{fileLinks-T2ko6Qmp.js → fileLinks-BfcK2bJU.js} +2 -2
  158. package/dist/client/assets/{fileTreeExpansion-BOutPxUH.js → fileTreeExpansion-DjiK1m5s.js} +2 -2
  159. package/dist/client/assets/{getDiffFileInput-Do7OSxYn.js → getDiffFileInput-XE3jyXxK.js} +2 -2
  160. package/dist/client/assets/{guideRunStore-DGAK_XSV.js → guideRunStore-CzF0q6A8.js} +2 -2
  161. package/dist/client/assets/{htmlRender-DAhG7IlW.js → htmlRender-DGe3WaPg.js} +2 -2
  162. package/dist/client/assets/{index-4XHdM2Yx.js → index-CurDuwfz.js} +3 -3
  163. package/dist/client/assets/{input-BGKmQVHf.js → input-CQaedaQh.js} +2 -2
  164. package/dist/client/assets/{input-group-BdgWY0OZ.js → input-group-BQ_2ox-w.js} +2 -2
  165. package/dist/client/assets/{kbd-BIypvknl.js → kbd-DQRicdHu.js} +2 -2
  166. package/dist/client/assets/{keybindings-C0ntbKmL.js → keybindings-tgj8XFFz.js} +2 -2
  167. package/dist/client/assets/{lazy-DudfZwDr.js → lazy-DmPH_lNd.js} +4 -4
  168. package/dist/client/assets/{lazyRouteComponent-VtherrNw.js → lazyRouteComponent-CE6uW_5p.js} +2 -2
  169. package/dist/client/assets/{link--eZ8ZXuK.js → link-CKfckeju.js} +2 -2
  170. package/dist/client/assets/{linkedPrompt-DRNVlalr.js → linkedPrompt-68_t5vwh.js} +2 -2
  171. package/dist/client/assets/main-B1sXOjZZ.js +37 -0
  172. package/dist/client/assets/main-CbkvDRKP.css +2 -0
  173. package/dist/client/assets/{mediaReference-CMwg4kE3.js → mediaReference-DQ6GIZY7.js} +2 -2
  174. package/dist/client/assets/mediaSource-DfTsMdqm.js +2 -0
  175. package/dist/client/assets/number-field-xEi5ylvp.js +2 -0
  176. package/dist/client/assets/{observeResize-CV41SgJr.js → observeResize-BbXolq6K.js} +2 -2
  177. package/dist/client/assets/onboarding-CkdZxdNL.js +2 -0
  178. package/dist/client/assets/openFileInPreview-BHhDd-id.js +2 -0
  179. package/dist/client/assets/{p4ProjectFile-DqqWNGdD.js → p4ProjectFile-5VDI-yAx.js} +2 -2
  180. package/dist/client/assets/{pair-Wl7C9P9c.js → pair-BpCo33SH.js} +2 -2
  181. package/dist/client/assets/{pendingSendStore-CFKdq-QP.js → pendingSendStore-Ba--K6cH.js} +2 -2
  182. package/dist/client/assets/{phoneViewer-C1sFfV5x.js → phoneViewer-C1aGY-h1.js} +2 -2
  183. package/dist/client/assets/{pierre-icons-2mAt8csu.js → pierre-icons-BdcegjLq.js} +3 -3
  184. package/dist/client/assets/popover-BB2K1---.js +2 -0
  185. package/dist/client/assets/preview-B4_sjsUX.js +2 -0
  186. package/dist/client/assets/preview-DgXn94k5.js +2 -0
  187. package/dist/client/assets/{previewMiniPlayerStore-DwJUVJAq.js → previewMiniPlayerStore-DguWdL1f.js} +2 -2
  188. package/dist/client/assets/primary-BDoRkJqU.js +2 -0
  189. package/dist/client/assets/primaryCloudLinkState-Cc0Xobh6.js +2 -0
  190. package/dist/client/assets/projectFilesQueryState-BdfD5cZ2.js +2 -0
  191. package/dist/client/assets/projectScriptEditor-faOsFlds.js +2 -0
  192. package/dist/client/assets/{providerSkills-B9Q5OmXk.js → providerSkills-C8PrnHb-.js} +2 -2
  193. package/dist/client/assets/{pullRequestDetail.logic-CVJbFct1.js → pullRequestDetail.logic-kOhR5jr9.js} +4 -4
  194. package/dist/client/assets/{pullRequestIcons-ZE5MB0dW.js → pullRequestIcons-CbDg0o8q.js} +2 -2
  195. package/dist/client/assets/{pullRequestReviewStore-CF0UmQoG.js → pullRequestReviewStore-0WIH92NQ.js} +2 -2
  196. package/dist/client/assets/pullRequests-Cf9E2kW-.js +2 -0
  197. package/dist/client/assets/queries-Cl508kPw.js +2 -0
  198. package/dist/client/assets/query-D3KVoW9G.js +2 -0
  199. package/dist/client/assets/radio-group-BnZVD-CO.js +2 -0
  200. package/dist/client/assets/relay-Do9UB5iT.js +2 -0
  201. package/dist/client/assets/{renderScheduler-BLYWx2Dl.js → renderScheduler-DsjkE3rh.js} +2 -2
  202. package/dist/client/assets/{rightPanelStore-BzpX6F8n.js → rightPanelStore-DB1OP4MT.js} +2 -2
  203. package/dist/client/assets/runtime-BBYIQ0f-.js +7 -0
  204. package/dist/client/assets/runtimeModeConfig-CRXk0H6e.js +2 -0
  205. package/dist/client/assets/scheduledTasksSettings.logic-Dw_swg_M.js +3 -0
  206. package/dist/client/assets/{scroll-area-BN4-XX3T.js → scroll-area-Cm9XZdHp.js} +2 -2
  207. package/dist/client/assets/{select-CHOl11x1.js → select-Cz_1ByI4.js} +2 -2
  208. package/dist/client/assets/{selfImproveFindings-BTdfhZ3z.js → selfImproveFindings-DtoTFNL_.js} +2 -2
  209. package/dist/client/assets/semver-BoU8Be_3.js +2 -0
  210. package/dist/client/assets/server-Dkj4NeYG.js +2 -0
  211. package/dist/client/assets/session-CBEVNHld.js +2 -0
  212. package/dist/client/assets/{session-logic-BwAELIPU.js → session-logic-DB_ei-pn.js} +5 -5
  213. package/dist/client/assets/{settings-fuKhbSed.js → settings-Yvo1RMvg.js} +2 -2
  214. package/dist/client/assets/{settings.appearance-K-0McYk9.js → settings.appearance-ONDNW-gc.js} +2 -2
  215. package/dist/client/assets/settings.archived-CjdyCMyi.js +2 -0
  216. package/dist/client/assets/{settings.computer-use-C8dDJqmo.js → settings.computer-use-97ffp9C_.js} +2 -2
  217. package/dist/client/assets/settings.connections-w3qKRKGa.js +2 -0
  218. package/dist/client/assets/settings.data-controls-C8ozSexu.js +2 -0
  219. package/dist/client/assets/{settings.decisions-C1RgAwXn.js → settings.decisions-BvR3_OTv.js} +2 -2
  220. package/dist/client/assets/{settings.designs-BgEqEGXM.js → settings.designs-CB8PWHwW.js} +2 -2
  221. package/dist/client/assets/settings.diagnostics-DdInPrq0.js +2 -0
  222. package/dist/client/assets/{settings.general-BeLPMggF.js → settings.general-Cf_bIbyH.js} +2 -2
  223. package/dist/client/assets/settings.integrations-pj9KVvtd.js +2 -0
  224. package/dist/client/assets/settings.keybindings-3diGciV1.js +2 -0
  225. package/dist/client/assets/{settings.open-source-licenses-DWVgu9MJ.js → settings.open-source-licenses-DlqO6HBa.js} +2 -2
  226. package/dist/client/assets/{settings.plugins-DsfEfMST.js → settings.plugins-DpaJJH_J.js} +4 -4
  227. package/dist/client/assets/settings.projects-Bfh3CJ1a.js +4 -0
  228. package/dist/client/assets/settings.providers-DNiEeQYT.js +3 -0
  229. package/dist/client/assets/{settings.scheduled-tasks-BJMUub-y.js → settings.scheduled-tasks-BIaHEXVF.js} +2 -2
  230. package/dist/client/assets/settings.secrets-BSNXem5A.js +2 -0
  231. package/dist/client/assets/{settings.snap-shot-6aF3J4Zd.js → settings.snap-shot-Ds0ywKhE.js} +2 -2
  232. package/dist/client/assets/settings.source-control-C41AVNSm.js +2 -0
  233. package/dist/client/assets/settings.storage-B-Hm5vEC.js +2 -0
  234. package/dist/client/assets/settingsLayout-BbEwQ6Fy.js +3 -0
  235. package/dist/client/assets/{sidebar-Dt9UYgk1.js → sidebar-B70J7v16.js} +2 -2
  236. package/dist/client/assets/{sidebarProjectGrouping-lpBYOlht.js → sidebarProjectGrouping-Cy06FqQF.js} +2 -2
  237. package/dist/client/assets/{skeleton-BiqtjWsk.js → skeleton-BavPX8IL.js} +2 -2
  238. package/dist/client/assets/sourceControl-De64nxc-.js +2 -0
  239. package/dist/client/assets/{sourceControlClients-Bcd4sqEi.js → sourceControlClients-BofXnV5S.js} +2 -2
  240. package/dist/client/assets/{spinner-C64jtA3m.js → spinner-BiCpg0TU.js} +2 -2
  241. package/dist/client/assets/terminal-links-DkNuyYrs.js +2 -0
  242. package/dist/client/assets/terminalSessions-BLnAzTpE.js +2 -0
  243. package/dist/client/assets/{textarea-DtceyvOF.js → textarea-DPWqoJRQ.js} +2 -2
  244. package/dist/client/assets/themePalette-1UQmJk98.js +5 -0
  245. package/dist/client/assets/{threadCheckpoints-BXz5LJLz.js → threadCheckpoints-C5aLz9nv.js} +2 -2
  246. package/dist/client/assets/{toggle-Be7gb_vD.js → toggle-DERKSGyC.js} +2 -2
  247. package/dist/client/assets/{toggle-group-Cz65VaLC.js → toggle-group-DYSJFIn3.js} +2 -2
  248. package/dist/client/assets/tooltip-C7NAkYG3.js +2 -0
  249. package/dist/client/assets/{uiStateStore-yyuUmO2M.js → uiStateStore-FYiLqqos.js} +2 -2
  250. package/dist/client/assets/usage-CtcqAwlu.js +2 -0
  251. package/dist/client/assets/{usageAccess-0MZ9DMCW.js → usageAccess-2Wks5kIN.js} +2 -2
  252. package/dist/client/assets/{usageFormat-4k8-70X2.js → usageFormat-BZJ9qCn4.js} +2 -2
  253. package/dist/client/assets/{usageShortcuts-C4Dhwzkz.js → usageShortcuts-BJyp1xT6.js} +2 -2
  254. package/dist/client/assets/use-atom-command-BbFDhw_c.js +2 -0
  255. package/dist/client/assets/useAriaLabelledBy-BJnK5b5h.js +2 -0
  256. package/dist/client/assets/useHandleNewThread-C6MtV3AM.js +2 -0
  257. package/dist/client/assets/{useLocation-_8If3LN3.js → useLocation-NTw9A5XQ.js} +2 -2
  258. package/dist/client/assets/{useNavigate-5WivMyAa.js → useNavigate-DV9bXnWr.js} +2 -2
  259. package/dist/client/assets/{useNavigateBack-DXfbYF86.js → useNavigateBack-D62rsj_4.js} +2 -2
  260. package/dist/client/assets/{useP4ConnectAuthPrompt-D0Equ6mY.js → useP4ConnectAuthPrompt-Bj5GIxgy.js} +2 -2
  261. package/dist/client/assets/{useParams-DV-Nw6Lj.js → useParams-jklHVL7l.js} +2 -2
  262. package/dist/client/assets/{usePermissionStatus-CIobAIHF.js → usePermissionStatus-DaCu90iN.js} +2 -2
  263. package/dist/client/assets/usePopupViewport-D1lXH2SQ.js +2 -0
  264. package/dist/client/assets/usePreviousValue-Dx4Nv0v8.js +2 -0
  265. package/dist/client/assets/usePullRequestActions-WFmep5Tm.js +3 -0
  266. package/dist/client/assets/useRegisterFieldControl-BtJcyaxh.js +2 -0
  267. package/dist/client/assets/{useScopedModelAvailability-Cc-bmdqn.js → useScopedModelAvailability-hsJL85Tg.js} +2 -2
  268. package/dist/client/assets/useSettings-EYJbJzT3.js +3 -0
  269. package/dist/client/assets/utils-DjbLtxuo.js +37 -0
  270. package/dist/client/assets/vcsRefInvalidation-DkXoQApH.js +2 -0
  271. package/dist/client/assets/welcome-uKSqaFeK.js +2 -0
  272. package/dist/client/index.html +1 -1
  273. package/dist/{renderer-D_KFqL06.mjs → renderer-D9dDeERN.mjs} +68 -13
  274. package/dist/{runtime-Tslhhp69.mjs → runtime-C3UJDGLb.mjs} +81 -11
  275. package/package.json +1 -1
  276. package/dist/AcpMcpStdioBridge-BinVfs5k.mjs +0 -3
  277. package/dist/client/assets/AlertDialogRoot-z7O2CaB2.js +0 -2
  278. package/dist/client/assets/ChatGptUsageButton-DQjnXjt6.js +0 -2
  279. package/dist/client/assets/ChatMarkdown-C7ocX514.js +0 -48
  280. package/dist/client/assets/CheckboxIndicator-D2jNOqVc.js +0 -2
  281. package/dist/client/assets/ClippedText-CDOkzr7r.js +0 -2
  282. package/dist/client/assets/CodexSetupSection.logic-BIpypa3y.js +0 -2
  283. package/dist/client/assets/ComboboxClear-CPvB2whi.js +0 -2
  284. package/dist/client/assets/ComboboxGroupLabel-DN75A_2f.js +0 -2
  285. package/dist/client/assets/CompositeRoot-Jf3zEGLN.js +0 -2
  286. package/dist/client/assets/ConnectAgentSurface-Cv2oB5Cw.js +0 -2
  287. package/dist/client/assets/DevicePanel-CKWUjHEE.js +0 -2
  288. package/dist/client/assets/DeviceSetup-BrOsu1Y4.js +0 -2
  289. package/dist/client/assets/DialogTitle-COHuuWBE.js +0 -2
  290. package/dist/client/assets/DiffPanel-CGIIHSDI.js +0 -2
  291. package/dist/client/assets/FieldControl-Yp1Yjlg7.js +0 -2
  292. package/dist/client/assets/FormContext-BEFZtJu9.js +0 -2
  293. package/dist/client/assets/Input-CVeLgfX4.js +0 -2
  294. package/dist/client/assets/JZOYTAAL-Bngs0npp.js +0 -1
  295. package/dist/client/assets/KeybindingsSettings.logic-A_266dBm.js +0 -2
  296. package/dist/client/assets/LinkMachineSelect-tm04n5mK.js +0 -2
  297. package/dist/client/assets/P4ConnectAccountPages-BkOCG7hq.js +0 -2
  298. package/dist/client/assets/PanelLayoutControls-amKHUz1V.js +0 -216
  299. package/dist/client/assets/PierreEntryIcon-CbhCWTjd.js +0 -2
  300. package/dist/client/assets/PopoverHandle-DbGxLy3d.js +0 -2
  301. package/dist/client/assets/PreviewPanel-B1KmgL5R.js +0 -2
  302. package/dist/client/assets/ProjectDefaultsSettings-D_2ixmme.js +0 -2
  303. package/dist/client/assets/ProjectFavicon-BXd2O1Gh.js +0 -3
  304. package/dist/client/assets/ProviderModelPicker-DJl5IM1n.js +0 -2
  305. package/dist/client/assets/PullRequestCodeTab-BcFFbURH.js +0 -6
  306. package/dist/client/assets/RenderErrorBoundary-DianZAsM.js +0 -23
  307. package/dist/client/assets/ScheduledTasksSettings-BHT9WAFD.js +0 -6
  308. package/dist/client/assets/ScrollAreaCorner-DW6lxPPn.js +0 -2
  309. package/dist/client/assets/SelectScrollUpArrow-DZfqWvZD.js +0 -2
  310. package/dist/client/assets/SettingsPanels-CrMsCqvq.js +0 -46
  311. package/dist/client/assets/ThemeEditorPanel-BuMI6s2A.js +0 -5
  312. package/dist/client/assets/ThreadTerminalDrawer-FZ0zyNm1.js +0 -5
  313. package/dist/client/assets/TooltipViewport-DjveMpIl.js +0 -2
  314. package/dist/client/assets/_chat-P2jEGe91.js +0 -47
  315. package/dist/client/assets/_chat.design-k56_YrCY.js +0 -2
  316. package/dist/client/assets/_chat.index-CUR_1FMo.js +0 -2
  317. package/dist/client/assets/_chat.new-7EgBpaGD.js +0 -4
  318. package/dist/client/assets/_chat.pull-requests-C97pdH91.js +0 -2
  319. package/dist/client/assets/assetUrls-ChygJppW.js +0 -2
  320. package/dist/client/assets/assets-Cv1qxio9.js +0 -2
  321. package/dist/client/assets/browserHistoryStore-PB9BBl0N.js +0 -2
  322. package/dist/client/assets/connect-agent-BitywHYq.js +0 -2
  323. package/dist/client/assets/design-NrL4Xyzh.js +0 -2
  324. package/dist/client/assets/device-DsIsK_g9.js +0 -2
  325. package/dist/client/assets/draft-input-Cp7zSsLs.js +0 -2
  326. package/dist/client/assets/entities-Ci9sZwRJ.js +0 -2
  327. package/dist/client/assets/main-CKOKCTSr.css +0 -2
  328. package/dist/client/assets/main-CRJyb41E.js +0 -37
  329. package/dist/client/assets/mediaSource-BQpgJ9hG.js +0 -2
  330. package/dist/client/assets/number-field-pjPmm2hH.js +0 -2
  331. package/dist/client/assets/onboarding-C7BynXti.js +0 -2
  332. package/dist/client/assets/openFileInPreview-Cs7GoIEO.js +0 -2
  333. package/dist/client/assets/popover-oNrAhEOs.js +0 -2
  334. package/dist/client/assets/preview-CAzlFJXG.js +0 -2
  335. package/dist/client/assets/preview-D8H2Itzr.js +0 -2
  336. package/dist/client/assets/primary-BdVzsWIK.js +0 -2
  337. package/dist/client/assets/primaryCloudLinkState-eu2avrjG.js +0 -2
  338. package/dist/client/assets/projectFilesQueryState-f8odJKc-.js +0 -2
  339. package/dist/client/assets/projectScriptEditor-D8Os7g21.js +0 -2
  340. package/dist/client/assets/pullRequests-p7FMtHTx.js +0 -2
  341. package/dist/client/assets/queries-C1_RUJ-8.js +0 -2
  342. package/dist/client/assets/query-DszcgUku.js +0 -2
  343. package/dist/client/assets/radio-group-Cb2KobOI.js +0 -2
  344. package/dist/client/assets/runtime-CcgzOADx.js +0 -6
  345. package/dist/client/assets/runtime-D2NRh41I.js +0 -3
  346. package/dist/client/assets/runtimeModeConfig-DTaQ5JjA.js +0 -2
  347. package/dist/client/assets/scheduledTasksSettings.logic-FST8Bc6V.js +0 -3
  348. package/dist/client/assets/semver-CFbvOQKc.js +0 -2
  349. package/dist/client/assets/server-C-cSQN_G.js +0 -2
  350. package/dist/client/assets/session-D6BRf77P.js +0 -2
  351. package/dist/client/assets/settings.archived-CalSrYkZ.js +0 -2
  352. package/dist/client/assets/settings.connections-D_XSkcFH.js +0 -2
  353. package/dist/client/assets/settings.data-controls-CTlXbRrO.js +0 -2
  354. package/dist/client/assets/settings.diagnostics-BxqI_9bx.js +0 -2
  355. package/dist/client/assets/settings.integrations-4rKfTDFW.js +0 -2
  356. package/dist/client/assets/settings.keybindings-DSavoJxs.js +0 -2
  357. package/dist/client/assets/settings.projects-CJzRAMVM.js +0 -4
  358. package/dist/client/assets/settings.providers-BoTCdGuy.js +0 -3
  359. package/dist/client/assets/settings.secrets-Ch_XS6ak.js +0 -2
  360. package/dist/client/assets/settings.source-control-B7PW3yi5.js +0 -2
  361. package/dist/client/assets/settings.storage-PmxiGFaE.js +0 -2
  362. package/dist/client/assets/settingsLayout-fG812pJ2.js +0 -3
  363. package/dist/client/assets/sourceControl-BUEFlHbW.js +0 -2
  364. package/dist/client/assets/terminal-links-DxE1mEi0.js +0 -2
  365. package/dist/client/assets/terminalSessions-Ceajv0BZ.js +0 -2
  366. package/dist/client/assets/themePalette-tZPF0oN0.js +0 -5
  367. package/dist/client/assets/toast-BYGaCmZu.js +0 -2
  368. package/dist/client/assets/tooltip-BYZIg_IY.js +0 -2
  369. package/dist/client/assets/usage-B6rUsIoY.js +0 -2
  370. package/dist/client/assets/use-atom-command-DEluSG6k.js +0 -2
  371. package/dist/client/assets/useAriaLabelledBy-Ca8fkLAD.js +0 -2
  372. package/dist/client/assets/useHandleNewThread-BOej8pJq.js +0 -2
  373. package/dist/client/assets/usePullRequestActions-Cf39XlVv.js +0 -3
  374. package/dist/client/assets/useRegisterFieldControl-Dmsxd6H8.js +0 -2
  375. package/dist/client/assets/useSettings-jZr_DfW0.js +0 -3
  376. package/dist/client/assets/utils-OWUgXvpr.js +0 -37
  377. package/dist/client/assets/vcsRefInvalidation-CRToBQE1.js +0 -2
  378. package/dist/client/assets/welcome-BcjbPbMq.js +0 -2
@@ -1,4 +1,4 @@
1
- import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJeoFXNw.js";import{D as i,Fs as a,Gf as o,Is as s,Ns as c,Pf as l,Qn as u,Qo as d,Xn as f,dr as p,er as m,fr as h,fv as g,hn as _,ir as v,j as y,lh as b,md as x,nr as S,or as C,rr as w,sb as T,sv as E,t as D,yT as O,zd as k}from"./utils-OWUgXvpr.js";import{L as ee,R as te,W as ne}from"./runtime-CcgzOADx.js";import{s as re}from"./vcsRefInvalidation-CRToBQE1.js";import{W as ie}from"./entities-Ci9sZwRJ.js";import{An as A,Bn as ae,Nn as oe,d as se,f as ce,u as le}from"./runtime-D2NRh41I.js";import{U as ue,b as j,g as M,h as N,l as de,w as fe}from"./TooltipViewport-DjveMpIl.js";import{J as P,Y as pe,n as me,tt as F}from"./ChatMarkdown-C7ocX514.js";import{t as he}from"./spinner-C64jtA3m.js";import{i as ge,m as _e}from"./toast-BYGaCmZu.js";import{J as ve,K as ye,O as be,S as xe,s as Se}from"./useSettings-jZr_DfW0.js";import{i as Ce,n as we}from"./session-D6BRf77P.js";import{t as Te}from"./use-atom-command-DEluSG6k.js";import{a as Ee}from"./fileLinks-T2ko6Qmp.js";import{d as De}from"./providerSkills-B9Q5OmXk.js";import{t as Oe}from"./toastHelpers-DxXYm50b.js";import{o as ke}from"./queries-C1_RUJ-8.js";import{H as I,V as L,l as Ae,ot as je,st as Me}from"./diffRendering-DosiBwUN.js";import{A as Ne,B as Pe,G as Fe,K as R,T as Ie,a as Le,j as Re,l as z,t as ze}from"./Virtualizer-CqFZ9IgG.js";import{B as Be,G as Ve,H as B,J as He,K as V,Q as Ue,U as H,V as We,W as Ge,q as U}from"./getDiffFileInput-Do7OSxYn.js";import{c as Ke,i as qe,n as Je,o as Ye,s as Xe,t as Ze}from"./DiffWorkerPoolProvider-CtpHksSf.js";import{n as Qe}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{S as $e,_ as et,b as tt,c as nt,d as rt,f as it,g as at,h as W,i as ot,l as st,m as G,o as ct,p as lt,r as ut,s as K,t as dt,u as ft,v as pt,x as mt,y as ht}from"./DiffCommentAnnotation-QtrnUuSs.js";import{t as gt}from"./mediaReference-CMwg4kE3.js";import{a as _t,n as vt,t as yt}from"./tooltip-BYZIg_IY.js";import{i as bt,n as xt,r as q,t as St}from"./fileCommentAnnotations-BgdL_7u9.js";import{r as Ct,t as wt}from"./ReadOnlySourcePreview-DDDARz8g.js";import{a as Tt,c as Et,i as Dt,n as Ot,o as kt,r as At,s as jt,t as Mt}from"./fileTreeExpansion-BOutPxUH.js";import{t as Nt}from"./pierre-icons-2mAt8csu.js";import{t as Pt}from"./scroll-area-BN4-XX3T.js";import{t as Ft}from"./observeResize-CV41SgJr.js";import{n as It,r as Lt,t as Rt}from"./RightPanelResizeHandle-DstJn39I.js";import{A as zt,C as Bt,D as Vt,E as Ht,I as Ut,L as Wt,M as Gt,O as Kt,P as qt,R as Jt,T as Yt,j as Xt,k as Zt}from"./ThreadDetailsItemsMenu-CSCIFtTP.js";import{t as Qt}from"./assets-Cv1qxio9.js";import{i as $t,n as en,t as tn}from"./assetUrls-ChygJppW.js";import{w as nn}from"./browserHistoryStore-PB9BBl0N.js";import{i as rn,r as an}from"./openFileInPreview-Cs7GoIEO.js";import{t as on}from"./preview-CAzlFJXG.js";import{t as sn}from"./PierreEntryIcon-CbhCWTjd.js";import{n as cn}from"./composerTrigger-BGi0iyhl.js";import{r as ln,t as un}from"./input-group-BdgWY0OZ.js";import{f as dn,i as fn,l as pn,n as mn,o as hn,t as gn,u as _n}from"./projectFilesQueryState-f8odJKc-.js";import{Eo as vn,_o as yn,xo as bn}from"./main-CRJyb41E.js";import{E as xn,f as Sn,m as Cn,p as wn}from"./_chat-P2jEGe91.js";var Tn={compositeOverBg:Be,contrastRatio:We,deriveMutedFg:B,hoverWouldEraseText:H,isDarkSurface:Ge,isFullyTransparent:Ve,pickReadableForeground:V,relativeLuminance:U,surfacesMatch:He},J=e(t(),1);function En(e,t){return e.isOpen===t.isOpen&&e.value===t.value&&Tt(e.matchingPaths,t.matchingPaths)}function Dn(e){let t=kt(e,e=>({isOpen:e.isSearchOpen(),matchingPaths:e.getSearchMatchingPaths(),value:e.getSearchValue()}),En);return(0,J.useMemo)(()=>({...t,close:()=>{e.closeSearch()},focusNextMatch:()=>{e.focusNextSearchMatch()},focusPreviousMatch:()=>{e.focusPreviousSearchMatch()},open:t=>{e.openSearch(t)},setValue:t=>{e.setSearch(t)}}),[e,t])}var On=100,kn=`insert`,An=`backspace`,jn=`delete`,Mn=class e{#e=[];#t=[];#n;#r=!1;constructor(e){this.#n=Math.max(1,e?.maxEntries??On)}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}getState(){return{undoStack:this.#e.map(Pn),redoStack:this.#t.map(Pn),maxEntries:this.#n,canCoalesce:this.#r}}getLiveState(){return Object.defineProperties({},{undoStack:{enumerable:!0,get:()=>this.#e},redoStack:{enumerable:!0,get:()=>this.#t},maxEntries:{enumerable:!0,get:()=>this.#n},canCoalesce:{enumerable:!0,get:()=>this.#r}})}static fromState(t){let n=new e({maxEntries:t.maxEntries});return n.#e=t.undoStack,n.#t=t.redoStack,n.#r=t.canCoalesce,n}clear(){this.#e.length=0,this.#t.length=0,this.#r=!1}clearRedo(){this.#t.length=0}push(e){this.#e.push(e),this.clearRedo(),this.#r=!0,this.#e.length>this.#n&&this.#e.shift()}setLastUndoSelectionsAfter(e){let t=this.#e[this.#e.length-1];t!==void 0&&(t.selectionsAfter=e.map(e=>({...e})))}setLastUndoLineAnnotations(e,t){let n=this.#e[this.#e.length-1];n!==void 0&&(n.lineAnnotationsBefore=e.slice(),n.lineAnnotationsAfter=t.slice())}peekUndo(){return this.#e[this.#e.length-1]}peekUndoForCoalescing(){return this.#r?this.peekUndo():void 0}replaceLastUndo(e){this.#e.length===0?this.push(e):(this.#e[this.#e.length-1]=e,this.clearRedo(),this.#r=!0)}popUndoToRedo(){let e=this.#e.pop();if(e!==void 0)return this.#t.push(e),this.#r=!1,e}popRedoToUndo(){let e=this.#t.pop();if(e!==void 0)return this.#e.push(e),this.#r=!1,e}};function Nn(e){return{...e,forwardEdits:e.forwardEdits.map(e=>({...e})),inverseEdits:e.inverseEdits.map(e=>({...e})),selectionsBefore:e.selectionsBefore?.map(Fn),selectionsAfter:e.selectionsAfter?.map(Fn),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:e.lineAnnotationsAfter?.slice()}}function Pn(e){return{...Nn(e),lineAnnotationsBefore:e.lineAnnotationsBefore?.map(e=>({...e})),lineAnnotationsAfter:e.lineAnnotationsAfter?.map(e=>({...e}))}}function Fn(e){return{...e,start:{...e.start},end:{...e.end}}}function In(e,t,n,r,i,a,o,s){let c=[...t].sort((e,t)=>e.start-t.start),l=[],u;if(i?.length===c.length){let t=[];for(let n of i){if(n.start.line!==n.end.line||n.start.character!==n.end.character)break;t.push(e.offsetAt(n.start))}if(t.length===c.length){t.sort((e,t)=>e-t);let e=!0,n=!0;for(let r=0;r<c.length;r++){let i=c[r];if(i.text.length>0||i.start===i.end){e=!1,n=!1;break}e&&=t[r]===i.end,n&&=t[r]===i.start}u=e?An:n?jn:void 0}}for(let t=0,n=0;t<c.length;t++){let r=c[t],i=e.getTextSlice(r.start,r.end),a=r.start+n;l.push({start:a,end:a+r.text.length,text:i}),n+=r.text.length-(r.end-r.start)}return{forwardEdits:c.map(e=>({...e})),inverseEdits:l,versionBefore:n,versionAfter:r,selectionsBefore:i?.map(e=>({...e})),selectionsAfter:a?.map(e=>({...e})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:s?.slice(),coalescingMode:u}}function Ln(e,t){if(e===void 0||e.undoBoundary===!0||t.undoBoundary===!0||e.forwardEdits.length===0||e.forwardEdits.length!==e.inverseEdits.length||e.forwardEdits.length!==t.forwardEdits.length||t.forwardEdits.length!==t.inverseEdits.length)return!1;let n;for(let r=0;r<e.forwardEdits.length;r++){let i=e.forwardEdits[r],a=e.inverseEdits[r],o=t.forwardEdits[r],s=t.inverseEdits[r],c=Bn(o.start,e.forwardEdits),l=i.start<=i.end&&i.text.length>0&&!i.text.includes(`
1
+ import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJeoFXNw.js";import{$n as i,CT as a,D as o,Fs as s,Ls as c,Rf as l,Rs as u,Ud as d,Yf as f,Zn as p,ar as m,db as h,dv as g,es as _,fr as v,gn as y,gv as b,ir as x,j as S,mr as C,ph as w,rr as T,sr as E,t as D,tr as O,vd as k}from"./utils-DjbLtxuo.js";import{$n as ee,Tr as te,br as ne,d as re,f as ie,lr as A,nr as ae,u as oe,yr as se}from"./runtime-BBYIQ0f-.js";import{s as ce}from"./vcsRefInvalidation-DkXoQApH.js";import{W as le}from"./entities-CWtNgawi.js";import{T as ue,W as j,_ as M,g as N,u as de,x as fe}from"./TooltipProvider-Czzm7ro-.js";import{J as P,Y as pe,n as me,tt as F}from"./ChatMarkdown-BUoR67CT.js";import{t as he}from"./spinner-BiCpg0TU.js";import{a as ge,h as _e}from"./relay-Do9UB5iT.js";import{C as ve,J as ye,K as be,k as xe,s as Se}from"./useSettings-EYJbJzT3.js";import{i as Ce,n as we}from"./session-CBEVNHld.js";import{t as Te}from"./use-atom-command-BbFDhw_c.js";import{a as Ee}from"./fileLinks-BfcK2bJU.js";import{d as De}from"./providerSkills-C8PrnHb-.js";import{t as Oe}from"./toastHelpers-DxXYm50b.js";import{o as ke}from"./queries-Cl508kPw.js";import{H as I,V as L,l as Ae,ot as je,st as Me}from"./diffRendering-DAzPanqh.js";import{A as Ne,B as Pe,G as Fe,K as R,T as Ie,a as Le,j as Re,l as z,t as ze}from"./Virtualizer-DsEq6qUF.js";import{B as Be,G as Ve,H as B,J as He,K as V,Q as Ue,U as H,V as We,W as Ge,q as U}from"./getDiffFileInput-XE3jyXxK.js";import{c as Ke,i as qe,n as Je,o as Ye,s as Xe,t as Ze}from"./DiffWorkerPoolProvider-TgqbZJCv.js";import{n as Qe}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{S as $e,_ as et,b as tt,c as nt,d as rt,f as it,g as at,h as W,i as ot,l as st,m as G,o as ct,p as lt,r as ut,s as K,t as dt,u as ft,v as pt,x as mt,y as ht}from"./DiffCommentAnnotation-C28NAT6f.js";import{t as gt}from"./mediaReference-DQ6GIZY7.js";import{A as _t,D as vt,E as yt,F as bt,L as xt,M as St,N as Ct,O as wt,R as q,j as Tt,k as Et,w as Dt,z as Ot}from"./ThreadDetailsItemsMenu-DEwUOoLt.js";import{a as kt,n as At,t as jt}from"./tooltip-C7NAkYG3.js";import{i as Mt,n as Nt,r as Pt,t as Ft}from"./fileCommentAnnotations-BgdL_7u9.js";import{r as It,t as Lt}from"./ReadOnlySourcePreview-CRy5hHfx.js";import{a as Rt,c as zt,i as Bt,n as Vt,o as Ht,r as Ut,s as Wt,t as Gt}from"./fileTreeExpansion-DjiK1m5s.js";import{t as Kt}from"./pierre-icons-BdcegjLq.js";import{t as qt}from"./scroll-area-Cm9XZdHp.js";import{t as Jt}from"./observeResize-BbXolq6K.js";import{n as Yt,r as Xt,t as Zt}from"./RightPanelResizeHandle-BODMyZa6.js";import{t as Qt}from"./assets-Dh1LFwqL.js";import{i as $t,n as en,t as tn}from"./assetUrls-CpRsTTqn.js";import{w as nn}from"./browserHistoryStore-BVEWgOnh.js";import{i as rn,r as an}from"./openFileInPreview-BHhDd-id.js";import{t as on}from"./preview-DgXn94k5.js";import{t as sn}from"./PierreEntryIcon-DLXDEcqA.js";import{n as cn}from"./composerTrigger-BGi0iyhl.js";import{r as ln,t as un}from"./input-group-BQ_2ox-w.js";import{f as dn,i as fn,l as pn,n as mn,o as hn,t as gn,u as _n}from"./projectFilesQueryState-BdfD5cZ2.js";import{Ao as vn,To as yn,xo as bn}from"./main-B1sXOjZZ.js";import{C as xn,f as Sn,m as Cn,p as wn}from"./_chat-BeJoXsdK.js";var Tn={compositeOverBg:Be,contrastRatio:We,deriveMutedFg:B,hoverWouldEraseText:H,isDarkSurface:Ge,isFullyTransparent:Ve,pickReadableForeground:V,relativeLuminance:U,surfacesMatch:He},J=e(t(),1);function En(e,t){return e.isOpen===t.isOpen&&e.value===t.value&&Rt(e.matchingPaths,t.matchingPaths)}function Dn(e){let t=Ht(e,e=>({isOpen:e.isSearchOpen(),matchingPaths:e.getSearchMatchingPaths(),value:e.getSearchValue()}),En);return(0,J.useMemo)(()=>({...t,close:()=>{e.closeSearch()},focusNextMatch:()=>{e.focusNextSearchMatch()},focusPreviousMatch:()=>{e.focusPreviousSearchMatch()},open:t=>{e.openSearch(t)},setValue:t=>{e.setSearch(t)}}),[e,t])}var On=100,kn=`insert`,An=`backspace`,jn=`delete`,Mn=class e{#e=[];#t=[];#n;#r=!1;constructor(e){this.#n=Math.max(1,e?.maxEntries??On)}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}getState(){return{undoStack:this.#e.map(Pn),redoStack:this.#t.map(Pn),maxEntries:this.#n,canCoalesce:this.#r}}getLiveState(){return Object.defineProperties({},{undoStack:{enumerable:!0,get:()=>this.#e},redoStack:{enumerable:!0,get:()=>this.#t},maxEntries:{enumerable:!0,get:()=>this.#n},canCoalesce:{enumerable:!0,get:()=>this.#r}})}static fromState(t){let n=new e({maxEntries:t.maxEntries});return n.#e=t.undoStack,n.#t=t.redoStack,n.#r=t.canCoalesce,n}clear(){this.#e.length=0,this.#t.length=0,this.#r=!1}clearRedo(){this.#t.length=0}push(e){this.#e.push(e),this.clearRedo(),this.#r=!0,this.#e.length>this.#n&&this.#e.shift()}setLastUndoSelectionsAfter(e){let t=this.#e[this.#e.length-1];t!==void 0&&(t.selectionsAfter=e.map(e=>({...e})))}setLastUndoLineAnnotations(e,t){let n=this.#e[this.#e.length-1];n!==void 0&&(n.lineAnnotationsBefore=e.slice(),n.lineAnnotationsAfter=t.slice())}peekUndo(){return this.#e[this.#e.length-1]}peekUndoForCoalescing(){return this.#r?this.peekUndo():void 0}replaceLastUndo(e){this.#e.length===0?this.push(e):(this.#e[this.#e.length-1]=e,this.clearRedo(),this.#r=!0)}popUndoToRedo(){let e=this.#e.pop();if(e!==void 0)return this.#t.push(e),this.#r=!1,e}popRedoToUndo(){let e=this.#t.pop();if(e!==void 0)return this.#e.push(e),this.#r=!1,e}};function Nn(e){return{...e,forwardEdits:e.forwardEdits.map(e=>({...e})),inverseEdits:e.inverseEdits.map(e=>({...e})),selectionsBefore:e.selectionsBefore?.map(Fn),selectionsAfter:e.selectionsAfter?.map(Fn),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:e.lineAnnotationsAfter?.slice()}}function Pn(e){return{...Nn(e),lineAnnotationsBefore:e.lineAnnotationsBefore?.map(e=>({...e})),lineAnnotationsAfter:e.lineAnnotationsAfter?.map(e=>({...e}))}}function Fn(e){return{...e,start:{...e.start},end:{...e.end}}}function In(e,t,n,r,i,a,o,s){let c=[...t].sort((e,t)=>e.start-t.start),l=[],u;if(i?.length===c.length){let t=[];for(let n of i){if(n.start.line!==n.end.line||n.start.character!==n.end.character)break;t.push(e.offsetAt(n.start))}if(t.length===c.length){t.sort((e,t)=>e-t);let e=!0,n=!0;for(let r=0;r<c.length;r++){let i=c[r];if(i.text.length>0||i.start===i.end){e=!1,n=!1;break}e&&=t[r]===i.end,n&&=t[r]===i.start}u=e?An:n?jn:void 0}}for(let t=0,n=0;t<c.length;t++){let r=c[t],i=e.getTextSlice(r.start,r.end),a=r.start+n;l.push({start:a,end:a+r.text.length,text:i}),n+=r.text.length-(r.end-r.start)}return{forwardEdits:c.map(e=>({...e})),inverseEdits:l,versionBefore:n,versionAfter:r,selectionsBefore:i?.map(e=>({...e})),selectionsAfter:a?.map(e=>({...e})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:s?.slice(),coalescingMode:u}}function Ln(e,t){if(e===void 0||e.undoBoundary===!0||t.undoBoundary===!0||e.forwardEdits.length===0||e.forwardEdits.length!==e.inverseEdits.length||e.forwardEdits.length!==t.forwardEdits.length||t.forwardEdits.length!==t.inverseEdits.length)return!1;let n;for(let r=0;r<e.forwardEdits.length;r++){let i=e.forwardEdits[r],a=e.inverseEdits[r],o=t.forwardEdits[r],s=t.inverseEdits[r],c=Bn(o.start,e.forwardEdits),l=i.start<=i.end&&i.text.length>0&&!i.text.includes(`
2
2
  `)&&!a.text.includes(`
3
3
  `),u=o.start===o.end&&o.text.length>0&&!o.text.includes(`
4
4
  `)&&s.text.length===0;if(l&&u){if(o.start!==a.end||(n??=kn,n!==kn||e.coalescingMode!==void 0&&e.coalescingMode!==kn||t.coalescingMode!==void 0&&t.coalescingMode!==kn))return!1;continue}let d=i.text.length===0&&i.end>i.start&&a.text.length>0,f=o.text.length===0&&o.end>o.start&&s.text.length>0;if(d&&f){let r;if(c===i.end)r=jn;else if(c+(o.end-o.start)!==i.start)return!1;else r=An;if(n??=r,n!==r||e.coalescingMode!==void 0&&e.coalescingMode!==r||t.coalescingMode!==void 0&&t.coalescingMode!==r)return!1}else return!1}return n!==void 0}function Rn(e,t){let n=[],r=[],i;for(let a=0;a<e.forwardEdits.length;a++){let o=e.forwardEdits[a],s=e.inverseEdits[a],c=t.forwardEdits[a],l=t.inverseEdits[a],u=Bn(c.start,e.forwardEdits);o.text.length>0?(i??=kn,n.push({start:o.start,end:o.end,text:o.text+c.text}),r.push(s.text)):u===o.end?(i??=jn,n.push({start:o.start,end:u+(c.end-c.start),text:``}),r.push(s.text+l.text)):(i??=An,n.push({start:Math.min(o.start,u),end:o.end,text:``}),r.push(l.text+s.text))}return{forwardEdits:n,inverseEdits:zn(n,r),versionBefore:e.versionBefore,versionAfter:t.versionAfter,selectionsBefore:e.selectionsBefore?.slice(),selectionsAfter:t.selectionsAfter?.slice(),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:t.lineAnnotationsAfter?.slice(),coalescingMode:i}}function zn(e,t){let n=[];for(let r=0,i=0;r<e.length;r++){let a=e[r],o=a.start+i;n.push({start:o,end:o+a.text.length,text:t[r]}),i+=a.text.length-(a.end-a.start)}return n}function Bn(e,t){let n=e;for(let e of t){let t=e.end-e.start,r=e.text.length,i=r-t;n<e.start||(n>=e.start+r?n-=i:n=e.start+Math.min(n-e.start,t))}return n}var Vn=new WeakMap;function Hn(e){return Vn.get(e)}function Un(e,t){Vn.set(e,t)}var Wn=class e{#e;#t;#n;#r;#i;#a;constructor(e,t,n=`text`,r=0,i=new Mn,a){if(this.#e=new URL(e,`file://`).toString(),this.#t=n,this.#n=r,this.#r=new pt(t),this.#i=i,a!=null)this.#a=a;else{let e=this.#r.getLineText(0,!0);this.#a=e.endsWith(`\r
@@ -20,7 +20,7 @@ import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJe
20
20
  --diffs-editor-info-fg: ${g??`initial`};
21
21
  --diffs-editor-warning-fg: ${_??`initial`};
22
22
  --diffs-editor-error-fg: ${v??`initial`};
23
- }`),this.#i=e,this.#r=t??n.type,this.#a=r}#F(){if(this.#i===``)return;let{colorMap:e}=this.#e.setTheme(this.#i);this.#a=e}cleanUp(){this.#m=!0,this.stopBackgroundTokenize(),this.#R(),this.#p?.forEach(e=>e()),this.#p=void 0}tokenize(e,t,n=!1){if(this.#I(),this.#F(),this.#t===void 0&&!qa(this.#o.languageId))throw Error(`Grammar for language "${this.#o.languageId}" not loaded`);let{lineCount:r}=this.#o,{startingLine:i=0,totalLines:a=1/0}=t??{},o=a===1/0?r:Math.min(i+a,r),s=e.startLine,c=Math.max(i,s),l=t!==void 0&&a!==1/0&&e.lineDelta>0&&s<o&&e.endLine>=o,u=e.lineDelta===0&&(e.changedLineChanges?.every(([,,e])=>e===0)??!0);this.#d&&!u&&(this.#O.length=Math.min(this.#O.length,e.startLine));let d=n&&e.lineDelta!==0&&s>=i,f=u||t===void 0||s>=c,p=e.changedLineRanges??[[s,e.endLine]];this.#g=[],this.#_=0,this.#v=[];let m=-1;if(s<c)for(let[e,t]of p)e<c&&(m=Math.max(m,Math.min(t,c-1)));let h=m>=s&&(u||e.lineDelta<0);u?this.#K(s):(this.#W(e),(t===void 0||s>=c)&&this.#K(c));let g=0,_=p[g][1],v,y=0,b=u?p[g][0]:c,x=!1,S=new Map,C=h?new Map:void 0;if(C!==void 0&&!u){let e=Math.min(m+1,c,o);if(e>s){this.#K(e);let t=s,n=this.#h[t]??I;for(;t<e;t++){let e=this.#H(t,n);n=e.state,C.set(t,e.resolvedTokens)}this.#h[e]=n}}let w=this.#h[b]??I;for(;b<o;){let e=u?this.#h[b+1]:d?this.#G(b+1):void 0;f&&(this.#h[b]=w);let{resolvedTokens:t,state:n}=this.#H(b,w);if(w=n,b>=c?S.set(b,t):C?.set(b,t),f&&(this.#h[b+1]=w),x=b>=_&&(u||d)&&e!==void 0&&w.equals(e),x){g++;let e=p[g];if(e===void 0)break;if(e[0]>=o){v=e[0],y=g;break}let t=this.#h[e[0]];if(d)for(let n=b+2;n<=e[0]&&(t=this.#G(n),t!==void 0);n++)this.#h[n]=t;t===void 0?(_=e[1],b++):(b=e[0],w=t,_=e[1]),x=!1}else b++}if(f&&(b<o?this.#h[b+1]=w:this.#h[b]=w),x&&d&&v===void 0){for(let e=b+2;e<=r;e++){let t=this.#G(e);if(t===void 0)break;this.#h[e]=t}this.#g=[],this.#_=0,this.#v=[]}if(C!==void 0&&C.size>0&&this.#l(C,this.#r),v!==void 0)this.#d&&u&&(this.#O.length=Math.min(this.#O.length,v)),this.#B(v,p,y);else if(!x&&b<r){let e=l&&s>=c?o:s<c&&!u?s:b;this.#d&&u&&(this.#O.length=Math.min(this.#O.length,e)),this.#B(e,p,g)}return S}prebuildStateStack(e){this.#I(),this.#A(e)}stopBackgroundTokenize(){this.#T=-1,!this.#b&&(this.#b=!0,this.#x=!1,this.#y=-1,this.#w=-1,this.#E=void 0,this.#D=0,this.#g=[],this.#_=0,this.#v=[],this.#R())}pauseBackgroundTokenize(){this.#b||this.#x||(this.#f&&console.log(`[diffs/editor] background tokenization paused`,{jobId:this.#S}),this.#x=!0)}resumeBackgroundTokenize(){this.#b||!this.#x||this.#t===void 0||this.#y<0||(this.#f&&console.log(`[diffs/editor] background tokenization resumed`,{jobId:this.#S}),this.#x=!1,this.#z(this.#S))}#I(){this.#t===void 0&&!qa(this.#o.languageId)&&this.#e.getLoadedLanguages().includes(this.#o.languageId)&&(this.#t=this.#e.getLanguage(this.#o.languageId))}#L(){this.#k||=(globalThis.addEventListener(`message`,this.#j),!0)}#R(){this.#k&&=(globalThis.removeEventListener(`message`,this.#j),!1)}#z(e){globalThis.postMessage({type:`tokenize`,tokenizerId:this.#C,jobId:e})}#B(e,t,n=0){if(qa(this.#o.languageId))return;let r=++this.#S;this.#f&&console.log(`[diffs/editor] background tokenization scheduled`,{jobId:r,startLine:e,changedLineRanges:t,changedRangeIndex:n}),this.#b=!1,this.#x=!1,this.#y=e,this.#w>=0&&(this.#T=Math.max(this.#T,this.#w)),this.#w=-1,this.#E=t,this.#D=n,this.#L(),this.#z(r)}#V(e){if(this.#t===void 0||this.#h.length>e)return;if(!this.#b){this.#w>=0?this.#w=Math.max(this.#w,e):this.#T=Math.max(this.#T,e);return}let t=++this.#S;this.#b=!1,this.#x=!1,this.#y=this.#h.length-1,this.#w=e,this.#T=-1,this.#E=void 0,this.#D=0,this.#L(),this.#z(t)}#H(e,t){let n=this.#o.getLineText(e);if(n.length>this.#s)return console.warn(`[diffs] Line(${e}) too long to tokenize: ${n.length}`),this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};if(this.#t===void 0||n===``||n.trim()===``)return this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};let r=Ga(this.#t,this.#a,n,t,Ha,this.#d);return this.#U(e,r.bracketIgnoredRanges),{resolvedTokens:r.resolvedTokens,state:r.ruleStack}}#U(e,t){this.#d&&(this.#O[e]=t)}#W(e){let t=e.changedLineChanges??[[e.startLine,e.endLine,e.lineDelta]],n=e.startLine+1;n<=this.#h.length-n?(this.#g=this.#h,this.#_=0,this.#h=this.#h.slice(0,n)):(this.#_=n,this.#g=this.#h.slice(n),this.#h.length=Math.min(this.#h.length,n)),this.#v=t}#G(e){let t=e;for(let n=this.#v.length-1;n>=0;n--){let[r,i,a]=this.#v[n];if(a!==0){if(t>i)t-=a;else if(t>r)return this.#h[e]}}return this.#g[t-this.#_]??this.#h[e]}#K(e,t){let n=Math.min(Math.max(0,e),this.#o.lineCount);if(this.#h.length>n||this.#t===void 0)return!0;let r=t===void 0?0:performance.now(),i=this.#h.length-1,a=this.#h[i]??I;for(;i<n;){this.#h[i]=a;let e=this.#o.getLineText(i);if(e.length<=this.#s&&e!==``&&e.trim()!==``){let t=Ga(this.#t,this.#a,e,a,Ha,this.#d,!1);this.#U(i,t.bracketIgnoredRanges),a=t.ruleStack}else this.#U(i,null);if(i++,this.#h[i]=a,t!==void 0&&performance.now()-r>t)break}return i>=n}#q(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=this.#K(this.#w,1);this.#b||this.#x||e!==this.#S||(t?this.stopBackgroundTokenize():(this.#y=this.#h.length-1,this.#z(e)))}#J(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=performance.now(),n=new Map,r=this.#o.lineCount,i=this.#E,a=this.#y,o=this.#h[a]??I,s=!1,c=this.#D,l=i?.[c]?.[1];for(;a<r;){this.#h[a]=o;let e=l===void 0?void 0:this.#G(a+1),r=this.#o.getLineText(a);if(r.length>this.#s)console.warn(`[diffs] Line(${a}) too long to tokenize: ${r.length}`),n.set(a,[[0,``,r]]),this.#U(a,null);else if(r===``||r.trim()===``)n.set(a,[[0,``,r]]),this.#U(a,null);else{let e=Ga(this.#t,this.#a,r,o,Ha,this.#d);n.set(a,e.resolvedTokens),this.#U(a,e.bracketIgnoredRanges),o=e.ruleStack}if(this.#h[a+1]=o,s=l!==void 0&&a>=l&&e!==void 0&&o.equals(e),a++,s){c++;let e=i?.[c];if(e===void 0)break;if(l=e[1],this.#h[e[0]]===void 0)s=!1;else{a=e[0],o=this.#h[a]??o,s=!1;continue}}if(performance.now()-t>1)break}if(this.#l(n,this.#r),!(this.#b||this.#x||e!==this.#S)){if(s||a>=r){let e=this.#T;this.stopBackgroundTokenize(),e>=0&&this.#V(e)}else this.#y=a,this.#D=c,this.#z(e)}}};function Ga(e,t,n,r,i,a=!0,o=!0){let s=e.tokenizeLine2(n,r,i);s.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);let c=s.tokens,l=c.length/2,u=[],d=[];if(!o&&!a)return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d};for(let e=0;e<l;e++){let r=c[2*e],i=e+1<l?c[2*e+2]:n.length;if(r===i)continue;let s=c[2*e+1];if(o){let e=L.getForeground(s);u.push([r,t[e],n.slice(r,i)])}a&&L.getTokenType(s)>0&&d.push([r,i])}return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d}}function Ka(e){return e.map(([e,t,n])=>e===0&&t===``?n===``?W(`br`):n:W(`span`,{dataset:{char:e.toString()},style:`color:${t};`,textContent:n}))}function qa(e){return e===`text`||e===`ansi`}function Ja(e){let t=e.getSelection?.();if(t==null||t.rangeCount===0)return;let n=t.getRangeAt(0);return{collapsed:n.collapsed,startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}}function Ya(e,t){let n=Ye(e),r=n[n.length-1]??0;return{start:0,end:e.length,text:t,range:{start:{line:0,character:0},end:{line:n.length-1,character:e.length-r}}}}function Xa(e){return e!=null&&`renderType`in e&&e.renderType===`virtualized`}var Za=2,Qa=1e4,$a=300,eo=256,to=131072,no=new TextEncoder,ro=`selection-action`,io=`application/vnd.pierre.diffs-selections+json`,ao=class{type;#e;#t;#n;#r=new La;#i;#a;#o;#s;#c;#l;#u={generation:0,callback:void 0,delivered:!1};#d;#f;#p;#m=new Map;#h=new Map;#g=new Map;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I=!1;#L=!1;#R;#z;#B;#V;#H;#U;#W;#G;#K;#q=!0;#J=!1;#Y=!1;#X=!1;#Z;#Q=!1;#$=!1;#ee=!1;#te;#ne=!1;#re;#ie=``;#ae;#oe;#se;#ce;#le;#ue;#de=!1;#fe=!1;#pe=!1;#me=!1;#he;#ge;#_e;#ve=0;#ye=!1;#be=!1;#xe;#Se=[];#Ce=new Map;#we=new Map;#Te=(e,t)=>{if(this.#I&&(this.#M?.updateRenderCache(e,t),this.#V!==void 0&&this.#V.totalLines!==1/0)){let t=this.#xe===void 0?void 0:new Set(this.#xe.response.edits.map(e=>e.range.start.line)),n=!1,{startingLine:r,totalLines:i}=this.#V,a=Math.min(r+i,(this.#n??this.#t)?.document?.lineCount??0);for(let[i,o]of e)if(i>=r&&i<a){let e=this.#gn(i);e!==void 0&&(e.replaceChildren(...Ka(o)),n||=t?.has(i)===!0)}n&&this.#se!==void 0&&this.#Wt(this.#se)}};constructor(e,t={},n){this.type=e,this.#e=t,this.#B=t.ownsVerticalViewport===!0,this.#t=t.initialState,this.#z=n}get#Ee(){return this.type,this}setOptions(e){let t=this.#e.renderCaret,n=this.#e.editPrediction;this.#e={...this.#e,...e},t!==this.#e.renderCaret&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#Gt()),n!==this.#e.editPrediction&&(this.#Rt(!0),this.#Se=[],this.#Bt())}__emitEditComplete(e){this.#e.onComplete?.(e)}__getGhostTextRows(){return this.#we}setCarets(e){let t=this.#n?.document;t!==void 0&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,this.#W=e.length===0?void 0:e.map(e=>{let n=t.normalizePosition(e.anchor),r=t.normalizePosition(e.focus);return{caret:{...e,anchor:n,focus:r},anchorOffset:t.offsetAt(n),focusOffset:t.offsetAt(r)}}),this.#Gt())}edit(e){let t=this.#Ee,n=this.#n;if(this.#I)throw Error(`Editor.edit: the editor is already rendering its component`);if(this.#M!=null&&this.#M!==e)throw Error(`Editor.edit: a recycled edit session cannot attach to a different component`);if(e.type===`file-diff`&&this.#n==null&&!e.__canAttachEditor())throw Error(`Editor.edit: a complete diff is required before editing`);let r=this.#t,i=r?.editor,a=this.#z,o=oo({type:this.type,editStateKey:a,owner:this,initialState:r,previousSession:n}),s=o.diffSession;this.#t=void 0,this.#n=o,this.#M=e,this.#I=!0,this.#L=o.editor!=null;try{if(this.#Ge(),e.type===`file`&&t.type===`file`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else if(e.type===`file-diff`&&t.type===`file-diff`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else throw Error(`Editor.edit: Impossible edit state`)}catch(e){throw this.cleanUp(`recycle`),o.type===`file-diff`&&o.diffSession==null&&(o.diffSession=s),this.#l==null&&a!=null&&(t.type===`file`?Qn.releaseFile(a,t):Qn.releaseFileDiff(a,t)),this.#n=n,this.#l??(this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0),r!=null&&i!=null&&(r.editor=i),this.#t=r,e}return()=>{this.cleanUp(`complete`)}}applyEdits(e,t=!0){let n=this.#n?.document;if(n==null)throw Error(`Editor.applyEdits: Editor is not attached`);let r=this.#X,i=this.#se,a=i?.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]),o=i===void 0?void 0:n.resolveEdits(e).sort((e,t)=>e.start-t.start),s=n.applyEdits(e,t,i);if(s===void 0)return;let c;i!==void 0&&a!==void 0&&o!==void 0&&(c=Hr(n,i,a,o),t&&n.setLastUndoSelectionsAfter(c)),this.#dn(s,c,this.#pn(s),{skipFocus:!r})}get canUndo(){return(this.#n??this.#t)?.document?.canUndo??!1}get canRedo(){return(this.#n??this.#t)?.document?.canRedo??!1}undo(){this.#et(`undo`)}redo(){this.#et(`redo`)}getFile(){let e=this.#n??this.#t,t=e?.fileInfo,n=e?.document;if(t===void 0||n===void 0)return;let r={...t};return Object.defineProperty(r,"contents",{enumerable:!0,get:()=>n.getText()}),r}getText(){return(this.#n??this.#t)?.document?.getText()??``}getViewState(){let e=this.#I?this.#M:void 0;if(!this.#I&&this.#n?.editor!=null)return Yn(this.#n.editor);let t=this.#se?.map(e=>({...e,start:{...e.start},end:{...e.end}}));if(e==null)return{selections:t};let n=this.#We(),r=e.getCodeScrollLeft();return n==null?{selections:t,view:{scrollLeft:r}}:{selections:t,view:{scrollLeft:r,scrollTop:n.scrollTop}}}getEditState(){let e=this.#n;if(e!=null){if(this.#M==null)throw Error(`Editor.getEditState: active ${this.type} session has no component`);return Xn(e)}}setViewState({selections:e,view:t}){if(!this.#I||this.#M===void 0||this.#n?.document===void 0)throw Error(`Editor.setViewState: Editor is not attached`);if(this.#q=!1,this.#Wt(e??[]),t!=null){this.#M.setCodeScrollLeft(t.scrollLeft);let e=this.#We();t.scrollTop!==void 0&&e!=null&&(e.scrollTop=t.scrollTop)}else this.#B&&this.#gt();this.#De()}setSelections(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setSelections: Text document is not initialized`);let n=e.map(e=>{let n=t.normalizePosition(e.start),r=t.normalizePosition(e.end),i=e.direction===`none`?0:e.direction===`backward`?-1:1;return Z(n,r)>0&&([n,r]=[r,n],i!==0&&(i=i===1?-1:1)),{direction:i,start:n,end:r}});this.#q=!1,this.#Wt(n);let r=n.at(-1);r!==void 0&&this.#Pe(X(r).line),this.#gt()}setMarkers(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setMarkers: Text document is not initialized`);e.length===0?(this.#U?.cleanup(),this.#U=void 0,this.#Wt(this.#se??[])):(this.#U??=new Pi({popoverManager:this.#Re(),getLineHeight:()=>this.#r.lineHeight,getOverlayElement:()=>this.#E,getGutterWidth:()=>this.#_n(),getCharX:(e,t)=>this.#bn(e,t),getLineY:e=>this.#yn(e),isMouseDown:()=>this.#ee||this.#$}),this.#U.setMarkers(e,t),this.#w!==void 0&&this.#U.listenHover(this.#w),this.#Wt(this.#se??[]),this.#Gt())}focus(e){let t=e?.preventScroll??!1,n=e?.lineNumber;if(n===`first-visible`||typeof n==`number`){let r=this.#n?.document;if(r==null||!this.#I||this.#M==null)return;let i=n===`first-visible`?this.#pt(e?.offset):n;if(i==null)return;let a=r.normalizePosition({line:i-1,character:n===`first-visible`?0:e?.character??0});this.#mt(a,t);return}let r=this.#se?.at(-1);if(r!==void 0){let e=r.direction===-1?r.end:r.start;this.#ut(e,t)}else this.#ut(void 0,t)}blur(){this.#Z=void 0,this.#X=!1,this.#J=!1,this.#w?.blur()}cleanUp(e=`discard`){let t=this.#M,n=e===`recycle`;this.#Rt(!0,!1),n||(this.#Se=[]);let r=this.#n;if(t!=null&&r!=null){let e=!this.#De();n||this.#Oe(e)}if(this.#Ve(),n||(this.#u.delivered=!1),this.#I=!1,Fe(this.#Ze),this.#i?.cleanUp(),this.#i=void 0,this.#s?.forEach(e=>e()),this.#s=void 0,this.#o?.forEach(e=>e()),this.#o=void 0,n||(this.#l?.(),this.#l=void 0),this.#f=void 0,this.#p=void 0,this.#m.clear(),this.#h.clear(),this.#g.clear(),this.#_=void 0,this.#v?.remove(),this.#v=void 0,this.#y?.remove(),this.#y=void 0,this.#b?.remove(),this.#b=void 0,this.#x?.remove(),this.#x=void 0,this.#S=void 0,this.#a?.cleanUp(),this.#a=void 0,this.#C=void 0,this.#T=void 0,this.#w?.removeAttribute(`contentEditable`),this.#w=void 0,this.#Z=void 0,this.#X=!1,this.#E?.remove(),this.#E=void 0,this.#j?.disconnect(),this.#j=void 0,this.#me=!1,this.#he!==void 0&&(cancelAnimationFrame(this.#he),this.#he=void 0),this.#Be(n),!n)try{if(t!=null&&r!=null){let n=this.#Ee,r=e===`complete`?`install`:`discard`;if(t.type===`file`&&n.type===`file`)t.__completeEditSession(n,r);else if(t.type===`file-diff`&&n.type===`file-diff`)t.__completeEditSession(n,r);else throw Error(`Editor.cleanUp: Impossible edit state`)}}finally{this.#n=void 0,this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0}}#De(){let e=this.#M,t=this.#n;if(e==null||t==null)return!1;let n=this.#I?this.getViewState():t.editor??{},{view:r}=n,i=r!=null&&(r.scrollLeft!==0||(r.scrollTop??0)!==0),a=n.selections!=null||i;if(t.editor=Yn(n),t.type===`file`)return!1;let o=e.__captureDocumentSessionState();if(o==null)return t.diffSession=void 0,!1;t.diffSession=o.diffSession;let s=t.document;return o.hasChanges||a||s?.canUndo===!0||s?.canRedo===!0}#Oe(e=!1){let t=this.#z;if(t==null)return;let n=this.#Ee;n.type===`file`?Qn.releaseFile(t,n):Qn.releaseFileDiff(t,n,e)}__postponeBgTokenizeToNextFrame(){let e=this.#i;e!==void 0&&(e.pauseBackgroundTokenize(),requestAnimationFrame(()=>{e.resumeBackgroundTokenize()}))}__captureFocusForDOMReplacement(){let e=this.#w,t=this.#S?.shadowRoot?.activeElement;e!=null&&(this.#X||t===e||t!=null&&e.contains(t))&&(this.#Z={})}__getDocumentContents(e){let t=this.#n?.fileInfo,n=this.#n?.document;if(n==null)return t==null||e==null?void 0:{...t,contents:e.contents};let r=t??e;if(r!=null)return{name:r.name,lang:r.lang,contents:n.getText()}}__getDocumentSessionState(){let e=this.#n?.diffSession;return e==null?void 0:Ri(e)}__syncRenderView(e){let{highlighter:t,fileContainer:n,renderRange:r,externalDocument:i=!1}=e,a=e,o;if(`file`in a&&this.type===`file`)o=a.file;else if(`fileDiff`in a&&this.type===`file-diff`)o=a.fileDiff;else throw Error(`Editor.__syncRenderView: Impossible render state`);let s=a.lineAnnotations,c=this.#z,l=this.#M,u=this.#n;if(!this.#I||l==null||u==null)return;let d=n.shadowRoot;if(d==null){console.error(`[editor] Could not find the shadow root.`);return}let f,p,m,h,g;for(let e of d.querySelectorAll(`[data-code]`)){let t=e.dataset.deletions!=null;t||(f=e);for(let n of e.children){if(!(n instanceof HTMLElement))continue;let{gutter:e,content:r}=n.dataset;e==null?r!=null&&(t?g=n:m=n):t?h=n:p=n}}if(g==null)this.#T=void 0;else if(h==null)throw Error(`Editor.__syncRenderView: the deletions column has no gutter`);else this.#T={content:g,gutter:h};if(f===void 0||m===void 0){this.#Z=void 0;return}this.#Re().setViewportElements(n,f),this.#S!==n&&(this.#S=n,this.#v!==void 0&&n.appendChild(this.#v),this.#y!==void 0&&d.appendChild(this.#y),this.#b!==void 0&&d.appendChild(this.#b),this.#x!==void 0&&d.prepend(this.#x));let _=o.lang??bn(o.name),v=`contents`in o?o.contents:o.additionLines.join(``),y=u.document,b=e.resetHistory??(y!=null&&u.fileInfo!=null&&(u.fileInfo.name!==o.name||y.languageId!==_)),x=i&&y!==void 0&&y.getText()!==v?[Ya(y.getText(),v)]:void 0,S=i&&b;if(u.document==null||u.fileInfo==null||c==null&&(u.fileInfo.name!==o.name||u.document.languageId!==_)||S){this.#Rt(!0),this.#Se=[],this.#Ve();let{name:e,lang:t}=o,n=S||c==null&&u.fileInfo!=null?void 0:u.document;if(y!=null&&n==null&&(u.editor=void 0),n==null){let e=new Mn({maxEntries:this.#e.historyMaxEntries});n=new Wn(o.name,v,_,0,e)}u.fileInfo={name:e,lang:t},u.document=n,S&&(u.diffSession=void 0),this.#i?.cleanUp(),this.#i=void 0,this.#Be(),this.#h.clear(),this.#se=this.#oe,this.#e.__debug===!0&&console.log(`[diffs/editor] text document initialized from`,o.name)}if(i&&!S){this.#ke(u,v,s);let{name:e,lang:t}=o;u.fileInfo={name:e,lang:t}}let C=u.document;if(this.#i==null&&C!=null&&(this.#i=new Wa({highlighter:t,textDocument:C,codeOptions:this.#M?.__getEffectiveCodeOptions()??{},matchBrackets:this.#e.matchBrackets,onDeferTokenize:this.#Te,onThemeChange:()=>this.#Ot(),setStyle:e=>{this.#b.textContent=e},__debug:this.#e.__debug})),this.#w!==m&&(this.#C=p,this.#w=it(m,{contentEditable:`true`,role:`textbox`,ariaMultiLine:`true`,autocapitalize:`off`,writingSuggestions:`off`,autocorrect:!1,spellcheck:!1,translate:!1}),this.#E!==void 0&&m.after(this.#E),this.#r.init(m),this.#st(),this.#Xe(m,p),this.#w!==void 0&&this.#e.__debug===!0&&console.log(`[diffs/editor] full re-render triggered !!!`)),this.#Z!=null&&(this.#Z.target=m),m.ariaLabel!==o.name&&(m.ariaLabel=o.name),s!==void 0&&s.length>0||this.#Ie)for(let e of this.#w.children){let t=e,{lineAnnotation:n,lineType:r,separator:i}=t.dataset;(n!==void 0||i!==void 0||r===`change-deletion`)&&t.setAttribute(`contenteditable`,`false`)}this.#ze(),this.#i?.syncTheme(this.#M?.__getEffectiveCodeOptions()??{}),this.#R=s,this.#V=r,this.#H=r?.totalLines,this.#i?.prebuildStateStack(r);let w=u.editor,T=this.#L;try{if(this.#U?.removePopover(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#be&&this.#Bt(),this.#oe!==void 0&&this.#A!==void 0?(this.#oe=void 0,this.#gt(!1,`center`)):this.#le===void 0?this.#Z===void 0?this.#se!==void 0&&this.#se.length>0&&this.#X&&!this.#pe&&this.focus({preventScroll:!0}):this.#dt():this.#vt(this.#le,this.#ue,this.#fe),this.#pe&&this.#G?.focus(),T&&(this.#L=!1,w!==void 0&&this.setViewState(w)),this.#e.__debug===!0&&r!==void 0){let{startingLine:e,totalLines:t}=r;console.log(`[diffs/editor] render file:`,o.name,`RenderRange:`,e+`-`+(e+t),`of`,u.document?.lineCount,`lines`)}i&&l.__acknowledgeDocumentUpdate(),this.#De()}catch(e){throw this.#L=T,u.editor=w,e}x!=null&&this.#fn(x,s),this.#He(l)}#ke(e,t,n){let r=e.document;if(r==null||r.getText()===t)return;let i=this.#se,a=i?.map(e=>[r.offsetAt(e.start),r.offsetAt(e.end)]),o={start:0,end:r.getText().length,text:t};if(r.applyResolvedEdits([o],!0,i,void 0,!0)!=null){if(i!=null&&a!=null){let e=Hr(r,i,a,[o]);r.setLastUndoSelectionsAfter(e),this.#se=e}(this.#R!=null||n!=null)&&r.setLastUndoLineAnnotations(this.#R??[],n??[]),this.#i?.cleanUp(),this.#i=void 0,this.#ze(),this.#h.clear(),this.#U?.removePopover(),this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1})}}get#Ae(){return this.#M?.type===`file-diff`?this.#M:void 0}get#je(){return Xa(this.#M)?this.#M:void 0}#Me(e){return this.#Ae?.isLineRenderable?.(e+1)??!0}get#Ne(){let e=this.#Ae;if(e!=null)return(t,n)=>{let r=e.getNearestRenderableLine(t+1,n);return r==null?void 0:r-1}}#Pe(e){this.#Me(e)||this.#Ae?.revealLine?.(e+1)}get#Fe(){return this.#Ae?.options.diffStyle??`split`}get#Ie(){return this.type===`file-diff`}get#Le(){return this.#M?.options.overflow===`wrap`}#Re(){return this.#a??=new $n({hasActivePopover:()=>this.#K!==void 0||this.#U?.isPopoverVisible()===!0,updateActivePopover:()=>{this.#Zt(),this.#U?.updatePopoverPosition()}})}#ze(){this.#m.clear(),this.#g.clear(),this.#_=void 0}#Be(e=!1){this.#Dt(null),this.#f=void 0,this.#p=void 0,this.#Ke(),this.#Y=!1,this.#D?.forEach(e=>e.remove()),this.#D=void 0,this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,e||(this.#W=void 0),this.#se=void 0,this.#le=void 0,this.#U?.cleanup(),this.#U=void 0,this.#G?.cleanup(),this.#G=void 0,this.#K?.cleanup(),this.#K=void 0,this.#q=!0}#Ve(){let e=this.#u;e.generation++,e.callback!=null&&(Fe(e.callback),e.callback=void 0)}#He(e){let t=this.#u,n=this.#n?.document;if(t.delivered||t.callback!=null||n==null)return;let{generation:r}=t,i=()=>{if(t.callback!==i||(t.callback=void 0,r!==t.generation||this.#M!==e||this.#n?.document!==n))return;let a=this.#w,o=this.#S?.shadowRoot;a!=null&&o!=null&&o.contains(a)&&(t.delivered=!0,this.#e.onAttach?.(this,e))};t.callback=i,R(i)}#Ue(){let e=this.#je?.getEditorViewport?.();if(e!=null)return e;let t=this.#S;if(this.#M!=null&&t!=null)return at(t)}#We(){if(!this.#B)return;let e=this.#je?.getEditorViewport?.();if(e instanceof HTMLElement)return e}#Ge(){this.#v=W(`style`,{dataset:`editorGlobalCss`,textContent:`
23
+ }`),this.#i=e,this.#r=t??n.type,this.#a=r}#F(){if(this.#i===``)return;let{colorMap:e}=this.#e.setTheme(this.#i);this.#a=e}cleanUp(){this.#m=!0,this.stopBackgroundTokenize(),this.#R(),this.#p?.forEach(e=>e()),this.#p=void 0}tokenize(e,t,n=!1){if(this.#I(),this.#F(),this.#t===void 0&&!qa(this.#o.languageId))throw Error(`Grammar for language "${this.#o.languageId}" not loaded`);let{lineCount:r}=this.#o,{startingLine:i=0,totalLines:a=1/0}=t??{},o=a===1/0?r:Math.min(i+a,r),s=e.startLine,c=Math.max(i,s),l=t!==void 0&&a!==1/0&&e.lineDelta>0&&s<o&&e.endLine>=o,u=e.lineDelta===0&&(e.changedLineChanges?.every(([,,e])=>e===0)??!0);this.#d&&!u&&(this.#O.length=Math.min(this.#O.length,e.startLine));let d=n&&e.lineDelta!==0&&s>=i,f=u||t===void 0||s>=c,p=e.changedLineRanges??[[s,e.endLine]];this.#g=[],this.#_=0,this.#v=[];let m=-1;if(s<c)for(let[e,t]of p)e<c&&(m=Math.max(m,Math.min(t,c-1)));let h=m>=s&&(u||e.lineDelta<0);u?this.#K(s):(this.#W(e),(t===void 0||s>=c)&&this.#K(c));let g=0,_=p[g][1],v,y=0,b=u?p[g][0]:c,x=!1,S=new Map,C=h?new Map:void 0;if(C!==void 0&&!u){let e=Math.min(m+1,c,o);if(e>s){this.#K(e);let t=s,n=this.#h[t]??I;for(;t<e;t++){let e=this.#H(t,n);n=e.state,C.set(t,e.resolvedTokens)}this.#h[e]=n}}let w=this.#h[b]??I;for(;b<o;){let e=u?this.#h[b+1]:d?this.#G(b+1):void 0;f&&(this.#h[b]=w);let{resolvedTokens:t,state:n}=this.#H(b,w);if(w=n,b>=c?S.set(b,t):C?.set(b,t),f&&(this.#h[b+1]=w),x=b>=_&&(u||d)&&e!==void 0&&w.equals(e),x){g++;let e=p[g];if(e===void 0)break;if(e[0]>=o){v=e[0],y=g;break}let t=this.#h[e[0]];if(d)for(let n=b+2;n<=e[0]&&(t=this.#G(n),t!==void 0);n++)this.#h[n]=t;t===void 0?(_=e[1],b++):(b=e[0],w=t,_=e[1]),x=!1}else b++}if(f&&(b<o?this.#h[b+1]=w:this.#h[b]=w),x&&d&&v===void 0){for(let e=b+2;e<=r;e++){let t=this.#G(e);if(t===void 0)break;this.#h[e]=t}this.#g=[],this.#_=0,this.#v=[]}if(C!==void 0&&C.size>0&&this.#l(C,this.#r),v!==void 0)this.#d&&u&&(this.#O.length=Math.min(this.#O.length,v)),this.#B(v,p,y);else if(!x&&b<r){let e=l&&s>=c?o:s<c&&!u?s:b;this.#d&&u&&(this.#O.length=Math.min(this.#O.length,e)),this.#B(e,p,g)}return S}prebuildStateStack(e){this.#I(),this.#A(e)}stopBackgroundTokenize(){this.#T=-1,!this.#b&&(this.#b=!0,this.#x=!1,this.#y=-1,this.#w=-1,this.#E=void 0,this.#D=0,this.#g=[],this.#_=0,this.#v=[],this.#R())}pauseBackgroundTokenize(){this.#b||this.#x||(this.#f&&console.log(`[diffs/editor] background tokenization paused`,{jobId:this.#S}),this.#x=!0)}resumeBackgroundTokenize(){this.#b||!this.#x||this.#t===void 0||this.#y<0||(this.#f&&console.log(`[diffs/editor] background tokenization resumed`,{jobId:this.#S}),this.#x=!1,this.#z(this.#S))}#I(){this.#t===void 0&&!qa(this.#o.languageId)&&this.#e.getLoadedLanguages().includes(this.#o.languageId)&&(this.#t=this.#e.getLanguage(this.#o.languageId))}#L(){this.#k||=(globalThis.addEventListener(`message`,this.#j),!0)}#R(){this.#k&&=(globalThis.removeEventListener(`message`,this.#j),!1)}#z(e){globalThis.postMessage({type:`tokenize`,tokenizerId:this.#C,jobId:e})}#B(e,t,n=0){if(qa(this.#o.languageId))return;let r=++this.#S;this.#f&&console.log(`[diffs/editor] background tokenization scheduled`,{jobId:r,startLine:e,changedLineRanges:t,changedRangeIndex:n}),this.#b=!1,this.#x=!1,this.#y=e,this.#w>=0&&(this.#T=Math.max(this.#T,this.#w)),this.#w=-1,this.#E=t,this.#D=n,this.#L(),this.#z(r)}#V(e){if(this.#t===void 0||this.#h.length>e)return;if(!this.#b){this.#w>=0?this.#w=Math.max(this.#w,e):this.#T=Math.max(this.#T,e);return}let t=++this.#S;this.#b=!1,this.#x=!1,this.#y=this.#h.length-1,this.#w=e,this.#T=-1,this.#E=void 0,this.#D=0,this.#L(),this.#z(t)}#H(e,t){let n=this.#o.getLineText(e);if(n.length>this.#s)return console.warn(`[diffs] Line(${e}) too long to tokenize: ${n.length}`),this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};if(this.#t===void 0||n===``||n.trim()===``)return this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};let r=Ga(this.#t,this.#a,n,t,Ha,this.#d);return this.#U(e,r.bracketIgnoredRanges),{resolvedTokens:r.resolvedTokens,state:r.ruleStack}}#U(e,t){this.#d&&(this.#O[e]=t)}#W(e){let t=e.changedLineChanges??[[e.startLine,e.endLine,e.lineDelta]],n=e.startLine+1;n<=this.#h.length-n?(this.#g=this.#h,this.#_=0,this.#h=this.#h.slice(0,n)):(this.#_=n,this.#g=this.#h.slice(n),this.#h.length=Math.min(this.#h.length,n)),this.#v=t}#G(e){let t=e;for(let n=this.#v.length-1;n>=0;n--){let[r,i,a]=this.#v[n];if(a!==0){if(t>i)t-=a;else if(t>r)return this.#h[e]}}return this.#g[t-this.#_]??this.#h[e]}#K(e,t){let n=Math.min(Math.max(0,e),this.#o.lineCount);if(this.#h.length>n||this.#t===void 0)return!0;let r=t===void 0?0:performance.now(),i=this.#h.length-1,a=this.#h[i]??I;for(;i<n;){this.#h[i]=a;let e=this.#o.getLineText(i);if(e.length<=this.#s&&e!==``&&e.trim()!==``){let t=Ga(this.#t,this.#a,e,a,Ha,this.#d,!1);this.#U(i,t.bracketIgnoredRanges),a=t.ruleStack}else this.#U(i,null);if(i++,this.#h[i]=a,t!==void 0&&performance.now()-r>t)break}return i>=n}#q(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=this.#K(this.#w,1);this.#b||this.#x||e!==this.#S||(t?this.stopBackgroundTokenize():(this.#y=this.#h.length-1,this.#z(e)))}#J(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=performance.now(),n=new Map,r=this.#o.lineCount,i=this.#E,a=this.#y,o=this.#h[a]??I,s=!1,c=this.#D,l=i?.[c]?.[1];for(;a<r;){this.#h[a]=o;let e=l===void 0?void 0:this.#G(a+1),r=this.#o.getLineText(a);if(r.length>this.#s)console.warn(`[diffs] Line(${a}) too long to tokenize: ${r.length}`),n.set(a,[[0,``,r]]),this.#U(a,null);else if(r===``||r.trim()===``)n.set(a,[[0,``,r]]),this.#U(a,null);else{let e=Ga(this.#t,this.#a,r,o,Ha,this.#d);n.set(a,e.resolvedTokens),this.#U(a,e.bracketIgnoredRanges),o=e.ruleStack}if(this.#h[a+1]=o,s=l!==void 0&&a>=l&&e!==void 0&&o.equals(e),a++,s){c++;let e=i?.[c];if(e===void 0)break;if(l=e[1],this.#h[e[0]]===void 0)s=!1;else{a=e[0],o=this.#h[a]??o,s=!1;continue}}if(performance.now()-t>1)break}if(this.#l(n,this.#r),!(this.#b||this.#x||e!==this.#S)){if(s||a>=r){let e=this.#T;this.stopBackgroundTokenize(),e>=0&&this.#V(e)}else this.#y=a,this.#D=c,this.#z(e)}}};function Ga(e,t,n,r,i,a=!0,o=!0){let s=e.tokenizeLine2(n,r,i);s.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);let c=s.tokens,l=c.length/2,u=[],d=[];if(!o&&!a)return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d};for(let e=0;e<l;e++){let r=c[2*e],i=e+1<l?c[2*e+2]:n.length;if(r===i)continue;let s=c[2*e+1];if(o){let e=L.getForeground(s);u.push([r,t[e],n.slice(r,i)])}a&&L.getTokenType(s)>0&&d.push([r,i])}return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d}}function Ka(e){return e.map(([e,t,n])=>e===0&&t===``?n===``?W(`br`):n:W(`span`,{dataset:{char:e.toString()},style:`color:${t};`,textContent:n}))}function qa(e){return e===`text`||e===`ansi`}function Ja(e){let t=e.getSelection?.();if(t==null||t.rangeCount===0)return;let n=t.getRangeAt(0);return{collapsed:n.collapsed,startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}}function Ya(e,t){let n=Ye(e),r=n[n.length-1]??0;return{start:0,end:e.length,text:t,range:{start:{line:0,character:0},end:{line:n.length-1,character:e.length-r}}}}function Xa(e){return e!=null&&`renderType`in e&&e.renderType===`virtualized`}var Za=2,Qa=1e4,$a=300,eo=256,to=131072,no=new TextEncoder,ro=`selection-action`,io=`application/vnd.pierre.diffs-selections+json`,ao=class{type;#e;#t;#n;#r=new La;#i;#a;#o;#s;#c;#l;#u={generation:0,callback:void 0,delivered:!1};#d;#f;#p;#m=new Map;#h=new Map;#g=new Map;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I=!1;#L=!1;#R;#z;#B;#V;#H;#U;#W;#G;#K;#q=!0;#J=!1;#Y=!1;#X=!1;#Z;#Q=!1;#$=!1;#ee=!1;#te;#ne=!1;#re;#ie=``;#ae;#oe;#se;#ce;#le;#ue;#de=!1;#fe=!1;#pe=!1;#me=!1;#he;#ge;#_e;#ve=0;#ye=!1;#be=!1;#xe;#Se=[];#Ce=new Map;#we=new Map;#Te=(e,t)=>{if(this.#I&&(this.#M?.updateRenderCache(e,t),this.#V!==void 0&&this.#V.totalLines!==1/0)){let t=this.#xe===void 0?void 0:new Set(this.#xe.response.edits.map(e=>e.range.start.line)),n=!1,{startingLine:r,totalLines:i}=this.#V,a=Math.min(r+i,(this.#n??this.#t)?.document?.lineCount??0);for(let[i,o]of e)if(i>=r&&i<a){let e=this.#gn(i);e!==void 0&&(e.replaceChildren(...Ka(o)),n||=t?.has(i)===!0)}n&&this.#se!==void 0&&this.#Wt(this.#se)}};constructor(e,t={},n){this.type=e,this.#e=t,this.#B=t.ownsVerticalViewport===!0,this.#t=t.initialState,this.#z=n}get#Ee(){return this.type,this}setOptions(e){let t=this.#e.renderCaret,n=this.#e.editPrediction;this.#e={...this.#e,...e},t!==this.#e.renderCaret&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#Gt()),n!==this.#e.editPrediction&&(this.#Rt(!0),this.#Se=[],this.#Bt())}__emitEditComplete(e){this.#e.onComplete?.(e)}__getGhostTextRows(){return this.#we}setCarets(e){let t=this.#n?.document;t!==void 0&&(this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,this.#W=e.length===0?void 0:e.map(e=>{let n=t.normalizePosition(e.anchor),r=t.normalizePosition(e.focus);return{caret:{...e,anchor:n,focus:r},anchorOffset:t.offsetAt(n),focusOffset:t.offsetAt(r)}}),this.#Gt())}edit(e){let t=this.#Ee,n=this.#n;if(this.#I)throw Error(`Editor.edit: the editor is already rendering its component`);if(this.#M!=null&&this.#M!==e)throw Error(`Editor.edit: a recycled edit session cannot attach to a different component`);if(e.type===`file-diff`&&this.#n==null&&!e.__canAttachEditor())throw Error(`Editor.edit: a complete diff is required before editing`);let r=this.#t,i=r?.editor,a=this.#z,o=oo({type:this.type,editStateKey:a,owner:this,initialState:r,previousSession:n}),s=o.diffSession;this.#t=void 0,this.#n=o,this.#M=e,this.#I=!0,this.#L=o.editor!=null;try{if(this.#Ge(),e.type===`file`&&t.type===`file`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else if(e.type===`file-diff`&&t.type===`file-diff`)t.#N=e.applyDocumentChange.bind(e),t.#P=e.applySuspendedDocumentChange.bind(e),t.#F=(n,r,i)=>{let a={changes:n,file:r,editor:t,lineAnnotations:i};e.__acceptEditorChange(a),t.#e.onChange?.(a),e.emitEditChange(a)},this.#l==null?this.#l=e.__attachEditor(t):e.__resumeEditor(t);else throw Error(`Editor.edit: Impossible edit state`)}catch(e){throw this.cleanUp(`recycle`),o.type===`file-diff`&&o.diffSession==null&&(o.diffSession=s),this.#l==null&&a!=null&&(t.type===`file`?Qn.releaseFile(a,t):Qn.releaseFileDiff(a,t)),this.#n=n,this.#l??(this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0),r!=null&&i!=null&&(r.editor=i),this.#t=r,e}return()=>{this.cleanUp(`complete`)}}applyEdits(e,t=!0){let n=this.#n?.document;if(n==null)throw Error(`Editor.applyEdits: Editor is not attached`);let r=this.#X,i=this.#se,a=i?.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]),o=i===void 0?void 0:n.resolveEdits(e).sort((e,t)=>e.start-t.start),s=n.applyEdits(e,t,i);if(s===void 0)return;let c;i!==void 0&&a!==void 0&&o!==void 0&&(c=Hr(n,i,a,o),t&&n.setLastUndoSelectionsAfter(c)),this.#dn(s,c,this.#pn(s),{skipFocus:!r})}get canUndo(){return(this.#n??this.#t)?.document?.canUndo??!1}get canRedo(){return(this.#n??this.#t)?.document?.canRedo??!1}undo(){this.#et(`undo`)}redo(){this.#et(`redo`)}getFile(){let e=this.#n??this.#t,t=e?.fileInfo,n=e?.document;if(t===void 0||n===void 0)return;let r={...t};return Object.defineProperty(r,"contents",{enumerable:!0,get:()=>n.getText()}),r}getText(){return(this.#n??this.#t)?.document?.getText()??``}getViewState(){let e=this.#I?this.#M:void 0;if(!this.#I&&this.#n?.editor!=null)return Yn(this.#n.editor);let t=this.#se?.map(e=>({...e,start:{...e.start},end:{...e.end}}));if(e==null)return{selections:t};let n=this.#We(),r=e.getCodeScrollLeft();return n==null?{selections:t,view:{scrollLeft:r}}:{selections:t,view:{scrollLeft:r,scrollTop:n.scrollTop}}}getEditState(){let e=this.#n;if(e!=null){if(this.#M==null)throw Error(`Editor.getEditState: active ${this.type} session has no component`);return Xn(e)}}setViewState({selections:e,view:t}){if(!this.#I||this.#M===void 0||this.#n?.document===void 0)throw Error(`Editor.setViewState: Editor is not attached`);if(this.#q=!1,this.#Wt(e??[]),t!=null){this.#M.setCodeScrollLeft(t.scrollLeft);let e=this.#We();t.scrollTop!==void 0&&e!=null&&(e.scrollTop=t.scrollTop)}else this.#B&&this.#gt();this.#De()}setSelections(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setSelections: Text document is not initialized`);let n=e.map(e=>{let n=t.normalizePosition(e.start),r=t.normalizePosition(e.end),i=e.direction===`none`?0:e.direction===`backward`?-1:1;return Z(n,r)>0&&([n,r]=[r,n],i!==0&&(i=i===1?-1:1)),{direction:i,start:n,end:r}});this.#q=!1,this.#Wt(n);let r=n.at(-1);r!==void 0&&this.#Pe(X(r).line),this.#gt()}setMarkers(e){let t=this.#n?.document;if(t===void 0)throw Error(`Editor.setMarkers: Text document is not initialized`);e.length===0?(this.#U?.cleanup(),this.#U=void 0,this.#Wt(this.#se??[])):(this.#U??=new Pi({popoverManager:this.#Re(),getLineHeight:()=>this.#r.lineHeight,getOverlayElement:()=>this.#E,getGutterWidth:()=>this.#_n(),getCharX:(e,t)=>this.#bn(e,t),getLineY:e=>this.#yn(e),isMouseDown:()=>this.#ee||this.#$}),this.#U.setMarkers(e,t),this.#w!==void 0&&this.#U.listenHover(this.#w),this.#Wt(this.#se??[]),this.#Gt())}focus(e){let t=e?.preventScroll??!1,n=e?.lineNumber;if(n===`first-visible`||typeof n==`number`){let r=this.#n?.document;if(r==null||!this.#I||this.#M==null)return;let i=n===`first-visible`?this.#pt(e?.offset):n;if(i==null)return;let a=r.normalizePosition({line:i-1,character:n===`first-visible`?0:e?.character??0});this.#mt(a,t);return}let r=this.#se?.at(-1);if(r!==void 0){let e=r.direction===-1?r.end:r.start;this.#ut(e,t)}else this.#ut(void 0,t)}blur(){this.#Z=void 0,this.#X=!1,this.#J=!1,this.#w?.blur()}cleanUp(e=`discard`){let t=this.#M,n=e===`recycle`;this.#Rt(!0,!1),n||(this.#Se=[]);let r=this.#n;if(t!=null&&r!=null){let e=!this.#De();n||this.#Oe(e)}if(this.#Ve(),n||(this.#u.delivered=!1),this.#I=!1,Fe(this.#Ze),this.#i?.cleanUp(),this.#i=void 0,this.#s?.forEach(e=>e()),this.#s=void 0,this.#o?.forEach(e=>e()),this.#o=void 0,n||(this.#l?.(),this.#l=void 0),this.#f=void 0,this.#p=void 0,this.#m.clear(),this.#h.clear(),this.#g.clear(),this.#_=void 0,this.#v?.remove(),this.#v=void 0,this.#y?.remove(),this.#y=void 0,this.#b?.remove(),this.#b=void 0,this.#x?.remove(),this.#x=void 0,this.#S=void 0,this.#a?.cleanUp(),this.#a=void 0,this.#C=void 0,this.#T=void 0,this.#w?.removeAttribute(`contentEditable`),this.#w=void 0,this.#Z=void 0,this.#X=!1,this.#E?.remove(),this.#E=void 0,this.#j?.disconnect(),this.#j=void 0,this.#me=!1,this.#he!==void 0&&(cancelAnimationFrame(this.#he),this.#he=void 0),this.#Be(n),!n)try{if(t!=null&&r!=null){let n=this.#Ee,r=e===`complete`?`install`:`discard`;if(t.type===`file`&&n.type===`file`)t.__completeEditSession(n,r);else if(t.type===`file-diff`&&n.type===`file-diff`)t.__completeEditSession(n,r);else throw Error(`Editor.cleanUp: Impossible edit state`)}}finally{this.#n=void 0,this.#M=void 0,this.#N=void 0,this.#P=void 0,this.#F=void 0}}#De(){let e=this.#M,t=this.#n;if(e==null||t==null)return!1;let n=this.#I?this.getViewState():t.editor??{},{view:r}=n,i=r!=null&&(r.scrollLeft!==0||(r.scrollTop??0)!==0),a=n.selections!=null||i;if(t.editor=Yn(n),t.type===`file`)return!1;let o=e.__captureDocumentSessionState();if(o==null)return t.diffSession=void 0,!1;t.diffSession=o.diffSession;let s=t.document;return o.hasChanges||a||s?.canUndo===!0||s?.canRedo===!0}#Oe(e=!1){let t=this.#z;if(t==null)return;let n=this.#Ee;n.type===`file`?Qn.releaseFile(t,n):Qn.releaseFileDiff(t,n,e)}__postponeBgTokenizeToNextFrame(){let e=this.#i;e!==void 0&&(e.pauseBackgroundTokenize(),requestAnimationFrame(()=>{e.resumeBackgroundTokenize()}))}__captureFocusForDOMReplacement(){let e=this.#w,t=this.#S?.shadowRoot?.activeElement;e!=null&&(this.#X||t===e||t!=null&&e.contains(t))&&(this.#Z={})}__getDocumentContents(e){let t=this.#n?.fileInfo,n=this.#n?.document;if(n==null)return t==null||e==null?void 0:{...t,contents:e.contents};let r=t??e;if(r!=null)return{name:r.name,lang:r.lang,contents:n.getText()}}__getDocumentSessionState(){let e=this.#n?.diffSession;return e==null?void 0:Ri(e)}__syncRenderView(e){let{highlighter:t,fileContainer:n,renderRange:r,externalDocument:i=!1}=e,a=e,o;if(`file`in a&&this.type===`file`)o=a.file;else if(`fileDiff`in a&&this.type===`file-diff`)o=a.fileDiff;else throw Error(`Editor.__syncRenderView: Impossible render state`);let s=a.lineAnnotations,c=this.#z,l=this.#M,u=this.#n;if(!this.#I||l==null||u==null)return;let d=n.shadowRoot;if(d==null){console.error(`[editor] Could not find the shadow root.`);return}let f,p,m,h,g;for(let e of d.querySelectorAll(`[data-code]`)){let t=e.dataset.deletions!=null;t||(f=e);for(let n of e.children){if(!(n instanceof HTMLElement))continue;let{gutter:e,content:r}=n.dataset;e==null?r!=null&&(t?g=n:m=n):t?h=n:p=n}}if(g==null)this.#T=void 0;else if(h==null)throw Error(`Editor.__syncRenderView: the deletions column has no gutter`);else this.#T={content:g,gutter:h};if(f===void 0||m===void 0){this.#Z=void 0;return}this.#Re().setViewportElements(n,f),this.#S!==n&&(this.#S=n,this.#v!==void 0&&n.appendChild(this.#v),this.#y!==void 0&&d.appendChild(this.#y),this.#b!==void 0&&d.appendChild(this.#b),this.#x!==void 0&&d.prepend(this.#x));let _=o.lang??yn(o.name),v=`contents`in o?o.contents:o.additionLines.join(``),y=u.document,b=e.resetHistory??(y!=null&&u.fileInfo!=null&&(u.fileInfo.name!==o.name||y.languageId!==_)),x=i&&y!==void 0&&y.getText()!==v?[Ya(y.getText(),v)]:void 0,S=i&&b;if(u.document==null||u.fileInfo==null||c==null&&(u.fileInfo.name!==o.name||u.document.languageId!==_)||S){this.#Rt(!0),this.#Se=[],this.#Ve();let{name:e,lang:t}=o,n=S||c==null&&u.fileInfo!=null?void 0:u.document;if(y!=null&&n==null&&(u.editor=void 0),n==null){let e=new Mn({maxEntries:this.#e.historyMaxEntries});n=new Wn(o.name,v,_,0,e)}u.fileInfo={name:e,lang:t},u.document=n,S&&(u.diffSession=void 0),this.#i?.cleanUp(),this.#i=void 0,this.#Be(),this.#h.clear(),this.#se=this.#oe,this.#e.__debug===!0&&console.log(`[diffs/editor] text document initialized from`,o.name)}if(i&&!S){this.#ke(u,v,s);let{name:e,lang:t}=o;u.fileInfo={name:e,lang:t}}let C=u.document;if(this.#i==null&&C!=null&&(this.#i=new Wa({highlighter:t,textDocument:C,codeOptions:this.#M?.__getEffectiveCodeOptions()??{},matchBrackets:this.#e.matchBrackets,onDeferTokenize:this.#Te,onThemeChange:()=>this.#Ot(),setStyle:e=>{this.#b.textContent=e},__debug:this.#e.__debug})),this.#w!==m&&(this.#C=p,this.#w=it(m,{contentEditable:`true`,role:`textbox`,ariaMultiLine:`true`,autocapitalize:`off`,writingSuggestions:`off`,autocorrect:!1,spellcheck:!1,translate:!1}),this.#E!==void 0&&m.after(this.#E),this.#r.init(m),this.#st(),this.#Xe(m,p),this.#w!==void 0&&this.#e.__debug===!0&&console.log(`[diffs/editor] full re-render triggered !!!`)),this.#Z!=null&&(this.#Z.target=m),m.ariaLabel!==o.name&&(m.ariaLabel=o.name),s!==void 0&&s.length>0||this.#Ie)for(let e of this.#w.children){let t=e,{lineAnnotation:n,lineType:r,separator:i}=t.dataset;(n!==void 0||i!==void 0||r===`change-deletion`)&&t.setAttribute(`contenteditable`,`false`)}this.#ze(),this.#i?.syncTheme(this.#M?.__getEffectiveCodeOptions()??{}),this.#R=s,this.#V=r,this.#H=r?.totalLines,this.#i?.prebuildStateStack(r);let w=u.editor,T=this.#L;try{if(this.#U?.removePopover(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#be&&this.#Bt(),this.#oe!==void 0&&this.#A!==void 0?(this.#oe=void 0,this.#gt(!1,`center`)):this.#le===void 0?this.#Z===void 0?this.#se!==void 0&&this.#se.length>0&&this.#X&&!this.#pe&&this.focus({preventScroll:!0}):this.#dt():this.#vt(this.#le,this.#ue,this.#fe),this.#pe&&this.#G?.focus(),T&&(this.#L=!1,w!==void 0&&this.setViewState(w)),this.#e.__debug===!0&&r!==void 0){let{startingLine:e,totalLines:t}=r;console.log(`[diffs/editor] render file:`,o.name,`RenderRange:`,e+`-`+(e+t),`of`,u.document?.lineCount,`lines`)}i&&l.__acknowledgeDocumentUpdate(),this.#De()}catch(e){throw this.#L=T,u.editor=w,e}x!=null&&this.#fn(x,s),this.#He(l)}#ke(e,t,n){let r=e.document;if(r==null||r.getText()===t)return;let i=this.#se,a=i?.map(e=>[r.offsetAt(e.start),r.offsetAt(e.end)]),o={start:0,end:r.getText().length,text:t};if(r.applyResolvedEdits([o],!0,i,void 0,!0)!=null){if(i!=null&&a!=null){let e=Hr(r,i,a,[o]);r.setLastUndoSelectionsAfter(e),this.#se=e}(this.#R!=null||n!=null)&&r.setLastUndoLineAnnotations(this.#R??[],n??[]),this.#i?.cleanUp(),this.#i=void 0,this.#ze(),this.#h.clear(),this.#U?.removePopover(),this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1})}}get#Ae(){return this.#M?.type===`file-diff`?this.#M:void 0}get#je(){return Xa(this.#M)?this.#M:void 0}#Me(e){return this.#Ae?.isLineRenderable?.(e+1)??!0}get#Ne(){let e=this.#Ae;if(e!=null)return(t,n)=>{let r=e.getNearestRenderableLine(t+1,n);return r==null?void 0:r-1}}#Pe(e){this.#Me(e)||this.#Ae?.revealLine?.(e+1)}get#Fe(){return this.#Ae?.options.diffStyle??`split`}get#Ie(){return this.type===`file-diff`}get#Le(){return this.#M?.options.overflow===`wrap`}#Re(){return this.#a??=new $n({hasActivePopover:()=>this.#K!==void 0||this.#U?.isPopoverVisible()===!0,updateActivePopover:()=>{this.#Zt(),this.#U?.updatePopoverPosition()}})}#ze(){this.#m.clear(),this.#g.clear(),this.#_=void 0}#Be(e=!1){this.#Dt(null),this.#f=void 0,this.#p=void 0,this.#Ke(),this.#Y=!1,this.#D?.forEach(e=>e.remove()),this.#D=void 0,this.#O?.forEach(e=>e.remove()),this.#O=void 0,this.#k?.forEach(e=>e.remove()),this.#k=void 0,e||(this.#W=void 0),this.#se=void 0,this.#le=void 0,this.#U?.cleanup(),this.#U=void 0,this.#G?.cleanup(),this.#G=void 0,this.#K?.cleanup(),this.#K=void 0,this.#q=!0}#Ve(){let e=this.#u;e.generation++,e.callback!=null&&(Fe(e.callback),e.callback=void 0)}#He(e){let t=this.#u,n=this.#n?.document;if(t.delivered||t.callback!=null||n==null)return;let{generation:r}=t,i=()=>{if(t.callback!==i||(t.callback=void 0,r!==t.generation||this.#M!==e||this.#n?.document!==n))return;let a=this.#w,o=this.#S?.shadowRoot;a!=null&&o!=null&&o.contains(a)&&(t.delivered=!0,this.#e.onAttach?.(this,e))};t.callback=i,R(i)}#Ue(){let e=this.#je?.getEditorViewport?.();if(e!=null)return e;let t=this.#S;if(this.#M!=null&&t!=null)return at(t)}#We(){if(!this.#B)return;let e=this.#je?.getEditorViewport?.();if(e instanceof HTMLElement)return e}#Ge(){this.#v=W(`style`,{dataset:`editorGlobalCss`,textContent:`
24
24
  [data-annotation-slot] {
25
25
  user-select: none;
26
26
  -webkit-user-select: none;
@@ -28,7 +28,7 @@ import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJe
28
28
  `}),this.#y=W(`style`,{dataset:`editorCss`,textContent:ut}),this.#b=W(`style`,{dataset:`editorThemeCss`}),this.#x=ct(),this.#E=W(`div`,{dataset:`editorOverlay`});let e=e=>{let t=e.composedPath()[0];return t instanceof Node&&this.#w?.contains(t)===!0},t=()=>{this.#Z!=null&&(this.#Z=void 0,this.#X=!1,this.#J=!1)},n=e=>{if(e.pointerType!==`mouse`)return;let t=this.#$;this.#Ke(),t&&this.#ut(),this.#e.enabledSelectionAction===!0&&this.#se!==void 0&&this.#se.length>0&&!Y(this.#se.at(-1))&&this.#Wt(this.#se)};this.#s=[K(document,`focusin`,n=>{e(n)||t()},{passive:!0}),K(document,`pointerdown`,n=>{e(n)||queueMicrotask(t)},{capture:!0,passive:!0}),K(document,`selectionchange`,()=>{let e=this.#S?.shadowRoot;if(this.#J||this.#Y||e==null||!this.#X||this.#se!==void 0&&this.#se.length>1&&!this.#ee)return;let t=document.getSelection();if(t==null)return;let n;if(n=typeof t.getComposedRanges==`function`?t.getComposedRanges({shadowRoots:[e]})?.[0]:Ja(e),n===void 0||!this.#Cn(n))return;let r=_r(n,0);if(r!==void 0){if(this.#ee&&this.#ne&&this.#se!==void 0&&this.#se.length>0){let e=this.#se.at(-1);this.#Wt([Wr(e,r)])}else{if(this.#re!==void 0)r.direction=Ur(this.#re,r).direction;else if(this.#ee)this.#re=r;else if(this.#se!==void 0&&this.#se.length===1){let e=this.#se[0];Z(e.start,r.start)===0&&Z(e.end,r.end)===0&&(r.direction=e.direction)}this.#te!==void 0&&(this.#te.focusLine=X(r).line,this.#kt())||(this.#ae===void 0?this.#Wt([r]):this.#Wt([...this.#ae.filter(e=>!zr(e,r)),r]))}}},{passive:!0}),K(document,`pointerup`,n,{passive:!0}),K(document,`pointercancel`,n,{passive:!0}),K(document,`keydown`,e=>{e.key===`Shift`?this.#re=this.#se?.at(-1):e.key===`Alt`&&!e.repeat&&this.#X&&this.#e.editPrediction?.mode===`subtle`&&(this.#ye=!this.#ye,this.#Wt(this.#se??[]))},{passive:!0}),K(document,`keyup`,e=>{e.key===`Shift`&&(this.#re=void 0)},{passive:!0})]}#Ke(){this.#c?.forEach(e=>e()),this.#c=void 0,this.#J=!1,this.#$=!1,this.#ee=!1,this.#te=void 0,this.#ne=!1,this.#re=void 0,this.#ae=void 0}#qe(e){this.#c?.forEach(e=>e()),this.#c=e}#Je(){return this.#M?.options.enableLineSelection===!0}#Ye(){this.#Y=this.#se!==void 0}#Xe(e,t){let{onFocus:n,onBlur:r}=this.#e,i=t=>{let n=t.composedPath()[0];return n!==void 0&&(n===e||e.contains(n))};this.#o?.forEach(e=>e()),this.#o=[K(e,`focus`,()=>{this.#X=!0,n?.(),!this.#ee&&!this.#J&&this.#se!==void 0&&this.#se.length>0&&this.#ht(this.#se.at(-1))},{passive:!0}),K(e,`blur`,()=>{this.#Z?.target===e&&(this.#Z=void 0,this.#J=!1),this.#X=!1,r?.()},{passive:!0}),K(e,`pointerdown`,t=>{if(this.#q=!0,this.#Y=!1,t.pointerType!==`mouse`)return;if(this.#te=void 0,this.#bt(t)){this.#Et(!0),this.#se!==void 0&&this.#Wt([]);return}this.#Et(!1),this.#U?.removePopover();let n=[];if(Ie()&&this.#R!==void 0&&this.#R.length>0){let t=[...e.querySelectorAll(`[data-line-annotation]`)].map(e=>[K(e,`mouseenter`,()=>{this.#J=!0}),K(e,`mouseleave`,()=>{this.#J=!1})]).flat();n.push(...t)}this.#ee=!0;let r=t.button===0&&t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(this.#re=void 0,r?(this.#te={pointerId:t.pointerId,startClientX:t.clientX,clientX:t.clientX,startScrollLeft:e.parentElement?.scrollLeft??0},this.#ae=void 0,this.#se=void 0,this.#Wt([]),n.push(K(document,`pointermove`,e=>{let t=this.#te;t!==void 0&&e.pointerType===`mouse`&&e.pointerId===t.pointerId&&(t.clientX=e.clientX,this.#kt())},{capture:!0,passive:!0}))):t.button===0&&$e(t)&&(this.#ae=this.#se?.map(e=>({...e}))),this.#qe(n),t.shiftKey){let e=this.#se?.at(-1);if(e!==void 0){let t=e.direction===-1?e.end:e.start;this.#ht({start:t,end:t,direction:0})}this.#ne=!0}},{passive:!0}),K(e,`keydown`,e=>{if(!i(e)||(this.#q=!0,this.#Y=!1,e.isComposing||e.keyCode===229))return;if(e.key===`Tab`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing&&!this.#Q&&(!e.altKey||this.#e.editPrediction?.mode===`subtle`)&&this.#xe?.rendered===!0){this.#Ht(),e.preventDefault();return}if(e.key===`Escape`&&this.#xe!==void 0){this.#Rt(!0),e.preventDefault();return}let t=ht(e,this.#e.keymap);if(t!==void 0){e.preventDefault(),t===`simplifySelection`&&(this.#G?.close(),this.#G=void 0,this.#pe=!1,this.#K?.cleanup(),this.#K=void 0),this.#et(t);return}let n=mt(e),r=this.#n?.document;if(this.#se!==void 0&&this.#se.length>0&&n!==void 0&&r!==void 0){let t={getSoftLineOffsets:this.#Le?e=>this.#Sn(e):void 0,resolveRenderableLine:this.#Ne};e.shiftKey?this.#Wt(Tr(r,this.#se,n,t)):this.#Wt(yr(r,this.#se,n,t)),this.#gt(),e.preventDefault()}else{if((e.key.length===1?e.key.toLowerCase():e.key)===`v`&&$e(e)){if(e.repeat&&this.#Ie){e.preventDefault();return}if(this.#e.clipboard!==void 0){e.preventDefault(),R(this.#Ze);return}}if(this.#G!==void 0){let t=tt(e);if(t!==void 0){e.preventDefault(),this.#G.navigate(t===`previous`);return}}}}),K(e,`copy`,e=>{i(e)&&(e.preventDefault(),this.#wt()?e.clipboardData?.setData(`text`,this.#Tt()):this.#nn(e.clipboardData,this.#en(),this.#tn()))}),K(e,`cut`,e=>{if(i(e)){if(e.preventDefault(),this.#wt())e.clipboardData?.setData(`text`,this.#Tt());else{let t=this.#tn();this.#nn(e.clipboardData,this.#rn(),t)}}}),K(e,`paste`,e=>{if(!i(e))return;e.preventDefault();let t=e.clipboardData,n=this.#n?.document;if(t===null||n===void 0)return;let r=t.getData(`text`),a=this.#se?.length??0;if(a>1){let e=t.getData(io);if(e!==void 0)try{let t=JSON.parse(e);Array.isArray(t)&&t.length===a&&(r=t)}catch{}}this.#an(Array.isArray(r)?r.map(e=>n.normalizeEol(e)):n.normalizeEol(r),void 0,!0,`document`)}),K(e,`beforeinput`,e=>{i(e)&&(e.inputType===`insertCompositionText`?this.#Rt(!0):(e.preventDefault(),this.#lt(e.inputType,e.data)))}),K(e,`drop`,e=>{i(e)&&e.preventDefault()}),K(e,`compositionstart`,e=>{i(e)&&(this.#Rt(!0),this.#Q=!0,this.#J=!0)},{passive:!0}),K(e,`compositionend`,e=>{if(!i(e))return;this.#J=!1;let t=this.#Q;this.#Q=!1,e.data===``&&t||this.#lt(`insertText`,e.data)},{passive:!0})];let a=this.#S?.shadowRoot?.querySelector(`[data-deletions]`);if(a!=null&&this.#o.push(K(a,`pointerdown`,e=>{let t=e.composedPath();if(Pe(t)){this.#Ye();return}let n=t[0],r=n instanceof HTMLElement?n.closest(`[data-column-number]`):null;if(r instanceof HTMLElement){if(this.#Je()){this.#Ye();return}if(this.#Ct(r,a,e.pointerType===`mouse`))return}this.#Et(!0),this.#se!==void 0&&this.#Wt([])},{passive:!0})),t!==void 0){let e=(e,t=!1)=>{let n=e;return n?.dataset.lineNumberContent===void 0?t&&n?.tagName===`SPAN`&&(n=n.closest(`[data-line]`)):n=n.parentElement??void 0,n},n=e=>{if(e===void 0)return;let t=e.dataset.lineType,n=G(e)??G(e,`columnNumber`);if(n!==void 0&&t!==void 0&&Rr(t))return n-1};this.#o.push(K(t,`pointerdown`,t=>{let r=t.composedPath();if(Pe(r)){this.#Ye();return}let i=e(r[0]);if(i!==void 0&&this.#Je()){this.#Ye();return}if(i?.dataset.lineType===`change-deletion`){let e=i.closest(`[data-code]`);e!=null&&this.#Ct(i,e,t.pointerType===`mouse`);return}if(t.pointerType!==`mouse`)return;let a=this.#n?.document,o=n(i);if(o===void 0||a===void 0)return;this.#q=!0,this.#U?.removePopover();let s=this.#yt(o,o,a);this.#$=!0,this.#re=s,this.#Wt([s]),this.#ht(s),this.#ut(),this.#qe([K(document,`mousemove`,t=>{if(!this.#$)return;let r=this.#n?.document,i=n(e(t.composedPath()[0],!0));if(i===void 0||r===void 0)return;let a=this.#re?.start.line??i,o=this.#yt(a,i,r);this.#re??=o,this.#Wt([o]),this.#ut(o.direction===-1?o.start:o.end)},{passive:!0})])},{passive:!0}))}this.#U?.listenHover(e),this.#j?.disconnect(),this.#j=new ResizeObserver(this.#ot),this.#j.observe(e),this.#j.observe(e.parentElement),this.#Qe(e)}#Ze=async()=>{let e=this.#e.clipboard;if(e!==void 0){let t=await e.readText(),n=this.#se?.length??0;if(n>1){let r=await e.readText(io);try{let e=JSON.parse(r);Array.isArray(e)&&e.length===n&&(t=e)}catch{}}let r=this.#n?.document;r!=null&&this.#an(Array.isArray(t)?t.map(e=>r.normalizeEol(e)):r.normalizeEol(t),void 0,!0,`document`)}};#Qe(e){this.#Ie&&this.#Fe===`split`&&this.#Le&&(this.#d={top:e.offsetTop-this.#r.paddingTop,left:e.offsetLeft-this.#_n()},this.#e.__debug===!0&&console.log(`[diffs/editor] content offset:`,this.#d))}get#$e(){if(this.#Ie&&this.#Fe===`split`&&this.#Le)return this.#d}#et(e){let t=this.#n?.document;if(t!=null)switch(e){case`openSearchPanel`:this.#Qt(`find`);break;case`openSearchReplacePanel`:this.#Qt(`replace`);break;case`findNextMatch`:{let e=this.#se;if(e===void 0)break;if(e.some(Y)){let n=e.map(e=>Y(e)?ci(t,e):e);this.#Wt(n),this.focus()}else{let n=Yr(t,e);if(n!==void 0){this.#Wt(n);let e=n.at(-1);e!==void 0&&this.#Pe(X(e).line),this.#gt()}}break}case`moveLineUp`:case`moveLineDown`:this.#at(e===`moveLineUp`?-1:1);break;case`copyLineUp`:case`copyLineDown`:this.#rt(e===`copyLineUp`?-1:1);break;case`simplifySelection`:{let e=this.#se,t=e?.at(-1);if(e===void 0||t===void 0)break;if(e.length>1)this.#Wt([t]),this.#ut(X(t));else if(!Y(t)){let e=X(t);this.#Wt([{start:e,end:e,direction:0}]),this.#ut(e)}break}case`insertBlankLine`:this.#it();break;case`deleteHardLineForward`:this.#ln();break;case`toggleComment`:case`toggleBlockComment`:{let n=this.#se;if(n===void 0)break;let{lineComment:r,blockComment:i}=fa(t.languageId,this.#e.languageCommentConfig);if(e===`toggleComment`&&r!==null){this.#nt(pa(t,n,r));break}let a=e===`toggleComment`,o=_a(t,n,i,a);o!==void 0&&this.#nt(o.edits,a?void 0:e=>o.nextSelectionOffsets.map(([t,n,r])=>({start:e.positionAt(t),end:e.positionAt(n),direction:r})));break}case`indent`:case`outdent`:case`indentLess`:case`indentMore`:if(this.#se!==void 0){let n=[],r=[],i=new Set,a=[];for(let o of this.#se){let s=o.start.line,c=e===`outdent`||e===`indentLess`,l=e===`indentLess`||e===`indentMore`;if(s!==o.end.line||c||l){let e=vr(t,o,this.#r.tabSize,c);for(let t of e[0]){let e=t.range.start.line;i.has(e)||(i.add(e),n.push(t))}r.push(e[1])}else{let e=t.charAt({line:s,character:0})===` `?` `:` `.repeat(this.#r.tabSize);n.push({range:o,newText:e}),a.push({line:s,startCharacter:o.start.character,addedLength:e.length-(o.end.character-o.start.character),selectionIndex:r.length});let i={line:o.start.line,character:o.start.character+e.length};r.push({start:i,end:i,direction:0})}}for(let e of a){let t=0;for(let n of a)n.line===e.line&&n.startCharacter<e.startCharacter&&(t+=n.addedLength);if(t!==0){let n=r[e.selectionIndex],i={line:e.line,character:n.start.character+t};r[e.selectionIndex]={start:i,end:i,direction:0}}}let o=t.applyEdits(n,!0,this.#se,r);o!==void 0&&this.#dn(o,r)}break;case`selectAll`:{let e=Xr(t);this.#Wt([e]),this.focus();let n=this.#mn(),r=n[0]?.[0],i=n.at(-1)?.[1];r!==void 0&&i!==void 0&&(this.#Y=!0,this.#ht({start:{line:r,character:0},end:{line:i,character:t.getLineLength(i)},direction:1}));break}case`moveCursorToDocStart`:case`moveCursorToDocEnd`:{let n=Zr(t,e===`moveCursorToDocEnd`,this.#Ie);this.#Wt([n]),this.#Pe(X(n).line),this.#gt()}break;case`expandSelectionDocStart`:case`expandSelectionDocEnd`:{let n=e===`expandSelectionDocEnd`,r=this.#se;if(r!==void 0){let e=Zr(t,n,this.#Ie);this.#Wt(Gr(r,e)),this.#Pe(X(e).line),this.#gt()}}break;case`undo`:case`redo`:this.#tt(e)}}#tt(e){let t=this.#n?.document;if(t==null||e===`undo`&&!t.canUndo||e===`redo`&&!t.canRedo)return;let n=this.#se,r=n?.map(e=>[t.offsetAt(e.start),t.offsetAt(e.end)]),i=e===`undo`?t.undo():t.redo();if(i===void 0)return;let[a,o,s,c]=i,l=o??(n!==void 0&&r!==void 0&&c!==void 0?Hr(t,n,r,c):void 0),u=s??(this.#R==null?void 0:nr(a,this.#R));this.#dn(a,l,u)}#nt(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0)return;let i=t===void 0,a=i?r.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]):void 0,o=i?e.map(e=>{let t=n.offsetAt(e.range.start),r=n.offsetAt(e.range.end);return{start:Math.min(t,r),end:Math.max(t,r),text:e.newText}}).sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n}):void 0,s=n.applyEdits(e,!0,r,void 0,!0);if(s===void 0)return;let c=i?Hr(n,r,a,o):t(n);n.setLastUndoSelectionsAfter(c),this.#dn(s,c,this.#pn(s))}#rt(e){let t=this.#n?.document,n=this.#se;if(t===void 0||n===void 0)return;let r=qr(n);if(r.length===0)return;let i=[],a=0,o=[];for(let n of r){i.push(a);let r=n.endLine-n.startLine+1;a+=r;let s=t.getText({start:{line:n.startLine,character:0},end:{line:n.endLine,character:t.getLineLength(n.endLine)}});if(e>0){let e={line:n.startLine,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else if(n.endLine<t.lineCount-1){let e={line:n.endLine+1,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else{let e={line:n.endLine,character:t.getLineLength(n.endLine)};o.push({range:{start:e,end:e},newText:t.eol+s})}}let s=n.map(t=>{let n=t.start.line,a=0,o=r.length-1;for(;a<=o;){let e=a+o>>>1,t=r[e];if(n<t.startLine)o=e-1;else if(n>t.endLine)a=e+1;else{a=e;break}}let s=Math.max(0,a<=o?a:o),c=r[s],l=i[s]+(e>0?c.endLine-c.startLine+1:0);return{start:{...t.start,line:t.start.line+l},end:{...t.end,line:t.end.line+l},direction:t.direction}});this.#nt(o,()=>s)}#it(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0)return;let n=t.map(e=>X(e).line),r=Array.from(new Set(n)).sort((e,t)=>e-t),i=new Map,a=new Map,o=[];for(let t=0;t<r.length;t++){let n=r[t],s=e.getLineText(n),c=/^\s*/.exec(s)?.[0]??``;i.set(n,t),a.set(n,c);let l={line:n,character:e.getLineLength(n)};o.push({range:{start:l,end:l},newText:e.eol+c})}let s=t.map((e,t)=>{let r=n[t],o={line:r+1+i.get(r),character:a.get(r).length};return{start:o,end:o,direction:0}});this.#nt(o,()=>s)}#at(e){let t=this.#n?.document,n=this.#se;if(t===void 0||n===void 0)return;let r=qr(n);if(r.length===0||e<0&&r[0].startLine===0||e>0&&r.at(-1).endLine>=t.lineCount-1)return;let i=t.lineCount,a=e=>e<i-1?{line:e+1,character:0}:{line:e,character:t.getLineLength(e)},o=(e,n)=>{let r=e.map(e=>t.getLineText(e)).join(t.eol);return n?r+t.eol:r},s=[];if(e<0)for(let e of r){let t=e.startLine-1,n=[];for(let t=e.startLine;t<=e.endLine;t++)n.push(t);s.push({range:{start:{line:t,character:0},end:a(e.endLine)},newText:o([...n,t],e.endLine<i-1)})}else for(let e=r.length-1;e>=0;e--){let t=r[e],n=t.endLine+1,c=[];for(let e=t.startLine;e<=t.endLine;e++)c.push(e);s.push({range:{start:{line:t.startLine,character:0},end:a(n)},newText:o([n,...c],n<i-1)})}let c=r.at(-1),l=e>0&&c.endLine===i-2?t.getLineLength(c.endLine):t.getLineLength(i-1),u=n.map(n=>Jr(n,e,i,e=>e===i-1?l:t.getLineLength(e))),d=t.applyEdits(s,!0,n,u,!0);d!==void 0&&this.#dn(d,u)}#ot=()=>{let e=this.#R?.length??0,t=this.#f,n=this.#p;this.#f=void 0,this.#p=void 0;let r=this.#_n()!==t,i=this.#vn()!==n;(r||i)&&(this.#g.clear(),this.#_=void 0,this.#r.clearTextWidthCache(),i&&(this.#h.clear(),(this.#Le||e>0)&&this.#m.clear()),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&(this.#Wt(this.#se??[]),this.#se!==void 0&&this.#X&&this.focus()),this.#U?.removePopover(),this.#Qe(this.#w),this.#Gt())};#st(){if(this.#me)return;let e=document.fonts;e!==void 0&&(this.#me=!0,e.ready.then(()=>{this.#w!==void 0&&this.#r.remeasureCharacterWidth()&&(this.#f=void 0,this.#p=void 0,this.#ze(),this.#h.clear(),(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[]),this.#Gt(),this.#U?.removePopover())}))}#ct(e,t,n=this.#V,r){let i=this.#i,a=this.#M,o=this.#N,s=this.#n?.document,c=this.#C,l=this.#w;if(i==null||a==null||o==null||s==null||l==null)return;i.stopBackgroundTokenize();let u=performance.now(),d=i.tokenize(e,n,!this.#Ie&&this.#je!=null),f=performance.now();if(d.size>0){let e=l.children,t=new Set;for(let e of d.keys())this.#Me(e)&&t.add(e);for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=G(r),n=r.dataset.lineType;if(e===void 0||n===`change-deletion`)continue;let i=e-1;if(t.has(i)){let e=d.get(i);if(r.replaceChildren(...Ka(e)),t.delete(i),t.size===0)break}}}if(t.size>0){let n=0;for(let t=e.length-1;t>=0;t--){let r=e[t],i=G(r);if(i!==void 0&&r.dataset.lineType!==`change-deletion`){n=i;break}}for(let e of t){if(e<n)continue;let t=d.get(e),r=String(e+1);W(`div`,{dataset:{line:r,lineType:`context`,lineIndex:e.toString()},children:Ka(t)},l),c!==void 0&&W(`div`,{dataset:{lineType:`context`,columnNumber:r,lineIndex:e.toString()},children:[W(`span`,{dataset:{lineNumberContent:``},textContent:r})]},c)}}}if(e.lineDelta<0)for(let t of[l.children,c?.children??[]])for(let n=t.length-1;n>=0;n--){let r=t[n],i=G(r)??G(r,`columnNumber`),a=r.dataset.lineType;if(i!==void 0&&a!==`change-deletion`){if(i-1<e.lineCount)break;r.remove()}}let p=e.lineDelta!==0;if(p){let e=l.children.length;for(let t of l.children){let{bufferSize:n}=t.dataset;n!==void 0&&(e+=parseInt(n)-1)}l.style.gridRow=`span `+e,c!==void 0&&(c.style.gridRow=`span `+e)}a.updateRenderCache(d,i.themeType,{shouldRefreshDiffsView:this.#Ie&&!p,lineCountChangeInFlight:p,changedDocumentLines:this.#Ie&&!p?ca(s,e):void 0,documentLineCount:s.lineCount}),p&&o(s,t,r,String(e.previousLineCount).length===String(e.lineCount).length?e.startLine:0),(p||this.#Ie&&this.#Fe===`unified`)&&this.#ze(),t!=null&&(this.#R=t,this.#Ie&&p||cr(t,l,c,a.getAnnotationSlotName)),this.#Gt(),this.#e.__debug===!0&&console.log(`[diffs/editor] re-render in: ${et(performance.now()-f)}ms,`,`tokenize in: ${et(f-u)}ms (${d.size} dirty lines)`)}#lt(e,t){switch(e){case`insertText`:{let e=t??``,n=this.#n?.document,r=this.#se,i=n!==void 0&&r!==void 0?jr(n,r,e,this.#e.autoSurround):void 0;this.#an(i??e);break}case`insertCompositionText`:break;case`insertLineBreak`:case`insertParagraph`:this.#an(this.#n?.document?.eol??`
29
29
  `);break;case`deleteContentBackward`:this.#on();break;case`deleteContentForward`:this.#on(!0);break;case`deleteSoftLineBackward`:case`deleteHardLineBackward`:this.#sn();break;case`deleteWordBackward`:this.#cn();break;case`insertTranspose`:this.#un();break;default:console.warn(`[diffs] Unknown input type: ${e}`,t)}}#ut(e,t=!0,n){this.#X=!0,e===void 0?n?.()===!1?this.#X=!1:this.#w?.focus({preventScroll:t}):(this.#J=!0,this.#ht({start:e,end:e,direction:0}),R(()=>{n?.()===!1||!this.#X?this.#J=!1:(this.#w?.focus({preventScroll:t}),R(()=>{this.#J=!1}))}))}#dt(e){let t=this.#Z;if(t==null)return;if(this.#pe){this.#Z=void 0,this.#X=!1,this.#J=!1;return}let n=this.#w;if(n==null||!this.#ft(n)){this.#Z=void 0,this.#X=!1;return}let r=()=>{if(this.#Z!==t)return!1;let e=this.#ft(n);return this.#Z=void 0,e};if(e!=null){this.#ut(e,!0,r);return}let i=this.#se?.at(-1);if(i==null){this.#ut(void 0,!0,r);return}let a=i.direction===-1?i.end:i.start;this.#ut(a,!0,r)}#ft(e){let t=this.#S,n=t?.shadowRoot;if(t==null||n==null||this.#w!==e||!n.contains(e))return!1;let{activeElement:r}=n;if(r===e||r!=null&&e.contains(r))return!0;if(r!=null)return!1;let{ownerDocument:i}=t,{activeElement:a}=i;return a==null||a===i.body||a===i.documentElement||a===t}#pt(e=0){let t=this.#w,n=this.#S;if(this.#n?.document==null||t==null||n==null)return;let r=this.#Ue();if(r===void 0)return;let i,a;if(r instanceof HTMLElement){let e=r.getBoundingClientRect();i=e.top,a=e.bottom}else i=0,a=r.defaultView?.innerHeight??0;let o=n.shadowRoot?.querySelector(`[data-diffs-header][data-sticky]`);if(o!=null&&(i=Math.max(i,o.getBoundingClientRect().bottom)),Number.isFinite(e)&&(i+=Math.max(0,e)),!(a<=i))for(let e of t.children){let t=e,n=G(t),r=t.dataset.lineType;if(n==null||r==null||!Rr(r))continue;let o=t.getBoundingClientRect();if(!(o.bottom<=o.top)&&o.top>=i&&o.top<a)return n}}#mt(e,t){let n={start:e,end:e,direction:0};this.#q=!1,this.#Wt([n]),this.#Pe(e.line),t?this.#ut(e,!0):this.#gt()}#ht(e){let t=window.getSelection();if(t===null)return;let{start:n,end:r,direction:i}=e;Z(n,r)>0&&([n,r]=[r,n]);let a=this.#gn(n.line),o=this.#gn(r.line);if(a===void 0||o===void 0)return;let[s,c]=si(a,n.character),[l,u]=si(o,r.character);i===-1&&([s,c,l,u]=[l,u,s,c]);try{t.setBaseAndExtent(s,nt(s,c),l,nt(l,u))}catch(e){console.error(`[diffs/editor] failed to update window selection:`,e)}}#gt(e=!1,t=`nearest`){let n=this.#se?.at(-1);if(n===void 0)return;let r=this.#A;if(r!==void 0){if(r.scrollIntoView({block:t,inline:`nearest`}),!e){let e=n.direction===-1?n.end:n.start;this.#Z===void 0?this.#ut(e):this.#dt(e)}}else{let t=X(n);this.#vt(t.line,t.character,e)}}#_t(){let e=this.#G===void 0?0:48,t=this.#_n()+this.#r.ch;return`${e}px ${this.#r.ch}px 0 ${t}px`}#vt(e,t=0,n=!1){this.__postponeBgTokenizeToNextFrame();let r=W(`div`,{style:{position:`absolute`,left:`0`,width:`2px`,height:this.#r.lineHeight+`px`,scrollMargin:this.#_t()}});if(this.#gn(e)!==void 0){let[i,a]=this.#bn(e,t),o=this.#yn(e)+a*this.#r.lineHeight;if(r.style.top=o+`px`,r.style.left=i+`px`,this.#E?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),!n){let n={line:e,character:t};this.#Z===void 0?this.#ut(n):this.#dt(n)}this.#le=void 0,this.#ue=void 0,this.#de=!1,this.#fe=!1}else{let i=this.#je?.getLinePosition?.(e+1);if(i!==void 0)r.style.top=i.top+`px`,this.#S?.shadowRoot?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),i.height>0&&this.#Me(e)?(this.#le=e,this.#ue=t,this.#fe=n):(this.#le=void 0,this.#ue=void 0,this.#fe=!1);else{let i=0;if(this.#le===e&&this.#w!==void 0)for(let t=this.#w.childElementCount-1;t>=0;t--){let n=this.#w.children[t],r=n.dataset.lineType,a=G(n);if(r!==void 0&&Rr(r)&&a!==void 0){i=(e-(a-1))*this.#r.lineHeight;break}}let a=((this.#R??[]).filter(t=>t.lineNumber<e).length+e)*this.#r.lineHeight+i;r.style.top=a+`px`,this.#S?.shadowRoot?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),this.#le===e&&(i===0||this.#de)||!this.#Me(e)?(this.#le=void 0,this.#ue=void 0,this.#de=!1,this.#fe=!1):(this.#le=e,this.#ue=t,this.#de=i!==0,this.#fe=n)}}r.remove()}#yt(e,t,n){let r=e=>({line:e,character:0}),i=e=>({line:e,character:n.getLineText(e).length});return t<e?{start:r(t),end:i(e),direction:-1}:{start:r(e),end:i(t),direction:1}}#bt(e){let t=e.composedPath()[0];return t instanceof HTMLElement&&t.closest(`[data-line]`)?.getAttribute(`data-line-type`)===`change-deletion`}#xt(e,t,n){let r=[...n.querySelectorAll(`[data-content] > [data-line]`)],i=r.indexOf(e),a=r.indexOf(t),[o,s]=a<i?[t,e]:[e,t],c=window.getSelection();if(c!==null){let e=document.createRange();e.setStart(o,0),e.setEnd(s,s.childNodes.length),c.removeAllRanges(),c.addRange(e)}this.#Et(!0),this.#Wt([]),this.#Dt(G(t)??null,!0,`deletions`);let l=Math.min(i,a),u=Math.max(i,a);this.#ie=l<0?``:r.slice(l,u+1).filter(e=>e.getAttribute(`data-line-type`)===`change-deletion`).map(e=>e.textContent??``).join(`
30
30
  `)}#St(e,t){let n=e.parentElement;if(n==null||t==null)return;let r=[...n.children].indexOf(e),i=t.children[r];return i instanceof HTMLElement?i:void 0}#Ct(e,t,n){let r=t.querySelector(`[data-content]`),i=this.#St(e,r);return i!==void 0&&(this.#xt(i,i,t),n&&this.#qe([K(document,`mousemove`,e=>{let n=e.composedPath()[0],a=n instanceof HTMLElement?n.closest(`[data-column-number]`):null;if(a instanceof HTMLElement&&t.contains(a)){let e=this.#St(a,r);e!==void 0&&this.#xt(i,e,t)}},{passive:!0})]),!0)}#wt(){return this.#S?.shadowRoot?.querySelector(`pre`)?.hasAttribute(`data-deleted-text-selection`)??!1}#Tt(){return this.#ie===``?window.getSelection()?.toString()??``:this.#ie}#Et(e){let t=this.#S?.shadowRoot?.querySelector(`pre`);t!=null&&(e?(t.setAttribute(`data-deleted-text-selection`,``),this.#Dt(null),this.#ie=``):(t.removeAttribute(`data-deleted-text-selection`),this.#ie=``))}#Dt(e,t=!1,n=`additions`){try{this.#M?.setEditorActiveLine(e,{lineNumberOnly:t,side:n})}catch{}}#Ot(){this.#he===void 0&&(this.#he=requestAnimationFrame(()=>{this.#he=void 0,(this.#se!==void 0||this.#ce!==void 0||this.#U!==void 0)&&this.#Wt(this.#se??[])}))}#kt(){let e=this.#te,t=this.#re,n=this.#n?.document;if(e===void 0||e.focusLine===void 0||t===void 0||n===void 0)return!1;let r=t.direction===-1?t.end:t.start,i=this.#w?.parentElement?.scrollLeft??0,a=(e.clientX-e.startClientX+i-e.startScrollLeft)/this.#r.ch,o=a<0?-Math.round(-a):Math.round(a),s=Math.max(0,r.character+o),c={line:e.focusLine,character:s};if(e.renderedGoal!==void 0&&Z(e.renderedGoal,c)===0)return!0;e.renderedGoal=c;let l=[],u=c.line<r.line?-1:1;for(let e=r.line;;e+=u){if(this.#Me(e)){let t=n.getLineText(e),i=Math.min(r.character,t.length),a=Math.min(s,t.length),o=xr(t,i),c=a===i?o:xr(t,a);l.push({start:{line:e,character:Math.min(o,c)},end:{line:e,character:Math.max(o,c)},direction:o===c?0:o<c?1:-1})}if(e===c.line)break}return this.#Wt(l),!0}#At(){for(let[e,t]of this.#D??[])e.startsWith(`editPrediction`)&&(t.remove(),this.#D?.delete(e))}#jt(e,t,n){let r=t[n],i=n,a=r.range.end.line;for(;i+1<t.length&&t[i+1].range.start.line<=a;)i++,a=Math.max(a,t[i].range.end.line);if(i===n&&(r.newText.length===0||Z(r.range.start,r.range.end)===0))return{edit:r,endIndex:i};let o=r.range.start,s={line:a,character:e.getLineLength(a)},c=[],l=e.offsetAt(o);for(let r=n;r<=i;r++){let n=t[r],i=e.offsetAt(n.range.start),a=e.offsetAt(n.range.end);c.push(e.getTextSlice(l,i),n.newText),l=a}return c.push(e.getTextSlice(l,e.offsetAt(s))),{edit:{range:{start:o,end:s},newText:c.join(``)},endIndex:i}}#Mt(){let e=this.#xe,t=this.#n?.document;if(e==null||t==null||e.document!==t||e.version!==t.version||this.#e.editPrediction?.mode===`subtle`&&!this.#ye)return;let{edits:n}=e.response,r=[],i=n.length>0;for(let e=0;e<n.length;){let{edit:a,endIndex:o}=this.#jt(t,n,e);for(let e=a.range.start.line;i&&e<=a.range.end.line;e++)i=this.#wn(e);r.push({edit:a,startIndex:e,endIndex:o}),e=o+1}return{groups:r,allVisible:i}}#Nt(e,t,n,r,i){this.#Le?(e.dataset.wrap=``,e.style.width=`calc(100cqw - ${r}px)`):(delete e.dataset.wrap,e.style.width=`max-content`);let a=t.split(/\r\n|\r|\n/);for(let t=0;t<a.length;t++){let o=a[t],s=t===a.length-1?i:void 0,c=o.length===0&&s===void 0,l=W(`span`,{dataset:c?[`editPredictionLine`,`empty`]:`editPredictionLine`,textContent:c?`​`:o},e);s!==void 0&&W(`span`,{dataset:`editPredictionSuffix`},l).append(s),t===0&&n!==r&&(l.style.textIndent=`${n-r}px`)}}#Pt(e){let t=this.#xe,n=this.#n?.document;if(t==null||n==null)return;let{edit:r,startIndex:i,endIndex:a}=e,{start:o,end:s}=r.range;if(!(Z(o,s)===0&&o.character<n.getLineLength(o.line))||t.response.edits[i-1]?.range.end.line===o.line||t.response.edits[a+1]?.range.start.line===o.line)return;let c=this.#gn(o.line);if(c===void 0)return document.createTextNode(n.getLineText(o.line).slice(o.character));let[l,u]=si(c,o.character),d=document.createRange();d.selectNodeContents(c),d.setStart(l,nt(l,u));let f=d.cloneContents();return f.firstChild?.textContent===``&&f.firstChild.remove(),f}#Ft(e){let{edit:t}=e,{start:n}=t.range,[r,i]=this.#bn(n.line,n.character),a=1,o=t.newText.split(/\r\n|\r|\n/).length,s=this.#E;if(this.#Le&&s!=null){a=Math.max(1,this.#Sn(n.line).length-1);let i=W(`span`,{dataset:`editPrediction`,style:{visibility:`hidden`}},s);this.#Nt(i,t.newText,r,this.#bn(n.line,0)[0],this.#Pt(e));let{width:c,height:l}=i.getBoundingClientRect();i.remove();let{lineHeight:u}=this.#r;c>0&&l>0&&u>0&&(o=Math.round(l/u))}return Math.max(0,o-(a-i))}#It(e=!0){let t=new Map,n=new Map,r=this.#we,i=!1,a=this.#w,o=this.#Mt();if(a!=null&&o!=null&&o.allVisible){for(let e of o.groups){let{edit:t}=e;if(t.newText.length===0)continue;let r=this.#Ft(e);r>(n.get(t.range.start.line)??0)&&n.set(t.range.start.line,r)}if(n.size>0){let e,o=this.#V?.startingLine??0;for(let[s,c]of n){i||=r.get(s)!==c;let n=this.#gn(s);if(n===void 0)continue;let l=s-o;if(a.children[l]!==n){if(e===void 0){e=new Map;for(let t=0;t<a.children.length;t++)e.set(a.children[t],t)}l=e.get(n)??-1}if(l<0)continue;t.set(n,c);let u=this.#C?.children[l];u instanceof HTMLElement&&t.set(u,c);let d=this.#Lt(l);d!=null&&(t.set(d.content,(t.get(d.content)??0)+c),t.set(d.gutter,(t.get(d.gutter)??0)+c))}}}let s=!1;for(let[e,n]of this.#Ce)t.get(e)!==n&&(delete e.dataset.editPredictionSpacer,e.style.removeProperty(`--diffs-edit-prediction-spacer-height`),s=!0);for(let[e,n]of t)this.#Ce.get(e)!==n&&(e.dataset.editPredictionSpacer=``,e.style.setProperty(`--diffs-edit-prediction-spacer-height`,`${n}lh`),s=!0);this.#Ce=t,(i||n.size!==r.size)&&(this.#we=n,e&&this.#je?.syncGhostTextRows()),s&&this.#ze()}#Lt(e){let t=this.#T,n=this.#w;if(t==null||n==null||!this.#Ie||this.#Fe!==`split`||this.#Le)return;let r=0;for(let t=0;t<e;t++)r+=so(n.children[t]);let{content:i,gutter:a}=t,o=0;for(let e=0;e<i.children.length;e++){let t=i.children[e];if(o+=so(t),o>r){let n=a.children[e];if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))throw Error(`Editor: deletions column rows and gutter cells are out of step`);return{content:t,gutter:n}}}}#Rt(e,t=!0){this.#ge!==void 0&&(clearTimeout(this.#ge),this.#ge=void 0),this.#_e?.abort(),this.#_e=void 0,this.#ve++,this.#ye=!1,this.#be=!1,this.#xe=void 0,this.#It(t),e&&this.#At()}#zt(e){let t=this.#e.editPrediction;if(t===void 0)return!1;let n=e.replaceAll(`\\`,`/`);return(t.include===void 0||t.include.some(e=>sa(n,e)))&&t.exclude?.some(e=>sa(n,e))!==!0}#Bt(){this.#Rt(!0);let e=this.#se?.[0];if(this.#e.editPrediction===void 0||this.#n?.document===void 0||this.#n?.fileInfo===void 0||this.#se?.length!==1||e===void 0||!Y(e))return;let t=this.#n?.document,n=t.offsetAt(X(e));this.#ge=setTimeout(()=>{this.#ge=void 0;let e=this.#e.editPrediction,r=this.#se?.[0],i=this.#n?.fileInfo?.name;if(e===void 0||i===void 0||this.#n?.document!==t||this.#se?.length!==1||r===void 0||!Y(r)||t.offsetAt(X(r))!==n||!this.#zt(i))return;let a=e=>this.#hn(e)&&this.#Me(e);if(!a(X(r).line)){this.#be=!0;return}let o=oa(i,t,n,this.#Se,a);if(o===void 0)return;let s=t.offsetAt({line:o.excerptStartLine,character:0}),c=s+o.editableRange.start,l=s+o.editableRange.end,u=new AbortController,d=++this.#ve;this.#_e=u;let f;try{f=e.provider.predict(o,{signal:u.signal})}catch{this.#_e=void 0;return}Promise.resolve(f).then(e=>{let r=this.#se?.[0];if(u.signal.aborted||d!==this.#ve||this.#_e!==u||this.#n?.document!==t||t.version!==o.version||this.#se?.length!==1||r===void 0||!Y(r)||t.offsetAt(X(r))!==n||e==null||!Array.isArray(e.edits)||e.edits.length===0||e.edits.length>eo||e.newCursor==null)return;let i=[],a=0;for(let n of e.edits){if(n==null||typeof n.newText!=`string`||!co(t,n.range?.start)||!co(t,n.range?.end)||Z(n.range.start,n.range.end)>0||(a+=no.encode(n.newText).byteLength,a>to))return;let e=t.offsetAt(n.range.start),r=t.offsetAt(n.range.end),o=t.resolveEdits([n])[0];if(o.start!==e||o.end!==r)return;i.push(o)}i.sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n});for(let e=0;e<i.length;e++){let t=i[e];if(t.start<c||t.end>l||e>0&&i[e-1].end>t.start)return}let s=i.filter(e=>e.text!==t.getTextSlice(e.start,e.end));if(s.length===0)return;let f=t.positionAt(s[0].start),p=t.positionAt(s.at(-1).end),m=t.offsetAt({line:f.line,character:0}),h=t.offsetAt({line:p.line,character:t.getLineLength(p.line)}),g=[],_=m;for(let e of s)g.push(t.getTextSlice(_,e.start),e.text),_=e.end;g.push(t.getTextSlice(_,h));let v=g.join(``).split(/\r\n|\r|\n/),y=f.line+v.length-1,b=v.length-(p.line-f.line+1),x=e.newCursor;if(!(!Number.isInteger(x.line)||!Number.isInteger(x.character)||x.line<0||x.character<0)){if(x.line>=f.line&&x.line<=y){let e=v[x.line-f.line];if(x.character>e.length||lo(e,x.character))return}else{let e=x.line<f.line?x.line:x.line-b;if(e<0||e>=t.lineCount||x.character>t.getLineLength(e))return;let n=t.offsetAt({line:e,character:x.character});if(lo(t.charAt(n-1)+t.charAt(n),1))return}this.#xe={document:t,version:o.version,cursorOffset:n,rendered:!1,response:{edits:s.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),newCursor:{...x}}},this.#Wt(this.#se)}}).catch(()=>{}).finally(()=>{this.#_e===u&&(this.#_e=void 0)})},$a)}#Vt(e,t){let n=this.#n?.document,r=this.#n?.fileInfo?.name,i=Hn(e);n!==void 0&&r!==void 0&&i!==void 0&&this.#zt(r)&&(this.#Se=ia(this.#Se,r,n,i,t))}#Ht(){let e=this.#xe,t=this.#n?.document,n=this.#se?.[0];if(e===void 0||!e.rendered||t===void 0||e.document!==t||e.version!==t.version||this.#se?.length!==1||n===void 0||!Y(n)||t.offsetAt(X(n))!==e.cursorOffset)return;let{edits:r,newCursor:i}=e.response;this.#Rt(!0);let a=t.applyEdits(r.map(e=>({range:{start:{...e.range.start},end:{...e.range.end}},newText:e.newText})),!0,this.#se,void 0,!0);if(a===void 0){this.#Bt();return}let o=t.normalizePosition(i),s=[{start:o,end:o,direction:0}];t.setLastUndoSelectionsAfter(s),this.#dn(a,s,this.#pn(a),{editSource:`prediction`})}#Ut(e){let t=this.#xe,n=this.#n?.document;t!==void 0&&(t.rendered=!1);let r=this.#Mt();if(t!=null&&n!=null&&r!=null&&r.allVisible){for(let t of r.groups){let{edit:r,endIndex:i}=t,{start:a,end:o}=r.range,s=r.newText.length===0,c=Z(a,o)!==0,l=n.getLineLength(a.line),u=!c&&a.character<l;if(c?this.#Kt(e,s?`editPredictionDeletion`:`editPredictionReplacement`,{start:a,end:o}):u&&this.#Kt(e,`editPredictionInsertion`,{start:a,end:{line:a.line,character:l}}),s)continue;let[d,f]=this.#bn(a.line,a.character),p=this.#bn(a.line,0)[0],m=this.#yn(a.line)+f*this.#r.lineHeight,h=`editPrediction-${i}`,g=this.#D?.get(h);if(g===void 0?g=W(`span`,{ariaHidden:`true`,contentEditable:`false`,dataset:`editPrediction`},e.fragment):(this.#D?.delete(h),g.replaceChildren()),c){g.dataset.replacement=``;let e=this.#gn(a.line);e!==void 0&&g.style.setProperty(`--diffs-edit-prediction-bg`,getComputedStyle(e).getPropertyValue(`--diffs-line-bg`))}else delete g.dataset.replacement,g.style.removeProperty(`--diffs-edit-prediction-bg`);this.#Nt(g,r.newText,d,p,this.#Pt(t)),g.style.transform=`translateX(${p}px) translateY(${m}px)`,e.elements.set(h,g)}t.rendered=!0}}#Wt(e){this.__postponeBgTokenizeToNextFrame();let t=this.#se,n=t?.length!==e.length;if(!n&&t!==void 0)for(let r=0;r<e.length;r++){let i=t[r],a=e[r];if(i.direction!==a.direction||Z(i.start,a.start)!==0||Z(i.end,a.end)!==0){n=!0;break}}if(n&&this.#Rt(!0),this.#It(),this.#A=void 0,this.#Dt(null),e.length===0&&this.#ce===void 0&&this.#U===void 0){this.#se=void 0,this.#D?.forEach(e=>e.remove()),this.#D?.clear(),this.#K?.cleanup(),this.#K=void 0,n&&this.#Bt();return}let r=document.createDocumentFragment(),i={fragment:r,elements:new Map};if(e.length>0){let t=Kr(e),n=t.at(-1);this.#se=t;let r=t.some(e=>!Y(e)),a=X(n).line+1;this.#Dt(a,r);for(let e of t)Y(e)||this.#Kt(i,`selection`,e),this.#Xt(i,e,e===n);let o=this.#e.matchBrackets!==!1&&this.#n?.document!=null&&this.#i!==void 0&&Y(n)?Sa(this.#n?.document,this.#i,n.start):void 0;if(o!==void 0)for(let e of o)this.#Kt(i,`bracketMatch`,e)}let a=this.#n?.document;if(this.#ce!==void 0&&a!==void 0){let e=this.#ce,t=this.#V,n=t!=null&&Number.isFinite(t.totalLines)||this.#Ie&&this.#Ae?.options.expandUnchanged!==!0?this.#mn():void 0,r=this.#se?.at(-1),o=r===void 0?-1:a.offsetAt(r.start),s=r===void 0?-1:a.offsetAt(r.end),c=0,l=n?.length??1;for(let t=0;t<l;t++){let r=1/0,l=n?.[t];if(l!==void 0){let[t,n]=l,i=a.offsetAt({line:t,character:0}),o=n+1;r=o<a.lineCount?a.offsetAt({line:o,character:0}):a.offsetAt({line:o-1,character:a.getLineLength(o-1)});let s=c,u=e.length;for(;s<u;){let t=s+Math.floor((u-s)/2);e[t][1]<=i?s=t+1:u=t}c=s}for(;c<e.length;c++){let[t,n]=e[c];if(t>=r)break;let l={start:a.positionAt(t),end:a.positionAt(n)},u=o===t&&s===n;this.#Kt(i,`match`,l,u?`focus`:void 0)}}}if(this.#U!==void 0&&a!==void 0)for(let e of this.#U.markers)this.#Kt(i,`marker`,e,Li(e.severity));this.#Ut(i),this.#E?.appendChild(r),this.#D?.forEach(e=>e.remove()),this.#D?.clear(),this.#D=i.elements,this.#Zt(),n&&this.#Bt()}#Gt(){let e=this.#W,t=this.#e.renderCaret,n=this.#E;if(this.#k?.forEach(e=>e.remove()),this.#k=void 0,e===void 0||t===void 0||n===void 0){this.#O?.forEach(e=>e.remove()),this.#O=void 0;return}let r=this.#O??=new Map;for(let[e,t]of r)this.#wn(e.caret.focus.line)||(t.remove(),r.delete(e));let i=document.createDocumentFragment(),a=[];for(let n of e){let{caret:e}=n,{line:o,character:s}=e.focus;if(n.anchorOffset!==n.focusOffset){let t={fragment:i,elements:new Map};this.#Kt(t,`caretHighlight`,n.anchorOffset<n.focusOffset?{start:e.anchor,end:e.focus}:{start:e.focus,end:e.anchor},void 0,e.focus);for(let n of t.elements.values())n.style.setProperty(`--diffs-caret-highlight-bg`,`color-mix(in srgb, ${e.metadata.color} 32%, transparent)`),a.push(n)}if(!this.#wn(o))continue;let c=r.get(n);c===void 0&&(c=W(`div`,{dataset:`remoteCaret`,children:[t(e)]},i),r.set(n,c));let[l,u]=this.#bn(o,s),d=this.#yn(o)+u*this.#r.lineHeight;c.style.transform=`translateX(${l}px) translateY(${d}px)`}this.#k=a,n.appendChild(i)}#Kt(e,t,n,r,i){if(this.#n?.document==null)return;let{start:a,end:o}=n,s=a.line,c=o.line+1;if(this.#V!==void 0){let{startingLine:e,totalLines:t}=this.#V;s=Math.max(s,e),c=Math.min(c,e+t)}for(let n=s;n<c;n++){if(!this.#wn(n))continue;let s=n===o.line,c=n===a.line?a.character:0,l=s?o.character:this.#n?.document.getLineLength(n);if(c===l&&(t===`editPredictionDeletion`||t===`editPredictionReplacement`)){if(s&&n!==a.line)continue;let[i,o]=this.#bn(n,c);this.#Yt(e,t,n,o,i,this.#r.ch,r);continue}if(this.#Le){let a=this.#vn(),o=this.#n?.document.getLineText(n);if(2*this.#r.ch+this.#r.measureTextWidth(o)>a){this.#qt(e,n,o,c,l,s,t,r,i);continue}}let u=0,d=0,f=0;u=c===0?this.#_n()+this.#r.ch+(this.#$e?.left??0):this.#bn(n,c)[0],!s&&t===`selection`&&(f=this.#r.ch),d=c===l?f:this.#bn(n,l)[0]-u+f,this.#Yt(e,t,n,0,u,d,r,{start:i?.line===a.line&&i.character===a.character&&n===a.line,end:i?.line===o.line&&i.character===o.character&&n===o.line})}}#qt(e,t,n,r,i,a,o,s,c){let l=this.#Sn(t),u=l.length-1,d=this.#_n()+this.#r.ch+(this.#$e?.left??0);for(let f=0;f<u;f++){let p=l[f],m=l[f+1],h=Math.max(r,p),g=Math.min(i,m);if(h>g)continue;let _=this.#Jt(n,p,h),v=d+_,y=0;!a&&f===u-1&&o===`selection`&&(y=this.#r.ch);let b=h===g?y:this.#Jt(n,p,g)-_+y;this.#Yt(e,o,t,f,v,b,s,{start:c?.line===t&&c.character===r&&h===r,end:c?.line===t&&c.character===i&&g===i})}}#Jt(e,t,n){if(n<=t)return 0;let r=e.slice(t,n),i=Va(r,this.#r.tabSize);return i===-1?this.#r.measureTextWidth(r):i*this.#r.ch}#Yt(e,t,n,r,i,a,o,s){if(a===0)return;let{ch:c,lineHeight:l}=this.#r,u=this.#yn(n)+r*l,d=`${t}-${n}/${r}-${i}-${a} ${o??``}`,f=this.#D,p=(this.#e.roundedSelection??!0)&&(t===`selection`||t===`caretHighlight`),m=(n,r,i,a)=>{let o=this.#yn(n)+r*l,s=this.#gn(n),u=`initial`;s!==void 0&&(s.dataset.lineType===`change-addition`||s.dataset.selectedLine!==void 0)&&(u=getComputedStyle(s).getPropertyValue(`--diffs-line-bg`));let d=`width:${c}px;transform:translateX(${i}px) translateY(${o}px);--diffs-selection-corner-bg:${u}`,p={selectionCorner:``,[a]:``},m=`${t}-block-${n}/${r}-${i}-1ch`,h=m+`-`+a;if(a===`rbl`){let t=m+`-rtl`,n=e.elements.get(t);n!==void 0&&(n.remove(),e.elements.delete(t),h+=`-rtl`,p.rtl=``)}let g=e.elements.get(h);g===void 0&&(f?.has(h)===!0?(g=f.get(h),g.style.cssText=d,f.delete(h)):g=W(`div`,{dataset:t===`caretHighlight`?`caretHighlightRange`:`selectionRange`,style:{cssText:d},children:[W(`div`,{dataset:p})]},e.fragment),e.elements.set(h,g))},h=t=>{let o=i+a,l=t.dataset,u=e.previousSelectionRange;if((u===void 0||u.line!==n||u.wrapLine!==r)&&(e.previousSelectionRange={element:t,line:n,wrapLine:r,left:i,width:a}),u===void 0||o<=u.left)[`rtl`,`rtr`,`rbl`,`rbr`].forEach(e=>{l[e]=``});else{let e=u.line,t=u.wrapLine,a=u.left,s=u.element.dataset,d=a+u.width;a>i&&m(e,t,a-c,`rbr`),delete s.rbl,delete l.rtl,delete l.rtr,o>=d&&delete s.rbr,o>d&&(m(e,t,d,`rbl`),l.rtr=``),o<d&&m(n,r,o,`rtl`),i<a&&(l.rtl=``),l.rbl=``,l.rbr=``}s?.start===!0&&(delete l.rtl,delete l.rbl),s?.end===!0&&(delete l.rtr,delete l.rbr)},g=e.elements.get(d);if(g!==void 0)p&&h(g);else{if(f?.has(d)===!0?(g=f.get(d),f.delete(d)):g=W(`div`,{dataset:o?[t+`Range`,o]:t+`Range`},e.fragment),g.style.width=`${a}px`,g.style.transform=`translateX(${i}px) translateY(${u}px)`,t===`editPredictionInsertion`||t===`editPredictionReplacement`){let e=this.#gn(n);e!==void 0&&g.style.setProperty(`--diffs-edit-prediction-bg`,getComputedStyle(e).getPropertyValue(`--diffs-line-bg`))}else g.style.removeProperty(`--diffs-edit-prediction-bg`);p&&h(g),e.elements.set(d,g)}}#Xt(e,t,n){let{line:r,character:i}=X(t);if(!this.#wn(r))return;let[a,o]=this.#bn(r,i),s=`caret-`+r+`/`+o+`:`+i;if(e.elements.has(s))return;let c=a-1,l=this.#yn(r)+o*this.#r.lineHeight,u=W(`div`,{dataset:`caret`,style:{transform:`translateX(${c}px) translateY(${l}px)`}},e.fragment);e.elements.set(s,u),n&&(u.style.scrollMargin=this.#_t(),this.#A=u)}#Zt(){let e=this.#se?.at(-1),t=this.#E,n=this.#n?.document,r=this.#e.renderSelectionAction,i=()=>{this.#K?.cleanup(),this.#K=void 0};if(this.#e.enabledSelectionAction!==!0||r===void 0||e===void 0||Y(e)||this.#ee||t===void 0||n===void 0){i();return}let a=X(e);if(!this.#wn(a.line)){i();return}if(this.#K===void 0){if(!this.#q)return;let a=()=>this.#se?.at(-1)??e,o=r({textDocument:n,get selection(){return a()},applyEdits:e=>this.applyEdits(e),getSelectionText:()=>this.#n?.document?.getText(a())??``,replaceSelectionText:e=>{this.#an(e,[a()])},close:()=>{i(),this.#gt()}});this.#K=new Pa(o,t,()=>this.#Zt()),this.#Re().resetPlacement(ro)}let o=this.#r.lineHeight,s=e.direction===-1,c={placeAbove:s,anchor:a},l=s?{placeAbove:!1,anchor:e.end}:{placeAbove:!0,anchor:e.start},u=this.#K.height,d=e=>{let[t,n]=this.#bn(e.anchor.line,e.anchor.character),r=this.#yn(e.anchor.line)+n*o,i=e.placeAbove?r:r+o,a=e.placeAbove?i-u:i;return{top:a,bottom:a+u,left:t,anchorTop:i,rowTop:r}},f=d(c),p=n.lineCount,m=s?a.line<3:a.line>=p-3,h=this.#wn(l.anchor.line)?d(l):void 0,g=this.#Re(),_=g.getPlacementBounds(),v=h!==void 0&&g.choosePlacement({preferred:f,fallback:h,viewport:_,popoverHeight:u,atDocumentEdge:m,placementKey:ro})===`fallback`;h===void 0&&g.setPlacement(`preferred`,ro);let{placeAbove:y}=v?l:c,{left:b,anchorTop:x}=v&&h!==void 0?h:f,S=s?f.rowTop:h?.rowTop??-1/0,C=(s?h?.rowTop??1/0:f.rowTop)+(e.end.line>e.start.line&&e.end.character===0?0:o),w=_===void 0||C>_.top&&S<_.bottom;this.#K.reposition(b,x,this.#_n(),y,w,_)}#Qt(e){this.#G===void 0?this.#$t(e):this.#G.setMode(e)}#$t(e){this.#G?.cleanup();let t=this.#n?.document,n=this.#S?.shadowRoot?.querySelector(`pre`),r=this.#se;if(t===void 0||n==null)return;let i=``,a;if(r!==void 0&&r.length>0){let e=r.at(-1);if(Y(e)){e=ci(t,e),this.#Wt([...r.slice(0,-1),e]);let n=t.getText(e);n!==``&&!n.includes(`
31
- `)&&(i=n,a=[t.offsetAt(e.start),t.offsetAt(e.end)])}}let o=([e,n],r)=>{let i=Br(t,e,n);this.#Wt([i]),this.#Pe(X(i).line),this.#gt(!0),this.#pe=r},s=new ot({textDocument:t,containerElement:n,defaultQuery:i,mode:e,initialMatch:a,scrollToMatch:o,applyReplace:e=>{if(e.length===0)return;let n=t.applyEdits(e.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),!0,this.#se);n!==void 0&&this.#dn(n,void 0,this.#pn(n),{skipSearchRefresh:!0})},onUpdate:(e,n)=>{if(e.length===0){this.#ce=void 0,this.#Wt(this.#se??[]);return}if(this.#ce=e,n?.syncSelection===!1){this.#Wt(this.#se??[]);let n=this.#se?.at(-1);if(n!==void 0){let r=t.offsetAt(n.start),i=t.offsetAt(n.end);for(let t of e)if(t[0]===r&&t[1]===i)return t}return}let r=this.#se?.at(-1),i=0,a;r!==void 0&&(i=t.offsetAt(r.start));for(let t of e)if(t[0]>=i){a=t;break}return a===void 0?this.#Wt(this.#se??[]):o(a,!0),a},onClose:()=>{this.#G=void 0,this.#pe=!1,this.#ce=void 0,this.#Wt(this.#se??[])}});this.#G=s,this.#pe=!1}#en(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?``:ti(e,t)}#tn(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?[]:ei(e,t)}#nn(e,t,n){e!==null&&(e.setData(`text`,t),n.length>1&&e.setData(io,JSON.stringify(n)))}#rn(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0||t.length===0)return``;if(t.some(e=>Y(e))){let n=oi(e,t);return this.#in(n.edits,n.nextSelectionOffsets),n.text}let n=ti(e,t);return this.#an(``,void 0,!0),n}#in(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0||e.length===0)return;let i=n.applyResolvedEdits(e,!0,r,void 0,!0);if(i===void 0)return;let a=t.map(e=>{let t=n.positionAt(e);return{start:t,end:t,direction:0}});n.setLastUndoSelectionsAfter(a),this.#dn(i,a,this.#pn(i))}#an(e,t=this.#se,n=!1,r=`selection`){if(t===void 0)return;let i=this.#n?.document,a=t.at(-1);if(i===void 0||a===void 0)return;let{nextSelections:o,change:s}=Array.isArray(e)&&e.length===t.length?kr(i,t,e,this.#R,n,r):Er(i,t,{start:i.offsetAt(a.start),end:i.offsetAt(a.end),text:Array.isArray(e)?e.join(i.eol):e},this.#R,void 0,n);s!==void 0&&this.#dn(s,o,this.#pn(s))}#on(e=!1){let t=this.#se,n=this.#n?.document;if(t===void 0||n===void 0)return;let{nextSelections:r,change:i}=Lr(n,t,e,this.#R,this.#r.tabSize);i!==void 0&&this.#dn(i,r,this.#pn(i))}#sn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Pr(t,e,this.#Le?(e,t)=>{let n=this.#Sn(e);for(let e=0;e+1<n.length;e++){let r=n[e],i=n[e+1];if(t>=r&&t<=i)return r}return 0}:void 0,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#cn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Fr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#ln(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Nr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#un(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Mr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#dn(e,t,n,r){this.#xe!=null&&this.#Rt(!0);let i=this.#n?.document;if(i!==void 0&&this.#W!==void 0)for(let t of this.#W)t.anchorOffset=Vr(t.anchorOffset,e.changes),t.focusOffset=Vr(t.focusOffset,e.changes),t.caret.anchor=i.positionAt(t.anchorOffset),t.caret.focus=i.positionAt(t.focusOffset);if(e.lineDelta!==0||this.#Le)for(let t of this.#m.keys())t>=e.startLine&&this.#m.delete(t);if(this.#h.size>0){if(e.lineDelta===0&&(e.changedLineRanges.length===1||e.changedLineChanges?.every(([,,e])=>e===0)===!0))for(let[t,n]of e.changedLineRanges)for(let e=t;e<=n;e++)this.#h.delete(e);else for(let t of this.#h.keys())t>=e.startLine&&this.#h.delete(t)}this.#_=void 0;let a=this.#V,o;if(a!==void 0&&t!==void 0&&t.length>0){let n=t.at(-1),r=a.startingLine+a.totalLines;if(n.end.line>=r){let t=n.end.line-a.startingLine+1,i=this.#H===void 0||this.#H===1/0?1/0:this.#H*Za;e.startLine<=r&&t<=i&&this.#Me(n.end.line)?(n.end.line>r&&(o=!0),a={...a,totalLines:t},this.#V=a):o=!0}}if(this.#I&&this.#i!=null&&this.#w!=null?this.#ct(e,n,a,o):i!=null&&(this.#P?.(i,n),n!=null&&(this.#R=n)),t!=null&&this.#Wt(t),this.#M?.__acknowledgeDocumentUpdate(),this.#De(),this.#Vt(e,r?.editSource??`user`),this.#Bt(),this.#fn(e.changes,n??this.#R),r?.skipSearchRefresh!==!0&&this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1}),t!=null&&r?.skipFocus!==!0){let e=t.at(-1);if(e!==void 0&&this.#Pe(X(e).line),this.#A!==void 0)requestAnimationFrame(()=>{this.#A?.scrollIntoView({block:`nearest`,inline:`nearest`})});else if(t.length>0){let e=X(t.at(-1));this.#vt(e.line,e.character)}this.focus({preventScroll:!0})}}#fn(e,t){let n=this.getFile(),r=this.#F;n!=null&&r!=null&&r(e,n,t)}#pn(e){if(this.#R!=null){let t=nr(e,this.#R);if(t!=null)return this.#n?.document?.setLastUndoLineAnnotations(this.#R,t),t}}#mn(){let e=this.#w;if(e===void 0)return[];let t=[];for(let n of e.children){let e=n,r=e.dataset.lineType,i=G(e);if(i===void 0||r===void 0||!Rr(r))continue;let a=i-1,o=t.at(-1);o!==void 0&&a<=o[1]+1?o[1]=Math.max(o[1],a):t.push([a,a])}return t}#hn(e){let t=this.#V;return t==null||e>=t.startingLine&&e<t.startingLine+t.totalLines}#gn(e){let t=this.#g.get(e);if(t!==void 0)return t??void 0;let n=this.#V;if(!this.#hn(e))return;let r=this.#w;if(r!==void 0){if(n!==void 0){let{startingLine:i}=n,{children:a}=r;for(let n=e-i;n<=a.length;n++){let r=a[n];if(r===void 0)break;let i=G(r),o=r.dataset.lineType;if(i!==void 0&&i===e+1&&o!==void 0&&Rr(o)){t=r;break}}}return t??=r.querySelector(`[data-line="${e+1}"]`+(this.#Fe===`unified`?`:not([data-line-type="change-deletion"])`:``)),t!==void 0&&this.#g.set(e,t),t??void 0}}#_n(){if(this.#C===void 0)return 0;if(this.#f===void 0){let e=this.#w?.parentElement?.style.getPropertyValue(`--diffs-column-number-width`);this.#f=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseInt(e.slice(0,-2),10):this.#C.offsetWidth}return this.#f}#vn(){if(this.#w===void 0)return 0;if(this.#p===void 0){let e=this.#w.parentElement?.style.getPropertyValue(`--diffs-column-content-width`);this.#p=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseFloat(e.slice(0,-2)):this.#w.offsetWidth}return this.#p}#yn(e){let t=this.#m.get(e);if(t!==void 0)return t;let n=this.#gn(e);if(n===void 0)return-1;let r=n.offsetTop+this.#r.paddingTop;return r+=this.#$e?.top??0,this.#m.set(e,r),r}#bn(e,t){if(this.#_!==void 0&&this.#_[0]===e&&this.#_[1]===t)return[this.#_[2],this.#_[3]];let n=this.#n?.document?.getLineText(e),r=this.#_n()+this.#r.ch;if(n===void 0||n.length===0||t<=0)return[r+(this.#$e?.left??0),0];let i=za(n,Math.min(t,n.length)),a=n.slice(0,i),o=Va(a,this.#r.tabSize),s=0,c=0;if(s=o===-1?r+this.#r.measureTextWidth(a):r+o*this.#r.ch,this.#Le){let t=this.#vn();if(2*this.#r.ch+this.#r.measureTextWidth(n)>t){let t=this.#xn(e);if(t==null)return[s+(this.#$e?.left??0),0];for(let e=0;e+1<t.length;e++){let a=t[e];if(i<=t[e+1]){c=e;let t=n.slice(a,i),o=Va(t,this.#r.tabSize);s=o===-1?r+this.#r.measureTextWidth(t):r+o*this.#r.ch;break}}}s+=this.#$e?.left??0}return this.#_===void 0?this.#_=[e,t,s,c]:(this.#_[0]=e,this.#_[1]=t,this.#_[2]=s,this.#_[3]=c),[s,c]}#xn(e){let t=this.#h.get(e);if(t!==void 0)return t;this.#h.size>=Qa&&this.#h.clear();let n=this.#n?.document?.getLineText(e);if(n===void 0||n.length===0){let t=new Uint32Array([0]);return this.#h.set(e,t),t}let r=this.#w;if(r==null||!r.isConnected)return;let i=W(`div`,{style:{position:`absolute`,top:`0`,left:`0`,width:`100%`,boxSizing:`border-box`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,font:`inherit`,paddingInline:`1ch`,tabSize:this.#r.tabSize.toString()},textContent:n},r),a=i.firstChild,o=document.createRange(),s=[];try{let t=i.getBoundingClientRect();if(t.width===0)return;let r=Ba(n),c=t.left+this.#r.ch,l=r===void 0?n.length:r.length-1,u=e=>r===void 0?e:r[e],d=e=>{o.setStart(a,u(e)),o.setEnd(a,u(e+1));let t=o.getClientRects();return t.item(t.length-1)??o.getBoundingClientRect()};s.push(0);let f=d(0).top,p=1;for(;p<l;){let e=p,t=l;for(;e<t;){let n=e+t>>1;d(n).top>f?t=n:e=n+1}if(e>=l)break;let{left:n,top:r}=d(e),i=Ie()&&n-c>this.#r.ch/2;s.push(u(i?e-1:e)),f=r,p=e+1}let m=new Uint32Array(s.length+1);for(let e=0;e<s.length;e++)m[e]=s[e];return m[s.length]=n.length,this.#h.set(e,m),m}finally{i.remove()}}#Sn(e){let t=this.#xn(e);if(t!==void 0)return t;let n=this.#n?.document?.getLineText(e)?.length??0;return Uint32Array.of(0,n)}#Cn({startContainer:e,endContainer:t}){let n=this.#w;return n!==void 0&&n.contains(e)&&n.contains(t)}#wn(e){let t=this.#n?.document?.lineCount??0;return e<0||e>=t?!1:this.#gn(e)!==void 0}};function oo({type:e,editStateKey:t,owner:n,initialState:r,previousSession:i}){if(r!=null&&r.type!==e)throw TypeError(`Editor: initialState: a ${r.type} state cannot initialize a ${e} editor`);let a=r;return t==null?a??i??(e===`file`?{type:`file`}:{type:`file-diff`}):Qn.activate(e,t,n,a)}function so(e){return e instanceof HTMLElement?Number(e.dataset.bufferSize??1):1}function co(e,t){return t!==void 0&&Number.isInteger(t.line)&&Number.isInteger(t.character)&&t.line>=0&&t.line<e.lineCount&&t.character>=0&&t.character<=e.getLineLength(t.line)}function lo(e,t){let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return t>0&&t<e.length&&n>=55296&&n<=56319&&r>=56320&&r<=57343}var Q=n();function uo(e,t){let n=A(t),r=oe(t)?`\\`:`/`,i=t.split(/[\\/]/).filter(Boolean),a=t.startsWith(`\\\\`)?`\\\\`:t.startsWith(`/`)?`/`:``;return[...n?[]:[{label:e,path:``,kind:`project`}],...i.map((e,t)=>{let o=a+i.slice(0,t+1).join(r);return{label:e,path:/^[A-Za-z]:$/.test(o)?`${o}\\`:n&&o===`~`?`~/`:o,kind:t===i.length-1?`file`:`directory`}})]}function fo(e){return uo(``,e).at(-1)?.path??e}function po(e){return A(e)&&!/^\\\\[^\\/]+$/.test(e)}function mo(e,t){let n=fo(t);return uo(``,e).findIndex(e=>e.path===n)}function ho(e,t){return e!==void 0&&mo(e,t)>=0?e:t}function go(e,t){let n=mo(t,e);return n<0?null:uo(``,t)[n+1]?.label??null}function _o(e,t){let n=oe(e)?`\\`:`/`;return(e.endsWith(n)?e:`${e}${n}`)+t.split(`/`).join(n)}function vo(e,t){let n,r=t?`${t}/`:``;return e.flatMap(e=>{if(!e.path.startsWith(r))return[];let t=e.path.slice(r.length);return!t||t.includes(`/`)?[]:[{...e,label:t}]}).toSorted((e,t)=>e.kind===t.kind?(n??=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),n.compare(e.label,t.label)):e.kind===`directory`?-1:1)}function yo(e){if(!e)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}var bo=e=>{if(typeof e!=`object`||!e)return null;let t=e;return typeof t.getAttribute==`function`?t.getAttribute(`data-item-path`):null};function xo(e){let t=[],n=[];return{isDragInProgress:()=>n.length>0,handleSelectionChange(e){t=e},handleDragStart(r){if(r.dataTransfer===null)return;let i=null;for(let e of r.composedPath())if(i=bo(e),i!==null)break;if(i===null)return;let a=t.includes(i)?t:[i],o=a.map(t=>{let n=t.replace(/\/+$/,``);return wn(n&&e.mentionPath?e.mentionPath(n):t)}).filter(e=>e!==null);o.length!==0&&(n=a,r.dataTransfer.setData(Sn,o.join(` `)))},handleDragEnd(){if(n.length!==0){for(let t of n)e.deselect(t);n=[]}}}}function So(e){return e.split(`/`).filter(Boolean).length}function Co(e,t){let n=new Set(e),r=new Set(t),i=[],a=[],o=e.filter(e=>!r.has(e)).toSorted((e,t)=>So(e)-So(t));for(let e of o){if(i.some(t=>e.startsWith(t)))continue;let t=e.endsWith(`/`);a.push({type:`remove`,path:e,...t?{recursive:!0}:{}}),t&&i.push(e)}let s=t.filter(e=>!n.has(e)).toSorted((e,t)=>So(e)-So(t));for(let e of s)a.push({type:`add`,path:e});return a}function wo(e,t){let[n,r]=(0,J.useState)(new Map),[i,a]=(0,J.useState)(new Map),[o,s]=(0,J.useState)(0),[c,l]=(0,J.useState)(new Set),u=(0,J.useRef)(new Map),f=(0,J.useRef)(new Set),p=(0,J.useRef)(new Set),m=(0,J.useRef)(!0),h=(0,J.useRef)(0),g=(0,J.useRef)([]),_=(0,J.useCallback)(function n(i,o=!1){let c=u.current.get(i);if(c)return o?c.then(()=>n(i,!0)):c;if(!o&&f.current.has(i))return Promise.resolve();f.current.add(i),p.current.add(i);let _=ie.listEntries({environmentId:e,input:{cwd:t,directoryPath:i}});s(e=>e+1),o||l(e=>new Set(e).add(i));let v=(async()=>{h.current>=4?await new Promise(e=>g.current.push(e)):h.current++;try{return m.current?await ee(d,_,{refresh:!0,reportFailure:!1,reportDefect:!1}):void 0}finally{let e=g.current.shift();e?e():h.current--}})().then(e=>{if(m.current&&e){if(e._tag===`Success`)r(t=>new Map(t).set(i,e.value.entries.filter(e=>e.path.slice(0,Math.max(0,e.path.lastIndexOf(`/`)))===i))),a(e=>{let t=new Map(e);return t.delete(i),t});else{f.current.delete(i);let t=O(e.cause);a(e=>new Map(e).set(i,t instanceof Error?t.message:`Unable to load folder.`))}}}).finally(()=>{u.current.delete(i),m.current&&(s(e=>e-1),o||l(e=>{let t=new Set(e);return t.delete(i),t}))});return u.current.set(i,v),v},[t,e]);(0,J.useEffect)(()=>(m.current=!0,_(``),()=>{m.current=!1}),[_]);let v=(0,J.useMemo)(()=>{let e=[],t=r=>{for(let i of n.get(r)??[])e.push(i),i.kind===`directory`&&t(i.path)};return t(``),e},[n]),y=(0,J.useMemo)(()=>new Set([``,...v.filter(e=>e.kind===`directory`).map(e=>e.path)]),[v]);return{entries:v,load:_,refresh:(0,J.useCallback)(()=>{let e=[...p.current].filter(e=>y.has(e)),t=0,n=async()=>{for(;t<e.length&&m.current;){let n=e[t++];n!==void 0&&await _(n,!0)}};for(let t=0;t<Math.min(4,e.length);t++)n()},[_,y]),isPending:o>0,loadingDirectories:c,ready:n.has(``),error:[...i].find(([e])=>y.has(e))?.[1]??null}}var $=e(r(),1);function To(e){return e.kind===`directory`?`${e.path}/`:e.path}function Eo(e){let t=(0,Q.c)(12),n;t[0]===e.onRefresh?n=t[1]:(n=(0,$.jsx)(h,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Refresh workspace files`,onClick:e.onRefresh}),t[0]=e.onRefresh,t[1]=n);let r;t[2]===e.isPending?r=t[3]:(r=(0,$.jsx)(vn,{refreshing:e.isPending}),t[2]=e.isPending,t[3]=r);let i;t[4]!==n||t[5]!==r?(i=(0,$.jsx)(_t,{render:n,children:r}),t[4]=n,t[5]=r,t[6]=i):i=t[6];let a=e.isPending?`Refreshing…`:`Refresh files`,o;t[7]===a?o=t[8]:(o=(0,$.jsx)(vt,{children:a}),t[7]=a,t[8]=o);let s;return t[9]!==i||t[10]!==o?(s=(0,$.jsxs)(yt,{children:[i,o]}),t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function Do(e){let t=(0,Q.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):(n=t=>e.onValueChange(t.target.value),r=t=>{t.key===`Escape`&&(e.onClose(),t.currentTarget.blur())},t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==e.ariaLabel||t[4]!==e.name||t[5]!==e.value||t[6]!==n||t[7]!==r?(i=(0,$.jsx)(un,{variant:`ghost`,className:`h-7 min-w-0 flex-1`,children:(0,$.jsx)(ln,{type:`search`,name:e.name,size:`sm`,value:e.value,"aria-label":e.ariaLabel,placeholder:`Search files`,spellCheck:!1,onChange:n,onKeyDown:r})}),t[3]=e.ariaLabel,t[4]=e.name,t[5]=e.value,t[6]=n,t[7]=r,t[8]=i):i=t[8],i}function Oo({environmentId:e,cwd:t,projectName:n,selectedPath:r,selectedPathRevealId:i,onOpenFile:a,onRefreshSelectedFile:o,workspaceMutationId:s,hostFolder:c=!1}){let l=e=>c?_o(t,e):e,{resolvedTheme:u}=ye(),d=_(),f=De(e),{entries:p,load:m,refresh:g,ready:v,error:y,isPending:b,loadingDirectories:x}=wo(e,t),[S,C]=(0,J.useState)(``),[w,T]=(0,J.useState)(!1),E=ke({environmentId:e,cwd:c?null:t,query:S.slice(0,256)},200),D=(0,J.useMemo)(()=>{let e=new Map(p.map(e=>[e.path,e]));if(S.trim()&&!E.isPending)for(let t of E.entries){e.has(t.path)||e.set(t.path,t);let n=t.path.split(`/`);for(let t=1;t<n.length;t++){let r=n.slice(0,t).join(`/`);e.has(r)||e.set(r,{path:r,kind:`directory`})}}return[...e.values()]},[p,E.entries,E.isPending,S]),O=(0,J.useMemo)(()=>new Map(D.map(e=>[e.path,e.kind])),[D]),k=(0,J.useRef)(O),ee=(0,J.useMemo)(()=>D.map(To),[D]),te=(0,J.useMemo)(()=>D.filter(e=>e.kind===`directory`).map(To),[D]),ne=(0,J.useRef)(null),re=(0,J.useRef)(!1),ie=(0,J.useRef)(null),A=(0,J.useRef)(null),ae=(0,J.useRef)(null),oe=async(n,r)=>{let i=ve();if(!i){r.close();return}let a=n.path.replace(/\/$/,``),o=cn(l(a)),s=ae.current,c=s!==null&&performance.now()-s.at<1e3,u=r.anchorElement.getBoundingClientRect(),p=c?{x:s.x,y:s.y}:{x:u.left,y:u.bottom},m={environmentId:e,filePath:a,workspaceRoot:t},h=f.buildItems(m);try{let e=await i.contextMenu.show([...h,{id:`copy-mention`,label:`Copy mention`},{id:`add-to-chat`,label:`Add to chat`}],p);if(e===null)return;if(h.some(t=>t.id===e)||e.startsWith(`editor:`)){await f.activate(e,m);return}if(e===`copy-mention`){try{await _e(o),ge.add({type:`success`,title:`Mention copied`,description:a})}catch(e){ge.add({type:`error`,title:`Failed to copy mention`,description:e instanceof Error?e.message:`An error occurred.`})}return}if(e===`add-to-chat`){let e=d?.current;if(!e){ge.add({type:`error`,title:`Unable to add to chat`,description:`Open a chat for this project and try again.`});return}e.insertTextAtEnd(`${o} `,{ensureLeadingBoundary:!0})||ge.add({type:`error`,title:`Unable to add to chat`,description:`The chat isn't ready to accept input right now.`})}}finally{r.close()}},se=(0,J.useRef)(oe);(0,J.useEffect)(()=>{se.current=oe});let ce=(0,J.useRef)(x),le=(0,J.useRef)(null),ue=(0,J.useMemo)(()=>xo({deselect:e=>le.current?.getItem(e)?.deselect(),...c?{mentionPath:e=>_o(t,e)}:{}}),[t,c]),{model:j}=jt({composition:{contextMenu:{triggerMode:`right-click`,onOpen:(e,t)=>{se.current(e,t)}}},dragAndDrop:{canDrop:()=>!1},density:`compact`,fileTreeSearchMode:`hide-non-matches`,flattenEmptyDirectories:!0,initialExpansion:`closed`,icons:Nt,onSelectionChange:e=>{if(ue.handleSelectionChange(e),re.current||ue.isDragInProgress())return;let t=e.at(-1)?.replace(/\/$/,``);t&&k.current.get(t)===`file`&&(ie.current=t,a(l(t)))},paths:[],renderRowDecoration:({item:e,row:t})=>t.kind===`directory`&&t.isExpanded&&ce.current.has(e.path.replace(/\/$/,``))?{icon:`p4-tree-icon-loading`,title:`Loading…`}:null,search:!1,onSearchChange:e=>C(e??``),unsafeCSS:At});(0,J.useEffect)(()=>{ce.current!==x&&(ce.current=x,j.setComposition(j.getComposition()))},[x,j]);let fe=Dn(j),P=kt(j,e=>Mt(e,te)),pe=()=>{let e=!(w||P);T(e),Ot(j,te,e)},me=()=>{C(``),fe.close()},F=(0,J.useRef)(new Set);(0,J.useEffect)(()=>{let e=new Set(te);for(let t of F.current)e.has(t)||F.current.delete(t);let t=()=>{if(!j.isSearchOpen())for(let e of te){let t=j.getItem(e);t?.isDirectory()&&`isExpanded`in t&&t.isExpanded()?F.current.has(e)||(F.current.add(e),m(e.replace(/\/$/,``))):(t?.isDirectory()&&F.current.has(e)&&T(!1),F.current.delete(e))}};return t(),j.subscribe(t)},[te,m,j]),(0,J.useEffect)(()=>{j.setGitStatus(D.filter(e=>e.ignored).map(e=>({path:To(e),status:`ignored`})))},[D,j]),(0,J.useEffect)(()=>{if(!r)return;let e=new AbortController;return(async()=>{let t=r.split(`/`);for(let n=0;n<t.length&&!e.signal.aborted;n++)await m(t.slice(0,n).join(`/`))})(),()=>{e.abort()}},[m,r]);let he=e=>{C(e),e.trim().length===0?fe.close():fe.setValue(e)},be=()=>{g(),S.trim()&&E.refresh(),o?.()};xn({mutationId:s,refresh:()=>{g(),S.trim()&&E.refresh()},resourceKey:`files:${e}:${t}`}),(0,J.useEffect)(()=>{if(!v||ne.current===ee)return;k.current=O;let e=ne.current;if(ne.current=ee,e===null){j.resetPaths(ee);return}let t=Co(e,ee);t.length>0&&j.batch(t)},[v,O,j,ee]),(0,J.useEffect)(()=>{w&&!S.trim()&&Ot(j,te,!0)},[te,w,j,S]),(0,J.useEffect)(()=>{if(!r){A.current=null;return}let e=O.get(r);if(e===void 0){A.current=null;return}let t={path:r,revealId:i},n=A.current;if(n?.path===t.path&&n.revealId===t.revealId)return;let a=e===`directory`?`${r}/`:r,o=j.getItem(a);if(!o)return;if(j.getSelectedPaths().some(e=>e.replace(/\/$/,``)===r)&&ie.current===r){ie.current=null,A.current=t;return}ie.current=null,A.current=t,re.current=!0,C(``),j.closeSearch();for(let e of j.getSelectedPaths())j.getItem(e)?.deselect();let s=r.split(`/`),c=``;for(let e of s.slice(0,-1)){c=c?`${c}/${e}`:e;let t=j.getItem(`${c}/`)??j.getItem(c);t&&`expand`in t&&t.expand()}`expand`in o&&o.expand(),o.select(),j.scrollToPath(a,{focus:!0,offset:`center`}),queueMicrotask(()=>{re.current=!1})},[O,j,r,i]);let xe=(0,J.useRef)(null);return(0,J.useEffect)(()=>{le.current=j},[j]),(0,J.useEffect)(()=>{let e=xe.current;if(e===null)return;let t=e=>ue.handleDragStart(e),n=()=>ue.handleDragEnd();return e.addEventListener(`dragstart`,t,!0),e.addEventListener(`dragend`,n),()=>{e.removeEventListener(`dragstart`,t,!0),e.removeEventListener(`dragend`,n)}},[ue]),(0,$.jsxs)(`div`,{ref:xe,className:`flex min-h-0 flex-1 flex-col bg-background`,"data-file-browser-panel":`${e}:${t}`,onContextMenuCapture:e=>{ae.current={x:e.clientX,y:e.clientY,at:e.timeStamp}},children:[(0,$.jsxs)(`div`,{className:`flex h-10 min-h-10 shrink-0 items-center gap-1 border-b border-border/60 bg-background px-2 in-data-[preview-panel-mode=inline]:mb-1 in-data-[preview-panel-mode=inline]:h-9 in-data-[preview-panel-mode=inline]:min-h-9 in-data-[preview-panel-mode=inline]:border-b-transparent`,"data-surface-subheader":!0,children:[(0,$.jsx)(Eo,{isPending:b,onRefresh:be}),(0,$.jsx)(Do,{name:`project-files-search`,ariaLabel:`Search ${n} files`,value:fe.value,onValueChange:he,onClose:me}),te.length>0&&!c?(0,$.jsx)(h,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":w||P?`Collapse all folders`:`Expand all folders`,onClick:pe,children:(0,$.jsx)(de,{className:`size-3.5`,icon:P?N:M})}):null]}),y||E.error?(0,$.jsxs)(`button`,{type:`button`,onClick:be,className:`p-4 text-left text-xs leading-relaxed text-destructive`,children:[y??E.error,` Click to retry.`]}):null,S.trim()&&E.truncated&&!E.isPending?(0,$.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:`More matches available. Refine your search.`}):null,(!v||E.isPending)&&(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-1 text-xs text-muted-foreground`,children:`Loading files…`}),(0,$.jsx)(Et,{model:j,"aria-label":`${n} files`,className:`min-h-0 flex-1 overflow-hidden`,style:Dt(u)})]})}var ko=160,Ao=560,jo=256;function Mo(e){let t=(0,Q.c)(21),{resizable:n,children:r}=e,[i,a]=(0,J.useState)(Ao),o;t[0]===i?o=t[1]:(o={storageKey:`p4code:fileExplorerWidth`,defaultWidth:256,minWidth:ko,maxWidth:i,edge:`left`},t[0]=i,t[1]=o);let{width:s,setWidth:c,handlers:l}=Lt(o),u;t[2]===n?u=t[3]:(u=e=>{let t=e?.parentElement;if(!t||!n)return;let r=()=>a(Math.max(ko,Math.min(Ao,t.clientWidth-jo)));return r(),Ft(t,r)},t[2]=n,t[3]=u);let d=n?`border-l border-border/60`:`flex-1`,f;t[4]===d?f=t[5]:(f=D(`relative flex min-h-0 min-w-0 shrink-0 bg-background`,d),t[4]=d,t[5]=f);let p;t[6]!==n||t[7]!==s?(p=n?{[It]:`${s}px`,width:`var(${It})`}:void 0,t[6]=n,t[7]=s,t[8]=p):p=t[8];let m;t[9]!==l||t[10]!==i||t[11]!==n||t[12]!==c||t[13]!==s?(m=n?(0,$.jsx)(Rt,{handlers:l,label:`Resize file explorer`,tabIndex:0,"aria-valuenow":s,"aria-valuemin":ko,"aria-valuemax":i,onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t;bb39:switch(e.key){case`ArrowLeft`:t=s+16;break bb39;case`ArrowRight`:t=s-16;break bb39;case`Home`:t=ko;break bb39;case`End`:t=i;break bb39;default:return}e.preventDefault(),e.stopPropagation(),c(t)}}):null,t[9]=l,t[10]=i,t[11]=n,t[12]=c,t[13]=s,t[14]=m):m=t[14];let h;return t[15]!==r||t[16]!==u||t[17]!==f||t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`aside`,{ref:u,"aria-label":`File explorer`,className:f,style:p,children:[m,r]}),t[15]=r,t[16]=u,t[17]=f,t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function No(e,t){return e.slice(e.lastIndexOf(`/`)+1)||t}function Po(e){let t=(0,Q.c)(12),n=e.current?`font-medium text-foreground`:`text-muted-foreground`,r;t[0]===n?r=t[1]:(r=D(`block max-w-40 truncate rounded-sm px-0.5`,n),t[0]=n,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{className:r}),t[2]=r,t[3]=i);let a;t[4]!==e.label||t[5]!==i?(a=(0,$.jsx)(_t,{render:i,children:e.label}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6];let o;t[7]===e.pathLabel?o=t[8]:(o=(0,$.jsx)(vt,{side:`top`,children:e.pathLabel}),t[7]=e.pathLabel,t[8]=o);let s;return t[9]!==a||t[10]!==o?(s=(0,$.jsxs)(yt,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s}function Fo(e){let t=(0,Q.c)(40),n=_n(e.environmentId,e.cwd,e.directoryPath,e.workspaceMutationId),{resolvedTheme:r}=ye(),i;t[0]===n.data?.entries?i=t[1]:(i=n.data?.entries??[],t[0]=n.data?.entries,t[1]=i);let a=i,o=n.data?.truncated??!1,s;t[2]!==a||t[3]!==e.directoryPath?(s=vo(a,e.directoryPath),t[2]=a,t[3]=e.directoryPath,t[4]=s):s=t[4];let c=s,l=n.data!==null,d,f,p,h,g;if(t[5]!==e){let n=yo(e.directoryPath),r=e.directoryPath!==e.rootPath&&n!==null&&(e.rootPath===``||n===e.rootPath||n.startsWith(`${e.rootPath}/`));d=S,f=`start`,p=`bottom`,h=t=>{t.key===`ArrowLeft`&&r&&n!==null&&(t.preventDefault(),t.stopPropagation(),e.onDirectoryChange(n))},g=r&&n!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(m,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(n),children:[(0,$.jsx)(x,{}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`Back to `,No(n,e.projectName)]})]}),(0,$.jsx)(C,{})]}):null,t[5]=e,t[6]=d,t[7]=f,t[8]=p,t[9]=h,t[10]=g}else d=t[6],f=t[7],p=t[8],h=t[9],g=t[10];let _;t[11]!==c||t[12]!==l||t[13]!==n.data||t[14]!==n.error||t[15]!==n.isPending||t[16]!==n.refresh||t[17]!==o||t[18]!==e||t[19]!==r?(_=n.isPending&&n.data===null?(0,$.jsxs)(m,{disabled:!0,children:[(0,$.jsx)(he,{}),`Loading folder…`]}):n.error&&n.data===null?(0,$.jsxs)(m,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(vn,{refreshing:n.isPending}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Retry loading folder`})]}):!l&&!o?(0,$.jsx)(m,{disabled:!0,children:`This folder is no longer available.`}):c.length===0?(0,$.jsx)(m,{disabled:!0,children:o?`No entries from this folder are available in the partial workspace index.`:`This folder is empty.`}):(0,$.jsx)(w,{value:e.currentFilePath,onValueChange:t=>{e.onOpenChange(!1),e.onOpenFile(t)},children:c.map(t=>{let n=t.kind===`file`&&t.path===e.currentFilePath,i=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sn,{pathValue:t.path,kind:t.kind,theme:r}),(0,$.jsxs)(yt,{children:[(0,$.jsx)(_t,{render:(0,$.jsx)(`span`,{className:D(`min-w-0 flex-1 truncate`,t.ignored&&`text-muted-foreground`)}),children:t.label}),(0,$.jsx)(vt,{side:`right`,children:t.path})]})]});return t.kind===`directory`?(0,$.jsxs)(m,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(t.path),children:[i,(0,$.jsx)(k,{})]},t.path):(0,$.jsx)(v,{value:t.path,closeOnClick:!0,"aria-current":n?`page`:void 0,children:(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:i})},t.path)})}),t[11]=c,t[12]=l,t[13]=n.data,t[14]=n.error,t[15]=n.isPending,t[16]=n.refresh,t[17]=o,t[18]=e,t[19]=r,t[20]=_):_=t[20];let y;t[21]!==e.directoryPath||t[22]!==_?(y=(0,$.jsx)(u,{children:_},e.directoryPath),t[21]=e.directoryPath,t[22]=_,t[23]=y):y=t[23];let b;t[24]!==n.data||t[25]!==n.error||t[26]!==n.isPending||t[27]!==n.refresh?(b=n.error&&n.data!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(C,{}),(0,$.jsxs)(m,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(vn,{refreshing:n.isPending}),`Refresh failed — retry`]})]}):null,t[24]=n.data,t[25]=n.error,t[26]=n.isPending,t[27]=n.refresh,t[28]=b):b=t[28];let T;t[29]===o?T=t[30]:(T=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(C,{}),(0,$.jsx)(m,{disabled:!0,children:`Some workspace entries are not shown.`})]}):null,t[29]=o,t[30]=T);let E;return t[31]!==d||t[32]!==f||t[33]!==p||t[34]!==h||t[35]!==g||t[36]!==y||t[37]!==b||t[38]!==T?(E=(0,$.jsxs)(d,{align:f,side:p,onKeyDown:h,children:[g,y,b,T]}),t[31]=d,t[32]=f,t[33]=p,t[34]=h,t[35]=g,t[36]=y,t[37]=b,t[38]=T,t[39]=E):E=t[39],E}function Io(e){let t=(0,Q.c)(28),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(e.crumb.path),o;t[0]===e.crumb.path?o=t[1]:(o=()=>{r(!1),a(e.crumb.path)},t[0]=e.crumb.path,t[1]=o);let s;t[2]!==e.crumb.path||t[3]!==e.relativePath?(s=[e.crumb.path,e.relativePath],t[2]=e.crumb.path,t[3]=e.relativePath,t[4]=s):s=t[4],(0,J.useEffect)(o,s);let c;t[5]===e.crumb.path?c=t[6]:(c=t=>{r(t),t&&a(e.crumb.path)},t[5]=e.crumb.path,t[6]=c);let l=c,u=`Browse ${e.crumb.label}`,d;t[7]===u?d=t[8]:(d=(0,$.jsx)(`button`,{type:`button`,"aria-label":u,className:`relative mx-0.5 flex h-5 w-4 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground/60 outline-none pointer-coarse:after:absolute pointer-coarse:after:-inset-3 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring data-popup-open:bg-accent data-popup-open:text-foreground`}),t[7]=u,t[8]=d);let m;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(k,{className:`size-3.5`}),t[9]=m):m=t[9];let h;t[10]===d?h=t[11]:(h=(0,$.jsx)(p,{render:d,children:m}),t[10]=d,t[11]=h);let g;t[12]!==i||t[13]!==l||t[14]!==n||t[15]!==e.crumb.path||t[16]!==e.cwd||t[17]!==e.environmentId||t[18]!==e.onOpenFile||t[19]!==e.projectName||t[20]!==e.relativePath||t[21]!==e.workspaceMutationId?(g=n?(0,$.jsx)(Fo,{cwd:e.cwd,currentFilePath:e.relativePath,directoryPath:i,environmentId:e.environmentId,onDirectoryChange:a,onOpenChange:l,onOpenFile:e.onOpenFile,projectName:e.projectName,rootPath:e.crumb.path,workspaceMutationId:e.workspaceMutationId}):null,t[12]=i,t[13]=l,t[14]=n,t[15]=e.crumb.path,t[16]=e.cwd,t[17]=e.environmentId,t[18]=e.onOpenFile,t[19]=e.projectName,t[20]=e.relativePath,t[21]=e.workspaceMutationId,t[22]=g):g=t[22];let _;return t[23]!==l||t[24]!==n||t[25]!==h||t[26]!==g?(_=(0,$.jsxs)(f,{open:n,onOpenChange:l,children:[h,g]}),t[23]=l,t[24]=n,t[25]=h,t[26]=g,t[27]=_):_=t[27],_}function Lo(e){let t=(0,Q.c)(17),n;t[0]===e?n=t[1]:(n=()=>e.onNavigate(e.crumb.path),t[0]=e,t[1]=n);let r=e.descendant?`text-muted-foreground/70`:`text-muted-foreground`,i;t[2]===r?i=t[3]:(i=D(`relative block max-w-40 cursor-pointer rounded-sm px-0.5 text-left outline-none pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,r),t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==i?(a=(0,$.jsx)(`button`,{type:`button`,onClick:n,className:i}),t[4]=n,t[5]=i,t[6]=a):a=t[6];let o;t[7]===e.crumb.label?o=t[8]:(o=(0,$.jsx)(`span`,{className:`block truncate`,children:e.crumb.label}),t[7]=e.crumb.label,t[8]=o);let s;t[9]!==a||t[10]!==o?(s=(0,$.jsx)(_t,{render:a,children:o}),t[9]=a,t[10]=o,t[11]=s):s=t[11];let c=e.crumb.path||e.projectName,l;t[12]===c?l=t[13]:(l=(0,$.jsx)(vt,{side:`top`,children:c}),t[12]=c,t[13]=l);let u;return t[14]!==s||t[15]!==l?(u=(0,$.jsxs)(yt,{children:[s,l]}),t[14]=s,t[15]=l,t[16]=u):u=t[16],u}function Ro(e){let t=(0,Q.c)(21),n;t[0]===e.relativePath?n=t[1]:(n=A(e.relativePath),t[0]=e.relativePath,t[1]=n);let r=n,i;t[2]!==e.projectName||t[3]!==e.trail?(i=uo(e.projectName,e.trail),t[2]=e.projectName,t[3]=e.trail,t[4]=i):i=t[4];let a=i,o;t[5]===e.relativePath?o=t[6]:(o=fo(e.relativePath),t[5]=e.relativePath,t[6]=o);let s=o,c;t[7]===s?c=t[8]:(c=e=>e.path===s,t[7]=s,t[8]=c);let l=a.findIndex(c),u;if(t[9]!==a||t[10]!==l||t[11]!==r||t[12]!==e){let n;t[14]!==a.length||t[15]!==l||t[16]!==r||t[17]!==e?(n=(t,n)=>{let i=n===l;return(0,$.jsxs)(`li`,{className:`flex min-w-0 shrink-0 items-center`,"data-file-crumb":!0,"data-current-file-crumb":i,children:[i?(0,$.jsx)(`span`,{"aria-current":`page`,children:(0,$.jsx)(Po,{current:!0,label:t.label,pathLabel:t.path||e.projectName})}):r&&!po(t.path)?(0,$.jsx)(Po,{label:t.label,pathLabel:t.path}):(0,$.jsx)(Lo,{crumb:t,descendant:n>l,onNavigate:e.onNavigateFolder,projectName:e.projectName}),n===a.length-1?null:r?(0,$.jsx)(k,{"aria-hidden":!0,className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):(0,$.jsx)(Io,{...e,crumb:t})]},t.path||`project`)},t[14]=a.length,t[15]=l,t[16]=r,t[17]=e,t[18]=n):n=t[18],u=a.map(n),t[9]=a,t[10]=l,t[11]=r,t[12]=e,t[13]=u}else u=t[13];let d;return t[19]===u?d=t[20]:(d=(0,$.jsx)(`nav`,{"aria-label":`File path`,className:`flex h-full`,children:(0,$.jsx)(`ol`,{className:`flex items-center`,children:u})}),t[19]=u,t[20]=d),d}function zo(e){let t=(0,Q.c)(16),n;t[0]===e.relativePath?n=t[1]:(n=e.relativePath.lastIndexOf(`/`),t[0]=e.relativePath,t[1]=n);let r;t[2]===e.relativePath?r=t[3]:(r=e.relativePath.lastIndexOf(`\\`),t[2]=e.relativePath,t[3]=r);let i=Math.max(n,r),a;t[4]!==i||t[5]!==e.cwd||t[6]!==e.relativePath?(a=i>=0?Ee(e.relativePath.slice(0,i),e.cwd):e.cwd,t[4]=i,t[5]=e.cwd,t[6]=e.relativePath,t[7]=a):a=t[7];let o=a,s;t[8]===e.text?s=t[9]:(s=Wt(e.text),t[8]=e.text,t[9]=s);let c;return t[10]!==o||t[11]!==e.cwd||t[12]!==e.onTaskListChange||t[13]!==e.threadRef||t[14]!==s?(c=(0,$.jsx)(me,{text:s,cwd:e.cwd,imageBaseDir:o,threadRef:e.threadRef,className:`mx-auto max-w-4xl px-6 py-5`,onTaskListChange:e.onTaskListChange}),t[10]=o,t[11]=e.cwd,t[12]=e.onTaskListChange,t[13]=e.threadRef,t[14]=s,t[15]=c):c=t[15],c}function Bo({root:e,editor:t,onDismiss:n}){n(),t.setSelections([]);let r=e.querySelector(`diffs-container`)?.shadowRoot?.activeElement;r instanceof HTMLElement&&r.blur()}function Vo(e){return e.querySelector(`diffs-container`)?.shadowRoot?.activeElement?.hasAttribute(`data-content`)===!0}function Ho({root:e,editor:t,isBlocked:n,onDismiss:r}){let i=i=>{n()||i.composedPath().includes(e)||Bo({root:e,editor:t,onDismiss:r})},a=i=>{i.key===`Escape`&&!n()&&Vo(e)&&(i.preventDefault(),i.stopImmediatePropagation(),Bo({root:e,editor:t,onDismiss:r}))};return document.addEventListener(`pointerdown`,i,!0),document.addEventListener(`keydown`,a,!0),()=>{document.removeEventListener(`pointerdown`,i,!0),document.removeEventListener(`keydown`,a,!0)}}function Uo(e){let t=e.renderedLine===void 0?e.fileTop+e.estimatedLine.top:e.scrollTop+e.renderedLine.top-e.viewportTop,n=e.renderedLine?.height??e.estimatedLine.height,r=Math.max(0,t-Math.max(0,(e.viewportHeight-n)/2));return Math.min(r,Math.max(0,e.scrollHeight-e.viewportHeight))}function Wo(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`${e.length}:${(t>>>0).toString(36)}`}function Go(e,t,n){return`${e}:${t}:${Wo(n)}`}function Ko(e,t){return e===null||e===`.`||ae(e,t)===`.`?null:e}var qo=e=>/\.(?:md|mdx)$/i.test(e);function Jo(e){switch(e.failure){case`path_not_file`:return`The path is a directory or special file, not a regular file.`;case`binary_file`:return`The file is binary and cannot be displayed as text.`;case`workspace_path_outside_root`:return`The requested path is outside the workspace.`;case`resolved_path_outside_root`:return`The path resolves to a location outside the workspace.`;case`operation_failed`:return e.operation===`realpath-workspace-root`?`The workspace folder could not be accessed.`:`The file could not be accessed or read. It may be missing or inaccessible.`;default:return e.message}}function Yo(e){return e.attachmentOpen||e.relativePath&&A(e.relativePath)?!1:e.explorerOpen||e.relativePath===null}function Xo(e,t,n){return t<0||e[t]!==`[`||!/[ xX]/.test(e[t+1]??``)||e[t+2]!==`]`?e:`${e.slice(0,t+1)}${n?`x`:` `}${e.slice(t+2)}`}function Zo(e){return e.draft?{_tag:`draft-workspace-file`,cwd:e.workspaceRoot,path:e.absolutePath}:{_tag:e.kind,threadId:e.threadRef.threadId,path:e.absolutePath}}var Qo=class{options;timer=null;latestContents=``;latestRevision=0;confirmedRevision=0;lastChangeAt=0;saving=!1;disposed=!1;constructor(e){this.options=e}change(e){this.disposed||(this.latestContents=e,this.latestRevision+=1,this.lastChangeAt=Date.now(),this.options.onPendingChange(!0),this.schedule(this.options.debounceMs))}dispose(){this.disposed=!0,this.clearTimer(),this.latestRevision>0&&this.persistLatest()}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.persistLatest()},e)}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}async persistLatest(){if(this.saving||this.latestRevision===this.confirmedRevision||this.options.canPersist?.()===!1)return;this.saving=!0;let e=this.latestContents,t=this.latestRevision,n=(await this.options.persist(e))._tag===`Success`,r=!1;if(n&&(this.confirmedRevision=t,r=this.options.onConfirmed(e)!==!1),this.saving=!1,t===this.latestRevision){r&&this.options.onPendingChange(!1);return}let i=Math.max(0,this.options.debounceMs-(Date.now()-this.lastChangeAt));this.disposed?this.persistLatest():this.schedule(i)}},$o=500;function es(e){let t=(0,Q.c)(17),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=Ce(n,E),s=Te(ie.writeFile),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,J.createRef)(),t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>l.current?.change(e),t[1]=u):u=t[1];let d;t[2]!==r||t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==s?(d={change:u,setup:()=>{let e=new Qo({debounceMs:$o,canPersist:()=>we(n,E),onPendingChange:e=>a(i,e),persist:e=>s({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),onConfirmed:e=>gn(n,r,i,e)});return l.current=e,()=>{l.current=null,e.dispose()}}},t[2]=r,t[3]=n,t[4]=a,t[5]=i,t[6]=s,t[7]=d):d=t[7];let f=d,p;t[8]===f?p=t[9]:(p=[f],t[8]=f,t[9]=p),(0,J.useEffect)(f.setup,p);let m,h;return t[10]!==o||t[11]!==r||t[12]!==n||t[13]!==i||t[14]!==f?(m=()=>{if(!o)return;let e=!1;return queueMicrotask(()=>{if(e)return;let t=hn(n,r,i);t&&f.change(t.contents)}),()=>{e=!0}},h=[o,r,n,i,f],t[10]=o,t[11]=r,t[12]=n,t[13]=i,t[14]=f,t[15]=m,t[16]=h):(m=t[15],h=t[16]),(0,J.useEffect)(m,h),f}var ts=`p4code.fileExplorerOpen`,ns=`p4code.renderMarkdown`,rs=`p4code.renderBrowserFile`,is=`p4code.renderTable`;function as(e){let t=(0,Q.c)(28),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Zo({kind:`workspace-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=en(e.environmentId,r),[a,o]=(0,J.useState)(null),s;t[5]!==i._tag||t[6]!==i.url||t[7]!==e.workspaceMutationId?(s=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[5]=i._tag,t[6]=i.url,t[7]=e.workspaceMutationId,t[8]=s):s=t[8];let c=s,l=i._tag===`Success`?`${i.url}${c}`:null,u=e.alt,d;t[9]!==e.absolutePath||t[10]!==e.workspaceRoot?(d=gt(e.absolutePath,e.workspaceRoot),t[9]=e.absolutePath,t[10]=e.workspaceRoot,t[11]=d):d=t[11];let f;t[12]!==e.environmentId||t[13]!==r?(f={environmentId:e.environmentId,resource:r},t[12]=e.environmentId,t[13]=r,t[14]=f):f=t[14];let p;t[15]!==l||t[16]!==e.alt||t[17]!==d||t[18]!==f?(p={kind:`image`,name:u,src:l,reference:d,asset:f},t[15]=l,t[16]=e.alt,t[17]=d,t[18]=f,t[19]=p):p=t[19];let m=p;if(i._tag===`Failure`||l!==null&&a===l){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load workspace image.`}),t[20]=e):e=t[20];let n;return t[21]===m?n=t[22]:(n=(0,$.jsx)(pe,{source:m,children:e}),t[21]=m,t[22]=n),n}let h;return t[23]!==m||t[24]!==i._tag||t[25]!==l||t[26]!==e.alt?(h=i._tag===`Success`&&l!==null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,$.jsx)(pe,{source:m,children:(0,$.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:l,alt:e.alt,onError:()=>o(l)})})}):(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(he,{size:`lg`})}),t[23]=m,t[24]=i._tag,t[25]=l,t[26]=e.alt,t[27]=h):h=t[27],h}function os(e){let t=(0,Q.c)(19),n=gt(e.absolutePath,e.workspaceRoot).relativePath===void 0?`media-file`:`workspace-file`,r;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot||t[4]!==n?(r=Zo({kind:n,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n,t[5]=r):r=t[5];let i=r,a=en(e.environmentId,i),o;t[6]!==a._tag||t[7]!==a.url||t[8]!==e.workspaceMutationId?(o=e.workspaceMutationId===null?``:`${a._tag===`Success`&&a.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[6]=a._tag,t[7]=a.url,t[8]=e.workspaceMutationId,t[9]=o):o=t[9];let s=o;if(a._tag===`Failure`){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load file preview.`}),t[10]=e):e=t[10],e}if(a._tag!==`Success`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(he,{size:`lg`})}),t[11]=e):e=t[11],e}let c=`${a.url}${s}`,l=`${e.environmentId}:${i._tag}:${e.threadRef.threadId}:${e.absolutePath}:${e.workspaceMutationId}`,u=e.title,d;t[12]===e.absolutePath?d=t[13]:(d=qt(e.absolutePath),t[12]=e.absolutePath,t[13]=d);let f;return t[14]!==e.title||t[15]!==c||t[16]!==l||t[17]!==d?(f=(0,$.jsx)(Gt,{src:c,documentKey:l,title:u,pdf:d}),t[14]=e.title,t[15]=c,t[16]=l,t[17]=d,t[18]=f):f=t[18],f}function ss(e){let t=(0,Q.c)(36),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Zo({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=en(e.environmentId,r),a=tn(e.environmentId,r),o=e.workspaceMutationId,s;t[5]!==e.environmentId||t[6]!==r?(s=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=s):s=t[7];let c;t[8]===a?c=t[9]:(c=()=>{a().catch(cs)},t[8]=a,t[9]=c);let l;t[10]!==e.workspaceMutationId||t[11]!==s||t[12]!==c?(l={mutationId:o,resourceKey:s,refresh:c},t[10]=e.workspaceMutationId,t[11]=s,t[12]=c,t[13]=l):l=t[13],xn(l);let u;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(u=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=u):u=t[17];let d=u,f=i._tag===`Success`?`${i.url}${d}`:null,p=i._tag===`Failure`,m=e.name,h=e.workspaceMutationId,g=e.name,_;t[18]!==e.absolutePath||t[19]!==e.workspaceRoot?(_=gt(e.absolutePath,e.workspaceRoot),t[18]=e.absolutePath,t[19]=e.workspaceRoot,t[20]=_):_=t[20];let v;t[21]!==e.environmentId||t[22]!==r?(v={environmentId:e.environmentId,resource:r},t[21]=e.environmentId,t[22]=r,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==e.name||t[26]!==_||t[27]!==v?(y={kind:`video`,name:g,src:f,reference:_,asset:v},t[24]=f,t[25]=e.name,t[26]=_,t[27]=v,t[28]=y):y=t[28];let b;return t[29]!==f||t[30]!==e.name||t[31]!==e.workspaceMutationId||t[32]!==a||t[33]!==y||t[34]!==p?(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,$.jsx)(P,{src:f,sourceFailed:p,label:m,revision:h,preload:`metadata`,className:`flex h-full min-h-0 w-full max-w-5xl items-center justify-center`,onRetry:a,actionsSource:y})}),t[29]=f,t[30]=e.name,t[31]=e.workspaceMutationId,t[32]=a,t[33]=y,t[34]=p,t[35]=b):b=t[35],b}function cs(){}function ls(e){let t=(0,Q.c)(27),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Zo({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=en(e.environmentId,r),a=tn(e.environmentId,r),[o,s]=(0,J.useState)(null),c=e.workspaceMutationId,l;t[5]!==e.environmentId||t[6]!==r?(l=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=l):l=t[7];let u;t[8]===a?u=t[9]:(u=()=>{a().catch(ds)},t[8]=a,t[9]=u);let d;t[10]!==e.workspaceMutationId||t[11]!==l||t[12]!==u?(d={mutationId:c,resourceKey:l,refresh:u},t[10]=e.workspaceMutationId,t[11]=l,t[12]=u,t[13]=d):d=t[13],xn(d);let f;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(f=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=f):f=t[17];let p=f,m=i._tag===`Success`?`${i.url}${p}`:null;if(i._tag===`Failure`||m!==null&&o===m){let e;return t[18]===a?e=t[19]:(e=(0,$.jsx)(zt,{message:`Unable to load audio.`,onRetry:()=>{s(null),a().catch(us)}}),t[18]=a,t[19]=e),e}if(m===null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Xt,{}),t[20]=e):e=t[20],e}let h;t[21]===m?h=t[22]:(h=()=>s(m),t[21]=m,t[22]=h);let g;return t[23]!==e.name||t[24]!==h||t[25]!==m?(g=(0,$.jsx)(Ut,{src:m,name:e.name,onError:h}),t[23]=e.name,t[24]=h,t[25]=m,t[26]=g):g=t[26],g}function us(){}function ds(){}function fs(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function ps(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${Ht}]`))e.removeAttribute(Ht);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(Ht,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(Ht,``))}var ms=30,hs=20,gs=2;function _s(e,t,n){let r=(0,Q.c)(5),[i]=(0,J.useState)(vs),a;return r[0]!==e||r[1]!==t||r[2]!==n||r[3]!==i?(a=(r,a,o)=>{if(e===null)return;let s=i.get(e),c=s??{frameId:null,cancelGuard:null,handledRequestId:null,latestRequestId:null};s||i.set(e,c);let l=()=>{c.frameId!==null&&(cancelAnimationFrame(c.frameId),c.frameId=null),c.cancelGuard?.()};if(o===`unmount`){l();return}let u=a.file?.contents;if(ps(r,t===null||u===void 0?null:fs(u,t)),!(a instanceof qe))return;if(c.latestRequestId!==n&&(l(),c.latestRequestId=n,c.handledRequestId=null),t===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);if(!d||(r.style.minHeight=`${Math.ceil(Math.max(a.height,d.clientHeight))}px`,c.handledRequestId===n||c.frameId!==null))return;let f=e=>{let t=a.getLinePosition(e);if(!t)return null;let n=d.getBoundingClientRect(),i=d.scrollTop+r.getBoundingClientRect().top-n.top,o=(r.shadowRoot??r).querySelector(`[data-line="${e}"]`)?.getBoundingClientRect();return Uo({scrollTop:d.scrollTop,scrollHeight:d.scrollHeight,viewportTop:n.top,viewportHeight:d.clientHeight,fileTop:i,estimatedLine:t,...o&&o.height>0?{renderedLine:{top:o.top,height:o.height}}:{}})},p=e=>{let t=hs,n=null,r=()=>{n!==null&&(cancelAnimationFrame(n),n=null),d.removeEventListener(`wheel`,r),d.removeEventListener(`touchstart`,r),d.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`keydown`,r,!0),c.cancelGuard===r&&(c.cancelGuard=null)};d.addEventListener(`wheel`,r,{passive:!0}),d.addEventListener(`touchstart`,r,{passive:!0}),d.addEventListener(`pointerdown`,r,{passive:!0,capture:!0}),window.addEventListener(`keydown`,r,!0);let i=()=>{if(n=null,--t,t<=0||!d.isConnected){r();return}let a=f(e);a!==null&&Math.abs(d.scrollTop-a)>gs&&(d.scrollTop=a),n=requestAnimationFrame(i)};n=requestAnimationFrame(i),c.cancelGuard=r},m=e=>{c.frameId=requestAnimationFrame(()=>{if(c.frameId=null,c.latestRequestId!==n||!r.isConnected)return;let i=a.file?.contents,o=i===void 0?null:fs(i,t),s=o===null?null:f(o);o===null||s===null?e<ms&&m(e+1):(ps(r,o),d.scrollTop=s,c.handledRequestId=n,p(o))})};m(0)},r[0]=e,r[1]=t,r[2]=n,r[3]=i,r[4]=a):a=r[4],a}function vs(){return new Map}var ys=(e,t,n)=>new ao(e,t,n);function bs(e,t,n,r){return{name:n,contents:r,cacheKey:`editor:${e}:${Go(t,n,r)}`}}function xs(e,t){if(e?.isWorkingPool()!==!0||(t.lang??bn(t.name))===`text`)return!1;let n=1;for(let e=t.contents.indexOf(`
31
+ `)&&(i=n,a=[t.offsetAt(e.start),t.offsetAt(e.end)])}}let o=([e,n],r)=>{let i=Br(t,e,n);this.#Wt([i]),this.#Pe(X(i).line),this.#gt(!0),this.#pe=r},s=new ot({textDocument:t,containerElement:n,defaultQuery:i,mode:e,initialMatch:a,scrollToMatch:o,applyReplace:e=>{if(e.length===0)return;let n=t.applyEdits(e.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),!0,this.#se);n!==void 0&&this.#dn(n,void 0,this.#pn(n),{skipSearchRefresh:!0})},onUpdate:(e,n)=>{if(e.length===0){this.#ce=void 0,this.#Wt(this.#se??[]);return}if(this.#ce=e,n?.syncSelection===!1){this.#Wt(this.#se??[]);let n=this.#se?.at(-1);if(n!==void 0){let r=t.offsetAt(n.start),i=t.offsetAt(n.end);for(let t of e)if(t[0]===r&&t[1]===i)return t}return}let r=this.#se?.at(-1),i=0,a;r!==void 0&&(i=t.offsetAt(r.start));for(let t of e)if(t[0]>=i){a=t;break}return a===void 0?this.#Wt(this.#se??[]):o(a,!0),a},onClose:()=>{this.#G=void 0,this.#pe=!1,this.#ce=void 0,this.#Wt(this.#se??[])}});this.#G=s,this.#pe=!1}#en(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?``:ti(e,t)}#tn(){let e=this.#n?.document,t=this.#se;return e===void 0||t===void 0?[]:ei(e,t)}#nn(e,t,n){e!==null&&(e.setData(`text`,t),n.length>1&&e.setData(io,JSON.stringify(n)))}#rn(){let e=this.#n?.document,t=this.#se;if(e===void 0||t===void 0||t.length===0)return``;if(t.some(e=>Y(e))){let n=oi(e,t);return this.#in(n.edits,n.nextSelectionOffsets),n.text}let n=ti(e,t);return this.#an(``,void 0,!0),n}#in(e,t){let n=this.#n?.document,r=this.#se;if(n===void 0||r===void 0||e.length===0)return;let i=n.applyResolvedEdits(e,!0,r,void 0,!0);if(i===void 0)return;let a=t.map(e=>{let t=n.positionAt(e);return{start:t,end:t,direction:0}});n.setLastUndoSelectionsAfter(a),this.#dn(i,a,this.#pn(i))}#an(e,t=this.#se,n=!1,r=`selection`){if(t===void 0)return;let i=this.#n?.document,a=t.at(-1);if(i===void 0||a===void 0)return;let{nextSelections:o,change:s}=Array.isArray(e)&&e.length===t.length?kr(i,t,e,this.#R,n,r):Er(i,t,{start:i.offsetAt(a.start),end:i.offsetAt(a.end),text:Array.isArray(e)?e.join(i.eol):e},this.#R,void 0,n);s!==void 0&&this.#dn(s,o,this.#pn(s))}#on(e=!1){let t=this.#se,n=this.#n?.document;if(t===void 0||n===void 0)return;let{nextSelections:r,change:i}=Lr(n,t,e,this.#R,this.#r.tabSize);i!==void 0&&this.#dn(i,r,this.#pn(i))}#sn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Pr(t,e,this.#Le?(e,t)=>{let n=this.#Sn(e);for(let e=0;e+1<n.length;e++){let r=n[e],i=n[e+1];if(t>=r&&t<=i)return r}return 0}:void 0,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#cn(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Fr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#ln(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Nr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#un(){let e=this.#se,t=this.#n?.document;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=Mr(t,e,this.#R);r!==void 0&&this.#dn(r,n,this.#pn(r))}#dn(e,t,n,r){this.#xe!=null&&this.#Rt(!0);let i=this.#n?.document;if(i!==void 0&&this.#W!==void 0)for(let t of this.#W)t.anchorOffset=Vr(t.anchorOffset,e.changes),t.focusOffset=Vr(t.focusOffset,e.changes),t.caret.anchor=i.positionAt(t.anchorOffset),t.caret.focus=i.positionAt(t.focusOffset);if(e.lineDelta!==0||this.#Le)for(let t of this.#m.keys())t>=e.startLine&&this.#m.delete(t);if(this.#h.size>0){if(e.lineDelta===0&&(e.changedLineRanges.length===1||e.changedLineChanges?.every(([,,e])=>e===0)===!0))for(let[t,n]of e.changedLineRanges)for(let e=t;e<=n;e++)this.#h.delete(e);else for(let t of this.#h.keys())t>=e.startLine&&this.#h.delete(t)}this.#_=void 0;let a=this.#V,o;if(a!==void 0&&t!==void 0&&t.length>0){let n=t.at(-1),r=a.startingLine+a.totalLines;if(n.end.line>=r){let t=n.end.line-a.startingLine+1,i=this.#H===void 0||this.#H===1/0?1/0:this.#H*Za;e.startLine<=r&&t<=i&&this.#Me(n.end.line)?(n.end.line>r&&(o=!0),a={...a,totalLines:t},this.#V=a):o=!0}}if(this.#I&&this.#i!=null&&this.#w!=null?this.#ct(e,n,a,o):i!=null&&(this.#P?.(i,n),n!=null&&(this.#R=n)),t!=null&&this.#Wt(t),this.#M?.__acknowledgeDocumentUpdate(),this.#De(),this.#Vt(e,r?.editSource??`user`),this.#Bt(),this.#fn(e.changes,n??this.#R),r?.skipSearchRefresh!==!0&&this.#G!==void 0&&this.#ce!==void 0&&this.#G.updateMatches({syncSelection:!1}),t!=null&&r?.skipFocus!==!0){let e=t.at(-1);if(e!==void 0&&this.#Pe(X(e).line),this.#A!==void 0)requestAnimationFrame(()=>{this.#A?.scrollIntoView({block:`nearest`,inline:`nearest`})});else if(t.length>0){let e=X(t.at(-1));this.#vt(e.line,e.character)}this.focus({preventScroll:!0})}}#fn(e,t){let n=this.getFile(),r=this.#F;n!=null&&r!=null&&r(e,n,t)}#pn(e){if(this.#R!=null){let t=nr(e,this.#R);if(t!=null)return this.#n?.document?.setLastUndoLineAnnotations(this.#R,t),t}}#mn(){let e=this.#w;if(e===void 0)return[];let t=[];for(let n of e.children){let e=n,r=e.dataset.lineType,i=G(e);if(i===void 0||r===void 0||!Rr(r))continue;let a=i-1,o=t.at(-1);o!==void 0&&a<=o[1]+1?o[1]=Math.max(o[1],a):t.push([a,a])}return t}#hn(e){let t=this.#V;return t==null||e>=t.startingLine&&e<t.startingLine+t.totalLines}#gn(e){let t=this.#g.get(e);if(t!==void 0)return t??void 0;let n=this.#V;if(!this.#hn(e))return;let r=this.#w;if(r!==void 0){if(n!==void 0){let{startingLine:i}=n,{children:a}=r;for(let n=e-i;n<=a.length;n++){let r=a[n];if(r===void 0)break;let i=G(r),o=r.dataset.lineType;if(i!==void 0&&i===e+1&&o!==void 0&&Rr(o)){t=r;break}}}return t??=r.querySelector(`[data-line="${e+1}"]`+(this.#Fe===`unified`?`:not([data-line-type="change-deletion"])`:``)),t!==void 0&&this.#g.set(e,t),t??void 0}}#_n(){if(this.#C===void 0)return 0;if(this.#f===void 0){let e=this.#w?.parentElement?.style.getPropertyValue(`--diffs-column-number-width`);this.#f=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseInt(e.slice(0,-2),10):this.#C.offsetWidth}return this.#f}#vn(){if(this.#w===void 0)return 0;if(this.#p===void 0){let e=this.#w.parentElement?.style.getPropertyValue(`--diffs-column-content-width`);this.#p=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseFloat(e.slice(0,-2)):this.#w.offsetWidth}return this.#p}#yn(e){let t=this.#m.get(e);if(t!==void 0)return t;let n=this.#gn(e);if(n===void 0)return-1;let r=n.offsetTop+this.#r.paddingTop;return r+=this.#$e?.top??0,this.#m.set(e,r),r}#bn(e,t){if(this.#_!==void 0&&this.#_[0]===e&&this.#_[1]===t)return[this.#_[2],this.#_[3]];let n=this.#n?.document?.getLineText(e),r=this.#_n()+this.#r.ch;if(n===void 0||n.length===0||t<=0)return[r+(this.#$e?.left??0),0];let i=za(n,Math.min(t,n.length)),a=n.slice(0,i),o=Va(a,this.#r.tabSize),s=0,c=0;if(s=o===-1?r+this.#r.measureTextWidth(a):r+o*this.#r.ch,this.#Le){let t=this.#vn();if(2*this.#r.ch+this.#r.measureTextWidth(n)>t){let t=this.#xn(e);if(t==null)return[s+(this.#$e?.left??0),0];for(let e=0;e+1<t.length;e++){let a=t[e];if(i<=t[e+1]){c=e;let t=n.slice(a,i),o=Va(t,this.#r.tabSize);s=o===-1?r+this.#r.measureTextWidth(t):r+o*this.#r.ch;break}}}s+=this.#$e?.left??0}return this.#_===void 0?this.#_=[e,t,s,c]:(this.#_[0]=e,this.#_[1]=t,this.#_[2]=s,this.#_[3]=c),[s,c]}#xn(e){let t=this.#h.get(e);if(t!==void 0)return t;this.#h.size>=Qa&&this.#h.clear();let n=this.#n?.document?.getLineText(e);if(n===void 0||n.length===0){let t=new Uint32Array([0]);return this.#h.set(e,t),t}let r=this.#w;if(r==null||!r.isConnected)return;let i=W(`div`,{style:{position:`absolute`,top:`0`,left:`0`,width:`100%`,boxSizing:`border-box`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,font:`inherit`,paddingInline:`1ch`,tabSize:this.#r.tabSize.toString()},textContent:n},r),a=i.firstChild,o=document.createRange(),s=[];try{let t=i.getBoundingClientRect();if(t.width===0)return;let r=Ba(n),c=t.left+this.#r.ch,l=r===void 0?n.length:r.length-1,u=e=>r===void 0?e:r[e],d=e=>{o.setStart(a,u(e)),o.setEnd(a,u(e+1));let t=o.getClientRects();return t.item(t.length-1)??o.getBoundingClientRect()};s.push(0);let f=d(0).top,p=1;for(;p<l;){let e=p,t=l;for(;e<t;){let n=e+t>>1;d(n).top>f?t=n:e=n+1}if(e>=l)break;let{left:n,top:r}=d(e),i=Ie()&&n-c>this.#r.ch/2;s.push(u(i?e-1:e)),f=r,p=e+1}let m=new Uint32Array(s.length+1);for(let e=0;e<s.length;e++)m[e]=s[e];return m[s.length]=n.length,this.#h.set(e,m),m}finally{i.remove()}}#Sn(e){let t=this.#xn(e);if(t!==void 0)return t;let n=this.#n?.document?.getLineText(e)?.length??0;return Uint32Array.of(0,n)}#Cn({startContainer:e,endContainer:t}){let n=this.#w;return n!==void 0&&n.contains(e)&&n.contains(t)}#wn(e){let t=this.#n?.document?.lineCount??0;return e<0||e>=t?!1:this.#gn(e)!==void 0}};function oo({type:e,editStateKey:t,owner:n,initialState:r,previousSession:i}){if(r!=null&&r.type!==e)throw TypeError(`Editor: initialState: a ${r.type} state cannot initialize a ${e} editor`);let a=r;return t==null?a??i??(e===`file`?{type:`file`}:{type:`file-diff`}):Qn.activate(e,t,n,a)}function so(e){return e instanceof HTMLElement?Number(e.dataset.bufferSize??1):1}function co(e,t){return t!==void 0&&Number.isInteger(t.line)&&Number.isInteger(t.character)&&t.line>=0&&t.line<e.lineCount&&t.character>=0&&t.character<=e.getLineLength(t.line)}function lo(e,t){let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return t>0&&t<e.length&&n>=55296&&n<=56319&&r>=56320&&r<=57343}var Q=n();function uo(e,t){let n=ee(t),r=ae(t)?`\\`:`/`,i=t.split(/[\\/]/).filter(Boolean),a=t.startsWith(`\\\\`)?`\\\\`:t.startsWith(`/`)?`/`:``;return[...n?[]:[{label:e,path:``,kind:`project`}],...i.map((e,t)=>{let o=a+i.slice(0,t+1).join(r);return{label:e,path:/^[A-Za-z]:$/.test(o)?`${o}\\`:n&&o===`~`?`~/`:o,kind:t===i.length-1?`file`:`directory`}})]}function fo(e){return uo(``,e).at(-1)?.path??e}function po(e){return ee(e)&&!/^\\\\[^\\/]+$/.test(e)}function mo(e,t){let n=fo(t);return uo(``,e).findIndex(e=>e.path===n)}function ho(e,t){return e!==void 0&&mo(e,t)>=0?e:t}function go(e,t){let n=mo(t,e);return n<0?null:uo(``,t)[n+1]?.label??null}function _o(e,t){let n=ae(e)?`\\`:`/`;return(e.endsWith(n)?e:`${e}${n}`)+t.split(`/`).join(n)}function vo(e,t){let n,r=t?`${t}/`:``;return e.flatMap(e=>{if(!e.path.startsWith(r))return[];let t=e.path.slice(r.length);return!t||t.includes(`/`)?[]:[{...e,label:t}]}).toSorted((e,t)=>e.kind===t.kind?(n??=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),n.compare(e.label,t.label)):e.kind===`directory`?-1:1)}function yo(e){if(!e)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}var bo=e=>{if(typeof e!=`object`||!e)return null;let t=e;return typeof t.getAttribute==`function`?t.getAttribute(`data-item-path`):null};function xo(e){let t=[],n=[];return{isDragInProgress:()=>n.length>0,handleSelectionChange(e){t=e},handleDragStart(r){if(r.dataTransfer===null)return;let i=null;for(let e of r.composedPath())if(i=bo(e),i!==null)break;if(i===null)return;let a=t.includes(i)?t:[i],o=a.map(t=>{let n=t.replace(/\/+$/,``);return wn(n&&e.mentionPath?e.mentionPath(n):t)}).filter(e=>e!==null);o.length!==0&&(n=a,r.dataTransfer.setData(Sn,o.join(` `)))},handleDragEnd(){if(n.length!==0){for(let t of n)e.deselect(t);n=[]}}}}function So(e){return e.split(`/`).filter(Boolean).length}function Co(e,t){let n=new Set(e),r=new Set(t),i=[],a=[],o=e.filter(e=>!r.has(e)).toSorted((e,t)=>So(e)-So(t));for(let e of o){if(i.some(t=>e.startsWith(t)))continue;let t=e.endsWith(`/`);a.push({type:`remove`,path:e,...t?{recursive:!0}:{}}),t&&i.push(e)}let s=t.filter(e=>!n.has(e)).toSorted((e,t)=>So(e)-So(t));for(let e of s)a.push({type:`add`,path:e});return a}function wo(e,t){let[n,r]=(0,J.useState)(new Map),[i,o]=(0,J.useState)(new Map),[s,c]=(0,J.useState)(0),[l,u]=(0,J.useState)(new Set),d=(0,J.useRef)(new Map),f=(0,J.useRef)(new Set),p=(0,J.useRef)(new Set),m=(0,J.useRef)(!0),h=(0,J.useRef)(0),g=(0,J.useRef)([]),v=(0,J.useCallback)(function n(i,s=!1){let l=d.current.get(i);if(l)return s?l.then(()=>n(i,!0)):l;if(!s&&f.current.has(i))return Promise.resolve();f.current.add(i),p.current.add(i);let v=le.listEntries({environmentId:e,input:{cwd:t,directoryPath:i}});c(e=>e+1),s||u(e=>new Set(e).add(i));let y=(async()=>{h.current>=4?await new Promise(e=>g.current.push(e)):h.current++;try{return m.current?await se(_,v,{refresh:!0,reportFailure:!1,reportDefect:!1}):void 0}finally{let e=g.current.shift();e?e():h.current--}})().then(e=>{if(m.current&&e){if(e._tag===`Success`)r(t=>new Map(t).set(i,e.value.entries.filter(e=>e.path.slice(0,Math.max(0,e.path.lastIndexOf(`/`)))===i))),o(e=>{let t=new Map(e);return t.delete(i),t});else{f.current.delete(i);let t=a(e.cause);o(e=>new Map(e).set(i,t instanceof Error?t.message:`Unable to load folder.`))}}}).finally(()=>{d.current.delete(i),m.current&&(c(e=>e-1),s||u(e=>{let t=new Set(e);return t.delete(i),t}))});return d.current.set(i,y),y},[t,e]);(0,J.useEffect)(()=>(m.current=!0,v(``),()=>{m.current=!1}),[v]);let y=(0,J.useMemo)(()=>{let e=[],t=r=>{for(let i of n.get(r)??[])e.push(i),i.kind===`directory`&&t(i.path)};return t(``),e},[n]),b=(0,J.useMemo)(()=>new Set([``,...y.filter(e=>e.kind===`directory`).map(e=>e.path)]),[y]);return{entries:y,load:v,refresh:(0,J.useCallback)(()=>{let e=[...p.current].filter(e=>b.has(e)),t=0,n=async()=>{for(;t<e.length&&m.current;){let n=e[t++];n!==void 0&&await v(n,!0)}};for(let t=0;t<Math.min(4,e.length);t++)n()},[v,b]),isPending:s>0,loadingDirectories:l,ready:n.has(``),error:[...i].find(([e])=>b.has(e))?.[1]??null}}var $=e(r(),1);function To(e){return e.kind===`directory`?`${e.path}/`:e.path}function Eo(e){let t=(0,Q.c)(12),n;t[0]===e.onRefresh?n=t[1]:(n=(0,$.jsx)(C,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Refresh workspace files`,onClick:e.onRefresh}),t[0]=e.onRefresh,t[1]=n);let r;t[2]===e.isPending?r=t[3]:(r=(0,$.jsx)(vn,{refreshing:e.isPending}),t[2]=e.isPending,t[3]=r);let i;t[4]!==n||t[5]!==r?(i=(0,$.jsx)(kt,{render:n,children:r}),t[4]=n,t[5]=r,t[6]=i):i=t[6];let a=e.isPending?`Refreshing…`:`Refresh files`,o;t[7]===a?o=t[8]:(o=(0,$.jsx)(At,{children:a}),t[7]=a,t[8]=o);let s;return t[9]!==i||t[10]!==o?(s=(0,$.jsxs)(jt,{children:[i,o]}),t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function Do(e){let t=(0,Q.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):(n=t=>e.onValueChange(t.target.value),r=t=>{t.key===`Escape`&&(e.onClose(),t.currentTarget.blur())},t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==e.ariaLabel||t[4]!==e.name||t[5]!==e.value||t[6]!==n||t[7]!==r?(i=(0,$.jsx)(un,{variant:`ghost`,className:`h-7 min-w-0 flex-1`,children:(0,$.jsx)(ln,{type:`search`,name:e.name,size:`sm`,value:e.value,"aria-label":e.ariaLabel,placeholder:`Search files`,spellCheck:!1,onChange:n,onKeyDown:r})}),t[3]=e.ariaLabel,t[4]=e.name,t[5]=e.value,t[6]=n,t[7]=r,t[8]=i):i=t[8],i}function Oo({environmentId:e,cwd:t,projectName:n,selectedPath:r,selectedPathRevealId:i,onOpenFile:a,onRefreshSelectedFile:o,workspaceMutationId:s,hostFolder:c=!1}){let l=e=>c?_o(t,e):e,{resolvedTheme:u}=be(),d=y(),f=De(e),{entries:p,load:m,refresh:h,ready:g,error:_,isPending:v,loadingDirectories:b}=wo(e,t),[x,S]=(0,J.useState)(``),[w,T]=(0,J.useState)(!1),E=ke({environmentId:e,cwd:c?null:t,query:x.slice(0,256)},200),D=(0,J.useMemo)(()=>{let e=new Map(p.map(e=>[e.path,e]));if(x.trim()&&!E.isPending)for(let t of E.entries){e.has(t.path)||e.set(t.path,t);let n=t.path.split(`/`);for(let t=1;t<n.length;t++){let r=n.slice(0,t).join(`/`);e.has(r)||e.set(r,{path:r,kind:`directory`})}}return[...e.values()]},[p,E.entries,E.isPending,x]),O=(0,J.useMemo)(()=>new Map(D.map(e=>[e.path,e.kind])),[D]),k=(0,J.useRef)(O),ee=(0,J.useMemo)(()=>D.map(To),[D]),te=(0,J.useMemo)(()=>D.filter(e=>e.kind===`directory`).map(To),[D]),ne=(0,J.useRef)(null),re=(0,J.useRef)(!1),ie=(0,J.useRef)(null),A=(0,J.useRef)(null),ae=(0,J.useRef)(null),oe=async(n,r)=>{let i=ye();if(!i){r.close();return}let a=n.path.replace(/\/$/,``),o=cn(l(a)),s=ae.current,c=s!==null&&performance.now()-s.at<1e3,u=r.anchorElement.getBoundingClientRect(),p=c?{x:s.x,y:s.y}:{x:u.left,y:u.bottom},m={environmentId:e,filePath:a,workspaceRoot:t},h=f.buildItems(m);r.close({restoreFocus:!c});let g=await i.contextMenu.show([...h,{id:`copy-mention`,label:`Copy mention`},{id:`add-to-chat`,label:`Add to chat`}],p);if(g!==null){if(h.some(e=>e.id===g)||g.startsWith(`editor:`))await f.activate(g,m);else if(g===`copy-mention`)try{await _e(o),ge.add({type:`success`,title:`Mention copied`,description:a})}catch(e){ge.add({type:`error`,title:`Failed to copy mention`,description:e instanceof Error?e.message:`An error occurred.`})}else if(g===`add-to-chat`){let e=d?.current;if(!e){ge.add({type:`error`,title:`Unable to add to chat`,description:`Open a chat for this project and try again.`});return}e.insertTextAtEnd(`${o} `,{ensureLeadingBoundary:!0})||ge.add({type:`error`,title:`Unable to add to chat`,description:`The chat isn't ready to accept input right now.`})}}},se=(0,J.useRef)(oe);(0,J.useEffect)(()=>{se.current=oe});let ce=(0,J.useRef)(b),le=(0,J.useRef)(null),ue=(0,J.useMemo)(()=>xo({deselect:e=>le.current?.getItem(e)?.deselect(),...c?{mentionPath:e=>_o(t,e)}:{}}),[t,c]),{model:j}=Wt({composition:{contextMenu:{triggerMode:`right-click`,onOpen:(e,t)=>{se.current(e,t)}}},dragAndDrop:{canDrop:()=>!1},density:`compact`,fileTreeSearchMode:`hide-non-matches`,flattenEmptyDirectories:!0,initialExpansion:`closed`,icons:Kt,onSelectionChange:e=>{if(ue.handleSelectionChange(e),re.current||ue.isDragInProgress())return;let t=e.at(-1)?.replace(/\/$/,``);t&&k.current.get(t)===`file`&&(ie.current=t,a(l(t)))},paths:[],renderRowDecoration:({item:e,row:t})=>t.kind===`directory`&&t.isExpanded&&ce.current.has(e.path.replace(/\/$/,``))?{icon:`p4-tree-icon-loading`,title:`Loading…`}:null,search:!1,onSearchChange:e=>S(e??``),unsafeCSS:Ut});(0,J.useEffect)(()=>{ce.current!==b&&(ce.current=b,j.setComposition(j.getComposition()))},[b,j]);let fe=Dn(j),P=Ht(j,e=>Gt(e,te)),pe=()=>{let e=!(w||P);T(e),Vt(j,te,e)},me=()=>{S(``),fe.close()},F=(0,J.useRef)(new Set);(0,J.useEffect)(()=>{let e=new Set(te);for(let t of F.current)e.has(t)||F.current.delete(t);let t=()=>{if(!j.isSearchOpen())for(let e of te){let t=j.getItem(e);t?.isDirectory()&&`isExpanded`in t&&t.isExpanded()?F.current.has(e)||(F.current.add(e),m(e.replace(/\/$/,``))):(t?.isDirectory()&&F.current.has(e)&&T(!1),F.current.delete(e))}};return t(),j.subscribe(t)},[te,m,j]),(0,J.useEffect)(()=>{j.setGitStatus(D.filter(e=>e.ignored).map(e=>({path:To(e),status:`ignored`})))},[D,j]),(0,J.useEffect)(()=>{if(!r)return;let e=new AbortController;return(async()=>{let t=r.split(`/`);for(let n=0;n<t.length&&!e.signal.aborted;n++)await m(t.slice(0,n).join(`/`))})(),()=>{e.abort()}},[m,r]);let he=e=>{S(e),e.trim().length===0?fe.close():fe.setValue(e)},ve=()=>{h(),x.trim()&&E.refresh(),o?.()};xn({mutationId:s,refresh:()=>{h(),x.trim()&&E.refresh()},resourceKey:`files:${e}:${t}`}),(0,J.useEffect)(()=>{if(!g||ne.current===ee)return;k.current=O;let e=ne.current;if(ne.current=ee,e===null){j.resetPaths(ee);return}let t=Co(e,ee);t.length>0&&j.batch(t)},[g,O,j,ee]),(0,J.useEffect)(()=>{w&&!x.trim()&&Vt(j,te,!0)},[te,w,j,x]),(0,J.useEffect)(()=>{if(!r){A.current=null;return}let e=O.get(r);if(e===void 0){A.current=null;return}let t={path:r,revealId:i},n=A.current;if(n?.path===t.path&&n.revealId===t.revealId)return;let a=e===`directory`?`${r}/`:r,o=j.getItem(a);if(!o)return;if(j.getSelectedPaths().some(e=>e.replace(/\/$/,``)===r)&&ie.current===r){ie.current=null,A.current=t;return}ie.current=null,A.current=t,re.current=!0,S(``),j.closeSearch();for(let e of j.getSelectedPaths())j.getItem(e)?.deselect();let s=r.split(`/`),c=``;for(let e of s.slice(0,-1)){c=c?`${c}/${e}`:e;let t=j.getItem(`${c}/`)??j.getItem(c);t&&`expand`in t&&t.expand()}`expand`in o&&o.expand(),o.select(),j.scrollToPath(a,{focus:!0,offset:`center`}),queueMicrotask(()=>{re.current=!1})},[O,j,r,i]);let xe=(0,J.useRef)(null);return(0,J.useEffect)(()=>{le.current=j},[j]),(0,J.useEffect)(()=>{let e=xe.current;if(e===null)return;let t=e=>ue.handleDragStart(e),n=()=>ue.handleDragEnd();return e.addEventListener(`dragstart`,t,!0),e.addEventListener(`dragend`,n),()=>{e.removeEventListener(`dragstart`,t,!0),e.removeEventListener(`dragend`,n)}},[ue]),(0,$.jsxs)(`div`,{ref:xe,className:`flex min-h-0 flex-1 flex-col bg-background`,"data-file-browser-panel":`${e}:${t}`,onContextMenuCapture:e=>{ae.current={x:e.clientX,y:e.clientY,at:e.timeStamp}},children:[(0,$.jsxs)(`div`,{className:`flex h-10 min-h-10 shrink-0 items-center gap-1 border-b border-border/60 bg-background px-2 in-data-[preview-panel-mode=inline]:mb-1 in-data-[preview-panel-mode=inline]:h-9 in-data-[preview-panel-mode=inline]:min-h-9 in-data-[preview-panel-mode=inline]:border-b-transparent`,"data-surface-subheader":!0,children:[(0,$.jsx)(Eo,{isPending:v,onRefresh:ve}),(0,$.jsx)(Do,{name:`project-files-search`,ariaLabel:`Search ${n} files`,value:fe.value,onValueChange:he,onClose:me}),te.length>0&&!c?(0,$.jsx)(C,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":w||P?`Collapse all folders`:`Expand all folders`,onClick:pe,children:(0,$.jsx)(de,{className:`size-3.5`,icon:P?N:M})}):null]}),_||E.error?(0,$.jsxs)(`button`,{type:`button`,onClick:ve,className:`p-4 text-left text-xs leading-relaxed text-destructive`,children:[_??E.error,` Click to retry.`]}):null,x.trim()&&E.truncated&&!E.isPending?(0,$.jsx)(`div`,{className:`px-3 py-1 text-xs text-muted-foreground`,children:`More matches available. Refine your search.`}):null,(!g||E.isPending)&&(0,$.jsx)(`div`,{role:`status`,className:`px-3 py-1 text-xs text-muted-foreground`,children:`Loading files…`}),(0,$.jsx)(zt,{model:j,"aria-label":`${n} files`,className:`min-h-0 flex-1 overflow-hidden`,style:Bt(u)})]})}var ko=160,Ao=560,jo=256;function Mo(e){let t=(0,Q.c)(21),{resizable:n,children:r}=e,[i,a]=(0,J.useState)(Ao),o;t[0]===i?o=t[1]:(o={storageKey:`p4code:fileExplorerWidth`,defaultWidth:256,minWidth:ko,maxWidth:i,edge:`left`},t[0]=i,t[1]=o);let{width:s,setWidth:c,handlers:l}=Xt(o),u;t[2]===n?u=t[3]:(u=e=>{let t=e?.parentElement;if(!t||!n)return;let r=()=>a(Math.max(ko,Math.min(Ao,t.clientWidth-jo)));return r(),Jt(t,r)},t[2]=n,t[3]=u);let d=n?`border-l border-border/60`:`flex-1`,f;t[4]===d?f=t[5]:(f=D(`relative flex min-h-0 min-w-0 shrink-0 bg-background`,d),t[4]=d,t[5]=f);let p;t[6]!==n||t[7]!==s?(p=n?{[Yt]:`${s}px`,width:`var(${Yt})`}:void 0,t[6]=n,t[7]=s,t[8]=p):p=t[8];let m;t[9]!==l||t[10]!==i||t[11]!==n||t[12]!==c||t[13]!==s?(m=n?(0,$.jsx)(Zt,{handlers:l,label:`Resize file explorer`,tabIndex:0,"aria-valuenow":s,"aria-valuemin":ko,"aria-valuemax":i,onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t;bb39:switch(e.key){case`ArrowLeft`:t=s+16;break bb39;case`ArrowRight`:t=s-16;break bb39;case`Home`:t=ko;break bb39;case`End`:t=i;break bb39;default:return}e.preventDefault(),e.stopPropagation(),c(t)}}):null,t[9]=l,t[10]=i,t[11]=n,t[12]=c,t[13]=s,t[14]=m):m=t[14];let h;return t[15]!==r||t[16]!==u||t[17]!==f||t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`aside`,{ref:u,"aria-label":`File explorer`,className:f,style:p,children:[m,r]}),t[15]=r,t[16]=u,t[17]=f,t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function No(e,t){return e.slice(e.lastIndexOf(`/`)+1)||t}function Po(e){let t=(0,Q.c)(12),n=e.current?`font-medium text-foreground`:`text-muted-foreground`,r;t[0]===n?r=t[1]:(r=D(`block max-w-40 truncate rounded-sm px-0.5`,n),t[0]=n,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{className:r}),t[2]=r,t[3]=i);let a;t[4]!==e.label||t[5]!==i?(a=(0,$.jsx)(kt,{render:i,children:e.label}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6];let o;t[7]===e.pathLabel?o=t[8]:(o=(0,$.jsx)(At,{side:`top`,children:e.pathLabel}),t[7]=e.pathLabel,t[8]=o);let s;return t[9]!==a||t[10]!==o?(s=(0,$.jsxs)(jt,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s}function Fo(e){let t=(0,Q.c)(40),n=_n(e.environmentId,e.cwd,e.directoryPath,e.workspaceMutationId),{resolvedTheme:r}=be(),a;t[0]===n.data?.entries?a=t[1]:(a=n.data?.entries??[],t[0]=n.data?.entries,t[1]=a);let o=a,s=n.data?.truncated??!1,c;t[2]!==o||t[3]!==e.directoryPath?(c=vo(o,e.directoryPath),t[2]=o,t[3]=e.directoryPath,t[4]=c):c=t[4];let l=c,u=n.data!==null,f,p,h,g,_;if(t[5]!==e){let n=yo(e.directoryPath),r=e.directoryPath!==e.rootPath&&n!==null&&(e.rootPath===``||n===e.rootPath||n.startsWith(`${e.rootPath}/`));f=T,p=`start`,h=`bottom`,g=t=>{t.key===`ArrowLeft`&&r&&n!==null&&(t.preventDefault(),t.stopPropagation(),e.onDirectoryChange(n))},_=r&&n!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(O,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(n),children:[(0,$.jsx)(k,{}),(0,$.jsxs)(`span`,{className:`truncate`,children:[`Back to `,No(n,e.projectName)]})]}),(0,$.jsx)(E,{})]}):null,t[5]=e,t[6]=f,t[7]=p,t[8]=h,t[9]=g,t[10]=_}else f=t[6],p=t[7],h=t[8],g=t[9],_=t[10];let v;t[11]!==l||t[12]!==u||t[13]!==n.data||t[14]!==n.error||t[15]!==n.isPending||t[16]!==n.refresh||t[17]!==s||t[18]!==e||t[19]!==r?(v=n.isPending&&n.data===null?(0,$.jsxs)(O,{disabled:!0,children:[(0,$.jsx)(he,{}),`Loading folder…`]}):n.error&&n.data===null?(0,$.jsxs)(O,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(vn,{refreshing:n.isPending}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Retry loading folder`})]}):!u&&!s?(0,$.jsx)(O,{disabled:!0,children:`This folder is no longer available.`}):l.length===0?(0,$.jsx)(O,{disabled:!0,children:s?`No entries from this folder are available in the partial workspace index.`:`This folder is empty.`}):(0,$.jsx)(x,{value:e.currentFilePath,onValueChange:t=>{e.onOpenChange(!1),e.onOpenFile(t)},children:l.map(t=>{let n=t.kind===`file`&&t.path===e.currentFilePath,i=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sn,{pathValue:t.path,kind:t.kind,theme:r}),(0,$.jsxs)(jt,{children:[(0,$.jsx)(kt,{render:(0,$.jsx)(`span`,{className:D(`min-w-0 flex-1 truncate`,t.ignored&&`text-muted-foreground`)}),children:t.label}),(0,$.jsx)(At,{side:`right`,children:t.path})]})]});return t.kind===`directory`?(0,$.jsxs)(O,{closeOnClick:!1,onClick:()=>e.onDirectoryChange(t.path),children:[i,(0,$.jsx)(d,{})]},t.path):(0,$.jsx)(m,{value:t.path,closeOnClick:!0,"aria-current":n?`page`:void 0,children:(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:i})},t.path)})}),t[11]=l,t[12]=u,t[13]=n.data,t[14]=n.error,t[15]=n.isPending,t[16]=n.refresh,t[17]=s,t[18]=e,t[19]=r,t[20]=v):v=t[20];let y;t[21]!==e.directoryPath||t[22]!==v?(y=(0,$.jsx)(i,{children:v},e.directoryPath),t[21]=e.directoryPath,t[22]=v,t[23]=y):y=t[23];let b;t[24]!==n.data||t[25]!==n.error||t[26]!==n.isPending||t[27]!==n.refresh?(b=n.error&&n.data!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{}),(0,$.jsxs)(O,{closeOnClick:!1,onClick:n.refresh,children:[(0,$.jsx)(vn,{refreshing:n.isPending}),`Refresh failed — retry`]})]}):null,t[24]=n.data,t[25]=n.error,t[26]=n.isPending,t[27]=n.refresh,t[28]=b):b=t[28];let S;t[29]===s?S=t[30]:(S=s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{}),(0,$.jsx)(O,{disabled:!0,children:`Some workspace entries are not shown.`})]}):null,t[29]=s,t[30]=S);let C;return t[31]!==f||t[32]!==p||t[33]!==h||t[34]!==g||t[35]!==_||t[36]!==y||t[37]!==b||t[38]!==S?(C=(0,$.jsxs)(f,{align:p,side:h,onKeyDown:g,children:[_,y,b,S]}),t[31]=f,t[32]=p,t[33]=h,t[34]=g,t[35]=_,t[36]=y,t[37]=b,t[38]=S,t[39]=C):C=t[39],C}function Io(e){let t=(0,Q.c)(28),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(e.crumb.path),o;t[0]===e.crumb.path?o=t[1]:(o=()=>{r(!1),a(e.crumb.path)},t[0]=e.crumb.path,t[1]=o);let s;t[2]!==e.crumb.path||t[3]!==e.relativePath?(s=[e.crumb.path,e.relativePath],t[2]=e.crumb.path,t[3]=e.relativePath,t[4]=s):s=t[4],(0,J.useEffect)(o,s);let c;t[5]===e.crumb.path?c=t[6]:(c=t=>{r(t),t&&a(e.crumb.path)},t[5]=e.crumb.path,t[6]=c);let l=c,u=`Browse ${e.crumb.label}`,f;t[7]===u?f=t[8]:(f=(0,$.jsx)(`button`,{type:`button`,"aria-label":u,className:`relative mx-0.5 flex h-5 w-4 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground/60 outline-none pointer-coarse:after:absolute pointer-coarse:after:-inset-3 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring data-popup-open:bg-accent data-popup-open:text-foreground`}),t[7]=u,t[8]=f);let m;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(d,{className:`size-3.5`}),t[9]=m):m=t[9];let h;t[10]===f?h=t[11]:(h=(0,$.jsx)(v,{render:f,children:m}),t[10]=f,t[11]=h);let g;t[12]!==i||t[13]!==l||t[14]!==n||t[15]!==e.crumb.path||t[16]!==e.cwd||t[17]!==e.environmentId||t[18]!==e.onOpenFile||t[19]!==e.projectName||t[20]!==e.relativePath||t[21]!==e.workspaceMutationId?(g=n?(0,$.jsx)(Fo,{cwd:e.cwd,currentFilePath:e.relativePath,directoryPath:i,environmentId:e.environmentId,onDirectoryChange:a,onOpenChange:l,onOpenFile:e.onOpenFile,projectName:e.projectName,rootPath:e.crumb.path,workspaceMutationId:e.workspaceMutationId}):null,t[12]=i,t[13]=l,t[14]=n,t[15]=e.crumb.path,t[16]=e.cwd,t[17]=e.environmentId,t[18]=e.onOpenFile,t[19]=e.projectName,t[20]=e.relativePath,t[21]=e.workspaceMutationId,t[22]=g):g=t[22];let _;return t[23]!==l||t[24]!==n||t[25]!==h||t[26]!==g?(_=(0,$.jsxs)(p,{open:n,onOpenChange:l,children:[h,g]}),t[23]=l,t[24]=n,t[25]=h,t[26]=g,t[27]=_):_=t[27],_}function Lo(e){let t=(0,Q.c)(17),n;t[0]===e?n=t[1]:(n=()=>e.onNavigate(e.crumb.path),t[0]=e,t[1]=n);let r=e.descendant?`text-muted-foreground/70`:`text-muted-foreground`,i;t[2]===r?i=t[3]:(i=D(`relative block max-w-40 cursor-pointer rounded-sm px-0.5 text-left outline-none pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,r),t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==i?(a=(0,$.jsx)(`button`,{type:`button`,onClick:n,className:i}),t[4]=n,t[5]=i,t[6]=a):a=t[6];let o;t[7]===e.crumb.label?o=t[8]:(o=(0,$.jsx)(`span`,{className:`block truncate`,children:e.crumb.label}),t[7]=e.crumb.label,t[8]=o);let s;t[9]!==a||t[10]!==o?(s=(0,$.jsx)(kt,{render:a,children:o}),t[9]=a,t[10]=o,t[11]=s):s=t[11];let c=e.crumb.path||e.projectName,l;t[12]===c?l=t[13]:(l=(0,$.jsx)(At,{side:`top`,children:c}),t[12]=c,t[13]=l);let u;return t[14]!==s||t[15]!==l?(u=(0,$.jsxs)(jt,{children:[s,l]}),t[14]=s,t[15]=l,t[16]=u):u=t[16],u}function Ro(e){let t=(0,Q.c)(21),n;t[0]===e.relativePath?n=t[1]:(n=ee(e.relativePath),t[0]=e.relativePath,t[1]=n);let r=n,i;t[2]!==e.projectName||t[3]!==e.trail?(i=uo(e.projectName,e.trail),t[2]=e.projectName,t[3]=e.trail,t[4]=i):i=t[4];let a=i,o;t[5]===e.relativePath?o=t[6]:(o=fo(e.relativePath),t[5]=e.relativePath,t[6]=o);let s=o,c;t[7]===s?c=t[8]:(c=e=>e.path===s,t[7]=s,t[8]=c);let l=a.findIndex(c),u;if(t[9]!==a||t[10]!==l||t[11]!==r||t[12]!==e){let n;t[14]!==a.length||t[15]!==l||t[16]!==r||t[17]!==e?(n=(t,n)=>{let i=n===l;return(0,$.jsxs)(`li`,{className:`flex min-w-0 shrink-0 items-center`,"data-file-crumb":!0,"data-current-file-crumb":i,children:[i?(0,$.jsx)(`span`,{"aria-current":`page`,children:(0,$.jsx)(Po,{current:!0,label:t.label,pathLabel:t.path||e.projectName})}):r&&!po(t.path)?(0,$.jsx)(Po,{label:t.label,pathLabel:t.path}):(0,$.jsx)(Lo,{crumb:t,descendant:n>l,onNavigate:e.onNavigateFolder,projectName:e.projectName}),n===a.length-1?null:r?(0,$.jsx)(d,{"aria-hidden":!0,className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):(0,$.jsx)(Io,{...e,crumb:t})]},t.path||`project`)},t[14]=a.length,t[15]=l,t[16]=r,t[17]=e,t[18]=n):n=t[18],u=a.map(n),t[9]=a,t[10]=l,t[11]=r,t[12]=e,t[13]=u}else u=t[13];let f;return t[19]===u?f=t[20]:(f=(0,$.jsx)(`nav`,{"aria-label":`File path`,className:`flex h-full`,children:(0,$.jsx)(`ol`,{className:`flex items-center`,children:u})}),t[19]=u,t[20]=f),f}function zo(e){let t=(0,Q.c)(16),n;t[0]===e.relativePath?n=t[1]:(n=e.relativePath.lastIndexOf(`/`),t[0]=e.relativePath,t[1]=n);let r;t[2]===e.relativePath?r=t[3]:(r=e.relativePath.lastIndexOf(`\\`),t[2]=e.relativePath,t[3]=r);let i=Math.max(n,r),a;t[4]!==i||t[5]!==e.cwd||t[6]!==e.relativePath?(a=i>=0?Ee(e.relativePath.slice(0,i),e.cwd):e.cwd,t[4]=i,t[5]=e.cwd,t[6]=e.relativePath,t[7]=a):a=t[7];let o=a,s;t[8]===e.text?s=t[9]:(s=q(e.text),t[8]=e.text,t[9]=s);let c;return t[10]!==o||t[11]!==e.cwd||t[12]!==e.onTaskListChange||t[13]!==e.threadRef||t[14]!==s?(c=(0,$.jsx)(me,{text:s,cwd:e.cwd,imageBaseDir:o,threadRef:e.threadRef,className:`mx-auto max-w-4xl px-6 py-5`,onTaskListChange:e.onTaskListChange}),t[10]=o,t[11]=e.cwd,t[12]=e.onTaskListChange,t[13]=e.threadRef,t[14]=s,t[15]=c):c=t[15],c}function Bo({root:e,editor:t,onDismiss:n}){n(),t.setSelections([]);let r=e.querySelector(`diffs-container`)?.shadowRoot?.activeElement;r instanceof HTMLElement&&r.blur()}function Vo(e){return e.querySelector(`diffs-container`)?.shadowRoot?.activeElement?.hasAttribute(`data-content`)===!0}function Ho({root:e,editor:t,isBlocked:n,onDismiss:r}){let i=i=>{n()||i.composedPath().includes(e)||Bo({root:e,editor:t,onDismiss:r})},a=i=>{i.key===`Escape`&&!n()&&Vo(e)&&(i.preventDefault(),i.stopImmediatePropagation(),Bo({root:e,editor:t,onDismiss:r}))};return document.addEventListener(`pointerdown`,i,!0),document.addEventListener(`keydown`,a,!0),()=>{document.removeEventListener(`pointerdown`,i,!0),document.removeEventListener(`keydown`,a,!0)}}function Uo(e){let t=e.renderedLine===void 0?e.fileTop+e.estimatedLine.top:e.scrollTop+e.renderedLine.top-e.viewportTop,n=e.renderedLine?.height??e.estimatedLine.height,r=Math.max(0,t-Math.max(0,(e.viewportHeight-n)/2));return Math.min(r,Math.max(0,e.scrollHeight-e.viewportHeight))}function Wo(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`${e.length}:${(t>>>0).toString(36)}`}function Go(e,t,n){return`${e}:${t}:${Wo(n)}`}function Ko(e,t){return e===null||e===`.`||A(e,t)===`.`?null:e}var qo=e=>/\.(?:md|mdx)$/i.test(e);function Jo(e){switch(e.failure){case`path_not_file`:return`The path is a directory or special file, not a regular file.`;case`binary_file`:return`The file is binary and cannot be displayed as text.`;case`workspace_path_outside_root`:return`The requested path is outside the workspace.`;case`resolved_path_outside_root`:return`The path resolves to a location outside the workspace.`;case`operation_failed`:return e.operation===`realpath-workspace-root`?`The workspace folder could not be accessed.`:`The file could not be accessed or read. It may be missing or inaccessible.`;default:return e.message}}function Yo(e){return e.attachmentOpen||e.relativePath&&ee(e.relativePath)?!1:e.explorerOpen||e.relativePath===null}function Xo(e,t,n){return t<0||e[t]!==`[`||!/[ xX]/.test(e[t+1]??``)||e[t+2]!==`]`?e:`${e.slice(0,t+1)}${n?`x`:` `}${e.slice(t+2)}`}function Zo(e){return e.draft?{_tag:`draft-workspace-file`,cwd:e.workspaceRoot,path:e.absolutePath}:{_tag:e.kind,threadId:e.threadRef.threadId,path:e.absolutePath}}var Qo=class{options;timer=null;latestContents=``;latestRevision=0;confirmedRevision=0;lastChangeAt=0;saving=!1;disposed=!1;constructor(e){this.options=e}change(e){this.disposed||(this.latestContents=e,this.latestRevision+=1,this.lastChangeAt=Date.now(),this.options.onPendingChange(!0),this.schedule(this.options.debounceMs))}dispose(){this.disposed=!0,this.clearTimer(),this.latestRevision>0&&this.persistLatest()}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.persistLatest()},e)}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}async persistLatest(){if(this.saving||this.latestRevision===this.confirmedRevision||this.options.canPersist?.()===!1)return;this.saving=!0;let e=this.latestContents,t=this.latestRevision,n=(await this.options.persist(e))._tag===`Success`,r=!1;if(n&&(this.confirmedRevision=t,r=this.options.onConfirmed(e)!==!1),this.saving=!1,t===this.latestRevision){r&&this.options.onPendingChange(!1);return}let i=Math.max(0,this.options.debounceMs-(Date.now()-this.lastChangeAt));this.disposed?this.persistLatest():this.schedule(i)}},$o=500;function es(e){let t=(0,Q.c)(17),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=Ce(n,g),s=Te(le.writeFile),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,J.createRef)(),t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>l.current?.change(e),t[1]=u):u=t[1];let d;t[2]!==r||t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==s?(d={change:u,setup:()=>{let e=new Qo({debounceMs:$o,canPersist:()=>we(n,g),onPendingChange:e=>a(i,e),persist:e=>s({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),onConfirmed:e=>gn(n,r,i,e)});return l.current=e,()=>{l.current=null,e.dispose()}}},t[2]=r,t[3]=n,t[4]=a,t[5]=i,t[6]=s,t[7]=d):d=t[7];let f=d,p;t[8]===f?p=t[9]:(p=[f],t[8]=f,t[9]=p),(0,J.useEffect)(f.setup,p);let m,h;return t[10]!==o||t[11]!==r||t[12]!==n||t[13]!==i||t[14]!==f?(m=()=>{if(!o)return;let e=!1;return queueMicrotask(()=>{if(e)return;let t=hn(n,r,i);t&&f.change(t.contents)}),()=>{e=!0}},h=[o,r,n,i,f],t[10]=o,t[11]=r,t[12]=n,t[13]=i,t[14]=f,t[15]=m,t[16]=h):(m=t[15],h=t[16]),(0,J.useEffect)(m,h),f}var ts=`p4code.fileExplorerOpen`,ns=`p4code.renderMarkdown`,rs=`p4code.renderBrowserFile`,is=`p4code.renderTable`;function as(e){let t=(0,Q.c)(28),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Zo({kind:`workspace-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=en(e.environmentId,r),[a,o]=(0,J.useState)(null),s;t[5]!==i._tag||t[6]!==i.url||t[7]!==e.workspaceMutationId?(s=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[5]=i._tag,t[6]=i.url,t[7]=e.workspaceMutationId,t[8]=s):s=t[8];let c=s,l=i._tag===`Success`?`${i.url}${c}`:null,u=e.alt,d;t[9]!==e.absolutePath||t[10]!==e.workspaceRoot?(d=gt(e.absolutePath,e.workspaceRoot),t[9]=e.absolutePath,t[10]=e.workspaceRoot,t[11]=d):d=t[11];let f;t[12]!==e.environmentId||t[13]!==r?(f={environmentId:e.environmentId,resource:r},t[12]=e.environmentId,t[13]=r,t[14]=f):f=t[14];let p;t[15]!==l||t[16]!==e.alt||t[17]!==d||t[18]!==f?(p={kind:`image`,name:u,src:l,reference:d,asset:f},t[15]=l,t[16]=e.alt,t[17]=d,t[18]=f,t[19]=p):p=t[19];let m=p;if(i._tag===`Failure`||l!==null&&a===l){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load workspace image.`}),t[20]=e):e=t[20];let n;return t[21]===m?n=t[22]:(n=(0,$.jsx)(pe,{source:m,children:e}),t[21]=m,t[22]=n),n}let h;return t[23]!==m||t[24]!==i._tag||t[25]!==l||t[26]!==e.alt?(h=i._tag===`Success`&&l!==null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,$.jsx)(pe,{source:m,children:(0,$.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:l,alt:e.alt,onError:()=>o(l)})})}):(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(he,{size:`lg`})}),t[23]=m,t[24]=i._tag,t[25]=l,t[26]=e.alt,t[27]=h):h=t[27],h}function os(e){let t=(0,Q.c)(19),n=gt(e.absolutePath,e.workspaceRoot).relativePath===void 0?`media-file`:`workspace-file`,r;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot||t[4]!==n?(r=Zo({kind:n,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n,t[5]=r):r=t[5];let i=r,a=en(e.environmentId,i),o;t[6]!==a._tag||t[7]!==a.url||t[8]!==e.workspaceMutationId?(o=e.workspaceMutationId===null?``:`${a._tag===`Success`&&a.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[6]=a._tag,t[7]=a.url,t[8]=e.workspaceMutationId,t[9]=o):o=t[9];let s=o;if(a._tag===`Failure`){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load file preview.`}),t[10]=e):e=t[10],e}if(a._tag!==`Success`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(he,{size:`lg`})}),t[11]=e):e=t[11],e}let c=`${a.url}${s}`,l=`${e.environmentId}:${i._tag}:${e.threadRef.threadId}:${e.absolutePath}:${e.workspaceMutationId}`,u=e.title,d;t[12]===e.absolutePath?d=t[13]:(d=bt(e.absolutePath),t[12]=e.absolutePath,t[13]=d);let f;return t[14]!==e.title||t[15]!==c||t[16]!==l||t[17]!==d?(f=(0,$.jsx)(Ct,{src:c,documentKey:l,title:u,pdf:d}),t[14]=e.title,t[15]=c,t[16]=l,t[17]=d,t[18]=f):f=t[18],f}function ss(e){let t=(0,Q.c)(36),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Zo({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=en(e.environmentId,r),a=tn(e.environmentId,r),o=e.workspaceMutationId,s;t[5]!==e.environmentId||t[6]!==r?(s=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=s):s=t[7];let c;t[8]===a?c=t[9]:(c=()=>{a().catch(cs)},t[8]=a,t[9]=c);let l;t[10]!==e.workspaceMutationId||t[11]!==s||t[12]!==c?(l={mutationId:o,resourceKey:s,refresh:c},t[10]=e.workspaceMutationId,t[11]=s,t[12]=c,t[13]=l):l=t[13],xn(l);let u;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(u=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=u):u=t[17];let d=u,f=i._tag===`Success`?`${i.url}${d}`:null,p=i._tag===`Failure`,m=e.name,h=e.workspaceMutationId,g=e.name,_;t[18]!==e.absolutePath||t[19]!==e.workspaceRoot?(_=gt(e.absolutePath,e.workspaceRoot),t[18]=e.absolutePath,t[19]=e.workspaceRoot,t[20]=_):_=t[20];let v;t[21]!==e.environmentId||t[22]!==r?(v={environmentId:e.environmentId,resource:r},t[21]=e.environmentId,t[22]=r,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==e.name||t[26]!==_||t[27]!==v?(y={kind:`video`,name:g,src:f,reference:_,asset:v},t[24]=f,t[25]=e.name,t[26]=_,t[27]=v,t[28]=y):y=t[28];let b;return t[29]!==f||t[30]!==e.name||t[31]!==e.workspaceMutationId||t[32]!==a||t[33]!==y||t[34]!==p?(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-hidden p-4`,children:(0,$.jsx)(P,{src:f,sourceFailed:p,label:m,revision:h,preload:`metadata`,className:`flex h-full min-h-0 w-full max-w-5xl items-center justify-center`,videoClassName:`aspect-auto max-h-full w-auto max-w-full`,onRetry:a,actionsSource:y})}),t[29]=f,t[30]=e.name,t[31]=e.workspaceMutationId,t[32]=a,t[33]=y,t[34]=p,t[35]=b):b=t[35],b}function cs(){}function ls(e){let t=(0,Q.c)(27),n;t[0]!==e.absolutePath||t[1]!==e.draft||t[2]!==e.threadRef||t[3]!==e.workspaceRoot?(n=Zo({kind:`media-file`,threadRef:e.threadRef,draft:e.draft,workspaceRoot:e.workspaceRoot,absolutePath:e.absolutePath}),t[0]=e.absolutePath,t[1]=e.draft,t[2]=e.threadRef,t[3]=e.workspaceRoot,t[4]=n):n=t[4];let r=n,i=en(e.environmentId,r),a=tn(e.environmentId,r),[o,s]=(0,J.useState)(null),c=e.workspaceMutationId,l;t[5]!==e.environmentId||t[6]!==r?(l=JSON.stringify([e.environmentId,r]),t[5]=e.environmentId,t[6]=r,t[7]=l):l=t[7];let u;t[8]===a?u=t[9]:(u=()=>{a().catch(ds)},t[8]=a,t[9]=u);let d;t[10]!==e.workspaceMutationId||t[11]!==l||t[12]!==u?(d={mutationId:c,resourceKey:l,refresh:u},t[10]=e.workspaceMutationId,t[11]=l,t[12]=u,t[13]=d):d=t[13],xn(d);let f;t[14]!==i._tag||t[15]!==i.url||t[16]!==e.workspaceMutationId?(f=e.workspaceMutationId===null?``:`${i._tag===`Success`&&i.url.includes(`?`)?`&`:`?`}workspace-revision=${encodeURIComponent(e.workspaceMutationId)}`,t[14]=i._tag,t[15]=i.url,t[16]=e.workspaceMutationId,t[17]=f):f=t[17];let p=f,m=i._tag===`Success`?`${i.url}${p}`:null;if(i._tag===`Failure`||m!==null&&o===m){let e;return t[18]===a?e=t[19]:(e=(0,$.jsx)(Tt,{message:`Unable to load audio.`,onRetry:()=>{s(null),a().catch(us)}}),t[18]=a,t[19]=e),e}if(m===null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(St,{}),t[20]=e):e=t[20],e}let h;t[21]===m?h=t[22]:(h=()=>s(m),t[21]=m,t[22]=h);let g;return t[23]!==e.name||t[24]!==h||t[25]!==m?(g=(0,$.jsx)(xt,{src:m,name:e.name,onError:h}),t[23]=e.name,t[24]=h,t[25]=m,t[26]=g):g=t[26],g}function us(){}function ds(){}function fs(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function ps(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${vt}]`))e.removeAttribute(vt);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(vt,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(vt,``))}var ms=30,hs=20,gs=2;function _s(e,t,n){let r=(0,Q.c)(5),[i]=(0,J.useState)(vs),a;return r[0]!==e||r[1]!==t||r[2]!==n||r[3]!==i?(a=(r,a,o)=>{if(e===null)return;let s=i.get(e),c=s??{frameId:null,cancelGuard:null,handledRequestId:null,latestRequestId:null};s||i.set(e,c);let l=()=>{c.frameId!==null&&(cancelAnimationFrame(c.frameId),c.frameId=null),c.cancelGuard?.()};if(o===`unmount`){l();return}let u=a.file?.contents;if(ps(r,t===null||u===void 0?null:fs(u,t)),!(a instanceof qe))return;if(c.latestRequestId!==n&&(l(),c.latestRequestId=n,c.handledRequestId=null),t===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);if(!d||(r.style.minHeight=`${Math.ceil(Math.max(a.height,d.clientHeight))}px`,c.handledRequestId===n||c.frameId!==null))return;let f=e=>{let t=a.getLinePosition(e);if(!t)return null;let n=d.getBoundingClientRect(),i=d.scrollTop+r.getBoundingClientRect().top-n.top,o=(r.shadowRoot??r).querySelector(`[data-line="${e}"]`)?.getBoundingClientRect();return Uo({scrollTop:d.scrollTop,scrollHeight:d.scrollHeight,viewportTop:n.top,viewportHeight:d.clientHeight,fileTop:i,estimatedLine:t,...o&&o.height>0?{renderedLine:{top:o.top,height:o.height}}:{}})},p=e=>{let t=hs,n=null,r=()=>{n!==null&&(cancelAnimationFrame(n),n=null),d.removeEventListener(`wheel`,r),d.removeEventListener(`touchstart`,r),d.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`keydown`,r,!0),c.cancelGuard===r&&(c.cancelGuard=null)};d.addEventListener(`wheel`,r,{passive:!0}),d.addEventListener(`touchstart`,r,{passive:!0}),d.addEventListener(`pointerdown`,r,{passive:!0,capture:!0}),window.addEventListener(`keydown`,r,!0);let i=()=>{if(n=null,--t,t<=0||!d.isConnected){r();return}let a=f(e);a!==null&&Math.abs(d.scrollTop-a)>gs&&(d.scrollTop=a),n=requestAnimationFrame(i)};n=requestAnimationFrame(i),c.cancelGuard=r},m=e=>{c.frameId=requestAnimationFrame(()=>{if(c.frameId=null,c.latestRequestId!==n||!r.isConnected)return;let i=a.file?.contents,o=i===void 0?null:fs(i,t),s=o===null?null:f(o);o===null||s===null?e<ms&&m(e+1):(ps(r,o),d.scrollTop=s,c.handledRequestId=n,p(o))})};m(0)},r[0]=e,r[1]=t,r[2]=n,r[3]=i,r[4]=a):a=r[4],a}function vs(){return new Map}var ys=(e,t,n)=>new ao(e,t,n);function bs(e,t,n,r){return{name:n,contents:r,cacheKey:`editor:${e}:${Go(t,n,r)}`}}function xs(e,t){if(e?.isWorkingPool()!==!0||(t.lang??yn(t.name))===`text`)return!1;let n=1;for(let e=t.contents.indexOf(`
32
32
  `);e!==-1;e=t.contents.indexOf(`
33
- `,e+1))n+=1;return n<=Me}function Ss(e){let t=(0,Q.c)(15),n=Le(),[r,i]=(0,J.useState)(null),a;t[0]!==e||t[1]!==n?(a=xs(n,e),t[0]=e,t[1]=n,t[2]=a):a=t[2];let o=!a||r===e,s,c;t[3]!==e||t[4]!==o||t[5]!==n?(s=()=>{o||n===void 0||n.primeFileHighlightCache(e).catch(()=>i(e))},c=[e,o,n],t[3]=e,t[4]=o,t[5]=n,t[6]=s,t[7]=c):(s=t[6],c=t[7]),(0,J.useEffect)(s,c);let l;t[8]!==e||t[9]!==o||t[10]!==n?(l=(t,r)=>{o||r===`unmount`||t?.cacheKey!==e.cacheKey||n?.getFileResultCache(e)!==void 0&&i(e)},t[8]=e,t[9]=o,t[10]=n,t[11]=l):l=t[11];let u=l,d;return t[12]!==u||t[13]!==o?(d={ready:o,onPostRender:u},t[12]=u,t[13]=o,t[14]=d):d=t[14],d}function Cs(e){let t=(0,Q.c)(68),{environmentId:n,cwd:r,relativePath:a,composerDraftTarget:o,contents:s,resolvedTheme:c,revealRequestId:l,wordWrap:u,onPostRender:d,onPendingChange:f}=e,p=i(As),m=i(ks),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[0]=h):h=t[0];let[g,_]=(0,J.useState)(h),[v,b]=(0,J.useState)(null),x=v?.revealRequestId===l?v.range:null,S;t[1]===l?S=t[2]:(S=e=>{b({revealRequestId:l,range:e})},t[1]=l,t[2]=S);let C=S,w=(0,J.useRef)(null),T=(0,J.useRef)(null),E;t[3]!==r||t[4]!==n||t[5]!==f||t[6]!==a?(E={environmentId:n,cwd:r,relativePath:a,onPendingChange:f},t[3]=r,t[4]=n,t[5]=f,t[6]=a,t[7]=E):E=t[7];let D=es(E),O;t[8]!==s||t[9]!==r||t[10]!==n||t[11]!==a?(O=()=>bs(n,r,a,s),t[8]=s,t[9]=r,t[10]=n,t[11]=a,t[12]=O):O=t[12];let[k,ee]=(0,J.useState)(O),[te,ne]=(0,J.useState)(null);s!==(te??k.contents)&&(ee(bs(n,r,a,s)),ne(null));let{ready:re,onPostRender:ie}=Ss(k),A=(0,J.useRef)(null),ae;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(ae={onAttach:e=>{A.current=e},onComplete:()=>{A.current=null}},t[13]=ae):ae=t[13];let oe=ae,se;t[14]!==p||t[15]!==o||t[16]!==r||t[17]!==n||t[18]!==a||t[19]!==D?(se=e=>{let{file:t,lineAnnotations:i}=e;if(t.contents===fn(n,r,a)||(ne(t.contents),pn(n,r,a,t.contents),D.change(t.contents),!i))return;let s=bt(i);_(e=>e===i?e:s);for(let e of s)for(let n of e.metadata.entries)n.kind===`comment`&&p(o,y({id:n.id,filePath:a,startLine:n.startLine,endLine:n.endLine,text:n.text,contents:t.contents}))},t[14]=p,t[15]=o,t[16]=r,t[17]=n,t[18]=a,t[19]=D,t[20]=se):se=t[20];let ce=se,le;t[21]!==o||t[22]!==m||t[23]!==C?(le=e=>{C(null),m(o,e),_(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},t[21]=o,t[22]=m,t[23]=C,t[24]=le):le=t[24];let ue=le,j;t[25]!==p||t[26]!==o||t[27]!==s||t[28]!==g||t[29]!==a||t[30]!==C?(j=(e,t)=>{C(null);let n=g.flatMap(Os).find(t=>t.id===e);n&&p(o,y({id:n.id,filePath:a,startLine:n.startLine,endLine:n.endLine,text:t,contents:s})),_(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[25]=p,t[26]=o,t[27]=s,t[28]=g,t[29]=a,t[30]=C,t[31]=j):j=t[31];let M=j,N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{A.current?.setSelections([]),A.current?.blur();let{startLine:t,endLine:n}=q(e),r={id:xt(),kind:`draft`,startLine:t,endLine:n,text:``};_(e=>{let t=e.flatMap(Es),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},t[32]=N):N=t[32];let de=N,fe;t[33]===g?fe=t[34]:(fe=g.some(ws),t[33]=g,t[34]=fe);let P=fe,pe,me;t[35]!==P||t[36]!==C?(pe=()=>{let e=w.current;if(e)return Ho({root:e,editor:{setSelections:e=>A.current?.setSelections(e)},isBlocked:()=>P,onDismiss:()=>C(null)})},me=[P,C],t[35]=P,t[36]=C,t[37]=pe,t[38]=me):(pe=t[37],me=t[38]),(0,J.useEffect)(pe,me);let F;t[39]===C?F=t[40]:(F=e=>{C(e),e&&de(e)},t[39]=C,t[40]=F);let he=F,ge;t[41]!==ie||t[42]!==d||t[43]!==x?(ge=(e,t,n)=>{d(e,t,n),ie(t.file,n),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),n!==`unmount`&&(T.current=requestAnimationFrame(()=>{T.current=null,e.isConnected&&t.setSelectedLines(x,{notify:!1})}))},t[41]=ie,t[42]=d,t[43]=x,t[44]=ge):ge=t[44];let _e=ge,ve;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ve={overscrollSize:600,intersectionObserverMargin:1200},t[45]=ve):ve=t[45];let ye=!P,be=!P,xe=u?`wrap`:`scroll`,Se;t[46]===c?Se=t[47]:(Se=Ae(c),t[46]=c,t[47]=Se);let Ce;t[48]!==he||t[49]!==_e||t[50]!==c||t[51]!==C||t[52]!==ye||t[53]!==be||t[54]!==xe||t[55]!==Se?(Ce={disableFileHeader:!0,enableGutterUtility:ye,enableLineSelection:be,onGutterUtilityClick:C,onLineSelectionChange:C,onLineSelectionEnd:he,overflow:xe,theme:Se,preferredHighlighter:yn,themeType:c,unsafeCSS:Vt,onPostRender:_e},t[48]=he,t[49]=_e,t[50]=c,t[51]=C,t[52]=ye,t[53]=be,t[54]=xe,t[55]=Se,t[56]=Ce):Ce=t[56];let we;t[57]!==ue||t[58]!==M?(we=e=>(0,$.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,$.jsx)(dt,{kind:e.kind,rangeLabel:St(e.startLine,e.endLine),text:e.text,onCancel:()=>ue(e.id),onComment:t=>M(e.id,t),onDelete:()=>ue(e.id)},e.id))}),t[57]=ue,t[58]=M,t[59]=we):we=t[59];let Te;return t[60]!==re||t[61]!==k||t[62]!==ce||t[63]!==g||t[64]!==x||t[65]!==Ce||t[66]!==we?(Te=(0,$.jsx)(z,{createEditor:ys,children:(0,$.jsx)(`div`,{ref:w,className:`flex min-h-0 flex-1`,children:(0,$.jsx)(ze,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:ve,children:(0,$.jsx)(Ct,{file:k,edit:re,editorOptions:oe,onEditChange:ce,options:Ce,selectedLines:x,lineAnnotations:g,renderAnnotation:we,className:`min-h-full`})})})}),t[60]=re,t[61]=k,t[62]=ce,t[63]=g,t[64]=x,t[65]=Ce,t[66]=we,t[67]=Te):Te=t[67],Te}function ws(e){return e.metadata.entries.some(Ts)}function Ts(e){return e.kind===`draft`}function Es(e){let t=e.metadata.entries.filter(Ds);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function Ds(e){return e.kind!==`draft`}function Os(e){return e.metadata.entries}function ks(e){return e.removeReviewComment}function As(e){return e.addReviewComment}function js(e){let t=(0,Q.c)(18),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=es(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?void 0:e=>{let{markerOffset:t,checked:o}=e,s=mn(n,r,i)?.contents??a,c=Xo(s,t,o);c!==s&&(pn(n,r,i,c),u.change(c))},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==i||t[15]!==d||t[16]!==o?(f=(0,$.jsx)(Pt,{className:`min-h-0 flex-1`,children:(0,$.jsx)(zo,{text:a,cwd:r,relativePath:i,threadRef:o,onTaskListChange:d})}),t[12]=a,t[13]=r,t[14]=i,t[15]=d,t[16]=o,t[17]=f):f=t[17],f}function Ms(e,t){return e===`markdown`?t?`Show markdown source`:`Show rendered markdown`:e===`table`?t?`Show source`:`Show table`:t?`Show HTML source`:`Show rendered page`}function Ns(){try{return c(ts,T)??!0}catch(e){return console.error(e),!0}}function Ps(e){let t=(0,Q.c)(168),{environmentId:n,cwd:r,projectName:i,relativePath:a,attachment:c,threadRef:u,composerDraftTarget:d,keybindings:f,availableEditors:p,revealLine:m,revealRequestId:h,onOpenFile:_,onNavigateFolder:v,folderTrail:y,onPendingChange:x,selectedFilePending:S,workspaceMutationId:C}=e,w;t[0]!==c||t[1]!==r||t[2]!==a?(w=c===void 0?Ko(a,r):a,t[0]=c,t[1]=r,t[2]=a,t[3]=w):w=t[3];let O=w,k=typeof d==`string`,{resolvedTheme:ee}=ye(),ie=Se(Is),[ae,oe]=(0,J.useState)(null),M=ae??ie,N=Ce(n,g),P=be(),pe=F(n),me=xe(n),_e=nn(n),ve;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ve={reportFailure:!1},t[4]=ve):ve=t[4];let we=$t(Qt.createUrl,ve),De;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(De={reportFailure:!1},t[5]=De):De=t[5];let ke=Te(on.open,De),I;t[6]===O?I=t[7]:(I=O!==null&&ce(O),t[6]=O,t[7]=I);let L=I,Ae;t[8]!==L||t[9]!==O?(Ae=O!==null&&!L&&le(O),t[8]=L,t[9]=O,t[10]=Ae):Ae=t[10];let je=Ae,Me;t[11]!==L||t[12]!==O?(Me=O!==null&&!L&&se(O),t[11]=L,t[12]=O,t[13]=Me):Me=t[13];let Ne=Me,Pe=Ne||L||je,Fe;t[14]===O?Fe=t[15]:(Fe=O!==null&&qt(O),t[14]=O,t[15]=Fe);let R=Fe,Ie;t[16]!==R||t[17]!==O?(Ie=O!==null&&!R&&an(O),t[16]=R,t[17]=O,t[18]=Ie):Ie=t[18];let Le=Ie,Re;t[19]!==c||t[20]!==O?(Re=c!==void 0||O!==null&&A(O),t[19]=c,t[20]=O,t[21]=Re):Re=t[21];let z=Re,ze=re(n),{canReadFiles:Be}=ze,Ve=Ce(n,E),B=dn(n,r,O,c===void 0&&O!==null),He=B.readError?.resolvedPath??B.readError?.operationPath,V=c===void 0?O??(y===void 0?null:``):null,Ue;t[22]!==V||t[23]!==y?(Ue=V===null?null:ho(y,V),t[22]=V,t[23]=y,t[24]=Ue):Ue=t[24];let H=Ue,We=c===void 0&&(B.isNotFile||y!==void 0&&B.data===null&&B.error===null),Ge=We&&z?O:null,U=We?null:O,[Ke,qe]=(0,J.useState)(Ns),Je=c!==void 0,Ye;t[25]!==Ke||t[26]!==U||t[27]!==Je?(Ye=Yo({relativePath:U,explorerOpen:Ke,attachmentOpen:Je}),t[25]=Ke,t[26]=U,t[27]=Je,t[28]=Ye):Ye=t[28];let Xe=Ye,[Qe,$e]=s(ns,!1,T),[et,tt]=s(rs,!0,T),[nt,rt]=s(is,!0,T),[it,at]=(0,J.useState)(null),W=(0,J.useRef)(null),ot;t[29]===U?ot=t[30]:(ot=U?qo(U):!1,t[29]=U,t[30]=ot);let st=ot,G;t[31]!==c||t[32]!==U?(G=U&&c===void 0?Jt({name:U}):null,t[31]=c,t[32]=U,t[33]=G):G=t[33];let ct=G,lt=m===null||it?.path===O&&it.requestId===h,ut=st&&Qe&&lt,K=R||Le&&et&&lt,dt=ct!==null&&nt&&lt,ft=st?`markdown`:ct?`table`:Le?`html`:null,pt=U!==null&&c===void 0&&ft!==null,mt=U!==null&&B.data!==null&&!(st&&ut)&&!(ct&&dt)&&!K,ht=st?ut:ct?dt:K,gt=st?$e:ct?rt:tt,_t;t[34]!==c||t[35]!==N||t[36]!==L||t[37]!==_e||t[38]!==U?(_t=N&&U!==null&&c===void 0&&!L&&_e&&an(U),t[34]=c,t[35]=N,t[36]=L,t[37]=_e,t[38]=U,t[39]=_t):_t=t[39];let vt=_t,yt;t[40]!==H||t[41]!==We||t[42]!==v?(yt=e=>{let t=H!==null&&fo(H)===e?H:e;v(t,ho(H??void 0,t),!We)},t[40]=H,t[41]=We,t[42]=v,t[43]=yt):yt=t[43];let bt=yt,xt;t[44]!==c||t[45]!==V||t[46]!==r||t[47]!==O?(xt=V===``?r:O&&c===void 0?Ee(O,r):null,t[44]=c,t[45]=V,t[46]=r,t[47]=O,t[48]=xt):xt=t[48];let q=xt,St=_s(O,m,h),Ct=c===void 0&&O!==null&&(We||!Pe&&!R)&&!S,Tt=`file:${n}:${r}:${O??``}`,Et;t[49]!==B.refresh||t[50]!==Ct||t[51]!==Tt||t[52]!==C?(Et={enabled:Ct,mutationId:C,refresh:B.refresh,resourceKey:Tt},t[49]=B.refresh,t[50]=Ct,t[51]=Tt,t[52]=C,t[53]=Et):Et=t[53],xn(Et);let Dt;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(Dt=()=>{let e=W.current?.querySelectorAll(`[data-file-crumb]`);e?.[e.length-1]?.scrollIntoView({block:`nearest`,inline:`end`}),W.current?.querySelector(`[data-current-file-crumb='true']`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},t[54]=Dt):Dt=t[54];let Ot;t[55]!==V||t[56]!==H?(Ot=[V,H],t[55]=V,t[56]=H,t[57]=Ot):Ot=t[57],(0,J.useEffect)(Dt,Ot);let kt;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(kt=()=>{qe(Fs)},t[58]=kt):kt=t[58];let At=kt,jt;t[59]!==q||t[60]!==N||t[61]!==Be||t[62]!==we||t[63]!==r||t[64]!==me||t[65]!==ke||t[66]!==u?(jt=()=>{Be&&N&&q&&me&&(async()=>{let e=await rn({threadRef:u,filePath:q,workspaceRoot:r,httpBaseUrl:me,createAssetUrl:we,openPreview:ke});if(e._tag===`Success`||te(e))return;let t=ne(e);ge.add(Oe({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[59]=q,t[60]=N,t[61]=Be,t[62]=we,t[63]=r,t[64]=me,t[65]=ke,t[66]=u,t[67]=jt):jt=t[67];let Mt=jt;if(c===void 0&&!Be){if(ze.isPending){let e;return t[68]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(he,{className:`size-4`}),`Checking file access...`]}),t[68]=e):e=t[68],e}let e=ze.error??`This connection cannot read host files.`,n;return t[69]===e?n=t[70]:(n=(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:e}),t[69]=e,t[70]=n),n}let Nt;t[71]!==q||t[72]!==p||t[73]!==V||t[74]!==H||t[75]!==vt||t[76]!==pt||t[77]!==r||t[78]!==n||t[79]!==Ke||t[80]!==Mt||t[81]!==z||t[82]!==f||t[83]!==bt||t[84]!==_||t[85]!==U||t[86]!==P||t[87]!==i||t[88]!==O||t[89]!==pe||t[90]!==ht||t[91]!==ft||t[92]!==h||t[93]!==gt||t[94]!==mt||t[95]!==M||t[96]!==C?(Nt=V!==null&&H!==null?(0,$.jsxs)(`div`,{className:Kt,"data-surface-subheader":!0,children:[(0,$.jsx)(Pt,{radius:`none`,ref:W,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1`,"data-file-breadcrumbs":!0,children:(0,$.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:(0,$.jsx)(Ro,{cwd:r,environmentId:n,onNavigateFolder:bt,onOpenFile:_,projectName:i,relativePath:V,trail:H,workspaceMutationId:C})})}),q&&(n===P||pe.mode!==`local-exec`)?(0,$.jsx)(Cn,{environmentId:n,keybindings:f,availableEditors:p,openInCwd:q,compact:!0}):null,pt&&ft?(0,$.jsx)(Zt,{label:Ms(ft,ht),pressed:ht,onPress:()=>{let e=!ht;gt(e),at(e&&O!==null?{path:O,requestId:h}:null)},children:(0,$.jsx)(de,{className:`size-3.5`,icon:ht?j:ft===`table`?ue:fe})}):null,mt?(0,$.jsx)(Zt,{label:M?`Disable word wrap`:`Enable word wrap`,pressed:M,onPress:()=>oe(!M),children:(0,$.jsx)(b,{className:`size-3.5`})}):null,vt?(0,$.jsx)(Zt,{label:`Open file in preview browser`,onPress:Mt,children:(0,$.jsx)(o,{className:`size-3.5`})}):null,!z&&U!==null?(0,$.jsx)(Zt,{label:Ke?`Hide file explorer`:`Show file explorer`,pressed:Ke,onPress:At,children:(0,$.jsx)(l,{className:`size-3.5`})}):null]}):null,t[71]=q,t[72]=p,t[73]=V,t[74]=H,t[75]=vt,t[76]=pt,t[77]=r,t[78]=n,t[79]=Ke,t[80]=Mt,t[81]=z,t[82]=f,t[83]=bt,t[84]=_,t[85]=U,t[86]=P,t[87]=i,t[88]=O,t[89]=pe,t[90]=ht,t[91]=ft,t[92]=h,t[93]=gt,t[94]=mt,t[95]=M,t[96]=C,t[97]=Nt):Nt=t[97];let Ft;t[98]!==c||t[99]!==Ve||t[100]!==ze.isPending||t[101]!==z||t[102]!==O?(Ft=O&&!c&&!z&&!Ve&&!ze.isPending?(0,$.jsx)(`div`,{className:`shrink-0 border-b px-3 py-1.5 text-2xs text-muted-foreground`,children:`Read-only connection. Unsaved edits are kept until write access returns.`}):null,t[98]=c,t[99]=Ve,t[100]=ze.isPending,t[101]=z,t[102]=O,t[103]=Ft):Ft=t[103];let It;t[104]!==c||t[105]!==B.data||t[106]!==Pe||t[107]!==U||t[108]!==K?(It=U&&c===void 0&&!Pe&&!K&&B.data?.truncated?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-warning/20 bg-warning-surface px-3 py-1.5 text-2xs text-warning-foreground`,children:[`Preview limited to the first 1 MB of a `,B.data.byteLength.toLocaleString(),` byte file.`]}):null,t[104]=c,t[105]=B.data,t[106]=Pe,t[107]=U,t[108]=K,t[109]=It):It=t[109];let Lt=U?`flex`:`hidden`,Rt;t[110]===Lt?Rt=t[111]:(Rt=D(`min-w-0 flex-1 flex-col overflow-hidden`,Lt),t[110]=Lt,t[111]=Rt);let zt;t[112]!==q||t[113]!==c||t[114]!==He||t[115]!==Ve||t[116]!==d||t[117]!==r||t[118]!==k||t[119]!==n||t[120]!==B.data||t[121]!==B.error||t[122]!==B.readError||t[123]!==je||t[124]!==We||t[125]!==z||t[126]!==Ne||t[127]!==st||t[128]!==L||t[129]!==St||t[130]!==x||t[131]!==O||t[132]!==K||t[133]!==ut||t[134]!==dt||t[135]!==ee||t[136]!==h||t[137]!==ct||t[138]!==u||t[139]!==M||t[140]!==C?(zt=We?null:O&&c?(0,$.jsx)(Bt,{name:c.name,mimeType:c.mimeType,sizeBytes:c.sizeBytes,asset:{environmentId:n,attachmentId:c.id},htmlRender:c.htmlRender===!0,threadRef:u},`${n}:${c.id}`):O&&L&&q?(0,$.jsx)(ss,{environmentId:n,threadRef:u,draft:k,absolutePath:q,workspaceRoot:r,name:O,workspaceMutationId:C},`${n}:${u.threadId}:${q}`):O&&je&&q?(0,$.jsx)(ls,{environmentId:n,threadRef:u,draft:k,absolutePath:q,workspaceRoot:r,name:O,workspaceMutationId:C},`${n}:${u.threadId}:${q}`):O&&Ne&&q?(0,$.jsx)(as,{environmentId:n,threadRef:u,draft:k,absolutePath:q,workspaceRoot:r,alt:O,workspaceMutationId:C},q):O&&K&&q?(0,$.jsx)(os,{environmentId:n,threadRef:u,draft:k,absolutePath:q,workspaceRoot:r,title:O,workspaceMutationId:C},q):O&&B.error&&B.data===null?(0,$.jsx)(`div`,{role:`alert`,className:`scrollbar-gutter-both flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,$.jsxs)(`div`,{className:`my-auto flex shrink-0 flex-col gap-3 px-6 py-6 text-center text-xs leading-relaxed`,children:[(0,$.jsx)(`p`,{className:`text-destructive`,children:B.readError?Jo(B.readError):B.error}),He?(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Attempted path`,(0,$.jsx)(`code`,{className:`block break-all font-mono text-foreground select-all`,children:He})]}):null,z?null:(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Workspace folder:`,` `,(0,$.jsx)(`code`,{className:`break-all font-mono select-all`,children:B.readError?.cwd??r}),`. Check the link's path or locate the file in Files.`]})]})}):O&&B.data===null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(he,{size:`lg`})}):O&&B.data?st&&ut?(0,$.jsx)(js,{environmentId:n,cwd:r,relativePath:O,threadRef:u,contents:B.data.contents,readOnly:z||!Ve,onPendingChange:x},O):ct&&dt?(0,$.jsx)(Yt,{name:O,text:B.data.contents,delimiter:ct},O):B.data.truncated||z||!Ve?(0,$.jsx)(wt,{name:O,text:B.data.contents,cacheKey:Go(r,O,B.data.contents),onPostRender:St}):(0,$.jsx)(Ze,{children:(0,$.jsx)(Cs,{environmentId:n,cwd:r,relativePath:O,composerDraftTarget:d,contents:B.data.contents,resolvedTheme:ee,revealRequestId:h,wordWrap:M,onPostRender:St,onPendingChange:x},`${O}:${ee}`)}):null,t[112]=q,t[113]=c,t[114]=He,t[115]=Ve,t[116]=d,t[117]=r,t[118]=k,t[119]=n,t[120]=B.data,t[121]=B.error,t[122]=B.readError,t[123]=je,t[124]=We,t[125]=z,t[126]=Ne,t[127]=st,t[128]=L,t[129]=St,t[130]=x,t[131]=O,t[132]=K,t[133]=ut,t[134]=dt,t[135]=ee,t[136]=h,t[137]=ct,t[138]=u,t[139]=M,t[140]=C,t[141]=zt):zt=t[141];let Vt;t[142]!==Rt||t[143]!==zt?(Vt=(0,$.jsx)(`div`,{className:Rt,children:zt}),t[142]=Rt,t[143]=zt,t[144]=Vt):Vt=t[144];let Ht;t[145]!==H||t[146]!==r||t[147]!==n||t[148]!==B.refresh||t[149]!==Ge||t[150]!==Pe||t[151]!==R||t[152]!==_||t[153]!==U||t[154]!==i||t[155]!==O||t[156]!==h||t[157]!==Xe||t[158]!==C?(Ht=Xe?(0,$.jsx)(Mo,{resizable:!!U,children:(0,$.jsx)(Oo,{environmentId:n,cwd:Ge??r,projectName:Ge??i,hostFolder:Ge!==null,selectedPath:Ge===null?O:go(Ge,H??Ge),selectedPathRevealId:h,onOpenFile:_,workspaceMutationId:C,...U&&!Pe&&!R?{onRefreshSelectedFile:B.refresh}:{}},`${n}:${Ge??r}`)}):null,t[145]=H,t[146]=r,t[147]=n,t[148]=B.refresh,t[149]=Ge,t[150]=Pe,t[151]=R,t[152]=_,t[153]=U,t[154]=i,t[155]=O,t[156]=h,t[157]=Xe,t[158]=C,t[159]=Ht):Ht=t[159];let Ut;t[160]!==Vt||t[161]!==Ht?(Ut=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[Vt,Ht]}),t[160]=Vt,t[161]=Ht,t[162]=Ut):Ut=t[162];let Wt;return t[163]!==Nt||t[164]!==Ft||t[165]!==It||t[166]!==Ut?(Wt=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[Nt,Ft,It,Ut]}),t[163]=Nt,t[164]=Ft,t[165]=It,t[166]=Ut,t[167]=Wt):Wt=t[167],Wt}function Fs(e){let t=!e;try{a(ts,t,T)}catch(e){console.error(e)}return t}function Is(e){return e.wordWrap}export{Ps as default};
34
- //# sourceMappingURL=FilePreviewPanel-CjKP3Q7G.js.map
33
+ `,e+1))n+=1;return n<=Me}function Ss(e){let t=(0,Q.c)(15),n=Le(),[r,i]=(0,J.useState)(null),a;t[0]!==e||t[1]!==n?(a=xs(n,e),t[0]=e,t[1]=n,t[2]=a):a=t[2];let o=!a||r===e,s,c;t[3]!==e||t[4]!==o||t[5]!==n?(s=()=>{o||n===void 0||n.primeFileHighlightCache(e).catch(()=>i(e))},c=[e,o,n],t[3]=e,t[4]=o,t[5]=n,t[6]=s,t[7]=c):(s=t[6],c=t[7]),(0,J.useEffect)(s,c);let l;t[8]!==e||t[9]!==o||t[10]!==n?(l=(t,r)=>{o||r===`unmount`||t?.cacheKey!==e.cacheKey||n?.getFileResultCache(e)!==void 0&&i(e)},t[8]=e,t[9]=o,t[10]=n,t[11]=l):l=t[11];let u=l,d;return t[12]!==u||t[13]!==o?(d={ready:o,onPostRender:u},t[12]=u,t[13]=o,t[14]=d):d=t[14],d}function Cs(e){let t=(0,Q.c)(68),{environmentId:n,cwd:r,relativePath:i,composerDraftTarget:a,contents:s,resolvedTheme:c,revealRequestId:l,wordWrap:u,onPostRender:d,onPendingChange:f}=e,p=o(As),m=o(ks),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[0]=h):h=t[0];let[g,_]=(0,J.useState)(h),[v,y]=(0,J.useState)(null),b=v?.revealRequestId===l?v.range:null,x;t[1]===l?x=t[2]:(x=e=>{y({revealRequestId:l,range:e})},t[1]=l,t[2]=x);let C=x,w=(0,J.useRef)(null),T=(0,J.useRef)(null),E;t[3]!==r||t[4]!==n||t[5]!==f||t[6]!==i?(E={environmentId:n,cwd:r,relativePath:i,onPendingChange:f},t[3]=r,t[4]=n,t[5]=f,t[6]=i,t[7]=E):E=t[7];let D=es(E),O;t[8]!==s||t[9]!==r||t[10]!==n||t[11]!==i?(O=()=>bs(n,r,i,s),t[8]=s,t[9]=r,t[10]=n,t[11]=i,t[12]=O):O=t[12];let[k,ee]=(0,J.useState)(O),[te,ne]=(0,J.useState)(null);s!==(te??k.contents)&&(ee(bs(n,r,i,s)),ne(null));let{ready:re,onPostRender:ie}=Ss(k),A=(0,J.useRef)(null),ae;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(ae={onAttach:e=>{A.current=e},onComplete:()=>{A.current=null}},t[13]=ae):ae=t[13];let oe=ae,se;t[14]!==p||t[15]!==a||t[16]!==r||t[17]!==n||t[18]!==i||t[19]!==D?(se=e=>{let{file:t,lineAnnotations:o}=e;if(t.contents===fn(n,r,i)||(ne(t.contents),pn(n,r,i,t.contents),D.change(t.contents),!o))return;let s=Mt(o);_(e=>e===o?e:s);for(let e of s)for(let n of e.metadata.entries)n.kind===`comment`&&p(a,S({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:n.text,contents:t.contents}))},t[14]=p,t[15]=a,t[16]=r,t[17]=n,t[18]=i,t[19]=D,t[20]=se):se=t[20];let ce=se,le;t[21]!==a||t[22]!==m||t[23]!==C?(le=e=>{C(null),m(a,e),_(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},t[21]=a,t[22]=m,t[23]=C,t[24]=le):le=t[24];let ue=le,j;t[25]!==p||t[26]!==a||t[27]!==s||t[28]!==g||t[29]!==i||t[30]!==C?(j=(e,t)=>{C(null);let n=g.flatMap(Os).find(t=>t.id===e);n&&p(a,S({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:t,contents:s})),_(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[25]=p,t[26]=a,t[27]=s,t[28]=g,t[29]=i,t[30]=C,t[31]=j):j=t[31];let M=j,N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{A.current?.setSelections([]),A.current?.blur();let{startLine:t,endLine:n}=Pt(e),r={id:Nt(),kind:`draft`,startLine:t,endLine:n,text:``};_(e=>{let t=e.flatMap(Es),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},t[32]=N):N=t[32];let de=N,fe;t[33]===g?fe=t[34]:(fe=g.some(ws),t[33]=g,t[34]=fe);let P=fe,pe,me;t[35]!==P||t[36]!==C?(pe=()=>{let e=w.current;if(e)return Ho({root:e,editor:{setSelections:e=>A.current?.setSelections(e)},isBlocked:()=>P,onDismiss:()=>C(null)})},me=[P,C],t[35]=P,t[36]=C,t[37]=pe,t[38]=me):(pe=t[37],me=t[38]),(0,J.useEffect)(pe,me);let F;t[39]===C?F=t[40]:(F=e=>{C(e),e&&de(e)},t[39]=C,t[40]=F);let he=F,ge;t[41]!==ie||t[42]!==d||t[43]!==b?(ge=(e,t,n)=>{d(e,t,n),ie(t.file,n),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),n!==`unmount`&&(T.current=requestAnimationFrame(()=>{T.current=null,e.isConnected&&t.setSelectedLines(b,{notify:!1})}))},t[41]=ie,t[42]=d,t[43]=b,t[44]=ge):ge=t[44];let _e=ge,ve;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ve={overscrollSize:600,intersectionObserverMargin:1200},t[45]=ve):ve=t[45];let ye=!P,be=!P,xe=u?`wrap`:`scroll`,Se;t[46]===c?Se=t[47]:(Se=Ae(c),t[46]=c,t[47]=Se);let Ce;t[48]!==he||t[49]!==_e||t[50]!==c||t[51]!==C||t[52]!==ye||t[53]!==be||t[54]!==xe||t[55]!==Se?(Ce={disableFileHeader:!0,enableGutterUtility:ye,enableLineSelection:be,onGutterUtilityClick:C,onLineSelectionChange:C,onLineSelectionEnd:he,overflow:xe,theme:Se,preferredHighlighter:bn,themeType:c,unsafeCSS:wt,onPostRender:_e},t[48]=he,t[49]=_e,t[50]=c,t[51]=C,t[52]=ye,t[53]=be,t[54]=xe,t[55]=Se,t[56]=Ce):Ce=t[56];let we;t[57]!==ue||t[58]!==M?(we=e=>(0,$.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,$.jsx)(dt,{kind:e.kind,rangeLabel:Ft(e.startLine,e.endLine),text:e.text,onCancel:()=>ue(e.id),onComment:t=>M(e.id,t),onDelete:()=>ue(e.id)},e.id))}),t[57]=ue,t[58]=M,t[59]=we):we=t[59];let Te;return t[60]!==re||t[61]!==k||t[62]!==ce||t[63]!==g||t[64]!==b||t[65]!==Ce||t[66]!==we?(Te=(0,$.jsx)(z,{createEditor:ys,children:(0,$.jsx)(`div`,{ref:w,className:`flex min-h-0 flex-1`,children:(0,$.jsx)(ze,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:ve,children:(0,$.jsx)(It,{file:k,edit:re,editorOptions:oe,onEditChange:ce,options:Ce,selectedLines:b,lineAnnotations:g,renderAnnotation:we,className:`min-h-full`})})})}),t[60]=re,t[61]=k,t[62]=ce,t[63]=g,t[64]=b,t[65]=Ce,t[66]=we,t[67]=Te):Te=t[67],Te}function ws(e){return e.metadata.entries.some(Ts)}function Ts(e){return e.kind===`draft`}function Es(e){let t=e.metadata.entries.filter(Ds);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function Ds(e){return e.kind!==`draft`}function Os(e){return e.metadata.entries}function ks(e){return e.removeReviewComment}function As(e){return e.addReviewComment}function js(e){let t=(0,Q.c)(18),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=es(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?void 0:e=>{let{markerOffset:t,checked:o}=e,s=mn(n,r,i)?.contents??a,c=Xo(s,t,o);c!==s&&(pn(n,r,i,c),u.change(c))},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==i||t[15]!==d||t[16]!==o?(f=(0,$.jsx)(qt,{className:`min-h-0 flex-1`,children:(0,$.jsx)(zo,{text:a,cwd:r,relativePath:i,threadRef:o,onTaskListChange:d})}),t[12]=a,t[13]=r,t[14]=i,t[15]=d,t[16]=o,t[17]=f):f=t[17],f}function Ms(e,t){return e===`markdown`?t?`Show markdown source`:`Show rendered markdown`:e===`table`?t?`Show source`:`Show table`:t?`Show HTML source`:`Show rendered page`}function Ns(){try{return s(ts,h)??!0}catch(e){return console.error(e),!0}}function Ps(e){let t=(0,Q.c)(168),{environmentId:n,cwd:r,projectName:i,relativePath:a,attachment:o,threadRef:s,composerDraftTarget:c,keybindings:d,availableEditors:p,revealLine:m,revealRequestId:_,onOpenFile:v,onNavigateFolder:y,folderTrail:x,onPendingChange:S,selectedFilePending:C,workspaceMutationId:T}=e,E;t[0]!==o||t[1]!==r||t[2]!==a?(E=o===void 0?Ko(a,r):a,t[0]=o,t[1]=r,t[2]=a,t[3]=E):E=t[3];let O=E,k=typeof c==`string`,{resolvedTheme:A}=be(),ae=Se(Is),[se,le]=(0,J.useState)(null),M=se??ae,N=Ce(n,b),P=xe(),pe=F(n),me=ve(n),_e=nn(n),ye;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ye={reportFailure:!1},t[4]=ye):ye=t[4];let we=$t(Qt.createUrl,ye),De;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(De={reportFailure:!1},t[5]=De):De=t[5];let ke=Te(on.open,De),I;t[6]===O?I=t[7]:(I=O!==null&&ie(O),t[6]=O,t[7]=I);let L=I,Ae;t[8]!==L||t[9]!==O?(Ae=O!==null&&!L&&oe(O),t[8]=L,t[9]=O,t[10]=Ae):Ae=t[10];let je=Ae,Me;t[11]!==L||t[12]!==O?(Me=O!==null&&!L&&re(O),t[11]=L,t[12]=O,t[13]=Me):Me=t[13];let Ne=Me,Pe=Ne||L||je,Fe;t[14]===O?Fe=t[15]:(Fe=O!==null&&bt(O),t[14]=O,t[15]=Fe);let R=Fe,Ie;t[16]!==R||t[17]!==O?(Ie=O!==null&&!R&&an(O),t[16]=R,t[17]=O,t[18]=Ie):Ie=t[18];let Le=Ie,Re;t[19]!==o||t[20]!==O?(Re=o!==void 0||O!==null&&ee(O),t[19]=o,t[20]=O,t[21]=Re):Re=t[21];let z=Re,ze=ce(n),{canReadFiles:Be}=ze,Ve=Ce(n,g),B=dn(n,r,O,o===void 0&&O!==null),He=B.readError?.resolvedPath??B.readError?.operationPath,V=o===void 0?O??(x===void 0?null:``):null,Ue;t[22]!==V||t[23]!==x?(Ue=V===null?null:ho(x,V),t[22]=V,t[23]=x,t[24]=Ue):Ue=t[24];let H=Ue,We=o===void 0&&(B.isNotFile||x!==void 0&&B.data===null&&B.error===null),Ge=We&&z?O:null,U=We?null:O,[Ke,qe]=(0,J.useState)(Ns),Je=o!==void 0,Ye;t[25]!==Ke||t[26]!==U||t[27]!==Je?(Ye=Yo({relativePath:U,explorerOpen:Ke,attachmentOpen:Je}),t[25]=Ke,t[26]=U,t[27]=Je,t[28]=Ye):Ye=t[28];let Xe=Ye,[Qe,$e]=u(ns,!1,h),[et,tt]=u(rs,!0,h),[nt,rt]=u(is,!0,h),[it,at]=(0,J.useState)(null),W=(0,J.useRef)(null),ot;t[29]===U?ot=t[30]:(ot=U?qo(U):!1,t[29]=U,t[30]=ot);let st=ot,G;t[31]!==o||t[32]!==U?(G=U&&o===void 0?Ot({name:U}):null,t[31]=o,t[32]=U,t[33]=G):G=t[33];let ct=G,lt=m===null||it?.path===O&&it.requestId===_,ut=st&&Qe&&lt,K=R||Le&&et&&lt,dt=ct!==null&&nt&&lt,ft=st?`markdown`:ct?`table`:Le?`html`:null,pt=U!==null&&o===void 0&&ft!==null,mt=U!==null&&B.data!==null&&!(st&&ut)&&!(ct&&dt)&&!K,ht=st?ut:ct?dt:K,gt=st?$e:ct?rt:tt,vt;t[34]!==o||t[35]!==N||t[36]!==L||t[37]!==_e||t[38]!==U?(vt=N&&U!==null&&o===void 0&&!L&&_e&&an(U),t[34]=o,t[35]=N,t[36]=L,t[37]=_e,t[38]=U,t[39]=vt):vt=t[39];let xt=vt,St;t[40]!==H||t[41]!==We||t[42]!==y?(St=e=>{let t=H!==null&&fo(H)===e?H:e;y(t,ho(H??void 0,t),!We)},t[40]=H,t[41]=We,t[42]=y,t[43]=St):St=t[43];let Ct=St,wt;t[44]!==o||t[45]!==V||t[46]!==r||t[47]!==O?(wt=V===``?r:O&&o===void 0?Ee(O,r):null,t[44]=o,t[45]=V,t[46]=r,t[47]=O,t[48]=wt):wt=t[48];let q=wt,Tt=_s(O,m,_),kt=o===void 0&&O!==null&&(We||!Pe&&!R)&&!C,At=`file:${n}:${r}:${O??``}`,jt;t[49]!==B.refresh||t[50]!==kt||t[51]!==At||t[52]!==T?(jt={enabled:kt,mutationId:T,refresh:B.refresh,resourceKey:At},t[49]=B.refresh,t[50]=kt,t[51]=At,t[52]=T,t[53]=jt):jt=t[53],xn(jt);let Mt;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=()=>{let e=W.current?.querySelectorAll(`[data-file-crumb]`);e?.[e.length-1]?.scrollIntoView({block:`nearest`,inline:`end`}),W.current?.querySelector(`[data-current-file-crumb='true']`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},t[54]=Mt):Mt=t[54];let Nt;t[55]!==V||t[56]!==H?(Nt=[V,H],t[55]=V,t[56]=H,t[57]=Nt):Nt=t[57],(0,J.useEffect)(Mt,Nt);let Pt;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(Pt=()=>{qe(Fs)},t[58]=Pt):Pt=t[58];let Ft=Pt,It;t[59]!==q||t[60]!==N||t[61]!==Be||t[62]!==we||t[63]!==r||t[64]!==me||t[65]!==ke||t[66]!==s?(It=()=>{Be&&N&&q&&me&&(async()=>{let e=await rn({threadRef:s,filePath:q,workspaceRoot:r,httpBaseUrl:me,createAssetUrl:we,openPreview:ke});if(e._tag===`Success`||ne(e))return;let t=te(e);ge.add(Oe({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[59]=q,t[60]=N,t[61]=Be,t[62]=we,t[63]=r,t[64]=me,t[65]=ke,t[66]=s,t[67]=It):It=t[67];let Rt=It;if(o===void 0&&!Be){if(ze.isPending){let e;return t[68]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(he,{className:`size-4`}),`Checking file access...`]}),t[68]=e):e=t[68],e}let e=ze.error??`This connection cannot read host files.`,n;return t[69]===e?n=t[70]:(n=(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:e}),t[69]=e,t[70]=n),n}let zt;t[71]!==q||t[72]!==p||t[73]!==V||t[74]!==H||t[75]!==xt||t[76]!==pt||t[77]!==r||t[78]!==n||t[79]!==Ke||t[80]!==Rt||t[81]!==z||t[82]!==d||t[83]!==Ct||t[84]!==v||t[85]!==U||t[86]!==P||t[87]!==i||t[88]!==O||t[89]!==pe||t[90]!==ht||t[91]!==ft||t[92]!==_||t[93]!==gt||t[94]!==mt||t[95]!==M||t[96]!==T?(zt=V!==null&&H!==null?(0,$.jsxs)(`div`,{className:Et,"data-surface-subheader":!0,children:[(0,$.jsx)(qt,{radius:`none`,ref:W,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1`,"data-file-breadcrumbs":!0,children:(0,$.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:(0,$.jsx)(Ro,{cwd:r,environmentId:n,onNavigateFolder:Ct,onOpenFile:v,projectName:i,relativePath:V,trail:H,workspaceMutationId:T})})}),q&&(n===P||pe.mode!==`local-exec`)?(0,$.jsx)(Cn,{environmentId:n,keybindings:d,availableEditors:p,openInCwd:q,compact:!0}):null,pt&&ft?(0,$.jsx)(_t,{label:Ms(ft,ht),pressed:ht,onPress:()=>{let e=!ht;gt(e),at(e&&O!==null?{path:O,requestId:_}:null)},children:(0,$.jsx)(de,{className:`size-3.5`,icon:ht?fe:ft===`table`?j:ue})}):null,mt?(0,$.jsx)(_t,{label:M?`Disable word wrap`:`Enable word wrap`,pressed:M,onPress:()=>le(!M),children:(0,$.jsx)(w,{className:`size-3.5`})}):null,xt?(0,$.jsx)(_t,{label:`Open file in preview browser`,onPress:Rt,children:(0,$.jsx)(f,{className:`size-3.5`})}):null,!z&&U!==null?(0,$.jsx)(_t,{label:Ke?`Hide file explorer`:`Show file explorer`,pressed:Ke,onPress:Ft,children:(0,$.jsx)(l,{className:`size-3.5`})}):null]}):null,t[71]=q,t[72]=p,t[73]=V,t[74]=H,t[75]=xt,t[76]=pt,t[77]=r,t[78]=n,t[79]=Ke,t[80]=Rt,t[81]=z,t[82]=d,t[83]=Ct,t[84]=v,t[85]=U,t[86]=P,t[87]=i,t[88]=O,t[89]=pe,t[90]=ht,t[91]=ft,t[92]=_,t[93]=gt,t[94]=mt,t[95]=M,t[96]=T,t[97]=zt):zt=t[97];let Bt;t[98]!==o||t[99]!==Ve||t[100]!==ze.isPending||t[101]!==z||t[102]!==O?(Bt=O&&!o&&!z&&!Ve&&!ze.isPending?(0,$.jsx)(`div`,{className:`shrink-0 border-b px-3 py-1.5 text-2xs text-muted-foreground`,children:`Read-only connection. Unsaved edits are kept until write access returns.`}):null,t[98]=o,t[99]=Ve,t[100]=ze.isPending,t[101]=z,t[102]=O,t[103]=Bt):Bt=t[103];let Vt;t[104]!==o||t[105]!==B.data||t[106]!==Pe||t[107]!==U||t[108]!==K?(Vt=U&&o===void 0&&!Pe&&!K&&B.data?.truncated?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-warning/20 bg-warning-surface px-3 py-1.5 text-2xs text-warning-foreground`,children:[`Preview limited to the first 1 MB of a `,B.data.byteLength.toLocaleString(),` byte file.`]}):null,t[104]=o,t[105]=B.data,t[106]=Pe,t[107]=U,t[108]=K,t[109]=Vt):Vt=t[109];let Ht=U?`flex`:`hidden`,Ut;t[110]===Ht?Ut=t[111]:(Ut=D(`min-w-0 flex-1 flex-col overflow-hidden`,Ht),t[110]=Ht,t[111]=Ut);let Wt;t[112]!==q||t[113]!==o||t[114]!==He||t[115]!==Ve||t[116]!==c||t[117]!==r||t[118]!==k||t[119]!==n||t[120]!==B.data||t[121]!==B.error||t[122]!==B.readError||t[123]!==je||t[124]!==We||t[125]!==z||t[126]!==Ne||t[127]!==st||t[128]!==L||t[129]!==Tt||t[130]!==S||t[131]!==O||t[132]!==K||t[133]!==ut||t[134]!==dt||t[135]!==A||t[136]!==_||t[137]!==ct||t[138]!==s||t[139]!==M||t[140]!==T?(Wt=We?null:O&&o?(0,$.jsx)(Dt,{name:o.name,mimeType:o.mimeType,sizeBytes:o.sizeBytes,asset:{environmentId:n,attachmentId:o.id},htmlRender:o.htmlRender===!0,threadRef:s},`${n}:${o.id}`):O&&L&&q?(0,$.jsx)(ss,{environmentId:n,threadRef:s,draft:k,absolutePath:q,workspaceRoot:r,name:O,workspaceMutationId:T},`${n}:${s.threadId}:${q}`):O&&je&&q?(0,$.jsx)(ls,{environmentId:n,threadRef:s,draft:k,absolutePath:q,workspaceRoot:r,name:O,workspaceMutationId:T},`${n}:${s.threadId}:${q}`):O&&Ne&&q?(0,$.jsx)(as,{environmentId:n,threadRef:s,draft:k,absolutePath:q,workspaceRoot:r,alt:O,workspaceMutationId:T},q):O&&K&&q?(0,$.jsx)(os,{environmentId:n,threadRef:s,draft:k,absolutePath:q,workspaceRoot:r,title:O,workspaceMutationId:T},q):O&&B.error&&B.data===null?(0,$.jsx)(`div`,{role:`alert`,className:`scrollbar-gutter-both flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,$.jsxs)(`div`,{className:`my-auto flex shrink-0 flex-col gap-3 px-6 py-6 text-center text-xs leading-relaxed`,children:[(0,$.jsx)(`p`,{className:`text-destructive`,children:B.readError?Jo(B.readError):B.error}),He?(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Attempted path`,(0,$.jsx)(`code`,{className:`block break-all font-mono text-foreground select-all`,children:He})]}):null,z?null:(0,$.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Workspace folder:`,` `,(0,$.jsx)(`code`,{className:`break-all font-mono select-all`,children:B.readError?.cwd??r}),`. Check the link's path or locate the file in Files.`]})]})}):O&&B.data===null?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(he,{size:`lg`})}):O&&B.data?st&&ut?(0,$.jsx)(js,{environmentId:n,cwd:r,relativePath:O,threadRef:s,contents:B.data.contents,readOnly:B.data.truncated||z||!Ve,onPendingChange:S},O):ct&&dt?(0,$.jsx)(yt,{name:O,text:B.data.contents,delimiter:ct},O):B.data.truncated||z||!Ve?(0,$.jsx)(Lt,{name:O,text:B.data.contents,cacheKey:Go(r,O,B.data.contents),onPostRender:Tt}):(0,$.jsx)(Ze,{children:(0,$.jsx)(Cs,{environmentId:n,cwd:r,relativePath:O,composerDraftTarget:c,contents:B.data.contents,resolvedTheme:A,revealRequestId:_,wordWrap:M,onPostRender:Tt,onPendingChange:S},`${O}:${A}`)}):null,t[112]=q,t[113]=o,t[114]=He,t[115]=Ve,t[116]=c,t[117]=r,t[118]=k,t[119]=n,t[120]=B.data,t[121]=B.error,t[122]=B.readError,t[123]=je,t[124]=We,t[125]=z,t[126]=Ne,t[127]=st,t[128]=L,t[129]=Tt,t[130]=S,t[131]=O,t[132]=K,t[133]=ut,t[134]=dt,t[135]=A,t[136]=_,t[137]=ct,t[138]=s,t[139]=M,t[140]=T,t[141]=Wt):Wt=t[141];let Gt;t[142]!==Ut||t[143]!==Wt?(Gt=(0,$.jsx)(`div`,{className:Ut,children:Wt}),t[142]=Ut,t[143]=Wt,t[144]=Gt):Gt=t[144];let Kt;t[145]!==H||t[146]!==r||t[147]!==n||t[148]!==B.refresh||t[149]!==Ge||t[150]!==Pe||t[151]!==R||t[152]!==v||t[153]!==U||t[154]!==i||t[155]!==O||t[156]!==_||t[157]!==Xe||t[158]!==T?(Kt=Xe?(0,$.jsx)(Mo,{resizable:!!U,children:(0,$.jsx)(Oo,{environmentId:n,cwd:Ge??r,projectName:Ge??i,hostFolder:Ge!==null,selectedPath:Ge===null?O:go(Ge,H??Ge),selectedPathRevealId:_,onOpenFile:v,workspaceMutationId:T,...U&&!Pe&&!R?{onRefreshSelectedFile:B.refresh}:{}},`${n}:${Ge??r}`)}):null,t[145]=H,t[146]=r,t[147]=n,t[148]=B.refresh,t[149]=Ge,t[150]=Pe,t[151]=R,t[152]=v,t[153]=U,t[154]=i,t[155]=O,t[156]=_,t[157]=Xe,t[158]=T,t[159]=Kt):Kt=t[159];let Jt;t[160]!==Gt||t[161]!==Kt?(Jt=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[Gt,Kt]}),t[160]=Gt,t[161]=Kt,t[162]=Jt):Jt=t[162];let Yt;return t[163]!==zt||t[164]!==Bt||t[165]!==Vt||t[166]!==Jt?(Yt=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[zt,Bt,Vt,Jt]}),t[163]=zt,t[164]=Bt,t[165]=Vt,t[166]=Jt,t[167]=Yt):Yt=t[167],Yt}function Fs(e){let t=!e;try{c(ts,t,h)}catch(e){console.error(e)}return t}function Is(e){return e.wordWrap}export{Ps as default};
34
+ //# sourceMappingURL=FilePreviewPanel-BUTTBdpa.js.map