zidane-gui 9.0.4 → 9.1.3

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 (284) hide show
  1. package/README.md +1 -1
  2. package/out/main/chunks/{dev-extension-D5os9z0A.js → dev-extension-CjcEOYly.js} +10 -9
  3. package/out/main/chunks/extension-watch-Bk_X4gTf.js +93 -0
  4. package/out/main/chunks/{history-pager-DUFgTrih.js → history-pager-B5iwhWqn.js} +44 -7
  5. package/out/main/chunks/idle-collect-ZgTY7fw2.js +33 -0
  6. package/out/main/chunks/{remote-hosts-DlvE2ELX.js → remote-hosts-DmiOiwKi.js} +41 -1
  7. package/out/main/chunks/{session-search-sql-BrNTuwjH.js → session-search-sql-BaBnjEgm.js} +4 -4
  8. package/out/main/chunks/{tool-results-sql-C0MqWcQc.js → tool-results-sql-CVleIS51.js} +1 -1
  9. package/out/main/chunks/transcript-sql-DfsO-a4Q.js +27 -0
  10. package/out/main/extension-worker.js +52 -0
  11. package/out/main/git-watch-worker.js +21 -0
  12. package/out/main/history-worker.js +6 -3
  13. package/out/main/index.js +7677 -4252
  14. package/out/main/session-search-worker.js +18 -13
  15. package/out/main/tool-results-worker.js +18 -13
  16. package/out/main/update-worker.js +6 -0
  17. package/out/main/usage-worker.js +4 -1
  18. package/out/preload/index.mjs +56 -6
  19. package/out/renderer/assets/2CHDFZHC-B7OS2WPy.js +76 -0
  20. package/out/renderer/assets/43YPWK3Q-BLwohgFu.js +297 -0
  21. package/out/renderer/assets/45MVAN6X-DCPmrh2y.js +227 -0
  22. package/out/renderer/assets/46GJKBLZ-n_NiMQEY.js +362 -0
  23. package/out/renderer/assets/5THPTBWS-2mBFupjU.js +21 -0
  24. package/out/renderer/assets/63WH7YNF-B0-gnOSz.js +1519 -0
  25. package/out/renderer/assets/6DDU7VKX-BKAF5gyQ.js +139 -0
  26. package/out/renderer/assets/7WLXJQOR-C8MM6Bra.js +23 -0
  27. package/out/renderer/assets/CLQLV5VT-BIZsXon4.js +1159 -0
  28. package/out/renderer/assets/CUSPXG5M-Donlp74Y.js +233 -0
  29. package/out/renderer/assets/{CodeEditor-in2F3Rz-.js → CodeEditor-80QT2Pyq.js} +404 -744
  30. package/out/renderer/assets/{ComposerEditor-DzKoxH6Z.js → ComposerEditor-CXpNHoo1.js} +6 -7
  31. package/out/renderer/assets/D3L7O4X2-BCbmkNpB.js +194 -0
  32. package/out/renderer/assets/D5TW5CPZ-Bp-wetYa.js +21 -0
  33. package/out/renderer/assets/DKTLEL5E-Dj3316cp.js +42 -0
  34. package/out/renderer/assets/{DiffsTab-Ceh4E5wW.js → DiffsTab-Dy8a_hwG.js} +43 -26
  35. package/out/renderer/assets/EGADTWYV-CqSrkc7g.js +292 -0
  36. package/out/renderer/assets/EOJSJZXM-BTI84tys.js +1137 -0
  37. package/out/renderer/assets/{EditorWorkers-Bhv2OJRb.js → EditorWorkers-Durn1REy.js} +9 -11
  38. package/out/renderer/assets/FTXIJQGB-BX14b7pN.js +13 -0
  39. package/out/renderer/assets/{FileIcon-CYgGSQ59.js → FileIcon-acads6Ac.js} +1 -1
  40. package/out/renderer/assets/{FilesTab-DESQMqGK.js → FilesTab-h32FFVsw.js} +70 -28
  41. package/out/renderer/assets/G2OEIG6X-CS8YUqSL.js +519 -0
  42. package/out/renderer/assets/G3MDBVQH-qZ3yfAIw.js +25 -0
  43. package/out/renderer/assets/GXJ2T77W-BHaQFzB4.js +445 -0
  44. package/out/renderer/assets/HX3UMAK7-DOOY2pSg.js +177 -0
  45. package/out/renderer/assets/IU7WZTP6-D7pwhQLH.js +137 -0
  46. package/out/renderer/assets/J5J2NR2G-SPjkbJgo.js +673 -0
  47. package/out/renderer/assets/JRCWTJEL-DT7JLR7k.js +419 -0
  48. package/out/renderer/assets/KHUP5TOH-BX0A2YHC.js +359 -0
  49. package/out/renderer/assets/L74FQTH5-MbDLfIZo.js +994 -0
  50. package/out/renderer/assets/LAV4ZXOS-ClHlsIHg.js +968 -0
  51. package/out/renderer/assets/LBIZYCRR-DmofT7Vk.js +715 -0
  52. package/out/renderer/assets/LFFXNLRS-yLLLefJM.js +377 -0
  53. package/out/renderer/assets/LLLWOAQD-DNhT1-qV.js +409 -0
  54. package/out/renderer/assets/LTYQZ5U5-BxUtiilS.js +1223 -0
  55. package/out/renderer/assets/NDSCUZ25-DltJ5xGa.js +83 -0
  56. package/out/renderer/assets/NMN3IKWL-BXUYzi9o.js +1042 -0
  57. package/out/renderer/assets/NMUA3R2D-CAVxt8OJ.js +1080 -0
  58. package/out/renderer/assets/NY5A6PPW-B3P5KUoQ.js +523 -0
  59. package/out/renderer/assets/OHJ2EJXK-CKyEtj37.js +85 -0
  60. package/out/renderer/assets/OU2GIT2H-i9HfUuBk.js +32 -0
  61. package/out/renderer/assets/PDMLSE6I-BnbSSXbG.js +15 -0
  62. package/out/renderer/assets/PJ7X32S5-Do_rplzd.js +188 -0
  63. package/out/renderer/assets/RLLQ44NJ-SEvjKAya.js +248 -0
  64. package/out/renderer/assets/RVARI57O-DMrXgtoB.js +10 -0
  65. package/out/renderer/assets/S6DWMCK5-CK9P5x9H.js +817 -0
  66. package/out/renderer/assets/STIOTUT7-KYZS5tvF.js +509 -0
  67. package/out/renderer/assets/SXSLPWUD-ylCpsia5.js +120 -0
  68. package/out/renderer/assets/TR4WJQGX-DXlqK6NQ.js +25 -0
  69. package/out/renderer/assets/UWRPUF3N-7_KSfEv0.js +1276 -0
  70. package/out/renderer/assets/VSWIZJ7B-qmPn48eQ.js +205 -0
  71. package/out/renderer/assets/WM7NR6YK-D4oWq6L3.js +193 -0
  72. package/out/renderer/assets/WXKV2YEK-DsK-bqP8.js +499 -0
  73. package/out/renderer/assets/XLHPVVFU-4_9lhZe2.js +56 -0
  74. package/out/renderer/assets/YNX532HU-C1DPijVc.js +119 -0
  75. package/out/renderer/assets/YUPSMAUO-0pM5w-ie.js +39 -0
  76. package/out/renderer/assets/ZFRCZTLK-4EIJek0V.js +150 -0
  77. package/out/renderer/assets/ZZDR4CN3-B_T2R-Zh.js +122 -0
  78. package/out/renderer/assets/andromeeda-Bx1G2cLE.js +293 -0
  79. package/out/renderer/assets/andromeeda-vBqMIOkk.js +293 -0
  80. package/out/renderer/assets/aurora-x-Cm7-xw-C.js +243 -0
  81. package/out/renderer/assets/aurora-x-DPl7s7lw.js +243 -0
  82. package/out/renderer/assets/ayu-dark-CwZzE4zG.js +207 -0
  83. package/out/renderer/assets/ayu-dark-DkHc-GR-.js +207 -0
  84. package/out/renderer/assets/ayu-light-D8NJUeg2.js +207 -0
  85. package/out/renderer/assets/ayu-light-DNVhSCsl.js +207 -0
  86. package/out/renderer/assets/ayu-mirage-C-lSBwzI.js +207 -0
  87. package/out/renderer/assets/ayu-mirage-JE49iZ2H.js +207 -0
  88. package/out/renderer/assets/catppuccin-frappe-DU1nAiyx.js +414 -0
  89. package/out/renderer/assets/catppuccin-frappe-DX6Q-ciL.js +414 -0
  90. package/out/renderer/assets/catppuccin-latte-CO9onEOF.js +414 -0
  91. package/out/renderer/assets/catppuccin-latte-CkSyOFfG.js +414 -0
  92. package/out/renderer/assets/catppuccin-macchiato-OyZDjojj.js +414 -0
  93. package/out/renderer/assets/catppuccin-macchiato-WINjU_Dw.js +414 -0
  94. package/out/renderer/assets/catppuccin-mocha-0z8-eFg0.js +414 -0
  95. package/out/renderer/assets/catppuccin-mocha-DRTSTdRR.js +414 -0
  96. package/out/renderer/assets/{core-xOIU6ifr.js → core-2jWUG3m-.js} +4466 -2537
  97. package/out/renderer/assets/core-COuvbqNs.js +5186 -0
  98. package/out/renderer/assets/{highlight.worker-gURcNJD7.js → core-Drnj1qQL.js} +404 -4454
  99. package/out/renderer/assets/dark-plus-BaggkchT.js +241 -0
  100. package/out/renderer/assets/dark-plus-Conw9IRY.js +241 -0
  101. package/out/renderer/assets/default-CzLFidVE.js +1890 -0
  102. package/out/renderer/assets/dracula-BKSZoV-6.js +227 -0
  103. package/out/renderer/assets/dracula-BpiXsqbq.js +227 -0
  104. package/out/renderer/assets/dracula-soft-BF0b4PXf.js +169 -0
  105. package/out/renderer/assets/dracula-soft-DIWOT7Wr.js +169 -0
  106. package/out/renderer/assets/engine-javascript-CtTomO8o.js +3238 -0
  107. package/out/renderer/assets/engine-javascript-DUvVq6Hk.js +3223 -0
  108. package/out/renderer/assets/engine-oniguruma-DKBWYAaE.js +482 -0
  109. package/out/renderer/assets/engine-oniguruma-mZf4aRKS.js +482 -0
  110. package/out/renderer/assets/everforest-dark-B3n4qCUZ.js +181 -0
  111. package/out/renderer/assets/everforest-dark-BXgth4bF.js +181 -0
  112. package/out/renderer/assets/everforest-light-BhaIwhYu.js +181 -0
  113. package/out/renderer/assets/everforest-light-cbpcbx0E.js +181 -0
  114. package/out/renderer/assets/{file-tabs-Cozt9Sho.js → file-tabs-DwqRIh1X.js} +10 -12
  115. package/out/renderer/assets/{ghostty-web-BTHoKwMc.js → ghostty-web-DnI2p8KS.js} +3 -1
  116. package/out/renderer/assets/github-dark-BESFF5XO.js +234 -0
  117. package/out/renderer/assets/github-dark-DNCSzN6m.js +234 -0
  118. package/out/renderer/assets/github-dark-default-DgFmzzcd.js +168 -0
  119. package/out/renderer/assets/github-dark-default-ffmDUf0z.js +168 -0
  120. package/out/renderer/assets/github-dark-dimmed-CLKTYZCg.js +225 -0
  121. package/out/renderer/assets/github-dark-dimmed-s1SLsKJt.js +225 -0
  122. package/out/renderer/assets/github-dark-high-contrast-CXehgwDU.js +225 -0
  123. package/out/renderer/assets/github-dark-high-contrast-KLlCEr3k.js +225 -0
  124. package/out/renderer/assets/github-light-U3PkvbB_.js +234 -0
  125. package/out/renderer/assets/github-light-default-BPzGUBgG.js +225 -0
  126. package/out/renderer/assets/github-light-default-xMLgS_bN.js +225 -0
  127. package/out/renderer/assets/github-light-high-contrast-C8D72_o0.js +225 -0
  128. package/out/renderer/assets/github-light-high-contrast-DQhuIFi9.js +225 -0
  129. package/out/renderer/assets/github-light-jtm9FPHO.js +234 -0
  130. package/out/renderer/assets/gruvbox-dark-hard-BAboCHnq.js +214 -0
  131. package/out/renderer/assets/gruvbox-dark-hard-woZR1aVf.js +214 -0
  132. package/out/renderer/assets/gruvbox-dark-medium-BsoEOmFF.js +214 -0
  133. package/out/renderer/assets/gruvbox-dark-medium-CNo7daJC.js +214 -0
  134. package/out/renderer/assets/gruvbox-dark-soft-CaJ_lf0b.js +214 -0
  135. package/out/renderer/assets/gruvbox-dark-soft-Cg271WAX.js +214 -0
  136. package/out/renderer/assets/gruvbox-light-hard-CEjA0x_J.js +214 -0
  137. package/out/renderer/assets/gruvbox-light-hard-D8Ufxp8E.js +214 -0
  138. package/out/renderer/assets/gruvbox-light-medium-BCS-MX7u.js +214 -0
  139. package/out/renderer/assets/gruvbox-light-medium-DZkNZdeM.js +214 -0
  140. package/out/renderer/assets/gruvbox-light-soft-CRdK2Ssn.js +214 -0
  141. package/out/renderer/assets/gruvbox-light-soft-DEEl98i-.js +214 -0
  142. package/out/renderer/assets/hastToHtml-AUrFnNH_.js +123 -0
  143. package/out/renderer/assets/highlight.worker-BYB12Fvh.js +1624 -0
  144. package/out/renderer/assets/highlights-6LT5DvBO.js +292 -0
  145. package/out/renderer/assets/highlights-CpZm9DAR-DaBE50nC.js +2188 -0
  146. package/out/renderer/assets/highlights-DmxOEap0.js +313 -0
  147. package/out/renderer/assets/horizon-B492K9Ky.js +165 -0
  148. package/out/renderer/assets/horizon-DAZuC-xh.js +165 -0
  149. package/out/renderer/assets/horizon-bright-D2Sfzu7E.js +165 -0
  150. package/out/renderer/assets/horizon-bright-tGFWGsRc.js +165 -0
  151. package/out/renderer/assets/houston-BuwDhoUX.js +373 -0
  152. package/out/renderer/assets/houston-Cp9zzZds.js +373 -0
  153. package/out/renderer/assets/icons-D67TrEZV.js +23 -0
  154. package/out/renderer/assets/{index-DkE-xvCG.js → index-BnnCv70H.js} +1852 -394
  155. package/out/renderer/assets/{index-DrLLItLS.css → index-C-Dal-Bp.css} +508 -44
  156. package/out/renderer/assets/index-DhpOdP7M.js +882 -0
  157. package/out/renderer/assets/kanagawa-dragon-6NLBJhOz.js +229 -0
  158. package/out/renderer/assets/kanagawa-dragon-BF7rCHRT.js +229 -0
  159. package/out/renderer/assets/kanagawa-lotus-Cj8RDQcT.js +229 -0
  160. package/out/renderer/assets/kanagawa-lotus-uV7FMPcj.js +229 -0
  161. package/out/renderer/assets/kanagawa-wave-0rvDP1ei.js +229 -0
  162. package/out/renderer/assets/kanagawa-wave-B6IVm0GO.js +229 -0
  163. package/out/renderer/assets/{kit-BUt8oFlT.js → kit-CdRTRA2T.js} +46458 -39887
  164. package/out/renderer/assets/langs-BtXnoosO.js +1331 -0
  165. package/out/renderer/assets/langs-D9nZatrh.js +1333 -0
  166. package/out/renderer/assets/laserwave-DXWE1WnK.js +166 -0
  167. package/out/renderer/assets/laserwave-JLRBtymH.js +166 -0
  168. package/out/renderer/assets/lazy-C1DShJVi.js +1188 -0
  169. package/out/renderer/assets/light-plus-DU2oMqtU.js +244 -0
  170. package/out/renderer/assets/light-plus-D_GZIzn-.js +244 -0
  171. package/out/renderer/assets/loader-BlmA-DDi.js +83 -0
  172. package/out/renderer/assets/loader-q6EC19QI.js +80 -0
  173. package/out/renderer/assets/material-theme-C0rHRk_7.js +171 -0
  174. package/out/renderer/assets/material-theme-CKzpgSIj.js +171 -0
  175. package/out/renderer/assets/material-theme-darker-LxtgP-nI.js +171 -0
  176. package/out/renderer/assets/material-theme-darker-q1PJSGwC.js +171 -0
  177. package/out/renderer/assets/material-theme-lighter-Bo7q33GI.js +171 -0
  178. package/out/renderer/assets/material-theme-lighter-DIrXq_cm.js +171 -0
  179. package/out/renderer/assets/material-theme-ocean-DBoGA257.js +171 -0
  180. package/out/renderer/assets/material-theme-ocean-DKw0PiZ1.js +171 -0
  181. package/out/renderer/assets/material-theme-palenight-C6KqY_uf.js +171 -0
  182. package/out/renderer/assets/material-theme-palenight-DoLm5E7H.js +171 -0
  183. package/out/renderer/assets/min-dark-C29HEm34.js +166 -0
  184. package/out/renderer/assets/min-dark-C5zOB6s9.js +166 -0
  185. package/out/renderer/assets/min-light-BDAdB2zx.js +166 -0
  186. package/out/renderer/assets/min-light-CCfylF7u.js +166 -0
  187. package/out/renderer/assets/monokai-CgbJVDnk.js +246 -0
  188. package/out/renderer/assets/monokai-hi1UnAdE.js +246 -0
  189. package/out/renderer/assets/night-owl-Cy8ZrWil.js +238 -0
  190. package/out/renderer/assets/night-owl-Pfm14M0L.js +238 -0
  191. package/out/renderer/assets/night-owl-light-Cr6ug2dl.js +237 -0
  192. package/out/renderer/assets/night-owl-light-UewpB7JV.js +237 -0
  193. package/out/renderer/assets/nord-C68LX7oy.js +200 -0
  194. package/out/renderer/assets/nord-D68iK8nx.js +200 -0
  195. package/out/renderer/assets/one-dark-pro-DSih0ZZj.js +196 -0
  196. package/out/renderer/assets/one-dark-pro-DyTT0T_G.js +196 -0
  197. package/out/renderer/assets/one-light--fEa3idW.js +232 -0
  198. package/out/renderer/assets/one-light-BzGf0rQc.js +232 -0
  199. package/out/renderer/assets/{patch-parse.worker-BAW1QWyk.js → patch-parse.worker-siqPY9wG.js} +24 -4
  200. package/out/renderer/assets/pierre-dark-1Xh1-lMo.js +4 -0
  201. package/out/renderer/assets/pierre-dark-7z_hCG7W.js +364 -0
  202. package/out/renderer/assets/pierre-dark-protanopia-deuteranopia-DjiH32kw.js +364 -0
  203. package/out/renderer/assets/pierre-dark-protanopia-deuteranopia-GW6g2K_K.js +364 -0
  204. package/out/renderer/assets/pierre-dark-protanopia-deuteranopia-LDfpPKjm.js +4 -0
  205. package/out/renderer/assets/pierre-dark-soft-1iBHdNO0.js +364 -0
  206. package/out/renderer/assets/pierre-dark-soft-C_k_gt55.js +4 -0
  207. package/out/renderer/assets/pierre-dark-soft-D5-n1AeJ.js +364 -0
  208. package/out/renderer/assets/pierre-dark-tritanopia-CeWJyYfV.js +4 -0
  209. package/out/renderer/assets/pierre-dark-tritanopia-ClMvjOGO.js +364 -0
  210. package/out/renderer/assets/pierre-dark-tritanopia-D9kXXcwP.js +364 -0
  211. package/out/renderer/assets/pierre-dark-vibrant-6Oqz1PbM.js +4 -0
  212. package/out/renderer/assets/pierre-dark-vibrant-C8yH51pK.js +364 -0
  213. package/out/renderer/assets/pierre-dark-vibrant-D_7rJXbX.js +364 -0
  214. package/out/renderer/assets/pierre-dark-yHUcpElV.js +364 -0
  215. package/out/renderer/assets/pierre-light-BIebL0yQ.js +4 -0
  216. package/out/renderer/assets/pierre-light-C34x-mcs.js +364 -0
  217. package/out/renderer/assets/pierre-light-C9v4GAHb.js +364 -0
  218. package/out/renderer/assets/pierre-light-protanopia-deuteranopia-BufD2-1n.js +4 -0
  219. package/out/renderer/assets/pierre-light-protanopia-deuteranopia-DUrvpW2C.js +364 -0
  220. package/out/renderer/assets/pierre-light-protanopia-deuteranopia-VwXWNPo2.js +364 -0
  221. package/out/renderer/assets/pierre-light-soft-BmDnpPlM.js +364 -0
  222. package/out/renderer/assets/pierre-light-soft-Cd6v49hf.js +4 -0
  223. package/out/renderer/assets/pierre-light-soft-DqFh0kZA.js +364 -0
  224. package/out/renderer/assets/pierre-light-tritanopia-BVCfgdSF.js +364 -0
  225. package/out/renderer/assets/pierre-light-tritanopia-RkA2q6k9.js +364 -0
  226. package/out/renderer/assets/pierre-light-tritanopia-VrCUn-Lh.js +4 -0
  227. package/out/renderer/assets/pierre-light-vibrant-C5BaqWq3.js +364 -0
  228. package/out/renderer/assets/pierre-light-vibrant-CCrCMYrB.js +364 -0
  229. package/out/renderer/assets/pierre-light-vibrant-ClZHsQXl.js +4 -0
  230. package/out/renderer/assets/{pierre-theme-Bj5EAt1L.js → pierre-theme-DpuLJ_93.js} +1022 -913
  231. package/out/renderer/assets/plastic-7t7HzasC.js +207 -0
  232. package/out/renderer/assets/plastic-EgWoj0TX.js +207 -0
  233. package/out/renderer/assets/poimandres-Clm3QHf_.js +186 -0
  234. package/out/renderer/assets/poimandres-_9ZL-zjP.js +186 -0
  235. package/out/renderer/assets/red-BGLMOAQA.js +240 -0
  236. package/out/renderer/assets/red-C7WxuK4s.js +240 -0
  237. package/out/renderer/assets/rose-pine-CSYOOLQH.js +200 -0
  238. package/out/renderer/assets/rose-pine-DQTixAK4.js +200 -0
  239. package/out/renderer/assets/rose-pine-dawn-BsExWFpO.js +200 -0
  240. package/out/renderer/assets/rose-pine-dawn-DtnCKB3V.js +200 -0
  241. package/out/renderer/assets/rose-pine-moon-CIVzFPCR.js +200 -0
  242. package/out/renderer/assets/rose-pine-moon-DUVYttUm.js +200 -0
  243. package/out/renderer/assets/shiki-Ci4cdHsM-C6d-uTVf.js +681 -0
  244. package/out/renderer/assets/shiki-RupN-xqP.js +651 -0
  245. package/out/renderer/assets/slack-dark-DqfBLzDN.js +156 -0
  246. package/out/renderer/assets/slack-dark-PDVLPqBV.js +156 -0
  247. package/out/renderer/assets/slack-ochin-BXb20b9s.js +167 -0
  248. package/out/renderer/assets/slack-ochin-Bkl8Akj-.js +167 -0
  249. package/out/renderer/assets/snazzy-light-B-XgRQqH.js +169 -0
  250. package/out/renderer/assets/snazzy-light-B_Pnr_t3.js +169 -0
  251. package/out/renderer/assets/solarized-dark-BExlwCgF.js +256 -0
  252. package/out/renderer/assets/solarized-dark-BWOkBqBk.js +256 -0
  253. package/out/renderer/assets/solarized-light-B0LC-9ef.js +256 -0
  254. package/out/renderer/assets/solarized-light-B7xKmc3j.js +256 -0
  255. package/out/renderer/assets/stream-tokenizer-DK9xp5M5-BkzgPytU.js +2641 -0
  256. package/out/renderer/assets/stream-tokenizer-DLDzyMrK.js +131 -0
  257. package/out/renderer/assets/synthwave-84-Bz5LYLQI.js +766 -0
  258. package/out/renderer/assets/synthwave-84-DnB997dV.js +766 -0
  259. package/out/renderer/assets/themes-B1aebwax.js +323 -0
  260. package/out/renderer/assets/themes-KOxcu5sY.js +322 -0
  261. package/out/renderer/assets/tokyo-night-BFQDXQF9.js +343 -0
  262. package/out/renderer/assets/tokyo-night-BKV2xFQO.js +343 -0
  263. package/out/renderer/assets/{useDetachCleanup-Bb7k1ePf.js → useDetachCleanup-BXvhEVk-.js} +95 -51
  264. package/out/renderer/assets/{useFolderChanges-B4X4n6NV.js → useFolderChanges-BHQktE6l.js} +406 -242
  265. package/out/renderer/assets/utils-BcG7Lqcy.js +90 -0
  266. package/out/renderer/assets/{vendor-BvslLX9q.js → vendor-BpwX-s_O.js} +16835 -16799
  267. package/out/renderer/assets/{vendor-editor-Bx3dRdBD.js → vendor-editor-Cx3SvGyZ.js} +2 -2
  268. package/out/renderer/assets/{vendor-motion-BLeNAEjH.js → vendor-motion-BgQeucLF.js} +3 -3
  269. package/out/renderer/assets/{vendor-react-DltKc0Ts.js → vendor-react-bPTwWURR.js} +28 -12
  270. package/out/renderer/assets/vesper-BVtJs6jF.js +173 -0
  271. package/out/renderer/assets/vesper-BXSaHQeX.js +173 -0
  272. package/out/renderer/assets/vitesse-black-Bk4nGSr_.js +388 -0
  273. package/out/renderer/assets/vitesse-black-DjBh7jMr.js +388 -0
  274. package/out/renderer/assets/vitesse-dark-BSeRY0TR.js +388 -0
  275. package/out/renderer/assets/vitesse-dark-Czy_Ejt3.js +388 -0
  276. package/out/renderer/assets/vitesse-light-BpMpGmeY.js +388 -0
  277. package/out/renderer/assets/vitesse-light-Cv09MZGR.js +388 -0
  278. package/out/renderer/assets/worker-CswOd5_T.js +2367 -0
  279. package/out/renderer/index.html +8 -9
  280. package/package.json +13 -6
  281. package/out/main/chunks/transcript-sql-DbZ-a5wb.js +0 -43
  282. package/out/renderer/assets/index-DogoEzwx.js +0 -10868
  283. package/out/renderer/assets/vendor-shiki-ba8IDo5s.js +0 -459
  284. package/out/renderer/assets/worker-DNIQ0wG8.js +0 -12761
@@ -0,0 +1,3223 @@
1
+ const MAX = 4294967295;
2
+ function isSearchCacheable(regexp) {
3
+ return !regexp.sticky && !regexp.rawOptions?.strategy;
4
+ }
5
+ function toResult(index, indices) {
6
+ return {
7
+ index,
8
+ captureIndices: indices.map((indice) => {
9
+ if (indice == null) return {
10
+ start: MAX,
11
+ end: MAX,
12
+ length: 0
13
+ };
14
+ return {
15
+ start: indice[0],
16
+ end: indice[1],
17
+ length: indice[1] - indice[0]
18
+ };
19
+ })
20
+ };
21
+ }
22
+ var JavaScriptScanner = class {
23
+ patterns;
24
+ options;
25
+ regexps;
26
+ /**
27
+ * Last search of each regexp on the current string, reused the way `vscode-oniguruma` does.
28
+ * `null` for regexps whose searches can't be reused.
29
+ */
30
+ lastSearches;
31
+ constructor(patterns, options = {}) {
32
+ this.patterns = patterns;
33
+ this.options = options;
34
+ const { forgiving = false, cache, regexConstructor } = options;
35
+ if (!regexConstructor) throw new Error("Option `regexConstructor` is not provided");
36
+ this.regexps = patterns.map((p) => {
37
+ if (typeof p !== "string") return p;
38
+ const cached = cache?.get(p);
39
+ if (cached) {
40
+ if (cached instanceof RegExp) return cached;
41
+ if (forgiving) return null;
42
+ throw cached;
43
+ }
44
+ try {
45
+ const regex = regexConstructor(p);
46
+ cache?.set(p, regex);
47
+ return regex;
48
+ } catch (e) {
49
+ cache?.set(p, e);
50
+ if (forgiving) return null;
51
+ throw e;
52
+ }
53
+ });
54
+ this.lastSearches = this.regexps.map((regexp) => regexp && isSearchCacheable(regexp) ? {
55
+ strId: 0,
56
+ searchedFrom: 0,
57
+ matchIndex: -1,
58
+ indices: null
59
+ } : null);
60
+ }
61
+ findNextMatchSync(string, startPosition, _options) {
62
+ const str = typeof string === "string" ? string : string.content;
63
+ const strId = typeof string === "string" ? 0 : string.id || 0;
64
+ let bestIndex = -1;
65
+ let bestMatchIndex = 0;
66
+ let bestIndices = null;
67
+ for (let i2 = 0; i2 < this.regexps.length; i2++) {
68
+ const regexp = this.regexps[i2];
69
+ if (!regexp) continue;
70
+ try {
71
+ const last = strId ? this.lastSearches[i2] : null;
72
+ let matchIndex;
73
+ let indices;
74
+ if (last && last.strId === strId && last.searchedFrom <= startPosition && (last.matchIndex === -1 || last.matchIndex >= startPosition)) {
75
+ matchIndex = last.matchIndex;
76
+ indices = last.indices;
77
+ } else {
78
+ regexp.lastIndex = startPosition;
79
+ const match = regexp.exec(str);
80
+ matchIndex = match ? match.index : -1;
81
+ indices = match ? match.indices : null;
82
+ if (last) {
83
+ last.strId = strId;
84
+ last.searchedFrom = startPosition;
85
+ last.matchIndex = matchIndex;
86
+ last.indices = indices;
87
+ }
88
+ }
89
+ if (matchIndex === -1) continue;
90
+ if (matchIndex === startPosition) return toResult(i2, indices);
91
+ if (bestIndex === -1 || matchIndex < bestMatchIndex) {
92
+ bestIndex = i2;
93
+ bestMatchIndex = matchIndex;
94
+ bestIndices = indices;
95
+ }
96
+ } catch (e) {
97
+ if (this.options.forgiving) continue;
98
+ throw e;
99
+ }
100
+ }
101
+ return bestIndex === -1 ? null : toResult(bestIndex, bestIndices);
102
+ }
103
+ };
104
+ let lastStringId = 0;
105
+ function createJavaScriptEngineString(content) {
106
+ return {
107
+ content,
108
+ id: ++lastStringId
109
+ };
110
+ }
111
+ function r$2(e) {
112
+ if ([...e].length !== 1) throw new Error(`Expected "${e}" to be a single code point`);
113
+ return e.codePointAt(0);
114
+ }
115
+ function l$1(e, t, n) {
116
+ return e.has(t) || e.set(t, n), e.get(t);
117
+ }
118
+ const i = /* @__PURE__ */ new Set(["alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "word", "xdigit"]), o$1 = String.raw;
119
+ function u(e, t) {
120
+ if (e == null) throw new Error(t ?? "Value expected");
121
+ return e;
122
+ }
123
+ const m$1 = o$1`\[\^?`, b$1 = `c.? | C(?:-.?)?|${o$1`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${o$1`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${o$1`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${o$1`o\{[^\}]*\}?`}|${o$1`\d{1,3}`}`, y$1 = /[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/, C$1 = new RegExp(o$1`
124
+ \\ (?:
125
+ ${b$1}
126
+ | [gk]<[^>]*>?
127
+ | [gk]'[^']*'?
128
+ | .
129
+ )
130
+ | \( (?:
131
+ \? (?:
132
+ [:=!>({]
133
+ | <[=!]
134
+ | <[^>]*>
135
+ | '[^']*'
136
+ | ~\|?
137
+ | #(?:[^)\\]|\\.?)*
138
+ | [^:)]*[:)]
139
+ )?
140
+ | \*[^\)]*\)?
141
+ )?
142
+ | (?:${y$1.source})+
143
+ | ${m$1}
144
+ | .
145
+ `.replace(/\s+/g, ""), "gsu"), T$1 = new RegExp(o$1`
146
+ \\ (?:
147
+ ${b$1}
148
+ | .
149
+ )
150
+ | \[:(?:\^?\p{Alpha}+|\^):\]
151
+ | ${m$1}
152
+ | &&
153
+ | .
154
+ `.replace(/\s+/g, ""), "gsu");
155
+ function M$1(e, n = {}) {
156
+ const t = { flags: "", ...n, rules: { captureGroup: false, singleline: false, ...n.rules } };
157
+ if (typeof e != "string") throw new Error("String expected as pattern");
158
+ const o2 = Y(t.flags), s2 = [o2.extended], a = { captureGroup: t.rules.captureGroup, getCurrentModX() {
159
+ return s2.at(-1);
160
+ }, numOpenGroups: 0, popModX() {
161
+ s2.pop();
162
+ }, pushModX(u2) {
163
+ s2.push(u2);
164
+ }, replaceCurrentModX(u2) {
165
+ s2[s2.length - 1] = u2;
166
+ }, singleline: t.rules.singleline };
167
+ let r2 = [], i2;
168
+ for (C$1.lastIndex = 0; i2 = C$1.exec(e); ) {
169
+ const u2 = F$1(a, e, i2[0], C$1.lastIndex);
170
+ u2.tokens ? r2.push(...u2.tokens) : u2.token && r2.push(u2.token), u2.lastIndex !== void 0 && (C$1.lastIndex = u2.lastIndex);
171
+ }
172
+ const l2 = [];
173
+ let c = 0;
174
+ r2.filter((u2) => u2.type === "GroupOpen").forEach((u2) => {
175
+ u2.kind === "capturing" ? u2.number = ++c : u2.raw === "(" && l2.push(u2);
176
+ }), c || l2.forEach((u2, S2) => {
177
+ u2.kind = "capturing", u2.number = S2 + 1;
178
+ });
179
+ const g = c || l2.length;
180
+ return { tokens: r2.map((u2) => u2.type === "EscapedNumber" ? ee$1(u2, g) : u2).flat(), flags: o2 };
181
+ }
182
+ function F$1(e, n, t, o2) {
183
+ const [s2, a] = t;
184
+ if (t === "[" || t === "[^") {
185
+ const r2 = K$1(n, t, o2);
186
+ return { tokens: r2.tokens, lastIndex: r2.lastIndex };
187
+ }
188
+ if (s2 === "\\") {
189
+ if ("AbBGyYzZ".includes(a)) return { token: w$1(t, t) };
190
+ if (/^\\g[<']/.test(t)) {
191
+ if (!/^\\g(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
192
+ return { token: R$1(t) };
193
+ }
194
+ if (/^\\k[<']/.test(t)) {
195
+ if (!/^\\k(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
196
+ return { token: A$1(t) };
197
+ }
198
+ if (a === "K") return { token: I$1("keep", t) };
199
+ if (a === "N" || a === "R") return { token: k$1("newline", t, { negate: a === "N" }) };
200
+ if (a === "O") return { token: k$1("any", t) };
201
+ if (a === "X") return { token: k$1("text_segment", t) };
202
+ const r2 = x$1(t, { inCharClass: false });
203
+ return Array.isArray(r2) ? { tokens: r2 } : { token: r2 };
204
+ }
205
+ if (s2 === "(") {
206
+ if (a === "*") return { token: j(t) };
207
+ if (t === "(?{") throw new Error(`Unsupported callout "${t}"`);
208
+ if (t.startsWith("(?#")) {
209
+ if (n[o2] !== ")") throw new Error('Unclosed comment group "(?#"');
210
+ return { lastIndex: o2 + 1 };
211
+ }
212
+ if (/^\(\?[-imx]+[:)]$/.test(t)) return { token: L$1(t, e) };
213
+ if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:") return { token: f("group", t) };
214
+ if (t === "(?>") return { token: f("atomic", t) };
215
+ if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!") return { token: f(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
216
+ if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'")) return { token: f("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
217
+ if (t.startsWith("(?~")) {
218
+ if (t === "(?~|") throw new Error(`Unsupported absence function kind "${t}"`);
219
+ return { token: f("absence_repeater", t) };
220
+ }
221
+ throw t === "(?(" ? new Error(`Unsupported conditional "${t}"`) : new Error(`Invalid or unsupported group option "${t}"`);
222
+ }
223
+ if (t === ")") {
224
+ if (e.popModX(), e.numOpenGroups--, e.numOpenGroups < 0) throw new Error('Unmatched ")"');
225
+ return { token: Q$1(t) };
226
+ }
227
+ if (e.getCurrentModX()) {
228
+ if (t === "#") {
229
+ const r2 = n.indexOf(`
230
+ `, o2);
231
+ return { lastIndex: r2 === -1 ? n.length : r2 };
232
+ }
233
+ if (/^\s$/.test(t)) {
234
+ const r2 = /\s+/y;
235
+ return r2.lastIndex = o2, { lastIndex: r2.exec(n) ? r2.lastIndex : o2 };
236
+ }
237
+ }
238
+ if (t === ".") return { token: k$1("dot", t) };
239
+ if (t === "^" || t === "$") {
240
+ const r2 = e.singleline ? { "^": o$1`\A`, $: o$1`\Z` }[t] : t;
241
+ return { token: w$1(r2, t) };
242
+ }
243
+ return t === "|" ? { token: P$1(t) } : y$1.test(t) ? { tokens: te$1(t) } : { token: d(r$2(t), t) };
244
+ }
245
+ function K$1(e, n, t) {
246
+ const o2 = [E$1(n[1] === "^", n)];
247
+ let s2 = 1, a;
248
+ for (T$1.lastIndex = t; a = T$1.exec(e); ) {
249
+ const r2 = a[0];
250
+ if (r2[0] === "[" && r2[1] !== ":") s2++, o2.push(E$1(r2[1] === "^", r2));
251
+ else if (r2 === "]") {
252
+ if (o2.at(-1).type === "CharacterClassOpen") o2.push(d(93, r2));
253
+ else if (s2--, o2.push(z$1(r2)), !s2) break;
254
+ } else {
255
+ const i2 = X$1(r2);
256
+ Array.isArray(i2) ? o2.push(...i2) : o2.push(i2);
257
+ }
258
+ }
259
+ return { tokens: o2, lastIndex: T$1.lastIndex || e.length };
260
+ }
261
+ function X$1(e) {
262
+ if (e[0] === "\\") return x$1(e, { inCharClass: true });
263
+ if (e[0] === "[") {
264
+ const n = /\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);
265
+ if (!n || !i.has(n.groups.name)) throw new Error(`Invalid POSIX class "${e}"`);
266
+ return k$1("posix", e, { value: n.groups.name, negate: !!n.groups.negate });
267
+ }
268
+ return e === "-" ? U$1(e) : e === "&&" ? H(e) : d(r$2(e), e);
269
+ }
270
+ function x$1(e, { inCharClass: n }) {
271
+ const t = e[1];
272
+ if (t === "c" || t === "C") return Z(e);
273
+ if ("dDhHsSwW".includes(t)) return q(e);
274
+ if (e.startsWith(o$1`\o{`)) throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);
275
+ if (/^\\[pP]\{/.test(e)) {
276
+ if (e.length === 3) throw new Error(`Incomplete or invalid Unicode property "${e}"`);
277
+ return V$1(e);
278
+ }
279
+ if (new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}", "u").test(e)) try {
280
+ const o2 = e.split(/\\x/).slice(1).map((i2) => parseInt(i2, 16)), s2 = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }).decode(new Uint8Array(o2)), a = new TextEncoder();
281
+ return [...s2].map((i2) => {
282
+ const l2 = [...a.encode(i2)].map((c) => `\\x${c.toString(16)}`).join("");
283
+ return d(r$2(i2), l2);
284
+ });
285
+ } catch {
286
+ throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`);
287
+ }
288
+ if (t === "u" || t === "x") return d(J$1(e), e);
289
+ if ($$1.has(t)) return d($$1.get(t), e);
290
+ if (/\d/.test(t)) return W$1(n, e);
291
+ if (e === "\\") throw new Error(o$1`Incomplete escape "\"`);
292
+ if (t === "M") throw new Error(`Unsupported meta "${e}"`);
293
+ if ([...e].length === 2) return d(e.codePointAt(1), e);
294
+ throw new Error(`Unexpected escape "${e}"`);
295
+ }
296
+ function P$1(e) {
297
+ return { type: "Alternator", raw: e };
298
+ }
299
+ function w$1(e, n) {
300
+ return { type: "Assertion", kind: e, raw: n };
301
+ }
302
+ function A$1(e) {
303
+ return { type: "Backreference", raw: e };
304
+ }
305
+ function d(e, n) {
306
+ return { type: "Character", value: e, raw: n };
307
+ }
308
+ function z$1(e) {
309
+ return { type: "CharacterClassClose", raw: e };
310
+ }
311
+ function U$1(e) {
312
+ return { type: "CharacterClassHyphen", raw: e };
313
+ }
314
+ function H(e) {
315
+ return { type: "CharacterClassIntersector", raw: e };
316
+ }
317
+ function E$1(e, n) {
318
+ return { type: "CharacterClassOpen", negate: e, raw: n };
319
+ }
320
+ function k$1(e, n, t = {}) {
321
+ return { type: "CharacterSet", kind: e, ...t, raw: n };
322
+ }
323
+ function I$1(e, n, t = {}) {
324
+ return e === "keep" ? { type: "Directive", kind: e, raw: n } : { type: "Directive", kind: e, flags: u(t.flags), raw: n };
325
+ }
326
+ function W$1(e, n) {
327
+ return { type: "EscapedNumber", inCharClass: e, raw: n };
328
+ }
329
+ function Q$1(e) {
330
+ return { type: "GroupClose", raw: e };
331
+ }
332
+ function f(e, n, t = {}) {
333
+ return { type: "GroupOpen", kind: e, ...t, raw: n };
334
+ }
335
+ function D$1(e, n, t, o2) {
336
+ return { type: "NamedCallout", kind: e, tag: n, arguments: t, raw: o2 };
337
+ }
338
+ function _$1(e, n, t, o2) {
339
+ return { type: "Quantifier", kind: e, min: n, max: t, raw: o2 };
340
+ }
341
+ function R$1(e) {
342
+ return { type: "Subroutine", raw: e };
343
+ }
344
+ const B$1 = /* @__PURE__ */ new Set(["COUNT", "CMP", "ERROR", "FAIL", "MAX", "MISMATCH", "SKIP", "TOTAL_COUNT"]), $$1 = /* @__PURE__ */ new Map([["a", 7], ["b", 8], ["e", 27], ["f", 12], ["n", 10], ["r", 13], ["t", 9], ["v", 11]]);
345
+ function Z(e) {
346
+ const n = e[1] === "c" ? e[2] : e[3];
347
+ if (!n || !/[A-Za-z]/.test(n)) throw new Error(`Unsupported control character "${e}"`);
348
+ return d(r$2(n.toUpperCase()) - 64, e);
349
+ }
350
+ function L$1(e, n) {
351
+ let { on: t, off: o2 } = /^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;
352
+ o2 ??= "";
353
+ const s2 = (n.getCurrentModX() || t.includes("x")) && !o2.includes("x"), a = v(t), r2 = v(o2), i2 = {};
354
+ if (a && (i2.enable = a), r2 && (i2.disable = r2), e.endsWith(")")) return n.replaceCurrentModX(s2), I$1("flags", e, { flags: i2 });
355
+ if (e.endsWith(":")) return n.pushModX(s2), n.numOpenGroups++, f("group", e, { ...(a || r2) && { flags: i2 } });
356
+ throw new Error(`Unexpected flag modifier "${e}"`);
357
+ }
358
+ function j(e) {
359
+ const n = /\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);
360
+ if (!n) throw new Error(`Incomplete or invalid named callout "${e}"`);
361
+ const { name: t, tag: o2, args: s2 } = n.groups;
362
+ if (!t) throw new Error(`Invalid named callout "${e}"`);
363
+ if (o2 === "") throw new Error(`Named callout tag with empty value not allowed "${e}"`);
364
+ const a = s2 ? s2.split(",").filter((g) => g !== "").map((g) => /^[+-]?\d+$/.test(g) ? +g : g) : [], [r2, i2, l2] = a, c = B$1.has(t) ? t.toLowerCase() : "custom";
365
+ switch (c) {
366
+ case "fail":
367
+ case "mismatch":
368
+ case "skip":
369
+ if (a.length > 0) throw new Error(`Named callout arguments not allowed "${a}"`);
370
+ break;
371
+ case "error":
372
+ if (a.length > 1) throw new Error(`Named callout allows only one argument "${a}"`);
373
+ if (typeof r2 == "string") throw new Error(`Named callout argument must be a number "${r2}"`);
374
+ break;
375
+ case "max":
376
+ if (!a.length || a.length > 2) throw new Error(`Named callout must have one or two arguments "${a}"`);
377
+ if (typeof r2 == "string" && !/^[A-Za-z_]\w*$/.test(r2)) throw new Error(`Named callout argument one must be a tag or number "${r2}"`);
378
+ if (a.length === 2 && (typeof i2 == "number" || !/^[<>X]$/.test(i2))) throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i2}"`);
379
+ break;
380
+ case "count":
381
+ case "total_count":
382
+ if (a.length > 1) throw new Error(`Named callout allows only one argument "${a}"`);
383
+ if (a.length === 1 && (typeof r2 == "number" || !/^[<>X]$/.test(r2))) throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${r2}"`);
384
+ break;
385
+ case "cmp":
386
+ if (a.length !== 3) throw new Error(`Named callout must have three arguments "${a}"`);
387
+ if (typeof r2 == "string" && !/^[A-Za-z_]\w*$/.test(r2)) throw new Error(`Named callout argument one must be a tag or number "${r2}"`);
388
+ if (typeof i2 == "number" || !/^(?:[<>!=]=|[<>])$/.test(i2)) throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i2}"`);
389
+ if (typeof l2 == "string" && !/^[A-Za-z_]\w*$/.test(l2)) throw new Error(`Named callout argument three must be a tag or number "${l2}"`);
390
+ break;
391
+ case "custom":
392
+ throw new Error(`Undefined callout name "${t}"`);
393
+ default:
394
+ throw new Error(`Unexpected named callout kind "${c}"`);
395
+ }
396
+ return D$1(c, o2 ?? null, s2?.split(",") ?? null, e);
397
+ }
398
+ function O$1(e) {
399
+ let n = null, t, o2;
400
+ if (e[0] === "{") {
401
+ const { minStr: s2, maxStr: a } = /^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups, r2 = 1e5;
402
+ if (+s2 > r2 || a && +a > r2) throw new Error("Quantifier value unsupported in Oniguruma");
403
+ if (t = +s2, o2 = a === void 0 ? +s2 : a === "" ? 1 / 0 : +a, t > o2 && (n = "possessive", [t, o2] = [o2, t]), e.endsWith("?")) {
404
+ if (n === "possessive") throw new Error('Unsupported possessive interval quantifier chain with "?"');
405
+ n = "lazy";
406
+ } else n || (n = "greedy");
407
+ } else t = e[0] === "+" ? 1 : 0, o2 = e[0] === "?" ? 1 : 1 / 0, n = e[1] === "+" ? "possessive" : e[1] === "?" ? "lazy" : "greedy";
408
+ return _$1(n, t, o2, e);
409
+ }
410
+ function q(e) {
411
+ const n = e[1].toLowerCase();
412
+ return k$1({ d: "digit", h: "hex", s: "space", w: "word" }[n], e, { negate: e[1] !== n });
413
+ }
414
+ function V$1(e) {
415
+ const { p: n, neg: t, value: o2 } = /^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;
416
+ return k$1("property", e, { value: o2, negate: n === "P" && !t || n === "p" && !!t });
417
+ }
418
+ function v(e) {
419
+ const n = {};
420
+ return e.includes("i") && (n.ignoreCase = true), e.includes("m") && (n.dotAll = true), e.includes("x") && (n.extended = true), Object.keys(n).length ? n : null;
421
+ }
422
+ function Y(e) {
423
+ const n = { ignoreCase: false, dotAll: false, extended: false, digitIsAscii: false, posixIsAscii: false, spaceIsAscii: false, wordIsAscii: false, textSegmentMode: null };
424
+ for (let t = 0; t < e.length; t++) {
425
+ const o2 = e[t];
426
+ if (!"imxDPSWy".includes(o2)) throw new Error(`Invalid flag "${o2}"`);
427
+ if (o2 === "y") {
428
+ if (!/^y{[gw]}/.test(e.slice(t))) throw new Error('Invalid or unspecified flag "y" mode');
429
+ n.textSegmentMode = e[t + 2] === "g" ? "grapheme" : "word", t += 3;
430
+ continue;
431
+ }
432
+ n[{ i: "ignoreCase", m: "dotAll", x: "extended", D: "digitIsAscii", P: "posixIsAscii", S: "spaceIsAscii", W: "wordIsAscii" }[o2]] = true;
433
+ }
434
+ return n;
435
+ }
436
+ function J$1(e) {
437
+ if (new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))", "u").test(e)) throw new Error(`Incomplete or invalid escape "${e}"`);
438
+ const n = e[2] === "{" ? new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)", "u").exec(e).groups.hex : e.slice(2);
439
+ return parseInt(n, 16);
440
+ }
441
+ function ee$1(e, n) {
442
+ const { raw: t, inCharClass: o2 } = e, s2 = t.slice(1);
443
+ if (!o2 && (s2 !== "0" && s2.length === 1 || s2[0] !== "0" && +s2 <= n)) return [A$1(t)];
444
+ const a = [], r2 = s2.match(/^[0-7]+|\d/g);
445
+ for (let i2 = 0; i2 < r2.length; i2++) {
446
+ const l2 = r2[i2];
447
+ let c;
448
+ if (i2 === 0 && l2 !== "8" && l2 !== "9") {
449
+ if (c = parseInt(l2, 8), c > 127) throw new Error(o$1`Octal encoded byte above 177 unsupported "${t}"`);
450
+ } else c = r$2(l2);
451
+ a.push(d(c, (i2 === 0 ? "\\" : "") + l2));
452
+ }
453
+ return a;
454
+ }
455
+ function te$1(e) {
456
+ const n = [], t = new RegExp(y$1, "gy");
457
+ let o2;
458
+ for (; o2 = t.exec(e); ) {
459
+ const s2 = o2[0];
460
+ if (s2[0] === "{") {
461
+ const a = /^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s2);
462
+ if (a) {
463
+ const { min: r2, max: i2 } = a.groups;
464
+ if (+r2 > +i2 && s2.endsWith("?")) {
465
+ t.lastIndex--, n.push(O$1(s2.slice(0, -1)));
466
+ continue;
467
+ }
468
+ }
469
+ }
470
+ n.push(O$1(s2));
471
+ }
472
+ return n;
473
+ }
474
+ function o(e, t) {
475
+ if (!Array.isArray(e.body)) throw new Error("Expected node with body array");
476
+ if (e.body.length !== 1) return false;
477
+ const r2 = e.body[0];
478
+ return !t || Object.keys(t).every((n) => t[n] === r2[n]);
479
+ }
480
+ function s(e) {
481
+ return y.has(e.type);
482
+ }
483
+ const y = /* @__PURE__ */ new Set(["AbsenceFunction", "Backreference", "CapturingGroup", "Character", "CharacterClass", "CharacterSet", "Group", "Quantifier", "Subroutine"]);
484
+ function J(e, r2 = {}) {
485
+ const n = { flags: "", normalizeUnknownPropertyNames: false, skipBackrefValidation: false, skipLookbehindValidation: false, skipPropertyNameValidation: false, unicodePropertyMap: null, ...r2, rules: { captureGroup: false, singleline: false, ...r2.rules } }, o2 = M$1(e, { flags: n.flags, rules: { captureGroup: n.rules.captureGroup, singleline: n.rules.singleline } }), i2 = (p, N) => {
486
+ const u2 = o2.tokens[t.nextIndex];
487
+ switch (t.parent = p, t.nextIndex++, u2.type) {
488
+ case "Alternator":
489
+ return b();
490
+ case "Assertion":
491
+ return W(u2);
492
+ case "Backreference":
493
+ return X(u2, t);
494
+ case "Character":
495
+ return m(u2.value, { useLastValid: !!N.isCheckingRangeEnd });
496
+ case "CharacterClassHyphen":
497
+ return ee(u2, t, N);
498
+ case "CharacterClassOpen":
499
+ return re(u2, t, N);
500
+ case "CharacterSet":
501
+ return ne(u2, t);
502
+ case "Directive":
503
+ return I(u2.kind, { flags: u2.flags });
504
+ case "GroupOpen":
505
+ return te(u2, t, N);
506
+ case "NamedCallout":
507
+ return U(u2.kind, u2.tag, u2.arguments);
508
+ case "Quantifier":
509
+ return oe(u2, t);
510
+ case "Subroutine":
511
+ return ae(u2, t);
512
+ default:
513
+ throw new Error(`Unexpected token type "${u2.type}"`);
514
+ }
515
+ }, t = { capturingGroups: [], hasNumberedRef: false, namedGroupsByName: /* @__PURE__ */ new Map(), nextIndex: 0, normalizeUnknownPropertyNames: n.normalizeUnknownPropertyNames, parent: null, skipBackrefValidation: n.skipBackrefValidation, skipLookbehindValidation: n.skipLookbehindValidation, skipPropertyNameValidation: n.skipPropertyNameValidation, subroutines: [], tokens: o2.tokens, unicodePropertyMap: n.unicodePropertyMap, walk: i2 }, d2 = B(T(o2.flags));
516
+ let s2 = d2.body[0];
517
+ for (; t.nextIndex < o2.tokens.length; ) {
518
+ const p = i2(s2, {});
519
+ p.type === "Alternative" ? (d2.body.push(p), s2 = p) : s2.body.push(p);
520
+ }
521
+ const { capturingGroups: a, hasNumberedRef: l2, namedGroupsByName: c, subroutines: f2 } = t;
522
+ if (l2 && c.size && !n.rules.captureGroup) throw new Error("Numbered backref/subroutine not allowed when using named capture");
523
+ for (const { ref: p } of f2) if (typeof p == "number") {
524
+ if (p > a.length) throw new Error("Subroutine uses a group number that's not defined");
525
+ p && (a[p - 1].isSubroutined = true);
526
+ } else if (c.has(p)) {
527
+ if (c.get(p).length > 1) throw new Error(o$1`Subroutine uses a duplicate group name "\g<${p}>"`);
528
+ c.get(p)[0].isSubroutined = true;
529
+ } else throw new Error(o$1`Subroutine uses a group name that's not defined "\g<${p}>"`);
530
+ return d2;
531
+ }
532
+ function W({ kind: e }) {
533
+ return F(u({ "^": "line_start", $: "line_end", "\\A": "string_start", "\\b": "word_boundary", "\\B": "word_boundary", "\\G": "search_start", "\\y": "text_segment_boundary", "\\Y": "text_segment_boundary", "\\z": "string_end", "\\Z": "string_end_newline" }[e], `Unexpected assertion kind "${e}"`), { negate: e === o$1`\B` || e === o$1`\Y` });
534
+ }
535
+ function X({ raw: e }, r2) {
536
+ const n = /^\\k[<']/.test(e), o2 = n ? e.slice(3, -1) : e.slice(1), i2 = (t, d2 = false) => {
537
+ const s2 = r2.capturingGroups.length;
538
+ let a = false;
539
+ if (t > s2) if (r2.skipBackrefValidation) a = true;
540
+ else throw new Error(`Not enough capturing groups defined to the left "${e}"`);
541
+ return r2.hasNumberedRef = true, k(d2 ? s2 + 1 - t : t, { orphan: a });
542
+ };
543
+ if (n) {
544
+ const t = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(o2);
545
+ if (t) return i2(+t.groups.num, !!t.groups.sign);
546
+ if (/[-+]/.test(o2)) throw new Error(`Invalid backref name "${e}"`);
547
+ if (!r2.namedGroupsByName.has(o2)) throw new Error(`Group name not defined to the left "${e}"`);
548
+ return k(o2);
549
+ }
550
+ return i2(+o2);
551
+ }
552
+ function ee(e, r2, n) {
553
+ const { tokens: o2, walk: i2 } = r2, t = r2.parent, d2 = t.body.at(-1), s2 = o2[r2.nextIndex];
554
+ if (!n.isCheckingRangeEnd && d2 && d2.type !== "CharacterClass" && d2.type !== "CharacterClassRange" && s2 && s2.type !== "CharacterClassOpen" && s2.type !== "CharacterClassClose" && s2.type !== "CharacterClassIntersector") {
555
+ const a = i2(t, { ...n, isCheckingRangeEnd: true });
556
+ if (d2.type === "Character" && a.type === "Character") return t.body.pop(), L(d2, a);
557
+ throw new Error("Invalid character class range");
558
+ }
559
+ return m(r$2("-"));
560
+ }
561
+ function re({ negate: e }, r2, n) {
562
+ const { tokens: o2, walk: i2 } = r2, t = [C()], d2 = o2[r2.nextIndex];
563
+ let s2 = z(d2);
564
+ for (; s2.type !== "CharacterClassClose"; ) {
565
+ if (s2.type === "CharacterClassIntersector") t.push(C()), r2.nextIndex++;
566
+ else {
567
+ const l2 = t.at(-1);
568
+ l2.body.push(i2(l2, n));
569
+ }
570
+ s2 = z(o2[r2.nextIndex], d2);
571
+ }
572
+ const a = C({ negate: e });
573
+ return t.length === 1 ? a.body = t[0].body : (a.kind = "intersection", a.body = t.map((l2) => l2.body.length === 1 ? l2.body[0] : l2)), r2.nextIndex++, a;
574
+ }
575
+ function ne({ kind: e, negate: r2, value: n }, o2) {
576
+ const { normalizeUnknownPropertyNames: i$1, skipPropertyNameValidation: t, unicodePropertyMap: d2 } = o2;
577
+ if (e === "property") {
578
+ const s2 = w(n);
579
+ if (i.has(s2) && !d2?.has(s2)) e = "posix", n = s2;
580
+ else return Q(n, { negate: r2, normalizeUnknownPropertyNames: i$1, skipPropertyNameValidation: t, unicodePropertyMap: d2 });
581
+ }
582
+ return e === "posix" ? R(n, { negate: r2 }) : E(e, { negate: r2 });
583
+ }
584
+ function te(e, r2, n) {
585
+ const { tokens: o2, capturingGroups: i2, namedGroupsByName: t, skipLookbehindValidation: d2, walk: s2 } = r2, a = ie(e), l2 = a.type === "AbsenceFunction", c = $(a), f2 = c && a.negate;
586
+ if (a.type === "CapturingGroup" && (i2.push(a), a.name && l$1(t, a.name, []).push(a)), l2 && n.isInAbsenceFunction) throw new Error("Nested absence function not supported by Oniguruma");
587
+ let p = D(o2[r2.nextIndex]);
588
+ for (; p.type !== "GroupClose"; ) {
589
+ if (p.type === "Alternator") a.body.push(b()), r2.nextIndex++;
590
+ else {
591
+ const N = a.body.at(-1), u2 = s2(N, { ...n, isInAbsenceFunction: n.isInAbsenceFunction || l2, isInLookbehind: n.isInLookbehind || c, isInNegLookbehind: n.isInNegLookbehind || f2 });
592
+ if (N.body.push(u2), (c || n.isInLookbehind) && !d2) {
593
+ const v2 = "Lookbehind includes a pattern not allowed by Oniguruma";
594
+ if (f2 || n.isInNegLookbehind) {
595
+ if (M(u2) || u2.type === "CapturingGroup") throw new Error(v2);
596
+ } else if (M(u2) || $(u2) && u2.negate) throw new Error(v2);
597
+ }
598
+ }
599
+ p = D(o2[r2.nextIndex]);
600
+ }
601
+ return r2.nextIndex++, a;
602
+ }
603
+ function oe({ kind: e, min: r2, max: n }, o2) {
604
+ const i2 = o2.parent, t = i2.body.at(-1);
605
+ if (!t || !s(t)) throw new Error("Quantifier requires a repeatable token");
606
+ const d2 = _(e, r2, n, t);
607
+ return i2.body.pop(), d2;
608
+ }
609
+ function ae({ raw: e }, r2) {
610
+ const { capturingGroups: n, subroutines: o2 } = r2;
611
+ let i2 = e.slice(3, -1);
612
+ const t = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i2);
613
+ if (t) {
614
+ const s2 = +t.groups.num, a = n.length;
615
+ if (r2.hasNumberedRef = true, i2 = { "": s2, "+": a + s2, "-": a + 1 - s2 }[t.groups.sign], i2 < 1) throw new Error("Invalid subroutine number");
616
+ } else i2 === "0" && (i2 = 0);
617
+ const d2 = O(i2);
618
+ return o2.push(d2), d2;
619
+ }
620
+ function G(e, r2) {
621
+ return { type: "AbsenceFunction", kind: e, body: h(r2?.body) };
622
+ }
623
+ function b(e) {
624
+ return { type: "Alternative", body: V(e?.body) };
625
+ }
626
+ function F(e, r2) {
627
+ const n = { type: "Assertion", kind: e };
628
+ return (e === "word_boundary" || e === "text_segment_boundary") && (n.negate = !!r2?.negate), n;
629
+ }
630
+ function k(e, r2) {
631
+ const n = !!r2?.orphan;
632
+ return { type: "Backreference", ref: e, ...n && { orphan: n } };
633
+ }
634
+ function P(e, r2) {
635
+ const n = { name: void 0, isSubroutined: false, ...r2 };
636
+ if (n.name !== void 0 && !se(n.name)) throw new Error(`Group name "${n.name}" invalid in Oniguruma`);
637
+ return { type: "CapturingGroup", number: e, ...n.name && { name: n.name }, ...n.isSubroutined && { isSubroutined: n.isSubroutined }, body: h(r2?.body) };
638
+ }
639
+ function m(e, r2) {
640
+ const n = { useLastValid: false, ...r2 };
641
+ if (e > 1114111) {
642
+ const o2 = e.toString(16);
643
+ if (n.useLastValid) e = 1114111;
644
+ else throw e > 1310719 ? new Error(`Invalid code point out of range "\\x{${o2}}"`) : new Error(`Invalid code point out of range in JS "\\x{${o2}}"`);
645
+ }
646
+ return { type: "Character", value: e };
647
+ }
648
+ function C(e) {
649
+ const r2 = { kind: "union", negate: false, ...e };
650
+ return { type: "CharacterClass", kind: r2.kind, negate: r2.negate, body: V(e?.body) };
651
+ }
652
+ function L(e, r2) {
653
+ if (r2.value < e.value) throw new Error("Character class range out of order");
654
+ return { type: "CharacterClassRange", min: e, max: r2 };
655
+ }
656
+ function E(e, r2) {
657
+ const n = !!r2?.negate, o2 = { type: "CharacterSet", kind: e };
658
+ return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (o2.negate = n), (e === "text_segment" || e === "newline" && !n) && (o2.variableLength = true), o2;
659
+ }
660
+ function I(e, r2 = {}) {
661
+ if (e === "keep") return { type: "Directive", kind: e };
662
+ if (e === "flags") return { type: "Directive", kind: e, flags: u(r2.flags) };
663
+ throw new Error(`Unexpected directive kind "${e}"`);
664
+ }
665
+ function T(e) {
666
+ return { type: "Flags", ...e };
667
+ }
668
+ function A(e) {
669
+ const r2 = e?.atomic, n = e?.flags;
670
+ if (r2 && n) throw new Error("Atomic group cannot have flags");
671
+ return { type: "Group", ...r2 && { atomic: r2 }, ...n && { flags: n }, body: h(e?.body) };
672
+ }
673
+ function K(e) {
674
+ const r2 = { behind: false, negate: false, ...e };
675
+ return { type: "LookaroundAssertion", kind: r2.behind ? "lookbehind" : "lookahead", negate: r2.negate, body: h(e?.body) };
676
+ }
677
+ function U(e, r2, n) {
678
+ return { type: "NamedCallout", kind: e, tag: r2, arguments: n };
679
+ }
680
+ function R(e, r2) {
681
+ const n = !!r2?.negate;
682
+ if (!i.has(e)) throw new Error(`Invalid POSIX class "${e}"`);
683
+ return { type: "CharacterSet", kind: "posix", value: e, negate: n };
684
+ }
685
+ function _(e, r2, n, o2) {
686
+ if (r2 > n) throw new Error("Invalid reversed quantifier range");
687
+ return { type: "Quantifier", kind: e, min: r2, max: n, body: o2 };
688
+ }
689
+ function B(e, r2) {
690
+ return { type: "Regex", body: h(r2?.body), flags: e };
691
+ }
692
+ function O(e) {
693
+ return { type: "Subroutine", ref: e };
694
+ }
695
+ function Q(e, r2) {
696
+ const n = { negate: false, normalizeUnknownPropertyNames: false, skipPropertyNameValidation: false, unicodePropertyMap: null, ...r2 };
697
+ let o2 = n.unicodePropertyMap?.get(w(e));
698
+ if (!o2) {
699
+ if (n.normalizeUnknownPropertyNames) o2 = de(e);
700
+ else if (n.unicodePropertyMap && !n.skipPropertyNameValidation) throw new Error(o$1`Invalid Unicode property "\p{${e}}"`);
701
+ }
702
+ return { type: "CharacterSet", kind: "property", value: o2 ?? e, negate: n.negate };
703
+ }
704
+ function ie({ flags: e, kind: r2, name: n, negate: o2, number: i2 }) {
705
+ switch (r2) {
706
+ case "absence_repeater":
707
+ return G("repeater");
708
+ case "atomic":
709
+ return A({ atomic: true });
710
+ case "capturing":
711
+ return P(i2, { name: n });
712
+ case "group":
713
+ return A({ flags: e });
714
+ case "lookahead":
715
+ case "lookbehind":
716
+ return K({ behind: r2 === "lookbehind", negate: o2 });
717
+ default:
718
+ throw new Error(`Unexpected group kind "${r2}"`);
719
+ }
720
+ }
721
+ function h(e) {
722
+ if (e === void 0) e = [b()];
723
+ else if (!Array.isArray(e) || !e.length || !e.every((r2) => r2.type === "Alternative")) throw new Error("Invalid body; expected array of one or more Alternative nodes");
724
+ return e;
725
+ }
726
+ function V(e) {
727
+ if (e === void 0) e = [];
728
+ else if (!Array.isArray(e) || !e.every((r2) => !!r2.type)) throw new Error("Invalid body; expected array of nodes");
729
+ return e;
730
+ }
731
+ function M(e) {
732
+ return e.type === "LookaroundAssertion" && e.kind === "lookahead";
733
+ }
734
+ function $(e) {
735
+ return e.type === "LookaroundAssertion" && e.kind === "lookbehind";
736
+ }
737
+ function se(e) {
738
+ return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e);
739
+ }
740
+ function de(e) {
741
+ return e.trim().replace(/[- _]+/g, "_").replace(/[A-Z][a-z]+(?=[A-Z])/g, "$&_").replace(/[A-Za-z]+/g, (r2) => r2[0].toUpperCase() + r2.slice(1).toLowerCase());
742
+ }
743
+ function w(e) {
744
+ return e.replace(/[- _]+/g, "").toLowerCase();
745
+ }
746
+ function z(e, r2) {
747
+ const n = r2;
748
+ return u(e, `Unclosed character class${n?.type === "Character" && n.value === 93 && n.raw === "]" ? ' (started with "]")' : ""}`);
749
+ }
750
+ function D(e) {
751
+ return u(e, "Unclosed group");
752
+ }
753
+ function S(a, v2, N = null) {
754
+ function b2(e, s2) {
755
+ for (let t = 0; t < e.length; t++) {
756
+ const r2 = n(e[t], s2, t, e);
757
+ t = Math.max(-1, t + r2);
758
+ }
759
+ }
760
+ function n(e, s2 = null, t = null, r2 = null) {
761
+ let i2 = 0, c = false;
762
+ const d2 = { node: e, parent: s2, key: t, container: r2, root: a, remove() {
763
+ x(r2).splice(Math.max(0, l(t) + i2), 1), i2--, c = true;
764
+ }, removeAllNextSiblings() {
765
+ return x(r2).splice(l(t) + 1);
766
+ }, removeAllPrevSiblings() {
767
+ const o2 = l(t) + i2;
768
+ return i2 -= o2, x(r2).splice(0, Math.max(0, o2));
769
+ }, replaceWith(o2, m2 = {}) {
770
+ const y2 = !!m2.traverse;
771
+ r2 ? r2[Math.max(0, l(t) + i2)] = o2 : u(s2, "Can't replace root node")[t] = o2, y2 && n(o2, s2, t, r2), c = true;
772
+ }, replaceWithMultiple(o2, m2 = {}) {
773
+ const y2 = !!m2.traverse;
774
+ if (x(r2).splice(Math.max(0, l(t) + i2), 1, ...o2), i2 += o2.length - 1, y2) {
775
+ let g = 0;
776
+ for (let p = 0; p < o2.length; p++) g += n(o2[p], s2, l(t) + p + g, r2);
777
+ }
778
+ c = true;
779
+ }, skip() {
780
+ c = true;
781
+ } }, { type: f2 } = e, u$1 = v2["*"], h2 = v2[f2], R2 = typeof u$1 == "function" ? u$1 : u$1?.enter, P2 = typeof h2 == "function" ? h2 : h2?.enter;
782
+ if (R2?.(d2, N), P2?.(d2, N), !c) switch (f2) {
783
+ case "AbsenceFunction":
784
+ case "Alternative":
785
+ case "CapturingGroup":
786
+ case "CharacterClass":
787
+ case "Group":
788
+ case "LookaroundAssertion":
789
+ b2(e.body, e);
790
+ break;
791
+ case "Assertion":
792
+ case "Backreference":
793
+ case "Character":
794
+ case "CharacterSet":
795
+ case "Directive":
796
+ case "Flags":
797
+ case "NamedCallout":
798
+ case "Subroutine":
799
+ break;
800
+ case "CharacterClassRange":
801
+ n(e.min, e, "min"), n(e.max, e, "max");
802
+ break;
803
+ case "Quantifier":
804
+ n(e.body, e, "body");
805
+ break;
806
+ case "Regex":
807
+ b2(e.body, e), n(e.flags, e, "flags");
808
+ break;
809
+ default:
810
+ throw new Error(`Unexpected node type "${f2}"`);
811
+ }
812
+ return h2?.exit?.(d2, N), u$1?.exit?.(d2, N), i2;
813
+ }
814
+ return n(a), a;
815
+ }
816
+ function x(a) {
817
+ if (!Array.isArray(a)) throw new Error("Container expected");
818
+ return a;
819
+ }
820
+ function l(a) {
821
+ if (typeof a != "number") throw new Error("Numeric key expected");
822
+ return a;
823
+ }
824
+ const noncapturingDelim = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
825
+ function incrementIfAtLeast$1(arr, threshold) {
826
+ for (let i2 = 0; i2 < arr.length; i2++) {
827
+ if (arr[i2] >= threshold) {
828
+ arr[i2]++;
829
+ }
830
+ }
831
+ }
832
+ function spliceStr(str, pos, oldValue, newValue) {
833
+ return str.slice(0, pos) + newValue + str.slice(pos + oldValue.length);
834
+ }
835
+ const Context = Object.freeze({
836
+ DEFAULT: "DEFAULT",
837
+ CHAR_CLASS: "CHAR_CLASS"
838
+ });
839
+ function replaceUnescaped(expression, needle, replacement, context) {
840
+ const re2 = new RegExp(String.raw`${needle}|(?<$skip>\[\^?|\\?.)`, "gsu");
841
+ const negated = [false];
842
+ let numCharClassesOpen = 0;
843
+ let result = "";
844
+ for (const match of expression.matchAll(re2)) {
845
+ const { 0: m2, groups: { $skip } } = match;
846
+ if (!$skip && (!context || context === Context.DEFAULT === !numCharClassesOpen)) {
847
+ if (replacement instanceof Function) {
848
+ result += replacement(match, {
849
+ context: numCharClassesOpen ? Context.CHAR_CLASS : Context.DEFAULT,
850
+ negated: negated[negated.length - 1]
851
+ });
852
+ } else {
853
+ result += replacement;
854
+ }
855
+ continue;
856
+ }
857
+ if (m2[0] === "[") {
858
+ numCharClassesOpen++;
859
+ negated.push(m2[1] === "^");
860
+ } else if (m2 === "]" && numCharClassesOpen) {
861
+ numCharClassesOpen--;
862
+ negated.pop();
863
+ }
864
+ result += m2;
865
+ }
866
+ return result;
867
+ }
868
+ function forEachUnescaped(expression, needle, callback, context) {
869
+ replaceUnescaped(expression, needle, callback, context);
870
+ }
871
+ function execUnescaped(expression, needle, pos = 0, context) {
872
+ if (!new RegExp(needle, "su").test(expression)) {
873
+ return null;
874
+ }
875
+ const re2 = new RegExp(`${needle}|(?<$skip>\\\\?.)`, "gsu");
876
+ re2.lastIndex = pos;
877
+ let numCharClassesOpen = 0;
878
+ let match;
879
+ while (match = re2.exec(expression)) {
880
+ const { 0: m2, groups: { $skip } } = match;
881
+ if (!$skip && (!context || context === Context.DEFAULT === !numCharClassesOpen)) {
882
+ return match;
883
+ }
884
+ if (m2 === "[") {
885
+ numCharClassesOpen++;
886
+ } else if (m2 === "]" && numCharClassesOpen) {
887
+ numCharClassesOpen--;
888
+ }
889
+ if (re2.lastIndex == match.index) {
890
+ re2.lastIndex++;
891
+ }
892
+ }
893
+ return null;
894
+ }
895
+ function hasUnescaped(expression, needle, context) {
896
+ return !!execUnescaped(expression, needle, 0, context);
897
+ }
898
+ function getGroupContents(expression, contentsStartPos) {
899
+ const token2 = /\\?./gsu;
900
+ token2.lastIndex = contentsStartPos;
901
+ let contentsEndPos = expression.length;
902
+ let numCharClassesOpen = 0;
903
+ let numGroupsOpen = 1;
904
+ let match;
905
+ while (match = token2.exec(expression)) {
906
+ const [m2] = match;
907
+ if (m2 === "[") {
908
+ numCharClassesOpen++;
909
+ } else if (!numCharClassesOpen) {
910
+ if (m2 === "(") {
911
+ numGroupsOpen++;
912
+ } else if (m2 === ")") {
913
+ numGroupsOpen--;
914
+ if (!numGroupsOpen) {
915
+ contentsEndPos = match.index;
916
+ break;
917
+ }
918
+ }
919
+ } else if (m2 === "]") {
920
+ numCharClassesOpen--;
921
+ }
922
+ }
923
+ return expression.slice(contentsStartPos, contentsEndPos);
924
+ }
925
+ const atomicPluginToken = new RegExp(String.raw`(?<noncapturingStart>${noncapturingDelim})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`, "gsu");
926
+ function atomic(expression, data) {
927
+ const hiddenCaptures = data?.hiddenCaptures ?? [];
928
+ let captureTransfers = data?.captureTransfers ?? /* @__PURE__ */ new Map();
929
+ if (!/\(\?>/.test(expression)) {
930
+ return {
931
+ pattern: expression,
932
+ captureTransfers,
933
+ hiddenCaptures
934
+ };
935
+ }
936
+ const aGDelim = "(?>";
937
+ const emulatedAGDelim = "(?:(?=(";
938
+ const captureNumMap = [0];
939
+ const addedHiddenCaptures = [];
940
+ let numCapturesBeforeAG = 0;
941
+ let numAGs = 0;
942
+ let aGPos = NaN;
943
+ let hasProcessedAG;
944
+ do {
945
+ hasProcessedAG = false;
946
+ let numCharClassesOpen = 0;
947
+ let numGroupsOpenInAG = 0;
948
+ let inAG = false;
949
+ let match;
950
+ atomicPluginToken.lastIndex = Number.isNaN(aGPos) ? 0 : aGPos + emulatedAGDelim.length;
951
+ while (match = atomicPluginToken.exec(expression)) {
952
+ const { 0: m2, index, groups: { capturingStart, noncapturingStart } } = match;
953
+ if (m2 === "[") {
954
+ numCharClassesOpen++;
955
+ } else if (!numCharClassesOpen) {
956
+ if (m2 === aGDelim && !inAG) {
957
+ aGPos = index;
958
+ inAG = true;
959
+ } else if (inAG && noncapturingStart) {
960
+ numGroupsOpenInAG++;
961
+ } else if (capturingStart) {
962
+ if (inAG) {
963
+ numGroupsOpenInAG++;
964
+ } else {
965
+ numCapturesBeforeAG++;
966
+ captureNumMap.push(numCapturesBeforeAG + numAGs);
967
+ }
968
+ } else if (m2 === ")" && inAG) {
969
+ if (!numGroupsOpenInAG) {
970
+ numAGs++;
971
+ const addedCaptureNum = numCapturesBeforeAG + numAGs;
972
+ expression = `${expression.slice(0, aGPos)}${emulatedAGDelim}${expression.slice(aGPos + aGDelim.length, index)}))<$$${addedCaptureNum}>)${expression.slice(index + 1)}`;
973
+ hasProcessedAG = true;
974
+ addedHiddenCaptures.push(addedCaptureNum);
975
+ incrementIfAtLeast$1(hiddenCaptures, addedCaptureNum);
976
+ if (captureTransfers.size) {
977
+ const newCaptureTransfers = /* @__PURE__ */ new Map();
978
+ captureTransfers.forEach((from, to) => {
979
+ newCaptureTransfers.set(
980
+ to >= addedCaptureNum ? to + 1 : to,
981
+ from.map((f2) => f2 >= addedCaptureNum ? f2 + 1 : f2)
982
+ );
983
+ });
984
+ captureTransfers = newCaptureTransfers;
985
+ }
986
+ break;
987
+ }
988
+ numGroupsOpenInAG--;
989
+ }
990
+ } else if (m2 === "]") {
991
+ numCharClassesOpen--;
992
+ }
993
+ }
994
+ } while (hasProcessedAG);
995
+ hiddenCaptures.push(...addedHiddenCaptures);
996
+ expression = replaceUnescaped(
997
+ expression,
998
+ String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,
999
+ ({ 0: m2, groups: { backrefNum, wrappedBackrefNum } }) => {
1000
+ if (backrefNum) {
1001
+ const bNum = +backrefNum;
1002
+ if (bNum > captureNumMap.length - 1) {
1003
+ throw new Error(`Backref "${m2}" greater than number of captures`);
1004
+ }
1005
+ return `\\${captureNumMap[bNum]}`;
1006
+ }
1007
+ return `\\${wrappedBackrefNum}`;
1008
+ },
1009
+ Context.DEFAULT
1010
+ );
1011
+ return {
1012
+ pattern: expression,
1013
+ captureTransfers,
1014
+ hiddenCaptures
1015
+ };
1016
+ }
1017
+ const baseQuantifier = String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`;
1018
+ const possessivePluginToken = new RegExp(String.raw`
1019
+ \\(?: \d+
1020
+ | c[A-Za-z]
1021
+ | [gk]<[^>]+>
1022
+ | [pPu]\{[^\}]+\}
1023
+ | u[A-Fa-f\d]{4}
1024
+ | x[A-Fa-f\d]{2}
1025
+ )
1026
+ | \((?: \? (?: [:=!>]
1027
+ | <(?:[=!]|[^>]+>)
1028
+ | [A-Za-z\-]+:
1029
+ | \(DEFINE\)
1030
+ ))?
1031
+ | (?<qBase>${baseQuantifier})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
1032
+ | \\?.
1033
+ `.replace(/\s+/g, ""), "gsu");
1034
+ function possessive(expression) {
1035
+ if (!new RegExp(`${baseQuantifier}\\+`).test(expression)) {
1036
+ return {
1037
+ pattern: expression
1038
+ };
1039
+ }
1040
+ const openGroupIndices = [];
1041
+ let lastGroupIndex = null;
1042
+ let lastCharClassIndex = null;
1043
+ let lastToken = "";
1044
+ let numCharClassesOpen = 0;
1045
+ let match;
1046
+ possessivePluginToken.lastIndex = 0;
1047
+ while (match = possessivePluginToken.exec(expression)) {
1048
+ const { 0: m2, index, groups: { qBase, qMod, invalidQ } } = match;
1049
+ if (m2 === "[") {
1050
+ if (!numCharClassesOpen) {
1051
+ lastCharClassIndex = index;
1052
+ }
1053
+ numCharClassesOpen++;
1054
+ } else if (m2 === "]") {
1055
+ if (numCharClassesOpen) {
1056
+ numCharClassesOpen--;
1057
+ } else {
1058
+ lastCharClassIndex = null;
1059
+ }
1060
+ } else if (!numCharClassesOpen) {
1061
+ if (qMod === "+" && lastToken && !lastToken.startsWith("(")) {
1062
+ if (invalidQ) {
1063
+ throw new Error(`Invalid quantifier "${m2}"`);
1064
+ }
1065
+ let charsAdded = -1;
1066
+ if (/^\{\d+\}$/.test(qBase)) {
1067
+ expression = spliceStr(expression, index + qBase.length, qMod, "");
1068
+ } else {
1069
+ if (lastToken === ")" || lastToken === "]") {
1070
+ const nodeIndex = lastToken === ")" ? lastGroupIndex : lastCharClassIndex;
1071
+ if (nodeIndex === null) {
1072
+ throw new Error(`Invalid unmatched "${lastToken}"`);
1073
+ }
1074
+ expression = `${expression.slice(0, nodeIndex)}(?>${expression.slice(nodeIndex, index)}${qBase})${expression.slice(index + m2.length)}`;
1075
+ } else {
1076
+ expression = `${expression.slice(0, index - lastToken.length)}(?>${lastToken}${qBase})${expression.slice(index + m2.length)}`;
1077
+ }
1078
+ charsAdded += 4;
1079
+ }
1080
+ possessivePluginToken.lastIndex += charsAdded;
1081
+ } else if (m2[0] === "(") {
1082
+ openGroupIndices.push(index);
1083
+ } else if (m2 === ")") {
1084
+ lastGroupIndex = openGroupIndices.length ? openGroupIndices.pop() : null;
1085
+ }
1086
+ }
1087
+ lastToken = m2;
1088
+ }
1089
+ return {
1090
+ pattern: expression
1091
+ };
1092
+ }
1093
+ const r$1 = String.raw;
1094
+ const gRToken = r$1`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`;
1095
+ const recursiveToken = r$1`\(\?R=(?<rDepth>[^\)]+)\)|${gRToken}`;
1096
+ const namedCaptureDelim = r$1`\(\?<(?![=!])(?<captureName>[^>]+)>`;
1097
+ const captureDelim = r$1`${namedCaptureDelim}|(?<unnamed>\()(?!\?)`;
1098
+ const token = new RegExp(r$1`${namedCaptureDelim}|${recursiveToken}|\(\?|\\?.`, "gsu");
1099
+ const overlappingRecursionMsg = "Cannot use multiple overlapping recursions";
1100
+ function recursion(pattern, data) {
1101
+ const { hiddenCaptures, mode } = {
1102
+ hiddenCaptures: [],
1103
+ mode: "plugin",
1104
+ ...data
1105
+ };
1106
+ let captureTransfers = data?.captureTransfers ?? /* @__PURE__ */ new Map();
1107
+ if (!new RegExp(recursiveToken, "su").test(pattern)) {
1108
+ return {
1109
+ pattern,
1110
+ captureTransfers,
1111
+ hiddenCaptures
1112
+ };
1113
+ }
1114
+ if (mode === "plugin" && hasUnescaped(pattern, r$1`\(\?\(DEFINE\)`, Context.DEFAULT)) {
1115
+ throw new Error("DEFINE groups cannot be used with recursion");
1116
+ }
1117
+ const addedHiddenCaptures = [];
1118
+ const hasNumberedBackref = hasUnescaped(pattern, r$1`\\[1-9]`, Context.DEFAULT);
1119
+ const groupContentsStartPos = /* @__PURE__ */ new Map();
1120
+ const openGroups = [];
1121
+ let hasRecursed = false;
1122
+ let numCharClassesOpen = 0;
1123
+ let numCapturesPassed = 0;
1124
+ let match;
1125
+ token.lastIndex = 0;
1126
+ while (match = token.exec(pattern)) {
1127
+ const { 0: m2, groups: { captureName, rDepth, gRNameOrNum, gRDepth } } = match;
1128
+ if (m2 === "[") {
1129
+ numCharClassesOpen++;
1130
+ } else if (!numCharClassesOpen) {
1131
+ if (rDepth) {
1132
+ assertMaxInBounds(rDepth);
1133
+ if (hasRecursed) {
1134
+ throw new Error(overlappingRecursionMsg);
1135
+ }
1136
+ if (hasNumberedBackref) {
1137
+ throw new Error(
1138
+ // When used in `external` mode by transpilers other than Regex+, backrefs might have
1139
+ // gone through conversion from named to numbered, so avoid a misleading error
1140
+ `${mode === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with global recursion`
1141
+ );
1142
+ }
1143
+ const left = pattern.slice(0, match.index);
1144
+ const right = pattern.slice(token.lastIndex);
1145
+ if (hasUnescaped(right, recursiveToken, Context.DEFAULT)) {
1146
+ throw new Error(overlappingRecursionMsg);
1147
+ }
1148
+ const reps = +rDepth - 1;
1149
+ pattern = makeRecursive(
1150
+ left,
1151
+ right,
1152
+ reps,
1153
+ false,
1154
+ hiddenCaptures,
1155
+ addedHiddenCaptures,
1156
+ numCapturesPassed
1157
+ );
1158
+ captureTransfers = mapCaptureTransfers(
1159
+ captureTransfers,
1160
+ left,
1161
+ reps,
1162
+ addedHiddenCaptures.length,
1163
+ 0,
1164
+ numCapturesPassed
1165
+ );
1166
+ break;
1167
+ } else if (gRNameOrNum) {
1168
+ assertMaxInBounds(gRDepth);
1169
+ let isWithinReffedGroup = false;
1170
+ for (const g of openGroups) {
1171
+ if (g.name === gRNameOrNum || g.num === +gRNameOrNum) {
1172
+ isWithinReffedGroup = true;
1173
+ if (g.hasRecursedWithin) {
1174
+ throw new Error(overlappingRecursionMsg);
1175
+ }
1176
+ break;
1177
+ }
1178
+ }
1179
+ if (!isWithinReffedGroup) {
1180
+ throw new Error(r$1`Recursive \g cannot be used outside the referenced group "${mode === "external" ? gRNameOrNum : r$1`\g<${gRNameOrNum}&R=${gRDepth}>`}"`);
1181
+ }
1182
+ const startPos = groupContentsStartPos.get(gRNameOrNum);
1183
+ const groupContents = getGroupContents(pattern, startPos);
1184
+ if (hasNumberedBackref && hasUnescaped(groupContents, r$1`${namedCaptureDelim}|\((?!\?)`, Context.DEFAULT)) {
1185
+ throw new Error(
1186
+ // When used in `external` mode by transpilers other than Regex+, backrefs might have
1187
+ // gone through conversion from named to numbered, so avoid a misleading error
1188
+ `${mode === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with recursion of capturing groups`
1189
+ );
1190
+ }
1191
+ const groupContentsLeft = pattern.slice(startPos, match.index);
1192
+ const groupContentsRight = groupContents.slice(groupContentsLeft.length + m2.length);
1193
+ const numAddedHiddenCapturesPreExpansion = addedHiddenCaptures.length;
1194
+ const reps = +gRDepth - 1;
1195
+ const expansion = makeRecursive(
1196
+ groupContentsLeft,
1197
+ groupContentsRight,
1198
+ reps,
1199
+ true,
1200
+ hiddenCaptures,
1201
+ addedHiddenCaptures,
1202
+ numCapturesPassed
1203
+ );
1204
+ captureTransfers = mapCaptureTransfers(
1205
+ captureTransfers,
1206
+ groupContentsLeft,
1207
+ reps,
1208
+ addedHiddenCaptures.length - numAddedHiddenCapturesPreExpansion,
1209
+ numAddedHiddenCapturesPreExpansion,
1210
+ numCapturesPassed
1211
+ );
1212
+ const pre = pattern.slice(0, startPos);
1213
+ const post = pattern.slice(startPos + groupContents.length);
1214
+ pattern = `${pre}${expansion}${post}`;
1215
+ token.lastIndex += expansion.length - m2.length - groupContentsLeft.length - groupContentsRight.length;
1216
+ openGroups.forEach((g) => g.hasRecursedWithin = true);
1217
+ hasRecursed = true;
1218
+ } else if (captureName) {
1219
+ numCapturesPassed++;
1220
+ groupContentsStartPos.set(String(numCapturesPassed), token.lastIndex);
1221
+ groupContentsStartPos.set(captureName, token.lastIndex);
1222
+ openGroups.push({
1223
+ num: numCapturesPassed,
1224
+ name: captureName
1225
+ });
1226
+ } else if (m2[0] === "(") {
1227
+ const isUnnamedCapture = m2 === "(";
1228
+ if (isUnnamedCapture) {
1229
+ numCapturesPassed++;
1230
+ groupContentsStartPos.set(String(numCapturesPassed), token.lastIndex);
1231
+ }
1232
+ openGroups.push(isUnnamedCapture ? { num: numCapturesPassed } : {});
1233
+ } else if (m2 === ")") {
1234
+ openGroups.pop();
1235
+ }
1236
+ } else if (m2 === "]") {
1237
+ numCharClassesOpen--;
1238
+ }
1239
+ }
1240
+ hiddenCaptures.push(...addedHiddenCaptures);
1241
+ return {
1242
+ pattern,
1243
+ captureTransfers,
1244
+ hiddenCaptures
1245
+ };
1246
+ }
1247
+ function assertMaxInBounds(max) {
1248
+ const errMsg = `Max depth must be integer between 2 and 100; used ${max}`;
1249
+ if (!/^[1-9]\d*$/.test(max)) {
1250
+ throw new Error(errMsg);
1251
+ }
1252
+ max = +max;
1253
+ if (max < 2 || max > 100) {
1254
+ throw new Error(errMsg);
1255
+ }
1256
+ }
1257
+ function makeRecursive(left, right, reps, isSubpattern, hiddenCaptures, addedHiddenCaptures, numCapturesPassed) {
1258
+ const namesInRecursed = /* @__PURE__ */ new Set();
1259
+ if (isSubpattern) {
1260
+ forEachUnescaped(left + right, namedCaptureDelim, ({ groups: { captureName } }) => {
1261
+ namesInRecursed.add(captureName);
1262
+ }, Context.DEFAULT);
1263
+ }
1264
+ const rest = [
1265
+ reps,
1266
+ isSubpattern ? namesInRecursed : null,
1267
+ hiddenCaptures,
1268
+ addedHiddenCaptures,
1269
+ numCapturesPassed
1270
+ ];
1271
+ return `${left}${repeatWithDepth(`(?:${left}`, "forward", ...rest)}(?:)${repeatWithDepth(`${right})`, "backward", ...rest)}${right}`;
1272
+ }
1273
+ function repeatWithDepth(pattern, direction, reps, namesInRecursed, hiddenCaptures, addedHiddenCaptures, numCapturesPassed) {
1274
+ const startNum = 2;
1275
+ const getDepthNum = (i2) => direction === "forward" ? i2 + startNum : reps - i2 + startNum - 1;
1276
+ let result = "";
1277
+ for (let i2 = 0; i2 < reps; i2++) {
1278
+ const depthNum = getDepthNum(i2);
1279
+ result += replaceUnescaped(
1280
+ pattern,
1281
+ r$1`${captureDelim}|\\k<(?<backref>[^>]+)>`,
1282
+ ({ 0: m2, groups: { captureName, unnamed, backref } }) => {
1283
+ if (backref && namesInRecursed && !namesInRecursed.has(backref)) {
1284
+ return m2;
1285
+ }
1286
+ const suffix = `_$${depthNum}`;
1287
+ if (unnamed || captureName) {
1288
+ const addedCaptureNum = numCapturesPassed + addedHiddenCaptures.length + 1;
1289
+ addedHiddenCaptures.push(addedCaptureNum);
1290
+ incrementIfAtLeast(hiddenCaptures, addedCaptureNum);
1291
+ return unnamed ? m2 : `(?<${captureName}${suffix}>`;
1292
+ }
1293
+ return r$1`\k<${backref}${suffix}>`;
1294
+ },
1295
+ Context.DEFAULT
1296
+ );
1297
+ }
1298
+ return result;
1299
+ }
1300
+ function incrementIfAtLeast(arr, threshold) {
1301
+ for (let i2 = 0; i2 < arr.length; i2++) {
1302
+ if (arr[i2] >= threshold) {
1303
+ arr[i2]++;
1304
+ }
1305
+ }
1306
+ }
1307
+ function mapCaptureTransfers(captureTransfers, left, reps, numCapturesAddedInExpansion, numAddedHiddenCapturesPreExpansion, numCapturesPassed) {
1308
+ if (captureTransfers.size && numCapturesAddedInExpansion) {
1309
+ let numCapturesInLeft = 0;
1310
+ forEachUnescaped(left, captureDelim, () => numCapturesInLeft++, Context.DEFAULT);
1311
+ const recursionDelimCaptureNum = numCapturesPassed - numCapturesInLeft + numAddedHiddenCapturesPreExpansion;
1312
+ const newCaptureTransfers = /* @__PURE__ */ new Map();
1313
+ captureTransfers.forEach((from, to) => {
1314
+ const numCapturesInRight = (numCapturesAddedInExpansion - numCapturesInLeft * reps) / reps;
1315
+ const numCapturesAddedInLeft = numCapturesInLeft * reps;
1316
+ const newTo = to > recursionDelimCaptureNum + numCapturesInLeft ? to + numCapturesAddedInExpansion : to;
1317
+ const newFrom = [];
1318
+ for (const f2 of from) {
1319
+ if (f2 <= recursionDelimCaptureNum) {
1320
+ newFrom.push(f2);
1321
+ } else if (f2 > recursionDelimCaptureNum + numCapturesInLeft + numCapturesInRight) {
1322
+ newFrom.push(f2 + numCapturesAddedInExpansion);
1323
+ } else if (f2 <= recursionDelimCaptureNum + numCapturesInLeft) {
1324
+ for (let i2 = 0; i2 <= reps; i2++) {
1325
+ newFrom.push(f2 + numCapturesInLeft * i2);
1326
+ }
1327
+ } else {
1328
+ for (let i2 = 0; i2 <= reps; i2++) {
1329
+ newFrom.push(f2 + numCapturesAddedInLeft + numCapturesInRight * i2);
1330
+ }
1331
+ }
1332
+ }
1333
+ newCaptureTransfers.set(newTo, newFrom);
1334
+ });
1335
+ return newCaptureTransfers;
1336
+ }
1337
+ return captureTransfers;
1338
+ }
1339
+ var cp = String.fromCodePoint;
1340
+ var r = String.raw;
1341
+ var envFlags = {};
1342
+ var globalRegExp = globalThis.RegExp;
1343
+ envFlags.flagGroups = (() => {
1344
+ try {
1345
+ new globalRegExp("(?i:)");
1346
+ } catch {
1347
+ return false;
1348
+ }
1349
+ return true;
1350
+ })();
1351
+ envFlags.unicodeSets = (() => {
1352
+ try {
1353
+ new globalRegExp("[[]]", "v");
1354
+ } catch {
1355
+ return false;
1356
+ }
1357
+ return true;
1358
+ })();
1359
+ envFlags.bugFlagVLiteralHyphenIsRange = envFlags.unicodeSets ? (() => {
1360
+ try {
1361
+ new globalRegExp(r`[\d\-a]`, "v");
1362
+ } catch {
1363
+ return true;
1364
+ }
1365
+ return false;
1366
+ })() : false;
1367
+ envFlags.bugNestedClassIgnoresNegation = envFlags.unicodeSets && new globalRegExp("[[^a]]", "v").test("a");
1368
+ function getNewCurrentFlags(current, { enable, disable }) {
1369
+ return {
1370
+ dotAll: !disable?.dotAll && !!(enable?.dotAll || current.dotAll),
1371
+ ignoreCase: !disable?.ignoreCase && !!(enable?.ignoreCase || current.ignoreCase)
1372
+ };
1373
+ }
1374
+ function getOrInsert(map, key, defaultValue) {
1375
+ if (!map.has(key)) {
1376
+ map.set(key, defaultValue);
1377
+ }
1378
+ return map.get(key);
1379
+ }
1380
+ function isMinTarget(target, min) {
1381
+ return EsVersion[target] >= EsVersion[min];
1382
+ }
1383
+ function throwIfNullish(value, msg) {
1384
+ if (value == null) {
1385
+ throw new Error(msg ?? "Value expected");
1386
+ }
1387
+ return value;
1388
+ }
1389
+ var EsVersion = {
1390
+ ES2025: 2025,
1391
+ ES2024: 2024,
1392
+ ES2018: 2018
1393
+ };
1394
+ var Target = (
1395
+ /** @type {const} */
1396
+ {
1397
+ auto: "auto",
1398
+ ES2025: "ES2025",
1399
+ ES2024: "ES2024",
1400
+ ES2018: "ES2018"
1401
+ }
1402
+ );
1403
+ function getOptions(options = {}) {
1404
+ if ({}.toString.call(options) !== "[object Object]") {
1405
+ throw new Error("Unexpected options");
1406
+ }
1407
+ if (options.target !== void 0 && !Target[options.target]) {
1408
+ throw new Error(`Unexpected target "${options.target}"`);
1409
+ }
1410
+ const opts = {
1411
+ // Sets the level of emulation rigor/strictness.
1412
+ accuracy: "default",
1413
+ // Disables advanced emulation that relies on returning a `RegExp` subclass, resulting in
1414
+ // certain patterns not being emulatable.
1415
+ avoidSubclass: false,
1416
+ // Oniguruma flags; a string with `i`, `m`, `x`, `D`, `S`, `W`, `y{g}` in any order (all
1417
+ // optional). Oniguruma's `m` is equivalent to JavaScript's `s` (`dotAll`).
1418
+ flags: "",
1419
+ // Include JavaScript flag `g` (`global`) in the result.
1420
+ global: false,
1421
+ // Include JavaScript flag `d` (`hasIndices`) in the result.
1422
+ hasIndices: false,
1423
+ // Delay regex construction until first use if the transpiled pattern is at least this length.
1424
+ lazyCompileLength: Infinity,
1425
+ // JavaScript version used for generated regexes. Using `auto` detects the best value based on
1426
+ // your environment. Later targets allow faster processing, simpler generated source, and
1427
+ // support for additional features.
1428
+ target: "auto",
1429
+ // Disables minifications that simplify the pattern without changing the meaning.
1430
+ verbose: false,
1431
+ ...options,
1432
+ // Advanced options that override standard behavior, error checking, and flags when enabled.
1433
+ rules: {
1434
+ // Useful with TextMate grammars that merge backreferences across patterns.
1435
+ allowOrphanBackrefs: false,
1436
+ // Use ASCII `\b` and `\B`, which increases search performance of generated regexes.
1437
+ asciiWordBoundaries: false,
1438
+ // Allow unnamed captures and numbered calls (backreferences and subroutines) when using
1439
+ // named capture. This is Oniguruma option `ONIG_OPTION_CAPTURE_GROUP`; on by default in
1440
+ // `vscode-oniguruma`.
1441
+ captureGroup: false,
1442
+ // Change the recursion depth limit from Oniguruma's `20` to an integer `2`–`20`.
1443
+ recursionLimit: 20,
1444
+ // `^` as `\A`; `$` as`\Z`. Improves search performance of generated regexes without changing
1445
+ // the meaning if searching line by line. This is Oniguruma option `ONIG_OPTION_SINGLELINE`.
1446
+ singleline: false,
1447
+ ...options.rules
1448
+ }
1449
+ };
1450
+ if (opts.target === "auto") {
1451
+ opts.target = envFlags.flagGroups ? "ES2025" : envFlags.unicodeSets ? "ES2024" : "ES2018";
1452
+ }
1453
+ return opts;
1454
+ }
1455
+ var asciiSpaceChar = "[ -\r ]";
1456
+ var CharsWithoutIgnoreCaseExpansion = /* @__PURE__ */ new Set([
1457
+ cp(304),
1458
+ // İ
1459
+ cp(305)
1460
+ // ı
1461
+ ]);
1462
+ var defaultWordChar = r`[\p{L}\p{M}\p{N}\p{Pc}]`;
1463
+ function getIgnoreCaseMatchChars(char) {
1464
+ if (CharsWithoutIgnoreCaseExpansion.has(char)) {
1465
+ return [char];
1466
+ }
1467
+ const set = /* @__PURE__ */ new Set();
1468
+ const lower = char.toLowerCase();
1469
+ const upper = lower.toUpperCase();
1470
+ const title = LowerToTitleCaseMap.get(lower);
1471
+ const altLower = LowerToAlternativeLowerCaseMap.get(lower);
1472
+ const altUpper = LowerToAlternativeUpperCaseMap.get(lower);
1473
+ if ([...upper].length === 1) {
1474
+ set.add(upper);
1475
+ }
1476
+ altUpper && set.add(altUpper);
1477
+ title && set.add(title);
1478
+ set.add(lower);
1479
+ altLower && set.add(altLower);
1480
+ return [...set];
1481
+ }
1482
+ var JsUnicodePropertyMap = /* @__PURE__ */ new Map(
1483
+ `C Other
1484
+ Cc Control cntrl
1485
+ Cf Format
1486
+ Cn Unassigned
1487
+ Co Private_Use
1488
+ Cs Surrogate
1489
+ L Letter
1490
+ LC Cased_Letter
1491
+ Ll Lowercase_Letter
1492
+ Lm Modifier_Letter
1493
+ Lo Other_Letter
1494
+ Lt Titlecase_Letter
1495
+ Lu Uppercase_Letter
1496
+ M Mark Combining_Mark
1497
+ Mc Spacing_Mark
1498
+ Me Enclosing_Mark
1499
+ Mn Nonspacing_Mark
1500
+ N Number
1501
+ Nd Decimal_Number digit
1502
+ Nl Letter_Number
1503
+ No Other_Number
1504
+ P Punctuation punct
1505
+ Pc Connector_Punctuation
1506
+ Pd Dash_Punctuation
1507
+ Pe Close_Punctuation
1508
+ Pf Final_Punctuation
1509
+ Pi Initial_Punctuation
1510
+ Po Other_Punctuation
1511
+ Ps Open_Punctuation
1512
+ S Symbol
1513
+ Sc Currency_Symbol
1514
+ Sk Modifier_Symbol
1515
+ Sm Math_Symbol
1516
+ So Other_Symbol
1517
+ Z Separator
1518
+ Zl Line_Separator
1519
+ Zp Paragraph_Separator
1520
+ Zs Space_Separator
1521
+ ASCII
1522
+ ASCII_Hex_Digit AHex
1523
+ Alphabetic Alpha
1524
+ Any
1525
+ Assigned
1526
+ Bidi_Control Bidi_C
1527
+ Bidi_Mirrored Bidi_M
1528
+ Case_Ignorable CI
1529
+ Cased
1530
+ Changes_When_Casefolded CWCF
1531
+ Changes_When_Casemapped CWCM
1532
+ Changes_When_Lowercased CWL
1533
+ Changes_When_NFKC_Casefolded CWKCF
1534
+ Changes_When_Titlecased CWT
1535
+ Changes_When_Uppercased CWU
1536
+ Dash
1537
+ Default_Ignorable_Code_Point DI
1538
+ Deprecated Dep
1539
+ Diacritic Dia
1540
+ Emoji
1541
+ Emoji_Component EComp
1542
+ Emoji_Modifier EMod
1543
+ Emoji_Modifier_Base EBase
1544
+ Emoji_Presentation EPres
1545
+ Extended_Pictographic ExtPict
1546
+ Extender Ext
1547
+ Grapheme_Base Gr_Base
1548
+ Grapheme_Extend Gr_Ext
1549
+ Hex_Digit Hex
1550
+ IDS_Binary_Operator IDSB
1551
+ IDS_Trinary_Operator IDST
1552
+ ID_Continue IDC
1553
+ ID_Start IDS
1554
+ Ideographic Ideo
1555
+ Join_Control Join_C
1556
+ Logical_Order_Exception LOE
1557
+ Lowercase Lower
1558
+ Math
1559
+ Noncharacter_Code_Point NChar
1560
+ Pattern_Syntax Pat_Syn
1561
+ Pattern_White_Space Pat_WS
1562
+ Quotation_Mark QMark
1563
+ Radical
1564
+ Regional_Indicator RI
1565
+ Sentence_Terminal STerm
1566
+ Soft_Dotted SD
1567
+ Terminal_Punctuation Term
1568
+ Unified_Ideograph UIdeo
1569
+ Uppercase Upper
1570
+ Variation_Selector VS
1571
+ White_Space space
1572
+ XID_Continue XIDC
1573
+ XID_Start XIDS`.split(/\s/).map((p) => [w(p), p])
1574
+ );
1575
+ var LowerToAlternativeLowerCaseMap = /* @__PURE__ */ new Map([
1576
+ ["s", cp(383)],
1577
+ // s, ſ
1578
+ [cp(383), "s"]
1579
+ // ſ, s
1580
+ ]);
1581
+ var LowerToAlternativeUpperCaseMap = /* @__PURE__ */ new Map([
1582
+ [cp(223), cp(7838)],
1583
+ // ß, ẞ
1584
+ [cp(107), cp(8490)],
1585
+ // k, K (Kelvin)
1586
+ [cp(229), cp(8491)],
1587
+ // å, Å (Angstrom)
1588
+ [cp(969), cp(8486)]
1589
+ // ω, Ω (Ohm)
1590
+ ]);
1591
+ var LowerToTitleCaseMap = new Map([
1592
+ titleEntry(453),
1593
+ titleEntry(456),
1594
+ titleEntry(459),
1595
+ titleEntry(498),
1596
+ ...titleRange(8072, 8079),
1597
+ ...titleRange(8088, 8095),
1598
+ ...titleRange(8104, 8111),
1599
+ titleEntry(8124),
1600
+ titleEntry(8140),
1601
+ titleEntry(8188)
1602
+ ]);
1603
+ var PosixClassMap = /* @__PURE__ */ new Map([
1604
+ ["alnum", r`[\p{Alpha}\p{Nd}]`],
1605
+ ["alpha", r`\p{Alpha}`],
1606
+ ["ascii", r`\p{ASCII}`],
1607
+ ["blank", r`[\p{Zs}\t]`],
1608
+ ["cntrl", r`\p{Cc}`],
1609
+ ["digit", r`\p{Nd}`],
1610
+ ["graph", r`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],
1611
+ ["lower", r`\p{Lower}`],
1612
+ ["print", r`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],
1613
+ ["punct", r`[\p{P}\p{S}]`],
1614
+ // Updated value from Onig 6.9.9; changed from Unicode `\p{punct}`
1615
+ ["space", r`\p{space}`],
1616
+ ["upper", r`\p{Upper}`],
1617
+ ["word", r`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],
1618
+ ["xdigit", r`\p{AHex}`]
1619
+ ]);
1620
+ function range(start, end) {
1621
+ const range2 = [];
1622
+ for (let i2 = start; i2 <= end; i2++) {
1623
+ range2.push(i2);
1624
+ }
1625
+ return range2;
1626
+ }
1627
+ function titleEntry(codePoint) {
1628
+ const char = cp(codePoint);
1629
+ return [char.toLowerCase(), char];
1630
+ }
1631
+ function titleRange(start, end) {
1632
+ return range(start, end).map((codePoint) => titleEntry(codePoint));
1633
+ }
1634
+ var UnicodePropertiesWithSpecificCase = /* @__PURE__ */ new Set([
1635
+ "Lower",
1636
+ "Lowercase",
1637
+ "Upper",
1638
+ "Uppercase",
1639
+ "Ll",
1640
+ "Lowercase_Letter",
1641
+ "Lt",
1642
+ "Titlecase_Letter",
1643
+ "Lu",
1644
+ "Uppercase_Letter"
1645
+ // The `Changes_When_*` properties (and their aliases) could be included, but they're very rare.
1646
+ // Some other properties include a handful of chars with specific cases only, but these chars are
1647
+ // generally extreme edge cases and using such properties case insensitively generally produces
1648
+ // undesired behavior anyway
1649
+ ]);
1650
+ function transform(ast, options) {
1651
+ const opts = {
1652
+ // A couple edge cases exist where options `accuracy` and `bestEffortTarget` are used:
1653
+ // - `CharacterSet` kind `text_segment` (`\X`): An exact representation would require heavy
1654
+ // Unicode data; a best-effort approximation requires knowing the target.
1655
+ // - `CharacterSet` kind `posix` with values `graph` and `print`: Their complex Unicode
1656
+ // representations would be hard to change to ASCII versions after the fact in the generator
1657
+ // based on `target`/`accuracy`, so produce the appropriate structure here.
1658
+ accuracy: "default",
1659
+ asciiWordBoundaries: false,
1660
+ avoidSubclass: false,
1661
+ bestEffortTarget: "ES2025",
1662
+ ...options
1663
+ };
1664
+ addParentProperties(ast);
1665
+ const firstPassState = {
1666
+ accuracy: opts.accuracy,
1667
+ asciiWordBoundaries: opts.asciiWordBoundaries,
1668
+ avoidSubclass: opts.avoidSubclass,
1669
+ flagDirectivesByAlt: /* @__PURE__ */ new Map(),
1670
+ jsGroupNameMap: /* @__PURE__ */ new Map(),
1671
+ minTargetEs2024: isMinTarget(opts.bestEffortTarget, "ES2024"),
1672
+ passedLookbehind: false,
1673
+ strategy: null,
1674
+ // Subroutines can appear before the groups they ref, so collect reffed nodes for a second pass
1675
+ subroutineRefMap: /* @__PURE__ */ new Map(),
1676
+ supportedGNodes: /* @__PURE__ */ new Set(),
1677
+ digitIsAscii: ast.flags.digitIsAscii,
1678
+ spaceIsAscii: ast.flags.spaceIsAscii,
1679
+ wordIsAscii: ast.flags.wordIsAscii
1680
+ };
1681
+ S(ast, FirstPassVisitor, firstPassState);
1682
+ const globalFlags = {
1683
+ dotAll: ast.flags.dotAll,
1684
+ ignoreCase: ast.flags.ignoreCase
1685
+ };
1686
+ const secondPassState = {
1687
+ currentFlags: globalFlags,
1688
+ prevFlags: null,
1689
+ globalFlags,
1690
+ groupOriginByCopy: /* @__PURE__ */ new Map(),
1691
+ groupsByName: /* @__PURE__ */ new Map(),
1692
+ multiplexCapturesToLeftByRef: /* @__PURE__ */ new Map(),
1693
+ openRefs: /* @__PURE__ */ new Map(),
1694
+ reffedNodesByReferencer: /* @__PURE__ */ new Map(),
1695
+ subroutineRefMap: firstPassState.subroutineRefMap
1696
+ };
1697
+ S(ast, SecondPassVisitor, secondPassState);
1698
+ const thirdPassState = {
1699
+ groupsByName: secondPassState.groupsByName,
1700
+ highestOrphanBackref: 0,
1701
+ numCapturesToLeft: 0,
1702
+ reffedNodesByReferencer: secondPassState.reffedNodesByReferencer
1703
+ };
1704
+ S(ast, ThirdPassVisitor, thirdPassState);
1705
+ ast._originMap = secondPassState.groupOriginByCopy;
1706
+ ast._strategy = firstPassState.strategy;
1707
+ return ast;
1708
+ }
1709
+ var FirstPassVisitor = {
1710
+ AbsenceFunction({ node, parent, replaceWith }) {
1711
+ const { body, kind } = node;
1712
+ if (kind === "repeater") {
1713
+ const innerGroup = A();
1714
+ innerGroup.body[0].body.push(
1715
+ // Insert own alts as `body`
1716
+ K({ negate: true, body }),
1717
+ Q("Any")
1718
+ );
1719
+ const outerGroup = A();
1720
+ outerGroup.body[0].body.push(
1721
+ _("greedy", 0, Infinity, innerGroup)
1722
+ );
1723
+ replaceWith(setParentDeep(outerGroup, parent), { traverse: true });
1724
+ } else {
1725
+ throw new Error(`Unsupported absence function "(?~|"`);
1726
+ }
1727
+ },
1728
+ Alternative: {
1729
+ enter({ node, parent, key }, { flagDirectivesByAlt }) {
1730
+ const flagDirectives = node.body.filter((el) => el.kind === "flags");
1731
+ for (let i2 = key + 1; i2 < parent.body.length; i2++) {
1732
+ const forwardSiblingAlt = parent.body[i2];
1733
+ getOrInsert(flagDirectivesByAlt, forwardSiblingAlt, []).push(...flagDirectives);
1734
+ }
1735
+ },
1736
+ exit({ node }, { flagDirectivesByAlt }) {
1737
+ if (flagDirectivesByAlt.get(node)?.length) {
1738
+ const flags = getCombinedFlagModsFromFlagNodes(flagDirectivesByAlt.get(node));
1739
+ if (flags) {
1740
+ const flagGroup = A({ flags });
1741
+ flagGroup.body[0].body = node.body;
1742
+ node.body = [setParentDeep(flagGroup, node)];
1743
+ }
1744
+ }
1745
+ }
1746
+ },
1747
+ Assertion({ node, parent, key, container, root, remove, replaceWith }, state) {
1748
+ const { kind, negate } = node;
1749
+ const { asciiWordBoundaries, avoidSubclass, supportedGNodes, wordIsAscii } = state;
1750
+ if (kind === "text_segment_boundary") {
1751
+ throw new Error(`Unsupported text segment boundary "\\${negate ? "Y" : "y"}"`);
1752
+ } else if (kind === "line_end") {
1753
+ replaceWith(setParentDeep(K({ body: [
1754
+ b({ body: [F("string_end")] }),
1755
+ b({ body: [m(10)] })
1756
+ // `\n`
1757
+ ] }), parent));
1758
+ } else if (kind === "line_start") {
1759
+ replaceWith(setParentDeep(parseFragment(r`(?<=\A|\n(?!\z))`, { skipLookbehindValidation: true }), parent));
1760
+ } else if (kind === "search_start") {
1761
+ if (supportedGNodes.has(node)) {
1762
+ root.flags.sticky = true;
1763
+ remove();
1764
+ } else {
1765
+ const prev = container[key - 1];
1766
+ if (prev && isAlwaysNonZeroLength(prev)) {
1767
+ replaceWith(setParentDeep(K({ negate: true }), parent));
1768
+ } else if (avoidSubclass) {
1769
+ throw new Error(r`Uses "\G" in a way that requires a subclass`);
1770
+ } else {
1771
+ replaceWith(setParent(F("string_start"), parent));
1772
+ state.strategy = "clip_search";
1773
+ }
1774
+ }
1775
+ } else if (kind === "string_end" || kind === "string_start") ;
1776
+ else if (kind === "string_end_newline") {
1777
+ replaceWith(setParentDeep(parseFragment(r`(?=\n?\z)`), parent));
1778
+ } else if (kind === "word_boundary") {
1779
+ if (!wordIsAscii && !asciiWordBoundaries) {
1780
+ const b2 = `(?:(?<=${defaultWordChar})(?!${defaultWordChar})|(?<!${defaultWordChar})(?=${defaultWordChar}))`;
1781
+ const B2 = `(?:(?<=${defaultWordChar})(?=${defaultWordChar})|(?<!${defaultWordChar})(?!${defaultWordChar}))`;
1782
+ replaceWith(setParentDeep(parseFragment(negate ? B2 : b2), parent));
1783
+ }
1784
+ } else {
1785
+ throw new Error(`Unexpected assertion kind "${kind}"`);
1786
+ }
1787
+ },
1788
+ Backreference({ node }, { jsGroupNameMap }) {
1789
+ let { ref } = node;
1790
+ if (typeof ref === "string" && !isValidJsGroupName(ref)) {
1791
+ ref = getAndStoreJsGroupName(ref, jsGroupNameMap);
1792
+ node.ref = ref;
1793
+ }
1794
+ },
1795
+ CapturingGroup({ node }, { jsGroupNameMap, subroutineRefMap }) {
1796
+ let { name } = node;
1797
+ if (name && !isValidJsGroupName(name)) {
1798
+ name = getAndStoreJsGroupName(name, jsGroupNameMap);
1799
+ node.name = name;
1800
+ }
1801
+ subroutineRefMap.set(node.number, node);
1802
+ if (name) {
1803
+ subroutineRefMap.set(name, node);
1804
+ }
1805
+ },
1806
+ CharacterClassRange({ node, parent, replaceWith }) {
1807
+ if (parent.kind === "intersection") {
1808
+ const cc = C({ body: [node] });
1809
+ replaceWith(setParentDeep(cc, parent), { traverse: true });
1810
+ }
1811
+ },
1812
+ CharacterSet({ node, parent, replaceWith }, { accuracy, minTargetEs2024, digitIsAscii, spaceIsAscii, wordIsAscii }) {
1813
+ const { kind, negate, value } = node;
1814
+ if (digitIsAscii && (kind === "digit" || value === "digit")) {
1815
+ replaceWith(setParent(E("digit", { negate }), parent));
1816
+ return;
1817
+ }
1818
+ if (spaceIsAscii && (kind === "space" || value === "space")) {
1819
+ replaceWith(setParentDeep(setNegate(parseFragment(asciiSpaceChar), negate), parent));
1820
+ return;
1821
+ }
1822
+ if (wordIsAscii && (kind === "word" || value === "word")) {
1823
+ replaceWith(setParent(E("word", { negate }), parent));
1824
+ return;
1825
+ }
1826
+ if (kind === "any") {
1827
+ replaceWith(setParent(Q("Any"), parent));
1828
+ } else if (kind === "digit") {
1829
+ replaceWith(setParent(Q("Nd", { negate }), parent));
1830
+ } else if (kind === "dot") ;
1831
+ else if (kind === "text_segment") {
1832
+ if (accuracy === "strict") {
1833
+ throw new Error(r`Use of "\X" requires non-strict accuracy`);
1834
+ }
1835
+ const eBase = "\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?";
1836
+ const emoji = r`\p{RI}{2}|${eBase}(?:\u200D${eBase})*`;
1837
+ replaceWith(setParentDeep(parseFragment(
1838
+ // Close approximation of an extended grapheme cluster; see <unicode.org/reports/tr29/>
1839
+ r`(?>\r\n|${minTargetEs2024 ? r`\p{RGI_Emoji}` : emoji}|\P{M}\p{M}*)`,
1840
+ // Allow JS property `RGI_Emoji` through
1841
+ { skipPropertyNameValidation: true }
1842
+ ), parent));
1843
+ } else if (kind === "hex") {
1844
+ replaceWith(setParent(Q("AHex", { negate }), parent));
1845
+ } else if (kind === "newline") {
1846
+ replaceWith(setParentDeep(parseFragment(negate ? "[^\n]" : "(?>\r\n?|[\n\v\f…\u2028\u2029])"), parent));
1847
+ } else if (kind === "posix") {
1848
+ if (!minTargetEs2024 && (value === "graph" || value === "print")) {
1849
+ if (accuracy === "strict") {
1850
+ throw new Error(`POSIX class "${value}" requires min target ES2024 or non-strict accuracy`);
1851
+ }
1852
+ let ascii = {
1853
+ graph: "!-~",
1854
+ print: " -~"
1855
+ }[value];
1856
+ if (negate) {
1857
+ ascii = `\0-${cp(ascii.codePointAt(0) - 1)}${cp(ascii.codePointAt(2) + 1)}-􏿿`;
1858
+ }
1859
+ replaceWith(setParentDeep(parseFragment(`[${ascii}]`), parent));
1860
+ } else {
1861
+ replaceWith(setParentDeep(setNegate(parseFragment(PosixClassMap.get(value)), negate), parent));
1862
+ }
1863
+ } else if (kind === "property") {
1864
+ if (!JsUnicodePropertyMap.has(w(value))) {
1865
+ node.key = "sc";
1866
+ }
1867
+ } else if (kind === "space") {
1868
+ replaceWith(setParent(Q("space", { negate }), parent));
1869
+ } else if (kind === "word") {
1870
+ replaceWith(setParentDeep(setNegate(parseFragment(defaultWordChar), negate), parent));
1871
+ } else {
1872
+ throw new Error(`Unexpected character set kind "${kind}"`);
1873
+ }
1874
+ },
1875
+ Directive({ node, parent, root, remove, replaceWith, removeAllPrevSiblings, removeAllNextSiblings }) {
1876
+ const { kind, flags } = node;
1877
+ if (kind === "flags") {
1878
+ if (!flags.enable && !flags.disable) {
1879
+ remove();
1880
+ } else {
1881
+ const flagGroup = A({ flags });
1882
+ flagGroup.body[0].body = removeAllNextSiblings();
1883
+ replaceWith(setParentDeep(flagGroup, parent), { traverse: true });
1884
+ }
1885
+ } else if (kind === "keep") {
1886
+ const firstAlt = root.body[0];
1887
+ const hasWrapperGroup = root.body.length === 1 && // Not emulatable if within a `CapturingGroup`
1888
+ o(firstAlt, { type: "Group" }) && firstAlt.body[0].body.length === 1;
1889
+ const topLevel = hasWrapperGroup ? firstAlt.body[0] : root;
1890
+ if (parent.parent !== topLevel || topLevel.body.length > 1) {
1891
+ throw new Error(r`Uses "\K" in a way that's unsupported`);
1892
+ }
1893
+ const lookbehind = K({ behind: true });
1894
+ lookbehind.body[0].body = removeAllPrevSiblings();
1895
+ replaceWith(setParentDeep(lookbehind, parent));
1896
+ } else {
1897
+ throw new Error(`Unexpected directive kind "${kind}"`);
1898
+ }
1899
+ },
1900
+ Flags({ node, parent }) {
1901
+ if (node.posixIsAscii) {
1902
+ throw new Error('Unsupported flag "P"');
1903
+ }
1904
+ if (node.textSegmentMode === "word") {
1905
+ throw new Error('Unsupported flag "y{w}"');
1906
+ }
1907
+ [
1908
+ "digitIsAscii",
1909
+ // Flag D
1910
+ "extended",
1911
+ // Flag x
1912
+ "posixIsAscii",
1913
+ // Flag P
1914
+ "spaceIsAscii",
1915
+ // Flag S
1916
+ "wordIsAscii",
1917
+ // Flag W
1918
+ "textSegmentMode"
1919
+ // Flag y{g} or y{w}
1920
+ ].forEach((f2) => delete node[f2]);
1921
+ Object.assign(node, {
1922
+ // JS flag g; no Onig equiv
1923
+ global: false,
1924
+ // JS flag d; no Onig equiv
1925
+ hasIndices: false,
1926
+ // JS flag m; no Onig equiv but its behavior is always on in Onig. Onig's only line break
1927
+ // char is line feed, unlike JS, so this flag isn't used since it would produce inaccurate
1928
+ // results (also allows `^` and `$` to be used in the generator for string start and end)
1929
+ multiline: false,
1930
+ // JS flag y; no Onig equiv, but used for `\G` emulation
1931
+ sticky: node.sticky ?? false
1932
+ // Note: Regex+ doesn't allow explicitly adding flags it handles implicitly, so leave out
1933
+ // properties `unicode` (JS flag u) and `unicodeSets` (JS flag v). Keep the existing values
1934
+ // for `ignoreCase` (flag i) and `dotAll` (JS flag s, but Onig flag m)
1935
+ });
1936
+ parent.options = {
1937
+ disable: {
1938
+ // Onig uses different rules for flag x than Regex+, so disable the implicit flag
1939
+ x: true,
1940
+ // Onig has no flag to control "named capture only" mode but contextually applies its
1941
+ // behavior when named capturing is used, so disable Regex+'s implicit flag for it
1942
+ n: true
1943
+ },
1944
+ force: {
1945
+ // Always add flag v because we're generating an AST that relies on it (it enables JS
1946
+ // support for Onig features nested classes, intersection, Unicode properties, etc.).
1947
+ // However, the generator might disable flag v based on its `target` option
1948
+ v: true
1949
+ }
1950
+ };
1951
+ },
1952
+ Group({ node }) {
1953
+ if (!node.flags) {
1954
+ return;
1955
+ }
1956
+ const { enable, disable } = node.flags;
1957
+ enable?.extended && delete enable.extended;
1958
+ disable?.extended && delete disable.extended;
1959
+ enable?.dotAll && disable?.dotAll && delete enable.dotAll;
1960
+ enable?.ignoreCase && disable?.ignoreCase && delete enable.ignoreCase;
1961
+ enable && !Object.keys(enable).length && delete node.flags.enable;
1962
+ disable && !Object.keys(disable).length && delete node.flags.disable;
1963
+ !node.flags.enable && !node.flags.disable && delete node.flags;
1964
+ },
1965
+ LookaroundAssertion({ node }, state) {
1966
+ const { kind } = node;
1967
+ if (kind === "lookbehind") {
1968
+ state.passedLookbehind = true;
1969
+ }
1970
+ },
1971
+ NamedCallout({ node, parent, replaceWith }) {
1972
+ const { kind } = node;
1973
+ if (kind === "fail") {
1974
+ replaceWith(setParentDeep(K({ negate: true }), parent));
1975
+ } else {
1976
+ throw new Error(`Unsupported named callout "(*${kind.toUpperCase()}"`);
1977
+ }
1978
+ },
1979
+ Quantifier({ node }) {
1980
+ if (node.body.type === "Quantifier") {
1981
+ const group = A();
1982
+ group.body[0].body.push(node.body);
1983
+ node.body = setParentDeep(group, node);
1984
+ }
1985
+ },
1986
+ Regex: {
1987
+ enter({ node }, { supportedGNodes }) {
1988
+ const leadingGs = [];
1989
+ let hasAltWithLeadG = false;
1990
+ let hasAltWithoutLeadG = false;
1991
+ for (const alt of node.body) {
1992
+ if (alt.body.length === 1 && alt.body[0].kind === "search_start") {
1993
+ alt.body.pop();
1994
+ } else {
1995
+ const leadingG = getLeadingG(alt.body);
1996
+ if (leadingG) {
1997
+ hasAltWithLeadG = true;
1998
+ Array.isArray(leadingG) ? leadingGs.push(...leadingG) : leadingGs.push(leadingG);
1999
+ } else {
2000
+ hasAltWithoutLeadG = true;
2001
+ }
2002
+ }
2003
+ }
2004
+ if (hasAltWithLeadG && !hasAltWithoutLeadG) {
2005
+ leadingGs.forEach((g) => supportedGNodes.add(g));
2006
+ }
2007
+ },
2008
+ exit(_2, { accuracy, passedLookbehind, strategy }) {
2009
+ if (accuracy === "strict" && passedLookbehind && strategy) {
2010
+ throw new Error(r`Uses "\G" in a way that requires non-strict accuracy`);
2011
+ }
2012
+ }
2013
+ },
2014
+ Subroutine({ node }, { jsGroupNameMap }) {
2015
+ let { ref } = node;
2016
+ if (typeof ref === "string" && !isValidJsGroupName(ref)) {
2017
+ ref = getAndStoreJsGroupName(ref, jsGroupNameMap);
2018
+ node.ref = ref;
2019
+ }
2020
+ }
2021
+ };
2022
+ var SecondPassVisitor = {
2023
+ Backreference({ node }, { multiplexCapturesToLeftByRef, reffedNodesByReferencer }) {
2024
+ const { orphan, ref } = node;
2025
+ if (!orphan) {
2026
+ reffedNodesByReferencer.set(node, [...multiplexCapturesToLeftByRef.get(ref).map(({ node: node2 }) => node2)]);
2027
+ }
2028
+ },
2029
+ CapturingGroup: {
2030
+ enter({
2031
+ node,
2032
+ parent,
2033
+ replaceWith,
2034
+ skip
2035
+ }, {
2036
+ groupOriginByCopy,
2037
+ groupsByName,
2038
+ multiplexCapturesToLeftByRef,
2039
+ openRefs,
2040
+ reffedNodesByReferencer
2041
+ }) {
2042
+ const origin = groupOriginByCopy.get(node);
2043
+ if (origin && openRefs.has(node.number)) {
2044
+ const recursion2 = setParent(createRecursion(node.number), parent);
2045
+ reffedNodesByReferencer.set(recursion2, openRefs.get(node.number));
2046
+ replaceWith(recursion2);
2047
+ return;
2048
+ }
2049
+ openRefs.set(node.number, node);
2050
+ multiplexCapturesToLeftByRef.set(node.number, []);
2051
+ if (node.name) {
2052
+ getOrInsert(multiplexCapturesToLeftByRef, node.name, []);
2053
+ }
2054
+ const multiplexNodes = multiplexCapturesToLeftByRef.get(node.name ?? node.number);
2055
+ for (let i2 = 0; i2 < multiplexNodes.length; i2++) {
2056
+ const multiplex = multiplexNodes[i2];
2057
+ if (
2058
+ // This group is from subroutine expansion, and there's a multiplex value from either the
2059
+ // origin node or a prior subroutine expansion group with the same origin
2060
+ origin === multiplex.node || origin && origin === multiplex.origin || // This group is not from subroutine expansion, and it comes after a subroutine expansion
2061
+ // group that refers to this group
2062
+ node === multiplex.origin
2063
+ ) {
2064
+ multiplexNodes.splice(i2, 1);
2065
+ break;
2066
+ }
2067
+ }
2068
+ multiplexCapturesToLeftByRef.get(node.number).push({ node, origin });
2069
+ if (node.name) {
2070
+ multiplexCapturesToLeftByRef.get(node.name).push({ node, origin });
2071
+ }
2072
+ if (node.name) {
2073
+ const groupsWithSameName = getOrInsert(groupsByName, node.name, /* @__PURE__ */ new Map());
2074
+ let hasDuplicateNameToRemove = false;
2075
+ if (origin) {
2076
+ hasDuplicateNameToRemove = true;
2077
+ } else {
2078
+ for (const groupInfo of groupsWithSameName.values()) {
2079
+ if (!groupInfo.hasDuplicateNameToRemove) {
2080
+ hasDuplicateNameToRemove = true;
2081
+ break;
2082
+ }
2083
+ }
2084
+ }
2085
+ groupsByName.get(node.name).set(node, { node, hasDuplicateNameToRemove });
2086
+ }
2087
+ },
2088
+ exit({ node }, { openRefs }) {
2089
+ if (openRefs.get(node.number) === node) {
2090
+ openRefs.delete(node.number);
2091
+ }
2092
+ }
2093
+ },
2094
+ Group: {
2095
+ enter({ node }, state) {
2096
+ state.prevFlags = state.currentFlags;
2097
+ if (node.flags) {
2098
+ state.currentFlags = getNewCurrentFlags(state.currentFlags, node.flags);
2099
+ }
2100
+ },
2101
+ exit(_2, state) {
2102
+ state.currentFlags = state.prevFlags;
2103
+ }
2104
+ },
2105
+ Subroutine({ node, parent, replaceWith }, state) {
2106
+ const { isRecursive, ref } = node;
2107
+ if (isRecursive) {
2108
+ let reffed = parent;
2109
+ while (reffed = reffed.parent) {
2110
+ if (reffed.type === "CapturingGroup" && (reffed.name === ref || reffed.number === ref)) {
2111
+ break;
2112
+ }
2113
+ }
2114
+ state.reffedNodesByReferencer.set(node, reffed);
2115
+ return;
2116
+ }
2117
+ const reffedGroupNode = state.subroutineRefMap.get(ref);
2118
+ const isGlobalRecursion = ref === 0;
2119
+ const expandedSubroutine = isGlobalRecursion ? createRecursion(0) : (
2120
+ // The reffed group might itself contain subroutines, which are expanded during sub-traversal
2121
+ cloneCapturingGroup(reffedGroupNode, state.groupOriginByCopy, null)
2122
+ );
2123
+ let replacement = expandedSubroutine;
2124
+ if (!isGlobalRecursion) {
2125
+ const reffedGroupFlagMods = getCombinedFlagModsFromFlagNodes(getAllParents(
2126
+ reffedGroupNode,
2127
+ (p) => p.type === "Group" && !!p.flags
2128
+ ));
2129
+ const reffedGroupFlags = reffedGroupFlagMods ? getNewCurrentFlags(state.globalFlags, reffedGroupFlagMods) : state.globalFlags;
2130
+ if (!areFlagsEqual(reffedGroupFlags, state.currentFlags)) {
2131
+ replacement = A({
2132
+ flags: getFlagModsFromFlags(reffedGroupFlags)
2133
+ });
2134
+ replacement.body[0].body.push(expandedSubroutine);
2135
+ }
2136
+ }
2137
+ replaceWith(setParentDeep(replacement, parent), { traverse: !isGlobalRecursion });
2138
+ }
2139
+ };
2140
+ var ThirdPassVisitor = {
2141
+ Backreference({ node, parent, replaceWith }, state) {
2142
+ if (node.orphan) {
2143
+ state.highestOrphanBackref = Math.max(state.highestOrphanBackref, node.ref);
2144
+ return;
2145
+ }
2146
+ const reffedNodes = state.reffedNodesByReferencer.get(node);
2147
+ const participants = reffedNodes.filter((reffed) => canParticipateWithNode(reffed, node));
2148
+ if (!participants.length) {
2149
+ replaceWith(setParentDeep(K({ negate: true }), parent));
2150
+ } else if (participants.length > 1) {
2151
+ const group = A({
2152
+ atomic: true,
2153
+ body: participants.reverse().map((reffed) => b({
2154
+ body: [k(reffed.number)]
2155
+ }))
2156
+ });
2157
+ replaceWith(setParentDeep(group, parent));
2158
+ } else {
2159
+ node.ref = participants[0].number;
2160
+ }
2161
+ },
2162
+ CapturingGroup({ node }, state) {
2163
+ node.number = ++state.numCapturesToLeft;
2164
+ if (node.name) {
2165
+ if (state.groupsByName.get(node.name).get(node).hasDuplicateNameToRemove) {
2166
+ delete node.name;
2167
+ }
2168
+ }
2169
+ },
2170
+ Regex: {
2171
+ exit({ node }, state) {
2172
+ const numCapsNeeded = Math.max(state.highestOrphanBackref - state.numCapturesToLeft, 0);
2173
+ for (let i2 = 0; i2 < numCapsNeeded; i2++) {
2174
+ const emptyCapture = P();
2175
+ node.body.at(-1).body.push(emptyCapture);
2176
+ }
2177
+ }
2178
+ },
2179
+ Subroutine({ node }, state) {
2180
+ if (!node.isRecursive || node.ref === 0) {
2181
+ return;
2182
+ }
2183
+ node.ref = state.reffedNodesByReferencer.get(node).number;
2184
+ }
2185
+ };
2186
+ function addParentProperties(root) {
2187
+ S(root, {
2188
+ "*"({ node, parent }) {
2189
+ node.parent = parent;
2190
+ }
2191
+ });
2192
+ }
2193
+ function areFlagsEqual(a, b2) {
2194
+ return a.dotAll === b2.dotAll && a.ignoreCase === b2.ignoreCase;
2195
+ }
2196
+ function canParticipateWithNode(capture, node) {
2197
+ let rightmostPoint = node;
2198
+ do {
2199
+ if (rightmostPoint.type === "Regex") {
2200
+ return false;
2201
+ }
2202
+ if (rightmostPoint.type === "Alternative") {
2203
+ continue;
2204
+ }
2205
+ if (rightmostPoint === capture) {
2206
+ return false;
2207
+ }
2208
+ const kidsOfParent = getKids(rightmostPoint.parent);
2209
+ for (const kid of kidsOfParent) {
2210
+ if (kid === rightmostPoint) {
2211
+ break;
2212
+ }
2213
+ if (kid === capture || isAncestorOf(kid, capture)) {
2214
+ return true;
2215
+ }
2216
+ }
2217
+ } while (rightmostPoint = rightmostPoint.parent);
2218
+ throw new Error("Unexpected path");
2219
+ }
2220
+ function cloneCapturingGroup(obj, originMap, up, up2) {
2221
+ const store = Array.isArray(obj) ? [] : {};
2222
+ for (const [key, value] of Object.entries(obj)) {
2223
+ if (key === "parent") {
2224
+ store.parent = Array.isArray(up) ? up2 : up;
2225
+ } else if (value && typeof value === "object") {
2226
+ store[key] = cloneCapturingGroup(value, originMap, store, up);
2227
+ } else {
2228
+ if (key === "type" && value === "CapturingGroup") {
2229
+ originMap.set(store, originMap.get(obj) ?? obj);
2230
+ }
2231
+ store[key] = value;
2232
+ }
2233
+ }
2234
+ return store;
2235
+ }
2236
+ function createRecursion(ref) {
2237
+ const node = O(ref);
2238
+ node.isRecursive = true;
2239
+ return node;
2240
+ }
2241
+ function getAllParents(node, filterFn) {
2242
+ const results = [];
2243
+ while (node = node.parent) {
2244
+ if (!filterFn || filterFn(node)) {
2245
+ results.push(node);
2246
+ }
2247
+ }
2248
+ return results;
2249
+ }
2250
+ function getAndStoreJsGroupName(name, map) {
2251
+ if (map.has(name)) {
2252
+ return map.get(name);
2253
+ }
2254
+ const jsName = `$${map.size}_${name.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug, "_")}`;
2255
+ map.set(name, jsName);
2256
+ return jsName;
2257
+ }
2258
+ function getCombinedFlagModsFromFlagNodes(flagNodes) {
2259
+ const flagProps = ["dotAll", "ignoreCase"];
2260
+ const combinedFlags = { enable: {}, disable: {} };
2261
+ flagNodes.forEach(({ flags }) => {
2262
+ flagProps.forEach((prop) => {
2263
+ if (flags.enable?.[prop]) {
2264
+ delete combinedFlags.disable[prop];
2265
+ combinedFlags.enable[prop] = true;
2266
+ }
2267
+ if (flags.disable?.[prop]) {
2268
+ combinedFlags.disable[prop] = true;
2269
+ }
2270
+ });
2271
+ });
2272
+ if (!Object.keys(combinedFlags.enable).length) {
2273
+ delete combinedFlags.enable;
2274
+ }
2275
+ if (!Object.keys(combinedFlags.disable).length) {
2276
+ delete combinedFlags.disable;
2277
+ }
2278
+ if (combinedFlags.enable || combinedFlags.disable) {
2279
+ return combinedFlags;
2280
+ }
2281
+ return null;
2282
+ }
2283
+ function getFlagModsFromFlags({ dotAll, ignoreCase }) {
2284
+ const mods = {};
2285
+ if (dotAll || ignoreCase) {
2286
+ mods.enable = {};
2287
+ dotAll && (mods.enable.dotAll = true);
2288
+ ignoreCase && (mods.enable.ignoreCase = true);
2289
+ }
2290
+ if (!dotAll || !ignoreCase) {
2291
+ mods.disable = {};
2292
+ !dotAll && (mods.disable.dotAll = true);
2293
+ !ignoreCase && (mods.disable.ignoreCase = true);
2294
+ }
2295
+ return mods;
2296
+ }
2297
+ function getKids(node) {
2298
+ if (!node) {
2299
+ throw new Error("Node expected");
2300
+ }
2301
+ const { body } = node;
2302
+ return Array.isArray(body) ? body : body ? [body] : null;
2303
+ }
2304
+ function getLeadingG(els) {
2305
+ const firstToConsider = els.find((el) => el.kind === "search_start" || isLoneGLookaround(el, { negate: false }) || !isAlwaysZeroLength(el));
2306
+ if (!firstToConsider) {
2307
+ return null;
2308
+ }
2309
+ if (firstToConsider.kind === "search_start") {
2310
+ return firstToConsider;
2311
+ }
2312
+ if (firstToConsider.type === "LookaroundAssertion") {
2313
+ return firstToConsider.body[0].body[0];
2314
+ }
2315
+ if (firstToConsider.type === "CapturingGroup" || firstToConsider.type === "Group") {
2316
+ const gNodesForGroup = [];
2317
+ for (const alt of firstToConsider.body) {
2318
+ const leadingG = getLeadingG(alt.body);
2319
+ if (!leadingG) {
2320
+ return null;
2321
+ }
2322
+ Array.isArray(leadingG) ? gNodesForGroup.push(...leadingG) : gNodesForGroup.push(leadingG);
2323
+ }
2324
+ return gNodesForGroup;
2325
+ }
2326
+ return null;
2327
+ }
2328
+ function isAncestorOf(node, descendant) {
2329
+ const kids = getKids(node) ?? [];
2330
+ for (const kid of kids) {
2331
+ if (kid === descendant || isAncestorOf(kid, descendant)) {
2332
+ return true;
2333
+ }
2334
+ }
2335
+ return false;
2336
+ }
2337
+ function isAlwaysZeroLength({ type }) {
2338
+ return type === "Assertion" || type === "Directive" || type === "LookaroundAssertion";
2339
+ }
2340
+ function isAlwaysNonZeroLength(node) {
2341
+ const types = [
2342
+ "Character",
2343
+ "CharacterClass",
2344
+ "CharacterSet"
2345
+ ];
2346
+ return types.includes(node.type) || node.type === "Quantifier" && node.min && types.includes(node.body.type);
2347
+ }
2348
+ function isLoneGLookaround(node, options) {
2349
+ const opts = {
2350
+ negate: null,
2351
+ ...options
2352
+ };
2353
+ return node.type === "LookaroundAssertion" && (opts.negate === null || node.negate === opts.negate) && node.body.length === 1 && o(node.body[0], {
2354
+ type: "Assertion",
2355
+ kind: "search_start"
2356
+ });
2357
+ }
2358
+ function isValidJsGroupName(name) {
2359
+ return /^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(name);
2360
+ }
2361
+ function parseFragment(pattern, options) {
2362
+ const ast = J(pattern, {
2363
+ ...options,
2364
+ // Providing a custom set of Unicode property names avoids converting some JS Unicode
2365
+ // properties (ex: `\p{Alpha}`) to Onig POSIX classes
2366
+ unicodePropertyMap: JsUnicodePropertyMap
2367
+ });
2368
+ const alts = ast.body;
2369
+ if (alts.length > 1 || alts[0].body.length > 1) {
2370
+ return A({ body: alts });
2371
+ }
2372
+ return alts[0].body[0];
2373
+ }
2374
+ function setNegate(node, negate) {
2375
+ node.negate = negate;
2376
+ return node;
2377
+ }
2378
+ function setParent(node, parent) {
2379
+ node.parent = parent;
2380
+ return node;
2381
+ }
2382
+ function setParentDeep(node, parent) {
2383
+ addParentProperties(node);
2384
+ node.parent = parent;
2385
+ return node;
2386
+ }
2387
+ function generate(ast, options) {
2388
+ const opts = getOptions(options);
2389
+ const minTargetEs2024 = isMinTarget(opts.target, "ES2024");
2390
+ const minTargetEs2025 = isMinTarget(opts.target, "ES2025");
2391
+ const recursionLimit = opts.rules.recursionLimit;
2392
+ if (!Number.isInteger(recursionLimit) || recursionLimit < 2 || recursionLimit > 20) {
2393
+ throw new Error("Invalid recursionLimit; use 2-20");
2394
+ }
2395
+ let hasCaseInsensitiveNode = null;
2396
+ let hasCaseSensitiveNode = null;
2397
+ if (!minTargetEs2025) {
2398
+ const iStack = [ast.flags.ignoreCase];
2399
+ S(ast, FlagModifierVisitor, {
2400
+ getCurrentModI: () => iStack.at(-1),
2401
+ popModI() {
2402
+ iStack.pop();
2403
+ },
2404
+ pushModI(isIOn) {
2405
+ iStack.push(isIOn);
2406
+ },
2407
+ setHasCasedChar() {
2408
+ if (iStack.at(-1)) {
2409
+ hasCaseInsensitiveNode = true;
2410
+ } else {
2411
+ hasCaseSensitiveNode = true;
2412
+ }
2413
+ }
2414
+ });
2415
+ }
2416
+ const appliedGlobalFlags = {
2417
+ dotAll: ast.flags.dotAll,
2418
+ // - Turn global flag i on if a case insensitive node was used and no case sensitive nodes were
2419
+ // used (to avoid unnecessary node expansion).
2420
+ // - Turn global flag i off if a case sensitive node was used (since case sensitivity can't be
2421
+ // forced without the use of ES2025 flag groups)
2422
+ ignoreCase: !!((ast.flags.ignoreCase || hasCaseInsensitiveNode) && !hasCaseSensitiveNode)
2423
+ };
2424
+ let lastNode = ast;
2425
+ const state = {
2426
+ accuracy: opts.accuracy,
2427
+ appliedGlobalFlags,
2428
+ captureMap: /* @__PURE__ */ new Map(),
2429
+ currentFlags: {
2430
+ dotAll: ast.flags.dotAll,
2431
+ ignoreCase: ast.flags.ignoreCase
2432
+ },
2433
+ inCharClass: false,
2434
+ lastNode,
2435
+ originMap: ast._originMap,
2436
+ recursionLimit,
2437
+ useAppliedIgnoreCase: !!(!minTargetEs2025 && hasCaseInsensitiveNode && hasCaseSensitiveNode),
2438
+ useFlagMods: minTargetEs2025,
2439
+ useFlagV: minTargetEs2024,
2440
+ verbose: opts.verbose
2441
+ };
2442
+ function gen(node) {
2443
+ state.lastNode = lastNode;
2444
+ lastNode = node;
2445
+ const fn = throwIfNullish(generator[node.type], `Unexpected node type "${node.type}"`);
2446
+ return fn(node, state, gen);
2447
+ }
2448
+ const result = {
2449
+ pattern: ast.body.map(gen).join("|"),
2450
+ // Could reset `lastNode` at this point via `lastNode = ast`, but it isn't needed by flags
2451
+ flags: gen(ast.flags),
2452
+ options: { ...ast.options }
2453
+ };
2454
+ if (!minTargetEs2024) {
2455
+ delete result.options.force.v;
2456
+ result.options.disable.v = true;
2457
+ result.options.unicodeSetsPlugin = null;
2458
+ }
2459
+ result._captureTransfers = /* @__PURE__ */ new Map();
2460
+ result._hiddenCaptures = [];
2461
+ state.captureMap.forEach((value, key) => {
2462
+ if (value.hidden) {
2463
+ result._hiddenCaptures.push(key);
2464
+ }
2465
+ if (value.transferTo) {
2466
+ getOrInsert(result._captureTransfers, value.transferTo, []).push(key);
2467
+ }
2468
+ });
2469
+ return result;
2470
+ }
2471
+ var FlagModifierVisitor = {
2472
+ "*": {
2473
+ enter({ node }, state) {
2474
+ if (isAnyGroup(node)) {
2475
+ const currentModI = state.getCurrentModI();
2476
+ state.pushModI(
2477
+ node.flags ? getNewCurrentFlags({ ignoreCase: currentModI }, node.flags).ignoreCase : currentModI
2478
+ );
2479
+ }
2480
+ },
2481
+ exit({ node }, state) {
2482
+ if (isAnyGroup(node)) {
2483
+ state.popModI();
2484
+ }
2485
+ }
2486
+ },
2487
+ Backreference(_2, state) {
2488
+ state.setHasCasedChar();
2489
+ },
2490
+ Character({ node }, state) {
2491
+ if (charHasCase(cp(node.value))) {
2492
+ state.setHasCasedChar();
2493
+ }
2494
+ },
2495
+ CharacterClassRange({ node, skip }, state) {
2496
+ skip();
2497
+ if (getCasesOutsideCharClassRange(node, { firstOnly: true }).length) {
2498
+ state.setHasCasedChar();
2499
+ }
2500
+ },
2501
+ CharacterSet({ node }, state) {
2502
+ if (node.kind === "property" && UnicodePropertiesWithSpecificCase.has(node.value)) {
2503
+ state.setHasCasedChar();
2504
+ }
2505
+ }
2506
+ };
2507
+ var generator = {
2508
+ /**
2509
+ @param {AlternativeNode} node
2510
+ */
2511
+ Alternative({ body }, _2, gen) {
2512
+ return body.map(gen).join("");
2513
+ },
2514
+ /**
2515
+ @param {AssertionNode} node
2516
+ */
2517
+ Assertion({ kind, negate }) {
2518
+ if (kind === "string_end") {
2519
+ return "$";
2520
+ }
2521
+ if (kind === "string_start") {
2522
+ return "^";
2523
+ }
2524
+ if (kind === "word_boundary") {
2525
+ return negate ? r`\B` : r`\b`;
2526
+ }
2527
+ throw new Error(`Unexpected assertion kind "${kind}"`);
2528
+ },
2529
+ /**
2530
+ @param {BackreferenceNode} node
2531
+ */
2532
+ Backreference({ ref }, state) {
2533
+ if (typeof ref !== "number") {
2534
+ throw new Error("Unexpected named backref in transformed AST");
2535
+ }
2536
+ if (!state.useFlagMods && state.accuracy === "strict" && state.currentFlags.ignoreCase && !state.captureMap.get(ref).ignoreCase) {
2537
+ throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");
2538
+ }
2539
+ return "\\" + ref;
2540
+ },
2541
+ /**
2542
+ @param {CapturingGroupNode} node
2543
+ */
2544
+ CapturingGroup(node, state, gen) {
2545
+ const { body, name, number } = node;
2546
+ const data = { ignoreCase: state.currentFlags.ignoreCase };
2547
+ const origin = state.originMap.get(node);
2548
+ if (origin) {
2549
+ data.hidden = true;
2550
+ if (number > origin.number) {
2551
+ data.transferTo = origin.number;
2552
+ }
2553
+ }
2554
+ state.captureMap.set(number, data);
2555
+ return `(${name ? `?<${name}>` : ""}${body.map(gen).join("|")})`;
2556
+ },
2557
+ /**
2558
+ @param {CharacterNode} node
2559
+ */
2560
+ Character({ value }, state) {
2561
+ const char = cp(value);
2562
+ const escaped = getCharEscape(value, {
2563
+ escDigit: state.lastNode.type === "Backreference",
2564
+ inCharClass: state.inCharClass,
2565
+ useFlagV: state.useFlagV
2566
+ });
2567
+ if (escaped !== char) {
2568
+ return escaped;
2569
+ }
2570
+ if (state.useAppliedIgnoreCase && state.currentFlags.ignoreCase && charHasCase(char)) {
2571
+ const cases = getIgnoreCaseMatchChars(char);
2572
+ return state.inCharClass ? cases.join("") : cases.length > 1 ? `[${cases.join("")}]` : cases[0];
2573
+ }
2574
+ return char;
2575
+ },
2576
+ /**
2577
+ @param {CharacterClassNode} node
2578
+ */
2579
+ CharacterClass(node, state, gen) {
2580
+ const { kind, negate, parent } = node;
2581
+ let { body } = node;
2582
+ if (kind === "intersection" && !state.useFlagV) {
2583
+ throw new Error("Use of character class intersection requires min target ES2024");
2584
+ }
2585
+ if (envFlags.bugFlagVLiteralHyphenIsRange && state.useFlagV && body.some(isLiteralHyphen)) {
2586
+ body = [m(45), ...body.filter((kid) => !isLiteralHyphen(kid))];
2587
+ }
2588
+ const genClass = () => `[${negate ? "^" : ""}${body.map(gen).join(kind === "intersection" ? "&&" : "")}]`;
2589
+ if (!state.inCharClass) {
2590
+ if (
2591
+ // Already established `kind !== 'intersection'` if `!state.useFlagV`; don't check again
2592
+ (!state.useFlagV || envFlags.bugNestedClassIgnoresNegation) && !negate
2593
+ ) {
2594
+ const negatedChildClasses = body.filter(
2595
+ (kid) => kid.type === "CharacterClass" && kid.kind === "union" && kid.negate
2596
+ );
2597
+ if (negatedChildClasses.length) {
2598
+ const group = A();
2599
+ const groupFirstAlt = group.body[0];
2600
+ group.parent = parent;
2601
+ groupFirstAlt.parent = group;
2602
+ body = body.filter((kid) => !negatedChildClasses.includes(kid));
2603
+ node.body = body;
2604
+ if (body.length) {
2605
+ node.parent = groupFirstAlt;
2606
+ groupFirstAlt.body.push(node);
2607
+ } else {
2608
+ group.body.pop();
2609
+ }
2610
+ negatedChildClasses.forEach((cc) => {
2611
+ const newAlt = b({ body: [cc] });
2612
+ cc.parent = newAlt;
2613
+ newAlt.parent = group;
2614
+ group.body.push(newAlt);
2615
+ });
2616
+ return gen(group);
2617
+ }
2618
+ }
2619
+ state.inCharClass = true;
2620
+ const result = genClass();
2621
+ state.inCharClass = false;
2622
+ return result;
2623
+ }
2624
+ const firstEl = body[0];
2625
+ if (
2626
+ // Already established that the parent is a char class via `inCharClass`; don't check again
2627
+ kind === "union" && !negate && firstEl && // Allows many nested classes to work with `target` ES2018 which doesn't support nesting
2628
+ ((!state.useFlagV || !state.verbose) && parent.kind === "union" && !(envFlags.bugFlagVLiteralHyphenIsRange && state.useFlagV) || !state.verbose && parent.kind === "intersection" && // JS doesn't allow intersection with union or ranges
2629
+ body.length === 1 && firstEl.type !== "CharacterClassRange")
2630
+ ) {
2631
+ return body.map(gen).join("");
2632
+ }
2633
+ if (!state.useFlagV && parent.type === "CharacterClass") {
2634
+ throw new Error("Uses nested character class in a way that requires min target ES2024");
2635
+ }
2636
+ return genClass();
2637
+ },
2638
+ /**
2639
+ @param {CharacterClassRangeNode} node
2640
+ */
2641
+ CharacterClassRange(node, state) {
2642
+ const min = node.min.value;
2643
+ const max = node.max.value;
2644
+ const escOpts = {
2645
+ escDigit: false,
2646
+ inCharClass: true,
2647
+ useFlagV: state.useFlagV
2648
+ };
2649
+ const minStr = getCharEscape(min, escOpts);
2650
+ const maxStr = getCharEscape(max, escOpts);
2651
+ const extraChars = /* @__PURE__ */ new Set();
2652
+ if (state.useAppliedIgnoreCase && state.currentFlags.ignoreCase) {
2653
+ const charsOutsideRange = getCasesOutsideCharClassRange(node);
2654
+ const ranges = getCodePointRangesFromChars(charsOutsideRange);
2655
+ ranges.forEach((value) => {
2656
+ extraChars.add(
2657
+ Array.isArray(value) ? `${getCharEscape(value[0], escOpts)}-${getCharEscape(value[1], escOpts)}` : getCharEscape(value, escOpts)
2658
+ );
2659
+ });
2660
+ }
2661
+ return `${minStr}-${maxStr}${[...extraChars].join("")}`;
2662
+ },
2663
+ /**
2664
+ @param {CharacterSetNode} node
2665
+ */
2666
+ CharacterSet({ kind, negate, value, key }, state) {
2667
+ if (kind === "dot") {
2668
+ return state.currentFlags.dotAll ? state.appliedGlobalFlags.dotAll || state.useFlagMods ? "." : "[^]" : (
2669
+ // Onig's only line break char is line feed, unlike JS
2670
+ r`[^\n]`
2671
+ );
2672
+ }
2673
+ if (kind === "digit") {
2674
+ return negate ? r`\D` : r`\d`;
2675
+ }
2676
+ if (kind === "property") {
2677
+ if (state.useAppliedIgnoreCase && state.currentFlags.ignoreCase && UnicodePropertiesWithSpecificCase.has(value)) {
2678
+ throw new Error(`Unicode property "${value}" can't be case-insensitive when other chars have specific case`);
2679
+ }
2680
+ return `${negate ? r`\P` : r`\p`}{${key ? `${key}=` : ""}${value}}`;
2681
+ }
2682
+ if (kind === "word") {
2683
+ return negate ? r`\W` : r`\w`;
2684
+ }
2685
+ throw new Error(`Unexpected character set kind "${kind}"`);
2686
+ },
2687
+ /**
2688
+ @param {FlagsNode} node
2689
+ */
2690
+ Flags(node, state) {
2691
+ return (
2692
+ // The transformer should never turn on the properties for flags d, g, m since Onig doesn't
2693
+ // have equivs. Flag m is never used since Onig uses different line break chars than JS
2694
+ // (node.hasIndices ? 'd' : '') +
2695
+ // (node.global ? 'g' : '') +
2696
+ // (node.multiline ? 'm' : '') +
2697
+ (state.appliedGlobalFlags.ignoreCase ? "i" : "") + (node.dotAll ? "s" : "") + (node.sticky ? "y" : "")
2698
+ );
2699
+ },
2700
+ /**
2701
+ @param {GroupNode} node
2702
+ */
2703
+ Group({ atomic: atomic2, body, flags, parent }, state, gen) {
2704
+ const currentFlags = state.currentFlags;
2705
+ if (flags) {
2706
+ state.currentFlags = getNewCurrentFlags(currentFlags, flags);
2707
+ }
2708
+ const contents = body.map(gen).join("|");
2709
+ const result = !state.verbose && body.length === 1 && // Single alt
2710
+ parent.type !== "Quantifier" && !atomic2 && (!state.useFlagMods || !flags) ? contents : `(?${getGroupPrefix(atomic2, flags, state.useFlagMods)}${contents})`;
2711
+ state.currentFlags = currentFlags;
2712
+ return result;
2713
+ },
2714
+ /**
2715
+ @param {LookaroundAssertionNode} node
2716
+ */
2717
+ LookaroundAssertion({ body, kind, negate }, _2, gen) {
2718
+ const prefix = `${kind === "lookahead" ? "" : "<"}${negate ? "!" : "="}`;
2719
+ return `(?${prefix}${body.map(gen).join("|")})`;
2720
+ },
2721
+ /**
2722
+ @param {QuantifierNode} node
2723
+ */
2724
+ Quantifier(node, _2, gen) {
2725
+ return gen(node.body) + getQuantifierStr(node);
2726
+ },
2727
+ /**
2728
+ @param {SubroutineNode & {isRecursive: true}} node
2729
+ */
2730
+ Subroutine({ isRecursive, ref }, state) {
2731
+ if (!isRecursive) {
2732
+ throw new Error("Unexpected non-recursive subroutine in transformed AST");
2733
+ }
2734
+ const limit = state.recursionLimit;
2735
+ return ref === 0 ? `(?R=${limit})` : r`\g<${ref}&R=${limit}>`;
2736
+ }
2737
+ };
2738
+ var BaseEscapeChars = /* @__PURE__ */ new Set([
2739
+ "$",
2740
+ "(",
2741
+ ")",
2742
+ "*",
2743
+ "+",
2744
+ ".",
2745
+ "?",
2746
+ "[",
2747
+ "\\",
2748
+ "]",
2749
+ "^",
2750
+ "{",
2751
+ "|",
2752
+ "}"
2753
+ ]);
2754
+ var CharClassEscapeChars = /* @__PURE__ */ new Set([
2755
+ "-",
2756
+ "\\",
2757
+ "]",
2758
+ "^",
2759
+ // Literal `[` doesn't require escaping with flag u, but this can help work around regex source
2760
+ // linters and regex syntax processors that expect unescaped `[` to create a nested class
2761
+ "["
2762
+ ]);
2763
+ var CharClassEscapeCharsFlagV = /* @__PURE__ */ new Set([
2764
+ "(",
2765
+ ")",
2766
+ "-",
2767
+ "/",
2768
+ "[",
2769
+ "\\",
2770
+ "]",
2771
+ "^",
2772
+ "{",
2773
+ "|",
2774
+ "}",
2775
+ // Double punctuators; also includes already-listed `-` and `^`
2776
+ "!",
2777
+ "#",
2778
+ "$",
2779
+ "%",
2780
+ "&",
2781
+ "*",
2782
+ "+",
2783
+ ",",
2784
+ ".",
2785
+ ":",
2786
+ ";",
2787
+ "<",
2788
+ "=",
2789
+ ">",
2790
+ "?",
2791
+ "@",
2792
+ "`",
2793
+ "~"
2794
+ ]);
2795
+ var CharCodeEscapeMap = /* @__PURE__ */ new Map([
2796
+ [9, r`\t`],
2797
+ // horizontal tab
2798
+ [10, r`\n`],
2799
+ // line feed
2800
+ [11, r`\v`],
2801
+ // vertical tab
2802
+ [12, r`\f`],
2803
+ // form feed
2804
+ [13, r`\r`],
2805
+ // carriage return
2806
+ [8232, r`\u2028`],
2807
+ // line separator
2808
+ [8233, r`\u2029`],
2809
+ // paragraph separator
2810
+ [65279, r`\uFEFF`]
2811
+ // ZWNBSP/BOM
2812
+ ]);
2813
+ var casedRe = new RegExp("^\\p{Cased}$", "u");
2814
+ function charHasCase(char) {
2815
+ return casedRe.test(char);
2816
+ }
2817
+ function getCasesOutsideCharClassRange(node, options) {
2818
+ const firstOnly = !!options?.firstOnly;
2819
+ const min = node.min.value;
2820
+ const max = node.max.value;
2821
+ const found = [];
2822
+ if (min < 65 && (max === 65535 || max >= 131071) || min === 65536 && max >= 131071) {
2823
+ return found;
2824
+ }
2825
+ for (let i2 = min; i2 <= max; i2++) {
2826
+ const char = cp(i2);
2827
+ if (!charHasCase(char)) {
2828
+ continue;
2829
+ }
2830
+ const charsOutsideRange = getIgnoreCaseMatchChars(char).filter((caseOfChar) => {
2831
+ const num = caseOfChar.codePointAt(0);
2832
+ return num < min || num > max;
2833
+ });
2834
+ if (charsOutsideRange.length) {
2835
+ found.push(...charsOutsideRange);
2836
+ if (firstOnly) {
2837
+ break;
2838
+ }
2839
+ }
2840
+ }
2841
+ return found;
2842
+ }
2843
+ function getCharEscape(codePoint, { escDigit, inCharClass, useFlagV }) {
2844
+ if (CharCodeEscapeMap.has(codePoint)) {
2845
+ return CharCodeEscapeMap.get(codePoint);
2846
+ }
2847
+ if (
2848
+ // Control chars, etc.; condition modeled on the Chrome developer console's display for strings
2849
+ codePoint < 32 || codePoint > 126 && codePoint < 160 || // Unicode planes 4-16; unassigned, special purpose, and private use area
2850
+ codePoint > 262143 || // Avoid corrupting a preceding backref by immediately following it with a literal digit
2851
+ escDigit && isDigitCharCode(codePoint)
2852
+ ) {
2853
+ return codePoint > 255 ? `\\u{${codePoint.toString(16).toUpperCase()}}` : `\\x${codePoint.toString(16).toUpperCase().padStart(2, "0")}`;
2854
+ }
2855
+ const escapeChars = inCharClass ? useFlagV ? CharClassEscapeCharsFlagV : CharClassEscapeChars : BaseEscapeChars;
2856
+ const char = cp(codePoint);
2857
+ return (escapeChars.has(char) ? "\\" : "") + char;
2858
+ }
2859
+ function getCodePointRangesFromChars(chars) {
2860
+ const codePoints = chars.map((char) => char.codePointAt(0)).sort((a, b2) => a - b2);
2861
+ const values = [];
2862
+ let start = null;
2863
+ for (let i2 = 0; i2 < codePoints.length; i2++) {
2864
+ if (codePoints[i2 + 1] === codePoints[i2] + 1) {
2865
+ start ??= codePoints[i2];
2866
+ } else if (start === null) {
2867
+ values.push(codePoints[i2]);
2868
+ } else {
2869
+ values.push([start, codePoints[i2]]);
2870
+ start = null;
2871
+ }
2872
+ }
2873
+ return values;
2874
+ }
2875
+ function getGroupPrefix(atomic2, flagMods, useFlagMods) {
2876
+ if (atomic2) {
2877
+ return ">";
2878
+ }
2879
+ let mods = "";
2880
+ if (flagMods && useFlagMods) {
2881
+ const { enable, disable } = flagMods;
2882
+ mods = (enable?.ignoreCase ? "i" : "") + (enable?.dotAll ? "s" : "") + (disable ? "-" : "") + (disable?.ignoreCase ? "i" : "") + (disable?.dotAll ? "s" : "");
2883
+ }
2884
+ return `${mods}:`;
2885
+ }
2886
+ function getQuantifierStr({ kind, max, min }) {
2887
+ let base;
2888
+ if (!min && max === 1) {
2889
+ base = "?";
2890
+ } else if (!min && max === Infinity) {
2891
+ base = "*";
2892
+ } else if (min === 1 && max === Infinity) {
2893
+ base = "+";
2894
+ } else if (min === max) {
2895
+ base = `{${min}}`;
2896
+ } else {
2897
+ base = `{${min},${max === Infinity ? "" : max}}`;
2898
+ }
2899
+ return base + {
2900
+ greedy: "",
2901
+ lazy: "?",
2902
+ possessive: "+"
2903
+ }[kind];
2904
+ }
2905
+ function isAnyGroup({ type }) {
2906
+ return type === "CapturingGroup" || type === "Group" || type === "LookaroundAssertion";
2907
+ }
2908
+ function isDigitCharCode(value) {
2909
+ return value > 47 && value < 58;
2910
+ }
2911
+ function isLiteralHyphen({ type, value }) {
2912
+ return type === "Character" && value === 45;
2913
+ }
2914
+ var EmulatedRegExp = class _EmulatedRegExp extends RegExp {
2915
+ /**
2916
+ @type {Map<number, {
2917
+ hidden?: true;
2918
+ transferTo?: number;
2919
+ }>}
2920
+ */
2921
+ #captureMap = /* @__PURE__ */ new Map();
2922
+ /**
2923
+ @type {RegExp | EmulatedRegExp | null}
2924
+ */
2925
+ #compiled = null;
2926
+ /**
2927
+ @type {string}
2928
+ */
2929
+ #pattern;
2930
+ /**
2931
+ @type {Map<number, string>?}
2932
+ */
2933
+ #nameMap = null;
2934
+ /**
2935
+ @type {string?}
2936
+ */
2937
+ #strategy = null;
2938
+ /**
2939
+ Can be used to serialize the instance.
2940
+ @type {EmulatedRegExpOptions}
2941
+ */
2942
+ rawOptions = {};
2943
+ // Override the getter with one that works with lazy-compiled regexes
2944
+ get source() {
2945
+ return this.#pattern || "(?:)";
2946
+ }
2947
+ /**
2948
+ @overload
2949
+ @param {string} pattern
2950
+ @param {string} [flags]
2951
+ @param {EmulatedRegExpOptions} [options]
2952
+ */
2953
+ /**
2954
+ @overload
2955
+ @param {EmulatedRegExp} pattern
2956
+ @param {string} [flags]
2957
+ */
2958
+ constructor(pattern, flags, options) {
2959
+ const lazyCompile = !!options?.lazyCompile;
2960
+ if (pattern instanceof RegExp) {
2961
+ if (options) {
2962
+ throw new Error("Cannot provide options when copying a regexp");
2963
+ }
2964
+ const re2 = pattern;
2965
+ super(re2, flags);
2966
+ this.#pattern = re2.source;
2967
+ if (re2 instanceof _EmulatedRegExp) {
2968
+ this.#captureMap = re2.#captureMap;
2969
+ this.#nameMap = re2.#nameMap;
2970
+ this.#strategy = re2.#strategy;
2971
+ this.rawOptions = re2.rawOptions;
2972
+ }
2973
+ } else {
2974
+ const opts = {
2975
+ hiddenCaptures: [],
2976
+ strategy: null,
2977
+ transfers: [],
2978
+ ...options
2979
+ };
2980
+ super(lazyCompile ? "" : pattern, flags);
2981
+ this.#pattern = pattern;
2982
+ this.#captureMap = createCaptureMap(opts.hiddenCaptures, opts.transfers);
2983
+ this.#strategy = opts.strategy;
2984
+ this.rawOptions = options ?? {};
2985
+ }
2986
+ if (!lazyCompile) {
2987
+ this.#compiled = this;
2988
+ }
2989
+ }
2990
+ /**
2991
+ Called internally by all String/RegExp methods that use regexes.
2992
+ @override
2993
+ @param {string} str
2994
+ @returns {RegExpExecArray?}
2995
+ */
2996
+ exec(str) {
2997
+ if (!this.#compiled) {
2998
+ const { lazyCompile, ...rest } = this.rawOptions;
2999
+ this.#compiled = new _EmulatedRegExp(this.#pattern, this.flags, rest);
3000
+ }
3001
+ const useLastIndex = this.global || this.sticky;
3002
+ const pos = this.lastIndex;
3003
+ if (this.#strategy === "clip_search" && useLastIndex && pos) {
3004
+ this.lastIndex = 0;
3005
+ const match = this.#execCore(str.slice(pos));
3006
+ if (match) {
3007
+ adjustMatchDetailsForOffset(match, pos, str, this.hasIndices);
3008
+ this.lastIndex += pos;
3009
+ }
3010
+ return match;
3011
+ }
3012
+ return this.#execCore(str);
3013
+ }
3014
+ /**
3015
+ Adds support for hidden and transfer captures.
3016
+ @param {string} str
3017
+ @returns
3018
+ */
3019
+ #execCore(str) {
3020
+ this.#compiled.lastIndex = this.lastIndex;
3021
+ const match = super.exec.call(this.#compiled, str);
3022
+ this.lastIndex = this.#compiled.lastIndex;
3023
+ if (!match || !this.#captureMap.size) {
3024
+ return match;
3025
+ }
3026
+ const matchCopy = [...match];
3027
+ match.length = 1;
3028
+ let indicesCopy;
3029
+ if (this.hasIndices) {
3030
+ indicesCopy = [...match.indices];
3031
+ match.indices.length = 1;
3032
+ }
3033
+ const mappedNums = [0];
3034
+ for (let i2 = 1; i2 < matchCopy.length; i2++) {
3035
+ const { hidden, transferTo } = this.#captureMap.get(i2) ?? {};
3036
+ if (hidden) {
3037
+ mappedNums.push(null);
3038
+ } else {
3039
+ mappedNums.push(match.length);
3040
+ match.push(matchCopy[i2]);
3041
+ if (this.hasIndices) {
3042
+ match.indices.push(indicesCopy[i2]);
3043
+ }
3044
+ }
3045
+ if (transferTo && matchCopy[i2] !== void 0) {
3046
+ const to = mappedNums[transferTo];
3047
+ if (!to) {
3048
+ throw new Error(`Invalid capture transfer to "${to}"`);
3049
+ }
3050
+ match[to] = matchCopy[i2];
3051
+ if (this.hasIndices) {
3052
+ match.indices[to] = indicesCopy[i2];
3053
+ }
3054
+ if (match.groups) {
3055
+ if (!this.#nameMap) {
3056
+ this.#nameMap = createNameMap(this.source);
3057
+ }
3058
+ const name = this.#nameMap.get(transferTo);
3059
+ if (name) {
3060
+ match.groups[name] = matchCopy[i2];
3061
+ if (this.hasIndices) {
3062
+ match.indices.groups[name] = indicesCopy[i2];
3063
+ }
3064
+ }
3065
+ }
3066
+ }
3067
+ }
3068
+ return match;
3069
+ }
3070
+ };
3071
+ function adjustMatchDetailsForOffset(match, offset, input, hasIndices) {
3072
+ match.index += offset;
3073
+ match.input = input;
3074
+ if (hasIndices) {
3075
+ const indices = match.indices;
3076
+ for (let i2 = 0; i2 < indices.length; i2++) {
3077
+ const arr = indices[i2];
3078
+ if (arr) {
3079
+ indices[i2] = [arr[0] + offset, arr[1] + offset];
3080
+ }
3081
+ }
3082
+ const groupIndices = indices.groups;
3083
+ if (groupIndices) {
3084
+ Object.keys(groupIndices).forEach((key) => {
3085
+ const arr = groupIndices[key];
3086
+ if (arr) {
3087
+ groupIndices[key] = [arr[0] + offset, arr[1] + offset];
3088
+ }
3089
+ });
3090
+ }
3091
+ }
3092
+ }
3093
+ function createCaptureMap(hiddenCaptures, transfers) {
3094
+ const captureMap = /* @__PURE__ */ new Map();
3095
+ for (const num of hiddenCaptures) {
3096
+ captureMap.set(num, {
3097
+ hidden: true
3098
+ });
3099
+ }
3100
+ for (const [to, from] of transfers) {
3101
+ for (const num of from) {
3102
+ getOrInsert(captureMap, num, {}).transferTo = to;
3103
+ }
3104
+ }
3105
+ return captureMap;
3106
+ }
3107
+ function createNameMap(pattern) {
3108
+ const re2 = /(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu;
3109
+ const map = /* @__PURE__ */ new Map();
3110
+ let numCharClassesOpen = 0;
3111
+ let numCaptures = 0;
3112
+ let match;
3113
+ while (match = re2.exec(pattern)) {
3114
+ const { 0: m2, groups: { capture, name } } = match;
3115
+ if (m2 === "[") {
3116
+ numCharClassesOpen++;
3117
+ } else if (!numCharClassesOpen) {
3118
+ if (capture) {
3119
+ numCaptures++;
3120
+ if (name) {
3121
+ map.set(numCaptures, name);
3122
+ }
3123
+ }
3124
+ } else if (m2 === "]") {
3125
+ numCharClassesOpen--;
3126
+ }
3127
+ }
3128
+ return map;
3129
+ }
3130
+ function toRegExp(pattern, options) {
3131
+ const d2 = toRegExpDetails(pattern, options);
3132
+ if (d2.options) {
3133
+ return new EmulatedRegExp(d2.pattern, d2.flags, d2.options);
3134
+ }
3135
+ return new RegExp(d2.pattern, d2.flags);
3136
+ }
3137
+ function toRegExpDetails(pattern, options) {
3138
+ const opts = getOptions(options);
3139
+ const onigurumaAst = J(pattern, {
3140
+ flags: opts.flags,
3141
+ normalizeUnknownPropertyNames: true,
3142
+ rules: {
3143
+ captureGroup: opts.rules.captureGroup,
3144
+ singleline: opts.rules.singleline
3145
+ },
3146
+ skipBackrefValidation: opts.rules.allowOrphanBackrefs,
3147
+ unicodePropertyMap: JsUnicodePropertyMap
3148
+ });
3149
+ const regexPlusAst = transform(onigurumaAst, {
3150
+ accuracy: opts.accuracy,
3151
+ asciiWordBoundaries: opts.rules.asciiWordBoundaries,
3152
+ avoidSubclass: opts.avoidSubclass,
3153
+ bestEffortTarget: opts.target
3154
+ });
3155
+ const generated = generate(regexPlusAst, opts);
3156
+ const recursionResult = recursion(generated.pattern, {
3157
+ captureTransfers: generated._captureTransfers,
3158
+ hiddenCaptures: generated._hiddenCaptures,
3159
+ mode: "external"
3160
+ });
3161
+ const possessiveResult = possessive(recursionResult.pattern);
3162
+ const atomicResult = atomic(possessiveResult.pattern, {
3163
+ captureTransfers: recursionResult.captureTransfers,
3164
+ hiddenCaptures: recursionResult.hiddenCaptures
3165
+ });
3166
+ const details = {
3167
+ pattern: atomicResult.pattern,
3168
+ flags: `${opts.hasIndices ? "d" : ""}${opts.global ? "g" : ""}${generated.flags}${generated.options.disable.v ? "u" : "v"}`
3169
+ };
3170
+ if (opts.avoidSubclass) {
3171
+ if (opts.lazyCompileLength !== Infinity) {
3172
+ throw new Error("Lazy compilation requires subclass");
3173
+ }
3174
+ } else {
3175
+ const hiddenCaptures = atomicResult.hiddenCaptures.sort((a, b2) => a - b2);
3176
+ const transfers = Array.from(atomicResult.captureTransfers);
3177
+ const strategy = regexPlusAst._strategy;
3178
+ const lazyCompile = details.pattern.length >= opts.lazyCompileLength;
3179
+ if (hiddenCaptures.length || transfers.length || strategy || lazyCompile) {
3180
+ details.options = {
3181
+ ...hiddenCaptures.length && { hiddenCaptures },
3182
+ ...transfers.length && { transfers },
3183
+ ...strategy && { strategy },
3184
+ ...lazyCompile && { lazyCompile }
3185
+ };
3186
+ }
3187
+ }
3188
+ return details;
3189
+ }
3190
+ function defaultJavaScriptRegexConstructor(pattern, options) {
3191
+ return toRegExp(pattern, {
3192
+ global: true,
3193
+ hasIndices: true,
3194
+ lazyCompileLength: 3e3,
3195
+ rules: {
3196
+ allowOrphanBackrefs: true,
3197
+ asciiWordBoundaries: true,
3198
+ captureGroup: true,
3199
+ recursionLimit: 5,
3200
+ singleline: true
3201
+ },
3202
+ ...options
3203
+ });
3204
+ }
3205
+ function createJavaScriptRegexEngine(options = {}) {
3206
+ const _options = {
3207
+ target: "auto",
3208
+ cache: /* @__PURE__ */ new Map(),
3209
+ ...options
3210
+ };
3211
+ _options.regexConstructor ||= (pattern) => defaultJavaScriptRegexConstructor(pattern, { target: _options.target });
3212
+ return {
3213
+ createScanner(patterns) {
3214
+ return new JavaScriptScanner(patterns, _options);
3215
+ },
3216
+ createString: createJavaScriptEngineString
3217
+ };
3218
+ }
3219
+ export {
3220
+ JavaScriptScanner,
3221
+ createJavaScriptRegexEngine,
3222
+ defaultJavaScriptRegexConstructor
3223
+ };