Source code

Revision control

Copy as Markdown

Other Tools

import*as e from"chrome://global/content/ml/ort.webgpu.mjs";var t={"#onnxruntime-webgpu":
/*!************************************************************!*\
!*** external "chrome://global/content/ml/ort.webgpu.mjs" ***!
\************************************************************/t=>{t.exports=e},"?7a2c":
/*!********************!*\
!*** fs (ignored) ***!
\********************/()=>{},"?a42a":
/*!**********************!*\
!*** path (ignored) ***!
\**********************/()=>{},"?2b25":
/*!***********************!*\
!*** sharp (ignored) ***!
\***********************/()=>{},"?569f":
/*!********************!*\
!*** fs (ignored) ***!
\********************/()=>{},"?3f59":
/*!**********************!*\
!*** path (ignored) ***!
\**********************/()=>{},"?154a":
/*!*********************!*\
!*** url (ignored) ***!
\*********************/()=>{},"./node_modules/@huggingface/jinja/dist/index.js":
/*!*******************************************************!*\
!*** ./node_modules/@huggingface/jinja/dist/index.js ***!
\*******************************************************/(e,t,r)=>{r.r(t),r.d(t,{Environment:()=>Y,Interpreter:()=>J,Template:()=>ee,parse:()=>B,tokenize:()=>d});var n=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",BooleanLiteral:"BooleanLiteral",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",Set:"Set",If:"If",For:"For",In:"In",Is:"Is",NotIn:"NotIn",Else:"Else",EndIf:"EndIf",ElseIf:"ElseIf",EndFor:"EndFor",And:"And",Or:"Or",Not:"UnaryOperator",Macro:"Macro",EndMacro:"EndMacro"}),o=Object.freeze({set:n.Set,for:n.For,in:n.In,is:n.Is,if:n.If,else:n.Else,endif:n.EndIf,elif:n.ElseIf,endfor:n.EndFor,and:n.And,or:n.Or,not:n.Not,"not in":n.NotIn,macro:n.Macro,endmacro:n.EndMacro,true:n.BooleanLiteral,false:n.BooleanLiteral,True:n.BooleanLiteral,False:n.BooleanLiteral}),s=class{constructor(e,t){this.value=e,this.type=t}};function a(e){return/\w/.test(e)}function i(e){return/[0-9]/.test(e)}var l=[["{%",n.OpenStatement],["%}",n.CloseStatement],["{{",n.OpenExpression],["}}",n.CloseExpression],["(",n.OpenParen],[")",n.CloseParen],["{",n.OpenCurlyBracket],["}",n.CloseCurlyBracket],["[",n.OpenSquareBracket],["]",n.CloseSquareBracket],[",",n.Comma],[".",n.Dot],[":",n.Colon],["|",n.Pipe],["<=",n.ComparisonBinaryOperator],[">=",n.ComparisonBinaryOperator],["==",n.ComparisonBinaryOperator],["!=",n.ComparisonBinaryOperator],["<",n.ComparisonBinaryOperator],[">",n.ComparisonBinaryOperator],["+",n.AdditiveBinaryOperator],["-",n.AdditiveBinaryOperator],["*",n.MultiplicativeBinaryOperator],["/",n.MultiplicativeBinaryOperator],["%",n.MultiplicativeBinaryOperator],["=",n.Equals]],c=new Map([["n","\n"],["t","\t"],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function d(e,t={}){const r=[],d=function(e,t={}){return e.endsWith("\n")&&(e=e.slice(0,-1)),e=e.replace(/{#.*?#}/gs,"{##}"),t.lstrip_blocks&&(e=e.replace(/^[ \t]*({[#%])/gm,"$1")),t.trim_blocks&&(e=e.replace(/([#%]})\n/g,"$1")),e.replace(/{##}/g,"").replace(/-%}\s*/g,"%}").replace(/\s*{%-/g,"{%").replace(/-}}\s*/g,"}}").replace(/\s*{{-/g,"{{")}(e,t);let u=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++],r=c.get(e);if(void 0===r)throw new SyntaxError(`Unexpected escaped character: ${e}`);t+=r}return t};e:for(;u<d.length;){const e=r.at(-1)?.type;if(void 0===e||e===n.CloseStatement||e===n.CloseExpression){let e="";for(;u<d.length&&("{"!==d[u]||"%"!==d[u+1]&&"{"!==d[u+1]);)e+=d[u++];if(e.length>0){r.push(new s(e,n.Text));continue}}p((e=>/\s/.test(e)));const t=d[u];if("-"===t||"+"===t){const e=r.at(-1)?.type;if(e===n.Text||void 0===e)throw new SyntaxError(`Unexpected character: ${t}`);switch(e){case n.Identifier:case n.NumericLiteral:case n.BooleanLiteral:case n.StringLiteral:case n.CloseParen:case n.CloseSquareBracket:break;default:{++u;const e=p(i);r.push(new s(`${t}${e}`,e.length>0?n.NumericLiteral:n.UnaryOperator));continue}}}for(const[e,t]of l){if(d.slice(u,u+e.length)===e){r.push(new s(e,t)),u+=e.length;continue e}}if("'"!==t&&'"'!==t)if(i(t)){const e=p(i);r.push(new s(e,n.NumericLiteral))}else{if(!a(t))throw new SyntaxError(`Unexpected character: ${t}`);{const e=p(a),t=Object.hasOwn(o,e)?o[e]:n.Identifier;t===n.In&&r.at(-1)?.type===n.Not?(r.pop(),r.push(new s("not in",n.NotIn))):r.push(new s(e,t))}}else{++u;const e=p((e=>e!==t));r.push(new s(e,n.StringLiteral)),++u}}return r}var u=class{type="Statement"},p=class extends u{constructor(e){super(),this.body=e}type="Program"},h=class extends u{constructor(e,t,r){super(),this.test=e,this.body=t,this.alternate=r}type="If"},m=class extends u{constructor(e,t,r,n){super(),this.loopvar=e,this.iterable=t,this.body=r,this.defaultBlock=n}type="For"},_=class extends u{constructor(e,t){super(),this.assignee=e,this.value=t}type="Set"},f=class extends u{constructor(e,t,r){super(),this.name=e,this.args=t,this.body=r}type="Macro"},g=class extends u{type="Expression"},M=class extends g{constructor(e,t,r){super(),this.object=e,this.property=t,this.computed=r}type="MemberExpression"},w=class extends g{constructor(e,t){super(),this.callee=e,this.args=t}type="CallExpression"},T=class extends g{constructor(e){super(),this.value=e}type="Identifier"},b=class extends g{constructor(e){super(),this.value=e}type="Literal"},x=class extends b{type="NumericLiteral"},k=class extends b{type="StringLiteral"},y=class extends b{type="BooleanLiteral"},F=class extends b{type="ArrayLiteral"},P=class extends b{type="TupleLiteral"},C=class extends b{type="ObjectLiteral"},v=class extends g{constructor(e,t,r){super(),this.operator=e,this.left=t,this.right=r}type="BinaryExpression"},S=class extends g{constructor(e,t){super(),this.operand=e,this.filter=t}type="FilterExpression"},A=class extends g{constructor(e,t){super(),this.iterable=e,this.test=t}type="SelectExpression"},E=class extends g{constructor(e,t,r){super(),this.operand=e,this.negate=t,this.test=r}type="TestExpression"},L=class extends g{constructor(e,t){super(),this.operator=e,this.argument=t}type="UnaryExpression"},z=class extends g{constructor(e=void 0,t=void 0,r=void 0){super(),this.start=e,this.stop=t,this.step=r}type="SliceExpression"},I=class extends g{constructor(e,t){super(),this.key=e,this.value=t}type="KeywordArgumentExpression"};function B(e){const t=new p([]);let r=0;function o(t,n){const o=e[r++];if(!o||o.type!==t)throw new Error(`Parser Error: ${n}. ${o.type} !== ${t}.`);return o}function s(){switch(e[r].type){case n.Text:return new k(o(n.Text,"Expected text token").value);case n.OpenStatement:return function(){let t;switch(o(n.OpenStatement,"Expected opening statement token"),e[r].type){case n.Set:++r,t=l(),o(n.CloseStatement,"Expected closing statement token");break;case n.If:++r,t=c(),o(n.OpenStatement,"Expected {% token"),o(n.EndIf,"Expected endif token"),o(n.CloseStatement,"Expected %} token");break;case n.Macro:++r,t=function(){const e=q();if("Identifier"!==e.type)throw new SyntaxError("Expected identifier following macro statement");const t=V();o(n.CloseStatement,"Expected closing statement token");const r=[];for(;a(n.OpenStatement,n.EndMacro);)r.push(s());return new f(e,t,r)}(),o(n.OpenStatement,"Expected {% token"),o(n.EndMacro,"Expected endmacro token"),o(n.CloseStatement,"Expected %} token");break;case n.For:++r,t=function(){const e=d(!0);if(!(e instanceof T||e instanceof P))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${e.type} instead`);o(n.In,"Expected `in` keyword following loop variable");const t=u();o(n.CloseStatement,"Expected closing statement token");const l=[];for(;a(n.OpenStatement,n.EndFor)&&a(n.OpenStatement,n.Else);)l.push(s());const c=[];if(i(n.OpenStatement,n.Else))for(++r,++r,o(n.CloseStatement,"Expected closing statement token");a(n.OpenStatement,n.EndFor);)c.push(s());return new m(e,t,l,c)}(),o(n.OpenStatement,"Expected {% token"),o(n.EndFor,"Expected endfor token"),o(n.CloseStatement,"Expected %} token");break;default:throw new SyntaxError(`Unknown statement type: ${e[r].type}`)}return t}();case n.OpenExpression:return function(){o(n.OpenExpression,"Expected opening expression token");const e=u();return o(n.CloseExpression,"Expected closing expression token"),e}();default:throw new SyntaxError(`Unexpected token type: ${e[r].type}`)}}function a(...t){return r+t.length<=e.length&&t.some(((t,n)=>t!==e[r+n].type))}function i(...t){return r+t.length<=e.length&&t.every(((t,n)=>t===e[r+n].type))}function l(){const e=u();if(i(n.Equals)){++r;const t=l();return new _(e,t)}return e}function c(){const t=u();o(n.CloseStatement,"Expected closing statement token");const a=[],l=[];for(;e[r]?.type!==n.OpenStatement||e[r+1]?.type!==n.ElseIf&&e[r+1]?.type!==n.Else&&e[r+1]?.type!==n.EndIf;)a.push(s());if(e[r]?.type===n.OpenStatement&&e[r+1]?.type!==n.EndIf)if(++r,i(n.ElseIf))o(n.ElseIf,"Expected elseif token"),l.push(c());else for(o(n.Else,"Expected else token"),o(n.CloseStatement,"Expected closing statement token");e[r]?.type!==n.OpenStatement||e[r+1]?.type!==n.EndIf;)l.push(s());return new h(t,a,l)}function d(e=!1){const t=e?q:u,o=[t()],s=i(n.Comma);for(;s&&(++r,o.push(t()),i(n.Comma)););return s?new P(o):o[0]}function u(){return function(){const e=g();if(i(n.If)){++r;const t=g();if(i(n.Else)){++r;const n=g();return new h(t,[e],[n])}return new A(e,t)}return e}()}function g(){let t=b();for(;i(n.Or);){const n=e[r];++r;const o=b();t=new v(n,t,o)}return t}function b(){let t=B();for(;i(n.And);){const n=e[r];++r;const o=B();t=new v(n,t,o)}return t}function B(){let t;for(;i(n.Not);){const n=e[r];++r;const o=B();t=new L(n,o)}return t??function(){let t=N();for(;i(n.ComparisonBinaryOperator)||i(n.In)||i(n.NotIn);){const n=e[r];++r;const o=N();t=new v(n,t,o)}return t}()}function N(){let t=R();for(;i(n.AdditiveBinaryOperator);){const n=e[r];++r;const o=R();t=new v(n,t,o)}return t}function O(){const t=function(){let t=q();for(;i(n.Dot)||i(n.OpenSquareBracket);){const s=e[r];let a;++r;const i=s.type!==n.Dot;if(i)a=j(),o(n.CloseSquareBracket,"Expected closing square bracket");else if(a=q(),"Identifier"!==a.type)throw new SyntaxError("Expected identifier following dot operator");t=new M(t,a,i)}return t}();return i(n.OpenParen)?D(t):t}function D(e){let t=new w(e,V());return i(n.OpenParen)&&(t=D(t)),t}function V(){o(n.OpenParen,"Expected opening parenthesis for arguments list");const e=function(){const e=[];for(;!i(n.CloseParen);){let t=u();if(i(n.Equals)){if(++r,!(t instanceof T))throw new SyntaxError("Expected identifier for keyword argument");const e=u();t=new I(t,e)}e.push(t),i(n.Comma)&&++r}return e}();return o(n.CloseParen,"Expected closing parenthesis for arguments list"),e}function j(){const e=[];let t=!1;for(;!i(n.CloseSquareBracket);)i(n.Colon)?(e.push(void 0),++r,t=!0):(e.push(u()),i(n.Colon)&&(++r,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 z(...e)}return e[0]}function R(){let t=G();for(;i(n.MultiplicativeBinaryOperator);){const n=e[r];++r;const o=G();t=new v(n,t,o)}return t}function G(){let e=function(){let e=O();for(;i(n.Pipe);){++r;let t=q();if(!(t instanceof T))throw new SyntaxError("Expected identifier for the filter");i(n.OpenParen)&&(t=D(t)),e=new S(e,t)}return e}();for(;i(n.Is);){++r;const t=i(n.Not);t&&++r;let o=q();if(o instanceof y&&(o=new T(o.value.toString())),!(o instanceof T))throw new SyntaxError("Expected identifier for the test");e=new E(e,t,o)}return e}function q(){const t=e[r];switch(t.type){case n.NumericLiteral:return++r,new x(Number(t.value));case n.StringLiteral:return++r,new k(t.value);case n.BooleanLiteral:return++r,new y("true"===t.value.toLowerCase());case n.Identifier:return++r,new T(t.value);case n.OpenParen:{++r;const t=d();if(e[r].type!==n.CloseParen)throw new SyntaxError(`Expected closing parenthesis, got ${e[r].type} instead`);return++r,t}case n.OpenSquareBracket:{++r;const e=[];for(;!i(n.CloseSquareBracket);)e.push(u()),i(n.Comma)&&++r;return++r,new F(e)}case n.OpenCurlyBracket:{++r;const e=new Map;for(;!i(n.CloseCurlyBracket);){const t=u();o(n.Colon,"Expected colon between key and value in object literal");const s=u();e.set(t,s),i(n.Comma)&&++r}return++r,new C(e)}default:throw new SyntaxError(`Unexpected token: ${t.type}`)}}for(;r<e.length;)t.body.push(s());return t}function N(e,t,r=1){void 0===t&&(t=e,e=0);const n=[];for(let o=e;o<t;o+=r)n.push(o);return n}function O(e,t,r,n=1){const o=Math.sign(n);o>=0?(t=(t??=0)<0?Math.max(e.length+t,0):Math.min(t,e.length),r=(r??=e.length)<0?Math.max(e.length+r,0):Math.min(r,e.length)):(t=(t??=e.length-1)<0?Math.max(e.length+t,-1):Math.min(t,e.length-1),r=(r??=-1)<-1?Math.max(e.length+r,-1):Math.min(r,e.length-1));const s=[];for(let a=t;o*a<o*r;a+=n)s.push(e[a]);return s}function D(e){return e.replace(/\b\w/g,(e=>e.toUpperCase()))}var V=class{type="RuntimeValue";value;builtins=new Map;constructor(e=void 0){this.value=e}__bool__(){return new G(!!this.value)}},j=class extends V{type="NumericValue"},R=class extends V{type="StringValue";builtins=new Map([["upper",new X((()=>new R(this.value.toUpperCase())))],["lower",new X((()=>new R(this.value.toLowerCase())))],["strip",new X((()=>new R(this.value.trim())))],["title",new X((()=>new R(D(this.value))))],["length",new j(this.value.length)]])},G=class extends V{type="BooleanValue"},q=class extends V{type="ObjectValue";__bool__(){return new G(this.value.size>0)}builtins=new Map([["get",new X((([e,t])=>{if(!(e instanceof R))throw new Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new Q}))],["items",new X((()=>new W(Array.from(this.value.entries()).map((([e,t])=>new W([new R(e),t]))))))]])},$=class extends q{type="KeywordArgumentsValue"},W=class extends V{type="ArrayValue";builtins=new Map([["length",new j(this.value.length)]]);__bool__(){return new G(this.value.length>0)}},U=class extends W{type="TupleValue"},X=class extends V{type="FunctionValue"},Q=class extends V{type="NullValue"},H=class extends V{type="UndefinedValue"},Y=class{constructor(e){this.parent=e}variables=new Map([["namespace",new X((e=>{if(0===e.length)return new q(new Map);if(1!==e.length||!(e[0]instanceof q))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 X],["odd",e=>{if("NumericValue"!==e.type)throw new Error(`Cannot apply test "odd" to type: ${e.type}`);return e.value%2!=0}],["even",e=>{if("NumericValue"!==e.type)throw new Error(`Cannot apply test "even" to type: ${e.type}`);return e.value%2==0}],["false",e=>"BooleanValue"===e.type&&!e.value],["true",e=>"BooleanValue"===e.type&&e.value],["string",e=>"StringValue"===e.type],["number",e=>"NumericValue"===e.type],["integer",e=>"NumericValue"===e.type&&Number.isInteger(e.value)],["iterable",e=>e instanceof W||e instanceof R],["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,K(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 H}catch{return new H}}},J=class{global;constructor(e){this.global=e??new Y}run(e){return this.evaluate(e,this.global)}evaluateBinaryExpression(e,t){const r=this.evaluate(e.left,t);switch(e.operator.value){case"and":return r.__bool__().value?this.evaluate(e.right,t):r;case"or":return r.__bool__().value?r:this.evaluate(e.right,t)}const n=this.evaluate(e.right,t);switch(e.operator.value){case"==":return new G(r.value==n.value);case"!=":return new G(r.value!=n.value)}if(r instanceof H||n instanceof H)throw new Error("Cannot perform operation on undefined values");if(r instanceof Q||n instanceof Q)throw new Error("Cannot perform operation on null values");if(r instanceof j&&n instanceof j)switch(e.operator.value){case"+":return new j(r.value+n.value);case"-":return new j(r.value-n.value);case"*":return new j(r.value*n.value);case"/":return new j(r.value/n.value);case"%":return new j(r.value%n.value);case"<":return new G(r.value<n.value);case">":return new G(r.value>n.value);case">=":return new G(r.value>=n.value);case"<=":return new G(r.value<=n.value)}else if(r instanceof W&&n instanceof W){if("+"===e.operator.value)return new W(r.value.concat(n.value))}else if(n instanceof W){const t=void 0!==n.value.find((e=>e.value===r.value));switch(e.operator.value){case"in":return new G(t);case"not in":return new G(!t)}}if((r instanceof R||n instanceof R)&&"+"===e.operator.value)return new R(r.value.toString()+n.value.toString());if(r instanceof R&&n instanceof R)switch(e.operator.value){case"in":return new G(n.value.includes(r.value));case"not in":return new G(!n.value.includes(r.value))}if(r instanceof R&&n instanceof q)switch(e.operator.value){case"in":return new G(n.value.has(r.value));case"not in":return new G(!n.value.has(r.value))}throw new SyntaxError(`Unknown operator "${e.operator.value}" between ${r.type} and ${n.type}`)}evaluateArguments(e,t){const r=[],n=new Map;for(const o of e)if("KeywordArgumentExpression"===o.type){const e=o;n.set(e.key.value,this.evaluate(e.value,t))}else{if(n.size>0)throw new Error("Positional arguments must come before keyword arguments");r.push(this.evaluate(o,t))}return[r,n]}evaluateFilterExpression(e,t){const r=this.evaluate(e.operand,t);if("Identifier"===e.filter.type){const t=e.filter;if("tojson"===t.value)return new R(Z(r));if(r instanceof W)switch(t.value){case"list":return r;case"first":return r.value[0];case"last":return r.value[r.value.length-1];case"length":return new j(r.value.length);case"reverse":return new W(r.value.reverse());case"sort":return new W(r.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"NumericValue":return e.value-t.value;case"StringValue":return e.value.localeCompare(t.value);default:throw new Error(`Cannot compare type: ${e.type}`)}})));default:throw new Error(`Unknown ArrayValue filter: ${t.value}`)}else if(r instanceof R)switch(t.value){case"length":return new j(r.value.length);case"upper":return new R(r.value.toUpperCase());case"lower":return new R(r.value.toLowerCase());case"title":return new R(D(r.value));case"capitalize":return new R(r.value.charAt(0).toUpperCase()+r.value.slice(1));case"trim":return new R(r.value.trim());case"indent":return new R(r.value.split("\n").map(((e,t)=>0===t||0===e.length?e:" "+e)).join("\n"));case"string":return r;default:throw new Error(`Unknown StringValue filter: ${t.value}`)}else{if(r instanceof j){if("abs"===t.value)return new j(Math.abs(r.value));throw new Error(`Unknown NumericValue filter: ${t.value}`)}if(r instanceof q)switch(t.value){case"items":return new W(Array.from(r.value.entries()).map((([e,t])=>new W([new R(e),t]))));case"length":return new j(r.value.size);default:throw new Error(`Unknown ObjectValue filter: ${t.value}`)}}throw new Error(`Cannot apply filter "${t.value}" to type: ${r.type}`)}if("CallExpression"===e.filter.type){const n=e.filter;if("Identifier"!==n.callee.type)throw new Error(`Unknown filter: ${n.callee.type}`);const o=n.callee.value;if("tojson"===o){const[,e]=this.evaluateArguments(n.args,t),o=e.get("indent")??new Q;if(!(o instanceof j||o instanceof Q))throw new Error("If set, indent must be a number");return new R(Z(r,o.value))}if(r instanceof W){switch(o){case"selectattr":{if(r.value.some((e=>!(e instanceof q))))throw new Error("`selectattr` can only be applied to array of objects");if(n.args.some((e=>"StringLiteral"!==e.type)))throw new Error("arguments of `selectattr` must be strings");const[e,o,s]=n.args.map((e=>this.evaluate(e,t)));let a;if(o){const e=t.tests.get(o.value);if(!e)throw new Error(`Unknown test: ${o.value}`);a=e}else a=(...e)=>e[0].__bool__().value;const i=r.value.filter((t=>{const r=t.value.get(e.value);return!!r&&a(r,s)}));return new W(i)}case"map":{const[,e]=this.evaluateArguments(n.args,t);if(e.has("attribute")){const t=e.get("attribute");if(!(t instanceof R))throw new Error("attribute must be a string");const n=e.get("default"),o=r.value.map((e=>{if(!(e instanceof q))throw new Error("items in map must be an object");return e.value.get(t.value)??n??new H}));return new W(o)}throw new Error("`map` expressions without `attribute` set are not currently supported.")}}throw new Error(`Unknown ArrayValue filter: ${o}`)}if(r instanceof R){if("indent"===o){const[e,o]=this.evaluateArguments(n.args,t),s=e.at(0)??o.get("width")??new j(4);if(!(s instanceof j))throw new Error("width must be a number");const a=e.at(1)??o.get("first")??new G(!1),i=e.at(2)??o.get("blank")??new G(!1),l=r.value.split("\n"),c=" ".repeat(s.value),d=l.map(((e,t)=>!a.value&&0===t||!i.value&&0===e.length?e:c+e));return new R(d.join("\n"))}throw new Error(`Unknown StringValue filter: ${o}`)}throw new Error(`Cannot apply filter "${o}" to type: ${r.type}`)}throw new Error(`Unknown filter: ${e.filter.type}`)}evaluateTestExpression(e,t){const r=this.evaluate(e.operand,t),n=t.tests.get(e.test.value);if(!n)throw new Error(`Unknown test: ${e.test.value}`);const o=n(r);return new G(e.negate?!o:o)}evaluateUnaryExpression(e,t){const r=this.evaluate(e.argument,t);if("not"===e.operator.value)return new G(!r.value);throw new SyntaxError(`Unknown operator: ${e.operator.value}`)}evalProgram(e,t){return this.evaluateBlock(e.body,t)}evaluateBlock(e,t){let r="";for(const n of e){const e=this.evaluate(n,t);"NullValue"!==e.type&&"UndefinedValue"!==e.type&&(r+=e.value)}return new R(r)}evaluateIdentifier(e,t){return t.lookupVariable(e.value)}evaluateCallExpression(e,t){const[r,n]=this.evaluateArguments(e.args,t);n.size>0&&r.push(new $(n));const o=this.evaluate(e.callee,t);if("FunctionValue"!==o.type)throw new Error(`Cannot call something that is not a function: got ${o.type}`);return o.value(r,t)}evaluateSliceExpression(e,t,r){if(!(e instanceof W||e instanceof R))throw new Error("Slice object must be an array or string");const n=this.evaluate(t.start,r),o=this.evaluate(t.stop,r),s=this.evaluate(t.step,r);if(!(n instanceof j||n instanceof H))throw new Error("Slice start must be numeric or undefined");if(!(o instanceof j||o instanceof H))throw new Error("Slice stop must be numeric or undefined");if(!(s instanceof j||s instanceof H))throw new Error("Slice step must be numeric or undefined");return e instanceof W?new W(O(e.value,n.value,o.value,s.value)):new R(O(Array.from(e.value),n.value,o.value,s.value).join(""))}evaluateMemberExpression(e,t){const r=this.evaluate(e.object,t);let n,o;if(e.computed){if("SliceExpression"===e.property.type)return this.evaluateSliceExpression(r,e.property,t);n=this.evaluate(e.property,t)}else n=new R(e.property.value);if(r instanceof q){if(!(n instanceof R))throw new Error(`Cannot access property with non-string: got ${n.type}`);o=r.value.get(n.value)??r.builtins.get(n.value)}else if(r instanceof W||r instanceof R)if(n instanceof j)o=r.value.at(n.value),r instanceof R&&(o=new R(r.value.at(n.value)));else{if(!(n instanceof R))throw new Error(`Cannot access property with non-string/non-number: got ${n.type}`);o=r.builtins.get(n.value)}else{if(!(n instanceof R))throw new Error(`Cannot access property with non-string: got ${n.type}`);o=r.builtins.get(n.value)}return o instanceof V?o:new H}evaluateSet(e,t){const r=this.evaluate(e.value,t);if("Identifier"===e.assignee.type){const n=e.assignee.value;t.setVariable(n,r)}else{if("MemberExpression"!==e.assignee.type)throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(e.assignee)}`);{const n=e.assignee,o=this.evaluate(n.object,t);if(!(o instanceof q))throw new Error("Cannot assign to member of non-object");if("Identifier"!==n.property.type)throw new Error("Cannot assign to member with non-identifier property");o.value.set(n.property.value,r)}}return new Q}evaluateIf(e,t){const r=this.evaluate(e.test,t);return this.evaluateBlock(r.__bool__().value?e.body:e.alternate,t)}evaluateFor(e,t){const r=new Y(t);let n,o;if("SelectExpression"===e.iterable.type){const t=e.iterable;o=this.evaluate(t.iterable,r),n=t.test}else o=this.evaluate(e.iterable,r);if(!(o instanceof W))throw new Error(`Expected iterable type in for loop: got ${o.type}`);const s=[],a=[];for(let t=0;t<o.value.length;++t){const i=new Y(r),l=o.value[t];let c;if("Identifier"===e.loopvar.type)c=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 r=l;if(t.value.length!==r.value.length)throw new Error(`Too ${t.value.length>r.value.length?"few":"many"} items to unpack`);c=e=>{for(let n=0;n<t.value.length;++n){if("Identifier"!==t.value[n].type)throw new Error(`Cannot unpack non-identifier type: ${t.value[n].type}`);e.setVariable(t.value[n].value,r.value[n])}}}}if(n){c(i);if(!this.evaluate(n,i).__bool__().value)continue}s.push(l),a.push(c)}let i="",l=!0;for(let t=0;t<s.length;++t){const n=new Map([["index",new j(t+1)],["index0",new j(t)],["revindex",new j(s.length-t)],["revindex0",new j(s.length-t-1)],["first",new G(0===t)],["last",new G(t===s.length-1)],["length",new j(s.length)],["previtem",t>0?s[t-1]:new H],["nextitem",t<s.length-1?s[t+1]:new H]]);r.setVariable("loop",new q(n)),a[t](r);i+=this.evaluateBlock(e.body,r).value,l=!1}if(l){i+=this.evaluateBlock(e.defaultBlock,r).value}return new R(i)}evaluateMacro(e,t){return t.setVariable(e.name.value,new X(((t,r)=>{const n=new Y(r);let o;t=t.slice(),"KeywordArgumentsValue"===t.at(-1)?.type&&(o=t.pop());for(let r=0;r<e.args.length;++r){const s=e.args[r],a=t[r];if("Identifier"===s.type){const e=s;if(!a)throw new Error(`Missing positional argument: ${e.value}`);n.setVariable(e.value,a)}else{if("KeywordArgumentExpression"!==s.type)throw new Error(`Unknown argument type: ${s.type}`);{const e=s,t=a??o?.value.get(e.key.value)??this.evaluate(e.value,n);n.setVariable(e.key.value,t)}}}return this.evaluateBlock(e.body,n)}))),new Q}evaluate(e,t){if(void 0===e)return new H;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"NumericLiteral":return new j(Number(e.value));case"StringLiteral":return new R(e.value);case"BooleanLiteral":return new G(e.value);case"ArrayLiteral":return new W(e.value.map((e=>this.evaluate(e,t))));case"TupleLiteral":return new U(e.value.map((e=>this.evaluate(e,t))));case"ObjectLiteral":{const r=new Map;for(const[n,o]of e.value){const e=this.evaluate(n,t);if(!(e instanceof R))throw new Error(`Object keys must be strings: got ${e.type}`);r.set(e.value,this.evaluate(o,t))}return new q(r)}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"TestExpression":return this.evaluateTestExpression(e,t);default:throw new SyntaxError(`Unknown node type: ${e.type}`)}}};function K(e){switch(typeof e){case"number":return new j(e);case"string":return new R(e);case"boolean":return new G(e);case"undefined":return new H;case"object":return null===e?new Q:Array.isArray(e)?new W(e.map(K)):new q(new Map(Object.entries(e).map((([e,t])=>[e,K(t)]))));case"function":return new X(((t,r)=>K(e(...t.map((e=>e.value)))??null)));default:throw new Error(`Cannot convert to runtime value: ${e}`)}}function Z(e,t,r){const n=r??0;switch(e.type){case"NullValue":case"UndefinedValue":return"null";case"NumericValue":case"StringValue":case"BooleanValue":return JSON.stringify(e.value);case"ArrayValue":case"ObjectValue":{const r=t?" ".repeat(t):"",o="\n"+r.repeat(n),s=o+r;if("ArrayValue"===e.type){const r=e.value.map((e=>Z(e,t,n+1)));return t?`[${s}${r.join(`,${s}`)}${o}]`:`[${r.join(", ")}]`}{const r=Array.from(e.value.entries()).map((([e,r])=>{const o=`"${e}": ${Z(r,t,n+1)}`;return t?`${s}${o}`:o}));return t?`{${r.join(",")}${o}}`:`{${r.join(", ")}}`}}default:throw new Error(`Cannot convert to JSON: ${e.type}`)}}var ee=class{parsed;constructor(e){const t=d(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=B(t)}render(e){const t=new Y;t.set("false",!1),t.set("true",!0),t.set("raise_exception",(e=>{throw new Error(e)})),t.set("range",N);for(const[r,n]of Object.entries(e))t.set(r,n);return new J(t).run(this.parsed).value}}},"./node_modules/onnxruntime-common/dist/esm/backend-impl.js":
/*!******************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/backend-impl.js ***!
\******************************************************************/(e,t,r)=>{r.r(t),r.d(t,{registerBackend:()=>s,resolveBackendAndExecutionProviders:()=>i});const n=new Map,o=[],s=(e,t,r)=>{if(!t||"function"!=typeof t.init||"function"!=typeof t.createInferenceSessionHandler)throw new TypeError("not a valid backend");{const s=n.get(e);if(void 0===s)n.set(e,{backend:t,priority:r});else{if(s.priority>r)return;if(s.priority===r&&s.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${r}`)}if(r>=0){const t=o.indexOf(e);-1!==t&&o.splice(t,1);for(let t=0;t<o.length;t++)if(n.get(o[t]).priority<=r)return void o.splice(t,0,e);o.push(e)}}},a=async e=>{const t=n.get(e);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{const r=!!t.initPromise;try{return r||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return r||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},i=async e=>{const t=e.executionProviders||[],r=t.map((e=>"string"==typeof e?e:e.name)),n=0===r.length?o:r;let s;const i=[],l=new Set;for(const e of n){const t=await a(e);"string"==typeof t?i.push({name:e,err:t}):(s||(s=t),s===t&&l.add(e))}if(!s)throw new Error(`no available backend found. ERR: ${i.map((e=>`[${e.name}] ${e.err}`)).join(", ")}`);for(const{name:e,err:t}of i)r.includes(e)&&console.warn(`removing requested execution provider "${e}" from session options because it is not available: ${t}`);const c=t.filter((e=>l.has("string"==typeof e?e:e.name)));return[s,new Proxy(e,{get:(e,t)=>"executionProviders"===t?c:Reflect.get(e,t)})]}},"./node_modules/onnxruntime-common/dist/esm/backend.js":
/*!*************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/backend.js ***!
\*************************************************************/(e,t,r)=>{r.r(t),r.d(t,{registerBackend:()=>n.registerBackend});var n=r(/*! ./backend-impl.js */"./node_modules/onnxruntime-common/dist/esm/backend-impl.js")},"./node_modules/onnxruntime-common/dist/esm/env-impl.js":
/*!**************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/env-impl.js ***!
\**************************************************************/(e,t,r)=>{r.r(t),r.d(t,{env:()=>s});var n=r(/*! ./version.js */"./node_modules/onnxruntime-common/dist/esm/version.js");let o="warning";const s={wasm:{},webgl:{},webgpu:{},versions:{common:n.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}`);o=e}},get logLevel(){return o}};Object.defineProperty(s,"logLevel",{enumerable:!0})},"./node_modules/onnxruntime-common/dist/esm/env.js":
/*!*********************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/env.js ***!
\*********************************************************/(e,t,r)=>{r.r(t),r.d(t,{env:()=>n});const n=r(/*! ./env-impl.js */"./node_modules/onnxruntime-common/dist/esm/env-impl.js").env},"./node_modules/onnxruntime-common/dist/esm/index.js":
/*!***********************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/index.js ***!
\***********************************************************/(e,t,r)=>{r.r(t),r.d(t,{InferenceSession:()=>s.InferenceSession,TRACE:()=>i.TRACE,TRACE_FUNC_BEGIN:()=>i.TRACE_FUNC_BEGIN,TRACE_FUNC_END:()=>i.TRACE_FUNC_END,Tensor:()=>a.Tensor,TrainingSession:()=>l.TrainingSession,env:()=>o.env,registerBackend:()=>n.registerBackend});var n=r(/*! ./backend.js */"./node_modules/onnxruntime-common/dist/esm/backend.js"),o=r(/*! ./env.js */"./node_modules/onnxruntime-common/dist/esm/env.js"),s=r(/*! ./inference-session.js */"./node_modules/onnxruntime-common/dist/esm/inference-session.js"),a=r(/*! ./tensor.js */"./node_modules/onnxruntime-common/dist/esm/tensor.js"),i=(r(/*! ./tensor-conversion.js */"./node_modules/onnxruntime-common/dist/esm/tensor-conversion.js"),r(/*! ./tensor-factory.js */"./node_modules/onnxruntime-common/dist/esm/tensor-factory.js"),r(/*! ./trace.js */"./node_modules/onnxruntime-common/dist/esm/trace.js")),l=(r(/*! ./onnx-model.js */"./node_modules/onnxruntime-common/dist/esm/onnx-model.js"),r(/*! ./onnx-value.js */"./node_modules/onnxruntime-common/dist/esm/onnx-value.js"),r(/*! ./training-session.js */"./node_modules/onnxruntime-common/dist/esm/training-session.js"))},"./node_modules/onnxruntime-common/dist/esm/inference-session-impl.js":
/*!****************************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/inference-session-impl.js ***!
\****************************************************************************/(e,t,r)=>{r.r(t),r.d(t,{InferenceSession:()=>a});var n=r(/*! ./backend-impl.js */"./node_modules/onnxruntime-common/dist/esm/backend-impl.js"),o=r(/*! ./tensor.js */"./node_modules/onnxruntime-common/dist/esm/tensor.js"),s=r(/*! ./trace.js */"./node_modules/onnxruntime-common/dist/esm/trace.js");class a{constructor(e){this.handler=e}async run(e,t,r){(0,s.TRACE_FUNC_BEGIN)();const n={};let a={};if("object"!=typeof e||null===e||e instanceof o.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 o.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}.`);n[e]=null}if("object"==typeof r&&null!==r)a=r;else if(void 0!==r)throw new TypeError("'options' must be an object.")}else{let e=!1;const s=Object.getOwnPropertyNames(t);for(const r of this.outputNames)if(-1!==s.indexOf(r)){const s=t[r];(null===s||s instanceof o.Tensor)&&(e=!0,i=!1,n[r]=s)}if(e){if("object"==typeof r&&null!==r)a=r;else if(void 0!==r)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)n[e]=null;const l=await this.handler.run(e,n,a),c={};for(const e in l)if(Object.hasOwnProperty.call(l,e)){const t=l[e];t instanceof o.Tensor?c[e]=t:c[e]=new o.Tensor(t.type,t.data,t.dims)}return(0,s.TRACE_FUNC_END)(),c}async release(){return this.handler.dispose()}static async create(e,t,r,o){let i;(0,s.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 n=e;let s=0,a=e.byteLength;if("object"==typeof t&&null!==t)l=t;else if("number"==typeof t){if(s=t,!Number.isSafeInteger(s))throw new RangeError("'byteOffset' must be an integer.");if(s<0||s>=n.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${n.byteLength}).`);if(a=e.byteLength-s,"number"==typeof r){if(a=r,!Number.isSafeInteger(a))throw new RangeError("'byteLength' must be an integer.");if(a<=0||s+a>n.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${n.byteLength-s}].`);if("object"==typeof o&&null!==o)l=o;else if(void 0!==o)throw new TypeError("'options' must be an object.")}else if(void 0!==r)throw new TypeError("'byteLength' must be a number.")}else if(void 0!==t)throw new TypeError("'options' must be an object.");i=new Uint8Array(n,s,a)}}const[c,d]=await(0,n.resolveBackendAndExecutionProviders)(l),u=await c.createInferenceSessionHandler(i,d);return(0,s.TRACE_FUNC_END)(),new a(u)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}},"./node_modules/onnxruntime-common/dist/esm/inference-session.js":
/*!***********************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/inference-session.js ***!
\***********************************************************************/(e,t,r)=>{r.r(t),r.d(t,{InferenceSession:()=>n});const n=r(/*! ./inference-session-impl.js */"./node_modules/onnxruntime-common/dist/esm/inference-session-impl.js").InferenceSession},"./node_modules/onnxruntime-common/dist/esm/onnx-model.js":
/*!****************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/onnx-model.js ***!
\****************************************************************/(e,t,r)=>{r.r(t)},"./node_modules/onnxruntime-common/dist/esm/onnx-value.js":
/*!****************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/onnx-value.js ***!
\****************************************************************/(e,t,r)=>{r.r(t)},"./node_modules/onnxruntime-common/dist/esm/tensor-conversion-impl.js":
/*!****************************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/tensor-conversion-impl.js ***!
\****************************************************************************/(e,t,r)=>{r.r(t),r.d(t,{tensorToDataURL:()=>n,tensorToImageData:()=>o});const n=(e,t)=>{const r="undefined"!=typeof document?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=e.dims[3],r.height=e.dims[2];const n=r.getContext("2d");if(null!=n){let o,s;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(o=e.dims[2],s=e.dims[3]):(o=e.dims[3],s=e.dims[2]);const a=void 0!==t?.format?t.format:"RGB",i=t?.norm;let l,c;void 0===i||void 0===i.mean?l=[255,255,255,255]:"number"==typeof i.mean?l=[i.mean,i.mean,i.mean,i.mean]:(l=[i.mean[0],i.mean[1],i.mean[2],0],void 0!==i.mean[3]&&(l[3]=i.mean[3])),void 0===i||void 0===i.bias?c=[0,0,0,0]:"number"==typeof i.bias?c=[i.bias,i.bias,i.bias,i.bias]:(c=[i.bias[0],i.bias[1],i.bias[2],0],void 0!==i.bias[3]&&(c[3]=i.bias[3]));const d=s*o;let u=0,p=d,h=2*d,m=-1;"RGBA"===a?(u=0,p=d,h=2*d,m=3*d):"RGB"===a?(u=0,p=d,h=2*d):"RBG"===a&&(u=0,h=d,p=2*d);for(let t=0;t<s;t++)for(let r=0;r<o;r++){const o=(e.data[u++]-c[0])*l[0],s=(e.data[p++]-c[1])*l[1],a=(e.data[h++]-c[2])*l[2],i=-1===m?255:(e.data[m++]-c[3])*l[3];n.fillStyle="rgba("+o+","+s+","+a+","+i+")",n.fillRect(r,t,1,1)}if("toDataURL"in r)return r.toDataURL();throw new Error("toDataURL is not supported")}throw new Error("Can not access image data")},o=(e,t)=>{const r="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");let n;if(null==r)throw new Error("Can not access image data");{let o,s,a;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(o=e.dims[2],s=e.dims[1],a=e.dims[3]):(o=e.dims[3],s=e.dims[2],a=e.dims[1]);const i=void 0!==t&&void 0!==t.format?t.format:"RGB",l=t?.norm;let c,d;void 0===l||void 0===l.mean?c=[255,255,255,255]:"number"==typeof l.mean?c=[l.mean,l.mean,l.mean,l.mean]:(c=[l.mean[0],l.mean[1],l.mean[2],255],void 0!==l.mean[3]&&(c[3]=l.mean[3])),void 0===l||void 0===l.bias?d=[0,0,0,0]:"number"==typeof l.bias?d=[l.bias,l.bias,l.bias,l.bias]:(d=[l.bias[0],l.bias[1],l.bias[2],0],void 0!==l.bias[3]&&(d[3]=l.bias[3]));const u=s*o;if(void 0!==t&&(void 0!==t.format&&4===a&&"RGBA"!==t.format||3===a&&"RGB"!==t.format&&"BGR"!==t.format))throw new Error("Tensor format doesn't match input tensor dims");const p=4;let h=0,m=1,_=2,f=3,g=0,M=u,w=2*u,T=-1;"RGBA"===i?(g=0,M=u,w=2*u,T=3*u):"RGB"===i?(g=0,M=u,w=2*u):"RBG"===i&&(g=0,w=u,M=2*u),n=r.createImageData(o,s);for(let t=0;t<s*o;h+=p,m+=p,_+=p,f+=p,t++)n.data[h]=(e.data[g++]-d[0])*c[0],n.data[m]=(e.data[M++]-d[1])*c[1],n.data[_]=(e.data[w++]-d[2])*c[2],n.data[f]=-1===T?255:(e.data[T++]-d[3])*c[3]}return n}},"./node_modules/onnxruntime-common/dist/esm/tensor-conversion.js":
/*!***********************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/tensor-conversion.js ***!
\***********************************************************************/(e,t,r)=>{r.r(t)},"./node_modules/onnxruntime-common/dist/esm/tensor-factory-impl.js":
/*!*************************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/tensor-factory-impl.js ***!
\*************************************************************************/(e,t,r)=>{r.r(t),r.d(t,{bufferToTensor:()=>o,tensorFromGpuBuffer:()=>i,tensorFromImage:()=>s,tensorFromPinnedBuffer:()=>l,tensorFromTexture:()=>a});var n=r(/*! ./tensor-impl.js */"./node_modules/onnxruntime-common/dist/esm/tensor-impl.js");const o=(e,t)=>{if(void 0===e)throw new Error("Image buffer must be defined");if(void 0===t.height||void 0===t.width)throw new Error("Image height and width must be defined");if("NHWC"===t.tensorLayout)throw new Error("NHWC Tensor layout is not supported yet");const{height:r,width:o}=t,s=t.norm??{mean:255,bias:0};let a,i;a="number"==typeof s.mean?[s.mean,s.mean,s.mean,s.mean]:[s.mean[0],s.mean[1],s.mean[2],s.mean[3]??255],i="number"==typeof s.bias?[s.bias,s.bias,s.bias,s.bias]:[s.bias[0],s.bias[1],s.bias[2],s.bias[3]??0];const l=void 0!==t.format?t.format:"RGBA",c=void 0!==t.tensorFormat&&void 0!==t.tensorFormat?t.tensorFormat:"RGB",d=r*o,u="RGBA"===c?new Float32Array(4*d):new Float32Array(3*d);let p=4,h=0,m=1,_=2,f=3,g=0,M=d,w=2*d,T=-1;"RGB"===l&&(p=3,h=0,m=1,_=2,f=-1),"RGBA"===c?T=3*d:"RBG"===c?(g=0,w=d,M=2*d):"BGR"===c&&(w=0,M=d,g=2*d);for(let t=0;t<d;t++,h+=p,_+=p,m+=p,f+=p)u[g++]=(e[h]+i[0])/a[0],u[M++]=(e[m]+i[1])/a[1],u[w++]=(e[_]+i[2])/a[2],-1!==T&&-1!==f&&(u[T++]=(e[f]+i[3])/a[3]);return"RGBA"===c?new n.Tensor("float32",u,[1,4,r,o]):new n.Tensor("float32",u,[1,3,r,o])},s=async(e,t)=>{const r="undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement,n="undefined"!=typeof ImageData&&e instanceof ImageData,s="undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap,a="string"==typeof e;let i,l=t??{};const c=()=>{if("undefined"!=typeof document)return document.createElement("canvas");if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},d=e=>e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext("2d"):null;if(r){const r=c();r.width=e.width,r.height=e.height;const n=d(r);if(null==n)throw new Error("Can not access image data");{let r=e.height,o=e.width;if(void 0!==t&&void 0!==t.resizedHeight&&void 0!==t.resizedWidth&&(r=t.resizedHeight,o=t.resizedWidth),void 0!==t){if(l=t,void 0!==t.tensorFormat)throw new Error("Image input config format must be RGBA for HTMLImageElement");l.tensorFormat="RGBA",l.height=r,l.width=o}else l.tensorFormat="RGBA",l.height=r,l.width=o;n.drawImage(e,0,0),i=n.getImageData(0,0,o,r).data}}else{if(!n){if(s){if(void 0===t)throw new Error("Please provide image config with format for Imagebitmap");const r=c();r.width=e.width,r.height=e.height;const n=d(r);if(null!=n){const t=e.height,r=e.width;return n.drawImage(e,0,0,r,t),i=n.getImageData(0,0,r,t).data,l.height=t,l.width=r,o(i,l)}throw new Error("Can not access image data")}if(a)return new Promise(((t,r)=>{const n=c(),s=d(n);if(!e||!s)return r();const a=new Image;a.crossOrigin="Anonymous",a.src=e,a.onload=()=>{n.width=a.width,n.height=a.height,s.drawImage(a,0,0,n.width,n.height);const e=s.getImageData(0,0,n.width,n.height);l.height=n.height,l.width=n.width,t(o(e.data,l))}}));throw new Error("Input data provided is not supported - aborted tensor creation")}{let r,n;if(void 0!==t&&void 0!==t.resizedWidth&&void 0!==t.resizedHeight?(r=t.resizedHeight,n=t.resizedWidth):(r=e.height,n=e.width),void 0!==t&&(l=t),l.format="RGBA",l.height=r,l.width=n,void 0!==t){const t=c();t.width=n,t.height=r;const o=d(t);if(null==o)throw new Error("Can not access image data");o.putImageData(e,0,0),i=o.getImageData(0,0,n,r).data}else i=e.data}}if(void 0!==i)return o(i,l);throw new Error("Input data provided is not supported - aborted tensor creation")},a=(e,t)=>{const{width:r,height:o,download:s,dispose:a}=t,i=[1,o,r,4];return new n.Tensor({location:"texture",type:"float32",texture:e,dims:i,download:s,dispose:a})},i=(e,t)=>{const{dataType:r,dims:o,download:s,dispose:a}=t;return new n.Tensor({location:"gpu-buffer",type:r??"float32",gpuBuffer:e,dims:o,download:s,dispose:a})},l=(e,t,r)=>new n.Tensor({location:"cpu-pinned",type:e,data:t,dims:r??[t.length]})},"./node_modules/onnxruntime-common/dist/esm/tensor-factory.js":
/*!********************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/tensor-factory.js ***!
\********************************************************************/(e,t,r)=>{r.r(t)},"./node_modules/onnxruntime-common/dist/esm/tensor-impl-type-mapping.js":
/*!******************************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/tensor-impl-type-mapping.js ***!
\******************************************************************************/(e,t,r)=>{r.r(t),r.d(t,{NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP:()=>o,NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP:()=>n,checkTypedArray:()=>a});const n=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),o=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);let s=!1;const a=()=>{if(!s){s=!0;const e="undefined"!=typeof BigInt64Array&&BigInt64Array.from,t="undefined"!=typeof BigUint64Array&&BigUint64Array.from,r="undefined"!=typeof Float16Array&&Float16Array.from;e&&(n.set("int64",BigInt64Array),o.set(BigInt64Array,"int64")),t&&(n.set("uint64",BigUint64Array),o.set(BigUint64Array,"uint64")),r?(n.set("float16",Float16Array),o.set(Float16Array,"float16")):n.set("float16",Uint16Array)}}},"./node_modules/onnxruntime-common/dist/esm/tensor-impl.js":
/*!*****************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/tensor-impl.js ***!
\*****************************************************************/(e,t,r)=>{r.r(t),r.d(t,{Tensor:()=>i});var n=r(/*! ./tensor-conversion-impl.js */"./node_modules/onnxruntime-common/dist/esm/tensor-conversion-impl.js"),o=r(/*! ./tensor-factory-impl.js */"./node_modules/onnxruntime-common/dist/esm/tensor-factory-impl.js"),s=r(/*! ./tensor-impl-type-mapping.js */"./node_modules/onnxruntime-common/dist/esm/tensor-impl-type-mapping.js"),a=r(/*! ./tensor-utils-impl.js */"./node_modules/onnxruntime-common/dist/esm/tensor-utils-impl.js");class i{constructor(e,t,r){let n,o;if((0,s.checkTypedArray)(),"object"==typeof e&&"location"in e)switch(this.dataLocation=e.location,n=e.type,o=e.dims,e.location){case"cpu-pinned":{const t=s.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(n);if(!t)throw new TypeError(`unsupported type "${n}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw new TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case"texture":if("float32"!==n)throw new TypeError(`unsupported type "${n}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case"gpu-buffer":if("float32"!==n&&"float16"!==n&&"int32"!==n&&"int64"!==n&&"uint32"!==n&&"uint8"!==n&&"bool"!==n)throw new TypeError(`unsupported type "${n}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,i;if("string"==typeof e)if(n=e,i=r,"string"===e){if(!Array.isArray(t))throw new TypeError("A string tensor's data must be a string array.");a=t}else{const r=s.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(e);if(void 0===r)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if("float16"===e&&r===Uint16Array)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");a="uint64"===e||"int64"===e?r.from(t,BigInt):r.from(t)}else{if(!(t instanceof r))throw new TypeError(`A ${n} tensor's data must be type of ${r}`);a=t}}else if(i=t,Array.isArray(e)){if(0===e.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");const t=typeof e[0];if("string"===t)n="string",a=e;else{if("boolean"!==t)throw new TypeError(`Invalid element type of data array: ${t}.`);n="bool",a=Uint8Array.from(e)}}else{const t=s.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.get(e.constructor);if(void 0===t)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);n=t,a=e}if(void 0===i)i=[a.length];else if(!Array.isArray(i))throw new TypeError("A tensor's dims must be a number array");o=i,this.cpuData=a,this.dataLocation="cpu"}const i=(0,a.calculateSize)(o);if(this.cpuData&&i!==this.cpuData.length)throw new Error(`Tensor's size(${i}) does not match data length(${this.cpuData.length}).`);this.type=n,this.dims=o,this.size=i}static async fromImage(e,t){return(0,o.tensorFromImage)(e,t)}static fromTexture(e,t){return(0,o.tensorFromTexture)(e,t)}static fromGpuBuffer(e,t){return(0,o.tensorFromGpuBuffer)(e,t)}static fromPinnedBuffer(e,t,r){return(0,o.tensorFromPinnedBuffer)(e,t,r)}toDataURL(e){return(0,n.tensorToDataURL)(this,e)}toImageData(e){return(0,n.tensorToImageData)(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}async getData(e){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;const t=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if("none"===this.dataLocation)throw new Error("The tensor is disposed.")}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return(0,a.tensorReshape)(this,e)}}},"./node_modules/onnxruntime-common/dist/esm/tensor-utils-impl.js":
/*!***********************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/tensor-utils-impl.js ***!
\***********************************************************************/(e,t,r)=>{r.r(t),r.d(t,{calculateSize:()=>o,tensorReshape:()=>s});var n=r(/*! ./tensor-impl.js */"./node_modules/onnxruntime-common/dist/esm/tensor-impl.js");const o=e=>{let t=1;for(let r=0;r<e.length;r++){const n=e[r];if("number"!=typeof n||!Number.isSafeInteger(n))throw new TypeError(`dims[${r}] must be an integer, got: ${n}`);if(n<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${n}`);t*=n}return t},s=(e,t)=>{switch(e.location){case"cpu":return new n.Tensor(e.type,e.data,t);case"cpu-pinned":return new n.Tensor({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new n.Tensor({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new n.Tensor({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}},"./node_modules/onnxruntime-common/dist/esm/tensor.js":
/*!************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/tensor.js ***!
\************************************************************/(e,t,r)=>{r.r(t),r.d(t,{Tensor:()=>n});const n=r(/*! ./tensor-impl.js */"./node_modules/onnxruntime-common/dist/esm/tensor-impl.js").Tensor},"./node_modules/onnxruntime-common/dist/esm/trace.js":
/*!***********************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/trace.js ***!
\***********************************************************/(e,t,r)=>{r.r(t),r.d(t,{TRACE:()=>o,TRACE_FUNC_BEGIN:()=>a,TRACE_FUNC_END:()=>i});var n=r(/*! ./env-impl.js */"./node_modules/onnxruntime-common/dist/esm/env-impl.js");const o=(e,t)=>{(void 0===n.env.trace?n.env.wasm.trace:n.env.trace)&&console.timeStamp(`${e}::ORT::${t}`)},s=(e,t)=>{const r=(new Error).stack?.split(/\r\n|\r|\n/g)||[];let n=!1;for(let s=0;s<r.length;s++){if(n&&!r[s].includes("TRACE_FUNC")){let n=`FUNC_${e}::${r[s].trim().split(" ")[1]}`;return t&&(n+=`::${t}`),void o("CPU",n)}r[s].includes("TRACE_FUNC")&&(n=!0)}},a=e=>{(void 0===n.env.trace?n.env.wasm.trace:n.env.trace)&&s("BEGIN",e)},i=e=>{(void 0===n.env.trace?n.env.wasm.trace:n.env.trace)&&s("END",e)}},"./node_modules/onnxruntime-common/dist/esm/training-session-impl.js":
/*!***************************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/training-session-impl.js ***!
\***************************************************************************/(e,t,r)=>{r.r(t),r.d(t,{TrainingSession:()=>s});var n=r(/*! ./backend-impl.js */"./node_modules/onnxruntime-common/dist/esm/backend-impl.js"),o=r(/*! ./tensor.js */"./node_modules/onnxruntime-common/dist/esm/tensor.js");class s{constructor(e,t,r){this.handler=e,this.hasOptimizerModel=t,this.hasEvalModel=r}get trainingInputNames(){return this.handler.inputNames}get trainingOutputNames(){return this.handler.outputNames}get evalInputNames(){if(this.hasEvalModel)return this.handler.evalInputNames;throw new Error("This training session has no evalModel loaded.")}get evalOutputNames(){if(this.hasEvalModel)return this.handler.evalOutputNames;throw new Error("This training session has no evalModel loaded.")}static async create(e,t){const r=e.evalModel||"",o=e.optimizerModel||"",a=t||{},[i,l]=await(0,n.resolveBackendAndExecutionProviders)(a);if(i.createTrainingSessionHandler){const t=await i.createTrainingSessionHandler(e.checkpointState,e.trainModel,r,o,l);return new s(t,!!e.optimizerModel,!!e.evalModel)}throw new Error("Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.")}typeNarrowingForRunStep(e,t,r,n,s){const a={};let i={};if("object"!=typeof r||null===r||r instanceof o.Tensor||Array.isArray(r))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let l=!0;if("object"==typeof n){if(null===n)throw new TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof o.Tensor)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(n)){if(0===n.length)throw new TypeError("'fetches' cannot be an empty array.");l=!1;for(const e of n){if("string"!=typeof e)throw new TypeError("'fetches' must be a string array or an object.");if(-1===t.indexOf(e))throw new RangeError(`'fetches' contains invalid output name: ${e}.`);a[e]=null}if("object"==typeof s&&null!==s)i=s;else if(void 0!==s)throw new TypeError("'options' must be an object.")}else{let e=!1;const r=Object.getOwnPropertyNames(n);for(const s of t)if(-1!==r.indexOf(s)){const t=n[s];(null===t||t instanceof o.Tensor)&&(e=!0,l=!1,a[s]=t)}if(e){if("object"==typeof s&&null!==s)i=s;else if(void 0!==s)throw new TypeError("'options' must be an object.")}else i=n}}else if(void 0!==n)throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const t of e)if(void 0===r[t])throw new Error(`input '${t}' is missing in 'feeds'.`);if(l)for(const e of t)a[e]=null;return[a,i]}convertHandlerReturnTypeToMapOfTensors(e){const t={};for(const r in e)if(Object.hasOwnProperty.call(e,r)){const n=e[r];n instanceof o.Tensor?t[r]=n:t[r]=new o.Tensor(n.type,n.data,n.dims)}return t}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(e,t,r){const[n,o]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,e,t,r),s=await this.handler.runTrainStep(e,n,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(e){if(!this.hasOptimizerModel)throw new Error("This TrainingSession has no OptimizerModel loaded.");await this.handler.runOptimizerStep(e||{})}async runEvalStep(e,t,r){if(this.hasEvalModel){const[n,o]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,e,t,r),s=await this.handler.runEvalStep(e,n,o);return this.convertHandlerReturnTypeToMapOfTensors(s)}throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(e=!0){return this.handler.getParametersSize(e)}async loadParametersBuffer(e,t=!0){const r=await this.getParametersSize(t);if(e.length!==4*r)throw new Error("Size of the buffer passed into loadParametersBuffer must match the number of parameters in the model. Please use getParametersSize method to check.");return this.handler.loadParametersBuffer(e,t)}async getContiguousParameters(e=!0){return this.handler.getContiguousParameters(e)}async release(){return this.handler.dispose()}}},"./node_modules/onnxruntime-common/dist/esm/training-session.js":
/*!**********************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/training-session.js ***!
\**********************************************************************/(e,t,r)=>{r.r(t),r.d(t,{TrainingSession:()=>n});const n=r(/*! ./training-session-impl.js */"./node_modules/onnxruntime-common/dist/esm/training-session-impl.js").TrainingSession},"./node_modules/onnxruntime-common/dist/esm/version.js":
/*!*************************************************************!*\
!*** ./node_modules/onnxruntime-common/dist/esm/version.js ***!
\*************************************************************/(e,t,r)=>{r.r(t),r.d(t,{version:()=>n});const n="1.19.2"},"./src/backends/onnx.js":
/*!******************************!*\
!*** ./src/backends/onnx.js ***!
\******************************/(e,t,r)=>{r.r(t),r.d(t,{Tensor:()=>s.Tensor,createInferenceSession:()=>h,deviceToExecutionProviders:()=>u,isONNXProxy:()=>f,isONNXTensor:()=>m});var n=r(/*! ../env.js */"./src/env.js"),o=r(/*! #onnxruntime-webgpu */"#onnxruntime-webgpu"),s=r(/*! onnxruntime-common */"./node_modules/onnxruntime-common/dist/esm/index.js");const a=Object.freeze({auto:null,gpu:null,cpu:"cpu",wasm:"wasm",webgpu:"webgpu",cuda:"cuda",dml:"dml",webnn:{name:"webnn",deviceType:"cpu"},"webnn-npu":{name:"webnn",deviceType:"npu"},"webnn-gpu":{name:"webnn",deviceType:"gpu"},"webnn-cpu":{name:"webnn",deviceType:"cpu"}}),i=[];let l,c;if(n.apis.IS_NODE_ENV){switch(c=null.default??null,process.platform){case"win32":i.push("dml");break;case"linux":"x64"===process.arch&&i.push("cuda")}i.push("cpu"),l=["cpu"]}else c=o,n.apis.IS_WEBNN_AVAILABLE&&i.push("webnn-npu","webnn-gpu","webnn-cpu","webnn"),n.apis.IS_WEBGPU_AVAILABLE&&i.push("webgpu"),i.push("wasm"),l=["wasm"];const d=c.InferenceSession;function u(e=null){if(!e)return l;switch(e){case"auto":return i;case"gpu":return i.filter((e=>["webgpu","cuda","dml","webnn-gpu"].includes(e)))}if(i.includes(e))return[a[e]??e];throw new Error(`Unsupported device: "${e}". Should be one of: ${i.join(", ")}.`)}let p=null;async function h(e,t){p&&await p;const r=d.create(e,t);return p??=r,await r}function m(e){return e instanceof c.Tensor}const _=c?.env;function f(){return _?.wasm?.proxy}_?.wasm&&(_.wasm.wasmPaths=`https://cdn.jsdelivr.net/npm/@huggingface/transformers@${n.env.version}/dist/`,_.wasm.proxy=!1,"undefined"!=typeof crossOriginIsolated&&crossOriginIsolated||(_.wasm.numThreads=1)),_?.webgpu&&(_.webgpu.powerPreference="high-performance"),n.env.backends.onnx=_},"./src/configs.js":
/*!************************!*\
!*** ./src/configs.js ***!
\************************/(e,t,r)=>{r.r(t),r.d(t,{AutoConfig:()=>l,PretrainedConfig:()=>i,getKeyValueShapes:()=>a});var n=r(/*! ./utils/core.js */"./src/utils/core.js"),o=r(/*! ./utils/hub.js */"./src/utils/hub.js");function s(e){const t={};let r={};switch(e.model_type){case"llava":case"paligemma":case"florence2":r=s(e.text_config);break;case"moondream1":r=s(e.phi_config);break;case"musicgen":r=s(e.decoder);break;case"gpt2":case"gptj":case"jais":case"codegen":case"gpt_bigcode":t.num_heads="n_head",t.num_layers="n_layer",t.hidden_size="n_embd";break;case"gpt_neox":case"stablelm":case"opt":case"phi":case"phi3":case"falcon":t.num_heads="num_attention_heads",t.num_layers="num_hidden_layers",t.hidden_size="hidden_size";break;case"llama":case"cohere":case"mistral":case"starcoder2":case"qwen2":t.num_heads="num_key_value_heads",t.num_layers="num_hidden_layers",t.hidden_size="hidden_size",t.num_attention_heads="num_attention_heads";break;case"gemma":case"gemma2":t.num_heads="num_key_value_heads",t.num_layers="num_hidden_layers",t.dim_kv="head_dim";break;case"openelm":t.num_heads="num_kv_heads",t.num_layers="num_transformer_layers",t.dim_kv="head_dim";break;case"gpt_neo":case"donut-swin":t.num_heads="num_heads",t.num_layers="num_layers",t.hidden_size="hidden_size";break;case"bloom":t.num_heads="n_head",t.num_layers="n_layer",t.hidden_size="hidden_size";break;case"mpt":t.num_heads="n_heads",t.num_layers="n_layers",t.hidden_size="d_model";break;case"t5":case"mt5":case"longt5":t.num_decoder_layers="num_decoder_layers",t.num_decoder_heads="num_heads",t.decoder_dim_kv="d_kv",t.num_encoder_layers="num_layers",t.num_encoder_heads="num_heads",t.encoder_dim_kv="d_kv";break;case"bart":case"mbart":case"marian":case"whisper":case"m2m_100":case"blenderbot":case"blenderbot-small":case"florence2_language":t.num_decoder_layers="decoder_layers",t.num_decoder_heads="decoder_attention_heads",t.decoder_hidden_size="d_model",t.num_encoder_layers="encoder_layers",t.num_encoder_heads="encoder_attention_heads",t.encoder_hidden_size="d_model";break;case"speecht5":t.num_decoder_layers="decoder_layers",t.num_decoder_heads="decoder_attention_heads",t.decoder_hidden_size="hidden_size",t.num_encoder_layers="encoder_layers",t.num_encoder_heads="encoder_attention_heads",t.encoder_hidden_size="hidden_size";break;case"trocr":t.num_encoder_layers=t.num_decoder_layers="decoder_layers",t.num_encoder_heads=t.num_decoder_heads="decoder_attention_heads",t.encoder_hidden_size=t.decoder_hidden_size="d_model";break;case"musicgen_decoder":t.num_encoder_layers=t.num_decoder_layers="num_hidden_layers",t.num_encoder_heads=t.num_decoder_heads="num_attention_heads",t.encoder_hidden_size=t.decoder_hidden_size="hidden_size";break;case"vision-encoder-decoder":const o=s(e.decoder),a="num_decoder_layers"in o,i=(0,n.pick)(e,["model_type","is_encoder_decoder"]);return a?(i.num_decoder_layers=o.num_decoder_layers,i.num_decoder_heads=o.num_decoder_heads,i.decoder_hidden_size=o.decoder_hidden_size,i.num_encoder_layers=o.num_encoder_layers,i.num_encoder_heads=o.num_encoder_heads,i.encoder_hidden_size=o.encoder_hidden_size):(i.num_layers=o.num_layers,i.num_heads=o.num_heads,i.hidden_size=o.hidden_size),i}const o={...r,...(0,n.pick)(e,["model_type","multi_query","is_encoder_decoder"])};for(const r in t)o[r]=e[t[r]];return o}function a(e,{prefix:t="past_key_values"}={}){const r={},n=e.normalized_config;if(n.is_encoder_decoder&&"num_encoder_heads"in n&&"num_decoder_heads"in n){const e=n.encoder_dim_kv??n.encoder_hidden_size/n.num_encoder_heads,o=n.decoder_dim_kv??n.decoder_hidden_size/n.num_decoder_heads,s=[1,n.num_encoder_heads,0,e],a=[1,n.num_decoder_heads,0,o];for(let e=0;e<n.num_decoder_layers;++e)r[`${t}.${e}.encoder.key`]=s,r[`${t}.${e}.encoder.value`]=s,r[`${t}.${e}.decoder.key`]=a,r[`${t}.${e}.decoder.value`]=a}else{const e=n.num_heads,o=n.num_layers,s=n.dim_kv??n.hidden_size/(n.num_attention_heads??e);if("falcon"===n.model_type){const n=[1*e,0,s];for(let e=0;e<o;++e)r[`${t}.${e}.key`]=n,r[`${t}.${e}.value`]=n}else if(n.multi_query){const n=[1*e,0,2*s];for(let e=0;e<o;++e)r[`${t}.${e}.key_value`]=n}else if("bloom"===n.model_type){const n=[1*e,s,0],a=[1*e,0,s];for(let e=0;e<o;++e)r[`${t}.${e}.key`]=n,r[`${t}.${e}.value`]=a}else if("openelm"===n.model_type)for(let n=0;n<o;++n){const o=[1,e[n],0,s];r[`${t}.${n}.key`]=o,r[`${t}.${n}.value`]=o}else{const n=[1,e,0,s];for(let e=0;e<o;++e)r[`${t}.${e}.key`]=n,r[`${t}.${e}.value`]=n}}return r}class i{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(e){Object.assign(this,e),this.normalized_config=s(this)}static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:n=null,local_files_only:s=!1,revision:a="main"}={}){!r||r instanceof i||(r=new i(r));const l=r??await async function(e,t){return await(0,o.getModelJSON)(e,"config.json",!0,t)}(e,{progress_callback:t,config:r,cache_dir:n,local_files_only:s,revision:a});return new this(l)}}class l{static async from_pretrained(...e){return i.from_pretrained(...e)}}},"./src/env.js":
/*!********************!*\
!*** ./src/env.js ***!
\********************/(e,t,r)=>{r.r(t),r.d(t,{apis:()=>_,env:()=>T});var n=r(/*! fs */"?569f"),o=r(/*! path */"?3f59"),s=r(/*! url */"?154a");const a="undefined"!=typeof self,i=a&&"DedicatedWorkerGlobalScope"===self.constructor.name,l=a&&"caches"in self,c="undefined"!=typeof navigator&&"gpu"in navigator,d="undefined"!=typeof navigator&&"ml"in navigator,u="undefined"!=typeof process,p=u&&"node"===process?.release?.name,h=!b(n),m=!b(o),_=Object.freeze({IS_BROWSER_ENV:a,IS_WEBWORKER_ENV:i,IS_WEB_CACHE_AVAILABLE:l,IS_WEBGPU_AVAILABLE:c,IS_WEBNN_AVAILABLE:d,IS_PROCESS_AVAILABLE:u,IS_NODE_ENV:p,IS_FS_AVAILABLE:h,IS_PATH_AVAILABLE:m}),f=h&&m,g=f?o.dirname(o.dirname(s.fileURLToPath(import.meta.url))):"./",M=f?o.join(g,"/.cache/"):null,w="/models/",T={version:"3.0.0-alpha.15",backends:{onnx:{}},allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!a,localModelPath:f?o.join(g,w):w,useFS:h,useBrowserCache:l,useFSCache:h,cacheDir:M,useCustomCache:!1,customCache:null};function b(e){return 0===Object.keys(e).length}},"./src/generation/configuration_utils.js":
/*!***********************************************!*\
!*** ./src/generation/configuration_utils.js ***!
\***********************************************/(e,t,r)=>{r.r(t),r.d(t,{GenerationConfig:()=>o});var n=r(/*! ../utils/core.js */"./src/utils/core.js");class o{max_length=20;max_new_tokens=null;min_length=0;min_new_tokens=null;early_stopping=!1;max_time=null;do_sample=!1;num_beams=1;num_beam_groups=1;penalty_alpha=null;use_cache=!0;temperature=1;top_k=50;top_p=1;typical_p=1;epsilon_cutoff=0;eta_cutoff=0;diversity_penalty=0;repetition_penalty=1;encoder_repetition_penalty=1;length_penalty=1;no_repeat_ngram_size=0;bad_words_ids=null;force_words_ids=null;renormalize_logits=!1;constraints=null;forced_bos_token_id=null;forced_eos_token_id=null;remove_invalid_values=!1;exponential_decay_length_penalty=null;suppress_tokens=null;begin_suppress_tokens=null;forced_decoder_ids=null;guidance_scale=null;num_return_sequences=1;output_attentions=!1;output_hidden_states=!1;output_scores=!1;return_dict_in_generate=!1;pad_token_id=null;bos_token_id=null;eos_token_id=null;encoder_no_repeat_ngram_size=0;decoder_start_token_id=null;generation_kwargs={};constructor(e){Object.assign(this,(0,n.pick)(e,Object.getOwnPropertyNames(this)))}}},"./src/generation/logits_process.js":
/*!******************************************!*\
!*** ./src/generation/logits_process.js ***!
\******************************************/(e,t,r)=>{r.r(t),r.d(t,{ClassifierFreeGuidanceLogitsProcessor:()=>g,ForcedBOSTokenLogitsProcessor:()=>l,ForcedEOSTokenLogitsProcessor:()=>c,LogitsProcessor:()=>s,LogitsProcessorList:()=>i,LogitsWarper:()=>a,MinLengthLogitsProcessor:()=>m,MinNewTokensLengthLogitsProcessor:()=>_,NoBadWordsLogitsProcessor:()=>f,NoRepeatNGramLogitsProcessor:()=>p,RepetitionPenaltyLogitsProcessor:()=>h,SuppressTokensAtBeginLogitsProcessor:()=>d,TemperatureLogitsWarper:()=>M,TopKLogitsWarper:()=>T,TopPLogitsWarper:()=>w,WhisperTimeStampLogitsProcessor:()=>u});var n=r(/*! ../utils/generic.js */"./src/utils/generic.js"),o=(r(/*! ../utils/tensor.js */"./src/utils/tensor.js"),r(/*! ../utils/maths.js */"./src/utils/maths.js"));class s extends n.Callable{_call(e,t){throw Error("`_call` should be implemented in a subclass")}}class a extends n.Callable{_call(e,t){throw Error("`_call` should be implemented in a subclass")}}class i extends n.Callable{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,t){let r=t;for(const t of this.processors)r=t(e,r);return r}[Symbol.iterator](){return this.processors.values()}}class l extends s{constructor(e){super(),this.bos_token_id=e}_call(e,t){for(let r=0;r<e.length;++r)if(1===e[r].length){const e=t[r].data;e.fill(-1/0),e[this.bos_token_id]=0}return t}}class c extends s{constructor(e,t){super(),this.max_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length===this.max_length-1){const e=t[r].data;e.fill(-1/0);for(const t of this.eos_token_id)e[t]=0}return t}}class d extends s{constructor(e,t){super(),this.begin_suppress_tokens=e,this.begin_index=t}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length===this.begin_index){const e=t[r].data;for(const t of this.begin_suppress_tokens)e[t]=-1/0}return t}}class u extends s{constructor(e,t){super(),this.eos_token_id=Array.isArray(e.eos_token_id)?e.eos_token_id[0]:e.eos_token_id,this.no_timestamps_token_id=e.no_timestamps_token_id,this.timestamp_begin=this.no_timestamps_token_id+1,this.begin_index=t.length,t.at(-1)===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,t){for(let r=0;r<e.length;++r){const n=t[r].data;if(n[this.no_timestamps_token_id]=-1/0,e[r].length===this.begin_index-1){n.fill(-1/0),n[this.timestamp_begin]=0;continue}const s=e[r].slice(this.begin_index),a=s.length>=1&&s[s.length-1]>=this.timestamp_begin,i=s.length<2||s[s.length-2]>=this.timestamp_begin;if(a&&(i?n.subarray(this.timestamp_begin).fill(-1/0):n.subarray(0,this.eos_token_id).fill(-1/0)),e[r].length===this.begin_index&&null!==this.max_initial_timestamp_index){const e=this.timestamp_begin+this.max_initial_timestamp_index;n.subarray(e+1).fill(-1/0)}const l=(0,o.log_softmax)(n);Math.log(l.subarray(this.timestamp_begin).map(Math.exp).reduce(((e,t)=>e+t)))>(0,o.max)(l.subarray(0,this.timestamp_begin))[0]&&n.subarray(0,this.timestamp_begin).fill(-1/0)}return t}}class p extends s{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){const t=e.length,r=[];for(let n=0;n<t+1-this.no_repeat_ngram_size;++n){const t=[];for(let r=0;r<this.no_repeat_ngram_size;++r)t.push(e[n+r]);r.push(t.map(Number))}const n=new Map;for(const e of r){const t=e.slice(0,e.length-1),r=JSON.stringify(t),o=n.get(r)??[];o.push(e[e.length-1]),n.set(r,o)}return n}getGeneratedNgrams(e,t){const r=t.slice(t.length+1-this.no_repeat_ngram_size,t.length);return e.get(JSON.stringify(r.map(Number)))??[]}calcBannedNgramTokens(e){const t=[];if(e.length+1<this.no_repeat_ngram_size)return t;{const t=this.getNgrams(e);return this.getGeneratedNgrams(t,e)}}_call(e,t){for(let r=0;r<e.length;++r){const n=t[r].data,o=this.calcBannedNgramTokens(e[r]);for(const e of o)n[e]=-1/0}return t}}class h extends s{constructor(e){super(),this.penalty=e}_call(e,t){for(let r=0;r<e.length;++r){const n=t[r].data;for(const t of e[r]){const e=Number(t);n[e]<0?n[e]*=this.penalty:n[e]/=this.penalty}}return t}}class m extends s{constructor(e,t){super(),this.min_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length<this.min_length){const e=t[r].data;for(const t of this.eos_token_id)e[t]=-1/0}return t}}class _ extends s{constructor(e,t,r){super(),this.prompt_length_to_skip=e,this.min_new_tokens=t,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,t){for(let r=0;r<e.length;++r){if(e[r].length-this.prompt_length_to_skip<this.min_new_tokens){const e=t[r].data;for(const t of this.eos_token_id)e[t]=-1/0}}return t}}class f extends s{constructor(e,t){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r=0;r<e.length;++r){const n=t[r].data,o=e[r];for(const e of this.bad_words_ids){let t=!0;for(let r=1;r<=e.length-1&&e.length<o.length;++r)if(e.at(-r-1)!=o.at(-r)){t=!1;break}t&&(n[e.at(-1)]=-1/0)}}return t}}class g extends s{constructor(e){if(super(),e<=1)throw new Error(`Require guidance scale >1 to use the classifier free guidance processor, got guidance scale ${e}.`);this.guidance_scale=e}_call(e,t){if(t.dims[0]!==2*e.length)throw new Error(`Logits should have twice the batch size of the input ids, the first half of batches corresponding to the conditional inputs, and the second half of batches corresponding to the unconditional inputs. Got batch size ${t.dims[0]} for the logits and ${e.length} for the input ids.`);const r=e.length,n=t.slice([0,r],null),o=t.slice([r,t.dims[0]],null);for(let e=0;e<o.data.length;++e)o.data[e]+=(n.data[e]-o.data[e])*this.guidance_scale;return o}}class M extends a{constructor(e){if(super(),"number"!=typeof e||e<=0){let t=`\`temperature\` (=${e}) must be a strictly positive float, otherwise your next token scores will be invalid.`;0===e&&(t+=" If you're looking for greedy decoding strategies, set `do_sample=false`.")}this.temperature=e}_call(e,t){const r=t.data;for(let e=0;e<r.length;++e)r[e]/=this.temperature;return t}}class w extends a{constructor(e,{filter_value:t=-1/0,min_tokens_to_keep:r=1}={}){if(super(),e<0||e>1)throw new Error(`\`top_p\` must be a float > 0 and < 1, but is ${e}`);if(!Number.isInteger(r)||r<1)throw new Error(`\`min_tokens_to_keep\` must be a positive integer, but is ${r}`);this.top_p=e,this.filter_value=t,this.min_tokens_to_keep=r}}class T extends a{constructor(e,{filter_value:t=-1/0,min_tokens_to_keep:r=1}={}){if(super(),!Number.isInteger(e)||e<0)throw new Error(`\`top_k\` must be a positive integer, but is ${e}`);this.top_k=Math.max(e,r),this.filter_value=t}}},"./src/generation/logits_sampler.js":
/*!******************************************!*\
!*** ./src/generation/logits_sampler.js ***!
\******************************************/(e,t,r)=>{r.r(t),r.d(t,{LogitsSampler:()=>a});var n=r(/*! ../utils/generic.js */"./src/utils/generic.js"),o=r(/*! ../utils/tensor.js */"./src/utils/tensor.js"),s=r(/*! ../utils/maths.js */"./src/utils/maths.js");r(/*! ../generation/configuration_utils.js */"./src/generation/configuration_utils.js");class a extends n.Callable{constructor(e){super(),this.generation_config=e}async _call(e){return this.sample(e)}async sample(e){throw Error("sample should be implemented in subclasses.")}getLogits(e,t){let r=e.dims.at(-1),n=e.data;if(-1===t)n=n.slice(-r);else{let e=t*r;n=n.slice(e,e+r)}return n}randomSelect(e){let t=0;for(let r=0;r<e.length;++r)t+=e[r];let r=Math.random()*t;for(let t=0;t<e.length;++t)if(r-=e[t],r<=0)return t;return 0}static getSampler(e){if(e.do_sample)return new l(e);if(e.num_beams>1)return new c(e);if(e.num_return_sequences>1)throw Error(`num_return_sequences has to be 1 when doing greedy search, but is ${e.num_return_sequences}.`);return new i(e)}}class i extends a{async sample(e){const t=(0,s.max)(e.data)[1];return[[BigInt(t),0]]}}class l extends a{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));const[r,n]=await(0,o.topk)(e,t),a=(0,s.softmax)(r.data);return Array.from({length:this.generation_config.num_beams},(()=>{const e=this.randomSelect(a);return[n.data[e],Math.log(a[e])]}))}}class c extends a{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));const[r,n]=await(0,o.topk)(e,t),a=(0,s.softmax)(r.data);return Array.from({length:this.generation_config.num_beams},((e,t)=>[n.data[t],Math.log(a[t])]))}}},"./src/generation/stopping_criteria.js":
/*!*********************************************!*\
!*** ./src/generation/stopping_criteria.js ***!
\*********************************************/(e,t,r)=>{r.r(t),r.d(t,{EosTokenCriteria:()=>i,InterruptableStoppingCriteria:()=>l,MaxLengthCriteria:()=>a,StoppingCriteria:()=>o,StoppingCriteriaList:()=>s});var n=r(/*! ../utils/generic.js */"./src/utils/generic.js");class o extends n.Callable{_call(e,t){throw Error("StoppingCriteria needs to be subclassed")}}class s extends n.Callable{constructor(){super(),this.criteria=[]}push(e){this.criteria.push(e)}extend(e){e instanceof s?e=e.criteria:e instanceof o&&(e=[e]),this.criteria.push(...e)}_call(e,t){const r=new Array(e.length).fill(!1);for(const n of this.criteria){const o=n(e,t);for(let e=0;e<r.length;++e)r[e]||=o[e]}return r}[Symbol.iterator](){return this.criteria.values()}}class a extends o{constructor(e,t=null){super(),this.max_length=e,this.max_position_embeddings=t}_call(e){return e.map((e=>e.length>=this.max_length))}}class i extends o{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,t){return e.map((e=>{const t=e.at(-1);return this.eos_token_id.some((e=>t==e))}))}}class l extends o{constructor(){super(),this.interrupted=!1}interrupt(){this.interrupted=!0}reset(){this.interrupted=!1}_call(e,t){return new Array(e.length).fill(this.interrupted)}}},"./src/generation/streamers.js":
/*!*************************************!*\
!*** ./src/generation/streamers.js ***!
\*************************************/(e,t,r)=>{r.r(t),r.d(t,{BaseStreamer:()=>a,TextStreamer:()=>l,WhisperTextStreamer:()=>c});var n=r(/*! ../utils/core.js */"./src/utils/core.js"),o=r(/*! ../tokenizers.js */"./src/tokenizers.js"),s=r(/*! ../env.js */"./src/env.js");class a{put(e){throw Error("Not implemented")}end(){throw Error("Not implemented")}}const i=s.apis.IS_PROCESS_AVAILABLE?e=>process.stdout.write(e):e=>console.log(e);class l extends a{constructor(e,{skip_prompt:t=!1,callback_function:r=null,token_callback_function:n=null,decode_kwargs:o={},...s}={}){super(),this.tokenizer=e,this.skip_prompt=t,this.callback_function=r??i,this.token_callback_function=n,this.decode_kwargs={...o,...s},this.token_cache=[],this.print_len=0,this.next_tokens_are_prompt=!0}put(e){if(e.length>1)throw Error("TextStreamer only supports batch size of 1");if(this.skip_prompt&&this.next_tokens_are_prompt)return void(this.next_tokens_are_prompt=!1);const t=e[0];this.token_callback_function?.(t),this.token_cache=(0,n.mergeArrays)(this.token_cache,t);const r=this.tokenizer.decode(this.token_cache,this.decode_kwargs);let s;r.endsWith("\n")?(s=r.slice(this.print_len),this.token_cache=[],this.print_len=0):r.length>0&&(0,o.is_chinese_char)(r.charCodeAt(r.length-1))?(s=r.slice(this.print_len),this.print_len+=s.length):(s=r.slice(this.print_len,r.lastIndexOf(" ")+1),this.print_len+=s.length),this.on_finalized_text(s,!1)}end(){let e;if(this.token_cache.length>0){e=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len),this.token_cache=[],this.print_len=0}else e="";this.next_tokens_are_prompt=!0,this.on_finalized_text(e,!0)}on_finalized_text(e,t){e.length>0&&this.callback_function?.(e),t&&this.callback_function===i&&s.apis.IS_PROCESS_AVAILABLE&&this.callback_function?.("\n")}}class c extends l{constructor(e,{skip_prompt:t=!1,callback_function:r=null,token_callback_function:n=null,on_chunk_start:o=null,on_chunk_end:s=null,on_finalize:a=null,time_precision:i=.02,skip_special_tokens:l=!0,decode_kwargs:c={}}={}){super(e,{skip_prompt:t,callback_function:r,token_callback_function:n,decode_kwargs:{skip_special_tokens:l,...c}}),this.timestamp_begin=e.timestamp_begin,this.on_chunk_start=o,this.on_chunk_end=s,this.on_finalize=a,this.time_precision=i,this.waiting_for_timestamp=!1}put(e){if(e.length>1)throw Error("WhisperTextStreamer only supports batch size of 1");const t=e[0];if(1===t.length){const r=Number(t[0])-this.timestamp_begin;if(r>=0){const t=r*this.time_precision;this.waiting_for_timestamp?this.on_chunk_end?.(t):this.on_chunk_start?.(t),this.waiting_for_timestamp=!this.waiting_for_timestamp,e=[[]]}}return super.put(e)}end(){super.end(),this.on_finalize?.()}}},"./src/models.js":
/*!***********************!*\
!*** ./src/models.js ***!
\***********************/(e,t,r)=>{r.r(t),r.d(t,{ASTForAudioClassification:()=>rr,ASTModel:()=>tr,ASTPreTrainedModel:()=>er,AlbertForMaskedLM:()=>ut,AlbertForQuestionAnswering:()=>dt,AlbertForSequenceClassification:()=>ct,AlbertModel:()=>lt,AlbertPreTrainedModel:()=>it,AutoModel:()=>Ei,AutoModelForAudioClassification:()=>Yi,AutoModelForAudioFrameClassification:()=>Ki,AutoModelForCTC:()=>Hi,AutoModelForCausalLM:()=>Di,AutoModelForDepthEstimation:()=>rl,AutoModelForDocumentQuestionAnswering:()=>Zi,AutoModelForImageClassification:()=>Gi,AutoModelForImageFeatureExtraction:()=>ol,AutoModelForImageMatting:()=>el,AutoModelForImageSegmentation:()=>qi,AutoModelForImageToImage:()=>tl,AutoModelForMaskGeneration:()=>Qi,AutoModelForMaskedLM:()=>Vi,AutoModelForNormalEstimation:()=>nl,AutoModelForObjectDetection:()=>Ui,AutoModelForQuestionAnswering:()=>ji,AutoModelForSemanticSegmentation:()=>$i,AutoModelForSeq2SeqLM:()=>Ii,AutoModelForSequenceClassification:()=>Li,AutoModelForSpeechSeq2Seq:()=>Bi,AutoModelForTextToSpectrogram:()=>Ni,AutoModelForTextToWaveform:()=>Oi,AutoModelForTokenClassification:()=>zi,AutoModelForUniversalSegmentation:()=>Wi,AutoModelForVision2Seq:()=>Ri,AutoModelForXVector:()=>Ji,AutoModelForZeroShotObjectDetection:()=>Xi,BartForConditionalGeneration:()=>kt,BartForSequenceClassification:()=>yt,BartModel:()=>xt,BartPretrainedModel:()=>bt,BaseModelOutput:()=>q,BeitForImageClassification:()=>ao,BeitModel:()=>so,BeitPreTrainedModel:()=>oo,BertForMaskedLM:()=>U,BertForQuestionAnswering:()=>H,BertForSequenceClassification:()=>X,BertForTokenClassification:()=>Q,BertModel:()=>W,BertPreTrainedModel:()=>$,BlenderbotForConditionalGeneration:()=>Lt,BlenderbotModel:()=>Et,BlenderbotPreTrainedModel:()=>At,BlenderbotSmallForConditionalGeneration:()=>Bt,BlenderbotSmallModel:()=>It,BlenderbotSmallPreTrainedModel:()=>zt,BloomForCausalLM:()=>bn,BloomModel:()=>Tn,BloomPreTrainedModel:()=>wn,CLIPModel:()=>hr,CLIPPreTrainedModel:()=>pr,CLIPSegForImageSegmentation:()=>Pr,CLIPSegModel:()=>Fr,CLIPSegPreTrainedModel:()=>yr,CLIPTextModel:()=>mr,CLIPTextModelWithProjection:()=>_r,CLIPVisionModel:()=>fr,CLIPVisionModelWithProjection:()=>gr,CamembertForMaskedLM:()=>Me,CamembertForQuestionAnswering:()=>be,CamembertForSequenceClassification:()=>we,CamembertForTokenClassification:()=>Te,CamembertModel:()=>ge,CamembertPreTrainedModel:()=>fe,CausalLMOutput:()=>ul,CausalLMOutputWithPast:()=>pl,ChineseCLIPModel:()=>kr,ChineseCLIPPreTrainedModel:()=>xr,ClapAudioModelWithProjection:()=>Ta,ClapModel:()=>Ma,ClapPreTrainedModel:()=>ga,ClapTextModelWithProjection:()=>wa,CodeGenForCausalLM:()=>Xr,CodeGenModel:()=>Ur,CodeGenPreTrainedModel:()=>Wr,CohereForCausalLM:()=>Zr,CohereModel:()=>Kr,CoherePreTrainedModel:()=>Jr,ConvBertForMaskedLM:()=>ae,ConvBertForQuestionAnswering:()=>ce,ConvBertForSequenceClassification:()=>ie,ConvBertForTokenClassification:()=>le,ConvBertModel:()=>se,ConvBertPreTrainedModel:()=>oe,ConvNextForImageClassification:()=>rs,ConvNextModel:()=>ts,ConvNextPreTrainedModel:()=>es,ConvNextV2ForImageClassification:()=>ss,ConvNextV2Model:()=>os,ConvNextV2PreTrainedModel:()=>ns,DPTForDepthEstimation:()=>Vo,DPTModel:()=>Do,DPTPreTrainedModel:()=>Oo,DebertaForMaskedLM:()=>ye,DebertaForQuestionAnswering:()=>Ce,DebertaForSequenceClassification:()=>Fe,DebertaForTokenClassification:()=>Pe,DebertaModel:()=>ke,DebertaPreTrainedModel:()=>xe,DebertaV2ForMaskedLM:()=>Ae,DebertaV2ForQuestionAnswering:()=>ze,DebertaV2ForSequenceClassification:()=>Ee,DebertaV2ForTokenClassification:()=>Le,DebertaV2Model:()=>Se,DebertaV2PreTrainedModel:()=>ve,DecisionTransformerModel:()=>Ya,DecisionTransformerPreTrainedModel:()=>Ha,DeiTForImageClassification:()=>yo,DeiTModel:()=>ko,DeiTPreTrainedModel:()=>xo,DepthAnythingForDepthEstimation:()=>Ro,DepthAnythingPreTrainedModel:()=>jo,DetrForObjectDetection:()=>co,DetrForSegmentation:()=>uo,DetrModel:()=>lo,DetrObjectDetectionOutput:()=>po,DetrPreTrainedModel:()=>io,DetrSegmentationOutput:()=>ho,Dinov2ForImageClassification:()=>ls,Dinov2Model:()=>is,Dinov2PreTrainedModel:()=>as,DistilBertForMaskedLM:()=>Ve,DistilBertForQuestionAnswering:()=>De,DistilBertForSequenceClassification:()=>Ne,DistilBertForTokenClassification:()=>Oe,DistilBertModel:()=>Be,DistilBertPreTrainedModel:()=>Ie,DonutSwinModel:()=>Zo,DonutSwinPreTrainedModel:()=>Ko,EfficientNetForImageClassification:()=>La,EfficientNetModel:()=>Ea,EfficientNetPreTrainedModel:()=>Aa,ElectraForMaskedLM:()=>pe,ElectraForQuestionAnswering:()=>_e,ElectraForSequenceClassification:()=>he,ElectraForTokenClassification:()=>me,ElectraModel:()=>ue,ElectraPreTrainedModel:()=>de,EsmForMaskedLM:()=>Ge,EsmForSequenceClassification:()=>qe,EsmForTokenClassification:()=>$e,EsmModel:()=>Re,EsmPreTrainedModel:()=>je,FalconForCausalLM:()=>fa,FalconModel:()=>_a,FalconPreTrainedModel:()=>ma,FastViTForImageClassification:()=>qn,FastViTModel:()=>Gn,FastViTPreTrainedModel:()=>Rn,Florence2ForConditionalGeneration:()=>ur,Florence2PreTrainedModel:()=>dr,GLPNForDepthEstimation:()=>Jo,GLPNModel:()=>Yo,GLPNPreTrainedModel:()=>Ho,GPT2LMHeadModel:()=>Sr,GPT2Model:()=>vr,GPT2PreTrainedModel:()=>Cr,GPTBigCodeForCausalLM:()=>$r,GPTBigCodeModel:()=>qr,GPTBigCodePreTrainedModel:()=>Gr,GPTJForCausalLM:()=>Rr,GPTJModel:()=>jr,GPTJPreTrainedModel:()=>Vr,GPTNeoForCausalLM:()=>Br,GPTNeoModel:()=>Ir,GPTNeoPreTrainedModel:()=>zr,GPTNeoXForCausalLM:()=>Dr,GPTNeoXModel:()=>Or,GPTNeoXPreTrainedModel:()=>Nr,Gemma2ForCausalLM:()=>sn,Gemma2Model:()=>on,Gemma2PreTrainedModel:()=>nn,GemmaForCausalLM:()=>rn,GemmaModel:()=>tn,GemmaPreTrainedModel:()=>en,GroupViTModel:()=>jn,GroupViTPreTrainedModel:()=>Vn,HieraForImageClassification:()=>Co,HieraModel:()=>Po,HieraPreTrainedModel:()=>Fo,HubertForCTC:()=>Xs,HubertForSequenceClassification:()=>Qs,HubertModel:()=>Us,HubertPreTrainedModel:()=>Ws,ImageMattingOutput:()=>hl,JAISLMHeadModel:()=>Lr,JAISModel:()=>Er,JAISPreTrainedModel:()=>Ar,LlamaForCausalLM:()=>Yr,LlamaModel:()=>Hr,LlamaPreTrainedModel:()=>Qr,LlavaForConditionalGeneration:()=>lr,LlavaPreTrainedModel:()=>ir,LongT5ForConditionalGeneration:()=>gt,LongT5Model:()=>ft,LongT5PreTrainedModel:()=>_t,M2M100ForConditionalGeneration:()=>bs,M2M100Model:()=>Ts,M2M100PreTrainedModel:()=>ws,MBartForCausalLM:()=>St,MBartForConditionalGeneration:()=>Ct,MBartForSequenceClassification:()=>vt,MBartModel:()=>Pt,MBartPreTrainedModel:()=>Ft,MPNetForMaskedLM:()=>Ke,MPNetForQuestionAnswering:()=>tt,MPNetForSequenceClassification:()=>Ze,MPNetForTokenClassification:()=>et,MPNetModel:()=>Je,MPNetPreTrainedModel:()=>Ye,MT5ForConditionalGeneration:()=>Tt,MT5Model:()=>wt,MT5PreTrainedModel:()=>Mt,MarianMTModel:()=>Ms,MarianModel:()=>gs,MarianPreTrainedModel:()=>fs,MaskFormerForInstanceSegmentation:()=>Qo,MaskFormerModel:()=>Xo,MaskFormerPreTrainedModel:()=>Uo,MaskedLMOutput:()=>cl,MistralForCausalLM:()=>da,MistralModel:()=>ca,MistralPreTrainedModel:()=>la,MobileBertForMaskedLM:()=>Xe,MobileBertForQuestionAnswering:()=>He,MobileBertForSequenceClassification:()=>Qe,MobileBertModel:()=>Ue,MobileBertPreTrainedModel:()=>We,MobileNetV1ForImageClassification:()=>Va,MobileNetV1Model:()=>Da,MobileNetV1PreTrainedModel:()=>Oa,MobileNetV2ForImageClassification:()=>Ga,MobileNetV2Model:()=>Ra,MobileNetV2PreTrainedModel:()=>ja,MobileNetV3ForImageClassification:()=>Wa,MobileNetV3Model:()=>$a,MobileNetV3PreTrainedModel:()=>qa,MobileNetV4ForImageClassification:()=>Qa,MobileNetV4Model:()=>Xa,MobileNetV4PreTrainedModel:()=>Ua,MobileViTForImageClassification:()=>Qn,MobileViTModel:()=>Xn,MobileViTPreTrainedModel:()=>Un,MobileViTV2ForImageClassification:()=>Jn,MobileViTV2Model:()=>Yn,MobileViTV2PreTrainedModel:()=>Hn,ModelOutput:()=>G,Moondream1ForConditionalGeneration:()=>cr,MptForCausalLM:()=>yn,MptModel:()=>kn,MptPreTrainedModel:()=>xn,MusicgenForCausalLM:()=>Ba,MusicgenForConditionalGeneration:()=>Na,MusicgenModel:()=>Ia,MusicgenPreTrainedModel:()=>za,NomicBertModel:()=>J,NomicBertPreTrainedModel:()=>Y,OPTForCausalLM:()=>Cn,OPTModel:()=>Pn,OPTPreTrainedModel:()=>Fn,OpenELMForCausalLM:()=>cn,OpenELMModel:()=>ln,OpenELMPreTrainedModel:()=>an,OwlViTForObjectDetection:()=>eo,OwlViTModel:()=>Zn,OwlViTPreTrainedModel:()=>Kn,Owlv2ForObjectDetection:()=>no,Owlv2Model:()=>ro,Owlv2PreTrainedModel:()=>to,Phi3ForCausalLM:()=>Mn,Phi3Model:()=>gn,Phi3PreTrainedModel:()=>fn,PhiForCausalLM:()=>_n,PhiModel:()=>mn,PhiPreTrainedModel:()=>hn,PreTrainedModel:()=>R,PretrainedMixin:()=>Ja,PvtForImageClassification:()=>zn,PvtModel:()=>Ln,PvtPreTrainedModel:()=>En,PyAnnoteForAudioFrameClassification:()=>Ss,PyAnnoteModel:()=>vs,PyAnnotePreTrainedModel:()=>Cs,QuestionAnsweringModelOutput:()=>dl,Qwen2ForCausalLM:()=>pn,Qwen2Model:()=>un,Qwen2PreTrainedModel:()=>dn,RTDetrForObjectDetection:()=>fo,RTDetrModel:()=>_o,RTDetrObjectDetectionOutput:()=>go,RTDetrPreTrainedModel:()=>mo,ResNetForImageClassification:()=>Ao,ResNetModel:()=>So,ResNetPreTrainedModel:()=>vo,RoFormerForMaskedLM:()=>ee,RoFormerForQuestionAnswering:()=>ne,RoFormerForSequenceClassification:()=>te,RoFormerForTokenClassification:()=>re,RoFormerModel:()=>Z,RoFormerPreTrainedModel:()=>K,RobertaForMaskedLM:()=>Dt,RobertaForQuestionAnswering:()=>Rt,RobertaForSequenceClassification:()=>Vt,RobertaForTokenClassification:()=>jt,RobertaModel:()=>Ot,RobertaPreTrainedModel:()=>Nt,SamImageSegmentationOutput:()=>_s,SamModel:()=>ms,SamPreTrainedModel:()=>hs,SapiensForDepthEstimation:()=>$o,SapiensForNormalEstimation:()=>Wo,SapiensForSemanticSegmentation:()=>qo,SapiensPreTrainedModel:()=>Go,SegformerForImageClassification:()=>Fa,SegformerForSemanticSegmentation:()=>Pa,SegformerModel:()=>ya,SegformerPreTrainedModel:()=>ka,Seq2SeqLMOutput:()=>sl,SequenceClassifierOutput:()=>al,SiglipModel:()=>wr,SiglipPreTrainedModel:()=>Mr,SiglipTextModel:()=>Tr,SiglipVisionModel:()=>br,SpeechT5ForSpeechToText:()=>na,SpeechT5ForTextToSpeech:()=>oa,SpeechT5HifiGan:()=>sa,SpeechT5Model:()=>ra,SpeechT5PreTrainedModel:()=>ta,SqueezeBertForMaskedLM:()=>ot,SqueezeBertForQuestionAnswering:()=>at,SqueezeBertForSequenceClassification:()=>st,SqueezeBertModel:()=>nt,SqueezeBertPreTrainedModel:()=>rt,StableLmForCausalLM:()=>Sa,StableLmModel:()=>va,StableLmPreTrainedModel:()=>Ca,Starcoder2ForCausalLM:()=>ha,Starcoder2Model:()=>pa,Starcoder2PreTrainedModel:()=>ua,Swin2SRForImageSuperResolution:()=>No,Swin2SRModel:()=>Bo,Swin2SRPreTrainedModel:()=>Io,SwinForImageClassification:()=>zo,SwinModel:()=>Lo,SwinPreTrainedModel:()=>Eo,T5ForConditionalGeneration:()=>mt,T5Model:()=>ht,T5PreTrainedModel:()=>pt,TableTransformerForObjectDetection:()=>To,TableTransformerModel:()=>wo,TableTransformerObjectDetectionOutput:()=>bo,TableTransformerPreTrainedModel:()=>Mo,TokenClassifierOutput:()=>ll,TrOCRForCausalLM:()=>ia,TrOCRPreTrainedModel:()=>aa,UniSpeechForCTC:()=>Is,UniSpeechForSequenceClassification:()=>Bs,UniSpeechModel:()=>zs,UniSpeechPreTrainedModel:()=>Ls,UniSpeechSatForAudioFrameClassification:()=>js,UniSpeechSatForCTC:()=>Ds,UniSpeechSatForSequenceClassification:()=>Vs,UniSpeechSatModel:()=>Os,UniSpeechSatPreTrainedModel:()=>Ns,ViTForImageClassification:()=>An,ViTMAEModel:()=>Bn,ViTMAEPreTrainedModel:()=>In,ViTMSNForImageClassification:()=>Dn,ViTMSNModel:()=>On,ViTMSNPreTrainedModel:()=>Nn,ViTModel:()=>Sn,ViTPreTrainedModel:()=>vn,VisionEncoderDecoderModel:()=>ar,VitMatteForImageMatting:()=>Wn,VitMattePreTrainedModel:()=>$n,VitsModel:()=>xa,VitsModelOutput:()=>ml,VitsPreTrainedModel:()=>ba,Wav2Vec2BertForCTC:()=>qs,Wav2Vec2BertForSequenceClassification:()=>$s,Wav2Vec2BertModel:()=>Gs,Wav2Vec2BertPreTrainedModel:()=>Rs,Wav2Vec2ForAudioFrameClassification:()=>Ps,Wav2Vec2ForCTC:()=>ys,Wav2Vec2ForSequenceClassification:()=>Fs,Wav2Vec2Model:()=>ks,Wav2Vec2PreTrainedModel:()=>xs,WavLMForAudioFrameClassification:()=>ea,WavLMForCTC:()=>Js,WavLMForSequenceClassification:()=>Ks,WavLMForXVector:()=>Zs,WavLMModel:()=>Ys,WavLMPreTrainedModel:()=>Hs,WeSpeakerResNetModel:()=>Es,WeSpeakerResNetPreTrainedModel:()=>As,WhisperForConditionalGeneration:()=>sr,WhisperModel:()=>or,WhisperPreTrainedModel:()=>nr,XLMForQuestionAnswering:()=>Xt,XLMForSequenceClassification:()=>Wt,XLMForTokenClassification:()=>Ut,XLMModel:()=>qt,XLMPreTrainedModel:()=>Gt,XLMRobertaForMaskedLM:()=>Yt,XLMRobertaForQuestionAnswering:()=>Zt,XLMRobertaForSequenceClassification:()=>Jt,XLMRobertaForTokenClassification:()=>Kt,XLMRobertaModel:()=>Ht,XLMRobertaPreTrainedModel:()=>Qt,XLMWithLMHeadModel:()=>$t,XVectorOutput:()=>il,YolosForObjectDetection:()=>us,YolosModel:()=>ds,YolosObjectDetectionOutput:()=>ps,YolosPreTrainedModel:()=>cs});var n=r(/*! ./configs.js */"./src/configs.js"),o=r(/*! ./backends/onnx.js */"./src/backends/onnx.js"),s=r(/*! ./utils/dtypes.js */"./src/utils/dtypes.js"),a=r(/*! ./utils/generic.js */"./src/utils/generic.js"),i=r(/*! ./utils/core.js */"./src/utils/core.js"),l=r(/*! ./utils/hub.js */"./src/utils/hub.js"),c=r(/*! ./generation/logits_process.js */"./src/generation/logits_process.js"),d=r(/*! ./generation/configuration_utils.js */"./src/generation/configuration_utils.js"),u=r(/*! ./utils/tensor.js */"./src/utils/tensor.js"),p=r(/*! ./utils/maths.js */"./src/utils/maths.js"),h=r(/*! ./generation/stopping_criteria.js */"./src/generation/stopping_criteria.js"),m=r(/*! ./generation/logits_sampler.js */"./src/generation/logits_sampler.js"),_=r(/*! ./env.js */"./src/env.js"),f=r(/*! ./models/whisper/generation_whisper.js */"./src/models/whisper/generation_whisper.js"),g=r(/*! ./models/whisper/common_whisper.js */"./src/models/whisper/common_whisper.js");const M=0,w=1,T=2,b=3,x=4,k=5,y=6,F=7,P=new Map,C=new Map,v=new Map;async function S(e,t,r){return Object.fromEntries(await Promise.all(Object.keys(t).map((async a=>{const{buffer:i,session_options:c}=await async function(e,t,r){let a=r.device;a&&"string"!=typeof a&&(a.hasOwnProperty(t)?a=a[t]:(console.warn(`device not specified for "${t}". Using the default device.`),a=null));const i=a??(_.apis.IS_NODE_ENV?"cpu":"wasm"),c=(0,o.deviceToExecutionProviders)(i);let d=r.dtype;"string"!=typeof d&&(d&&d.hasOwnProperty(t)?d=d[t]:(d=s.DEFAULT_DEVICE_DTYPE_MAPPING[i]??s.DATA_TYPES.fp32,console.warn(`dtype not specified for "${t}". Using the default dtype (${d}) for this device (${i}).`)));const u=d;if(!s.DEFAULT_DTYPE_SUFFIX_MAPPING.hasOwnProperty(u))throw new Error(`Invalid dtype: ${u}. Should be one of: ${Object.keys(s.DATA_TYPES).join(", ")}`);if(u===s.DATA_TYPES.fp16&&"webgpu"===i&&!await(0,s.isWebGpuFp16Supported)())throw new Error(`The device (${i}) does not support fp16.`);const p=s.DEFAULT_DTYPE_SUFFIX_MAPPING[u],h=`${r.subfolder??""}/${t}${p}.onnx`,m={...r.session_options}??{};m.executionProviders??=c;const f=r.config?.["transformers.js_config"]?.free_dimension_overrides;f?m.freeDimensionOverrides??=f:i.startsWith("webnn")&&!m.freeDimensionOverrides&&console.warn('WebNN does not currently support dynamic shapes and requires `free_dimension_overrides` to be set in config.json as a field within "transformers.js_config". When `free_dimension_overrides` is not set, you may experience significant performance degradation.');const g=(0,l.getModelFile)(e,h,!0,r);let M=[];if(r.use_external_data_format&&(!0===r.use_external_data_format||"object"==typeof r.use_external_data_format&&r.use_external_data_format.hasOwnProperty(t)&&!0===r.use_external_data_format[t])){if(_.apis.IS_NODE_ENV)throw new Error("External data format is not yet supported in Node.js");const n=`${t}${p}.onnx_data`,o=`${r.subfolder??""}/${n}`;M.push(new Promise((async(t,s)=>{const a=await(0,l.getModelFile)(e,o,!0,r);t({path:n,data:a})})))}else void 0!==m.externalData&&(M=m.externalData.map((async t=>{if("string"==typeof t.data){const n=await(0,l.getModelFile)(e,t.data,!0,r);return{...t,data:n}}return t})));if(M.length>0&&(m.externalData=await Promise.all(M)),"webgpu"===i){const e=(0,n.getKeyValueShapes)(r.config,{prefix:"present"});if(Object.keys(e).length>0&&!(0,o.isONNXProxy)()){const t={};for(const r in e)r.includes("encoder")||(t[r]="gpu-buffer");m.preferredOutputLocation=t}}return{buffer:await g,session_options:m}}(e,t[a],r);return[a,await(0,o.createInferenceSession)(i,c)]}))))}async function A(e,t){const r=function(e,t){const r=Object.create(null),n=[];for(const s of e.inputNames){const e=t[s];e instanceof u.Tensor?r[s]=(0,o.isONNXProxy)()?e.clone():e:n.push(s)}if(n.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${n.join(", ")}.`);const s=Object.keys(t).length,a=e.inputNames.length;if(s>a){let r=Object.keys(t).filter((t=>!e.inputNames.includes(t)));console.warn(`WARNING: Too many inputs were provided (${s} > ${a}). The following inputs will be ignored: "${r.join(", ")}".`)}return r}(e,t);try{const t=Object.fromEntries(Object.entries(r).map((([e,t])=>[e,t.ort_tensor])));let n=await e.run(t);return n=E(n),n}catch(e){throw console.error(`An error occurred during model execution: "${e}".`),console.error("Inputs given to model:",r),e}}function E(e){for(let t in e)(0,o.isONNXTensor)(e[t])?e[t]=new u.Tensor(e[t]):"object"==typeof e[t]&&E(e[t]);return e}function L(e){if(e instanceof u.Tensor)return e;if(0===e.length)throw Error("items must be non-empty");if(Array.isArray(e[0])){if(e.some((t=>t.length!==e[0].length)))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new u.Tensor("int64",BigInt64Array.from(e.flat().map((e=>BigInt(e)))),[e.length,e[0].length])}return new u.Tensor("int64",BigInt64Array.from(e.map((e=>BigInt(e)))),[1,e.length])}function z(e){return new u.Tensor("bool",[e],[1])}async function I(e,t){let{encoder_outputs:r,input_ids:n,decoder_input_ids:o,...s}=t;if(!r){const n=(0,i.pick)(t,e.sessions.model.inputNames);r=(await B(e,n)).last_hidden_state}s.input_ids=o,s.encoder_hidden_states=r,e.sessions.decoder_model_merged.inputNames.includes("encoder_attention_mask")&&(s.encoder_attention_mask=t.attention_mask);return await N(e,s,!0)}async function B(e,t){const r=e.sessions.model,n=(0,i.pick)(t,r.inputNames);if(r.inputNames.includes("inputs_embeds")&&!n.inputs_embeds){if(!t.input_ids)throw new Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");n.inputs_embeds=await e.encode_text({input_ids:t.input_ids})}return r.inputNames.includes("token_type_ids")&&!n.token_type_ids&&(n.token_type_ids=new u.Tensor("int64",new BigInt64Array(n.input_ids.data.length),n.input_ids.dims)),await A(r,n)}async function N(e,t,r=!1){const n=e.sessions[r?"decoder_model_merged":"model"],{past_key_values:o,...s}=t;n.inputNames.includes("use_cache_branch")&&(s.use_cache_branch=z(!!o)),n.inputNames.includes("position_ids")&&s.attention_mask&&!s.position_ids&&(s.position_ids=function(e,t=null){const{input_ids:r,inputs_embeds:n,attention_mask:o}=e,[s,a]=o.dims,i=new BigInt64Array(o.data.length);for(let e=0;e<s;++e){const t=e*a;let r=BigInt(0);for(let e=0;e<a;++e){const n=t+e;0n===o.data[n]?i[n]=BigInt(1):(i[n]=r,r+=o.data[n])}}let l=new u.Tensor("int64",i,o.dims);if(t){const e=-(r??n).dims.at(1);l=l.slice(null,[e,null])}return l}(s,o)),e.addPastKeyValues(s,o);const a=(0,i.pick)(s,n.inputNames);return await A(n,a)}async function O(e,{input_ids:t=null,attention_mask:r=null,pixel_values:n=null,position_ids:o=null,inputs_embeds:s=null,past_key_values:a=null,generation_config:i=null,logits_processor:l=null,...c}){if(!s)if(s=await e.encode_text({input_ids:t}),n&&1!==t.dims[1]){const o=await e.encode_image({pixel_values:n});({inputs_embeds:s,attention_mask:r}=e._merge_input_ids_with_image_features({image_features:o,inputs_embeds:s,input_ids:t,attention_mask:r}))}else if(a&&n&&1===t.dims[1]){const e=t.dims[1],n=Object.values(a)[0].dims.at(-2);r=(0,u.cat)([(0,u.ones)([t.dims[0],n]),r.slice(null,[r.dims[1]-e,r.dims[1]])],1)}return await N(e,{inputs_embeds:s,past_key_values:a,attention_mask:r,position_ids:o,generation_config:i,logits_processor:l},!0)}function D(e,t,r,n){if(r.past_key_values){const t=Object.values(r.past_key_values)[0].dims.at(-2),{input_ids:n,attention_mask:o}=r;if(o&&o.dims[1]>n.dims[1]);else if(t<n.dims[1])r.input_ids=n.slice(null,[t,null]);else if(null!=e.config.image_token_index&&n.data.some((t=>t==e.config.image_token_index))){const o=e.config.num_image_tokens;if(!o)throw new Error("`num_image_tokens` is missing in the model configuration.");const s=n.dims[1]-(t-o);r.input_ids=n.slice(null,[-s,null]),r.attention_mask=(0,u.ones)([1,t+s])}}return r}function V(e,t,r,n){return r.past_key_values&&(t=t.map((e=>[e.at(-1)]))),{...r,decoder_input_ids:L(t)}}function j(e,...t){return e.config.is_encoder_decoder?V(e,...t):D(e,...t)}class R extends a.Callable{main_input_name="input_ids";forward_params=["input_ids","attention_mask"];constructor(e,t){super(),this.config=e,this.sessions=t;const r=v.get(this.constructor),n=P.get(r);switch(this.can_generate=!1,this._forward=null,this._prepare_inputs_for_generation=null,n){case x:this.can_generate=!0,this._forward=N,this._prepare_inputs_for_generation=D;break;case T:case b:case F:this.can_generate=!0,this._forward=I,this._prepare_inputs_for_generation=V;break;case w:this._forward=I;break;case y:this.can_generate=!0,this._forward=O,this._prepare_inputs_for_generation=j;break;default:this._forward=B}this.can_generate&&this.forward_params.push("past_key_values"),this.custom_config=this.config["transformers.js_config"]??{}}async dispose(){const e=[];for(const t of Object.values(this.sessions))t?.handler?.dispose&&e.push(t.handler.dispose());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:o=null,local_files_only:s=!1,revision:a="main",model_file_name:i=null,subfolder:c="onnx",device:d=null,dtype:u=null,use_external_data_format:p=null,session_options:h={}}={}){let m={progress_callback:t,config:r,cache_dir:o,local_files_only:s,revision:a,model_file_name:i,subfolder:c,device:d,dtype:u,use_external_data_format:p,session_options:h};const _=v.get(this),f=P.get(_);let g;if(r=m.config=await n.AutoConfig.from_pretrained(e,m),f===x)g=await Promise.all([S(e,{model:m.model_file_name??"model"},m),(0,l.getModelJSON)(e,"generation_config.json",!1,m)]);else if(f===T||f===b)g=await Promise.all([S(e,{model:"encoder_model",decoder_model_merged:"decoder_model_merged"},m),(0,l.getModelJSON)(e,"generation_config.json",!1,m)]);else if(f===k)g=await Promise.all([S(e,{model:"vision_encoder",prompt_encoder_mask_decoder:"prompt_encoder_mask_decoder"},m)]);else if(f===w)g=await Promise.all([S(e,{model:"encoder_model",decoder_model_merged:"decoder_model_merged"},m)]);else if(f===y){const t={embed_tokens:"embed_tokens",vision_encoder:"vision_encoder",decoder_model_merged:"decoder_model_merged"};r.is_encoder_decoder&&(t.model="encoder_model"),g=await Promise.all([S(e,t,m),(0,l.getModelJSON)(e,"generation_config.json",!1,m)])}else f===F?g=await Promise.all([S(e,{model:"text_encoder",decoder_model_merged:"decoder_model_merged",encodec_decode:"encodec_decode"},m),(0,l.getModelJSON)(e,"generation_config.json",!1,m)]):(f!==M&&console.warn(`Model type for '${_??r?.model_type}' not found, assuming encoder-only architecture. Please report this at https://github.com/xenova/transformers.js/issues/new/choose.`),g=await Promise.all([S(e,{model:m.model_file_name??"model"},m)]));return new this(r,...g)}async _call(e){return await this.forward(e)}async forward(e){return await this._forward(this,e)}_get_logits_warper(e){const t=new c.LogitsProcessorList;return null!==e.temperature&&1!==e.temperature&&t.push(new c.TemperatureLogitsWarper(e.temperature)),null!==e.top_k&&0!==e.top_k&&t.push(new c.TopKLogitsWarper(e.top_k)),null!==e.top_p&&e.top_p<1&&t.push(new c.TopPLogitsWarper(e.top_p)),t}_get_logits_processor(e,t,r=null){const n=new c.LogitsProcessorList;if(null!==e.repetition_penalty&&1!==e.repetition_penalty&&n.push(new c.RepetitionPenaltyLogitsProcessor(e.repetition_penalty)),null!==e.no_repeat_ngram_size&&e.no_repeat_ngram_size>0&&n.push(new c.NoRepeatNGramLogitsProcessor(e.no_repeat_ngram_size)),null!==e.bad_words_ids&&n.push(new c.NoBadWordsLogitsProcessor(e.bad_words_ids,e.eos_token_id)),null!==e.min_length&&null!==e.eos_token_id&&e.min_length>0&&n.push(new c.MinLengthLogitsProcessor(e.min_length,e.eos_token_id)),null!==e.min_new_tokens&&null!==e.eos_token_id&&e.min_new_tokens>0&&n.push(new c.MinNewTokensLengthLogitsProcessor(t,e.min_new_tokens,e.eos_token_id)),null!==e.forced_bos_token_id&&n.push(new c.ForcedBOSTokenLogitsProcessor(e.forced_bos_token_id)),null!==e.forced_eos_token_id&&n.push(new c.ForcedEOSTokenLogitsProcessor(e.max_length,e.forced_eos_token_id)),null!==e.begin_suppress_tokens){const r=t>1||null===e.forced_bos_token_id?t:t+1;n.push(new c.SuppressTokensAtBeginLogitsProcessor(e.begin_suppress_tokens,r))}return null!==e.guidance_scale&&e.guidance_scale>1&&n.push(new c.ClassifierFreeGuidanceLogitsProcessor(e.guidance_scale)),null!==r&&n.extend(r),n}_prepare_generation_config(e,t,r=d.GenerationConfig){const n={...this.config};for(const e of["decoder","generator","text_config"])e in n&&Object.assign(n,n[e]);const o=new r(n);return"generation_config"in this&&Object.assign(o,this.generation_config),e&&Object.assign(o,e),t&&Object.assign(o,(0,i.pick)(t,Object.getOwnPropertyNames(o))),o}_get_stopping_criteria(e,t=null){const r=new h.StoppingCriteriaList;return null!==e.max_length&&r.push(new h.MaxLengthCriteria(e.max_length,this.config.max_position_embeddings??null)),null!==e.eos_token_id&&r.push(new h.EosTokenCriteria(e.eos_token_id)),t&&r.extend(t),r}_validate_model_class(){if(!this.can_generate){const e=[ii,di,ai,ti],t=v.get(this.constructor),r=new Set,n=this.config.model_type;for(const t of e){const e=t.get(n);e&&r.add(e[0])}let o=`The current model class (${t}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw r.size>0&&(o+=` Please use the following class instead: ${[...r].join(", ")}`),Error(o)}}prepare_inputs_for_generation(...e){return this._prepare_inputs_for_generation(this,...e)}_update_model_kwargs_for_generation({generated_input_ids:e,outputs:t,model_inputs:r,is_encoder_decoder:n}){return r.past_key_values=this.getPastKeyValues(t,r.past_key_values),r.input_ids=new u.Tensor("int64",e.flat(),[e.length,1]),n||(r.attention_mask=(0,u.cat)([r.attention_mask,(0,u.ones)([r.attention_mask.dims[0],1])],1)),r.position_ids=null,r}_prepare_model_inputs({inputs:e,bos_token_id:t,model_kwargs:r}){const n=(0,i.pick)(r,this.forward_params),o=this.main_input_name;if(o in n){if(e)throw new Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else n[o]=e;return{inputs_tensor:n[o],model_inputs:n,model_input_name:o}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:t,model_input_name:r,generation_config:n}){if(this.sessions.model.inputNames.includes("inputs_embeds")&&!t.inputs_embeds&&"_prepare_inputs_embeds"in this){const{input_ids:e,pixel_values:r,attention_mask:n,...o}=t,s=await this._prepare_inputs_embeds(t);t={...o,...(0,i.pick)(s,["inputs_embeds","attention_mask"])}}let{last_hidden_state:o}=await B(this,t);if(null!==n.guidance_scale&&n.guidance_scale>1)o=(0,u.cat)([o,(0,u.full_like)(o,0)],0),"attention_mask"in t&&(t.attention_mask=(0,u.cat)([t.attention_mask,(0,u.zeros_like)(t.attention_mask)],0));else if(t.decoder_input_ids){const e=L(t.decoder_input_ids).dims[0];if(e!==o.dims[0]){if(1!==o.dims[0])throw new Error(`The encoder outputs have a different batch size (${o.dims[0]}) than the decoder inputs (${e}).`);o=(0,u.cat)(Array.from({length:e},(()=>o)),0)}}return t.encoder_outputs=o,t}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:t,model_kwargs:r,decoder_start_token_id:n,bos_token_id:o,generation_config:s}){let{decoder_input_ids:a,...i}=r;if(a)Array.isArray(a[0])||(a=Array.from({length:e},(()=>a)));else if(n??=o,"musicgen"===this.config.model_type)a=Array.from({length:e*this.config.decoder.num_codebooks},(()=>[n]));else if(Array.isArray(n)){if(n.length!==e)throw new Error(`\`decoder_start_token_id\` expcted to have length ${e} but got ${n.length}`);a=n}else a=Array.from({length:e},(()=>[n]));return a=L(a),r.decoder_attention_mask=(0,u.ones_like)(a),{input_ids:a,model_inputs:i}}async generate({inputs:e=null,generation_config:t=null,logits_processor:r=null,stopping_criteria:n=null,streamer:o=null,...s}){this._validate_model_class(),t=this._prepare_generation_config(t,s);let{inputs_tensor:a,model_inputs:i,model_input_name:l}=this._prepare_model_inputs({inputs:e,model_kwargs:s});const c=this.config.is_encoder_decoder;let d;c&&("encoder_outputs"in i||(i=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:a,model_inputs:i,model_input_name:l,generation_config:t}))),c?({input_ids:d,model_inputs:i}=this._prepare_decoder_input_ids_for_generation({batch_size:i[l].dims.at(0),model_input_name:l,model_kwargs:i,decoder_start_token_id:t.decoder_start_token_id,bos_token_id:t.bos_token_id,generation_config:t})):d=i[l];let p=d.dims.at(-1);null!==t.max_new_tokens&&(t.max_length=p+t.max_new_tokens);const h=this._get_logits_processor(t,p,r),_=this._get_stopping_criteria(t,n),f=i[l].dims.at(0),g=m.LogitsSampler.getSampler(t),M=new Array(f).fill(0),w=d.tolist();let T;o&&o.put(w);let b={};for(;;){if(i=this.prepare_inputs_for_generation(w,i,t),T=await this.forward(i),t.output_attentions&&t.return_dict_in_generate){const e=this.getAttentions(T);for(const t in e)t in b||(b[t]=[]),b[t].push(e[t])}const e=h(w,T.logits.slice(null,-1,null)),r=[];for(let t=0;t<e.dims.at(0);++t){const n=e[t],o=await g(n);for(const[e,n]of o){const o=BigInt(e);M[t]+=n,w[t].push(o),r.push([o]);break}}o&&o.put(r);if(_(w).every((e=>e)))break;i=this._update_model_kwargs_for_generation({generated_input_ids:r,outputs:T,model_inputs:i,is_encoder_decoder:c})}o&&o.end();const x=this.getPastKeyValues(T,i.past_key_values,!0),k=new u.Tensor("int64",w.flat(),[w.length,w[0].length]);if(t.return_dict_in_generate)return{sequences:k,past_key_values:x,...b};for(const e of Object.values(T))"gpu-buffer"===e.location&&e.dispose();return k}getPastKeyValues(e,t,r=!1){const n=Object.create(null);for(const o in e)if(o.startsWith("present")){const s=o.replace("present","past_key_values"),a=o.includes("encoder");if(n[s]=a&&t?t[s]:e[o],t&&(!a||r)){const e=t[s];"gpu-buffer"===e.location&&e.dispose()}}return n}getAttentions(e){const t={};for(const r of["cross_attentions","encoder_attentions","decoder_attentions"])for(const n in e)n.startsWith(r)&&(r in t||(t[r]=[]),t[r].push(e[n]));return t}addPastKeyValues(e,t){if(t)Object.assign(e,t);else{const t=this.custom_config.kv_cache_dtype??"float32",r="float16"===t?new Uint16Array:[],o=(0,n.getKeyValueShapes)(this.config);for(const n in o)e[n]=new u.Tensor(t,r,o[n])}}async encode_image({pixel_values:e}){const t=(await A(this.sessions.vision_encoder,{pixel_values:e})).image_features;return this.config.num_image_tokens||(console.warn(`The number of image tokens was not set in the model configuration. Setting it to the number of features detected by the vision encoder (${t.dims[1]}).`),this.config.num_image_tokens=t.dims[1]),t}async encode_text({input_ids:e}){return(await A(this.sessions.embed_tokens,{input_ids:e})).inputs_embeds}}class G{}class q extends G{constructor({last_hidden_state:e,hidden_states:t=null,attentions:r=null}){super(),this.last_hidden_state=e,this.hidden_states=t,this.attentions=r}}class $ extends R{}class W extends ${}class U extends ${async _call(e){return new cl(await super._call(e))}}class X extends ${async _call(e){return new al(await super._call(e))}}class Q extends ${async _call(e){return new ll(await super._call(e))}}class H extends ${async _call(e){return new dl(await super._call(e))}}class Y extends R{}class J extends Y{}class K extends R{}class Z extends K{}class ee extends K{async _call(e){return new cl(await super._call(e))}}class te extends K{async _call(e){return new al(await super._call(e))}}class re extends K{async _call(e){return new ll(await super._call(e))}}class ne extends K{async _call(e){return new dl(await super._call(e))}}class oe extends R{}class se extends oe{}class ae extends oe{async _call(e){return new cl(await super._call(e))}}class ie extends oe{async _call(e){return new al(await super._call(e))}}class le extends oe{async _call(e){return new ll(await super._call(e))}}class ce extends oe{async _call(e){return new dl(await super._call(e))}}class de extends R{}class ue extends de{}class pe extends de{async _call(e){return new cl(await super._call(e))}}class he extends de{async _call(e){return new al(await super._call(e))}}class me extends de{async _call(e){return new ll(await super._call(e))}}class _e extends de{async _call(e){return new dl(await super._call(e))}}class fe extends R{}class ge extends fe{}class Me extends fe{async _call(e){return new cl(await super._call(e))}}class we extends fe{async _call(e){return new al(await super._call(e))}}class Te extends fe{async _call(e){return new ll(await super._call(e))}}class be extends fe{async _call(e){return new dl(await super._call(e))}}class xe extends R{}class ke extends xe{}class ye extends xe{async _call(e){return new cl(await super._call(e))}}class Fe extends xe{async _call(e){return new al(await super._call(e))}}class Pe extends xe{async _call(e){return new ll(await super._call(e))}}class Ce extends xe{async _call(e){return new dl(await super._call(e))}}class ve extends R{}class Se extends ve{}class Ae extends ve{async _call(e){return new cl(await super._call(e))}}class Ee extends ve{async _call(e){return new al(await super._call(e))}}class Le extends ve{async _call(e){return new ll(await super._call(e))}}class ze extends ve{async _call(e){return new dl(await super._call(e))}}class Ie extends R{}class Be extends Ie{}class Ne extends Ie{async _call(e){return new al(await super._call(e))}}class Oe extends Ie{async _call(e){return new ll(await super._call(e))}}class De extends Ie{async _call(e){return new dl(await super._call(e))}}class Ve extends Ie{async _call(e){return new cl(await super._call(e))}}class je extends R{}class Re extends je{}class Ge extends je{async _call(e){return new cl(await super._call(e))}}class qe extends je{async _call(e){return new al(await super._call(e))}}class $e extends je{async _call(e){return new ll(await super._call(e))}}class We extends R{}class Ue extends We{}class Xe extends We{async _call(e){return new cl(await super._call(e))}}class Qe extends We{async _call(e){return new al(await super._call(e))}}class He extends We{async _call(e){return new dl(await super._call(e))}}class Ye extends R{}class Je extends Ye{}class Ke extends Ye{async _call(e){return new cl(await super._call(e))}}class Ze extends Ye{async _call(e){return new al(await super._call(e))}}class et extends Ye{async _call(e){return new ll(await super._call(e))}}class tt extends Ye{async _call(e){return new dl(await super._call(e))}}class rt extends R{}class nt extends rt{}class ot extends rt{async _call(e){return new cl(await super._call(e))}}class st extends rt{async _call(e){return new al(await super._call(e))}}class at extends rt{async _call(e){return new dl(await super._call(e))}}class it extends R{}class lt extends it{}class ct extends it{async _call(e){return new al(await super._call(e))}}class dt extends it{async _call(e){return new dl(await super._call(e))}}class ut extends it{async _call(e){return new cl(await super._call(e))}}class pt extends R{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"];constructor(e,t,r){super(e,t),this.generation_config=r}}class ht extends pt{}class mt extends pt{}class _t extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class ft extends _t{}class gt extends _t{}class Mt extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class wt extends Mt{}class Tt extends Mt{}class bt extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class xt extends bt{}class kt extends bt{}class yt extends bt{async _call(e){return new al(await super._call(e))}}class Ft extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Pt extends Ft{}class Ct extends Ft{}class vt extends Ft{async _call(e){return new al(await super._call(e))}}class St extends Ft{}class At extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Et extends At{}class Lt extends At{}class zt extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class It extends zt{}class Bt extends zt{}class Nt extends R{}class Ot extends Nt{}class Dt extends Nt{async _call(e){return new cl(await super._call(e))}}class Vt extends Nt{async _call(e){return new al(await super._call(e))}}class jt extends Nt{async _call(e){return new ll(await super._call(e))}}class Rt extends Nt{async _call(e){return new dl(await super._call(e))}}class Gt extends R{}class qt extends Gt{}class $t extends Gt{async _call(e){return new cl(await super._call(e))}}class Wt extends Gt{async _call(e){return new al(await super._call(e))}}class Ut extends Gt{async _call(e){return new ll(await super._call(e))}}class Xt extends Gt{async _call(e){return new dl(await super._call(e))}}class Qt extends R{}class Ht extends Qt{}class Yt extends Qt{async _call(e){return new cl(await super._call(e))}}class Jt extends Qt{async _call(e){return new al(await super._call(e))}}class Kt extends Qt{async _call(e){return new ll(await super._call(e))}}class Zt extends Qt{async _call(e){return new dl(await super._call(e))}}class er extends R{}class tr extends er{}class rr extends er{}class nr extends R{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","attention_mask","decoder_input_ids","decoder_attention_mask","past_key_values"];constructor(e,t,r){super(e,t),this.generation_config=r}}class or extends nr{}class sr extends nr{_prepare_generation_config(e,t){return super._prepare_generation_config(e,t,f.WhisperGenerationConfig)}_retrieve_init_tokens(e){const t=[e.decoder_start_token_id];let r=e.language;const n=e.task;if(e.is_multilingual){r||(console.warn("No language specified - defaulting to English (en)."),r="en");const o=`<|${(0,g.whisper_language_to_code)(r)}|>`;t.push(e.lang_to_id[o]),t.push(e.task_to_id[n??"transcribe"])}else if(r||n)throw new Error("Cannot specify `task` or `language` for an English-only model. If the model is intended to be multilingual, pass `is_multilingual=true` to generate, or update the generation config.");return!e.return_timestamps&&e.no_timestamps_token_id&&t.at(-1)!==e.no_timestamps_token_id?t.push(e.no_timestamps_token_id):e.return_timestamps&&t.at(-1)===e.no_timestamps_token_id&&(console.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),t.pop()),t.filter((e=>null!=e))}async generate({inputs:e=null,generation_config:t=null,logits_processor:r=null,stopping_criteria:n=null,...o}){t=this._prepare_generation_config(t,o);const s=o.decoder_input_ids??this._retrieve_init_tokens(t);if(t.return_timestamps&&(r??=new c.LogitsProcessorList,r.push(new c.WhisperTimeStampLogitsProcessor(t,s))),t.begin_suppress_tokens&&(r??=new c.LogitsProcessorList,r.push(new c.SuppressTokensAtBeginLogitsProcessor(t.begin_suppress_tokens,s.length))),t.return_token_timestamps){if(!t.alignment_heads)throw new Error("Model generation config has no `alignment_heads`, token-level timestamps not available. See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config.");"translate"===t.task&&console.warn("Token-level timestamps may not be reliable for task 'translate'."),t.output_attentions=!0,t.return_dict_in_generate=!0}const a=await super.generate({inputs:e,generation_config:t,logits_processor:r,decoder_input_ids:s,...o});return t.return_token_timestamps&&(a.token_timestamps=this._extract_token_timestamps(a,t.alignment_heads,t.num_frames)),a}_extract_token_timestamps(e,t,r=null,n=.02){if(!e.cross_attentions)throw new Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");null==r&&console.warn("`num_frames` has not been set, meaning the entire audio will be analyzed. This may lead to inaccurate token-level timestamps for short audios (< 30 seconds).");let o=this.config.median_filter_width;void 0===o&&(console.warn("Model config has no `median_filter_width`, using default value of 7."),o=7);const s=e.cross_attentions,a=Array.from({length:this.config.decoder_layers},((e,t)=>(0,u.cat)(s.map((e=>e[t])),2))),l=(0,u.stack)(t.map((([e,t])=>{if(e>=a.length)throw new Error(`Layer index ${e} is out of bounds for cross attentions (length ${a.length}).`);return r?a[e].slice(null,t,null,[0,r]):a[e].slice(null,t)}))).transpose(1,0,2,3),[c,d]=(0,u.std_mean)(l,-2,0,!0),h=l.clone();for(let e=0;e<h.dims[0];++e){const t=h[e];for(let r=0;r<t.dims[0];++r){const n=t[r],s=c[e][r][0].data,a=d[e][r][0].data;for(let e=0;e<n.dims[0];++e){let t=n[e].data;for(let e=0;e<t.length;++e)t[e]=(t[e]-a[e])/s[e];t.set((0,p.medianFilter)(t,o))}}}const m=[(0,u.mean)(h,1)],_=e.sequences.dims,f=new u.Tensor("float32",new Float32Array(_[0]*_[1]),_);for(let e=0;e<_[0];++e){const t=m[e].neg().squeeze_(0),[r,o]=(0,p.dynamic_time_warping)(t.tolist()),s=Array.from({length:r.length-1},((e,t)=>r[t+1]-r[t])),a=(0,i.mergeArrays)([1],s).map((e=>!!e)),l=[];for(let e=0;e<a.length;++e)a[e]&&l.push(o[e]*n);f[e].data.set(l,1)}return f}}class ar extends R{main_input_name="pixel_values";forward_params=["pixel_values","input_ids","encoder_hidden_states","past_key_values"];constructor(e,t,r){super(e,t),this.generation_config=r}}class ir extends R{forward_params=["input_ids","pixel_values","attention_mask","position_ids","past_key_values"];constructor(e,t,r){super(e,t),this.generation_config=r}}class lr extends ir{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:t,input_ids:r,attention_mask:n}){const o=this.config.image_token_index,s=r.tolist().map((e=>e.findIndex((e=>e==o)))),a=s.every((e=>-1===e)),i=s.every((e=>-1!==e));if(!a&&!i)throw new Error("Every input should contain either 0 or 1 image token.");if(a)return{inputs_embeds:e,attention_mask:n};const l=[],c=[];for(let r=0;r<s.length;++r){const o=s[r],a=e[r],i=t[r],d=n[r];l.push((0,u.cat)([a.slice([0,o]),i,a.slice([o+1,a.dims[0]])],0)),c.push((0,u.cat)([d.slice([0,o]),(0,u.ones)([i.dims[0]]),d.slice([o+1,d.dims[0]])],0))}return{inputs_embeds:(0,u.stack)(l,0),attention_mask:(0,u.stack)(c,0)}}}class cr extends lr{}class dr extends R{forward_params=["input_ids","inputs_embeds","attention_mask","pixel_values","encoder_outputs","decoder_input_ids","decoder_inputs_embeds","decoder_attention_mask","past_key_values"];main_input_name="inputs_embeds";constructor(e,t,r){super(e,t),this.generation_config=r}}class ur extends dr{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:t,input_ids:r,attention_mask:n}){return{inputs_embeds:(0,u.cat)([t,e],1),attention_mask:(0,u.cat)([(0,u.ones)(t.dims.slice(0,2)),n],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:r,attention_mask:n}){if(!e&&!t)throw new Error("Either `input_ids` or `pixel_values` should be provided.");let o,s;return e&&(o=await this.encode_text({input_ids:e})),t&&(s=await this.encode_image({pixel_values:t})),o&&s?({inputs_embeds:r,attention_mask:n}=this._merge_input_ids_with_image_features({inputs_embeds:o,image_features:s,input_ids:e,attention_mask:n})):r=o||s,{inputs_embeds:r,attention_mask:n}}async forward({input_ids:e,pixel_values:t,attention_mask:r,decoder_input_ids:n,decoder_attention_mask:o,encoder_outputs:s,past_key_values:a,inputs_embeds:i,decoder_inputs_embeds:l}){if(i||({inputs_embeds:i,attention_mask:r}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:i,attention_mask:r})),!s){let{last_hidden_state:e}=await B(this,{inputs_embeds:i,attention_mask:r});s=e}if(!l){if(!n)throw new Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");l=await this.encode_text({input_ids:n})}const c={inputs_embeds:l,attention_mask:o,encoder_attention_mask:r,encoder_hidden_states:s,past_key_values:a};return await N(this,c,!0)}}class pr extends R{}class hr extends pr{}class mr extends pr{static async from_pretrained(e,t={}){return t.model_file_name??="text_model",super.from_pretrained(e,t)}}class _r extends pr{static async from_pretrained(e,t={}){return t.model_file_name??="text_model",super.from_pretrained(e,t)}}class fr extends pr{static async from_pretrained(e,t={}){return t.model_file_name??="vision_model",super.from_pretrained(e,t)}}class gr extends pr{static async from_pretrained(e,t={}){return t.model_file_name??="vision_model",super.from_pretrained(e,t)}}class Mr extends R{}class wr extends Mr{}class Tr extends Mr{static async from_pretrained(e,t={}){return t.model_file_name??="text_model",super.from_pretrained(e,t)}}class br extends pr{static async from_pretrained(e,t={}){return t.model_file_name??="vision_model",super.from_pretrained(e,t)}}class xr extends R{}class kr extends xr{}class yr extends R{}class Fr extends yr{}class Pr extends yr{}class Cr extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class vr extends Cr{}class Sr extends Cr{}class Ar extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Er extends Ar{}class Lr extends Ar{}class zr extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Ir extends zr{}class Br extends zr{}class Nr extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Or extends Nr{}class Dr extends Nr{}class Vr extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class jr extends Vr{}class Rr extends Vr{}class Gr extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class qr extends Gr{}class $r extends Gr{}class Wr extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Ur extends Wr{}class Xr extends Wr{}class Qr extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Hr extends Qr{}class Yr extends Qr{}class Jr extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Kr extends Jr{}class Zr extends Jr{}class en extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class tn extends en{}class rn extends en{}class nn extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class on extends nn{}class sn extends nn{}class an extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class ln extends an{}class cn extends an{}class dn extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class un extends dn{}class pn extends dn{}class hn extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class mn extends hn{}class _n extends hn{}class fn extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class gn extends fn{}class Mn extends fn{}class wn extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Tn extends wn{}class bn extends wn{}class xn extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class kn extends xn{}class yn extends xn{}class Fn extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Pn extends Fn{}class Cn extends Fn{}class vn extends R{}class Sn extends vn{}class An extends vn{async _call(e){return new al(await super._call(e))}}class En extends R{}class Ln extends En{}class zn extends En{async _call(e){return new al(await super._call(e))}}class In extends R{}class Bn extends In{}class Nn extends R{}class On extends Nn{}class Dn extends Nn{async _call(e){return new al(await super._call(e))}}class Vn extends R{}class jn extends Vn{}class Rn extends R{}class Gn extends Rn{}class qn extends Rn{async _call(e){return new al(await super._call(e))}}class $n extends R{}class Wn extends $n{async _call(e){return new hl(await super._call(e))}}class Un extends R{}class Xn extends Un{}class Qn extends Un{async _call(e){return new al(await super._call(e))}}class Hn extends R{}class Yn extends Hn{}class Jn extends Hn{async _call(e){return new al(await super._call(e))}}class Kn extends R{}class Zn extends Kn{}class eo extends Kn{}class to extends R{}class ro extends to{}class no extends to{}class oo extends R{}class so extends oo{}class ao extends oo{async _call(e){return new al(await super._call(e))}}class io extends R{}class lo extends io{}class co extends io{async _call(e){return new po(await super._call(e))}}class uo extends io{async _call(e){return new ho(await super._call(e))}}class po extends G{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}}class ho extends G{constructor({logits:e,pred_boxes:t,pred_masks:r}){super(),this.logits=e,this.pred_boxes=t,this.pred_masks=r}}class mo extends R{}class _o extends mo{}class fo extends mo{async _call(e){return new go(await super._call(e))}}class go extends G{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}}class Mo extends R{}class wo extends Mo{}class To extends Mo{async _call(e){return new bo(await super._call(e))}}class bo extends po{}class xo extends R{}class ko extends xo{}class yo extends xo{async _call(e){return new al(await super._call(e))}}class Fo extends R{}class Po extends Fo{}class Co extends Fo{async _call(e){return new al(await super._call(e))}}class vo extends R{}class So extends vo{}class Ao extends vo{async _call(e){return new al(await super._call(e))}}class Eo extends R{}class Lo extends Eo{}class zo extends Eo{async _call(e){return new al(await super._call(e))}}class Io extends R{}class Bo extends Io{}class No extends Io{}class Oo extends R{}class Do extends Oo{}class Vo extends Oo{}class jo extends R{}class Ro extends jo{}class Go extends R{}class qo extends Go{}class $o extends Go{}class Wo extends Go{}class Uo extends R{}class Xo extends Uo{}class Qo extends Uo{}class Ho extends R{}class Yo extends Ho{}class Jo extends Ho{}class Ko extends R{}class Zo extends Ko{}class es extends R{}class ts extends es{}class rs extends es{async _call(e){return new al(await super._call(e))}}class ns extends R{}class os extends ns{}class ss extends ns{async _call(e){return new al(await super._call(e))}}class as extends R{}class is extends as{}class ls extends as{async _call(e){return new al(await super._call(e))}}class cs extends R{}class ds extends cs{}class us extends cs{async _call(e){return new ps(await super._call(e))}}class ps extends G{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}}class hs extends R{}class ms extends hs{async get_image_embeddings({pixel_values:e}){return await B(this,{pixel_values:e})}async forward(e){if(e.image_embeddings&&e.image_positional_embeddings||(e={...e,...await this.get_image_embeddings(e)}),!e.input_labels&&e.input_points){const t=e.input_points.dims.slice(0,-1),r=t.reduce(((e,t)=>e*t),1);e.input_labels=new u.Tensor("int64",new BigInt64Array(r).fill(1n),t)}const t={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(t.input_points=e.input_points),e.input_labels&&(t.input_labels=e.input_labels),e.input_boxes&&(t.input_boxes=e.input_boxes),await A(this.sessions.prompt_encoder_mask_decoder,t)}async _call(e){return new _s(await super._call(e))}}class _s extends G{constructor({iou_scores:e,pred_masks:t}){super(),this.iou_scores=e,this.pred_masks=t}}class fs extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class gs extends fs{}class Ms extends fs{}class ws extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class Ts extends ws{}class bs extends ws{}class xs extends R{}class ks extends xs{}class ys extends xs{async _call(e){return new ul(await super._call(e))}}class Fs extends xs{async _call(e){return new al(await super._call(e))}}class Ps extends xs{async _call(e){return new ll(await super._call(e))}}class Cs extends R{}class vs extends Cs{}class Ss extends Cs{async _call(e){return new ll(await super._call(e))}}class As extends R{}class Es extends As{}class Ls extends R{}class zs extends Ls{}class Is extends Ls{async _call(e){return new ul(await super._call(e))}}class Bs extends Ls{async _call(e){return new al(await super._call(e))}}class Ns extends R{}class Os extends Ns{}class Ds extends Ns{async _call(e){return new ul(await super._call(e))}}class Vs extends Ns{async _call(e){return new al(await super._call(e))}}class js extends Ns{async _call(e){return new ll(await super._call(e))}}class Rs extends R{}class Gs extends Rs{}class qs extends Rs{async _call(e){return new ul(await super._call(e))}}class $s extends Rs{async _call(e){return new al(await super._call(e))}}class Ws extends R{}class Us extends xs{}class Xs extends xs{async _call(e){return new ul(await super._call(e))}}class Qs extends xs{async _call(e){return new al(await super._call(e))}}class Hs extends R{}class Ys extends Hs{}class Js extends Hs{async _call(e){return new ul(await super._call(e))}}class Ks extends Hs{async _call(e){return new al(await super._call(e))}}class Zs extends Hs{async _call(e){return new il(await super._call(e))}}class ea extends Hs{async _call(e){return new ll(await super._call(e))}}class ta extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class ra extends ta{}class na extends ta{}class oa extends ta{async generate_speech(e,t,{threshold:r=.5,minlenratio:n=0,maxlenratio:o=20,vocoder:s=null}={}){const a={input_ids:e},{encoder_outputs:i,encoder_attention_mask:l}=await B(this,a),c=i.dims[1]/this.config.reduction_factor,d=Math.floor(c*o),p=Math.floor(c*n),h=this.config.num_mel_bins;let m=[],_=null,f=null,g=0;for(;;){++g;const e=z(!!f);let n;n=f?f.output_sequence_out:new u.Tensor("float32",new Float32Array(h),[1,1,h]);let o={use_cache_branch:e,output_sequence:n,encoder_attention_mask:l,speaker_embeddings:t,encoder_hidden_states:i};this.addPastKeyValues(o,_),f=await A(this.sessions.decoder_model_merged,o),_=this.getPastKeyValues(f,_);const{prob:s,spectrum:a}=f;if(m.push(a),g>=p&&(Array.from(s.data).filter((e=>e>=r)).length>0||g>=d))break}const M=(0,u.cat)(m),{waveform:w}=await A(s.sessions.model,{spectrogram:M});return{spectrogram:M,waveform:w}}}class sa extends R{main_input_name="spectrogram"}class aa extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class ia extends aa{}class la extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class ca extends la{}class da extends la{}class ua extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class pa extends ua{}class ha extends ua{}class ma extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class _a extends ma{}class fa extends ma{}class ga extends R{}class Ma extends ga{}class wa extends ga{static async from_pretrained(e,t={}){return t.model_file_name??="text_model",super.from_pretrained(e,t)}}class Ta extends ga{static async from_pretrained(e,t={}){return t.model_file_name??="audio_model",super.from_pretrained(e,t)}}class ba extends R{}class xa extends ba{async _call(e){return new ml(await super._call(e))}}class ka extends R{}class ya extends ka{}class Fa extends ka{}class Pa extends ka{}class Ca extends R{constructor(e,t,r){super(e,t),this.generation_config=r}}class va extends Ca{}class Sa extends Ca{}class Aa extends R{}class Ea extends Aa{}class La extends Aa{async _call(e){return new al(await super._call(e))}}class za extends R{}class Ia extends za{}class Ba extends za{}class Na extends R{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"];constructor(e,t,r){super(e,t),this.generation_config=r}_apply_and_filter_by_delay_pattern_mask(e){const[t,r]=e.dims,n=this.config.decoder.num_codebooks,o=r-n;let s=0;for(let t=0;t<e.size;++t){if(e.data[t]===this.config.decoder.pad_token_id)continue;const a=t%r-Math.floor(t/r)%n;a>0&&a<=o&&(e.data[s++]=e.data[t])}const a=Math.floor(t/n),i=s/(a*n);return new u.Tensor(e.type,e.data.slice(0,s),[a,n,i])}prepare_inputs_for_generation(e,t,r){let n=structuredClone(e);for(let e=0;e<n.length;++e)for(let t=0;t<n[e].length;++t)e%this.config.decoder.num_codebooks>=t&&(n[e][t]=BigInt(this.config.decoder.pad_token_id));null!==r.guidance_scale&&r.guidance_scale>1&&(n=n.concat(n));return super.prepare_inputs_for_generation(n,t,r)}async generate(e){const t=await super.generate(e),r=this._apply_and_filter_by_delay_pattern_mask(t).unsqueeze_(0),{audio_values:n}=await A(this.sessions.encodec_decode,{audio_codes:r});return n}}class Oa extends R{}class Da extends Oa{}class Va extends Oa{async _call(e){return new al(await super._call(e))}}class ja extends R{}class Ra extends ja{}class Ga extends ja{async _call(e){return new al(await super._call(e))}}class qa extends R{}class $a extends qa{}class Wa extends qa{async _call(e){return new al(await super._call(e))}}class Ua extends R{}class Xa extends Ua{}class Qa extends Ua{async _call(e){return new al(await super._call(e))}}class Ha extends R{}class Ya extends Ha{}class Ja{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:o=null,local_files_only:s=!1,revision:a="main",model_file_name:i=null,subfolder:l="onnx",device:c=null,dtype:d=null,use_external_data_format:u=null,session_options:p={}}={}){const h={progress_callback:t,config:r,cache_dir:o,local_files_only:s,revision:a,model_file_name:i,subfolder:l,device:c,dtype:d,use_external_data_format:u,session_options:p};if(h.config=await n.AutoConfig.from_pretrained(e,h),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);for(const t of this.MODEL_CLASS_MAPPINGS){const r=t.get(h.config.model_type);if(r)return await r[1].from_pretrained(e,h)}if(this.BASE_IF_FAIL)return console.warn(`Unknown model class "${h.config.model_type}", attempting to construct from base class.`),await R.from_pretrained(e,h);throw Error(`Unsupported model type: ${h.config.model_type}`)}}const Ka=new Map([["bert",["BertModel",W]],["nomic_bert",["NomicBertModel",J]],["roformer",["RoFormerModel",Z]],["electra",["ElectraModel",ue]],["esm",["EsmModel",Re]],["convbert",["ConvBertModel",se]],["camembert",["CamembertModel",ge]],["deberta",["DebertaModel",ke]],["deberta-v2",["DebertaV2Model",Se]],["mpnet",["MPNetModel",Je]],["albert",["AlbertModel",lt]],["distilbert",["DistilBertModel",Be]],["roberta",["RobertaModel",Ot]],["xlm",["XLMModel",qt]],["xlm-roberta",["XLMRobertaModel",Ht]],["clap",["ClapModel",Ma]],["clip",["CLIPModel",hr]],["clipseg",["CLIPSegModel",Fr]],["chinese_clip",["ChineseCLIPModel",kr]],["siglip",["SiglipModel",wr]],["mobilebert",["MobileBertModel",Ue]],["squeezebert",["SqueezeBertModel",nt]],["wav2vec2",["Wav2Vec2Model",ks]],["wav2vec2-bert",["Wav2Vec2BertModel",Gs]],["unispeech",["UniSpeechModel",zs]],["unispeech-sat",["UniSpeechSatModel",Os]],["hubert",["HubertModel",Us]],["wavlm",["WavLMModel",Ys]],["audio-spectrogram-transformer",["ASTModel",tr]],["vits",["VitsModel",xa]],["pyannote",["PyAnnoteModel",vs]],["wespeaker-resnet",["WeSpeakerResNetModel",Es]],["detr",["DetrModel",lo]],["rt_detr",["RTDetrModel",_o]],["table-transformer",["TableTransformerModel",wo]],["vit",["ViTModel",Sn]],["pvt",["PvtModel",Ln]],["vit_msn",["ViTMSNModel",On]],["vit_mae",["ViTMAEModel",Bn]],["groupvit",["GroupViTModel",jn]],["fastvit",["FastViTModel",Gn]],["mobilevit",["MobileViTModel",Xn]],["mobilevitv2",["MobileViTV2Model",Yn]],["owlvit",["OwlViTModel",Zn]],["owlv2",["Owlv2Model",ro]],["beit",["BeitModel",so]],["deit",["DeiTModel",ko]],["hiera",["HieraModel",Po]],["convnext",["ConvNextModel",ts]],["convnextv2",["ConvNextV2Model",os]],["dinov2",["Dinov2Model",is]],["resnet",["ResNetModel",So]],["swin",["SwinModel",Lo]],["swin2sr",["Swin2SRModel",Bo]],["donut-swin",["DonutSwinModel",Zo]],["yolos",["YolosModel",ds]],["dpt",["DPTModel",Do]],["glpn",["GLPNModel",Yo]],["hifigan",["SpeechT5HifiGan",sa]],["efficientnet",["EfficientNetModel",Ea]],["decision_transformer",["DecisionTransformerModel",Ya]],["mobilenet_v1",["MobileNetV1Model",Da]],["mobilenet_v2",["MobileNetV2Model",Ra]],["mobilenet_v3",["MobileNetV3Model",$a]],["mobilenet_v4",["MobileNetV4Model",Xa]],["maskformer",["MaskFormerModel",Xo]]]),Za=new Map([["t5",["T5Model",ht]],["longt5",["LongT5Model",ft]],["mt5",["MT5Model",wt]],["bart",["BartModel",xt]],["mbart",["MBartModel",Pt]],["marian",["MarianModel",gs]],["whisper",["WhisperModel",or]],["m2m_100",["M2M100Model",Ts]],["blenderbot",["BlenderbotModel",Et]],["blenderbot-small",["BlenderbotSmallModel",It]]]),ei=new Map([["bloom",["BloomModel",Tn]],["jais",["JAISModel",Er]],["gpt2",["GPT2Model",vr]],["gptj",["GPTJModel",jr]],["gpt_bigcode",["GPTBigCodeModel",qr]],["gpt_neo",["GPTNeoModel",Ir]],["gpt_neox",["GPTNeoXModel",Or]],["codegen",["CodeGenModel",Ur]],["llama",["LlamaModel",Hr]],["cohere",["CohereModel",Kr]],["gemma",["GemmaModel",tn]],["gemma2",["Gemma2Model",on]],["openelm",["OpenELMModel",ln]],["qwen2",["Qwen2Model",un]],["phi",["PhiModel",mn]],["phi3",["Phi3Model",gn]],["mpt",["MptModel",kn]],["opt",["OPTModel",Pn]],["mistral",["MistralModel",ca]],["starcoder2",["Starcoder2Model",pa]],["falcon",["FalconModel",_a]],["stablelm",["StableLmModel",va]]]),ti=new Map([["speecht5",["SpeechT5ForSpeechToText",na]],["whisper",["WhisperForConditionalGeneration",sr]]]),ri=new Map([["speecht5",["SpeechT5ForTextToSpeech",oa]]]),ni=new Map([["vits",["VitsModel",xa]],["musicgen",["MusicgenForConditionalGeneration",Na]]]),oi=new Map([["bert",["BertForSequenceClassification",X]],["roformer",["RoFormerForSequenceClassification",te]],["electra",["ElectraForSequenceClassification",he]],["esm",["EsmForSequenceClassification",qe]],["convbert",["ConvBertForSequenceClassification",ie]],["camembert",["CamembertForSequenceClassification",we]],["deberta",["DebertaForSequenceClassification",Fe]],["deberta-v2",["DebertaV2ForSequenceClassification",Ee]],["mpnet",["MPNetForSequenceClassification",Ze]],["albert",["AlbertForSequenceClassification",ct]],["distilbert",["DistilBertForSequenceClassification",Ne]],["roberta",["RobertaForSequenceClassification",Vt]],["xlm",["XLMForSequenceClassification",Wt]],["xlm-roberta",["XLMRobertaForSequenceClassification",Jt]],["bart",["BartForSequenceClassification",yt]],["mbart",["MBartForSequenceClassification",vt]],["mobilebert",["MobileBertForSequenceClassification",Qe]],["squeezebert",["SqueezeBertForSequenceClassification",st]]]),si=new Map([["bert",["BertForTokenClassification",Q]],["roformer",["RoFormerForTokenClassification",re]],["electra",["ElectraForTokenClassification",me]],["esm",["EsmForTokenClassification",$e]],["convbert",["ConvBertForTokenClassification",le]],["camembert",["CamembertForTokenClassification",Te]],["deberta",["DebertaForTokenClassification",Pe]],["deberta-v2",["DebertaV2ForTokenClassification",Le]],["mpnet",["MPNetForTokenClassification",et]],["distilbert",["DistilBertForTokenClassification",Oe]],["roberta",["RobertaForTokenClassification",jt]],["xlm",["XLMForTokenClassification",Ut]],["xlm-roberta",["XLMRobertaForTokenClassification",Kt]]]),ai=new Map([["t5",["T5ForConditionalGeneration",mt]],["longt5",["LongT5ForConditionalGeneration",gt]],["mt5",["MT5ForConditionalGeneration",Tt]],["bart",["BartForConditionalGeneration",kt]],["mbart",["MBartForConditionalGeneration",Ct]],["marian",["MarianMTModel",Ms]],["m2m_100",["M2M100ForConditionalGeneration",bs]],["blenderbot",["BlenderbotForConditionalGeneration",Lt]],["blenderbot-small",["BlenderbotSmallForConditionalGeneration",Bt]]]),ii=new Map([["bloom",["BloomForCausalLM",bn]],["gpt2",["GPT2LMHeadModel",Sr]],["jais",["JAISLMHeadModel",Lr]],["gptj",["GPTJForCausalLM",Rr]],["gpt_bigcode",["GPTBigCodeForCausalLM",$r]],["gpt_neo",["GPTNeoForCausalLM",Br]],["gpt_neox",["GPTNeoXForCausalLM",Dr]],["codegen",["CodeGenForCausalLM",Xr]],["llama",["LlamaForCausalLM",Yr]],["cohere",["CohereForCausalLM",Zr]],["gemma",["GemmaForCausalLM",rn]],["gemma2",["Gemma2ForCausalLM",sn]],["openelm",["OpenELMForCausalLM",cn]],["qwen2",["Qwen2ForCausalLM",pn]],["phi",["PhiForCausalLM",_n]],["phi3",["Phi3ForCausalLM",Mn]],["mpt",["MptForCausalLM",yn]],["opt",["OPTForCausalLM",Cn]],["mbart",["MBartForCausalLM",St]],["mistral",["MistralForCausalLM",da]],["starcoder2",["Starcoder2ForCausalLM",ha]],["falcon",["FalconForCausalLM",fa]],["trocr",["TrOCRForCausalLM",ia]],["stablelm",["StableLmForCausalLM",Sa]]]),li=new Map([["bert",["BertForMaskedLM",U]],["roformer",["RoFormerForMaskedLM",ee]],["electra",["ElectraForMaskedLM",pe]],["esm",["EsmForMaskedLM",Ge]],["convbert",["ConvBertForMaskedLM",ae]],["camembert",["CamembertForMaskedLM",Me]],["deberta",["DebertaForMaskedLM",ye]],["deberta-v2",["DebertaV2ForMaskedLM",Ae]],["mpnet",["MPNetForMaskedLM",Ke]],["albert",["AlbertForMaskedLM",ut]],["distilbert",["DistilBertForMaskedLM",Ve]],["roberta",["RobertaForMaskedLM",Dt]],["xlm",["XLMWithLMHeadModel",$t]],["xlm-roberta",["XLMRobertaForMaskedLM",Yt]],["mobilebert",["MobileBertForMaskedLM",Xe]],["squeezebert",["SqueezeBertForMaskedLM",ot]]]),ci=new Map([["bert",["BertForQuestionAnswering",H]],["roformer",["RoFormerForQuestionAnswering",ne]],["electra",["ElectraForQuestionAnswering",_e]],["convbert",["ConvBertForQuestionAnswering",ce]],["camembert",["CamembertForQuestionAnswering",be]],["deberta",["DebertaForQuestionAnswering",Ce]],["deberta-v2",["DebertaV2ForQuestionAnswering",ze]],["mpnet",["MPNetForQuestionAnswering",tt]],["albert",["AlbertForQuestionAnswering",dt]],["distilbert",["DistilBertForQuestionAnswering",De]],["roberta",["RobertaForQuestionAnswering",Rt]],["xlm",["XLMForQuestionAnswering",Xt]],["xlm-roberta",["XLMRobertaForQuestionAnswering",Zt]],["mobilebert",["MobileBertForQuestionAnswering",He]],["squeezebert",["SqueezeBertForQuestionAnswering",at]]]),di=new Map([["vision-encoder-decoder",["VisionEncoderDecoderModel",ar]]]),ui=new Map([["llava",["LlavaForConditionalGeneration",lr]],["moondream1",["Moondream1ForConditionalGeneration",cr]],["florence2",["Florence2ForConditionalGeneration",ur]]]),pi=new Map([["vision-encoder-decoder",["VisionEncoderDecoderModel",ar]]]),hi=new Map([["vit",["ViTForImageClassification",An]],["pvt",["PvtForImageClassification",zn]],["vit_msn",["ViTMSNForImageClassification",Dn]],["fastvit",["FastViTForImageClassification",qn]],["mobilevit",["MobileViTForImageClassification",Qn]],["mobilevitv2",["MobileViTV2ForImageClassification",Jn]],["beit",["BeitForImageClassification",ao]],["deit",["DeiTForImageClassification",yo]],["hiera",["HieraForImageClassification",Co]],["convnext",["ConvNextForImageClassification",rs]],["convnextv2",["ConvNextV2ForImageClassification",ss]],["dinov2",["Dinov2ForImageClassification",ls]],["resnet",["ResNetForImageClassification",Ao]],["swin",["SwinForImageClassification",zo]],["segformer",["SegformerForImageClassification",Fa]],["efficientnet",["EfficientNetForImageClassification",La]],["mobilenet_v1",["MobileNetV1ForImageClassification",Va]],["mobilenet_v2",["MobileNetV2ForImageClassification",Ga]],["mobilenet_v3",["MobileNetV3ForImageClassification",Wa]],["mobilenet_v4",["MobileNetV4ForImageClassification",Qa]]]),mi=new Map([["detr",["DetrForObjectDetection",co]],["rt_detr",["RTDetrForObjectDetection",fo]],["table-transformer",["TableTransformerForObjectDetection",To]],["yolos",["YolosForObjectDetection",us]]]),_i=new Map([["owlvit",["OwlViTForObjectDetection",eo]],["owlv2",["Owlv2ForObjectDetection",no]]]),fi=new Map([["detr",["DetrForSegmentation",uo]],["clipseg",["CLIPSegForImageSegmentation",Pr]]]),gi=new Map([["segformer",["SegformerForSemanticSegmentation",Pa]],["sapiens",["SapiensForSemanticSegmentation",qo]]]),Mi=new Map([["detr",["DetrForSegmentation",uo]],["maskformer",["MaskFormerForInstanceSegmentation",Qo]]]),wi=new Map([["sam",["SamModel",ms]]]),Ti=new Map([["wav2vec2",["Wav2Vec2ForCTC",ys]],["wav2vec2-bert",["Wav2Vec2BertForCTC",qs]],["unispeech",["UniSpeechForCTC",Is]],["unispeech-sat",["UniSpeechSatForCTC",Ds]],["wavlm",["WavLMForCTC",Js]],["hubert",["HubertForCTC",Xs]]]),bi=new Map([["wav2vec2",["Wav2Vec2ForSequenceClassification",Fs]],["wav2vec2-bert",["Wav2Vec2BertForSequenceClassification",$s]],["unispeech",["UniSpeechForSequenceClassification",Bs]],["unispeech-sat",["UniSpeechSatForSequenceClassification",Vs]],["wavlm",["WavLMForSequenceClassification",Ks]],["hubert",["HubertForSequenceClassification",Qs]],["audio-spectrogram-transformer",["ASTForAudioClassification",rr]]]),xi=new Map([["wavlm",["WavLMForXVector",Zs]]]),ki=new Map([["unispeech-sat",["UniSpeechSatForAudioFrameClassification",js]],["wavlm",["WavLMForAudioFrameClassification",ea]],["wav2vec2",["Wav2Vec2ForAudioFrameClassification",Ps]],["pyannote",["PyAnnoteForAudioFrameClassification",Ss]]]),yi=new Map([["vitmatte",["VitMatteForImageMatting",Wn]]]),Fi=new Map([["swin2sr",["Swin2SRForImageSuperResolution",No]]]),Pi=new Map([["dpt",["DPTForDepthEstimation",Vo]],["depth_anything",["DepthAnythingForDepthEstimation",Ro]],["glpn",["GLPNForDepthEstimation",Jo]],["sapiens",["SapiensForDepthEstimation",$o]]]),Ci=new Map([["sapiens",["SapiensForNormalEstimation",Wo]]]),vi=new Map([["clip",["CLIPVisionModelWithProjection",gr]],["siglip",["SiglipVisionModel",br]]]),Si=[[Ka,M],[Za,w],[ei,x],[oi,M],[si,M],[ai,T],[ti,T],[ii,x],[li,M],[ci,M],[di,b],[ui,y],[hi,M],[fi,M],[Mi,M],[gi,M],[yi,M],[Fi,M],[Pi,M],[Ci,M],[mi,M],[_i,M],[wi,k],[Ti,M],[bi,M],[ri,T],[ni,M],[xi,M],[ki,M],[vi,M]];for(const[e,t]of Si)for(const[r,n]of e.values())P.set(r,t),v.set(n,r),C.set(r,n);const Ai=[["MusicgenForConditionalGeneration",Na,F],["CLIPTextModelWithProjection",_r,M],["SiglipTextModel",Tr,M],["ClapTextModelWithProjection",wa,M],["ClapAudioModelWithProjection",Ta,M]];for(const[e,t,r]of Ai)P.set(e,r),v.set(t,e),C.set(e,t);class Ei extends Ja{static MODEL_CLASS_MAPPINGS=Si.map((e=>e[0]));static BASE_IF_FAIL=!0}class Li extends Ja{static MODEL_CLASS_MAPPINGS=[oi]}class zi extends Ja{static MODEL_CLASS_MAPPINGS=[si]}class Ii extends Ja{static MODEL_CLASS_MAPPINGS=[ai]}class Bi extends Ja{static MODEL_CLASS_MAPPINGS=[ti]}class Ni extends Ja{static MODEL_CLASS_MAPPINGS=[ri]}class Oi extends Ja{static MODEL_CLASS_MAPPINGS=[ni]}class Di extends Ja{static MODEL_CLASS_MAPPINGS=[ii]}class Vi extends Ja{static MODEL_CLASS_MAPPINGS=[li]}class ji extends Ja{static MODEL_CLASS_MAPPINGS=[ci]}class Ri extends Ja{static MODEL_CLASS_MAPPINGS=[di]}class Gi extends Ja{static MODEL_CLASS_MAPPINGS=[hi]}class qi extends Ja{static MODEL_CLASS_MAPPINGS=[fi]}class $i extends Ja{static MODEL_CLASS_MAPPINGS=[gi]}class Wi extends Ja{static MODEL_CLASS_MAPPINGS=[Mi]}class Ui extends Ja{static MODEL_CLASS_MAPPINGS=[mi]}class Xi extends Ja{static MODEL_CLASS_MAPPINGS=[_i]}class Qi extends Ja{static MODEL_CLASS_MAPPINGS=[wi]}class Hi extends Ja{static MODEL_CLASS_MAPPINGS=[Ti]}class Yi extends Ja{static MODEL_CLASS_MAPPINGS=[bi]}class Ji extends Ja{static MODEL_CLASS_MAPPINGS=[xi]}class Ki extends Ja{static MODEL_CLASS_MAPPINGS=[ki]}class Zi extends Ja{static MODEL_CLASS_MAPPINGS=[pi]}class el extends Ja{static MODEL_CLASS_MAPPINGS=[yi]}class tl extends Ja{static MODEL_CLASS_MAPPINGS=[Fi]}class rl extends Ja{static MODEL_CLASS_MAPPINGS=[Pi]}class nl extends Ja{static MODEL_CLASS_MAPPINGS=[Ci]}class ol extends Ja{static MODEL_CLASS_MAPPINGS=[vi]}class sl extends G{constructor({logits:e,past_key_values:t,encoder_outputs:r,decoder_attentions:n=null,cross_attentions:o=null}){super(),this.logits=e,this.past_key_values=t,this.encoder_outputs=r,this.decoder_attentions=n,this.cross_attentions=o}}class al extends G{constructor({logits:e}){super(),this.logits=e}}class il extends G{constructor({logits:e,embeddings:t}){super(),this.logits=e,this.embeddings=t}}class ll extends G{constructor({logits:e}){super(),this.logits=e}}class cl extends G{constructor({logits:e}){super(),this.logits=e}}class dl extends G{constructor({start_logits:e,end_logits:t}){super(),this.start_logits=e,this.end_logits=t}}class ul extends G{constructor({logits:e}){super(),this.logits=e}}class pl extends G{constructor({logits:e,past_key_values:t}){super(),this.logits=e,this.past_key_values=t}}class hl extends G{constructor({alphas:e}){super(),this.alphas=e}}class ml extends G{constructor({waveform:e,spectrogram:t}){super(),this.waveform=e,this.spectrogram=t}}},"./src/models/whisper/common_whisper.js":
/*!**********************************************!*\
!*** ./src/models/whisper/common_whisper.js ***!
\**********************************************/(e,t,r)=>{r.r(t),r.d(t,{WHISPER_LANGUAGE_MAPPING:()=>o,WHISPER_TO_LANGUAGE_CODE_MAPPING:()=>s,whisper_language_to_code:()=>a});const n=[["en","english"],["zh","chinese"],["de","german"],["es","spanish"],["ru","russian"],["ko","korean"],["fr","french"],["ja","japanese"],["pt","portuguese"],["tr","turkish"],["pl","polish"],["ca","catalan"],["nl","dutch"],["ar","arabic"],["sv","swedish"],["it","italian"],["id","indonesian"],["hi","hindi"],["fi","finnish"],["vi","vietnamese"],["he","hebrew"],["uk","ukrainian"],["el","greek"],["ms","malay"],["cs","czech"],["ro","romanian"],["da","danish"],["hu","hungarian"],["ta","tamil"],["no","norwegian"],["th","thai"],["ur","urdu"],["hr","croatian"],["bg","bulgarian"],["lt","lithuanian"],["la","latin"],["mi","maori"],["ml","malayalam"],["cy","welsh"],["sk","slovak"],["te","telugu"],["fa","persian"],["lv","latvian"],["bn","bengali"],["sr","serbian"],["az","azerbaijani"],["sl","slovenian"],["kn","kannada"],["et","estonian"],["mk","macedonian"],["br","breton"],["eu","basque"],["is","icelandic"],["hy","armenian"],["ne","nepali"],["mn","mongolian"],["bs","bosnian"],["kk","kazakh"],["sq","albanian"],["sw","swahili"],["gl","galician"],["mr","marathi"],["pa","punjabi"],["si","sinhala"],["km","khmer"],["sn","shona"],["yo","yoruba"],["so","somali"],["af","afrikaans"],["oc","occitan"],["ka","georgian"],["be","belarusian"],["tg","tajik"],["sd","sindhi"],["gu","gujarati"],["am","amharic"],["yi","yiddish"],["lo","lao"],["uz","uzbek"],["fo","faroese"],["ht","haitian creole"],["ps","pashto"],["tk","turkmen"],["nn","nynorsk"],["mt","maltese"],["sa","sanskrit"],["lb","luxembourgish"],["my","myanmar"],["bo","tibetan"],["tl","tagalog"],["mg","malagasy"],["as","assamese"],["tt","tatar"],["haw","hawaiian"],["ln","lingala"],["ha","hausa"],["ba","bashkir"],["jw","javanese"],["su","sundanese"]],o=new Map(n),s=new Map([...n.map((([e,t])=>[t,e])),["burmese","my"],["valencian","ca"],["flemish","nl"],["haitian","ht"],["letzeburgesch","lb"],["pushto","ps"],["panjabi","pa"],["moldavian","ro"],["moldovan","ro"],["sinhalese","si"],["castilian","es"]]);function a(e){e=e.toLowerCase();let t=s.get(e);if(void 0===t){if(!o.has(e)){const t=2===e.length?o.keys():o.values();throw new Error(`Language "${e}" is not supported. Must be one of: ${JSON.stringify(t)}`)}t=e}return t}},"./src/models/whisper/generation_whisper.js":
/*!**************************************************!*\
!*** ./src/models/whisper/generation_whisper.js ***!
\**************************************************/(e,t,r)=>{r.r(t),r.d(t,{WhisperGenerationConfig:()=>o});var n=r(/*! ../../generation/configuration_utils.js */"./src/generation/configuration_utils.js");class o extends n.GenerationConfig{return_timestamps=null;return_token_timestamps=null;num_frames=null;alignment_heads=null;task=null;language=null;no_timestamps_token_id=null;prompt_ids=null;is_multilingual=null;lang_to_id=null;task_to_id=null;max_initial_timestamp_index=1}},"./src/ops/registry.js":
/*!*****************************!*\
!*** ./src/ops/registry.js ***!
\*****************************/(e,t,r)=>{r.r(t),r.d(t,{TensorOpRegistry:()=>a});var n=r(/*! ../backends/onnx.js */"./src/backends/onnx.js"),o=r(/*! ../utils/tensor.js */"./src/utils/tensor.js");const s=async(e,t,r)=>{const s=await(0,n.createInferenceSession)(new Uint8Array(e),t);return async e=>{const t=Object.fromEntries(Object.entries(e).map((([e,t])=>[e,t.ort_tensor]))),n=await s.run(t);return Array.isArray(r)?r.map((e=>new o.Tensor(n[e]))):new o.Tensor(n[r])}};class a{static session_options={};static get bilinear_interpolate_4d(){return this._bilinear_interpolate_4d||(this._bilinear_interpolate_4d=s([8,9,18,0,58,128,1,10,40,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,17,10,4,109,111,100,101,34,6,108,105,110,101,97,114,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bilinear_interpolate_4d}static get bicubic_interpolate_4d(){return this._bicubic_interpolate_4d||(this._bicubic_interpolate_4d=s([8,9,18,0,58,127,10,39,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,16,10,4,109,111,100,101,34,5,99,117,98,105,99,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bicubic_interpolate_4d}static get matmul(){return this._matmul||(this._matmul=s([8,9,18,0,58,55,10,17,10,1,97,10,1,98,18,1,99,34,6,77,97,116,77,117,108,18,1,114,90,9,10,1,97,18,4,10,2,8,1,90,9,10,1,98,18,4,10,2,8,1,98,9,10,1,99,18,4,10,2,8,1,66,2,16,20],this.session_options,"c")),this._matmul}static get stft(){return this._stft||(this._stft=s([8,7,18,0,58,148,1,10,38,10,1,115,10,1,106,10,1,119,10,1,108,18,1,111,34,4,83,84,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,115,90,26,10,1,115,18,21,10,19,8,1,18,15,10,3,18,1,98,10,3,18,1,115,10,3,18,1,99,90,11,10,1,106,18,6,10,4,8,7,18,0,90,16,10,1,119,18,11,10,9,8,1,18,5,10,3,18,1,119,90,11,10,1,108,18,6,10,4,8,7,18,0,98,31,10,1,111,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,102,10,3,18,1,100,10,3,18,1,99,66,2,16,17],this.session_options,"o")),this._stft}static get rfft(){return this._rfft||(this._rfft=s([8,9,18,0,58,97,10,33,10,1,120,10,0,10,1,97,18,1,121,34,3,68,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,100,90,21,10,1,120,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,90,11,10,1,97,18,6,10,4,8,7,18,0,98,21,10,1,121,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,66,2,16,20],this.session_options,"y")),this._rfft}static get top_k(){return this._top_k||(this._top_k=s([8,10,18,0,58,73,10,18,10,1,120,10,1,107,18,1,118,18,1,105,34,4,84,111,112,75,18,1,116,90,9,10,1,120,18,4,10,2,8,1,90,15,10,1,107,18,10,10,8,8,7,18,4,10,2,8,1,98,9,10,1,118,18,4,10,2,8,1,98,9,10,1,105,18,4,10,2,8,7,66,2,16,21],this.session_options,["v","i"])),this._top_k}}},"./src/pipelines.js":
/*!**************************!*\
!*** ./src/pipelines.js ***!
\**************************/(e,t,r)=>{r.r(t),r.d(t,{AudioClassificationPipeline:()=>v,AutomaticSpeechRecognitionPipeline:()=>A,DepthEstimationPipeline:()=>j,DocumentQuestionAnsweringPipeline:()=>O,FeatureExtractionPipeline:()=>P,FillMaskPipeline:()=>w,ImageClassificationPipeline:()=>L,ImageFeatureExtractionPipeline:()=>C,ImageSegmentationPipeline:()=>z,ImageToImagePipeline:()=>V,ImageToTextPipeline:()=>E,ObjectDetectionPipeline:()=>B,Pipeline:()=>_,QuestionAnsweringPipeline:()=>M,SummarizationPipeline:()=>b,Text2TextGenerationPipeline:()=>T,TextClassificationPipeline:()=>f,TextGenerationPipeline:()=>y,TextToAudioPipeline:()=>D,TokenClassificationPipeline:()=>g,TranslationPipeline:()=>x,ZeroShotAudioClassificationPipeline:()=>S,ZeroShotClassificationPipeline:()=>F,ZeroShotImageClassificationPipeline:()=>I,ZeroShotObjectDetectionPipeline:()=>N,pipeline:()=>q});var n=r(/*! ./tokenizers.js */"./src/tokenizers.js"),o=r(/*! ./models.js */"./src/models.js"),s=r(/*! ./processors.js */"./src/processors.js"),a=r(/*! ./utils/generic.js */"./src/utils/generic.js"),i=r(/*! ./utils/core.js */"./src/utils/core.js"),l=r(/*! ./utils/maths.js */"./src/utils/maths.js"),c=r(/*! ./utils/audio.js */"./src/utils/audio.js"),d=r(/*! ./utils/tensor.js */"./src/utils/tensor.js"),u=r(/*! ./utils/image.js */"./src/utils/image.js");async function p(e){return Array.isArray(e)||(e=[e]),await Promise.all(e.map((e=>u.RawImage.read(e))))}async function h(e,t){return Array.isArray(e)||(e=[e]),await Promise.all(e.map((e=>"string"==typeof e||e instanceof URL?(0,c.read_audio)(e,t):e instanceof Float64Array?new Float32Array(e):e)))}function m(e,t){t&&(e=e.map((e=>0|e)));const[r,n,o,s]=e;return{xmin:r,ymin:n,xmax:o,ymax:s}}class _ extends a.Callable{constructor({task:e,model:t,tokenizer:r=null,processor:n=null}){super(),this.task=e,this.model=t,this.tokenizer=r,this.processor=n}async dispose(){await this.model.dispose()}}class f extends _{constructor(e){super(e)}async _call(e,{top_k:t=1}={}){const r=this.tokenizer(e,{padding:!0,truncation:!0}),n=await this.model(r),o="multi_label_classification"===this.model.config.problem_type?e=>e.sigmoid():e=>new d.Tensor("float32",(0,l.softmax)(e.data),e.dims),s=this.model.config.id2label,a=[];for(const e of n.logits){const r=o(e),n=await(0,d.topk)(r,t),i=n[0].tolist(),l=n[1].tolist().map(((e,t)=>({label:s?s[e]:`LABEL_${e}`,score:i[t]})));1===t?a.push(...l):a.push(l)}return Array.isArray(e)||1===t?a:a[0]}}class g extends _{constructor(e){super(e)}async _call(e,{ignore_labels:t=["O"]}={}){const r=Array.isArray(e),n=this.tokenizer(r?e:[e],{padding:!0,truncation:!0}),o=(await this.model(n)).logits,s=this.model.config.id2label,a=[];for(let e=0;e<o.dims[0];++e){const r=n.input_ids[e],i=o[e],c=[];for(let e=0;e<i.dims[0];++e){const n=i[e],o=(0,l.max)(n.data)[1],a=s?s[o]:`LABEL_${o}`;if(t.includes(a))continue;const d=this.tokenizer.decode([r[e].item()],{skip_special_tokens:!0});if(""===d)continue;const u=(0,l.softmax)(n.data);c.push({entity:a,score:u[o],index:e,word:d})}a.push(c)}return r?a:a[0]}}class M extends _{constructor(e){super(e)}async _call(e,t,{top_k:r=1}={}){const n=this.tokenizer(e,{text_pair:t,padding:!0,truncation:!0}),{start_logits:o,end_logits:s}=await this.model(n),a=n.input_ids.tolist(),c=n.attention_mask.tolist(),d=this.tokenizer.all_special_ids,u=[];for(let e=0;e<o.dims[0];++e){const t=a[e],n=t.findIndex((e=>e==this.tokenizer.sep_token_id)),p=(c[e].map(((e,r)=>1==e&&(0===r||r>n&&-1===d.findIndex((e=>e==t[r]))))),o[e].tolist()),h=s[e].tolist();for(let r=1;r<p.length;++r)(0==c[e]||r<=n||-1!==d.findIndex((e=>e==t[r])))&&(p[r]=-1/0,h[r]=-1/0);const m=(0,l.softmax)(p).map(((e,t)=>[e,t])),_=(0,l.softmax)(h).map(((e,t)=>[e,t]));m[0][0]=0,_[0][0]=0;const f=(0,i.product)(m,_).filter((e=>e[0][1]<=e[1][1])).map((e=>[e[0][1],e[1][1],e[0][0]*e[1][0]])).sort(((e,t)=>t[2]-e[2]));for(let e=0;e<Math.min(f.length,r);++e){const[r,n,o]=f[e],s=t.slice(r,n+1),a=this.tokenizer.decode(s,{skip_special_tokens:!0});u.push({answer:a,score:o})}}return 1===r?u[0]:u}}class w extends _{constructor(e){super(e)}async _call(e,{top_k:t=5}={}){const r=this.tokenizer(e,{padding:!0,truncation:!0}),{logits:n}=await this.model(r),o=[],s=r.input_ids.tolist();for(let e=0;e<s.length;++e){const r=s[e],a=r.findIndex((e=>e==this.tokenizer.mask_token_id));if(-1===a)throw Error(`Mask token (${this.tokenizer.mask_token}) not found in text.`);const i=n[e][a],c=await(0,d.topk)(new d.Tensor("float32",(0,l.softmax)(i.data),i.dims),t),u=c[0].tolist(),p=c[1].tolist();o.push(p.map(((e,t)=>{const n=r.slice();return n[a]=e,{score:u[t],token:Number(e),token_str:this.tokenizer.model.vocab[e],sequence:this.tokenizer.decode(n,{skip_special_tokens:!0})}})))}return Array.isArray(e)?o:o[0]}}class T extends _{_key="generated_text";constructor(e){super(e)}async _call(e,t={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map((e=>this.model.config.prefix+e)));const r=this.model.config.task_specific_params;r&&r[this.task]&&r[this.task].prefix&&(e=e.map((e=>r[this.task].prefix+e)));const n=this.tokenizer,o={padding:!0,truncation:!0};let s;s=this instanceof x&&"_build_translation_inputs"in n?n._build_translation_inputs(e,o,t):n(e,o);const a=await this.model.generate({...s,...t});return n.batch_decode(a,{skip_special_tokens:!0}).map((e=>({[this._key]:e})))}}class b extends T{_key="summary_text";constructor(e){super(e)}}class x extends T{_key="translation_text";constructor(e){super(e)}}function k(e){return Array.isArray(e)&&e.every((e=>"role"in e&&"content"in e))}class y extends _{constructor(e){super(e)}async _call(e,t={}){let r,n=!1,o=!1;if("string"==typeof e)r=e=[e];else if(Array.isArray(e)&&e.every((e=>"string"==typeof e)))n=!0,r=e;else{if(k(e))e=[e];else{if(!Array.isArray(e)||!e.every(k))throw new Error("Input must be a string, an array of strings, a Chat, or an array of Chats");n=!0}o=!0,r=e.map((e=>this.tokenizer.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0})))}const s=t.add_special_tokens??!1,a=!o&&(t.return_full_text??!0);this.tokenizer.padding_side="left";const i=this.tokenizer(r,{add_special_tokens:s,padding:!0,truncation:!0}),l=await this.model.generate({...i,...t}),c=this.tokenizer.batch_decode(l,{skip_special_tokens:!0});let d;!a&&i.input_ids.dims.at(-1)>0&&(d=this.tokenizer.batch_decode(i.input_ids,{skip_special_tokens:!0}).map((e=>e.length)));const u=Array.from({length:e.length},(e=>[]));for(let t=0;t<c.length;++t){const r=Math.floor(t/l.dims[0]*e.length);d&&(c[t]=c[t].slice(d[r])),u[r].push({generated_text:o?[...e[r],{role:"assistant",content:c[t]}]:c[t]})}return n||1!==u.length?u:u[0]}}class F extends _{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map((([e,t])=>[e.toLowerCase(),t]))),this.entailment_id=this.label2id.entailment,void 0===this.entailment_id&&(console.warn("Could not find 'entailment' in label2id mapping. Using 2 as entailment_id."),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction??this.label2id.not_entailment,void 0===this.contradiction_id&&(console.warn("Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id."),this.contradiction_id=0)}async _call(e,t,{hypothesis_template:r="This example is {}.",multi_label:n=!1}={}){const o=Array.isArray(e);o||(e=[e]),Array.isArray(t)||(t=[t]);const s=t.map((e=>r.replace("{}",e))),a=n||1===t.length,i=[];for(const r of e){const e=[];for(const t of s){const n=this.tokenizer(r,{text_pair:t,padding:!0,truncation:!0}),o=await this.model(n);a?e.push([o.logits.data[this.contradiction_id],o.logits.data[this.entailment_id]]):e.push(o.logits.data[this.entailment_id])}const n=(a?e.map((e=>(0,l.softmax)(e)[1])):(0,l.softmax)(e)).map(((e,t)=>[e,t])).sort(((e,t)=>t[0]-e[0]));i.push({sequence:r,labels:n.map((e=>t[e[1]])),scores:n.map((e=>e[0]))})}return o?i:i[0]}}class P extends _{constructor(e){super(e)}async _call(e,{pooling:t="none",normalize:r=!1,quantize:n=!1,precision:o="binary"}={}){const s=this.tokenizer(e,{padding:!0,truncation:!0}),a=await this.model(s);let i=a.last_hidden_state??a.logits??a.token_embeddings;if("none"===t);else if("mean"===t)i=(0,d.mean_pooling)(i,s.attention_mask);else{if("cls"!==t)throw Error(`Pooling method '${t}' not supported.`);i=i.slice(null,0)}return r&&(i=i.normalize(2,-1)),n&&(i=(0,d.quantize_embeddings)(i,o)),i}}class C extends _{constructor(e){super(e)}async _call(e,{pool:t=null}={}){const r=await p(e),{pixel_values:n}=await this.processor(r),o=await this.model({pixel_values:n});let s;if(t){if(!("pooler_output"in o))throw Error("No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.");s=o.pooler_output}else s=o.last_hidden_state??o.logits??o.image_embeds;return s}}class v extends _{constructor(e){super(e)}async _call(e,{top_k:t=5}={}){const r=this.processor.feature_extractor.config.sampling_rate,n=await h(e,r),o=this.model.config.id2label,s=[];for(const e of n){const r=await this.processor(e),n=(await this.model(r)).logits[0],a=await(0,d.topk)(new d.Tensor("float32",(0,l.softmax)(n.data),n.dims),t),i=a[0].tolist(),c=a[1].tolist().map(((e,t)=>({label:o?o[e]:`LABEL_${e}`,score:i[t]})));s.push(c)}return Array.isArray(e)?s:s[0]}}class S extends _{constructor(e){super(e)}async _call(e,t,{hypothesis_template:r="This is a sound of {}."}={}){const n=!Array.isArray(e);n&&(e=[e]);const o=t.map((e=>r.replace("{}",e))),s=this.tokenizer(o,{padding:!0,truncation:!0}),a=this.processor.feature_extractor.config.sampling_rate,i=await h(e,a),c=[];for(const e of i){const r=await this.processor(e),n=await this.model({...s,...r}),o=(0,l.softmax)(n.logits_per_audio.data);c.push([...o].map(((e,r)=>({score:e,label:t[r]}))))}return n?c[0]:c}}class A extends _{constructor(e){super(e)}async _call(e,t={}){switch(this.model.config.model_type){case"whisper":return this._call_whisper(e,t);case"wav2vec2":case"wav2vec2-bert":case"unispeech":case"unispeech-sat":case"hubert":return this._call_wav2vec2(e,t);default:throw new Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,t){t.language&&console.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),t.task&&console.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');const r=!Array.isArray(e);r&&(e=[e]);const n=this.processor.feature_extractor.config.sampling_rate,o=await h(e,n),s=[];for(const e of o){const t=await this.processor(e),r=(await this.model(t)).logits[0],n=[];for(const e of r)n.push((0,l.max)(e.data)[1]);const o=this.tokenizer.decode(n);s.push({text:o})}return r?s[0]:s}async _call_whisper(e,t){const r=t.return_timestamps??!1,n=t.chunk_length_s??0,o=t.force_full_sequences??!1;let s=t.stride_length_s??null;const a={...t};"word"===r&&(a.return_token_timestamps=!0,a.return_timestamps=!1);const i=!Array.isArray(e);i&&(e=[e]);const c=this.processor.feature_extractor.config.chunk_length/this.model.config.max_source_positions,d=this.processor.feature_extractor.config.hop_length,u=this.processor.feature_extractor.config.sampling_rate,p=await h(e,u),m=[];for(const e of p){let t=[];if(n>0){if(null===s)s=n/6;else if(n<=s)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");const r=u*n,o=u*s,a=r-2*o;let i=0;for(;;){const n=i+r,s=e.subarray(i,n),l=await this.processor(s),c=0===i,d=n>=e.length;if(t.push({stride:[s.length,c?0:o,d?0:o],input_features:l.input_features,is_last:d}),d)break;i+=a}}else t=[{stride:[e.length,0,0],input_features:(await this.processor(e)).input_features,is_last:!0}];for(const e of t){a.num_frames=Math.floor(e.stride[0]/d);const t=await this.model.generate({inputs:e.input_features,...a});"word"===r?(e.tokens=t.sequences.tolist()[0],e.token_timestamps=t.token_timestamps.tolist()[0].map((e=>(0,l.round)(e,2)))):e.tokens=t[0].tolist(),e.stride=e.stride.map((e=>e/u))}const[i,p]=this.tokenizer._decode_asr(t,{time_precision:c,return_timestamps:r,force_full_sequences:o});m.push({text:i,...p})}return i?m[0]:m}}class E extends _{constructor(e){super(e)}async _call(e,t={}){const r=Array.isArray(e),n=await p(e),{pixel_values:o}=await this.processor(n),s=[];for(const e of o){e.dims=[1,...e.dims];const r=await this.model.generate({inputs:e,...t}),n=this.tokenizer.batch_decode(r,{skip_special_tokens:!0}).map((e=>({generated_text:e.trim()})));s.push(n)}return r?s:s[0]}}class L extends _{constructor(e){super(e)}async _call(e,{top_k:t=5}={}){const r=await p(e),{pixel_values:n}=await this.processor(r),o=await this.model({pixel_values:n}),s=this.model.config.id2label,a=[];for(const e of o.logits){const r=await(0,d.topk)(new d.Tensor("float32",(0,l.softmax)(e.data),e.dims),t),n=r[0].tolist(),o=r[1].tolist().map(((e,t)=>({label:s?s[e]:`LABEL_${e}`,score:n[t]})));a.push(o)}return Array.isArray(e)?a:a[0]}}class z extends _{constructor(e){super(e),this.subtasks_mapping={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"}}async _call(e,{threshold:t=.5,mask_threshold:r=.5,overlap_mask_area_threshold:n=.8,label_ids_to_fuse:o=null,target_sizes:s=null,subtask:a=null}={}){if(Array.isArray(e)&&1!==e.length)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");const i=await p(e),l=i.map((e=>[e.height,e.width])),{pixel_values:c,pixel_mask:d}=await this.processor(i),h=await this.model({pixel_values:c,pixel_mask:d});let m=null;if(null!==a)m=this.subtasks_mapping[a];else for(let[e,t]of Object.entries(this.subtasks_mapping))if(t in this.processor.feature_extractor){m=this.processor.feature_extractor[t].bind(this.processor.feature_extractor),a=e;break}const _=this.model.config.id2label,f=[];if("panoptic"===a||"instance"===a){const e=m(h,t,r,n,o,s??l)[0],a=e.segmentation;for(const t of e.segments_info){const e=new Uint8ClampedArray(a.data.length);for(let r=0;r<a.data.length;++r)a.data[r]===t.id&&(e[r]=255);const r=new u.RawImage(e,a.dims[1],a.dims[0],1);f.push({score:t.score,label:_[t.label_id],mask:r})}}else{if("semantic"!==a)throw Error(`Subtask ${a} not supported.`);{const{segmentation:e,labels:t}=m(h,s??l)[0];for(const r of t){const t=new Uint8ClampedArray(e.data.length);for(let n=0;n<e.data.length;++n)e.data[n]===r&&(t[n]=255);const n=new u.RawImage(t,e.dims[1],e.dims[0],1);f.push({score:null,label:_[r],mask:n})}}}return f}}class I extends _{constructor(e){super(e)}async _call(e,t,{hypothesis_template:r="This is a photo of {}"}={}){const n=Array.isArray(e),o=await p(e),s=t.map((e=>r.replace("{}",e))),a=this.tokenizer(s,{padding:"siglip"!==this.model.config.model_type||"max_length",truncation:!0}),{pixel_values:i}=await this.processor(o),c=await this.model({...a,pixel_values:i}),d="siglip"===this.model.config.model_type?e=>e.sigmoid().data:e=>(0,l.softmax)(e.data),u=[];for(const e of c.logits_per_image){const r=[...d(e)].map(((e,r)=>({score:e,label:t[r]})));r.sort(((e,t)=>t.score-e.score)),u.push(r)}return n?u:u[0]}}class B extends _{constructor(e){super(e)}async _call(e,{threshold:t=.9,percentage:r=!1}={}){const n=Array.isArray(e);if(n&&1!==e.length)throw Error("Object detection pipeline currently only supports a batch size of 1.");const o=await p(e),s=r?null:o.map((e=>[e.height,e.width])),{pixel_values:a,pixel_mask:i}=await this.processor(o),l=await this.model({pixel_values:a,pixel_mask:i}),c=this.processor.feature_extractor.post_process_object_detection(l,t,s),d=this.model.config.id2label,u=c.map((e=>e.boxes.map(((t,n)=>({score:e.scores[n],label:d[e.classes[n]],box:m(t,!r)})))));return n?u:u[0]}}class N extends _{constructor(e){super(e)}async _call(e,t,{threshold:r=.1,top_k:n=null,percentage:o=!1}={}){const s=Array.isArray(e),a=await p(e),i=this.tokenizer(t,{padding:!0,truncation:!0}),l=await this.processor(a),c=[];for(let e=0;e<a.length;++e){const s=a[e],d=o?null:[[s.height,s.width]],u=l.pixel_values[e].unsqueeze_(0),p=await this.model({...i,pixel_values:u}),h=this.processor.feature_extractor.post_process_object_detection(p,r,d,!0)[0];let _=h.boxes.map(((e,r)=>({score:h.scores[r],label:t[h.classes[r]],box:m(e,!o)}))).sort(((e,t)=>t.score-e.score));null!==n&&(_=_.slice(0,n)),c.push(_)}return s?c:c[0]}}class O extends _{constructor(e){super(e)}async _call(e,t,r={}){throw new Error("This pipeline is not yet supported in Transformers.js v3.")}}class D extends _{DEFAULT_VOCODER_ID="Xenova/speecht5_hifigan";constructor(e){super(e),this.vocoder=e.vocoder??null}async _call(e,{speaker_embeddings:t=null}={}){return this.processor?this._call_text_to_spectrogram(e,{speaker_embeddings:t}):this._call_text_to_waveform(e)}async _call_text_to_waveform(e){const t=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:r}=await this.model(t),n=this.model.config.sampling_rate;return{audio:r.data,sampling_rate:n}}async _call_text_to_spectrogram(e,{speaker_embeddings:t}){if(this.vocoder||(console.log("No vocoder specified, using default HifiGan vocoder."),this.vocoder=await o.AutoModel.from_pretrained(this.DEFAULT_VOCODER_ID,{dtype:"fp32"})),("string"==typeof t||t instanceof URL)&&(t=new Float32Array(await(await fetch(t)).arrayBuffer())),t instanceof Float32Array)t=new d.Tensor("float32",t,[1,t.length]);else if(!(t instanceof d.Tensor))throw new Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");const{input_ids:r}=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:n}=await this.model.generate_speech(r,t,{vocoder:this.vocoder}),s=this.processor.feature_extractor.config.sampling_rate;return{audio:n.data,sampling_rate:s}}}class V extends _{constructor(e){super(e)}async _call(e){const t=await p(e),r=await this.processor(t),n=await this.model(r),o=[];for(const e of n.reconstruction){const t=e.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");o.push(u.RawImage.fromTensor(t))}return o.length>1?o:o[0]}}class j extends _{constructor(e){super(e)}async _call(e){const t=await p(e),r=await this.processor(t),{predicted_depth:n}=await this.model(r),o=[];for(let e=0;e<t.length;++e){const r=(0,d.interpolate)(n[e],t[e].size.reverse(),"bilinear",!1),s=r.mul_(255/(0,l.max)(r.data)[0]).to("uint8");o.push({predicted_depth:n[e],depth:u.RawImage.fromTensor(s)})}return o.length>1?o:o[0]}}const R=Object.freeze({"text-classification":{tokenizer:n.AutoTokenizer,pipeline:f,model:o.AutoModelForSequenceClassification,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{tokenizer:n.AutoTokenizer,pipeline:g,model:o.AutoModelForTokenClassification,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{tokenizer:n.AutoTokenizer,pipeline:M,model:o.AutoModelForQuestionAnswering,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{tokenizer:n.AutoTokenizer,pipeline:w,model:o.AutoModelForMaskedLM,default:{model:"Xenova/bert-base-uncased"},type:"text"},summarization:{tokenizer:n.AutoTokenizer,pipeline:b,model:o.AutoModelForSeq2SeqLM,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{tokenizer:n.AutoTokenizer,pipeline:x,model:o.AutoModelForSeq2SeqLM,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{tokenizer:n.AutoTokenizer,pipeline:T,model:o.AutoModelForSeq2SeqLM,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{tokenizer:n.AutoTokenizer,pipeline:y,model:o.AutoModelForCausalLM,default:{model:"Xenova/gpt2"},type:"text"},"zero-shot-classification":{tokenizer:n.AutoTokenizer,pipeline:F,model:o.AutoModelForSequenceClassification,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:v,model:o.AutoModelForAudioClassification,processor:s.AutoProcessor,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{tokenizer:n.AutoTokenizer,pipeline:S,model:o.AutoModel,processor:s.AutoProcessor,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{tokenizer:n.AutoTokenizer,pipeline:A,model:[o.AutoModelForSpeechSeq2Seq,o.AutoModelForCTC],processor:s.AutoProcessor,default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{tokenizer:n.AutoTokenizer,pipeline:D,model:[o.AutoModelForTextToWaveform,o.AutoModelForTextToSpectrogram],processor:[s.AutoProcessor,null],default:{model:"Xenova/speecht5_tts"},type:"text"},"image-to-text":{tokenizer:n.AutoTokenizer,pipeline:E,model:o.AutoModelForVision2Seq,processor:s.AutoProcessor,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:L,model:o.AutoModelForImageClassification,processor:s.AutoProcessor,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:z,model:[o.AutoModelForImageSegmentation,o.AutoModelForSemanticSegmentation,o.AutoModelForUniversalSegmentation],processor:s.AutoProcessor,default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"zero-shot-image-classification":{tokenizer:n.AutoTokenizer,pipeline:I,model:o.AutoModel,processor:s.AutoProcessor,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:B,model:o.AutoModelForObjectDetection,processor:s.AutoProcessor,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{tokenizer:n.AutoTokenizer,pipeline:N,model:o.AutoModelForZeroShotObjectDetection,processor:s.AutoProcessor,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{tokenizer:n.AutoTokenizer,pipeline:O,model:o.AutoModelForDocumentQuestionAnswering,processor:s.AutoProcessor,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:V,model:o.AutoModelForImageToImage,processor:s.AutoProcessor,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:j,model:o.AutoModelForDepthEstimation,processor:s.AutoProcessor,default:{model:"Xenova/dpt-large"},type:"image"},"feature-extraction":{tokenizer:n.AutoTokenizer,pipeline:P,model:o.AutoModel,default:{model:"Xenova/all-MiniLM-L6-v2"},type:"text"},"image-feature-extraction":{processor:s.AutoProcessor,pipeline:C,model:[o.AutoModelForImageFeatureExtraction,o.AutoModel],default:{model:"Xenova/vit-base-patch16-224-in21k"},type:"image"}}),G=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});async function q(e,t=null,{progress_callback:r=null,config:n=null,cache_dir:o=null,local_files_only:s=!1,revision:a="main",device:l=null,dtype:c=null,model_file_name:d=null,session_options:u={}}={}){e=G[e]??e;const p=R[e.split("_",1)[0]];if(!p)throw Error(`Unsupported pipeline: ${e}. Must be one of [${Object.keys(R)}]`);t||(t=p.default.model,console.log(`No model specified. Using default model: "${t}".`));const h={progress_callback:r,config:n,cache_dir:o,local_files_only:s,revision:a,device:l,dtype:c,model_file_name:d,session_options:u},m=new Map([["tokenizer",p.tokenizer],["model",p.model],["processor",p.processor]]),_=await async function(e,t,r){const n=Object.create(null),o=[];for(const[s,a]of e.entries()){if(!a)continue;let e;e=Array.isArray(a)?new Promise((async(e,n)=>{let o;for(const s of a){if(null===s)return void e(null);try{return void e(await s.from_pretrained(t,r))}catch(e){if(e.message?.includes("Unsupported model type"))o=e;else{if(!e.message?.includes("Could not locate file"))return void n(e);o=e}}}n(o)})):a.from_pretrained(t,r),n[s]=e,o.push(e)}await Promise.all(o);for(const[e,t]of Object.entries(n))n[e]=await t;return n}(m,t,h);_.task=e,(0,i.dispatchCallback)(r,{status:"ready",task:e,model:t});return new(0,p.pipeline)(_)}},"./src/processors.js":
/*!***************************!*\
!*** ./src/processors.js ***!
\***************************/(e,t,r)=>{r.r(t),r.d(t,{ASTFeatureExtractor:()=>se,AutoProcessor:()=>Me,BeitFeatureExtractor:()=>X,BitImageProcessor:()=>P,CLIPFeatureExtractor:()=>v,CLIPImageProcessor:()=>S,ChineseCLIPFeatureExtractor:()=>A,ClapFeatureExtractor:()=>ae,ConvNextFeatureExtractor:()=>L,ConvNextImageProcessor:()=>z,DPTFeatureExtractor:()=>y,DPTImageProcessor:()=>F,DeiTFeatureExtractor:()=>U,DetrFeatureExtractor:()=>Y,DonutFeatureExtractor:()=>Q,EfficientNetImageProcessor:()=>N,FeatureExtractor:()=>w,Florence2Processor:()=>ge,GLPNFeatureExtractor:()=>C,ImageFeatureExtractor:()=>T,MaskFormerFeatureExtractor:()=>J,MobileNetV1FeatureExtractor:()=>O,MobileNetV2FeatureExtractor:()=>D,MobileNetV3FeatureExtractor:()=>V,MobileNetV4FeatureExtractor:()=>j,MobileViTFeatureExtractor:()=>R,MobileViTImageProcessor:()=>G,NougatImageProcessor:()=>H,OwlViTFeatureExtractor:()=>q,OwlViTProcessor:()=>fe,Owlv2ImageProcessor:()=>$,Processor:()=>de,PvtImageProcessor:()=>k,PyAnnoteFeatureExtractor:()=>ie,PyAnnoteProcessor:()=>me,RTDetrImageProcessor:()=>W,SamImageProcessor:()=>Z,SamProcessor:()=>ue,SapiensFeatureExtractor:()=>b,SeamlessM4TFeatureExtractor:()=>oe,SegformerFeatureExtractor:()=>x,SiglipImageProcessor:()=>E,SpeechT5FeatureExtractor:()=>ce,SpeechT5Processor:()=>_e,Swin2SRImageProcessor:()=>ee,ViTFeatureExtractor:()=>I,ViTImageProcessor:()=>B,VitMatteImageProcessor:()=>te,Wav2Vec2FeatureExtractor:()=>ne,Wav2Vec2ProcessorWithLM:()=>he,WeSpeakerFeatureExtractor:()=>le,WhisperFeatureExtractor:()=>re,WhisperProcessor:()=>pe,YolosFeatureExtractor:()=>K});var n=r(/*! ./utils/generic.js */"./src/utils/generic.js"),o=r(/*! ./utils/core.js */"./src/utils/core.js"),s=r(/*! ./utils/hub.js */"./src/utils/hub.js"),a=r(/*! ./utils/maths.js */"./src/utils/maths.js"),i=r(/*! ./utils/tensor.js */"./src/utils/tensor.js"),l=(r(/*! ./utils/image.js */"./src/utils/image.js"),r(/*! ./utils/audio.js */"./src/utils/audio.js"));function c([e,t,r,n]){return[e-r/2,t-n/2,e+r/2,t+n/2]}function d(e,t=.5,r=null,n=!1){const o=e.logits,s=e.pred_boxes,[i,l,d]=o.dims;if(null!==r&&r.length!==i)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let u=[];for(let e=0;e<i;++e){let i=null!==r?r[e]:null,p={boxes:[],classes:[],scores:[]},h=o[e],m=s[e];for(let e=0;e<l;++e){let r,o=h[e],s=[];if(n){r=o.sigmoid().data;for(let e=0;e<r.length;++e)r[e]>t&&s.push(e)}else{let e=(0,a.max)(o.data)[1];if(e===d-1)continue;if(r=(0,a.softmax)(o.data),r[e]<t)continue;s.push(e)}for(const t of s){let n=m[e].data;n=c(n),null!==i&&(n=n.map(((e,t)=>e*i[(t+1)%2]))),p.boxes.push(n),p.classes.push(t),p.scores.push(r[t])}}u.push(p)}return u}function u(e,t=null){const r=e.logits,n=r.dims[0];if(null!==t&&t.length!==n)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");const o=[];for(let e=0;e<n;++e){const n=null!==t?t[e]:null;let s=r[e];null!==n&&(s=(0,i.interpolate)(s,n,"bilinear",!1));const[a,l]=n??s.dims.slice(-2),c=new i.Tensor("int32",new Int32Array(a*l),[a,l]),d=s[0].data,u=c.data;for(let e=1;e<s.dims[0];++e){const t=s[e].data;for(let r=0;r<t.length;++r)t[r]>d[r]&&(d[r]=t[r],u[r]=e)}const p=new Array(s.dims[0]);for(let e=0;e<u.length;++e){const t=u[e];p[t]=t}const h=p.filter((e=>void 0!==e));o.push({segmentation:c,labels:h})}return o}function p(e,t,r,n){const o=[],s=[],i=[];for(let l=0;l<e.dims[0];++l){const c=e[l],d=t[l],u=(0,a.max)(c.data)[1];if(u===n)continue;const p=(0,a.softmax)(c.data)[u];p>r&&(o.push(d),s.push(p),i.push(u))}return[o,s,i]}function h(e,t,r,n=.5,o=.8){const s=[];let a=0,i=0;const l=t[r].data;for(let t=0;t<e.length;++t)e[t]===r&&(s.push(t),++a),l[t]>=n&&++i;let c=a>0&&i>0;if(c){c=a/i>o}return[c,s]}function m(e,t,r,n,o,s=null,a=null){const[l,c]=a??e[0].dims,d=new i.Tensor("int32",new Int32Array(l*c),[l,c]),u=[];if(null!==a)for(let t=0;t<e.length;++t)e[t]=(0,i.interpolate)(e[t],a,"bilinear",!1);const p=new Int32Array(e[0].data.length),m=new Float32Array(e[0].data.length);for(let r=0;r<e.length;++r){let n=t[r];const o=e[r].data;for(let e=0;e<o.length;++e)o[e]*=n,o[e]>m[e]&&(p[e]=r,m[e]=o[e])}let _=0;const f=d.data;for(let s=0;s<r.length;++s){const a=r[s],[i,l]=h(p,e,s,n,o);if(i){++_;for(const e of l)f[e]=_;u.push({id:_,label_id:a,score:t[s]})}}return[d,u]}function _(e,t=.5,r=.5,n=.8,o=null,s=null){null===o&&(console.warn("`label_ids_to_fuse` unset. No instance will be fused."),o=new Set);const a=e.class_queries_logits??e.logits,l=(e.masks_queries_logits??e.pred_masks).sigmoid();let[c,d,u]=a.dims;if(u-=1,null!==s&&s.length!==c)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let h=[];for(let e=0;e<c;++e){let c=null!==s?s[e]:null,d=a[e],_=l[e],[f,g,M]=p(d,_,t,u);if(0===M.length){let[e,t]=c??_.dims.slice(-2),r=new i.Tensor("int32",new Int32Array(e*t).fill(-1),[e,t]);h.push({segmentation:r,segments_info:[]});continue}let[w,T]=m(f,g,M,r,n,o,c);h.push({segmentation:w,segments_info:T})}return h}function f(e,t){if(!(e instanceof Float32Array||e instanceof Float64Array))throw new Error(`${t} expects input to be a Float32Array or a Float64Array, but got ${e?.constructor?.name??typeof e} instead. If using the feature extractor directly, remember to use \`read_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}function g(e,t,r=0,n=null){const o=e/t;let s=(0,a.bankers_round)(o)*t;return null!==n&&s>n&&(s=Math.floor(o)*t),s<r&&(s=Math.ceil(o)*t),s}function M([e,t],r){return[Math.max(Math.floor(e/r),1)*r,Math.max(Math.floor(t/r),1)*r]}class w extends n.Callable{constructor(e){super(),this.config=e}}class T extends w{constructor(e){super(e),this.image_mean=this.config.image_mean??this.config.mean,this.image_std=this.config.image_std??this.config.std,this.resample=this.config.resample??2,this.do_rescale=this.config.do_rescale??!0,this.rescale_factor=this.config.rescale_factor??1/255,this.do_normalize=this.config.do_normalize,this.do_resize=this.config.do_resize,this.do_thumbnail=this.config.do_thumbnail,this.size=this.config.size,this.size_divisibility=this.config.size_divisibility??this.config.size_divisor,this.do_center_crop=this.config.do_center_crop,this.crop_size=this.config.crop_size,this.do_convert_rgb=this.config.do_convert_rgb??!0,this.do_crop_margin=this.config.do_crop_margin,this.pad_size=this.config.pad_size,this.do_pad=this.config.do_pad,this.do_pad&&!this.pad_size&&this.size&&void 0!==this.size.width&&void 0!==this.size.height&&(this.pad_size=this.size),this.do_flip_channel_order=this.config.do_flip_channel_order??!1}async thumbnail(e,t,r=2){const n=e.height,o=e.width,s=t.height,a=t.width;let i=Math.min(n,s),l=Math.min(o,a);return i===n&&l===o?e:(n>o?l=Math.floor(o*i/n):o>n&&(i=Math.floor(n*l/o)),await e.resize(l,i,{resample:r}))}async crop_margin(e,t=200){const r=e.clone().grayscale(),n=(0,a.min)(r.data)[0],o=(0,a.max)(r.data)[0]-n;if(0===o)return e;const s=t/255;let i=r.width,l=r.height,c=0,d=0;const u=r.data;for(let e=0;e<r.height;++e){const t=e*r.width;for(let a=0;a<r.width;++a)(u[t+a]-n)/o<s&&(i=Math.min(i,a),l=Math.min(l,e),c=Math.max(c,a),d=Math.max(d,e))}return e=await e.crop([i,l,c,d])}pad_image(e,t,r,{mode:n="constant",center:s=!1,constant_values:a=0}={}){const[i,l,c]=t;let d,u;if("number"==typeof r?(d=r,u=r):(d=r.width,u=r.height),d!==l||u!==i){const r=new Float32Array(d*u*c);if(Array.isArray(a))for(let e=0;e<r.length;++e)r[e]=a[e%c];else 0!==a&&r.fill(a);const[p,h]=s?[Math.floor((d-l)/2),Math.floor((u-i)/2)]:[0,0];for(let t=0;t<i;++t){const n=(t+h)*d,o=t*l;for(let t=0;t<l;++t){const s=(n+t+p)*c,a=(o+t)*c;for(let t=0;t<c;++t)r[s+t]=e[a+t]}}if("symmetric"===n){if(s)throw new Error("`center` padding is not supported when `mode` is set to `symmetric`.");const t=i-1,n=l-1;for(let s=0;s<u;++s){const a=s*d,u=(0,o.calculateReflectOffset)(s,t)*l;for(let t=0;t<d;++t){if(s<i&&t<l)continue;const d=(a+t)*c,p=(u+(0,o.calculateReflectOffset)(t,n))*c;for(let t=0;t<c;++t)r[d+t]=e[p+t]}}}e=r,t=[u,d,c]}return[e,t]}rescale(e){for(let t=0;t<e.length;++t)e[t]=this.rescale_factor*e[t]}get_resize_output_image_size(e,t){const[r,n]=e.size;let o,s;if(this.do_thumbnail){const{height:e,width:r}=t;o=Math.min(e,r)}else Number.isInteger(t)?(o=t,s=this.config.max_size??o):void 0!==t&&(o=t.shortest_edge,s=t.longest_edge);if(void 0!==o||void 0!==s){const e=void 0===o?1:Math.max(o/r,o/n),t=r*e,a=n*e,i=void 0===s?1:Math.min(s/t,s/a);let l=Math.floor(Number((t*i).toFixed(2))),c=Math.floor(Number((a*i).toFixed(2)));return void 0!==this.size_divisibility&&([l,c]=M([l,c],this.size_divisibility)),[l,c]}if(void 0!==t&&void 0!==t.width&&void 0!==t.height){let e=t.width,o=t.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let t=o/n,s=e/r;Math.abs(1-s)<Math.abs(1-t)?t=s:s=t,o=g(t*n,this.config.ensure_multiple_of),e=g(s*r,this.config.ensure_multiple_of)}return[e,o]}if(void 0!==this.size_divisibility)return M([r,n],this.size_divisibility);throw new Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(t)}`)}async resize(e){const[t,r]=this.get_resize_output_image_size(e,this.size);return await e.resize(t,r,{resample:this.resample})}async preprocess(e,{do_normalize:t=null,do_pad:r=null,do_convert_rgb:n=null,do_convert_grayscale:o=null,do_flip_channel_order:s=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));const[a,l]=e.size;if(n??this.do_convert_rgb?e=e.rgb():o&&(e=e.grayscale()),this.do_resize&&(e=await this.resize(e)),this.do_thumbnail&&(e=await this.thumbnail(e,this.size,this.resample)),this.do_center_crop){let t,r;Number.isInteger(this.crop_size)?(t=this.crop_size,r=this.crop_size):(t=this.crop_size.width,r=this.crop_size.height),e=await e.center_crop(t,r)}const c=[e.height,e.width];let d=Float32Array.from(e.data),u=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(d),t??this.do_normalize){let t=this.image_mean;Array.isArray(this.image_mean)||(t=new Array(e.channels).fill(t));let r=this.image_std;if(Array.isArray(this.image_std)||(r=new Array(e.channels).fill(t)),t.length!==e.channels||r.length!==e.channels)throw new Error(`When set to arrays, the length of \`image_mean\` (${t.length}) and \`image_std\` (${r.length}) must match the number of channels in the image (${e.channels}).`);for(let n=0;n<d.length;n+=e.channels)for(let o=0;o<e.channels;++o)d[n+o]=(d[n+o]-t[o])/r[o]}if(r??this.do_pad)if(this.pad_size){const t=this.pad_image(d,[e.height,e.width,e.channels],this.pad_size);[d,u]=t}else if(this.size_divisibility){const[e,t]=M([u[1],u[0]],this.size_divisibility);[d,u]=this.pad_image(d,u,{width:e,height:t})}if(s??this.do_flip_channel_order){if(3!==u[2])throw new Error("Flipping channel order is only supported for RGB images.");for(let e=0;e<d.length;e+=3){const t=d[e];d[e]=d[e+2],d[e+2]=t}}return{original_size:[l,a],reshaped_input_size:c,pixel_values:new i.Tensor("float32",d,u).permute(2,0,1)}}async _call(e,...t){Array.isArray(e)||(e=[e]);const r=await Promise.all(e.map((e=>this.preprocess(e))));return{pixel_values:(0,i.stack)(r.map((e=>e.pixel_values)),0),original_sizes:r.map((e=>e.original_size)),reshaped_input_sizes:r.map((e=>e.reshaped_input_size))}}}class b extends T{post_process_semantic_segmentation(...e){return u(...e)}}class x extends T{post_process_semantic_segmentation(...e){return u(...e)}}class k extends T{}class y extends T{}class F extends y{}class P extends T{}class C extends T{}class v extends T{}class S extends v{}class A extends T{}class E extends T{}class L extends T{constructor(e){super(e),this.crop_pct=this.config.crop_pct??.875}async resize(e){const t=this.size?.shortest_edge;if(void 0===t)throw new Error("Size dictionary must contain 'shortest_edge' key.");if(t<384){const r=Math.floor(t/this.crop_pct),[n,o]=this.get_resize_output_image_size(e,{shortest_edge:r});e=await e.resize(n,o,{resample:this.resample}),e=await e.center_crop(t,t)}else e=await e.resize(t,t,{resample:this.resample});return e}}class z extends L{}class I extends T{}class B extends T{}class N extends T{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map((e=>e*e)))}}class O extends T{}class D extends T{}class V extends T{}class j extends T{}class R extends T{}class G extends R{}class q extends T{post_process_object_detection(...e){return d(...e)}}class $ extends q{}class W extends T{post_process_object_detection(...e){return d(...e)}}class U extends T{}class X extends T{}class Q extends T{pad_image(e,t,r,n={}){const[o,s,a]=t;let i=this.image_mean;Array.isArray(this.image_mean)||(i=new Array(a).fill(i));let l=this.image_std;Array.isArray(l)||(l=new Array(a).fill(i));const c=i.map(((e,t)=>-e/l[t]));return super.pad_image(e,t,r,{center:!0,constant_values:c,...n})}}class H extends Q{}class Y extends T{async _call(e){const t=await super._call(e),r=[t.pixel_values.dims[0],64,64],n=(0,i.full)(r,1n);return{...t,pixel_mask:n}}post_process_object_detection(...e){return d(...e)}post_process_panoptic_segmentation(...e){return _(...e)}post_process_instance_segmentation(){throw Error("Not implemented yet")}}class J extends T{post_process_panoptic_segmentation(...e){return _(...e)}post_process_instance_segmentation(){throw Error("Not implemented yet")}}class K extends T{post_process_object_detection(...e){return d(...e)}}class Z extends T{reshape_input_points(e,t,r,n=!1){e=structuredClone(e);let s=(0,o.calculateDimensions)(e);if(3===s.length)n||(s=[1,...s]),e=[e];else if(4!==s.length)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");for(let n=0;n<e.length;++n){let o=t[n],s=r[n],a=[s[0]/o[0],s[1]/o[1]];for(let t=0;t<e[n].length;++t)for(let r=0;r<e[n][t].length;++r)for(let o=0;o<e[n][t][r].length;++o)e[n][t][r][o]*=a[o%2]}return new i.Tensor("float32",Float32Array.from(e.flat(1/0)),s)}add_input_labels(e,t){let r=(0,o.calculateDimensions)(e);if(2===r.length)r=[1,...r],e=[e];else if(3!==r.length)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");if(r.some(((e,r)=>e!==t.dims[r])))throw Error(`The first ${r.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new i.Tensor("int64",e.flat(1/0).map(BigInt),r)}async _call(e,{input_points:t=null,input_labels:r=null,input_boxes:n=null}={}){const o=await super._call(e);if(t&&(o.input_points=this.reshape_input_points(t,o.original_sizes,o.reshaped_input_sizes)),r){if(!o.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");o.input_labels=this.add_input_labels(r,o.input_points)}return n&&(o.input_boxes=this.reshape_input_points(n,o.original_sizes,o.reshaped_input_sizes,!0)),o}async post_process_masks(e,t,r,{mask_threshold:n=0,binarize:o=!0,pad_size:s=null}={}){const a=[],l=[(s=s??this.pad_size).height,s.width];for(let s=0;s<t.length;++s){const c=t[s],d=r[s];let u=await(0,i.interpolate_4d)(e[s],{mode:"bilinear",size:l});if(u=u.slice(null,null,[0,d[0]],[0,d[1]]),u=await(0,i.interpolate_4d)(u,{mode:"bilinear",size:c}),o){const e=u.data,t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)e[r]>n&&(t[r]=1);u=new i.Tensor("bool",t,u.dims)}a.push(u)}return a}generate_crop_boxes(e,t,{crop_n_layers:r=0,overlap_ratio:n=512/1500,points_per_crop:o=32,crop_n_points_downscale_factor:s=1}={}){}}class ee extends T{pad_image(e,t,r,n={}){const[o,s,a]=t;return super.pad_image(e,t,{width:s+(r-s%r)%r,height:o+(r-o%r)%r},{mode:"symmetric",center:!1,constant_values:-1,...n})}}class te extends T{async _call(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);const r=await Promise.all(e.map((e=>this.preprocess(e)))),n=await Promise.all(t.map((e=>this.preprocess(e,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0}))));return{pixel_values:(0,i.stack)(r.map(((e,t)=>(0,i.cat)([e.pixel_values,n[t].pixel_values],0))),0),original_sizes:r.map((e=>e.original_size)),reshaped_input_sizes:r.map((e=>e.reshaped_input_size))}}}class re extends w{constructor(e){super(e),this.config.mel_filters??=(0,l.mel_filter_bank)(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=(0,l.window_function)(this.config.n_fft,"hann")}async _extract_fbank_features(e){const t=await(0,l.spectrogram)(e,this.window,this.config.n_fft,this.config.hop_length,{power:2,mel_filters:this.config.mel_filters,log_mel:"log10",max_num_frames:this.config.nb_max_frames}),r=t.data,n=(0,a.max)(r)[0];for(let e=0;e<r.length;++e)r[e]=(Math.max(r[e],n-8)+4)/4;return t}async _call(e){let t;f(e,"WhisperFeatureExtractor"),e.length>this.config.n_samples?(console.warn("Attempting to extract features for audio longer than 30 seconds. If using a pipeline to extract transcript from a long audio clip, remember to specify `chunk_length_s` and/or `stride_length_s`."),t=e.slice(0,this.config.n_samples)):(t=new Float32Array(this.config.n_samples),t.set(e));return{input_features:(await this._extract_fbank_features(t)).unsqueeze_(0)}}}class ne extends w{_zero_mean_unit_var_norm(e){const t=e.reduce(((e,t)=>e+t),0)/e.length,r=e.reduce(((e,r)=>e+(r-t)**2),0)/e.length;return e.map((e=>(e-t)/Math.sqrt(r+1e-7)))}async _call(e){f(e,"Wav2Vec2FeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let t=e;this.config.do_normalize&&(t=this._zero_mean_unit_var_norm(t));const r=[1,t.length];return{input_values:new i.Tensor("float32",t,r),attention_mask:new i.Tensor("int64",new BigInt64Array(t.length).fill(1n),r)}}}class oe extends w{constructor(e){super(e);const t=this.config.sampling_rate,r=(0,l.mel_filter_bank)(256,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);for(let e=0;e<r.length;++e)r[e].push(0);this.mel_filters=r,this.window=(0,l.window_function)(400,"povey",{periodic:!1})}async _extract_fbank_features(e,t){return e=e.map((e=>32768*e)),(0,l.spectrogram)(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e,{padding:t=!0,pad_to_multiple_of:r=2,do_normalize_per_mel_bins:n=!0,return_attention_mask:o=!0}={}){f(e,"SeamlessM4TFeatureExtractor");let s,a=await this._extract_fbank_features(e,this.config.max_length);if(n){const[e,t]=a.dims,r=a.data;for(let n=0;n<t;++n){let o=0;for(let s=0;s<e;++s)o+=r[s*t+n];const s=o/e;let a=0;for(let o=0;o<e;++o)a+=(r[o*t+n]-s)**2;a/=e-1;const i=Math.sqrt(a+1e-7);for(let o=0;o<e;++o){const e=o*t+n;r[e]=(r[e]-s)/i}}}if(t){const[e,t]=a.dims,n=a.data,l=e%r;if(l>0){const r=new Float32Array(t*(e+l));r.set(n),r.fill(this.config.padding_value,n.length);const c=e+l;a=new i.Tensor(a.type,r,[c,t]),o&&(s=new i.Tensor("int64",new BigInt64Array(c),[1,c]),s.data.fill(1n,0,e))}}const[l,c]=a.dims,d=this.config.stride;if(0!==l%d)throw new Error(`The number of frames (${l}) must be a multiple of the stride (${d}).`);const u=a.view(1,Math.floor(l/d),c*d),p={input_features:u};if(o){const e=u.dims[1],t=new BigInt64Array(e);if(s){const e=s.data;for(let r=1,n=0;r<l;r+=d,++n)t[n]=e[r]}else t.fill(1n);p.attention_mask=new i.Tensor("int64",t,[1,e])}return p}}class se extends w{constructor(e){super(e);const t=this.config.sampling_rate,r=(0,l.mel_filter_bank)(256,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);for(let e=0;e<r.length;++e)r[e].push(0);this.mel_filters=r,this.window=(0,l.window_function)(400,"hann",{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,t){return(0,l.spectrogram)(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e){f(e,"ASTFeatureExtractor");const t=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){const e=2*this.std,r=t.data;for(let t=0;t<r.length;++t)r[t]=(r[t]-this.mean)/e}return{input_values:t.unsqueeze_(0)}}}class ae extends w{constructor(e){super(e),this.mel_filters=(0,l.mel_filter_bank)(this.config.nb_frequency_bins,this.config.feature_size,this.config.frequency_min,this.config.frequency_max,this.config.sampling_rate,null,"htk"),this.mel_filters_slaney=(0,l.mel_filter_bank)(this.config.nb_frequency_bins,this.config.feature_size,this.config.frequency_min,this.config.frequency_max,this.config.sampling_rate,"slaney","slaney"),this.window=(0,l.window_function)(this.config.fft_window_size,"hann")}async _get_input_mel(e,t,r,n){let o,s=!1;const a=e.length-t;if(a>0){if("rand_trunc"!==r)throw new Error(`Truncation strategy "${r}" not implemented`);{s=!0;const r=Math.floor(Math.random()*(a+1));e=e.subarray(r,r+t),o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}}else{if(a<0){let r=new Float64Array(t);if(r.set(e),"repeat"===n)for(let n=e.length;n<t;n+=e.length)r.set(e.subarray(0,Math.min(e.length,t-n)),n);else if("repeatpad"===n)for(let t=e.length;t<-a;t+=e.length)r.set(e,t);e=r}if("fusion"===r)throw new Error(`Truncation strategy "${r}" not implemented`);o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}return o.unsqueeze_(0)}async _extract_fbank_features(e,t,r=null){return(0,l.spectrogram)(e,this.window,this.config.fft_window_size,this.config.hop_length,{power:2,mel_filters:t,log_mel:"dB",max_num_frames:r,do_pad:!1,transpose:!0})}async _call(e,{max_length:t=null}={}){f(e,"ClapFeatureExtractor");return{input_features:(await this._get_input_mel(e,t??this.config.nb_max_samples,this.config.truncation,this.config.padding)).unsqueeze_(0)}}}class ie extends w{async _call(e){f(e,"PyAnnoteFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));const t=[1,1,e.length];return{input_values:new i.Tensor("float32",e,t)}}samples_to_frames(e){return(e-this.config.offset)/this.config.step}post_process_speaker_diarization(e,t){const r=t/this.samples_to_frames(t)/this.config.sampling_rate,n=[];for(const t of e.tolist()){const e=[];let o=-1;for(let r=0;r<t.length;++r){const n=(0,a.softmax)(t[r]),[s,i]=(0,a.max)(n),[l,c]=[r,r+1];i!==o?(o=i,e.push({id:i,start:l,end:c,score:s})):(e.at(-1).end=c,e.at(-1).score+=s)}n.push(e.map((({id:e,start:t,end:n,score:o})=>({id:e,start:t*r,end:n*r,confidence:o/(n-t)}))))}return n}}class le extends w{constructor(e){super(e);const t=this.config.sampling_rate,r=(0,l.mel_filter_bank)(256,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);for(let e=0;e<r.length;++e)r[e].push(0);this.mel_filters=r,this.window=(0,l.window_function)(400,"hamming",{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map((e=>32768*e)),(0,l.spectrogram)(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1.192092955078125e-7,remove_dc_offset:!0,transpose:!0,min_num_frames:this.min_num_frames})}async _call(e){f(e,"WeSpeakerFeatureExtractor");const t=(await this._extract_fbank_features(e)).unsqueeze_(0);if(null===this.config.fbank_centering_span){const e=t.mean(1).data,r=t.data,[n,o,s]=t.dims;for(let t=0;t<n;++t){const n=t*o*s,a=t*s;for(let t=0;t<o;++t){const o=n+t*s;for(let t=0;t<s;++t)r[o+t]-=e[a+t]}}}return{input_features:t}}}class ce extends w{}class de extends n.Callable{constructor(e){super(),this.feature_extractor=e}async _call(e,...t){return await this.feature_extractor(e,...t)}}class ue extends de{async _call(...e){return await this.feature_extractor(...e)}post_process_masks(...e){return this.feature_extractor.post_process_masks(...e)}reshape_input_points(...e){return this.feature_extractor.reshape_input_points(...e)}}class pe extends de{async _call(e){return await this.feature_extractor(e)}}class he extends de{async _call(e){return await this.feature_extractor(e)}}class me extends de{async _call(e){return await this.feature_extractor(e)}post_process_speaker_diarization(...e){return this.feature_extractor.post_process_speaker_diarization(...e)}}class _e extends de{async _call(e){return await this.feature_extractor(e)}}class fe extends de{}class ge extends de{constructor(e){super(e);const{tasks_answer_post_processing_type:t,task_prompts_without_inputs:r,task_prompts_with_input:n}=e.config;this.tasks_answer_post_processing_type=new Map(Object.entries(t??{})),this.task_prompts_without_inputs=new Map(Object.entries(r??{})),this.task_prompts_with_input=new Map(Object.entries(n??{})),this.regexes={quad_boxes:/(.+?)<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm,bboxes:/([^<]+)?<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm},this.size_per_bin=1e3}construct_prompts(e){"string"==typeof e&&(e=[e]);const t=[];for(const r of e)if(this.task_prompts_without_inputs.has(r))t.push(this.task_prompts_without_inputs.get(r));else{for(const[e,n]of this.task_prompts_with_input)if(r.includes(e)){t.push(n.replaceAll("{input}",r).replaceAll(e,""));break}t.length!==e.length&&t.push(r)}return t}post_process_generation(e,t,r){const n=this.tasks_answer_post_processing_type.get(t)??"pure_text";let o;switch(e=e.replaceAll("<s>","").replaceAll("</s>",""),n){case"pure_text":o=e;break;case"description_with_bboxes":case"bboxes":case"phrase_grounding":case"ocr":const s="ocr"===n?"quad_boxes":"bboxes",a=e.matchAll(this.regexes[s]),i=[],l=[];for(const[e,t,...n]of a)i.push(t?t.trim():i.at(-1)??""),l.push(n.map(((e,t)=>(Number(e)+.5)/this.size_per_bin*r[t%2])));o={labels:i,[s]:l};break;default:throw new Error(`Task "${t}" (of type "${n}") not yet implemented.`)}return{[t]:o}}}class Me{static FEATURE_EXTRACTOR_CLASS_MAPPING={ImageFeatureExtractor:T,WhisperFeatureExtractor:re,ViTFeatureExtractor:I,MobileViTFeatureExtractor:R,MobileViTImageProcessor:G,MobileNetV1FeatureExtractor:O,MobileNetV2FeatureExtractor:D,MobileNetV3FeatureExtractor:V,MobileNetV4FeatureExtractor:j,OwlViTFeatureExtractor:q,Owlv2ImageProcessor:$,CLIPFeatureExtractor:v,CLIPImageProcessor:S,Florence2Processor:ge,ChineseCLIPFeatureExtractor:A,SiglipImageProcessor:E,ConvNextFeatureExtractor:L,ConvNextImageProcessor:z,SegformerFeatureExtractor:x,SapiensFeatureExtractor:b,BitImageProcessor:P,DPTImageProcessor:F,DPTFeatureExtractor:y,PvtImageProcessor:k,GLPNFeatureExtractor:C,BeitFeatureExtractor:X,DeiTFeatureExtractor:U,DetrFeatureExtractor:Y,RTDetrImageProcessor:W,MaskFormerFeatureExtractor:J,YolosFeatureExtractor:K,DonutFeatureExtractor:Q,NougatImageProcessor:H,EfficientNetImageProcessor:N,ViTImageProcessor:B,VitMatteImageProcessor:te,SamImageProcessor:Z,Swin2SRImageProcessor:ee,Wav2Vec2FeatureExtractor:ne,SeamlessM4TFeatureExtractor:oe,SpeechT5FeatureExtractor:ce,ASTFeatureExtractor:se,ClapFeatureExtractor:ae,PyAnnoteFeatureExtractor:ie,WeSpeakerFeatureExtractor:le};static PROCESSOR_CLASS_MAPPING={WhisperProcessor:pe,Wav2Vec2ProcessorWithLM:he,PyAnnoteProcessor:me,SamProcessor:ue,SpeechT5Processor:_e,OwlViTProcessor:fe,Florence2Processor:ge};static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){let i=r??await(0,s.getModelJSON)(e,"preprocessor_config.json",!0,{progress_callback:t,config:r,cache_dir:n,local_files_only:o,revision:a}),l=i.feature_extractor_type??i.image_processor_type,c=this.FEATURE_EXTRACTOR_CLASS_MAPPING[l];if(!c){if(void 0===i.size)throw new Error(`Unknown Feature Extractor type: ${l}`);console.warn(`Feature extractor type "${l}" not found, assuming ImageFeatureExtractor due to size parameter in config.`),c=T}return new(this.PROCESSOR_CLASS_MAPPING[i.processor_class]??de)(new c(i))}}},"./src/tokenizers.js":
/*!***************************!*\
!*** ./src/tokenizers.js ***!
\***************************/(e,t,r)=>{r.r(t),r.d(t,{AlbertTokenizer:()=>xe,AutoTokenizer:()=>ht,BartTokenizer:()=>Ne,BertTokenizer:()=>be,BlenderbotSmallTokenizer:()=>lt,BlenderbotTokenizer:()=>it,BloomTokenizer:()=>je,CLIPTokenizer:()=>nt,CamembertTokenizer:()=>Ee,CodeGenTokenizer:()=>rt,CodeLlamaTokenizer:()=>qe,CohereTokenizer:()=>pt,ConvBertTokenizer:()=>ve,DebertaTokenizer:()=>Fe,DebertaV2Tokenizer:()=>Pe,DistilBertTokenizer:()=>Ae,ElectraTokenizer:()=>ze,EsmTokenizer:()=>Qe,FalconTokenizer:()=>Ue,GPT2Tokenizer:()=>Be,GPTNeoXTokenizer:()=>Xe,GemmaTokenizer:()=>Ye,Grok1Tokenizer:()=>Je,HerbertTokenizer:()=>Ce,LlamaTokenizer:()=>Ge,M2M100Tokenizer:()=>et,MBart50Tokenizer:()=>De,MBartTokenizer:()=>Oe,MPNetTokenizer:()=>We,MarianTokenizer:()=>st,MobileBertTokenizer:()=>ke,NllbTokenizer:()=>Ze,NougatTokenizer:()=>dt,PreTrainedTokenizer:()=>Te,Qwen2Tokenizer:()=>He,RoFormerTokenizer:()=>Se,RobertaTokenizer:()=>Ve,SiglipTokenizer:()=>ot,SpeechT5Tokenizer:()=>ct,SqueezeBertTokenizer:()=>ye,T5Tokenizer:()=>Ie,TokenizerModel:()=>k,VitsTokenizer:()=>ut,Wav2Vec2CTCTokenizer:()=>at,WhisperTokenizer:()=>tt,XLMRobertaTokenizer:()=>$e,XLMTokenizer:()=>Le,is_chinese_char:()=>M});var n=r(/*! ./utils/generic.js */"./src/utils/generic.js"),o=r(/*! ./utils/core.js */"./src/utils/core.js"),s=r(/*! ./utils/hub.js */"./src/utils/hub.js"),a=r(/*! ./utils/maths.js */"./src/utils/maths.js"),i=r(/*! ./utils/tensor.js */"./src/utils/tensor.js"),l=r(/*! ./utils/data-structures.js */"./src/utils/data-structures.js"),c=r(/*! @huggingface/jinja */"./node_modules/@huggingface/jinja/dist/index.js"),d=r(/*! ./models/whisper/common_whisper.js */"./src/models/whisper/common_whisper.js"),u=r(/*! ./utils/constants.js */"./src/utils/constants.js");async function p(e,t){const r=await Promise.all([(0,s.getModelJSON)(e,"tokenizer.json",!0,t),(0,s.getModelJSON)(e,"tokenizer_config.json",!0,t)]);return null!==t.legacy&&(r[1].legacy=t.legacy),r}function h(e,t=!0){if(void 0!==e.Regex){let t=e.Regex.replace(/\\([#&~])/g,"$1");for(const[e,r]of b)t=t.replaceAll(e,r);return new RegExp(t,"gu")}if(void 0!==e.String){const r=(0,o.escapeRegExp)(e.String);return new RegExp(t?r:`(${r})`,"gu")}return console.warn("Unknown pattern type:",e),null}function m(e){return new Map(Object.entries(e))}function _(e){const t=e.dims;switch(t.length){case 1:return e.tolist();case 2:if(1!==t[0])throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return e.tolist()[0];default:throw new Error(`Expected tensor to have 1-2 dimensions, got ${t.length}.`)}}function f(e){return e.replace(/ \./g,".").replace(/ \?/g,"?").replace(/ \!/g,"!").replace(/ ,/g,",").replace(/ \' /g,"'").replace(/ n\'t/g,"n't").replace(/ \'m/g,"'m").replace(/ \'s/g,"'s").replace(/ \'ve/g,"'ve").replace(/ \'re/g,"'re")}function g(e){return e.replace(/\p{M}/gu,"")}function M(e){return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=63744&&e<=64255||e>=194560&&e<=195103}const w="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",T=new RegExp(`^[${w}]+$`,"gu"),b=new Map([["(?i:'s|'t|'re|'ve|'m|'ll|'d)","(?:'([sS]|[tT]|[rR][eE]|[vV][eE]|[mM]|[lL][lL]|[dD]))"]]);class x{constructor(e){this.content=e.content,this.id=e.id,this.single_word=e.single_word??!1,this.lstrip=e.lstrip??!1,this.rstrip=e.rstrip??!1,this.special=e.special??!1,this.normalized=e.normalized??null}}class k extends n.Callable{constructor(e){super(),this.config=e,this.vocab=[],this.tokens_to_ids=new Map,this.unk_token_id=void 0,this.unk_token=void 0,this.end_of_word_suffix=void 0,this.fuse_unk=this.config.fuse_unk??!1}static fromConfig(e,...t){switch(e.type){case"WordPiece":return new y(e);case"Unigram":return new F(e,...t);case"BPE":return new v(e);default:if(e.vocab)return new S(e,...t);throw new Error(`Unknown TokenizerModel type: ${e.type}`)}}_call(e){return e=this.encode(e),this.fuse_unk&&(e=function(e,t,r){const n=[];let o=0;for(;o<e.length;)if(n.push(e[o]),(t.get(e[o])??r)===r)for(;++o<e.length&&(t.get(e[o])??r)===r;)t.get(n.at(-1))!==r&&(n[n.length-1]+=e[o]);else++o;return n}(e,this.tokens_to_ids,this.unk_token_id)),e}encode(e){throw Error("encode should be implemented in subclass.")}convert_tokens_to_ids(e){return e.map((e=>this.tokens_to_ids.get(e)??this.unk_token_id))}convert_ids_to_tokens(e){return e.map((e=>this.vocab[e]??this.unk_token))}}class y extends k{constructor(e){super(e),this.tokens_to_ids=m(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.max_input_chars_per_word=e.max_input_chars_per_word??100,this.vocab=new Array(this.tokens_to_ids.size);for(const[e,t]of this.tokens_to_ids)this.vocab[t]=e}encode(e){const t=[];for(const r of e){const e=[...r];if(e.length>this.max_input_chars_per_word){t.push(this.unk_token);continue}let n=!1,o=0;const s=[];for(;o<e.length;){let t=e.length,r=null;for(;o<t;){let n=e.slice(o,t).join("");if(o>0&&(n=this.config.continuing_subword_prefix+n),this.tokens_to_ids.has(n)){r=n;break}--t}if(null===r){n=!0;break}s.push(r),o=t}n?t.push(this.unk_token):t.push(...s)}return t}}class F extends k{constructor(e,t){super(e);const r=e.vocab.length;this.vocab=new Array(r),this.scores=new Array(r);for(let t=0;t<r;++t){const r=e.vocab[t];this.vocab[t]=r[0],this.scores[t]=r[1]}this.unk_token_id=e.unk_id,this.unk_token=this.vocab[e.unk_id],this.tokens_to_ids=new Map(this.vocab.map(((e,t)=>[e,t]))),this.bos_token=" ",this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.minScore=(0,a.min)(this.scores)[0],this.unk_score=this.minScore-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new l.CharTrie,this.trie.extend(this.vocab),this.fuse_unk=!0}populateNodes(e){const t=e.chars;let r=0;for(;r<t.length;){let n=!1;const s=[],a=t.slice(r).join(""),i=this.trie.commonPrefixSearch(a);for(const t of i){s.push(t);const a=this.tokens_to_ids.get(t),i=this.scores[a],l=(0,o.len)(t);e.insert(r,l,i,a),n||1!==l||(n=!0)}n||e.insert(r,1,this.unk_score,this.unk_token_id),r+=1}}tokenize(e){const t=new l.TokenLattice(e,this.bos_token_id,this.eos_token_id);return this.populateNodes(t),t.tokens()}encode(e){const t=[];for(const r of e){const e=this.tokenize(r);t.push(...e)}return t}}const P=(()=>{const e=[...Array.from({length:"~".charCodeAt(0)-"!".charCodeAt(0)+1},((e,t)=>t+"!".charCodeAt(0))),...Array.from({length:"¬".charCodeAt(0)-"¡".charCodeAt(0)+1},((e,t)=>t+"¡".charCodeAt(0))),...Array.from({length:"ÿ".charCodeAt(0)-"®".charCodeAt(0)+1},((e,t)=>t+"®".charCodeAt(0)))],t=e.slice();let r=0;for(let n=0;n<256;++n)e.includes(n)||(e.push(n),t.push(256+r),r+=1);const n=t.map((e=>String.fromCharCode(e)));return Object.fromEntries(e.map(((e,t)=>[e,n[t]])))})(),C=(0,o.reverseDictionary)(P);class v extends k{constructor(e){super(e),this.BPE_SPLIT_TOKEN=" ",this.tokens_to_ids=m(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(const[e,t]of this.tokens_to_ids)this.vocab[t]=e;this.bpe_ranks=new Map(e.merges.map(((e,t)=>[e,t]))),this.merges=e.merges.map((e=>e.split(this.BPE_SPLIT_TOKEN))),this.end_of_word_suffix=e.end_of_word_suffix,this.continuing_subword_suffix=e.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.ignore_merges=this.config.ignore_merges??!1,this.cache=new Map}bpe(e){if(0===e.length)return[];const t=this.cache.get(e);if(void 0!==t)return t;const r=Array.from(e);this.end_of_word_suffix&&(r[r.length-1]+=this.end_of_word_suffix);let n=[];if(r.length>1){const e=new l.PriorityQueue(((e,t)=>e.score<t.score));let t={token:r[0],bias:0,prev:null,next:null},o=t;for(let t=1;t<r.length;++t){const n={bias:t/r.length,token:r[t],prev:o,next:null};o.next=n,this._add_node(e,o),o=n}for(;!e.isEmpty();){const r=e.pop();if(r.deleted||!r.next||r.next.deleted)continue;if(r.deleted=!0,r.next.deleted=!0,r.prev){const e={...r.prev};r.prev.deleted=!0,r.prev=e,e.prev?e.prev.next=e:t=e}const n={token:r.token+r.next.token,bias:r.bias,prev:r.prev,next:r.next.next};n.prev?(n.prev.next=n,this._add_node(e,n.prev)):t=n,n.next&&(n.next.prev=n,this._add_node(e,n))}for(let e=t;null!==e;e=e.next)n.push(e.token)}else n=r;if(this.continuing_subword_suffix)for(let e=0;e<n.length-1;++e)n[e]+=this.continuing_subword_suffix;return this.cache.set(e,n),n}_add_node(e,t){const r=this.bpe_ranks.get(t.token+this.BPE_SPLIT_TOKEN+t.next.token);void 0!==r&&(t.score=r+t.bias,e.push(t))}encode(e){const t=[];for(const r of e){if(this.ignore_merges&&this.tokens_to_ids.has(r)){t.push(r);continue}const e=this.bpe(r);for(const r of e)if(this.tokens_to_ids.has(r))t.push(r);else if(this.byte_fallback){const e=Array.from(this.text_encoder.encode(r)).map((e=>`<0x${e.toString(16).toUpperCase().padStart(2,"0")}>`));e.every((e=>this.tokens_to_ids.has(e)))?t.push(...e):t.push(this.unk_token)}else t.push(this.unk_token)}return t}}class S extends k{constructor(e,t){super(e),this.tokens_to_ids=m(t.target_lang?e.vocab[t.target_lang]:e.vocab),this.bos_token=t.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=t.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=t.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=new Array(this.tokens_to_ids.size);for(const[e,t]of this.tokens_to_ids)this.vocab[t]=e}encode(e){return e}}class A extends n.Callable{constructor(e){super(),this.config=e}static fromConfig(e){if(null===e)return null;switch(e.type){case"BertNormalizer":return new j(e);case"Precompiled":return new pe(e);case"Sequence":return new V(e);case"Replace":return new E(e);case"NFC":return new L(e);case"NFKC":return new z(e);case"NFKD":return new I(e);case"Strip":return new B(e);case"StripAccents":return new N(e);case"Lowercase":return new O(e);case"Prepend":return new D(e);default:throw new Error(`Unknown Normalizer type: ${e.type}`)}}normalize(e){throw Error("normalize should be implemented in subclass.")}_call(e){return this.normalize(e)}}class E extends A{normalize(e){const t=h(this.config.pattern);return null===t?e:e.replaceAll(t,this.config.content)}}class L extends A{normalize(e){return e=e.normalize("NFC")}}class z extends A{normalize(e){return e=e.normalize("NFKC")}}class I extends A{normalize(e){return e=e.normalize("NFKD")}}class B extends A{normalize(e){return this.config.strip_left&&this.config.strip_right?e=e.trim():(this.config.strip_left&&(e=e.trimStart()),this.config.strip_right&&(e=e.trimEnd())),e}}class N extends A{normalize(e){return e=g(e)}}class O extends A{normalize(e){return e=e.toLowerCase()}}class D extends A{normalize(e){return e=this.config.prepend+e}}class V extends A{constructor(e){super(e),this.normalizers=e.normalizers.map((e=>A.fromConfig(e)))}normalize(e){return this.normalizers.reduce(((e,t)=>t.normalize(e)),e)}}class j extends A{_tokenize_chinese_chars(e){const t=[];for(let r=0;r<e.length;++r){const n=e[r];M(n.charCodeAt(0))?(t.push(" "),t.push(n),t.push(" ")):t.push(n)}return t.join("")}stripAccents(e){return e.normalize("NFD").replace(/\p{Mn}/gu,"")}_is_control(e){switch(e){case"\t":case"\n":case"\r":return!1;default:return/^\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}$/u.test(e)}}_clean_text(e){const t=[];for(const r of e){const e=r.charCodeAt(0);0===e||65533===e||this._is_control(r)||(/^\s$/.test(r)?t.push(" "):t.push(r))}return t.join("")}normalize(e){return this.config.clean_text&&(e=this._clean_text(e)),this.config.handle_chinese_chars&&(e=this._tokenize_chinese_chars(e)),this.config.lowercase?(e=e.toLowerCase(),!1!==this.config.strip_accents&&(e=this.stripAccents(e))):this.config.strip_accents&&(e=this.stripAccents(e)),e}}class R extends n.Callable{static fromConfig(e){if(null===e)return null;switch(e.type){case"BertPreTokenizer":return new G(e);case"Sequence":return new he(e);case"Whitespace":return new me(e);case"WhitespaceSplit":return new _e(e);case"Metaspace":return new de(e);case"ByteLevel":return new q(e);case"Split":return new $(e);case"Punctuation":return new W(e);case"Digits":return new U(e);case"Replace":return new fe(e);default:throw new Error(`Unknown PreTokenizer type: ${e.type}`)}}pre_tokenize_text(e,t){throw Error("pre_tokenize_text should be implemented in subclass.")}pre_tokenize(e,t){return(Array.isArray(e)?e.map((e=>this.pre_tokenize_text(e,t))):this.pre_tokenize_text(e,t)).flat()}_call(e,t){return this.pre_tokenize(e,t)}}class G extends R{constructor(e){super(),this.pattern=new RegExp(`[^\\s${w}]+|[${w}]`,"gu")}pre_tokenize_text(e,t){return e.trim().match(this.pattern)||[]}}class q extends R{constructor(e){super(),this.config=e,this.add_prefix_space=this.config.add_prefix_space,this.trim_offsets=this.config.trim_offsets,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=P,this.text_encoder=new TextEncoder}pre_tokenize_text(e,t){this.add_prefix_space&&!e.startsWith(" ")&&(e=" "+e);return(this.use_regex?e.match(this.pattern)||[]:[e]).map((e=>Array.from(this.text_encoder.encode(e),(e=>this.byte_encoder[e])).join("")))}}class $ extends R{constructor(e){super(),this.config=e,this.pattern=h(this.config.pattern,this.config.invert)}pre_tokenize_text(e,t){return null===this.pattern?[]:this.config.invert?e.match(this.pattern)||[]:function(e,t){const r=[];let n=0;for(const o of e.matchAll(t)){const t=o[0];n<o.index&&r.push(e.slice(n,o.index)),t.length>0&&r.push(t),n=o.index+t.length}return n<e.length&&r.push(e.slice(n)),r}(e,this.pattern)}}class W extends R{constructor(e){super(),this.config=e,this.pattern=new RegExp(`[^${w}]+|[${w}]+`,"gu")}pre_tokenize_text(e,t){return e.match(this.pattern)||[]}}class U extends R{constructor(e){super(),this.config=e;const t="[^\\d]+|\\d"+(this.config.individual_digits?"":"+");this.pattern=new RegExp(t,"gu")}pre_tokenize_text(e,t){return e.match(this.pattern)||[]}}class X extends n.Callable{constructor(e){super(),this.config=e}static fromConfig(e){if(null===e)return null;switch(e.type){case"TemplateProcessing":return new Y(e);case"ByteLevel":return new J(e);case"RobertaProcessing":return new H(e);case"BertProcessing":return new Q(e);case"Sequence":return new K(e);default:throw new Error(`Unknown PostProcessor type: ${e.type}`)}}post_process(e,...t){throw Error("post_process should be implemented in subclass.")}_call(e,...t){return this.post_process(e,...t)}}class Q extends X{constructor(e){super(e),this.cls=e.cls[0],this.sep=e.sep[0]}post_process(e,t=null,{add_special_tokens:r=!0}={}){r&&(e=(0,o.mergeArrays)([this.cls],e,[this.sep]));let n=new Array(e.length).fill(0);if(null!==t){const s=r&&this instanceof H?[this.sep]:[],a=r?[this.sep]:[];e=(0,o.mergeArrays)(e,s,t,a),n=(0,o.mergeArrays)(n,new Array(t.length+s.length+a.length).fill(1))}return{tokens:e,token_type_ids:n}}}class H extends Q{}class Y extends X{constructor(e){super(e),this.single=e.single,this.pair=e.pair}post_process(e,t=null,{add_special_tokens:r=!0}={}){const n=null===t?this.single:this.pair;let s=[],a=[];for(const i of n)"SpecialToken"in i?r&&(s.push(i.SpecialToken.id),a.push(i.SpecialToken.type_id)):"Sequence"in i&&("A"===i.Sequence.id?(s=(0,o.mergeArrays)(s,e),a=(0,o.mergeArrays)(a,new Array(e.length).fill(i.Sequence.type_id))):"B"===i.Sequence.id&&(s=(0,o.mergeArrays)(s,t),a=(0,o.mergeArrays)(a,new Array(t.length).fill(i.Sequence.type_id))));return{tokens:s,token_type_ids:a}}}class J extends X{post_process(e,t=null){return t&&(e=(0,o.mergeArrays)(e,t)),{tokens:e}}}class K extends X{constructor(e){super(e),this.processors=e.processors.map((e=>X.fromConfig(e)))}post_process(e,t=null,r={}){let n;for(const o of this.processors)if(o instanceof J){if(e=o.post_process(e).tokens,t){t=o.post_process(t).tokens}}else{const s=o.post_process(e,t,r);e=s.tokens,n=s.token_type_ids}return{tokens:e,token_type_ids:n}}}class Z extends n.Callable{constructor(e){super(),this.config=e,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets=e.trim_offsets}static fromConfig(e){if(null===e)return null;switch(e.type){case"WordPiece":return new oe(e);case"Metaspace":return new ue(e);case"ByteLevel":return new se(e);case"Replace":return new ee(e);case"ByteFallback":return new te(e);case"Fuse":return new re(e);case"Strip":return new ne(e);case"Sequence":return new ie(e);case"CTC":return new ae(e);case"BPEDecoder":return new le(e);default:throw new Error(`Unknown Decoder type: ${e.type}`)}}_call(e){return this.decode(e)}decode(e){return this.decode_chain(e).join("")}decode_chain(e){throw Error("`decode_chain` should be implemented in subclass.")}}class ee extends Z{decode_chain(e){const t=h(this.config.pattern);return null===t?e:e.map((e=>e.replaceAll(t,this.config.content)))}}class te extends Z{constructor(e){super(e),this.text_decoder=new TextDecoder}decode_chain(e){const t=[];let r=[];for(const n of e){let e=null;if(6===n.length&&n.startsWith("<0x")&&n.endsWith(">")){const t=parseInt(n.slice(3,5),16);isNaN(t)||(e=t)}if(null!==e)r.push(e);else{if(r.length>0){const e=this.text_decoder.decode(Uint8Array.from(r));t.push(e),r=[]}t.push(n)}}if(r.length>0){const e=this.text_decoder.decode(Uint8Array.from(r));t.push(e),r=[]}return t}}class re extends Z{decode_chain(e){return[e.join("")]}}class ne extends Z{constructor(e){super(e),this.content=this.config.content,this.start=this.config.start,this.stop=this.config.stop}decode_chain(e){return e.map((e=>{let t=0;for(let r=0;r<this.start&&e[r]===this.content;++r)t=r+1;let r=e.length;for(let t=0;t<this.stop;++t){const n=e.length-t-1;if(e[n]!==this.content)break;r=n}return e.slice(t,r)}))}}class oe extends Z{constructor(e){super(e),this.cleanup=e.cleanup}decode_chain(e){return e.map(((e,t)=>(0!==t&&(e=e.startsWith(this.config.prefix)?e.replace(this.config.prefix,""):" "+e),this.cleanup&&(e=f(e)),e)))}}class se extends Z{constructor(e){super(e),this.byte_decoder=C,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(e){const t=e.join(""),r=new Uint8Array([...t].map((e=>this.byte_decoder[e])));return this.text_decoder.decode(r)}decode_chain(e){const t=[];let r=[];for(const n of e)void 0!==this.added_tokens.find((e=>e.content===n))?(r.length>0&&(t.push(this.convert_tokens_to_string(r)),r=[]),t.push(n)):r.push(n);return r.length>0&&t.push(this.convert_tokens_to_string(r)),t}}class ae extends Z{constructor(e){super(e),this.pad_token=this.config.pad_token,this.word_delimiter_token=this.config.word_delimiter_token,this.cleanup=this.config.cleanup}convert_tokens_to_string(e){if(0===e.length)return"";const t=[e[0]];for(let r=1;r<e.length;++r)e[r]!==t.at(-1)&&t.push(e[r]);let r=t.filter((e=>e!==this.pad_token)).join("");return this.cleanup&&(r=f(r).replaceAll(this.word_delimiter_token," ").trim()),r}decode_chain(e){return[this.convert_tokens_to_string(e)]}}class ie extends Z{constructor(e){super(e),this.decoders=e.decoders.map((e=>Z.fromConfig(e)))}decode_chain(e){return this.decoders.reduce(((e,t)=>t.decode_chain(e)),e)}}class le extends Z{constructor(e){super(e),this.suffix=this.config.suffix}decode_chain(e){return e.map(((t,r)=>t.replaceAll(this.suffix,r===e.length-1?"":" ")))}}class ce extends Z{decode_chain(e){let t="";for(let r=1;r<e.length;r+=2)t+=e[r];return[t]}}class de extends R{constructor(e){super(),this.addPrefixSpace=e.add_prefix_space,this.replacement=e.replacement,this.strRep=e.str_rep||this.replacement,this.prepend_scheme=e.prepend_scheme??"always"}pre_tokenize_text(e,{section_index:t}={}){let r=e.replaceAll(" ",this.strRep);return this.addPrefixSpace&&!r.startsWith(this.replacement)&&("always"===this.prepend_scheme||"first"===this.prepend_scheme&&0===t)&&(r=this.strRep+r),[r]}}class ue extends Z{constructor(e){super(e),this.addPrefixSpace=e.add_prefix_space,this.replacement=e.replacement}decode_chain(e){const t=[];for(let r=0;r<e.length;++r){let n=e[r].replaceAll(this.replacement," ");this.addPrefixSpace&&0==r&&n.startsWith(" ")&&(n=n.substring(1)),t.push(n)}return t}}class pe extends A{constructor(e){super(e),this.charsmap=e.precompiled_charsmap}normalize(e){if((e=(e=e.replace(/[\u0001-\u0008\u000B\u000E-\u001F\u007F\u008F\u009F]/gm,"")).replace(/[\u0009\u000A\u000C\u000D\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u2581\u3000\uFEFF\uFFFD]/gm," ")).includes("~")){const t=e.split("~");e=t.map((e=>e.normalize("NFKC"))).join("~")}else e=e.normalize("NFKC");return e}}class he extends R{constructor(e){super(),this.tokenizers=e.pretokenizers.map((e=>R.fromConfig(e)))}pre_tokenize_text(e,t){return this.tokenizers.reduce(((e,r)=>r.pre_tokenize(e,t)),[e])}}class me extends R{constructor(e){super()}pre_tokenize_text(e,t){return e.match(/\w+|[^\w\s]+/g)||[]}}class _e extends R{constructor(e){super()}pre_tokenize_text(e,t){return function(e){return e.match(/\S+/g)||[]}(e)}}class fe extends R{constructor(e){super(),this.config=e,this.pattern=h(this.config.pattern),this.content=this.config.content}pre_tokenize_text(e,t){return null===this.pattern?[e]:[e.replaceAll(this.pattern,this.config.content)]}}const ge=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function Me(e,t,r,n){for(const s of Object.keys(e)){const a=t-e[s].length,i=r(s),l=new Array(a).fill(i);e[s]="right"===n?(0,o.mergeArrays)(e[s],l):(0,o.mergeArrays)(l,e[s])}}function we(e,t){for(const r of Object.keys(e))e[r].length=t}class Te extends n.Callable{return_token_type_ids=!1;padding_side="right";constructor(e,t){super(),this._tokenizer_config=t,this.normalizer=A.fromConfig(e.normalizer),this.pre_tokenizer=R.fromConfig(e.pre_tokenizer),this.model=k.fromConfig(e.model,t),this.post_processor=X.fromConfig(e.post_processor),this.decoder=Z.fromConfig(e.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];for(const t of e.added_tokens){const e=new x(t);this.added_tokens.push(e),this.model.tokens_to_ids.set(e.content,e.id),this.model.vocab[e.id]=e.content,e.special&&(this.special_tokens.push(e.content),this.all_special_ids.push(e.id))}if(this.additional_special_tokens=t.additional_special_tokens??[],this.special_tokens.push(...this.additional_special_tokens),this.special_tokens=[...new Set(this.special_tokens)],this.decoder&&(this.decoder.added_tokens=this.added_tokens,this.decoder.end_of_word_suffix=this.model.end_of_word_suffix),this.added_tokens_regex=this.added_tokens.length>0?new RegExp(this.added_tokens.slice().sort(((e,t)=>t.content.length-e.content.length)).map((e=>`${e.lstrip?"\\s*":""}(${(0,o.escapeRegExp)(e.content)})${e.rstrip?"\\s*":""}`)).join("|")):null,this.mask_token=this.getToken("mask_token"),this.mask_token_id=this.model.tokens_to_ids.get(this.mask_token),this.pad_token=this.getToken("pad_token","eos_token"),this.pad_token_id=this.model.tokens_to_ids.get(this.pad_token),this.sep_token=this.getToken("sep_token"),this.sep_token_id=this.model.tokens_to_ids.get(this.sep_token),this.unk_token=this.getToken("unk_token"),this.unk_token_id=this.model.tokens_to_ids.get(this.unk_token),this.model_max_length=t.model_max_length,this.remove_space=t.remove_space,this.clean_up_tokenization_spaces=t.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=t.do_lowercase_and_remove_accent??!1,t.padding_side&&(this.padding_side=t.padding_side),this.legacy=!1,this.chat_template=t.chat_template??null,Array.isArray(this.chat_template)){const e=Object.create(null);for(const{name:t,template:r}of this.chat_template){if("string"!=typeof t||"string"!=typeof r)throw new Error('Chat template must be a list of objects with "name" and "template" properties');e[t]=r}this.chat_template=e}this._compiled_template_cache=new Map}getToken(...e){for(const t of e){const e=this._tokenizer_config[t];if(e){if("object"==typeof e){if("AddedToken"===e.__type)return e.content;throw Error(`Unknown token: ${e}`)}return e}}return null}static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:s="main",legacy:a=null}={}){return new this(...await p(e,{progress_callback:t,config:r,cache_dir:n,local_files_only:o,revision:s,legacy:a}))}_call(e,{text_pair:t=null,add_special_tokens:r=!0,padding:n=!1,truncation:o=null,max_length:s=null,return_tensor:l=!0,return_token_type_ids:c=null}={}){const d=Array.isArray(e);let u;if(d){if(0===e.length)throw Error("text array must be non-empty");if(null!==t){if(!Array.isArray(t))throw Error("text_pair must also be an array");if(e.length!==t.length)throw Error("text and text_pair must have the same length");u=e.map(((e,n)=>this._encode_plus(e,{text_pair:t[n],add_special_tokens:r,return_token_type_ids:c})))}else u=e.map((e=>this._encode_plus(e,{add_special_tokens:r,return_token_type_ids:c})))}else{if(null==e)throw Error("text may not be null or undefined");if(Array.isArray(t))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");u=[this._encode_plus(e,{text_pair:t,add_special_tokens:r,return_token_type_ids:c})]}if(null===s?s="max_length"===n?this.model_max_length:(0,a.max)(u.map((e=>e.input_ids.length)))[0]:o||console.warn("Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation=true` to explicitly truncate examples to max length."),s=Math.min(s,this.model_max_length??1/0),n||o)for(let e=0;e<u.length;++e)u[e].input_ids.length!==s&&(u[e].input_ids.length>s?o&&we(u[e],s):n&&Me(u[e],s,(e=>"input_ids"===e?this.pad_token_id:0),this.padding_side));const p={};if(l){if((!n||!o)&&u.some((e=>{for(const t of Object.keys(e))if(e[t].length!==u[0][t]?.length)return!0;return!1})))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=true' and 'truncation=true' to have batched tensors with the same length.");const e=[u.length,u[0].input_ids.length];for(const t of Object.keys(u[0]))p[t]=new i.Tensor("int64",BigInt64Array.from(u.flatMap((e=>e[t])).map(BigInt)),e)}else{for(const e of Object.keys(u[0]))p[e]=u.map((t=>t[e]));if(!d)for(const e of Object.keys(p))p[e]=p[e][0]}return p}_encode_text(e){if(null===e)return null;const t=(this.added_tokens_regex?e.split(this.added_tokens_regex).filter((e=>e)):[e]).map(((e,t)=>{if(void 0!==this.added_tokens.find((t=>t.content===e)))return e;{if(!0===this.remove_space&&(e=e.trim().split(/\s+/).join(" ")),this.do_lowercase_and_remove_accent&&(e=function(e){return g(e.toLowerCase())}(e)),null!==this.normalizer&&(e=this.normalizer(e)),0===e.length)return[];const r=null!==this.pre_tokenizer?this.pre_tokenizer(e,{section_index:t}):[e];return this.model(r)}})).flat();return t}_encode_plus(e,{text_pair:t=null,add_special_tokens:r=!0,return_token_type_ids:n=null}={}){const{tokens:o,token_type_ids:s}=this._tokenize_helper(e,{pair:t,add_special_tokens:r}),a=this.model.convert_tokens_to_ids(o),i={input_ids:a,attention_mask:new Array(a.length).fill(1)};return(n??this.return_token_type_ids)&&s&&(i.token_type_ids=s),i}_tokenize_helper(e,{pair:t=null,add_special_tokens:r=!1}={}){const n=this._encode_text(e),s=this._encode_text(t);return this.post_processor?this.post_processor(n,s,{add_special_tokens:r}):{tokens:(0,o.mergeArrays)(n??[],s??[])}}tokenize(e,{pair:t=null,add_special_tokens:r=!1}={}){return this._tokenize_helper(e,{pair:t,add_special_tokens:r}).tokens}encode(e,{text_pair:t=null,add_special_tokens:r=!0,return_token_type_ids:n=null}={}){return this._encode_plus(e,{text_pair:t,add_special_tokens:r,return_token_type_ids:n}).input_ids}batch_decode(e,t={}){return e instanceof i.Tensor&&(e=e.tolist()),e.map((e=>this.decode(e,t)))}decode(e,t={}){if(e instanceof i.Tensor&&(e=_(e)),!Array.isArray(e)||0===e.length||!(0,o.isIntegralNumber)(e[0]))throw Error("token_ids must be a non-empty array of integers.");return this.decode_single(e,t)}decode_single(e,{skip_special_tokens:t=!1,clean_up_tokenization_spaces:r=null}){let n=this.model.convert_ids_to_tokens(e);t&&(n=n.filter((e=>!this.special_tokens.includes(e))));let o=this.decoder?this.decoder(n):n.join(" ");return this.decoder&&this.decoder.end_of_word_suffix&&(o=o.replaceAll(this.decoder.end_of_word_suffix," "),t&&(o=o.trim())),(r??this.clean_up_tokenization_spaces)&&(o=f(o)),o}get_chat_template({chat_template:e=null,tools:t=null}={}){if(this.chat_template&&"object"==typeof this.chat_template){const r=this.chat_template;if(null!==e&&Object.hasOwn(r,e))e=r[e];else if(null===e)if(null!==t&&"tool_use"in r)e=r.tool_use;else{if(!("default"in r))throw Error(`This model has multiple chat templates with no default specified! Please either pass a chat template or the name of the template you wish to use to the 'chat_template' argument. Available template names are ${Object.keys(r).sort()}.`);e=r.default}}else if(null===e){if(!this.chat_template)throw Error("Cannot use apply_chat_template() because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating");e=this.chat_template}return e}apply_chat_template(e,{tools:t=null,documents:r=null,chat_template:n=null,add_generation_prompt:o=!1,tokenize:s=!0,padding:a=!1,truncation:i=!1,max_length:l=null,return_tensor:d=!0,return_dict:u=!1,tokenizer_kwargs:p={},...h}={}){if("string"!=typeof(n=this.get_chat_template({chat_template:n,tools:t})))throw Error("chat_template must be a string, but got "+typeof n);let m=this._compiled_template_cache.get(n);void 0===m&&(m=new c.Template(n),this._compiled_template_cache.set(n,m));const _=Object.create(null);for(const e of ge){const t=this.getToken(e);t&&(_[e]=t)}const f=m.render({messages:e,add_generation_prompt:o,tools:t,documents:r,..._,...h});if(s){const e=this._call(f,{add_special_tokens:!1,padding:a,truncation:i,max_length:l,return_tensor:d,...p});return u?e:e.input_ids}return f}}class be extends Te{return_token_type_ids=!0}class xe extends Te{return_token_type_ids=!0}class ke extends Te{return_token_type_ids=!0}class ye extends Te{return_token_type_ids=!0}class Fe extends Te{return_token_type_ids=!0}class Pe extends Te{return_token_type_ids=!0}class Ce extends Te{return_token_type_ids=!0}class ve extends Te{return_token_type_ids=!0}class Se extends Te{return_token_type_ids=!0}class Ae extends Te{}class Ee extends Te{}class Le extends Te{return_token_type_ids=!0;constructor(e,t){super(e,t),console.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}}class ze extends Te{return_token_type_ids=!0}class Ie extends Te{}class Be extends Te{}class Ne extends Te{}class Oe extends Te{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.special_tokens.filter((e=>this.languageRegex.test(e))),this.lang_to_token=e=>e}_build_translation_inputs(e,t,r){return Ke(this,e,t,r)}}class De extends Oe{}class Ve extends Te{}class je extends Te{constructor(e,t){const r=".,!?…。,、।۔،",n=e.pre_tokenizer?.pretokenizers[0]?.pattern;n&&n.Regex===` ?[^(\\s|[${r}])]+`&&(n.Regex=` ?[^\\s${r}]+`),super(e,t)}}const Re="▁";class Ge extends Te{padding_side="left";constructor(e,t){super(e,t),this.legacy=t.legacy??!0,this.legacy||(this.normalizer=null,this.pre_tokenizer=new de({replacement:Re,add_prefix_space:!0,prepend_scheme:"first"}))}_encode_text(e){if(null===e)return null;if(this.legacy||0===e.length)return super._encode_text(e);let t=super._encode_text(Re+e.replaceAll(Re," "));return t.length>1&&t[0]===Re&&this.special_tokens.includes(t[1])&&(t=t.slice(1)),t}}class qe extends Te{}class $e extends Te{}class We extends Te{}class Ue extends Te{}class Xe extends Te{}class Qe extends Te{}class He extends Te{}class Ye extends Te{}class Je extends Te{}function Ke(e,t,r,n){if(!("language_codes"in e)||!Array.isArray(e.language_codes))throw new Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!("languageRegex"in e&&e.languageRegex instanceof RegExp))throw new Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!("lang_to_token"in e)||"function"!=typeof e.lang_to_token)throw new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");const o=n.src_lang,s=n.tgt_lang;if(!e.language_codes.includes(s))throw new Error(`Target language code "${s}" is not valid. Must be one of: {${e.language_codes.join(", ")}}`);if(void 0!==o){if(!e.language_codes.includes(o))throw new Error(`Source language code "${o}" is not valid. Must be one of: {${e.language_codes.join(", ")}}`);for(const t of e.post_processor.config.single)if("SpecialToken"in t&&e.languageRegex.test(t.SpecialToken.id)){t.SpecialToken.id=e.lang_to_token(o);break}}return n.forced_bos_token_id=e.model.convert_tokens_to_ids([e.lang_to_token(s)])[0],e._call(t,r)}class Ze extends Te{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.special_tokens.filter((e=>this.languageRegex.test(e))),this.lang_to_token=e=>e}_build_translation_inputs(e,t,r){return Ke(this,e,t,r)}}class et extends Te{constructor(e,t){super(e,t),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.special_tokens.filter((e=>this.languageRegex.test(e))).map((e=>e.slice(2,-2))),this.lang_to_token=e=>`__${e}__`}_build_translation_inputs(e,t,r){return Ke(this,e,t,r)}}class tt extends Te{get timestamp_begin(){return this.model.convert_tokens_to_ids(["<|notimestamps|>"])[0]+1}_decode_asr(e,{return_timestamps:t=!1,return_language:r=!1,time_precision:n=null,force_full_sequences:o=!0}={}){if(null===n)throw Error("Must specify time_precision");let s=null;const i="word"===t;function l(){return{language:s,timestamp:[null,null],text:""}}const c=[];let u=l(),p=0;const h=this.timestamp_begin;let m=[],_=[],f=!1,g=null;const M=new Set(this.all_special_ids);for(const r of e){const e=r.tokens,o=i?r.token_timestamps:null;let w=null,b=h;if("stride"in r){const[t,o,s]=r.stride;if(p-=o,g=t-s,o&&(b=o/n+h),s)for(let t=e.length-1;t>=0;--t){const r=Number(e[t]);if(r>=h){if(null!==w&&(r-h)*n<g)break;w=r}}}let x=[],k=[];for(let r=0;r<e.length;++r){const g=Number(e[r]);if(M.has(g)){const e=this.decode([g]),r=d.WHISPER_LANGUAGE_MAPPING.get(e.slice(2,-2));if(void 0!==r){if(null!==s&&r!==s&&!t){m.push(x);const e=this.findLongestCommonSequence(m)[0],t=this.decode(e);u.text=t,c.push(u),m=[],x=[],u=l()}s=u.language=r}}else if(g>=h){const e=(g-h)*n+p,t=(0,a.round)(e,2);if(null!==w&&g>=w)f=!0;else if(f||m.length>0&&g<b)f=!1;else if(null===u.timestamp[0])u.timestamp[0]=t;else if(t===u.timestamp[0]);else{u.timestamp[1]=t,m.push(x),i&&_.push(k);const[e,r]=this.findLongestCommonSequence(m,_),n=this.decode(e);u.text=n,i&&(u.words=this.collateWordTimestamps(e,r,s)),c.push(u),m=[],x=[],_=[],k=[],u=l()}}else if(x.push(g),i){let e,t=(0,a.round)(o[r]+p,2);if(r+1<o.length){e=(0,a.round)(o[r+1]+p,2);const s=this.decode([g]);T.test(s)&&(e=(0,a.round)(Math.min(t+n,e),2))}else e=null;k.push([t,e])}}if("stride"in r){const[e,t,n]=r.stride;p+=e-n}x.length>0?(m.push(x),i&&_.push(k)):m.every((e=>0===e.length))&&(u=l(),m=[],x=[],_=[],k=[])}if(m.length>0){if(o&&t)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");const[e,r]=this.findLongestCommonSequence(m,_),n=this.decode(e);u.text=n,i&&(u.words=this.collateWordTimestamps(e,r,s)),c.push(u)}let w=Object.create(null);const b=c.map((e=>e.text)).join("");if(t||r){for(let e=0;e<c.length;++e){const n=c[e];t||delete n.timestamp,r||delete n.language}if(i){const e=[];for(const t of c)for(const r of t.words)e.push(r);w={chunks:e}}else w={chunks:c}}return[b,w]}findLongestCommonSequence(e,t=null){let r=e[0],n=r.length,o=[];const s=Array.isArray(t)&&t.length>0;let a=s?[]:null,i=s?t[0]:null;for(let l=1;l<e.length;++l){const c=e[l];let d=0,u=[n,n,0,0];const p=c.length;for(let e=1;e<n+p;++e){const o=Math.max(0,n-e),a=Math.min(n,n+p-e),h=r.slice(o,a),m=Math.max(0,e-n),_=Math.min(p,e),f=c.slice(m,_);if(h.length!==f.length)throw new Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");let g;g=s?h.filter(((e,r)=>e===f[r]&&i[o+r]<=t[l][m+r])).length:h.filter(((e,t)=>e===f[t])).length;const M=g/e+e/1e4;g>1&&M>d&&(d=M,u=[o,a,m,_])}const[h,m,_,f]=u,g=Math.floor((m+h)/2),M=Math.floor((f+_)/2);o.push(...r.slice(0,g)),r=c.slice(M),n=r.length,s&&(a.push(...i.slice(0,g)),i=t[l].slice(M))}return o.push(...r),s?(a.push(...i),[o,a]):[o,[]]}collateWordTimestamps(e,t,r){const[n,o,s]=this.combineTokensIntoWords(e,r),a=[];for(let e=0;e<n.length;++e){const r=s[e];a.push({text:n[e],timestamp:[t[r.at(0)][0],t[r.at(-1)][1]]})}return a}combineTokensIntoWords(e,t,r="\"'“¡¿([{-",n="\"'.。,,!!??::”)]}、"){let o,s,a;return["chinese","japanese","thai","lao","myanmar"].includes(t=t??"english")?[o,s,a]=this.splitTokensOnUnicode(e):[o,s,a]=this.splitTokensOnSpaces(e),this.mergePunctuations(o,s,a,r,n)}decode(e,t){let r;return t?.decode_with_timestamps?(e instanceof i.Tensor&&(e=_(e)),r=this.decodeWithTimestamps(e,t)):r=super.decode(e,t),r}decodeWithTimestamps(e,t){const r=t?.time_precision??.02,n=Array.from(this.all_special_ids).at(-1)+1;let o=[[]];for(let t of e)if(t=Number(t),t>=n){const e=((t-n)*r).toFixed(2);o.push(`<|${e}|>`),o.push([])}else o[o.length-1].push(t);return o=o.map((e=>"string"==typeof e?e:super.decode(e,t))),o.join("")}splitTokensOnUnicode(e){const t=this.decode(e,{decode_with_timestamps:!0}),r=[],n=[],o=[];let s=[],a=[],i=0;for(let l=0;l<e.length;++l){const c=e[l];s.push(c),a.push(l);const d=this.decode(s,{decode_with_timestamps:!0});d.includes("�")&&"�"!==t[i+d.indexOf("�")]||(r.push(d),n.push(s),o.push(a),s=[],a=[],i+=d.length)}return[r,n,o]}splitTokensOnSpaces(e){const[t,r,n]=this.splitTokensOnUnicode(e),o=[],s=[],a=[],i=new RegExp(`^[${w}]$`,"gu");for(let e=0;e<t.length;++e){const l=t[e],c=r[e],d=n[e],u=c[0]>=this.model.tokens_to_ids.get("<|endoftext|>"),p=l.startsWith(" "),h=l.trim(),m=i.test(h);if(u||p||m||0===o.length)o.push(l),s.push(c),a.push(d);else{const e=o.length-1;o[e]+=l,s[e].push(...c),a[e].push(...d)}}return[o,s,a]}mergePunctuations(e,t,r,n,s){const a=structuredClone(e),i=structuredClone(t),l=structuredClone(r);let c=a.length-2,d=a.length-1;for(;c>=0;)a[c].startsWith(" ")&&n.includes(a[c].trim())?(a[d]=a[c]+a[d],i[d]=(0,o.mergeArrays)(i[c],i[d]),l[d]=(0,o.mergeArrays)(l[c],l[d]),a[c]="",i[c]=[],l[c]=[]):d=c,--c;for(c=0,d=1;d<a.length;)!a[c].endsWith(" ")&&s.includes(a[d])?(a[c]+=a[d],i[c]=(0,o.mergeArrays)(i[c],i[d]),l[c]=(0,o.mergeArrays)(l[c],l[d]),a[d]="",i[d]=[],l[d]=[]):c=d,++d;return[a.filter((e=>e)),i.filter((e=>e.length>0)),l.filter((e=>e.length>0))]}get_decoder_prompt_ids({language:e=null,task:t=null,no_timestamps:r=!0}={}){const n=[];if(e){const t=(0,d.whisper_language_to_code)(e),r=this.model.tokens_to_ids.get(`<|${t}|>`);if(void 0===r)throw new Error(`Unable to find language "${t}" in model vocabulary. Please report this issue at ${u.GITHUB_ISSUE_URL}.`);n.push(r)}else n.push(null);if(t){if("transcribe"!==(t=t.toLowerCase())&&"translate"!==t)throw new Error(`Task "${t}" is not supported. Must be one of: ["transcribe", "translate"]`);const e=this.model.tokens_to_ids.get(`<|${t}|>`);if(void 0===e)throw new Error(`Unable to find task "${t}" in model vocabulary. Please report this issue at ${u.GITHUB_ISSUE_URL}.`);n.push(e)}else n.push(null);if(r){const e=this.model.tokens_to_ids.get("<|notimestamps|>");if(void 0===e)throw new Error(`Unable to find "<|notimestamps|>" in model vocabulary. Please report this issue at ${u.GITHUB_ISSUE_URL}.`);n.push(e)}return n.map(((e,t)=>[t+1,e])).filter((e=>null!==e[1]))}}class rt extends Te{}class nt extends Te{}class ot extends Te{}class st extends Te{constructor(e,t){super(e,t),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=this.model.vocab.filter((e=>this.languageRegex.test(e))),console.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(e){if(null===e)return null;const[t,...r]=e.trim().split(this.languageRegex);if(0===r.length)return super._encode_text(t);if(2===r.length){const[e,t]=r;return this.supported_language_codes.includes(e)||console.warn(`Unsupported language code "${e}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),(0,o.mergeArrays)([e],super._encode_text(t))}}}class at extends Te{}class it extends Te{}class lt extends Te{}class ct extends Te{}class dt extends Te{}class ut extends Te{constructor(e,t){super(e,t),this.decoder=new ce({})}}class pt extends Te{}class ht{static TOKENIZER_CLASS_MAPPING={T5Tokenizer:Ie,DistilBertTokenizer:Ae,CamembertTokenizer:Ee,DebertaTokenizer:Fe,DebertaV2Tokenizer:Pe,BertTokenizer:be,HerbertTokenizer:Ce,ConvBertTokenizer:ve,RoFormerTokenizer:Se,XLMTokenizer:Le,ElectraTokenizer:ze,MobileBertTokenizer:ke,SqueezeBertTokenizer:ye,AlbertTokenizer:xe,GPT2Tokenizer:Be,BartTokenizer:Ne,MBartTokenizer:Oe,MBart50Tokenizer:De,RobertaTokenizer:Ve,WhisperTokenizer:tt,CodeGenTokenizer:rt,CLIPTokenizer:nt,SiglipTokenizer:ot,MarianTokenizer:st,BloomTokenizer:je,NllbTokenizer:Ze,M2M100Tokenizer:et,LlamaTokenizer:Ge,CodeLlamaTokenizer:qe,XLMRobertaTokenizer:$e,MPNetTokenizer:We,FalconTokenizer:Ue,GPTNeoXTokenizer:Xe,EsmTokenizer:Qe,Wav2Vec2CTCTokenizer:at,BlenderbotTokenizer:it,BlenderbotSmallTokenizer:lt,SpeechT5Tokenizer:ct,NougatTokenizer:dt,VitsTokenizer:ut,Qwen2Tokenizer:He,GemmaTokenizer:Ye,Grok1Tokenizer:Je,CohereTokenizer:pt,PreTrainedTokenizer:Te};static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:s="main",legacy:a=null}={}){const[i,l]=await p(e,{progress_callback:t,config:r,cache_dir:n,local_files_only:o,revision:s,legacy:a}),c=l.tokenizer_class?.replace(/Fast$/,"")??"PreTrainedTokenizer";let d=this.TOKENIZER_CLASS_MAPPING[c];return d||(console.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),d=Te),new d(i,l)}}},"./src/utils/audio.js":
/*!****************************!*\
!*** ./src/utils/audio.js ***!
\****************************/(e,t,r)=>{r.r(t),r.d(t,{hamming:()=>d,hanning:()=>c,mel_filter_bank:()=>_,read_audio:()=>i,spectrogram:()=>g,window_function:()=>M});var n=r(/*! ./hub.js */"./src/utils/hub.js"),o=r(/*! ./maths.js */"./src/utils/maths.js"),s=r(/*! ./core.js */"./src/utils/core.js"),a=r(/*! ./tensor.js */"./src/utils/tensor.js");async function i(e,t){if("undefined"==typeof AudioContext)throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");const r=await(await(0,n.getFile)(e)).arrayBuffer(),o=new AudioContext({sampleRate:t});void 0===t&&console.warn(`No sampling rate provided, using default of ${o.sampleRate}Hz.`);const s=await o.decodeAudioData(r);let a;if(2===s.numberOfChannels){const e=Math.sqrt(2),t=s.getChannelData(0),r=s.getChannelData(1);a=new Float32Array(t.length);for(let n=0;n<s.length;++n)a[n]=e*(t[n]+r[n])/2}else a=s.getChannelData(0);return a}function l(e,t){if(e<1)return new Float64Array;if(1===e)return new Float64Array([1]);const r=1-t,n=2*Math.PI/(e-1),o=new Float64Array(e);for(let s=0;s<e;++s)o[s]=t-r*Math.cos(s*n);return o}function c(e){return l(e,.5)}function d(e){return l(e,.54)}const u={htk:e=>2595*Math.log10(1+e/700),kaldi:e=>1127*Math.log(1+e/700),slaney:(e,t=1e3,r=15,n=27/Math.log(6.4))=>e>=t?r+Math.log(e/t)*n:3*e/200};function p(e,t="htk"){const r=u[t];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return"number"==typeof e?r(e):e.map((e=>r(e)))}const h={htk:e=>700*(10**(e/2595)-1),kaldi:e=>700*(Math.exp(e/1127)-1),slaney:(e,t=1e3,r=15,n=Math.log(6.4)/27)=>e>=r?t*Math.exp(n*(e-r)):200*e/3};function m(e,t,r){const n=(t-e)/(r-1);return Float64Array.from({length:r},((t,r)=>e+n*r))}function _(e,t,r,n,o,s=null,a="htk",i=!1){if(null!==s&&"slaney"!==s)throw new Error('norm must be one of null or "slaney"');const l=m(p(r,a),p(n,a),t+2);let c,d=function(e,t="htk"){const r=h[t];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return"number"==typeof e?r(e):e.map((e=>r(e)))}(l,a);if(i){const t=o/(2*e);c=p(Float64Array.from({length:e},((e,r)=>r*t)),a),d=l}else c=m(0,Math.floor(o/2),e);const u=function(e,t){const r=Float64Array.from({length:t.length-1},((e,r)=>t[r+1]-t[r])),n=Array.from({length:e.length},(()=>new Array(t.length)));for(let r=0;r<e.length;++r){const o=n[r];for(let n=0;n<t.length;++n)o[n]=t[n]-e[r]}const o=t.length-2,s=Array.from({length:o},(()=>new Array(e.length)));for(let t=0;t<e.length;++t){const e=n[t];for(let n=0;n<o;++n){const o=-e[n]/r[n],a=e[n+2]/r[n+1];s[n][t]=Math.max(0,Math.min(o,a))}}return s}(c,d);if(null!==s&&"slaney"===s)for(let r=0;r<t;++r){const t=u[r],n=2/(d[r+2]-d[r]);for(let r=0;r<e;++r)t[r]*=n}return u}function f(e,t,r,n,s){if(r<=0)throw new Error("reference must be greater than zero");if(n<=0)throw new Error("min_value must be greater than zero");r=Math.max(n,r);const a=Math.log10(r);for(let r=0;r<e.length;++r)e[r]=t*Math.log10(Math.max(n,e[r])-a);if(null!==s){if(s<=0)throw new Error("db_range must be greater than zero");const t=(0,o.max)(e)[0]-s;for(let r=0;r<e.length;++r)e[r]=Math.max(e[r],t)}return e}async function g(e,t,r,n,{fft_length:i=null,power:l=1,center:c=!0,pad_mode:d="reflect",onesided:u=!0,preemphasis:p=null,mel_filters:h=null,mel_floor:m=1e-10,log_mel:_=null,reference:g=1,min_value:M=1e-10,db_range:w=null,remove_dc_offset:T=null,min_num_frames:b=null,max_num_frames:x=null,do_pad:k=!0,transpose:y=!1}={}){const F=t.length;if(null===i&&(i=r),r>i)throw Error(`frame_length (${r}) may not be larger than fft_length (${i})`);if(F!==r)throw new Error(`Length of the window (${F}) must equal frame_length (${r})`);if(n<=0)throw new Error("hop_length must be greater than zero");if(null===l&&null!==h)throw new Error("You have provided `mel_filters` but `power` is `None`. Mel spectrogram computation is not yet supported for complex-valued spectrogram. Specify `power` to fix this issue.");if(c){if("reflect"!==d)throw new Error(`pad_mode="${d}" not implemented yet.`);const t=Math.floor((i-1)/2)+1;e=function(e,t,r){const n=new e.constructor(e.length+t+r),o=e.length-1;for(let r=0;r<e.length;++r)n[t+r]=e[r];for(let r=1;r<=t;++r)n[t-r]=e[(0,s.calculateReflectOffset)(r,o)];for(let a=1;a<=r;++a)n[o+t+a]=e[(0,s.calculateReflectOffset)(o-a,o)];return n}(e,t,t)}let P=Math.floor(1+Math.floor((e.length-r)/n));null!==b&&P<b&&(P=b);const C=u?Math.floor(i/2)+1:i;let v=P,S=P;null!==x&&(x>P?k&&(S=x):S=v=x);const A=new o.FFT(i),E=new Float64Array(i),L=new Float64Array(A.outputBufferSize),z=new Float32Array(C*S);for(let o=0;o<v;++o){const s=o*n,a=Math.min(e.length-s,r);a!==r&&E.fill(0,0,r);for(let t=0;t<a;++t)E[t]=e[s+t];if(T){let e=0;for(let t=0;t<a;++t)e+=E[t];const t=e/a;for(let e=0;e<a;++e)E[e]-=t}if(null!==p){for(let e=a-1;e>=1;--e)E[e]-=p*E[e-1];E[0]*=1-p}for(let e=0;e<t.length;++e)E[e]*=t[e];A.realTransform(L,E);for(let e=0;e<C;++e){const t=e<<1;z[e*S+o]=L[t]**2+L[t+1]**2}}if(null!==l&&2!==l){const e=2/l;for(let t=0;t<z.length;++t)z[t]**=e}const I=h.length;let B=await(0,a.matmul)(new a.Tensor("float32",h.flat(),[I,C]),new a.Tensor("float32",z,[C,S]));y&&(B=B.transpose(1,0));const N=B.data;for(let e=0;e<N.length;++e)N[e]=Math.max(m,N[e]);if(null!==l&&null!==_){const e=Math.min(N.length,v*I);switch(_){case"log":for(let t=0;t<e;++t)N[t]=Math.log(N[t]);break;case"log10":for(let t=0;t<e;++t)N[t]=Math.log10(N[t]);break;case"dB":if(1===l)!function(e,t=1,r=1e-5,n=null){f(e,20,t,r,n)}(N,g,M,w);else{if(2!==l)throw new Error(`Cannot use log_mel option '${_}' with power ${l}`);!function(e,t=1,r=1e-10,n=null){f(e,10,t,r,n)}(N,g,M,w)}break;default:throw new Error(`log_mel must be one of null, 'log', 'log10' or 'dB'. Got '${_}'`)}}return B}function M(e,t,{periodic:r=!0,frame_length:n=null,center:o=!0}={}){const s=r?e+1:e;let a;switch(t){case"boxcar":a=new Float64Array(s).fill(1);break;case"hann":case"hann_window":a=c(s);break;case"hamming":a=d(s);break;case"povey":a=c(s).map((e=>Math.pow(e,.85)));break;default:throw new Error(`Unknown window type ${t}.`)}if(r&&(a=a.subarray(0,e)),null===n)return a;if(e>n)throw new Error(`Length of the window (${e}) may not be larger than frame_length (${n})`);return a}},"./src/utils/constants.js":
/*!********************************!*\
!*** ./src/utils/constants.js ***!
\********************************/(e,t,r)=>{r.r(t),r.d(t,{GITHUB_ISSUE_URL:()=>n});const n="https://github.com/xenova/transformers.js/issues/new/choose"},"./src/utils/core.js":
/*!***************************!*\
!*** ./src/utils/core.js ***!
\***************************/(e,t,r)=>{function n(e,t){e&&e(t)}function o(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[t,e])))}function s(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function a(e){return"TypedArray"===e?.prototype?.__proto__?.constructor?.name}function i(e){return Number.isInteger(e)||"bigint"==typeof e}function l(e){const t=[];let r=e;for(;Array.isArray(r);)t.push(r.length),r=r[0];return t}function c(e,t,r=void 0){const n=e[t];if(void 0!==n)return delete e[t],n;if(void 0===r)throw Error(`Key ${t} does not exist in object.`);return r}function d(...e){return Array.prototype.concat.apply([],e)}function u(...e){return e.reduce(((e,t)=>e.flatMap((e=>t.map((t=>[e,t]))))))}function p(e,t){return Math.abs((e+t)%(2*t)-t)}function h(e,t){return Object.assign({},...t.map((t=>{if(void 0!==e[t])return{[t]:e[t]}})))}function m(e){let t=0;for(const r of e)++t;return t}r.r(t),r.d(t,{calculateDimensions:()=>l,calculateReflectOffset:()=>p,dispatchCallback:()=>n,escapeRegExp:()=>s,isIntegralNumber:()=>i,isTypedArray:()=>a,len:()=>m,mergeArrays:()=>d,pick:()=>h,pop:()=>c,product:()=>u,reverseDictionary:()=>o})},"./src/utils/data-structures.js":
/*!**************************************!*\
!*** ./src/utils/data-structures.js ***!
\**************************************/(e,t,r)=>{r.r(t),r.d(t,{CharTrie:()=>o,PriorityQueue:()=>n,TokenLattice:()=>a});class n{constructor(e=(e,t)=>e>t,t=1/0){this._heap=[],this._comparator=e,this._maxSize=t}get size(){return this._heap.length}isEmpty(){return 0===this.size}peek(){return this._heap[0]}push(...e){return this.extend(e)}extend(e){for(const t of e)if(this.size<this._maxSize)this._heap.push(t),this._siftUp();else{const e=this._smallest();this._comparator(t,this._heap[e])&&(this._heap[e]=t,this._siftUpFrom(e))}return this.size}pop(){const e=this.peek(),t=this.size-1;return t>0&&this._swap(0,t),this._heap.pop(),this._siftDown(),e}replace(e){const t=this.peek();return this._heap[0]=e,this._siftDown(),t}_parent(e){return(e+1>>>1)-1}_left(e){return 1+(e<<1)}_right(e){return e+1<<1}_greater(e,t){return this._comparator(this._heap[e],this._heap[t])}_swap(e,t){const r=this._heap[e];this._heap[e]=this._heap[t],this._heap[t]=r}_siftUp(){this._siftUpFrom(this.size-1)}_siftUpFrom(e){for(;e>0&&this._greater(e,this._parent(e));)this._swap(e,this._parent(e)),e=this._parent(e)}_siftDown(){let e=0;for(;this._left(e)<this.size&&this._greater(this._left(e),e)||this._right(e)<this.size&&this._greater(this._right(e),e);){const t=this._right(e)<this.size&&this._greater(this._right(e),this._left(e))?this._right(e):this._left(e);this._swap(e,t),e=t}}_smallest(){return 2**Math.floor(Math.log2(this.size))-1}}class o{constructor(){this.root=s.default()}extend(e){for(const t of e)this.push(t)}push(e){let t=this.root;for(const r of e){let e=t.children.get(r);void 0===e&&(e=s.default(),t.children.set(r,e)),t=e}t.isLeaf=!0}*commonPrefixSearch(e){let t=this.root;if(void 0===t)return;let r="";for(const n of e){if(r+=n,t=t.children.get(n),void 0===t)return;t.isLeaf&&(yield r)}}}class s{constructor(e,t){this.isLeaf=e,this.children=t}static default(){return new s(!1,new Map)}}class a{constructor(e,t,r){this.chars=Array.from(e),this.len=this.chars.length,this.bosTokenId=t,this.eosTokenId=r,this.nodes=[],this.beginNodes=Array.from({length:this.len+1},(()=>[])),this.endNodes=Array.from({length:this.len+1},(()=>[]));const n=new i(this.bosTokenId,0,0,0,0),o=new i(this.eosTokenId,1,this.len,0,0);this.nodes.push(n.clone()),this.nodes.push(o.clone()),this.beginNodes[this.len].push(o),this.endNodes[0].push(n)}insert(e,t,r,n){const o=this.nodes.length,s=new i(n,o,e,t,r);this.beginNodes[e].push(s),this.endNodes[e+t].push(s),this.nodes.push(s)}viterbi(){const e=this.len;let t=0;for(;t<=e;){if(0==this.beginNodes[t].length)return[];for(let e of this.beginNodes[t]){e.prev=null;let r=0,n=null;for(let o of this.endNodes[t]){const t=o.backtraceScore+e.score;(null===n||t>r)&&(n=o.clone(),r=t)}if(null===n)return[];e.prev=n,e.backtraceScore=r}++t}const r=[],n=this.beginNodes[e][0].prev;if(null===n)return[];let o=n.clone();for(;null!==o.prev;){r.push(o.clone());const e=o.clone();o=e.prev.clone()}return r.reverse(),r}piece(e){return this.chars.slice(e.pos,e.pos+e.length).join("")}tokens(){return this.viterbi().map((e=>this.piece(e)))}tokenIds(){return this.viterbi().map((e=>e.tokenId))}}class i{constructor(e,t,r,n,o){this.tokenId=e,this.nodeId=t,this.pos=r,this.length=n,this.score=o,this.prev=null,this.backtraceScore=0}clone(){const e=new i(this.tokenId,this.nodeId,this.pos,this.length,this.score);return e.prev=this.prev,e.backtraceScore=this.backtraceScore,e}}},"./src/utils/devices.js":
/*!******************************!*\
!*** ./src/utils/devices.js ***!
\******************************/(e,t,r)=>{r.r(t),r.d(t,{DEVICE_TYPES:()=>n});const n=Object.freeze({auto:"auto",gpu:"gpu",cpu:"cpu",wasm:"wasm",webgpu:"webgpu",cuda:"cuda",dml:"dml",webnn:"webnn","webnn-npu":"webnn-npu","webnn-gpu":"webnn-gpu","webnn-cpu":"webnn-cpu"})},"./src/utils/dtypes.js":
/*!*****************************!*\
!*** ./src/utils/dtypes.js ***!
\*****************************/(e,t,r)=>{r.r(t),r.d(t,{DATA_TYPES:()=>a,DEFAULT_DEVICE_DTYPE_MAPPING:()=>i,DEFAULT_DTYPE_SUFFIX_MAPPING:()=>l,isWebGpuFp16Supported:()=>s});var n=r(/*! ../env.js */"./src/env.js"),o=r(/*! ./devices.js */"./src/utils/devices.js");const s=function(){let e;return async function(){if(void 0===e)if(n.apis.IS_WEBGPU_AVAILABLE)try{const t=await navigator.gpu.requestAdapter();e=t.features.has("shader-f16")}catch(t){e=!1}else e=!1;return e}}(),a=Object.freeze({fp32:"fp32",fp16:"fp16",q8:"q8",int8:"int8",uint8:"uint8",q4:"q4",bnb4:"bnb4",q4f16:"q4f16"}),i=Object.freeze({[o.DEVICE_TYPES.wasm]:a.q8}),l=Object.freeze({[a.fp32]:"",[a.fp16]:"_fp16",[a.int8]:"_int8",[a.uint8]:"_uint8",[a.q8]:"_quantized",[a.q4]:"_q4",[a.q4f16]:"_q4f16",[a.bnb4]:"_bnb4"})},"./src/utils/generic.js":
/*!******************************!*\
!*** ./src/utils/generic.js ***!
\******************************/(e,t,r)=>{r.r(t),r.d(t,{Callable:()=>n});const n=class{constructor(){let e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}_call(...e){throw Error("Must implement _call method in subclass")}}},"./src/utils/hub.js":
/*!**************************!*\
!*** ./src/utils/hub.js ***!
\**************************/(e,t,r)=>{r.r(t),r.d(t,{getFile:()=>d,getModelFile:()=>h,getModelJSON:()=>m});var n=r(/*! fs */"?7a2c"),o=r(/*! path */"?a42a"),s=r(/*! ../env.js */"./src/env.js"),a=r(/*! ./core.js */"./src/utils/core.js");const i={txt:"text/plain",html:"text/html",css:"text/css",js:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif"};class l{constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=n.existsSync(e),this.exists){this.status=200,this.statusText="OK";let t=n.statSync(e);this.headers.set("content-length",t.size.toString()),this.updateContentType();let r=this;this.body=new ReadableStream({start(e){r.arrayBuffer().then((t=>{e.enqueue(new Uint8Array(t)),e.close()}))}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){const e=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",i[e]??"application/octet-stream")}clone(){let e=new l(this.filePath);return e.exists=this.exists,e.status=this.status,e.statusText=this.statusText,e.headers=new Headers(this.headers),e}async arrayBuffer(){return(await n.promises.readFile(this.filePath)).buffer}async blob(){const e=await n.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get("content-type")})}async text(){return await n.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}}function c(e,t=null,r=null){let n;try{n=new URL(e)}catch(e){return!1}return!(t&&!t.includes(n.protocol))&&!(r&&!r.includes(n.hostname))}async function d(e){if(s.env.useFS&&!c(e,["http:","https:","blob:"]))return new l(e);if("undefined"!=typeof process&&"node"===process?.release?.name){const t=!!process.env?.TESTING_REMOTELY,r=s.env.version,n=new Headers;n.set("User-Agent",`transformers.js/${r}; is_ci/${t};`);if(c(e,["http:","https:"],["huggingface.co","hf.co"])){const e=process.env?.HF_TOKEN??process.env?.HF_ACCESS_TOKEN;e&&n.set("Authorization",`Bearer ${e}`)}return fetch(e,{headers:n})}return fetch(e)}const u={400:"Bad request error occurred while trying to load file",401:"Unauthorized access to file",403:"Forbidden access to file",404:"Could not locate file",408:"Request timeout error occurred while trying to load file",500:"Internal server error error occurred while trying to load file",502:"Bad gateway error occurred while trying to load file",503:"Service unavailable error occurred while trying to load file",504:"Gateway timeout error occurred while trying to load file"};class p{constructor(e){this.path=e}async match(e){let t=o.join(this.path,e),r=new l(t);return r.exists?r:void 0}async put(e,t){const r=Buffer.from(await t.arrayBuffer());let s=o.join(this.path,e);try{await n.promises.mkdir(o.dirname(s),{recursive:!0}),await n.promises.writeFile(s,r)}catch(e){console.warn("An error occurred while writing the file to cache:",e)}}}async function h(e,t,r=!0,n={}){if(!s.env.allowLocalModels){if(n.local_files_only)throw Error("Invalid configuration detected: local models are disabled (`env.allowLocalModels=false`) but you have requested to only use local models (`local_files_only=true`).");if(!s.env.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}let o;if((0,a.dispatchCallback)(n.progress_callback,{status:"initiate",name:e,file:t}),!o&&s.env.useBrowserCache){if("undefined"==typeof caches)throw Error("Browser cache is not available in this environment.");try{o=await caches.open("transformers-cache")}catch(e){console.warn("An error occurred while opening the browser cache:",e)}}if(!o&&s.env.useFSCache&&(o=new p(n.cache_dir??s.env.cacheDir)),!o&&s.env.useCustomCache){if(!s.env.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!s.env.customCache.match||!s.env.customCache.put)throw new Error("`env.customCache` must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache");o=s.env.customCache}const i=n.revision??"main";let l,h,m=_(e,t),f=_(s.env.localModelPath,m),g=_(s.env.remoteHost,s.env.remotePathTemplate.replaceAll("{model}",e).replaceAll("{revision}",encodeURIComponent(i)),t),M="main"===i?m:_(e,i,t),w=o instanceof p?M:g,T=!1;o&&(h=await async function(e,...t){for(let r of t)try{let t=await e.match(r);if(t)return t}catch(e){continue}}(o,f,w));const b=void 0!==h;if(void 0===h){if(s.env.allowLocalModels){if(c(m,["http:","https:"])){if(n.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${m}.`);if(!s.env.allowRemoteModels)throw new Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${m}.`)}else try{h=await d(f),l=f}catch(e){console.warn(`Unable to load from local path "${f}": "${e}"`)}}if(void 0===h||404===h.status){if(n.local_files_only||!s.env.allowRemoteModels){if(r)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${f}".`);return null}if(h=await d(g),200!==h.status)return function(e,t,r){if(!r)return null;const n=u[e]??`Error (${e}) occurred while trying to load file`;throw Error(`${n}: "${t}".`)}(h.status,g,r);l=w}T=o&&"undefined"!=typeof Response&&h instanceof Response&&200===h.status}(0,a.dispatchCallback)(n.progress_callback,{status:"download",name:e,file:t});const x={status:"progress",name:e,file:t};let k;return n.progress_callback?b&&"undefined"!=typeof navigator&&/firefox/i.test(navigator.userAgent)?(k=new Uint8Array(await h.arrayBuffer()),(0,a.dispatchCallback)(n.progress_callback,{...x,progress:100,loaded:k.length,total:k.length})):k=await async function(e,t){const r=e.headers.get("Content-Length");null===r&&console.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let n=parseInt(r??"0"),o=new Uint8Array(n),s=0;const a=e.body.getReader();async function i(){const{done:e,value:r}=await a.read();if(e)return;let l=s+r.length;if(l>n){n=l;let e=new Uint8Array(n);e.set(o),o=e}o.set(r,s),s=l;return t({progress:s/n*100,loaded:s,total:n}),i()}return await i(),o}(h,(e=>{(0,a.dispatchCallback)(n.progress_callback,{...x,...e})})):k=new Uint8Array(await h.arrayBuffer()),T&&l&&void 0===await o.match(l)&&await o.put(l,new Response(k,{headers:h.headers})).catch((e=>{console.warn(`Unable to add response to browser cache: ${e}.`)})),(0,a.dispatchCallback)(n.progress_callback,{status:"done",name:e,file:t}),k}async function m(e,t,r=!0,n={}){let o=await h(e,t,r,n);if(null===o)return{};let s=new TextDecoder("utf-8").decode(o);return JSON.parse(s)}function _(...e){return(e=e.map(((t,r)=>(r&&(t=t.replace(new RegExp("^/"),"")),r!==e.length-1&&(t=t.replace(new RegExp("/$"),"")),t)))).join("/")}},"./src/utils/image.js":
/*!****************************!*\
!*** ./src/utils/image.js ***!
\****************************/(e,t,r)=>{r.r(t),r.d(t,{RawImage:()=>m});var n=r(/*! ./hub.js */"./src/utils/hub.js"),o=r(/*! ../env.js */"./src/env.js"),s=r(/*! ./tensor.js */"./src/utils/tensor.js"),a=r(/*! sharp */"?2b25");const i="undefined"!=typeof self,l=i&&"DedicatedWorkerGlobalScope"===self.constructor.name;let c,d,u;if(i)c=(e,t)=>{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this browser.");return new self.OffscreenCanvas(e,t)},u=self.createImageBitmap,d=self.ImageData;else{if(!a)throw new Error("Unable to load image processing library.");u=async e=>{const t=(await e.metadata()).channels,{data:r,info:n}=await e.rotate().raw().toBuffer({resolveWithObject:!0}),o=new m(new Uint8ClampedArray(r),n.width,n.height,n.channels);return void 0!==t&&t!==n.channels&&o.convert(t),o}}const p={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},h=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]);class m{constructor(e,t,r,n){this.data=e,this.width=t,this.height=r,this.channels=n}get size(){return[this.width,this.height]}static async read(e){if(e instanceof m)return e;if("string"==typeof e||e instanceof URL)return await this.fromURL(e);throw new Error("Unsupported input type: "+typeof e)}static fromCanvas(e){if(!i)throw new Error("fromCanvas() is only supported in browser environments.");const t=e.getContext("2d").getImageData(0,0,e.width,e.height).data;return new m(t,e.width,e.height,4)}static async fromURL(e){const t=await(0,n.getFile)(e);if(200!==t.status)throw new Error(`Unable to read image from "${e}" (${t.status} ${t.statusText})`);const r=await t.blob();return this.fromBlob(r)}static async fromBlob(e){if(i){const t=await u(e),r=c(t.width,t.height).getContext("2d");return r.drawImage(t,0,0),new this(r.getImageData(0,0,t.width,t.height).data,t.width,t.height,4)}{const t=a(await e.arrayBuffer());return await u(t)}}static fromTensor(e,t="CHW"){if(3!==e.dims.length)throw new Error(`Tensor should have 3 dimensions, but has ${e.dims.length} dimensions.`);if("CHW"===t)e=e.transpose(1,2,0);else if("HWC"!==t)throw new Error(`Unsupported channel format: ${t}`);if(!(e.data instanceof Uint8ClampedArray||e.data instanceof Uint8Array))throw new Error(`Unsupported tensor type: ${e.type}`);switch(e.dims[2]){case 1:case 2:case 3:case 4:return new m(e.data,e.dims[1],e.dims[0],e.dims[2]);default:throw new Error(`Unsupported number of channels: ${e.dims[2]}`)}}grayscale(){if(1===this.channels)return this;const e=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let t=0,r=0;t<this.data.length;t+=this.channels){const n=this.data[t],o=this.data[t+1],s=this.data[t+2];e[r++]=Math.round(.2989*n+.587*o+.114*s)}break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,1)}rgb(){if(3===this.channels)return this;const e=new Uint8ClampedArray(this.width*this.height*3);switch(this.channels){case 1:for(let t=0,r=0;t<this.data.length;++t)e[r++]=this.data[t],e[r++]=this.data[t],e[r++]=this.data[t];break;case 4:for(let t=0,r=0;t<this.data.length;t+=4)e[r++]=this.data[t],e[r++]=this.data[t+1],e[r++]=this.data[t+2];break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,3)}rgba(){if(4===this.channels)return this;const e=new Uint8ClampedArray(this.width*this.height*4);switch(this.channels){case 1:for(let t=0,r=0;t<this.data.length;++t)e[r++]=this.data[t],e[r++]=this.data[t],e[r++]=this.data[t],e[r++]=255;break;case 3:for(let t=0,r=0;t<this.data.length;t+=3)e[r++]=this.data[t],e[r++]=this.data[t+1],e[r++]=this.data[t+2],e[r++]=255;break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,4)}async resize(e,t,{resample:r=2}={}){let n=p[r]??r;if(i){const r=this.channels,n=this.toCanvas(),o=c(e,t).getContext("2d");o.drawImage(n,0,0,e,t);return new m(o.getImageData(0,0,e,t).data,e,t,4).convert(r)}{let r=this.toSharp();switch(n){case"box":case"hamming":"box"!==n&&"hamming"!==n||(console.warn(`Resampling method ${n} is not yet supported. Using bilinear instead.`),n="bilinear");case"nearest":case"bilinear":case"bicubic":r=r.affine([e/this.width,0,0,t/this.height],{interpolator:n});break;case"lanczos":r=r.resize({width:e,height:t,fit:"fill",kernel:"lanczos3"});break;default:throw new Error(`Resampling method ${n} is not supported.`)}return await u(r)}}async pad([e,t,r,n]){if(e=Math.max(e,0),t=Math.max(t,0),r=Math.max(r,0),n=Math.max(n,0),0===e&&0===t&&0===r&&0===n)return this;if(i){const o=this.channels,s=this.toCanvas(),a=this.width+e+t,i=this.height+r+n,l=c(a,i).getContext("2d");l.drawImage(s,0,0,this.width,this.height,e,r,a,i);return new m(l.getImageData(0,0,a,i).data,a,i,4).convert(o)}{const o=this.toSharp().extend({left:e,right:t,top:r,bottom:n});return await u(o)}}async crop([e,t,r,n]){if(e=Math.max(e,0),t=Math.max(t,0),r=Math.min(r,this.width-1),n=Math.min(n,this.height-1),0===e&&0===t&&r===this.width-1&&n===this.height-1)return this;const o=r-e+1,s=n-t+1;if(i){const r=this.channels,n=this.toCanvas(),a=c(o,s).getContext("2d");a.drawImage(n,e,t,o,s,0,0,o,s);return new m(a.getImageData(0,0,o,s).data,o,s,4).convert(r)}{const r=this.toSharp().extract({left:e,top:t,width:o,height:s});return await u(r)}}async center_crop(e,t){if(this.width===e&&this.height===t)return this;const r=(this.width-e)/2,n=(this.height-t)/2;if(i){const o=this.channels,s=this.toCanvas(),a=c(e,t).getContext("2d");let i=0,l=0,d=0,u=0;r>=0?i=r:d=-r,n>=0?l=n:u=-n,a.drawImage(s,i,l,e,t,d,u,e,t);return new m(a.getImageData(0,0,e,t).data,e,t,4).convert(o)}{let o=this.toSharp();if(r>=0&&n>=0)o=o.extract({left:Math.floor(r),top:Math.floor(n),width:e,height:t});else if(r<=0&&n<=0){const s=Math.floor(-n),a=Math.floor(-r);o=o.extend({top:s,left:a,right:e-this.width-a,bottom:t-this.height-s})}else{let s=[0,0],a=0;n<0?(s[0]=Math.floor(-n),s[1]=t-this.height-s[0]):a=Math.floor(n);let i=[0,0],l=0;r<0?(i[0]=Math.floor(-r),i[1]=e-this.width-i[0]):l=Math.floor(r),o=o.extend({top:s[0],bottom:s[1],left:i[0],right:i[1]}).extract({left:l,top:a,width:e,height:t})}return await u(o)}}async toBlob(e="image/png",t=1){if(!i)throw new Error("toBlob() is only supported in browser environments.");const r=this.toCanvas();return await r.convertToBlob({type:e,quality:t})}toTensor(e="CHW"){let t=new s.Tensor("uint8",new Uint8Array(this.data),[this.height,this.width,this.channels]);if("HWC"===e);else{if("CHW"!==e)throw new Error(`Unsupported channel format: ${e}`);t=t.permute(2,0,1)}return t}toCanvas(){if(!i)throw new Error("toCanvas() is only supported in browser environments.");const e=this.clone().rgba(),t=c(e.width,e.height),r=new d(e.data,e.width,e.height);return t.getContext("2d").putImageData(r,0,0),t}_update(e,t,r,n=null){return this.data=e,this.width=t,this.height=r,null!==n&&(this.channels=n),this}clone(){return new m(this.data.slice(),this.width,this.height,this.channels)}convert(e){if(this.channels===e)return this;switch(e){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(!i){if(o.env.useFS){const t=this.toSharp();return await t.toFile(e)}throw new Error("Unable to save the image because filesystem is disabled in this environment.")}{if(l)throw new Error("Unable to save an image from a Web Worker.");const t=e.split(".").pop().toLowerCase(),r=h.get(t)??"image/png",n=await this.toBlob(r),o=URL.createObjectURL(n),s=document.createElement("a");s.href=o,s.download=e,s.click(),s.remove()}}toSharp(){if(i)throw new Error("toSharp() is only supported in server-side environments.");return a(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}}},"./src/utils/maths.js":
/*!****************************!*\
!*** ./src/utils/maths.js ***!
\****************************/(e,t,r)=>{function n(e,[t,r,n],[o,s],a="bilinear",i=!1){const l=s/n,c=o/r,d=new e.constructor(o*s*t),u=r*n,p=o*s;for(let a=0;a<o;++a)for(let o=0;o<s;++o){const i=a*s+o,h=(o+.5)/l-.5,m=(a+.5)/c-.5;let _=Math.floor(h),f=Math.floor(m);const g=Math.min(_+1,n-1),M=Math.min(f+1,r-1);_=Math.max(_,0),f=Math.max(f,0);const w=h-_,T=m-f,b=(1-w)*(1-T),x=w*(1-T),k=(1-w)*T,y=w*T,F=f*n,P=M*n,C=F+_,v=F+g,S=P+_,A=P+g;for(let r=0;r<t;++r){const t=r*u;d[r*p+i]=b*e[t+C]+x*e[t+v]+k*e[t+S]+y*e[t+A]}}return d}function o(e,t,r){const n=new Array(r.length),o=new Array(r.length);for(let e=r.length-1,s=1;e>=0;--e)o[e]=s,n[e]=t[r[e]],s*=n[e];const s=r.map(((e,t)=>o[r.indexOf(t)])),a=new e.constructor(e.length);for(let r=0;r<e.length;++r){let n=0;for(let e=t.length-1,o=r;e>=0;--e)n+=o%t[e]*s[e],o=Math.floor(o/t[e]);a[n]=e[r]}return[a,n]}function s(e){const t=u(e)[0],r=e.map((e=>Math.exp(e-t))),n=r.reduce(((e,t)=>e+t),0);return r.map((e=>e/n))}function a(e){const t=u(e)[0];let r=0;for(let n=0;n<e.length;++n)r+=Math.exp(e[n]-t);const n=Math.log(r);return e.map((e=>e-t-n))}function i(e,t){let r=0;for(let n=0;n<e.length;++n)r+=e[n]*t[n];return r}function l(e,t){return i(e,t)/(c(e)*c(t))}function c(e){return Math.sqrt(e.reduce(((e,t)=>e+t*t),0))}function d(e){if(0===e.length)throw Error("Array must not be empty");let t=e[0],r=0;for(let n=1;n<e.length;++n)e[n]<t&&(t=e[n],r=n);return[t,r]}function u(e){if(0===e.length)throw Error("Array must not be empty");let t=e[0],r=0;for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n],r=n);return[Number(t),r]}function p(e){return e>0&&!(e&e-1)}r.r(t),r.d(t,{FFT:()=>_,bankers_round:()=>M,cos_sim:()=>l,dot:()=>i,dynamic_time_warping:()=>w,interpolate_data:()=>n,log_softmax:()=>a,magnitude:()=>c,max:()=>u,medianFilter:()=>f,min:()=>d,permute_data:()=>o,round:()=>g,softmax:()=>s});class h{constructor(e){if(this.size=0|e,this.size<=1||!p(this.size))throw new Error("FFT size must be a power of two larger than 1");this._csize=e<<1,this.table=new Float64Array(2*this.size);for(let e=0;e<this.table.length;e+=2){const t=Math.PI*e/this.size;this.table[e]=Math.cos(t),this.table[e+1]=-Math.sin(t)}let t=0;for(let e=1;this.size>e;e<<=1)++t;this._width=t%2==0?t-1:t,this._bitrev=new Int32Array(1<<this._width);for(let e=0;e<this._bitrev.length;++e){this._bitrev[e]=0;for(let t=0;t<this._width;t+=2){const r=this._width-t-2;this._bitrev[e]|=(e>>>t&3)<<r}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,t){const r=t||new Array(e.length>>>1);for(let t=0;t<e.length;t+=2)r[t>>>1]=e[t];return r}toComplexArray(e,t){const r=t||this.createComplexArray();for(let t=0;t<r.length;t+=2)r[t]=e[t>>>1],r[t+1]=0;return r}transform(e,t){if(e===t)throw new Error("Input and output buffers must be different");this._transform4(e,t,1)}realTransform(e,t){if(e===t)throw new Error("Input and output buffers must be different");this._realTransform4(e,t,1)}inverseTransform(e,t){if(e===t)throw new Error("Input and output buffers must be different");this._transform4(e,t,-1);for(let t=0;t<e.length;++t)e[t]/=this.size}_transform4(e,t,r){const n=this._csize;let o,s,a=1<<this._width,i=n/a<<1;const l=this._bitrev;if(4===i)for(o=0,s=0;o<n;o+=i,++s){const r=l[s];this._singleTransform2(t,e,o,r,a)}else for(o=0,s=0;o<n;o+=i,++s){const n=l[s];this._singleTransform4(t,e,o,n,a,r)}const c=this.table;for(a>>=2;a>=2;a>>=2){i=n/a<<1;const t=i>>>2;for(o=0;o<n;o+=i){const n=o+t-1;for(let s=o,i=0;s<n;s+=2,i+=a){const n=s,o=n+t,a=o+t,l=a+t,d=e[n],u=e[n+1],p=e[o],h=e[o+1],m=e[a],_=e[a+1],f=e[l],g=e[l+1],M=c[i],w=r*c[i+1],T=p*M-h*w,b=p*w+h*M,x=c[2*i],k=r*c[2*i+1],y=m*x-_*k,F=m*k+_*x,P=c[3*i],C=r*c[3*i+1],v=f*P-g*C,S=f*C+g*P,A=d+y,E=u+F,L=d-y,z=u-F,I=T+v,B=b+S,N=r*(T-v),O=r*(b-S);e[n]=A+I,e[n+1]=E+B,e[o]=L+O,e[o+1]=z-N,e[a]=A-I,e[a+1]=E-B,e[l]=L-O,e[l+1]=z+N}}}}_singleTransform2(e,t,r,n,o){const s=e[n],a=e[n+1],i=e[n+o],l=e[n+o+1];t[r]=s+i,t[r+1]=a+l,t[r+2]=s-i,t[r+3]=a-l}_singleTransform4(e,t,r,n,o,s){const a=2*o,i=3*o,l=e[n],c=e[n+1],d=e[n+o],u=e[n+o+1],p=e[n+a],h=e[n+a+1],m=e[n+i],_=e[n+i+1],f=l+p,g=c+h,M=l-p,w=c-h,T=d+m,b=u+_,x=s*(d-m),k=s*(u-_);t[r]=f+T,t[r+1]=g+b,t[r+2]=M+k,t[r+3]=w-x,t[r+4]=f-T,t[r+5]=g-b,t[r+6]=M-k,t[r+7]=w+x}_realTransform4(e,t,r){const n=this._csize;let o,s,a=1<<this._width,i=n/a<<1;const l=this._bitrev;if(4===i)for(o=0,s=0;o<n;o+=i,++s){const r=l[s];this._singleRealTransform2(t,e,o,r>>>1,a>>>1)}else for(o=0,s=0;o<n;o+=i,++s){const n=l[s];this._singleRealTransform4(t,e,o,n>>>1,a>>>1,r)}const c=this.table;for(a>>=2;a>=2;a>>=2){i=n/a<<1;const t=i>>>1,s=t>>>1,l=s>>>1;for(o=0;o<n;o+=i)for(let n=0,i=0;n<=l;n+=2,i+=a){const a=o+n,d=a+s,u=d+s,p=u+s,h=e[a],m=e[a+1],_=e[d],f=e[d+1],g=e[u],M=e[u+1],w=e[p],T=e[p+1],b=h,x=m,k=c[i],y=r*c[i+1],F=_*k-f*y,P=_*y+f*k,C=c[2*i],v=r*c[2*i+1],S=g*C-M*v,A=g*v+M*C,E=c[3*i],L=r*c[3*i+1],z=w*E-T*L,I=w*L+T*E,B=b+S,N=x+A,O=b-S,D=x-A,V=F+z,j=P+I,R=r*(F-z),G=r*(P-I);if(e[a]=B+V,e[a+1]=N+j,e[d]=O+G,e[d+1]=D-R,0===n){e[u]=B-V,e[u+1]=N-j;continue}if(n===l)continue;const q=o+s-n,$=o+t-n;e[q]=O-r*G,e[q+1]=-D-r*R,e[$]=B-r*V,e[$+1]=r*j-N}}const d=n>>>1;for(let t=2;t<d;t+=2)e[n-t]=e[t],e[n-t+1]=-e[t+1]}_singleRealTransform2(e,t,r,n,o){const s=e[n],a=e[n+o];t[r]=s+a,t[r+1]=0,t[r+2]=s-a,t[r+3]=0}_singleRealTransform4(e,t,r,n,o,s){const a=2*o,i=3*o,l=e[n],c=e[n+o],d=e[n+a],u=e[n+i],p=l+d,h=l-d,m=c+u,_=s*(c-u);t[r]=p+m,t[r+1]=0,t[r+2]=h,t[r+3]=-_,t[r+4]=p-m,t[r+5]=0,t[r+6]=h,t[r+7]=_}}class m{constructor(e){const t=2*(e-1),r=2*(2*e-1),n=2**Math.ceil(Math.log2(r));this.bufferSize=n,this._a=t;const o=new Float64Array(r),s=new Float64Array(n);this._chirpBuffer=new Float64Array(n),this._buffer1=new Float64Array(n),this._buffer2=new Float64Array(n),this._outBuffer1=new Float64Array(n),this._outBuffer2=new Float64Array(n);const a=-2*Math.PI/e,i=Math.cos(a),l=Math.sin(a);for(let t=0;t<r>>1;++t){const r=(t+1-e)**2/2,n=Math.sqrt(i**2+l**2)**r,a=r*Math.atan2(l,i),c=2*t;o[c]=n*Math.cos(a),o[c+1]=n*Math.sin(a),s[c]=o[c],s[c+1]=-o[c+1]}this._slicedChirpBuffer=o.subarray(t,r),this._f=new h(n>>1),this._f.transform(this._chirpBuffer,s)}_transform(e,t,r){const n=this._buffer1,o=this._buffer2,s=this._outBuffer1,a=this._outBuffer2,i=this._chirpBuffer,l=this._slicedChirpBuffer,c=this._a;if(r)for(let e=0;e<l.length;e+=2){const r=e+1,o=t[e>>1];n[e]=o*l[e],n[r]=o*l[r]}else for(let e=0;e<l.length;e+=2){const r=e+1;n[e]=t[e]*l[e]-t[r]*l[r],n[r]=t[e]*l[r]+t[r]*l[e]}this._f.transform(s,n);for(let e=0;e<i.length;e+=2){const t=e+1;o[e]=s[e]*i[e]-s[t]*i[t],o[t]=s[e]*i[t]+s[t]*i[e]}this._f.inverseTransform(a,o);for(let t=0;t<a.length;t+=2){const r=a[t+c],n=a[t+c+1],o=l[t],s=l[t+1];e[t]=r*o-n*s,e[t+1]=r*s+n*o}}transform(e,t){this._transform(e,t,!1)}realTransform(e,t){this._transform(e,t,!0)}}class _{constructor(e){this.fft_length=e,this.isPowerOfTwo=p(e),this.isPowerOfTwo?(this.fft=new h(e),this.outputBufferSize=2*e):(this.fft=new m(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,t){this.fft.realTransform(e,t)}transform(e,t){this.fft.transform(e,t)}}function f(e,t){if(t%2==0||t<=0)throw new Error("Window size must be a positive odd number");const r=new e.constructor(e.length),n=new e.constructor(t),o=Math.floor(t/2);for(let t=0;t<e.length;++t){let s=0;for(let r=-o;r<=o;++r){let o=t+r;o<0?o=Math.abs(o):o>=e.length&&(o=2*(e.length-1)-o),n[s++]=e[o]}n.sort(),r[t]=n[o]}return r}function g(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}function M(e){const t=Math.round(e);return Math.abs(e)%1==.5?t%2==0?t:t-1:t}function w(e){const t=e.length,r=e[0].length,n=[t+1,r+1],o=Array.from({length:n[0]},(()=>Array(n[1]).fill(1/0)));o[0][0]=0;const s=Array.from({length:n[0]},(()=>Array(n[1]).fill(-1)));for(let t=1;t<n[1];++t)for(let r=1;r<n[0];++r){const n=o[r-1][t-1],a=o[r-1][t],i=o[r][t-1];let l,c;n<a&&n<i?(l=n,c=0):a<n&&a<i?(l=a,c=1):(l=i,c=2),o[r][t]=e[r-1][t-1]+l,s[r][t]=c}for(let e=0;e<n[1];++e)s[0][e]=2;for(let e=0;e<n[0];++e)s[e][0]=1;let a=t,i=r,l=[],c=[];for(;a>0||i>0;)switch(l.push(a-1),c.push(i-1),s[a][i]){case 0:--a,--i;break;case 1:--a;break;case 2:--i;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${a}, ${i}]. Please file a bug report.`)}return l.reverse(),c.reverse(),[l,c]}},"./src/utils/tensor.js":
/*!*****************************!*\
!*** ./src/utils/tensor.js ***!
\*****************************/(e,t,r)=>{r.r(t),r.d(t,{Tensor:()=>i,cat:()=>w,full:()=>y,full_like:()=>F,interpolate:()=>c,interpolate_4d:()=>d,layer_norm:()=>_,matmul:()=>u,mean:()=>x,mean_pooling:()=>m,ones:()=>P,ones_like:()=>C,permute:()=>l,quantize_embeddings:()=>A,rfft:()=>p,stack:()=>T,std_mean:()=>b,topk:()=>h,zeros:()=>v,zeros_like:()=>S});var n=r(/*! ./maths.js */"./src/utils/maths.js"),o=r(/*! ../backends/onnx.js */"./src/backends/onnx.js"),s=r(/*! ../ops/registry.js */"./src/ops/registry.js");const a=Object.freeze({float32:Float32Array,float16:Uint16Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array});class i{get dims(){return this.ort_tensor.dims}set dims(e){this.ort_tensor.dims=e}get type(){return this.ort_tensor.type}get data(){return this.ort_tensor.data}get size(){return this.ort_tensor.size}get location(){return this.ort_tensor.location}ort_tensor;constructor(...e){return(0,o.isONNXTensor)(e[0])?this.ort_tensor=e[0]:this.ort_tensor=new o.Tensor(e[0],e[1],e[2]),new Proxy(this,{get:(e,t)=>{if("string"==typeof t){let r=Number(t);if(Number.isInteger(r))return e._getitem(r)}return e[t]},set:(e,t,r)=>e[t]=r})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){const[e,...t]=this.dims;if(t.length>0){const r=t.reduce(((e,t)=>e*t));for(let n=0;n<e;++n)yield this._subarray(n,r,t)}else yield*this.data}_getitem(e){const[t,...r]=this.dims;if(e=M(e,t),r.length>0){const t=r.reduce(((e,t)=>e*t));return this._subarray(e,t,r)}return new i(this.type,[this.data[e]],r)}indexOf(e){const t=this.data;for(let r=0;r<t.length;++r)if(t[r]==e)return r;return-1}_subarray(e,t,r){const n=e*t,o=(e+1)*t,s="subarray"in this.data?this.data.subarray(n,o):this.data.slice(n,o);return new i(this.type,s,r)}item(){const e=this.data;if(1!==e.length)throw new Error(`a Tensor with ${e.length} elements cannot be converted to Scalar`);return e[0]}tolist(){return function(e,t){const r=e.length,n=t.reduce(((e,t)=>e*t));if(r!==n)throw Error(`cannot reshape array of size ${r} into shape (${t})`);let o=e;for(let e=t.length-1;e>=0;e--)o=o.reduce(((r,n)=>{let o=r[r.length-1];return o.length<t[e]?o.push(n):r.push([n]),r}),[[]]);return o[0]}(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){const e=this.data;for(let t=0;t<e.length;++t)e[t]=1/(1+Math.exp(-e[t]));return this}mul(e){return this.clone().mul_(e)}mul_(e){const t=this.data;for(let r=0;r<t.length;++r)t[r]*=e;return this}div(e){return this.clone().div_(e)}div_(e){const t=this.data;for(let r=0;r<t.length;++r)t[r]/=e;return this}add(e){return this.clone().add_(e)}add_(e){const t=this.data;for(let r=0;r<t.length;++r)t[r]+=e;return this}sub(e){return this.clone().sub_(e)}sub_(e){const t=this.data;for(let r=0;r<t.length;++r)t[r]-=e;return this}clone(){return new i(this.type,this.data.slice(),this.dims.slice())}slice(...e){const t=[],r=[];for(let n=0;n<this.dims.length;++n){let o=e[n];if(null==o)r.push([0,this.dims[n]]),t.push(this.dims[n]);else if("number"==typeof o)o=M(o,this.dims[n],n),r.push([o,o+1]);else{if(!Array.isArray(o)||2!==o.length)throw new Error(`Invalid slice: ${o}`);{let[e,s]=o;if(e=null===e?0:M(e,this.dims[n],n,!1),s=null===s?this.dims[n]:M(s,this.dims[n],n,!1),e>s)throw new Error(`Invalid slice: ${o}`);const a=[Math.max(e,0),Math.min(s,this.dims[n])];r.push(a),t.push(a[1]-a[0])}}}const n=r.map((([e,t])=>t-e)),o=n.reduce(((e,t)=>e*t)),s=this.data,a=new s.constructor(o),l=this.stride();for(let e=0;e<o;++e){let t=0;for(let o=n.length-1,s=e;o>=0;--o){const e=n[o];t+=(s%e+r[o][0])*l[o],s=Math.floor(s/e)}a[e]=s[t]}return new i(this.type,a,t)}permute(...e){return l(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,t=!1){return this.norm(1,e,t)}norm(e="fro",t=null,r=!1){if("fro"===e)e=2;else if("string"==typeof e)throw Error(`Unsupported norm: ${e}`);const n=this.data;if(null===t){let t=n.reduce(((t,r)=>t+r**e),0)**(1/e);return new i(this.type,[t],[])}t=M(t,this.dims.length);const o=this.dims.slice();o[t]=1;const s=new n.constructor(n.length/this.dims[t]);for(let r=0;r<n.length;++r){let a=0;for(let e=this.dims.length-1,n=r,s=1;e>=0;--e){const r=this.dims[e];if(e!==t){a+=n%r*s,s*=o[e]}n=Math.floor(n/r)}s[a]+=n[r]**e}if(1!==e)for(let t=0;t<s.length;++t)s[t]=s[t]**(1/e);return r||o.splice(t,1),new i(this.type,s,o)}normalize_(e=2,t=1){t=M(t,this.dims.length);const r=this.norm(e,t,!0),n=this.data,o=r.data;for(let e=0;e<n.length;++e){let r=0;for(let n=this.dims.length-1,o=e,s=1;n>=0;--n){const e=this.dims[n];if(n!==t){r+=o%e*s,s*=this.dims[n]}o=Math.floor(o/e)}n[e]/=o[r]}return this}normalize(e=2,t=1){return this.clone().normalize_(e,t)}stride(){return function(e){const t=new Array(e.length);for(let r=e.length-1,n=1;r>=0;--r)t[r]=n,n*=e[r];return t}(this.dims)}squeeze(e=null){return new i(this.type,this.data,f(this.dims,e))}squeeze_(e=null){return this.dims=f(this.dims,e),this}unsqueeze(e=null){return new i(this.type,this.data,g(this.dims,e))}unsqueeze_(e=null){return this.dims=g(this.dims,e),this}flatten_(e=0,t=-1){t=(t+this.dims.length)%this.dims.length;let r=this.dims.slice(0,e),n=this.dims.slice(e,t+1),o=this.dims.slice(t+1);return this.dims=[...r,n.reduce(((e,t)=>e*t),1),...o],this}flatten(e=0,t=-1){return this.clone().flatten_(e,t)}view(...e){let t=-1;for(let r=0;r<e.length;++r)if(-1===e[r]){if(-1!==t)throw new Error("Only one dimension can be inferred");t=r}const r=this.data;if(-1!==t){const n=e.reduce(((e,r,n)=>n!==t?e*r:e),1);e[t]=r.length/n}return new i(this.type,r,e)}neg_(){const e=this.data;for(let t=0;t<e.length;++t)e[t]=-e[t];return this}neg(){return this.clone().neg_()}clamp_(e,t){const r=this.data;for(let n=0;n<r.length;++n)r[n]=Math.min(Math.max(r[n],e),t);return this}clamp(e,t){return this.clone().clamp_(e,t)}round_(){const e=this.data;for(let t=0;t<e.length;++t)e[t]=Math.round(e[t]);return this}round(){return this.clone().round_()}mean(e=null,t=!1){return x(this,e,t)}to(e){if(this.type===e)return this;if(!a.hasOwnProperty(e))throw new Error(`Unsupported type: ${e}`);return new i(e,a[e].from(this.data),this.dims)}}function l(e,t){const[r,o]=(0,n.permute_data)(e.data,e.dims,t);return new i(e.type,r,o)}function c(e,[t,r],o="bilinear",s=!1){const a=e.dims.at(-3)??1,l=e.dims.at(-2),c=e.dims.at(-1);let d=(0,n.interpolate_data)(e.data,[a,l,c],[t,r],o,s);return new i(e.type,d,[a,t,r])}async function d(e,{size:t=null,mode:r="bilinear"}={}){if(4!==e.dims.length)throw new Error("`interpolate_4d` currently only supports 4D input.");if(!t)throw new Error("`interpolate_4d` requires a `size` argument.");let n,o;if(2===t.length)n=[...e.dims.slice(0,2),...t];else if(3===t.length)n=[e.dims[0],...t];else{if(4!==t.length)throw new Error("`size` must be of length 2, 3, or 4.");n=t}if("bilinear"===r)o=await s.TensorOpRegistry.bilinear_interpolate_4d;else{if("bicubic"!==r)throw new Error(`Unsupported mode: ${r}`);o=await s.TensorOpRegistry.bicubic_interpolate_4d}const a=new i("int64",new BigInt64Array(n.map(BigInt)),[n.length]);return await o({x:e,s:a})}async function u(e,t){const r=await s.TensorOpRegistry.matmul;return await r({a:e,b:t})}async function p(e,t){const r=await s.TensorOpRegistry.rfft;return await r({x:e,a:t})}async function h(e,t){const r=await s.TensorOpRegistry.top_k;return t=null===t?e.dims.at(-1):Math.min(t,e.dims.at(-1)),await r({x:e,k:new i("int64",[BigInt(t)],[1])})}function m(e,t){const r=e.data,n=t.data,o=[e.dims[0],e.dims[2]],s=new r.constructor(o[0]*o[1]),[a,l,c]=e.dims;let d=0;for(let e=0;e<a;++e){const t=e*c*l;for(let o=0;o<c;++o){let a=0,i=0;const u=e*l,p=t+o;for(let e=0;e<l;++e){const t=Number(n[u+e]);i+=t,a+=r[p+e*c]*t}const h=a/i;s[d++]=h}}return new i(e.type,s,o)}function _(e,t,{eps:r=1e-5}={}){if(2!==e.dims.length)throw new Error("`layer_norm` currently only supports 2D input.");const[n,o]=e.dims;if(1!==t.length&&t[0]!==o)throw new Error("`normalized_shape` must be a 1D array with shape `[input.dims[1]]`.");const[s,a]=b(e,1,0,!0),l=s.data,c=a.data,d=e.data,u=new d.constructor(d.length);for(let e=0;e<n;++e){const t=e*o;for(let n=0;n<o;++n){const o=t+n;u[o]=(d[o]-c[e])/(l[e]+r)}}return new i(e.type,u,e.dims)}function f(e,t){return e=e.slice(),null===t?e=e.filter((e=>1!==e)):"number"==typeof t?1===e[t]&&e.splice(t,1):Array.isArray(t)&&(e=e.filter(((e,r)=>1!==e||!t.includes(r)))),e}function g(e,t){return t=M(t,e.length+1),(e=e.slice()).splice(t,0,1),e}function M(e,t,r=null,n=!0){if(n&&(e<-t||e>=t))throw new Error(`IndexError: index ${e} is out of bounds for dimension${null===r?"":" "+r} with size ${t}`);return e<0&&(e=(e%t+t)%t),e}function w(e,t=0){t=M(t,e[0].dims.length);const r=e[0].dims.slice();r[t]=e.reduce(((e,r)=>e+r.dims[t]),0);const n=r.reduce(((e,t)=>e*t),1),o=new e[0].data.constructor(n),s=e[0].type;if(0===t){let t=0;for(const r of e){const e=r.data;o.set(e,t),t+=e.length}}else{let n=0;for(let s=0;s<e.length;++s){const{data:a,dims:i}=e[s];for(let e=0;e<a.length;++e){let s=0;for(let o=i.length-1,a=e,l=1;o>=0;--o){const e=i[o];let c=a%e;o===t&&(c+=n),s+=c*l,l*=r[o],a=Math.floor(a/e)}o[s]=a[e]}n+=i[t]}}return new i(s,o,r)}function T(e,t=0){return w(e.map((e=>e.unsqueeze(t))),t)}function b(e,t=null,r=1,n=!1){const o=e.data,s=e.dims;if(null===t){const t=o.reduce(((e,t)=>e+t),0)/o.length,n=Math.sqrt(o.reduce(((e,r)=>e+(r-t)**2),0)/(o.length-r)),s=new i(e.type,[t],[]);return[new i(e.type,[n],[]),s]}const a=x(e,t=M(t,s.length),n),l=a.data,c=s.slice();c[t]=1;const d=new o.constructor(o.length/s[t]);for(let e=0;e<o.length;++e){let r=0;for(let n=s.length-1,o=e,a=1;n>=0;--n){const e=s[n];if(n!==t){r+=o%e*a,a*=c[n]}o=Math.floor(o/e)}d[r]+=(o[e]-l[r])**2}for(let e=0;e<d.length;++e)d[e]=Math.sqrt(d[e]/(s[t]-r));n||c.splice(t,1);return[new i(e.type,d,c),a]}function x(e,t=null,r=!1){const n=e.data;if(null===t){const t=n.reduce(((e,t)=>e+t),0);return new i(e.type,[t/n.length],[])}const o=e.dims;t=M(t,o.length);const s=o.slice();s[t]=1;const a=new n.constructor(n.length/o[t]);for(let e=0;e<n.length;++e){let r=0;for(let n=o.length-1,a=e,i=1;n>=0;--n){const e=o[n];if(n!==t){r+=a%e*i,i*=s[n]}a=Math.floor(a/e)}a[r]+=n[e]}if(1!==o[t])for(let e=0;e<a.length;++e)a[e]=a[e]/o[t];return r||s.splice(t,1),new i(e.type,a,s)}function k(e,t,r,n){const o=e.reduce(((e,t)=>e*t),1);return new i(r,new n(o).fill(t),e)}function y(e,t){let r,n;if("number"==typeof t)r="float32",n=Float32Array;else{if("bigint"!=typeof t)throw new Error("Unsupported data type: "+typeof t);r="int64",n=BigInt64Array}return k(e,t,r,n)}function F(e,t){return y(e.dims,t)}function P(e){return k(e,1n,"int64",BigInt64Array)}function C(e){return P(e.dims)}function v(e){return k(e,0n,"int64",BigInt64Array)}function S(e){return v(e.dims)}function A(e,t){if(2!==e.dims.length)throw new Error("The tensor must have 2 dimensions");if(e.dims.at(-1)%8!=0)throw new Error("The last dimension of the tensor must be a multiple of 8");if(!["binary","ubinary"].includes(t))throw new Error("The precision must be either 'binary' or 'ubinary'");const r="binary"===t,n=r?"int8":"uint8",o=r?Int8Array:Uint8Array,s=e.data,a=new o(s.length/8);for(let e=0;e<s.length;++e){const t=s[e]>0?1:0,n=Math.floor(e/8),o=e%8;a[n]|=t<<7-o,r&&0===o&&(a[n]-=128)}return new i(n,a,[e.dims[0],e.dims[1]/8])}}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var s=r[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};
/*!*****************************!*\
!*** ./src/transformers.js ***!
\*****************************/n.r(o),n.d(o,{ASTFeatureExtractor:()=>c.ASTFeatureExtractor,ASTForAudioClassification:()=>i.ASTForAudioClassification,ASTModel:()=>i.ASTModel,ASTPreTrainedModel:()=>i.ASTPreTrainedModel,AlbertForMaskedLM:()=>i.AlbertForMaskedLM,AlbertForQuestionAnswering:()=>i.AlbertForQuestionAnswering,AlbertForSequenceClassification:()=>i.AlbertForSequenceClassification,AlbertModel:()=>i.AlbertModel,AlbertPreTrainedModel:()=>i.AlbertPreTrainedModel,AlbertTokenizer:()=>l.AlbertTokenizer,AudioClassificationPipeline:()=>a.AudioClassificationPipeline,AutoConfig:()=>d.AutoConfig,AutoModel:()=>i.AutoModel,AutoModelForAudioClassification:()=>i.AutoModelForAudioClassification,AutoModelForAudioFrameClassification:()=>i.AutoModelForAudioFrameClassification,AutoModelForCTC:()=>i.AutoModelForCTC,AutoModelForCausalLM:()=>i.AutoModelForCausalLM,AutoModelForDepthEstimation:()=>i.AutoModelForDepthEstimation,AutoModelForDocumentQuestionAnswering:()=>i.AutoModelForDocumentQuestionAnswering,AutoModelForImageClassification:()=>i.AutoModelForImageClassification,AutoModelForImageFeatureExtraction:()=>i.AutoModelForImageFeatureExtraction,AutoModelForImageMatting:()=>i.AutoModelForImageMatting,AutoModelForImageSegmentation:()=>i.AutoModelForImageSegmentation,AutoModelForImageToImage:()=>i.AutoModelForImageToImage,AutoModelForMaskGeneration:()=>i.AutoModelForMaskGeneration,AutoModelForMaskedLM:()=>i.AutoModelForMaskedLM,AutoModelForNormalEstimation:()=>i.AutoModelForNormalEstimation,AutoModelForObjectDetection:()=>i.AutoModelForObjectDetection,AutoModelForQuestionAnswering:()=>i.AutoModelForQuestionAnswering,AutoModelForSemanticSegmentation:()=>i.AutoModelForSemanticSegmentation,AutoModelForSeq2SeqLM:()=>i.AutoModelForSeq2SeqLM,AutoModelForSequenceClassification:()=>i.AutoModelForSequenceClassification,AutoModelForSpeechSeq2Seq:()=>i.AutoModelForSpeechSeq2Seq,AutoModelForTextToSpectrogram:()=>i.AutoModelForTextToSpectrogram,AutoModelForTextToWaveform:()=>i.AutoModelForTextToWaveform,AutoModelForTokenClassification:()=>i.AutoModelForTokenClassification,AutoModelForUniversalSegmentation:()=>i.AutoModelForUniversalSegmentation,AutoModelForVision2Seq:()=>i.AutoModelForVision2Seq,AutoModelForXVector:()=>i.AutoModelForXVector,AutoModelForZeroShotObjectDetection:()=>i.AutoModelForZeroShotObjectDetection,AutoProcessor:()=>c.AutoProcessor,AutoTokenizer:()=>l.AutoTokenizer,AutomaticSpeechRecognitionPipeline:()=>a.AutomaticSpeechRecognitionPipeline,BartForConditionalGeneration:()=>i.BartForConditionalGeneration,BartForSequenceClassification:()=>i.BartForSequenceClassification,BartModel:()=>i.BartModel,BartPretrainedModel:()=>i.BartPretrainedModel,BartTokenizer:()=>l.BartTokenizer,BaseModelOutput:()=>i.BaseModelOutput,BaseStreamer:()=>_.BaseStreamer,BeitFeatureExtractor:()=>c.BeitFeatureExtractor,BeitForImageClassification:()=>i.BeitForImageClassification,BeitModel:()=>i.BeitModel,BeitPreTrainedModel:()=>i.BeitPreTrainedModel,BertForMaskedLM:()=>i.BertForMaskedLM,BertForQuestionAnswering:()=>i.BertForQuestionAnswering,BertForSequenceClassification:()=>i.BertForSequenceClassification,BertForTokenClassification:()=>i.BertForTokenClassification,BertModel:()=>i.BertModel,BertPreTrainedModel:()=>i.BertPreTrainedModel,BertTokenizer:()=>l.BertTokenizer,BitImageProcessor:()=>c.BitImageProcessor,BlenderbotForConditionalGeneration:()=>i.BlenderbotForConditionalGeneration,BlenderbotModel:()=>i.BlenderbotModel,BlenderbotPreTrainedModel:()=>i.BlenderbotPreTrainedModel,BlenderbotSmallForConditionalGeneration:()=>i.BlenderbotSmallForConditionalGeneration,BlenderbotSmallModel:()=>i.BlenderbotSmallModel,BlenderbotSmallPreTrainedModel:()=>i.BlenderbotSmallPreTrainedModel,BlenderbotSmallTokenizer:()=>l.BlenderbotSmallTokenizer,BlenderbotTokenizer:()=>l.BlenderbotTokenizer,BloomForCausalLM:()=>i.BloomForCausalLM,BloomModel:()=>i.BloomModel,BloomPreTrainedModel:()=>i.BloomPreTrainedModel,BloomTokenizer:()=>l.BloomTokenizer,CLIPFeatureExtractor:()=>c.CLIPFeatureExtractor,CLIPImageProcessor:()=>c.CLIPImageProcessor,CLIPModel:()=>i.CLIPModel,CLIPPreTrainedModel:()=>i.CLIPPreTrainedModel,CLIPSegForImageSegmentation:()=>i.CLIPSegForImageSegmentation,CLIPSegModel:()=>i.CLIPSegModel,CLIPSegPreTrainedModel:()=>i.CLIPSegPreTrainedModel,CLIPTextModel:()=>i.CLIPTextModel,CLIPTextModelWithProjection:()=>i.CLIPTextModelWithProjection,CLIPTokenizer:()=>l.CLIPTokenizer,CLIPVisionModel:()=>i.CLIPVisionModel,CLIPVisionModelWithProjection:()=>i.CLIPVisionModelWithProjection,CamembertForMaskedLM:()=>i.CamembertForMaskedLM,CamembertForQuestionAnswering:()=>i.CamembertForQuestionAnswering,CamembertForSequenceClassification:()=>i.CamembertForSequenceClassification,CamembertForTokenClassification:()=>i.CamembertForTokenClassification,CamembertModel:()=>i.CamembertModel,CamembertPreTrainedModel:()=>i.CamembertPreTrainedModel,CamembertTokenizer:()=>l.CamembertTokenizer,CausalLMOutput:()=>i.CausalLMOutput,CausalLMOutputWithPast:()=>i.CausalLMOutputWithPast,ChineseCLIPFeatureExtractor:()=>c.ChineseCLIPFeatureExtractor,ChineseCLIPModel:()=>i.ChineseCLIPModel,ChineseCLIPPreTrainedModel:()=>i.ChineseCLIPPreTrainedModel,ClapAudioModelWithProjection:()=>i.ClapAudioModelWithProjection,ClapFeatureExtractor:()=>c.ClapFeatureExtractor,ClapModel:()=>i.ClapModel,ClapPreTrainedModel:()=>i.ClapPreTrainedModel,ClapTextModelWithProjection:()=>i.ClapTextModelWithProjection,CodeGenForCausalLM:()=>i.CodeGenForCausalLM,CodeGenModel:()=>i.CodeGenModel,CodeGenPreTrainedModel:()=>i.CodeGenPreTrainedModel,CodeGenTokenizer:()=>l.CodeGenTokenizer,CodeLlamaTokenizer:()=>l.CodeLlamaTokenizer,CohereForCausalLM:()=>i.CohereForCausalLM,CohereModel:()=>i.CohereModel,CoherePreTrainedModel:()=>i.CoherePreTrainedModel,CohereTokenizer:()=>l.CohereTokenizer,ConvBertForMaskedLM:()=>i.ConvBertForMaskedLM,ConvBertForQuestionAnswering:()=>i.ConvBertForQuestionAnswering,ConvBertForSequenceClassification:()=>i.ConvBertForSequenceClassification,ConvBertForTokenClassification:()=>i.ConvBertForTokenClassification,ConvBertModel:()=>i.ConvBertModel,ConvBertPreTrainedModel:()=>i.ConvBertPreTrainedModel,ConvBertTokenizer:()=>l.ConvBertTokenizer,ConvNextFeatureExtractor:()=>c.ConvNextFeatureExtractor,ConvNextForImageClassification:()=>i.ConvNextForImageClassification,ConvNextImageProcessor:()=>c.ConvNextImageProcessor,ConvNextModel:()=>i.ConvNextModel,ConvNextPreTrainedModel:()=>i.ConvNextPreTrainedModel,ConvNextV2ForImageClassification:()=>i.ConvNextV2ForImageClassification,ConvNextV2Model:()=>i.ConvNextV2Model,ConvNextV2PreTrainedModel:()=>i.ConvNextV2PreTrainedModel,DPTFeatureExtractor:()=>c.DPTFeatureExtractor,DPTForDepthEstimation:()=>i.DPTForDepthEstimation,DPTImageProcessor:()=>c.DPTImageProcessor,DPTModel:()=>i.DPTModel,DPTPreTrainedModel:()=>i.DPTPreTrainedModel,DebertaForMaskedLM:()=>i.DebertaForMaskedLM,DebertaForQuestionAnswering:()=>i.DebertaForQuestionAnswering,DebertaForSequenceClassification:()=>i.DebertaForSequenceClassification,DebertaForTokenClassification:()=>i.DebertaForTokenClassification,DebertaModel:()=>i.DebertaModel,DebertaPreTrainedModel:()=>i.DebertaPreTrainedModel,DebertaTokenizer:()=>l.DebertaTokenizer,DebertaV2ForMaskedLM:()=>i.DebertaV2ForMaskedLM,DebertaV2ForQuestionAnswering:()=>i.DebertaV2ForQuestionAnswering,DebertaV2ForSequenceClassification:()=>i.DebertaV2ForSequenceClassification,DebertaV2ForTokenClassification:()=>i.DebertaV2ForTokenClassification,DebertaV2Model:()=>i.DebertaV2Model,DebertaV2PreTrainedModel:()=>i.DebertaV2PreTrainedModel,DebertaV2Tokenizer:()=>l.DebertaV2Tokenizer,DecisionTransformerModel:()=>i.DecisionTransformerModel,DecisionTransformerPreTrainedModel:()=>i.DecisionTransformerPreTrainedModel,DeiTFeatureExtractor:()=>c.DeiTFeatureExtractor,DeiTForImageClassification:()=>i.DeiTForImageClassification,DeiTModel:()=>i.DeiTModel,DeiTPreTrainedModel:()=>i.DeiTPreTrainedModel,DepthAnythingForDepthEstimation:()=>i.DepthAnythingForDepthEstimation,DepthAnythingPreTrainedModel:()=>i.DepthAnythingPreTrainedModel,DepthEstimationPipeline:()=>a.DepthEstimationPipeline,DetrFeatureExtractor:()=>c.DetrFeatureExtractor,DetrForObjectDetection:()=>i.DetrForObjectDetection,DetrForSegmentation:()=>i.DetrForSegmentation,DetrModel:()=>i.DetrModel,DetrObjectDetectionOutput:()=>i.DetrObjectDetectionOutput,DetrPreTrainedModel:()=>i.DetrPreTrainedModel,DetrSegmentationOutput:()=>i.DetrSegmentationOutput,Dinov2ForImageClassification:()=>i.Dinov2ForImageClassification,Dinov2Model:()=>i.Dinov2Model,Dinov2PreTrainedModel:()=>i.Dinov2PreTrainedModel,DistilBertForMaskedLM:()=>i.DistilBertForMaskedLM,DistilBertForQuestionAnswering:()=>i.DistilBertForQuestionAnswering,DistilBertForSequenceClassification:()=>i.DistilBertForSequenceClassification,DistilBertForTokenClassification:()=>i.DistilBertForTokenClassification,DistilBertModel:()=>i.DistilBertModel,DistilBertPreTrainedModel:()=>i.DistilBertPreTrainedModel,DistilBertTokenizer:()=>l.DistilBertTokenizer,DocumentQuestionAnsweringPipeline:()=>a.DocumentQuestionAnsweringPipeline,DonutFeatureExtractor:()=>c.DonutFeatureExtractor,DonutSwinModel:()=>i.DonutSwinModel,DonutSwinPreTrainedModel:()=>i.DonutSwinPreTrainedModel,EfficientNetForImageClassification:()=>i.EfficientNetForImageClassification,EfficientNetImageProcessor:()=>c.EfficientNetImageProcessor,EfficientNetModel:()=>i.EfficientNetModel,EfficientNetPreTrainedModel:()=>i.EfficientNetPreTrainedModel,ElectraForMaskedLM:()=>i.ElectraForMaskedLM,ElectraForQuestionAnswering:()=>i.ElectraForQuestionAnswering,ElectraForSequenceClassification:()=>i.ElectraForSequenceClassification,ElectraForTokenClassification:()=>i.ElectraForTokenClassification,ElectraModel:()=>i.ElectraModel,ElectraPreTrainedModel:()=>i.ElectraPreTrainedModel,ElectraTokenizer:()=>l.ElectraTokenizer,EosTokenCriteria:()=>f.EosTokenCriteria,EsmForMaskedLM:()=>i.EsmForMaskedLM,EsmForSequenceClassification:()=>i.EsmForSequenceClassification,EsmForTokenClassification:()=>i.EsmForTokenClassification,EsmModel:()=>i.EsmModel,EsmPreTrainedModel:()=>i.EsmPreTrainedModel,EsmTokenizer:()=>l.EsmTokenizer,FFT:()=>m.FFT,FalconForCausalLM:()=>i.FalconForCausalLM,FalconModel:()=>i.FalconModel,FalconPreTrainedModel:()=>i.FalconPreTrainedModel,FalconTokenizer:()=>l.FalconTokenizer,FastViTForImageClassification:()=>i.FastViTForImageClassification,FastViTModel:()=>i.FastViTModel,FastViTPreTrainedModel:()=>i.FastViTPreTrainedModel,FeatureExtractionPipeline:()=>a.FeatureExtractionPipeline,FeatureExtractor:()=>c.FeatureExtractor,FillMaskPipeline:()=>a.FillMaskPipeline,Florence2ForConditionalGeneration:()=>i.Florence2ForConditionalGeneration,Florence2PreTrainedModel:()=>i.Florence2PreTrainedModel,Florence2Processor:()=>c.Florence2Processor,GLPNFeatureExtractor:()=>c.GLPNFeatureExtractor,GLPNForDepthEstimation:()=>i.GLPNForDepthEstimation,GLPNModel:()=>i.GLPNModel,GLPNPreTrainedModel:()=>i.GLPNPreTrainedModel,GPT2LMHeadModel:()=>i.GPT2LMHeadModel,GPT2Model:()=>i.GPT2Model,GPT2PreTrainedModel:()=>i.GPT2PreTrainedModel,GPT2Tokenizer:()=>l.GPT2Tokenizer,GPTBigCodeForCausalLM:()=>i.GPTBigCodeForCausalLM,GPTBigCodeModel:()=>i.GPTBigCodeModel,GPTBigCodePreTrainedModel:()=>i.GPTBigCodePreTrainedModel,GPTJForCausalLM:()=>i.GPTJForCausalLM,GPTJModel:()=>i.GPTJModel,GPTJPreTrainedModel:()=>i.GPTJPreTrainedModel,GPTNeoForCausalLM:()=>i.GPTNeoForCausalLM,GPTNeoModel:()=>i.GPTNeoModel,GPTNeoPreTrainedModel:()=>i.GPTNeoPreTrainedModel,GPTNeoXForCausalLM:()=>i.GPTNeoXForCausalLM,GPTNeoXModel:()=>i.GPTNeoXModel,GPTNeoXPreTrainedModel:()=>i.GPTNeoXPreTrainedModel,GPTNeoXTokenizer:()=>l.GPTNeoXTokenizer,Gemma2ForCausalLM:()=>i.Gemma2ForCausalLM,Gemma2Model:()=>i.Gemma2Model,Gemma2PreTrainedModel:()=>i.Gemma2PreTrainedModel,GemmaForCausalLM:()=>i.GemmaForCausalLM,GemmaModel:()=>i.GemmaModel,GemmaPreTrainedModel:()=>i.GemmaPreTrainedModel,GemmaTokenizer:()=>l.GemmaTokenizer,Grok1Tokenizer:()=>l.Grok1Tokenizer,GroupViTModel:()=>i.GroupViTModel,GroupViTPreTrainedModel:()=>i.GroupViTPreTrainedModel,HerbertTokenizer:()=>l.HerbertTokenizer,HieraForImageClassification:()=>i.HieraForImageClassification,HieraModel:()=>i.HieraModel,HieraPreTrainedModel:()=>i.HieraPreTrainedModel,HubertForCTC:()=>i.HubertForCTC,HubertForSequenceClassification:()=>i.HubertForSequenceClassification,HubertModel:()=>i.HubertModel,HubertPreTrainedModel:()=>i.HubertPreTrainedModel,ImageClassificationPipeline:()=>a.ImageClassificationPipeline,ImageFeatureExtractionPipeline:()=>a.ImageFeatureExtractionPipeline,ImageFeatureExtractor:()=>c.ImageFeatureExtractor,ImageMattingOutput:()=>i.ImageMattingOutput,ImageSegmentationPipeline:()=>a.ImageSegmentationPipeline,ImageToImagePipeline:()=>a.ImageToImagePipeline,ImageToTextPipeline:()=>a.ImageToTextPipeline,InterruptableStoppingCriteria:()=>f.InterruptableStoppingCriteria,JAISLMHeadModel:()=>i.JAISLMHeadModel,JAISModel:()=>i.JAISModel,JAISPreTrainedModel:()=>i.JAISPreTrainedModel,LlamaForCausalLM:()=>i.LlamaForCausalLM,LlamaModel:()=>i.LlamaModel,LlamaPreTrainedModel:()=>i.LlamaPreTrainedModel,LlamaTokenizer:()=>l.LlamaTokenizer,LlavaForConditionalGeneration:()=>i.LlavaForConditionalGeneration,LlavaPreTrainedModel:()=>i.LlavaPreTrainedModel,LongT5ForConditionalGeneration:()=>i.LongT5ForConditionalGeneration,LongT5Model:()=>i.LongT5Model,LongT5PreTrainedModel:()=>i.LongT5PreTrainedModel,M2M100ForConditionalGeneration:()=>i.M2M100ForConditionalGeneration,M2M100Model:()=>i.M2M100Model,M2M100PreTrainedModel:()=>i.M2M100PreTrainedModel,M2M100Tokenizer:()=>l.M2M100Tokenizer,MBart50Tokenizer:()=>l.MBart50Tokenizer,MBartForCausalLM:()=>i.MBartForCausalLM,MBartForConditionalGeneration:()=>i.MBartForConditionalGeneration,MBartForSequenceClassification:()=>i.MBartForSequenceClassification,MBartModel:()=>i.MBartModel,MBartPreTrainedModel:()=>i.MBartPreTrainedModel,MBartTokenizer:()=>l.MBartTokenizer,MPNetForMaskedLM:()=>i.MPNetForMaskedLM,MPNetForQuestionAnswering:()=>i.MPNetForQuestionAnswering,MPNetForSequenceClassification:()=>i.MPNetForSequenceClassification,MPNetForTokenClassification:()=>i.MPNetForTokenClassification,MPNetModel:()=>i.MPNetModel,MPNetPreTrainedModel:()=>i.MPNetPreTrainedModel,MPNetTokenizer:()=>l.MPNetTokenizer,MT5ForConditionalGeneration:()=>i.MT5ForConditionalGeneration,MT5Model:()=>i.MT5Model,MT5PreTrainedModel:()=>i.MT5PreTrainedModel,MarianMTModel:()=>i.MarianMTModel,MarianModel:()=>i.MarianModel,MarianPreTrainedModel:()=>i.MarianPreTrainedModel,MarianTokenizer:()=>l.MarianTokenizer,MaskFormerFeatureExtractor:()=>c.MaskFormerFeatureExtractor,MaskFormerForInstanceSegmentation:()=>i.MaskFormerForInstanceSegmentation,MaskFormerModel:()=>i.MaskFormerModel,MaskFormerPreTrainedModel:()=>i.MaskFormerPreTrainedModel,MaskedLMOutput:()=>i.MaskedLMOutput,MaxLengthCriteria:()=>f.MaxLengthCriteria,MistralForCausalLM:()=>i.MistralForCausalLM,MistralModel:()=>i.MistralModel,MistralPreTrainedModel:()=>i.MistralPreTrainedModel,MobileBertForMaskedLM:()=>i.MobileBertForMaskedLM,MobileBertForQuestionAnswering:()=>i.MobileBertForQuestionAnswering,MobileBertForSequenceClassification:()=>i.MobileBertForSequenceClassification,MobileBertModel:()=>i.MobileBertModel,MobileBertPreTrainedModel:()=>i.MobileBertPreTrainedModel,MobileBertTokenizer:()=>l.MobileBertTokenizer,MobileNetV1FeatureExtractor:()=>c.MobileNetV1FeatureExtractor,MobileNetV1ForImageClassification:()=>i.MobileNetV1ForImageClassification,MobileNetV1Model:()=>i.MobileNetV1Model,MobileNetV1PreTrainedModel:()=>i.MobileNetV1PreTrainedModel,MobileNetV2FeatureExtractor:()=>c.MobileNetV2FeatureExtractor,MobileNetV2ForImageClassification:()=>i.MobileNetV2ForImageClassification,MobileNetV2Model:()=>i.MobileNetV2Model,MobileNetV2PreTrainedModel:()=>i.MobileNetV2PreTrainedModel,MobileNetV3FeatureExtractor:()=>c.MobileNetV3FeatureExtractor,MobileNetV3ForImageClassification:()=>i.MobileNetV3ForImageClassification,MobileNetV3Model:()=>i.MobileNetV3Model,MobileNetV3PreTrainedModel:()=>i.MobileNetV3PreTrainedModel,MobileNetV4FeatureExtractor:()=>c.MobileNetV4FeatureExtractor,MobileNetV4ForImageClassification:()=>i.MobileNetV4ForImageClassification,MobileNetV4Model:()=>i.MobileNetV4Model,MobileNetV4PreTrainedModel:()=>i.MobileNetV4PreTrainedModel,MobileViTFeatureExtractor:()=>c.MobileViTFeatureExtractor,MobileViTForImageClassification:()=>i.MobileViTForImageClassification,MobileViTImageProcessor:()=>c.MobileViTImageProcessor,MobileViTModel:()=>i.MobileViTModel,MobileViTPreTrainedModel:()=>i.MobileViTPreTrainedModel,MobileViTV2ForImageClassification:()=>i.MobileViTV2ForImageClassification,MobileViTV2Model:()=>i.MobileViTV2Model,MobileViTV2PreTrainedModel:()=>i.MobileViTV2PreTrainedModel,ModelOutput:()=>i.ModelOutput,Moondream1ForConditionalGeneration:()=>i.Moondream1ForConditionalGeneration,MptForCausalLM:()=>i.MptForCausalLM,MptModel:()=>i.MptModel,MptPreTrainedModel:()=>i.MptPreTrainedModel,MusicgenForCausalLM:()=>i.MusicgenForCausalLM,MusicgenForConditionalGeneration:()=>i.MusicgenForConditionalGeneration,MusicgenModel:()=>i.MusicgenModel,MusicgenPreTrainedModel:()=>i.MusicgenPreTrainedModel,NllbTokenizer:()=>l.NllbTokenizer,NomicBertModel:()=>i.NomicBertModel,NomicBertPreTrainedModel:()=>i.NomicBertPreTrainedModel,NougatImageProcessor:()=>c.NougatImageProcessor,NougatTokenizer:()=>l.NougatTokenizer,OPTForCausalLM:()=>i.OPTForCausalLM,OPTModel:()=>i.OPTModel,OPTPreTrainedModel:()=>i.OPTPreTrainedModel,ObjectDetectionPipeline:()=>a.ObjectDetectionPipeline,OpenELMForCausalLM:()=>i.OpenELMForCausalLM,OpenELMModel:()=>i.OpenELMModel,OpenELMPreTrainedModel:()=>i.OpenELMPreTrainedModel,OwlViTFeatureExtractor:()=>c.OwlViTFeatureExtractor,OwlViTForObjectDetection:()=>i.OwlViTForObjectDetection,OwlViTModel:()=>i.OwlViTModel,OwlViTPreTrainedModel:()=>i.OwlViTPreTrainedModel,OwlViTProcessor:()=>c.OwlViTProcessor,Owlv2ForObjectDetection:()=>i.Owlv2ForObjectDetection,Owlv2ImageProcessor:()=>c.Owlv2ImageProcessor,Owlv2Model:()=>i.Owlv2Model,Owlv2PreTrainedModel:()=>i.Owlv2PreTrainedModel,Phi3ForCausalLM:()=>i.Phi3ForCausalLM,Phi3Model:()=>i.Phi3Model,Phi3PreTrainedModel:()=>i.Phi3PreTrainedModel,PhiForCausalLM:()=>i.PhiForCausalLM,PhiModel:()=>i.PhiModel,PhiPreTrainedModel:()=>i.PhiPreTrainedModel,Pipeline:()=>a.Pipeline,PreTrainedModel:()=>i.PreTrainedModel,PreTrainedTokenizer:()=>l.PreTrainedTokenizer,PretrainedConfig:()=>d.PretrainedConfig,PretrainedMixin:()=>i.PretrainedMixin,Processor:()=>c.Processor,PvtForImageClassification:()=>i.PvtForImageClassification,PvtImageProcessor:()=>c.PvtImageProcessor,PvtModel:()=>i.PvtModel,PvtPreTrainedModel:()=>i.PvtPreTrainedModel,PyAnnoteFeatureExtractor:()=>c.PyAnnoteFeatureExtractor,PyAnnoteForAudioFrameClassification:()=>i.PyAnnoteForAudioFrameClassification,PyAnnoteModel:()=>i.PyAnnoteModel,PyAnnotePreTrainedModel:()=>i.PyAnnotePreTrainedModel,PyAnnoteProcessor:()=>c.PyAnnoteProcessor,QuestionAnsweringModelOutput:()=>i.QuestionAnsweringModelOutput,QuestionAnsweringPipeline:()=>a.QuestionAnsweringPipeline,Qwen2ForCausalLM:()=>i.Qwen2ForCausalLM,Qwen2Model:()=>i.Qwen2Model,Qwen2PreTrainedModel:()=>i.Qwen2PreTrainedModel,Qwen2Tokenizer:()=>l.Qwen2Tokenizer,RTDetrForObjectDetection:()=>i.RTDetrForObjectDetection,RTDetrImageProcessor:()=>c.RTDetrImageProcessor,RTDetrModel:()=>i.RTDetrModel,RTDetrObjectDetectionOutput:()=>i.RTDetrObjectDetectionOutput,RTDetrPreTrainedModel:()=>i.RTDetrPreTrainedModel,RawImage:()=>p.RawImage,ResNetForImageClassification:()=>i.ResNetForImageClassification,ResNetModel:()=>i.ResNetModel,ResNetPreTrainedModel:()=>i.ResNetPreTrainedModel,RoFormerForMaskedLM:()=>i.RoFormerForMaskedLM,RoFormerForQuestionAnswering:()=>i.RoFormerForQuestionAnswering,RoFormerForSequenceClassification:()=>i.RoFormerForSequenceClassification,RoFormerForTokenClassification:()=>i.RoFormerForTokenClassification,RoFormerModel:()=>i.RoFormerModel,RoFormerPreTrainedModel:()=>i.RoFormerPreTrainedModel,RoFormerTokenizer:()=>l.RoFormerTokenizer,RobertaForMaskedLM:()=>i.RobertaForMaskedLM,RobertaForQuestionAnswering:()=>i.RobertaForQuestionAnswering,RobertaForSequenceClassification:()=>i.RobertaForSequenceClassification,RobertaForTokenClassification:()=>i.RobertaForTokenClassification,RobertaModel:()=>i.RobertaModel,RobertaPreTrainedModel:()=>i.RobertaPreTrainedModel,RobertaTokenizer:()=>l.RobertaTokenizer,SamImageProcessor:()=>c.SamImageProcessor,SamImageSegmentationOutput:()=>i.SamImageSegmentationOutput,SamModel:()=>i.SamModel,SamPreTrainedModel:()=>i.SamPreTrainedModel,SamProcessor:()=>c.SamProcessor,SapiensFeatureExtractor:()=>c.SapiensFeatureExtractor,SapiensForDepthEstimation:()=>i.SapiensForDepthEstimation,SapiensForNormalEstimation:()=>i.SapiensForNormalEstimation,SapiensForSemanticSegmentation:()=>i.SapiensForSemanticSegmentation,SapiensPreTrainedModel:()=>i.SapiensPreTrainedModel,SeamlessM4TFeatureExtractor:()=>c.SeamlessM4TFeatureExtractor,SegformerFeatureExtractor:()=>c.SegformerFeatureExtractor,SegformerForImageClassification:()=>i.SegformerForImageClassification,SegformerForSemanticSegmentation:()=>i.SegformerForSemanticSegmentation,SegformerModel:()=>i.SegformerModel,SegformerPreTrainedModel:()=>i.SegformerPreTrainedModel,Seq2SeqLMOutput:()=>i.Seq2SeqLMOutput,SequenceClassifierOutput:()=>i.SequenceClassifierOutput,SiglipImageProcessor:()=>c.SiglipImageProcessor,SiglipModel:()=>i.SiglipModel,SiglipPreTrainedModel:()=>i.SiglipPreTrainedModel,SiglipTextModel:()=>i.SiglipTextModel,SiglipTokenizer:()=>l.SiglipTokenizer,SiglipVisionModel:()=>i.SiglipVisionModel,SpeechT5FeatureExtractor:()=>c.SpeechT5FeatureExtractor,SpeechT5ForSpeechToText:()=>i.SpeechT5ForSpeechToText,SpeechT5ForTextToSpeech:()=>i.SpeechT5ForTextToSpeech,SpeechT5HifiGan:()=>i.SpeechT5HifiGan,SpeechT5Model:()=>i.SpeechT5Model,SpeechT5PreTrainedModel:()=>i.SpeechT5PreTrainedModel,SpeechT5Processor:()=>c.SpeechT5Processor,SpeechT5Tokenizer:()=>l.SpeechT5Tokenizer,SqueezeBertForMaskedLM:()=>i.SqueezeBertForMaskedLM,SqueezeBertForQuestionAnswering:()=>i.SqueezeBertForQuestionAnswering,SqueezeBertForSequenceClassification:()=>i.SqueezeBertForSequenceClassification,SqueezeBertModel:()=>i.SqueezeBertModel,SqueezeBertPreTrainedModel:()=>i.SqueezeBertPreTrainedModel,SqueezeBertTokenizer:()=>l.SqueezeBertTokenizer,StableLmForCausalLM:()=>i.StableLmForCausalLM,StableLmModel:()=>i.StableLmModel,StableLmPreTrainedModel:()=>i.StableLmPreTrainedModel,Starcoder2ForCausalLM:()=>i.Starcoder2ForCausalLM,Starcoder2Model:()=>i.Starcoder2Model,Starcoder2PreTrainedModel:()=>i.Starcoder2PreTrainedModel,StoppingCriteria:()=>f.StoppingCriteria,StoppingCriteriaList:()=>f.StoppingCriteriaList,SummarizationPipeline:()=>a.SummarizationPipeline,Swin2SRForImageSuperResolution:()=>i.Swin2SRForImageSuperResolution,Swin2SRImageProcessor:()=>c.Swin2SRImageProcessor,Swin2SRModel:()=>i.Swin2SRModel,Swin2SRPreTrainedModel:()=>i.Swin2SRPreTrainedModel,SwinForImageClassification:()=>i.SwinForImageClassification,SwinModel:()=>i.SwinModel,SwinPreTrainedModel:()=>i.SwinPreTrainedModel,T5ForConditionalGeneration:()=>i.T5ForConditionalGeneration,T5Model:()=>i.T5Model,T5PreTrainedModel:()=>i.T5PreTrainedModel,T5Tokenizer:()=>l.T5Tokenizer,TableTransformerForObjectDetection:()=>i.TableTransformerForObjectDetection,TableTransformerModel:()=>i.TableTransformerModel,TableTransformerObjectDetectionOutput:()=>i.TableTransformerObjectDetectionOutput,TableTransformerPreTrainedModel:()=>i.TableTransformerPreTrainedModel,Tensor:()=>h.Tensor,Text2TextGenerationPipeline:()=>a.Text2TextGenerationPipeline,TextClassificationPipeline:()=>a.TextClassificationPipeline,TextGenerationPipeline:()=>a.TextGenerationPipeline,TextStreamer:()=>_.TextStreamer,TextToAudioPipeline:()=>a.TextToAudioPipeline,TokenClassificationPipeline:()=>a.TokenClassificationPipeline,TokenClassifierOutput:()=>i.TokenClassifierOutput,TokenizerModel:()=>l.TokenizerModel,TrOCRForCausalLM:()=>i.TrOCRForCausalLM,TrOCRPreTrainedModel:()=>i.TrOCRPreTrainedModel,TranslationPipeline:()=>a.TranslationPipeline,UniSpeechForCTC:()=>i.UniSpeechForCTC,UniSpeechForSequenceClassification:()=>i.UniSpeechForSequenceClassification,UniSpeechModel:()=>i.UniSpeechModel,UniSpeechPreTrainedModel:()=>i.UniSpeechPreTrainedModel,UniSpeechSatForAudioFrameClassification:()=>i.UniSpeechSatForAudioFrameClassification,UniSpeechSatForCTC:()=>i.UniSpeechSatForCTC,UniSpeechSatForSequenceClassification:()=>i.UniSpeechSatForSequenceClassification,UniSpeechSatModel:()=>i.UniSpeechSatModel,UniSpeechSatPreTrainedModel:()=>i.UniSpeechSatPreTrainedModel,ViTFeatureExtractor:()=>c.ViTFeatureExtractor,ViTForImageClassification:()=>i.ViTForImageClassification,ViTImageProcessor:()=>c.ViTImageProcessor,ViTMAEModel:()=>i.ViTMAEModel,ViTMAEPreTrainedModel:()=>i.ViTMAEPreTrainedModel,ViTMSNForImageClassification:()=>i.ViTMSNForImageClassification,ViTMSNModel:()=>i.ViTMSNModel,ViTMSNPreTrainedModel:()=>i.ViTMSNPreTrainedModel,ViTModel:()=>i.ViTModel,ViTPreTrainedModel:()=>i.ViTPreTrainedModel,VisionEncoderDecoderModel:()=>i.VisionEncoderDecoderModel,VitMatteForImageMatting:()=>i.VitMatteForImageMatting,VitMatteImageProcessor:()=>c.VitMatteImageProcessor,VitMattePreTrainedModel:()=>i.VitMattePreTrainedModel,VitsModel:()=>i.VitsModel,VitsModelOutput:()=>i.VitsModelOutput,VitsPreTrainedModel:()=>i.VitsPreTrainedModel,VitsTokenizer:()=>l.VitsTokenizer,Wav2Vec2BertForCTC:()=>i.Wav2Vec2BertForCTC,Wav2Vec2BertForSequenceClassification:()=>i.Wav2Vec2BertForSequenceClassification,Wav2Vec2BertModel:()=>i.Wav2Vec2BertModel,Wav2Vec2BertPreTrainedModel:()=>i.Wav2Vec2BertPreTrainedModel,Wav2Vec2CTCTokenizer:()=>l.Wav2Vec2CTCTokenizer,Wav2Vec2FeatureExtractor:()=>c.Wav2Vec2FeatureExtractor,Wav2Vec2ForAudioFrameClassification:()=>i.Wav2Vec2ForAudioFrameClassification,Wav2Vec2ForCTC:()=>i.Wav2Vec2ForCTC,Wav2Vec2ForSequenceClassification:()=>i.Wav2Vec2ForSequenceClassification,Wav2Vec2Model:()=>i.Wav2Vec2Model,Wav2Vec2PreTrainedModel:()=>i.Wav2Vec2PreTrainedModel,Wav2Vec2ProcessorWithLM:()=>c.Wav2Vec2ProcessorWithLM,WavLMForAudioFrameClassification:()=>i.WavLMForAudioFrameClassification,WavLMForCTC:()=>i.WavLMForCTC,WavLMForSequenceClassification:()=>i.WavLMForSequenceClassification,WavLMForXVector:()=>i.WavLMForXVector,WavLMModel:()=>i.WavLMModel,WavLMPreTrainedModel:()=>i.WavLMPreTrainedModel,WeSpeakerFeatureExtractor:()=>c.WeSpeakerFeatureExtractor,WeSpeakerResNetModel:()=>i.WeSpeakerResNetModel,WeSpeakerResNetPreTrainedModel:()=>i.WeSpeakerResNetPreTrainedModel,WhisperFeatureExtractor:()=>c.WhisperFeatureExtractor,WhisperForConditionalGeneration:()=>i.WhisperForConditionalGeneration,WhisperModel:()=>i.WhisperModel,WhisperPreTrainedModel:()=>i.WhisperPreTrainedModel,WhisperProcessor:()=>c.WhisperProcessor,WhisperTextStreamer:()=>_.WhisperTextStreamer,WhisperTokenizer:()=>l.WhisperTokenizer,XLMForQuestionAnswering:()=>i.XLMForQuestionAnswering,XLMForSequenceClassification:()=>i.XLMForSequenceClassification,XLMForTokenClassification:()=>i.XLMForTokenClassification,XLMModel:()=>i.XLMModel,XLMPreTrainedModel:()=>i.XLMPreTrainedModel,XLMRobertaForMaskedLM:()=>i.XLMRobertaForMaskedLM,XLMRobertaForQuestionAnswering:()=>i.XLMRobertaForQuestionAnswering,XLMRobertaForSequenceClassification:()=>i.XLMRobertaForSequenceClassification,XLMRobertaForTokenClassification:()=>i.XLMRobertaForTokenClassification,XLMRobertaModel:()=>i.XLMRobertaModel,XLMRobertaPreTrainedModel:()=>i.XLMRobertaPreTrainedModel,XLMRobertaTokenizer:()=>l.XLMRobertaTokenizer,XLMTokenizer:()=>l.XLMTokenizer,XLMWithLMHeadModel:()=>i.XLMWithLMHeadModel,XVectorOutput:()=>i.XVectorOutput,YolosFeatureExtractor:()=>c.YolosFeatureExtractor,YolosForObjectDetection:()=>i.YolosForObjectDetection,YolosModel:()=>i.YolosModel,YolosObjectDetectionOutput:()=>i.YolosObjectDetectionOutput,YolosPreTrainedModel:()=>i.YolosPreTrainedModel,ZeroShotAudioClassificationPipeline:()=>a.ZeroShotAudioClassificationPipeline,ZeroShotClassificationPipeline:()=>a.ZeroShotClassificationPipeline,ZeroShotImageClassificationPipeline:()=>a.ZeroShotImageClassificationPipeline,ZeroShotObjectDetectionPipeline:()=>a.ZeroShotObjectDetectionPipeline,bankers_round:()=>m.bankers_round,cat:()=>h.cat,cos_sim:()=>m.cos_sim,dot:()=>m.dot,dynamic_time_warping:()=>m.dynamic_time_warping,env:()=>s.env,full:()=>h.full,full_like:()=>h.full_like,getKeyValueShapes:()=>d.getKeyValueShapes,hamming:()=>u.hamming,hanning:()=>u.hanning,interpolate:()=>h.interpolate,interpolate_4d:()=>h.interpolate_4d,interpolate_data:()=>m.interpolate_data,is_chinese_char:()=>l.is_chinese_char,layer_norm:()=>h.layer_norm,log_softmax:()=>m.log_softmax,magnitude:()=>m.magnitude,matmul:()=>h.matmul,max:()=>m.max,mean:()=>h.mean,mean_pooling:()=>h.mean_pooling,medianFilter:()=>m.medianFilter,mel_filter_bank:()=>u.mel_filter_bank,min:()=>m.min,ones:()=>h.ones,ones_like:()=>h.ones_like,permute:()=>h.permute,permute_data:()=>m.permute_data,pipeline:()=>a.pipeline,quantize_embeddings:()=>h.quantize_embeddings,read_audio:()=>u.read_audio,rfft:()=>h.rfft,round:()=>m.round,softmax:()=>m.softmax,spectrogram:()=>u.spectrogram,stack:()=>h.stack,std_mean:()=>h.std_mean,topk:()=>h.topk,window_function:()=>u.window_function,zeros:()=>h.zeros,zeros_like:()=>h.zeros_like});var s=n(/*! ./env.js */"./src/env.js"),a=n(/*! ./pipelines.js */"./src/pipelines.js"),i=n(/*! ./models.js */"./src/models.js"),l=n(/*! ./tokenizers.js */"./src/tokenizers.js"),c=n(/*! ./processors.js */"./src/processors.js"),d=n(/*! ./configs.js */"./src/configs.js"),u=n(/*! ./utils/audio.js */"./src/utils/audio.js"),p=n(/*! ./utils/image.js */"./src/utils/image.js"),h=n(/*! ./utils/tensor.js */"./src/utils/tensor.js"),m=n(/*! ./utils/maths.js */"./src/utils/maths.js"),_=n(/*! ./generation/streamers.js */"./src/generation/streamers.js"),f=n(/*! ./generation/stopping_criteria.js */"./src/generation/stopping_criteria.js"),g=o.ASTFeatureExtractor,M=o.ASTForAudioClassification,w=o.ASTModel,T=o.ASTPreTrainedModel,b=o.AlbertForMaskedLM,x=o.AlbertForQuestionAnswering,k=o.AlbertForSequenceClassification,y=o.AlbertModel,F=o.AlbertPreTrainedModel,P=o.AlbertTokenizer,C=o.AudioClassificationPipeline,v=o.AutoConfig,S=o.AutoModel,A=o.AutoModelForAudioClassification,E=o.AutoModelForAudioFrameClassification,L=o.AutoModelForCTC,z=o.AutoModelForCausalLM,I=o.AutoModelForDepthEstimation,B=o.AutoModelForDocumentQuestionAnswering,N=o.AutoModelForImageClassification,O=o.AutoModelForImageFeatureExtraction,D=o.AutoModelForImageMatting,V=o.AutoModelForImageSegmentation,j=o.AutoModelForImageToImage,R=o.AutoModelForMaskGeneration,G=o.AutoModelForMaskedLM,q=o.AutoModelForNormalEstimation,$=o.AutoModelForObjectDetection,W=o.AutoModelForQuestionAnswering,U=o.AutoModelForSemanticSegmentation,X=o.AutoModelForSeq2SeqLM,Q=o.AutoModelForSequenceClassification,H=o.AutoModelForSpeechSeq2Seq,Y=o.AutoModelForTextToSpectrogram,J=o.AutoModelForTextToWaveform,K=o.AutoModelForTokenClassification,Z=o.AutoModelForUniversalSegmentation,ee=o.AutoModelForVision2Seq,te=o.AutoModelForXVector,re=o.AutoModelForZeroShotObjectDetection,ne=o.AutoProcessor,oe=o.AutoTokenizer,se=o.AutomaticSpeechRecognitionPipeline,ae=o.BartForConditionalGeneration,ie=o.BartForSequenceClassification,le=o.BartModel,ce=o.BartPretrainedModel,de=o.BartTokenizer,ue=o.BaseModelOutput,pe=o.BaseStreamer,he=o.BeitFeatureExtractor,me=o.BeitForImageClassification,_e=o.BeitModel,fe=o.BeitPreTrainedModel,ge=o.BertForMaskedLM,Me=o.BertForQuestionAnswering,we=o.BertForSequenceClassification,Te=o.BertForTokenClassification,be=o.BertModel,xe=o.BertPreTrainedModel,ke=o.BertTokenizer,ye=o.BitImageProcessor,Fe=o.BlenderbotForConditionalGeneration,Pe=o.BlenderbotModel,Ce=o.BlenderbotPreTrainedModel,ve=o.BlenderbotSmallForConditionalGeneration,Se=o.BlenderbotSmallModel,Ae=o.BlenderbotSmallPreTrainedModel,Ee=o.BlenderbotSmallTokenizer,Le=o.BlenderbotTokenizer,ze=o.BloomForCausalLM,Ie=o.BloomModel,Be=o.BloomPreTrainedModel,Ne=o.BloomTokenizer,Oe=o.CLIPFeatureExtractor,De=o.CLIPImageProcessor,Ve=o.CLIPModel,je=o.CLIPPreTrainedModel,Re=o.CLIPSegForImageSegmentation,Ge=o.CLIPSegModel,qe=o.CLIPSegPreTrainedModel,$e=o.CLIPTextModel,We=o.CLIPTextModelWithProjection,Ue=o.CLIPTokenizer,Xe=o.CLIPVisionModel,Qe=o.CLIPVisionModelWithProjection,He=o.CamembertForMaskedLM,Ye=o.CamembertForQuestionAnswering,Je=o.CamembertForSequenceClassification,Ke=o.CamembertForTokenClassification,Ze=o.CamembertModel,et=o.CamembertPreTrainedModel,tt=o.CamembertTokenizer,rt=o.CausalLMOutput,nt=o.CausalLMOutputWithPast,ot=o.ChineseCLIPFeatureExtractor,st=o.ChineseCLIPModel,at=o.ChineseCLIPPreTrainedModel,it=o.ClapAudioModelWithProjection,lt=o.ClapFeatureExtractor,ct=o.ClapModel,dt=o.ClapPreTrainedModel,ut=o.ClapTextModelWithProjection,pt=o.CodeGenForCausalLM,ht=o.CodeGenModel,mt=o.CodeGenPreTrainedModel,_t=o.CodeGenTokenizer,ft=o.CodeLlamaTokenizer,gt=o.CohereForCausalLM,Mt=o.CohereModel,wt=o.CoherePreTrainedModel,Tt=o.CohereTokenizer,bt=o.ConvBertForMaskedLM,xt=o.ConvBertForQuestionAnswering,kt=o.ConvBertForSequenceClassification,yt=o.ConvBertForTokenClassification,Ft=o.ConvBertModel,Pt=o.ConvBertPreTrainedModel,Ct=o.ConvBertTokenizer,vt=o.ConvNextFeatureExtractor,St=o.ConvNextForImageClassification,At=o.ConvNextImageProcessor,Et=o.ConvNextModel,Lt=o.ConvNextPreTrainedModel,zt=o.ConvNextV2ForImageClassification,It=o.ConvNextV2Model,Bt=o.ConvNextV2PreTrainedModel,Nt=o.DPTFeatureExtractor,Ot=o.DPTForDepthEstimation,Dt=o.DPTImageProcessor,Vt=o.DPTModel,jt=o.DPTPreTrainedModel,Rt=o.DebertaForMaskedLM,Gt=o.DebertaForQuestionAnswering,qt=o.DebertaForSequenceClassification,$t=o.DebertaForTokenClassification,Wt=o.DebertaModel,Ut=o.DebertaPreTrainedModel,Xt=o.DebertaTokenizer,Qt=o.DebertaV2ForMaskedLM,Ht=o.DebertaV2ForQuestionAnswering,Yt=o.DebertaV2ForSequenceClassification,Jt=o.DebertaV2ForTokenClassification,Kt=o.DebertaV2Model,Zt=o.DebertaV2PreTrainedModel,er=o.DebertaV2Tokenizer,tr=o.DecisionTransformerModel,rr=o.DecisionTransformerPreTrainedModel,nr=o.DeiTFeatureExtractor,or=o.DeiTForImageClassification,sr=o.DeiTModel,ar=o.DeiTPreTrainedModel,ir=o.DepthAnythingForDepthEstimation,lr=o.DepthAnythingPreTrainedModel,cr=o.DepthEstimationPipeline,dr=o.DetrFeatureExtractor,ur=o.DetrForObjectDetection,pr=o.DetrForSegmentation,hr=o.DetrModel,mr=o.DetrObjectDetectionOutput,_r=o.DetrPreTrainedModel,fr=o.DetrSegmentationOutput,gr=o.Dinov2ForImageClassification,Mr=o.Dinov2Model,wr=o.Dinov2PreTrainedModel,Tr=o.DistilBertForMaskedLM,br=o.DistilBertForQuestionAnswering,xr=o.DistilBertForSequenceClassification,kr=o.DistilBertForTokenClassification,yr=o.DistilBertModel,Fr=o.DistilBertPreTrainedModel,Pr=o.DistilBertTokenizer,Cr=o.DocumentQuestionAnsweringPipeline,vr=o.DonutFeatureExtractor,Sr=o.DonutSwinModel,Ar=o.DonutSwinPreTrainedModel,Er=o.EfficientNetForImageClassification,Lr=o.EfficientNetImageProcessor,zr=o.EfficientNetModel,Ir=o.EfficientNetPreTrainedModel,Br=o.ElectraForMaskedLM,Nr=o.ElectraForQuestionAnswering,Or=o.ElectraForSequenceClassification,Dr=o.ElectraForTokenClassification,Vr=o.ElectraModel,jr=o.ElectraPreTrainedModel,Rr=o.ElectraTokenizer,Gr=o.EosTokenCriteria,qr=o.EsmForMaskedLM,$r=o.EsmForSequenceClassification,Wr=o.EsmForTokenClassification,Ur=o.EsmModel,Xr=o.EsmPreTrainedModel,Qr=o.EsmTokenizer,Hr=o.FFT,Yr=o.FalconForCausalLM,Jr=o.FalconModel,Kr=o.FalconPreTrainedModel,Zr=o.FalconTokenizer,en=o.FastViTForImageClassification,tn=o.FastViTModel,rn=o.FastViTPreTrainedModel,nn=o.FeatureExtractionPipeline,on=o.FeatureExtractor,sn=o.FillMaskPipeline,an=o.Florence2ForConditionalGeneration,ln=o.Florence2PreTrainedModel,cn=o.Florence2Processor,dn=o.GLPNFeatureExtractor,un=o.GLPNForDepthEstimation,pn=o.GLPNModel,hn=o.GLPNPreTrainedModel,mn=o.GPT2LMHeadModel,_n=o.GPT2Model,fn=o.GPT2PreTrainedModel,gn=o.GPT2Tokenizer,Mn=o.GPTBigCodeForCausalLM,wn=o.GPTBigCodeModel,Tn=o.GPTBigCodePreTrainedModel,bn=o.GPTJForCausalLM,xn=o.GPTJModel,kn=o.GPTJPreTrainedModel,yn=o.GPTNeoForCausalLM,Fn=o.GPTNeoModel,Pn=o.GPTNeoPreTrainedModel,Cn=o.GPTNeoXForCausalLM,vn=o.GPTNeoXModel,Sn=o.GPTNeoXPreTrainedModel,An=o.GPTNeoXTokenizer,En=o.Gemma2ForCausalLM,Ln=o.Gemma2Model,zn=o.Gemma2PreTrainedModel,In=o.GemmaForCausalLM,Bn=o.GemmaModel,Nn=o.GemmaPreTrainedModel,On=o.GemmaTokenizer,Dn=o.Grok1Tokenizer,Vn=o.GroupViTModel,jn=o.GroupViTPreTrainedModel,Rn=o.HerbertTokenizer,Gn=o.HieraForImageClassification,qn=o.HieraModel,$n=o.HieraPreTrainedModel,Wn=o.HubertForCTC,Un=o.HubertForSequenceClassification,Xn=o.HubertModel,Qn=o.HubertPreTrainedModel,Hn=o.ImageClassificationPipeline,Yn=o.ImageFeatureExtractionPipeline,Jn=o.ImageFeatureExtractor,Kn=o.ImageMattingOutput,Zn=o.ImageSegmentationPipeline,eo=o.ImageToImagePipeline,to=o.ImageToTextPipeline,ro=o.InterruptableStoppingCriteria,no=o.JAISLMHeadModel,oo=o.JAISModel,so=o.JAISPreTrainedModel,ao=o.LlamaForCausalLM,io=o.LlamaModel,lo=o.LlamaPreTrainedModel,co=o.LlamaTokenizer,uo=o.LlavaForConditionalGeneration,po=o.LlavaPreTrainedModel,ho=o.LongT5ForConditionalGeneration,mo=o.LongT5Model,_o=o.LongT5PreTrainedModel,fo=o.M2M100ForConditionalGeneration,go=o.M2M100Model,Mo=o.M2M100PreTrainedModel,wo=o.M2M100Tokenizer,To=o.MBart50Tokenizer,bo=o.MBartForCausalLM,xo=o.MBartForConditionalGeneration,ko=o.MBartForSequenceClassification,yo=o.MBartModel,Fo=o.MBartPreTrainedModel,Po=o.MBartTokenizer,Co=o.MPNetForMaskedLM,vo=o.MPNetForQuestionAnswering,So=o.MPNetForSequenceClassification,Ao=o.MPNetForTokenClassification,Eo=o.MPNetModel,Lo=o.MPNetPreTrainedModel,zo=o.MPNetTokenizer,Io=o.MT5ForConditionalGeneration,Bo=o.MT5Model,No=o.MT5PreTrainedModel,Oo=o.MarianMTModel,Do=o.MarianModel,Vo=o.MarianPreTrainedModel,jo=o.MarianTokenizer,Ro=o.MaskFormerFeatureExtractor,Go=o.MaskFormerForInstanceSegmentation,qo=o.MaskFormerModel,$o=o.MaskFormerPreTrainedModel,Wo=o.MaskedLMOutput,Uo=o.MaxLengthCriteria,Xo=o.MistralForCausalLM,Qo=o.MistralModel,Ho=o.MistralPreTrainedModel,Yo=o.MobileBertForMaskedLM,Jo=o.MobileBertForQuestionAnswering,Ko=o.MobileBertForSequenceClassification,Zo=o.MobileBertModel,es=o.MobileBertPreTrainedModel,ts=o.MobileBertTokenizer,rs=o.MobileNetV1FeatureExtractor,ns=o.MobileNetV1ForImageClassification,os=o.MobileNetV1Model,ss=o.MobileNetV1PreTrainedModel,as=o.MobileNetV2FeatureExtractor,is=o.MobileNetV2ForImageClassification,ls=o.MobileNetV2Model,cs=o.MobileNetV2PreTrainedModel,ds=o.MobileNetV3FeatureExtractor,us=o.MobileNetV3ForImageClassification,ps=o.MobileNetV3Model,hs=o.MobileNetV3PreTrainedModel,ms=o.MobileNetV4FeatureExtractor,_s=o.MobileNetV4ForImageClassification,fs=o.MobileNetV4Model,gs=o.MobileNetV4PreTrainedModel,Ms=o.MobileViTFeatureExtractor,ws=o.MobileViTForImageClassification,Ts=o.MobileViTImageProcessor,bs=o.MobileViTModel,xs=o.MobileViTPreTrainedModel,ks=o.MobileViTV2ForImageClassification,ys=o.MobileViTV2Model,Fs=o.MobileViTV2PreTrainedModel,Ps=o.ModelOutput,Cs=o.Moondream1ForConditionalGeneration,vs=o.MptForCausalLM,Ss=o.MptModel,As=o.MptPreTrainedModel,Es=o.MusicgenForCausalLM,Ls=o.MusicgenForConditionalGeneration,zs=o.MusicgenModel,Is=o.MusicgenPreTrainedModel,Bs=o.NllbTokenizer,Ns=o.NomicBertModel,Os=o.NomicBertPreTrainedModel,Ds=o.NougatImageProcessor,Vs=o.NougatTokenizer,js=o.OPTForCausalLM,Rs=o.OPTModel,Gs=o.OPTPreTrainedModel,qs=o.ObjectDetectionPipeline,$s=o.OpenELMForCausalLM,Ws=o.OpenELMModel,Us=o.OpenELMPreTrainedModel,Xs=o.OwlViTFeatureExtractor,Qs=o.OwlViTForObjectDetection,Hs=o.OwlViTModel,Ys=o.OwlViTPreTrainedModel,Js=o.OwlViTProcessor,Ks=o.Owlv2ForObjectDetection,Zs=o.Owlv2ImageProcessor,ea=o.Owlv2Model,ta=o.Owlv2PreTrainedModel,ra=o.Phi3ForCausalLM,na=o.Phi3Model,oa=o.Phi3PreTrainedModel,sa=o.PhiForCausalLM,aa=o.PhiModel,ia=o.PhiPreTrainedModel,la=o.Pipeline,ca=o.PreTrainedModel,da=o.PreTrainedTokenizer,ua=o.PretrainedConfig,pa=o.PretrainedMixin,ha=o.Processor,ma=o.PvtForImageClassification,_a=o.PvtImageProcessor,fa=o.PvtModel,ga=o.PvtPreTrainedModel,Ma=o.PyAnnoteFeatureExtractor,wa=o.PyAnnoteForAudioFrameClassification,Ta=o.PyAnnoteModel,ba=o.PyAnnotePreTrainedModel,xa=o.PyAnnoteProcessor,ka=o.QuestionAnsweringModelOutput,ya=o.QuestionAnsweringPipeline,Fa=o.Qwen2ForCausalLM,Pa=o.Qwen2Model,Ca=o.Qwen2PreTrainedModel,va=o.Qwen2Tokenizer,Sa=o.RTDetrForObjectDetection,Aa=o.RTDetrImageProcessor,Ea=o.RTDetrModel,La=o.RTDetrObjectDetectionOutput,za=o.RTDetrPreTrainedModel,Ia=o.RawImage,Ba=o.ResNetForImageClassification,Na=o.ResNetModel,Oa=o.ResNetPreTrainedModel,Da=o.RoFormerForMaskedLM,Va=o.RoFormerForQuestionAnswering,ja=o.RoFormerForSequenceClassification,Ra=o.RoFormerForTokenClassification,Ga=o.RoFormerModel,qa=o.RoFormerPreTrainedModel,$a=o.RoFormerTokenizer,Wa=o.RobertaForMaskedLM,Ua=o.RobertaForQuestionAnswering,Xa=o.RobertaForSequenceClassification,Qa=o.RobertaForTokenClassification,Ha=o.RobertaModel,Ya=o.RobertaPreTrainedModel,Ja=o.RobertaTokenizer,Ka=o.SamImageProcessor,Za=o.SamImageSegmentationOutput,ei=o.SamModel,ti=o.SamPreTrainedModel,ri=o.SamProcessor,ni=o.SapiensFeatureExtractor,oi=o.SapiensForDepthEstimation,si=o.SapiensForNormalEstimation,ai=o.SapiensForSemanticSegmentation,ii=o.SapiensPreTrainedModel,li=o.SeamlessM4TFeatureExtractor,ci=o.SegformerFeatureExtractor,di=o.SegformerForImageClassification,ui=o.SegformerForSemanticSegmentation,pi=o.SegformerModel,hi=o.SegformerPreTrainedModel,mi=o.Seq2SeqLMOutput,_i=o.SequenceClassifierOutput,fi=o.SiglipImageProcessor,gi=o.SiglipModel,Mi=o.SiglipPreTrainedModel,wi=o.SiglipTextModel,Ti=o.SiglipTokenizer,bi=o.SiglipVisionModel,xi=o.SpeechT5FeatureExtractor,ki=o.SpeechT5ForSpeechToText,yi=o.SpeechT5ForTextToSpeech,Fi=o.SpeechT5HifiGan,Pi=o.SpeechT5Model,Ci=o.SpeechT5PreTrainedModel,vi=o.SpeechT5Processor,Si=o.SpeechT5Tokenizer,Ai=o.SqueezeBertForMaskedLM,Ei=o.SqueezeBertForQuestionAnswering,Li=o.SqueezeBertForSequenceClassification,zi=o.SqueezeBertModel,Ii=o.SqueezeBertPreTrainedModel,Bi=o.SqueezeBertTokenizer,Ni=o.StableLmForCausalLM,Oi=o.StableLmModel,Di=o.StableLmPreTrainedModel,Vi=o.Starcoder2ForCausalLM,ji=o.Starcoder2Model,Ri=o.Starcoder2PreTrainedModel,Gi=o.StoppingCriteria,qi=o.StoppingCriteriaList,$i=o.SummarizationPipeline,Wi=o.Swin2SRForImageSuperResolution,Ui=o.Swin2SRImageProcessor,Xi=o.Swin2SRModel,Qi=o.Swin2SRPreTrainedModel,Hi=o.SwinForImageClassification,Yi=o.SwinModel,Ji=o.SwinPreTrainedModel,Ki=o.T5ForConditionalGeneration,Zi=o.T5Model,el=o.T5PreTrainedModel,tl=o.T5Tokenizer,rl=o.TableTransformerForObjectDetection,nl=o.TableTransformerModel,ol=o.TableTransformerObjectDetectionOutput,sl=o.TableTransformerPreTrainedModel,al=o.Tensor,il=o.Text2TextGenerationPipeline,ll=o.TextClassificationPipeline,cl=o.TextGenerationPipeline,dl=o.TextStreamer,ul=o.TextToAudioPipeline,pl=o.TokenClassificationPipeline,hl=o.TokenClassifierOutput,ml=o.TokenizerModel,_l=o.TrOCRForCausalLM,fl=o.TrOCRPreTrainedModel,gl=o.TranslationPipeline,Ml=o.UniSpeechForCTC,wl=o.UniSpeechForSequenceClassification,Tl=o.UniSpeechModel,bl=o.UniSpeechPreTrainedModel,xl=o.UniSpeechSatForAudioFrameClassification,kl=o.UniSpeechSatForCTC,yl=o.UniSpeechSatForSequenceClassification,Fl=o.UniSpeechSatModel,Pl=o.UniSpeechSatPreTrainedModel,Cl=o.ViTFeatureExtractor,vl=o.ViTForImageClassification,Sl=o.ViTImageProcessor,Al=o.ViTMAEModel,El=o.ViTMAEPreTrainedModel,Ll=o.ViTMSNForImageClassification,zl=o.ViTMSNModel,Il=o.ViTMSNPreTrainedModel,Bl=o.ViTModel,Nl=o.ViTPreTrainedModel,Ol=o.VisionEncoderDecoderModel,Dl=o.VitMatteForImageMatting,Vl=o.VitMatteImageProcessor,jl=o.VitMattePreTrainedModel,Rl=o.VitsModel,Gl=o.VitsModelOutput,ql=o.VitsPreTrainedModel,$l=o.VitsTokenizer,Wl=o.Wav2Vec2BertForCTC,Ul=o.Wav2Vec2BertForSequenceClassification,Xl=o.Wav2Vec2BertModel,Ql=o.Wav2Vec2BertPreTrainedModel,Hl=o.Wav2Vec2CTCTokenizer,Yl=o.Wav2Vec2FeatureExtractor,Jl=o.Wav2Vec2ForAudioFrameClassification,Kl=o.Wav2Vec2ForCTC,Zl=o.Wav2Vec2ForSequenceClassification,ec=o.Wav2Vec2Model,tc=o.Wav2Vec2PreTrainedModel,rc=o.Wav2Vec2ProcessorWithLM,nc=o.WavLMForAudioFrameClassification,oc=o.WavLMForCTC,sc=o.WavLMForSequenceClassification,ac=o.WavLMForXVector,ic=o.WavLMModel,lc=o.WavLMPreTrainedModel,cc=o.WeSpeakerFeatureExtractor,dc=o.WeSpeakerResNetModel,uc=o.WeSpeakerResNetPreTrainedModel,pc=o.WhisperFeatureExtractor,hc=o.WhisperForConditionalGeneration,mc=o.WhisperModel,_c=o.WhisperPreTrainedModel,fc=o.WhisperProcessor,gc=o.WhisperTextStreamer,Mc=o.WhisperTokenizer,wc=o.XLMForQuestionAnswering,Tc=o.XLMForSequenceClassification,bc=o.XLMForTokenClassification,xc=o.XLMModel,kc=o.XLMPreTrainedModel,yc=o.XLMRobertaForMaskedLM,Fc=o.XLMRobertaForQuestionAnswering,Pc=o.XLMRobertaForSequenceClassification,Cc=o.XLMRobertaForTokenClassification,vc=o.XLMRobertaModel,Sc=o.XLMRobertaPreTrainedModel,Ac=o.XLMRobertaTokenizer,Ec=o.XLMTokenizer,Lc=o.XLMWithLMHeadModel,zc=o.XVectorOutput,Ic=o.YolosFeatureExtractor,Bc=o.YolosForObjectDetection,Nc=o.YolosModel,Oc=o.YolosObjectDetectionOutput,Dc=o.YolosPreTrainedModel,Vc=o.ZeroShotAudioClassificationPipeline,jc=o.ZeroShotClassificationPipeline,Rc=o.ZeroShotImageClassificationPipeline,Gc=o.ZeroShotObjectDetectionPipeline,qc=o.bankers_round,$c=o.cat,Wc=o.cos_sim,Uc=o.dot,Xc=o.dynamic_time_warping,Qc=o.env,Hc=o.full,Yc=o.full_like,Jc=o.getKeyValueShapes,Kc=o.hamming,Zc=o.hanning,ed=o.interpolate,td=o.interpolate_4d,rd=o.interpolate_data,nd=o.is_chinese_char,od=o.layer_norm,sd=o.log_softmax,ad=o.magnitude,id=o.matmul,ld=o.max,cd=o.mean,dd=o.mean_pooling,ud=o.medianFilter,pd=o.mel_filter_bank,hd=o.min,md=o.ones,_d=o.ones_like,fd=o.permute,gd=o.permute_data,Md=o.pipeline,wd=o.quantize_embeddings,Td=o.read_audio,bd=o.rfft,xd=o.round,kd=o.softmax,yd=o.spectrogram,Fd=o.stack,Pd=o.std_mean,Cd=o.topk,vd=o.window_function,Sd=o.zeros,Ad=o.zeros_like;export{g as ASTFeatureExtractor,M as ASTForAudioClassification,w as ASTModel,T as ASTPreTrainedModel,b as AlbertForMaskedLM,x as AlbertForQuestionAnswering,k as AlbertForSequenceClassification,y as AlbertModel,F as AlbertPreTrainedModel,P as AlbertTokenizer,C as AudioClassificationPipeline,v as AutoConfig,S as AutoModel,A as AutoModelForAudioClassification,E as AutoModelForAudioFrameClassification,L as AutoModelForCTC,z as AutoModelForCausalLM,I as AutoModelForDepthEstimation,B as AutoModelForDocumentQuestionAnswering,N as AutoModelForImageClassification,O as AutoModelForImageFeatureExtraction,D as AutoModelForImageMatting,V as AutoModelForImageSegmentation,j as AutoModelForImageToImage,R as AutoModelForMaskGeneration,G as AutoModelForMaskedLM,q as AutoModelForNormalEstimation,$ as AutoModelForObjectDetection,W as AutoModelForQuestionAnswering,U as AutoModelForSemanticSegmentation,X as AutoModelForSeq2SeqLM,Q as AutoModelForSequenceClassification,H as AutoModelForSpeechSeq2Seq,Y as AutoModelForTextToSpectrogram,J as AutoModelForTextToWaveform,K as AutoModelForTokenClassification,Z as AutoModelForUniversalSegmentation,ee as AutoModelForVision2Seq,te as AutoModelForXVector,re as AutoModelForZeroShotObjectDetection,ne as AutoProcessor,oe as AutoTokenizer,se as AutomaticSpeechRecognitionPipeline,ae as BartForConditionalGeneration,ie as BartForSequenceClassification,le as BartModel,ce as BartPretrainedModel,de as BartTokenizer,ue as BaseModelOutput,pe as BaseStreamer,he as BeitFeatureExtractor,me as BeitForImageClassification,_e as BeitModel,fe as BeitPreTrainedModel,ge as BertForMaskedLM,Me as BertForQuestionAnswering,we as BertForSequenceClassification,Te as BertForTokenClassification,be as BertModel,xe as BertPreTrainedModel,ke as BertTokenizer,ye as BitImageProcessor,Fe as BlenderbotForConditionalGeneration,Pe as BlenderbotModel,Ce as BlenderbotPreTrainedModel,ve as BlenderbotSmallForConditionalGeneration,Se as BlenderbotSmallModel,Ae as BlenderbotSmallPreTrainedModel,Ee as BlenderbotSmallTokenizer,Le as BlenderbotTokenizer,ze as BloomForCausalLM,Ie as BloomModel,Be as BloomPreTrainedModel,Ne as BloomTokenizer,Oe as CLIPFeatureExtractor,De as CLIPImageProcessor,Ve as CLIPModel,je as CLIPPreTrainedModel,Re as CLIPSegForImageSegmentation,Ge as CLIPSegModel,qe as CLIPSegPreTrainedModel,$e as CLIPTextModel,We as CLIPTextModelWithProjection,Ue as CLIPTokenizer,Xe as CLIPVisionModel,Qe as CLIPVisionModelWithProjection,He as CamembertForMaskedLM,Ye as CamembertForQuestionAnswering,Je as CamembertForSequenceClassification,Ke as CamembertForTokenClassification,Ze as CamembertModel,et as CamembertPreTrainedModel,tt as CamembertTokenizer,rt as CausalLMOutput,nt as CausalLMOutputWithPast,ot as ChineseCLIPFeatureExtractor,st as ChineseCLIPModel,at as ChineseCLIPPreTrainedModel,it as ClapAudioModelWithProjection,lt as ClapFeatureExtractor,ct as ClapModel,dt as ClapPreTrainedModel,ut as ClapTextModelWithProjection,pt as CodeGenForCausalLM,ht as CodeGenModel,mt as CodeGenPreTrainedModel,_t as CodeGenTokenizer,ft as CodeLlamaTokenizer,gt as CohereForCausalLM,Mt as CohereModel,wt as CoherePreTrainedModel,Tt as CohereTokenizer,bt as ConvBertForMaskedLM,xt as ConvBertForQuestionAnswering,kt as ConvBertForSequenceClassification,yt as ConvBertForTokenClassification,Ft as ConvBertModel,Pt as ConvBertPreTrainedModel,Ct as ConvBertTokenizer,vt as ConvNextFeatureExtractor,St as ConvNextForImageClassification,At as ConvNextImageProcessor,Et as ConvNextModel,Lt as ConvNextPreTrainedModel,zt as ConvNextV2ForImageClassification,It as ConvNextV2Model,Bt as ConvNextV2PreTrainedModel,Nt as DPTFeatureExtractor,Ot as DPTForDepthEstimation,Dt as DPTImageProcessor,Vt as DPTModel,jt as DPTPreTrainedModel,Rt as DebertaForMaskedLM,Gt as DebertaForQuestionAnswering,qt as DebertaForSequenceClassification,$t as DebertaForTokenClassification,Wt as DebertaModel,Ut as DebertaPreTrainedModel,Xt as DebertaTokenizer,Qt as DebertaV2ForMaskedLM,Ht as DebertaV2ForQuestionAnswering,Yt as DebertaV2ForSequenceClassification,Jt as DebertaV2ForTokenClassification,Kt as DebertaV2Model,Zt as DebertaV2PreTrainedModel,er as DebertaV2Tokenizer,tr as DecisionTransformerModel,rr as DecisionTransformerPreTrainedModel,nr as DeiTFeatureExtractor,or as DeiTForImageClassification,sr as DeiTModel,ar as DeiTPreTrainedModel,ir as DepthAnythingForDepthEstimation,lr as DepthAnythingPreTrainedModel,cr as DepthEstimationPipeline,dr as DetrFeatureExtractor,ur as DetrForObjectDetection,pr as DetrForSegmentation,hr as DetrModel,mr as DetrObjectDetectionOutput,_r as DetrPreTrainedModel,fr as DetrSegmentationOutput,gr as Dinov2ForImageClassification,Mr as Dinov2Model,wr as Dinov2PreTrainedModel,Tr as DistilBertForMaskedLM,br as DistilBertForQuestionAnswering,xr as DistilBertForSequenceClassification,kr as DistilBertForTokenClassification,yr as DistilBertModel,Fr as DistilBertPreTrainedModel,Pr as DistilBertTokenizer,Cr as DocumentQuestionAnsweringPipeline,vr as DonutFeatureExtractor,Sr as DonutSwinModel,Ar as DonutSwinPreTrainedModel,Er as EfficientNetForImageClassification,Lr as EfficientNetImageProcessor,zr as EfficientNetModel,Ir as EfficientNetPreTrainedModel,Br as ElectraForMaskedLM,Nr as ElectraForQuestionAnswering,Or as ElectraForSequenceClassification,Dr as ElectraForTokenClassification,Vr as ElectraModel,jr as ElectraPreTrainedModel,Rr as ElectraTokenizer,Gr as EosTokenCriteria,qr as EsmForMaskedLM,$r as EsmForSequenceClassification,Wr as EsmForTokenClassification,Ur as EsmModel,Xr as EsmPreTrainedModel,Qr as EsmTokenizer,Hr as FFT,Yr as FalconForCausalLM,Jr as FalconModel,Kr as FalconPreTrainedModel,Zr as FalconTokenizer,en as FastViTForImageClassification,tn as FastViTModel,rn as FastViTPreTrainedModel,nn as FeatureExtractionPipeline,on as FeatureExtractor,sn as FillMaskPipeline,an as Florence2ForConditionalGeneration,ln as Florence2PreTrainedModel,cn as Florence2Processor,dn as GLPNFeatureExtractor,un as GLPNForDepthEstimation,pn as GLPNModel,hn as GLPNPreTrainedModel,mn as GPT2LMHeadModel,_n as GPT2Model,fn as GPT2PreTrainedModel,gn as GPT2Tokenizer,Mn as GPTBigCodeForCausalLM,wn as GPTBigCodeModel,Tn as GPTBigCodePreTrainedModel,bn as GPTJForCausalLM,xn as GPTJModel,kn as GPTJPreTrainedModel,yn as GPTNeoForCausalLM,Fn as GPTNeoModel,Pn as GPTNeoPreTrainedModel,Cn as GPTNeoXForCausalLM,vn as GPTNeoXModel,Sn as GPTNeoXPreTrainedModel,An as GPTNeoXTokenizer,En as Gemma2ForCausalLM,Ln as Gemma2Model,zn as Gemma2PreTrainedModel,In as GemmaForCausalLM,Bn as GemmaModel,Nn as GemmaPreTrainedModel,On as GemmaTokenizer,Dn as Grok1Tokenizer,Vn as GroupViTModel,jn as GroupViTPreTrainedModel,Rn as HerbertTokenizer,Gn as HieraForImageClassification,qn as HieraModel,$n as HieraPreTrainedModel,Wn as HubertForCTC,Un as HubertForSequenceClassification,Xn as HubertModel,Qn as HubertPreTrainedModel,Hn as ImageClassificationPipeline,Yn as ImageFeatureExtractionPipeline,Jn as ImageFeatureExtractor,Kn as ImageMattingOutput,Zn as ImageSegmentationPipeline,eo as ImageToImagePipeline,to as ImageToTextPipeline,ro as InterruptableStoppingCriteria,no as JAISLMHeadModel,oo as JAISModel,so as JAISPreTrainedModel,ao as LlamaForCausalLM,io as LlamaModel,lo as LlamaPreTrainedModel,co as LlamaTokenizer,uo as LlavaForConditionalGeneration,po as LlavaPreTrainedModel,ho as LongT5ForConditionalGeneration,mo as LongT5Model,_o as LongT5PreTrainedModel,fo as M2M100ForConditionalGeneration,go as M2M100Model,Mo as M2M100PreTrainedModel,wo as M2M100Tokenizer,To as MBart50Tokenizer,bo as MBartForCausalLM,xo as MBartForConditionalGeneration,ko as MBartForSequenceClassification,yo as MBartModel,Fo as MBartPreTrainedModel,Po as MBartTokenizer,Co as MPNetForMaskedLM,vo as MPNetForQuestionAnswering,So as MPNetForSequenceClassification,Ao as MPNetForTokenClassification,Eo as MPNetModel,Lo as MPNetPreTrainedModel,zo as MPNetTokenizer,Io as MT5ForConditionalGeneration,Bo as MT5Model,No as MT5PreTrainedModel,Oo as MarianMTModel,Do as MarianModel,Vo as MarianPreTrainedModel,jo as MarianTokenizer,Ro as MaskFormerFeatureExtractor,Go as MaskFormerForInstanceSegmentation,qo as MaskFormerModel,$o as MaskFormerPreTrainedModel,Wo as MaskedLMOutput,Uo as MaxLengthCriteria,Xo as MistralForCausalLM,Qo as MistralModel,Ho as MistralPreTrainedModel,Yo as MobileBertForMaskedLM,Jo as MobileBertForQuestionAnswering,Ko as MobileBertForSequenceClassification,Zo as MobileBertModel,es as MobileBertPreTrainedModel,ts as MobileBertTokenizer,rs as MobileNetV1FeatureExtractor,ns as MobileNetV1ForImageClassification,os as MobileNetV1Model,ss as MobileNetV1PreTrainedModel,as as MobileNetV2FeatureExtractor,is as MobileNetV2ForImageClassification,ls as MobileNetV2Model,cs as MobileNetV2PreTrainedModel,ds as MobileNetV3FeatureExtractor,us as MobileNetV3ForImageClassification,ps as MobileNetV3Model,hs as MobileNetV3PreTrainedModel,ms as MobileNetV4FeatureExtractor,_s as MobileNetV4ForImageClassification,fs as MobileNetV4Model,gs as MobileNetV4PreTrainedModel,Ms as MobileViTFeatureExtractor,ws as MobileViTForImageClassification,Ts as MobileViTImageProcessor,bs as MobileViTModel,xs as MobileViTPreTrainedModel,ks as MobileViTV2ForImageClassification,ys as MobileViTV2Model,Fs as MobileViTV2PreTrainedModel,Ps as ModelOutput,Cs as Moondream1ForConditionalGeneration,vs as MptForCausalLM,Ss as MptModel,As as MptPreTrainedModel,Es as MusicgenForCausalLM,Ls as MusicgenForConditionalGeneration,zs as MusicgenModel,Is as MusicgenPreTrainedModel,Bs as NllbTokenizer,Ns as NomicBertModel,Os as NomicBertPreTrainedModel,Ds as NougatImageProcessor,Vs as NougatTokenizer,js as OPTForCausalLM,Rs as OPTModel,Gs as OPTPreTrainedModel,qs as ObjectDetectionPipeline,$s as OpenELMForCausalLM,Ws as OpenELMModel,Us as OpenELMPreTrainedModel,Xs as OwlViTFeatureExtractor,Qs as OwlViTForObjectDetection,Hs as OwlViTModel,Ys as OwlViTPreTrainedModel,Js as OwlViTProcessor,Ks as Owlv2ForObjectDetection,Zs as Owlv2ImageProcessor,ea as Owlv2Model,ta as Owlv2PreTrainedModel,ra as Phi3ForCausalLM,na as Phi3Model,oa as Phi3PreTrainedModel,sa as PhiForCausalLM,aa as PhiModel,ia as PhiPreTrainedModel,la as Pipeline,ca as PreTrainedModel,da as PreTrainedTokenizer,ua as PretrainedConfig,pa as PretrainedMixin,ha as Processor,ma as PvtForImageClassification,_a as PvtImageProcessor,fa as PvtModel,ga as PvtPreTrainedModel,Ma as PyAnnoteFeatureExtractor,wa as PyAnnoteForAudioFrameClassification,Ta as PyAnnoteModel,ba as PyAnnotePreTrainedModel,xa as PyAnnoteProcessor,ka as QuestionAnsweringModelOutput,ya as QuestionAnsweringPipeline,Fa as Qwen2ForCausalLM,Pa as Qwen2Model,Ca as Qwen2PreTrainedModel,va as Qwen2Tokenizer,Sa as RTDetrForObjectDetection,Aa as RTDetrImageProcessor,Ea as RTDetrModel,La as RTDetrObjectDetectionOutput,za as RTDetrPreTrainedModel,Ia as RawImage,Ba as ResNetForImageClassification,Na as ResNetModel,Oa as ResNetPreTrainedModel,Da as RoFormerForMaskedLM,Va as RoFormerForQuestionAnswering,ja as RoFormerForSequenceClassification,Ra as RoFormerForTokenClassification,Ga as RoFormerModel,qa as RoFormerPreTrainedModel,$a as RoFormerTokenizer,Wa as RobertaForMaskedLM,Ua as RobertaForQuestionAnswering,Xa as RobertaForSequenceClassification,Qa as RobertaForTokenClassification,Ha as RobertaModel,Ya as RobertaPreTrainedModel,Ja as RobertaTokenizer,Ka as SamImageProcessor,Za as SamImageSegmentationOutput,ei as SamModel,ti as SamPreTrainedModel,ri as SamProcessor,ni as SapiensFeatureExtractor,oi as SapiensForDepthEstimation,si as SapiensForNormalEstimation,ai as SapiensForSemanticSegmentation,ii as SapiensPreTrainedModel,li as SeamlessM4TFeatureExtractor,ci as SegformerFeatureExtractor,di as SegformerForImageClassification,ui as SegformerForSemanticSegmentation,pi as SegformerModel,hi as SegformerPreTrainedModel,mi as Seq2SeqLMOutput,_i as SequenceClassifierOutput,fi as SiglipImageProcessor,gi as SiglipModel,Mi as SiglipPreTrainedModel,wi as SiglipTextModel,Ti as SiglipTokenizer,bi as SiglipVisionModel,xi as SpeechT5FeatureExtractor,ki as SpeechT5ForSpeechToText,yi as SpeechT5ForTextToSpeech,Fi as SpeechT5HifiGan,Pi as SpeechT5Model,Ci as SpeechT5PreTrainedModel,vi as SpeechT5Processor,Si as SpeechT5Tokenizer,Ai as SqueezeBertForMaskedLM,Ei as SqueezeBertForQuestionAnswering,Li as SqueezeBertForSequenceClassification,zi as SqueezeBertModel,Ii as SqueezeBertPreTrainedModel,Bi as SqueezeBertTokenizer,Ni as StableLmForCausalLM,Oi as StableLmModel,Di as StableLmPreTrainedModel,Vi as Starcoder2ForCausalLM,ji as Starcoder2Model,Ri as Starcoder2PreTrainedModel,Gi as StoppingCriteria,qi as StoppingCriteriaList,$i as SummarizationPipeline,Wi as Swin2SRForImageSuperResolution,Ui as Swin2SRImageProcessor,Xi as Swin2SRModel,Qi as Swin2SRPreTrainedModel,Hi as SwinForImageClassification,Yi as SwinModel,Ji as SwinPreTrainedModel,Ki as T5ForConditionalGeneration,Zi as T5Model,el as T5PreTrainedModel,tl as T5Tokenizer,rl as TableTransformerForObjectDetection,nl as TableTransformerModel,ol as TableTransformerObjectDetectionOutput,sl as TableTransformerPreTrainedModel,al as Tensor,il as Text2TextGenerationPipeline,ll as TextClassificationPipeline,cl as TextGenerationPipeline,dl as TextStreamer,ul as TextToAudioPipeline,pl as TokenClassificationPipeline,hl as TokenClassifierOutput,ml as TokenizerModel,_l as TrOCRForCausalLM,fl as TrOCRPreTrainedModel,gl as TranslationPipeline,Ml as UniSpeechForCTC,wl as UniSpeechForSequenceClassification,Tl as UniSpeechModel,bl as UniSpeechPreTrainedModel,xl as UniSpeechSatForAudioFrameClassification,kl as UniSpeechSatForCTC,yl as UniSpeechSatForSequenceClassification,Fl as UniSpeechSatModel,Pl as UniSpeechSatPreTrainedModel,Cl as ViTFeatureExtractor,vl as ViTForImageClassification,Sl as ViTImageProcessor,Al as ViTMAEModel,El as ViTMAEPreTrainedModel,Ll as ViTMSNForImageClassification,zl as ViTMSNModel,Il as ViTMSNPreTrainedModel,Bl as ViTModel,Nl as ViTPreTrainedModel,Ol as VisionEncoderDecoderModel,Dl as VitMatteForImageMatting,Vl as VitMatteImageProcessor,jl as VitMattePreTrainedModel,Rl as VitsModel,Gl as VitsModelOutput,ql as VitsPreTrainedModel,$l as VitsTokenizer,Wl as Wav2Vec2BertForCTC,Ul as Wav2Vec2BertForSequenceClassification,Xl as Wav2Vec2BertModel,Ql as Wav2Vec2BertPreTrainedModel,Hl as Wav2Vec2CTCTokenizer,Yl as Wav2Vec2FeatureExtractor,Jl as Wav2Vec2ForAudioFrameClassification,Kl as Wav2Vec2ForCTC,Zl as Wav2Vec2ForSequenceClassification,ec as Wav2Vec2Model,tc as Wav2Vec2PreTrainedModel,rc as Wav2Vec2ProcessorWithLM,nc as WavLMForAudioFrameClassification,oc as WavLMForCTC,sc as WavLMForSequenceClassification,ac as WavLMForXVector,ic as WavLMModel,lc as WavLMPreTrainedModel,cc as WeSpeakerFeatureExtractor,dc as WeSpeakerResNetModel,uc as WeSpeakerResNetPreTrainedModel,pc as WhisperFeatureExtractor,hc as WhisperForConditionalGeneration,mc as WhisperModel,_c as WhisperPreTrainedModel,fc as WhisperProcessor,gc as WhisperTextStreamer,Mc as WhisperTokenizer,wc as XLMForQuestionAnswering,Tc as XLMForSequenceClassification,bc as XLMForTokenClassification,xc as XLMModel,kc as XLMPreTrainedModel,yc as XLMRobertaForMaskedLM,Fc as XLMRobertaForQuestionAnswering,Pc as XLMRobertaForSequenceClassification,Cc as XLMRobertaForTokenClassification,vc as XLMRobertaModel,Sc as XLMRobertaPreTrainedModel,Ac as XLMRobertaTokenizer,Ec as XLMTokenizer,Lc as XLMWithLMHeadModel,zc as XVectorOutput,Ic as YolosFeatureExtractor,Bc as YolosForObjectDetection,Nc as YolosModel,Oc as YolosObjectDetectionOutput,Dc as YolosPreTrainedModel,Vc as ZeroShotAudioClassificationPipeline,jc as ZeroShotClassificationPipeline,Rc as ZeroShotImageClassificationPipeline,Gc as ZeroShotObjectDetectionPipeline,qc as bankers_round,$c as cat,Wc as cos_sim,Uc as dot,Xc as dynamic_time_warping,Qc as env,Hc as full,Yc as full_like,Jc as getKeyValueShapes,Kc as hamming,Zc as hanning,ed as interpolate,td as interpolate_4d,rd as interpolate_data,nd as is_chinese_char,od as layer_norm,sd as log_softmax,ad as magnitude,id as matmul,ld as max,cd as mean,dd as mean_pooling,ud as medianFilter,pd as mel_filter_bank,hd as min,md as ones,_d as ones_like,fd as permute,gd as permute_data,Md as pipeline,wd as quantize_embeddings,Td as read_audio,bd as rfft,xd as round,kd as softmax,yd as spectrogram,Fd as stack,Pd as std_mean,Cd as topk,vd as window_function,Sd as zeros,Ad as zeros_like};
//# sourceMappingURL=transformers.min.js.map