just-bash 2.11.14 → 2.12.0
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/Bash.d.ts +6 -0
- package/dist/bin/chunks/awk2-YRDDZZBN.js +2 -0
- package/dist/bin/{shell/chunks/bash-WB6O736J.js → chunks/bash-6ZHZ6BX7.js} +1 -1
- package/dist/bin/chunks/{chunk-PDVXLMUU.js → chunk-27KQPTIX.js} +17 -17
- package/dist/bin/chunks/{chunk-XB2MDT3B.js → chunk-3NVWSLHI.js} +1 -1
- package/dist/bin/chunks/{chunk-K5IXNHO5.js → chunk-6KZRLMG3.js} +3 -3
- package/dist/bin/{shell/chunks/chunk-AHMZLMTU.js → chunks/chunk-6L4K3UGO.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-K7XSYP4L.js → chunks/chunk-6SAF32NO.js} +1 -1
- package/dist/bin/chunks/{chunk-V4CRXAQO.js → chunk-7SWOLTCR.js} +1 -1
- package/dist/bin/chunks/{chunk-ISOXAKGQ.js → chunk-CPL5P744.js} +1 -1
- package/dist/bin/chunks/{chunk-BWWPUUC5.js → chunk-EPIOK4SY.js} +1 -1
- package/dist/bin/chunks/chunk-F37UEO7A.js +10 -0
- package/dist/bin/chunks/chunk-GO6FXSC4.js +6 -0
- package/dist/bin/chunks/chunk-HA4QZ6XJ.js +12 -0
- package/dist/bin/chunks/chunk-KTFEQPO7.js +4 -0
- package/dist/bin/{shell/chunks/chunk-LW7FS3EH.js → chunks/chunk-ND23BJUM.js} +1 -1
- package/dist/bin/chunks/chunk-QC46PWBQ.js +63 -0
- package/dist/bin/{shell/chunks/chunk-XORPAMNK.js → chunks/chunk-RYXW3SZQ.js} +1 -1
- package/dist/bin/chunks/chunk-WIWKAGK6.js +2 -0
- package/dist/bin/chunks/{expansion-AMH5BAVV.js → expansion-HLAOHDFJ.js} +1 -1
- package/dist/bin/{shell/chunks/flag-coverage-KFNWHFPU.js → chunks/flag-coverage-GZCUF7B4.js} +1 -1
- package/dist/bin/{shell/chunks/jq-TIHNHMOR.js → chunks/jq-CXSPO2J5.js} +1 -1
- package/dist/bin/chunks/printf-P3QVL4IO.js +2 -0
- package/dist/bin/chunks/python3-XRP5IZRL.js +16 -0
- package/dist/bin/chunks/sed-DNLJZZXZ.js +2 -0
- package/dist/bin/chunks/sleep-RA6DYTJX.js +2 -0
- package/dist/bin/chunks/sqlite3-2UNB5OLS.js +2 -0
- package/dist/bin/chunks/tar-GP2CCB47.js +2 -0
- package/dist/bin/chunks/timeout-QMKFLOWX.js +2 -0
- package/dist/bin/chunks/worker.js +62 -24
- package/dist/bin/chunks/{xan-3IA4WP2G.js → xan-7NIVZ3HP.js} +1 -1
- package/dist/bin/chunks/yq-L5ZSGLLO.js +2 -0
- package/dist/bin/just-bash.js +286 -286
- package/dist/bin/shell/chunks/awk2-YRDDZZBN.js +2 -0
- package/dist/bin/{chunks/bash-WB6O736J.js → shell/chunks/bash-6ZHZ6BX7.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-PDVXLMUU.js → chunk-27KQPTIX.js} +17 -17
- package/dist/bin/shell/chunks/{chunk-XB2MDT3B.js → chunk-3NVWSLHI.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-K5IXNHO5.js → chunk-6KZRLMG3.js} +3 -3
- package/dist/bin/{chunks/chunk-AHMZLMTU.js → shell/chunks/chunk-6L4K3UGO.js} +1 -1
- package/dist/bin/{chunks/chunk-K7XSYP4L.js → shell/chunks/chunk-6SAF32NO.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-V4CRXAQO.js → chunk-7SWOLTCR.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-ISOXAKGQ.js → chunk-CPL5P744.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-BWWPUUC5.js → chunk-EPIOK4SY.js} +1 -1
- package/dist/bin/shell/chunks/chunk-F37UEO7A.js +10 -0
- package/dist/bin/shell/chunks/chunk-GO6FXSC4.js +6 -0
- package/dist/bin/shell/chunks/chunk-HA4QZ6XJ.js +12 -0
- package/dist/bin/shell/chunks/chunk-KTFEQPO7.js +4 -0
- package/dist/bin/{chunks/chunk-LW7FS3EH.js → shell/chunks/chunk-ND23BJUM.js} +1 -1
- package/dist/bin/shell/chunks/chunk-QC46PWBQ.js +63 -0
- package/dist/bin/{chunks/chunk-XORPAMNK.js → shell/chunks/chunk-RYXW3SZQ.js} +1 -1
- package/dist/bin/shell/chunks/chunk-WIWKAGK6.js +2 -0
- package/dist/bin/shell/chunks/{expansion-AMH5BAVV.js → expansion-HLAOHDFJ.js} +1 -1
- package/dist/bin/{chunks/flag-coverage-KFNWHFPU.js → shell/chunks/flag-coverage-GZCUF7B4.js} +1 -1
- package/dist/bin/{chunks/jq-TIHNHMOR.js → shell/chunks/jq-CXSPO2J5.js} +1 -1
- package/dist/bin/shell/chunks/printf-P3QVL4IO.js +2 -0
- package/dist/bin/shell/chunks/python3-XRP5IZRL.js +16 -0
- package/dist/bin/shell/chunks/sed-DNLJZZXZ.js +2 -0
- package/dist/bin/shell/chunks/sleep-RA6DYTJX.js +2 -0
- package/dist/bin/shell/chunks/sqlite3-2UNB5OLS.js +2 -0
- package/dist/bin/shell/chunks/tar-GP2CCB47.js +2 -0
- package/dist/bin/shell/chunks/timeout-QMKFLOWX.js +2 -0
- package/dist/bin/shell/chunks/{xan-3IA4WP2G.js → xan-7NIVZ3HP.js} +1 -1
- package/dist/bin/shell/chunks/yq-L5ZSGLLO.js +2 -0
- package/dist/bin/shell/shell.js +288 -288
- package/dist/bundle/browser.js +617 -615
- package/dist/bundle/chunks/awk2-66MVVLQI.js +1 -0
- package/dist/bundle/chunks/{bash-DYXMG247.js → bash-IJWYRKFO.js} +1 -1
- package/dist/bundle/chunks/{chunk-IBG6HR7V.js → chunk-AOFQVUAD.js} +1 -1
- package/dist/bundle/chunks/{chunk-U5TNQJ3C.js → chunk-C6ZZC5FL.js} +1 -1
- package/dist/bundle/chunks/{chunk-V4CDPGZH.js → chunk-CCCK5QHL.js} +1 -1
- package/dist/bundle/chunks/chunk-D6CWQ5DW.js +5 -0
- package/dist/bundle/chunks/chunk-FPGA7RT4.js +62 -0
- package/dist/bundle/chunks/{chunk-PSW6BMXW.js → chunk-GFQRA5P5.js} +3 -3
- package/dist/bundle/chunks/{chunk-HDZ4QEVJ.js → chunk-K4OVSVUA.js} +17 -17
- package/dist/bundle/chunks/{chunk-FWYCF7NE.js → chunk-KPFCTJEX.js} +1 -1
- package/dist/bundle/chunks/chunk-LEOLL6PF.js +1 -0
- package/dist/bundle/chunks/{chunk-3JDQKHMS.js → chunk-LN5KAJOV.js} +1 -1
- package/dist/bundle/chunks/chunk-R7KYILVY.js +3 -0
- package/dist/bundle/chunks/{chunk-3KWUDRIP.js → chunk-RARYJBGX.js} +1 -1
- package/dist/bundle/chunks/chunk-S7ED3RD5.js +11 -0
- package/dist/bundle/chunks/{chunk-M2LI252W.js → chunk-T56QNPHK.js} +1 -1
- package/dist/bundle/chunks/chunk-VFBZTF5G.js +9 -0
- package/dist/bundle/chunks/{chunk-OAOCWUTE.js → chunk-XULIVM35.js} +1 -1
- package/dist/bundle/chunks/{expansion-5HXXJ2SG.js → expansion-GY7U2FC2.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-ZCNVOYRY.js → flag-coverage-25MQKYJJ.js} +1 -1
- package/dist/bundle/chunks/{jq-YDGLHC7M.js → jq-MYSLFARY.js} +1 -1
- package/dist/bundle/chunks/printf-CX64KX2P.js +1 -0
- package/dist/bundle/chunks/python3-E7VF6UYO.js +15 -0
- package/dist/bundle/chunks/sed-3ZCNFRHI.js +1 -0
- package/dist/bundle/chunks/sleep-RKLUWJ7F.js +1 -0
- package/dist/bundle/chunks/sqlite3-TLIZUW3F.js +1 -0
- package/dist/bundle/chunks/tar-H6XTXOAP.js +1 -0
- package/dist/bundle/chunks/timeout-QDZFJCOQ.js +1 -0
- package/dist/bundle/chunks/worker.js +62 -24
- package/dist/bundle/chunks/{xan-Y62IEVU4.js → xan-VTO4FP3H.js} +1 -1
- package/dist/bundle/chunks/yq-JRZFRYSK.js +1 -0
- package/dist/bundle/index.cjs +763 -761
- package/dist/bundle/index.js +242 -242
- package/dist/commands/python3/protocol.d.ts +0 -1
- package/dist/commands/python3/python3.d.ts +2 -0
- package/dist/commands/tar/archive.d.ts +20 -6
- package/dist/interpreter/errors.d.ts +10 -2
- package/dist/interpreter/helpers/result.d.ts +1 -1
- package/dist/interpreter/types.d.ts +5 -0
- package/dist/limits.d.ts +4 -0
- package/dist/network/allow-list.d.ts +5 -0
- package/dist/network/types.d.ts +6 -0
- package/dist/sandbox/Sandbox.d.ts +6 -0
- package/dist/timers.d.ts +15 -0
- package/dist/types.d.ts +12 -0
- package/dist/vitest-setup.d.ts +1 -0
- package/package.json +2 -2
- package/dist/bin/chunks/awk2-PWEGD656.js +0 -2
- package/dist/bin/chunks/chunk-5UHJVSR5.js +0 -10
- package/dist/bin/chunks/chunk-EFX3F2HZ.js +0 -63
- package/dist/bin/chunks/chunk-P7UCWJ33.js +0 -12
- package/dist/bin/chunks/chunk-RDZMRK5M.js +0 -6
- package/dist/bin/chunks/printf-4NJFGX3O.js +0 -2
- package/dist/bin/chunks/python3-YJ7YGEW7.js +0 -16
- package/dist/bin/chunks/sed-3DO5EXEU.js +0 -2
- package/dist/bin/chunks/sleep-3QRDZXBH.js +0 -2
- package/dist/bin/chunks/sqlite3-4SEIR46P.js +0 -2
- package/dist/bin/chunks/tar-7B5KH3QG.js +0 -2
- package/dist/bin/chunks/timeout-RS7REDYT.js +0 -2
- package/dist/bin/chunks/yq-OUNV2BWM.js +0 -2
- package/dist/bin/shell/chunks/awk2-PWEGD656.js +0 -2
- package/dist/bin/shell/chunks/chunk-5UHJVSR5.js +0 -10
- package/dist/bin/shell/chunks/chunk-EFX3F2HZ.js +0 -63
- package/dist/bin/shell/chunks/chunk-P7UCWJ33.js +0 -12
- package/dist/bin/shell/chunks/chunk-RDZMRK5M.js +0 -6
- package/dist/bin/shell/chunks/printf-4NJFGX3O.js +0 -2
- package/dist/bin/shell/chunks/python3-YJ7YGEW7.js +0 -16
- package/dist/bin/shell/chunks/sed-3DO5EXEU.js +0 -2
- package/dist/bin/shell/chunks/sleep-3QRDZXBH.js +0 -2
- package/dist/bin/shell/chunks/sqlite3-4SEIR46P.js +0 -2
- package/dist/bin/shell/chunks/tar-7B5KH3QG.js +0 -2
- package/dist/bin/shell/chunks/timeout-RS7REDYT.js +0 -2
- package/dist/bin/shell/chunks/yq-OUNV2BWM.js +0 -2
- package/dist/bundle/chunks/awk2-BDPR2JPZ.js +0 -1
- package/dist/bundle/chunks/chunk-7WX4V2UH.js +0 -9
- package/dist/bundle/chunks/chunk-JP44OYZS.js +0 -5
- package/dist/bundle/chunks/chunk-VZWXH2PZ.js +0 -62
- package/dist/bundle/chunks/chunk-XNL7YAHW.js +0 -11
- package/dist/bundle/chunks/printf-IO3EBW5H.js +0 -1
- package/dist/bundle/chunks/python3-6Y4Z63NZ.js +0 -15
- package/dist/bundle/chunks/sed-2K6ULZ6P.js +0 -1
- package/dist/bundle/chunks/sleep-U2ORRQJB.js +0 -1
- package/dist/bundle/chunks/sqlite3-Z2IGWYCE.js +0 -1
- package/dist/bundle/chunks/tar-K7K7BL55.js +0 -1
- package/dist/bundle/chunks/timeout-5UJUQXOE.js +0 -1
- package/dist/bundle/chunks/yq-CESEW5B3.js +0 -1
package/dist/Bash.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* This class provides the shell environment (filesystem, commands, variables)
|
|
8
8
|
* and delegates execution to the Interpreter.
|
|
9
9
|
*/
|
|
10
|
+
import "./timers.js";
|
|
10
11
|
import { type CommandName } from "./commands/registry.js";
|
|
11
12
|
import { type CustomCommand } from "./custom-commands.js";
|
|
12
13
|
import type { IFileSystem, InitialFiles } from "./fs/interface.js";
|
|
@@ -174,6 +175,11 @@ export interface ExecOptions {
|
|
|
174
175
|
* This will be available to commands via stdin (e.g., for `bash -c 'cat'`).
|
|
175
176
|
*/
|
|
176
177
|
stdin?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Abort signal for cooperative cancellation.
|
|
180
|
+
* When aborted, the interpreter stops executing at the next statement boundary.
|
|
181
|
+
*/
|
|
182
|
+
signal?: AbortSignal;
|
|
177
183
|
}
|
|
178
184
|
export declare class Bash {
|
|
179
185
|
readonly fs: IFileSystem;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
+
import{a,b,c,d}from"./chunk-GO6FXSC4.js";import"./chunk-4PRVMER6.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";export{a as bashCommand,c as flagsForFuzzing,b as shCommand,d as shFlagsForFuzzing};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as b,b as
|
|
2
|
+
import{b as p}from"./chunk-KTFEQPO7.js";import{a as j,b as h}from"./chunk-WIWKAGK6.js";import{a as S,b as q}from"./chunk-GTNBSMZR.js";import{existsSync as g}from"node:fs";import{dirname as H,join as w}from"node:path";import{fileURLToPath as J}from"node:url";import{Worker as W}from"node:worker_threads";import _ from"sql.js";function T(e,r,n){switch(n.mode){case"list":return V(e,r,n);case"csv":return O(e,r,n);case"json":return I(e,r);case"line":return N(e,r,n);case"column":return P(e,r,n);case"table":return M(e,r,n);case"markdown":return R(e,r,n);case"tabs":return F(e,r,n);case"box":return Q(e,r,n);case"quote":return B(e,r,n);case"html":return D(e,r,n);case"ascii":return U(e,r,n)}}function u(e,r){return e==null?r:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString("utf8"):typeof e=="number"&&!Number.isInteger(e)?e.toPrecision(17).replace(/\.?0+$/,""):String(e)}function V(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.join(n.separator));for(let l of r)t.push(l.map(i=>u(i,n.nullValue)).join(n.separator));return t.length>0?`${t.join(n.newline)}${n.newline}`:""}function O(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.map(x).join(","));for(let l of r)t.push(l.map(i=>x(u(i,n.nullValue))).join(","));return t.length>0?`${t.join(`
|
|
3
3
|
`)}
|
|
4
|
-
`:""}function
|
|
5
|
-
`)?`"${e.replace(/"/g,'""')}"`:e}function
|
|
4
|
+
`:""}function x(e){return e.includes(",")||e.includes('"')||e.includes("'")||e.includes(`
|
|
5
|
+
`)?`"${e.replace(/"/g,'""')}"`:e}function y(e){return e.toPrecision(17).replace(/\.?0+$/,"")}function A(e){return e===null?"null":typeof e=="number"?Number.isInteger(e)?String(e):y(e):JSON.stringify(e)}function I(e,r){return r.length===0?"":`[${r.map(t=>`{${e.map((i,s)=>`${JSON.stringify(i)}:${A(t[s])}`).join(",")}}`).join(`,
|
|
6
6
|
`)}]
|
|
7
|
-
`}function
|
|
7
|
+
`}function N(e,r,n){if(e.length===0||r.length===0)return"";let t=Math.max(5,...e.map(i=>i.length)),l=[];for(let i of r)for(let s=0;s<e.length;s++){let o=e[s].padStart(t);l.push(`${o} = ${u(i[s],n.nullValue)}`)}return`${l.join(`
|
|
8
8
|
`)}
|
|
9
|
-
`}function
|
|
9
|
+
`}function P(e,r,n){if(e.length===0)return"";let t=e.map(i=>i.length);for(let i of r)for(let s=0;s<i.length;s++){let o=u(i[s],n.nullValue).length;o>t[s]&&(t[s]=o)}let l=[];n.header&&(l.push(e.map((i,s)=>i.padEnd(t[s])).join(" ")),l.push(t.map(i=>"-".repeat(i)).join(" ")));for(let i of r)l.push(i.map((s,o)=>u(s,n.nullValue).padEnd(t[o])).join(" "));return l.length>0?`${l.join(`
|
|
10
10
|
`)}
|
|
11
|
-
`:""}function
|
|
11
|
+
`:""}function M(e,r,n){if(e.length===0)return"";let t=e.map(s=>s.length);for(let s of r)for(let o=0;o<s.length;o++){let f=u(s[o],n.nullValue).length;f>t[o]&&(t[o]=f)}let l=[],i=`+${t.map(s=>"-".repeat(s+2)).join("+")}+`;l.push(i),n.header&&(l.push(`| ${e.map((s,o)=>s.padEnd(t[o])).join(" | ")} |`),l.push(i));for(let s of r)l.push(`| ${s.map((o,f)=>u(o,n.nullValue).padEnd(t[f])).join(" | ")} |`);return l.push(i),`${l.join(`
|
|
12
12
|
`)}
|
|
13
|
-
`}function
|
|
13
|
+
`}function R(e,r,n){if(e.length===0)return"";let t=[];n.header&&(t.push(`| ${e.join(" | ")} |`),t.push(`|${e.map(()=>"---").join("|")}|`));for(let l of r)t.push(`| ${l.map(i=>u(i,n.nullValue)).join(" | ")} |`);return t.length>0?`${t.join(`
|
|
14
14
|
`)}
|
|
15
|
-
`:""}function
|
|
15
|
+
`:""}function F(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.join(" "));for(let l of r)t.push(l.map(i=>u(i,n.nullValue)).join(" "));return t.length>0?`${t.join(n.newline)}${n.newline}`:""}function Q(e,r,n){if(e.length===0)return"";let t=e.map(i=>i.length);for(let i of r)for(let s=0;s<i.length;s++){let o=u(i[s],n.nullValue).length;o>t[s]&&(t[s]=o)}let l=[];l.push(`\u250C${t.map(i=>"\u2500".repeat(i+2)).join("\u252C")}\u2510`),l.push(`\u2502 ${e.map((i,s)=>i.padEnd(t[s])).join(" \u2502 ")} \u2502`),l.push(`\u251C${t.map(i=>"\u2500".repeat(i+2)).join("\u253C")}\u2524`);for(let i of r)l.push(`\u2502 ${i.map((s,o)=>u(s,n.nullValue).padEnd(t[o])).join(" \u2502 ")} \u2502`);return l.push(`\u2514${t.map(i=>"\u2500".repeat(i+2)).join("\u2534")}\u2518`),`${l.join(`
|
|
16
16
|
`)}
|
|
17
|
-
`}function
|
|
17
|
+
`}function B(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.map(l=>`'${l}'`).join(","));for(let l of r)t.push(l.map(i=>i==null?"NULL":typeof i=="number"?Number.isInteger(i)?String(i):y(i):`'${String(i)}'`).join(","));return t.length>0?`${t.join(n.newline)}${n.newline}`:""}function D(e,r,n){let t=[];n.header&&e.length>0&&(t.push(`<TR>${e.map(l=>`<TH>${E(l)}</TH>`).join("")}`),t.push("</TR>"));for(let l of r)t.push(`<TR>${l.map(i=>`<TD>${E(u(i,n.nullValue))}</TD>`).join("")}`),t.push("</TR>");return t.length>0?`${t.join(`
|
|
18
18
|
`)}
|
|
19
|
-
`:""}function
|
|
19
|
+
`:""}function E(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function U(e,r,n){let i=[];n.header&&e.length>0&&i.push(e.join(""));for(let s of r)i.push(s.map(o=>u(o,n.nullValue)).join(""));return i.length>0?i.join("")+"":""}var z=5e3,X={name:"sqlite3",summary:"SQLite database CLI",usage:"sqlite3 [OPTIONS] DATABASE [SQL]",options:["-list output in list mode (default)","-csv output in CSV mode","-json output in JSON mode","-line output in line mode","-column output in column mode","-table output as ASCII table","-markdown output as markdown table","-tabs output in tab-separated mode","-box output in Unicode box mode","-quote output in SQL quote mode","-html output as HTML table","-ascii output in ASCII mode (control chars)","-header show column headers","-noheader hide column headers","-separator SEP field separator for list mode (default: |)","-newline SEP row separator (default: \\n)","-nullvalue TEXT text for NULL values (default: empty)","-readonly open database read-only (no writeback)","-bail stop on first error","-echo print SQL before execution","-cmd COMMAND run SQL command before main SQL","-version show SQLite version","-- end of options","--help show this help"],examples:['sqlite3 :memory: "CREATE TABLE t(x); INSERT INTO t VALUES(1); SELECT * FROM t"','sqlite3 -json data.db "SELECT * FROM users"','sqlite3 -csv -header data.db "SELECT id, name FROM products"','sqlite3 -box data.db "SELECT * FROM users"']};function Y(e){let r={mode:"list",header:!1,separator:"|",newline:`
|
|
20
20
|
`,nullValue:"",readonly:!1,bail:!1,echo:!1,cmd:null},n=null,t=null,l=!1,i=!1;for(let s=0;s<e.length;s++){let o=e[s];if(i){n===null?n=o:t===null&&(t=o);continue}if(o==="--")i=!0;else if(o==="-version")l=!0;else if(o==="-list")r.mode="list";else if(o==="-csv")r.mode="csv";else if(o==="-json")r.mode="json";else if(o==="-line")r.mode="line";else if(o==="-column")r.mode="column";else if(o==="-table")r.mode="table";else if(o==="-markdown")r.mode="markdown";else if(o==="-tabs")r.mode="tabs";else if(o==="-box")r.mode="box";else if(o==="-quote")r.mode="quote";else if(o==="-html")r.mode="html";else if(o==="-ascii")r.mode="ascii";else if(o==="-header")r.header=!0;else if(o==="-noheader")r.header=!1;else if(o==="-readonly")r.readonly=!0;else if(o==="-bail")r.bail=!0;else if(o==="-echo")r.echo=!0;else if(o==="-separator"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -separator
|
|
21
21
|
`,exitCode:1};r.separator=e[++s]}else if(o==="-newline"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -newline
|
|
22
22
|
`,exitCode:1};r.newline=e[++s]}else if(o==="-nullvalue"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -nullvalue
|
|
23
23
|
`,exitCode:1};r.nullValue=e[++s]}else if(o==="-cmd"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -cmd
|
|
24
24
|
`,exitCode:1};r.cmd=e[++s]}else{if(o.startsWith("-"))return{stdout:"",stderr:`sqlite3: Error: unknown option: ${o.startsWith("--")?o.slice(1):o}
|
|
25
25
|
Use -help for a list of options.
|
|
26
|
-
`,exitCode:1};n===null?n=o:t===null&&(t=o)}}return{options:r,database:n,sql:t,showVersion:l}}async function
|
|
26
|
+
`,exitCode:1};n===null?n=o:t===null&&(t=o)}}return{options:r,database:n,sql:t,showVersion:l}}async function G(){let e=await p.runTrustedAsync(()=>_()),r=new e.Database;try{let n=r.exec("SELECT sqlite_version()");return n.length>0&&n[0].values.length>0?String(n[0].values[0][0]):"unknown"}finally{r.close()}}function K(){let e=H(J(import.meta.url)),r=w(e,"../../commands/sqlite3/worker.js");if(g(r))return r;let n=w(e,"worker.js");if(g(n))return n;let t=w(e,"../../../dist/commands/sqlite3/worker.js");if(g(t))return t;throw new Error("sqlite3 worker not found. Run 'pnpm build' to compile the worker.")}async function Z(e,r){try{let n=K();return await new Promise((t,l)=>{let i=p.runTrusted(()=>new W(n,{workerData:e})),s=j(()=>{i.terminate(),t({success:!1,error:`Query timeout: execution exceeded ${r}ms limit`})},r);i.on("message",o=>{if(o.type==="security-violation"){h(s),t({success:!1,error:`Security violation: ${o.violation?.type??"unknown"}`});return}h(s),t(o)}),i.on("error",o=>{h(s),l(o)}),i.on("exit",o=>{h(s),o!==0&&t({success:!1,error:`Worker exited with code ${o}`})})})}catch(n){throw new Error(`sqlite3 worker failed to load: ${n.message}`)}}var ue={name:"sqlite3",async execute(e,r){if(q(e)||e.includes("-help"))return S(X);let n=Y(e);if("exitCode"in n)return n;let{options:t,database:l,sql:i,showVersion:s}=n;if(s)return{stdout:`${await G()}
|
|
27
27
|
`,stderr:"",exitCode:0};if(!l)return{stdout:"",stderr:`sqlite3: missing database argument
|
|
28
28
|
`,exitCode:1};let o=i||r.stdin.trim();if(t.cmd&&(o=t.cmd+(o?`; ${o}`:"")),!o)return{stdout:"",stderr:`sqlite3: no SQL provided
|
|
29
|
-
`,exitCode:1};let f=l===":memory:",m="",
|
|
30
|
-
`,exitCode:1}}let
|
|
29
|
+
`,exitCode:1};let f=l===":memory:",m="",b=null;try{f||(m=r.fs.resolvePath(r.cwd,l),await r.fs.exists(m)&&(b=await r.fs.readFileBuffer(m)))}catch(a){return{stdout:"",stderr:`sqlite3: unable to open database "${l}": ${a.message}
|
|
30
|
+
`,exitCode:1}}let C=r.limits?.maxSqliteTimeoutMs??z,L={dbBuffer:b,sql:o,options:{bail:t.bail,echo:t.echo}},d;try{d=await Z(L,C)}catch(a){return{stdout:"",stderr:`sqlite3: worker error: ${a.message}
|
|
31
31
|
`,exitCode:1}}if(!d.success)return{stdout:"",stderr:`sqlite3: ${d.error}
|
|
32
|
-
`,exitCode:1};let
|
|
33
|
-
`);let
|
|
32
|
+
`,exitCode:1};let k={mode:t.mode,header:t.header,separator:t.separator,newline:t.newline,nullValue:t.nullValue},c="";t.echo&&(c+=`${o}
|
|
33
|
+
`);let $=!1;for(let a of d.results)if(a.type==="error"){if(t.bail)return{stdout:c,stderr:`Error: ${a.error}
|
|
34
34
|
`,exitCode:1};c+=`Error: ${a.error}
|
|
35
|
-
|
|
36
|
-
`,exitCode:1}}return{stdout:c,stderr:"",exitCode
|
|
35
|
+
`,$=!0}else a.columns&&a.rows&&(a.rows.length>0||t.header)&&(c+=T(a.columns,a.rows,k));if(d.hasModifications&&!t.readonly&&!f&&m&&d.dbBuffer)try{await r.fs.writeFile(m,d.dbBuffer)}catch(a){return{stdout:c,stderr:`sqlite3: failed to write database: ${a.message}
|
|
36
|
+
`,exitCode:1}}return{stdout:c,stderr:"",exitCode:$&&t.bail?1:0}}},fe={name:"sqlite3",flags:[],needsArgs:!0};export{ue as a,fe as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as Ja}from"./chunk-QSDVMMYI.js";import{a as Le,b as Oi}from"./chunk-
|
|
2
|
+
import{a as Ja}from"./chunk-QSDVMMYI.js";import{a as Le,b as Oi}from"./chunk-EPIOK4SY.js";import{k as Ts}from"./chunk-6KZRLMG3.js";import{a as Ai,b as Ti,c as ae}from"./chunk-GTNBSMZR.js";import{a as bt,c as b,e as As}from"./chunk-KGOUQS5A.js";var Yi=b((rp,Ri)=>{var{hasOwnProperty:Ps}=Object.prototype,Ms=(s,e={})=>{typeof e=="string"&&(e={section:e}),e.align=e.align===!0,e.newline=e.newline===!0,e.sort=e.sort===!0,e.whitespace=e.whitespace===!0||e.align===!0,e.platform=e.platform||typeof process<"u"&&process.platform,e.bracketedArray=e.bracketedArray!==!1;let t=e.platform==="win32"?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`,n=e.whitespace?" = ":"=",i=[],r=e.sort?Object.keys(s).sort():Object.keys(s),o=0;e.align&&(o=G(r.filter(c=>s[c]===null||Array.isArray(s[c])||typeof s[c]!="object").map(c=>Array.isArray(s[c])?`${c}[]`:c).concat([""]).reduce((c,u)=>G(c).length>=G(u).length?c:u)).length);let a="",l=e.bracketedArray?"[]":"";for(let c of r){let u=s[c];if(u&&Array.isArray(u))for(let f of u)a+=G(`${c}${l}`).padEnd(o," ")+n+G(f)+t;else u&&typeof u=="object"?i.push(c):a+=G(c).padEnd(o," ")+n+G(u)+t}e.section&&a.length&&(a="["+G(e.section)+"]"+(e.newline?t+t:t)+a);for(let c of i){let u=Vi(c,".").join("\\."),f=(e.section?e.section+".":"")+u,d=Ms(s[c],{...e,section:f});a.length&&d.length&&(a+=t),a+=d}return a};function Vi(s,e){var t=0,n=0,i=0,r=[];do if(i=s.indexOf(e,t),i!==-1){if(t=i+e.length,i>0&&s[i-1]==="\\")continue;r.push(s.slice(n,i)),n=i+e.length}while(i!==-1);return r.push(s.slice(n)),r}var ji=(s,e={})=>{e.bracketedArray=e.bracketedArray!==!1;let t=Object.create(null),n=t,i=null,r=/^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i,o=s.split(/[\r\n]+/g),a={};for(let c of o){if(!c||c.match(/^\s*[;#]/)||c.match(/^\s*$/))continue;let u=c.match(r);if(!u)continue;if(u[1]!==void 0){if(i=Nt(u[1]),i==="__proto__"){n=Object.create(null);continue}n=t[i]=t[i]||Object.create(null);continue}let f=Nt(u[2]),d;e.bracketedArray?d=f.length>2&&f.slice(-2)==="[]":(a[f]=(a?.[f]||0)+1,d=a[f]>1);let p=d&&f.endsWith("[]")?f.slice(0,-2):f;if(p==="__proto__")continue;let g=u[3]?Nt(u[4]):!0,h=g==="true"||g==="false"||g==="null"?JSON.parse(g):g;d&&(Ps.call(n,p)?Array.isArray(n[p])||(n[p]=[n[p]]):n[p]=[]),Array.isArray(n[p])?n[p].push(h):n[p]=h}let l=[];for(let c of Object.keys(t)){if(!Ps.call(t,c)||typeof t[c]!="object"||Array.isArray(t[c]))continue;let u=Vi(c,".");n=t;let f=u.pop(),d=f.replace(/\\\./g,".");for(let p of u)p!=="__proto__"&&((!Ps.call(n,p)||typeof n[p]!="object")&&(n[p]=Object.create(null)),n=n[p]);n===t&&d===f||(n[d]=t[c],l.push(c))}for(let c of l)delete t[c];return t},Ki=s=>s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"),G=s=>typeof s!="string"||s.match(/[=\r\n]/)||s.match(/^\[/)||s.length>1&&Ki(s)||s!==s.trim()?JSON.stringify(s):s.split(";").join("\\;").split("#").join("\\#"),Nt=s=>{if(s=(s||"").trim(),Ki(s)){s.charAt(0)==="'"&&(s=s.slice(1,-1));try{s=JSON.parse(s)}catch{}}else{let e=!1,t="";for(let n=0,i=s.length;n<i;n++){let r=s.charAt(n);if(e)"\\;#".indexOf(r)!==-1?t+=r:t+="\\"+r,e=!1;else{if(";#".indexOf(r)!==-1)break;r==="\\"?e=!0:t+=r}}return e&&(t+="\\"),t.trim()}return s};Ri.exports={parse:ji,decode:ji,stringify:Ms,encode:Ms,safe:G,unsafe:Nt}});var O=b($=>{"use strict";var Fs=Symbol.for("yaml.alias"),Di=Symbol.for("yaml.document"),kt=Symbol.for("yaml.map"),zi=Symbol.for("yaml.pair"),js=Symbol.for("yaml.scalar"),It=Symbol.for("yaml.seq"),X=Symbol.for("yaml.node.type"),Xl=s=>!!s&&typeof s=="object"&&s[X]===Fs,Ql=s=>!!s&&typeof s=="object"&&s[X]===Di,Hl=s=>!!s&&typeof s=="object"&&s[X]===kt,Dl=s=>!!s&&typeof s=="object"&&s[X]===zi,Zi=s=>!!s&&typeof s=="object"&&s[X]===js,zl=s=>!!s&&typeof s=="object"&&s[X]===It;function er(s){if(s&&typeof s=="object")switch(s[X]){case kt:case It:return!0}return!1}function Zl(s){if(s&&typeof s=="object")switch(s[X]){case Fs:case kt:case js:case It:return!0}return!1}var ec=s=>(Zi(s)||er(s))&&!!s.anchor;$.ALIAS=Fs;$.DOC=Di;$.MAP=kt;$.NODE_TYPE=X;$.PAIR=zi;$.SCALAR=js;$.SEQ=It;$.hasAnchor=ec;$.isAlias=Xl;$.isCollection=er;$.isDocument=Ql;$.isMap=Hl;$.isNode=Zl;$.isPair=Dl;$.isScalar=Zi;$.isSeq=zl});var Ve=b(Vs=>{"use strict";var M=O(),F=Symbol("break visit"),tr=Symbol("skip children"),J=Symbol("remove node");function qt(s,e){let t=sr(e);M.isDocument(s)?Se(null,s.contents,t,Object.freeze([s]))===J&&(s.contents=null):Se(null,s,t,Object.freeze([]))}qt.BREAK=F;qt.SKIP=tr;qt.REMOVE=J;function Se(s,e,t,n){let i=nr(s,e,t,n);if(M.isNode(i)||M.isPair(i))return ir(s,n,i),Se(s,i,t,n);if(typeof i!="symbol"){if(M.isCollection(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){let o=Se(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===F)return F;o===J&&(e.items.splice(r,1),r-=1)}}}else if(M.isPair(e)){n=Object.freeze(n.concat(e));let r=Se("key",e.key,t,n);if(r===F)return F;r===J&&(e.key=null);let o=Se("value",e.value,t,n);if(o===F)return F;o===J&&(e.value=null)}}return i}async function Ct(s,e){let t=sr(e);M.isDocument(s)?await Ne(null,s.contents,t,Object.freeze([s]))===J&&(s.contents=null):await Ne(null,s,t,Object.freeze([]))}Ct.BREAK=F;Ct.SKIP=tr;Ct.REMOVE=J;async function Ne(s,e,t,n){let i=await nr(s,e,t,n);if(M.isNode(i)||M.isPair(i))return ir(s,n,i),Ne(s,i,t,n);if(typeof i!="symbol"){if(M.isCollection(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){let o=await Ne(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===F)return F;o===J&&(e.items.splice(r,1),r-=1)}}}else if(M.isPair(e)){n=Object.freeze(n.concat(e));let r=await Ne("key",e.key,t,n);if(r===F)return F;r===J&&(e.key=null);let o=await Ne("value",e.value,t,n);if(o===F)return F;o===J&&(e.value=null)}}return i}function sr(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}function nr(s,e,t,n){if(typeof t=="function")return t(s,e,n);if(M.isMap(e))return t.Map?.(s,e,n);if(M.isSeq(e))return t.Seq?.(s,e,n);if(M.isPair(e))return t.Pair?.(s,e,n);if(M.isScalar(e))return t.Scalar?.(s,e,n);if(M.isAlias(e))return t.Alias?.(s,e,n)}function ir(s,e,t){let n=e[e.length-1];if(M.isCollection(n))n.items[s]=t;else if(M.isPair(n))s==="key"?n.key=t:n.value=t;else if(M.isDocument(n))n.contents=t;else{let i=M.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}Vs.visit=qt;Vs.visitAsync=Ct});var Ks=b(or=>{"use strict";var rr=O(),tc=Ve(),sc={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},nc=s=>s.replace(/[!,[\]{}]/g,e=>sc[e]),Ke=class s{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,e),this.tags=Object.assign({},s.defaultTags,t)}clone(){let e=new s(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[r,o]=n;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);let r=this.tags[n];if(r)try{return r+decodeURIComponent(i)}catch(o){return t(String(o)),null}return n==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+nc(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&rr.isNode(e.contents)){let r={};tc.visit(e.contents,(o,a)=>{rr.isNode(a)&&a.tag&&(r[a.tag]=!0)}),i=Object.keys(r)}else i=[];for(let[r,o]of n)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
|
|
5
5
|
`)}};Ke.defaultYaml={explicit:!1,version:"1.2"};Ke.defaultTags={"!!":"tag:yaml.org,2002:"};or.Directives=Ke});var Lt=b(Re=>{"use strict";var ar=O(),ic=Ve();function rc(s){if(/[\x00-\x19\s,[\]{}]/.test(s)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function lr(s){let e=new Set;return ic.visit(s,{Value(t,n){n.anchor&&e.add(n.anchor)}}),e}function cr(s,e){for(let t=1;;++t){let n=`${s}${t}`;if(!e.has(n))return n}}function oc(s,e){let t=[],n=new Map,i=null;return{onAnchor:r=>{t.push(r),i??(i=lr(s));let o=cr(e,i);return i.add(o),o},setAnchors:()=>{for(let r of t){let o=n.get(r);if(typeof o=="object"&&o.anchor&&(ar.isScalar(o.node)||ar.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:n}}Re.anchorIsValid=rc;Re.anchorNames=lr;Re.createNodeAnchors=oc;Re.findNewAnchor=cr});var Rs=b(fr=>{"use strict";function Ye(s,e,t,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let i=0,r=n.length;i<r;++i){let o=n[i],a=Ye(s,n,String(i),o);a===void 0?delete n[i]:a!==o&&(n[i]=a)}else if(n instanceof Map)for(let i of Array.from(n.keys())){let r=n.get(i),o=Ye(s,n,i,r);o===void 0?n.delete(i):o!==r&&n.set(i,o)}else if(n instanceof Set)for(let i of Array.from(n)){let r=Ye(s,n,i,i);r===void 0?n.delete(i):r!==i&&(n.delete(i),n.add(r))}else for(let[i,r]of Object.entries(n)){let o=Ye(s,n,i,r);o===void 0?delete n[i]:o!==r&&(n[i]=o)}return s.call(e,t,n)}fr.applyReviver=Ye});var D=b(dr=>{"use strict";var ac=O();function ur(s,e,t){if(Array.isArray(s))return s.map((n,i)=>ur(n,String(i),t));if(s&&typeof s.toJSON=="function"){if(!t||!ac.hasAnchor(s))return s.toJSON(e,t);let n={aliasCount:0,count:1,res:void 0};t.anchors.set(s,n),t.onCreate=r=>{n.res=r,delete t.onCreate};let i=s.toJSON(e,t);return t.onCreate&&t.onCreate(i),i}return typeof s=="bigint"&&!t?.keep?Number(s):s}dr.toJS=ur});var Pt=b(pr=>{"use strict";var lc=Rs(),hr=O(),cc=D(),Ys=class{constructor(e){Object.defineProperty(this,hr.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:i,reviver:r}={}){if(!hr.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=cc.toJS(this,"",o);if(typeof i=="function")for(let{count:l,res:c}of o.anchors.values())i(c,l);return typeof r=="function"?lc.applyReviver(r,{"":a},"",a):a}};pr.NodeBase=Ys});var Ue=b(mr=>{"use strict";var fc=Lt(),uc=Ve(),Ee=O(),dc=Pt(),hc=D(),Us=class extends dc.NodeBase{constructor(e){super(Ee.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],uc.visit(e,{Node:(r,o)=>{(Ee.isAlias(o)||Ee.hasAnchor(o))&&n.push(o)}}),t&&(t.aliasResolveCache=n));let i;for(let r of n){if(r===this)break;r.anchor===this.source&&(i=r)}return i}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:i,maxAliasCount:r}=t,o=this.resolve(i,t);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=n.get(o);if(a||(hc.toJS(o,null,t),a=n.get(o)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(r>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Mt(i,o,n)),a.count*a.aliasCount>r)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,t,n){let i=`*${this.source}`;if(e){if(fc.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${i} `}return i}};function Mt(s,e,t){if(Ee.isAlias(e)){let n=e.resolve(s),i=t&&n&&t.get(n);return i?i.count*i.aliasCount:0}else if(Ee.isCollection(e)){let n=0;for(let i of e.items){let r=Mt(s,i,t);r>n&&(n=r)}return n}else if(Ee.isPair(e)){let n=Mt(s,e.key,t),i=Mt(s,e.value,t);return Math.max(n,i)}return 1}mr.Alias=Us});var C=b(Js=>{"use strict";var pc=O(),mc=Pt(),gc=D(),yc=s=>!s||typeof s!="function"&&typeof s!="object",z=class extends mc.NodeBase{constructor(e){super(pc.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:gc.toJS(this.value,e,t)}toString(){return String(this.value)}};z.BLOCK_FOLDED="BLOCK_FOLDED";z.BLOCK_LITERAL="BLOCK_LITERAL";z.PLAIN="PLAIN";z.QUOTE_DOUBLE="QUOTE_DOUBLE";z.QUOTE_SINGLE="QUOTE_SINGLE";Js.Scalar=z;Js.isScalarValue=yc});var Je=b(yr=>{"use strict";var bc=Ue(),fe=O(),gr=C(),wc="tag:yaml.org,2002:";function Sc(s,e,t){if(e){let n=t.filter(r=>r.tag===e),i=n.find(r=>!r.format)??n[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return t.find(n=>n.identify?.(s)&&!n.format)}function Nc(s,e,t){if(fe.isDocument(s)&&(s=s.contents),fe.isNode(s))return s;if(fe.isPair(s)){let f=t.schema[fe.MAP].createNode?.(t.schema,null,t);return f.items.push(s),f}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt<"u"&&s instanceof BigInt)&&(s=s.valueOf());let{aliasDuplicateObjects:n,onAnchor:i,onTagObj:r,schema:o,sourceObjects:a}=t,l;if(n&&s&&typeof s=="object"){if(l=a.get(s),l)return l.anchor??(l.anchor=i(s)),new bc.Alias(l.anchor);l={anchor:null,node:null},a.set(s,l)}e?.startsWith("!!")&&(e=wc+e.slice(2));let c=Sc(s,e,o.tags);if(!c){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){let f=new gr.Scalar(s);return l&&(l.node=f),f}c=s instanceof Map?o[fe.MAP]:Symbol.iterator in Object(s)?o[fe.SEQ]:o[fe.MAP]}r&&(r(c),delete t.onTagObj);let u=c?.createNode?c.createNode(t.schema,s,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,s,t):new gr.Scalar(s);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}yr.createNode=Nc});var _t=b($t=>{"use strict";var Ec=Je(),W=O(),vc=Pt();function Ws(s,e,t){let n=t;for(let i=e.length-1;i>=0;--i){let r=e[i];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){let o=[];o[r]=n,n=o}else n=new Map([[r,n]])}return Ec.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}var br=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done,Gs=class extends vc.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(n=>W.isNode(n)||W.isPair(n)?n.clone(e):n),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(br(e))this.add(t);else{let[n,...i]=e,r=this.get(n,!0);if(W.isCollection(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(n,Ws(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let i=this.get(t,!0);if(W.isCollection(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...i]=e,r=this.get(n,!0);return i.length===0?!t&&W.isScalar(r)?r.value:r:W.isCollection(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!W.isPair(t))return!1;let n=t.value;return n==null||e&&W.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let i=this.get(t,!0);return W.isCollection(i)?i.hasIn(n):!1}setIn(e,t){let[n,...i]=e;if(i.length===0)this.set(n,t);else{let r=this.get(n,!0);if(W.isCollection(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(n,Ws(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}};$t.Collection=Gs;$t.collectionFromPath=Ws;$t.isEmptyPath=br});var We=b(xt=>{"use strict";var Ac=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function Xs(s,e){return/^\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}var Tc=(s,e,t)=>s.endsWith(`
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var n=class extends Error{stdout;stderr;constructor(t,s="",e=""){super(t),this.stdout=s,this.stderr=e}prependOutput(t,s){this.stdout=t+this.stdout,this.stderr=s+this.stderr}},c=class extends n{levels;name="BreakError";constructor(t=1,s="",e=""){super("break",s,e),this.levels=t}},a=class extends n{levels;name="ContinueError";constructor(t=1,s="",e=""){super("continue",s,e),this.levels=t}},i=class extends n{exitCode;name="ReturnError";constructor(t=0,s="",e=""){super("return",s,e),this.exitCode=t}},u=class extends n{exitCode;name="ErrexitError";constructor(t,s="",e=""){super(`errexit: command exited with status ${t}`,s,e),this.exitCode=t}},x=class extends n{varName;name="NounsetError";constructor(t,s=""){super(`${t}: unbound variable`,s,`bash: ${t}: unbound variable
|
|
3
3
|
`),this.varName=t}},d=class extends n{exitCode;name="ExitError";constructor(t,s="",e=""){super("exit",s,e),this.exitCode=t}},p=class extends n{name="ArithmeticError";fatal;constructor(t,s="",e="",o=!1){super(t,s,e),this.stderr=e||`bash: ${t}
|
|
4
|
-
`,this.fatal=o}},
|
|
5
|
-
`}},
|
|
4
|
+
`,this.fatal=o}},l=class extends n{name="BadSubstitutionError";constructor(t,s="",e=""){super(t,s,e),this.stderr=e||`bash: ${t}: bad substitution
|
|
5
|
+
`}},h=class extends n{name="GlobError";constructor(t,s="",e=""){super(`no match: ${t}`,s,e),this.stderr=e||`bash: no match: ${t}
|
|
6
6
|
`}},m=class extends n{name="BraceExpansionError";constructor(t,s="",e=""){super(t,s,e),this.stderr=e||`bash: ${t}
|
|
7
7
|
`}},b=class extends n{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(t,s,e="",o=""){super(t,e,o),this.limitType=s,this.stderr=o||`bash: ${t}
|
|
8
|
-
`}},$=class extends n{name="SubshellExitError";constructor(t="",s=""){super("subshell exit",t,s)}};function
|
|
8
|
+
`}},$=class extends n{name="ExecutionAbortedError";constructor(t="",s=""){super("execution aborted",t,s)}},f=class extends n{name="SubshellExitError";constructor(t="",s=""){super("subshell exit",t,s)}};function v(r){return r instanceof c||r instanceof a||r instanceof i}var C=class extends n{exitCode;name="PosixFatalError";constructor(t,s="",e=""){super("posix fatal error",s,e),this.exitCode=t}};export{c as a,a as b,i as c,u as d,x as e,d as f,p as g,l as h,h as i,m as j,b as k,$ as l,f as m,v as n,C as o};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as N}from"./chunk-SE4C7FJY.js";import{k as C}from"./chunk-
|
|
2
|
+
import{a as N}from"./chunk-SE4C7FJY.js";import{k as C}from"./chunk-6KZRLMG3.js";import{a as G,b as j,c as T}from"./chunk-GTNBSMZR.js";var B=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]]);function P(n){let e="",t=0,i=!1;for(;t<n.length;){if(n[t]==="["&&!i){if(n[t+1]==="["&&n[t+2]===":"){let s=n.indexOf(":]]",t+3);if(s!==-1){let a=n.slice(t+3,s),r=B.get(a);if(r){e+=`[${r}]`,t=s+3;continue}}}if(n[t+1]==="^"&&n[t+2]==="["&&n[t+3]===":"){let s=n.indexOf(":]]",t+4);if(s!==-1){let a=n.slice(t+4,s),r=B.get(a);if(r){e+=`[^${r}]`,t=s+3;continue}}}e+="[",t++,i=!0,t<n.length&&n[t]==="^"&&(e+="^",t++),t<n.length&&n[t]==="]"&&(e+="\\]",t++);continue}if(i){if(n[t]==="]"){e+="]",t++,i=!1;continue}if(n[t]==="["&&n[t+1]===":"){let s=n.indexOf(":]",t+2);if(s!==-1){let a=n.slice(t+2,s),r=B.get(a);if(r){e+=r,t=s+2;continue}}}if(n[t]==="\\"&&t+1<n.length){e+=n[t]+n[t+1],t+=2;continue}e+=n[t],t++;continue}if(n[t]==="\\"&&t+1<n.length){let s=n[t+1];if(s==="+"||s==="?"||s==="|"){e+=s,t+=2;continue}if(s==="("||s===")"){e+=s,t+=2;continue}if(s==="{"||s==="}"){e+=s,t+=2;continue}if(s==="t"){e+=" ",t+=2;continue}if(s==="n"){e+=`
|
|
3
3
|
`,t+=2;continue}if(s==="r"){e+="\r",t+=2;continue}e+=n[t]+s,t+=2;continue}if(n[t]==="+"||n[t]==="?"||n[t]==="|"||n[t]==="("||n[t]===")"){e+=`\\${n[t]}`,t++;continue}if(n[t]==="^"&&!(e===""||e.endsWith("("))){e+="\\^",t++;continue}if(n[t]==="$"){let s=t===n.length-1,a=t+2<n.length&&n[t+1]==="\\"&&n[t+2]===")";if(!s&&!a){e+="\\$",t++;continue}}e+=n[t],t++}return e}function D(n){let e="",t=!1;for(let i=0;i<n.length;i++)n[i]==="["&&!t?(t=!0,e+="[",i++,i<n.length&&n[i]==="^"&&(e+="^",i++),i<n.length&&n[i]==="]"&&(e+="]",i++),i--):n[i]==="]"&&t?(t=!1,e+="]"):!t&&n[i]==="{"&&n[i+1]===","?(e+="{0,",i++):e+=n[i];return e}function Z(n){let e="";for(let t=0;t<n.length;t++){let i=n[t],s=i.charCodeAt(0);i==="\\"?e+="\\\\":i===" "?e+="\\t":i===`
|
|
4
4
|
`?e+=`$
|
|
5
5
|
`:i==="\r"?e+="\\r":i==="\x07"?e+="\\a":i==="\b"?e+="\\b":i==="\f"?e+="\\f":i==="\v"?e+="\\v":s<32||s>=127?e+=`\\${s.toString(8).padStart(3,"0")}`:e+=i}return`${e}$`}var ce=1e4;function Q(n,e,t){return{patternSpace:"",holdSpace:"",lineNumber:0,totalLines:n,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,errorMessage:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],nCommandOutput:[],restartCycle:!1,inDRestartedCycle:!1,currentFilename:e,pendingFileReads:[],pendingFileWrites:[],pendingExecute:void 0,rangeStates:t||new Map,linesConsumedInCycle:0}}function le(n){return typeof n=="object"&&"first"in n&&"step"in n}function oe(n){return typeof n=="object"&&"offset"in n}function O(n,e,t,i,s){if(n==="$")return e===t;if(typeof n=="number")return e===n;if(le(n)){let{first:a,step:r}=n;return r===0?e===a:(e-a)%r===0&&e>=a}if(typeof n=="object"&&"pattern"in n)try{let a=n.pattern;a===""&&s?.lastPattern?a=s.lastPattern:a!==""&&s&&(s.lastPattern=a);let r=D(P(a));return N(r).test(i)}catch{return!1}return!1}function W(n){let e=t=>t===void 0?"undefined":t==="$"?"$":typeof t=="number"?String(t):"pattern"in t?`/${t.pattern}/`:"first"in t?`${t.first}~${t.step}`:"unknown";return`${e(n.start)},${e(n.end)}`}function ue(n,e,t,i,s,a){if(!n||!n.start&&!n.end)return!0;let r=n.start,l=n.end;if(r!==void 0&&l===void 0)return O(r,e,t,i,a);if(r!==void 0&&l!==void 0){let o=typeof r=="object"&&"pattern"in r,d=typeof l=="object"&&"pattern"in l,f=oe(l);if(f&&s){let m=W(n),p=s.get(m);if(p||(p={active:!1},s.set(m,p)),p.active){let u=p.startLine||e;return e>=u+l.offset&&(p.active=!1,s.set(m,p)),!0}else return O(r,e,t,i,a)?(p.active=!0,p.startLine=e,s.set(m,p),l.offset===0&&(p.active=!1,s.set(m,p)),!0):!1}if(!o&&!d&&!f){let m=typeof r=="number"?r:r==="$"?t:1,p=typeof l=="number"?l:t;if(m<=p)return e>=m&&e<=p;if(s){let u=W(n),h=s.get(u);return h||(h={active:!1},s.set(u,h)),!h.completed&&e>=m?(h.completed=!0,s.set(u,h),!0):!1}return!1}if(s){let m=W(n),p=s.get(m);if(p||(p={active:!1},s.set(m,p)),p.active)return O(l,e,t,i,a)&&(p.active=!1,typeof r=="number"&&(p.completed=!0),s.set(m,p)),!0;{if(p.completed)return!1;let u=!1;return typeof r=="number"?u=e>=r:u=O(r,e,t,i,a),u?(p.active=!0,p.startLine=e,s.set(m,p),O(l,e,t,i,a)&&(p.active=!1,typeof r=="number"&&(p.completed=!0),s.set(m,p)),!0):!1}}return O(r,e,t,i,a)}return!0}function I(n,e,t,i,s,a){let r=ue(n,e,t,i,s,a);return n?.negated?!r:r}function he(n,e,t,i){let s="",a=0,r=!1;for(;a<=n.length;){e.lastIndex=a;let l=e.exec(n);if(!l){s+=n.slice(a);break}if(l.index!==a){s+=n.slice(a,l.index),a=l.index,r=!1;continue}let o=l[0],d=l.slice(1);if(r&&o.length===0){if(a<n.length)s+=n[a],a++;else break;r=!1;continue}if(s+=i(o,d),r=!1,o.length===0)if(a<n.length)s+=n[a],a++;else break;else a+=o.length,r=!0}return s}function q(n,e,t){let i="",s=0;for(;s<n.length;){if(n[s]==="\\"&&s+1<n.length){let a=n[s+1];if(a==="&"){i+="&",s+=2;continue}if(a==="n"){i+=`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as oe}from"./chunk-4PRVMER6.js";import{a as A,b as P}from"./chunk-SE4C7FJY.js";import{k as O}from"./chunk-
|
|
2
|
+
import{a as oe}from"./chunk-4PRVMER6.js";import{a as A,b as P}from"./chunk-SE4C7FJY.js";import{k as O}from"./chunk-6KZRLMG3.js";import{a as se,b as ae,c as z}from"./chunk-GTNBSMZR.js";var Le=1e4,Me=100,Pe=new P(/\s+/);function Q(e={}){let{fieldSep:t=Pe,maxIterations:n=Le,maxRecursionDepth:i=Me,maxOutputSize:a=0,fs:s,cwd:o,exec:c,coverage:u}=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:a,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:"",openedFiles:new Set,fs:s,cwd:o,exec:c,coverage:u}}function le(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 C(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function I(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}async function U(e,t){if(e.type==="regex")return e.pattern;let n=I(await t.evalExpr(e));return n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)),n}async function ue(e,t){return e?e.type==="variable"?e.name:e.type==="field"?`$${Math.floor(C(await t.evalExpr(e.index)))}`:"$0":"$0"}function he(e,t){if(e==="$0")return t.line;if(e.startsWith("$")){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||""}return I(t.vars[e]??"")}function pe(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 Te(e,t,n){return e.length===0?t.line.length:I(await n.evalExpr(e[0])).length}async function Fe(e,t,n){if(e.length<2)return"";let i=I(await n.evalExpr(e[0])),a=Math.floor(C(await n.evalExpr(e[1])))-1;if(e.length>=3){let s=Math.floor(C(await n.evalExpr(e[2])));return i.substr(Math.max(0,a),s)}return i.substr(Math.max(0,a))}async function _e(e,t,n){if(e.length<2)return 0;let i=I(await n.evalExpr(e[0])),a=I(await n.evalExpr(e[1])),s=i.indexOf(a);return s===-1?0:s+1}async function Ge(e,t,n){if(e.length<2)return 0;let i=I(await n.evalExpr(e[0])),a=e[1];if(a.type!=="variable")return 0;let s=a.name,o=t.FS;if(e.length>=3){let u=e[2];if(u.type==="regex")o=A(u.pattern);else{let N=I(await n.evalExpr(u));o=N===" "?A("\\s+"):N}}else t.FS===" "&&(o=A("\\s+"));let c=typeof o=="string"?i.split(o):o.split(i);t.arrays[s]=Object.create(null);for(let u=0;u<c.length;u++)t.arrays[s][String(u+1)]=c[u];return c.length}async function De(e,t,n){if(e.length<2)return 0;let i=await U(e[0],n),a=I(await n.evalExpr(e[1])),s=await ue(e[2],n),o=he(s,t);try{let u=A(i).replace(o,fe(a)),N=u!==o?1:0;return pe(s,u,t),N}catch{return 0}}async function xe(e,t,n){if(e.length<2)return 0;let i=await U(e[0],n),a=I(await n.evalExpr(e[1])),s=await ue(e[2],n),o=he(s,t);try{let c=A(i,"g"),u=c.match(o),N=u?u.length:0,k=c.replace(o,fe(a));return pe(s,k,t),N}catch{return 0}}function fe(e){return t=>{let n="",i=0;for(;i<e.length;)if(e[i]==="\\"&&i+1<e.length){let a=e[i+1];a==="&"?(n+="&",i+=2):a==="\\"?(n+="\\",i+=2):(n+=e[i+1],i+=2)}else e[i]==="&"?(n+=t,i++):(n+=e[i],i++);return n}}async function Ue(e,t,n){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let i=I(await n.evalExpr(e[0])),a=await U(e[1],n);try{let o=A(a).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 Be(e,t,n){if(e.length<3)return"";let i=await U(e[0],n),a=I(await n.evalExpr(e[1])),s=I(await n.evalExpr(e[2])),o=e.length>=4?I(await n.evalExpr(e[3])):t.line;try{let c=s.toLowerCase()==="g",u=c?0:parseInt(s,10)||1;if(c)return A(i,"g").replace(o,(k,...y)=>ce(a,k,y.slice(0,-2)));{let N=0;return A(i,"g").replace(o,(y,...w)=>(N++,N===u?ce(a,y,w.slice(0,-2)):y))}}catch{return o}}function ce(e,t,n){let i="",a=0;for(;a<e.length;)if(e[a]==="\\"&&a+1<e.length){let s=e[a+1];if(s==="&")i+="&",a+=2;else if(s==="0")i+=t,a+=2;else if(s>="1"&&s<="9"){let o=parseInt(s,10)-1;i+=n[o]||"",a+=2}else s==="n"?(i+=`
|
|
4
4
|
`,a+=2):s==="t"?(i+=" ",a+=2):(i+=s,a+=2)}else e[a]==="&"?(i+=t,a++):(i+=e[a],a++);return i}async function He(e,t,n){return e.length===0?"":I(await n.evalExpr(e[0])).toLowerCase()}async function $e(e,t,n){return e.length===0?"":I(await n.evalExpr(e[0])).toUpperCase()}async function We(e,t,n){if(e.length===0)return"";let i=I(await n.evalExpr(e[0])),a=[];for(let s=1;s<e.length;s++)a.push(await n.evalExpr(e[s]));return B(i,a)}async function Ve(e,t,n){return e.length===0?0:Math.floor(C(await n.evalExpr(e[0])))}async function Ke(e,t,n){return e.length===0?0:Math.sqrt(C(await n.evalExpr(e[0])))}async function Xe(e,t,n){return e.length===0?0:Math.sin(C(await n.evalExpr(e[0])))}async function je(e,t,n){return e.length===0?0:Math.cos(C(await n.evalExpr(e[0])))}async function ze(e,t,n){let i=e.length>0?C(await n.evalExpr(e[0])):0,a=e.length>1?C(await n.evalExpr(e[1])):0;return Math.atan2(i,a)}async function Qe(e,t,n){return e.length===0?0:Math.log(C(await n.evalExpr(e[0])))}async function qe(e,t,n){return e.length===0?1:Math.exp(C(await n.evalExpr(e[0])))}function Je(e,t,n){return t.random?t.random():Math.random()}async function Ze(e,t,n){let i=e.length>0?C(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=i,i}function Ye(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function q(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}var L=1e4;function B(e,t){let n=0,i="",a=0;for(;a<e.length;)if(e[a]==="%"&&a+1<e.length){let s=a+1,o="",c="",u="",N,k=s;for(;s<e.length&&/\d/.test(e[s]);)s++;s>k&&e[s]==="$"?(N=parseInt(e.substring(k,s),10)-1,s++):s=k;let y=()=>{if(s<e.length){if(s+1<e.length&&(e[s]==="h"&&e[s+1]==="h"||e[s]==="l"&&e[s+1]==="l")){s+=2;return}/[lzjh]/.test(e[s])&&s++}};for(;s<e.length&&/[-+ #0]/.test(e[s]);)o+=e[s++];if(e[s]==="*"){let l=t[n++],p=l!==void 0?Math.floor(Number(l)):0;p<0?(o+="-",c=String(Math.min(-p,L))):c=String(Math.min(p,L)),s++}else for(;s<e.length&&/\d/.test(e[s]);)c+=e[s++];if(c&&parseInt(c,10)>L&&(c=String(L)),e[s]==="."){if(s++,e[s]==="*"){let l=t[n++];u=String(Math.min(l!==void 0?Math.floor(Number(l)):0,L)),s++}else for(;s<e.length&&/\d/.test(e[s]);)u+=e[s++];u&&parseInt(u,10)>L&&(u=String(L))}y();let w=e[s],g=t[N!==void 0?N:n];switch(w){case"s":{let l=g!==void 0?String(g):"";if(u&&(l=l.substring(0,parseInt(u,10))),c){let p=parseInt(c,10);o.includes("-")?l=l.padEnd(p):l=l.padStart(p)}i+=l,N===void 0&&n++;break}case"d":case"i":{let l=g!==void 0?Math.floor(Number(g)):0;Number.isNaN(l)&&(l=0);let p=l<0,E=Math.abs(l).toString();if(u){let b=parseInt(u,10);E=E.padStart(b,"0")}let d="";p?d="-":o.includes("+")?d="+":o.includes(" ")&&(d=" ");let R=d+E;if(c){let b=parseInt(c,10);o.includes("-")?R=R.padEnd(b):o.includes("0")&&!u?R=d+E.padStart(b-d.length,"0"):R=R.padStart(b)}i+=R,N===void 0&&n++;break}case"f":{let l=g!==void 0?Number(g):0;Number.isNaN(l)&&(l=0);let p=u?parseInt(u,10):6,E=l.toFixed(p);if(c){let d=parseInt(c,10);o.includes("-")?E=E.padEnd(d):E=E.padStart(d)}i+=E,N===void 0&&n++;break}case"e":case"E":{let l=g!==void 0?Number(g):0;Number.isNaN(l)&&(l=0);let p=u?parseInt(u,10):6,E=l.toExponential(p);if(w==="E"&&(E=E.toUpperCase()),c){let d=parseInt(c,10);o.includes("-")?E=E.padEnd(d):E=E.padStart(d)}i+=E,N===void 0&&n++;break}case"g":case"G":{let l=g!==void 0?Number(g):0;Number.isNaN(l)&&(l=0);let p=u?parseInt(u,10):6,E=l!==0?Math.floor(Math.log10(Math.abs(l))):0,d;if(l===0?d="0":E<-4||E>=p?(d=l.toExponential(p-1),w==="G"&&(d=d.toUpperCase())):d=l.toPrecision(p),d.includes(".")&&(d=d.replace(/\.?0+$/,"").replace(/\.?0+e/,"e")),d.includes("e")&&(d=d.replace(/\.?0+e/,"e")),c){let R=parseInt(c,10);o.includes("-")?d=d.padEnd(R):d=d.padStart(R)}i+=d,N===void 0&&n++;break}case"x":case"X":{let l=g!==void 0?Math.floor(Number(g)):0;Number.isNaN(l)&&(l=0);let p=Math.abs(l).toString(16);if(w==="X"&&(p=p.toUpperCase()),u){let R=parseInt(u,10);p=p.padStart(R,"0")}let E=l<0?"-":"",d=E+p;if(c){let R=parseInt(c,10);o.includes("-")?d=d.padEnd(R):o.includes("0")&&!u?d=E+p.padStart(R-E.length,"0"):d=d.padStart(R)}i+=d,N===void 0&&n++;break}case"o":{let l=g!==void 0?Math.floor(Number(g)):0;Number.isNaN(l)&&(l=0);let p=Math.abs(l).toString(8);if(u){let R=parseInt(u,10);p=p.padStart(R,"0")}let E=l<0?"-":"",d=E+p;if(c){let R=parseInt(c,10);o.includes("-")?d=d.padEnd(R):o.includes("0")&&!u?d=E+p.padStart(R-E.length,"0"):d=d.padStart(R)}i+=d,N===void 0&&n++;break}case"c":{typeof g=="number"?i+=String.fromCharCode(g):i+=String(g??"").charAt(0)||"",N===void 0&&n++;break}case"%":i+="%";break;default:i+=e.substring(a,s+1)}a=s+1}else if(e[a]==="\\"&&a+1<e.length){let s=e[a+1];switch(s){case"n":i+=`
|
|
5
5
|
`;break;case"t":i+=" ";break;case"r":i+="\r";break;case"\\":i+="\\";break;default:i+=s}a+=2}else i+=e[a++];return i}var de=new Map([["length",Te],["substr",Fe],["index",_e],["split",Ge],["sub",De],["gsub",xe],["match",Ue],["gensub",Be],["tolower",He],["toupper",$e],["sprintf",We],["int",Ve],["sqrt",Ke],["sin",Xe],["cos",je],["atan2",ze],["log",Qe],["exp",qe],["rand",Je],["srand",Ze],["system",Ye("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",q("systime")],["mktime",q("mktime")],["strftime",q("strftime")]]);function v(e){return typeof e=="number"?e!==0:!(e===""||e==="0")}function m(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 J(e){if(typeof e=="number")return!0;let t=String(e).trim();return t===""?!1:!Number.isNaN(Number(t))}function G(e,t){try{return A(e).test(t)}catch{return!1}}function Ee(e,t){return t===""?[]:e.FS===" "?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function H(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function Z(e,t,n){if(t===0)e.line=S(n),e.fields=Ee(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 T(e,t){e.line=t,e.fields=Ee(e,t),e.NF=e.fields.length}function Ne(e,t){if(e.FS=t,t===" ")e.fieldSep=new P(/\s+/);else try{e.fieldSep=A(t)}catch{e.fieldSep=A(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}function $(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 F(e,t,n){switch(t){case"FS":Ne(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(m(n));return;case"NF":{let i=Math.floor(m(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(m(n));return;case"FILENAME":e.FILENAME=S(n);return;case"RSTART":e.RSTART=Math.floor(m(n));return;case"RLENGTH":e.RLENGTH=Math.floor(m(n));return;case"SUBSEP":e.SUBSEP=S(n);return}e.vars[t]=n}function D(e,t){let n=t,i=new Set,a=e.arrayAliases.get(n);for(;a!==void 0&&!i.has(n);)i.add(n),n=a,a=e.arrayAliases.get(n);return n}function W(e,t,n){if(t==="ARGV")return e.ARGV[n]??"";if(t==="ENVIRON")return e.ENVIRON[n]??"";let i=D(e,t);return e.arrays[i]?.[n]??""}function Y(e,t,n,i){let a=D(e,t);e.arrays[a]||(e.arrays[a]=Object.create(null)),e.arrays[a][n]=i}function Se(e,t,n){if(t==="ARGV")return e.ARGV[n]!==void 0;if(t==="ENVIRON")return e.ENVIRON[n]!==void 0;let i=D(e,t);return e.arrays[i]?.[n]!==void 0}function ye(e,t,n){let i=D(e,t);e.arrays[i]&&delete e.arrays[i][n]}function Re(e,t){let n=D(e,t);delete e.arrays[n]}var ee=null;function me(e){ee=e}async function f(e,t){switch(e.coverage?.hit(`awk:expr:${t.type}`),t.type){case"number":return t.value;case"string":return t.value;case"regex":return G(t.pattern,e.line)?1:0;case"field":return et(e,t);case"variable":return $(e,t.name);case"array_access":return tt(e,t);case"binary":return nt(e,t);case"unary":return st(e,t);case"ternary":return v(await f(e,t.condition))?await f(e,t.consequent):await f(e,t.alternate);case"call":return at(e,t.name,t.args);case"assignment":return lt(e,t);case"pre_increment":return ct(e,t.operand);case"pre_decrement":return ut(e,t.operand);case"post_increment":return ht(e,t.operand);case"post_decrement":return pt(e,t.operand);case"in":return ft(e,t.key,t.array);case"getline":return dt(e,t.variable,t.file,t.command);case"tuple":return St(e,t.elements);default:return""}}async function et(e,t){let n=Math.floor(m(await f(e,t.index)));return H(e,n)}async function tt(e,t){let n=S(await f(e,t.key));return W(e,t.array,n)}async function nt(e,t){let n=t.operator;if(n==="||")return v(await f(e,t.left))||v(await f(e,t.right))?1:0;if(n==="&&")return v(await f(e,t.left))&&v(await f(e,t.right))?1:0;if(n==="~"){let c=await 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 f(e,t.right));try{return A(u).test(S(c))?1:0}catch{return 0}}if(n==="!~"){let c=await 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 f(e,t.right));try{return A(u).test(S(c))?0:1}catch{return 1}}let i=await f(e,t.left),a=await f(e,t.right);if(n===" "){let c=S(i)+S(a);if(e.maxOutputSize>0&&c.length>e.maxOutputSize)throw new O(`awk: string concatenation size limit exceeded (${e.maxOutputSize} bytes)`,"string_length",e.output);return c}if(rt(n))return it(i,a,n);let s=m(i),o=m(a);return le(s,o,n)}function rt(e){return["<","<=",">",">=","==","!="].includes(e)}function it(e,t,n){let i=J(e),a=J(t);if(i&&a){let c=m(e),u=m(t);switch(n){case"<":return c<u?1:0;case"<=":return c<=u?1:0;case">":return c>u?1:0;case">=":return c>=u?1:0;case"==":return c===u?1:0;case"!=":return c!==u?1:0}}let s=S(e),o=S(t);switch(n){case"<":return s<o?1:0;case"<=":return s<=o?1:0;case">":return s>o?1:0;case">=":return s>=o?1:0;case"==":return s===o?1:0;case"!=":return s!==o?1:0}return 0}async function st(e,t){let n=await f(e,t.operand);switch(t.operator){case"!":return v(n)?0:1;case"-":return-m(n);case"+":return+m(n);default:return n}}async function at(e,t,n){let i=de.get(t);if(i)return i(n,e,{evalExpr:s=>f(e,s)});let a=e.functions.get(t);return a?ot(e,a,n):""}async function ot(e,t,n){if(e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new O(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let i=Object.create(null);for(let o of t.params)i[o]=e.vars[o];let a=[];for(let o=0;o<t.params.length;o++){let c=t.params[o];if(o<n.length){let u=n[o];u.type==="variable"&&(e.arrayAliases.set(c,u.name),a.push(c));let N=await f(e,u);e.vars[c]=N}else e.vars[c]=""}e.hasReturn=!1,e.returnValue=void 0,ee&&await ee(e,t.body.statements);let s=e.returnValue??"";for(let o of t.params)i[o]!==void 0?e.vars[o]=i[o]:delete e.vars[o];for(let o of a)e.arrayAliases.delete(o);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,s}async function lt(e,t){let n=await f(e,t.value),i=t.target,a=t.operator,s;if(a==="=")s=n;else{let o;if(i.type==="field"){let N=Math.floor(m(await f(e,i.index)));o=H(e,N)}else if(i.type==="variable")o=$(e,i.name);else{let N=S(await f(e,i.key));o=W(e,i.array,N)}let c=m(o),u=m(n);switch(a){case"+=":s=c+u;break;case"-=":s=c-u;break;case"*=":s=c*u;break;case"/=":s=u!==0?c/u:0;break;case"%=":s=u!==0?c%u:0;break;case"^=":s=c**u;break;default:s=n}}if(i.type==="field"){let o=Math.floor(m(await f(e,i.index)));Z(e,o,s)}else if(i.type==="variable")F(e,i.name,s);else{let o=S(await f(e,i.key));Y(e,i.array,o,s)}return s}async function V(e,t,n,i){let a;if(t.type==="field"){let s=Math.floor(m(await f(e,t.index)));a=m(H(e,s)),Z(e,s,a+n)}else if(t.type==="variable")a=m($(e,t.name)),F(e,t.name,a+n);else{let s=S(await f(e,t.key));a=m(W(e,t.array,s)),Y(e,t.array,s,a+n)}return i?a+n:a}async function ct(e,t){return V(e,t,1,!0)}async function ut(e,t){return V(e,t,-1,!0)}async function ht(e,t){return V(e,t,1,!1)}async function pt(e,t){return V(e,t,-1,!1)}async function ft(e,t,n){let i;if(t.type==="tuple"){e.coverage?.hit("awk:expr:tuple");let a=[];for(let s of t.elements)a.push(S(await f(e,s)));i=a.join(e.SUBSEP)}else i=S(await f(e,t));return Se(e,n,i)?1:0}async function dt(e,t,n,i){if(i)return Et(e,t,i);if(n)return Nt(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let a=e.lineIndex+1;if(a>=e.lines.length)return 0;let s=e.lines[a];return t?F(e,t,s):T(e,s),e.NR++,e.lineIndex=a,1}async function Et(e,t,n){if(!e.exec)return-1;let i=S(await f(e,n)),a=`__cmd_${i}`,s=`__cmdi_${i}`,o,c;if(e.vars[a]===void 0)try{o=(await e.exec(i)).stdout.split(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as F,b,c as M,d as qe,e as w,f as v,g as X,h as Y}from"./chunk-GZHFXDDO.js";import{a as et}from"./chunk-QSDVMMYI.js";import{a as $}from"./chunk-
|
|
2
|
+
import{a as F,b,c as M,d as qe,e as w,f as v,g as X,h as Y}from"./chunk-GZHFXDDO.js";import{a as et}from"./chunk-QSDVMMYI.js";import{a as $}from"./chunk-EPIOK4SY.js";import{d as G}from"./chunk-UYBH3FNE.js";import{a as H}from"./chunk-SE4C7FJY.js";import{a as We}from"./chunk-5WFYIUU2.js";import{a as D,b as K}from"./chunk-GTNBSMZR.js";import{b as Ue,d as Be,e as Ze,f as Qe}from"./chunk-KGOUQS5A.js";var q,_e=Ue(()=>{"use strict";q=class{input;pos=0;tokens=[];constructor(n){this.input=n}tokenize(){for(;this.pos<this.input.length&&(this.skipWhitespace(),!(this.pos>=this.input.length));){let n=this.nextToken();n&&this.tokens.push(n)}return this.tokens.push({type:"eof",value:"",pos:this.pos}),this.tokens}skipWhitespace(){for(;this.pos<this.input.length;){let n=this.input[this.pos];if(n===" "||n===" "||n===`
|
|
3
3
|
`||n==="\r")this.pos++;else if(n==="#")for(;this.pos<this.input.length&&this.input[this.pos]!==`
|
|
4
4
|
`;)this.pos++;else break}}nextToken(){let n=this.pos,t=this.input[this.pos];if(t>="0"&&t<="9")return this.readNumber();if(t==='"'||t==="'"||t==="`")return this.readString(t);if(t==="b"&&this.pos+1<this.input.length){let o=this.input[this.pos+1];if(o==='"'||o==="'"||o==="`")return this.pos++,this.readString(o)}if(t==="/"){let o=this.tokens[this.tokens.length-1];return o&&(o.type==="int"||o.type==="float"||o.type==="string"||o.type==="ident"||o.type===")"||o.type==="]")?this.input[this.pos+1]==="/"?(this.pos+=2,{type:"//",value:"//",pos:n}):(this.pos++,{type:"/",value:"/",pos:n}):this.readRegex()}if(this.match("not in"))return{type:"not in",value:"not in",pos:n};if(this.match("=>"))return{type:"=>",value:"=>",pos:n};if(this.match("**"))return{type:"**",value:"**",pos:n};if(this.match("++"))return{type:"++",value:"++",pos:n};if(this.match("//"))return{type:"//",value:"//",pos:n};if(this.match("=="))return{type:"==",value:"==",pos:n};if(this.match("!="))return{type:"!=",value:"!=",pos:n};if(this.match("<="))return{type:"<=",value:"<=",pos:n};if(this.match(">="))return{type:">=",value:">=",pos:n};if(this.match("&&"))return{type:"&&",value:"&&",pos:n};if(this.match("||"))return{type:"||",value:"||",pos:n};let r=new Map([["(","("],[")",")"],["[","["],["]","]"],["{","{"],["}","}"],[",",","],[":",":"],[";",";"],["+","+"],["-","-"],["*","*"],["%","%"],["<","<"],[">",">"],["!","!"],[".","."],["|","|"],["=","="]]).get(t);if(r!==void 0)return this.pos++,{type:r,value:t,pos:n};if(this.isIdentStart(t))return this.readIdentifier();throw new Error(`Unexpected character '${t}' at position ${this.pos}`)}match(n){if(this.input.slice(this.pos,this.pos+n.length)===n){if(/^[a-zA-Z]/.test(n)){let t=this.input[this.pos+n.length];if(t&&this.isIdentChar(t))return!1}return this.pos+=n.length,!0}return!1}isIdentStart(n){return n>="a"&&n<="z"||n>="A"&&n<="Z"||n==="_"}isIdentChar(n){return this.isIdentStart(n)||n>="0"&&n<="9"}readNumber(){let n=this.pos,t=!1,s=!1;for(;this.pos<this.input.length;){let o=this.input[this.pos];if(o>="0"&&o<="9")this.pos++;else if(o==="_")this.pos++;else if(o==="."&&!t&&!s)t=!0,this.pos++;else if((o==="e"||o==="E")&&!s)s=!0,t=!0,this.pos++,this.pos<this.input.length&&(this.input[this.pos]==="+"||this.input[this.pos]==="-")&&this.pos++;else break}let r=this.input.slice(n,this.pos).replace(/_/g,"");return{type:t?"float":"int",value:r,pos:n}}readString(n){let t=this.pos;this.pos++;let s="";for(;this.pos<this.input.length;){let r=this.input[this.pos];if(r===n)return this.pos++,{type:"string",value:s,pos:t};if(r==="\\"){if(this.pos++,this.pos<this.input.length){let o=this.input[this.pos];switch(o){case"n":s+=`
|
|
5
5
|
`;break;case"r":s+="\r";break;case"t":s+=" ";break;case"\\":s+="\\";break;case'"':s+='"';break;case"'":s+="'";break;case"`":s+="`";break;case"0":s+="\0";break;default:s+=o}this.pos++}}else s+=r,this.pos++}throw new Error(`Unterminated string starting at position ${t}`)}readRegex(){let n=this.pos;this.pos++;let t="",s="";for(;this.pos<this.input.length;){let r=this.input[this.pos];if(r==="/"){for(this.pos++;this.pos<this.input.length&&this.input[this.pos]==="i";)s+=this.input[this.pos],this.pos++;return{type:"regex",value:t+(s?`/${s}`:""),pos:n}}r==="\\"?(t+=r,this.pos++,this.pos<this.input.length&&(t+=this.input[this.pos],this.pos++)):(t+=r,this.pos++)}throw new Error(`Unterminated regex starting at position ${n}`)}readIdentifier(){let n=this.pos;for(;this.pos<this.input.length&&this.isIdentChar(this.input[this.pos]);)this.pos++;let t=!1;this.pos<this.input.length&&this.input[this.pos]==="?"&&(t=!0,this.pos++);let s=this.input.slice(n,t?this.pos-1:this.pos);t&&(s+="?");let r=new Map([["true","true"],["false","false"],["null","null"],["and","and"],["or","or"],["eq","eq"],["ne","ne"],["lt","lt"],["le","le"],["gt","gt"],["ge","ge"],["in","in"],["as","as"],["_","_"]]),o=s.replace(/\?$/,""),i=r.get(o);return i!==void 0&&!t?{type:i,value:o,pos:n}:{type:"ident",value:s,pos:n}}}});var He={};Be(He,{parseMoonblade:()=>_,parseNamedExpressions:()=>V});function V(e){let n=[],s=new q(e).tokenize(),r=0,o=()=>s[r]||{type:"eof",value:"",pos:0},i=()=>s[r++];for(;o().type!=="eof";){if(o().type===","&&n.length>0){i();continue}let h=[],u=0,p=r;for(;o().type!=="eof";){let a=o();if((a.type===","||a.type==="as")&&u===0)break;(a.type==="("||a.type==="["||a.type==="{")&&u++,(a.type===")"||a.type==="]"||a.type==="}")&&u--,h.push(i())}h.push({type:"eof",value:"",pos:0});let f=new J(h).parse(),c;if(o().type==="as")if(i(),o().type==="("){i();let a=[];for(;o().type!==")"&&o().type!=="eof";)(o().type==="ident"||o().type==="string")&&(a.push(o().value),i()),o().type===","&&i();o().type===")"&&i(),c=a}else if(o().type==="ident"||o().type==="string")c=o().value,i();else throw new Error(`Expected name after 'as', got ${o().type}`);else c=e.slice(s[p].pos,s[r-1]?.pos||e.length).trim(),f.type==="identifier"&&(c=f.name);n.push({expr:f,name:c})}return n}function _(e){let t=new q(e).tokenize();return new J(t).parse()}var R,J,U=Ue(()=>{"use strict";_e();R={PIPE:1,OR:2,AND:3,EQUALITY:4,COMPARISON:5,ADDITIVE:6,MULTIPLICATIVE:7,POWER:8,UNARY:9,POSTFIX:10},J=class{pos=0;tokens;constructor(n){this.tokens=n}parse(){let n=this.parseExpr(0);if(this.peek().type!=="eof")throw new Error(`Unexpected token: ${this.peek().value}`);return n}parseExpr(n){let t=this.parsePrefix();for(;;){let s=this.peek(),r=this.getInfixPrec(s.type);if(r<n)break;t=this.parseInfix(t,r)}return t}parsePrefix(){let n=this.peek();switch(n.type){case"int":return this.advance(),{type:"int",value:Number.parseInt(n.value,10)};case"float":return this.advance(),{type:"float",value:Number.parseFloat(n.value)};case"string":return this.advance(),{type:"string",value:n.value};case"regex":{this.advance();let t=n.value.split("/"),s=t.length>1?t[t.length-1]:"";return{type:"regex",pattern:t.slice(0,-1).join("/")||n.value,caseInsensitive:s.includes("i")}}case"true":return this.advance(),{type:"bool",value:!0};case"false":return this.advance(),{type:"bool",value:!1};case"null":return this.advance(),{type:"null"};case"_":return this.advance(),{type:"underscore"};case"ident":{let t=n.value,s=t.endsWith("?"),r=s?t.slice(0,-1):t;if(this.advance(),this.peek().type==="(")return this.parseFunctionCall(r);if(this.peek().type==="=>"){this.advance();let o=this.parseExpr(0);return this.bindLambdaArgs({type:"lambda",params:[r],body:o},[r])}return{type:"identifier",name:r,unsure:s}}case"(":{this.advance();let t=[];if(this.peek().type===")"){if(this.advance(),this.peek().type==="=>"){this.advance();let r=this.parseExpr(0);return{type:"lambda",params:[],body:r}}throw new Error("Empty parentheses not allowed")}if(this.peek().type==="ident"){let r=this.peek().value;if(this.advance(),this.peek().type===","||this.peek().type===")"){for(t.push(r);this.peek().type===","&&(this.advance(),this.peek().type==="ident");)t.push(this.peek().value),this.advance();if(this.peek().type===")"&&(this.advance(),this.peek().type==="=>")){this.advance();let o=this.parseExpr(0);return this.bindLambdaArgs({type:"lambda",params:t,body:o},t)}this.pos-=t.length*2,t.length>1&&(this.pos=this.pos)}this.pos--}let s=this.parseExpr(0);return this.expect(")"),this.peek().type,s}case"[":return this.parseList();case"{":return this.parseMap();case"-":{this.advance();let t=this.parseExpr(R.UNARY);return t.type==="int"?{type:"int",value:-t.value}:t.type==="float"?{type:"float",value:-t.value}:{type:"func",name:"neg",args:[{expr:t}]}}case"!":return this.advance(),{type:"func",name:"not",args:[{expr:this.parseExpr(R.UNARY)}]};default:throw new Error(`Unexpected token: ${n.type} (${n.value})`)}}parseFunctionCall(n){this.expect("(");let t=[];if(this.peek().type!==")")do{t.length>0&&this.peek().type===","&&this.advance();let s;if(this.peek().type==="ident"){let o=this.peek().value,i=this.pos+1;i<this.tokens.length&&this.tokens[i].type==="="&&(s=o,this.advance(),this.advance())}let r=this.parseExpr(0);t.push({name:s,expr:r})}while(this.peek().type===",");return this.expect(")"),{type:"func",name:n.toLowerCase(),args:t}}parseList(){this.expect("[");let n=[];if(this.peek().type!=="]")do n.length>0&&this.peek().type===","&&this.advance(),n.push(this.parseExpr(0));while(this.peek().type===",");return this.expect("]"),{type:"list",elements:n}}parseMap(){this.expect("{");let n=[];if(this.peek().type!=="}")do{n.length>0&&this.peek().type===","&&this.advance();let t;if(this.peek().type==="ident")t=this.peek().value,this.advance();else if(this.peek().type==="string")t=this.peek().value,this.advance();else throw new Error(`Expected map key, got ${this.peek().type}`);this.expect(":");let s=this.parseExpr(0);n.push({key:t,value:s})}while(this.peek().type===",");return this.expect("}"),{type:"map",entries:n}}parseInfix(n,t){let s=this.peek(),o=new Map([["+","add"],["-","sub"],["*","mul"],["/","div"],["//","idiv"],["%","mod"],["**","pow"],["++","concat"],["==","=="],["!=","!="],["<","<"],["<=","<="],[">",">"],[">=",">="],["eq","eq"],["ne","ne"],["lt","lt"],["le","le"],["gt","gt"],["ge","ge"],["&&","and"],["and","and"],["||","or"],["or","or"]]).get(s.type);if(o!==void 0){this.advance();let i=this.parseExpr(t+(this.isRightAssoc(s.type)?0:1));return{type:"func",name:o,args:[{expr:n},{expr:i}]}}if(s.type==="|"){this.advance();let i=this.parseExpr(t);return this.handlePipe(n,i)}if(s.type===".")return this.advance(),this.handleDot(n);if(s.type==="[")return this.advance(),this.handleIndexing(n);if(s.type==="in")return this.advance(),{type:"func",name:"contains",args:[{expr:this.parseExpr(t+1)},{expr:n}]};if(s.type==="not in")return this.advance(),{type:"func",name:"not",args:[{expr:{type:"func",name:"contains",args:[{expr:this.parseExpr(t+1)},{expr:n}]}}]};throw new Error(`Unexpected infix token: ${s.type}`)}handlePipe(n,t){if(t.type==="identifier")return{type:"func",name:t.name,args:[{expr:n}]};if(t.type==="func"){let s=this.countUnderscores(t);return s===0?t:s===1?this.fillUnderscore(t,n):{type:"pipeline",exprs:[n,t]}}return this.countUnderscores(t)===1?this.fillUnderscore(t,n):t}handleDot(n){let t=this.peek();if(t.type==="ident"){let s=t.value;if(this.advance(),this.peek().type==="("){let r=this.parseFunctionCall(s);return r.type==="func"&&r.args.unshift({expr:n}),r}return{type:"func",name:"get",args:[{expr:n},{expr:{type:"string",value:s}}]}}if(t.type==="int"){let s=Number.parseInt(t.value,10);return this.advance(),{type:"func",name:"get",args:[{expr:n},{expr:{type:"int",value:s}}]}}if(t.type==="string"){let s=t.value;return this.advance(),{type:"func",name:"get",args:[{expr:n},{expr:{type:"string",value:s}}]}}throw new Error(`Expected identifier, number, or string after dot, got ${t.type}`)}handleIndexing(n){if(this.peek().type===":"){if(this.advance(),this.peek().type==="]")return this.advance(),{type:"func",name:"slice",args:[{expr:n}]};let s=this.parseExpr(0);return this.expect("]"),{type:"func",name:"slice",args:[{expr:n},{expr:{type:"int",value:0}},{expr:s}]}}let t=this.parseExpr(0);if(this.peek().type===":"){if(this.advance(),this.peek().type==="]")return this.advance(),{type:"func",name:"slice",args:[{expr:n},{expr:t}]};let s=this.parseExpr(0);return this.expect("]"),{type:"func",name:"slice",args:[{expr:n},{expr:t},{expr:s}]}}return this.expect("]"),{type:"func",name:"get",args:[{expr:n},{expr:t}]}}countUnderscores(n){return n.type==="underscore"?1:n.type==="func"?n.args.reduce((t,s)=>t+this.countUnderscores(s.expr),0):n.type==="list"?n.elements.reduce((t,s)=>t+this.countUnderscores(s),0):n.type==="map"?n.entries.reduce((t,s)=>t+this.countUnderscores(s.value),0):0}fillUnderscore(n,t){return n.type==="underscore"?t:n.type==="func"?{...n,args:n.args.map(s=>({...s,expr:this.fillUnderscore(s.expr,t)}))}:n.type==="list"?{...n,elements:n.elements.map(s=>this.fillUnderscore(s,t))}:n.type==="map"?{...n,entries:n.entries.map(s=>({...s,value:this.fillUnderscore(s.value,t)}))}:n}bindLambdaArgs(n,t){return{...n,body:this.bindLambdaArgsInExpr(n.body,t)}}bindLambdaArgsInExpr(n,t){return n.type==="identifier"&&t.includes(n.name)?{type:"lambdaBinding",name:n.name}:n.type==="func"?{...n,args:n.args.map(s=>({...s,expr:this.bindLambdaArgsInExpr(s.expr,t)}))}:n.type==="list"?{...n,elements:n.elements.map(s=>this.bindLambdaArgsInExpr(s,t))}:n.type==="map"?{...n,entries:n.entries.map(s=>({...s,value:this.bindLambdaArgsInExpr(s.value,t)}))}:n}getInfixPrec(n){switch(n){case"|":return R.PIPE;case"||":case"or":return R.OR;case"&&":case"and":return R.AND;case"==":case"!=":case"eq":case"ne":return R.EQUALITY;case"<":case"<=":case">":case">=":case"lt":case"le":case"gt":case"ge":case"in":case"not in":return R.COMPARISON;case"+":case"-":case"++":return R.ADDITIVE;case"*":case"/":case"//":case"%":return R.MULTIPLICATIVE;case"**":return R.POWER;case".":case"[":return R.POSTFIX;default:return-1}}isRightAssoc(n){return n==="**"}peek(){return this.tokens[this.pos]||{type:"eof",value:"",pos:0}}advance(){return this.tokens[this.pos++]}expect(n){let t=this.peek();if(t.type!==n)throw new Error(`Expected ${n}, got ${t.type}`);return this.advance()}}});U();function E(e,n){return n.length===0?k(e,[]):n.length===1?{type:"Pipe",left:n[0],right:k(e,[])}:{type:"Pipe",left:n[0],right:k(e,n.slice(1))}}var B={add:e=>S("+",e[0],e[1]),sub:e=>S("-",e[0],e[1]),mul:e=>S("*",e[0],e[1]),div:e=>S("/",e[0],e[1]),mod:e=>S("%",e[0],e[1]),idiv:e=>k("floor",[S("/",e[0],e[1])]),pow:e=>E("pow",e),neg:e=>({type:"UnaryOp",op:"-",operand:e[0]}),"==":e=>S("==",e[0],e[1]),"!=":e=>S("!=",e[0],e[1]),"<":e=>S("<",e[0],e[1]),"<=":e=>S("<=",e[0],e[1]),">":e=>S(">",e[0],e[1]),">=":e=>S(">=",e[0],e[1]),eq:e=>S("==",P(e[0]),P(e[1])),ne:e=>S("!=",P(e[0]),P(e[1])),lt:e=>S("<",P(e[0]),P(e[1])),le:e=>S("<=",P(e[0]),P(e[1])),gt:e=>S(">",P(e[0]),P(e[1])),ge:e=>S(">=",P(e[0]),P(e[1])),and:e=>S("and",e[0],e[1]),or:e=>S("or",e[0],e[1]),not:e=>({type:"UnaryOp",op:"not",operand:e[0]}),len:e=>E("length",e),length:e=>E("length",e),upper:e=>E("ascii_upcase",e),lower:e=>E("ascii_downcase",e),trim:e=>E("trim",e),ltrim:e=>e.length===0?k("ltrimstr",[{type:"Literal",value:" "}]):{type:"Pipe",left:e[0],right:k("ltrimstr",[{type:"Literal",value:" "}])},rtrim:e=>e.length===0?k("rtrimstr",[{type:"Literal",value:" "}]):{type:"Pipe",left:e[0],right:k("rtrimstr",[{type:"Literal",value:" "}])},split:e=>E("split",e),join:e=>e.length===1?k("join",[{type:"Literal",value:""}]):E("join",e),concat:e=>S("+",e[0],e[1]),startswith:e=>E("startswith",e),endswith:e=>E("endswith",e),contains:e=>E("contains",e),replace:e=>E("gsub",e),substr:e=>e.length===2?{type:"Slice",base:e[0],start:e[1]}:{type:"Slice",base:e[0],start:e[1],end:S("+",e[1],e[2])},abs:e=>E("fabs",e),floor:e=>E("floor",e),ceil:e=>E("ceil",e),round:e=>E("round",e),sqrt:e=>E("sqrt",e),log:e=>E("log",e),log10:e=>E("log10",e),log2:e=>E("log2",e),exp:e=>E("exp",e),sin:e=>E("sin",e),cos:e=>E("cos",e),tan:e=>E("tan",e),asin:e=>E("asin",e),acos:e=>E("acos",e),atan:e=>E("atan",e),min:e=>E("min",e),max:e=>E("max",e),first:e=>e.length===0?{type:"Index",index:{type:"Literal",value:0}}:{type:"Index",index:{type:"Literal",value:0},base:e[0]},last:e=>e.length===0?{type:"Index",index:{type:"Literal",value:-1}}:{type:"Index",index:{type:"Literal",value:-1},base:e[0]},get:e=>e.length===1?{type:"Index",index:e[0]}:{type:"Index",index:e[1],base:e[0]},slice:e=>e.length===1?{type:"Slice",base:e[0]}:e.length===2?{type:"Slice",base:e[0],start:e[1]}:{type:"Slice",base:e[0],start:e[1],end:e[2]},keys:"keys",values:"values",entries:e=>k("to_entries",e),from_entries:"from_entries",reverse:"reverse",sort:"sort",sort_by:"sort_by",group_by:"group_by",unique:"unique",unique_by:"unique_by",flatten:"flatten",map:e=>({type:"Pipe",left:e[0],right:{type:"Array",elements:e[1]}}),select:e=>k("select",e),empty:()=>k("empty",[]),count:()=>k("length",[]),sum:e=>e.length===0?k("add",[]):{type:"Pipe",left:{type:"Array",elements:e[0]},right:k("add",[])},mean:e=>e.length===0?{type:"Pipe",left:{type:"Identity"},right:S("/",k("add",[]),k("length",[]))}:{type:"Pipe",left:{type:"Array",elements:e[0]},right:S("/",k("add",[]),k("length",[]))},avg:e=>e.length===0?{type:"Pipe",left:{type:"Identity"},right:S("/",k("add",[]),k("length",[]))}:{type:"Pipe",left:{type:"Array",elements:e[0]},right:S("/",k("add",[]),k("length",[]))},type:"type",isnull:e=>e.length===0?S("==",{type:"Identity"},{type:"Literal",value:null}):S("==",e[0],{type:"Literal",value:null}),isempty:e=>e.length===0?S("==",{type:"Identity"},{type:"Literal",value:""}):S("==",e[0],{type:"Literal",value:""}),tonumber:e=>e.length===0?k("tonumber",[]):k("tonumber",e),tostring:e=>e.length===0?k("tostring",[]):k("tostring",e),if:e=>Je(e[0],e[1],e[2]),coalesce:e=>{if(e.length===0)return{type:"Literal",value:null};if(e.length===1)return e[0];let[n,...t]=e,s=S("and",S("!=",n,{type:"Literal",value:null}),S("!=",n,{type:"Literal",value:""}));return Je(s,n,t.length===1?t[0]:B.coalesce(t))},index:()=>({type:"Field",name:"_row_index"}),now:()=>k("now",[]),fmt:e=>k("tostring",e),format:e=>k("tostring",e)};function S(e,n,t){return{type:"BinaryOp",op:e,left:n,right:t}}function k(e,n){return{type:"Call",name:e,args:n}}var tt="then";function Je(e,n,t){let s={type:"Cond",cond:e,elifs:[],else:t||{type:"Literal",value:null}};return s[tt]=n,s}function P(e){return{type:"Pipe",left:e,right:{type:"Call",name:"tostring",args:[]}}}function O(e,n=!0){switch(e.type){case"int":case"float":return{type:"Literal",value:e.value};case"string":return{type:"Literal",value:e.value};case"bool":return{type:"Literal",value:e.value};case"null":return{type:"Literal",value:null};case"underscore":return{type:"Index",base:{type:"Identity"},index:{type:"Literal",value:"_"}};case"identifier":return n?{type:"Field",name:e.name}:{type:"VarRef",name:e.name};case"lambdaBinding":return{type:"VarRef",name:e.name};case"func":{let t=e.args.map(r=>O(r.expr,n)),s=Object.hasOwn(B,e.name)?B[e.name]:void 0;return typeof s=="function"?s(t):k(typeof s=="string"?s:e.name,t)}case"list":return e.elements.length===0?{type:"Array"}:{type:"Array",elements:e.elements.reduce((t,s,r)=>{let o=O(s,n);return r===0?o:{type:"Comma",left:t,right:o}},null)};case"map":return{type:"Object",entries:e.entries.map(t=>({key:t.key,value:O(t.value,n)}))};case"regex":return{type:"Literal",value:e.pattern};case"slice":return{type:"Slice",start:e.start?O(e.start,n):void 0,end:e.end?O(e.end,n):void 0};case"lambda":return O(e.body,n);case"pipeline":return{type:"Identity"};default:throw new Error(`Unknown moonblade expression type: ${e.type}`)}}function Q(e){let n=[],t=0;for(;t<e.length;){for(;t<e.length&&(e[t]===" "||e[t]===",");)t++;if(t>=e.length)break;let s=t;for(;t<e.length&&/\w/.test(e[t]);)t++;let r=e.slice(s,t);for(;t<e.length&&e[t]===" ";)t++;if(e[t]!=="(")break;t++;let o=1,i=t;for(;t<e.length&&o>0;)e[t]==="("?o++:e[t]===")"&&o--,o>0&&t++;let h=e.slice(i,t).trim();for(t++;t<e.length&&e[t]===" ";)t++;let u="";if(e.slice(t,t+3).toLowerCase()==="as "){for(t+=3;t<e.length&&e[t]===" ";)t++;let p=t;for(;t<e.length&&/\w/.test(e[t]);)t++;u=e.slice(p,t)}u||(u=h?`${r}(${h})`:`${r}()`),n.push({func:r,expr:h,alias:u})}return n}function ze(e){return/^\w+$/.test(e)}function Z(e,n,t){let s=O(_(n)),r=$(e,s,t);return r.length>0?r[0]:null}function ee(e,n,t={}){let{func:s,expr:r}=n;if(s==="count"&&!r)return e.length;let o;switch(ze(r)?o=e.map(i=>i[r]).filter(i=>i!=null):o=e.map(i=>Z(i,r,t)).filter(i=>i!=null),s){case"count":return ze(r)?o.length:o.filter(i=>!!i).length;case"sum":return o.map(h=>typeof h=="number"?h:Number.parseFloat(String(h))).reduce((h,u)=>h+u,0);case"mean":case"avg":{let i=o.map(h=>typeof h=="number"?h:Number.parseFloat(String(h)));return i.length>0?i.reduce((h,u)=>h+u,0)/i.length:0}case"min":{let i=o.map(h=>typeof h=="number"?h:Number.parseFloat(String(h)));return i.length>0?Math.min(...i):null}case"max":{let i=o.map(h=>typeof h=="number"?h:Number.parseFloat(String(h)));return i.length>0?Math.max(...i):null}case"first":return o.length>0?o[0]:null;case"last":return o.length>0?o[o.length-1]:null;case"median":{let i=o.map(u=>typeof u=="number"?u:Number.parseFloat(String(u))).filter(u=>!Number.isNaN(u)).sort((u,p)=>u-p);if(i.length===0)return null;let h=Math.floor(i.length/2);return i.length%2===0?(i[h-1]+i[h])/2:i[h]}case"mode":{let i=new Map;for(let p of o){let l=String(p);i.set(l,(i.get(l)||0)+1)}let h=0,u=null;for(let[p,l]of i)l>h&&(h=l,u=p);return u}case"cardinality":return new Set(o.map(h=>String(h))).size;case"values":return o.map(i=>String(i)).join("|");case"distinct_values":return[...new Set(o.map(h=>String(h)))].sort().join("|");case"all":{if(e.length===0)return!0;for(let i of e)if(!Z(i,r,t))return!1;return!0}case"any":{for(let i of e)if(Z(i,r,t))return!0;return!1}default:return null}}function Ke(e,n,t={}){let s=F();for(let r of n)b(s,r.alias,ee(e,r,t));return s}async function te(e,n){let t="",s=[];for(let l of e)l.startsWith("-")||(t?s.push(l):t=l);if(!t)return{stdout:"",stderr:`xan agg: no aggregation expression
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as O}from"./chunk-SE4C7FJY.js";import{e as j,f as K,g as C,h as re,i as ke,j as Rt,k as W}from"./chunk-
|
|
2
|
+
import{a as O}from"./chunk-SE4C7FJY.js";import{e as j,f as K,g as C,h as re,i as ke,j as Rt,k as W}from"./chunk-6KZRLMG3.js";function $(e,t){for(;t<e.length;){if(e[t]==="\\"&&e[t+1]===`
|
|
3
3
|
`){t+=2;continue}if(/\s/.test(e[t])){t++;continue}break}return t}var Pe=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];function ge(e){if(e.includes("#")){let[r,s]=e.split("#"),n=Number.parseInt(r,10);if(n<2||n>64)return Number.NaN;if(n<=36){let i=Number.parseInt(s,n);return i>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:i}let a=0;for(let i of s){let l;if(/[0-9]/.test(i))l=i.charCodeAt(0)-48;else if(/[a-z]/.test(i))l=i.charCodeAt(0)-97+10;else if(/[A-Z]/.test(i))l=i.charCodeAt(0)-65+36;else if(i==="@")l=62;else if(i==="_")l=63;else return Number.NaN;if(l>=n)return Number.NaN;if(a=a*n+l,a>Number.MAX_SAFE_INTEGER)return Number.MAX_SAFE_INTEGER}return a}if(e.startsWith("0x")||e.startsWith("0X")){let r=Number.parseInt(e.slice(2),16);return r>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:r}if(e.startsWith("0")&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return Number.NaN;let r=Number.parseInt(e,8);return r>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:r}let t=Number.parseInt(e,10);return t>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:t}function It(e,t,r,s){if(r.slice(s,s+3)!=="$((")return null;let n=s+3,a=1,i=n;for(;n<r.length-1&&a>0;)r[n]==="("&&r[n+1]==="("?(a++,n+=2):r[n]===")"&&r[n+1]===")"?(a--,a>0&&(n+=2)):n++;let l=r.slice(i,n),{expr:o}=e(t,l,0);return n+=2,{expr:{type:"ArithNested",expression:o},pos:n}}function vt(e,t){if(e.slice(t,t+2)!=="$'")return null;let r=t+2,s="";for(;r<e.length&&e[r]!=="'";)if(e[r]==="\\"&&r+1<e.length){let a=e[r+1];switch(a){case"n":s+=`
|
|
4
4
|
`;break;case"t":s+=" ";break;case"r":s+="\r";break;case"\\":s+="\\";break;case"'":s+="'";break;default:s+=a}r+=2}else s+=e[r],r++;e[r]==="'"&&r++;let n=Number.parseInt(s,10);return{expr:{type:"ArithNumber",value:Number.isNaN(n)?0:n},pos:r}}function Dt(e,t){if(e.slice(t,t+2)!=='$"')return null;let r=t+2,s="";for(;r<e.length&&e[r]!=='"';)e[r]==="\\"&&r+1<e.length?(s+=e[r+1],r+=2):(s+=e[r],r++);e[r]==='"'&&r++;let n=Number.parseInt(s,10);return{expr:{type:"ArithNumber",value:Number.isNaN(n)?0:n},pos:r}}function wr(e){let t="",r=0;for(;r<e.length;)if(e[r]==='"'){for(r++;r<e.length&&e[r]!=='"';)e[r]==="\\"&&r+1<e.length?(t+=e[r+1],r+=2):(t+=e[r],r++);r<e.length&&r++}else t+=e[r],r++;return t}function M(e,t){let r=wr(t),{expr:s,pos:n}=Z(e,r,0),a=$(r,n);if(a<r.length){let i=t.slice(a).trim();if(i)return{type:"ArithmeticExpression",originalText:t,expression:{type:"ArithSyntaxError",errorToken:i,message:`${i}: syntax error: invalid arithmetic operator (error token is "${i}")`}}}return{type:"ArithmeticExpression",expression:s,originalText:t}}function F(e,t){return{expr:{type:"ArithSyntaxError",errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function z(e,t){return $(e,t)>=e.length}function Z(e,t,r){return Nr(e,t,r)}function Nr(e,t,r){let{expr:s,pos:n}=ye(e,t,r);for(n=$(t,n);t[n]===",";){if(n++,z(t,n))return F(",",n);let{expr:i,pos:l}=ye(e,t,n);s={type:"ArithBinary",operator:",",left:s,right:i},n=$(t,l)}return{expr:s,pos:n}}function ye(e,t,r){let{expr:s,pos:n}=kr(e,t,r);if(n=$(t,n),t[n]==="?"){n++;let{expr:a,pos:i}=Z(e,t,n);if(n=$(t,i),t[n]===":"){n++;let{expr:l,pos:o}=Z(e,t,n);return{expr:{type:"ArithTernary",condition:s,consequent:a,alternate:l},pos:o}}}return{expr:s,pos:n}}function kr(e,t,r){let{expr:s,pos:n}=xt(e,t,r);for(;n=$(t,n),t.slice(n,n+2)==="||";){if(n+=2,z(t,n))return F("||",n);let{expr:i,pos:l}=xt(e,t,n);s={type:"ArithBinary",operator:"||",left:s,right:i},n=l}return{expr:s,pos:n}}function xt(e,t,r){let{expr:s,pos:n}=_t(e,t,r);for(;n=$(t,n),t.slice(n,n+2)==="&&";){if(n+=2,z(t,n))return F("&&",n);let{expr:i,pos:l}=_t(e,t,n);s={type:"ArithBinary",operator:"&&",left:s,right:i},n=l}return{expr:s,pos:n}}function _t(e,t,r){let{expr:s,pos:n}=$t(e,t,r);for(;n=$(t,n),t[n]==="|"&&t[n+1]!=="|";){if(n++,z(t,n))return F("|",n);let{expr:i,pos:l}=$t(e,t,n);s={type:"ArithBinary",operator:"|",left:s,right:i},n=l}return{expr:s,pos:n}}function $t(e,t,r){let{expr:s,pos:n}=Ct(e,t,r);for(;n=$(t,n),t[n]==="^";){if(n++,z(t,n))return F("^",n);let{expr:i,pos:l}=Ct(e,t,n);s={type:"ArithBinary",operator:"^",left:s,right:i},n=l}return{expr:s,pos:n}}function Ct(e,t,r){let{expr:s,pos:n}=Ot(e,t,r);for(;n=$(t,n),t[n]==="&"&&t[n+1]!=="&";){if(n++,z(t,n))return F("&",n);let{expr:i,pos:l}=Ot(e,t,n);s={type:"ArithBinary",operator:"&",left:s,right:i},n=l}return{expr:s,pos:n}}function Ot(e,t,r){let{expr:s,pos:n}=Lt(e,t,r);for(;n=$(t,n),t.slice(n,n+2)==="=="||t.slice(n,n+2)==="!=";){let a=t.slice(n,n+2);if(n+=2,z(t,n))return F(a,n);let{expr:i,pos:l}=Lt(e,t,n);s={type:"ArithBinary",operator:a,left:s,right:i},n=l}return{expr:s,pos:n}}function Lt(e,t,r){let{expr:s,pos:n}=Fe(e,t,r);for(;;)if(n=$(t,n),t.slice(n,n+2)==="<="||t.slice(n,n+2)===">="){let a=t.slice(n,n+2);if(n+=2,z(t,n))return F(a,n);let{expr:i,pos:l}=Fe(e,t,n);s={type:"ArithBinary",operator:a,left:s,right:i},n=l}else if(t[n]==="<"||t[n]===">"){let a=t[n];if(n++,z(t,n))return F(a,n);let{expr:i,pos:l}=Fe(e,t,n);s={type:"ArithBinary",operator:a,left:s,right:i},n=l}else break;return{expr:s,pos:n}}function Fe(e,t,r){let{expr:s,pos:n}=Wt(e,t,r);for(;n=$(t,n),t.slice(n,n+2)==="<<"||t.slice(n,n+2)===">>";){let a=t.slice(n,n+2);if(n+=2,z(t,n))return F(a,n);let{expr:i,pos:l}=Wt(e,t,n);s={type:"ArithBinary",operator:a,left:s,right:i},n=l}return{expr:s,pos:n}}function Wt(e,t,r){let{expr:s,pos:n}=Tt(e,t,r);for(;n=$(t,n),(t[n]==="+"||t[n]==="-")&&t[n+1]!==t[n];){let a=t[n];if(n++,z(t,n))return F(a,n);let{expr:i,pos:l}=Tt(e,t,n);s={type:"ArithBinary",operator:a,left:s,right:i},n=l}return{expr:s,pos:n}}function Tt(e,t,r){let{expr:s,pos:n}=Re(e,t,r);for(;;)if(n=$(t,n),t[n]==="*"&&t[n+1]!=="*"){if(n++,z(t,n))return F("*",n);let{expr:i,pos:l}=Re(e,t,n);s={type:"ArithBinary",operator:"*",left:s,right:i},n=l}else if(t[n]==="/"||t[n]==="%"){let a=t[n];if(n++,z(t,n))return F(a,n);let{expr:i,pos:l}=Re(e,t,n);s={type:"ArithBinary",operator:a,left:s,right:i},n=l}else break;return{expr:s,pos:n}}function Re(e,t,r){let{expr:s,pos:n}=ze(e,t,r),a=$(t,n);if(t.slice(a,a+2)==="**"){if(a+=2,z(t,a))return F("**",a);let{expr:l,pos:o}=Re(e,t,a);return{expr:{type:"ArithBinary",operator:"**",left:s,right:l},pos:o}}return{expr:s,pos:n}}function ze(e,t,r){let s=$(t,r);if(t.slice(s,s+2)==="++"||t.slice(s,s+2)==="--"){let n=t.slice(s,s+2);s+=2;let{expr:a,pos:i}=ze(e,t,s);return{expr:{type:"ArithUnary",operator:n,operand:a,prefix:!0},pos:i}}if(t[s]==="+"||t[s]==="-"||t[s]==="!"||t[s]==="~"){let n=t[s];s++;let{expr:a,pos:i}=ze(e,t,s);return{expr:{type:"ArithUnary",operator:n,operand:a,prefix:!0},pos:i}}return Rr(e,t,s)}function Pr(e,t){let r=e[t];return r==="$"||r==="`"}function Rr(e,t,r){let{expr:s,pos:n}=Mt(e,t,r,!1),a=[s];for(;Pr(t,n);){let{expr:l,pos:o}=Mt(e,t,n,!0);a.push(l),n=o}a.length>1&&(s={type:"ArithConcat",parts:a});let i;if(t[n]==="["&&s.type==="ArithConcat"){n++;let{expr:l,pos:o}=Z(e,t,n);i=l,n=o,t[n]==="]"&&n++}if(i&&s.type==="ArithConcat"&&(s={type:"ArithDynamicElement",nameExpr:s,subscript:i},i=void 0),n=$(t,n),s.type==="ArithConcat"||s.type==="ArithVariable"||s.type==="ArithDynamicElement"){for(let l of Pe)if(t.slice(n,n+l.length)===l&&t.slice(n,n+l.length+1)!=="=="){n+=l.length;let{expr:o,pos:c}=ye(e,t,n);return s.type==="ArithDynamicElement"?{expr:{type:"ArithDynamicAssignment",operator:l,target:s.nameExpr,subscript:s.subscript,value:o},pos:c}:s.type==="ArithConcat"?{expr:{type:"ArithDynamicAssignment",operator:l,target:s,value:o},pos:c}:{expr:{type:"ArithAssignment",operator:l,variable:s.name,value:o},pos:c}}}if(t.slice(n,n+2)==="++"||t.slice(n,n+2)==="--"){let l=t.slice(n,n+2);return n+=2,{expr:{type:"ArithUnary",operator:l,operand:s,prefix:!1},pos:n}}return{expr:s,pos:n}}function Mt(e,t,r,s=!1){let n=$(t,r),a=It(Z,e,t,n);if(a)return a;let i=vt(t,n);if(i)return i;let l=Dt(t,n);if(l)return l;if(t.slice(n,n+2)==="$("&&t[n+2]!=="("){n+=2;let c=1,u=n;for(;n<t.length&&c>0;)t[n]==="("?c++:t[n]===")"&&c--,c>0&&n++;let f=t.slice(u,n);return n++,{expr:{type:"ArithCommandSubst",command:f},pos:n}}if(t[n]==="`"){n++;let c=n;for(;n<t.length&&t[n]!=="`";)n++;let u=t.slice(c,n);return t[n]==="`"&&n++,{expr:{type:"ArithCommandSubst",command:u},pos:n}}if(t[n]==="("){n++;let{expr:c,pos:u}=Z(e,t,n);return n=$(t,u),t[n]===")"&&n++,{expr:{type:"ArithGroup",expression:c},pos:n}}if(t[n]==="'"){n++;let c="";for(;n<t.length&&t[n]!=="'";)c+=t[n],n++;t[n]==="'"&&n++;let u=Number.parseInt(c,10);return{expr:{type:"ArithSingleQuote",content:c,value:Number.isNaN(u)?0:u},pos:n}}if(t[n]==='"'){n++;let c="";for(;n<t.length&&t[n]!=='"';)t[n]==="\\"&&n+1<t.length?(c+=t[n+1],n+=2):(c+=t[n],n++);t[n]==='"'&&n++;let u=c.trim();if(!u)return{expr:{type:"ArithNumber",value:0},pos:n};let{expr:f}=Z(e,u,0);return{expr:f,pos:n}}if(/[0-9]/.test(t[n])){let c="",u=!1,f=!1;for(;n<t.length;){let d=t[n];if(u)if(/[0-9a-zA-Z@_]/.test(d))c+=d,n++;else break;else if(d==="#")u=!0,c+=d,n++;else if(c==="0"&&(d==="x"||d==="X")&&n+1<t.length&&/[0-9a-fA-F]/.test(t[n+1]))f=!0,c+=d,n++;else if(f&&/[0-9a-fA-F]/.test(d))c+=d,n++;else if(!f&&/[0-9]/.test(d))c+=d,n++;else break}if(n<t.length&&/[a-zA-Z_]/.test(t[n])){let d=c;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)d+=t[n],n++;return{expr:{type:"ArithSyntaxError",errorToken:d,message:`${d}: value too great for base (error token is "${d}")`},pos:n}}if(t[n]==="."&&/[0-9]/.test(t[n+1]))throw new C(`${c}.${t[n+1]}...: syntax error: invalid arithmetic operator`);if(t[n]==="["){let d=t.slice(n).trim();return{expr:{type:"ArithNumberSubscript",number:c,errorToken:d},pos:t.length}}return{expr:{type:"ArithNumber",value:ge(c)},pos:n}}if(t[n]==="$"&&t[n+1]==="{"){let c=n+2,u=1,f=c;for(;f<t.length&&u>0;)t[f]==="{"?u++:t[f]==="}"&&u--,u>0&&f++;let h=t.slice(c,f),d=f+1;if(t[d]==="#"){let m=d+1;for(;m<t.length&&/[0-9a-zA-Z@_]/.test(t[m]);)m++;let g=t.slice(d+1,m);return{expr:{type:"ArithDynamicBase",baseExpr:h,value:g},pos:m}}if(/[0-9]/.test(t[d])||t[d]==="x"||t[d]==="X"){let m=d;if(t[d]==="x"||t[d]==="X")for(m++;m<t.length&&/[0-9a-fA-F]/.test(t[m]);)m++;else for(;m<t.length&&/[0-9]/.test(t[m]);)m++;let g=t.slice(d,m);return{expr:{type:"ArithDynamicNumber",prefix:h,suffix:g},pos:m}}return n=d,{expr:{type:"ArithBracedExpansion",content:h},pos:n}}if(t[n]==="$"&&n+1<t.length&&/[0-9]/.test(t[n+1])){n++;let c="";for(;n<t.length&&/[0-9]/.test(t[n]);)c+=t[n],n++;return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:!0},pos:n}}if(t[n]==="$"&&n+1<t.length&&/[*@#?\-!$]/.test(t[n+1])){let c=t[n+1];return n+=2,{expr:{type:"ArithSpecialVar",name:c},pos:n}}let o=!1;if(t[n]==="$"&&n+1<t.length&&/[a-zA-Z_]/.test(t[n+1])&&(o=!0,n++),n<t.length&&/[a-zA-Z_]/.test(t[n])){let c="";for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)c+=t[n],n++;if(t[n]==="["&&!s){n++;let u;if(t[n]==="'"||t[n]==='"'){let h=t[n];for(n++,u="";n<t.length&&t[n]!==h;)u+=t[n],n++;t[n]===h&&n++,n=$(t,n),t[n]==="]"&&n++}let f;if(u===void 0){let{expr:h,pos:d}=Z(e,t,n);f=h,n=d,t[n]==="]"&&n++}if(n=$(t,n),t[n]==="["&&f)return{expr:{type:"ArithDoubleSubscript",array:c,index:f},pos:n};if(!s){for(let h of Pe)if(t.slice(n,n+h.length)===h&&t.slice(n,n+h.length+1)!=="=="){n+=h.length;let{expr:d,pos:m}=ye(e,t,n);return{expr:{type:"ArithAssignment",operator:h,variable:c,subscript:f,stringKey:u,value:d},pos:m}}}return{expr:{type:"ArithArrayElement",array:c,index:f,stringKey:u},pos:n}}if(n=$(t,n),!s){for(let u of Pe)if(t.slice(n,n+u.length)===u&&t.slice(n,n+u.length+1)!=="=="){n+=u.length;let{expr:f,pos:h}=ye(e,t,n);return{expr:{type:"ArithAssignment",operator:u,variable:c,value:f},pos:h}}}return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:o},pos:n}}if(t[n]==="#"){let c=n+1;for(;c<t.length&&t[c]!==`
|
|
5
5
|
`;)c++;let u=t.slice(n,c).trim()||"#";return{expr:{type:"ArithSyntaxError",errorToken:u,message:`${u}: syntax error: invalid arithmetic operator (error token is "${u}")`},pos:t.length}}return{expr:{type:"ArithNumber",value:0},pos:n}}var w={script(e){return{type:"Script",statements:e}},statement(e,t=[],r=!1,s,n){let a={type:"Statement",pipelines:e,operators:t,background:r};return s&&(a.deferredError=s),n!==void 0&&(a.sourceText=n),a},pipeline(e,t=!1,r=!1,s=!1,n){return{type:"Pipeline",commands:e,negated:t,timed:r,timePosix:s,pipeStderr:n}},simpleCommand(e,t=[],r=[],s=[]){return{type:"SimpleCommand",name:e,args:t,assignments:r,redirections:s}},word(e){return{type:"Word",parts:e}},literal(e){return{type:"Literal",value:e}},singleQuoted(e){return{type:"SingleQuoted",value:e}},doubleQuoted(e){return{type:"DoubleQuoted",parts:e}},escaped(e){return{type:"Escaped",value:e}},parameterExpansion(e,t=null){return{type:"ParameterExpansion",parameter:e,operation:t}},commandSubstitution(e,t=!1){return{type:"CommandSubstitution",body:e,legacy:t}},arithmeticExpansion(e){return{type:"ArithmeticExpansion",expression:e}},assignment(e,t,r=!1,s=null){return{type:"Assignment",name:e,value:t,append:r,array:s}},redirection(e,t,r=null,s){let n={type:"Redirection",fd:r,operator:e,target:t};return s&&(n.fdVariable=s),n},hereDoc(e,t,r=!1,s=!1){return{type:"HereDoc",delimiter:e,content:t,stripTabs:r,quoted:s}},ifNode(e,t=null,r=[]){return{type:"If",clauses:e,elseBody:t,redirections:r}},forNode(e,t,r,s=[]){return{type:"For",variable:e,words:t,body:r,redirections:s}},whileNode(e,t,r=[]){return{type:"While",condition:e,body:t,redirections:r}},untilNode(e,t,r=[]){return{type:"Until",condition:e,body:t,redirections:r}},caseNode(e,t,r=[]){return{type:"Case",word:e,items:t,redirections:r}},caseItem(e,t,r=";;"){return{type:"CaseItem",patterns:e,body:t,terminator:r}},subshell(e,t=[]){return{type:"Subshell",body:e,redirections:t}},group(e,t=[]){return{type:"Group",body:e,redirections:t}},functionDef(e,t,r=[],s){return{type:"FunctionDef",name:e,body:t,redirections:r,sourceFile:s}},conditionalCommand(e,t=[],r){return{type:"ConditionalCommand",expression:e,redirections:t,line:r}},arithmeticCommand(e,t=[],r){return{type:"ArithmeticCommand",expression:e,redirections:t,line:r}}};var p;(function(e){e.EOF="EOF",e.NEWLINE="NEWLINE",e.SEMICOLON="SEMICOLON",e.AMP="AMP",e.PIPE="PIPE",e.PIPE_AMP="PIPE_AMP",e.AND_AND="AND_AND",e.OR_OR="OR_OR",e.BANG="BANG",e.LESS="LESS",e.GREAT="GREAT",e.DLESS="DLESS",e.DGREAT="DGREAT",e.LESSAND="LESSAND",e.GREATAND="GREATAND",e.LESSGREAT="LESSGREAT",e.DLESSDASH="DLESSDASH",e.CLOBBER="CLOBBER",e.TLESS="TLESS",e.AND_GREAT="AND_GREAT",e.AND_DGREAT="AND_DGREAT",e.LPAREN="LPAREN",e.RPAREN="RPAREN",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.DSEMI="DSEMI",e.SEMI_AND="SEMI_AND",e.SEMI_SEMI_AND="SEMI_SEMI_AND",e.DBRACK_START="DBRACK_START",e.DBRACK_END="DBRACK_END",e.DPAREN_START="DPAREN_START",e.DPAREN_END="DPAREN_END",e.IF="IF",e.THEN="THEN",e.ELSE="ELSE",e.ELIF="ELIF",e.FI="FI",e.FOR="FOR",e.WHILE="WHILE",e.UNTIL="UNTIL",e.DO="DO",e.DONE="DONE",e.CASE="CASE",e.ESAC="ESAC",e.IN="IN",e.FUNCTION="FUNCTION",e.SELECT="SELECT",e.TIME="TIME",e.COPROC="COPROC",e.WORD="WORD",e.NAME="NAME",e.NUMBER="NUMBER",e.ASSIGNMENT_WORD="ASSIGNMENT_WORD",e.FD_VARIABLE="FD_VARIABLE",e.COMMENT="COMMENT",e.HEREDOC_CONTENT="HEREDOC_CONTENT"})(p||(p={}));var pe=class extends Error{line;column;constructor(t,r,s){super(`line ${r}: ${t}`),this.line=r,this.column=s,this.name="LexerError"}},qt=new Map([["if",p.IF],["then",p.THEN],["else",p.ELSE],["elif",p.ELIF],["fi",p.FI],["for",p.FOR],["while",p.WHILE],["until",p.UNTIL],["do",p.DO],["done",p.DONE],["case",p.CASE],["esac",p.ESAC],["in",p.IN],["function",p.FUNCTION],["select",p.SELECT],["time",p.TIME],["coproc",p.COPROC]]);function Bt(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let r=e.slice(t[0].length);if(r===""||r==="+")return!0;if(r[0]==="["){let s=0,n=0;for(;n<r.length;n++)if(r[n]==="[")s++;else if(r[n]==="]"&&(s--,s===0))break;if(s!==0||n>=r.length)return!1;let a=r.slice(n+1);return a===""||a==="+"}return!1}function Ft(e){let t=0;for(let r=0;r<e.length;r++){let s=e[r];if(s==="[")t++;else if(s==="]")t--;else{if(t===0&&s==="=")return r;if(t===0&&s==="+"&&e[r+1]==="=")return r+1}}return-1}var Ir=[[";",";","&",p.SEMI_SEMI_AND],["<","<","<",p.TLESS],["&",">",">",p.AND_DGREAT]],vr=[["[","[",p.DBRACK_START],["]","]",p.DBRACK_END],["(","(",p.DPAREN_START],[")",")",p.DPAREN_END],["&","&",p.AND_AND],["|","|",p.OR_OR],[";",";",p.DSEMI],[";","&",p.SEMI_AND],["|","&",p.PIPE_AMP],[">",">",p.DGREAT],["<","&",p.LESSAND],[">","&",p.GREATAND],["<",">",p.LESSGREAT],[">","|",p.CLOBBER],["&",">",p.AND_GREAT]],Dr=new Map([["|",p.PIPE],["&",p.AMP],[";",p.SEMICOLON],["(",p.LPAREN],[")",p.RPAREN],["<",p.LESS],[">",p.GREAT]]);function xr(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function zt(e){return e===" "||e===" "||e===`
|