|
let n=r(48738),i=r(6868),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function o(e){if(e>2147483647)throw RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return u(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e)return function(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!a.isEncoding(t))throw TypeError("Unknown encoding: "+t);let r=0|p(e,t),n=o(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(R(e,Uint8Array)){let t=new Uint8Array(e);return c(t.buffer,t.byteOffset,t.byteLength)}return f(e)}(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(R(e,ArrayBuffer)||e&&R(e.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(R(e,SharedArrayBuffer)||e&&R(e.buffer,SharedArrayBuffer)))return c(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return a.from(n,t,r);let i=function(e){var t;if(a.isBuffer(e)){let t=0|d(e.length),r=o(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||(t=e.length)!=t?o(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function h(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function u(e){return h(e),o(e<0?0:0|d(e))}function f(e){let t=e.length<0?0:0|d(e.length),r=o(t);for(let n=0;n<t;n+=1)r[n]=255&e[n];return r}function c(e,t,r){let n;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),a.prototype),n}function d(e){if(e>=2147483647)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function p(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||R(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return T(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(e).length;default:if(i)return n?-1:T(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t,r){let i=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=t;n<r;++n)i+=j[e[n]];return i}(this,t,r);case"utf8":case"utf-8":return w(this,t,r);case"ascii":return function(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}(this,t,r);case"latin1":case"binary":return function(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}(this,t,r);case"base64":var s,o;return s=t,o=r,0===s&&o===this.length?n.fromByteArray(this):n.fromByteArray(this.slice(s,o));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){let n=e.slice(t,r),i="";for(let e=0;e<n.length-1;e+=2)i+=String.fromCharCode(n[e]+256*n[e+1]);return i}(this,t,r);default:if(i)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function m(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function y(e,t,r,n,i){var s;if(0===e.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),(s=r=+r)!=s&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return -1;r=e.length-1}else if(r<0){if(!i)return -1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,i);if("number"==typeof t)return(t&=255,"function"==typeof Uint8Array.prototype.indexOf)?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,i);throw TypeError("val must be string, number or Buffer")}function _(e,t,r,n,i){let s,o=1,a=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return -1;o=2,a/=2,l/=2,r/=2}function h(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){let n=-1;for(s=r;s<a;s++)if(h(e,s)===h(t,-1===n?0:s-n)){if(-1===n&&(n=s),s-n+1===l)return n*o}else -1!==n&&(s-=s-n),n=-1}else for(r+l>a&&(r=a-l),s=r;s>=0;s--){let r=!0;for(let n=0;n<l;n++)if(h(e,s+n)!==h(t,n)){r=!1;break}if(r)return s}return -1}function w(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let t=e[i],s=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=r){let r,n,a,l;switch(o){case 1:t<128&&(s=t);break;case 2:(192&(r=e[i+1]))==128&&(l=(31&t)<<6|63&r)>127&&(s=l);break;case 3:r=e[i+1],n=e[i+2],(192&r)==128&&(192&n)==128&&(l=(15&t)<<12|(63&r)<<6|63&n)>2047&&(l<55296||l>57343)&&(s=l);break;case 4:r=e[i+1],n=e[i+2],a=e[i+3],(192&r)==128&&(192&n)==128&&(192&a)==128&&(l=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&a)>65535&&l<1114112&&(s=l)}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=o}return function(e){let t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}function b(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function v(e,t,r,n,i,s){if(!a.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw RangeError('"value" argument is out of bounds');if(r+n>e.length)throw RangeError("Index out of range")}function x(e,t,r,n,i){S(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,r}function E(e,t,r,n,i){S(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r+7]=s,s>>=8,e[r+6]=s,s>>=8,e[r+5]=s,s>>=8,e[r+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=o,o>>=8,e[r+2]=o,o>>=8,e[r+1]=o,o>>=8,e[r]=o,r+8}function A(e,t,r,n,i,s){if(r+n>e.length||r<0)throw RangeError("Index out of range")}function k(e,t,r,n,s){return t=+t,r>>>=0,s||A(e,t,r,4,34028234663852886e22,-34028234663852886e22),i.write(e,t,r,n,23,4),r+4}function B(e,t,r,n,s){return t=+t,r>>>=0,s||A(e,t,r,8,17976931348623157e292,-17976931348623157e292),i.write(e,t,r,n,52,8),r+8}t.Buffer=a,t.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=function(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(e,t,r){return(h(e),e<=0)?o(e):void 0!==t?"string"==typeof r?o(e).fill(t,r):o(e).fill(t):o(e)},a.allocUnsafe=function(e){return u(e)},a.allocUnsafeSlow=function(e){return u(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(R(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),R(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,n=t.length;for(let i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){let r;if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;let n=a.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){let t=e[r];if(R(t,Uint8Array))i+t.length>n.length?(a.isBuffer(t)||(t=a.from(t)),t.copy(n,i)):Uint8Array.prototype.set.call(n,t,i);else if(a.isBuffer(t))t.copy(n,i);else throw TypeError('"list" argument must be an Array of Buffers');i+=t.length}return n},a.byteLength=p,a.prototype._isBuffer=!0,a.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)m(this,t,t+1);return this},a.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},a.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},a.prototype.toString=function(){let e=this.length;return 0===e?"":0==arguments.length?w(this,0,e):g.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){let e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(e,t,r,n,i){if(R(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;let s=i-n,o=r-t,l=Math.min(s,o),h=this.slice(n,i),u=e.slice(t,r);for(let e=0;e<l;++e)if(h[e]!==u[e]){s=h[e],o=u[e];break}return s<o?-1:o<s?1:0},a.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},a.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},a.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)},a.prototype.write=function(e,t,r,n){var i,s,o,a,l,h,u,f;if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let c=this.length-t;if((void 0===r||r>c)&&(r=c),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let d=!1;for(;;)switch(n){case"hex":return function(e,t,r,n){let i;r=Number(r)||0;let s=e.length-r;n?(n=Number(n))>s&&(n=s):n=s;let o=t.length;for(n>o/2&&(n=o/2),i=0;i<n;++i){let n=parseInt(t.substr(2*i,2),16);if(n!=n)break;e[r+i]=n}return i}(this,e,t,r);case"utf8":case"utf-8":return i=t,s=r,L(T(e,this.length-i),this,i,s);case"ascii":case"latin1":case"binary":return o=t,a=r,L(function(e){let t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(e),this,o,a);case"base64":return l=t,h=r,L($(e),this,l,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u=t,f=r,L(function(e,t){let r,n;let i=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i.push(r%256),i.push(n);return i}(e,this.length-u),this,u,f);default:if(d)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},a.prototype.slice=function(e,t){let r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);let n=this.subarray(e,t);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);let n=this[e],i=1,s=0;for(;++s<t&&(i*=256);)n+=this[e+s]*i;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);let n=this[e+--t],i=1;for(;t>0&&(i*=256);)n+=this[e+--t]*i;return n},a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e>>>=0,t||b(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||b(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||b(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||b(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||b(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readBigUInt64LE=F(function(e){O(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&U(e,this.length-8);let n=t+256*this[++e]+65536*this[++e]+16777216*this[++e],i=this[++e]+256*this[++e]+65536*this[++e]+16777216*r;return BigInt(n)+(BigInt(i)<<BigInt(32))}),a.prototype.readBigUInt64BE=F(function(e){O(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&U(e,this.length-8);let n=16777216*t+65536*this[++e]+256*this[++e]+this[++e],i=16777216*this[++e]+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);let n=this[e],i=1,s=0;for(;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);let n=t,i=1,s=this[e+--n];for(;n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},a.prototype.readInt8=function(e,t){return(e>>>=0,t||b(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||b(e,2,this.length);let r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||b(e,2,this.length);let r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||b(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||b(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readBigInt64LE=F(function(e){O(e>>>=0,"offset");let t=this[e],r=this[e+7];return(void 0===t||void 0===r)&&U(e,this.length-8),(BigInt(this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24))<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+16777216*this[++e])}),a.prototype.readBigInt64BE=F(function(e){O(e>>>=0,"offset");let t=this[e],r=this[e+7];return(void 0===t||void 0===r)&&U(e,this.length-8),(BigInt((t<<24)+65536*this[++e]+256*this[++e]+this[++e])<<BigInt(32))+BigInt(16777216*this[++e]+65536*this[++e]+256*this[++e]+r)}),a.prototype.readFloatLE=function(e,t){return e>>>=0,t||b(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||b(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||b(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||b(e,8,this.length),i.read(this,e,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){let n=Math.pow(2,8*r)-1;v(this,e,t,r,n,0)}let i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){let n=Math.pow(2,8*r)-1;v(this,e,t,r,n,0)}let i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeBigUInt64LE=F(function(e,t=0){return x(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=F(function(e,t=0){return E(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){let n=Math.pow(2,8*r-1);v(this,e,t,r,n-1,-n)}let i=0,s=1,o=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){let n=Math.pow(2,8*r-1);v(this,e,t,r,n-1,-n)}let i=r-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeBigInt64LE=F(function(e,t=0){return x(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=F(function(e,t=0){return E(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeFloatLE=function(e,t,r){return k(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return k(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return B(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return B(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(!a.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);let i=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},a.prototype.fill=function(e,t,r,n){let i;if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw TypeError("Unknown encoding: "+n);if(1===e.length){let t=e.charCodeAt(0);("utf8"===n&&t<128||"latin1"===n)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{let s=a.isBuffer(e)?e:a.from(e,n),o=s.length;if(0===o)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=s[i%o]}return this};let I={};function z(e,t,r){I[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function C(e){let t="",r=e.length,n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function S(e,t,r,n,i,s){if(e>r||e<t){let n;let i="bigint"==typeof t?"n":"";throw n=s>3?0===t||t===BigInt(0)?`>= 0${i} and < 2${i} ** ${(s+1)*8}${i}`:`>= -(2${i} ** ${(s+1)*8-1}${i}) and < 2 ** ${(s+1)*8-1}${i}`:`>= ${t}${i} and <= ${r}${i}`,new I.ERR_OUT_OF_RANGE("value",n,e)}O(i,"offset"),(void 0===n[i]||void 0===n[i+s])&&U(i,n.length-(s+1))}function O(e,t){if("number"!=typeof e)throw new I.ERR_INVALID_ARG_TYPE(t,"number",e)}function U(e,t,r){if(Math.floor(e)!==e)throw O(e,r),new I.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new I.ERR_BUFFER_OUT_OF_BOUNDS;throw new I.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}z("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),z("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),z("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>4294967296?i=C(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=C(i)),i+="n"),n+=` It must be ${t}. Received ${i}`},RangeError);let M=/[^+/0-9A-Za-z-_]/g;function T(e,t){let r;t=t||1/0;let n=e.length,i=null,s=[];for(let o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319||o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return s}function $(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function L(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length)&&!(i>=e.length);++i)t[i+r]=e[i];return i}function R(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}let j=function(){let e="0123456789abcdef",t=Array(256);for(let r=0;r<16;++r){let n=16*r;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function F(e){return"undefined"==typeof BigInt?N:e}function N(){throw Error("BigInt not supported")}},13414:function(e,t,r){var n=r(2381).Symbol;e.exports=n},12731:function(e,t,r){var n=r(13414),i=r(37363),s=r(68391),o=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":o&&o in Object(e)?i(e):s(e)}},19334:function(e,t,r){var n=r(25788),i=/^\s+/;e.exports=function(e){return e?e.slice(0,n(e)+1).replace(i,""):e}},93330:function(e,t,r){var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=n},37363:function(e,t,r){var n=r(13414),i=Object.prototype,s=i.hasOwnProperty,o=i.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=s.call(e,a),r=e[a];try{e[a]=void 0;var n=!0}catch(e){}var i=o.call(e);return n&&(t?e[a]=r:delete e[a]),i}},68391:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},2381:function(e,t,r){var n=r(93330),i="object"==typeof self&&self&&self.Object===Object&&self,s=n||i||Function("return this")();e.exports=s},25788:function(e){var t=/\s/;e.exports=function(e){for(var r=e.length;r--&&t.test(e.charAt(r)););return r}},22170:function(e,t,r){var n=r(63117),i=r(49423),s=r(49666),o=Math.max,a=Math.min;e.exports=function(e,t,r){var l,h,u,f,c,d,p=0,g=!1,m=!1,y=!0;if("function"!=typeof e)throw TypeError("Expected a function");function _(t){var r=l,n=h;return l=h=void 0,p=t,f=e.apply(n,r)}function w(e){var r=e-d,n=e-p;return void 0===d||r>=t||r<0||m&&n>=u}function b(){var e,r,n,s=i();if(w(s))return v(s);c=setTimeout(b,(e=s-d,r=s-p,n=t-e,m?a(n,u-r):n))}function v(e){return(c=void 0,y&&l)?_(e):(l=h=void 0,f)}function x(){var e,r=i(),n=w(r);if(l=arguments,h=this,d=r,n){if(void 0===c)return p=e=d,c=setTimeout(b,t),g?_(e):f;if(m)return clearTimeout(c),c=setTimeout(b,t),_(d)}return void 0===c&&(c=setTimeout(b,t)),f}return t=s(t)||0,n(r)&&(g=!!r.leading,u=(m="maxWait"in r)?o(s(r.maxWait)||0,t):u,y="trailing"in r?!!r.trailing:y),x.cancel=function(){void 0!==c&&clearTimeout(c),p=0,l=d=h=c=void 0},x.flush=function(){return void 0===c?f:v(i())},x}},63117:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},50561:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},41108:function(e,t,r){var n=r(12731),i=r(50561);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==n(e)}},49423:function(e,t,r){var n=r(2381);e.exports=function(){return n.Date.now()}},49666:function(e,t,r){var n=r(19334),i=r(63117),s=r(41108),o=0/0,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,h=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(s(e))return o;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=n(e);var r=l.test(e);return r||h.test(e)?u(e.slice(2),r?2:8):a.test(e)?o:+e}},48464:function(e,t,r){!function(){var t={452:function(e){"use strict";e.exports=r(46405)}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var s=n[e]={exports:{}},o=!0;try{t[e](s,s.exports,i),o=!1}finally{o&&delete n[e]}return s.exports}i.ab="//";var s={};!function(){var e,t=(e=i(452))&&"object"==typeof e&&"default"in e?e.default:e,r=/https?|ftp|gopher|file/;function n(e){"string"==typeof e&&(e=y(e));var n,i,s,o,a,l,h,u,f,c=(i=(n=e).auth,s=n.hostname,o=n.protocol||"",a=n.pathname||"",l=n.hash||"",h=n.query||"",u=!1,i=i?encodeURIComponent(i).replace(/%3A/i,":")+"@":"",n.host?u=i+n.host:s&&(u=i+(~s.indexOf(":")?"["+s+"]":s),n.port&&(u+=":"+n.port)),h&&"object"==typeof h&&(h=t.encode(h)),f=n.search||h&&"?"+h||"",o&&":"!==o.substr(-1)&&(o+=":"),n.slashes||(!o||r.test(o))&&!1!==u?(u="//"+(u||""),a&&"/"!==a[0]&&(a="/"+a)):u||(u=""),l&&"#"!==l[0]&&(l="#"+l),f&&"?"!==f[0]&&(f="?"+f),{protocol:o,host:u,pathname:a=a.replace(/[?#]/g,encodeURIComponent),search:f=f.replace("#","%23"),hash:l});return""+c.protocol+c.host+c.pathname+c.search+c.hash}var o="http://",a=o+"w.w",l=/^([a-z0-9.+-]*:\/\/\/)([a-z0-9.+-]:\/*)?/i,h=/https?|ftp|gopher|file/;function u(e,t){var r="string"==typeof e?y(e):e;e="object"==typeof e?n(e):e;var i=y(t),s="";r.protocol&&!r.slashes&&(s=r.protocol,e=e.replace(r.protocol,""),s+="/"===t[0]||"/"===e[0]?"/":""),s&&i.protocol&&(s="",i.slashes||(s=i.protocol,t=t.replace(i.protocol,"")));var u=e.match(l);u&&!i.protocol&&(e=e.substr((s=u[1]+(u[2]||"")).length),/^\/\/[^/]/.test(t)&&(s=s.slice(0,-1)));var f=new URL(e,a+"/"),c=new URL(t,f).toString().replace(a,""),d=i.protocol||r.protocol;return d+=r.slashes||i.slashes?"//":"",!s&&d?c=c.replace(o,d):s&&(c=c.replace(o,"")),h.test(c)||~t.indexOf(".")||"/"===e.slice(-1)||"/"===t.slice(-1)||"/"!==c.slice(-1)||(c=c.slice(0,-1)),s&&(c=s+("/"===c[0]?c.substr(1):c)),c}function f(){}f.prototype.parse=y,f.prototype.format=n,f.prototype.resolve=u,f.prototype.resolveObject=u;var c=/^https?|ftp|gopher|file/,d=/^(.*?)([#?].*)/,p=/^([a-z0-9.+-]*:)(\/{0,3})(.*)/i,g=/^([a-z0-9.+-]*:)?\/\/\/*/i,m=/^([a-z0-9.+-]*:)(\/{0,2})\[(.*)\]$/i;function y(e,r,i){if(void 0===r&&(r=!1),void 0===i&&(i=!1),e&&"object"==typeof e&&e instanceof f)return e;var s=(e=e.trim()).match(d);e=s?s[1].replace(/\\/g,"/")+s[2]:e.replace(/\\/g,"/"),m.test(e)&&"/"!==e.slice(-1)&&(e+="/");var o=!/(^javascript)/.test(e)&&e.match(p),l=g.test(e),h="";o&&(c.test(o[1])||(h=o[1].toLowerCase(),e=""+o[2]+o[3]),o[2]||(l=!1,c.test(o[1])?(h=o[1],e=""+o[3]):e="//"+o[3]),3!==o[2].length&&1!==o[2].length||(h=o[1],e="/"+o[3]));var u,y=(s?s[1]:e).match(/^https?:\/\/[^/]+(:[0-9]+)(?=\/|$)/),_=y&&y[1],w=new f,b="",v="";try{u=new URL(e)}catch(t){b=t,h||i||!/^\/\//.test(e)||/^\/\/.+[@.]/.test(e)||(v="/",e=e.substr(1));try{u=new URL(e,a)}catch(e){return w.protocol=h,w.href=h,w}}w.slashes=l&&!v,w.host="w.w"===u.host?"":u.host,w.hostname="w.w"===u.hostname?"":u.hostname.replace(/(\[|\])/g,""),w.protocol=b?h||null:u.protocol,w.search=u.search.replace(/\\/g,"%5C"),w.hash=u.hash.replace(/\\/g,"%5C");var x=e.split("#");!w.search&&~x[0].indexOf("?")&&(w.search="?"),w.hash||""!==x[1]||(w.hash="#"),w.query=r?t.decode(u.search.substr(1)):w.search.substr(1),w.pathname=v+(o?u.pathname.replace(/['^|`]/g,function(e){return"%"+e.charCodeAt().toString(16).toUpperCase()}).replace(/((?:%[0-9A-F]{2})+)/g,function(e,t){try{return decodeURIComponent(t).split("").map(function(e){var t=e.charCodeAt();return t>256||/^[a-z0-9]$/i.test(e)?e:"%"+t.toString(16).toUpperCase()}).join("")}catch(e){return t}}):u.pathname),"about:"===w.protocol&&"blank"===w.pathname&&(w.protocol="",w.pathname=""),b&&"/"!==e[0]&&(w.pathname=w.pathname.substr(1)),h&&!c.test(h)&&"/"!==e.slice(-1)&&"/"===w.pathname&&(w.pathname=""),w.path=w.pathname+w.search,w.auth=[u.username,u.password].map(decodeURIComponent).filter(Boolean).join(":"),w.port=u.port,_&&!w.host.endsWith(_)&&(w.host+=_,w.port=_.slice(1)),w.href=v?""+w.pathname+w.search+w.hash:n(w);var E=/^(file)/.test(w.href)?["host","hostname"]:[];return Object.keys(w).forEach(function(e){~E.indexOf(e)||(w[e]=w[e]||null)}),w}s.parse=y,s.format=n,s.resolve=u,s.resolveObject=function(e,t){return y(u(e,t))},s.Url=f}(),e.exports=s}()},46405:function(e){!function(){"use strict";var t={815:function(e){e.exports=function(e,r,n,i){r=r||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var o=/\+/g;e=e.split(r);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var l=e.length;a>0&&l>a&&(l=a);for(var h=0;h<l;++h){var u,f,c,d,p=e[h].replace(o,"%20"),g=p.indexOf(n);(g>=0?(u=p.substr(0,g),f=p.substr(g+1)):(u=p,f=""),c=decodeURIComponent(u),d=decodeURIComponent(f),Object.prototype.hasOwnProperty.call(s,c))?t(s[c])?s[c].push(d):s[c]=[s[c],d]:s[c]=d}return s};var t=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},577:function(e){var t=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,s,o,a){return(s=s||"&",o=o||"=",null===e&&(e=void 0),"object"==typeof e)?n(i(e),function(i){var a=encodeURIComponent(t(i))+o;return r(e[i])?n(e[i],function(e){return a+encodeURIComponent(t(e))}).join(s):a+encodeURIComponent(t(e[i]))}).join(s):a?encodeURIComponent(t(a))+o+encodeURIComponent(t(e)):""};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function n(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n<e.length;n++)r.push(t(e[n],n));return r}var i=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t}}},r={};function n(e){var i=r[e];if(void 0!==i)return i.exports;var s=r[e]={exports:{}},o=!0;try{t[e](s,s.exports,n),o=!1}finally{o&&delete r[e]}return s.exports}n.ab="//";var i={};i.decode=i.parse=n(815),i.encode=i.stringify=n(577),e.exports=i}()},63426:function(e,t,r){"use strict";r.r(t),r.d(t,{InferenceSession:function(){return y},Tensor:function(){return g},env:function(){return l},registerBackend:function(){return s}});let n={},i=[],s=(e,t,r)=>{if(t&&"function"==typeof t.init&&"function"==typeof t.createSessionHandler){let s=n[e];if(void 0===s)n[e]={backend:t,priority:r};else if(s.priority>r)return;else if(s.priority===r&&s.backend!==t)throw Error(`cannot register backend "${e}" using priority ${r}`);if(r>=0){let t=i.indexOf(e);-1!==t&&i.splice(t,1);for(let t=0;t<i.length;t++)if(n[i[t]].priority<=r){i.splice(t,0,e);return}i.push(e)}return}throw TypeError("not a valid backend")},o=async e=>{let t=0===e.length?i:e,r=[];for(let e of t){let t=n[e];if(t){if(t.initialized)return t.backend;if(t.aborted)continue;let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init()),await t.initPromise,t.initialized=!0,t.backend}catch(i){n||r.push({name:e,err:i}),t.aborted=!0}finally{delete t.initPromise}}}throw Error(`no available backend found. ERR: ${r.map(e=>`[${e.name}] ${e.err}`).join(", ")}`)};class a{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(e){if(void 0!==e){if("string"!=typeof e||-1===["verbose","info","warning","error","fatal"].indexOf(e))throw Error(`Unsupported logging level: ${e}`);this.logLevelInternal=e}}get logLevel(){return this.logLevelInternal}}let l=new a,h="undefined"!=typeof BigInt64Array&&"function"==typeof BigInt64Array.from,u="undefined"!=typeof BigUint64Array&&"function"==typeof BigUint64Array.from,f=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),c=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);h&&(f.set("int64",BigInt64Array),c.set(BigInt64Array,"int64")),u&&(f.set("uint64",BigUint64Array),c.set(BigUint64Array,"uint64"));let d=e=>{let t=1;for(let r=0;r<e.length;r++){let n=e[r];if("number"!=typeof n||!Number.isSafeInteger(n))throw TypeError(`dims[${r}] must be an integer, got: ${n}`);if(n<0)throw RangeError(`dims[${r}] must be a non-negative integer, got: ${n}`);t*=n}return t};class p{constructor(e,t,r){let n,i,s;if("string"==typeof e){if(n=e,s=r,"string"===e){if(!Array.isArray(t))throw TypeError("A string tensor's data must be a string array.");i=t}else{let r=f.get(e);if(void 0===r)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t))i=r.from(t);else if(t instanceof r)i=t;else throw TypeError(`A ${n} tensor's data must be type of ${r}`)}}else if(s=t,Array.isArray(e)){if(0===e.length)throw TypeError("Tensor type cannot be inferred from an empty array.");let t=typeof e[0];if("string"===t)n="string",i=e;else if("boolean"===t)n="bool",i=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else{let t=c.get(e.constructor);if(void 0===t)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);n=t,i=e}if(void 0===s)s=[i.length];else if(!Array.isArray(s))throw TypeError("A tensor's dims must be a number array");let o=d(s);if(o!==i.length)throw Error(`Tensor's size(${o}) does not match data length(${i.length}).`);this.dims=s,this.type=n,this.data=i,this.size=o}static bufferToTensor(e,t){let r,n;if(void 0===e)throw Error("Image buffer must be defined");if(void 0===t.height||void 0===t.width)throw Error("Image height and width must be defined");let{height:i,width:s}=t,o=t.norm;r=void 0===o||void 0===o.mean?255:o.mean,n=void 0===o||void 0===o.bias?0:o.bias;let a=void 0!==t.bitmapFormat?t.bitmapFormat:"RGBA",l=void 0!==t.tensorFormat&&void 0!==t.tensorFormat?t.tensorFormat:"RGB",h=i*s,u=new Float32Array("RGBA"===l?4*h:3*h),f=4,c=0,d=1,g=2,m=3,y=0,_=h,w=2*h,b=-1;"RGB"===a&&(f=3,c=0,d=1,g=2,m=-1),"RGBA"===l?b=3*h:"RBG"===l?(y=0,w=h,_=2*h):"BGR"===l&&(w=0,_=h,y=2*h);for(let t=0;t<h;t++,c+=f,g+=f,d+=f,m+=f)u[y++]=(e[c]+n)/r,u[_++]=(e[d]+n)/r,u[w++]=(e[g]+n)/r,-1!==b&&-1!==m&&(u[b++]=(e[m]+n)/r);return"RGBA"===l?new p("float32",u,[1,4,i,s]):new p("float32",u,[1,3,i,s])}static async fromImage(e,t){let r;let n="undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement,i="undefined"!=typeof ImageData&&e instanceof ImageData,s="undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap,o="undefined"!=typeof String&&(e instanceof String||"string"==typeof e),a={};if(n){let n=document.createElement("canvas"),i=n.getContext("2d");if(null!=i){let s=e.naturalHeight,o=e.naturalWidth;if(void 0!==t&&void 0!==t.resizedHeight&&void 0!==t.resizedWidth&&(s=t.resizedHeight,o=t.resizedWidth),void 0!==t){if(a=t,void 0!==t.tensorFormat)throw Error("Image input config format must be RGBA for HTMLImageElement");if(a.tensorFormat="RGBA",void 0!==t.height&&t.height!==s)throw Error("Image input config height doesn't match HTMLImageElement height");if(a.height=s,void 0!==t.width&&t.width!==o)throw Error("Image input config width doesn't match HTMLImageElement width");a.width=o}else a.tensorFormat="RGBA",a.height=s,a.width=o;n.width=o,n.height=s,i.drawImage(e,0,0,o,s),r=i.getImageData(0,0,o,s).data}else throw Error("Can not access image data")}else if(i){let n,i;if(void 0!==t&&void 0!==t.resizedWidth&&void 0!==t.resizedHeight?(n=t.resizedHeight,i=t.resizedWidth):(n=e.height,i=e.width),void 0!==t){if(a=t,void 0!==t.bitmapFormat&&"RGBA"!==t.bitmapFormat)throw Error("Image input config format must be RGBA for ImageData");a.bitmapFormat="RGBA"}else a.bitmapFormat="RGBA";if(a.height=n,a.width=i,void 0!==t){let t=document.createElement("canvas");t.width=i,t.height=n;let s=t.getContext("2d");if(null!=s)s.putImageData(e,0,0),r=s.getImageData(0,0,i,n).data;else throw Error("Can not access image data")}else r=e.data}else if(s){if(void 0===t)throw Error("Please provide image config with format for Imagebitmap");if(void 0!==t.bitmapFormat)throw Error("Image input config format must be defined for ImageBitmap");let n=document.createElement("canvas").getContext("2d");if(null!=n){let i=e.height,s=e.width;if(n.drawImage(e,0,0,s,i),r=n.getImageData(0,0,s,i).data,void 0!==t){if(void 0!==t.height&&t.height!==i)throw Error("Image input config height doesn't match ImageBitmap height");if(a.height=i,void 0!==t.width&&t.width!==s)throw Error("Image input config width doesn't match ImageBitmap width");a.width=s}else a.height=i,a.width=s;return p.bufferToTensor(r,a)}throw Error("Can not access image data")}else if(o)return new Promise((r,n)=>{let i=document.createElement("canvas"),s=i.getContext("2d");if(!e||!s)return n();let o=new Image;o.crossOrigin="Anonymous",o.src=e,o.onload=()=>{i.width=o.width,i.height=o.height,s.drawImage(o,0,0,i.width,i.height);let e=s.getImageData(0,0,i.width,i.height);if(void 0!==t){if(void 0!==t.height&&t.height!==i.height)throw Error("Image input config height doesn't match ImageBitmap height");if(a.height=i.height,void 0!==t.width&&t.width!==i.width)throw Error("Image input config width doesn't match ImageBitmap width");a.width=i.width}else a.height=i.height,a.width=i.width;r(p.bufferToTensor(e.data,a))}});else throw Error("Input data provided is not supported - aborted tensor creation");if(void 0!==r)return p.bufferToTensor(r,a);throw Error("Input data provided is not supported - aborted tensor creation")}toImageData(e){var t,r;let n;let i=document.createElement("canvas").getContext("2d");if(null!=i){let s=this.dims[3],o=this.dims[2],a=this.dims[1],l=void 0!==e&&void 0!==e.format?e.format:"RGB",h=void 0!==e&&(null===(t=e.norm)||void 0===t?void 0:t.mean)!==void 0?e.norm.mean:255,u=void 0!==e&&(null===(r=e.norm)||void 0===r?void 0:r.bias)!==void 0?e.norm.bias:0,f=o*s;if(void 0!==e){if(void 0!==e.height&&e.height!==o)throw Error("Image output config height doesn't match tensor height");if(void 0!==e.width&&e.width!==s)throw Error("Image output config width doesn't match tensor width");if(void 0!==e.format&&4===a&&"RGBA"!==e.format||3===a&&"RGB"!==e.format&&"BGR"!==e.format)throw Error("Tensor format doesn't match input tensor dims")}let c=0,d=1,p=2,g=3,m=0,y=f,_=2*f,w=-1;"RGBA"===l?(m=0,y=f,_=2*f,w=3*f):"RGB"===l?(m=0,y=f,_=2*f):"RBG"===l&&(m=0,_=f,y=2*f),n=i.createImageData(s,o);for(let e=0;e<o*s;c+=4,d+=4,p+=4,g+=4,e++)n.data[c]=(this.data[m++]-u)*h,n.data[d]=(this.data[y++]-u)*h,n.data[p]=(this.data[_++]-u)*h,n.data[g]=-1===w?255:(this.data[w++]-u)*h}else throw Error("Can not access image data");return n}reshape(e){return new p(this.type,this.data,e)}}let g=p;class m{constructor(e){this.handler=e}async run(e,t,r){let n={},i={};if("object"!=typeof e||null===e||e instanceof g||Array.isArray(e))throw TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if("object"==typeof t){if(null===t)throw TypeError("Unexpected argument[1]: cannot be null.");if(t instanceof g)throw TypeError("'fetches' cannot be a Tensor");if(Array.isArray(t)){if(0===t.length)throw TypeError("'fetches' cannot be an empty array.");for(let e of(s=!1,t)){if("string"!=typeof e)throw TypeError("'fetches' must be a string array or an object.");if(-1===this.outputNames.indexOf(e))throw RangeError(`'fetches' contains invalid output name: ${e}.`);n[e]=null}if("object"==typeof r&&null!==r)i=r;else if(void 0!==r)throw TypeError("'options' must be an object.")}else{let e=!1,o=Object.getOwnPropertyNames(t);for(let r of this.outputNames)if(-1!==o.indexOf(r)){let i=t[r];(null===i||i instanceof g)&&(e=!0,s=!1,n[r]=i)}if(e){if("object"==typeof r&&null!==r)i=r;else if(void 0!==r)throw TypeError("'options' must be an object.")}else i=t}}else if(void 0!==t)throw TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let t of this.inputNames)if(void 0===e[t])throw Error(`input '${t}' is missing in 'feeds'.`);if(s)for(let e of this.outputNames)n[e]=null;let o=await this.handler.run(e,n,i),a={};for(let e in o)Object.hasOwnProperty.call(o,e)&&(a[e]=new g(o[e].type,o[e].data,o[e].dims));return a}static async create(e,t,r,n){let i;let s={};if("string"==typeof e){if(i=e,"object"==typeof t&&null!==t)s=t;else if(void 0!==t)throw TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(i=e,"object"==typeof t&&null!==t)s=t;else if(void 0!==t)throw TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer){let o=0,a=e.byteLength;if("object"==typeof t&&null!==t)s=t;else if("number"==typeof t){if(!Number.isSafeInteger(o=t))throw RangeError("'byteOffset' must be an integer.");if(o<0||o>=e.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(a=e.byteLength-o,"number"==typeof r){if(!Number.isSafeInteger(a=r))throw RangeError("'byteLength' must be an integer.");if(a<=0||o+a>e.byteLength)throw RangeError(`'byteLength' is out of range (0, ${e.byteLength-o}].`);if("object"==typeof n&&null!==n)s=n;else if(void 0!==n)throw TypeError("'options' must be an object.")}else if(void 0!==r)throw TypeError("'byteLength' must be a number.")}else if(void 0!==t)throw TypeError("'options' must be an object.");i=new Uint8Array(e,o,a)}else throw TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let a=(s.executionProviders||[]).map(e=>"string"==typeof e?e:e.name),l=await o(a);return new m(await l.createSessionHandler(i,s))}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}let y=m},24087:function(e,t,r){"use strict";r.d(t,{YS:function(){return X}});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"}),i=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,true:n.BooleanLiteral,false:n.BooleanLiteral}),s=class{constructor(e,t){this.value=e,this.type=t}};function o(e){return/\w/.test(e)}function a(e){return/[0-9]/.test(e)}var 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]],h=new Map([["n","\n"],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]),u=class{type="Statement"},f=class extends u{constructor(e){super(),this.body=e}type="Program"},c=class extends u{constructor(e,t,r){super(),this.test=e,this.body=t,this.alternate=r}type="If"},d=class extends u{constructor(e,t,r){super(),this.loopvar=e,this.iterable=t,this.body=r}type="For"},p=class extends u{constructor(e,t){super(),this.assignee=e,this.value=t}type="Set"},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"},y=class extends g{constructor(e,t){super(),this.callee=e,this.args=t}type="CallExpression"},_=class extends g{constructor(e){super(),this.value=e}type="Identifier"},w=class extends g{constructor(e){super(),this.value=e}type="Literal"},b=class extends w{type="NumericLiteral"},v=class extends w{type="StringLiteral"},x=class extends w{type="BooleanLiteral"},E=class extends w{type="ArrayLiteral"},A=class extends w{type="TupleLiteral"},k=class extends w{type="ObjectLiteral"},B=class extends g{constructor(e,t,r){super(),this.operator=e,this.left=t,this.right=r}type="BinaryExpression"},I=class extends g{constructor(e,t){super(),this.operand=e,this.filter=t}type="FilterExpression"},z=class extends g{constructor(e,t,r){super(),this.operand=e,this.negate=t,this.test=r}type="TestExpression"},C=class extends g{constructor(e,t){super(),this.operator=e,this.argument=t}type="UnaryExpression"},S=class extends g{constructor(e,t,r){super(),this.start=e,this.stop=t,this.step=r}type="SliceExpression"},O=class extends g{constructor(e,t){super(),this.key=e,this.value=t}type="KeywordArgumentExpression"};function U(e,t,r=1){void 0===t&&(t=e,e=0);let n=[];for(let i=e;i<t;i+=r)n.push(i);return n}function M(e,t,r,n=1){let i=Math.sign(n);i>=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));let s=[];for(let o=t;i*o<i*r;o+=n)s.push(e[o]);return s}function T(e){return e.replace(/\b\w/g,e=>e.toUpperCase())}var $=class{type="RuntimeValue";value;builtins=new Map;constructor(e){this.value=e}__bool__(){return new j(!!this.value)}},L=class extends ${type="NumericValue"},R=class extends ${type="StringValue";builtins=new Map([["upper",new q(()=>new R(this.value.toUpperCase()))],["lower",new q(()=>new R(this.value.toLowerCase()))],["strip",new q(()=>new R(this.value.trim()))],["title",new q(()=>new R(T(this.value)))],["length",new L(this.value.length)]])},j=class extends ${type="BooleanValue"},F=class extends ${type="ObjectValue";__bool__(){return new j(this.value.size>0)}builtins=new Map([["get",new q(([e,t])=>{if(!(e instanceof R))throw Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new H})],["items",new q(()=>new N(Array.from(this.value.entries()).map(([e,t])=>new N([new R(e),t]))))]])},N=class extends ${type="ArrayValue";builtins=new Map([["length",new L(this.value.length)]]);__bool__(){return new j(this.value.length>0)}},P=class extends N{type="TupleValue"},q=class extends ${type="FunctionValue"},H=class extends ${type="NullValue"},G=class extends ${type="UndefinedValue"},V=class{constructor(e){this.parent=e}variables=new Map([["namespace",new q(e=>{if(0===e.length)return new F(new Map);if(1!==e.length||!(e[0]instanceof F))throw 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 q],["odd",e=>{if("NumericValue"!==e.type)throw Error(`Cannot apply test "odd" to type: ${e.type}`);return e.value%2!=0}],["even",e=>{if("NumericValue"!==e.type)throw 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],["number",e=>"NumericValue"===e.type],["integer",e=>"NumericValue"===e.type&&Number.isInteger(e.value)],["iterable",e=>e instanceof N||e instanceof R],["lower",e=>{let t=e.value;return"StringValue"===e.type&&t===t.toLowerCase()}],["upper",e=>{let 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]]);set(e,t){return this.declareVariable(e,function e(t){switch(typeof t){case"number":return new L(t);case"string":return new R(t);case"boolean":return new j(t);case"object":if(null===t)return new H;if(Array.isArray(t))return new N(t.map(e));return new F(new Map(Object.entries(t).map(([t,r])=>[t,e(r)])));case"function":return new q((r,n)=>e(t(...r.map(e=>e.value))??null));default:throw Error(`Cannot convert to runtime value: ${t}`)}}(t))}declareVariable(e,t){if(this.variables.has(e))throw 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 Error(`Unknown variable: ${e}`)}lookupVariable(e){try{return this.resolve(e).variables.get(e)??new G}catch{return new G}}},D=class{global;constructor(e){this.global=e??new V}run(e){return this.evaluate(e,this.global)}evaluateBinaryExpression(e,t){let 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)}let n=this.evaluate(e.right,t);switch(e.operator.value){case"==":return new j(r.value==n.value);case"!=":return new j(r.value!=n.value)}if(r instanceof G||n instanceof G)throw Error("Cannot perform operation on undefined values");if(r instanceof H||n instanceof H)throw Error("Cannot perform operation on null values");if(r instanceof L&&n instanceof L)switch(e.operator.value){case"+":return new L(r.value+n.value);case"-":return new L(r.value-n.value);case"*":return new L(r.value*n.value);case"/":return new L(r.value/n.value);case"%":return new L(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)}else if(r instanceof N&&n instanceof N){if("+"===e.operator.value)return new N(r.value.concat(n.value))}else if(n instanceof N){let t=void 0!==n.value.find(e=>e.value===r.value);switch(e.operator.value){case"in":return new j(t);case"not in":return new j(!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 j(n.value.includes(r.value));case"not in":return new j(!n.value.includes(r.value))}if(r instanceof R&&n instanceof F)switch(e.operator.value){case"in":return new j(n.value.has(r.value));case"not in":return new j(!n.value.has(r.value))}throw SyntaxError(`Unknown operator "${e.operator.value}" between ${r.type} and ${n.type}`)}evaluateFilterExpression(e,t){let r=this.evaluate(e.operand,t);if("Identifier"===e.filter.type){let t=e.filter;if(r instanceof N)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 L(r.value.length);case"reverse":return new N(r.value.reverse());case"sort":return new N(r.value.sort((e,t)=>{if(e.type!==t.type)throw 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 Error(`Cannot compare type: ${e.type}`)}}));default:throw Error(`Unknown ArrayValue filter: ${t.value}`)}else if(r instanceof R)switch(t.value){case"length":return new L(r.value.length);case"upper":return new R(r.value.toUpperCase());case"lower":return new R(r.value.toLowerCase());case"title":return new R(T(r.value));case"capitalize":return new R(r.value.charAt(0).toUpperCase()+r.value.slice(1));case"trim":return new R(r.value.trim());default:throw Error(`Unknown StringValue filter: ${t.value}`)}else if(r instanceof L){if("abs"===t.value)return new L(Math.abs(r.value));throw Error(`Unknown NumericValue filter: ${t.value}`)}else if(r instanceof F)switch(t.value){case"items":return new N(Array.from(r.value.entries()).map(([e,t])=>new N([new R(e),t])));case"length":return new L(r.value.size);default:throw Error(`Unknown ObjectValue filter: ${t.value}`)}throw Error(`Cannot apply filter "${t.value}" to type: ${r.type}`)}if("CallExpression"===e.filter.type){let n=e.filter;if("Identifier"!==n.callee.type)throw Error(`Unknown filter: ${n.callee.type}`);let i=n.callee.value;if(r instanceof N){if("selectattr"===i){let e;if(r.value.some(e=>!(e instanceof F)))throw Error("`selectattr` can only be applied to array of objects");if(n.args.some(e=>"StringLiteral"!==e.type))throw Error("arguments of `selectattr` must be strings");let[i,s,o]=n.args.map(e=>this.evaluate(e,t));if(s){let r=t.tests.get(s.value);if(!r)throw Error(`Unknown test: ${s.value}`);e=r}else e=(...e)=>e[0].__bool__().value;return new N(r.value.filter(t=>{let r=t.value.get(i.value);return!!r&&e(r,o)}))}throw Error(`Unknown ArrayValue filter: ${i}`)}throw Error(`Cannot apply filter "${i}" to type: ${r.type}`)}throw Error(`Unknown filter: ${e.filter.type}`)}evaluateTestExpression(e,t){let r=this.evaluate(e.operand,t),n=t.tests.get(e.test.value);if(!n)throw Error(`Unknown test: ${e.test.value}`);let i=n(r);return new j(e.negate?!i:i)}evaluateUnaryExpression(e,t){let r=this.evaluate(e.argument,t);if("not"===e.operator.value)return new j(!r.value);throw SyntaxError(`Unknown operator: ${e.operator.value}`)}evalProgram(e,t){return this.evaluateBlock(e.body,t)}evaluateBlock(e,t){let r="";for(let n of e){let 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){let r=[],n=new Map;for(let i of e.args)"KeywordArgumentExpression"===i.type?n.set(i.key.value,this.evaluate(i.value,t)):r.push(this.evaluate(i,t));n.size>0&&r.push(new F(n));let i=this.evaluate(e.callee,t);if("FunctionValue"!==i.type)throw Error(`Cannot call something that is not a function: got ${i.type}`);return i.value(r,t)}evaluateSliceExpression(e,t,r){if(!(e instanceof N||e instanceof R))throw Error("Slice object must be an array or string");let n=this.evaluate(t.start,r),i=this.evaluate(t.stop,r),s=this.evaluate(t.step,r);if(!(n instanceof L||n instanceof G))throw Error("Slice start must be numeric or undefined");if(!(i instanceof L||i instanceof G))throw Error("Slice stop must be numeric or undefined");if(!(s instanceof L||s instanceof G))throw Error("Slice step must be numeric or undefined");return e instanceof N?new N(M(e.value,n.value,i.value,s.value)):new R(M(Array.from(e.value),n.value,i.value,s.value).join(""))}evaluateMemberExpression(e,t){let r,n;let i=this.evaluate(e.object,t);if(e.computed){if("SliceExpression"===e.property.type)return this.evaluateSliceExpression(i,e.property,t);r=this.evaluate(e.property,t)}else r=new R(e.property.value);if(i instanceof F){if(!(r instanceof R))throw Error(`Cannot access property with non-string: got ${r.type}`);n=i.value.get(r.value)??i.builtins.get(r.value)}else if(i instanceof N||i instanceof R){if(r instanceof L)n=i.value.at(r.value),i instanceof R&&(n=new R(i.value.at(r.value)));else if(r instanceof R)n=i.builtins.get(r.value);else throw Error(`Cannot access property with non-string/non-number: got ${r.type}`)}else{if(!(r instanceof R))throw Error(`Cannot access property with non-string: got ${r.type}`);n=i.builtins.get(r.value)}return n instanceof $?n:new G}evaluateSet(e,t){let r=this.evaluate(e.value,t);if("Identifier"===e.assignee.type){let n=e.assignee.value;t.setVariable(n,r)}else if("MemberExpression"===e.assignee.type){let n=e.assignee,i=this.evaluate(n.object,t);if(!(i instanceof F))throw Error("Cannot assign to member of non-object");if("Identifier"!==n.property.type)throw Error("Cannot assign to member with non-identifier property");i.value.set(n.property.value,r)}else throw Error(`Invalid LHS inside assignment expression: ${JSON.stringify(e.assignee)}`);return new H}evaluateIf(e,t){let r=this.evaluate(e.test,t);return this.evaluateBlock(r.__bool__().value?e.body:e.alternate,t)}evaluateFor(e,t){let r=new V(t),n=this.evaluate(e.iterable,r);if(!(n instanceof N))throw Error(`Expected iterable type in for loop: got ${n.type}`);let i="";for(let t=0;t<n.value.length;++t){let s=new Map([["index",new L(t+1)],["index0",new L(t)],["revindex",new L(n.value.length-t)],["revindex0",new L(n.value.length-t-1)],["first",new j(0===t)],["last",new j(t===n.value.length-1)],["length",new L(n.value.length)],["previtem",t>0?n.value[t-1]:new G],["nextitem",t<n.value.length-1?n.value[t+1]:new G]]);r.setVariable("loop",new F(s));let o=n.value[t];if("Identifier"===e.loopvar.type)r.setVariable(e.loopvar.value,o);else if("TupleLiteral"===e.loopvar.type){let t=e.loopvar;if("ArrayValue"!==o.type)throw Error(`Cannot unpack non-iterable type: ${o.type}`);if(t.value.length!==o.value.length)throw Error(`Too ${t.value.length>o.value.length?"few":"many"} items to unpack`);for(let e=0;e<t.value.length;++e){if("Identifier"!==t.value[e].type)throw Error(`Cannot unpack non-identifier type: ${t.value[e].type}`);r.setVariable(t.value[e].value,o.value[e])}}i+=this.evaluateBlock(e.body,r).value}return new R(i)}evaluate(e,t){if(void 0===e)return new G;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"NumericLiteral":return new L(Number(e.value));case"StringLiteral":return new R(e.value);case"BooleanLiteral":return new j(e.value);case"ArrayLiteral":return new N(e.value.map(e=>this.evaluate(e,t)));case"TupleLiteral":return new P(e.value.map(e=>this.evaluate(e,t)));case"ObjectLiteral":{let r=new Map;for(let[n,i]of e.value){let e=this.evaluate(n,t);if(!(e instanceof R))throw Error(`Object keys must be strings: got ${e.type}`);r.set(e.value,this.evaluate(i,t))}return new F(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 SyntaxError(`Unknown node type: ${e.type}`)}}},X=class{parsed;constructor(e){let t=function(e,t={}){let r=[],u=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),f=0,c=e=>{let t="";for(;e(u[f]);){if("\\"===u[f]){if(++f>=u.length)throw SyntaxError("Unexpected end of input");let e=u[f++],r=h.get(e);if(void 0===r)throw SyntaxError(`Unexpected escaped character: ${e}`);t+=r;continue}if(t+=u[f++],f>=u.length)throw SyntaxError("Unexpected end of input")}return t};e:for(;f<u.length;){let e=r.at(-1)?.type;if(void 0===e||e===n.CloseStatement||e===n.CloseExpression){let e="";for(;f<u.length&&!("{"===u[f]&&("%"===u[f+1]||"{"===u[f+1]));)e+=u[f++];if(e.length>0){r.push(new s(e,n.Text));continue}}c(e=>/\s/.test(e));let t=u[f];if("-"===t||"+"===t){let e=r.at(-1)?.type;if(e===n.Text||void 0===e)throw 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:{++f;let e=c(a);r.push(new s(`${t}${e}`,e.length>0?n.NumericLiteral:n.UnaryOperator));continue}}}for(let[e,t]of l)if(u.slice(f,f+e.length)===e){r.push(new s(e,t)),f+=e.length;continue e}if("'"===t||'"'===t){++f;let e=c(e=>e!==t);r.push(new s(e,n.StringLiteral)),++f;continue}if(a(t)){let e=c(a);r.push(new s(e,n.NumericLiteral));continue}if(o(t)){let e=c(o),t=Object.hasOwn(i,e)?i[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));continue}throw SyntaxError(`Unexpected character: ${t}`)}return r}(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=function(e){let t=new f([]),r=0;function i(t,n){let i=e[r++];if(!i||i.type!==t)throw Error(`Parser Error: ${n}. ${i.type} !== ${t}.`);return i}function s(...t){return r+t.length<=e.length&&t.every((t,n)=>t===e[r+n].type)}function o(e=!1){let t=e?T:a,i=[t()],o=s(n.Comma);for(;o&&(++r,i.push(t()),s(n.Comma)););return o?new A(i):i[0]}function a(){return function(){let e=l();if(s(n.If)){++r;let t=l();return i(n.Else,"Expected else token"),new c(t,[e],[l()])}return e}()}function l(){let t=h();for(;s(n.Or);){let n=e[r];++r,t=new B(n,t,h())}return t}function h(){let t=u();for(;s(n.And);){let n=e[r];++r,t=new B(n,t,u())}return t}function u(){let t;for(;s(n.Not);){let n=e[r];++r,t=new C(n,u())}return t??function(){let t=g();for(;s(n.ComparisonBinaryOperator)||s(n.In)||s(n.NotIn);){let n=e[r];++r,t=new B(n,t,g())}return t}()}function g(){let t=U();for(;s(n.AdditiveBinaryOperator);){let n=e[r];++r,t=new B(n,t,U())}return t}function w(e){let t=new y(e,function(){i(n.OpenParen,"Expected opening parenthesis for arguments list");let e=function(){let e=[];for(;!s(n.CloseParen);){let t=a();if(s(n.Equals)){if(++r,!(t instanceof _))throw SyntaxError("Expected identifier for keyword argument");t=new O(t,a())}e.push(t),s(n.Comma)&&++r}return e}();return i(n.CloseParen,"Expected closing parenthesis for arguments list"),e}());return s(n.OpenParen)&&(t=w(t)),t}function U(){let t=M();for(;s(n.MultiplicativeBinaryOperator);){let n=e[r];++r,t=new B(n,t,M())}return t}function M(){let t=function(){let t=function(){let t=function(){let t=T();for(;s(n.Dot)||s(n.OpenSquareBracket);){let o;let l=e[r];++r;let h=l.type!==n.Dot;if(h)o=function(){let e=[],t=!1;for(;!s(n.CloseSquareBracket);)s(n.Colon)?(e.push(void 0),++r,t=!0):(e.push(a()),s(n.Colon)&&(++r,t=!0));if(0===e.length)throw SyntaxError("Expected at least one argument for member/slice expression");if(t){if(e.length>3)throw SyntaxError("Expected 0-3 arguments for slice expression");return new S(...e)}return e[0]}(),i(n.CloseSquareBracket,"Expected closing square bracket");else if("Identifier"!==(o=T()).type)throw SyntaxError("Expected identifier following dot operator");t=new m(t,o,h)}return t}();return s(n.OpenParen)?w(t):t}();for(;s(n.Pipe);){++r;let e=T();if(!(e instanceof _))throw SyntaxError("Expected identifier for the filter");s(n.OpenParen)&&(e=w(e)),t=new I(t,e)}return t}();for(;s(n.Is);){++r;let e=s(n.Not);e&&++r;let i=T();if(i instanceof x&&(i=new _(i.value.toString())),!(i instanceof _))throw SyntaxError("Expected identifier for the test");t=new z(t,e,i)}return t}function T(){let t=e[r];switch(t.type){case n.NumericLiteral:return++r,new b(Number(t.value));case n.StringLiteral:return++r,new v(t.value);case n.BooleanLiteral:return++r,new x("true"===t.value);case n.Identifier:return++r,new _(t.value);case n.OpenParen:{++r;let t=o();if(e[r].type!==n.CloseParen)throw SyntaxError(`Expected closing parenthesis, got ${e[r].type} instead`);return++r,t}case n.OpenSquareBracket:{++r;let e=[];for(;!s(n.CloseSquareBracket);)e.push(a()),s(n.Comma)&&++r;return++r,new E(e)}case n.OpenCurlyBracket:{++r;let e=new Map;for(;!s(n.CloseCurlyBracket);){let t=a();i(n.Colon,"Expected colon between key and value in object literal");let o=a();e.set(t,o),s(n.Comma)&&++r}return++r,new k(e)}default:throw SyntaxError(`Unexpected token: ${t.type}`)}}for(;r<e.length;)t.body.push(function t(){switch(e[r].type){case n.Text:return new v(i(n.Text,"Expected text token").value);case n.OpenStatement:return function(){let l;switch(i(n.OpenStatement,"Expected opening statement token"),e[r].type){case n.Set:++r,l=function e(){let t=a();return s(n.Equals)?(++r,new p(t,e())):t}(),i(n.CloseStatement,"Expected closing statement token");break;case n.If:++r,l=function o(){let l=a();i(n.CloseStatement,"Expected closing statement token");let h=[],u=[];for(;!(e[r]?.type===n.OpenStatement&&(e[r+1]?.type===n.ElseIf||e[r+1]?.type===n.Else||e[r+1]?.type===n.EndIf));)h.push(t());if(e[r]?.type===n.OpenStatement&&e[r+1]?.type!==n.EndIf){if(++r,s(n.ElseIf))i(n.ElseIf,"Expected elseif token"),u.push(o());else for(i(n.Else,"Expected else token"),i(n.CloseStatement,"Expected closing statement token");!(e[r]?.type===n.OpenStatement&&e[r+1]?.type===n.EndIf);)u.push(t())}return new c(l,h,u)}(),i(n.OpenStatement,"Expected {% token"),i(n.EndIf,"Expected endif token"),i(n.CloseStatement,"Expected %} token");break;case n.For:++r,l=function(){let s=o(!0);if(!(s instanceof _||s instanceof A))throw SyntaxError(`Expected identifier/tuple for the loop variable, got ${s.type} instead`);i(n.In,"Expected `in` keyword following loop variable");let l=a();i(n.CloseStatement,"Expected closing statement token");let h=[];for(;function(...t){return r+t.length<=e.length&&t.some((t,n)=>t!==e[r+n].type)}(n.OpenStatement,n.EndFor);)h.push(t());return new d(s,l,h)}(),i(n.OpenStatement,"Expected {% token"),i(n.EndFor,"Expected endfor token"),i(n.CloseStatement,"Expected %} token");break;default:throw SyntaxError(`Unknown statement type: ${e[r].type}`)}return l}();case n.OpenExpression:return function(){i(n.OpenExpression,"Expected opening expression token");let e=a();return i(n.CloseExpression,"Expected closing expression token"),e}();default:throw SyntaxError(`Unexpected token type: ${e[r].type}`)}}());return t}(t)}render(e){let t=new V;for(let[r,n]of(t.set("false",!1),t.set("true",!0),t.set("raise_exception",e=>{throw Error(e)}),t.set("range",U),Object.entries(e)))t.set(r,n);return new D(t).run(this.parsed).value}}},69893:function(e,t,r){"use strict";let n,i;r.d(t,{UG:function(){return S}});let s=2n**255n-19n,o=2n**252n+0x14def9dea2f79cd65812631a5cf5d3edn,a={a:-1n,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,p:s,n:o,h:8,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},l=(e="")=>{throw Error(e)},h=e=>"string"==typeof e,u=e=>e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name,f=(e,t)=>!u(e)||"number"==typeof t&&t>0&&e.length!==t?l("Uint8Array of valid length expected"):e,c=e=>new Uint8Array(e),d=(e,t)=>f(h(e)?v(e):c(f(e)),t),p=(e,t=s)=>{let r=e%t;return r>=0n?r:t+r},g=e=>e instanceof m?e:l("Point expected");class m{constructor(e,t,r,n){this.ex=e,this.ey=t,this.ez=r,this.et=n}static fromAffine(e){return new m(e.x,e.y,1n,p(e.x*e.y))}static fromHex(e,t=!1){let{d:r}=a,n=(e=d(e,32)).slice(),i=e[31];n[31]=-129&i;let o=E(n);t&&!(0n<=o&&o<2n**256n)&&l("bad y coord 1"),t||0n<=o&&o<s||l("bad y coord 2");let h=p(o*o),{isValid:u,value:f}=z(p(h-1n),p(r*h+1n));u||l("bad y coordinate 3");let c=(1n&f)===1n,g=(128&i)!=0;return!t&&0n===f&&g&&l("bad y coord 3"),g!==c&&(f=p(-f)),new m(f,o,1n,p(f*o))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(e){let{ex:t,ey:r,ez:n}=this,{ex:i,ey:s,ez:o}=g(e),a=p(t*o),l=p(i*n),h=p(r*o),u=p(s*n);return a===l&&h===u}is0(){return this.equals(_)}negate(){return new m(p(-this.ex),this.ey,this.ez,p(-this.et))}double(){let{ex:e,ey:t,ez:r}=this,{a:n}=a,i=p(e*e),s=p(t*t),o=p(2n*p(r*r)),l=p(n*i),h=e+t,u=p(p(h*h)-i-s),f=l+s,c=f-o,d=l-s,g=p(u*c),y=p(f*d),_=p(u*d);return new m(g,y,p(c*f),_)}add(e){let{ex:t,ey:r,ez:n,et:i}=this,{ex:s,ey:o,ez:l,et:h}=g(e),{a:u,d:f}=a,c=p(t*s),d=p(r*o),y=p(i*f*h),_=p(n*l),w=p((t+r)*(s+o)-c-d),b=p(_-y),v=p(_+y),x=p(d-u*c),E=p(w*b),A=p(v*x),k=p(w*x);return new m(E,A,p(b*v),k)}mul(e,t=!0){if(0n===e)return!0===t?l("cannot multiply by 0"):_;if("bigint"==typeof e&&0n<e&&e<o||l("invalid scalar, must be < L"),!t&&this.is0()||1n===e)return this;if(this.equals(y))return U(e).p;let r=_,n=y;for(let i=this;e>0n;i=i.double(),e>>=1n)1n&e?r=r.add(i):t&&(n=n.add(i));return r}multiply(e){return this.mul(e)}clearCofactor(){return this.mul(BigInt(a.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.mul(o/2n,!1).double();return o%2n&&(e=e.add(this)),e.is0()}toAffine(){let{ex:e,ey:t,ez:r}=this;if(this.equals(_))return{x:0n,y:1n};let n=k(r);return 1n!==p(r*n)&&l("invalid inverse"),{x:p(e*n),y:p(t*n)}}toRawBytes(){let{x:e,y:t}=this.toAffine(),r=x(t);return r[31]|=1n&e?128:0,r}toHex(){return b(this.toRawBytes())}}m.BASE=new m(0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,0x6666666666666666666666666666666666666666666666666666666666666658n,1n,p(0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an*0x6666666666666666666666666666666666666666666666666666666666666658n)),m.ZERO=new m(0n,1n,1n,0n);let{BASE:y,ZERO:_}=m,w=(e,t)=>e.toString(16).padStart(t,"0"),b=e=>Array.from(e).map(e=>w(e,2)).join(""),v=e=>{let t=e.length;(!h(e)||t%2)&&l("hex invalid 1");let r=c(t/2);for(let t=0;t<r.length;t++){let n=2*t,i=Number.parseInt(e.slice(n,n+2),16);(Number.isNaN(i)||i<0)&&l("hex invalid 2"),r[t]=i}return r},x=e=>v(w(e,64)).reverse(),E=e=>BigInt("0x"+b(c(f(e)).reverse())),A=(...e)=>{let t=c(e.reduce((e,t)=>e+f(t).length,0)),r=0;return e.forEach(e=>{t.set(e,r),r+=e.length}),t},k=(e,t=s)=>{(0n===e||t<=0n)&&l("no inverse n="+e+" mod="+t);let r=p(e,t),n=t,i=0n,o=1n,a=1n,h=0n;for(;0n!==r;){let e=n/r,t=n%r,s=i-a*e,l=o-h*e;n=r,r=t,i=a,o=h,a=s,h=l}return 1n===n?p(i,t):l("no inverse")},B=(e,t)=>{let r=e;for(;t-- >0n;)r*=r,r%=s;return r},I=e=>{let t=e*e%s*e%s,r=B(t,2n)*t%s,n=B(r,1n)*e%s,i=B(n,5n)*n%s,o=B(i,10n)*i%s,a=B(o,20n)*o%s,l=B(a,40n)*a%s,h=B(l,80n)*l%s,u=B(h,80n)*l%s,f=B(u,10n)*i%s;return{pow_p_5_8:B(f,2n)*e%s,b2:t}},z=(e,t)=>{let r=p(t*t*t),n=I(e*p(r*r*t)).pow_p_5_8,i=p(e*r*n),s=p(t*i*i),o=i,a=p(0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n*i),l=s===e,h=s===p(-e),u=s===p(-(0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n*e));return l&&(i=o),(h||u)&&(i=a),(1n&p(i))===1n&&(i=p(-i)),{isValid:l||h,value:i}},C=()=>"object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,S={bytesToHex:b,hexToBytes:v,concatBytes:A,mod:p,invert:k,randomBytes:(e=32)=>{let t=C();return t&&t.getRandomValues||l("crypto.getRandomValues must be defined"),t.getRandomValues(c(e))},sha512Async:async(...e)=>{let t=C();t&&t.subtle||l("crypto.subtle or etc.sha512Async must be defined");let r=A(...e);return c(await t.subtle.digest("SHA-512",r.buffer))},sha512Sync:void 0};Object.defineProperties(S,{sha512Sync:{configurable:!1,get:()=>n,set(e){n||(n=e)}}});let O=()=>{let e=[],t=y,r=t;for(let n=0;n<33;n++){r=t,e.push(r);for(let n=1;n<128;n++)r=r.add(t),e.push(r);t=r.double()}return e},U=e=>{let t=i||(i=O()),r=(e,t)=>{let r=t.negate();return e?r:t},n=_,s=y,o=BigInt(255),a=BigInt(8);for(let i=0;i<33;i++){let l=128*i,h=Number(e&o);e>>=a,h>128&&(h-=256,e+=1n);let u=l+Math.abs(h)-1,f=i%2!=0,c=h<0;0===h?s=s.add(r(f,t[l])):n=n.add(r(c,t[u]))}return{p:n,f:s}}},65376:function(e,t,r){"use strict";function n(e,...t){if(!(e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function i(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function s(e,t){n(e);let r=t.outputLen;if(e.length<r)throw Error(`digestInto() expects output buffer of length at least ${r}`)}r.d(t,{Gg:function(){return i},J8:function(){return s},aI:function(){return n}})},44815:function(e,t,r){"use strict";r.d(t,{VR:function(){return s}});var n=r(65376),i=r(93560);class s extends i.kb{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,i.GL)(this.buffer)}update(e){(0,n.Gg)(this);let{view:t,buffer:r,blockLen:s}=this,o=(e=(0,i.O0)(e)).length;for(let n=0;n<o;){let a=Math.min(s-this.pos,o-n);if(a===s){let t=(0,i.GL)(e);for(;s<=o-n;n+=s)this.process(t,n);continue}r.set(e.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,n.Gg)(this),(0,n.J8)(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:s,isLE:o}=this,{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>s-a&&(this.process(r,0),a=0);for(let e=a;e<s;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),l=n?4:0,h=n?0:4;e.setUint32(t+l,o,n),e.setUint32(t+h,a,n)}(r,s-8,BigInt(8*this.length),o),this.process(r,0);let l=(0,i.GL)(e),h=this.outputLen;if(h%4)throw Error("_sha2: outputLen should be aligned to 32bit");let u=h/4,f=this.get();if(u>f.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)l.setUint32(4*e,f[e],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:n,finished:i,destroyed:s,pos:o}=this;return e.length=n,e.pos=o,e.finished=i,e.destroyed=s,n%t&&e.buffer.set(r),e}}},78967:function(e,t,r){"use strict";r.d(t,{o:function(){return d}});var n=r(44815);let i=BigInt(4294967296-1),s=BigInt(32);var o={split:function(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let o=0;o<e.length;o++){let{h:a,l}=function(e,t=!1){return t?{h:Number(e&i),l:Number(e>>s&i)}:{h:0|Number(e>>s&i),l:0|Number(e&i)}}(e[o],t);[r[o],n[o]]=[a,l]}return[r,n]},shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,add:function(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/4294967296|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,n)=>t+r+n+(e/4294967296|0)|0,add4L:(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),add4H:(e,t,r,n,i)=>t+r+n+i+(e/4294967296|0)|0,add5H:(e,t,r,n,i,s)=>t+r+n+i+s+(e/4294967296|0)|0,add5L:(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},a=r(93560);let[l,h]=o.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),u=new Uint32Array(80),f=new Uint32Array(80);class c extends n.VR{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:r,Bl:n,Ch:i,Cl:s,Dh:o,Dl:a,Eh:l,El:h,Fh:u,Fl:f,Gh:c,Gl:d,Hh:p,Hl:g}=this;return[e,t,r,n,i,s,o,a,l,h,u,f,c,d,p,g]}set(e,t,r,n,i,s,o,a,l,h,u,f,c,d,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|l,this.El=0|h,this.Fh=0|u,this.Fl=0|f,this.Gh=0|c,this.Gl=0|d,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let r=0;r<16;r++,t+=4)u[r]=e.getUint32(t),f[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=0|u[e-15],r=0|f[e-15],n=o.rotrSH(t,r,1)^o.rotrSH(t,r,8)^o.shrSH(t,r,7),i=o.rotrSL(t,r,1)^o.rotrSL(t,r,8)^o.shrSL(t,r,7),s=0|u[e-2],a=0|f[e-2],l=o.rotrSH(s,a,19)^o.rotrBH(s,a,61)^o.shrSH(s,a,6),h=o.rotrSL(s,a,19)^o.rotrBL(s,a,61)^o.shrSL(s,a,6),c=o.add4L(i,h,f[e-7],f[e-16]),d=o.add4H(c,n,l,u[e-7],u[e-16]);u[e]=0|d,f[e]=0|c}let{Ah:r,Al:n,Bh:i,Bl:s,Ch:a,Cl:c,Dh:d,Dl:p,Eh:g,El:m,Fh:y,Fl:_,Gh:w,Gl:b,Hh:v,Hl:x}=this;for(let e=0;e<80;e++){let t=o.rotrSH(g,m,14)^o.rotrSH(g,m,18)^o.rotrBH(g,m,41),E=o.rotrSL(g,m,14)^o.rotrSL(g,m,18)^o.rotrBL(g,m,41),A=g&y^~g&w,k=m&_^~m&b,B=o.add5L(x,E,k,h[e],f[e]),I=o.add5H(B,v,t,A,l[e],u[e]),z=0|B,C=o.rotrSH(r,n,28)^o.rotrBH(r,n,34)^o.rotrBH(r,n,39),S=o.rotrSL(r,n,28)^o.rotrBL(r,n,34)^o.rotrBL(r,n,39),O=r&i^r&a^i&a,U=n&s^n&c^s&c;v=0|w,x=0|b,w=0|y,b=0|_,y=0|g,_=0|m,({h:g,l:m}=o.add(0|d,0|p,0|I,0|z)),d=0|a,p=0|c,a=0|i,c=0|s,i=0|r,s=0|n;let M=o.add3L(z,S,U);r=o.add3H(M,I,C,O),n=0|M}({h:r,l:n}=o.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:s}=o.add(0|this.Bh,0|this.Bl,0|i,0|s)),({h:a,l:c}=o.add(0|this.Ch,0|this.Cl,0|a,0|c)),({h:d,l:p}=o.add(0|this.Dh,0|this.Dl,0|d,0|p)),({h:g,l:m}=o.add(0|this.Eh,0|this.El,0|g,0|m)),({h:y,l:_}=o.add(0|this.Fh,0|this.Fl,0|y,0|_)),({h:w,l:b}=o.add(0|this.Gh,0|this.Gl,0|w,0|b)),({h:v,l:x}=o.add(0|this.Hh,0|this.Hl,0|v,0|x)),this.set(r,n,i,s,a,c,d,p,g,m,y,_,w,b,v,x)}roundClean(){u.fill(0),f.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}let d=(0,a.hE)(()=>new c)},93560:function(e,t,r){"use strict";r.d(t,{GL:function(){return i},O0:function(){return s},hE:function(){return a},kb:function(){return o}});var n=r(65376);let i=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function s(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}(e)),(0,n.aI)(e),e}new Uint8Array(new Uint32Array([287454020]).buffer)[0];class o{clone(){return this._cloneInto()}}function a(e){let t=t=>e().update(s(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}},71542:function(e,t,r){"use strict";let n;r.d(t,{ONNX:function(){return n},p:function(){return h}});var i,s,o=r(50495),a=r(97004),l=r(25566);let h=["wasm"];void 0!==l&&l?.release?.name==="node"?(n=o??(i||(i=r.t(o,2))),h.unshift("cpu")):(n=a??(s||(s=r.t(a,2))),"undefined"!=typeof navigator&&/iP(hone|od|ad).+16_4.+AppleWebKit/.test(navigator.userAgent)&&(n.env.wasm.simd=!1))},90016:function(e,t,r){"use strict";r.d(t,{z:function(){return o}});var n=r(40911);async function i(e,t){return await (0,n.yM)(e,"config.json",!0,t)}class s{constructor(e){this.model_type=null,this.is_encoder_decoder=!1,Object.assign(this,e)}static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:n=null,local_files_only:s=!1,revision:o="main"}={}){return new this(r??await i(e,{progress_callback:t,config:r,cache_dir:n,local_files_only:s,revision:o}))}}class o{static async from_pretrained(...e){return s.from_pretrained(...e)}}},50851:function(e,t,r){"use strict";r.d(t,{O:function(){return m}});var n=r(78386),i=r(73342),s=r(48464);let{env:o}=r(71542).ONNX,a="2.17.1",l="undefined"!=typeof self&&"caches"in self,h=!y(n),u=!y(i),f=h&&u,c=f?i.dirname(i.dirname(s.fileURLToPath("file:///Users/hrishioa/Dropbox/Projects/ChatGPT/Synthient/rakis/node_modules/@xenova/transformers/src/env.js"))):"./",d=f?i.join(c,"/.cache/"):null,p="/models/",g=f?i.join(c,p):p;o?.wasm&&(o.wasm.wasmPaths=f?i.join(c,"/dist/"):`https://cdn.jsdelivr.net/npm/@xenova/transformers@${a}/dist/`);let m={backends:{onnx:o,tfjs:{}},__dirname:c,version:a,allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!0,localModelPath:g,useFS:h,useBrowserCache:l,useFSCache:h,cacheDir:d,useCustomCache:!1,customCache:null};function y(e){return 0===Object.keys(e).length}},78703:function(e,t,r){"use strict";let n,i,s;r.d(t,{qCb:function(){return u.qC},EUT:function(){return eK},eaU:function(){return f.e}});var o=r(9046),a=r(99454),l=r(20761),h=r(40911),u=r(68709),f=r(62414),c=r(50851),d=r(68741);let p="undefined"!=typeof self,g=p&&"DedicatedWorkerGlobalScope"===self.constructor.name;if(p)n=(e,t)=>{if(!self.OffscreenCanvas)throw Error("OffscreenCanvas not supported by this browser.");return new self.OffscreenCanvas(e,t)},s=self.createImageBitmap,i=self.ImageData;else if(d)s=async e=>{let t=(await e.metadata()).channels,{data:r,info:n}=await e.raw().toBuffer({resolveWithObject:!0}),i=new _(new Uint8ClampedArray(r),n.width,n.height,n.channels);return void 0!==t&&t!==n.channels&&i.convert(t),i};else throw Error("Unable to load image processing library.");let m={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},y=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]);class _{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 _)return e;if("string"==typeof e||e instanceof URL)return await this.fromURL(e);throw Error(`Unsupported input type: ${typeof e}`)}static async fromURL(e){let t=await (0,h.hn)(e);if(200!==t.status)throw Error(`Unable to read image from "${e}" (${t.status} ${t.statusText})`);let r=await t.blob();return this.fromBlob(r)}static async fromBlob(e){if(p){let t=await s(e),r=n(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)}{let t=d(await e.arrayBuffer());return await s(t)}}static fromTensor(e,t="CHW"){if(3!==e.dims.length)throw 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);else throw Error(`Unsupported channel format: ${t}`);if(!(e.data instanceof Uint8ClampedArray||e.data instanceof Uint8Array))throw Error(`Unsupported tensor type: ${e.type}`);switch(e.dims[2]){case 1:case 2:case 3:case 4:return new _(e.data,e.dims[1],e.dims[0],e.dims[2]);default:throw Error(`Unsupported number of channels: ${e.dims[2]}`)}}grayscale(){if(1===this.channels)return this;let 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){let n=this.data[t],i=this.data[t+1],s=this.data[t+2];e[r++]=Math.round(.2989*n+.587*i+.114*s)}break;default:throw 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;let 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 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;let 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 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 i=m[r]??r;if(p){let r=this.channels,i=this.toCanvas(),s=n(e,t).getContext("2d");return s.drawImage(i,0,0,e,t),new _(s.getImageData(0,0,e,t).data,e,t,4).convert(r)}{let r=this.toSharp();switch(i){case"box":case"hamming":("box"===i||"hamming"===i)&&(console.warn(`Resampling method ${i} is not yet supported. Using bilinear instead.`),i="bilinear");case"nearest":case"bilinear":case"bicubic":r=r.affine([e/this.width,0,0,t/this.height],{interpolator:i});break;case"lanczos":r=r.resize({width:e,height:t,fit:"fill",kernel:"lanczos3"});break;default:throw Error(`Resampling method ${i} is not supported.`)}return await s(r)}}async pad([e,t,r,i]){if(e=Math.max(e,0),t=Math.max(t,0),r=Math.max(r,0),i=Math.max(i,0),0===e&&0===t&&0===r&&0===i)return this;if(p){let s=this.channels,o=this.toCanvas(),a=this.width+e+t,l=this.height+r+i,h=n(a,l).getContext("2d");return h.drawImage(o,0,0,this.width,this.height,e,r,a,l),new _(h.getImageData(0,0,a,l).data,a,l,4).convert(s)}{let n=this.toSharp().extend({left:e,right:t,top:r,bottom:i});return await s(n)}}async crop([e,t,r,i]){if(e=Math.max(e,0),t=Math.max(t,0),r=Math.min(r,this.width-1),i=Math.min(i,this.height-1),0===e&&0===t&&r===this.width-1&&i===this.height-1)return this;let o=r-e+1,a=i-t+1;if(p){let r=this.channels,i=this.toCanvas(),s=n(o,a).getContext("2d");return s.drawImage(i,e,t,o,a,0,0,o,a),new _(s.getImageData(0,0,o,a).data,o,a,4).convert(r)}{let r=this.toSharp().extract({left:e,top:t,width:o,height:a});return await s(r)}}async center_crop(e,t){if(this.width===e&&this.height===t)return this;let r=(this.width-e)/2,i=(this.height-t)/2;if(p){let s=this.channels,o=this.toCanvas(),a=n(e,t).getContext("2d"),l=0,h=0,u=0,f=0;return r>=0?l=r:u=-r,i>=0?h=i:f=-i,a.drawImage(o,l,h,e,t,u,f,e,t),new _(a.getImageData(0,0,e,t).data,e,t,4).convert(s)}{let n=this.toSharp();if(r>=0&&i>=0)n=n.extract({left:Math.floor(r),top:Math.floor(i),width:e,height:t});else if(r<=0&&i<=0){let s=Math.floor(-i),o=Math.floor(-r);n=n.extend({top:s,left:o,right:e-this.width-o,bottom:t-this.height-s})}else{let s=[0,0],o=0;i<0?(s[0]=Math.floor(-i),s[1]=t-this.height-s[0]):o=Math.floor(i);let a=[0,0],l=0;r<0?(a[0]=Math.floor(-r),a[1]=e-this.width-a[0]):l=Math.floor(r),n=n.extend({top:s[0],bottom:s[1],left:a[0],right:a[1]}).extract({left:l,top:o,width:e,height:t})}return await s(n)}}async toBlob(e="image/png",t=1){if(!p)throw Error("toBlob() is only supported in browser environments.");let r=this.toCanvas();return await r.convertToBlob({type:e,quality:t})}toTensor(e="CHW"){let t=new f.es("uint8",new Uint8Array(this.data),[this.height,this.width,this.channels]);if("HWC"===e);else if("CHW"===e)t=t.permute(2,0,1);else throw Error(`Unsupported channel format: ${e}`);return t}toCanvas(){if(!p)throw Error("toCanvas() is only supported in browser environments.");let e=this.clone().rgba(),t=n(e.width,e.height),r=new i(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 _(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 Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(p){if(g)throw Error("Unable to save an image from a Web Worker.");let t=e.split(".").pop().toLowerCase(),r=y.get(t)??"image/png",n=await this.toBlob(r),i=URL.createObjectURL(n),s=document.createElement("a");s.href=i,s.download=e,s.click(),s.remove()}else if(c.O.useFS){let t=this.toSharp();return await t.toFile(e)}else throw Error("Unable to save the image because filesystem is disabled in this environment.")}toSharp(){if(p)throw Error("toSharp() is only supported in server-side environments.");return d(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}}async function w(e,t){let r;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.");let n=await (await (0,h.hn)(e)).arrayBuffer(),i=new AudioContext({sampleRate:t});void 0===t&&console.warn(`No sampling rate provided, using default of ${i.sampleRate}Hz.`);let s=await i.decodeAudioData(n);if(2===s.numberOfChannels){let e=Math.sqrt(2),t=s.getChannelData(0),n=s.getChannelData(1);r=new Float32Array(t.length);for(let i=0;i<s.length;++i)r[i]=e*(t[i]+n[i])/2}else r=s.getChannelData(0);return r}function b(e){if(e<1)return new Float64Array;if(1===e)return new Float64Array([1]);let t=e-1,r=Math.PI/t,n=new Float64Array(e);for(let i=0;i<e;++i){let e=2*i-t;n[i]=.5+.5*Math.cos(r*e)}return n}let v={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 x(e,t="htk"){let r=v[t];if(!r)throw Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return"number"==typeof e?r(e):e.map(e=>r(e))}let E={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 A(e,t,r){let n=(t-e)/(r-1);return Float64Array.from({length:r},(t,r)=>e+n*r)}function k(e,t,r,n,i,s=null,o="htk",a=!1){let l;if(null!==s&&"slaney"!==s)throw Error('norm must be one of null or "slaney"');let h=A(x(r,o),x(n,o),t+2),u=function(e,t="htk"){let r=E[t];if(!r)throw Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return"number"==typeof e?r(e):e.map(e=>r(e))}(h,o);if(a){let t=i/(2*e);l=x(Float64Array.from({length:e},(e,r)=>r*t),o),u=h}else l=A(0,Math.floor(i/2),e);let f=function(e,t){let r=Float64Array.from({length:t.length-1},(e,r)=>t[r+1]-t[r]),n=Array.from({length:e.length},()=>Array(t.length));for(let r=0;r<e.length;++r){let i=n[r];for(let n=0;n<t.length;++n)i[n]=t[n]-e[r]}let i=t.length-2,s=Array.from({length:i},()=>Array(e.length));for(let t=0;t<e.length;++t){let e=n[t];for(let n=0;n<i;++n){let i=-e[n]/r[n],o=e[n+2]/r[n+1];s[n][t]=Math.max(0,Math.min(i,o))}}return s}(l,u);if(null!==s&&"slaney"===s)for(let r=0;r<t;++r){let t=f[r],n=2/(u[r+2]-u[r]);for(let r=0;r<e;++r)t[r]*=n}return f}function B(e,t,r,n,i){if(r<=0)throw Error("reference must be greater than zero");if(n<=0)throw Error("min_value must be greater than zero");let s=Math.log10(r=Math.max(n,r));for(let r=0;r<e.length;++r)e[r]=t*Math.log10(Math.max(n,e[r])-s);if(null!==i){if(i<=0)throw Error("db_range must be greater than zero");let t=(0,u.Fp)(e)[0]-i;for(let r=0;r<e.length;++r)e[r]=Math.max(e[r],t)}return e}function I(e,t,r,n,{fft_length:i=null,power:s=1,center:o=!0,pad_mode:a="reflect",onesided:h=!0,preemphasis:f=null,mel_filters:c=null,mel_floor:d=1e-10,log_mel:p=null,reference:g=1,min_value:m=1e-10,db_range:y=null,remove_dc_offset:_=null,max_num_frames:w=null,do_pad:b=!0,transpose:v=!1}={}){let x=t.length;if(null===i&&(i=r),r>i)throw Error(`frame_length (${r}) may not be larger than fft_length (${i})`);if(x!==r)throw Error(`Length of the window (${x}) must equal frame_length (${r})`);if(n<=0)throw Error("hop_length must be greater than zero");if(o){if("reflect"!==a)throw Error(`pad_mode="${a}" not implemented yet.`);let t=Math.floor((i-1)/2)+1;e=function(e,t,r){let n=new e.constructor(e.length+t+r),i=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,l.hs)(r,i)];for(let s=1;s<=r;++s)n[i+t+s]=e[(0,l.hs)(i-s,i)];return n}(e,t,t)}let E=Math.floor(1+Math.floor((e.length-r)/n)),A=h?Math.floor(i/2)+1:i,k=E,I=E;null!==w&&(w>E?b&&(I=w):I=k=w);let z=new u.vw(i),C=new Float64Array(i),S=new Float64Array(z.outputBufferSize),O=Array(k);for(let i=0;i<k;++i){let s=i*n;for(let t=0;t<r;++t)C[t]=e[s+t];if(_){let e=0;for(let t=0;t<r;++t)e+=C[t];let t=e/r;for(let e=0;e<r;++e)C[e]-=t}if(null!==f){for(let e=r-1;e>=1;--e)C[e]-=f*C[e-1];C[0]*=1-f}for(let e=0;e<t.length;++e)C[e]*=t[e];z.realTransform(S,C);let o=Array(A);for(let e=0;e<o.length;++e){let t=e<<1;o[e]=S[t]**2+S[t+1]**2}O[i]=o}if(null!==s&&2!==s){let e=2/s;for(let t=0;t<O.length;++t){let r=O[t];for(let t=0;t<r.length;++t)r[t]**=e}}let U=c.length,M=new Float32Array(U*I),T=v?[I,U]:[U,I];for(let e=0;e<U;++e){let t=c[e];for(let r=0;r<k;++r){let n=O[r],i=0;for(let e=0;e<A;++e)i+=t[e]*n[e];M[v?r*U+e:e*k+r]=Math.max(d,i)}}if(null!==s&&null!==p){let e=Math.min(M.length,k*U);switch(p){case"log":for(let t=0;t<e;++t)M[t]=Math.log(M[t]);break;case"log10":for(let t=0;t<e;++t)M[t]=Math.log10(M[t]);break;case"dB":if(1===s)!function(e,t=1,r=1e-5,n=null){B(e,20,t,r,n)}(M,g,m,y);else if(2===s)!function(e,t=1,r=1e-10,n=null){B(e,10,t,r,n)}(M,g,m,y);else throw Error(`Cannot use log_mel option '${p}' with power ${s}`);break;default:throw Error(`log_mel must be one of null, 'log', 'log10' or 'dB'. Got '${p}'`)}}return{data:M,dims:T}}function z(e,t,{periodic:r=!0,frame_length:n=null,center:i=!0}={}){let s;let o=r?e+1:e;switch(t){case"boxcar":s=new Float64Array(o).fill(1);break;case"hann":case"hann_window":s=b(o);break;case"povey":s=b(o).map(e=>Math.pow(e,.85));break;default:throw Error(`Unknown window type ${t}.`)}if(r&&(s=s.subarray(0,e)),null===n)return s;if(e>n)throw Error(`Length of the window (${e}) may not be larger than frame_length (${n})`);return s}function C(e,t=.5,r=null,n=!1){let i=e.logits,s=e.pred_boxes,[o,a,l]=i.dims;if(null!==r&&r.length!==o)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<o;++e){let o=null!==r?r[e]:null,f={boxes:[],classes:[],scores:[]},c=i[e],d=s[e];for(let e=0;e<a;++e){let r,i=c[e],s=[];if(n){r=i.sigmoid().data;for(let e=0;e<r.length;++e)r[e]>t&&s.push(e)}else{let e=(0,u.Fp)(i.data)[1];if(e===l-1)continue;s.push(e),r=(0,u.XA)(i.data)}for(let t of s){let n=d[e].data;n=function([e,t,r,n]){return[e-r/2,t-n/2,e+r/2,t+n/2]}(n),null!==o&&(n=n.map((e,t)=>e*o[(t+1)%2])),f.boxes.push(n),f.classes.push(t),f.scores.push(r[t])}}h.push(f)}return h}function S(e,t){if(!(e instanceof Float32Array||e instanceof Float64Array))throw 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 O(e,t,r=0,n=null){let i=e/t,s=(0,u.eT)(i)*t;return null!==n&&s>n&&(s=Math.floor(i)*t),s<r&&(s=Math.ceil(i)*t),s}function U([e,t],r){return[Math.max(Math.floor(e/r),1)*r,Math.max(Math.floor(t/r),1)*r]}class M extends l.Ag{constructor(e){super(),this.config=e}}class T extends M{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)}async thumbnail(e,t,r=2){let n=e.height,i=e.width,s=t.height,o=t.width,a=Math.min(n,s),l=Math.min(i,o);return a===n&&l===i?e:(n>i?l=Math.floor(i*a/n):i>n&&(a=Math.floor(n*l/i)),await e.resize(l,a,{resample:r}))}async crop_margin(e,t=200){let r=e.clone().grayscale(),n=(0,u.VV)(r.data)[0],i=(0,u.Fp)(r.data)[0]-n;if(0===i)return e;let s=t/255,o=r.width,a=r.height,l=0,h=0;for(let e=0;e<r.height;++e){let t=e*r.width;for(let u=0;u<r.width;++u)(r.data[t+u]-n)/i<s&&(o=Math.min(o,u),a=Math.min(a,e),l=Math.max(l,u),h=Math.max(h,e))}return e=await e.crop([o,a,l,h])}pad_image(e,t,r,{mode:n="constant",center:i=!1,constant_values:s=0}={}){let o,a;let[h,u,f]=t;if("number"==typeof r?(o=r,a=r):(o=r.width,a=r.height),o!==u||a!==h){let r=new Float32Array(o*a*f);if(Array.isArray(s))for(let e=0;e<r.length;++e)r[e]=s[e%f];else 0!==s&&r.fill(s);let[c,d]=i?[Math.floor((o-u)/2),Math.floor((a-h)/2)]:[0,0];for(let t=0;t<h;++t){let n=(t+d)*o,i=t*u;for(let t=0;t<u;++t){let s=(n+t+c)*f,o=(i+t)*f;for(let t=0;t<f;++t)r[s+t]=e[o+t]}}if("symmetric"===n){if(i)throw Error("`center` padding is not supported when `mode` is set to `symmetric`.");let t=h-1,n=u-1;for(let i=0;i<a;++i){let s=i*o,a=(0,l.hs)(i,t)*u;for(let t=0;t<o;++t){if(i<h&&t<u)continue;let o=(s+t)*f,c=(a+(0,l.hs)(t,n))*f;for(let t=0;t<f;++t)r[o+t]=e[c+t]}}}e=r,t=[a,o,f]}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){let r,n;let[i,s]=e.size;if(this.do_thumbnail){let{height:e,width:n}=t;r=Math.min(e,n)}else Number.isInteger(t)?(r=t,n=this.config.max_size??r):void 0!==t&&(r=t.shortest_edge,n=t.longest_edge);if(void 0!==r||void 0!==n){let e=void 0===r?1:Math.max(r/i,r/s),t=i*e,o=s*e,a=void 0===n?1:Math.min(n/t,n/o),l=Math.floor(Number((t*a).toFixed(2))),h=Math.floor(Number((o*a).toFixed(2)));return void 0!==this.size_divisibility&&([l,h]=U([l,h],this.size_divisibility)),[l,h]}if(void 0!==t&&void 0!==t.width&&void 0!==t.height){let e=t.width,r=t.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let t=r/s,n=e/i;Math.abs(1-n)<Math.abs(1-t)?t=n:n=t,r=O(t*s,this.config.ensure_multiple_of),e=O(n*i,this.config.ensure_multiple_of)}return[e,r]}if(void 0!==this.size_divisibility)return U([i,s],this.size_divisibility);throw Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(t)}`)}async resize(e){let[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:i=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));let[s,o]=e.size;if(n??this.do_convert_rgb?e=e.rgb():i&&(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)}let a=[e.height,e.width],l=Float32Array.from(e.data),h=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(l),t??this.do_normalize){let t=this.image_mean;Array.isArray(this.image_mean)||(t=Array(e.channels).fill(t));let r=this.image_std;if(Array.isArray(this.image_std)||(r=Array(e.channels).fill(t)),t.length!==e.channels||r.length!==e.channels)throw 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<l.length;n+=e.channels)for(let i=0;i<e.channels;++i)l[n+i]=(l[n+i]-t[i])/r[i]}if(r??this.do_pad){if(this.pad_size){let t=this.pad_image(l,[e.height,e.width,e.channels],this.pad_size);[l,h]=t}else if(this.size_divisibility){let[e,t]=U([h[1],h[0]],this.size_divisibility);[l,h]=this.pad_image(l,h,{width:e,height:t})}}return{original_size:[o,s],reshaped_input_size:a,pixel_values:new f.es("float32",l,h).permute(2,0,1)}}async _call(e,...t){Array.isArray(e)||(e=[e]);let r=await Promise.all(e.map(e=>this.preprocess(e)));return{pixel_values:(0,f.kn)(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 $ extends T{post_process_semantic_segmentation(e,t=null){let 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");let i=[];for(let e=0;e<n;++e){let n=null!==t?t[e]:null,s=r[e];null!==n&&(s=(0,f.sX)(s,n,"bilinear",!1));let[o,a]=n??s.dims.slice(-2),l=new f.es("int32",new Int32Array(o*a),[o,a]),h=s[0].data;for(let e=1;e<s.dims[0];++e){let t=s[e].data;for(let r=0;r<t.length;++r)t[r]>h[r]&&(h[r]=t[r],l.data[r]=e)}let u=Array(s.dims[0]),c=l.data;for(let e=0;e<c.length;++e){let t=c[e];u[t]=t}let d=u.filter(e=>void 0!==e);i.push({segmentation:l,labels:d})}return i}}class L extends T{}class R extends L{}class j extends T{}class F extends T{}class N extends T{}class P extends T{}class q extends T{}class H extends T{constructor(e){super(e),this.crop_pct=this.config.crop_pct??.875}async resize(e){let t=this.size?.shortest_edge;if(void 0===t)throw Error("Size dictionary must contain 'shortest_edge' key.");if(t<384){let r=Math.floor(t/this.crop_pct),[n,i]=this.get_resize_output_image_size(e,{shortest_edge:r});e=await e.resize(n,i,{resample:this.resample}),e=await e.center_crop(t,t)}else e=await e.resize(t,t,{resample:this.resample});return e}}class G extends H{}class V extends T{}class D extends T{}class X 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 W extends T{}class J extends T{post_process_object_detection(...e){return C(...e)}}class K extends J{}class Y extends T{}class Z extends T{}class Q extends T{pad_image(e,t,r,n={}){let[i,s,o]=t,a=this.image_mean;Array.isArray(this.image_mean)||(a=Array(o).fill(a));let l=this.image_std;Array.isArray(l)||(l=Array(o).fill(a));let h=a.map((e,t)=>-e/l[t]);return super.pad_image(e,t,r,{center:!0,constant_values:h,...n})}}class ee extends Q{}class et extends T{async _call(e){let t=await super._call(e),r=[t.pixel_values.dims[0],64,64],n=new f.es("int64",new BigInt64Array(r.reduce((e,t)=>e*t)).fill(1n),r);return{...t,pixel_mask:n}}post_process_object_detection(...e){return C(...e)}remove_low_and_no_objects(e,t,r,n){let i=[],s=[],o=[];for(let a=0;a<e.dims[0];++a){let l=e[a],h=t[a],f=(0,u.Fp)(l.data)[1];if(f===n)continue;let c=(0,u.XA)(l.data)[f];c>r&&(i.push(h),s.push(c),o.push(f))}return[i,s,o]}check_segment_validity(e,t,r,n=.5,i=.8){let s=[],o=0,a=0;for(let i=0;i<e.length;++i)e[i]===r&&(s.push(i),++o),t[r].data[i]>=n&&++a;let l=o>0&&a>0;return l&&(l=o/a>i),[l,s]}compute_segments(e,t,r,n,i,s=null,o=null){let[a,l]=o??e[0].dims,h=new f.es("int32",new Int32Array(a*l),[a,l]),u=[];if(null!==o)for(let t=0;t<e.length;++t)e[t]=(0,f.sX)(e[t],o,"bilinear",!1);let c=new Int32Array(e[0].data.length),d=new Float32Array(e[0].data.length);for(let r=0;r<e.length;++r){let n=t[r];for(let t=0;t<e[r].data.length;++t)e[r].data[t]*=n,e[r].data[t]>d[t]&&(c[t]=r,d[t]=e[r].data[t])}let p=0;for(let s=0;s<r.length;++s){let o=r[s],[a,l]=this.check_segment_validity(c,e,s,n,i);if(a){for(let e of(++p,l))h.data[e]=p;u.push({id:p,label_id:o,score:t[s]})}}return[h,u]}post_process_panoptic_segmentation(e,t=.5,r=.5,n=.8,i=null,s=null){null===i&&(console.warn("`label_ids_to_fuse` unset. No instance will be fused."),i=new Set);let o=e.logits,a=e.pred_masks.sigmoid(),[l,h,u]=o.dims;if(u-=1,null!==s&&s.length!==l)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let c=[];for(let e=0;e<l;++e){let l=null!==s?s[e]:null,h=o[e],d=a[e],[p,g,m]=this.remove_low_and_no_objects(h,d,t,u);if(0===m.length){let[e,t]=l??d.dims.slice(-2),r=new f.es("int32",new Int32Array(e*t).fill(-1),[e,t]);c.push({segmentation:r,segments_info:[]});continue}let[y,_]=this.compute_segments(p,g,m,r,n,i,l);c.push({segmentation:y,segments_info:_})}return c}post_process_instance_segmentation(){throw Error("Not implemented yet")}}class er extends T{post_process_object_detection(...e){return C(...e)}}class en extends T{reshape_input_points(e,t,r){e=structuredClone(e);let n=(0,l.jg)(e);if(3===n.length)n=[1,...n],e=[e];else if(4!==n.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 i=t[n],s=r[n],o=[s[0]/i[0],s[1]/i[1]];for(let t=0;t<e[n].length;++t)for(let r=0;r<e[n][t].length;++r)for(let i=0;i<e[n][t][r].length;++i)e[n][t][r][i]*=o[i]}return new f.es("float32",Float32Array.from(e.flat(1/0)),n)}add_input_labels(e,t){let r=(0,l.jg)(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 f.es("int64",e.flat(1/0).map(BigInt),r)}async _call(e,t=null,r=null){let n=await super._call(e);if(t&&(n.input_points=this.reshape_input_points(t,n.original_sizes,n.reshaped_input_sizes)),r){if(!n.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");n.input_labels=this.add_input_labels(r,n.input_points)}return n}post_process_masks(e,t,r,{mask_threshold:n=0,binarize:i=!0,pad_size:s=null}={}){let o=[],a=[(s=s??this.pad_size).height,s.width];for(let s=0;s<t.length;++s){let l=t[s],h=r[s],u=e[s],c=[];for(let e=0;e<u.dims[0];++e){let t=u[e],r=(0,f.sX)(t,a,"bilinear",!1);if(r=r.slice(null,[0,h[0]],[0,h[1]]),r=(0,f.sX)(r,l,"bilinear",!1),i){let e=new Uint8Array(r.data.length);for(let t=0;t<r.data.length;++t)r.data[t]>n&&(e[t]=1);r=new f.es("bool",e,r.dims)}c.push(r)}o.push((0,f.kn)(c))}return o}}class ei extends T{pad_image(e,t,r,n={}){let[i,s,o]=t;return super.pad_image(e,t,{width:s+(r-s%r)%r,height:i+(r-i%r)%r},{mode:"symmetric",center:!1,constant_values:-1,...n})}}class es extends T{async _call(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let 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,f.kn)(r.map((e,t)=>(0,f.d3)([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 eo extends M{constructor(e){super(e),this.config.mel_filters??=k(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=z(this.config.n_fft,"hann")}_extract_fbank_features(e){let{data:t,dims:r}=I(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}),n=(0,u.Fp)(t)[0];for(let e=0;e<t.length;++e)t[e]=(Math.max(t[e],n-8)+4)/4;return{data:t,dims:r}}async _call(e){let t;S(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)).set(e);let{data:r,dims:n}=this._extract_fbank_features(t);return{input_features:new f.es("float32",r,[1,...n])}}}class ea extends M{_zero_mean_unit_var_norm(e){let 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){S(e,"Wav2Vec2FeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let t=e;this.config.do_normalize&&(t=this._zero_mean_unit_var_norm(t));let r=[1,t.length];return{input_values:new f.es("float32",t,r),attention_mask:new f.es("int64",new BigInt64Array(t.length).fill(1n),r)}}}class el extends M{constructor(e){super(e);let t=this.config.sampling_rate,r=k(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=z(400,"povey",{periodic:!1})}_extract_fbank_features(e,t){return I(e=e.map(e=>32768*e),this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,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:i=!0}={}){let s;S(e,"SeamlessM4TFeatureExtractor");let o=this._extract_fbank_features(e,this.config.max_length);if(n){let[e,t]=o.dims;for(let r=0;r<t;++r){let n=0;for(let i=0;i<e;++i)n+=o.data[i*t+r];let i=n/e,s=0;for(let n=0;n<e;++n)s+=(o.data[n*t+r]-i)**2;let a=Math.sqrt((s/=e-1)+1e-7);for(let n=0;n<e;++n){let e=n*t+r;o.data[e]=(o.data[e]-i)/a}}}if(t){let[e,t]=o.dims,n=e%r;if(n>0){let r=new Float32Array(t*(e+n));r.set(o.data),r.fill(this.config.padding_value,o.data.length);let a=e+n;o={data:r,dims:[a,t]},i&&(s=new f.es("int64",new BigInt64Array(a),[1,a])).data.fill(1n,0,e)}}let[a,l]=o.dims,h=this.config.stride;if(0!=a%h)throw Error(`The number of frames (${a}) must be a multiple of the stride (${h}).`);let u=new f.es("float32",o.data,o.dims).view(1,Math.floor(a/h),l*h),c={input_features:u};if(i){let e=u.dims[1],t=new f.es("int64",new BigInt64Array(e),[1,e]);if(s)for(let e=1,r=0;e<a;e+=h,++r)t.data[r]=s.data[e];else t.data.fill(1n);c.attention_mask=t}return c}}class eh extends M{constructor(e){super(e);let t=this.config.sampling_rate,r=k(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=z(400,"hann",{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}_extract_fbank_features(e,t){return I(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e){S(e,"ASTFeatureExtractor");let t=this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let e=2*this.std;for(let r=0;r<t.data.length;++r)t.data[r]=(t.data[r]-this.mean)/e}return{input_values:new f.es("float32",t.data,[1,...t.dims])}}}class eu extends M{constructor(e){super(e),this.mel_filters=k(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=k(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=z(this.config.fft_window_size,"hann")}_get_input_mel(e,t,r,n){let i;let s=!1,o=e.length-t;if(o>0){if("rand_trunc"===r){s=!0;let r=Math.floor(Math.random()*(o+1));e=e.subarray(r,r+t),(i=this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)).dims=[1,...i.dims]}else throw Error(`Truncation strategy "${r}" not implemented`)}else{if(o<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<-o;t+=e.length)r.set(e,t);e=r}if("fusion"===r)throw Error(`Truncation strategy "${r}" not implemented`);(i=this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)).dims=[1,...i.dims]}return{...i,longer:s}}_extract_fbank_features(e,t,r=null){return I(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}={}){S(e,"ClapFeatureExtractor");let r=this._get_input_mel(e,t??this.config.nb_max_samples,this.config.truncation,this.config.padding);return{input_features:new f.es("float32",r.data,[1,...r.dims])}}}class ef extends M{}class ec extends l.Ag{constructor(e){super(),this.feature_extractor=e}async _call(e,...t){return await this.feature_extractor(e,...t)}}class ed extends ec{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 ep extends ec{async _call(e){return await this.feature_extractor(e)}}class eg extends ec{async _call(e){return await this.feature_extractor(e)}}class em extends ec{async _call(e){return await this.feature_extractor(e)}}class ey extends ec{}class e_{static FEATURE_EXTRACTOR_CLASS_MAPPING={ImageFeatureExtractor:T,WhisperFeatureExtractor:eo,ViTFeatureExtractor:V,MobileViTFeatureExtractor:W,OwlViTFeatureExtractor:J,Owlv2ImageProcessor:K,CLIPFeatureExtractor:N,ChineseCLIPFeatureExtractor:P,SiglipImageProcessor:q,ConvNextFeatureExtractor:H,ConvNextImageProcessor:G,SegformerFeatureExtractor:$,BitImageProcessor:j,DPTImageProcessor:R,DPTFeatureExtractor:L,GLPNFeatureExtractor:F,BeitFeatureExtractor:Z,DeiTFeatureExtractor:Y,DetrFeatureExtractor:et,YolosFeatureExtractor:er,DonutFeatureExtractor:Q,NougatImageProcessor:ee,EfficientNetImageProcessor:X,ViTImageProcessor:D,VitMatteImageProcessor:es,SamImageProcessor:en,Swin2SRImageProcessor:ei,Wav2Vec2FeatureExtractor:ea,SeamlessM4TFeatureExtractor:el,SpeechT5FeatureExtractor:ef,ASTFeatureExtractor:eh,ClapFeatureExtractor:eu};static PROCESSOR_CLASS_MAPPING={WhisperProcessor:ep,Wav2Vec2ProcessorWithLM:eg,SamProcessor:ed,SpeechT5Processor:em,OwlViTProcessor:ey};static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:n=null,local_files_only:i=!1,revision:s="main"}={}){let o=r??await (0,h.yM)(e,"preprocessor_config.json",!0,{progress_callback:t,config:r,cache_dir:n,local_files_only:i,revision:s}),a=o.feature_extractor_type??o.image_processor_type,l=this.FEATURE_EXTRACTOR_CLASS_MAPPING[a];if(!l){if(void 0!==o.size)console.warn(`Feature extractor type "${a}" not found, assuming ImageFeatureExtractor due to size parameter in config.`),l=T;else throw Error(`Unknown Feature Extractor type: ${a}`)}return new(this.PROCESSOR_CLASS_MAPPING[o.processor_class]??ec)(new l(o))}}async function ew(e){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>_.read(e)))}async function eb(e,t){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>"string"==typeof e||e instanceof URL?w(e,t):e instanceof Float64Array?new Float32Array(e):e))}function ev(e,t){t&&(e=e.map(e=>0|e));let[r,n,i,s]=e;return{xmin:r,ymin:n,xmax:i,ymax:s}}class ex extends l.Ag{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 eE extends ex{constructor(e){super(e)}async _call(e,{topk:t=1}={}){let r=this.tokenizer(e,{padding:!0,truncation:!0}),n=await this.model(r),i="multi_label_classification"===this.model.config.problem_type?e=>e.sigmoid().data:e=>(0,u.XA)(e.data),s=this.model.config.id2label,o=[];for(let e of n.logits){let r=i(e),n=(0,u.em)(r,t).map(e=>({label:s[e[0]],score:e[1]}));1===t?o.push(...n):o.push(n)}return Array.isArray(e)||1===t?o:o[0]}}class eA extends ex{constructor(e){super(e)}async _call(e,{ignore_labels:t=["O"]}={}){let r=Array.isArray(e),n=this.tokenizer(r?e:[e],{padding:!0,truncation:!0}),i=(await this.model(n)).logits,s=this.model.config.id2label,o=[];for(let e=0;e<i.dims[0];++e){let r=n.input_ids[e],a=i[e],l=[];for(let e=0;e<a.dims[0];++e){let n=a[e],i=(0,u.Fp)(n.data)[1],o=s?s[i]:`LABEL_${i}`;if(t.includes(o))continue;let h=this.tokenizer.decode([r[e].item()],{skip_special_tokens:!0});if(""===h)continue;let f=(0,u.XA)(n.data);l.push({entity:o,score:f[i],index:e,word:h,start:null,end:null})}o.push(l)}return r?o:o[0]}}class ek extends ex{constructor(e){super(e)}async _call(e,t,{topk:r=1}={}){let n=this.tokenizer(e,{text_pair:t,padding:!0,truncation:!0}),i=await this.model(n),s=[];for(let e=0;e<i.start_logits.dims[0];++e){let t=n.input_ids[e],o=t.indexOf(this.tokenizer.sep_token_id),a=Array.from((0,u.XA)(i.start_logits[e].data)).map((e,t)=>[e,t]).filter(e=>e[1]>o),h=Array.from((0,u.XA)(i.end_logits[e].data)).map((e,t)=>[e,t]).filter(e=>e[1]>o),f=(0,l.O7)(a,h).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){let[r,n,i]=f[e],o=[...t].slice(r,n+1),a=this.tokenizer.decode(o,{skip_special_tokens:!0});s.push({answer:a,score:i})}}return 1===r?s[0]:s}}class eB extends ex{constructor(e){super(e)}async _call(e,{topk:t=5}={}){let r=this.tokenizer(e,{padding:!0,truncation:!0}),n=await this.model(r),i=[];for(let e=0;e<r.input_ids.dims[0];++e){let s=r.input_ids[e],o=s.indexOf(this.tokenizer.mask_token_id);if(-1===o)throw Error(`Mask token (${this.tokenizer.mask_token}) not found in text.`);let a=n.logits[e][o],l=(0,u.em)((0,u.XA)(a.data),t);i.push(l.map(e=>{let t=[...s];return t[o]=e[0],{score:e[1],token:e[0],token_str:this.tokenizer.model.vocab[e[0]],sequence:this.tokenizer.decode(t,{skip_special_tokens:!0})}}))}return Array.isArray(e)?i:i[0]}}class eI extends ex{_key="generated_text";constructor(e){super(e)}async _call(e,t={}){let r;Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(e=>this.model.config.prefix+e));let n=this.model.config.task_specific_params;n&&n[this.task]&&n[this.task].prefix&&(e=e.map(e=>n[this.task].prefix+e));let i=this.tokenizer,s={padding:!0,truncation:!0};r=this instanceof eC&&"_build_translation_inputs"in i?i._build_translation_inputs(e,s,t).input_ids:i(e,s).input_ids;let o=await this.model.generate(r,t);return i.batch_decode(o,{skip_special_tokens:!0}).map(e=>({[this._key]:e}))}}class ez extends eI{_key="summary_text";constructor(e){super(e)}}class eC extends eI{_key="translation_text";constructor(e){super(e)}}function eS(e){return Array.isArray(e)&&e.every(e=>"role"in e&&"content"in e)}class eO extends ex{constructor(e){super(e)}async _call(e,t={}){let r,n,i=!1,s=!1;if("string"==typeof e)r=e=[e];else if(Array.isArray(e)&&e.every(e=>"string"==typeof e))i=!0,r=e;else{if(eS(e))e=[e];else if(Array.isArray(e)&&e.every(eS))i=!0;else throw Error("Input must be a string, an array of strings, a Chat, or an array of Chats");s=!0,r=e.map(e=>this.tokenizer.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0}))}let o=t.add_special_tokens??!1,a=!s&&(t.return_full_text??!0);this.tokenizer.padding_side="left";let{input_ids:l,attention_mask:h}=this.tokenizer(r,{add_special_tokens:o,padding:!0,truncation:!0}),u=await this.model.generate(l,t,null,{inputs_attention_mask:h}),f=this.tokenizer.batch_decode(u,{skip_special_tokens:!0});!a&&l.dims.at(-1)>0&&(n=this.tokenizer.batch_decode(l,{skip_special_tokens:!0}).map(e=>e.length));let c=Array.from({length:e.length},e=>[]);for(let t=0;t<f.length;++t){let r=Math.floor(t/u.length*e.length);n&&(f[t]=f[t].slice(n[r])),c[r].push({generated_text:s?[...e[r],{role:"assistant",content:f[t]}]:f[t]})}return i||1!==c.length?c:c[0]}}class eU extends ex{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}={}){let i=Array.isArray(e);i||(e=[e]),Array.isArray(t)||(t=[t]);let s=t.map(e=>r.replace("{}",e)),o=n||1===t.length,a=[];for(let r of e){let e=[];for(let t of s){let n=this.tokenizer(r,{text_pair:t,padding:!0,truncation:!0}),i=await this.model(n);o?e.push([i.logits.data[this.contradiction_id],i.logits.data[this.entailment_id]]):e.push(i.logits.data[this.entailment_id])}let n=(o?e.map(e=>(0,u.XA)(e)[1]):(0,u.XA)(e)).map((e,t)=>[e,t]).sort((e,t)=>t[0]-e[0]);a.push({sequence:r,labels:n.map(e=>t[e[1]]),scores:n.map(e=>e[0])})}return i?a:a[0]}}class eM extends ex{constructor(e){super(e)}async _call(e,{pooling:t="none",normalize:r=!1,quantize:n=!1,precision:i="binary"}={}){let s=this.tokenizer(e,{padding:!0,truncation:!0}),o=await this.model(s),a=o.last_hidden_state??o.logits;if("none"===t);else if("mean"===t)a=(0,f.v6)(a,s.attention_mask);else if("cls"===t)a=a.slice(null,0);else throw Error(`Pooling method '${t}' not supported.`);return r&&(a=a.normalize(2,-1)),n&&(a=(0,f.e)(a,i)),a}}class eT extends ex{constructor(e){super(e)}async _call(e,{pool:t=null}={}){let r;let n=await ew(e),{pixel_values:i}=await this.processor(n),s=await this.model({pixel_values:i});if(t){if(!("pooler_output"in s))throw Error("No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.");r=s.pooler_output}else r=s.last_hidden_state??s.logits??s.image_embeds;return r}}class e$ extends ex{constructor(e){super(e)}async _call(e,{topk:t=null}={}){let r=!Array.isArray(e),n=this.processor.feature_extractor.config.sampling_rate,i=await eb(e,n),s=this.model.config.id2label,o=[];for(let e of i){let r=await this.processor(e),n=(await this.model(r)).logits[0],i=(0,u.em)((0,u.XA)(n.data),t).map(e=>({label:s[e[0]],score:e[1]}));1===t?o.push(...i):o.push(i)}return r&&1!==t?o[0]:o}}class eL extends ex{constructor(e){super(e)}async _call(e,t,{hypothesis_template:r="This is a sound of {}."}={}){let n=!Array.isArray(e);n&&(e=[e]);let i=t.map(e=>r.replace("{}",e)),s=this.tokenizer(i,{padding:!0,truncation:!0}),o=this.processor.feature_extractor.config.sampling_rate,a=await eb(e,o),l=[];for(let e of a){let r=await this.processor(e),n=await this.model({...s,...r}),i=(0,u.XA)(n.logits_per_audio.data);l.push([...i].map((e,r)=>({score:e,label:t[r]})))}return n?l[0]:l}}class eR extends ex{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 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".');let r=!Array.isArray(e);r&&(e=[e]);let n=this.processor.feature_extractor.config.sampling_rate,i=await eb(e,n),s=[];for(let e of i){let t=await this.processor(e),r=(await this.model(t)).logits[0],n=[];for(let e of r)n.push((0,u.Fp)(e.data)[1]);let i=this.tokenizer.decode(n);s.push({text:i})}return r?s[0]:s}async _call_whisper(e,t={}){let r=t.return_timestamps??!1,n=t.chunk_length_s??0,i=t.chunk_callback??null,s=t.force_full_sequences??!1,o=t.stride_length_s??null;"word"===r&&(t.return_token_timestamps=!0);let a=(0,l.Sw)(t,"language",null),h=(0,l.Sw)(t,"task",null);if(a||h||r){if(t.forced_decoder_ids)throw Error("Cannot specify `language`/`task`/`return_timestamps` and `forced_decoder_ids` at the same time.");let e=this.tokenizer.get_decoder_prompt_ids({language:a,task:h,no_timestamps:!r});e.length>0&&(t.forced_decoder_ids=e)}let f=!Array.isArray(e);f&&(e=[e]);let c=this.processor.feature_extractor.config.chunk_length/this.model.config.max_source_positions,d=this.processor.feature_extractor.config.hop_length,p=this.processor.feature_extractor.config.sampling_rate,g=await eb(e,p),m=[];for(let e of g){let a=[];if(n>0){if(null===o)o=n/6;else if(n<=o)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let t=p*n,r=p*o,i=t-2*r,s=0;for(;s<e.length;){let n=e.subarray(s,s+t),o=await this.processor(n),l=0===s,h=s+i>=e.length;a.push({stride:[n.length,l?0:r,h?0:r],input_features:o.input_features,is_last:h}),s+=i}}else a=[{stride:[e.length,0,0],input_features:(await this.processor(e)).input_features,is_last:!0}];for(let e of a){t.num_frames=Math.floor(e.stride[0]/d);let n=await this.model.generate(e.input_features,t);"word"===r?(e.tokens=n.sequences[0],e.token_timestamps=n.token_timestamps.tolist()[0].map(e=>(0,u.NM)(e,2))):e.tokens=n[0],e.stride=e.stride.map(e=>e/p),null!==i&&i(e)}let[l,h]=this.tokenizer._decode_asr(a,{time_precision:c,return_timestamps:r,force_full_sequences:s});m.push({text:l,...h})}return f?m[0]:m}}class ej extends ex{constructor(e){super(e)}async _call(e,t={}){let r=Array.isArray(e),n=await ew(e),{pixel_values:i}=await this.processor(n),s=[];for(let e of i){e.dims=[1,...e.dims];let r=await this.model.generate(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 eF extends ex{constructor(e){super(e)}async _call(e,{topk:t=1}={}){let r=Array.isArray(e),n=await ew(e),{pixel_values:i}=await this.processor(n),s=await this.model({pixel_values:i}),o=this.model.config.id2label,a=[];for(let e of s.logits){let r=(0,u.em)((0,u.XA)(e.data),t).map(e=>({label:o[e[0]],score:e[1]}));1===t?a.push(...r):a.push(r)}return r||1===t?a:a[0]}}class eN extends ex{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:i=null,target_sizes:s=null,subtask:o=null}={}){if(Array.isArray(e)&&1!==e.length)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");let a=await ew(e),l=a.map(e=>[e.height,e.width]),{pixel_values:h,pixel_mask:u}=await this.processor(a),f=await this.model({pixel_values:h,pixel_mask:u}),c=null;if(null!==o)c=this.subtasks_mapping[o];else for(let[e,t]of Object.entries(this.subtasks_mapping))if(t in this.processor.feature_extractor){c=this.processor.feature_extractor[t].bind(this.processor.feature_extractor),o=e;break}let d=this.model.config.id2label,p=[];if("panoptic"===o||"instance"===o){let e=c(f,t,r,n,i,s??l)[0],o=e.segmentation;for(let t of e.segments_info){let e=new Uint8ClampedArray(o.data.length);for(let r=0;r<o.data.length;++r)o.data[r]===t.id&&(e[r]=255);let r=new _(e,o.dims[1],o.dims[0],1);p.push({score:t.score,label:d[t.label_id],mask:r})}}else if("semantic"===o){let{segmentation:e,labels:t}=c(f,s??l)[0];for(let r of t){let t=new Uint8ClampedArray(e.data.length);for(let n=0;n<e.data.length;++n)e.data[n]===r&&(t[n]=255);let n=new _(t,e.dims[1],e.dims[0],1);p.push({score:null,label:d[r],mask:n})}}else throw Error(`Subtask ${o} not supported.`);return p}}class eP extends ex{constructor(e){super(e)}async _call(e,t,{hypothesis_template:r="This is a photo of {}"}={}){let n=Array.isArray(e),i=await ew(e),s=t.map(e=>r.replace("{}",e)),o=this.tokenizer(s,{padding:"siglip"!==this.model.config.model_type||"max_length",truncation:!0}),{pixel_values:a}=await this.processor(i),l=await this.model({...o,pixel_values:a}),h="siglip"===this.model.config.model_type?e=>e.sigmoid().data:e=>(0,u.XA)(e.data),f=[];for(let e of l.logits_per_image){let r=[...h(e)].map((e,r)=>({score:e,label:t[r]}));r.sort((e,t)=>t.score-e.score),f.push(r)}return n?f:f[0]}}class eq extends ex{constructor(e){super(e)}async _call(e,{threshold:t=.9,percentage:r=!1}={}){let n=Array.isArray(e);if(n&&1!==e.length)throw Error("Object detection pipeline currently only supports a batch size of 1.");let i=await ew(e),s=r?null:i.map(e=>[e.height,e.width]),{pixel_values:o,pixel_mask:a}=await this.processor(i),l=await this.model({pixel_values:o,pixel_mask:a}),h=this.processor.feature_extractor.post_process_object_detection(l,t,s),u=this.model.config.id2label,f=h.map(e=>e.boxes.map((t,n)=>({score:e.scores[n],label:u[e.classes[n]],box:ev(t,!r)})));return n?f:f[0]}}class eH extends ex{constructor(e){super(e)}async _call(e,t,{threshold:r=.1,topk:n=null,percentage:i=!1}={}){let s=Array.isArray(e),o=await ew(e),a=this.tokenizer(t,{padding:!0,truncation:!0}),l=await this.processor(o),h=[];for(let e=0;e<o.length;++e){let s=o[e],u=i?null:[[s.height,s.width]],f=l.pixel_values[e].unsqueeze_(0),c=await this.model({...a,pixel_values:f}),d=this.processor.feature_extractor.post_process_object_detection(c,r,u,!0)[0],p=d.boxes.map((e,r)=>({score:d.scores[r],label:t[d.classes[r]],box:ev(e,!i)})).sort((e,t)=>t.score-e.score);null!==n&&(p=p.slice(0,n)),h.push(p)}return s?h:h[0]}}class eG extends ex{constructor(e){super(e)}async _call(e,t,r={}){let n=(await ew(e))[0],{pixel_values:i}=await this.processor(n),s=`<s_docvqa><s_question>${t}</s_question><s_answer>`,o=this.tokenizer(s,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,a=await this.model.generate(i,{...r,decoder_input_ids:o,max_length:this.model.config.decoder.max_position_embeddings}),l=this.tokenizer.batch_decode(a)[0].match(/<s_answer>(.*?)<\/s_answer>/),h=null;return l&&l.length>=2&&(h=l[1].trim()),[{answer:h}]}}class eV extends ex{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){let 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 a.$Sz.from_pretrained(this.DEFAULT_VOCODER_ID,{quantized:!1})),("string"==typeof t||t instanceof URL)&&(t=new Float32Array(await (await fetch(t)).arrayBuffer())),t instanceof Float32Array)t=new f.es("float32",t,[1,t.length]);else if(!(t instanceof f.es))throw Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");let{input_ids:r}=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:n}=await this.model.generate_speech(r,t,{vocoder:this.vocoder}),i=this.processor.feature_extractor.config.sampling_rate;return{audio:n.data,sampling_rate:i}}}class eD extends ex{constructor(e){super(e)}async _call(e){let t=await ew(e),r=await this.processor(t),n=await this.model(r),i=[];for(let e of n.reconstruction){let t=e.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");i.push(_.fromTensor(t))}return i.length>1?i:i[0]}}class eX extends ex{constructor(e){super(e)}async _call(e){let t=await ew(e),r=await this.processor(t),{predicted_depth:n}=await this.model(r),i=[];for(let e=0;e<t.length;++e){let r=(0,f.sX)(n[e],t[e].size.reverse(),"bilinear",!1),s=r.mul_(255/(0,u.Fp)(r.data)[0]).to("uint8");i.push({predicted_depth:n[e],depth:_.fromTensor(s)})}return i.length>1?i:i[0]}}let eW=Object.freeze({"text-classification":{tokenizer:o.t2,pipeline:eE,model:a.o$X,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{tokenizer:o.t2,pipeline:eA,model:a.OjJ,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{tokenizer:o.t2,pipeline:ek,model:a.wiU,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{tokenizer:o.t2,pipeline:eB,model:a.t78,default:{model:"Xenova/bert-base-uncased"},type:"text"},summarization:{tokenizer:o.t2,pipeline:ez,model:a.Kf0,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{tokenizer:o.t2,pipeline:eC,model:a.Kf0,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{tokenizer:o.t2,pipeline:eI,model:a.Kf0,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{tokenizer:o.t2,pipeline:eO,model:a.Hqk,default:{model:"Xenova/gpt2"},type:"text"},"zero-shot-classification":{tokenizer:o.t2,pipeline:eU,model:a.o$X,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:e$,model:a.K2m,processor:e_,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{tokenizer:o.t2,pipeline:eL,model:a.$Sz,processor:e_,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{tokenizer:o.t2,pipeline:eR,model:[a.hZO,a.ENH],processor:e_,default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{tokenizer:o.t2,pipeline:eV,model:[a.z6E,a.lbf],processor:[e_,null],default:{model:"Xenova/speecht5_tts"},type:"text"},"image-to-text":{tokenizer:o.t2,pipeline:ej,model:a.tLj,processor:e_,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:eF,model:a.En$,processor:e_,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:eN,model:[a.U$$,a.$Bv],processor:e_,default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"zero-shot-image-classification":{tokenizer:o.t2,pipeline:eP,model:a.$Sz,processor:e_,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:eq,model:a.Zn,processor:e_,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{tokenizer:o.t2,pipeline:eH,model:a.LdW,processor:e_,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{tokenizer:o.t2,pipeline:eG,model:a.DcG,processor:e_,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:eD,model:a.S2d,processor:e_,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:eX,model:a.hY6,processor:e_,default:{model:"Xenova/dpt-large"},type:"image"},"feature-extraction":{tokenizer:o.t2,pipeline:eM,model:a.$Sz,default:{model:"Xenova/all-MiniLM-L6-v2"},type:"text"},"image-feature-extraction":{processor:e_,pipeline:eT,model:[a.IFL,a.$Sz],default:{model:"Xenova/vit-base-patch16-224-in21k"},type:"image"}}),eJ=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});async function eK(e,t=null,{quantized:r=!0,progress_callback:n=null,config:i=null,cache_dir:s=null,local_files_only:o=!1,revision:a="main"}={}){let h=eW[(e=eJ[e]??e).split("_",1)[0]];if(!h)throw Error(`Unsupported pipeline: ${e}. Must be one of [${Object.keys(eW)}]`);t||(t=h.default.model,console.log(`No model specified. Using default model: "${t}".`));let u=new Map([["tokenizer",h.tokenizer],["model",h.model],["processor",h.processor]]),f=await eY(u,t,{quantized:r,progress_callback:n,config:i,cache_dir:s,local_files_only:o,revision:a});return f.task=e,(0,l.T2)(n,{status:"ready",task:e,model:t}),new h.pipeline(f)}async function eY(e,t,r){let n=Object.create(null),i=[];for(let[s,o]of e.entries()){let e;o&&(e=Array.isArray(o)?new Promise(async(e,n)=>{let i;for(let n of o){if(null===n){e(null);return}try{e(await n.from_pretrained(t,r));return}catch(e){i=e}}n(i)}):o.from_pretrained(t,r),n[s]=e,i.push(e))}for(let[e,t]of(await Promise.all(i),Object.entries(n)))n[e]=await t;return n}r(90016)},20761:function(e,t,r){"use strict";function n(e,t){e&&e(t)}function i(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))}function s(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}r.d(t,{$2:function(){return i},Ag:function(){return o},Gg:function(){return h},O7:function(){return d},Sw:function(){return f},T2:function(){return n},Wy:function(){return l},eG:function(){return c},fU:function(){return a},hr:function(){return s},hs:function(){return p},jg:function(){return u}});let o=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")}};function a(e){return e?.prototype?.__proto__?.constructor?.name==="TypedArray"}function l(e){return Number.isInteger(e)||"bigint"==typeof e}function h(e){return null!=e}function u(e){let t=[],r=e;for(;Array.isArray(r);)t.push(r.length),r=r[0];return t}function f(e,t,r){let 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 c(...e){return Array.prototype.concat.apply([],e)}function d(...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)}},81510:function(e,t,r){"use strict";r.d(t,{GA:function(){return i},Z3:function(){return n},pQ:function(){return o}});class n{constructor(e=(e,t)=>e>t){this._heap=[],this._comparator=e}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(let t of e)this._heap.push(t),this._siftUp();return this.size}pop(){let e=this.peek(),t=this.size-1;return t>0&&this._swap(0,t),this._heap.pop(),this._siftDown(),e}replace(e){let t=this.peek();return this._heap[0]=e,this._siftDown(),t}_parent(e){return(e+1>>>1)-1}_left(e){return(e<<1)+1}_right(e){return e+1<<1}_greater(e,t){return this._comparator(this._heap[e],this._heap[t])}_swap(e,t){let r=this._heap[e];this._heap[e]=this._heap[t],this._heap[t]=r}_siftUp(){let e=this.size-1;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);){let 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}}}class i{constructor(){this.root=s.default()}extend(e){for(let t of e)this.push(t)}push(e){let t=this.root;for(let 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,r="";for(let n=0;n<e.length&&void 0!==t;++n){let i=e[n];r+=i,void 0!==(t=t.children.get(i))&&t.isLeaf&&(yield r)}}}class s{constructor(e,t){this.isLeaf=e,this.children=t}static default(){return new s(!1,new Map)}}class o{constructor(e,t,r){this.sentence=e,this.len=e.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},()=>[]);let n=new a(this.bosTokenId,0,0,0,0),i=new a(this.eosTokenId,1,this.len,0,0);this.nodes.push(n.clone()),this.nodes.push(i.clone()),this.beginNodes[this.len].push(i),this.endNodes[0].push(n)}insert(e,t,r,n){let i=new a(n,this.nodes.length,e,t,r);this.beginNodes[e].push(i),this.endNodes[e+t].push(i),this.nodes.push(i)}viterbi(){let e=this.len,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 i of this.endNodes[t]){let t=i.backtraceScore+e.score;(null===n||t>r)&&(n=i.clone(),r=t)}if(null===n)return[];e.prev=n,e.backtraceScore=r}++t}let r=[],n=this.beginNodes[e][0].prev;if(null===n)return[];let i=n.clone();for(;null!==i.prev;)r.push(i.clone()),i=i.clone().prev.clone();return r.reverse(),r}piece(e){return this.sentence.slice(e.pos,e.pos+e.length)}tokens(){return this.viterbi().map(e=>this.piece(e))}tokenIds(){return this.viterbi().map(e=>e.tokenId)}}class a{constructor(e,t,r,n,i){this.tokenId=e,this.nodeId=t,this.pos=r,this.length=n,this.score=i,this.prev=null,this.backtraceScore=0}clone(){let e=new a(this.tokenId,this.nodeId,this.pos,this.length,this.score);return e.prev=this.prev,e.backtraceScore=this.backtraceScore,e}}},45774:function(e,t,r){"use strict";r.d(t,{AE:function(){return m},C9:function(){return l},CJ:function(){return g},E:function(){return a},GU:function(){return u},Jj:function(){return d},Jm:function(){return s},Pg:function(){return f},Z4:function(){return _},aP:function(){return y},dZ:function(){return h},ez:function(){return p},jF:function(){return c}}),r(62414);var n=r(20761),i=r(68709);class s extends n.Ag{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,t){for(let r of t)this.processors.forEach(t=>t(e,r))}[Symbol.iterator](){return this.processors.values()}}class o extends n.Ag{_call(e,t){throw Error("`_call` should be implemented in a subclass")}}class a extends o{constructor(e){super(),this.force_token_map=Object.fromEntries(e??[])}_call(e,t){let r=this.force_token_map[e.length];return(0,n.Gg)(r)&&(t.data.fill(-1/0),t.data[r]=0),t}}class l extends o{constructor(e){super(),this.bos_token_id=e}_call(e,t){return 1===e.length&&(t.data.fill(-1/0),t.data[this.bos_token_id]=0),t}}class h extends o{constructor(e,t){super(),this.max_length=e,this.forced_eos_token_id=t}_call(e,t){}}class u extends o{constructor(e,t){super(),this.begin_suppress_tokens=e,this.begin_index=t}_call(e,t){if(e.length===this.begin_index)for(let e of this.begin_suppress_tokens)t.data[e]=-1/0;return t}}class f extends o{constructor(e){super(),this.eos_token_id=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=(e.forced_decoder_ids||[]).length+2,e.forced_decoder_ids.slice(-1)[0][1]===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,t){let r=t.data;if(r[this.no_timestamps_token_id]=-1/0,e.length===this.begin_index-1)return r.fill(-1/0),r[this.timestamp_begin]=0,t;let n=e.slice(this.begin_index),s=n.length>=1&&n[n.length-1]>=this.timestamp_begin,o=n.length<2||n[n.length-2]>=this.timestamp_begin;if(s&&(o?r.subarray(this.timestamp_begin).fill(-1/0):r.subarray(0,this.eos_token_id).fill(-1/0)),e.length===this.begin_index&&null!==this.max_initial_timestamp_index){let e=this.timestamp_begin+this.max_initial_timestamp_index;r.subarray(e+1).fill(-1/0)}let a=(0,i.CI)(r);return Math.log(a.subarray(this.timestamp_begin).map(Math.exp).reduce((e,t)=>e+t))>(0,i.Fp)(a.subarray(0,this.timestamp_begin))[0]&&r.subarray(0,this.timestamp_begin).fill(-1/0),t}}class c extends o{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let t=e.length,r=[];for(let n=0;n<t+1-this.no_repeat_ngram_size;++n){let t=[];for(let r=0;r<this.no_repeat_ngram_size;++r)t.push(e[n+r]);r.push(t)}let n=new Map;for(let e of r){let t=JSON.stringify(e.slice(0,e.length-1)),r=n.get(t)??[];r.push(e[e.length-1]),n.set(t,r)}return n}getGeneratedNgrams(e,t){let r=t.slice(t.length+1-this.no_repeat_ngram_size,t.length);return e.get(JSON.stringify(r))??[]}calcBannedNgramTokens(e){if(e.length+1<this.no_repeat_ngram_size)return[];{let t=this.getNgrams(e);return this.getGeneratedNgrams(t,e)}}_call(e,t){for(let r of this.calcBannedNgramTokens(e))t.data[r]=-1/0;return t}}class d extends o{constructor(e){super(),this.penalty=e}_call(e,t){for(let r of e)t.data[r]<0?t.data[r]*=this.penalty:t.data[r]/=this.penalty;return t}}class p extends o{constructor(e,t){super(),this.min_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){if(e.length<this.min_length)for(let e of this.eos_token_id)t.data[e]=-1/0;return t}}class g extends o{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){if(e.length-this.prompt_length_to_skip<this.min_new_tokens)for(let e of this.eos_token_id)t.data[e]=-1/0;return t}}class m extends o{constructor(e,t){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r of this.bad_words_ids){let n=!0;for(let t=1;t<=r.length-1&&r.length<e.length;++t)if(r.at(-t-1)!==e.at(-t)){n=!1;break}n&&(t.data[r.at(-1)]=-1/0)}return t}}let y=class{constructor(e={}){this.max_length=e.max_length??20,this.max_new_tokens=e.max_new_tokens??null,this.min_length=e.min_length??0,this.min_new_tokens=e.min_new_tokens??null,this.early_stopping=e.early_stopping??!1,this.max_time=e.max_time??null,this.do_sample=e.do_sample??!1,this.num_beams=e.num_beams??1,this.num_beam_groups=e.num_beam_groups??1,this.penalty_alpha=e.penalty_alpha??null,this.use_cache=e.use_cache??!0,this.temperature=e.temperature??1,this.top_k=e.top_k??50,this.top_p=e.top_p??1,this.typical_p=e.typical_p??1,this.epsilon_cutoff=e.epsilon_cutoff??0,this.eta_cutoff=e.eta_cutoff??0,this.diversity_penalty=e.diversity_penalty??0,this.repetition_penalty=e.repetition_penalty??1,this.encoder_repetition_penalty=e.encoder_repetition_penalty??1,this.length_penalty=e.length_penalty??1,this.no_repeat_ngram_size=e.no_repeat_ngram_size??0,this.bad_words_ids=e.bad_words_ids??null,this.force_words_ids=e.force_words_ids??null,this.renormalize_logits=e.renormalize_logits??!1,this.constraints=e.constraints??null,this.forced_bos_token_id=e.forced_bos_token_id??null,this.forced_eos_token_id=e.forced_eos_token_id??null,this.remove_invalid_values=e.remove_invalid_values??!1,this.exponential_decay_length_penalty=e.exponential_decay_length_penalty??null,this.suppress_tokens=e.suppress_tokens??null,this.begin_suppress_tokens=e.begin_suppress_tokens??null,this.forced_decoder_ids=e.forced_decoder_ids??null,this.num_return_sequences=e.num_return_sequences??1,this.output_attentions=e.output_attentions??!1,this.output_hidden_states=e.output_hidden_states??!1,this.output_scores=e.output_scores??!1,this.return_dict_in_generate=e.return_dict_in_generate??!1,this.pad_token_id=e.pad_token_id??null,this.bos_token_id=e.bos_token_id??null,this.eos_token_id=e.eos_token_id??null,this.encoder_no_repeat_ngram_size=e.encoder_no_repeat_ngram_size??0,this.decoder_start_token_id=e.decoder_start_token_id??null,this.generation_kwargs=e.generation_kwargs??{}}};class _ extends n.Ag{constructor(e){super(),this.generation_config=e}_call(e,t=-1){return this.sample(e,t)}sample(e,t){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 this.generation_config.temperature>0&&(n=n.map(e=>e/this.generation_config.temperature)),n}randomSelect(e){let t=Math.random()*e.reduce((e,t)=>e+t,0);for(let r=0;r<e.length;++r)if((t-=e[r])<=0)return r;return 0}static getSampler(e){if(e.do_sample)return new b(e);if(e.num_beams>1)return new v(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 w(e)}}class w extends _{sample(e,t=-1){let r=this.getLogits(e,t);return[[(0,i.Fp)(r)[1],0]]}}class b extends _{sample(e,t=-1){let r=e.dims.at(-1);this.generation_config.top_k>0&&(r=Math.min(this.generation_config.top_k,r));let n=this.getLogits(e,t),s=(0,i.em)(n,r),o=(0,i.XA)(s.map(e=>e[1]));return Array.from({length:this.generation_config.num_beams},()=>{let e=this.randomSelect(o);return[s[e][0],Math.log(o[e])]})}}class v extends _{sample(e,t=-1){let r=e.dims.at(-1);this.generation_config.top_k>0&&(r=Math.min(this.generation_config.top_k,r));let n=this.getLogits(e,t),s=(0,i.em)(n,r),o=(0,i.XA)(s.map(e=>e[1]));return Array.from({length:this.generation_config.num_beams},(e,t)=>[s[t][0],Math.log(o[t])])}}},40911:function(e,t,r){"use strict";r.d(t,{hn:function(){return c},st:function(){return m},yM:function(){return y}});var n=r(27147),i=r(31418),s=r(70319),o=r(50851),a=r(20761),l=r(25566),h=r(9109).Buffer;globalThis.ReadableStream||(globalThis.ReadableStream=s.ReadableStream);class u{_CONTENT_TYPE_MAP={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"};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(){let e=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",this._CONTENT_TYPE_MAP[e]??"application/octet-stream")}clone(){let e=new u(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(){return new Blob([await n.promises.readFile(this.filePath)],{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 f(e,t=null){let r;try{r=new URL(e)}catch(e){return!1}return(!t||!!t.includes(r.hostname))&&("http:"===r.protocol||"https:"===r.protocol)}async function c(e){if(o.O.useFS&&!f(e))return new u(e);if(void 0===l||l?.release?.name!=="node")return fetch(e);{let t=!!l.env?.TESTING_REMOTELY,r=o.O.version,n=new Headers;if(n.set("User-Agent",`transformers.js/${r}; is_ci/${t};`),f(e,["huggingface.co","hf.co"])){let e=l.env?.HF_TOKEN??l.env?.HF_ACCESS_TOKEN;e&&n.set("Authorization",`Bearer ${e}`)}return fetch(e,{headers:n})}}let d={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=new u(i.join(this.path,e));return t.exists?t:void 0}async put(e,t){let r=h.from(await t.arrayBuffer()),s=i.join(this.path,e);try{await n.promises.mkdir(i.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 g(e,...t){for(let r of t)try{let t=await e.match(r);if(t)return t}catch(e){continue}}async function m(e,t,r=!0,n={}){let i,s,l,h;if(!o.O.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(!o.O.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}if((0,a.T2)(n.progress_callback,{status:"initiate",name:e,file:t}),!i&&o.O.useBrowserCache){if("undefined"==typeof caches)throw Error("Browser cache is not available in this environment.");try{i=await caches.open("transformers-cache")}catch(e){console.warn("An error occurred while opening the browser cache:",e)}}if(!i&&o.O.useFSCache&&(i=new p(n.cache_dir??o.O.cacheDir)),!i&&o.O.useCustomCache){if(!o.O.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!o.O.customCache.match||!o.O.customCache.put)throw 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");i=o.O.customCache}let u=n.revision??"main",m=w(e,t),y=w(o.O.localModelPath,m),b=w(o.O.remoteHost,o.O.remotePathTemplate.replaceAll("{model}",e).replaceAll("{revision}",encodeURIComponent(u)),t),v="main"===u?m:w(e,u,t),x=i instanceof p?v:b,E=!1;i&&(l=await g(i,y,x));let A=void 0!==l;if(void 0===l){if(o.O.allowLocalModels){if(f(m)){if(n.local_files_only)throw Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${m}.`);if(!o.O.allowRemoteModels)throw Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${m}.`)}else try{l=await c(y),s=y}catch(e){console.warn(`Unable to load from local path "${y}": "${e}"`)}}if(void 0===l||404===l.status){if(n.local_files_only||!o.O.allowRemoteModels){if(!r)return null;throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${y}".`)}if(200!==(l=await c(b)).status)return function(e,t,r){if(!r)return null;let n=d[e]??`Error (${e}) occurred while trying to load file`;throw Error(`${n}: "${t}".`)}(l.status,b,r);s=x}E=i&&"undefined"!=typeof Response&&l instanceof Response&&200===l.status}(0,a.T2)(n.progress_callback,{status:"download",name:e,file:t});let k={status:"progress",name:e,file:t};return n.progress_callback?A&&"undefined"!=typeof navigator&&/firefox/i.test(navigator.userAgent)?(h=new Uint8Array(await l.arrayBuffer()),(0,a.T2)(n.progress_callback,{...k,progress:100,loaded:h.length,total:h.length})):h=await _(l,e=>{(0,a.T2)(n.progress_callback,{...k,...e})}):h=new Uint8Array(await l.arrayBuffer()),E&&s&&await i.match(s)===void 0&&await i.put(s,new Response(h,{headers:l.headers})).catch(e=>{console.warn(`Unable to add response to browser cache: ${e}.`)}),(0,a.T2)(n.progress_callback,{status:"done",name:e,file:t}),h}async function y(e,t,r=!0,n={}){let i=await m(e,t,r,n);return null===i?{}:JSON.parse(new TextDecoder("utf-8").decode(i))}async function _(e,t){let 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"),i=new Uint8Array(n),s=0,o=e.body.getReader();async function a(){let{done:e,value:r}=await o.read();if(e)return;let l=s+r.length;if(l>n){let e=new Uint8Array(n=l);e.set(i),i=e}return i.set(r,s),t({progress:(s=l)/n*100,loaded:s,total:n}),a()}return await a(),i}function w(...e){return(e=e.map((t,r)=>(r&&(t=t.replace(RegExp("^/"),"")),r!==e.length-1&&(t=t.replace(RegExp("/$"),"")),t))).join("/")}},68709:function(e,t,r){"use strict";function n(e,[t,r,n],[i,s],o="bilinear",a=!1){let l=s/n,h=i/r,u=new e.constructor(i*s*t),f=r*n,c=i*s;for(let o=0;o<i;++o)for(let i=0;i<s;++i){let a=o*s+i,d=(i+.5)/l-.5,p=(o+.5)/h-.5,g=Math.floor(d),m=Math.floor(p),y=Math.min(g+1,n-1),_=Math.min(m+1,r-1),w=d-(g=Math.max(g,0)),b=p-(m=Math.max(m,0)),v=(1-w)*(1-b),x=w*(1-b),E=(1-w)*b,A=w*b,k=m*n,B=_*n,I=k+g,z=k+y,C=B+g,S=B+y;for(let r=0;r<t;++r){let t=r*f;u[r*c+a]=v*e[t+I]+x*e[t+z]+E*e[t+C]+A*e[t+S]}}return u}function i(e,t,r){let n=Array(r.length),i=Array(r.length);for(let e=r.length-1,s=1;e>=0;--e)i[e]=s,n[e]=t[r[e]],s*=n[e];let s=r.map((e,t)=>i[r.indexOf(t)]),o=new e.constructor(e.length);for(let r=0;r<e.length;++r){let n=0;for(let e=t.length-1,i=r;e>=0;--e)n+=i%t[e]*s[e],i=Math.floor(i/t[e]);o[n]=e[r]}return[o,n]}function s(e){let t=h(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 o(e){return s(e).map(e=>Math.log(e))}function a(e,t=0){return e=Array.from(e).map((e,t)=>[t,e]).sort((e,t)=>t[1]-e[1]),null!==t&&t>0&&(e=e.slice(0,t)),e}function l(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 h(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 u(e){return e>0&&(e&e-1)==0}r.d(t,{CI:function(){return o},Fp:function(){return h},NM:function(){return g},Nq:function(){return n},VV:function(){return l},XA:function(){return s},eT:function(){return m},em:function(){return a},nu:function(){return i},qC:function(){return p},vw:function(){return d}});class f{constructor(e){if(this.size=0|e,this.size<=1||!u(this.size))throw 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){let 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){let r=this._width-t-2;this._bitrev[e]|=(e>>>t&3)<<r}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,t){let r=t||Array(e.length>>>1);for(let t=0;t<e.length;t+=2)r[t>>>1]=e[t];return r}toComplexArray(e,t){let r=t||this.createComplexArray();for(let t=0;t<r.length;t+=2)r[t]=e[t>>>1],r[t+1]=0;return r}completeSpectrum(e){let t=this._csize,r=t>>>1;for(let n=2;n<r;n+=2)e[t-n]=e[n],e[t-n+1]=-e[n+1]}transform(e,t){if(e===t)throw Error("Input and output buffers must be different");this._transform4(e,t,1)}realTransform(e,t){if(e===t)throw Error("Input and output buffers must be different");this._realTransform4(e,t,1)}inverseTransform(e,t){if(e===t)throw 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){let n,i;let s=this._csize,o=1<<this._width,a=s/o<<1,l=this._bitrev;if(4===a)for(n=0,i=0;n<s;n+=a,++i){let r=l[i];this._singleTransform2(t,e,n,r,o)}else for(n=0,i=0;n<s;n+=a,++i){let s=l[i];this._singleTransform4(t,e,n,s,o,r)}for(o>>=2;o>=2;o>>=2){let t=(a=s/o<<1)>>>2;for(n=0;n<s;n+=a){let i=n+t-1;for(let s=n,a=0;s<i;s+=2,a+=o){let n=s,i=n+t,o=i+t,l=o+t,h=e[n],u=e[n+1],f=e[i],c=e[i+1],d=e[o],p=e[o+1],g=e[l],m=e[l+1],y=this.table[a],_=r*this.table[a+1],w=f*y-c*_,b=f*_+c*y,v=this.table[2*a],x=r*this.table[2*a+1],E=d*v-p*x,A=d*x+p*v,k=this.table[3*a],B=r*this.table[3*a+1],I=g*k-m*B,z=g*B+m*k,C=h+E,S=u+A,O=h-E,U=u-A,M=w+I,T=b+z,$=r*(w-I),L=r*(b-z);e[n]=C+M,e[n+1]=S+T,e[i]=O+L,e[i+1]=U-$,e[o]=C-M,e[o+1]=S-T,e[l]=O-L,e[l+1]=U+$}}}}_singleTransform2(e,t,r,n,i){let s=e[n],o=e[n+1],a=e[n+i],l=e[n+i+1];t[r]=s+a,t[r+1]=o+l,t[r+2]=s-a,t[r+3]=o-l}_singleTransform4(e,t,r,n,i,s){let o=2*i,a=3*i,l=e[n],h=e[n+1],u=e[n+i],f=e[n+i+1],c=e[n+o],d=e[n+o+1],p=e[n+a],g=e[n+a+1],m=l+c,y=h+d,_=l-c,w=h-d,b=u+p,v=f+g,x=s*(u-p),E=s*(f-g);t[r]=m+b,t[r+1]=y+v,t[r+2]=_+E,t[r+3]=w-x,t[r+4]=m-b,t[r+5]=y-v,t[r+6]=_-E,t[r+7]=w+x}_realTransform4(e,t,r){let n,i;let s=this._csize,o=1<<this._width,a=s/o<<1,l=this._bitrev;if(4===a)for(n=0,i=0;n<s;n+=a,++i){let r=l[i];this._singleRealTransform2(t,e,n,r>>>1,o>>>1)}else for(n=0,i=0;n<s;n+=a,++i){let s=l[i];this._singleRealTransform4(t,e,n,s>>>1,o>>>1,r)}for(o>>=2;o>=2;o>>=2){let t=(a=s/o<<1)>>>2;for(n=0;n<s;n+=a){let i=n+t-1;for(let s=n,a=0;s<i;s+=2,a+=o){let n=s,i=n+t,o=i+t,l=o+t,h=e[n],u=e[n+1],f=e[i],c=e[i+1],d=e[o],p=e[o+1],g=e[l],m=e[l+1],y=this.table[a],_=r*this.table[a+1],w=f*y-c*_,b=f*_+c*y,v=this.table[2*a],x=r*this.table[2*a+1],E=d*v-p*x,A=d*x+p*v,k=this.table[3*a],B=r*this.table[3*a+1],I=g*k-m*B,z=g*B+m*k,C=h+E,S=u+A,O=h-E,U=u-A,M=w+I,T=b+z,$=r*(w-I),L=r*(b-z);e[n]=C+M,e[n+1]=S+T,e[i]=O+L,e[i+1]=U-$,e[o]=C-M,e[o+1]=S-T,e[l]=O-L,e[l+1]=U+$}}}}_singleRealTransform2(e,t,r,n,i){let s=e[n],o=e[n+i];t[r]=s+o,t[r+1]=0,t[r+2]=s-o,t[r+3]=0}_singleRealTransform4(e,t,r,n,i,s){let o=e[n],a=e[n+i],l=e[n+2*i],h=e[n+3*i],u=o+l,f=o-l,c=a+h,d=s*(a-h);t[r]=u+c,t[r+1]=0,t[r+2]=f,t[r+3]=-d,t[r+4]=u-c,t[r+5]=0,t[r+6]=f,t[r+7]=d}}class c{constructor(e){let t=2*(e-1),r=2*(2*e-1),n=2**Math.ceil(Math.log2(r));this.bufferSize=n,this._a=t;let i=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);let o=-2*Math.PI/e,a=Math.cos(o),l=Math.sin(o);for(let t=0;t<r>>1;++t){let r=(t+1-e)**2/2,n=Math.sqrt(a**2+l**2)**r,o=r*Math.atan2(l,a),h=2*t;i[h]=n*Math.cos(o),i[h+1]=n*Math.sin(o),s[h]=i[h],s[h+1]=-i[h+1]}this._slicedChirpBuffer=i.subarray(t,r),this._f=new f(n>>1),this._f.transform(this._chirpBuffer,s)}_transform(e,t,r){let n=this._buffer1,i=this._buffer2,s=this._outBuffer1,o=this._outBuffer2,a=this._chirpBuffer,l=this._slicedChirpBuffer,h=this._a;if(r)for(let e=0;e<l.length;e+=2){let r=e+1,i=t[e>>1];n[e]=i*l[e],n[r]=i*l[r]}else for(let e=0;e<l.length;e+=2){let 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<a.length;e+=2){let t=e+1;i[e]=s[e]*a[e]-s[t]*a[t],i[t]=s[e]*a[t]+s[t]*a[e]}this._f.inverseTransform(o,i);for(let t=0;t<o.length;t+=2){let r=o[t+h],n=o[t+h+1],i=l[t],s=l[t+1];e[t]=r*i-n*s,e[t+1]=r*s+n*i}}transform(e,t){this._transform(e,t,!1)}realTransform(e,t){this._transform(e,t,!0)}}class d{constructor(e){this.fft_length=e,this.isPowerOfTwo=u(e),this.isPowerOfTwo?(this.fft=new f(e),this.outputBufferSize=2*e):(this.fft=new c(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,t){this.fft.realTransform(e,t)}transform(e,t){this.fft.transform(e,t)}}function p(e,t){if(t%2==0||t<=0)throw Error("Window size must be a positive odd number");let r=new e.constructor(e.length),n=new e.constructor(t),i=Math.floor(t/2);for(let t=0;t<e.length;++t){let s=0;for(let r=-i;r<=i;++r){let i=t+r;i<0?i=Math.abs(i):i>=e.length&&(i=2*(e.length-1)-i),n[s++]=e[i]}n.sort(),r[t]=n[i]}return r}function g(e,t){let r=Math.pow(10,t);return Math.round(e*r)/r}function m(e){let t=Math.round(e);return Math.abs(e)%1==.5?t%2==0?t:t-1:t}},62414:function(e,t,r){"use strict";r.d(t,{J6:function(){return m},Ks:function(){return y},d3:function(){return d},e:function(){return w},es:function(){return a},f3:function(){return g},kn:function(){return p},r6:function(){return _},sX:function(){return l},v6:function(){return h}});var n=r(71542),i=r(68709);let s=Object.freeze({float32:Float32Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array}),o=n.ONNX.Tensor;class a{dims;type;data;size;constructor(...e){return e[0]instanceof o?Object.assign(this,e[0]):Object.assign(this,new o(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})}*[Symbol.iterator](){let[e,...t]=this.dims;if(t.length>0){let 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){let[t,...r]=this.dims;if(e=c(e,t),!(r.length>0))return new a(this.type,[this.data[e]],r);{let t=r.reduce((e,t)=>e*t);return this._subarray(e,t,r)}}indexOf(e){for(let t=0;t<this.data.length;++t)if(this.data[t]==e)return t;return -1}_subarray(e,t,r){let n=e*t,i=(e+1)*t,s="subarray"in this.data?this.data.subarray(n,i):this.data.slice(n,i);return new a(this.type,s,r)}item(){if(1!==this.data.length)throw Error(`a Tensor with ${this.data.length} elements cannot be converted to Scalar`);return this.data[0]}tolist(){return function(e,t){let r=e.length;if(r!==t.reduce((e,t)=>e*t))throw Error(`cannot reshape array of size ${r} into shape (${t})`);let n=e;for(let e=t.length-1;e>=0;e--)n=n.reduce((r,n)=>{let i=r[r.length-1];return i.length<t[e]?i.push(n):r.push([n]),r},[[]]);return n[0]}(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){for(let e=0;e<this.data.length;++e)this.data[e]=1/(1+Math.exp(-this.data[e]));return this}mul(e){return this.clone().mul_(e)}mul_(e){for(let t=0;t<this.data.length;++t)this.data[t]*=e;return this}add(e){return this.clone().add_(e)}add_(e){for(let t=0;t<this.data.length;++t)this.data[t]+=e;return this}clone(){return new a(this.type,this.data.slice(),this.dims.slice())}slice(...e){let t=[],r=[];for(let n=0;n<this.dims.length;++n){let i=e[n];if(null==i)r.push([0,this.dims[n]]),t.push(this.dims[n]);else if("number"==typeof i)i=c(i,this.dims[n],n),r.push([i,i+1]);else if(Array.isArray(i)&&2===i.length){if(i[0]>i[1])throw Error(`Invalid slice: ${i}`);let e=[Math.max(i[0],0),Math.min(i[1],this.dims[n])];r.push(e),t.push(e[1]-e[0])}else throw Error(`Invalid slice: ${i}`)}let n=r.map(([e,t])=>t-e),i=n.reduce((e,t)=>e*t),s=new this.data.constructor(i),o=this.stride();for(let e=0;e<i;++e){let t=0;for(let i=n.length-1,s=e;i>=0;--i){let e=n[i];t+=(s%e+r[i][0])*o[i],s=Math.floor(s/e)}s[e]=this.data[t]}return new a(this.type,s,t)}permute(...e){return function(e,t){let[r,n]=(0,i.nu)(e.data,e.dims,t);return new a(e.type,r,n)}(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}`);if(null===t){let t=this.data.reduce((t,r)=>t+r**e,0)**(1/e);return new a(this.type,[t],[])}t=c(t,this.dims.length);let n=this.dims.slice();n[t]=1;let i=new this.data.constructor(this.data.length/this.dims[t]);for(let r=0;r<this.data.length;++r){let s=0;for(let e=this.dims.length-1,i=r,o=1;e>=0;--e){let r=this.dims[e];e!==t&&(s+=i%r*o,o*=n[e]),i=Math.floor(i/r)}i[s]+=this.data[r]**e}if(1!==e)for(let t=0;t<i.length;++t)i[t]=i[t]**(1/e);return r||n.splice(t,1),new a(this.type,i,n)}normalize_(e=2,t=1){t=c(t,this.dims.length);let r=this.norm(e,t,!0);for(let e=0;e<this.data.length;++e){let n=0;for(let r=this.dims.length-1,i=e,s=1;r>=0;--r){let e=this.dims[r];r!==t&&(n+=i%e*s,s*=this.dims[r]),i=Math.floor(i/e)}this.data[e]/=r.data[n]}return this}normalize(e=2,t=1){return this.clone().normalize_(e,t)}stride(){return function(e){let t=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 a(this.type,this.data,u(this.dims,e))}squeeze_(e=null){return this.dims=u(this.dims,e),this}unsqueeze(e=null){return new a(this.type,this.data,f(this.dims,e))}unsqueeze_(e=null){return this.dims=f(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),i=this.dims.slice(t+1);return this.dims=[...r,n.reduce((e,t)=>e*t,1),...i],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 Error("Only one dimension can be inferred");t=r}if(-1!==t){let r=e.reduce((e,r,n)=>n!==t?e*r:e,1);e[t]=this.data.length/r}return new a(this.type,this.data,e)}neg_(){for(let e=0;e<this.data.length;++e)this.data[e]=-this.data[e];return this}neg(){return this.clone().neg_()}clamp_(e,t){for(let r=0;r<this.data.length;++r)this.data[r]=Math.min(Math.max(this.data[r],e),t);return this}clamp(e,t){return this.clone().clamp_(e,t)}round_(){for(let e=0;e<this.data.length;++e)this.data[e]=Math.round(this.data[e]);return this}round(){return this.clone().round_()}to(e){if(this.type===e)return this;if(!s.hasOwnProperty(e))throw Error(`Unsupported type: ${e}`);return new a(e,s[e].from(this.data),this.dims)}}function l(e,[t,r],n="bilinear",s=!1){let o=e.dims.at(-3)??1,l=e.dims.at(-2),h=e.dims.at(-1),u=(0,i.Nq)(e.data,[o,l,h],[t,r],n,s);return new a(e.type,u,[o,t,r])}function h(e,t){let r=[e.dims[0],e.dims[2]],n=new e.data.constructor(r[0]*r[1]),[i,s,o]=e.dims,l=0;for(let r=0;r<i;++r){let i=r*o*s;for(let a=0;a<o;++a){let h=0,u=0,f=r*s,c=i+a;for(let r=0;r<s;++r){let n=Number(t.data[f+r]);u+=n,h+=e.data[c+r*o]*n}let d=h/u;n[l++]=d}}return new a(e.type,n,r)}function u(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 f(e,t){return t=c(t,e.length+1),(e=e.slice()).splice(t,0,1),e}function c(e,t,r=null){if(e<-t||e>=t)throw 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 d(e,t=0){t=c(t,e[0].dims.length);let r=e[0].dims.slice();r[t]=e.reduce((e,r)=>e+r.dims[t],0);let n=r.reduce((e,t)=>e*t,1),i=new e[0].data.constructor(n),s=e[0].type;if(0===t){let t=0;for(let r of e)i.set(r.data,t),t+=r.data.length}else{let n=0;for(let s=0;s<e.length;++s){let o=e[s];for(let e=0;e<o.data.length;++e){let s=0;for(let i=o.dims.length-1,a=e,l=1;i>=0;--i){let e=o.dims[i],h=a%e;i===t&&(h+=n),s+=h*l,l*=r[i],a=Math.floor(a/e)}i[s]=o.data[e]}n+=o.dims[t]}}return new a(s,i,r)}function p(e,t=0){return d(e.map(e=>e.unsqueeze(t)),t)}function g(e,t=null,r=1,n=!1){if(null===t){let t=e.data.reduce((e,t)=>e+t,0)/e.data.length,n=Math.sqrt(e.data.reduce((e,r)=>e+(r-t)**2,0)/(e.data.length-r)),i=new a(e.type,[t],[]);return[new a(e.type,[n],[]),i]}t=c(t,e.dims.length);let i=m(e,t,n),s=e.dims.slice();s[t]=1;let o=new e.data.constructor(e.data.length/e.dims[t]);for(let r=0;r<e.data.length;++r){let n=0;for(let i=e.dims.length-1,o=r,a=1;i>=0;--i){let r=e.dims[i];i!==t&&(n+=o%r*a,a*=s[i]),o=Math.floor(o/r)}o[n]+=(e.data[r]-i.data[n])**2}for(let n=0;n<o.length;++n)o[n]=Math.sqrt(o[n]/(e.dims[t]-r));return n||s.splice(t,1),[new a(e.type,o,s),i]}function m(e,t=null,r=!1){if(null===t){let t=e.data.reduce((e,t)=>e+t,0);return new a(e.type,[t/e.data.length],[])}t=c(t,e.dims.length);let n=e.dims.slice();n[t]=1;let i=new e.data.constructor(e.data.length/e.dims[t]);for(let r=0;r<e.data.length;++r){let s=0;for(let i=e.dims.length-1,o=r,a=1;i>=0;--i){let r=e.dims[i];i!==t&&(s+=o%r*a,a*=n[i]),o=Math.floor(o/r)}i[s]+=e.data[r]}if(1!==e.dims[t])for(let r=0;r<i.length;++r)i[r]=i[r]/e.dims[t];return r||n.splice(t,1),new a(e.type,i,n)}function y(e){let[t,r]=e.dims,n=[t+1,r+1],i=new a("float32",new Float32Array(n[0]*n[1]).fill(1/0),n),s=new a("float32",new Float32Array(n[0]*n[1]).fill(-1),n);i[0].data[0]=0;for(let n=1;n<r+1;++n)for(let r=1;r<t+1;++r){let t,o;let a=i[r-1][n-1].item(),l=i[r-1][n].item(),h=i[r][n-1].item();a<l&&a<h?(t=a,o=0):l<a&&l<h?(t=l,o=1):(t=h,o=2),i[r].data[n]=e[r-1][n-1].item()+t,s[r].data[n]=o}let o=t,l=r;s.data.fill(2,0,n[1]);for(let e=0;e<n[0];++e)s[e].data[0]=1;let h=[],u=[];for(;o>0||l>0;)switch(h.push(o-1),u.push(l-1),s[o][l].item()){case 0:--o,--l;break;case 1:--o;break;case 2:--l;break;default:throw Error(`Internal error in dynamic time warping. Unexpected trace[${o}, ${l}]. Please file a bug report.`)}return h.reverse(),u.reverse(),[h,u]}function _(e){var t;return new a("int64",new BigInt64Array((t=e.dims).reduce((e,t)=>e*t,1)).fill(1n),t)}function w(e,t){if(2!==e.dims.length)throw Error("The tensor must have 2 dimensions");if(e.dims.at(-1)%8!=0)throw Error("The last dimension of the tensor must be a multiple of 8");if(!["binary","ubinary"].includes(t))throw Error("The precision must be either 'binary' or 'ubinary'");let r="binary"===t,n=r?Int8Array:Uint8Array,i=e.data,s=new n(i.length/8);for(let e=0;e<i.length;++e){let t=i[e]>0?1:0,n=Math.floor(e/8),o=e%8;s[n]|=t<<7-o,r&&0===o&&(s[n]-=128)}return new a(r?"int8":"uint8",s,[e.dims[0],e.dims[1]/8])}},36393:function(e,t,r){"use strict";var n=r(37836);t.Z=n}}]); |