UNPKG

@kiloscribe/inscription-sdk

Version:
13 lines 179 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@hashgraph/sdk")):"function"==typeof define&&define.amd?define(["exports","@hashgraph/sdk"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).InscriptionSDK={},e["@hashgraph/sdk"])}(this,function(e,t){"use strict";for(var i=Object.defineProperty,n=((e,t,n)=>((e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n)),r={},o={byteLength:function(e){var t=f(e),i=t[0],n=t[1];return 3*(i+n)/4-n},toByteArray:function(e){var t,i,n=f(e),r=n[0],o=n[1],s=new c(function(e,t,i){return 3*(t+i)/4-i}(0,r,o)),h=0,u=o>0?r-4:r;for(i=0;i<u;i+=4)t=a[e.charCodeAt(i)]<<18|a[e.charCodeAt(i+1)]<<12|a[e.charCodeAt(i+2)]<<6|a[e.charCodeAt(i+3)],s[h++]=t>>16&255,s[h++]=t>>8&255,s[h++]=255&t;2===o&&(t=a[e.charCodeAt(i)]<<2|a[e.charCodeAt(i+1)]>>4,s[h++]=255&t);1===o&&(t=a[e.charCodeAt(i)]<<10|a[e.charCodeAt(i+1)]<<4|a[e.charCodeAt(i+2)]>>2,s[h++]=t>>8&255,s[h++]=255&t);return s},fromByteArray:function(e){for(var t,i=e.length,n=i%3,r=[],o=16383,a=0,c=i-n;a<c;a+=o)r.push(p(e,a,a+o>c?c:a+o));1===n?(t=e[i-1],r.push(s[t>>2]+s[t<<4&63]+"==")):2===n&&(t=(e[i-2]<<8)+e[i-1],r.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return r.join("")}},s=[],a=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)s[u]=h[u],a[h.charCodeAt(u)]=u;function f(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function l(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function p(e,t,i){for(var n,r=[],o=t;o<i;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),r.push(l(n));return r.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var d={
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
read:function(e,t,i,n,r){var o,s,a=8*r-n-1,c=(1<<a)-1,h=c>>1,u=-7,f=i?r-1:0,l=i?-1:1,p=e[t+f];for(f+=l,o=p&(1<<-u)-1,p>>=-u,u+=a;u>0;o=256*o+e[t+f],f+=l,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=256*s+e[t+f],f+=l,u-=8);if(0===o)o=1-h;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(e,t,i,n,r,o){var s,a,c,h=8*o-r-1,u=(1<<h)-1,f=u>>1,l=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(s++,c/=2),s+f>=u?(a=0,s=u):s+f>=1?(a=(t*c-1)*Math.pow(2,r),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,r),s=0));r>=8;e[i+p]=255&a,p+=d,a/=256,r-=8);for(s=s<<r|a,h+=r;h>0;e[i+p]=255&s,p+=d,s/=256,h-=8);e[i+p-d]|=128*m}};
/*!
   * The buffer module from node.js, for the browser.
   *
   * @author   Feross Aboukhadijeh <https://feross.org>
   * @license  MIT
   */
!function(e){const t=o,i=d,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},e.INSPECT_MAX_BYTES=50;const r=2147483647;e.kMaxLength=r;const{Uint8Array:s,ArrayBuffer:a,SharedArrayBuffer:c}=globalThis;function h(e){if(e>r)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new s(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,i){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return p(e)}return f(e,t,i)}function f(e,t,i){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!u.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const i=0|w(e,t);let n=h(i);const r=n.write(e,t);r!==i&&(n=n.slice(0,r));return n}(e,t);if(a.isView(e))return function(e){if(Q(e,s)){const t=new s(e);return g(t.buffer,t.byteOffset,t.byteLength)}return m(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Q(e,a)||e&&Q(e.buffer,a))return g(e,t,i);if(void 0!==c&&(Q(e,c)||e&&Q(e.buffer,c)))return g(e,t,i);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return u.from(n,t,i);const r=function(e){if(u.isBuffer(e)){const t=0|y(e.length),i=h(t);return 0===i.length||e.copy(i,0,0,t),i}if(void 0!==e.length)return"number"!=typeof e.length||Z(e.length)?h(0):m(e);if("Buffer"===e.type&&Array.isArray(e.data))return m(e.data)}(e);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return u.from(e[Symbol.toPrimitive]("string"),t,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function p(e){return l(e),h(e<0?0:0|y(e))}function m(e){const t=e.length<0?0:0|y(e.length),i=h(t);for(let n=0;n<t;n+=1)i[n]=255&e[n];return i}function g(e,t,i){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(i||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===t&&void 0===i?new s(e):void 0===i?new s(e,t):new s(e,t,i),Object.setPrototypeOf(n,u.prototype),n}function y(e){if(e>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|e}function w(e,t){if(u.isBuffer(e))return e.length;if(a.isView(e)||Q(e,a))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return X(e).length;default:if(r)return n?-1:Y(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return U(this,t,i);case"utf8":case"utf-8":return A(this,t,i);case"ascii":return R(this,t,i);case"latin1":case"binary":return I(this,t,i);case"base64":return O(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,t,i);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function v(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function x(e,t,i,n,r){if(0===e.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),Z(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:k(e,t,i,n,r);if("number"==typeof t)return t&=255,"function"==typeof s.prototype.indexOf?r?s.prototype.indexOf.call(e,t,i):s.prototype.lastIndexOf.call(e,t,i):k(e,[t],i,n,r);throw new TypeError("val must be string, number or Buffer")}function k(e,t,i,n,r){let o,s=1,a=e.length,c=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;s=2,a/=2,c/=2,i/=2}function h(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(r){let n=-1;for(o=i;o<a;o++)if(h(e,o)===h(t,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===c)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(i+c>a&&(i=a-c),o=i;o>=0;o--){let i=!0;for(let n=0;n<c;n++)if(h(e,o+n)!==h(t,n)){i=!1;break}if(i)return o}return-1}function E(e,t,i,n){i=Number(i)||0;const r=e.length-i;n?(n=Number(n))>r&&(n=r):n=r;const o=t.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(t.substr(2*s,2),16);if(Z(n))return s;e[i+s]=n}return s}function S(e,t,i,n){return G(Y(t,e.length-i),e,i,n)}function _(e,t,i,n){return G(function(e){const t=[];for(let i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,n)}function T(e,t,i,n){return G(X(t),e,i,n)}function C(e,t,i,n){return G(function(e,t){let i,n,r;const o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)i=e.charCodeAt(s),n=i>>8,r=i%256,o.push(r),o.push(n);return o}(t,e.length-i),e,i,n)}function O(e,i,n){return 0===i&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(i,n))}function A(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r<i;){const t=e[r];let o=null,s=t>239?4:t>223?3:t>191?2:1;if(r+s<=i){let i,n,a,c;switch(s){case 1:t<128&&(o=t);break;case 2:i=e[r+1],128==(192&i)&&(c=(31&t)<<6|63&i,c>127&&(o=c));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(c=(15&t)<<12|(63&i)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),r+=s}return function(e){const t=e.length;if(t<=B)return String.fromCharCode.apply(String,e);let i="",n=0;for(;n<t;)i+=String.fromCharCode.apply(String,e.slice(n,n+=B));return i}(n)}u.TYPED_ARRAY_SUPPORT=function(){try{const e=new s(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,s.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),u.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(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(e,t,i){return f(e,t,i)},Object.setPrototypeOf(u.prototype,s.prototype),Object.setPrototypeOf(u,s),u.alloc=function(e,t,i){return function(e,t,i){return l(e),e<=0?h(e):void 0!==t?"string"==typeof i?h(e).fill(t,i):h(e).fill(t):h(e)}(e,t,i)},u.allocUnsafe=function(e){return p(e)},u.allocUnsafeSlow=function(e){return p(e)},u.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==u.prototype},u.compare=function(e,t){if(Q(e,s)&&(e=u.from(e,e.offset,e.byteLength)),Q(t,s)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,n=t.length;for(let r=0,o=Math.min(i,n);r<o;++r)if(e[r]!==t[r]){i=e[r],n=t[r];break}return i<n?-1:n<i?1:0},u.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}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);let i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;const n=u.allocUnsafe(t);let r=0;for(i=0;i<e.length;++i){let t=e[i];if(Q(t,s))r+t.length>n.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(n,r)):s.prototype.set.call(n,t,r);else{if(!u.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},u.byteLength=w,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)v(this,t,t+1);return this},u.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)v(this,t,t+3),v(this,t+1,t+2);return this},u.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)v(this,t,t+7),v(this,t+1,t+6),v(this,t+2,t+5),v(this,t+3,t+4);return this},u.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?A(this,0,e):b.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){let t="";const i=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(t+=" ... "),"<Buffer "+t+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(e,t,i,n,r){if(Q(e,s)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let o=(r>>>=0)-(n>>>=0),a=(i>>>=0)-(t>>>=0);const c=Math.min(o,a),h=this.slice(n,r),f=e.slice(t,i);for(let s=0;s<c;++s)if(h[s]!==f[s]){o=h[s],a=f[s];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},u.prototype.indexOf=function(e,t,i){return x(this,e,t,i,!0)},u.prototype.lastIndexOf=function(e,t,i){return x(this,e,t,i,!1)},u.prototype.write=function(e,t,i,n){if(void 0===t)n="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)n=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return E(this,e,t,i);case"utf8":case"utf-8":return S(this,e,t,i);case"ascii":case"latin1":case"binary":return _(this,e,t,i);case"base64":return T(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,t,i);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const B=4096;function R(e,t,i){let n="";i=Math.min(e.length,i);for(let r=t;r<i;++r)n+=String.fromCharCode(127&e[r]);return n}function I(e,t,i){let n="";i=Math.min(e.length,i);for(let r=t;r<i;++r)n+=String.fromCharCode(e[r]);return n}function U(e,t,i){const n=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>n)&&(i=n);let r="";for(let o=t;o<i;++o)r+=ee[e[o]];return r}function F(e,t,i){const n=e.slice(t,i);let r="";for(let o=0;o<n.length-1;o+=2)r+=String.fromCharCode(n[o]+256*n[o+1]);return r}function L(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,i,n,r,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||t<o)throw new RangeError('"value" argument is out of bounds');if(i+n>e.length)throw new RangeError("Index out of range")}function N(e,t,i,n,r){K(t,n,r,e,i,7);let o=Number(t&BigInt(4294967295));e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,i}function M(e,t,i,n,r){K(t,n,r,e,i,7);let o=Number(t&BigInt(4294967295));e[i+7]=o,o>>=8,e[i+6]=o,o>>=8,e[i+5]=o,o>>=8,e[i+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=s,s>>=8,e[i+2]=s,s>>=8,e[i+1]=s,s>>=8,e[i]=s,i+8}function P(e,t,i,n,r,o){if(i+n>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function z(e,t,n,r,o){return t=+t,n>>>=0,o||P(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function D(e,t,n,r,o){return t=+t,n>>>=0,o||P(e,0,n,8),i.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t<e&&(t=e);const n=this.subarray(e,t);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,i){e>>>=0,t>>>=0,i||L(e,t,this.length);let n=this[e],r=1,o=0;for(;++o<t&&(r*=256);)n+=this[e+o]*r;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,i){e>>>=0,t>>>=0,i||L(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=te(function(e){V(e>>>=0,"offset");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||H(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<<BigInt(32))}),u.prototype.readBigUInt64BE=te(function(e){V(e>>>=0,"offset");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||H(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<<BigInt(32))+BigInt(r)}),u.prototype.readIntLE=function(e,t,i){e>>>=0,t>>>=0,i||L(e,t,this.length);let n=this[e],r=1,o=0;for(;++o<t&&(r*=256);)n+=this[e+o]*r;return r*=128,n>=r&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||L(e,t,this.length);let n=t,r=1,o=this[e+--n];for(;n>0&&(r*=256);)o+=this[e+--n]*r;return r*=128,o>=r&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||L(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},u.prototype.readInt16BE=function(e,t){e>>>=0,t||L(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=te(function(e){V(e>>>=0,"offset");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||H(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)}),u.prototype.readBigInt64BE=te(function(e){V(e>>>=0,"offset");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||H(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+i)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||L(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||L(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||L(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||L(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t>>>=0,i>>>=0,!n){j(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=1,o=0;for(this[t]=255&e;++o<i&&(r*=256);)this[t+o]=e/r&255;return t+i},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,i,n){if(e=+e,t>>>=0,i>>>=0,!n){j(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=i-1,o=1;for(this[t+r]=255&e;--r>=0&&(o*=256);)this[t+r]=e/o&255;return t+i},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||j(this,e,t,1,255,0),this[t]=255&e,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||j(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},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||j(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},u.prototype.writeBigUInt64LE=te(function(e,t=0){return N(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=te(function(e,t=0){return M(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);j(this,e,t,i,n-1,-n)}let r=0,o=1,s=0;for(this[t]=255&e;++r<i&&(o*=256);)e<0&&0===s&&0!==this[t+r-1]&&(s=1),this[t+r]=(e/o|0)-s&255;return t+i},u.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);j(this,e,t,i,n-1,-n)}let r=i-1,o=1,s=0;for(this[t+r]=255&e;--r>=0&&(o*=256);)e<0&&0===s&&0!==this[t+r+1]&&(s=1),this[t+r]=(e/o|0)-s&255;return t+i},u.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||j(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||j(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},u.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||j(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},u.prototype.writeBigInt64LE=te(function(e,t=0){return N(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=te(function(e,t=0){return M(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(e,t,i){return z(this,e,t,!0,i)},u.prototype.writeFloatBE=function(e,t,i){return z(this,e,t,!1,i)},u.prototype.writeDoubleLE=function(e,t,i){return D(this,e,t,!0,i)},u.prototype.writeDoubleBE=function(e,t,i){return D(this,e,t,!1,i)},u.prototype.copy=function(e,t,i,n){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);const r=n-i;return this===e&&"function"==typeof s.prototype.copyWithin?this.copyWithin(t,i,n):s.prototype.set.call(e,this.subarray(i,n),t),r},u.prototype.fill=function(e,t,i,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){const 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<i)throw new RangeError("Out of range index");if(i<=t)return this;let r;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(r=t;r<i;++r)this[r]=e;else{const o=u.isBuffer(e)?e:u.from(e,n),s=o.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(r=0;r<i-t;++r)this[r+t]=o[r%s]}return this};const q={};function $(e,t,i){q[e]=class extends i{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 W(e){let t="",i=e.length;const n="-"===e[0]?1:0;for(;i>=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function K(e,t,i,n,r,o){if(e>i||e<t){const i="bigint"==typeof t?"n":"";let n;throw n=0===t||t===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(o+1)}${i}`:`>= -(2${i} ** ${8*(o+1)-1}${i}) and < 2 ** ${8*(o+1)-1}${i}`,new q.ERR_OUT_OF_RANGE("value",n,e)}!function(e,t,i){V(t,"offset"),void 0!==e[t]&&void 0!==e[t+i]||H(t,e.length-(i+1))}(n,r,o)}function V(e,t){if("number"!=typeof e)throw new q.ERR_INVALID_ARG_TYPE(t,"number",e)}function H(e,t,i){if(Math.floor(e)!==e)throw V(e,i),new q.ERR_OUT_OF_RANGE("offset","an integer",e);if(t<0)throw new q.ERR_BUFFER_OUT_OF_BOUNDS;throw new q.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}$("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),$("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),$("ERR_OUT_OF_RANGE",function(e,t,i){let n=`The value of "${e}" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=W(String(i)):"bigint"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=W(r)),r+="n"),n+=` It must be ${t}. Received ${r}`,n},RangeError);const J=/[^+/0-9A-Za-z-_]/g;function Y(e,t){let i;t=t||1/0;const n=e.length;let r=null;const o=[];for(let s=0;s<n;++s){if(i=e.charCodeAt(s),i>55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&o.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&o.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;o.push(i)}else if(i<2048){if((t-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function X(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(J,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function G(e,t,i,n){let r;for(r=0;r<n&&!(r+i>=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function Q(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Z(e){return e!=e}const ee=function(){const e="0123456789abcdef",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function te(e){return"undefined"==typeof BigInt?ie:e}function ie(){throw new Error("BigInt not supported")}}(r);const m=r.Buffer,g=r.Buffer,y=globalThis||self;function w(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var b,v,x={exports:{}},k=x.exports={};function E(){throw new Error("setTimeout has not been defined")}function S(){throw new Error("clearTimeout has not been defined")}function _(e){if(b===setTimeout)return setTimeout(e,0);if((b===E||!b)&&setTimeout)return b=setTimeout,setTimeout(e,0);try{return b(e,0)}catch(t){try{return b.call(null,e,0)}catch(i){return b.call(this,e,0)}}}!function(){try{b="function"==typeof setTimeout?setTimeout:E}catch(e){b=E}try{v="function"==typeof clearTimeout?clearTimeout:S}catch(e){v=S}}();var T,C=[],O=!1,A=-1;function B(){O&&T&&(O=!1,T.length?C=T.concat(C):A=-1,C.length&&R())}function R(){if(!O){var e=_(B);O=!0;for(var t=C.length;t;){for(T=C,C=[];++A<t;)T&&T[A].run();A=-1,t=C.length}T=null,O=!1,function(e){if(v===clearTimeout)return clearTimeout(e);if((v===S||!v)&&clearTimeout)return v=clearTimeout,clearTimeout(e);try{return v(e)}catch(t){try{return v.call(null,e)}catch(i){return v.call(this,e)}}}(e)}}function I(e,t){this.fun=e,this.array=t}function U(){}k.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];C.push(new I(e,t)),1!==C.length||O||_(R)},I.prototype.run=function(){this.fun.apply(null,this.array)},k.title="browser",k.browser=!0,k.env={},k.argv=[],k.version="",k.versions={},k.on=U,k.addListener=U,k.once=U,k.off=U,k.removeListener=U,k.removeAllListeners=U,k.emit=U,k.prependListener=U,k.prependOnceListener=U,k.listeners=function(e){return[]},k.binding=function(e){throw new Error("process.binding is not supported")},k.cwd=function(){return"/"},k.chdir=function(e){throw new Error("process.chdir is not supported")},k.umask=function(){return 0};const F=w(x.exports);function L(e,t){return function(){return e.apply(t,arguments)}}const{toString:j}=Object.prototype,{getPrototypeOf:N}=Object,{iterator:M,toStringTag:P}=Symbol,z=(e=>t=>{const i=j.call(t);return e[i]||(e[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>z(t)===e),q=e=>t=>typeof t===e,{isArray:$}=Array,W=q("undefined");function K(e){return null!==e&&!W(e)&&null!==e.constructor&&!W(e.constructor)&&J(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const V=D("ArrayBuffer");const H=q("string"),J=q("function"),Y=q("number"),X=e=>null!==e&&"object"==typeof e,G=e=>{if("object"!==z(e))return!1;const t=N(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||P in e||M in e)},Q=D("Date"),Z=D("File"),ee=D("Blob"),te=D("FileList"),ie=D("URLSearchParams"),[ne,re,oe,se]=["ReadableStream","Request","Response","Headers"].map(D);function ae(e,t,{allOwnKeys:i=!1}={}){if(null==e)return;let n,r;if("object"!=typeof e&&(e=[e]),$(e))for(n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else{if(K(e))return;const r=i?Object.getOwnPropertyNames(e):Object.keys(e),o=r.length;let s;for(n=0;n<o;n++)s=r[n],t.call(null,e[s],s,e)}}function ce(e,t){if(K(e))return null;t=t.toLowerCase();const i=Object.keys(e);let n,r=i.length;for(;r-- >0;)if(n=i[r],t===n.toLowerCase())return n;return null}const he="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:y,ue=e=>!W(e)&&e!==he;const fe=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&N(Uint8Array)),le=D("HTMLFormElement"),pe=(({hasOwnProperty:e})=>(t,i)=>e.call(t,i))(Object.prototype),de=D("RegExp"),me=(e,t)=>{const i=Object.getOwnPropertyDescriptors(e),n={};ae(i,(i,r)=>{let o;!1!==(o=t(i,r,e))&&(n[r]=o||i)}),Object.defineProperties(e,n)};const ge=D("AsyncFunction"),ye=(we="function"==typeof setImmediate,be=J(he.postMessage),we?setImmediate:be?(ve=`axios@${Math.random()}`,xe=[],he.addEventListener("message",({source:e,data:t})=>{e===he&&t===ve&&xe.length&&xe.shift()()},!1),e=>{xe.push(e),he.postMessage(ve,"*")}):e=>setTimeout(e));var we,be,ve,xe;const ke="undefined"!=typeof queueMicrotask?queueMicrotask.bind(he):void 0!==F&&F.nextTick||ye,Ee={isArray:$,isArrayBuffer:V,isBuffer:K,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||J(e.append)&&("formdata"===(t=z(e))||"object"===t&&J(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&V(e.buffer),t},isString:H,isNumber:Y,isBoolean:e=>!0===e||!1===e,isObject:X,isPlainObject:G,isEmptyObject:e=>{if(!X(e)||K(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(t){return!1}},isReadableStream:ne,isRequest:re,isResponse:oe,isHeaders:se,isUndefined:W,isDate:Q,isFile:Z,isBlob:ee,isRegExp:de,isFunction:J,isStream:e=>X(e)&&J(e.pipe),isURLSearchParams:ie,isTypedArray:fe,isFileList:te,forEach:ae,merge:function e(){const{caseless:t}=ue(this)&&this||{},i={},n=(n,r)=>{const o=t&&ce(i,r)||r;G(i[o])&&G(n)?i[o]=e(i[o],n):G(n)?i[o]=e({},n):$(n)?i[o]=n.slice():i[o]=n};for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&ae(arguments[r],n);return i},extend:(e,t,i,{allOwnKeys:n}={})=>(ae(t,(t,n)=>{i&&J(t)?e[n]=L(t,i):e[n]=t},{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,i,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),i&&Object.assign(e.prototype,i)},toFlatObject:(e,t,i,n)=>{let r,o,s;const a={};if(t=t||{},null==e)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)s=r[o],n&&!n(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==i&&N(e)}while(e&&(!i||i(e,t))&&e!==Object.prototype);return t},kindOf:z,kindOfTest:D,endsWith:(e,t,i)=>{e=String(e),(void 0===i||i>e.length)&&(i=e.length),i-=t.length;const n=e.indexOf(t,i);return-1!==n&&n===i},toArray:e=>{if(!e)return null;if($(e))return e;let t=e.length;if(!Y(t))return null;const i=new Array(t);for(;t-- >0;)i[t]=e[t];return i},forEachEntry:(e,t)=>{const i=(e&&e[M]).call(e);let n;for(;(n=i.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},matchAll:(e,t)=>{let i;const n=[];for(;null!==(i=e.exec(t));)n.push(i);return n},isHTMLForm:le,hasOwnProperty:pe,hasOwnProp:pe,reduceDescriptors:me,freezeMethods:e=>{me(e,(t,i)=>{if(J(e)&&-1!==["arguments","caller","callee"].indexOf(i))return!1;const n=e[i];J(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")}))})},toObjectSet:(e,t)=>{const i={},n=e=>{e.forEach(e=>{i[e]=!0})};return $(e)?n(e):n(String(e).split(t)),i},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,i){return t.toUpperCase()+i}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:ce,global:he,isContextDefined:ue,isSpecCompliantForm:function(e){return!!(e&&J(e.append)&&"FormData"===e[P]&&e[M])},toJSONObject:e=>{const t=new Array(10),i=(e,n)=>{if(X(e)){if(t.indexOf(e)>=0)return;if(K(e))return e;if(!("toJSON"in e)){t[n]=e;const r=$(e)?[]:{};return ae(e,(e,t)=>{const o=i(e,n+1);!W(o)&&(r[t]=o)}),t[n]=void 0,r}}return e};return i(e,0)},isAsyncFn:ge,isThenable:e=>e&&(X(e)||J(e))&&J(e.then)&&J(e.catch),setImmediate:ye,asap:ke,isIterable:e=>null!=e&&J(e[M])};function Se(e,t,i,n,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),i&&(this.config=i),n&&(this.request=n),r&&(this.response=r,this.status=r.status?r.status:null)}Ee.inherits(Se,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ee.toJSONObject(this.config),code:this.code,status:this.status}}});const _e=Se.prototype,Te={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Te[e]={value:e}}),Object.defineProperties(Se,Te),Object.defineProperty(_e,"isAxiosError",{value:!0}),Se.from=(e,t,i,n,r,o)=>{const s=Object.create(_e);return Ee.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e),Se.call(s,e.message,t,i,n,r),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};function Ce(e){return Ee.isPlainObject(e)||Ee.isArray(e)}function Oe(e){return Ee.endsWith(e,"[]")?e.slice(0,-2):e}function Ae(e,t,i){return e?e.concat(t).map(function(e,t){return e=Oe(e),!i&&t?"["+e+"]":e}).join(i?".":""):t}const Be=Ee.toFlatObject(Ee,{},null,function(e){return/^is[A-Z]/.test(e)});function Re(e,t,i){if(!Ee.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(i=Ee.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Ee.isUndefined(t[e])})).metaTokens,r=i.visitor||h,o=i.dots,s=i.indexes,a=(i.Blob||"undefined"!=typeof Blob&&Blob)&&Ee.isSpecCompliantForm(t);if(!Ee.isFunction(r))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Ee.isDate(e))return e.toISOString();if(Ee.isBoolean(e))return e.toString();if(!a&&Ee.isBlob(e))throw new Se("Blob is not supported. Use a Buffer instead.");return Ee.isArrayBuffer(e)||Ee.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):m.from(e):e}function h(e,i,r){let a=e;if(e&&!r&&"object"==typeof e)if(Ee.endsWith(i,"{}"))i=n?i:i.slice(0,-2),e=JSON.stringify(e);else if(Ee.isArray(e)&&function(e){return Ee.isArray(e)&&!e.some(Ce)}(e)||(Ee.isFileList(e)||Ee.endsWith(i,"[]"))&&(a=Ee.toArray(e)))return i=Oe(i),a.forEach(function(e,n){!Ee.isUndefined(e)&&null!==e&&t.append(!0===s?Ae([i],n,o):null===s?i:i+"[]",c(e))}),!1;return!!Ce(e)||(t.append(Ae(r,i,o),c(e)),!1)}const u=[],f=Object.assign(Be,{defaultVisitor:h,convertValue:c,isVisitable:Ce});if(!Ee.isObject(e))throw new TypeError("data must be an object");return function e(i,n){if(!Ee.isUndefined(i)){if(-1!==u.indexOf(i))throw Error("Circular reference detected in "+n.join("."));u.push(i),Ee.forEach(i,function(i,o){!0===(!(Ee.isUndefined(i)||null===i)&&r.call(t,i,Ee.isString(o)?o.trim():o,n,f))&&e(i,n?n.concat(o):[o])}),u.pop()}}(e),t}function Ie(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Ue(e,t){this._pairs=[],e&&Re(e,this,t)}const Fe=Ue.prototype;function Le(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function je(e,t,i){if(!t)return e;const n=i&&i.encode||Le;Ee.isFunction(i)&&(i={serialize:i});const r=i&&i.serialize;let o;if(o=r?r(t,i):Ee.isURLSearchParams(t)?t.toString():new Ue(t,i).toString(n),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}Fe.append=function(e,t){this._pairs.push([e,t])},Fe.toString=function(e){const t=e?function(t){return e.call(this,t,Ie)}:Ie;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class Ne{constructor(){this.handlers=[]}use(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!i&&i.synchronous,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ee.forEach(this.handlers,function(t){null!==t&&e(t)})}}const Me={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Pe={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ue,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},ze="undefined"!=typeof window&&"undefined"!=typeof document,De="object"==typeof navigator&&navigator||void 0,qe=ze&&(!De||["ReactNative","NativeScript","NS"].indexOf(De.product)<0),$e="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,We=ze&&window.location.href||"http://localhost",Ke={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ze,hasStandardBrowserEnv:qe,hasStandardBrowserWebWorkerEnv:$e,navigator:De,origin:We},Symbol.toStringTag,{value:"Module"})),...Pe};function Ve(e){function t(e,i,n,r){let o=e[r++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=r>=e.length;if(o=!o&&Ee.isArray(n)?n.length:o,a)return Ee.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!s;n[o]&&Ee.isObject(n[o])||(n[o]=[]);return t(e,i,n[o],r)&&Ee.isArray(n[o])&&(n[o]=function(e){const t={},i=Object.keys(e);let n;const r=i.length;let o;for(n=0;n<r;n++)o=i[n],t[o]=e[o];return t}(n[o])),!s}if(Ee.isFormData(e)&&Ee.isFunction(e.entries)){const i={};return Ee.forEachEntry(e,(e,n)=>{t(function(e){return Ee.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),n,i,0)}),i}return null}const He={transitional:Me,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const i=t.getContentType()||"",n=i.indexOf("application/json")>-1,r=Ee.isObject(e);r&&Ee.isHTMLForm(e)&&(e=new FormData(e));if(Ee.isFormData(e))return n?JSON.stringify(Ve(e)):e;if(Ee.isArrayBuffer(e)||Ee.isBuffer(e)||Ee.isStream(e)||Ee.isFile(e)||Ee.isBlob(e)||Ee.isReadableStream(e))return e;if(Ee.isArrayBufferView(e))return e.buffer;if(Ee.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Re(e,new Ke.classes.URLSearchParams,{visitor:function(e,t,i,n){return Ke.isNode&&Ee.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=Ee.isFileList(e))||i.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Re(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||n?(t.setContentType("application/json",!1),function(e,t,i){if(Ee.isString(e))try{return(t||JSON.parse)(e),Ee.trim(e)}catch(n){if("SyntaxError"!==n.name)throw n}return(i||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||He.transitional,i=t&&t.forcedJSONParsing,n="json"===this.responseType;if(Ee.isResponse(e)||Ee.isReadableStream(e))return e;if(e&&Ee.isString(e)&&(i&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(r){if(i){if("SyntaxError"===r.name)throw Se.from(r,Se.ERR_BAD_RESPONSE,this,null,this.response);throw r}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ke.classes.FormData,Blob:Ke.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ee.forEach(["delete","get","head","post","put","patch"],e=>{He.headers[e]={}});const Je=Ee.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Ye=Symbol("internals");function Xe(e){return e&&String(e).trim().toLowerCase()}function Ge(e){return!1===e||null==e?e:Ee.isArray(e)?e.map(Ge):String(e)}function Qe(e,t,i,n,r){return Ee.isFunction(n)?n.call(this,t,i):(r&&(t=i),Ee.isString(t)?Ee.isString(n)?-1!==t.indexOf(n):Ee.isRegExp(n)?n.test(t):void 0:void 0)}let Ze=class{constructor(e){e&&this.set(e)}set(e,t,i){const n=this;function r(e,t,i){const r=Xe(t);if(!r)throw new Error("header name must be a non-empty string");const o=Ee.findKey(n,r);(!o||void 0===n[o]||!0===i||void 0===i&&!1!==n[o])&&(n[o||t]=Ge(e))}const o=(e,t)=>Ee.forEach(e,(e,i)=>r(e,i,t));if(Ee.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Ee.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let i,n,r;return e&&e.split("\n").forEach(function(e){r=e.indexOf(":"),i=e.substring(0,r).trim().toLowerCase(),n=e.substring(r+1).trim(),!i||t[i]&&Je[i]||("set-cookie"===i?t[i]?t[i].push(n):t[i]=[n]:t[i]=t[i]?t[i]+", "+n:n)}),t})(e),t);else if(Ee.isObject(e)&&Ee.isIterable(e)){let i,n,r={};for(const t of e){if(!Ee.isArray(t))throw TypeError("Object iterator must return a key-value pair");r[n=t[0]]=(i=r[n])?Ee.isArray(i)?[...i,t[1]]:[i,t[1]]:t[1]}o(r,t)}else null!=e&&r(t,e,i);return this}get(e,t){if(e=Xe(e)){const i=Ee.findKey(this,e);if(i){const e=this[i];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=i.exec(e);)t[n[1]]=n[2];return t}(e);if(Ee.isFunction(t))return t.call(this,e,i);if(Ee.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Xe(e)){const i=Ee.findKey(this,e);return!(!i||void 0===this[i]||t&&!Qe(0,this[i],i,t))}return!1}delete(e,t){const i=this;let n=!1;function r(e){if(e=Xe(e)){const r=Ee.findKey(i,e);!r||t&&!Qe(0,i[r],r,t)||(delete i[r],n=!0)}}return Ee.isArray(e)?e.forEach(r):r(e),n}clear(e){const t=Object.keys(this);let i=t.length,n=!1;for(;i--;){const r=t[i];e&&!Qe(0,this[r],r,e,!0)||(delete this[r],n=!0)}return n}normalize(e){const t=this,i={};return Ee.forEach(this,(n,r)=>{const o=Ee.findKey(i,r);if(o)return t[o]=Ge(n),void delete t[r];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,i)=>t.toUpperCase()+i)}(r):String(r).trim();s!==r&&delete t[r],t[s]=Ge(n),i[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ee.forEach(this,(i,n)=>{null!=i&&!1!==i&&(t[n]=e&&Ee.isArray(i)?i.join(", "):i)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const i=new this(e);return t.forEach(e=>i.set(e)),i}static accessor(e){const t=(this[Ye]=this[Ye]={accessors:{}}).accessors,i=this.prototype;function n(e){const n=Xe(e);t[n]||(!function(e,t){const i=Ee.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+i,{value:function(e,i,r){return this[n].call(this,t,e,i,r)},configurable:!0})})}(i,e),t[n]=!0)}return Ee.isArray(e)?e.forEach(n):n(e),this}};function et(e,t){const i=this||He,n=t||i,r=Ze.from(n.headers);let o=n.data;return Ee.forEach(e,function(e){o=e.call(i,o,r.normalize(),t?t.status:void 0)}),r.normalize(),o}function tt(e){return!(!e||!e.__CANCEL__)}function it(e,t,i){Se.call(this,null==e?"canceled":e,Se.ERR_CANCELED,t,i),this.name="CanceledError"}function nt(e,t,i){const n=i.config.validateStatus;i.status&&n&&!n(i.status)?t(new Se("Request failed with status code "+i.status,[Se.ERR_BAD_REQUEST,Se.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i)):e(i)}Ze.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ee.reduceDescriptors(Ze.prototype,({value:e},t)=>{let i=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[i]=e}}}),Ee.freezeMethods(Ze),Ee.inherits(it,Se,{__CANCEL__:!0});const rt=(e,t,i=3)=>{let n=0;const r=function(e,t){e=e||10;const i=new Array(e),n=new Array(e);let r,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),h=n[s];r||(r=c),i[o]=a,n[o]=c;let u=s,f=0;for(;u!==o;)f+=i[u++],u%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-r<t)return;const l=h&&c-h;return l?Math.round(1e3*f/l):void 0}}(50,250);return function(e,t){let i,n,r=0,o=1e3/t;const s=(t,o=Date.now())=>{r=o,i=null,n&&(clearTimeout(n),n=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-r;a>=o?s(e,t):(i=e,n||(n=setTimeout(()=>{n=null,s(i)},o-a)))},()=>i&&s(i)]}(i=>{const o=i.loaded,s=i.lengthComputable?i.total:void 0,a=o-n,c=r(a);n=o;e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&o<=s?(s-o)/c:void 0,event:i,lengthComputable:null!=s,[t?"download":"upload"]:!0})},i)},ot=(e,t)=>{const i=null!=e;return[n=>t[0]({lengthComputable:i,total:e,loaded:n}),t[1]]},st=e=>(...t)=>Ee.asap(()=>e(...t)),at=Ke.hasStandardBrowserEnv?((e,t)=>i=>(i=new URL(i,Ke.origin),e.protocol===i.protocol&&e.host===i.host&&(t||e.port===i.port)))(new URL(Ke.origin),Ke.navigator&&/(msie|trident)/i.test(Ke.navigator.userAgent)):()=>!0,ct=Ke.hasStandardBrowserEnv?{write(e,t,i,n,r,o){const s=[e+"="+encodeURIComponent(t)];Ee.isNumber(i)&&s.push("expires="+new Date(i).toGMTString()),Ee.isString(n)&&s.push("path="+n),Ee.isString(r)&&s.push("domain="+r),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function ht(e,t,i){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==i)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const ut=e=>e instanceof Ze?{...e}:e;function ft(e,t){t=t||{};const i={};function n(e,t,i,n){return Ee.isPlainObject(e)&&Ee.isPlainObject(t)?Ee.merge.call({caseless:n},e,t):Ee.isPlainObject(t)?Ee.merge({},t):Ee.isArray(t)?t.slice():t}function r(e,t,i,r){return Ee.isUndefined(t)?Ee.isUndefined(e)?void 0:n(void 0,e,0,r):n(e,t,0,r)}function o(e,t){if(!Ee.isUndefined(t))return n(void 0,t)}function s(e,t){return Ee.isUndefined(t)?Ee.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(i,r,o){return o in t?n(i,r):o in e?n(void 0,i):void 0}const c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,i)=>r(ut(e),ut(t),0,!0)};return Ee.forEach(Object.keys({...e,...t}),function(n){const o=c[n]||r,s=o(e[n],t[n],n);Ee.isUndefined(s)&&o!==a||(i[n]=s)}),i}const lt=e=>{const t=ft({},e);let i,{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=Ze.from(a),t.url=je(ht(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Ee.isFormData(n))if(Ke.hasStandardBrowserEnv||Ke.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(i=a.getContentType())){const[e,...t]=i?i.split(";").map(e=>e.trim()).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(Ke.hasStandardBrowserEnv&&(r&&Ee.isFunction(r)&&(r=r(t)),r||!1!==r&&at(t.url))){const e=o&&s&&ct.read(s);e&&a.set(o,e)}return t},pt="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,i){const n=lt(e);let r=n.data;const o=Ze.from(n.headers).normalize();let s,a,c,h,u,{responseType:f,onUploadProgress:l,onDownloadProgress:p}=n;function d(){h&&h(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(s),n.signal&&n.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function g(){if(!m)return;const n=Ze.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());nt(function(e){t(e),d()},function(e){i(e),d()},{data:f&&"text"!==f&&"json"!==f?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:n,config:e,request:m}),m=null}m.open(n.method.toUpperCase(),n.url,!0),m.timeout=n.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(i(new Se("Request aborted",Se.ECONNABORTED,e,m)),m=null)},m.onerror=function(){i(new Se("Network Error",Se.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const r=n.transitional||Me;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),i(new Se(t,r.clarifyTimeoutError?Se.ETIMEDOUT:Se.ECONNABORTED,e,m)),m=null},void 0===r&&o.setContentType(null),"setRequestHeader"in m&&Ee.forEach(o.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Ee.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),f&&"json"!==f&&(m.responseType=n.responseType),p&&([c,u]=rt(p,!0),m.addEventListener("progress",c)),l&&m.upload&&([a,h]=rt(l),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",h)),(n.cancelToken||n.signal)&&(s=t=>{m&&(i(!t||t.type?new it(null,e,m):t),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(s),n.signal&&(n.signal.aborted?s():n.signal.addEventListener("abort",s)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);y&&-1===Ke.protocols.indexOf(y)?i(new Se("Unsupported protocol "+y+":",Se.ERR_BAD_REQUEST,e)):m.send(r||null)})},dt=(e,t)=>{const{length:i}=e=e?e.filter(Boolean):[];if(t||i){let i,n=new AbortController;const r=function(e){if(!i){i=!0,s();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Se?t:new it(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,r(new Se(`timeout ${t} of ms exceeded`,Se.ETIMEDOUT))},t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(r):e.removeEventListener("abort",r)}),e=null)};e.forEach(e=>e.addEventListener("abort",r));const{signal:a}=n;return a.unsubscribe=()=>Ee.asap(s),a}},mt=function*(e,t){let i=e.byteLength;if(i<t)return void(yield e);let n,r=0;for(;r<i;)n=r+t,yield e.slice(r,n),r=n},gt=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:i}=await t.read();if(e)break;yield i}}finally{await t.cancel()}},yt=(e,t,i,n)=>{const r=async function*(e,t){for await(const i of gt(e))yield*mt(i,t)}(e,t);let o,s=0,a=e=>{o||(o=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await r.next();if(t)return a(),void e.close();let o=n.byteLength;if(i){let e=s+=o;i(e)}e.enqueue(new Uint8Array(n))}catch(t){throw a(t),t}},cancel:e=>(a(e),r.return())},{highWaterMark:2})},wt="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,bt=wt&&"function"==typeof ReadableStream,vt=wt&&("function"==typeof TextEncoder?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),xt=(e,...t)=>{try{return!!e(...t)}catch(i){return!1}},kt=bt&&xt(()=>{let e=!1;const t=new Request(Ke.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Et=bt&&xt(()=>Ee.isReadableStream(new Response("").body)),St={stream:Et&&(e=>e.body)};var _t;wt&&(_t=new Response,["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!St[e]&&(St[e]=Ee.isFunction(_t[e])?t=>t[e]():(t,i)=>{throw new Se(`Response type '${e}' is not supported`,Se.ERR_NOT_SUPPORT,i)})}));const Tt=async(e,t)=>{const i=Ee.toFiniteNumber(e.getContentLength());return null==i?(async e=>{if(null==e)return 0;if(Ee.isBlob(e))return e.size;if(Ee.isSpecCompliantForm(e)){const t=new Request(Ke.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ee.isArrayBufferView(e)||Ee.isArrayBuffer(e)?e.byteLength:(Ee.isURLSearchParams(e)&&(e+=""),Ee.isString(e)?(await vt(e)).byteLength:void 0)})(t):i},Ct={http:null,xhr:pt,fetch:wt&&(async e=>{let{url:t,method:i,data:n,signal:r,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:h,headers:u,withCredentials:f="same-origin",fetchOptions:l}=lt(e);h=h?(h+"").toLowerCase():"text";let p,d=dt([r,o&&o.toAbortSignal()],s);const m=d&&d.unsubscribe&&(()=>{d.unsubscribe()});let g;try{if(c&&kt&&"get"!==i&&"head"!==i&&0!==(g=await Tt(u,n))){let e,i=new Request(t,{method:"POST",body:n,duplex:"half"});if(Ee.isFormData(n)&&(e=i.headers.get("content-type"))&&u.setContentType(e),i.body){const[e,t]=ot(g,rt(st(c)));n=yt(i.body,65536,e,t)}}Ee.isString(f)||(f=f?"include":"omit");const r="credentials"in Request.prototype;p=new Request(t,{...l,signal:d,method:i.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:r?f:void 0});let o=await fetch(p,l);const s=Et&&("stream"===h||"response"===h);if(Et&&(a||s&&m)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=o[t]});const t=Ee.toFiniteNumber(o.headers.get("content-length")),[i,n]=a&&ot(t,rt(st(a),!0))||[];o=new Response(yt(o.body,65536,i,()=>{n&&n(),m&&m()}),e)}h=h||"text";let y=await St[Ee.findKey(St,h)||"text"](o,e);return!s&&m&&m(),await new Promise((t,i)=>{nt(t,i,{data:y,headers:Ze.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:p})})}catch(y){if(m&&m(),y&&"TypeError"===y.name&&/Load failed|fetch/i.test(y.message))throw Object.assign(new Se("Network Error",Se.ERR_NETWORK,e,p),{cause:y.cause||y});throw Se.from(y,y&&y.code,e,p)}})};Ee.forEach(Ct,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(i){}Object.defineProperty(e,"adapterName",{value:t})}});const Ot=e=>`- ${e}`,At=e=>Ee.isFunction(e)||null===e||!1===e,Bt=e=>{e=Ee.isArray(e)?e:[e];const{length:t}=e;let i,n;const r={};for(let o=0;o<t;o++){let t;if(i=e[o],n=i,!At(i)&&(n=Ct[(t=String(i)).toLowerCase()],void 0===n))throw new Se(`Unknown adapter '${t}'`);if(n)break;r[t||"#"+o]=n}if(!n){const e=Object.entries(r).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new Se("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Ot).join("\n"):" "+Ot(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function Rt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new it(null,e)}function It(e){Rt(e),e.headers=Ze.from(e.headers),e.data=et.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Bt(e.adapter||He.adapter)(e).then(function(t){return Rt(e),t.data=et.call(e,e.transformResponse,t),t.headers=Ze.from(t.headers),t},function(t){return tt(t)||(Rt(e),t&&t.response&&(t.response.data=et.call(e,e.transformResponse,t.response),t.response.headers=Ze.from(t.response.headers))),Promise.reject(t)})}const Ut="1.11.0",Ft={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ft[e]=function(i){return typeof i===e||"a"+(t<1?"n ":" ")+e}});const Lt={};Ft.transitional=function(e,t,i){function n(e,t){return"[Axios v"+Ut+"] Transitional option '"+e+"'"+t+(i?". "+i:"")}return(i,r,o)=>{if(!1===e)throw new Se(n(r," has been removed"+(t?" in "+t:"")),Se.ERR_DEPRECATED);return t&&!Lt[r]&&(Lt[r]=!0,console.warn(n(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(i,r,o)}},Ft.spelling=function(e){return(t,i)=>(console.warn(`${i} is likely a misspelling of ${e}`),!0)};const jt={assertOptions:function(e,t,i){if("object"!=typeof e)throw new Se("options must be an object",Se.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let r=n.length;for(;r-- >0;){const o=n[r],s=t[o];if(s){const t=e[o],i=void 0===t||s(t,o,e);if(!0!==i)throw new Se("option "+o+" must be "+i,Se.ERR_BAD_OPTION_VALUE);continue}if(!0!==i)throw new Se("Unknown option "+o,Se.ERR_BAD_OPTION)}},validators:Ft},Nt=jt.validators;let Mt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Ne,response:new Ne}}async request(e,t){try{return await this._request(e,t)}catch(i){if(i instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const t=e.stack?e.stack.replace(/^.+\n/,""):"";try{i.stack?t&&!String(i.stack).endsWith(t.replace(/^.+\n.+\n/,""))&&(i.stack+="\n"+t):i.stack=t}catch(n){}}throw i}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=ft(this.defaults,t);const{transitional:i,paramsSerializer:n,headers:r}=t;void 0!==i&&jt.assertOptions(i,{silentJSONParsing:Nt.transitional(Nt.boolean),forcedJSONParsing:Nt.transitional(Nt.boolean),clarifyTimeoutError:Nt.transitional(Nt.boolean)},!1),null!=n&&(Ee.isFunction(n)?t.paramsSerializer={serialize:n}:jt.assertOptions(n,{encode:Nt.function,serialize:Nt.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),jt.assertOptions(t,{baseUrl:Nt.spelling("baseURL"),withXsrfToken:Nt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&Ee.merge(r.common,r[t.method]);r&&Ee.forEach(["delete","get","head","post","put","patch","common"],e=>{delete r[e]}),t.headers=Ze.concat(o,r);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const c=[];let h;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let u,f=0;if(!a){const e=[It.bind(this),void 0];for(e.unshift(...s),e.push(...c),u=e.length,h=Promise.resolve(t);f<u;)h=h.then(e[f++],e[f++]);return h}u=s.length;let l=t;for(f=0;f<u;){const e=s[f++],t=s[f++];try{l=e(l)}catch(p){t.call(this,p);break}}try{h=It.call(this,l)}catch(p){return Promise.reject(p)}for(f=0,u=c.length;f<u;)h=h.then(c[f++],c[f++]);return h}getUri(e){return je(ht((e=ft(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Ee.forEach(["delete","get","head","options"],function(e){Mt.prototype[e]=function(t,i){return this.request(ft(i||{},{method:e,url:t,data:(i||{}).data}))}}),Ee.forEach(["post","put","patch"],function(e){function t(t){return function(i,n,r){return this.request(ft(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}Mt.prototype[e]=t(),Mt.prototype[e+"Form"]=t(!0)});const Pt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Pt).forEach(([e,t])=>{Pt[t]=e});const zt=function e(t){const i=new Mt(t),n=L(Mt.prototype.request,i);return Ee.extend(n,Mt.prototype,i,{allOwnKeys:!0}),Ee.extend(n,i,null,{allOwnKeys:!0}),n.create=function(i){return e(ft(t,i))},n}(He);zt.Axios=Mt,zt.CanceledError=it,zt.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const i=this;this.promise.then(e=>{if(!i._listeners)return;let t=i._listeners.length;for(;t-- >0;)i._listeners[t](e);i._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{i.subscribe(e),t=e}).then(e);return n.cancel=function(){i.unsubscribe(t)},n},e(function(e,n,r){i.reason||(i.reason=new it(e,n,r),t(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},zt.isCancel=tt,zt.VERSION=Ut,zt.toFormData=Re,zt.AxiosError=Se,zt.Cancel=zt.CanceledError,zt.all=function(e){return Promise.all(e)},zt.spread=function(e){return function(t){return e.apply(null,t)}},zt.isAxiosError=function(e){return Ee.isObject(e)&&!0===e.isAxiosError},zt.mergeConfig=ft,zt.AxiosHeaders=Ze,zt.formToJSON=e=>Ve(Ee.isHTMLForm(e)?new FormData(e):e),zt.getAdapter=Bt,zt.HttpStatusCode=Pt,zt.default=zt;const{Axios:Dt,AxiosError:qt,CanceledError:$t,isCancel:Wt,CancelToken:Kt,VERSION:Vt,all:Ht,Cancel:Jt,isAxiosError:Yt,spread:Xt,toFormData:Gt,AxiosHeaders:Qt,HttpStatusCode:Zt,formToJSON:ei,getAdapter:ti,mergeConfig:ii}=zt,ni=class e{constructor(){n(this,"isProduction"),this.isProduction="production"===F.env.NODE_ENV}static getInstance(){return e.instance||(e.instance=new e),e.instance}debug(e,...t){this.isProduction||console.debug(e,...t)}info(e,...t){this.isProduction||console.info(e,...t)}warn(e,...t){console.warn(e,...t)}error(e,...t){console.error(e,...t)}};n(ni,"instance");let ri=ni;class oi extends Error{constructor(e){super(e),this.name="ValidationError"}}function si(e){try{return{detectedType:"ecdsa",privateKey:t.PrivateKey.fromStringECDSA(e)}}catch(i){try{return{detectedType:"ed25519",privateKey:t.PrivateKey.fromStringED25519(e)}}catch{throw new Error(`Failed to parse private key as either ECDSA or ED25519: ${String(i)}`)}}}class ai{constructor(e){if(n(this,"accountId"),n(this,"privateKey"),n(this,"baseUrl"),n(this,"network"),this.accountId=e.accountId,"string"==typeof e.privateKey){const t=si(e.privateKey);this.privateKey=t.privateKey}else this.privateKey=e.privateKey;this.network=e.network||"mainnet",this.baseUrl=e.baseUrl||"https://kiloscribe.com"}async authenticate(){var e,t,i;const n=await zt.get(`${this.baseUrl}/api/auth/request-signature`,{headers:{"x-session":this.accountId}});if(!(null==(e=n.data)?void 0:e.message))throw new Error("Failed to get signature message");const r=n.data.message,o=await this.signMessage(r),s=await zt.post(`${this.baseUrl}/api/auth/authenticate`,{authData:{id:this.accountId,signature:o,data:r,network:this.network},include:"apiKey"});if(!(null==(i=null==(t=s.data)?void 0:t.user)?void 0:i.sessionToken))throw new Error("Authentication failed");return{apiKey:s.data.apiKey}}async signMessage(e){const t=(new TextEncoder).encode(e),i=await this.privateKey.sign(t);return g.from(i).toString("hex")}}class ci{constructor(e,t){n(this,"baseUrl"),this.baseUrl=t??function(e){return"mainnet"===e?"https://mainnet-public.mirrornode.hedera.com":"https://testnet.mirrornode.hedera.com"}(e)}async requestAccount(e){return(await zt.get(`${this.baseUrl}/api/v1/accounts/${e}`)).data}}class hi{constructor(e){n(this,"accountId"),n(this,"signer"),n(this,"baseUrl"),n(this,"network"),n(this,"logger"),this.accountId=e.accountId,this.signer=e.signer,this.network=e.network||"mainnet",this.baseUrl=e.baseUrl||"https://kiloscribe.com",this.logger=e.logger}async authenticate(){var e,t,i;const n=await zt.get(`${this.baseUrl}/api/auth/request-signature`,{headers:{"x-session":this.accountId}});if(!(null==(e=n.data)?void 0:e.message))throw new Error("Failed to get signature message");const r=n.data.message,o=await this.signMessage(JSON.stringify(r)),s=await zt.post(`${this.baseUrl}/api/auth/authenticate`,{authData:{id:this.accountId,signature:o,data:r,network:this.network},include:"apiKey"});if(!(null==(i=null==(t=s.data)?void 0:t.user)?void 0:i.sessionToken))throw new Error("Authentication failed");return{apiKey:s.data.apiKey}}async signMessage(e){try{const t=(new TextEncoder).encode(e);this.logger.debug("signing message");const i=await this.signer.sign([t],{encoding:"utf-8"});return g.from(null==i?void 0:i[0].signature).toString("hex")}catch(t){throw this.logger.error("Failed to sign message",t),new Error("Failed to sign message")}}}function ui(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fi,li={};
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function pi(e){return new DataView(e.buffer,e.byteOffset)}fi||(fi=1,li.read=function(e,t,i,n,r){var o,s,a=8*r-n-1,c=(1<<a)-1,h=c>>1,u=-7,f=i?r-1:0,l=i?-1:1,p=e[t+f];for(f+=l,o=p&(1<<-u)-1,p>>=-u,u+=a;u>0;o=256*o+e[t+f],f+=l,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=256*s+e[t+f],f+=l,u-=8);if(0===o)o=1-h;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},li.write=function(e,t,i,n,r,o){var s,a,c,h=8*o-r-1,u=(1<<h)-1,f=u>>1,l=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(s++,c/=2),s+f>=u?(a=0,s=u):s+f>=1?(a=(t*c-1)*Math.pow(2,r),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,r),s=0));r>=8;e[i+p]=255&a,p+=d,a/=256,r-=8);for(s=s<<r|a,h+=r;h>0;e[i+p]=255&s,p+=d,s/=256,h-=8);e[i+p-d]|=128*m});const di={len:1,get:(e,t)=>pi(e).getUint8(t),put:(e,t,i)=>(pi(e).setUint8(t,i),t+1)},mi={len:2,get:(e,t)=>pi(e).getUint16(t,!0),put:(e,t,i)=>(pi(e).setUint16(t,i,!0),t+2)},gi={len:2,get:(e,t)=>pi(e).getUint16(t),put:(e,t,i)=>(pi(e).setUint16(t,i),t+2)},yi={len:4,get:(e,t)=>pi(e).getUint32(t,!0),put:(e,t,i)=>(pi(e).setUint32(t,i,!0),t+4)},wi={len:4,get:(e,t)=>pi(e).getUint32(t),put:(e,t,i)=>(pi(e).setUint32(t,i),t+4)},bi={len:4,get:(e,t)=>pi(e).getInt32(t),put:(e,t,i)=>(pi(e).setInt32(t,i),t+4)},vi={len:8,get:(e,t)=>pi(e).getBigUint64(t,!0),put:(e,t,i)=>(pi(e).setBigUint64(t,i,!0),t+8)};class xi{constructor(e,t){if(this.len=e,t&&"windows-1252"===t.toLowerCase())this.decoder=xi.decodeWindows1252;else{const e=new TextDecoder(t);this.decoder=t=>e.decode(t)}}get(e,t=0){const i=e.subarray(t,t+this.len);return this.decoder(i)}static decodeWindows1252(e){let t="";for(let i=0;i<e.length;i++){const n=e[i];t+=n<128||n>=160?String.fromCharCode(n):xi.win1252Map[n-128]}return t}}xi.win1252Map="€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ";class ki extends Error{constructor(){super("End-Of-Stream"),this.name="EndOfStreamError"}}class Ei extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}class Si{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){const i=await this.read(e,t);return this.peekQueue.push(e.subarray(0,i)),i}async read(e,t=!1){if(0===e.length)return 0;let i=this.readFromPeekBuffer(e);if(this.endOfStream||(i+=await this.readRemainderFromStream(e.subarray(i),t)),0===i&&!t)throw new ki;return i}readFromPeekBuffer(e){let t=e.length,i=0;for(;this.peekQueue.length>0&&t>0;){const n=this.peekQueue.pop();if(!n)throw new Error("peekData should be defined");const r=Math.min(n.length,t);e.set(n.subarray(0,r),i),i+=r,t-=r,r<n.length&&this.peekQueue.push(n.subarray(r))}return i}async readRemainderFromStream(e,t){let i=0;for(;i<e.length&&!this.endOfStream;){if(this.interrupted)throw new Ei;const n=await this.readFromStream(e.subarray(i),t);if(0===n)break;i+=n}if(!t&&i<e.length)throw new ki;return i}}class _i extends Si{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}class Ti extends _i{async readFromStream(e,t){if(0===e.length)return 0;const i=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return i.done&&(this.endOfStream=i.done),i.value?(e.set(i.value),i.value.length):0}}class Ci extends Si{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){const i=Math.min(t.length,e.length);return e.set(t.subarray(0,i)),i<t.length?this.buffer=t.subarray(i):this.buffer=null,i}async readFromStream(e,t){if(0===e.length)return 0;let i=0;for(this.buffer&&(i+=this.writeChunk(e,this.buffer));i<e.length&&!this.endOfStream;){const t=await this.reader.read();if(t.done){this.endOfStream=!0;break}t.value&&(i+=this.writeChunk(e.subarray(i),t.value))}if(!t&&0===i&&this.endOfStream)throw new ki;return i}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}class Oi{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=null==e?void 0:e.onClose,(null==e?void 0:e.abortSignal)&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,t=this.position){const i=new Uint8Array(e.len);if(await this.readBuffer(i,{position:t})<e.len)throw new ki;return e.get(i,0)}async peekToken(e,t=this.position){const i=new Uint8Array(e.len);if(await this.peekBuffer(i,{position:t})<e.len)throw new ki;return e.get(i,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new ki;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new ki;return e.get(this.numBuffer,0)}async ignore(e){if(void 0!==this.fileInfo.size){const t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){var e;await this.abort(),await(null==(e=this.onClose)?void 0:e.call(this))}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&void 0!==t.position&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}}class Ai extends Oi{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=(null==t?void 0:t.fileInfo)??{}}async readBuffer(e,t){const i=this.normalizeOptions(e,t),n=i.position-this.position;if(n>0)return await this.ignore(n),this.readBuffer(e,t);if(n<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(0===i.length)return 0;const r=await this.streamReader.read(e.subarray(0,i.length),i.mayBeLess);if(this.position+=r,(!t||!t.mayBeLess)&&r<i.length)throw new ki;return r}async peekBuffer(e,t){const i=this.normalizeOptions(e,t);let n=0;if(i.position){const t=i.position-this.position;if(t>0){const r=new Uint8Array(i.length+t);return n=await this.peekBuffer(r,{mayBeLess:i.mayBeLess}),e.set(r.subarray(t)),n-t}if(t<0)throw new Error("Cannot peek from a negative offset in a stream")}if(i.length>0){try{n=await this.streamReader.peek(e.subarray(0,i.length),i.mayBeLess)}catch(r){if((null==t?void 0:t.mayBeLess)&&r instanceof ki)return 0;throw r}if(!i.mayBeLess&&n<i.length)throw new ki}return n}async ignore(e){const t=Math.min(256e3,e),i=new Uint8Array(t);let n=0;for(;n<e;){const r=e-n,o=await this.readBuffer(i,{length:Math.min(t,r)});if(o<0)return o;n+=o}return n}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}class Bi extends Oi{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...(null==t?void 0:t.fileInfo)??{},size:e.length}}async readBuffer(e,t){(null==t?void 0:t.position)&&(this.position=t.position);const i=await this.peekBuffer(e,t);return this.position+=i,i}async peekBuffer(e,t){const i=this.normalizeOptions(e,t),n=Math.min(this.uint8Array.length-i.position,i.length);if(!i.mayBeLess&&n<i.length)throw new ki;return e.set(this.uint8Array.subarray(i.position,i.position+n)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}function Ri(e,t){const i=function(e){try{const t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new Ci(t):new Ti(t)}catch(t){if(t instanceof TypeError)return new Ci(e.getReader());throw t}}(e),n=t??{},r=n.onClose;return n.onClose=async()=>{if(await i.close(),r)return r()},new Ai(i,n)}var Ii=Uint8Array,Ui=Uint16Array,Fi=Int32Array,Li=new Ii([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ji=new Ii([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ni=new Ii([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mi=function(e,t){for(var i=new Ui(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var r=new Fi(i[30]);for(n=1;n<30;++n)for(var o=i[n];o<i[n+1];++o)r[o]=o-i[n]<<5|n;return{b:i,r:r}},Pi=Mi(Li,2),zi=Pi.b,Di=Pi.r;zi[28]=258,Di[258]=28;for(var qi=Mi(ji,0).b,$i=new Ui(32768),Wi=0;Wi<32768;++Wi){var Ki=(43690&Wi)>>1|(21845&Wi)<<1;Ki=(61680&(Ki=(52428&Ki)>>2|(13107&Ki)<<2))>>4|(3855&Ki)<<4,$i[Wi]=((65280&Ki)>>8|(255&Ki)<<8)>>1}var Vi=function(e,t,i){for(var n=e.length,r=0,o=new Ui(t);r<n;++r)e[r]&&++o[e[r]-1];var s,a=new Ui(t);for(r=1;r<t;++r)a[r]=a[r-1]+o[r-1]<<1;if(i){s=new Ui(1<<t);var c=15-t;for(r=0;r<n;++r)if(e[r])for(var h=r<<4|e[r],u=t-e[r],f=a[e[r]-1]++<<u,l=f|(1<<u)-1;f<=l;++f)s[$i[f]>>c]=h}else for(s=new Ui(n),r=0;r<n;++r)e[r]&&(s[r]=$i[a[e[r]-1]++]>>15-e[r]);return s},Hi=new Ii(288);for(Wi=0;Wi<144;++Wi)Hi[Wi]=8;for(Wi=144;Wi<256;++Wi)Hi[Wi]=9;for(Wi=256;Wi<280;++Wi)Hi[Wi]=7;for(Wi=280;Wi<288;++Wi)Hi[Wi]=8;var Ji=new Ii(32);for(Wi=0;Wi<32;++Wi)Ji[Wi]=5;var Yi=Vi(Hi,9,1),Xi=Vi(Ji,5,1),Gi=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},Qi=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},Zi=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},en=function(e){return(e+7)/8|0},tn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],nn=function(e,t,i){var n=new Error(t||tn[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,nn),!i)throw n;return n},rn=function(e,t,i,n){var r=e.length;if(!r||t.f&&!t.l)return i||new Ii(0);var o=!i,s=o||2!=t.i,a=t.i;o&&(i=new Ii(3*r));var c=function(e){var t=i.length;if(e>t){var n=new Ii(Math.max(2*t,e));n.set(i),i=n}},h=t.f||0,u=t.p||0,f=t.b||0,l=t.l,p=t.d,d=t.m,m=t.n,g=8*r;do{if(!l){h=Qi(e,u,1);var y=Qi(e,u+1,3);if(u+=3,!y){var w=e[(A=en(u)+4)-4]|e[A-3]<<8,b=A+w;if(b>r){a&&nn(0);break}s&&c(f+w),i.set(e.subarray(A,b),f),t.b=f+=w,t.p=u=8*b,t.f=h;continue}if(1==y)l=Yi,p=Xi,d=9,m=5;else if(2==y){var v=Qi(e,u,31)+257,x=Qi(e,u+10,15)+4,k=v+Qi(e,u+5,31)+1;u+=14;for(var E=new Ii(k),S=new Ii(19),_=0;_<x;++_)S[Ni[_]]=Qi(e,u+3*_,7);u+=3*x;var T=Gi(S),C=(1<<T)-1,O=Vi(S,T,1);for(_=0;_<k;){var A,B=O[Qi(e,u,C)];if(u+=15&B,(A=B>>4)<16)E[_++]=A;else{var R=0,I=0;for(16==A?(I=3+Qi(e,u,3),u+=2,R=E[_-1]):17==A?(I=3+Qi(e,u,7),u+=3):18==A&&(I=11+Qi(e,u,127),u+=7);I--;)E[_++]=R}}var U=E.subarray(0,v),F=E.subarray(v);d=Gi(U),m=Gi(F),l=Vi(U,d,1),p=Vi(F,m,1)}else nn(1);if(u>g){a&&nn(0);break}}s&&c(f+131072);for(var L=(1<<d)-1,j=(1<<m)-1,N=u;;N=u){var M=(R=l[Zi(e,u)&L])>>4;if((u+=15&R)>g){a&&nn(0);break}if(R||nn(2),M<256)i[f++]=M;else{if(256==M){N=u,l=null;break}var P=M-254;if(M>264){var z=Li[_=M-257];P=Qi(e,u,(1<<z)-1)+zi[_],u+=z}var D=p[Zi(e,u)&j],q=D>>4;D||nn(3),u+=15&D;F=qi[q];if(q>3){z=ji[q];F+=Zi(e,u)&(1<<z)-1,u+=z}if(u>g){a&&nn(0);break}s&&c(f+131072);var $=f+P;if(f<F){var W=0-F,K=Math.min(F,$);for(W+f<0&&nn(3);f<K;++f)i[f]=n[W+f]}for(;f<$;++f)i[f]=i[f-F]}}t.l=l,t.p=N,t.b=f,t.f=h,l&&(h=1,t.m=d,t.d=p,t.n=m)}while(!h);return f!=i.length&&o?function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new Ii(e.subarray(t,i))}(i,0,f):i.subarray(0,f)},on=new Ii(0);function sn(e,t){var i,n,r=function(e){31==e[0]&&139==e[1]&&8==e[2]||nn(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[i++]);return i+(2&t)}(e);return r+8>e.length&&nn(6,"invalid gzip data"),rn(e.subarray(r,-8),{i:2},new Ii((n=(i=e).length,(i[n-4]|i[n-3]<<8|i[n-2]<<16|i[n-1]<<24)>>>0)),t)}function an(e,t){return rn(e.subarray(((8!=(15&(i=e)[0])||i[0]>>4>7||(i[0]<<8|i[1])%31)&&nn(6,"invalid zlib data"),1==(i[1]>>5&1)&&nn(6,"invalid zlib data: "+(32&i[1]?"need":"unexpected")+" dictionary"),2+(i[1]>>3&4)),-4),{i:2},t,t);var i}function cn(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?sn(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?function(e,t){return rn(e,{i:2},t,t)}(e,t):an(e,t)}var hn="undefined"!=typeof TextDecoder&&new TextDecoder;try{hn.decode(on,{stream:!0})}catch(fo){}var un,fn,ln,pn,dn,mn={exports:{}};function gn(){if(fn)return un;fn=1;var e=1e3,t=60*e,i=60*t,n=24*i,r=7*n,o=365.25*n;function s(e,t,i,n){var r=t>=1.5*i;return Math.round(e/i)+" "+n+(r?"s":"")}return un=function(a,c){c=c||{};var h=typeof a;if("string"===h&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*r;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===h&&isFinite(a))return c.long?function(r){var o=Math.abs(r);if(o>=n)return s(r,o,n,"day");if(o>=i)return s(r,o,i,"hour");if(o>=t)return s(r,o,t,"minute");if(o>=e)return s(r,o,e,"second");return r+" ms"}(a):function(r){var o=Math.abs(r);if(o>=n)return Math.round(r/n)+"d";if(o>=i)return Math.round(r/i)+"h";if(o>=t)return Math.round(r/t)+"m";if(o>=e)return Math.round(r/e)+"s";return r+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}const yn=ui((dn||(dn=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const i="color: "+this.color;t.splice(1,0,i,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(r=n))}),t.splice(r,0,i)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(i){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(i){}return!e&&void 0!==F&&"env"in F&&(e=F.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(pn?ln:(pn=1,ln=function(e){function t(e){let n,r,o,s=null;function a(...e){if(!a.enabled)return;const i=a,r=Number(new Date),o=r-(n||r);i.diff=o,i.prev=n,i.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,r)=>{if("%%"===n)return"%";s++;const o=t.formatters[r];if("function"==typeof o){const t=e[s];n=o.call(i,t),e.splice(s,1),s--}return n}),t.formatArgs.call(i,e),(i.log||t.log).apply(i,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=i,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function i(e,i){const n=t(this.namespace+(void 0===i?":":i)+e);return n.log=this.log,n}function n(e,t){let i=0,n=0,r=-1,o=0;for(;i<e.length;)if(n<t.length&&(t[n]===e[i]||"*"===t[n]))"*"===t[n]?(r=n,o=i,n++):(i++,n++);else{if(-1===r)return!1;n=r+1,o++,i=o}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const i=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const n of i)"-"===n[0]?t.skips.push(n.slice(1)):t.names.push(n)},t.enabled=function(e){for(const i of t.skips)if(n(e,i))return!1;for(const i of t.names)if(n(e,i))return!0;return!1},t.humanize=gn(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(i=>{t[i]=e[i]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let i=0;for(let t=0;t<e.length;t++)i=(i<<5)-i+e.charCodeAt(t),i|=0;return t.colors[Math.abs(i)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}(mn,mn.exports)),mn.exports)),wn=67324752,bn=134695760,vn=33639248,xn=101010256,kn={get:e=>(mi.get(e,6),{signature:yi.get(e,0),compressedSize:yi.get(e,8),uncompressedSize:yi.get(e,12)}),len:16},En={get(e){const t=mi.get(e,6);return{signature:yi.get(e,0),minVersion:mi.get(e,4),dataDescriptor:!!(8&t),compressedMethod:mi.get(e,8),compressedSize:yi.get(e,18),uncompressedSize:yi.get(e,22),filenameLength:mi.get(e,26),extraFieldLength:mi.get(e,28),filename:null}},len:30},Sn={get:e=>({signature:yi.get(e,0),nrOfThisDisk:mi.get(e,4),nrOfThisDiskWithTheStart:mi.get(e,6),nrOfEntriesOnThisDisk:mi.get(e,8),nrOfEntriesOfSize:mi.get(e,10),sizeOfCd:yi.get(e,12),offsetOfStartOfCd:yi.get(e,16),zipFileCommentLength:mi.get(e,20)}),len:22},_n={get(e){const t=mi.get(e,8);return{signature:yi.get(e,0),minVersion:mi.get(e,6),dataDescriptor:!!(8&t),compressedMethod:mi.get(e,10),compressedSize:yi.get(e,20),uncompressedSize:yi.get(e,24),filenameLength:mi.get(e,28),extraFieldLength:mi.get(e,30),fileCommentLength:mi.get(e,32),relativeOffsetOfLocalHeader:yi.get(e,42),filename:null}},len:46};function Tn(e){const t=new Uint8Array(yi.len);return yi.put(t,0,e),t}const Cn=yn("tokenizer:inflate"),On=262144,An=Tn(bn),Bn=Tn(xn);class Rn{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(On)}async isZip(){return await this.peekSignature()===wn}peekSignature(){return this.tokenizer.peekToken(yi)}async findEndOfCentralDirectoryLocator(){const e=this.tokenizer,t=Math.min(16384,e.fileInfo.size),i=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(i,{position:e.fileInfo.size-t});for(let n=i.length-4;n>=0;n--)if(i[n]===Bn[0]&&i[n+1]===Bn[1]&&i[n+2]===Bn[2]&&i[n+3]===Bn[3])return e.fileInfo.size-t+n;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess())return void Cn("Cannot reading central-directory without random-read support");Cn("Reading central-directory...");const e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){Cn("Central-directory 32-bit signature found");const i=await this.tokenizer.readToken(Sn,t),n=[];this.tokenizer.setPosition(i.offsetOfStartOfCd);for(let e=0;e<i.nrOfEntriesOfSize;++e){const t=await this.tokenizer.readToken(_n);if(t.signature!==vn)throw new Error("Expected Central-File-Header signature");t.filename=await this.tokenizer.readToken(new xi(t.filenameLength,"utf-8")),await this.tokenizer.ignore(t.extraFieldLength),await this.tokenizer.ignore(t.fileCommentLength),n.push(t),Cn(`Add central-directory file-entry: n=${e+1}/${n.length}: filename=${n[e].filename}`)}return this.tokenizer.setPosition(e),n}this.tokenizer.setPosition(e)}async unzip(e){const t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let i=!1;do{const t=await this.readLocalFileHeader();if(!t)break;const n=e(t);let r;if(i=!!n.stop,await this.tokenizer.ignore(t.extraFieldLength),t.dataDescriptor&&0===t.compressedSize){const e=[];let i=On;Cn("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let r=-1;for(;r<0&&i===On;){i=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),r=In(this.syncBuffer.subarray(0,i),An);const t=r>=0?r:i;if(n.handler){const i=new Uint8Array(t);await this.tokenizer.readBuffer(i),e.push(i)}else await this.tokenizer.ignore(t)}Cn(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),n.handler&&await this.inflate(t,Un(e),n.handler)}else n.handler?(Cn(`Reading compressed-file-data: ${t.compressedSize} bytes`),r=new Uint8Array(t.compressedSize),await this.tokenizer.readBuffer(r),await this.inflate(t,r,n.handler)):(Cn(`Ignoring compressed-file-data: ${t.compressedSize} bytes`),await this.tokenizer.ignore(t.compressedSize));if(Cn(`Reading data-descriptor at pos=${this.tokenizer.position}`),t.dataDescriptor){if(134695760!==(await this.tokenizer.readToken(kn)).signature)throw new Error("Expected data-descriptor-signature at position "+(this.tokenizer.position-kn.len))}}while(!i)}async iterateOverCentralDirectory(e,t){for(const i of e){const e=t(i);if(e.handler){this.tokenizer.setPosition(i.relativeOffsetOfLocalHeader);const t=await this.readLocalFileHeader();if(t){await this.tokenizer.ignore(t.extraFieldLength);const n=new Uint8Array(i.compressedSize);await this.tokenizer.readBuffer(n),await this.inflate(t,n,e.handler)}}if(e.stop)break}}inflate(e,t,i){if(0===e.compressedMethod)return i(t);Cn(`Decompress filename=${e.filename}, compressed-size=${t.length}`);return i(cn(t))}async readLocalFileHeader(){const e=await this.tokenizer.peekToken(yi);if(e===wn){const e=await this.tokenizer.readToken(En);return e.filename=await this.tokenizer.readToken(new xi(e.filenameLength,"utf-8")),e}if(e===vn)return!1;if(3759263696===e)throw new Error("Encrypted ZIP");throw new Error("Unexpected signature")}}function In(e,t){const i=e.length,n=t.length;if(n>i)return-1;for(let r=0;r<=i-n;r++){let i=!0;for(let o=0;o<n;o++)if(e[r+o]!==t[o]){i=!1;break}if(i)return r}return-1}function Un(e){const t=e.reduce((e,t)=>e+t.length,0),i=new Uint8Array(t);let n=0;for(const r of e)i.set(r,n),n+=r.length;return i}function Fn(e){const{byteLength:t}=e;return 6===t?e.getUint16(0)*2**32+e.getUint32(2):5===t?e.getUint8(0)*2**32+e.getUint32(1):4===t?e.getUint32(0):3===t?65536*e.getUint8(0)+e.getUint16(1):2===t?e.getUint16(0):1===t?e.getUint8(0):void 0}new globalThis.TextDecoder("utf8"),new globalThis.TextEncoder,Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));const Ln={get:(e,t)=>127&e[t+3]|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},jn=4100;function Nn(e){switch(e=e.toLowerCase()){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:e};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:e};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:e};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:e};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:e};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function Mn(e,t,i){i={offset:0,...i};for(const[n,r]of t.entries())if(i.mask){if(r!==(i.mask[n]&e[n+i.offset]))return!1}else if(r!==e[n+i.offset])return!1;return!0}class Pn{constructor(e){n(this,"detectConfident",async e=>{if(this.buffer=new Uint8Array(jn),void 0===e.fileInfo.size&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:12,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);const t=await e.readToken(Ln);return e.position+t>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(t),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((67===this.buffer[0]||70===this.buffer[0])&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let i;return await new Rn(e).unzip(e=>{switch(e.filename){case"META-INF/mozilla.rsa":return i={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return i={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(e){const t=new TextDecoder("utf-8").decode(e).trim();i=Nn(t)},stop:!0};case"[Content_Types].xml":return{async handler(e){let t=new TextDecoder("utf-8").decode(e);const n=t.indexOf('.main+xml"');if(-1===n){const e="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";t.includes(`ContentType="${e}"`)&&(i=Nn(e))}else{t=t.slice(0,Math.max(0,n));const e=t.lastIndexOf('"'),r=t.slice(Math.max(0,e+1));i=Nn(r)}},stop:!0};default:return/classes\d*\.dex/.test(e.filename)?(i={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}),i??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);const n=new Uint8Array(8);return await e.readBuffer(n),Mn(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Mn(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Mn(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Mn(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Mn(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Mn(n,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(3===this.buffer[2]||5===this.buffer[2]||7===this.buffer[2])&&(4===this.buffer[3]||6===this.buffer[3]||8===this.buffer[3]))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){const o=await this.readTiffHeader(!0);if(o)return o}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function s(){const t=await e.peekNumber(di);let i=128,n=0;for(;0===(t&i)&&0!==i;)++n,i>>=1;const r=new Uint8Array(n+1);return await e.readBuffer(r),r}async function a(){const e=await s(),t=await s();t[0]^=128>>t.length-1;const i=Math.min(6,t.length),n=new DataView(e.buffer),r=new DataView(t.buffer,t.length-i,i);return{id:Fn(n),len:Fn(r)}}async function c(t){for(;t>0;){const i=await a();if(17026===i.id){return(await e.readToken(new xi(i.len))).replaceAll(/\00.*$/g,"")}await e.ignore(i.len),--t}}const h=await a();switch(await c(h.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(0===this.buffer[6]||1===this.buffer[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const u=new xi(4,"latin1").get(this.buffer,2);if(u.match("^d*")&&u>=1e3&&u<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>")){await e.ignore(8);return"debian-binary"===await e.readToken(new xi(13,"ascii"))?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"}}if(this.checkString("WEBVTT")&&["\n","\r","\t"," ","\0"].some(e=>this.checkString(e,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){async function f(){return{length:await e.readToken(bi),type:await e.readToken(new xi(4,"latin1"))}}await e.ignore(8);do{const l=await f();if(l.length<0)return;switch(l.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(l.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&96&this.buffer[8]){const p=new xi(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(p){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return p.startsWith("3g")?p.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function d(){const t=new Uint8Array(16);return await e.readBuffer(t),{id:t,size:Number(await e.readToken(vi))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){const m=await d();let g=m.size-24;if(Mn(m.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const y=new Uint8Array(16);if(g-=await e.readBuffer(y),Mn(y,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(Mn(y,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(g)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10])){await e.ignore(20);switch(await e.readToken(new xi(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const w=new DataView(this.buffer.buffer).getUint32(12,!0);if(w>12&&this.buffer.length>=w+16)try{const b=(new TextDecoder).decode(this.buffer.subarray(16,w+16));if(JSON.parse(b).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}return this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2])?{ext:"mxf",mime:"application/mxf"}:this.checkString("SCRM",{offset:44})?{ext:"s3m",mime:"audio/x-s3m"}:this.check([71])&&this.check([71],{offset:188})||this.check([71],{offset:4})&&this.check([71],{offset:196})?{ext:"mts",mime:"video/mp2t"}:this.check([66,79,79,75,77,79,66,73],{offset:60})?{ext:"mobi",mime:"application/x-mobipocket-ebook"}:this.check([68,73,67,77],{offset:128})?{ext:"dcm",mime:"application/dicom"}:this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70])?{ext:"lnk",mime:"application/x.ms.shortcut"}:this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0])?{ext:"alias",mime:"application/x.apple.alias"}:this.checkString("Kaydara FBX Binary  \0")?{ext:"fbx",mime:"application/x.autodesk.fbx"}:this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8}))?{ext:"eot",mime:"application/vnd.ms-fontobject"}:this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29])?{ext:"indd",mime:"application/x-indesign"}:(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&function(e,t=0){const i=Number.parseInt(new xi(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(i))return!1;let n=256;for(let r=t;r<t+148;r++)n+=e[r];for(let r=t+156;r<t+512;r++)n+=e[r];return i===n}(this.buffer)?{ext:"tar",mime:"application/x-tar"}:this.check([255,254])?this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0:this.checkString("-----BEGIN PGP MESSAGE-----")?{ext:"pgp",mime:"application/pgp-encrypted"}:void 0)}),n(this,"detectImprecise",async e=>{if(this.buffer=new Uint8Array(jn),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let t=0;t<=this.options.mpegOffsetTolerance;++t){const e=this.scanMpeg(t);if(e)return e}}),this.options={mpegOffsetTolerance:0,...e},this.detectors=[...(null==e?void 0:e.customDetectors)??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:null==e?void 0:e.signal}}async fromTokenizer(e){const t=e.position;for(const i of this.detectors){const n=await i.detect(e);if(n)return n;if(t!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);const t=e instanceof Uint8Array?e:new Uint8Array(e);var i,n;if((null==t?void 0:t.length)>1)return this.fromTokenizer((i=t,n=this.tokenizerOptions,new Bi(i,n)))}async fromBlob(e){return this.fromStream(e.stream())}async fromStream(e){const t=await Ri(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(e,t){const{sampleSize:i=jn}=t;let n,r;const o=e.getReader({mode:"byob"});try{const{value:e,done:t}=await o.read(new Uint8Array(i));if(r=e,!t&&e)try{n=await this.fromBuffer(e.subarray(0,i))}catch(c){if(!(c instanceof ki))throw c;n=void 0}r=e}finally{o.releaseLock()}const s=new TransformStream({async start(e){e.enqueue(r)},transform(e,t){t.enqueue(e)}}),a=e.pipeThrough(s);return a.fileType=n,a}check(e,t){return Mn(this.buffer,e,t)}checkString(e,t){return this.check((i=e,[...i].map(e=>e.charCodeAt(0))),t);var i}async readTiffTag(e){const t=await this.tokenizer.readToken(e?gi:mi);switch(this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(e){const t=await this.tokenizer.readToken(e?gi:mi);for(let i=0;i<t;++i){const t=await this.readTiffTag(e);if(t)return t}}async readTiffHeader(e){const t=(e?gi:mi).get(this.buffer,2),i=(e?wi:yi).get(this.buffer,4);if(42===t){if(i>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8){const t=(e?gi:mi).get(this.buffer,8),i=(e?gi:mi).get(this.buffer,10);if(28===t&&254===i||31===t&&11===i)return{ext:"nef",mime:"image/x-nikon-nef"}}}await this.tokenizer.ignore(i);return await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(43===t)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]}),{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set(["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","rm","ppsm","ppsx"]),new Set(["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia"]);const zn=Object.create(null);zn.open="0",zn.close="1",zn.ping="2",zn.pong="3",zn.message="4",zn.upgrade="5",zn.noop="6";const Dn=Object.create(null);Object.keys(zn).forEach(e=>{Dn[zn[e]]=e});const qn={type:"error",data:"parser error"},$n="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),Wn="function"==typeof ArrayBuffer,Kn=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Vn=({type:e,data:t},i,n)=>$n&&t instanceof Blob?i?n(t):Hn(t,n):Wn&&(t instanceof ArrayBuffer||Kn(t))?i?n(t):Hn(new Blob([t]),n):n(zn[e]+(t||"")),Hn=(e,t)=>{const i=new FileReader;return i.onload=function(){const e=i.result.split(",")[1];t("b"+(e||""))},i.readAsDataURL(e)};function Jn(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Yn;const Xn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gn="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let po=0;po<64;po++)Gn[Xn.charCodeAt(po)]=po;const Qn="function"==typeof ArrayBuffer,Zn=(e,t)=>{if("string"!=typeof e)return{type:"message",data:tr(e,t)};const i=e.charAt(0);if("b"===i)return{type:"message",data:er(e.substring(1),t)};return Dn[i]?e.length>1?{type:Dn[i],data:e.substring(1)}:{type:Dn[i]}:qn},er=(e,t)=>{if(Qn){const i=(e=>{let t,i,n,r,o,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);const h=new ArrayBuffer(s),u=new Uint8Array(h);for(t=0;t<a;t+=4)i=Gn[e.charCodeAt(t)],n=Gn[e.charCodeAt(t+1)],r=Gn[e.charCodeAt(t+2)],o=Gn[e.charCodeAt(t+3)],u[c++]=i<<2|n>>4,u[c++]=(15&n)<<4|r>>2,u[c++]=(3&r)<<6|63&o;return h})(e);return tr(i,t)}return{base64:!0,data:e}},tr=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,ir=String.fromCharCode(30);function nr(){return new TransformStream({transform(e,t){!function(e,t){$n&&e.data instanceof Blob?e.data.arrayBuffer().then(Jn).then(t):Wn&&(e.data instanceof ArrayBuffer||Kn(e.data))?t(Jn(e.data)):Vn(e,!1,e=>{Yn||(Yn=new TextEncoder),t(Yn.encode(e))})}(e,i=>{const n=i.length;let r;if(n<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,n);else if(n<65536){r=new Uint8Array(3);const e=new DataView(r.buffer);e.setUint8(0,126),e.setUint16(1,n)}else{r=new Uint8Array(9);const e=new DataView(r.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(n))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(i)})}})}let rr;function or(e){return e.reduce((e,t)=>e+t.length,0)}function sr(e,t){if(e[0].length===t)return e.shift();const i=new Uint8Array(t);let n=0;for(let r=0;r<t;r++)i[r]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),i}function ar(e){if(e)return function(e){for(var t in ar.prototype)e[t]=ar.prototype[t];return e}(e)}ar.prototype.on=ar.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},ar.prototype.once=function(e,t){function i(){this.off(e,i),t.apply(this,arguments)}return i.fn=t,this.on(e,i),this},ar.prototype.off=ar.prototype.removeListener=ar.prototype.removeAllListeners=ar.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var r=0;r<n.length;r++)if((i=n[r])===t||i.fn===t){n.splice(r,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},ar.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),i=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(i){n=0;for(var r=(i=i.slice(0)).length;n<r;++n)i[n].apply(this,t)}return this},ar.prototype.emitReserved=ar.prototype.emit,ar.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},ar.prototype.hasListeners=function(e){return!!this.listeners(e).length};const cr="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),hr="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function ur(e,...t){return t.reduce((t,i)=>(e.hasOwnProperty(i)&&(t[i]=e[i]),t),{})}const fr=hr.setTimeout,lr=hr.clearTimeout;function pr(e,t){t.useNativeTimers?(e.setTimeoutFn=fr.bind(hr),e.clearTimeoutFn=lr.bind(hr)):(e.setTimeoutFn=hr.setTimeout.bind(hr),e.clearTimeoutFn=hr.clearTimeout.bind(hr))}function dr(e){return"string"==typeof e?function(e){let t=0,i=0;for(let n=0,r=e.length;n<r;n++)t=e.charCodeAt(n),t<128?i+=1:t<2048?i+=2:t<55296||t>=57344?i+=3:(n++,i+=4);return i}(e):Math.ceil(1.33*(e.byteLength||e.size))}function mr(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class gr extends Error{constructor(e,t,i){super(e),this.description=t,this.context=i,this.type="TransportError"}}class yr extends ar{constructor(e){super(),this.writable=!1,pr(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,i){return super.emitReserved("error",new gr(e,t,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=Zn(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let i in e)e.hasOwnProperty(i)&&(t.length&&(t+="&"),t+=encodeURIComponent(i)+"="+encodeURIComponent(e[i]));return t}(e);return t.length?"?"+t:""}}class wr extends yr{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once("pollComplete",function(){--e||t()})),this.writable||(e++,this.once("drain",function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const i=e.split(ir),n=[];for(let r=0;r<i.length;r++){const e=Zn(i[r],t);if(n.push(e),"error"===e.type)break}return n})(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const i=e.length,n=new Array(i);let r=0;e.forEach((e,o)=>{Vn(e,!1,e=>{n[o]=e,++r===i&&t(n.join(ir))})})})(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=mr()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}let br=!1;try{br="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(lo){}const vr=br;function xr(){}class kr extends wr{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let i=location.port;i||(i=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||i!==e.port}}doWrite(e,t){const i=this.request({method:"POST",data:e});i.on("success",t),i.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}let Er=class e extends ar{constructor(e,t,i){super(),this.createRequest=e,pr(this,i),this._opts=i,this._method=i.method||"GET",this._uri=t,this._data=void 0!==i.data?i.data:null,this._create()}_create(){var t;const i=ur(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(i);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(fo){}if("POST"===this._method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(fo){}try{n.setRequestHeader("Accept","*/*")}catch(fo){}null===(t=this._opts.cookieJar)||void 0===t||t.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(n.getResponseHeader("set-cookie"))),4===n.readyState&&(200===n.status||1223===n.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof n.status?n.status:0)},0))},n.send(this._data)}catch(fo){return void this.setTimeoutFn(()=>{this._onError(fo)},0)}"undefined"!=typeof document&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(t){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=xr,t)try{this._xhr.abort()}catch(fo){}"undefined"!=typeof document&&delete e.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};if(Er.requestsCount=0,Er.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Sr);else if("function"==typeof addEventListener){addEventListener("onpagehide"in hr?"pagehide":"unload",Sr,!1)}function Sr(){for(let e in Er.requests)Er.requests.hasOwnProperty(e)&&Er.requests[e].abort()}const _r=function(){const e=Tr({xdomain:!1});return e&&null!==e.responseType}();function Tr(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||vr))return new XMLHttpRequest}catch(fo){}if(!t)try{return new(hr[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(fo){}}const Cr="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class Or extends yr{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,i=Cr?{}:ur(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,i)}catch(lo){return this.emitReserved("error",lo)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const i=e[t],n=t===e.length-1;Vn(i,this.supportsBinary,e=>{try{this.doWrite(i,e)}catch(fo){}n&&cr(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=mr()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const Ar=hr.WebSocket||hr.MozWebSocket;const Br={websocket:class extends Or{createSocket(e,t,i){return Cr?new Ar(e,t,i):t?new Ar(e,t):new Ar(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends yr{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(lo){return this.emitReserved("error",lo)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=function(e,t){rr||(rr=new TextDecoder);const i=[];let n=0,r=-1,o=!1;return new TransformStream({transform(s,a){for(i.push(s);;){if(0===n){if(or(i)<1)break;const e=sr(i,1);o=!(128&~e[0]),r=127&e[0],n=r<126?3:126===r?1:2}else if(1===n){if(or(i)<2)break;const e=sr(i,2);r=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),n=3}else if(2===n){if(or(i)<8)break;const e=sr(i,8),t=new DataView(e.buffer,e.byteOffset,e.length),o=t.getUint32(0);if(o>Math.pow(2,21)-1){a.enqueue(qn);break}r=o*Math.pow(2,32)+t.getUint32(4),n=3}else{if(or(i)<r)break;const e=sr(i,r);a.enqueue(Zn(o?e:rr.decode(e),t)),n=0}if(0===r||r>e){a.enqueue(qn);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(t).getReader(),n=nr();n.readable.pipeTo(e.writable),this._writer=n.writable.getWriter();const r=()=>{i.read().then(({done:e,value:t})=>{e||(this.onPacket(t),r())}).catch(e=>{})};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const i=e[t],n=t===e.length-1;this._writer.write(i).then(()=>{n&&cr(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}},polling:class extends kr{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=_r&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Er(Tr,this.uri(),e)}}},Rr=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ir=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ur(e){if(e.length>8e3)throw"URI too long";const t=e,i=e.indexOf("["),n=e.indexOf("]");-1!=i&&-1!=n&&(e=e.substring(0,i)+e.substring(i,n).replace(/:/g,";")+e.substring(n,e.length));let r=Rr.exec(e||""),o={},s=14;for(;s--;)o[Ir[s]]=r[s]||"";return-1!=i&&-1!=n&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(e,t){const i=/\/{2,9}/g,n=t.replace(i,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1);"/"==t.slice(-1)&&n.splice(n.length-1,1);return n}(0,o.path),o.queryKey=function(e,t){const i={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,n){t&&(i[t]=n)}),i}(0,o.query),o}const Fr="function"==typeof addEventListener&&"function"==typeof removeEventListener,Lr=[];Fr&&addEventListener("offline",()=>{Lr.forEach(e=>e())},!1);class jr extends ar{constructor(e,t){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const i=Ur(e);t.hostname=i.host,t.secure="https"===i.protocol||"wss"===i.protocol,t.port=i.port,i.query&&(t.query=i.query)}else t.host&&(t.hostname=Ur(t.host).host);pr(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},i=e.split("&");for(let n=0,r=i.length;n<r;n++){let e=i[n].split("=");t[decodeURIComponent(e[0])]=decodeURIComponent(e[1])}return t}(this.opts.query)),Fr&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Lr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const i=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](i)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const e=this.opts.rememberUpgrade&&jr.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",jr.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const i=this.writeBuffer[t].data;if(i&&(e+=dr(i)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,cr(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,i){return this._sendPacket("message",e,t,i),this}send(e,t,i){return this._sendPacket("message",e,t,i),this}_sendPacket(e,t,i,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof i&&(n=i,i=null),"closing"===this.readyState||"closed"===this.readyState)return;(i=i||{}).compress=!1!==i.compress;const r={type:e,data:t,options:i};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),n&&this.once("flush",n),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},i=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}_onError(e){if(jr.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Fr&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=Lr.indexOf(this._offlineEventListener);-1!==e&&Lr.splice(e,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}jr.protocol=4;class Nr extends jr{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),i=!1;jr.priorWebsocketSuccess=!1;const n=()=>{i||(t.send([{type:"ping",data:"probe"}]),t.once("packet",e=>{if(!i)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;jr.priorWebsocketSuccess="websocket"===t.name,this.transport.pause(()=>{i||"closed"!==this.readyState&&(h(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}}))};function r(){i||(i=!0,h(),t.close(),t=null)}const o=e=>{const i=new Error("probe error: "+e);i.transport=t.name,r(),this.emitReserved("upgradeError",i)};function s(){o("transport closed")}function a(){o("socket closed")}function c(e){t&&e.name!==t.name&&r()}const h=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",s),this.off("close",a),this.off("upgrading",c)};t.once("open",n),t.once("error",o),t.once("close",s),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{i||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let i=0;i<e.length;i++)~this.transports.indexOf(e[i])&&t.push(e[i]);return t}}let Mr=class extends Nr{constructor(e,t={}){const i="object"==typeof e?e:t;(!i.transports||i.transports&&"string"==typeof i.transports[0])&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(e=>Br[e]).filter(e=>!!e)),super(e,i)}};const Pr="function"==typeof ArrayBuffer,zr=Object.prototype.toString,Dr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===zr.call(Blob),qr="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===zr.call(File);function $r(e){return Pr&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||Dr&&e instanceof Blob||qr&&e instanceof File}function Wr(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,i=e.length;t<i;t++)if(Wr(e[t]))return!0;return!1}if($r(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return Wr(e.toJSON(),!0);for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&Wr(e[i]))return!0;return!1}function Kr(e){const t=[],i=e.data,n=e;return n.data=Vr(i,t),n.attachments=t.length,{packet:n,buffers:t}}function Vr(e,t){if(!e)return e;if($r(e)){const i={_placeholder:!0,num:t.length};return t.push(e),i}if(Array.isArray(e)){const i=new Array(e.length);for(let n=0;n<e.length;n++)i[n]=Vr(e[n],t);return i}if("object"==typeof e&&!(e instanceof Date)){const i={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=Vr(e[n],t));return i}return e}function Hr(e,t){return e.data=Jr(e.data,t),delete e.attachments,e}function Jr(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let i=0;i<e.length;i++)e[i]=Jr(e[i],t);else if("object"==typeof e)for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(e[i]=Jr(e[i],t));return e}const Yr=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Xr,Gr;(Gr=Xr||(Xr={}))[Gr.CONNECT=0]="CONNECT",Gr[Gr.DISCONNECT=1]="DISCONNECT",Gr[Gr.EVENT=2]="EVENT",Gr[Gr.ACK=3]="ACK",Gr[Gr.CONNECT_ERROR=4]="CONNECT_ERROR",Gr[Gr.BINARY_EVENT=5]="BINARY_EVENT",Gr[Gr.BINARY_ACK=6]="BINARY_ACK";function Qr(e){return"[object Object]"===Object.prototype.toString.call(e)}class Zr extends ar{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const i=t.type===Xr.BINARY_EVENT;i||t.type===Xr.BINARY_ACK?(t.type=i?Xr.EVENT:Xr.ACK,this.reconstructor=new eo(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!$r(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const i={type:Number(e.charAt(0))};if(void 0===Xr[i.type])throw new Error("unknown packet type "+i.type);if(i.type===Xr.BINARY_EVENT||i.type===Xr.BINARY_ACK){const n=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const r=e.substring(n,t);if(r!=Number(r)||"-"!==e.charAt(t))throw new Error("Illegal attachments");i.attachments=Number(r)}if("/"===e.charAt(t+1)){const n=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}i.nsp=e.substring(n,t)}else i.nsp="/";const n=e.charAt(t+1);if(""!==n&&Number(n)==n){const n=t+1;for(;++t;){const i=e.charAt(t);if(null==i||Number(i)!=i){--t;break}if(t===e.length)break}i.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){const n=this.tryParse(e.substr(t));if(!Zr.isPayloadValid(i.type,n))throw new Error("invalid payload");i.data=n}return i}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(fo){return!1}}static isPayloadValid(e,t){switch(e){case Xr.CONNECT:return Qr(t);case Xr.DISCONNECT:return void 0===t;case Xr.CONNECT_ERROR:return"string"==typeof t||Qr(t);case Xr.EVENT:case Xr.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===Yr.indexOf(t[0]));case Xr.ACK:case Xr.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class eo{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Hr(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const to=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Zr,Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==Xr.EVENT&&e.type!==Xr.ACK||!Wr(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Xr.EVENT?Xr.BINARY_EVENT:Xr.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==Xr.BINARY_EVENT&&e.type!==Xr.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Kr(e),i=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(i),n}},get PacketType(){return Xr},protocol:5},Symbol.toStringTag,{value:"Module"}));function io(e,t,i){return e.on(t,i),function(){e.off(t,i)}}const no=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ro extends ar{constructor(e,t,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[io(e,"open",this.onopen.bind(this)),io(e,"packet",this.onpacket.bind(this)),io(e,"error",this.onerror.bind(this)),io(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var i,n,r;if(no.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:Xr.EVENT,data:t,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,i=t.pop();this._registerAckCallback(e,i),o.id=e}const s=null===(n=null===(i=this.io.engine)||void 0===i?void 0:i.transport)||void 0===n?void 0:n.writable,a=this.connected&&!(null===(r=this.io.engine)||void 0===r?void 0:r._hasPingExpired());return this.flags.volatile&&!s||(a?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var i;const n=null!==(i=this.flags.timeout)&&void 0!==i?i:this._opts.ackTimeout;if(void 0===n)return void(this.acks[e]=t);const r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))},n),o=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((i,n)=>{const r=(e,t)=>e?n(e):i(t);r.withError=!0,t.push(r),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...n)=>{if(i!==this._queue[0])return;return null!==e?i.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...n)),i.pending=!1,this._drainQueue()}),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Xr.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Xr.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Xr.EVENT:case Xr.BINARY_EVENT:this.onevent(e);break;case Xr.ACK:case Xr.BINARY_ACK:this.onack(e);break;case Xr.DISCONNECT:this.ondisconnect();break;case Xr.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const i of t)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let i=!1;return function(...n){i||(i=!0,t.packet({type:Xr.ACK,id:e,data:n}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Xr.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const i of t)i.apply(this,e.data)}}}function oo(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}oo.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),i=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+i:e-i}return 0|Math.min(e,this.max)},oo.prototype.reset=function(){this.attempts=0},oo.prototype.setMin=function(e){this.ms=e},oo.prototype.setMax=function(e){this.max=e},oo.prototype.setJitter=function(e){this.jitter=e};class so extends ar{constructor(e,t){var i;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,pr(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(i=t.randomizationFactor)&&void 0!==i?i:.5),this.backoff=new oo({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const n=t.parser||to;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Mr(this.uri,this.opts);const t=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const n=io(t,"open",function(){i.onopen(),e&&e()}),r=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},o=io(t,"error",r);if(!1!==this._timeout){const e=this._timeout,i=this.setTimeoutFn(()=>{n(),r(new Error("timeout")),t.close()},e);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}return this.subs.push(n),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(io(e,"ping",this.onping.bind(this)),io(e,"data",this.ondata.bind(this)),io(e,"error",this.onerror.bind(this)),io(e,"close",this.onclose.bind(this)),io(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(fo){this.onclose("parse error",fo)}}ondecoded(e){cr(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let i=this.nsps[e];return i?this._autoConnect&&!i.active&&i.connect():(i=new ro(this,e,t),this.nsps[e]=i),i}_destroy(e){const t=Object.keys(this.nsps);for(const i of t){if(this.nsps[i].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let i=0;i<t.length;i++)this.engine.write(t[i],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var i;this.cleanup(),null===(i=this.engine)||void 0===i||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()}))},t);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const ao={};function co(e,t){"object"==typeof e&&(t=e,e=void 0);const i=function(e,t="",i){let n=e;i=i||"undefined"!=typeof location&&location,null==e&&(e=i.protocol+"//"+i.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?i.protocol+e:i.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==i?i.protocol+"//"+e:"https://"+e),n=Ur(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const r=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port+t,n.href=n.protocol+"://"+r+(i&&i.port===n.port?"":":"+n.port),n}(e,(t=t||{}).path||"/socket.io"),n=i.source,r=i.id,o=i.path,s=ao[r]&&o in ao[r].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||s?a=new so(n,t):(ao[r]||(ao[r]=new so(n,t)),a=ao[r]),i.query&&!t.query&&(t.query=i.queryKey),a.socket(i.path,t)}Object.assign(co,{Manager:so,Socket:ro,io:co,connect:co});const ho=class e{constructor(e){if(n(this,"client"),n(this,"config"),n(this,"logger",ri.getInstance()),n(this,"socket",null),n(this,"socketConnected",!1),n(this,"connectionMode","auto"),n(this,"wsBaseUrl",null),this.config=e,!e.apiKey)throw new oi("API key is required");if(!e.network)throw new oi("Network is required");const t={"x-api-key":e.apiKey,"Content-Type":"application/json"};this.client=zt.create({baseURL:"https://v2-api.tier.bot/api",headers:t}),this.logger=ri.getInstance(),e.wsBaseUrl&&(this.wsBaseUrl=e.wsBaseUrl),this.connectionMode=e.connectionMode||"websocket",this.wsBaseUrl||"http"===this.connectionMode||this.fetchWebSocketServers().catch(e=>this.logger.warn("Failed to fetch WebSocket servers:",e))}async getFileMetadata(e){try{const t=await zt.get(e),i=t.headers["content-type"]||"";return{size:parseInt(t.headers["content-length"]||"0",10),mimeType:i}}catch(t){throw this.logger.error("Error fetching file metadata:",t),new oi("Unable to fetch file metadata")}}getMimeType(t){const i=t.toLowerCase().split(".").pop();if(!i)throw new oi("File must have an extension");const n=e.VALID_MIME_TYPES[i];if(!n)throw new oi(`Unsupported file type: ${i}`);return n}validateRequest(t){if(this.logger.debug("Validating request:",t),!t.holderId||""===t.holderId.trim())throw this.logger.warn("holderId is missing or empty"),new oi("holderId is required");if(!e.VALID_MODES.includes(t.mode))throw new oi(`Invalid mode: ${t.mode}. Must be one of: ${e.VALID_MODES.join(", ")}`);if("hashinal"===t.mode&&!t.jsonFileURL&&!t.metadataObject)throw new oi("Hashinal mode requires either jsonFileURL or metadataObject");if(t.onlyJSONCollection&&"hashinal-collection"!==t.mode)throw new oi("onlyJSONCollection can only be used with hashinal-collection mode");this.validateFileInput(t.file)}normalizeMimeType(e){return"image/vnd.microsoft.icon"===e?(this.logger.debug("Normalizing MIME type from image/vnd.microsoft.icon to image/x-icon"),"image/x-icon"):e}validateMimeType(t){return!!Object.values(e.VALID_MIME_TYPES).includes(t)||"image/vnd.microsoft.icon"===t&&(this.logger.debug("Accepting alternative MIME type for ICO: image/vnd.microsoft.icon"),!0)}validateFileInput(t){if("base64"===t.type){if(!t.base64)throw new oi("Base64 data is required");const i=t.base64.replace(/^data:.*?;base64,/,"");if(Math.ceil(.75*i.length)>e.MAX_BASE64_SIZE)throw new oi(`File size exceeds maximum limit of ${e.MAX_BASE64_SIZE/1024/1024}MB`);const n=t.mimeType||this.getMimeType(t.fileName);if(!this.validateMimeType(n))throw new oi("File must have one of the supported MIME types");"image/vnd.microsoft.icon"===t.mimeType&&(t.mimeType=this.normalizeMimeType(t.mimeType))}else if("url"===t.type&&!t.url)throw new oi("URL is required")}async detectMimeTypeFromBase64(e){if(e.startsWith("data:")){const t=e.match(/^data:([^;]+);base64,/);if(t&&t.length>1)return t[1]}try{const t=e.replace(/\s/g,""),i=m.from(t,"base64"),n=await async function(e,t){return new Pn(t).fromBuffer(e)}(i);return(null==n?void 0:n.mime)||"application/octet-stream"}catch(lo){return this.logger.warn("Failed to detect MIME type from buffer"),"application/octet-stream"}}async startInscription(t){var i,n;try{this.validateRequest(t);let i=t.file.mimeType;if("url"===t.file.type){const n=await this.getFileMetadata(t.file.url);if(i=n.mimeType||i,n.size>e.MAX_URL_FILE_SIZE)throw new oi(`File size exceeds maximum URL file limit of ${e.MAX_URL_FILE_SIZE/1024/1024}MB`)}else"base64"===t.file.type&&(i=await this.detectMimeTypeFromBase64(t.file.base64));if("image/vnd.microsoft.icon"===i&&(i=this.normalizeMimeType(i)),t.jsonFileURL){if("application/json"!==(await this.getFileMetadata(t.jsonFileURL)).mimeType)throw new oi("JSON file must be of type application/json")}const n={holderId:t.holderId,mode:t.mode,network:this.config.network,onlyJSONCollection:t.onlyJSONCollection?1:0,creator:t.creator,description:t.description,fileStandard:t.fileStandard,metadataObject:t.metadataObject,jsonFileURL:t.jsonFileURL};let r;return r="url"===t.file.type?await this.client.post("/inscriptions/start-inscription",{...n,fileURL:t.file.url}):await this.client.post("/inscriptions/start-inscription",{...n,fileBase64:t.file.base64,fileName:t.file.fileName,fileMimeType:i||this.getMimeType(t.file.fileName)}),r.data}catch(r){if(r instanceof oi)throw r;if(zt.isAxiosError(r))throw new Error((null==(n=null==(i=r.response)?void 0:i.data)?void 0:n.message)||"Failed to start inscription");throw r}}async executeTransaction(e,i){var n,r;try{const o="mainnet"===i.network?t.Client.forMainnet():t.Client.forTestnet(),s=new ci(i.network),a=await s.requestAccount(i.accountId),c=null==(n=null==a?void 0:a.key)?void 0:n._type,h="string"==typeof i.privateKey;let u;if(c&&h)u=(null==(r=null==c?void 0:c.toLowerCase())?void 0:r.includes("ecdsa"))?t.PrivateKey.fromStringECDSA(i.privateKey):t.PrivateKey.fromStringED25519(i.privateKey);else if(!c&&h){const e=h?si(i.privateKey):void 0;u="ed25519"===(null==e?void 0:e.detectedType)?t.PrivateKey.fromStringED25519(i.privateKey):t.PrivateKey.fromStringECDSA(i.privateKey)}else u=i.privateKey;o.setOperator(i.accountId,u);const f=t.TransferTransaction.fromBytes(m.from(e,"base64")),l=await f.sign(u),p=await l.execute(o),d=(await p.getReceipt(o)).status.toString();if("SUCCESS"!==d)throw new Error(`Transaction failed with status: ${d}`);return p.transactionId.toString()}catch(o){throw new Error(`Failed to execute transaction: ${o instanceof Error?o.message:"Unknown error"}`)}}async executeTransactionWithSigner(e,i){try{const n=t.TransferTransaction.fromBytes(m.from(e,"base64")),r=await n.executeWithSigner(i),o=(await r.getReceiptWithSigner(i)).status.toString();if("SUCCESS"!==o)throw new Error(`Transaction failed with status: ${o}`);return r.transactionId.toString()}catch(n){throw new Error(`Failed to execute transaction: ${n instanceof Error?n.message:"Unknown error"}`)}}async inscribeAndExecute(e,t,i,n){const r=(null==n?void 0:n.waitForCompletion)??!0,o=(null==n?void 0:n.maxWaitTime)??12e4,s=(null==n?void 0:n.checkInterval)??2e3;if(this.logger.debug("inscribeAndExecute called",{hasProgressCallback:!!i,connectionMode:this.connectionMode,wsBaseUrl:this.wsBaseUrl}),"http"!==this.connectionMode){const n="websocket"===this.connectionMode||"auto"===this.connectionMode&&await this.detectBestConnection();if(n)try{return await this.inscribeViaWebSocket(e,t,i)}catch(u){throw this.logger.error("WebSocket inscription failed, falling back to HTTP:",u),u}else this.logger.info(`Not using WebSocket: useWebSocket=${n}, wsBaseUrl=${this.wsBaseUrl}`)}else this.logger.info(`Not using WebSocket: hasCallback=${!!i}, connectionMode=${this.connectionMode}`);const a=await this.startInscription(e);if(!a.transactionBytes)throw this.logger.error("No transaction bytes returned from inscription request",a),new Error("No transaction bytes returned from inscription request");this.logger.info("executing transaction");const c=await this.executeTransaction(a.transactionBytes,t),h={jobId:a.tx_id,transactionId:c};if(r){i&&i({stage:"confirming",message:"Transaction executed, waiting for inscription to complete",progressPercent:5});const e=Math.floor(o/s),t=await this.waitForInscription(c,e,s,!0,i);return{...h,topicId:t.topic_id,status:t.status,completed:t.completed}}return h}async fetchWebSocketServers(){try{const e=await this.client.get("/inscriptions/websocket-servers"),{servers:t,recommended:i}=e.data;if(i)this.wsBaseUrl=i;else if(t&&t.length>0){const e=t.filter(e=>"active"===e.status);if(e.length>0){const t=e[0];this.wsBaseUrl=t.url}}}catch(e){this.logger.debug("Could not fetch WebSocket servers, will use HTTP only")}}async detectBestConnection(){if(!this.wsBaseUrl)return!1;try{const e=co(this.wsBaseUrl,{auth:{apiKey:this.config.apiKey},transports:["websocket"],timeout:3e3});return new Promise(t=>{const i=setTimeout(()=>{e.disconnect(),t(!1)},3e3);e.on("connect",()=>{clearTimeout(i),e.disconnect(),t(!0)}),e.on("connect_error",()=>{clearTimeout(i),e.disconnect(),t(!1)})})}catch(fo){return!1}}async inscribeViaWebSocket(e,t,i){if(!this.wsBaseUrl){const e=(await this.client.get("/inscriptions/websocket-servers")).data.recommended;if(!e)throw new Error("No WebSocket servers available");this.wsBaseUrl=e}return await this.connectWebSocket(),new Promise((n,r)=>{if(!this.socket)return r(new Error("WebSocket not connected"));let o,s,a,c;const h=()=>{var e,t,i;c&&clearTimeout(c),null==(e=this.socket)||e.off("inscription-progress",l),null==(t=this.socket)||t.off("inscription-complete",u),null==(i=this.socket)||i.off("inscription-error",f)};c=setTimeout(()=>{this.logger.error("WebSocket inscription timeout after 60 seconds",{jobId:o,transactionId:s,lastTopicId:a}),h(),n({jobId:o,transactionId:s,topicId:a,topic_id:a,status:"timeout",completed:!1})},6e4);const u=e=>{h(),n({jobId:o,transactionId:s,topicId:e.topicId||e.topic_id,topic_id:e.topicId||e.topic_id,status:"completed",completed:!0})},f=e=>{h(),r(new Error(e.error||"Inscription failed"))},l=e=>{this.logger.debug("Progress event received:",{jobId:e.jobId,status:e.status,progress:e.progress,topicId:e.topicId||e.topic_id,topic_id:e.topicId||e.topic_id}),(e.topicId||e.topic_id)&&(a=e.topicId||e.topic_id),i&&i({stage:"completed"===e.status?"completed":"confirming",message:`Processing inscription: ${e.status}`,progressPercent:e.progress||0,details:e}),"completed"!==e.status&&100!==e.progress||(this.logger.info("Inscription completed via progress handler",{status:e.status,progress:e.progress,topicId:e.topicId||e.topic_id||a,topic_id:e.topicId||e.topic_id||a}),h(),n({jobId:o,transactionId:s,topicId:e.topicId||e.topic_id||a,topic_id:e.topicId||e.topic_id||a,status:"completed",completed:!0}))};this.socket.on("inscription-progress",l),this.socket.on("inscription-complete",u),this.socket.on("inscription-error",f),this.socket.emit("start-inscription",{...e,network:this.config.network},async e=>{if(!e.success)return h(),r(new Error(e.error||"Inscription failed"));try{if(!e.transactionBytes)throw new Error("No transaction bytes returned from WebSocket inscription");if(s=await this.executeTransaction(e.transactionBytes,t),o=e.jobId||e.tx_id,!o)throw new Error("No job ID returned from WebSocket inscription");i&&i({stage:"confirming",message:"Transaction executed, inscribing to HCS...",progressPercent:5}),this.logger.info("Transaction executed, waiting for inscription completion...",{jobId:o,transactionId:s})}catch(n){h(),r(n)}})})}async connectWebSocket(){if(!this.socketConnected||!this.socket){if(!this.wsBaseUrl)throw new Error("WebSocket URL not configured");return new Promise((e,t)=>{this.socket=co(this.wsBaseUrl,{auth:{apiKey:this.config.apiKey},transports:["websocket","polling"]});const i=setTimeout(()=>{t(new Error("WebSocket connection timeout"))},1e4);this.socket.on("connect",()=>{clearTimeout(i),this.socketConnected=!0,this.logger.info("WebSocket connected"),e()}),this.socket.on("connect_error",e=>{clearTimeout(i),this.socketConnected=!1,t(new Error(`WebSocket connection failed: ${e.message}`))}),this.socket.on("disconnect",()=>{this.socketConnected=!1,this.logger.info("WebSocket disconnected")})})}}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null,this.socketConnected=!1)}async inscribe(e,t){const i=await this.startInscription(e);if(!i.transactionBytes)throw this.logger.error("No transaction bytes returned from inscription request",i),new Error("No transaction bytes returned from inscription request");this.logger.info("executing transaction");const n=await this.executeTransactionWithSigner(i.transactionBytes,t);return{jobId:i.tx_id,transactionId:n}}async retryWithBackoff(e,t=3,i=1e3){for(let r=0;r<t;r++)try{return await e()}catch(n){if(r===t-1)throw n;const e=i*Math.pow(2,r);await new Promise(t=>setTimeout(t,e)),this.logger.debug(`Retry attempt ${r+1}/${t} after ${e}ms delay`)}throw new Error("Retry operation failed")}async retrieveInscription(e){if(!e)throw new oi("Transaction ID is required");try{const t=e.includes("@")?`${e.split("@")[0]}-${e.split("@")[1].replace(/\./g,"-")}`:e;return await this.retryWithBackoff(async()=>{const e=(await this.client.get(`/inscriptions/retrieve-inscription?id=${t}`)).data,i=e.completed||"completed"===e.status.toLowerCase();return{...e,completed:i,jobId:e.id}})}catch(t){throw this.logger.error("Failed to retrieve inscription:",t),t}}async getInscriptionNumbers(e={}){try{return(await this.client.get("/inscriptions/numbers",{params:e})).data}catch(t){throw this.logger.error("Failed to fetch inscription numbers:",t),t}}static async authenticate(e){return new ai(e).authenticate()}static async createWithAuth(t){const i="client"===t.type?new hi({...t,logger:ri.getInstance()}):new ai(t),{apiKey:n}=await i.authenticate();return new e({apiKey:n,network:t.network||"mainnet",wsBaseUrl:t.wsBaseUrl,connectionMode:t.connectionMode||"websocket"})}async waitForInscription(e,t=30,i=4e3,n=!1,r){var o;let s=0,a=0;const c=(i,n,o,c)=>{if(r)try{a=Math.max(a,o),r({stage:i,message:n,progressPercent:a,details:{...c,txId:e,currentAttempt:s,maxAttempts:t}})}catch(lo){this.logger.warn(`Error in progress callback: ${lo}`)}};for(c("confirming","Starting inscription verification",0);s<t;){c("confirming",`Verifying inscription status (attempt ${s+1}/${t})`,5,{attempt:s+1});const r=await this.retrieveInscription(e);if(r.error)throw c("verifying",`Error: ${r.error}`,100,{error:r.error}),new Error(r.error);let a=5;const h=r.completed||"completed"===r.status.toLowerCase();void 0!==r.messages&&void 0!==r.maxMessages&&r.maxMessages>0?(a=Math.min(95,5+r.messages/r.maxMessages*90),h&&(a=100)):"processing"===r.status?a=10:h&&(a=100),c(h?"completed":"confirming",h?"Inscription completed successfully":`Processing inscription (${r.status})`,a,{status:r.status,messagesProcessed:r.messages,maxMessages:r.maxMessages,messageCount:r.messages,completed:h,confirmedMessages:r.confirmedMessages,result:r});const u="hashinal"===r.mode,f="hashinal-collection"===r.mode,l="6"===(null==(o=r.fileStandard)?void 0:o.toString());if(f&&h&&(!n||h))return c("completed","Inscription verification complete",100,{result:r}),r;if(u&&r.topic_id&&r.jsonTopicId&&(!n||h))return c("completed","Inscription verification complete",100,{result:r}),r;if(!u&&!l&&r.topic_id&&(!n||h))return c("completed","Inscription verification complete",100,{result:r}),r;if(l&&r.topic_id&&r.jsonTopicId&&r.registryTopicId&&(!n||h))return c("completed","Inscription verification complete",100,{result:r}),r;await new Promise(e=>setTimeout(e,i)),s++}throw c("verifying",`Inscription ${e} did not complete within ${t} attempts`,100,{timedOut:!0}),new Error(`Inscription ${e} did not complete within ${t} attempts`)}async getHolderInscriptions(e){var t,i;if(!e.holderId)throw new oi("Holder ID is required");try{const t={holderId:e.holderId};e.includeCollections&&(t.includeCollections="1");return(await this.client.get("/inscriptions/holder-inscriptions",{params:t})).data}catch(n){if(this.logger.error("Failed to fetch holder inscriptions:",n),zt.isAxiosError(n))throw new Error((null==(i=null==(t=n.response)?void 0:t.data)?void 0:i.message)||"Failed to fetch holder inscriptions");throw n}}};n(ho,"VALID_MODES",["file","upload","hashinal","hashinal-collection"]),n(ho,"MAX_BASE64_SIZE",2097152),n(ho,"MAX_URL_FILE_SIZE",104857600),n(ho,"VALID_MIME_TYPES",{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",ico:"image/x-icon",heic:"image/heic",heif:"image/heif",bmp:"image/bmp",webp:"image/webp",tiff:"image/tiff",tif:"image/tiff",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",html:"text/html",htm:"text/html",css:"text/css",php:"application/x-httpd-php",java:"text/x-java-source",js:"application/javascript",mjs:"application/javascript",csv:"text/csv",json:"application/json",txt:"text/plain",glb:"model/gltf-binary",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",flac:"audio/flac",aac:"audio/aac",m4a:"audio/mp4",avi:"video/x-msvideo",mov:"video/quicktime",mkv:"video/x-matroska",m4v:"video/mp4",mpg:"video/mpeg",mpeg:"video/mpeg",ts:"application/typescript",zip:"application/zip",rar:"application/vnd.rar",tar:"application/x-tar",gz:"application/gzip","7z":"application/x-7z-compressed",xml:"application/xml",yaml:"application/yaml",yml:"application/yaml",md:"text/markdown",markdown:"text/markdown",rtf:"application/rtf",gltf:"model/gltf+json",usdz:"model/vnd.usdz+zip",obj:"model/obj",stl:"model/stl",fbx:"application/octet-stream",ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2",eot:"application/vnd.ms-fontobject",psd:"application/vnd.adobe.photoshop",ai:"application/postscript",eps:"application/postscript",ps:"application/postscript",sqlite:"application/x-sqlite3",db:"application/x-sqlite3",apk:"application/vnd.android.package-archive",ics:"text/calendar",vcf:"text/vcard",py:"text/x-python",rb:"text/x-ruby",go:"text/x-go",rs:"text/x-rust",typescript:"application/typescript",jsx:"text/jsx",tsx:"text/tsx",sql:"application/sql",toml:"application/toml",avif:"image/avif",jxl:"image/jxl",weba:"audio/webm",wasm:"application/wasm"});let uo=ho;window.InscriptionSDK=uo,e.Auth=ai,e.ClientAuth=hi,e.InscriptionSDK=uo,e.ValidationError=oi,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=inscription-sdk.umd.js.map