1ls 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +279 -11
  2. package/dist/browser/constants.d.ts +1 -1
  3. package/dist/browser/index.js +11 -11
  4. package/dist/cli/constants.d.ts +1 -1
  5. package/dist/{utils → cli}/stream.d.ts +1 -1
  6. package/dist/completions/1ls.bash +10 -18
  7. package/dist/completions/1ls.zsh +69 -7
  8. package/dist/{shared/constants.d.ts → constants.d.ts} +1 -1
  9. package/dist/expression/constants.d.ts +2 -0
  10. package/dist/expression/index.d.ts +3 -12
  11. package/dist/expression/utils.d.ts +14 -1
  12. package/dist/file/constants.d.ts +4 -0
  13. package/dist/file/filters.d.ts +7 -0
  14. package/dist/file/grep.d.ts +10 -0
  15. package/dist/file/index.d.ts +7 -0
  16. package/dist/file/info.d.ts +4 -0
  17. package/dist/file/io.d.ts +5 -0
  18. package/dist/{utils → file}/types.d.ts +0 -17
  19. package/dist/file/walk.d.ts +4 -0
  20. package/dist/formats/index.d.ts +1 -1
  21. package/dist/formats/types.d.ts +1 -0
  22. package/dist/formats/yaml/index.d.ts +2 -0
  23. package/dist/formats/yaml/types.d.ts +8 -0
  24. package/dist/formats/yaml/utils.d.ts +28 -0
  25. package/dist/index.js +83 -63
  26. package/dist/interactive/builder/constants.d.ts +14 -0
  27. package/dist/interactive/{builder.d.ts → builder/index.d.ts} +1 -1
  28. package/dist/interactive/builder/types.d.ts +4 -0
  29. package/dist/interactive/builder/utils.d.ts +7 -0
  30. package/dist/interactive/methods/constants.d.ts +10 -0
  31. package/dist/interactive/methods/index.d.ts +4 -0
  32. package/dist/interactive/methods/types.d.ts +8 -0
  33. package/dist/interactive/preview/constants.d.ts +4 -0
  34. package/dist/interactive/preview/index.d.ts +5 -0
  35. package/dist/interactive/preview/types.d.ts +6 -0
  36. package/dist/interactive/tooltip/constants.d.ts +3 -0
  37. package/dist/interactive/tooltip/index.d.ts +20 -0
  38. package/dist/interactive/tooltip/types.d.ts +13 -0
  39. package/dist/interactive/types.d.ts +5 -7
  40. package/dist/{utils/logger.d.ts → logger.d.ts} +10 -1
  41. package/dist/navigator/builtins/constants.d.ts +62 -0
  42. package/dist/navigator/builtins/index.d.ts +6 -0
  43. package/dist/navigator/builtins/types.d.ts +3 -0
  44. package/dist/navigator/builtins/utils.d.ts +12 -0
  45. package/dist/navigator/json/constants.d.ts +2 -0
  46. package/dist/navigator/json/index.d.ts +22 -0
  47. package/dist/navigator/json/types.d.ts +3 -0
  48. package/dist/navigator/json/utils.d.ts +14 -0
  49. package/dist/shortcuts/constants.d.ts +15 -0
  50. package/dist/shortcuts/index.d.ts +9 -0
  51. package/dist/shortcuts/types.d.ts +6 -0
  52. package/dist/types.d.ts +22 -2
  53. package/dist/version.d.ts +1 -0
  54. package/package.json +5 -3
  55. package/dist/formats/yaml.d.ts +0 -3
  56. package/dist/interactive/methods.d.ts +0 -12
  57. package/dist/navigator/json.d.ts +0 -26
  58. package/dist/utils/constants.d.ts +0 -12
  59. package/dist/utils/file.d.ts +0 -27
  60. package/dist/utils/index.d.ts +0 -7
  61. package/dist/utils/shortcuts.d.ts +0 -8
package/dist/index.js CHANGED
@@ -1,78 +1,91 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var br=Object.defineProperty;var O=(t,e)=>{for(var n in e)br(t,n,{get:e[n],enumerable:!0,configurable:!0,set:(r)=>e[n]=()=>r})};var x=(t,e)=>()=>(t&&(e=t(t=0)),e);var Sr,wr,Er,Ar,Ne,Tr,Nr,Or,vr,Ir,Rr,Cr,Fr,Mr,Lr,kr,Pr,_r,Br,Ft,Mt,M,Oe,Lt,jr,Dr,Vr,$r,Gr,Wr,E;var V=x(()=>{Sr=/^-?\d+$/,wr=/^[+-]?\d+$/,Er=/^-?\d+\.\d+$/,Ar=/^[+-]?\d+\.\d+$/,Ne=/^-?\d+(\.\d+)?$/,Tr=/(\w+)=["']([^"']+)["']/g,Nr=/^<(\w+)([^>]*?)\/>/,Or=/^<(\w+)([^>]*)>([\s\S]*)<\/\1>$/,vr=/<\w+/,Ir=/<\/\w+>$/,Rr=/^<\?xml[^>]+\?>\s*/,Cr=/,(\s*[}\]])/g,Fr=/(['"])?([a-zA-Z_$][a-zA-Z0-9_$]*)\1?\s*:/g,Mr=/\/\/|\/\*|,\s*[}\]]/,Lr=/^\[[\w.\s]+\]$/m,kr=/^\[[\w.]+\]$/m,Pr=/^\w+\s*=\s*"[^"]*"$/m,_r=/=\s*["[{]/m,Br=/^\w+\s*=\s*.+$/m,Ft={INTEGER:Sr,FLOAT:Er},Mt={INTEGER:wr,FLOAT:Ar},M={NUMBER:Ne,ATTRIBUTES:Tr,SELF_CLOSING:Nr,OPEN_TAG:Or,NESTED_TAGS:vr,COMPLETE_TAGS:Ir,XML_DECLARATION:Rr},Oe={NUMBER:Ne},Lt={TRAILING_COMMA:Cr,UNQUOTED_KEY:Fr},jr=/^\s*export\s+(const|let|var|function|class|default|type|interface|enum)/m,Dr=/:\s*(string|number|boolean|any|unknown|void|never|object|Array|Promise)/,Vr=/^\s*interface\s+\w+/m,$r=/^\s*type\s+\w+\s*=/m,Gr=/^[A-Z_][A-Z0-9_]*\s*=/m,Wr=/^\{.*\}\s*$/m,E={JSON5_FEATURES:Mr,SECTION_HEADER:Lr,TOML_SECTION:kr,TOML_QUOTED_VALUES:Pr,TOML_SYNTAX:_r,INI_SYNTAX:Br,JS_EXPORT:jr,TS_TYPE_ANNOTATION:Dr,TS_INTERFACE:Vr,TS_TYPE_ALIAS:$r,ENV_FEATURES:Gr,NDJSON_FEATURES:Wr}});var ke={};O(ke,{stripJSON5Comments:()=>Me,parseJSON5:()=>Ur,normalizeJSON5:()=>Le,isQuoteChar:()=>ve,handleStringChar:()=>Ce,handleNormalChar:()=>Fe,findMultiLineCommentEnd:()=>Re,findCommentEnd:()=>Ie});function ve(t){return t==='"'||t==="'"}function Ie(t,e,n){let o=t.slice(e).findIndex((i)=>i===n);return o===-1?t.length-e:o}function Re(t,e){let n=2,r=t.length-e;while(n<r){let o=t[e+n],s=t[e+n+1];if(o==="*"&&s==="/")return n+1;n++}return n}function Ce(t,e,n){if(t.result.push(e),e==="\\"&&n)return t.result.push(n),{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:1};if(e===t.delimiter)return{result:t.result,inString:!1,delimiter:"",skip:0};return t}function Fe(t,e,n,r,o){if(ve(e))return t.result.push(e),{result:t.result,inString:!0,delimiter:e,skip:0};if(e==="/"&&n==="/"){let a=Ie(r,o,`
4
- `);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}if(e==="/"&&n==="*"){let a=Re(r,o);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}return t.result.push(e),t}function Me(t){let e=t.split("");return e.reduce((n,r,o)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let i=e[o+1];return n.inString?Ce(n,r,i):Fe(n,r,i,e,o)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function Le(t){let e=Me(t);return e=e.replace(Lt.TRAILING_COMMA,"$1"),e=e.replace(Lt.UNQUOTED_KEY,'"$2":'),e=e.replace(/'/g,'"'),e}function Ur(t){let e=Le(t);return JSON.parse(e)}var Pe=x(()=>{V()});var Jr,zr,Qr,Hr=(t)=>Jr.includes(t),Kr=(t)=>zr.includes(t),Xr=(t)=>Qr.includes(t),Q=(t)=>{if(Hr(t))return!0;if(Kr(t))return!1;return},H=(t)=>{if(Xr(t))return null;return},lt=(t)=>{if(t==="")return;let e=Number(t);return isNaN(e)?void 0:e};var pt=x(()=>{Jr=["true","yes","on"],zr=["false","no","off"],Qr=["null","~",""]});var Be={};O(Be,{parseYAMLValue:()=>K,parseYAML:()=>ts,findPreviousKey:()=>_e});function qr(t){if(t.startsWith("!!")){let e=t.indexOf(" ");if(e>0)return{tag:t.substring(2,e),content:t.substring(e+1)}}return{tag:null,content:t}}function K(t){let{tag:e,content:n}=qr(t);if(e==="str")return n;let r=n.startsWith('"')&&n.endsWith('"'),o=n.startsWith("'")&&n.endsWith("'");if(r||o)return n.slice(1,-1);let i=Q(n);if(i!==void 0)return i;let c=H(n);if(c!==void 0)return c;if(Ft.INTEGER.test(n))return parseInt(n,10);if(Ft.FLOAT.test(n))return parseFloat(n);if(n.startsWith("[")&&n.endsWith("]"))return n.slice(1,-1).split(",").map((d)=>K(d.trim()));if(n.startsWith("{")&&n.endsWith("}")){let d={};return n.slice(1,-1).split(",").forEach((N)=>{let[T,y]=N.split(":").map((b)=>b.trim());if(T&&y)d[T]=K(y)}),d}return n}function _e(t,e){return Array.from({length:e},(r,o)=>e-1-o).reduce((r,o)=>{if(r!==null)return r;let s=t[o],i=s.indexOf("#");if(i>=0){let l=s.substring(0,i);if((l.match(/["']/g)||[]).length%2===0)s=l}let a=s.trim();if(a&&!a.startsWith("-")&&a.includes(":")){let l=a.indexOf(":"),p=a.substring(0,l).trim(),d=a.substring(l+1).trim();if(!d||d==="|"||d===">"||d==="|+"||d===">-")return p}return null},null)}function kt(t){let e=t.indexOf("#");if(e<0)return t;let n=t.substring(0,e);return(n.match(/["']/g)||[]).length%2===0?n:t}function Yr(t){let e=t.indexOf(":");if(e<=0)return!1;let n=t.substring(0,e);return!n.includes(" ")||n.startsWith('"')||n.startsWith("'")}function Pt(t){return t.length-t.trimStart().length}function Zr(t,e,n,r){let o=[],s=e;while(s<t.length){let c=t[s];if(!c.trim()){o.push(""),s++;continue}if(Pt(c)<=n)break;o.push(c.substring(n+2)),s++}while(o.length>0&&o[o.length-1]==="")o.pop();return{value:r==="|"?o.join(`
5
- `):o.join(" ").replace(/\s+/g," ").trim(),endIdx:s-1}}function _t(t,e){if(typeof t==="string"&&t.startsWith("*")){let n=t.substring(1);return e[n]!==void 0?e[n]:t}if(Array.isArray(t))return t.map((n)=>_t(n,e));if(typeof t==="object"&&t!==null){let n={};for(let[r,o]of Object.entries(t))if(r==="<<"&&typeof o==="string"&&o.startsWith("*")){let s=o.substring(1),i=e[s];if(typeof i==="object"&&i!==null&&!Array.isArray(i))Object.assign(n,i)}else n[r]=_t(o,e);return n}return t}function ts(t){let e=t.trim().split(`
6
- `),n={},s=e.find((u)=>{let l=kt(u).trim();return l&&l!=="---"&&l!=="..."})?.trim().startsWith("- ")?[]:{},i=[{container:s,indent:-1}];function c(){return i[i.length-1]}function a(u){while(i.length>1&&u(c()))i.pop()}for(let u=0;u<e.length;u++){let l=e[u],p=kt(l),d=p.trim();if(!d||d==="---"||d==="...")continue;let h=Pt(p);if(d.startsWith("- ")||d==="-"){let y=d==="-"?"":d.substring(2).trim();a((w)=>w.indent>h||w.indent>=h&&!Array.isArray(w.container));let g,b=c();if(Array.isArray(b.container)&&(b.indent===h||b.indent===-1&&h===0)){if(g=b.container,b.indent===-1)b.indent=h}else{if(g=[],b.pendingKey)b.container[b.pendingKey]=g,b.pendingKey=void 0;else if(!Array.isArray(b.container)){let w=_e(e,u);if(w)b.container[w]=g}i.push({container:g,indent:h})}if(Yr(y)){let w=y.indexOf(":"),S=y.substring(0,w).trim(),F=y.substring(w+1).trim(),_=null;if(S.includes(" &")){let z=S.split(" &");S=z[0],_=z[1]}let D={[S]:F?K(F):null};if(g.push(D),_)n[_]=D;i.push({container:D,indent:h+2})}else if(y)g.push(K(y));else{let w={};g.push(w),i.push({container:w,indent:h+2})}continue}let T=d.indexOf(":");if(T>0){let y=d.substring(0,T).trim(),g=d.substring(T+1).trim(),b=null;if(g.startsWith("&")){let S=g.indexOf(" ");if(S>0)b=g.substring(1,S),g=g.substring(S+1);else b=g.substring(1),g=""}a((S)=>S.indent>h||S.indent===h&&Array.isArray(S.container));let C=c(),w=C.container;if(Array.isArray(w))continue;if(g==="|"||g===">"||g==="|+"||g===">-"||g==="|-"||g===">+"){let S=g.startsWith("|")?"|":">",{value:F,endIdx:_}=Zr(e,u+1,h,S);if(w[y]=F,b)n[b]=F;u=_}else if(g){let S=K(g);if(w[y]=S,b)n[b]=S}else{let S=u+1,F=S<e.length,_=F?kt(e[S]):"",D=_.trim(),z=F?Pt(_):-1,gr=D.startsWith("- ")||D==="-",xr=F&&z>h&&D;if(gr&&z>h){if(C.pendingKey=y,b){let Z={};n[b]=Z}}else if(xr){let Z={};if(w[y]=Z,b)n[b]=Z;i.push({container:Z,indent:z})}else if(w[y]=null,b)n[b]=null}}}return _t(s,n)}var je=x(()=>{V();pt()});var De={};O(De,{parseTOMLValue:()=>dt,parseTOML:()=>es});function dt(t){if(t.startsWith('"')&&t.endsWith('"'))return t.slice(1,-1).replace(/\\"/g,'"');if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(Mt.INTEGER.test(t))return parseInt(t,10);if(Mt.FLOAT.test(t))return parseFloat(t);if(t.startsWith("[")&&t.endsWith("]"))return t.slice(1,-1).split(",").map((a)=>dt(a.trim()));if(t.startsWith("{")&&t.endsWith("}")){let c={};return t.slice(1,-1).split(",").forEach((u)=>{let[l,p]=u.split("=").map((d)=>d.trim());if(l&&p)c[l]=dt(p)}),c}return t}function es(t){let e=t.trim().split(`
7
- `),n={},r=n,o=[];return e.forEach((s)=>{let i=s,c=i.indexOf("#");if(c>=0){let d=i.substring(0,c);if((d.match(/["']/g)||[]).length%2===0)i=d}let a=i.trim();if(!a)return;if(a.startsWith("[")&&a.endsWith("]")){let d=a.slice(1,-1).split(".");r=n,o=[],d.forEach((h)=>{if(!r[h])r[h]={};r=r[h],o.push(h)});return}let l=a.indexOf("=");if(l>0){let d=a.substring(0,l).trim(),h=a.substring(l+1).trim();r[d]=dt(h)}}),n}var Ve=x(()=>{V()});var Ge={};O(Ge,{parseXMLValue:()=>tt,parseXMLElement:()=>Bt,parseXMLChildren:()=>$e,parseXMLAttributes:()=>ht,parseXML:()=>ss});function tt(t){let e=t.trim();if(e==="true")return!0;if(e==="false")return!1;if(M.NUMBER.test(e))return parseFloat(e);return e}function ht(t){return Array.from(t.matchAll(M.ATTRIBUTES)).reduce((n,r)=>{let[,o,s]=r;return n[o]=tt(s),n},{})}function Bt(t){let e=t.trim(),n=e.match(M.SELF_CLOSING);if(n){let[,p,d]=n;if(d.trim().length>0)return{[p]:{_attributes:ht(d)}};return{[p]:null}}let r=e.match(M.OPEN_TAG);if(!r)return tt(e);let[,o,s,i]=r,c=i.trim();if(!M.NESTED_TAGS.test(c)){if(s.trim().length>0)return{[o]:{_attributes:ht(s),_text:tt(c)}};return{[o]:tt(c)}}let u=$e(c);if(s.trim().length>0)return{[o]:{_attributes:ht(s),...u}};return{[o]:u}}function ns(t){let e=t.split(""),n=e.reduce((s,i,c)=>{if(s.skip>0)return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:s.skip-1};if(i==="<"){let N=e[c+1]==="/",y=t.slice(c).match(/^<[^>]+\/>/);if(N)return s.buffer.push(i),{elements:s.elements,buffer:s.buffer,depth:s.depth-1,skip:0};if(y){let g=y[0];if(g.split("").forEach((C)=>s.buffer.push(C)),s.depth===0){let C=s.buffer.join("").trim();s.elements.push(C),s.buffer.length=0}return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:g.length-1}}return s.buffer.push(i),{elements:s.elements,buffer:s.buffer,depth:s.depth+1,skip:0}}s.buffer.push(i);let l=s.depth===0,p=s.buffer.join("").trim(),d=p.length>0,h=!i.match(/\s/);if(l&&d&&h){if(p.match(M.COMPLETE_TAGS))s.elements.push(p),s.buffer.length=0}return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:0}},{elements:[],buffer:[],depth:0,skip:0}),r=n.buffer.join("").trim();return r.length>0?[...n.elements,r]:n.elements}function rs(t,e,n){let r=t[e];if(r===void 0){t[e]=n;return}if(Array.isArray(r)){r.push(n);return}t[e]=[r,n]}function $e(t){return ns(t).reduce((n,r)=>{let o=Bt(r);if(typeof o==="object"&&o!==null)Object.entries(o).forEach(([i,c])=>{rs(n,i,c)});return n},{})}function ss(t){let e=t.trim(),n=e.match(M.XML_DECLARATION),r=n?e.slice(n[0].length):e;return Bt(r)}var We=x(()=>{V()});var ze={};O(ze,{stripINIComments:()=>Ue,processINILine:()=>Je,parseINIValue:()=>jt,parseINI:()=>os});function jt(t){let e=t.trim();if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;if(Oe.NUMBER.test(e))return parseFloat(e);return e}function Ue(t){let e=t.indexOf(";"),n=t.indexOf("#");if(!(e>=0||n>=0))return t;let o=e>=0&&n>=0?Math.min(e,n):Math.max(e,n);return t.substring(0,o)}function Je(t,e){let r=Ue(e).trim();if(!r)return t;if(r.startsWith("[")&&r.endsWith("]")){let a=r.slice(1,-1).trim();if(!t.result[a])t.result[a]={};return{result:t.result,currentSection:a}}let i=r.indexOf("=");if(i>0){let a=r.substring(0,i).trim(),u=r.substring(i+1).trim();if(t.currentSection.length>0){let p=t.result[t.currentSection];p[a]=jt(u)}else t.result[a]=jt(u)}return t}function os(t){return t.trim().split(`
8
- `).reduce((r,o)=>Je(r,o),{result:{},currentSection:""}).result}var Qe=x(()=>{V()});var Vt={};O(Vt,{parseTSV:()=>is,parseCSVValue:()=>He,parseCSVLine:()=>Dt,parseCSV:()=>Ke});function Dt(t,e){let n=[],r="",o=!1,s=t.split("");return s.forEach((i,c)=>{let a=s[c+1];if(i==='"'){if(o&&a==='"'){r+='"',s.splice(c+1,1);return}o=!o;return}if(i===e&&!o){n.push(r),r="";return}r+=i}),n.push(r),n.map((i)=>i.trim())}function He(t){let e=t.trim();if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/""/g,'"');let r=lt(e);if(r!==void 0)return r;let o=e.toLowerCase(),s=Q(o);if(s!==void 0)return s;let i=H(o);if(i!==void 0)return i;return e}function Ke(t,e=","){let n=t.trim().split(`
9
- `);if(n.length===0)return[];let r=Dt(n[0],e);if(n.length===1)return[];return n.slice(1).reduce((o,s)=>{let i=Dt(s,e);if(i.length===0)return o;let c=Object.fromEntries(r.map((a,u)=>[a,He(i[u]||"")]));return[...o,c]},[])}function is(t){return Ke(t,"\t")}var $t=x(()=>{pt()});var Xe={};O(Xe,{parseProtobufJSON:()=>as,parseProtobuf:()=>cs});function cs(t){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 as(t){return JSON.parse(t)}var nn={};O(nn,{stripJSComments:()=>mt,parseJavaScript:()=>us,isQuoteChar:()=>qe,handleStringChar:()=>tn,handleNormalChar:()=>en,findMultiLineCommentEnd:()=>Ze,findCommentEnd:()=>Ye});function qe(t){return t==='"'||t==="'"||t==="`"}function Ye(t,e,n){let o=t.slice(e).findIndex((i)=>i===n);return o===-1?t.length-e:o}function Ze(t,e){let n=2,r=t.length-e;while(n<r){let o=t[e+n],s=t[e+n+1];if(o==="*"&&s==="/")return n+1;n++}return n}function tn(t,e,n){if(t.result.push(e),e==="\\"&&n)return t.result.push(n),{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:1};if(e===t.delimiter)return{result:t.result,inString:!1,delimiter:"",skip:0};return t}function en(t,e,n,r,o){if(qe(e))return t.result.push(e),{result:t.result,inString:!0,delimiter:e,skip:0};if(e==="/"&&n==="/"){let a=Ye(r,o,`
10
- `);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}if(e==="/"&&n==="*"){let a=Ze(r,o);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}return t.result.push(e),t}function mt(t){let e=t.split("");return e.reduce((n,r,o)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let i=e[o+1];return n.inString?tn(n,r,i):en(n,r,i,e,o)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function us(t){let e=mt(t),n=e.match(/export\s+default\s+([\s\S]+)/),o=(n?n[1]:e).trim().replace(/;$/,"");return Function(`return (${o})`)()}var rn={};O(rn,{parseTypeScript:()=>ps});function ls(){if(ft!==null)return ft;return ft=new Bun.Transpiler({loader:"ts"}),ft}function ps(t){let e=mt(t),r=ls().transformSync(e),o=r.match(/export\s+default\s+(.+?)(?:;|\n|$)/),s=o?o[1]:null;if(s===null)return null;let c=r.indexOf("export default"),u=`${r.substring(0,c)}
11
- return (${s})`;return Function(u)()}var ft=null;var sn=()=>{};var cn={};O(cn,{parseENVValue:()=>on,parseENV:()=>ms});function on(t){let e=t.trim(),n=e.startsWith('"')&&e.endsWith('"'),r=e.startsWith("'")&&e.endsWith("'");if(n||r)return e.slice(1,-1);let s=Q(e);if(s!==void 0)return s;let i=H(e);if(i!==void 0)return i;let c=lt(e);if(c!==void 0)return c;return e}function ds(t){let e=t.indexOf("#");if(!(e>=0))return t;let r=t.substring(0,e);if(r.match(/["'].*["']/)!==null){if((r.match(/["']/g)||[]).length%2!==0)return t}return r}function hs(t,e){let r=ds(e).trim();if(!r)return t;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();t.result[u]=on(l)}return t}function ms(t){return t.trim().split(`
12
- `).reduce((r,o)=>hs(r,o),{result:{}}).result}var an=x(()=>{pt()});var un={};O(un,{parseNDJSON:()=>fs});function fs(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 gs(t){return t.trim().split(`
14
- `).filter((e)=>e.length>0)}async function gt(t,e){switch(e??Gt(t)){case"json":return JSON.parse(t);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(() => (Ve(),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(() => ($t(),Vt));return r(t)}case"tsv":{let{parseTSV:r}=await Promise.resolve().then(() => ($t(),Vt));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 gs(t);case"text":default:return t}}function bs(t){let e=t.split(`
15
- `),n=E.NDJSON_FEATURES.test(t),r=e.every(xs);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 ys(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=Ns(e,n,r);if(o)return o;let s=Os(e);if(s)return s;return"text"}var xs=(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,Ss=(t)=>{try{return JSON.parse(t),"json"}catch{return E.JSON5_FEATURES.test(t)?"json5":null}},ws=(t,e,n)=>{if(e==="{"&&n==="}"||e==="["&&n==="]")return Ss(t);return null},Es=(t)=>{let e=t.startsWith("<?xml"),n=/<\/\w+>/.test(t);return e||n?"xml":null},As=(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 As(t)?"typescript":"javascript"},Ns=(t,e,n)=>{switch(e){case"{":case"[":return ws(t,e,n);case"<":return Es(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}},Os=(t)=>{if(t.includes("="))return ys(t);let n=t.includes(": "),r=/^[\s]*-\s+/m.test(t);if(n||r)return"yaml";if(t.includes(`
16
- `))return bs(t);return null};var xt=x(()=>{V()});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 gt(n,t)}var Wt=x(()=>{xt()});var vs,Is,Rs,dn,hn;var bt=x(()=>{vs=[".ts",".js",".tsx",".jsx"],Is=[".json",".yml",".yaml"],Rs=[".md",".txt"],dn=[...vs,...Is,...Rs],hn=/[.*+?^${}()|[\]\\]/g});import{readdir as Cs,stat as mn}from"fs/promises";import{join as Fs,extname as Ms,basename as Ls}from"path";async function yt(t,e=!0){let r=await Bun.file(t).text();if(!e)return r;return gt(r)}function ks(t,e){return{path:t,name:Ls(t),ext:Ms(t),size:Number(e.size),isDirectory:e.isDirectory(),isFile:e.isFile(),modified:e.mtime,created:e.birthtime}}async function Ps(t){let e=await mn(t);return ks(t,e)}function _s(t){return t.startsWith(".")}function Bs(t,e){return e||!_s(t)}function js(t,e){if(e===void 0)return!0;return e.includes(t)}function Ds(t,e){if(e===void 0)return!0;return e.test(t)}function Vs(t,e,n){let r=js(t.ext,e),o=Ds(t.name,n);return r&&o}function $s(t,e){return t<=(e??1/0)}async function Gs(t,e,n,r){if(!Bs(e,r.includeHidden??!1))return[];let s=Fs(t,e),i=await Ps(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(!$s(e,n.maxDepth))return[];let o=await Cs(t);return(await Promise.all(o.map((i)=>Gs(t,i,e,n)))).flat()}async function Ut(t,e={}){return fn(t,0,e)}function Ws(t,e){if(typeof t!=="string")return t;return new RegExp(t,e?"gi":"g")}function Us(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 Js(t,e,n){if(!n)return;let r=e instanceof Error?e.message:String(e);console.error(`Failed to search ${t}: ${r}`)}function zs(t,e,n,r,o,s){return[...t.matchAll(n)].map((c)=>Us(r,e,c.index,t,o,s))}async function gn(t,e,n){try{let r=await yt(t,!1);if(typeof r!=="string")return[];let s=r.split(`
17
- `),i=s.flatMap((a,u)=>zs(a,u,e,t,s,n.context)),c=n.maxMatches??1/0;return i.slice(0,c)}catch(r){return Js(t,r,n.verbose??!1),[]}}async function Qs(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=Ws(t,n.ignoreCase??!1),o=await mn(e);if(o.isFile())return gn(e,r,n);if(o.isDirectory()&&n.recursive)return Qs(e,r,n);return[]}var Jt=x(()=>{bt();xt()});var St=()=>{};var yn,Sn="+-*/%<>!&|=",wn;var En=x(()=>{St();yn={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},wn=[" ","\t",`
18
- `,"\r"]});function $(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($("EOF","",this.position)),t}nextToken(){let t=this.position,e=yn[this.current];if(e){let u=this.current;return this.advance(),$(e,u,t)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),$("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 $("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 $("NUMBER",e,t)}readIdentifier(){let t=this.position,e="";while(this.isIdentifierChar(this.current))e+=this.current,this.advance();return $("IDENTIFIER",e,t)}readOperator(){let t=this.position,e="";while(this.isOperator(this.current))e+=this.current,this.advance();return $("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(()=>{St();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 Tn=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 Hs(t,e){return{type:"IndexAccess",index:t,object:e}}function Ks(t,e,n){return{type:"SliceAccess",start:t,end:e,object:n}}function Nn(t,e,n){return{type:"MethodCall",method:t,args:e,object:n}}function Xs(t,e){return{type:"ObjectOperation",operation:t,object:e}}function qs(t){return{type:"ArraySpread",object:t}}function Ys(t,e){return{type:"ArrowFunction",params:t,body:e}}function wt(t){return{type:"Root",expression:t}}function Zs(t){return On.includes(t)}class nt{tokens;position=0;current;constructor(t){this.tokens=t,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return wt();let e=this.parseExpression();return wt(e)}parseExpression(){return this.parsePrimary()}parsePrimary(){let t=this.parsePrimaryNode();return this.parsePostfix(t)}parsePrimaryNode(){let t=this.current.type;if(t==="DOT")return this.advance(),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(),qs(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"),Hs(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"),Ks(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(!Zs(n)){let r=On.join(", ");throw Error(k(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),Xs(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 Ys(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=Nn(`__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:wt(),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"),Nn(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(wt(),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(()=>{St();Tn();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=to[e];if(!r)throw Error(`Unknown operator: ${e}`);return r(t,n)}function eo(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 no(t,e){if(!Array.isArray(t))return;let n=qt(e,t.length);return t[n]}function ro(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 so(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(!oo(t,e))throw Error(`Method ${e} does not exist on ${typeof t}`);try{return t[e].call(t,...n)}catch(o){let s=io(o);throw Error(`Error executing method ${e}: ${s}`)}}class rt{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 no(t.object?this.evaluate(t.object,e):e,t.index);case"SliceAccess":return ro(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 so(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;return Xt(n,t.property)}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=eo(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 to,oo=(t,e)=>{if(t===null||t===void 0)return!1;return typeof t[e]==="function"},io=(t)=>t instanceof Error?t.message:String(t);var Yt=x(()=>{to={"+":(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 ao,yc;var kn=x(()=>{te();ao={ERROR:W.ERROR,WARN:W.WARN,INFO:W.INFO,DEBUG:W.DEBUG},yc=process.env.LOG_LEVEL?ao[process.env.LOG_LEVEL]||W.INFO:W.INFO});function ee(t){return t.replace(hn,"\\$&")}var Pn=x(()=>{bt();bt();Jt();kn();Et();Wt();te()});function ot(t){return uo.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function _n(t){return lo.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=`
19
- ${s}:
20
- `,l=i.map((p)=>` ${p.short.padEnd(c+2)} \u2192 ${p.full.padEnd(a+2)} # ${p.description}`).join(`
21
- `);return u+l};return`
3
+ var eo=Object.defineProperty;var E=(e,t)=>{for(var n in t)eo(e,n,{get:t[n],enumerable:!0,configurable:!0,set:(r)=>t[n]=()=>r})};var g=(e,t)=>()=>(e&&(t=e(e=0)),t);var Se,p;var se=g(()=>{Se=Symbol("empty"),p={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 Vn,O,M,C;var it=g(()=>{Vn=/[.*+?^${}()|[\]\\]/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 be=(e)=>e.replace(Vn,"\\$&"),qc,Zc,no,ro,so,oo,io=(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=no.reduce((r,{regex:s,replacement:o})=>r.replace(s,o),e),n=so.reduce((r,{regex:s,replacement:o})=>r.replace(s,o),t);return io(n)},co=(e)=>new RegExp(O.PARAM_DOT_TEMPLATE.replace("PARAM",e),"g"),ao=(e)=>{let t=new RegExp(O.ARROW_FUNC.source,"g");return e.replace(t,(n,r,s,o)=>{let i=co(s),c=o.replace(i,".");if(c===o)return n;return`.${r}(${c})`})},$n=(e)=>{let t=ao(e),n=ro.reduce((r,{regex:s,replacement:o})=>r.replace(s,o),t);return oo.reduce((r,{regex:s,replacement:o})=>r.replace(s,o),n)},Hn=()=>{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
+ `,h=c.map((f)=>` ${f.short.padEnd(a+2)} \u2192 ${f.full.padEnd(u+2)} # ${f.description}`).join(`
6
+ `);return l+h},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`
22
12
  Shorthand Reference:
23
- ${o("Array Methods",t)}
24
- ${o("Object Methods",e)}
25
- ${o("String Methods",n)}
26
- ${o("Universal Methods",r)}
13
+ ${s("Array Methods",e)}
14
+ ${s("Object Methods",t)}
15
+ ${s("String Methods",n)}
16
+ ${s("Universal Methods",r)}
17
+ ${o()}
27
18
 
28
19
  Examples:
29
20
  echo '[1,2,3]' | 1ls '.mp(x => x * 2)' # Short form
30
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
31
24
 
32
25
  1ls --shorten ".map(x => x * 2)" # Returns: .mp(x => x * 2)
33
26
  1ls --expand ".mp(x => x * 2)" # Returns: .map(x => x * 2)
34
- `}var B,Cc,Fc,uo,lo;var Et=x(()=>{Pn();B=[{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"}],Cc=new Map(B.map((t)=>[t.short,t.full])),Fc=new Map(B.map((t)=>[t.full,t.short])),uo=B.map((t)=>({regex:new RegExp(`${ee(t.short)}(?![a-zA-Z])`,"g"),replacement:t.full})).sort((t,e)=>e.replacement.length-t.replacement.length),lo=B.map((t)=>({regex:new RegExp(`${ee(t.full)}(?![a-zA-Z])`,"g"),replacement:t.short})).sort((t,e)=>e.regex.source.length-t.regex.source.length)});var At=(t)=>{if(t===null)return"null";if(Array.isArray(t))return"Array";let e=typeof t;return e.charAt(0).toUpperCase()+e.slice(1)},Tt=(t,e)=>{if(e==="null")return"null";if(e==="String")return`"${t}"`;if(e==="Array")return`[${t.length} items]`;if(e==="Object")return`{${Object.keys(t).length} keys}`;return String(t)},ne=(t,e="",n=[])=>{if(t===null||t===void 0){let i=At(t),c=Tt(t,i);return n.push({path:e||".",value:t,type:i,displayValue:c}),n}if(Array.isArray(t)){let i=At(t),c=Tt(t,i),a=e||".";return n.push({path:a,value:t,type:i,displayValue:c}),t.forEach((u,l)=>{let p=e?`${e}[${l}]`:`.[${l}]`;ne(u,p,n)}),n}if(typeof t==="object"){let i=At(t),c=Tt(t,i),a=e||".";if(e)n.push({path:a,value:t,type:i,displayValue:c});return Object.entries(t).forEach(([l,p])=>{let d=/[^a-zA-Z0-9_$]/.test(l),h=e?d?`${e}["${l}"]`:`${e}.${l}`:d?`.["${l}"]`:`.${l}`;ne(p,h,n)}),n}let r=At(t),o=Tt(t,r),s=e||".";return n.push({path:s,value:t,type:r,displayValue:o}),n},Nt=(t)=>{return ne(t)};var po=(t,e,n)=>{let r=n.length*100,o=(p,d,h)=>{if(h===0)return p;let g=n[h-1]===d-1?5:0;return p+g},s=n.reduce(o,0),a=n[0]===0?10:0,u=t.length-e.length;return r+s+a-u},ho=(t,e)=>{let n=t.toLowerCase(),r=e.toLowerCase(),o=[],s=0,i=0,c=()=>{let u=s<n.length,l=i<r.length;return u&&l};while(c()){let u=n[s],l=r[i];if(u===l)o.push(s),i=i+1;s=s+1}return i===r.length?o:null},mo=(t,e,n)=>{let r=ho(e,n);if(!r)return null;let s=po(e,n,r);return Object.assign({},{item:t,score:s,matches:r})},fo=(t,e)=>e.score-t.score,P=(t,e,n)=>{if(!e){let u=(l)=>{return Object.assign({},{item:l,score:0,matches:[]})};return t.map(u)}let o=(u)=>{let l=n(u);return mo(u,l,e)},s=t.map(o),i=(u)=>u!==null;return s.filter(i).sort(fo)};var jn=(t,e)=>{let n=P(t,"",(o)=>o.path);return Object.assign({},{mode:"explore",paths:t,matches:n,query:"",selectedIndex:0,builder:null,originalData:e,methodMatches:[],propertyMatches:[]})},re=(t,e)=>{let n=P(t.paths,e,(s)=>s.path),r=n.length>0?0:t.selectedIndex;return Object.assign({},t,{query:e,matches:n,selectedIndex:r})},U=(t,e)=>{let n=t.mode==="explore",r=t.mode==="build",o=n?t.matches.length:r?t.methodMatches.length:t.propertyMatches.length;if(o===0)return t;let c=t.selectedIndex+e;if(c<0)c=o-1;else if(c>=o)c=0;return Object.assign({},t,{selectedIndex:c})},Dn=(t)=>{let e=t.matches.length>0,n=t.selectedIndex>=0&&t.selectedIndex<t.matches.length;if(e&&n)return t.matches[t.selectedIndex].item;return null};var se=()=>{};import{stdout as X}from"process";var J=()=>{X.write("\x1B[2J\x1B[H")},oe=(t,e=1)=>{X.write(`\x1B[${t};${e}H`)},Vn=()=>{X.write("\x1B[2K")},$n=()=>{X.write("\x1B[J")},Gn=()=>{X.write("\x1B[?25l")},Wn=()=>{X.write("\x1B[?25h")},Un=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!0);process.stdin.resume()},Jn=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!1);process.stdin.pause()},m,f=(t,e)=>{let n=m.reset;return e.concat(t,n)},it=(t,e)=>{let n=t.split(""),r=m.bright.concat(m.cyan),o=(c,a)=>{return e.includes(a)?f(c,r):c};return n.map(o).join("")};var Ot=x(()=>{m=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 j}from"process";var v=10,go=(t,e)=>it(t,e),xo=(t)=>{let e=`[${t}]`;return f(e,m.dim)},bo=(t)=>f(t,m.gray),zn=(t)=>{let e=f("\u276F",m.green),n=" ";return t?e:" "},yo=(t,e,n)=>{let r=zn(e),o=go(t.signature,n),s=t.category?xo(t.category):"",i=bo(t.description);return r.concat(" ",o).concat(s?" "+s:"").concat(" - ",i)},So=(t,e)=>{let{item:n,matches:r}=t,o=zn(e),s=it(n.path,r),i=f(`[${n.type}]`,m.dim),c=f(n.displayValue,m.gray);return o.concat(" ",s).concat(" ",i).concat(" ",c)},wo=(t)=>{if(t.builder===null)return"";let n="Expression Builder",r=m.bright.concat(m.cyan),o=f(n,r),s=t.builder.expression,i=`
27
+ `};var oe=g(()=>{it();it();qc=new Map(C.map((e)=>[e.short,e.full])),Zc=new Map(C.map((e)=>[e.full,e.short])),no=C.map((e)=>({regex:new RegExp(`${be(e.short)}(?![a-zA-Z])`,"g"),replacement:e.full})).sort((e,t)=>t.replacement.length-e.replacement.length),ro=C.map((e)=>({regex:new RegExp(`${be(e.full)}(?![a-zA-Z])`,"g"),replacement:e.short})).sort((e,t)=>t.regex.source.length-e.regex.source.length),so=M.map((e)=>({regex:new RegExp(`(?<![a-zA-Z])${be(e.short)}\\(`,"g"),replacement:`${e.full}(`})).sort((e,t)=>t.replacement.length-e.replacement.length),oo=M.map((e)=>({regex:new RegExp(`(?<![a-zA-Z])${be(e.full)}\\(`,"g"),replacement:`${e.short}(`})).sort((e,t)=>t.regex.source.length-e.regex.source.length)});var po,ho,mo,fo,Wn,go,yo,xo,So,bo,To,Ao,Eo,No,Oo,wo,Ro,Io,vo,at,ut,L,Jn,lt,Mo,Co,Po,Fo,ko,Lo,b;var H=g(()=>{po=/^-?\d+$/,ho=/^[+-]?\d+$/,mo=/^-?\d+\.\d+$/,fo=/^[+-]?\d+\.\d+$/,Wn=/^-?\d+(\.\d+)?$/,go=/(\w+)=["']([^"']+)["']/g,yo=/^<(\w+)([^>]*?)\/>/,xo=/^<(\w+)([^>]*)>([\s\S]*)<\/\1>$/,So=/<\w+/,bo=/<\/\w+>$/,To=/^<\?xml[^>]+\?>\s*/,Ao=/,(\s*[}\]])/g,Eo=/(['"])?([a-zA-Z_$][a-zA-Z0-9_$]*)\1?\s*:/g,No=/\/\/|\/\*|,\s*[}\]]/,Oo=/^\[[\w.\s]+\]$/m,wo=/^\[[\w.]+\]$/m,Ro=/^\w+\s*=\s*"[^"]*"$/m,Io=/=\s*["[{]/m,vo=/^\w+\s*=\s*.+$/m,at={INTEGER:po,FLOAT:mo},ut={INTEGER:ho,FLOAT:fo},L={NUMBER:Wn,ATTRIBUTES:go,SELF_CLOSING:yo,OPEN_TAG:xo,NESTED_TAGS:So,COMPLETE_TAGS:bo,XML_DECLARATION:To},Jn={NUMBER:Wn},lt={TRAILING_COMMA:Ao,UNQUOTED_KEY:Eo},Mo=/^\s*export\s+(const|let|var|function|class|default|type|interface|enum)/m,Co=/:\s*(string|number|boolean|any|unknown|void|never|object|Array|Promise)/,Po=/^\s*interface\s+\w+/m,Fo=/^\s*type\s+\w+\s*=/m,ko=/^[A-Z_][A-Z0-9_]*\s*=/m,Lo=/^\{.*\}\s*$/m,b={JSON5_FEATURES:No,SECTION_HEADER:Oo,TOML_SECTION:wo,TOML_QUOTED_VALUES:Ro,TOML_SYNTAX:Io,INI_SYNTAX:vo,JS_EXPORT:Mo,TS_TYPE_ANNOTATION:Co,TS_INTERFACE:Po,TS_TYPE_ALIAS:Fo,ENV_FEATURES:ko,NDJSON_FEATURES:Lo}});var er={};E(er,{stripJSON5Comments:()=>qn,parseJSON5:()=>_o,normalizeJSON5:()=>Zn,isQuoteChar:()=>zn,handleStringChar:()=>Yn,handleNormalChar:()=>Xn,findMultiLineCommentEnd:()=>Kn,findCommentEnd:()=>Qn});function zn(e){return e==='"'||e==="'"}function Qn(e,t,n){let s=e.slice(t).findIndex((i)=>i===n);return s===-1?e.length-t:s}function Kn(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 Yn(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 Xn(e,t,n,r,s){if(zn(t))return e.result.push(t),{result:e.result,inString:!0,delimiter:t,skip:0};if(t==="/"&&n==="/"){let a=Qn(r,s,`
28
+ `);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}if(t==="/"&&n==="*"){let a=Kn(r,s);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}return e.result.push(t),e}function qn(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?Yn(n,r,i):Xn(n,r,i,t,s)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function Zn(e){let t=qn(e);return t=t.replace(lt.TRAILING_COMMA,"$1"),t=t.replace(lt.UNQUOTED_KEY,'"$2":'),t=t.replace(/'/g,'"'),t}function _o(e){let t=Zn(e);return JSON.parse(t)}var tr=g(()=>{H()});var Bo,Do,jo,Uo=(e)=>Bo.includes(e),Vo=(e)=>Do.includes(e),$o=(e)=>jo.includes(e),q=(e)=>{if(Uo(e))return!0;if(Vo(e))return!1;return},Z=(e)=>{if($o(e))return null;return},Te=(e)=>{if(e==="")return;let t=Number(e);return isNaN(t)?void 0:t};var Ae=g(()=>{Bo=["true","yes","on"],Do=["false","no","off"],jo=["null","~",""]});var Ee=(e)=>e.length-e.trimStart().length,Ho=(e)=>(e.match(/["']/g)||[]).length,Go=(e,t)=>{let n=e.substring(0,t);return Ho(n)%2===0},ie=(e)=>{let t=e.indexOf("#");if(t<0)return e;return Go(e,t)?e.substring(0,t):e},pt=(e)=>["|",">","|+",">-","|-",">+"].includes(e),ht=(e)=>e==="---"||e==="...",dt=(e)=>e.startsWith("- ")||e==="-",nr=(e)=>e==="-"?"":e.substring(2).trim(),rr=(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},mt=(e)=>{let t=e.indexOf(":");if(t<=0)return null;return{key:e.substring(0,t).trim(),value:e.substring(t+1).trim()}},sr=(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:""}},or=(e)=>{if(!e.includes(" &"))return{cleanKey:e,anchorName:null};let[n,r]=e.split(" &");return{cleanKey:n,anchorName:r}},Wo=(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)}},Jo=(e)=>{let t=e.startsWith('"')&&e.endsWith('"'),n=e.startsWith("'")&&e.endsWith("'");return t||n?e.slice(1,-1):null},zo=(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}=Wo(e);if(t==="str")return n;let r=Jo(n);if(r!==null)return r;let s=q(n);if(s!==void 0)return s;let o=Z(n);if(o!==void 0)return o;if(at.INTEGER.test(n))return parseInt(n,10);if(at.FLOAT.test(n))return parseFloat(n);let a=zo(n);if(a!==null)return a;let u=Qo(n);if(u!==null)return u;return n},Ne=(e,t)=>Array.from({length:t},(n,r)=>t-1-r).reduce((n,r)=>{if(n!==null)return n;let o=ie(e[r]).trim();if(!o||o.startsWith("-")||!o.includes(":"))return null;let c=mt(o);if(!c)return null;return!c.value||pt(c.value)?c.key:null},null),ir=(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(Ee(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}},cr=(e,t)=>t==="|"?e.join(`
29
+ `):e.join(" ").replace(/\s+/g," ").trim();var ft=g(()=>{H();Ae()});var lr={};E(lr,{parseYAMLValue:()=>D,parseYAML:()=>ri,findPreviousKey:()=>Ne});var Ko=(e,t)=>{let n=e.substring(1);return t[n]!==void 0?t[n]:e},Yo=(e,t)=>{let n=e.substring(1),r=t[n];return typeof r==="object"&&r!==null&&!Array.isArray(r)?r:null},gt=(e,t)=>{if(typeof e==="string"&&e.startsWith("*"))return Ko(e,t);if(Array.isArray(e))return e.map((s)=>gt(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]:gt(i,t)};let l=Yo(i,t);return l?{...s,...l}:s},{})},Xo=(e)=>e.find((t)=>{let n=ie(t).trim();return n&&!ht(n)}),qo=(e)=>{return Xo(e)?.trim().startsWith("- ")?[]:{}},Oe=(e)=>e[e.length-1],ur=(e,t)=>{while(e.length>1&&t(Oe(e)))e.pop()},ar=(e,t,n,r,s)=>{if(rr(e)){let c=e.indexOf(":"),a=e.substring(0,c).trim(),u=e.substring(c+1).trim(),{cleanKey:l,anchorName:h}=or(a),f=u?D(u):null,x={[l]:f};if(t.push(x),h)s[h]=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})},Zo=(e,t,n,r,s,o)=>{let i=nr(e);ur(s,(l)=>l.indent>t||l.indent>=t&&!Array.isArray(l.container));let c=Oe(s);if(Array.isArray(c.container)&&(c.indent===t||c.indent===-1&&t===0)){if(c.indent===-1)c.indent=t;ar(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=Ne(n,r);if(l)c.container[l]=u}s.push({container:u,indent:t}),ar(i,u,s,t,o)},ei=(e,t,n,r,s,o,i,c)=>{let a=n.startsWith("|")?"|":">",{contentLines:u,endIdx:l}=ir(r,s+1,o),h=cr(u,a);if(e[t]=h,c)i[c]=h;return l},ti=(e,t,n,r,s,o,i,c)=>{let a=Oe(o),u=r+1,l=u<n.length,h=l?ie(n[u]):"",f=h.trim(),x=l?Ee(h):-1,X=dt(f)&&x>s,V=l&&x>s&&f;if(X){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},ni=(e,t,n,r,s,o)=>{let i=mt(e);if(!i)return r;let{anchorName:c,cleanValue:a}=sr(i.value);ur(s,(h)=>h.indent>t||h.indent===t&&Array.isArray(h.container));let u=Oe(s).container;if(Array.isArray(u))return r;if(pt(a))return ei(u,i.key,a,n,r,t,o,c);if(a){let h=D(a);if(u[i.key]=h,c)o[c]=h;return r}return ti(u,i.key,n,r,t,s,o,c),r},ri=(e)=>{let t=e.trim().split(`
30
+ `),n={},r=qo(t),s=[{container:r,indent:-1}],o=0;while(o<t.length){let i=ie(t[o]),c=i.trim();if(!c||ht(c)){o++;continue}let u=Ee(i);if(dt(c)){Zo(c,u,t,o,s,n),o++;continue}o=ni(c,u,t,o,s,n)+1}return gt(r,n)};var pr=g(()=>{ft();ft()});var hr={};E(hr,{parseTOMLValue:()=>we,parseTOML:()=>si});function we(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(ut.INTEGER.test(e))return parseInt(e,10);if(ut.FLOAT.test(e))return parseFloat(e);if(e.startsWith("[")&&e.endsWith("]"))return e.slice(1,-1).split(",").map((a)=>we(a.trim()));if(e.startsWith("{")&&e.endsWith("}")){let c={};return e.slice(1,-1).split(",").forEach((u)=>{let[l,h]=u.split("=").map((f)=>f.trim());if(l&&h)c[l]=we(h)}),c}return e}function si(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]=we(x)}}),n}var dr=g(()=>{H()});var fr={};E(fr,{parseXMLValue:()=>ce,parseXMLElement:()=>yt,parseXMLChildren:()=>mr,parseXMLAttributes:()=>Re,parseXML:()=>ci});function ce(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 Re(e){return Array.from(e.matchAll(L.ATTRIBUTES)).reduce((n,r)=>{let[,s,o]=r;return n[s]=ce(o),n},{})}function yt(e){let t=e.trim(),n=t.match(L.SELF_CLOSING);if(n){let[,h,f]=n;if(f.trim().length>0)return{[h]:{_attributes:Re(f)}};return{[h]:null}}let r=t.match(L.OPEN_TAG);if(!r)return ce(t);let[,s,o,i]=r,c=i.trim();if(!L.NESTED_TAGS.test(c)){if(o.trim().length>0)return{[s]:{_attributes:Re(o),_text:ce(c)}};return{[s]:ce(c)}}let u=mr(c);if(o.trim().length>0)return{[s]:{_attributes:Re(o),...u}};return{[s]:u}}function oi(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((st)=>o.buffer.push(st)),o.depth===0){let st=o.buffer.join("").trim();o.elements.push(st),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,h=o.buffer.join("").trim(),f=h.length>0,x=!i.match(/\s/);if(l&&f&&x){if(h.match(L.COMPLETE_TAGS))o.elements.push(h),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 ii(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 mr(e){return oi(e).reduce((n,r)=>{let s=yt(r);if(typeof s==="object"&&s!==null)Object.entries(s).forEach(([i,c])=>{ii(n,i,c)});return n},{})}function ci(e){let t=e.trim(),n=t.match(L.XML_DECLARATION),r=n?t.slice(n[0].length):t;return yt(r)}var gr=g(()=>{H()});var Sr={};E(Sr,{stripINIComments:()=>yr,processINILine:()=>xr,parseINIValue:()=>xt,parseINI:()=>ai});function xt(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(Jn.NUMBER.test(t))return parseFloat(t);return t}function yr(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 xr(e,t){let r=yr(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 h=e.result[e.currentSection];h[a]=xt(u)}else e.result[a]=xt(u)}return e}function ai(e){return e.trim().split(`
32
+ `).reduce((r,s)=>xr(r,s),{result:{},currentSection:""}).result}var br=g(()=>{H()});var bt={};E(bt,{parseTSV:()=>ui,parseCSVValue:()=>Tr,parseCSVLine:()=>St,parseCSV:()=>Ar});function St(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 Tr(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"'))return t.slice(1,-1).replace(/""/g,'"');let r=Te(t);if(r!==void 0)return r;let s=t.toLowerCase(),o=q(s);if(o!==void 0)return o;let i=Z(s);if(i!==void 0)return i;return t}function Ar(e,t=","){let n=e.trim().split(`
33
+ `);if(n.length===0)return[];let r=St(n[0],t);if(n.length===1)return[];return n.slice(1).reduce((s,o)=>{let i=St(o,t);if(i.length===0)return s;let c=Object.fromEntries(r.map((a,u)=>[a,Tr(i[u]||"")]));return[...s,c]},[])}function ui(e){return Ar(e,"\t")}var Tt=g(()=>{Ae()});var Er={};E(Er,{parseProtobufJSON:()=>pi,parseProtobuf:()=>li});function li(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 pi(e){return JSON.parse(e)}var vr={};E(vr,{stripJSComments:()=>Ie,parseJavaScript:()=>hi,isQuoteChar:()=>Nr,handleStringChar:()=>Rr,handleNormalChar:()=>Ir,findMultiLineCommentEnd:()=>wr,findCommentEnd:()=>Or});function Nr(e){return e==='"'||e==="'"||e==="`"}function Or(e,t,n){let s=e.slice(t).findIndex((i)=>i===n);return s===-1?e.length-t:s}function wr(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 Rr(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 Ir(e,t,n,r,s){if(Nr(t))return e.result.push(t),{result:e.result,inString:!0,delimiter:t,skip:0};if(t==="/"&&n==="/"){let a=Or(r,s,`
34
+ `);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}if(t==="/"&&n==="*"){let a=wr(r,s);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}return e.result.push(t),e}function Ie(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?Rr(n,r,i):Ir(n,r,i,t,s)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function hi(e){let t=Ie(e),n=t.match(/export\s+default\s+([\s\S]+)/),s=(n?n[1]:t).trim().replace(/;$/,"");return Function(`return (${s})`)()}var Mr={};E(Mr,{parseTypeScript:()=>mi});function di(){if(ve!==null)return ve;return ve=new Bun.Transpiler({loader:"ts"}),ve}function mi(e){let t=Ie(e),r=di().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 ve=null;var Cr=()=>{};var Fr={};E(Fr,{parseENVValue:()=>Pr,parseENV:()=>yi});function Pr(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=q(t);if(o!==void 0)return o;let i=Z(t);if(i!==void 0)return i;let c=Te(t);if(c!==void 0)return c;return t}function fi(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 gi(e,t){let r=fi(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]=Pr(l)}return e}function yi(e){return e.trim().split(`
36
+ `).reduce((r,s)=>gi(r,s),{result:{}}).result}var kr=g(()=>{Ae()});var Lr={};E(Lr,{parseNDJSON:()=>xi});function xi(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 Ce=()=>{};var qr,Zr="+-*/%<>!&|=",es;var ts=g(()=>{Ce();qr={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},es=[" ","\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=qr[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 es.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 Zr.includes(e)}}var Pe=g(()=>{Ce();ts()});var ue;var Fe=g(()=>{ue=["keys","values","entries","length"]});var F=(e)=>({type:"Literal",value:e}),Ct=(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}),Pt=(e,t)=>({type:"IndexAccess",index:e,object:t}),Ft=(e,t,n)=>({type:"SliceAccess",start:e,end:t,object:n}),ke=(e,t,n)=>({type:"MethodCall",method:e,args:t,object:n}),kt=(e,t)=>({type:"ObjectOperation",operation:e,object:t}),Lt=(e)=>({type:"ArraySpread",object:e}),_t=(e,t)=>({type:"ArrowFunction",params:e,body:t}),W=(e)=>({type:"Root",expression:e}),Le=(e)=>({type:"RecursiveDescent",object:e}),Bt=(e,t)=>({type:"OptionalAccess",expression:e,object:t}),Dt=(e,t)=>({type:"NullCoalescing",left:e,right:t}),jt=(e)=>ue.includes(e);var Ut=g(()=>{Fe()});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(),Le();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(),Lt(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"),Pt(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"),Ft(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(!jt(n)){let r=ue.join(", ");throw Error(w(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),kt(n,e)}parseIdentifierOrFunction(){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);let n=Ct(e);if(n)return n;return _(e)}parseArrowFunction(e){this.expect("ARROW");let t=this.parseFunctionBody();return _t(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=ke(`__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=Ct(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"),ke(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=Le(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=Bt(t);continue}if(n==="DOUBLE_QUESTION"){this.advance();let u=this.parsePrimary();t=Dt(t,u);continue}if(n==="LEFT_PAREN"){if(t.type==="PropertyAccess"&&!t.object){let h=t.property;t=this.parseMethodCall(W(),h);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 _e=g(()=>{Ce();Fe();Ut();Ut();Fe()});var y=(e)=>Array.isArray(e),S=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),le=(e)=>e===null||e===void 0,N=(e)=>typeof e==="string",te=(e)=>typeof e==="number",ns=(e)=>{if(e===null)return"null";if(y(e))return"array";return typeof e},Vt=(e,t)=>Object.keys(t).reduce((n,r)=>{let s=e[r],o=t[r],i=S(s)&&S(o);return{...n,[r]:i?Vt(s,o):o}},{...e}),Be=(e,t)=>{if(e===t)return!0;if(y(e)&&y(t))return t.every((s)=>e.some((o)=>Be(o,s)));if(S(e)&&S(t)){let s=e;return Object.entries(t).every(([o,i])=>(o in s)&&Be(s[o],i))}return!1},rs=(e,t)=>t.reduce((n,r)=>{if(le(n))return;if(y(n)&&typeof r==="number")return n[r];if(S(n)&&typeof r==="string")return n[r];return},e),$t=(e,t,n)=>{if(t.length===0)return n;let[r,...s]=t,o=s.length===0?n:$t(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}},De=(e)=>{let t=[e],n=y(e)?e.flatMap(De):S(e)?Object.values(e).flatMap(De):[];return[...t,...n]},je=(e,t)=>{let n=[t];if(y(e)){let r=e.flatMap((s,o)=>je(s,[...t,o]));return[...n,...r]}if(S(e)){let r=Object.keys(e).flatMap((s)=>je(e[s],[...t,s]));return[...n,...r]}return n};var ss,os=(e)=>(e in ss),is=(e,t,n)=>{let r=ss[e];if(!r)throw Error(`Unknown builtin: ${e}`);return r(t,n)};var cs=g(()=>{se();se();ss={[p.HEAD]:(e)=>y(e)?e[0]:void 0,[p.LAST]:(e)=>y(e)?e[e.length-1]:void 0,[p.TAIL]:(e)=>y(e)?e.slice(1):[],[p.TAKE]:(e,[t])=>y(e)?e.slice(0,t):[],[p.DROP]:(e,[t])=>y(e)?e.slice(t):[],[p.UNIQ]:(e)=>y(e)?[...new Set(e)]:[],[p.FLATTEN]:(e)=>y(e)?e.flat(1/0):[],[p.REVERSE]:(e)=>y(e)?[...e].reverse():[],[p.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]}},{})},[p.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})},[p.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))},[p.COMPACT]:(e)=>y(e)?e.filter(Boolean):[],[p.PLUCK]:(e,[t])=>{if(!y(e))return[];return e.map((n)=>S(n)?n[t]:void 0)},[p.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},{})},[p.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)))},[p.KEYS]:(e)=>S(e)?Object.keys(e):[],[p.VALUES]:(e)=>S(e)?Object.values(e):[],[p.MERGE]:(e,t)=>{if(!S(e))return{};return t.reduce((n,r)=>{return{...n,...r}},e)},[p.DEEPMERGE]:(e,t)=>{if(!S(e))return{};return t.reduce((n,r)=>{return S(r)?Vt(n,r):n},e)},[p.FROMPAIRS]:(e)=>{if(!y(e))return{};return Object.fromEntries(e)},[p.TOPAIRS]:(e)=>S(e)?Object.entries(e):[],[p.SUM]:(e)=>{if(!y(e))return 0;return e.reduce((t,n)=>t+n,0)},[p.MEAN]:(e)=>{if(!y(e)||e.length===0)return 0;return e.reduce((r,s)=>r+s,0)/e.length},[p.MIN]:(e)=>{if(!y(e))return;return Math.min(...e)},[p.MAX]:(e)=>{if(!y(e))return;return Math.max(...e)},[p.LEN]:(e)=>{if(y(e))return e.length;if(S(e))return Object.keys(e).length;if(N(e))return e.length;return 0},[p.COUNT]:(e)=>{if(y(e))return e.length;if(S(e))return Object.keys(e).length;if(N(e))return e.length;return 0},[p.ISEMPTY]:(e)=>{if(le(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},[p.ISNIL]:(e)=>le(e),[p.IDENTITY]:(e)=>e,[p.TYPE]:(e)=>ns(e),[p.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,h)=>i+h*a)},[p.HAS]:(e,[t])=>{if(S(e))return t in e;if(y(e)){let n=t;return n>=0&&n<e.length}return!1},[p.NTH]:(e,[t])=>{if(!y(e))return;let n=t,s=n<0?e.length+n:n;return e[s]},[p.CONTAINS]:(e,[t])=>Be(e,t),[p.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)},[p.PATH]:(e)=>je(e,[]),[p.GETPATH]:(e,[t])=>rs(e,t),[p.SETPATH]:(e,[t,n])=>$t(e,t,n),[p.RECURSE]:(e)=>De(e),[p.SPLIT]:(e,[t])=>{if(!N(e))return[];let n=t;return e.split(n)},[p.JOIN]:(e,[t])=>{if(!y(e))return"";let n=t;return e.join(n)},[p.STARTSWITH]:(e,[t])=>{if(!N(e))return!1;let n=t;return e.startsWith(n)},[p.ENDSWITH]:(e,[t])=>{if(!N(e))return!1;let n=t;return e.endsWith(n)},[p.LTRIMSTR]:(e,[t])=>{if(!N(e))return e;let n=t;return e.startsWith(n)?e.slice(n.length):e},[p.RTRIMSTR]:(e,[t])=>{if(!N(e))return e;let n=t;return e.endsWith(n)?e.slice(0,-n.length):e},[p.TOSTRING]:(e)=>{if(N(e))return e;if(le(e))return String(e);return JSON.stringify(e)},[p.TONUMBER]:(e)=>{if(te(e))return e;if(N(e)){let t=Number(e);return!Number.isNaN(t)?t:null}return null},[p.FLOOR]:(e)=>te(e)?Math.floor(e):null,[p.CEIL]:(e)=>te(e)?Math.ceil(e):null,[p.ROUND]:(e)=>te(e)?Math.round(e):null,[p.ABS]:(e)=>te(e)?Math.abs(e):null,[p.NOT]:(e)=>!e,[p.SELECT]:(e,[t])=>{return t(e)?e:Se},[p.EMPTY]:()=>Se,[p.ERROR]:(e,[t])=>{throw Error(t||"error")},[p.DEBUG]:(e)=>{return console.error("DEBUG:",e),e}}});var Ht;var Gt=g(()=>{Ht={"+":(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 Ve=(e)=>e.startsWith("__operator_")&&e.endsWith("__"),$e=(e)=>e.slice(11,-2),He=(e,t,n)=>{let r=Ht[t];if(!r)throw Error(`Unknown operator: ${t}`);return r(e,n)},Wt=(e,t)=>Object.fromEntries(e.map((n,r)=>[n,t[r]])),pe=(e)=>{return Object.values(e)[0]},Jt=(e)=>e!==null&&typeof e==="object",he=(e,t)=>{if(!Jt(e))return;return e[t]},Ue=(e,t)=>e<0?t+e:e,zt=(e,t)=>{if(!Array.isArray(e))return;let n=Ue(t,e.length);return e[n]},Qt=(e,t,n)=>{if(!Array.isArray(e))return;let r=e.length,s=t!==void 0?Ue(t,r):0,o=n!==void 0?Ue(n,r):r;return e.slice(s,o)},Kt=(e,t)=>{if(!Jt(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}},_i=(e,t)=>{if(e===null||e===void 0)return!1;return typeof e[t]==="function"},Bi=(e)=>e instanceof Error?e.message:String(e),Ge=(e,t,n)=>{if(!_i(e,t))throw Error(`Method ${t} does not exist on ${typeof e}`);try{return e[t].call(e,...n)}catch(s){let o=Bi(s);throw Error(`Error executing method ${t}: ${o}`)}};var Yt=g(()=>{Gt()});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 zt(e.object?this.evaluate(e.object,t):t,e.index);case"SliceAccess":return Qt(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 Kt(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=he(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===p.PIPE)return this.evaluatePipe(e.args,t);if(e.method===p.COMPOSE)return this.evaluatePipe([...e.args].reverse(),t);let n=e.object?this.evaluate(e.object,t):t;if(os(e.method)){let o=e.args.map((i)=>this.evaluateArg(i,t));return is(e.method,n,o)}if(Ve(e.method)){let o=$e(e.method),i=this.evaluate(e.args[0],t);return He(n,o,i)}let s=e.args.map((o)=>this.evaluateArg(o,t));return Ge(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){let t=Array.isArray(e),n=e!==null&&typeof e==="object"&&!t,r=[e];if(t){let s=e.flatMap((o)=>this.collectAllValues(o));return[...r,...s]}if(n){let s=Object.values(e).flatMap((o)=>this.collectAllValues(o));return[...r,...s]}return r}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=Wt(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,pe(t))}}evaluatePropertyAccessInFunction(e,t){if(e.object!==void 0){let o=this.evaluateFunctionBody(e.object,t);return he(o,e.property)}if(Object.prototype.hasOwnProperty.call(t,e.property))return t[e.property];let s=pe(t);return he(s,e.property)}evaluateMethodCallInFunction(e,t){let n=e.object?this.evaluateFunctionBody(e.object,t):pe(t);if(Ve(e.method)){let o=$e(e.method),i=this.evaluateFunctionBody(e.args[0],t);return He(n,o,i)}let s=e.args.map((o)=>this.evaluateFunctionBody(o,t));return Ge(n,e.method,s)}}var We=g(()=>{se();cs();Yt();Gt();Yt()});var Je=(e)=>{if(e===null)return"null";if(Array.isArray(e))return"Array";let t=typeof e;return t.charAt(0).toUpperCase()+t.slice(1)},ze=(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)},qt=(e,t="",n=[])=>{if(e===null||e===void 0){let i=Je(e),c=ze(e,i);return n.push({path:t||".",value:e,type:i,displayValue:c}),n}if(Array.isArray(e)){let i=Je(e),c=ze(e,i),a=t||".";return n.push({path:a,value:e,type:i,displayValue:c}),e.forEach((u,l)=>{let h=t?`${t}[${l}]`:`.[${l}]`;qt(u,h,n)}),n}if(typeof e==="object"){let i=Je(e),c=ze(e,i),a=t||".";if(t)n.push({path:a,value:e,type:i,displayValue:c});return Object.entries(e).forEach(([l,h])=>{let f=/[^a-zA-Z0-9_$]/.test(l),x=t?f?`${t}["${l}"]`:`${t}.${l}`:f?`.["${l}"]`:`.${l}`;qt(h,x,n)}),n}let r=Je(e),s=ze(e,r),o=t||".";return n.push({path:o,value:e,type:r,displayValue:s}),n},Qe=(e)=>{return qt(e)};var ji=(e,t,n)=>{let r=n.length*100,s=(h,f,x)=>{if(x===0)return h;let B=n[x-1]===f-1?5:0;return h+B},o=n.reduce(s,0),a=n[0]===0?10:0,u=e.length-t.length;return r+o+a-u},Ui=(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},Vi=(e,t,n)=>{let r=Ui(t,n);if(!r)return null;let o=ji(t,n,r);return Object.assign({},{item:e,score:o,matches:r})},$i=(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 Vi(u,l,t)},o=e.map(s),i=(u)=>u!==null;return o.filter(i).sort($i)};var Zt,en,tn,nn,rn,sn,on,cn,an;var un=g(()=>{Zt=[{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"}],en=[{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"}],tn=[{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"}],nn=[{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"}],rn=[{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}],sn=[{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}],on=[{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}],cn=[{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}],an=[{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 j=(e)=>{let t=an;switch(e){case"Array":return[...Zt,...rn,...t];case"String":return[...en,...on,...t];case"Object":return[...tn,...sn,...t];case"Number":return[...nn,...cn,...t];default:return t}};var ln=g(()=>{un();un()});var pn=6,Ke=500,Ye=5;var hn="",Xe=null,Hi=(e)=>{if(Array.isArray(e)&&e.length>Ye)return{value:e.slice(0,Ye),truncated:!0};return{value:e,truncated:!1}},Gi=(e,t)=>{let n=JSON.stringify(e,null,2),r=t?`
39
+ ... (truncated)`:"";if(n.length>Ke)return n.slice(0,Ke)+`
40
+ ... (truncated)`;return n+r},qe=(e,t)=>{if(e===hn&&Xe!==null)return Xe;try{let n=$(e),s=new G(n).tokenize(),i=new J(s).parse(),a=new z().evaluate(i,t),{value:u,truncated:l}=Hi(a),h={success:!0,value:u,error:null,truncated:l};return hn=e,Xe=h,h}catch(n){let s={success:!1,value:null,error:n instanceof Error?n.message:String(n),truncated:!1};return hn=e,Xe=s,s}},Ze=(e)=>{if(!e.success)return`Error: ${e.error}`;return Gi(e.value,e.truncated)};var dn=g(()=>{Pe();_e();We();oe()});var mn=5,et=".";var fn=()=>{};var Wi=(e)=>{let t=e.lastIndexOf(et);if(t===-1)return null;let r=e.slice(t+1);if(r.includes("(")||r.includes(")"))return null;return r},Ji=(e)=>{if(e===null)return"null";if(Array.isArray(e))return"Array";return{string:"String",number:"Number",boolean:"Boolean",object:"Object"}[typeof e]||"unknown"},gn=()=>Object.assign({},{visible:!1,methodHints:[],partialMethod:"",selectedHintIndex:0}),ps=(e)=>{let t=Wi(e.query);if(t===null)return gn();let r=e.dataType||Ji(e.originalData),s=j(r),i=R(s,t,(a)=>a.name).slice(0,mn),c=i.length>0;return Object.assign({},{visible:c,methodHints:i,partialMethod:t,selectedHintIndex:0})},zi,hs=(e)=>{let t=e.lastIndexOf(et);if(t===-1)return!1;let r=e.slice(t+1),s=r.includes(")"),o=zi.includes(r);return s||o},ds=(e,t)=>{let n=qe(e,t),r=Ze(n);return{success:n.success,preview:r}};var yn=g(()=>{ln();dn();fn();fn();zi=["length","keys","values","entries"]});var ms=(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:gn()})},Qi=(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=(e,t)=>{let n=R(e.paths,t,(a)=>a.path),r=n.length>0?0:e.selectedIndex,s=Qi(e.originalData),o={query:t,dataType:s,originalData:e.originalData},i=ps(o);return Object.assign({},e,{query:t,matches:n,selectedIndex:r,tooltip:i})},Q=(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})},fs=(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 Sn=g(()=>{yn()});import{stdout as ne}from"process";var K=()=>{ne.write("\x1B[2J\x1B[H")},bn=(e,t=1)=>{ne.write(`\x1B[${e};${t}H`)},gs=()=>{ne.write("\x1B[2K")},ys=()=>{ne.write("\x1B[J")},xs=()=>{ne.write("\x1B[?25l")},Ss=()=>{ne.write("\x1B[?25h")},bs=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!0);process.stdin.resume()},Ts=()=>{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)},me=(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 tt=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,Ki=(e,t)=>me(e,t),Yi=(e)=>{let t=`[${e}]`;return m(t,d.dim)},Xi=(e)=>m(e,d.gray),As=(e)=>{let t=m("\u276F",d.green),n=" ";return e?t:" "},qi=(e,t,n)=>{let r=As(t),s=Ki(e.signature,n),o=e.category?Yi(e.category):"",i=Xi(e.description);return r.concat(" ",s).concat(o?" "+o:"").concat(" - ",i)},Zi=(e,t)=>{let{item:n,matches:r}=e,s=As(t),o=me(n.path,r),i=m(`[${n.type}]`,d.dim),c=m(n.displayValue,d.gray);return s.concat(" ",o).concat(" ",i).concat(" ",c)},ec=(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=`
35
41
 
36
- Building: `,c=f(s,m.bright.concat(m.yellow)),a=`
42
+ Building: `,c=m(o,d.bright.concat(d.yellow)),a=`
37
43
 
38
- Search methods for `,u=f(t.builder.baseType,m.bright),l=": ",p=t.query;return o.concat(i,c).concat(a,u,l,p,`
44
+ Search methods for `,u=m(e.builder.baseType,d.bright),l=": ",h=e.query;return s.concat(i,c).concat(a,u,l,h,`
39
45
 
40
- `)},Eo=(t)=>{let e=t.builder!==null,n=t.builder?.arrowFnContext!==null;if(!e||!n)return"";let r="Expression Builder - Arrow Function",o=m.bright.concat(m.cyan),s=f(r,o),i=t.builder.expression,c=`
46
+ `)},tc=(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=`
41
47
 
42
- Building: `,a=f(i,m.bright.concat(m.yellow)),u=t.builder.arrowFnContext,l=`
48
+ Building: `,a=m(i,d.bright.concat(d.yellow)),u=e.builder.arrowFnContext,l=`
43
49
 
44
- Search properties for '${u.paramName}' (${u.paramType}): `,p=t.query;return s.concat(c,a).concat(l,p,`
50
+ Search properties for '${u.paramName}' (${u.paramType}): `,h=e.query;return o.concat(c,a).concat(l,h,`
45
51
 
46
- `)},Ao=(t)=>{if(t.builder===null)return"";let{methodMatches:n,selectedIndex:r}=t;if(n.length===0)return f("No methods found",m.dim);let o=Math.floor(v/2),s=Math.max(0,r-o),i=Math.min(n.length,s+v);if(i-s<v&&n.length>=v)s=Math.max(0,i-v);let a=n.slice(s,i),u=(d,h)=>{let T=s+h===r;return yo(d.item,T,d.matches)};return a.map(u).join(`
47
- `)},To=(t)=>{let e=t.builder===null,n=t.builder?.arrowFnContext===null;if(e||n)return"";let{propertyMatches:r,selectedIndex:o}=t;if(r.length===0)return f("No properties found",m.dim);let s=Math.floor(v/2),i=Math.max(0,o-s),c=Math.min(r.length,i+v);if(c-i<v&&r.length>=v)i=Math.max(0,c-v);let u=r.slice(i,c),l=(h,N)=>{let y=i+N===o;return So(h,y)};return u.map(l).join(`
48
- `)},Qn=(t)=>{let e=t-v;if(e>0){let r=`
52
+ `)},nc=(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 X=o+x===r;return qi(f.item,X,f.matches)};return a.map(u).join(`
53
+ `)},rc=(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 Zi(x,V)};return u.map(l).join(`
54
+ `)},Es=(e)=>{let t=e-I;if(t>0){let r=`
49
55
 
50
- ... `.concat(String(e)," more");return f(r,m.dim)}return""},Hn=()=>{let t=`
56
+ ... `.concat(String(t)," more");return m(r,d.dim)}return""},Ns=()=>{let e=`
51
57
 
52
- `.concat(f("\u2191/\u2193",m.bright)," navigate ",f("\u2192/Tab",m.bright)," accept ",f("\u2190",m.bright)," undo ",f("Enter",m.bright)," execute ",f("Esc",m.bright)," quit");return f(t,m.dim)},Kn=(t)=>{J();let e=wo(t);j.write(e);let n=Ao(t);j.write(n);let r=t.methodMatches.length,o=Qn(r);j.write(o);let s=Hn();j.write(s)},Xn=(t)=>{J();let e=Eo(t);j.write(e);let n=To(t);j.write(n);let r=t.propertyMatches.length,o=Qn(r);j.write(o);let s=Hn();j.write(s)};var qn=x(()=>{Ot()});import{stdout as Zn}from"process";var q=10,vt,tr=!0,No=(t,e)=>it(t,e),Oo=(t)=>{let r="[".concat(t,"]");return f(r,m.dim)},vo=(t)=>f(t,m.gray),Io=(t)=>{let e=f("\u276F",m.green),n=" ";return t?e:" "},Ro=(t,e)=>{let{item:n,matches:r}=t,o=Io(e),s=No(n.path,r),i=Oo(n.type),c=vo(n.displayValue);return o.concat(" ",s).concat(" ",i).concat(" ",c)},Co=()=>{let e=m.bright.concat(m.cyan);return f("1ls Interactive Explorer",e)},Fo,Mo,Yn=5,Lo=(t)=>f(String(t),m.cyan),ko=(t)=>{let n=JSON.stringify(t,null,2).split(`
53
- `),r=n.slice(0,Yn),o=n.length>Yn,s=f(r.join(`
54
- `),m.cyan);return o?s.concat(f(`
55
- ... (truncated)`,m.dim)):s},Po=(t)=>{let{type:e,displayValue:n,value:r}=t;if(Fo.includes(e))return Lo(n);if(Mo.includes(e))return ko(r);return f(String(r),m.cyan)},_o=(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)},Os=(e)=>{if(!e.builder)return"";let t=e.builder.expression,n=e.originalData,r=qe(t,n),c=Ze(r).split(`
59
+ `).slice(0,pn).join(`
60
+ `),a=m(`
56
61
 
57
62
  Preview:
58
- `,m.bright),a=Po(i);return c.concat(a)},Bo=()=>{let t=`
59
-
60
- `.concat(f("\u2191/\u2193",m.bright)," navigate ",f("Enter",m.bright)," select ",f("Tab",m.bright)," build ",f("Esc/q",m.bright)," quit");return f(t,m.dim)},jo=(t,e)=>{let n=Math.floor(q/2),r=Math.max(0,t-n),o=Math.min(e,r+q);return{start:o-r<q&&e>=q?Math.max(0,o-q):r,end:o}},Do=(t)=>{let{selectedIndex:e,matches:n}=t,r=n.length;if(r===0)return[f("No matches found",m.dim)];let{start:s,end:i}=jo(e,r);return n.slice(s,i).map((a,u)=>{let p=s+u===e;return Ro(a,p)})},Vo=(t)=>{let e=t-q;return e>0?["",f("... "+e+" more",m.dim)]:[]},$o=(t)=>{let e=_o(t);return e?e.split(`
61
- `):[]},Go=(t)=>{let e=[Co(),"","Search: "+t.query,""],n=Do(t),r=Vo(t.matches.length),o=$o(t),s=["",Bo().trim()];return[...e,...n,...r,...o,...s]},Wo=(t)=>{J(),Zn.write(t.join(`
62
- `)),vt=t,tr=!1},Uo=(t,e)=>{oe(e+1),Vn(),Zn.write(t)},Jo=(t)=>{if(tr){Wo(t);return}if(t.forEach((n,r)=>{if(vt[r]!==n)Uo(n,r)}),t.length<vt.length)oe(t.length+1),$n();vt=t},zo=(t)=>{let e=Go(t);Jo(e)},Qo,ie=(t)=>{let e=Qo[t.mode];e(t)};var er=x(()=>{Ot();qn();vt=[],Fo=["String","Number","Boolean","null"],Mo=["Array","Object"],Qo={explore:zo,build:Kn,"build-arrow-fn":Xn}});var Ho,Ko,Xo,qo,Y=(t)=>{switch(t){case"Array":return Ho;case"String":return Ko;case"Object":return Xo;case"Number":return qo;default:return[]}};var nr=x(()=>{Ho=[{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"}],Ko=[{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"}],Xo=[{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"}],qo=[{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 rr=(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})},ct=(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})},sr=(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,N=Array.isArray(h)?"Array":h===null?"null":typeof h==="object"?"Object":typeof h==="string"?"String":typeof h==="number"?"Number":typeof h==="boolean"?"Boolean":"unknown",T=i.includes("(a, b)")?"a":"x",y=Nt(h),g={paramName:T,paramType:N,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})},or=(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})},ir=(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,N,T)=>{let y=h.lastIndexOf(N);if(y===-1)return h;return h.substring(0,y)+T+h.substring(y+N.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})},cr=(t)=>{if(!t.builder)return t;let n=t.builder,r=n.expression,o=r.lastIndexOf(".");if(o===-1)return ct(t);let c=r.lastIndexOf("(")>o?r.substring(0,o):r;if(c===n.basePath)return ct(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 ar=x(()=>{nr()});var I,Yo=(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,ur=(t)=>t===I.LEFT,lr=(t)=>t===I.RIGHT,me=(t)=>t===I.BACKSPACE,fe=(t)=>{let e=t>=" ",n=t<="~";return e&&n},Zo=(t,e)=>{if(pe(e))return{state:rr(t),output:null};if(le(e)){let n=Dn(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}},ti=(t,e)=>{if(e===I.ESCAPE)return{state:ct(t),output:null};if(le(e)){if(!t.builder)return{state:t,output:null};return{state:null,output:t.builder.expression}}if(lr(e)||pe(e)){if(!t.builder)return{state:t,output:null};return{state:sr(t,t.selectedIndex),output:null}}if(ur(e))return{state:cr(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}},ei=(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(lr(e)||pe(e)){let n=or(t,t.selectedIndex);return{state:ir(n),output:null}}if(ur(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}},ni,pr=(t,e)=>{let n=e.toString();if(Yo(n)){if(t.mode==="build"||t.mode==="build-arrow-fn")return{state:ct(t),output:null};return{state:null,output:null}}let r=ni[t.mode];return r(t,n)};var dr=x(()=>{se();ar();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"}),ni={explore:Zo,build:ti,"build-arrow-fn":ei}});var hr={};O(hr,{runInteractive:()=>ii});import{stdin as ge,stdout as at,exit as ut}from"process";var xe=!1,It=()=>{if(xe)Wn(),Jn(),xe=!1;J()},be=(t)=>{It();let e=t instanceof Error?t.message:String(t),n=f(`Fatal error: ${e}
63
- `,m.yellow);at.write(n),ut(1)},ri=()=>{process.on("uncaughtException",be),process.on("unhandledRejection",be),process.on("SIGINT",()=>{It(),ut(0)}),process.on("SIGTERM",()=>{It(),ut(0)})},si=(t,e)=>{return pr(t,e)},oi=async(t)=>{let e=t;return new Promise((n)=>{let r=(o)=>{let{state:s,output:i}=si(e,o);if(i!==null){ge.off("data",r),n(i);return}if(s===null){ge.off("data",r),n(null);return}e=s,ie(e)};ge.on("data",r)})},ii=async(t)=>{ri();let e=Nt(t);if(!(e.length>0)){let o=f(`No paths found in data
64
- `,m.yellow);at.write(o),ut(1)}let r=jn(e,t);Un(),xe=!0,Gn(),ie(r);try{let o=await oi(r);if(It(),o!==null)try{let i=ot(o),a=new et(i).tokenize(),l=new nt(a).parse(),d=new rt().evaluate(l,t),h=JSON.stringify(d,null,2);at.write(h),at.write(`
65
- `)}catch(i){let c=i instanceof Error?i.message:String(i);at.write(f("Error: "+c+`
66
- `,m.yellow))}ut(0)}catch(o){be(o)}};var mr=x(()=>{se();er();dr();Ot();zt();Ht();Yt();Et()});var ye=["json","yaml","csv","table"],Se=["json","yaml","toml","csv","tsv","lines","text"],yr=[{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 Rt=(t,e)=>{let r=yr.filter((o)=>o.type===t).map((o)=>` ${o.short.padEnd(6)} -> ${o.full.padEnd(14)} ${o.description}`);return`${e}:
63
+ `,d.bright),u=r.success?m(c,d.cyan):m(c,d.yellow);return a.concat(u)},ws=(e)=>{K();let t=ec(e);k.write(t);let n=nc(e);k.write(n);let r=e.methodMatches.length,s=Es(r);k.write(s);let o=Os(e);k.write(o);let i=Ns();k.write(i)},Rs=(e)=>{K();let t=tc(e);k.write(t);let n=rc(e);k.write(n);let r=e.propertyMatches.length,s=Es(r);k.write(s);let o=Os(e);k.write(o);let i=Ns();k.write(i)};var Is=g(()=>{tt();dn()});import{stdout as Ms}from"process";var re=10,nt,Cs=!0,sc=(e,t)=>me(e,t),oc=(e)=>{let r="[".concat(e,"]");return m(r,d.dim)},ic=(e)=>m(e,d.gray),cc=(e)=>{let t=m("\u276F",d.green),n=" ";return e?t:" "},ac=(e,t)=>{let{item:n,matches:r}=e,s=cc(t),o=sc(n.path,r),i=oc(n.type),c=ic(n.displayValue);return s.concat(" ",o).concat(" ",i).concat(" ",c)},uc=()=>{let t=d.bright.concat(d.cyan);return m("1ls Interactive Explorer",t)},lc,pc,vs=5,hc=(e)=>m(String(e),d.cyan),dc=(e)=>{let n=JSON.stringify(e,null,2).split(`
64
+ `),r=n.slice(0,vs),s=n.length>vs,o=m(r.join(`
65
+ `),d.cyan);return s?o.concat(m(`
66
+ ... (truncated)`,d.dim)):o},mc=(e)=>{let{type:t,displayValue:n,value:r}=e;if(lc.includes(t))return hc(n);if(pc.includes(t))return dc(r);return m(String(r),d.cyan)},fc=(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=mc(i);return c.concat(a)},gc=()=>{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)},yc=(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)},xc=(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 yc(s,i)});return["",n,...r]},Sc=(e)=>{let t=e.query.length>0,n=e.query.includes("."),r=hs(e.query);if(!(t&&n&&r))return[];let{success:o,preview:i}=ds(e.query,e.originalData),c=m(`
72
+ Result:`,d.bright),a=o?d.cyan:d.yellow,l=i.split(`
73
+ `).slice(0,5).map((h)=>m(h,a));return[c,...l]},bc=(e,t)=>{let n=Math.floor(re/2),r=Math.max(0,e-n),s=Math.min(t,r+re);return{start:s-r<re&&t>=re?Math.max(0,s-re):r,end:s}},Tc=(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}=bc(t,r);return n.slice(o,i).map((a,u)=>{let h=o+u===t;return ac(a,h)})},Ac=(e)=>{let t=e-re;return t>0?["",m("... "+t+" more",d.dim)]:[]},Ec=(e)=>{let t=fc(e);return t?t.split(`
74
+ `):[]},Nc=(e)=>{let t=[uc(),"","Search: "+e.query,""],n=Tc(e),r=Ac(e.matches.length),s=xc(e.tooltip),o=Sc(e),i=Ec(e),c=["",gc().trim()];return t.concat(n).concat(r).concat(s).concat(o).concat(i).concat(c)},Oc=(e)=>{K(),Ms.write(e.join(`
75
+ `)),nt=e,Cs=!1},wc=(e,t)=>{bn(t+1),gs(),Ms.write(e)},Rc=(e)=>{if(Cs){Oc(e);return}if(e.forEach((n,r)=>{if(nt[r]!==n)wc(n,r)}),e.length<nt.length)bn(e.length+1),ys();nt=e},Ic=(e)=>{let t=Nc(e);Rc(t)},vc,Tn=(e)=>{let t=vc[e.mode];t(e)};var Ps=g(()=>{tt();Is();yn();nt=[],lc=["String","Number","Boolean","null"],pc=["Array","Object"],vc={explore:Ic,build:ws,"build-arrow-fn":Rs}});var fe,Y,An;var Fs=g(()=>{fe={SINGLE_PARAM:"x =>",SORT_PARAMS:"(a, b)",REDUCE_PARAMS:"(acc, x)"},Y={SINGLE_PARAM:"x => x",SORT_COMPARE:"(a, b) => a - b",REDUCE_ACC:"(acc, x) => acc"},An={SORT:"a",DEFAULT:"x"}});var ks=(e)=>e.includes(fe.SINGLE_PARAM)||e.includes(fe.SORT_PARAMS)||e.includes(fe.REDUCE_PARAMS),Ls=(e)=>e.includes(fe.SORT_PARAMS)?An.SORT:An.DEFAULT,_s=(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"},Bs=(e)=>{if(!Array.isArray(e))return{};if(e.length===0)return{};return e[0]},En=(e,t,n)=>{let r=e.lastIndexOf(t);if(r===-1)return e;return e.substring(0,r)+n+e.substring(r+t.length)},Ds=(e,t,n)=>{if(t.includes(Y.SINGLE_PARAM))return En(e,Y.SINGLE_PARAM,`x => ${n}`);if(t.includes(Y.SORT_COMPARE))return En(e,Y.SORT_COMPARE,`(a, b) => ${n}`);if(t.includes(Y.REDUCE_ACC))return En(e,Y.REDUCE_ACC,`(acc, x) => ${n}`);return e},js=(e,t)=>e==="."?t:`${t}${e}`;var Us=g(()=>{Fs()});var Vs=(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})},ge=(e)=>Object.assign({},e,{mode:"explore",builder:null,selectedIndex:0}),Nn=(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})},On=(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})},$s=(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(ks(o)){let a=n.baseType==="Array"?Bs(n.baseValue):n.baseValue,u={paramName:Ls(o),paramType:_s(a),paramValue:a,paramPaths:Qe(a),expression:""},l=R(u.paramPaths,"",(f)=>f.path),h=Object.assign({},n,{currentMethodIndex:t,arrowFnContext:u,expression:n.expression+o});return Object.assign({},e,{mode:"build-arrow-fn",builder:h,query:"",selectedIndex:0,propertyMatches:l})}let i=Object.assign({},n,{expression:n.expression+o,currentMethodIndex:t});return Object.assign({},e,{builder:i})},Hs=(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:js(o.path,s.paramName)}),c=Object.assign({},r,{arrowFnContext:i});return Object.assign({},e,{builder:c})},Gs=(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=Ds(t.expression,i,n.expression),a=Object.assign({},t,{expression:c,arrowFnContext:null});return Object.assign({},e,{mode:"build",builder:a,query:"",selectedIndex:0})},wn=(e)=>{if(!e.builder)return e;let t=e.builder,s=j(t.baseType)[t.currentMethodIndex].template||"",o=Object.assign({},t,{expression:t.expression.replace(s,""),arrowFnContext:null});return Object.assign({},e,{mode:"build",builder:o})},Ws=(e)=>{if(!e.builder)return e;let t=e.builder,n=t.expression,r=n.lastIndexOf(".");if(r===-1)return ge(e);let i=n.lastIndexOf("(")>r?n.substring(0,r):n;if(i===t.basePath)return ge(e);let c=Object.assign({},t,{expression:i}),a=j(t.baseType),u=R(a,"",(l)=>l.signature);return Object.assign({},e,{builder:c,methodMatches:u,query:"",selectedIndex:0})};var Js=g(()=>{ln();Us()});var v,Mc=(e)=>{let t=e===v.CTRL_C,n=e===v.ESCAPE;return t||n||e==="q"},Rn=(e)=>e===v.ENTER,In=(e)=>e===v.TAB,vn=(e)=>e===v.UP,Mn=(e)=>e===v.DOWN,zs=(e)=>e===v.LEFT,Qs=(e)=>e===v.RIGHT,Cn=(e)=>e===v.BACKSPACE,Pn=(e)=>{let t=e>=" ",n=e<="~";return t&&n},Cc=(e,t)=>{if(In(t))return{state:Vs(e),output:null};if(Rn(t)){let n=fs(e);if(!n)return{state:null,output:null};return{state:null,output:JSON.stringify(n.value,null,2)}}if(vn(t))return{state:Q(e,-1),output:null};if(Mn(t))return{state:Q(e,1),output:null};if(Cn(t)){let n=e.query.slice(0,-1);return{state:xn(e,n),output:null}}if(Pn(t)){let n=e.query.concat(t);return{state:xn(e,n),output:null}}return{state:e,output:null}},Pc=(e,t)=>{if(t===v.ESCAPE)return{state:ge(e),output:null};if(Rn(t)){if(!e.builder)return{state:e,output:null};return{state:null,output:e.builder.expression}}if(Qs(t)||In(t)){if(!e.builder)return{state:e,output:null};return{state:$s(e,e.selectedIndex),output:null}}if(zs(t))return{state:Ws(e),output:null};if(vn(t))return{state:Q(e,-1),output:null};if(Mn(t))return{state:Q(e,1),output:null};if(Cn(t)){let n=e.query.slice(0,-1);return{state:Nn(e,n),output:null}}if(Pn(t)){let n=e.query.concat(t);return{state:Nn(e,n),output:null}}return{state:e,output:null}},Fc=(e,t)=>{if(t===v.ESCAPE)return{state:wn(e),output:null};if(Rn(t)){if(!e.builder)return{state:e,output:null};return{state:null,output:e.builder.expression}}if(Qs(t)||In(t)){let n=Hs(e,e.selectedIndex);return{state:Gs(n),output:null}}if(zs(t))return{state:wn(e),output:null};if(vn(t))return{state:Q(e,-1),output:null};if(Mn(t))return{state:Q(e,1),output:null};if(Cn(t)){let n=e.query.slice(0,-1);return{state:On(e,n),output:null}}if(Pn(t)){let n=e.query.concat(t);return{state:On(e,n),output:null}}return{state:e,output:null}},kc,Ks=(e,t)=>{let n=t.toString();if(Mc(n)){if(e.mode==="build"||e.mode==="build-arrow-fn")return{state:ge(e),output:null};return{state:null,output:null}}let r=kc[e.mode];return r(e,n)};var Ys=g(()=>{Sn();Js();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"}),kc={explore:Cc,build:Pc,"build-arrow-fn":Fc}});var Xs={};E(Xs,{runInteractive:()=>Dc});import{stdin as Fn,stdout as ye,exit as xe}from"process";var kn=!1,rt=()=>{if(kn)Ss(),Ts(),kn=!1;K()},Ln=(e)=>{rt();let t=e instanceof Error?e.message:String(e),n=m(`Fatal error: ${t}
76
+ `,d.yellow);ye.write(n),xe(1)},Lc=()=>{process.on("uncaughtException",Ln),process.on("unhandledRejection",Ln),process.on("SIGINT",()=>{rt(),xe(0)}),process.on("SIGTERM",()=>{rt(),xe(0)})},_c=(e,t)=>{return Ks(e,t)},Bc=async(e)=>{let t=e;return new Promise((n)=>{let r=(s)=>{let{state:o,output:i}=_c(t,s);if(i!==null){Fn.off("data",r),n(i);return}if(o===null){Fn.off("data",r),n(null);return}t=o,Tn(t)};Fn.on("data",r)})},Dc=async(e)=>{Lc();let t=Qe(e);if(!(t.length>0)){let s=m(`No paths found in data
77
+ `,d.yellow);ye.write(s),xe(1)}let r=ms(t,e);bs(),kn=!0,xs(),Tn(r);try{let s=await Bc(r);if(rt(),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);ye.write(x),ye.write(`
78
+ `)}catch(i){let c=i instanceof Error?i.message:String(i);ye.write(m("Error: "+c+`
79
+ `,d.yellow))}xe(0)}catch(s){Ln(s)}};var qs=g(()=>{Sn();Ps();Ys();tt();Pe();_e();We();oe()});var _n=["json","yaml","csv","table"],Bn=["json","yaml","toml","csv","tsv","lines","text"],to=[{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 ot=(e,t)=>{let r=to.filter((s)=>s.type===e).map((s)=>` ${s.short.padEnd(6)} -> ${s.full.padEnd(14)} ${s.description}`);return`${t}:
67
80
  ${r.join(`
68
- `)}`},di=`Expression Shortcuts:
81
+ `)}`},Wc=`Expression Shortcuts:
69
82
 
70
- ${Rt("array","Array Methods")}
83
+ ${ot("array","Array Methods")}
71
84
 
72
- ${Rt("object","Object Methods")}
85
+ ${ot("object","Object Methods")}
73
86
 
74
- ${Rt("string","String Methods")}
75
- `;var we=ye,Ee=[...Se],Ae={format:"json",pretty:!1,raw:!1,compact:!1,type:!1,recursive:!1,ignoreCase:!1,showLineNumbers:!1,inputFormat:void 0};function Te(t){let e={...Ae},n=0;while(n<t.length){let r=t[n];switch(r){case"--help":case"-h":e.help=!0;break;case"--version":case"-v":e.version=!0;break;case"--raw":case"-r":e.raw=!0;break;case"--pretty":case"-p":e.pretty=!0;break;case"--compact":case"-c":e.compact=!0;break;case"--type":case"-t":e.type=!0;break;case"--format":if(n++,n<t.length){let s=t[n],i=we.includes(s);if(s&&i)e.format=s}break;case"--input-format":case"-if":if(n++,n<t.length){let s=t[n];if(Ee.includes(s))e.inputFormat=s}break;case"readFile":e.readFile=!0,n+=2;break;case"--find":case"-f":if(n++,n<t.length)e.find=t[n];break;case"--grep":case"-g":if(n++,n<t.length)e.grep=t[n];break;case"--list":case"-l":if(n++,n<t.length)e.list=t[n];break;case"--recursive":case"-R":e.recursive=!0;break;case"--interactive":e.interactive=!0;break;case"--ignore-case":case"-i":e.ignoreCase=!0;break;case"--line-numbers":case"-n":e.showLineNumbers=!0;break;case"--ext":if(n++,n<t.length){let s=t[n].split(",");e.extensions=s.map((i)=>i.startsWith(".")?i:`.${i}`)}break;case"--max-depth":if(n++,n<t.length)e.maxDepth=parseInt(t[n],10);break;case"--shorten":if(n++,n<t.length)e.shorten=t[n];break;case"--expand":if(n++,n<t.length)e.expand=t[n];break;case"--shortcuts":e.shortcuts=!0;break;case"--detect":e.detect=!0;break;default:if(r.startsWith(".")||r.startsWith("["))e.expression=r;break}n++}return e}function Ct(){console.log(`
87
+ ${ot("string","String Methods")}
88
+ `;var Dn=_n,jn=[...Bn],Un={format:"json",pretty:!1,raw:!1,compact:!1,type:!1,recursive:!1,ignoreCase:!1,showLineNumbers:!1,inputFormat:void 0,slurp:!1,nullInput:!1};se();oe();var uo=Object.values(p),lo=M.map((e)=>e.short);function Gn(e){let t={...Un},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=Dn.includes(c);if(c&&a)t.format=c}break;case"--input-format":case"-if":if(n++,n<e.length){let c=e[n];if(jn.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=uo.some((c)=>r.startsWith(`${c}(`)),i=lo.some((c)=>r.startsWith(`${c}(`));if(s||o||i)t.expression=r;break}n++}return t}function ct(){console.log(`
76
89
  1ls - 1 line script for JSON manipulation and file operations
77
90
 
78
91
  Usage:
@@ -120,6 +133,7 @@ Output Options:
120
133
  -p, --pretty Pretty print JSON
121
134
  -c, --compact Compact JSON
122
135
  -t, --type Show value type info
136
+ -s, --strict Error on undefined properties
123
137
  --format <type> Output format (json|yaml|csv|table)
124
138
  -h, --help Show help
125
139
  -v, --version Show version
@@ -145,15 +159,21 @@ Examples:
145
159
  1ls --shorten ".map(x => x * 2)" # Convert to shorthand
146
160
  1ls --expand ".mp(x => x * 2)" # Convert to full form
147
161
  1ls --shortcuts # Show all shortcuts
148
- `)}Wt();Jt();zt();Ht();Yt();var A={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"},co=[{regex:/"([^"]+)":/g,replacement:`${A.cyan}"$1"${A.reset}:`},{regex:/: "([^"]*)"/g,replacement:`: ${A.green}"$1"${A.reset}`},{regex:/: (-?\d+\.?\d*)/g,replacement:`: ${A.yellow}$1${A.reset}`},{regex:/: (true|false)/g,replacement:`: ${A.magenta}$1${A.reset}`},{regex:/: (null)/g,replacement:`: ${A.gray}$1${A.reset}`},{regex:/([{[])/g,replacement:`${A.gray}$1${A.reset}`},{regex:/([}\]])/g,replacement:`${A.gray}$1${A.reset}`}];function Mn(t){if(process.env.NO_COLOR)return t;return co.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function Ln(t){if(process.env.NO_COLOR)return t;return`${A.yellow}${t}${A.reset}`}function Zt(t){if(process.env.NO_COLOR)return t;return`${A.cyan}${t}${A.reset}`}class st{options;constructor(t){this.options=t}format(t){if(this.options.raw)return this.formatRaw(t);if(this.options.type)return this.formatWithType(t);switch(this.options.format){case"yaml":return this.formatYaml(t);case"csv":return this.formatCsv(t);case"table":return this.formatTable(t);default:return this.formatJson(t)}}formatRaw(t){if(typeof t==="string")return t;if(t===void 0)return"";if(t===null)return"null";if(typeof t==="object")return JSON.stringify(t);return String(t)}formatJson(t){if(t===void 0)return"undefined";if(this.options.compact)return JSON.stringify(t);if(this.options.pretty){let e=JSON.stringify(t,null,2);return Mn(e)}return JSON.stringify(t,null,2)}formatWithType(t){let e=Array.isArray(t)?"array":typeof t,n=this.formatJson(t);return`[${e}] ${n}`}formatYaml(t){return this.toYaml(t,0)}toYaml(t,e){let n=" ".repeat(e);if(t===null||t===void 0)return"null";if(typeof t==="string")return t.includes(`
149
- `)||t.includes('"')||t.includes("'")?`|
150
- ${n} ${t.replace(/\n/g,`
151
- `+n+" ")}`:t;if(typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t)){if(t.length===0)return"[]";return t.map((r)=>`${n}- ${this.toYaml(r,e+2).trim()}`).join(`
152
- `)}if(typeof t==="object"){let r=Object.entries(t);if(r.length===0)return"{}";return r.map(([o,s])=>{let i=this.toYaml(s,e+2);if(typeof s==="object"&&s!==null)return`${n}${o}:
153
- ${i}`;return`${n}${o}: ${i}`}).join(`
154
- `)}return String(t)}formatCsv(t){if(!Array.isArray(t))return this.formatJson(t);if(t.length===0)return"";if(typeof t[0]==="object"&&t[0]!==null&&!Array.isArray(t[0])){let e=Object.keys(t[0]),n=e.join(","),r=t.map((o)=>e.map((s)=>this.escapeCsvValue(o[s])).join(","));return[n,...r].join(`
155
- `)}return t.map((e)=>this.escapeCsvValue(e)).join(`
156
- `)}escapeCsvValue(t){if(t===null||t===void 0)return"";let e=String(t);if(e.includes(",")||e.includes('"')||e.includes(`
157
- `))return`"${e.replace(/"/g,'""')}"`;return e}formatTable(t){if(!Array.isArray(t))return this.formatJson(t);if(t.length===0)return"(empty array)";if(typeof t[0]==="object"&&t[0]!==null&&!Array.isArray(t[0]))return this.formatObjectTable(t);return t.map((e,n)=>`${n}: ${this.formatRaw(e)}`).join(`
158
- `)}formatObjectTable(t){let e=[...new Set(t.flatMap((i)=>Object.keys(i)))],n={};e.forEach((i)=>{n[i]=Math.max(i.length,...t.map((c)=>String(c[i]??"").length))});let r=e.map((i)=>i.padEnd(n[i])).join(" | "),o=e.map((i)=>"-".repeat(n[i])).join("-+-"),s=t.map((i)=>e.map((c)=>String(i[c]??"").padEnd(n[c])).join(" | "));return[r,o,...s].join(`
159
- `)}}Et();xt();var ci=()=>Promise.resolve().then(() => (mr(),hr));async function ai(t){let e=await xn(t.grep,t.find,{recursive:t.recursive,ignoreCase:t.ignoreCase,showLineNumbers:t.showLineNumbers});if(e.length===0){console.log(Ln("No matches found"));return}for(let n of e){let r=`${Zt(n.file)}:${n.line}:${n.column}`,o=t.showLineNumbers?`${r}: ${n.match}`:`${Zt(n.file)}: ${n.match}`;console.log(o)}}async function ui(t,e){if(t.readFile){let s=e[e.indexOf("readFile")+1],i=await yt(s);return t.expression=e[e.indexOf("readFile")+2]||".",i}let n=!process.stdin.isTTY,r=t.list||t.grep;if(!n&&!r)Ct(),process.exit(1);if(n)return await pn(t.inputFormat);return null}async function fr(t,e){if(!t.expression){let n=new st(t);console.log(n.format(e));return}try{let n=ot(t.expression),o=new et(n).tokenize(),i=new nt(o).parse(),a=new rt().evaluate(i,e),u=new st(t);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 li(t){let e=Te(t);if(e.help)Ct(),process.exit(0);if(e.version){let r=await Bun.file("package.json").json();console.log(`1ls version ${r.version}`),process.exit(0)}if(e.shortcuts)console.log(Bn()),process.exit(0);if(e.shorten)console.log(_n(e.shorten)),process.exit(0);if(e.expand)console.log(ot(e.expand)),process.exit(0);if(e.detect){if(!!process.stdin.isTTY)console.error("Error: --detect requires input from stdin"),process.exit(1);let o=await Bun.stdin.text(),s=Gt(o);console.log(s),process.exit(0)}if(e.list){let r=await Ut(e.list,{recursive:e.recursive,extensions:e.extensions,maxDepth:e.maxDepth});console.log(new st(e).format(r));return}if(e.grep&&e.find){await ai(e);return}if(e.readFile){let r=t[t.indexOf("readFile")+1],o=await yt(r),s=t[t.indexOf("readFile")+2]||".",i=s===".";if(e.interactive||i){let{runInteractive:a}=await ci();await a(o);return}e.expression=s,await fr(e,o);return}if(e.interactive)console.error("Error: Interactive mode requires a file path. Use: 1ls readFile <path>"),process.exit(1);let n=await ui(e,t);await fr(e,n)}if(import.meta.main)li(process.argv.slice(2)).catch((t)=>{console.error("Error:",t.message),process.exit(1)});export{fr as processExpression,li as main,ui as loadData,ai as handleGrepOperation,ci as getInteractive};
162
+ `)}H();function Si(e){return e.trim().split(`
163
+ `).filter((t)=>t.length>0)}async function Me(e,t){switch(t??At(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(() => (tr(),er));return r(e)}case"yaml":{let{parseYAML:r}=await Promise.resolve().then(() => (pr(),lr));return r(e)}case"toml":{let{parseTOML:r}=await Promise.resolve().then(() => (dr(),hr));return r(e)}case"xml":{let{parseXML:r}=await Promise.resolve().then(() => (gr(),fr));return r(e)}case"ini":{let{parseINI:r}=await Promise.resolve().then(() => (br(),Sr));return r(e)}case"csv":{let{parseCSV:r}=await Promise.resolve().then(() => (Tt(),bt));return r(e)}case"tsv":{let{parseTSV:r}=await Promise.resolve().then(() => (Tt(),bt));return r(e)}case"protobuf":{let{parseProtobuf:r}=await Promise.resolve().then(() => Er);return r(e)}case"javascript":{let{parseJavaScript:r}=await Promise.resolve().then(() => vr);return r(e)}case"typescript":{let{parseTypeScript:r}=await Promise.resolve().then(() => (Cr(),Mr));return r(e)}case"env":{let{parseENV:r}=await Promise.resolve().then(() => (kr(),Fr));return r(e)}case"ndjson":{let{parseNDJSON:r}=await Promise.resolve().then(() => Lr);return r(e)}case"lines":return Si(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 bi=(e)=>{let t=e.trim();if(!t)return!0;try{return JSON.parse(t),!0}catch{return!1}},_r=(e,t)=>(e.match(t)||[]).length;function Ti(e){let t=e.split(`
166
+ `),n=b.NDJSON_FEATURES.test(e),r=t.every(bi);if(n&&r)return"ndjson";let o=t[0],i=_r(o,/,/g),c=_r(o,/\t/g);if(c>0&&c>=i)return"tsv";if(i>0)return"csv";return"lines"}function Ai(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 Ei=(e)=>{try{return JSON.parse(e),"json"}catch{return b.JSON5_FEATURES.test(e)?"json5":null}},Ni=(e,t,n)=>{if(t==="{"&&n==="}"||t==="["&&n==="]")return Ei(e);return null},Oi=(e)=>{let t=e.startsWith("<?xml"),n=/<\/\w+>/.test(e);return t||n?"xml":null},wi=(e)=>b.TS_INTERFACE.test(e)||b.TS_TYPE_ALIAS.test(e)||b.TS_TYPE_ANNOTATION.test(e),Ri=(e)=>{if(!b.JS_EXPORT.test(e))return null;return wi(e)?"typescript":"javascript"},Ii=(e,t,n)=>{switch(t){case"{":case"[":return Ni(e,t,n);case"<":return Oi(e);case"-":return e.startsWith("---")?"yaml":null;case"e":return Ri(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}},vi=(e)=>{if(e.includes("="))return Ai(e);let n=e.includes(": "),r=/^[\s]*-\s+/m.test(e);if(n||r)return"yaml";if(e.includes(`
167
+ `))return Ti(e);return null};function At(e){let t=e.trim();if(!t)return"text";let n=t[0],r=t[t.length-1],s=Ii(t,n,r);if(s)return s;let o=vi(t);if(o)return o;return"text"}async function Br(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 Me(n,e)}var Dr=[".ts",".js",".tsx",".jsx"],jr=[".json",".yml",".yaml"],Ur=[".md",".txt"],Et=[...Dr,...jr,...Ur];async function ee(e,t=!0){let r=await Bun.file(e).text();if(!t)return r;return Me(r)}import{stat as Mi}from"fs/promises";import{extname as Ci,basename as Pi}from"path";var Vr=(e,t)=>({path:e,name:Pi(e),ext:Ci(e),size:Number(t.size),isDirectory:t.isDirectory(),isFile:t.isFile(),modified:t.mtime,created:t.birthtime}),Nt=async(e)=>{let t=await Mi(e);return Vr(e,t)};var $r=(e)=>e.startsWith("."),Ot=(e,t)=>t||!$r(e),Hr=(e,t)=>{return t===void 0||t.includes(e)},Gr=(e,t)=>{return t===void 0||t.test(e)},wt=(e,t,n)=>{let r=Hr(e.ext,t),s=Gr(e.name,n);return r&&s},Rt=(e,t)=>{return e<=(t??1/0)};import{readdir as Fi}from"fs/promises";import{join as ki}from"path";var Wr=async(e,t,n,r)=>{if(!Ot(t,r.includeHidden??!1))return[];let o=ki(e,t),i=await Nt(o);if(i.isFile)return wt(i,r.extensions,r.pattern)?[i]:[];if(!i.isDirectory)return[];let a=r.recursive===!0?await It(o,n+1,r):[];return[i,...a]},It=async(e,t,n)=>{if(!Rt(t,n.maxDepth))return[];let s=await Fi(e);return(await Promise.all(s.map((i)=>Wr(e,i,t,n)))).flat()},ae=async(e,t={})=>It(e,0,t);import{stat as Li}from"fs/promises";var Jr=(e,t)=>{if(typeof e!=="string")return e;return new RegExp(e,t?"gi":"g")},zr=(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)}},Qr=(e,t,n)=>{if(!n)return;let r=t instanceof Error?t.message:String(t);console.error(`Failed to search ${e}: ${r}`)},Kr=(e,t,n,r,s,o)=>[...e.matchAll(n)].map((i)=>zr(r,t,i.index,e,s,o));var vt=async(e,t,n)=>{try{let r=await ee(e,!1);if(typeof r!=="string")return[];let o=r.split(`
168
+ `),i=o.flatMap((a,u)=>Kr(a,u,t,e,o,n.context)),c=n.maxMatches??1/0;return i.slice(0,c)}catch(r){return Qr(e,r,n.verbose??!1),[]}},Yr=async(e,t,n)=>{let r=await ae(e,{recursive:!0,extensions:[...Et]});return(await Promise.all(r.filter((o)=>o.isFile).map((o)=>vt(o.path,t,n)))).flat()};async function Mt(e,t,n={}){let r=Jr(e,n.ignoreCase??!1),s=await Li(t);if(s.isFile())return vt(t,r,n);if(s.isDirectory()&&n.recursive)return Yr(t,r,n);return[]}Pe();_e();We();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"},Di=[{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 as(e){if(process.env.NO_COLOR)return e;return Di.reduce((t,{regex:n,replacement:r})=>t.replace(n,r),e)}function us(e){if(process.env.NO_COLOR)return e;return`${T.yellow}${e}${T.reset}`}function Xt(e){if(process.env.NO_COLOR)return e;return`${T.cyan}${e}${T.reset}`}class de{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 as(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
+ `)}}oe();var ls="0.1.13";var jc=()=>Promise.resolve().then(() => (qs(),Xs));async function Uc(e){let t=await Mt(e.grep,e.find,{recursive:e.recursive,ignoreCase:e.ignoreCase,showLineNumbers:e.showLineNumbers});if(t.length===0){console.log(us("No matches found"));return}for(let n of t){let r=`${Xt(n.file)}:${n.line}:${n.column}`,s=e.showLineNumbers?`${r}: ${n.match}`:`${Xt(n.file)}: ${n.match}`;console.log(s)}}async function Vc(e,t){if(e.readFile){let o=t[t.indexOf("readFile")+1],i=await ee(o);return e.expression=t[t.indexOf("readFile")+2]||".",i}let n=!process.stdin.isTTY,r=e.list||e.grep;if(!n&&!r)ct(),process.exit(1);if(n)return await Br(e.inputFormat);return null}async function Zs(e,t){if(!e.expression){let n=new de(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 de(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 $c(e){let t=Gn(e);if(t.help)ct(),process.exit(0);if(t.version)console.log(`1ls version ${ls}`),process.exit(0);if(t.shortcuts)console.log(Hn()),process.exit(0);if(t.shorten)console.log($n(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=At(s);console.log(o),process.exit(0)}if(t.list){let r=await ae(t.list,{recursive:t.recursive,extensions:t.extensions,maxDepth:t.maxDepth});console.log(new de(t).format(r));return}if(t.grep&&t.find){await Uc(t);return}if(t.readFile){let r=e[e.indexOf("readFile")+1],s=await ee(r),o=e[e.indexOf("readFile")+2]||".",i=o===".";if(t.interactive||i){let{runInteractive:a}=await jc();await a(s);return}t.expression=o,await Zs(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 Vc(t,e);await Zs(t,n)}if(import.meta.main)$c(process.argv.slice(2)).catch((e)=>{console.error("Error:",e.message),process.exit(1)});export{Zs as processExpression,$c as main,Vc as loadData,Uc as handleGrepOperation,jc as getInteractive};