@limai.io/cli 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -25,7 +25,7 @@ Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[t]?this._life
25
25
  `),this._exit(0,"commander.version",t)}),this}description(t,e){return t===void 0&&e===void 0?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(t);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${i}'`)}return e._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(e=>this.alias(e)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(n=>tu(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=pt.basename(t,pt.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let e=this.createHelp(),n=this._getOutputContext(t);e.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=e.formatHelp(this,e);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(t){t=t||{};let e=!!t.error,n,i,r;return e?(n=a=>this._outputConfiguration.writeErr(a),i=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(n=a=>this._outputConfiguration.writeOut(a),i=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth()),{error:e,write:a=>(i||(a=this._outputConfiguration.stripColor(a)),n(a)),hasColors:i,helpWidth:r}}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);let n=this._getOutputContext(t),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let r=this.helpInformation({error:n.error});if(e&&(r=e(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(t,e){return typeof t=="boolean"?(t?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(t=t??"-h, --help",e=e??"display help for command",this._helpOption=this.createOption(t,e),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let e=Number($.exitCode??0);e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let n=["beforeAll","before","after","afterAll"];if(!n.includes(t))throw new Error(`Unexpected value for position to addHelpText.
26
26
  Expecting one of '${n.join("', '")}'`);let i=`${t}Help`;return this.on(i,r=>{let o;typeof e=="function"?o=e({error:r.error,command:r.command}):o=e,o&&r.write(`${o}
27
27
  `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(i=>e.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function fs(s){return s.map(t=>{if(!t.startsWith("--inspect"))return t;let e,n="127.0.0.1",i="9229",r;return(r=t.match(/^(--inspect(-brk)?)$/))!==null?e=r[1]:(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=r[1],n=r[3],i=r[4]),e&&i!=="0"?`${e}=${n}:${parseInt(i)+1}`:t})}function Ln(){if($.env.NO_COLOR||$.env.FORCE_COLOR==="0"||$.env.FORCE_COLOR==="false")return!1;if($.env.FORCE_COLOR||$.env.CLICOLOR_FORCE!==void 0)return!0}Mn.Command=jn;Mn.useColor=Ln});var ys=P(X=>{"use strict";var{Argument:hs}=we(),{Command:Un}=gs(),{CommanderError:su,InvalidArgumentError:Fs}=Xt(),{Help:ru}=Rn(),{Option:Cs}=$n();X.program=new Un;X.createCommand=s=>new Un(s);X.createOption=(s,t)=>new Cs(s,t);X.createArgument=(s,t)=>new hs(s,t);X.Command=Un;X.Option=Cs;X.Argument=hs;X.Help=ru;X.CommanderError=su;X.InvalidArgumentError=Fs;X.InvalidOptionArgumentError=Fs});var Ir=P((Lp,tl)=>{tl.exports={dots:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},dots2:{interval:80,frames:["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"]},dots3:{interval:80,frames:["\u280B","\u2819","\u281A","\u281E","\u2816","\u2826","\u2834","\u2832","\u2833","\u2813"]},dots4:{interval:80,frames:["\u2804","\u2806","\u2807","\u280B","\u2819","\u2838","\u2830","\u2820","\u2830","\u2838","\u2819","\u280B","\u2807","\u2806"]},dots5:{interval:80,frames:["\u280B","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B"]},dots6:{interval:80,frames:["\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2834","\u2832","\u2812","\u2802","\u2802","\u2812","\u281A","\u2819","\u2809","\u2801"]},dots7:{interval:80,frames:["\u2808","\u2809","\u280B","\u2813","\u2812","\u2810","\u2810","\u2812","\u2816","\u2826","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808"]},dots8:{interval:80,frames:["\u2801","\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808","\u2808"]},dots9:{interval:80,frames:["\u28B9","\u28BA","\u28BC","\u28F8","\u28C7","\u2867","\u2857","\u284F"]},dots10:{interval:80,frames:["\u2884","\u2882","\u2881","\u2841","\u2848","\u2850","\u2860"]},dots11:{interval:100,frames:["\u2801","\u2802","\u2804","\u2840","\u2880","\u2820","\u2810","\u2808"]},dots12:{interval:80,frames:["\u2880\u2800","\u2840\u2800","\u2804\u2800","\u2882\u2800","\u2842\u2800","\u2805\u2800","\u2883\u2800","\u2843\u2800","\u280D\u2800","\u288B\u2800","\u284B\u2800","\u280D\u2801","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2888\u2829","\u2840\u2899","\u2804\u2859","\u2882\u2829","\u2842\u2898","\u2805\u2858","\u2883\u2828","\u2843\u2890","\u280D\u2850","\u288B\u2820","\u284B\u2880","\u280D\u2841","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2808\u2829","\u2800\u2899","\u2800\u2859","\u2800\u2829","\u2800\u2898","\u2800\u2858","\u2800\u2828","\u2800\u2890","\u2800\u2850","\u2800\u2820","\u2800\u2880","\u2800\u2840"]},dots13:{interval:80,frames:["\u28FC","\u28F9","\u28BB","\u283F","\u285F","\u28CF","\u28E7","\u28F6"]},dots8Bit:{interval:80,frames:["\u2800","\u2801","\u2802","\u2803","\u2804","\u2805","\u2806","\u2807","\u2840","\u2841","\u2842","\u2843","\u2844","\u2845","\u2846","\u2847","\u2808","\u2809","\u280A","\u280B","\u280C","\u280D","\u280E","\u280F","\u2848","\u2849","\u284A","\u284B","\u284C","\u284D","\u284E","\u284F","\u2810","\u2811","\u2812","\u2813","\u2814","\u2815","\u2816","\u2817","\u2850","\u2851","\u2852","\u2853","\u2854","\u2855","\u2856","\u2857","\u2818","\u2819","\u281A","\u281B","\u281C","\u281D","\u281E","\u281F","\u2858","\u2859","\u285A","\u285B","\u285C","\u285D","\u285E","\u285F","\u2820","\u2821","\u2822","\u2823","\u2824","\u2825","\u2826","\u2827","\u2860","\u2861","\u2862","\u2863","\u2864","\u2865","\u2866","\u2867","\u2828","\u2829","\u282A","\u282B","\u282C","\u282D","\u282E","\u282F","\u2868","\u2869","\u286A","\u286B","\u286C","\u286D","\u286E","\u286F","\u2830","\u2831","\u2832","\u2833","\u2834","\u2835","\u2836","\u2837","\u2870","\u2871","\u2872","\u2873","\u2874","\u2875","\u2876","\u2877","\u2838","\u2839","\u283A","\u283B","\u283C","\u283D","\u283E","\u283F","\u2878","\u2879","\u287A","\u287B","\u287C","\u287D","\u287E","\u287F","\u2880","\u2881","\u2882","\u2883","\u2884","\u2885","\u2886","\u2887","\u28C0","\u28C1","\u28C2","\u28C3","\u28C4","\u28C5","\u28C6","\u28C7","\u2888","\u2889","\u288A","\u288B","\u288C","\u288D","\u288E","\u288F","\u28C8","\u28C9","\u28CA","\u28CB","\u28CC","\u28CD","\u28CE","\u28CF","\u2890","\u2891","\u2892","\u2893","\u2894","\u2895","\u2896","\u2897","\u28D0","\u28D1","\u28D2","\u28D3","\u28D4","\u28D5","\u28D6","\u28D7","\u2898","\u2899","\u289A","\u289B","\u289C","\u289D","\u289E","\u289F","\u28D8","\u28D9","\u28DA","\u28DB","\u28DC","\u28DD","\u28DE","\u28DF","\u28A0","\u28A1","\u28A2","\u28A3","\u28A4","\u28A5","\u28A6","\u28A7","\u28E0","\u28E1","\u28E2","\u28E3","\u28E4","\u28E5","\u28E6","\u28E7","\u28A8","\u28A9","\u28AA","\u28AB","\u28AC","\u28AD","\u28AE","\u28AF","\u28E8","\u28E9","\u28EA","\u28EB","\u28EC","\u28ED","\u28EE","\u28EF","\u28B0","\u28B1","\u28B2","\u28B3","\u28B4","\u28B5","\u28B6","\u28B7","\u28F0","\u28F1","\u28F2","\u28F3","\u28F4","\u28F5","\u28F6","\u28F7","\u28B8","\u28B9","\u28BA","\u28BB","\u28BC","\u28BD","\u28BE","\u28BF","\u28F8","\u28F9","\u28FA","\u28FB","\u28FC","\u28FD","\u28FE","\u28FF"]},sand:{interval:80,frames:["\u2801","\u2802","\u2804","\u2840","\u2848","\u2850","\u2860","\u28C0","\u28C1","\u28C2","\u28C4","\u28CC","\u28D4","\u28E4","\u28E5","\u28E6","\u28EE","\u28F6","\u28F7","\u28FF","\u287F","\u283F","\u289F","\u281F","\u285B","\u281B","\u282B","\u288B","\u280B","\u280D","\u2849","\u2809","\u2811","\u2821","\u2881"]},line:{interval:130,frames:["-","\\","|","/"]},line2:{interval:100,frames:["\u2802","-","\u2013","\u2014","\u2013","-"]},pipe:{interval:100,frames:["\u2524","\u2518","\u2534","\u2514","\u251C","\u250C","\u252C","\u2510"]},simpleDots:{interval:400,frames:[". ",".. ","..."," "]},simpleDotsScrolling:{interval:200,frames:[". ",".. ","..."," .."," ."," "]},star:{interval:70,frames:["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"]},star2:{interval:80,frames:["+","x","*"]},flip:{interval:70,frames:["_","_","_","-","`","`","'","\xB4","-","_","_","_"]},hamburger:{interval:100,frames:["\u2631","\u2632","\u2634"]},growVertical:{interval:120,frames:["\u2581","\u2583","\u2584","\u2585","\u2586","\u2587","\u2586","\u2585","\u2584","\u2583"]},growHorizontal:{interval:120,frames:["\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u258A","\u258B","\u258C","\u258D","\u258E"]},balloon:{interval:140,frames:[" ",".","o","O","@","*"," "]},balloon2:{interval:120,frames:[".","o","O","\xB0","O","o","."]},noise:{interval:100,frames:["\u2593","\u2592","\u2591"]},bounce:{interval:120,frames:["\u2801","\u2802","\u2804","\u2802"]},boxBounce:{interval:120,frames:["\u2596","\u2598","\u259D","\u2597"]},boxBounce2:{interval:100,frames:["\u258C","\u2580","\u2590","\u2584"]},triangle:{interval:50,frames:["\u25E2","\u25E3","\u25E4","\u25E5"]},binary:{interval:80,frames:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},arc:{interval:100,frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"]},circle:{interval:120,frames:["\u25E1","\u2299","\u25E0"]},squareCorners:{interval:180,frames:["\u25F0","\u25F3","\u25F2","\u25F1"]},circleQuarters:{interval:120,frames:["\u25F4","\u25F7","\u25F6","\u25F5"]},circleHalves:{interval:50,frames:["\u25D0","\u25D3","\u25D1","\u25D2"]},squish:{interval:100,frames:["\u256B","\u256A"]},toggle:{interval:250,frames:["\u22B6","\u22B7"]},toggle2:{interval:80,frames:["\u25AB","\u25AA"]},toggle3:{interval:120,frames:["\u25A1","\u25A0"]},toggle4:{interval:100,frames:["\u25A0","\u25A1","\u25AA","\u25AB"]},toggle5:{interval:100,frames:["\u25AE","\u25AF"]},toggle6:{interval:300,frames:["\u101D","\u1040"]},toggle7:{interval:80,frames:["\u29BE","\u29BF"]},toggle8:{interval:100,frames:["\u25CD","\u25CC"]},toggle9:{interval:100,frames:["\u25C9","\u25CE"]},toggle10:{interval:100,frames:["\u3282","\u3280","\u3281"]},toggle11:{interval:50,frames:["\u29C7","\u29C6"]},toggle12:{interval:120,frames:["\u2617","\u2616"]},toggle13:{interval:80,frames:["=","*","-"]},arrow:{interval:100,frames:["\u2190","\u2196","\u2191","\u2197","\u2192","\u2198","\u2193","\u2199"]},arrow2:{interval:80,frames:["\u2B06\uFE0F ","\u2197\uFE0F ","\u27A1\uFE0F ","\u2198\uFE0F ","\u2B07\uFE0F ","\u2199\uFE0F ","\u2B05\uFE0F ","\u2196\uFE0F "]},arrow3:{interval:120,frames:["\u25B9\u25B9\u25B9\u25B9\u25B9","\u25B8\u25B9\u25B9\u25B9\u25B9","\u25B9\u25B8\u25B9\u25B9\u25B9","\u25B9\u25B9\u25B8\u25B9\u25B9","\u25B9\u25B9\u25B9\u25B8\u25B9","\u25B9\u25B9\u25B9\u25B9\u25B8"]},bouncingBar:{interval:80,frames:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},bouncingBall:{interval:80,frames:["( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF)","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","(\u25CF )"]},smiley:{interval:200,frames:["\u{1F604} ","\u{1F61D} "]},monkey:{interval:300,frames:["\u{1F648} ","\u{1F648} ","\u{1F649} ","\u{1F64A} "]},hearts:{interval:100,frames:["\u{1F49B} ","\u{1F499} ","\u{1F49C} ","\u{1F49A} ","\u2764\uFE0F "]},clock:{interval:100,frames:["\u{1F55B} ","\u{1F550} ","\u{1F551} ","\u{1F552} ","\u{1F553} ","\u{1F554} ","\u{1F555} ","\u{1F556} ","\u{1F557} ","\u{1F558} ","\u{1F559} ","\u{1F55A} "]},earth:{interval:180,frames:["\u{1F30D} ","\u{1F30E} ","\u{1F30F} "]},material:{interval:17,frames:["\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"]},moon:{interval:80,frames:["\u{1F311} ","\u{1F312} ","\u{1F313} ","\u{1F314} ","\u{1F315} ","\u{1F316} ","\u{1F317} ","\u{1F318} "]},runner:{interval:140,frames:["\u{1F6B6} ","\u{1F3C3} "]},pong:{interval:80,frames:["\u2590\u2802 \u258C","\u2590\u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802\u258C","\u2590 \u2820\u258C","\u2590 \u2840\u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590\u2820 \u258C"]},shark:{interval:120,frames:["\u2590|\\____________\u258C","\u2590_|\\___________\u258C","\u2590__|\\__________\u258C","\u2590___|\\_________\u258C","\u2590____|\\________\u258C","\u2590_____|\\_______\u258C","\u2590______|\\______\u258C","\u2590_______|\\_____\u258C","\u2590________|\\____\u258C","\u2590_________|\\___\u258C","\u2590__________|\\__\u258C","\u2590___________|\\_\u258C","\u2590____________|\\\u258C","\u2590____________/|\u258C","\u2590___________/|_\u258C","\u2590__________/|__\u258C","\u2590_________/|___\u258C","\u2590________/|____\u258C","\u2590_______/|_____\u258C","\u2590______/|______\u258C","\u2590_____/|_______\u258C","\u2590____/|________\u258C","\u2590___/|_________\u258C","\u2590__/|__________\u258C","\u2590_/|___________\u258C","\u2590/|____________\u258C"]},dqpb:{interval:100,frames:["d","q","p","b"]},weather:{interval:100,frames:["\u2600\uFE0F ","\u2600\uFE0F ","\u2600\uFE0F ","\u{1F324} ","\u26C5\uFE0F ","\u{1F325} ","\u2601\uFE0F ","\u{1F327} ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u26C8 ","\u{1F328} ","\u{1F327} ","\u{1F328} ","\u2601\uFE0F ","\u{1F325} ","\u26C5\uFE0F ","\u{1F324} ","\u2600\uFE0F ","\u2600\uFE0F "]},christmas:{interval:400,frames:["\u{1F332}","\u{1F384}"]},grenade:{interval:80,frames:["\u060C ","\u2032 "," \xB4 "," \u203E "," \u2E0C"," \u2E0A"," |"," \u204E"," \u2055"," \u0DF4 "," \u2053"," "," "," "]},point:{interval:125,frames:["\u2219\u2219\u2219","\u25CF\u2219\u2219","\u2219\u25CF\u2219","\u2219\u2219\u25CF","\u2219\u2219\u2219"]},layer:{interval:150,frames:["-","=","\u2261"]},betaWave:{interval:80,frames:["\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"]},fingerDance:{interval:160,frames:["\u{1F918} ","\u{1F91F} ","\u{1F596} ","\u270B ","\u{1F91A} ","\u{1F446} "]},fistBump:{interval:80,frames:["\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ","\u3000\u{1F91C}\u3000\u3000\u{1F91B}\u3000 ","\u3000\u3000\u{1F91C}\u{1F91B}\u3000\u3000 ","\u3000\u{1F91C}\u2728\u{1F91B}\u3000\u3000 ","\u{1F91C}\u3000\u2728\u3000\u{1F91B}\u3000 "]},soccerHeader:{interval:80,frames:[" \u{1F9D1}\u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F\u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} ","\u{1F9D1} \u26BD\uFE0F \u{1F9D1} "]},mindblown:{interval:160,frames:["\u{1F610} ","\u{1F610} ","\u{1F62E} ","\u{1F62E} ","\u{1F626} ","\u{1F626} ","\u{1F627} ","\u{1F627} ","\u{1F92F} ","\u{1F4A5} ","\u2728 ","\u3000 ","\u3000 ","\u3000 "]},speaker:{interval:160,frames:["\u{1F508} ","\u{1F509} ","\u{1F50A} ","\u{1F509} "]},orangePulse:{interval:100,frames:["\u{1F538} ","\u{1F536} ","\u{1F7E0} ","\u{1F7E0} ","\u{1F536} "]},bluePulse:{interval:100,frames:["\u{1F539} ","\u{1F537} ","\u{1F535} ","\u{1F535} ","\u{1F537} "]},orangeBluePulse:{interval:100,frames:["\u{1F538} ","\u{1F536} ","\u{1F7E0} ","\u{1F7E0} ","\u{1F536} ","\u{1F539} ","\u{1F537} ","\u{1F535} ","\u{1F535} ","\u{1F537} "]},timeTravel:{interval:100,frames:["\u{1F55B} ","\u{1F55A} ","\u{1F559} ","\u{1F558} ","\u{1F557} ","\u{1F556} ","\u{1F555} ","\u{1F554} ","\u{1F553} ","\u{1F552} ","\u{1F551} ","\u{1F550} "]},aesthetic:{interval:80,frames:["\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0","\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"]},dwarfFortress:{interval:80,frames:[" \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A \u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A \xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A \xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\u2593\xA3 "," \u263A\u2593\xA3 "," \u263A\u2592\xA3 "," \u263A\u2592\xA3 "," \u263A\u2591\xA3 "," \u263A\u2591\xA3 "," \u263A \xA3 "," \u263A\xA3 "," \u263A\xA3 "," \u263A\u2593 "," \u263A\u2593 "," \u263A\u2592 "," \u263A\u2592 "," \u263A\u2591 "," \u263A\u2591 "," \u263A "," \u263A &"," \u263A \u263C&"," \u263A \u263C &"," \u263A\u263C &"," \u263A\u263C & "," \u203C & "," \u263A & "," \u203C & "," \u263A & "," \u203C & "," \u263A & ","\u203C & "," & "," & "," & \u2591 "," & \u2592 "," & \u2593 "," & \xA3 "," & \u2591\xA3 "," & \u2592\xA3 "," & \u2593\xA3 "," & \xA3\xA3 "," & \u2591\xA3\xA3 "," & \u2592\xA3\xA3 ","& \u2593\xA3\xA3 ","& \xA3\xA3\xA3 "," \u2591\xA3\xA3\xA3 "," \u2592\xA3\xA3\xA3 "," \u2593\xA3\xA3\xA3 "," \u2588\xA3\xA3\xA3 "," \u2591\u2588\xA3\xA3\xA3 "," \u2592\u2588\xA3\xA3\xA3 "," \u2593\u2588\xA3\xA3\xA3 "," \u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "]}}});var Fi=P((Mp,_r)=>{"use strict";var Ze=Object.assign({},Ir()),Ar=Object.keys(Ze);Object.defineProperty(Ze,"random",{get(){let s=Math.floor(Math.random()*Ar.length),t=Ar[s];return Ze[t]}});_r.exports=Ze});var no=P((FD,eo)=>{"use strict";var Oi=class{constructor(t,e,n){this.etaBufferLength=t||100,this.valueBuffer=[n],this.timeBuffer=[e],this.eta="0"}update(t,e,n){this.valueBuffer.push(e),this.timeBuffer.push(t),this.calculate(n-e)}getTime(){return this.eta}calculate(t){let e=this.valueBuffer.length,n=Math.min(this.etaBufferLength,e),i=this.valueBuffer[e-1]-this.valueBuffer[e-n],r=this.timeBuffer[e-1]-this.timeBuffer[e-n],o=i/r;this.valueBuffer=this.valueBuffer.slice(-this.etaBufferLength),this.timeBuffer=this.timeBuffer.slice(-this.etaBufferLength);let a=Math.ceil(t/o/1e3);isNaN(a)?this.eta="NULL":isFinite(a)?a>1e7?this.eta="INF":a<0?this.eta=0:this.eta=a:this.eta="INF"}};eo.exports=Oi});var Bi=P((CD,io)=>{"use strict";var _t=require("readline"),ki=class{constructor(t){this.stream=t,this.linewrap=!0,this.dy=0}cursorSave(){this.stream.isTTY&&this.stream.write("\x1B7")}cursorRestore(){this.stream.isTTY&&this.stream.write("\x1B8")}cursor(t){this.stream.isTTY&&(t?this.stream.write("\x1B[?25h"):this.stream.write("\x1B[?25l"))}cursorTo(t=null,e=null){this.stream.isTTY&&_t.cursorTo(this.stream,t,e)}cursorRelative(t=null,e=null){this.stream.isTTY&&(this.dy=this.dy+e,_t.moveCursor(this.stream,t,e))}cursorRelativeReset(){this.stream.isTTY&&(_t.moveCursor(this.stream,0,-this.dy),_t.cursorTo(this.stream,0,null),this.dy=0)}clearRight(){this.stream.isTTY&&_t.clearLine(this.stream,1)}clearLine(){this.stream.isTTY&&_t.clearLine(this.stream,0)}clearBottom(){this.stream.isTTY&&_t.clearScreenDown(this.stream)}newline(){this.stream.write(`
28
- `),this.dy++}write(t,e=!1){this.linewrap===!0&&e===!1?this.stream.write(t.substr(0,this.getWidth())):this.stream.write(t)}lineWrapping(t){this.stream.isTTY&&(this.linewrap=t,t?this.stream.write("\x1B[?7h"):this.stream.write("\x1B[?7l"))}isTTY(){return this.stream.isTTY===!0}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}};io.exports=ki});var ro=P((yD,so)=>{"use strict";so.exports=({onlyFirst:s=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,s?void 0:"g")}});var ao=P((ED,oo)=>{"use strict";var Pl=ro();oo.exports=s=>typeof s=="string"?s.replace(Pl(),""):s});var lo=P((bD,$i)=>{"use strict";var uo=s=>Number.isNaN(s)?!1:s>=4352&&(s<=4447||s===9001||s===9002||11904<=s&&s<=12871&&s!==12351||12880<=s&&s<=19903||19968<=s&&s<=42182||43360<=s&&s<=43388||44032<=s&&s<=55203||63744<=s&&s<=64255||65040<=s&&s<=65049||65072<=s&&s<=65131||65281<=s&&s<=65376||65504<=s&&s<=65510||110592<=s&&s<=110593||127488<=s&&s<=127569||131072<=s&&s<=262141);$i.exports=uo;$i.exports.default=uo});var po=P((wD,co)=>{"use strict";co.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var Do=P((ID,Pi)=>{"use strict";var Nl=ao(),jl=lo(),Ll=po(),mo=s=>{if(typeof s!="string"||s.length===0||(s=Nl(s),s.length===0))return 0;s=s.replace(Ll()," ");let t=0;for(let e=0;e<s.length;e++){let n=s.codePointAt(e);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&e++,t+=jl(n)?2:1)}return t};Pi.exports=mo;Pi.exports.default=mo});var Ni=P((AD,fo)=>{"use strict";fo.exports=function(t,e,n){if(e.autopadding!==!0)return t;function i(r,o){return(e.autopaddingChar+r).slice(-o)}return n==="percentage"?i(t,3):t}});var ji=P((_D,go)=>{"use strict";go.exports=function(t,e){let n=Math.round(t*e.barsize),i=e.barsize-n;return e.barCompleteString.substr(0,n)+e.barGlue+e.barIncompleteString.substr(0,i)}});var Li=P((vD,ho)=>{"use strict";ho.exports=function(t,e,n){function i(o){return n?n*Math.round(o/n):o}function r(o){return(e.autopaddingChar+o).slice(-2)}return t>3600?r(Math.floor(t/3600))+"h"+r(i(t%3600/60))+"m":t>60?r(Math.floor(t/60))+"m"+r(i(t%60))+"s":t>10?r(i(t))+"s":r(t)+"s"}});var Mi=P((SD,Fo)=>{"use strict";var Ml=Do(),Ul=Ni(),Wl=ji(),Vl=Li();Fo.exports=function(t,e,n){let i=t.format,r=t.formatTime||Vl,o=t.formatValue||Ul,a=t.formatBar||Wl,u=Math.floor(e.progress*100)+"",l=e.stopTime||Date.now(),c=Math.round((l-e.startTime)/1e3),d=Object.assign({},n,{bar:a(e.progress,t),percentage:o(u,t,"percentage"),total:o(e.total,t,"total"),value:o(e.value,t,"value"),eta:o(e.eta,t,"eta"),eta_formatted:r(e.eta,t,5),duration:o(c,t,"duration"),duration_formatted:r(c,t,1)});i=i.replace(/\{(\w+)\}/g,function(F,A){return typeof d[A]<"u"?d[A]:F});let m=Math.max(0,e.maxWidth-Ml(i)-2),h=Math.floor(m/2);switch(t.align){case"right":i=m>0?" ".repeat(m)+i:i;break;case"center":i=h>0?" ".repeat(h)+i:i;break;default:break}return i}});var un=P((xD,Co)=>{"use strict";function j(s,t){return typeof s>"u"||s===null?t:s}Co.exports={parse:function(t,e){let n={},i=Object.assign({},e,t);return n.throttleTime=1e3/j(i.fps,10),n.stream=j(i.stream,process.stderr),n.terminal=j(i.terminal,null),n.clearOnComplete=j(i.clearOnComplete,!1),n.stopOnComplete=j(i.stopOnComplete,!1),n.barsize=j(i.barsize,40),n.align=j(i.align,"left"),n.hideCursor=j(i.hideCursor,!1),n.linewrap=j(i.linewrap,!1),n.barGlue=j(i.barGlue,""),n.barCompleteChar=j(i.barCompleteChar,"="),n.barIncompleteChar=j(i.barIncompleteChar,"-"),n.format=j(i.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),n.formatTime=j(i.formatTime,null),n.formatValue=j(i.formatValue,null),n.formatBar=j(i.formatBar,null),n.etaBufferLength=j(i.etaBuffer,10),n.etaAsynchronousUpdate=j(i.etaAsynchronousUpdate,!1),n.progressCalculationRelative=j(i.progressCalculationRelative,!1),n.synchronousUpdate=j(i.synchronousUpdate,!0),n.noTTYOutput=j(i.noTTYOutput,!1),n.notTTYSchedule=j(i.notTTYSchedule,2e3),n.emptyOnZero=j(i.emptyOnZero,!1),n.forceRedraw=j(i.forceRedraw,!1),n.autopadding=j(i.autopadding,!1),n.gracefulExit=j(i.gracefulExit,!1),n},assignDerivedOptions:function(t){return t.barCompleteString=t.barCompleteChar.repeat(t.barsize+1),t.barIncompleteString=t.barIncompleteChar.repeat(t.barsize+1),t.autopaddingChar=t.autopadding?j(t.autopaddingChar," "):"",t}}});var Ui=P((RD,Eo)=>{"use strict";var yo=no(),Jl=Bi(),Hl=Mi(),ql=un(),Gl=require("events");Eo.exports=class extends Gl{constructor(t){super(),this.options=ql.assignDerivedOptions(t),this.terminal=this.options.terminal?this.options.terminal:new Jl(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new yo(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format=="function"?this.options.format:Hl}render(t=!1){let e={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};this.options.etaAsynchronousUpdate&&this.updateETA();let n=this.formatter(this.options,e,this.payload);(t||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=n)&&(this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(n),this.terminal.clearRight(),this.lastDrawnString=n,this.lastRedraw=Date.now(),this.emit("redraw-post"))}start(t,e,n){this.value=e||0,this.total=typeof t<"u"&&t>=0?t:100,this.startValue=e||0,this.payload=n||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new yo(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",t,e)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(t,e={}){typeof t=="number"&&(this.value=t,this.eta.update(Date.now(),t,this.total));let n=(typeof t=="object"?t:e)||{};this.emit("update",this.total,this.value);for(let i in n)this.payload[i]=n[i];this.value>=this.getTotal()&&this.options.stopOnComplete&&this.stop()}getProgress(){let t=this.value/this.total;return this.options.progressCalculationRelative&&(t=(this.value-this.startValue)/(this.total-this.startValue)),isNaN(t)&&(t=this.options&&this.options.emptyOnZero?0:1),t=Math.min(Math.max(t,0),1),t}increment(t=1,e={}){typeof t=="object"?this.update(this.value+1,t):this.update(this.value+t,e)}getTotal(){return this.total}setTotal(t){typeof t<"u"&&t>=0&&(this.total=t)}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}});var wo=P((kD,bo)=>{"use strict";var Kl=Ui(),Yl=un();bo.exports=class extends Kl{constructor(t,e){super(Yl.parse(t,e)),this.timer=null,this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.options.synchronousUpdate=!1),this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){this.timer&&(clearTimeout(this.timer),this.timer=null),super.render(),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&this.terminal.newline(),this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(t,e){this.timer&&(super.update(t,e),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2<Date.now()&&this.render())}start(t,e,n){this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.terminal.cursorSave(),this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),super.start(t,e,n),this.render())}stop(){this.timer&&(this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.render(),super.stop(),clearTimeout(this.timer),this.timer=null,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRestore(),this.options.clearOnComplete?(this.terminal.cursorTo(0,null),this.terminal.clearLine()):this.terminal.newline())}}});var Ao=P(($D,Io)=>{"use strict";var zl=Bi(),Xl=Ui(),Ql=un(),Zl=require("events");Io.exports=class extends Zl{constructor(t,e){super(),this.bars=[],this.options=Ql.parse(t,e),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new zl(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(t,e,n,i={}){let r=new Xl(Object.assign({},this.options,{terminal:this.terminal},i));return this.bars.push(r),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.isActive||(this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),this.timer=setTimeout(this.update.bind(this),this.schedulingRate)),this.isActive=!0,r.start(t,e,n),this.emit("start")),r}remove(t){let e=this.bars.indexOf(t);return e<0?!1:(this.bars.splice(e,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),!0)}update(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0)for(this.terminal.clearLine();this.loggingBuffer.length>0;)this.terminal.write(this.loggingBuffer.shift(),!0);for(let t=0;t<this.bars.length;t++)t>0&&this.terminal.newline(),this.bars[t].render();this.emit("redraw-post"),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.terminal.newline(),this.terminal.newline()),this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find(t=>t.isActive)&&this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.isActive=!1,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let t=0;t<this.bars.length;t++)t>0&&this.terminal.newline(),this.bars[t].render(),this.bars[t].stop();this.terminal.newline()}this.emit("stop")}log(t){this.loggingBuffer.push(t)}}});var vo=P((PD,_o)=>{"use strict";_o.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var xo=P((ND,So)=>{"use strict";So.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var Ro=P((jD,To)=>{"use strict";To.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var ko=P((LD,Oo)=>{"use strict";Oo.exports={format:" {bar}\u25A0 {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u25A0",barIncompleteChar:" "}});var $o=P((MD,Bo)=>{"use strict";var tc=vo(),ec=xo(),nc=Ro(),ic=ko();Bo.exports={legacy:tc,shades_classic:ec,shades_grey:nc,rect:ic}});var jo=P((UD,No)=>{"use strict";var Po=wo(),sc=Ao(),rc=$o(),oc=Mi(),ac=Ni(),uc=ji(),lc=Li();No.exports={Bar:Po,SingleBar:Po,MultiBar:sc,Presets:rc,Format:{Formatter:oc,BarFormat:uc,ValueFormat:ac,TimeFormat:lc}}});var Es=I(ys(),1),{program:Uc,createCommand:Wc,createArgument:Vc,createOption:Jc,CommanderError:Hc,InvalidArgumentError:nt,InvalidOptionArgumentError:qc,Command:bs,Argument:Gc,Option:Kc,Help:Yc}=Es.default;var Et=!1,ws=!1;function Is(s){Et=s}function p(){return Et}function As(s){ws=s}function D(s){console.log(JSON.stringify(s,null,2))}function _(s){Et?console.error(JSON.stringify({error:s})):(console.error(`Error: ${s.message}`),s.details&&ws&&console.error(JSON.stringify(s.details,null,2)))}function ou(s){return s instanceof Error&&"code"in s&&"exitCode"in s&&typeof s.code=="string"&&typeof s.exitCode=="number"}function _s(s){ou(s)&&(_({code:s.code,message:s.message,details:s.details}),process.exit(s.exitCode)),_({code:"UNKNOWN_ERROR",message:s instanceof Error?s.message:"Unknown error"}),process.exit(1)}function E(s){Et||console.log(`\x1B[32m${s}\x1B[0m`)}function B(s){Et||console.log(`\x1B[36m${s}\x1B[0m`)}function Y(s){Et||console.log(`\x1B[33m${s}\x1B[0m`)}function Qt(s){Et||console.log(`\x1B[2m${s}\x1B[0m`)}var ti=I(require("readline"));var q=I(require("fs")),Bt=I(require("path")),vs=I(require("os")),Ae=require("child_process"),Wn=Bt.join(vs.homedir(),".limai"),Zt=Bt.join(Wn,"config.json"),au=".limai.token",kt;function uu(s){if(!q.existsSync(s))return{};let t={};for(let e of q.readFileSync(s,"utf-8").split(/\r?\n/)){let n=e.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)\s*$/);n&&(t[n[1]]=n[2].replace(/^(["'])(.*)\1$/,"$2"))}return t}function Ss(){if(kt!==void 0)return kt;try{let s=(0,Ae.execSync)("git rev-parse --show-toplevel",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(!q.existsSync(Bt.join(s,"packages","cli")))return kt=null,null;let t=(0,Ae.execSync)("git rev-parse --git-common-dir",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim(),e="";if(t!==".git"){let i=(0,Ae.execSync)("git rev-parse --abbrev-ref HEAD",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(i){let r=i.replace(/[/\\]/g,"-").replace(/[^a-zA-Z0-9._-]/g,"").replace(/^-+|-+$/g,"");r&&(e=`${r}.`)}}let n=uu(Bt.join(s,"tables",".env.local"));return kt={root:s,apiUrl:n.NEXT_PUBLIC_BASE_URL??`https://${e}tables.localhost`,sseUrl:n.NEXT_PUBLIC_SSE_URL??`https://${e}ws.localhost`},kt}catch{return kt=null,null}}function lu(){let s=Ss();if(!s)return;let t=Bt.join(s.root,au);if(q.existsSync(t))return q.readFileSync(t,"utf-8").trim()}function $t(){let s=process.env.LIMAI_API_TOKEN,t=process.env.LIMAI_API_URL,e=process.env.LIMAI_SSE_URL,n={};if(q.existsSync(Zt))try{let u=q.readFileSync(Zt,"utf-8"),l=JSON.parse(u);l&&typeof l=="object"&&!Array.isArray(l)&&(n=l)}catch{n={}}let i=Ss(),r=s||lu()||n.token,o=t||n.apiUrl||i?.apiUrl||process.env.LIMAI_BUILD_URL||void 0,a=e||n.sseUrl||i?.sseUrl||void 0;return!r||!o?null:{token:r,apiUrl:o,sseUrl:a,defaultProjectId:n.defaultProjectId,defaultDeploymentId:n.defaultDeploymentId}}function bt(s){let t={};if(q.existsSync(Zt))try{let n=q.readFileSync(Zt,"utf-8");t=JSON.parse(n)}catch{t={}}let e={...t,...s};q.existsSync(Wn)||q.mkdirSync(Wn,{recursive:!0,mode:448}),q.writeFileSync(Zt,JSON.stringify(e,null,2),{mode:384})}function f(){let s=$t();return s||(console.error("Not authenticated. Run `npm run cli:setup` or set LIMAI_API_TOKEN environment variable."),process.exit(1)),s}function xs(){return!!process.env.LIMAI_EXECUTION_ID}var ks=require("fs"),Bs=require("fs/promises"),$s=require("stream");var R=class extends Error{code;statusCode;exitCode;details;constructor(t,e){super(t),this.name="LimaiError",this.code=e.code,this.statusCode=e.statusCode,this.exitCode=e.exitCode??1,this.details=e.details}},Vn=class extends R{constructor(t,e){super(t,{code:"AUTH_ERROR",statusCode:401,exitCode:2,details:e}),this.name="AuthError"}},Jn=class extends R{constructor(t,e){super(t,{code:"FORBIDDEN",statusCode:403,exitCode:2,details:e}),this.name="ForbiddenError"}},Hn=class extends R{constructor(t,e){super(t,{code:"NOT_FOUND",statusCode:404,exitCode:3,details:e}),this.name="NotFoundError"}},W=class extends R{constructor(t,e){super(t,{code:"VALIDATION_ERROR",statusCode:400,exitCode:4,details:e}),this.name="ValidationError"}},qn=class extends R{constructor(t,e){super(t,{code:"CONFLICT",statusCode:409,exitCode:4,details:e}),this.name="ConflictError"}},Gn=class extends R{retryAfterMs;constructor(t,e){super(t,{code:"RATE_LIMITED",statusCode:429,exitCode:5}),this.name="RateLimitError",this.retryAfterMs=e}},Kn=class extends R{constructor(t,e=500,n){super(t,{code:"SERVER_ERROR",statusCode:e,exitCode:6,details:n}),this.name="ServerError"}},Pt=class extends R{constructor(t){super(t,{code:"TIMEOUT",exitCode:7}),this.name="TimeoutError"}},gt=class extends R{constructor(t,e){super(t,{code:"UPLOAD_ERROR",exitCode:8,details:e}),this.name="UploadError"}};function Ts(s,t,e){switch(s){case 400:return new W(t,e);case 401:return new Vn(t,e);case 403:return new Jn(t,e);case 404:return new Hn(t,e);case 409:return new qn(t,e);case 429:return new Gn(t);default:return s>=500?new Kn(t,s,e):new R(t,{code:"HTTP_ERROR",statusCode:s,details:e})}}var cu=3e4,Yn=3,Rs=1e3,Os=2;function du(){return process.env.LIMAI_DEBUG==="1"}function te(...s){du()&&console.error("[limai:http]",...s)}var _e=class{baseUrl;token;constructor(t){this.baseUrl=t.apiUrl.replace(/\/$/,""),this.token=t.token}buildUrl(t,e){let n=new URL(`/api/v1${t}`,this.baseUrl);if(e)for(let[i,r]of Object.entries(e))r!=null&&n.searchParams.set(i,r);return n.toString()}authHeaders(){let t={Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},e=process.env.VERCEL_BYPASS;return e&&(t["x-vercel-protection-bypass"]=e),t}async parseErrorBody(t){try{let e=await t.json();return{message:typeof e.error=="string"?e.error:typeof e.message=="string"?e.message:`HTTP ${t.status}`,details:e.details}}catch{return{message:await t.text().catch(()=>"")||`HTTP ${t.status}`}}}shouldRetry(t){return t===429||t>=500}getRetryDelay(t,e){let n=t.headers.get("Retry-After");if(n){let i=parseInt(n,10);if(!isNaN(i))return i*1e3}return Rs*Math.pow(Os,e)}async request(t,e,n={}){let i=this.buildUrl(e,n.params),r=n.timeoutMs??cu;for(let o=0;o<=Yn;o++){let a=new AbortController,u=setTimeout(()=>a.abort(),r);n.signal&&n.signal.addEventListener("abort",()=>a.abort());try{te(`${t} ${i}${o>0?` (retry ${o})`:""}`);let l=await fetch(i,{method:t,headers:this.authHeaders(),body:n.body?JSON.stringify(n.body):void 0,signal:a.signal});if(clearTimeout(u),l.ok){let m=await l.text();return m?JSON.parse(m):{}}if(n.retry!==!1&&this.shouldRetry(l.status)&&o<Yn){let m=this.getRetryDelay(l,o);te(`Retrying in ${m}ms (status ${l.status})`),await new Promise(h=>setTimeout(h,m));continue}let{message:c,details:d}=await this.parseErrorBody(l);throw Ts(l.status,c,d)}catch(l){if(clearTimeout(u),l instanceof R)throw l;if(l instanceof DOMException&&l.name==="AbortError"){if(n.retry!==!1&&o<Yn){let c=Rs*Math.pow(Os,o);te(`Timeout, retrying in ${c}ms`),await new Promise(d=>setTimeout(d,c));continue}throw new Pt(`Request timed out after ${r}ms: ${t} ${e}`)}throw new R(l instanceof Error?l.message:"Unknown network error",{code:"NETWORK_ERROR",exitCode:1})}}throw new R("Max retries exceeded",{code:"MAX_RETRIES",exitCode:1})}async get(t,e,n){return this.request("GET",t,{params:e,timeoutMs:n})}async post(t,e,n,i){return this.request("POST",t,{body:e,timeoutMs:n,retry:i?.retry})}async patch(t,e,n){return this.request("PATCH",t,{body:e,retry:n?.retry})}async del(t,e){return this.request("DELETE",t,{body:e})}async putRaw(t,e,n,i){let r=e instanceof Blob?e.size:e.length;te(`PUT ${t} (${r} bytes)`);let o=await fetch(t,{method:"PUT",headers:{"Content-Type":n},body:e});if(i&&i(r,r),!o.ok)throw new gt(`Upload failed: HTTP ${o.status}`)}async putFile(t,e,n,i){let r=(await(0,Bs.stat)(e)).size;te(`PUT ${t} (${r} bytes, streamed from ${e})`);let o=(0,ks.createReadStream)(e),a=o;if(i){let l=0,c=new $s.Transform({transform(d,m,h){l+=d.byteLength,i(l,r),h(null,d)}});a=o.pipe(c)}let u=await fetch(t,{method:"PUT",headers:{"Content-Type":n,"Content-Length":String(r)},body:a,duplex:"half"});if(i&&i(r,r),!u.ok)throw new gt(`Upload failed: HTTP ${u.status}`);return r}};var ve=class{constructor(t){this.http=t}http;async getUploadUrl(t,e,n){let i={filename:e,contentHash:n};return this.http.get(`/document/${t}/get-url`,i)}async processSync(t,e,n){return this.http.post(`/document/${t}/process-file/${e}`,n,18e4)}async processAsync(t,e,n){return this.http.post(`/document/${t}/process-file-async/${e}`,n)}async processFilesAsync(t,e,n){return this.http.post(`/document/${t}/process-files-async`,{fileIds:e,...n})}async getFileData(t,e,n){let i={fileId:t,extractionSchemaId:e,include:n?.length?n.join(","):void 0};return this.http.get("/document/get-file-data",i)}async getFilesData(t,e){return this.http.post("/document/get-files-data",{fileIds:t,...e?.length?{include:e}:{}})}async getDocumentData(t,e,n){let i={include:n?.length?n.join(","):void 0};return this.http.get(`/deployments/${t}/documents/${e}/data`,i)}async getDocumentsData(t,e,n){return this.http.post(`/deployments/${t}/documents/data`,{fileIds:e,...n?.length?{include:n}:{}})}async submitCorrections(t,e,n){return this.http.post(`/document/${t}/process-file/${e}/submit-corrections`,n)}};var Se=class{constructor(t){this.http=t}http;async list(){let t=await this.http.get("/projects");return Array.isArray(t)?t:t.data}async create(t){return this.http.post("/projects",t)}async delete(t){return this.http.del(`/projects/${t}`)}async getSharedColumnIds(t){return this.http.get(`/projects/${t}/shared-column-ids`)}async listDeployments(t){return this.http.get(`/projects/${t}/deployments`)}async listBenchmarks(t){return this.http.get(`/projects/${t}/benchmarks`)}async listNotificationRoutes(t){return this.http.get(`/projects/${t}/notifications`)}async createNotificationRoute(t,e){return this.http.post(`/projects/${t}/notifications`,e)}async updateNotificationRoute(t,e,n){return this.http.patch(`/projects/${t}/notifications/${e}`,n)}async deleteNotificationRoute(t,e){return this.http.del(`/projects/${t}/notifications/${e}`)}async listNotificationIntegrations(t,e){return this.http.get(`/projects/${t}/notifications/integrations`,{provider:e})}async listNotificationSlackChannels(t,e){return this.http.get(`/projects/${t}/notifications/integrations/slack/channels`,{connectionId:e})}async listNotificationTeamsTeams(t,e){return this.http.get(`/projects/${t}/notifications/integrations/teams/teams`,{connectionId:e})}async listNotificationTeamsChannels(t,e,n){return this.http.get(`/projects/${t}/notifications/integrations/teams/channels`,{connectionId:e,teamId:n})}};var xe=class{constructor(t){this.http=t}http;async list(t,e){let n={status:e?.status,type:e?.type},i=await this.http.get(`/projects/${t}/deployments`,n);return Array.isArray(i)?i:i.data}async create(t,e){return this.http.post(`/projects/${t}/deployments`,e)}async getConfig(t){return this.http.get(`/deployments/${t}/configuration`)}async updateConfig(t,e){await this.http.patch(`/deployment/${t}/configuration`,e)}async listDocuments(t,e){let n={limit:e?.limit?.toString(),offset:e?.offset?.toString(),status:e?.status};return this.http.get(`/deployments/${t}/documents`,n)}async getDocument(t,e){return this.http.get(`/deployments/${t}/documents/${e}`)}async deleteDocument(t,e){await this.http.del(`/deployments/${t}/documents/${e}`)}async bulkDelete(t,e){await this.http.del(`/deployments/${t}/documents/bulk-delete`,{fileIds:e})}};var Te=class{constructor(t){this.http=t}http;async get(t){return this.http.get(`/tables/${t}`)}async listColumns(t){let e=await this.http.get(`/tables/${t}/columns`);return Array.isArray(e)?e:e.data}async listRows(t,e){let n={limit:e?.limit?.toString(),offset:e?.offset?.toString(),status:e?.status};return this.http.get(`/tables/${t}/rows`,n)}async createRows(t,e){return this.http.post(`/tables/${t}/rows`,e,6e4)}async deleteRows(t,e){return this.http.del(`/tables/${t}/rows`,e)}async createTable(t,e){return this.http.post(`/deployments/${t}/tables`,e)}async update(t,e){return this.http.patch(`/tables/${t}`,e)}};var Re=class{constructor(t){this.http=t}http;async list(t){let e=await this.http.get(`/tables/${t}/columns`);return Array.isArray(e)?e:e.data}async get(t){return this.http.get(`/columns/${t}`)}async create(t,e){let n=await this.http.post(`/tables/${t}/columns`,e);return n&&typeof n=="object"&&"data"in n?n.data:[n]}async update(t,e){return this.http.patch(`/columns/${t}`,e)}};async function*Ps(s,t={}){let e=Math.min(t.pageSize??100,500),n=0,i=0;for(;;){let r=t.maxItems?Math.min(e,t.maxItems-i):e;if(r<=0)break;let o=await s(r,n),a=o.data;if(a.length===0||(yield a,i+=a.length,n+=a.length,n>=o.pagination.total)||t.maxItems&&i>=t.maxItems)break}}async function*Ns(s,t={}){let e=Math.min(t.pageSize??100,500),n=1,i=0;for(;;){let r=t.maxItems?Math.min(e,t.maxItems-i):e;if(r<=0)break;let o=await s(n,r),a=o.data;if(a.length===0||(yield a,i+=a.length,n++,n>o.pagination.totalPages)||t.maxItems&&i>=t.maxItems)break}}async function Oe(s){let t=[];for await(let e of s)t.push(...e);return t}var ke=class{constructor(t){this.http=t}http;async getRows(t,e){let n={page:e?.page?.toString(),limit:e?.limit?.toString(),order:e?.order,status:e?.status};return this.http.get(`/extractions/${t}`,n)}async*getAllRows(t,e){yield*Ns(async(n,i)=>this.http.get(`/extractions/${t}`,{page:n.toString(),limit:i.toString(),order:e?.order,status:e?.status}),e)}async collectAllRows(t,e){return Oe(this.getAllRows(t,e))}};var Be=class{constructor(t){this.http=t}http;async getStatus(t){return this.http.get(`/queue/${t}/status`)}async cancel(t){await this.http.post("/queue/cancel",{jobId:t})}async updateStatus(t,e){return this.http.patch(`/queue/${t}/status`,e)}};var $e=class{constructor(t){this.http=t}http;async list(t){return this.http.get("/classify",{projectId:t})}async getUploadUrl(t,e){return this.http.get(`/classify/${t}/get-url`,{filename:e})}async classify(t,e){return this.http.post(`/classify/${t}`,{fileId:e})}async classifyAsync(t,e){return this.http.post(`/classify/${t}/async`,{fileId:e})}async getStatus(t,e){return this.http.get(`/classify/${t}`,{classificationId:e})}async createClassifier(t){return this.http.post("/classify",t)}async createRoute(t,e){return this.http.post(`/classify/${t}/routes`,e)}};var Pe=class{constructor(t){this.http=t}http;async list(t){return this.http.get("/split",{projectId:t})}async getUploadUrl(t,e){return this.http.get(`/split/${t}/get-url`,{filename:e})}async split(t,e){return this.http.post(`/split/${t}`,{fileId:e})}async splitAsync(t,e){return this.http.post(`/split/${t}/async`,{fileId:e})}async getStatus(t,e){return this.http.get(`/split/${t}`,{splitId:e})}async listSplits(t){return this.http.get(`/split/${t}/splits`)}async createSplitter(t){return this.http.post("/split",t)}};var Ne=class{constructor(t){this.http=t}http;async get(t){return this.http.get(`/extraction-schema/${t}`)}async update(t,e){return this.http.patch(`/extraction-schema/${t}`,e)}async getAllData(t){return this.http.get("/extraction-schema/get-all-data",{extractionSchemaId:t})}};var je=class{constructor(t){this.http=t}http;async list(t){return this.http.get(`/projects/${t}/buckets`)}async get(t){return this.http.get(`/buckets/${t}`)}async create(t,e,n){return this.http.post(`/projects/${t}/buckets`,{name:e,description:n})}async delete(t){await this.http.del(`/buckets/${t}`)}async getUploadUrl(t,e){return this.http.get(`/buckets/${t}/get-url`,{filename:e})}async confirmUpload(t,e,n){await this.http.patch(`/buckets/${t}/files/${e}/status`,{status:"UPLOADED",...n!==void 0&&{sizeBytes:n}})}async listFiles(t,e){let n={};return e&&e.length>0&&(n.labels=e.join(",")),this.http.get(`/buckets/${t}/files`,n)}async getDownloadUrl(t,e){return this.http.get(`/buckets/${t}/files/${e}/download`)}async updateLabels(t,e,n){return this.http.patch(`/buckets/${t}/files/${e}`,{labels:n})}async deleteFile(t,e){await this.http.del(`/buckets/${t}/files/${e}`)}async sendTo(t,e,n,i){return this.http.post(`/buckets/${t}/files/${e}/send-to`,{targetType:n,targetId:i})}};var Le=class{constructor(t){this.http=t}http;async list(t,e){let n={};return e?.status&&(n.status=e.status),this.http.get(`/projects/${t}/agents`,n)}async get(t,e){return this.http.get(`/projects/${t}/agents/${e}`)}async create(t,e){return this.http.post(`/projects/${t}/agents`,e)}async update(t,e,n){return this.http.patch(`/projects/${t}/agents/${e}`,n)}async delete(t,e){await this.http.del(`/projects/${t}/agents/${e}`)}async getFileUploadUrl(t,e,n){return this.http.get(`/projects/${t}/agents/${e}/files/get-url`,{filename:n})}async deleteFile(t,e,n){await this.http.del(`/projects/${t}/agents/${e}/files/${n}`)}async updateFileMetadata(t,e,n,i){return this.http.patch(`/projects/${t}/agents/${e}/files/${n}`,i)}async getFileDownloadUrl(t,e,n){return this.http.get(`/projects/${t}/agents/${e}/files/${n}/download`)}async listSkills(t,e){return this.http.get(`/projects/${t}/agents/${e}/skills`)}async createSkill(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/skills`,n)}async updateSkill(t,e,n,i){return this.http.patch(`/projects/${t}/agents/${e}/skills/${n}`,i)}async deleteSkill(t,e,n){await this.http.del(`/projects/${t}/agents/${e}/skills/${n}`)}async linkFileToSkill(t,e,n,i){return this.http.post(`/projects/${t}/agents/${e}/skills/${n}/files`,{fileId:i})}async unlinkFileFromSkill(t,e,n,i){await this.http.del(`/projects/${t}/agents/${e}/skills/${n}/files/${i}`)}async listRuns(t,e,n){let i={};return n?.limit&&(i.limit=String(n.limit)),n?.status&&(i.status=n.status),this.http.get(`/projects/${t}/agents/${e}/runs`,i)}async getRun(t,e,n){return this.http.get(`/projects/${t}/agents/${e}/runs/${n}`)}async getRunConversation(t,e,n,i){let r={};return i?.stepId&&(r.stepId=i.stepId),this.http.get(`/projects/${t}/agents/${e}/runs/${n}/conversation`,r)}async getRunInferenceLogs(t,e,n,i){let r={};return i?.limit!==void 0&&(r.limit=String(i.limit)),i?.status&&(r.status=i.status),this.http.get(`/projects/${t}/agents/${e}/runs/${n}/inference-logs`,r)}async createRun(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/runs`,n)}async createStep(t,e,n,i){return this.http.post(`/projects/${t}/agents/${e}/runs/${n}/steps`,i)}async createSteps(t,e,n,i){return this.http.post(`/projects/${t}/agents/${e}/runs/${n}/steps`,{steps:i})}async updateRun(t,e,n,i){return this.http.patch(`/projects/${t}/agents/${e}/runs/${n}`,i)}async updateStep(t,e,n,i,r){return this.http.patch(`/projects/${t}/agents/${e}/runs/${n}/steps/${i}`,r)}async updateStepConditions(t,e,n,i,r){return this.http.patch(`/projects/${t}/agents/${e}/runs/${n}/steps/${i}`,{conditions:r})}async pauseRun(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/runs/${n}/pause`,{})}async submitStepAction(t,e,n,i,r){return this.http.post(`/projects/${t}/agents/${e}/runs/${n}/steps/${i}/action`,r)}async sendEmail(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/send-email`,n)}async completeExecution(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/executions/complete`,n)}async getSharePointToken(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/sharepoint-token`,n)}async getArtifactUploadUrl(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/upload-artifact/get-url`,n)}};var Me=class{constructor(t){this.http=t}http;async ask(t,e){return this.http.post(`/projects/${t}/vision/ask`,e,12e4)}};var Ue=class{constructor(t){this.http=t}http;async submit(t,e,n){return this.http.post(`/document/${t}/process-file/${e}/submit-validation`,n)}async listScripts(t){return(await this.http.get(`/extraction-schema/${t}/validation-scripts`)).scripts}async getScript(t,e,n){return(await this.http.get(`/extraction-schema/${t}/validation-scripts/${encodeURIComponent(e)}`,n?.includeSource?{includeSource:"true"}:void 0)).script}async pushScript(t,e){return this.http.post(`/extraction-schema/${t}/validation-scripts`,e)}async updateScript(t,e,n){return(await this.http.patch(`/extraction-schema/${t}/validation-scripts/${encodeURIComponent(e)}`,n)).script}async deleteScript(t,e){return this.http.del(`/extraction-schema/${t}/validation-scripts/${encodeURIComponent(e)}`)}};var We=class{constructor(t){this.http=t}http;async list(t,e){let n={};return e?.entityType&&(n.entityType=e.entityType),this.http.get(`/projects/${t}/labels`,n)}async addRemove(t,e,n,i,r){return this.http.post(`/projects/${t}/labels`,{entityType:e,entityId:n,add:i,remove:r})}async search(t,e){let n={};return e?.entityType&&(n.entityType=e.entityType),e?.labels&&(n.labels=e.labels),e?.key&&(n.key=e.key),this.http.get(`/projects/${t}/labels/search`,n)}};var ee=["DOCUMENT_EXTRACTED","DOCUMENT_REVIEWED","DOCUMENT_EXTRACTION_FAILED","DOCUMENT_VALIDATED","DOCUMENT_VALIDATION_STARTED","DOCUMENT_VALIDATION_FAILED","DOCUMENT_CLASSIFIED","DOCUMENT_CLASSIFICATION_FAILED","DOCUMENT_SPLIT","DOCUMENT_SPLIT_FAILED","AGENT_RUN_STARTED","AGENT_RUN_COMPLETED","AGENT_RUN_FAILED","AGENT_RUN_WAITING_HUMAN"],zn=["success","failed","dead_lettered","retrying","pending"],Xn=["24h","7d","30d"],Qn=["hour","day"];var Ve=class{constructor(t){this.http=t}http;basePath(t){return`/projects/${t}/webhooks`}async list(t){return this.http.get(this.basePath(t))}async get(t,e){return this.http.get(`${this.basePath(t)}/${e}`)}async create(t,e){return this.http.post(this.basePath(t),e,void 0,{retry:!1})}async update(t,e,n){return this.http.patch(`${this.basePath(t)}/${e}`,n,{retry:!1})}async delete(t,e){await this.http.del(`${this.basePath(t)}/${e}`)}async pause(t,e){return this.http.post(`${this.basePath(t)}/${e}/pause`)}async resume(t,e){return this.http.post(`${this.basePath(t)}/${e}/resume`)}async verify(t,e){return this.http.post(`${this.basePath(t)}/${e}/verify`,void 0,void 0,{retry:!1})}async rotateSecret(t,e){return this.http.post(`${this.basePath(t)}/${e}/rotate-secret`,void 0,void 0,{retry:!1})}async deliveries(t,e,n){let i={};return n?.status&&(i.status=n.status),n?.eventType&&(i.eventType=n.eventType),n?.deploymentId&&(i.deploymentId=n.deploymentId),n?.agentId&&(i.agentId=n.agentId),n?.classifierId&&(i.classifierId=n.classifierId),n?.splitterId&&(i.splitterId=n.splitterId),n?.limit!==void 0&&(i.limit=String(n.limit)),n?.offset!==void 0&&(i.offset=String(n.offset)),this.http.get(`${this.basePath(t)}/${e}/deliveries`,i)}async metrics(t,e,n){let i={};return n?.window&&(i.window=n.window),n?.bucket&&(i.bucket=n.bucket),this.http.get(`${this.basePath(t)}/${e}/metrics`,i)}async retry(t,e,n){return this.http.post(`${this.basePath(t)}/${e}/retry`,{eventIds:n})}};var Je=I(require("fs")),Nt=I(require("path"));var js=I(require("fs")),Ls=I(require("crypto"));async function Ms(s){return new Promise((t,e)=>{let n=Ls.createHash("sha256"),i=js.createReadStream(s);i.on("data",r=>n.update(r)),i.on("end",()=>t(n.digest("hex"))),i.on("error",e)})}var pu={".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".tiff":"image/tiff",".tif":"image/tiff",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".xls":"application/vnd.ms-excel",".csv":"text/csv",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".doc":"application/msword"};function mu(s){let t=Nt.extname(s).toLowerCase();return pu[t]||"application/octet-stream"}async function He(s,t,e,n,i){let r=Nt.resolve(n),o=Nt.basename(r);if(!Je.existsSync(r))throw new gt(`File not found: ${r}`);if(!Je.statSync(r).isFile())throw new gt(`Not a file: ${r}`);let u=await Ms(r),l=await t.getUploadUrl(e,o,u);if(l.isDuplicate)return{fileId:l.fileId,filename:l.fileName??o,isDuplicate:!0,bytesUploaded:0};let c=mu(r),d=await s.putFile(l.url,r,c,i);return{fileId:l.fileId,filename:l.fileName??o,isDuplicate:!1,bytesUploaded:d}}var jt=I(require("fs")),Lt=I(require("path"));var Ws=I(require("path"));var Us=250,Du=5,Zn=class{constructor(t){this.max=t}max;queue=[];current=0;async acquire(){if(this.current<this.max){this.current++;return}return new Promise(t=>{this.queue.push(t)})}release(){this.current--;let t=this.queue.shift();t&&(this.current++,t())}};async function Vs(s,t,e,n,i){let r=Math.min(i?.concurrency??Du,10),o=new Zn(r),a=n.map(m=>({path:m,filename:Ws.basename(m),status:"pending"})),u=a.map(async(m,h)=>{await o.acquire();try{m.status="uploading",i?.onFileStatus?.(m);let F=await He(s,t,e,m.path);m.fileId=F.fileId,m.status="uploaded",i?.onFileStatus?.(m)}catch(F){m.status="failed",m.error=F instanceof Error?F.message:String(F),i?.onFileStatus?.(m)}finally{o.release()}});if(await Promise.all(u),i?.process){let h=a.filter(F=>F.status==="uploaded"&&F.fileId).map(F=>F.fileId);for(let F=0;F<h.length;F+=Us){let A=h.slice(F,F+Us);try{let k=await t.processFilesAsync(e,A,i.processOptions);for(let[b,C]of Object.entries(k.results)){let x=a.find(V=>V.fileId===b);x&&(C.status==="queued"?(x.status="queued",x.jobId=C.jobId):(x.status="failed",x.error=C.error),i?.onFileStatus?.(x))}}catch(k){for(let b of A){let C=a.find(x=>x.fileId===b);C&&(C.status="failed",C.error=k instanceof Error?k.message:String(k),i?.onFileStatus?.(C))}}}}let l=a.filter(m=>m.status==="uploaded"||m.status==="queued").length,c=a.filter(m=>m.status==="queued").length,d=a.filter(m=>m.status==="failed").length;return{total:n.length,uploaded:l,queued:c,failed:d,files:a}}var fu=new Set([".pdf",".png",".jpg",".jpeg",".tiff",".tif",".xlsx",".xls",".csv",".docx",".doc"]);function Js(s,t){let e=[],n=jt.readdirSync(s,{withFileTypes:!0});for(let i of n){let r=Lt.join(s,i.name);if(!i.name.startsWith(".")){if(i.isDirectory())e.push(...Js(r,t));else if(i.isFile()){let o=Lt.extname(i.name).toLowerCase();if(!fu.has(o)||t&&!gu(i.name,t))continue;e.push(r)}}}return e.sort()}function gu(s,t){let e=t.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${e}$`,"i").test(s)}async function Hs(s,t,e,n,i){let r=Lt.resolve(n);if(!jt.existsSync(r))throw new Error(`Directory not found: ${r}`);if(!jt.statSync(r).isDirectory())throw new Error(`Not a directory: ${r}`);let a=Js(r,i?.globPattern);return a.length===0?{total:0,uploaded:0,queued:0,failed:0,files:[]}:Vs(s,t,e,a,{concurrency:i?.concurrency,process:i?.process,processOptions:i?.processOptions,onFileStatus:i?.onFileStatus})}var hu=1e3,Fu=1e4,Cu=1.5,yu=3e5,Eu=["COMPLETED","FAILED","STALLED"],Q=class{constructor(t){this.queue=t}queue;async*poll(t,e){let n=e?.intervalMs??hu,i=e?.maxIntervalMs??Fu,r=e?.backoffMultiplier??Cu,o=e?.timeoutMs??yu,a=n,u=Date.now(),l;for(;;){if(Date.now()-u>o)throw new Pt(`Polling timed out after ${Math.round(o/1e3)}s for job ${t}`);let c=await this.queue.getStatus(t);if(c.status!==l&&(l=c.status,e?.onStatus?.(c),yield c),Eu.includes(c.status))return;await new Promise(d=>setTimeout(d,a)),a=Math.min(a*r,i)}}async waitForCompletion(t,e){let n;for await(let i of this.poll(t,e))n=i;if(!n)throw new Error(`No status received for job ${t}`);return n}};var g=class{http;documents;projects;deployments;tables;columns;extractions;queue;classify;split;schema;buckets;agents;vision;validations;labels;webhooks;constructor(t){this.http=new _e({apiUrl:t.apiUrl,token:t.token}),this.documents=new ve(this.http),this.projects=new Se(this.http),this.deployments=new xe(this.http),this.tables=new Te(this.http),this.columns=new Re(this.http),this.extractions=new ke(this.http),this.queue=new Be(this.http),this.classify=new $e(this.http),this.split=new Pe(this.http),this.schema=new Ne(this.http),this.buckets=new je(this.http),this.agents=new Le(this.http),this.vision=new Me(this.http),this.validations=new Ue(this.http),this.labels=new We(this.http),this.webhooks=new Ve(this.http)}async uploadFile(t,e,n){return He(this.http,this.documents,t,e,n)}async uploadFolder(t,e,n){return Hs(this.http,this.documents,t,e,n)}async processAndWait(t,e,n){let i=await this.documents.processAsync(t,e,n?.processOptions),r=new Q(this.queue),o;for await(let a of r.poll(i.jobId,n?.pollOptions))o=a;if(!o||o.status==="FAILED")throw new Error(`Extraction failed for file ${e}${o?`: ${o.status}`:""}`);return this.documents.getFileData(e,t)}async*downloadAll(t,e){yield*this.extractions.getAllRows(t,e)}};function v(s,t){if(p()){D(s);return}if(s.length===0){console.log("\x1B[2mNo results.\x1B[0m");return}let e=t||Object.keys(s[0]),n={};for(let r of e)n[r]=r.length;for(let r of s)for(let o of e){let a=String(r[o]??"");n[o]=Math.max(n[o],Math.min(a.length,60))}let i=e.map(r=>`\x1B[1m${r.padEnd(n[r])}\x1B[0m`).join(" ");console.log(i),console.log(e.map(r=>"\u2500".repeat(n[r])).join(" "));for(let r of s){let o=e.map(a=>{let u=String(r[a]??"");return u.length>60?u.slice(0,57)+"...":u.padEnd(n[a])}).join(" ");console.log(o)}}function w(s){if(p()){D(s);return}let t=Math.max(...Object.keys(s).map(e=>e.length));for(let[e,n]of Object.entries(s)){let i=`\x1B[1m${e.padEnd(t)}\x1B[0m`,r=typeof n=="object"&&n!==null?JSON.stringify(n):String(n??"");console.log(`${i} ${r}`)}}var Ks=require("child_process"),Ys=require("crypto"),zs=require("http"),qs=9768,Gs=9780,bu=12e4;function wu(){return(0,Ys.randomBytes)(32).toString("hex")}function Iu(s){let t=process.platform,e=t==="darwin"?`open "${s}"`:t==="win32"?`start "" "${s}"`:`xdg-open "${s}"`;try{return(0,Ks.exec)(e),!0}catch{return!1}}function Au(){return`<!DOCTYPE html>
28
+ `),this.dy++}write(t,e=!1){this.linewrap===!0&&e===!1?this.stream.write(t.substr(0,this.getWidth())):this.stream.write(t)}lineWrapping(t){this.stream.isTTY&&(this.linewrap=t,t?this.stream.write("\x1B[?7h"):this.stream.write("\x1B[?7l"))}isTTY(){return this.stream.isTTY===!0}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}};io.exports=ki});var ro=P((yD,so)=>{"use strict";so.exports=({onlyFirst:s=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,s?void 0:"g")}});var ao=P((ED,oo)=>{"use strict";var Pl=ro();oo.exports=s=>typeof s=="string"?s.replace(Pl(),""):s});var lo=P((bD,$i)=>{"use strict";var uo=s=>Number.isNaN(s)?!1:s>=4352&&(s<=4447||s===9001||s===9002||11904<=s&&s<=12871&&s!==12351||12880<=s&&s<=19903||19968<=s&&s<=42182||43360<=s&&s<=43388||44032<=s&&s<=55203||63744<=s&&s<=64255||65040<=s&&s<=65049||65072<=s&&s<=65131||65281<=s&&s<=65376||65504<=s&&s<=65510||110592<=s&&s<=110593||127488<=s&&s<=127569||131072<=s&&s<=262141);$i.exports=uo;$i.exports.default=uo});var po=P((wD,co)=>{"use strict";co.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var Do=P((ID,Pi)=>{"use strict";var Nl=ao(),jl=lo(),Ll=po(),mo=s=>{if(typeof s!="string"||s.length===0||(s=Nl(s),s.length===0))return 0;s=s.replace(Ll()," ");let t=0;for(let e=0;e<s.length;e++){let n=s.codePointAt(e);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&e++,t+=jl(n)?2:1)}return t};Pi.exports=mo;Pi.exports.default=mo});var Ni=P((AD,fo)=>{"use strict";fo.exports=function(t,e,n){if(e.autopadding!==!0)return t;function i(r,o){return(e.autopaddingChar+r).slice(-o)}return n==="percentage"?i(t,3):t}});var ji=P((_D,go)=>{"use strict";go.exports=function(t,e){let n=Math.round(t*e.barsize),i=e.barsize-n;return e.barCompleteString.substr(0,n)+e.barGlue+e.barIncompleteString.substr(0,i)}});var Li=P((vD,ho)=>{"use strict";ho.exports=function(t,e,n){function i(o){return n?n*Math.round(o/n):o}function r(o){return(e.autopaddingChar+o).slice(-2)}return t>3600?r(Math.floor(t/3600))+"h"+r(i(t%3600/60))+"m":t>60?r(Math.floor(t/60))+"m"+r(i(t%60))+"s":t>10?r(i(t))+"s":r(t)+"s"}});var Mi=P((SD,Fo)=>{"use strict";var Ml=Do(),Ul=Ni(),Wl=ji(),Vl=Li();Fo.exports=function(t,e,n){let i=t.format,r=t.formatTime||Vl,o=t.formatValue||Ul,a=t.formatBar||Wl,u=Math.floor(e.progress*100)+"",l=e.stopTime||Date.now(),c=Math.round((l-e.startTime)/1e3),d=Object.assign({},n,{bar:a(e.progress,t),percentage:o(u,t,"percentage"),total:o(e.total,t,"total"),value:o(e.value,t,"value"),eta:o(e.eta,t,"eta"),eta_formatted:r(e.eta,t,5),duration:o(c,t,"duration"),duration_formatted:r(c,t,1)});i=i.replace(/\{(\w+)\}/g,function(F,A){return typeof d[A]<"u"?d[A]:F});let m=Math.max(0,e.maxWidth-Ml(i)-2),h=Math.floor(m/2);switch(t.align){case"right":i=m>0?" ".repeat(m)+i:i;break;case"center":i=h>0?" ".repeat(h)+i:i;break;default:break}return i}});var un=P((xD,Co)=>{"use strict";function j(s,t){return typeof s>"u"||s===null?t:s}Co.exports={parse:function(t,e){let n={},i=Object.assign({},e,t);return n.throttleTime=1e3/j(i.fps,10),n.stream=j(i.stream,process.stderr),n.terminal=j(i.terminal,null),n.clearOnComplete=j(i.clearOnComplete,!1),n.stopOnComplete=j(i.stopOnComplete,!1),n.barsize=j(i.barsize,40),n.align=j(i.align,"left"),n.hideCursor=j(i.hideCursor,!1),n.linewrap=j(i.linewrap,!1),n.barGlue=j(i.barGlue,""),n.barCompleteChar=j(i.barCompleteChar,"="),n.barIncompleteChar=j(i.barIncompleteChar,"-"),n.format=j(i.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),n.formatTime=j(i.formatTime,null),n.formatValue=j(i.formatValue,null),n.formatBar=j(i.formatBar,null),n.etaBufferLength=j(i.etaBuffer,10),n.etaAsynchronousUpdate=j(i.etaAsynchronousUpdate,!1),n.progressCalculationRelative=j(i.progressCalculationRelative,!1),n.synchronousUpdate=j(i.synchronousUpdate,!0),n.noTTYOutput=j(i.noTTYOutput,!1),n.notTTYSchedule=j(i.notTTYSchedule,2e3),n.emptyOnZero=j(i.emptyOnZero,!1),n.forceRedraw=j(i.forceRedraw,!1),n.autopadding=j(i.autopadding,!1),n.gracefulExit=j(i.gracefulExit,!1),n},assignDerivedOptions:function(t){return t.barCompleteString=t.barCompleteChar.repeat(t.barsize+1),t.barIncompleteString=t.barIncompleteChar.repeat(t.barsize+1),t.autopaddingChar=t.autopadding?j(t.autopaddingChar," "):"",t}}});var Ui=P((RD,Eo)=>{"use strict";var yo=no(),Jl=Bi(),Hl=Mi(),ql=un(),Gl=require("events");Eo.exports=class extends Gl{constructor(t){super(),this.options=ql.assignDerivedOptions(t),this.terminal=this.options.terminal?this.options.terminal:new Jl(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new yo(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format=="function"?this.options.format:Hl}render(t=!1){let e={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};this.options.etaAsynchronousUpdate&&this.updateETA();let n=this.formatter(this.options,e,this.payload);(t||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=n)&&(this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(n),this.terminal.clearRight(),this.lastDrawnString=n,this.lastRedraw=Date.now(),this.emit("redraw-post"))}start(t,e,n){this.value=e||0,this.total=typeof t<"u"&&t>=0?t:100,this.startValue=e||0,this.payload=n||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new yo(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",t,e)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(t,e={}){typeof t=="number"&&(this.value=t,this.eta.update(Date.now(),t,this.total));let n=(typeof t=="object"?t:e)||{};this.emit("update",this.total,this.value);for(let i in n)this.payload[i]=n[i];this.value>=this.getTotal()&&this.options.stopOnComplete&&this.stop()}getProgress(){let t=this.value/this.total;return this.options.progressCalculationRelative&&(t=(this.value-this.startValue)/(this.total-this.startValue)),isNaN(t)&&(t=this.options&&this.options.emptyOnZero?0:1),t=Math.min(Math.max(t,0),1),t}increment(t=1,e={}){typeof t=="object"?this.update(this.value+1,t):this.update(this.value+t,e)}getTotal(){return this.total}setTotal(t){typeof t<"u"&&t>=0&&(this.total=t)}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}});var wo=P((kD,bo)=>{"use strict";var Kl=Ui(),Yl=un();bo.exports=class extends Kl{constructor(t,e){super(Yl.parse(t,e)),this.timer=null,this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.options.synchronousUpdate=!1),this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){this.timer&&(clearTimeout(this.timer),this.timer=null),super.render(),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&this.terminal.newline(),this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(t,e){this.timer&&(super.update(t,e),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2<Date.now()&&this.render())}start(t,e,n){this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.terminal.cursorSave(),this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),super.start(t,e,n),this.render())}stop(){this.timer&&(this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.render(),super.stop(),clearTimeout(this.timer),this.timer=null,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRestore(),this.options.clearOnComplete?(this.terminal.cursorTo(0,null),this.terminal.clearLine()):this.terminal.newline())}}});var Ao=P(($D,Io)=>{"use strict";var zl=Bi(),Xl=Ui(),Ql=un(),Zl=require("events");Io.exports=class extends Zl{constructor(t,e){super(),this.bars=[],this.options=Ql.parse(t,e),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new zl(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(t,e,n,i={}){let r=new Xl(Object.assign({},this.options,{terminal:this.terminal},i));return this.bars.push(r),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1||(this.sigintCallback===null&&this.options.gracefulExit&&(this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback)),this.isActive||(this.options.hideCursor===!0&&this.terminal.cursor(!1),this.options.linewrap===!1&&this.terminal.lineWrapping(!1),this.timer=setTimeout(this.update.bind(this),this.schedulingRate)),this.isActive=!0,r.start(t,e,n),this.emit("start")),r}remove(t){let e=this.bars.indexOf(t);return e<0?!1:(this.bars.splice(e,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),!0)}update(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0)for(this.terminal.clearLine();this.loggingBuffer.length>0;)this.terminal.write(this.loggingBuffer.shift(),!0);for(let t=0;t<this.bars.length;t++)t>0&&this.terminal.newline(),this.bars[t].render();this.emit("redraw-post"),this.options.noTTYOutput&&this.terminal.isTTY()===!1&&(this.terminal.newline(),this.terminal.newline()),this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find(t=>t.isActive)&&this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback&&(process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null),this.isActive=!1,this.options.hideCursor===!0&&this.terminal.cursor(!0),this.options.linewrap===!1&&this.terminal.lineWrapping(!0),this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let t=0;t<this.bars.length;t++)t>0&&this.terminal.newline(),this.bars[t].render(),this.bars[t].stop();this.terminal.newline()}this.emit("stop")}log(t){this.loggingBuffer.push(t)}}});var vo=P((PD,_o)=>{"use strict";_o.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var xo=P((ND,So)=>{"use strict";So.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var Ro=P((jD,To)=>{"use strict";To.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u2588",barIncompleteChar:"\u2591"}});var ko=P((LD,Oo)=>{"use strict";Oo.exports={format:" {bar}\u25A0 {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"\u25A0",barIncompleteChar:" "}});var $o=P((MD,Bo)=>{"use strict";var tc=vo(),ec=xo(),nc=Ro(),ic=ko();Bo.exports={legacy:tc,shades_classic:ec,shades_grey:nc,rect:ic}});var jo=P((UD,No)=>{"use strict";var Po=wo(),sc=Ao(),rc=$o(),oc=Mi(),ac=Ni(),uc=ji(),lc=Li();No.exports={Bar:Po,SingleBar:Po,MultiBar:sc,Presets:rc,Format:{Formatter:oc,BarFormat:uc,ValueFormat:ac,TimeFormat:lc}}});var Es=I(ys(),1),{program:Uc,createCommand:Wc,createArgument:Vc,createOption:Jc,CommanderError:Hc,InvalidArgumentError:nt,InvalidOptionArgumentError:qc,Command:bs,Argument:Gc,Option:Kc,Help:Yc}=Es.default;var Et=!1,ws=!1;function Is(s){Et=s}function p(){return Et}function As(s){ws=s}function D(s){console.log(JSON.stringify(s,null,2))}function _(s){Et?console.error(JSON.stringify({error:s})):(console.error(`Error: ${s.message}`),s.details&&ws&&console.error(JSON.stringify(s.details,null,2)))}function ou(s){return s instanceof Error&&"code"in s&&"exitCode"in s&&typeof s.code=="string"&&typeof s.exitCode=="number"}function _s(s){ou(s)&&(_({code:s.code,message:s.message,details:s.details}),process.exit(s.exitCode)),_({code:"UNKNOWN_ERROR",message:s instanceof Error?s.message:"Unknown error"}),process.exit(1)}function E(s){Et||console.log(`\x1B[32m${s}\x1B[0m`)}function B(s){Et||console.log(`\x1B[36m${s}\x1B[0m`)}function Y(s){Et||console.log(`\x1B[33m${s}\x1B[0m`)}function Qt(s){Et||console.log(`\x1B[2m${s}\x1B[0m`)}var ti=I(require("readline"));var q=I(require("fs")),Bt=I(require("path")),vs=I(require("os")),Ae=require("child_process"),Wn=Bt.join(vs.homedir(),".limai"),Zt=Bt.join(Wn,"config.json"),au=".limai.token",kt;function uu(s){if(!q.existsSync(s))return{};let t={};for(let e of q.readFileSync(s,"utf-8").split(/\r?\n/)){let n=e.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)\s*$/);n&&(t[n[1]]=n[2].replace(/^(["'])(.*)\1$/,"$2"))}return t}function Ss(){if(kt!==void 0)return kt;try{let s=(0,Ae.execSync)("git rev-parse --show-toplevel",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(!q.existsSync(Bt.join(s,"packages","cli")))return kt=null,null;let t=(0,Ae.execSync)("git rev-parse --git-common-dir",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim(),e="";if(t!==".git"){let i=(0,Ae.execSync)("git rev-parse --abbrev-ref HEAD",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(i){let r=i.replace(/[/\\]/g,"-").replace(/[^a-zA-Z0-9._-]/g,"").replace(/^-+|-+$/g,"");r&&(e=`${r}.`)}}let n=uu(Bt.join(s,"tables",".env.local"));return kt={root:s,apiUrl:n.NEXT_PUBLIC_BASE_URL??`https://${e}tables.localhost`,sseUrl:n.NEXT_PUBLIC_SSE_URL??`https://${e}ws.localhost`},kt}catch{return kt=null,null}}function lu(){let s=Ss();if(!s)return;let t=Bt.join(s.root,au);if(q.existsSync(t))return q.readFileSync(t,"utf-8").trim()}function $t(){let s=process.env.LIMAI_API_TOKEN,t=process.env.LIMAI_API_URL,e=process.env.LIMAI_SSE_URL,n={};if(q.existsSync(Zt))try{let u=q.readFileSync(Zt,"utf-8"),l=JSON.parse(u);l&&typeof l=="object"&&!Array.isArray(l)&&(n=l)}catch{n={}}let i=Ss(),r=s||lu()||n.token,o=t||n.apiUrl||i?.apiUrl||process.env.LIMAI_BUILD_URL||void 0,a=e||n.sseUrl||i?.sseUrl||void 0;return!r||!o?null:{token:r,apiUrl:o,sseUrl:a,defaultProjectId:n.defaultProjectId,defaultDeploymentId:n.defaultDeploymentId}}function bt(s){let t={};if(q.existsSync(Zt))try{let n=q.readFileSync(Zt,"utf-8");t=JSON.parse(n)}catch{t={}}let e={...t,...s};q.existsSync(Wn)||q.mkdirSync(Wn,{recursive:!0,mode:448}),q.writeFileSync(Zt,JSON.stringify(e,null,2),{mode:384})}function f(){let s=$t();return s||(console.error("Not authenticated. Run `npm run cli:setup` or set LIMAI_API_TOKEN environment variable."),process.exit(1)),s}function xs(){return!!process.env.LIMAI_EXECUTION_ID}var ks=require("fs"),Bs=require("fs/promises"),$s=require("stream");var R=class extends Error{code;statusCode;exitCode;details;constructor(t,e){super(t),this.name="LimaiError",this.code=e.code,this.statusCode=e.statusCode,this.exitCode=e.exitCode??1,this.details=e.details}},Vn=class extends R{constructor(t,e){super(t,{code:"AUTH_ERROR",statusCode:401,exitCode:2,details:e}),this.name="AuthError"}},Jn=class extends R{constructor(t,e){super(t,{code:"FORBIDDEN",statusCode:403,exitCode:2,details:e}),this.name="ForbiddenError"}},Hn=class extends R{constructor(t,e){super(t,{code:"NOT_FOUND",statusCode:404,exitCode:3,details:e}),this.name="NotFoundError"}},W=class extends R{constructor(t,e){super(t,{code:"VALIDATION_ERROR",statusCode:400,exitCode:4,details:e}),this.name="ValidationError"}},qn=class extends R{constructor(t,e){super(t,{code:"CONFLICT",statusCode:409,exitCode:4,details:e}),this.name="ConflictError"}},Gn=class extends R{retryAfterMs;constructor(t,e){super(t,{code:"RATE_LIMITED",statusCode:429,exitCode:5}),this.name="RateLimitError",this.retryAfterMs=e}},Kn=class extends R{constructor(t,e=500,n){super(t,{code:"SERVER_ERROR",statusCode:e,exitCode:6,details:n}),this.name="ServerError"}},Pt=class extends R{constructor(t){super(t,{code:"TIMEOUT",exitCode:7}),this.name="TimeoutError"}},gt=class extends R{constructor(t,e){super(t,{code:"UPLOAD_ERROR",exitCode:8,details:e}),this.name="UploadError"}};function Ts(s,t,e){switch(s){case 400:return new W(t,e);case 401:return new Vn(t,e);case 403:return new Jn(t,e);case 404:return new Hn(t,e);case 409:return new qn(t,e);case 429:return new Gn(t);default:return s>=500?new Kn(t,s,e):new R(t,{code:"HTTP_ERROR",statusCode:s,details:e})}}var cu=3e4,Yn=3,Rs=1e3,Os=2;function du(){return process.env.LIMAI_DEBUG==="1"}function te(...s){du()&&console.error("[limai:http]",...s)}var _e=class{baseUrl;token;constructor(t){this.baseUrl=t.apiUrl.replace(/\/$/,""),this.token=t.token}buildUrl(t,e){let n=new URL(`/api/v1${t}`,this.baseUrl);if(e)for(let[i,r]of Object.entries(e))r!=null&&n.searchParams.set(i,r);return n.toString()}authHeaders(){let t={Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},e=process.env.VERCEL_BYPASS;return e&&(t["x-vercel-protection-bypass"]=e),t}async parseErrorBody(t){try{let e=await t.json();return{message:typeof e.error=="string"?e.error:typeof e.message=="string"?e.message:`HTTP ${t.status}`,details:e.details}}catch{return{message:await t.text().catch(()=>"")||`HTTP ${t.status}`}}}shouldRetry(t){return t===429||t>=500}getRetryDelay(t,e){let n=t.headers.get("Retry-After");if(n){let i=parseInt(n,10);if(!isNaN(i))return i*1e3}return Rs*Math.pow(Os,e)}async request(t,e,n={}){let i=this.buildUrl(e,n.params),r=n.timeoutMs??cu;for(let o=0;o<=Yn;o++){let a=new AbortController,u=setTimeout(()=>a.abort(),r);n.signal&&n.signal.addEventListener("abort",()=>a.abort());try{te(`${t} ${i}${o>0?` (retry ${o})`:""}`);let l=await fetch(i,{method:t,headers:this.authHeaders(),body:n.body?JSON.stringify(n.body):void 0,signal:a.signal});if(clearTimeout(u),l.ok){let m=await l.text();return m?JSON.parse(m):{}}if(n.retry!==!1&&this.shouldRetry(l.status)&&o<Yn){let m=this.getRetryDelay(l,o);te(`Retrying in ${m}ms (status ${l.status})`),await new Promise(h=>setTimeout(h,m));continue}let{message:c,details:d}=await this.parseErrorBody(l);throw Ts(l.status,c,d)}catch(l){if(clearTimeout(u),l instanceof R)throw l;if(l instanceof DOMException&&l.name==="AbortError"){if(n.retry!==!1&&o<Yn){let c=Rs*Math.pow(Os,o);te(`Timeout, retrying in ${c}ms`),await new Promise(d=>setTimeout(d,c));continue}throw new Pt(`Request timed out after ${r}ms: ${t} ${e}`)}throw new R(l instanceof Error?l.message:"Unknown network error",{code:"NETWORK_ERROR",exitCode:1})}}throw new R("Max retries exceeded",{code:"MAX_RETRIES",exitCode:1})}async get(t,e,n){return this.request("GET",t,{params:e,timeoutMs:n})}async post(t,e,n,i){return this.request("POST",t,{body:e,timeoutMs:n,retry:i?.retry})}async patch(t,e,n){return this.request("PATCH",t,{body:e,retry:n?.retry})}async del(t,e){return this.request("DELETE",t,{body:e})}async putRaw(t,e,n,i){let r=e instanceof Blob?e.size:e.length;te(`PUT ${t} (${r} bytes)`);let o=await fetch(t,{method:"PUT",headers:{"Content-Type":n},body:e});if(i&&i(r,r),!o.ok)throw new gt(`Upload failed: HTTP ${o.status}`)}async putFile(t,e,n,i){let r=(await(0,Bs.stat)(e)).size;te(`PUT ${t} (${r} bytes, streamed from ${e})`);let o=(0,ks.createReadStream)(e),a=o;if(i){let l=0,c=new $s.Transform({transform(d,m,h){l+=d.byteLength,i(l,r),h(null,d)}});a=o.pipe(c)}let u=await fetch(t,{method:"PUT",headers:{"Content-Type":n,"Content-Length":String(r)},body:a,duplex:"half"});if(i&&i(r,r),!u.ok)throw new gt(`Upload failed: HTTP ${u.status}`);return r}};var ve=class{constructor(t){this.http=t}http;async getUploadUrl(t,e,n){let i={filename:e,contentHash:n};return this.http.get(`/document/${t}/get-url`,i)}async processSync(t,e,n){return this.http.post(`/document/${t}/process-file/${e}`,n,18e4)}async processAsync(t,e,n){return this.http.post(`/document/${t}/process-file-async/${e}`,n)}async processFilesAsync(t,e,n){return this.http.post(`/document/${t}/process-files-async`,{fileIds:e,...n})}async getFileData(t,e,n){let i={fileId:t,extractionSchemaId:e,include:n?.length?n.join(","):void 0};return this.http.get("/document/get-file-data",i)}async getFilesData(t,e){return this.http.post("/document/get-files-data",{fileIds:t,...e?.length?{include:e}:{}})}async getDocumentData(t,e,n){let i={include:n?.length?n.join(","):void 0};return this.http.get(`/deployments/${t}/documents/${e}/data`,i)}async getDocumentsData(t,e,n){return this.http.post(`/deployments/${t}/documents/data`,{fileIds:e,...n?.length?{include:n}:{}})}async submitCorrections(t,e,n){return this.http.post(`/document/${t}/process-file/${e}/submit-corrections`,n)}};var Se=class{constructor(t){this.http=t}http;async list(){let t=await this.http.get("/projects");return Array.isArray(t)?t:t.data}async create(t){return this.http.post("/projects",t)}async delete(t){return this.http.del(`/projects/${t}`)}async getSharedColumnIds(t){return this.http.get(`/projects/${t}/shared-column-ids`)}async listDeployments(t){return this.http.get(`/projects/${t}/deployments`)}async listBenchmarks(t){return this.http.get(`/projects/${t}/benchmarks`)}async listNotificationRoutes(t){return this.http.get(`/projects/${t}/notifications`)}async createNotificationRoute(t,e){return this.http.post(`/projects/${t}/notifications`,e)}async updateNotificationRoute(t,e,n){return this.http.patch(`/projects/${t}/notifications/${e}`,n)}async deleteNotificationRoute(t,e){return this.http.del(`/projects/${t}/notifications/${e}`)}async listNotificationIntegrations(t,e){return this.http.get(`/projects/${t}/notifications/integrations`,{provider:e})}async listNotificationSlackChannels(t,e){return this.http.get(`/projects/${t}/notifications/integrations/slack/channels`,{connectionId:e})}async listNotificationTeamsTeams(t,e){return this.http.get(`/projects/${t}/notifications/integrations/teams/teams`,{connectionId:e})}async listNotificationTeamsChannels(t,e,n){return this.http.get(`/projects/${t}/notifications/integrations/teams/channels`,{connectionId:e,teamId:n})}};var xe=class{constructor(t){this.http=t}http;async list(t,e){let n={status:e?.status,type:e?.type},i=await this.http.get(`/projects/${t}/deployments`,n);return Array.isArray(i)?i:i.data}async create(t,e){return this.http.post(`/projects/${t}/deployments`,e)}async getConfig(t){return this.http.get(`/deployments/${t}/configuration`)}async updateConfig(t,e){await this.http.patch(`/deployment/${t}/configuration`,e)}async listDocuments(t,e){let n={limit:e?.limit?.toString(),offset:e?.offset?.toString(),status:e?.status};return this.http.get(`/deployments/${t}/documents`,n)}async getDocument(t,e){return this.http.get(`/deployments/${t}/documents/${e}`)}async deleteDocument(t,e){await this.http.del(`/deployments/${t}/documents/${e}`)}async bulkDelete(t,e){await this.http.del(`/deployments/${t}/documents/bulk-delete`,{fileIds:e})}};var Te=class{constructor(t){this.http=t}http;async get(t){return this.http.get(`/tables/${t}`)}async listColumns(t){let e=await this.http.get(`/tables/${t}/columns`);return Array.isArray(e)?e:e.data}async listRows(t,e){let n={limit:e?.limit?.toString(),offset:e?.offset?.toString(),status:e?.status};return this.http.get(`/tables/${t}/rows`,n)}async createRows(t,e){return this.http.post(`/tables/${t}/rows`,e,6e4)}async deleteRows(t,e){return this.http.del(`/tables/${t}/rows`,e)}async createTable(t,e){return this.http.post(`/deployments/${t}/tables`,e)}async update(t,e){return this.http.patch(`/tables/${t}`,e)}};var Re=class{constructor(t){this.http=t}http;async list(t){let e=await this.http.get(`/tables/${t}/columns`);return Array.isArray(e)?e:e.data}async get(t){return this.http.get(`/columns/${t}`)}async create(t,e){let n=await this.http.post(`/tables/${t}/columns`,e);return n&&typeof n=="object"&&"data"in n?n.data:[n]}async update(t,e){return this.http.patch(`/columns/${t}`,e)}};async function*Ps(s,t={}){let e=Math.min(t.pageSize??100,500),n=0,i=0;for(;;){let r=t.maxItems?Math.min(e,t.maxItems-i):e;if(r<=0)break;let o=await s(r,n),a=o.data;if(a.length===0||(yield a,i+=a.length,n+=a.length,n>=o.pagination.total)||t.maxItems&&i>=t.maxItems)break}}async function*Ns(s,t={}){let e=Math.min(t.pageSize??100,500),n=1,i=0;for(;;){let r=t.maxItems?Math.min(e,t.maxItems-i):e;if(r<=0)break;let o=await s(n,r),a=o.data;if(a.length===0||(yield a,i+=a.length,n++,n>o.pagination.totalPages)||t.maxItems&&i>=t.maxItems)break}}async function Oe(s){let t=[];for await(let e of s)t.push(...e);return t}var ke=class{constructor(t){this.http=t}http;async getRows(t,e){let n={page:e?.page?.toString(),limit:e?.limit?.toString(),order:e?.order,status:e?.status};return this.http.get(`/extractions/${t}`,n)}async*getAllRows(t,e){yield*Ns(async(n,i)=>this.http.get(`/extractions/${t}`,{page:n.toString(),limit:i.toString(),order:e?.order,status:e?.status}),e)}async collectAllRows(t,e){return Oe(this.getAllRows(t,e))}};var Be=class{constructor(t){this.http=t}http;async getStatus(t){return this.http.get(`/queue/${t}/status`)}async cancel(t){await this.http.post("/queue/cancel",{jobId:t})}async updateStatus(t,e){return this.http.patch(`/queue/${t}/status`,e)}};var $e=class{constructor(t){this.http=t}http;async list(t){return this.http.get("/classify",{projectId:t})}async getUploadUrl(t,e){return this.http.get(`/classify/${t}/get-url`,{filename:e})}async classify(t,e){return this.http.post(`/classify/${t}`,{fileId:e})}async classifyAsync(t,e){return this.http.post(`/classify/${t}/async`,{fileId:e})}async getStatus(t,e){return this.http.get(`/classify/${t}`,{classificationId:e})}async createClassifier(t){return this.http.post("/classify",t)}async createRoute(t,e){return this.http.post(`/classify/${t}/routes`,e)}};var Pe=class{constructor(t){this.http=t}http;async list(t){return this.http.get("/split",{projectId:t})}async getUploadUrl(t,e){return this.http.get(`/split/${t}/get-url`,{filename:e})}async split(t,e){return this.http.post(`/split/${t}`,{fileId:e})}async splitAsync(t,e){return this.http.post(`/split/${t}/async`,{fileId:e})}async getStatus(t,e){return this.http.get(`/split/${t}`,{splitId:e})}async listSplits(t){return this.http.get(`/split/${t}/splits`)}async createSplitter(t){return this.http.post("/split",t)}};var Ne=class{constructor(t){this.http=t}http;async get(t){return this.http.get(`/deployments/${t}/configuration`)}async update(t,e){return this.http.patch(`/deployments/${t}/configuration`,e)}async getAllData(t){return this.http.get(`/deployments/${t}/all-data`)}};var je=class{constructor(t){this.http=t}http;async list(t){return this.http.get(`/projects/${t}/buckets`)}async get(t){return this.http.get(`/buckets/${t}`)}async create(t,e,n){return this.http.post(`/projects/${t}/buckets`,{name:e,description:n})}async delete(t){await this.http.del(`/buckets/${t}`)}async getUploadUrl(t,e){return this.http.get(`/buckets/${t}/get-url`,{filename:e})}async confirmUpload(t,e,n){await this.http.patch(`/buckets/${t}/files/${e}/status`,{status:"UPLOADED",...n!==void 0&&{sizeBytes:n}})}async listFiles(t,e){let n={};return e&&e.length>0&&(n.labels=e.join(",")),this.http.get(`/buckets/${t}/files`,n)}async getDownloadUrl(t,e){return this.http.get(`/buckets/${t}/files/${e}/download`)}async updateLabels(t,e,n){return this.http.patch(`/buckets/${t}/files/${e}`,{labels:n})}async deleteFile(t,e){await this.http.del(`/buckets/${t}/files/${e}`)}async sendTo(t,e,n,i){return this.http.post(`/buckets/${t}/files/${e}/send-to`,{targetType:n,targetId:i})}};var Le=class{constructor(t){this.http=t}http;async list(t,e){let n={};return e?.status&&(n.status=e.status),this.http.get(`/projects/${t}/agents`,n)}async get(t,e){return this.http.get(`/projects/${t}/agents/${e}`)}async create(t,e){return this.http.post(`/projects/${t}/agents`,e)}async update(t,e,n){return this.http.patch(`/projects/${t}/agents/${e}`,n)}async delete(t,e){await this.http.del(`/projects/${t}/agents/${e}`)}async getFileUploadUrl(t,e,n){return this.http.get(`/projects/${t}/agents/${e}/files/get-url`,{filename:n})}async deleteFile(t,e,n){await this.http.del(`/projects/${t}/agents/${e}/files/${n}`)}async updateFileMetadata(t,e,n,i){return this.http.patch(`/projects/${t}/agents/${e}/files/${n}`,i)}async getFileDownloadUrl(t,e,n){return this.http.get(`/projects/${t}/agents/${e}/files/${n}/download`)}async listSkills(t,e){return this.http.get(`/projects/${t}/agents/${e}/skills`)}async createSkill(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/skills`,n)}async updateSkill(t,e,n,i){return this.http.patch(`/projects/${t}/agents/${e}/skills/${n}`,i)}async deleteSkill(t,e,n){await this.http.del(`/projects/${t}/agents/${e}/skills/${n}`)}async linkFileToSkill(t,e,n,i){return this.http.post(`/projects/${t}/agents/${e}/skills/${n}/files`,{fileId:i})}async unlinkFileFromSkill(t,e,n,i){await this.http.del(`/projects/${t}/agents/${e}/skills/${n}/files/${i}`)}async listRuns(t,e,n){let i={};return n?.limit&&(i.limit=String(n.limit)),n?.status&&(i.status=n.status),this.http.get(`/projects/${t}/agents/${e}/runs`,i)}async getRun(t,e,n){return this.http.get(`/projects/${t}/agents/${e}/runs/${n}`)}async getRunConversation(t,e,n,i){let r={};return i?.stepId&&(r.stepId=i.stepId),this.http.get(`/projects/${t}/agents/${e}/runs/${n}/conversation`,r)}async getRunInferenceLogs(t,e,n,i){let r={};return i?.limit!==void 0&&(r.limit=String(i.limit)),i?.status&&(r.status=i.status),this.http.get(`/projects/${t}/agents/${e}/runs/${n}/inference-logs`,r)}async createRun(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/runs`,n)}async createStep(t,e,n,i){return this.http.post(`/projects/${t}/agents/${e}/runs/${n}/steps`,i)}async createSteps(t,e,n,i){return this.http.post(`/projects/${t}/agents/${e}/runs/${n}/steps`,{steps:i})}async updateRun(t,e,n,i){return this.http.patch(`/projects/${t}/agents/${e}/runs/${n}`,i)}async updateStep(t,e,n,i,r){return this.http.patch(`/projects/${t}/agents/${e}/runs/${n}/steps/${i}`,r)}async updateStepConditions(t,e,n,i,r){return this.http.patch(`/projects/${t}/agents/${e}/runs/${n}/steps/${i}`,{conditions:r})}async pauseRun(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/runs/${n}/pause`,{})}async submitStepAction(t,e,n,i,r){return this.http.post(`/projects/${t}/agents/${e}/runs/${n}/steps/${i}/action`,r)}async sendEmail(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/send-email`,n)}async completeExecution(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/executions/complete`,n)}async getSharePointToken(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/sharepoint-token`,n)}async getArtifactUploadUrl(t,e,n){return this.http.post(`/projects/${t}/agents/${e}/upload-artifact/get-url`,n)}};var Me=class{constructor(t){this.http=t}http;async ask(t,e){return this.http.post(`/projects/${t}/vision/ask`,e,12e4)}};var Ue=class{constructor(t){this.http=t}http;async submit(t,e,n){return this.http.post(`/document/${t}/process-file/${e}/submit-validation`,n)}async listScripts(t){return(await this.http.get(`/deployments/${t}/validation-scripts`)).scripts}async getScript(t,e,n){return(await this.http.get(`/deployments/${t}/validation-scripts/${encodeURIComponent(e)}`,n?.includeSource?{includeSource:"true"}:void 0)).script}async pushScript(t,e){return this.http.post(`/deployments/${t}/validation-scripts`,e)}async updateScript(t,e,n){return(await this.http.patch(`/deployments/${t}/validation-scripts/${encodeURIComponent(e)}`,n)).script}async deleteScript(t,e){return this.http.del(`/deployments/${t}/validation-scripts/${encodeURIComponent(e)}`)}};var We=class{constructor(t){this.http=t}http;async list(t,e){let n={};return e?.entityType&&(n.entityType=e.entityType),this.http.get(`/projects/${t}/labels`,n)}async addRemove(t,e,n,i,r){return this.http.post(`/projects/${t}/labels`,{entityType:e,entityId:n,add:i,remove:r})}async search(t,e){let n={};return e?.entityType&&(n.entityType=e.entityType),e?.labels&&(n.labels=e.labels),e?.key&&(n.key=e.key),this.http.get(`/projects/${t}/labels/search`,n)}};var ee=["DOCUMENT_EXTRACTED","DOCUMENT_REVIEWED","DOCUMENT_EXTRACTION_FAILED","DOCUMENT_VALIDATED","DOCUMENT_VALIDATION_STARTED","DOCUMENT_VALIDATION_FAILED","DOCUMENT_CLASSIFIED","DOCUMENT_CLASSIFICATION_FAILED","DOCUMENT_SPLIT","DOCUMENT_SPLIT_FAILED","AGENT_RUN_STARTED","AGENT_RUN_COMPLETED","AGENT_RUN_FAILED","AGENT_RUN_WAITING_HUMAN"],zn=["success","failed","dead_lettered","retrying","pending"],Xn=["24h","7d","30d"],Qn=["hour","day"];var Ve=class{constructor(t){this.http=t}http;basePath(t){return`/projects/${t}/webhooks`}async list(t){return this.http.get(this.basePath(t))}async get(t,e){return this.http.get(`${this.basePath(t)}/${e}`)}async create(t,e){return this.http.post(this.basePath(t),e,void 0,{retry:!1})}async update(t,e,n){return this.http.patch(`${this.basePath(t)}/${e}`,n,{retry:!1})}async delete(t,e){await this.http.del(`${this.basePath(t)}/${e}`)}async pause(t,e){return this.http.post(`${this.basePath(t)}/${e}/pause`)}async resume(t,e){return this.http.post(`${this.basePath(t)}/${e}/resume`)}async verify(t,e){return this.http.post(`${this.basePath(t)}/${e}/verify`,void 0,void 0,{retry:!1})}async rotateSecret(t,e){return this.http.post(`${this.basePath(t)}/${e}/rotate-secret`,void 0,void 0,{retry:!1})}async deliveries(t,e,n){let i={};return n?.status&&(i.status=n.status),n?.eventType&&(i.eventType=n.eventType),n?.deploymentId&&(i.deploymentId=n.deploymentId),n?.agentId&&(i.agentId=n.agentId),n?.classifierId&&(i.classifierId=n.classifierId),n?.splitterId&&(i.splitterId=n.splitterId),n?.limit!==void 0&&(i.limit=String(n.limit)),n?.offset!==void 0&&(i.offset=String(n.offset)),this.http.get(`${this.basePath(t)}/${e}/deliveries`,i)}async metrics(t,e,n){let i={};return n?.window&&(i.window=n.window),n?.bucket&&(i.bucket=n.bucket),this.http.get(`${this.basePath(t)}/${e}/metrics`,i)}async retry(t,e,n){return this.http.post(`${this.basePath(t)}/${e}/retry`,{eventIds:n})}};var Je=I(require("fs")),Nt=I(require("path"));var js=I(require("fs")),Ls=I(require("crypto"));async function Ms(s){return new Promise((t,e)=>{let n=Ls.createHash("sha256"),i=js.createReadStream(s);i.on("data",r=>n.update(r)),i.on("end",()=>t(n.digest("hex"))),i.on("error",e)})}var pu={".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".tiff":"image/tiff",".tif":"image/tiff",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".xls":"application/vnd.ms-excel",".csv":"text/csv",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".doc":"application/msword"};function mu(s){let t=Nt.extname(s).toLowerCase();return pu[t]||"application/octet-stream"}async function He(s,t,e,n,i){let r=Nt.resolve(n),o=Nt.basename(r);if(!Je.existsSync(r))throw new gt(`File not found: ${r}`);if(!Je.statSync(r).isFile())throw new gt(`Not a file: ${r}`);let u=await Ms(r),l=await t.getUploadUrl(e,o,u);if(l.isDuplicate)return{fileId:l.fileId,filename:l.fileName??o,isDuplicate:!0,bytesUploaded:0};let c=mu(r),d=await s.putFile(l.url,r,c,i);return{fileId:l.fileId,filename:l.fileName??o,isDuplicate:!1,bytesUploaded:d}}var jt=I(require("fs")),Lt=I(require("path"));var Ws=I(require("path"));var Us=250,Du=5,Zn=class{constructor(t){this.max=t}max;queue=[];current=0;async acquire(){if(this.current<this.max){this.current++;return}return new Promise(t=>{this.queue.push(t)})}release(){this.current--;let t=this.queue.shift();t&&(this.current++,t())}};async function Vs(s,t,e,n,i){let r=Math.min(i?.concurrency??Du,10),o=new Zn(r),a=n.map(m=>({path:m,filename:Ws.basename(m),status:"pending"})),u=a.map(async(m,h)=>{await o.acquire();try{m.status="uploading",i?.onFileStatus?.(m);let F=await He(s,t,e,m.path);m.fileId=F.fileId,m.status="uploaded",i?.onFileStatus?.(m)}catch(F){m.status="failed",m.error=F instanceof Error?F.message:String(F),i?.onFileStatus?.(m)}finally{o.release()}});if(await Promise.all(u),i?.process){let h=a.filter(F=>F.status==="uploaded"&&F.fileId).map(F=>F.fileId);for(let F=0;F<h.length;F+=Us){let A=h.slice(F,F+Us);try{let k=await t.processFilesAsync(e,A,i.processOptions);for(let[b,C]of Object.entries(k.results)){let x=a.find(V=>V.fileId===b);x&&(C.status==="queued"?(x.status="queued",x.jobId=C.jobId):(x.status="failed",x.error=C.error),i?.onFileStatus?.(x))}}catch(k){for(let b of A){let C=a.find(x=>x.fileId===b);C&&(C.status="failed",C.error=k instanceof Error?k.message:String(k),i?.onFileStatus?.(C))}}}}let l=a.filter(m=>m.status==="uploaded"||m.status==="queued").length,c=a.filter(m=>m.status==="queued").length,d=a.filter(m=>m.status==="failed").length;return{total:n.length,uploaded:l,queued:c,failed:d,files:a}}var fu=new Set([".pdf",".png",".jpg",".jpeg",".tiff",".tif",".xlsx",".xls",".csv",".docx",".doc"]);function Js(s,t){let e=[],n=jt.readdirSync(s,{withFileTypes:!0});for(let i of n){let r=Lt.join(s,i.name);if(!i.name.startsWith(".")){if(i.isDirectory())e.push(...Js(r,t));else if(i.isFile()){let o=Lt.extname(i.name).toLowerCase();if(!fu.has(o)||t&&!gu(i.name,t))continue;e.push(r)}}}return e.sort()}function gu(s,t){let e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*").replace(/\\\?/g,".");return new RegExp(`^${e}$`,"i").test(s)}async function Hs(s,t,e,n,i){let r=Lt.resolve(n);if(!jt.existsSync(r))throw new Error(`Directory not found: ${r}`);if(!jt.statSync(r).isDirectory())throw new Error(`Not a directory: ${r}`);let a=Js(r,i?.globPattern);return a.length===0?{total:0,uploaded:0,queued:0,failed:0,files:[]}:Vs(s,t,e,a,{concurrency:i?.concurrency,process:i?.process,processOptions:i?.processOptions,onFileStatus:i?.onFileStatus})}var hu=1e3,Fu=1e4,Cu=1.5,yu=3e5,Eu=["COMPLETED","FAILED","STALLED"],Q=class{constructor(t){this.queue=t}queue;async*poll(t,e){let n=e?.intervalMs??hu,i=e?.maxIntervalMs??Fu,r=e?.backoffMultiplier??Cu,o=e?.timeoutMs??yu,a=n,u=Date.now(),l;for(;;){if(Date.now()-u>o)throw new Pt(`Polling timed out after ${Math.round(o/1e3)}s for job ${t}`);let c=await this.queue.getStatus(t);if(c.status!==l&&(l=c.status,e?.onStatus?.(c),yield c),Eu.includes(c.status))return;await new Promise(d=>setTimeout(d,a)),a=Math.min(a*r,i)}}async waitForCompletion(t,e){let n;for await(let i of this.poll(t,e))n=i;if(!n)throw new Error(`No status received for job ${t}`);return n}};var g=class{http;documents;projects;deployments;tables;columns;extractions;queue;classify;split;schema;buckets;agents;vision;validations;labels;webhooks;constructor(t){this.http=new _e({apiUrl:t.apiUrl,token:t.token}),this.documents=new ve(this.http),this.projects=new Se(this.http),this.deployments=new xe(this.http),this.tables=new Te(this.http),this.columns=new Re(this.http),this.extractions=new ke(this.http),this.queue=new Be(this.http),this.classify=new $e(this.http),this.split=new Pe(this.http),this.schema=new Ne(this.http),this.buckets=new je(this.http),this.agents=new Le(this.http),this.vision=new Me(this.http),this.validations=new Ue(this.http),this.labels=new We(this.http),this.webhooks=new Ve(this.http)}async uploadFile(t,e,n){return He(this.http,this.documents,t,e,n)}async uploadFolder(t,e,n){return Hs(this.http,this.documents,t,e,n)}async processAndWait(t,e,n){let i=await this.documents.processAsync(t,e,n?.processOptions),r=new Q(this.queue),o;for await(let a of r.poll(i.jobId,n?.pollOptions))o=a;if(!o||o.status==="FAILED")throw new Error(`Extraction failed for file ${e}${o?`: ${o.status}`:""}`);return this.documents.getFileData(e,t)}async*downloadAll(t,e){yield*this.extractions.getAllRows(t,e)}};function v(s,t){if(p()){D(s);return}if(s.length===0){console.log("\x1B[2mNo results.\x1B[0m");return}let e=t||Object.keys(s[0]),n={};for(let r of e)n[r]=r.length;for(let r of s)for(let o of e){let a=String(r[o]??"");n[o]=Math.max(n[o],Math.min(a.length,60))}let i=e.map(r=>`\x1B[1m${r.padEnd(n[r])}\x1B[0m`).join(" ");console.log(i),console.log(e.map(r=>"\u2500".repeat(n[r])).join(" "));for(let r of s){let o=e.map(a=>{let u=String(r[a]??"");return u.length>60?u.slice(0,57)+"...":u.padEnd(n[a])}).join(" ");console.log(o)}}function w(s){if(p()){D(s);return}let t=Math.max(...Object.keys(s).map(e=>e.length));for(let[e,n]of Object.entries(s)){let i=`\x1B[1m${e.padEnd(t)}\x1B[0m`,r=typeof n=="object"&&n!==null?JSON.stringify(n):String(n??"");console.log(`${i} ${r}`)}}var Ks=require("child_process"),Ys=require("crypto"),zs=require("http"),qs=9768,Gs=9780,bu=12e4;function wu(){return(0,Ys.randomBytes)(32).toString("hex")}function Iu(s){let t=process.platform,e=t==="darwin"?`open "${s}"`:t==="win32"?`start "" "${s}"`:`xdg-open "${s}"`;try{return(0,Ks.exec)(e),!0}catch{return!1}}function Au(){return`<!DOCTYPE html>
29
29
  <html>
30
30
  <head><title>LimAI CLI</title></head>
31
31
  <body style="font-family: system-ui, sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; background: #0a0a0a; color: #fafafa;">
@@ -48,7 +48,7 @@ Choice: `);if(a==="2"){await e(o);return}if(a==="3"){await n(o);return}B("Openin
48
48
  ${t}`,Ku=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Yu=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),zu=(s,t,e)=>{let n=e===""?"":`with ${e.trim()}() `,i=Gu.bind(null,n,t.toString());Object.defineProperty(i,"name",Yu);let{writable:r,enumerable:o,configurable:a}=Ku;Object.defineProperty(s,"toString",{value:i,writable:r,enumerable:o,configurable:a})};function li(s,t,{ignoreNonConfigurable:e=!1}={}){let{name:n}=s;for(let i of Reflect.ownKeys(t))Ju(s,t,i,e);return qu(s,t),zu(s,t,n),s}var Ye=new WeakMap,Cr=(s,t={})=>{if(typeof s!="function")throw new TypeError("Expected a function");let e,n=0,i=s.displayName||s.name||"<anonymous>",r=function(...o){if(Ye.set(r,++n),n===1)e=s.apply(this,o),s=void 0;else if(t.throw===!0)throw new Error(`Function \`${i}\` can only be called once`);return e};return li(r,s),Ye.set(r,n),r};Cr.callCount=s=>{if(!Ye.has(s))throw new Error(`The given function \`${s.name}\` is not wrapped by the \`onetime\` package`);return Ye.get(s)};var yr=Cr;var wt=[];wt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&wt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&wt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ze=s=>!!s&&typeof s=="object"&&typeof s.removeListener=="function"&&typeof s.emit=="function"&&typeof s.reallyExit=="function"&&typeof s.listeners=="function"&&typeof s.kill=="function"&&typeof s.pid=="number"&&typeof s.on=="function",ci=Symbol.for("signal-exit emitter"),di=globalThis,Xu=Object.defineProperty.bind(Object),pi=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(di[ci])return di[ci];Xu(di,ci,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,e){this.listeners[t].push(e)}removeListener(t,e){let n=this.listeners[t],i=n.indexOf(e);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(t,e,n){if(this.emitted[t])return!1;this.emitted[t]=!0;let i=!1;for(let r of this.listeners[t])i=r(e,n)===!0||i;return t==="exit"&&(i=this.emit("afterExit",e,n)||i),i}},Xe=class{},Qu=s=>({onExit(t,e){return s.onExit(t,e)},load(){return s.load()},unload(){return s.unload()}}),mi=class extends Xe{onExit(){return()=>{}}load(){}unload(){}},Di=class extends Xe{#o=fi.platform==="win32"?"SIGINT":"SIGHUP";#n=new pi;#t;#s;#p;#e={};#r=!1;constructor(t){super(),this.#t=t,this.#e={};for(let e of wt)this.#e[e]=()=>{let n=this.#t.listeners(e),{count:i}=this.#n,r=t;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(i+=r.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#n.emit("exit",null,e),a=e==="SIGHUP"?this.#o:e;o||t.kill(t.pid,a)}};this.#p=t.reallyExit,this.#s=t.emit}onExit(t,e){if(!ze(this.#t))return()=>{};this.#r===!1&&this.load();let n=e?.alwaysLast?"afterExit":"exit";return this.#n.on(n,t),()=>{this.#n.removeListener(n,t),this.#n.listeners.exit.length===0&&this.#n.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#r){this.#r=!0,this.#n.count+=1;for(let t of wt)try{let e=this.#e[t];e&&this.#t.on(t,e)}catch{}this.#t.emit=(t,...e)=>this.#m(t,...e),this.#t.reallyExit=t=>this.#i(t)}}unload(){this.#r&&(this.#r=!1,wt.forEach(t=>{let e=this.#e[t];if(!e)throw new Error("Listener not defined for signal: "+t);try{this.#t.removeListener(t,e)}catch{}}),this.#t.emit=this.#s,this.#t.reallyExit=this.#p,this.#n.count-=1)}#i(t){return ze(this.#t)?(this.#t.exitCode=t||0,this.#n.emit("exit",this.#t.exitCode,null),this.#p.call(this.#t,this.#t.exitCode)):0}#m(t,...e){let n=this.#s;if(t==="exit"&&ze(this.#t)){typeof e[0]=="number"&&(this.#t.exitCode=e[0]);let i=n.call(this.#t,t,...e);return this.#n.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,t,...e)}},fi=globalThis.process,{onExit:Er,load:Rp,unload:Op}=Qu(ze(fi)?new Di(fi):new mi);var br=se.default.stderr.isTTY?se.default.stderr:se.default.stdout.isTTY?se.default.stdout:void 0,Zu=br?yr(()=>{Er(()=>{br.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},wr=Zu;var Qe=!1,Wt={};Wt.show=(s=gi.default.stderr)=>{s.isTTY&&(Qe=!1,s.write("\x1B[?25h"))};Wt.hide=(s=gi.default.stderr)=>{s.isTTY&&(wr(),Qe=!0,s.write("\x1B[?25l"))};Wt.toggle=(s,t)=>{s!==void 0&&(Qe=s),Qe?Wt.show(t):Wt.hide(t)};var hi=Wt;var le=I(Fi(),1);var tt=I(require("process"),1);function Ci(){return tt.default.platform!=="win32"?tt.default.env.TERM!=="linux":!!tt.default.env.CI||!!tt.default.env.WT_SESSION||!!tt.default.env.TERMINUS_SUBLIME||tt.default.env.ConEmuTask==="{cmd::Cmder}"||tt.default.env.TERM_PROGRAM==="Terminus-Sublime"||tt.default.env.TERM_PROGRAM==="vscode"||tt.default.env.TERM==="xterm-256color"||tt.default.env.TERM==="alacritty"||tt.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var el={info:st.blue("\u2139"),success:st.green("\u2714"),warning:st.yellow("\u26A0"),error:st.red("\u2716")},nl={info:st.blue("i"),success:st.green("\u221A"),warning:st.yellow("\u203C"),error:st.red("\xD7")},il=Ci()?el:nl,re=il;function yi({onlyFirst:s=!1}={}){let i="(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(i,s?void 0:"g")}var sl=yi();function oe(s){if(typeof s!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof s}\``);return!s.includes("\x1B")&&!s.includes("\x9B")?s:s.replace(sl,"")}var tn=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],en=[12288,12288,65281,65376,65504,65510],Ei=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],bi=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],ae=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var nn=(s,t)=>{let e=0,n=Math.floor(s.length/2)-1;for(;e<=n;){let i=Math.floor((e+n)/2),r=i*2;if(t<s[r])n=i-1;else if(t>s[r+1])e=i+1;else return!0}return!1};var rl=tn[0],ol=tn.at(-1),al=en[0],ul=en.at(-1),Qp=Ei[0],Zp=Ei.at(-1),tm=bi[0],em=bi.at(-1),ll=ae[0],cl=ae.at(-1),vr=19968,[dl,pl]=ml(ae);function ml(s){let t=s[0],e=s[1];for(let n=0;n<s.length;n+=2){let i=s[n],r=s[n+1];if(vr>=i&&vr<=r)return[i,r];r-i>e-t&&(t=i,e=r)}return[t,e]}var Sr=s=>s<rl||s>ol?!1:nn(tn,s),xr=s=>s<al||s>ul?!1:nn(en,s);var Tr=s=>s>=dl&&s<=pl?!0:s<ll||s>cl?!1:nn(ae,s);function Dl(s){if(!Number.isSafeInteger(s))throw new TypeError(`Expected a code point, got \`${typeof s}\`.`)}function Rr(s,{ambiguousAsWide:t=!1}={}){return Dl(s),xr(s)||Tr(s)||t&&Sr(s)?2:1}var Or=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;var fl=new Intl.Segmenter,gl=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function wi(s,t={}){if(typeof s!="string"||s.length===0)return 0;let{ambiguousIsNarrow:e=!0,countAnsiEscapeCodes:n=!1}=t;if(n||(s=oe(s)),s.length===0)return 0;let i=0,r={ambiguousAsWide:!e};for(let{segment:o}of fl.segment(s)){let a=o.codePointAt(0);if(!(a<=31||a>=127&&a<=159)&&!(a>=8203&&a<=8207||a===65279)&&!(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)&&!(a>=55296&&a<=57343)&&!(a>=65024&&a<=65039)&&!gl.test(o)){if(Or().test(o)){i+=2;continue}i+=Rr(a,r)}}return i}function Ii({stream:s=process.stdout}={}){return!!(s&&s.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}var Ai=I(require("process"),1);function _i(){let{env:s}=Ai.default,{TERM:t,TERM_PROGRAM:e}=s;return Ai.default.platform!=="win32"?t!=="linux":!!s.WT_SESSION||!!s.TERMINUS_SUBLIME||s.ConEmuTask==="{cmd::Cmder}"||e==="Terminus-Sublime"||e==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||s.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var rt=I(require("process"),1),hl=3,vi=class{#o=0;start(){this.#o++,this.#o===1&&this.#n()}stop(){if(this.#o<=0)throw new Error("`stop` called more times than `start`");this.#o--,this.#o===0&&this.#t()}#n(){rt.default.platform==="win32"||!rt.default.stdin.isTTY||(rt.default.stdin.setRawMode(!0),rt.default.stdin.on("data",this.#s),rt.default.stdin.resume())}#t(){rt.default.stdin.isTTY&&(rt.default.stdin.off("data",this.#s),rt.default.stdin.pause(),rt.default.stdin.setRawMode(!1))}#s(t){t[0]===hl&&rt.default.emit("SIGINT")}},Fl=new vi,Si=Fl;var Cl=I(Fi(),1),xi=class{#o=0;#n=!1;#t=0;#s=-1;#p=0;#e;#r;#i;#m;#f;#l;#c;#d;#g;#a;#u;color;constructor(t){typeof t=="string"&&(t={text:t}),this.#e={color:"cyan",stream:ue.default.stderr,discardStdin:!0,hideCursor:!0,...t},this.color=this.#e.color,this.spinner=this.#e.spinner,this.#f=this.#e.interval,this.#i=this.#e.stream,this.#l=typeof this.#e.isEnabled=="boolean"?this.#e.isEnabled:Ii({stream:this.#i}),this.#c=typeof this.#e.isSilent=="boolean"?this.#e.isSilent:!1,this.text=this.#e.text,this.prefixText=this.#e.prefixText,this.suffixText=this.#e.suffixText,this.indent=this.#e.indent,ue.default.env.NODE_ENV==="test"&&(this._stream=this.#i,this._isEnabled=this.#l,Object.defineProperty(this,"_linesToClear",{get(){return this.#o},set(e){this.#o=e}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#s}}),Object.defineProperty(this,"_lineCount",{get(){return this.#t}}))}get indent(){return this.#d}set indent(t=0){if(!(t>=0&&Number.isInteger(t)))throw new Error("The `indent` option must be an integer from 0 and up");this.#d=t,this.#D()}get interval(){return this.#f??this.#r.interval??100}get spinner(){return this.#r}set spinner(t){if(this.#s=-1,this.#f=void 0,typeof t=="object"){if(t.frames===void 0)throw new Error("The given spinner must have a `frames` property");this.#r=t}else if(!_i())this.#r=le.default.line;else if(t===void 0)this.#r=le.default.dots;else if(t!=="default"&&le.default[t])this.#r=le.default[t];else throw new Error(`There is no built-in spinner named '${t}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#g}set text(t=""){this.#g=t,this.#D()}get prefixText(){return this.#a}set prefixText(t=""){this.#a=t,this.#D()}get suffixText(){return this.#u}set suffixText(t=""){this.#u=t,this.#D()}get isSpinning(){return this.#m!==void 0}#h(t=this.#a,e=" "){return typeof t=="string"&&t!==""?t+e:typeof t=="function"?t()+e:""}#F(t=this.#u,e=" "){return typeof t=="string"&&t!==""?e+t:typeof t=="function"?e+t():""}#D(){let t=this.#i.columns??80,e=this.#h(this.#a,"-"),n=this.#F(this.#u,"-"),i=" ".repeat(this.#d)+e+"--"+this.#g+"--"+n;this.#t=0;for(let r of oe(i).split(`
49
49
  `))this.#t+=Math.max(1,Math.ceil(wi(r,{countAnsiEscapeCodes:!0})/t))}get isEnabled(){return this.#l&&!this.#c}set isEnabled(t){if(typeof t!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");this.#l=t}get isSilent(){return this.#c}set isSilent(t){if(typeof t!="boolean")throw new TypeError("The `isSilent` option must be a boolean");this.#c=t}frame(){let t=Date.now();(this.#s===-1||t-this.#p>=this.interval)&&(this.#s=++this.#s%this.#r.frames.length,this.#p=t);let{frames:e}=this.#r,n=e[this.#s];this.color&&(n=st[this.color](n));let i=typeof this.#a=="string"&&this.#a!==""?this.#a+" ":"",r=typeof this.text=="string"?" "+this.text:"",o=typeof this.#u=="string"&&this.#u!==""?" "+this.#u:"";return i+n+r+o}clear(){if(!this.#l||!this.#i.isTTY)return this;this.#i.cursorTo(0);for(let t=0;t<this.#o;t++)t>0&&this.#i.moveCursor(0,-1),this.#i.clearLine(1);return(this.#d||this.lastIndent!==this.#d)&&this.#i.cursorTo(this.#d),this.lastIndent=this.#d,this.#o=0,this}render(){return this.#c?this:(this.clear(),this.#i.write(this.frame()),this.#o=this.#t,this)}start(t){return t&&(this.text=t),this.#c?this:this.#l?this.isSpinning?this:(this.#e.hideCursor&&hi.hide(this.#i),this.#e.discardStdin&&ue.default.stdin.isTTY&&(this.#n=!0,Si.start()),this.render(),this.#m=setInterval(this.render.bind(this),this.interval),this):(this.text&&this.#i.write(`- ${this.text}
50
50
  `),this)}stop(){return this.#l?(clearInterval(this.#m),this.#m=void 0,this.#s=0,this.clear(),this.#e.hideCursor&&hi.show(this.#i),this.#e.discardStdin&&ue.default.stdin.isTTY&&this.#n&&(Si.stop(),this.#n=!1),this):this}succeed(t){return this.stopAndPersist({symbol:re.success,text:t})}fail(t){return this.stopAndPersist({symbol:re.error,text:t})}warn(t){return this.stopAndPersist({symbol:re.warning,text:t})}info(t){return this.stopAndPersist({symbol:re.info,text:t})}stopAndPersist(t={}){if(this.#c)return this;let e=t.prefixText??this.#a,n=this.#h(e," "),i=t.symbol??" ",r=t.text??this.text,a=typeof r=="string"?(i?" ":"")+r:"",u=t.suffixText??this.#u,l=this.#F(u," "),c=n+i+a+l+`
51
- `;return this.stop(),this.#i.write(c),this}};function Ti(s){return new xi(s)}var It={start(){return It},stop(){return It},succeed(){return It},fail(){return It},warn(){return It},info(){return It},text:"",isSpinning:!1};function y(s){return p()?It:Ti({text:s,color:"cyan"})}function kr(s){let t=s.command("documents").description("Document upload and processing");t.command("upload <extractionSchemaId> <file>").description("Upload a document for extraction").action(async(e,n)=>{let i=new g(f()),r=rn.resolve(n);sn.existsSync(r)||(console.error(`File not found: ${r}`),process.exit(1));let o=y(`Uploading ${rn.basename(r)}...`);o.start();let a=await i.uploadFile(e,r);a.isDuplicate?o.warn("File already exists (duplicate)."):o.succeed("File uploaded."),p()?D(a):w(a)}),t.command("process <extractionSchemaId> <fileId>").description("Process a document for extraction").option("--async","Process asynchronously").option("--wait","Wait for completion (implies --async)").action(async(e,n,i)=>{let r=new g(f());if(i.async||i.wait){let a=await r.documents.processAsync(e,n);if(i.wait){let u=y(`Waiting for extraction (job ${a.jobId})...`);u.start();let c=await new Q(r.queue).waitForCompletion(a.jobId,{onStatus:d=>{u.text=`Extraction: ${d.status} (${d.extractionStageStatus})`}});if(c.status==="COMPLETED"){u.succeed("Extraction completed.");let d=await r.documents.getFileData(n,e);p()?D(d):w({fileId:n,status:"COMPLETED",tables:Object.keys(d.data?.tables??{}).length})}else u.fail(`Extraction ${c.status}`),process.exit(1)}else p()?D(a):(E("Processing job queued."),w(a))}else{let a=y("Processing file...");a.start();let u=await r.documents.processSync(e,n);a.succeed("Processing complete."),p()?D(u):w(u)}}),t.command("get <fileId>").description("Get extracted file data").option("--extraction-schema-id <id>","Extraction schema ID").action(async(e,n)=>{let r=await new g(f()).documents.getFileData(e,n.extractionSchemaId);p()?D(r):w(r)}),t.command("data <deploymentId> <fileIds...>").description("Get flat slug-keyed data for one or more documents").option("--include <options>","Comma-separated enrichments: confidence, boundingBoxes, validations").action(async(e,n,i)=>{let r=new g(f()),o=i.include?.split(",").map(u=>u.trim()).filter(Boolean),a=await r.documents.getDocumentsData(e,n,o);p()?D(a):w(a)}),t.command("correct <extractionSchemaId> <fileId>").description("Submit corrections for extracted data").requiredOption("--corrections <file>","JSON file with corrections").action(async(e,n,i)=>{let r=new g(f()),o=sn.readFileSync(i.corrections,"utf-8"),a=JSON.parse(o);await r.documents.submitCorrections(e,n,a),p()?D({success:!0}):E("Corrections submitted.")})}var Ri=I(require("fs"));function Br(s){let t=s.command("tables").description("Table management");t.command("create <deploymentId>").description("Create a table in a deployment").requiredOption("--body <file>","JSON file with table definition").action(async(e,n)=>{let i=new g(f()),r=Ri.readFileSync(n.body,"utf-8"),o=JSON.parse(r),a=await i.tables.createTable(e,o);p()?D(a):(E("Table created."),w(a))}),t.command("update <tableId>").description("Update a table's instructions or name").option("--instructions <text>","New instructions text").option("--instructions-file <file>","Read new instructions from a file (overrides --instructions)").option("--name <name>","New table name").action(async(e,n)=>{let i=new g(f()),r={};if(n.instructionsFile?r.instructions=Ri.readFileSync(n.instructionsFile,"utf-8"):n.instructions!==void 0&&(r.instructions=n.instructions),n.name!==void 0&&(r.name=n.name),Object.keys(r).length===0)throw new Error("Provide at least one of --instructions, --instructions-file, or --name");let o=await i.tables.update(e,r);p()?D(o):(E("Table updated."),w(o))}),t.command("get <tableId>").description("Get table details").action(async e=>{let i=await new g(f()).tables.get(e);p()?D(i):w(i)}),t.command("rows <tableId>").description("List rows in a table").option("--limit <n>","Number of rows","50").option("--offset <n>","Offset","0").option("--all","Fetch all rows (auto-paginate)").action(async(e,n)=>{let i=new g(f());if(n.all){let r=await Oe(Ps(async(o,a)=>i.tables.listRows(e,{limit:o,offset:a}),{pageSize:500}));p()?D(r):v(r)}else{let r=await i.tables.listRows(e,{limit:parseInt(n.limit),offset:parseInt(n.offset)});p()?D(r):v(r.data)}}),t.command("columns <tableId>").description("List columns in a table").action(async e=>{let i=await new g(f()).tables.listColumns(e);p()?D(i):v(i,["id","name","type"])})}var Wr=I(require("fs"));var $r=["index","id","name","slug","type","isKey","units","autoGenerateUnits","defaultValue","defaultValueEnabled"],yl="NUMBER_WITH_UNIT columns need --units a,b or --auto-generate-units on.";function Pr(s){return{...s,units:(s.units??[]).map(t=>t.name).join(", ")}}function El(s){if(s.type==="NUMBER_WITH_UNIT"&&!s.autoGenerateUnits&&!(s.units&&s.units.length>0))throw new nt(yl)}function At(s){if(s==="on")return!0;if(s==="off")return!1;throw new nt("Expected 'on' or 'off'.")}function bl(s){let t=Number(s);if(!Number.isInteger(t)||t<40||t>2e3)throw new nt("Expected an integer between 40 and 2000.");return t}function wl(s){try{return JSON.parse(s)}catch{return s}}function Nr(s){return s.split(",").map(t=>t.trim()).filter(Boolean)}function jr(s){return s.option("--name <name>","Column name").option("--slug <slug>","Column slug (snake_case)").option("--type <type>","Column type, e.g. TEXT, NUMBER, DATE, LABEL").option("--description <text>","Column description").option("--is-key <on|off>","Mark the column as a key column",At).option("--is-list <on|off>","Store multiple values per cell",At).option("--date-format <format>","Date format: EU, US or ISO").option("--measurement-type <type>","Benchmark measurement type").option("--excluded-from-extraction <on|off>","Keep the column out of extraction prompts",At).option("--pinned <on|off>","Pin the column in the grid",At).option("--size <px>","Column width in pixels (40-2000)",bl).option("--default-value <json>","Default value as JSON (falls back to a plain string)",wl).option("--clear-default-value","Clear the stored default value").option("--default-value-enabled <on|off>","Write the default value into empty cells during extraction",At).option("--auto-generate-labels <on|off>","Let extraction invent new labels",At).option("--auto-generate-units <on|off>","Let extraction invent new units",At).option("--labels <names>","Comma-separated label names",Nr).option("--units <names>","Comma-separated unit names",Nr)}function Lr(s){let t={};return s.name!==void 0&&(t.name=s.name),s.slug!==void 0&&(t.slug=s.slug),s.type!==void 0&&(t.type=s.type),s.description!==void 0&&(t.description=s.description),s.isKey!==void 0&&(t.isKey=s.isKey),s.isList!==void 0&&(t.isList=s.isList),s.dateFormat!==void 0&&(t.dateFormat=s.dateFormat),s.measurementType!==void 0&&(t.measurementType=s.measurementType),s.excludedFromExtraction!==void 0&&(t.excludedFromExtraction=s.excludedFromExtraction),s.pinned!==void 0&&(t.pinned=s.pinned),s.size!==void 0&&(t.size=s.size),s.clearDefaultValue?t.defaultValue=null:s.defaultValue!==void 0&&(t.defaultValue=s.defaultValue),s.defaultValueEnabled!==void 0&&(t.defaultValueEnabled=s.defaultValueEnabled),s.autoGenerateLabels!==void 0&&(t.autoGenerateLabels=s.autoGenerateLabels),s.autoGenerateUnits!==void 0&&(t.autoGenerateUnits=s.autoGenerateUnits),s.labels!==void 0&&(t.labels=s.labels.map(e=>({name:e}))),s.units!==void 0&&(t.units=s.units.map(e=>({name:e}))),t}function Mr(s){return JSON.parse(Wr.readFileSync(s,"utf-8"))}function Ur(s){if(p()){D(s);return}w(s)}function Vr(s){let t=s.command("columns").description("Column management");t.command("list <tableId>").description("List the columns of a table").action(async e=>{let i=await new g(f()).columns.list(e);p()?D(i):v(i.map(Pr),$r)}),t.command("get <columnId>").description("Get column details").action(async e=>{let i=await new g(f()).columns.get(e);Ur(i)}),jr(t.command("create <tableId>").description("Create one or more columns in a table").option("--body <file>","JSON file with a column object or { columns: [...] }")).action(async(e,n)=>{let i=Lr(n),r=n.body?Mr(n.body):void 0,o=Il(r,i);for(let l of"columns"in o?o.columns:[o])El(l);let u=await new g(f()).columns.create(e,o);if(p()){D(u);return}E(`Created ${u.length} column${u.length===1?"":"s"}.`),v(u.map(Pr),$r)}),jr(t.command("update <columnId>").description("Update a column").option("--body <file>","JSON file with the fields to update").option("--confirm-slug-change","Confirm a slug change (breaks integrations that reference it)")).action(async(e,n)=>{let r={...n.body?Mr(n.body):{},...Lr(n)};if(n.confirmSlugChange&&(r.confirmSlugChange=!0),Object.keys(r).every(u=>u==="confirmSlugChange"))throw new nt("Provide --body or at least one field flag.");let a=await new g(f()).columns.update(e,r);if(p()){D(a);return}E("Column updated."),Ur(a)})}function Il(s,t){if(s&&typeof s=="object"&&"columns"in s){if(Object.keys(t).length>0)throw new nt("Field flags cannot be combined with a bulk --body file.");return s}let e={...s,...t};if(typeof e.name!="string"||e.name.length===0)throw new nt("A column name is required (--name).");return e}var Hr=I(require("fs"));var Jr=["OFF","FAST","BALANCED","PRO"];function Al(s){if(s==="on")return!0;if(s==="off")return!1;throw new nt("Expected 'on' or 'off'.")}function _l(s){let t=s.toUpperCase();if(Jr.includes(t))return t;throw new nt(`Expected one of ${Jr.join(", ")}.`)}function qr(s){let t=s.command("schema").description("Extraction schema management");t.command("get <extractionSchemaId>").description("Get extraction schema details").action(async e=>{let i=await new g(f()).schema.get(e);p()?D(i):w(i)}),t.command("update <extractionSchemaId>").description("Update extraction schema settings (dynamic mapping, bbox tier, or any field via --body)").option("--body <file>","JSON file with schema settings to update").option("--dynamic-mapping <on|off>","Enable or disable dynamic mapping (turns big-table extraction off when enabled)",Al).option("--bbox-tier <tier>","Bounding box tier: OFF, FAST, BALANCED or PRO",_l).action(async(e,n)=>{let r={...n.body?JSON.parse(Hr.readFileSync(n.body,"utf-8")):{},...n.dynamicMapping!==void 0?{useDynamicMapping:n.dynamicMapping}:{},...n.bboxTier!==void 0?{bboxTier:n.bboxTier}:{}};if(Object.keys(r).length===0)throw new nt("Provide --body, --dynamic-mapping or --bbox-tier.");let a=await new g(f()).schema.update(e,r);p()?D(a):(E("Extraction schema updated."),w(a))}),t.command("data <extractionSchemaId>").description("Get all data for an extraction schema").action(async e=>{let i=await new g(f()).schema.getAllData(e);p()?D(i):w(i)})}var Gr=I(require("fs"));function Kr(s){let t=s.command("benchmarks").description("Benchmark management");t.command("run <extractionSchemaId>").description("Run a benchmark").requiredOption("--name <name>","Benchmark name").option("--description <desc>","Benchmark description").option("--file-ids <ids>","Comma-separated file IDs").option("--config-file <file>","JSON file with benchmark configuration").action(async(e,n)=>{let i=new g(f()),r={name:n.name};if(n.description&&(r.description=n.description),n.fileIds&&(r.fileIds=n.fileIds.split(",")),n.configFile){let a=Gr.readFileSync(n.configFile,"utf-8"),u=JSON.parse(a);r={...r,...u}}let o=await i.http.post(`/benchmark/${e}/run-benchmark`,r);p()?D(o):(E("Benchmark started."),w(o))}),t.command("files <extractionSchemaId>").description("List files available for benchmarking").action(async e=>{let i=await new g(f()).http.get(`/benchmark/${e}/list-files`),r=Array.isArray(i)?i:i.data||i;p()?D(i):v(r)}),t.command("results <extractionSchemaId>").description("Get benchmark results").requiredOption("--execution-id <id>","Execution ID").action(async(e,n)=>{let r=await new g(f()).http.get(`/benchmark/${e}/get-results`,{executionId:n.executionId});p()?D(r):w(r)}),t.command("status <executionId>").description("Get benchmark execution status").action(async e=>{let i=await new g(f()).http.get(`/benchmarks/${e}`);p()?D(i):w(i)}),t.command("metrics <executionId>").description("Get benchmark execution metrics").action(async e=>{let i=await new g(f()).http.get(`/benchmarks/${e}/metrics`);p()?D(i):w(i)})}var mt=I(require("fs")),de=I(require("path")),an=require("stream"),Qr=require("stream/promises");var on=I(require("fs")),ce=I(require("path"));var vl=["JOB_CONTEXT.json",ce.join(process.env.HOME||"/home/daytona","JOB_CONTEXT.json")];function Yr(s){let t=s?[ce.resolve(s)]:vl.map(e=>ce.resolve(e));for(let e of t)if(on.existsSync(e)){let n=on.readFileSync(e,"utf-8"),i;try{i=JSON.parse(n)}catch{throw new W(`Invalid JSON in ${e}`)}return Sl(i,e),i}throw new R("JOB_CONTEXT.json not found. Searched: "+t.join(", "),{code:"JOB_CONTEXT_NOT_FOUND",exitCode:1})}function Sl(s,t){let e=[];if(s.jobId||e.push("jobId"),s.fileId||e.push("fileId"),s.fileName||e.push("fileName"),s.sourceFileUrl||e.push("sourceFileUrl"),s.deploymentId||e.push("deploymentId"),s.extractionSchemaId||e.push("extractionSchemaId"),e.length>0)throw new W(`JOB_CONTEXT.json (${t}) missing required fields: ${e.join(", ")}`);if(!s.schema||!Array.isArray(s.schema.tables)||s.schema.tables.length===0)throw new W(`JOB_CONTEXT.json (${t}) must have schema.tables with at least one table`);for(let n of s.schema.tables){if(!n.id||!n.name)throw new W("JOB_CONTEXT.json: table missing id or name");if(!Array.isArray(n.columns)||n.columns.length===0)throw new W(`JOB_CONTEXT.json: table "${n.name}" has no columns`)}}function zr(s,t){let e=[],n=[],i=[],r=0;if(!s||typeof s!="object")return{valid:!1,errors:["Submission must be a JSON object"],warnings:[],summary:{tablesFound:0,totalRows:0,tableDetails:[]}};if(!s.tables||typeof s.tables!="object")return{valid:!1,errors:['Submission must have a "tables" object'],warnings:[],summary:{tablesFound:0,totalRows:0,tableDetails:[]}};let o=new Map;for(let u of t.schema.tables)o.set(u.name,u);let a=Object.keys(s.tables);for(let u of a){let l=o.get(u);if(!l){e.push(`Table "${u}" not found in schema. Available tables: ${[...o.keys()].join(", ")}`);continue}let c=s.tables[u];if(!Array.isArray(c)){e.push(`Table "${u}": rows must be an array`);continue}let d=!l.isPrimary,m=new Set(l.columns.map(F=>F.name)),h=new Map(l.columns.map(F=>[F.name,F]));for(let F=0;F<c.length;F++){let A=c[F];xl(A,F,u,d,m,h,e,n)}i.push({name:u,rowCount:c.length,isChild:d}),r+=c.length}for(let u of t.schema.tables)a.includes(u.name)||n.push(`Schema table "${u.name}" has no data in submission`);return{valid:e.length===0,errors:e,warnings:n,summary:{tablesFound:a.length,totalRows:r,tableDetails:i}}}function xl(s,t,e,n,i,r,o,a){let u=`Table "${e}" row ${t}`;if(typeof s!="object"||s===null){o.push(`${u}: must be an object`);return}if(typeof s.index!="number"&&o.push(`${u}: missing or invalid "index" (must be a number)`),!s.cells||typeof s.cells!="object"){o.push(`${u}: missing or invalid "cells" object`);return}n&&(s.parentIndex===void 0||s.parentIndex===null)&&o.push(`${u}: child table rows must have "parentIndex"`),n&&s.parentIndex!==void 0&&typeof s.parentIndex!="number"&&o.push(`${u}: "parentIndex" must be a number`);let l=Object.keys(s.cells);if(l.length===0){o.push(`${u}: cells object is empty`);return}let c=0;for(let d of l)if(!i.has(d))a.push(`${u}: unknown column "${d}" (will be skipped by API)`);else{c++;let m=r.get(d);m&&Tl(s.cells[d],d,m.type,m.isList,u,a)}c===0&&o.push(`${u}: no cell keys match any schema column`)}function Tl(s,t,e,n,i,r){if(s!=null){if(n&&!Array.isArray(s)){r.push(`${i}: column "${t}" is a LIST but value is not an array`);return}switch(e){case"NUMBER":typeof s!="number"&&typeof s!="string"&&r.push(`${i}: column "${t}" (NUMBER) has unexpected type ${typeof s}`);break;case"BOOLEAN":typeof s!="boolean"&&r.push(`${i}: column "${t}" (BOOLEAN) has unexpected type ${typeof s}`);break;case"DATE":typeof s!="string"&&r.push(`${i}: column "${t}" (DATE) should be an ISO date string`);break;case"LIST":Array.isArray(s)||r.push(`${i}: column "${t}" (LIST) should be an array`);break}}}var Xr=200;function Zr(s){let t=s.command("jobs").description("Job queue management");t.command("status <jobId>").description("Get job status").option("--wait","Poll until job completes").option("--timeout <seconds>","Timeout in seconds","300").action(async(e,n)=>{let i=new g(f());if(n.wait){let r=new Q(i.queue),o=y(`Waiting for job ${e}...`);o.start();let a;for await(let u of r.poll(e,{timeoutMs:parseInt(n.timeout)*1e3}))o.text=`Job ${e}: ${u.status} (extraction: ${u.extractionStageStatus})`,a=u;a?.status==="COMPLETED"?o.succeed(`Job ${e} completed.`):o.fail(`Job ${e}: ${a?.status}`),p()?D(a):w(a)}else{let r=await i.queue.getStatus(e);p()?D(r):w(r)}}),t.command("wait <jobId>").description("Wait for a job to complete").option("--timeout <seconds>","Timeout in seconds","300").action(async(e,n)=>{let i=new g(f()),r=new Q(i.queue),o=y(`Waiting for job ${e}...`);o.start();let a=await r.waitForCompletion(e,{timeoutMs:parseInt(n.timeout)*1e3,onStatus:u=>{o.text=`Job ${e}: ${u.status}`}});a.status==="COMPLETED"?o.succeed(`Job ${e} completed.`):o.fail(`Job ${e}: ${a.status}`),p()?D(a):w(a)}),t.command("cancel <jobId>").description("Cancel a queued job").action(async e=>{await new g(f()).queue.cancel(e),p()?D({success:!0,jobId:e}):E(`Job ${e} cancelled.`)}),t.command("update <jobId>").description("Update job status").requiredOption("--status <status>","Status: PROCESSING, COMPLETED, or FAILED").option("--error-message <msg>","Error message (required for FAILED)").option("--pages <n>","Pages processed (for COMPLETED billing)").option("--rows <n>","Rows created (for COMPLETED billing)").action(async(e,n)=>{let i=n.status.toUpperCase();if(!["PROCESSING","COMPLETED","FAILED"].includes(i))throw new W("Status must be PROCESSING, COMPLETED, or FAILED");if(i==="FAILED"&&!n.errorMessage)throw new W("--error-message is required when status is FAILED");let o=await new g(f()).queue.updateStatus(e,{status:i,errorMessage:n.errorMessage,pages:n.pages?parseInt(n.pages):void 0,rows:n.rows?parseInt(n.rows):void 0});p()?D(o):E(`Job ${e} status updated to ${i}`)}),t.command("download <url>").description("Download a file from a URL and optionally mark a job as PROCESSING").option("--job-id <id>","Job ID to mark as PROCESSING (or $LIMAI_JOB_ID)").option("--output <path>","Output file path","./source").action(async(e,n)=>{let i=new g(f()),r=n.jobId||process.env.LIMAI_JOB_ID,o=y("Downloading...");o.start();try{r&&(o.text="Marking job as PROCESSING...",await i.queue.updateStatus(r,{status:"PROCESSING"})),o.text="Downloading file...";let a=await fetch(e);if(!a.ok)throw new R(`Failed to download: HTTP ${a.status}`,{code:"DOWNLOAD_ERROR",exitCode:1});let u=de.resolve(n.output),l=de.dirname(u);if(mt.existsSync(l)||mt.mkdirSync(l,{recursive:!0}),!a.body)throw new R("Download failed: response body is empty",{code:"DOWNLOAD_ERROR",exitCode:1});let c=0,d=new an.Transform({transform(h,F,A){c+=h.byteLength,A(null,h)}});await(0,Qr.pipeline)(an.Readable.fromWeb(a.body),d,mt.createWriteStream(u)),o.succeed(`Downloaded (${$l(c)})`);let m={file:u,bytes:c};r&&(m.jobId=r,m.status="PROCESSING"),p()&&D(m)}catch(a){throw o.fail("Download failed"),r&&await Bl(i,r,a),a}}),t.command("submit <file>").description("Validate and submit extraction data, then mark job complete").requiredOption("--context <path>","Path to JOB_CONTEXT.json").option("--job-id <id>","Job ID (or $LIMAI_JOB_ID)").option("--file-id <id>","File ID (or $LIMAI_FILE_ID)").option("--deployment-id <id>","Deployment ID (or $LIMAI_DEPLOYMENT_ID)").option("--batch-size <n>","Rows per API batch",String(Xr)).option("--dry-run","Validate and show plan without submitting").action(async(e,n)=>{let i=Yr(n.context),r=n.jobId||process.env.LIMAI_JOB_ID||i.jobId,o=n.fileId||process.env.LIMAI_FILE_ID||i.fileId,a=n.deploymentId||process.env.LIMAI_DEPLOYMENT_ID||i.deploymentId,u=new g(f()),l=parseInt(n.batchSize)||Xr,c=y("Loading and validating submission...");c.start();try{let d=kl(e),m=zr(d,i);if(!m.valid){c.fail("Validation failed");for(let S of m.errors)console.error(`\x1B[31m ${S}\x1B[0m`);p()&&D({error:{code:"VALIDATION_ERROR",errors:m.errors}}),process.exit(1)}if(m.warnings.length>0&&!p())for(let S of m.warnings)Y(` ${S}`);let h=new Map,F=[],A=[];for(let S of i.schema.tables)h.set(S.name,S.id),S.isPrimary?F.push(S.name):A.push(S.name);if(n.dryRun){c.succeed("Validation passed (dry run)");let S={dryRun:!0,validation:m.summary,deleteOrder:[...A,...F].filter(T=>d.tables[T]).map(T=>({table:T,tableId:h.get(T)})),createOrder:[...F,...A].filter(T=>d.tables[T]).map(T=>({table:T,tableId:h.get(T),rows:d.tables[T].length,batches:Math.ceil(d.tables[T].length/l)}))};if(p())D(S);else{B("Delete order:");for(let T of S.deleteOrder)B(` ${T.table} (${T.tableId})`);B("Create order:");for(let T of S.createOrder)B(` ${T.table}: ${T.rows} rows in ${T.batches} batch(es)`)}return}let k=Object.keys(d.tables),b=[...A,...F].filter(S=>k.includes(S));for(let S of b){let T=h.get(S);c.text=`Deleting existing rows from "${S}"...`,await u.tables.deleteRows(T,{fileId:o,deploymentId:a})}let C=0,x=new Map;for(let S of F){let T=d.tables[S];if(!T||T.length===0)continue;let zt=h.get(S),yt=new Map;x.set(S,yt);let ft=await Rl(u,zt,o,a,T,l,c,S);for(let K=0;K<T.length;K++)ft[K]&&yt.set(T[K].index,ft[K]);C+=ft.length}for(let S of A){let T=d.tables[S];if(!T||T.length===0)continue;let zt=h.get(S),yt=Ol(S,i),ft=yt?x.get(yt):void 0,K=T.map(Ot=>{let In;if(Ot.parentIndex!==void 0&&ft&&(In=ft.get(Ot.parentIndex),!In))throw new W(`Table "${S}" row ${Ot.index}: parentIndex ${Ot.parentIndex} does not match any parent row`);return{cells:Ot.cells,index:Ot.index,parentRowId:In}}),Ee=await to(u,zt,o,a,K,l,c,S);C+=Ee.length}c.text="Marking job as COMPLETED...",await u.queue.updateStatus(r,{status:"COMPLETED",pages:d.metadata?.pages,rows:C}),c.succeed(`Submitted ${C} rows across ${m.summary.tablesFound} table(s). Job COMPLETED.`);let V={status:"COMPLETED",jobId:r,tablesProcessed:m.summary.tablesFound,totalRowsCreated:C,tables:m.summary.tableDetails};p()&&D(V)}catch(d){c.fail("Submission failed");let m=d instanceof Error?d.message:String(d),h=d instanceof W?"VALIDATION_ERROR":"SUBMISSION_ERROR";p()?D({error:{code:h,message:m}}):console.error(`\x1B[31m ${m}\x1B[0m`),process.exit(1)}})}async function Rl(s,t,e,n,i,r,o,a){let u=i.map(l=>({cells:l.cells,index:l.index}));return to(s,t,e,n,u,r,o,a)}async function to(s,t,e,n,i,r,o,a){let u=Array.from({length:i.length}),l=Math.ceil(i.length/r),c=3,d=0,m=[];for(let h=0;h<i.length;h+=r)m.push({start:h,batchRows:i.slice(h,h+r)});for(let h=0;h<m.length;h+=c){let F=m.slice(h,h+c),A=await Promise.all(F.map(({batchRows:k})=>s.tables.createRows(t,{fileId:e,deploymentId:n,rows:k})));for(let k=0;k<F.length;k++){let{start:b}=F[k];A[k].rowIds.forEach((C,x)=>{u[b+x]=C})}d+=F.length,o.text=`"${a}" batch ${d}/${l} (${Math.min(d*r,i.length)}/${i.length} rows)...`}return u.filter(Boolean)}function Ol(s,t){let e=t.schema.tables.find(i=>i.name===s);return!e||e.isPrimary?void 0:t.schema.tables.find(i=>i.isPrimary)?.name}function kl(s){let t=de.resolve(s);if(!mt.existsSync(t))throw new W(`File not found: ${t}`);let e=mt.readFileSync(t,"utf-8");try{return JSON.parse(e)}catch{throw new W(`Invalid JSON in ${t}`)}}async function Bl(s,t,e){try{let n=e instanceof Error?e.message:String(e);await s.queue.updateStatus(t,{status:"FAILED",errorMessage:n.slice(0,500)})}catch{}}function $l(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}var vt=I(require("fs")),ln=I(require("path"));var Wi=I(jo());var cc={update(){},increment(){},stop(){}};function Lo(s){if(p())return cc;let t=s.format??" {bar} {percentage}% | {value}/{total} | {filename}",e=new Wi.default.SingleBar({format:t,barCompleteChar:"\u2588",barIncompleteChar:"\u2591",hideCursor:!0,clearOnComplete:!1,stopOnComplete:!0},Wi.default.Presets.shades_classic);return e.start(s.total,0),{update(n,i){e.update(n,i)},increment(n=1,i){e.increment(n,i)},stop(){e.stop()}}}function Mo(s){s.command("upload <extractionSchemaId> <path>").description("Upload a file or folder for extraction").option("--concurrency <n>","Concurrent uploads","5").option("--process","Queue files for extraction after upload").option("--wait","Wait for all extractions to complete (implies --process)").option("--output <file>","Write results to JSON file").option("--glob <pattern>","Filter files by glob pattern").action(async(t,e,n)=>{let i=f(),r=new g(i),o=ln.resolve(e),a=n.process||n.wait;vt.existsSync(o)||(console.error(`Path not found: ${o}`),process.exit(1));let u=vt.statSync(o);if(u.isFile()){let l=y(`Uploading ${ln.basename(o)}...`);l.start();let c=await r.uploadFile(t,o);if(c.isDuplicate?l.warn(`File already exists (duplicate). File ID: ${c.fileId}`):l.succeed(`Uploaded ${c.filename} (${dc(c.bytesUploaded)})`),a){let d=y("Queuing for extraction...");d.start();let m=await r.documents.processAsync(t,c.fileId);if(d.succeed(`Queued. Job ID: ${m.jobId}`),n.wait){let h=new Q(r.queue),F=y("Waiting for extraction...");F.start();let A=await h.waitForCompletion(m.jobId,{onStatus:k=>{F.text=`Extraction: ${k.status} (${k.extractionStageStatus})`}});if(A.status==="COMPLETED"){F.succeed("Extraction completed.");let k=await r.documents.getFileData(c.fileId,t);n.output?(vt.writeFileSync(n.output,JSON.stringify(k,null,2)),E(`Results written to ${n.output}`)):p()?D(k):w({fileId:c.fileId,status:"COMPLETED",tables:Object.keys(k.data?.tables??{}).length})}else F.fail(`Extraction ${A.status}`),process.exit(1)}else p()&&D({fileId:c.fileId,fileName:c.filename,jobId:m.jobId})}else p()&&D(c)}else if(u.isDirectory()){B(`Scanning ${o} for files...`);let l=await r.uploadFolder(t,o,{concurrency:parseInt(n.concurrency),process:a,globPattern:n.glob});if(l.total===0){Y("No supported files found in directory.");return}if(E(`Upload complete: ${l.uploaded} uploaded, ${l.queued} queued, ${l.failed} failed (${l.total} total)`),l.failed>0){let c=l.files.filter(d=>d.status==="failed");for(let d of c)Y(` Failed: ${d.filename} - ${d.error}`)}if(n.wait&&l.queued>0){let c=l.files.filter(h=>h.status==="queued"&&h.jobId);B(`Waiting for ${c.length} extractions to complete...`);let d=Lo({total:c.length,format:" Extracting {bar} {percentage}% | {value}/{total} files"}),m=0;await Promise.all(c.map(async h=>{await new Q(r.queue).waitForCompletion(h.jobId),m++,d.update(m)})),d.stop(),E("All extractions completed.")}n.output?(vt.writeFileSync(n.output,JSON.stringify(l,null,2)),E(`Results written to ${n.output}`)):p()&&D(l)}})}function dc(s){return s<1024?`${s}B`:s<1024*1024?`${(s/1024).toFixed(1)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}var Uo=I(require("fs"));function Wo(s){s.command("download <tableId>").description("Download extracted data from a table").option("--output <file>","Output file path (streams NDJSON to file)").option("--limit <n>","Max rows to download").option("--all","Download all rows (auto-paginate)").option("--page-size <n>","Rows per API call","100").option("--order <order>","Sort order (asc|desc)","desc").option("--status <status>","Filter by row status").action(async(t,e)=>{let n=new g(f()),i=y("Fetching extraction data...");i.start();let r=e.limit?parseInt(e.limit):e.all?void 0:100;if(e.output){let o=Uo.createWriteStream(e.output),a=0,u=0;for await(let l of n.downloadAll(t,{pageSize:parseInt(e.pageSize),maxItems:r,order:e.order,status:e.status})){for(let c of l)o.write(JSON.stringify(c)+`
51
+ `;return this.stop(),this.#i.write(c),this}};function Ti(s){return new xi(s)}var It={start(){return It},stop(){return It},succeed(){return It},fail(){return It},warn(){return It},info(){return It},text:"",isSpinning:!1};function y(s){return p()?It:Ti({text:s,color:"cyan"})}function kr(s){let t=s.command("documents").description("Document upload and processing");t.command("upload <extractionSchemaId> <file>").description("Upload a document for extraction").action(async(e,n)=>{let i=new g(f()),r=rn.resolve(n);sn.existsSync(r)||(console.error(`File not found: ${r}`),process.exit(1));let o=y(`Uploading ${rn.basename(r)}...`);o.start();let a=await i.uploadFile(e,r);a.isDuplicate?o.warn("File already exists (duplicate)."):o.succeed("File uploaded."),p()?D(a):w(a)}),t.command("process <extractionSchemaId> <fileId>").description("Process a document for extraction").option("--async","Process asynchronously").option("--wait","Wait for completion (implies --async)").action(async(e,n,i)=>{let r=new g(f());if(i.async||i.wait){let a=await r.documents.processAsync(e,n);if(i.wait){let u=y(`Waiting for extraction (job ${a.jobId})...`);u.start();let c=await new Q(r.queue).waitForCompletion(a.jobId,{onStatus:d=>{u.text=`Extraction: ${d.status} (${d.extractionStageStatus})`}});if(c.status==="COMPLETED"){u.succeed("Extraction completed.");let d=await r.documents.getFileData(n,e);p()?D(d):w({fileId:n,status:"COMPLETED",tables:Object.keys(d.data?.tables??{}).length})}else u.fail(`Extraction ${c.status}`),process.exit(1)}else p()?D(a):(E("Processing job queued."),w(a))}else{let a=y("Processing file...");a.start();let u=await r.documents.processSync(e,n);a.succeed("Processing complete."),p()?D(u):w(u)}}),t.command("get <fileId>").description("Get extracted file data").option("--extraction-schema-id <id>","Extraction schema ID").action(async(e,n)=>{let r=await new g(f()).documents.getFileData(e,n.extractionSchemaId);p()?D(r):w(r)}),t.command("data <deploymentId> <fileIds...>").description("Get flat slug-keyed data for one or more documents").option("--include <options>","Comma-separated enrichments: confidence, boundingBoxes, validations").action(async(e,n,i)=>{let r=new g(f()),o=i.include?.split(",").map(u=>u.trim()).filter(Boolean),a=await r.documents.getDocumentsData(e,n,o);p()?D(a):w(a)}),t.command("correct <extractionSchemaId> <fileId>").description("Submit corrections for extracted data").requiredOption("--corrections <file>","JSON file with corrections").action(async(e,n,i)=>{let r=new g(f()),o=sn.readFileSync(i.corrections,"utf-8"),a=JSON.parse(o);await r.documents.submitCorrections(e,n,a),p()?D({success:!0}):E("Corrections submitted.")})}var Ri=I(require("fs"));function Br(s){let t=s.command("tables").description("Table management");t.command("create <deploymentId>").description("Create a table in a deployment").requiredOption("--body <file>","JSON file with table definition").action(async(e,n)=>{let i=new g(f()),r=Ri.readFileSync(n.body,"utf-8"),o=JSON.parse(r),a=await i.tables.createTable(e,o);p()?D(a):(E("Table created."),w(a))}),t.command("update <tableId>").description("Update a table's instructions or name").option("--instructions <text>","New instructions text").option("--instructions-file <file>","Read new instructions from a file (overrides --instructions)").option("--name <name>","New table name").action(async(e,n)=>{let i=new g(f()),r={};if(n.instructionsFile?r.instructions=Ri.readFileSync(n.instructionsFile,"utf-8"):n.instructions!==void 0&&(r.instructions=n.instructions),n.name!==void 0&&(r.name=n.name),Object.keys(r).length===0)throw new Error("Provide at least one of --instructions, --instructions-file, or --name");let o=await i.tables.update(e,r);p()?D(o):(E("Table updated."),w(o))}),t.command("get <tableId>").description("Get table details").action(async e=>{let i=await new g(f()).tables.get(e);p()?D(i):w(i)}),t.command("rows <tableId>").description("List rows in a table").option("--limit <n>","Number of rows","50").option("--offset <n>","Offset","0").option("--all","Fetch all rows (auto-paginate)").action(async(e,n)=>{let i=new g(f());if(n.all){let r=await Oe(Ps(async(o,a)=>i.tables.listRows(e,{limit:o,offset:a}),{pageSize:500}));p()?D(r):v(r)}else{let r=await i.tables.listRows(e,{limit:parseInt(n.limit),offset:parseInt(n.offset)});p()?D(r):v(r.data)}}),t.command("columns <tableId>").description("List columns in a table").action(async e=>{let i=await new g(f()).tables.listColumns(e);p()?D(i):v(i,["id","name","type"])})}var Wr=I(require("fs"));var $r=["index","id","name","slug","type","isKey","units","autoGenerateUnits","defaultValue","defaultValueEnabled"],yl="NUMBER_WITH_UNIT columns need --units a,b or --auto-generate-units on.";function Pr(s){return{...s,units:(s.units??[]).map(t=>t.name).join(", ")}}function El(s){if(s.type==="NUMBER_WITH_UNIT"&&!s.autoGenerateUnits&&!(s.units&&s.units.length>0))throw new nt(yl)}function At(s){if(s==="on")return!0;if(s==="off")return!1;throw new nt("Expected 'on' or 'off'.")}function bl(s){let t=Number(s);if(!Number.isInteger(t)||t<40||t>2e3)throw new nt("Expected an integer between 40 and 2000.");return t}function wl(s){try{return JSON.parse(s)}catch{return s}}function Nr(s){return s.split(",").map(t=>t.trim()).filter(Boolean)}function jr(s){return s.option("--name <name>","Column name").option("--slug <slug>","Column slug (snake_case)").option("--type <type>","Column type, e.g. TEXT, NUMBER, DATE, LABEL").option("--description <text>","Column description").option("--is-key <on|off>","Mark the column as a key column",At).option("--is-list <on|off>","Store multiple values per cell",At).option("--date-format <format>","Date format: EU, US or ISO").option("--measurement-type <type>","Benchmark measurement type").option("--excluded-from-extraction <on|off>","Keep the column out of extraction prompts",At).option("--pinned <on|off>","Pin the column in the grid",At).option("--size <px>","Column width in pixels (40-2000)",bl).option("--default-value <json>","Default value as JSON (falls back to a plain string)",wl).option("--clear-default-value","Clear the stored default value").option("--default-value-enabled <on|off>","Write the default value into empty cells during extraction",At).option("--auto-generate-labels <on|off>","Let extraction invent new labels",At).option("--auto-generate-units <on|off>","Let extraction invent new units",At).option("--labels <names>","Comma-separated label names",Nr).option("--units <names>","Comma-separated unit names",Nr)}function Lr(s){let t={};return s.name!==void 0&&(t.name=s.name),s.slug!==void 0&&(t.slug=s.slug),s.type!==void 0&&(t.type=s.type),s.description!==void 0&&(t.description=s.description),s.isKey!==void 0&&(t.isKey=s.isKey),s.isList!==void 0&&(t.isList=s.isList),s.dateFormat!==void 0&&(t.dateFormat=s.dateFormat),s.measurementType!==void 0&&(t.measurementType=s.measurementType),s.excludedFromExtraction!==void 0&&(t.excludedFromExtraction=s.excludedFromExtraction),s.pinned!==void 0&&(t.pinned=s.pinned),s.size!==void 0&&(t.size=s.size),s.clearDefaultValue?t.defaultValue=null:s.defaultValue!==void 0&&(t.defaultValue=s.defaultValue),s.defaultValueEnabled!==void 0&&(t.defaultValueEnabled=s.defaultValueEnabled),s.autoGenerateLabels!==void 0&&(t.autoGenerateLabels=s.autoGenerateLabels),s.autoGenerateUnits!==void 0&&(t.autoGenerateUnits=s.autoGenerateUnits),s.labels!==void 0&&(t.labels=s.labels.map(e=>({name:e}))),s.units!==void 0&&(t.units=s.units.map(e=>({name:e}))),t}function Mr(s){return JSON.parse(Wr.readFileSync(s,"utf-8"))}function Ur(s){if(p()){D(s);return}w(s)}function Vr(s){let t=s.command("columns").description("Column management");t.command("list <tableId>").description("List the columns of a table").action(async e=>{let i=await new g(f()).columns.list(e);p()?D(i):v(i.map(Pr),$r)}),t.command("get <columnId>").description("Get column details").action(async e=>{let i=await new g(f()).columns.get(e);Ur(i)}),jr(t.command("create <tableId>").description("Create one or more columns in a table").option("--body <file>","JSON file with a column object or { columns: [...] }")).action(async(e,n)=>{let i=Lr(n),r=n.body?Mr(n.body):void 0,o=Il(r,i);for(let l of"columns"in o?o.columns:[o])El(l);let u=await new g(f()).columns.create(e,o);if(p()){D(u);return}E(`Created ${u.length} column${u.length===1?"":"s"}.`),v(u.map(Pr),$r)}),jr(t.command("update <columnId>").description("Update a column").option("--body <file>","JSON file with the fields to update").option("--confirm-slug-change","Confirm a slug change (breaks integrations that reference it)")).action(async(e,n)=>{let r={...n.body?Mr(n.body):{},...Lr(n)};if(n.confirmSlugChange&&(r.confirmSlugChange=!0),Object.keys(r).every(u=>u==="confirmSlugChange"))throw new nt("Provide --body or at least one field flag.");let a=await new g(f()).columns.update(e,r);if(p()){D(a);return}E("Column updated."),Ur(a)})}function Il(s,t){if(s&&typeof s=="object"&&"columns"in s){if(Object.keys(t).length>0)throw new nt("Field flags cannot be combined with a bulk --body file.");return s}let e={...s,...t};if(typeof e.name!="string"||e.name.length===0)throw new nt("A column name is required (--name).");return e}var Hr=I(require("fs"));var Jr=["OFF","FAST","BALANCED","PRO"];function Al(s){if(s==="on")return!0;if(s==="off")return!1;throw new nt("Expected 'on' or 'off'.")}function _l(s){let t=s.toUpperCase();if(Jr.includes(t))return t;throw new nt(`Expected one of ${Jr.join(", ")}.`)}function qr(s){let t=s.command("schema").description("Extraction schema management");t.command("get <deploymentId>").description("Get extraction schema details").action(async e=>{let i=await new g(f()).schema.get(e);p()?D(i):w(i)}),t.command("update <deploymentId>").description("Update extraction schema settings (dynamic mapping, bbox tier, or any field via --body)").option("--body <file>","JSON file with schema settings to update").option("--dynamic-mapping <on|off>","Enable or disable dynamic mapping (turns big-table extraction off when enabled)",Al).option("--bbox-tier <tier>","Bounding box tier: OFF, FAST, BALANCED or PRO",_l).action(async(e,n)=>{let r={...n.body?JSON.parse(Hr.readFileSync(n.body,"utf-8")):{},...n.dynamicMapping!==void 0?{useDynamicMapping:n.dynamicMapping}:{},...n.bboxTier!==void 0?{bboxTier:n.bboxTier}:{}};if(Object.keys(r).length===0)throw new nt("Provide --body, --dynamic-mapping or --bbox-tier.");let a=await new g(f()).schema.update(e,r);p()?D(a):(E("Extraction schema updated."),w(a))}),t.command("data <deploymentId>").description("Get all data for an extraction schema").action(async e=>{let i=await new g(f()).schema.getAllData(e);p()?D(i):w(i)})}var Gr=I(require("fs"));function Kr(s){let t=s.command("benchmarks").description("Benchmark management");t.command("run <extractionSchemaId>").description("Run a benchmark").requiredOption("--name <name>","Benchmark name").option("--description <desc>","Benchmark description").option("--file-ids <ids>","Comma-separated file IDs").option("--config-file <file>","JSON file with benchmark configuration").action(async(e,n)=>{let i=new g(f()),r={name:n.name};if(n.description&&(r.description=n.description),n.fileIds&&(r.fileIds=n.fileIds.split(",")),n.configFile){let a=Gr.readFileSync(n.configFile,"utf-8"),u=JSON.parse(a);r={...r,...u}}let o=await i.http.post(`/benchmark/${e}/run-benchmark`,r);p()?D(o):(E("Benchmark started."),w(o))}),t.command("files <extractionSchemaId>").description("List files available for benchmarking").action(async e=>{let i=await new g(f()).http.get(`/benchmark/${e}/list-files`),r=Array.isArray(i)?i:i.data||i;p()?D(i):v(r)}),t.command("results <extractionSchemaId>").description("Get benchmark results").requiredOption("--execution-id <id>","Execution ID").action(async(e,n)=>{let r=await new g(f()).http.get(`/benchmark/${e}/get-results`,{executionId:n.executionId});p()?D(r):w(r)}),t.command("status <executionId>").description("Get benchmark execution status").action(async e=>{let i=await new g(f()).http.get(`/benchmarks/${e}`);p()?D(i):w(i)}),t.command("metrics <executionId>").description("Get benchmark execution metrics").action(async e=>{let i=await new g(f()).http.get(`/benchmarks/${e}/metrics`);p()?D(i):w(i)})}var mt=I(require("fs")),de=I(require("path")),an=require("stream"),Qr=require("stream/promises");var on=I(require("fs")),ce=I(require("path"));var vl=["JOB_CONTEXT.json",ce.join(process.env.HOME||"/home/daytona","JOB_CONTEXT.json")];function Yr(s){let t=s?[ce.resolve(s)]:vl.map(e=>ce.resolve(e));for(let e of t)if(on.existsSync(e)){let n=on.readFileSync(e,"utf-8"),i;try{i=JSON.parse(n)}catch{throw new W(`Invalid JSON in ${e}`)}return Sl(i,e),i}throw new R("JOB_CONTEXT.json not found. Searched: "+t.join(", "),{code:"JOB_CONTEXT_NOT_FOUND",exitCode:1})}function Sl(s,t){let e=[];if(s.jobId||e.push("jobId"),s.fileId||e.push("fileId"),s.fileName||e.push("fileName"),s.sourceFileUrl||e.push("sourceFileUrl"),s.deploymentId||e.push("deploymentId"),s.extractionSchemaId||e.push("extractionSchemaId"),e.length>0)throw new W(`JOB_CONTEXT.json (${t}) missing required fields: ${e.join(", ")}`);if(!s.schema||!Array.isArray(s.schema.tables)||s.schema.tables.length===0)throw new W(`JOB_CONTEXT.json (${t}) must have schema.tables with at least one table`);for(let n of s.schema.tables){if(!n.id||!n.name)throw new W("JOB_CONTEXT.json: table missing id or name");if(!Array.isArray(n.columns)||n.columns.length===0)throw new W(`JOB_CONTEXT.json: table "${n.name}" has no columns`)}}function zr(s,t){let e=[],n=[],i=[],r=0;if(!s||typeof s!="object")return{valid:!1,errors:["Submission must be a JSON object"],warnings:[],summary:{tablesFound:0,totalRows:0,tableDetails:[]}};if(!s.tables||typeof s.tables!="object")return{valid:!1,errors:['Submission must have a "tables" object'],warnings:[],summary:{tablesFound:0,totalRows:0,tableDetails:[]}};let o=new Map;for(let u of t.schema.tables)o.set(u.name,u);let a=Object.keys(s.tables);for(let u of a){let l=o.get(u);if(!l){e.push(`Table "${u}" not found in schema. Available tables: ${[...o.keys()].join(", ")}`);continue}let c=s.tables[u];if(!Array.isArray(c)){e.push(`Table "${u}": rows must be an array`);continue}let d=!l.isPrimary,m=new Set(l.columns.map(F=>F.name)),h=new Map(l.columns.map(F=>[F.name,F]));for(let F=0;F<c.length;F++){let A=c[F];xl(A,F,u,d,m,h,e,n)}i.push({name:u,rowCount:c.length,isChild:d}),r+=c.length}for(let u of t.schema.tables)a.includes(u.name)||n.push(`Schema table "${u.name}" has no data in submission`);return{valid:e.length===0,errors:e,warnings:n,summary:{tablesFound:a.length,totalRows:r,tableDetails:i}}}function xl(s,t,e,n,i,r,o,a){let u=`Table "${e}" row ${t}`;if(typeof s!="object"||s===null){o.push(`${u}: must be an object`);return}if(typeof s.index!="number"&&o.push(`${u}: missing or invalid "index" (must be a number)`),!s.cells||typeof s.cells!="object"){o.push(`${u}: missing or invalid "cells" object`);return}n&&(s.parentIndex===void 0||s.parentIndex===null)&&o.push(`${u}: child table rows must have "parentIndex"`),n&&s.parentIndex!==void 0&&typeof s.parentIndex!="number"&&o.push(`${u}: "parentIndex" must be a number`);let l=Object.keys(s.cells);if(l.length===0){o.push(`${u}: cells object is empty`);return}let c=0;for(let d of l)if(!i.has(d))a.push(`${u}: unknown column "${d}" (will be skipped by API)`);else{c++;let m=r.get(d);m&&Tl(s.cells[d],d,m.type,m.isList,u,a)}c===0&&o.push(`${u}: no cell keys match any schema column`)}function Tl(s,t,e,n,i,r){if(s!=null){if(n&&!Array.isArray(s)){r.push(`${i}: column "${t}" is a LIST but value is not an array`);return}switch(e){case"NUMBER":typeof s!="number"&&typeof s!="string"&&r.push(`${i}: column "${t}" (NUMBER) has unexpected type ${typeof s}`);break;case"BOOLEAN":typeof s!="boolean"&&r.push(`${i}: column "${t}" (BOOLEAN) has unexpected type ${typeof s}`);break;case"DATE":typeof s!="string"&&r.push(`${i}: column "${t}" (DATE) should be an ISO date string`);break;case"LIST":Array.isArray(s)||r.push(`${i}: column "${t}" (LIST) should be an array`);break}}}var Xr=200;function Zr(s){let t=s.command("jobs").description("Job queue management");t.command("status <jobId>").description("Get job status").option("--wait","Poll until job completes").option("--timeout <seconds>","Timeout in seconds","300").action(async(e,n)=>{let i=new g(f());if(n.wait){let r=new Q(i.queue),o=y(`Waiting for job ${e}...`);o.start();let a;for await(let u of r.poll(e,{timeoutMs:parseInt(n.timeout)*1e3}))o.text=`Job ${e}: ${u.status} (extraction: ${u.extractionStageStatus})`,a=u;a?.status==="COMPLETED"?o.succeed(`Job ${e} completed.`):o.fail(`Job ${e}: ${a?.status}`),p()?D(a):w(a)}else{let r=await i.queue.getStatus(e);p()?D(r):w(r)}}),t.command("wait <jobId>").description("Wait for a job to complete").option("--timeout <seconds>","Timeout in seconds","300").action(async(e,n)=>{let i=new g(f()),r=new Q(i.queue),o=y(`Waiting for job ${e}...`);o.start();let a=await r.waitForCompletion(e,{timeoutMs:parseInt(n.timeout)*1e3,onStatus:u=>{o.text=`Job ${e}: ${u.status}`}});a.status==="COMPLETED"?o.succeed(`Job ${e} completed.`):o.fail(`Job ${e}: ${a.status}`),p()?D(a):w(a)}),t.command("cancel <jobId>").description("Cancel a queued job").action(async e=>{await new g(f()).queue.cancel(e),p()?D({success:!0,jobId:e}):E(`Job ${e} cancelled.`)}),t.command("update <jobId>").description("Update job status").requiredOption("--status <status>","Status: PROCESSING, COMPLETED, or FAILED").option("--error-message <msg>","Error message (required for FAILED)").option("--pages <n>","Pages processed (for COMPLETED billing)").option("--rows <n>","Rows created (for COMPLETED billing)").action(async(e,n)=>{let i=n.status.toUpperCase();if(!["PROCESSING","COMPLETED","FAILED"].includes(i))throw new W("Status must be PROCESSING, COMPLETED, or FAILED");if(i==="FAILED"&&!n.errorMessage)throw new W("--error-message is required when status is FAILED");let o=await new g(f()).queue.updateStatus(e,{status:i,errorMessage:n.errorMessage,pages:n.pages?parseInt(n.pages):void 0,rows:n.rows?parseInt(n.rows):void 0});p()?D(o):E(`Job ${e} status updated to ${i}`)}),t.command("download <url>").description("Download a file from a URL and optionally mark a job as PROCESSING").option("--job-id <id>","Job ID to mark as PROCESSING (or $LIMAI_JOB_ID)").option("--output <path>","Output file path","./source").action(async(e,n)=>{let i=new g(f()),r=n.jobId||process.env.LIMAI_JOB_ID,o=y("Downloading...");o.start();try{r&&(o.text="Marking job as PROCESSING...",await i.queue.updateStatus(r,{status:"PROCESSING"})),o.text="Downloading file...";let a=await fetch(e);if(!a.ok)throw new R(`Failed to download: HTTP ${a.status}`,{code:"DOWNLOAD_ERROR",exitCode:1});let u=de.resolve(n.output),l=de.dirname(u);if(mt.existsSync(l)||mt.mkdirSync(l,{recursive:!0}),!a.body)throw new R("Download failed: response body is empty",{code:"DOWNLOAD_ERROR",exitCode:1});let c=0,d=new an.Transform({transform(h,F,A){c+=h.byteLength,A(null,h)}});await(0,Qr.pipeline)(an.Readable.fromWeb(a.body),d,mt.createWriteStream(u)),o.succeed(`Downloaded (${$l(c)})`);let m={file:u,bytes:c};r&&(m.jobId=r,m.status="PROCESSING"),p()&&D(m)}catch(a){throw o.fail("Download failed"),r&&await Bl(i,r,a),a}}),t.command("submit <file>").description("Validate and submit extraction data, then mark job complete").requiredOption("--context <path>","Path to JOB_CONTEXT.json").option("--job-id <id>","Job ID (or $LIMAI_JOB_ID)").option("--file-id <id>","File ID (or $LIMAI_FILE_ID)").option("--deployment-id <id>","Deployment ID (or $LIMAI_DEPLOYMENT_ID)").option("--batch-size <n>","Rows per API batch",String(Xr)).option("--dry-run","Validate and show plan without submitting").action(async(e,n)=>{let i=Yr(n.context),r=n.jobId||process.env.LIMAI_JOB_ID||i.jobId,o=n.fileId||process.env.LIMAI_FILE_ID||i.fileId,a=n.deploymentId||process.env.LIMAI_DEPLOYMENT_ID||i.deploymentId,u=new g(f()),l=parseInt(n.batchSize)||Xr,c=y("Loading and validating submission...");c.start();try{let d=kl(e),m=zr(d,i);if(!m.valid){c.fail("Validation failed");for(let S of m.errors)console.error(`\x1B[31m ${S}\x1B[0m`);p()&&D({error:{code:"VALIDATION_ERROR",errors:m.errors}}),process.exit(1)}if(m.warnings.length>0&&!p())for(let S of m.warnings)Y(` ${S}`);let h=new Map,F=[],A=[];for(let S of i.schema.tables)h.set(S.name,S.id),S.isPrimary?F.push(S.name):A.push(S.name);if(n.dryRun){c.succeed("Validation passed (dry run)");let S={dryRun:!0,validation:m.summary,deleteOrder:[...A,...F].filter(T=>d.tables[T]).map(T=>({table:T,tableId:h.get(T)})),createOrder:[...F,...A].filter(T=>d.tables[T]).map(T=>({table:T,tableId:h.get(T),rows:d.tables[T].length,batches:Math.ceil(d.tables[T].length/l)}))};if(p())D(S);else{B("Delete order:");for(let T of S.deleteOrder)B(` ${T.table} (${T.tableId})`);B("Create order:");for(let T of S.createOrder)B(` ${T.table}: ${T.rows} rows in ${T.batches} batch(es)`)}return}let k=Object.keys(d.tables),b=[...A,...F].filter(S=>k.includes(S));for(let S of b){let T=h.get(S);c.text=`Deleting existing rows from "${S}"...`,await u.tables.deleteRows(T,{fileId:o,deploymentId:a})}let C=0,x=new Map;for(let S of F){let T=d.tables[S];if(!T||T.length===0)continue;let zt=h.get(S),yt=new Map;x.set(S,yt);let ft=await Rl(u,zt,o,a,T,l,c,S);for(let K=0;K<T.length;K++)ft[K]&&yt.set(T[K].index,ft[K]);C+=ft.length}for(let S of A){let T=d.tables[S];if(!T||T.length===0)continue;let zt=h.get(S),yt=Ol(S,i),ft=yt?x.get(yt):void 0,K=T.map(Ot=>{let In;if(Ot.parentIndex!==void 0&&ft&&(In=ft.get(Ot.parentIndex),!In))throw new W(`Table "${S}" row ${Ot.index}: parentIndex ${Ot.parentIndex} does not match any parent row`);return{cells:Ot.cells,index:Ot.index,parentRowId:In}}),Ee=await to(u,zt,o,a,K,l,c,S);C+=Ee.length}c.text="Marking job as COMPLETED...",await u.queue.updateStatus(r,{status:"COMPLETED",pages:d.metadata?.pages,rows:C}),c.succeed(`Submitted ${C} rows across ${m.summary.tablesFound} table(s). Job COMPLETED.`);let V={status:"COMPLETED",jobId:r,tablesProcessed:m.summary.tablesFound,totalRowsCreated:C,tables:m.summary.tableDetails};p()&&D(V)}catch(d){c.fail("Submission failed");let m=d instanceof Error?d.message:String(d),h=d instanceof W?"VALIDATION_ERROR":"SUBMISSION_ERROR";p()?D({error:{code:h,message:m}}):console.error(`\x1B[31m ${m}\x1B[0m`),process.exit(1)}})}async function Rl(s,t,e,n,i,r,o,a){let u=i.map(l=>({cells:l.cells,index:l.index}));return to(s,t,e,n,u,r,o,a)}async function to(s,t,e,n,i,r,o,a){let u=Array.from({length:i.length}),l=Math.ceil(i.length/r),c=3,d=0,m=[];for(let h=0;h<i.length;h+=r)m.push({start:h,batchRows:i.slice(h,h+r)});for(let h=0;h<m.length;h+=c){let F=m.slice(h,h+c),A=await Promise.all(F.map(({batchRows:k})=>s.tables.createRows(t,{fileId:e,deploymentId:n,rows:k})));for(let k=0;k<F.length;k++){let{start:b}=F[k];A[k].rowIds.forEach((C,x)=>{u[b+x]=C})}d+=F.length,o.text=`"${a}" batch ${d}/${l} (${Math.min(d*r,i.length)}/${i.length} rows)...`}return u.filter(Boolean)}function Ol(s,t){let e=t.schema.tables.find(i=>i.name===s);return!e||e.isPrimary?void 0:t.schema.tables.find(i=>i.isPrimary)?.name}function kl(s){let t=de.resolve(s);if(!mt.existsSync(t))throw new W(`File not found: ${t}`);let e=mt.readFileSync(t,"utf-8");try{return JSON.parse(e)}catch{throw new W(`Invalid JSON in ${t}`)}}async function Bl(s,t,e){try{let n=e instanceof Error?e.message:String(e);await s.queue.updateStatus(t,{status:"FAILED",errorMessage:n.slice(0,500)})}catch{}}function $l(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}var vt=I(require("fs")),ln=I(require("path"));var Wi=I(jo());var cc={update(){},increment(){},stop(){}};function Lo(s){if(p())return cc;let t=s.format??" {bar} {percentage}% | {value}/{total} | {filename}",e=new Wi.default.SingleBar({format:t,barCompleteChar:"\u2588",barIncompleteChar:"\u2591",hideCursor:!0,clearOnComplete:!1,stopOnComplete:!0},Wi.default.Presets.shades_classic);return e.start(s.total,0),{update(n,i){e.update(n,i)},increment(n=1,i){e.increment(n,i)},stop(){e.stop()}}}function Mo(s){s.command("upload <extractionSchemaId> <path>").description("Upload a file or folder for extraction").option("--concurrency <n>","Concurrent uploads","5").option("--process","Queue files for extraction after upload").option("--wait","Wait for all extractions to complete (implies --process)").option("--output <file>","Write results to JSON file").option("--glob <pattern>","Filter files by glob pattern").action(async(t,e,n)=>{let i=f(),r=new g(i),o=ln.resolve(e),a=n.process||n.wait;vt.existsSync(o)||(console.error(`Path not found: ${o}`),process.exit(1));let u=vt.statSync(o);if(u.isFile()){let l=y(`Uploading ${ln.basename(o)}...`);l.start();let c=await r.uploadFile(t,o);if(c.isDuplicate?l.warn(`File already exists (duplicate). File ID: ${c.fileId}`):l.succeed(`Uploaded ${c.filename} (${dc(c.bytesUploaded)})`),a){let d=y("Queuing for extraction...");d.start();let m=await r.documents.processAsync(t,c.fileId);if(d.succeed(`Queued. Job ID: ${m.jobId}`),n.wait){let h=new Q(r.queue),F=y("Waiting for extraction...");F.start();let A=await h.waitForCompletion(m.jobId,{onStatus:k=>{F.text=`Extraction: ${k.status} (${k.extractionStageStatus})`}});if(A.status==="COMPLETED"){F.succeed("Extraction completed.");let k=await r.documents.getFileData(c.fileId,t);n.output?(vt.writeFileSync(n.output,JSON.stringify(k,null,2)),E(`Results written to ${n.output}`)):p()?D(k):w({fileId:c.fileId,status:"COMPLETED",tables:Object.keys(k.data?.tables??{}).length})}else F.fail(`Extraction ${A.status}`),process.exit(1)}else p()&&D({fileId:c.fileId,fileName:c.filename,jobId:m.jobId})}else p()&&D(c)}else if(u.isDirectory()){B(`Scanning ${o} for files...`);let l=await r.uploadFolder(t,o,{concurrency:parseInt(n.concurrency),process:a,globPattern:n.glob});if(l.total===0){Y("No supported files found in directory.");return}if(E(`Upload complete: ${l.uploaded} uploaded, ${l.queued} queued, ${l.failed} failed (${l.total} total)`),l.failed>0){let c=l.files.filter(d=>d.status==="failed");for(let d of c)Y(` Failed: ${d.filename} - ${d.error}`)}if(n.wait&&l.queued>0){let c=l.files.filter(h=>h.status==="queued"&&h.jobId);B(`Waiting for ${c.length} extractions to complete...`);let d=Lo({total:c.length,format:" Extracting {bar} {percentage}% | {value}/{total} files"}),m=0;await Promise.all(c.map(async h=>{await new Q(r.queue).waitForCompletion(h.jobId),m++,d.update(m)})),d.stop(),E("All extractions completed.")}n.output?(vt.writeFileSync(n.output,JSON.stringify(l,null,2)),E(`Results written to ${n.output}`)):p()&&D(l)}})}function dc(s){return s<1024?`${s}B`:s<1024*1024?`${(s/1024).toFixed(1)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}var Uo=I(require("fs"));function Wo(s){s.command("download <tableId>").description("Download extracted data from a table").option("--output <file>","Output file path (streams NDJSON to file)").option("--limit <n>","Max rows to download").option("--all","Download all rows (auto-paginate)").option("--page-size <n>","Rows per API call","100").option("--order <order>","Sort order (asc|desc)","desc").option("--status <status>","Filter by row status").action(async(t,e)=>{let n=new g(f()),i=y("Fetching extraction data...");i.start();let r=e.limit?parseInt(e.limit):e.all?void 0:100;if(e.output){let o=Uo.createWriteStream(e.output),a=0,u=0;for await(let l of n.downloadAll(t,{pageSize:parseInt(e.pageSize),maxItems:r,order:e.order,status:e.status})){for(let c of l)o.write(JSON.stringify(c)+`
52
52
  `);a+=l.length,u++,i.text=`Streamed ${a} rows (${u} pages)...`}await new Promise((l,c)=>{o.end(()=>l()),o.on("error",c)}),i.succeed(`Downloaded ${a} rows.`),E(`Data written to ${e.output} (NDJSON format)`)}else{let o=[],a=0;for await(let u of n.downloadAll(t,{pageSize:parseInt(e.pageSize),maxItems:r,order:e.order,status:e.status}))o.push(...u),a++,i.text=`Fetched ${o.length} rows (${a} pages)...`;i.succeed(`Downloaded ${o.length} rows.`),D(o)}})}var cn=class extends Error{constructor(t,e){super(t),this.name="ParseError",this.type=e.type,this.field=e.field,this.value=e.value,this.line=e.line}},Vo=10,pc=13,St=32;function Vi(s){}function qo(s){if(typeof s=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Vi,onError:e=Vi,onRetry:n=Vi,onComment:i}=s,r=[],o=!0,a,u="",l=0,c;function d(b){if(o&&(o=!1,b.charCodeAt(0)===239&&b.charCodeAt(1)===187&&b.charCodeAt(2)===191&&(b=b.slice(3))),r.length===0){let V=m(b);V!==""&&r.push(V);return}if(b.indexOf(`
53
53
  `)===-1&&b.indexOf("\r")===-1){r.push(b);return}r.push(b);let C=r.join("");r.length=0;let x=m(C);x!==""&&r.push(x)}function m(b){let C=0;if(b.indexOf("\r")===-1){let x=b.indexOf(`
54
54
  `,C);for(;x!==-1;){if(C===x){l>0&&t({id:a,event:c,data:u}),a=void 0,u="",l=0,c=void 0,C=x+1,x=b.indexOf(`
@@ -68,4 +68,4 @@ Conditions:`),v(m.conditions.map(h=>({id:h.id,type:h.type,entityId:h.entityId,la
68
68
  Per route`),v(a.perRoute.map(u=>({family:u.routeFamily,id:u.routeId,name:u.routeName,total:u.totalEvents,success:u.successfulEvents,failed:u.failedEvents,pending:u.pendingEvents,successRate:u.successRate}))),B(`
69
69
  Series`),v(a.series.map(u=>({bucket:u.bucket,successful:u.successful,failed:u.failed,pending:u.pending})))}),t.command("retry <projectId> <webhookId>").description("Re-enqueue failed deliveries for a webhook subscription").requiredOption("--event-id <id>",`Delivery event ID to retry (repeatable, max ${100})`,ut).action(async(e,n,i)=>{i.eventId.length>100&&dt("VALIDATION_ERROR",`Too many event IDs (${i.eventId.length}). The API accepts at most ${100} per call.`);let r=new g(f()),o=y("Retrying deliveries...");o.start();let a=await r.webhooks.retry(e,n,i.eventId);if(o.succeed(a.message),p()){D(a);return}a.retried.length>0&&(B(`
70
70
  Retried`),v(a.retried.map(u=>({eventId:u.eventId,url:u.url})))),a.skipped.length>0&&(B(`
71
- Skipped`),v(a.skipped.map(u=>({eventId:u.eventId,url:u.url,reason:u.reason}))))})}var $a=require("child_process"),Pa=I(require("os")),Na=I(require("path"));var ye="@limai.io/cli",xc=`https://registry.npmjs.org/${ye.replace("/","%2f")}/latest`,wn="0.4.1";function Tc(){let s=Na.join(Pa.homedir(),".limai","bin");return process.execPath.startsWith(s)}async function Rc(){let s=await fetch(xc);if(!s.ok)throw new Error(`npm registry responded with ${s.status}`);let t=await s.json();if(!t.version)throw new Error("npm registry response did not include a version");return t.version}function ja(s){s.command("update").description("Update the LimAI CLI to the latest version").action(async()=>{if(Tc()&&(_({code:"UPDATE",message:"This copy of the CLI is the discontinued standalone binary and can no longer be updated."}),B("Remove it and reinstall with npm:"),B(" rm -rf ~/.limai/bin"),B(` npm install -g ${ye}`),process.exit(1)),wn.endsWith("-dev")){B("Running from source \u2014 update with `git pull` in the monorepo instead.");return}let t;try{t=await Rc()}catch(n){_({code:"UPDATE",message:n instanceof Error?`Could not check for updates: ${n.message}`:"Could not check for updates"}),process.exit(1)}if(t===wn){E(`Already up to date (v${wn}).`);return}B(`Updating ${ye} v${wn} \u2192 v${t}...`);let e=(0,$a.spawnSync)("npm",["install","-g",`${ye}@latest`],{stdio:"inherit",shell:process.platform==="win32"});(e.error||e.status!==0)&&(_({code:"UPDATE",message:e.error instanceof Error?e.error.message:`npm install exited with status ${e.status}`}),B(`Run it manually: npm install -g ${ye}@latest`),process.exit(1)),E(`Updated to v${t}.`)})}var N=new bs,Oc="0.4.1";N.name("limai").description("CLI for the LimAI data extraction platform").version(Oc).option("--json","Output raw JSON (pipe-friendly)").option("--verbose","Enable debug logging").option("--token <token>","Override stored API token").option("--api-url <url>","Override stored API URL").hook("preAction",s=>{let t=s.optsWithGlobals();t.json&&Is(!0),t.verbose&&As(!0),t.token&&(process.env.LIMAI_API_TOKEN=t.token),t.apiUrl&&(process.env.LIMAI_API_URL=t.apiUrl)});tr(N);sa(N);or(N);ar(N);kr(N);Br(N);Vr(N);qr(N);Kr(N);Zr(N);Mo(N);Wo(N);zo(N);Qo(N);ta(N);aa(N);la(N);ma(N);fa(N);ya(N);ba(N);Ia(N);Aa(N);_a(N);va(N);Sa(N);Ba(N);ja(N);process.on("unhandledRejection",s=>{_s(s)});N.parse();
71
+ Skipped`),v(a.skipped.map(u=>({eventId:u.eventId,url:u.url,reason:u.reason}))))})}var $a=require("child_process"),Pa=I(require("os")),Na=I(require("path"));var ye="@limai.io/cli",xc=`https://registry.npmjs.org/${ye.replaceAll("/","%2f")}/latest`,wn="0.4.3";function Tc(){let s=Na.join(Pa.homedir(),".limai","bin");return process.execPath.startsWith(s)}async function Rc(){let s=await fetch(xc);if(!s.ok)throw new Error(`npm registry responded with ${s.status}`);let t=await s.json();if(!t.version)throw new Error("npm registry response did not include a version");return t.version}function ja(s){s.command("update").description("Update the LimAI CLI to the latest version").action(async()=>{if(Tc()&&(_({code:"UPDATE",message:"This copy of the CLI is the discontinued standalone binary and can no longer be updated."}),B("Remove it and reinstall with npm:"),B(" rm -rf ~/.limai/bin"),B(` npm install -g ${ye}`),process.exit(1)),wn.endsWith("-dev")){B("Running from source \u2014 update with `git pull` in the monorepo instead.");return}let t;try{t=await Rc()}catch(n){_({code:"UPDATE",message:n instanceof Error?`Could not check for updates: ${n.message}`:"Could not check for updates"}),process.exit(1)}if(t===wn){E(`Already up to date (v${wn}).`);return}B(`Updating ${ye} v${wn} \u2192 v${t}...`);let e=(0,$a.spawnSync)("npm",["install","-g",`${ye}@latest`],{stdio:"inherit",shell:process.platform==="win32"});(e.error||e.status!==0)&&(_({code:"UPDATE",message:e.error instanceof Error?e.error.message:`npm install exited with status ${e.status}`}),B(`Run it manually: npm install -g ${ye}@latest`),process.exit(1)),E(`Updated to v${t}.`)})}var N=new bs,Oc="0.4.3";N.name("limai").description("CLI for the LimAI data extraction platform").version(Oc).option("--json","Output raw JSON (pipe-friendly)").option("--verbose","Enable debug logging").option("--token <token>","Override stored API token").option("--api-url <url>","Override stored API URL").hook("preAction",s=>{let t=s.optsWithGlobals();t.json&&Is(!0),t.verbose&&As(!0),t.token&&(process.env.LIMAI_API_TOKEN=t.token),t.apiUrl&&(process.env.LIMAI_API_URL=t.apiUrl)});tr(N);sa(N);or(N);ar(N);kr(N);Br(N);Vr(N);qr(N);Kr(N);Zr(N);Mo(N);Wo(N);zo(N);Qo(N);ta(N);aa(N);la(N);ma(N);fa(N);ya(N);ba(N);Ia(N);Aa(N);_a(N);va(N);Sa(N);Ba(N);ja(N);process.on("unhandledRejection",s=>{_s(s)});N.parse();
package/dist/index.d.ts CHANGED
@@ -315,16 +315,75 @@ type DeploymentConfig = {
315
315
  id: string;
316
316
  modelName?: string;
317
317
  temperature?: number;
318
+ thinkingBudget?: number | null;
318
319
  instructions?: string;
320
+ writeMode?: string;
319
321
  bigTableExtraction?: string;
320
322
  useDynamicMapping?: boolean;
321
323
  bboxTier?: "OFF" | "FAST" | "BALANCED" | "PRO";
324
+ parsePdf?: boolean;
325
+ markdownConversionType?: "BASIC" | "PRO";
326
+ excelConversionMode?: "MARKDOWN_ONLY" | "PDF_ONLY" | "MARKDOWN_AND_PDF";
327
+ docxConversionMode?: "MARKDOWN_ONLY" | "PDF_ONLY" | "MARKDOWN_AND_PDF";
322
328
  enableConfidenceScore?: boolean;
323
329
  enableLLMConfidence?: boolean;
324
330
  enableLayoutConfidence?: boolean;
325
- maxPagesToProcess?: number;
331
+ llmConfidencePrompt?: string | null;
332
+ confidenceHighThreshold?: number;
333
+ extractionRunsCount?: number;
334
+ maxPagesToProcess?: number | null;
335
+ enableFilenameInExtraction?: boolean;
326
336
  useExamples?: boolean;
327
337
  numberOfExamples?: number;
338
+ includeExampleDiff?: boolean;
339
+ exampleMatchingThreshold?: number;
340
+ disableExampleThreshold?: boolean;
341
+ setAllCorrectionsAsExamples?: boolean;
342
+ updatedAt?: string;
343
+ };
344
+ type DeploymentConfigurationColumn = {
345
+ id: string;
346
+ name: string;
347
+ slug: string | null;
348
+ type: string;
349
+ index: number;
350
+ description: string | null;
351
+ defaultValue?: unknown;
352
+ defaultValueEnabled: boolean;
353
+ isKey: boolean;
354
+ isList: boolean;
355
+ measurementType: string;
356
+ dateFormat: string;
357
+ excludedFromExtraction: boolean;
358
+ autoGenerateLabels: boolean;
359
+ autoGenerateUnits: boolean;
360
+ sharedId: string | null;
361
+ labels: ColumnLabel[];
362
+ units: ColumnUnit[];
363
+ };
364
+ type DeploymentConfigurationTable = {
365
+ id: string;
366
+ name: string;
367
+ slug: string | null;
368
+ instructions: string | null;
369
+ isPrimary: boolean;
370
+ parentTableId: string | null;
371
+ wrapColumns: boolean;
372
+ columns: DeploymentConfigurationColumn[];
373
+ };
374
+ type DeploymentConfiguration = {
375
+ deployment: {
376
+ id: string;
377
+ name: string;
378
+ status: DeploymentStatus;
379
+ type: DeploymentType;
380
+ };
381
+ extractionSchema: DeploymentConfig;
382
+ tables: DeploymentConfigurationTable[];
383
+ sharedColumnIds: Array<{
384
+ id: string;
385
+ name: string;
386
+ }>;
328
387
  };
329
388
  type FileStatus = "UPLOADING" | "PARSING" | "UPLOADED" | "FAILED";
330
389
  type Document = {
@@ -426,18 +485,6 @@ type Table = {
426
485
  parentTableId?: string;
427
486
  columns: Column[];
428
487
  };
429
- type ExtractionSchema = {
430
- id: string;
431
- projectId: string;
432
- deploymentId: string;
433
- modelName?: string;
434
- instructions?: string;
435
- temperature?: number;
436
- bigTableExtraction?: string;
437
- useDynamicMapping?: boolean;
438
- bboxTier?: "OFF" | "FAST" | "BALANCED" | "PRO";
439
- enableConfidenceScore?: boolean;
440
- };
441
488
  type JobContextColumn = {
442
489
  id: string;
443
490
  name: string;
@@ -976,9 +1023,9 @@ declare class SplitResource {
976
1023
  declare class SchemaResource {
977
1024
  private http;
978
1025
  constructor(http: HttpClient);
979
- get(extractionSchemaId: string): Promise<ExtractionSchema>;
980
- update(extractionSchemaId: string, body: Partial<DeploymentConfig>): Promise<DeploymentConfig>;
981
- getAllData(extractionSchemaId: string): Promise<unknown>;
1026
+ get(deploymentId: string): Promise<DeploymentConfiguration>;
1027
+ update(deploymentId: string, body: Partial<DeploymentConfig>): Promise<DeploymentConfig>;
1028
+ getAllData(deploymentId: string): Promise<unknown>;
982
1029
  }
983
1030
 
984
1031
  declare class BucketsResource {
@@ -1650,4 +1697,4 @@ declare class UploadError extends LimaiError {
1650
1697
  }
1651
1698
  declare function mapHttpError(status: number, message: string, details?: unknown): LimaiError;
1652
1699
 
1653
- export { type Agent, type AgentDeploymentRoute, type AgentDetail, type AgentFile, type AgentIntegrationConfig, type AgentRole, type AgentRowData, type AgentRun, type AgentRunConversation, type AgentRunDetail, type AgentRunInferenceLog, type AgentRunInferenceLogSummary, type AgentRunInferenceLogs, type AgentRunStatus, type AgentSkill, type AgentSkillLinkedFile, type AgentStatus, type AgentStep, type AgentStepType, type AgentSubmission, type AgentTriggerType, AuthError, type Bucket, type BucketFile, type BulkFileResult, type BulkFlatDocumentDataResponse, type BulkGetFilesDataResponse, type BulkProcessResponse, type BulkProcessResult, type BulkUploadFileStatus, type BulkUploadResult, type CellBoundingBox, type CellConfidence, type CellValidation, type CellValue, type ClassificationAsyncResponse, type ClassificationResult, type ClassificationStatus, type Column, type ColumnInput, type ColumnLabel, type ColumnUnit, type ColumnUpdateInput, ConflictError, type CreateRowInput, type CreateRowsRequest, type CreateRowsResponse, type DeleteRowsRequest, type DeleteRowsResponse, type Deployment, type DeploymentConfig, type DeploymentStatus, type DeploymentType, type Document, type ExtractionRow, type ExtractionSchema, type ExtractionsResponse, type FileData, type FileStatus, type FileValidationCheck, type FileValidations, type FlatCellData, type FlatCellValidation, type FlatDocumentDataResponse, type FlatDocumentEntry, type FlatFileValidations, type FlatRow, ForbiddenError, type GetUrlResponse, HttpClient, type IncludeOption, type JobContext, type JobContextColumn, type JobContextTable, JobPoller, type JobStatus, type JobStatusValue, LimaiClient, type LimaiClientConfig, type LimaiConfig, LimaiError, NotFoundError, type OffsetPaginatedResponse, type OffsetPagination, type PagePaginatedResponse, type PagePagination, type PaginationOptions, type PollOptions, type ProcessFileAsyncResponse, type ProcessOptions, type Project, RateLimitError, type Row, SSEClient, ServerError, type SplitAsyncResponse, type SplitResult, type SplitSegment, type SplitStatus, type StageStatus, type Table, type TableData, TimeoutError, type UpdateStatusRequest, type UpdateStatusResponse, UploadError, type UploadResult, ValidationError, type ValidationResult, collectAll, getDeploymentId, getFileId, getJobId, loadConfig, loadJobContext, mapHttpError, paginateOffset, paginatePage, requireConfig, saveConfig, validateSubmission };
1700
+ export { type Agent, type AgentDeploymentRoute, type AgentDetail, type AgentFile, type AgentIntegrationConfig, type AgentRole, type AgentRowData, type AgentRun, type AgentRunConversation, type AgentRunDetail, type AgentRunInferenceLog, type AgentRunInferenceLogSummary, type AgentRunInferenceLogs, type AgentRunStatus, type AgentSkill, type AgentSkillLinkedFile, type AgentStatus, type AgentStep, type AgentStepType, type AgentSubmission, type AgentTriggerType, AuthError, type Bucket, type BucketFile, type BulkFileResult, type BulkFlatDocumentDataResponse, type BulkGetFilesDataResponse, type BulkProcessResponse, type BulkProcessResult, type BulkUploadFileStatus, type BulkUploadResult, type CellBoundingBox, type CellConfidence, type CellValidation, type CellValue, type ClassificationAsyncResponse, type ClassificationResult, type ClassificationStatus, type Column, type ColumnInput, type ColumnLabel, type ColumnUnit, type ColumnUpdateInput, ConflictError, type CreateRowInput, type CreateRowsRequest, type CreateRowsResponse, type DeleteRowsRequest, type DeleteRowsResponse, type Deployment, type DeploymentConfig, type DeploymentConfiguration, type DeploymentConfigurationColumn, type DeploymentConfigurationTable, type DeploymentStatus, type DeploymentType, type Document, type ExtractionRow, type ExtractionsResponse, type FileData, type FileStatus, type FileValidationCheck, type FileValidations, type FlatCellData, type FlatCellValidation, type FlatDocumentDataResponse, type FlatDocumentEntry, type FlatFileValidations, type FlatRow, ForbiddenError, type GetUrlResponse, HttpClient, type IncludeOption, type JobContext, type JobContextColumn, type JobContextTable, JobPoller, type JobStatus, type JobStatusValue, LimaiClient, type LimaiClientConfig, type LimaiConfig, LimaiError, NotFoundError, type OffsetPaginatedResponse, type OffsetPagination, type PagePaginatedResponse, type PagePagination, type PaginationOptions, type PollOptions, type ProcessFileAsyncResponse, type ProcessOptions, type Project, RateLimitError, type Row, SSEClient, ServerError, type SplitAsyncResponse, type SplitResult, type SplitSegment, type SplitStatus, type StageStatus, type Table, type TableData, TimeoutError, type UpdateStatusRequest, type UpdateStatusResponse, UploadError, type UploadResult, ValidationError, type ValidationResult, collectAll, getDeploymentId, getFileId, getJobId, loadConfig, loadJobContext, mapHttpError, paginateOffset, paginatePage, requireConfig, saveConfig, validateSubmission };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var _e=Object.create;var ot=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var We=(n,t)=>{for(var e in t)ot(n,e,{get:t[e],enumerable:!0})},ne=(n,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ne(t))!Fe.call(n,r)&&r!==e&&ot(n,r,{get:()=>t[r],enumerable:!(s=Le(t,r))||s.enumerable});return n};var P=(n,t,e)=>(e=n!=null?_e(Me(n)):{},ne(t||!n||!n.__esModule?ot(e,"default",{value:n,enumerable:!0}):e,n)),Be=n=>ne(ot({},"__esModule",{value:!0}),n);var us={};We(us,{AuthError:()=>at,ConflictError:()=>pt,ForbiddenError:()=>ct,HttpClient:()=>F,JobPoller:()=>G,LimaiClient:()=>Ot,LimaiError:()=>R,NotFoundError:()=>lt,RateLimitError:()=>ut,SSEClient:()=>Mt,ServerError:()=>dt,TimeoutError:()=>j,UploadError:()=>k,ValidationError:()=>$,collectAll:()=>Rt,getDeploymentId:()=>ke,getFileId:()=>Ae,getJobId:()=>$e,loadConfig:()=>Vt,loadJobContext:()=>it,mapHttpError:()=>Wt,paginateOffset:()=>le,paginatePage:()=>bt,requireConfig:()=>we,saveConfig:()=>Ce,validateSubmission:()=>De});module.exports=Be(us);var oe=require("fs"),ae=require("fs/promises"),ce=require("stream");var R=class extends Error{code;statusCode;exitCode;details;constructor(t,e){super(t),this.name="LimaiError",this.code=e.code,this.statusCode=e.statusCode,this.exitCode=e.exitCode??1,this.details=e.details}},at=class extends R{constructor(t,e){super(t,{code:"AUTH_ERROR",statusCode:401,exitCode:2,details:e}),this.name="AuthError"}},ct=class extends R{constructor(t,e){super(t,{code:"FORBIDDEN",statusCode:403,exitCode:2,details:e}),this.name="ForbiddenError"}},lt=class extends R{constructor(t,e){super(t,{code:"NOT_FOUND",statusCode:404,exitCode:3,details:e}),this.name="NotFoundError"}},$=class extends R{constructor(t,e){super(t,{code:"VALIDATION_ERROR",statusCode:400,exitCode:4,details:e}),this.name="ValidationError"}},pt=class extends R{constructor(t,e){super(t,{code:"CONFLICT",statusCode:409,exitCode:4,details:e}),this.name="ConflictError"}},ut=class extends R{retryAfterMs;constructor(t,e){super(t,{code:"RATE_LIMITED",statusCode:429,exitCode:5}),this.name="RateLimitError",this.retryAfterMs=e}},dt=class extends R{constructor(t,e=500,s){super(t,{code:"SERVER_ERROR",statusCode:e,exitCode:6,details:s}),this.name="ServerError"}},j=class extends R{constructor(t){super(t,{code:"TIMEOUT",exitCode:7}),this.name="TimeoutError"}},k=class extends R{constructor(t,e){super(t,{code:"UPLOAD_ERROR",exitCode:8,details:e}),this.name="UploadError"}};function Wt(n,t,e){switch(n){case 400:return new $(t,e);case 401:return new at(t,e);case 403:return new ct(t,e);case 404:return new lt(t,e);case 409:return new pt(t,e);case 429:return new ut(t);default:return n>=500?new dt(t,n,e):new R(t,{code:"HTTP_ERROR",statusCode:n,details:e})}}var He=3e4,Bt=3,re=1e3,ie=2;function Ge(){return process.env.LIMAI_DEBUG==="1"}function Q(...n){Ge()&&console.error("[limai:http]",...n)}var F=class{baseUrl;token;constructor(t){this.baseUrl=t.apiUrl.replace(/\/$/,""),this.token=t.token}buildUrl(t,e){let s=new URL(`/api/v1${t}`,this.baseUrl);if(e)for(let[r,i]of Object.entries(e))i!=null&&s.searchParams.set(r,i);return s.toString()}authHeaders(){let t={Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},e=process.env.VERCEL_BYPASS;return e&&(t["x-vercel-protection-bypass"]=e),t}async parseErrorBody(t){try{let e=await t.json();return{message:typeof e.error=="string"?e.error:typeof e.message=="string"?e.message:`HTTP ${t.status}`,details:e.details}}catch{return{message:await t.text().catch(()=>"")||`HTTP ${t.status}`}}}shouldRetry(t){return t===429||t>=500}getRetryDelay(t,e){let s=t.headers.get("Retry-After");if(s){let r=parseInt(s,10);if(!isNaN(r))return r*1e3}return re*Math.pow(ie,e)}async request(t,e,s={}){let r=this.buildUrl(e,s.params),i=s.timeoutMs??He;for(let a=0;a<=Bt;a++){let p=new AbortController,u=setTimeout(()=>p.abort(),i);s.signal&&s.signal.addEventListener("abort",()=>p.abort());try{Q(`${t} ${r}${a>0?` (retry ${a})`:""}`);let c=await fetch(r,{method:t,headers:this.authHeaders(),body:s.body?JSON.stringify(s.body):void 0,signal:p.signal});if(clearTimeout(u),c.ok){let m=await c.text();return m?JSON.parse(m):{}}if(s.retry!==!1&&this.shouldRetry(c.status)&&a<Bt){let m=this.getRetryDelay(c,a);Q(`Retrying in ${m}ms (status ${c.status})`),await new Promise(E=>setTimeout(E,m));continue}let{message:g,details:y}=await this.parseErrorBody(c);throw Wt(c.status,g,y)}catch(c){if(clearTimeout(u),c instanceof R)throw c;if(c instanceof DOMException&&c.name==="AbortError"){if(s.retry!==!1&&a<Bt){let g=re*Math.pow(ie,a);Q(`Timeout, retrying in ${g}ms`),await new Promise(y=>setTimeout(y,g));continue}throw new j(`Request timed out after ${i}ms: ${t} ${e}`)}throw new R(c instanceof Error?c.message:"Unknown network error",{code:"NETWORK_ERROR",exitCode:1})}}throw new R("Max retries exceeded",{code:"MAX_RETRIES",exitCode:1})}async get(t,e,s){return this.request("GET",t,{params:e,timeoutMs:s})}async post(t,e,s,r){return this.request("POST",t,{body:e,timeoutMs:s,retry:r?.retry})}async patch(t,e,s){return this.request("PATCH",t,{body:e,retry:s?.retry})}async del(t,e){return this.request("DELETE",t,{body:e})}async putRaw(t,e,s,r){let i=e instanceof Blob?e.size:e.length;Q(`PUT ${t} (${i} bytes)`);let a=await fetch(t,{method:"PUT",headers:{"Content-Type":s},body:e});if(r&&r(i,i),!a.ok)throw new k(`Upload failed: HTTP ${a.status}`)}async putFile(t,e,s,r){let i=(await(0,ae.stat)(e)).size;Q(`PUT ${t} (${i} bytes, streamed from ${e})`);let a=(0,oe.createReadStream)(e),p=a;if(r){let c=0,g=new ce.Transform({transform(y,m,E){c+=y.byteLength,r(c,i),E(null,y)}});p=a.pipe(g)}let u=await fetch(t,{method:"PUT",headers:{"Content-Type":s,"Content-Length":String(i)},body:p,duplex:"half"});if(r&&r(i,i),!u.ok)throw new k(`Upload failed: HTTP ${u.status}`);return i}};var gt=class{constructor(t){this.http=t}http;async getUploadUrl(t,e,s){let r={filename:e,contentHash:s};return this.http.get(`/document/${t}/get-url`,r)}async processSync(t,e,s){return this.http.post(`/document/${t}/process-file/${e}`,s,18e4)}async processAsync(t,e,s){return this.http.post(`/document/${t}/process-file-async/${e}`,s)}async processFilesAsync(t,e,s){return this.http.post(`/document/${t}/process-files-async`,{fileIds:e,...s})}async getFileData(t,e,s){let r={fileId:t,extractionSchemaId:e,include:s?.length?s.join(","):void 0};return this.http.get("/document/get-file-data",r)}async getFilesData(t,e){return this.http.post("/document/get-files-data",{fileIds:t,...e?.length?{include:e}:{}})}async getDocumentData(t,e,s){let r={include:s?.length?s.join(","):void 0};return this.http.get(`/deployments/${t}/documents/${e}/data`,r)}async getDocumentsData(t,e,s){return this.http.post(`/deployments/${t}/documents/data`,{fileIds:e,...s?.length?{include:s}:{}})}async submitCorrections(t,e,s){return this.http.post(`/document/${t}/process-file/${e}/submit-corrections`,s)}};var mt=class{constructor(t){this.http=t}http;async list(){let t=await this.http.get("/projects");return Array.isArray(t)?t:t.data}async create(t){return this.http.post("/projects",t)}async delete(t){return this.http.del(`/projects/${t}`)}async getSharedColumnIds(t){return this.http.get(`/projects/${t}/shared-column-ids`)}async listDeployments(t){return this.http.get(`/projects/${t}/deployments`)}async listBenchmarks(t){return this.http.get(`/projects/${t}/benchmarks`)}async listNotificationRoutes(t){return this.http.get(`/projects/${t}/notifications`)}async createNotificationRoute(t,e){return this.http.post(`/projects/${t}/notifications`,e)}async updateNotificationRoute(t,e,s){return this.http.patch(`/projects/${t}/notifications/${e}`,s)}async deleteNotificationRoute(t,e){return this.http.del(`/projects/${t}/notifications/${e}`)}async listNotificationIntegrations(t,e){return this.http.get(`/projects/${t}/notifications/integrations`,{provider:e})}async listNotificationSlackChannels(t,e){return this.http.get(`/projects/${t}/notifications/integrations/slack/channels`,{connectionId:e})}async listNotificationTeamsTeams(t,e){return this.http.get(`/projects/${t}/notifications/integrations/teams/teams`,{connectionId:e})}async listNotificationTeamsChannels(t,e,s){return this.http.get(`/projects/${t}/notifications/integrations/teams/channels`,{connectionId:e,teamId:s})}};var ht=class{constructor(t){this.http=t}http;async list(t,e){let s={status:e?.status,type:e?.type},r=await this.http.get(`/projects/${t}/deployments`,s);return Array.isArray(r)?r:r.data}async create(t,e){return this.http.post(`/projects/${t}/deployments`,e)}async getConfig(t){return this.http.get(`/deployments/${t}/configuration`)}async updateConfig(t,e){await this.http.patch(`/deployment/${t}/configuration`,e)}async listDocuments(t,e){let s={limit:e?.limit?.toString(),offset:e?.offset?.toString(),status:e?.status};return this.http.get(`/deployments/${t}/documents`,s)}async getDocument(t,e){return this.http.get(`/deployments/${t}/documents/${e}`)}async deleteDocument(t,e){await this.http.del(`/deployments/${t}/documents/${e}`)}async bulkDelete(t,e){await this.http.del(`/deployments/${t}/documents/bulk-delete`,{fileIds:e})}};var ft=class{constructor(t){this.http=t}http;async get(t){return this.http.get(`/tables/${t}`)}async listColumns(t){let e=await this.http.get(`/tables/${t}/columns`);return Array.isArray(e)?e:e.data}async listRows(t,e){let s={limit:e?.limit?.toString(),offset:e?.offset?.toString(),status:e?.status};return this.http.get(`/tables/${t}/rows`,s)}async createRows(t,e){return this.http.post(`/tables/${t}/rows`,e,6e4)}async deleteRows(t,e){return this.http.del(`/tables/${t}/rows`,e)}async createTable(t,e){return this.http.post(`/deployments/${t}/tables`,e)}async update(t,e){return this.http.patch(`/tables/${t}`,e)}};var yt=class{constructor(t){this.http=t}http;async list(t){let e=await this.http.get(`/tables/${t}/columns`);return Array.isArray(e)?e:e.data}async get(t){return this.http.get(`/columns/${t}`)}async create(t,e){let s=await this.http.post(`/tables/${t}/columns`,e);return s&&typeof s=="object"&&"data"in s?s.data:[s]}async update(t,e){return this.http.patch(`/columns/${t}`,e)}};async function*le(n,t={}){let e=Math.min(t.pageSize??100,500),s=0,r=0;for(;;){let i=t.maxItems?Math.min(e,t.maxItems-r):e;if(i<=0)break;let a=await n(i,s),p=a.data;if(p.length===0||(yield p,r+=p.length,s+=p.length,s>=a.pagination.total)||t.maxItems&&r>=t.maxItems)break}}async function*bt(n,t={}){let e=Math.min(t.pageSize??100,500),s=1,r=0;for(;;){let i=t.maxItems?Math.min(e,t.maxItems-r):e;if(i<=0)break;let a=await n(s,i),p=a.data;if(p.length===0||(yield p,r+=p.length,s++,s>a.pagination.totalPages)||t.maxItems&&r>=t.maxItems)break}}async function Rt(n){let t=[];for await(let e of n)t.push(...e);return t}var Ct=class{constructor(t){this.http=t}http;async getRows(t,e){let s={page:e?.page?.toString(),limit:e?.limit?.toString(),order:e?.order,status:e?.status};return this.http.get(`/extractions/${t}`,s)}async*getAllRows(t,e){yield*bt(async(s,r)=>this.http.get(`/extractions/${t}`,{page:s.toString(),limit:r.toString(),order:e?.order,status:e?.status}),e)}async collectAllRows(t,e){return Rt(this.getAllRows(t,e))}};var wt=class{constructor(t){this.http=t}http;async getStatus(t){return this.http.get(`/queue/${t}/status`)}async cancel(t){await this.http.post("/queue/cancel",{jobId:t})}async updateStatus(t,e){return this.http.patch(`/queue/${t}/status`,e)}};var St=class{constructor(t){this.http=t}http;async list(t){return this.http.get("/classify",{projectId:t})}async getUploadUrl(t,e){return this.http.get(`/classify/${t}/get-url`,{filename:e})}async classify(t,e){return this.http.post(`/classify/${t}`,{fileId:e})}async classifyAsync(t,e){return this.http.post(`/classify/${t}/async`,{fileId:e})}async getStatus(t,e){return this.http.get(`/classify/${t}`,{classificationId:e})}async createClassifier(t){return this.http.post("/classify",t)}async createRoute(t,e){return this.http.post(`/classify/${t}/routes`,e)}};var vt=class{constructor(t){this.http=t}http;async list(t){return this.http.get("/split",{projectId:t})}async getUploadUrl(t,e){return this.http.get(`/split/${t}/get-url`,{filename:e})}async split(t,e){return this.http.post(`/split/${t}`,{fileId:e})}async splitAsync(t,e){return this.http.post(`/split/${t}/async`,{fileId:e})}async getStatus(t,e){return this.http.get(`/split/${t}`,{splitId:e})}async listSplits(t){return this.http.get(`/split/${t}/splits`)}async createSplitter(t){return this.http.post("/split",t)}};var Et=class{constructor(t){this.http=t}http;async get(t){return this.http.get(`/extraction-schema/${t}`)}async update(t,e){return this.http.patch(`/extraction-schema/${t}`,e)}async getAllData(t){return this.http.get("/extraction-schema/get-all-data",{extractionSchemaId:t})}};var It=class{constructor(t){this.http=t}http;async list(t){return this.http.get(`/projects/${t}/buckets`)}async get(t){return this.http.get(`/buckets/${t}`)}async create(t,e,s){return this.http.post(`/projects/${t}/buckets`,{name:e,description:s})}async delete(t){await this.http.del(`/buckets/${t}`)}async getUploadUrl(t,e){return this.http.get(`/buckets/${t}/get-url`,{filename:e})}async confirmUpload(t,e,s){await this.http.patch(`/buckets/${t}/files/${e}/status`,{status:"UPLOADED",...s!==void 0&&{sizeBytes:s}})}async listFiles(t,e){let s={};return e&&e.length>0&&(s.labels=e.join(",")),this.http.get(`/buckets/${t}/files`,s)}async getDownloadUrl(t,e){return this.http.get(`/buckets/${t}/files/${e}/download`)}async updateLabels(t,e,s){return this.http.patch(`/buckets/${t}/files/${e}`,{labels:s})}async deleteFile(t,e){await this.http.del(`/buckets/${t}/files/${e}`)}async sendTo(t,e,s,r){return this.http.post(`/buckets/${t}/files/${e}/send-to`,{targetType:s,targetId:r})}};var Pt=class{constructor(t){this.http=t}http;async list(t,e){let s={};return e?.status&&(s.status=e.status),this.http.get(`/projects/${t}/agents`,s)}async get(t,e){return this.http.get(`/projects/${t}/agents/${e}`)}async create(t,e){return this.http.post(`/projects/${t}/agents`,e)}async update(t,e,s){return this.http.patch(`/projects/${t}/agents/${e}`,s)}async delete(t,e){await this.http.del(`/projects/${t}/agents/${e}`)}async getFileUploadUrl(t,e,s){return this.http.get(`/projects/${t}/agents/${e}/files/get-url`,{filename:s})}async deleteFile(t,e,s){await this.http.del(`/projects/${t}/agents/${e}/files/${s}`)}async updateFileMetadata(t,e,s,r){return this.http.patch(`/projects/${t}/agents/${e}/files/${s}`,r)}async getFileDownloadUrl(t,e,s){return this.http.get(`/projects/${t}/agents/${e}/files/${s}/download`)}async listSkills(t,e){return this.http.get(`/projects/${t}/agents/${e}/skills`)}async createSkill(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/skills`,s)}async updateSkill(t,e,s,r){return this.http.patch(`/projects/${t}/agents/${e}/skills/${s}`,r)}async deleteSkill(t,e,s){await this.http.del(`/projects/${t}/agents/${e}/skills/${s}`)}async linkFileToSkill(t,e,s,r){return this.http.post(`/projects/${t}/agents/${e}/skills/${s}/files`,{fileId:r})}async unlinkFileFromSkill(t,e,s,r){await this.http.del(`/projects/${t}/agents/${e}/skills/${s}/files/${r}`)}async listRuns(t,e,s){let r={};return s?.limit&&(r.limit=String(s.limit)),s?.status&&(r.status=s.status),this.http.get(`/projects/${t}/agents/${e}/runs`,r)}async getRun(t,e,s){return this.http.get(`/projects/${t}/agents/${e}/runs/${s}`)}async getRunConversation(t,e,s,r){let i={};return r?.stepId&&(i.stepId=r.stepId),this.http.get(`/projects/${t}/agents/${e}/runs/${s}/conversation`,i)}async getRunInferenceLogs(t,e,s,r){let i={};return r?.limit!==void 0&&(i.limit=String(r.limit)),r?.status&&(i.status=r.status),this.http.get(`/projects/${t}/agents/${e}/runs/${s}/inference-logs`,i)}async createRun(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/runs`,s)}async createStep(t,e,s,r){return this.http.post(`/projects/${t}/agents/${e}/runs/${s}/steps`,r)}async createSteps(t,e,s,r){return this.http.post(`/projects/${t}/agents/${e}/runs/${s}/steps`,{steps:r})}async updateRun(t,e,s,r){return this.http.patch(`/projects/${t}/agents/${e}/runs/${s}`,r)}async updateStep(t,e,s,r,i){return this.http.patch(`/projects/${t}/agents/${e}/runs/${s}/steps/${r}`,i)}async updateStepConditions(t,e,s,r,i){return this.http.patch(`/projects/${t}/agents/${e}/runs/${s}/steps/${r}`,{conditions:i})}async pauseRun(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/runs/${s}/pause`,{})}async submitStepAction(t,e,s,r,i){return this.http.post(`/projects/${t}/agents/${e}/runs/${s}/steps/${r}/action`,i)}async sendEmail(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/send-email`,s)}async completeExecution(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/executions/complete`,s)}async getSharePointToken(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/sharepoint-token`,s)}async getArtifactUploadUrl(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/upload-artifact/get-url`,s)}};var xt=class{constructor(t){this.http=t}http;async ask(t,e){return this.http.post(`/projects/${t}/vision/ask`,e,12e4)}};var Tt=class{constructor(t){this.http=t}http;async submit(t,e,s){return this.http.post(`/document/${t}/process-file/${e}/submit-validation`,s)}async listScripts(t){return(await this.http.get(`/extraction-schema/${t}/validation-scripts`)).scripts}async getScript(t,e,s){return(await this.http.get(`/extraction-schema/${t}/validation-scripts/${encodeURIComponent(e)}`,s?.includeSource?{includeSource:"true"}:void 0)).script}async pushScript(t,e){return this.http.post(`/extraction-schema/${t}/validation-scripts`,e)}async updateScript(t,e,s){return(await this.http.patch(`/extraction-schema/${t}/validation-scripts/${encodeURIComponent(e)}`,s)).script}async deleteScript(t,e){return this.http.del(`/extraction-schema/${t}/validation-scripts/${encodeURIComponent(e)}`)}};var $t=class{constructor(t){this.http=t}http;async list(t,e){let s={};return e?.entityType&&(s.entityType=e.entityType),this.http.get(`/projects/${t}/labels`,s)}async addRemove(t,e,s,r,i){return this.http.post(`/projects/${t}/labels`,{entityType:e,entityId:s,add:r,remove:i})}async search(t,e){let s={};return e?.entityType&&(s.entityType=e.entityType),e?.labels&&(s.labels=e.labels),e?.key&&(s.key=e.key),this.http.get(`/projects/${t}/labels/search`,s)}};var At=class{constructor(t){this.http=t}http;basePath(t){return`/projects/${t}/webhooks`}async list(t){return this.http.get(this.basePath(t))}async get(t,e){return this.http.get(`${this.basePath(t)}/${e}`)}async create(t,e){return this.http.post(this.basePath(t),e,void 0,{retry:!1})}async update(t,e,s){return this.http.patch(`${this.basePath(t)}/${e}`,s,{retry:!1})}async delete(t,e){await this.http.del(`${this.basePath(t)}/${e}`)}async pause(t,e){return this.http.post(`${this.basePath(t)}/${e}/pause`)}async resume(t,e){return this.http.post(`${this.basePath(t)}/${e}/resume`)}async verify(t,e){return this.http.post(`${this.basePath(t)}/${e}/verify`,void 0,void 0,{retry:!1})}async rotateSecret(t,e){return this.http.post(`${this.basePath(t)}/${e}/rotate-secret`,void 0,void 0,{retry:!1})}async deliveries(t,e,s){let r={};return s?.status&&(r.status=s.status),s?.eventType&&(r.eventType=s.eventType),s?.deploymentId&&(r.deploymentId=s.deploymentId),s?.agentId&&(r.agentId=s.agentId),s?.classifierId&&(r.classifierId=s.classifierId),s?.splitterId&&(r.splitterId=s.splitterId),s?.limit!==void 0&&(r.limit=String(s.limit)),s?.offset!==void 0&&(r.offset=String(s.offset)),this.http.get(`${this.basePath(t)}/${e}/deliveries`,r)}async metrics(t,e,s){let r={};return s?.window&&(r.window=s.window),s?.bucket&&(r.bucket=s.bucket),this.http.get(`${this.basePath(t)}/${e}/metrics`,r)}async retry(t,e,s){return this.http.post(`${this.basePath(t)}/${e}/retry`,{eventIds:s})}};var kt=P(require("fs")),W=P(require("path"));var pe=P(require("fs")),ue=P(require("crypto"));async function de(n){return new Promise((t,e)=>{let s=ue.createHash("sha256"),r=pe.createReadStream(n);r.on("data",i=>s.update(i)),r.on("end",()=>t(s.digest("hex"))),r.on("error",e)})}var Ve={".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".tiff":"image/tiff",".tif":"image/tiff",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".xls":"application/vnd.ms-excel",".csv":"text/csv",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".doc":"application/msword"};function Je(n){let t=W.extname(n).toLowerCase();return Ve[t]||"application/octet-stream"}async function Dt(n,t,e,s,r){let i=W.resolve(s),a=W.basename(i);if(!kt.existsSync(i))throw new k(`File not found: ${i}`);if(!kt.statSync(i).isFile())throw new k(`Not a file: ${i}`);let u=await de(i),c=await t.getUploadUrl(e,a,u);if(c.isDuplicate)return{fileId:c.fileId,filename:c.fileName??a,isDuplicate:!0,bytesUploaded:0};let g=Je(i),y=await n.putFile(c.url,i,g,r);return{fileId:c.fileId,filename:c.fileName??a,isDuplicate:!1,bytesUploaded:y}}var B=P(require("fs")),H=P(require("path"));var me=P(require("path"));var ge=250,qe=5,Ht=class{constructor(t){this.max=t}max;queue=[];current=0;async acquire(){if(this.current<this.max){this.current++;return}return new Promise(t=>{this.queue.push(t)})}release(){this.current--;let t=this.queue.shift();t&&(this.current++,t())}};async function he(n,t,e,s,r){let i=Math.min(r?.concurrency??qe,10),a=new Ht(i),p=s.map(m=>({path:m,filename:me.basename(m),status:"pending"})),u=p.map(async(m,E)=>{await a.acquire();try{m.status="uploading",r?.onFileStatus?.(m);let f=await Dt(n,t,e,m.path);m.fileId=f.fileId,m.status="uploaded",r?.onFileStatus?.(m)}catch(f){m.status="failed",m.error=f instanceof Error?f.message:String(f),r?.onFileStatus?.(m)}finally{a.release()}});if(await Promise.all(u),r?.process){let E=p.filter(f=>f.status==="uploaded"&&f.fileId).map(f=>f.fileId);for(let f=0;f<E.length;f+=ge){let A=E.slice(f,f+ge);try{let T=await t.processFilesAsync(e,A,r.processOptions);for(let[l,o]of Object.entries(T.results)){let d=p.find(w=>w.fileId===l);d&&(o.status==="queued"?(d.status="queued",d.jobId=o.jobId):(d.status="failed",d.error=o.error),r?.onFileStatus?.(d))}}catch(T){for(let l of A){let o=p.find(d=>d.fileId===l);o&&(o.status="failed",o.error=T instanceof Error?T.message:String(T),r?.onFileStatus?.(o))}}}}let c=p.filter(m=>m.status==="uploaded"||m.status==="queued").length,g=p.filter(m=>m.status==="queued").length,y=p.filter(m=>m.status==="failed").length;return{total:s.length,uploaded:c,queued:g,failed:y,files:p}}var Ke=new Set([".pdf",".png",".jpg",".jpeg",".tiff",".tif",".xlsx",".xls",".csv",".docx",".doc"]);function fe(n,t){let e=[],s=B.readdirSync(n,{withFileTypes:!0});for(let r of s){let i=H.join(n,r.name);if(!r.name.startsWith(".")){if(r.isDirectory())e.push(...fe(i,t));else if(r.isFile()){let a=H.extname(r.name).toLowerCase();if(!Ke.has(a)||t&&!ze(r.name,t))continue;e.push(i)}}}return e.sort()}function ze(n,t){let e=t.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${e}$`,"i").test(n)}async function ye(n,t,e,s,r){let i=H.resolve(s);if(!B.existsSync(i))throw new Error(`Directory not found: ${i}`);if(!B.statSync(i).isDirectory())throw new Error(`Not a directory: ${i}`);let p=fe(i,r?.globPattern);return p.length===0?{total:0,uploaded:0,queued:0,failed:0,files:[]}:he(n,t,e,p,{concurrency:r?.concurrency,process:r?.process,processOptions:r?.processOptions,onFileStatus:r?.onFileStatus})}var Xe=1e3,Ye=1e4,Qe=1.5,Ze=3e5,ts=["COMPLETED","FAILED","STALLED"],G=class{constructor(t){this.queue=t}queue;async*poll(t,e){let s=e?.intervalMs??Xe,r=e?.maxIntervalMs??Ye,i=e?.backoffMultiplier??Qe,a=e?.timeoutMs??Ze,p=s,u=Date.now(),c;for(;;){if(Date.now()-u>a)throw new j(`Polling timed out after ${Math.round(a/1e3)}s for job ${t}`);let g=await this.queue.getStatus(t);if(g.status!==c&&(c=g.status,e?.onStatus?.(g),yield g),ts.includes(g.status))return;await new Promise(y=>setTimeout(y,p)),p=Math.min(p*i,r)}}async waitForCompletion(t,e){let s;for await(let r of this.poll(t,e))s=r;if(!s)throw new Error(`No status received for job ${t}`);return s}};var Ot=class{http;documents;projects;deployments;tables;columns;extractions;queue;classify;split;schema;buckets;agents;vision;validations;labels;webhooks;constructor(t){this.http=new F({apiUrl:t.apiUrl,token:t.token}),this.documents=new gt(this.http),this.projects=new mt(this.http),this.deployments=new ht(this.http),this.tables=new ft(this.http),this.columns=new yt(this.http),this.extractions=new Ct(this.http),this.queue=new wt(this.http),this.classify=new St(this.http),this.split=new vt(this.http),this.schema=new Et(this.http),this.buckets=new It(this.http),this.agents=new Pt(this.http),this.vision=new xt(this.http),this.validations=new Tt(this.http),this.labels=new $t(this.http),this.webhooks=new At(this.http)}async uploadFile(t,e,s){return Dt(this.http,this.documents,t,e,s)}async uploadFolder(t,e,s){return ye(this.http,this.documents,t,e,s)}async processAndWait(t,e,s){let r=await this.documents.processAsync(t,e,s?.processOptions),i=new G(this.queue),a;for await(let p of i.poll(r.jobId,s?.pollOptions))a=p;if(!a||a.status==="FAILED")throw new Error(`Extraction failed for file ${e}${a?`: ${a.status}`:""}`);return this.documents.getFileData(e,t)}async*downloadAll(t,e){yield*this.extractions.getAllRows(t,e)}};var v=P(require("fs")),J=P(require("path")),be=P(require("os")),Ut=require("child_process"),Gt=J.join(be.homedir(),".limai"),Z=J.join(Gt,"config.json"),es=".limai.token",V;function ss(n){if(!v.existsSync(n))return{};let t={};for(let e of v.readFileSync(n,"utf-8").split(/\r?\n/)){let s=e.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)\s*$/);s&&(t[s[1]]=s[2].replace(/^(["'])(.*)\1$/,"$2"))}return t}function Re(){if(V!==void 0)return V;try{let n=(0,Ut.execSync)("git rev-parse --show-toplevel",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(!v.existsSync(J.join(n,"packages","cli")))return V=null,null;let t=(0,Ut.execSync)("git rev-parse --git-common-dir",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim(),e="";if(t!==".git"){let r=(0,Ut.execSync)("git rev-parse --abbrev-ref HEAD",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(r){let i=r.replace(/[/\\]/g,"-").replace(/[^a-zA-Z0-9._-]/g,"").replace(/^-+|-+$/g,"");i&&(e=`${i}.`)}}let s=ss(J.join(n,"tables",".env.local"));return V={root:n,apiUrl:s.NEXT_PUBLIC_BASE_URL??`https://${e}tables.localhost`,sseUrl:s.NEXT_PUBLIC_SSE_URL??`https://${e}ws.localhost`},V}catch{return V=null,null}}function ns(){let n=Re();if(!n)return;let t=J.join(n.root,es);if(v.existsSync(t))return v.readFileSync(t,"utf-8").trim()}function Vt(){let n=process.env.LIMAI_API_TOKEN,t=process.env.LIMAI_API_URL,e=process.env.LIMAI_SSE_URL,s={};if(v.existsSync(Z))try{let u=v.readFileSync(Z,"utf-8"),c=JSON.parse(u);c&&typeof c=="object"&&!Array.isArray(c)&&(s=c)}catch{s={}}let r=Re(),i=n||ns()||s.token,a=t||s.apiUrl||r?.apiUrl||process.env.LIMAI_BUILD_URL||void 0,p=e||s.sseUrl||r?.sseUrl||void 0;return!i||!a?null:{token:i,apiUrl:a,sseUrl:p,defaultProjectId:s.defaultProjectId,defaultDeploymentId:s.defaultDeploymentId}}function Ce(n){let t={};if(v.existsSync(Z))try{let s=v.readFileSync(Z,"utf-8");t=JSON.parse(s)}catch{t={}}let e={...t,...n};v.existsSync(Gt)||v.mkdirSync(Gt,{recursive:!0,mode:448}),v.writeFileSync(Z,JSON.stringify(e,null,2),{mode:384})}function we(){let n=Vt();return n||(console.error("Not authenticated. Run `npm run cli:setup` or set LIMAI_API_TOKEN environment variable."),process.exit(1)),n}var jt=class extends Error{constructor(t,e){super(t),this.name="ParseError",this.type=e.type,this.field=e.field,this.value=e.value,this.line=e.line}},Se=10,rs=13,_=32;function Jt(n){}function Ie(n){if(typeof n=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Jt,onError:e=Jt,onRetry:s=Jt,onComment:r}=n,i=[],a=!0,p,u="",c=0,g;function y(l){if(a&&(a=!1,l.charCodeAt(0)===239&&l.charCodeAt(1)===187&&l.charCodeAt(2)===191&&(l=l.slice(3))),i.length===0){let w=m(l);w!==""&&i.push(w);return}if(l.indexOf(`
1
+ "use strict";var _e=Object.create;var ot=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var We=(n,t)=>{for(var e in t)ot(n,e,{get:t[e],enumerable:!0})},ne=(n,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ne(t))!Fe.call(n,r)&&r!==e&&ot(n,r,{get:()=>t[r],enumerable:!(s=Le(t,r))||s.enumerable});return n};var P=(n,t,e)=>(e=n!=null?_e(Me(n)):{},ne(t||!n||!n.__esModule?ot(e,"default",{value:n,enumerable:!0}):e,n)),Be=n=>ne(ot({},"__esModule",{value:!0}),n);var us={};We(us,{AuthError:()=>at,ConflictError:()=>pt,ForbiddenError:()=>ct,HttpClient:()=>F,JobPoller:()=>G,LimaiClient:()=>Ot,LimaiError:()=>R,NotFoundError:()=>lt,RateLimitError:()=>ut,SSEClient:()=>Mt,ServerError:()=>dt,TimeoutError:()=>j,UploadError:()=>k,ValidationError:()=>x,collectAll:()=>Rt,getDeploymentId:()=>ke,getFileId:()=>Ae,getJobId:()=>xe,loadConfig:()=>Vt,loadJobContext:()=>it,mapHttpError:()=>Wt,paginateOffset:()=>le,paginatePage:()=>bt,requireConfig:()=>we,saveConfig:()=>Ce,validateSubmission:()=>De});module.exports=Be(us);var oe=require("fs"),ae=require("fs/promises"),ce=require("stream");var R=class extends Error{code;statusCode;exitCode;details;constructor(t,e){super(t),this.name="LimaiError",this.code=e.code,this.statusCode=e.statusCode,this.exitCode=e.exitCode??1,this.details=e.details}},at=class extends R{constructor(t,e){super(t,{code:"AUTH_ERROR",statusCode:401,exitCode:2,details:e}),this.name="AuthError"}},ct=class extends R{constructor(t,e){super(t,{code:"FORBIDDEN",statusCode:403,exitCode:2,details:e}),this.name="ForbiddenError"}},lt=class extends R{constructor(t,e){super(t,{code:"NOT_FOUND",statusCode:404,exitCode:3,details:e}),this.name="NotFoundError"}},x=class extends R{constructor(t,e){super(t,{code:"VALIDATION_ERROR",statusCode:400,exitCode:4,details:e}),this.name="ValidationError"}},pt=class extends R{constructor(t,e){super(t,{code:"CONFLICT",statusCode:409,exitCode:4,details:e}),this.name="ConflictError"}},ut=class extends R{retryAfterMs;constructor(t,e){super(t,{code:"RATE_LIMITED",statusCode:429,exitCode:5}),this.name="RateLimitError",this.retryAfterMs=e}},dt=class extends R{constructor(t,e=500,s){super(t,{code:"SERVER_ERROR",statusCode:e,exitCode:6,details:s}),this.name="ServerError"}},j=class extends R{constructor(t){super(t,{code:"TIMEOUT",exitCode:7}),this.name="TimeoutError"}},k=class extends R{constructor(t,e){super(t,{code:"UPLOAD_ERROR",exitCode:8,details:e}),this.name="UploadError"}};function Wt(n,t,e){switch(n){case 400:return new x(t,e);case 401:return new at(t,e);case 403:return new ct(t,e);case 404:return new lt(t,e);case 409:return new pt(t,e);case 429:return new ut(t);default:return n>=500?new dt(t,n,e):new R(t,{code:"HTTP_ERROR",statusCode:n,details:e})}}var He=3e4,Bt=3,re=1e3,ie=2;function Ge(){return process.env.LIMAI_DEBUG==="1"}function Q(...n){Ge()&&console.error("[limai:http]",...n)}var F=class{baseUrl;token;constructor(t){this.baseUrl=t.apiUrl.replace(/\/$/,""),this.token=t.token}buildUrl(t,e){let s=new URL(`/api/v1${t}`,this.baseUrl);if(e)for(let[r,i]of Object.entries(e))i!=null&&s.searchParams.set(r,i);return s.toString()}authHeaders(){let t={Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},e=process.env.VERCEL_BYPASS;return e&&(t["x-vercel-protection-bypass"]=e),t}async parseErrorBody(t){try{let e=await t.json();return{message:typeof e.error=="string"?e.error:typeof e.message=="string"?e.message:`HTTP ${t.status}`,details:e.details}}catch{return{message:await t.text().catch(()=>"")||`HTTP ${t.status}`}}}shouldRetry(t){return t===429||t>=500}getRetryDelay(t,e){let s=t.headers.get("Retry-After");if(s){let r=parseInt(s,10);if(!isNaN(r))return r*1e3}return re*Math.pow(ie,e)}async request(t,e,s={}){let r=this.buildUrl(e,s.params),i=s.timeoutMs??He;for(let a=0;a<=Bt;a++){let p=new AbortController,u=setTimeout(()=>p.abort(),i);s.signal&&s.signal.addEventListener("abort",()=>p.abort());try{Q(`${t} ${r}${a>0?` (retry ${a})`:""}`);let c=await fetch(r,{method:t,headers:this.authHeaders(),body:s.body?JSON.stringify(s.body):void 0,signal:p.signal});if(clearTimeout(u),c.ok){let m=await c.text();return m?JSON.parse(m):{}}if(s.retry!==!1&&this.shouldRetry(c.status)&&a<Bt){let m=this.getRetryDelay(c,a);Q(`Retrying in ${m}ms (status ${c.status})`),await new Promise(E=>setTimeout(E,m));continue}let{message:g,details:y}=await this.parseErrorBody(c);throw Wt(c.status,g,y)}catch(c){if(clearTimeout(u),c instanceof R)throw c;if(c instanceof DOMException&&c.name==="AbortError"){if(s.retry!==!1&&a<Bt){let g=re*Math.pow(ie,a);Q(`Timeout, retrying in ${g}ms`),await new Promise(y=>setTimeout(y,g));continue}throw new j(`Request timed out after ${i}ms: ${t} ${e}`)}throw new R(c instanceof Error?c.message:"Unknown network error",{code:"NETWORK_ERROR",exitCode:1})}}throw new R("Max retries exceeded",{code:"MAX_RETRIES",exitCode:1})}async get(t,e,s){return this.request("GET",t,{params:e,timeoutMs:s})}async post(t,e,s,r){return this.request("POST",t,{body:e,timeoutMs:s,retry:r?.retry})}async patch(t,e,s){return this.request("PATCH",t,{body:e,retry:s?.retry})}async del(t,e){return this.request("DELETE",t,{body:e})}async putRaw(t,e,s,r){let i=e instanceof Blob?e.size:e.length;Q(`PUT ${t} (${i} bytes)`);let a=await fetch(t,{method:"PUT",headers:{"Content-Type":s},body:e});if(r&&r(i,i),!a.ok)throw new k(`Upload failed: HTTP ${a.status}`)}async putFile(t,e,s,r){let i=(await(0,ae.stat)(e)).size;Q(`PUT ${t} (${i} bytes, streamed from ${e})`);let a=(0,oe.createReadStream)(e),p=a;if(r){let c=0,g=new ce.Transform({transform(y,m,E){c+=y.byteLength,r(c,i),E(null,y)}});p=a.pipe(g)}let u=await fetch(t,{method:"PUT",headers:{"Content-Type":s,"Content-Length":String(i)},body:p,duplex:"half"});if(r&&r(i,i),!u.ok)throw new k(`Upload failed: HTTP ${u.status}`);return i}};var gt=class{constructor(t){this.http=t}http;async getUploadUrl(t,e,s){let r={filename:e,contentHash:s};return this.http.get(`/document/${t}/get-url`,r)}async processSync(t,e,s){return this.http.post(`/document/${t}/process-file/${e}`,s,18e4)}async processAsync(t,e,s){return this.http.post(`/document/${t}/process-file-async/${e}`,s)}async processFilesAsync(t,e,s){return this.http.post(`/document/${t}/process-files-async`,{fileIds:e,...s})}async getFileData(t,e,s){let r={fileId:t,extractionSchemaId:e,include:s?.length?s.join(","):void 0};return this.http.get("/document/get-file-data",r)}async getFilesData(t,e){return this.http.post("/document/get-files-data",{fileIds:t,...e?.length?{include:e}:{}})}async getDocumentData(t,e,s){let r={include:s?.length?s.join(","):void 0};return this.http.get(`/deployments/${t}/documents/${e}/data`,r)}async getDocumentsData(t,e,s){return this.http.post(`/deployments/${t}/documents/data`,{fileIds:e,...s?.length?{include:s}:{}})}async submitCorrections(t,e,s){return this.http.post(`/document/${t}/process-file/${e}/submit-corrections`,s)}};var mt=class{constructor(t){this.http=t}http;async list(){let t=await this.http.get("/projects");return Array.isArray(t)?t:t.data}async create(t){return this.http.post("/projects",t)}async delete(t){return this.http.del(`/projects/${t}`)}async getSharedColumnIds(t){return this.http.get(`/projects/${t}/shared-column-ids`)}async listDeployments(t){return this.http.get(`/projects/${t}/deployments`)}async listBenchmarks(t){return this.http.get(`/projects/${t}/benchmarks`)}async listNotificationRoutes(t){return this.http.get(`/projects/${t}/notifications`)}async createNotificationRoute(t,e){return this.http.post(`/projects/${t}/notifications`,e)}async updateNotificationRoute(t,e,s){return this.http.patch(`/projects/${t}/notifications/${e}`,s)}async deleteNotificationRoute(t,e){return this.http.del(`/projects/${t}/notifications/${e}`)}async listNotificationIntegrations(t,e){return this.http.get(`/projects/${t}/notifications/integrations`,{provider:e})}async listNotificationSlackChannels(t,e){return this.http.get(`/projects/${t}/notifications/integrations/slack/channels`,{connectionId:e})}async listNotificationTeamsTeams(t,e){return this.http.get(`/projects/${t}/notifications/integrations/teams/teams`,{connectionId:e})}async listNotificationTeamsChannels(t,e,s){return this.http.get(`/projects/${t}/notifications/integrations/teams/channels`,{connectionId:e,teamId:s})}};var ht=class{constructor(t){this.http=t}http;async list(t,e){let s={status:e?.status,type:e?.type},r=await this.http.get(`/projects/${t}/deployments`,s);return Array.isArray(r)?r:r.data}async create(t,e){return this.http.post(`/projects/${t}/deployments`,e)}async getConfig(t){return this.http.get(`/deployments/${t}/configuration`)}async updateConfig(t,e){await this.http.patch(`/deployment/${t}/configuration`,e)}async listDocuments(t,e){let s={limit:e?.limit?.toString(),offset:e?.offset?.toString(),status:e?.status};return this.http.get(`/deployments/${t}/documents`,s)}async getDocument(t,e){return this.http.get(`/deployments/${t}/documents/${e}`)}async deleteDocument(t,e){await this.http.del(`/deployments/${t}/documents/${e}`)}async bulkDelete(t,e){await this.http.del(`/deployments/${t}/documents/bulk-delete`,{fileIds:e})}};var ft=class{constructor(t){this.http=t}http;async get(t){return this.http.get(`/tables/${t}`)}async listColumns(t){let e=await this.http.get(`/tables/${t}/columns`);return Array.isArray(e)?e:e.data}async listRows(t,e){let s={limit:e?.limit?.toString(),offset:e?.offset?.toString(),status:e?.status};return this.http.get(`/tables/${t}/rows`,s)}async createRows(t,e){return this.http.post(`/tables/${t}/rows`,e,6e4)}async deleteRows(t,e){return this.http.del(`/tables/${t}/rows`,e)}async createTable(t,e){return this.http.post(`/deployments/${t}/tables`,e)}async update(t,e){return this.http.patch(`/tables/${t}`,e)}};var yt=class{constructor(t){this.http=t}http;async list(t){let e=await this.http.get(`/tables/${t}/columns`);return Array.isArray(e)?e:e.data}async get(t){return this.http.get(`/columns/${t}`)}async create(t,e){let s=await this.http.post(`/tables/${t}/columns`,e);return s&&typeof s=="object"&&"data"in s?s.data:[s]}async update(t,e){return this.http.patch(`/columns/${t}`,e)}};async function*le(n,t={}){let e=Math.min(t.pageSize??100,500),s=0,r=0;for(;;){let i=t.maxItems?Math.min(e,t.maxItems-r):e;if(i<=0)break;let a=await n(i,s),p=a.data;if(p.length===0||(yield p,r+=p.length,s+=p.length,s>=a.pagination.total)||t.maxItems&&r>=t.maxItems)break}}async function*bt(n,t={}){let e=Math.min(t.pageSize??100,500),s=1,r=0;for(;;){let i=t.maxItems?Math.min(e,t.maxItems-r):e;if(i<=0)break;let a=await n(s,i),p=a.data;if(p.length===0||(yield p,r+=p.length,s++,s>a.pagination.totalPages)||t.maxItems&&r>=t.maxItems)break}}async function Rt(n){let t=[];for await(let e of n)t.push(...e);return t}var Ct=class{constructor(t){this.http=t}http;async getRows(t,e){let s={page:e?.page?.toString(),limit:e?.limit?.toString(),order:e?.order,status:e?.status};return this.http.get(`/extractions/${t}`,s)}async*getAllRows(t,e){yield*bt(async(s,r)=>this.http.get(`/extractions/${t}`,{page:s.toString(),limit:r.toString(),order:e?.order,status:e?.status}),e)}async collectAllRows(t,e){return Rt(this.getAllRows(t,e))}};var wt=class{constructor(t){this.http=t}http;async getStatus(t){return this.http.get(`/queue/${t}/status`)}async cancel(t){await this.http.post("/queue/cancel",{jobId:t})}async updateStatus(t,e){return this.http.patch(`/queue/${t}/status`,e)}};var St=class{constructor(t){this.http=t}http;async list(t){return this.http.get("/classify",{projectId:t})}async getUploadUrl(t,e){return this.http.get(`/classify/${t}/get-url`,{filename:e})}async classify(t,e){return this.http.post(`/classify/${t}`,{fileId:e})}async classifyAsync(t,e){return this.http.post(`/classify/${t}/async`,{fileId:e})}async getStatus(t,e){return this.http.get(`/classify/${t}`,{classificationId:e})}async createClassifier(t){return this.http.post("/classify",t)}async createRoute(t,e){return this.http.post(`/classify/${t}/routes`,e)}};var vt=class{constructor(t){this.http=t}http;async list(t){return this.http.get("/split",{projectId:t})}async getUploadUrl(t,e){return this.http.get(`/split/${t}/get-url`,{filename:e})}async split(t,e){return this.http.post(`/split/${t}`,{fileId:e})}async splitAsync(t,e){return this.http.post(`/split/${t}/async`,{fileId:e})}async getStatus(t,e){return this.http.get(`/split/${t}`,{splitId:e})}async listSplits(t){return this.http.get(`/split/${t}/splits`)}async createSplitter(t){return this.http.post("/split",t)}};var Et=class{constructor(t){this.http=t}http;async get(t){return this.http.get(`/deployments/${t}/configuration`)}async update(t,e){return this.http.patch(`/deployments/${t}/configuration`,e)}async getAllData(t){return this.http.get(`/deployments/${t}/all-data`)}};var It=class{constructor(t){this.http=t}http;async list(t){return this.http.get(`/projects/${t}/buckets`)}async get(t){return this.http.get(`/buckets/${t}`)}async create(t,e,s){return this.http.post(`/projects/${t}/buckets`,{name:e,description:s})}async delete(t){await this.http.del(`/buckets/${t}`)}async getUploadUrl(t,e){return this.http.get(`/buckets/${t}/get-url`,{filename:e})}async confirmUpload(t,e,s){await this.http.patch(`/buckets/${t}/files/${e}/status`,{status:"UPLOADED",...s!==void 0&&{sizeBytes:s}})}async listFiles(t,e){let s={};return e&&e.length>0&&(s.labels=e.join(",")),this.http.get(`/buckets/${t}/files`,s)}async getDownloadUrl(t,e){return this.http.get(`/buckets/${t}/files/${e}/download`)}async updateLabels(t,e,s){return this.http.patch(`/buckets/${t}/files/${e}`,{labels:s})}async deleteFile(t,e){await this.http.del(`/buckets/${t}/files/${e}`)}async sendTo(t,e,s,r){return this.http.post(`/buckets/${t}/files/${e}/send-to`,{targetType:s,targetId:r})}};var Pt=class{constructor(t){this.http=t}http;async list(t,e){let s={};return e?.status&&(s.status=e.status),this.http.get(`/projects/${t}/agents`,s)}async get(t,e){return this.http.get(`/projects/${t}/agents/${e}`)}async create(t,e){return this.http.post(`/projects/${t}/agents`,e)}async update(t,e,s){return this.http.patch(`/projects/${t}/agents/${e}`,s)}async delete(t,e){await this.http.del(`/projects/${t}/agents/${e}`)}async getFileUploadUrl(t,e,s){return this.http.get(`/projects/${t}/agents/${e}/files/get-url`,{filename:s})}async deleteFile(t,e,s){await this.http.del(`/projects/${t}/agents/${e}/files/${s}`)}async updateFileMetadata(t,e,s,r){return this.http.patch(`/projects/${t}/agents/${e}/files/${s}`,r)}async getFileDownloadUrl(t,e,s){return this.http.get(`/projects/${t}/agents/${e}/files/${s}/download`)}async listSkills(t,e){return this.http.get(`/projects/${t}/agents/${e}/skills`)}async createSkill(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/skills`,s)}async updateSkill(t,e,s,r){return this.http.patch(`/projects/${t}/agents/${e}/skills/${s}`,r)}async deleteSkill(t,e,s){await this.http.del(`/projects/${t}/agents/${e}/skills/${s}`)}async linkFileToSkill(t,e,s,r){return this.http.post(`/projects/${t}/agents/${e}/skills/${s}/files`,{fileId:r})}async unlinkFileFromSkill(t,e,s,r){await this.http.del(`/projects/${t}/agents/${e}/skills/${s}/files/${r}`)}async listRuns(t,e,s){let r={};return s?.limit&&(r.limit=String(s.limit)),s?.status&&(r.status=s.status),this.http.get(`/projects/${t}/agents/${e}/runs`,r)}async getRun(t,e,s){return this.http.get(`/projects/${t}/agents/${e}/runs/${s}`)}async getRunConversation(t,e,s,r){let i={};return r?.stepId&&(i.stepId=r.stepId),this.http.get(`/projects/${t}/agents/${e}/runs/${s}/conversation`,i)}async getRunInferenceLogs(t,e,s,r){let i={};return r?.limit!==void 0&&(i.limit=String(r.limit)),r?.status&&(i.status=r.status),this.http.get(`/projects/${t}/agents/${e}/runs/${s}/inference-logs`,i)}async createRun(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/runs`,s)}async createStep(t,e,s,r){return this.http.post(`/projects/${t}/agents/${e}/runs/${s}/steps`,r)}async createSteps(t,e,s,r){return this.http.post(`/projects/${t}/agents/${e}/runs/${s}/steps`,{steps:r})}async updateRun(t,e,s,r){return this.http.patch(`/projects/${t}/agents/${e}/runs/${s}`,r)}async updateStep(t,e,s,r,i){return this.http.patch(`/projects/${t}/agents/${e}/runs/${s}/steps/${r}`,i)}async updateStepConditions(t,e,s,r,i){return this.http.patch(`/projects/${t}/agents/${e}/runs/${s}/steps/${r}`,{conditions:i})}async pauseRun(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/runs/${s}/pause`,{})}async submitStepAction(t,e,s,r,i){return this.http.post(`/projects/${t}/agents/${e}/runs/${s}/steps/${r}/action`,i)}async sendEmail(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/send-email`,s)}async completeExecution(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/executions/complete`,s)}async getSharePointToken(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/sharepoint-token`,s)}async getArtifactUploadUrl(t,e,s){return this.http.post(`/projects/${t}/agents/${e}/upload-artifact/get-url`,s)}};var Tt=class{constructor(t){this.http=t}http;async ask(t,e){return this.http.post(`/projects/${t}/vision/ask`,e,12e4)}};var $t=class{constructor(t){this.http=t}http;async submit(t,e,s){return this.http.post(`/document/${t}/process-file/${e}/submit-validation`,s)}async listScripts(t){return(await this.http.get(`/deployments/${t}/validation-scripts`)).scripts}async getScript(t,e,s){return(await this.http.get(`/deployments/${t}/validation-scripts/${encodeURIComponent(e)}`,s?.includeSource?{includeSource:"true"}:void 0)).script}async pushScript(t,e){return this.http.post(`/deployments/${t}/validation-scripts`,e)}async updateScript(t,e,s){return(await this.http.patch(`/deployments/${t}/validation-scripts/${encodeURIComponent(e)}`,s)).script}async deleteScript(t,e){return this.http.del(`/deployments/${t}/validation-scripts/${encodeURIComponent(e)}`)}};var xt=class{constructor(t){this.http=t}http;async list(t,e){let s={};return e?.entityType&&(s.entityType=e.entityType),this.http.get(`/projects/${t}/labels`,s)}async addRemove(t,e,s,r,i){return this.http.post(`/projects/${t}/labels`,{entityType:e,entityId:s,add:r,remove:i})}async search(t,e){let s={};return e?.entityType&&(s.entityType=e.entityType),e?.labels&&(s.labels=e.labels),e?.key&&(s.key=e.key),this.http.get(`/projects/${t}/labels/search`,s)}};var At=class{constructor(t){this.http=t}http;basePath(t){return`/projects/${t}/webhooks`}async list(t){return this.http.get(this.basePath(t))}async get(t,e){return this.http.get(`${this.basePath(t)}/${e}`)}async create(t,e){return this.http.post(this.basePath(t),e,void 0,{retry:!1})}async update(t,e,s){return this.http.patch(`${this.basePath(t)}/${e}`,s,{retry:!1})}async delete(t,e){await this.http.del(`${this.basePath(t)}/${e}`)}async pause(t,e){return this.http.post(`${this.basePath(t)}/${e}/pause`)}async resume(t,e){return this.http.post(`${this.basePath(t)}/${e}/resume`)}async verify(t,e){return this.http.post(`${this.basePath(t)}/${e}/verify`,void 0,void 0,{retry:!1})}async rotateSecret(t,e){return this.http.post(`${this.basePath(t)}/${e}/rotate-secret`,void 0,void 0,{retry:!1})}async deliveries(t,e,s){let r={};return s?.status&&(r.status=s.status),s?.eventType&&(r.eventType=s.eventType),s?.deploymentId&&(r.deploymentId=s.deploymentId),s?.agentId&&(r.agentId=s.agentId),s?.classifierId&&(r.classifierId=s.classifierId),s?.splitterId&&(r.splitterId=s.splitterId),s?.limit!==void 0&&(r.limit=String(s.limit)),s?.offset!==void 0&&(r.offset=String(s.offset)),this.http.get(`${this.basePath(t)}/${e}/deliveries`,r)}async metrics(t,e,s){let r={};return s?.window&&(r.window=s.window),s?.bucket&&(r.bucket=s.bucket),this.http.get(`${this.basePath(t)}/${e}/metrics`,r)}async retry(t,e,s){return this.http.post(`${this.basePath(t)}/${e}/retry`,{eventIds:s})}};var kt=P(require("fs")),W=P(require("path"));var pe=P(require("fs")),ue=P(require("crypto"));async function de(n){return new Promise((t,e)=>{let s=ue.createHash("sha256"),r=pe.createReadStream(n);r.on("data",i=>s.update(i)),r.on("end",()=>t(s.digest("hex"))),r.on("error",e)})}var Ve={".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".tiff":"image/tiff",".tif":"image/tiff",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".xls":"application/vnd.ms-excel",".csv":"text/csv",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".doc":"application/msword"};function Je(n){let t=W.extname(n).toLowerCase();return Ve[t]||"application/octet-stream"}async function Dt(n,t,e,s,r){let i=W.resolve(s),a=W.basename(i);if(!kt.existsSync(i))throw new k(`File not found: ${i}`);if(!kt.statSync(i).isFile())throw new k(`Not a file: ${i}`);let u=await de(i),c=await t.getUploadUrl(e,a,u);if(c.isDuplicate)return{fileId:c.fileId,filename:c.fileName??a,isDuplicate:!0,bytesUploaded:0};let g=Je(i),y=await n.putFile(c.url,i,g,r);return{fileId:c.fileId,filename:c.fileName??a,isDuplicate:!1,bytesUploaded:y}}var B=P(require("fs")),H=P(require("path"));var me=P(require("path"));var ge=250,qe=5,Ht=class{constructor(t){this.max=t}max;queue=[];current=0;async acquire(){if(this.current<this.max){this.current++;return}return new Promise(t=>{this.queue.push(t)})}release(){this.current--;let t=this.queue.shift();t&&(this.current++,t())}};async function he(n,t,e,s,r){let i=Math.min(r?.concurrency??qe,10),a=new Ht(i),p=s.map(m=>({path:m,filename:me.basename(m),status:"pending"})),u=p.map(async(m,E)=>{await a.acquire();try{m.status="uploading",r?.onFileStatus?.(m);let f=await Dt(n,t,e,m.path);m.fileId=f.fileId,m.status="uploaded",r?.onFileStatus?.(m)}catch(f){m.status="failed",m.error=f instanceof Error?f.message:String(f),r?.onFileStatus?.(m)}finally{a.release()}});if(await Promise.all(u),r?.process){let E=p.filter(f=>f.status==="uploaded"&&f.fileId).map(f=>f.fileId);for(let f=0;f<E.length;f+=ge){let A=E.slice(f,f+ge);try{let $=await t.processFilesAsync(e,A,r.processOptions);for(let[l,o]of Object.entries($.results)){let d=p.find(w=>w.fileId===l);d&&(o.status==="queued"?(d.status="queued",d.jobId=o.jobId):(d.status="failed",d.error=o.error),r?.onFileStatus?.(d))}}catch($){for(let l of A){let o=p.find(d=>d.fileId===l);o&&(o.status="failed",o.error=$ instanceof Error?$.message:String($),r?.onFileStatus?.(o))}}}}let c=p.filter(m=>m.status==="uploaded"||m.status==="queued").length,g=p.filter(m=>m.status==="queued").length,y=p.filter(m=>m.status==="failed").length;return{total:s.length,uploaded:c,queued:g,failed:y,files:p}}var Ke=new Set([".pdf",".png",".jpg",".jpeg",".tiff",".tif",".xlsx",".xls",".csv",".docx",".doc"]);function fe(n,t){let e=[],s=B.readdirSync(n,{withFileTypes:!0});for(let r of s){let i=H.join(n,r.name);if(!r.name.startsWith(".")){if(r.isDirectory())e.push(...fe(i,t));else if(r.isFile()){let a=H.extname(r.name).toLowerCase();if(!Ke.has(a)||t&&!ze(r.name,t))continue;e.push(i)}}}return e.sort()}function ze(n,t){let e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*").replace(/\\\?/g,".");return new RegExp(`^${e}$`,"i").test(n)}async function ye(n,t,e,s,r){let i=H.resolve(s);if(!B.existsSync(i))throw new Error(`Directory not found: ${i}`);if(!B.statSync(i).isDirectory())throw new Error(`Not a directory: ${i}`);let p=fe(i,r?.globPattern);return p.length===0?{total:0,uploaded:0,queued:0,failed:0,files:[]}:he(n,t,e,p,{concurrency:r?.concurrency,process:r?.process,processOptions:r?.processOptions,onFileStatus:r?.onFileStatus})}var Xe=1e3,Ye=1e4,Qe=1.5,Ze=3e5,ts=["COMPLETED","FAILED","STALLED"],G=class{constructor(t){this.queue=t}queue;async*poll(t,e){let s=e?.intervalMs??Xe,r=e?.maxIntervalMs??Ye,i=e?.backoffMultiplier??Qe,a=e?.timeoutMs??Ze,p=s,u=Date.now(),c;for(;;){if(Date.now()-u>a)throw new j(`Polling timed out after ${Math.round(a/1e3)}s for job ${t}`);let g=await this.queue.getStatus(t);if(g.status!==c&&(c=g.status,e?.onStatus?.(g),yield g),ts.includes(g.status))return;await new Promise(y=>setTimeout(y,p)),p=Math.min(p*i,r)}}async waitForCompletion(t,e){let s;for await(let r of this.poll(t,e))s=r;if(!s)throw new Error(`No status received for job ${t}`);return s}};var Ot=class{http;documents;projects;deployments;tables;columns;extractions;queue;classify;split;schema;buckets;agents;vision;validations;labels;webhooks;constructor(t){this.http=new F({apiUrl:t.apiUrl,token:t.token}),this.documents=new gt(this.http),this.projects=new mt(this.http),this.deployments=new ht(this.http),this.tables=new ft(this.http),this.columns=new yt(this.http),this.extractions=new Ct(this.http),this.queue=new wt(this.http),this.classify=new St(this.http),this.split=new vt(this.http),this.schema=new Et(this.http),this.buckets=new It(this.http),this.agents=new Pt(this.http),this.vision=new Tt(this.http),this.validations=new $t(this.http),this.labels=new xt(this.http),this.webhooks=new At(this.http)}async uploadFile(t,e,s){return Dt(this.http,this.documents,t,e,s)}async uploadFolder(t,e,s){return ye(this.http,this.documents,t,e,s)}async processAndWait(t,e,s){let r=await this.documents.processAsync(t,e,s?.processOptions),i=new G(this.queue),a;for await(let p of i.poll(r.jobId,s?.pollOptions))a=p;if(!a||a.status==="FAILED")throw new Error(`Extraction failed for file ${e}${a?`: ${a.status}`:""}`);return this.documents.getFileData(e,t)}async*downloadAll(t,e){yield*this.extractions.getAllRows(t,e)}};var v=P(require("fs")),J=P(require("path")),be=P(require("os")),Ut=require("child_process"),Gt=J.join(be.homedir(),".limai"),Z=J.join(Gt,"config.json"),es=".limai.token",V;function ss(n){if(!v.existsSync(n))return{};let t={};for(let e of v.readFileSync(n,"utf-8").split(/\r?\n/)){let s=e.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)\s*$/);s&&(t[s[1]]=s[2].replace(/^(["'])(.*)\1$/,"$2"))}return t}function Re(){if(V!==void 0)return V;try{let n=(0,Ut.execSync)("git rev-parse --show-toplevel",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(!v.existsSync(J.join(n,"packages","cli")))return V=null,null;let t=(0,Ut.execSync)("git rev-parse --git-common-dir",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim(),e="";if(t!==".git"){let r=(0,Ut.execSync)("git rev-parse --abbrev-ref HEAD",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(r){let i=r.replace(/[/\\]/g,"-").replace(/[^a-zA-Z0-9._-]/g,"").replace(/^-+|-+$/g,"");i&&(e=`${i}.`)}}let s=ss(J.join(n,"tables",".env.local"));return V={root:n,apiUrl:s.NEXT_PUBLIC_BASE_URL??`https://${e}tables.localhost`,sseUrl:s.NEXT_PUBLIC_SSE_URL??`https://${e}ws.localhost`},V}catch{return V=null,null}}function ns(){let n=Re();if(!n)return;let t=J.join(n.root,es);if(v.existsSync(t))return v.readFileSync(t,"utf-8").trim()}function Vt(){let n=process.env.LIMAI_API_TOKEN,t=process.env.LIMAI_API_URL,e=process.env.LIMAI_SSE_URL,s={};if(v.existsSync(Z))try{let u=v.readFileSync(Z,"utf-8"),c=JSON.parse(u);c&&typeof c=="object"&&!Array.isArray(c)&&(s=c)}catch{s={}}let r=Re(),i=n||ns()||s.token,a=t||s.apiUrl||r?.apiUrl||process.env.LIMAI_BUILD_URL||void 0,p=e||s.sseUrl||r?.sseUrl||void 0;return!i||!a?null:{token:i,apiUrl:a,sseUrl:p,defaultProjectId:s.defaultProjectId,defaultDeploymentId:s.defaultDeploymentId}}function Ce(n){let t={};if(v.existsSync(Z))try{let s=v.readFileSync(Z,"utf-8");t=JSON.parse(s)}catch{t={}}let e={...t,...n};v.existsSync(Gt)||v.mkdirSync(Gt,{recursive:!0,mode:448}),v.writeFileSync(Z,JSON.stringify(e,null,2),{mode:384})}function we(){let n=Vt();return n||(console.error("Not authenticated. Run `npm run cli:setup` or set LIMAI_API_TOKEN environment variable."),process.exit(1)),n}var jt=class extends Error{constructor(t,e){super(t),this.name="ParseError",this.type=e.type,this.field=e.field,this.value=e.value,this.line=e.line}},Se=10,rs=13,_=32;function Jt(n){}function Ie(n){if(typeof n=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Jt,onError:e=Jt,onRetry:s=Jt,onComment:r}=n,i=[],a=!0,p,u="",c=0,g;function y(l){if(a&&(a=!1,l.charCodeAt(0)===239&&l.charCodeAt(1)===187&&l.charCodeAt(2)===191&&(l=l.slice(3))),i.length===0){let w=m(l);w!==""&&i.push(w);return}if(l.indexOf(`
2
2
  `)===-1&&l.indexOf("\r")===-1){i.push(l);return}i.push(l);let o=i.join("");i.length=0;let d=m(o);d!==""&&i.push(d)}function m(l){let o=0;if(l.indexOf("\r")===-1){let d=l.indexOf(`
3
3
  `,o);for(;d!==-1;){if(o===d){c>0&&t({id:p,event:g,data:u}),p=void 0,u="",c=0,g=void 0,o=d+1,d=l.indexOf(`
4
4
  `,o);continue}let w=l.charCodeAt(o);if(ve(l,o,w)){let S=l.charCodeAt(o+5)===_?o+6:o+5,O=l.slice(S,d);if(c===0&&l.charCodeAt(d+1)===Se){t({id:p,event:g,data:O}),p=void 0,u="",g=void 0,o=d+2,d=l.indexOf(`
@@ -7,4 +7,4 @@ ${O}`,c++}else Ee(l,o,w)?g=l.slice(l.charCodeAt(o+6)===_?o+7:o+6,d)||void 0:E(l,
7
7
  `,o)}return l.slice(o)}for(;o<l.length;){let d=l.indexOf("\r",o),w=l.indexOf(`
8
8
  `,o),S=-1;if(d!==-1&&w!==-1?S=d<w?d:w:d!==-1?d===l.length-1?S=-1:S=d:w!==-1&&(S=w),S===-1)break;E(l,o,S),o=S+1,l.charCodeAt(o-1)===rs&&l.charCodeAt(o)===Se&&o++}return l.slice(o)}function E(l,o,d){if(o===d){A();return}let w=l.charCodeAt(o);if(ve(l,o,w)){let M=l.charCodeAt(o+5)===_?o+6:o+5,se=l.slice(M,d);u=c===0?se:`${u}
9
9
  ${se}`,c++;return}if(Ee(l,o,w)){g=l.slice(l.charCodeAt(o+6)===_?o+7:o+6,d)||void 0;return}if(w===105&&l.charCodeAt(o+1)===100&&l.charCodeAt(o+2)===58){let M=l.slice(l.charCodeAt(o+3)===_?o+4:o+3,d);p=M.includes("\0")?void 0:M;return}if(w===58){if(r){let M=l.slice(o,d);r(M.slice(l.charCodeAt(o+1)===_?2:1))}return}let S=l.slice(o,d),O=S.indexOf(":");if(O===-1){f(S,"",S);return}let Oe=S.slice(0,O),Ue=S.charCodeAt(O+1)===_?2:1,je=S.slice(O+Ue);f(Oe,je,S)}function f(l,o,d){switch(l){case"event":g=o||void 0;break;case"data":u=c===0?o:`${u}
10
- ${o}`,c++;break;case"id":p=o.includes("\0")?void 0:o;break;case"retry":/^\d+$/.test(o)?s(parseInt(o,10)):e(new jt(`Invalid \`retry\` value: "${o}"`,{type:"invalid-retry",value:o,line:d}));break;default:e(new jt(`Unknown field "${l.length>20?`${l.slice(0,20)}\u2026`:l}"`,{type:"unknown-field",field:l,value:o,line:d}));break}}function A(){c>0&&t({id:p,event:g,data:u}),p=void 0,u="",c=0,g=void 0}function T(l={}){if(l.consume&&i.length>0){let o=i.join("");E(o,0,o.length)}a=!0,p=void 0,u="",c=0,g=void 0,i.length=0}return{feed:y,reset:T}}function ve(n,t,e){return e===100&&n.charCodeAt(t+1)===97&&n.charCodeAt(t+2)===116&&n.charCodeAt(t+3)===97&&n.charCodeAt(t+4)===58}function Ee(n,t,e){return e===101&&n.charCodeAt(t+1)===118&&n.charCodeAt(t+2)===101&&n.charCodeAt(t+3)===110&&n.charCodeAt(t+4)===116&&n.charCodeAt(t+5)===58}var Lt=class extends Event{constructor(t,e){var s,r;super(t),this.code=(s=e?.code)!=null?s:void 0,this.message=(r=e?.message)!=null?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,e,s){return s(Pe(this),e)}[Symbol.for("Deno.customInspect")](t,e){return t(Pe(this),e)}};function is(n){let t=globalThis.DOMException;return typeof t=="function"?new t(n,"SyntaxError"):new SyntaxError(n)}function qt(n){return n instanceof Error?"errors"in n&&Array.isArray(n.errors)?n.errors.map(qt).join(", "):"cause"in n&&n.cause instanceof Error?`${n}: ${qt(n.cause)}`:n.message:`${n}`}function Pe(n){return{type:n.type,message:n.message,code:n.code,defaultPrevented:n.defaultPrevented,cancelable:n.cancelable,timeStamp:n.timeStamp}}var Te=n=>{throw TypeError(n)},ee=(n,t,e)=>t.has(n)||Te("Cannot "+e),h=(n,t,e)=>(ee(n,t,"read from private field"),e?e.call(n):t.get(n)),C=(n,t,e)=>t.has(n)?Te("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),b=(n,t,e,s)=>(ee(n,t,"write to private field"),t.set(n,e),e),D=(n,t,e)=>(ee(n,t,"access private method"),e),I,L,q,_t,Nt,st,X,nt,U,K,Y,z,tt,x,Kt,zt,Xt,xe,Yt,Qt,et,Zt,te,N=class extends EventTarget{constructor(t,e){var s,r;super(),C(this,x),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,C(this,I),C(this,L),C(this,q),C(this,_t),C(this,Nt),C(this,st),C(this,X),C(this,nt,null),C(this,U),C(this,K),C(this,Y,null),C(this,z,null),C(this,tt,null),C(this,zt,async i=>{var a;h(this,K).reset();let{body:p,redirected:u,status:c,headers:g}=i;if(c===204){D(this,x,et).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?b(this,q,new URL(i.url)):b(this,q,void 0),c!==200){D(this,x,et).call(this,`Non-200 status code (${c})`,c);return}if(!(g.get("content-type")||"").startsWith("text/event-stream")){D(this,x,et).call(this,'Invalid content type, expected "text/event-stream"',c);return}if(h(this,I)===this.CLOSED)return;b(this,I,this.OPEN);let y=new Event("open");if((a=h(this,tt))==null||a.call(this,y),this.dispatchEvent(y),typeof p!="object"||!p||!("getReader"in p)){D(this,x,et).call(this,"Invalid response body, expected a web ReadableStream",c),this.close();return}let m=new TextDecoder,E=p.getReader(),f=!0;do{let{done:A,value:T}=await E.read();T&&h(this,K).feed(m.decode(T,{stream:!A})),A&&(f=!1,h(this,K).reset(),D(this,x,Zt).call(this))}while(f)}),C(this,Xt,i=>{b(this,U,void 0),!(i.name==="AbortError"||i.type==="aborted")&&D(this,x,Zt).call(this,qt(i))}),C(this,Yt,i=>{typeof i.id=="string"&&b(this,nt,i.id);let a=new MessageEvent(i.event||"message",{data:i.data,origin:h(this,q)?h(this,q).origin:h(this,L).origin,lastEventId:i.id||""});h(this,z)&&(!i.event||i.event==="message")&&h(this,z).call(this,a),this.dispatchEvent(a)}),C(this,Qt,i=>{b(this,st,i)}),C(this,te,()=>{b(this,X,void 0),h(this,I)===this.CONNECTING&&D(this,x,Kt).call(this)});try{if(t instanceof URL)b(this,L,t);else if(typeof t=="string")b(this,L,new URL(t,os()));else throw new Error("Invalid URL")}catch{throw is("An invalid or illegal string was specified")}b(this,K,Ie({onEvent:h(this,Yt),onRetry:h(this,Qt)})),b(this,I,this.CONNECTING),b(this,st,3e3),b(this,Nt,(s=e?.fetch)!=null?s:globalThis.fetch),b(this,_t,(r=e?.withCredentials)!=null?r:!1),D(this,x,Kt).call(this)}get readyState(){return h(this,I)}get url(){return h(this,L).href}get withCredentials(){return h(this,_t)}get onerror(){return h(this,Y)}set onerror(t){b(this,Y,t)}get onmessage(){return h(this,z)}set onmessage(t){b(this,z,t)}get onopen(){return h(this,tt)}set onopen(t){b(this,tt,t)}addEventListener(t,e,s){let r=e;super.addEventListener(t,r,s)}removeEventListener(t,e,s){let r=e;super.removeEventListener(t,r,s)}close(){h(this,X)&&clearTimeout(h(this,X)),h(this,I)!==this.CLOSED&&(h(this,U)&&h(this,U).abort(),b(this,I,this.CLOSED),b(this,U,void 0))}};I=new WeakMap,L=new WeakMap,q=new WeakMap,_t=new WeakMap,Nt=new WeakMap,st=new WeakMap,X=new WeakMap,nt=new WeakMap,U=new WeakMap,K=new WeakMap,Y=new WeakMap,z=new WeakMap,tt=new WeakMap,x=new WeakSet,Kt=function(){b(this,I,this.CONNECTING),b(this,U,new AbortController),h(this,Nt)(h(this,L),D(this,x,xe).call(this)).then(h(this,zt)).catch(h(this,Xt))},zt=new WeakMap,Xt=new WeakMap,xe=function(){var n;let t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...h(this,nt)?{"Last-Event-ID":h(this,nt)}:void 0},cache:"no-store",signal:(n=h(this,U))==null?void 0:n.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Yt=new WeakMap,Qt=new WeakMap,et=function(n,t){var e;h(this,I)!==this.CLOSED&&b(this,I,this.CLOSED);let s=new Lt("error",{code:t,message:n});(e=h(this,Y))==null||e.call(this,s),this.dispatchEvent(s)},Zt=function(n,t){var e;if(h(this,I)===this.CLOSED)return;b(this,I,this.CONNECTING);let s=new Lt("error",{code:t,message:n});(e=h(this,Y))==null||e.call(this,s),this.dispatchEvent(s),b(this,X,setTimeout(h(this,te),h(this,st)))},te=new WeakMap,N.CONNECTING=0,N.OPEN=1,N.CLOSED=2;function os(){let n="document"in globalThis?globalThis.document:void 0;return n&&typeof n=="object"&&"baseURI"in n&&typeof n.baseURI=="string"?n.baseURI:void 0}var Mt=class{eventSource=null;handlers=new Map;config;reconnectAttempts=0;maxReconnectAttempts=10;baseReconnectDelay=1e3;connected=!1;constructor(t){this.config={...t,sessionId:t.sessionId??crypto.randomUUID()}}async connect(){return new Promise((t,e)=>{let s=new URL("/events",this.config.sseUrl);s.searchParams.set("sessionId",this.config.sessionId),this.eventSource=new N(s.toString(),{fetch:(r,i)=>fetch(r,{...i,headers:{...i?.headers,Authorization:`Bearer ${this.config.token}`}})}),this.eventSource.onopen=()=>{this.connected=!0,this.reconnectAttempts=0,t()},this.eventSource.onerror=()=>{if(!this.connected){e(new Error("Failed to connect to SSE server"));return}this.handleReconnect()},this.eventSource.onmessage=r=>{try{let i=JSON.parse(r.data);this.dispatchEvent(i)}catch{}}})}async subscribe(t){if(!this.connected)throw new Error("Not connected to SSE server");let e=new URL("/subscribe",this.config.sseUrl),s=await fetch(e.toString(),{method:"POST",headers:{Authorization:`Bearer ${this.config.token}`,"Content-Type":"application/json"},body:JSON.stringify({projectId:t})});if(!s.ok)throw new Error(`Failed to subscribe to project ${t}: ${s.status}`)}async unsubscribe(t){if(!this.connected)return;let e=new URL("/unsubscribe",this.config.sseUrl);await fetch(e.toString(),{method:"POST",headers:{Authorization:`Bearer ${this.config.token}`,"Content-Type":"application/json"},body:JSON.stringify({projectId:t})})}on(t,e){let s=t;return this.handlers.has(s)||this.handlers.set(s,new Set),this.handlers.get(s).add(e),()=>{this.handlers.get(s)?.delete(e)}}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.connected=!1,this.handlers.clear()}get isConnected(){return this.connected}dispatchEvent(t){let e={type:t.type,data:t.data??t,timestamp:t.timestamp??new Date().toISOString(),sequenceNumber:t.sequenceNumber},s=this.handlers.get(e.type);if(s)for(let i of s)i(e);let r=this.handlers.get("*");if(r)for(let i of r)i(e)}handleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){this.disconnect();return}this.eventSource&&(this.eventSource.close(),this.eventSource=null);let t=this.baseReconnectDelay*Math.pow(2,this.reconnectAttempts);this.reconnectAttempts++,setTimeout(()=>{this.connect().catch(()=>{this.handleReconnect()})},t)}};var Ft=P(require("fs")),rt=P(require("path"));var as=["JOB_CONTEXT.json",rt.join(process.env.HOME||"/home/daytona","JOB_CONTEXT.json")];function it(n){let t=n?[rt.resolve(n)]:as.map(e=>rt.resolve(e));for(let e of t)if(Ft.existsSync(e)){let s=Ft.readFileSync(e,"utf-8"),r;try{r=JSON.parse(s)}catch{throw new $(`Invalid JSON in ${e}`)}return cs(r,e),r}throw new R("JOB_CONTEXT.json not found. Searched: "+t.join(", "),{code:"JOB_CONTEXT_NOT_FOUND",exitCode:1})}function cs(n,t){let e=[];if(n.jobId||e.push("jobId"),n.fileId||e.push("fileId"),n.fileName||e.push("fileName"),n.sourceFileUrl||e.push("sourceFileUrl"),n.deploymentId||e.push("deploymentId"),n.extractionSchemaId||e.push("extractionSchemaId"),e.length>0)throw new $(`JOB_CONTEXT.json (${t}) missing required fields: ${e.join(", ")}`);if(!n.schema||!Array.isArray(n.schema.tables)||n.schema.tables.length===0)throw new $(`JOB_CONTEXT.json (${t}) must have schema.tables with at least one table`);for(let s of n.schema.tables){if(!s.id||!s.name)throw new $("JOB_CONTEXT.json: table missing id or name");if(!Array.isArray(s.columns)||s.columns.length===0)throw new $(`JOB_CONTEXT.json: table "${s.name}" has no columns`)}}function $e(n){let t=process.env.LIMAI_JOB_ID;return t||it(n).jobId}function Ae(n){let t=process.env.LIMAI_FILE_ID;return t||it(n).fileId}function ke(n){let t=process.env.LIMAI_DEPLOYMENT_ID;return t||it(n).deploymentId}function De(n,t){let e=[],s=[],r=[],i=0;if(!n||typeof n!="object")return{valid:!1,errors:["Submission must be a JSON object"],warnings:[],summary:{tablesFound:0,totalRows:0,tableDetails:[]}};if(!n.tables||typeof n.tables!="object")return{valid:!1,errors:['Submission must have a "tables" object'],warnings:[],summary:{tablesFound:0,totalRows:0,tableDetails:[]}};let a=new Map;for(let u of t.schema.tables)a.set(u.name,u);let p=Object.keys(n.tables);for(let u of p){let c=a.get(u);if(!c){e.push(`Table "${u}" not found in schema. Available tables: ${[...a.keys()].join(", ")}`);continue}let g=n.tables[u];if(!Array.isArray(g)){e.push(`Table "${u}": rows must be an array`);continue}let y=!c.isPrimary,m=new Set(c.columns.map(f=>f.name)),E=new Map(c.columns.map(f=>[f.name,f]));for(let f=0;f<g.length;f++){let A=g[f];ls(A,f,u,y,m,E,e,s)}r.push({name:u,rowCount:g.length,isChild:y}),i+=g.length}for(let u of t.schema.tables)p.includes(u.name)||s.push(`Schema table "${u.name}" has no data in submission`);return{valid:e.length===0,errors:e,warnings:s,summary:{tablesFound:p.length,totalRows:i,tableDetails:r}}}function ls(n,t,e,s,r,i,a,p){let u=`Table "${e}" row ${t}`;if(typeof n!="object"||n===null){a.push(`${u}: must be an object`);return}if(typeof n.index!="number"&&a.push(`${u}: missing or invalid "index" (must be a number)`),!n.cells||typeof n.cells!="object"){a.push(`${u}: missing or invalid "cells" object`);return}s&&(n.parentIndex===void 0||n.parentIndex===null)&&a.push(`${u}: child table rows must have "parentIndex"`),s&&n.parentIndex!==void 0&&typeof n.parentIndex!="number"&&a.push(`${u}: "parentIndex" must be a number`);let c=Object.keys(n.cells);if(c.length===0){a.push(`${u}: cells object is empty`);return}let g=0;for(let y of c)if(!r.has(y))p.push(`${u}: unknown column "${y}" (will be skipped by API)`);else{g++;let m=i.get(y);m&&ps(n.cells[y],y,m.type,m.isList,u,p)}g===0&&a.push(`${u}: no cell keys match any schema column`)}function ps(n,t,e,s,r,i){if(n!=null){if(s&&!Array.isArray(n)){i.push(`${r}: column "${t}" is a LIST but value is not an array`);return}switch(e){case"NUMBER":typeof n!="number"&&typeof n!="string"&&i.push(`${r}: column "${t}" (NUMBER) has unexpected type ${typeof n}`);break;case"BOOLEAN":typeof n!="boolean"&&i.push(`${r}: column "${t}" (BOOLEAN) has unexpected type ${typeof n}`);break;case"DATE":typeof n!="string"&&i.push(`${r}: column "${t}" (DATE) should be an ISO date string`);break;case"LIST":Array.isArray(n)||i.push(`${r}: column "${t}" (LIST) should be an array`);break}}}0&&(module.exports={AuthError,ConflictError,ForbiddenError,HttpClient,JobPoller,LimaiClient,LimaiError,NotFoundError,RateLimitError,SSEClient,ServerError,TimeoutError,UploadError,ValidationError,collectAll,getDeploymentId,getFileId,getJobId,loadConfig,loadJobContext,mapHttpError,paginateOffset,paginatePage,requireConfig,saveConfig,validateSubmission});
10
+ ${o}`,c++;break;case"id":p=o.includes("\0")?void 0:o;break;case"retry":/^\d+$/.test(o)?s(parseInt(o,10)):e(new jt(`Invalid \`retry\` value: "${o}"`,{type:"invalid-retry",value:o,line:d}));break;default:e(new jt(`Unknown field "${l.length>20?`${l.slice(0,20)}\u2026`:l}"`,{type:"unknown-field",field:l,value:o,line:d}));break}}function A(){c>0&&t({id:p,event:g,data:u}),p=void 0,u="",c=0,g=void 0}function $(l={}){if(l.consume&&i.length>0){let o=i.join("");E(o,0,o.length)}a=!0,p=void 0,u="",c=0,g=void 0,i.length=0}return{feed:y,reset:$}}function ve(n,t,e){return e===100&&n.charCodeAt(t+1)===97&&n.charCodeAt(t+2)===116&&n.charCodeAt(t+3)===97&&n.charCodeAt(t+4)===58}function Ee(n,t,e){return e===101&&n.charCodeAt(t+1)===118&&n.charCodeAt(t+2)===101&&n.charCodeAt(t+3)===110&&n.charCodeAt(t+4)===116&&n.charCodeAt(t+5)===58}var Lt=class extends Event{constructor(t,e){var s,r;super(t),this.code=(s=e?.code)!=null?s:void 0,this.message=(r=e?.message)!=null?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,e,s){return s(Pe(this),e)}[Symbol.for("Deno.customInspect")](t,e){return t(Pe(this),e)}};function is(n){let t=globalThis.DOMException;return typeof t=="function"?new t(n,"SyntaxError"):new SyntaxError(n)}function qt(n){return n instanceof Error?"errors"in n&&Array.isArray(n.errors)?n.errors.map(qt).join(", "):"cause"in n&&n.cause instanceof Error?`${n}: ${qt(n.cause)}`:n.message:`${n}`}function Pe(n){return{type:n.type,message:n.message,code:n.code,defaultPrevented:n.defaultPrevented,cancelable:n.cancelable,timeStamp:n.timeStamp}}var $e=n=>{throw TypeError(n)},ee=(n,t,e)=>t.has(n)||$e("Cannot "+e),h=(n,t,e)=>(ee(n,t,"read from private field"),e?e.call(n):t.get(n)),C=(n,t,e)=>t.has(n)?$e("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),b=(n,t,e,s)=>(ee(n,t,"write to private field"),t.set(n,e),e),D=(n,t,e)=>(ee(n,t,"access private method"),e),I,L,q,_t,Nt,st,X,nt,U,K,Y,z,tt,T,Kt,zt,Xt,Te,Yt,Qt,et,Zt,te,N=class extends EventTarget{constructor(t,e){var s,r;super(),C(this,T),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,C(this,I),C(this,L),C(this,q),C(this,_t),C(this,Nt),C(this,st),C(this,X),C(this,nt,null),C(this,U),C(this,K),C(this,Y,null),C(this,z,null),C(this,tt,null),C(this,zt,async i=>{var a;h(this,K).reset();let{body:p,redirected:u,status:c,headers:g}=i;if(c===204){D(this,T,et).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?b(this,q,new URL(i.url)):b(this,q,void 0),c!==200){D(this,T,et).call(this,`Non-200 status code (${c})`,c);return}if(!(g.get("content-type")||"").startsWith("text/event-stream")){D(this,T,et).call(this,'Invalid content type, expected "text/event-stream"',c);return}if(h(this,I)===this.CLOSED)return;b(this,I,this.OPEN);let y=new Event("open");if((a=h(this,tt))==null||a.call(this,y),this.dispatchEvent(y),typeof p!="object"||!p||!("getReader"in p)){D(this,T,et).call(this,"Invalid response body, expected a web ReadableStream",c),this.close();return}let m=new TextDecoder,E=p.getReader(),f=!0;do{let{done:A,value:$}=await E.read();$&&h(this,K).feed(m.decode($,{stream:!A})),A&&(f=!1,h(this,K).reset(),D(this,T,Zt).call(this))}while(f)}),C(this,Xt,i=>{b(this,U,void 0),!(i.name==="AbortError"||i.type==="aborted")&&D(this,T,Zt).call(this,qt(i))}),C(this,Yt,i=>{typeof i.id=="string"&&b(this,nt,i.id);let a=new MessageEvent(i.event||"message",{data:i.data,origin:h(this,q)?h(this,q).origin:h(this,L).origin,lastEventId:i.id||""});h(this,z)&&(!i.event||i.event==="message")&&h(this,z).call(this,a),this.dispatchEvent(a)}),C(this,Qt,i=>{b(this,st,i)}),C(this,te,()=>{b(this,X,void 0),h(this,I)===this.CONNECTING&&D(this,T,Kt).call(this)});try{if(t instanceof URL)b(this,L,t);else if(typeof t=="string")b(this,L,new URL(t,os()));else throw new Error("Invalid URL")}catch{throw is("An invalid or illegal string was specified")}b(this,K,Ie({onEvent:h(this,Yt),onRetry:h(this,Qt)})),b(this,I,this.CONNECTING),b(this,st,3e3),b(this,Nt,(s=e?.fetch)!=null?s:globalThis.fetch),b(this,_t,(r=e?.withCredentials)!=null?r:!1),D(this,T,Kt).call(this)}get readyState(){return h(this,I)}get url(){return h(this,L).href}get withCredentials(){return h(this,_t)}get onerror(){return h(this,Y)}set onerror(t){b(this,Y,t)}get onmessage(){return h(this,z)}set onmessage(t){b(this,z,t)}get onopen(){return h(this,tt)}set onopen(t){b(this,tt,t)}addEventListener(t,e,s){let r=e;super.addEventListener(t,r,s)}removeEventListener(t,e,s){let r=e;super.removeEventListener(t,r,s)}close(){h(this,X)&&clearTimeout(h(this,X)),h(this,I)!==this.CLOSED&&(h(this,U)&&h(this,U).abort(),b(this,I,this.CLOSED),b(this,U,void 0))}};I=new WeakMap,L=new WeakMap,q=new WeakMap,_t=new WeakMap,Nt=new WeakMap,st=new WeakMap,X=new WeakMap,nt=new WeakMap,U=new WeakMap,K=new WeakMap,Y=new WeakMap,z=new WeakMap,tt=new WeakMap,T=new WeakSet,Kt=function(){b(this,I,this.CONNECTING),b(this,U,new AbortController),h(this,Nt)(h(this,L),D(this,T,Te).call(this)).then(h(this,zt)).catch(h(this,Xt))},zt=new WeakMap,Xt=new WeakMap,Te=function(){var n;let t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...h(this,nt)?{"Last-Event-ID":h(this,nt)}:void 0},cache:"no-store",signal:(n=h(this,U))==null?void 0:n.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Yt=new WeakMap,Qt=new WeakMap,et=function(n,t){var e;h(this,I)!==this.CLOSED&&b(this,I,this.CLOSED);let s=new Lt("error",{code:t,message:n});(e=h(this,Y))==null||e.call(this,s),this.dispatchEvent(s)},Zt=function(n,t){var e;if(h(this,I)===this.CLOSED)return;b(this,I,this.CONNECTING);let s=new Lt("error",{code:t,message:n});(e=h(this,Y))==null||e.call(this,s),this.dispatchEvent(s),b(this,X,setTimeout(h(this,te),h(this,st)))},te=new WeakMap,N.CONNECTING=0,N.OPEN=1,N.CLOSED=2;function os(){let n="document"in globalThis?globalThis.document:void 0;return n&&typeof n=="object"&&"baseURI"in n&&typeof n.baseURI=="string"?n.baseURI:void 0}var Mt=class{eventSource=null;handlers=new Map;config;reconnectAttempts=0;maxReconnectAttempts=10;baseReconnectDelay=1e3;connected=!1;constructor(t){this.config={...t,sessionId:t.sessionId??crypto.randomUUID()}}async connect(){return new Promise((t,e)=>{let s=new URL("/events",this.config.sseUrl);s.searchParams.set("sessionId",this.config.sessionId),this.eventSource=new N(s.toString(),{fetch:(r,i)=>fetch(r,{...i,headers:{...i?.headers,Authorization:`Bearer ${this.config.token}`}})}),this.eventSource.onopen=()=>{this.connected=!0,this.reconnectAttempts=0,t()},this.eventSource.onerror=()=>{if(!this.connected){e(new Error("Failed to connect to SSE server"));return}this.handleReconnect()},this.eventSource.onmessage=r=>{try{let i=JSON.parse(r.data);this.dispatchEvent(i)}catch{}}})}async subscribe(t){if(!this.connected)throw new Error("Not connected to SSE server");let e=new URL("/subscribe",this.config.sseUrl),s=await fetch(e.toString(),{method:"POST",headers:{Authorization:`Bearer ${this.config.token}`,"Content-Type":"application/json"},body:JSON.stringify({projectId:t})});if(!s.ok)throw new Error(`Failed to subscribe to project ${t}: ${s.status}`)}async unsubscribe(t){if(!this.connected)return;let e=new URL("/unsubscribe",this.config.sseUrl);await fetch(e.toString(),{method:"POST",headers:{Authorization:`Bearer ${this.config.token}`,"Content-Type":"application/json"},body:JSON.stringify({projectId:t})})}on(t,e){let s=t;return this.handlers.has(s)||this.handlers.set(s,new Set),this.handlers.get(s).add(e),()=>{this.handlers.get(s)?.delete(e)}}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.connected=!1,this.handlers.clear()}get isConnected(){return this.connected}dispatchEvent(t){let e={type:t.type,data:t.data??t,timestamp:t.timestamp??new Date().toISOString(),sequenceNumber:t.sequenceNumber},s=this.handlers.get(e.type);if(s)for(let i of s)i(e);let r=this.handlers.get("*");if(r)for(let i of r)i(e)}handleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){this.disconnect();return}this.eventSource&&(this.eventSource.close(),this.eventSource=null);let t=this.baseReconnectDelay*Math.pow(2,this.reconnectAttempts);this.reconnectAttempts++,setTimeout(()=>{this.connect().catch(()=>{this.handleReconnect()})},t)}};var Ft=P(require("fs")),rt=P(require("path"));var as=["JOB_CONTEXT.json",rt.join(process.env.HOME||"/home/daytona","JOB_CONTEXT.json")];function it(n){let t=n?[rt.resolve(n)]:as.map(e=>rt.resolve(e));for(let e of t)if(Ft.existsSync(e)){let s=Ft.readFileSync(e,"utf-8"),r;try{r=JSON.parse(s)}catch{throw new x(`Invalid JSON in ${e}`)}return cs(r,e),r}throw new R("JOB_CONTEXT.json not found. Searched: "+t.join(", "),{code:"JOB_CONTEXT_NOT_FOUND",exitCode:1})}function cs(n,t){let e=[];if(n.jobId||e.push("jobId"),n.fileId||e.push("fileId"),n.fileName||e.push("fileName"),n.sourceFileUrl||e.push("sourceFileUrl"),n.deploymentId||e.push("deploymentId"),n.extractionSchemaId||e.push("extractionSchemaId"),e.length>0)throw new x(`JOB_CONTEXT.json (${t}) missing required fields: ${e.join(", ")}`);if(!n.schema||!Array.isArray(n.schema.tables)||n.schema.tables.length===0)throw new x(`JOB_CONTEXT.json (${t}) must have schema.tables with at least one table`);for(let s of n.schema.tables){if(!s.id||!s.name)throw new x("JOB_CONTEXT.json: table missing id or name");if(!Array.isArray(s.columns)||s.columns.length===0)throw new x(`JOB_CONTEXT.json: table "${s.name}" has no columns`)}}function xe(n){let t=process.env.LIMAI_JOB_ID;return t||it(n).jobId}function Ae(n){let t=process.env.LIMAI_FILE_ID;return t||it(n).fileId}function ke(n){let t=process.env.LIMAI_DEPLOYMENT_ID;return t||it(n).deploymentId}function De(n,t){let e=[],s=[],r=[],i=0;if(!n||typeof n!="object")return{valid:!1,errors:["Submission must be a JSON object"],warnings:[],summary:{tablesFound:0,totalRows:0,tableDetails:[]}};if(!n.tables||typeof n.tables!="object")return{valid:!1,errors:['Submission must have a "tables" object'],warnings:[],summary:{tablesFound:0,totalRows:0,tableDetails:[]}};let a=new Map;for(let u of t.schema.tables)a.set(u.name,u);let p=Object.keys(n.tables);for(let u of p){let c=a.get(u);if(!c){e.push(`Table "${u}" not found in schema. Available tables: ${[...a.keys()].join(", ")}`);continue}let g=n.tables[u];if(!Array.isArray(g)){e.push(`Table "${u}": rows must be an array`);continue}let y=!c.isPrimary,m=new Set(c.columns.map(f=>f.name)),E=new Map(c.columns.map(f=>[f.name,f]));for(let f=0;f<g.length;f++){let A=g[f];ls(A,f,u,y,m,E,e,s)}r.push({name:u,rowCount:g.length,isChild:y}),i+=g.length}for(let u of t.schema.tables)p.includes(u.name)||s.push(`Schema table "${u.name}" has no data in submission`);return{valid:e.length===0,errors:e,warnings:s,summary:{tablesFound:p.length,totalRows:i,tableDetails:r}}}function ls(n,t,e,s,r,i,a,p){let u=`Table "${e}" row ${t}`;if(typeof n!="object"||n===null){a.push(`${u}: must be an object`);return}if(typeof n.index!="number"&&a.push(`${u}: missing or invalid "index" (must be a number)`),!n.cells||typeof n.cells!="object"){a.push(`${u}: missing or invalid "cells" object`);return}s&&(n.parentIndex===void 0||n.parentIndex===null)&&a.push(`${u}: child table rows must have "parentIndex"`),s&&n.parentIndex!==void 0&&typeof n.parentIndex!="number"&&a.push(`${u}: "parentIndex" must be a number`);let c=Object.keys(n.cells);if(c.length===0){a.push(`${u}: cells object is empty`);return}let g=0;for(let y of c)if(!r.has(y))p.push(`${u}: unknown column "${y}" (will be skipped by API)`);else{g++;let m=i.get(y);m&&ps(n.cells[y],y,m.type,m.isList,u,p)}g===0&&a.push(`${u}: no cell keys match any schema column`)}function ps(n,t,e,s,r,i){if(n!=null){if(s&&!Array.isArray(n)){i.push(`${r}: column "${t}" is a LIST but value is not an array`);return}switch(e){case"NUMBER":typeof n!="number"&&typeof n!="string"&&i.push(`${r}: column "${t}" (NUMBER) has unexpected type ${typeof n}`);break;case"BOOLEAN":typeof n!="boolean"&&i.push(`${r}: column "${t}" (BOOLEAN) has unexpected type ${typeof n}`);break;case"DATE":typeof n!="string"&&i.push(`${r}: column "${t}" (DATE) should be an ISO date string`);break;case"LIST":Array.isArray(n)||i.push(`${r}: column "${t}" (LIST) should be an array`);break}}}0&&(module.exports={AuthError,ConflictError,ForbiddenError,HttpClient,JobPoller,LimaiClient,LimaiError,NotFoundError,RateLimitError,SSEClient,ServerError,TimeoutError,UploadError,ValidationError,collectAll,getDeploymentId,getFileId,getJobId,loadConfig,loadJobContext,mapHttpError,paginateOffset,paginatePage,requireConfig,saveConfig,validateSubmission});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limai.io/cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "CLI and SDK for the LimAI data extraction platform",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",