just-bash 2.12.2 → 2.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/bin/chunks/awk2-RGDNV4HO.js +2 -0
  2. package/dist/bin/chunks/{base64-YXBFJFHG.js → base64-43M2R3GA.js} +1 -1
  3. package/dist/bin/{shell/chunks/cat-3J7U3HHI.js → chunks/cat-XZIJZXKP.js} +1 -1
  4. package/dist/bin/chunks/chunk-4C4F4EKM.js +2 -0
  5. package/dist/bin/{shell/chunks/chunk-MZKPWGID.js → chunks/chunk-54G6AE72.js} +23 -23
  6. package/dist/bin/chunks/chunk-55QIFSKH.js +36 -0
  7. package/dist/bin/chunks/chunk-6MF2IYQX.js +10 -0
  8. package/dist/bin/{shell/chunks/chunk-NEQEZ32M.js → chunks/chunk-CGE2EHYP.js} +3 -3
  9. package/dist/bin/chunks/chunk-DGFDVZ4N.js +21 -0
  10. package/dist/bin/chunks/chunk-EO5AH4U7.js +5 -0
  11. package/dist/bin/chunks/{chunk-2SIXTZCJ.js → chunk-EZS766DD.js} +4 -4
  12. package/dist/bin/{shell/chunks/chunk-THLAHQXV.js → chunks/chunk-FA2CHD73.js} +1 -1
  13. package/dist/bin/chunks/{chunk-BARKRZDC.js → chunk-GOJZHH3L.js} +1 -1
  14. package/dist/bin/chunks/{chunk-435ZOZCY.js → chunk-J4WYAO5Q.js} +1 -1
  15. package/dist/bin/chunks/chunk-LHN3LRVT.js +100 -0
  16. package/dist/bin/chunks/chunk-MRP4ZCD7.js +6 -0
  17. package/dist/bin/chunks/{chunk-JNPUO56K.js → chunk-NDP6L74Z.js} +1 -1
  18. package/dist/bin/chunks/chunk-PWZZGTFL.js +13 -0
  19. package/dist/bin/chunks/{chunk-3NVWSLHI.js → chunk-Q3FNZYGG.js} +99 -99
  20. package/dist/bin/{shell/chunks/chunk-7SWOLTCR.js → chunks/chunk-Q4WHWGOT.js} +1 -1
  21. package/dist/bin/chunks/chunk-SY2WM5RM.js +14 -0
  22. package/dist/bin/chunks/chunk-SYG3IW7P.js +2 -0
  23. package/dist/bin/chunks/chunk-SYL34GE7.js +21 -0
  24. package/dist/bin/chunks/{chunk-DREQRXNN.js → chunk-V5YFCVCZ.js} +1 -1
  25. package/dist/bin/chunks/chunk-V7VIJQD6.js +6 -0
  26. package/dist/bin/chunks/chunk-WMYKQURM.js +2 -0
  27. package/dist/bin/chunks/chunk-WO4B7WUT.js +2 -0
  28. package/dist/bin/{shell/chunks/chunk-5U7Q4GUC.js → chunks/chunk-WWZVR5NN.js} +4 -4
  29. package/dist/bin/chunks/{cut-HDHQDWRG.js → cut-5EY2XPXX.js} +1 -1
  30. package/dist/bin/chunks/expr-VEFRBJT4.js +2 -0
  31. package/dist/bin/chunks/flag-coverage-K6IBGWAC.js +2 -0
  32. package/dist/bin/chunks/{gzip-RQ5RIFJV.js → gzip-LHOO65AN.js} +1 -1
  33. package/dist/bin/chunks/jq-VBB2XIZS.js +2 -0
  34. package/dist/bin/chunks/ln-BEOFQJNP.js +2 -0
  35. package/dist/bin/chunks/python3-JX5PXXTX.js +17 -0
  36. package/dist/bin/chunks/sed-BYFYBR4A.js +2 -0
  37. package/dist/bin/chunks/sleep-E3K6M6BN.js +2 -0
  38. package/dist/bin/chunks/{sort-NZSEYCI6.js → sort-7GENYU2I.js} +1 -1
  39. package/dist/bin/chunks/sqlite3-SJHZFBT2.js +2 -0
  40. package/dist/bin/{shell/chunks/tar-VIYVHMER.js → chunks/tar-W5GBTEDZ.js} +1 -1
  41. package/dist/bin/chunks/time-AWAKKRSE.js +2 -0
  42. package/dist/bin/chunks/timeout-OLS72AZG.js +2 -0
  43. package/dist/bin/chunks/tr-LZF57GYP.js +2 -0
  44. package/dist/bin/chunks/{uniq-FZWFZEN5.js → uniq-TMSAIZM3.js} +1 -1
  45. package/dist/bin/chunks/worker.js +92 -29
  46. package/dist/bin/chunks/xan-BJ66NSYT.js +2 -0
  47. package/dist/bin/chunks/yq-GPYVGU2N.js +2 -0
  48. package/dist/bin/just-bash.js +294 -294
  49. package/dist/bin/shell/chunks/awk2-RGDNV4HO.js +2 -0
  50. package/dist/bin/shell/chunks/{base64-YXBFJFHG.js → base64-43M2R3GA.js} +1 -1
  51. package/dist/bin/{chunks/cat-3J7U3HHI.js → shell/chunks/cat-XZIJZXKP.js} +1 -1
  52. package/dist/bin/shell/chunks/chunk-4C4F4EKM.js +2 -0
  53. package/dist/bin/{chunks/chunk-MZKPWGID.js → shell/chunks/chunk-54G6AE72.js} +23 -23
  54. package/dist/bin/shell/chunks/chunk-55QIFSKH.js +36 -0
  55. package/dist/bin/shell/chunks/chunk-6MF2IYQX.js +10 -0
  56. package/dist/bin/{chunks/chunk-NEQEZ32M.js → shell/chunks/chunk-CGE2EHYP.js} +3 -3
  57. package/dist/bin/shell/chunks/chunk-DGFDVZ4N.js +21 -0
  58. package/dist/bin/shell/chunks/chunk-EO5AH4U7.js +5 -0
  59. package/dist/bin/shell/chunks/{chunk-2SIXTZCJ.js → chunk-EZS766DD.js} +4 -4
  60. package/dist/bin/{chunks/chunk-THLAHQXV.js → shell/chunks/chunk-FA2CHD73.js} +1 -1
  61. package/dist/bin/shell/chunks/{chunk-BARKRZDC.js → chunk-GOJZHH3L.js} +1 -1
  62. package/dist/bin/shell/chunks/{chunk-435ZOZCY.js → chunk-J4WYAO5Q.js} +1 -1
  63. package/dist/bin/shell/chunks/chunk-LHN3LRVT.js +100 -0
  64. package/dist/bin/shell/chunks/chunk-MRP4ZCD7.js +6 -0
  65. package/dist/bin/shell/chunks/{chunk-JNPUO56K.js → chunk-NDP6L74Z.js} +1 -1
  66. package/dist/bin/shell/chunks/chunk-PWZZGTFL.js +13 -0
  67. package/dist/bin/shell/chunks/{chunk-3NVWSLHI.js → chunk-Q3FNZYGG.js} +99 -99
  68. package/dist/bin/{chunks/chunk-7SWOLTCR.js → shell/chunks/chunk-Q4WHWGOT.js} +1 -1
  69. package/dist/bin/shell/chunks/chunk-SY2WM5RM.js +14 -0
  70. package/dist/bin/shell/chunks/chunk-SYG3IW7P.js +2 -0
  71. package/dist/bin/shell/chunks/chunk-SYL34GE7.js +21 -0
  72. package/dist/bin/shell/chunks/{chunk-DREQRXNN.js → chunk-V5YFCVCZ.js} +1 -1
  73. package/dist/bin/shell/chunks/chunk-V7VIJQD6.js +6 -0
  74. package/dist/bin/shell/chunks/chunk-WMYKQURM.js +2 -0
  75. package/dist/bin/shell/chunks/chunk-WO4B7WUT.js +2 -0
  76. package/dist/bin/{chunks/chunk-5U7Q4GUC.js → shell/chunks/chunk-WWZVR5NN.js} +4 -4
  77. package/dist/bin/shell/chunks/{cut-HDHQDWRG.js → cut-5EY2XPXX.js} +1 -1
  78. package/dist/bin/shell/chunks/expr-VEFRBJT4.js +2 -0
  79. package/dist/bin/shell/chunks/flag-coverage-K6IBGWAC.js +2 -0
  80. package/dist/bin/shell/chunks/{gzip-RQ5RIFJV.js → gzip-LHOO65AN.js} +1 -1
  81. package/dist/bin/shell/chunks/jq-VBB2XIZS.js +2 -0
  82. package/dist/bin/shell/chunks/ln-BEOFQJNP.js +2 -0
  83. package/dist/bin/shell/chunks/python3-JX5PXXTX.js +17 -0
  84. package/dist/bin/shell/chunks/sed-BYFYBR4A.js +2 -0
  85. package/dist/bin/shell/chunks/sleep-E3K6M6BN.js +2 -0
  86. package/dist/bin/shell/chunks/{sort-NZSEYCI6.js → sort-7GENYU2I.js} +1 -1
  87. package/dist/bin/shell/chunks/sqlite3-SJHZFBT2.js +2 -0
  88. package/dist/bin/{chunks/tar-VIYVHMER.js → shell/chunks/tar-W5GBTEDZ.js} +1 -1
  89. package/dist/bin/shell/chunks/time-AWAKKRSE.js +2 -0
  90. package/dist/bin/shell/chunks/timeout-OLS72AZG.js +2 -0
  91. package/dist/bin/shell/chunks/tr-LZF57GYP.js +2 -0
  92. package/dist/bin/shell/chunks/{uniq-FZWFZEN5.js → uniq-TMSAIZM3.js} +1 -1
  93. package/dist/bin/shell/chunks/xan-BJ66NSYT.js +2 -0
  94. package/dist/bin/shell/chunks/yq-GPYVGU2N.js +2 -0
  95. package/dist/bin/shell/shell.js +234 -234
  96. package/dist/bundle/browser.js +671 -671
  97. package/dist/bundle/chunks/awk2-XLDR2J4Q.js +1 -0
  98. package/dist/bundle/chunks/{base64-A3SGWC34.js → base64-4YMZCVJ5.js} +1 -1
  99. package/dist/bundle/chunks/{cat-C2OBLGHA.js → cat-RDUMLXKC.js} +1 -1
  100. package/dist/bundle/chunks/chunk-2OHMPZNZ.js +20 -0
  101. package/dist/bundle/chunks/chunk-3RCXHB4E.js +4 -0
  102. package/dist/bundle/chunks/chunk-CCNMISUL.js +1 -0
  103. package/dist/bundle/chunks/chunk-DOTBQEPN.js +5 -0
  104. package/dist/bundle/chunks/chunk-GENDESYN.js +1 -0
  105. package/dist/bundle/chunks/chunk-H4QOE4W3.js +99 -0
  106. package/dist/bundle/chunks/{chunk-C6ZZC5FL.js → chunk-K5BTXJQC.js} +99 -99
  107. package/dist/bundle/chunks/chunk-KAZYKNBG.js +13 -0
  108. package/dist/bundle/chunks/{chunk-KAEMRWOH.js → chunk-KMEYNNUA.js} +1 -1
  109. package/dist/bundle/chunks/{chunk-FO655G4V.js → chunk-LTZRCH7N.js} +23 -23
  110. package/dist/bundle/chunks/{chunk-XULIVM35.js → chunk-N4QLRJ32.js} +1 -1
  111. package/dist/bundle/chunks/{chunk-5CJQNRNJ.js → chunk-NTP6TTH5.js} +1 -1
  112. package/dist/bundle/chunks/{chunk-IBFD7QQD.js → chunk-QJ7O6ZN3.js} +1 -1
  113. package/dist/bundle/chunks/chunk-QUME7R6S.js +9 -0
  114. package/dist/bundle/chunks/{chunk-U7QI5ZS5.js → chunk-RVT3MU3A.js} +4 -4
  115. package/dist/bundle/chunks/{chunk-6NY2AP72.js → chunk-SDNKECQQ.js} +4 -4
  116. package/dist/bundle/chunks/chunk-T2EHE3CV.js +1 -0
  117. package/dist/bundle/chunks/chunk-TBAWQWQB.js +12 -0
  118. package/dist/bundle/chunks/chunk-TXBZCHCQ.js +5 -0
  119. package/dist/bundle/chunks/chunk-VYV3YE2F.js +35 -0
  120. package/dist/bundle/chunks/{chunk-UJIR5V54.js → chunk-W42IGK5R.js} +1 -1
  121. package/dist/bundle/chunks/{chunk-7BQDVPII.js → chunk-WAN3B6E3.js} +1 -1
  122. package/dist/bundle/chunks/{chunk-7C6RBHP3.js → chunk-WKFATFPP.js} +3 -3
  123. package/dist/bundle/chunks/chunk-XXZ46GOX.js +20 -0
  124. package/dist/bundle/chunks/chunk-ZK6J6F7O.js +1 -0
  125. package/dist/bundle/chunks/{cut-LO6YYY5P.js → cut-OPC3VAGB.js} +1 -1
  126. package/dist/bundle/chunks/expr-74QHYJL5.js +1 -0
  127. package/dist/bundle/chunks/flag-coverage-VGF5NAZP.js +1 -0
  128. package/dist/bundle/chunks/{gzip-Y4N2UKE7.js → gzip-AQXSGOVS.js} +1 -1
  129. package/dist/bundle/chunks/jq-JQXAVWNT.js +1 -0
  130. package/dist/bundle/chunks/ln-RI2SJGXU.js +1 -0
  131. package/dist/bundle/chunks/python3-TSPOVUHX.js +16 -0
  132. package/dist/bundle/chunks/sed-CJFW7UYO.js +1 -0
  133. package/dist/bundle/chunks/sleep-TFDNFOXK.js +1 -0
  134. package/dist/bundle/chunks/{sort-T7TNLWXL.js → sort-DCNRDA7U.js} +1 -1
  135. package/dist/bundle/chunks/sqlite3-CTI4ZW7L.js +1 -0
  136. package/dist/bundle/chunks/{tar-E2DVQEWO.js → tar-Y6LP5EBC.js} +1 -1
  137. package/dist/bundle/chunks/time-WBKSMCJ6.js +1 -0
  138. package/dist/bundle/chunks/timeout-O7WSXY5H.js +1 -0
  139. package/dist/bundle/chunks/tr-GVTWMRZB.js +1 -0
  140. package/dist/bundle/chunks/{uniq-ZXE4O5XB.js → uniq-SUNANL47.js} +1 -1
  141. package/dist/bundle/chunks/worker.js +92 -29
  142. package/dist/bundle/chunks/xan-VMLUNIDS.js +1 -0
  143. package/dist/bundle/chunks/yq-QXIYE3MW.js +1 -0
  144. package/dist/bundle/index.cjs +852 -852
  145. package/dist/bundle/index.js +242 -242
  146. package/dist/commands/awk/interpreter/context.d.ts +2 -0
  147. package/dist/commands/awk/interpreter/interpreter.d.ts +2 -0
  148. package/dist/commands/query-engine/evaluator.d.ts +3 -0
  149. package/dist/interpreter/defense-aware-command-context.d.ts +6 -0
  150. package/dist/interpreter/interpreter.d.ts +8 -0
  151. package/dist/interpreter/types.d.ts +5 -0
  152. package/dist/timers.d.ts +2 -11
  153. package/dist/types.d.ts +13 -0
  154. package/package.json +1 -1
  155. package/dist/bin/chunks/awk2-ZE5HJBNV.js +0 -2
  156. package/dist/bin/chunks/chunk-2FFXXW3F.js +0 -14
  157. package/dist/bin/chunks/chunk-4E3LY6YK.js +0 -10
  158. package/dist/bin/chunks/chunk-4FNW6LFM.js +0 -5
  159. package/dist/bin/chunks/chunk-4PZYIYYG.js +0 -36
  160. package/dist/bin/chunks/chunk-6L4K3UGO.js +0 -100
  161. package/dist/bin/chunks/chunk-EPIOK4SY.js +0 -6
  162. package/dist/bin/chunks/chunk-IYZRLSTQ.js +0 -2
  163. package/dist/bin/chunks/chunk-JJHAWOIB.js +0 -2
  164. package/dist/bin/chunks/chunk-K47SEEPI.js +0 -6
  165. package/dist/bin/chunks/chunk-KPWFKFSD.js +0 -21
  166. package/dist/bin/chunks/chunk-RYXW3SZQ.js +0 -13
  167. package/dist/bin/chunks/chunk-VZKEP45B.js +0 -21
  168. package/dist/bin/chunks/expr-MLHUWFYI.js +0 -2
  169. package/dist/bin/chunks/flag-coverage-LQ37DA4R.js +0 -2
  170. package/dist/bin/chunks/jq-CXSPO2J5.js +0 -2
  171. package/dist/bin/chunks/ln-5TCJXDGY.js +0 -2
  172. package/dist/bin/chunks/python3-74B25WCY.js +0 -17
  173. package/dist/bin/chunks/sed-DNLJZZXZ.js +0 -2
  174. package/dist/bin/chunks/sleep-GUJH2AMQ.js +0 -2
  175. package/dist/bin/chunks/sqlite3-57UI7HYL.js +0 -2
  176. package/dist/bin/chunks/time-FAWHHOMA.js +0 -2
  177. package/dist/bin/chunks/timeout-4O4YYRTS.js +0 -2
  178. package/dist/bin/chunks/tr-4V5A3V2C.js +0 -2
  179. package/dist/bin/chunks/xan-7NIVZ3HP.js +0 -2
  180. package/dist/bin/chunks/yq-L5ZSGLLO.js +0 -2
  181. package/dist/bin/shell/chunks/awk2-ZE5HJBNV.js +0 -2
  182. package/dist/bin/shell/chunks/chunk-2FFXXW3F.js +0 -14
  183. package/dist/bin/shell/chunks/chunk-4E3LY6YK.js +0 -10
  184. package/dist/bin/shell/chunks/chunk-4FNW6LFM.js +0 -5
  185. package/dist/bin/shell/chunks/chunk-4PZYIYYG.js +0 -36
  186. package/dist/bin/shell/chunks/chunk-6L4K3UGO.js +0 -100
  187. package/dist/bin/shell/chunks/chunk-EPIOK4SY.js +0 -6
  188. package/dist/bin/shell/chunks/chunk-IYZRLSTQ.js +0 -2
  189. package/dist/bin/shell/chunks/chunk-JJHAWOIB.js +0 -2
  190. package/dist/bin/shell/chunks/chunk-K47SEEPI.js +0 -6
  191. package/dist/bin/shell/chunks/chunk-KPWFKFSD.js +0 -21
  192. package/dist/bin/shell/chunks/chunk-RYXW3SZQ.js +0 -13
  193. package/dist/bin/shell/chunks/chunk-VZKEP45B.js +0 -21
  194. package/dist/bin/shell/chunks/expr-MLHUWFYI.js +0 -2
  195. package/dist/bin/shell/chunks/flag-coverage-LQ37DA4R.js +0 -2
  196. package/dist/bin/shell/chunks/jq-CXSPO2J5.js +0 -2
  197. package/dist/bin/shell/chunks/ln-5TCJXDGY.js +0 -2
  198. package/dist/bin/shell/chunks/python3-74B25WCY.js +0 -17
  199. package/dist/bin/shell/chunks/sed-DNLJZZXZ.js +0 -2
  200. package/dist/bin/shell/chunks/sleep-GUJH2AMQ.js +0 -2
  201. package/dist/bin/shell/chunks/sqlite3-57UI7HYL.js +0 -2
  202. package/dist/bin/shell/chunks/time-FAWHHOMA.js +0 -2
  203. package/dist/bin/shell/chunks/timeout-4O4YYRTS.js +0 -2
  204. package/dist/bin/shell/chunks/tr-4V5A3V2C.js +0 -2
  205. package/dist/bin/shell/chunks/xan-7NIVZ3HP.js +0 -2
  206. package/dist/bin/shell/chunks/yq-L5ZSGLLO.js +0 -2
  207. package/dist/bundle/chunks/awk2-T6LHPVZE.js +0 -1
  208. package/dist/bundle/chunks/chunk-5BFLZVGH.js +0 -20
  209. package/dist/bundle/chunks/chunk-7DBA735O.js +0 -5
  210. package/dist/bundle/chunks/chunk-7KHLIOOW.js +0 -4
  211. package/dist/bundle/chunks/chunk-AOFQVUAD.js +0 -99
  212. package/dist/bundle/chunks/chunk-BAAVD5NO.js +0 -20
  213. package/dist/bundle/chunks/chunk-BEFDX7IY.js +0 -1
  214. package/dist/bundle/chunks/chunk-KPFCTJEX.js +0 -12
  215. package/dist/bundle/chunks/chunk-LN5KAJOV.js +0 -5
  216. package/dist/bundle/chunks/chunk-NBAARP4B.js +0 -1
  217. package/dist/bundle/chunks/chunk-RHOPHAL6.js +0 -35
  218. package/dist/bundle/chunks/chunk-SL4FN3A5.js +0 -9
  219. package/dist/bundle/chunks/chunk-YIY2RKBW.js +0 -13
  220. package/dist/bundle/chunks/expr-3572LAOT.js +0 -1
  221. package/dist/bundle/chunks/flag-coverage-MPLWXQQK.js +0 -1
  222. package/dist/bundle/chunks/jq-MYSLFARY.js +0 -1
  223. package/dist/bundle/chunks/ln-YAIFIHCT.js +0 -1
  224. package/dist/bundle/chunks/python3-6BKA3FYA.js +0 -16
  225. package/dist/bundle/chunks/sed-3ZCNFRHI.js +0 -1
  226. package/dist/bundle/chunks/sleep-LB7FI6AB.js +0 -1
  227. package/dist/bundle/chunks/sqlite3-FVNA4KNF.js +0 -1
  228. package/dist/bundle/chunks/time-AGNW2ZY6.js +0 -1
  229. package/dist/bundle/chunks/timeout-VN35D5O7.js +0 -1
  230. package/dist/bundle/chunks/tr-2N7Q3KKJ.js +0 -1
  231. package/dist/bundle/chunks/xan-VTO4FP3H.js +0 -1
  232. package/dist/bundle/chunks/yq-JRZFRYSK.js +0 -1
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-2OHMPZNZ.js";import"./chunk-OJDRYQWQ.js";import"./chunk-T2EHE3CV.js";import"./chunk-3RCXHB4E.js";import"./chunk-YNYSPYQ5.js";import"./chunk-GFQRA5P5.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{a as awkCommand2,b as flagsForFuzzing};
@@ -1 +1 @@
1
- import{a,b}from"./chunk-IBFD7QQD.js";import"./chunk-HWKDQ44K.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{a as base64Command,b as flagsForFuzzing};
1
+ import{a,b}from"./chunk-QJ7O6ZN3.js";import"./chunk-HWKDQ44K.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{a as base64Command,b as flagsForFuzzing};
@@ -1 +1 @@
1
- import{a,b}from"./chunk-7DBA735O.js";import"./chunk-7L36YK2X.js";import"./chunk-NUFRM6SI.js";import"./chunk-HWKDQ44K.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{a as catCommand,b as flagsForFuzzing};
1
+ import{a,b}from"./chunk-TXBZCHCQ.js";import"./chunk-7L36YK2X.js";import"./chunk-NUFRM6SI.js";import"./chunk-HWKDQ44K.js";import"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";export{a as catCommand,b as flagsForFuzzing};
@@ -0,0 +1,20 @@
1
+ import{a as de}from"./chunk-OJDRYQWQ.js";import{a as D,b as _}from"./chunk-T2EHE3CV.js";import{a as x}from"./chunk-3RCXHB4E.js";import{a as A,b as H}from"./chunk-YNYSPYQ5.js";import{k as P}from"./chunk-GFQRA5P5.js";import{a as pe,b as fe,c as re}from"./chunk-74CEPOFO.js";var Ue=1e4,Be=100,He=new H(/\s+/);function ie(e={}){let{fieldSep:t=He,maxIterations:n=Ue,maxRecursionDepth:i=Be,maxOutputSize:s=0,fs:a,cwd:o,exec:l,coverage:u,requireDefenseContext:N}=e;return{FS:" ",OFS:" ",ORS:`
2
+ `,OFMT:"%.6g",NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:Object.create(null),arrays:Object.create(null),arrayAliases:new Map,ARGC:0,ARGV:Object.create(null),ENVIRON:Object.create(null),functions:new Map,fieldSep:t,maxIterations:n,maxRecursionDepth:i,maxOutputSize:s,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:"",openedFiles:new Set,fs:a,cwd:o,exec:l,coverage:u,requireDefenseContext:N}}function Ee(e,t,n){switch(n){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return t!==0?e/t:0;case"%":return t!==0?e%t:0;case"^":case"**":return e**t;default:return 0}}function M(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function k(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}async function z(e,t){if(e.type==="regex")return e.pattern;let n=k(await t.evalExpr(e));return n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)),n}async function ye(e,t){return e?e.type==="variable"?e.name:e.type==="field"?`$${Math.floor(M(await t.evalExpr(e.index)))}`:"$0":"$0"}function me(e,t){if(e==="$0")return t.line;if(e.startsWith("$")){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||""}return k(t.vars[e]??"")}function Se(e,t,n){if(e==="$0")n.line=t,n.fields=n.FS===" "?t.trim().split(/\s+/).filter(Boolean):n.fieldSep.split(t),n.NF=n.fields.length;else if(e.startsWith("$")){let i=parseInt(e.slice(1),10)-1;for(;n.fields.length<=i;)n.fields.push("");n.fields[i]=t,n.NF=n.fields.length,n.line=n.fields.join(n.OFS)}else n.vars[e]=t}async function $e(e,t,n){return e.length===0?t.line.length:k(await n.evalExpr(e[0])).length}async function We(e,t,n){if(e.length<2)return"";let i=k(await n.evalExpr(e[0])),s=Math.floor(M(await n.evalExpr(e[1])))-1;if(e.length>=3){let a=Math.floor(M(await n.evalExpr(e[2])));return i.substr(Math.max(0,s),a)}return i.substr(Math.max(0,s))}async function Ve(e,t,n){if(e.length<2)return 0;let i=k(await n.evalExpr(e[0])),s=k(await n.evalExpr(e[1])),a=i.indexOf(s);return a===-1?0:a+1}async function Ke(e,t,n){if(e.length<2)return 0;let i=k(await n.evalExpr(e[0])),s=e[1];if(s.type!=="variable")return 0;let a=s.name,o=t.FS;if(e.length>=3){let u=e[2];if(u.type==="regex")o=A(u.pattern);else{let N=k(await n.evalExpr(u));o=N===" "?A("\\s+"):N}}else t.FS===" "&&(o=A("\\s+"));let l=typeof o=="string"?i.split(o):o.split(i);t.arrays[a]=Object.create(null);for(let u=0;u<l.length;u++)t.arrays[a][String(u+1)]=l[u];return l.length}async function Xe(e,t,n){if(e.length<2)return 0;let i=await z(e[0],n),s=k(await n.evalExpr(e[1])),a=await ye(e[2],n),o=me(a,t);try{let u=A(i).replace(o,we(s)),N=u!==o?1:0;return Se(a,u,t),N}catch{return 0}}async function qe(e,t,n){if(e.length<2)return 0;let i=await z(e[0],n),s=k(await n.evalExpr(e[1])),a=await ye(e[2],n),o=me(a,t);try{let l=A(i,"g"),u=l.match(o),N=u?u.length:0,v=l.replace(o,we(s));return Se(a,v,t),N}catch{return 0}}function we(e){return t=>{let n="",i=0;for(;i<e.length;)if(e[i]==="\\"&&i+1<e.length){let s=e[i+1];s==="&"?(n+="&",i+=2):s==="\\"?(n+="\\",i+=2):(n+=e[i+1],i+=2)}else e[i]==="&"?(n+=t,i++):(n+=e[i],i++);return n}}async function ze(e,t,n){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let i=k(await n.evalExpr(e[0])),s=await z(e[1],n);try{let o=A(s).exec(i);if(o)return t.RSTART=o.index+1,t.RLENGTH=o[0].length,t.RSTART}catch{}return t.RSTART=0,t.RLENGTH=-1,0}async function je(e,t,n){if(e.length<3)return"";let i=await z(e[0],n),s=k(await n.evalExpr(e[1])),a=k(await n.evalExpr(e[2])),o=e.length>=4?k(await n.evalExpr(e[3])):t.line;try{let l=a.toLowerCase()==="g",u=l?0:parseInt(a,10)||1;if(l)return A(i,"g").replace(o,(v,...C)=>Ne(s,v,C.slice(0,-2)));{let N=0;return A(i,"g").replace(o,(C,...O)=>(N++,N===u?Ne(s,C,O.slice(0,-2)):C))}}catch{return o}}function Ne(e,t,n){let i="",s=0;for(;s<e.length;)if(e[s]==="\\"&&s+1<e.length){let a=e[s+1];if(a==="&")i+="&",s+=2;else if(a==="0")i+=t,s+=2;else if(a>="1"&&a<="9"){let o=parseInt(a,10)-1;i+=n[o]||"",s+=2}else a==="n"?(i+=`
3
+ `,s+=2):a==="t"?(i+=" ",s+=2):(i+=a,s+=2)}else e[s]==="&"?(i+=t,s++):(i+=e[s],s++);return i}async function Qe(e,t,n){return e.length===0?"":k(await n.evalExpr(e[0])).toLowerCase()}async function Je(e,t,n){return e.length===0?"":k(await n.evalExpr(e[0])).toUpperCase()}async function Ze(e,t,n){if(e.length===0)return"";let i=k(await n.evalExpr(e[0])),s=[];for(let a=1;a<e.length;a++)s.push(await n.evalExpr(e[a]));return j(i,s)}async function Ye(e,t,n){return e.length===0?0:Math.floor(M(await n.evalExpr(e[0])))}async function et(e,t,n){return e.length===0?0:Math.sqrt(M(await n.evalExpr(e[0])))}async function tt(e,t,n){return e.length===0?0:Math.sin(M(await n.evalExpr(e[0])))}async function nt(e,t,n){return e.length===0?0:Math.cos(M(await n.evalExpr(e[0])))}async function rt(e,t,n){let i=e.length>0?M(await n.evalExpr(e[0])):0,s=e.length>1?M(await n.evalExpr(e[1])):0;return Math.atan2(i,s)}async function it(e,t,n){return e.length===0?0:Math.log(M(await n.evalExpr(e[0])))}async function st(e,t,n){return e.length===0?1:Math.exp(M(await n.evalExpr(e[0])))}function at(e,t,n){return t.random?t.random():Math.random()}async function ot(e,t,n){let i=e.length>0?M(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=i,i}function lt(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function se(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}var U=1e4;function j(e,t){let n=0,i="",s=0;for(;s<e.length;)if(e[s]==="%"&&s+1<e.length){let a=s+1,o="",l="",u="",N,v=a;for(;a<e.length&&/\d/.test(e[a]);)a++;a>v&&e[a]==="$"?(N=parseInt(e.substring(v,a),10)-1,a++):a=v;let C=()=>{if(a<e.length){if(a+1<e.length&&(e[a]==="h"&&e[a+1]==="h"||e[a]==="l"&&e[a+1]==="l")){a+=2;return}/[lzjh]/.test(e[a])&&a++}};for(;a<e.length&&/[-+ #0]/.test(e[a]);)o+=e[a++];if(e[a]==="*"){let d=t[n++],R=d!==void 0?Math.floor(Number(d)):0;R<0?(o+="-",l=String(Math.min(-R,U))):l=String(Math.min(R,U)),a++}else for(;a<e.length&&/\d/.test(e[a]);)l+=e[a++];if(l&&parseInt(l,10)>U&&(l=String(U)),e[a]==="."){if(a++,e[a]==="*"){let d=t[n++];u=String(Math.min(d!==void 0?Math.floor(Number(d)):0,U)),a++}else for(;a<e.length&&/\d/.test(e[a]);)u+=e[a++];u&&parseInt(u,10)>U&&(u=String(U))}C();let O=e[a],w=t[N!==void 0?N:n];switch(O){case"s":{let d=w!==void 0?String(w):"";if(u&&(d=d.substring(0,parseInt(u,10))),l){let R=parseInt(l,10);o.includes("-")?d=d.padEnd(R):d=d.padStart(R)}i+=d,N===void 0&&n++;break}case"d":case"i":{let d=w!==void 0?Math.floor(Number(w)):0;Number.isNaN(d)&&(d=0);let R=d<0,h=Math.abs(d).toString();if(u){let F=parseInt(u,10);h=h.padStart(F,"0")}let c="";R?c="-":o.includes("+")?c="+":o.includes(" ")&&(c=" ");let E=c+h;if(l){let F=parseInt(l,10);o.includes("-")?E=E.padEnd(F):o.includes("0")&&!u?E=c+h.padStart(F-c.length,"0"):E=E.padStart(F)}i+=E,N===void 0&&n++;break}case"f":{let d=w!==void 0?Number(w):0;Number.isNaN(d)&&(d=0);let R=u?parseInt(u,10):6,h=d.toFixed(R);if(l){let c=parseInt(l,10);o.includes("-")?h=h.padEnd(c):h=h.padStart(c)}i+=h,N===void 0&&n++;break}case"e":case"E":{let d=w!==void 0?Number(w):0;Number.isNaN(d)&&(d=0);let R=u?parseInt(u,10):6,h=d.toExponential(R);if(O==="E"&&(h=h.toUpperCase()),l){let c=parseInt(l,10);o.includes("-")?h=h.padEnd(c):h=h.padStart(c)}i+=h,N===void 0&&n++;break}case"g":case"G":{let d=w!==void 0?Number(w):0;Number.isNaN(d)&&(d=0);let R=u?parseInt(u,10):6,h=d!==0?Math.floor(Math.log10(Math.abs(d))):0,c;if(d===0?c="0":h<-4||h>=R?(c=d.toExponential(R-1),O==="G"&&(c=c.toUpperCase())):c=d.toPrecision(R),c.includes(".")&&(c=c.replace(/\.?0+$/,"").replace(/\.?0+e/,"e")),c.includes("e")&&(c=c.replace(/\.?0+e/,"e")),l){let E=parseInt(l,10);o.includes("-")?c=c.padEnd(E):c=c.padStart(E)}i+=c,N===void 0&&n++;break}case"x":case"X":{let d=w!==void 0?Math.floor(Number(w)):0;Number.isNaN(d)&&(d=0);let R=Math.abs(d).toString(16);if(O==="X"&&(R=R.toUpperCase()),u){let E=parseInt(u,10);R=R.padStart(E,"0")}let h=d<0?"-":"",c=h+R;if(l){let E=parseInt(l,10);o.includes("-")?c=c.padEnd(E):o.includes("0")&&!u?c=h+R.padStart(E-h.length,"0"):c=c.padStart(E)}i+=c,N===void 0&&n++;break}case"o":{let d=w!==void 0?Math.floor(Number(w)):0;Number.isNaN(d)&&(d=0);let R=Math.abs(d).toString(8);if(u){let E=parseInt(u,10);R=R.padStart(E,"0")}let h=d<0?"-":"",c=h+R;if(l){let E=parseInt(l,10);o.includes("-")?c=c.padEnd(E):o.includes("0")&&!u?c=h+R.padStart(E-h.length,"0"):c=c.padStart(E)}i+=c,N===void 0&&n++;break}case"c":{typeof w=="number"?i+=String.fromCharCode(w):i+=String(w??"").charAt(0)||"",N===void 0&&n++;break}case"%":i+="%";break;default:i+=e.substring(s,a+1)}s=a+1}else if(e[s]==="\\"&&s+1<e.length){let a=e[s+1];switch(a){case"n":i+=`
4
+ `;break;case"t":i+=" ";break;case"r":i+="\r";break;case"\\":i+="\\";break;default:i+=a}s+=2}else i+=e[s++];return i}var Re=new Map([["length",$e],["substr",We],["index",Ve],["split",Ke],["sub",Xe],["gsub",qe],["match",ze],["gensub",je],["tolower",Qe],["toupper",Je],["sprintf",Ze],["int",Ye],["sqrt",et],["sin",tt],["cos",nt],["atan2",rt],["log",it],["exp",st],["rand",at],["srand",ot],["system",lt("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",se("systime")],["mktime",se("mktime")],["strftime",se("strftime")]]);function b(e){return typeof e=="number"?e!==0:!(e===""||e==="0")}function g(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function S(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}function ae(e){if(typeof e=="number")return!0;let t=String(e).trim();return t===""?!1:!Number.isNaN(Number(t))}function K(e,t){try{return A(e).test(t)}catch{return!1}}function ge(e,t){return t===""?[]:e.FS===" "?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function Q(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function oe(e,t,n){if(t===0)e.line=S(n),e.fields=ge(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push("");e.fields[t-1]=S(n),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function $(e,t){e.line=t,e.fields=ge(e,t),e.NF=e.fields.length}function ve(e,t){if(e.FS=t,t===" ")e.fieldSep=new H(/\s+/);else try{e.fieldSep=A(t)}catch{e.fieldSep=A(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}function J(e,t){switch(t){case"FS":return e.FS;case"OFS":return e.OFS;case"ORS":return e.ORS;case"OFMT":return e.OFMT;case"NR":return e.NR;case"NF":return e.NF;case"FNR":return e.FNR;case"FILENAME":return e.FILENAME;case"RSTART":return e.RSTART;case"RLENGTH":return e.RLENGTH;case"SUBSEP":return e.SUBSEP;case"ARGC":return e.ARGC}return e.vars[t]??""}function W(e,t,n){switch(t){case"FS":ve(e,S(n));return;case"OFS":e.OFS=S(n);return;case"ORS":e.ORS=S(n);return;case"OFMT":e.OFMT=S(n);return;case"NR":e.NR=Math.floor(g(n));return;case"NF":{let i=Math.floor(g(n));if(i<e.NF)e.fields=e.fields.slice(0,i),e.line=e.fields.join(e.OFS);else if(i>e.NF){for(;e.fields.length<i;)e.fields.push("");e.line=e.fields.join(e.OFS)}e.NF=i;return}case"FNR":e.FNR=Math.floor(g(n));return;case"FILENAME":e.FILENAME=S(n);return;case"RSTART":e.RSTART=Math.floor(g(n));return;case"RLENGTH":e.RLENGTH=Math.floor(g(n));return;case"SUBSEP":e.SUBSEP=S(n);return}e.vars[t]=n}function X(e,t){let n=t,i=new Set,s=e.arrayAliases.get(n);for(;s!==void 0&&!i.has(n);)i.add(n),n=s,s=e.arrayAliases.get(n);return n}function Z(e,t,n){if(t==="ARGV")return e.ARGV[n]??"";if(t==="ENVIRON")return e.ENVIRON[n]??"";let i=X(e,t);return e.arrays[i]?.[n]??""}function le(e,t,n,i){let s=X(e,t);e.arrays[s]||(e.arrays[s]=Object.create(null)),e.arrays[s][n]=i}function Ae(e,t,n){if(t==="ARGV")return e.ARGV[n]!==void 0;if(t==="ENVIRON")return e.ENVIRON[n]!==void 0;let i=X(e,t);return e.arrays[i]?.[n]!==void 0}function Ie(e,t,n){let i=X(e,t);e.arrays[i]&&delete e.arrays[i][n]}function ke(e,t){let n=X(e,t);delete e.arrays[n]}var Ce=null;function be(e){Ce=e}function L(e,t){D(e.requireDefenseContext,"awk",t)}function m(e,t,n){return _(e.requireDefenseContext,"awk",t,n)}async function f(e,t){switch(L(e,"expression evaluation"),e.coverage?.hit(`awk:expr:${t.type}`),t.type){case"number":return t.value;case"string":return t.value;case"regex":return K(t.pattern,e.line)?1:0;case"field":return ut(e,t);case"variable":return J(e,t.name);case"array_access":return ct(e,t);case"binary":return ht(e,t);case"unary":return dt(e,t);case"ternary":return b(await m(e,"ternary condition evaluation",()=>f(e,t.condition)))?await m(e,"ternary consequent evaluation",()=>f(e,t.consequent)):await m(e,"ternary alternate evaluation",()=>f(e,t.alternate));case"call":return Et(e,t.name,t.args);case"assignment":return yt(e,t);case"pre_increment":return mt(e,t.operand);case"pre_decrement":return St(e,t.operand);case"post_increment":return wt(e,t.operand);case"post_decrement":return Rt(e,t.operand);case"in":return gt(e,t.key,t.array);case"getline":return vt(e,t.variable,t.file,t.command);case"tuple":return kt(e,t.elements);default:return""}}async function ut(e,t){L(e,"field reference evaluation");let n=Math.floor(g(await m(e,"field index evaluation",()=>f(e,t.index))));return Q(e,n)}async function ct(e,t){L(e,"array access evaluation");let n=S(await m(e,"array key evaluation",()=>f(e,t.key)));return Z(e,t.array,n)}async function ht(e,t){L(e,"binary expression evaluation");let n=t.operator;if(n==="||")return b(await m(e,"logical-or left evaluation",()=>f(e,t.left)))||b(await m(e,"logical-or right evaluation",()=>f(e,t.right)))?1:0;if(n==="&&")return b(await m(e,"logical-and left evaluation",()=>f(e,t.left)))&&b(await m(e,"logical-and right evaluation",()=>f(e,t.right)))?1:0;if(n==="~"){let l=await m(e,"regex left evaluation",()=>f(e,t.left));t.right.type==="regex"&&e.coverage?.hit("awk:expr:regex");let u=t.right.type==="regex"?t.right.pattern:S(await m(e,"regex right evaluation",()=>f(e,t.right)));try{return A(u).test(S(l))?1:0}catch{return 0}}if(n==="!~"){let l=await m(e,"negated-regex left evaluation",()=>f(e,t.left));t.right.type==="regex"&&e.coverage?.hit("awk:expr:regex");let u=t.right.type==="regex"?t.right.pattern:S(await m(e,"negated-regex right evaluation",()=>f(e,t.right)));try{return A(u).test(S(l))?0:1}catch{return 1}}let i=await m(e,"binary left evaluation",()=>f(e,t.left)),s=await m(e,"binary right evaluation",()=>f(e,t.right));if(n===" "){let l=S(i)+S(s);if(e.maxOutputSize>0&&l.length>e.maxOutputSize)throw new P(`awk: string concatenation size limit exceeded (${e.maxOutputSize} bytes)`,"string_length",e.output);return l}if(pt(n))return ft(i,s,n);let a=g(i),o=g(s);return Ee(a,o,n)}function pt(e){return["<","<=",">",">=","==","!="].includes(e)}function ft(e,t,n){let i=ae(e),s=ae(t);if(i&&s){let l=g(e),u=g(t);switch(n){case"<":return l<u?1:0;case"<=":return l<=u?1:0;case">":return l>u?1:0;case">=":return l>=u?1:0;case"==":return l===u?1:0;case"!=":return l!==u?1:0}}let a=S(e),o=S(t);switch(n){case"<":return a<o?1:0;case"<=":return a<=o?1:0;case">":return a>o?1:0;case">=":return a>=o?1:0;case"==":return a===o?1:0;case"!=":return a!==o?1:0}return 0}async function dt(e,t){L(e,"unary expression evaluation");let n=await m(e,"unary operand evaluation",()=>f(e,t.operand));switch(t.operator){case"!":return b(n)?0:1;case"-":return-g(n);case"+":return+g(n);default:return n}}async function Et(e,t,n){L(e,"function call evaluation");let i=Re.get(t);if(i)return i(n,e,{evalExpr:a=>f(e,a)});let s=e.functions.get(t);return s?Nt(e,s,n):""}async function Nt(e,t,n){if(L(e,"user function call"),e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new P(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let i=Object.create(null);for(let l of t.params)i[l]=e.vars[l];let s=[];for(let l=0;l<t.params.length;l++){let u=t.params[l];if(l<n.length){let N=n[l];N.type==="variable"&&(e.arrayAliases.set(u,N.name),s.push(u));let v=await m(e,"user function argument evaluation",()=>f(e,N));e.vars[u]=v}else e.vars[u]=""}e.hasReturn=!1,e.returnValue=void 0;let a=Ce;a&&await m(e,"user function body execution",()=>a(e,t.body.statements));let o=e.returnValue??"";for(let l of t.params)i[l]!==void 0?e.vars[l]=i[l]:delete e.vars[l];for(let l of s)e.arrayAliases.delete(l);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,o}async function yt(e,t){L(e,"assignment evaluation");let n=await m(e,"assignment value evaluation",()=>f(e,t.value)),i=t.target,s=t.operator,a;if(s==="=")a=n;else{let o;if(i.type==="field"){let N=Math.floor(g(await m(e,"assignment field index",()=>f(e,i.index))));o=Q(e,N)}else if(i.type==="variable")o=J(e,i.name);else{let N=S(await m(e,"assignment array key",()=>f(e,i.key)));o=Z(e,i.array,N)}let l=g(o),u=g(n);switch(s){case"+=":a=l+u;break;case"-=":a=l-u;break;case"*=":a=l*u;break;case"/=":a=u!==0?l/u:0;break;case"%=":a=u!==0?l%u:0;break;case"^=":a=l**u;break;default:a=n}}if(i.type==="field"){let o=Math.floor(g(await m(e,"assignment target field index",()=>f(e,i.index))));oe(e,o,a)}else if(i.type==="variable")W(e,i.name,a);else{let o=S(await m(e,"assignment target array key",()=>f(e,i.key)));le(e,i.array,o,a)}return a}async function Y(e,t,n,i){L(e,"inc/dec evaluation");let s;if(t.type==="field"){let a=Math.floor(g(await m(e,"inc/dec field index",()=>f(e,t.index))));s=g(Q(e,a)),oe(e,a,s+n)}else if(t.type==="variable")s=g(J(e,t.name)),W(e,t.name,s+n);else{let a=S(await m(e,"inc/dec array key",()=>f(e,t.key)));s=g(Z(e,t.array,a)),le(e,t.array,a,s+n)}return i?s+n:s}async function mt(e,t){return Y(e,t,1,!0)}async function St(e,t){return Y(e,t,-1,!0)}async function wt(e,t){return Y(e,t,1,!1)}async function Rt(e,t){return Y(e,t,-1,!1)}async function gt(e,t,n){L(e,"in-expression evaluation");let i;if(t.type==="tuple"){e.coverage?.hit("awk:expr:tuple");let s=[];for(let a of t.elements)s.push(S(await m(e,"tuple key element evaluation",()=>f(e,a))));i=s.join(e.SUBSEP)}else i=S(await m(e,"in-expression key evaluation",()=>f(e,t)));return Ae(e,n,i)?1:0}async function vt(e,t,n,i){if(L(e,"getline evaluation"),i)return At(e,t,i);if(n)return It(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let s=e.lineIndex+1;if(s>=e.lines.length)return 0;let a=e.lines[s];return t?W(e,t,a):$(e,a),e.NR++,e.lineIndex=s,1}async function At(e,t,n){let i=e.exec;if(!i)return-1;L(e,"getline command source");let s=S(await m(e,"getline command expression",()=>f(e,n))),a=`__cmd_${s}`,o=`__cmdi_${s}`,l,u;if(e.vars[a]===void 0)try{l=(await m(e,"getline command exec",()=>i(s))).stdout.split(`
5
+ `),l.length>0&&l[l.length-1]===""&&l.pop(),e.vars[a]=JSON.stringify(l),e.vars[o]=-1,u=-1}catch(C){if(C instanceof x)throw C;return-1}else l=JSON.parse(e.vars[a]),u=e.vars[o];let N=u+1;if(N>=l.length)return 0;let v=l[N];return e.vars[o]=N,t?W(e,t,v):$(e,v),1}async function It(e,t,n){let i=e.fs;if(!i||!e.cwd)return-1;L(e,"getline file source");let s=S(await m(e,"getline filename evaluation",()=>f(e,n)));if(s==="/dev/null")return 0;let a=i.resolvePath(e.cwd,s),o=`__fc_${a}`,l=`__fi_${a}`,u,N;if(e.vars[o]===void 0)try{u=(await m(e,"getline file read",()=>i.readFile(a))).split(`
6
+ `),u.length>0&&u[u.length-1]===""&&u.pop(),e.vars[o]=JSON.stringify(u),e.vars[l]=-1,N=-1}catch(O){if(O instanceof x)throw O;return-1}else u=JSON.parse(e.vars[o]),N=e.vars[l];let v=N+1;if(v>=u.length)return 0;let C=u[v];return e.vars[l]=v,t?W(e,t,C):$(e,C),1}async function kt(e,t){if(L(e,"tuple evaluation"),t.length===0)return"";for(let n=0;n<t.length-1;n++)await m(e,"tuple intermediate element",()=>f(e,t[n]));return m(e,"tuple final element",()=>f(e,t[t.length-1]))}be(V);function ue(e){if(e.maxOutputSize>0&&e.output.length>e.maxOutputSize)throw new P(`awk: output size limit exceeded (${e.maxOutputSize} bytes)`,"string_length",e.output)}function T(e,t){D(e.requireDefenseContext,"awk",t)}function y(e,t,n){return _(e.requireDefenseContext,"awk",t,n)}async function V(e,t){T(e,"block execution");for(let n of t)if(await y(e,"statement execution",()=>B(e,n)),Ct(e))break}function Ct(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function B(e,t){switch(T(e,"single statement execution"),e.coverage?.hit(`awk:stmt:${t.type}`),t.type){case"block":await y(e,"nested block statement",()=>V(e,t.statements));break;case"expr_stmt":await y(e,"expression statement",()=>f(e,t.expression));break;case"print":await y(e,"print statement",()=>bt(e,t.args,t.output));break;case"printf":await y(e,"printf statement",()=>Ot(e,t.format,t.args,t.output));break;case"if":await y(e,"if statement",()=>Lt(e,t));break;case"while":await y(e,"while statement",()=>Mt(e,t));break;case"do_while":await y(e,"do-while statement",()=>Pt(e,t));break;case"for":await y(e,"for statement",()=>Tt(e,t));break;case"for_in":await y(e,"for-in statement",()=>Ft(e,t));break;case"break":e.loopBreak=!0;break;case"continue":e.loopContinue=!0;break;case"next":e.shouldNext=!0;break;case"nextfile":e.shouldNextFile=!0;break;case"exit":e.shouldExit=!0;{let n=t.code;e.exitCode=n?Math.floor(g(await y(e,"exit code expression",()=>f(e,n)))):0}break;case"return":e.hasReturn=!0;{let n=t.value;e.returnValue=n?await y(e,"return expression",()=>f(e,n)):""}break;case"delete":await y(e,"delete statement",()=>Dt(e,t.target));break}}async function bt(e,t,n){T(e,"print execution");let i=[];for(let a of t){let o=await y(e,"print argument evaluation",()=>f(e,a));typeof o=="number"?Number.isInteger(o)&&Math.abs(o)<Number.MAX_SAFE_INTEGER?i.push(String(o)):i.push(j(e.OFMT,[o])):i.push(S(o))}let s=i.join(e.OFS)+e.ORS;n?await y(e,"print redirection write",()=>Oe(e,n.redirect,n.file,s)):(e.output+=s,ue(e))}async function Ot(e,t,n,i){T(e,"printf execution");let s=S(await y(e,"printf format evaluation",()=>f(e,t))),a=[];for(let l of n)a.push(await y(e,"printf argument evaluation",()=>f(e,l)));let o=j(s,a);i?await y(e,"printf redirection write",()=>Oe(e,i.redirect,i.file,o)):(e.output+=o,ue(e))}async function Oe(e,t,n,i){T(e,"file write execution");let s=e.fs;if(!s||!e.cwd){e.output+=i,ue(e);return}let a=S(await y(e,"redirection filename evaluation",()=>f(e,n))),o=s.resolvePath(e.cwd,a);t===">"?e.openedFiles.has(o)?await y(e,"redirection append write",()=>s.appendFile(o,i)):(await y(e,"redirection overwrite write",()=>s.writeFile(o,i)),e.openedFiles.add(o)):(e.openedFiles.has(o)||e.openedFiles.add(o),await y(e,"redirection append mode write",()=>s.appendFile(o,i)))}async function Lt(e,t){if(T(e,"if execution"),b(await y(e,"if condition evaluation",()=>f(e,t.condition))))await y(e,"if consequent execution",()=>B(e,t.consequent));else if(t.alternate){let n=t.alternate;await y(e,"if alternate execution",()=>B(e,n))}}async function Mt(e,t){T(e,"while execution");let n=0;for(;b(await y(e,"while condition evaluation",()=>f(e,t.condition)));){if(n++,n>e.maxIterations)throw new P(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await y(e,"while body execution",()=>B(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function Pt(e,t){T(e,"do-while execution");let n=0;do{if(n++,n>e.maxIterations)throw new P(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await y(e,"do-while body execution",()=>B(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(b(await y(e,"do-while condition evaluation",()=>f(e,t.condition))))}async function Tt(e,t){T(e,"for execution");let n=t.init,i=t.condition,s=t.update;n&&await y(e,"for init evaluation",()=>f(e,n));let a=0;for(;!i||b(await y(e,"for condition evaluation",()=>f(e,i)));){if(a++,a>e.maxIterations)throw new P(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await y(e,"for body execution",()=>B(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;s&&await y(e,"for update evaluation",()=>f(e,s))}}async function Ft(e,t){T(e,"for-in execution");let n=e.arrays[t.array];if(n)for(let i of Object.keys(n)){if(e.vars[t.variable]=i,e.loopContinue=!1,await y(e,"for-in body execution",()=>B(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function Dt(e,t){if(T(e,"delete execution"),t.type==="array_access"){let n=S(await y(e,"delete key evaluation",()=>f(e,t.key)));Ie(e,t.array,n)}else t.type==="variable"&&ke(e,t.name)}var q=class{ctx;program=null;rangeStates=[];constructor(t){this.ctx=t}assertDefenseContext(t){D(this.ctx.requireDefenseContext,"awk",t)}withDefenseContext(t,n){return _(this.ctx.requireDefenseContext,"awk",t,n)}execute(t){this.assertDefenseContext("program initialization"),this.program=t,this.ctx.output="";for(let n of t.functions)this.ctx.functions.set(n.name,n);this.rangeStates=t.rules.map(()=>!1)}async executeBegin(){if(this.assertDefenseContext("BEGIN execution entry"),!!this.program){for(let t of this.program.rules)if(t.pattern?.type==="begin"&&(await this.withDefenseContext("BEGIN block execution",()=>V(this.ctx,t.action.statements)),this.ctx.shouldExit))break}}async executeLine(t){if(this.assertDefenseContext("line execution entry"),!(!this.program||this.ctx.shouldExit)){$(this.ctx,t),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let n=0;n<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);n++){let i=this.program.rules[n];i.pattern?.type==="begin"||i.pattern?.type==="end"||await this.withDefenseContext("rule match",()=>this.matchesRule(i,n))&&await this.withDefenseContext("rule block execution",()=>V(this.ctx,i.action.statements))}}}async executeEnd(){if(this.assertDefenseContext("END execution entry"),!!this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let t of this.program.rules)if(t.pattern?.type==="end"&&(await this.withDefenseContext("END block execution",()=>V(this.ctx,t.action.statements)),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(t,n){this.assertDefenseContext("rule matching");let i=t.pattern;if(!i)return!0;switch(i.type){case"begin":case"end":return!1;case"regex_pattern":return K(i.pattern,this.ctx.line);case"expr_pattern":return b(await this.withDefenseContext("expression pattern evaluation",()=>f(this.ctx,i.expression)));case"range":{let s=await this.withDefenseContext("range start pattern",()=>this.matchPattern(i.start)),a=await this.withDefenseContext("range end pattern",()=>this.matchPattern(i.end));return this.rangeStates[n]?(a&&(this.rangeStates[n]=!1),!0):s?(this.rangeStates[n]=!0,a&&(this.rangeStates[n]=!1),!0):!1}default:return!1}}async matchPattern(t){switch(this.assertDefenseContext("pattern matching"),t.type){case"regex_pattern":return K(t.pattern,this.ctx.line);case"expr_pattern":return b(await this.withDefenseContext("nested expression pattern",()=>f(this.ctx,t.expression)));default:return!1}}};var r;(function(e){e.NUMBER="NUMBER",e.STRING="STRING",e.REGEX="REGEX",e.IDENT="IDENT",e.BEGIN="BEGIN",e.END="END",e.IF="IF",e.ELSE="ELSE",e.WHILE="WHILE",e.DO="DO",e.FOR="FOR",e.IN="IN",e.BREAK="BREAK",e.CONTINUE="CONTINUE",e.NEXT="NEXT",e.NEXTFILE="NEXTFILE",e.EXIT="EXIT",e.RETURN="RETURN",e.DELETE="DELETE",e.FUNCTION="FUNCTION",e.PRINT="PRINT",e.PRINTF="PRINTF",e.GETLINE="GETLINE",e.PLUS="PLUS",e.MINUS="MINUS",e.STAR="STAR",e.SLASH="SLASH",e.PERCENT="PERCENT",e.CARET="CARET",e.EQ="EQ",e.NE="NE",e.LT="LT",e.GT="GT",e.LE="LE",e.GE="GE",e.MATCH="MATCH",e.NOT_MATCH="NOT_MATCH",e.AND="AND",e.OR="OR",e.NOT="NOT",e.ASSIGN="ASSIGN",e.PLUS_ASSIGN="PLUS_ASSIGN",e.MINUS_ASSIGN="MINUS_ASSIGN",e.STAR_ASSIGN="STAR_ASSIGN",e.SLASH_ASSIGN="SLASH_ASSIGN",e.PERCENT_ASSIGN="PERCENT_ASSIGN",e.CARET_ASSIGN="CARET_ASSIGN",e.INCREMENT="INCREMENT",e.DECREMENT="DECREMENT",e.QUESTION="QUESTION",e.COLON="COLON",e.COMMA="COMMA",e.SEMICOLON="SEMICOLON",e.NEWLINE="NEWLINE",e.LPAREN="LPAREN",e.RPAREN="RPAREN",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.LBRACKET="LBRACKET",e.RBRACKET="RBRACKET",e.DOLLAR="DOLLAR",e.APPEND="APPEND",e.PIPE="PIPE",e.EOF="EOF"})(r||(r={}));var _t=new Map([["BEGIN",r.BEGIN],["END",r.END],["if",r.IF],["else",r.ELSE],["while",r.WHILE],["do",r.DO],["for",r.FOR],["in",r.IN],["break",r.BREAK],["continue",r.CONTINUE],["next",r.NEXT],["nextfile",r.NEXTFILE],["exit",r.EXIT],["return",r.RETURN],["delete",r.DELETE],["function",r.FUNCTION],["print",r.PRINT],["printf",r.PRINTF],["getline",r.GETLINE]]);function Gt(e){return e.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var ee=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(t){this.input=t}tokenize(){let t=[];for(;this.pos<this.input.length;){let n=this.nextToken();n&&(t.push(n),this.lastTokenType=n.type)}return t.push(this.makeToken(r.EOF,"")),t}makeToken(t,n){return{type:t,value:n,line:this.line,column:this.column}}peek(t=0){return this.input[this.pos+t]||""}advance(){let t=this.input[this.pos++]||"";return t===`
7
+ `?(this.line++,this.column=1):this.column++,t}skipWhitespace(){for(;this.pos<this.input.length;){let t=this.peek();if(t===" "||t===" "||t==="\r")this.advance();else if(t==="\\")if(this.peek(1)===`
8
+ `)this.advance(),this.advance();else break;else if(t==="#")for(;this.pos<this.input.length&&this.peek()!==`
9
+ `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let t=this.line,n=this.column,i=this.peek();return i===`
10
+ `?(this.advance(),{type:r.NEWLINE,value:`
11
+ `,line:t,column:n}):i==='"'?this.readString():i==="/"&&this.canBeRegex()?this.readRegex():this.isDigit(i)||i==="."&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(i)||i==="_"?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,r.NEWLINE,r.SEMICOLON,r.LBRACE,r.RBRACE,r.LPAREN,r.LBRACKET,r.COMMA,r.ASSIGN,r.PLUS_ASSIGN,r.MINUS_ASSIGN,r.STAR_ASSIGN,r.SLASH_ASSIGN,r.PERCENT_ASSIGN,r.CARET_ASSIGN,r.AND,r.OR,r.NOT,r.MATCH,r.NOT_MATCH,r.QUESTION,r.COLON,r.LT,r.GT,r.LE,r.GE,r.EQ,r.NE,r.PLUS,r.MINUS,r.STAR,r.PERCENT,r.CARET,r.PRINT,r.PRINTF,r.IF,r.WHILE,r.DO,r.FOR,r.RETURN]).has(this.lastTokenType)}readString(){let t=this.line,n=this.column;this.advance();let i="";for(;this.pos<this.input.length&&this.peek()!=='"';)if(this.peek()==="\\"){this.advance();let s=this.advance();switch(s){case"n":i+=`
12
+ `;break;case"t":i+=" ";break;case"r":i+="\r";break;case"f":i+="\f";break;case"b":i+="\b";break;case"v":i+="\v";break;case"a":i+="\x07";break;case"\\":i+="\\";break;case'"':i+='"';break;case"/":i+="/";break;case"x":{let a="";for(;a.length<2&&/[0-9a-fA-F]/.test(this.peek());)a+=this.advance();a.length>0?i+=String.fromCharCode(parseInt(a,16)):i+="x";break}default:if(/[0-7]/.test(s)){let a=s;for(;a.length<3&&/[0-7]/.test(this.peek());)a+=this.advance();i+=String.fromCharCode(parseInt(a,8))}else i+=s}}else i+=this.advance();return this.peek()==='"'&&this.advance(),{type:r.STRING,value:i,line:t,column:n}}readRegex(){let t=this.line,n=this.column;this.advance();let i="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")i+=this.advance(),this.pos<this.input.length&&(i+=this.advance());else{if(this.peek()===`
13
+ `)break;i+=this.advance()}return this.peek()==="/"&&this.advance(),i=Gt(i),{type:r.REGEX,value:i,line:t,column:n}}readNumber(){let t=this.line,n=this.column,i="";for(;this.isDigit(this.peek());)i+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(i+=this.advance();this.isDigit(this.peek());)i+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(i+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(i+=this.advance());this.isDigit(this.peek());)i+=this.advance();return{type:r.NUMBER,value:parseFloat(i),line:t,column:n}}readIdentifier(){let t=this.line,n=this.column,i="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)i+=this.advance();let s=_t.get(i);return s!==void 0?{type:s,value:i,line:t,column:n}:{type:r.IDENT,value:i,line:t,column:n}}readOperator(){let t=this.line,n=this.column,i=this.advance(),s=this.peek();switch(i){case"+":return s==="+"?(this.advance(),{type:r.INCREMENT,value:"++",line:t,column:n}):s==="="?(this.advance(),{type:r.PLUS_ASSIGN,value:"+=",line:t,column:n}):{type:r.PLUS,value:"+",line:t,column:n};case"-":return s==="-"?(this.advance(),{type:r.DECREMENT,value:"--",line:t,column:n}):s==="="?(this.advance(),{type:r.MINUS_ASSIGN,value:"-=",line:t,column:n}):{type:r.MINUS,value:"-",line:t,column:n};case"*":return s==="*"?(this.advance(),{type:r.CARET,value:"**",line:t,column:n}):s==="="?(this.advance(),{type:r.STAR_ASSIGN,value:"*=",line:t,column:n}):{type:r.STAR,value:"*",line:t,column:n};case"/":return s==="="?(this.advance(),{type:r.SLASH_ASSIGN,value:"/=",line:t,column:n}):{type:r.SLASH,value:"/",line:t,column:n};case"%":return s==="="?(this.advance(),{type:r.PERCENT_ASSIGN,value:"%=",line:t,column:n}):{type:r.PERCENT,value:"%",line:t,column:n};case"^":return s==="="?(this.advance(),{type:r.CARET_ASSIGN,value:"^=",line:t,column:n}):{type:r.CARET,value:"^",line:t,column:n};case"=":return s==="="?(this.advance(),{type:r.EQ,value:"==",line:t,column:n}):{type:r.ASSIGN,value:"=",line:t,column:n};case"!":return s==="="?(this.advance(),{type:r.NE,value:"!=",line:t,column:n}):s==="~"?(this.advance(),{type:r.NOT_MATCH,value:"!~",line:t,column:n}):{type:r.NOT,value:"!",line:t,column:n};case"<":return s==="="?(this.advance(),{type:r.LE,value:"<=",line:t,column:n}):{type:r.LT,value:"<",line:t,column:n};case">":return s==="="?(this.advance(),{type:r.GE,value:">=",line:t,column:n}):s===">"?(this.advance(),{type:r.APPEND,value:">>",line:t,column:n}):{type:r.GT,value:">",line:t,column:n};case"&":return s==="&"?(this.advance(),{type:r.AND,value:"&&",line:t,column:n}):{type:r.IDENT,value:"&",line:t,column:n};case"|":return s==="|"?(this.advance(),{type:r.OR,value:"||",line:t,column:n}):{type:r.PIPE,value:"|",line:t,column:n};case"~":return{type:r.MATCH,value:"~",line:t,column:n};case"?":return{type:r.QUESTION,value:"?",line:t,column:n};case":":return{type:r.COLON,value:":",line:t,column:n};case",":return{type:r.COMMA,value:",",line:t,column:n};case";":return{type:r.SEMICOLON,value:";",line:t,column:n};case"(":return{type:r.LPAREN,value:"(",line:t,column:n};case")":return{type:r.RPAREN,value:")",line:t,column:n};case"{":return{type:r.LBRACE,value:"{",line:t,column:n};case"}":return{type:r.RBRACE,value:"}",line:t,column:n};case"[":return{type:r.LBRACKET,value:"[",line:t,column:n};case"]":return{type:r.RBRACKET,value:"]",line:t,column:n};case"$":return{type:r.DOLLAR,value:"$",line:t,column:n};default:return{type:r.IDENT,value:i,line:t,column:n}}}isDigit(t){return t>="0"&&t<="9"}isAlpha(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}isAlphaNumeric(t){return this.isDigit(t)||this.isAlpha(t)}};var p={LPAREN:"LPAREN",RPAREN:"RPAREN",QUESTION:"QUESTION",NEWLINE:"NEWLINE",SEMICOLON:"SEMICOLON",RBRACE:"RBRACE",COMMA:"COMMA",PIPE:"PIPE",GT:"GT",APPEND:"APPEND",AND:"AND",OR:"OR",ASSIGN:"ASSIGN",PLUS_ASSIGN:"PLUS_ASSIGN",MINUS_ASSIGN:"MINUS_ASSIGN",STAR_ASSIGN:"STAR_ASSIGN",SLASH_ASSIGN:"SLASH_ASSIGN",PERCENT_ASSIGN:"PERCENT_ASSIGN",CARET_ASSIGN:"CARET_ASSIGN",RBRACKET:"RBRACKET",COLON:"COLON",IN:"IN",PRINT:"PRINT",PRINTF:"PRINTF",IDENT:"IDENT",LT:"LT",LE:"LE",GE:"GE",EQ:"EQ",NE:"NE",MATCH:"MATCH",NOT_MATCH:"NOT_MATCH",NUMBER:"NUMBER",STRING:"STRING",DOLLAR:"DOLLAR",NOT:"NOT",MINUS:"MINUS",PLUS:"PLUS",INCREMENT:"INCREMENT",DECREMENT:"DECREMENT"};function Fe(e){e.expect(p.PRINT);let t=[];if(e.check(p.NEWLINE)||e.check(p.SEMICOLON)||e.check(p.RBRACE)||e.check(p.PIPE)||e.check(p.GT)||e.check(p.APPEND))t.push({type:"field",index:{type:"number",value:0}});else for(t.push(te(e));e.check(p.COMMA);)e.advance(),t.push(te(e));let n;return e.check(p.GT)?(e.advance(),n={redirect:">",file:e.parsePrimary()}):e.check(p.APPEND)&&(e.advance(),n={redirect:">>",file:e.parsePrimary()}),{type:"print",args:t,output:n}}function te(e){return xt(e)?ce(e,!0):ce(e,!1)}function ce(e,t){let n=t?e.parseTernary():Ut(e);if(e.match(p.ASSIGN,p.PLUS_ASSIGN,p.MINUS_ASSIGN,p.STAR_ASSIGN,p.SLASH_ASSIGN,p.PERCENT_ASSIGN,p.CARET_ASSIGN)){let i=e.advance(),s=ce(e,t);if(n.type!=="variable"&&n.type!=="field"&&n.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:new Map([["=","="],["+=","+="],["-=","-="],["*=","*="],["/=","/="],["%=","%="],["^=","^="]]).get(i.value)??"=",target:n,value:s}}return n}function xt(e){let t=0,n=e.pos;for(;n<e.tokens.length;){let i=e.tokens[n];if(i.type===p.LPAREN&&t++,i.type===p.RPAREN&&t--,i.type===p.QUESTION&&t===0)return!0;if(i.type===p.NEWLINE||i.type===p.SEMICOLON||i.type===p.RBRACE||i.type===p.COMMA||i.type===p.PIPE)return!1;n++}return!1}function Ut(e){let t=Le(e);for(;e.check(p.OR);){e.advance();let n=Le(e);t={type:"binary",operator:"||",left:t,right:n}}return t}function Le(e){let t=Me(e);for(;e.check(p.AND);){e.advance();let n=Me(e);t={type:"binary",operator:"&&",left:t,right:n}}return t}function Me(e){let t=Bt(e);if(e.check(p.IN)){e.advance();let n=String(e.expect(p.IDENT).value);return{type:"in",key:t,array:n}}return t}function Bt(e){let t=Pe(e);for(;Ht(e)&&!$t(e);){let n=Pe(e);t={type:"binary",operator:" ",left:t,right:n}}return t}function Pe(e){let t=Te(e);for(;e.match(p.MATCH,p.NOT_MATCH);){let n=e.advance().type===p.MATCH?"~":"!~",i=Te(e);t={type:"binary",operator:n,left:t,right:i}}return t}function Te(e){let t=e.parseAddSub();for(;e.match(p.LT,p.LE,p.GE,p.EQ,p.NE);){let n=e.advance(),i=e.parseAddSub();t={type:"binary",operator:new Map([["<","<"],["<=","<="],[">=",">="],["==","=="],["!=","!="]]).get(n.value)??"==",left:t,right:i}}return t}function Ht(e){return e.match(p.NUMBER,p.STRING,p.IDENT,p.DOLLAR,p.LPAREN,p.NOT,p.MINUS,p.PLUS,p.INCREMENT,p.DECREMENT)}function $t(e){return e.match(p.AND,p.OR,p.QUESTION,p.ASSIGN,p.PLUS_ASSIGN,p.MINUS_ASSIGN,p.STAR_ASSIGN,p.SLASH_ASSIGN,p.PERCENT_ASSIGN,p.CARET_ASSIGN,p.COMMA,p.SEMICOLON,p.NEWLINE,p.RBRACE,p.RPAREN,p.RBRACKET,p.COLON,p.PIPE,p.APPEND,p.GT,p.IN)}function De(e){e.expect(p.PRINTF);let t=e.check(p.LPAREN);t&&(e.advance(),e.skipNewlines());let n=t?e.parseExpression():te(e),i=[];for(;e.check(p.COMMA);)e.advance(),t&&e.skipNewlines(),i.push(t?e.parseExpression():te(e));t&&(e.skipNewlines(),e.expect(p.RPAREN));let s;return e.check(p.GT)?(e.advance(),s={redirect:">",file:e.parsePrimary()}):e.check(p.APPEND)&&(e.advance(),s={redirect:">>",file:e.parsePrimary()}),{type:"printf",format:n,args:i,output:s}}var ne=class{tokens=[];pos=0;parse(t){let n=new ee(t);return this.tokens=n.tokenize(),this.pos=0,this.parseProgram()}setPos(t){this.pos=t}current(){return this.tokens[this.pos]||{type:r.EOF,value:"",line:0,column:0}}advance(){let t=this.current();return this.pos<this.tokens.length&&this.pos++,t}match(...t){return t.includes(this.current().type)}check(t){return this.current().type===t}expect(t,n){if(!this.check(t)){let i=this.current();throw new Error(n||`Expected ${t}, got ${i.type} at line ${i.line}:${i.column}`)}return this.advance()}skipNewlines(){for(;this.check(r.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(r.NEWLINE)||this.check(r.SEMICOLON);)this.advance()}parseProgram(){let t=[],n=[];for(this.skipNewlines();!this.check(r.EOF)&&(this.skipNewlines(),!this.check(r.EOF));)this.check(r.FUNCTION)?t.push(this.parseFunction()):n.push(this.parseRule()),this.skipTerminators();return{functions:t,rules:n}}parseFunction(){this.expect(r.FUNCTION);let t=this.expect(r.IDENT).value;this.expect(r.LPAREN);let n=[];if(!this.check(r.RPAREN))for(n.push(this.expect(r.IDENT).value);this.check(r.COMMA);)this.advance(),n.push(this.expect(r.IDENT).value);this.expect(r.RPAREN),this.skipNewlines();let i=this.parseBlock();return{name:t,params:n,body:i}}parseRule(){let t;if(this.check(r.BEGIN))this.advance(),t={type:"begin"};else if(this.check(r.END))this.advance(),t={type:"end"};else if(this.check(r.LBRACE))t=void 0;else if(this.check(r.REGEX)){let i=this.advance();if(this.check(r.AND)||this.check(r.OR)){let s={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:i.value}};t={type:"expr_pattern",expression:this.parseLogicalOrRest(s)}}else{let s={type:"regex_pattern",pattern:i.value};if(this.check(r.COMMA)){this.advance();let a;this.check(r.REGEX)?a={type:"regex_pattern",pattern:this.advance().value}:a={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:s,end:a}}else t=s}}else{let s={type:"expr_pattern",expression:this.parseExpression()};if(this.check(r.COMMA)){this.advance();let a;this.check(r.REGEX)?a={type:"regex_pattern",pattern:this.advance().value}:a={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:s,end:a}}else t=s}this.skipNewlines();let n;return this.check(r.LBRACE)?n=this.parseBlock():n={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:t,action:n}}parseBlock(){this.expect(r.LBRACE),this.skipNewlines();let t=[];for(;!this.check(r.RBRACE)&&!this.check(r.EOF);)t.push(this.parseStatement()),this.skipTerminators();return this.expect(r.RBRACE),{type:"block",statements:t}}parseStatement(){if(this.check(r.SEMICOLON)||this.check(r.NEWLINE))return this.advance(),{type:"block",statements:[]};if(this.check(r.LBRACE))return this.parseBlock();if(this.check(r.IF))return this.parseIf();if(this.check(r.WHILE))return this.parseWhile();if(this.check(r.DO))return this.parseDoWhile();if(this.check(r.FOR))return this.parseFor();if(this.check(r.BREAK))return this.advance(),{type:"break"};if(this.check(r.CONTINUE))return this.advance(),{type:"continue"};if(this.check(r.NEXT))return this.advance(),{type:"next"};if(this.check(r.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(r.EXIT)){this.advance();let n;return!this.check(r.NEWLINE)&&!this.check(r.SEMICOLON)&&!this.check(r.RBRACE)&&!this.check(r.EOF)&&(n=this.parseExpression()),{type:"exit",code:n}}if(this.check(r.RETURN)){this.advance();let n;return!this.check(r.NEWLINE)&&!this.check(r.SEMICOLON)&&!this.check(r.RBRACE)&&!this.check(r.EOF)&&(n=this.parseExpression()),{type:"return",value:n}}if(this.check(r.DELETE)){this.advance();let n=this.parsePrimary();if(n.type!=="array_access"&&n.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:n}}return this.check(r.PRINT)?Fe(this):this.check(r.PRINTF)?De(this):{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(r.IF),this.expect(r.LPAREN);let t=this.parseExpression();this.expect(r.RPAREN),this.skipNewlines();let n=this.parseStatement();this.skipTerminators();let i;return this.check(r.ELSE)&&(this.advance(),this.skipNewlines(),i=this.parseStatement()),{type:"if",condition:t,consequent:n,alternate:i}}parseWhile(){this.expect(r.WHILE),this.expect(r.LPAREN);let t=this.parseExpression();this.expect(r.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:"while",condition:t,body:n}}parseDoWhile(){this.expect(r.DO),this.skipNewlines();let t=this.parseStatement();this.skipNewlines(),this.expect(r.WHILE),this.expect(r.LPAREN);let n=this.parseExpression();return this.expect(r.RPAREN),{type:"do_while",body:t,condition:n}}parseFor(){if(this.expect(r.FOR),this.expect(r.LPAREN),this.check(r.IDENT)){let a=this.advance();if(this.check(r.IN)){this.advance();let o=this.expect(r.IDENT).value;this.expect(r.RPAREN),this.skipNewlines();let l=this.parseStatement();return{type:"for_in",variable:a.value,array:o,body:l}}this.pos--}let t;this.check(r.SEMICOLON)||(t=this.parseExpression()),this.expect(r.SEMICOLON);let n;this.check(r.SEMICOLON)||(n=this.parseExpression()),this.expect(r.SEMICOLON);let i;this.check(r.RPAREN)||(i=this.parseExpression()),this.expect(r.RPAREN),this.skipNewlines();let s=this.parseStatement();return{type:"for",init:t,condition:n,update:i,body:s}}parseExpression(){return this.parseAssignment()}parseAssignment(){let t=this.parseTernary();if(this.match(r.ASSIGN,r.PLUS_ASSIGN,r.MINUS_ASSIGN,r.STAR_ASSIGN,r.SLASH_ASSIGN,r.PERCENT_ASSIGN,r.CARET_ASSIGN)){let n=this.advance(),i=this.parseAssignment();if(t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[n.value],target:t,value:i}}return t}parseTernary(){let t=this.parsePipeGetline();if(this.check(r.QUESTION)){this.advance();let n=this.parseExpression();this.expect(r.COLON);let i=this.parseExpression();t={type:"ternary",condition:t,consequent:n,alternate:i}}return t}parsePipeGetline(){let t=this.parseOr();if(this.check(r.PIPE)){if(this.advance(),!this.check(r.GETLINE))throw new Error("Expected 'getline' after '|' in expression context");this.advance();let n;return this.check(r.IDENT)&&(n=this.advance().value),{type:"getline",command:t,variable:n}}return t}parseOr(){let t=this.parseAnd();for(;this.check(r.OR);){this.advance();let n=this.parseAnd();t={type:"binary",operator:"||",left:t,right:n}}return t}parseLogicalOrRest(t){for(t=this.parseLogicalAndRest(t);this.check(r.OR);){this.advance();let n=this.parseAnd();t={type:"binary",operator:"||",left:t,right:n}}return t}parseLogicalAndRest(t){for(;this.check(r.AND);){this.advance();let n=this.parseIn();t={type:"binary",operator:"&&",left:t,right:n}}return t}parseAnd(){let t=this.parseIn();for(;this.check(r.AND);){this.advance();let n=this.parseIn();t={type:"binary",operator:"&&",left:t,right:n}}return t}parseIn(){let t=this.parseConcatenation();if(this.check(r.IN)){this.advance();let n=this.expect(r.IDENT).value;return{type:"in",key:t,array:n}}return t}parseConcatenation(){let t=this.parseMatch();for(;this.canStartExpression()&&!this.isConcatTerminator();){let n=this.parseMatch();t={type:"binary",operator:" ",left:t,right:n}}return t}parseMatch(){let t=this.parseComparison();for(;this.match(r.MATCH,r.NOT_MATCH);){let n=this.advance().type===r.MATCH?"~":"!~",i=this.parseComparison();t={type:"binary",operator:n,left:t,right:i}}return t}parseComparison(){let t=this.parseAddSub();for(;this.match(r.LT,r.LE,r.GT,r.GE,r.EQ,r.NE);){let n=this.advance(),i=this.parseAddSub();t={type:"binary",operator:new Map([["<","<"],["<=","<="],[">",">"],[">=",">="],["==","=="],["!=","!="]]).get(n.value)??"==",left:t,right:i}}return t}canStartExpression(){return this.match(r.NUMBER,r.STRING,r.IDENT,r.DOLLAR,r.LPAREN,r.NOT,r.MINUS,r.PLUS,r.INCREMENT,r.DECREMENT)}isConcatTerminator(){return this.match(r.AND,r.OR,r.QUESTION,r.ASSIGN,r.PLUS_ASSIGN,r.MINUS_ASSIGN,r.STAR_ASSIGN,r.SLASH_ASSIGN,r.PERCENT_ASSIGN,r.CARET_ASSIGN,r.COMMA,r.SEMICOLON,r.NEWLINE,r.RBRACE,r.RPAREN,r.RBRACKET,r.COLON,r.PIPE,r.APPEND,r.IN)}parseAddSub(){let t=this.parseMulDiv();for(;this.match(r.PLUS,r.MINUS);){let n=this.advance().value,i=this.parseMulDiv();t={type:"binary",operator:n,left:t,right:i}}return t}parseMulDiv(){let t=this.parseUnary();for(;this.match(r.STAR,r.SLASH,r.PERCENT);){let n=this.advance(),i=this.parseUnary();t={type:"binary",operator:new Map([["*","*"],["/","/"],["%","%"]]).get(n.value)??"*",left:t,right:i}}return t}parseUnary(){if(this.check(r.INCREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:t}}:{type:"pre_increment",operand:t}}if(this.check(r.DECREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:t}}:{type:"pre_decrement",operand:t}}if(this.match(r.NOT,r.MINUS,r.PLUS)){let t=this.advance().value,n=this.parseUnary();return{type:"unary",operator:t,operand:n}}return this.parsePower()}parsePower(){let t=this.parsePostfix();if(this.check(r.CARET)){this.advance();let n=this.parsePower();t={type:"binary",operator:"^",left:t,right:n}}return t}parsePostfix(){let t=this.parsePrimary();if(this.check(r.INCREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid increment operand");return{type:"post_increment",operand:t}}if(this.check(r.DECREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid decrement operand");return{type:"post_decrement",operand:t}}return t}parseFieldIndex(){if(this.check(r.INCREMENT)){this.advance();let t=this.parseFieldIndex();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:t}}:{type:"pre_increment",operand:t}}if(this.check(r.DECREMENT)){this.advance();let t=this.parseFieldIndex();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:t}}:{type:"pre_decrement",operand:t}}if(this.match(r.NOT,r.MINUS,r.PLUS)){let t=this.advance().value,n=this.parseFieldIndex();return{type:"unary",operator:t,operand:n}}return this.parseFieldIndexPower()}parseFieldIndexPower(){let t=this.parseFieldIndexPrimary();if(this.check(r.CARET)){this.advance();let n=this.parseFieldIndexPower();t={type:"binary",operator:"^",left:t,right:n}}return t}parseFieldIndexPrimary(){if(this.check(r.NUMBER))return{type:"number",value:this.advance().value};if(this.check(r.STRING))return{type:"string",value:this.advance().value};if(this.check(r.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(r.LPAREN)){this.advance();let t=this.parseExpression();return this.expect(r.RPAREN),t}if(this.check(r.IDENT)){let t=this.advance().value;if(this.check(r.LPAREN)){this.advance();let n=[];if(!this.check(r.RPAREN))for(n.push(this.parseExpression());this.check(r.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(r.RPAREN),{type:"call",name:t,args:n}}if(this.check(r.LBRACKET)){this.advance();let n=this.parseExpression();if(this.check(r.COMMA)){let i=[n];for(;this.check(r.COMMA);)this.advance(),i.push(this.parseExpression());this.expect(r.RBRACKET);let s=i.reduce((a,o)=>({type:"binary",operator:" ",left:{type:"binary",operator:" ",left:a,right:{type:"variable",name:"SUBSEP"}},right:o}));return{type:"array_access",array:t,key:s}}return this.expect(r.RBRACKET),{type:"array_access",array:t,key:n}}return{type:"variable",name:t}}throw new Error(`Unexpected token in field index: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}parsePrimary(){if(this.check(r.NUMBER))return{type:"number",value:this.advance().value};if(this.check(r.STRING))return{type:"string",value:this.advance().value};if(this.check(r.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(r.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(r.LPAREN)){this.advance();let t=this.parseExpression();if(this.check(r.COMMA)){let n=[t];for(;this.check(r.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(r.RPAREN),{type:"tuple",elements:n}}return this.expect(r.RPAREN),t}if(this.check(r.GETLINE)){this.advance();let t,n;return this.check(r.IDENT)&&(t=this.advance().value),this.check(r.LT)&&(this.advance(),n=this.parsePrimary()),{type:"getline",variable:t,file:n}}if(this.check(r.IDENT)){let t=this.advance().value;if(this.check(r.LPAREN)){this.advance();let n=[];if(this.skipNewlines(),!this.check(r.RPAREN))for(n.push(this.parseExpression());this.check(r.COMMA);)this.advance(),this.skipNewlines(),n.push(this.parseExpression());return this.skipNewlines(),this.expect(r.RPAREN),{type:"call",name:t,args:n}}if(this.check(r.LBRACKET)){this.advance();let n=[this.parseExpression()];for(;this.check(r.COMMA);)this.advance(),n.push(this.parseExpression());this.expect(r.RBRACKET);let i;if(n.length===1)i=n[0];else{i=n[0];for(let s=1;s<n.length;s++)i={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:i,right:{type:"variable",name:"SUBSEP"}},right:n[s]}}return{type:"array_access",array:t,key:i}}return{type:"variable",name:t}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}};var Wt={name:"awk",summary:"pattern scanning and text processing language",usage:"awk [OPTIONS] 'PROGRAM' [FILE...]",options:["-F FS use FS as field separator","-v VAR=VAL assign VAL to variable VAR"," --help display this help and exit"]},Wn={name:"awk",async execute(e,t){D(t.requireDefenseContext,"awk","execution entry");let n=(h,c)=>_(t.requireDefenseContext,"awk",h,c);if(fe(e))return pe(Wt);let i=new H(/\s+/),s=" ",a=Object.create(null),o=0;for(let h=0;h<e.length;h++){let c=e[h];if(c==="-F"&&h+1<e.length)s=he(e[++h]),i=_e(s),o=h+1;else if(c.startsWith("-F"))s=he(c.slice(2)),i=_e(s),o=h+1;else if(c==="-v"&&h+1<e.length){let E=e[++h],F=E.indexOf("=");if(F>0){let G=E.slice(0,F),xe=he(E.slice(F+1));a[G]=xe}o=h+1}else{if(c.startsWith("--"))return re("awk",c);if(c.startsWith("-")&&c.length>1){let E=c[1];if(E!=="F"&&E!=="v")return re("awk",`-${E}`);o=h+1}else if(!c.startsWith("-")){o=h;break}}}if(o>=e.length)return{stdout:"",stderr:`awk: missing program
14
+ `,exitCode:1};let l=e[o],u=e.slice(o+1),N=new ne,v;try{v=N.parse(l)}catch(h){return{stdout:"",stderr:`awk: ${h instanceof Error?h.message:String(h)}
15
+ `,exitCode:1}}let C={readFile:t.fs.readFile.bind(t.fs),writeFile:t.fs.writeFile.bind(t.fs),appendFile:async(h,c)=>{try{let E=await n("appendFile read",()=>t.fs.readFile(h));await n("appendFile write",()=>t.fs.writeFile(h,E+c))}catch(E){if(E instanceof x)throw E;await n("appendFile create",()=>t.fs.writeFile(h,c))}},resolvePath:t.fs.resolvePath.bind(t.fs)},O=t.exec,I=ie({fieldSep:i,maxIterations:t.limits?.maxAwkIterations,maxOutputSize:t.limits?.maxStringLength,fs:C,cwd:t.cwd,exec:O?h=>n("command pipe exec",()=>O(h,{cwd:t.cwd,signal:t.signal})):void 0,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext});I.FS=s,I.vars=Object.assign(Object.create(null),a),I.ARGC=u.length+1,I.ARGV=Object.create(null),I.ARGV[0]="awk";for(let h=0;h<u.length;h++)I.ARGV[String(h+1)]=u[h];I.ENVIRON=de(t.env);let w=new q(I);w.execute(v);let d=v.rules.some(h=>h.pattern?.type!=="begin"&&h.pattern?.type!=="end"),R=v.rules.some(h=>h.pattern?.type==="end");try{if(await n("BEGIN execution",()=>w.executeBegin()),I.shouldExit)return await n("END execution after BEGIN exit",()=>w.executeEnd()),{stdout:w.getOutput(),stderr:"",exitCode:w.getExitCode()};if(!d&&!R)return{stdout:w.getOutput(),stderr:"",exitCode:w.getExitCode()};let h=[];if(u.length>0)for(let c of u)try{let E=t.fs.resolvePath(t.cwd,c),G=(await n("input file read",()=>t.fs.readFile(E))).split(`
16
+ `);G.length>0&&G[G.length-1]===""&&G.pop(),h.push({filename:c,lines:G})}catch(E){if(E instanceof x)throw E;return{stdout:"",stderr:`awk: ${c}: No such file or directory
17
+ `,exitCode:1}}else{let c=t.stdin.split(`
18
+ `);c.length>0&&c[c.length-1]===""&&c.pop(),h.push({filename:"",lines:c})}for(let c of h){for(I.FILENAME=c.filename,I.FNR=0,I.lines=c.lines,I.lineIndex=-1,I.shouldNextFile=!1;I.lineIndex<c.lines.length-1;){I.lineIndex++;let E=I.lineIndex;if(await n("line execution",()=>w.executeLine(c.lines[E])),I.shouldExit||I.shouldNextFile)break}if(I.shouldExit)break}return await n("END execution",()=>w.executeEnd()),{stdout:w.getOutput(),stderr:"",exitCode:w.getExitCode()}}catch(h){if(h instanceof x)throw h;let c=h instanceof Error?h.message:String(h),E=h instanceof P?P.EXIT_CODE:2;return{stdout:w.getOutput(),stderr:`awk: ${c}
19
+ `,exitCode:E}}}};function he(e){return e.replace(/\\t/g," ").replace(/\\n/g,`
20
+ `).replace(/\\r/g,"\r").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\a/g,"\x07").replace(/\\v/g,"\v").replace(/\\\\/g,"\\")}function _e(e){if(e===" ")return A("\\s+");if(/[[\](){}.*+?^$|\\]/.test(e))try{return A(e)}catch{return A(Ge(e))}return A(Ge(e))}function Ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Vn={name:"awk",flags:[{flag:"-F",type:"value",valueHint:"delimiter"},{flag:"-v",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0};export{Wn as a,Vn as b};
@@ -0,0 +1,4 @@
1
+ import{a as h}from"./chunk-DXB73IDG.js";function v(){let a=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables",allowedKeys:new Set(["NODE_V8_COVERAGE","NODE_DEBUG","NODE_DEBUG_NATIVE","NODE_COMPILE_CACHE","WATCH_REPORT_DEPENDENCIES","FORCE_COLOR","DEBUG","UNDICI_NO_FG","JEST_WORKER_ID","__MINIMATCH_TESTING_PLATFORM__","LOG_TOKENS","LOG_STREAM"])},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"getBuiltinModule",target:process,violationType:"process_get_builtin_module",strategy:"throw",reason:"process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)"},{prop:"exit",target:process,violationType:"process_exit",strategy:"throw",reason:"process.exit could terminate the interpreter"},{prop:"abort",target:process,violationType:"process_exit",strategy:"throw",reason:"process.abort could crash the interpreter"},{prop:"kill",target:process,violationType:"process_kill",strategy:"throw",reason:"process.kill could signal other processes"},{prop:"setuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setuid could escalate privileges"},{prop:"setgid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgid could escalate privileges"},{prop:"umask",target:process,violationType:"process_umask",strategy:"throw",reason:"process.umask could modify file creation permissions"},{prop:"argv",target:process,violationType:"process_argv",strategy:"throw",reason:"process.argv may contain secrets in CLI arguments"},{prop:"chdir",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.chdir could confuse the interpreter's CWD tracking"},{prop:"send",target:process,violationType:"process_send",strategy:"throw",reason:"process.send could communicate with parent process in IPC contexts"},{prop:"channel",target:process,violationType:"process_channel",strategy:"throw",reason:"process.channel could access IPC channel to parent process"},{prop:"cpuUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.cpuUsage could enable timing side-channel attacks"},{prop:"memoryUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.memoryUsage could enable timing side-channel attacks"},{prop:"hrtime",target:process,violationType:"process_timing",strategy:"throw",reason:"process.hrtime could enable timing side-channel attacks"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"},{prop:"performance",target:globalThis,violationType:"performance_timing",strategy:"throw",reason:"performance.now() provides sub-millisecond timing for side-channel attacks"},{prop:"stdout",target:process,violationType:"process_stdout",strategy:"throw",reason:"process.stdout could bypass interpreter output to write to host stdout"},{prop:"stderr",target:process,violationType:"process_stderr",strategy:"throw",reason:"process.stderr could bypass interpreter output to write to host stderr"},{prop:"__defineGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineGetter__ allows prototype pollution via getter injection"},{prop:"__defineSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineSetter__ allows prototype pollution via setter injection"},{prop:"__lookupGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupGetter__ enables introspection for prototype pollution attacks"},{prop:"__lookupSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupSetter__ enables introspection for prototype pollution attacks"},{prop:"JSON",target:globalThis,violationType:"json_mutation",strategy:"freeze",reason:"Freeze JSON to prevent mutation of parsing/serialization"},{prop:"Math",target:globalThis,violationType:"math_mutation",strategy:"freeze",reason:"Freeze Math to prevent mutation of math utilities"}];try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&a.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&a.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let e=Object.getPrototypeOf(async function*(){}).constructor;e&&e!==Function&&e!==Object.getPrototypeOf(async()=>{}).constructor&&a.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return a.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}})}var g=typeof __BROWSER__<"u"&&__BROWSER__;function _(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{let e=Math.random()*16|0;return(a==="x"?e:e&3|8).toString(16)})}var x=null;if(!g)try{let{AsyncLocalStorage:a}=h("node:async_hooks");x=a}catch{}var T=`
2
+
3
+ This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,p=class extends Error{violation;constructor(e,t){super(e+T),this.violation=t,this.name="SecurityViolationError"}},u=!g&&x?new x:null,k=1e3;function D(a,e,...t){return u.run(a,()=>e(...t))}var m={enabled:!0,auditMode:!1};function O(a){return a===void 0?{...m,enabled:!1}:typeof a=="boolean"?{...m,enabled:a}:{...m,...a}}var w=class a{static instance=null;static importHooksRegistered=!1;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(e){let t=O(e);if(!a.instance)a.instance=new a(t);else{let o=a.instance.config;if(t.enabled!==o.enabled||t.auditMode!==o.auditMode)throw new Error(`DefenseInDepthBox config conflict: requested {enabled: ${t.enabled}, auditMode: ${t.auditMode}} but singleton already has {enabled: ${o.enabled}, auditMode: ${o.auditMode}}. All Bash instances must use the same defense-in-depth security settings, or call DefenseInDepthBox.resetInstance() between incompatible configurations.`)}return a.instance}static resetInstance(){a.instance&&(a.instance.forceDeactivate(),a.instance=null)}static isInSandboxedContext(){return u?u?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(u)return u?.getStore()?.executionId}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let t=this.contextCache.get(e);return t||(t={sandboxActive:!0,executionId:e},this.contextCache.set(e,t)),t}getPreferredActiveExecutionId(){if(this.activeExecutionIds.size!==0)for(let e of this.activeExecutionIds)return e}static bindCurrentContext(e){if(!u)return e;let t=u.getStore(),o=t?.sandboxActive===!0?t.executionId:a.instance?.getPreferredActiveExecutionId();if(!o)return e;let s=a.instance?.getCachedContext(o)??{sandboxActive:!0,executionId:o};return D.bind(null,s,e)}isEnabled(){return this.config.enabled===!0&&u!==null&&!g}updateConfig(e){this.config={...this.config,...e}}activate(){if(g||!this.config.enabled||!u){let o=_(),s=!1;return{run:r=>s?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):r(),deactivate:()=>{s=!0},executionId:o}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let e=_(),t=!1;return{run:o=>t?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):(this.activeExecutionIds.add(e),u.run({sandboxActive:!0,executionId:e},o)),deactivate:()=>{t||(t=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`<object>.${t}`}static runTrusted(e){if(!u)return e();let t=u.getStore();return t?u.run({...t,trusted:!0},e):e()}static async runTrustedAsync(e){if(!u)return e();let t=u.getStore();return t?u.run({...t,trusted:!0},e):e()}shouldBlock(){if(g||this.config.auditMode||!u)return!1;let e=u?.getStore();return!(e?.sandboxActive!==!0||e.trusted)}recordViolation(e,t,o){let s={timestamp:Date.now(),type:e,message:o,path:t,stack:new Error().stack,executionId:u?.getStore()?.executionId};if(this.violations.length<k&&this.violations.push(s),this.config.onViolation)try{this.config.onViolation(s)}catch(r){console.debug("[DefenseInDepthBox] onViolation callback threw:",r instanceof Error?r.message:r)}return s}createBlockingProxy(e,t,o){let s=this;return new Proxy(e,{apply(r,n,i){if(s.shouldBlock()){let c=`${t} is blocked during script execution`,l=s.recordViolation(o,t,c);throw new p(c,l)}return s.config.auditMode&&u?.getStore()?.sandboxActive===!0&&s.recordViolation(o,t,`${t} called (audit mode)`),Reflect.apply(r,n,i)},construct(r,n,i){if(s.shouldBlock()){let c=`${t} constructor is blocked during script execution`,l=s.recordViolation(o,t,c);throw new p(c,l)}return s.config.auditMode&&u?.getStore()?.sandboxActive===!0&&s.recordViolation(o,t,`${t} constructor called (audit mode)`),Reflect.construct(r,n,i)}})}createBlockingObjectProxy(e,t,o,s){let r=this;return new Proxy(e,{get(n,i,c){if(r.shouldBlock()){if(s&&typeof i=="string"&&s.has(i))return Reflect.get(n,i,c);let l=`${t}.${String(i)}`,d=`${l} is blocked during script execution`,f=r.recordViolation(o,l,d);throw new p(d,f)}if(r.config.auditMode&&u?.getStore()?.sandboxActive===!0){let l=`${t}.${String(i)}`;r.recordViolation(o,l,`${l} accessed (audit mode)`)}return Reflect.get(n,i,c)},set(n,i,c,l){if(r.shouldBlock()){let d=`${t}.${String(i)}`,f=`${d} modification is blocked during script execution`,y=r.recordViolation(o,d,f);throw new p(f,y)}return Reflect.set(n,i,c,l)},ownKeys(n){if(r.shouldBlock()){let i=`${t} enumeration is blocked during script execution`,c=r.recordViolation(o,t,i);throw new p(i,c)}return Reflect.ownKeys(n)},getOwnPropertyDescriptor(n,i){if(r.shouldBlock()){let c=`${t}.${String(i)}`,l=`${c} descriptor access is blocked during script execution`,d=r.recordViolation(o,c,l);throw new p(l,d)}return Reflect.getOwnPropertyDescriptor(n,i)},has(n,i){if(r.shouldBlock()){let c=`${t}.${String(i)}`,l=`${c} existence check is blocked during script execution`,d=r.recordViolation(o,c,l);throw new p(l,d)}return Reflect.has(n,i)}})}applyPatches(){this.patchFailures=[];let e=v(),t=new Set(["process_send","process_channel","process_stdout","process_stderr"]);for(let r of e)t.has(r.violationType)||this.applyPatch(r);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath();let o=["Function.prototype.constructor","Module._load"],s=this.patchFailures.filter(r=>o.includes(r));if(s.length>0)throw this.restorePatches(),new Error(`DefenseInDepthBox: critical patches failed: ${s.join(", ")}`)}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(e){this.patchFailures.push("AsyncFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(e){this.patchFailures.push("GeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(e){this.patchFailures.push("AsyncGeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:t});let o=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return o},set(s){if(e.shouldBlock()){let r="Error.prepareStackTrace modification is blocked during script execution",n=e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",r);throw new p(r,n)}e.config.auditMode&&u?.getStore()?.sandboxActive===!0&&e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),o=s},configurable:!0})}catch(t){this.patchFailures.push("Error.prepareStackTrace"),console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",t instanceof Error?t.message:t)}}protectPromiseThen(){let e=this;try{let r=function(...n){return u.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation("promise_then_after_deactivate","Promise.then","Promise.then callback is blocked after defense deactivation"),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,n);if(this.kind==="fulfilled")return n[0];throw n[0]}return Reflect.apply(this.cb,void 0,n)})};var t=r;let o=Object.getOwnPropertyDescriptor(Promise.prototype,"then");this.originalDescriptors.push({target:Promise.prototype,prop:"then",descriptor:o});let s=o?.value;if(typeof s!="function")return;Object.defineProperty(Promise.prototype,"then",{value:function(i,c){if(!u)return Reflect.apply(s,this,[i,c]);let l=u.getStore(),d=l?.sandboxActive===!0&&l.trusted!==!0?l.executionId:void 0;if(!d)return Reflect.apply(s,this,[i,c]);let f=e.getCachedContext(d),y=(b,P)=>typeof b!="function"?b:r.bind({box:e,executionId:d,captured:f,cb:b,kind:P});return Reflect.apply(s,this,[y(i,"fulfilled"),y(c,"rejected")])},writable:!0,configurable:!0})}catch(o){this.patchFailures.push("Promise.prototype.then"),console.debug("[DefenseInDepthBox] Could not protect Promise.prototype.then:",o instanceof Error?o.message:o)}}patchPrototypeConstructor(e,t,o){let s=this;try{let r=Object.getOwnPropertyDescriptor(e,"constructor");this.originalDescriptors.push({target:e,prop:"constructor",descriptor:r});let n=r?.value;Object.defineProperty(e,"constructor",{get(){if(s.shouldBlock()){let i=`${t} access is blocked during script execution`,c=s.recordViolation(o,t,i);throw new p(i,c)}return s.config.auditMode&&u?.getStore()?.sandboxActive===!0&&s.recordViolation(o,t,`${t} accessed (audit mode)`),n},set(i){if(s.shouldBlock()){let c=`${t} modification is blocked during script execution`,l=s.recordViolation(o,t,c);throw new p(c,l)}Object.defineProperty(this,"constructor",{value:i,writable:!0,configurable:!0})},configurable:!0})}catch(r){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,r instanceof Error?r.message:r)}}protectProcessMainModule(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:t});let o=t?.value;o!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let s="process.mainModule access is blocked during script execution",r=e.recordViolation("process_main_module","process.mainModule",s);throw new p(s,r)}return e.config.auditMode&&u?.getStore()?.sandboxActive===!0&&e.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),o},set(s){if(e.shouldBlock()){let r="process.mainModule modification is blocked during script execution",n=e.recordViolation("process_main_module","process.mainModule",r);throw new p(r,n)}Object.defineProperty(process,"mainModule",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.mainModule"),console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",t instanceof Error?t.message:t)}}protectProcessExecPath(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"execPath");this.originalDescriptors.push({target:process,prop:"execPath",descriptor:t});let o=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let s="process.execPath access is blocked during script execution",r=e.recordViolation("process_exec_path","process.execPath",s);throw new p(s,r)}return e.config.auditMode&&u?.getStore()?.sandboxActive===!0&&e.recordViolation("process_exec_path","process.execPath","process.execPath accessed (audit mode)"),o},set(s){if(e.shouldBlock()){let r="process.execPath modification is blocked during script execution",n=e.recordViolation("process_exec_path","process.execPath",r);throw new p(r,n)}Object.defineProperty(process,"execPath",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.execPath"),console.debug("[DefenseInDepthBox] Could not protect process.execPath:",t instanceof Error?t.message:t)}}protectDynamicImport(){if(!(g||a.importHooksRegistered))try{let e=h("node:module");if(typeof e.registerHooks=="function"){e.registerHooks({resolve(t,o,s){if(t.startsWith("data:")||t.startsWith("blob:"))throw new Error(`dynamic import of ${t.startsWith("data:")?"data:":"blob:"} URLs is blocked by defense-in-depth`);return s(t,o)}}),a.importHooksRegistered=!0;return}if(typeof e.register=="function"){let t=["export async function resolve(specifier, context, nextResolve) {",' if (specifier.startsWith("data:") || specifier.startsWith("blob:")) {',' throw new Error("dynamic import of " + (specifier.startsWith("data:") ? "data:" : "blob:") + " URLs is blocked by defense-in-depth");'," }"," return nextResolve(specifier, context);","}"].join(`
4
+ `);e.register(`data:text/javascript,${encodeURIComponent(t)}`),a.importHooksRegistered=!0}}catch(e){console.debug("[DefenseInDepthBox] Could not register import() hooks:",e instanceof Error?e.message:e)}}protectModuleLoad(){if(!g)try{let e=null;if(typeof process<"u"){let n=process.mainModule;n&&typeof n=="object"&&(e=n.constructor)}if(!e&&typeof h<"u"&&typeof h.main<"u"&&(e=h.main.constructor),!e||typeof e._load!="function")return;let t=e._load,o=Object.getOwnPropertyDescriptor(e,"_load");this.originalDescriptors.push({target:e,prop:"_load",descriptor:o});let r=this.createBlockingProxy(t,"Module._load","module_load");Object.defineProperty(e,"_load",{value:r,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._load"),console.debug("[DefenseInDepthBox] Could not protect Module._load:",e instanceof Error?e.message:e)}}protectModuleResolveFilename(){if(!g)try{let e=null;if(typeof process<"u"){let n=process.mainModule;n&&typeof n=="object"&&(e=n.constructor)}if(!e&&typeof h<"u"&&typeof h.main<"u"&&(e=h.main.constructor),!e||typeof e._resolveFilename!="function")return;let t=e._resolveFilename,o=Object.getOwnPropertyDescriptor(e,"_resolveFilename");this.originalDescriptors.push({target:e,prop:"_resolveFilename",descriptor:o});let r=this.createBlockingProxy(t,"Module._resolveFilename","module_resolve_filename");Object.defineProperty(e,"_resolveFilename",{value:r,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._resolveFilename"),console.debug("[DefenseInDepthBox] Could not protect Module._resolveFilename:",e instanceof Error?e.message:e)}}applyPatch(e){let{target:t,prop:o,violationType:s,strategy:r}=e;try{let n=t[o];if(n===void 0)return;let i=Object.getOwnPropertyDescriptor(t,o);if(this.originalDescriptors.push({target:t,prop:o,descriptor:i}),r==="freeze")typeof n=="object"&&n!==null&&Object.freeze(n);else{let c=this.getPathForTarget(t,o),l=typeof n=="function"?this.createBlockingProxy(n,c,s):this.createBlockingObjectProxy(n,c,s,e.allowedKeys);Object.defineProperty(t,o,{value:l,writable:!0,configurable:!0})}}catch(n){let i=this.getPathForTarget(t,o);this.patchFailures.push(i),console.debug(`[DefenseInDepthBox] Could not patch ${i}:`,n instanceof Error?n.message:n)}}restorePatches(){for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:t,prop:o,descriptor:s}=this.originalDescriptors[e];try{s?Object.defineProperty(t,o,s):delete t[o]}catch(r){let n=this.getPathForTarget(t,o);console.debug(`[DefenseInDepthBox] Could not restore ${n}:`,r instanceof Error?r.message:r)}}this.originalDescriptors=[]}};export{p as a,w as b};
@@ -0,0 +1 @@
1
+ function t(r){if(!r)return r;let e=r.replace(/\n\s+at\s.*/g,"");return e=e.replace(/(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap))\b[^\s'",)}\]:]*/g,"<path>"),e=e.replace(/node:internal\/[^\s'",)}\]:]+/g,"<internal>"),e=e.replace(/[A-Z]:\\[^\s'",)}\]:]+/g,"<path>"),e}export{t as a};
@@ -0,0 +1,5 @@
1
+ import{a as b,b as g,c as C,d as k,e as X}from"./chunk-7MKBHGLS.js";import{a as G,c as yt}from"./chunk-OJDRYQWQ.js";import{a as ht}from"./chunk-T2EHE3CV.js";import{a as T}from"./chunk-YNYSPYQ5.js";import{k as P}from"./chunk-GFQRA5P5.js";function W(t,r,e,n,p,i,u,c,s,f){switch(r){case"sort":return Array.isArray(t)?[[...t].sort(u)]:[null];case"sort_by":return!Array.isArray(t)||e.length===0?[null]:[[...t].sort((h,y)=>{let a=p(h,e[0],n)[0],l=p(y,e[0],n)[0];return u(a,l)})];case"bsearch":{if(!Array.isArray(t)){let h=t===null?"null":typeof t=="object"?"object":typeof t;throw new Error(`${h} (${JSON.stringify(t)}) cannot be searched from`)}return e.length===0?[null]:p(t,e[0],n).map(h=>{let y=0,a=t.length;for(;y<a;){let l=y+a>>>1;u(t[l],h)<0?y=l+1:a=l}return y<t.length&&u(t[y],h)===0?y:-y-1})}case"unique_by":{if(!Array.isArray(t)||e.length===0)return[null];let o=new Map;for(let y of t){let a=p(y,e[0],n)[0],l=JSON.stringify(a);o.has(l)||o.set(l,{item:y,key:a})}let h=[...o.values()];return h.sort((y,a)=>u(y.key,a.key)),[h.map(y=>y.item)]}case"group_by":{if(!Array.isArray(t)||e.length===0)return[null];let o=new Map;for(let h of t){let y=JSON.stringify(p(h,e[0],n)[0]);o.has(y)||o.set(y,[]),o.get(y)?.push(h)}return[[...o.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((o,h)=>u(o,h)>0?o:h)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((o,h)=>{let y=p(o,e[0],n)[0],a=p(h,e[0],n)[0];return u(y,a)>0?o:h})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((o,h)=>u(o,h)<0?o:h)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((o,h)=>{let y=p(o,e[0],n)[0],a=p(h,e[0],n)[0];return u(y,a)<0?o:h})];case"add":{let o=h=>{let y=h.filter(a=>a!==null);return y.length===0?null:y.every(a=>typeof a=="number")?y.reduce((a,l)=>a+l,0):y.every(a=>typeof a=="string")?y.join(""):y.every(a=>Array.isArray(a))?y.flat():y.every(a=>a&&typeof a=="object"&&!Array.isArray(a))?yt(...y):null};if(e.length>=1){let h=p(t,e[0],n);return[o(h)]}return Array.isArray(t)?[o(t)]:[null]}case"any":{if(e.length>=2){try{let o=i(t,e[0],n);for(let h of o)if(p(h,e[1],n).some(c))return[!0]}catch(o){if(o instanceof f)throw o}return[!1]}return e.length===1?Array.isArray(t)?[t.some(o=>c(p(o,e[0],n)[0]))]:[!1]:Array.isArray(t)?[t.some(c)]:[!1]}case"all":{if(e.length>=2){try{let o=i(t,e[0],n);for(let h of o)if(!p(h,e[1],n).some(c))return[!1]}catch(o){if(o instanceof f)throw o}return[!0]}return e.length===1?Array.isArray(t)?[t.every(o=>c(p(o,e[0],n)[0]))]:[!0]:Array.isArray(t)?[t.every(c)]:[!0]}case"select":return e.length===0?[t]:p(t,e[0],n).some(c)?[t]:[];case"map":return e.length===0||!Array.isArray(t)?[null]:[t.flatMap(h=>p(h,e[0],n))];case"map_values":{if(e.length===0)return[null];if(Array.isArray(t))return[t.flatMap(o=>p(o,e[0],n))];if(t&&typeof t=="object"){let o=Object.create(null);for(let[h,y]of Object.entries(t)){if(!b(h))continue;let a=p(y,e[0],n);a.length>0&&g(o,h,a[0])}return[o]}return[null]}case"has":{if(e.length===0)return[!1];let h=p(t,e[0],n)[0];return Array.isArray(t)&&typeof h=="number"?[h>=0&&h<t.length]:t&&typeof t=="object"&&typeof h=="string"?[C(t,h)]:[!1]}case"in":{if(e.length===0)return[!1];let h=p(t,e[0],n)[0];return Array.isArray(h)&&typeof t=="number"?[t>=0&&t<h.length]:h&&typeof h=="object"&&typeof t=="string"?[C(h,t)]:[!1]}case"contains":{if(e.length===0)return[!1];let o=p(t,e[0],n);return[s(t,o[0])]}case"inside":{if(e.length===0)return[!1];let o=p(t,e[0],n);return[s(o[0],t)]}default:return null}}function Q(t,r,e,n,p,i,u,c){switch(r){case"first":if(e.length>0)try{let s=i(t,e[0],n);return s.length>0?[s[0]]:[]}catch(s){if(s instanceof c)throw s;return[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(e.length>0){let s=p(t,e[0],n);return s.length>0?[s[s.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(e.length<1)return[null];let s=p(t,e[0],n);if(e.length>1){for(let o of s)if(o<0)throw new Error("nth doesn't support negative indices");let f;try{f=i(t,e[1],n)}catch(o){if(o instanceof c)throw o;f=[]}return s.flatMap(o=>{let h=o;return h<f.length?[f[h]]:[]})}return Array.isArray(t)?s.flatMap(f=>{let o=f;if(o<0)throw new Error("nth doesn't support negative indices");return o<t.length?[t[o]]:[null]}):[null]}case"range":{if(e.length===0)return[];let s=Math.max(n.limits.maxIterations*100,1e6),f=l=>l.length>=s,o=p(t,e[0],n);if(e.length===1){let l=[];for(let m of o){let A=m;for(let E=0;E<A;E++)if(l.push(E),f(l))return l}return l}let h=p(t,e[1],n);if(e.length===2){let l=[];for(let m of o)for(let A of h){let E=m,w=A;for(let O=E;O<w;O++)if(l.push(O),f(l))return l}return l}let y=p(t,e[2],n),a=[];for(let l of o)for(let m of h)for(let A of y){let E=l,w=m,O=A;if(O!==0){if(O>0){for(let S=E;S<w;S+=O)if(a.push(S),f(a))return a}else for(let S=E;S>w;S+=O)if(a.push(S),f(a))return a}}return a}case"limit":return e.length<2?[]:p(t,e[0],n).flatMap(f=>{let o=f;if(o<0)throw new Error("limit doesn't support negative count");if(o===0)return[];let h;try{h=i(t,e[1],n)}catch(y){if(y instanceof c)throw y;h=[]}return h.slice(0,o)});case"isempty":{if(e.length<1)return[!0];try{return[i(t,e[0],n).length===0]}catch(s){if(s instanceof c)throw s;return[!0]}}case"isvalid":{if(e.length<1)return[!0];try{return[p(t,e[0],n).length>0]}catch(s){if(s instanceof c)throw s;return[!1]}}case"skip":return e.length<2?[]:p(t,e[0],n).flatMap(f=>{let o=f;if(o<0)throw new Error("skip doesn't support negative count");return p(t,e[1],n).slice(o)});case"until":{if(e.length<2)return[t];let s=t,f=n.limits.maxIterations;for(let o=0;o<f;o++){if(p(s,e[0],n).some(u))return[s];let y=p(s,e[1],n);if(y.length===0)return[s];s=y[0]}throw new c(`jq until: too many iterations (${f}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(e.length<2)return[t];let s=[],f=t,o=n.limits.maxIterations;for(let h=0;h<o&&p(f,e[0],n).some(u);h++){s.push(f);let a=p(f,e[1],n);if(a.length===0)break;f=a[0]}if(s.length>=o)throw new c(`jq while: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"repeat":{if(e.length===0)return[t];let s=[],f=t,o=n.limits.maxIterations;for(let h=0;h<o;h++){s.push(f);let y=p(f,e[0],n);if(y.length===0)break;f=y[0]}if(s.length>=o)throw new c(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}default:return null}}function Z(t,r,e,n,p){switch(r){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof t!="number")return[null];let i=new Date(t*1e3),u=i.getUTCFullYear(),c=i.getUTCMonth(),s=i.getUTCDate(),f=i.getUTCHours(),o=i.getUTCMinutes(),h=i.getUTCSeconds(),y=i.getUTCDay(),a=Date.UTC(u,0,1),l=Math.floor((i.getTime()-a)/(1440*60*1e3));return[[u,c,s,f,o,h,y,l]]}case"mktime":{if(!Array.isArray(t))throw new Error("mktime requires parsed datetime inputs");let[i,u,c,s=0,f=0,o=0]=t;if(typeof i!="number"||typeof u!="number")throw new Error("mktime requires parsed datetime inputs");let h=Date.UTC(i,u,c??1,s??0,f??0,o??0);return[Math.floor(h/1e3)]}case"strftime":{if(e.length===0)return[null];let u=p(t,e[0],n)[0];if(typeof u!="string")throw new Error("strftime/1 requires a string format");let c;if(typeof t=="number")c=new Date(t*1e3);else if(Array.isArray(t)){let[y,a,l,m=0,A=0,E=0]=t;if(typeof y!="number"||typeof a!="number")throw new Error("strftime/1 requires parsed datetime inputs");c=new Date(Date.UTC(y,a,l??1,m??0,A??0,E??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],f=["January","February","March","April","May","June","July","August","September","October","November","December"],o=(y,a=2)=>String(y).padStart(a,"0");return[u.replace(/%Y/g,String(c.getUTCFullYear())).replace(/%m/g,o(c.getUTCMonth()+1)).replace(/%d/g,o(c.getUTCDate())).replace(/%H/g,o(c.getUTCHours())).replace(/%M/g,o(c.getUTCMinutes())).replace(/%S/g,o(c.getUTCSeconds())).replace(/%A/g,s[c.getUTCDay()]).replace(/%B/g,f[c.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(e.length===0)return[null];if(typeof t!="string")throw new Error("strptime/1 requires a string input");let u=p(t,e[0],n)[0];if(typeof u!="string")throw new Error("strptime/1 requires a string format");if(u==="%Y-%m-%dT%H:%M:%SZ"){let s=t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(s){let[,f,o,h,y,a,l]=s.map(Number),m=new Date(Date.UTC(f,o-1,h,y,a,l)),A=m.getUTCDay(),E=Date.UTC(f,0,1),w=Math.floor((m.getTime()-E)/(1440*60*1e3));return[[f,o-1,h,y,a,l,A,w]]}}let c=new Date(t);if(!Number.isNaN(c.getTime())){let s=c.getUTCFullYear(),f=c.getUTCMonth(),o=c.getUTCDate(),h=c.getUTCHours(),y=c.getUTCMinutes(),a=c.getUTCSeconds(),l=c.getUTCDay(),m=Date.UTC(s,0,1),A=Math.floor((c.getTime()-m)/(1440*60*1e3));return[[s,f,o,h,y,a,l,A]]}throw new Error(`Cannot parse date: ${t}`)}case"fromdate":{if(typeof t!="string")throw new Error("fromdate requires a string input");let i=new Date(t);if(Number.isNaN(i.getTime()))throw new Error(`date "${t}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof t!="number")throw new Error("todate requires a number input");return[new Date(t*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}function N(t){return t!==!1&&t!==null}function x(t,r){return JSON.stringify(t)===JSON.stringify(r)}function B(t,r){return typeof t=="number"&&typeof r=="number"?t-r:typeof t=="string"&&typeof r=="string"?t.localeCompare(r):0}function z(t,r){let e=k(t);for(let n of Object.keys(r))b(n)&&(C(e,n)&&e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])&&r[n]&&typeof r[n]=="object"&&!Array.isArray(r[n])?g(e,n,z(e[n],r[n])):g(e,n,r[n]));return e}function I(t,r=3e3){let e=0,n=t;for(;e<r;)if(Array.isArray(n)){if(n.length===0)return e+1;n=n[0],e++}else if(n!==null&&typeof n=="object"){let p=Object.keys(n);if(p.length===0)return e+1;n=n[p[0]],e++}else return e;return e}function _(t,r){let e=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,n=e(t),p=e(r);if(n!==p)return n-p;if(typeof t=="number"&&typeof r=="number")return t-r;if(typeof t=="string"&&typeof r=="string")return t.localeCompare(r);if(typeof t=="boolean"&&typeof r=="boolean")return(t?1:0)-(r?1:0);if(Array.isArray(t)&&Array.isArray(r)){for(let i=0;i<Math.min(t.length,r.length);i++){let u=_(t[i],r[i]);if(u!==0)return u}return t.length-r.length}if(t&&r&&typeof t=="object"&&typeof r=="object"){let i=t,u=r,c=Object.keys(i).sort(),s=Object.keys(u).sort();for(let f=0;f<Math.min(c.length,s.length);f++){let o=c[f].localeCompare(s[f]);if(o!==0)return o}if(c.length!==s.length)return c.length-s.length;for(let f of c){let o=_(i[f],u[f]);if(o!==0)return o}}return 0}function $(t,r){if(x(t,r))return!0;if(typeof t=="string"&&typeof r=="string")return t.includes(r);if(Array.isArray(t)&&Array.isArray(r))return r.every(e=>t.some(n=>$(n,e)));if(t&&r&&typeof t=="object"&&typeof r=="object"&&!Array.isArray(t)&&!Array.isArray(r)){let e=t,n=r;return Object.keys(n).every(p=>C(e,p)&&$(e[p],n[p]))}return!1}var wt=2e3;function v(t,r,e){switch(r){case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof t=="string"?[decodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(p=>{if(p===null)return"";if(typeof p=="boolean")return p?"true":"false";if(typeof p=="number")return String(p);let i=String(p);return i.includes(",")||i.includes('"')||i.includes(`
2
+ `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(n=>String(n??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let n=e??wt;return I(t,n+1)>n?[null]:[JSON.stringify(t)]}case"@html":return typeof t=="string"?[t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];default:return null}}function tt(t,r,e,n,p,i){switch(r){case"index":return e.length===0?[null]:p(t,e[0],n).map(c=>{if(typeof t=="string"&&typeof c=="string"){if(c===""&&t==="")return null;let s=t.indexOf(c);return s>=0?s:null}if(Array.isArray(t)){if(Array.isArray(c)){for(let f=0;f<=t.length-c.length;f++){let o=!0;for(let h=0;h<c.length;h++)if(!i(t[f+h],c[h])){o=!1;break}if(o)return f}return null}let s=t.findIndex(f=>i(f,c));return s>=0?s:null}return null});case"rindex":return e.length===0?[null]:p(t,e[0],n).map(c=>{if(typeof t=="string"&&typeof c=="string"){let s=t.lastIndexOf(c);return s>=0?s:null}if(Array.isArray(t)){if(Array.isArray(c)){for(let s=t.length-c.length;s>=0;s--){let f=!0;for(let o=0;o<c.length;o++)if(!i(t[s+o],c[o])){f=!1;break}if(f)return s}return null}for(let s=t.length-1;s>=0;s--)if(i(t[s],c))return s;return null}return null});case"indices":return e.length===0?[[]]:p(t,e[0],n).map(c=>{let s=[];if(typeof t=="string"&&typeof c=="string"){let f=t.indexOf(c);for(;f!==-1;)s.push(f),f=t.indexOf(c,f+1)}else if(Array.isArray(t))if(Array.isArray(c)){let f=c.length;if(f===0)for(let o=0;o<=t.length;o++)s.push(o);else for(let o=0;o<=t.length-f;o++){let h=!0;for(let y=0;y<f;y++)if(!i(t[o+y],c[y])){h=!1;break}h&&s.push(o)}}else for(let f=0;f<t.length;f++)i(t[f],c)&&s.push(f);return s});default:return null}}function et(t,r,e,n,p){switch(r){case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:typeof t=="string"?[t]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),c=i[0],s=u[0];return typeof c!="number"||typeof s!="number"?[null]:[c**s]}case"atan2":{if(e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),c=i[0],s=u[0];return typeof c!="number"||typeof s!="number"?[null]:[Math.atan2(c,s)]}case"hypot":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.hypot(t,i)]}case"fma":{if(typeof t!="number"||e.length<2)return[null];let i=p(t,e[0],n)[0],u=p(t,e[1],n)[0];return[t*i+u]}case"copysign":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.sign(i)*Math.abs(t)]}case"drem":case"remainder":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[t-Math.round(t/i)*i]}case"fdim":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.max(0,t-i)]}case"fmax":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.max(t,i)]}case"fmin":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.min(t,i)]}case"ldexp":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[t*2**i]}case"scalbn":case"scalbln":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[t*2**i]}case"nearbyint":return typeof t=="number"?[Math.round(t)]:[null];case"logb":return typeof t=="number"?[Math.floor(Math.log2(Math.abs(t)))]:[null];case"significand":if(typeof t=="number"){let i=Math.floor(Math.log2(Math.abs(t)));return[t/2**i]}return[null];case"frexp":if(typeof t=="number"){if(t===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(t)))+1;return[[t/2**i,i]]}return[null];case"modf":if(typeof t=="number"){let i=Math.trunc(t);return[[t-i,i]]}return[null];default:return null}}function rt(t,r,e,n,p,i,u,c){switch(r){case"recurse":{if(e.length===0){let a=[],l=m=>{if(a.push(m),Array.isArray(m))for(let A of m)l(A);else if(m&&typeof m=="object")for(let A of Object.keys(m))l(m[A])};return l(t),a}let s=[],f=e.length>=2?e[1]:null,o=1e4,h=0,y=a=>{if(h++>o||f&&!p(a,f,n).some(i))return;s.push(a);let l=p(a,e[0],n);for(let m of l)m!=null&&y(m)};return y(t),s}case"recurse_down":return c(t,"recurse",e,n);case"walk":{if(e.length===0)return[t];let s=new WeakSet,f=o=>{if(o&&typeof o=="object"){if(s.has(o))return o;s.add(o)}let h;if(Array.isArray(o))h=o.map(f);else if(o&&typeof o=="object"){let a=Object.create(null);for(let[l,m]of Object.entries(o))b(l)&&g(a,l,f(m));h=a}else h=o;return p(h,e[0],n)[0]};return[f(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let s=Math.max(...t.map(o=>Array.isArray(o)?o.length:0)),f=[];for(let o=0;o<s;o++)f.push(t.map(h=>Array.isArray(h)?h[o]:null));return[f]}case"combinations":{if(e.length>0){let h=p(t,e[0],n)[0];if(!Array.isArray(t)||h<0)return[];if(h===0)return[[]];let y=[],a=(l,m)=>{if(m===h){y.push([...l]);return}for(let A of t)l.push(A),a(l,m+1),l.pop()};return a([],0),y}if(!Array.isArray(t))return[];if(t.length===0)return[[]];for(let o of t)if(!Array.isArray(o))return[];let s=[],f=(o,h)=>{if(o===t.length){s.push([...h]);return}let y=t[o];for(let a of y)h.push(a),f(o+1,h),h.pop()};return f(0,[]),s}case"parent":{if(n.root===void 0||n.currentPath===void 0)return[];let s=n.currentPath;if(s.length===0)return[];let f=e.length>0?p(t,e[0],n)[0]:1;if(f>=0){if(f>s.length)return[];let o=s.slice(0,s.length-f);return[u(n.root,o)]}else{let o=-f-1;if(o>=s.length)return[t];let h=s.slice(0,o);return[u(n.root,h)]}}case"parents":{if(n.root===void 0||n.currentPath===void 0)return[[]];let s=n.currentPath,f=[];for(let o=s.length-1;o>=0;o--)f.push(u(n.root,s.slice(0,o)));return[f]}case"root":return n.root!==void 0?[n.root]:[];default:return null}}var kt=2e3;function nt(t,r,e,n,p){switch(r){case"keys":return Array.isArray(t)?[t.map((i,u)=>u)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((i,u)=>u)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:typeof t=="number"?[Math.abs(t)]:[null];case"utf8bytelength":{if(typeof t=="string")return[new TextEncoder().encode(t).length];let i=t===null?"null":Array.isArray(t)?"array":typeof t,u=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${u}) only strings have UTF-8 byte length`)}case"to_entries":return t&&typeof t=="object"&&!Array.isArray(t)?[Object.entries(t).map(([i,u])=>({key:i,value:u}))]:[null];case"from_entries":if(Array.isArray(t)){let i=Object.create(null);for(let u of t)if(u&&typeof u=="object"){let c=u,s=c.key??c.Key??c.name??c.Name??c.k,f=c.value??c.Value??c.v;if(s!==void 0){let o=String(s);b(o)&&g(i,o,f)}}return[i]}return[null];case"with_entries":{if(e.length===0)return[t];if(t&&typeof t=="object"&&!Array.isArray(t)){let u=Object.entries(t).map(([s,f])=>({key:s,value:f})).flatMap(s=>p(s,e[0],n)),c=Object.create(null);for(let s of u)if(s&&typeof s=="object"){let f=s,o=f.key??f.name??f.k,h=f.value??f.v;if(o!==void 0){let y=String(o);b(y)&&g(c,y,h)}}return[c]}return[null]}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(t)?(e.length>0?p(t,e[0],n):[Number.POSITIVE_INFINITY]).map(u=>{let c=u;if(c<0)throw new Error("flatten depth must not be negative");return t.flat(c)}):[null];case"unique":if(Array.isArray(t)){let i=new Set,u=[];for(let c of t){let s=JSON.stringify(c);i.has(s)||(i.add(s),u.push(c))}return[u]}return[null];case"tojson":case"tojsonstream":{let i=n.limits.maxDepth??kt;return I(t,i+1)>i?[null]:[JSON.stringify(t)]}case"fromjson":{if(typeof t=="string"){let i=t.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[JSON.parse(t)]}catch{throw new Error(`Invalid JSON: ${t}`)}}return[t]}case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let i=Number(t);if(Number.isNaN(i))throw new Error(`${JSON.stringify(t)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof t} cannot be parsed as a number`);case"toboolean":{if(typeof t=="boolean")return[t];if(typeof t=="string"){if(t==="true")return[!0];if(t==="false")return[!1];throw new Error(`string (${JSON.stringify(t)}) cannot be parsed as a boolean`)}let i=t===null?"null":Array.isArray(t)?"array":typeof t,u=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${u}) cannot be parsed as a boolean`)}case"tostream":{let i=[],u=(c,s)=>{if(c===null||typeof c!="object")i.push([s,c]);else if(Array.isArray(c))if(c.length===0)i.push([s,[]]);else for(let f=0;f<c.length;f++)u(c[f],[...s,f]);else{let f=Object.keys(c);if(f.length===0)i.push([s,Object.create(null)]);else for(let o of f)u(c[o],[...s,o])}};return u(t,[]),i.push([[]]),i}case"fromstream":{if(e.length===0)return[t];let i=p(t,e[0],n),u=null;for(let c of i){if(!Array.isArray(c)||c.length===1&&Array.isArray(c[0])&&c[0].length===0||c.length!==2)continue;let[s,f]=c;if(!Array.isArray(s))continue;if(s.length===0){u=f;continue}u===null&&(u=typeof s[0]=="number"?[]:{});let o=u;for(let y=0;y<s.length-1;y++){let a=s[y],l=s[y+1];if(Array.isArray(o)&&typeof a=="number"){for(;o.length<=a;)o.push(null);o[a]===null&&(o[a]=typeof l=="number"?[]:{}),o=o[a]}else if(o&&typeof o=="object"&&!Array.isArray(o)){let m=String(a);if(!b(m))continue;let A=o;(A[m]===null||A[m]===void 0)&&g(A,m,typeof l=="number"?[]:{}),o=A[m]}}let h=s[s.length-1];if(Array.isArray(o)&&typeof h=="number"){for(;o.length<=h;)o.push(null);o[h]=f}else if(o&&typeof o=="object"&&!Array.isArray(o)){let y=String(h);b(y)&&g(o,y,f)}}return[u]}case"truncate_stream":{let i=typeof t=="number"?Math.floor(t):0;if(e.length===0)return[];let u=[],c=p(t,e[0],n);for(let s of c)if(Array.isArray(s)){if(s.length===1&&Array.isArray(s[0])){let f=s[0];f.length>i&&u.push([f.slice(i)]);continue}if(s.length===2&&Array.isArray(s[0])){let f=s[0],o=s[1];f.length>i&&u.push([f.slice(i),o])}}return u}default:return null}}function st(t,r,e,n,p,i,u,c,s,f){switch(r){case"getpath":{if(e.length===0)return[null];let o=p(t,e[0],n),h=[];for(let y of o){let a=y,l=t;for(let m of a){if(l==null){l=null;break}if(Array.isArray(l)&&typeof m=="number")l=l[m];else if(typeof l=="object"&&typeof m=="string"){let A=l;if(!Object.hasOwn(A,m)){l=null;break}l=A[m]}else{l=null;break}}h.push(l)}return h}case"setpath":{if(e.length<2)return[null];let h=p(t,e[0],n)[0],a=p(t,e[1],n)[0];return[u(t,h,a)]}case"delpaths":{if(e.length===0)return[t];let h=p(t,e[0],n)[0],y=t;for(let a of h.sort((l,m)=>m.length-l.length))y=c(y,a);return[y]}case"path":{if(e.length===0)return[[]];let o=[];return f(t,e[0],n,[],o),o}case"del":return e.length===0?[t]:[s(t,e[0],n)];case"pick":{if(e.length===0)return[null];let o=[];for(let y of e)f(t,y,n,[],o);let h=null;for(let y of o){for(let l of y)if(typeof l=="number"&&l<0)throw new Error("Out of bounds negative array index");let a=t;for(let l of y){if(a==null)break;if(Array.isArray(a)&&typeof l=="number")a=a[l];else if(typeof a=="object"&&typeof l=="string"){let m=a;if(!Object.hasOwn(m,l)){a=null;break}a=m[l]}else{a=null;break}}h=u(h,y,a)}return[h]}case"paths":{let o=[],h=(y,a)=>{if(y&&typeof y=="object")if(Array.isArray(y))for(let l=0;l<y.length;l++)o.push([...a,l]),h(y[l],[...a,l]);else for(let l of Object.keys(y))o.push([...a,l]),h(y[l],[...a,l])};return h(t,[]),e.length>0?o.filter(y=>{let a=t;for(let m of y)if(Array.isArray(a)&&typeof m=="number")a=a[m];else if(a&&typeof a=="object"&&typeof m=="string"){let A=a;if(!Object.hasOwn(A,m))return!1;a=A[m]}else return!1;return p(a,e[0],n).some(i)}):o}case"leaf_paths":{let o=[],h=(y,a)=>{if(y===null||typeof y!="object")o.push(a);else if(Array.isArray(y))for(let l=0;l<y.length;l++)h(y[l],[...a,l]);else for(let l of Object.keys(y))h(y[l],[...a,l])};return h(t,[]),o}default:return null}}function it(t,r,e,n,p,i){switch(r){case"IN":{if(e.length===0)return[!1];if(e.length===1){let f=p(t,e[0],n);for(let o of f)if(i(t,o))return[!0];return[!1]}let u=p(t,e[0],n),c=p(t,e[1],n),s=new Set(c.map(f=>JSON.stringify(f)));for(let f of u)if(s.has(JSON.stringify(f)))return[!0];return[!1]}case"INDEX":{if(e.length===0)return[Object.create(null)];if(e.length===1){let s=p(t,e[0],n),f=Object.create(null);for(let o of s){let h=String(o);b(h)&&g(f,h,o)}return[f]}if(e.length===2){let s=p(t,e[0],n),f=Object.create(null);for(let o of s){let h=p(o,e[1],n);if(h.length>0){let y=String(h[0]);b(y)&&g(f,y,o)}}return[f]}let u=p(t,e[0],n),c=Object.create(null);for(let s of u){let f=p(s,e[1],n),o=p(s,e[2],n);if(f.length>0&&o.length>0){let h=String(f[0]);b(h)&&g(c,h,o[0])}}return[c]}case"JOIN":{if(e.length<2)return[null];let u=p(t,e[0],n)[0];if(!u||typeof u!="object"||Array.isArray(u))return[null];let c=u;if(!Array.isArray(t))return[null];let s=[];for(let f of t){let o=p(f,e[1],n),h=o.length>0?String(o[0]):"",y=C(c,h)?c[h]:null;s.push([f,y])}return[s]}default:return null}}function ot(t,r,e,n,p){switch(r){case"join":{if(!Array.isArray(t))return[null];let i=e.length>0?p(t,e[0],n):[""];for(let u of t)if(Array.isArray(u)||u!==null&&typeof u=="object")throw new Error("cannot join: contains arrays or objects");return i.map(u=>t.map(c=>c===null?"":typeof c=="string"?c:String(c)).join(String(u)))}case"split":{if(typeof t!="string"||e.length===0)return[null];let i=p(t,e[0],n),u=String(i[0]);return[t.split(u)]}case"splits":{if(typeof t!="string"||e.length===0)return[];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"g";return T(u,c.includes("g")?c:`${c}g`).split(t)}catch{return[]}}case"scan":{if(typeof t!="string"||e.length===0)return[];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"";return[...T(u,c.includes("g")?c:`${c}g`).matchAll(t)].map(o=>o.length>1?o.slice(1):o[0])}catch{return[]}}case"test":{if(typeof t!="string"||e.length===0)return[!1];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"";return[T(u,c).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||e.length===0)return[null];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"",f=T(u,`${c}d`).exec(t);if(!f)return[];let o=f.indices;return[{offset:f.index,length:f[0].length,string:f[0],captures:f.slice(1).map((h,y)=>({offset:o?.[y+1]?.[0]??null,length:h?.length??0,string:h??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||e.length===0)return[null];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"",f=T(u,c).match(t);return!f||!f.groups?[Object.create(null)]:[f.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),c=String(i[0]),s=String(u[0]);try{let f=e.length>2?String(p(t,e[2],n)[0]):"";return[T(c,f).replace(t,s)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),c=String(i[0]),s=String(u[0]);try{let f=e.length>2?String(p(t,e[2],n)[0]):"g",o=f.includes("g")?f:`${f}g`;return[T(c,o).replace(t,s)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof t=="string"?[t.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof t!="string"||e.length===0)return[t];let i=p(t,e[0],n),u=String(i[0]);return[t.startsWith(u)?t.slice(u.length):t]}case"rtrimstr":{if(typeof t!="string"||e.length===0)return[t];let i=p(t,e[0],n),u=String(i[0]);return u===""?[t]:[t.endsWith(u)?t.slice(0,-u.length):t]}case"trimstr":{if(typeof t!="string"||e.length===0)return[t];let i=p(t,e[0],n),u=String(i[0]);if(u==="")return[t];let c=t;return c.startsWith(u)&&(c=c.slice(u.length)),c.endsWith(u)&&(c=c.slice(0,-u.length)),[c]}case"trim":if(typeof t=="string")return[t.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof t=="string")return[t.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof t=="string")return[t.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof t!="string"||e.length===0)return[!1];let i=p(t,e[0],n);return[t.startsWith(String(i[0]))]}case"endswith":{if(typeof t!="string"||e.length===0)return[!1];let i=p(t,e[0],n);return[t.endsWith(String(i[0]))]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(t))throw new Error("implode input must be an array");return[t.map(c=>{if(typeof c=="string")throw new Error(`string (${JSON.stringify(c)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof c!="number"||Number.isNaN(c))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let s=Math.trunc(c);return s<0||s>1114111||s>=55296&&s<=57343?String.fromCodePoint(65533):String.fromCodePoint(s)}).join("")];default:return null}}function ft(t,r){switch(r){case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"values":return t===null?[]:[t];case"not":return t===!1||t===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}function F(t,r,e){if(r.length===0)return e;let[n,...p]=r;if(typeof n=="number"){if(t&&typeof t=="object"&&!Array.isArray(t))throw new Error("Cannot index object with number");if(n>536870911)throw new Error("Array index too large");if(n<0)throw new Error("Out of bounds negative array index");let s=Array.isArray(t)?[...t]:[];for(;s.length<=n;)s.push(null);return s[n]=F(s[n],p,e),s}if(Array.isArray(t))throw new Error("Cannot index array with string");if(!b(n))return t??Object.create(null);let i=t&&typeof t=="object"&&!Array.isArray(t)?k(t):Object.create(null),u=Object.hasOwn(i,n)?i[n]:void 0;return g(i,n,F(u,p,e)),i}function K(t,r){if(r.length===0)return null;if(r.length===1){let p=r[0];if(Array.isArray(t)&&typeof p=="number"){let i=[...t];return i.splice(p,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i=String(p);if(!b(i))return t;let u=k(t);return delete u[i],u}return t}let[e,...n]=r;if(Array.isArray(t)&&typeof e=="number"){let p=[...t];return p[e]=K(p[e],n),p}if(t&&typeof t=="object"&&!Array.isArray(t)){let p=String(e);if(!b(p))return t;let i=k(t);return Object.hasOwn(i,p)&&g(i,p,K(i[p],n)),i}return t}var D=class t extends Error{label;partialResults;constructor(r,e=[]){super(`break ${r}`),this.label=r,this.partialResults=e,this.name="BreakError"}withPrependedResults(r){return new t(this.label,[...r,...this.partialResults])}},J=class extends Error{value;constructor(r){super(typeof r=="string"?r:JSON.stringify(r)),this.value=r,this.name="JqError"}},Ot=1e4,mt=2e3,Nt=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]]);function St(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??Ot,maxDepth:t?.limits?.maxDepth??mt},env:t?.env,coverage:t?.coverage,requireDefenseContext:t?.requireDefenseContext,defenseContextChecked:!1}}function H(t,r,e){let n=new Map(t.vars);return n.set(r,e),{vars:n,limits:t.limits,env:t.env,requireDefenseContext:t.requireDefenseContext,defenseContextChecked:t.defenseContextChecked,root:t.root,currentPath:t.currentPath,funcs:t.funcs,labels:t.labels,coverage:t.coverage}}function U(t,r,e){switch(r.type){case"var":return H(t,r.name,e);case"array":{if(!Array.isArray(e))return null;let n=t;for(let p=0;p<r.elements.length;p++){let i=r.elements[p],u=p<e.length?e[p]:null,c=U(n,i,u);if(c===null)return null;n=c}return n}case"object":{if(e===null||typeof e!="object"||Array.isArray(e))return null;let n=e,p=t;for(let i of r.fields){let u;if(typeof i.key=="string")u=i.key;else{let f=d(e,i.key,t);if(f.length===0)return null;u=String(f[0])}let c=C(n,u)?n[u]:null;i.keyVar&&(p=H(p,i.keyVar,c));let s=U(p,i.pattern,c);if(s===null)return null;p=s}return p}}}function Ct(t,r){let e=t;for(let n of r)if(e&&typeof e=="object")if(Array.isArray(e))if(typeof n=="number")e=e[n];else return;else{let p=e;if(typeof n=="string"&&Object.hasOwn(p,n))e=p[n];else return}else return;return e}function j(t){if(t.type==="Identity")return[];if(t.type==="Field"){let r=t.base?j(t.base):[];return r===null?null:[...r,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let r=t.base?j(t.base):[];if(r===null)return null;let e=t.index.value;return typeof e=="number"||typeof e=="string"?[...r,e]:null}if(t.type==="Pipe"){let r=j(t.left);return r===null?null:ct(r,t.right)}if(t.type==="Call"){if(t.name==="parent"||t.name==="root")return null;if(t.name==="first"&&t.args.length===0)return[0];if(t.name==="last"&&t.args.length===0)return[-1]}return null}function ct(t,r){if(r.type==="Call"){if(r.name==="parent"){let e=1;if(r.args.length>0&&r.args[0].type==="Literal"){let n=r.args[0].value;typeof n=="number"&&(e=n)}if(e>=0)return t.slice(0,Math.max(0,t.length-e));{let n=-e-1;return t.slice(0,Math.min(n,t.length))}}if(r.name==="root")return[]}if(r.type==="Field"){let e=j(r);if(e!==null)return[...t,...e]}if(r.type==="Index"&&r.index.type==="Literal"){let e=j(r);if(e!==null)return[...t,...e]}if(r.type==="Pipe"){let e=ct(t,r.left);return e===null?null:ct(e,r.right)}return r.type==="Identity"?t:null}function at(t,r,e){if(r.type==="Comma"){let n=[];try{n.push(...d(t,r.left,e))}catch(p){if(p instanceof P)throw p;if(n.length>0)return n;throw new Error("evaluation failed")}try{n.push(...d(t,r.right,e))}catch(p){if(p instanceof P)throw p;return n}return n}return d(t,r,e)}function d(t,r,e){let n=e&&"vars"in e?e:St(e);switch(n.defenseContextChecked||(ht(n.requireDefenseContext,"query-engine","evaluation"),n={...n,defenseContextChecked:!0}),n.root===void 0&&(n={...n,root:t,currentPath:[]}),n.coverage?.hit(`jq:node:${r.type}`),r.type){case"Identity":return[t];case"Field":return(r.base?d(t,r.base,n):[t]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let c=i;if(!Object.hasOwn(c,r.name))return[null];let s=c[r.name];return[s===void 0?null:s]}if(i===null)return[null];let u=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${u} with string "${r.name}"`)});case"Index":return(r.base?d(t,r.base,n):[t]).flatMap(i=>d(i,r.index,n).flatMap(c=>{if(typeof c=="number"&&Array.isArray(i)){if(Number.isNaN(c))return[null];let s=Math.trunc(c),f=s<0?i.length+s:s;return f>=0&&f<i.length?[i[f]]:[null]}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){let s=i;return Object.hasOwn(s,c)?[s[c]]:[null]}return[null]}));case"Slice":return(r.base?d(t,r.base,n):[t]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let u=i.length,c=r.start?d(t,r.start,n):[0],s=r.end?d(t,r.end,n):[u];return c.flatMap(f=>s.map(o=>{let h=f,y=o,a=Number.isNaN(h)?0:Number.isInteger(h)?h:Math.floor(h),l=Number.isNaN(y)?u:Number.isInteger(y)?y:Math.ceil(y),m=lt(a,u),A=lt(l,u);return Array.isArray(i),i.slice(m,A)}))});case"Iterate":return(r.base?d(t,r.base,n):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let p=d(t,r.left,n),i=j(r.left),u=[];for(let c of p)try{if(i!==null){let s={...n,currentPath:[...n.currentPath??[],...i]};u.push(...d(c,r.right,s))}else u.push(...d(c,r.right,n))}catch(s){throw s instanceof D?s.withPrependedResults(u):s}return u}case"Comma":{let p=d(t,r.left,n),i=d(t,r.right,n);return[...p,...i]}case"Literal":return[r.value];case"Array":return r.elements?[d(t,r.elements,n)]:[[]];case"Object":{let p=[Object.create(null)];for(let i of r.entries){let u=typeof i.key=="string"?[i.key]:d(t,i.key,n),c=d(t,i.value,n),s=[];for(let f of p)for(let o of u){if(typeof o!="string"){let h=o===null?"null":Array.isArray(o)?"array":typeof o;throw new Error(`Cannot use ${h} (${JSON.stringify(o)}) as object key`)}if(!b(o)){for(let h of c)s.push(k(f));continue}for(let h of c){let y=k(f);g(y,o,h),s.push(y)}}p.length=0,p.push(...s)}return p}case"Paren":return d(t,r.expr,n);case"BinaryOp":return Rt(t,r.op,r.left,r.right,n);case"UnaryOp":return d(t,r.operand,n).map(i=>{if(r.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let u=c=>c.length>5?`"${c.slice(0,3)}...`:JSON.stringify(c);throw new Error(`string (${u(i)}) cannot be negated`)}return null}return r.op==="not"?!N(i):null});case"Cond":return d(t,r.cond,n).flatMap(i=>{if(N(i))return d(t,r.then,n);for(let u of r.elifs)if(d(t,u.cond,n).some(N))return d(t,u.then,n);return r.else?d(t,r.else,n):[t]});case"Try":try{return d(t,r.body,n)}catch(p){if(r.catch){let i=p instanceof J?p.value:p instanceof Error?p.message:String(p);return d(i,r.catch,n)}return[]}case"Call":return dt(t,r.name,r.args,n);case"VarBind":return d(t,r.value,n).flatMap(i=>{let u=null,c=[];r.pattern?c.push(r.pattern):r.name&&c.push({type:"var",name:r.name}),r.alternatives&&c.push(...r.alternatives);for(let s of c)if(u=U(n,s,i),u!==null)break;return u===null?[]:d(t,r.body,u)});case"VarRef":{if(r.name==="$ENV")return[n.env?G(n.env):Object.create(null)];let p=n.vars.get(r.name);return p!==void 0?[p]:[null]}case"Recurse":{let p=[],i=new WeakSet,u=c=>{if(c&&typeof c=="object"){if(i.has(c))return;i.add(c)}if(p.push(c),Array.isArray(c))for(let s of c)u(s);else if(c&&typeof c=="object")for(let s of Object.keys(c))u(c[s])};return u(t),p}case"Optional":try{return d(t,r.expr,n)}catch{return[]}case"StringInterp":return[r.parts.map(i=>typeof i=="string"?i:d(t,i,n).map(c=>typeof c=="string"?c:JSON.stringify(c)).join("")).join("")];case"UpdateOp":return[Tt(t,r.path,r.op,r.value,n)];case"Reduce":{let p=d(t,r.expr,n),i=d(t,r.init,n)[0],u=n.limits.maxDepth??mt;for(let c of p){let s;if(r.pattern){if(s=U(n,r.pattern,c),s===null)continue}else s=H(n,r.varName,c);if(i=d(i,r.update,s)[0],I(i,u+1)>u)return[null]}return[i]}case"Foreach":{let p=d(t,r.expr,n),i=d(t,r.init,n)[0],u=[];for(let c of p)try{let s;if(r.pattern){if(s=U(n,r.pattern,c),s===null)continue}else s=H(n,r.varName,c);if(i=d(i,r.update,s)[0],r.extract){let f=d(i,r.extract,s);u.push(...f)}else u.push(i)}catch(s){throw s instanceof D?s.withPrependedResults(u):s}return u}case"Label":try{return d(t,r.body,{...n,labels:new Set([...n.labels??[],r.name])})}catch(p){if(p instanceof D&&p.label===r.name)return p.partialResults;throw p}case"Break":throw new D(r.name);case"Def":{let p=new Map(n.funcs??[]),i=`${r.name}/${r.params.length}`;p.set(i,{params:r.params,body:r.funcBody,closure:new Map(n.funcs??[])});let u={...n,funcs:p};return d(t,r.body,u)}default:{let p=r;throw new Error(`Unknown AST node type: ${p.type}`)}}}function lt(t,r){return t<0?Math.max(0,r+t):Math.min(t,r)}function Tt(t,r,e,n,p){function i(s,f){switch(e){case"=":return f;case"|=":return d(s,n,p)[0]??null;case"+=":return typeof s=="number"&&typeof f=="number"||typeof s=="string"&&typeof f=="string"?s+f:Array.isArray(s)&&Array.isArray(f)?[...s,...f]:s&&f&&typeof s=="object"&&typeof f=="object"?X(s,f):f;case"-=":return typeof s=="number"&&typeof f=="number"?s-f:s;case"*=":return typeof s=="number"&&typeof f=="number"?s*f:s;case"/=":return typeof s=="number"&&typeof f=="number"?s/f:s;case"%=":return typeof s=="number"&&typeof f=="number"?s%f:s;case"//=":return s===null||s===!1?f:s;default:return f}}function u(s,f,o){switch(f.type){case"Identity":return o(s);case"Field":{if(!b(f.name))return s;if(f.base)return u(s,f.base,h=>{if(h&&typeof h=="object"&&!Array.isArray(h)){let y=k(h),a=Object.hasOwn(y,f.name)?y[f.name]:void 0;return g(y,f.name,o(a)),y}return h});if(s&&typeof s=="object"&&!Array.isArray(s)){let h=k(s),y=Object.hasOwn(h,f.name)?h[f.name]:void 0;return g(h,f.name,o(y)),h}return s}case"Index":{let y=d(t,f.index,p)[0];if(typeof y=="number"&&Number.isNaN(y))throw new Error("Cannot set array element at NaN index");if(typeof y=="number"&&!Number.isInteger(y)&&(y=Math.trunc(y)),f.base)return u(s,f.base,a=>{if(typeof y=="number"&&Array.isArray(a)){let l=[...a],m=y<0?l.length+y:y;if(m>=0){for(;l.length<=m;)l.push(null);l[m]=o(l[m])}return l}if(typeof y=="string"&&a&&typeof a=="object"&&!Array.isArray(a)){if(!b(y))return a;let l=k(a),m=Object.hasOwn(l,y)?l[y]:void 0;return g(l,y,o(m)),l}return a});if(typeof y=="number"){if(y>536870911)throw new Error("Array index too large");if(y<0&&(!s||!Array.isArray(s)))throw new Error("Out of bounds negative array index");if(Array.isArray(s)){let l=[...s],m=y<0?l.length+y:y;if(m>=0){for(;l.length<=m;)l.push(null);l[m]=o(l[m])}return l}if(s==null){let l=[];for(;l.length<=y;)l.push(null);return l[y]=o(null),l}return s}if(typeof y=="string"&&s&&typeof s=="object"&&!Array.isArray(s)){if(!b(y))return s;let a=k(s),l=Object.hasOwn(a,y)?a[y]:void 0;return g(a,y,o(l)),a}return s}case"Iterate":{let h=y=>{if(Array.isArray(y))return y.map(a=>o(a));if(y&&typeof y=="object"){let a=Object.create(null);for(let[l,m]of Object.entries(y))b(l)&&g(a,l,o(m));return a}return y};return f.base?u(s,f.base,h):h(s)}case"Pipe":{let h=u(s,f.left,y=>y);return u(h,f.right,o)}default:return o(s)}}return u(t,r,s=>{if(e==="|=")return i(s,s);let f=d(t,n,p);return i(s,f[0]??null)})}function jt(t,r,e){function n(i,u,c){switch(u.type){case"Identity":return c;case"Field":{if(!b(u.name))return i;if(u.base){let s=d(i,u.base,e)[0],f=n(s,{type:"Field",name:u.name},c);return n(i,u.base,f)}if(i&&typeof i=="object"&&!Array.isArray(i)){let s=k(i);return g(s,u.name,c),s}return i}case"Index":{if(u.base){let o=d(i,u.base,e)[0],h=n(o,{type:"Index",index:u.index},c);return n(i,u.base,h)}let f=d(t,u.index,e)[0];if(typeof f=="number"&&Array.isArray(i)){let o=[...i],h=f<0?o.length+f:f;return h>=0&&h<o.length&&(o[h]=c),o}if(typeof f=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!b(f))return i;let o=k(i);return g(o,f,c),o}return i}default:return i}}function p(i,u){switch(u.type){case"Identity":return null;case"Field":{if(!b(u.name))return i;if(u.base){let s=d(i,u.base,e)[0];if(s==null)return i;let f=p(s,{type:"Field",name:u.name});return n(i,u.base,f)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!b(u.name))return i;let s=k(i);return delete s[u.name],s}return i}case"Index":{if(u.base){let o=d(i,u.base,e)[0];if(o==null)return i;let h=p(o,{type:"Index",index:u.index});return n(i,u.base,h)}let f=d(t,u.index,e)[0];if(typeof f=="number"&&Array.isArray(i)){let o=[...i],h=f<0?o.length+f:f;return h>=0&&h<o.length&&o.splice(h,1),o}if(typeof f=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!b(f))return i;let o=k(i);return delete o[f],o}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?Object.create(null):i;case"Pipe":{let o=function(a,l,m){switch(l.type){case"Identity":return m;case"Field":{if(!b(l.name))return a;if(a&&typeof a=="object"&&!Array.isArray(a)){let A=k(a);return g(A,l.name,m),A}return a}case"Index":{let E=d(t,l.index,e)[0];if(typeof E=="number"&&Array.isArray(a)){let w=[...a],O=E<0?w.length+E:E;return O>=0&&O<w.length&&(w[O]=m),w}if(typeof E=="string"&&a&&typeof a=="object"&&!Array.isArray(a)){if(!b(E))return a;let w=k(a);return g(w,E,m),w}return a}case"Pipe":{let A=d(a,l.left,e)[0],E=o(A,l.right,m);return o(a,l.left,E)}default:return a}};var c=o;let s=u.left,f=u.right,h=d(i,s,e)[0];if(h==null)return i;let y=p(h,f);return o(i,s,y)}default:return i}}return p(t,r)}function Rt(t,r,e,n,p){if(r==="and")return d(t,e,p).flatMap(s=>N(s)?d(t,n,p).map(o=>N(o)):[!1]);if(r==="or")return d(t,e,p).flatMap(s=>N(s)?[!0]:d(t,n,p).map(o=>N(o)));if(r==="//"){let s=d(t,e,p).filter(f=>f!=null&&f!==!1);return s.length>0?s:d(t,n,p)}let i=d(t,e,p),u=d(t,n,p);return i.flatMap(c=>u.map(s=>{switch(r){case"+":return c===null?s:s===null?c:typeof c=="number"&&typeof s=="number"||typeof c=="string"&&typeof s=="string"?c+s:Array.isArray(c)&&Array.isArray(s)?[...c,...s]:c&&s&&typeof c=="object"&&typeof s=="object"&&!Array.isArray(c)&&!Array.isArray(s)?X(c,s):null;case"-":if(typeof c=="number"&&typeof s=="number")return c-s;if(Array.isArray(c)&&Array.isArray(s)){let f=new Set(s.map(o=>JSON.stringify(o)));return c.filter(o=>!f.has(JSON.stringify(o)))}if(typeof c=="string"&&typeof s=="string"){let f=o=>o.length>10?`"${o.slice(0,10)}...`:JSON.stringify(o);throw new Error(`string (${f(c)}) and string (${f(s)}) cannot be subtracted`)}return null;case"*":return typeof c=="number"&&typeof s=="number"?c*s:typeof c=="string"&&typeof s=="number"?c.repeat(s):c&&s&&typeof c=="object"&&typeof s=="object"&&!Array.isArray(c)&&!Array.isArray(s)?z(c,s):null;case"/":if(typeof c=="number"&&typeof s=="number"){if(s===0)throw new Error(`number (${c}) and number (${s}) cannot be divided because the divisor is zero`);return c/s}return typeof c=="string"&&typeof s=="string"?c.split(s):null;case"%":if(typeof c=="number"&&typeof s=="number"){if(s===0)throw new Error(`number (${c}) and number (${s}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(c)&&!Number.isNaN(c)?!Number.isFinite(s)&&!Number.isNaN(s)&&c<0&&s>0?-1:0:c%s}return null;case"==":return x(c,s);case"!=":return!x(c,s);case"<":return B(c,s)<0;case"<=":return B(c,s)<=0;case">":return B(c,s)>0;case">=":return B(c,s)>=0;default:return null}}))}function dt(t,r,e,n){let p=Nt.get(r);if(p)return typeof t=="number"?[p(t)]:[null];let i=et(t,r,e,n,d);if(i!==null)return i;let u=ot(t,r,e,n,d);if(u!==null)return u;let c=Z(t,r,e,n,d);if(c!==null)return c;let s=v(t,r,n.limits.maxDepth);if(s!==null)return s;let f=ft(t,r);if(f!==null)return f;let o=nt(t,r,e,n,d);if(o!==null)return o;let h=W(t,r,e,n,d,at,_,N,$,P);if(h!==null)return h;let y=st(t,r,e,n,d,N,F,K,jt,V);if(y!==null)return y;let a=tt(t,r,e,n,d,x);if(a!==null)return a;let l=Q(t,r,e,n,d,at,N,P);if(l!==null)return l;let m=rt(t,r,e,n,d,N,Ct,dt);if(m!==null)return m;let A=it(t,r,e,n,d,x);if(A!==null)return A;switch(r){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let E=e.length>0?d(t,e[0],n)[0]:t;throw new J(E)}case"env":return[n.env?G(n.env):Object.create(null)];case"debug":return[t];case"input_line_number":return[1];default:{let E=`${r}/${e.length}`,w=n.funcs?.get(E);if(w){let O=w.closure??n.funcs??new Map,S=new Map(O);S.set(E,w);for(let L=0;L<w.params.length;L++){let Et=w.params[L],ut=e[L];if(ut){let R=d(t,ut,n),M;if(R.length===0)M={type:"Call",name:"empty",args:[]};else if(R.length===1)M={type:"Literal",value:R[0]};else{M={type:"Literal",value:R[R.length-1]};for(let Y=R.length-2;Y>=0;Y--)M={type:"Comma",left:{type:"Literal",value:R[Y]},right:M}}S.set(`${Et}/0`,{params:[],body:M})}}let gt={...n,funcs:S};return d(t,w.body,gt)}throw new Error(`Unknown function: ${r}`)}}}function V(t,r,e,n,p){if(r.type==="Comma"){let c=r;V(t,c.left,e,n,p),V(t,c.right,e,n,p);return}let i=j(r);if(i!==null){p.push([...n,...i]);return}if(r.type==="Iterate"){if(Array.isArray(t))for(let c=0;c<t.length;c++)p.push([...n,c]);else if(t&&typeof t=="object")for(let c of Object.keys(t))p.push([...n,c]);return}if(r.type==="Recurse"){let c=(s,f)=>{if(p.push([...n,...f]),s&&typeof s=="object")if(Array.isArray(s))for(let o=0;o<s.length;o++)c(s[o],[...f,o]);else for(let o of Object.keys(s))c(s[o],[...f,o])};c(t,[]);return}if(r.type==="Pipe"){let c=j(r.left);if(c!==null){let s=d(t,r.left,e);for(let f of s)V(f,r.right,e,[...n,...c],p);return}}d(t,r,e).length>0&&p.push(n)}var At=new Map([["and","AND"],["or","OR"],["not","NOT"],["if","IF"],["then","THEN"],["elif","ELIF"],["else","ELSE"],["end","END"],["as","AS"],["try","TRY"],["catch","CATCH"],["true","TRUE"],["false","FALSE"],["null","NULL"],["reduce","REDUCE"],["foreach","FOREACH"],["label","LABEL"],["break","BREAK"],["def","DEF"]]),q=new Set(At.values());function bt(t){let r=[],e=0,n=(f=0)=>t[e+f],p=()=>t[e++],i=()=>e>=t.length,u=f=>f>="0"&&f<="9",c=f=>f>="a"&&f<="z"||f>="A"&&f<="Z"||f==="_",s=f=>c(f)||u(f);for(;!i();){let f=e,o=p();if(!(o===" "||o===" "||o===`
3
+ `||o==="\r")){if(o==="#"){for(;!i()&&n()!==`
4
+ `;)p();continue}if(o==="."&&n()==="."){p(),r.push({type:"DOTDOT",pos:f});continue}if(o==="="&&n()==="="){p(),r.push({type:"EQ",pos:f});continue}if(o==="!"&&n()==="="){p(),r.push({type:"NE",pos:f});continue}if(o==="<"&&n()==="="){p(),r.push({type:"LE",pos:f});continue}if(o===">"&&n()==="="){p(),r.push({type:"GE",pos:f});continue}if(o==="/"&&n()==="/"){p(),n()==="="?(p(),r.push({type:"UPDATE_ALT",pos:f})):r.push({type:"ALT",pos:f});continue}if(o==="+"&&n()==="="){p(),r.push({type:"UPDATE_ADD",pos:f});continue}if(o==="-"&&n()==="="){p(),r.push({type:"UPDATE_SUB",pos:f});continue}if(o==="*"&&n()==="="){p(),r.push({type:"UPDATE_MUL",pos:f});continue}if(o==="/"&&n()==="="){p(),r.push({type:"UPDATE_DIV",pos:f});continue}if(o==="%"&&n()==="="){p(),r.push({type:"UPDATE_MOD",pos:f});continue}if(o==="="&&n()!=="="){r.push({type:"ASSIGN",pos:f});continue}if(o==="."){r.push({type:"DOT",pos:f});continue}if(o==="|"){n()==="="?(p(),r.push({type:"UPDATE_PIPE",pos:f})):r.push({type:"PIPE",pos:f});continue}if(o===","){r.push({type:"COMMA",pos:f});continue}if(o===":"){r.push({type:"COLON",pos:f});continue}if(o===";"){r.push({type:"SEMICOLON",pos:f});continue}if(o==="("){r.push({type:"LPAREN",pos:f});continue}if(o===")"){r.push({type:"RPAREN",pos:f});continue}if(o==="["){r.push({type:"LBRACKET",pos:f});continue}if(o==="]"){r.push({type:"RBRACKET",pos:f});continue}if(o==="{"){r.push({type:"LBRACE",pos:f});continue}if(o==="}"){r.push({type:"RBRACE",pos:f});continue}if(o==="?"){r.push({type:"QUESTION",pos:f});continue}if(o==="+"){r.push({type:"PLUS",pos:f});continue}if(o==="-"){r.push({type:"MINUS",pos:f});continue}if(o==="*"){r.push({type:"STAR",pos:f});continue}if(o==="/"){r.push({type:"SLASH",pos:f});continue}if(o==="%"){r.push({type:"PERCENT",pos:f});continue}if(o==="<"){r.push({type:"LT",pos:f});continue}if(o===">"){r.push({type:"GT",pos:f});continue}if(u(o)){let h=o;for(;!i()&&(u(n())||n()==="."||n()==="e"||n()==="E");)(n()==="e"||n()==="E")&&(t[e+1]==="+"||t[e+1]==="-")&&(h+=p()),h+=p();r.push({type:"NUMBER",value:Number(h),pos:f});continue}if(o==='"'){let h="";for(;!i()&&n()!=='"';)if(n()==="\\"){if(p(),i())break;let y=p();switch(y){case"n":h+=`
5
+ `;break;case"r":h+="\r";break;case"t":h+=" ";break;case"\\":h+="\\";break;case'"':h+='"';break;case"(":h+="\\(";break;default:h+=y}}else h+=p();i()||p(),r.push({type:"STRING",value:h,pos:f});continue}if(c(o)||o==="$"||o==="@"){let h=o;for(;!i()&&s(n());)h+=p();let y=At.get(h);y?r.push({type:y,value:h,pos:f}):r.push({type:"IDENT",value:h,pos:f});continue}throw new Error(`Unexpected character '${o}' at position ${f}`)}}return r.push({type:"EOF",pos:e}),r}var pt=class t{tokens;pos=0;constructor(r){this.tokens=r}peek(r=0){return this.tokens[this.pos+r]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(r){return this.peek().type===r}match(...r){for(let e of r)if(this.check(e))return this.advance();return null}expect(r,e){if(!this.check(r))throw new Error(`${e} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}isFieldNameAfterDot(r=0){let e=this.peek(r),n=this.peek(r+1);return n.type==="STRING"?!0:n.type==="IDENT"||q.has(n.type)?n.pos===e.pos+1:!1}isIdentLike(){let r=this.peek().type;return r==="IDENT"||q.has(r)}consumeFieldNameAfterDot(r){let e=this.peek();return e.type==="STRING"?this.advance().value:(e.type==="IDENT"||q.has(e.type))&&e.pos===r.pos+1?this.advance().value:null}parse(){let r=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return r}parseExpr(){return this.parsePipe()}parsePattern(){if(this.match("LBRACKET")){let n=[];if(!this.check("RBRACKET"))for(n.push(this.parsePattern());this.match("COMMA")&&!this.check("RBRACKET");)n.push(this.parsePattern());return this.expect("RBRACKET","Expected ']' after array pattern"),{type:"array",elements:n}}if(this.match("LBRACE")){let n=[];if(!this.check("RBRACE"))for(n.push(this.parsePatternField());this.match("COMMA")&&!this.check("RBRACE");)n.push(this.parsePatternField());return this.expect("RBRACE","Expected '}' after object pattern"),{type:"object",fields:n}}let r=this.expect("IDENT","Expected variable name in pattern"),e=r.value;if(!e.startsWith("$"))throw new Error(`Variable name must start with $ at position ${r.pos}`);return{type:"var",name:e}}parsePatternField(){if(this.match("LPAREN")){let e=this.parseExpr();this.expect("RPAREN","Expected ')' after computed key"),this.expect("COLON","Expected ':' after computed key");let n=this.parsePattern();return{key:e,pattern:n}}let r=this.peek();if(r.type==="IDENT"||q.has(r.type)){let e=r.value;if(e.startsWith("$")){if(this.advance(),this.match("COLON")){let n=this.parsePattern();return{key:e.slice(1),pattern:n,keyVar:e}}return{key:e.slice(1),pattern:{type:"var",name:e}}}if(this.advance(),this.match("COLON")){let n=this.parsePattern();return{key:e,pattern:n}}return{key:e,pattern:{type:"var",name:`$${e}`}}}throw new Error(`Expected field name in object pattern at position ${r.pos}`)}parsePipe(){let r=this.parseComma();for(;this.match("PIPE");){let e=this.parseComma();r={type:"Pipe",left:r,right:e}}return r}parseComma(){let r=this.parseVarBind();for(;this.match("COMMA");){let e=this.parseVarBind();r={type:"Comma",left:r,right:e}}return r}parseVarBind(){let r=this.parseUpdate();if(this.match("AS")){let e=this.parsePattern(),n=[];for(;this.check("QUESTION")&&this.peekAhead(1)?.type==="ALT";)this.advance(),this.advance(),n.push(this.parsePattern());this.expect("PIPE","Expected '|' after variable binding");let p=this.parseExpr();return e.type==="var"&&n.length===0?{type:"VarBind",name:e.name,value:r,body:p}:{type:"VarBind",name:e.type==="var"?e.name:"",value:r,body:p,pattern:e.type!=="var"?e:void 0,alternatives:n.length>0?n:void 0}}return r}peekAhead(r){let e=this.pos+r;return e<this.tokens.length?this.tokens[e]:void 0}parseUpdate(){let r=this.parseAlt(),e=new Map([["ASSIGN","="],["UPDATE_ADD","+="],["UPDATE_SUB","-="],["UPDATE_MUL","*="],["UPDATE_DIV","/="],["UPDATE_MOD","%="],["UPDATE_ALT","//="],["UPDATE_PIPE","|="]]),n=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(n){let p=this.parseVarBind(),i=e.get(n.type);if(i)return{type:"UpdateOp",op:i,path:r,value:p}}return r}parseAlt(){let r=this.parseOr();for(;this.match("ALT");){let e=this.parseOr();r={type:"BinaryOp",op:"//",left:r,right:e}}return r}parseOr(){let r=this.parseAnd();for(;this.match("OR");){let e=this.parseAnd();r={type:"BinaryOp",op:"or",left:r,right:e}}return r}parseAnd(){let r=this.parseNot();for(;this.match("AND");){let e=this.parseNot();r={type:"BinaryOp",op:"and",left:r,right:e}}return r}parseNot(){return this.parseComparison()}parseComparison(){let r=this.parseAddSub(),e=new Map([["EQ","=="],["NE","!="],["LT","<"],["LE","<="],["GT",">"],["GE",">="]]),n=this.match("EQ","NE","LT","LE","GT","GE");if(n){let p=e.get(n.type);if(p){let i=this.parseAddSub();r={type:"BinaryOp",op:p,left:r,right:i}}}return r}parseAddSub(){let r=this.parseMulDiv();for(;;)if(this.match("PLUS")){let e=this.parseMulDiv();r={type:"BinaryOp",op:"+",left:r,right:e}}else if(this.match("MINUS")){let e=this.parseMulDiv();r={type:"BinaryOp",op:"-",left:r,right:e}}else break;return r}parseMulDiv(){let r=this.parseUnary();for(;;)if(this.match("STAR")){let e=this.parseUnary();r={type:"BinaryOp",op:"*",left:r,right:e}}else if(this.match("SLASH")){let e=this.parseUnary();r={type:"BinaryOp",op:"/",left:r,right:e}}else if(this.match("PERCENT")){let e=this.parseUnary();r={type:"BinaryOp",op:"%",left:r,right:e}}else break;return r}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let r=this.parsePrimary();for(;;)if(this.match("QUESTION"))r={type:"Optional",expr:r};else if(this.check("DOT")&&this.isFieldNameAfterDot())this.advance(),r={type:"Field",name:this.advance().value,base:r};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))r={type:"Iterate",base:r};else if(this.check("COLON")){this.advance();let e=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),r={type:"Slice",end:e,base:r}}else{let e=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),r={type:"Slice",start:e,end:n,base:r}}else this.expect("RBRACKET","Expected ']'"),r={type:"Index",index:e,base:r}}else break;return r}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.check("DOT")){let r=this.advance();if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let p=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:p}}let n=this.parseExpr();if(this.match("COLON")){let p=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:n,end:p}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:n}}let e=this.consumeFieldNameAfterDot(r);return e!==null?{type:"Field",name:e}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let e=this.advance().value;return e.includes("\\(")?this.parseStringInterpolation(e):{type:"Literal",value:e}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let r=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:r}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let r=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:r}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let r=this.parsePostfix(),e;return this.match("CATCH")&&(e=this.parsePostfix()),{type:"Try",body:r,catch:e}}if(this.match("REDUCE")){let r=this.parseAddSub();this.expect("AS","Expected 'as' after reduce expression");let e=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let n=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let p=this.parseExpr();this.expect("RPAREN","Expected ')' after update expression");let i=e.type==="var"?e.name:"";return{type:"Reduce",expr:r,varName:i,init:n,update:p,pattern:e.type!=="var"?e:void 0}}if(this.match("FOREACH")){let r=this.parseAddSub();this.expect("AS","Expected 'as' after foreach expression");let e=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let n=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let p=this.parseExpr(),i;this.match("SEMICOLON")&&(i=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions");let u=e.type==="var"?e.name:"";return{type:"Foreach",expr:r,varName:u,init:n,update:p,extract:i,pattern:e.type!=="var"?e:void 0}}if(this.match("LABEL")){let r=this.expect("IDENT","Expected label name (e.g., $out)"),e=r.value;if(!e.startsWith("$"))throw new Error(`Label name must start with $ at position ${r.pos}`);this.expect("PIPE","Expected '|' after label name");let n=this.parseExpr();return{type:"Label",name:e,body:n}}if(this.match("BREAK")){let r=this.expect("IDENT","Expected label name to break to"),e=r.value;if(!e.startsWith("$"))throw new Error(`Break label must start with $ at position ${r.pos}`);return{type:"Break",name:e}}if(this.match("DEF")){let e=this.expect("IDENT","Expected function name after def").value,n=[];if(this.match("LPAREN")){if(!this.check("RPAREN")){let u=this.expect("IDENT","Expected parameter name");for(n.push(u.value);this.match("SEMICOLON");){let c=this.expect("IDENT","Expected parameter name");n.push(c.value)}}this.expect("RPAREN","Expected ')' after parameters")}this.expect("COLON","Expected ':' after function name");let p=this.parseExpr();this.expect("SEMICOLON","Expected ';' after function body");let i=this.parseExpr();return{type:"Def",name:e,params:n,funcBody:p,body:i}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let e=this.advance().value;if(e.startsWith("$"))return{type:"VarRef",name:e};if(this.match("LPAREN")){let n=[];if(!this.check("RPAREN"))for(n.push(this.parseExpr());this.match("SEMICOLON");)n.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:e,args:n}}return{type:"Call",name:e,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let r=[];if(!this.check("RBRACE"))do{let e,n;if(this.match("LPAREN"))e=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else if(this.isIdentLike()){let p=this.advance().value;this.match("COLON")?(e=p,n=this.parseObjectValue()):(e=p,n={type:"Field",name:p})}else if(this.check("STRING"))e=this.advance().value,this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);r.push({key:e,value:n})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:r}}parseObjectValue(){let r=this.parseVarBind();for(;this.match("PIPE");){let e=this.parseVarBind();r={type:"Pipe",left:r,right:e}}return r}parseIf(){let r=this.parseExpr();this.expect("THEN","Expected 'then'");let e=this.parseExpr(),n=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let u=this.parseExpr();n.push({cond:i,then:u})}let p;return this.match("ELSE")&&(p=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:r,then:e,elifs:n,else:p}}parseStringInterpolation(r){let e=[],n="",p=0;for(;p<r.length;)if(r[p]==="\\"&&r[p+1]==="("){n&&(e.push(n),n=""),p+=2;let i=1,u="";for(;p<r.length&&i>0;)r[p]==="("?i++:r[p]===")"&&i--,i>0&&(u+=r[p]),p++;let c=bt(u),s=new t(c);e.push(s.parse())}else n+=r[p],p++;return n&&e.push(n),{type:"StringInterp",parts:e}}};function we(t){let r=bt(t);return new pt(r).parse()}export{d as a,we as b};
@@ -0,0 +1 @@
1
+ import*as o from"node:fs";import*as r from"node:path";function y(t){if(!t||t==="/")return"/";let e=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;e.startsWith("/")||(e=`/${e}`);let n=e.split("/").filter(i=>i&&i!=="."),s=[];for(let i of n)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}function u(t,e){return t===e||t.startsWith(`${e}/`)}function a(t,e){try{let n=o.realpathSync(t);return u(n,e)?n:null}catch(n){if(n.code==="ENOENT"){let s=r.dirname(t);if(s===t)return null;let i=a(s,e);if(i===null)return null;try{if(o.lstatSync(t).isSymbolicLink()){let l=o.readlinkSync(t),f=r.isAbsolute(l)?l:r.resolve(r.dirname(t),l);if(a(f,e)===null)return null}}catch{}return r.join(i,r.basename(t))}return null}}function m(t,e,n){let s=a(t,n);if(s===null)return null;let i=r.resolve(t),c=i.slice(e.length),l=s.slice(n.length);if(c!==l)return null;try{if(o.lstatSync(i).isSymbolicLink())return null}catch{}return s}function v(t,e){if(!o.existsSync(t))throw new Error(`${e} root does not exist`);if(!o.statSync(t).isDirectory())throw new Error(`${e} root is not a directory`)}function p(t,e){if(t.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${e} '${t}'`)}function S(t,e){if(!r.isAbsolute(t))return{withinRoot:!0,relativePath:t};let n;try{n=o.realpathSync(t)}catch{n=r.resolve(t)}return u(n,e)?{withinRoot:!0,relativePath:n.slice(e.length)||"/"}:{withinRoot:!1,safeName:r.basename(t)}}export{y as a,u as b,a as c,m as d,v as e,p as f,S as g};