1ls 0.1.12 → 0.1.14
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/README.md +285 -11
- package/dist/browser/constants.d.ts +1 -1
- package/dist/browser/index.js +11 -11
- package/dist/cli/constants.d.ts +1 -1
- package/dist/{utils → cli}/stream.d.ts +1 -1
- package/dist/completions/1ls.bash +11 -19
- package/dist/completions/1ls.zsh +146 -40
- package/dist/completions/constants.d.ts +124 -0
- package/dist/completions/constants.ts +41 -0
- package/dist/completions/index.d.ts +17 -0
- package/dist/completions/index.ts +197 -0
- package/dist/completions/install-completions.sh +8 -7
- package/dist/{shared/constants.d.ts → constants.d.ts} +1 -1
- package/dist/expression/constants.d.ts +2 -0
- package/dist/expression/index.d.ts +3 -12
- package/dist/expression/utils.d.ts +14 -1
- package/dist/file/constants.d.ts +4 -0
- package/dist/file/filters.d.ts +7 -0
- package/dist/file/grep.d.ts +10 -0
- package/dist/file/index.d.ts +7 -0
- package/dist/file/info.d.ts +4 -0
- package/dist/file/io.d.ts +5 -0
- package/dist/{utils → file}/types.d.ts +0 -17
- package/dist/file/walk.d.ts +4 -0
- package/dist/formats/index.d.ts +1 -1
- package/dist/formats/types.d.ts +1 -0
- package/dist/formats/yaml/index.d.ts +2 -0
- package/dist/formats/yaml/types.d.ts +8 -0
- package/dist/formats/yaml/utils.d.ts +28 -0
- package/dist/index.js +82 -65
- package/dist/interactive/builder/constants.d.ts +14 -0
- package/dist/interactive/{builder.d.ts → builder/index.d.ts} +1 -1
- package/dist/interactive/builder/types.d.ts +4 -0
- package/dist/interactive/builder/utils.d.ts +7 -0
- package/dist/interactive/methods/constants.d.ts +10 -0
- package/dist/interactive/methods/index.d.ts +4 -0
- package/dist/interactive/methods/types.d.ts +8 -0
- package/dist/interactive/preview/constants.d.ts +4 -0
- package/dist/interactive/preview/index.d.ts +5 -0
- package/dist/interactive/preview/types.d.ts +6 -0
- package/dist/interactive/tooltip/constants.d.ts +3 -0
- package/dist/interactive/tooltip/index.d.ts +20 -0
- package/dist/interactive/tooltip/types.d.ts +13 -0
- package/dist/interactive/types.d.ts +5 -7
- package/dist/{utils/logger.d.ts → logger.d.ts} +10 -1
- package/dist/navigator/builtins/constants.d.ts +62 -0
- package/dist/navigator/builtins/index.d.ts +6 -0
- package/dist/navigator/builtins/types.d.ts +3 -0
- package/dist/navigator/builtins/utils.d.ts +12 -0
- package/dist/navigator/json/constants.d.ts +2 -0
- package/dist/navigator/json/index.d.ts +22 -0
- package/dist/navigator/json/types.d.ts +3 -0
- package/dist/navigator/json/utils.d.ts +14 -0
- package/dist/shortcuts/constants.d.ts +15 -0
- package/dist/shortcuts/index.d.ts +9 -0
- package/dist/shortcuts/types.d.ts +6 -0
- package/dist/types.d.ts +21 -2
- package/dist/version.d.ts +1 -1
- package/package.json +18 -10
- package/dist/formats/yaml.d.ts +0 -3
- package/dist/interactive/methods.d.ts +0 -12
- package/dist/navigator/json.d.ts +0 -31
- package/dist/utils/constants.d.ts +0 -12
- package/dist/utils/file.d.ts +0 -27
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/shortcuts.d.ts +0 -8
package/dist/index.js
CHANGED
|
@@ -1,80 +1,91 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`).reduce((r,o)=>ms(r,o),{result:{}}).result}var an=x(()=>{dt()});var un={};O(un,{parseNDJSON:()=>gs});function gs(t){return t.trim().split(`
|
|
13
|
-
`).map((n)=>n.trim()).filter((n)=>n.length>0).map((n)=>{try{return JSON.parse(n)}catch{return n}})}function xs(t){return t.trim().split(`
|
|
14
|
-
`).filter((e)=>e.length>0)}async function xt(t,e){switch(e??Gt(t)){case"json":try{return JSON.parse(t)}catch(r){let o=t.length>50?t.slice(0,50)+"...":t;throw Error(`Invalid JSON: ${r.message}
|
|
15
|
-
Input: ${o}`)}case"json5":{let{parseJSON5:r}=await Promise.resolve().then(() => (Pe(),ke));return r(t)}case"yaml":{let{parseYAML:r}=await Promise.resolve().then(() => (je(),Be));return r(t)}case"toml":{let{parseTOML:r}=await Promise.resolve().then(() => ($e(),De));return r(t)}case"xml":{let{parseXML:r}=await Promise.resolve().then(() => (We(),Ge));return r(t)}case"ini":{let{parseINI:r}=await Promise.resolve().then(() => (Qe(),ze));return r(t)}case"csv":{let{parseCSV:r}=await Promise.resolve().then(() => (Vt(),$t));return r(t)}case"tsv":{let{parseTSV:r}=await Promise.resolve().then(() => (Vt(),$t));return r(t)}case"protobuf":{let{parseProtobuf:r}=await Promise.resolve().then(() => Xe);return r(t)}case"javascript":{let{parseJavaScript:r}=await Promise.resolve().then(() => nn);return r(t)}case"typescript":{let{parseTypeScript:r}=await Promise.resolve().then(() => (sn(),rn));return r(t)}case"env":{let{parseENV:r}=await Promise.resolve().then(() => (an(),cn));return r(t)}case"ndjson":{let{parseNDJSON:r}=await Promise.resolve().then(() => un);return r(t)}case"lines":return xs(t);case"text":default:{if(/^\s*[{[]/.test(t))try{return JSON.parse(t)}catch(o){let s=t.length>50?t.slice(0,50)+"...":t;throw Error(`Invalid JSON: ${o.message}
|
|
16
|
-
Input: ${s}`)}return t}}}function ys(t){let e=t.split(`
|
|
17
|
-
`),n=E.NDJSON_FEATURES.test(t),r=e.every(bs);if(n&&r)return"ndjson";let s=e[0],i=ln(s,/,/g),c=ln(s,/\t/g);if(c>0&&c>=i)return"tsv";if(i>0)return"csv";return"lines"}function Ss(t){if(E.ENV_FEATURES.test(t))return"env";if(E.TOML_QUOTED_VALUES.test(t))return"toml";let r=E.SECTION_HEADER.test(t),o=E.TOML_SECTION.test(t),s=E.TOML_SYNTAX.test(t);if(r&&o&&s)return"toml";let c=E.INI_SYNTAX.test(t);if(r&&c)return"ini";if(c)return"ini";return"text"}function Gt(t){let e=t.trim();if(!e)return"text";let n=e[0],r=e[e.length-1],o=Os(e,n,r);if(o)return o;let s=vs(e);if(s)return s;return"text"}var bs=(t)=>{let e=t.trim();if(!e)return!0;try{return JSON.parse(e),!0}catch{return!1}},ln=(t,e)=>(t.match(e)||[]).length,ws=(t)=>{try{return JSON.parse(t),"json"}catch{return E.JSON5_FEATURES.test(t)?"json5":null}},Es=(t,e,n)=>{if(e==="{"&&n==="}"||e==="["&&n==="]")return ws(t);return null},As=(t)=>{let e=t.startsWith("<?xml"),n=/<\/\w+>/.test(t);return e||n?"xml":null},Ns=(t)=>E.TS_INTERFACE.test(t)||E.TS_TYPE_ALIAS.test(t)||E.TS_TYPE_ANNOTATION.test(t),Ts=(t)=>{if(!E.JS_EXPORT.test(t))return null;return Ns(t)?"typescript":"javascript"},Os=(t,e,n)=>{switch(e){case"{":case"[":return Es(t,e,n);case"<":return As(t);case"-":return t.startsWith("---")?"yaml":null;case"e":return Ts(t);case"i":return E.TS_INTERFACE.test(t)?"typescript":null;case"t":return E.TS_TYPE_ALIAS.test(t)?"typescript":null;case"c":case"l":case"v":return E.TS_TYPE_ANNOTATION.test(t)?"typescript":null;default:return null}},vs=(t)=>{if(t.includes("="))return Ss(t);let n=t.includes(": "),r=/^[\s]*-\s+/m.test(t);if(n||r)return"yaml";if(t.includes(`
|
|
18
|
-
`))return ys(t);return null};var bt=x(()=>{$()});async function pn(t){let e=[];for await(let r of process.stdin)e.push(r);let n=Buffer.concat(e).toString("utf-8").trim();if(!n)return null;return xt(n,t)}var Wt=x(()=>{bt()});var Is,Rs,Cs,dn,hn;var yt=x(()=>{Is=[".ts",".js",".tsx",".jsx"],Rs=[".json",".yml",".yaml"],Cs=[".md",".txt"],dn=[...Is,...Rs,...Cs],hn=/[.*+?^${}()|[\]\\]/g});import{readdir as Fs,stat as mn}from"fs/promises";import{join as Ms,extname as Ls,basename as ks}from"path";async function St(t,e=!0){let r=await Bun.file(t).text();if(!e)return r;return xt(r)}function Ps(t,e){return{path:t,name:ks(t),ext:Ls(t),size:Number(e.size),isDirectory:e.isDirectory(),isFile:e.isFile(),modified:e.mtime,created:e.birthtime}}async function _s(t){let e=await mn(t);return Ps(t,e)}function Bs(t){return t.startsWith(".")}function js(t,e){return e||!Bs(t)}function Ds(t,e){if(e===void 0)return!0;return e.includes(t)}function $s(t,e){if(e===void 0)return!0;return e.test(t)}function Vs(t,e,n){let r=Ds(t.ext,e),o=$s(t.name,n);return r&&o}function Gs(t,e){return t<=(e??1/0)}async function Ws(t,e,n,r){if(!js(e,r.includeHidden??!1))return[];let s=Ms(t,e),i=await _s(s);if(i.isFile)return Vs(i,r.extensions,r.pattern)?[i]:[];if(!i.isDirectory)return[];let a=r.recursive===!0?await fn(s,n+1,r):[];return[i,...a]}async function fn(t,e,n){if(!Gs(e,n.maxDepth))return[];let o=await Fs(t);return(await Promise.all(o.map((i)=>Ws(t,i,e,n)))).flat()}async function Ut(t,e={}){return fn(t,0,e)}function Us(t,e){if(typeof t!=="string")return t;return new RegExp(t,e?"gi":"g")}function Js(t,e,n,r,o,s){let i={file:t,line:e+1,column:n+1,match:r};if(s===void 0)return i;let a=Math.max(0,e-s),u=Math.min(o.length,e+s+1);return{...i,context:o.slice(a,u)}}function zs(t,e,n){if(!n)return;let r=e instanceof Error?e.message:String(e);console.error(`Failed to search ${t}: ${r}`)}function Qs(t,e,n,r,o,s){return[...t.matchAll(n)].map((c)=>Js(r,e,c.index,t,o,s))}async function gn(t,e,n){try{let r=await St(t,!1);if(typeof r!=="string")return[];let s=r.split(`
|
|
19
|
-
`),i=s.flatMap((a,u)=>Qs(a,u,e,t,s,n.context)),c=n.maxMatches??1/0;return i.slice(0,c)}catch(r){return zs(t,r,n.verbose??!1),[]}}async function Hs(t,e,n){let r=await Ut(t,{recursive:!0,extensions:[...dn]});return(await Promise.all(r.filter((s)=>s.isFile).map((s)=>gn(s.path,e,n)))).flat()}async function xn(t,e,n={}){let r=Us(t,n.ignoreCase??!1),o=await mn(e);if(o.isFile())return gn(e,r,n);if(o.isDirectory()&&n.recursive)return Hs(e,r,n);return[]}var Jt=x(()=>{yt();bt()});var wt=()=>{};var yn,Sn="+-*/%<>!&|=",wn;var En=x(()=>{wt();yn={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},wn=[" ","\t",`
|
|
20
|
-
`,"\r"]});function V(t,e,n){return{type:t,value:e,position:n}}class et{input;position=0;current;constructor(t){this.input=t,this.current=this.input[0]||""}tokenize(){let t=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let e=this.nextToken();if(e)t.push(e)}return t.push(V("EOF","",this.position)),t}nextToken(){let t=this.position,e=yn[this.current];if(e){let u=this.current;return this.advance(),V(e,u,t)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),V("ARROW","=>",t);if(this.current==='"'||this.current==="'")return this.readString();let o=this.isDigit(this.current),s=this.current==="-"&&this.isDigit(this.peek());if(o||s)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let t=this.position,e=this.current,n=[];this.advance();while(this.current!==e&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===e)this.advance();return V("STRING",n.join(""),t)}readNumber(){let t=this.position,e="";if(this.current==="-")e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance()}return V("NUMBER",e,t)}readIdentifier(){let t=this.position,e="";while(this.isIdentifierChar(this.current))e+=this.current,this.advance();return V("IDENTIFIER",e,t)}readOperator(){let t=this.position,e="";while(this.isOperator(this.current))e+=this.current,this.advance();return V("OPERATOR",e,t)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(t){return wn.includes(t)}isDigit(t){return t>="0"&&t<="9"}isIdentifierStart(t){let e=t>="a"&&t<="z",n=t>="A"&&t<="Z";return e||n||t==="_"||t==="$"}isIdentifierChar(t){return this.isIdentifierStart(t)||this.isDigit(t)}isOperator(t){return Sn.includes(t)}}var zt=x(()=>{wt();En()});var An=()=>{};var R=(t)=>{return{type:"Literal",value:t}},Qt=(t)=>{if(t==="true")return R(!0);if(t==="false")return R(!1);if(t==="null")return R(null);return};var Nn=x(()=>{An()});function k(t,e){return`${e} at position ${t.position} (got ${t.type}: "${t.value}")`}function G(t,e){return{type:"PropertyAccess",property:t,object:e}}function Ks(t,e){return{type:"IndexAccess",index:t,object:e}}function Xs(t,e,n){return{type:"SliceAccess",start:t,end:e,object:n}}function Tn(t,e,n){return{type:"MethodCall",method:t,args:e,object:n}}function qs(t,e){return{type:"ObjectOperation",operation:t,object:e}}function Ys(t){return{type:"ArraySpread",object:t}}function Zs(t,e){return{type:"ArrowFunction",params:t,body:e}}function nt(t){return{type:"Root",expression:t}}function to(t){return On.includes(t)}class rt{tokens;position=0;current;constructor(t){this.tokens=t,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return nt();let e=this.parseExpression();return nt(e)}parseExpression(){return this.parsePrimary()}parsePrimary(){let t=this.parsePrimaryNode();return this.parsePostfix(t)}parsePrimaryNode(){let t=this.current.type;if(t==="DOT"){if(this.advance(),this.current.type==="EOF")return nt();return this.parseAccessChain()}if(t==="LEFT_BRACKET")return this.parseArrayAccess();if(t==="IDENTIFIER")return this.parseIdentifierOrFunction();if(t==="STRING"){let e=this.current.value;return this.advance(),R(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),R(e)}if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}throw Error(k(this.current,"Unexpected token"))}parseAccessChain(t){let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;return this.advance(),G(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(k(this.current,"Expected property name after dot"))}parseBracketAccess(t){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),Ys(t);if(this.current.type==="STRING"){let c=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),G(c,t)}let r=this.current.type==="NUMBER",o=this.current.type==="OPERATOR"&&this.current.value==="-",s=this.current.type==="COLON";if(r||o||s)return this.parseNumericIndexOrSlice(t);throw Error(k(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(t){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,t);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,t);return this.expect("RIGHT_BRACKET"),Ks(n,t)}parseSliceFromColon(t,e){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",o=n||r,s=o?this.parseNumber():void 0;if(o)this.advance();return this.expect("RIGHT_BRACKET"),Xs(t,s,e)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(t){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(k(this.current,"Expected operation name after {"));let n=this.current.value;if(!to(n)){let r=On.join(", ");throw Error(k(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),qs(n,t)}parseIdentifierOrFunction(){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);let n=Qt(t);if(n)return n;return G(t)}parseArrowFunction(t){this.expect("ARROW");let e=this.parseFunctionBody();return Zs(t,e)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),e}return this.parseBinaryExpression()}parseBinaryExpression(){let t=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let e=this.current.value;this.advance();let n=this.parseFunctionTerm();t=Tn(`__operator_${e}__`,[n],t)}return t}parseFunctionTerm(){let t=this.current.type;if(t==="IDENTIFIER")return this.parseIdentifierChain();if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),R(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),R(e)}if(t==="LEFT_PAREN"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),e}throw Error(k(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let t=this.current.value;this.advance();let e=Qt(t);if(e)return e;let n=G(t),r=()=>this.current.type==="DOT",o=()=>this.current.type==="IDENTIFIER",s=()=>this.current.type==="LEFT_PAREN";while(r()||s()){if(s()){let c=n,a=c.property,u=c.object;n=this.parseMethodCall(u?u:nt(),a);continue}if(this.advance(),!o())break;let i=this.current.value;this.advance(),n=G(i,n)}return n}parseMethodCall(t,e){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),Tn(e,n,t)}parseMethodArguments(){let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let e=this.parseMethodArgument();if(t.push(e),this.current.type==="COMMA")this.advance()}return t}parseMethodArgument(){let t=this.current.type;if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}if(t==="IDENTIFIER"){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);return G(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),R(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),R(e)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")t.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),t}parsePostfix(t){let e=t;while(!0){let n=this.current.type;if(n==="DOT"){e=this.parsePostfixDot(e);continue}if(n==="LEFT_BRACKET"){e=this.parseBracketAccess(e);continue}if(n==="LEFT_PAREN"){if(e.type==="PropertyAccess"&&!e.object){let s=e.property;e=this.parseMethodCall(nt(),s);continue}}break}return e}parsePostfixDot(t){this.advance();let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(t,n);return G(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(k(this.current,"Expected property name after dot"))}parseNumber(){let t=this.current.value==="-";if(t)this.advance();if(this.current.type!=="NUMBER")throw Error(k(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return t?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(t){if(this.current.type!==t)throw Error(k(this.current,`Expected ${t} but got ${this.current.type}`));this.advance()}}var On;var Ht=x(()=>{wt();Nn();On=["keys","values","entries","length"]});function vn(t){return t.startsWith("__operator_")&&t.endsWith("__")}function In(t){return t.slice(11,-2)}function Rn(t,e,n){let r=eo[e];if(!r)throw Error(`Unknown operator: ${e}`);return r(t,n)}function no(t,e){return Object.fromEntries(t.map((n,r)=>[n,e[r]]))}function Kt(t){return Object.values(t)[0]}function Fn(t){return t!==null&&typeof t==="object"}function Xt(t,e){if(!Fn(t))return;return t[e]}function qt(t,e){return t<0?e+t:t}function ro(t,e){if(!Array.isArray(t))return;let n=qt(e,t.length);return t[n]}function so(t,e,n){if(!Array.isArray(t))return;let r=t.length,o=e!==void 0?qt(e,r):0,s=n!==void 0?qt(n,r):r;return t.slice(o,s)}function oo(t,e){if(!Fn(t))return;switch(e){case"keys":return Object.keys(t);case"values":return Object.values(t);case"entries":return Object.entries(t);case"length":return Array.isArray(t)?t.length:Object.keys(t).length}}function Cn(t,e,n){if(!io(t,e))throw Error(`Method ${e} does not exist on ${typeof t}`);try{return t[e].call(t,...n)}catch(o){let s=co(o);throw Error(`Error executing method ${e}: ${s}`)}}class st{options;constructor(t={}){this.options=t}evaluate(t,e){switch(t.type){case"Root":return t.expression?this.evaluate(t.expression,e):e;case"PropertyAccess":return this.evaluatePropertyAccess(t,e);case"IndexAccess":return ro(t.object?this.evaluate(t.object,e):e,t.index);case"SliceAccess":return so(t.object?this.evaluate(t.object,e):e,t.start,t.end);case"ArraySpread":return t.object?this.evaluate(t.object,e):e;case"MethodCall":return this.evaluateMethodCall(t,e);case"ObjectOperation":return oo(t.object?this.evaluate(t.object,e):e,t.operation);case"Literal":return t.value;case"ArrowFunction":return this.createFunction(t);default:throw Error(`Unknown AST node type: ${t.type}`)}}evaluatePropertyAccess(t,e){let n=t.object?this.evaluate(t.object,e):e,r=Xt(n,t.property);if(this.options.strict&&r===void 0){let o=t.property;throw Error(`Property "${o}" is undefined`)}return r}evaluateArg(t,e){return t.type==="ArrowFunction"?this.createFunction(t):this.evaluate(t,e)}evaluateMethodCall(t,e){let n=t.object?this.evaluate(t.object,e):e;if(vn(t.method)){let s=In(t.method),i=this.evaluate(t.args[0],e);return Rn(n,s,i)}let o=t.args.map((s)=>this.evaluateArg(s,e));return Cn(n,t.method,o)}createFunction(t){return(...e)=>{let n=no(t.params,e);return this.evaluateFunctionBody(t.body,n)}}evaluateFunctionBody(t,e){switch(t.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(t,e);case"MethodCall":return this.evaluateMethodCallInFunction(t,e);case"Literal":return t.value;case"Root":return t.expression?this.evaluateFunctionBody(t.expression,e):e;default:return this.evaluate(t,Kt(e))}}evaluatePropertyAccessInFunction(t,e){if(t.object!==void 0){let s=this.evaluateFunctionBody(t.object,e);return Xt(s,t.property)}if(Object.prototype.hasOwnProperty.call(e,t.property))return e[t.property];let o=Kt(e);return Xt(o,t.property)}evaluateMethodCallInFunction(t,e){let n=t.object?this.evaluateFunctionBody(t.object,e):Kt(e);if(vn(t.method)){let s=In(t.method),i=this.evaluateFunctionBody(t.args[0],e);return Rn(n,s,i)}let o=t.args.map((s)=>this.evaluateFunctionBody(s,e));return Cn(n,t.method,o)}}var eo,io=(t,e)=>{if(t===null||t===void 0)return!1;return typeof t[e]==="function"},co=(t)=>t instanceof Error?t.message:String(t);var Yt=x(()=>{eo={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"%":(t,e)=>t%e,">":(t,e)=>t>e,"<":(t,e)=>t<e,">=":(t,e)=>t>=e,"<=":(t,e)=>t<=e,"==":(t,e)=>t==e,"===":(t,e)=>t===e,"!=":(t,e)=>t!=e,"!==":(t,e)=>t!==e,"&&":(t,e)=>t&&e,"||":(t,e)=>t||e}});var W;var te=x(()=>{W={ERROR:0,WARN:1,INFO:2,DEBUG:3}});var uo,Sc;var kn=x(()=>{te();uo={ERROR:W.ERROR,WARN:W.WARN,INFO:W.INFO,DEBUG:W.DEBUG},Sc=process.env.LOG_LEVEL?uo[process.env.LOG_LEVEL]||W.INFO:W.INFO});function ee(t){return t.replace(hn,"\\$&")}var Pn=x(()=>{yt();yt();Jt();kn();Et();Wt();te()});function it(t){return lo.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function _n(t){return po.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function Bn(){let t=B.filter((s)=>s.type==="array"),e=B.filter((s)=>s.type==="object"),n=B.filter((s)=>s.type==="string"),r=B.filter((s)=>s.type==="any"),o=(s,i)=>{let c=Math.max(...i.map((p)=>p.short.length)),a=Math.max(...i.map((p)=>p.full.length)),u=`
|
|
21
|
-
${s}:
|
|
22
|
-
`,l=i.map((p)=>` ${p.short.padEnd(c+2)} \u2192 ${p.full.padEnd(a+2)} # ${p.description}`).join(`
|
|
23
|
-
`);return u+l};return`
|
|
3
|
+
var no=Object.defineProperty;var ro=(e)=>e;function so(e,t){this[e]=ro.bind(null,t)}var E=(e,t)=>{for(var n in t)no(e,n,{get:t[n],enumerable:!0,configurable:!0,set:so.bind(t,n)})};var g=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ae,h;var ce=g(()=>{Ae=Symbol("empty"),h={PIPE:"pipe",COMPOSE:"compose",HEAD:"head",LAST:"last",TAIL:"tail",TAKE:"take",DROP:"drop",UNIQ:"uniq",FLATTEN:"flatten",REVERSE:"rev",GROUPBY:"groupBy",SORTBY:"sortBy",CHUNK:"chunk",COMPACT:"compact",PICK:"pick",OMIT:"omit",KEYS:"keys",VALUES:"vals",MERGE:"merge",DEEPMERGE:"deepMerge",FROMPAIRS:"fromPairs",TOPAIRS:"toPairs",SUM:"sum",MEAN:"mean",MIN:"min",MAX:"max",LEN:"len",COUNT:"count",ISEMPTY:"isEmpty",ISNIL:"isNil",IDENTITY:"id",PLUCK:"pluck",TYPE:"type",RANGE:"range",HAS:"has",NTH:"nth",CONTAINS:"contains",ADD:"add",PATH:"path",GETPATH:"getpath",SETPATH:"setpath",RECURSE:"recurse",SPLIT:"split",JOIN:"join",STARTSWITH:"startswith",ENDSWITH:"endswith",LTRIMSTR:"ltrimstr",RTRIMSTR:"rtrimstr",TOSTRING:"tostring",TONUMBER:"tonumber",FLOOR:"floor",CEIL:"ceil",ROUND:"round",ABS:"abs",NOT:"not",SELECT:"select",EMPTY:"empty",ERROR:"error",DEBUG:"debug"}});var $n,O,M,C;var ut=g(()=>{$n=/[.*+?^${}()|[\]\\]/g,O={PARAM:"x",METHOD_WITH_ARGS:/\.(\w+)\(([^)]+)\)/g,PROPERTY_ACCESS:/(?<=[(,\s&|><=!+\-*/%])\.([a-zA-Z_]\w*)/g,PROPERTY_AT_START:/^\s*\.([a-zA-Z_]\w*)/,PROPERTY_AFTER_OPERATOR:/[,\s&|><=!+\-*/%]\.([a-zA-Z_]\w*)/,EXPAND_AT_START:/^(\s*)\.([a-zA-Z_]\w*)/,EXPAND_AFTER_OPERATOR:/([,\s&|><=!+\-*/%])\.([a-zA-Z_]\w*)/g,ARROW_FUNC:/\.(\w+)\((\w+)\s*=>\s*([^)]+)\)/g,PARAM_DOT_TEMPLATE:"(?<![a-zA-Z0-9_])PARAM\\."},M=[{short:"hd",full:"head",description:"First element",type:"builtin"},{short:"lst",full:"last",description:"Last element",type:"builtin"},{short:"tl",full:"tail",description:"All but first",type:"builtin"},{short:"tk",full:"take",description:"Take n elements",type:"builtin"},{short:"drp",full:"drop",description:"Drop n elements",type:"builtin"},{short:"unq",full:"uniq",description:"Unique values",type:"builtin"},{short:"fltn",full:"flatten",description:"Flatten nested",type:"builtin"},{short:"grpBy",full:"groupBy",description:"Group by key",type:"builtin"},{short:"srtBy",full:"sortBy",description:"Sort by key",type:"builtin"},{short:"chnk",full:"chunk",description:"Split into chunks",type:"builtin"},{short:"cmpct",full:"compact",description:"Remove falsy",type:"builtin"},{short:"pk",full:"pick",description:"Pick keys",type:"builtin"},{short:"omt",full:"omit",description:"Omit keys",type:"builtin"},{short:"ks",full:"keys",description:"Object keys",type:"builtin"},{short:"mrg",full:"merge",description:"Merge objects",type:"builtin"},{short:"dMrg",full:"deepMerge",description:"Deep merge",type:"builtin"},{short:"frPrs",full:"fromPairs",description:"Pairs to object",type:"builtin"},{short:"toPrs",full:"toPairs",description:"Object to pairs",type:"builtin"},{short:"avg",full:"mean",description:"Average value",type:"builtin"},{short:"cnt",full:"count",description:"Count items",type:"builtin"},{short:"emp",full:"isEmpty",description:"Check if empty",type:"builtin"},{short:"nil",full:"isNil",description:"Check if nil",type:"builtin"},{short:"plk",full:"pluck",description:"Pluck property",type:"builtin"},{short:"typ",full:"type",description:"Get type",type:"builtin"},{short:"rng",full:"range",description:"Generate range",type:"builtin"},{short:"hs",full:"has",description:"Has key",type:"builtin"},{short:"nth",full:"nth",description:"Nth element",type:"builtin"},{short:"ctns",full:"contains",description:"Contains value",type:"builtin"},{short:"add",full:"add",description:"Add/concat",type:"builtin"},{short:"pth",full:"path",description:"All paths",type:"builtin"},{short:"gpth",full:"getpath",description:"Get at path",type:"builtin"},{short:"spth",full:"setpath",description:"Set at path",type:"builtin"},{short:"rec",full:"recurse",description:"Recurse all",type:"builtin"},{short:"spl",full:"split",description:"Split string",type:"builtin"},{short:"jn",full:"join",description:"Join array",type:"builtin"},{short:"stw",full:"startswith",description:"Starts with",type:"builtin"},{short:"edw",full:"endswith",description:"Ends with",type:"builtin"},{short:"ltrm",full:"ltrimstr",description:"Trim prefix",type:"builtin"},{short:"rtrm",full:"rtrimstr",description:"Trim suffix",type:"builtin"},{short:"tstr",full:"tostring",description:"To string",type:"builtin"},{short:"tnum",full:"tonumber",description:"To number",type:"builtin"},{short:"flr",full:"floor",description:"Floor number",type:"builtin"},{short:"cl",full:"ceil",description:"Ceil number",type:"builtin"},{short:"rnd",full:"round",description:"Round number",type:"builtin"},{short:"abs",full:"abs",description:"Absolute value",type:"builtin"},{short:"sel",full:"select",description:"Filter by predicate",type:"builtin"},{short:"dbg",full:"debug",description:"Debug output",type:"builtin"}],C=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".fndIdx",full:".findIndex",description:"Find index of first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".psh",full:".push",description:"Add to end",type:"array"},{short:".pp",full:".pop",description:"Remove from end",type:"array"},{short:".shft",full:".shift",description:"Remove from start",type:"array"},{short:".unshft",full:".unshift",description:"Add to start",type:"array"},{short:".fltMap",full:".flatMap",description:"Map and flatten",type:"array"},{short:".flt1",full:".flat",description:"Flatten array",type:"array"},{short:".incl",full:".includes",description:"Check if includes",type:"array"},{short:".idxOf",full:".indexOf",description:"Find index",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".trmSt",full:".trimStart",description:"Remove leading whitespace",type:"string"},{short:".trmEnd",full:".trimEnd",description:"Remove trailing whitespace",type:"string"},{short:".rpl",full:".replace",description:"Replace text",type:"string"},{short:".rplAll",full:".replaceAll",description:"Replace all occurrences",type:"string"},{short:".pdSt",full:".padStart",description:"Pad start",type:"string"},{short:".pdEnd",full:".padEnd",description:"Pad end",type:"string"},{short:".stsWith",full:".startsWith",description:"Check if starts with",type:"string"},{short:".endsWith",full:".endsWith",description:"Check if ends with",type:"string"},{short:".sbstr",full:".substring",description:"Extract substring",type:"string"},{short:".chr",full:".charAt",description:"Get character at index",type:"string"},{short:".chrCd",full:".charCodeAt",description:"Get character code",type:"string"},{short:".mtch",full:".match",description:"Match pattern",type:"string"},{short:".str",full:".toString",description:"Convert to string",type:"any"},{short:".json",full:".toJSON",description:"Convert to JSON",type:"any"},{short:".val",full:".valueOf",description:"Get primitive value",type:"any"}]});var Ee=(e)=>e.replace($n,"\\$&"),na,ra,io,co,ao,uo,lo=(e)=>{let t=new RegExp(O.METHOD_WITH_ARGS.source,"g");return e.replace(t,(n,r,s)=>{if(s.includes("=>"))return n;if(!(O.PROPERTY_AT_START.test(s)||O.PROPERTY_AFTER_OPERATOR.test(s)))return n;let c=O.PARAM,a=s.replace(O.EXPAND_AT_START,`$1${c}.$2`).replace(O.EXPAND_AFTER_OPERATOR,`$1${c}.$2`);return`.${r}(${c} => ${a})`})},$=(e)=>{let t=io.reduce((r,{regex:s,replacement:o})=>r.replace(s,o),e),n=ao.reduce((r,{regex:s,replacement:o})=>r.replace(s,o),t);return lo(n)},po=(e)=>new RegExp(O.PARAM_DOT_TEMPLATE.replace("PARAM",e),"g"),ho=(e)=>{let t=new RegExp(O.ARROW_FUNC.source,"g");return e.replace(t,(n,r,s,o)=>{let i=po(s),c=o.replace(i,".");if(c===o)return n;return`.${r}(${c})`})},Hn=(e)=>{let t=ho(e),n=co.reduce((r,{regex:s,replacement:o})=>r.replace(s,o),t);return uo.reduce((r,{regex:s,replacement:o})=>r.replace(s,o),n)},Gn=()=>{let e=C.filter((i)=>i.type==="array"),t=C.filter((i)=>i.type==="object"),n=C.filter((i)=>i.type==="string"),r=C.filter((i)=>i.type==="any"),s=(i,c)=>{let a=Math.max(...c.map((f)=>f.short.length)),u=Math.max(...c.map((f)=>f.full.length)),l=`
|
|
4
|
+
${i}:
|
|
5
|
+
`,p=c.map((f)=>` ${f.short.padEnd(a+2)} \u2192 ${f.full.padEnd(u+2)} # ${f.description}`).join(`
|
|
6
|
+
`);return l+p},o=()=>{let i=Math.max(...M.map((l)=>l.short.length)),c=Math.max(...M.map((l)=>l.full.length)),a=`
|
|
7
|
+
Builtin Functions:
|
|
8
|
+
`;return`
|
|
9
|
+
Builtin Functions:
|
|
10
|
+
`+M.map((l)=>` ${l.short}()`.padEnd(i+4)+` \u2192 ${l.full}()`.padEnd(c+4)+` # ${l.description}`).join(`
|
|
11
|
+
`)};return`
|
|
24
12
|
Shorthand Reference:
|
|
25
|
-
${
|
|
26
|
-
${
|
|
27
|
-
${
|
|
28
|
-
${
|
|
13
|
+
${s("Array Methods",e)}
|
|
14
|
+
${s("Object Methods",t)}
|
|
15
|
+
${s("String Methods",n)}
|
|
16
|
+
${s("Universal Methods",r)}
|
|
17
|
+
${o()}
|
|
29
18
|
|
|
30
19
|
Examples:
|
|
31
20
|
echo '[1,2,3]' | 1ls '.mp(x => x * 2)' # Short form
|
|
32
21
|
echo '[1,2,3]' | 1ls '.map(x => x * 2)' # Full form
|
|
22
|
+
echo '[1,2,3]' | 1ls 'hd()' # First element
|
|
23
|
+
echo '[1,2,3]' | 1ls 'sum()' # Sum all
|
|
33
24
|
|
|
34
25
|
1ls --shorten ".map(x => x * 2)" # Returns: .mp(x => x * 2)
|
|
35
26
|
1ls --expand ".mp(x => x * 2)" # Returns: .map(x => x * 2)
|
|
36
|
-
`}
|
|
27
|
+
`};var ae=g(()=>{ut();ut();na=new Map(C.map((e)=>[e.short,e.full])),ra=new Map(C.map((e)=>[e.full,e.short])),io=C.map((e)=>({regex:new RegExp(`${Ee(e.short)}(?![a-zA-Z])`,"g"),replacement:e.full})).sort((e,t)=>t.replacement.length-e.replacement.length),co=C.map((e)=>({regex:new RegExp(`${Ee(e.full)}(?![a-zA-Z])`,"g"),replacement:e.short})).sort((e,t)=>t.regex.source.length-e.regex.source.length),ao=M.map((e)=>({regex:new RegExp(`(?<![a-zA-Z])${Ee(e.short)}\\(`,"g"),replacement:`${e.full}(`})).sort((e,t)=>t.replacement.length-e.replacement.length),uo=M.map((e)=>({regex:new RegExp(`(?<![a-zA-Z])${Ee(e.full)}\\(`,"g"),replacement:`${e.short}(`})).sort((e,t)=>t.regex.source.length-e.regex.source.length)});var go,yo,xo,So,Jn,bo,To,Ao,Eo,No,Oo,wo,Ro,Io,vo,Mo,Co,Po,Fo,pt,ht,L,zn,dt,ko,Lo,_o,Bo,Do,jo,b;var H=g(()=>{go=/^-?\d+$/,yo=/^[+-]?\d+$/,xo=/^-?\d+\.\d+$/,So=/^[+-]?\d+\.\d+$/,Jn=/^-?\d+(\.\d+)?$/,bo=/(\w+)=["']([^"']+)["']/g,To=/^<(\w+)([^>]*?)\/>/,Ao=/^<(\w+)([^>]*)>([\s\S]*)<\/\1>$/,Eo=/<\w+/,No=/<\/\w+>$/,Oo=/^<\?xml[^>]+\?>\s*/,wo=/,(\s*[}\]])/g,Ro=/(['"])?([a-zA-Z_$][a-zA-Z0-9_$]*)\1?\s*:/g,Io=/\/\/|\/\*|,\s*[}\]]/,vo=/^\[[\w.\s]+\]$/m,Mo=/^\[[\w.]+\]$/m,Co=/^\w+\s*=\s*"[^"]*"$/m,Po=/=\s*["[{]/m,Fo=/^\w+\s*=\s*.+$/m,pt={INTEGER:go,FLOAT:xo},ht={INTEGER:yo,FLOAT:So},L={NUMBER:Jn,ATTRIBUTES:bo,SELF_CLOSING:To,OPEN_TAG:Ao,NESTED_TAGS:Eo,COMPLETE_TAGS:No,XML_DECLARATION:Oo},zn={NUMBER:Jn},dt={TRAILING_COMMA:wo,UNQUOTED_KEY:Ro},ko=/^\s*export\s+(const|let|var|function|class|default|type|interface|enum)/m,Lo=/:\s*(string|number|boolean|any|unknown|void|never|object|Array|Promise)/,_o=/^\s*interface\s+\w+/m,Bo=/^\s*type\s+\w+\s*=/m,Do=/^[A-Z_][A-Z0-9_]*\s*=/m,jo=/^\{.*\}\s*$/m,b={JSON5_FEATURES:Io,SECTION_HEADER:vo,TOML_SECTION:Mo,TOML_QUOTED_VALUES:Co,TOML_SYNTAX:Po,INI_SYNTAX:Fo,JS_EXPORT:ko,TS_TYPE_ANNOTATION:Lo,TS_INTERFACE:_o,TS_TYPE_ALIAS:Bo,ENV_FEATURES:Do,NDJSON_FEATURES:jo}});var tr={};E(tr,{stripJSON5Comments:()=>Zn,parseJSON5:()=>Uo,normalizeJSON5:()=>er,isQuoteChar:()=>Qn,handleStringChar:()=>Xn,handleNormalChar:()=>qn,findMultiLineCommentEnd:()=>Yn,findCommentEnd:()=>Kn});function Qn(e){return e==='"'||e==="'"}function Kn(e,t,n){let s=e.slice(t).findIndex((i)=>i===n);return s===-1?e.length-t:s}function Yn(e,t){let n=2,r=e.length-t;while(n<r){let s=e[t+n],o=e[t+n+1];if(s==="*"&&o==="/")return n+1;n++}return n}function Xn(e,t,n){if(e.result.push(t),t==="\\"&&n)return e.result.push(n),{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:1};if(t===e.delimiter)return{result:e.result,inString:!1,delimiter:"",skip:0};return e}function qn(e,t,n,r,s){if(Qn(t))return e.result.push(t),{result:e.result,inString:!0,delimiter:t,skip:0};if(t==="/"&&n==="/"){let a=Kn(r,s,`
|
|
28
|
+
`);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}if(t==="/"&&n==="*"){let a=Yn(r,s);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}return e.result.push(t),e}function Zn(e){let t=e.split("");return t.reduce((n,r,s)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let i=t[s+1];return n.inString?Xn(n,r,i):qn(n,r,i,t,s)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function er(e){let t=Zn(e);return t=t.replace(dt.TRAILING_COMMA,"$1"),t=t.replace(dt.UNQUOTED_KEY,'"$2":'),t=t.replace(/'/g,'"'),t}function Uo(e){let t=er(e);return JSON.parse(t)}var nr=g(()=>{H()});var Vo,$o,Ho,Go=(e)=>Vo.includes(e),Wo=(e)=>$o.includes(e),Jo=(e)=>Ho.includes(e),Z=(e)=>{if(Go(e))return!0;if(Wo(e))return!1;return},ee=(e)=>{if(Jo(e))return null;return},Ne=(e)=>{if(e==="")return;let t=Number(e);return isNaN(t)?void 0:t};var Oe=g(()=>{Vo=["true","yes","on"],$o=["false","no","off"],Ho=["null","~",""]});var we=(e)=>e.length-e.trimStart().length,zo=(e)=>(e.match(/["']/g)||[]).length,Qo=(e,t)=>{let n=e.substring(0,t);return zo(n)%2===0},ue=(e)=>{let t=e.indexOf("#");if(t<0)return e;return Qo(e,t)?e.substring(0,t):e},mt=(e)=>["|",">","|+",">-","|-",">+"].includes(e),ft=(e)=>e==="---"||e==="...",gt=(e)=>e.startsWith("- ")||e==="-",rr=(e)=>e==="-"?"":e.substring(2).trim(),sr=(e)=>{let t=e.indexOf(":");if(t<=0)return!1;let n=e.substring(0,t),r=!n.includes(" "),s=n.startsWith('"')||n.startsWith("'");return r||s},yt=(e)=>{let t=e.indexOf(":");if(t<=0)return null;return{key:e.substring(0,t).trim(),value:e.substring(t+1).trim()}},or=(e)=>{if(!e.startsWith("&"))return{anchorName:null,cleanValue:e};let n=e.indexOf(" ");return n>0?{anchorName:e.substring(1,n),cleanValue:e.substring(n+1)}:{anchorName:e.substring(1),cleanValue:""}},ir=(e)=>{if(!e.includes(" &"))return{cleanKey:e,anchorName:null};let[n,r]=e.split(" &");return{cleanKey:n,anchorName:r}},Ko=(e)=>{if(!e.startsWith("!!"))return{tag:null,content:e};let n=e.indexOf(" ");if(!(n>0))return{tag:null,content:e};return{tag:e.substring(2,n),content:e.substring(n+1)}},Yo=(e)=>{let t=e.startsWith('"')&&e.endsWith('"'),n=e.startsWith("'")&&e.endsWith("'");return t||n?e.slice(1,-1):null},Xo=(e)=>{if(!(e.startsWith("[")&&e.endsWith("]")))return null;return e.slice(1,-1).split(",").map((n)=>D(n.trim()))},qo=(e)=>{if(!(e.startsWith("{")&&e.endsWith("}")))return null;return e.slice(1,-1).split(",").map((n)=>n.split(":").map((r)=>r.trim())).filter(([n,r])=>n&&r).reduce((n,[r,s])=>({...n,[r]:D(s)}),{})},D=(e)=>{let{tag:t,content:n}=Ko(e);if(t==="str")return n;let r=Yo(n);if(r!==null)return r;let s=Z(n);if(s!==void 0)return s;let o=ee(n);if(o!==void 0)return o;if(pt.INTEGER.test(n))return parseInt(n,10);if(pt.FLOAT.test(n))return parseFloat(n);let a=Xo(n);if(a!==null)return a;let u=qo(n);if(u!==null)return u;return n},Re=(e,t)=>Array.from({length:t},(n,r)=>t-1-r).reduce((n,r)=>{if(n!==null)return n;let o=ue(e[r]).trim();if(!o||o.startsWith("-")||!o.includes(":"))return null;let c=yt(o);if(!c)return null;return!c.value||mt(c.value)?c.key:null},null),cr=(e,t,n)=>{let r=e.slice(t).reduce((o,i,c)=>{if(o.done)return o;if(!i.trim())return{...o,contentLines:[...o.contentLines,""],endIdx:t+c};if(we(i)<=n)return{...o,done:!0};let l=i.substring(n+2);return{...o,contentLines:[...o.contentLines,l],endIdx:t+c}},{contentLines:[],endIdx:t-1,done:!1});return{contentLines:r.contentLines.reduceRight((o,i)=>o.length===0&&i===""?o:[i,...o],[]),endIdx:r.endIdx}},ar=(e,t)=>t==="|"?e.join(`
|
|
29
|
+
`):e.join(" ").replace(/\s+/g," ").trim();var xt=g(()=>{H();Oe()});var pr={};E(pr,{parseYAMLValue:()=>D,parseYAML:()=>ci,findPreviousKey:()=>Re});var Zo=(e,t)=>{let n=e.substring(1);return t[n]!==void 0?t[n]:e},ei=(e,t)=>{let n=e.substring(1),r=t[n];return typeof r==="object"&&r!==null&&!Array.isArray(r)?r:null},St=(e,t)=>{if(typeof e==="string"&&e.startsWith("*"))return Zo(e,t);if(Array.isArray(e))return e.map((s)=>St(s,t));if(!(typeof e==="object"&&e!==null))return e;return Object.entries(e).reduce((s,[o,i])=>{let c=o==="<<",a=typeof i==="string"&&i.startsWith("*");if(!(c&&a))return{...s,[o]:St(i,t)};let l=ei(i,t);return l?{...s,...l}:s},{})},ti=(e)=>e.find((t)=>{let n=ue(t).trim();return n&&!ft(n)}),ni=(e)=>{return ti(e)?.trim().startsWith("- ")?[]:{}},Ie=(e)=>e[e.length-1],lr=(e,t)=>{while(e.length>1&&t(Ie(e)))e.pop()},ur=(e,t,n,r,s)=>{if(sr(e)){let c=e.indexOf(":"),a=e.substring(0,c).trim(),u=e.substring(c+1).trim(),{cleanKey:l,anchorName:p}=ir(a),f=u?D(u):null,x={[l]:f};if(t.push(x),p)s[p]=x;n.push({container:x,indent:r+2});return}if(e){t.push(D(e));return}let i={};t.push(i),n.push({container:i,indent:r+2})},ri=(e,t,n,r,s,o)=>{let i=rr(e);lr(s,(l)=>l.indent>t||l.indent>=t&&!Array.isArray(l.container));let c=Ie(s);if(Array.isArray(c.container)&&(c.indent===t||c.indent===-1&&t===0)){if(c.indent===-1)c.indent=t;ur(i,c.container,s,t,o);return}let u=[];if(c.pendingKey)c.container[c.pendingKey]=u,c.pendingKey=void 0;else if(!Array.isArray(c.container)){let l=Re(n,r);if(l)c.container[l]=u}s.push({container:u,indent:t}),ur(i,u,s,t,o)},si=(e,t,n,r,s,o,i,c)=>{let a=n.startsWith("|")?"|":">",{contentLines:u,endIdx:l}=cr(r,s+1,o),p=ar(u,a);if(e[t]=p,c)i[c]=p;return l},oi=(e,t,n,r,s,o,i,c)=>{let a=Ie(o),u=r+1,l=u<n.length,p=l?ue(n[u]):"",f=p.trim(),x=l?we(p):-1,q=gt(f)&&x>s,V=l&&x>s&&f;if(q){if(a.pendingKey=t,c)i[c]={};return}if(V){let B={};if(e[t]=B,c)i[c]=B;o.push({container:B,indent:x});return}if(e[t]=null,c)i[c]=null},ii=(e,t,n,r,s,o)=>{let i=yt(e);if(!i)return r;let{anchorName:c,cleanValue:a}=or(i.value);lr(s,(p)=>p.indent>t||p.indent===t&&Array.isArray(p.container));let u=Ie(s).container;if(Array.isArray(u))return r;if(mt(a))return si(u,i.key,a,n,r,t,o,c);if(a){let p=D(a);if(u[i.key]=p,c)o[c]=p;return r}return oi(u,i.key,n,r,t,s,o,c),r},ci=(e)=>{let t=e.trim().split(`
|
|
30
|
+
`),n={},r=ni(t),s=[{container:r,indent:-1}],o=0;while(o<t.length){let i=ue(t[o]),c=i.trim();if(!c||ft(c)){o++;continue}let u=we(i);if(gt(c)){ri(c,u,t,o,s,n),o++;continue}o=ii(c,u,t,o,s,n)+1}return St(r,n)};var hr=g(()=>{xt();xt()});var dr={};E(dr,{parseTOMLValue:()=>ve,parseTOML:()=>ai});function ve(e){if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\"/g,'"');if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;if(ht.INTEGER.test(e))return parseInt(e,10);if(ht.FLOAT.test(e))return parseFloat(e);if(e.startsWith("[")&&e.endsWith("]"))return e.slice(1,-1).split(",").map((a)=>ve(a.trim()));if(e.startsWith("{")&&e.endsWith("}")){let c={};return e.slice(1,-1).split(",").forEach((u)=>{let[l,p]=u.split("=").map((f)=>f.trim());if(l&&p)c[l]=ve(p)}),c}return e}function ai(e){let t=e.trim().split(`
|
|
31
|
+
`),n={},r=n,s=[];return t.forEach((o)=>{let i=o,c=i.indexOf("#");if(c>=0){let f=i.substring(0,c);if((f.match(/["']/g)||[]).length%2===0)i=f}let a=i.trim();if(!a)return;if(a.startsWith("[")&&a.endsWith("]")){let f=a.slice(1,-1).split(".");r=n,s=[],f.forEach((x)=>{if(!r[x])r[x]={};r=r[x],s.push(x)});return}let l=a.indexOf("=");if(l>0){let f=a.substring(0,l).trim(),x=a.substring(l+1).trim();r[f]=ve(x)}}),n}var mr=g(()=>{H()});var gr={};E(gr,{parseXMLValue:()=>le,parseXMLElement:()=>bt,parseXMLChildren:()=>fr,parseXMLAttributes:()=>Me,parseXML:()=>pi});function le(e){let t=e.trim();if(t==="true")return!0;if(t==="false")return!1;if(L.NUMBER.test(t))return parseFloat(t);return t}function Me(e){return Array.from(e.matchAll(L.ATTRIBUTES)).reduce((n,r)=>{let[,s,o]=r;return n[s]=le(o),n},{})}function bt(e){let t=e.trim(),n=t.match(L.SELF_CLOSING);if(n){let[,p,f]=n;if(f.trim().length>0)return{[p]:{_attributes:Me(f)}};return{[p]:null}}let r=t.match(L.OPEN_TAG);if(!r)return le(t);let[,s,o,i]=r,c=i.trim();if(!L.NESTED_TAGS.test(c)){if(o.trim().length>0)return{[s]:{_attributes:Me(o),_text:le(c)}};return{[s]:le(c)}}let u=fr(c);if(o.trim().length>0)return{[s]:{_attributes:Me(o),...u}};return{[s]:u}}function ui(e){let t=e.split(""),n=t.reduce((o,i,c)=>{if(o.skip>0)return{elements:o.elements,buffer:o.buffer,depth:o.depth,skip:o.skip-1};if(i==="<"){let U=t[c+1]==="/",V=e.slice(c).match(/^<[^>]+\/>/);if(U)return o.buffer.push(i),{elements:o.elements,buffer:o.buffer,depth:o.depth-1,skip:0};if(V){let B=V[0];if(B.split("").forEach((ct)=>o.buffer.push(ct)),o.depth===0){let ct=o.buffer.join("").trim();o.elements.push(ct),o.buffer.length=0}return{elements:o.elements,buffer:o.buffer,depth:o.depth,skip:B.length-1}}return o.buffer.push(i),{elements:o.elements,buffer:o.buffer,depth:o.depth+1,skip:0}}o.buffer.push(i);let l=o.depth===0,p=o.buffer.join("").trim(),f=p.length>0,x=!i.match(/\s/);if(l&&f&&x){if(p.match(L.COMPLETE_TAGS))o.elements.push(p),o.buffer.length=0}return{elements:o.elements,buffer:o.buffer,depth:o.depth,skip:0}},{elements:[],buffer:[],depth:0,skip:0}),r=n.buffer.join("").trim();return r.length>0?[...n.elements,r]:n.elements}function li(e,t,n){let r=e[t];if(r===void 0){e[t]=n;return}if(Array.isArray(r)){r.push(n);return}e[t]=[r,n]}function fr(e){return ui(e).reduce((n,r)=>{let s=bt(r);if(typeof s==="object"&&s!==null)Object.entries(s).forEach(([i,c])=>{li(n,i,c)});return n},{})}function pi(e){let t=e.trim(),n=t.match(L.XML_DECLARATION),r=n?t.slice(n[0].length):t;return bt(r)}var yr=g(()=>{H()});var br={};E(br,{stripINIComments:()=>xr,processINILine:()=>Sr,parseINIValue:()=>Tt,parseINI:()=>hi});function Tt(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(zn.NUMBER.test(t))return parseFloat(t);return t}function xr(e){let t=e.indexOf(";"),n=e.indexOf("#");if(!(t>=0||n>=0))return e;let s=t>=0&&n>=0?Math.min(t,n):Math.max(t,n);return e.substring(0,s)}function Sr(e,t){let r=xr(t).trim();if(!r)return e;if(r.startsWith("[")&&r.endsWith("]")){let a=r.slice(1,-1).trim();if(!e.result[a])e.result[a]={};return{result:e.result,currentSection:a}}let i=r.indexOf("=");if(i>0){let a=r.substring(0,i).trim(),u=r.substring(i+1).trim();if(e.currentSection.length>0){let p=e.result[e.currentSection];p[a]=Tt(u)}else e.result[a]=Tt(u)}return e}function hi(e){return e.trim().split(`
|
|
32
|
+
`).reduce((r,s)=>Sr(r,s),{result:{},currentSection:""}).result}var Tr=g(()=>{H()});var Et={};E(Et,{parseTSV:()=>di,parseCSVValue:()=>Ar,parseCSVLine:()=>At,parseCSV:()=>Er});function At(e,t){let n=[],r="",s=!1,o=e.split("");return o.forEach((i,c)=>{let a=o[c+1];if(i==='"'){if(s&&a==='"'){r+='"',o.splice(c+1,1);return}s=!s;return}if(i===t&&!s){n.push(r),r="";return}r+=i}),n.push(r),n.map((i)=>i.trim())}function Ar(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"'))return t.slice(1,-1).replace(/""/g,'"');let r=Ne(t);if(r!==void 0)return r;let s=t.toLowerCase(),o=Z(s);if(o!==void 0)return o;let i=ee(s);if(i!==void 0)return i;return t}function Er(e,t=","){let n=e.trim().split(`
|
|
33
|
+
`);if(n.length===0)return[];let r=At(n[0],t);if(n.length===1)return[];return n.slice(1).reduce((s,o)=>{let i=At(o,t);if(i.length===0)return s;let c=Object.fromEntries(r.map((a,u)=>[a,Ar(i[u]||"")]));return[...s,c]},[])}function di(e){return Er(e,"\t")}var Nt=g(()=>{Oe()});var Nr={};E(Nr,{parseProtobufJSON:()=>fi,parseProtobuf:()=>mi});function mi(e){throw Error("Protobuf parsing requires a .proto schema file. Please convert your protobuf to JSON first using protoc: protoc --decode_raw < file.pb | 1ls")}function fi(e){return JSON.parse(e)}var Mr={};E(Mr,{stripJSComments:()=>Ce,parseJavaScript:()=>gi,isQuoteChar:()=>Or,handleStringChar:()=>Ir,handleNormalChar:()=>vr,findMultiLineCommentEnd:()=>Rr,findCommentEnd:()=>wr});function Or(e){return e==='"'||e==="'"||e==="`"}function wr(e,t,n){let s=e.slice(t).findIndex((i)=>i===n);return s===-1?e.length-t:s}function Rr(e,t){let n=2,r=e.length-t;while(n<r){let s=e[t+n],o=e[t+n+1];if(s==="*"&&o==="/")return n+1;n++}return n}function Ir(e,t,n){if(e.result.push(t),t==="\\"&&n)return e.result.push(n),{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:1};if(t===e.delimiter)return{result:e.result,inString:!1,delimiter:"",skip:0};return e}function vr(e,t,n,r,s){if(Or(t))return e.result.push(t),{result:e.result,inString:!0,delimiter:t,skip:0};if(t==="/"&&n==="/"){let a=wr(r,s,`
|
|
34
|
+
`);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}if(t==="/"&&n==="*"){let a=Rr(r,s);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}return e.result.push(t),e}function Ce(e){let t=e.split("");return t.reduce((n,r,s)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let i=t[s+1];return n.inString?Ir(n,r,i):vr(n,r,i,t,s)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function gi(e){let t=Ce(e),n=t.match(/export\s+default\s+([\s\S]+)/),s=(n?n[1]:t).trim().replace(/;$/,"");return Function(`return (${s})`)()}var Cr={};E(Cr,{parseTypeScript:()=>xi});function yi(){if(Pe!==null)return Pe;return Pe=new Bun.Transpiler({loader:"ts"}),Pe}function xi(e){let t=Ce(e),r=yi().transformSync(t),s=r.match(/export\s+default\s+(.+?)(?:;|\n|$)/),o=s?s[1]:null;if(o===null)return null;let c=r.indexOf("export default"),u=`${r.substring(0,c)}
|
|
35
|
+
return (${o})`;return Function(u)()}var Pe=null;var Pr=()=>{};var kr={};E(kr,{parseENVValue:()=>Fr,parseENV:()=>Ti});function Fr(e){let t=e.trim(),n=t.startsWith('"')&&t.endsWith('"'),r=t.startsWith("'")&&t.endsWith("'");if(n||r)return t.slice(1,-1);let o=Z(t);if(o!==void 0)return o;let i=ee(t);if(i!==void 0)return i;let c=Ne(t);if(c!==void 0)return c;return t}function Si(e){let t=e.indexOf("#");if(!(t>=0))return e;let r=e.substring(0,t);if(r.match(/["'].*["']/)!==null){if((r.match(/["']/g)||[]).length%2!==0)return e}return r}function bi(e,t){let r=Si(t).trim();if(!r)return e;let i=r.startsWith("export ")?r.substring(7).trim():r,c=i.indexOf("=");if(c>0){let u=i.substring(0,c).trim(),l=i.substring(c+1).trim();e.result[u]=Fr(l)}return e}function Ti(e){return e.trim().split(`
|
|
36
|
+
`).reduce((r,s)=>bi(r,s),{result:{}}).result}var Lr=g(()=>{Oe()});var _r={};E(_r,{parseNDJSON:()=>Ai});function Ai(e){return e.trim().split(`
|
|
37
|
+
`).map((n)=>n.trim()).filter((n)=>n.length>0).map((n)=>{try{return JSON.parse(n)}catch{return n}})}var ke=()=>{};var Zr,es="+-*/%<>!&|=",ts;var ns=g(()=>{ke();Zr={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},ts=[" ","\t",`
|
|
38
|
+
`,"\r"]});function P(e,t,n){return{type:e,value:t,position:n}}class G{input;position=0;current;constructor(e){this.input=e,this.current=this.input[0]||""}tokenize(){let e=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let t=this.nextToken();if(t)e.push(t)}return e.push(P("EOF","",this.position)),e}nextToken(){let e=this.position;if(this.current==="."&&this.peek()===".")return this.advance(),this.advance(),P("DOUBLE_DOT","..",e);if(this.current==="?"&&this.peek()==="?")return this.advance(),this.advance(),P("DOUBLE_QUESTION","??",e);if(this.current==="?")return this.advance(),P("QUESTION","?",e);let s=Zr[this.current];if(s){let f=this.current;return this.advance(),P(s,f,e)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),P("ARROW","=>",e);if(this.current==='"'||this.current==="'")return this.readString();let c=this.isDigit(this.current),a=this.current==="-"&&this.isDigit(this.peek());if(c||a)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let e=this.position,t=this.current,n=[];this.advance();while(this.current!==t&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===t)this.advance();return P("STRING",n.join(""),e)}readNumber(){let e=this.position,t="";if(this.current==="-")t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance()}return P("NUMBER",t,e)}readIdentifier(){let e=this.position,t="";while(this.isIdentifierChar(this.current))t+=this.current,this.advance();return P("IDENTIFIER",t,e)}readOperator(){let e=this.position,t="";while(this.isOperator(this.current))t+=this.current,this.advance();return P("OPERATOR",t,e)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(e){return ts.includes(e)}isDigit(e){return e>="0"&&e<="9"}isIdentifierStart(e){let t=e>="a"&&e<="z",n=e>="A"&&e<="Z";return t||n||e==="_"||e==="$"}isIdentifierChar(e){return this.isIdentifierStart(e)||this.isDigit(e)}isOperator(e){return es.includes(e)}}var Le=g(()=>{ke();ns()});var he;var _e=g(()=>{he=["keys","values","entries","length"]});var F=(e)=>({type:"Literal",value:e}),kt=(e)=>{if(e==="true")return F(!0);if(e==="false")return F(!1);if(e==="null")return F(null);return},w=(e,t)=>`${t} at position ${e.position} (got ${e.type}: "${e.value}")`,_=(e,t)=>({type:"PropertyAccess",property:e,object:t}),Lt=(e,t)=>({type:"IndexAccess",index:e,object:t}),_t=(e,t,n)=>({type:"SliceAccess",start:e,end:t,object:n}),Be=(e,t,n)=>({type:"MethodCall",method:e,args:t,object:n}),Bt=(e,t)=>({type:"ObjectOperation",operation:e,object:t}),Dt=(e)=>({type:"ArraySpread",object:e}),jt=(e,t)=>({type:"ArrowFunction",params:e,body:t}),W=(e)=>({type:"Root",expression:e}),De=(e)=>({type:"RecursiveDescent",object:e}),Ut=(e,t)=>({type:"OptionalAccess",expression:e,object:t}),Vt=(e,t)=>({type:"NullCoalescing",left:e,right:t}),$t=(e)=>he.includes(e);var Ht=g(()=>{_e()});class J{tokens;position=0;current;constructor(e){this.tokens=e,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return W();let t=this.parseExpression();return W(t)}parseExpression(){return this.parsePrimary()}parsePrimary(){let e=this.parsePrimaryNode();return this.parsePostfix(e)}parsePrimaryNode(){let e=this.current.type;if(e==="DOUBLE_DOT")return this.advance(),De();if(e==="DOT"){if(this.advance(),this.current.type==="EOF")return W();return this.parseAccessChain()}if(e==="LEFT_BRACKET")return this.parseArrayAccess();if(e==="IDENTIFIER")return this.parseIdentifierOrFunction();if(e==="STRING"){let s=this.current.value;return this.advance(),F(s)}if(e==="NUMBER"){let s=Number(this.current.value);return this.advance(),F(s)}if(e==="LEFT_PAREN"){let s=this.parseFunctionParams();return this.parseArrowFunction(s)}throw Error(w(this.current,"Unexpected token"))}parseAccessChain(e){let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;return this.advance(),_(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(w(this.current,"Expected property name after dot"))}parseBracketAccess(e){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),Dt(e);if(this.current.type==="STRING"){let c=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),_(c,e)}let r=this.current.type==="NUMBER",s=this.current.type==="OPERATOR"&&this.current.value==="-",o=this.current.type==="COLON";if(r||s||o)return this.parseNumericIndexOrSlice(e);throw Error(w(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(e){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,e);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,e);return this.expect("RIGHT_BRACKET"),Lt(n,e)}parseSliceFromColon(e,t){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",s=n||r,o=s?this.parseNumber():void 0;if(s)this.advance();return this.expect("RIGHT_BRACKET"),_t(e,o,t)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(e){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(w(this.current,"Expected operation name after {"));let n=this.current.value;if(!$t(n)){let r=he.join(", ");throw Error(w(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),Bt(n,e)}parseIdentifierOrFunction(){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);let n=kt(e);if(n)return n;return _(e)}parseArrowFunction(e){this.expect("ARROW");let t=this.parseFunctionBody();return jt(e,t)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),t}return this.parseBinaryExpression()}parseBinaryExpression(){let e=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let t=this.current.value;this.advance();let n=this.parseFunctionTerm();e=Be(`__operator_${t}__`,[n],e)}return e}parseFunctionTerm(){let e=this.current.type;if(e==="IDENTIFIER")return this.parseIdentifierChain();if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),F(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),F(t)}if(e==="LEFT_PAREN"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),t}throw Error(w(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let e=this.current.value;this.advance();let t=kt(e);if(t)return t;let n=_(e),r=()=>this.current.type==="DOT",s=()=>this.current.type==="IDENTIFIER",o=()=>this.current.type==="LEFT_PAREN";while(r()||o()){if(o()){let c=n,a=c.property,u=c.object;n=this.parseMethodCall(u?u:W(),a);continue}if(this.advance(),!s())break;let i=this.current.value;this.advance(),n=_(i,n)}return n}parseMethodCall(e,t){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),Be(t,n,e)}parseMethodArguments(){let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let t=this.parseMethodArgument();if(e.push(t),this.current.type==="COMMA")this.advance()}return e}parseMethodArgument(){let e=this.current.type;if(e==="LEFT_PAREN"){let t=this.parseFunctionParams();return this.parseArrowFunction(t)}if(e==="IDENTIFIER"){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);return _(t)}if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),F(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),F(t)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")e.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),e}parsePostfix(e){let t=e;while(!0){let n=this.current.type;if(n==="DOUBLE_DOT"){this.advance(),t=De(t);continue}if(n==="DOT"){t=this.parsePostfixDot(t);continue}if(n==="LEFT_BRACKET"){t=this.parseBracketAccess(t);continue}if(n==="QUESTION"){this.advance(),t=Ut(t);continue}if(n==="DOUBLE_QUESTION"){this.advance();let u=this.parsePrimary();t=Vt(t,u);continue}if(n==="LEFT_PAREN"){if(t.type==="PropertyAccess"&&!t.object){let p=t.property;t=this.parseMethodCall(W(),p);continue}}break}return t}parsePostfixDot(e){this.advance();let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(e,n);return _(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(w(this.current,"Expected property name after dot"))}parseNumber(){let e=this.current.value==="-";if(e)this.advance();if(this.current.type!=="NUMBER")throw Error(w(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return e?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(e){if(this.current.type!==e)throw Error(w(this.current,`Expected ${e} but got ${this.current.type}`));this.advance()}}var je=g(()=>{ke();_e();Ht();Ht();_e()});var y=(e)=>Array.isArray(e),S=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),de=(e)=>e===null||e===void 0,N=(e)=>typeof e==="string",ne=(e)=>typeof e==="number",rs=(e)=>{if(e===null)return"null";if(y(e))return"array";return typeof e},Gt=(e,t)=>Object.keys(t).reduce((n,r)=>{let s=e[r],o=t[r],i=S(s)&&S(o);return{...n,[r]:i?Gt(s,o):o}},{...e}),Ue=(e,t)=>{if(e===t)return!0;if(y(e)&&y(t))return t.every((s)=>e.some((o)=>Ue(o,s)));if(S(e)&&S(t)){let s=e;return Object.entries(t).every(([o,i])=>(o in s)&&Ue(s[o],i))}return!1},ss=(e,t)=>t.reduce((n,r)=>{if(de(n))return;if(y(n)&&typeof r==="number")return n[r];if(S(n)&&typeof r==="string")return n[r];return},e),Wt=(e,t,n)=>{if(t.length===0)return n;let[r,...s]=t,o=s.length===0?n:Wt(y(e)&&typeof r==="number"?e[r]:S(e)&&typeof r==="string"?e[r]:void 0,s,n);if(y(e)&&typeof r==="number")return e.map((i,c)=>c===r?o:i);if(S(e)&&typeof r==="string")return{...e,[r]:o};if(typeof r==="number")return Array.from({length:r+1},(i,c)=>c===r?o:void 0);return{[r]:o}},Ve=(e)=>{let t=[e],n=y(e)?e.flatMap(Ve):S(e)?Object.values(e).flatMap(Ve):[];return[...t,...n]},$e=(e,t)=>{let n=[t];if(y(e)){let r=e.flatMap((s,o)=>$e(s,[...t,o]));return[...n,...r]}if(S(e)){let r=Object.keys(e).flatMap((s)=>$e(e[s],[...t,s]));return[...n,...r]}return n};var os,is=(e)=>(e in os),cs=(e,t,n)=>{let r=os[e];if(!r)throw Error(`Unknown builtin: ${e}`);return r(t,n)};var as=g(()=>{ce();ce();os={[h.HEAD]:(e)=>y(e)?e[0]:void 0,[h.LAST]:(e)=>y(e)?e[e.length-1]:void 0,[h.TAIL]:(e)=>y(e)?e.slice(1):[],[h.TAKE]:(e,[t])=>y(e)?e.slice(0,t):[],[h.DROP]:(e,[t])=>y(e)?e.slice(t):[],[h.UNIQ]:(e)=>y(e)?[...new Set(e)]:[],[h.FLATTEN]:(e)=>y(e)?e.flat(1/0):[],[h.REVERSE]:(e)=>y(e)?[...e].reverse():[],[h.GROUPBY]:(e,[t])=>{if(!y(e))return{};let n=t;return e.reduce((r,s)=>{let o=String(n(s)),i=r[o]||[];return{...r,[o]:[...i,s]}},{})},[h.SORTBY]:(e,[t])=>{if(!y(e))return[];let n=t;return[...e].sort((r,s)=>{let o=n(r),i=n(s),c=o<i,a=o>i;if(c)return-1;if(a)return 1;return 0})},[h.CHUNK]:(e,[t])=>{if(!y(e))return[];let n=t,r=Math.ceil(e.length/n);return Array.from({length:r},(s,o)=>e.slice(o*n,(o+1)*n))},[h.COMPACT]:(e)=>y(e)?e.filter(Boolean):[],[h.PLUCK]:(e,[t])=>{if(!y(e))return[];return e.map((n)=>S(n)?n[t]:void 0)},[h.PICK]:(e,t)=>{if(!S(e))return{};return(t.length===1&&y(t[0])?t[0]:t).reduce((s,o)=>{let i=o;return i in e?{...s,[i]:e[i]}:s},{})},[h.OMIT]:(e,t)=>{if(!S(e))return{};let r=t.length===1&&y(t[0])?t[0]:t,s=new Set(r);return Object.fromEntries(Object.entries(e).filter(([o])=>!s.has(o)))},[h.KEYS]:(e)=>S(e)?Object.keys(e):[],[h.VALUES]:(e)=>S(e)?Object.values(e):[],[h.MERGE]:(e,t)=>{if(!S(e))return{};return t.reduce((n,r)=>{return{...n,...r}},e)},[h.DEEPMERGE]:(e,t)=>{if(!S(e))return{};return t.reduce((n,r)=>{return S(r)?Gt(n,r):n},e)},[h.FROMPAIRS]:(e)=>{if(!y(e))return{};return Object.fromEntries(e)},[h.TOPAIRS]:(e)=>S(e)?Object.entries(e):[],[h.SUM]:(e)=>{if(!y(e))return 0;return e.reduce((t,n)=>t+n,0)},[h.MEAN]:(e)=>{if(!y(e)||e.length===0)return 0;return e.reduce((r,s)=>r+s,0)/e.length},[h.MIN]:(e)=>{if(!y(e))return;return Math.min(...e)},[h.MAX]:(e)=>{if(!y(e))return;return Math.max(...e)},[h.LEN]:(e)=>{if(y(e))return e.length;if(S(e))return Object.keys(e).length;if(N(e))return e.length;return 0},[h.COUNT]:(e)=>{if(y(e))return e.length;if(S(e))return Object.keys(e).length;if(N(e))return e.length;return 0},[h.ISEMPTY]:(e)=>{if(de(e))return!0;if(y(e))return e.length===0;if(S(e))return Object.keys(e).length===0;if(N(e))return e.length===0;return!1},[h.ISNIL]:(e)=>de(e),[h.IDENTITY]:(e)=>e,[h.TYPE]:(e)=>rs(e),[h.RANGE]:(e,t)=>{let[n,r,s=1]=t,o=r===void 0,i=o?0:n,c=o?n:r,a=s,u=Math.max(0,Math.ceil((c-i)/a));return Array.from({length:u},(l,p)=>i+p*a)},[h.HAS]:(e,[t])=>{if(S(e))return t in e;if(y(e)){let n=t;return n>=0&&n<e.length}return!1},[h.NTH]:(e,[t])=>{if(!y(e))return;let n=t,s=n<0?e.length+n:n;return e[s]},[h.CONTAINS]:(e,[t])=>Ue(e,t),[h.ADD]:(e)=>{if(!y(e))return e;if(e.length===0)return null;let n=N(e[0]),r=y(e[0]);if(n)return e.join("");if(r)return e.flat();return e.reduce((s,o)=>s+o,0)},[h.PATH]:(e)=>$e(e,[]),[h.GETPATH]:(e,[t])=>ss(e,t),[h.SETPATH]:(e,[t,n])=>Wt(e,t,n),[h.RECURSE]:(e)=>Ve(e),[h.SPLIT]:(e,[t])=>{if(!N(e))return[];let n=t;return e.split(n)},[h.JOIN]:(e,[t])=>{if(!y(e))return"";let n=t;return e.join(n)},[h.STARTSWITH]:(e,[t])=>{if(!N(e))return!1;let n=t;return e.startsWith(n)},[h.ENDSWITH]:(e,[t])=>{if(!N(e))return!1;let n=t;return e.endsWith(n)},[h.LTRIMSTR]:(e,[t])=>{if(!N(e))return e;let n=t;return e.startsWith(n)?e.slice(n.length):e},[h.RTRIMSTR]:(e,[t])=>{if(!N(e))return e;let n=t;return e.endsWith(n)?e.slice(0,-n.length):e},[h.TOSTRING]:(e)=>{if(N(e))return e;if(de(e))return String(e);return JSON.stringify(e)},[h.TONUMBER]:(e)=>{if(ne(e))return e;if(N(e)){let t=Number(e);return!Number.isNaN(t)?t:null}return null},[h.FLOOR]:(e)=>ne(e)?Math.floor(e):null,[h.CEIL]:(e)=>ne(e)?Math.ceil(e):null,[h.ROUND]:(e)=>ne(e)?Math.round(e):null,[h.ABS]:(e)=>ne(e)?Math.abs(e):null,[h.NOT]:(e)=>!e,[h.SELECT]:(e,[t])=>{return t(e)?e:Ae},[h.EMPTY]:()=>Ae,[h.ERROR]:(e,[t])=>{throw Error(t||"error")},[h.DEBUG]:(e)=>{return console.error("DEBUG:",e),e}}});var Jt;var zt=g(()=>{Jt={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>e<t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t,"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,"&&":(e,t)=>e&&t,"||":(e,t)=>e||t}});var Ge=(e)=>e.startsWith("__operator_")&&e.endsWith("__"),We=(e)=>e.slice(11,-2),Je=(e,t,n)=>{let r=Jt[t];if(!r)throw Error(`Unknown operator: ${t}`);return r(e,n)},Qt=(e,t)=>Object.fromEntries(e.map((n,r)=>[n,t[r]])),me=(e)=>{return Object.values(e)[0]},Kt=(e)=>e!==null&&typeof e==="object",fe=(e,t)=>{if(!Kt(e))return;return e[t]},He=(e,t)=>e<0?t+e:e,Yt=(e,t)=>{if(!Array.isArray(e))return;let n=He(t,e.length);return e[n]},Xt=(e,t,n)=>{if(!Array.isArray(e))return;let r=e.length,s=t!==void 0?He(t,r):0,o=n!==void 0?He(n,r):r;return e.slice(s,o)},qt=(e,t)=>{if(!Kt(e))return;switch(t){case"keys":return Object.keys(e);case"values":return Object.values(e);case"entries":return Object.entries(e);case"length":return Array.isArray(e)?e.length:Object.keys(e).length}},Ui=(e,t)=>{if(e===null||e===void 0)return!1;return typeof e[t]==="function"},Vi=(e)=>e instanceof Error?e.message:String(e),ze=(e,t,n)=>{if(!Ui(e,t))throw Error(`Method ${t} does not exist on ${typeof e}`);try{return e[t].call(e,...n)}catch(s){let o=Vi(s);throw Error(`Error executing method ${t}: ${o}`)}};var Zt=g(()=>{zt()});class z{options;constructor(e={}){this.options=e}evaluate(e,t){switch(e.type){case"Root":return e.expression?this.evaluate(e.expression,t):t;case"PropertyAccess":return this.evaluatePropertyAccess(e,t);case"IndexAccess":return Yt(e.object?this.evaluate(e.object,t):t,e.index);case"SliceAccess":return Xt(e.object?this.evaluate(e.object,t):t,e.start,e.end);case"ArraySpread":return e.object?this.evaluate(e.object,t):t;case"MethodCall":return this.evaluateMethodCall(e,t);case"ObjectOperation":return qt(e.object?this.evaluate(e.object,t):t,e.operation);case"Literal":return e.value;case"ArrowFunction":return this.createFunction(e);case"RecursiveDescent":return this.evaluateRecursiveDescent(e,t);case"OptionalAccess":return this.evaluateOptionalAccess(e,t);case"NullCoalescing":return this.evaluateNullCoalescing(e,t);default:throw Error(`Unknown AST node type: ${e.type}`)}}evaluatePropertyAccess(e,t){let n=e.object?this.evaluate(e.object,t):t,r=fe(n,e.property);if(this.options.strict&&r===void 0){let s=e.property;throw Error(`Property "${s}" is undefined`)}return r}evaluateArg(e,t){return e.type==="ArrowFunction"?this.createFunction(e):this.evaluate(e,t)}evaluateMethodCall(e,t){if(e.method===h.PIPE)return this.evaluatePipe(e.args,t);if(e.method===h.COMPOSE)return this.evaluatePipe([...e.args].reverse(),t);let n=e.object?this.evaluate(e.object,t):t;if(is(e.method)){let o=e.args.map((i)=>this.evaluateArg(i,t));return cs(e.method,n,o)}if(Ge(e.method)){let o=We(e.method),i=this.evaluate(e.args[0],t);return Je(n,o,i)}let s=e.args.map((o)=>this.evaluateArg(o,t));return ze(n,e.method,s)}evaluatePipe(e,t){return e.reduce((n,r)=>this.evaluate(r,n),t)}evaluateRecursiveDescent(e,t){let n=e.object?this.evaluate(e.object,t):t;return this.collectAllValues(n)}collectAllValues(e,t=[]){if(t.push(e),Array.isArray(e))e.forEach((n)=>this.collectAllValues(n,t));else if(e!==null&&typeof e==="object")Object.values(e).forEach((n)=>this.collectAllValues(n,t));return t}evaluateOptionalAccess(e,t){try{return this.evaluate(e.expression,t)}catch{return null}}evaluateNullCoalescing(e,t){let n=this.evaluate(e.left,t);return n===null||n===void 0?this.evaluate(e.right,t):n}createFunction(e){return(...t)=>{let n=Qt(e.params,t);return this.evaluateFunctionBody(e.body,n)}}evaluateFunctionBody(e,t){switch(e.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(e,t);case"MethodCall":return this.evaluateMethodCallInFunction(e,t);case"Literal":return e.value;case"Root":return e.expression?this.evaluateFunctionBody(e.expression,t):t;default:return this.evaluate(e,me(t))}}evaluatePropertyAccessInFunction(e,t){if(e.object!==void 0){let o=this.evaluateFunctionBody(e.object,t);return fe(o,e.property)}if(Object.prototype.hasOwnProperty.call(t,e.property))return t[e.property];let s=me(t);return fe(s,e.property)}evaluateMethodCallInFunction(e,t){let n=e.object?this.evaluateFunctionBody(e.object,t):me(t);if(Ge(e.method)){let o=We(e.method),i=this.evaluateFunctionBody(e.args[0],t);return Je(n,o,i)}let s=e.args.map((o)=>this.evaluateFunctionBody(o,t));return ze(n,e.method,s)}}var Qe=g(()=>{ce();as();Zt();zt();Zt()});var Ke=(e)=>{if(e===null)return"null";if(Array.isArray(e))return"Array";let t=typeof e;return t.charAt(0).toUpperCase()+t.slice(1)},Ye=(e,t)=>{if(t==="null")return"null";if(t==="String")return`"${e}"`;if(t==="Array")return`[${e.length} items]`;if(t==="Object")return`{${Object.keys(e).length} keys}`;return String(e)},tn=(e,t="",n=[])=>{if(e===null||e===void 0){let i=Ke(e),c=Ye(e,i);return n.push({path:t||".",value:e,type:i,displayValue:c}),n}if(Array.isArray(e)){let i=Ke(e),c=Ye(e,i),a=t||".";return n.push({path:a,value:e,type:i,displayValue:c}),e.forEach((u,l)=>{let p=t?`${t}[${l}]`:`.[${l}]`;tn(u,p,n)}),n}if(typeof e==="object"){let i=Ke(e),c=Ye(e,i),a=t||".";if(t)n.push({path:a,value:e,type:i,displayValue:c});return Object.entries(e).forEach(([l,p])=>{let f=/[^a-zA-Z0-9_$]/.test(l),x=t?f?`${t}["${l}"]`:`${t}.${l}`:f?`.["${l}"]`:`.${l}`;tn(p,x,n)}),n}let r=Ke(e),s=Ye(e,r),o=t||".";return n.push({path:o,value:e,type:r,displayValue:s}),n},Xe=(e)=>{return tn(e)};var Hi=(e,t,n)=>{let r=n.length*100,s=(p,f,x)=>{if(x===0)return p;let B=n[x-1]===f-1?5:0;return p+B},o=n.reduce(s,0),a=n[0]===0?10:0,u=e.length-t.length;return r+o+a-u},Gi=(e,t)=>{let n=e.toLowerCase(),r=t.toLowerCase(),s=[],o=0,i=0,c=()=>{let u=o<n.length,l=i<r.length;return u&&l};while(c()){let u=n[o],l=r[i];if(u===l)s.push(o),i=i+1;o=o+1}return i===r.length?s:null},Wi=(e,t,n)=>{let r=Gi(t,n);if(!r)return null;let o=Hi(t,n,r);return Object.assign({},{item:e,score:o,matches:r})},Ji=(e,t)=>t.score-e.score,R=(e,t,n)=>{if(!t){let u=(l)=>{return Object.assign({},{item:l,score:0,matches:[]})};return e.map(u)}let s=(u)=>{let l=n(u);return Wi(u,l,t)},o=e.map(s),i=(u)=>u!==null;return o.filter(i).sort(Ji)};var nn,rn,sn,on,cn,an,un,ln,Q;var pn=g(()=>{nn=[{name:"map",signature:".map(x => ...)",description:"Transform each item",template:".map(x => x)",category:"Transform"},{name:"filter",signature:".filter(x => ...)",description:"Filter by condition",template:".filter(x => x)",category:"Filter"},{name:"reduce",signature:".reduce((acc, x) => ..., initial)",description:"Reduce to single value",template:".reduce((acc, x) => acc, 0)",category:"Aggregate"},{name:"find",signature:".find(x => ...)",description:"Find first match",template:".find(x => x)",category:"Search"},{name:"findIndex",signature:".findIndex(x => ...)",description:"Find first match index",template:".findIndex(x => x)",category:"Search"},{name:"some",signature:".some(x => ...)",description:"Check if any match",template:".some(x => x)",category:"Test"},{name:"every",signature:".every(x => ...)",description:"Check if all match",template:".every(x => x)",category:"Test"},{name:"sort",signature:".sort((a, b) => ...)",description:"Sort items",template:".sort((a, b) => a - b)",category:"Transform"},{name:"reverse",signature:".reverse()",description:"Reverse order",template:".reverse()",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Get subset",template:".slice(0, 10)",category:"Transform"},{name:"concat",signature:".concat(arr)",description:"Combine arrays",template:".concat([])",category:"Transform"},{name:"join",signature:".join(separator)",description:"Join to string",template:".join(', ')",category:"Convert"},{name:"flat",signature:".flat(depth)",description:"Flatten nested arrays",template:".flat(1)",category:"Transform"},{name:"flatMap",signature:".flatMap(x => ...)",description:"Map then flatten",template:".flatMap(x => x)",category:"Transform"},{name:"length",signature:".length",description:"Get array length",template:".length",category:"Property"}],rn=[{name:"toUpperCase",signature:".toUpperCase()",description:"Convert to uppercase",template:".toUpperCase()",category:"Transform"},{name:"toLowerCase",signature:".toLowerCase()",description:"Convert to lowercase",template:".toLowerCase()",category:"Transform"},{name:"trim",signature:".trim()",description:"Remove whitespace",template:".trim()",category:"Transform"},{name:"trimStart",signature:".trimStart()",description:"Remove leading whitespace",template:".trimStart()",category:"Transform"},{name:"trimEnd",signature:".trimEnd()",description:"Remove trailing whitespace",template:".trimEnd()",category:"Transform"},{name:"split",signature:".split(separator)",description:"Split into array",template:".split(',')",category:"Convert"},{name:"replace",signature:".replace(search, replace)",description:"Replace first match",template:".replace('old', 'new')",category:"Transform"},{name:"replaceAll",signature:".replaceAll(search, replace)",description:"Replace all matches",template:".replaceAll('old', 'new')",category:"Transform"},{name:"substring",signature:".substring(start, end)",description:"Extract substring",template:".substring(0, 10)",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Extract slice",template:".slice(0, 10)",category:"Transform"},{name:"startsWith",signature:".startsWith(str)",description:"Check if starts with",template:".startsWith('prefix')",category:"Test"},{name:"endsWith",signature:".endsWith(str)",description:"Check if ends with",template:".endsWith('suffix')",category:"Test"},{name:"includes",signature:".includes(str)",description:"Check if contains",template:".includes('text')",category:"Test"},{name:"match",signature:".match(regex)",description:"Match regex pattern",template:".match(/pattern/)",category:"Search"},{name:"length",signature:".length",description:"Get string length",template:".length",category:"Property"}],sn=[{name:"keys",signature:".{keys}",description:"Get object keys",template:".{keys}",category:"Convert"},{name:"values",signature:".{values}",description:"Get object values",template:".{values}",category:"Convert"},{name:"entries",signature:".{entries}",description:"Get key-value pairs",template:".{entries}",category:"Convert"},{name:"length",signature:".{length}",description:"Get property count",template:".{length}",category:"Property"}],on=[{name:"toFixed",signature:".toFixed(decimals)",description:"Format with decimals",template:".toFixed(2)",category:"Format"},{name:"toString",signature:".toString()",description:"Convert to string",template:".toString()",category:"Convert"}],cn=[{name:"head",signature:"head()",description:"First element",template:".head()",category:"Access",isBuiltin:!0},{name:"last",signature:"last()",description:"Last element",template:".last()",category:"Access",isBuiltin:!0},{name:"tail",signature:"tail()",description:"All but first element",template:".tail()",category:"Transform",isBuiltin:!0},{name:"take",signature:"take(n)",description:"First n elements",template:".take(5)",category:"Transform",isBuiltin:!0},{name:"drop",signature:"drop(n)",description:"Skip first n elements",template:".drop(5)",category:"Transform",isBuiltin:!0},{name:"uniq",signature:"uniq()",description:"Remove duplicates",template:".uniq()",category:"Transform",isBuiltin:!0},{name:"flatten",signature:"flatten()",description:"Flatten nested arrays",template:".flatten()",category:"Transform",isBuiltin:!0},{name:"compact",signature:"compact()",description:"Remove falsy values",template:".compact()",category:"Transform",isBuiltin:!0},{name:"chunk",signature:"chunk(n)",description:"Split into chunks of size n",template:".chunk(3)",category:"Transform",isBuiltin:!0},{name:"groupBy",signature:"groupBy(fn)",description:"Group by key function",template:".groupBy(x => x)",category:"Aggregate",isBuiltin:!0},{name:"sortBy",signature:"sortBy(fn)",description:"Sort by key function",template:".sortBy(x => x)",category:"Transform",isBuiltin:!0},{name:"pluck",signature:"pluck(key)",description:"Extract property from each item",template:".pluck('name')",category:"Transform",isBuiltin:!0},{name:"sum",signature:"sum()",description:"Sum of numbers",template:".sum()",category:"Aggregate",isBuiltin:!0},{name:"mean",signature:"mean()",description:"Average of numbers",template:".mean()",category:"Aggregate",isBuiltin:!0},{name:"min",signature:"min()",description:"Minimum value",template:".min()",category:"Aggregate",isBuiltin:!0},{name:"max",signature:"max()",description:"Maximum value",template:".max()",category:"Aggregate",isBuiltin:!0},{name:"add",signature:"add()",description:"Sum numbers or concat strings/arrays",template:".add()",category:"Aggregate",isBuiltin:!0}],an=[{name:"keys",signature:"keys()",description:"Get object keys",template:".keys()",category:"Convert",isBuiltin:!0},{name:"vals",signature:"vals()",description:"Get object values",template:".vals()",category:"Convert",isBuiltin:!0},{name:"pick",signature:"pick(k1, k2, ...)",description:"Pick specific keys",template:".pick('key1', 'key2')",category:"Transform",isBuiltin:!0},{name:"omit",signature:"omit(k1, k2, ...)",description:"Omit specific keys",template:".omit('key1', 'key2')",category:"Transform",isBuiltin:!0},{name:"merge",signature:"merge(obj)",description:"Shallow merge objects",template:".merge({})",category:"Transform",isBuiltin:!0},{name:"toPairs",signature:"toPairs()",description:"Convert object to pairs",template:".toPairs()",category:"Convert",isBuiltin:!0},{name:"has",signature:"has(key)",description:"Check if key exists",template:".has('key')",category:"Test",isBuiltin:!0}],un=[{name:"split",signature:"split(sep)",description:"Split string by separator",template:".split(',')",category:"Convert",isBuiltin:!0},{name:"startswith",signature:"startswith(s)",description:"Check if starts with string",template:".startswith('prefix')",category:"Test",isBuiltin:!0},{name:"endswith",signature:"endswith(s)",description:"Check if ends with string",template:".endswith('suffix')",category:"Test",isBuiltin:!0},{name:"ltrimstr",signature:"ltrimstr(s)",description:"Remove prefix",template:".ltrimstr('prefix')",category:"Transform",isBuiltin:!0},{name:"rtrimstr",signature:"rtrimstr(s)",description:"Remove suffix",template:".rtrimstr('suffix')",category:"Transform",isBuiltin:!0},{name:"tostring",signature:"tostring()",description:"Convert to string",template:".tostring()",category:"Convert",isBuiltin:!0}],ln=[{name:"floor",signature:"floor()",description:"Floor number",template:".floor()",category:"Math",isBuiltin:!0},{name:"ceil",signature:"ceil()",description:"Ceiling number",template:".ceil()",category:"Math",isBuiltin:!0},{name:"round",signature:"round()",description:"Round number",template:".round()",category:"Math",isBuiltin:!0},{name:"abs",signature:"abs()",description:"Absolute value",template:".abs()",category:"Math",isBuiltin:!0},{name:"tonumber",signature:"tonumber()",description:"Convert to number",template:".tonumber()",category:"Convert",isBuiltin:!0}],Q=[{name:"type",signature:"type()",description:"Get value type",template:".type()",category:"Inspect",isBuiltin:!0},{name:"len",signature:"len()",description:"Get length",template:".len()",category:"Inspect",isBuiltin:!0},{name:"isEmpty",signature:"isEmpty()",description:"Check if empty",template:".isEmpty()",category:"Test",isBuiltin:!0},{name:"isNil",signature:"isNil()",description:"Check if null/undefined",template:".isNil()",category:"Test",isBuiltin:!0},{name:"contains",signature:"contains(val)",description:"Check if contains value",template:".contains(value)",category:"Test",isBuiltin:!0}]});var zi,j=(e)=>zi.get(e)??Q;var hn=g(()=>{pn();pn();zi=new Map([["Array",[...nn,...cn,...Q]],["String",[...rn,...un,...Q]],["Object",[...sn,...an,...Q]],["Number",[...on,...ln,...Q]]])});var dn=6,qe=500,Ze=5;var mn="",fn=void 0,et=null,Qi=(e)=>{if(Array.isArray(e)&&e.length>Ze)return{value:e.slice(0,Ze),truncated:!0};return{value:e,truncated:!1}},Ki=(e,t)=>{let n=JSON.stringify(e,null,2),r=t?`
|
|
39
|
+
... (truncated)`:"";if(n.length>qe)return n.slice(0,qe)+`
|
|
40
|
+
... (truncated)`;return n+r},re=(e,t)=>{if(e===mn&&t===fn&&et!==null)return et;try{let n=$(e),s=new G(n).tokenize(),i=new J(s).parse(),a=new z().evaluate(i,t),{value:u,truncated:l}=Qi(a),p={success:!0,value:u,error:null,truncated:l};return mn=e,fn=t,et=p,p}catch(n){let s={success:!1,value:null,error:n instanceof Error?n.message:String(n),truncated:!1};return mn=e,fn=t,et=s,s}},tt=(e)=>{if(!e.success)return`Error: ${e.error}`;return Ki(e.value,e.truncated)};var nt=g(()=>{Le();je();Qe();ae()});var gn=5,rt=".";var yn=()=>{};var Yi=(e)=>{let t=e.lastIndexOf(rt);if(t===-1)return null;let r=e.slice(t+1);if(r.includes("(")||r.includes(")"))return null;return r},Xi=(e)=>{if(e===null)return"null";if(Array.isArray(e))return"Array";return{string:"String",number:"Number",boolean:"Boolean",object:"Object"}[typeof e]||"unknown"},xn=()=>Object.assign({},{visible:!1,methodHints:[],partialMethod:"",selectedHintIndex:0}),hs=(e)=>{let t=Yi(e.query);if(t===null)return xn();let r=e.dataType||Xi(e.originalData),s=j(r),i=R(s,t,(a)=>a.name).slice(0,gn),c=i.length>0;return Object.assign({},{visible:c,methodHints:i,partialMethod:t,selectedHintIndex:0})},qi,ds=(e)=>{let t=e.lastIndexOf(rt);if(t===-1)return!1;let r=e.slice(t+1),s=r.includes(")"),o=qi.includes(r);return s||o},ms=(e,t)=>{let n=re(e,t),r=tt(n);return{success:n.success,preview:r}};var Sn=g(()=>{hn();nt();yn();yn();qi=["length","keys","values","entries"]});var gs=(e,t)=>{let n=R(e,"",(s)=>s.path);return Object.assign({},{mode:"explore",paths:e,matches:n,query:"",selectedIndex:0,builder:null,originalData:t,methodMatches:[],propertyMatches:[],tooltip:xn()})},fs=(e)=>{if(e===null)return"null";if(Array.isArray(e))return"Array";return{string:"String",number:"Number",boolean:"Boolean",object:"Object"}[typeof e]||"unknown"},bn=(e,t)=>{let n=R(e.paths,t,(p)=>p.path),r=n.length>0?0:e.selectedIndex,s=t.lastIndexOf("."),o=s>0?t.slice(0,s):"",i=o?re(o,e.originalData):null,c=i?.success?fs(i.value):fs(e.originalData),a={query:t,dataType:c,originalData:e.originalData},u=hs(a);return Object.assign({},e,{query:t,matches:n,selectedIndex:r,tooltip:u})},K=(e,t)=>{let n=e.mode==="explore",r=e.mode==="build",s=n?e.matches.length:r?e.methodMatches.length:e.propertyMatches.length;if(s===0)return e;let c=e.selectedIndex+t;if(c<0)c=s-1;else if(c>=s)c=0;return Object.assign({},e,{selectedIndex:c})},ys=(e)=>{let t=e.matches.length>0,n=e.selectedIndex>=0&&e.selectedIndex<e.matches.length;if(t&&n)return e.matches[e.selectedIndex].item;return null};var Tn=g(()=>{Sn();nt()});import{stdout as se}from"process";var Y=()=>{se.write("\x1B[2J\x1B[H")},An=(e,t=1)=>{se.write(`\x1B[${e};${t}H`)},xs=()=>{se.write("\x1B[2K")},Ss=()=>{se.write("\x1B[J")},bs=()=>{se.write("\x1B[?25l")},Ts=()=>{se.write("\x1B[?25h")},As=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!0);process.stdin.resume()},Es=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!1);process.stdin.pause()},d,m=(e,t)=>{let n=d.reset;return t.concat(e,n)},ye=(e,t)=>{let n=e.split(""),r=d.bright.concat(d.cyan),s=(c,a)=>{return t.includes(a)?m(c,r):c};return n.map(s).join("")};var st=g(()=>{d=Object.assign({},{reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",cyan:"\x1B[36m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",gray:"\x1B[90m"})});import{stdout as k}from"process";var I=10,Zi=(e,t)=>ye(e,t),ec=(e)=>{let t=`[${e}]`;return m(t,d.dim)},tc=(e)=>m(e,d.gray),Ns=(e)=>{let t=m("\u276F",d.green),n=" ";return e?t:" "},nc=(e,t,n)=>{let r=Ns(t),s=Zi(e.signature,n),o=e.category?ec(e.category):"",i=tc(e.description);return r.concat(" ",s).concat(o?" "+o:"").concat(" - ",i)},rc=(e,t)=>{let{item:n,matches:r}=e,s=Ns(t),o=ye(n.path,r),i=m(`[${n.type}]`,d.dim),c=m(n.displayValue,d.gray);return s.concat(" ",o).concat(" ",i).concat(" ",c)},sc=(e)=>{if(e.builder===null)return"";let n="Expression Builder",r=d.bright.concat(d.cyan),s=m(n,r),o=e.builder.expression,i=`
|
|
37
41
|
|
|
38
|
-
Building: `,c=
|
|
42
|
+
Building: `,c=m(o,d.bright.concat(d.yellow)),a=`
|
|
39
43
|
|
|
40
|
-
Search methods for `,u=
|
|
44
|
+
Search methods for `,u=m(e.builder.baseType,d.bright),l=": ",p=e.query;return s.concat(i,c).concat(a,u,l,p,`
|
|
41
45
|
|
|
42
|
-
`)},
|
|
46
|
+
`)},oc=(e)=>{let t=e.builder!==null,n=e.builder?.arrowFnContext!==null;if(!t||!n)return"";let r="Expression Builder - Arrow Function",s=d.bright.concat(d.cyan),o=m(r,s),i=e.builder.expression,c=`
|
|
43
47
|
|
|
44
|
-
Building: `,a=
|
|
48
|
+
Building: `,a=m(i,d.bright.concat(d.yellow)),u=e.builder.arrowFnContext,l=`
|
|
45
49
|
|
|
46
|
-
Search properties for '${u.paramName}' (${u.paramType}): `,p=
|
|
50
|
+
Search properties for '${u.paramName}' (${u.paramType}): `,p=e.query;return o.concat(c,a).concat(l,p,`
|
|
47
51
|
|
|
48
|
-
`)},
|
|
49
|
-
`)},
|
|
50
|
-
`)},
|
|
52
|
+
`)},ic=(e)=>{if(e.builder===null)return"";let{methodMatches:n,selectedIndex:r}=e;if(n.length===0)return m("No methods found",d.dim);let s=Math.floor(I/2),o=Math.max(0,r-s),i=Math.min(n.length,o+I);if(i-o<I&&n.length>=I)o=Math.max(0,i-I);let a=n.slice(o,i),u=(f,x)=>{let q=o+x===r;return nc(f.item,q,f.matches)};return a.map(u).join(`
|
|
53
|
+
`)},cc=(e)=>{let t=e.builder===null,n=e.builder?.arrowFnContext===null;if(t||n)return"";let{propertyMatches:r,selectedIndex:s}=e;if(r.length===0)return m("No properties found",d.dim);let o=Math.floor(I/2),i=Math.max(0,s-o),c=Math.min(r.length,i+I);if(c-i<I&&r.length>=I)i=Math.max(0,c-I);let u=r.slice(i,c),l=(x,U)=>{let V=i+U===s;return rc(x,V)};return u.map(l).join(`
|
|
54
|
+
`)},Os=(e)=>{let t=e-I;if(t>0){let r=`
|
|
51
55
|
|
|
52
|
-
... `.concat(String(
|
|
56
|
+
... `.concat(String(t)," more");return m(r,d.dim)}return""},ws=()=>{let e=`
|
|
53
57
|
|
|
54
|
-
`.concat(
|
|
55
|
-
`)
|
|
56
|
-
`),m
|
|
57
|
-
... (truncated)`,m.dim)):s},_o=(t)=>{let{type:e,displayValue:n,value:r}=t;if(Mo.includes(e))return ko(n);if(Lo.includes(e))return Po(r);return f(String(r),m.cyan)},Bo=(t)=>{let{matches:e,selectedIndex:n}=t,r=e.length>0,o=n>=0&&n<e.length;if(!(r&&o))return"";let i=e[n].item,c=f(`
|
|
58
|
+
`.concat(m("\u2191/\u2193",d.bright)," navigate ",m("\u2192/Tab",d.bright)," accept ",m("\u2190",d.bright)," undo ",m("Enter",d.bright)," execute ",m("Esc",d.bright)," quit");return m(e,d.dim)},Rs=(e)=>{if(!e.builder)return"";let t=e.builder.expression,n=e.originalData,r=re(t,n),c=tt(r).split(`
|
|
59
|
+
`).slice(0,dn).join(`
|
|
60
|
+
`),a=m(`
|
|
58
61
|
|
|
59
62
|
Preview:
|
|
60
|
-
`,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
`)),vt=t,er=!1},Jo=(t,e)=>{oe(e+1),Vn(),tr.write(t)},zo=(t)=>{if(er){Uo(t);return}if(t.forEach((n,r)=>{if(vt[r]!==n)Jo(n,r)}),t.length<vt.length)oe(t.length+1),Gn();vt=t},Qo=(t)=>{let e=Wo(t);zo(e)},Ho,ie=(t)=>{let e=Ho[t.mode];e(t)};var nr=x(()=>{Ot();Yn();vt=[],Mo=["String","Number","Boolean","null"],Lo=["Array","Object"],Ho={explore:Qo,build:Xn,"build-arrow-fn":qn}});var Ko,Xo,qo,Yo,Y=(t)=>{switch(t){case"Array":return Ko;case"String":return Xo;case"Object":return qo;case"Number":return Yo;default:return[]}};var rr=x(()=>{Ko=[{name:"map",signature:".map(x => ...)",description:"Transform each item",template:".map(x => x)",category:"Transform"},{name:"filter",signature:".filter(x => ...)",description:"Filter by condition",template:".filter(x => x)",category:"Filter"},{name:"reduce",signature:".reduce((acc, x) => ..., initial)",description:"Reduce to single value",template:".reduce((acc, x) => acc, 0)",category:"Aggregate"},{name:"find",signature:".find(x => ...)",description:"Find first match",template:".find(x => x)",category:"Search"},{name:"findIndex",signature:".findIndex(x => ...)",description:"Find first match index",template:".findIndex(x => x)",category:"Search"},{name:"some",signature:".some(x => ...)",description:"Check if any match",template:".some(x => x)",category:"Test"},{name:"every",signature:".every(x => ...)",description:"Check if all match",template:".every(x => x)",category:"Test"},{name:"sort",signature:".sort((a, b) => ...)",description:"Sort items",template:".sort((a, b) => a - b)",category:"Transform"},{name:"reverse",signature:".reverse()",description:"Reverse order",template:".reverse()",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Get subset",template:".slice(0, 10)",category:"Transform"},{name:"concat",signature:".concat(arr)",description:"Combine arrays",template:".concat([])",category:"Transform"},{name:"join",signature:".join(separator)",description:"Join to string",template:".join(', ')",category:"Convert"},{name:"flat",signature:".flat(depth)",description:"Flatten nested arrays",template:".flat(1)",category:"Transform"},{name:"flatMap",signature:".flatMap(x => ...)",description:"Map then flatten",template:".flatMap(x => x)",category:"Transform"},{name:"length",signature:".length",description:"Get array length",template:".length",category:"Property"}],Xo=[{name:"toUpperCase",signature:".toUpperCase()",description:"Convert to uppercase",template:".toUpperCase()",category:"Transform"},{name:"toLowerCase",signature:".toLowerCase()",description:"Convert to lowercase",template:".toLowerCase()",category:"Transform"},{name:"trim",signature:".trim()",description:"Remove whitespace",template:".trim()",category:"Transform"},{name:"trimStart",signature:".trimStart()",description:"Remove leading whitespace",template:".trimStart()",category:"Transform"},{name:"trimEnd",signature:".trimEnd()",description:"Remove trailing whitespace",template:".trimEnd()",category:"Transform"},{name:"split",signature:".split(separator)",description:"Split into array",template:".split(',')",category:"Convert"},{name:"replace",signature:".replace(search, replace)",description:"Replace first match",template:".replace('old', 'new')",category:"Transform"},{name:"replaceAll",signature:".replaceAll(search, replace)",description:"Replace all matches",template:".replaceAll('old', 'new')",category:"Transform"},{name:"substring",signature:".substring(start, end)",description:"Extract substring",template:".substring(0, 10)",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Extract slice",template:".slice(0, 10)",category:"Transform"},{name:"startsWith",signature:".startsWith(str)",description:"Check if starts with",template:".startsWith('prefix')",category:"Test"},{name:"endsWith",signature:".endsWith(str)",description:"Check if ends with",template:".endsWith('suffix')",category:"Test"},{name:"includes",signature:".includes(str)",description:"Check if contains",template:".includes('text')",category:"Test"},{name:"match",signature:".match(regex)",description:"Match regex pattern",template:".match(/pattern/)",category:"Search"},{name:"length",signature:".length",description:"Get string length",template:".length",category:"Property"}],qo=[{name:"keys",signature:".{keys}",description:"Get object keys",template:".{keys}",category:"Convert"},{name:"values",signature:".{values}",description:"Get object values",template:".{values}",category:"Convert"},{name:"entries",signature:".{entries}",description:"Get key-value pairs",template:".{entries}",category:"Convert"},{name:"length",signature:".{length}",description:"Get property count",template:".{length}",category:"Property"}],Yo=[{name:"toFixed",signature:".toFixed(decimals)",description:"Format with decimals",template:".toFixed(2)",category:"Format"},{name:"toString",signature:".toString()",description:"Convert to string",template:".toString()",category:"Convert"}]});var sr=(t)=>{let e=t.matches.length>0,n=t.selectedIndex>=0&&t.selectedIndex<t.matches.length;if(!e||!n)return t;let r=t.matches[t.selectedIndex].item,o={basePath:r.path,baseValue:r.value,baseType:r.type,expression:r.path,currentMethodIndex:0,arrowFnContext:null},s=Y(r.type),i=P(s,"",(a)=>a.signature);return Object.assign({},t,{mode:"build",builder:o,query:"",selectedIndex:0,methodMatches:i})},at=(t)=>{return Object.assign({},t,{mode:"explore",builder:null,selectedIndex:0})},ce=(t,e)=>{if(!t.builder)return t;let r=t.builder,o=Y(r.baseType),s=P(o,e,(c)=>c.signature);return Object.assign({},t,{query:e,methodMatches:s,selectedIndex:0})},ae=(t,e)=>{let n=!t.builder,r=!t.builder?.arrowFnContext;if(n||r)return t;let o=t.builder.arrowFnContext,s=P(o.paramPaths,e,(c)=>c.path);return Object.assign({},t,{query:e,propertyMatches:s,selectedIndex:0})},or=(t,e)=>{if(!t.builder)return t;let r=t.builder;if(e<0||e>=t.methodMatches.length)return t;let i=t.methodMatches[e].item.template||"";if(i.includes("x =>")||i.includes("(a, b)")||i.includes("(acc, x)")){let h=r.baseType==="Array"?(()=>{if(!Array.isArray(r.baseValue))return{};if(r.baseValue.length===0)return{};return r.baseValue[0]})():r.baseValue,T=Array.isArray(h)?"Array":h===null?"null":typeof h==="object"?"Object":typeof h==="string"?"String":typeof h==="number"?"Number":typeof h==="boolean"?"Boolean":"unknown",N=i.includes("(a, b)")?"a":"x",y=Tt(h),g={paramName:N,paramType:T,paramValue:h,paramPaths:y,expression:""},b=P(y,"",(S)=>S.path),C=Object.assign({},r,{currentMethodIndex:e,arrowFnContext:g,expression:r.expression+i});return Object.assign({},t,{mode:"build-arrow-fn",builder:C,query:"",selectedIndex:0,propertyMatches:b})}let a=r.expression+i,u=Object.assign({},r,{expression:a,currentMethodIndex:e});return Object.assign({},t,{builder:u})},ir=(t,e)=>{let n=!t.builder,r=!t.builder?.arrowFnContext;if(n||r)return t;if(e<0||e>=t.propertyMatches.length)return t;let s=t.builder,i=s.arrowFnContext,c=t.propertyMatches[e].item,a=i.paramName,u=c.path==="."?a:`${a}${c.path}`,l=Object.assign({},i,{expression:u}),p=Object.assign({},s,{arrowFnContext:l});return Object.assign({},t,{builder:p})},cr=(t)=>{let e=!t.builder,n=!t.builder?.arrowFnContext;if(e||n)return t;let r=t.builder,o=r.arrowFnContext;if(!o.expression)return t;let a=Y(r.baseType)[r.currentMethodIndex].template||"",u=(h,T,N)=>{let y=h.lastIndexOf(T);if(y===-1)return h;return h.substring(0,y)+N+h.substring(y+T.length)},l=r.expression;if(a.includes("x => x"))l=u(l,"x => x",`x => ${o.expression}`);else if(a.includes("(a, b) => a - b"))l=u(l,"(a, b) => a - b",`(a, b) => ${o.expression}`);else if(a.includes("(acc, x) => acc"))l=u(l,"(acc, x) => acc",`(acc, x) => ${o.expression}`);let p=Object.assign({},r,{expression:l,arrowFnContext:null});return Object.assign({},t,{mode:"build",builder:p,query:"",selectedIndex:0})},ue=(t)=>{if(!t.builder)return t;let n=t.builder,s=Y(n.baseType)[n.currentMethodIndex].template||"",i=n.expression.replace(s,""),c=Object.assign({},n,{expression:i,arrowFnContext:null});return Object.assign({},t,{mode:"build",builder:c})},ar=(t)=>{if(!t.builder)return t;let n=t.builder,r=n.expression,o=r.lastIndexOf(".");if(o===-1)return at(t);let c=r.lastIndexOf("(")>o?r.substring(0,o):r;if(c===n.basePath)return at(t);let a=Object.assign({},n,{expression:c}),u=Y(n.baseType),l=P(u,"",(d)=>d.signature);return Object.assign({},t,{builder:a,methodMatches:l,query:"",selectedIndex:0})};var ur=x(()=>{rr()});var I,Zo=(t)=>{let e=t===I.CTRL_C,n=t===I.ESCAPE;return e||n||t==="q"},le=(t)=>t===I.ENTER,pe=(t)=>t===I.TAB,de=(t)=>t===I.UP,he=(t)=>t===I.DOWN,lr=(t)=>t===I.LEFT,pr=(t)=>t===I.RIGHT,me=(t)=>t===I.BACKSPACE,fe=(t)=>{let e=t>=" ",n=t<="~";return e&&n},ti=(t,e)=>{if(pe(e))return{state:sr(t),output:null};if(le(e)){let n=$n(t);if(!n)return{state:null,output:null};return{state:null,output:JSON.stringify(n.value,null,2)}}if(de(e))return{state:U(t,-1),output:null};if(he(e))return{state:U(t,1),output:null};if(me(e)){let n=t.query.slice(0,-1);return{state:re(t,n),output:null}}if(fe(e)){let n=t.query.concat(e);return{state:re(t,n),output:null}}return{state:t,output:null}},ei=(t,e)=>{if(e===I.ESCAPE)return{state:at(t),output:null};if(le(e)){if(!t.builder)return{state:t,output:null};return{state:null,output:t.builder.expression}}if(pr(e)||pe(e)){if(!t.builder)return{state:t,output:null};return{state:or(t,t.selectedIndex),output:null}}if(lr(e))return{state:ar(t),output:null};if(de(e))return{state:U(t,-1),output:null};if(he(e))return{state:U(t,1),output:null};if(me(e)){let n=t.query.slice(0,-1);return{state:ce(t,n),output:null}}if(fe(e)){let n=t.query.concat(e);return{state:ce(t,n),output:null}}return{state:t,output:null}},ni=(t,e)=>{if(e===I.ESCAPE)return{state:ue(t),output:null};if(le(e)){if(!t.builder)return{state:t,output:null};return{state:null,output:t.builder.expression}}if(pr(e)||pe(e)){let n=ir(t,t.selectedIndex);return{state:cr(n),output:null}}if(lr(e))return{state:ue(t),output:null};if(de(e))return{state:U(t,-1),output:null};if(he(e))return{state:U(t,1),output:null};if(me(e)){let n=t.query.slice(0,-1);return{state:ae(t,n),output:null}}if(fe(e)){let n=t.query.concat(e);return{state:ae(t,n),output:null}}return{state:t,output:null}},ri,dr=(t,e)=>{let n=e.toString();if(Zo(n)){if(t.mode==="build"||t.mode==="build-arrow-fn")return{state:at(t),output:null};return{state:null,output:null}}let r=ri[t.mode];return r(t,n)};var hr=x(()=>{se();ur();I=Object.assign({},{CTRL_C:"\x03",ESCAPE:"\x1B",ENTER:"\r",TAB:"\t",UP:"\x1B[A",DOWN:"\x1B[B",LEFT:"\x1B[D",RIGHT:"\x1B[C",BACKSPACE:"\x7F"}),ri={explore:ti,build:ei,"build-arrow-fn":ni}});var mr={};O(mr,{runInteractive:()=>ci});import{stdin as ge,stdout as ut,exit as lt}from"process";var xe=!1,It=()=>{if(xe)Un(),zn(),xe=!1;J()},be=(t)=>{It();let e=t instanceof Error?t.message:String(t),n=f(`Fatal error: ${e}
|
|
65
|
-
|
|
66
|
-
`,
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
`,d.bright),u=r.success?m(c,d.cyan):m(c,d.yellow);return a.concat(u)},Is=(e)=>{Y();let t=sc(e);k.write(t);let n=ic(e);k.write(n);let r=e.methodMatches.length,s=Os(r);k.write(s);let o=Rs(e);k.write(o);let i=ws();k.write(i)},vs=(e)=>{Y();let t=oc(e);k.write(t);let n=cc(e);k.write(n);let r=e.propertyMatches.length,s=Os(r);k.write(s);let o=Rs(e);k.write(o);let i=ws();k.write(i)};var Ms=g(()=>{st();nt()});import{stdout as Ps}from"process";var oe=10,ot,Fs=!0,ac=(e,t)=>ye(e,t),uc=(e)=>{let r="[".concat(e,"]");return m(r,d.dim)},lc=(e)=>m(e,d.gray),pc=(e)=>{let t=m("\u276F",d.green),n=" ";return e?t:" "},hc=(e,t)=>{let{item:n,matches:r}=e,s=pc(t),o=ac(n.path,r),i=uc(n.type),c=lc(n.displayValue);return s.concat(" ",o).concat(" ",i).concat(" ",c)},dc=()=>{let t=d.bright.concat(d.cyan);return m("1ls Interactive Explorer",t)},mc,fc,Cs=5,gc=(e)=>m(String(e),d.cyan),yc=(e)=>{let n=JSON.stringify(e,null,2).split(`
|
|
64
|
+
`),r=n.slice(0,Cs),s=n.length>Cs,o=m(r.join(`
|
|
65
|
+
`),d.cyan);return s?o.concat(m(`
|
|
66
|
+
... (truncated)`,d.dim)):o},xc=(e)=>{let{type:t,displayValue:n,value:r}=e;if(mc.includes(t))return gc(n);if(fc.includes(t))return yc(r);return m(String(r),d.cyan)},Sc=(e)=>{let{matches:t,selectedIndex:n}=e,r=t.length>0,s=n>=0&&n<t.length;if(!(r&&s))return"";let i=t[n].item,c=m(`
|
|
67
|
+
|
|
68
|
+
Preview:
|
|
69
|
+
`,d.bright),a=xc(i);return c.concat(a)},bc=()=>{let e=`
|
|
70
|
+
|
|
71
|
+
`.concat(m("\u2191/\u2193",d.bright)," navigate ",m("Enter",d.bright)," select ",m("Tab",d.bright)," build ",m("Esc/q",d.bright)," quit");return m(e,d.dim)},Tc=(e,t)=>{let n=e.item,r=t?m("\u203A",d.cyan):" ",s=m(n.signature,d.bright),o=m(" - "+n.description,d.dim),i=n.isBuiltin?m(" [builtin]",d.yellow):"";return r.concat(" ",s,o,i)},Ac=(e)=>{if(!e.visible||e.methodHints.length===0)return[];let n=m("Method hints:",d.dim),r=e.methodHints.map((s,o)=>{let i=o===e.selectedHintIndex;return Tc(s,i)});return["",n,...r]},Ec=(e)=>{let t=e.query.length>0,n=e.query.includes("."),r=ds(e.query);if(!(t&&n&&r))return[];let{success:o,preview:i}=ms(e.query,e.originalData),c=m(`
|
|
72
|
+
Result:`,d.bright),a=o?d.cyan:d.yellow,l=i.split(`
|
|
73
|
+
`).slice(0,5).map((p)=>m(p,a));return[c,...l]},Nc=(e,t)=>{let n=Math.floor(oe/2),r=Math.max(0,e-n),s=Math.min(t,r+oe);return{start:s-r<oe&&t>=oe?Math.max(0,s-oe):r,end:s}},Oc=(e)=>{let{selectedIndex:t,matches:n}=e,r=n.length;if(r===0)return[m("No matches found",d.dim)];let{start:o,end:i}=Nc(t,r);return n.slice(o,i).map((a,u)=>{let p=o+u===t;return hc(a,p)})},wc=(e)=>{let t=e-oe;return t>0?["",m("... "+t+" more",d.dim)]:[]},Rc=(e)=>{let t=Sc(e);return t?t.split(`
|
|
74
|
+
`):[]},Ic=(e)=>{let t=[dc(),"","Search: "+e.query,""],n=Oc(e),r=wc(e.matches.length),s=Ac(e.tooltip),o=Ec(e),i=Rc(e),c=["",bc().trim()];return t.concat(n).concat(r).concat(s).concat(o).concat(i).concat(c)},vc=(e)=>{Y(),Ps.write(e.join(`
|
|
75
|
+
`)),ot=e,Fs=!1},Mc=(e,t)=>{An(t+1),xs(),Ps.write(e)},Cc=(e)=>{if(Fs){vc(e);return}if(e.forEach((n,r)=>{if(ot[r]!==n)Mc(n,r)}),e.length<ot.length)An(e.length+1),Ss();ot=e},Pc=(e)=>{let t=Ic(e);Cc(t)},Fc,En=(e)=>{let t=Fc[e.mode];t(e)};var ks=g(()=>{st();Ms();Sn();ot=[],mc=["String","Number","Boolean","null"],fc=["Array","Object"],Fc={explore:Pc,build:Is,"build-arrow-fn":vs}});var xe,X,Nn;var Ls=g(()=>{xe={SINGLE_PARAM:"x =>",SORT_PARAMS:"(a, b)",REDUCE_PARAMS:"(acc, x)"},X={SINGLE_PARAM:"x => x",SORT_COMPARE:"(a, b) => a - b",REDUCE_ACC:"(acc, x) => acc"},Nn={SORT:"a",DEFAULT:"x"}});var _s=(e)=>e.includes(xe.SINGLE_PARAM)||e.includes(xe.SORT_PARAMS)||e.includes(xe.REDUCE_PARAMS),Bs=(e)=>e.includes(xe.SORT_PARAMS)?Nn.SORT:Nn.DEFAULT,Ds=(e)=>{if(Array.isArray(e))return"Array";if(e===null)return"null";if(typeof e==="object")return"Object";if(typeof e==="string")return"String";if(typeof e==="number")return"Number";if(typeof e==="boolean")return"Boolean";return"unknown"},js=(e)=>{if(!Array.isArray(e))return{};if(e.length===0)return{};return e[0]},Se=(e,t,n)=>{let r=e.lastIndexOf(t);if(r===-1)return e;return e.substring(0,r)+n+e.substring(r+t.length)},Us=(e,t,n)=>{if(t.includes(X.SINGLE_PARAM))return Se(e,X.SINGLE_PARAM,`x => ${n}`);if(t.includes(X.SORT_COMPARE)){let r=n==="a"?"b":n.replace(/^a\./,"b.");return Se(e,X.SORT_COMPARE,`(a, b) => ${n} - ${r}`)}if(t.includes(X.REDUCE_ACC))return Se(e,X.REDUCE_ACC,`(acc, x) => ${n}`);return e},Vs=(e,t)=>e==="."?t:`${t}${e}`;var $s=g(()=>{Ls()});var Hs=(e)=>{let t=e.matches.length>0,n=e.selectedIndex>=0&&e.selectedIndex<e.matches.length;if(!t||!n)return e;let r=e.matches[e.selectedIndex].item,s={basePath:r.path,baseValue:r.value,baseType:r.type,expression:r.path,currentMethodIndex:0,arrowFnContext:null},o=j(r.type),i=R(o,"",(c)=>c.signature);return Object.assign({},e,{mode:"build",builder:s,query:"",selectedIndex:0,methodMatches:i})},ie=(e)=>Object.assign({},e,{mode:"explore",builder:null,selectedIndex:0}),On=(e,t)=>{if(!e.builder)return e;let n=e.builder,r=j(n.baseType),s=R(r,t,(o)=>o.signature);return Object.assign({},e,{query:t,methodMatches:s,selectedIndex:0})},wn=(e,t)=>{if(!e.builder?.arrowFnContext)return e;let n=e.builder.arrowFnContext,r=R(n.paramPaths,t,(s)=>s.path);return Object.assign({},e,{query:t,propertyMatches:r,selectedIndex:0})},Gs=(e,t)=>{if(!e.builder)return e;let n=e.builder;if(t<0||t>=e.methodMatches.length)return e;let o=e.methodMatches[t].item.template||"";if(_s(o)){let a=n.baseType==="Array"?js(n.baseValue):n.baseValue,u={paramName:Bs(o),paramType:Ds(a),paramValue:a,paramPaths:Xe(a),expression:""},l=R(u.paramPaths,"",(f)=>f.path),p=Object.assign({},n,{currentMethodIndex:t,arrowFnContext:u,expression:n.expression+o});return Object.assign({},e,{mode:"build-arrow-fn",builder:p,query:"",selectedIndex:0,propertyMatches:l})}let i=Object.assign({},n,{expression:n.expression+o,currentMethodIndex:t});return Object.assign({},e,{builder:i})},Ws=(e,t)=>{if(!e.builder?.arrowFnContext)return e;if(t<0||t>=e.propertyMatches.length)return e;let r=e.builder,s=r.arrowFnContext;if(!s)return e;let o=e.propertyMatches[t].item,i=Object.assign({},s,{expression:Vs(o.path,s.paramName)}),c=Object.assign({},r,{arrowFnContext:i});return Object.assign({},e,{builder:c})},Js=(e)=>{if(!e.builder?.arrowFnContext)return e;let t=e.builder,n=t.arrowFnContext;if(!(n&&n.expression))return e;let i=j(t.baseType)[t.currentMethodIndex].template||"",c=Us(t.expression,i,n.expression),a=Object.assign({},t,{expression:c,arrowFnContext:null});return Object.assign({},e,{mode:"build",builder:a,query:"",selectedIndex:0})},Rn=(e)=>{if(!e.builder)return e;let t=e.builder,s=j(t.baseType)[t.currentMethodIndex].template||"",o=Object.assign({},t,{expression:Se(t.expression,s,""),arrowFnContext:null});return Object.assign({},e,{mode:"build",builder:o})},zs=(e)=>{if(!e.builder)return e;let t=e.builder,n=t.expression;if(n===t.basePath)return ie(e);let r=n.lastIndexOf(".");if(r===-1)return ie(e);let s=n.substring(0,r);if(!s||s===t.basePath)return ie(e);let o=Object.assign({},t,{expression:s}),i=j(t.baseType),c=R(i,"",(a)=>a.signature);return Object.assign({},e,{builder:o,methodMatches:c,query:"",selectedIndex:0})};var Qs=g(()=>{hn();$s()});var v,kc=(e)=>{let t=e===v.CTRL_C,n=e===v.ESCAPE;return t||n||e==="q"},In=(e)=>e===v.ENTER,vn=(e)=>e===v.TAB,Mn=(e)=>e===v.UP,Cn=(e)=>e===v.DOWN,Ks=(e)=>e===v.LEFT,Ys=(e)=>e===v.RIGHT,Pn=(e)=>e===v.BACKSPACE,Fn=(e)=>{let t=e>=" ",n=e<="~";return t&&n},Lc=(e,t)=>{if(vn(t))return{state:Hs(e),output:null};if(In(t)){let n=ys(e);if(n)return{state:null,output:JSON.stringify(n.value,null,2)};if(e.query.length>0)return{state:null,output:e.query};return{state:null,output:null}}if(Mn(t))return{state:K(e,-1),output:null};if(Cn(t))return{state:K(e,1),output:null};if(Pn(t)){let n=e.query.slice(0,-1);return{state:bn(e,n),output:null}}if(Fn(t)){let n=e.query.concat(t);return{state:bn(e,n),output:null}}return{state:e,output:null}},_c=(e,t)=>{if(t===v.ESCAPE)return{state:ie(e),output:null};if(In(t)){if(!e.builder)return{state:e,output:null};return{state:null,output:e.builder.expression}}if(Ys(t)||vn(t)){if(!e.builder)return{state:e,output:null};return{state:Gs(e,e.selectedIndex),output:null}}if(Ks(t))return{state:zs(e),output:null};if(Mn(t))return{state:K(e,-1),output:null};if(Cn(t))return{state:K(e,1),output:null};if(Pn(t)){let n=e.query.slice(0,-1);return{state:On(e,n),output:null}}if(Fn(t)){let n=e.query.concat(t);return{state:On(e,n),output:null}}return{state:e,output:null}},Bc=(e,t)=>{if(t===v.ESCAPE)return{state:Rn(e),output:null};if(In(t)){if(!e.builder)return{state:e,output:null};return{state:null,output:e.builder.expression}}if(Ys(t)||vn(t)){let n=Ws(e,e.selectedIndex);return{state:Js(n),output:null}}if(Ks(t))return{state:Rn(e),output:null};if(Mn(t))return{state:K(e,-1),output:null};if(Cn(t))return{state:K(e,1),output:null};if(Pn(t)){let n=e.query.slice(0,-1);return{state:wn(e,n),output:null}}if(Fn(t)){let n=e.query.concat(t);return{state:wn(e,n),output:null}}return{state:e,output:null}},Dc,Xs=(e,t)=>{let n=t.toString();if(kc(n)){if(e.mode==="build"||e.mode==="build-arrow-fn")return{state:ie(e),output:null};return{state:null,output:null}}let r=Dc[e.mode];return r(e,n)};var qs=g(()=>{Tn();Qs();v=Object.assign({},{CTRL_C:"\x03",ESCAPE:"\x1B",ENTER:"\r",TAB:"\t",UP:"\x1B[A",DOWN:"\x1B[B",LEFT:"\x1B[D",RIGHT:"\x1B[C",BACKSPACE:"\x7F"}),Dc={explore:Lc,build:_c,"build-arrow-fn":Bc}});var Zs={};E(Zs,{runInteractive:()=>$c});import{stdin as kn,stdout as be,exit as Te}from"process";var Ln=!1,it=()=>{if(Ln)Ts(),Es(),Ln=!1;Y()},_n=(e)=>{it();let t=e instanceof Error?e.message:String(e),n=m(`Fatal error: ${t}
|
|
76
|
+
`,d.yellow);be.write(n),Te(1)},jc=()=>{process.on("uncaughtException",_n),process.on("unhandledRejection",_n),process.on("SIGINT",()=>{it(),Te(0)}),process.on("SIGTERM",()=>{it(),Te(0)})},Uc=(e,t)=>{return Xs(e,t)},Vc=async(e)=>{let t=e;return new Promise((n)=>{let r=(s)=>{let{state:o,output:i}=Uc(t,s);if(i!==null){kn.off("data",r),n(i);return}if(o===null){kn.off("data",r),n(null);return}t=o,En(t)};kn.on("data",r)})},$c=async(e)=>{jc();let t=Xe(e);if(!(t.length>0)){let s=m(`No paths found in data
|
|
77
|
+
`,d.yellow);be.write(s),Te(1)}let r=gs(t,e);As(),Ln=!0,bs(),En(r);try{let s=await Vc(r);if(it(),s!==null)try{let i=$(s),a=new G(i).tokenize(),l=new J(a).parse(),f=new z().evaluate(l,e),x=JSON.stringify(f,null,2);be.write(x),be.write(`
|
|
78
|
+
`)}catch(i){let c=i instanceof Error?i.message:String(i);be.write(m("Error: "+c+`
|
|
79
|
+
`,d.yellow))}Te(0)}catch(s){_n(s)}};var eo=g(()=>{Tn();ks();qs();st();Le();je();Qe();ae()});var Bn=["json","yaml","csv","table"],Dn=["json","yaml","toml","csv","tsv","lines","text"],oo=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".incl",full:".includes",description:"Check if includes",type:"array"}];var at=(e,t)=>{let r=oo.filter((s)=>s.type===e).map((s)=>` ${s.short.padEnd(6)} -> ${s.full.padEnd(14)} ${s.description}`);return`${t}:
|
|
69
80
|
${r.join(`
|
|
70
|
-
`)}`},
|
|
81
|
+
`)}`},Kc=`Expression Shortcuts:
|
|
71
82
|
|
|
72
|
-
${
|
|
83
|
+
${at("array","Array Methods")}
|
|
73
84
|
|
|
74
|
-
${
|
|
85
|
+
${at("object","Object Methods")}
|
|
75
86
|
|
|
76
|
-
${
|
|
77
|
-
`;var
|
|
87
|
+
${at("string","String Methods")}
|
|
88
|
+
`;var jn=Bn,Un=[...Dn],Vn={format:"json",pretty:!1,raw:!1,compact:!1,type:!1,recursive:!1,ignoreCase:!1,showLineNumbers:!1,inputFormat:void 0,slurp:!1,nullInput:!1};ce();ae();var mo=Object.values(h),fo=M.map((e)=>e.short);function Wn(e){let t={...Vn},n=0;while(n<e.length){let r=e[n];switch(r){case"--help":case"-h":t.help=!0;break;case"--version":case"-v":t.version=!0;break;case"--raw":case"-r":t.raw=!0;break;case"--pretty":case"-p":t.pretty=!0;break;case"--compact":case"-c":t.compact=!0;break;case"--type":case"-t":t.type=!0;break;case"--format":if(n++,n<e.length){let c=e[n],a=jn.includes(c);if(c&&a)t.format=c}break;case"--input-format":case"-if":if(n++,n<e.length){let c=e[n];if(Un.includes(c))t.inputFormat=c}break;case"readFile":t.readFile=!0,n+=2;break;case"--find":case"-f":if(n++,n<e.length)t.find=e[n];break;case"--grep":case"-g":if(n++,n<e.length)t.grep=e[n];break;case"--list":case"-l":if(n++,n<e.length)t.list=e[n];break;case"--recursive":case"-R":t.recursive=!0;break;case"--interactive":t.interactive=!0;break;case"--ignore-case":case"-i":t.ignoreCase=!0;break;case"--line-numbers":case"-n":t.showLineNumbers=!0;break;case"--ext":if(n++,n<e.length){let c=e[n].split(",");t.extensions=c.map((a)=>a.startsWith(".")?a:`.${a}`)}break;case"--max-depth":if(n++,n<e.length)t.maxDepth=parseInt(e[n],10);break;case"--shorten":if(n++,n<e.length)t.shorten=e[n];break;case"--expand":if(n++,n<e.length)t.expand=e[n];break;case"--shortcuts":t.shortcuts=!0;break;case"--detect":t.detect=!0;break;case"--strict":case"-s":t.strict=!0;break;case"--slurp":case"-S":t.slurp=!0;break;case"--null-input":case"-N":t.nullInput=!0;break;default:let s=r.startsWith(".")||r.startsWith("["),o=mo.some((c)=>r.startsWith(`${c}(`)),i=fo.some((c)=>r.startsWith(`${c}(`));if(s||o||i)t.expression=r;break}n++}return t}function lt(){console.log(`
|
|
78
89
|
1ls - 1 line script for JSON manipulation and file operations
|
|
79
90
|
|
|
80
91
|
Usage:
|
|
@@ -148,15 +159,21 @@ Examples:
|
|
|
148
159
|
1ls --shorten ".map(x => x * 2)" # Convert to shorthand
|
|
149
160
|
1ls --expand ".mp(x => x * 2)" # Convert to full form
|
|
150
161
|
1ls --shortcuts # Show all shortcuts
|
|
151
|
-
`)}
|
|
152
|
-
`)
|
|
153
|
-
${
|
|
154
|
-
|
|
155
|
-
`)
|
|
156
|
-
${i}
|
|
157
|
-
`)}return
|
|
158
|
-
`)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
`)}
|
|
162
|
-
|
|
162
|
+
`)}H();function Ei(e){return e.trim().split(`
|
|
163
|
+
`).filter((t)=>t.length>0)}async function Fe(e,t){switch(t??Ot(e)){case"json":try{return JSON.parse(e)}catch(r){let s=e.length>50?e.slice(0,50)+"...":e;throw Error(`Invalid JSON: ${r.message}
|
|
164
|
+
Input: ${s}`)}case"json5":{let{parseJSON5:r}=await Promise.resolve().then(() => (nr(),tr));return r(e)}case"yaml":{let{parseYAML:r}=await Promise.resolve().then(() => (hr(),pr));return r(e)}case"toml":{let{parseTOML:r}=await Promise.resolve().then(() => (mr(),dr));return r(e)}case"xml":{let{parseXML:r}=await Promise.resolve().then(() => (yr(),gr));return r(e)}case"ini":{let{parseINI:r}=await Promise.resolve().then(() => (Tr(),br));return r(e)}case"csv":{let{parseCSV:r}=await Promise.resolve().then(() => (Nt(),Et));return r(e)}case"tsv":{let{parseTSV:r}=await Promise.resolve().then(() => (Nt(),Et));return r(e)}case"protobuf":{let{parseProtobuf:r}=await Promise.resolve().then(() => Nr);return r(e)}case"javascript":{let{parseJavaScript:r}=await Promise.resolve().then(() => Mr);return r(e)}case"typescript":{let{parseTypeScript:r}=await Promise.resolve().then(() => (Pr(),Cr));return r(e)}case"env":{let{parseENV:r}=await Promise.resolve().then(() => (Lr(),kr));return r(e)}case"ndjson":{let{parseNDJSON:r}=await Promise.resolve().then(() => _r);return r(e)}case"lines":return Ei(e);case"text":default:{if(/^\s*[{[]/.test(e))try{return JSON.parse(e)}catch(s){let o=e.length>50?e.slice(0,50)+"...":e;throw Error(`Invalid JSON: ${s.message}
|
|
165
|
+
Input: ${o}`)}return e}}}var Ni=(e)=>{let t=e.trim();if(!t)return!0;try{return JSON.parse(t),!0}catch{return!1}},Br=(e,t)=>(e.match(t)||[]).length;function Oi(e){let t=e.split(`
|
|
166
|
+
`),n=b.NDJSON_FEATURES.test(e),r=t.every(Ni);if(n&&r)return"ndjson";let o=t[0],i=Br(o,/,/g),c=Br(o,/\t/g);if(c>0&&c>=i)return"tsv";if(i>0)return"csv";return"lines"}function wi(e){if(b.ENV_FEATURES.test(e))return"env";if(b.TOML_QUOTED_VALUES.test(e))return"toml";let r=b.SECTION_HEADER.test(e),s=b.TOML_SECTION.test(e),o=b.TOML_SYNTAX.test(e);if(r&&s&&o)return"toml";let c=b.INI_SYNTAX.test(e);if(r&&c)return"ini";if(c)return"ini";return"text"}var Ri=(e)=>{try{return JSON.parse(e),"json"}catch{return b.JSON5_FEATURES.test(e)?"json5":null}},Ii=(e,t,n)=>{if(t==="{"&&n==="}"||t==="["&&n==="]")return Ri(e);return null},vi=(e)=>{let t=e.startsWith("<?xml"),n=/<\/\w+>/.test(e);return t||n?"xml":null},Mi=(e)=>b.TS_INTERFACE.test(e)||b.TS_TYPE_ALIAS.test(e)||b.TS_TYPE_ANNOTATION.test(e),Ci=(e)=>{if(!b.JS_EXPORT.test(e))return null;return Mi(e)?"typescript":"javascript"},Pi=(e,t,n)=>{switch(t){case"{":case"[":return Ii(e,t,n);case"<":return vi(e);case"-":return e.startsWith("---")?"yaml":null;case"e":return Ci(e);case"i":return b.TS_INTERFACE.test(e)?"typescript":null;case"t":return b.TS_TYPE_ALIAS.test(e)?"typescript":null;case"c":case"l":case"v":return b.TS_TYPE_ANNOTATION.test(e)?"typescript":null;default:return null}},Fi=(e)=>{if(e.includes("="))return wi(e);let n=e.includes(": "),r=/^[\s]*-\s+/m.test(e);if(n||r)return"yaml";if(e.includes(`
|
|
167
|
+
`))return Oi(e);return null};function Ot(e){let t=e.trim();if(!t)return"text";let n=t[0],r=t[t.length-1],s=Pi(t,n,r);if(s)return s;let o=Fi(t);if(o)return o;return"text"}async function Dr(e){let t=[];for await(let r of process.stdin)t.push(r);let n=Buffer.concat(t).toString("utf-8").trim();if(!n)return null;return Fe(n,e)}var jr=[".ts",".js",".tsx",".jsx"],Ur=[".json",".yml",".yaml"],Vr=[".md",".txt"],wt=[...jr,...Ur,...Vr];async function te(e,t=!0){let r=await Bun.file(e).text();if(!t)return r;return Fe(r)}import{stat as ki}from"fs/promises";import{extname as Li,basename as _i}from"path";var $r=(e,t)=>({path:e,name:_i(e),ext:Li(e),size:Number(t.size),isDirectory:t.isDirectory(),isFile:t.isFile(),modified:t.mtime,created:t.birthtime}),Rt=async(e)=>{let t=await ki(e);return $r(e,t)};var Hr=(e)=>e.startsWith("."),It=(e,t)=>t||!Hr(e),Gr=(e,t)=>{return t===void 0||t.includes(e)},Wr=(e,t)=>{return t===void 0||t.test(e)},vt=(e,t,n)=>{let r=Gr(e.ext,t),s=Wr(e.name,n);return r&&s},Mt=(e,t)=>{return e<=(t??1/0)};import{readdir as Bi}from"fs/promises";import{join as Di}from"path";var Jr=async(e,t,n,r)=>{if(!It(t,r.includeHidden??!1))return[];let o=Di(e,t),i=await Rt(o);if(i.isFile)return vt(i,r.extensions,r.pattern)?[i]:[];if(!i.isDirectory)return[];let a=r.recursive===!0?await Ct(o,n+1,r):[];return[i,...a]},Ct=async(e,t,n)=>{if(!Mt(t,n.maxDepth))return[];let s=await Bi(e);return(await Promise.all(s.map((i)=>Jr(e,i,t,n)))).flat()},pe=async(e,t={})=>Ct(e,0,t);import{stat as ji}from"fs/promises";var zr=(e,t)=>{if(typeof e!=="string")return e;return new RegExp(e,t?"gi":"g")},Qr=(e,t,n,r,s,o)=>{let i={file:e,line:t+1,column:n+1,match:r};if(o===void 0)return i;let a=Math.max(0,t-o),u=Math.min(s.length,t+o+1);return{...i,context:s.slice(a,u)}},Kr=(e,t,n)=>{if(!n)return;let r=t instanceof Error?t.message:String(t);console.error(`Failed to search ${e}: ${r}`)},Yr=(e,t,n,r,s,o)=>[...e.matchAll(n)].map((i)=>Qr(r,t,i.index,e,s,o));var Pt=async(e,t,n)=>{try{let r=await te(e,!1);if(typeof r!=="string")return[];let o=r.split(`
|
|
168
|
+
`),i=o.flatMap((a,u)=>Yr(a,u,t,e,o,n.context)),c=n.maxMatches??1/0;return i.slice(0,c)}catch(r){return Kr(e,r,n.verbose??!1),[]}},Xr=async(e,t,n)=>{let r=await pe(e,{recursive:!0,extensions:[...wt]});return(await Promise.all(r.filter((o)=>o.isFile).map((o)=>Pt(o.path,t,n)))).flat()};async function Ft(e,t,n={}){let r=zr(e,n.ignoreCase??!1),s=await ji(t);if(s.isFile())return Pt(t,r,n);if(s.isDirectory()&&n.recursive)return Xr(t,r,n);return[]}Le();je();Qe();var T={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"},$i=[{regex:/"([^"]+)":/g,replacement:`${T.cyan}"$1"${T.reset}:`},{regex:/: "([^"]*)"/g,replacement:`: ${T.green}"$1"${T.reset}`},{regex:/: (-?\d+\.?\d*)/g,replacement:`: ${T.yellow}$1${T.reset}`},{regex:/: (true|false)/g,replacement:`: ${T.magenta}$1${T.reset}`},{regex:/: (null)/g,replacement:`: ${T.gray}$1${T.reset}`},{regex:/([{[])/g,replacement:`${T.gray}$1${T.reset}`},{regex:/([}\]])/g,replacement:`${T.gray}$1${T.reset}`}];function us(e){if(process.env.NO_COLOR)return e;return $i.reduce((t,{regex:n,replacement:r})=>t.replace(n,r),e)}function ls(e){if(process.env.NO_COLOR)return e;return`${T.yellow}${e}${T.reset}`}function en(e){if(process.env.NO_COLOR)return e;return`${T.cyan}${e}${T.reset}`}class ge{options;constructor(e){this.options=e}format(e){if(this.options.raw)return this.formatRaw(e);if(this.options.type)return this.formatWithType(e);switch(this.options.format){case"yaml":return this.formatYaml(e);case"csv":return this.formatCsv(e);case"table":return this.formatTable(e);default:return this.formatJson(e)}}formatRaw(e){if(typeof e==="string")return e;if(e===void 0)return"";if(e===null)return"null";if(typeof e==="object")return JSON.stringify(e);return String(e)}formatJson(e){if(e===void 0)return"undefined";if(this.options.compact)return JSON.stringify(e);if(this.options.pretty){let t=JSON.stringify(e,null,2);return us(t)}return JSON.stringify(e,null,2)}formatWithType(e){let t=Array.isArray(e)?"array":typeof e,n=this.formatJson(e);return`[${t}] ${n}`}formatYaml(e){return this.toYaml(e,0)}toYaml(e,t){let n=" ".repeat(t);if(e===null||e===void 0)return"null";if(typeof e==="string")return e.includes(`
|
|
169
|
+
`)||e.includes('"')||e.includes("'")?`|
|
|
170
|
+
${n} ${e.replace(/\n/g,`
|
|
171
|
+
`+n+" ")}`:e;if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e)){if(e.length===0)return"[]";return e.map((r)=>`${n}- ${this.toYaml(r,t+2).trim()}`).join(`
|
|
172
|
+
`)}if(typeof e==="object"){let r=Object.entries(e);if(r.length===0)return"{}";return r.map(([s,o])=>{let i=this.toYaml(o,t+2);if(typeof o==="object"&&o!==null)return`${n}${s}:
|
|
173
|
+
${i}`;return`${n}${s}: ${i}`}).join(`
|
|
174
|
+
`)}return String(e)}formatCsv(e){if(!Array.isArray(e))return this.formatJson(e);if(e.length===0)return"";if(typeof e[0]==="object"&&e[0]!==null&&!Array.isArray(e[0])){let t=Object.keys(e[0]),n=t.join(","),r=e.map((s)=>t.map((o)=>this.escapeCsvValue(s[o])).join(","));return[n,...r].join(`
|
|
175
|
+
`)}return e.map((t)=>this.escapeCsvValue(t)).join(`
|
|
176
|
+
`)}escapeCsvValue(e){if(e===null||e===void 0)return"";let t=String(e);if(t.includes(",")||t.includes('"')||t.includes(`
|
|
177
|
+
`))return`"${t.replace(/"/g,'""')}"`;return t}formatTable(e){if(!Array.isArray(e))return this.formatJson(e);if(e.length===0)return"(empty array)";if(typeof e[0]==="object"&&e[0]!==null&&!Array.isArray(e[0]))return this.formatObjectTable(e);return e.map((t,n)=>`${n}: ${this.formatRaw(t)}`).join(`
|
|
178
|
+
`)}formatObjectTable(e){let t=[...new Set(e.flatMap((i)=>Object.keys(i)))],n={};t.forEach((i)=>{n[i]=Math.max(i.length,...e.map((c)=>String(c[i]??"").length))});let r=t.map((i)=>i.padEnd(n[i])).join(" | "),s=t.map((i)=>"-".repeat(n[i])).join("-+-"),o=e.map((i)=>t.map((c)=>String(i[c]??"").padEnd(n[c])).join(" | "));return[r,s,...o].join(`
|
|
179
|
+
`)}}ae();var ps="0.1.14";var Hc=()=>Promise.resolve().then(() => (eo(),Zs));async function Gc(e){let t=await Ft(e.grep,e.find,{recursive:e.recursive,ignoreCase:e.ignoreCase,showLineNumbers:e.showLineNumbers});if(t.length===0){console.log(ls("No matches found"));return}for(let n of t){let r=`${en(n.file)}:${n.line}:${n.column}`,s=e.showLineNumbers?`${r}: ${n.match}`:`${en(n.file)}: ${n.match}`;console.log(s)}}async function Wc(e,t){if(e.readFile){let o=t[t.indexOf("readFile")+1],i=await te(o),c=t[t.indexOf("readFile")+2];return e.expression=c?.startsWith("-")?".":c||".",i}let n=!process.stdin.isTTY,r=e.list||e.grep;if(!n&&!r)lt(),process.exit(1);if(n)return await Dr(e.inputFormat);return null}async function to(e,t){if(!e.expression){let n=new ge(e);console.log(n.format(t));return}try{let n=$(e.expression),s=new G(n).tokenize(),i=new J(s).parse(),a=new z({strict:e.strict}).evaluate(i,t),u=new ge(e);console.log(u.format(a))}catch(n){let r=n instanceof Error?n.message:String(n);console.error("Error:",r),process.exit(1)}}async function Jc(e){let t=Wn(e);if(t.help)lt(),process.exit(0);if(t.version)console.log(`1ls version ${ps}`),process.exit(0);if(t.shortcuts)console.log(Gn()),process.exit(0);if(t.shorten)console.log(Hn(t.shorten)),process.exit(0);if(t.expand)console.log($(t.expand)),process.exit(0);if(t.detect){if(!!process.stdin.isTTY)console.error("Error: --detect requires input from stdin"),process.exit(1);let s=await Bun.stdin.text(),o=Ot(s);console.log(o),process.exit(0)}if(t.list){let r=await pe(t.list,{recursive:t.recursive,extensions:t.extensions,maxDepth:t.maxDepth});console.log(new ge(t).format(r));return}if(t.grep&&t.find){await Gc(t);return}if(t.readFile){let r=e[e.indexOf("readFile")+1],s=await te(r),o=e[e.indexOf("readFile")+2],i=o?.startsWith("-")?".":o||".",c=i===".";if(t.interactive||c){let{runInteractive:u}=await Hc();await u(s);return}t.expression=i,await to(t,s);return}if(t.interactive)console.error("Error: Interactive mode requires a file path. Use: 1ls readFile <path>"),process.exit(1);let n=await Wc(t,e);await to(t,n)}if(import.meta.main)Jc(process.argv.slice(2)).catch((e)=>{console.error("Error:",e.message),process.exit(1)});export{to as processExpression,Jc as main,Wc as loadData,Gc as handleGrepOperation,Hc as getInteractive};
|