@keystrokehq/cli 0.1.2 → 0.1.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 (237) hide show
  1. package/dist/alias-RTYYYW3D-CLFgrowj.mjs +98 -0
  2. package/dist/alias-RTYYYW3D-CLFgrowj.mjs.map +1 -0
  3. package/dist/awk2-LA3USKJP-BbsfXVlR.mjs +2737 -0
  4. package/dist/awk2-LA3USKJP-BbsfXVlR.mjs.map +1 -0
  5. package/dist/base64-C2AIWVNC-C0WIgu5V.mjs +123 -0
  6. package/dist/base64-C2AIWVNC-C0WIgu5V.mjs.map +1 -0
  7. package/dist/basename-UB3CIYNI-BgNN3bGm.mjs +53 -0
  8. package/dist/basename-UB3CIYNI-BgNN3bGm.mjs.map +1 -0
  9. package/dist/bash-YZ33HQZQ-N6YyKtUH.mjs +118 -0
  10. package/dist/bash-YZ33HQZQ-N6YyKtUH.mjs.map +1 -0
  11. package/dist/cat-TSFMZVYS-Dz3-oHsV.mjs +63 -0
  12. package/dist/cat-TSFMZVYS-Dz3-oHsV.mjs.map +1 -0
  13. package/dist/chmod-TFEPA42X-YF02QJUv.mjs +125 -0
  14. package/dist/chmod-TFEPA42X-YF02QJUv.mjs.map +1 -0
  15. package/dist/chunk-27JIFWUR-B6ZjjMMI.mjs +100 -0
  16. package/dist/chunk-27JIFWUR-B6ZjjMMI.mjs.map +1 -0
  17. package/dist/chunk-4I3HOE5Z-BixWWVkW.mjs +719 -0
  18. package/dist/chunk-4I3HOE5Z-BixWWVkW.mjs.map +1 -0
  19. package/dist/chunk-4RUAZWKT-D60fyWAB.mjs +22543 -0
  20. package/dist/chunk-4RUAZWKT-D60fyWAB.mjs.map +1 -0
  21. package/dist/chunk-4WKZNNJK-CiwxAWRf.mjs +69 -0
  22. package/dist/chunk-4WKZNNJK-CiwxAWRf.mjs.map +1 -0
  23. package/dist/chunk-5H5SCKJM-BvfXlL01.mjs +606 -0
  24. package/dist/chunk-5H5SCKJM-BvfXlL01.mjs.map +1 -0
  25. package/dist/chunk-AQ6FYS2X-CkVetjym.mjs +37 -0
  26. package/dist/chunk-AQ6FYS2X-CkVetjym.mjs.map +1 -0
  27. package/dist/chunk-BZUGFHVS-CPWRFwK8.mjs +34 -0
  28. package/dist/chunk-BZUGFHVS-CPWRFwK8.mjs.map +1 -0
  29. package/dist/chunk-CHFEPBH4-BUdgjFtD.mjs +594 -0
  30. package/dist/chunk-CHFEPBH4-BUdgjFtD.mjs.map +1 -0
  31. package/dist/chunk-DLL7UR66-BUYgzxnR.mjs +14 -0
  32. package/dist/chunk-DLL7UR66-BUYgzxnR.mjs.map +1 -0
  33. package/dist/chunk-DiodbrVj.mjs +27 -0
  34. package/dist/chunk-EBAPSGAO-Ctfslw2R.mjs +247 -0
  35. package/dist/chunk-EBAPSGAO-Ctfslw2R.mjs.map +1 -0
  36. package/dist/chunk-FOCWZZDE-BIntqBh2.mjs +19 -0
  37. package/dist/chunk-FOCWZZDE-BIntqBh2.mjs.map +1 -0
  38. package/dist/chunk-HBVMHTO5-CJyD-QZX.mjs +10 -0
  39. package/dist/chunk-HBVMHTO5-CJyD-QZX.mjs.map +1 -0
  40. package/dist/chunk-L2UW7DWF-B3tEHhPF.mjs +14 -0
  41. package/dist/chunk-L2UW7DWF-B3tEHhPF.mjs.map +1 -0
  42. package/dist/chunk-L64BMZUV-CyR7RKok.mjs +30 -0
  43. package/dist/chunk-L64BMZUV-CyR7RKok.mjs.map +1 -0
  44. package/dist/chunk-LEKBROJD-CJMrAyu9.mjs +3113 -0
  45. package/dist/chunk-LEKBROJD-CJMrAyu9.mjs.map +1 -0
  46. package/dist/chunk-NRSASXYY-CuWyREpD.mjs +41 -0
  47. package/dist/chunk-NRSASXYY-CuWyREpD.mjs.map +1 -0
  48. package/dist/chunk-QAYAQNCG-Bl0Kbd53.mjs +63 -0
  49. package/dist/chunk-QAYAQNCG-Bl0Kbd53.mjs.map +1 -0
  50. package/dist/chunk-QIQMJJZ4-BwKdslXs.mjs +93 -0
  51. package/dist/chunk-QIQMJJZ4-BwKdslXs.mjs.map +1 -0
  52. package/dist/chunk-SAI2SPQQ-CVRoDNs9.mjs +26 -0
  53. package/dist/chunk-SAI2SPQQ-CVRoDNs9.mjs.map +1 -0
  54. package/dist/chunk-SO6R3ZKN-tTw_RMDX.mjs +140 -0
  55. package/dist/chunk-SO6R3ZKN-tTw_RMDX.mjs.map +1 -0
  56. package/dist/chunk-STHBFACM-lyj-j2a-.mjs +8 -0
  57. package/dist/chunk-STHBFACM-lyj-j2a-.mjs.map +1 -0
  58. package/dist/chunk-SX2HC7SO-Cc4Hpis1.mjs +20 -0
  59. package/dist/chunk-SX2HC7SO-Cc4Hpis1.mjs.map +1 -0
  60. package/dist/chunk-TDD4NFYE-wsWW75MX.mjs +21 -0
  61. package/dist/chunk-TDD4NFYE-wsWW75MX.mjs.map +1 -0
  62. package/dist/chunk-TN7HHBQW-CSB_R-XD.mjs +1137 -0
  63. package/dist/chunk-TN7HHBQW-CSB_R-XD.mjs.map +1 -0
  64. package/dist/chunk-VPADYNBD-BKlA28GJ.mjs +122 -0
  65. package/dist/chunk-VPADYNBD-BKlA28GJ.mjs.map +1 -0
  66. package/dist/chunk-W5DWRFSU-lCyWk0ph.mjs +11 -0
  67. package/dist/chunk-W5DWRFSU-lCyWk0ph.mjs.map +1 -0
  68. package/dist/chunk-WNH3HOQA-BCZUOjCJ.mjs +34 -0
  69. package/dist/chunk-WNH3HOQA-BCZUOjCJ.mjs.map +1 -0
  70. package/dist/chunk-XRFHFXFP-BGxzVZgK.mjs +16 -0
  71. package/dist/chunk-XRFHFXFP-BGxzVZgK.mjs.map +1 -0
  72. package/dist/chunk-YCLFEX4T-COc1AThz.mjs +77 -0
  73. package/dist/chunk-YCLFEX4T-COc1AThz.mjs.map +1 -0
  74. package/dist/clear-HKGFEOF6-CekN2x-O.mjs +28 -0
  75. package/dist/clear-HKGFEOF6-CekN2x-O.mjs.map +1 -0
  76. package/dist/column-XT6UFXNQ-DHENV9D2.mjs +143 -0
  77. package/dist/column-XT6UFXNQ-DHENV9D2.mjs.map +1 -0
  78. package/dist/comm-VV2LDX2J-ppxDJFkY.mjs +87 -0
  79. package/dist/comm-VV2LDX2J-ppxDJFkY.mjs.map +1 -0
  80. package/dist/cp-BISAAS7A-CMWayU4n.mjs +106 -0
  81. package/dist/cp-BISAAS7A-CMWayU4n.mjs.map +1 -0
  82. package/dist/cut-OKARJCCV-Bt8b58eI.mjs +119 -0
  83. package/dist/cut-OKARJCCV-Bt8b58eI.mjs.map +1 -0
  84. package/dist/date-UUUPW43J-B7T5OTZZ.mjs +188 -0
  85. package/dist/date-UUUPW43J-B7T5OTZZ.mjs.map +1 -0
  86. package/dist/diff-MWJFIG7X-DhnPc_5r.mjs +755 -0
  87. package/dist/diff-MWJFIG7X-DhnPc_5r.mjs.map +1 -0
  88. package/dist/dirname-MPHRFUTI-Dkb3S4OX.mjs +43 -0
  89. package/dist/dirname-MPHRFUTI-Dkb3S4OX.mjs.map +1 -0
  90. package/dist/{dist-DjfxlOWX.mjs → dist-C47GdlWY.mjs} +18 -93
  91. package/dist/{dist-DjfxlOWX.mjs.map → dist-C47GdlWY.mjs.map} +1 -1
  92. package/dist/{dist-DWcRd4Se.mjs → dist-CJL2zYbP.mjs} +4 -71
  93. package/dist/dist-CJL2zYbP.mjs.map +1 -0
  94. package/dist/dist-Ch53z2P3.mjs +3 -0
  95. package/dist/dist-CwR72_PS.mjs +1887 -0
  96. package/dist/dist-CwR72_PS.mjs.map +1 -0
  97. package/dist/du-572XNP42-ClP4jXB1.mjs +176 -0
  98. package/dist/du-572XNP42-ClP4jXB1.mjs.map +1 -0
  99. package/dist/echo-NDWZZHPO-CCp_-MxA.mjs +137 -0
  100. package/dist/echo-NDWZZHPO-CCp_-MxA.mjs.map +1 -0
  101. package/dist/env-36M5BO7M-CsP_aiWr.mjs +119 -0
  102. package/dist/env-36M5BO7M-CsP_aiWr.mjs.map +1 -0
  103. package/dist/expand-JSPG6VOP-B-YUvYpu.mjs +145 -0
  104. package/dist/expand-JSPG6VOP-B-YUvYpu.mjs.map +1 -0
  105. package/dist/expr-5JAACS4X-1TBq84gG.mjs +153 -0
  106. package/dist/expr-5JAACS4X-1TBq84gG.mjs.map +1 -0
  107. package/dist/file-IPZJC3FQ-DcZNOWyY.mjs +4201 -0
  108. package/dist/file-IPZJC3FQ-DcZNOWyY.mjs.map +1 -0
  109. package/dist/find-INTH3OLC-6p47KeeT.mjs +1332 -0
  110. package/dist/find-INTH3OLC-6p47KeeT.mjs.map +1 -0
  111. package/dist/fold-4TQNYMSW-C54bHzLd.mjs +138 -0
  112. package/dist/fold-4TQNYMSW-C54bHzLd.mjs.map +1 -0
  113. package/dist/grep-V3LQVMRQ-D99Bq7Kj.mjs +335 -0
  114. package/dist/grep-V3LQVMRQ-D99Bq7Kj.mjs.map +1 -0
  115. package/dist/gzip-O5ASJAFY-CZDRROqP.mjs +592 -0
  116. package/dist/gzip-O5ASJAFY-CZDRROqP.mjs.map +1 -0
  117. package/dist/head-442HYESI-D96RMdki.mjs +36 -0
  118. package/dist/head-442HYESI-D96RMdki.mjs.map +1 -0
  119. package/dist/help-HZ6M2CKN--DK8mY2L.mjs +123 -0
  120. package/dist/help-HZ6M2CKN--DK8mY2L.mjs.map +1 -0
  121. package/dist/history-WYYKSLSZ-ACNQVupn.mjs +48 -0
  122. package/dist/history-WYYKSLSZ-ACNQVupn.mjs.map +1 -0
  123. package/dist/hostname-C4HQXXUP-CXVVFkUK.mjs +24 -0
  124. package/dist/hostname-C4HQXXUP-CXVVFkUK.mjs.map +1 -0
  125. package/dist/html-to-markdown-JW4MSQZO-DQOxFIvF.mjs +15890 -0
  126. package/dist/html-to-markdown-JW4MSQZO-DQOxFIvF.mjs.map +1 -0
  127. package/dist/index.mjs +20 -18
  128. package/dist/index.mjs.map +1 -1
  129. package/dist/join-TBRGI3LQ-B8I9tkJ5.mjs +198 -0
  130. package/dist/join-TBRGI3LQ-B8I9tkJ5.mjs.map +1 -0
  131. package/dist/jq-4XLYLOS5-wFZYfsfJ.mjs +257 -0
  132. package/dist/jq-4XLYLOS5-wFZYfsfJ.mjs.map +1 -0
  133. package/dist/js-exec-N5KEZBH7-CgtG-I6s.mjs +333 -0
  134. package/dist/js-exec-N5KEZBH7-CgtG-I6s.mjs.map +1 -0
  135. package/dist/lib-D4GpdNNK.mjs +45 -0
  136. package/dist/lib-D4GpdNNK.mjs.map +1 -0
  137. package/dist/ln-4LGSXXGD-Dg0R9i5G.mjs +101 -0
  138. package/dist/ln-4LGSXXGD-Dg0R9i5G.mjs.map +1 -0
  139. package/dist/ls-ZJGQER7M-DLDSfI4x.mjs +1891 -0
  140. package/dist/ls-ZJGQER7M-DLDSfI4x.mjs.map +1 -0
  141. package/dist/lzma-CTMDi254.mjs +1135 -0
  142. package/dist/lzma-CTMDi254.mjs.map +1 -0
  143. package/dist/{maybe-auto-update-Ou7H6dXT.mjs → maybe-auto-update-B0kal2FM.mjs} +2 -2
  144. package/dist/{maybe-auto-update-Ou7H6dXT.mjs.map → maybe-auto-update-B0kal2FM.mjs.map} +1 -1
  145. package/dist/md5sum-SPU24VSG-DQc8sqXO.mjs +16 -0
  146. package/dist/md5sum-SPU24VSG-DQc8sqXO.mjs.map +1 -0
  147. package/dist/mkdir-MEPGZOB6-BjUKzhdL.mjs +58 -0
  148. package/dist/mkdir-MEPGZOB6-BjUKzhdL.mjs.map +1 -0
  149. package/dist/mv-W5BIQ646-CdSIyY-U.mjs +93 -0
  150. package/dist/mv-W5BIQ646-CdSIyY-U.mjs.map +1 -0
  151. package/dist/nl-WSDW7I4O-DmtCnyKU.mjs +208 -0
  152. package/dist/nl-WSDW7I4O-DmtCnyKU.mjs.map +1 -0
  153. package/dist/od-WOKFDJTP-DZ2nxQNJ.mjs +73 -0
  154. package/dist/od-WOKFDJTP-DZ2nxQNJ.mjs.map +1 -0
  155. package/dist/paste-7JC6S4DX-CtmM5Qy8.mjs +113 -0
  156. package/dist/paste-7JC6S4DX-CtmM5Qy8.mjs.map +1 -0
  157. package/dist/printf-TWGXF445-B7cTysaa.mjs +880 -0
  158. package/dist/printf-TWGXF445-B7cTysaa.mjs.map +1 -0
  159. package/dist/pwd-WE6EN5AV-CO8o2WQS.mjs +34 -0
  160. package/dist/pwd-WE6EN5AV-CO8o2WQS.mjs.map +1 -0
  161. package/dist/python3-POMOR4OA-CKy80mpF.mjs +299 -0
  162. package/dist/python3-POMOR4OA-CKy80mpF.mjs.map +1 -0
  163. package/dist/readlink-OPJF4DL5-Rc1Mz_Xx.mjs +76 -0
  164. package/dist/readlink-OPJF4DL5-Rc1Mz_Xx.mjs.map +1 -0
  165. package/dist/rev-5EHFX4EJ-3dd9vwHW.mjs +66 -0
  166. package/dist/rev-5EHFX4EJ-3dd9vwHW.mjs.map +1 -0
  167. package/dist/rg-S4FXYXWB-BbXVo6JX.mjs +1539 -0
  168. package/dist/rg-S4FXYXWB-BbXVo6JX.mjs.map +1 -0
  169. package/dist/rm-SSGETQVQ-Ch53Rmrr.mjs +81 -0
  170. package/dist/rm-SSGETQVQ-Ch53Rmrr.mjs.map +1 -0
  171. package/dist/rmdir-OC4ZLPYA-D3QCHlIB.mjs +132 -0
  172. package/dist/rmdir-OC4ZLPYA-D3QCHlIB.mjs.map +1 -0
  173. package/dist/sed-S5UIK574-DE1KeTk3.mjs +1722 -0
  174. package/dist/sed-S5UIK574-DE1KeTk3.mjs.map +1 -0
  175. package/dist/seq-M5EC7Q57-BHfGjQvK.mjs +85 -0
  176. package/dist/seq-M5EC7Q57-BHfGjQvK.mjs.map +1 -0
  177. package/dist/sha1sum-2PTOAFR6-DNjSNcYK.mjs +16 -0
  178. package/dist/sha1sum-2PTOAFR6-DNjSNcYK.mjs.map +1 -0
  179. package/dist/sha256sum-NS7D3IXX-BMaCKkT5.mjs +16 -0
  180. package/dist/sha256sum-NS7D3IXX-BMaCKkT5.mjs.map +1 -0
  181. package/dist/sleep-X22JJINO-Do5hEQQW.mjs +67 -0
  182. package/dist/sleep-X22JJINO-Do5hEQQW.mjs.map +1 -0
  183. package/dist/sort-SW2YEO5B-B7j1zw8k.mjs +320 -0
  184. package/dist/sort-SW2YEO5B-B7j1zw8k.mjs.map +1 -0
  185. package/dist/split-4KKZZXXE-h8GD4HP4.mjs +248 -0
  186. package/dist/split-4KKZZXXE-h8GD4HP4.mjs.map +1 -0
  187. package/dist/sqlite3-CGOEFJAO-DvzzghDg.mjs +2879 -0
  188. package/dist/sqlite3-CGOEFJAO-DvzzghDg.mjs.map +1 -0
  189. package/dist/stat-CD34IZ4P-B5ZOJh4J.mjs +65 -0
  190. package/dist/stat-CD34IZ4P-B5ZOJh4J.mjs.map +1 -0
  191. package/dist/strings-6WDHLGMX-DdiEdoL-.mjs +179 -0
  192. package/dist/strings-6WDHLGMX-DdiEdoL-.mjs.map +1 -0
  193. package/dist/tac-2STMMJYW-DPyeWM9R.mjs +53 -0
  194. package/dist/tac-2STMMJYW-DPyeWM9R.mjs.map +1 -0
  195. package/dist/tail-R4PCA2C4-CUfroNeu.mjs +37 -0
  196. package/dist/tail-R4PCA2C4-CUfroNeu.mjs.map +1 -0
  197. package/dist/tar-STHHZTZ6-DRf60e-G.mjs +2838 -0
  198. package/dist/tar-STHHZTZ6-DRf60e-G.mjs.map +1 -0
  199. package/dist/tee-YUZ2FKCJ-po_dfyc_.mjs +46 -0
  200. package/dist/tee-YUZ2FKCJ-po_dfyc_.mjs.map +1 -0
  201. package/dist/time-D4LNBSWX-DVWhAldK.mjs +112 -0
  202. package/dist/time-D4LNBSWX-DVWhAldK.mjs.map +1 -0
  203. package/dist/timeout-YDCRSLPQ-B_yntmXU.mjs +113 -0
  204. package/dist/timeout-YDCRSLPQ-B_yntmXU.mjs.map +1 -0
  205. package/dist/touch-UA33VN3N-oW1SBT1r.mjs +104 -0
  206. package/dist/touch-UA33VN3N-oW1SBT1r.mjs.map +1 -0
  207. package/dist/tr-36LHWFRQ-CTq3z6wq.mjs +167 -0
  208. package/dist/tr-36LHWFRQ-CTq3z6wq.mjs.map +1 -0
  209. package/dist/tree-YLD52CNT-CIozNsLQ.mjs +186 -0
  210. package/dist/tree-YLD52CNT-CIozNsLQ.mjs.map +1 -0
  211. package/dist/true-FHQXJXBE-DsJOznSp.mjs +31 -0
  212. package/dist/true-FHQXJXBE-DsJOznSp.mjs.map +1 -0
  213. package/dist/unexpand-CADSA4VO-Cq9DTcUg.mjs +155 -0
  214. package/dist/unexpand-CADSA4VO-Cq9DTcUg.mjs.map +1 -0
  215. package/dist/uniq-XSIZR6PB-D5lt-IXF.mjs +92 -0
  216. package/dist/uniq-XSIZR6PB-D5lt-IXF.mjs.map +1 -0
  217. package/dist/{version-n-JpPeUF.mjs → version-Dxl3y5p6.mjs} +2 -2
  218. package/dist/{version-n-JpPeUF.mjs.map → version-Dxl3y5p6.mjs.map} +1 -1
  219. package/dist/wc-LF7NU4LA-BFPabrwD.mjs +111 -0
  220. package/dist/wc-LF7NU4LA-BFPabrwD.mjs.map +1 -0
  221. package/dist/which-XEM24D5D-2LvlkpUo.mjs +62 -0
  222. package/dist/which-XEM24D5D-2LvlkpUo.mjs.map +1 -0
  223. package/dist/whoami-XMTX52VE-24Kwqrk6.mjs +24 -0
  224. package/dist/whoami-XMTX52VE-24Kwqrk6.mjs.map +1 -0
  225. package/dist/xan-Y6WF3IRG-DjKO96Pj.mjs +2832 -0
  226. package/dist/xan-Y6WF3IRG-DjKO96Pj.mjs.map +1 -0
  227. package/dist/xan-view-HDVKHFC2-DhDNVE_V.mjs +12 -0
  228. package/dist/xan-view-HDVKHFC2-DhDNVE_V.mjs.map +1 -0
  229. package/dist/xargs-MGZPH7AX-D2bIgrdg.mjs +112 -0
  230. package/dist/xargs-MGZPH7AX-D2bIgrdg.mjs.map +1 -0
  231. package/dist/yq-4QJW3EQG-XhB3aACo.mjs +8610 -0
  232. package/dist/yq-4QJW3EQG-XhB3aACo.mjs.map +1 -0
  233. package/package.json +1 -1
  234. package/dist/dist-DWcRd4Se.mjs.map +0 -1
  235. package/dist/dist-DitNZUHA.mjs +0 -3
  236. package/dist/dist-vwoMCz6d.mjs +0 -775
  237. package/dist/dist-vwoMCz6d.mjs.map +0 -1
@@ -0,0 +1,3113 @@
1
+ #!/usr/bin/env node
2
+ import { n as r, t as c } from "./chunk-DLL7UR66-BUYgzxnR.mjs";
3
+ import { t as a } from "./chunk-L64BMZUV-CyR7RKok.mjs";
4
+ import { t as I1 } from "./chunk-4RUAZWKT-D60fyWAB.mjs";
5
+ import { t as b } from "./chunk-SAI2SPQQ-CVRoDNs9.mjs";
6
+ import { a as l, c as y, i as b$1, n as S$1, o as u, r as _, t as O } from "./chunk-4WKZNNJK-CiwxAWRf.mjs";
7
+ import { createRequire } from "node:module";
8
+ //#region ../../node_modules/.pnpm/just-bash@3.0.1/node_modules/just-bash/dist/bundle/chunks/chunk-LEKBROJD.js
9
+ createRequire(import.meta.url);
10
+ function W(t, r, e, n, p, o, u$1, c$1, s, f) {
11
+ switch (r) {
12
+ case "sort": return Array.isArray(t) ? [[...t].sort(u$1)] : [null];
13
+ case "sort_by": return !Array.isArray(t) || e.length === 0 ? [null] : [[...t].sort((h, a) => {
14
+ let y = p(h, e[0], n)[0], l = p(a, e[0], n)[0];
15
+ return u$1(y, l);
16
+ })];
17
+ case "bsearch":
18
+ if (!Array.isArray(t)) throw new Error(`${t === null ? "null" : typeof t == "object" ? "object" : typeof t} (${JSON.stringify(t)}) cannot be searched from`);
19
+ return e.length === 0 ? [null] : p(t, e[0], n).map((h) => {
20
+ let a = 0, y = t.length;
21
+ for (; a < y;) {
22
+ let l = a + y >>> 1;
23
+ u$1(t[l], h) < 0 ? a = l + 1 : y = l;
24
+ }
25
+ return a < t.length && u$1(t[a], h) === 0 ? a : -a - 1;
26
+ });
27
+ case "unique_by": {
28
+ if (!Array.isArray(t) || e.length === 0) return [null];
29
+ let i = /* @__PURE__ */ new Map();
30
+ for (let a of t) {
31
+ let y = p(a, e[0], n)[0], l = JSON.stringify(y);
32
+ i.has(l) || i.set(l, {
33
+ item: a,
34
+ key: y
35
+ });
36
+ }
37
+ let h = [...i.values()];
38
+ return h.sort((a, y) => u$1(a.key, y.key)), [h.map((a) => a.item)];
39
+ }
40
+ case "group_by": {
41
+ if (!Array.isArray(t) || e.length === 0) return [null];
42
+ let i = /* @__PURE__ */ new Map();
43
+ for (let h of t) {
44
+ let a = JSON.stringify(p(h, e[0], n)[0]);
45
+ i.has(a) || i.set(a, []), i.get(a)?.push(h);
46
+ }
47
+ return [[...i.values()]];
48
+ }
49
+ case "max": return Array.isArray(t) && t.length > 0 ? [t.reduce((i, h) => u$1(i, h) > 0 ? i : h)] : [null];
50
+ case "max_by": return !Array.isArray(t) || t.length === 0 || e.length === 0 ? [null] : [t.reduce((i, h) => {
51
+ let a = p(i, e[0], n)[0], y = p(h, e[0], n)[0];
52
+ return u$1(a, y) > 0 ? i : h;
53
+ })];
54
+ case "min": return Array.isArray(t) && t.length > 0 ? [t.reduce((i, h) => u$1(i, h) < 0 ? i : h)] : [null];
55
+ case "min_by": return !Array.isArray(t) || t.length === 0 || e.length === 0 ? [null] : [t.reduce((i, h) => {
56
+ let a = p(i, e[0], n)[0], y = p(h, e[0], n)[0];
57
+ return u$1(a, y) < 0 ? i : h;
58
+ })];
59
+ case "add": {
60
+ let i = (h) => {
61
+ let a = h.filter((y) => y !== null);
62
+ return a.length === 0 ? null : a.every((y) => typeof y == "number") ? a.reduce((y, l) => y + l, 0) : a.every((y) => typeof y == "string") ? a.join("") : a.every((y) => Array.isArray(y)) ? a.flat() : a.every((y) => y && typeof y == "object" && !Array.isArray(y)) ? c(...a) : null;
63
+ };
64
+ if (e.length >= 1) return [i(p(t, e[0], n))];
65
+ return Array.isArray(t) ? [i(t)] : [null];
66
+ }
67
+ case "any":
68
+ if (e.length >= 2) {
69
+ try {
70
+ let i = o(t, e[0], n);
71
+ for (let h of i) if (p(h, e[1], n).some(c$1)) return [!0];
72
+ } catch (i) {
73
+ if (i instanceof f) throw i;
74
+ }
75
+ return [!1];
76
+ }
77
+ return e.length === 1 ? Array.isArray(t) ? [t.some((i) => c$1(p(i, e[0], n)[0]))] : [!1] : Array.isArray(t) ? [t.some(c$1)] : [!1];
78
+ case "all":
79
+ if (e.length >= 2) {
80
+ try {
81
+ let i = o(t, e[0], n);
82
+ for (let h of i) if (!p(h, e[1], n).some(c$1)) return [!1];
83
+ } catch (i) {
84
+ if (i instanceof f) throw i;
85
+ }
86
+ return [!0];
87
+ }
88
+ return e.length === 1 ? Array.isArray(t) ? [t.every((i) => c$1(p(i, e[0], n)[0]))] : [!0] : Array.isArray(t) ? [t.every(c$1)] : [!0];
89
+ case "select": return e.length === 0 ? [t] : p(t, e[0], n).some(c$1) ? [t] : [];
90
+ case "map": return e.length === 0 || !Array.isArray(t) ? [null] : [t.flatMap((h) => p(h, e[0], n))];
91
+ case "map_values":
92
+ if (e.length === 0) return [null];
93
+ if (Array.isArray(t)) return [t.flatMap((i) => p(i, e[0], n))];
94
+ if (t && typeof t == "object") {
95
+ let i = Object.create(null);
96
+ for (let [h, a] of Object.entries(t)) {
97
+ if (!u(h)) continue;
98
+ let y = p(a, e[0], n);
99
+ y.length > 0 && l(i, h, y[0]);
100
+ }
101
+ return [i];
102
+ }
103
+ return [null];
104
+ case "has": {
105
+ if (e.length === 0) return [!1];
106
+ let h = p(t, e[0], n)[0];
107
+ return Array.isArray(t) && typeof h == "number" ? [h >= 0 && h < t.length] : t && typeof t == "object" && typeof h == "string" ? [y(t, h)] : [!1];
108
+ }
109
+ case "in": {
110
+ if (e.length === 0) return [!1];
111
+ let h = p(t, e[0], n)[0];
112
+ return Array.isArray(h) && typeof t == "number" ? [t >= 0 && t < h.length] : h && typeof h == "object" && typeof t == "string" ? [y(h, t)] : [!1];
113
+ }
114
+ case "contains":
115
+ if (e.length === 0) return [!1];
116
+ return [s(t, p(t, e[0], n)[0])];
117
+ case "inside":
118
+ if (e.length === 0) return [!1];
119
+ return [s(p(t, e[0], n)[0], t)];
120
+ default: return null;
121
+ }
122
+ }
123
+ function z(t, r, e, n, p, o, u, c) {
124
+ switch (r) {
125
+ case "first":
126
+ if (e.length > 0) try {
127
+ let s = o(t, e[0], n);
128
+ return s.length > 0 ? [s[0]] : [];
129
+ } catch (s) {
130
+ if (s instanceof c) throw s;
131
+ return [];
132
+ }
133
+ return Array.isArray(t) && t.length > 0 ? [t[0]] : [null];
134
+ case "last":
135
+ if (e.length > 0) {
136
+ let s = p(t, e[0], n);
137
+ return s.length > 0 ? [s[s.length - 1]] : [];
138
+ }
139
+ return Array.isArray(t) && t.length > 0 ? [t[t.length - 1]] : [null];
140
+ case "nth": {
141
+ if (e.length < 1) return [null];
142
+ let s = p(t, e[0], n);
143
+ if (e.length > 1) {
144
+ for (let i of s) if (i < 0) throw new Error("nth doesn't support negative indices");
145
+ let f;
146
+ try {
147
+ f = o(t, e[1], n);
148
+ } catch (i) {
149
+ if (i instanceof c) throw i;
150
+ f = [];
151
+ }
152
+ return s.flatMap((i) => {
153
+ let h = i;
154
+ return h < f.length ? [f[h]] : [];
155
+ });
156
+ }
157
+ return Array.isArray(t) ? s.flatMap((f) => {
158
+ let i = f;
159
+ if (i < 0) throw new Error("nth doesn't support negative indices");
160
+ return i < t.length ? [t[i]] : [null];
161
+ }) : [null];
162
+ }
163
+ case "range": {
164
+ if (e.length === 0) return [];
165
+ let s = Math.max(n.limits.maxIterations * 100, 1e6), f = (l) => l.length >= s, i = p(t, e[0], n);
166
+ if (e.length === 1) {
167
+ let l = [];
168
+ for (let m of i) {
169
+ let b = m;
170
+ for (let w = 0; w < b; w++) if (l.push(w), f(l)) return l;
171
+ }
172
+ return l;
173
+ }
174
+ let h = p(t, e[1], n);
175
+ if (e.length === 2) {
176
+ let l = [];
177
+ for (let m of i) for (let b of h) {
178
+ let w = m, k = b;
179
+ for (let N = w; N < k; N++) if (l.push(N), f(l)) return l;
180
+ }
181
+ return l;
182
+ }
183
+ let a = p(t, e[2], n), y = [];
184
+ for (let l of i) for (let m of h) for (let b of a) {
185
+ let w = l, k = m, N = b;
186
+ if (N !== 0) {
187
+ if (N > 0) {
188
+ for (let C = w; C < k; C += N) if (y.push(C), f(y)) return y;
189
+ } else for (let C = w; C > k; C += N) if (y.push(C), f(y)) return y;
190
+ }
191
+ }
192
+ return y;
193
+ }
194
+ case "limit": return e.length < 2 ? [] : p(t, e[0], n).flatMap((f) => {
195
+ let i = f;
196
+ if (i < 0) throw new Error("limit doesn't support negative count");
197
+ if (i === 0) return [];
198
+ let h;
199
+ try {
200
+ h = o(t, e[1], n);
201
+ } catch (a) {
202
+ if (a instanceof c) throw a;
203
+ h = [];
204
+ }
205
+ return h.slice(0, i);
206
+ });
207
+ case "isempty":
208
+ if (e.length < 1) return [!0];
209
+ try {
210
+ return [o(t, e[0], n).length === 0];
211
+ } catch (s) {
212
+ if (s instanceof c) throw s;
213
+ return [!0];
214
+ }
215
+ case "isvalid":
216
+ if (e.length < 1) return [!0];
217
+ try {
218
+ return [p(t, e[0], n).length > 0];
219
+ } catch (s) {
220
+ if (s instanceof c) throw s;
221
+ return [!1];
222
+ }
223
+ case "skip": return e.length < 2 ? [] : p(t, e[0], n).flatMap((f) => {
224
+ let i = f;
225
+ if (i < 0) throw new Error("skip doesn't support negative count");
226
+ return p(t, e[1], n).slice(i);
227
+ });
228
+ case "until": {
229
+ if (e.length < 2) return [t];
230
+ let s = t, f = n.limits.maxIterations;
231
+ for (let i = 0; i < f; i++) {
232
+ if (p(s, e[0], n).some(u)) return [s];
233
+ let a = p(s, e[1], n);
234
+ if (a.length === 0) return [s];
235
+ s = a[0];
236
+ }
237
+ throw new c(`jq until: too many iterations (${f}), increase executionLimits.maxJqIterations`, "iterations");
238
+ }
239
+ case "while": {
240
+ if (e.length < 2) return [t];
241
+ let s = [], f = t, i = n.limits.maxIterations;
242
+ for (let h = 0; h < i && p(f, e[0], n).some(u); h++) {
243
+ s.push(f);
244
+ let y = p(f, e[1], n);
245
+ if (y.length === 0) break;
246
+ f = y[0];
247
+ }
248
+ if (s.length >= i) throw new c(`jq while: too many iterations (${i}), increase executionLimits.maxJqIterations`, "iterations");
249
+ return s;
250
+ }
251
+ case "repeat": {
252
+ if (e.length === 0) return [t];
253
+ let s = [], f = t, i = n.limits.maxIterations;
254
+ for (let h = 0; h < i; h++) {
255
+ s.push(f);
256
+ let a = p(f, e[0], n);
257
+ if (a.length === 0) break;
258
+ f = a[0];
259
+ }
260
+ if (s.length >= i) throw new c(`jq repeat: too many iterations (${i}), increase executionLimits.maxJqIterations`, "iterations");
261
+ return s;
262
+ }
263
+ default: return null;
264
+ }
265
+ }
266
+ function Z(t, r, e, n, p) {
267
+ switch (r) {
268
+ case "now": return [Date.now() / 1e3];
269
+ case "gmtime": {
270
+ if (typeof t != "number") return [null];
271
+ let o = /* @__PURE__ */ new Date(t * 1e3), u = o.getUTCFullYear(), c = o.getUTCMonth(), s = o.getUTCDate(), f = o.getUTCHours(), i = o.getUTCMinutes(), h = o.getUTCSeconds(), a = o.getUTCDay(), y = Date.UTC(u, 0, 1);
272
+ return [[
273
+ u,
274
+ c,
275
+ s,
276
+ f,
277
+ i,
278
+ h,
279
+ a,
280
+ Math.floor((o.getTime() - y) / (1440 * 60 * 1e3))
281
+ ]];
282
+ }
283
+ case "mktime": {
284
+ if (!Array.isArray(t)) throw new Error("mktime requires parsed datetime inputs");
285
+ let [o, u, c, s = 0, f = 0, i = 0] = t;
286
+ if (typeof o != "number" || typeof u != "number") throw new Error("mktime requires parsed datetime inputs");
287
+ return [Math.floor(Date.UTC(o, u, c ?? 1, s ?? 0, f ?? 0, i ?? 0) / 1e3)];
288
+ }
289
+ case "strftime": {
290
+ if (e.length === 0) return [null];
291
+ let u = p(t, e[0], n)[0];
292
+ if (typeof u != "string") throw new Error("strftime/1 requires a string format");
293
+ let c;
294
+ if (typeof t == "number") c = /* @__PURE__ */ new Date(t * 1e3);
295
+ else if (Array.isArray(t)) {
296
+ let [a, y, l, m = 0, b = 0, w = 0] = t;
297
+ if (typeof a != "number" || typeof y != "number") throw new Error("strftime/1 requires parsed datetime inputs");
298
+ c = new Date(Date.UTC(a, y, l ?? 1, m ?? 0, b ?? 0, w ?? 0));
299
+ } else throw new Error("strftime/1 requires parsed datetime inputs");
300
+ let s = [
301
+ "Sunday",
302
+ "Monday",
303
+ "Tuesday",
304
+ "Wednesday",
305
+ "Thursday",
306
+ "Friday",
307
+ "Saturday"
308
+ ], f = [
309
+ "January",
310
+ "February",
311
+ "March",
312
+ "April",
313
+ "May",
314
+ "June",
315
+ "July",
316
+ "August",
317
+ "September",
318
+ "October",
319
+ "November",
320
+ "December"
321
+ ], i = (a, y = 2) => String(a).padStart(y, "0");
322
+ return [u.replace(/%Y/g, String(c.getUTCFullYear())).replace(/%m/g, i(c.getUTCMonth() + 1)).replace(/%d/g, i(c.getUTCDate())).replace(/%H/g, i(c.getUTCHours())).replace(/%M/g, i(c.getUTCMinutes())).replace(/%S/g, i(c.getUTCSeconds())).replace(/%A/g, s[c.getUTCDay()]).replace(/%B/g, f[c.getUTCMonth()]).replace(/%Z/g, "UTC").replace(/%%/g, "%")];
323
+ }
324
+ case "strptime": {
325
+ if (e.length === 0) return [null];
326
+ if (typeof t != "string") throw new Error("strptime/1 requires a string input");
327
+ let u = p(t, e[0], n)[0];
328
+ if (typeof u != "string") throw new Error("strptime/1 requires a string format");
329
+ if (u === "%Y-%m-%dT%H:%M:%SZ") {
330
+ let s = t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);
331
+ if (s) {
332
+ let [, f, i, h, a, y, l] = s.map(Number), m = new Date(Date.UTC(f, i - 1, h, a, y, l)), b = m.getUTCDay(), w = Date.UTC(f, 0, 1), k = Math.floor((m.getTime() - w) / (1440 * 60 * 1e3));
333
+ return [[
334
+ f,
335
+ i - 1,
336
+ h,
337
+ a,
338
+ y,
339
+ l,
340
+ b,
341
+ k
342
+ ]];
343
+ }
344
+ }
345
+ let c = new Date(t);
346
+ if (!Number.isNaN(c.getTime())) {
347
+ let s = c.getUTCFullYear(), f = c.getUTCMonth(), i = c.getUTCDate(), h = c.getUTCHours(), a = c.getUTCMinutes(), y = c.getUTCSeconds(), l = c.getUTCDay(), m = Date.UTC(s, 0, 1);
348
+ return [[
349
+ s,
350
+ f,
351
+ i,
352
+ h,
353
+ a,
354
+ y,
355
+ l,
356
+ Math.floor((c.getTime() - m) / (1440 * 60 * 1e3))
357
+ ]];
358
+ }
359
+ throw new Error(`Cannot parse date: ${t}`);
360
+ }
361
+ case "fromdate": {
362
+ if (typeof t != "string") throw new Error("fromdate requires a string input");
363
+ let o = new Date(t);
364
+ if (Number.isNaN(o.getTime())) throw new Error(`date "${t}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);
365
+ return [Math.floor(o.getTime() / 1e3)];
366
+ }
367
+ case "todate":
368
+ if (typeof t != "number") throw new Error("todate requires a number input");
369
+ return [(/* @__PURE__ */ new Date(t * 1e3)).toISOString().replace(/\.\d{3}Z$/, "Z")];
370
+ default: return null;
371
+ }
372
+ }
373
+ function S(t) {
374
+ return t !== !1 && t !== null;
375
+ }
376
+ function I(t, r) {
377
+ return JSON.stringify(t) === JSON.stringify(r);
378
+ }
379
+ function U(t, r) {
380
+ return typeof t == "number" && typeof r == "number" ? t - r : typeof t == "string" && typeof r == "string" ? t.localeCompare(r) : 0;
381
+ }
382
+ function v(t, r) {
383
+ let e = S$1(t);
384
+ for (let n of Object.keys(r)) {
385
+ if (!u(n)) continue;
386
+ let p = y(e, n) ? _(e[n]) : null, o = _(r[n]);
387
+ p && o ? l(e, n, v(p, o)) : l(e, n, r[n]);
388
+ }
389
+ return e;
390
+ }
391
+ function D(t, r = 3e3) {
392
+ let e = 0, n = t;
393
+ for (; e < r;) if (Array.isArray(n)) {
394
+ if (n.length === 0) return e + 1;
395
+ n = n[0], e++;
396
+ } else if (n !== null && typeof n == "object") {
397
+ let p = Object.keys(n);
398
+ if (p.length === 0) return e + 1;
399
+ n = n[p[0]], e++;
400
+ } else return e;
401
+ return e;
402
+ }
403
+ function $(t, r) {
404
+ let e = (c) => c === null ? 0 : typeof c == "boolean" ? 1 : typeof c == "number" ? 2 : typeof c == "string" ? 3 : Array.isArray(c) ? 4 : typeof c == "object" ? 5 : 6, n = e(t), p = e(r);
405
+ if (n !== p) return n - p;
406
+ if (typeof t == "number" && typeof r == "number") return t - r;
407
+ if (typeof t == "string" && typeof r == "string") return t.localeCompare(r);
408
+ if (typeof t == "boolean" && typeof r == "boolean") return (t ? 1 : 0) - (r ? 1 : 0);
409
+ if (Array.isArray(t) && Array.isArray(r)) {
410
+ for (let c = 0; c < Math.min(t.length, r.length); c++) {
411
+ let s = $(t[c], r[c]);
412
+ if (s !== 0) return s;
413
+ }
414
+ return t.length - r.length;
415
+ }
416
+ let o = _(t), u = _(r);
417
+ if (o && u) {
418
+ let c = Object.keys(o).sort(), s = Object.keys(u).sort();
419
+ for (let f = 0; f < Math.min(c.length, s.length); f++) {
420
+ let i = c[f].localeCompare(s[f]);
421
+ if (i !== 0) return i;
422
+ }
423
+ if (c.length !== s.length) return c.length - s.length;
424
+ for (let f of c) {
425
+ let i = $(o[f], u[f]);
426
+ if (i !== 0) return i;
427
+ }
428
+ }
429
+ return 0;
430
+ }
431
+ function F(t, r) {
432
+ if (I(t, r)) return !0;
433
+ if (typeof t == "string" && typeof r == "string") return t.includes(r);
434
+ if (Array.isArray(t) && Array.isArray(r)) return r.every((p) => t.some((o) => F(o, p)));
435
+ let e = _(t), n = _(r);
436
+ return e && n ? Object.keys(n).every((p) => y(e, p) && F(e[p], n[p])) : !1;
437
+ }
438
+ var Ot = 2e3;
439
+ function tt(t, r, e) {
440
+ switch (r) {
441
+ case "@base64": return typeof t == "string" ? typeof Buffer < "u" ? [Buffer.from(t, "utf-8").toString("base64")] : [btoa(t)] : [null];
442
+ case "@base64d": return typeof t == "string" ? typeof Buffer < "u" ? [Buffer.from(t, "base64").toString("utf-8")] : [atob(t)] : [null];
443
+ case "@uri": return typeof t == "string" ? [encodeURIComponent(t).replace(/!/g, "%21").replace(/'/g, "%27").replace(/\(/g, "%28").replace(/\)/g, "%29").replace(/\*/g, "%2A")] : [null];
444
+ case "@urid": return typeof t == "string" ? [decodeURIComponent(t)] : [null];
445
+ case "@csv": return Array.isArray(t) ? [t.map((p) => {
446
+ if (p === null) return "";
447
+ if (typeof p == "boolean") return p ? "true" : "false";
448
+ if (typeof p == "number") return String(p);
449
+ let o = String(p);
450
+ return o.includes(",") || o.includes("\"") || o.includes(`
451
+ `) || o.includes("\r") ? `"${o.replace(/"/g, "\"\"")}"` : o;
452
+ }).join(",")] : [null];
453
+ case "@tsv": return Array.isArray(t) ? [t.map((n) => String(n ?? "").replace(/\t/g, "\\t").replace(/\n/g, "\\n")).join(" ")] : [null];
454
+ case "@json": {
455
+ let n = e ?? Ot;
456
+ return D(t, n + 1) > n ? [null] : [JSON.stringify(t)];
457
+ }
458
+ case "@html": return typeof t == "string" ? [t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&apos;").replace(/"/g, "&quot;")] : [null];
459
+ case "@sh": return typeof t == "string" ? [`'${t.replace(/'/g, "'\\''")}'`] : [null];
460
+ case "@text": return typeof t == "string" ? [t] : t == null ? [""] : [String(t)];
461
+ default: return null;
462
+ }
463
+ }
464
+ function et(t, r, e, n, p, o) {
465
+ switch (r) {
466
+ case "index": return e.length === 0 ? [null] : p(t, e[0], n).map((c) => {
467
+ if (typeof t == "string" && typeof c == "string") {
468
+ if (c === "" && t === "") return null;
469
+ let s = t.indexOf(c);
470
+ return s >= 0 ? s : null;
471
+ }
472
+ if (Array.isArray(t)) {
473
+ if (Array.isArray(c)) {
474
+ for (let f = 0; f <= t.length - c.length; f++) {
475
+ let i = !0;
476
+ for (let h = 0; h < c.length; h++) if (!o(t[f + h], c[h])) {
477
+ i = !1;
478
+ break;
479
+ }
480
+ if (i) return f;
481
+ }
482
+ return null;
483
+ }
484
+ let s = t.findIndex((f) => o(f, c));
485
+ return s >= 0 ? s : null;
486
+ }
487
+ return null;
488
+ });
489
+ case "rindex": return e.length === 0 ? [null] : p(t, e[0], n).map((c) => {
490
+ if (typeof t == "string" && typeof c == "string") {
491
+ let s = t.lastIndexOf(c);
492
+ return s >= 0 ? s : null;
493
+ }
494
+ if (Array.isArray(t)) {
495
+ if (Array.isArray(c)) {
496
+ for (let s = t.length - c.length; s >= 0; s--) {
497
+ let f = !0;
498
+ for (let i = 0; i < c.length; i++) if (!o(t[s + i], c[i])) {
499
+ f = !1;
500
+ break;
501
+ }
502
+ if (f) return s;
503
+ }
504
+ return null;
505
+ }
506
+ for (let s = t.length - 1; s >= 0; s--) if (o(t[s], c)) return s;
507
+ return null;
508
+ }
509
+ return null;
510
+ });
511
+ case "indices": return e.length === 0 ? [[]] : p(t, e[0], n).map((c) => {
512
+ let s = [];
513
+ if (typeof t == "string" && typeof c == "string") {
514
+ let f = t.indexOf(c);
515
+ for (; f !== -1;) s.push(f), f = t.indexOf(c, f + 1);
516
+ } else if (Array.isArray(t)) if (Array.isArray(c)) {
517
+ let f = c.length;
518
+ if (f === 0) for (let i = 0; i <= t.length; i++) s.push(i);
519
+ else for (let i = 0; i <= t.length - f; i++) {
520
+ let h = !0;
521
+ for (let a = 0; a < f; a++) if (!o(t[i + a], c[a])) {
522
+ h = !1;
523
+ break;
524
+ }
525
+ h && s.push(i);
526
+ }
527
+ } else for (let f = 0; f < t.length; f++) o(t[f], c) && s.push(f);
528
+ return s;
529
+ });
530
+ default: return null;
531
+ }
532
+ }
533
+ function rt(t, r, e, n, p) {
534
+ switch (r) {
535
+ case "fabs":
536
+ case "abs": return typeof t == "number" ? [Math.abs(t)] : typeof t == "string" ? [t] : [null];
537
+ case "exp10": return typeof t == "number" ? [10 ** t] : [null];
538
+ case "exp2": return typeof t == "number" ? [2 ** t] : [null];
539
+ case "pow": {
540
+ if (e.length < 2) return [null];
541
+ let o = p(t, e[0], n), u = p(t, e[1], n), c = o[0], s = u[0];
542
+ return typeof c != "number" || typeof s != "number" ? [null] : [c ** s];
543
+ }
544
+ case "atan2": {
545
+ if (e.length < 2) return [null];
546
+ let o = p(t, e[0], n), u = p(t, e[1], n), c = o[0], s = u[0];
547
+ return typeof c != "number" || typeof s != "number" ? [null] : [Math.atan2(c, s)];
548
+ }
549
+ case "hypot": {
550
+ if (typeof t != "number" || e.length === 0) return [null];
551
+ let o = p(t, e[0], n)[0];
552
+ return [Math.hypot(t, o)];
553
+ }
554
+ case "fma": {
555
+ if (typeof t != "number" || e.length < 2) return [null];
556
+ let o = p(t, e[0], n)[0], u = p(t, e[1], n)[0];
557
+ return [t * o + u];
558
+ }
559
+ case "copysign": {
560
+ if (typeof t != "number" || e.length === 0) return [null];
561
+ let o = p(t, e[0], n)[0];
562
+ return [Math.sign(o) * Math.abs(t)];
563
+ }
564
+ case "drem":
565
+ case "remainder": {
566
+ if (typeof t != "number" || e.length === 0) return [null];
567
+ let o = p(t, e[0], n)[0];
568
+ return [t - Math.round(t / o) * o];
569
+ }
570
+ case "fdim": {
571
+ if (typeof t != "number" || e.length === 0) return [null];
572
+ let o = p(t, e[0], n)[0];
573
+ return [Math.max(0, t - o)];
574
+ }
575
+ case "fmax": {
576
+ if (typeof t != "number" || e.length === 0) return [null];
577
+ let o = p(t, e[0], n)[0];
578
+ return [Math.max(t, o)];
579
+ }
580
+ case "fmin": {
581
+ if (typeof t != "number" || e.length === 0) return [null];
582
+ let o = p(t, e[0], n)[0];
583
+ return [Math.min(t, o)];
584
+ }
585
+ case "ldexp":
586
+ if (typeof t != "number" || e.length === 0) return [null];
587
+ return [t * 2 ** p(t, e[0], n)[0]];
588
+ case "scalbn":
589
+ case "scalbln":
590
+ if (typeof t != "number" || e.length === 0) return [null];
591
+ return [t * 2 ** p(t, e[0], n)[0]];
592
+ case "nearbyint": return typeof t == "number" ? [Math.round(t)] : [null];
593
+ case "logb": return typeof t == "number" ? [Math.floor(Math.log2(Math.abs(t)))] : [null];
594
+ case "significand":
595
+ if (typeof t == "number") return [t / 2 ** Math.floor(Math.log2(Math.abs(t)))];
596
+ return [null];
597
+ case "frexp":
598
+ if (typeof t == "number") {
599
+ if (t === 0) return [[0, 0]];
600
+ let o = Math.floor(Math.log2(Math.abs(t))) + 1;
601
+ return [[t / 2 ** o, o]];
602
+ }
603
+ return [null];
604
+ case "modf":
605
+ if (typeof t == "number") {
606
+ let o = Math.trunc(t);
607
+ return [[t - o, o]];
608
+ }
609
+ return [null];
610
+ default: return null;
611
+ }
612
+ }
613
+ function nt(t, r, e, n, p, o, u$2, c) {
614
+ switch (r) {
615
+ case "recurse": {
616
+ if (e.length === 0) {
617
+ let y = [], l = (m) => {
618
+ if (y.push(m), Array.isArray(m)) for (let b of m) l(b);
619
+ else if (m && typeof m == "object") for (let b of Object.keys(m)) l(m[b]);
620
+ };
621
+ return l(t), y;
622
+ }
623
+ let s = [], f = e.length >= 2 ? e[1] : null, i = 1e4, h = 0, a = (y) => {
624
+ if (h++ > i || f && !p(y, f, n).some(o)) return;
625
+ s.push(y);
626
+ let l = p(y, e[0], n);
627
+ for (let m of l) m != null && a(m);
628
+ };
629
+ return a(t), s;
630
+ }
631
+ case "recurse_down": return c(t, "recurse", e, n);
632
+ case "walk": {
633
+ if (e.length === 0) return [t];
634
+ let s = /* @__PURE__ */ new WeakSet(), f = (i) => {
635
+ if (i && typeof i == "object") {
636
+ if (s.has(i)) return i;
637
+ s.add(i);
638
+ }
639
+ let h;
640
+ if (Array.isArray(i)) h = i.map(f);
641
+ else if (i && typeof i == "object") {
642
+ let y = Object.create(null);
643
+ for (let [l$1, m] of Object.entries(i)) u(l$1) && l(y, l$1, f(m));
644
+ h = y;
645
+ } else h = i;
646
+ return p(h, e[0], n)[0];
647
+ };
648
+ return [f(t)];
649
+ }
650
+ case "transpose": {
651
+ if (!Array.isArray(t)) return [null];
652
+ if (t.length === 0) return [[]];
653
+ let s = Math.max(...t.map((i) => Array.isArray(i) ? i.length : 0)), f = [];
654
+ for (let i = 0; i < s; i++) f.push(t.map((h) => Array.isArray(h) ? h[i] : null));
655
+ return [f];
656
+ }
657
+ case "combinations": {
658
+ if (e.length > 0) {
659
+ let h = p(t, e[0], n)[0];
660
+ if (!Array.isArray(t) || h < 0) return [];
661
+ if (h === 0) return [[]];
662
+ let a = [], y = (l, m) => {
663
+ if (m === h) {
664
+ a.push([...l]);
665
+ return;
666
+ }
667
+ for (let b of t) l.push(b), y(l, m + 1), l.pop();
668
+ };
669
+ return y([], 0), a;
670
+ }
671
+ if (!Array.isArray(t)) return [];
672
+ if (t.length === 0) return [[]];
673
+ for (let i of t) if (!Array.isArray(i)) return [];
674
+ let s = [], f = (i, h) => {
675
+ if (i === t.length) {
676
+ s.push([...h]);
677
+ return;
678
+ }
679
+ let a = t[i];
680
+ for (let y of a) h.push(y), f(i + 1, h), h.pop();
681
+ };
682
+ return f(0, []), s;
683
+ }
684
+ case "parent": {
685
+ if (n.root === void 0 || n.currentPath === void 0) return [];
686
+ let s = n.currentPath;
687
+ if (s.length === 0) return [];
688
+ let f = e.length > 0 ? p(t, e[0], n)[0] : 1;
689
+ if (f >= 0) {
690
+ if (f > s.length) return [];
691
+ let i = s.slice(0, s.length - f);
692
+ return [u$2(n.root, i)];
693
+ } else {
694
+ let i = -f - 1;
695
+ if (i >= s.length) return [t];
696
+ let h = s.slice(0, i);
697
+ return [u$2(n.root, h)];
698
+ }
699
+ }
700
+ case "parents": {
701
+ if (n.root === void 0 || n.currentPath === void 0) return [[]];
702
+ let s = n.currentPath, f = [];
703
+ for (let i = s.length - 1; i >= 0; i--) f.push(u$2(n.root, s.slice(0, i)));
704
+ return [f];
705
+ }
706
+ case "root": return n.root !== void 0 ? [n.root] : [];
707
+ default: return null;
708
+ }
709
+ }
710
+ var Nt = 2e3;
711
+ function st(t, r, e, n, p) {
712
+ switch (r) {
713
+ case "keys": return Array.isArray(t) ? [t.map((o, u) => u)] : t && typeof t == "object" ? [Object.keys(t).sort()] : [null];
714
+ case "keys_unsorted": return Array.isArray(t) ? [t.map((o, u) => u)] : t && typeof t == "object" ? [Object.keys(t)] : [null];
715
+ 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];
716
+ case "utf8bytelength": {
717
+ if (typeof t == "string") return [new TextEncoder().encode(t).length];
718
+ let o = t === null ? "null" : Array.isArray(t) ? "array" : typeof t, u = o === "array" || o === "object" ? JSON.stringify(t) : String(t);
719
+ throw new Error(`${o} (${u}) only strings have UTF-8 byte length`);
720
+ }
721
+ case "to_entries": {
722
+ let o = _(t);
723
+ return o ? [Object.entries(o).map(([u, c]) => ({
724
+ key: u,
725
+ value: c
726
+ }))] : [null];
727
+ }
728
+ case "from_entries":
729
+ if (Array.isArray(t)) {
730
+ let o = Object.create(null);
731
+ for (let u$3 of t) {
732
+ let c = _(u$3);
733
+ if (c) {
734
+ let s = c.key ?? c.Key ?? c.name ?? c.Name ?? c.k, f = c.value ?? c.Value ?? c.v;
735
+ if (s !== void 0) {
736
+ let i = String(s);
737
+ u(i) && l(o, i, f);
738
+ }
739
+ }
740
+ }
741
+ return [o];
742
+ }
743
+ return [null];
744
+ case "with_entries": {
745
+ if (e.length === 0) return [t];
746
+ let o = _(t);
747
+ if (o) {
748
+ let c = Object.entries(o).map(([f, i]) => ({
749
+ key: f,
750
+ value: i
751
+ })).flatMap((f) => p(f, e[0], n)), s = Object.create(null);
752
+ for (let f of c) {
753
+ let i = _(f);
754
+ if (i) {
755
+ let h = i.key ?? i.name ?? i.k, a = i.value ?? i.v;
756
+ if (h !== void 0) {
757
+ let y = String(h);
758
+ u(y) && l(s, y, a);
759
+ }
760
+ }
761
+ }
762
+ return [s];
763
+ }
764
+ return [null];
765
+ }
766
+ case "reverse": return Array.isArray(t) ? [[...t].reverse()] : typeof t == "string" ? [t.split("").reverse().join("")] : [null];
767
+ case "flatten": return Array.isArray(t) ? (e.length > 0 ? p(t, e[0], n) : [Number.POSITIVE_INFINITY]).map((u) => {
768
+ let c = u;
769
+ if (c < 0) throw new Error("flatten depth must not be negative");
770
+ return t.flat(c);
771
+ }) : [null];
772
+ case "unique":
773
+ if (Array.isArray(t)) {
774
+ let o = /* @__PURE__ */ new Set(), u = [];
775
+ for (let c of t) {
776
+ let s = JSON.stringify(c);
777
+ o.has(s) || (o.add(s), u.push(c));
778
+ }
779
+ return [u];
780
+ }
781
+ return [null];
782
+ case "tojson":
783
+ case "tojsonstream": {
784
+ let o = n.limits.maxDepth ?? Nt;
785
+ return D(t, o + 1) > o ? [null] : [JSON.stringify(t)];
786
+ }
787
+ case "fromjson":
788
+ if (typeof t == "string") {
789
+ let o = t.trim().toLowerCase();
790
+ if (o === "nan") return [NaN];
791
+ if (o === "inf" || o === "infinity") return [Number.POSITIVE_INFINITY];
792
+ if (o === "-inf" || o === "-infinity") return [Number.NEGATIVE_INFINITY];
793
+ try {
794
+ return [O(JSON.parse(t))];
795
+ } catch {
796
+ throw new Error(`Invalid JSON: ${t}`);
797
+ }
798
+ }
799
+ return [t];
800
+ case "tostring": return typeof t == "string" ? [t] : [JSON.stringify(t)];
801
+ case "tonumber":
802
+ if (typeof t == "number") return [t];
803
+ if (typeof t == "string") {
804
+ let o = Number(t);
805
+ if (Number.isNaN(o)) throw new Error(`${JSON.stringify(t)} cannot be parsed as a number`);
806
+ return [o];
807
+ }
808
+ throw new Error(`${typeof t} cannot be parsed as a number`);
809
+ case "toboolean": {
810
+ if (typeof t == "boolean") return [t];
811
+ if (typeof t == "string") {
812
+ if (t === "true") return [!0];
813
+ if (t === "false") return [!1];
814
+ throw new Error(`string (${JSON.stringify(t)}) cannot be parsed as a boolean`);
815
+ }
816
+ let o = t === null ? "null" : Array.isArray(t) ? "array" : typeof t, u = o === "array" || o === "object" ? JSON.stringify(t) : String(t);
817
+ throw new Error(`${o} (${u}) cannot be parsed as a boolean`);
818
+ }
819
+ case "tostream": {
820
+ let o = [], u = (c, s) => {
821
+ if (c === null || typeof c != "object") o.push([s, c]);
822
+ else if (Array.isArray(c)) if (c.length === 0) o.push([s, []]);
823
+ else for (let f = 0; f < c.length; f++) u(c[f], [...s, f]);
824
+ else {
825
+ let f = Object.keys(c);
826
+ if (f.length === 0) o.push([s, Object.create(null)]);
827
+ else for (let i of f) u(c[i], [...s, i]);
828
+ }
829
+ };
830
+ return u(t, []), o.push([[]]), o;
831
+ }
832
+ case "fromstream": {
833
+ if (e.length === 0) return [t];
834
+ let o = p(t, e[0], n), u$4 = null;
835
+ for (let c of o) {
836
+ if (!Array.isArray(c) || c.length === 1 && Array.isArray(c[0]) && c[0].length === 0 || c.length !== 2) continue;
837
+ let [s, f] = c;
838
+ if (!Array.isArray(s)) continue;
839
+ if (s.length === 0) {
840
+ u$4 = f;
841
+ continue;
842
+ }
843
+ u$4 === null && (u$4 = typeof s[0] == "number" ? [] : Object.create(null));
844
+ let i = u$4;
845
+ for (let a = 0; a < s.length - 1; a++) {
846
+ let y = s[a], l$2 = s[a + 1];
847
+ if (Array.isArray(i) && typeof y == "number") {
848
+ for (; i.length <= y;) i.push(null);
849
+ i[y] === null && (i[y] = typeof l$2 == "number" ? [] : Object.create(null)), i = i[y];
850
+ } else {
851
+ let m = _(i);
852
+ if (m) {
853
+ let b = String(y);
854
+ if (!u(b)) continue;
855
+ (m[b] === null || m[b] === void 0) && l(m, b, typeof l$2 == "number" ? [] : Object.create(null)), i = m[b];
856
+ }
857
+ }
858
+ }
859
+ let h = s[s.length - 1];
860
+ if (Array.isArray(i) && typeof h == "number") {
861
+ for (; i.length <= h;) i.push(null);
862
+ i[h] = f;
863
+ } else {
864
+ let a = _(i);
865
+ if (a) {
866
+ let y = String(h);
867
+ u(y) && l(a, y, f);
868
+ }
869
+ }
870
+ }
871
+ return [u$4];
872
+ }
873
+ case "truncate_stream": {
874
+ let o = typeof t == "number" ? Math.floor(t) : 0;
875
+ if (e.length === 0) return [];
876
+ let u = [], c = p(t, e[0], n);
877
+ for (let s of c) if (Array.isArray(s)) {
878
+ if (s.length === 1 && Array.isArray(s[0])) {
879
+ let f = s[0];
880
+ f.length > o && u.push([f.slice(o)]);
881
+ continue;
882
+ }
883
+ if (s.length === 2 && Array.isArray(s[0])) {
884
+ let f = s[0], i = s[1];
885
+ f.length > o && u.push([f.slice(o), i]);
886
+ }
887
+ }
888
+ return u;
889
+ }
890
+ default: return null;
891
+ }
892
+ }
893
+ function it(t, r, e, n, p, o, u, c, s, f) {
894
+ switch (r) {
895
+ case "getpath": {
896
+ if (e.length === 0) return [null];
897
+ let i = p(t, e[0], n), h = [];
898
+ for (let a of i) {
899
+ let y = a, l = t;
900
+ for (let m of y) {
901
+ if (l == null) {
902
+ l = null;
903
+ break;
904
+ }
905
+ if (Array.isArray(l) && typeof m == "number") l = l[m];
906
+ else if (typeof m == "string") {
907
+ let b = _(l);
908
+ if (!b || !Object.hasOwn(b, m)) {
909
+ l = null;
910
+ break;
911
+ }
912
+ l = b[m];
913
+ } else {
914
+ l = null;
915
+ break;
916
+ }
917
+ }
918
+ h.push(l);
919
+ }
920
+ return h;
921
+ }
922
+ case "setpath": {
923
+ if (e.length < 2) return [null];
924
+ let h = p(t, e[0], n)[0], y = p(t, e[1], n)[0];
925
+ return [u(t, h, y)];
926
+ }
927
+ case "delpaths": {
928
+ if (e.length === 0) return [t];
929
+ let h = p(t, e[0], n)[0], a = t;
930
+ for (let y of h.sort((l, m) => m.length - l.length)) a = c(a, y);
931
+ return [a];
932
+ }
933
+ case "path": {
934
+ if (e.length === 0) return [[]];
935
+ let i = [];
936
+ return f(t, e[0], n, [], i), i;
937
+ }
938
+ case "del": return e.length === 0 ? [t] : [s(t, e[0], n)];
939
+ case "pick": {
940
+ if (e.length === 0) return [null];
941
+ let i = [];
942
+ for (let a of e) f(t, a, n, [], i);
943
+ let h = null;
944
+ for (let a of i) {
945
+ for (let l of a) if (typeof l == "number" && l < 0) throw new Error("Out of bounds negative array index");
946
+ let y = t;
947
+ for (let l of a) {
948
+ if (y == null) break;
949
+ if (Array.isArray(y) && typeof l == "number") y = y[l];
950
+ else if (typeof l == "string") {
951
+ let m = _(y);
952
+ if (!m || !Object.hasOwn(m, l)) {
953
+ y = null;
954
+ break;
955
+ }
956
+ y = m[l];
957
+ } else {
958
+ y = null;
959
+ break;
960
+ }
961
+ }
962
+ h = u(h, a, y);
963
+ }
964
+ return [h];
965
+ }
966
+ case "paths": {
967
+ let i = [], h = (a, y) => {
968
+ if (a && typeof a == "object") if (Array.isArray(a)) for (let l = 0; l < a.length; l++) i.push([...y, l]), h(a[l], [...y, l]);
969
+ else for (let l of Object.keys(a)) i.push([...y, l]), h(a[l], [...y, l]);
970
+ };
971
+ return h(t, []), e.length > 0 ? i.filter((a) => {
972
+ let y = t;
973
+ for (let m of a) if (Array.isArray(y) && typeof m == "number") y = y[m];
974
+ else if (typeof m == "string") {
975
+ let b = _(y);
976
+ if (!b || !Object.hasOwn(b, m)) return !1;
977
+ y = b[m];
978
+ } else return !1;
979
+ return p(y, e[0], n).some(o);
980
+ }) : i;
981
+ }
982
+ case "leaf_paths": {
983
+ let i = [], h = (a, y) => {
984
+ if (a === null || typeof a != "object") i.push(y);
985
+ else if (Array.isArray(a)) for (let l = 0; l < a.length; l++) h(a[l], [...y, l]);
986
+ else for (let l of Object.keys(a)) h(a[l], [...y, l]);
987
+ };
988
+ return h(t, []), i;
989
+ }
990
+ default: return null;
991
+ }
992
+ }
993
+ function ot(t, r, e, n, p, o) {
994
+ switch (r) {
995
+ case "IN": {
996
+ if (e.length === 0) return [!1];
997
+ if (e.length === 1) {
998
+ let f = p(t, e[0], n);
999
+ for (let i of f) if (o(t, i)) return [!0];
1000
+ return [!1];
1001
+ }
1002
+ let u = p(t, e[0], n), c = p(t, e[1], n), s = new Set(c.map((f) => JSON.stringify(f)));
1003
+ for (let f of u) if (s.has(JSON.stringify(f))) return [!0];
1004
+ return [!1];
1005
+ }
1006
+ case "INDEX": {
1007
+ if (e.length === 0) return [Object.create(null)];
1008
+ if (e.length === 1) {
1009
+ let s = p(t, e[0], n), f = Object.create(null);
1010
+ for (let i of s) {
1011
+ let h = String(i);
1012
+ u(h) && l(f, h, i);
1013
+ }
1014
+ return [f];
1015
+ }
1016
+ if (e.length === 2) {
1017
+ let s = p(t, e[0], n), f = Object.create(null);
1018
+ for (let i of s) {
1019
+ let h = p(i, e[1], n);
1020
+ if (h.length > 0) {
1021
+ let a = String(h[0]);
1022
+ u(a) && l(f, a, i);
1023
+ }
1024
+ }
1025
+ return [f];
1026
+ }
1027
+ let u$5 = p(t, e[0], n), c = Object.create(null);
1028
+ for (let s of u$5) {
1029
+ let f = p(s, e[1], n), i = p(s, e[2], n);
1030
+ if (f.length > 0 && i.length > 0) {
1031
+ let h = String(f[0]);
1032
+ u(h) && l(c, h, i[0]);
1033
+ }
1034
+ }
1035
+ return [c];
1036
+ }
1037
+ case "JOIN": {
1038
+ if (e.length < 2) return [null];
1039
+ let u = _(p(t, e[0], n)[0]);
1040
+ if (!u) return [null];
1041
+ if (!Array.isArray(t)) return [null];
1042
+ let c = [];
1043
+ for (let s of t) {
1044
+ let f = p(s, e[1], n), i = f.length > 0 ? String(f[0]) : "", h = y(u, i) ? u[i] : null;
1045
+ c.push([s, h]);
1046
+ }
1047
+ return [c];
1048
+ }
1049
+ default: return null;
1050
+ }
1051
+ }
1052
+ function ft(t, r, e, n, p) {
1053
+ switch (r) {
1054
+ case "join": {
1055
+ if (!Array.isArray(t)) return [null];
1056
+ let o = e.length > 0 ? p(t, e[0], n) : [""];
1057
+ for (let u of t) if (Array.isArray(u) || u !== null && typeof u == "object") throw new Error("cannot join: contains arrays or objects");
1058
+ return o.map((u) => t.map((c) => c === null ? "" : typeof c == "string" ? c : String(c)).join(String(u)));
1059
+ }
1060
+ case "split": {
1061
+ if (typeof t != "string" || e.length === 0) return [null];
1062
+ let o = p(t, e[0], n), u = String(o[0]);
1063
+ return [t.split(u)];
1064
+ }
1065
+ case "splits": {
1066
+ if (typeof t != "string" || e.length === 0) return [];
1067
+ let o = p(t, e[0], n), u = String(o[0]);
1068
+ try {
1069
+ let c = e.length > 1 ? String(p(t, e[1], n)[0]) : "g";
1070
+ return I1(u, c.includes("g") ? c : `${c}g`).split(t);
1071
+ } catch {
1072
+ return [];
1073
+ }
1074
+ }
1075
+ case "scan": {
1076
+ if (typeof t != "string" || e.length === 0) return [];
1077
+ let o = p(t, e[0], n), u = String(o[0]);
1078
+ try {
1079
+ let c = e.length > 1 ? String(p(t, e[1], n)[0]) : "";
1080
+ return [...I1(u, c.includes("g") ? c : `${c}g`).matchAll(t)].map((i) => i.length > 1 ? i.slice(1) : i[0]);
1081
+ } catch {
1082
+ return [];
1083
+ }
1084
+ }
1085
+ case "test": {
1086
+ if (typeof t != "string" || e.length === 0) return [!1];
1087
+ let o = p(t, e[0], n), u = String(o[0]);
1088
+ try {
1089
+ return [I1(u, e.length > 1 ? String(p(t, e[1], n)[0]) : "").test(t)];
1090
+ } catch {
1091
+ return [!1];
1092
+ }
1093
+ }
1094
+ case "match": {
1095
+ if (typeof t != "string" || e.length === 0) return [null];
1096
+ let o = p(t, e[0], n), u = String(o[0]);
1097
+ try {
1098
+ let f = I1(u, `${e.length > 1 ? String(p(t, e[1], n)[0]) : ""}d`).exec(t);
1099
+ if (!f) return [];
1100
+ let i = f.indices;
1101
+ return [{
1102
+ offset: f.index,
1103
+ length: f[0].length,
1104
+ string: f[0],
1105
+ captures: f.slice(1).map((h, a) => ({
1106
+ offset: i?.[a + 1]?.[0] ?? null,
1107
+ length: h?.length ?? 0,
1108
+ string: h ?? "",
1109
+ name: null
1110
+ }))
1111
+ }];
1112
+ } catch {
1113
+ return [null];
1114
+ }
1115
+ }
1116
+ case "capture": {
1117
+ if (typeof t != "string" || e.length === 0) return [null];
1118
+ let o = p(t, e[0], n), u = String(o[0]);
1119
+ try {
1120
+ let f = I1(u, e.length > 1 ? String(p(t, e[1], n)[0]) : "").match(t);
1121
+ return !f || !f.groups ? [Object.create(null)] : [f.groups];
1122
+ } catch {
1123
+ return [null];
1124
+ }
1125
+ }
1126
+ case "sub": {
1127
+ if (typeof t != "string" || e.length < 2) return [null];
1128
+ let o = p(t, e[0], n), u = p(t, e[1], n), c = String(o[0]), s = String(u[0]);
1129
+ try {
1130
+ return [I1(c, e.length > 2 ? String(p(t, e[2], n)[0]) : "").replace(t, s)];
1131
+ } catch {
1132
+ return [t];
1133
+ }
1134
+ }
1135
+ case "gsub": {
1136
+ if (typeof t != "string" || e.length < 2) return [null];
1137
+ let o = p(t, e[0], n), u = p(t, e[1], n), c = String(o[0]), s = String(u[0]);
1138
+ try {
1139
+ let f = e.length > 2 ? String(p(t, e[2], n)[0]) : "g";
1140
+ return [I1(c, f.includes("g") ? f : `${f}g`).replace(t, s)];
1141
+ } catch {
1142
+ return [t];
1143
+ }
1144
+ }
1145
+ case "ascii_downcase": return typeof t == "string" ? [t.replace(/[A-Z]/g, (o) => String.fromCharCode(o.charCodeAt(0) + 32))] : [null];
1146
+ case "ascii_upcase": return typeof t == "string" ? [t.replace(/[a-z]/g, (o) => String.fromCharCode(o.charCodeAt(0) - 32))] : [null];
1147
+ case "ltrimstr": {
1148
+ if (typeof t != "string" || e.length === 0) return [t];
1149
+ let o = p(t, e[0], n), u = String(o[0]);
1150
+ return [t.startsWith(u) ? t.slice(u.length) : t];
1151
+ }
1152
+ case "rtrimstr": {
1153
+ if (typeof t != "string" || e.length === 0) return [t];
1154
+ let o = p(t, e[0], n), u = String(o[0]);
1155
+ return u === "" ? [t] : [t.endsWith(u) ? t.slice(0, -u.length) : t];
1156
+ }
1157
+ case "trimstr": {
1158
+ if (typeof t != "string" || e.length === 0) return [t];
1159
+ let o = p(t, e[0], n), u = String(o[0]);
1160
+ if (u === "") return [t];
1161
+ let c = t;
1162
+ return c.startsWith(u) && (c = c.slice(u.length)), c.endsWith(u) && (c = c.slice(0, -u.length)), [c];
1163
+ }
1164
+ case "trim":
1165
+ if (typeof t == "string") return [t.trim()];
1166
+ throw new Error("trim input must be a string");
1167
+ case "ltrim":
1168
+ if (typeof t == "string") return [t.trimStart()];
1169
+ throw new Error("trim input must be a string");
1170
+ case "rtrim":
1171
+ if (typeof t == "string") return [t.trimEnd()];
1172
+ throw new Error("trim input must be a string");
1173
+ case "startswith": {
1174
+ if (typeof t != "string" || e.length === 0) return [!1];
1175
+ let o = p(t, e[0], n);
1176
+ return [t.startsWith(String(o[0]))];
1177
+ }
1178
+ case "endswith": {
1179
+ if (typeof t != "string" || e.length === 0) return [!1];
1180
+ let o = p(t, e[0], n);
1181
+ return [t.endsWith(String(o[0]))];
1182
+ }
1183
+ case "ascii": return typeof t == "string" && t.length > 0 ? [t.charCodeAt(0)] : [null];
1184
+ case "explode": return typeof t == "string" ? [Array.from(t).map((o) => o.codePointAt(0))] : [null];
1185
+ case "implode":
1186
+ if (!Array.isArray(t)) throw new Error("implode input must be an array");
1187
+ return [t.map((c) => {
1188
+ if (typeof c == "string") throw new Error(`string (${JSON.stringify(c)}) can't be imploded, unicode codepoint needs to be numeric`);
1189
+ if (typeof c != "number" || Number.isNaN(c)) throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");
1190
+ let s = Math.trunc(c);
1191
+ return s < 0 || s > 1114111 || s >= 55296 && s <= 57343 ? String.fromCodePoint(65533) : String.fromCodePoint(s);
1192
+ }).join("")];
1193
+ default: return null;
1194
+ }
1195
+ }
1196
+ function ct(t, r) {
1197
+ switch (r) {
1198
+ 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"];
1199
+ case "infinite": return [Number.POSITIVE_INFINITY];
1200
+ case "nan": return [NaN];
1201
+ case "isinfinite": return [typeof t == "number" && !Number.isFinite(t)];
1202
+ case "isnan": return [typeof t == "number" && Number.isNaN(t)];
1203
+ case "isnormal": return [typeof t == "number" && Number.isFinite(t) && t !== 0];
1204
+ case "isfinite": return [typeof t == "number" && Number.isFinite(t)];
1205
+ case "numbers": return typeof t == "number" ? [t] : [];
1206
+ case "strings": return typeof t == "string" ? [t] : [];
1207
+ case "booleans": return typeof t == "boolean" ? [t] : [];
1208
+ case "nulls": return t === null ? [t] : [];
1209
+ case "arrays": return Array.isArray(t) ? [t] : [];
1210
+ case "objects": return t && typeof t == "object" && !Array.isArray(t) ? [t] : [];
1211
+ case "iterables": return Array.isArray(t) || t && typeof t == "object" && !Array.isArray(t) ? [t] : [];
1212
+ case "scalars": return !Array.isArray(t) && !(t && typeof t == "object") ? [t] : [];
1213
+ case "values": return t === null ? [] : [t];
1214
+ case "not": return t === !1 || t === null ? [!0] : [!1];
1215
+ case "null": return [null];
1216
+ case "true": return [!0];
1217
+ case "false": return [!1];
1218
+ case "empty": return [];
1219
+ default: return null;
1220
+ }
1221
+ }
1222
+ function K(t, r, e) {
1223
+ if (r.length === 0) return e;
1224
+ let [n, ...p] = r;
1225
+ if (typeof n == "number") {
1226
+ if (t && typeof t == "object" && !Array.isArray(t)) throw new Error("Cannot index object with number");
1227
+ if (n > 536870911) throw new Error("Array index too large");
1228
+ if (n < 0) throw new Error("Out of bounds negative array index");
1229
+ let f = Array.isArray(t) ? [...t] : [];
1230
+ for (; f.length <= n;) f.push(null);
1231
+ return f[n] = K(f[n], p, e), f;
1232
+ }
1233
+ if (Array.isArray(t)) throw new Error("Cannot index array with string");
1234
+ if (!u(n)) return t ?? Object.create(null);
1235
+ let o = _(t), u$6 = o ? S$1(o) : Object.create(null);
1236
+ return l(u$6, n, K(Object.hasOwn(u$6, n) ? u$6[n] : void 0, p, e)), u$6;
1237
+ }
1238
+ function V(t, r) {
1239
+ if (r.length === 0) return null;
1240
+ if (r.length === 1) {
1241
+ let p = r[0];
1242
+ if (Array.isArray(t) && typeof p == "number") {
1243
+ let o = [...t];
1244
+ return o.splice(p, 1), o;
1245
+ }
1246
+ if (t && typeof t == "object" && !Array.isArray(t)) {
1247
+ let o = String(p);
1248
+ if (!u(o)) return t;
1249
+ let u$7 = S$1(t);
1250
+ return delete u$7[o], u$7;
1251
+ }
1252
+ return t;
1253
+ }
1254
+ let [e, ...n] = r;
1255
+ if (Array.isArray(t) && typeof e == "number") {
1256
+ let p = [...t];
1257
+ return p[e] = V(p[e], n), p;
1258
+ }
1259
+ if (t && typeof t == "object" && !Array.isArray(t)) {
1260
+ let p = String(e);
1261
+ if (!u(p)) return t;
1262
+ let o = S$1(t);
1263
+ return Object.hasOwn(o, p) && l(o, p, V(o[p], n)), o;
1264
+ }
1265
+ return t;
1266
+ }
1267
+ var P = class t extends Error {
1268
+ label;
1269
+ partialResults;
1270
+ constructor(r, e = []) {
1271
+ super(`break ${r}`), this.label = r, this.partialResults = e, this.name = "BreakError";
1272
+ }
1273
+ withPrependedResults(r) {
1274
+ return new t(this.label, [...r, ...this.partialResults]);
1275
+ }
1276
+ }, H = class extends Error {
1277
+ value;
1278
+ constructor(r) {
1279
+ super(typeof r == "string" ? r : JSON.stringify(r)), this.value = r, this.name = "JqError";
1280
+ }
1281
+ }, St = 1e4, bt = 2e3, Ct = new Map([
1282
+ ["floor", Math.floor],
1283
+ ["ceil", Math.ceil],
1284
+ ["round", Math.round],
1285
+ ["sqrt", Math.sqrt],
1286
+ ["log", Math.log],
1287
+ ["log10", Math.log10],
1288
+ ["log2", Math.log2],
1289
+ ["exp", Math.exp],
1290
+ ["sin", Math.sin],
1291
+ ["cos", Math.cos],
1292
+ ["tan", Math.tan],
1293
+ ["asin", Math.asin],
1294
+ ["acos", Math.acos],
1295
+ ["atan", Math.atan],
1296
+ ["sinh", Math.sinh],
1297
+ ["cosh", Math.cosh],
1298
+ ["tanh", Math.tanh],
1299
+ ["asinh", Math.asinh],
1300
+ ["acosh", Math.acosh],
1301
+ ["atanh", Math.atanh],
1302
+ ["cbrt", Math.cbrt],
1303
+ ["expm1", Math.expm1],
1304
+ ["log1p", Math.log1p],
1305
+ ["trunc", Math.trunc]
1306
+ ]);
1307
+ function Tt(t) {
1308
+ return {
1309
+ vars: /* @__PURE__ */ new Map(),
1310
+ limits: {
1311
+ maxIterations: t?.limits?.maxIterations ?? St,
1312
+ maxDepth: t?.limits?.maxDepth ?? bt
1313
+ },
1314
+ env: t?.env,
1315
+ coverage: t?.coverage,
1316
+ requireDefenseContext: t?.requireDefenseContext,
1317
+ defenseContextChecked: !1
1318
+ };
1319
+ }
1320
+ function q(t, r, e) {
1321
+ let n = new Map(t.vars);
1322
+ return n.set(r, e), {
1323
+ vars: n,
1324
+ limits: t.limits,
1325
+ env: t.env,
1326
+ requireDefenseContext: t.requireDefenseContext,
1327
+ defenseContextChecked: t.defenseContextChecked,
1328
+ root: t.root,
1329
+ currentPath: t.currentPath,
1330
+ funcs: t.funcs,
1331
+ labels: t.labels,
1332
+ coverage: t.coverage
1333
+ };
1334
+ }
1335
+ function L(t, r, e) {
1336
+ switch (r.type) {
1337
+ case "var": return q(t, r.name, e);
1338
+ case "array": {
1339
+ if (!Array.isArray(e)) return null;
1340
+ let n = t;
1341
+ for (let p = 0; p < r.elements.length; p++) {
1342
+ let o = r.elements[p], u = p < e.length ? e[p] : null, c = L(n, o, u);
1343
+ if (c === null) return null;
1344
+ n = c;
1345
+ }
1346
+ return n;
1347
+ }
1348
+ case "object": {
1349
+ let n = _(e);
1350
+ if (!n) return null;
1351
+ let p = t;
1352
+ for (let o of r.fields) {
1353
+ let u;
1354
+ if (typeof o.key == "string") u = o.key;
1355
+ else {
1356
+ let f = d(e, o.key, t);
1357
+ if (f.length === 0) return null;
1358
+ u = String(f[0]);
1359
+ }
1360
+ let c = y(n, u) ? n[u] : null;
1361
+ o.keyVar && (p = q(p, o.keyVar, c));
1362
+ let s = L(p, o.pattern, c);
1363
+ if (s === null) return null;
1364
+ p = s;
1365
+ }
1366
+ return p;
1367
+ }
1368
+ }
1369
+ }
1370
+ function Rt(t, r) {
1371
+ let e = t;
1372
+ for (let n of r) if (e && typeof e == "object") if (Array.isArray(e)) if (typeof n == "number") e = e[n];
1373
+ else return;
1374
+ else {
1375
+ let p = _(e);
1376
+ if (p && typeof n == "string" && Object.hasOwn(p, n)) e = p[n];
1377
+ else return;
1378
+ }
1379
+ else return;
1380
+ return e;
1381
+ }
1382
+ function M(t) {
1383
+ if (t.type === "Identity") return [];
1384
+ if (t.type === "Field") {
1385
+ let r = t.base ? M(t.base) : [];
1386
+ return r === null ? null : [...r, t.name];
1387
+ }
1388
+ if (t.type === "Index" && t.index.type === "Literal") {
1389
+ let r = t.base ? M(t.base) : [];
1390
+ if (r === null) return null;
1391
+ let e = t.index.value;
1392
+ return typeof e == "number" || typeof e == "string" ? [...r, e] : null;
1393
+ }
1394
+ if (t.type === "Pipe") {
1395
+ let r = M(t.left);
1396
+ return r === null ? null : pt(r, t.right);
1397
+ }
1398
+ if (t.type === "Call") {
1399
+ if (t.name === "parent" || t.name === "root") return null;
1400
+ if (t.name === "first" && t.args.length === 0) return [0];
1401
+ if (t.name === "last" && t.args.length === 0) return [-1];
1402
+ }
1403
+ return null;
1404
+ }
1405
+ function pt(t, r) {
1406
+ if (r.type === "Call") {
1407
+ if (r.name === "parent") {
1408
+ let e = 1;
1409
+ if (r.args.length > 0 && r.args[0].type === "Literal") {
1410
+ let n = r.args[0].value;
1411
+ typeof n == "number" && (e = n);
1412
+ }
1413
+ if (e >= 0) return t.slice(0, Math.max(0, t.length - e));
1414
+ {
1415
+ let n = -e - 1;
1416
+ return t.slice(0, Math.min(n, t.length));
1417
+ }
1418
+ }
1419
+ if (r.name === "root") return [];
1420
+ }
1421
+ if (r.type === "Field") {
1422
+ let e = M(r);
1423
+ if (e !== null) return [...t, ...e];
1424
+ }
1425
+ if (r.type === "Index" && r.index.type === "Literal") {
1426
+ let e = M(r);
1427
+ if (e !== null) return [...t, ...e];
1428
+ }
1429
+ if (r.type === "Pipe") {
1430
+ let e = pt(t, r.left);
1431
+ return e === null ? null : pt(e, r.right);
1432
+ }
1433
+ return r.type === "Identity" ? t : null;
1434
+ }
1435
+ function mt(t, r, e) {
1436
+ if (r.type === "Comma") {
1437
+ let n = [];
1438
+ try {
1439
+ n.push(...d(t, r.left, e));
1440
+ } catch (p) {
1441
+ if (p instanceof b) throw p;
1442
+ if (n.length > 0) return n;
1443
+ throw new Error("evaluation failed");
1444
+ }
1445
+ try {
1446
+ n.push(...d(t, r.right, e));
1447
+ } catch (p) {
1448
+ if (p instanceof b) throw p;
1449
+ return n;
1450
+ }
1451
+ return n;
1452
+ }
1453
+ return d(t, r, e);
1454
+ }
1455
+ function d(t, r$1, e) {
1456
+ let n = e && "vars" in e ? e : Tt(e);
1457
+ switch (n.defenseContextChecked || (a(n.requireDefenseContext, "query-engine", "evaluation"), n = {
1458
+ ...n,
1459
+ defenseContextChecked: !0
1460
+ }), n.root === void 0 && (n = {
1461
+ ...n,
1462
+ root: t,
1463
+ currentPath: []
1464
+ }), n.coverage?.hit(`jq:node:${r$1.type}`), r$1.type) {
1465
+ case "Identity": return [t];
1466
+ case "Field": return (r$1.base ? d(t, r$1.base, n) : [t]).flatMap((o) => {
1467
+ let u = _(o);
1468
+ if (u) {
1469
+ if (!Object.hasOwn(u, r$1.name)) return [null];
1470
+ let s = u[r$1.name];
1471
+ return [s === void 0 ? null : s];
1472
+ }
1473
+ if (o === null) return [null];
1474
+ throw new Error(`Cannot index ${Array.isArray(o) ? "array" : typeof o} with string "${r$1.name}"`);
1475
+ });
1476
+ case "Index": return (r$1.base ? d(t, r$1.base, n) : [t]).flatMap((o) => d(o, r$1.index, n).flatMap((c) => {
1477
+ if (typeof c == "number" && Array.isArray(o)) {
1478
+ if (Number.isNaN(c)) return [null];
1479
+ let s = Math.trunc(c), f = s < 0 ? o.length + s : s;
1480
+ return f >= 0 && f < o.length ? [o[f]] : [null];
1481
+ }
1482
+ if (typeof c == "string") {
1483
+ let s = _(o);
1484
+ return !s || !Object.hasOwn(s, c) ? [null] : [s[c]];
1485
+ }
1486
+ return [null];
1487
+ }));
1488
+ case "Slice": return (r$1.base ? d(t, r$1.base, n) : [t]).flatMap((o) => {
1489
+ if (o === null) return [null];
1490
+ if (!Array.isArray(o) && typeof o != "string") throw new Error(`Cannot slice ${typeof o} (${JSON.stringify(o)})`);
1491
+ let u = o.length, c = r$1.start ? d(t, r$1.start, n) : [0], s = r$1.end ? d(t, r$1.end, n) : [u];
1492
+ return c.flatMap((f) => s.map((i) => {
1493
+ let h = f, a = i, y = Number.isNaN(h) ? 0 : Number.isInteger(h) ? h : Math.floor(h), l = Number.isNaN(a) ? u : Number.isInteger(a) ? a : Math.ceil(a), m = dt(y, u), b = dt(l, u);
1494
+ return o.slice(m, b);
1495
+ }));
1496
+ });
1497
+ case "Iterate": return (r$1.base ? d(t, r$1.base, n) : [t]).flatMap((o) => Array.isArray(o) ? o : o && typeof o == "object" ? Object.values(o) : []);
1498
+ case "Pipe": {
1499
+ let p = d(t, r$1.left, n), o = M(r$1.left), u = [];
1500
+ for (let c of p) try {
1501
+ if (o !== null) {
1502
+ let s = {
1503
+ ...n,
1504
+ currentPath: [...n.currentPath ?? [], ...o]
1505
+ };
1506
+ u.push(...d(c, r$1.right, s));
1507
+ } else u.push(...d(c, r$1.right, n));
1508
+ } catch (s) {
1509
+ throw s instanceof P ? s.withPrependedResults(u) : s;
1510
+ }
1511
+ return u;
1512
+ }
1513
+ case "Comma": {
1514
+ let p = d(t, r$1.left, n), o = d(t, r$1.right, n);
1515
+ return [...p, ...o];
1516
+ }
1517
+ case "Literal": return [r$1.value];
1518
+ case "Array": return r$1.elements ? [d(t, r$1.elements, n)] : [[]];
1519
+ case "Object": {
1520
+ let p = [Object.create(null)];
1521
+ for (let o of r$1.entries) {
1522
+ let u$8 = typeof o.key == "string" ? [o.key] : d(t, o.key, n), c = d(t, o.value, n), s = [];
1523
+ for (let f of p) for (let i of u$8) {
1524
+ if (typeof i != "string") throw new Error(`Cannot use ${i === null ? "null" : Array.isArray(i) ? "array" : typeof i} (${JSON.stringify(i)}) as object key`);
1525
+ if (!u(i)) {
1526
+ for (let h of c) s.push(S$1(f));
1527
+ continue;
1528
+ }
1529
+ for (let h of c) {
1530
+ let a = S$1(f);
1531
+ l(a, i, h), s.push(a);
1532
+ }
1533
+ }
1534
+ p.length = 0, p.push(...s);
1535
+ }
1536
+ return p;
1537
+ }
1538
+ case "Paren": return d(t, r$1.expr, n);
1539
+ case "BinaryOp": return xt(t, r$1.op, r$1.left, r$1.right, n);
1540
+ case "UnaryOp": return d(t, r$1.operand, n).map((o) => {
1541
+ if (r$1.op === "-") {
1542
+ if (typeof o == "number") return -o;
1543
+ if (typeof o == "string") {
1544
+ let u = (c) => c.length > 5 ? `"${c.slice(0, 3)}...` : JSON.stringify(c);
1545
+ throw new Error(`string (${u(o)}) cannot be negated`);
1546
+ }
1547
+ return null;
1548
+ }
1549
+ return r$1.op === "not" ? !S(o) : null;
1550
+ });
1551
+ case "Cond": return d(t, r$1.cond, n).flatMap((o) => {
1552
+ if (S(o)) return d(t, r$1.then, n);
1553
+ for (let u of r$1.elifs) if (d(t, u.cond, n).some(S)) return d(t, u.then, n);
1554
+ return r$1.else ? d(t, r$1.else, n) : [t];
1555
+ });
1556
+ case "Try": try {
1557
+ return d(t, r$1.body, n);
1558
+ } catch (p) {
1559
+ if (r$1.catch) return d(p instanceof H ? p.value : p instanceof Error ? p.message : String(p), r$1.catch, n);
1560
+ return [];
1561
+ }
1562
+ case "Call": return gt(t, r$1.name, r$1.args, n);
1563
+ case "VarBind": return d(t, r$1.value, n).flatMap((o) => {
1564
+ let u = null, c = [];
1565
+ r$1.pattern ? c.push(r$1.pattern) : r$1.name && c.push({
1566
+ type: "var",
1567
+ name: r$1.name
1568
+ }), r$1.alternatives && c.push(...r$1.alternatives);
1569
+ for (let s of c) if (u = L(n, s, o), u !== null) break;
1570
+ return u === null ? [] : d(t, r$1.body, u);
1571
+ });
1572
+ case "VarRef": {
1573
+ if (r$1.name === "$ENV") return [n.env ? r(n.env) : Object.create(null)];
1574
+ let p = n.vars.get(r$1.name);
1575
+ return p !== void 0 ? [p] : [null];
1576
+ }
1577
+ case "Recurse": {
1578
+ let p = [], o = /* @__PURE__ */ new WeakSet(), u = (c) => {
1579
+ if (c && typeof c == "object") {
1580
+ if (o.has(c)) return;
1581
+ o.add(c);
1582
+ }
1583
+ if (p.push(c), Array.isArray(c)) for (let s of c) u(s);
1584
+ else if (c && typeof c == "object") for (let s of Object.keys(c)) u(c[s]);
1585
+ };
1586
+ return u(t), p;
1587
+ }
1588
+ case "Optional": try {
1589
+ return d(t, r$1.expr, n);
1590
+ } catch {
1591
+ return [];
1592
+ }
1593
+ case "StringInterp": return [r$1.parts.map((o) => typeof o == "string" ? o : d(t, o, n).map((c) => typeof c == "string" ? c : JSON.stringify(c)).join("")).join("")];
1594
+ case "UpdateOp": return [Mt(t, r$1.path, r$1.op, r$1.value, n)];
1595
+ case "Reduce": {
1596
+ let p = d(t, r$1.expr, n), o = d(t, r$1.init, n)[0], u = n.limits.maxDepth ?? bt;
1597
+ for (let c of p) {
1598
+ let s;
1599
+ if (r$1.pattern) {
1600
+ if (s = L(n, r$1.pattern, c), s === null) continue;
1601
+ } else s = q(n, r$1.varName, c);
1602
+ if (o = d(o, r$1.update, s)[0], D(o, u + 1) > u) return [null];
1603
+ }
1604
+ return [o];
1605
+ }
1606
+ case "Foreach": {
1607
+ let p = d(t, r$1.expr, n), o = d(t, r$1.init, n)[0], u = [];
1608
+ for (let c of p) try {
1609
+ let s;
1610
+ if (r$1.pattern) {
1611
+ if (s = L(n, r$1.pattern, c), s === null) continue;
1612
+ } else s = q(n, r$1.varName, c);
1613
+ if (o = d(o, r$1.update, s)[0], r$1.extract) {
1614
+ let f = d(o, r$1.extract, s);
1615
+ u.push(...f);
1616
+ } else u.push(o);
1617
+ } catch (s) {
1618
+ throw s instanceof P ? s.withPrependedResults(u) : s;
1619
+ }
1620
+ return u;
1621
+ }
1622
+ case "Label": try {
1623
+ return d(t, r$1.body, {
1624
+ ...n,
1625
+ labels: new Set([...n.labels ?? [], r$1.name])
1626
+ });
1627
+ } catch (p) {
1628
+ if (p instanceof P && p.label === r$1.name) return p.partialResults;
1629
+ throw p;
1630
+ }
1631
+ case "Break": throw new P(r$1.name);
1632
+ case "Def": {
1633
+ let p = new Map(n.funcs ?? []), o = `${r$1.name}/${r$1.params.length}`;
1634
+ p.set(o, {
1635
+ params: r$1.params,
1636
+ body: r$1.funcBody,
1637
+ closure: new Map(n.funcs ?? [])
1638
+ });
1639
+ let u = {
1640
+ ...n,
1641
+ funcs: p
1642
+ };
1643
+ return d(t, r$1.body, u);
1644
+ }
1645
+ default: throw new Error(`Unknown AST node type: ${r$1.type}`);
1646
+ }
1647
+ }
1648
+ function dt(t, r) {
1649
+ return t < 0 ? Math.max(0, r + t) : Math.min(t, r);
1650
+ }
1651
+ function Mt(t, r, e, n, p) {
1652
+ function o(s, f) {
1653
+ switch (e) {
1654
+ case "=": return f;
1655
+ case "|=": return d(s, n, p)[0] ?? null;
1656
+ 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" ? b$1(s, f) : f;
1657
+ case "-=": return typeof s == "number" && typeof f == "number" ? s - f : s;
1658
+ case "*=": return typeof s == "number" && typeof f == "number" ? s * f : s;
1659
+ case "/=": return typeof s == "number" && typeof f == "number" ? s / f : s;
1660
+ case "%=": return typeof s == "number" && typeof f == "number" ? s % f : s;
1661
+ case "//=": return s === null || s === !1 ? f : s;
1662
+ default: return f;
1663
+ }
1664
+ }
1665
+ function u$9(s, f, i) {
1666
+ switch (f.type) {
1667
+ case "Identity": return i(s);
1668
+ case "Field":
1669
+ if (!u(f.name)) return s;
1670
+ if (f.base) return u$9(s, f.base, (h) => {
1671
+ if (h && typeof h == "object" && !Array.isArray(h)) {
1672
+ let a = S$1(h), y = Object.hasOwn(a, f.name) ? a[f.name] : void 0;
1673
+ return l(a, f.name, i(y)), a;
1674
+ }
1675
+ return h;
1676
+ });
1677
+ if (s && typeof s == "object" && !Array.isArray(s)) {
1678
+ let h = S$1(s), a = Object.hasOwn(h, f.name) ? h[f.name] : void 0;
1679
+ return l(h, f.name, i(a)), h;
1680
+ }
1681
+ return s;
1682
+ case "Index": {
1683
+ let a = d(t, f.index, p)[0];
1684
+ if (typeof a == "number" && Number.isNaN(a)) throw new Error("Cannot set array element at NaN index");
1685
+ if (typeof a == "number" && !Number.isInteger(a) && (a = Math.trunc(a)), f.base) return u$9(s, f.base, (y) => {
1686
+ if (typeof a == "number" && Array.isArray(y)) {
1687
+ let l = [...y], m = a < 0 ? l.length + a : a;
1688
+ if (m >= 0) {
1689
+ for (; l.length <= m;) l.push(null);
1690
+ l[m] = i(l[m]);
1691
+ }
1692
+ return l;
1693
+ }
1694
+ if (typeof a == "string" && y && typeof y == "object" && !Array.isArray(y)) {
1695
+ if (!u(a)) return y;
1696
+ let l$3 = S$1(y), m = Object.hasOwn(l$3, a) ? l$3[a] : void 0;
1697
+ return l(l$3, a, i(m)), l$3;
1698
+ }
1699
+ return y;
1700
+ });
1701
+ if (typeof a == "number") {
1702
+ if (a > 536870911) throw new Error("Array index too large");
1703
+ if (a < 0 && (!s || !Array.isArray(s))) throw new Error("Out of bounds negative array index");
1704
+ if (Array.isArray(s)) {
1705
+ let l = [...s], m = a < 0 ? l.length + a : a;
1706
+ if (m >= 0) {
1707
+ for (; l.length <= m;) l.push(null);
1708
+ l[m] = i(l[m]);
1709
+ }
1710
+ return l;
1711
+ }
1712
+ if (s == null) {
1713
+ let l = [];
1714
+ for (; l.length <= a;) l.push(null);
1715
+ return l[a] = i(null), l;
1716
+ }
1717
+ return s;
1718
+ }
1719
+ if (typeof a == "string" && s && typeof s == "object" && !Array.isArray(s)) {
1720
+ if (!u(a)) return s;
1721
+ let y = S$1(s), l$4 = Object.hasOwn(y, a) ? y[a] : void 0;
1722
+ return l(y, a, i(l$4)), y;
1723
+ }
1724
+ return s;
1725
+ }
1726
+ case "Iterate": {
1727
+ let h = (a) => {
1728
+ if (Array.isArray(a)) return a.map((y) => i(y));
1729
+ if (a && typeof a == "object") {
1730
+ let y = Object.create(null);
1731
+ for (let [l$5, m] of Object.entries(a)) u(l$5) && l(y, l$5, i(m));
1732
+ return y;
1733
+ }
1734
+ return a;
1735
+ };
1736
+ return f.base ? u$9(s, f.base, h) : h(s);
1737
+ }
1738
+ case "Pipe": return u$9(u$9(s, f.left, (a) => a), f.right, i);
1739
+ default: return i(s);
1740
+ }
1741
+ }
1742
+ return u$9(t, r, (s) => {
1743
+ if (e === "|=") return o(s, s);
1744
+ return o(s, d(t, n, p)[0] ?? null);
1745
+ });
1746
+ }
1747
+ function jt(t, r, e) {
1748
+ function n(o, u$10, c) {
1749
+ switch (u$10.type) {
1750
+ case "Identity": return c;
1751
+ case "Field":
1752
+ if (!u(u$10.name)) return o;
1753
+ if (u$10.base) {
1754
+ let s = d(o, u$10.base, e)[0], f = n(s, {
1755
+ type: "Field",
1756
+ name: u$10.name
1757
+ }, c);
1758
+ return n(o, u$10.base, f);
1759
+ }
1760
+ if (o && typeof o == "object" && !Array.isArray(o)) {
1761
+ let s = S$1(o);
1762
+ return l(s, u$10.name, c), s;
1763
+ }
1764
+ return o;
1765
+ case "Index": {
1766
+ if (u$10.base) {
1767
+ let i = d(o, u$10.base, e)[0], h = n(i, {
1768
+ type: "Index",
1769
+ index: u$10.index
1770
+ }, c);
1771
+ return n(o, u$10.base, h);
1772
+ }
1773
+ let f = d(t, u$10.index, e)[0];
1774
+ if (typeof f == "number" && Array.isArray(o)) {
1775
+ let i = [...o], h = f < 0 ? i.length + f : f;
1776
+ return h >= 0 && h < i.length && (i[h] = c), i;
1777
+ }
1778
+ if (typeof f == "string" && o && typeof o == "object" && !Array.isArray(o)) {
1779
+ if (!u(f)) return o;
1780
+ let i = S$1(o);
1781
+ return l(i, f, c), i;
1782
+ }
1783
+ return o;
1784
+ }
1785
+ default: return o;
1786
+ }
1787
+ }
1788
+ function p(o, u$11) {
1789
+ switch (u$11.type) {
1790
+ case "Identity": return null;
1791
+ case "Field":
1792
+ if (!u(u$11.name)) return o;
1793
+ if (u$11.base) {
1794
+ let s = d(o, u$11.base, e)[0];
1795
+ if (s == null) return o;
1796
+ let f = p(s, {
1797
+ type: "Field",
1798
+ name: u$11.name
1799
+ });
1800
+ return n(o, u$11.base, f);
1801
+ }
1802
+ if (o && typeof o == "object" && !Array.isArray(o)) {
1803
+ if (!u(u$11.name)) return o;
1804
+ let s = S$1(o);
1805
+ return delete s[u$11.name], s;
1806
+ }
1807
+ return o;
1808
+ case "Index": {
1809
+ if (u$11.base) {
1810
+ let i = d(o, u$11.base, e)[0];
1811
+ if (i == null) return o;
1812
+ let h = p(i, {
1813
+ type: "Index",
1814
+ index: u$11.index
1815
+ });
1816
+ return n(o, u$11.base, h);
1817
+ }
1818
+ let f = d(t, u$11.index, e)[0];
1819
+ if (typeof f == "number" && Array.isArray(o)) {
1820
+ let i = [...o], h = f < 0 ? i.length + f : f;
1821
+ return h >= 0 && h < i.length && i.splice(h, 1), i;
1822
+ }
1823
+ if (typeof f == "string" && o && typeof o == "object" && !Array.isArray(o)) {
1824
+ if (!u(f)) return o;
1825
+ let i = S$1(o);
1826
+ return delete i[f], i;
1827
+ }
1828
+ return o;
1829
+ }
1830
+ case "Iterate": return Array.isArray(o) ? [] : o && typeof o == "object" ? Object.create(null) : o;
1831
+ case "Pipe": {
1832
+ let i = function(y, l$6, m) {
1833
+ switch (l$6.type) {
1834
+ case "Identity": return m;
1835
+ case "Field":
1836
+ if (!u(l$6.name)) return y;
1837
+ if (y && typeof y == "object" && !Array.isArray(y)) {
1838
+ let b = S$1(y);
1839
+ return l(b, l$6.name, m), b;
1840
+ }
1841
+ return y;
1842
+ case "Index": {
1843
+ let w = d(t, l$6.index, e)[0];
1844
+ if (typeof w == "number" && Array.isArray(y)) {
1845
+ let k = [...y], N = w < 0 ? k.length + w : w;
1846
+ return N >= 0 && N < k.length && (k[N] = m), k;
1847
+ }
1848
+ if (typeof w == "string" && y && typeof y == "object" && !Array.isArray(y)) {
1849
+ if (!u(w)) return y;
1850
+ let k = S$1(y);
1851
+ return l(k, w, m), k;
1852
+ }
1853
+ return y;
1854
+ }
1855
+ case "Pipe": {
1856
+ let b = d(y, l$6.left, e)[0], w = i(b, l$6.right, m);
1857
+ return i(y, l$6.left, w);
1858
+ }
1859
+ default: return y;
1860
+ }
1861
+ };
1862
+ let s = u$11.left, f = u$11.right, h = d(o, s, e)[0];
1863
+ if (h == null) return o;
1864
+ return i(o, s, p(h, f));
1865
+ }
1866
+ default: return o;
1867
+ }
1868
+ }
1869
+ return p(t, r);
1870
+ }
1871
+ function xt(t, r, e, n, p) {
1872
+ if (r === "and") return d(t, e, p).flatMap((s) => S(s) ? d(t, n, p).map((i) => S(i)) : [!1]);
1873
+ if (r === "or") return d(t, e, p).flatMap((s) => S(s) ? [!0] : d(t, n, p).map((i) => S(i)));
1874
+ if (r === "//") {
1875
+ let s = d(t, e, p).filter((f) => f != null && f !== !1);
1876
+ return s.length > 0 ? s : d(t, n, p);
1877
+ }
1878
+ let o = d(t, e, p), u = d(t, n, p);
1879
+ return o.flatMap((c) => u.map((s) => {
1880
+ switch (r) {
1881
+ 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) ? b$1(c, s) : null;
1882
+ case "-":
1883
+ if (typeof c == "number" && typeof s == "number") return c - s;
1884
+ if (Array.isArray(c) && Array.isArray(s)) {
1885
+ let f = new Set(s.map((i) => JSON.stringify(i)));
1886
+ return c.filter((i) => !f.has(JSON.stringify(i)));
1887
+ }
1888
+ if (typeof c == "string" && typeof s == "string") {
1889
+ let f = (i) => i.length > 10 ? `"${i.slice(0, 10)}...` : JSON.stringify(i);
1890
+ throw new Error(`string (${f(c)}) and string (${f(s)}) cannot be subtracted`);
1891
+ }
1892
+ return null;
1893
+ case "*":
1894
+ if (typeof c == "number" && typeof s == "number") return c * s;
1895
+ if (typeof c == "string" && typeof s == "number") return c.repeat(s);
1896
+ {
1897
+ let f = _(c), i = _(s);
1898
+ if (f && i) return v(f, i);
1899
+ }
1900
+ return null;
1901
+ case "/":
1902
+ if (typeof c == "number" && typeof s == "number") {
1903
+ if (s === 0) throw new Error(`number (${c}) and number (${s}) cannot be divided because the divisor is zero`);
1904
+ return c / s;
1905
+ }
1906
+ return typeof c == "string" && typeof s == "string" ? c.split(s) : null;
1907
+ case "%":
1908
+ if (typeof c == "number" && typeof s == "number") {
1909
+ if (s === 0) throw new Error(`number (${c}) and number (${s}) cannot be divided (remainder) because the divisor is zero`);
1910
+ return !Number.isFinite(c) && !Number.isNaN(c) ? !Number.isFinite(s) && !Number.isNaN(s) && c < 0 && s > 0 ? -1 : 0 : c % s;
1911
+ }
1912
+ return null;
1913
+ case "==": return I(c, s);
1914
+ case "!=": return !I(c, s);
1915
+ case "<": return U(c, s) < 0;
1916
+ case "<=": return U(c, s) <= 0;
1917
+ case ">": return U(c, s) > 0;
1918
+ case ">=": return U(c, s) >= 0;
1919
+ default: return null;
1920
+ }
1921
+ }));
1922
+ }
1923
+ function gt(t, r$2, e, n) {
1924
+ let p = Ct.get(r$2);
1925
+ if (p) return typeof t == "number" ? [p(t)] : [null];
1926
+ let o = rt(t, r$2, e, n, d);
1927
+ if (o !== null) return o;
1928
+ let u = ft(t, r$2, e, n, d);
1929
+ if (u !== null) return u;
1930
+ let c = Z(t, r$2, e, n, d);
1931
+ if (c !== null) return c;
1932
+ let s = tt(t, r$2, n.limits.maxDepth);
1933
+ if (s !== null) return s;
1934
+ let f = ct(t, r$2);
1935
+ if (f !== null) return f;
1936
+ let i = st(t, r$2, e, n, d);
1937
+ if (i !== null) return i;
1938
+ let h = W(t, r$2, e, n, d, mt, $, S, F, b);
1939
+ if (h !== null) return h;
1940
+ let a = it(t, r$2, e, n, d, S, K, V, jt, J);
1941
+ if (a !== null) return a;
1942
+ let y = et(t, r$2, e, n, d, I);
1943
+ if (y !== null) return y;
1944
+ let l = z(t, r$2, e, n, d, mt, S, b);
1945
+ if (l !== null) return l;
1946
+ let m = nt(t, r$2, e, n, d, S, Rt, gt);
1947
+ if (m !== null) return m;
1948
+ let b$2 = ot(t, r$2, e, n, d, I);
1949
+ if (b$2 !== null) return b$2;
1950
+ switch (r$2) {
1951
+ case "builtins": return [[
1952
+ "add/0",
1953
+ "all/0",
1954
+ "all/1",
1955
+ "all/2",
1956
+ "any/0",
1957
+ "any/1",
1958
+ "any/2",
1959
+ "arrays/0",
1960
+ "ascii/0",
1961
+ "ascii_downcase/0",
1962
+ "ascii_upcase/0",
1963
+ "booleans/0",
1964
+ "bsearch/1",
1965
+ "builtins/0",
1966
+ "combinations/0",
1967
+ "combinations/1",
1968
+ "contains/1",
1969
+ "debug/0",
1970
+ "del/1",
1971
+ "delpaths/1",
1972
+ "empty/0",
1973
+ "env/0",
1974
+ "error/0",
1975
+ "error/1",
1976
+ "explode/0",
1977
+ "first/0",
1978
+ "first/1",
1979
+ "flatten/0",
1980
+ "flatten/1",
1981
+ "floor/0",
1982
+ "from_entries/0",
1983
+ "fromdate/0",
1984
+ "fromjson/0",
1985
+ "getpath/1",
1986
+ "gmtime/0",
1987
+ "group_by/1",
1988
+ "gsub/2",
1989
+ "gsub/3",
1990
+ "has/1",
1991
+ "implode/0",
1992
+ "IN/1",
1993
+ "IN/2",
1994
+ "INDEX/1",
1995
+ "INDEX/2",
1996
+ "index/1",
1997
+ "indices/1",
1998
+ "infinite/0",
1999
+ "inside/1",
2000
+ "isempty/1",
2001
+ "isnan/0",
2002
+ "isnormal/0",
2003
+ "isvalid/1",
2004
+ "iterables/0",
2005
+ "join/1",
2006
+ "keys/0",
2007
+ "keys_unsorted/0",
2008
+ "last/0",
2009
+ "last/1",
2010
+ "length/0",
2011
+ "limit/2",
2012
+ "ltrimstr/1",
2013
+ "map/1",
2014
+ "map_values/1",
2015
+ "match/1",
2016
+ "match/2",
2017
+ "max/0",
2018
+ "max_by/1",
2019
+ "min/0",
2020
+ "min_by/1",
2021
+ "mktime/0",
2022
+ "modulemeta/1",
2023
+ "nan/0",
2024
+ "not/0",
2025
+ "nth/1",
2026
+ "nth/2",
2027
+ "null/0",
2028
+ "nulls/0",
2029
+ "numbers/0",
2030
+ "objects/0",
2031
+ "path/1",
2032
+ "paths/0",
2033
+ "paths/1",
2034
+ "pick/1",
2035
+ "range/1",
2036
+ "range/2",
2037
+ "range/3",
2038
+ "recurse/0",
2039
+ "recurse/1",
2040
+ "recurse_down/0",
2041
+ "repeat/1",
2042
+ "reverse/0",
2043
+ "rindex/1",
2044
+ "rtrimstr/1",
2045
+ "scalars/0",
2046
+ "scan/1",
2047
+ "scan/2",
2048
+ "select/1",
2049
+ "setpath/2",
2050
+ "skip/2",
2051
+ "sort/0",
2052
+ "sort_by/1",
2053
+ "split/1",
2054
+ "splits/1",
2055
+ "splits/2",
2056
+ "sqrt/0",
2057
+ "startswith/1",
2058
+ "strftime/1",
2059
+ "strings/0",
2060
+ "strptime/1",
2061
+ "sub/2",
2062
+ "sub/3",
2063
+ "test/1",
2064
+ "test/2",
2065
+ "to_entries/0",
2066
+ "toboolean/0",
2067
+ "todate/0",
2068
+ "tojson/0",
2069
+ "tostream/0",
2070
+ "fromstream/1",
2071
+ "truncate_stream/1",
2072
+ "tonumber/0",
2073
+ "tostring/0",
2074
+ "transpose/0",
2075
+ "trim/0",
2076
+ "ltrim/0",
2077
+ "rtrim/0",
2078
+ "type/0",
2079
+ "unique/0",
2080
+ "unique_by/1",
2081
+ "until/2",
2082
+ "utf8bytelength/0",
2083
+ "values/0",
2084
+ "walk/1",
2085
+ "while/2",
2086
+ "with_entries/1"
2087
+ ]];
2088
+ case "error": throw new H(e.length > 0 ? d(t, e[0], n)[0] : t);
2089
+ case "env": return [n.env ? r(n.env) : Object.create(null)];
2090
+ case "debug": return [t];
2091
+ case "input_line_number": return [1];
2092
+ default: {
2093
+ let w = `${r$2}/${e.length}`, k = n.funcs?.get(w);
2094
+ if (k) {
2095
+ let N = k.closure ?? n.funcs ?? /* @__PURE__ */ new Map(), C = new Map(N);
2096
+ C.set(w, k);
2097
+ for (let _ = 0; _ < k.params.length; _++) {
2098
+ let kt = k.params[_], ht = e[_];
2099
+ if (ht) {
2100
+ let j = d(t, ht, n), x;
2101
+ if (j.length === 0) x = {
2102
+ type: "Call",
2103
+ name: "empty",
2104
+ args: []
2105
+ };
2106
+ else if (j.length === 1) x = {
2107
+ type: "Literal",
2108
+ value: j[0]
2109
+ };
2110
+ else {
2111
+ x = {
2112
+ type: "Literal",
2113
+ value: j[j.length - 1]
2114
+ };
2115
+ for (let Q = j.length - 2; Q >= 0; Q--) x = {
2116
+ type: "Comma",
2117
+ left: {
2118
+ type: "Literal",
2119
+ value: j[Q]
2120
+ },
2121
+ right: x
2122
+ };
2123
+ }
2124
+ C.set(`${kt}/0`, {
2125
+ params: [],
2126
+ body: x
2127
+ });
2128
+ }
2129
+ }
2130
+ let wt = {
2131
+ ...n,
2132
+ funcs: C
2133
+ };
2134
+ return d(t, k.body, wt);
2135
+ }
2136
+ throw new Error(`Unknown function: ${r$2}`);
2137
+ }
2138
+ }
2139
+ }
2140
+ function J(t, r, e, n, p) {
2141
+ if (r.type === "Comma") {
2142
+ let c = r;
2143
+ J(t, c.left, e, n, p), J(t, c.right, e, n, p);
2144
+ return;
2145
+ }
2146
+ let o = M(r);
2147
+ if (o !== null) {
2148
+ p.push([...n, ...o]);
2149
+ return;
2150
+ }
2151
+ if (r.type === "Iterate") {
2152
+ if (Array.isArray(t)) for (let c = 0; c < t.length; c++) p.push([...n, c]);
2153
+ else if (t && typeof t == "object") for (let c of Object.keys(t)) p.push([...n, c]);
2154
+ return;
2155
+ }
2156
+ if (r.type === "Recurse") {
2157
+ let c = (s, f) => {
2158
+ if (p.push([...n, ...f]), s && typeof s == "object") if (Array.isArray(s)) for (let i = 0; i < s.length; i++) c(s[i], [...f, i]);
2159
+ else for (let i of Object.keys(s)) c(s[i], [...f, i]);
2160
+ };
2161
+ c(t, []);
2162
+ return;
2163
+ }
2164
+ if (r.type === "Pipe") {
2165
+ let c = M(r.left);
2166
+ if (c !== null) {
2167
+ let s = d(t, r.left, e);
2168
+ for (let f of s) J(f, r.right, e, [...n, ...c], p);
2169
+ return;
2170
+ }
2171
+ }
2172
+ d(t, r, e).length > 0 && p.push(n);
2173
+ }
2174
+ var At = new Map([
2175
+ ["and", "AND"],
2176
+ ["or", "OR"],
2177
+ ["not", "NOT"],
2178
+ ["if", "IF"],
2179
+ ["then", "THEN"],
2180
+ ["elif", "ELIF"],
2181
+ ["else", "ELSE"],
2182
+ ["end", "END"],
2183
+ ["as", "AS"],
2184
+ ["try", "TRY"],
2185
+ ["catch", "CATCH"],
2186
+ ["true", "TRUE"],
2187
+ ["false", "FALSE"],
2188
+ ["null", "NULL"],
2189
+ ["reduce", "REDUCE"],
2190
+ ["foreach", "FOREACH"],
2191
+ ["label", "LABEL"],
2192
+ ["break", "BREAK"],
2193
+ ["def", "DEF"]
2194
+ ]), Y = new Set(At.values());
2195
+ function Et(t) {
2196
+ let r = [], e = 0, n = (f = 0) => t[e + f], p = () => t[e++], o = () => 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);
2197
+ for (; !o();) {
2198
+ let f = e, i = p();
2199
+ if (!(i === " " || i === " " || i === `
2200
+ ` || i === "\r")) {
2201
+ if (i === "#") {
2202
+ for (; !o() && n() !== `
2203
+ `;) p();
2204
+ continue;
2205
+ }
2206
+ if (i === "." && n() === ".") {
2207
+ p(), r.push({
2208
+ type: "DOTDOT",
2209
+ pos: f
2210
+ });
2211
+ continue;
2212
+ }
2213
+ if (i === "=" && n() === "=") {
2214
+ p(), r.push({
2215
+ type: "EQ",
2216
+ pos: f
2217
+ });
2218
+ continue;
2219
+ }
2220
+ if (i === "!" && n() === "=") {
2221
+ p(), r.push({
2222
+ type: "NE",
2223
+ pos: f
2224
+ });
2225
+ continue;
2226
+ }
2227
+ if (i === "<" && n() === "=") {
2228
+ p(), r.push({
2229
+ type: "LE",
2230
+ pos: f
2231
+ });
2232
+ continue;
2233
+ }
2234
+ if (i === ">" && n() === "=") {
2235
+ p(), r.push({
2236
+ type: "GE",
2237
+ pos: f
2238
+ });
2239
+ continue;
2240
+ }
2241
+ if (i === "/" && n() === "/") {
2242
+ p(), n() === "=" ? (p(), r.push({
2243
+ type: "UPDATE_ALT",
2244
+ pos: f
2245
+ })) : r.push({
2246
+ type: "ALT",
2247
+ pos: f
2248
+ });
2249
+ continue;
2250
+ }
2251
+ if (i === "+" && n() === "=") {
2252
+ p(), r.push({
2253
+ type: "UPDATE_ADD",
2254
+ pos: f
2255
+ });
2256
+ continue;
2257
+ }
2258
+ if (i === "-" && n() === "=") {
2259
+ p(), r.push({
2260
+ type: "UPDATE_SUB",
2261
+ pos: f
2262
+ });
2263
+ continue;
2264
+ }
2265
+ if (i === "*" && n() === "=") {
2266
+ p(), r.push({
2267
+ type: "UPDATE_MUL",
2268
+ pos: f
2269
+ });
2270
+ continue;
2271
+ }
2272
+ if (i === "/" && n() === "=") {
2273
+ p(), r.push({
2274
+ type: "UPDATE_DIV",
2275
+ pos: f
2276
+ });
2277
+ continue;
2278
+ }
2279
+ if (i === "%" && n() === "=") {
2280
+ p(), r.push({
2281
+ type: "UPDATE_MOD",
2282
+ pos: f
2283
+ });
2284
+ continue;
2285
+ }
2286
+ if (i === "=" && n() !== "=") {
2287
+ r.push({
2288
+ type: "ASSIGN",
2289
+ pos: f
2290
+ });
2291
+ continue;
2292
+ }
2293
+ if (i === ".") {
2294
+ r.push({
2295
+ type: "DOT",
2296
+ pos: f
2297
+ });
2298
+ continue;
2299
+ }
2300
+ if (i === "|") {
2301
+ n() === "=" ? (p(), r.push({
2302
+ type: "UPDATE_PIPE",
2303
+ pos: f
2304
+ })) : r.push({
2305
+ type: "PIPE",
2306
+ pos: f
2307
+ });
2308
+ continue;
2309
+ }
2310
+ if (i === ",") {
2311
+ r.push({
2312
+ type: "COMMA",
2313
+ pos: f
2314
+ });
2315
+ continue;
2316
+ }
2317
+ if (i === ":") {
2318
+ r.push({
2319
+ type: "COLON",
2320
+ pos: f
2321
+ });
2322
+ continue;
2323
+ }
2324
+ if (i === ";") {
2325
+ r.push({
2326
+ type: "SEMICOLON",
2327
+ pos: f
2328
+ });
2329
+ continue;
2330
+ }
2331
+ if (i === "(") {
2332
+ r.push({
2333
+ type: "LPAREN",
2334
+ pos: f
2335
+ });
2336
+ continue;
2337
+ }
2338
+ if (i === ")") {
2339
+ r.push({
2340
+ type: "RPAREN",
2341
+ pos: f
2342
+ });
2343
+ continue;
2344
+ }
2345
+ if (i === "[") {
2346
+ r.push({
2347
+ type: "LBRACKET",
2348
+ pos: f
2349
+ });
2350
+ continue;
2351
+ }
2352
+ if (i === "]") {
2353
+ r.push({
2354
+ type: "RBRACKET",
2355
+ pos: f
2356
+ });
2357
+ continue;
2358
+ }
2359
+ if (i === "{") {
2360
+ r.push({
2361
+ type: "LBRACE",
2362
+ pos: f
2363
+ });
2364
+ continue;
2365
+ }
2366
+ if (i === "}") {
2367
+ r.push({
2368
+ type: "RBRACE",
2369
+ pos: f
2370
+ });
2371
+ continue;
2372
+ }
2373
+ if (i === "?") {
2374
+ r.push({
2375
+ type: "QUESTION",
2376
+ pos: f
2377
+ });
2378
+ continue;
2379
+ }
2380
+ if (i === "+") {
2381
+ r.push({
2382
+ type: "PLUS",
2383
+ pos: f
2384
+ });
2385
+ continue;
2386
+ }
2387
+ if (i === "-") {
2388
+ r.push({
2389
+ type: "MINUS",
2390
+ pos: f
2391
+ });
2392
+ continue;
2393
+ }
2394
+ if (i === "*") {
2395
+ r.push({
2396
+ type: "STAR",
2397
+ pos: f
2398
+ });
2399
+ continue;
2400
+ }
2401
+ if (i === "/") {
2402
+ r.push({
2403
+ type: "SLASH",
2404
+ pos: f
2405
+ });
2406
+ continue;
2407
+ }
2408
+ if (i === "%") {
2409
+ r.push({
2410
+ type: "PERCENT",
2411
+ pos: f
2412
+ });
2413
+ continue;
2414
+ }
2415
+ if (i === "<") {
2416
+ r.push({
2417
+ type: "LT",
2418
+ pos: f
2419
+ });
2420
+ continue;
2421
+ }
2422
+ if (i === ">") {
2423
+ r.push({
2424
+ type: "GT",
2425
+ pos: f
2426
+ });
2427
+ continue;
2428
+ }
2429
+ if (u(i)) {
2430
+ let h = i;
2431
+ for (; !o() && (u(n()) || n() === "." || n() === "e" || n() === "E");) (n() === "e" || n() === "E") && (t[e + 1] === "+" || t[e + 1] === "-") && (h += p()), h += p();
2432
+ r.push({
2433
+ type: "NUMBER",
2434
+ value: Number(h),
2435
+ pos: f
2436
+ });
2437
+ continue;
2438
+ }
2439
+ if (i === "\"") {
2440
+ let h = "";
2441
+ for (; !o() && n() !== "\"";) if (n() === "\\") {
2442
+ if (p(), o()) break;
2443
+ let a = p();
2444
+ switch (a) {
2445
+ case "n":
2446
+ h += `
2447
+ `;
2448
+ break;
2449
+ case "r":
2450
+ h += "\r";
2451
+ break;
2452
+ case "t":
2453
+ h += " ";
2454
+ break;
2455
+ case "\\":
2456
+ h += "\\";
2457
+ break;
2458
+ case "\"":
2459
+ h += "\"";
2460
+ break;
2461
+ case "(":
2462
+ h += "\\(";
2463
+ break;
2464
+ default: h += a;
2465
+ }
2466
+ } else h += p();
2467
+ o() || p(), r.push({
2468
+ type: "STRING",
2469
+ value: h,
2470
+ pos: f
2471
+ });
2472
+ continue;
2473
+ }
2474
+ if (c(i) || i === "$" || i === "@") {
2475
+ let h = i;
2476
+ for (; !o() && s(n());) h += p();
2477
+ let a = At.get(h);
2478
+ a ? r.push({
2479
+ type: a,
2480
+ value: h,
2481
+ pos: f
2482
+ }) : r.push({
2483
+ type: "IDENT",
2484
+ value: h,
2485
+ pos: f
2486
+ });
2487
+ continue;
2488
+ }
2489
+ throw new Error(`Unexpected character '${i}' at position ${f}`);
2490
+ }
2491
+ }
2492
+ return r.push({
2493
+ type: "EOF",
2494
+ pos: e
2495
+ }), r;
2496
+ }
2497
+ var ut = class t {
2498
+ tokens;
2499
+ pos = 0;
2500
+ constructor(r) {
2501
+ this.tokens = r;
2502
+ }
2503
+ peek(r = 0) {
2504
+ return this.tokens[this.pos + r] ?? {
2505
+ type: "EOF",
2506
+ pos: -1
2507
+ };
2508
+ }
2509
+ advance() {
2510
+ return this.tokens[this.pos++];
2511
+ }
2512
+ check(r) {
2513
+ return this.peek().type === r;
2514
+ }
2515
+ match(...r) {
2516
+ for (let e of r) if (this.check(e)) return this.advance();
2517
+ return null;
2518
+ }
2519
+ expect(r, e) {
2520
+ if (!this.check(r)) throw new Error(`${e} at position ${this.peek().pos}, got ${this.peek().type}`);
2521
+ return this.advance();
2522
+ }
2523
+ isFieldNameAfterDot(r = 0) {
2524
+ let e = this.peek(r), n = this.peek(r + 1);
2525
+ return n.type === "STRING" ? !0 : n.type === "IDENT" || Y.has(n.type) ? n.pos === e.pos + 1 : !1;
2526
+ }
2527
+ isIdentLike() {
2528
+ let r = this.peek().type;
2529
+ return r === "IDENT" || Y.has(r);
2530
+ }
2531
+ consumeFieldNameAfterDot(r) {
2532
+ let e = this.peek();
2533
+ return e.type === "STRING" ? this.advance().value : (e.type === "IDENT" || Y.has(e.type)) && e.pos === r.pos + 1 ? this.advance().value : null;
2534
+ }
2535
+ parse() {
2536
+ let r = this.parseExpr();
2537
+ if (!this.check("EOF")) throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);
2538
+ return r;
2539
+ }
2540
+ parseExpr() {
2541
+ return this.parsePipe();
2542
+ }
2543
+ parsePattern() {
2544
+ if (this.match("LBRACKET")) {
2545
+ let n = [];
2546
+ if (!this.check("RBRACKET")) for (n.push(this.parsePattern()); this.match("COMMA") && !this.check("RBRACKET");) n.push(this.parsePattern());
2547
+ return this.expect("RBRACKET", "Expected ']' after array pattern"), {
2548
+ type: "array",
2549
+ elements: n
2550
+ };
2551
+ }
2552
+ if (this.match("LBRACE")) {
2553
+ let n = [];
2554
+ if (!this.check("RBRACE")) for (n.push(this.parsePatternField()); this.match("COMMA") && !this.check("RBRACE");) n.push(this.parsePatternField());
2555
+ return this.expect("RBRACE", "Expected '}' after object pattern"), {
2556
+ type: "object",
2557
+ fields: n
2558
+ };
2559
+ }
2560
+ let r = this.expect("IDENT", "Expected variable name in pattern"), e = r.value;
2561
+ if (!e.startsWith("$")) throw new Error(`Variable name must start with $ at position ${r.pos}`);
2562
+ return {
2563
+ type: "var",
2564
+ name: e
2565
+ };
2566
+ }
2567
+ parsePatternField() {
2568
+ if (this.match("LPAREN")) {
2569
+ let e = this.parseExpr();
2570
+ this.expect("RPAREN", "Expected ')' after computed key"), this.expect("COLON", "Expected ':' after computed key");
2571
+ return {
2572
+ key: e,
2573
+ pattern: this.parsePattern()
2574
+ };
2575
+ }
2576
+ let r = this.peek();
2577
+ if (r.type === "IDENT" || Y.has(r.type)) {
2578
+ let e = r.value;
2579
+ if (e.startsWith("$")) {
2580
+ if (this.advance(), this.match("COLON")) {
2581
+ let n = this.parsePattern();
2582
+ return {
2583
+ key: e.slice(1),
2584
+ pattern: n,
2585
+ keyVar: e
2586
+ };
2587
+ }
2588
+ return {
2589
+ key: e.slice(1),
2590
+ pattern: {
2591
+ type: "var",
2592
+ name: e
2593
+ }
2594
+ };
2595
+ }
2596
+ if (this.advance(), this.match("COLON")) return {
2597
+ key: e,
2598
+ pattern: this.parsePattern()
2599
+ };
2600
+ return {
2601
+ key: e,
2602
+ pattern: {
2603
+ type: "var",
2604
+ name: `$${e}`
2605
+ }
2606
+ };
2607
+ }
2608
+ throw new Error(`Expected field name in object pattern at position ${r.pos}`);
2609
+ }
2610
+ parsePipe() {
2611
+ let r = this.parseComma();
2612
+ for (; this.match("PIPE");) {
2613
+ let e = this.parseComma();
2614
+ r = {
2615
+ type: "Pipe",
2616
+ left: r,
2617
+ right: e
2618
+ };
2619
+ }
2620
+ return r;
2621
+ }
2622
+ parseComma() {
2623
+ let r = this.parseVarBind();
2624
+ for (; this.match("COMMA");) {
2625
+ let e = this.parseVarBind();
2626
+ r = {
2627
+ type: "Comma",
2628
+ left: r,
2629
+ right: e
2630
+ };
2631
+ }
2632
+ return r;
2633
+ }
2634
+ parseVarBind() {
2635
+ let r = this.parseUpdate();
2636
+ if (this.match("AS")) {
2637
+ let e = this.parsePattern(), n = [];
2638
+ for (; this.check("QUESTION") && this.peekAhead(1)?.type === "ALT";) this.advance(), this.advance(), n.push(this.parsePattern());
2639
+ this.expect("PIPE", "Expected '|' after variable binding");
2640
+ let p = this.parseExpr();
2641
+ return e.type === "var" && n.length === 0 ? {
2642
+ type: "VarBind",
2643
+ name: e.name,
2644
+ value: r,
2645
+ body: p
2646
+ } : {
2647
+ type: "VarBind",
2648
+ name: e.type === "var" ? e.name : "",
2649
+ value: r,
2650
+ body: p,
2651
+ pattern: e.type !== "var" ? e : void 0,
2652
+ alternatives: n.length > 0 ? n : void 0
2653
+ };
2654
+ }
2655
+ return r;
2656
+ }
2657
+ peekAhead(r) {
2658
+ let e = this.pos + r;
2659
+ return e < this.tokens.length ? this.tokens[e] : void 0;
2660
+ }
2661
+ parseUpdate() {
2662
+ let r = this.parseAlt(), e = new Map([
2663
+ ["ASSIGN", "="],
2664
+ ["UPDATE_ADD", "+="],
2665
+ ["UPDATE_SUB", "-="],
2666
+ ["UPDATE_MUL", "*="],
2667
+ ["UPDATE_DIV", "/="],
2668
+ ["UPDATE_MOD", "%="],
2669
+ ["UPDATE_ALT", "//="],
2670
+ ["UPDATE_PIPE", "|="]
2671
+ ]), n = this.match("ASSIGN", "UPDATE_ADD", "UPDATE_SUB", "UPDATE_MUL", "UPDATE_DIV", "UPDATE_MOD", "UPDATE_ALT", "UPDATE_PIPE");
2672
+ if (n) {
2673
+ let p = this.parseVarBind(), o = e.get(n.type);
2674
+ if (o) return {
2675
+ type: "UpdateOp",
2676
+ op: o,
2677
+ path: r,
2678
+ value: p
2679
+ };
2680
+ }
2681
+ return r;
2682
+ }
2683
+ parseAlt() {
2684
+ let r = this.parseOr();
2685
+ for (; this.match("ALT");) {
2686
+ let e = this.parseOr();
2687
+ r = {
2688
+ type: "BinaryOp",
2689
+ op: "//",
2690
+ left: r,
2691
+ right: e
2692
+ };
2693
+ }
2694
+ return r;
2695
+ }
2696
+ parseOr() {
2697
+ let r = this.parseAnd();
2698
+ for (; this.match("OR");) {
2699
+ let e = this.parseAnd();
2700
+ r = {
2701
+ type: "BinaryOp",
2702
+ op: "or",
2703
+ left: r,
2704
+ right: e
2705
+ };
2706
+ }
2707
+ return r;
2708
+ }
2709
+ parseAnd() {
2710
+ let r = this.parseNot();
2711
+ for (; this.match("AND");) {
2712
+ let e = this.parseNot();
2713
+ r = {
2714
+ type: "BinaryOp",
2715
+ op: "and",
2716
+ left: r,
2717
+ right: e
2718
+ };
2719
+ }
2720
+ return r;
2721
+ }
2722
+ parseNot() {
2723
+ return this.parseComparison();
2724
+ }
2725
+ parseComparison() {
2726
+ let r = this.parseAddSub(), e = new Map([
2727
+ ["EQ", "=="],
2728
+ ["NE", "!="],
2729
+ ["LT", "<"],
2730
+ ["LE", "<="],
2731
+ ["GT", ">"],
2732
+ ["GE", ">="]
2733
+ ]), n = this.match("EQ", "NE", "LT", "LE", "GT", "GE");
2734
+ if (n) {
2735
+ let p = e.get(n.type);
2736
+ if (p) {
2737
+ let o = this.parseAddSub();
2738
+ r = {
2739
+ type: "BinaryOp",
2740
+ op: p,
2741
+ left: r,
2742
+ right: o
2743
+ };
2744
+ }
2745
+ }
2746
+ return r;
2747
+ }
2748
+ parseAddSub() {
2749
+ let r = this.parseMulDiv();
2750
+ for (;;) if (this.match("PLUS")) {
2751
+ let e = this.parseMulDiv();
2752
+ r = {
2753
+ type: "BinaryOp",
2754
+ op: "+",
2755
+ left: r,
2756
+ right: e
2757
+ };
2758
+ } else if (this.match("MINUS")) {
2759
+ let e = this.parseMulDiv();
2760
+ r = {
2761
+ type: "BinaryOp",
2762
+ op: "-",
2763
+ left: r,
2764
+ right: e
2765
+ };
2766
+ } else break;
2767
+ return r;
2768
+ }
2769
+ parseMulDiv() {
2770
+ let r = this.parseUnary();
2771
+ for (;;) if (this.match("STAR")) {
2772
+ let e = this.parseUnary();
2773
+ r = {
2774
+ type: "BinaryOp",
2775
+ op: "*",
2776
+ left: r,
2777
+ right: e
2778
+ };
2779
+ } else if (this.match("SLASH")) {
2780
+ let e = this.parseUnary();
2781
+ r = {
2782
+ type: "BinaryOp",
2783
+ op: "/",
2784
+ left: r,
2785
+ right: e
2786
+ };
2787
+ } else if (this.match("PERCENT")) {
2788
+ let e = this.parseUnary();
2789
+ r = {
2790
+ type: "BinaryOp",
2791
+ op: "%",
2792
+ left: r,
2793
+ right: e
2794
+ };
2795
+ } else break;
2796
+ return r;
2797
+ }
2798
+ parseUnary() {
2799
+ return this.match("MINUS") ? {
2800
+ type: "UnaryOp",
2801
+ op: "-",
2802
+ operand: this.parseUnary()
2803
+ } : this.parsePostfix();
2804
+ }
2805
+ parsePostfix() {
2806
+ let r = this.parsePrimary();
2807
+ for (;;) if (this.match("QUESTION")) r = {
2808
+ type: "Optional",
2809
+ expr: r
2810
+ };
2811
+ else if (this.check("DOT") && this.isFieldNameAfterDot()) this.advance(), r = {
2812
+ type: "Field",
2813
+ name: this.advance().value,
2814
+ base: r
2815
+ };
2816
+ else if (this.check("LBRACKET")) if (this.advance(), this.match("RBRACKET")) r = {
2817
+ type: "Iterate",
2818
+ base: r
2819
+ };
2820
+ else if (this.check("COLON")) {
2821
+ this.advance();
2822
+ let e = this.check("RBRACKET") ? void 0 : this.parseExpr();
2823
+ this.expect("RBRACKET", "Expected ']'"), r = {
2824
+ type: "Slice",
2825
+ end: e,
2826
+ base: r
2827
+ };
2828
+ } else {
2829
+ let e = this.parseExpr();
2830
+ if (this.match("COLON")) {
2831
+ let n = this.check("RBRACKET") ? void 0 : this.parseExpr();
2832
+ this.expect("RBRACKET", "Expected ']'"), r = {
2833
+ type: "Slice",
2834
+ start: e,
2835
+ end: n,
2836
+ base: r
2837
+ };
2838
+ } else this.expect("RBRACKET", "Expected ']'"), r = {
2839
+ type: "Index",
2840
+ index: e,
2841
+ base: r
2842
+ };
2843
+ }
2844
+ else break;
2845
+ return r;
2846
+ }
2847
+ parsePrimary() {
2848
+ if (this.match("DOTDOT")) return { type: "Recurse" };
2849
+ if (this.check("DOT")) {
2850
+ let r = this.advance();
2851
+ if (this.check("LBRACKET")) {
2852
+ if (this.advance(), this.match("RBRACKET")) return { type: "Iterate" };
2853
+ if (this.check("COLON")) {
2854
+ this.advance();
2855
+ let p = this.check("RBRACKET") ? void 0 : this.parseExpr();
2856
+ return this.expect("RBRACKET", "Expected ']'"), {
2857
+ type: "Slice",
2858
+ end: p
2859
+ };
2860
+ }
2861
+ let n = this.parseExpr();
2862
+ if (this.match("COLON")) {
2863
+ let p = this.check("RBRACKET") ? void 0 : this.parseExpr();
2864
+ return this.expect("RBRACKET", "Expected ']'"), {
2865
+ type: "Slice",
2866
+ start: n,
2867
+ end: p
2868
+ };
2869
+ }
2870
+ return this.expect("RBRACKET", "Expected ']'"), {
2871
+ type: "Index",
2872
+ index: n
2873
+ };
2874
+ }
2875
+ let e = this.consumeFieldNameAfterDot(r);
2876
+ return e !== null ? {
2877
+ type: "Field",
2878
+ name: e
2879
+ } : { type: "Identity" };
2880
+ }
2881
+ if (this.match("TRUE")) return {
2882
+ type: "Literal",
2883
+ value: !0
2884
+ };
2885
+ if (this.match("FALSE")) return {
2886
+ type: "Literal",
2887
+ value: !1
2888
+ };
2889
+ if (this.match("NULL")) return {
2890
+ type: "Literal",
2891
+ value: null
2892
+ };
2893
+ if (this.check("NUMBER")) return {
2894
+ type: "Literal",
2895
+ value: this.advance().value
2896
+ };
2897
+ if (this.check("STRING")) {
2898
+ let e = this.advance().value;
2899
+ return e.includes("\\(") ? this.parseStringInterpolation(e) : {
2900
+ type: "Literal",
2901
+ value: e
2902
+ };
2903
+ }
2904
+ if (this.match("LBRACKET")) {
2905
+ if (this.match("RBRACKET")) return { type: "Array" };
2906
+ let r = this.parseExpr();
2907
+ return this.expect("RBRACKET", "Expected ']'"), {
2908
+ type: "Array",
2909
+ elements: r
2910
+ };
2911
+ }
2912
+ if (this.match("LBRACE")) return this.parseObjectConstruction();
2913
+ if (this.match("LPAREN")) {
2914
+ let r = this.parseExpr();
2915
+ return this.expect("RPAREN", "Expected ')'"), {
2916
+ type: "Paren",
2917
+ expr: r
2918
+ };
2919
+ }
2920
+ if (this.match("IF")) return this.parseIf();
2921
+ if (this.match("TRY")) {
2922
+ let r = this.parsePostfix(), e;
2923
+ return this.match("CATCH") && (e = this.parsePostfix()), {
2924
+ type: "Try",
2925
+ body: r,
2926
+ catch: e
2927
+ };
2928
+ }
2929
+ if (this.match("REDUCE")) {
2930
+ let r = this.parseAddSub();
2931
+ this.expect("AS", "Expected 'as' after reduce expression");
2932
+ let e = this.parsePattern();
2933
+ this.expect("LPAREN", "Expected '(' after variable");
2934
+ let n = this.parseExpr();
2935
+ this.expect("SEMICOLON", "Expected ';' after init expression");
2936
+ let p = this.parseExpr();
2937
+ this.expect("RPAREN", "Expected ')' after update expression");
2938
+ return {
2939
+ type: "Reduce",
2940
+ expr: r,
2941
+ varName: e.type === "var" ? e.name : "",
2942
+ init: n,
2943
+ update: p,
2944
+ pattern: e.type !== "var" ? e : void 0
2945
+ };
2946
+ }
2947
+ if (this.match("FOREACH")) {
2948
+ let r = this.parseAddSub();
2949
+ this.expect("AS", "Expected 'as' after foreach expression");
2950
+ let e = this.parsePattern();
2951
+ this.expect("LPAREN", "Expected '(' after variable");
2952
+ let n = this.parseExpr();
2953
+ this.expect("SEMICOLON", "Expected ';' after init expression");
2954
+ let p = this.parseExpr(), o;
2955
+ this.match("SEMICOLON") && (o = this.parseExpr()), this.expect("RPAREN", "Expected ')' after expressions");
2956
+ return {
2957
+ type: "Foreach",
2958
+ expr: r,
2959
+ varName: e.type === "var" ? e.name : "",
2960
+ init: n,
2961
+ update: p,
2962
+ extract: o,
2963
+ pattern: e.type !== "var" ? e : void 0
2964
+ };
2965
+ }
2966
+ if (this.match("LABEL")) {
2967
+ let r = this.expect("IDENT", "Expected label name (e.g., $out)"), e = r.value;
2968
+ if (!e.startsWith("$")) throw new Error(`Label name must start with $ at position ${r.pos}`);
2969
+ this.expect("PIPE", "Expected '|' after label name");
2970
+ return {
2971
+ type: "Label",
2972
+ name: e,
2973
+ body: this.parseExpr()
2974
+ };
2975
+ }
2976
+ if (this.match("BREAK")) {
2977
+ let r = this.expect("IDENT", "Expected label name to break to"), e = r.value;
2978
+ if (!e.startsWith("$")) throw new Error(`Break label must start with $ at position ${r.pos}`);
2979
+ return {
2980
+ type: "Break",
2981
+ name: e
2982
+ };
2983
+ }
2984
+ if (this.match("DEF")) {
2985
+ let e = this.expect("IDENT", "Expected function name after def").value, n = [];
2986
+ if (this.match("LPAREN")) {
2987
+ if (!this.check("RPAREN")) {
2988
+ let u = this.expect("IDENT", "Expected parameter name");
2989
+ for (n.push(u.value); this.match("SEMICOLON");) {
2990
+ let c = this.expect("IDENT", "Expected parameter name");
2991
+ n.push(c.value);
2992
+ }
2993
+ }
2994
+ this.expect("RPAREN", "Expected ')' after parameters");
2995
+ }
2996
+ this.expect("COLON", "Expected ':' after function name");
2997
+ let p = this.parseExpr();
2998
+ this.expect("SEMICOLON", "Expected ';' after function body");
2999
+ return {
3000
+ type: "Def",
3001
+ name: e,
3002
+ params: n,
3003
+ funcBody: p,
3004
+ body: this.parseExpr()
3005
+ };
3006
+ }
3007
+ if (this.match("NOT")) return {
3008
+ type: "Call",
3009
+ name: "not",
3010
+ args: []
3011
+ };
3012
+ if (this.check("IDENT")) {
3013
+ let e = this.advance().value;
3014
+ if (e.startsWith("$")) return {
3015
+ type: "VarRef",
3016
+ name: e
3017
+ };
3018
+ if (this.match("LPAREN")) {
3019
+ let n = [];
3020
+ if (!this.check("RPAREN")) for (n.push(this.parseExpr()); this.match("SEMICOLON");) n.push(this.parseExpr());
3021
+ return this.expect("RPAREN", "Expected ')'"), {
3022
+ type: "Call",
3023
+ name: e,
3024
+ args: n
3025
+ };
3026
+ }
3027
+ return {
3028
+ type: "Call",
3029
+ name: e,
3030
+ args: []
3031
+ };
3032
+ }
3033
+ throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);
3034
+ }
3035
+ parseObjectConstruction() {
3036
+ let r = [];
3037
+ if (!this.check("RBRACE")) do {
3038
+ let e, n;
3039
+ if (this.match("LPAREN")) e = this.parseExpr(), this.expect("RPAREN", "Expected ')'"), this.expect("COLON", "Expected ':'"), n = this.parseObjectValue();
3040
+ else if (this.isIdentLike()) {
3041
+ let p = this.advance().value;
3042
+ this.match("COLON") ? (e = p, n = this.parseObjectValue()) : (e = p, n = {
3043
+ type: "Field",
3044
+ name: p
3045
+ });
3046
+ } else if (this.check("STRING")) e = this.advance().value, this.expect("COLON", "Expected ':'"), n = this.parseObjectValue();
3047
+ else throw new Error(`Expected object key at position ${this.peek().pos}`);
3048
+ r.push({
3049
+ key: e,
3050
+ value: n
3051
+ });
3052
+ } while (this.match("COMMA"));
3053
+ return this.expect("RBRACE", "Expected '}'"), {
3054
+ type: "Object",
3055
+ entries: r
3056
+ };
3057
+ }
3058
+ parseObjectValue() {
3059
+ let r = this.parseVarBind();
3060
+ for (; this.match("PIPE");) {
3061
+ let e = this.parseVarBind();
3062
+ r = {
3063
+ type: "Pipe",
3064
+ left: r,
3065
+ right: e
3066
+ };
3067
+ }
3068
+ return r;
3069
+ }
3070
+ parseIf() {
3071
+ let r = this.parseExpr();
3072
+ this.expect("THEN", "Expected 'then'");
3073
+ let e = this.parseExpr(), n = [];
3074
+ for (; this.match("ELIF");) {
3075
+ let o = this.parseExpr();
3076
+ this.expect("THEN", "Expected 'then' after elif");
3077
+ let u = this.parseExpr();
3078
+ n.push({
3079
+ cond: o,
3080
+ then: u
3081
+ });
3082
+ }
3083
+ let p;
3084
+ return this.match("ELSE") && (p = this.parseExpr()), this.expect("END", "Expected 'end'"), {
3085
+ type: "Cond",
3086
+ cond: r,
3087
+ then: e,
3088
+ elifs: n,
3089
+ else: p
3090
+ };
3091
+ }
3092
+ parseStringInterpolation(r) {
3093
+ let e = [], n = "", p = 0;
3094
+ for (; p < r.length;) if (r[p] === "\\" && r[p + 1] === "(") {
3095
+ n && (e.push(n), n = ""), p += 2;
3096
+ let o = 1, u = "";
3097
+ for (; p < r.length && o > 0;) r[p] === "(" ? o++ : r[p] === ")" && o--, o > 0 && (u += r[p]), p++;
3098
+ let s = new t(Et(u));
3099
+ e.push(s.parse());
3100
+ } else n += r[p], p++;
3101
+ return n && e.push(n), {
3102
+ type: "StringInterp",
3103
+ parts: e
3104
+ };
3105
+ }
3106
+ };
3107
+ function Ne(t) {
3108
+ return new ut(Et(t)).parse();
3109
+ }
3110
+ //#endregion
3111
+ export { d as n, Ne as t };
3112
+
3113
+ //# sourceMappingURL=chunk-LEKBROJD-CJMrAyu9.mjs.map