import{i as e}from"./chunk-GFQRA5P5-DbAN9IDm.mjs";import{n as t}from"./chunk-5QMZ5MUS-BwpNU33k.mjs";import{r as n,t as r}from"./chunk-24IMIIXA-DaS5XS55.mjs";import{n as i}from"./chunk-3THT3N7L-B1WzJUh4.mjs";import{n as a,r as o,t as s}from"./chunk-74CEPOFO-V0JXh91S.mjs";import{n as c}from"./chunk-7L36YK2X-B3QRwLbB.mjs";import{t as l}from"./chunk-7TSDKFEO-CMVuiOdP.mjs";import{n as u,t as d}from"./chunk-BBXLRYSX-XWD4jM9A.mjs";function f(e){let t=[],n=0,r=e.length;for(;n<r;){for(;n<r&&/\s/.test(e[n]);)n++;if(n>=r)break;let i=n,a=e[n];if(a===`{`||a===`[`){let o=a,s=a===`{`?`}`:`]`,c=1,u=!1,d=!1;for(n++;n<r&&c>0;){let t=e[n];d?d=!1:t===`\\`?d=!0:t===`"`?u=!u:u||(t===o?c++:t===s&&c--),n++}if(c!==0)throw Error(`Unexpected end of JSON input at position ${n} (unclosed ${o})`);t.push(l(JSON.parse(e.slice(i,n))))}else if(a===`"`){let a=!1;for(n++;n<r;){let t=e[n];if(a)a=!1;else if(t===`\\`)a=!0;else if(t===`"`){n++;break}n++}t.push(l(JSON.parse(e.slice(i,n))))}else if(a===`-`||a>=`0`&&a<=`9`){for(;n<r&&/[\d.eE+-]/.test(e[n]);)n++;t.push(l(JSON.parse(e.slice(i,n))))}else if(e.slice(n,n+4)===`true`)t.push(!0),n+=4;else if(e.slice(n,n+5)===`false`)t.push(!1),n+=5;else if(e.slice(n,n+4)===`null`)t.push(null),n+=4;else{let t=e.slice(n,n+10);throw Error(`Invalid JSON at position ${i}: unexpected '${t.split(/\s/)[0]}'`)}}return t}var p={name:`jq`,summary:`command-line JSON processor`,usage:`jq [OPTIONS] FILTER [FILE]`,options:[`-r, --raw-output  output strings without quotes`,`-c, --compact     compact output (no pretty printing)`,`-e, --exit-status set exit status based on output`,`-s, --slurp       read entire input into array`,`-n, --null-input  don't read any input`,`-j, --join-output don't print newlines after each output`,`-a, --ascii       force ASCII output`,`-S, --sort-keys   sort object keys`,`-C, --color       colorize output (ignored)`,`-M, --monochrome  monochrome output (ignored)`,`    --tab         use tabs for indentation`,`    --help        display this help and exit`]};function m(e,t,n,r,i,a=0){if(e==null)return`null`;if(typeof e==`boolean`)return String(e);if(typeof e==`number`)return Number.isFinite(e)?String(e):`null`;if(typeof e==`string`)return n?e:JSON.stringify(e);let o=i?`	`:`  `;if(Array.isArray(e))return e.length===0?`[]`:t?`[${e.map(e=>m(e,!0,!1,r,i)).join(`,`)}]`:`[
${e.map(e=>o.repeat(a+1)+m(e,!1,!1,r,i,a+1)).join(`,
`)}
${o.repeat(a)}]`;if(typeof e==`object`){let n=Object.keys(e);return r&&(n=n.sort()),n.length===0?`{}`:t?`{${n.map(t=>`${JSON.stringify(t)}:${m(e[t],!0,!1,r,i)}`).join(`,`)}}`:`{
${n.map(t=>{let n=m(e[t],!1,!1,r,i,a+1);return`${o.repeat(a+1)}${JSON.stringify(t)}: ${n}`}).join(`,
`)}
${o.repeat(a)}}`}return String(e)}var h={name:`jq`,async execute(l,h){r(h.requireDefenseContext,`jq`,`execution entry`);let g=(e,t)=>n(h.requireDefenseContext,`jq`,e,t);if(s(l))return o(p);let _=!1,v=!1,y=!1,b=!1,x=!1,S=!1,C=!1,w=!1,T=`.`,E=!1,D=[];for(let e=0;e<l.length;e++){let t=l[e];if(t===`-r`||t===`--raw-output`)_=!0;else if(t===`-c`||t===`--compact-output`)v=!0;else if(t===`-e`||t===`--exit-status`)y=!0;else if(t===`-s`||t===`--slurp`)b=!0;else if(t===`-n`||t===`--null-input`)x=!0;else if(t===`-j`||t===`--join-output`)S=!0;else if(!(t===`-a`||t===`--ascii`)){if(t===`-S`||t===`--sort-keys`)C=!0;else if(!(t===`-C`||t===`--color`)&&!(t===`-M`||t===`--monochrome`))if(t===`--tab`)w=!0;else if(t===`-`)D.push(`-`);else{if(t.startsWith(`--`))return a(`jq`,t);if(t.startsWith(`-`)){for(let e of t.slice(1))if(e===`r`)_=!0;else if(e===`c`)v=!0;else if(e===`e`)y=!0;else if(e===`s`)b=!0;else if(e===`n`)x=!0;else if(e===`j`)S=!0;else if(e!==`a`){if(e===`S`)C=!0;else if(e!==`C`&&e!==`M`)return a(`jq`,`-${e}`)}}else E?D.push(t):(T=t,E=!0)}}}let O=[];if(!x)if(D.length===0||D.length===1&&D[0]===`-`)O.push({source:`stdin`,content:h.stdin});else{let e=await g(`file read`,()=>c(h,D,{cmdName:`jq`,stopOnError:!0}));if(e.exitCode!==0)return{stdout:``,stderr:e.stderr,exitCode:2};O=e.files.map(e=>({source:e.filename||`stdin`,content:e.content}))}try{let t=d(T),n=[],r={limits:h.limits?{maxIterations:h.limits.maxJqIterations}:void 0,env:h.env,coverage:h.coverage,requireDefenseContext:h.requireDefenseContext};if(x)n=u(null,t,r);else if(b){let e=[];for(let{content:t}of O){let n=t.trim();n&&e.push(...f(n))}n=u(e,t,r)}else for(let{content:e}of O){let i=e.trim();if(!i)continue;let a=f(i);for(let e of a)n.push(...u(e,t,r))}let i=n.map(e=>m(e,v,_,C,w)),a=S?``:`
`,o=i.join(a),s=h.limits?.maxStringLength;if(s!==void 0&&s>0&&o.length>s)throw new e(`jq: output size limit exceeded (${s} bytes)`,`string_length`);let c=y&&(n.length===0||n.every(e=>e==null||e===!1))?1:0;return{stdout:o?S?o:`${o}
`:``,stderr:``,exitCode:c}}catch(n){if(n instanceof t)throw n;if(n instanceof e)return{stdout:``,stderr:`jq: ${i(n.message)}
`,exitCode:e.EXIT_CODE};let r=i(n.message);return r.includes(`Unknown function`)?{stdout:``,stderr:`jq: error: ${r}
`,exitCode:3}:{stdout:``,stderr:`jq: parse error: ${r}
`,exitCode:5}}}},g={name:`jq`,flags:[{flag:`-r`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-e`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-j`,type:`boolean`},{flag:`-S`,type:`boolean`},{flag:`--tab`,type:`boolean`}],stdinType:`json`,needsArgs:!0};export{g as n,h as t};
//# sourceMappingURL=chunk-YCFVLTST-DsF45PbT.mjs.map