(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7559],{26446:function(t,e){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return(r+n)*3/4-n},e.toByteArray=function(t){var e,r,o=u(t),s=o[0],a=o[1],l=new i((s+a)*3/4-a),f=0,c=a>0?s-4:s;for(r=0;r<c;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],l[f++]=e>>16&255,l[f++]=e>>8&255,l[f++]=255&e;return 2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,l[f++]=255&e),1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,l[f++]=e>>8&255,l[f++]=255&e),l},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=0,a=n-i;s<a;s+=16383)o.push(function(t,e,n){for(var i,o=[],s=e;s<n;s+=3)o.push(r[(i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]))>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return o.join("")}(t,s,s+16383>a?a:s+16383));return 1===i?o.push(r[(e=t[n-1])>>2]+r[e<<4&63]+"=="):2===i&&o.push(r[(e=(t[n-2]<<8)+t[n-1])>>10]+r[e>>4&63]+r[e<<2&63]+"="),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=o.length;s<a;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");-1===r&&(r=e);var n=r===e?0:4-r%4;return[r,n]}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},15313:function(t,e,r){"use strict";/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */let n=r(26446),i=r(47164),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function s(t){if(t>2147483647)throw RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw TypeError('The "string" argument must be of type string. Received type number');return f(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if(("string"!=typeof e||""===e)&&(e="utf8"),!a.isEncoding(e))throw TypeError("Unknown encoding: "+e);let r=0|p(t,e),n=s(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(N(t,Uint8Array)){let e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(N(t,ArrayBuffer)||t&&N(t.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(N(t,SharedArrayBuffer)||t&&N(t.buffer,SharedArrayBuffer)))return h(t,e,r);if("number"==typeof t)throw TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);let i=function(t){var e;if(a.isBuffer(t)){let e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||(e=t.length)!=e?s(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw TypeError('"size" argument must be of type number');if(t<0)throw RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),s(t<0?0:0|d(t))}function c(t){let e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function h(t,e,r){let n;if(e<0||t.byteLength<e)throw RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),a.prototype),n}function d(t){if(t>=2147483647)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|t}function p(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return C(t).length;default:if(i)return n?-1:k(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(e>>>=0)))return"";for(t||(t="utf8");;)switch(t){case"hex":return function(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=$[t[n]];return i}(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return function(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}(this,e,r);case"latin1":case"binary":return function(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}(this,e,r);case"base64":var o,s;return o=e,s=r,0===o&&s===this.length?n.fromByteArray(this):n.fromByteArray(this.slice(o,s));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(t,e,r){let n=t.slice(e,r),i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}(this,e,r);default:if(i)throw TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function y(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,i){var o;if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),(o=r=+r)!=o&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1}else if(r<0){if(!i)return -1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return(e&=255,"function"==typeof Uint8Array.prototype.indexOf)?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;s=2,a/=2,u/=2,r/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(l(t,o)===l(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else -1!==n&&(o-=o-n),n=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(l(t,o+n)!==l(e,n)){r=!1;break}if(r)return o}return -1}function w(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let e=t[i],o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:(192&(r=t[i+1]))==128&&(u=(31&e)<<6|63&r)>127&&(o=u);break;case 3:r=t[i+1],n=t[i+2],(192&r)==128&&(192&n)==128&&(u=(15&e)<<12|(63&r)<<6|63&n)>2047&&(u<55296||u>57343)&&(o=u);break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],(192&r)==128&&(192&n)==128&&(192&a)==128&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a)>65535&&u<1114112&&(o=u)}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){let e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}function v(t,e,r){if(t%1!=0||t<0)throw RangeError("offset is not uint");if(t+e>r)throw RangeError("Trying to access beyond buffer length")}function E(t,e,r,n,i,o){if(!a.isBuffer(t))throw TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw RangeError('"value" argument is out of bounds');if(r+n>t.length)throw RangeError("Index out of range")}function x(t,e,r,n,i){O(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function R(t,e,r,n,i){O(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function A(t,e,r,n,i,o){if(r+n>t.length||r<0)throw RangeError("Index out of range")}function _(t,e,r,n,o){return e=+e,r>>>=0,o||A(t,e,r,4,34028234663852886e22,-34028234663852886e22),i.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,o){return e=+e,r>>>=0,o||A(t,e,r,8,17976931348623157e292,-17976931348623157e292),i.write(t,e,r,n,52,8),r+8}e.lW=a,e.h2=50,a.TYPED_ARRAY_SUPPORT=function(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return(l(t),t<=0)?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)},a.allocUnsafe=function(t){return f(t)},a.allocUnsafeSlow=function(t){return f(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(N(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),N(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){let r;if(!Array.isArray(t))throw TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);if(void 0===e)for(r=0,e=0;r<t.length;++r)e+=t[r].length;let n=a.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){let e=t[r];if(N(e,Uint8Array))i+e.length>n.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else if(a.isBuffer(e))e.copy(n,i);else throw TypeError('"list" argument must be an Array of Buffers');i+=e.length}return n},a.byteLength=p,a.prototype._isBuffer=!0,a.prototype.swap16=function(){let t=this.length;if(t%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},a.prototype.swap32=function(){let t=this.length;if(t%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},a.prototype.swap64=function(){let t=this.length;if(t%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},a.prototype.toString=function(){let t=this.length;return 0===t?"":0==arguments.length?w(this,0,t):g.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){let t="",r=e.h2;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(a.prototype[o]=a.prototype.inspect),a.prototype.compare=function(t,e,r,n,i){if(N(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;let o=i-n,s=r-e,u=Math.min(o,s),l=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<u;++t)if(l[t]!==f[t]){o=l[t],s=f[t];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return m(this,t,e,r,!1)},a.prototype.write=function(t,e,r,n){var i,o,s,a,u,l,f,c;if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let h=this.length-e;if((void 0===r||r>h)&&(r=h),t.length>0&&(r<0||e<0)||e>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let d=!1;for(;;)switch(n){case"hex":return function(t,e,r,n){let i;r=Number(r)||0;let o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;let s=e.length;for(n>s/2&&(n=s/2),i=0;i<n;++i){let n=parseInt(e.substr(2*i,2),16);if(n!=n)break;t[r+i]=n}return i}(this,t,e,r);case"utf8":case"utf-8":return i=e,o=r,j(k(t,this.length-i),this,i,o);case"ascii":case"latin1":case"binary":return s=e,a=r,j(function(t){let e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(t),this,s,a);case"base64":return u=e,l=r,j(C(t),this,u,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return f=e,c=r,j(function(t,e){let r,n;let i=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)n=(r=t.charCodeAt(o))>>8,i.push(r%256),i.push(n);return i}(t,this.length-f),this,f,c);default:if(d)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},a.prototype.slice=function(t,e){let r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);let n=this.subarray(t,e);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||v(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||v(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||v(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||v(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||v(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||v(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||v(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=F(function(t){P(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&U(t,this.length-8);let n=e+256*this[++t]+65536*this[++t]+16777216*this[++t],i=this[++t]+256*this[++t]+65536*this[++t]+16777216*r;return BigInt(n)+(BigInt(i)<<BigInt(32))}),a.prototype.readBigUInt64BE=F(function(t){P(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&U(t,this.length-8);let n=16777216*e+65536*this[++t]+256*this[++t]+this[++t],i=16777216*this[++t]+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)}),a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||v(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||v(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},a.prototype.readInt8=function(t,e){return(t>>>=0,e||v(t,1,this.length),128&this[t])?-((255-this[t]+1)*1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||v(t,2,this.length);let r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||v(t,2,this.length);let r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||v(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||v(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=F(function(t){P(t>>>=0,"offset");let e=this[t],r=this[t+7];return(void 0===e||void 0===r)&&U(t,this.length-8),(BigInt(this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24))<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+16777216*this[++t])}),a.prototype.readBigInt64BE=F(function(t){P(t>>>=0,"offset");let e=this[t],r=this[t+7];return(void 0===e||void 0===r)&&U(t,this.length-8),(BigInt((e<<24)+65536*this[++t]+256*this[++t]+this[++t])<<BigInt(32))+BigInt(16777216*this[++t]+65536*this[++t]+256*this[++t]+r)}),a.prototype.readFloatLE=function(t,e){return t>>>=0,e||v(t,4,this.length),i.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||v(t,4,this.length),i.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||v(t,8,this.length),i.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||v(t,8,this.length),i.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){let n=Math.pow(2,8*r)-1;E(this,t,e,r,n,0)}let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){let n=Math.pow(2,8*r)-1;E(this,t,e,r,n,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=F(function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=F(function(t,e=0){return R(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){let n=Math.pow(2,8*r-1);E(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){let n=Math.pow(2,8*r-1);E(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||E(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=F(function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=F(function(t,e=0){return R(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeFloatLE=function(t,e,r){return _(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return _(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r||0===t.length||0===this.length)return 0;if(e<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);let i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},a.prototype.fill=function(t,e,r,n){let i;if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw TypeError("Unknown encoding: "+n);if(1===t.length){let e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw RangeError("Out of range index");if(r<=e)return this;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{let o=a.isBuffer(t)?t:a.from(t,n),s=o.length;if(0===s)throw TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s]}return this};let S={};function B(t,e,r){S[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function T(t){let e="",r=t.length,n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function O(t,e,r,n,i,o){if(t>r||t<e){let n;let i="bigint"==typeof e?"n":"";throw n=o>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${(o+1)*8}${i}`:`>= -(2${i} ** ${(o+1)*8-1}${i}) and < 2 ** ${(o+1)*8-1}${i}`:`>= ${e}${i} and <= ${r}${i}`,new S.ERR_OUT_OF_RANGE("value",n,t)}P(i,"offset"),(void 0===n[i]||void 0===n[i+o])&&U(i,n.length-(o+1))}function P(t,e){if("number"!=typeof t)throw new S.ERR_INVALID_ARG_TYPE(e,"number",t)}function U(t,e,r){if(Math.floor(t)!==t)throw P(t,r),new S.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new S.ERR_BUFFER_OUT_OF_BOUNDS;throw new S.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}B("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),B("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),B("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>4294967296?i=T(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=T(i)),i+="n"),n+=` It must be ${e}. Received ${i}`},RangeError);let L=/[^+/0-9A-Za-z-_]/g;function k(t,e){let r;e=e||1/0;let n=t.length,i=null,o=[];for(let s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319||s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return o}function C(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length)&&!(i>=t.length);++i)e[i+r]=t[i];return i}function N(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}let $=function(){let t="0123456789abcdef",e=Array(256);for(let r=0;r<16;++r){let n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function F(t){return"undefined"==typeof BigInt?D:t}function D(){throw Error("BigInt not supported")}},47164:function(t,e){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,l=u>>1,f=-7,c=r?i-1:0,h=r?-1:1,d=t[e+c];for(c+=h,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+c],c+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+c],c+=h,f-=8);if(0===o)o=1-l;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=l}return(d?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,l=8*o-i-1,f=(1<<l)-1,c=f>>1,h=23===i?5960464477539062e-23:0,d=n?0:o-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(isNaN(e=Math.abs(e))||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+c>=1?e+=h/u:e+=h*Math.pow(2,1-c),e*u>=2&&(s++,u/=2),s+c>=f?(a=0,s=f):s+c>=1?(a=(e*u-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;t[r+d]=255&s,d+=p,s/=256,l-=8);t[r+d-p]|=128*g}},83678:function(t,e,r){"use strict";r.d(e,{Z:function(){return x}});var n=r(10025),i=r(20964),o=r(44194),s=o.useLayoutEffect,a=function(t){var e=o.useRef(t);return s(function(){e.current=t}),e},u=function(t,e){if("function"==typeof t){t(e);return}t.current=e},l=function(t,e){var r=(0,o.useRef)();return(0,o.useCallback)(function(n){t.current=n,r.current&&u(r.current,null),r.current=e,e&&u(e,n)},[e])},f={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},c=function(t){Object.keys(f).forEach(function(e){t.style.setProperty(e,f[e],"important")})},h=null,d=function(t,e){var r=t.scrollHeight;return"border-box"===e.sizingStyle.boxSizing?r+e.borderSize:r-e.paddingSize},p=function(){},g=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak"],y=!!document.documentElement.currentStyle,m=function(t){var e=window.getComputedStyle(t);if(null===e)return null;var r=g.reduce(function(t,r){return t[r]=e[r],t},{}),n=r.boxSizing;if(""===n)return null;y&&"border-box"===n&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var i=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),o=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:i,borderSize:o}};function b(t,e,r){var n=a(r);o.useLayoutEffect(function(){var r=function(t){return n.current(t)};if(t)return t.addEventListener(e,r),function(){return t.removeEventListener(e,r)}},[])}var w=function(t){b(window,"resize",t)},v=function(t){b(document.fonts,"loadingdone",t)},E=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],x=o.forwardRef(function(t,e){var r=t.cacheMeasurements,s=t.maxRows,a=t.minRows,u=t.onChange,f=void 0===u?p:u,g=t.onHeightChange,y=void 0===g?p:g,b=(0,i.Z)(t,E),x=void 0!==b.value,R=o.useRef(null),A=l(R,e),_=o.useRef(0),I=o.useRef(),S=function(){var t,e,n,i,o,u,l,f,p,g,b,w=R.current,v=r&&I.current?I.current:m(w);if(v){I.current=v;var E=(t=w.value||w.placeholder||"x",void 0===(e=a)&&(e=1),void 0===(n=s)&&(n=1/0),h||((h=document.createElement("textarea")).setAttribute("tabindex","-1"),h.setAttribute("aria-hidden","true"),c(h)),null===h.parentNode&&document.body.appendChild(h),i=v.paddingSize,o=v.borderSize,l=(u=v.sizingStyle).boxSizing,Object.keys(u).forEach(function(t){h.style[t]=u[t]}),c(h),h.value=t,f=d(h,v),h.value=t,f=d(h,v),h.value="x",g=(p=h.scrollHeight-i)*e,"border-box"===l&&(g=g+i+o),f=Math.max(g,f),b=p*n,"border-box"===l&&(b=b+i+o),[f=Math.min(b,f),p]),x=E[0],A=E[1];_.current!==x&&(_.current=x,w.style.setProperty("height",x+"px","important"),y(x,{rowHeight:A}))}};return o.useLayoutEffect(S),w(S),v(S),o.createElement("textarea",(0,n.Z)({},b,{onChange:function(t){x||S(),f(t)},ref:A}))})},14527:function(t,e,r){"use strict";/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var n=r(44194),i="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=n.useState,s=n.useEffect,a=n.useLayoutEffect,u=n.useDebugValue;function l(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!i(t,r)}catch(t){return!0}}var f="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var r=e(),n=o({inst:{value:r,getSnapshot:e}}),i=n[0].inst,f=n[1];return a(function(){i.value=r,i.getSnapshot=e,l(i)&&f({inst:i})},[t,r,e]),s(function(){return l(i)&&f({inst:i}),t(function(){l(i)&&f({inst:i})})},[t]),u(r),r};e.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:f},38645:function(t,e,r){"use strict";t.exports=r(14527)},5015:function(t,e,r){"use strict";let n;r.d(e,{RJ:function(){return tv}});var i=r(44194),o=r(38645);let s=()=>{},a=s(),u=Object,l=t=>t===a,f=t=>"function"==typeof t,c=(t,e)=>({...t,...e}),h=t=>f(t.then),d=new WeakMap,p=0,g=t=>{let e,r;let n=typeof t,i=t&&t.constructor,o=i==Date;if(u(t)!==t||o||i==RegExp)e=o?t.toJSON():"symbol"==n?t.toString():"string"==n?JSON.stringify(t):""+t;else{if(e=d.get(t))return e;if(e=++p+"~",d.set(t,e),i==Array){for(r=0,e="@";r<t.length;r++)e+=g(t[r])+",";d.set(t,e)}if(i==u){e="#";let n=u.keys(t).sort();for(;!l(r=n.pop());)l(t[r])||(e+=r+":"+g(t[r])+",");d.set(t,e)}}return e},y=new WeakMap,m={},b={},w="undefined",v=typeof window!=w,E=typeof document!=w,x=()=>v&&typeof window.requestAnimationFrame!=w,R=(t,e)=>{let r=y.get(t);return[()=>!l(e)&&t.get(e)||m,n=>{if(!l(e)){let i=t.get(e);e in b||(b[e]=i),r[5](e,c(i,n),i||m)}},r[6],()=>!l(e)&&e in b?b[e]:!l(e)&&t.get(e)||m]},A=!0,[_,I]=v&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[s,s],S={initFocus:t=>(E&&document.addEventListener("visibilitychange",t),_("focus",t),()=>{E&&document.removeEventListener("visibilitychange",t),I("focus",t)}),initReconnect:t=>{let e=()=>{A=!0,t()},r=()=>{A=!1};return _("online",e),_("offline",r),()=>{I("online",e),I("offline",r)}}},B=!i.useId,T=!v||"Deno"in window,O=t=>x()?window.requestAnimationFrame(t):setTimeout(t,1),P=T?i.useEffect:i.useLayoutEffect,U="undefined"!=typeof navigator&&navigator.connection,L=!T&&U&&(["slow-2g","2g"].includes(U.effectiveType)||U.saveData),k=t=>{if(f(t))try{t=t()}catch(e){t=""}let e=t;return[t="string"==typeof t?t:(Array.isArray(t)?t.length:t)?g(t):"",e]},C=0,j=()=>++C;var N={ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:0,MUTATE_EVENT:2,RECONNECT_EVENT:1};async function $(...t){let[e,r,n,i]=t,o=c({populateCache:!0,throwOnError:!0},"boolean"==typeof i?{revalidate:i}:i||{}),s=o.populateCache,u=o.rollbackOnError,d=o.optimisticData,p=!1!==o.revalidate,g=t=>"function"==typeof u?u(t):!1!==u,m=o.throwOnError;if(f(r)){let t=[];for(let n of e.keys())!/^\$(inf|sub)\$/.test(n)&&r(e.get(n)._k)&&t.push(n);return Promise.all(t.map(b))}return b(r);async function b(r){let i;let[o]=k(r);if(!o)return;let[u,c]=R(e,o),[b,w,v,E]=y.get(e),x=b[o],A=()=>p&&(delete v[o],delete E[o],x&&x[0])?x[0](2).then(()=>u().data):u().data;if(t.length<3)return A();let _=n,I=j();w[o]=[I,0];let S=!l(d),B=u(),T=B.data,O=B._c,P=l(O)?T:O;if(S&&c({data:d=f(d)?d(P,T):d,_c:P}),f(_))try{_=_(P)}catch(t){i=t}if(_&&h(_)){if(_=await _.catch(t=>{i=t}),I!==w[o][0]){if(i)throw i;return _}i&&S&&g(i)&&(s=!0,c({data:_=P,_c:a}))}s&&!i&&(f(s)&&(_=s(_,P)),c({data:_,error:a,_c:a})),w[o][1]=j();let U=await A();if(c({_c:a}),i){if(m)throw i;return}return s?U:_}}let F=(t,e)=>{for(let r in t)t[r][0]&&t[r][0](e)},D=(t,e)=>{if(!y.has(t)){let r=c(S,e),n={},i=$.bind(a,t),o=s,u={},l=(t,e)=>{let r=u[t]||[];return u[t]=r,r.push(e),()=>r.splice(r.indexOf(e),1)},f=(e,r,n)=>{t.set(e,r);let i=u[e];if(i)for(let t of i)t(r,n)},h=()=>{if(!y.has(t)&&(y.set(t,[n,{},{},{},i,f,l]),!T)){let e=r.initFocus(setTimeout.bind(a,F.bind(a,n,0))),i=r.initReconnect(setTimeout.bind(a,F.bind(a,n,1)));o=()=>{e&&e(),i&&i(),y.delete(t)}}};return h(),[t,i,h,o]}return[t,y.get(t)[4]]},[M,V]=D(new Map),W=c({onLoadingSlow:s,onSuccess:s,onError:s,onErrorRetry:(t,e,r,n,i)=>{let o=r.errorRetryCount,s=i.retryCount,a=~~((Math.random()+.5)*(1<<(s<8?s:8)))*r.errorRetryInterval;(l(o)||!(s>o))&&setTimeout(n,a,i)},onDiscarded:s,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:L?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:L?5e3:3e3,compare:(t,e)=>g(t)==g(e),isPaused:()=>!1,cache:M,mutate:V,fallback:{}},{isOnline:()=>A,isVisible:()=>{let t=E&&document.visibilityState;return l(t)||"hidden"!==t}}),q=(t,e)=>{let r=c(t,e);if(e){let{use:n,fallback:i}=t,{use:o,fallback:s}=e;n&&o&&(r.use=n.concat(o)),i&&s&&(r.fallback=c(i,s))}return r},X=(0,i.createContext)({}),z=v&&window.__SWR_DEVTOOLS_USE__,H=z?window.__SWR_DEVTOOLS_USE__:[],J=t=>f(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(null===t[1]?t[2]:t[1])||{}],K=()=>c(W,(0,i.useContext)(X)),G=H.concat(t=>(e,r,n)=>{let i=r&&((...t)=>{let[n]=k(e),[,,,i]=y.get(M),o=i[n];return l(o)?r(...t):(delete i[n],o)});return t(e,i,n)}),Y=(t,e,r)=>{let n=e[t]||(e[t]=[]);return n.push(r),()=>{let t=n.indexOf(r);t>=0&&(n[t]=n[n.length-1],n.pop())}};z&&(window.__SWR_DEVTOOLS_REACT__=i);let Q=i.use||(t=>{if("pending"===t.status)throw t;if("fulfilled"===t.status)return t.value;if("rejected"===t.status)throw t.reason;throw t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e}),t}),Z={dedupe:!0};u.defineProperty(t=>{let{value:e}=t,r=(0,i.useContext)(X),n=f(e),o=(0,i.useMemo)(()=>n?e(r):e,[n,r,e]),s=(0,i.useMemo)(()=>n?o:q(r,o),[n,r,o]),u=o&&o.provider,l=(0,i.useRef)(a);u&&!l.current&&(l.current=D(u(s.cache||M),o));let h=l.current;return h&&(s.cache=h[0],s.mutate=h[1]),P(()=>{if(h)return h[2]&&h[2](),h[3]},[]),(0,i.createElement)(X.Provider,c(t,{value:s}))},"defaultValue",{value:W});let tt=(n=(t,e,r)=>{let{cache:n,compare:s,suspense:u,fallbackData:h,revalidateOnMount:d,revalidateIfStale:p,refreshInterval:g,refreshWhenHidden:m,refreshWhenOffline:b,keepPreviousData:w}=r,[v,E,x,A]=y.get(n),[_,I]=k(t),S=(0,i.useRef)(!1),U=(0,i.useRef)(!1),L=(0,i.useRef)(_),C=(0,i.useRef)(e),F=(0,i.useRef)(r),D=()=>F.current,M=()=>D().isVisible()&&D().isOnline(),[V,W,q,X]=R(n,_),z=(0,i.useRef)({}).current,H=l(h)?r.fallback[_]:h,J=(t,e)=>{for(let r in z)if("data"===r){if(!s(t[r],e[r])&&(!l(t[r])||!s(ts,e[r])))return!1}else if(e[r]!==t[r])return!1;return!0},K=(0,i.useMemo)(()=>{let t=!!_&&!!e&&(l(d)?!D().isPaused()&&!u&&(!!l(p)||p):d),r=e=>{let r=c(e);return(delete r._k,t)?{isValidating:!0,isLoading:!0,...r}:r},n=V(),i=X(),o=r(n),s=n===i?o:r(i),a=o;return[()=>{let t=r(V());return J(t,a)?(a.data=t.data,a.isLoading=t.isLoading,a.isValidating=t.isValidating,a.error=t.error,a):(a=t,t)},()=>s]},[n,_]),G=(0,o.useSyncExternalStore)((0,i.useCallback)(t=>q(_,(e,r)=>{J(r,e)||t()}),[n,_]),K[0],K[1]),tt=!S.current,te=v[_]&&v[_].length>0,tr=G.data,tn=l(tr)?H:tr,ti=G.error,to=(0,i.useRef)(tn),ts=w?l(tr)?to.current:tr:tn,ta=(!te||!!l(ti))&&(tt&&!l(d)?d:!D().isPaused()&&(u?!l(tn)&&p:l(tn)||p)),tu=!!(_&&e&&tt&&ta),tl=l(G.isValidating)?tu:G.isValidating,tf=l(G.isLoading)?tu:G.isLoading,tc=(0,i.useCallback)(async t=>{let e,n;let i=C.current;if(!_||!i||U.current||D().isPaused())return!1;let o=!0,u=t||{},c=!x[_]||!u.dedupe,h=()=>B?!U.current&&_===L.current&&S.current:_===L.current,d={isValidating:!1,isLoading:!1},p=()=>{W(d)},g=()=>{let t=x[_];t&&t[1]===n&&delete x[_]},y={isValidating:!0};l(V().data)&&(y.isLoading=!0);try{if(c&&(W(y),r.loadingTimeout&&l(V().data)&&setTimeout(()=>{o&&h()&&D().onLoadingSlow(_,r)},r.loadingTimeout),x[_]=[i(I),j()]),[e,n]=x[_],e=await e,c&&setTimeout(g,r.dedupingInterval),!x[_]||x[_][1]!==n)return c&&h()&&D().onDiscarded(_),!1;d.error=a;let t=E[_];if(!l(t)&&(n<=t[0]||n<=t[1]||0===t[1]))return p(),c&&h()&&D().onDiscarded(_),!1;let u=V().data;d.data=s(u,e)?u:e,c&&h()&&D().onSuccess(e,_,r)}catch(r){g();let t=D(),{shouldRetryOnError:e}=t;!t.isPaused()&&(d.error=r,c&&h()&&(t.onError(r,_,t),(!0===e||f(e)&&e(r))&&M()&&t.onErrorRetry(r,_,t,t=>{let e=v[_];e&&e[0]&&e[0](N.ERROR_REVALIDATE_EVENT,t)},{retryCount:(u.retryCount||0)+1,dedupe:!0})))}return o=!1,p(),!0},[_,n]),th=(0,i.useCallback)((...t)=>$(n,L.current,...t),[]);if(P(()=>{C.current=e,F.current=r,l(tr)||(to.current=tr)}),P(()=>{if(!_)return;let t=tc.bind(a,Z),e=0,r=Y(_,v,(r,n={})=>{if(r==N.FOCUS_EVENT){let r=Date.now();D().revalidateOnFocus&&r>e&&M()&&(e=r+D().focusThrottleInterval,t())}else if(r==N.RECONNECT_EVENT)D().revalidateOnReconnect&&M()&&t();else if(r==N.MUTATE_EVENT)return tc();else if(r==N.ERROR_REVALIDATE_EVENT)return tc(n)});return U.current=!1,L.current=_,S.current=!0,W({_k:I}),ta&&(l(tn)||T?t():O(t)),()=>{U.current=!0,r()}},[_]),P(()=>{let t;function e(){let e=f(g)?g(V().data):g;e&&-1!==t&&(t=setTimeout(r,e))}function r(){!V().error&&(m||D().isVisible())&&(b||D().isOnline())?tc(Z).then(e):e()}return e(),()=>{t&&(clearTimeout(t),t=-1)}},[g,m,b,_]),(0,i.useDebugValue)(ts),u&&l(tn)&&_){if(!B&&T)throw Error("Fallback data is required when using suspense in SSR.");C.current=e,F.current=r,U.current=!1;let t=A[_];if(l(t)||Q(th(t)),l(ti)){let t=tc(Z);l(ts)||(t.status="fulfilled",t.value=!0),Q(t)}else throw ti}return{mutate:th,get data(){return z.data=!0,ts},get error(){return z.error=!0,ti},get isValidating(){return z.isValidating=!0,tl},get isLoading(){return z.isLoading=!0,tf}}},function(...t){let e=K(),[r,i,o]=J(t),s=q(e,o),a=n,{use:u}=s,l=(u||[]).concat(G);for(let t=l.length;t--;)a=l[t](a);return a(r,i||s.fetcher||null,s)});var te={code:"0",name:"text",parse:t=>{if("string"!=typeof t)throw Error('"text" parts expect a string value.');return{type:"text",value:t}}},tr={code:"1",name:"function_call",parse:t=>{if(null==t||"object"!=typeof t||!("function_call"in t)||"object"!=typeof t.function_call||null==t.function_call||!("name"in t.function_call)||!("arguments"in t.function_call)||"string"!=typeof t.function_call.name||"string"!=typeof t.function_call.arguments)throw Error('"function_call" parts expect an object with a "function_call" property.');return{type:"function_call",value:t}}},tn={code:"2",name:"data",parse:t=>{if(!Array.isArray(t))throw Error('"data" parts expect an array value.');return{type:"data",value:t}}},ti={code:"3",name:"error",parse:t=>{if("string"!=typeof t)throw Error('"error" parts expect a string value.');return{type:"error",value:t}}},to={code:"4",name:"assistant_message",parse:t=>{if(null==t||"object"!=typeof t||!("id"in t)||!("role"in t)||!("content"in t)||"string"!=typeof t.id||"string"!=typeof t.role||"assistant"!==t.role||!Array.isArray(t.content)||!t.content.every(t=>null!=t&&"object"==typeof t&&"type"in t&&"text"===t.type&&"text"in t&&null!=t.text&&"object"==typeof t.text&&"value"in t.text&&"string"==typeof t.text.value))throw Error('"assistant_message" parts expect an object with an "id", "role", and "content" property.');return{type:"assistant_message",value:t}}},ts={code:"5",name:"assistant_control_data",parse:t=>{if(null==t||"object"!=typeof t||!("threadId"in t)||!("messageId"in t)||"string"!=typeof t.threadId||"string"!=typeof t.messageId)throw Error('"assistant_control_data" parts expect an object with a "threadId" and "messageId" property.');return{type:"assistant_control_data",value:{threadId:t.threadId,messageId:t.messageId}}}},ta={code:"6",name:"data_message",parse:t=>{if(null==t||"object"!=typeof t||!("role"in t)||!("data"in t)||"string"!=typeof t.role||"data"!==t.role)throw Error('"data_message" parts expect an object with a "role" and "data" property.');return{type:"data_message",value:t}}},tu={code:"7",name:"tool_calls",parse:t=>{if(null==t||"object"!=typeof t||!("tool_calls"in t)||"object"!=typeof t.tool_calls||null==t.tool_calls||!Array.isArray(t.tool_calls)||t.tool_calls.some(t=>{null!=t&&"object"==typeof t&&"id"in t&&"string"==typeof t.id&&"type"in t&&"string"==typeof t.type&&"function"in t&&null!=t.function&&"object"==typeof t.function&&"arguments"in t.function&&"string"==typeof t.function.name&&t.function.arguments}))throw Error('"tool_calls" parts expect an object with a ToolCallPayload.');return{type:"tool_calls",value:t}}},tl={code:"8",name:"message_annotations",parse:t=>{if(!Array.isArray(t))throw Error('"message_annotations" parts expect an array value.');return{type:"message_annotations",value:t}}},tf={[te.code]:te,[tr.code]:tr,[tn.code]:tn,[ti.code]:ti,[to.code]:to,[ts.code]:ts,[ta.code]:ta,[tu.code]:tu,[tl.code]:tl};te.name,te.code,tr.name,tr.code,tn.name,tn.code,ti.name,ti.code,to.name,to.code,ts.name,ts.code,ta.name,ta.code,tu.name,tu.code,tl.name,tl.code;var tc=[te,tr,tn,ti,to,ts,ta,tu,tl].map(t=>t.code),th=t=>{let e=t.indexOf(":");if(-1===e)throw Error("Failed to parse stream string. No separator found.");let r=t.slice(0,e);if(!tc.includes(r))throw Error(`Failed to parse stream string. Invalid code ${r}.`);let n=JSON.parse(t.slice(e+1));return tf[r].parse(n)};async function*td(t,{isAborted:e}={}){let r=new TextDecoder,n=[],i=0;for(;;){let{value:o}=await t.read();if(o&&(n.push(o),i+=o.length,10!==o[o.length-1]))continue;if(0===n.length)break;let s=function(t,e){let r=new Uint8Array(e),n=0;for(let e of t)r.set(e,n),n+=e.length;return t.length=0,r}(n,i);for(let t of(i=0,r.decode(s,{stream:!0}).split("\n").filter(t=>""!==t).map(th)))yield t;if(null==e?void 0:e()){t.cancel();break}}}var tp=((t,e=21)=>(r=e)=>{let n="",i=r;for(;i--;)n+=t[Math.random()*t.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);function tg(t,e){return t&&e&&e.length?{...t,annotations:[...e]}:t}async function ty({reader:t,abortControllerRef:e,update:r,onFinish:n,generateId:i=tp,getCurrentDate:o=()=>new Date}){let s;let a=o(),u={data:[]};for await(let{type:n,value:o}of td(t,{isAborted:()=>(null==e?void 0:e.current)===null})){"text"===n&&(u.text?u.text={...u.text,content:(u.text.content||"")+o}:u.text={id:i(),role:"assistant",content:o,createdAt:a});let t=null;"function_call"===n&&(u.function_call={id:i(),role:"assistant",content:"",function_call:o.function_call,name:o.function_call.name,createdAt:a},t=u.function_call);let e=null;"tool_calls"===n&&(u.tool_calls={id:i(),role:"assistant",content:"",tool_calls:o.tool_calls,createdAt:a},e=u.tool_calls),"data"===n&&u.data.push(...o);let l=u.text;"message_annotations"===n&&(s?s.push(...o):s=[...o],t=tg(u.function_call,s),e=tg(u.tool_calls,s),l=tg(u.text,s)),(null==s?void 0:s.length)&&["text","function_call","tool_calls"].forEach(t=>{u[t]&&(u[t].annotations=[...s])}),r([t,e,l].filter(Boolean).map(t=>({...tg(t,s)})),[...u.data])}return null==n||n(u),{messages:[u.text,u.function_call,u.tool_calls].filter(Boolean),data:u.data}}async function tm({api:t,messages:e,body:r,credentials:n,headers:i,abortController:o,appendMessage:s,restoreMessagesOnFailure:a,onResponse:u,onUpdate:l,onFinish:f,generateId:c}){var h;let d=await fetch(t,{method:"POST",body:JSON.stringify({messages:e,...r}),headers:{"Content-Type":"application/json",...i},signal:null==(h=null==o?void 0:o())?void 0:h.signal,credentials:n}).catch(t=>{throw a(),t});if(u)try{await u(d)}catch(t){throw t}if(!d.ok)throw a(),Error(await d.text()||"Failed to fetch the chat response.");if(!d.body)throw Error("The response body is empty.");let p=d.body.getReader();if("true"===d.headers.get("X-Experimental-Stream-Data"))return await ty({reader:p,abortControllerRef:null!=o?{current:o()}:void 0,update:l,onFinish(t){f&&null!=t.text&&f(t.text)},generateId:c});{let t=new Date,e=function(t){let e=new TextDecoder;return t?function(t){return e.decode(t,{stream:!0}).split("\n").filter(t=>""!==t).map(th).filter(Boolean)}:function(t){return t?e.decode(t,{stream:!0}):""}}(!1),r="",n={id:c(),createdAt:t,content:"",role:"assistant"};for(;;){let{done:t,value:i}=await p.read();if(t)break;if((r+=e(i)).startsWith('{"function_call":')?n.function_call=r:r.startsWith('{"tool_calls":')?n.tool_calls=r:n.content=r,s({...n}),(null==o?void 0:o())===null){p.cancel();break}}if(r.startsWith('{"function_call":')){let t=JSON.parse(r).function_call;n.function_call=t,s({...n})}if(r.startsWith('{"tool_calls":')){let t=JSON.parse(r).tool_calls;n.tool_calls=t,s({...n})}return f&&f(n),n}}async function tb({getStreamedResponse:t,experimental_onFunctionCall:e,experimental_onToolCall:r,updateChatRequest:n,getCurrentMessages:i}){for(;;){let o=await t();if("messages"in o){let t=!1;for(let s of o.messages)if(void 0!==s.function_call&&"string"!=typeof s.function_call||void 0!==s.tool_calls&&"string"!=typeof s.tool_calls){if(t=!0,e){let r=s.function_call;if("object"!=typeof r){console.warn("experimental_onFunctionCall should not be defined when using tools");continue}let o=await e(i(),r);if(void 0===o){t=!1;break}n(o)}if(r){let e=s.tool_calls;if(!Array.isArray(e)||e.some(t=>"object"!=typeof t)){console.warn("experimental_onToolCall should not be defined when using tools");continue}let o=await r(i(),e);if(void 0===o){t=!1;break}n(o)}}if(!t)break}else{let t=function(t){for(let e of t.messages){if(void 0!==e.tool_calls)for(let t of e.tool_calls)"object"==typeof t&&t.function.arguments&&"string"!=typeof t.function.arguments&&(t.function.arguments=JSON.stringify(t.function.arguments));void 0!==e.function_call&&"object"==typeof e.function_call&&e.function_call.arguments&&"string"!=typeof e.function_call.arguments&&(e.function_call.arguments=JSON.stringify(e.function_call.arguments))}};if((void 0===o.function_call||"string"==typeof o.function_call)&&(void 0===o.tool_calls||"string"==typeof o.tool_calls))break;if(e){let r=o.function_call;if("object"!=typeof r){console.warn("experimental_onFunctionCall should not be defined when using tools");continue}let s=await e(i(),r);if(void 0===s)break;t(s),n(s)}if(r){let e=o.tool_calls;if("object"!=typeof e){console.warn("experimental_onToolCall should not be defined when using functions");continue}let s=await r(i(),e);if(void 0===s)break;t(s),n(s)}}}}var tw=async(t,e,r,n,i,o,s,a,u,l,f,c)=>{var h,d;let p=s.current;r(e.messages,!1);let g=c?e.messages:e.messages.map(({role:t,content:e,name:r,function_call:n,tool_calls:i,tool_call_id:o})=>({role:t,content:e,tool_call_id:o,...void 0!==r&&{name:r},...void 0!==n&&{function_call:n},...void 0!==i&&{tool_calls:i}}));if("string"!=typeof t){let n={id:u(),createdAt:new Date,content:"",role:"assistant"};async function y(t){let{content:i,ui:o,next:s}=await t;n.content=i,n.ui=await o,r([...e.messages,{...n}],!1),s&&await y(s)}try{let r=t({messages:g,data:e.data});await y(r)}catch(t){throw r(p,!1),t}return l&&l(n),n}return await tm({api:t,messages:g,body:{data:e.data,...o.current.body,...null==(h=e.options)?void 0:h.body,...void 0!==e.functions&&{functions:e.functions},...void 0!==e.function_call&&{function_call:e.function_call},...void 0!==e.tools&&{tools:e.tools},...void 0!==e.tool_choice&&{tool_choice:e.tool_choice}},credentials:o.current.credentials,headers:{...o.current.headers,...null==(d=e.options)?void 0:d.headers},abortController:()=>a.current,appendMessage(t){r([...e.messages,t],!1)},restoreMessagesOnFailure(){r(p,!1)},onResponse:f,onUpdate(t,o){r([...e.messages,...t],!1),n([...i||[],...o||[]],!1)},onFinish:l,generateId:u})};function tv({api:t="/api/chat",id:e,initialMessages:r,initialInput:n="",sendExtraMessageFields:o,experimental_onFunctionCall:s,experimental_onToolCall:a,onResponse:u,onFinish:l,onError:f,credentials:c,headers:h,body:d,generateId:p=tp}={}){let g=(0,i.useId)(),y=null!=e?e:g,m="string"==typeof t?[t,y]:y,[b]=(0,i.useState)([]),{data:w,mutate:v}=tt([m,"messages"],null,{fallbackData:null!=r?r:b}),{data:E=!1,mutate:x}=tt([m,"loading"],null),{data:R,mutate:A}=tt([m,"streamData"],null),{data:_,mutate:I}=tt([m,"error"],null),S=(0,i.useRef)(w||[]);(0,i.useEffect)(()=>{S.current=w||[]},[w]);let B=(0,i.useRef)(null),T=(0,i.useRef)({credentials:c,headers:h,body:d});(0,i.useEffect)(()=>{T.current={credentials:c,headers:h,body:d}},[c,h,d]);let O=(0,i.useCallback)(async e=>{try{x(!0),I(void 0);let r=new AbortController;B.current=r,await tb({getStreamedResponse:()=>tw(t,e,v,A,R,T,S,B,p,l,u,o),experimental_onFunctionCall:s,experimental_onToolCall:a,updateChatRequest:t=>{e=t},getCurrentMessages:()=>S.current}),B.current=null}catch(t){if("AbortError"===t.name)return B.current=null,null;f&&t instanceof Error&&f(t),I(t)}finally{x(!1)}},[v,x,t,T,u,l,f,I,A,R,o,s,a,S,B,p]),P=(0,i.useCallback)(async(t,{options:e,functions:r,function_call:n,tools:i,tool_choice:o,data:s}={})=>(t.id||(t.id=p()),O({messages:S.current.concat(t),options:e,data:s,...void 0!==r&&{functions:r},...void 0!==n&&{function_call:n},...void 0!==i&&{tools:i},...void 0!==o&&{tool_choice:o}})),[O,p]),U=(0,i.useCallback)(async({options:t,functions:e,function_call:r,tools:n,tool_choice:i}={})=>0===S.current.length?null:"assistant"===S.current[S.current.length-1].role?O({messages:S.current.slice(0,-1),options:t,...void 0!==e&&{functions:e},...void 0!==r&&{function_call:r},...void 0!==n&&{tools:n},...void 0!==i&&{tool_choice:i}}):O({messages:S.current,options:t,...void 0!==e&&{functions:e},...void 0!==r&&{function_call:r},...void 0!==n&&{tools:n},...void 0!==i&&{tool_choice:i}}),[O]),L=(0,i.useCallback)(()=>{B.current&&(B.current.abort(),B.current=null)},[]),k=(0,i.useCallback)(t=>{v(t,!1),S.current=t},[v]),[C,j]=(0,i.useState)(n),N=(0,i.useCallback)((t,e={},r)=>{r&&(T.current={...T.current,...r}),t.preventDefault(),C&&(P({content:C,role:"user",createdAt:new Date},e),j(""))},[C,P]);return{messages:w||[],error:_,append:P,reload:U,stop:L,setMessages:k,input:C,setInput:j,handleInputChange:t=>{j(t.target.value)},handleSubmit:N,isLoading:E,data:R}}},57161:function(t,e,r){"use strict";let n;var i,o,s,a,u,l={};r.r(l),r.d(l,{APIConnectionError:function(){return m},APIConnectionTimeoutError:function(){return b},APIError:function(){return g},APIUserAbortError:function(){return y},AuthenticationError:function(){return v},BadRequestError:function(){return w},ConflictError:function(){return R},InternalServerError:function(){return I},NotFoundError:function(){return x},PermissionDeniedError:function(){return E},RateLimitError:function(){return _},UnprocessableEntityError:function(){return A}});let f="4.3.1";var c=r(15313).lW;class h{constructor(t,e){this.response=t,this.controller=e,this.decoder=new d}async *iterMessages(){if(!this.response.body)throw this.controller.abort(),Error("Attempted to iterate over a response with no body");let t=new p;for await(let e of function(t){if(t[Symbol.asyncIterator])return t;let e=t.getReader();return{async next(){try{let t=await e.read();return(null==t?void 0:t.done)&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}(this.response.body))for(let r of t.decode(e)){let t=this.decoder.decode(r);t&&(yield t)}for(let e of t.flush()){let t=this.decoder.decode(e);t&&(yield t)}}async *[Symbol.asyncIterator](){let t=!1;try{for await(let e of this.iterMessages())if(!t){if(e.data.startsWith("[DONE]")){t=!0;continue}if(null===e.event)try{yield JSON.parse(e.data)}catch(t){throw console.error("Could not parse message into JSON:",e.data),console.error("From chunk:",e.raw),t}}t=!0}catch(t){if(t instanceof Error&&"AbortError"===t.name)return;throw t}finally{t||this.controller.abort()}}}class d{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;let t={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],t}if(this.chunks.push(t),t.startsWith(":"))return null;let[e,r,n]=function(t,e){let r=t.indexOf(":");return -1!==r?[t.substring(0,r),":",t.substring(r+e.length)]:[t,"",""]}(t,":");return n.startsWith(" ")&&(n=n.substring(1)),"event"===e?this.event=n:"data"===e&&this.data.push(n),null}}class p{constructor(){this.buffer=[],this.trailingCR=!1}decode(t){let e=this.decodeText(t);if(this.trailingCR&&(e="\r"+e,this.trailingCR=!1),e.endsWith("\r")&&(this.trailingCR=!0,e=e.slice(0,-1)),!e)return[];let r=p.NEWLINE_CHARS.has(e[e.length-1]||""),n=e.split(p.NEWLINE_REGEXP);return 1!==n.length||r?(this.buffer.length>0&&(n=[this.buffer.join("")+n[0],...n.slice(1)],this.buffer=[]),r||(this.buffer=[n.pop()||""]),n):(this.buffer.push(n[0]),[])}decodeText(t){var e;if(null==t)return"";if("string"==typeof t)return t;if(void 0!==c){if(t instanceof c)return t.toString();if(t instanceof Uint8Array)return c.from(t).toString();throw Error(`Unexpected: received non-Uint8Array (${t.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if("undefined"!=typeof TextDecoder){if(t instanceof Uint8Array||t instanceof ArrayBuffer)return null!==(e=this.textDecoder)&&void 0!==e||(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(t);throw Error(`Unexpected: received non-Uint8Array/ArrayBuffer (${t.constructor.name}) in a web platform. Please report this error.`)}throw Error("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length&&!this.trailingCR)return[];let t=[this.buffer.join("")];return this.buffer=[],this.trailingCR=!1,t}}p.NEWLINE_CHARS=new Set(["\n","\r","\v","\f","\x1c","\x1d","\x1e","\x85","\u2028","\u2029"]),p.NEWLINE_REGEXP=/\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;class g extends Error{constructor(t,e,r,n){super(g.makeMessage(e,r)),this.status=t,this.headers=n,this.error=e,this.code=null==e?void 0:e.code,this.param=null==e?void 0:e.param,this.type=null==e?void 0:e.type}static makeMessage(t,e){return(null==t?void 0:t.message)?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):e||"Unknown error occurred"}static generate(t,e,r,n){if(!t)return new m({cause:tg(e)});let i=null==e?void 0:e.error;return 400===t?new w(t,i,r,n):401===t?new v(t,i,r,n):403===t?new E(t,i,r,n):404===t?new x(t,i,r,n):409===t?new R(t,i,r,n):422===t?new A(t,i,r,n):429===t?new _(t,i,r,n):t>=500?new I(t,i,r,n):new g(t,i,r,n)}}class y extends g{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0),this.status=void 0}}class m extends g{constructor({message:t,cause:e}){super(void 0,void 0,t||"Connection error.",void 0),this.status=void 0,e&&(this.cause=e)}}class b extends m{constructor(){super({message:"Request timed out."})}}class w extends g{constructor(){super(...arguments),this.status=400}}class v extends g{constructor(){super(...arguments),this.status=401}}class E extends g{constructor(){super(...arguments),this.status=403}}class x extends g{constructor(){super(...arguments),this.status=404}}class R extends g{constructor(){super(...arguments),this.status=409}}class A extends g{constructor(){super(...arguments),this.status=422}}class _ extends g{constructor(){super(...arguments),this.status=429}}class I extends g{}let S=t=>{},B=fetch.bind(void 0),T=FormData,O="undefined"!=typeof File?File:class extends Blob{constructor(){throw Error("file uploads aren't supported in this environment yet as 'File' is not defined")}};async function P(t,e){return{...e,body:new V(t)}}async function U(){throw Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")}var L=r(15313).lW;let k=t=>null!=t&&"object"==typeof t&&"string"==typeof t.url&&"function"==typeof t.blob,C=t=>null!=t&&"object"==typeof t&&"string"==typeof t.name&&"number"==typeof t.lastModified&&j(t),j=t=>null!=t&&"object"==typeof t&&"number"==typeof t.size&&"string"==typeof t.type&&"function"==typeof t.text&&"function"==typeof t.slice&&"function"==typeof t.arrayBuffer,N=t=>C(t)||k(t)||!1;async function $(t,e,r={}){var n,i,o,s,a;if(k(t=await t)){let i=await t.blob();return e||(e=null!==(n=new URL(t.url).pathname.split(/[\\/]/).pop())&&void 0!==n?n:"unknown_file"),new O([i],e,r)}let u=await F(t);if(e||(e=null!==(i=D((s=t).name)||D(s.filename)||(null===(a=D(s.path))||void 0===a?void 0:a.split(/[\\/]/).pop()))&&void 0!==i?i:"unknown_file"),!r.type){let t=null===(o=u[0])||void 0===o?void 0:o.type;"string"==typeof t&&(r={...r,type:t})}return new O(u,e,r)}async function F(t){var e;let r=[];if("string"==typeof t||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)r.push(t);else if(j(t))r.push(await t.arrayBuffer());else if(M(t))for await(let e of t)r.push(e);else throw Error(`Unexpected data type: ${typeof t}; constructor: ${null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e.name}; props: ${function(t){let e=Object.getOwnPropertyNames(t);return`[${e.map(t=>`"${t}"`).join(", ")}]`}(t)}`);return r}let D=t=>"string"==typeof t?t:void 0!==L&&t instanceof L?String(t):void 0,M=t=>null!=t&&"object"==typeof t&&"function"==typeof t[Symbol.asyncIterator];class V{constructor(t){this.body=t}get[Symbol.toStringTag](){return"MultipartBody"}}let W=t=>t&&"object"==typeof t&&t.body&&"MultipartBody"===t[Symbol.toStringTag],q=async t=>P(await X(t.body),t),X=async t=>{let e=new T;return await Promise.all(Object.entries(t||{}).map(([t,r])=>H(e,t,r))),e},z=t=>{if(N(t))return!0;if(Array.isArray(t))return t.some(z);if(t&&"object"==typeof t){for(let e in t)if(z(t[e]))return!0}return!1},H=async(t,e,r)=>{if(void 0!==r){if(null==r)throw TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof r||"number"==typeof r||"boolean"==typeof r)t.append(e,String(r));else if(N(r)){let n=await $(r);t.append(e,n)}else if(Array.isArray(r))await Promise.all(r.map(r=>H(t,e+"[]",r)));else if("object"==typeof r)await Promise.all(Object.entries(r).map(([r,n])=>H(t,`${e}[${r}]`,n)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${r} instead`)}};var J=r(15313).lW,K=r(73656),G=function(t,e,r,n,i){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},Y=function(t,e,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};async function Q(t){let{response:e}=t;if(t.options.stream)return new h(e,t.controller);let r=e.headers.get("content-type");if(null==r?void 0:r.includes("application/json")){let t=await e.json();return tb("response",e.status,e.url,e.headers,t),t}let n=await e.text();return tb("response",e.status,e.url,e.headers,n),n}class Z extends Promise{constructor(t,e=Q){super(t=>{t(null)}),this.responsePromise=t,this.parseResponse=e}_thenUnwrap(t){return new Z(this.responsePromise,async e=>t(await this.parseResponse(e)))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,e]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:e}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(this.parseResponse)),this.parsedPromise}then(t,e){return this.parse().then(t,e)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}}class tt{constructor({baseURL:t,maxRetries:e,timeout:r=6e5,httpAgent:n,fetch:i}){this.baseURL=t,this.maxRetries=tp("maxRetries",null!=e?e:2),this.timeout=tp("timeout",r),this.httpAgent=n,this.fetch=null!=i?i:B}authHeaders(t){return{}}defaultHeaders(t){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...tl(),...this.authHeaders(t)}}validateHeaders(t,e){}defaultIdempotencyKey(){return`stainless-node-retry-${tw()}`}get(t,e){return this.methodRequest("get",t,e)}post(t,e){return this.methodRequest("post",t,e)}patch(t,e){return this.methodRequest("patch",t,e)}put(t,e){return this.methodRequest("put",t,e)}delete(t,e){return this.methodRequest("delete",t,e)}methodRequest(t,e,r){return this.request(Promise.resolve(r).then(r=>({method:t,path:e,...r})))}getAPIList(t,e,r){return this.requestAPIList(e,{method:"get",path:t,...r})}calculateContentLength(t){if("string"==typeof t){if(void 0!==J)return J.byteLength(t,"utf8").toString();if("undefined"!=typeof TextEncoder)return new TextEncoder().encode(t).length.toString()}return null}buildRequest(t){var e,r,n,i,o,s;let{method:a,path:u,query:l,headers:f={}}=t,c=W(t.body)?t.body.body:t.body?JSON.stringify(t.body,null,2):null,h=this.calculateContentLength(c),d=this.buildURL(u,l);"timeout"in t&&tp("timeout",t.timeout);let p=null!==(e=t.timeout)&&void 0!==e?e:this.timeout,g=null!==(n=null!==(r=t.httpAgent)&&void 0!==r?r:this.httpAgent)&&void 0!==n?n:S(d),y=p+1e3;"number"==typeof(null===(i=null==g?void 0:g.options)||void 0===i?void 0:i.timeout)&&y>(null!==(o=g.options.timeout)&&void 0!==o?o:0)&&(g.options.timeout=y),this.idempotencyHeader&&"get"!==a&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),f[this.idempotencyHeader]=t.idempotencyKey);let m={...h&&{"Content-Length":h},...this.defaultHeaders(t),...f};W(t.body)&&delete m["Content-Type"],Object.keys(m).forEach(t=>null===m[t]&&delete m[t]);let b={method:a,...c&&{body:c},headers:m,...g&&{agent:g},signal:null!==(s=t.signal)&&void 0!==s?s:null};return this.validateHeaders(m,f),{req:b,url:d,timeout:p}}async prepareRequest(t,{url:e,options:r}){}parseHeaders(t){return t?Symbol.iterator in t?Object.fromEntries(Array.from(t).map(t=>[...t])):{...t}:{}}makeStatusError(t,e,r,n){return g.generate(t,e,r,n)}request(t,e=null){return new Z(this.makeRequest(t,e))}async makeRequest(t,e){var r,n,i;let o=await t;null==e&&(e=null!==(r=o.maxRetries)&&void 0!==r?r:this.maxRetries);let{req:s,url:a,timeout:u}=this.buildRequest(o);if(await this.prepareRequest(s,{url:a,options:o}),tb("request",a,o,s.headers),null===(n=o.signal)||void 0===n?void 0:n.aborted)throw new y;let l=new AbortController,f=await this.fetchWithTimeout(a,s,u,l).catch(tg);if(f instanceof Error){if(null===(i=o.signal)||void 0===i?void 0:i.aborted)throw new y;if(e)return this.retryRequest(o,e);if("AbortError"===f.name)throw new b;throw new m({cause:f})}let c=tn(f.headers);if(!f.ok){if(e&&this.shouldRetry(f))return this.retryRequest(o,e,c);let t=await f.text().catch(()=>"Unknown"),r=tf(t),n=r?void 0:t;throw tb("response",f.status,a,c,n),this.makeStatusError(f.status,r,n,c)}return{response:f,options:o,controller:l}}requestAPIList(t,e){return new tr(this,this.makeRequest(e,null),t)}buildURL(t,e){let r=new URL(th(t)?t:this.baseURL+(this.baseURL.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),n=this.defaultQuery();return tm(n)||(e={...n,...e}),e&&(r.search=this.stringifyQuery(e)),r.toString()}stringifyQuery(t){return Object.entries(t).filter(([t,e])=>void 0!==e).map(([t,e])=>{if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return`${encodeURIComponent(t)}=${encodeURIComponent(e)}`;if(null===e)return`${encodeURIComponent(t)}=`;throw Error(`Cannot stringify type ${typeof e}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout(t,e,r,n){let{signal:i,...o}=e||{};i&&i.addEventListener("abort",()=>n.abort());let s=setTimeout(()=>n.abort(),r);return this.getRequestClient().fetch(t,{signal:n.signal,...o}).finally(()=>{clearTimeout(s)})}getRequestClient(){return{fetch:this.fetch}}shouldRetry(t){let e=t.headers.get("x-should-retry");return"true"===e||"false"!==e&&(409===t.status||429===t.status||t.status>=500)}async retryRequest(t,e,r){var n;e-=1;let i=parseInt((null==r?void 0:r["retry-after"])||""),o=null!==(n=t.maxRetries)&&void 0!==n?n:this.maxRetries,s=1e3*this.calculateRetryTimeoutSeconds(e,i,o);return await td(s),this.makeRequest(t,e)}calculateRetryTimeoutSeconds(t,e,r){return Number.isInteger(e)&&e<=60?e:Math.min(.5*Math.pow(r-t-1,2),2)+(Math.random()-.5)}getUserAgent(){return`${this.constructor.name}/JS ${f}`}}class te{constructor(t,e,r,n){a.set(this,void 0),G(this,a,t,"f"),this.options=n,this.response=e,this.body=r}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageInfo()}async getNextPage(){let t=this.nextPageInfo();if(!t)throw Error("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let e={...this.options};if("params"in t)e.query={...e.query,...t.params};else if("url"in t){for(let[r,n]of[...Object.entries(e.query||{}),...t.url.searchParams.entries()])t.url.searchParams.set(r,n);e.query=void 0,e.path=t.url.toString()}return await Y(this,a,"f").requestAPIList(this.constructor,e)}async *iterPages(){let t=this;for(yield t;t.hasNextPage();)t=await t.getNextPage(),yield t}async *[(a=new WeakMap,Symbol.asyncIterator)](){for await(let t of this.iterPages())for(let e of t.getPaginatedItems())yield e}}class tr extends Z{constructor(t,e,r){super(e,async e=>new r(t,e.response,await Q(e),e.options))}async *[Symbol.asyncIterator](){for await(let t of(await this))yield t}}let tn=t=>new Proxy(Object.fromEntries(t.entries()),{get(t,e){let r=e.toString();return t[r.toLowerCase()]||t[r]}}),ti={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0},to=t=>"object"==typeof t&&null!==t&&!tm(t)&&Object.keys(t).every(t=>Object.prototype.hasOwnProperty.call(ti,t)),ts=()=>{if("undefined"!=typeof Deno&&null!=Deno.build)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":f,"X-Stainless-OS":tu(Deno.build.os),"X-Stainless-Arch":ta(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":Deno.version};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":f,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":K.version};if("[object process]"===Object.prototype.toString.call(void 0!==K?K:0))return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":f,"X-Stainless-OS":tu(K.platform),"X-Stainless-Arch":ta(K.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":K.version};let t=function(){if("undefined"==typeof navigator||!navigator)return null;for(let{key:t,pattern:e}of[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let r=e.exec(navigator.userAgent);if(r){let e=r[1]||0,n=r[2]||0,i=r[3]||0;return{browser:t,version:`${e}.${n}.${i}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":f,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":f,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},ta=t=>"x32"===t?"x32":"x86_64"===t||"x64"===t?"x64":"arm"===t?"arm":"aarch64"===t||"arm64"===t?"arm64":t?`other:${t}`:"unknown",tu=t=>(t=t.toLowerCase()).includes("ios")?"iOS":"android"===t?"Android":"darwin"===t?"MacOS":"win32"===t?"Windows":"freebsd"===t?"FreeBSD":"openbsd"===t?"OpenBSD":"linux"===t?"Linux":t?`Other:${t}`:"Unknown",tl=()=>null!=n?n:n=ts(),tf=t=>{try{return JSON.parse(t)}catch(t){return}},tc=RegExp("^(?:[a-z]+:)?//","i"),th=t=>tc.test(t),td=t=>new Promise(e=>setTimeout(e,t)),tp=(t,e)=>{if("number"!=typeof e||!Number.isInteger(e))throw Error(`${t} must be an integer`);if(e<0)throw Error(`${t} must be a positive integer`);return e},tg=t=>t instanceof Error?t:Error(t),ty=t=>{var e,r,n,i;return void 0!==K?null!==(r=null===(e=K.env)||void 0===e?void 0:e[t])&&void 0!==r?r:void 0:"undefined"!=typeof Deno?null===(i=null===(n=Deno.env)||void 0===n?void 0:n.get)||void 0===i?void 0:i.call(n,t):void 0};function tm(t){if(!t)return!0;for(let e in t)return!1;return!0}function tb(t,...e){void 0!==K&&"true"===K.env.DEBUG&&console.log(`OpenAI:DEBUG:${t}`,...e)}let tw=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}),tv=()=>"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator;class tE extends te{constructor(t,e,r,n){super(t,e,r,n),this.object=r.object,this.data=r.data}getPaginatedItems(){return this.data}nextPageParams(){return null}nextPageInfo(){return null}}class tx extends te{constructor(t,e,r,n){super(t,e,r,n),this.data=r.data}getPaginatedItems(){return this.data}nextPageParams(){let t=this.nextPageInfo();if(!t)return null;if("params"in t)return t.params;let e=Object.fromEntries(t.url.searchParams);return Object.keys(e).length?e:null}nextPageInfo(){var t,e;if(!(null===(t=this.data)||void 0===t?void 0:t.length))return null;let r=null===(e=this.data[this.data.length-1])||void 0===e?void 0:e.id;return r?{params:{after:r}}:null}}class tR{constructor(t){this.client=t,this.get=t.get.bind(t),this.post=t.post.bind(t),this.patch=t.patch.bind(t),this.put=t.put.bind(t),this.delete=t.delete.bind(t),this.getAPIList=t.getAPIList.bind(t)}}class tA extends tR{create(t,e){return this.post("/audio/transcriptions",q({body:t,...e}))}}tA||(tA={});class t_ extends tR{create(t,e){return this.post("/audio/translations",q({body:t,...e}))}}t_||(t_={});class tI extends tR{constructor(){super(...arguments),this.transcriptions=new tA(this.client),this.translations=new t_(this.client)}}(i=tI||(tI={})).Transcriptions=tA,i.Translations=t_;class tS extends tR{create(t,e){var r;return this.post("/chat/completions",{body:t,...e,stream:null!==(r=t.stream)&&void 0!==r&&r})}}tS||(tS={});class tB extends tR{constructor(){super(...arguments),this.completions=new tS(this.client)}}(tB||(tB={})).Completions=tS;class tT extends tR{create(t,e){var r;return this.post("/completions",{body:t,...e,stream:null!==(r=t.stream)&&void 0!==r&&r})}}tT||(tT={});class tO extends tR{create(t,e){return this.post("/embeddings",{body:t,...e})}}tO||(tO={});class tP extends tR{create(t,e){return this.post("/edits",{body:t,...e})}}tP||(tP={});class tU extends tR{create(t,e){return this.post("/files",q({body:t,...e}))}retrieve(t,e){return this.get(`/files/${t}`,e)}list(t){return this.getAPIList("/files",tL,t)}del(t,e){return this.delete(`/files/${t}`,e)}retrieveContent(t,e){return this.get(`/files/${t}/content`,{...e,headers:{Accept:"application/json",...null==e?void 0:e.headers}})}}class tL extends tE{}tU||(tU={});class tk extends tR{create(t,e){return this.post("/fine-tunes",{body:t,...e})}retrieve(t,e){return this.get(`/fine-tunes/${t}`,e)}list(t){return this.getAPIList("/fine-tunes",tC,t)}cancel(t,e){return this.post(`/fine-tunes/${t}/cancel`,e)}listEvents(t,e,r){var n;return this.get(`/fine-tunes/${t}/events`,{query:e,timeout:864e5,...r,stream:null!==(n=null==e?void 0:e.stream)&&void 0!==n&&n})}}class tC extends tE{}tk||(tk={});class tj extends tR{create(t,e){return this.post("/fine_tuning/jobs",{body:t,...e})}retrieve(t,e){return this.get(`/fine_tuning/jobs/${t}`,e)}list(t={},e){return to(t)?this.list({},t):this.getAPIList("/fine_tuning/jobs",tN,{query:t,...e})}cancel(t,e){return this.post(`/fine_tuning/jobs/${t}/cancel`,e)}listEvents(t,e={},r){return to(e)?this.listEvents(t,{},e):this.getAPIList(`/fine_tuning/jobs/${t}/events`,t$,{query:e,...r})}}class tN extends tx{}class t$ extends tx{}tj||(tj={});class tF extends tR{constructor(){super(...arguments),this.jobs=new tj(this.client)}}(o=tF||(tF={})).Jobs=tj,o.FineTuningJobsPage=tN,o.FineTuningJobEventsPage=t$;class tD extends tR{createVariation(t,e){return this.post("/images/variations",q({body:t,...e}))}edit(t,e){return this.post("/images/edits",q({body:t,...e}))}generate(t,e){return this.post("/images/generations",{body:t,...e})}}tD||(tD={});class tM extends tR{retrieve(t,e){return this.get(`/models/${t}`,e)}list(t){return this.getAPIList("/models",tV,t)}del(t,e){return this.delete(`/models/${t}`,e)}}class tV extends tE{}tM||(tM={});class tW extends tR{create(t,e){return this.post("/moderations",{body:t,...e})}}tW||(tW={});class tq extends tt{constructor(t){var e,r,{apiKey:n=ty("OPENAI_API_KEY"),organization:i=null!==(e=ty("OPENAI_ORG_ID"))&&void 0!==e?e:null,...o}=void 0===t?{}:t;if(void 0===n)throw Error("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'my apiKey' }).");let s={apiKey:n,organization:i,baseURL:"https://api.openai.com/v1",...o};if(!s.dangerouslyAllowBrowser&&tv())throw Error("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");super({baseURL:s.baseURL,timeout:null!==(r=s.timeout)&&void 0!==r?r:6e5,httpAgent:s.httpAgent,maxRetries:s.maxRetries,fetch:s.fetch}),this.completions=new tT(this),this.chat=new tB(this),this.edits=new tP(this),this.embeddings=new tO(this),this.files=new tU(this),this.images=new tD(this),this.audio=new tI(this),this.moderations=new tW(this),this.models=new tM(this),this.fineTuning=new tF(this),this.fineTunes=new tk(this),this._options=s,this.apiKey=n,this.organization=i}defaultQuery(){return this._options.defaultQuery}defaultHeaders(t){return{...super.defaultHeaders(t),"OpenAI-Organization":this.organization,...this._options.defaultHeaders}}authHeaders(t){return{Authorization:`Bearer ${this.apiKey}`}}}u=tq,tq.OpenAI=u,tq.APIError=g,tq.APIConnectionError=m,tq.APIConnectionTimeoutError=b,tq.APIUserAbortError=y,tq.NotFoundError=x,tq.ConflictError=R,tq.RateLimitError=_,tq.BadRequestError=w,tq.AuthenticationError=v,tq.InternalServerError=I,tq.PermissionDeniedError=E,tq.UnprocessableEntityError=A;let{APIError:tX,APIConnectionError:tz,APIConnectionTimeoutError:tH,APIUserAbortError:tJ,NotFoundError:tK,ConflictError:tG,RateLimitError:tY,BadRequestError:tQ,AuthenticationError:tZ,InternalServerError:t0,PermissionDeniedError:t1,UnprocessableEntityError:t2}=l;(s=tq||(tq={})).toFile=$,s.fileFromPath=U,s.Page=tE,s.CursorPage=tx,s.Completions=tT,s.Chat=tB,s.Edits=tP,s.Embeddings=tO,s.Files=tU,s.FileObjectsPage=tL,s.Images=tD,s.Audio=tI,s.Moderations=tW,s.Models=tM,s.ModelsPage=tV,s.FineTuning=tF,s.FineTunes=tk,s.FineTunesPage=tC}}]);