just-bash 2.12.4 → 2.12.5
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.
- package/dist/bin/chunks/{awk2-RGDNV4HO.js → awk2-4MK3F3NZ.js} +1 -1
- package/dist/bin/{shell/chunks/chmod-4O2C4V42.js → chunks/chmod-N5CQATDW.js} +1 -1
- package/dist/bin/chunks/chunk-2HDH5VPF.js +12 -0
- package/dist/bin/chunks/{chunk-LHN3LRVT.js → chunk-5ATRLST6.js} +20 -20
- package/dist/bin/chunks/{chunk-Q3FNZYGG.js → chunk-6W7JTG6A.js} +1 -1
- package/dist/bin/chunks/chunk-7ADG3DNO.js +8 -0
- package/dist/bin/chunks/{chunk-55QIFSKH.js → chunk-DERQIX2O.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-Q4WHWGOT.js → chunks/chunk-EMSJEY2U.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-PWZZGTFL.js → chunks/chunk-LWKIHJ5L.js} +1 -1
- package/dist/bin/chunks/chunk-MY5PY2PL.js +2 -0
- package/dist/bin/chunks/{chunk-OKL2SPHK.js → chunk-O5B6WWQQ.js} +39 -39
- package/dist/bin/chunks/chunk-OQV5J23L.js +7 -0
- package/dist/bin/chunks/chunk-Q5MYEU7X.js +5 -0
- package/dist/bin/chunks/chunk-QZNF3Y3J.js +2 -0
- package/dist/bin/chunks/chunk-R2LDP472.js +8 -0
- package/dist/bin/chunks/{chunk-DGFDVZ4N.js → chunk-RDGXTKIB.js} +1 -1
- package/dist/bin/chunks/chunk-RS2PRILS.js +10 -0
- package/dist/bin/chunks/chunk-STOAUD75.js +11 -0
- package/dist/bin/chunks/chunk-SXB55JOI.js +2 -0
- package/dist/bin/chunks/chunk-UT6LUTWP.js +2 -0
- package/dist/bin/chunks/{chunk-SY2WM5RM.js → chunk-VIYJJTN2.js} +5 -5
- package/dist/bin/{shell/chunks/chunk-V7VIJQD6.js → chunks/chunk-W752QGNZ.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-J4WYAO5Q.js → chunks/chunk-WWVVJW3F.js} +13 -13
- package/dist/bin/{shell/chunks/chunk-GA6KXSOC.js → chunks/chunk-YFPDB4PH.js} +1 -1
- package/dist/bin/chunks/chunk-YMMJLYIX.js +2 -0
- package/dist/bin/chunks/chunk-YTIURC67.js +2 -0
- package/dist/bin/chunks/chunk-YWZOGBFE.js +9 -0
- package/dist/bin/chunks/chunk-YX7OOTPO.js +9 -0
- package/dist/bin/{shell/chunks/chunk-WO4B7WUT.js → chunks/chunk-ZRRNCS7N.js} +1 -1
- package/dist/bin/chunks/chunk-ZSVBYEY4.js +6 -0
- package/dist/bin/chunks/curl-GIQ5S66Y.js +26 -0
- package/dist/bin/{shell/chunks/expansion-TCB3WZP5.js → chunks/expansion-JBCP2CHQ.js} +1 -1
- package/dist/bin/chunks/find-MTLF23HX.js +2 -0
- package/dist/bin/chunks/flag-coverage-NDF6MQAO.js +2 -0
- package/dist/bin/{shell/chunks/grep-F3GT2VPG.js → chunks/grep-OZJTRD4D.js} +1 -1
- package/dist/bin/chunks/jq-F7FJ46VM.js +2 -0
- package/dist/bin/chunks/{ln-BEOFQJNP.js → ln-VAOSD4HK.js} +1 -1
- package/dist/bin/chunks/mkdir-CH7JGW4N.js +2 -0
- package/dist/bin/{shell/chunks/python3-JX5PXXTX.js → chunks/python3-QBGIYRFR.js} +7 -7
- package/dist/bin/chunks/{readlink-YNOUXNUY.js → readlink-BD5VFOC5.js} +1 -1
- package/dist/bin/chunks/rm-GWYJO4W7.js +2 -0
- package/dist/bin/chunks/sed-ENUQOCBB.js +2 -0
- package/dist/bin/chunks/sleep-5T34UFNF.js +2 -0
- package/dist/bin/chunks/{sqlite3-SJHZFBT2.js → sqlite3-4SBQACEE.js} +1 -1
- package/dist/bin/chunks/stat-XS2LXYS2.js +2 -0
- package/dist/bin/chunks/tar-3UIZ4IRM.js +2 -0
- package/dist/bin/chunks/time-GZSHCM77.js +2 -0
- package/dist/bin/chunks/timeout-7ECKKPNP.js +2 -0
- package/dist/bin/chunks/worker.js +74 -6
- package/dist/bin/chunks/{xan-BJ66NSYT.js → xan-5QTBTP4U.js} +1 -1
- package/dist/bin/chunks/yq-O5RSLLA3.js +2 -0
- package/dist/bin/just-bash.js +183 -183
- package/dist/bin/shell/chunks/{awk2-RGDNV4HO.js → awk2-4MK3F3NZ.js} +1 -1
- package/dist/bin/{chunks/chmod-4O2C4V42.js → shell/chunks/chmod-N5CQATDW.js} +1 -1
- package/dist/bin/shell/chunks/chunk-2HDH5VPF.js +12 -0
- package/dist/bin/shell/chunks/{chunk-LHN3LRVT.js → chunk-5ATRLST6.js} +20 -20
- package/dist/bin/shell/chunks/{chunk-Q3FNZYGG.js → chunk-6W7JTG6A.js} +1 -1
- package/dist/bin/shell/chunks/chunk-7ADG3DNO.js +8 -0
- package/dist/bin/shell/chunks/chunk-D64U2VGQ.js +2 -0
- package/dist/bin/shell/chunks/{chunk-55QIFSKH.js → chunk-DERQIX2O.js} +1 -1
- package/dist/bin/{chunks/chunk-Q4WHWGOT.js → shell/chunks/chunk-EMSJEY2U.js} +1 -1
- package/dist/bin/{chunks/chunk-PWZZGTFL.js → shell/chunks/chunk-LWKIHJ5L.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-OKL2SPHK.js → chunk-O5B6WWQQ.js} +39 -39
- package/dist/bin/shell/chunks/chunk-OQV5J23L.js +7 -0
- package/dist/bin/shell/chunks/chunk-Q5MYEU7X.js +5 -0
- package/dist/bin/shell/chunks/chunk-QZNF3Y3J.js +2 -0
- package/dist/bin/shell/chunks/chunk-R2LDP472.js +8 -0
- package/dist/bin/shell/chunks/{chunk-DGFDVZ4N.js → chunk-RDGXTKIB.js} +1 -1
- package/dist/bin/shell/chunks/chunk-RS2PRILS.js +10 -0
- package/dist/bin/shell/chunks/chunk-STOAUD75.js +11 -0
- package/dist/bin/shell/chunks/chunk-SXB55JOI.js +2 -0
- package/dist/bin/shell/chunks/chunk-UT6LUTWP.js +2 -0
- package/dist/bin/shell/chunks/{chunk-SY2WM5RM.js → chunk-VIYJJTN2.js} +5 -5
- package/dist/bin/{chunks/chunk-V7VIJQD6.js → shell/chunks/chunk-W752QGNZ.js} +1 -1
- package/dist/bin/{chunks/chunk-J4WYAO5Q.js → shell/chunks/chunk-WWVVJW3F.js} +13 -13
- package/dist/bin/{chunks/chunk-GA6KXSOC.js → shell/chunks/chunk-YFPDB4PH.js} +1 -1
- package/dist/bin/shell/chunks/chunk-YMMJLYIX.js +2 -0
- package/dist/bin/shell/chunks/chunk-YTIURC67.js +2 -0
- package/dist/bin/shell/chunks/chunk-YWZOGBFE.js +9 -0
- package/dist/bin/shell/chunks/chunk-YX7OOTPO.js +9 -0
- package/dist/bin/{chunks/chunk-WO4B7WUT.js → shell/chunks/chunk-ZRRNCS7N.js} +1 -1
- package/dist/bin/shell/chunks/chunk-ZSVBYEY4.js +6 -0
- package/dist/bin/shell/chunks/curl-GIQ5S66Y.js +26 -0
- package/dist/bin/{chunks/expansion-TCB3WZP5.js → shell/chunks/expansion-JBCP2CHQ.js} +1 -1
- package/dist/bin/shell/chunks/find-MTLF23HX.js +2 -0
- package/dist/bin/shell/chunks/flag-coverage-NDF6MQAO.js +2 -0
- package/dist/bin/{chunks/grep-F3GT2VPG.js → shell/chunks/grep-OZJTRD4D.js} +1 -1
- package/dist/bin/shell/chunks/jq-F7FJ46VM.js +2 -0
- package/dist/bin/shell/chunks/{ln-BEOFQJNP.js → ln-VAOSD4HK.js} +1 -1
- package/dist/bin/shell/chunks/mkdir-CH7JGW4N.js +2 -0
- package/dist/bin/{chunks/python3-JX5PXXTX.js → shell/chunks/python3-XN7O5X3A.js} +7 -7
- package/dist/bin/shell/chunks/{readlink-YNOUXNUY.js → readlink-BD5VFOC5.js} +1 -1
- package/dist/bin/shell/chunks/rm-GWYJO4W7.js +2 -0
- package/dist/bin/shell/chunks/sed-ENUQOCBB.js +2 -0
- package/dist/bin/shell/chunks/sleep-5T34UFNF.js +2 -0
- package/dist/bin/shell/chunks/{sqlite3-SJHZFBT2.js → sqlite3-4SBQACEE.js} +1 -1
- package/dist/bin/shell/chunks/stat-XS2LXYS2.js +2 -0
- package/dist/bin/shell/chunks/tar-3UIZ4IRM.js +2 -0
- package/dist/bin/shell/chunks/time-GZSHCM77.js +2 -0
- package/dist/bin/shell/chunks/timeout-7ECKKPNP.js +2 -0
- package/dist/bin/shell/chunks/{xan-BJ66NSYT.js → xan-5QTBTP4U.js} +1 -1
- package/dist/bin/shell/chunks/yq-O5RSLLA3.js +2 -0
- package/dist/bin/shell/shell.js +187 -187
- package/dist/bundle/browser.js +627 -630
- package/dist/bundle/chunks/{awk2-XLDR2J4Q.js → awk2-ID6QVUYU.js} +1 -1
- package/dist/bundle/chunks/{chmod-MIKE3OIT.js → chmod-SYMGL4JA.js} +1 -1
- package/dist/bundle/chunks/chunk-2OZNLYX4.js +9 -0
- package/dist/bundle/chunks/{chunk-K5BTXJQC.js → chunk-3J4BCKUH.js} +1 -1
- package/dist/bundle/chunks/chunk-3ZBKQKTX.js +11 -0
- package/dist/bundle/chunks/chunk-3ZUFRYJ4.js +1 -0
- package/dist/bundle/chunks/chunk-4GTNDTRF.js +7 -0
- package/dist/bundle/chunks/chunk-5QVNJEHU.js +8 -0
- package/dist/bundle/chunks/chunk-64CW2LGZ.js +6 -0
- package/dist/bundle/chunks/{chunk-2OHMPZNZ.js → chunk-AYQ5FKKK.js} +1 -1
- package/dist/bundle/chunks/{chunk-VYV3YE2F.js → chunk-C764MECG.js} +1 -1
- package/dist/bundle/chunks/{chunk-N4QLRJ32.js → chunk-CBAJ47B3.js} +1 -1
- package/dist/bundle/chunks/chunk-D2FZX7A2.js +10 -0
- package/dist/bundle/chunks/{chunk-KAZYKNBG.js → chunk-EX62JIX3.js} +5 -5
- package/dist/bundle/chunks/chunk-FD7SFJNJ.js +4 -0
- package/dist/bundle/chunks/chunk-FGALERPA.js +8 -0
- package/dist/bundle/chunks/chunk-HJWBQKYG.js +5 -0
- package/dist/bundle/chunks/{chunk-H4QOE4W3.js → chunk-HOFSUCIB.js} +20 -20
- package/dist/bundle/chunks/chunk-IP7G3BNA.js +7 -0
- package/dist/bundle/chunks/chunk-J642UCRS.js +1 -0
- package/dist/bundle/chunks/{chunk-T2EHE3CV.js → chunk-L75XCEQX.js} +1 -1
- package/dist/bundle/chunks/{chunk-DOTBQEPN.js → chunk-QI4EPYAT.js} +1 -1
- package/dist/bundle/chunks/{chunk-TBAWQWQB.js → chunk-R5XRHEZH.js} +1 -1
- package/dist/bundle/chunks/chunk-RH6GWZAJ.js +1 -0
- package/dist/bundle/chunks/chunk-SJ5LXPUH.js +1 -0
- package/dist/bundle/chunks/{chunk-4VCAQZKQ.js → chunk-TRD56HID.js} +39 -39
- package/dist/bundle/chunks/{chunk-NTP6TTH5.js → chunk-TVHAURH5.js} +13 -13
- package/dist/bundle/chunks/chunk-X2AJGDEF.js +1 -0
- package/dist/bundle/chunks/chunk-XHM67O4N.js +1 -0
- package/dist/bundle/chunks/{chunk-CYTBPLPE.js → chunk-YS3AZT3J.js} +1 -1
- package/dist/bundle/chunks/curl-743M564K.js +25 -0
- package/dist/bundle/chunks/{expansion-HJ6B4DDG.js → expansion-XG7G47TX.js} +1 -1
- package/dist/bundle/chunks/find-DOIVMX6X.js +1 -0
- package/dist/bundle/chunks/flag-coverage-4M54QHNZ.js +1 -0
- package/dist/bundle/chunks/{grep-LXKUQUAE.js → grep-3AIAIJVR.js} +1 -1
- package/dist/bundle/chunks/jq-5FRYP6YP.js +1 -0
- package/dist/bundle/chunks/{ln-RI2SJGXU.js → ln-UJ6YJVBK.js} +1 -1
- package/dist/bundle/chunks/mkdir-F6XHPXZC.js +1 -0
- package/dist/bundle/chunks/{python3-TSPOVUHX.js → python3-WANWDR22.js} +7 -7
- package/dist/bundle/chunks/{readlink-IEQO24KU.js → readlink-MI4GCHJF.js} +1 -1
- package/dist/bundle/chunks/rm-FYNVTQIU.js +1 -0
- package/dist/bundle/chunks/sed-TS7M7I25.js +1 -0
- package/dist/bundle/chunks/sleep-RRZXXEW2.js +1 -0
- package/dist/bundle/chunks/{sqlite3-CTI4ZW7L.js → sqlite3-IH5QMEIK.js} +1 -1
- package/dist/bundle/chunks/stat-BT5A227F.js +1 -0
- package/dist/bundle/chunks/tar-JCULQ5J2.js +1 -0
- package/dist/bundle/chunks/time-XL42Z4U5.js +1 -0
- package/dist/bundle/chunks/timeout-DNGO7OHT.js +1 -0
- package/dist/bundle/chunks/worker.js +74 -6
- package/dist/bundle/chunks/{xan-VMLUNIDS.js → xan-LAW2EMOM.js} +1 -1
- package/dist/bundle/chunks/yq-MFJEXB7R.js +1 -0
- package/dist/bundle/index.cjs +852 -855
- package/dist/bundle/index.js +246 -246
- package/dist/commands/duration.d.ts +5 -0
- package/dist/commands/format-mode.d.ts +4 -0
- package/dist/commands/sed/types.d.ts +0 -4
- package/dist/commands/tar/archive.d.ts +18 -4
- package/dist/fs/in-memory-fs/in-memory-fs.d.ts +0 -3
- package/dist/fs/mountable-fs/mountable-fs.d.ts +0 -4
- package/dist/fs/overlay-fs/overlay-fs.d.ts +6 -7
- package/dist/fs/path-utils.d.ts +46 -0
- package/dist/fs/read-write-fs/read-write-fs.d.ts +0 -4
- package/dist/fs/real-fs-utils.d.ts +17 -11
- package/dist/timers.d.ts +0 -3
- package/package.json +34 -33
- package/vendor/cpython-emscripten/python.wasm +0 -0
- package/dist/bin/chunks/chunk-253LRF5J.js +0 -11
- package/dist/bin/chunks/chunk-4C4F4EKM.js +0 -2
- package/dist/bin/chunks/chunk-5VFN7VVJ.js +0 -9
- package/dist/bin/chunks/chunk-6MF2IYQX.js +0 -10
- package/dist/bin/chunks/chunk-D2GFNFUN.js +0 -7
- package/dist/bin/chunks/chunk-EO5AH4U7.js +0 -5
- package/dist/bin/chunks/chunk-GIFF636B.js +0 -2
- package/dist/bin/chunks/chunk-KWLLB7S3.js +0 -7
- package/dist/bin/chunks/chunk-NDP6L74Z.js +0 -10
- package/dist/bin/chunks/chunk-V5YFCVCZ.js +0 -12
- package/dist/bin/chunks/chunk-WMYKQURM.js +0 -2
- package/dist/bin/chunks/chunk-XAL6VWGA.js +0 -9
- package/dist/bin/chunks/chunk-YYQ22ZRL.js +0 -8
- package/dist/bin/chunks/curl-RWQO3SBN.js +0 -26
- package/dist/bin/chunks/find-4YAO7JQS.js +0 -2
- package/dist/bin/chunks/flag-coverage-K6IBGWAC.js +0 -2
- package/dist/bin/chunks/jq-VBB2XIZS.js +0 -2
- package/dist/bin/chunks/mkdir-6OKMS3KO.js +0 -2
- package/dist/bin/chunks/rm-5QIBTLJG.js +0 -2
- package/dist/bin/chunks/sed-BYFYBR4A.js +0 -2
- package/dist/bin/chunks/sleep-E3K6M6BN.js +0 -2
- package/dist/bin/chunks/stat-XH7E4E2C.js +0 -2
- package/dist/bin/chunks/tar-W5GBTEDZ.js +0 -2
- package/dist/bin/chunks/time-AWAKKRSE.js +0 -2
- package/dist/bin/chunks/timeout-OLS72AZG.js +0 -2
- package/dist/bin/chunks/yq-GPYVGU2N.js +0 -2
- package/dist/bin/shell/chunks/chunk-253LRF5J.js +0 -11
- package/dist/bin/shell/chunks/chunk-4C4F4EKM.js +0 -2
- package/dist/bin/shell/chunks/chunk-5VFN7VVJ.js +0 -9
- package/dist/bin/shell/chunks/chunk-6MF2IYQX.js +0 -10
- package/dist/bin/shell/chunks/chunk-D2GFNFUN.js +0 -7
- package/dist/bin/shell/chunks/chunk-EO5AH4U7.js +0 -5
- package/dist/bin/shell/chunks/chunk-GIFF636B.js +0 -2
- package/dist/bin/shell/chunks/chunk-KWLLB7S3.js +0 -7
- package/dist/bin/shell/chunks/chunk-NDP6L74Z.js +0 -10
- package/dist/bin/shell/chunks/chunk-V5YFCVCZ.js +0 -12
- package/dist/bin/shell/chunks/chunk-WMYKQURM.js +0 -2
- package/dist/bin/shell/chunks/chunk-XAL6VWGA.js +0 -9
- package/dist/bin/shell/chunks/chunk-YYQ22ZRL.js +0 -8
- package/dist/bin/shell/chunks/curl-RWQO3SBN.js +0 -26
- package/dist/bin/shell/chunks/find-4YAO7JQS.js +0 -2
- package/dist/bin/shell/chunks/flag-coverage-K6IBGWAC.js +0 -2
- package/dist/bin/shell/chunks/jq-VBB2XIZS.js +0 -2
- package/dist/bin/shell/chunks/mkdir-6OKMS3KO.js +0 -2
- package/dist/bin/shell/chunks/rm-5QIBTLJG.js +0 -2
- package/dist/bin/shell/chunks/sed-BYFYBR4A.js +0 -2
- package/dist/bin/shell/chunks/sleep-E3K6M6BN.js +0 -2
- package/dist/bin/shell/chunks/stat-XH7E4E2C.js +0 -2
- package/dist/bin/shell/chunks/tar-W5GBTEDZ.js +0 -2
- package/dist/bin/shell/chunks/time-AWAKKRSE.js +0 -2
- package/dist/bin/shell/chunks/timeout-OLS72AZG.js +0 -2
- package/dist/bin/shell/chunks/yq-GPYVGU2N.js +0 -2
- package/dist/bundle/chunks/chunk-27LMNKBP.js +0 -7
- package/dist/bundle/chunks/chunk-3RCXHB4E.js +0 -4
- package/dist/bundle/chunks/chunk-GENDESYN.js +0 -1
- package/dist/bundle/chunks/chunk-GZ2N3SXD.js +0 -8
- package/dist/bundle/chunks/chunk-IJXFPKNC.js +0 -1
- package/dist/bundle/chunks/chunk-IKZ5LEGB.js +0 -6
- package/dist/bundle/chunks/chunk-OFJTSXN6.js +0 -8
- package/dist/bundle/chunks/chunk-QUME7R6S.js +0 -9
- package/dist/bundle/chunks/chunk-W42IGK5R.js +0 -11
- package/dist/bundle/chunks/chunk-WAN3B6E3.js +0 -9
- package/dist/bundle/chunks/chunk-XZ3MZS57.js +0 -6
- package/dist/bundle/chunks/chunk-YCABLDKV.js +0 -10
- package/dist/bundle/chunks/chunk-ZK6J6F7O.js +0 -1
- package/dist/bundle/chunks/curl-6L7YZUIH.js +0 -25
- package/dist/bundle/chunks/find-DQFMWHAC.js +0 -1
- package/dist/bundle/chunks/flag-coverage-VGF5NAZP.js +0 -1
- package/dist/bundle/chunks/jq-JQXAVWNT.js +0 -1
- package/dist/bundle/chunks/mkdir-QWGXDWUS.js +0 -1
- package/dist/bundle/chunks/rm-KPTLPKPH.js +0 -1
- package/dist/bundle/chunks/sed-CJFW7UYO.js +0 -1
- package/dist/bundle/chunks/sleep-TFDNFOXK.js +0 -1
- package/dist/bundle/chunks/stat-74KBZFAX.js +0 -1
- package/dist/bundle/chunks/tar-Y6LP5EBC.js +0 -1
- package/dist/bundle/chunks/time-WBKSMCJ6.js +0 -1
- package/dist/bundle/chunks/timeout-O7WSXY5H.js +0 -1
- package/dist/bundle/chunks/yq-QXIYE3MW.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as f}from"./chunk-SYG3IW7P.js";import{a as d}from"./chunk-JBABAK44.js";import{a as l}from"./chunk-4VDEBYW7.js";var p={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},b={name:"mkdir",async execute(m,t){let e=d("mkdir",m,p);if(!e.ok)return e.error;let u=e.result.flags.recursive,g=e.result.flags.verbose,n=e.result.positional;if(n.length===0)return{stdout:"",stderr:`mkdir: missing operand
|
|
3
|
+
`,exitCode:1};let a="",o="",c=0;for(let r of n)try{let i=t.fs.resolvePath(t.cwd,r);await t.fs.mkdir(i,{recursive:u}),g&&(a+=`mkdir: created directory '${r}'
|
|
4
|
+
`)}catch(i){let s=l(i);s.includes("ENOENT")||s.includes("no such file")?o+=`mkdir: cannot create directory '${r}': No such file or directory
|
|
5
|
+
`:s.includes("EEXIST")||s.includes("already exists")?o+=`mkdir: cannot create directory '${r}': File exists
|
|
6
|
+
`:o+=`mkdir: cannot create directory '${r}': ${f(s)}
|
|
7
|
+
`,c=1}return{stdout:a,stderr:o,exitCode:c}}},h={name:"mkdir",flags:[{flag:"-p",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0};export{b as a,h as b};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as h}from"./chunk-KGOUQS5A.js";function v(){let u=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables",allowedKeys:new Set(["NODE_V8_COVERAGE","NODE_DEBUG","NODE_DEBUG_NATIVE","NODE_COMPILE_CACHE","WATCH_REPORT_DEPENDENCIES","FORCE_COLOR","DEBUG","UNDICI_NO_FG","JEST_WORKER_ID","__MINIMATCH_TESTING_PLATFORM__","LOG_TOKENS","LOG_STREAM"])},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"getBuiltinModule",target:process,violationType:"process_get_builtin_module",strategy:"throw",reason:"process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)"},{prop:"exit",target:process,violationType:"process_exit",strategy:"throw",reason:"process.exit could terminate the interpreter"},{prop:"abort",target:process,violationType:"process_exit",strategy:"throw",reason:"process.abort could crash the interpreter"},{prop:"kill",target:process,violationType:"process_kill",strategy:"throw",reason:"process.kill could signal other processes"},{prop:"setuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setuid could escalate privileges"},{prop:"setgid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgid could escalate privileges"},{prop:"umask",target:process,violationType:"process_umask",strategy:"throw",reason:"process.umask could modify file creation permissions"},{prop:"argv",target:process,violationType:"process_argv",strategy:"throw",reason:"process.argv may contain secrets in CLI arguments"},{prop:"cwd",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.cwd could disclose real host working directory path"},{prop:"chdir",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.chdir could confuse the interpreter's CWD tracking"},{prop:"send",target:process,violationType:"process_send",strategy:"throw",reason:"process.send could communicate with parent process in IPC contexts"},{prop:"channel",target:process,violationType:"process_channel",strategy:"throw",reason:"process.channel could access IPC channel to parent process"},{prop:"cpuUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.cpuUsage could enable timing side-channel attacks"},{prop:"memoryUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.memoryUsage could enable timing side-channel attacks"},{prop:"hrtime",target:process,violationType:"process_timing",strategy:"throw",reason:"process.hrtime could enable timing side-channel attacks"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"},{prop:"performance",target:globalThis,violationType:"performance_timing",strategy:"throw",reason:"performance.now() provides sub-millisecond timing for side-channel attacks"},{prop:"stdout",target:process,violationType:"process_stdout",strategy:"throw",reason:"process.stdout could bypass interpreter output to write to host stdout"},{prop:"stderr",target:process,violationType:"process_stderr",strategy:"throw",reason:"process.stderr could bypass interpreter output to write to host stderr"},{prop:"__defineGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineGetter__ allows prototype pollution via getter injection"},{prop:"__defineSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineSetter__ allows prototype pollution via setter injection"},{prop:"__lookupGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupGetter__ enables introspection for prototype pollution attacks"},{prop:"__lookupSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupSetter__ enables introspection for prototype pollution attacks"},{prop:"JSON",target:globalThis,violationType:"json_mutation",strategy:"freeze",reason:"Freeze JSON to prevent mutation of parsing/serialization"},{prop:"Math",target:globalThis,violationType:"math_mutation",strategy:"freeze",reason:"Freeze Math to prevent mutation of math utilities"}];try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&u.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&u.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let e=Object.getPrototypeOf(async function*(){}).constructor;e&&e!==Function&&e!==Object.getPrototypeOf(async()=>{}).constructor&&u.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return u.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}})}var f=typeof __BROWSER__<"u"&&__BROWSER__;function _(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,u=>{let e=Math.random()*16|0;return(u==="x"?e:e&3|8).toString(16)})}var x=null;if(!f)try{let{AsyncLocalStorage:u}=h("node:async_hooks");x=u}catch{}var k=`
|
|
3
|
+
|
|
4
|
+
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,p=class extends Error{violation;constructor(e,t){super(e+k),this.violation=t,this.name="SecurityViolationError"}},l=!f&&x?new x:null,T=1e3;function D(u,e,...t){return l.run(u,()=>e(...t))}var m={enabled:!0,auditMode:!1};function O(u){return u===void 0?{...m,enabled:!1}:typeof u=="boolean"?{...m,enabled:u}:{...m,...u}}var w=class u{static instance=null;static importHooksRegistered=!1;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(e){let t=O(e);if(!u.instance)u.instance=new u(t);else{let o=u.instance.config;if(t.enabled!==o.enabled||t.auditMode!==o.auditMode)throw new Error(`DefenseInDepthBox config conflict: requested {enabled: ${t.enabled}, auditMode: ${t.auditMode}} but singleton already has {enabled: ${o.enabled}, auditMode: ${o.auditMode}}. All Bash instances must use the same defense-in-depth security settings, or call DefenseInDepthBox.resetInstance() between incompatible configurations.`)}return u.instance}static resetInstance(){u.instance&&(u.instance.forceDeactivate(),u.instance=null)}static isInSandboxedContext(){return l?l?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(l)return l?.getStore()?.executionId}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let t=this.contextCache.get(e);return t||(t={sandboxActive:!0,executionId:e},this.contextCache.set(e,t)),t}getPreferredActiveExecutionId(){if(this.activeExecutionIds.size!==0)for(let e of this.activeExecutionIds)return e}static bindCurrentContext(e){if(!l)return e;let t=l.getStore(),o=t?.sandboxActive===!0?t.executionId:u.instance?.getPreferredActiveExecutionId();if(!o)return e;let s=u.instance?.getCachedContext(o)??{sandboxActive:!0,executionId:o};return D.bind(null,s,e)}isEnabled(){return this.config.enabled===!0&&l!==null&&!f}updateConfig(e){this.config={...this.config,...e}}activate(){if(f||!this.config.enabled||!l){let o=_(),s=!1;return{run:r=>s?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):r(),deactivate:()=>{s=!0},executionId:o}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let e=_(),t=!1;return{run:o=>t?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):(this.activeExecutionIds.add(e),l.run({sandboxActive:!0,executionId:e},o)),deactivate:()=>{t||(t=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`<object>.${t}`}static runTrusted(e){if(!l)return e();let t=l.getStore();return t?l.run({...t,trusted:!0},e):e()}static async runTrustedAsync(e){if(!l)return e();let t=l.getStore();return t?l.run({...t,trusted:!0},e):e()}shouldBlock(){if(f||this.config.auditMode||!l)return!1;let e=l?.getStore();return!(e?.sandboxActive!==!0||e.trusted)}recordViolation(e,t,o){let s={timestamp:Date.now(),type:e,message:o,path:t,stack:new Error().stack,executionId:l?.getStore()?.executionId};if(this.violations.length<T&&this.violations.push(s),this.config.onViolation)try{this.config.onViolation(s)}catch(r){console.debug("[DefenseInDepthBox] onViolation callback threw:",r instanceof Error?r.message:r)}return s}createBlockingProxy(e,t,o){let s=this;return new Proxy(e,{apply(r,n,i){if(s.shouldBlock()){let c=`${t} is blocked during script execution`,a=s.recordViolation(o,t,c);throw new p(c,a)}return s.config.auditMode&&l?.getStore()?.sandboxActive===!0&&s.recordViolation(o,t,`${t} called (audit mode)`),Reflect.apply(r,n,i)},construct(r,n,i){if(s.shouldBlock()){let c=`${t} constructor is blocked during script execution`,a=s.recordViolation(o,t,c);throw new p(c,a)}return s.config.auditMode&&l?.getStore()?.sandboxActive===!0&&s.recordViolation(o,t,`${t} constructor called (audit mode)`),Reflect.construct(r,n,i)}})}createBlockingObjectProxy(e,t,o,s){let r=this;return new Proxy(e,{get(n,i,c){if(r.shouldBlock()){if(s&&typeof i=="string"&&s.has(i))return Reflect.get(n,i,c);let a=`${t}.${String(i)}`,d=`${a} is blocked during script execution`,g=r.recordViolation(o,a,d);throw new p(d,g)}if(r.config.auditMode&&l?.getStore()?.sandboxActive===!0){let a=`${t}.${String(i)}`;r.recordViolation(o,a,`${a} accessed (audit mode)`)}return Reflect.get(n,i,c)},set(n,i,c,a){if(r.shouldBlock()){let d=`${t}.${String(i)}`,g=`${d} modification is blocked during script execution`,y=r.recordViolation(o,d,g);throw new p(g,y)}return Reflect.set(n,i,c,a)},ownKeys(n){if(r.shouldBlock()){let i=`${t} enumeration is blocked during script execution`,c=r.recordViolation(o,t,i);throw new p(i,c)}return Reflect.ownKeys(n)},getOwnPropertyDescriptor(n,i){if(r.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} descriptor access is blocked during script execution`,d=r.recordViolation(o,c,a);throw new p(a,d)}return Reflect.getOwnPropertyDescriptor(n,i)},has(n,i){if(r.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} existence check is blocked during script execution`,d=r.recordViolation(o,c,a);throw new p(a,d)}return Reflect.has(n,i)},deleteProperty(n,i){if(r.shouldBlock()){let c=`${t}.${String(i)}`,a=`${c} deletion is blocked during script execution`,d=r.recordViolation(o,c,a);throw new p(a,d)}return Reflect.deleteProperty(n,i)},setPrototypeOf(n,i){if(r.shouldBlock()){let c=`${t} setPrototypeOf is blocked during script execution`,a=r.recordViolation(o,t,c);throw new p(c,a)}return Reflect.setPrototypeOf(n,i)},defineProperty(n,i,c){if(r.shouldBlock()){let a=`${t}.${String(i)}`,d=`${a} defineProperty is blocked during script execution`,g=r.recordViolation(o,a,d);throw new p(d,g)}return Reflect.defineProperty(n,i,c)}})}applyPatches(){this.patchFailures=[];let e=v(),t=new Set(["process_send","process_channel","process_stdout","process_stderr"]);for(let r of e)t.has(r.violationType)||this.applyPatch(r);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath();let o=["Function.prototype.constructor","Module._load"],s=this.patchFailures.filter(r=>o.includes(r));if(s.length>0)throw this.restorePatches(),new Error(`DefenseInDepthBox: critical patches failed: ${s.join(", ")}`)}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(e){this.patchFailures.push("AsyncFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(e){this.patchFailures.push("GeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(e){this.patchFailures.push("AsyncGeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:t});let o=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return o},set(s){if(e.shouldBlock()){let r="Error.prepareStackTrace modification is blocked during script execution",n=e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",r);throw new p(r,n)}e.config.auditMode&&l?.getStore()?.sandboxActive===!0&&e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),o=s},configurable:!0})}catch(t){this.patchFailures.push("Error.prepareStackTrace"),console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",t instanceof Error?t.message:t)}}protectPromiseThen(){let e=this;try{let r=function(...n){return l.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation("promise_then_after_deactivate","Promise.then","Promise.then callback is blocked after defense deactivation"),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,n);if(this.kind==="fulfilled")return n[0];throw n[0]}return Reflect.apply(this.cb,void 0,n)})};var t=r;let o=Object.getOwnPropertyDescriptor(Promise.prototype,"then");this.originalDescriptors.push({target:Promise.prototype,prop:"then",descriptor:o});let s=o?.value;if(typeof s!="function")return;Object.defineProperty(Promise.prototype,"then",{value:function(i,c){if(!l)return Reflect.apply(s,this,[i,c]);let a=l.getStore(),d=a?.sandboxActive===!0&&a.trusted!==!0?a.executionId:void 0;if(!d)return Reflect.apply(s,this,[i,c]);let g=e.getCachedContext(d),y=(b,P)=>typeof b!="function"?b:r.bind({box:e,executionId:d,captured:g,cb:b,kind:P});return Reflect.apply(s,this,[y(i,"fulfilled"),y(c,"rejected")])},writable:!0,configurable:!0})}catch(o){this.patchFailures.push("Promise.prototype.then"),console.debug("[DefenseInDepthBox] Could not protect Promise.prototype.then:",o instanceof Error?o.message:o)}}patchPrototypeConstructor(e,t,o){let s=this;try{let r=Object.getOwnPropertyDescriptor(e,"constructor");this.originalDescriptors.push({target:e,prop:"constructor",descriptor:r});let n=r?.value;Object.defineProperty(e,"constructor",{get(){if(s.shouldBlock()){let i=`${t} access is blocked during script execution`,c=s.recordViolation(o,t,i);throw new p(i,c)}return s.config.auditMode&&l?.getStore()?.sandboxActive===!0&&s.recordViolation(o,t,`${t} accessed (audit mode)`),n},set(i){if(s.shouldBlock()){let c=`${t} modification is blocked during script execution`,a=s.recordViolation(o,t,c);throw new p(c,a)}Object.defineProperty(this,"constructor",{value:i,writable:!0,configurable:!0})},configurable:!0})}catch(r){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,r instanceof Error?r.message:r)}}protectProcessMainModule(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:t});let o=t?.value;o!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let s="process.mainModule access is blocked during script execution",r=e.recordViolation("process_main_module","process.mainModule",s);throw new p(s,r)}return e.config.auditMode&&l?.getStore()?.sandboxActive===!0&&e.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),o},set(s){if(e.shouldBlock()){let r="process.mainModule modification is blocked during script execution",n=e.recordViolation("process_main_module","process.mainModule",r);throw new p(r,n)}Object.defineProperty(process,"mainModule",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.mainModule"),console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",t instanceof Error?t.message:t)}}protectProcessExecPath(){if(typeof process>"u")return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,"execPath");this.originalDescriptors.push({target:process,prop:"execPath",descriptor:t});let o=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let s="process.execPath access is blocked during script execution",r=e.recordViolation("process_exec_path","process.execPath",s);throw new p(s,r)}return e.config.auditMode&&l?.getStore()?.sandboxActive===!0&&e.recordViolation("process_exec_path","process.execPath","process.execPath accessed (audit mode)"),o},set(s){if(e.shouldBlock()){let r="process.execPath modification is blocked during script execution",n=e.recordViolation("process_exec_path","process.execPath",r);throw new p(r,n)}Object.defineProperty(process,"execPath",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(t){this.patchFailures.push("process.execPath"),console.debug("[DefenseInDepthBox] Could not protect process.execPath:",t instanceof Error?t.message:t)}}protectDynamicImport(){if(!(f||u.importHooksRegistered))try{let e=h("node:module");if(typeof e.registerHooks=="function"){e.registerHooks({resolve(t,o,s){if(t.startsWith("data:")||t.startsWith("blob:"))throw new Error(`dynamic import of ${t.startsWith("data:")?"data:":"blob:"} URLs is blocked by defense-in-depth`);return s(t,o)}}),u.importHooksRegistered=!0;return}if(typeof e.register=="function"){let t=["export async function resolve(specifier, context, nextResolve) {",' if (specifier.startsWith("data:") || specifier.startsWith("blob:")) {',' throw new Error("dynamic import of " + (specifier.startsWith("data:") ? "data:" : "blob:") + " URLs is blocked by defense-in-depth");'," }"," return nextResolve(specifier, context);","}"].join(`
|
|
5
|
+
`);e.register(`data:text/javascript,${encodeURIComponent(t)}`),u.importHooksRegistered=!0}}catch(e){console.debug("[DefenseInDepthBox] Could not register import() hooks:",e instanceof Error?e.message:e)}}protectModuleLoad(){if(!f)try{let e=null;if(typeof process<"u"){let n=process.mainModule;n&&typeof n=="object"&&(e=n.constructor)}if(!e&&typeof h<"u"&&typeof h.main<"u"&&(e=h.main.constructor),!e||typeof e._load!="function")return;let t=e._load,o=Object.getOwnPropertyDescriptor(e,"_load");this.originalDescriptors.push({target:e,prop:"_load",descriptor:o});let r=this.createBlockingProxy(t,"Module._load","module_load");Object.defineProperty(e,"_load",{value:r,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._load"),console.debug("[DefenseInDepthBox] Could not protect Module._load:",e instanceof Error?e.message:e)}}protectModuleResolveFilename(){if(!f)try{let e=null;if(typeof process<"u"){let n=process.mainModule;n&&typeof n=="object"&&(e=n.constructor)}if(!e&&typeof h<"u"&&typeof h.main<"u"&&(e=h.main.constructor),!e||typeof e._resolveFilename!="function")return;let t=e._resolveFilename,o=Object.getOwnPropertyDescriptor(e,"_resolveFilename");this.originalDescriptors.push({target:e,prop:"_resolveFilename",descriptor:o});let r=this.createBlockingProxy(t,"Module._resolveFilename","module_resolve_filename");Object.defineProperty(e,"_resolveFilename",{value:r,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._resolveFilename"),console.debug("[DefenseInDepthBox] Could not protect Module._resolveFilename:",e instanceof Error?e.message:e)}}applyPatch(e){let{target:t,prop:o,violationType:s,strategy:r}=e;try{let n=t[o];if(n===void 0)return;let i=Object.getOwnPropertyDescriptor(t,o);if(this.originalDescriptors.push({target:t,prop:o,descriptor:i}),r==="freeze")typeof n=="object"&&n!==null&&Object.freeze(n);else{let c=this.getPathForTarget(t,o),a=typeof n=="function"?this.createBlockingProxy(n,c,s):this.createBlockingObjectProxy(n,c,s,e.allowedKeys);Object.defineProperty(t,o,{value:a,writable:!0,configurable:!0})}}catch(n){let i=this.getPathForTarget(t,o);this.patchFailures.push(i),console.debug(`[DefenseInDepthBox] Could not patch ${i}:`,n instanceof Error?n.message:n)}}restorePatches(){for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:t,prop:o,descriptor:s}=this.originalDescriptors[e];try{s?Object.defineProperty(t,o,s):delete t[o]}catch(r){let n=this.getPathForTarget(t,o);console.debug(`[DefenseInDepthBox] Could not restore ${n}:`,r instanceof Error?r.message:r)}}this.originalDescriptors=[]}};export{p as a,w as b};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as p}from"./chunk-SYG3IW7P.js";import{a as m}from"./chunk-JBABAK44.js";import{a as u}from"./chunk-4VDEBYW7.js";var v={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},E={name:"rm",async execute(g,s){let e=m("rm",g,v);if(!e.ok)return e.error;let i=e.result.flags.recursive||e.result.flags.recursiveUpper,a=e.result.flags.force,d=e.result.flags.verbose,c=e.result.positional;if(c.length===0)return a?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:`rm: missing operand
|
|
3
|
+
`,exitCode:1};let f="",t="",l=0;for(let r of c)try{let n=s.fs.resolvePath(s.cwd,r);if((await s.fs.stat(n)).isDirectory&&!i){t+=`rm: cannot remove '${r}': Is a directory
|
|
4
|
+
`,l=1;continue}await s.fs.rm(n,{recursive:i,force:a}),d&&(f+=`removed '${r}'
|
|
5
|
+
`)}catch(n){if(!a){let o=u(n);o.includes("ENOENT")||o.includes("no such file")?t+=`rm: cannot remove '${r}': No such file or directory
|
|
6
|
+
`:o.includes("ENOTEMPTY")||o.includes("not empty")?t+=`rm: cannot remove '${r}': Directory not empty
|
|
7
|
+
`:t+=`rm: cannot remove '${r}': ${p(o)}
|
|
8
|
+
`,l=1}}return{stdout:f,stderr:t,exitCode:l}}},$={name:"rm",flags:[{flag:"-r",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0};export{E as a,$ as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as de}from"./chunk-4PRVMER6.js";import{a as D,b as _}from"./chunk-
|
|
2
|
+
import{a as de}from"./chunk-4PRVMER6.js";import{a as D,b as _}from"./chunk-ZRRNCS7N.js";import{a as x}from"./chunk-Q5MYEU7X.js";import{a as A,b as H}from"./chunk-SE4C7FJY.js";import{k as P}from"./chunk-6KZRLMG3.js";import{a as pe,b as fe,c as re}from"./chunk-GTNBSMZR.js";var Ue=1e4,Be=100,He=new H(/\s+/);function ie(e={}){let{fieldSep:t=He,maxIterations:n=Ue,maxRecursionDepth:i=Be,maxOutputSize:s=0,fs:a,cwd:o,exec:l,coverage:u,requireDefenseContext:N}=e;return{FS:" ",OFS:" ",ORS:`
|
|
3
3
|
`,OFMT:"%.6g",NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:Object.create(null),arrays:Object.create(null),arrayAliases:new Map,ARGC:0,ARGV:Object.create(null),ENVIRON:Object.create(null),functions:new Map,fieldSep:t,maxIterations:n,maxRecursionDepth:i,maxOutputSize:s,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:"",openedFiles:new Set,fs:a,cwd:o,exec:l,coverage:u,requireDefenseContext:N}}function Ee(e,t,n){switch(n){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return t!==0?e/t:0;case"%":return t!==0?e%t:0;case"^":case"**":return e**t;default:return 0}}function M(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function k(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}async function z(e,t){if(e.type==="regex")return e.pattern;let n=k(await t.evalExpr(e));return n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)),n}async function ye(e,t){return e?e.type==="variable"?e.name:e.type==="field"?`$${Math.floor(M(await t.evalExpr(e.index)))}`:"$0":"$0"}function me(e,t){if(e==="$0")return t.line;if(e.startsWith("$")){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||""}return k(t.vars[e]??"")}function Se(e,t,n){if(e==="$0")n.line=t,n.fields=n.FS===" "?t.trim().split(/\s+/).filter(Boolean):n.fieldSep.split(t),n.NF=n.fields.length;else if(e.startsWith("$")){let i=parseInt(e.slice(1),10)-1;for(;n.fields.length<=i;)n.fields.push("");n.fields[i]=t,n.NF=n.fields.length,n.line=n.fields.join(n.OFS)}else n.vars[e]=t}async function $e(e,t,n){return e.length===0?t.line.length:k(await n.evalExpr(e[0])).length}async function We(e,t,n){if(e.length<2)return"";let i=k(await n.evalExpr(e[0])),s=Math.floor(M(await n.evalExpr(e[1])))-1;if(e.length>=3){let a=Math.floor(M(await n.evalExpr(e[2])));return i.substr(Math.max(0,s),a)}return i.substr(Math.max(0,s))}async function Ve(e,t,n){if(e.length<2)return 0;let i=k(await n.evalExpr(e[0])),s=k(await n.evalExpr(e[1])),a=i.indexOf(s);return a===-1?0:a+1}async function Ke(e,t,n){if(e.length<2)return 0;let i=k(await n.evalExpr(e[0])),s=e[1];if(s.type!=="variable")return 0;let a=s.name,o=t.FS;if(e.length>=3){let u=e[2];if(u.type==="regex")o=A(u.pattern);else{let N=k(await n.evalExpr(u));o=N===" "?A("\\s+"):N}}else t.FS===" "&&(o=A("\\s+"));let l=typeof o=="string"?i.split(o):o.split(i);t.arrays[a]=Object.create(null);for(let u=0;u<l.length;u++)t.arrays[a][String(u+1)]=l[u];return l.length}async function Xe(e,t,n){if(e.length<2)return 0;let i=await z(e[0],n),s=k(await n.evalExpr(e[1])),a=await ye(e[2],n),o=me(a,t);try{let u=A(i).replace(o,we(s)),N=u!==o?1:0;return Se(a,u,t),N}catch{return 0}}async function qe(e,t,n){if(e.length<2)return 0;let i=await z(e[0],n),s=k(await n.evalExpr(e[1])),a=await ye(e[2],n),o=me(a,t);try{let l=A(i,"g"),u=l.match(o),N=u?u.length:0,v=l.replace(o,we(s));return Se(a,v,t),N}catch{return 0}}function we(e){return t=>{let n="",i=0;for(;i<e.length;)if(e[i]==="\\"&&i+1<e.length){let s=e[i+1];s==="&"?(n+="&",i+=2):s==="\\"?(n+="\\",i+=2):(n+=e[i+1],i+=2)}else e[i]==="&"?(n+=t,i++):(n+=e[i],i++);return n}}async function ze(e,t,n){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let i=k(await n.evalExpr(e[0])),s=await z(e[1],n);try{let o=A(s).exec(i);if(o)return t.RSTART=o.index+1,t.RLENGTH=o[0].length,t.RSTART}catch{}return t.RSTART=0,t.RLENGTH=-1,0}async function je(e,t,n){if(e.length<3)return"";let i=await z(e[0],n),s=k(await n.evalExpr(e[1])),a=k(await n.evalExpr(e[2])),o=e.length>=4?k(await n.evalExpr(e[3])):t.line;try{let l=a.toLowerCase()==="g",u=l?0:parseInt(a,10)||1;if(l)return A(i,"g").replace(o,(v,...C)=>Ne(s,v,C.slice(0,-2)));{let N=0;return A(i,"g").replace(o,(C,...O)=>(N++,N===u?Ne(s,C,O.slice(0,-2)):C))}}catch{return o}}function Ne(e,t,n){let i="",s=0;for(;s<e.length;)if(e[s]==="\\"&&s+1<e.length){let a=e[s+1];if(a==="&")i+="&",s+=2;else if(a==="0")i+=t,s+=2;else if(a>="1"&&a<="9"){let o=parseInt(a,10)-1;i+=n[o]||"",s+=2}else a==="n"?(i+=`
|
|
4
4
|
`,s+=2):a==="t"?(i+=" ",s+=2):(i+=a,s+=2)}else e[s]==="&"?(i+=t,s++):(i+=e[s],s++);return i}async function Qe(e,t,n){return e.length===0?"":k(await n.evalExpr(e[0])).toLowerCase()}async function Je(e,t,n){return e.length===0?"":k(await n.evalExpr(e[0])).toUpperCase()}async function Ze(e,t,n){if(e.length===0)return"";let i=k(await n.evalExpr(e[0])),s=[];for(let a=1;a<e.length;a++)s.push(await n.evalExpr(e[a]));return j(i,s)}async function Ye(e,t,n){return e.length===0?0:Math.floor(M(await n.evalExpr(e[0])))}async function et(e,t,n){return e.length===0?0:Math.sqrt(M(await n.evalExpr(e[0])))}async function tt(e,t,n){return e.length===0?0:Math.sin(M(await n.evalExpr(e[0])))}async function nt(e,t,n){return e.length===0?0:Math.cos(M(await n.evalExpr(e[0])))}async function rt(e,t,n){let i=e.length>0?M(await n.evalExpr(e[0])):0,s=e.length>1?M(await n.evalExpr(e[1])):0;return Math.atan2(i,s)}async function it(e,t,n){return e.length===0?0:Math.log(M(await n.evalExpr(e[0])))}async function st(e,t,n){return e.length===0?1:Math.exp(M(await n.evalExpr(e[0])))}function at(e,t,n){return t.random?t.random():Math.random()}async function ot(e,t,n){let i=e.length>0?M(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=i,i}function lt(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function se(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}var U=1e4;function j(e,t){let n=0,i="",s=0;for(;s<e.length;)if(e[s]==="%"&&s+1<e.length){let a=s+1,o="",l="",u="",N,v=a;for(;a<e.length&&/\d/.test(e[a]);)a++;a>v&&e[a]==="$"?(N=parseInt(e.substring(v,a),10)-1,a++):a=v;let C=()=>{if(a<e.length){if(a+1<e.length&&(e[a]==="h"&&e[a+1]==="h"||e[a]==="l"&&e[a+1]==="l")){a+=2;return}/[lzjh]/.test(e[a])&&a++}};for(;a<e.length&&/[-+ #0]/.test(e[a]);)o+=e[a++];if(e[a]==="*"){let d=t[n++],R=d!==void 0?Math.floor(Number(d)):0;R<0?(o+="-",l=String(Math.min(-R,U))):l=String(Math.min(R,U)),a++}else for(;a<e.length&&/\d/.test(e[a]);)l+=e[a++];if(l&&parseInt(l,10)>U&&(l=String(U)),e[a]==="."){if(a++,e[a]==="*"){let d=t[n++];u=String(Math.min(d!==void 0?Math.floor(Number(d)):0,U)),a++}else for(;a<e.length&&/\d/.test(e[a]);)u+=e[a++];u&&parseInt(u,10)>U&&(u=String(U))}C();let O=e[a],w=t[N!==void 0?N:n];switch(O){case"s":{let d=w!==void 0?String(w):"";if(u&&(d=d.substring(0,parseInt(u,10))),l){let R=parseInt(l,10);o.includes("-")?d=d.padEnd(R):d=d.padStart(R)}i+=d,N===void 0&&n++;break}case"d":case"i":{let d=w!==void 0?Math.floor(Number(w)):0;Number.isNaN(d)&&(d=0);let R=d<0,h=Math.abs(d).toString();if(u){let F=parseInt(u,10);h=h.padStart(F,"0")}let c="";R?c="-":o.includes("+")?c="+":o.includes(" ")&&(c=" ");let E=c+h;if(l){let F=parseInt(l,10);o.includes("-")?E=E.padEnd(F):o.includes("0")&&!u?E=c+h.padStart(F-c.length,"0"):E=E.padStart(F)}i+=E,N===void 0&&n++;break}case"f":{let d=w!==void 0?Number(w):0;Number.isNaN(d)&&(d=0);let R=u?parseInt(u,10):6,h=d.toFixed(R);if(l){let c=parseInt(l,10);o.includes("-")?h=h.padEnd(c):h=h.padStart(c)}i+=h,N===void 0&&n++;break}case"e":case"E":{let d=w!==void 0?Number(w):0;Number.isNaN(d)&&(d=0);let R=u?parseInt(u,10):6,h=d.toExponential(R);if(O==="E"&&(h=h.toUpperCase()),l){let c=parseInt(l,10);o.includes("-")?h=h.padEnd(c):h=h.padStart(c)}i+=h,N===void 0&&n++;break}case"g":case"G":{let d=w!==void 0?Number(w):0;Number.isNaN(d)&&(d=0);let R=u?parseInt(u,10):6,h=d!==0?Math.floor(Math.log10(Math.abs(d))):0,c;if(d===0?c="0":h<-4||h>=R?(c=d.toExponential(R-1),O==="G"&&(c=c.toUpperCase())):c=d.toPrecision(R),c.includes(".")&&(c=c.replace(/\.?0+$/,"").replace(/\.?0+e/,"e")),c.includes("e")&&(c=c.replace(/\.?0+e/,"e")),l){let E=parseInt(l,10);o.includes("-")?c=c.padEnd(E):c=c.padStart(E)}i+=c,N===void 0&&n++;break}case"x":case"X":{let d=w!==void 0?Math.floor(Number(w)):0;Number.isNaN(d)&&(d=0);let R=Math.abs(d).toString(16);if(O==="X"&&(R=R.toUpperCase()),u){let E=parseInt(u,10);R=R.padStart(E,"0")}let h=d<0?"-":"",c=h+R;if(l){let E=parseInt(l,10);o.includes("-")?c=c.padEnd(E):o.includes("0")&&!u?c=h+R.padStart(E-h.length,"0"):c=c.padStart(E)}i+=c,N===void 0&&n++;break}case"o":{let d=w!==void 0?Math.floor(Number(w)):0;Number.isNaN(d)&&(d=0);let R=Math.abs(d).toString(8);if(u){let E=parseInt(u,10);R=R.padStart(E,"0")}let h=d<0?"-":"",c=h+R;if(l){let E=parseInt(l,10);o.includes("-")?c=c.padEnd(E):o.includes("0")&&!u?c=h+R.padStart(E-h.length,"0"):c=c.padStart(E)}i+=c,N===void 0&&n++;break}case"c":{typeof w=="number"?i+=String.fromCharCode(w):i+=String(w??"").charAt(0)||"",N===void 0&&n++;break}case"%":i+="%";break;default:i+=e.substring(s,a+1)}s=a+1}else if(e[s]==="\\"&&s+1<e.length){let a=e[s+1];switch(a){case"n":i+=`
|
|
5
5
|
`;break;case"t":i+=" ";break;case"r":i+="\r";break;case"\\":i+="\\";break;default:i+=a}s+=2}else i+=e[s++];return i}var Re=new Map([["length",$e],["substr",We],["index",Ve],["split",Ke],["sub",Xe],["gsub",qe],["match",ze],["gensub",je],["tolower",Qe],["toupper",Je],["sprintf",Ze],["int",Ye],["sqrt",et],["sin",tt],["cos",nt],["atan2",rt],["log",it],["exp",st],["rand",at],["srand",ot],["system",lt("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",se("systime")],["mktime",se("mktime")],["strftime",se("strftime")]]);function b(e){return typeof e=="number"?e!==0:!(e===""||e==="0")}function g(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function S(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}function ae(e){if(typeof e=="number")return!0;let t=String(e).trim();return t===""?!1:!Number.isNaN(Number(t))}function K(e,t){try{return A(e).test(t)}catch{return!1}}function ge(e,t){return t===""?[]:e.FS===" "?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function Q(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function oe(e,t,n){if(t===0)e.line=S(n),e.fields=ge(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push("");e.fields[t-1]=S(n),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function $(e,t){e.line=t,e.fields=ge(e,t),e.NF=e.fields.length}function ve(e,t){if(e.FS=t,t===" ")e.fieldSep=new H(/\s+/);else try{e.fieldSep=A(t)}catch{e.fieldSep=A(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}function J(e,t){switch(t){case"FS":return e.FS;case"OFS":return e.OFS;case"ORS":return e.ORS;case"OFMT":return e.OFMT;case"NR":return e.NR;case"NF":return e.NF;case"FNR":return e.FNR;case"FILENAME":return e.FILENAME;case"RSTART":return e.RSTART;case"RLENGTH":return e.RLENGTH;case"SUBSEP":return e.SUBSEP;case"ARGC":return e.ARGC}return e.vars[t]??""}function W(e,t,n){switch(t){case"FS":ve(e,S(n));return;case"OFS":e.OFS=S(n);return;case"ORS":e.ORS=S(n);return;case"OFMT":e.OFMT=S(n);return;case"NR":e.NR=Math.floor(g(n));return;case"NF":{let i=Math.floor(g(n));if(i<e.NF)e.fields=e.fields.slice(0,i),e.line=e.fields.join(e.OFS);else if(i>e.NF){for(;e.fields.length<i;)e.fields.push("");e.line=e.fields.join(e.OFS)}e.NF=i;return}case"FNR":e.FNR=Math.floor(g(n));return;case"FILENAME":e.FILENAME=S(n);return;case"RSTART":e.RSTART=Math.floor(g(n));return;case"RLENGTH":e.RLENGTH=Math.floor(g(n));return;case"SUBSEP":e.SUBSEP=S(n);return}e.vars[t]=n}function X(e,t){let n=t,i=new Set,s=e.arrayAliases.get(n);for(;s!==void 0&&!i.has(n);)i.add(n),n=s,s=e.arrayAliases.get(n);return n}function Z(e,t,n){if(t==="ARGV")return e.ARGV[n]??"";if(t==="ENVIRON")return e.ENVIRON[n]??"";let i=X(e,t);return e.arrays[i]?.[n]??""}function le(e,t,n,i){let s=X(e,t);e.arrays[s]||(e.arrays[s]=Object.create(null)),e.arrays[s][n]=i}function Ae(e,t,n){if(t==="ARGV")return e.ARGV[n]!==void 0;if(t==="ENVIRON")return e.ENVIRON[n]!==void 0;let i=X(e,t);return e.arrays[i]?.[n]!==void 0}function Ie(e,t,n){let i=X(e,t);e.arrays[i]&&delete e.arrays[i][n]}function ke(e,t){let n=X(e,t);delete e.arrays[n]}var Ce=null;function be(e){Ce=e}function L(e,t){D(e.requireDefenseContext,"awk",t)}function m(e,t,n){return _(e.requireDefenseContext,"awk",t,n)}async function f(e,t){switch(L(e,"expression evaluation"),e.coverage?.hit(`awk:expr:${t.type}`),t.type){case"number":return t.value;case"string":return t.value;case"regex":return K(t.pattern,e.line)?1:0;case"field":return ut(e,t);case"variable":return J(e,t.name);case"array_access":return ct(e,t);case"binary":return ht(e,t);case"unary":return dt(e,t);case"ternary":return b(await m(e,"ternary condition evaluation",()=>f(e,t.condition)))?await m(e,"ternary consequent evaluation",()=>f(e,t.consequent)):await m(e,"ternary alternate evaluation",()=>f(e,t.alternate));case"call":return Et(e,t.name,t.args);case"assignment":return yt(e,t);case"pre_increment":return mt(e,t.operand);case"pre_decrement":return St(e,t.operand);case"post_increment":return wt(e,t.operand);case"post_decrement":return Rt(e,t.operand);case"in":return gt(e,t.key,t.array);case"getline":return vt(e,t.variable,t.file,t.command);case"tuple":return kt(e,t.elements);default:return""}}async function ut(e,t){L(e,"field reference evaluation");let n=Math.floor(g(await m(e,"field index evaluation",()=>f(e,t.index))));return Q(e,n)}async function ct(e,t){L(e,"array access evaluation");let n=S(await m(e,"array key evaluation",()=>f(e,t.key)));return Z(e,t.array,n)}async function ht(e,t){L(e,"binary expression evaluation");let n=t.operator;if(n==="||")return b(await m(e,"logical-or left evaluation",()=>f(e,t.left)))||b(await m(e,"logical-or right evaluation",()=>f(e,t.right)))?1:0;if(n==="&&")return b(await m(e,"logical-and left evaluation",()=>f(e,t.left)))&&b(await m(e,"logical-and right evaluation",()=>f(e,t.right)))?1:0;if(n==="~"){let l=await m(e,"regex left evaluation",()=>f(e,t.left));t.right.type==="regex"&&e.coverage?.hit("awk:expr:regex");let u=t.right.type==="regex"?t.right.pattern:S(await m(e,"regex right evaluation",()=>f(e,t.right)));try{return A(u).test(S(l))?1:0}catch{return 0}}if(n==="!~"){let l=await m(e,"negated-regex left evaluation",()=>f(e,t.left));t.right.type==="regex"&&e.coverage?.hit("awk:expr:regex");let u=t.right.type==="regex"?t.right.pattern:S(await m(e,"negated-regex right evaluation",()=>f(e,t.right)));try{return A(u).test(S(l))?0:1}catch{return 1}}let i=await m(e,"binary left evaluation",()=>f(e,t.left)),s=await m(e,"binary right evaluation",()=>f(e,t.right));if(n===" "){let l=S(i)+S(s);if(e.maxOutputSize>0&&l.length>e.maxOutputSize)throw new P(`awk: string concatenation size limit exceeded (${e.maxOutputSize} bytes)`,"string_length",e.output);return l}if(pt(n))return ft(i,s,n);let a=g(i),o=g(s);return Ee(a,o,n)}function pt(e){return["<","<=",">",">=","==","!="].includes(e)}function ft(e,t,n){let i=ae(e),s=ae(t);if(i&&s){let l=g(e),u=g(t);switch(n){case"<":return l<u?1:0;case"<=":return l<=u?1:0;case">":return l>u?1:0;case">=":return l>=u?1:0;case"==":return l===u?1:0;case"!=":return l!==u?1:0}}let a=S(e),o=S(t);switch(n){case"<":return a<o?1:0;case"<=":return a<=o?1:0;case">":return a>o?1:0;case">=":return a>=o?1:0;case"==":return a===o?1:0;case"!=":return a!==o?1:0}return 0}async function dt(e,t){L(e,"unary expression evaluation");let n=await m(e,"unary operand evaluation",()=>f(e,t.operand));switch(t.operator){case"!":return b(n)?0:1;case"-":return-g(n);case"+":return+g(n);default:return n}}async function Et(e,t,n){L(e,"function call evaluation");let i=Re.get(t);if(i)return i(n,e,{evalExpr:a=>f(e,a)});let s=e.functions.get(t);return s?Nt(e,s,n):""}async function Nt(e,t,n){if(L(e,"user function call"),e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new P(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let i=Object.create(null);for(let l of t.params)i[l]=e.vars[l];let s=[];for(let l=0;l<t.params.length;l++){let u=t.params[l];if(l<n.length){let N=n[l];N.type==="variable"&&(e.arrayAliases.set(u,N.name),s.push(u));let v=await m(e,"user function argument evaluation",()=>f(e,N));e.vars[u]=v}else e.vars[u]=""}e.hasReturn=!1,e.returnValue=void 0;let a=Ce;a&&await m(e,"user function body execution",()=>a(e,t.body.statements));let o=e.returnValue??"";for(let l of t.params)i[l]!==void 0?e.vars[l]=i[l]:delete e.vars[l];for(let l of s)e.arrayAliases.delete(l);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,o}async function yt(e,t){L(e,"assignment evaluation");let n=await m(e,"assignment value evaluation",()=>f(e,t.value)),i=t.target,s=t.operator,a;if(s==="=")a=n;else{let o;if(i.type==="field"){let N=Math.floor(g(await m(e,"assignment field index",()=>f(e,i.index))));o=Q(e,N)}else if(i.type==="variable")o=J(e,i.name);else{let N=S(await m(e,"assignment array key",()=>f(e,i.key)));o=Z(e,i.array,N)}let l=g(o),u=g(n);switch(s){case"+=":a=l+u;break;case"-=":a=l-u;break;case"*=":a=l*u;break;case"/=":a=u!==0?l/u:0;break;case"%=":a=u!==0?l%u:0;break;case"^=":a=l**u;break;default:a=n}}if(i.type==="field"){let o=Math.floor(g(await m(e,"assignment target field index",()=>f(e,i.index))));oe(e,o,a)}else if(i.type==="variable")W(e,i.name,a);else{let o=S(await m(e,"assignment target array key",()=>f(e,i.key)));le(e,i.array,o,a)}return a}async function Y(e,t,n,i){L(e,"inc/dec evaluation");let s;if(t.type==="field"){let a=Math.floor(g(await m(e,"inc/dec field index",()=>f(e,t.index))));s=g(Q(e,a)),oe(e,a,s+n)}else if(t.type==="variable")s=g(J(e,t.name)),W(e,t.name,s+n);else{let a=S(await m(e,"inc/dec array key",()=>f(e,t.key)));s=g(Z(e,t.array,a)),le(e,t.array,a,s+n)}return i?s+n:s}async function mt(e,t){return Y(e,t,1,!0)}async function St(e,t){return Y(e,t,-1,!0)}async function wt(e,t){return Y(e,t,1,!1)}async function Rt(e,t){return Y(e,t,-1,!1)}async function gt(e,t,n){L(e,"in-expression evaluation");let i;if(t.type==="tuple"){e.coverage?.hit("awk:expr:tuple");let s=[];for(let a of t.elements)s.push(S(await m(e,"tuple key element evaluation",()=>f(e,a))));i=s.join(e.SUBSEP)}else i=S(await m(e,"in-expression key evaluation",()=>f(e,t)));return Ae(e,n,i)?1:0}async function vt(e,t,n,i){if(L(e,"getline evaluation"),i)return At(e,t,i);if(n)return It(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let s=e.lineIndex+1;if(s>=e.lines.length)return 0;let a=e.lines[s];return t?W(e,t,a):$(e,a),e.NR++,e.lineIndex=s,1}async function At(e,t,n){let i=e.exec;if(!i)return-1;L(e,"getline command source");let s=S(await m(e,"getline command expression",()=>f(e,n))),a=`__cmd_${s}`,o=`__cmdi_${s}`,l,u;if(e.vars[a]===void 0)try{l=(await m(e,"getline command exec",()=>i(s))).stdout.split(`
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as d}from"./chunk-YTIURC67.js";import{a as n,b as i}from"./chunk-UT6LUTWP.js";import{a,b as l}from"./chunk-GTNBSMZR.js";var u={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
|
|
3
|
+
s - seconds (default)
|
|
4
|
+
m - minutes
|
|
5
|
+
h - hours
|
|
6
|
+
d - days
|
|
7
|
+
|
|
8
|
+
NUMBER may be a decimal number.`,options:[" --help display this help and exit"]},m=36e5,h={name:"sleep",async execute(r,s){if(l(r))return a(u);if(r.length===0)return{stdout:"",stderr:`sleep: missing operand
|
|
9
|
+
`,exitCode:1};let t=0;for(let e of r){let o=d(e);if(o===null)return{stdout:"",stderr:`sleep: invalid time interval '${e}'
|
|
10
|
+
`,exitCode:1};t+=o}return t>m&&(t=m),s.signal?.aborted?{stdout:"",stderr:"",exitCode:0}:(s.sleep?await s.sleep(t):s.signal?await new Promise(e=>{let o=()=>{i(p),e()},p=n(()=>{s.signal?.removeEventListener("abort",o),e()},t);s.signal?.addEventListener("abort",o,{once:!0})}):await new Promise(e=>n(e,t)),{stdout:"",stderr:"",exitCode:0})}},b={name:"sleep",flags:[],needsArgs:!0};export{h as a,b};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as fe}from"./chunk-YMMJLYIX.js";import{a as Y}from"./chunk-SXB55JOI.js";import{a as ne}from"./chunk-4OALHZXB.js";import{a as te}from"./chunk-SE4C7FJY.js";import{a as oe,b as pe,c as ce}from"./chunk-D5WP4CKS.js";import{a as ie,b as le}from"./chunk-GTNBSMZR.js";function N(e,t){switch(e.type){case"name":{let n=e.pattern,a=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(a){let s=a[1],o=t.name;if(e.ignoreCase){if(!o.toLowerCase().endsWith(s.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!o.endsWith(s))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Y(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,a=t.relativePath,s=n.split("/");for(let i=0;i<s.length-1;i++){let r=s[i];if(r&&r!=="."&&r!==".."&&!r.includes("*")&&!r.includes("?")&&!r.includes("[")){let p=`/${r}/`;if(e.ignoreCase){if(!a.toLowerCase().includes(p.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!a.includes(p))return{matches:!1,pruned:!1,printed:!1}}}let o=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(o){let i=o[1];if(e.ignoreCase){if(!a.toLowerCase().endsWith(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!a.endsWith(i))return{matches:!1,pruned:!1,printed:!1}}return{matches:Y(a,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:te(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let a=(Date.now()-t.mtime)/(1e3*60*60*24),s;return e.comparison==="more"?s=a>e.days:e.comparison==="less"?s=a<e.days:s=Math.floor(a)===e.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let a;return e.comparison==="more"?a=t.size>n:e.comparison==="less"?a=t.size<n:e.unit==="b"?a=Math.ceil(t.size/512)===e.value:a=t.size===n,{matches:a,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,a=e.mode&511,s;return e.matchType==="exact"?s=n===a:e.matchType==="all"?s=(n&a)===a:s=(n&a)!==0,{matches:s,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=N(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=N(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let a=N(e.right,t);return{matches:a.matches,pruned:n.pruned||a.pruned,printed:n.printed||a.printed}}case"or":{let n=N(e.left,t);if(n.matches)return n;let a=N(e.right,t);return{matches:a.matches,pruned:n.pruned||a.pruned,printed:a.printed}}}}function _(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return _(e.expr);case"and":case"or":return _(e.left)||_(e.right)}}function j(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return j(e.expr);case"and":case"or":return j(e.left)||j(e.right);default:return!1}}function ue(e){let t={terminalDirName:null,requiredExtension:null};if(!e)return t;let n=Ee(e);if(Me(e)&&n.length===1){let o=n[0].split("/").filter(i=>i.length>0);if(o.length>=2)for(let i=o.length-2;i>=0;i--){let r=o[i];if(!r.includes("*")&&!r.includes("?")&&!r.includes("[")&&r!=="."&&r!==".."){let p=o[i+1];if(p&&(p.includes("*")||p.includes("?"))){t.terminalDirName=r;let l=p.match(/^\*(\.[a-zA-Z0-9]+)$/);l&&(t.requiredExtension=l[1])}break}}}return t}function Ee(e){let t=[],n=a=>{a.type==="path"?t.push(a.pattern):a.type==="not"?n(a.expr):(a.type==="and"||a.type==="or")&&(n(a.left),n(a.right))};return n(e),t}function Me(e){let t=n=>n.type==="type"&&n.fileType==="f"?!0:n.type==="not"?t(n.expr):n.type==="and"||n.type==="or"?t(n.left)||t(n.right):!1;return t(e)}function he(e){let t=[],n=a=>{a&&(a.type==="newer"?t.push(a.refPath):a.type==="not"?n(a.expr):(a.type==="and"||a.type==="or")&&(n(a.left),n(a.right)))};return n(e),t}function J(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return J(e.expr);case"and":case"or":return J(e.left)&&J(e.right)}}function H(e,t,n,a,s){switch(e.type){case"name":{let o=e.pattern,i=o.match(/^\*(\.[a-zA-Z0-9]+)$/);if(i){let r=i[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(r.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(r))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Y(t,o,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let o=e.pattern,i=o.split("/");for(let p=0;p<i.length-1;p++){let l=i[p];if(l&&l!=="."&&l!==".."&&!l.includes("*")&&!l.includes("?")&&!l.includes("[")){let d=`/${l}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(d.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(d))return{matches:!1,pruned:!1,printed:!1}}}let r=o.match(/\*(\.[a-zA-Z0-9]+)$/);if(r){let p=r[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(p.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(p))return{matches:!1,pruned:!1,printed:!1}}return{matches:Y(n,o,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let o=e.ignoreCase?"i":"";return{matches:te(e.pattern,o).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:a,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let o=H(e.expr,t,n,a,s);return{matches:!o.matches,pruned:o.pruned,printed:!1}}case"and":{let o=H(e.left,t,n,a,s);if(!o.matches)return{matches:!1,pruned:o.pruned,printed:!1};let i=H(e.right,t,n,a,s);return{matches:i.matches,pruned:o.pruned||i.pruned,printed:o.printed||i.printed}}case"or":{let o=H(e.left,t,n,a,s);if(o.matches)return o;let i=H(e.right,t,n,a,s);return{matches:i.matches,pruned:o.pruned||i.pruned,printed:i.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function V(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return V(e.expr);case"and":case"or":return V(e.left)||V(e.right);default:return!1}}function W(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return W(e.expr);case"and":case"or":return W(e.left)&&W(e.right)}}function de(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!W(e))return se(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:N(e,n).pruned}}function se(e,t){switch(e.type){case"or":{if(W(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(N(e.left,n).pruned)return{shouldPrune:!0}}return se(e.right,t)}case"and":{if(W(e.left)&&W(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:N(e,n).pruned}}if(W(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return N(e.left,n).matches?se(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}function me(e,t){let n=[],a=[],s=t;for(;s<e.length;){let i=e[s];if(i==="("||i==="\\("){n.push({type:"lparen"}),s++;continue}if(i===")"||i==="\\)"){n.push({type:"rparen"}),s++;continue}if(i==="-name"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(i==="-iname"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(i==="-path"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(i==="-ipath"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(i==="-regex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}});else if(i==="-iregex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}});else if(i==="-type"&&s+1<e.length){let r=e[++s];if(r==="f"||r==="d")n.push({type:"expr",expr:{type:"type",fileType:r}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${r}
|
|
3
|
+
`,actions:[]}}else if(i==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(i==="-mtime"&&s+1<e.length){let r=e[++s],p="exact",l=r;r.startsWith("+")?(p="more",l=r.slice(1)):r.startsWith("-")&&(p="less",l=r.slice(1));let d=parseInt(l,10);Number.isNaN(d)||n.push({type:"expr",expr:{type:"mtime",days:d,comparison:p}})}else if(i==="-newer"&&s+1<e.length){let r=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:r}})}else if(i==="-size"&&s+1<e.length){let r=e[++s],p="exact",l=r;r.startsWith("+")?(p="more",l=r.slice(1)):r.startsWith("-")&&(p="less",l=r.slice(1));let d=l.match(/^(\d+)([ckMGb])?$/);if(d){let B=parseInt(d[1],10),x=d[2]||"b";n.push({type:"expr",expr:{type:"size",value:B,unit:x,comparison:p}})}}else if(i==="-perm"&&s+1<e.length){let r=e[++s],p="exact",l=r;r.startsWith("-")?(p="all",l=r.slice(1)):r.startsWith("/")&&(p="any",l=r.slice(1));let d=parseInt(l,8);Number.isNaN(d)||n.push({type:"expr",expr:{type:"perm",mode:d,matchType:p}})}else if(i==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(i==="-not"||i==="!")n.push({type:"not"});else if(i==="-o"||i==="-or")n.push({type:"op",op:"or"});else if(i==="-a"||i==="-and")n.push({type:"op",op:"and"});else if(i==="-maxdepth"||i==="-mindepth")s++;else if(i!=="-depth")if(i==="-exec"){let r=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)r.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[s]==="+";a.push({type:"exec",command:r,batchMode:p})}else if(i==="-print")n.push({type:"expr",expr:{type:"print"}}),a.push({type:"print"});else if(i==="-print0")a.push({type:"print0"});else if(i==="-printf"&&s+1<e.length){let r=e[++s];a.push({type:"printf",format:r})}else if(i==="-delete")a.push({type:"delete"});else{if(i.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${i}'
|
|
4
|
+
`,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:a};let o=Fe(n);return o.error?{expr:null,pathIndex:s,error:o.error,actions:a}:{expr:o.expr,pathIndex:s,actions:a}}function Fe(e){let t=0;function n(){let r=a();if(!r)return null;for(;t<e.length;){let p=e[t];if(p.type==="op"&&p.op==="or"){t++;let l=a();if(!l)return r;r={type:"or",left:r,right:l}}else break}return r}function a(){let r=s();if(!r)return null;for(;t<e.length;){let p=e[t];if(p.type==="op"&&p.op==="and"){t++;let l=s();if(!l)return r;r={type:"and",left:r,right:l}}else if(p.type==="expr"||p.type==="not"||p.type==="lparen"){let l=s();if(!l)return r;r={type:"and",left:r,right:l}}else break}return r}function s(){if(t<e.length&&e[t].type==="not"){t++;let r=s();return r?{type:"not",expr:r}:null}return o()}function o(){if(t>=e.length)return null;let r=e[t];if(r.type==="lparen"){t++;let p=n();return t<e.length&&e[t].type==="rparen"&&t++,p}return r.type==="expr"?(t++,r.expr):(r.type==="rparen",null)}return{expr:n()}}var ye=500;function Ie(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function xe(e,t,n){e({category:"find",name:"summary",durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}var $e={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},Re=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),je={name:"find",async execute(e,t){if(le(e))return ie($e);let n=[],a=null,s=null,o=!1,i=!1;for(let c=0;c<e.length;c++){let f=e[c];if(f==="-maxdepth"&&c+1<e.length)i=!0,a=parseInt(e[++c],10);else if(f==="-mindepth"&&c+1<e.length)i=!0,s=parseInt(e[++c],10);else if(f==="-depth")i=!0,o=!0;else if(f==="-exec")for(i=!0,c++;c<e.length&&e[c]!==";"&&e[c]!=="+";)c++;else!f.startsWith("-")&&f!==";"&&f!=="+"&&f!=="("&&f!==")"&&f!=="\\("&&f!=="\\)"&&f!=="!"?i||n.push(f):Re.has(f)?(i=!0,c++):(f.startsWith("-")||f==="("||f==="\\("||f==="!")&&(i=!0)}n.length===0&&n.push(".");let{expr:r,error:p,actions:l}=me(e,0);if(p)return{stdout:"",stderr:p,exitCode:1};let d=l.some(c=>c.type==="print"),B=l.length===0,x=[],ge=l.some(c=>c.type==="printf"),re=[],q="",G=0,we=he(r),U=new Map;for(let c of we){let f=t.fs.resolvePath(t.cwd,c);try{let h=await t.fs.stat(f);U.set(c,h.mtime?.getTime()??Date.now())}catch{}}let De=l.some(c=>{if(c.type!=="printf")return!1;let f=c.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(f)}),Te=_(r)||De,Ce=j(r),K=ue(r),ae=V(r),Pe=J(r),Se=typeof t.fs.readdirWithFileTypes=="function";for(let c of n){let z=function(u){let R=s===null||u.depth>=s,P=!1;if(R&&r!==null){let S=Date.now(),y;if(Pe)y=H(r,u.name,u.relativePath,u.isFile,u.isDirectory);else{let m={name:u.name,relativePath:u.relativePath,isFile:u.isFile,isDirectory:u.isDirectory,isEmpty:u.isEmpty,mtime:u.stat?.mtime?.getTime()??Date.now(),size:u.stat?.size??0,mode:u.stat?.mode??420,newerRefTimes:U};y=N(r,m)}R=y.matches,P=d?y.printed:R,h.evalCalls++,h.evalTime+=Date.now()-S}else R&&(P=!0);return P?{print:!0,printfData:ge?{path:u.relativePath,name:u.name,size:u.stat?.size??0,mtime:u.stat?.mtime?.getTime()??Date.now(),mode:u.stat?.mode??420,isDirectory:u.isDirectory,depth:u.depth,startingPoint:c}:null}:{print:!1,printfData:null}};var We=z;c.length>1&&c.endsWith("/")&&(c=c.slice(0,-1));let f=t.fs.resolvePath(t.cwd,c);try{await t.fs.stat(f)}catch{q+=`find: ${c}: No such file or directory
|
|
5
|
+
`,G=1;continue}let h=Ie(),$=Date.now();async function v(u){let{path:b,depth:R,typeInfo:P}=u;if(h.nodeCount++,R>(a??256))return null;let E,S,y;if(P&&!Te)E=P.isFile,S=P.isDirectory;else{try{let L=Date.now();y=await t.fs.stat(b),h.statCalls++,h.statTime+=Date.now()-L}catch{return null}if(!y)return null;E=y.isFile,S=y.isDirectory}let m;b===f?m=c.split("/").pop()||c:m=b.split("/").pop()||"";let g=b===f?c:c==="."?`./${b.slice(f==="/"?f.length:f.length+1)}`:c+b.slice(f.length),T=[],C=null,w=null,D=!1;S&&ae&&!o&&(D=de(r,{name:m,relativePath:g,isFile:E,isDirectory:S}).shouldPrune,D&&h.earlyPrunes++);let F=R>=(a??256),I=K.terminalDirName!==null&&m===K.terminalDirName,Z=!F&&!I&&!D;if(S&&((Z||Ce||I)&&!D)){let L=Date.now();if(Se&&t.fs.readdirWithFileTypes){if(C=await t.fs.readdirWithFileTypes(b),w=C.map(M=>M.name),h.readdirCalls++,h.readdirTime+=Date.now()-L,Z)T=C.map((M,k)=>({path:b==="/"?`/${M.name}`:`${b}/${M.name}`,depth:R+1,typeInfo:{isFile:M.isFile,isDirectory:M.isDirectory},resultIndex:k}));else if(I){let M=K.requiredExtension;T=C.filter(k=>k.isFile&&(!M||k.name.endsWith(M))).map((k,ve)=>({path:b==="/"?`/${k.name}`:`${b}/${k.name}`,depth:R+1,typeInfo:{isFile:k.isFile,isDirectory:k.isDirectory},resultIndex:ve}))}}else w=await t.fs.readdir(b),h.readdirCalls++,h.readdirTime+=Date.now()-L,Z&&(T=w.map((M,k)=>({path:b==="/"?`/${M}`:`${b}/${M}`,depth:R+1,resultIndex:k})))}let Q=E?(y?.size??0)===0:w!==null&&w.length===0,O=D;if(!o&&r!==null&&!D&&ae){let L=Date.now(),M={name:m,relativePath:g,isFile:E,isDirectory:S,isEmpty:Q,mtime:y?.mtime?.getTime()??Date.now(),size:y?.size??0,mode:y?.mode??420,newerRefTimes:U};O=N(r,M).pruned,h.evalCalls++,h.evalTime+=Date.now()-L}return{relativePath:g,name:m,isFile:E,isDirectory:S,isEmpty:Q,stat:y,depth:R,children:O?[]:T,pruned:O}}async function be(){let u={paths:[],printfData:[]};if(o){let y=function(m){let g={paths:[],printfData:[]},T=P[m];if(!T)return g;for(let D of T.childIndices){let F=y(D);g.paths.push(...F.paths),g.printfData.push(...F.printfData)}let{print:C,printfData:w}=z(T.node);return C&&(g.paths.push(T.node.relativePath),w&&g.printfData.push(w)),g};var b=y;let P=[],E=[{item:{path:f,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],S=new Map;for(;E.length>0;){let m=Date.now(),g=E.splice(0,ye),T=await Promise.all(g.map(C=>v(C.item)));h.batchCount++,h.batchTime+=Date.now()-m;for(let C=0;C<g.length;C++){let w=T[C],D=g[C];if(!w)continue;let F=P.length;if(D.parentIndex>=0){let I=S.get(D.parentIndex)||[];I.push(F),S.set(D.parentIndex,I)}P.push({node:w,parentIndex:D.parentIndex,childIndices:[]});for(let I=0;I<w.children.length;I++)E.push({item:w.children[I],parentIndex:F,childOrderInParent:I})}}for(let[m,g]of S)m>=0&&m<P.length&&(P[m].childIndices=g);if(P.length>0){let m=y(0);u.paths.push(...m.paths),u.printfData.push(...m.printfData)}}else{let m=function(g){let T=P.get(g);T&&(u.paths.push(T.path),T.printfData&&u.printfData.push(T.printfData));let C=y.get(g);if(C)for(let w of C)m(w)};var R=m;let P=new Map,E=0,S=[{item:{path:f,depth:0,resultIndex:0},orderIndex:E++}],y=new Map;for(;S.length>0;){let g=Date.now(),T=S.splice(0,ye),C=await Promise.all(T.map(async({item:w,orderIndex:D})=>{let F=await v(w);return F?{node:F,orderIndex:D}:null}));h.batchCount++,h.batchTime+=Date.now()-g;for(let w of C){if(!w)continue;let{node:D,orderIndex:F}=w,{print:I,printfData:Z}=z(D);if(I&&P.set(F,{path:D.relativePath,printfData:Z}),D.children.length>0){let ee=[];for(let Q of D.children){let O=E++;ee.push(O),S.push({item:Q,orderIndex:O})}y.set(F,ee)}}}m(0)}return u}let X=await be();if(x.push(...X.paths),re.push(...X.printfData),t.trace){let u=Date.now()-$;xe(t.trace,h,u),t.trace({category:"find",name:"searchPath",durationMs:u,details:{path:c,resultsFound:X.paths.length}})}}let A="";if(l.length>0)for(let c of l)switch(c.type){case"print":A+=x.length>0?`${x.join(`
|
|
6
|
+
`)}
|
|
7
|
+
`:"";break;case"print0":A+=x.length>0?`${x.join("\0")}\0`:"";break;case"delete":{let f=[...x].sort((h,$)=>$.length-h.length);for(let h of f){let $=t.fs.resolvePath(t.cwd,h);try{await t.fs.rm($,{recursive:!1})}catch(v){let z=v instanceof Error?v.message:String(v);q+=`find: cannot delete '${h}': ${z}
|
|
8
|
+
`,G=1}}break}case"printf":for(let f of re)A+=ke(c.format,f);break;case"exec":if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
9
|
+
`,exitCode:1};if(c.batchMode){let f=[];for(let v of c.command)v==="{}"?f.push(...x):f.push(v);let h=ne(f),$=await t.exec(h,{cwd:t.cwd,signal:t.signal});A+=$.stdout,q+=$.stderr,$.exitCode!==0&&(G=$.exitCode)}else for(let f of x){let h=c.command.map(z=>z==="{}"?f:z),$=ne(h),v=await t.exec($,{cwd:t.cwd,signal:t.signal});A+=v.stdout,q+=v.stderr,v.exitCode!==0&&(G=v.exitCode)}break}else B&&(A=x.length>0?`${x.join(`
|
|
10
|
+
`)}
|
|
11
|
+
`:"");return{stdout:A,stderr:q,exitCode:G}}};function ke(e,t){let n=ce(e),a="",s=0;for(;s<n.length;)if(n[s]==="%"&&s+1<n.length){if(s++,n[s]==="%"){a+="%",s++;continue}let[o,i,r]=pe(n,s);if(s+=r,s>=n.length){a+="%";break}let p=n[s],l;switch(p){case"f":l=t.name,s++;break;case"h":{let d=t.path.lastIndexOf("/");l=d>0?t.path.slice(0,d):".",s++;break}case"p":l=t.path,s++;break;case"P":{let d=t.startingPoint;t.path===d?l="":t.path.startsWith(`${d}/`)?l=t.path.slice(d.length+1):d==="."&&t.path.startsWith("./")?l=t.path.slice(2):l=t.path,s++;break}case"s":l=String(t.size),s++;break;case"d":l=String(t.depth),s++;break;case"m":l=(t.mode&511).toString(8),s++;break;case"M":l=fe(t.mode,t.isDirectory),s++;break;case"t":{let d=new Date(t.mtime);l=Ne(d),s++;break}case"T":{if(s+1<n.length){let d=n[s+1],B=new Date(t.mtime);l=ze(B,d),s+=2}else l="%T",s++;break}default:a+=`%${o!==0||i!==-1?`${o}.${i}`:""}${p}`,s++;continue}a+=oe(l,o,i)}else a+=n[s],s++;return a}function Ne(e){let t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],a=t[e.getDay()],s=n[e.getMonth()],o=String(e.getDate()).padStart(2," "),i=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),p=String(e.getSeconds()).padStart(2,"0"),l=e.getFullYear();return`${a} ${s} ${o} ${i}:${r}:${p} ${l}`}function ze(e,t){switch(t){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${t}`}}var Je={name:"find",flags:[{flag:"-name",type:"value",valueHint:"pattern"},{flag:"-iname",type:"value",valueHint:"pattern"},{flag:"-type",type:"value",valueHint:"string"},{flag:"-maxdepth",type:"value",valueHint:"number"},{flag:"-mindepth",type:"value",valueHint:"number"},{flag:"-empty",type:"boolean"},{flag:"-print",type:"boolean"},{flag:"-print0",type:"boolean"}],needsFiles:!0};export{je as a,Je as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as r}from"./chunk-SE4C7FJY.js";var g=2048,o=new Map;function u(l,c,t){let s=typeof t=="boolean"?{ignoreCase:t}:t??{},e=c;s.stripQuotes&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));let i=s.ignoreCase?`i:${e}`:e,n=o.get(i);if(!n){if(n=a(e,s.ignoreCase),o.size>=g){let f=o.keys().next().value;f!==void 0&&o.delete(f)}o.set(i,n)}return n.test(l)}function a(l,c){let t="^";for(let s=0;s<l.length;s++){let e=l[s];if(e==="*")t+=".*";else if(e==="?")t+=".";else if(e==="["){let i=s+1;for(;i<l.length&&l[i]!=="]";)i++;t+=l.slice(s,i+1),s=i}else e==="."||e==="+"||e==="^"||e==="$"||e==="{"||e==="}"||e==="("||e===")"||e==="|"||e==="\\"?t+=`\\${e}`:t+=e}return t+="$",r(t,c?"i":"")}export{u as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{b as e}from"./chunk-Q5MYEU7X.js";var i=globalThis.setTimeout.bind(globalThis),r=globalThis.clearTimeout.bind(globalThis),s=globalThis.setInterval.bind(globalThis),T=globalThis.clearInterval.bind(globalThis);function l(t){return typeof t!="function"?t:e.bindCurrentContext(t)}var b=((t,n,...o)=>i(l(t),n,...o)),u=r;export{b as a,u as b};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as g}from"./chunk-4OALHZXB.js";import{
|
|
2
|
+
import{a as g}from"./chunk-4OALHZXB.js";import{c as u}from"./chunk-QZNF3Y3J.js";import{a as h}from"./chunk-4PRVMER6.js";import{a as f}from"./chunk-SYG3IW7P.js";var v={name:"time",async execute(r,s){let a="%e %M",o=null,c=!1,p=!1,t=0;for(;t<r.length;){let e=r[t];if(e==="-f"||e==="--format"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-f'
|
|
3
3
|
`,exitCode:1};a=r[t],t++}else if(e==="-o"||e==="--output"){if(t++,t>=r.length)return{stdout:"",stderr:`time: missing argument to '-o'
|
|
4
4
|
`,exitCode:1};o=r[t],t++}else if(e==="-a"||e==="--append")c=!0,t++;else if(e==="-v"||e==="--verbose")a=`Command being timed: %C
|
|
5
5
|
Elapsed (wall clock) time: %e seconds
|
|
6
|
-
Maximum resident set size (kbytes): %M`,t++;else if(e==="-p"||e==="--portability")p=!0,t++;else if(e==="--"){t++;break}else if(e.startsWith("-"))t++;else break}let d=r.slice(t);if(d.length===0)return{stdout:"",stderr:"",exitCode:0};let w=
|
|
7
|
-
`,exitCode:1};i=await s.exec(C,{env:h(s.env),cwd:s.cwd,stdin:s.stdin,signal:s.signal})}catch(e){i={stdout:"",stderr:`time: ${
|
|
8
|
-
`,exitCode:127}}let m=(
|
|
6
|
+
Maximum resident set size (kbytes): %M`,t++;else if(e==="-p"||e==="--portability")p=!0,t++;else if(e==="--"){t++;break}else if(e.startsWith("-"))t++;else break}let d=r.slice(t);if(d.length===0)return{stdout:"",stderr:"",exitCode:0};let w=u(),C=g(d),F=d.join(" "),i;try{if(!s.exec)return{stdout:"",stderr:`time: exec not available
|
|
7
|
+
`,exitCode:1};i=await s.exec(C,{env:h(s.env),cwd:s.cwd,stdin:s.stdin,signal:s.signal})}catch(e){i={stdout:"",stderr:`time: ${f(e.message)}
|
|
8
|
+
`,exitCode:127}}let m=(u()-w)/1e3,n;if(p?n=`real ${m.toFixed(2)}
|
|
9
9
|
user 0.00
|
|
10
10
|
sys 0.00
|
|
11
11
|
`:(n=a.replace(/%e/g,m.toFixed(2)).replace(/%E/g,x(m)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,F),n.endsWith(`
|
|
12
12
|
`)||(n+=`
|
|
13
|
-
`)),o)try{let e=s.fs.resolvePath(s.cwd,o);if(c&&await s.fs.exists(e)){let l=await s.fs.readFile(e);await s.fs.writeFile(e,l+n)}else await s.fs.writeFile(e,n)}catch(e){let l=
|
|
13
|
+
`)),o)try{let e=s.fs.resolvePath(s.cwd,o);if(c&&await s.fs.exists(e)){let l=await s.fs.readFile(e);await s.fs.writeFile(e,l+n)}else await s.fs.writeFile(e,n)}catch(e){let l=f(e.message);return{stdout:i.stdout,stderr:i.stderr+`time: cannot write to '${o}': ${l}
|
|
14
14
|
`,exitCode:i.exitCode}}else i={...i,stderr:i.stderr+n};return i}};function x(r){let s=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return s>0?`${s}:${a.toString().padStart(2,"0")}:${o.toFixed(2).padStart(5,"0")}`:`${a}:${o.toFixed(2).padStart(5,"0")}`}var T={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0};export{v as a,T as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as b,b as g,c as C,d as k,e as X}from"./chunk-UYBH3FNE.js";import{a as G,c as yt}from"./chunk-4PRVMER6.js";import{a as ht}from"./chunk-WO4B7WUT.js";import{a as T}from"./chunk-SE4C7FJY.js";import{k as P}from"./chunk-6KZRLMG3.js";function W(t,r,e,n,p,i,u,c,s,f){switch(r){case"sort":return Array.isArray(t)?[[...t].sort(u)]:[null];case"sort_by":return!Array.isArray(t)||e.length===0?[null]:[[...t].sort((h,y)=>{let a=p(h,e[0],n)[0],l=p(y,e[0],n)[0];return u(a,l)})];case"bsearch":{if(!Array.isArray(t)){let h=t===null?"null":typeof t=="object"?"object":typeof t;throw new Error(`${h} (${JSON.stringify(t)}) cannot be searched from`)}return e.length===0?[null]:p(t,e[0],n).map(h=>{let y=0,a=t.length;for(;y<a;){let l=y+a>>>1;u(t[l],h)<0?y=l+1:a=l}return y<t.length&&u(t[y],h)===0?y:-y-1})}case"unique_by":{if(!Array.isArray(t)||e.length===0)return[null];let o=new Map;for(let y of t){let a=p(y,e[0],n)[0],l=JSON.stringify(a);o.has(l)||o.set(l,{item:y,key:a})}let h=[...o.values()];return h.sort((y,a)=>u(y.key,a.key)),[h.map(y=>y.item)]}case"group_by":{if(!Array.isArray(t)||e.length===0)return[null];let o=new Map;for(let h of t){let y=JSON.stringify(p(h,e[0],n)[0]);o.has(y)||o.set(y,[]),o.get(y)?.push(h)}return[[...o.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((o,h)=>u(o,h)>0?o:h)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((o,h)=>{let y=p(o,e[0],n)[0],a=p(h,e[0],n)[0];return u(y,a)>0?o:h})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((o,h)=>u(o,h)<0?o:h)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((o,h)=>{let y=p(o,e[0],n)[0],a=p(h,e[0],n)[0];return u(y,a)<0?o:h})];case"add":{let o=h=>{let y=h.filter(a=>a!==null);return y.length===0?null:y.every(a=>typeof a=="number")?y.reduce((a,l)=>a+l,0):y.every(a=>typeof a=="string")?y.join(""):y.every(a=>Array.isArray(a))?y.flat():y.every(a=>a&&typeof a=="object"&&!Array.isArray(a))?yt(...y):null};if(e.length>=1){let h=p(t,e[0],n);return[o(h)]}return Array.isArray(t)?[o(t)]:[null]}case"any":{if(e.length>=2){try{let o=i(t,e[0],n);for(let h of o)if(p(h,e[1],n).some(c))return[!0]}catch(o){if(o instanceof f)throw o}return[!1]}return e.length===1?Array.isArray(t)?[t.some(o=>c(p(o,e[0],n)[0]))]:[!1]:Array.isArray(t)?[t.some(c)]:[!1]}case"all":{if(e.length>=2){try{let o=i(t,e[0],n);for(let h of o)if(!p(h,e[1],n).some(c))return[!1]}catch(o){if(o instanceof f)throw o}return[!0]}return e.length===1?Array.isArray(t)?[t.every(o=>c(p(o,e[0],n)[0]))]:[!0]:Array.isArray(t)?[t.every(c)]:[!0]}case"select":return e.length===0?[t]:p(t,e[0],n).some(c)?[t]:[];case"map":return e.length===0||!Array.isArray(t)?[null]:[t.flatMap(h=>p(h,e[0],n))];case"map_values":{if(e.length===0)return[null];if(Array.isArray(t))return[t.flatMap(o=>p(o,e[0],n))];if(t&&typeof t=="object"){let o=Object.create(null);for(let[h,y]of Object.entries(t)){if(!b(h))continue;let a=p(y,e[0],n);a.length>0&&g(o,h,a[0])}return[o]}return[null]}case"has":{if(e.length===0)return[!1];let h=p(t,e[0],n)[0];return Array.isArray(t)&&typeof h=="number"?[h>=0&&h<t.length]:t&&typeof t=="object"&&typeof h=="string"?[C(t,h)]:[!1]}case"in":{if(e.length===0)return[!1];let h=p(t,e[0],n)[0];return Array.isArray(h)&&typeof t=="number"?[t>=0&&t<h.length]:h&&typeof h=="object"&&typeof t=="string"?[C(h,t)]:[!1]}case"contains":{if(e.length===0)return[!1];let o=p(t,e[0],n);return[s(t,o[0])]}case"inside":{if(e.length===0)return[!1];let o=p(t,e[0],n);return[s(o[0],t)]}default:return null}}function Q(t,r,e,n,p,i,u,c){switch(r){case"first":if(e.length>0)try{let s=i(t,e[0],n);return s.length>0?[s[0]]:[]}catch(s){if(s instanceof c)throw s;return[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(e.length>0){let s=p(t,e[0],n);return s.length>0?[s[s.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(e.length<1)return[null];let s=p(t,e[0],n);if(e.length>1){for(let o of s)if(o<0)throw new Error("nth doesn't support negative indices");let f;try{f=i(t,e[1],n)}catch(o){if(o instanceof c)throw o;f=[]}return s.flatMap(o=>{let h=o;return h<f.length?[f[h]]:[]})}return Array.isArray(t)?s.flatMap(f=>{let o=f;if(o<0)throw new Error("nth doesn't support negative indices");return o<t.length?[t[o]]:[null]}):[null]}case"range":{if(e.length===0)return[];let s=Math.max(n.limits.maxIterations*100,1e6),f=l=>l.length>=s,o=p(t,e[0],n);if(e.length===1){let l=[];for(let m of o){let A=m;for(let E=0;E<A;E++)if(l.push(E),f(l))return l}return l}let h=p(t,e[1],n);if(e.length===2){let l=[];for(let m of o)for(let A of h){let E=m,w=A;for(let O=E;O<w;O++)if(l.push(O),f(l))return l}return l}let y=p(t,e[2],n),a=[];for(let l of o)for(let m of h)for(let A of y){let E=l,w=m,O=A;if(O!==0){if(O>0){for(let S=E;S<w;S+=O)if(a.push(S),f(a))return a}else for(let S=E;S>w;S+=O)if(a.push(S),f(a))return a}}return a}case"limit":return e.length<2?[]:p(t,e[0],n).flatMap(f=>{let o=f;if(o<0)throw new Error("limit doesn't support negative count");if(o===0)return[];let h;try{h=i(t,e[1],n)}catch(y){if(y instanceof c)throw y;h=[]}return h.slice(0,o)});case"isempty":{if(e.length<1)return[!0];try{return[i(t,e[0],n).length===0]}catch(s){if(s instanceof c)throw s;return[!0]}}case"isvalid":{if(e.length<1)return[!0];try{return[p(t,e[0],n).length>0]}catch(s){if(s instanceof c)throw s;return[!1]}}case"skip":return e.length<2?[]:p(t,e[0],n).flatMap(f=>{let o=f;if(o<0)throw new Error("skip doesn't support negative count");return p(t,e[1],n).slice(o)});case"until":{if(e.length<2)return[t];let s=t,f=n.limits.maxIterations;for(let o=0;o<f;o++){if(p(s,e[0],n).some(u))return[s];let y=p(s,e[1],n);if(y.length===0)return[s];s=y[0]}throw new c(`jq until: too many iterations (${f}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(e.length<2)return[t];let s=[],f=t,o=n.limits.maxIterations;for(let h=0;h<o&&p(f,e[0],n).some(u);h++){s.push(f);let a=p(f,e[1],n);if(a.length===0)break;f=a[0]}if(s.length>=o)throw new c(`jq while: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"repeat":{if(e.length===0)return[t];let s=[],f=t,o=n.limits.maxIterations;for(let h=0;h<o;h++){s.push(f);let y=p(f,e[0],n);if(y.length===0)break;f=y[0]}if(s.length>=o)throw new c(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}default:return null}}function Z(t,r,e,n,p){switch(r){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof t!="number")return[null];let i=new Date(t*1e3),u=i.getUTCFullYear(),c=i.getUTCMonth(),s=i.getUTCDate(),f=i.getUTCHours(),o=i.getUTCMinutes(),h=i.getUTCSeconds(),y=i.getUTCDay(),a=Date.UTC(u,0,1),l=Math.floor((i.getTime()-a)/(1440*60*1e3));return[[u,c,s,f,o,h,y,l]]}case"mktime":{if(!Array.isArray(t))throw new Error("mktime requires parsed datetime inputs");let[i,u,c,s=0,f=0,o=0]=t;if(typeof i!="number"||typeof u!="number")throw new Error("mktime requires parsed datetime inputs");let h=Date.UTC(i,u,c??1,s??0,f??0,o??0);return[Math.floor(h/1e3)]}case"strftime":{if(e.length===0)return[null];let u=p(t,e[0],n)[0];if(typeof u!="string")throw new Error("strftime/1 requires a string format");let c;if(typeof t=="number")c=new Date(t*1e3);else if(Array.isArray(t)){let[y,a,l,m=0,A=0,E=0]=t;if(typeof y!="number"||typeof a!="number")throw new Error("strftime/1 requires parsed datetime inputs");c=new Date(Date.UTC(y,a,l??1,m??0,A??0,E??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],f=["January","February","March","April","May","June","July","August","September","October","November","December"],o=(y,a=2)=>String(y).padStart(a,"0");return[u.replace(/%Y/g,String(c.getUTCFullYear())).replace(/%m/g,o(c.getUTCMonth()+1)).replace(/%d/g,o(c.getUTCDate())).replace(/%H/g,o(c.getUTCHours())).replace(/%M/g,o(c.getUTCMinutes())).replace(/%S/g,o(c.getUTCSeconds())).replace(/%A/g,s[c.getUTCDay()]).replace(/%B/g,f[c.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(e.length===0)return[null];if(typeof t!="string")throw new Error("strptime/1 requires a string input");let u=p(t,e[0],n)[0];if(typeof u!="string")throw new Error("strptime/1 requires a string format");if(u==="%Y-%m-%dT%H:%M:%SZ"){let s=t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(s){let[,f,o,h,y,a,l]=s.map(Number),m=new Date(Date.UTC(f,o-1,h,y,a,l)),A=m.getUTCDay(),E=Date.UTC(f,0,1),w=Math.floor((m.getTime()-E)/(1440*60*1e3));return[[f,o-1,h,y,a,l,A,w]]}}let c=new Date(t);if(!Number.isNaN(c.getTime())){let s=c.getUTCFullYear(),f=c.getUTCMonth(),o=c.getUTCDate(),h=c.getUTCHours(),y=c.getUTCMinutes(),a=c.getUTCSeconds(),l=c.getUTCDay(),m=Date.UTC(s,0,1),A=Math.floor((c.getTime()-m)/(1440*60*1e3));return[[s,f,o,h,y,a,l,A]]}throw new Error(`Cannot parse date: ${t}`)}case"fromdate":{if(typeof t!="string")throw new Error("fromdate requires a string input");let i=new Date(t);if(Number.isNaN(i.getTime()))throw new Error(`date "${t}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof t!="number")throw new Error("todate requires a number input");return[new Date(t*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}function N(t){return t!==!1&&t!==null}function x(t,r){return JSON.stringify(t)===JSON.stringify(r)}function B(t,r){return typeof t=="number"&&typeof r=="number"?t-r:typeof t=="string"&&typeof r=="string"?t.localeCompare(r):0}function z(t,r){let e=k(t);for(let n of Object.keys(r))b(n)&&(C(e,n)&&e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])&&r[n]&&typeof r[n]=="object"&&!Array.isArray(r[n])?g(e,n,z(e[n],r[n])):g(e,n,r[n]));return e}function I(t,r=3e3){let e=0,n=t;for(;e<r;)if(Array.isArray(n)){if(n.length===0)return e+1;n=n[0],e++}else if(n!==null&&typeof n=="object"){let p=Object.keys(n);if(p.length===0)return e+1;n=n[p[0]],e++}else return e;return e}function _(t,r){let e=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,n=e(t),p=e(r);if(n!==p)return n-p;if(typeof t=="number"&&typeof r=="number")return t-r;if(typeof t=="string"&&typeof r=="string")return t.localeCompare(r);if(typeof t=="boolean"&&typeof r=="boolean")return(t?1:0)-(r?1:0);if(Array.isArray(t)&&Array.isArray(r)){for(let i=0;i<Math.min(t.length,r.length);i++){let u=_(t[i],r[i]);if(u!==0)return u}return t.length-r.length}if(t&&r&&typeof t=="object"&&typeof r=="object"){let i=t,u=r,c=Object.keys(i).sort(),s=Object.keys(u).sort();for(let f=0;f<Math.min(c.length,s.length);f++){let o=c[f].localeCompare(s[f]);if(o!==0)return o}if(c.length!==s.length)return c.length-s.length;for(let f of c){let o=_(i[f],u[f]);if(o!==0)return o}}return 0}function $(t,r){if(x(t,r))return!0;if(typeof t=="string"&&typeof r=="string")return t.includes(r);if(Array.isArray(t)&&Array.isArray(r))return r.every(e=>t.some(n=>$(n,e)));if(t&&r&&typeof t=="object"&&typeof r=="object"&&!Array.isArray(t)&&!Array.isArray(r)){let e=t,n=r;return Object.keys(n).every(p=>C(e,p)&&$(e[p],n[p]))}return!1}var wt=2e3;function v(t,r,e){switch(r){case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof t=="string"?[decodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(p=>{if(p===null)return"";if(typeof p=="boolean")return p?"true":"false";if(typeof p=="number")return String(p);let i=String(p);return i.includes(",")||i.includes('"')||i.includes(`
|
|
2
|
+
import{a as b,b as g,c as C,d as k,e as X}from"./chunk-UYBH3FNE.js";import{a as G,c as yt}from"./chunk-4PRVMER6.js";import{a as ht}from"./chunk-ZRRNCS7N.js";import{a as T}from"./chunk-SE4C7FJY.js";import{k as P}from"./chunk-6KZRLMG3.js";function W(t,r,e,n,p,i,u,c,s,f){switch(r){case"sort":return Array.isArray(t)?[[...t].sort(u)]:[null];case"sort_by":return!Array.isArray(t)||e.length===0?[null]:[[...t].sort((h,y)=>{let a=p(h,e[0],n)[0],l=p(y,e[0],n)[0];return u(a,l)})];case"bsearch":{if(!Array.isArray(t)){let h=t===null?"null":typeof t=="object"?"object":typeof t;throw new Error(`${h} (${JSON.stringify(t)}) cannot be searched from`)}return e.length===0?[null]:p(t,e[0],n).map(h=>{let y=0,a=t.length;for(;y<a;){let l=y+a>>>1;u(t[l],h)<0?y=l+1:a=l}return y<t.length&&u(t[y],h)===0?y:-y-1})}case"unique_by":{if(!Array.isArray(t)||e.length===0)return[null];let o=new Map;for(let y of t){let a=p(y,e[0],n)[0],l=JSON.stringify(a);o.has(l)||o.set(l,{item:y,key:a})}let h=[...o.values()];return h.sort((y,a)=>u(y.key,a.key)),[h.map(y=>y.item)]}case"group_by":{if(!Array.isArray(t)||e.length===0)return[null];let o=new Map;for(let h of t){let y=JSON.stringify(p(h,e[0],n)[0]);o.has(y)||o.set(y,[]),o.get(y)?.push(h)}return[[...o.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((o,h)=>u(o,h)>0?o:h)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((o,h)=>{let y=p(o,e[0],n)[0],a=p(h,e[0],n)[0];return u(y,a)>0?o:h})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((o,h)=>u(o,h)<0?o:h)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((o,h)=>{let y=p(o,e[0],n)[0],a=p(h,e[0],n)[0];return u(y,a)<0?o:h})];case"add":{let o=h=>{let y=h.filter(a=>a!==null);return y.length===0?null:y.every(a=>typeof a=="number")?y.reduce((a,l)=>a+l,0):y.every(a=>typeof a=="string")?y.join(""):y.every(a=>Array.isArray(a))?y.flat():y.every(a=>a&&typeof a=="object"&&!Array.isArray(a))?yt(...y):null};if(e.length>=1){let h=p(t,e[0],n);return[o(h)]}return Array.isArray(t)?[o(t)]:[null]}case"any":{if(e.length>=2){try{let o=i(t,e[0],n);for(let h of o)if(p(h,e[1],n).some(c))return[!0]}catch(o){if(o instanceof f)throw o}return[!1]}return e.length===1?Array.isArray(t)?[t.some(o=>c(p(o,e[0],n)[0]))]:[!1]:Array.isArray(t)?[t.some(c)]:[!1]}case"all":{if(e.length>=2){try{let o=i(t,e[0],n);for(let h of o)if(!p(h,e[1],n).some(c))return[!1]}catch(o){if(o instanceof f)throw o}return[!0]}return e.length===1?Array.isArray(t)?[t.every(o=>c(p(o,e[0],n)[0]))]:[!0]:Array.isArray(t)?[t.every(c)]:[!0]}case"select":return e.length===0?[t]:p(t,e[0],n).some(c)?[t]:[];case"map":return e.length===0||!Array.isArray(t)?[null]:[t.flatMap(h=>p(h,e[0],n))];case"map_values":{if(e.length===0)return[null];if(Array.isArray(t))return[t.flatMap(o=>p(o,e[0],n))];if(t&&typeof t=="object"){let o=Object.create(null);for(let[h,y]of Object.entries(t)){if(!b(h))continue;let a=p(y,e[0],n);a.length>0&&g(o,h,a[0])}return[o]}return[null]}case"has":{if(e.length===0)return[!1];let h=p(t,e[0],n)[0];return Array.isArray(t)&&typeof h=="number"?[h>=0&&h<t.length]:t&&typeof t=="object"&&typeof h=="string"?[C(t,h)]:[!1]}case"in":{if(e.length===0)return[!1];let h=p(t,e[0],n)[0];return Array.isArray(h)&&typeof t=="number"?[t>=0&&t<h.length]:h&&typeof h=="object"&&typeof t=="string"?[C(h,t)]:[!1]}case"contains":{if(e.length===0)return[!1];let o=p(t,e[0],n);return[s(t,o[0])]}case"inside":{if(e.length===0)return[!1];let o=p(t,e[0],n);return[s(o[0],t)]}default:return null}}function Q(t,r,e,n,p,i,u,c){switch(r){case"first":if(e.length>0)try{let s=i(t,e[0],n);return s.length>0?[s[0]]:[]}catch(s){if(s instanceof c)throw s;return[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(e.length>0){let s=p(t,e[0],n);return s.length>0?[s[s.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(e.length<1)return[null];let s=p(t,e[0],n);if(e.length>1){for(let o of s)if(o<0)throw new Error("nth doesn't support negative indices");let f;try{f=i(t,e[1],n)}catch(o){if(o instanceof c)throw o;f=[]}return s.flatMap(o=>{let h=o;return h<f.length?[f[h]]:[]})}return Array.isArray(t)?s.flatMap(f=>{let o=f;if(o<0)throw new Error("nth doesn't support negative indices");return o<t.length?[t[o]]:[null]}):[null]}case"range":{if(e.length===0)return[];let s=Math.max(n.limits.maxIterations*100,1e6),f=l=>l.length>=s,o=p(t,e[0],n);if(e.length===1){let l=[];for(let m of o){let A=m;for(let E=0;E<A;E++)if(l.push(E),f(l))return l}return l}let h=p(t,e[1],n);if(e.length===2){let l=[];for(let m of o)for(let A of h){let E=m,w=A;for(let O=E;O<w;O++)if(l.push(O),f(l))return l}return l}let y=p(t,e[2],n),a=[];for(let l of o)for(let m of h)for(let A of y){let E=l,w=m,O=A;if(O!==0){if(O>0){for(let S=E;S<w;S+=O)if(a.push(S),f(a))return a}else for(let S=E;S>w;S+=O)if(a.push(S),f(a))return a}}return a}case"limit":return e.length<2?[]:p(t,e[0],n).flatMap(f=>{let o=f;if(o<0)throw new Error("limit doesn't support negative count");if(o===0)return[];let h;try{h=i(t,e[1],n)}catch(y){if(y instanceof c)throw y;h=[]}return h.slice(0,o)});case"isempty":{if(e.length<1)return[!0];try{return[i(t,e[0],n).length===0]}catch(s){if(s instanceof c)throw s;return[!0]}}case"isvalid":{if(e.length<1)return[!0];try{return[p(t,e[0],n).length>0]}catch(s){if(s instanceof c)throw s;return[!1]}}case"skip":return e.length<2?[]:p(t,e[0],n).flatMap(f=>{let o=f;if(o<0)throw new Error("skip doesn't support negative count");return p(t,e[1],n).slice(o)});case"until":{if(e.length<2)return[t];let s=t,f=n.limits.maxIterations;for(let o=0;o<f;o++){if(p(s,e[0],n).some(u))return[s];let y=p(s,e[1],n);if(y.length===0)return[s];s=y[0]}throw new c(`jq until: too many iterations (${f}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(e.length<2)return[t];let s=[],f=t,o=n.limits.maxIterations;for(let h=0;h<o&&p(f,e[0],n).some(u);h++){s.push(f);let a=p(f,e[1],n);if(a.length===0)break;f=a[0]}if(s.length>=o)throw new c(`jq while: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"repeat":{if(e.length===0)return[t];let s=[],f=t,o=n.limits.maxIterations;for(let h=0;h<o;h++){s.push(f);let y=p(f,e[0],n);if(y.length===0)break;f=y[0]}if(s.length>=o)throw new c(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}default:return null}}function Z(t,r,e,n,p){switch(r){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof t!="number")return[null];let i=new Date(t*1e3),u=i.getUTCFullYear(),c=i.getUTCMonth(),s=i.getUTCDate(),f=i.getUTCHours(),o=i.getUTCMinutes(),h=i.getUTCSeconds(),y=i.getUTCDay(),a=Date.UTC(u,0,1),l=Math.floor((i.getTime()-a)/(1440*60*1e3));return[[u,c,s,f,o,h,y,l]]}case"mktime":{if(!Array.isArray(t))throw new Error("mktime requires parsed datetime inputs");let[i,u,c,s=0,f=0,o=0]=t;if(typeof i!="number"||typeof u!="number")throw new Error("mktime requires parsed datetime inputs");let h=Date.UTC(i,u,c??1,s??0,f??0,o??0);return[Math.floor(h/1e3)]}case"strftime":{if(e.length===0)return[null];let u=p(t,e[0],n)[0];if(typeof u!="string")throw new Error("strftime/1 requires a string format");let c;if(typeof t=="number")c=new Date(t*1e3);else if(Array.isArray(t)){let[y,a,l,m=0,A=0,E=0]=t;if(typeof y!="number"||typeof a!="number")throw new Error("strftime/1 requires parsed datetime inputs");c=new Date(Date.UTC(y,a,l??1,m??0,A??0,E??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],f=["January","February","March","April","May","June","July","August","September","October","November","December"],o=(y,a=2)=>String(y).padStart(a,"0");return[u.replace(/%Y/g,String(c.getUTCFullYear())).replace(/%m/g,o(c.getUTCMonth()+1)).replace(/%d/g,o(c.getUTCDate())).replace(/%H/g,o(c.getUTCHours())).replace(/%M/g,o(c.getUTCMinutes())).replace(/%S/g,o(c.getUTCSeconds())).replace(/%A/g,s[c.getUTCDay()]).replace(/%B/g,f[c.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(e.length===0)return[null];if(typeof t!="string")throw new Error("strptime/1 requires a string input");let u=p(t,e[0],n)[0];if(typeof u!="string")throw new Error("strptime/1 requires a string format");if(u==="%Y-%m-%dT%H:%M:%SZ"){let s=t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(s){let[,f,o,h,y,a,l]=s.map(Number),m=new Date(Date.UTC(f,o-1,h,y,a,l)),A=m.getUTCDay(),E=Date.UTC(f,0,1),w=Math.floor((m.getTime()-E)/(1440*60*1e3));return[[f,o-1,h,y,a,l,A,w]]}}let c=new Date(t);if(!Number.isNaN(c.getTime())){let s=c.getUTCFullYear(),f=c.getUTCMonth(),o=c.getUTCDate(),h=c.getUTCHours(),y=c.getUTCMinutes(),a=c.getUTCSeconds(),l=c.getUTCDay(),m=Date.UTC(s,0,1),A=Math.floor((c.getTime()-m)/(1440*60*1e3));return[[s,f,o,h,y,a,l,A]]}throw new Error(`Cannot parse date: ${t}`)}case"fromdate":{if(typeof t!="string")throw new Error("fromdate requires a string input");let i=new Date(t);if(Number.isNaN(i.getTime()))throw new Error(`date "${t}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof t!="number")throw new Error("todate requires a number input");return[new Date(t*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}function N(t){return t!==!1&&t!==null}function x(t,r){return JSON.stringify(t)===JSON.stringify(r)}function B(t,r){return typeof t=="number"&&typeof r=="number"?t-r:typeof t=="string"&&typeof r=="string"?t.localeCompare(r):0}function z(t,r){let e=k(t);for(let n of Object.keys(r))b(n)&&(C(e,n)&&e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])&&r[n]&&typeof r[n]=="object"&&!Array.isArray(r[n])?g(e,n,z(e[n],r[n])):g(e,n,r[n]));return e}function I(t,r=3e3){let e=0,n=t;for(;e<r;)if(Array.isArray(n)){if(n.length===0)return e+1;n=n[0],e++}else if(n!==null&&typeof n=="object"){let p=Object.keys(n);if(p.length===0)return e+1;n=n[p[0]],e++}else return e;return e}function _(t,r){let e=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,n=e(t),p=e(r);if(n!==p)return n-p;if(typeof t=="number"&&typeof r=="number")return t-r;if(typeof t=="string"&&typeof r=="string")return t.localeCompare(r);if(typeof t=="boolean"&&typeof r=="boolean")return(t?1:0)-(r?1:0);if(Array.isArray(t)&&Array.isArray(r)){for(let i=0;i<Math.min(t.length,r.length);i++){let u=_(t[i],r[i]);if(u!==0)return u}return t.length-r.length}if(t&&r&&typeof t=="object"&&typeof r=="object"){let i=t,u=r,c=Object.keys(i).sort(),s=Object.keys(u).sort();for(let f=0;f<Math.min(c.length,s.length);f++){let o=c[f].localeCompare(s[f]);if(o!==0)return o}if(c.length!==s.length)return c.length-s.length;for(let f of c){let o=_(i[f],u[f]);if(o!==0)return o}}return 0}function $(t,r){if(x(t,r))return!0;if(typeof t=="string"&&typeof r=="string")return t.includes(r);if(Array.isArray(t)&&Array.isArray(r))return r.every(e=>t.some(n=>$(n,e)));if(t&&r&&typeof t=="object"&&typeof r=="object"&&!Array.isArray(t)&&!Array.isArray(r)){let e=t,n=r;return Object.keys(n).every(p=>C(e,p)&&$(e[p],n[p]))}return!1}var wt=2e3;function v(t,r,e){switch(r){case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof t=="string"?[decodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(p=>{if(p===null)return"";if(typeof p=="boolean")return p?"true":"false";if(typeof p=="number")return String(p);let i=String(p);return i.includes(",")||i.includes('"')||i.includes(`
|
|
3
3
|
`)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(n=>String(n??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let n=e??wt;return I(t,n+1)>n?[null]:[JSON.stringify(t)]}case"@html":return typeof t=="string"?[t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];default:return null}}function tt(t,r,e,n,p,i){switch(r){case"index":return e.length===0?[null]:p(t,e[0],n).map(c=>{if(typeof t=="string"&&typeof c=="string"){if(c===""&&t==="")return null;let s=t.indexOf(c);return s>=0?s:null}if(Array.isArray(t)){if(Array.isArray(c)){for(let f=0;f<=t.length-c.length;f++){let o=!0;for(let h=0;h<c.length;h++)if(!i(t[f+h],c[h])){o=!1;break}if(o)return f}return null}let s=t.findIndex(f=>i(f,c));return s>=0?s:null}return null});case"rindex":return e.length===0?[null]:p(t,e[0],n).map(c=>{if(typeof t=="string"&&typeof c=="string"){let s=t.lastIndexOf(c);return s>=0?s:null}if(Array.isArray(t)){if(Array.isArray(c)){for(let s=t.length-c.length;s>=0;s--){let f=!0;for(let o=0;o<c.length;o++)if(!i(t[s+o],c[o])){f=!1;break}if(f)return s}return null}for(let s=t.length-1;s>=0;s--)if(i(t[s],c))return s;return null}return null});case"indices":return e.length===0?[[]]:p(t,e[0],n).map(c=>{let s=[];if(typeof t=="string"&&typeof c=="string"){let f=t.indexOf(c);for(;f!==-1;)s.push(f),f=t.indexOf(c,f+1)}else if(Array.isArray(t))if(Array.isArray(c)){let f=c.length;if(f===0)for(let o=0;o<=t.length;o++)s.push(o);else for(let o=0;o<=t.length-f;o++){let h=!0;for(let y=0;y<f;y++)if(!i(t[o+y],c[y])){h=!1;break}h&&s.push(o)}}else for(let f=0;f<t.length;f++)i(t[f],c)&&s.push(f);return s});default:return null}}function et(t,r,e,n,p){switch(r){case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:typeof t=="string"?[t]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),c=i[0],s=u[0];return typeof c!="number"||typeof s!="number"?[null]:[c**s]}case"atan2":{if(e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),c=i[0],s=u[0];return typeof c!="number"||typeof s!="number"?[null]:[Math.atan2(c,s)]}case"hypot":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.hypot(t,i)]}case"fma":{if(typeof t!="number"||e.length<2)return[null];let i=p(t,e[0],n)[0],u=p(t,e[1],n)[0];return[t*i+u]}case"copysign":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.sign(i)*Math.abs(t)]}case"drem":case"remainder":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[t-Math.round(t/i)*i]}case"fdim":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.max(0,t-i)]}case"fmax":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.max(t,i)]}case"fmin":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.min(t,i)]}case"ldexp":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[t*2**i]}case"scalbn":case"scalbln":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[t*2**i]}case"nearbyint":return typeof t=="number"?[Math.round(t)]:[null];case"logb":return typeof t=="number"?[Math.floor(Math.log2(Math.abs(t)))]:[null];case"significand":if(typeof t=="number"){let i=Math.floor(Math.log2(Math.abs(t)));return[t/2**i]}return[null];case"frexp":if(typeof t=="number"){if(t===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(t)))+1;return[[t/2**i,i]]}return[null];case"modf":if(typeof t=="number"){let i=Math.trunc(t);return[[t-i,i]]}return[null];default:return null}}function rt(t,r,e,n,p,i,u,c){switch(r){case"recurse":{if(e.length===0){let a=[],l=m=>{if(a.push(m),Array.isArray(m))for(let A of m)l(A);else if(m&&typeof m=="object")for(let A of Object.keys(m))l(m[A])};return l(t),a}let s=[],f=e.length>=2?e[1]:null,o=1e4,h=0,y=a=>{if(h++>o||f&&!p(a,f,n).some(i))return;s.push(a);let l=p(a,e[0],n);for(let m of l)m!=null&&y(m)};return y(t),s}case"recurse_down":return c(t,"recurse",e,n);case"walk":{if(e.length===0)return[t];let s=new WeakSet,f=o=>{if(o&&typeof o=="object"){if(s.has(o))return o;s.add(o)}let h;if(Array.isArray(o))h=o.map(f);else if(o&&typeof o=="object"){let a=Object.create(null);for(let[l,m]of Object.entries(o))b(l)&&g(a,l,f(m));h=a}else h=o;return p(h,e[0],n)[0]};return[f(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let s=Math.max(...t.map(o=>Array.isArray(o)?o.length:0)),f=[];for(let o=0;o<s;o++)f.push(t.map(h=>Array.isArray(h)?h[o]:null));return[f]}case"combinations":{if(e.length>0){let h=p(t,e[0],n)[0];if(!Array.isArray(t)||h<0)return[];if(h===0)return[[]];let y=[],a=(l,m)=>{if(m===h){y.push([...l]);return}for(let A of t)l.push(A),a(l,m+1),l.pop()};return a([],0),y}if(!Array.isArray(t))return[];if(t.length===0)return[[]];for(let o of t)if(!Array.isArray(o))return[];let s=[],f=(o,h)=>{if(o===t.length){s.push([...h]);return}let y=t[o];for(let a of y)h.push(a),f(o+1,h),h.pop()};return f(0,[]),s}case"parent":{if(n.root===void 0||n.currentPath===void 0)return[];let s=n.currentPath;if(s.length===0)return[];let f=e.length>0?p(t,e[0],n)[0]:1;if(f>=0){if(f>s.length)return[];let o=s.slice(0,s.length-f);return[u(n.root,o)]}else{let o=-f-1;if(o>=s.length)return[t];let h=s.slice(0,o);return[u(n.root,h)]}}case"parents":{if(n.root===void 0||n.currentPath===void 0)return[[]];let s=n.currentPath,f=[];for(let o=s.length-1;o>=0;o--)f.push(u(n.root,s.slice(0,o)));return[f]}case"root":return n.root!==void 0?[n.root]:[];default:return null}}var kt=2e3;function nt(t,r,e,n,p){switch(r){case"keys":return Array.isArray(t)?[t.map((i,u)=>u)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((i,u)=>u)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:typeof t=="number"?[Math.abs(t)]:[null];case"utf8bytelength":{if(typeof t=="string")return[new TextEncoder().encode(t).length];let i=t===null?"null":Array.isArray(t)?"array":typeof t,u=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${u}) only strings have UTF-8 byte length`)}case"to_entries":return t&&typeof t=="object"&&!Array.isArray(t)?[Object.entries(t).map(([i,u])=>({key:i,value:u}))]:[null];case"from_entries":if(Array.isArray(t)){let i=Object.create(null);for(let u of t)if(u&&typeof u=="object"){let c=u,s=c.key??c.Key??c.name??c.Name??c.k,f=c.value??c.Value??c.v;if(s!==void 0){let o=String(s);b(o)&&g(i,o,f)}}return[i]}return[null];case"with_entries":{if(e.length===0)return[t];if(t&&typeof t=="object"&&!Array.isArray(t)){let u=Object.entries(t).map(([s,f])=>({key:s,value:f})).flatMap(s=>p(s,e[0],n)),c=Object.create(null);for(let s of u)if(s&&typeof s=="object"){let f=s,o=f.key??f.name??f.k,h=f.value??f.v;if(o!==void 0){let y=String(o);b(y)&&g(c,y,h)}}return[c]}return[null]}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(t)?(e.length>0?p(t,e[0],n):[Number.POSITIVE_INFINITY]).map(u=>{let c=u;if(c<0)throw new Error("flatten depth must not be negative");return t.flat(c)}):[null];case"unique":if(Array.isArray(t)){let i=new Set,u=[];for(let c of t){let s=JSON.stringify(c);i.has(s)||(i.add(s),u.push(c))}return[u]}return[null];case"tojson":case"tojsonstream":{let i=n.limits.maxDepth??kt;return I(t,i+1)>i?[null]:[JSON.stringify(t)]}case"fromjson":{if(typeof t=="string"){let i=t.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[JSON.parse(t)]}catch{throw new Error(`Invalid JSON: ${t}`)}}return[t]}case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let i=Number(t);if(Number.isNaN(i))throw new Error(`${JSON.stringify(t)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof t} cannot be parsed as a number`);case"toboolean":{if(typeof t=="boolean")return[t];if(typeof t=="string"){if(t==="true")return[!0];if(t==="false")return[!1];throw new Error(`string (${JSON.stringify(t)}) cannot be parsed as a boolean`)}let i=t===null?"null":Array.isArray(t)?"array":typeof t,u=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${u}) cannot be parsed as a boolean`)}case"tostream":{let i=[],u=(c,s)=>{if(c===null||typeof c!="object")i.push([s,c]);else if(Array.isArray(c))if(c.length===0)i.push([s,[]]);else for(let f=0;f<c.length;f++)u(c[f],[...s,f]);else{let f=Object.keys(c);if(f.length===0)i.push([s,Object.create(null)]);else for(let o of f)u(c[o],[...s,o])}};return u(t,[]),i.push([[]]),i}case"fromstream":{if(e.length===0)return[t];let i=p(t,e[0],n),u=null;for(let c of i){if(!Array.isArray(c)||c.length===1&&Array.isArray(c[0])&&c[0].length===0||c.length!==2)continue;let[s,f]=c;if(!Array.isArray(s))continue;if(s.length===0){u=f;continue}u===null&&(u=typeof s[0]=="number"?[]:{});let o=u;for(let y=0;y<s.length-1;y++){let a=s[y],l=s[y+1];if(Array.isArray(o)&&typeof a=="number"){for(;o.length<=a;)o.push(null);o[a]===null&&(o[a]=typeof l=="number"?[]:{}),o=o[a]}else if(o&&typeof o=="object"&&!Array.isArray(o)){let m=String(a);if(!b(m))continue;let A=o;(A[m]===null||A[m]===void 0)&&g(A,m,typeof l=="number"?[]:{}),o=A[m]}}let h=s[s.length-1];if(Array.isArray(o)&&typeof h=="number"){for(;o.length<=h;)o.push(null);o[h]=f}else if(o&&typeof o=="object"&&!Array.isArray(o)){let y=String(h);b(y)&&g(o,y,f)}}return[u]}case"truncate_stream":{let i=typeof t=="number"?Math.floor(t):0;if(e.length===0)return[];let u=[],c=p(t,e[0],n);for(let s of c)if(Array.isArray(s)){if(s.length===1&&Array.isArray(s[0])){let f=s[0];f.length>i&&u.push([f.slice(i)]);continue}if(s.length===2&&Array.isArray(s[0])){let f=s[0],o=s[1];f.length>i&&u.push([f.slice(i),o])}}return u}default:return null}}function st(t,r,e,n,p,i,u,c,s,f){switch(r){case"getpath":{if(e.length===0)return[null];let o=p(t,e[0],n),h=[];for(let y of o){let a=y,l=t;for(let m of a){if(l==null){l=null;break}if(Array.isArray(l)&&typeof m=="number")l=l[m];else if(typeof l=="object"&&typeof m=="string"){let A=l;if(!Object.hasOwn(A,m)){l=null;break}l=A[m]}else{l=null;break}}h.push(l)}return h}case"setpath":{if(e.length<2)return[null];let h=p(t,e[0],n)[0],a=p(t,e[1],n)[0];return[u(t,h,a)]}case"delpaths":{if(e.length===0)return[t];let h=p(t,e[0],n)[0],y=t;for(let a of h.sort((l,m)=>m.length-l.length))y=c(y,a);return[y]}case"path":{if(e.length===0)return[[]];let o=[];return f(t,e[0],n,[],o),o}case"del":return e.length===0?[t]:[s(t,e[0],n)];case"pick":{if(e.length===0)return[null];let o=[];for(let y of e)f(t,y,n,[],o);let h=null;for(let y of o){for(let l of y)if(typeof l=="number"&&l<0)throw new Error("Out of bounds negative array index");let a=t;for(let l of y){if(a==null)break;if(Array.isArray(a)&&typeof l=="number")a=a[l];else if(typeof a=="object"&&typeof l=="string"){let m=a;if(!Object.hasOwn(m,l)){a=null;break}a=m[l]}else{a=null;break}}h=u(h,y,a)}return[h]}case"paths":{let o=[],h=(y,a)=>{if(y&&typeof y=="object")if(Array.isArray(y))for(let l=0;l<y.length;l++)o.push([...a,l]),h(y[l],[...a,l]);else for(let l of Object.keys(y))o.push([...a,l]),h(y[l],[...a,l])};return h(t,[]),e.length>0?o.filter(y=>{let a=t;for(let m of y)if(Array.isArray(a)&&typeof m=="number")a=a[m];else if(a&&typeof a=="object"&&typeof m=="string"){let A=a;if(!Object.hasOwn(A,m))return!1;a=A[m]}else return!1;return p(a,e[0],n).some(i)}):o}case"leaf_paths":{let o=[],h=(y,a)=>{if(y===null||typeof y!="object")o.push(a);else if(Array.isArray(y))for(let l=0;l<y.length;l++)h(y[l],[...a,l]);else for(let l of Object.keys(y))h(y[l],[...a,l])};return h(t,[]),o}default:return null}}function it(t,r,e,n,p,i){switch(r){case"IN":{if(e.length===0)return[!1];if(e.length===1){let f=p(t,e[0],n);for(let o of f)if(i(t,o))return[!0];return[!1]}let u=p(t,e[0],n),c=p(t,e[1],n),s=new Set(c.map(f=>JSON.stringify(f)));for(let f of u)if(s.has(JSON.stringify(f)))return[!0];return[!1]}case"INDEX":{if(e.length===0)return[Object.create(null)];if(e.length===1){let s=p(t,e[0],n),f=Object.create(null);for(let o of s){let h=String(o);b(h)&&g(f,h,o)}return[f]}if(e.length===2){let s=p(t,e[0],n),f=Object.create(null);for(let o of s){let h=p(o,e[1],n);if(h.length>0){let y=String(h[0]);b(y)&&g(f,y,o)}}return[f]}let u=p(t,e[0],n),c=Object.create(null);for(let s of u){let f=p(s,e[1],n),o=p(s,e[2],n);if(f.length>0&&o.length>0){let h=String(f[0]);b(h)&&g(c,h,o[0])}}return[c]}case"JOIN":{if(e.length<2)return[null];let u=p(t,e[0],n)[0];if(!u||typeof u!="object"||Array.isArray(u))return[null];let c=u;if(!Array.isArray(t))return[null];let s=[];for(let f of t){let o=p(f,e[1],n),h=o.length>0?String(o[0]):"",y=C(c,h)?c[h]:null;s.push([f,y])}return[s]}default:return null}}function ot(t,r,e,n,p){switch(r){case"join":{if(!Array.isArray(t))return[null];let i=e.length>0?p(t,e[0],n):[""];for(let u of t)if(Array.isArray(u)||u!==null&&typeof u=="object")throw new Error("cannot join: contains arrays or objects");return i.map(u=>t.map(c=>c===null?"":typeof c=="string"?c:String(c)).join(String(u)))}case"split":{if(typeof t!="string"||e.length===0)return[null];let i=p(t,e[0],n),u=String(i[0]);return[t.split(u)]}case"splits":{if(typeof t!="string"||e.length===0)return[];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"g";return T(u,c.includes("g")?c:`${c}g`).split(t)}catch{return[]}}case"scan":{if(typeof t!="string"||e.length===0)return[];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"";return[...T(u,c.includes("g")?c:`${c}g`).matchAll(t)].map(o=>o.length>1?o.slice(1):o[0])}catch{return[]}}case"test":{if(typeof t!="string"||e.length===0)return[!1];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"";return[T(u,c).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||e.length===0)return[null];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"",f=T(u,`${c}d`).exec(t);if(!f)return[];let o=f.indices;return[{offset:f.index,length:f[0].length,string:f[0],captures:f.slice(1).map((h,y)=>({offset:o?.[y+1]?.[0]??null,length:h?.length??0,string:h??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||e.length===0)return[null];let i=p(t,e[0],n),u=String(i[0]);try{let c=e.length>1?String(p(t,e[1],n)[0]):"",f=T(u,c).match(t);return!f||!f.groups?[Object.create(null)]:[f.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),c=String(i[0]),s=String(u[0]);try{let f=e.length>2?String(p(t,e[2],n)[0]):"";return[T(c,f).replace(t,s)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),c=String(i[0]),s=String(u[0]);try{let f=e.length>2?String(p(t,e[2],n)[0]):"g",o=f.includes("g")?f:`${f}g`;return[T(c,o).replace(t,s)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof t=="string"?[t.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof t!="string"||e.length===0)return[t];let i=p(t,e[0],n),u=String(i[0]);return[t.startsWith(u)?t.slice(u.length):t]}case"rtrimstr":{if(typeof t!="string"||e.length===0)return[t];let i=p(t,e[0],n),u=String(i[0]);return u===""?[t]:[t.endsWith(u)?t.slice(0,-u.length):t]}case"trimstr":{if(typeof t!="string"||e.length===0)return[t];let i=p(t,e[0],n),u=String(i[0]);if(u==="")return[t];let c=t;return c.startsWith(u)&&(c=c.slice(u.length)),c.endsWith(u)&&(c=c.slice(0,-u.length)),[c]}case"trim":if(typeof t=="string")return[t.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof t=="string")return[t.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof t=="string")return[t.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof t!="string"||e.length===0)return[!1];let i=p(t,e[0],n);return[t.startsWith(String(i[0]))]}case"endswith":{if(typeof t!="string"||e.length===0)return[!1];let i=p(t,e[0],n);return[t.endsWith(String(i[0]))]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(t))throw new Error("implode input must be an array");return[t.map(c=>{if(typeof c=="string")throw new Error(`string (${JSON.stringify(c)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof c!="number"||Number.isNaN(c))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let s=Math.trunc(c);return s<0||s>1114111||s>=55296&&s<=57343?String.fromCodePoint(65533):String.fromCodePoint(s)}).join("")];default:return null}}function ft(t,r){switch(r){case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"values":return t===null?[]:[t];case"not":return t===!1||t===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}function F(t,r,e){if(r.length===0)return e;let[n,...p]=r;if(typeof n=="number"){if(t&&typeof t=="object"&&!Array.isArray(t))throw new Error("Cannot index object with number");if(n>536870911)throw new Error("Array index too large");if(n<0)throw new Error("Out of bounds negative array index");let s=Array.isArray(t)?[...t]:[];for(;s.length<=n;)s.push(null);return s[n]=F(s[n],p,e),s}if(Array.isArray(t))throw new Error("Cannot index array with string");if(!b(n))return t??Object.create(null);let i=t&&typeof t=="object"&&!Array.isArray(t)?k(t):Object.create(null),u=Object.hasOwn(i,n)?i[n]:void 0;return g(i,n,F(u,p,e)),i}function K(t,r){if(r.length===0)return null;if(r.length===1){let p=r[0];if(Array.isArray(t)&&typeof p=="number"){let i=[...t];return i.splice(p,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i=String(p);if(!b(i))return t;let u=k(t);return delete u[i],u}return t}let[e,...n]=r;if(Array.isArray(t)&&typeof e=="number"){let p=[...t];return p[e]=K(p[e],n),p}if(t&&typeof t=="object"&&!Array.isArray(t)){let p=String(e);if(!b(p))return t;let i=k(t);return Object.hasOwn(i,p)&&g(i,p,K(i[p],n)),i}return t}var D=class t extends Error{label;partialResults;constructor(r,e=[]){super(`break ${r}`),this.label=r,this.partialResults=e,this.name="BreakError"}withPrependedResults(r){return new t(this.label,[...r,...this.partialResults])}},J=class extends Error{value;constructor(r){super(typeof r=="string"?r:JSON.stringify(r)),this.value=r,this.name="JqError"}},Ot=1e4,mt=2e3,Nt=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]]);function St(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??Ot,maxDepth:t?.limits?.maxDepth??mt},env:t?.env,coverage:t?.coverage,requireDefenseContext:t?.requireDefenseContext,defenseContextChecked:!1}}function H(t,r,e){let n=new Map(t.vars);return n.set(r,e),{vars:n,limits:t.limits,env:t.env,requireDefenseContext:t.requireDefenseContext,defenseContextChecked:t.defenseContextChecked,root:t.root,currentPath:t.currentPath,funcs:t.funcs,labels:t.labels,coverage:t.coverage}}function U(t,r,e){switch(r.type){case"var":return H(t,r.name,e);case"array":{if(!Array.isArray(e))return null;let n=t;for(let p=0;p<r.elements.length;p++){let i=r.elements[p],u=p<e.length?e[p]:null,c=U(n,i,u);if(c===null)return null;n=c}return n}case"object":{if(e===null||typeof e!="object"||Array.isArray(e))return null;let n=e,p=t;for(let i of r.fields){let u;if(typeof i.key=="string")u=i.key;else{let f=d(e,i.key,t);if(f.length===0)return null;u=String(f[0])}let c=C(n,u)?n[u]:null;i.keyVar&&(p=H(p,i.keyVar,c));let s=U(p,i.pattern,c);if(s===null)return null;p=s}return p}}}function Ct(t,r){let e=t;for(let n of r)if(e&&typeof e=="object")if(Array.isArray(e))if(typeof n=="number")e=e[n];else return;else{let p=e;if(typeof n=="string"&&Object.hasOwn(p,n))e=p[n];else return}else return;return e}function j(t){if(t.type==="Identity")return[];if(t.type==="Field"){let r=t.base?j(t.base):[];return r===null?null:[...r,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let r=t.base?j(t.base):[];if(r===null)return null;let e=t.index.value;return typeof e=="number"||typeof e=="string"?[...r,e]:null}if(t.type==="Pipe"){let r=j(t.left);return r===null?null:ct(r,t.right)}if(t.type==="Call"){if(t.name==="parent"||t.name==="root")return null;if(t.name==="first"&&t.args.length===0)return[0];if(t.name==="last"&&t.args.length===0)return[-1]}return null}function ct(t,r){if(r.type==="Call"){if(r.name==="parent"){let e=1;if(r.args.length>0&&r.args[0].type==="Literal"){let n=r.args[0].value;typeof n=="number"&&(e=n)}if(e>=0)return t.slice(0,Math.max(0,t.length-e));{let n=-e-1;return t.slice(0,Math.min(n,t.length))}}if(r.name==="root")return[]}if(r.type==="Field"){let e=j(r);if(e!==null)return[...t,...e]}if(r.type==="Index"&&r.index.type==="Literal"){let e=j(r);if(e!==null)return[...t,...e]}if(r.type==="Pipe"){let e=ct(t,r.left);return e===null?null:ct(e,r.right)}return r.type==="Identity"?t:null}function at(t,r,e){if(r.type==="Comma"){let n=[];try{n.push(...d(t,r.left,e))}catch(p){if(p instanceof P)throw p;if(n.length>0)return n;throw new Error("evaluation failed")}try{n.push(...d(t,r.right,e))}catch(p){if(p instanceof P)throw p;return n}return n}return d(t,r,e)}function d(t,r,e){let n=e&&"vars"in e?e:St(e);switch(n.defenseContextChecked||(ht(n.requireDefenseContext,"query-engine","evaluation"),n={...n,defenseContextChecked:!0}),n.root===void 0&&(n={...n,root:t,currentPath:[]}),n.coverage?.hit(`jq:node:${r.type}`),r.type){case"Identity":return[t];case"Field":return(r.base?d(t,r.base,n):[t]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let c=i;if(!Object.hasOwn(c,r.name))return[null];let s=c[r.name];return[s===void 0?null:s]}if(i===null)return[null];let u=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${u} with string "${r.name}"`)});case"Index":return(r.base?d(t,r.base,n):[t]).flatMap(i=>d(i,r.index,n).flatMap(c=>{if(typeof c=="number"&&Array.isArray(i)){if(Number.isNaN(c))return[null];let s=Math.trunc(c),f=s<0?i.length+s:s;return f>=0&&f<i.length?[i[f]]:[null]}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){let s=i;return Object.hasOwn(s,c)?[s[c]]:[null]}return[null]}));case"Slice":return(r.base?d(t,r.base,n):[t]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let u=i.length,c=r.start?d(t,r.start,n):[0],s=r.end?d(t,r.end,n):[u];return c.flatMap(f=>s.map(o=>{let h=f,y=o,a=Number.isNaN(h)?0:Number.isInteger(h)?h:Math.floor(h),l=Number.isNaN(y)?u:Number.isInteger(y)?y:Math.ceil(y),m=lt(a,u),A=lt(l,u);return Array.isArray(i),i.slice(m,A)}))});case"Iterate":return(r.base?d(t,r.base,n):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let p=d(t,r.left,n),i=j(r.left),u=[];for(let c of p)try{if(i!==null){let s={...n,currentPath:[...n.currentPath??[],...i]};u.push(...d(c,r.right,s))}else u.push(...d(c,r.right,n))}catch(s){throw s instanceof D?s.withPrependedResults(u):s}return u}case"Comma":{let p=d(t,r.left,n),i=d(t,r.right,n);return[...p,...i]}case"Literal":return[r.value];case"Array":return r.elements?[d(t,r.elements,n)]:[[]];case"Object":{let p=[Object.create(null)];for(let i of r.entries){let u=typeof i.key=="string"?[i.key]:d(t,i.key,n),c=d(t,i.value,n),s=[];for(let f of p)for(let o of u){if(typeof o!="string"){let h=o===null?"null":Array.isArray(o)?"array":typeof o;throw new Error(`Cannot use ${h} (${JSON.stringify(o)}) as object key`)}if(!b(o)){for(let h of c)s.push(k(f));continue}for(let h of c){let y=k(f);g(y,o,h),s.push(y)}}p.length=0,p.push(...s)}return p}case"Paren":return d(t,r.expr,n);case"BinaryOp":return Rt(t,r.op,r.left,r.right,n);case"UnaryOp":return d(t,r.operand,n).map(i=>{if(r.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let u=c=>c.length>5?`"${c.slice(0,3)}...`:JSON.stringify(c);throw new Error(`string (${u(i)}) cannot be negated`)}return null}return r.op==="not"?!N(i):null});case"Cond":return d(t,r.cond,n).flatMap(i=>{if(N(i))return d(t,r.then,n);for(let u of r.elifs)if(d(t,u.cond,n).some(N))return d(t,u.then,n);return r.else?d(t,r.else,n):[t]});case"Try":try{return d(t,r.body,n)}catch(p){if(r.catch){let i=p instanceof J?p.value:p instanceof Error?p.message:String(p);return d(i,r.catch,n)}return[]}case"Call":return dt(t,r.name,r.args,n);case"VarBind":return d(t,r.value,n).flatMap(i=>{let u=null,c=[];r.pattern?c.push(r.pattern):r.name&&c.push({type:"var",name:r.name}),r.alternatives&&c.push(...r.alternatives);for(let s of c)if(u=U(n,s,i),u!==null)break;return u===null?[]:d(t,r.body,u)});case"VarRef":{if(r.name==="$ENV")return[n.env?G(n.env):Object.create(null)];let p=n.vars.get(r.name);return p!==void 0?[p]:[null]}case"Recurse":{let p=[],i=new WeakSet,u=c=>{if(c&&typeof c=="object"){if(i.has(c))return;i.add(c)}if(p.push(c),Array.isArray(c))for(let s of c)u(s);else if(c&&typeof c=="object")for(let s of Object.keys(c))u(c[s])};return u(t),p}case"Optional":try{return d(t,r.expr,n)}catch{return[]}case"StringInterp":return[r.parts.map(i=>typeof i=="string"?i:d(t,i,n).map(c=>typeof c=="string"?c:JSON.stringify(c)).join("")).join("")];case"UpdateOp":return[Tt(t,r.path,r.op,r.value,n)];case"Reduce":{let p=d(t,r.expr,n),i=d(t,r.init,n)[0],u=n.limits.maxDepth??mt;for(let c of p){let s;if(r.pattern){if(s=U(n,r.pattern,c),s===null)continue}else s=H(n,r.varName,c);if(i=d(i,r.update,s)[0],I(i,u+1)>u)return[null]}return[i]}case"Foreach":{let p=d(t,r.expr,n),i=d(t,r.init,n)[0],u=[];for(let c of p)try{let s;if(r.pattern){if(s=U(n,r.pattern,c),s===null)continue}else s=H(n,r.varName,c);if(i=d(i,r.update,s)[0],r.extract){let f=d(i,r.extract,s);u.push(...f)}else u.push(i)}catch(s){throw s instanceof D?s.withPrependedResults(u):s}return u}case"Label":try{return d(t,r.body,{...n,labels:new Set([...n.labels??[],r.name])})}catch(p){if(p instanceof D&&p.label===r.name)return p.partialResults;throw p}case"Break":throw new D(r.name);case"Def":{let p=new Map(n.funcs??[]),i=`${r.name}/${r.params.length}`;p.set(i,{params:r.params,body:r.funcBody,closure:new Map(n.funcs??[])});let u={...n,funcs:p};return d(t,r.body,u)}default:{let p=r;throw new Error(`Unknown AST node type: ${p.type}`)}}}function lt(t,r){return t<0?Math.max(0,r+t):Math.min(t,r)}function Tt(t,r,e,n,p){function i(s,f){switch(e){case"=":return f;case"|=":return d(s,n,p)[0]??null;case"+=":return typeof s=="number"&&typeof f=="number"||typeof s=="string"&&typeof f=="string"?s+f:Array.isArray(s)&&Array.isArray(f)?[...s,...f]:s&&f&&typeof s=="object"&&typeof f=="object"?X(s,f):f;case"-=":return typeof s=="number"&&typeof f=="number"?s-f:s;case"*=":return typeof s=="number"&&typeof f=="number"?s*f:s;case"/=":return typeof s=="number"&&typeof f=="number"?s/f:s;case"%=":return typeof s=="number"&&typeof f=="number"?s%f:s;case"//=":return s===null||s===!1?f:s;default:return f}}function u(s,f,o){switch(f.type){case"Identity":return o(s);case"Field":{if(!b(f.name))return s;if(f.base)return u(s,f.base,h=>{if(h&&typeof h=="object"&&!Array.isArray(h)){let y=k(h),a=Object.hasOwn(y,f.name)?y[f.name]:void 0;return g(y,f.name,o(a)),y}return h});if(s&&typeof s=="object"&&!Array.isArray(s)){let h=k(s),y=Object.hasOwn(h,f.name)?h[f.name]:void 0;return g(h,f.name,o(y)),h}return s}case"Index":{let y=d(t,f.index,p)[0];if(typeof y=="number"&&Number.isNaN(y))throw new Error("Cannot set array element at NaN index");if(typeof y=="number"&&!Number.isInteger(y)&&(y=Math.trunc(y)),f.base)return u(s,f.base,a=>{if(typeof y=="number"&&Array.isArray(a)){let l=[...a],m=y<0?l.length+y:y;if(m>=0){for(;l.length<=m;)l.push(null);l[m]=o(l[m])}return l}if(typeof y=="string"&&a&&typeof a=="object"&&!Array.isArray(a)){if(!b(y))return a;let l=k(a),m=Object.hasOwn(l,y)?l[y]:void 0;return g(l,y,o(m)),l}return a});if(typeof y=="number"){if(y>536870911)throw new Error("Array index too large");if(y<0&&(!s||!Array.isArray(s)))throw new Error("Out of bounds negative array index");if(Array.isArray(s)){let l=[...s],m=y<0?l.length+y:y;if(m>=0){for(;l.length<=m;)l.push(null);l[m]=o(l[m])}return l}if(s==null){let l=[];for(;l.length<=y;)l.push(null);return l[y]=o(null),l}return s}if(typeof y=="string"&&s&&typeof s=="object"&&!Array.isArray(s)){if(!b(y))return s;let a=k(s),l=Object.hasOwn(a,y)?a[y]:void 0;return g(a,y,o(l)),a}return s}case"Iterate":{let h=y=>{if(Array.isArray(y))return y.map(a=>o(a));if(y&&typeof y=="object"){let a=Object.create(null);for(let[l,m]of Object.entries(y))b(l)&&g(a,l,o(m));return a}return y};return f.base?u(s,f.base,h):h(s)}case"Pipe":{let h=u(s,f.left,y=>y);return u(h,f.right,o)}default:return o(s)}}return u(t,r,s=>{if(e==="|=")return i(s,s);let f=d(t,n,p);return i(s,f[0]??null)})}function jt(t,r,e){function n(i,u,c){switch(u.type){case"Identity":return c;case"Field":{if(!b(u.name))return i;if(u.base){let s=d(i,u.base,e)[0],f=n(s,{type:"Field",name:u.name},c);return n(i,u.base,f)}if(i&&typeof i=="object"&&!Array.isArray(i)){let s=k(i);return g(s,u.name,c),s}return i}case"Index":{if(u.base){let o=d(i,u.base,e)[0],h=n(o,{type:"Index",index:u.index},c);return n(i,u.base,h)}let f=d(t,u.index,e)[0];if(typeof f=="number"&&Array.isArray(i)){let o=[...i],h=f<0?o.length+f:f;return h>=0&&h<o.length&&(o[h]=c),o}if(typeof f=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!b(f))return i;let o=k(i);return g(o,f,c),o}return i}default:return i}}function p(i,u){switch(u.type){case"Identity":return null;case"Field":{if(!b(u.name))return i;if(u.base){let s=d(i,u.base,e)[0];if(s==null)return i;let f=p(s,{type:"Field",name:u.name});return n(i,u.base,f)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!b(u.name))return i;let s=k(i);return delete s[u.name],s}return i}case"Index":{if(u.base){let o=d(i,u.base,e)[0];if(o==null)return i;let h=p(o,{type:"Index",index:u.index});return n(i,u.base,h)}let f=d(t,u.index,e)[0];if(typeof f=="number"&&Array.isArray(i)){let o=[...i],h=f<0?o.length+f:f;return h>=0&&h<o.length&&o.splice(h,1),o}if(typeof f=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!b(f))return i;let o=k(i);return delete o[f],o}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?Object.create(null):i;case"Pipe":{let o=function(a,l,m){switch(l.type){case"Identity":return m;case"Field":{if(!b(l.name))return a;if(a&&typeof a=="object"&&!Array.isArray(a)){let A=k(a);return g(A,l.name,m),A}return a}case"Index":{let E=d(t,l.index,e)[0];if(typeof E=="number"&&Array.isArray(a)){let w=[...a],O=E<0?w.length+E:E;return O>=0&&O<w.length&&(w[O]=m),w}if(typeof E=="string"&&a&&typeof a=="object"&&!Array.isArray(a)){if(!b(E))return a;let w=k(a);return g(w,E,m),w}return a}case"Pipe":{let A=d(a,l.left,e)[0],E=o(A,l.right,m);return o(a,l.left,E)}default:return a}};var c=o;let s=u.left,f=u.right,h=d(i,s,e)[0];if(h==null)return i;let y=p(h,f);return o(i,s,y)}default:return i}}return p(t,r)}function Rt(t,r,e,n,p){if(r==="and")return d(t,e,p).flatMap(s=>N(s)?d(t,n,p).map(o=>N(o)):[!1]);if(r==="or")return d(t,e,p).flatMap(s=>N(s)?[!0]:d(t,n,p).map(o=>N(o)));if(r==="//"){let s=d(t,e,p).filter(f=>f!=null&&f!==!1);return s.length>0?s:d(t,n,p)}let i=d(t,e,p),u=d(t,n,p);return i.flatMap(c=>u.map(s=>{switch(r){case"+":return c===null?s:s===null?c:typeof c=="number"&&typeof s=="number"||typeof c=="string"&&typeof s=="string"?c+s:Array.isArray(c)&&Array.isArray(s)?[...c,...s]:c&&s&&typeof c=="object"&&typeof s=="object"&&!Array.isArray(c)&&!Array.isArray(s)?X(c,s):null;case"-":if(typeof c=="number"&&typeof s=="number")return c-s;if(Array.isArray(c)&&Array.isArray(s)){let f=new Set(s.map(o=>JSON.stringify(o)));return c.filter(o=>!f.has(JSON.stringify(o)))}if(typeof c=="string"&&typeof s=="string"){let f=o=>o.length>10?`"${o.slice(0,10)}...`:JSON.stringify(o);throw new Error(`string (${f(c)}) and string (${f(s)}) cannot be subtracted`)}return null;case"*":return typeof c=="number"&&typeof s=="number"?c*s:typeof c=="string"&&typeof s=="number"?c.repeat(s):c&&s&&typeof c=="object"&&typeof s=="object"&&!Array.isArray(c)&&!Array.isArray(s)?z(c,s):null;case"/":if(typeof c=="number"&&typeof s=="number"){if(s===0)throw new Error(`number (${c}) and number (${s}) cannot be divided because the divisor is zero`);return c/s}return typeof c=="string"&&typeof s=="string"?c.split(s):null;case"%":if(typeof c=="number"&&typeof s=="number"){if(s===0)throw new Error(`number (${c}) and number (${s}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(c)&&!Number.isNaN(c)?!Number.isFinite(s)&&!Number.isNaN(s)&&c<0&&s>0?-1:0:c%s}return null;case"==":return x(c,s);case"!=":return!x(c,s);case"<":return B(c,s)<0;case"<=":return B(c,s)<=0;case">":return B(c,s)>0;case">=":return B(c,s)>=0;default:return null}}))}function dt(t,r,e,n){let p=Nt.get(r);if(p)return typeof t=="number"?[p(t)]:[null];let i=et(t,r,e,n,d);if(i!==null)return i;let u=ot(t,r,e,n,d);if(u!==null)return u;let c=Z(t,r,e,n,d);if(c!==null)return c;let s=v(t,r,n.limits.maxDepth);if(s!==null)return s;let f=ft(t,r);if(f!==null)return f;let o=nt(t,r,e,n,d);if(o!==null)return o;let h=W(t,r,e,n,d,at,_,N,$,P);if(h!==null)return h;let y=st(t,r,e,n,d,N,F,K,jt,V);if(y!==null)return y;let a=tt(t,r,e,n,d,x);if(a!==null)return a;let l=Q(t,r,e,n,d,at,N,P);if(l!==null)return l;let m=rt(t,r,e,n,d,N,Ct,dt);if(m!==null)return m;let A=it(t,r,e,n,d,x);if(A!==null)return A;switch(r){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let E=e.length>0?d(t,e[0],n)[0]:t;throw new J(E)}case"env":return[n.env?G(n.env):Object.create(null)];case"debug":return[t];case"input_line_number":return[1];default:{let E=`${r}/${e.length}`,w=n.funcs?.get(E);if(w){let O=w.closure??n.funcs??new Map,S=new Map(O);S.set(E,w);for(let L=0;L<w.params.length;L++){let Et=w.params[L],ut=e[L];if(ut){let R=d(t,ut,n),M;if(R.length===0)M={type:"Call",name:"empty",args:[]};else if(R.length===1)M={type:"Literal",value:R[0]};else{M={type:"Literal",value:R[R.length-1]};for(let Y=R.length-2;Y>=0;Y--)M={type:"Comma",left:{type:"Literal",value:R[Y]},right:M}}S.set(`${Et}/0`,{params:[],body:M})}}let gt={...n,funcs:S};return d(t,w.body,gt)}throw new Error(`Unknown function: ${r}`)}}}function V(t,r,e,n,p){if(r.type==="Comma"){let c=r;V(t,c.left,e,n,p),V(t,c.right,e,n,p);return}let i=j(r);if(i!==null){p.push([...n,...i]);return}if(r.type==="Iterate"){if(Array.isArray(t))for(let c=0;c<t.length;c++)p.push([...n,c]);else if(t&&typeof t=="object")for(let c of Object.keys(t))p.push([...n,c]);return}if(r.type==="Recurse"){let c=(s,f)=>{if(p.push([...n,...f]),s&&typeof s=="object")if(Array.isArray(s))for(let o=0;o<s.length;o++)c(s[o],[...f,o]);else for(let o of Object.keys(s))c(s[o],[...f,o])};c(t,[]);return}if(r.type==="Pipe"){let c=j(r.left);if(c!==null){let s=d(t,r.left,e);for(let f of s)V(f,r.right,e,[...n,...c],p);return}}d(t,r,e).length>0&&p.push(n)}var At=new Map([["and","AND"],["or","OR"],["not","NOT"],["if","IF"],["then","THEN"],["elif","ELIF"],["else","ELSE"],["end","END"],["as","AS"],["try","TRY"],["catch","CATCH"],["true","TRUE"],["false","FALSE"],["null","NULL"],["reduce","REDUCE"],["foreach","FOREACH"],["label","LABEL"],["break","BREAK"],["def","DEF"]]),q=new Set(At.values());function bt(t){let r=[],e=0,n=(f=0)=>t[e+f],p=()=>t[e++],i=()=>e>=t.length,u=f=>f>="0"&&f<="9",c=f=>f>="a"&&f<="z"||f>="A"&&f<="Z"||f==="_",s=f=>c(f)||u(f);for(;!i();){let f=e,o=p();if(!(o===" "||o===" "||o===`
|
|
4
4
|
`||o==="\r")){if(o==="#"){for(;!i()&&n()!==`
|
|
5
5
|
`;)p();continue}if(o==="."&&n()==="."){p(),r.push({type:"DOTDOT",pos:f});continue}if(o==="="&&n()==="="){p(),r.push({type:"EQ",pos:f});continue}if(o==="!"&&n()==="="){p(),r.push({type:"NE",pos:f});continue}if(o==="<"&&n()==="="){p(),r.push({type:"LE",pos:f});continue}if(o===">"&&n()==="="){p(),r.push({type:"GE",pos:f});continue}if(o==="/"&&n()==="/"){p(),n()==="="?(p(),r.push({type:"UPDATE_ALT",pos:f})):r.push({type:"ALT",pos:f});continue}if(o==="+"&&n()==="="){p(),r.push({type:"UPDATE_ADD",pos:f});continue}if(o==="-"&&n()==="="){p(),r.push({type:"UPDATE_SUB",pos:f});continue}if(o==="*"&&n()==="="){p(),r.push({type:"UPDATE_MUL",pos:f});continue}if(o==="/"&&n()==="="){p(),r.push({type:"UPDATE_DIV",pos:f});continue}if(o==="%"&&n()==="="){p(),r.push({type:"UPDATE_MOD",pos:f});continue}if(o==="="&&n()!=="="){r.push({type:"ASSIGN",pos:f});continue}if(o==="."){r.push({type:"DOT",pos:f});continue}if(o==="|"){n()==="="?(p(),r.push({type:"UPDATE_PIPE",pos:f})):r.push({type:"PIPE",pos:f});continue}if(o===","){r.push({type:"COMMA",pos:f});continue}if(o===":"){r.push({type:"COLON",pos:f});continue}if(o===";"){r.push({type:"SEMICOLON",pos:f});continue}if(o==="("){r.push({type:"LPAREN",pos:f});continue}if(o===")"){r.push({type:"RPAREN",pos:f});continue}if(o==="["){r.push({type:"LBRACKET",pos:f});continue}if(o==="]"){r.push({type:"RBRACKET",pos:f});continue}if(o==="{"){r.push({type:"LBRACE",pos:f});continue}if(o==="}"){r.push({type:"RBRACE",pos:f});continue}if(o==="?"){r.push({type:"QUESTION",pos:f});continue}if(o==="+"){r.push({type:"PLUS",pos:f});continue}if(o==="-"){r.push({type:"MINUS",pos:f});continue}if(o==="*"){r.push({type:"STAR",pos:f});continue}if(o==="/"){r.push({type:"SLASH",pos:f});continue}if(o==="%"){r.push({type:"PERCENT",pos:f});continue}if(o==="<"){r.push({type:"LT",pos:f});continue}if(o===">"){r.push({type:"GT",pos:f});continue}if(u(o)){let h=o;for(;!i()&&(u(n())||n()==="."||n()==="e"||n()==="E");)(n()==="e"||n()==="E")&&(t[e+1]==="+"||t[e+1]==="-")&&(h+=p()),h+=p();r.push({type:"NUMBER",value:Number(h),pos:f});continue}if(o==='"'){let h="";for(;!i()&&n()!=='"';)if(n()==="\\"){if(p(),i())break;let y=p();switch(y){case"n":h+=`
|