@huggingface/transformers
Version:
State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
1 lines • 872 kB
JavaScript
var e,t,n={"./node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.jsep.wasm":(e,t,n)=>{e.exports=n.p+"ort-wasm-simd-threaded.jsep.wasm"},"./node_modules/onnxruntime-web/dist/ort.bundle.min.mjs?46eb":(e,t,n)=>{e.exports=n.p+"ort.bundle.min.mjs"},"?2ce3":()=>{},"?7992":()=>{},"?5af5":()=>{},"?2b25":()=>{},"?db59":()=>{},"?383f":()=>{},"?fa4b":()=>{},"./node_modules/@huggingface/jinja/dist/index.js":(e,t,n)=>{n.r(t),n.d(t,{Environment:()=>oe,Interpreter:()=>ae,Template:()=>fe,parse:()=>j,tokenize:()=>d});var r=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",StringLiteral:"StringLiteral",Identifier:"Identifier",Equals:"Equals",OpenParen:"OpenParen",CloseParen:"CloseParen",OpenStatement:"OpenStatement",CloseStatement:"CloseStatement",OpenExpression:"OpenExpression",CloseExpression:"CloseExpression",OpenSquareBracket:"OpenSquareBracket",CloseSquareBracket:"CloseSquareBracket",OpenCurlyBracket:"OpenCurlyBracket",CloseCurlyBracket:"CloseCurlyBracket",Comma:"Comma",Dot:"Dot",Colon:"Colon",Pipe:"Pipe",CallOperator:"CallOperator",AdditiveBinaryOperator:"AdditiveBinaryOperator",MultiplicativeBinaryOperator:"MultiplicativeBinaryOperator",ComparisonBinaryOperator:"ComparisonBinaryOperator",UnaryOperator:"UnaryOperator",Comment:"Comment"}),s=class{constructor(e,t){this.value=e,this.type=t}};function o(e){return/\w/.test(e)}function a(e){return/[0-9]/.test(e)}var i=[["{%",r.OpenStatement],["%}",r.CloseStatement],["{{",r.OpenExpression],["}}",r.CloseExpression],["(",r.OpenParen],[")",r.CloseParen],["{",r.OpenCurlyBracket],["}",r.CloseCurlyBracket],["[",r.OpenSquareBracket],["]",r.CloseSquareBracket],[",",r.Comma],[".",r.Dot],[":",r.Colon],["|",r.Pipe],["<=",r.ComparisonBinaryOperator],[">=",r.ComparisonBinaryOperator],["==",r.ComparisonBinaryOperator],["!=",r.ComparisonBinaryOperator],["<",r.ComparisonBinaryOperator],[">",r.ComparisonBinaryOperator],["+",r.AdditiveBinaryOperator],["-",r.AdditiveBinaryOperator],["~",r.AdditiveBinaryOperator],["*",r.MultiplicativeBinaryOperator],["/",r.MultiplicativeBinaryOperator],["%",r.MultiplicativeBinaryOperator],["=",r.Equals]],l=new Map([["n","\n"],["t","\t"],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function d(e,t={}){const n=[],d=function(e,t={}){return e.endsWith("\n")&&(e=e.slice(0,-1)),t.lstrip_blocks&&(e=e.replace(/^[ \t]*({[#%-])/gm,"$1")),t.trim_blocks&&(e=e.replace(/([#%-]})\n/g,"$1")),e.replace(/-%}\s*/g,"%}").replace(/\s*{%-/g,"{%").replace(/-}}\s*/g,"}}").replace(/\s*{{-/g,"{{").replace(/-#}\s*/g,"#}").replace(/\s*{#-/g,"{#").replace(/{%\s*(end)?generation\s*%}/gs,"")}(e,t);let u=0,c=0;const p=e=>{let t="";for(;e(d[u]);)if("\\"!==d[u]){if(t+=d[u++],u>=d.length)throw new SyntaxError("Unexpected end of input")}else{if(++u,u>=d.length)throw new SyntaxError("Unexpected end of input");const e=d[u++],n=l.get(e);if(void 0===n)throw new SyntaxError(`Unexpected escaped character: ${e}`);t+=n}return t};e:for(;u<d.length;){const e=n.at(-1)?.type;if(void 0===e||e===r.CloseStatement||e===r.CloseExpression||e===r.Comment){let e="";for(;u<d.length&&("{"!==d[u]||"%"!==d[u+1]&&"{"!==d[u+1]&&"#"!==d[u+1]);)e+=d[u++];if(e.length>0){n.push(new s(e,r.Text));continue}}if("{"===d[u]&&"#"===d[u+1]){u+=2;let e="";for(;"#"!==d[u]||"}"!==d[u+1];){if(u+2>=d.length)throw new SyntaxError("Missing end of comment tag");e+=d[u++]}n.push(new s(e,r.Comment)),u+=2;continue}p((e=>/\s/.test(e)));const t=d[u];if("-"===t||"+"===t){const e=n.at(-1)?.type;if(e===r.Text||void 0===e)throw new SyntaxError(`Unexpected character: ${t}`);switch(e){case r.Identifier:case r.NumericLiteral:case r.StringLiteral:case r.CloseParen:case r.CloseSquareBracket:break;default:{++u;const e=p(a);n.push(new s(`${t}${e}`,e.length>0?r.NumericLiteral:r.UnaryOperator));continue}}}for(const[e,t]of i){if("}}"===e&&c>0)continue;if(d.slice(u,u+e.length)===e){n.push(new s(e,t)),t===r.OpenExpression?c=0:t===r.OpenCurlyBracket?++c:t===r.CloseCurlyBracket&&--c,u+=e.length;continue e}}if("'"!==t&&'"'!==t)if(a(t)){let e=p(a);if("."===d[u]&&a(d[u+1])){++u;e=`${e}.${p(a)}`}n.push(new s(e,r.NumericLiteral))}else{if(!o(t))throw new SyntaxError(`Unexpected character: ${t}`);{const e=p(o);n.push(new s(e,r.Identifier))}}else{++u;const e=p((e=>e!==t));n.push(new s(e,r.StringLiteral)),++u}}return n}var u=class{type="Statement"},c=class extends u{constructor(e){super(),this.body=e}type="Program"},p=class extends u{constructor(e,t,n){super(),this.test=e,this.body=t,this.alternate=n}type="If"},m=class extends u{constructor(e,t,n,r){super(),this.loopvar=e,this.iterable=t,this.body=n,this.defaultBlock=r}type="For"},h=class extends u{type="Break"},f=class extends u{type="Continue"},_=class extends u{constructor(e,t,n){super(),this.assignee=e,this.value=t,this.body=n}type="Set"},g=class extends u{constructor(e,t,n){super(),this.name=e,this.args=t,this.body=n}type="Macro"},w=class extends u{constructor(e){super(),this.value=e}type="Comment"},b=class extends u{type="Expression"},y=class extends b{constructor(e,t,n){super(),this.object=e,this.property=t,this.computed=n}type="MemberExpression"},M=class extends b{constructor(e,t){super(),this.callee=e,this.args=t}type="CallExpression"},x=class extends b{constructor(e){super(),this.value=e}type="Identifier"},v=class extends b{constructor(e){super(),this.value=e}type="Literal"},T=class extends v{type="IntegerLiteral"},k=class extends v{type="FloatLiteral"},P=class extends v{type="StringLiteral"},$=class extends v{type="ArrayLiteral"},C=class extends v{type="TupleLiteral"},S=class extends v{type="ObjectLiteral"},F=class extends b{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}type="BinaryExpression"},E=class extends b{constructor(e,t){super(),this.operand=e,this.filter=t}type="FilterExpression"},I=class extends u{constructor(e,t){super(),this.filter=e,this.body=t}type="FilterStatement"},A=class extends b{constructor(e,t){super(),this.lhs=e,this.test=t}type="SelectExpression"},z=class extends b{constructor(e,t,n){super(),this.operand=e,this.negate=t,this.test=n}type="TestExpression"},L=class extends b{constructor(e,t){super(),this.operator=e,this.argument=t}type="UnaryExpression"},O=class extends b{constructor(e=void 0,t=void 0,n=void 0){super(),this.start=e,this.stop=t,this.step=n}type="SliceExpression"},D=class extends b{constructor(e,t){super(),this.key=e,this.value=t}type="KeywordArgumentExpression"},B=class extends b{constructor(e){super(),this.argument=e}type="SpreadExpression"},N=class extends u{constructor(e,t,n){super(),this.call=e,this.callerArgs=t,this.body=n}type="CallStatement"},R=class extends b{constructor(e,t,n){super(),this.condition=e,this.trueExpr=t,this.falseExpr=n}type="Ternary"};function j(e){const t=new c([]);let n=0;function o(t,r){const s=e[n++];if(!s||s.type!==t)throw new Error(`Parser Error: ${r}. ${s.type} !== ${t}.`);return s}function a(e){if(!u(e))throw new SyntaxError(`Expected ${e}`);++n}function i(){switch(e[n].type){case r.Comment:return new w(e[n++].value);case r.Text:return new P(o(r.Text,"Expected text token").value);case r.OpenStatement:return function(){if(o(r.OpenStatement,"Expected opening statement token"),e[n].type!==r.Identifier)throw new SyntaxError(`Unknown statement, got ${e[n].type}`);const t=e[n].value;let s;switch(t){case"set":++n,s=function(){const e=v();let t=null;const s=[];if(l(r.Equals))++n,t=v();else{for(o(r.CloseStatement,"Expected %} token");!d("endset");)s.push(i());o(r.OpenStatement,"Expected {% token"),a("endset")}return o(r.CloseStatement,"Expected closing statement token"),new _(e,t,s)}();break;case"if":++n,s=b(),o(r.OpenStatement,"Expected {% token"),a("endif"),o(r.CloseStatement,"Expected %} token");break;case"macro":++n,s=function(){const e=Z();if("Identifier"!==e.type)throw new SyntaxError("Expected identifier following macro statement");const t=Q();o(r.CloseStatement,"Expected closing statement token");const n=[];for(;!d("endmacro");)n.push(i());return new g(e,t,n)}(),o(r.OpenStatement,"Expected {% token"),a("endmacro"),o(r.CloseStatement,"Expected %} token");break;case"for":++n,s=function(){const e=v(!0);if(!(e instanceof x||e instanceof C))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${e.type} instead`);if(!u("in"))throw new SyntaxError("Expected `in` keyword following loop variable");++n;const t=j();o(r.CloseStatement,"Expected closing statement token");const s=[];for(;!d("endfor","else");)s.push(i());const a=[];if(d("else"))for(++n,++n,o(r.CloseStatement,"Expected closing statement token");!d("endfor");)a.push(i());return new m(e,t,s,a)}(),o(r.OpenStatement,"Expected {% token"),a("endfor"),o(r.CloseStatement,"Expected %} token");break;case"call":{++n;let e=null;l(r.OpenParen)&&(e=Q());const t=Z();if("Identifier"!==t.type)throw new SyntaxError("Expected identifier following call statement");const u=Q();o(r.CloseStatement,"Expected closing statement token");const c=[];for(;!d("endcall");)c.push(i());o(r.OpenStatement,"Expected '{%'"),a("endcall"),o(r.CloseStatement,"Expected closing statement token");const p=new M(t,u);s=new N(p,e,c);break}case"break":++n,o(r.CloseStatement,"Expected closing statement token"),s=new h;break;case"continue":++n,o(r.CloseStatement,"Expected closing statement token"),s=new f;break;case"filter":{++n;let e=Z();e instanceof x&&l(r.OpenParen)&&(e=H(e)),o(r.CloseStatement,"Expected closing statement token");const t=[];for(;!d("endfilter");)t.push(i());o(r.OpenStatement,"Expected '{%'"),a("endfilter"),o(r.CloseStatement,"Expected '%}'"),s=new I(e,t);break}default:throw new SyntaxError(`Unknown statement type: ${t}`)}return s}();case r.OpenExpression:return function(){o(r.OpenExpression,"Expected opening expression token");const e=j();return o(r.CloseExpression,"Expected closing expression token"),e}();default:throw new SyntaxError(`Unexpected token type: ${e[n].type}`)}}function l(...t){return n+t.length<=e.length&&t.every(((t,r)=>t===e[n+r].type))}function d(...t){return e[n]?.type===r.OpenStatement&&e[n+1]?.type===r.Identifier&&t.includes(e[n+1]?.value)}function u(...t){return n+t.length<=e.length&&t.every(((t,r)=>"Identifier"===e[n+r].type&&t===e[n+r].value))}function b(){const e=j();o(r.CloseStatement,"Expected closing statement token");const t=[],s=[];for(;!d("elif","else","endif");)t.push(i());if(d("elif")){++n,++n;const e=b();s.push(e)}else if(d("else"))for(++n,++n,o(r.CloseStatement,"Expected closing statement token");!d("endif");)s.push(i());return new p(e,t,s)}function v(e=!1){const t=e?Z:j,s=[t()],o=l(r.Comma);for(;o&&(++n,s.push(t()),l(r.Comma)););return o?new C(s):s[0]}function j(){return V()}function V(){const e=G();if(u("if")){++n;const t=G();if(u("else")){++n;const r=V();return new R(t,e,r)}return new A(e,t)}return e}function G(){let t=q();for(;u("or");){const r=e[n];++n;const s=q();t=new F(r,t,s)}return t}function q(){let t=U();for(;u("and");){const r=e[n];++n;const s=U();t=new F(r,t,s)}return t}function U(){let t;for(;u("not");){const r=e[n];++n;const s=U();t=new L(r,s)}return t??function(){let t=W();for(;;){let o;if(u("not","in"))o=new s("not in",r.Identifier),n+=2;else if(u("in"))o=e[n++];else{if(!l(r.ComparisonBinaryOperator))break;o=e[n++]}const a=W();t=new F(o,t,a)}return t}()}function W(){let t=J();for(;l(r.AdditiveBinaryOperator);){const r=e[n];++n;const s=J();t=new F(r,t,s)}return t}function H(e){let t=new M(e,Q());return t=X(t),l(r.OpenParen)&&(t=H(t)),t}function Q(){o(r.OpenParen,"Expected opening parenthesis for arguments list");const t=function(){const t=[];for(;!l(r.CloseParen);){let s;if(e[n].type===r.MultiplicativeBinaryOperator&&"*"===e[n].value){++n;const e=j();s=new B(e)}else if(s=j(),l(r.Equals)){if(++n,!(s instanceof x))throw new SyntaxError("Expected identifier for keyword argument");const e=j();s=new D(s,e)}t.push(s),l(r.Comma)&&++n}return t}();return o(r.CloseParen,"Expected closing parenthesis for arguments list"),t}function K(){const e=[];let t=!1;for(;!l(r.CloseSquareBracket);)l(r.Colon)?(e.push(void 0),++n,t=!0):(e.push(j()),l(r.Colon)&&(++n,t=!0));if(0===e.length)throw new SyntaxError("Expected at least one argument for member/slice expression");if(t){if(e.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new O(...e)}return e[0]}function X(t){for(;l(r.Dot)||l(r.OpenSquareBracket);){const s=e[n];let a;++n;const i=s.type===r.OpenSquareBracket;if(i)a=K(),o(r.CloseSquareBracket,"Expected closing square bracket");else if(a=Z(),"Identifier"!==a.type)throw new SyntaxError("Expected identifier following dot operator");t=new y(t,a,i)}return t}function J(){let t=Y();for(;l(r.MultiplicativeBinaryOperator);){const r=e[n++],s=Y();t=new F(r,t,s)}return t}function Y(){let e=function(){let e=function(){const e=X(Z());return l(r.OpenParen)?H(e):e}();for(;l(r.Pipe);){++n;let t=Z();if(!(t instanceof x))throw new SyntaxError("Expected identifier for the filter");l(r.OpenParen)&&(t=H(t)),e=new E(e,t)}return e}();for(;u("is");){++n;const t=u("not");t&&++n;const r=Z();if(!(r instanceof x))throw new SyntaxError("Expected identifier for the test");e=new z(e,t,r)}return e}function Z(){const t=e[n++];switch(t.type){case r.NumericLiteral:{const e=t.value;return e.includes(".")?new k(Number(e)):new T(Number(e))}case r.StringLiteral:{let s=t.value;for(;l(r.StringLiteral);)s+=e[n++].value;return new P(s)}case r.Identifier:return new x(t.value);case r.OpenParen:{const e=v();return o(r.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),e}case r.OpenSquareBracket:{const e=[];for(;!l(r.CloseSquareBracket);)e.push(j()),l(r.Comma)&&++n;return++n,new $(e)}case r.OpenCurlyBracket:{const e=new Map;for(;!l(r.CloseCurlyBracket);){const t=j();o(r.Colon,"Expected colon between key and value in object literal");const s=j();e.set(t,s),l(r.Comma)&&++n}return++n,new S(e)}default:throw new SyntaxError(`Unexpected token: ${t.type}`)}}for(;n<e.length;)t.body.push(i());return t}function V(e,t,n=1){void 0===t&&(t=e,e=0);const r=[];for(let s=e;s<t;s+=n)r.push(s);return r}function G(e,t,n,r=1){const s=Math.sign(r);s>=0?(t=(t??=0)<0?Math.max(e.length+t,0):Math.min(t,e.length),n=(n??=e.length)<0?Math.max(e.length+n,0):Math.min(n,e.length)):(t=(t??=e.length-1)<0?Math.max(e.length+t,-1):Math.min(t,e.length-1),n=(n??=-1)<-1?Math.max(e.length+n,-1):Math.min(n,e.length-1));const o=[];for(let a=t;s*a<s*n;a+=r)o.push(e[a]);return o}function q(e){return function(e,t){const n=new Intl.DateTimeFormat(void 0,{month:"long"}),r=new Intl.DateTimeFormat(void 0,{month:"short"}),s=e=>e<10?"0"+e:e.toString();return t.replace(/%[YmdbBHM%]/g,(t=>{switch(t){case"%Y":return e.getFullYear().toString();case"%m":return s(e.getMonth()+1);case"%d":return s(e.getDate());case"%b":return r.format(e);case"%B":return n.format(e);case"%H":return s(e.getHours());case"%M":return s(e.getMinutes());case"%%":return"%";default:return t}}))}(new Date,e)}var U=class extends Error{},W=class extends Error{},H=class{type="RuntimeValue";value;builtins=new Map;constructor(e=void 0){this.value=e}__bool__(){return new J(!!this.value)}toString(){return String(this.value)}},Q=class extends H{type="IntegerValue"},K=class extends H{type="FloatValue";toString(){return this.value%1==0?this.value.toFixed(1):this.value.toString()}},X=class extends H{type="StringValue";builtins=new Map([["upper",new ne((()=>new X(this.value.toUpperCase())))],["lower",new ne((()=>new X(this.value.toLowerCase())))],["strip",new ne((()=>new X(this.value.trim())))],["title",new ne((()=>new X(this.value.replace(/\b\w/g,(e=>e.toUpperCase())))))],["capitalize",new ne((()=>new X(this.value.charAt(0).toUpperCase()+this.value.slice(1))))],["length",new Q(this.value.length)],["rstrip",new ne((()=>new X(this.value.trimEnd())))],["lstrip",new ne((()=>new X(this.value.trimStart())))],["startswith",new ne((e=>{if(0===e.length)throw new Error("startswith() requires at least one argument");const t=e[0];if(t instanceof X)return new J(this.value.startsWith(t.value));if(t instanceof ee){for(const e of t.value){if(!(e instanceof X))throw new Error("startswith() tuple elements must be strings");if(this.value.startsWith(e.value))return new J(!0)}return new J(!1)}throw new Error("startswith() argument must be a string or tuple of strings")}))],["endswith",new ne((e=>{if(0===e.length)throw new Error("endswith() requires at least one argument");const t=e[0];if(t instanceof X)return new J(this.value.endsWith(t.value));if(t instanceof ee){for(const e of t.value){if(!(e instanceof X))throw new Error("endswith() tuple elements must be strings");if(this.value.endsWith(e.value))return new J(!0)}return new J(!1)}throw new Error("endswith() argument must be a string or tuple of strings")}))],["split",new ne((e=>{const t=e[0]??new re;if(!(t instanceof X||t instanceof re))throw new Error("sep argument must be a string or null");const n=e[1]??new Q(-1);if(!(n instanceof Q))throw new Error("maxsplit argument must be a number");let r=[];if(t instanceof re){const e=this.value.trimStart();for(const{0:t,index:s}of e.matchAll(/\S+/g)){if(-1!==n.value&&r.length>=n.value&&void 0!==s){r.push(t+e.slice(s+t.length));break}r.push(t)}}else{if(""===t.value)throw new Error("empty separator");r=this.value.split(t.value),-1!==n.value&&r.length>n.value&&r.push(r.splice(n.value).join(t.value))}return new ee(r.map((e=>new X(e))))}))],["replace",new ne((e=>{if(e.length<2)throw new Error("replace() requires at least two arguments");const t=e[0],n=e[1];if(!(t instanceof X&&n instanceof X))throw new Error("replace() arguments must be strings");let r;if(r=e.length>2?"KeywordArgumentsValue"===e[2].type?e[2].value.get("count")??new re:e[2]:new re,!(r instanceof Q||r instanceof re))throw new Error("replace() count argument must be a number or null");return new X(function(e,t,n,r){if(0===r)return e;let s=null==r||r<0?1/0:r;const o=0===t.length?new RegExp("(?=)","gu"):new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gu");return e.replaceAll(o,(e=>s>0?(--s,n):e))}(this.value,t.value,n.value,r.value))}))]])},J=class extends H{type="BooleanValue"},Y=class extends H{type="ObjectValue";__bool__(){return new J(this.value.size>0)}builtins=new Map([["get",new ne((([e,t])=>{if(!(e instanceof X))throw new Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new re}))],["items",new ne((()=>this.items()))],["keys",new ne((()=>this.keys()))],["values",new ne((()=>this.values()))]]);items(){return new ee(Array.from(this.value.entries()).map((([e,t])=>new ee([new X(e),t]))))}keys(){return new ee(Array.from(this.value.keys()).map((e=>new X(e))))}values(){return new ee(Array.from(this.value.values()))}},Z=class extends Y{type="KeywordArgumentsValue"},ee=class extends H{type="ArrayValue";builtins=new Map([["length",new Q(this.value.length)]]);__bool__(){return new J(this.value.length>0)}},te=class extends ee{type="TupleValue"},ne=class extends H{type="FunctionValue"},re=class extends H{type="NullValue"},se=class extends H{type="UndefinedValue"},oe=class{constructor(e){this.parent=e}variables=new Map([["namespace",new ne((e=>{if(0===e.length)return new Y(new Map);if(1!==e.length||!(e[0]instanceof Y))throw new Error("`namespace` expects either zero arguments or a single object argument");return e[0]}))]]);tests=new Map([["boolean",e=>"BooleanValue"===e.type],["callable",e=>e instanceof ne],["odd",e=>{if(!(e instanceof Q))throw new Error(`cannot odd on ${e.type}`);return e.value%2!=0}],["even",e=>{if(!(e instanceof Q))throw new Error(`cannot even on ${e.type}`);return e.value%2==0}],["false",e=>"BooleanValue"===e.type&&!e.value],["true",e=>"BooleanValue"===e.type&&e.value],["none",e=>"NullValue"===e.type],["string",e=>"StringValue"===e.type],["number",e=>e instanceof Q||e instanceof K],["integer",e=>e instanceof Q],["iterable",e=>"ArrayValue"===e.type||"StringValue"===e.type],["mapping",e=>"ObjectValue"===e.type],["lower",e=>{const t=e.value;return"StringValue"===e.type&&t===t.toLowerCase()}],["upper",e=>{const t=e.value;return"StringValue"===e.type&&t===t.toUpperCase()}],["none",e=>"NullValue"===e.type],["defined",e=>"UndefinedValue"!==e.type],["undefined",e=>"UndefinedValue"===e.type],["equalto",(e,t)=>e.value===t.value],["eq",(e,t)=>e.value===t.value]]);set(e,t){return this.declareVariable(e,ie(t))}declareVariable(e,t){if(this.variables.has(e))throw new SyntaxError(`Variable already declared: ${e}`);return this.variables.set(e,t),t}setVariable(e,t){return this.variables.set(e,t),t}resolve(e){if(this.variables.has(e))return this;if(this.parent)return this.parent.resolve(e);throw new Error(`Unknown variable: ${e}`)}lookupVariable(e){try{return this.resolve(e).variables.get(e)??new se}catch{return new se}}};var ae=class{global;constructor(e){this.global=e??new oe}run(e){return this.evaluate(e,this.global)}evaluateBinaryExpression(e,t){const n=this.evaluate(e.left,t);switch(e.operator.value){case"and":return n.__bool__().value?this.evaluate(e.right,t):n;case"or":return n.__bool__().value?n:this.evaluate(e.right,t)}const r=this.evaluate(e.right,t);switch(e.operator.value){case"==":return new J(n.value==r.value);case"!=":return new J(n.value!=r.value)}if(n instanceof se||r instanceof se){if(r instanceof se&&["in","not in"].includes(e.operator.value))return new J("not in"===e.operator.value);throw new Error(`Cannot perform operation ${e.operator.value} on undefined values`)}if(n instanceof re||r instanceof re)throw new Error("Cannot perform operation on null values");if("~"===e.operator.value)return new X(n.value.toString()+r.value.toString());if((n instanceof Q||n instanceof K)&&(r instanceof Q||r instanceof K)){const t=n.value,s=r.value;switch(e.operator.value){case"+":case"-":case"*":{const o="+"===e.operator.value?t+s:"-"===e.operator.value?t-s:t*s;return n instanceof K||r instanceof K?new K(o):new Q(o)}case"/":return new K(t/s);case"%":{const e=t%s;return n instanceof K||r instanceof K?new K(e):new Q(e)}case"<":return new J(t<s);case">":return new J(t>s);case">=":return new J(t>=s);case"<=":return new J(t<=s)}}else if(n instanceof ee&&r instanceof ee){if("+"===e.operator.value)return new ee(n.value.concat(r.value))}else if(r instanceof ee){const t=void 0!==r.value.find((e=>e.value===n.value));switch(e.operator.value){case"in":return new J(t);case"not in":return new J(!t)}}if((n instanceof X||r instanceof X)&&"+"===e.operator.value)return new X(n.value.toString()+r.value.toString());if(n instanceof X&&r instanceof X)switch(e.operator.value){case"in":return new J(r.value.includes(n.value));case"not in":return new J(!r.value.includes(n.value))}if(n instanceof X&&r instanceof Y)switch(e.operator.value){case"in":return new J(r.value.has(n.value));case"not in":return new J(!r.value.has(n.value))}throw new SyntaxError(`Unknown operator "${e.operator.value}" between ${n.type} and ${r.type}`)}evaluateArguments(e,t){const n=[],r=new Map;for(const s of e)if("SpreadExpression"===s.type){const e=s,r=this.evaluate(e.argument,t);if(!(r instanceof ee))throw new Error(`Cannot unpack non-iterable type: ${r.type}`);for(const e of r.value)n.push(e)}else if("KeywordArgumentExpression"===s.type){const e=s;r.set(e.key.value,this.evaluate(e.value,t))}else{if(r.size>0)throw new Error("Positional arguments must come before keyword arguments");n.push(this.evaluate(s,t))}return[n,r]}applyFilter(e,t,n){if("Identifier"===t.type){const r=t;if("tojson"===r.value)return new X(le(e));if(e instanceof ee)switch(r.value){case"list":return e;case"first":return e.value[0];case"last":return e.value[e.value.length-1];case"length":return new Q(e.value.length);case"reverse":return new ee(e.value.reverse());case"sort":return new ee(e.value.sort(((e,t)=>{if(e.type!==t.type)throw new Error(`Cannot compare different types: ${e.type} and ${t.type}`);switch(e.type){case"IntegerValue":case"FloatValue":return e.value-t.value;case"StringValue":return e.value.localeCompare(t.value);default:throw new Error(`Cannot compare type: ${e.type}`)}})));case"join":return new X(e.value.map((e=>e.value)).join(""));case"string":return new X(le(e));case"unique":{const t=new Set,n=[];for(const r of e.value)t.has(r.value)||(t.add(r.value),n.push(r));return new ee(n)}default:throw new Error(`Unknown ArrayValue filter: ${r.value}`)}else if(e instanceof X)switch(r.value){case"length":case"upper":case"lower":case"title":case"capitalize":{const t=e.builtins.get(r.value);if(t instanceof ne)return t.value([],n);if(t instanceof Q)return t;throw new Error(`Unknown StringValue filter: ${r.value}`)}case"trim":return new X(e.value.trim());case"indent":return new X(e.value.split("\n").map(((e,t)=>0===t||0===e.length?e:" "+e)).join("\n"));case"join":case"string":return e;case"int":{const t=parseInt(e.value,10);return new Q(isNaN(t)?0:t)}case"float":{const t=parseFloat(e.value);return new K(isNaN(t)?0:t)}default:throw new Error(`Unknown StringValue filter: ${r.value}`)}else if(e instanceof Q||e instanceof K)switch(r.value){case"abs":return e instanceof Q?new Q(Math.abs(e.value)):new K(Math.abs(e.value));case"int":return new Q(Math.floor(e.value));case"float":return new K(e.value);default:throw new Error(`Unknown NumericValue filter: ${r.value}`)}else if(e instanceof Y)switch(r.value){case"items":return new ee(Array.from(e.value.entries()).map((([e,t])=>new ee([new X(e),t]))));case"length":return new Q(e.value.size);default:throw new Error(`Unknown ObjectValue filter: ${r.value}`)}else if(e instanceof J)switch(r.value){case"bool":return new J(e.value);case"int":return new Q(e.value?1:0);case"float":return new K(e.value?1:0);case"string":return new X(e.value?"true":"false");default:throw new Error(`Unknown BooleanValue filter: ${r.value}`)}throw new Error(`Cannot apply filter "${r.value}" to type: ${e.type}`)}if("CallExpression"===t.type){const r=t;if("Identifier"!==r.callee.type)throw new Error(`Unknown filter: ${r.callee.type}`);const s=r.callee.value;if("tojson"===s){const[,t]=this.evaluateArguments(r.args,n),s=t.get("indent")??new re;if(!(s instanceof Q||s instanceof re))throw new Error("If set, indent must be a number");return new X(le(e,s.value))}if("join"===s){let t;if(e instanceof X)t=Array.from(e.value);else{if(!(e instanceof ee))throw new Error(`Cannot apply filter "${s}" to type: ${e.type}`);t=e.value.map((e=>e.value))}const[o,a]=this.evaluateArguments(r.args,n),i=o.at(0)??a.get("separator")??new X("");if(!(i instanceof X))throw new Error("separator must be a string");return new X(t.join(i.value))}if("int"===s||"float"===s){const[t,o]=this.evaluateArguments(r.args,n),a=t.at(0)??o.get("default")??("int"===s?new Q(0):new K(0));if(e instanceof X){const t="int"===s?parseInt(e.value,10):parseFloat(e.value);return isNaN(t)?a:"int"===s?new Q(t):new K(t)}if(e instanceof Q||e instanceof K)return e;if(e instanceof J)return"int"===s?new Q(e.value?1:0):new K(e.value?1:0);throw new Error(`Cannot apply filter "${s}" to type: ${e.type}`)}if("default"===s){const[t,s]=this.evaluateArguments(r.args,n),o=t[0]??new X(""),a=t[1]??s.get("boolean")??new J(!1);if(!(a instanceof J))throw new Error("`default` filter flag must be a boolean");return e instanceof se||a.value&&!e.__bool__().value?o:e}if(e instanceof ee){switch(s){case"selectattr":case"rejectattr":{const t="selectattr"===s;if(e.value.some((e=>!(e instanceof Y))))throw new Error(`\`${s}\` can only be applied to array of objects`);if(r.args.some((e=>"StringLiteral"!==e.type)))throw new Error(`arguments of \`${s}\` must be strings`);const[o,a,i]=r.args.map((e=>this.evaluate(e,n)));let l;if(a){const e=n.tests.get(a.value);if(!e)throw new Error(`Unknown test: ${a.value}`);l=e}else l=(...e)=>e[0].__bool__().value;const d=e.value.filter((e=>{const n=e.value.get(o.value),r=!!n&&l(n,i);return t?r:!r}));return new ee(d)}case"map":{const[,t]=this.evaluateArguments(r.args,n);if(t.has("attribute")){const n=t.get("attribute");if(!(n instanceof X))throw new Error("attribute must be a string");const r=t.get("default"),s=e.value.map((e=>{if(!(e instanceof Y))throw new Error("items in map must be an object");return e.value.get(n.value)??r??new se}));return new ee(s)}throw new Error("`map` expressions without `attribute` set are not currently supported.")}}throw new Error(`Unknown ArrayValue filter: ${s}`)}if(e instanceof X){switch(s){case"indent":{const[t,s]=this.evaluateArguments(r.args,n),o=t.at(0)??s.get("width")??new Q(4);if(!(o instanceof Q))throw new Error("width must be a number");const a=t.at(1)??s.get("first")??new J(!1),i=t.at(2)??s.get("blank")??new J(!1),l=e.value.split("\n"),d=" ".repeat(o.value),u=l.map(((e,t)=>!a.value&&0===t||!i.value&&0===e.length?e:d+e));return new X(u.join("\n"))}case"replace":{const t=e.builtins.get("replace");if(!(t instanceof ne))throw new Error("replace filter not available");const[s,o]=this.evaluateArguments(r.args,n);return t.value([...s,new Z(o)],n)}}throw new Error(`Unknown StringValue filter: ${s}`)}throw new Error(`Cannot apply filter "${s}" to type: ${e.type}`)}throw new Error(`Unknown filter: ${t.type}`)}evaluateFilterExpression(e,t){const n=this.evaluate(e.operand,t);return this.applyFilter(n,e.filter,t)}evaluateTestExpression(e,t){const n=this.evaluate(e.operand,t),r=t.tests.get(e.test.value);if(!r)throw new Error(`Unknown test: ${e.test.value}`);const s=r(n);return new J(e.negate?!s:s)}evaluateSelectExpression(e,t){return this.evaluate(e.test,t).__bool__().value?this.evaluate(e.lhs,t):new se}evaluateUnaryExpression(e,t){const n=this.evaluate(e.argument,t);if("not"===e.operator.value)return new J(!n.value);throw new SyntaxError(`Unknown operator: ${e.operator.value}`)}evaluateTernaryExpression(e,t){return this.evaluate(e.condition,t).__bool__().value?this.evaluate(e.trueExpr,t):this.evaluate(e.falseExpr,t)}evalProgram(e,t){return this.evaluateBlock(e.body,t)}evaluateBlock(e,t){let n="";for(const r of e){const e=this.evaluate(r,t);"NullValue"!==e.type&&"UndefinedValue"!==e.type&&(n+=e.toString())}return new X(n)}evaluateIdentifier(e,t){return t.lookupVariable(e.value)}evaluateCallExpression(e,t){const[n,r]=this.evaluateArguments(e.args,t);r.size>0&&n.push(new Z(r));const s=this.evaluate(e.callee,t);if("FunctionValue"!==s.type)throw new Error(`Cannot call something that is not a function: got ${s.type}`);return s.value(n,t)}evaluateSliceExpression(e,t,n){if(!(e instanceof ee||e instanceof X))throw new Error("Slice object must be an array or string");const r=this.evaluate(t.start,n),s=this.evaluate(t.stop,n),o=this.evaluate(t.step,n);if(!(r instanceof Q||r instanceof se))throw new Error("Slice start must be numeric or undefined");if(!(s instanceof Q||s instanceof se))throw new Error("Slice stop must be numeric or undefined");if(!(o instanceof Q||o instanceof se))throw new Error("Slice step must be numeric or undefined");return e instanceof ee?new ee(G(e.value,r.value,s.value,o.value)):new X(G(Array.from(e.value),r.value,s.value,o.value).join(""))}evaluateMemberExpression(e,t){const n=this.evaluate(e.object,t);let r,s;if(e.computed){if("SliceExpression"===e.property.type)return this.evaluateSliceExpression(n,e.property,t);r=this.evaluate(e.property,t)}else r=new X(e.property.value);if(n instanceof Y){if(!(r instanceof X))throw new Error(`Cannot access property with non-string: got ${r.type}`);s=n.value.get(r.value)??n.builtins.get(r.value)}else if(n instanceof ee||n instanceof X)if(r instanceof Q)s=n.value.at(r.value),n instanceof X&&(s=new X(n.value.at(r.value)));else{if(!(r instanceof X))throw new Error(`Cannot access property with non-string/non-number: got ${r.type}`);s=n.builtins.get(r.value)}else{if(!(r instanceof X))throw new Error(`Cannot access property with non-string: got ${r.type}`);s=n.builtins.get(r.value)}return s instanceof H?s:new se}evaluateSet(e,t){const n=e.value?this.evaluate(e.value,t):this.evaluateBlock(e.body,t);if("Identifier"===e.assignee.type){const r=e.assignee.value;t.setVariable(r,n)}else if("TupleLiteral"===e.assignee.type){const r=e.assignee;if(!(n instanceof ee))throw new Error(`Cannot unpack non-iterable type in set: ${n.type}`);const s=n.value;if(s.length!==r.value.length)throw new Error(`Too ${r.value.length>s.length?"few":"many"} items to unpack in set`);for(let e=0;e<r.value.length;++e){const n=r.value[e];if("Identifier"!==n.type)throw new Error(`Cannot unpack to non-identifier in set: ${n.type}`);t.setVariable(n.value,s[e])}}else{if("MemberExpression"!==e.assignee.type)throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(e.assignee)}`);{const r=e.assignee,s=this.evaluate(r.object,t);if(!(s instanceof Y))throw new Error("Cannot assign to member of non-object");if("Identifier"!==r.property.type)throw new Error("Cannot assign to member with non-identifier property");s.value.set(r.property.value,n)}}return new re}evaluateIf(e,t){const n=this.evaluate(e.test,t);return this.evaluateBlock(n.__bool__().value?e.body:e.alternate,t)}evaluateFor(e,t){const n=new oe(t);let r,s;if("SelectExpression"===e.iterable.type){const t=e.iterable;s=this.evaluate(t.lhs,n),r=t.test}else s=this.evaluate(e.iterable,n);if(!(s instanceof ee||s instanceof Y))throw new Error(`Expected iterable or object type in for loop: got ${s.type}`);s instanceof Y&&(s=s.keys());const o=[],a=[];for(let t=0;t<s.value.length;++t){const i=new oe(n),l=s.value[t];let d;if("Identifier"===e.loopvar.type)d=t=>t.setVariable(e.loopvar.value,l);else{if("TupleLiteral"!==e.loopvar.type)throw new Error(`Invalid loop variable(s): ${e.loopvar.type}`);{const t=e.loopvar;if("ArrayValue"!==l.type)throw new Error(`Cannot unpack non-iterable type: ${l.type}`);const n=l;if(t.value.length!==n.value.length)throw new Error(`Too ${t.value.length>n.value.length?"few":"many"} items to unpack`);d=e=>{for(let r=0;r<t.value.length;++r){if("Identifier"!==t.value[r].type)throw new Error(`Cannot unpack non-identifier type: ${t.value[r].type}`);e.setVariable(t.value[r].value,n.value[r])}}}}if(r){d(i);if(!this.evaluate(r,i).__bool__().value)continue}o.push(l),a.push(d)}let i="",l=!0;for(let t=0;t<o.length;++t){const r=new Map([["index",new Q(t+1)],["index0",new Q(t)],["revindex",new Q(o.length-t)],["revindex0",new Q(o.length-t-1)],["first",new J(0===t)],["last",new J(t===o.length-1)],["length",new Q(o.length)],["previtem",t>0?o[t-1]:new se],["nextitem",t<o.length-1?o[t+1]:new se]]);n.setVariable("loop",new Y(r)),a[t](n);try{i+=this.evaluateBlock(e.body,n).value}catch(e){if(e instanceof W)continue;if(e instanceof U)break;throw e}l=!1}if(l){i+=this.evaluateBlock(e.defaultBlock,n).value}return new X(i)}evaluateMacro(e,t){return t.setVariable(e.name.value,new ne(((t,n)=>{const r=new oe(n);let s;t=t.slice(),"KeywordArgumentsValue"===t.at(-1)?.type&&(s=t.pop());for(let n=0;n<e.args.length;++n){const o=e.args[n],a=t[n];if("Identifier"===o.type){const e=o;if(!a)throw new Error(`Missing positional argument: ${e.value}`);r.setVariable(e.value,a)}else{if("KeywordArgumentExpression"!==o.type)throw new Error(`Unknown argument type: ${o.type}`);{const e=o,t=a??s?.value.get(e.key.value)??this.evaluate(e.value,r);r.setVariable(e.key.value,t)}}}return this.evaluateBlock(e.body,r)}))),new re}evaluateCallStatement(e,t){const n=new ne(((t,n)=>{const r=new oe(n);if(e.callerArgs)for(let n=0;n<e.callerArgs.length;++n){const s=e.callerArgs[n];if("Identifier"!==s.type)throw new Error(`Caller parameter must be an identifier, got ${s.type}`);r.setVariable(s.value,t[n]??new se)}return this.evaluateBlock(e.body,r)})),[r,s]=this.evaluateArguments(e.call.args,t);r.push(new Z(s));const o=this.evaluate(e.call.callee,t);if("FunctionValue"!==o.type)throw new Error(`Cannot call something that is not a function: got ${o.type}`);const a=new oe(t);return a.setVariable("caller",n),o.value(r,a)}evaluateFilterStatement(e,t){const n=this.evaluateBlock(e.body,t);return this.applyFilter(n,e.filter,t)}evaluate(e,t){if(!e)return new se;switch(e.type){case"Program":return this.evalProgram(e,t);case"Set":return this.evaluateSet(e,t);case"If":return this.evaluateIf(e,t);case"For":return this.evaluateFor(e,t);case"Macro":return this.evaluateMacro(e,t);case"CallStatement":return this.evaluateCallStatement(e,t);case"Break":throw new U;case"Continue":throw new W;case"IntegerLiteral":return new Q(e.value);case"FloatLiteral":return new K(e.value);case"StringLiteral":return new X(e.value);case"ArrayLiteral":return new ee(e.value.map((e=>this.evaluate(e,t))));case"TupleLiteral":return new te(e.value.map((e=>this.evaluate(e,t))));case"ObjectLiteral":{const n=new Map;for(const[r,s]of e.value){const e=this.evaluate(r,t);if(!(e instanceof X))throw new Error(`Object keys must be strings: got ${e.type}`);n.set(e.value,this.evaluate(s,t))}return new Y(n)}case"Identifier":return this.evaluateIdentifier(e,t);case"CallExpression":return this.evaluateCallExpression(e,t);case"MemberExpression":return this.evaluateMemberExpression(e,t);case"UnaryExpression":return this.evaluateUnaryExpression(e,t);case"BinaryExpression":return this.evaluateBinaryExpression(e,t);case"FilterExpression":return this.evaluateFilterExpression(e,t);case"FilterStatement":return this.evaluateFilterStatement(e,t);case"TestExpression":return this.evaluateTestExpression(e,t);case"SelectExpression":return this.evaluateSelectExpression(e,t);case"Ternary":return this.evaluateTernaryExpression(e,t);case"Comment":return new re;default:throw new SyntaxError(`Unknown node type: ${e.type}`)}}};function ie(e){switch(typeof e){case"number":return Number.isInteger(e)?new Q(e):new K(e);case"string":return new X(e);case"boolean":return new J(e);case"undefined":return new se;case"object":return null===e?new re:Array.isArray(e)?new ee(e.map(ie)):new Y(new Map(Object.entries(e).map((([e,t])=>[e,ie(t)]))));case"function":return new ne(((t,n)=>ie(e(...t.map((e=>e.value)))??null)));default:throw new Error(`Cannot convert to runtime value: ${e}`)}}function le(e,t,n){const r=n??0;switch(e.type){case"NullValue":case"UndefinedValue":return"null";case"IntegerValue":case"FloatValue":case"StringValue":case"BooleanValue":return JSON.stringify(e.value);case"ArrayValue":case"ObjectValue":{const n=t?" ".repeat(t):"",s="\n"+n.repeat(r),o=s+n;if("ArrayValue"===e.type){const n=e.value.map((e=>le(e,t,r+1)));return t?`[${o}${n.join(`,${o}`)}${s}]`:`[${n.join(", ")}]`}{const n=Array.from(e.value.entries()).map((([e,n])=>{const s=`"${e}": ${le(n,t,r+1)}`;return t?`${o}${s}`:s}));return t?`{${n.join(",")}${s}}`:`{${n.join(", ")}}`}}default:throw new Error(`Cannot convert to JSON: ${e.type}`)}}var de="\n",ue="{%- ",ce=" -%}";function pe(...e){return ue+e.join(" ")+ce}function me(e,t,n){return e.map((e=>function(e,t,n){const r=n.repeat(t);switch(e.type){case"Program":return me(e.body,t,n);case"If":return function(e,t,n){const r=n.repeat(t),s=[];let o=e;for(;o&&(s.push({test:o.test,body:o.body}),1===o.alternate.length&&"If"===o.alternate[0].type);)o=o.alternate[0];let a=r+pe("if",he(s[0].test))+de+me(s[0].body,t+1,n);for(let e=1;e<s.length;++e)a+=de+r+pe("elif",he(s[e].test))+de+me(s[e].body,t+1,n);o&&o.alternate.length>0&&(a+=de+r+pe("else")+de+me(o.alternate,t+1,n));return a+=de+r+pe("endif"),a}(e,t,n);case"For":return function(e,t,n){const r=n.repeat(t);let s="";if("SelectExpression"===e.iterable.type){const t=e.iterable;s=`${he(t.lhs)} if ${he(t.test)}`}else s=he(e.iterable);let o=r+pe("for",he(e.loopvar),"in",s)+de+me(e.body,t+1,n);e.defaultBlock.length>0&&(o+=de+r+pe("else")+de+me(e.defaultBlock,t+1,n));return o+=de+r+pe("endfor"),o}(e,t,n);case"Set":return function(e,t,n){const r=n.repeat(t),s=he(e.assignee),o=e.value?he(e.value):"",a=r+pe("set",`${s}${e.value?" = "+o:""}`);if(0===e.body.length)return a;return a+de+me(e.body,t+1,n)+de+r+pe("endset")}(e,t,n);case"Macro":return function(e,t,n){const r=n.repeat(t),s=e.args.map(he).join(", ");return r+pe("macro",`${e.name.value}(${s})`)+de+me(e.body,t+1,n)+de+r+pe("endmacro")}(e,t,n);case"Break":return r+pe("break");case"Continue":return r+pe("continue");case"CallStatement":return function(e,t,n){const r=n.repeat(t),s=e.callerArgs&&e.callerArgs.length>0?`(${e.callerArgs.map(he).join(", ")})`:"",o=he(e.call);let a=r+pe(`call${s}`,o)+de;return a+=me(e.body,t+1,n)+de,a+=r+pe("endcall"),a}(e,t,n);case"FilterStatement":return function(e,t,n){const r=n.repeat(t),s="Identifier"===e.filter.type?e.filter.value:he(e.filter);let o=r+pe("filter",s)+de;return o+=me(e.body,t+1,n)+de,o+=r+pe("endfilter"),o}(e,t,n);case"Comment":return r+"{# "+e.value+" #}";default:return r+"{{- "+he(e)+" -}}"}}(e,t,n))).join(de)}function he(e,t=-1){switch(e.type){case"SpreadExpression":return`*${he(e.argument)}`;case"Identifier":return e.value;case"IntegerLiteral":case"FloatLiteral":return`${e.value}`;case"StringLiteral":return JSON.stringify(e.value);case"BinaryExpression":{const n=e,r=function(e){switch(e.operator.type){case"MultiplicativeBinaryOperator":return 4;case"AdditiveBinaryOperator":return 3;case"ComparisonBinaryOperator":return 2;case"Identifier":return"and"===e.operator.value?1:"in"===e.operator.value||"not in"===e.operator.value?2:0}return 0}(n),s=he(n.left,r),o=he(n.right,r+1),a=`${s} ${n.operator.value} ${o}`;return r<t?`(${a})`:a}case"UnaryExpression":{const t=e;return t.operator.value+("not"===t.operator.value?" ":"")+he(t.argument,1/0)}case"CallExpression":{const t=e,n=t.args.map(he).join(", ");return`${he(t.callee)}(${n})`}case"MemberExpression":{const t=e;let n=he(t.object);["Identifier","MemberExpression","CallExpression","StringLiteral","IntegerLiteral","FloatLiteral","ArrayLiteral","TupleLiteral","ObjectLiteral"].includes(t.object.type)||(n=`(${n})`);let r=he(t.property);return t.computed||"Identifier"===t.property.type||(r=`(${r})`),t.computed?`${n}[${r}]`:`${n}.${r}`}case"FilterExpression":{const t=e,n=he(t.operand,1/0);return"CallExpression"===t.filter.type?`${n} | ${he(t.filter)}`:`${n} | ${t.filter.value}`}case"SelectExpression":{const t=e;return`${he(t.lhs)} if ${he(t.test)}`}case"TestExpression":{const t=e;return`${he(t.operand)} is${t.negate?" not":""} ${t.test.value}`}case"ArrayLiteral":case"TupleLiteral":{const t=e.value.map(he),n="ArrayLiteral"===e.type?"[]":"()";return`${n[0]}${t.join(", ")}${n[1]}`}case"ObjectLiteral":return`{${Array.from(e.value.entries()).map((([e,t])=>`${he(e)}: ${he(t)}`)).join(", ")}}`;case"SliceExpression":{const t=e;return`${t.start?he(t.start):""}:${t.stop?he(t.stop):""}${t.step?`:${he(t.step)}`:""}`}case"KeywordArgumentExpression":{const t=e;return`${t.key.value}=${he(t.value)}`}case"Ternary":{const n=e,r=`${he(n.trueExpr)} if ${he(n.condition,0)} else ${he(n.falseExpr)}`;return t>-1?`(${r})`:r}default:throw new Error(`Unknown expression type: ${e.type}`)}}var fe=class{parsed;constructor(e){const t=d(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=j(t)}render(e){const t=new oe;if(function(e){e.set("false",!1),e.set("true",!0),e.set("none",null),e.set("raise_exception",(e=>{throw new Error(e)})),e.set("range",V),e.set("strftime_now",q),e.set("True",!0),e.set("False",!1),e.set("None",null)}(t),e)for(const[n,r]of Object.entries(e))t.set(n,r);return new ae(t).run(this.parsed).value}format(e){return function(e,t="\t"){const n="number"==typeof t?" ".repeat(t):t;return me(e.body,0,n).replace(/\n$/,"")}(this.parsed,e?.indent||"\t")}}},"./node_modules/onnxruntime-common/dist/esm/backend-impl.js":(e,t,n)=>{n.r(t),n.d(t,{registerBackend:()=>o,resolveBackendAndExecutionProviders:()=>i});const r=new Map,s=[],o=(e,t,n)=>{if(!t||"function"!=typeof t.init||"function"!=typeof t.createInferenceSessionHandler)throw new TypeError("not a valid backend");{const o=r.get(e);if(void 0===o)r.set(e,{backend:t,priority:n});else{if(o.priority>n)return;if(o.priority===n&&o.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){const t=s.indexOf(e);-1!==t&&s.splice(t,1);for(let t=0;t<s.length;t++)if(r.get(s[t]).priority<=n)return void s.splice(t,0,e);s.push(e)}}},a=async e=>{const t=r.get(e);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{const n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},i=async e=>{const t=e.executionProviders||[],n=t.map((e=>"string"==typeof e?e:e.name)),r=0===n.length?s:n;let o;const i=[],l=new Set;for(const e of r){const t=await a(e);"string"==typeof t?i.push({name:e,err:t}):(o||(o=t),o===t&&l.add(e))}if(!o)throw new Error(`no available backend found. ERR: ${i.map((e=>`[${e.name}] ${e.err}`)).join(", ")}`);for(const{name:e,err:t}of i)n.includes(e)&&console.warn(`removing requested execution provider "${e}" from session options because it is not available: ${t}`);const d=t.filter((e=>l.has("string"==typeof e?e:e.name)));return[o,new Proxy(e,{get:(e,t)=>"executionProviders"===t?d:Reflect.get(e,t)})]}},"./node_modules/onnxruntime-common/dist/esm/backend.js":(e,t,n)=>{n.r(t),n.d(t,{registerBackend:()=>r.registerBackend});var r=n("./node_modules/onnxruntime-common/dist/esm/backend-impl.js")},"./node_modules/onnxruntime-common/dist/esm/env-impl.js":(e,t,n)=>{n.r(t),n.d(t,{env:()=>o});var r=n("./node_modules/onnxruntime-common/dist/esm/version.js");let s="warning";const o={wasm:{},webgl:{},webgpu:{},versions:{common:r.version},set logLevel(e){if(void 0!==e){if("string"!=typeof e||-1===["verbose","info","warning","error","fatal"].indexOf(e))throw new Error(`Unsupported logging level: ${e}`);s=e}},get logLevel(){return s}};Object.defineProperty(o,"logLevel",{enumerable:!0})},"./node_modules/onnxruntime-common/dist/esm/env.js":(e,t,n)=>{n.r(t),n.d(t,{env:()=>r});const r=n("./node_modules/onnxruntime-common/dist/esm/env-impl.js").env},"./node_modules/onnxruntime-common/dist/esm/index.js":(e,t,n)=>{n.r(t),n.d(t,{InferenceSession:()=>o.InferenceSession,TRACE:()=>i.TRACE,TRACE_FUNC_BEGIN:()=>i.TRACE_FUNC_BEGIN,TRACE_FUNC_END:()=>i.TRACE_FUNC_END,Tensor:()=>a.Tensor,env:()=>s.env,registerBackend:()=>r.registerBackend});var r=n("./node_modules/onnxruntime-common/dist/esm/backend.js"),s=n("./node_modules/onnxruntime-common/dist/esm/env.js"),o=n("./node_modules/onnxruntime-common/dist/esm/inference-session.js"),a=n("./node_modules/onnxruntime-common/dist/esm/tensor.js"),i=(n("./node_modules/onnxruntime-common/dist/esm/tensor-conversion.js"),n("./node_modules/onnxruntime-common/dist/esm/tensor-factory.js"),n("./node_modules/onnxruntime-common/dist/esm/trace.js"));n("./node_modules/onnxruntime-common/dist/esm/onnx-model.js"),n("./node_modules/onnxruntime-common/dist/esm/onnx-value.js")},"./node_modules/onnxruntime-common/dist/esm/inference-session-impl.js":(e,t,n)=>{n.r(t),n.d(t,{InferenceSession:()=>a});var r=n("./node_modules/onnxruntime-common/dist/esm/backend-impl.js"),s=n("./node_modules/onnxruntime-common/dist/esm/tensor.js"),o=n("./node_modules/onnxruntime-common/dist/esm/trace.js");class a{constructor(e){this.handler=e}async run(e,t,n){(0,o.TRACE_FUNC_BEGIN)();const r={};let a={};if("object"!=typeof e||null===e||e instanceof s.Tensor||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let i=!0;if("object"==typeof t){if(null===t)throw new TypeError("Unexpected argument[1]: cannot be null.");if(t instanceof s.Tensor)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(t)){if(0===t.length)throw new TypeError("'fetches' cannot be an empty array.");i=!1;for(const e of t){if("string"!=typeof e)throw new TypeError("'fetches' must be a string array or an object.");if(-1===this.outputNames.indexOf(e))throw new RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if("object"==typeof n&&null!==n)a=n;else if(void 0!==n)throw new TypeError("'options' must be an object.")}else{let e=!1;const o=Object.getOwnPropertyNames(t);for(const n of this.outputNames)if(-1!==o.indexOf(n)){const o=t[n];(null===o||o instanceof s.Tensor)&&(e=!0,i=!1,r[n]=o)}if(e){if("object"==typeof n&&null!==n)a=n;else if(void 0!==n)throw new TypeError("'options' must be an object.")}else a=t}}else if(void 0!==t)throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const t of this.inputNames)if(void 0===e[t])throw new Error(`input '${t}' is missing in 'feeds'.`);if(i)for(const e of this.outputNames)r[e]=null;const l=await this.handler.run(e,r,a),d={};for(const e in l)if(Object.hasOwnProperty.call(l,e)){const t=l[e];t instanceof s.Tensor?d[e]=t:d[e]=new s.Tensor(t.type,t.data,t.dims)}return(0,o.TRACE_FUNC_END)(),d}async release(){return this.handler.dispose()}static async create(e,t,n,s){let i;(0,o.TRACE_FUNC_BEGIN)();let l={};if("string"==typeof e){if(i=e,"object"==typeof t&&null!==t)l=t;else if(void 0!==t)throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(i=e,"object"==typeof t&&null!==t)l=t;else if(void 0!==t)throw new TypeError("'options' must be an object.")}else{if(!(e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{const r=e;let o=0,a=e.byteLength;if("object"==typeof t&&null!==t)l=t;else if("number"==typeof t){if(o=t,!Number.isSafeInteger(o))throw new RangeError("'byteOffset' must be an integer.");if(o<0||o>=r.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${r.byteLength}).`);if(a=e.byteLength-o,"number"==typeof n){if(a=n,!Number.isSafeInteger(a))throw new RangeError("'byteLength' must be an integer.");if(a<=0||o+a>r.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${r.byteLength-o}].`);if("object"==typeof s&&null!==s)l=s;else if(void 0!==s)throw new TypeError("'options' must be an object.")}else if(void 0!==n)throw new TypeError("'byteLength' must be a number.")}else if(void 0!==t)throw new TypeError("'options' must be an object.");i=new Uint8Array(r,o,a)}}const[d,u]=await(0,r.resolveBackendAndExecutionProviders)(l),c=await d.createInferenceSessionHandler(i,u);return(0,o.TRACE_FUNC_END)(),new a(c)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}},