@pi-chamber/web 1.0.3 → 1.0.4-rc.2

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 (303) hide show
  1. package/dist/assets/DiagramView-GKGxPczP.js +1 -0
  2. package/dist/assets/{DiffView-D19Jps0i.js → DiffView-Cay8VAqL.js} +6 -6
  3. package/dist/assets/FileSaveConflictDialog-BRM9TJo0.js +3 -0
  4. package/dist/assets/FilesView-CEeQzjc6.js +6 -0
  5. package/dist/assets/GitHubDetailScaffold-q4YP8iyJ.js +11 -0
  6. package/dist/assets/GitHubLinkPicker-B9xgIW8y.js +1 -0
  7. package/dist/assets/GitHubListPrimitives-XkALat1v.js +1 -0
  8. package/dist/assets/GitView-DV3d0oSJ.js +9 -0
  9. package/dist/assets/IssuesSurface-OTyt9f3A.js +7 -0
  10. package/dist/assets/JsonTreeView-X2Auiy_q.js +1 -0
  11. package/dist/assets/MarkdownRendererImpl-1HameF6j.js +12 -0
  12. package/dist/assets/PatchDiff-GMQAv4en.js +1 -0
  13. package/dist/assets/PierreDiffViewer-0X__nypk.js +134 -0
  14. package/dist/assets/PullRequestsSurface-Dec20SIg.js +2 -0
  15. package/dist/assets/SessionSwitcherContent-DEw4nz7K.js +1 -0
  16. package/dist/assets/SessionSwitcherDropdown-DmLhbRzE.js +2 -0
  17. package/dist/assets/SessionUnreadDot-CJFawQpo.js +1 -0
  18. package/dist/assets/SettingsView-CwSspvq-.js +6 -0
  19. package/dist/assets/SettingsWindow-DkPv9MaU.js +1 -0
  20. package/dist/assets/ToolOutputDialog-DDwbOpTO.js +8 -0
  21. package/dist/assets/ToolPartDiffPreview-DZRP7p-Q.js +1 -0
  22. package/dist/assets/{VirtualizedFileDiff-CJondRlh.js → VirtualizedFileDiff-CUWx7JVZ.js} +3 -3
  23. package/dist/assets/Virtualizer-wpC51ZBQ.js +1 -0
  24. package/dist/assets/collapsible-Ce85nuXX.js +1 -0
  25. package/dist/assets/computeVirtualFileMetrics-3PpRLd5B.js +3 -0
  26. package/dist/assets/{contextFileOpenGuard-CsZL8yie.js → contextFileOpenGuard-PoBklHMz.js} +1 -1
  27. package/dist/assets/gitStatusPredicates-BvzxqidP.js +1 -0
  28. package/dist/assets/githubLink-iQ51wqRa.js +10 -0
  29. package/dist/assets/index-CkMnC_GK.js +1 -0
  30. package/dist/assets/index-Dd2OcIUY.js +10 -0
  31. package/dist/assets/index-DvN8zlLT.css +1 -0
  32. package/dist/assets/main-FasHq7Ck.js +2 -0
  33. package/dist/assets/main-PSCt716b.js +136 -0
  34. package/dist/assets/markdownCore-BH56o6Wu.js +2 -0
  35. package/dist/assets/miniChat-BzfobBDq.js +2 -0
  36. package/dist/assets/mobile-DAzZE2EL.js +2 -0
  37. package/dist/assets/permissionStore-B9Hkrqny.js +1 -0
  38. package/dist/assets/pi-session-focus-preference-D2-1HWmY.js +10 -0
  39. package/dist/assets/renderDiffWithHighlighter-l8hZWWBO.js +1 -0
  40. package/dist/assets/renderElectronMiniChatApp-DGYSIihR.js +2 -0
  41. package/dist/assets/renderFileWithHighlighter-BvDoP7ob.js +1 -0
  42. package/dist/assets/renderMobileApp-CwgWG0lU.js +11 -0
  43. package/dist/assets/runtimeEndpointReset-CmI6dBKM.js +62 -0
  44. package/dist/assets/{runtimeSurface-BdndJV2m.js → runtimeSurface-B1GRkkKC.js} +1 -1
  45. package/dist/assets/shell-CjFT_Tl9.js +1 -0
  46. package/dist/assets/sprite-HGQGInUp.js +6510 -0
  47. package/dist/assets/useAppFontEffects--lKKtKVo.js +212 -0
  48. package/dist/assets/{useFilesViewSearch-DJ3psTKU.js → useFilesViewSearch-D1jsGQrN.js} +3 -3
  49. package/dist/assets/useGitHubRemoteSearch-zNgy2bSt.js +1 -0
  50. package/dist/assets/useSwitcherItems-OCRYcHeu.js +1 -0
  51. package/dist/assets/vendor-base-ui-DIkTOIJS.js +1 -0
  52. package/dist/assets/{vendor-beautiful-mermaid-D3YCkKz7.js → vendor-beautiful-mermaid-DApbjBp2.js} +1 -1
  53. package/dist/assets/vendor-boot-DyL2td56.js +69 -0
  54. package/dist/assets/vendor-codemirror-autocomplete-DsFn4GLp.js +1 -0
  55. package/dist/assets/vendor-codemirror-lang-angular-B_NMmBbS.js +1 -0
  56. package/dist/assets/vendor-codemirror-lang-cpp-GOE7Gjd0.js +1 -0
  57. package/dist/assets/vendor-codemirror-lang-css-Dwf2XpnZ.js +1 -0
  58. package/dist/assets/vendor-codemirror-lang-go-C2KHbcll.js +7 -0
  59. package/dist/assets/vendor-codemirror-lang-html-DcKqyeGk.js +1 -0
  60. package/dist/assets/vendor-codemirror-lang-java-6eGbyB2k.js +1 -0
  61. package/dist/assets/vendor-codemirror-lang-javascript-DpTUrvx8.js +13 -0
  62. package/dist/assets/vendor-codemirror-lang-jinja-xSUJjXhr.js +1 -0
  63. package/dist/assets/vendor-codemirror-lang-json-CLGxdOCz.js +1 -0
  64. package/dist/assets/vendor-codemirror-lang-less-6nXi1rS9.js +1 -0
  65. package/dist/assets/vendor-codemirror-lang-liquid-B9hmb9P8.js +1 -0
  66. package/dist/assets/vendor-codemirror-lang-markdown-DmFP9s6x.js +1 -0
  67. package/dist/assets/vendor-codemirror-lang-php-DC6To8iX.js +1 -0
  68. package/dist/assets/vendor-codemirror-lang-python-yuxIkjit.js +3 -0
  69. package/dist/assets/vendor-codemirror-lang-rust-di1Sjz-0.js +1 -0
  70. package/dist/assets/vendor-codemirror-lang-sass-BWpV9NPV.js +1 -0
  71. package/dist/assets/{vendor-codemirror-lang-sql-HpQWHJjv.js → vendor-codemirror-lang-sql-C_RazIaB.js} +2 -2
  72. package/dist/assets/vendor-codemirror-lang-vue-BYL0r7KR.js +1 -0
  73. package/dist/assets/vendor-codemirror-lang-wast-BiVarhcz.js +1 -0
  74. package/dist/assets/vendor-codemirror-lang-xml-Cn1lY1ts.js +1 -0
  75. package/dist/assets/vendor-codemirror-lang-yaml-BZ6mZw9L.js +1 -0
  76. package/dist/assets/vendor-codemirror-language-data-DglcKYWT.js +2 -0
  77. package/dist/assets/vendor-codemirror-search-DaE6R5gH.js +2 -0
  78. package/dist/assets/{vendor-elkjs-mzfkf0ML.js → vendor-elkjs-D27273Ms.js} +1 -1
  79. package/dist/assets/{vendor-heic2any-BHsbokcA.js → vendor-heic2any-pq-UTQQR.js} +1 -1
  80. package/dist/assets/vendor-lezer-cpp-Dt99h3WT.js +1 -0
  81. package/dist/assets/vendor-lezer-css-DNU_fzPI.js +1 -0
  82. package/dist/assets/vendor-lezer-go-BEFtcNyS.js +1 -0
  83. package/dist/assets/vendor-lezer-html-DDGRhRUz.js +1 -0
  84. package/dist/assets/vendor-lezer-java-DmfZtW09.js +1 -0
  85. package/dist/assets/vendor-lezer-javascript-oje4tdp_.js +1 -0
  86. package/dist/assets/vendor-lezer-json-BRXb_bDX.js +1 -0
  87. package/dist/assets/vendor-lezer-lr-BU2qmu_5.js +1 -0
  88. package/dist/assets/{vendor-lezer-markdown-C6g-d6P3.js → vendor-lezer-markdown-CicYv7V9.js} +4 -4
  89. package/dist/assets/vendor-lezer-php-COORrTpE.js +1 -0
  90. package/dist/assets/vendor-lezer-python-Cuvm9X9Y.js +1 -0
  91. package/dist/assets/vendor-lezer-rust-C_zOfHbX.js +1 -0
  92. package/dist/assets/vendor-lezer-sass-DWP4w7O1.js +1 -0
  93. package/dist/assets/vendor-lezer-xml-Br6nOYeG.js +1 -0
  94. package/dist/assets/vendor-lezer-yaml-CYQmm6Sb.js +1 -0
  95. package/dist/assets/{vendor-lru_map-Cy8fTs3_.js → vendor-lru_map-DOPmc7GU.js} +1 -1
  96. package/dist/assets/{vendor-qrcode-B0KNSajT.js → vendor-qrcode-Dv4uniC1.js} +1 -1
  97. package/dist/assets/vendor-react-DASdDPIk.js +1 -0
  98. package/dist/assets/{vendor-react-drawio-BYDptOsj.js → vendor-react-drawio-Duu5LgQA.js} +1 -1
  99. package/dist/assets/{vendor-replit-codemirror-vim-DaSwPsXt.js → vendor-replit-codemirror-vim-CZy3BUVv.js} +15 -15
  100. package/dist/assets/vendor-zustand-CUi8eEds.js +6 -0
  101. package/dist/assets/{web-components-CCKlju0Z.js → web-components-v9fuidaX.js} +4 -4
  102. package/dist/index.html +7 -9
  103. package/dist/mini-chat.html +6 -8
  104. package/dist/mobile.html +6 -8
  105. package/package.json +2 -2
  106. package/server/index.js +3 -1
  107. package/server/lib/fs/DOCUMENTATION.md +1 -1
  108. package/server/lib/fs/routes.js +1 -50
  109. package/server/lib/git/DOCUMENTATION.md +18 -11
  110. package/server/lib/git/index.js +8 -3
  111. package/server/lib/git/routes.js +0 -129
  112. package/server/lib/git/service.js +40 -152
  113. package/server/lib/git/service.test.js +42 -18
  114. package/server/lib/github/DOCUMENTATION.md +271 -0
  115. package/server/lib/github/cache.js +164 -0
  116. package/server/lib/github/checks.js +230 -0
  117. package/server/lib/github/client.js +305 -0
  118. package/server/lib/github/context.js +177 -0
  119. package/server/lib/github/contracts.test.js +235 -0
  120. package/server/lib/github/correctness.test.js +356 -0
  121. package/server/lib/github/credential.js +46 -0
  122. package/server/lib/github/errors.js +151 -0
  123. package/server/lib/github/gh-cli.js +336 -0
  124. package/server/lib/github/index.js +27 -0
  125. package/server/lib/github/issues.js +495 -0
  126. package/server/lib/github/pulls.js +699 -0
  127. package/server/lib/github/repo-scope.js +688 -0
  128. package/server/lib/github/routes.js +599 -0
  129. package/server/lib/github/security.test.js +275 -0
  130. package/server/lib/github/templates.js +153 -0
  131. package/server/lib/package-manager-detect-child.js +12 -0
  132. package/server/lib/package-manager.js +366 -92
  133. package/server/lib/package-manager.test.js +109 -0
  134. package/server/lib/pi/routes-extension-events.test.js +268 -4
  135. package/server/lib/pi/routes.js +109 -25
  136. package/server/lib/pi/routes.test.js +118 -0
  137. package/server/lib/pi/session-daemon/DOCUMENTATION.md +24 -9
  138. package/server/lib/pi/session-daemon/builtin-extensions.js +37 -0
  139. package/server/lib/pi/session-daemon/daemon-process.js +6 -0
  140. package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +222 -0
  141. package/server/lib/pi/session-daemon/extension-bridge.js +415 -42
  142. package/server/lib/pi/session-daemon/extension-name.js +87 -0
  143. package/server/lib/pi/session-daemon/extension-name.test.js +143 -0
  144. package/server/lib/pi/session-daemon/extension-theme.js +217 -0
  145. package/server/lib/pi/session-daemon/extension-theme.test.js +164 -0
  146. package/server/lib/pi/session-daemon/extension-tool-render.js +365 -0
  147. package/server/lib/pi/session-daemon/extension-tool-render.test.js +607 -0
  148. package/server/lib/pi/session-daemon/prompt-operations.test.js +3 -3
  149. package/server/lib/pi/session-daemon/prompt-preflight.test.js +12 -14
  150. package/server/lib/pi/session-daemon/sdk-upgrade.test.js +118 -2
  151. package/server/lib/pi/session-daemon/send-operation-dedup.test.js +1 -1
  152. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +323 -3
  153. package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +244 -0
  154. package/server/lib/pi/session-daemon/session-daemon-mcp.e2e.test.js +638 -0
  155. package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +437 -0
  156. package/server/lib/pi/session-daemon/session-daemon.js +265 -75
  157. package/server/lib/pi/session-daemon/session-daemon.test.js +271 -5
  158. package/server/lib/pi/session-daemon/session-idle-residency.test.js +1 -1
  159. package/server/lib/pi/session-daemon/session-replay.test.js +1 -1
  160. package/server/lib/pi/session-persistence-gap.test.js +2 -3
  161. package/server/lib/pi/ui-settings-store.js +2 -1
  162. package/server/lib/pi/ui-settings-store.test.js +27 -0
  163. package/server/lib/static-cache-control.js +18 -0
  164. package/server/lib/static-cache-control.test.js +25 -0
  165. package/server/lib/workspace/host.js +2 -0
  166. package/dist/assets/DiagramView-Bj1ZrdhI.js +0 -1
  167. package/dist/assets/FileSaveConflictDialog-2Z4V_gZU.js +0 -3
  168. package/dist/assets/FilesView-K18gBSws.js +0 -6
  169. package/dist/assets/GitView-Hm1KBPaD.js +0 -8
  170. package/dist/assets/JsonTreeView-fNsiZEIo.js +0 -1
  171. package/dist/assets/MarkdownRendererImpl-DV5Xkj8N.js +0 -12
  172. package/dist/assets/PatchDiff-DZaJG6jj.js +0 -1
  173. package/dist/assets/SessionSwitcherContent-RAsmsuYk.js +0 -1
  174. package/dist/assets/SessionSwitcherDropdown-DuLPlIF_.js +0 -2
  175. package/dist/assets/SessionUnreadDot-Dm6k5OCd.js +0 -1
  176. package/dist/assets/SettingsView-Chu4zbWo.js +0 -6
  177. package/dist/assets/SettingsWindow-CJzFmmfu.js +0 -1
  178. package/dist/assets/ToolOutputDialog-uYeXsAGc.js +0 -8
  179. package/dist/assets/ToolPartDiffPreview-DnAHVRs-.js +0 -1
  180. package/dist/assets/Virtualizer-BSHVMKgK.js +0 -1
  181. package/dist/assets/collapsible-BH1vXEAI.js +0 -1
  182. package/dist/assets/computeVirtualFileMetrics-DXkR5jdw.js +0 -3
  183. package/dist/assets/gitStatusPredicates-BW8heN1a.js +0 -134
  184. package/dist/assets/index-5fyXnZFi.css +0 -1
  185. package/dist/assets/index-BrgKwTb0.js +0 -1
  186. package/dist/assets/index-C-sV_9sb.js +0 -8
  187. package/dist/assets/isDiffPlainText-DZFr1Tta.js +0 -1
  188. package/dist/assets/isFilePlainText-KNpEMvb-.js +0 -1
  189. package/dist/assets/main-BPY2ug1A.js +0 -135
  190. package/dist/assets/main-BRIjzIRl.js +0 -2
  191. package/dist/assets/markdownCore-DYizLr1N.js +0 -3
  192. package/dist/assets/miniChat-Dva4MINl.js +0 -2
  193. package/dist/assets/mobile-6jNUNv_x.js +0 -2
  194. package/dist/assets/permissionStore-iKN1K2_x.js +0 -1
  195. package/dist/assets/renderElectronMiniChatApp-BIeBrZmO.js +0 -2
  196. package/dist/assets/renderMobileApp-BDCtZpeS.js +0 -11
  197. package/dist/assets/runtimeEndpointReset-DqdGOWp8.js +0 -53
  198. package/dist/assets/useAppFontEffects-BABx-DxZ.js +0 -6722
  199. package/dist/assets/usePushVisibilityBeacon-BciEu3HS.js +0 -10
  200. package/dist/assets/useSwitcherItems-C7_5TB_n.js +0 -1
  201. package/dist/assets/vendor-aria-hidden-DvXkyWUv.js +0 -1
  202. package/dist/assets/vendor-base-ui-DXSHfszQ.js +0 -1
  203. package/dist/assets/vendor-class-variance-authority-5VPnzWs2.js +0 -1
  204. package/dist/assets/vendor-cmdk-zXx6sGnS.js +0 -1
  205. package/dist/assets/vendor-codemirror-autocomplete-wd6iRebq.js +0 -1
  206. package/dist/assets/vendor-codemirror-commands-CNlncqrr.js +0 -1
  207. package/dist/assets/vendor-codemirror-lang-angular-DU_4KiiW.js +0 -1
  208. package/dist/assets/vendor-codemirror-lang-cpp-CmIT9Z5_.js +0 -1
  209. package/dist/assets/vendor-codemirror-lang-css-djiuoTi8.js +0 -1
  210. package/dist/assets/vendor-codemirror-lang-go-COZSwZYW.js +0 -7
  211. package/dist/assets/vendor-codemirror-lang-html-CKHqhW5R.js +0 -1
  212. package/dist/assets/vendor-codemirror-lang-java-CNMP5hyC.js +0 -1
  213. package/dist/assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js +0 -13
  214. package/dist/assets/vendor-codemirror-lang-jinja-DaKn_b1k.js +0 -1
  215. package/dist/assets/vendor-codemirror-lang-json-CZ07HmNC.js +0 -1
  216. package/dist/assets/vendor-codemirror-lang-less-wJdQiDBf.js +0 -1
  217. package/dist/assets/vendor-codemirror-lang-liquid-0z48Roi8.js +0 -1
  218. package/dist/assets/vendor-codemirror-lang-markdown-DtcZDGqe.js +0 -1
  219. package/dist/assets/vendor-codemirror-lang-php-W8plS-JQ.js +0 -1
  220. package/dist/assets/vendor-codemirror-lang-python-DzzokVau.js +0 -3
  221. package/dist/assets/vendor-codemirror-lang-rust-C4ulBVpf.js +0 -1
  222. package/dist/assets/vendor-codemirror-lang-sass-BkZJYEwS.js +0 -1
  223. package/dist/assets/vendor-codemirror-lang-vue-DiBPljCc.js +0 -1
  224. package/dist/assets/vendor-codemirror-lang-wast-DoABsogh.js +0 -1
  225. package/dist/assets/vendor-codemirror-lang-xml-BhLJhOCH.js +0 -1
  226. package/dist/assets/vendor-codemirror-lang-yaml-D95i1Y5R.js +0 -1
  227. package/dist/assets/vendor-codemirror-language-BByA_dGF.js +0 -3
  228. package/dist/assets/vendor-codemirror-language-data-BB5mQv-R.js +0 -2
  229. package/dist/assets/vendor-codemirror-search-BV44140v.js +0 -2
  230. package/dist/assets/vendor-codemirror-state-CNWM3Q8V.js +0 -5
  231. package/dist/assets/vendor-codemirror-view-Ct4T37Ue.js +0 -4
  232. package/dist/assets/vendor-crelt-C8TCjufn.js +0 -1
  233. package/dist/assets/vendor-detect-node-es-l0sNRNKZ.js +0 -1
  234. package/dist/assets/vendor-dnd-kit-accessibility-DZKKhs9S.js +0 -1
  235. package/dist/assets/vendor-dnd-kit-core-C9qcAm_1.js +0 -5
  236. package/dist/assets/vendor-dnd-kit-sortable-D8ozj8M-.js +0 -1
  237. package/dist/assets/vendor-dnd-kit-utilities-DTY1C6ST.js +0 -1
  238. package/dist/assets/vendor-floating-ui-core-CXmKXOXc.js +0 -1
  239. package/dist/assets/vendor-floating-ui-dom-WyXykhNi.js +0 -1
  240. package/dist/assets/vendor-floating-ui-react-dom-BZOGXAGe.js +0 -1
  241. package/dist/assets/vendor-floating-ui-utils-BzXdqYpP.js +0 -1
  242. package/dist/assets/vendor-framer-motion-CfplGuM0.js +0 -1
  243. package/dist/assets/vendor-get-nonce-C-Z93AgS.js +0 -1
  244. package/dist/assets/vendor-lezer-common-B3-cUCR_.js +0 -1
  245. package/dist/assets/vendor-lezer-cpp-BleAU9o-.js +0 -1
  246. package/dist/assets/vendor-lezer-css-C5xB6jxd.js +0 -1
  247. package/dist/assets/vendor-lezer-go-CXK1UKk8.js +0 -1
  248. package/dist/assets/vendor-lezer-highlight-CDMHUZ74.js +0 -1
  249. package/dist/assets/vendor-lezer-html-C0I1p52t.js +0 -1
  250. package/dist/assets/vendor-lezer-java-D_zzj-NV.js +0 -1
  251. package/dist/assets/vendor-lezer-javascript-D7Tj24ot.js +0 -1
  252. package/dist/assets/vendor-lezer-json-Iaex0UN-.js +0 -1
  253. package/dist/assets/vendor-lezer-lr-bhwg1HMg.js +0 -1
  254. package/dist/assets/vendor-lezer-php-_DHrbsZG.js +0 -1
  255. package/dist/assets/vendor-lezer-python-CvuFxeZl.js +0 -1
  256. package/dist/assets/vendor-lezer-rust-Lqgd5SAo.js +0 -1
  257. package/dist/assets/vendor-lezer-sass-Dnm2lY4t.js +0 -1
  258. package/dist/assets/vendor-lezer-xml-hUDuAyS5.js +0 -1
  259. package/dist/assets/vendor-lezer-yaml-BNIl6S_O.js +0 -1
  260. package/dist/assets/vendor-marijn-find-cluster-break-DXwl3gUT.js +0 -1
  261. package/dist/assets/vendor-motion-dom-DhJ-sYS5.js +0 -1
  262. package/dist/assets/vendor-motion-l0sNRNKZ.js +0 -1
  263. package/dist/assets/vendor-motion-utils-CKEGc_YG.js +0 -1
  264. package/dist/assets/vendor-radix-ui-primitive-Dc_FVRD7.js +0 -1
  265. package/dist/assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js +0 -1
  266. package/dist/assets/vendor-radix-ui-react-context-CFsX-AUC.js +0 -1
  267. package/dist/assets/vendor-radix-ui-react-dialog-D2yhEu2p.js +0 -5
  268. package/dist/assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js +0 -1
  269. package/dist/assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js +0 -1
  270. package/dist/assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js +0 -1
  271. package/dist/assets/vendor-radix-ui-react-id-D2kS9K1j.js +0 -1
  272. package/dist/assets/vendor-radix-ui-react-portal-YgCRIyi7.js +0 -1
  273. package/dist/assets/vendor-radix-ui-react-presence-D432pCMB.js +0 -1
  274. package/dist/assets/vendor-radix-ui-react-primitive-DkH8dMOR.js +0 -1
  275. package/dist/assets/vendor-radix-ui-react-slot-BIDFZX0-.js +0 -1
  276. package/dist/assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js +0 -1
  277. package/dist/assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js +0 -1
  278. package/dist/assets/vendor-radix-ui-react-use-effect-event-D94va83M.js +0 -1
  279. package/dist/assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js +0 -1
  280. package/dist/assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js +0 -1
  281. package/dist/assets/vendor-react-B5Z1Mdn3.js +0 -9
  282. package/dist/assets/vendor-react-remove-scroll-bar-CSAHp1YF.js +0 -38
  283. package/dist/assets/vendor-react-remove-scroll-vR1dy1aP.js +0 -4
  284. package/dist/assets/vendor-react-style-singleton-Ctw6HnYx.js +0 -1
  285. package/dist/assets/vendor-reselect-l0sNRNKZ.js +0 -1
  286. package/dist/assets/vendor-scheduler-7OC5HNn7.js +0 -1
  287. package/dist/assets/vendor-simplewebauthn-browser-VDA66rT_.js +0 -2
  288. package/dist/assets/vendor-sonner-BDtm25td.js +0 -1
  289. package/dist/assets/vendor-style-mod-NZ5MEPvj.js +0 -3
  290. package/dist/assets/vendor-tanstack-react-virtual-2skouoFw.js +0 -1
  291. package/dist/assets/vendor-tanstack-virtual-core-Dubg10g5.js +0 -1
  292. package/dist/assets/vendor-tslib-De9GV7Vy.js +0 -1
  293. package/dist/assets/vendor-use-callback-ref-CVVuCyLj.js +0 -1
  294. package/dist/assets/vendor-use-sidecar-Vv4V8Nd1.js +0 -1
  295. package/dist/assets/vendor-use-sync-external-store-D0AXkdQC.js +0 -1
  296. package/dist/assets/vendor-w3c-keyname-Vcq4gwWv.js +0 -1
  297. package/dist/assets/vendor-zustand-GVb4H8HE.js +0 -6
  298. package/server/lib/git/credentials.js +0 -41
  299. package/server/lib/git/identity-storage.js +0 -122
  300. /package/dist/assets/{vendor-katex-CNckGUMB.js → vendor-katex-DZG0Ov6p.js} +0 -0
  301. /package/dist/assets/{vendor-katex-Cp579UoJ.css → vendor-katex-css-Cp579UoJ.css} +0 -0
  302. /package/dist/assets/{vendor-xterm-xterm-CrXqRur4.js → vendor-xterm-xterm-B-qIQCd3.js} +0 -0
  303. /package/dist/assets/{vendor-xterm-xterm-DDGTF8rc.css → vendor-xterm-xterm-css-DDGTF8rc.css} +0 -0
@@ -0,0 +1,7 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dd2OcIUY.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-DvN8zlLT.css"])))=>i.map(i=>d[i]);
2
+ import{j as t}from"./vendor-boot-DyL2td56.js";import{R as u}from"./vendor-react-DASdDPIk.js";import{i as Pe,j as ot,p as lt,l as it,m as ct,r as ut,b as dt,c as mt,G as ht,h as Ne,u as ft,n as bt,o as gt}from"./useGitHubRemoteSearch-zNgy2bSt.js";import{a4 as xt,B as j,I as R,ak as pt,al as yt,am as vt,an as Ct,ao as jt,ap as wt,p as $e,f as kt,t as P,cH as St,o as ye,ai as Oe,a8 as Re,ab as Le,ad as Ee,cu as Nt,cv as Rt,af as xe,ag as Lt,n as Et}from"./useAppFontEffects--lKKtKVo.js";import{ae as It,af as Ie,ag as pe,ah as Ae,ai as ce,aj as At,ak as ue,U as Dt,_ as _e,a4 as Gt,a1 as Tt,al as Ht}from"./runtimeEndpointReset-CmI6dBKM.js";import{_ as Bt}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as Ft,d as Mt}from"./vendor-zustand-CUi8eEds.js";import{v as Ue,A as zt}from"./index-Dd2OcIUY.js";import{a as Ke,u as Pt,p as $t,r as Ot,t as De,x as _t,z as Ut,A as Kt,w as ie,y as Wt,B as oe,C as We,D as qt,R as Vt,E as Ge,G as Qt,H as Jt,I as Yt,J as Zt,K as Te}from"./GitHubDetailScaffold-q4YP8iyJ.js";import{I as He,a as Xt,b as es,i as qe,c as ts,d as ss,s as as,g as le,e as ns,f as rs,h as Be,j as Fe,C as os,k as ls,v as is}from"./githubLink-iQ51wqRa.js";import{a as cs,b as us}from"./GitHubListPrimitives-XkALat1v.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-B1GRkkKC.js";import"./SessionUnreadDot-CJFawQpo.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-dompurify-r8glNMJW.js";const ve={state:"open",involvement:"all",labels:"",search:"",sort:"updated"},ds=3e4,ms=100,hs=50,Ve=(e,s)=>ue([e,"issues-collection",s]),Qe=(e,s)=>ue([e,"issues-remote",s.state,s.involvement,s.labels.trim(),s.q.trim()]),Ce=(e,s)=>ue([e,"issue-detail",s]),je=(e,s)=>ue([e,"issue-comments",s]),fs=e=>({state:e,perPage:ms}),bs=(e,s)=>({state:e.state,filter:e.involvement,q:e.q.trim()?e.q.trim():void 0,labels:e.labels.trim()?e.labels.trim():void 0,perPage:hs,...s?{cursor:s}:{}}),gs={set:e=>{typeof e=="function"?C.setState(s=>{const n={filtersByScope:s.filtersByScope,selectionByDirectory:s.selectionByDirectory};return e(n)}):C.setState(e)},get:()=>{const e=C.getState();return{filtersByScope:e.filtersByScope,selectionByDirectory:e.selectionByDirectory}}},g=At({openCollection:"open",closedCollection:"closed",defaultFilters:ve,freshWindowMs:ds,serverKind:"issues",errorFallback:"Issue request failed",collectionKeyFor:Ve,remoteKeyFor:Qe,detailKeyFor:Ce,commentsKeyFor:je,buildCollectionQuery:e=>({...fs(e)}),buildRemoteQuery:(e,s)=>({...bs(e,s)}),fetchList:async(e,s,n,r)=>{const l=await e.issuesList(s,n,r);return{items:l.items,nextCursor:l.nextCursor,fetchedAt:l.fetchedAt}},fetchDetail:async(e,s,n,r)=>e.issueGet(s,n,r),fetchComments:async(e,s,n,r,l)=>{const a=await e.issueComments(s,n,r,l);return{comments:a.comments,nextCursor:a.nextCursor,fetchedAt:a.fetchedAt}}},gs),C=Ft()(Mt((e,s)=>({...g.initialState,actionErrorByDetail:{},actingActions:{},setFilters:g.setFilters,resetFilters:g.resetFilters,selectIssue:g.select,ensureCollection:g.ensureCollection,ensureCollectionsFresh:g.ensureCollectionsFresh,prefetchClosedCollection:g.prefetchClosedCollection,loadMoreCollection:g.loadMoreCollection,refreshCollections:g.refreshCollections,searchRemote:g.searchRemote,loadMoreRemote:g.loadMoreRemote,dropRemoteForRepo:g.dropRemoteForRepo,refreshAllForScope:g.refreshAllForScope,ensureDetail:g.ensureDetail,refreshDetail:g.refreshDetail,ensureComments:g.ensureComments,loadMoreComments:g.loadMoreComments,refreshComments:g.refreshComments,updateIssue:async(n,r,l,a,d)=>{const b=Ae(r,l),o=Ce(r,l);if(s().actingActions[b])return{ok:!1,error:{kind:"failed",message:"An update is already in progress"}};e(x=>({actingActions:{...x.actingActions,[b]:!0},actionErrorByDetail:{...x.actionErrorByDetail,[b]:null}}));const c=g.resources.details.getEntry(o)?.data?.detail??null,y=c?.issue??null,w=y?{...y,title:a.title??y.title,body:a.body??y.body,state:a.state??y.state,stateReason:a.state!==void 0?a.stateReason??null:y.stateReason,labels:a.labels!==void 0?a.labels.map(x=>({name:x})):y.labels,assignees:a.assignees!==void 0?a.assignees.map(x=>({login:x})):y.assignees}:null;w&&c&&await g.resources.details.refresh(o,async()=>({detail:{...c,issue:w}})).catch(()=>null);try{return await d.issueUpdate(n,r,l,a),await pe(d,{directory:n,repo:r,kind:"issues",number:l}),s().dropRemoteForRepo(r),await s().refreshCollections(n,r,"both",d).catch(()=>null),await s().refreshDetail(n,r,l,d).catch(()=>null),e(x=>({actingActions:{...x.actingActions,[b]:!1}})),{ok:!0}}catch(x){const S=g.toStoreError(x);return c&&await g.resources.details.refresh(o,async()=>({detail:c})).catch(()=>null),e(f=>({actingActions:{...f.actingActions,[b]:!1},actionErrorByDetail:{...f.actionErrorByDetail,[b]:S}})),{ok:!1,error:S}}},addComment:async(n,r,l,a,d)=>{const b=Ae(r,l),o=je(r,l),c=a.trim(),y={id:-Date.now(),url:"",body:c,author:null,createdAt:new Date().toISOString(),updatedAt:null},w=g.resources.comments.getEntry(o)?.data??null;if(w){const x={comments:[...w.comments,y],nextCursor:w.nextCursor,fetchedAt:w.fetchedAt};await g.resources.comments.refresh(o,async()=>x).catch(()=>null)}try{return await d.issueComment(n,r,l,c),await pe(d,{directory:n,repo:r,kind:"issues",number:l}),await s().refreshComments(n,r,l,d).catch(()=>null),await s().refreshDetail(n,r,l,d).catch(()=>null),{ok:!0}}catch(x){const S=g.toStoreError(x);return w?await g.resources.comments.refresh(o,async()=>w).catch(()=>null):g.resources.comments.remove(o),e(f=>({actionErrorByDetail:{...f.actionErrorByDetail,[b]:S}})),{ok:!1,error:S}}},createIssue:async(n,r)=>{try{const l=await r.issueCreate(n.directory,n.repo,{title:n.title,body:n.body,labels:n.labels,assignees:n.assignees});return await pe(r,{directory:n.directory,repo:n.repo,kind:"issues"}),s().dropRemoteForRepo(n.repo),await s().refreshCollections(n.directory,n.repo,"both",r).catch(()=>null),{ok:!0,number:l.issue.number}}catch(l){return{ok:!1,error:g.toStoreError(l)}}},notifyAgentTurnComplete:n=>{const r=Ue((n||"").trim());if(!r)return;const l=s().selectionByDirectory[r];!l?.repo||typeof l.number!="number"||(g.markCollectionsStale(l.repo),Bt(async()=>{const{getRegisteredRuntimeAPIs:a}=await import("./index-Dd2OcIUY.js").then(d=>d.cx);return{getRegisteredRuntimeAPIs:a}},__vite__mapDeps([0,1,2,3,4,5,6])).then(({getRegisteredRuntimeAPIs:a})=>{const d=a()?.github??null;if(d)return s().refreshDetail(r,l.repo,l.number,d)}).catch(()=>{}))},resetForRuntimeSwitch:()=>{g.resetCore(),e({actionErrorByDetail:{},actingActions:{}})}}),{name:"github-issues-store"}));typeof window<"u"&&zt(()=>{C.getState().resetForRuntimeSwitch()});const xs=e=>g.getLocalIndex(e),ps=(e,s)=>g.getLocalIndex(e).find(n=>n.number===s)??null,Me=(e,s)=>ce(g.resources.collections,e?Ve(e,s):null),ys=(e,s)=>ce(g.resources.remote,e?Qe(e,s):null),vs=(e,s)=>ce(g.resources.details,e!=null&&s!=null?Ce(e,s):null),Cs=(e,s)=>ce(g.resources.comments,e!=null&&s!=null?je(e,s):null),js=(e,s)=>C(n=>!e||!s?ve:n.filtersByScope[It(e,s)]??ve),ws=e=>C(s=>e?s.selectionByDirectory[Ue(e)]??Ie:Ie),ks=e=>typeof e!="number"||e===0?null:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 typography-micro tabular-nums text-muted-foreground",title:`${e} comments`,"aria-label":`${e} comments`,children:[t.jsx(R,{name:"chat-1",className:"size-3.5"}),e]}),Ss=({items:e,hasMore:s,isLoadingMore:n,isLoading:r,isRefreshing:l,stale:a,error:d,filters:b,countComplete:o=!0,incompleteNotice:c=null,remote:y=null,numberJump:w=null,onFiltersChange:x,onClearFilters:S,onLoadMore:f,onRetry:p,onOpen:N,onNewIssue:k,headerActionsSlot:T=null,headerActionsPresentation:H="drawer"})=>{const z=b.state==="open"&&b.involvement==="all"&&!b.search.trim()&&!b.labels.trim(),{isMobile:D,isTablet:I}=xt(),B=D||I,G=T!=null,A=H??"drawer",$=G?A==="desktop"?t.jsxs(j,{type:"button",variant:"ghost",size:"sm",onClick:k,"aria-label":"New issue",title:"New issue",children:[t.jsx(R,{name:"add",className:"size-4"}),"New issue"]}):t.jsxs(j,{type:"button",variant:"ghost",size:"default",onClick:k,"aria-label":"New issue",title:"New issue",children:[t.jsx(R,{name:"add",className:"size-4"}),"New issue"]}):t.jsxs(j,{type:"button",variant:"ghost",size:B?"sm":"xs",onClick:k,"aria-label":"New issue",title:"New issue",children:[t.jsx(R,{name:"add",className:"size-3.5"}),"New issue"]}),O=u.useCallback(h=>t.jsx("li",{role:"listitem",children:t.jsx(Pe,{glyph:t.jsx(Ke,{kind:"issue",state:h.state}),number:`#${h.number}`,title:h.title,signals:ks(h.comments),meta:t.jsxs(t.Fragment,{children:[t.jsx(ot,{login:h.author?.login,avatarUrl:h.author?.avatarUrl}),t.jsx(lt,{labels:h.labels??[]})]}),updatedAt:h.updatedAt,onOpen:()=>N(h.number),ariaLabel:`Open issue #${h.number} ${h.title}`})},h.number),[N]);return t.jsx(it,{items:e,renderRow:O,hasMore:s,isLoadingMore:n,isLoading:r,isRefreshing:l,stale:a,error:d,searchValue:b.search,onSearchChange:h=>x({search:h}),searchPlaceholder:"Search issues, or label:bug",searchAriaLabel:"Search issues",toolbarControls:t.jsx(ct,{stateValue:b.state,stateOptions:He.map(h=>({id:h.id,label:h.label})),onStateChange:h=>x({state:h}),involvementValue:b.involvement,involvementOptions:es.map(h=>({id:h.id,label:h.label})),onInvolvementChange:h=>x({involvement:h}),labelsValue:b.labels,onLabelsChange:h=>x({labels:h}),sortValue:b.sort,sortOptions:Xt.map(h=>({id:h.id,label:h.label})),onSortChange:h=>x({sort:h}),sortAriaLabel:"Sort issues"}),primaryAction:$,headerActionsSlot:T,headerActionsPresentation:A,isDefaultFilters:z,stateLabel:He.find(h=>h.id===b.state)?.label??b.state,kindSingular:"issue",kindPlural:"issues",noItemsTitle:b.state==="open"?"No open issues":"No issues yet",noItemsBody:"Issues for this repository appear here.",noItemsIcon:"inbox-archive",noItemsAction:t.jsxs(j,{type:"button",variant:"outline",size:"sm",onClick:k,children:[t.jsx(R,{name:"add",className:"size-3.5"}),"New issue"]}),listAriaLabel:"Issues",skeletonLabel:"Loading issues",updatedAtOf:h=>h.updatedAt,countComplete:o,incompleteNotice:c,remote:y,numberJump:w,numberJumpKind:"issue",onClearFilters:S,onLoadMore:f,onRetry:p,onOpen:N})},Je=(e,s,n)=>{const[r,l]=u.useState([]),[a,d]=u.useState([]),[b,o]=u.useState(!1);return u.useEffect(()=>{if(!n)return;let c=!1;return o(!0),n.repoMeta(e,s).then(y=>{c||(l(y.labels??[]),d(y.assignees??[]))}).catch(()=>{c||(l([]),d([]))}).finally(()=>{c||o(!1)}),()=>{c=!0}},[n,e,s]),{labels:r,assignees:a,loading:b}},Ye=(e,s)=>e.includes(s)?e.filter(n=>n!==s):[...e,s],Ze=({candidates:e,loading:s,selected:n,onChange:r})=>s?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading labels…"}):e.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"No labels in this repository."}):t.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(l=>{const a=n.includes(l.name);return t.jsx(j,{type:"button",variant:"chip",size:"xs","aria-pressed":a,onClick:()=>r(Ye(n,l.name)),children:l.name},l.name)})}),Xe=({candidates:e,loading:s,selected:n,onChange:r})=>s?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading assignees…"}):e.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"No assignable users found."}):t.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(l=>{const a=l.login,d=a?n.includes(a):!1;return t.jsx(j,{type:"button",variant:"chip",size:"xs","aria-pressed":d,onClick:()=>{a&&r(Ye(n,a))},children:a},a)})}),Ns=({open:e,onOpenChange:s,issueNumber:n,issueTitle:r,busy:l,onChoose:a})=>{const[d,b]=u.useState("worktree"),o=qe(n,r);return t.jsx(pt,{open:e,onOpenChange:s,children:t.jsxs(yt,{className:"max-w-md w-[calc(100vw-2rem)]",children:[t.jsxs(vt,{children:[t.jsxs(Ct,{children:["Start session from issue #",n]}),t.jsx(jt,{children:"Choose where the new session works. The composer is pre-filled — nothing is sent automatically."})]}),t.jsxs("div",{className:"flex flex-col gap-1",role:"radiogroup","aria-label":"Session location",children:[t.jsxs("button",{type:"button",role:"radio","aria-checked":d==="current",onClick:()=>b("current"),className:"flex items-start gap-2 rounded-md border border-border px-3 py-2 text-left hover:bg-interactive-hover",children:[t.jsx(R,{name:d==="current"?"record-circle":"checkbox-blank-circle-fill",className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block typography-ui-label text-foreground",children:"Current checkout"}),t.jsx("span",{className:"block typography-micro text-muted-foreground",children:"Work directly where you are now."})]})]}),t.jsxs("button",{type:"button",role:"radio","aria-checked":d==="worktree",onClick:()=>b("worktree"),className:"flex items-start gap-2 rounded-md border border-border px-3 py-2 text-left hover:bg-interactive-hover",children:[t.jsx(R,{name:d==="worktree"?"record-circle":"checkbox-blank-circle-fill",className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block typography-ui-label text-foreground",children:"New worktree"}),t.jsxs("span",{className:"block truncate font-mono typography-micro text-muted-foreground",title:o,children:["Branch ",o]})]})]})]}),t.jsxs(wt,{children:[t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:()=>s(!1),disabled:l,children:"Cancel"}),t.jsx(j,{type:"button",variant:"default",size:"sm",onClick:()=>a(d),disabled:l,"aria-label":d==="worktree"?"Create worktree and open session draft":"Open session draft in current checkout",children:l?"Working…":d==="worktree"?"Create worktree":"Open draft"})]})]})})},ze=e=>{const s=as(e.title);return e.kind==="pr"?`pr-${e.number}-${s}`:qe(e.number,e.title)},Rs=async(e,s)=>{const{github:n,git:r,openDraft:l,refreshWorktrees:a}=s;if(!l)return{ok:!1,error:"Sessions are not available in this runtime"};let d;try{d=(await n.agentContext(e.directory,e.repo,e.kind==="pr"?"pr":"issue",e.number)).text}catch(p){return{ok:!1,error:p instanceof Error?p.message:"Failed to load issue context"}}const o=`${e.kind==="pr"?"PR":"Issue"} #${e.number}: ${e.title.trim()||"(untitled)"}`,c=e.kind==="pr"?`Work on this GitHub pull request. Read the quoted context below, then propose a plan and wait for confirmation before changing code.
3
+
4
+ PR #${e.number}: ${e.title}
5
+ ${e.url}
6
+
7
+ ${d}`:ts({repo:e.repo,number:e.number,title:e.title,url:e.url,contextText:d}),y=[{text:ss({kind:e.kind,number:e.number,title:e.title,url:e.url}),synthetic:!0},{text:d,synthetic:!0}];if(e.target==="current")return l({directoryOverride:e.directory,title:o,initialPrompt:c,syntheticParts:y}),{ok:!0,directory:e.directory};if(!r?.getGitBranches||!r?.createGitWorktree)return{ok:!1,error:"Worktree creation is not available in this runtime"};let w,x=!1;try{const p=await r.getGitBranches(e.directory);if(w=p.current?.trim()??"",!w)throw new Error("no current branch");x=Array.isArray(p.all)&&p.all.includes(ze(e))}catch{return{ok:!1,error:"Could not determine the current branch to start the worktree from"}}const S=ze(e);let f;try{if(x){let p=null;if(r.listGitWorktrees)try{const N=await r.listGitWorktrees(e.directory);p=Array.isArray(N)?N.find(k=>!k?.prunable&&k?.branch===S)?.path??null:null}catch{p=null}if(p)f=p;else if(f=(await r.createGitWorktree(e.directory,{mode:"existing",existingBranch:S})).path,!f)throw new Error("worktree path missing")}else if(f=(await r.createGitWorktree(e.directory,{mode:"new",startRef:w,branchName:S})).path,!f)throw new Error("worktree path missing")}catch(p){return{ok:!1,error:p instanceof Error?p.message:"Worktree creation failed"}}return await a?.(e.directory),l({directoryOverride:f,title:o,initialPrompt:c,syntheticParts:y}),{ok:!0,directory:f}},Ls=()=>{const e=$e(),s=kt(a=>a.openNewSessionDraft),[n,r]=u.useState(null);return{start:u.useCallback(async a=>{const d=e.github;if(!d)return P.error("GitHub is not available in this runtime"),!1;const b=`${a.repo}#${a.number}:${a.target}`;r(b);try{const o=await Rs(a,{github:d,git:e.git??null,refreshWorktrees:c=>ut(c,e.git),openDraft:c=>s(c)});return o.ok?(P.success(a.target==="worktree"?"Worktree ready — session draft opened":"Session draft opened"),!0):(P.error(o.error),!1)}finally{r(null)}},[e.github,e.git,s]),startingKey:n}},Es=({issue:e})=>t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(We,{login:e.author?.login,avatarUrl:e.author?.avatarUrl,size:"xs"}),e.author?.login??"ghost"]}),e.createdAt?` · opened ${Te(e.createdAt)}`:"",e.updatedAt&&e.updatedAt!==e.createdAt?` · updated ${Te(e.updatedAt)}`:""]}),Is=({number:e,closed:s,closeReason:n,onCloseReasonChange:r,closeAllowed:l,closeReasonText:a,reopenAllowed:d,reopenReasonText:b,acting:o,onStateAction:c,askSending:y,onAskAgent:w,onEditTitle:x,editAllowed:S,editReasonText:f,onCopyLink:p,url:N})=>t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pt-1 pb-2","aria-label":"Issue actions",children:[s?t.jsx(Ne,{copy:Fe("reopen",e),busy:o,variant:"outline",disabled:!d,disabledReason:b??"Reopen issue",label:"Reopen issue",icon:t.jsx(R,{name:"history",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>{c("reopen")}}):t.jsxs("span",{role:"group","aria-label":"Close issue",className:"inline-flex shrink-0 items-center gap-1",children:[t.jsx(Ne,{copy:Fe(n==="not_planned"?"close-not-planned":"close-completed",e),busy:o,destructive:!0,variant:"outline",disabled:!l,disabledReason:a??"Close issue",label:"Close issue",icon:t.jsx(R,{name:"close",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>{c(n==="not_planned"?"close-not-planned":"close-completed")}}),t.jsxs(Re,{modal:!1,children:[t.jsx(Le,{asChild:!0,children:t.jsx(j,{type:"button",variant:"outline",size:"xs",className:"shrink-0 px-1.5",title:"Close options","aria-label":"Close options",disabled:!l||o,children:t.jsx(R,{name:"arrow-down-s",className:"size-3.5"})})}),t.jsx(Ee,{align:"start",className:"w-60",children:t.jsx(Nt,{value:n,onValueChange:k=>r(k),children:os.map(k=>t.jsx(Rt,{value:k.id,children:k.id==="completed"?"Close as completed":"Close as not planned"},k.id))})})]})]}),t.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:w,disabled:y,title:"Send issue context to the agent composer","aria-label":"Ask agent about this issue",children:[t.jsx(R,{name:"send-plane-2",className:"size-3.5","aria-hidden":"true"}),y?"Asking…":"Ask agent"]}),t.jsxs(j,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{ye(N)},title:"Open on GitHub","aria-label":"Open on GitHub",children:[t.jsx(R,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Open on GitHub"]}),t.jsxs(Re,{modal:!1,children:[t.jsx(Le,{asChild:!0,children:t.jsx(j,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 px-1.5","aria-label":"More issue actions",title:"More issue actions",children:t.jsx(R,{name:"more-2",className:"size-4"})})}),t.jsxs(Ee,{align:"end",className:"w-60",children:[t.jsxs(xe,{onClick:x,disabled:!S,title:f??"Edit title",children:[t.jsx(R,{name:"pencil",className:"size-3.5"}),"Edit title"]}),t.jsx(Lt,{}),t.jsxs(xe,{onClick:()=>{ye(N)},children:[t.jsx(R,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),t.jsxs(xe,{onClick:p,children:[t.jsx(R,{name:"file-copy",className:"size-3.5"}),"Copy link"]})]})]})]}),As=e=>{const{directory:s,repo:n,number:r,github:l,issue:a}=e,d=C(i=>i.updateIssue),b=C(i=>i.addComment),o=C(i=>i.actionErrorByDetail[`${n}#${r}`]??null),c=C(i=>i.actingActions[`${n}#${r}`]??!1),{start:y,startingKey:w}=Ls(),x=Pt(s,n),[S,f]=u.useState("completed"),[p,N]=u.useState(!1),[k,T]=u.useState(""),[H,z]=u.useState(!1),[D,I]=u.useState(""),[B,G]=u.useState(!1),[A,$]=u.useState([]),[O,h]=u.useState([]),{draft:v,onDraftChange:L,flushDraft:_}=dt(n,r),{busy:W,error:de,submit:X}=mt({postComment:i=>b(s,n,r,i,l),runFollowUp:i=>d(s,n,r,Be(i==="reopen"?"reopen":S==="not_planned"?"close-not-planned":"close-completed"),l),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{L(""),ft.getState().clearCommentDraft(n,r)}}),[Q,me]=u.useState("newest"),[he,J]=u.useState(!1),[Y,ee]=u.useState(!1),U=u.useMemo(()=>({capabilities:e.capabilities??null,isAuthor:$t(a?.author?.login,e.viewerLogin),permissionFallback:e.viewerPermission?.fallback===!0}),[e.capabilities,e.viewerLogin,e.viewerPermission?.fallback,a?.author?.login]),F=le(a?.state==="closed"?"reopen":"close",a,U),M=le("edit",a,U),te=le("labels",a,U),se=le("comment",a,U),ae=St(s),Z=u.useMemo(()=>{const i=new Set;for(const E of ae.scope?.repositories??[])E.host&&E.owner&&E.repo&&i.add(`${E.host}/${E.owner}/${E.repo}`.toLowerCase());return i.add(n.toLowerCase()),i},[ae.scope,n]),m=u.useCallback(i=>{Z.has(i.repoRef.toLowerCase())?Dt(s,i.repoRef,i.number):ye(i.url)},[s,Z]),{labels:q,assignees:et,loading:we}=Je(s,n,l),ne=i=>{a&&(i==="title"?(T(a.title),N(!0)):i==="body"?(I(a.body??""),z(!0)):($((a.labels??[]).map(E=>E.name)),h((a.assignees??[]).map(E=>E.login).filter(Boolean)),G(!0)))},fe=u.useCallback(async i=>{const E=await d(s,n,r,i,l);return E.ok?(N(!1),z(!1),G(!1),!0):(P.error(E.error?.kind==="failed"?E.error.message:"Update failed"),!1)},[d,s,n,r,l]),tt=u.useCallback(async i=>{const E=Be(i),ge=await d(s,n,r,E,l);return ge.ok?!0:(P.error(ge.error?.kind==="failed"?ge.error.message:"State change failed"),!1)},[d,s,n,r,l]),st=Ot(a?.url),at=u.useCallback(async()=>{if(!(!a||Y)){ee(!0);try{const i=await l.agentContext(s,n,"issue",r);ns({kind:"issue",number:r,title:a.title,url:a.url,contextText:i.text},rs()),P.success("Added to composer")}catch(i){P.error(i instanceof Error?i.message:"Failed to fetch GitHub context")}finally{ee(!1)}}},[a,Y,l,s,n,r]),K=u.useMemo(()=>{const i=[...e.comments];return Q==="newest"&&i.reverse(),i},[e.comments,Q]),nt=u.useMemo(()=>K.filter(i=>!De(i.author?.login)),[K]),rt=u.useMemo(()=>K.filter(i=>De(i.author?.login)),[K]),ke=a?.state==="closed",Se=w!==null,V=a??(e.seed&&e.seed.number===r?e.seed:null),be=t.jsxs(t.Fragment,{children:[t.jsx(_t,{onBack:e.onBack,backLabel:"Back to issues",repoName:x,number:r,url:V?.url,numberTintClass:Kt("issue",V?.state??"open",!1,a?.stateReason),statePill:V?t.jsx(Ut,{kind:"issue",state:V.state,stateReason:a?.stateReason}):void 0,openLabel:`Open issue #${r} on GitHub`,title:V?.title??null,onEditTitle:a?()=>ne("title"):void 0,editTitleLabel:"Edit issue title",editTitleDisabledReason:M.allowed?null:M.reason,meta:V?t.jsx(Es,{issue:V}):void 0,primary:a?t.jsxs(j,{type:"button",variant:"default",size:"xs",onClick:()=>J(!0),disabled:Se,"aria-label":"Start session from issue",children:[t.jsx(R,{name:"add-circle",className:"size-3.5"}),"Start session"]}):void 0}),a?t.jsx(Is,{number:r,closed:ke,closeReason:S,onCloseReasonChange:f,closeAllowed:a.state!=="closed"?F.allowed:!1,closeReasonText:a.state!=="closed"?F.reason:"Already closed",reopenAllowed:a.state==="closed"?F.allowed:!1,reopenReasonText:a.state==="closed"?F.reason:"Already open",acting:c,onStateAction:i=>tt(i),askSending:Y,onAskAgent:()=>{at()},onEditTitle:()=>ne("title"),editAllowed:M.allowed,editReasonText:M.reason,onCopyLink:st,url:a.url}):null]});if(!a&&e.detailError)return t.jsx(ie,{header:be,tabs:[],activeTab:"",onTabChange:()=>{},children:t.jsx(cs,{icon:"error-warning",title:"Could not load this issue",action:t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:e.onRetryDetail,disabled:e.detailLoading,children:"Retry"})})});if(!a)return t.jsx(ie,{header:be,tabs:[],activeTab:"",onTabChange:()=>{},children:t.jsx(Wt,{label:"Loading issue"})});const re=ke?"reopen":"close";return t.jsxs(ie,{header:be,tabs:[],activeTab:"",onTabChange:()=>{},children:[t.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[e.detailStale?t.jsxs("p",{className:"typography-micro text-muted-foreground",role:"note",children:["Showing saved issue — last refresh failed."," ",t.jsx("button",{type:"button",className:"underline",onClick:e.onRetryDetail,children:"Retry"})]}):null,o?t.jsxs("p",{className:"flex items-start gap-2 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-micro text-foreground",role:"alert",children:[t.jsx(R,{name:"error-warning",className:"size-4 shrink-0 text-[var(--status-error)]","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0",children:o.kind==="failed"?o.message:"Action failed"})]}):null,U.permissionFallback?t.jsx("p",{className:"typography-micro text-muted-foreground",role:"note",children:"Permissions could not be loaded — actions stay enabled and any failure will be shown after you act."}):null,p?t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 py-1",children:[t.jsx(Oe,{value:k,onChange:i=>T(i.target.value),"aria-label":"Issue title",className:"h-7"}),t.jsx(j,{type:"button",variant:"default",size:"xs",onClick:()=>{fe({title:k})},disabled:c||!k.trim(),children:"Save"}),t.jsx(j,{type:"button",variant:"ghost",size:"xs",onClick:()=>N(!1),disabled:c,children:"Cancel"})]}):null,t.jsxs("div",{className:"flex flex-col gap-1.5 py-1",children:[t.jsx(oe,{icon:"user",label:"Assignees",children:t.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:(a.assignees??[]).length===0?t.jsx("span",{className:"typography-micro text-muted-foreground",children:"Unassigned"}):(a.assignees??[]).map(i=>t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",children:[t.jsx(We,{login:i.login,avatarUrl:i.avatarUrl,size:"xs"}),t.jsx("span",{className:"truncate",children:i.login})]},i.login))})}),t.jsx(oe,{icon:"list-unordered",label:"Labels",children:t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[(a.labels??[]).length===0?t.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):(a.labels??[]).map(i=>t.jsx(qt,{name:i.name,color:i.color},i.name)),t.jsx(j,{type:"button",variant:"ghost",size:"xs",onClick:()=>ne("meta"),"aria-label":"Edit labels and assignees",title:te.reason??"Edit labels and assignees",disabled:!te.allowed,children:"Edit"})]})}),a.milestone?t.jsx(oe,{icon:"time",label:"Milestone",children:t.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:a.milestone.title})}):null,t.jsx(oe,{icon:"git-pull-request",label:"Linked PRs",children:t.jsx("span",{className:"min-w-0 flex-1",children:e.linkedPullRequestsError?t.jsxs("span",{className:"flex items-center gap-2 typography-micro text-[var(--status-error)]",role:"alert",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Linked pull requests failed to load"}),t.jsx(j,{type:"button",variant:"outline",size:"xs",onClick:e.onRetryDetail,children:"Retry"})]}):(e.linkedPullRequests??[]).length===0?t.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):t.jsx("ul",{className:"flex min-w-0 flex-col",children:(e.linkedPullRequests??[]).map(i=>{const E=Z.has(i.repoRef.toLowerCase());return t.jsx("li",{children:t.jsx(Pe,{glyph:t.jsx(Ke,{kind:"pr",state:i.state,draft:i.draft}),number:`#${i.number}`,title:i.title||"(no title)",meta:t.jsxs("span",{className:"truncate",children:[Vt(i.repoRef),E?"":" · GitHub"]}),onOpen:()=>m(i),ariaLabel:`Open linked pull request #${i.number}: ${i.title}`})},`${i.repoRef}#${i.number}`)})})})}),B?t.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[t.jsx("p",{className:"typography-micro font-medium text-muted-foreground",children:"Labels"}),t.jsx(Ze,{candidates:q,loading:we,selected:A,onChange:$}),t.jsx("p",{className:"typography-micro font-medium text-muted-foreground",children:"Assignees"}),t.jsx(Xe,{candidates:et,loading:we,selected:O,onChange:h}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(j,{type:"button",size:"sm",onClick:()=>{fe({labels:A,assignees:O})},disabled:c,children:"Save"}),t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:()=>G(!1),disabled:c,children:"Cancel"})]})]}):null]}),t.jsx(Ge,{id:`issue-${r}-description`,title:"Description",action:H?void 0:t.jsx(j,{type:"button",variant:"ghost",size:"xs",onClick:()=>ne("body"),"aria-label":"Edit issue body",title:M.reason??"Edit issue body",disabled:!M.allowed,children:"Edit"}),children:H?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(_e,{value:D,onChange:i=>I(i.target.value),"aria-label":"Issue body",rows:6}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(j,{type:"button",size:"sm",onClick:()=>{fe({body:D})},disabled:c,children:"Save"}),t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:()=>z(!1),disabled:c,children:"Cancel"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx(Qt,{markdown:a.body??"",html:a.bodyHtml??null,fallbackUrl:a.url}),a.body?.trim()?null:t.jsx("p",{className:"typography-micro text-muted-foreground",children:"No description."})]})}),t.jsx(Ge,{id:`issue-${r}-comments`,title:`Comments${K.length?` (${K.length})`:""}`,action:t.jsx(Zt,{order:Q,onToggle:()=>me(i=>i==="newest"?"oldest":"newest")}),children:t.jsxs("div",{className:"flex flex-col gap-2",children:[K.length===0&&!e.commentsLoading?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):nt.map(i=>t.jsx(Jt,{comment:i},i.id)),t.jsx(Yt,{comments:rt}),e.commentsLoading&&K.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,t.jsx(us,{hasMore:e.commentsHasMore,isLoading:e.commentsLoading,onLoadMore:e.onLoadMoreComments,label:"Load older comments"}),se.allowed?t.jsx(ht,{draft:v,onDraftChange:L,onDraftBlur:_,ariaLabel:`Leave a comment on issue #${r}`,busy:W,error:de,disabledReason:se.reason,followUp:{id:re,label:re==="close"?"Close with comment":"Reopen with comment",busyLabel:re==="close"?"Closing…":"Reopening…",onRun:()=>{X(re,v)},allowed:F.allowed,reason:F.reason},onSubmitComment:()=>{X("comment",v)}}):null]})})]}),a?t.jsx(Ns,{open:he,onOpenChange:J,issueNumber:r,issueTitle:a.title,busy:Se,onChoose:i=>{J(!1),y({directory:s,repo:n,number:r,kind:"issue",title:a.title,url:a.url,target:i})}}):null]})},Ds=({directory:e,repo:s,github:n,onCreated:r,onCancel:l})=>{const a=C(v=>v.createIssue),[d,b]=u.useState(""),[o,c]=u.useState(""),[y,w]=u.useState([]),[x,S]=u.useState([]),[f,p]=u.useState(""),[N,k]=u.useState([]),[T,H]=u.useState(null),{labels:z,assignees:D,loading:I}=Je(e,s,n),[B,G]=u.useState(!1),[A,$]=u.useState({});u.useEffect(()=>{let v=!1;return n.issueTemplates(e,s).then(L=>{v||(k(L.templates),H(L.templates.length===0?"No markdown templates in this repository. YAML issue forms are not supported.":null))}).catch(()=>{v||H("Issue templates are unavailable.")}),()=>{v=!0}},[n,e,s]);const O=v=>{if(p(v),!v)return;const L=N.find(_=>_.filename===v);L&&c(_=>ls(_,L.body))},h=async()=>{const v=is({title:d,body:o});if($(v.errors),!!v.ok){G(!0);try{const L=await a({directory:e,repo:s,title:d.trim(),body:o.trim()?o:void 0,labels:y.length>0?y:void 0,assignees:x.length>0?x:void 0},n);if(!L.ok||typeof L.number!="number"){P.error(L.error?.kind==="failed"?L.error.message:"Could not create the issue");return}P.success(`Issue #${L.number} created`),r(L.number)}finally{G(!1)}}};return t.jsx(ie,{header:t.jsxs("div",{className:"flex h-7 min-w-0 items-center gap-1 px-2 pt-1",children:[t.jsx(j,{type:"button",variant:"ghost",size:"icon",onClick:l,title:"Back to issues","aria-label":"Back to issues",className:"size-6 shrink-0",children:t.jsx(R,{name:"arrow-left",className:"size-4"})}),t.jsx("h1",{className:"min-w-0 flex-1 truncate text-base font-semibold text-foreground",children:"New issue"})]}),tabs:[],activeTab:"",onTabChange:()=>{},children:t.jsxs("div",{className:"flex flex-col gap-3 px-4 py-3",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("label",{htmlFor:"new-issue-title",className:"typography-micro font-medium text-muted-foreground",children:"Title"}),t.jsx(Oe,{id:"new-issue-title",value:d,onChange:v=>b(v.target.value),placeholder:"Short summary","aria-label":"Issue title",className:"h-8",maxLength:300}),A.title?t.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:A.title}):null]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("label",{htmlFor:"new-issue-template",className:"typography-micro font-medium text-muted-foreground",children:"Template"}),t.jsxs("select",{id:"new-issue-template","aria-label":"Issue template",value:f,onChange:v=>O(v.target.value),className:"h-8 rounded-md border border-border bg-[var(--surface-elevated)] px-2 typography-micro text-foreground",children:[t.jsx("option",{value:"",children:"No template"}),N.map(v=>t.jsx("option",{value:v.filename,children:v.name},v.filename))]}),T?t.jsx("p",{className:"typography-micro text-muted-foreground",children:T}):null]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("label",{htmlFor:"new-issue-body",className:"typography-micro font-medium text-muted-foreground",children:"Body"}),t.jsx(_e,{id:"new-issue-body",value:o,onChange:v=>c(v.target.value),placeholder:"Describe the issue","aria-label":"Issue body",rows:8}),A.body?t.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:A.body}):null]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"typography-micro font-medium text-muted-foreground",children:"Labels"}),t.jsx(Ze,{candidates:z,loading:I,selected:y,onChange:w})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"typography-micro font-medium text-muted-foreground",children:"Assignees"}),t.jsx(Xe,{candidates:D,loading:I,selected:x,onChange:S})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(j,{type:"button",size:"sm",onClick:h,disabled:B||!d.trim(),"aria-label":"Create issue",children:B?"Creating…":"Create issue"}),t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:l,disabled:B,children:"Cancel"})]})]})})},Gs=({directory:e,repo:s,isRefreshing:n,registerRefresh:r,onRefreshChange:l,headerActionsSlot:a=null,headerActionsPresentation:d="drawer"})=>{const o=$e().github??null,c=js(e,s),y=ws(e),w=Gt(),[x,S]=u.useState(!1),f=y.repo===s&&typeof y.number=="number"?y.number:null,p=c.state==="open"?"open":c.state==="all"?"both":"closed",N=u.useCallback(()=>{o&&(l(!0),C.getState().refreshAllForScope(e,s,o).catch(()=>null).finally(()=>l(!1)))},[o,e,s,l]);u.useEffect(()=>(r(N),()=>r(null)),[r,N]),u.useEffect(()=>{o&&(l(!0),C.getState().ensureCollectionsFresh(e,s,p,o).catch(()=>null).finally(()=>l(!1)))},[o,e,s,p]),u.useEffect(()=>{if(!o||f===null)return;const m=C.getState();m.ensureDetail(e,s,f,o),m.ensureComments(e,s,f,o)},[o,e,s,f]),u.useEffect(()=>{if(!o)return;const m=()=>{typeof document<"u"&&document.hidden||C.getState().ensureCollectionsFresh(e,s,p,o).catch(()=>{})};return window.addEventListener("focus",m),document.addEventListener("visibilitychange",m),()=>{window.removeEventListener("focus",m),document.removeEventListener("visibilitychange",m)}},[o,e,s,p]),u.useEffect(()=>Tt(m=>{C.getState().notifyAgentTurnComplete(m)}),[]);const k=Me(s,"open"),T=Me(s,"closed"),H=u.useMemo(()=>xs(s),[s,k?.data,T?.data]),z=u.useMemo(()=>new Set(H.map(m=>m.number)),[H]),D=u.useMemo(()=>Ht(H,{state:c.state,involvement:c.involvement,labels:c.labels,search:c.search,sort:c.sort,viewerLogin:w}),[H,c.state,c.involvement,c.labels,c.search,c.sort,w]),I=p==="both"?[k,T]:[p==="open"?k:T],B=I.some(m=>m?.data!=null),G=B&&I.every(m=>m?.data?.nextCursor==null),A=I.reduce((m,q)=>m+(q?.data?.items.length??0),0),$=I.find(m=>m?.error)?.error??null,O=I.some(m=>m?.stale),h=c.search.trim(),v=c.labels.trim(),L=c.involvement!=="all"&&!w||c.involvement==="mentioned",_=h.length>0||v.length>0||c.involvement!=="all",W=u.useMemo(()=>({state:c.state,involvement:c.involvement,labels:v,q:h}),[c.state,c.involvement,v,h]),de=`${W.state}|${W.involvement}|${W.labels}|${W.q}`,X=!G&&B&&(D.length===0||L)&&(h.length>0||v.length>0||L),Q=u.useCallback(m=>o?C.getState().searchRemote(e,s,m,o):Promise.resolve(null),[e,s,o]),me=u.useCallback(m=>o?C.getState().loadMoreRemote(e,s,m,o):Promise.resolve(null),[e,s,o]),{remoteView:he,numberJump:J,remotePending:Y,handleSearchAll:ee}=gt({repo:s,query:W,queryKey:de,autoRemote:X,indexNumbers:z,visibleItems:D,searchText:h,useRemoteEntry:ys,runSearch:Q,runLoadMore:me}),U=u.useMemo(()=>{if(G||!B||!_)return null;const m=D.length===1?"1 match":`${D.length} matches`,q=A===1?"1 most recent loaded issue":`${A} most recent loaded issues`;return`Showing ${m} from the ${q}`},[G,B,_,D.length,A]),F=vs(s,f),M=Cs(s,f),te=u.useCallback(()=>{!o||f===null||C.getState().loadMoreComments(e,s,f,o)},[o,e,s,f]),se=u.useCallback(()=>{C.getState().selectIssue(e,null,null)},[e]),ae=u.useCallback(()=>{!o||f===null||C.getState().refreshDetail(e,s,f,o)},[o,e,s,f]),Z=u.useCallback(()=>{!o||f===null||C.getState().refreshComments(e,s,f,o)},[o,e,s,f]);if(!o)return null;if(x)return t.jsx(Ds,{directory:e,repo:s,github:o,onCancel:()=>S(!1),onCreated:m=>{S(!1),C.getState().selectIssue(e,s,m)}});if(f!==null){const m=F?.data?.detail??null;return t.jsx(As,{directory:e,repo:s,number:f,github:o,seed:ps(s,f),issue:m?.issue??null,linkedPullRequests:m?.linkedPullRequests??[],linkedPullRequestsError:m?.sectionErrors?.linkedPullRequests??null,capabilities:m?.capabilities??null,viewerLogin:m?.viewerLogin??null,viewerPermission:m?.viewerPermission??null,detailError:F?.error??null,detailStale:F?.stale??!1,detailLoading:F?.isLoading??!1,comments:M?.data?.comments??[],commentsHasMore:!!M?.data?.nextCursor,commentsLoading:M?.isLoading??!1,onLoadMoreComments:te,onBack:se,onRetryDetail:ae,onRetryComments:Z})}return t.jsx(Ss,{items:D,headerActionsSlot:a,headerActionsPresentation:d,hasMore:I.some(m=>m?.data?.nextCursor!=null),isLoadingMore:I.some(m=>m?.isLoading),isLoading:I.some(m=>m?.isLoading),isRefreshing:n,stale:O,error:$,filters:c,countComplete:G,incompleteNotice:U?{summary:U,searching:Y,onSearchAll:ee}:null,remote:he,numberJump:J,onFiltersChange:m=>C.getState().setFilters(e,s,m),onClearFilters:()=>C.getState().resetFilters(e,s),onLoadMore:()=>{const m=p==="both"?["open","closed"]:[p];Promise.all(m.map(q=>C.getState().loadMoreCollection(e,s,q,o)))},onRetry:()=>N(),onOpen:m=>C.getState().selectIssue(e,s,m),onNewIssue:()=>S(!0)})},Xs=({headerActionsSlot:e=null,headerActionsPresentation:s="drawer"})=>{const n=Et()??"",[r,l]=u.useState(!1),a=u.useRef(null),d=u.useCallback(o=>{a.current=o},[]),b=u.useCallback(o=>l(o),[]);return n?t.jsx(bt,{directory:n,isRefreshing:r,onRefresh:()=>a.current?.(),children:({repo:o,directory:c})=>t.jsx(Gs,{directory:c,repo:o,isRefreshing:r,registerRefresh:d,onRefreshChange:b,headerActionsSlot:e,headerActionsPresentation:s})}):t.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:t.jsx("p",{className:"typography-ui text-muted-foreground",children:"Open a project to browse issues."})})};export{Xs as IssuesSurface};
@@ -0,0 +1 @@
1
+ import{c5 as M,di as Z,dj as Fe,dk as Ce,dl as ke,dm as Ie,dn as ze,dd as Ne,dp as Oe,B as ee,I as te,dq as Ve}from"./useAppFontEffects--lKKtKVo.js";import{a as ie,s as Pe,b as Se,c as ne,d as ve,g as Be,e as re,f as I,h as De,i as Ue,j as _e,k as We,R as Ge,I as je,p as se,l as $e,m as qe,n as Ke,o as Je,w as Ye,q as ae,u as Xe,r as Qe,t as Ze,v as et,x as oe,S as tt,y as it,z as nt,A as rt,B as ye,C as he,F as st}from"./web-components-v9fuidaX.js";import{G as at,u as ot,W as ht,a as lt,b as dt,n as le,t as ct}from"./Virtualizer-wpC51ZBQ.js";import{j as C}from"./vendor-boot-DyL2td56.js";import{o as ut,i as j,f as A,a as ft,q as de,s as pt,t as ce,d as gt,u as ue,b as mt,w as B,x as fe}from"./computeVirtualFileMetrics-3PpRLd5B.js";import{a as F,i as K,l as pe,h as Ct,r as St}from"./renderFileWithHighlighter-BvDoP7ob.js";import{t as H}from"./vendor-hast-util-to-html-BKBhbTDb.js";import{a as k,R as L}from"./vendor-react-DASdDPIk.js";let vt=-1;var yt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++vt}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;textDoucmentCache=new WeakMap;constructor(i={theme:M},e,t){this.options=i,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=ie(i.theme??M)?ut():void 0)}setOptions(i){this.options=i}mergeOptions(i){this.options={...this.options,...i}}setLineAnnotations(i){this.lineAnnotations={};for(const e of i){const t=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=t,t.push(e)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0}clearRenderCache(){const i=this.renderCache;this.renderCache=void 0,i!=null&&i.isDirty===!0&&i.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(i.file.cacheKey)}hydrate(i){const{options:e}=this.getRenderOptions(i),t=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());let n=this.workerManager?.getFileResultCache(i);n!=null&&!F(e,n.options)&&(n=void 0),this.renderCache??={file:i,options:e,highlighted:!t&&!K(i),result:t?void 0:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightFileAST(this,i):this.highlighter==null&&(this.computedLang=i.lang??j(i.name),this.initializeHighlighter())}getRenderOptions(i){const e=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getFileRenderOptions();const{theme:n=M,tokenizeMaxLineLength:r=1e3}=this.options;return{theme:n,useTokenTransformer:Pe(this.options),tokenizeMaxLineLength:r}})(),{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!A(i,t.file)||!F(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getOrCreateLineCache(i){if(i.cacheKey==null)return this.lineCache=void 0,pe(i.contents);let{lineCache:e}=this;return(e==null||e.cacheKey!==i.cacheKey)&&(e={cacheKey:i.cacheKey,lines:pe(i.contents)}),this.lineCache=e,e.lines}getLineCount(i){return this.textDoucmentCache.get(i)?.lineCount??this.getOrCreateLineCache(i).length}updateRenderCache(i,e){if(this.renderCache==null)return;const{result:t}=this.renderCache;if(t!=null){for(const[n,r]of i)t.code[n]={type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:r.map(([s,a,o])=>s===0&&a===""?o===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:o}:{type:"element",tagName:"span",properties:{"data-char":s,style:`--diffs-token-${e}:${a};`},children:[{type:"text",value:o}]})};t.baseThemeType=e,this.renderCache.isDirty=!0}}applyDocumentChange(i){if(this.renderCache==null)return;const{file:e,result:t}=this.renderCache;if(t!=null&&t.code.length!==i.lineCount){t.code.length=Math.min(t.code.length,i.lineCount);for(let n=t.code.length;n<i.lineCount;n++)t.code.push({type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:i.getLineText(n)}]}]});this.renderCache.isDirty=!0}this.textDoucmentCache.set(e,i)}renderFile(i=this.renderCache?.file,e=Z){if(i==null)return;let{options:t,forceHighlight:n}=this.getRenderOptions(i);const r=this.getMatchingWorkerResultCache(i,t);r!=null&&!this.hasHighlightedRenderCache(i,t)&&(this.renderCache={file:i,highlighted:!0,renderRange:void 0,...r},n=!1),this.renderCache??={file:i,highlighted:!1,options:t,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(i),a=i.contents.length>0,o=!a||K(i)||$(s.length,this.getTokenizeMaxLength()),h=!A(i,this.renderCache.file),d=!Se(this.renderCache.renderRange,e);if(this.workerManager?.isWorkingPool()===!0)(o||this.renderCache.result==null||!this.renderCache.highlighted&&(h||d))&&(this.renderCache.file=i,this.renderCache.options=t,this.renderCache.highlighted=!1,(this.renderCache.result==null||h||d||n)&&(this.renderCache.result=this.workerManager.getPlainFileAST(i,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!o&&a&&(!this.renderCache.highlighted||n)&&this.workerManager.highlightFileAST(this,i);else{this.computedLang=i.lang??j(i.name);const l=this.highlighter!=null&&ie(t.theme),c=this.highlighter!=null&&ne(this.computedLang),u=!o&&c;if(this.highlighter!=null&&l&&(n||o||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:p,options:f}=this.renderFileWithHighlighter(i,this.highlighter,o||!c);this.renderCache={file:i,options:f,highlighted:u,result:p,renderRange:void 0}}(!l||!o&&!c)&&this.asyncHighlight(i).then(({result:p,options:f})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(i,p,f,!o)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(i,e=Z){const{result:t}=await this.asyncHighlight(i);return this.processFileResult(i,e,t)}async asyncHighlight(i){const e=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());this.computedLang=e?"text":i.lang??j(i.name);const t=this.highlighter!=null&&Ct(ft(this.options.theme)),n=e||this.highlighter!=null&&ne(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(i,this.highlighter,e)}renderFileWithHighlighter(i,e,t=!1){const{options:n}=this.getRenderOptions(i);return{result:St(i,e,n,{forcePlainText:t}),options:n}}processFileResult(i,e,{code:t,themeStyles:n,baseThemeType:r}){const s=this.getLineCount(i),{disableFileHeader:a=!1}=this.options,o=[],h=ue(),d=Math.min(e.startingLine+e.totalLines,s);let l=0;const c=ve(e)?Be(this.lineAnnotations):void 0;c!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>I(u))})),l++);for(let u=e.startingLine;u<d;u++){const p=u+1,f=t[u];if(f==null){const g="FileRenderer.processFileResult: Line doesnt exist";throw console.error(g,{name:i.name,lineIndex:u,lineNumber:p}),new Error(g)}h.children.push(pt("context",p,`${u}`)),o.push(f),l++;const S=this.lineAnnotations[p];S!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:0,lineIndex:p,annotations:S.map(g=>I(g))})),l++)}return h.properties.style=`grid-row: span ${l}`,{gutterAST:h.children??[],contentAST:o,preAST:this.createPreElement(s),headerAST:a?void 0:this.renderHeader(i),totalLines:s,rowCount:l,themeStyles:n,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(i){const{headerRenderMode:e="default",stickyHeader:t=!1}=this.options;return De({fileOrDiff:i,mode:e,stickyHeader:t})}renderFullHTML(i){return H(this.renderFullAST(i))}renderFullAST(i,e=[]){return e.push(ce({tagName:"code",children:this.renderCodeAST(i),properties:{"data-code":""}})),{...i.preAST,children:e}}renderCodeAST(i){const e=ue();return e.children=i.gutterAST,e.properties.style=`grid-row: span ${i.rowCount}`,[e,Ue(i.contentAST,i.rowCount)]}renderPartialHTML(i,e=!1){return e?H(ce({tagName:"code",children:i,properties:{"data-code":""}})):H(i)}async initializeHighlighter(){return this.highlighter=await gt(_e(this.computedLang,this.options)),this.highlighter}onHighlightSuccess(i,e,t,n=!0){if(this.renderCache==null)return;const r=!A(i,this.renderCache.file)||!this.renderCache.highlighted||!F(t,this.renderCache.options);this.renderCache={file:i,options:t,highlighted:n,result:e,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(i,e){const t=this.workerManager?.getFileResultCache(i);if(!(t==null||!F(e,t.options)))return t}hasHighlightedRenderCache(i,e){const{renderCache:t}=this;return t?.result!=null&&t.highlighted&&A(i,t.file)&&F(e,t.options)}onHighlightError(i){console.error(i)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(i){const{disableLineNumbers:e=!1,overflow:t="scroll"}=this.options;return We({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:t,split:!1,totalLines:i})}};function $(i,e){return i>e}function Tt(i,e){return i.lineNumber===e.lineNumber&&i.metadata===e.metadata}function ge(i){return{theme:i?.theme,disableLineNumbers:i?.disableLineNumbers,overflow:i?.overflow,themeType:i?.themeType,collapsed:i?.collapsed,disableFileHeader:i?.disableFileHeader,disableVirtualizationBuffers:i?.disableVirtualizationBuffers,stickyHeader:i?.stickyHeader,preferredHighlighter:i?.preferredHighlighter,useCSSClasses:i?.useCSSClasses,useTokenTransformer:i?.useTokenTransformer,tokenizeMaxLineLength:i?.tokenizeMaxLineLength,tokenizeMaxLength:i?.tokenizeMaxLength,unsafeCSS:i?.unsafeCSS,headerRenderMode:i?.renderCustomHeader!=null?"custom":"default"}}const bt=[""];let Rt=-1;var Te=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++Rt}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:M},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new yt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new Ge,this.interactionManager=new je("file",se(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(se(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!mt(this.appliedThemeCSS.theme,this.options.theme??M)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,e==="wrap"),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.annotationCache.clear(),this.pre=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder=void 0,this.unsafeCSSStyle=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1,this.editor?.cleanUp(),this.editor=void 0}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:s,lineAnnotations:a}=e;this.hydrateElements(t,n),Lt(this.pre,s,this.options.collapsed)||At(this.headerElement,s,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:s,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),$e(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):bt}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(r=>{e.__syncRenderView(r,t,n,this.lineAnnotations,this.renderRange)})}attachEditor(e){return this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0),this.syncRenderViewToEditor(),()=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1)}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t){this.fileRenderer.updateRenderCache(e,t)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:s,deferManagers:a=!1,lineAnnotations:o,renderRange:h}){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");this.editor?.__postponeBackgroundTokenizeToNextFrame();const{collapsed:d=!1,themeType:l="system"}=this.options,c=d?void 0:h,u=this.renderRange,p=this.hasThemeChanged(),f=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1,S=!A(this.file,e);if(!d&&!n&&Se(c,this.renderRange)&&!S&&!f&&!p)return this.applyCachedThemeState(l);this.renderRange=c,S&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:g=!1,disableFileHeader:y=!1}=this.options;if(y&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,s),this.applyCachedThemeState(l),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const m=this.fileRenderer.renderFile(e,Fe);m!=null&&this.applyThemeState(t,m.themeStyles,l,m.baseThemeType),m?.headerAST!=null&&this.applyHeaderToDOM(m.headerAST,t),this.injectUnsafeCSS()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}try{const m=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,f,S||p)||!this.applyPartialRender(u,c)){const v=this.fileRenderer.renderFile(e,c);if(v==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,v.themeStyles,l,v.baseThemeType),v.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.applyFullRender(v,m)}this.applyBuffers(m,c),this.injectUnsafeCSS(),this.managersDirty=!0,a||this.flushManagers(),this.renderAnnotations(),this.renderGutterUtility(),this.editor!=null&&this.syncRenderViewToEditor()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}primeHighlightCache(){const{file:e,workerManager:t}=this;e==null||e.cacheKey==null||t==null||K(e)||this.fileRenderer.getOrCreateLineCache(e).length>(this.options.tokenizeMaxLength??1e5)||t.primeFileHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const s=`${n}-${I(r)}`;let a=this.annotationCache.get(s);if(a==null||!Tt(r,a.annotation)){a?.element.remove();const o=t(r);if(o==null)continue;a={element:qe(I(r)),annotation:r},a.element.appendChild(o),this.fileContainer.appendChild(a.element),this.annotationCache.set(s,a)}e.delete(s)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=Ke();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=Je(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ye(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){const s=e.shadowRoot??e.attachShadow({mode:"open"}),a=r??n,o=this.options.theme??M,h=typeof o=="string"?o:{...o},d=ae(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===d){this.appliedThemeCSS.theme=h;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d};return}this.themeCSSStyle=Xe({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:Qe(t,a,d)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=Ze(this.themeCSSStyle.textContent??"",ae(e)))}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e),this.code=et({code:this.code});const n=this.fileRenderer.renderCodeAST(e);if(this.code.childElementCount>=2)for(let r=0;r<2;r++){const s=this.code.children[r],a=n[r];s.innerHTML=H(a.children),s.style.cssText=a.properties.style}else this.code.innerHTML=H(n);t.contains(this.code)||t.replaceChildren(this.code),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:r}=this,s=r!=null?this.getColumns(r):void 0;if(n==null||r==null||s==null)return!1;const a=e.startingLine,o=t.startingLine,h=e.totalLines===1/0?Number.POSITIVE_INFINITY:a+e.totalLines,d=t.totalLines===1/0?Number.POSITIVE_INFINITY:o+t.totalLines,l=Math.max(a,o),c=Math.min(h,d);if(c<=l||!this.trimDOMToOverlap(s.gutter,l,c)||!this.trimDOMToOverlap(s.content,l,c))return!1;let{length:u}=s.content.children;const p=(y,m)=>{if(!(m<=0))return this.fileRenderer.renderFile(n,{startingLine:y,totalLines:m,bufferBefore:0,bufferAfter:0})},f=o<l?p(o,l-o):void 0;if(f===void 0&&o<l)return!1;const S=d===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,d-c),g=d>c?p(c,S):void 0;return g===void 0&&d>c?!1:(this.cleanupErrorWrapper(),f!=null&&(s.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.gutterAST)),s.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.contentAST)),u+=f.rowCount),g!=null&&(s.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.gutterAST)),s.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.contentAST)),u+=g.rowCount),this.lastRowCount!==u&&(s.gutter.style.setProperty("grid-row",`span ${u}`),s.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const r=this.getDOMBoundaryIndices(e,[t,n]),s=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(s>a)return!1;for(let o=e.children.length-1;o>=a;o-=1)e.children[o]?.remove();for(let o=s-1;o>=0;o-=1)e.children[o]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((h,d)=>h-d),r=new Map;if(n.length===0)return r;let s=0,a=n[s];const{children:o}=e;a===0&&(r.set(0,0),s+=1,a=n[s]);for(let h=0;h<o.length;h+=1){const d=o[h];if(!(d instanceof HTMLElement))continue;const l=this.getLineIndexFromDOMNode(d);if(l!=null){for(;a!=null&&l>=a;)r.set(a,h),s+=1,a=n[s];if(s>=n.length)break}}for(const h of n)r.has(h)||r.set(h,o.length);return r}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const r=this.cachedHeaderHTML??H(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){const d=document.createElement("div");d.innerHTML=r;const l=d.firstElementChild;if(!(l instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(l,this.headerElement):t.shadowRoot?.prepend(l),this.headerElement=l,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;const{renderHeaderPrefix:s,renderHeaderFilenameSuffix:a,renderCustomHeader:o,renderHeaderMetadata:h}=this.options;if(o!=null){const d=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Ce,d),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const d=s?.(n)??void 0,l=a?.(n)??void 0,c=h?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,ke,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Ie,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ze,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}const s=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,r),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),s=n!==r;return s&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:oe(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):oe(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=tt;const r=n.firstChild;r instanceof SVGElement&&(this.spriteSVG=r)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,s={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};it(s,this.appliedPreAttributes)||(nt(e,s),this.appliedPreAttributes=s)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Lt(i,e,t=!1){return!t&&i==null&&e!=null}function At(i,e,t=!1){return i==null&&e!=null&&!t}const Mt=5e3;let Ht=-1;function xt(i,e){return(i.overflow??"scroll")!==(e.overflow??"scroll")||(i.collapsed??!1)!==(e.collapsed??!1)||(i.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(i.disableFileHeader??!1)!==(e.disableFileHeader??!1)||i.unsafeCSS!==e.unsafeCSS}var wt=class extends Te{virtualizer;metrics;__id=`virtualized-file:${++Ht}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(i,e,t=Ne,n,r=!1){super(i,n,r),this.virtualizer=e,this.metrics=t}setMetrics(i,e=!1){!e&&rt(this.metrics,i)||(this.metrics=i,this.resetLayoutCache())}setLineAnnotations(i){this.syncLineAnnotations(i)&&this.resetLayoutCache()}syncLineAnnotations(i){return i==null||i===this.lineAnnotations||i.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(i),!0)}hasLineAnnotations(){return this.lineAnnotations.some(i=>i.lineNumber>0)}getLineHeight(i,e=!1){const t=this.cache.heights.get(i);if(t!=null)return t;const n=e?2:1;return this.metrics.lineHeight*n}setOptions(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(i==null)return;const{options:e}=this,t=!ye(e,i),n=xt(e,i);super.setOptions(i),n&&this.resetLayoutCache(!0),t&&(this.forceRenderOverride=!0),t&&this.virtualizer.instanceChanged(this,n)}setThemeType(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(i)}resetLayoutCache(i=!1){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&(this.renderRange=void 0),i&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let i=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(i=!0),this.height=0,i;const{overflow:e="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),e==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return i;const t=this.code.children[1];if(!(t instanceof HTMLElement))return i;const n=he(this.lineAnnotations);if(this.renderRange!=null&&n&&ve(this.renderRange)){const r=Et(t)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,i=!0)}else!n&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,i=!0);for(const r of t.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const a=Number(s);let o=r.getBoundingClientRect().height,h=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(h=!0),o+=r.nextElementSibling.getBoundingClientRect().height);const d=this.getLineHeight(a,h);o!==d&&(i=!0,o===this.metrics.lineHeight*(h?2:1)?this.cache.heights.delete(a):this.cache.heights.set(a,o))}return(i||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),i}onRender=i=>this.fileContainer==null||this.file==null?!1:(i&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(i,e,t,n){const r=this.syncLineAnnotations(n);let s=t?.resetFileLayoutCache===!0||r;t?.metrics!=null&&(this.metrics=t.metrics,s=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,s=!0),s&&this.resetLayoutCache(),this.file!==i&&(this.layoutDirty=!0),this.file=i,this.top=e,this.computeApproximateSize(),this.height}getLinePosition(i){if(this.file==null||i<1)return;const{disableFileHeader:e=!1,collapsed:t=!1}=this.options,n=this.fileRenderer.getLineCount(this.file)-1;let r=B(this.metrics,e);if(t||n<0)return{top:r,height:0};const s=Math.min(Math.max(i-1,0),n),{overflow:a="scroll"}=this.options,{lineHeight:o}=this.metrics;if(r+=this.cache.fileAnnotationHeight,a==="scroll"&&!this.hasLineAnnotations())return{top:r+s*o,height:o};const h=this.getLayoutCheckpointBeforeLineIndex(s);r=h?.top??r;for(let d=h?.lineIndex??0;d<s;d++)r+=this.getLineHeight(d,!1);return{top:r,height:this.getLineHeight(s,!1)}}getNumericScrollAnchor(i){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:e=!1,collapsed:t=!1,overflow:n="scroll"}=this.options;if(t||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=B(this.metrics,e),a=Math.min(this.renderRange.startingLine,r),o=Math.min(a+this.renderRange.totalLines-1,r);if(o<a)return;const{fileAnnotationHeight:h}=this.cache;if(n==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:l}=this.metrics,c=s+(a===0?h:this.renderRange.bufferBefore),u=a+Math.max(Math.ceil((i-c)/l),0);return u>o?void 0:{lineNumber:u+1,top:s+h+u*l}}let d=s+(a===0?h:this.renderRange.bufferBefore);for(let l=a;l<=o;l++){if(d>=i)return{lineNumber:l+1,top:d};d+=this.getLineHeight(l)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(i){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const e=i!=null?this.computeRenderRangeFromWindow(this.file,this.top,i):this.renderRange;if(e==null)return;const{bufferBefore:t,bufferAfter:n,totalLines:r}=e;let s=0;if(r===0){const a=i??this.virtualizer.getWindowSpecs();this.top<a.top&&(s=n)}return{topOffset:this.top+t+s,height:this.height-(t+n)}}cleanUp(i=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),i||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(i)}computeApproximateSize(i=!1){const e=this.isResizeDebuggingEnabled();if(!i&&!this.layoutDirty&&!e)return;const t=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.file==null){this.layoutDirty=!1;return}const{disableFileHeader:n=!1,collapsed:r=!1,overflow:s="scroll"}=this.options,{lineHeight:a}=this.metrics,o=this.fileRenderer.getLineCount(this.file),h=B(this.metrics,n),d=fe(this.metrics);if(this.height+=h,r){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,s==="scroll"&&!this.hasLineAnnotations())this.height+=o*a;else for(let l=0;l<o;l++)this.addLayoutCheckpoint(l,this.height),this.height+=this.getLineHeight(l,!1);if(o>0&&(this.height+=d),this.fileContainer!=null&&e&&!t){const l=this.fileContainer.getBoundingClientRect();l.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:this.file.name,elementHeight:l.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(i){this.isAdvancedMode()||this.fileContainer==null||(i&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!i&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(i,e,t=!1){const{heights:n,checkpoints:r}=this.cache,s=this.renderRange;if(super.applyDocumentChange(i,e),this.getSimpleVirtualizer()?.markDOMDirty(),this.layoutDirty=!0,n.size>0&&n.clear(),r.length>0&&(r.length=0),this.isSimpleMode()&&this.computeApproximateSize(),t&&s!==void 0&&this.file!==void 0){const a=this.virtualizer.getWindowSpecs(),o=this.computeRenderRangeFromWindow(this.file,this.top??0,a);o.bufferAfter!==s.bufferAfter&&this.updateBuffers(o)}}render({fileContainer:i,file:e,forceRender:t=!1,lineAnnotations:n,...r}){const s=this.file==null||!A(this.file,e),{forceRenderOverride:a,isSetup:o}=this;this.forceRenderOverride=void 0;const h=this.syncLineAnnotations(n);if(h&&this.resetLayoutCache(),this.file=e,i=this.getOrCreateFileContainerNode(i),this.file==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(o)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!0));else{this.computeApproximateSize();const u=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(u==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");u.connect(i,this),this.isVisible=u.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);const d=this.virtualizer.getWindowSpecs(),l=this.top??0,c=this.computeRenderRangeFromWindow(this.file,l,d);return super.render({file:this.file,fileContainer:i,renderRange:c,lineAnnotations:n,forceRender:(a??t)||h,...r})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(i,e){i%Mt===0&&this.cache.checkpoints.push({lineIndex:i,top:e})}getLayoutCheckpointBeforeLineIndex(i){if(i<=0||this.cache.checkpoints.length===0)return;let e=0,t=this.cache.checkpoints.length-1,n;for(;e<=t;){const r=e+t>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=i?(n=s,e=r+1):t=r-1}return n}getLayoutCheckpointBeforeTop(i,e){let t=0,n=this.cache.checkpoints.length-1,r=-1;for(;t<=n;){const s=t+n>>1,a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");a.top<=i?(r=s,t=s+1):n=s-1}if(e==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(a.lineIndex%e===0)return a}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(i,e,{top:t,bottom:n}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:a,lineHeight:o}=this.metrics,h=this.fileRenderer.getLineCount(i),d=this.height,l=B(this.metrics,r),c=h>0?fe(this.metrics):0,{fileAnnotationHeight:u}=this.cache,p=l+u,f=Math.max(0,d-l-u-c),S=he(this.lineAnnotations),g=e+l,y=u>0&&S&&g<n&&g+u>t;if(e<t-d||e>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};if(h<=a)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};const m=Math.ceil(Math.max(n-t,0)/o),v=Math.ceil(m/a)*a+a*2,z=v/a,D=(t+n)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const R=e+p,P=R+f;if(!y&&!(R<n&&P>t))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};const w=Math.floor(y&&D<e+p?0:(D-(e+p))/o),b=Math.floor(w/a)-Math.floor(z/2),xe=Math.ceil(h/a),E=Math.max(0,Math.min(b,xe))*a,Q=b<0?v+b*a:v,we=E===0?0:u+E*o,Ee=Math.min(Q,h-E);return{startingLine:E,totalLines:Q,bufferBefore:we,bufferAfter:Math.max(0,(h-E-Ee)*o)}}const be=z,N=[],U=this.getLayoutCheckpointBeforeTop(Math.max(0,t-e-v*o*2),a);let T=e+(U?.top??p),_=U?.lineIndex??0,O,V,x;const Re=U?.lineIndex??0;for(let R=Re;R<h;R++){const P=_%a===0,w=Math.floor(_/a);if(P&&(N[w]=T-(e+p),x!=null)){if(x<=0)break;x--}const b=this.getLineHeight(R,!1);T>t-b&&T<n&&(O??=w),T+b>D&&(V??=w),x==null&&T>=n&&P&&(x=be),_++,T+=b}if(O==null)if(y)O=0,V=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};V??=O;const W=Math.round(V-z/2),Le=Math.max(0,Math.ceil(h/a)-z),G=Math.max(0,Math.min(W,Le)),J=G*a,Y=W<0?v+W*a:v,Ae=N[G]??0,Me=J===0?0:u+Ae,X=G+Y/a,He=X<N.length?f-N[X]:f-(T-e-p);return{startingLine:J,totalLines:Y,bufferBefore:Me,bufferAfter:Math.max(0,He)}}};function Et(i){let e;for(const t of i.children)t instanceof HTMLElement&&t.dataset.lineAnnotation===st&&(e=Math.max(e??0,t.getBoundingClientRect().height));return e}function Ft({file:i,renderCustomHeader:e,renderHeaderPrefix:t,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:a,renderGutterUtility:o,getHoveredLine:h}){const d=e?.(i),l=t?.(i),c=n?.(i),u=r?.(i);return C.jsxs(C.Fragment,{children:[d!=null?C.jsx("div",{slot:Ce,children:d}):C.jsxs(C.Fragment,{children:[l!=null&&C.jsx("div",{slot:"header-prefix",children:l}),c!=null&&C.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&C.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&a?.map((p,f)=>C.jsx("div",{slot:I(p),children:s(p)},f)),o!=null&&C.jsx("div",{slot:"gutter-utility-slot",style:at,children:o(h)})]})}const me=typeof window>"u"?k.useEffect:k.useLayoutEffect;function kt({file:i,options:e,lineAnnotations:t,selectedLines:n,prerenderedHTML:r,metrics:s,hasGutterRenderUtility:a,hasCustomHeader:o,disableWorkerPool:h,contentEditable:d}){const l=ot(),c=n!==void 0,u=k.useContext(ht),p=lt(),f=k.useRef(null),S=dt(g=>{if(g!=null){if(f.current!=null)throw new Error("File: An instance should not already exist when a node is created");l!=null?f.current=new wt(q({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),l,s,h?void 0:u,!0):f.current=new Te(q({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),h?void 0:u,!0),f.current.hydrate({file:i,fileContainer:g,lineAnnotations:t,prerenderedHTML:r})}else{if(f.current==null)throw new Error("File: A File instance should exist when unmounting");f.current.cleanUp(),f.current=null}});return me(()=>{if(f.current==null)return;const g=q({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),y=!ye(f.current.options,g);f.current.setOptions(g),f.current.render({file:i,lineAnnotations:t,forceRender:y}),n!==void 0&&f.current.setSelectedLines(n)}),me(()=>{if(d&&f.current!=null){if(p===void 0)throw new Error("File: Editor is not attached");return p.edit(f.current)}},[d,p]),{ref:S,getHoveredLine:k.useCallback(()=>f.current?.getHoveredLine(),[])}}function q({options:i,controlledSelection:e,contentEditable:t,hasCustomHeader:n,hasEditor:r,hasGutterRenderUtility:s}){const a=t&&r,o=e||s||n;if(!o&&!a)return i;let h={...i};return o&&(h={...h,controlledSelection:e,renderCustomHeader:n?le:i?.renderCustomHeader,renderGutterUtility:s?le:i?.renderGutterUtility}),a&&(h={...h,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,lineHoverHighlight:"disabled"}),h}function _t({file:i,lineAnnotations:e,selectedLines:t,options:n,metrics:r,className:s,style:a,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,prerenderedHTML:u,renderGutterUtility:p,disableWorkerPool:f=!1,contentEditable:S=!1}){const{ref:g,getHoveredLine:y}=kt({file:i,options:n,metrics:r,lineAnnotations:e,selectedLines:t,prerenderedHTML:u,hasGutterRenderUtility:p!=null,hasCustomHeader:h!=null,disableWorkerPool:f,contentEditable:S});return C.jsx(Oe,{ref:g,className:s,style:a,children:ct(Ft({file:i,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,renderGutterUtility:p,lineAnnotations:e,getHoveredLine:y}),u)})}const Wt=L.memo(function({jsonString:e,className:t,maxHeight:n="100%",initiallyExpandedDepth:r=2}){const s=L.useRef(null),[a,o]=L.useState(null),h=L.useMemo(()=>{try{const c=e.trim();if(!c)return o("Empty JSON content"),null;const u=JSON.parse(c);return o(null),u}catch(c){return o(c instanceof Error?c.message:"Invalid JSON"),null}},[e]),d=L.useCallback(()=>{s.current?.expandAll()},[]),l=L.useCallback(()=>{s.current?.collapseAll()},[]);return a?C.jsx("div",{className:t,children:C.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4",children:[C.jsx("div",{className:"mb-1 font-medium text-[var(--surface-foreground)]",children:"Invalid JSON"}),C.jsx("div",{className:"font-mono text-xs text-[var(--surface-mutedForeground)]",children:a})]})}):h===null?null:C.jsxs("div",{className:t,children:[C.jsxs("div",{className:"flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1",children:[C.jsxs(ee,{variant:"ghost",size:"xs",onClick:d,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-down-s",className:"h-3 w-3"}),"Expand All"]}),C.jsxs(ee,{variant:"ghost",size:"xs",onClick:l,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-up-s",className:"h-3 w-3"}),"Collapse All"]})]}),C.jsx("div",{className:"bg-[var(--syntax-base-background)] py-1",style:{maxHeight:n,overflow:"auto"},children:C.jsx(Ve,{ref:s,data:h,maxHeight:n,initiallyExpandedDepth:r})})]})});export{_t as F,Wt as J};
@@ -0,0 +1,12 @@
1
+ import{j as _}from"./vendor-boot-DyL2td56.js";import{R as y}from"./vendor-react-DASdDPIk.js";import{m as Ke}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ue}from"./vendor-beautiful-mermaid-DApbjBp2.js";import{S as Ze,an as Xe,t as ve,m as Ge,a8 as ee,bN as Ye,o as Z,_ as te}from"./index-Dd2OcIUY.js";import{c6 as Ae,c7 as Je,c8 as Qe,ae as W,br as et,bs as tt,c9 as nt,ca as rt,o as ot,cb as ne,cc as at,cd as it,ce as st,p as ke,n as Ee,cf as Ce,cg as ct,aX as lt}from"./useAppFontEffects--lKKtKVo.js";import{r as dt,s as ut,i as mt,a as pt,b as ft}from"./markdownCore-BH56o6Wu.js";import{r as ht}from"./registerCustomTheme-DmolaWWZ.js";import{i as bt}from"./runtimeSurface-B1GRkkKC.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-elkjs-D27273Ms.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-dompurify-r8glNMJW.js";import"./vendor-remend-BWYYytN3.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";const Se="pichamber-md",gt={name:Se,colors:{"editor.background":"transparent","editor.foreground":"var(--md-syntax-foreground)"},tokenColors:[{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:"var(--md-syntax-comment)",fontStyle:"italic"}},{scope:["string","punctuation.definition.string","string.template"],settings:{foreground:"var(--md-syntax-string)"}},{scope:["constant.numeric","constant.language","constant.character","constant"],settings:{foreground:"var(--md-syntax-number)"}},{scope:["keyword","storage","storage.type","storage.modifier","keyword.control"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["keyword.operator","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--md-syntax-operator)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--md-syntax-function)"}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--md-syntax-type)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--md-syntax-variable)"}},{scope:["variable.other.property","meta.property-name","support.type.property-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["entity.name.tag","punctuation.definition.tag"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["entity.other.attribute-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:"var(--md-syntax-keyword)",fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted"],settings:{foreground:"var(--md-syntax-deleted)"}},{scope:["invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let re=!1;const wt=()=>{re||(re=!0,ht(Se,()=>Promise.resolve(gt)))},k=e=>Number.isFinite(e)&&e>0,oe=e=>{if(typeof e=="number")return k(e)?e:null;if(typeof e!="string")return null;const t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;const r=Number(t[1]);return k(r)?r:null},B=(e,t,r)=>Math.min(r,Math.max(t,e)),yt=6,ae=1.25,vt=1.0015,At=.5,kt=12,ie=3,Et=400,I='[data-markdown="mermaid-block"]',L=e=>e.querySelector(I)!==null,Ct=e=>[e.x,e.y,e.width,e.height].map(t=>{const r=Number(t.toFixed(yt));return Object.is(r,-0)?"0":String(r)}).join(" "),St=e=>{const t=e.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(t?.length===4){const[s,o,a,i]=t;if(Number.isFinite(s)&&Number.isFinite(o)&&k(a)&&k(i))return{x:s,y:o,width:a,height:i}}const r=oe(e.width),n=oe(e.height);return r===null||n===null?null:{x:0,y:0,width:r,height:n}},Lt=e=>{let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Mt=e=>{const t=e.renderMode||"unknown",r=e.svgMarkup??"";if(!r){const n=[e.viewBox??"",e.width??"",e.height??""];return n.some(s=>s!=="")?`${t}:bounds:${n.join(":")}`:`${t}:no-svg`}return[t,Lt(r)].join(":")},Le=(e,t)=>{if(!k(t.width)||!k(t.height))return e;const r=e.width/e.height,n=t.width/t.height;if(r>n){const o=e.width/n;return{x:e.x,y:e.y-(o-e.height)/2,width:e.width,height:o}}const s=e.height*n;return{x:e.x-(s-e.width)/2,y:e.y,width:s,height:e.height}},Nt=({currentBox:e,viewport:t,delta:r})=>!k(t.width)||!k(t.height)||!k(e.width)||!k(e.height)?e:{x:e.x-r.x/t.width*e.width,y:e.y-r.y/t.height*e.height,width:e.width,height:e.height},xt=(e,t)=>{const r=t.x-e.x,n=t.y-e.y;return r*r+n*n>ie*ie},Tt=({currentBox:e,contentBox:t,viewport:r,pointer:n,zoomFactor:s,minScale:o,maxScale:a})=>{if(!k(r.width)||!k(r.height)||!k(s)||!k(e.width)||!k(e.height)||!k(t.width)||!k(t.height)||!k(o)||!k(a))return e;const i=Math.min(o,a),c=Math.max(o,a),d=Le(t,r),l=d.width/e.width,m=B(l*s,i,c),p=d.width/m,f=p/(e.width/e.height),h=B(n.x/r.width,0,1),v=B(n.y/r.height,0,1),A=e.x+h*e.width,w=e.y+v*e.height;return{x:A-h*p,y:w-v*f,width:p,height:f}},X=new WeakMap,Pt=e=>e instanceof HTMLElement?X.get(e)??null:null,Rt=e=>e.querySelector('[data-markdown="mermaid-viewport"]')??e.querySelector('[data-markdown="mermaid"]'),se=e=>{const t=e.querySelector('[data-markdown="mermaid"] svg'),r=e.querySelector('[data-markdown="mermaid"]');return Mt({renderMode:e.getAttribute("data-mermaid-render"),svgMarkup:r?.getAttribute("data-md-original-svg")??t?.outerHTML??null,viewBox:t?.getAttribute("viewBox"),width:t?.getAttribute("width"),height:t?.getAttribute("height")})},R=e=>{const t=e.getBoundingClientRect();return{width:t.width,height:t.height}},_t=(e,t)=>{const r=t.getBoundingClientRect();return{x:e.clientX-r.left,y:e.clientY-r.top}},It=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),Ft=e=>{const t=Rt(e),r=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!r)return null;const n=St({viewBox:r.getAttribute("viewBox"),width:r.getAttribute("width"),height:r.getAttribute("height")});if(!n)return null;let s=n,o=null,a=null,i=null,c=null;const d=u=>{s=u,r.setAttribute("viewBox",Ct(u)),r.removeAttribute("width"),r.removeAttribute("height")},l=()=>{d(Le(n,R(t)))},m=(u,E)=>{d(Tt({currentBox:s,contentBox:n,viewport:R(t),pointer:u,zoomFactor:E,minScale:At,maxScale:kt}))},p=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},ae)},f=()=>{const u=R(t);m({x:u.width/2,y:u.height/2},1/ae)},h=u=>{!u.ctrlKey&&!u.metaKey||(u.preventDefault(),u.stopPropagation(),m(_t(u,t),Math.pow(vt,-u.deltaY)))},v=u=>{u.button!==0||It(u.target)||(o=u.pointerId,a={x:u.clientX,y:u.clientY},i=a,c!==null&&(window.clearTimeout(c),c=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(u.pointerId),e.setAttribute("data-mermaid-panning","true"),u.preventDefault())},A=u=>{if(o!==u.pointerId||!i)return;const E={x:u.clientX,y:u.clientY};d(Nt({currentBox:s,viewport:R(t),delta:{x:E.x-i.x,y:E.y-i.y}})),i=E,a&&xt(a,E)&&e.setAttribute("data-mermaid-suppress-click","true"),u.preventDefault()},w=u=>{o===u.pointerId&&(t.releasePointerCapture?.(u.pointerId),o=null,a=null,i=null,e.removeAttribute("data-mermaid-panning"),e.hasAttribute("data-mermaid-suppress-click")&&(c=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),c=null},Et)))},b=()=>{l()};t.addEventListener("wheel",h,{passive:!1}),t.addEventListener("pointerdown",v),t.addEventListener("pointermove",A),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),window.addEventListener("resize",b);const g=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return g?.observe(t),l(),{zoomIn:p,zoomOut:f,fit:l,cleanup:()=>{t.removeEventListener("wheel",h),t.removeEventListener("pointerdown",v),t.removeEventListener("pointermove",A),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),window.removeEventListener("resize",b),g?.disconnect(),c!==null&&window.clearTimeout(c),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),X.delete(e)}}},Ot=e=>{const t=new Map,r=new Map,n=()=>{for(const[o,a]of Array.from(t.entries())){const i=se(o);(!e.contains(o)||i!==r.get(o))&&(a.cleanup(),t.delete(o),r.delete(o))}for(const o of Array.from(e.querySelectorAll(I))){if(t.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const a=Ft(o);a&&(t.set(o,a),r.set(o,se(o)),X.set(o,a))}},s=()=>{for(const o of t.values())o.cleanup();t.clear(),r.clear()};return n(),{refresh:n,cleanup:s}},x=e=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${e}"></use></svg>`,q={copy:x("file-copy"),check:x("check"),download:x("download"),zoomIn:x("add"),zoomOut:x("subtract"),fit:x("refresh")},Me="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",$=(e,t)=>{e.innerHTML=t},S=(e,t,r)=>{const n=document.createElement("button");return n.type="button",n.className=Me,n.setAttribute("data-md-action",r),n.setAttribute("title",t),n.setAttribute("aria-label",t),$(n,q[e]),n},Ne=e=>{const t=e.querySelector("[data-md-code-body]"),r=e.querySelector("pre"),n=e.querySelector("pre code"),s=e.querySelectorAll("[data-md-code-line-content]");e.setAttribute("data-code-wrap","true"),t?.classList.remove("overflow-x-auto"),t?.classList.add("overflow-x-hidden"),r?.classList.add("whitespace-pre-wrap","break-words"),n?.classList.add("whitespace-pre-wrap","break-words"),r&&(r.style.whiteSpace="pre-wrap",r.style.overflowWrap="anywhere"),n&&(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere");for(const o of Array.from(s))o.style.whiteSpace="pre-wrap",o.style.overflowWrap="anywhere"},xe=e=>{const t=e.querySelector(":scope > code");if(!t||t.hasAttribute("data-md-code-lines"))return;const r=t.textContent??"",n=r.endsWith(`
2
+ `),s=n?r.slice(0,-1).split(`
3
+ `):r.split(`
4
+ `),o=s.length>0?s:[""],a=Array.from(t.children).filter(d=>d.classList.contains("line"));n&&a.length===o.length+1&&a.at(-1)?.textContent===""&&a.pop();const i=a.length===o.length,c=document.createDocumentFragment();o.forEach((d,l)=>{const m=document.createElement("span");m.setAttribute("data-md-code-line","");const p=document.createElement("span");p.setAttribute("data-md-code-line-number",""),p.setAttribute("aria-hidden","true"),p.textContent=String(l+1);const f=document.createElement("span");if(f.setAttribute("data-md-code-line-content",""),i){const h=a[l];h&&f.append(...Array.from(h.childNodes))}else f.textContent=d;if(m.append(p,f),c.appendChild(m),l<o.length-1||n){const h=document.createElement("span");h.setAttribute("data-md-code-line-break",""),h.textContent=`
5
+ `,c.appendChild(h)}}),t.replaceChildren(c),t.setAttribute("data-md-code-lines",""),t.toggleAttribute("data-md-code-trailing-newline",n)},Te=e=>{const t=Array.from(e.querySelectorAll("[data-md-code-line-content]"));if(t.length===0)return e.textContent??"";const r=t.map(n=>n.textContent??"").join(`
6
+ `);return e.hasAttribute("data-md-code-trailing-newline")?`${r}
7
+ `:r},Dt=e=>{const t=e.querySelectorAll('[data-component="markdown-code"]');for(const r of Array.from(t)){const n=r.querySelector("pre");n&&xe(n),Ne(r)}},ce=(e,t,r,n)=>{$(e,q.check),e.setAttribute("title",t),e.setAttribute("aria-label",t),window.setTimeout(()=>{$(e,q[r]),e.setAttribute("title",n),e.setAttribute("aria-label",n)},2e3)},qt=e=>{const t=e.querySelectorAll(":not(pre) > code");for(const r of Array.from(t))r.getAttribute("data-markdown")!=="inline-code"&&r.setAttribute("data-markdown","inline-code")},$t=(e,t)=>{const r=e.querySelectorAll("pre");for(const n of Array.from(r)){if(n.querySelector("code.language-mermaid"))continue;const s=n.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=n.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],a=n.getAttribute("data-md-lang")??o??"text",i=document.createElement("div");i.setAttribute("data-component","markdown-code"),i.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const c=document.createElement("div");c.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const d=document.createElement("span");d.className="font-mono text-[13px] text-muted-foreground",d.textContent=a;const l=S("copy",t.labels.copy,"copy-code");c.appendChild(d);const m=document.createElement("div");m.className="flex items-center gap-1",m.setAttribute("data-md-code-actions",""),m.appendChild(l),c.appendChild(m);const p=document.createElement("div");p.setAttribute("data-md-code-body",""),p.className="px-3 py-2.5 overflow-x-auto",s.replaceChild(i,n),n.style.margin="0",n.style.background="transparent",n.classList.add("min-w-0","w-full","flex-1"),t.deferCodeLineNumberSync||xe(n),p.appendChild(n),i.appendChild(c),i.appendChild(p),Ne(i)}},le=e=>{const t=[],r=[],n=e.querySelectorAll("thead th");for(const o of Array.from(n))t.push((o.textContent??"").trim());const s=e.querySelectorAll("tbody tr");for(const o of Array.from(s)){const a=Array.from(o.querySelectorAll("td")).map(i=>(i.textContent??"").trim());a.length>0&&r.push(a)}return{headers:t,rows:r}},zt=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,de=({headers:e,rows:t})=>[e,...t].map(r=>r.map(zt).join(",")).join(`
8
+ `),Ht=({headers:e,rows:t})=>[e,...t].map(r=>r.join(" ")).join(`
9
+ `),ue=({headers:e,rows:t})=>{const r=`| ${e.join(" | ")} |`,n=`| ${e.map(()=>"---").join(" | ")} |`,s=t.map(o=>`| ${o.join(" | ")} |`).join(`
10
+ `);return`${r}
11
+ ${n}
12
+ ${s}`},me=(e,t)=>{const r=document.createElement("div");r.className=`absolute top-full right-0 mt-1 hidden ${et}`,r.style.backgroundColor="var(--surface-elevated)",r.style.color="var(--surface-elevated-foreground)",r.setAttribute("data-md-menu",e);for(const n of t){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${tt}`,s.setAttribute("data-md-action",`${e}-${n.key}`),s.textContent=n.label,r.appendChild(s)}return r},Wt=(e,t)=>{const r=e.querySelectorAll("table");for(const n of Array.from(r)){if(n.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const a=document.createElement("div");a.className="flex items-center justify-end gap-1";const i=document.createElement("div");i.className="relative",i.appendChild(S("copy",t.copyTable,"table-copy-toggle")),i.appendChild(me("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const c=document.createElement("div");c.className="relative",c.appendChild(S("download",t.downloadTable,"table-download-toggle")),c.appendChild(me("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),a.appendChild(i),a.appendChild(c);const d=document.createElement("div");d.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const l=n.parentElement;if(!l)continue;l.replaceChild(o,n),n.setAttribute("data-markdown","table"),n.classList.add("w-full","border-collapse","text-sm");for(const p of Array.from(n.querySelectorAll("tr")))p.classList.add("border-b","border-border/60");const m=n.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const p of Array.from(n.querySelectorAll("th")))p.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const p of Array.from(n.querySelectorAll("td")))p.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");d.appendChild(n),o.appendChild(a),o.appendChild(d)}},Bt=(e,t)=>{const r=e.querySelectorAll("pre > code.language-mermaid");for(const n of Array.from(r)){const s=n.parentElement;if(!s)continue;const o=(n.textContent??"").replace(/\s+$/,""),a=t.renderMermaid(o),i=document.createElement("div");i.setAttribute("data-markdown","mermaid-block"),i.setAttribute("data-md-source",o),i.className="group relative";const c=document.createElement("div");c.setAttribute("data-markdown","mermaid-scroll");const d=document.createElement("div");if(d.setAttribute("data-markdown","mermaid-toolbar"),d.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",a.svg){i.setAttribute("data-mermaid-render","svg");const m=document.createElement("div");m.setAttribute("data-markdown","mermaid-viewport");const p=document.createElement("div");if(p.setAttribute("data-markdown","mermaid"),p.setAttribute("data-md-original-svg",a.svg),p.innerHTML=a.svg,m.appendChild(p),c.appendChild(m),t.mermaidControls.showPanZoomControls&&(d.appendChild(S("zoomIn",t.labels.zoomInDiagram,"mermaid-zoom-in")),d.appendChild(S("zoomOut",t.labels.zoomOutDiagram,"mermaid-zoom-out")),d.appendChild(S("fit",t.labels.resetDiagramView,"mermaid-fit"))),t.mermaidControls.copy){const f=S("copy",t.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",o),d.appendChild(f)}if(t.mermaidControls.download){const f=S("download",t.labels.downloadDiagram,"mermaid-download");f.setAttribute("data-md-svg","1"),d.appendChild(f)}}else{i.setAttribute("data-mermaid-render","svg");const m=document.createElement("pre");if(m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=o,c.appendChild(m),t.mermaidControls.copy){const p=S("copy",t.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o),d.appendChild(p)}}i.appendChild(c),i.appendChild(d);const l=s.parentElement;l&&l.replaceChild(i,s)}},Vt=(e,t)=>{const r=e.querySelectorAll("a[href]");for(const n of Array.from(r)){if(n.getAttribute("data-md-link-decorated")==="true"||n.getAttribute("data-pichamber-file-link")==="true")continue;const s=n.getAttribute("href")??"";if(!Ae(s))continue;n.setAttribute("data-md-link-decorated","true");const o=Je(s);if(o){const a=document.createElement("span");a.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const i=document.createElement("img");i.src=o,i.alt="",i.setAttribute("aria-hidden","true"),i.loading="lazy",i.decoding="async",i.className="size-3.5 rounded-sm",i.addEventListener("error",()=>a.remove(),{once:!0}),a.appendChild(i),n.parentNode?.insertBefore(a,n)}if(t.onPreviewLoopback&&Qe(s)){const a=document.createElement("button");a.type="button",a.className=`ml-1 align-middle ${Me}`,a.setAttribute("data-md-action","preview-loopback"),a.setAttribute("data-md-url",s),a.setAttribute("title",t.labels.previewTitle),a.setAttribute("aria-label",t.labels.previewLabel),$(a,q.download),n.parentNode?.insertBefore(a,n.nextSibling)}}},pe=(e,t)=>{qt(e),Bt(e,t),$t(e,t),Wt(e,t.labels),Vt(e,t)},fe=(e,t,r)=>{const n=new Blob([t],{type:r}),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)},F=e=>{for(const t of Array.from(e.querySelectorAll("[data-md-menu]")))t.classList.add("hidden")},jt=(e,t)=>{const r=n=>{const s=n.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){F(e);return}const a=o.getAttribute("data-md-action")??"";if(a==="copy-code"){const i=o.closest('[data-component="markdown-code"]')?.querySelector("code"),c=i?Te(i):"";c&&W(c).then(()=>ce(o,t.labels.copied,"copy",t.labels.copy));return}if(a==="table-copy-toggle"||a==="table-download-toggle"){n.preventDefault();const i=o.parentElement?.querySelector("[data-md-menu]")??null,c=i?.classList.contains("hidden")??!1;F(e),i&&c&&i.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const i=a.replace("table-copy-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const d=le(c),l=i==="csv"?de(d):i==="tsv"?Ht(d):ue(d);W(l)}F(e);return}if(a.startsWith("table-download-")){const i=a.replace("table-download-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const d=le(c),l=i==="csv"?de(d):ue(d);fe(i==="csv"?"table.csv":"table.md",l,i==="csv"?"text/csv":"text/markdown")}F(e);return}if(a==="mermaid-copy"){const i=o.getAttribute("data-md-source")??"";i&&W(i).then(()=>ce(o,t.labels.copied,"copy",t.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){n.preventDefault();const i=o.closest('[data-markdown="mermaid-block"]'),c=Pt(i);a==="mermaid-zoom-in"?c?.zoomIn():a==="mermaid-zoom-out"?c?.zoomOut():c?.fit();return}if(a==="mermaid-download"){const i=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),c=i?.getAttribute("data-md-original-svg")??i?.innerHTML??"";c&&fe("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){n.preventDefault();const i=o.getAttribute("data-md-url")??"";i&&t.onPreviewLoopback?.(i);return}};return e.addEventListener("click",r),()=>e.removeEventListener("click",r)},he=(e,t,r)=>{let n=0;for(const o of e){const a=n+o.data.length;if(t<a||t===a&&r==="left")return{node:o,offset:Math.max(0,t-n)};n=a}const s=e.at(-1);return s?{node:s,offset:s.data.length}:null},Kt=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),be=Array.from(Kt).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Ut=e=>rt(e),Zt=e=>nt(e),z=e=>{let t=(e||"").trim();return t?((t.startsWith("`")&&t.endsWith("`")||t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).trim()),t=t.replace(/[.,;!?]+$/g,""),t.endsWith(")")&&!t.includes("(")&&(t=t.slice(0,-1)),t.endsWith("]")&&!t.includes("[")&&(t=t.slice(0,-1)),t):""},O=e=>{let t=z(e);if(!t)return"";const r=t.indexOf(";");r>=0&&(t=t.slice(0,r)),t=t.replace(/#.*$/,"");const n=t.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);n&&(t=n[1]??t);const s=be.length>0?t.match(new RegExp(`^(.*(?:/|^)(${be})):.*$`,"i")):null;return s&&(t=s[1]??t),z(t)},Pe=e=>{const t=z(e);if(!t)return null;const r=t.indexOf(";"),n=r>=0?z(t.slice(0,r)):t;if(!n)return null;const s=n.match(/^(.*?):(\d+)-(\d+)$/);if(s){const c=O(s[1]??""),d=Number.parseInt(s[2]??"",10),l=Number.parseInt(s[3]??"",10);return!c||!Number.isFinite(d)||!Number.isFinite(l)||l<d?null:{path:c,line:d,endLine:l}}const o=n.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const c=O(o[1]??""),d=Number.parseInt(o[2]??"",10),l=o[3]?Number.parseInt(o[3],10):void 0;return!c||!Number.isFinite(d)?null:{path:c,line:d,column:Number.isFinite(l??Number.NaN)?l:void 0}}const a=n.match(/^(.*?):(\d+)(?::(\d+))?$/);if(a){const c=O(a[1]??""),d=Number.parseInt(a[2]??"",10),l=a[3]?Number.parseInt(a[3],10):void 0;return!c||!Number.isFinite(d)?null:{path:c,line:d,column:Number.isFinite(l??Number.NaN)?l:void 0}}const i=O(n);return i?{path:i}:null},V=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Re=({containerRef:e,enabled:t})=>{y.useEffect(()=>{if(t===!1)return;const r=e.current;if(!r)return;const n=s=>{if(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey)return;const o=s.target;if(!(o instanceof Element))return;const a=o.closest("a[href]");if(!(a instanceof HTMLAnchorElement)||a.getAttribute("data-pichamber-file-link")==="true")return;const i=a.getAttribute("href")??"";Ae(i)&&(s.preventDefault(),s.stopPropagation(),ot(i))};return r.addEventListener("click",n),()=>{r.removeEventListener("click",n)}},[e,t])},ge='[data-pichamber-file-link="true"]',_e="data-pichamber-block-path-token",Ie=`[${_e}]`,T="data-pichamber-block-paths-scanned",Xt=2e5,Gt=4,Yt=1e3,Jt=80,we=160,M=new Map;let D=0;const ye=[],Qt=()=>Yt,en=()=>Jt,tn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),G=e=>Ut(e),nn=e=>Zt(e),rn=(e,t)=>st(e,t),on=e=>{const t=e.split("/").filter(Boolean).pop()??"";return!t||t.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(t)},Fe=e=>{if(!e||e.startsWith("--")||e.includes("://")||/[<>]/.test(e)||/\s{2,}/.test(e))return!1;const t=G(e),r=t.split("/").filter(Boolean).pop()??t;if(!r||r==="."||r==="..")return!1;const n=r.toLowerCase();return tn.has(n)||n.startsWith(".")&&n.length>1?!0:on(t)},Oe=e=>{const t=Pe(e);return t?Fe(t.path):!1},an=e=>{const t=e.querySelectorAll(Ie);for(const n of Array.from(t))n.replaceWith(e.ownerDocument.createTextNode(n.textContent??""));const r=e.querySelectorAll(`code[${T}]`);for(const n of Array.from(r))n.removeAttribute(T),n.normalize()},j=e=>{if(e.tagName.toLowerCase()==="a"){const t=e.getAttribute("href")?.trim();if(t&&Oe(t))return t}return(e.textContent||"").trim()},sn=e=>{const t=e.querySelectorAll("pre code");if(t.length===0)return;const r=e.ownerDocument;if(r)for(const n of Array.from(t)){if(n.getAttribute(T)==="true")continue;if((n.textContent??"").length>Xt){n.setAttribute(T,"true");continue}const s=r.createTreeWalker(n,NodeFilter.SHOW_TEXT),o=[];let a=s.nextNode();for(;a;){const l=a;l.parentElement?.closest("[data-md-code-line-number]")||o.push(l),a=s.nextNode()}const i=Te(n);if(!i.includes(".")){n.setAttribute(T,"true");continue}V.lastIndex=0;const c=[];let d=V.exec(i);for(;d;){const l=d[0];l&&Oe(l)&&c.push({start:d.index,end:d.index+l.length,raw:l}),d=V.exec(i)}for(const{start:l,end:m,raw:p}of c.reverse()){const f=he(o,l,"right"),h=he(o,m,"left");if(!f||!h)continue;const v=r.createRange();v.setStart(f.node,f.offset),v.setEnd(h.node,h.offset);const A=r.createElement("span");A.setAttribute(_e,"true"),A.textContent=p,v.deleteContents(),v.insertNode(A)}n.setAttribute(T,"true")}},K=(e,t)=>{const r=Pe(e);if(!r||!Fe(r.path))return null;const n=nn(r.path)?G(r.path):rn(t,r.path);return n?{...r,resolvedPath:n}:null},cn=e=>{const t=G(e);if(!t)return Promise.resolve(!1);const r=M.get(t);if(r)return M.delete(t),M.set(t,r),r;const n=new Promise(o=>{const a=()=>{D+=1,Ge(`/api/fs/stat?path=${encodeURIComponent(t)}&optional=true`,{method:"GET",cache:"no-store"}).then(async i=>{if(!i.ok){o(!1);return}const c=await i.json().catch(()=>null);o(c?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{D=Math.max(0,D-1),ye.shift()?.()})};if(D<Gt){a();return}ye.push(a)}),s=Qt();for(;M.size>=s;){const o=M.keys().next().value;if(typeof o!="string")break;M.delete(o)}return M.set(t,n),n},ln=(e,t)=>e||it(e,t),De=({containerRef:e,effectiveDirectory:t,editor:r,preferRuntimeEditor:n,enabled:s})=>{const o=y.useRef(null);y.useEffect(()=>{const a=e.current;if(!a)return;let i=!1;const c=en(),d=s&&!bt(),l=b=>{b.removeAttribute("data-pichamber-file-link"),b.removeAttribute("data-pichamber-file-ref"),b.removeAttribute("data-pichamber-file-path"),b.getAttribute("title")==="Open file"&&b.removeAttribute("title"),b.tagName.toLowerCase()!=="a"&&(b.removeAttribute("role"),b.removeAttribute("tabindex"))},m=()=>{const b=a.querySelectorAll(ge);for(const g of Array.from(b))l(g);an(a)};if(!d){m();return}const p=(b=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){f();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{i||f()})},b)},f=()=>{d&&sn(a);const b=a.querySelectorAll(`[data-markdown="inline-code"], a, ${Ie}`);let g=0;for(const u of Array.from(b)){const E=j(u),C=K(E,t);if(l(u),!C||g>=c)continue;g+=1,(Ze()&&Xe()&&!ne(C.resolvedPath,t)?Promise.resolve(!0):cn(C.resolvedPath)).then(je=>{if(i||!je||!a.contains(u))return;const Q=j(u),H=K(Q,t);!H||H.resolvedPath!==C.resolvedPath||(u.setAttribute("data-pichamber-file-link","true"),u.setAttribute("data-pichamber-file-ref",Q),u.setAttribute("data-pichamber-file-path",H.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},h=async b=>{const g=b.getAttribute("data-pichamber-file-ref")||j(b),u=K(g,t);if(!u)return;const E=ln(t,u.resolvedPath);ne(u.resolvedPath,t)||await at(u.resolvedPath,t);const C=ve.getState();Number.isFinite(u.line??Number.NaN)?C.openContextFileAtLine(E,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):C.openContextFile(E,u.resolvedPath)},v=b=>{const g=b.target;if(!(g instanceof Element))return;const u=g.closest(ge);u instanceof HTMLElement&&(b.preventDefault(),b.stopPropagation(),h(u))},A=b=>{if(b.key!=="Enter"&&b.key!==" ")return;const g=b.target;!(g instanceof HTMLElement)||g.getAttribute("data-pichamber-file-link")!=="true"||(b.preventDefault(),b.stopPropagation(),h(g))};p(we);const w=new MutationObserver(()=>{p(we)});return w.observe(a,{childList:!0,subtree:!0}),a.addEventListener("click",v),a.addEventListener("keydown",A),()=>{i=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,w.disconnect(),a.removeEventListener("click",v),a.removeEventListener("keydown",A)}},[e,r,t,n,s])},P={download:!0,copy:!0,showPanZoomControls:!0},qe=!0,$e=({containerRef:e,onShowPopup:t,enableFullscreen:r,enablePanZoom:n,allowMermaidWheelEvents:s})=>{y.useEffect(()=>{const o=e.current;if(!o)return;const a=c=>{if(!t)return;const d=c.target;if(!(d instanceof Element)||d.closest('button, a, [role="button"]'))return;const l=d.closest(I);if(!l)return;if(l instanceof HTMLElement&&l.hasAttribute("data-mermaid-suppress-click")){l.removeAttribute("data-mermaid-suppress-click");return}const p=Array.from(o.querySelectorAll(I)).indexOf(l);if(p<0)return;const f=l instanceof HTMLElement?l.getAttribute("data-md-source"):null;if(!f||f.trim().length===0)return;const h=`Diagram ${p+1}`;t({open:!0,title:h,content:"",metadata:{tool:"mermaid-preview",filename:h},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(f)}`,source:f,filename:h}})},i=c=>{if(s||(c.ctrlKey||c.metaKey)&&n)return;const d=c.target;!(d instanceof Element)||!d.closest(I)||c.stopPropagation()};return o.addEventListener("click",a),o.addEventListener("wheel",i,{capture:!0,passive:!0}),()=>{o.removeEventListener("click",a),o.removeEventListener("wheel",i,!0)}},[s,e,r,n,t])},N=new Map,dn=100,un=(e,t)=>{const r=N.get(e);if(r)return N.delete(e),N.set(e,r),r;const n=t();if(N.set(e,n),N.size>dn){const s=N.keys().next().value;s&&N.delete(s)}return n},mn=e=>({bg:e.colors.surface.elevated,fg:e.colors.surface.foreground,line:e.colors.interactive.border,accent:e.colors.primary.base,muted:e.colors.surface.mutedForeground,surface:e.colors.surface.muted,border:e.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),ze=()=>{const e=lt(),t=te(!1),r=te(!0);return e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?r:t)},pn=e=>{const t=e.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return t?e.slice(t[0].length):e},He=(e,t,r,n=P)=>{const s=y.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:"Copy table",downloadTable:"Download table",copyDiagram:"Copy source",downloadDiagram:"Download SVG",zoomInDiagram:"Zoom in",zoomOutDiagram:"Zoom out",resetDiagramView:"Reset view",previewLabel:"Preview",previewTitle:"Open preview pane"}),[]);return y.useMemo(()=>{const o=mn(e),a=e.metadata?.id??"theme";return{labels:s,mermaidControls:n,deferCodeLineNumberSync:t,renderMermaid:c=>un(`${a}:svg:${c}`,()=>{try{return{svg:Ue(c,o)}}catch{return{}}}),onPreviewLoopback:r}},[e,s,n,t,r])},We=e=>{e.style.display="contents",e.style.width="",e.style.minWidth="",e.style.maxWidth=""},U=(e,t)=>{We(e);const r=ft(t);let n=e.querySelector(":scope > [data-md-live]");const s=n?.hasAttribute("data-md-live-pre")===!0;(!n||s!==r)&&(e.replaceChildren(),n=document.createElement(r?"div":"p"),n.setAttribute("data-md-live",""),r&&n.setAttribute("data-md-live-pre",""),n.className=r?"w-full min-w-0 whitespace-pre-wrap break-words":"w-full min-w-0 break-words",n.appendChild(document.createTextNode("")),e.appendChild(n));const o=n.firstChild;if(!(o instanceof globalThis.Text)){n.replaceChildren(document.createTextNode(t));return}if(t.startsWith(o.data)){const a=t.slice(o.data.length);a.length>0&&o.appendData(a);return}o.data=t},Be=({containerRef:e,text:t,streaming:r,cacheKey:n,syntaxVars:s,ctx:o})=>{y.useEffect(()=>{wt()},[]);const a=y.useRef(null),i=y.useRef(null),c=y.useRef(n);c.current!==n&&(c.current=n,i.current=null);const d=y.useCallback(()=>{const l=e.current;if(l){if(!a.current){if(!L(l))return;a.current=Ot(l);return}a.current.refresh()}},[e]);y.useLayoutEffect(()=>{const l=e.current,m=l?.querySelector("[data-markdown-content]")??l;if(m&&t&&m.childNodes.length===0){const p=document.createElement("div");if(p.setAttribute("data-md-block",""),p.style.display="contents",r){U(p,t),m.appendChild(p);return}p.innerHTML=dt(t),pe(p,o),m.appendChild(p),L(p)&&d()}},[e,t,r,o,d]),y.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),y.useEffect(()=>{const l=e.current;if(!l)return;const m=l.querySelector("[data-markdown-content]")??l;let p=!0;if(r&&i.current){const f=ut(n).update(t);if(mt(i.current,f)){const h=f[f.length-1],v=m.querySelectorAll(":scope > [data-md-block]")[f.length-1];if(h&&v){U(v,h.raw),v.setAttribute("data-md-id",`live:${f.length-1}`),i.current=i.current.map((A,w)=>w===f.length-1?{...A,raw:h.raw,id:`live:${w}`,mode:"live"}:A);return}}}return pt(t,r,n).then(f=>{if(!p)return;const h=Array.from(m.querySelectorAll(":scope > [data-md-block]"));f.forEach((w,b)=>{let g=h[b];if(g||(g=document.createElement("div"),g.setAttribute("data-md-block",""),g.style.display="contents",m.appendChild(g)),w.mode==="live"){U(g,w.raw),g.setAttribute("data-md-id",w.id);return}if(We(g),g.getAttribute("data-md-id")===w.id)return;const u=document.createElement("div");u.innerHTML=w.html,pe(u,o);const E=L(g),C=L(u);Ke(g,u,{childrenOnly:!0,onBeforeElUpdated:(Y,J)=>!Y.isEqualNode(J)}),g.setAttribute("data-md-id",w.id),(E||C||L(g))&&d()});const v=L(m);let A=!1;for(let w=h.length-1;w>=f.length;w-=1){const b=h[w];b&&L(b)&&(A=!0),b?.remove()}(A||h.length>f.length&&v)&&d(),i.current=f}),()=>{p=!1}},[e,t,r,n,o,d]),y.useEffect(()=>{const l=e.current;if(l)return jt(l,o)},[e,o]),y.useEffect(()=>{const l=e.current,m=l?.querySelector("[data-markdown-content]")??l;if(m)for(const[p,f]of Object.entries(s))m.style.setProperty(p,f)},[e,s]),y.useEffect(()=>{const l=e.current,m=l?.querySelector("[data-markdown-content]")??l;m&&(o.deferCodeLineNumberSync||Dt(m))},[e,o.deferCodeLineNumberSync])},Ve=(e,t)=>Z("w-full min-w-0",e==="tool"?"markdown-content markdown-tool":e==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",t&&"markdown-streaming"),fn=({content:e,part:t,messageId:r,isAnimated:n=!0,skipFadeIn:s=!1,className:o,isStreaming:a=!1,disableStreamAnimation:i=!1,variant:c="assistant",onShowPopup:d,enableFileReferences:l=!0})=>{ee("ui.markdown_renderer.render"),a&&ee("ui.markdown_renderer.render.streaming"),Ye("ui.markdown_renderer.content_len",e.length);const m=ze(),{editor:p}=ke(),f=y.useRef(null),h=Ee()??"",v=ve(C=>C.openContextPreview),A=y.useCallback(C=>{h&&v(h,C)},[h,v]),w=a&&!i;$e({containerRef:f,onShowPopup:d,enableFullscreen:qe,enablePanZoom:P.showPanZoomControls}),De({containerRef:f,effectiveDirectory:h,editor:p,preferRuntimeEditor:!1,enabled:l&&!a}),Re({containerRef:f});const b=y.useMemo(()=>Ce(m),[m]),g=He(m,w,h?A:void 0,P),u=`markdown-${t?.id?`part-${t.id}`:`message-${r}`}`;Be({containerRef:f,text:e,streaming:w,cacheKey:u,syntaxVars:b,ctx:g});const E=_.jsx("div",{className:Z("break-words w-full min-w-0",o),ref:f,children:_.jsx("div",{className:Ve(c,w),"data-markdown-content":!0})});return n?_.jsx(ct,{skipAnimation:s,children:E},u):E},Yn=y.memo(fn,(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id),hn=({content:e,className:t,variant:r="assistant",disableLinkSafety:n,stripFrontmatter:s=!1,onShowPopup:o,mermaidControls:a=P,allowMermaidWheelEvents:i=!1,enableFileReferences:c=!0})=>{const{editor:d}=ke(),l=ze(),m=y.useRef(null),p=Ee()??"",f=y.useMemo(()=>s?pn(e):e,[e,s]);$e({containerRef:m,onShowPopup:o,enableFullscreen:qe,enablePanZoom:a.showPanZoomControls,allowMermaidWheelEvents:i}),De({containerRef:m,effectiveDirectory:p,editor:d,preferRuntimeEditor:!1,enabled:c}),Re({containerRef:m,enabled:!n});const h=y.useMemo(()=>Ce(l),[l]),v=He(l,!1,void 0,a);return Be({containerRef:m,text:f,streaming:!1,cacheKey:`simple:${r}`,syntaxVars:h,ctx:v}),_.jsx("div",{className:Z("break-words w-full min-w-0",t),ref:m,children:_.jsx("div",{className:Ve(r),"data-markdown-content":!0})})},Jn=y.memo(hn,(e,t)=>{const r=e.mermaidControls??P,n=t.mermaidControls??P;return e.content===t.content&&e.variant===t.variant&&e.className===t.className&&e.disableLinkSafety===t.disableLinkSafety&&e.stripFrontmatter===t.stripFrontmatter&&e.onShowPopup===t.onShowPopup&&r.download===n.download&&r.copy===n.copy&&r.showPanZoomControls===n.showPanZoomControls&&e.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});export{Yn as MarkdownRenderer,Jn as SimpleMarkdownRenderer};
@@ -0,0 +1 @@
1
+ import{dL as j,dk as k,dp as y}from"./useAppFontEffects--lKKtKVo.js";import{f as D,B as C}from"./web-components-v9fuidaX.js";import{M as P,G as L,u as O,W as A,a as M,b as R,n as F,t as H}from"./Virtualizer-wpC51ZBQ.js";import{j as d}from"./vendor-boot-DyL2td56.js";import{V as _,F as N}from"./VirtualizedFileDiff-CUWx7JVZ.js";import{a as w}from"./vendor-react-DASdDPIk.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const s=e.hunkContent[l];n+=s.type==="context"?s.lines:s.deletions+s.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:s,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:o,lineAnnotations:a,getHoveredLine:g,getInstance:m}){const p=n?.(e),c=l?.(e),i=s?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[p!=null?d.jsx("div",{slot:k,children:p}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:D(r),children:f(r)},h)),t!=null&&o!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:o(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:L,children:u(g)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:s,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:o,contentEditable:a}){const g=O(),m=l!==void 0,p=w.useContext(A),c=M(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");g!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),g,x,o?void 0:p,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),o?void 0:p,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:s})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:s,hasGutterRenderUtility:x}){const f=n&&s,u=t||x||l;if(!u&&!f)return e;let o={...e};return u&&(o={...o,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(o={...o,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),o}function Y({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:s,className:x,style:f,prerenderedHTML:u,renderAnnotation:o,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:s,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(y,{ref:h,className:x,style:f,children:H($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderAnnotation:o,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{Y as P};
@@ -0,0 +1,134 @@
1
+ import{aJ as Re,j as M}from"./vendor-boot-DyL2td56.js";import{a as d,R as ae}from"./vendor-react-DASdDPIk.js";import{B as Se}from"./web-components-v9fuidaX.js";import{f as ce}from"./computeVirtualFileMetrics-3PpRLd5B.js";import{V as Ee,F as ke}from"./VirtualizedFileDiff-CUWx7JVZ.js";import{aX as xe,aj as Te}from"./useAppFontEffects--lKKtKVo.js";import{a$ as Oe}from"./runtimeEndpointReset-CmI6dBKM.js";import{ensurePierreThemeRegistered as ue,getResolvedShikiTheme as he}from"./appThemeRegistry-gegrE2dq.js";import{_ as de,o as fe}from"./index-Dd2OcIUY.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(ve)}function ve(n){const e=new Set(J);J.clear();for(const t of e)try{t(n)}catch(r){console.error(r)}J.size>0?ne=requestAnimationFrame(ve):ne=null}function ge({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const h=t+s*2,f=r?t+i*2:h;if(e=Math.max(e,f),h>=e||r){const g=Math.max(n-i,0),y=Math.min(n+f,e);return{top:g,bottom:Math.max(y,g)}}let c=n+t/2-h/2,m=c+h;return c<0&&(c=0),m>e&&(m=e),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(m,e),c))}}function ze(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const be=1e3,De=be*4,Ce=[0,1e-6,.99999,1],Ie={overscrollSize:be,intersectionObserverMargin:De,resizeDebugging:!1};let X=0,Me=-1;var He=class x{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Me}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...Ie,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:Ce,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{x.__STOP?(x.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:x.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(x.__lastScrollPosition=this.getScrollTop(),x.__STOP=!0)};for(const[r,i]of this.connectQueue.entries())this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const r=this.getScrollTop(),i=this.getHeight(),s=this.config.intersectionObserverMargin,h=r-s,f=r+i+s;return!(e<h-t||e>f)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const r of e){const i=r.borderBoxSize[0].blockSize;this.root instanceof Document?i!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:i-X,newSize:i}),X=i)):r.target===this.root?i!==this.height&&(this.heightDirty=!0,t=!0):r.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:i-X,newSize:i}),X=i))}t&&E(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+U(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),E(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{x.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{x.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{x.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(x.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const s=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&ze(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const r=this.getScrollAnchor(this.height),i=new Set;for(const s of e?this.observers.values():this.visibleInstances.values())s.onRender(e)&&i.add(s);for(const s of this.instancesChanged)i.has(s)||s.onRender(e)&&i.add(s);this.scrollFix(r);for(const s of i)s.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&E(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:r,lineOffset:i,fileElement:s,fileOffset:h,fileTypeOffset:f}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const g=U(m,t);if(g!==i){const y=g-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(f==="top")c!==h&&this.applyScrollFix(c-h);else{const m=c+s.getBoundingClientRect().height;m!==h&&this.applyScrollFix(m-h)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let r;for(const[i]of this.visibleInstances.entries()){const s=U(i,t),h=s+i.offsetHeight;let f,c;h<=0?(f=h,c="bottom"):(f=s,c="top");let m,g;if(h>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const q=w.dataset.lineIndex;if(q==null)continue;const z=U(w,t);if(!(z<0)){m=q,g=z;break}}if(r?.lineOffset!=null&&g==null)continue;let y=!1;(r==null||g!=null&&(r.lineOffset==null||g<r.lineOffset)||g==null&&r.lineOffset==null&&(f>=0&&(r.fileOffset<0||f<r.fileOffset)||f<0&&r.fileOffset<0&&f>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:f,lineIndex:m,lineOffset:g})}return r}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:r}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const i=this.observers.get(t);i!=null&&(r&&!this.visibleInstances.has(t)?(i.setVisibility(!0),this.visibleInstances.set(t,i),this.visibleInstancesDirty=!0):!r&&this.visibleInstances.has(t)&&(i.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&E(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function U(n,e){const t=n.getBoundingClientRect(),r=e?.getBoundingClientRect().top??0;return t.top-r}const pe=5e5,Pe=`
2
+ :host {
3
+ font-family: var(--font-mono);
4
+ font-size: var(--text-code);
5
+ }
6
+
7
+ pre, [data-code] {
8
+ font-family: var(--font-mono);
9
+ font-size: var(--text-code);
10
+ }
11
+
12
+ /* Mobile touch selection support */
13
+ [data-line-number] {
14
+ touch-action: manipulation;
15
+ -webkit-tap-highlight-color: transparent;
16
+ cursor: pointer;
17
+ }
18
+
19
+ /* Ensure interactive line numbers work on touch */
20
+ pre[data-interactive-line-numbers] [data-line-number] {
21
+ touch-action: manipulation;
22
+ }
23
+ `,Le=`
24
+ ${Pe}
25
+
26
+ :host {
27
+ --diffs-bg-separator-override: var(--surface-elevated);
28
+ }
29
+
30
+ [data-diff-header],
31
+ [data-diff] {
32
+ [data-separator] {
33
+ height: 24px !important;
34
+ }
35
+ }
36
+
37
+ [data-separator="line-info-basic"] {
38
+ height: 24px !important;
39
+ background: var(--diffs-bg) !important;
40
+ position: relative;
41
+ }
42
+
43
+ [data-diff-type="single"] [data-gutter],
44
+ [data-diff-type="split"] [data-deletions] [data-gutter] {
45
+ [data-separator-wrapper] {
46
+ position: absolute;
47
+ left: 100%;
48
+ display: flex;
49
+ align-items: center;
50
+ gap: unset;
51
+ width: max-content;
52
+ background: transparent;
53
+ color: var(--diffs-fg-number);
54
+ font-family: var(--diffs-header-font-family, var(--font-sans));
55
+ font-size: 0.75rem;
56
+ line-height: 1;
57
+ margin-left: calc(-2ch - 2px);
58
+ }
59
+
60
+ [data-separator-wrapper][data-separator-multi-button] {
61
+ margin-left: calc(-3ch - 2px);
62
+ }
63
+
64
+ [data-expand-button],
65
+ [data-separator-content] {
66
+ display: block;
67
+ align-self: unset;
68
+ min-width: unset;
69
+ min-height: unset;
70
+ padding: 0;
71
+ flex-shrink: 0;
72
+ grid-column: unset;
73
+ border: none;
74
+ width: auto;
75
+ height: auto;
76
+ background-color: transparent;
77
+ color: inherit;
78
+ font: inherit;
79
+ }
80
+
81
+ [data-expand-button]:not([data-expand-all-button]) {
82
+ &[data-expand-down]::before {
83
+ content: '\\2191';
84
+ }
85
+
86
+ &[data-expand-up]::before {
87
+ content: '\\2193';
88
+ }
89
+
90
+ &[data-expand-both]::before {
91
+ content: '\\2195';
92
+ }
93
+
94
+ svg {
95
+ display: none;
96
+ }
97
+ }
98
+
99
+ [data-separator-content] {
100
+ background: transparent;
101
+ margin-left: calc(2px + 1ch);
102
+ }
103
+
104
+ [data-expand-all-button] {
105
+ position: relative;
106
+ margin-left: 14px;
107
+ text-transform: lowercase;
108
+ }
109
+
110
+ [data-expand-all-button]::before {
111
+ content: '';
112
+ display: block;
113
+ position: absolute;
114
+ top: 50%;
115
+ left: -8px;
116
+ margin-top: -1px;
117
+ width: 3px;
118
+ height: 3px;
119
+ border-radius: 2px;
120
+ background-color: var(--diffs-fg-number);
121
+ pointer-events: none;
122
+ }
123
+
124
+ [data-separator-content]:hover,
125
+ [data-expand-button]:hover,
126
+ [data-expand-all-button]:hover {
127
+ color: var(--diffs-fg);
128
+ }
129
+
130
+ [data-expand-all-button]:hover {
131
+ text-decoration: underline;
132
+ }
133
+ }
134
+ `;function _e(n){let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function me(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${_e(e)}`}const Fe=n=>n==="auto"||n==="scroll"||n==="overlay",Ae=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Fe(t.overflowY))return e;e=e.parentElement}return null},Ve=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=Ae(n);if(!t)return()=>{};const r=e.getBoundingClientRect().height;if(!r)return()=>{};const i=n.getBoundingClientRect().top-t.getBoundingClientRect().top,s=e.style.minHeight;e.style.minHeight=`${Math.ceil(r)}px`;let h=!1;return()=>{if(h)return;h=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},$e=(n,e)=>{if(typeof window>"u")return()=>{};let t=null,r=null,i=!1;const s=()=>{i||(r?.disconnect(),r=null,t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>{i||e()})}))},h=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,f=(c=h())=>!!c?.querySelector("[data-line]");return f()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=h();if(c){if(f(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{f(c)&&s()}),r.observe(c,{childList:!0,subtree:!0})}}),r.observe(n,{childList:!0,subtree:!0})):t=window.requestAnimationFrame(s),()=>{i=!0,r?.disconnect(),t!==null&&window.cancelAnimationFrame(t)}},Z=new WeakMap,qe={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function We(n){const e=n.closest("[data-diff-virtual-root]");if(e instanceof HTMLElement){const t=e.querySelector("[data-diff-virtual-content]");return{key:e,root:e,content:t instanceof HTMLElement?t:void 0}}return{key:document,root:document,content:void 0}}function Be(n){if(typeof document>"u")return null;const e=We(n);let t=Z.get(e.key);if(!t){const i=new He;i.setup(e.root,e.content),t={virtualizer:i,refs:0},Z.set(e.key,t)}t.refs+=1;let r=!1;return{virtualizer:t.virtualizer,root:e.root,release:()=>{if(r)return;r=!0;const i=Z.get(e.key);i&&(i.refs-=1,!(i.refs>0)&&(i.virtualizer.cleanUp(),Z.delete(e.key)))}}}const Ne=(n,e,t)=>{if(typeof window>"u")return()=>{};const r=[],i=()=>{try{n.rerender()}catch{}const s=e?.root;s instanceof HTMLElement?s.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),t()};return r.push(window.requestAnimationFrame(i)),r.push(window.requestAnimationFrame(()=>{r.push(window.requestAnimationFrame(i))})),()=>{for(const s of r)window.cancelAnimationFrame(s)}},tt=({original:n,modified:e,fileDiff:t,language:r,fileName:i,renderSideBySide:s,wrapLines:h,layout:f="fill",enableGutterUtility:c=!1,enableLineSelection:m=!1,onGutterUtilityClick:g,onLineSelectionEnd:y,lineAnnotations:w,renderAnnotation:q})=>{const z=xe(),D=z?.currentTheme.metadata.variant==="dark",_=z?.availableThemes.find(o=>o.metadata.id===z.lightThemeId)??de(!1),F=z?.availableThemes.find(o=>o.metadata.id===z.darkThemeId)??de(!0);ue(_),ue(F);const W=`${_.metadata.id}:${F.metadata.id}:${D?"dark":"light"}`,B=d.useMemo(()=>{if(t){const o=t.deletionLines.reduce((a,u)=>a+u.length,0),l=t.additionLines.reduce((a,u)=>a+u.length,0);return Math.max(o,l)>pe}return Math.max(n.length,e.length)>pe},[t,e.length,n.length]),Q=d.useRef(null),N=d.useRef(null),A=d.useRef(null),j=d.useRef(null),ee=d.useRef(null),te=d.useRef(null),re=d.useRef(void 0),K=d.useRef(void 0),G=d.useRef(void 0),Y=d.useRef(void 0),[,se]=ae.useReducer(o=>o+1,0),V=Oe(B?"unified":s?"split":"unified"),C=d.useRef(new Map),ie=d.useRef(q);ie.current=q;const oe=o=>`${o.side}:${o.lineNumber}`,le=d.useCallback(o=>{if(typeof document>"u")return;const l=`${o.side}:${o.lineNumber}`;let a=C.current.get(l);if(!a){const u=document.createElement("div");u.setAttribute("data-pichamber-line-annotation",l),a={root:Re.createRoot(u),element:u},C.current.set(l,a)}return a.root.render(ie.current?.(o)??null),a.element},[]);d.useEffect(()=>{if(!w){for(const[,a]of C.current)a.root.unmount();C.current.clear();return}const o=new Set(w.map(oe));for(const[a,u]of C.current)o.has(a)||(u.root.unmount(),C.current.delete(a));const l=ie.current;if(l)for(const a of w){const u=C.current.get(oe(a));u&&u.root.render(l(a))}},[w]),d.useEffect(()=>{const o=C.current;return()=>{for(const l of o.values())l.root.unmount();o.clear()}},[]);const T=d.useMemo(()=>he(_),[_]),O=d.useMemo(()=>he(F),[F]);ae.useLayoutEffect(()=>{const o=Q.current;if(!o)return;const l=o.querySelector("diffs-container");if(!l)return;const a=D?O:T,u=(ye,we)=>ye.colors?.[we],R=u(T,"terminal.ansiGreen"),v=u(T,"terminal.ansiRed"),b=u(T,"terminal.ansiBlue"),P=u(O,"terminal.ansiGreen"),k=u(O,"terminal.ansiRed"),I=u(O,"terminal.ansiBlue");l.style.setProperty("--shiki-light",T.fg),l.style.setProperty("--shiki-light-bg",T.bg),R&&l.style.setProperty("--shiki-light-addition-color",R),v&&l.style.setProperty("--shiki-light-deletion-color",v),b&&l.style.setProperty("--shiki-light-modified-color",b),l.style.setProperty("--shiki-dark",O.fg),l.style.setProperty("--shiki-dark-bg",O.bg),P&&l.style.setProperty("--shiki-dark-addition-color",P),k&&l.style.setProperty("--shiki-dark-deletion-color",k),I&&l.style.setProperty("--shiki-dark-modified-color",I),l.style.setProperty("--diffs-bg",a.bg),l.style.setProperty("--diffs-fg",a.fg);const S=D?P:R,L=D?k:v,$=D?I:b;S&&l.style.setProperty("--diffs-addition-color-override",S),L&&l.style.setProperty("--diffs-deletion-color-override",L),$&&l.style.setProperty("--diffs-modified-color-override",$);const p=l.shadowRoot?.querySelector("pre");p&&(p.style.setProperty("--shiki-light",T.fg),p.style.setProperty("--shiki-light-bg",T.bg),R&&p.style.setProperty("--shiki-light-addition-color",R),v&&p.style.setProperty("--shiki-light-deletion-color",v),b&&p.style.setProperty("--shiki-light-modified-color",b),p.style.setProperty("--shiki-dark",O.fg),p.style.setProperty("--shiki-dark-bg",O.bg),P&&p.style.setProperty("--shiki-dark-addition-color",P),k&&p.style.setProperty("--shiki-dark-deletion-color",k),I&&p.style.setProperty("--shiki-dark-modified-color",I),p.style.setProperty("--diffs-bg",a.bg),p.style.setProperty("--diffs-fg",a.fg),S&&p.style.setProperty("--diffs-addition-color-override",S),L&&p.style.setProperty("--diffs-deletion-color-override",L),$&&p.style.setProperty("--diffs-modified-color-override",$))},[O,W,D,T]);const H=d.useMemo(()=>({theme:{dark:F.metadata.id,light:_.metadata.id},themeType:D?"dark":"light",diffStyle:s?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:B?0:1e3,maxLineLengthForHighlighting:B?1:1e3,tokenizeMaxLineLength:B?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:h?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:m,enableGutterUtility:c,enableHoverUtility:!1,...g?{onGutterUtilityClick:g}:{},...y?{onLineSelectionEnd:y}:{},renderAnnotation:le,unsafeCSS:Le}),[le,F.metadata.id,c,m,D,B,_.metadata.id,g,y,s,h]);return d.useEffect(()=>{const o=N.current;return()=>{A.current?.cleanUp(),A.current=null,j.current?.release(),j.current=null,ee.current=null,te.current=null,re.current=void 0,K.current=void 0,G.current=void 0,Y.current=void 0,o&&(o.innerHTML="")}},[]),d.useEffect(()=>{if(typeof window>"u")return;const o=N.current,l=Q.current;if(!o||!V)return;const a=Ve(l,o);let u=j.current;u||(u=Be(o),j.current=u),j.current=u;const R=u?.virtualizer??null,v=t?void 0:{name:i||"",contents:n,lang:r,cacheKey:`old:${W}:${i}:${me(n)}`},b=t?void 0:{name:i||"",contents:e,lang:r,cacheKey:`new:${W}:${i}:${me(e)}`},P=t?K.current!==t:K.current!==void 0||!v||!b||!G.current||!Y.current||!ce(G.current,v)||!ce(Y.current,b),k=A.current,I=!!(k&&(ee.current!==R||te.current!==V||R&&(re.current!==H.hunkSeparators||P)));I&&(k?.cleanUp(),A.current=null,o.innerHTML="");let S=A.current;const L=!I&&k?!Se(k.options,H):!1;if(S?S.setOptions(H):(S=u?new Ee(H,u.virtualizer,qe,V):new ke(H,V),A.current=S),ee.current=R,te.current=V,re.current=R?H.hunkSeparators:void 0,K.current=t,G.current=v,Y.current=b,t)S.render({fileDiff:t,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}});else{if(!v||!b)return;S.render({oldFile:v,newFile:b,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}})}const $=$e(o,()=>{a(),Ne(S,u,se)});return()=>{$(),a()}},[W,t,i,r,w,e,H,n,V]),d.useEffect(()=>{const o=N.current;if(!o)return;let l=null,a=null;const R=setTimeout(()=>{const v=o.querySelector("diffs-container");if(!(v instanceof HTMLElement))return;const b=v.shadowRoot;l=new MutationObserver(()=>{a&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{se(),a=null})}),l.observe(v,{childList:!0,subtree:!0}),b&&l.observe(b,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(R),a&&cancelAnimationFrame(a),l?.disconnect()}},[W,i]),typeof window>"u"?null:f==="fill"?M.jsx("div",{className:fe("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:M.jsx("div",{className:"flex-1 relative min-h-0",children:M.jsx(Te,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:M.jsx("div",{ref:Q,className:"size-full relative",children:M.jsx("div",{ref:N,className:"size-full"})})})})}):M.jsx("div",{className:fe("relative","w-full"),children:M.jsx("div",{ref:Q,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative","data-no-drawer-swipe":"true",children:M.jsx("div",{ref:N,className:"w-full"})})})};export{tt as P};