@formant/data-sdk 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/data-sdk.es.js +519 -583
- package/dist/data-sdk.umd.js +9 -9
- package/dist/types/data-sdk/src/main.d.ts +20 -15
- package/package.json +4 -2
package/dist/data-sdk.umd.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(it,Ve){typeof exports=="object"&&typeof module<"u"?Ve(exports,require("date-fns")):typeof define=="function"&&define.amd?define(["exports","date-fns"],Ve):(it=typeof globalThis<"u"?globalThis:it||self,Ve(it.FormantDataSDK={},it.dateFns))})(this,function(exports,dateFns){var it;"use strict";var un=Object.defineProperty;var cn=(it,Ve,lt)=>Ve in it?un(it,Ve,{enumerable:!0,configurable:!0,writable:!0,value:lt}):it[Ve]=lt;var Te=(it,Ve,lt)=>(cn(it,typeof Ve!="symbol"?Ve+"":Ve,lt),lt);function _interopNamespaceDefault(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const dateFns__namespace=_interopNamespaceDefault(dateFns),global$1=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{};var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,inited=!1;function init(){inited=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,n=e.length;t<n;++t)lookup[t]=e[t],revLookup[e.charCodeAt(t)]=t;revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63}function toByteArray(e){inited||init();var t,n,r,i,s,l,o=e.length;if(o%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=e[o-2]==="="?2:e[o-1]==="="?1:0,l=new Arr(o*3/4-s),r=s>0?o-4:o;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)i=revLookup[e.charCodeAt(t)]<<18|revLookup[e.charCodeAt(t+1)]<<12|revLookup[e.charCodeAt(t+2)]<<6|revLookup[e.charCodeAt(t+3)],l[c++]=i>>16&255,l[c++]=i>>8&255,l[c++]=i&255;return s===2?(i=revLookup[e.charCodeAt(t)]<<2|revLookup[e.charCodeAt(t+1)]>>4,l[c++]=i&255):s===1&&(i=revLookup[e.charCodeAt(t)]<<10|revLookup[e.charCodeAt(t+1)]<<4|revLookup[e.charCodeAt(t+2)]>>2,l[c++]=i>>8&255,l[c++]=i&255),l}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,n){for(var r,i=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(tripletToBase64(r));return i.join("")}function fromByteArray(e){inited||init();for(var t,n=e.length,r=n%3,i="",s=[],l=16383,o=0,c=n-r;o<c;o+=l)s.push(encodeChunk(e,o,o+l>c?c:o+l));return r===1?(t=e[n-1],i+=lookup[t>>2],i+=lookup[t<<4&63],i+="=="):r===2&&(t=(e[n-2]<<8)+e[n-1],i+=lookup[t>>10],i+=lookup[t>>4&63],i+=lookup[t<<2&63],i+="="),s.push(i),s.join("")}function read(e,t,n,r,i){var s,l,o=i*8-r-1,c=(1<<o)-1,u=c>>1,f=-7,E=n?i-1:0,_=n?-1:1,h=e[t+E];for(E+=_,s=h&(1<<-f)-1,h>>=-f,f+=o;f>0;s=s*256+e[t+E],E+=_,f-=8);for(l=s&(1<<-f)-1,s>>=-f,f+=r;f>0;l=l*256+e[t+E],E+=_,f-=8);if(s===0)s=1-u;else{if(s===c)return l?NaN:(h?-1:1)*(1/0);l=l+Math.pow(2,r),s=s-u}return(h?-1:1)*l*Math.pow(2,s-r)}function write(e,t,n,r,i,s){var l,o,c,u=s*8-i-1,f=(1<<u)-1,E=f>>1,_=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:s-1,g=r?1:-1,b=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,l=f):(l=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-l))<1&&(l--,c*=2),l+E>=1?t+=_/c:t+=_*Math.pow(2,1-E),t*c>=2&&(l++,c/=2),l+E>=f?(o=0,l=f):l+E>=1?(o=(t*c-1)*Math.pow(2,i),l=l+E):(o=t*Math.pow(2,E-1)*Math.pow(2,i),l=0));i>=8;e[n+h]=o&255,h+=g,o/=256,i-=8);for(l=l<<i|o,u+=i;u>0;e[n+h]=l&255,h+=g,l/=256,u-=8);e[n+h-g]|=b*128}var toString={}.toString,isArray$1=Array.isArray||function(e){return toString.call(e)=="[object Array]"};/*!
|
|
2
2
|
* The buffer module from node.js, for the browser.
|
|
3
3
|
*
|
|
4
4
|
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
5
5
|
* @license MIT
|
|
6
|
-
*/var INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global$1.TYPED_ARRAY_SUPPORT!==void 0?global$1.TYPED_ARRAY_SUPPORT:!0,kMaxLength();function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()<t)throw new RangeError("Invalid typed array length");return Buffer.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=Buffer.prototype):(e===null&&(e=new Buffer(t)),e.length=t),e}function Buffer(e,t,n){if(!Buffer.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer))return new Buffer(e,t,n);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(this,e)}return from(this,e,t,n)}Buffer.poolSize=8192,Buffer._augment=function(e){return e.__proto__=Buffer.prototype,e};function from(e,t,n,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?fromArrayBuffer(e,t,n,r):typeof t=="string"?fromString(e,t,n):fromObject(e,t)}Buffer.from=function(e,t,n){return from(null,e,t,n)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array);function assertSize(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function alloc(e,t,n,r){return assertSize(t),t<=0?createBuffer(e,t):n!==void 0?typeof r=="string"?createBuffer(e,t).fill(n,r):createBuffer(e,t).fill(n):createBuffer(e,t)}Buffer.alloc=function(e,t,n){return alloc(null,e,t,n)};function allocUnsafe(e,t){if(assertSize(t),e=createBuffer(e,t<0?0:checked(t)|0),!Buffer.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}Buffer.allocUnsafe=function(e){return allocUnsafe(null,e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(null,e)};function fromString(e,t,n){if((typeof n!="string"||n==="")&&(n="utf8"),!Buffer.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=byteLength(t,n)|0;e=createBuffer(e,r);var i=e.write(t,n);return i!==r&&(e=e.slice(0,i)),e}function fromArrayLike(e,t){var n=t.length<0?0:checked(t.length)|0;e=createBuffer(e,n);for(var r=0;r<n;r+=1)e[r]=t[r]&255;return e}function fromArrayBuffer(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return n===void 0&&r===void 0?t=new Uint8Array(t):r===void 0?t=new Uint8Array(t,n):t=new Uint8Array(t,n,r),Buffer.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=Buffer.prototype):e=fromArrayLike(e,t),e}function fromObject(e,t){if(internalIsBuffer(t)){var n=checked(t.length)|0;return e=createBuffer(e,n),e.length===0||t.copy(e,0,0,n),e}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||isnan(t.length)?createBuffer(e,0):fromArrayLike(e,t);if(t.type==="Buffer"&&isArray$1(t.data))return fromArrayLike(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(e){if(e>=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return e|0}Buffer.isBuffer=isBuffer;function internalIsBuffer(e){return!!(e!=null&&e._isBuffer)}Buffer.compare=function(t,n){if(!internalIsBuffer(t)||!internalIsBuffer(n))throw new TypeError("Arguments must be Buffers");if(t===n)return 0;for(var r=t.length,i=n.length,s=0,l=Math.min(r,i);s<l;++s)if(t[s]!==n[s]){r=t[s],i=n[s];break}return r<i?-1:i<r?1:0},Buffer.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}},Buffer.concat=function(t,n){if(!isArray$1(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return Buffer.alloc(0);var r;if(n===void 0)for(n=0,r=0;r<t.length;++r)n+=t[r].length;var i=Buffer.allocUnsafe(n),s=0;for(r=0;r<t.length;++r){var l=t[r];if(!internalIsBuffer(l))throw new TypeError('"list" argument must be an Array of Buffers');l.copy(i,s),s+=l.length}return i};function byteLength(e,t){if(internalIsBuffer(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var n=e.length;if(n===0)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return base64ToBytes(e).length;default:if(r)return utf8ToBytes(e).length;t=(""+t).toLowerCase(),r=!0}}Buffer.byteLength=byteLength;function slowToString(e,t,n){var r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,n);case"utf8":case"utf-8":return utf8Slice(this,t,n);case"ascii":return asciiSlice(this,t,n);case"latin1":case"binary":return latin1Slice(this,t,n);case"base64":return base64Slice(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}Buffer.prototype._isBuffer=!0;function swap(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}Buffer.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<t;n+=2)swap(this,n,n+1);return this},Buffer.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<t;n+=4)swap(this,n,n+3),swap(this,n+1,n+2);return this},Buffer.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<t;n+=8)swap(this,n,n+7),swap(this,n+1,n+6),swap(this,n+2,n+5),swap(this,n+3,n+4);return this},Buffer.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?utf8Slice(this,0,t):slowToString.apply(this,arguments)},Buffer.prototype.equals=function(t){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:Buffer.compare(this,t)===0},Buffer.prototype.inspect=function(){var t="",n=INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},Buffer.prototype.compare=function(t,n,r,i,s){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");if(n===void 0&&(n=0),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),n<0||r>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&n>=r)return 0;if(i>=s)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var l=s-i,o=r-n,c=Math.min(l,o),u=this.slice(i,s),f=t.slice(n,r),E=0;E<c;++E)if(u[E]!==f[E]){l=u[E],o=f[E];break}return l<o?-1:o<l?1:0};function bidirectionalIndexOf(e,t,n,r,i){if(e.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t=="string"&&(t=Buffer.from(t,r)),internalIsBuffer(t))return t.length===0?-1:arrayIndexOf(e,t,n,r,i);if(typeof t=="number")return t=t&255,Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):arrayIndexOf(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,n,r,i){var s=1,l=e.length,o=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,l/=2,o/=2,n/=2}function c(h,g){return s===1?h[g]:h.readUInt16BE(g*s)}var u;if(i){var f=-1;for(u=n;u<l;u++)if(c(e,u)===c(t,f===-1?0:u-f)){if(f===-1&&(f=u),u-f+1===o)return f*s}else f!==-1&&(u-=u-f),f=-1}else for(n+o>l&&(n=l-o),u=n;u>=0;u--){for(var E=!0,_=0;_<o;_++)if(c(e,u+_)!==c(t,_)){E=!1;break}if(E)return u}return-1}Buffer.prototype.includes=function(t,n,r){return this.indexOf(t,n,r)!==-1},Buffer.prototype.indexOf=function(t,n,r){return bidirectionalIndexOf(this,t,n,r,!0)},Buffer.prototype.lastIndexOf=function(t,n,r){return bidirectionalIndexOf(this,t,n,r,!1)};function hexWrite(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var s=t.length;if(s%2!==0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var l=0;l<r;++l){var o=parseInt(t.substr(l*2,2),16);if(isNaN(o))return l;e[n+l]=o}return l}function utf8Write(e,t,n,r){return blitBuffer(utf8ToBytes(t,e.length-n),e,n,r)}function asciiWrite(e,t,n,r){return blitBuffer(asciiToBytes(t),e,n,r)}function latin1Write(e,t,n,r){return asciiWrite(e,t,n,r)}function base64Write(e,t,n,r){return blitBuffer(base64ToBytes(t),e,n,r)}function ucs2Write(e,t,n,r){return blitBuffer(utf16leToBytes(t,e.length-n),e,n,r)}Buffer.prototype.write=function(t,n,r,i){if(n===void 0)i="utf8",r=this.length,n=0;else if(r===void 0&&typeof n=="string")i=n,r=this.length,n=0;else if(isFinite(n))n=n|0,isFinite(r)?(r=r|0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-n;if((r===void 0||r>s)&&(r=s),t.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var l=!1;;)switch(i){case"hex":return hexWrite(this,t,n,r);case"utf8":case"utf-8":return utf8Write(this,t,n,r);case"ascii":return asciiWrite(this,t,n,r);case"latin1":case"binary":return latin1Write(this,t,n,r);case"base64":return base64Write(this,t,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,n,r);default:if(l)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),l=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(e,t,n){return t===0&&n===e.length?fromByteArray(e):fromByteArray(e.slice(t,n))}function utf8Slice(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s=e[i],l=null,o=s>239?4:s>223?3:s>191?2:1;if(i+o<=n){var c,u,f,E;switch(o){case 1:s<128&&(l=s);break;case 2:c=e[i+1],(c&192)===128&&(E=(s&31)<<6|c&63,E>127&&(l=E));break;case 3:c=e[i+1],u=e[i+2],(c&192)===128&&(u&192)===128&&(E=(s&15)<<12|(c&63)<<6|u&63,E>2047&&(E<55296||E>57343)&&(l=E));break;case 4:c=e[i+1],u=e[i+2],f=e[i+3],(c&192)===128&&(u&192)===128&&(f&192)===128&&(E=(s&15)<<18|(c&63)<<12|(u&63)<<6|f&63,E>65535&&E<1114112&&(l=E))}}l===null?(l=65533,o=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l),i+=o}return decodeCodePointsArray(r)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=MAX_ARGUMENTS_LENGTH));return n}function asciiSlice(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function latin1Slice(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function hexSlice(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=t;s<n;++s)i+=toHex(e[s]);return i}function utf16leSlice(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+r[s+1]*256);return i}Buffer.prototype.slice=function(t,n){var r=this.length;t=~~t,n=n===void 0?r:~~n,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n<t&&(n=t);var i;if(Buffer.TYPED_ARRAY_SUPPORT)i=this.subarray(t,n),i.__proto__=Buffer.prototype;else{var s=n-t;i=new Buffer(s,void 0);for(var l=0;l<s;++l)i[l]=this[l+t]}return i};function checkOffset(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(t,n,r){t=t|0,n=n|0,r||checkOffset(t,n,this.length);for(var i=this[t],s=1,l=0;++l<n&&(s*=256);)i+=this[t+l]*s;return i},Buffer.prototype.readUIntBE=function(t,n,r){t=t|0,n=n|0,r||checkOffset(t,n,this.length);for(var i=this[t+--n],s=1;n>0&&(s*=256);)i+=this[t+--n]*s;return i},Buffer.prototype.readUInt8=function(t,n){return n||checkOffset(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,n){return n||checkOffset(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,n){return n||checkOffset(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,n){return n||checkOffset(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},Buffer.prototype.readUInt32BE=function(t,n){return n||checkOffset(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,n,r){t=t|0,n=n|0,r||checkOffset(t,n,this.length);for(var i=this[t],s=1,l=0;++l<n&&(s*=256);)i+=this[t+l]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*n)),i},Buffer.prototype.readIntBE=function(t,n,r){t=t|0,n=n|0,r||checkOffset(t,n,this.length);for(var i=n,s=1,l=this[t+--i];i>0&&(s*=256);)l+=this[t+--i]*s;return s*=128,l>=s&&(l-=Math.pow(2,8*n)),l},Buffer.prototype.readInt8=function(t,n){return n||checkOffset(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},Buffer.prototype.readInt16LE=function(t,n){n||checkOffset(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r},Buffer.prototype.readInt16BE=function(t,n){n||checkOffset(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r},Buffer.prototype.readInt32LE=function(t,n){return n||checkOffset(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,n){return n||checkOffset(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,n){return n||checkOffset(t,4,this.length),read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,n){return n||checkOffset(t,4,this.length),read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,n){return n||checkOffset(t,8,this.length),read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,n){return n||checkOffset(t,8,this.length),read(this,t,!1,52,8)};function checkInt(e,t,n,r,i,s){if(!internalIsBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function(t,n,r,i){if(t=+t,n=n|0,r=r|0,!i){var s=Math.pow(2,8*r)-1;checkInt(this,t,n,r,s,0)}var l=1,o=0;for(this[n]=t&255;++o<r&&(l*=256);)this[n+o]=t/l&255;return n+r},Buffer.prototype.writeUIntBE=function(t,n,r,i){if(t=+t,n=n|0,r=r|0,!i){var s=Math.pow(2,8*r)-1;checkInt(this,t,n,r,s,0)}var l=r-1,o=1;for(this[n+l]=t&255;--l>=0&&(o*=256);)this[n+l]=t/o&255;return n+r},Buffer.prototype.writeUInt8=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[n]=t&255,n+1};function objectWriteUInt16(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-n,2);i<s;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}Buffer.prototype.writeUInt16LE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t&255,this[n+1]=t>>>8):objectWriteUInt16(this,t,n,!0),n+2},Buffer.prototype.writeUInt16BE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=t&255):objectWriteUInt16(this,t,n,!1),n+2};function objectWriteUInt32(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-n,4);i<s;++i)e[n+i]=t>>>(r?i:3-i)*8&255}Buffer.prototype.writeUInt32LE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255):objectWriteUInt32(this,t,n,!0),n+4},Buffer.prototype.writeUInt32BE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255):objectWriteUInt32(this,t,n,!1),n+4},Buffer.prototype.writeIntLE=function(t,n,r,i){if(t=+t,n=n|0,!i){var s=Math.pow(2,8*r-1);checkInt(this,t,n,r,s-1,-s)}var l=0,o=1,c=0;for(this[n]=t&255;++l<r&&(o*=256);)t<0&&c===0&&this[n+l-1]!==0&&(c=1),this[n+l]=(t/o>>0)-c&255;return n+r},Buffer.prototype.writeIntBE=function(t,n,r,i){if(t=+t,n=n|0,!i){var s=Math.pow(2,8*r-1);checkInt(this,t,n,r,s-1,-s)}var l=r-1,o=1,c=0;for(this[n+l]=t&255;--l>=0&&(o*=256);)t<0&&c===0&&this[n+l+1]!==0&&(c=1),this[n+l]=(t/o>>0)-c&255;return n+r},Buffer.prototype.writeInt8=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[n]=t&255,n+1},Buffer.prototype.writeInt16LE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t&255,this[n+1]=t>>>8):objectWriteUInt16(this,t,n,!0),n+2},Buffer.prototype.writeInt16BE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=t&255):objectWriteUInt16(this,t,n,!1),n+2},Buffer.prototype.writeInt32LE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):objectWriteUInt32(this,t,n,!0),n+4},Buffer.prototype.writeInt32BE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255):objectWriteUInt32(this,t,n,!1),n+4};function checkIEEE754(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function writeFloat(e,t,n,r,i){return i||checkIEEE754(e,t,n,4),write(e,t,n,r,23,4),n+4}Buffer.prototype.writeFloatLE=function(t,n,r){return writeFloat(this,t,n,!0,r)},Buffer.prototype.writeFloatBE=function(t,n,r){return writeFloat(this,t,n,!1,r)};function writeDouble(e,t,n,r,i){return i||checkIEEE754(e,t,n,8),write(e,t,n,r,52,8),n+8}Buffer.prototype.writeDoubleLE=function(t,n,r){return writeDouble(this,t,n,!0,r)},Buffer.prototype.writeDoubleBE=function(t,n,r){return writeDouble(this,t,n,!1,r)},Buffer.prototype.copy=function(t,n,r,i){if(r||(r=0),!i&&i!==0&&(i=this.length),n>=t.length&&(n=t.length),n||(n=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-n<i-r&&(i=t.length-n+r);var s=i-r,l;if(this===t&&r<n&&n<i)for(l=s-1;l>=0;--l)t[l+n]=this[l+r];else if(s<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(l=0;l<s;++l)t[l+n]=this[l+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),n);return s},Buffer.prototype.fill=function(t,n,r,i){if(typeof t=="string"){if(typeof n=="string"?(i=n,n=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),t.length===1){var s=t.charCodeAt(0);s<256&&(t=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!Buffer.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n=n>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var l;if(typeof t=="number")for(l=n;l<r;++l)this[l]=t;else{var o=internalIsBuffer(t)?t:utf8ToBytes(new Buffer(t,i).toString()),c=o.length;for(l=0;l<r-n;++l)this[l+n]=o[l%c]}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g;function base64clean(e){if(e=stringtrim(e).replace(INVALID_BASE64_RE,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function stringtrim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function toHex(e){return e<16?"0"+e.toString(16):e.toString(16)}function utf8ToBytes(e,t){t=t||1/0;for(var n,r=e.length,i=null,s=[],l=0;l<r;++l){if(n=e.charCodeAt(l),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(l+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return s}function asciiToBytes(e){for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function utf16leToBytes(e,t){for(var n,r,i,s=[],l=0;l<e.length&&!((t-=2)<0);++l)n=e.charCodeAt(l),r=n>>8,i=n%256,s.push(i),s.push(r);return s}function base64ToBytes(e){return toByteArray(base64clean(e))}function blitBuffer(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function isnan(e){return e!==e}function isBuffer(e){return e!=null&&(!!e._isBuffer||isFastBuffer(e)||isSlowBuffer(e))}function isFastBuffer(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&isFastBuffer(e.slice(0,0))}function defined(e,t){if(e!==void 0)return e;throw new Error(t||"Value is undefined")}const DEFAULT_FORMANT_API_URL="https://api.formant.io";function whichFormantApiUrl(e,t){if(t.get("formant_stage"))return"https://api-stage.formant.io";if(t.get("formant_dev"))return"https://api-dev.formant.io";if(t.get("formant_local"))return"https://api.formant.local";if(t.get("formant_url")){const n=t.get("formant_url");if(n!==null)try{return new URL(n).origin}catch{console.warn(`Ignoring malformed \`formant_url\` url parameter: ${n}`)}}return typeof e<"u"&&"FORMANT_API_URL"in e&&typeof e.FORMANT_API_URL=="string"?e.FORMANT_API_URL:DEFAULT_FORMANT_API_URL}const FORMANT_API_URL=whichFormantApiUrl(window,new URLSearchParams(typeof window<"u"?window.location.search:void 0)),millisecond=1,second=1e3,minute=60*second,hour=60*minute,day=24*hour,week=7*day,month=30*day,year=365*day,duration={millisecond,second,minute,hour,day,week,month,year};function filterDataByType(e,t){return e.filter(n=>t.includes(n.type))}function filterDataByTime(e,t,n){const r=t.getTime(),i=n.getTime();return e.map(s=>({...s,points:s.points.filter(([l])=>l>=r&&l<i)})).filter(({points:s})=>s.length>0)}function fork(e){}class StoreCache{constructor({capacity:t,timeout:n}={}){Te(this,"entries",new Map);Te(this,"metadata",new Map);Te(this,"capacity");Te(this,"timeout");this.capacity=t||1e4,this.timeout=n||duration.minute}get(t,n){const r=this.keyToCacheKey(t),i=this.entries.get(r),s=this.metadata.get(r);return(i===void 0||s&&(s==null?void 0:s.expiration.getTime())<Date.now())&&!(s!=null&&s.generating)&&n&&this.generate(t,n()),i===void 0&&s&&s.lastValue!==void 0?s.lastValue:i}set(t,n){const r=this.keyToCacheKey(t);this.metadata.set(r,{generating:!1,expiration:new Date(Date.now()+this.timeout),lastValue:n}),this.entries.set(r,n),this.metadata.size>this.capacity&&this.deleteOldestEntry()}clear(){this.entries.clear(),[...this.metadata.values()].forEach(t=>t.generating=!1)}clearKey(t){this.metadata.delete(t),this.entries.delete(t)}keyToCacheKey(t){return JSON.stringify(t)}deleteOldestEntry(){if(this.metadata.size<1)return;const[t]=[...this.metadata.entries()].reduce(([n,r],[i,s])=>s.expiration.getTime()<r.expiration.getTime()?[i,s]:[n,r]);this.clearKey(t)}generate(t,n){const r=this.keyToCacheKey(t),i=this.metadata.get(r)||{};this.metadata.set(r,{...i,generating:!0,expiration:new Date(Date.now()+this.timeout)}),setTimeout(()=>{n.then(s=>{const l=this.metadata.get(r);!(l!=null&&l.generating)||this.set(t,s)})},0)}}class QueryStore{constructor(){Te(this,"queryStoreCache",new StoreCache({capacity:1e4,timeout:20*duration.second}));Te(this,"liveQueryStoreCache",new StoreCache({capacity:1e4,timeout:200*duration.millisecond}))}moduleQuery(t,n,r,i,s,l=!1){const o={...t,names:[...n],types:[...r]},c=this.query(o,i,s,l);return c===void 0||c==="too much data"?c:filterDataByType(c,r)}query(t,n,r,i=!1){const s={...t,start:dateFns.startOfMinute(n).toISOString(),end:i?r.toISOString():dateFns.addMinutes(dateFns.roundToNearestMinutes(r),1).toISOString(),latestOnly:i},l=r>dateFns.addSeconds(new Date,-20);let o;return l?o=this.liveQueryCache(s):o=this.queryCache(s),!o||o==="too much data"||i?o:filterDataByTime(o,n,r)}queryCache(t){return this.queryStoreCache.get(t,async()=>{try{return await Fleet.queryTelemetry(t)}catch(n){throw n}})}liveQueryCache(t){return this.liveQueryStoreCache.get(t,async()=>{try{return await Fleet.queryTelemetry(t)}catch(n){throw n}})}}const queryStore=new QueryStore,Ke=class{static sendAppMessage(t){window.parent.postMessage(t,"*")}static getCurrentModuleContext(){let t=new URLSearchParams("");return typeof window<"u"&&(t=new URLSearchParams(window.location.search)),t.get("module")}static async getCurrentModuleConfiguration(){let t=new URLSearchParams("");typeof window<"u"&&(t=new URLSearchParams(window.location.search));const n=t.get("configuration");return n===null||n.trim()===""?void 0:(await(await fetch(`${FORMANT_API_URL}/v1/admin/module-configurations/`+n,{headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).configuration}static isModule(){return this.getCurrentModuleContext()!==null}static goToTime(t){this.sendAppMessage({type:"go_to_time",time:t.getTime()})}static goToDevice(t){this.sendAppMessage({type:"go_to_device",deviceId:t})}static showMessage(t){this.sendAppMessage({type:"show_message",message:t})}static requestModuleData(){const t=this.getCurrentModuleContext();if(!t)throw new Error("No module context");this.sendAppMessage({type:"request_module_data",module:t})}static setModuleDateTimeRange(t,n){const r=this.getCurrentModuleContext();if(!r)throw new Error("No module context");this.sendAppMessage({type:"set_module_data_time_range",module:r,before:t,after:n||0})}static refreshAuthToken(){const t=this.getCurrentModuleContext();if(!t)throw new Error("No module context");this.sendAppMessage({type:"refresh_auth_token",module:t})}static sendChannelData(t,n){const r=this.getCurrentModuleContext();if(!r)throw new Error("No module context");this.sendAppMessage({type:"send_channel_data",source:r,channel:t,data:n})}static setupModuleMenus(t){const n=this.getCurrentModuleContext();if(!n)throw new Error("No module context");this.sendAppMessage({type:"setup_module_menus",module:n,menus:t})}static addMenuListener(t){window.addEventListener("message",n=>{const r=n.data;r.type==="module_menu_item_clicked"&&t(r.menu)})}static addAccessTokenRefreshListener(t){window.addEventListener("message",n=>{const r=n.data;r.type==="auth_token"&&t(r.token)})}static addModuleDataListener(t){const n=this.getCurrentModuleContext();n&&this.sendAppMessage({type:"request_module_data",module:n}),window.addEventListener("message",r=>{const i=r.data;i.type==="module_data"&&t({streams:i.streams,time:i.time,queryRange:i.queryRange})})}static addOverviewDeviceListener(t){this.sendAppMessage({type:"request_devices"});const n=r=>{const i=r.data;i.type==="overview_devices"&&t(i.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}static addStreamListener(t,n,r){const i=s=>{const l=s.data;if(l.type==="module_data"){const{start:o,end:c}=l.queryRange;r(queryStore.moduleQuery({},t,n,new Date(o),new Date(c),!1))}};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)}static addModuleConfigurationListener(t){window.addEventListener("message",n=>{const r=n.data;r.type==="module_configuration"&&t(r)})}static addChannelDataListener(t,n){window.addEventListener("message",r=>{const i=r.data;i.type==="channel_data"&&i.channel===t&&n({source:i.source,data:i.data})})}static async prompt(t,n){return new Promise(r=>{const i=Math.random().toString();this.sendAppMessage({type:"prompt",promptId:i,schema:t,okText:n==null?void 0:n.okText,cancelText:n==null?void 0:n.cancelText});const s=l=>{const o=l.data;o.type==="prompt_response"&&o.promptId===i&&r(o.data),window.removeEventListener("message",s)};window.addEventListener("message",s)})}static async getDate(t,n,r){return new Promise(i=>{this.sendAppMessage({type:"request_date",minTime:n,maxTime:r,time:t});const s=l=>{const o=l.data;o.type==="date_response"&&(window.removeEventListener("message",s),i(o.data))};window.addEventListener("message",s)})}static async disableAnalyticsBottomBar(){this.sendAppMessage({type:"hide_analytics_date_picker"})}static get isOnline(){return Ke._isOnline}static listenForConnectionEvents(){window.addEventListener("message",this._handleOnlineEvent)}static checkConnection(t=1e3){return new Promise((n,r)=>{const i=setTimeout(()=>r(new Error("deadline expired: took too long")),t),s=l=>{window.removeEventListener("message",s),clearTimeout(i);const{data:o}=l;o.type==="formant_online"&&(this._isOnline=o.online,n(o.online))};window.addEventListener("message",s),this.sendAppMessage({type:"formant_online"})})}static waitForConnection(t=5e3){let n=!1;const r=new Promise((l,o)=>{setTimeout(()=>{n=!0,o(new Error("deadline expired: took too long"))},t)}),i=l=>new Promise(o=>setTimeout(o,l)),s=async()=>{for(await i(50);!n&&!(this.isOnline||await this.checkConnection);)await i(500)};return Promise.race([r,s()])}};let App=Ke;Te(App,"_isOnline",null),Te(App,"_handleOnlineEvent",t=>{const{data:n}=t;n.type==="formant_online"&&(Ke._isOnline=n.online)});class AuthenticationStore{constructor({apiUrl:t,refreshAuthToken:n,addAccessTokenRefreshListener:r}){Te(this,"_refreshToken");Te(this,"_isShareToken",!1);Te(this,"_currentOrganization");Te(this,"_currentUser");Te(this,"_defaultDeviceId");Te(this,"_token");Te(this,"_waitingForAuth",new Set);Te(this,"_refreshTimer");Te(this,"_apiUrl");Te(this,"_refreshAuthToken");Te(this,"_addAccessTokenRefreshListener");this._apiUrl=t,this._refreshAuthToken=n,this._addAccessTokenRefreshListener=r}get token(){return this._token}get currentUser(){return this._currentUser}get currentOrganization(){return this._currentOrganization}get defaultDeviceId(){return this._defaultDeviceId}get refreshToken(){return this._refreshToken}get isShareToken(){return this._isShareToken}async login(t,n){try{const r=await fetch(`${this._apiUrl}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:n}),headers:{"Content-Type":"application/json"}}),i=await r.json();if(r.status!==200)throw new Error(i.message);return await this.loginWithToken(i.authentication.accessToken,i.authentication.refreshToken),i.authentication}catch(r){return console.error("login() failed",{err:r}),this._waitingForAuth.forEach(i=>i(!1)),this._waitingForAuth.clear(),Promise.reject(r)}}async loginWithToken(t,n){var i;const r=JSON.parse(atob(t.split(".")[1]));try{let s;if(this._isShareToken=r["formant:claims"]&&r["formant:claims"].type=="share",r["formant:claims"]&&(this._currentOrganization=r["formant:claims"].organizationId),r["custom:organization_id"]&&(this._currentOrganization=r["custom:organization_id"]),this._isShareToken||(s=r.sub),r["formant:claims"]&&r["formant:claims"].userId&&(s=r["formant:claims"].userId),s&&((i=this._currentUser)==null?void 0:i.id)!==s){const l=await fetch(`${this._apiUrl}/v1/admin/users/${s}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),o=await l.json();if(l.status!==200)throw new Error(o.message);this._currentUser=o}this._token=t,this._waitingForAuth.forEach(l=>l(!0))}catch(s){console.error("loginWithToken() failed",{err:s}),this._waitingForAuth.forEach(l=>l(!1))}finally{this._waitingForAuth.clear()}n&&(this._refreshToken=n,setInterval(async()=>{if(this._refreshToken){const l=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:this._refreshToken})})).json();this._token=l.authentication.accessToken}},1e3*60*60))}isAuthenticated(){return this._token!==void 0}getCurrentUser(){return this._currentUser}async waitTilAuthenticated(){return this.token!==void 0?!0:new Promise(t=>{this._waitingForAuth.add(t)})}async listenForRefresh(){const n=()=>{this._refreshTimer=void 0,this._refreshAuthToken()};this._addAccessTokenRefreshListener(r=>{this._refreshTimer&&clearTimeout(this._refreshTimer),this._refreshTimer=setTimeout(n,36e5),this.loginWithToken(r)}),this._refreshTimer=setTimeout(n,36e5)}async forgotPassword(t){await fetch(`${this._apiUrl}/v1/admin/auth/forgot-password`,{method:"POST",body:JSON.stringify({email:t}),headers:{"Content-Type":"application/json"}})}async confirmForgotPassword(t){return(await fetch(`${this._apiUrl}/v1/admin/auth/confirm-forgot-password`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).ok}async respondToNewPasswordRequiredChallenge(t){return await(await fetch(`${this._apiUrl}/v1/admin/auth/respond-to-new-password-required-challenge`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json()}async loginWithGoogle(t){return await(await fetch(`${this._apiUrl}/v1/admin/auth/login-google`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json()}async refresh(t){const r=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})})).json();await this.loginWithToken(r.authentication.accessToken,t)}}const Authentication=new AuthenticationStore({apiUrl:FORMANT_API_URL,refreshAuthToken:App.refreshAuthToken,addAccessTokenRefreshListener:App.addAccessTokenRefreshListener});var dist={exports:{}};/*! For license information please see index.js.LICENSE.txt */(function(module,exports){(function(e,t){module.exports=t()})(window,function(){return function(e){function t(u){for(var f,E,_=u[0],h=u[1],g=0,b=[];g<_.length;g++)E=_[g],Object.prototype.hasOwnProperty.call(r,E)&&r[E]&&b.push(r[E][0]),r[E]=0;for(f in h)Object.prototype.hasOwnProperty.call(h,f)&&(e[f]=h[f]);for(c&&c(u);b.length;)b.shift()()}var n={},r={0:0};function i(u){if(n[u])return n[u].exports;var f=n[u]={i:u,l:!1,exports:{}};return e[u].call(f.exports,f,f.exports,i),f.l=!0,f.exports}i.e=function(){return Promise.resolve()},i.m=e,i.c=n,i.d=function(u,f,E){i.o(u,f)||Object.defineProperty(u,f,{enumerable:!0,get:E})},i.r=function(u){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},i.t=function(u,f){if(1&f&&(u=i(u)),8&f||4&f&&typeof u=="object"&&u&&u.__esModule)return u;var E=Object.create(null);if(i.r(E),Object.defineProperty(E,"default",{enumerable:!0,value:u}),2&f&&typeof u!="string")for(var _ in u)i.d(E,_,function(h){return u[h]}.bind(null,_));return E},i.n=function(u){var f=u&&u.__esModule?function(){return u.default}:function(){return u};return i.d(f,"a",f),f},i.o=function(u,f){return Object.prototype.hasOwnProperty.call(u,f)},i.p="",i.oe=function(u){throw console.error(u),u};var s=window.webpackJsonpFormantRealtimeSDK=window.webpackJsonpFormantRealtimeSDK||[],l=s.push.bind(s);s.push=t,s=s.slice();for(var o=0;o<s.length;o++)t(s[o]);var c=l;return i(i.s=228)}([function(e,t,n){n.d(t,"a",function(){return G});function r(T,B){if(B.length<T)throw new TypeError(T+" argument"+(T>1?"s":"")+" required, but only "+B.length+" present")}function i(T){if(T===null||T===!0||T===!1)return NaN;var B=Number(T);return isNaN(B)?B:B<0?Math.ceil(B):Math.floor(B)}var s={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},l=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,o=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,c=/^([+-])(\d{2})(?::?(\d{2}))?$/;function u(T){var B,J={},K=T.split(s.dateTimeDelimiter);if(K.length>2)return J;if(/:/.test(K[0])?B=K[0]:(J.date=K[0],B=K[1],s.timeZoneDelimiter.test(J.date)&&(J.date=T.split(s.timeZoneDelimiter)[0],B=T.substr(J.date.length,T.length))),B){var re=s.timezone.exec(B);re?(J.time=B.replace(re[1],""),J.timezone=re[1]):J.time=B}return J}function f(T,B){var J=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+B)+"})|(\\d{2}|[+-]\\d{"+(2+B)+"})$)"),K=T.match(J);if(!K)return{year:NaN,restDateString:""};var re=K[1]?parseInt(K[1]):null,se=K[2]?parseInt(K[2]):null;return{year:se===null?re:100*se,restDateString:T.slice((K[1]||K[2]).length)}}function E(T,B){if(B===null)return new Date(NaN);var J=T.match(l);if(!J)return new Date(NaN);var K=!!J[4],re=_(J[1]),se=_(J[2])-1,fe=_(J[3]),ve=_(J[4]),Ie=_(J[5])-1;if(K)return function(Ce,Ae,Oe){return Ae>=1&&Ae<=53&&Oe>=0&&Oe<=6}(0,ve,Ie)?function(Ce,Ae,Oe){var Pe=new Date(0);Pe.setUTCFullYear(Ce,0,4);var qe=Pe.getUTCDay()||7,rt=7*(Ae-1)+Oe+1-qe;return Pe.setUTCDate(Pe.getUTCDate()+rt),Pe}(B,ve,Ie):new Date(NaN);var Se=new Date(0);return function(Ce,Ae,Oe){return Ae>=0&&Ae<=11&&Oe>=1&&Oe<=(A[Ae]||(j(Ce)?29:28))}(B,se,fe)&&function(Ce,Ae){return Ae>=1&&Ae<=(j(Ce)?366:365)}(B,re)?(Se.setUTCFullYear(B,se,Math.max(re,fe)),Se):new Date(NaN)}function _(T){return T?parseInt(T):1}function h(T){var B=T.match(o);if(!B)return NaN;var J=g(B[1]),K=g(B[2]),re=g(B[3]);return function(se,fe,ve){return se===24?fe===0&&ve===0:ve>=0&&ve<60&&fe>=0&&fe<60&&se>=0&&se<25}(J,K,re)?36e5*J+6e4*K+1e3*re:NaN}function g(T){return T&&parseFloat(T.replace(",","."))||0}function b(T){if(T==="Z")return 0;var B=T.match(c);if(!B)return 0;var J=B[1]==="+"?-1:1,K=parseInt(B[2]),re=B[3]&&parseInt(B[3])||0;return function(se,fe){return fe>=0&&fe<=59}(0,re)?J*(36e5*K+6e4*re):NaN}var A=[31,null,31,30,31,30,31,31,30,31,30,31];function j(T){return T%400==0||T%4==0&&T%100!=0}function F(T){return r(1,arguments),T instanceof Date||typeof T=="object"&&Object.prototype.toString.call(T)==="[object Date]"}function M(T){r(1,arguments);var B=Object.prototype.toString.call(T);return T instanceof Date||typeof T=="object"&&B==="[object Date]"?new Date(T.getTime()):typeof T=="number"||B==="[object Number]"?new Date(T):(typeof T!="string"&&B!=="[object String]"||typeof console>"u"||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function R(T){const B=function(J,K){var re;r(1,arguments);var se=i((re=K==null?void 0:K.additionalDigits)!==null&&re!==void 0?re:2);if(se!==2&&se!==1&&se!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(typeof J!="string"&&Object.prototype.toString.call(J)!=="[object String]")return new Date(NaN);var fe,ve=u(J);if(ve.date){var Ie=f(ve.date,se);fe=E(Ie.restDateString,Ie.year)}if(!fe||isNaN(fe.getTime()))return new Date(NaN);var Se,Ce=fe.getTime(),Ae=0;if(ve.time&&(Ae=h(ve.time),isNaN(Ae)))return new Date(NaN);if(!ve.timezone){var Oe=new Date(Ce+Ae),Pe=new Date(0);return Pe.setFullYear(Oe.getUTCFullYear(),Oe.getUTCMonth(),Oe.getUTCDate()),Pe.setHours(Oe.getUTCHours(),Oe.getUTCMinutes(),Oe.getUTCSeconds(),Oe.getUTCMilliseconds()),Pe}return Se=b(ve.timezone),isNaN(Se)?new Date(NaN):new Date(Ce+Ae+Se)}(T);if(!function(J){if(r(1,arguments),!F(J)&&typeof J!="number")return!1;var K=M(J);return!isNaN(Number(K))}(B))throw new Error(`Invalid ISO 8601 date string (${T})`);return B}const d=Math.pow(2,20),I=d;var $=n(14),q=n.n($),y=n(18),m=n(56),C=n(19),w=n(4),L=n(34);function W(T){return q()(T,{cycles:!0})}var k=function(T,B){var J={};for(var K in T)Object.prototype.hasOwnProperty.call(T,K)&&B.indexOf(K)<0&&(J[K]=T[K]);if(T!=null&&typeof Object.getOwnPropertySymbols=="function"){var re=0;for(K=Object.getOwnPropertySymbols(T);re<K.length;re++)B.indexOf(K[re])<0&&Object.prototype.propertyIsEnumerable.call(T,K[re])&&(J[K[re]]=T[K[re]])}return J};function N(T,B={}){const J=ve=>B.redacted!==!1?Object(L.a)(ve):ve;if(!T.stack)return{message:W(J(T))};const{name:K,message:re,stack:se}=T,fe=k(T,["name","message","stack"]);return{name:K,message:re!==void 0?re:W(J(T)),stack:se,meta:fe&&Object.keys(fe).length===0?void 0:J(fe)}}function P(T,B={}){const{message:J,stack:K,meta:re}=N(T,B);return`${K||J||""}${re&&Object.keys(re).length>0?` -- ${W(re)}`:""}`}var z=n(39),O=n(103),p=n.n(O),U=function(T,B,J,K){return new(J||(J=Promise))(function(re,se){function fe(Se){try{Ie(K.next(Se))}catch(Ce){se(Ce)}}function ve(Se){try{Ie(K.throw(Se))}catch(Ce){se(Ce)}}function Ie(Se){var Ce;Se.done?re(Se.value):(Ce=Se.value,Ce instanceof J?Ce:new J(function(Ae){Ae(Ce)})).then(fe,ve)}Ie((K=K.apply(T,B||[])).next())})},V=function(T,B){var J={};for(var K in T)Object.prototype.hasOwnProperty.call(T,K)&&B.indexOf(K)<0&&(J[K]=T[K]);if(T!=null&&typeof Object.getOwnPropertySymbols=="function"){var re=0;for(K=Object.getOwnPropertySymbols(T);re<K.length;re++)B.indexOf(K[re])<0&&Object.prototype.propertyIsEnumerable.call(T,K[re])&&(J[K[re]]=T[K[re]])}return J};class Q extends p.a{constructor(B,J){super(),this.endpoint=B,this.metadata=J,this.logClient=this.getLogClient()}getLogClient(){return U(this,void 0,void 0,function*(){const{LogClient:B}=yield Promise.resolve().then(n.bind(null,231));return new B(this.endpoint)})}log(B,J){return U(this,void 0,void 0,function*(){const{level:K,message:re,error:se}=B,fe=V(B,["level","message","error"]);this.emit("logged");try{yield(yield this.logClient).log([{timestamp:new Date().toISOString(),level:K,message:`${re}`.substring(0,1e3),error:se!==void 0?N(se):void 0,meta:Object.assign(Object.assign({},fe),this.metadata)}])}catch(ve){console.error(`Failed to log to log-api: ${P(ve)}`)}J()})}}var ee=function(T,B){var J={};for(var K in T)Object.prototype.hasOwnProperty.call(T,K)&&B.indexOf(K)<0&&(J[K]=T[K]);if(T!=null&&typeof Object.getOwnPropertySymbols=="function"){var re=0;for(K=Object.getOwnPropertySymbols(T);re<K.length;re++)B.indexOf(K[re])<0&&Object.prototype.propertyIsEnumerable.call(T,K[re])&&(J[K[re]]=T[K[re]])}return J};const ne={app:w.a,namespace:w.i,buildTag:w.b,instanceId:z.a},Y=w.e?C.format.printf(T=>{var{timestamp:B,level:J,message:K,error:re}=T,se=ee(T,["timestamp","level","message","error"]);const fe=Object.assign(Object.assign({timestamp:B?R(B).getTime():new Date().getTime(),level:J.toUpperCase(),message:K},re?{error:N(re)}:{}),{meta:Object.assign(Object.assign({},ne),se)});return q()(fe,{cycles:!0})}):C.format.printf(T=>{var{timestamp:B,level:J,message:K,error:re}=T,se=ee(T,["timestamp","level","message","error"]);let fe=`${B||new Date().toISOString()} ${J.toUpperCase()}: ${K} `;return Object.keys(se).length>0&&(fe+=q()(se,{cycles:!0})),re&&(fe+=`
|
|
6
|
+
*/var INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global$1.TYPED_ARRAY_SUPPORT!==void 0?global$1.TYPED_ARRAY_SUPPORT:!0,kMaxLength();function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()<t)throw new RangeError("Invalid typed array length");return Buffer.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=Buffer.prototype):(e===null&&(e=new Buffer(t)),e.length=t),e}function Buffer(e,t,n){if(!Buffer.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer))return new Buffer(e,t,n);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(this,e)}return from(this,e,t,n)}Buffer.poolSize=8192,Buffer._augment=function(e){return e.__proto__=Buffer.prototype,e};function from(e,t,n,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?fromArrayBuffer(e,t,n,r):typeof t=="string"?fromString(e,t,n):fromObject(e,t)}Buffer.from=function(e,t,n){return from(null,e,t,n)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array);function assertSize(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function alloc(e,t,n,r){return assertSize(t),t<=0?createBuffer(e,t):n!==void 0?typeof r=="string"?createBuffer(e,t).fill(n,r):createBuffer(e,t).fill(n):createBuffer(e,t)}Buffer.alloc=function(e,t,n){return alloc(null,e,t,n)};function allocUnsafe(e,t){if(assertSize(t),e=createBuffer(e,t<0?0:checked(t)|0),!Buffer.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}Buffer.allocUnsafe=function(e){return allocUnsafe(null,e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(null,e)};function fromString(e,t,n){if((typeof n!="string"||n==="")&&(n="utf8"),!Buffer.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=byteLength(t,n)|0;e=createBuffer(e,r);var i=e.write(t,n);return i!==r&&(e=e.slice(0,i)),e}function fromArrayLike(e,t){var n=t.length<0?0:checked(t.length)|0;e=createBuffer(e,n);for(var r=0;r<n;r+=1)e[r]=t[r]&255;return e}function fromArrayBuffer(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return n===void 0&&r===void 0?t=new Uint8Array(t):r===void 0?t=new Uint8Array(t,n):t=new Uint8Array(t,n,r),Buffer.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=Buffer.prototype):e=fromArrayLike(e,t),e}function fromObject(e,t){if(internalIsBuffer(t)){var n=checked(t.length)|0;return e=createBuffer(e,n),e.length===0||t.copy(e,0,0,n),e}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||isnan(t.length)?createBuffer(e,0):fromArrayLike(e,t);if(t.type==="Buffer"&&isArray$1(t.data))return fromArrayLike(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(e){if(e>=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return e|0}Buffer.isBuffer=isBuffer;function internalIsBuffer(e){return!!(e!=null&&e._isBuffer)}Buffer.compare=function(t,n){if(!internalIsBuffer(t)||!internalIsBuffer(n))throw new TypeError("Arguments must be Buffers");if(t===n)return 0;for(var r=t.length,i=n.length,s=0,l=Math.min(r,i);s<l;++s)if(t[s]!==n[s]){r=t[s],i=n[s];break}return r<i?-1:i<r?1:0},Buffer.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}},Buffer.concat=function(t,n){if(!isArray$1(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return Buffer.alloc(0);var r;if(n===void 0)for(n=0,r=0;r<t.length;++r)n+=t[r].length;var i=Buffer.allocUnsafe(n),s=0;for(r=0;r<t.length;++r){var l=t[r];if(!internalIsBuffer(l))throw new TypeError('"list" argument must be an Array of Buffers');l.copy(i,s),s+=l.length}return i};function byteLength(e,t){if(internalIsBuffer(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var n=e.length;if(n===0)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return base64ToBytes(e).length;default:if(r)return utf8ToBytes(e).length;t=(""+t).toLowerCase(),r=!0}}Buffer.byteLength=byteLength;function slowToString(e,t,n){var r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,n);case"utf8":case"utf-8":return utf8Slice(this,t,n);case"ascii":return asciiSlice(this,t,n);case"latin1":case"binary":return latin1Slice(this,t,n);case"base64":return base64Slice(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}Buffer.prototype._isBuffer=!0;function swap(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}Buffer.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<t;n+=2)swap(this,n,n+1);return this},Buffer.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<t;n+=4)swap(this,n,n+3),swap(this,n+1,n+2);return this},Buffer.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<t;n+=8)swap(this,n,n+7),swap(this,n+1,n+6),swap(this,n+2,n+5),swap(this,n+3,n+4);return this},Buffer.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?utf8Slice(this,0,t):slowToString.apply(this,arguments)},Buffer.prototype.equals=function(t){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:Buffer.compare(this,t)===0},Buffer.prototype.inspect=function(){var t="",n=INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},Buffer.prototype.compare=function(t,n,r,i,s){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");if(n===void 0&&(n=0),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),n<0||r>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&n>=r)return 0;if(i>=s)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var l=s-i,o=r-n,c=Math.min(l,o),u=this.slice(i,s),f=t.slice(n,r),E=0;E<c;++E)if(u[E]!==f[E]){l=u[E],o=f[E];break}return l<o?-1:o<l?1:0};function bidirectionalIndexOf(e,t,n,r,i){if(e.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t=="string"&&(t=Buffer.from(t,r)),internalIsBuffer(t))return t.length===0?-1:arrayIndexOf(e,t,n,r,i);if(typeof t=="number")return t=t&255,Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):arrayIndexOf(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,n,r,i){var s=1,l=e.length,o=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,l/=2,o/=2,n/=2}function c(h,g){return s===1?h[g]:h.readUInt16BE(g*s)}var u;if(i){var f=-1;for(u=n;u<l;u++)if(c(e,u)===c(t,f===-1?0:u-f)){if(f===-1&&(f=u),u-f+1===o)return f*s}else f!==-1&&(u-=u-f),f=-1}else for(n+o>l&&(n=l-o),u=n;u>=0;u--){for(var E=!0,_=0;_<o;_++)if(c(e,u+_)!==c(t,_)){E=!1;break}if(E)return u}return-1}Buffer.prototype.includes=function(t,n,r){return this.indexOf(t,n,r)!==-1},Buffer.prototype.indexOf=function(t,n,r){return bidirectionalIndexOf(this,t,n,r,!0)},Buffer.prototype.lastIndexOf=function(t,n,r){return bidirectionalIndexOf(this,t,n,r,!1)};function hexWrite(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var s=t.length;if(s%2!==0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var l=0;l<r;++l){var o=parseInt(t.substr(l*2,2),16);if(isNaN(o))return l;e[n+l]=o}return l}function utf8Write(e,t,n,r){return blitBuffer(utf8ToBytes(t,e.length-n),e,n,r)}function asciiWrite(e,t,n,r){return blitBuffer(asciiToBytes(t),e,n,r)}function latin1Write(e,t,n,r){return asciiWrite(e,t,n,r)}function base64Write(e,t,n,r){return blitBuffer(base64ToBytes(t),e,n,r)}function ucs2Write(e,t,n,r){return blitBuffer(utf16leToBytes(t,e.length-n),e,n,r)}Buffer.prototype.write=function(t,n,r,i){if(n===void 0)i="utf8",r=this.length,n=0;else if(r===void 0&&typeof n=="string")i=n,r=this.length,n=0;else if(isFinite(n))n=n|0,isFinite(r)?(r=r|0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-n;if((r===void 0||r>s)&&(r=s),t.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var l=!1;;)switch(i){case"hex":return hexWrite(this,t,n,r);case"utf8":case"utf-8":return utf8Write(this,t,n,r);case"ascii":return asciiWrite(this,t,n,r);case"latin1":case"binary":return latin1Write(this,t,n,r);case"base64":return base64Write(this,t,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,n,r);default:if(l)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),l=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(e,t,n){return t===0&&n===e.length?fromByteArray(e):fromByteArray(e.slice(t,n))}function utf8Slice(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s=e[i],l=null,o=s>239?4:s>223?3:s>191?2:1;if(i+o<=n){var c,u,f,E;switch(o){case 1:s<128&&(l=s);break;case 2:c=e[i+1],(c&192)===128&&(E=(s&31)<<6|c&63,E>127&&(l=E));break;case 3:c=e[i+1],u=e[i+2],(c&192)===128&&(u&192)===128&&(E=(s&15)<<12|(c&63)<<6|u&63,E>2047&&(E<55296||E>57343)&&(l=E));break;case 4:c=e[i+1],u=e[i+2],f=e[i+3],(c&192)===128&&(u&192)===128&&(f&192)===128&&(E=(s&15)<<18|(c&63)<<12|(u&63)<<6|f&63,E>65535&&E<1114112&&(l=E))}}l===null?(l=65533,o=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l),i+=o}return decodeCodePointsArray(r)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=MAX_ARGUMENTS_LENGTH));return n}function asciiSlice(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function latin1Slice(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function hexSlice(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=t;s<n;++s)i+=toHex(e[s]);return i}function utf16leSlice(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+r[s+1]*256);return i}Buffer.prototype.slice=function(t,n){var r=this.length;t=~~t,n=n===void 0?r:~~n,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n<t&&(n=t);var i;if(Buffer.TYPED_ARRAY_SUPPORT)i=this.subarray(t,n),i.__proto__=Buffer.prototype;else{var s=n-t;i=new Buffer(s,void 0);for(var l=0;l<s;++l)i[l]=this[l+t]}return i};function checkOffset(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(t,n,r){t=t|0,n=n|0,r||checkOffset(t,n,this.length);for(var i=this[t],s=1,l=0;++l<n&&(s*=256);)i+=this[t+l]*s;return i},Buffer.prototype.readUIntBE=function(t,n,r){t=t|0,n=n|0,r||checkOffset(t,n,this.length);for(var i=this[t+--n],s=1;n>0&&(s*=256);)i+=this[t+--n]*s;return i},Buffer.prototype.readUInt8=function(t,n){return n||checkOffset(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,n){return n||checkOffset(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,n){return n||checkOffset(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,n){return n||checkOffset(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},Buffer.prototype.readUInt32BE=function(t,n){return n||checkOffset(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,n,r){t=t|0,n=n|0,r||checkOffset(t,n,this.length);for(var i=this[t],s=1,l=0;++l<n&&(s*=256);)i+=this[t+l]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*n)),i},Buffer.prototype.readIntBE=function(t,n,r){t=t|0,n=n|0,r||checkOffset(t,n,this.length);for(var i=n,s=1,l=this[t+--i];i>0&&(s*=256);)l+=this[t+--i]*s;return s*=128,l>=s&&(l-=Math.pow(2,8*n)),l},Buffer.prototype.readInt8=function(t,n){return n||checkOffset(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},Buffer.prototype.readInt16LE=function(t,n){n||checkOffset(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r},Buffer.prototype.readInt16BE=function(t,n){n||checkOffset(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r},Buffer.prototype.readInt32LE=function(t,n){return n||checkOffset(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,n){return n||checkOffset(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,n){return n||checkOffset(t,4,this.length),read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,n){return n||checkOffset(t,4,this.length),read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,n){return n||checkOffset(t,8,this.length),read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,n){return n||checkOffset(t,8,this.length),read(this,t,!1,52,8)};function checkInt(e,t,n,r,i,s){if(!internalIsBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function(t,n,r,i){if(t=+t,n=n|0,r=r|0,!i){var s=Math.pow(2,8*r)-1;checkInt(this,t,n,r,s,0)}var l=1,o=0;for(this[n]=t&255;++o<r&&(l*=256);)this[n+o]=t/l&255;return n+r},Buffer.prototype.writeUIntBE=function(t,n,r,i){if(t=+t,n=n|0,r=r|0,!i){var s=Math.pow(2,8*r)-1;checkInt(this,t,n,r,s,0)}var l=r-1,o=1;for(this[n+l]=t&255;--l>=0&&(o*=256);)this[n+l]=t/o&255;return n+r},Buffer.prototype.writeUInt8=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[n]=t&255,n+1};function objectWriteUInt16(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-n,2);i<s;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}Buffer.prototype.writeUInt16LE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t&255,this[n+1]=t>>>8):objectWriteUInt16(this,t,n,!0),n+2},Buffer.prototype.writeUInt16BE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=t&255):objectWriteUInt16(this,t,n,!1),n+2};function objectWriteUInt32(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-n,4);i<s;++i)e[n+i]=t>>>(r?i:3-i)*8&255}Buffer.prototype.writeUInt32LE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255):objectWriteUInt32(this,t,n,!0),n+4},Buffer.prototype.writeUInt32BE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255):objectWriteUInt32(this,t,n,!1),n+4},Buffer.prototype.writeIntLE=function(t,n,r,i){if(t=+t,n=n|0,!i){var s=Math.pow(2,8*r-1);checkInt(this,t,n,r,s-1,-s)}var l=0,o=1,c=0;for(this[n]=t&255;++l<r&&(o*=256);)t<0&&c===0&&this[n+l-1]!==0&&(c=1),this[n+l]=(t/o>>0)-c&255;return n+r},Buffer.prototype.writeIntBE=function(t,n,r,i){if(t=+t,n=n|0,!i){var s=Math.pow(2,8*r-1);checkInt(this,t,n,r,s-1,-s)}var l=r-1,o=1,c=0;for(this[n+l]=t&255;--l>=0&&(o*=256);)t<0&&c===0&&this[n+l+1]!==0&&(c=1),this[n+l]=(t/o>>0)-c&255;return n+r},Buffer.prototype.writeInt8=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[n]=t&255,n+1},Buffer.prototype.writeInt16LE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t&255,this[n+1]=t>>>8):objectWriteUInt16(this,t,n,!0),n+2},Buffer.prototype.writeInt16BE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=t&255):objectWriteUInt16(this,t,n,!1),n+2},Buffer.prototype.writeInt32LE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):objectWriteUInt32(this,t,n,!0),n+4},Buffer.prototype.writeInt32BE=function(t,n,r){return t=+t,n=n|0,r||checkInt(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255):objectWriteUInt32(this,t,n,!1),n+4};function checkIEEE754(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function writeFloat(e,t,n,r,i){return i||checkIEEE754(e,t,n,4),write(e,t,n,r,23,4),n+4}Buffer.prototype.writeFloatLE=function(t,n,r){return writeFloat(this,t,n,!0,r)},Buffer.prototype.writeFloatBE=function(t,n,r){return writeFloat(this,t,n,!1,r)};function writeDouble(e,t,n,r,i){return i||checkIEEE754(e,t,n,8),write(e,t,n,r,52,8),n+8}Buffer.prototype.writeDoubleLE=function(t,n,r){return writeDouble(this,t,n,!0,r)},Buffer.prototype.writeDoubleBE=function(t,n,r){return writeDouble(this,t,n,!1,r)},Buffer.prototype.copy=function(t,n,r,i){if(r||(r=0),!i&&i!==0&&(i=this.length),n>=t.length&&(n=t.length),n||(n=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-n<i-r&&(i=t.length-n+r);var s=i-r,l;if(this===t&&r<n&&n<i)for(l=s-1;l>=0;--l)t[l+n]=this[l+r];else if(s<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(l=0;l<s;++l)t[l+n]=this[l+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),n);return s},Buffer.prototype.fill=function(t,n,r,i){if(typeof t=="string"){if(typeof n=="string"?(i=n,n=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),t.length===1){var s=t.charCodeAt(0);s<256&&(t=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!Buffer.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n=n>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var l;if(typeof t=="number")for(l=n;l<r;++l)this[l]=t;else{var o=internalIsBuffer(t)?t:utf8ToBytes(new Buffer(t,i).toString()),c=o.length;for(l=0;l<r-n;++l)this[l+n]=o[l%c]}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g;function base64clean(e){if(e=stringtrim(e).replace(INVALID_BASE64_RE,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function stringtrim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function toHex(e){return e<16?"0"+e.toString(16):e.toString(16)}function utf8ToBytes(e,t){t=t||1/0;for(var n,r=e.length,i=null,s=[],l=0;l<r;++l){if(n=e.charCodeAt(l),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(l+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return s}function asciiToBytes(e){for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function utf16leToBytes(e,t){for(var n,r,i,s=[],l=0;l<e.length&&!((t-=2)<0);++l)n=e.charCodeAt(l),r=n>>8,i=n%256,s.push(i),s.push(r);return s}function base64ToBytes(e){return toByteArray(base64clean(e))}function blitBuffer(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function isnan(e){return e!==e}function isBuffer(e){return e!=null&&(!!e._isBuffer||isFastBuffer(e)||isSlowBuffer(e))}function isFastBuffer(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&isFastBuffer(e.slice(0,0))}const DEFAULT_FORMANT_API_URL="https://api.formant.io";function whichFormantApiUrl(e,t){if(t.get("formant_stage"))return"https://api-stage.formant.io";if(t.get("formant_dev"))return"https://api-dev.formant.io";if(t.get("formant_local"))return"https://api.formant.local";if(t.get("formant_url")){const n=t.get("formant_url");if(n!==null)try{return new URL(n).origin}catch{console.warn(`Ignoring malformed \`formant_url\` url parameter: ${n}`)}}return typeof e<"u"&&"FORMANT_API_URL"in e&&typeof e.FORMANT_API_URL=="string"?e.FORMANT_API_URL:DEFAULT_FORMANT_API_URL}const FORMANT_API_URL=whichFormantApiUrl(window,new URLSearchParams(typeof window<"u"?window.location.search:void 0));class AuthenticationStore{constructor({apiUrl:t,refreshAuthToken:n,addAccessTokenRefreshListener:r}){Te(this,"_refreshToken");Te(this,"_isShareToken",!1);Te(this,"_currentOrganization");Te(this,"_currentUser");Te(this,"_defaultDeviceId");Te(this,"_token");Te(this,"_waitingForAuth",new Set);Te(this,"_refreshTimer");Te(this,"_apiUrl");Te(this,"_refreshAuthToken");Te(this,"_addAccessTokenRefreshListener");this._apiUrl=t,this._refreshAuthToken=n,this._addAccessTokenRefreshListener=r}get token(){return this._token}get currentUser(){return this._currentUser}get currentOrganization(){return this._currentOrganization}get defaultDeviceId(){return this._defaultDeviceId}get refreshToken(){return this._refreshToken}get isShareToken(){return this._isShareToken}async login(t,n){try{const r=await fetch(`${this._apiUrl}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:n}),headers:{"Content-Type":"application/json"}}),i=await r.json();if(r.status!==200)throw new Error(i.message);return await this.loginWithToken(i.authentication.accessToken,i.authentication.refreshToken),i.authentication}catch(r){return console.error("login() failed",{err:r}),this._waitingForAuth.forEach(i=>i(!1)),this._waitingForAuth.clear(),Promise.reject(r)}}async loginWithToken(t,n){var i;const r=JSON.parse(atob(t.split(".")[1]));try{let s;if(this._isShareToken=r["formant:claims"]&&r["formant:claims"].type=="share",r["formant:claims"]&&(this._currentOrganization=r["formant:claims"].organizationId),r["custom:organization_id"]&&(this._currentOrganization=r["custom:organization_id"]),this._isShareToken||(s=r.sub),r["formant:claims"]&&r["formant:claims"].userId&&(s=r["formant:claims"].userId),s&&((i=this._currentUser)==null?void 0:i.id)!==s){const l=await fetch(`${this._apiUrl}/v1/admin/users/${s}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),o=await l.json();if(l.status!==200)throw new Error(o.message);this._currentUser=o}this._token=t,this._waitingForAuth.forEach(l=>l(!0))}catch(s){console.error("loginWithToken() failed",{err:s}),this._waitingForAuth.forEach(l=>l(!1))}finally{this._waitingForAuth.clear()}n&&(this._refreshToken=n,setInterval(async()=>{if(this._refreshToken){const l=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:this._refreshToken})})).json();this._token=l.authentication.accessToken}},1e3*60*60))}isAuthenticated(){return this._token!==void 0}getCurrentUser(){return this._currentUser}async waitTilAuthenticated(){return this.token!==void 0?!0:new Promise(t=>{this._waitingForAuth.add(t)})}async listenForRefresh(){const n=()=>{this._refreshTimer=void 0,this._refreshAuthToken()};this._addAccessTokenRefreshListener(r=>{this._refreshTimer&&clearTimeout(this._refreshTimer),this._refreshTimer=setTimeout(n,36e5),this.loginWithToken(r)}),this._refreshTimer=setTimeout(n,36e5)}async forgotPassword(t){await fetch(`${this._apiUrl}/v1/admin/auth/forgot-password`,{method:"POST",body:JSON.stringify({email:t}),headers:{"Content-Type":"application/json"}})}async confirmForgotPassword(t){return(await fetch(`${this._apiUrl}/v1/admin/auth/confirm-forgot-password`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).ok}async respondToNewPasswordRequiredChallenge(t){return await(await fetch(`${this._apiUrl}/v1/admin/auth/respond-to-new-password-required-challenge`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json()}async loginWithGoogle(t){return await(await fetch(`${this._apiUrl}/v1/admin/auth/login-google`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json()}async refresh(t){const r=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})})).json();await this.loginWithToken(r.authentication.accessToken,t)}}const Authentication=new AuthenticationStore({apiUrl:FORMANT_API_URL,refreshAuthToken:App.refreshAuthToken,addAccessTokenRefreshListener:App.addAccessTokenRefreshListener});function defined(e,t){if(e!==void 0)return e;throw new Error(t||"Value is undefined")}var dist={exports:{}};/*! For license information please see index.js.LICENSE.txt */(function(module,exports){(function(e,t){module.exports=t()})(window,function(){return function(e){function t(u){for(var f,E,_=u[0],h=u[1],g=0,b=[];g<_.length;g++)E=_[g],Object.prototype.hasOwnProperty.call(r,E)&&r[E]&&b.push(r[E][0]),r[E]=0;for(f in h)Object.prototype.hasOwnProperty.call(h,f)&&(e[f]=h[f]);for(c&&c(u);b.length;)b.shift()()}var n={},r={0:0};function i(u){if(n[u])return n[u].exports;var f=n[u]={i:u,l:!1,exports:{}};return e[u].call(f.exports,f,f.exports,i),f.l=!0,f.exports}i.e=function(){return Promise.resolve()},i.m=e,i.c=n,i.d=function(u,f,E){i.o(u,f)||Object.defineProperty(u,f,{enumerable:!0,get:E})},i.r=function(u){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},i.t=function(u,f){if(1&f&&(u=i(u)),8&f||4&f&&typeof u=="object"&&u&&u.__esModule)return u;var E=Object.create(null);if(i.r(E),Object.defineProperty(E,"default",{enumerable:!0,value:u}),2&f&&typeof u!="string")for(var _ in u)i.d(E,_,function(h){return u[h]}.bind(null,_));return E},i.n=function(u){var f=u&&u.__esModule?function(){return u.default}:function(){return u};return i.d(f,"a",f),f},i.o=function(u,f){return Object.prototype.hasOwnProperty.call(u,f)},i.p="",i.oe=function(u){throw console.error(u),u};var s=window.webpackJsonpFormantRealtimeSDK=window.webpackJsonpFormantRealtimeSDK||[],l=s.push.bind(s);s.push=t,s=s.slice();for(var o=0;o<s.length;o++)t(s[o]);var c=l;return i(i.s=228)}([function(e,t,n){n.d(t,"a",function(){return G});function r(T,B){if(B.length<T)throw new TypeError(T+" argument"+(T>1?"s":"")+" required, but only "+B.length+" present")}function i(T){if(T===null||T===!0||T===!1)return NaN;var B=Number(T);return isNaN(B)?B:B<0?Math.ceil(B):Math.floor(B)}var s={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},l=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,o=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,c=/^([+-])(\d{2})(?::?(\d{2}))?$/;function u(T){var B,J={},K=T.split(s.dateTimeDelimiter);if(K.length>2)return J;if(/:/.test(K[0])?B=K[0]:(J.date=K[0],B=K[1],s.timeZoneDelimiter.test(J.date)&&(J.date=T.split(s.timeZoneDelimiter)[0],B=T.substr(J.date.length,T.length))),B){var re=s.timezone.exec(B);re?(J.time=B.replace(re[1],""),J.timezone=re[1]):J.time=B}return J}function f(T,B){var J=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+B)+"})|(\\d{2}|[+-]\\d{"+(2+B)+"})$)"),K=T.match(J);if(!K)return{year:NaN,restDateString:""};var re=K[1]?parseInt(K[1]):null,se=K[2]?parseInt(K[2]):null;return{year:se===null?re:100*se,restDateString:T.slice((K[1]||K[2]).length)}}function E(T,B){if(B===null)return new Date(NaN);var J=T.match(l);if(!J)return new Date(NaN);var K=!!J[4],re=_(J[1]),se=_(J[2])-1,fe=_(J[3]),ve=_(J[4]),Ie=_(J[5])-1;if(K)return function(Ce,Ae,Oe){return Ae>=1&&Ae<=53&&Oe>=0&&Oe<=6}(0,ve,Ie)?function(Ce,Ae,Oe){var Pe=new Date(0);Pe.setUTCFullYear(Ce,0,4);var qe=Pe.getUTCDay()||7,tt=7*(Ae-1)+Oe+1-qe;return Pe.setUTCDate(Pe.getUTCDate()+tt),Pe}(B,ve,Ie):new Date(NaN);var Se=new Date(0);return function(Ce,Ae,Oe){return Ae>=0&&Ae<=11&&Oe>=1&&Oe<=(A[Ae]||(j(Ce)?29:28))}(B,se,fe)&&function(Ce,Ae){return Ae>=1&&Ae<=(j(Ce)?366:365)}(B,re)?(Se.setUTCFullYear(B,se,Math.max(re,fe)),Se):new Date(NaN)}function _(T){return T?parseInt(T):1}function h(T){var B=T.match(o);if(!B)return NaN;var J=g(B[1]),K=g(B[2]),re=g(B[3]);return function(se,fe,ve){return se===24?fe===0&&ve===0:ve>=0&&ve<60&&fe>=0&&fe<60&&se>=0&&se<25}(J,K,re)?36e5*J+6e4*K+1e3*re:NaN}function g(T){return T&&parseFloat(T.replace(",","."))||0}function b(T){if(T==="Z")return 0;var B=T.match(c);if(!B)return 0;var J=B[1]==="+"?-1:1,K=parseInt(B[2]),re=B[3]&&parseInt(B[3])||0;return function(se,fe){return fe>=0&&fe<=59}(0,re)?J*(36e5*K+6e4*re):NaN}var A=[31,null,31,30,31,30,31,31,30,31,30,31];function j(T){return T%400==0||T%4==0&&T%100!=0}function F(T){return r(1,arguments),T instanceof Date||typeof T=="object"&&Object.prototype.toString.call(T)==="[object Date]"}function M(T){r(1,arguments);var B=Object.prototype.toString.call(T);return T instanceof Date||typeof T=="object"&&B==="[object Date]"?new Date(T.getTime()):typeof T=="number"||B==="[object Number]"?new Date(T):(typeof T!="string"&&B!=="[object String]"||typeof console>"u"||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function R(T){const B=function(J,K){var re;r(1,arguments);var se=i((re=K==null?void 0:K.additionalDigits)!==null&&re!==void 0?re:2);if(se!==2&&se!==1&&se!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(typeof J!="string"&&Object.prototype.toString.call(J)!=="[object String]")return new Date(NaN);var fe,ve=u(J);if(ve.date){var Ie=f(ve.date,se);fe=E(Ie.restDateString,Ie.year)}if(!fe||isNaN(fe.getTime()))return new Date(NaN);var Se,Ce=fe.getTime(),Ae=0;if(ve.time&&(Ae=h(ve.time),isNaN(Ae)))return new Date(NaN);if(!ve.timezone){var Oe=new Date(Ce+Ae),Pe=new Date(0);return Pe.setFullYear(Oe.getUTCFullYear(),Oe.getUTCMonth(),Oe.getUTCDate()),Pe.setHours(Oe.getUTCHours(),Oe.getUTCMinutes(),Oe.getUTCSeconds(),Oe.getUTCMilliseconds()),Pe}return Se=b(ve.timezone),isNaN(Se)?new Date(NaN):new Date(Ce+Ae+Se)}(T);if(!function(J){if(r(1,arguments),!F(J)&&typeof J!="number")return!1;var K=M(J);return!isNaN(Number(K))}(B))throw new Error(`Invalid ISO 8601 date string (${T})`);return B}const d=Math.pow(2,20),I=d;var $=n(14),q=n.n($),y=n(18),m=n(56),C=n(19),w=n(4),L=n(34);function W(T){return q()(T,{cycles:!0})}var k=function(T,B){var J={};for(var K in T)Object.prototype.hasOwnProperty.call(T,K)&&B.indexOf(K)<0&&(J[K]=T[K]);if(T!=null&&typeof Object.getOwnPropertySymbols=="function"){var re=0;for(K=Object.getOwnPropertySymbols(T);re<K.length;re++)B.indexOf(K[re])<0&&Object.prototype.propertyIsEnumerable.call(T,K[re])&&(J[K[re]]=T[K[re]])}return J};function N(T,B={}){const J=ve=>B.redacted!==!1?Object(L.a)(ve):ve;if(!T.stack)return{message:W(J(T))};const{name:K,message:re,stack:se}=T,fe=k(T,["name","message","stack"]);return{name:K,message:re!==void 0?re:W(J(T)),stack:se,meta:fe&&Object.keys(fe).length===0?void 0:J(fe)}}function P(T,B={}){const{message:J,stack:K,meta:re}=N(T,B);return`${K||J||""}${re&&Object.keys(re).length>0?` -- ${W(re)}`:""}`}var z=n(39),O=n(103),p=n.n(O),U=function(T,B,J,K){return new(J||(J=Promise))(function(re,se){function fe(Se){try{Ie(K.next(Se))}catch(Ce){se(Ce)}}function ve(Se){try{Ie(K.throw(Se))}catch(Ce){se(Ce)}}function Ie(Se){var Ce;Se.done?re(Se.value):(Ce=Se.value,Ce instanceof J?Ce:new J(function(Ae){Ae(Ce)})).then(fe,ve)}Ie((K=K.apply(T,B||[])).next())})},V=function(T,B){var J={};for(var K in T)Object.prototype.hasOwnProperty.call(T,K)&&B.indexOf(K)<0&&(J[K]=T[K]);if(T!=null&&typeof Object.getOwnPropertySymbols=="function"){var re=0;for(K=Object.getOwnPropertySymbols(T);re<K.length;re++)B.indexOf(K[re])<0&&Object.prototype.propertyIsEnumerable.call(T,K[re])&&(J[K[re]]=T[K[re]])}return J};class Q extends p.a{constructor(B,J){super(),this.endpoint=B,this.metadata=J,this.logClient=this.getLogClient()}getLogClient(){return U(this,void 0,void 0,function*(){const{LogClient:B}=yield Promise.resolve().then(n.bind(null,231));return new B(this.endpoint)})}log(B,J){return U(this,void 0,void 0,function*(){const{level:K,message:re,error:se}=B,fe=V(B,["level","message","error"]);this.emit("logged");try{yield(yield this.logClient).log([{timestamp:new Date().toISOString(),level:K,message:`${re}`.substring(0,1e3),error:se!==void 0?N(se):void 0,meta:Object.assign(Object.assign({},fe),this.metadata)}])}catch(ve){console.error(`Failed to log to log-api: ${P(ve)}`)}J()})}}var ee=function(T,B){var J={};for(var K in T)Object.prototype.hasOwnProperty.call(T,K)&&B.indexOf(K)<0&&(J[K]=T[K]);if(T!=null&&typeof Object.getOwnPropertySymbols=="function"){var re=0;for(K=Object.getOwnPropertySymbols(T);re<K.length;re++)B.indexOf(K[re])<0&&Object.prototype.propertyIsEnumerable.call(T,K[re])&&(J[K[re]]=T[K[re]])}return J};const ne={app:w.a,namespace:w.i,buildTag:w.b,instanceId:z.a},Y=w.e?C.format.printf(T=>{var{timestamp:B,level:J,message:K,error:re}=T,se=ee(T,["timestamp","level","message","error"]);const fe=Object.assign(Object.assign({timestamp:B?R(B).getTime():new Date().getTime(),level:J.toUpperCase(),message:K},re?{error:N(re)}:{}),{meta:Object.assign(Object.assign({},ne),se)});return q()(fe,{cycles:!0})}):C.format.printf(T=>{var{timestamp:B,level:J,message:K,error:re}=T,se=ee(T,["timestamp","level","message","error"]);let fe=`${B||new Date().toISOString()} ${J.toUpperCase()}: ${K} `;return Object.keys(se).length>0&&(fe+=q()(se,{cycles:!0})),re&&(fe+=`
|
|
7
7
|
${P(re)}`),fe}),G=Object(C.createLogger)({level:w.f});if(G.add(new C.transports.Console({format:Y,level:"debug"})),G.transports.forEach(T=>{T.silent=!w.g}),w.d&&G.add(new Q(w.d,ne)),w.h){const T=m.resolve(y.tmpdir(),`silly-${w.a}.log`);G.debug("Logging silly logs to file",{filename:T}),G.add(new C.transports.File({filename:T,maxsize:1*I,maxFiles:10,format:C.format.combine((S="silly",Object(C.format)(B=>B.level===S&&B)()),Y),level:"silly"}))}var S},function(e,t,n){n.d(t,"a",function(){return r});const r={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6,year:31536e6}},function(e,t){var n,r,i=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function o(A){if(n===setTimeout)return setTimeout(A,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(A,0);try{return n(A,0)}catch{try{return n.call(null,A,0)}catch{return n.call(this,A,0)}}}(function(){try{n=typeof setTimeout=="function"?setTimeout:s}catch{n=s}try{r=typeof clearTimeout=="function"?clearTimeout:l}catch{r=l}})();var c,u=[],f=!1,E=-1;function _(){f&&c&&(f=!1,c.length?u=c.concat(u):E=-1,u.length&&h())}function h(){if(!f){var A=o(_);f=!0;for(var j=u.length;j;){for(c=u,u=[];++E<j;)c&&c[E].run();E=-1,j=u.length}c=null,f=!1,function(F){if(r===clearTimeout)return clearTimeout(F);if((r===l||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(F);try{r(F)}catch{try{return r.call(null,F)}catch{return r.call(this,F)}}}(A)}}function g(A,j){this.fun=A,this.array=j}function b(){}i.nextTick=function(A){var j=new Array(arguments.length-1);if(arguments.length>1)for(var F=1;F<arguments.length;F++)j[F-1]=arguments[F];u.push(new g(A,j)),u.length!==1||f||o(h)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=b,i.addListener=b,i.once=b,i.off=b,i.removeListener=b,i.removeAllListeners=b,i.emit=b,i.prependListener=b,i.prependOnceListener=b,i.listeners=function(A){return[]},i.binding=function(A){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(A){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){Object.defineProperty(t,"LEVEL",{value:Symbol.for("level")}),Object.defineProperty(t,"MESSAGE",{value:Symbol.for("message")}),Object.defineProperty(t,"SPLAT",{value:Symbol.for("splat")}),Object.defineProperty(t,"configs",{value:n(118)})},function(e,t,n){(function(r){n.d(t,"a",function(){return l}),n.d(t,"i",function(){return o}),n.d(t,"j",function(){return c}),n.d(t,"b",function(){return u}),n.d(t,"f",function(){return f}),n.d(t,"e",function(){return E}),n.d(t,"g",function(){return _}),n.d(t,"d",function(){return h}),n.d(t,"c",function(){return g}),n.d(t,"h",function(){return b});var i=n(102);const s=i.from({ENVIRONMENT:r.env.ENV,AGGREGATE_LEVEL:r.env.AGGREGATE_LEVEL,API_ENDPOINT:r.env.API_ENDPOINT,APP:"realtime-sdk",APP_PATH:r.env.APP_PATH,BUILD_TAG:r.env.BUILD_TAG,ENABLE_SELF_SERVE:r.env.ENABLE_SELF_SERVE,ENABLE_SENTRY:r.env.ENABLE_SENTRY,ENABLE_SENTRY_PROFILING:r.env.ENABLE_SENTRY_PROFILING,GIT_COMMIT:r.env.GIT_COMMIT,JEST_WORKER_ID:r.env.JEST_WORKER_ID,LOG_API_ENDPOINT:r.env.LOG_API_ENDPOINT,LOG_JSON:"false",LOG_LEVEL:r.env.LOG_LEVEL,LOG_TO_CONSOLE:r.env.LOG_TO_CONSOLE,LOG_TO_FILE:r.env.LOG_TO_FILE,NAMESPACE:"production",SENTRY_DSN:r.env.SENTRY_DSN,SHEET_EXPORT_MAX_ROW_COUNT:r.env.SHEET_EXPORT_MAX_ROW_COUNT,STABLE_AGENT_VERSION:r.env.STABLE_AGENT_VERSION,VERSION:r.env.VERSION}),l=(s.get("ENVIRONMENT").default("").asString(),s.get("APP").default("").asString()),o=(s.get("APP_PATH").default("").asString(),s.get("API_ENDPOINT").default("").asString(),s.get("NAMESPACE").default("").asString()),c=s.get("VERSION").default("").asString(),u=s.get("BUILD_TAG").default("").asString(),f=(s.get("GIT_COMMIT").default("").asString(),s.get("ENABLE_SENTRY").default("false").asBool(),s.get("ENABLE_SENTRY_PROFILING").default("false").asBool(),s.get("SENTRY_DSN").default("").asString(),s.get("LOG_LEVEL").default("debug").asString()),E=s.get("LOG_JSON").default("true").asBool(),_=s.get("LOG_TO_CONSOLE").default("true").asBool(),h=(s.get("STABLE_AGENT_VERSION").default("").asString(),s.get("LOG_API_ENDPOINT").asString()),g=s.get("JEST_WORKER_ID").asString(),b=(s.get("SHEET_EXPORT_MAX_ROW_COUNT").default("10000").asIntPositive(),s.get("LOG_TO_FILE").default("false").asBoolStrict());s.get("ENABLE_SELF_SERVE").default("true").asBoolStrict(),s.get("AGGREGATE_LEVEL").default("hour").asEnum(["day","hour","minute"])}).call(this,n(2))},function(e,t,n){(function(r){var i=n(126),s=n(127),l=n(42);function o(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function c(S,T){if(o()<T)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(S=new Uint8Array(T)).__proto__=u.prototype:(S===null&&(S=new u(T)),S.length=T),S}function u(S,T,B){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(S,T,B);if(typeof S=="number"){if(typeof T=="string")throw new Error("If encoding is specified then the first argument must be a string");return _(this,S)}return f(this,S,T,B)}function f(S,T,B,J){if(typeof T=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&T instanceof ArrayBuffer?function(K,re,se,fe){if(re.byteLength,se<0||re.byteLength<se)throw new RangeError("'offset' is out of bounds");if(re.byteLength<se+(fe||0))throw new RangeError("'length' is out of bounds");return re=se===void 0&&fe===void 0?new Uint8Array(re):fe===void 0?new Uint8Array(re,se):new Uint8Array(re,se,fe),u.TYPED_ARRAY_SUPPORT?(K=re).__proto__=u.prototype:K=h(K,re),K}(S,T,B,J):typeof T=="string"?function(K,re,se){if(typeof se=="string"&&se!==""||(se="utf8"),!u.isEncoding(se))throw new TypeError('"encoding" must be a valid string encoding');var fe=0|b(re,se),ve=(K=c(K,fe)).write(re,se);return ve!==fe&&(K=K.slice(0,ve)),K}(S,T,B):function(K,re){if(u.isBuffer(re)){var se=0|g(re.length);return(K=c(K,se)).length===0||re.copy(K,0,0,se),K}if(re){if(typeof ArrayBuffer<"u"&&re.buffer instanceof ArrayBuffer||"length"in re)return typeof re.length!="number"||(fe=re.length)!=fe?c(K,0):h(K,re);if(re.type==="Buffer"&&l(re.data))return h(K,re.data)}var fe;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(S,T)}function E(S){if(typeof S!="number")throw new TypeError('"size" argument must be a number');if(S<0)throw new RangeError('"size" argument must not be negative')}function _(S,T){if(E(T),S=c(S,T<0?0:0|g(T)),!u.TYPED_ARRAY_SUPPORT)for(var B=0;B<T;++B)S[B]=0;return S}function h(S,T){var B=T.length<0?0:0|g(T.length);S=c(S,B);for(var J=0;J<B;J+=1)S[J]=255&T[J];return S}function g(S){if(S>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|S}function b(S,T){if(u.isBuffer(S))return S.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(S)||S instanceof ArrayBuffer))return S.byteLength;typeof S!="string"&&(S=""+S);var B=S.length;if(B===0)return 0;for(var J=!1;;)switch(T){case"ascii":case"latin1":case"binary":return B;case"utf8":case"utf-8":case void 0:return ne(S).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*B;case"hex":return B>>>1;case"base64":return Y(S).length;default:if(J)return ne(S).length;T=(""+T).toLowerCase(),J=!0}}function A(S,T,B){var J=!1;if((T===void 0||T<0)&&(T=0),T>this.length||((B===void 0||B>this.length)&&(B=this.length),B<=0)||(B>>>=0)<=(T>>>=0))return"";for(S||(S="utf8");;)switch(S){case"hex":return W(this,T,B);case"utf8":case"utf-8":return C(this,T,B);case"ascii":return w(this,T,B);case"latin1":case"binary":return L(this,T,B);case"base64":return m(this,T,B);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,T,B);default:if(J)throw new TypeError("Unknown encoding: "+S);S=(S+"").toLowerCase(),J=!0}}function j(S,T,B){var J=S[T];S[T]=S[B],S[B]=J}function F(S,T,B,J,K){if(S.length===0)return-1;if(typeof B=="string"?(J=B,B=0):B>2147483647?B=2147483647:B<-2147483648&&(B=-2147483648),B=+B,isNaN(B)&&(B=K?0:S.length-1),B<0&&(B=S.length+B),B>=S.length){if(K)return-1;B=S.length-1}else if(B<0){if(!K)return-1;B=0}if(typeof T=="string"&&(T=u.from(T,J)),u.isBuffer(T))return T.length===0?-1:M(S,T,B,J,K);if(typeof T=="number")return T&=255,u.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?K?Uint8Array.prototype.indexOf.call(S,T,B):Uint8Array.prototype.lastIndexOf.call(S,T,B):M(S,[T],B,J,K);throw new TypeError("val must be string, number or Buffer")}function M(S,T,B,J,K){var re,se=1,fe=S.length,ve=T.length;if(J!==void 0&&((J=String(J).toLowerCase())==="ucs2"||J==="ucs-2"||J==="utf16le"||J==="utf-16le")){if(S.length<2||T.length<2)return-1;se=2,fe/=2,ve/=2,B/=2}function Ie(Oe,Pe){return se===1?Oe[Pe]:Oe.readUInt16BE(Pe*se)}if(K){var Se=-1;for(re=B;re<fe;re++)if(Ie(S,re)===Ie(T,Se===-1?0:re-Se)){if(Se===-1&&(Se=re),re-Se+1===ve)return Se*se}else Se!==-1&&(re-=re-Se),Se=-1}else for(B+ve>fe&&(B=fe-ve),re=B;re>=0;re--){for(var Ce=!0,Ae=0;Ae<ve;Ae++)if(Ie(S,re+Ae)!==Ie(T,Ae)){Ce=!1;break}if(Ce)return re}return-1}function R(S,T,B,J){B=Number(B)||0;var K=S.length-B;J?(J=Number(J))>K&&(J=K):J=K;var re=T.length;if(re%2!=0)throw new TypeError("Invalid hex string");J>re/2&&(J=re/2);for(var se=0;se<J;++se){var fe=parseInt(T.substr(2*se,2),16);if(isNaN(fe))return se;S[B+se]=fe}return se}function d(S,T,B,J){return G(ne(T,S.length-B),S,B,J)}function I(S,T,B,J){return G(function(K){for(var re=[],se=0;se<K.length;++se)re.push(255&K.charCodeAt(se));return re}(T),S,B,J)}function $(S,T,B,J){return I(S,T,B,J)}function q(S,T,B,J){return G(Y(T),S,B,J)}function y(S,T,B,J){return G(function(K,re){for(var se,fe,ve,Ie=[],Se=0;Se<K.length&&!((re-=2)<0);++Se)se=K.charCodeAt(Se),fe=se>>8,ve=se%256,Ie.push(ve),Ie.push(fe);return Ie}(T,S.length-B),S,B,J)}function m(S,T,B){return T===0&&B===S.length?i.fromByteArray(S):i.fromByteArray(S.slice(T,B))}function C(S,T,B){B=Math.min(S.length,B);for(var J=[],K=T;K<B;){var re,se,fe,ve,Ie=S[K],Se=null,Ce=Ie>239?4:Ie>223?3:Ie>191?2:1;if(K+Ce<=B)switch(Ce){case 1:Ie<128&&(Se=Ie);break;case 2:(192&(re=S[K+1]))==128&&(ve=(31&Ie)<<6|63&re)>127&&(Se=ve);break;case 3:re=S[K+1],se=S[K+2],(192&re)==128&&(192&se)==128&&(ve=(15&Ie)<<12|(63&re)<<6|63&se)>2047&&(ve<55296||ve>57343)&&(Se=ve);break;case 4:re=S[K+1],se=S[K+2],fe=S[K+3],(192&re)==128&&(192&se)==128&&(192&fe)==128&&(ve=(15&Ie)<<18|(63&re)<<12|(63&se)<<6|63&fe)>65535&&ve<1114112&&(Se=ve)}Se===null?(Se=65533,Ce=1):Se>65535&&(Se-=65536,J.push(Se>>>10&1023|55296),Se=56320|1023&Se),J.push(Se),K+=Ce}return function(Ae){var Oe=Ae.length;if(Oe<=4096)return String.fromCharCode.apply(String,Ae);for(var Pe="",qe=0;qe<Oe;)Pe+=String.fromCharCode.apply(String,Ae.slice(qe,qe+=4096));return Pe}(J)}t.Buffer=u,t.SlowBuffer=function(S){return+S!=S&&(S=0),u.alloc(+S)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=r.TYPED_ARRAY_SUPPORT!==void 0?r.TYPED_ARRAY_SUPPORT:function(){try{var S=new Uint8Array(1);return S.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},S.foo()===42&&typeof S.subarray=="function"&&S.subarray(1,1).byteLength===0}catch{return!1}}(),t.kMaxLength=o(),u.poolSize=8192,u._augment=function(S){return S.__proto__=u.prototype,S},u.from=function(S,T,B){return f(null,S,T,B)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(S,T,B){return function(J,K,re,se){return E(K),K<=0?c(J,K):re!==void 0?typeof se=="string"?c(J,K).fill(re,se):c(J,K).fill(re):c(J,K)}(null,S,T,B)},u.allocUnsafe=function(S){return _(null,S)},u.allocUnsafeSlow=function(S){return _(null,S)},u.isBuffer=function(S){return!(S==null||!S._isBuffer)},u.compare=function(S,T){if(!u.isBuffer(S)||!u.isBuffer(T))throw new TypeError("Arguments must be Buffers");if(S===T)return 0;for(var B=S.length,J=T.length,K=0,re=Math.min(B,J);K<re;++K)if(S[K]!==T[K]){B=S[K],J=T[K];break}return B<J?-1:J<B?1:0},u.isEncoding=function(S){switch(String(S).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(S,T){if(!l(S))throw new TypeError('"list" argument must be an Array of Buffers');if(S.length===0)return u.alloc(0);var B;if(T===void 0)for(T=0,B=0;B<S.length;++B)T+=S[B].length;var J=u.allocUnsafe(T),K=0;for(B=0;B<S.length;++B){var re=S[B];if(!u.isBuffer(re))throw new TypeError('"list" argument must be an Array of Buffers');re.copy(J,K),K+=re.length}return J},u.byteLength=b,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var S=this.length;if(S%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var T=0;T<S;T+=2)j(this,T,T+1);return this},u.prototype.swap32=function(){var S=this.length;if(S%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var T=0;T<S;T+=4)j(this,T,T+3),j(this,T+1,T+2);return this},u.prototype.swap64=function(){var S=this.length;if(S%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var T=0;T<S;T+=8)j(this,T,T+7),j(this,T+1,T+6),j(this,T+2,T+5),j(this,T+3,T+4);return this},u.prototype.toString=function(){var S=0|this.length;return S===0?"":arguments.length===0?C(this,0,S):A.apply(this,arguments)},u.prototype.equals=function(S){if(!u.isBuffer(S))throw new TypeError("Argument must be a Buffer");return this===S||u.compare(this,S)===0},u.prototype.inspect=function(){var S="",T=t.INSPECT_MAX_BYTES;return this.length>0&&(S=this.toString("hex",0,T).match(/.{2}/g).join(" "),this.length>T&&(S+=" ... ")),"<Buffer "+S+">"},u.prototype.compare=function(S,T,B,J,K){if(!u.isBuffer(S))throw new TypeError("Argument must be a Buffer");if(T===void 0&&(T=0),B===void 0&&(B=S?S.length:0),J===void 0&&(J=0),K===void 0&&(K=this.length),T<0||B>S.length||J<0||K>this.length)throw new RangeError("out of range index");if(J>=K&&T>=B)return 0;if(J>=K)return-1;if(T>=B)return 1;if(this===S)return 0;for(var re=(K>>>=0)-(J>>>=0),se=(B>>>=0)-(T>>>=0),fe=Math.min(re,se),ve=this.slice(J,K),Ie=S.slice(T,B),Se=0;Se<fe;++Se)if(ve[Se]!==Ie[Se]){re=ve[Se],se=Ie[Se];break}return re<se?-1:se<re?1:0},u.prototype.includes=function(S,T,B){return this.indexOf(S,T,B)!==-1},u.prototype.indexOf=function(S,T,B){return F(this,S,T,B,!0)},u.prototype.lastIndexOf=function(S,T,B){return F(this,S,T,B,!1)},u.prototype.write=function(S,T,B,J){if(T===void 0)J="utf8",B=this.length,T=0;else if(B===void 0&&typeof T=="string")J=T,B=this.length,T=0;else{if(!isFinite(T))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");T|=0,isFinite(B)?(B|=0,J===void 0&&(J="utf8")):(J=B,B=void 0)}var K=this.length-T;if((B===void 0||B>K)&&(B=K),S.length>0&&(B<0||T<0)||T>this.length)throw new RangeError("Attempt to write outside buffer bounds");J||(J="utf8");for(var re=!1;;)switch(J){case"hex":return R(this,S,T,B);case"utf8":case"utf-8":return d(this,S,T,B);case"ascii":return I(this,S,T,B);case"latin1":case"binary":return $(this,S,T,B);case"base64":return q(this,S,T,B);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y(this,S,T,B);default:if(re)throw new TypeError("Unknown encoding: "+J);J=(""+J).toLowerCase(),re=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function w(S,T,B){var J="";B=Math.min(S.length,B);for(var K=T;K<B;++K)J+=String.fromCharCode(127&S[K]);return J}function L(S,T,B){var J="";B=Math.min(S.length,B);for(var K=T;K<B;++K)J+=String.fromCharCode(S[K]);return J}function W(S,T,B){var J=S.length;(!T||T<0)&&(T=0),(!B||B<0||B>J)&&(B=J);for(var K="",re=T;re<B;++re)K+=ee(S[re]);return K}function k(S,T,B){for(var J=S.slice(T,B),K="",re=0;re<J.length;re+=2)K+=String.fromCharCode(J[re]+256*J[re+1]);return K}function N(S,T,B){if(S%1!=0||S<0)throw new RangeError("offset is not uint");if(S+T>B)throw new RangeError("Trying to access beyond buffer length")}function P(S,T,B,J,K,re){if(!u.isBuffer(S))throw new TypeError('"buffer" argument must be a Buffer instance');if(T>K||T<re)throw new RangeError('"value" argument is out of bounds');if(B+J>S.length)throw new RangeError("Index out of range")}function z(S,T,B,J){T<0&&(T=65535+T+1);for(var K=0,re=Math.min(S.length-B,2);K<re;++K)S[B+K]=(T&255<<8*(J?K:1-K))>>>8*(J?K:1-K)}function O(S,T,B,J){T<0&&(T=4294967295+T+1);for(var K=0,re=Math.min(S.length-B,4);K<re;++K)S[B+K]=T>>>8*(J?K:3-K)&255}function p(S,T,B,J,K,re){if(B+J>S.length)throw new RangeError("Index out of range");if(B<0)throw new RangeError("Index out of range")}function U(S,T,B,J,K){return K||p(S,0,B,4),s.write(S,T,B,J,23,4),B+4}function V(S,T,B,J,K){return K||p(S,0,B,8),s.write(S,T,B,J,52,8),B+8}u.prototype.slice=function(S,T){var B,J=this.length;if((S=~~S)<0?(S+=J)<0&&(S=0):S>J&&(S=J),(T=T===void 0?J:~~T)<0?(T+=J)<0&&(T=0):T>J&&(T=J),T<S&&(T=S),u.TYPED_ARRAY_SUPPORT)(B=this.subarray(S,T)).__proto__=u.prototype;else{var K=T-S;B=new u(K,void 0);for(var re=0;re<K;++re)B[re]=this[re+S]}return B},u.prototype.readUIntLE=function(S,T,B){S|=0,T|=0,B||N(S,T,this.length);for(var J=this[S],K=1,re=0;++re<T&&(K*=256);)J+=this[S+re]*K;return J},u.prototype.readUIntBE=function(S,T,B){S|=0,T|=0,B||N(S,T,this.length);for(var J=this[S+--T],K=1;T>0&&(K*=256);)J+=this[S+--T]*K;return J},u.prototype.readUInt8=function(S,T){return T||N(S,1,this.length),this[S]},u.prototype.readUInt16LE=function(S,T){return T||N(S,2,this.length),this[S]|this[S+1]<<8},u.prototype.readUInt16BE=function(S,T){return T||N(S,2,this.length),this[S]<<8|this[S+1]},u.prototype.readUInt32LE=function(S,T){return T||N(S,4,this.length),(this[S]|this[S+1]<<8|this[S+2]<<16)+16777216*this[S+3]},u.prototype.readUInt32BE=function(S,T){return T||N(S,4,this.length),16777216*this[S]+(this[S+1]<<16|this[S+2]<<8|this[S+3])},u.prototype.readIntLE=function(S,T,B){S|=0,T|=0,B||N(S,T,this.length);for(var J=this[S],K=1,re=0;++re<T&&(K*=256);)J+=this[S+re]*K;return J>=(K*=128)&&(J-=Math.pow(2,8*T)),J},u.prototype.readIntBE=function(S,T,B){S|=0,T|=0,B||N(S,T,this.length);for(var J=T,K=1,re=this[S+--J];J>0&&(K*=256);)re+=this[S+--J]*K;return re>=(K*=128)&&(re-=Math.pow(2,8*T)),re},u.prototype.readInt8=function(S,T){return T||N(S,1,this.length),128&this[S]?-1*(255-this[S]+1):this[S]},u.prototype.readInt16LE=function(S,T){T||N(S,2,this.length);var B=this[S]|this[S+1]<<8;return 32768&B?4294901760|B:B},u.prototype.readInt16BE=function(S,T){T||N(S,2,this.length);var B=this[S+1]|this[S]<<8;return 32768&B?4294901760|B:B},u.prototype.readInt32LE=function(S,T){return T||N(S,4,this.length),this[S]|this[S+1]<<8|this[S+2]<<16|this[S+3]<<24},u.prototype.readInt32BE=function(S,T){return T||N(S,4,this.length),this[S]<<24|this[S+1]<<16|this[S+2]<<8|this[S+3]},u.prototype.readFloatLE=function(S,T){return T||N(S,4,this.length),s.read(this,S,!0,23,4)},u.prototype.readFloatBE=function(S,T){return T||N(S,4,this.length),s.read(this,S,!1,23,4)},u.prototype.readDoubleLE=function(S,T){return T||N(S,8,this.length),s.read(this,S,!0,52,8)},u.prototype.readDoubleBE=function(S,T){return T||N(S,8,this.length),s.read(this,S,!1,52,8)},u.prototype.writeUIntLE=function(S,T,B,J){S=+S,T|=0,B|=0,J||P(this,S,T,B,Math.pow(2,8*B)-1,0);var K=1,re=0;for(this[T]=255&S;++re<B&&(K*=256);)this[T+re]=S/K&255;return T+B},u.prototype.writeUIntBE=function(S,T,B,J){S=+S,T|=0,B|=0,J||P(this,S,T,B,Math.pow(2,8*B)-1,0);var K=B-1,re=1;for(this[T+K]=255&S;--K>=0&&(re*=256);)this[T+K]=S/re&255;return T+B},u.prototype.writeUInt8=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,1,255,0),u.TYPED_ARRAY_SUPPORT||(S=Math.floor(S)),this[T]=255&S,T+1},u.prototype.writeUInt16LE=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[T]=255&S,this[T+1]=S>>>8):z(this,S,T,!0),T+2},u.prototype.writeUInt16BE=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[T]=S>>>8,this[T+1]=255&S):z(this,S,T,!1),T+2},u.prototype.writeUInt32LE=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[T+3]=S>>>24,this[T+2]=S>>>16,this[T+1]=S>>>8,this[T]=255&S):O(this,S,T,!0),T+4},u.prototype.writeUInt32BE=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[T]=S>>>24,this[T+1]=S>>>16,this[T+2]=S>>>8,this[T+3]=255&S):O(this,S,T,!1),T+4},u.prototype.writeIntLE=function(S,T,B,J){if(S=+S,T|=0,!J){var K=Math.pow(2,8*B-1);P(this,S,T,B,K-1,-K)}var re=0,se=1,fe=0;for(this[T]=255&S;++re<B&&(se*=256);)S<0&&fe===0&&this[T+re-1]!==0&&(fe=1),this[T+re]=(S/se>>0)-fe&255;return T+B},u.prototype.writeIntBE=function(S,T,B,J){if(S=+S,T|=0,!J){var K=Math.pow(2,8*B-1);P(this,S,T,B,K-1,-K)}var re=B-1,se=1,fe=0;for(this[T+re]=255&S;--re>=0&&(se*=256);)S<0&&fe===0&&this[T+re+1]!==0&&(fe=1),this[T+re]=(S/se>>0)-fe&255;return T+B},u.prototype.writeInt8=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,1,127,-128),u.TYPED_ARRAY_SUPPORT||(S=Math.floor(S)),S<0&&(S=255+S+1),this[T]=255&S,T+1},u.prototype.writeInt16LE=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[T]=255&S,this[T+1]=S>>>8):z(this,S,T,!0),T+2},u.prototype.writeInt16BE=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[T]=S>>>8,this[T+1]=255&S):z(this,S,T,!1),T+2},u.prototype.writeInt32LE=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[T]=255&S,this[T+1]=S>>>8,this[T+2]=S>>>16,this[T+3]=S>>>24):O(this,S,T,!0),T+4},u.prototype.writeInt32BE=function(S,T,B){return S=+S,T|=0,B||P(this,S,T,4,2147483647,-2147483648),S<0&&(S=4294967295+S+1),u.TYPED_ARRAY_SUPPORT?(this[T]=S>>>24,this[T+1]=S>>>16,this[T+2]=S>>>8,this[T+3]=255&S):O(this,S,T,!1),T+4},u.prototype.writeFloatLE=function(S,T,B){return U(this,S,T,!0,B)},u.prototype.writeFloatBE=function(S,T,B){return U(this,S,T,!1,B)},u.prototype.writeDoubleLE=function(S,T,B){return V(this,S,T,!0,B)},u.prototype.writeDoubleBE=function(S,T,B){return V(this,S,T,!1,B)},u.prototype.copy=function(S,T,B,J){if(B||(B=0),J||J===0||(J=this.length),T>=S.length&&(T=S.length),T||(T=0),J>0&&J<B&&(J=B),J===B||S.length===0||this.length===0)return 0;if(T<0)throw new RangeError("targetStart out of bounds");if(B<0||B>=this.length)throw new RangeError("sourceStart out of bounds");if(J<0)throw new RangeError("sourceEnd out of bounds");J>this.length&&(J=this.length),S.length-T<J-B&&(J=S.length-T+B);var K,re=J-B;if(this===S&&B<T&&T<J)for(K=re-1;K>=0;--K)S[K+T]=this[K+B];else if(re<1e3||!u.TYPED_ARRAY_SUPPORT)for(K=0;K<re;++K)S[K+T]=this[K+B];else Uint8Array.prototype.set.call(S,this.subarray(B,B+re),T);return re},u.prototype.fill=function(S,T,B,J){if(typeof S=="string"){if(typeof T=="string"?(J=T,T=0,B=this.length):typeof B=="string"&&(J=B,B=this.length),S.length===1){var K=S.charCodeAt(0);K<256&&(S=K)}if(J!==void 0&&typeof J!="string")throw new TypeError("encoding must be a string");if(typeof J=="string"&&!u.isEncoding(J))throw new TypeError("Unknown encoding: "+J)}else typeof S=="number"&&(S&=255);if(T<0||this.length<T||this.length<B)throw new RangeError("Out of range index");if(B<=T)return this;var re;if(T>>>=0,B=B===void 0?this.length:B>>>0,S||(S=0),typeof S=="number")for(re=T;re<B;++re)this[re]=S;else{var se=u.isBuffer(S)?S:ne(new u(S,J).toString()),fe=se.length;for(re=0;re<B-T;++re)this[re+T]=se[re%fe]}return this};var Q=/[^+\/0-9A-Za-z-_]/g;function ee(S){return S<16?"0"+S.toString(16):S.toString(16)}function ne(S,T){var B;T=T||1/0;for(var J=S.length,K=null,re=[],se=0;se<J;++se){if((B=S.charCodeAt(se))>55295&&B<57344){if(!K){if(B>56319){(T-=3)>-1&&re.push(239,191,189);continue}if(se+1===J){(T-=3)>-1&&re.push(239,191,189);continue}K=B;continue}if(B<56320){(T-=3)>-1&&re.push(239,191,189),K=B;continue}B=65536+(K-55296<<10|B-56320)}else K&&(T-=3)>-1&&re.push(239,191,189);if(K=null,B<128){if((T-=1)<0)break;re.push(B)}else if(B<2048){if((T-=2)<0)break;re.push(B>>6|192,63&B|128)}else if(B<65536){if((T-=3)<0)break;re.push(B>>12|224,B>>6&63|128,63&B|128)}else{if(!(B<1114112))throw new Error("Invalid code point");if((T-=4)<0)break;re.push(B>>18|240,B>>12&63|128,B>>6&63|128,63&B|128)}}return re}function Y(S){return i.toByteArray(function(T){if((T=function(B){return B.trim?B.trim():B.replace(/^\s+|\s+$/g,"")}(T).replace(Q,"")).length<2)return"";for(;T.length%4!=0;)T+="=";return T}(S))}function G(S,T,B,J){for(var K=0;K<J&&!(K+B>=T.length||K>=S.length);++K)T[K+B]=S[K];return K}}).call(this,n(6))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch{typeof window=="object"&&(n=window)}e.exports=n},function(e,t){typeof Object.create=="function"?e.exports=function(n,r){r&&(n.super_=r,n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(n,r){if(r){n.super_=r;var i=function(){};i.prototype=r.prototype,n.prototype=new i,n.prototype.constructor=n}}},function(e,t,n){n.d(t,"a",function(){return r});const r=i=>new Promise(s=>setTimeout(s,i||0))},function(e,t,n){var r=n(99),i=r,s=Function("return this")(),l=n(98);i.object.extend(proto,l),i.exportSymbol("proto.v1.signaling.api.CreatePeerRequest",null,s),i.exportSymbol("proto.v1.signaling.api.CreatePeerResponse",null,s),i.exportSymbol("proto.v1.signaling.api.DeletePeerRequest",null,s),i.exportSymbol("proto.v1.signaling.api.DeletePeerResponse",null,s),i.exportSymbol("proto.v1.signaling.api.GetHealthRequest",null,s),i.exportSymbol("proto.v1.signaling.api.GetHealthResponse",null,s),i.exportSymbol("proto.v1.signaling.api.GetIceServersRequest",null,s),i.exportSymbol("proto.v1.signaling.api.GetIceServersResponse",null,s),i.exportSymbol("proto.v1.signaling.api.GetPeersRequest",null,s),i.exportSymbol("proto.v1.signaling.api.GetPeersResponse",null,s),i.exportSymbol("proto.v1.signaling.api.Peer",null,s),i.exportSymbol("proto.v1.signaling.api.ReceiveSignalStreamRequest",null,s),i.exportSymbol("proto.v1.signaling.api.ReceiveSignalStreamResponse",null,s),i.exportSymbol("proto.v1.signaling.api.RefreshPeerRequest",null,s),i.exportSymbol("proto.v1.signaling.api.RefreshPeerResponse",null,s),i.exportSymbol("proto.v1.signaling.api.SendSignalRequest",null,s),i.exportSymbol("proto.v1.signaling.api.SendSignalResponse",null,s),i.exportSymbol("proto.v1.signaling.api.SessionType",null,s),i.exportSymbol("proto.v1.signaling.api.Signal",null,s),proto.v1.signaling.api.Peer=function(o){r.Message.initialize(this,o,0,-1,proto.v1.signaling.api.Peer.repeatedFields_,null)},i.inherits(proto.v1.signaling.api.Peer,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.Peer.displayName="proto.v1.signaling.api.Peer"),proto.v1.signaling.api.Signal=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.Signal,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.Signal.displayName="proto.v1.signaling.api.Signal"),proto.v1.signaling.api.GetHealthRequest=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.GetHealthRequest,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetHealthRequest.displayName="proto.v1.signaling.api.GetHealthRequest"),proto.v1.signaling.api.GetHealthResponse=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.GetHealthResponse,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetHealthResponse.displayName="proto.v1.signaling.api.GetHealthResponse"),proto.v1.signaling.api.CreatePeerRequest=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.CreatePeerRequest,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.CreatePeerRequest.displayName="proto.v1.signaling.api.CreatePeerRequest"),proto.v1.signaling.api.CreatePeerResponse=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.CreatePeerResponse,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.CreatePeerResponse.displayName="proto.v1.signaling.api.CreatePeerResponse"),proto.v1.signaling.api.DeletePeerRequest=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.DeletePeerRequest,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.DeletePeerRequest.displayName="proto.v1.signaling.api.DeletePeerRequest"),proto.v1.signaling.api.DeletePeerResponse=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.DeletePeerResponse,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.DeletePeerResponse.displayName="proto.v1.signaling.api.DeletePeerResponse"),proto.v1.signaling.api.RefreshPeerRequest=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.RefreshPeerRequest,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.RefreshPeerRequest.displayName="proto.v1.signaling.api.RefreshPeerRequest"),proto.v1.signaling.api.RefreshPeerResponse=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.RefreshPeerResponse,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.RefreshPeerResponse.displayName="proto.v1.signaling.api.RefreshPeerResponse"),proto.v1.signaling.api.GetPeersRequest=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.GetPeersRequest,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetPeersRequest.displayName="proto.v1.signaling.api.GetPeersRequest"),proto.v1.signaling.api.GetPeersResponse=function(o){r.Message.initialize(this,o,0,-1,proto.v1.signaling.api.GetPeersResponse.repeatedFields_,null)},i.inherits(proto.v1.signaling.api.GetPeersResponse,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetPeersResponse.displayName="proto.v1.signaling.api.GetPeersResponse"),proto.v1.signaling.api.GetIceServersRequest=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.GetIceServersRequest,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetIceServersRequest.displayName="proto.v1.signaling.api.GetIceServersRequest"),proto.v1.signaling.api.GetIceServersResponse=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.GetIceServersResponse,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetIceServersResponse.displayName="proto.v1.signaling.api.GetIceServersResponse"),proto.v1.signaling.api.SendSignalRequest=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.SendSignalRequest,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.SendSignalRequest.displayName="proto.v1.signaling.api.SendSignalRequest"),proto.v1.signaling.api.SendSignalResponse=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.SendSignalResponse,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.SendSignalResponse.displayName="proto.v1.signaling.api.SendSignalResponse"),proto.v1.signaling.api.ReceiveSignalStreamRequest=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.ReceiveSignalStreamRequest,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.ReceiveSignalStreamRequest.displayName="proto.v1.signaling.api.ReceiveSignalStreamRequest"),proto.v1.signaling.api.ReceiveSignalStreamResponse=function(o){r.Message.initialize(this,o,0,-1,null,null)},i.inherits(proto.v1.signaling.api.ReceiveSignalStreamResponse,r.Message),i.DEBUG&&!COMPILED&&(proto.v1.signaling.api.ReceiveSignalStreamResponse.displayName="proto.v1.signaling.api.ReceiveSignalStreamResponse"),proto.v1.signaling.api.Peer.repeatedFields_=[5],r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.Peer.prototype.toObject=function(o){return proto.v1.signaling.api.Peer.toObject(o,this)},proto.v1.signaling.api.Peer.toObject=function(o,c){var u,f={peerId:r.Message.getFieldWithDefault(c,1,""),organizationId:r.Message.getFieldWithDefault(c,2,""),userId:(u=c.getUserId())&&l.StringValue.toObject(o,u),deviceId:(u=c.getDeviceId())&&l.StringValue.toObject(o,u),sessionIdsList:(u=r.Message.getRepeatedField(c,5))==null?void 0:u,peerCreatedTimestamp:(u=c.getPeerCreatedTimestamp())&&l.Int64Value.toObject(o,u)};return o&&(f.$jspbMessageInstance=c),f}),proto.v1.signaling.api.Peer.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.Peer;return proto.v1.signaling.api.Peer.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.Peer.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=c.readString();o.setPeerId(u);break;case 2:u=c.readString(),o.setOrganizationId(u);break;case 3:u=new l.StringValue,c.readMessage(u,l.StringValue.deserializeBinaryFromReader),o.setUserId(u);break;case 4:u=new l.StringValue,c.readMessage(u,l.StringValue.deserializeBinaryFromReader),o.setDeviceId(u);break;case 5:u=c.readString(),o.addSessionIds(u);break;case 6:u=new l.Int64Value,c.readMessage(u,l.Int64Value.deserializeBinaryFromReader),o.setPeerCreatedTimestamp(u);break;default:c.skipField()}return o},proto.v1.signaling.api.Peer.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.Peer.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.Peer.serializeBinaryToWriter=function(o,c){var u=void 0;(u=o.getPeerId()).length>0&&c.writeString(1,u),(u=o.getOrganizationId()).length>0&&c.writeString(2,u),(u=o.getUserId())!=null&&c.writeMessage(3,u,l.StringValue.serializeBinaryToWriter),(u=o.getDeviceId())!=null&&c.writeMessage(4,u,l.StringValue.serializeBinaryToWriter),(u=o.getSessionIdsList()).length>0&&c.writeRepeatedString(5,u),(u=o.getPeerCreatedTimestamp())!=null&&c.writeMessage(6,u,l.Int64Value.serializeBinaryToWriter)},proto.v1.signaling.api.Peer.prototype.getPeerId=function(){return r.Message.getFieldWithDefault(this,1,"")},proto.v1.signaling.api.Peer.prototype.setPeerId=function(o){return r.Message.setProto3StringField(this,1,o)},proto.v1.signaling.api.Peer.prototype.getOrganizationId=function(){return r.Message.getFieldWithDefault(this,2,"")},proto.v1.signaling.api.Peer.prototype.setOrganizationId=function(o){return r.Message.setProto3StringField(this,2,o)},proto.v1.signaling.api.Peer.prototype.getUserId=function(){return r.Message.getWrapperField(this,l.StringValue,3)},proto.v1.signaling.api.Peer.prototype.setUserId=function(o){return r.Message.setWrapperField(this,3,o)},proto.v1.signaling.api.Peer.prototype.clearUserId=function(){return this.setUserId(void 0)},proto.v1.signaling.api.Peer.prototype.hasUserId=function(){return r.Message.getField(this,3)!=null},proto.v1.signaling.api.Peer.prototype.getDeviceId=function(){return r.Message.getWrapperField(this,l.StringValue,4)},proto.v1.signaling.api.Peer.prototype.setDeviceId=function(o){return r.Message.setWrapperField(this,4,o)},proto.v1.signaling.api.Peer.prototype.clearDeviceId=function(){return this.setDeviceId(void 0)},proto.v1.signaling.api.Peer.prototype.hasDeviceId=function(){return r.Message.getField(this,4)!=null},proto.v1.signaling.api.Peer.prototype.getSessionIdsList=function(){return r.Message.getRepeatedField(this,5)},proto.v1.signaling.api.Peer.prototype.setSessionIdsList=function(o){return r.Message.setField(this,5,o||[])},proto.v1.signaling.api.Peer.prototype.addSessionIds=function(o,c){return r.Message.addToRepeatedField(this,5,o,c)},proto.v1.signaling.api.Peer.prototype.clearSessionIdsList=function(){return this.setSessionIdsList([])},proto.v1.signaling.api.Peer.prototype.getPeerCreatedTimestamp=function(){return r.Message.getWrapperField(this,l.Int64Value,6)},proto.v1.signaling.api.Peer.prototype.setPeerCreatedTimestamp=function(o){return r.Message.setWrapperField(this,6,o)},proto.v1.signaling.api.Peer.prototype.clearPeerCreatedTimestamp=function(){return this.setPeerCreatedTimestamp(void 0)},proto.v1.signaling.api.Peer.prototype.hasPeerCreatedTimestamp=function(){return r.Message.getField(this,6)!=null},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.Signal.prototype.toObject=function(o){return proto.v1.signaling.api.Signal.toObject(o,this)},proto.v1.signaling.api.Signal.toObject=function(o,c){var u,f={sessionId:(u=c.getSessionId())&&l.StringValue.toObject(o,u),sessionCreatedTimestamp:(u=c.getSessionCreatedTimestamp())&&l.Int64Value.toObject(o,u),senderId:r.Message.getFieldWithDefault(c,3,""),receiverId:r.Message.getFieldWithDefault(c,4,""),payload:r.Message.getFieldWithDefault(c,5,""),iceServers:r.Message.getFieldWithDefault(c,6,""),iceTransportPolicy:r.Message.getFieldWithDefault(c,7,""),sessionType:r.Message.getFieldWithDefault(c,8,0)};return o&&(f.$jspbMessageInstance=c),f}),proto.v1.signaling.api.Signal.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.Signal;return proto.v1.signaling.api.Signal.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.Signal.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new l.StringValue;c.readMessage(u,l.StringValue.deserializeBinaryFromReader),o.setSessionId(u);break;case 2:u=new l.Int64Value,c.readMessage(u,l.Int64Value.deserializeBinaryFromReader),o.setSessionCreatedTimestamp(u);break;case 3:u=c.readString(),o.setSenderId(u);break;case 4:u=c.readString(),o.setReceiverId(u);break;case 5:u=c.readString(),o.setPayload(u);break;case 6:u=c.readString(),o.setIceServers(u);break;case 7:u=c.readString(),o.setIceTransportPolicy(u);break;case 8:u=c.readEnum(),o.setSessionType(u);break;default:c.skipField()}return o},proto.v1.signaling.api.Signal.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.Signal.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.Signal.serializeBinaryToWriter=function(o,c){var u=void 0;(u=o.getSessionId())!=null&&c.writeMessage(1,u,l.StringValue.serializeBinaryToWriter),(u=o.getSessionCreatedTimestamp())!=null&&c.writeMessage(2,u,l.Int64Value.serializeBinaryToWriter),(u=o.getSenderId()).length>0&&c.writeString(3,u),(u=o.getReceiverId()).length>0&&c.writeString(4,u),(u=o.getPayload()).length>0&&c.writeString(5,u),(u=o.getIceServers()).length>0&&c.writeString(6,u),(u=o.getIceTransportPolicy()).length>0&&c.writeString(7,u),(u=o.getSessionType())!==0&&c.writeEnum(8,u)},proto.v1.signaling.api.Signal.prototype.getSessionId=function(){return r.Message.getWrapperField(this,l.StringValue,1)},proto.v1.signaling.api.Signal.prototype.setSessionId=function(o){return r.Message.setWrapperField(this,1,o)},proto.v1.signaling.api.Signal.prototype.clearSessionId=function(){return this.setSessionId(void 0)},proto.v1.signaling.api.Signal.prototype.hasSessionId=function(){return r.Message.getField(this,1)!=null},proto.v1.signaling.api.Signal.prototype.getSessionCreatedTimestamp=function(){return r.Message.getWrapperField(this,l.Int64Value,2)},proto.v1.signaling.api.Signal.prototype.setSessionCreatedTimestamp=function(o){return r.Message.setWrapperField(this,2,o)},proto.v1.signaling.api.Signal.prototype.clearSessionCreatedTimestamp=function(){return this.setSessionCreatedTimestamp(void 0)},proto.v1.signaling.api.Signal.prototype.hasSessionCreatedTimestamp=function(){return r.Message.getField(this,2)!=null},proto.v1.signaling.api.Signal.prototype.getSenderId=function(){return r.Message.getFieldWithDefault(this,3,"")},proto.v1.signaling.api.Signal.prototype.setSenderId=function(o){return r.Message.setProto3StringField(this,3,o)},proto.v1.signaling.api.Signal.prototype.getReceiverId=function(){return r.Message.getFieldWithDefault(this,4,"")},proto.v1.signaling.api.Signal.prototype.setReceiverId=function(o){return r.Message.setProto3StringField(this,4,o)},proto.v1.signaling.api.Signal.prototype.getPayload=function(){return r.Message.getFieldWithDefault(this,5,"")},proto.v1.signaling.api.Signal.prototype.setPayload=function(o){return r.Message.setProto3StringField(this,5,o)},proto.v1.signaling.api.Signal.prototype.getIceServers=function(){return r.Message.getFieldWithDefault(this,6,"")},proto.v1.signaling.api.Signal.prototype.setIceServers=function(o){return r.Message.setProto3StringField(this,6,o)},proto.v1.signaling.api.Signal.prototype.getIceTransportPolicy=function(){return r.Message.getFieldWithDefault(this,7,"")},proto.v1.signaling.api.Signal.prototype.setIceTransportPolicy=function(o){return r.Message.setProto3StringField(this,7,o)},proto.v1.signaling.api.Signal.prototype.getSessionType=function(){return r.Message.getFieldWithDefault(this,8,0)},proto.v1.signaling.api.Signal.prototype.setSessionType=function(o){return r.Message.setProto3EnumField(this,8,o)},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetHealthRequest.prototype.toObject=function(o){return proto.v1.signaling.api.GetHealthRequest.toObject(o,this)},proto.v1.signaling.api.GetHealthRequest.toObject=function(o,c){var u={};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetHealthRequest.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.GetHealthRequest;return proto.v1.signaling.api.GetHealthRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetHealthRequest.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return o},proto.v1.signaling.api.GetHealthRequest.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.GetHealthRequest.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.GetHealthRequest.serializeBinaryToWriter=function(o,c){},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetHealthResponse.prototype.toObject=function(o){return proto.v1.signaling.api.GetHealthResponse.toObject(o,this)},proto.v1.signaling.api.GetHealthResponse.toObject=function(o,c){var u={version:r.Message.getFieldWithDefault(c,1,"")};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetHealthResponse.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.GetHealthResponse;return proto.v1.signaling.api.GetHealthResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetHealthResponse.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=c.readString();o.setVersion(u);break;default:c.skipField()}return o},proto.v1.signaling.api.GetHealthResponse.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.GetHealthResponse.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.GetHealthResponse.serializeBinaryToWriter=function(o,c){var u;(u=o.getVersion()).length>0&&c.writeString(1,u)},proto.v1.signaling.api.GetHealthResponse.prototype.getVersion=function(){return r.Message.getFieldWithDefault(this,1,"")},proto.v1.signaling.api.GetHealthResponse.prototype.setVersion=function(o){return r.Message.setProto3StringField(this,1,o)},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.CreatePeerRequest.prototype.toObject=function(o){return proto.v1.signaling.api.CreatePeerRequest.toObject(o,this)},proto.v1.signaling.api.CreatePeerRequest.toObject=function(o,c){var u={};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.CreatePeerRequest.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.CreatePeerRequest;return proto.v1.signaling.api.CreatePeerRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.CreatePeerRequest.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return o},proto.v1.signaling.api.CreatePeerRequest.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.CreatePeerRequest.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.CreatePeerRequest.serializeBinaryToWriter=function(o,c){},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.CreatePeerResponse.prototype.toObject=function(o){return proto.v1.signaling.api.CreatePeerResponse.toObject(o,this)},proto.v1.signaling.api.CreatePeerResponse.toObject=function(o,c){var u,f={peer:(u=c.getPeer())&&proto.v1.signaling.api.Peer.toObject(o,u)};return o&&(f.$jspbMessageInstance=c),f}),proto.v1.signaling.api.CreatePeerResponse.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.CreatePeerResponse;return proto.v1.signaling.api.CreatePeerResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.CreatePeerResponse.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Peer;c.readMessage(u,proto.v1.signaling.api.Peer.deserializeBinaryFromReader),o.setPeer(u);break;default:c.skipField()}return o},proto.v1.signaling.api.CreatePeerResponse.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.CreatePeerResponse.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.CreatePeerResponse.serializeBinaryToWriter=function(o,c){var u;(u=o.getPeer())!=null&&c.writeMessage(1,u,proto.v1.signaling.api.Peer.serializeBinaryToWriter)},proto.v1.signaling.api.CreatePeerResponse.prototype.getPeer=function(){return r.Message.getWrapperField(this,proto.v1.signaling.api.Peer,1)},proto.v1.signaling.api.CreatePeerResponse.prototype.setPeer=function(o){return r.Message.setWrapperField(this,1,o)},proto.v1.signaling.api.CreatePeerResponse.prototype.clearPeer=function(){return this.setPeer(void 0)},proto.v1.signaling.api.CreatePeerResponse.prototype.hasPeer=function(){return r.Message.getField(this,1)!=null},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.DeletePeerRequest.prototype.toObject=function(o){return proto.v1.signaling.api.DeletePeerRequest.toObject(o,this)},proto.v1.signaling.api.DeletePeerRequest.toObject=function(o,c){var u={peerId:r.Message.getFieldWithDefault(c,1,"")};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.DeletePeerRequest.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.DeletePeerRequest;return proto.v1.signaling.api.DeletePeerRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.DeletePeerRequest.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=c.readString();o.setPeerId(u);break;default:c.skipField()}return o},proto.v1.signaling.api.DeletePeerRequest.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.DeletePeerRequest.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.DeletePeerRequest.serializeBinaryToWriter=function(o,c){var u;(u=o.getPeerId()).length>0&&c.writeString(1,u)},proto.v1.signaling.api.DeletePeerRequest.prototype.getPeerId=function(){return r.Message.getFieldWithDefault(this,1,"")},proto.v1.signaling.api.DeletePeerRequest.prototype.setPeerId=function(o){return r.Message.setProto3StringField(this,1,o)},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.DeletePeerResponse.prototype.toObject=function(o){return proto.v1.signaling.api.DeletePeerResponse.toObject(o,this)},proto.v1.signaling.api.DeletePeerResponse.toObject=function(o,c){var u={};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.DeletePeerResponse.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.DeletePeerResponse;return proto.v1.signaling.api.DeletePeerResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.DeletePeerResponse.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return o},proto.v1.signaling.api.DeletePeerResponse.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.DeletePeerResponse.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.DeletePeerResponse.serializeBinaryToWriter=function(o,c){},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.RefreshPeerRequest.prototype.toObject=function(o){return proto.v1.signaling.api.RefreshPeerRequest.toObject(o,this)},proto.v1.signaling.api.RefreshPeerRequest.toObject=function(o,c){var u,f={peer:(u=c.getPeer())&&proto.v1.signaling.api.Peer.toObject(o,u)};return o&&(f.$jspbMessageInstance=c),f}),proto.v1.signaling.api.RefreshPeerRequest.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.RefreshPeerRequest;return proto.v1.signaling.api.RefreshPeerRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.RefreshPeerRequest.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Peer;c.readMessage(u,proto.v1.signaling.api.Peer.deserializeBinaryFromReader),o.setPeer(u);break;default:c.skipField()}return o},proto.v1.signaling.api.RefreshPeerRequest.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.RefreshPeerRequest.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.RefreshPeerRequest.serializeBinaryToWriter=function(o,c){var u;(u=o.getPeer())!=null&&c.writeMessage(1,u,proto.v1.signaling.api.Peer.serializeBinaryToWriter)},proto.v1.signaling.api.RefreshPeerRequest.prototype.getPeer=function(){return r.Message.getWrapperField(this,proto.v1.signaling.api.Peer,1)},proto.v1.signaling.api.RefreshPeerRequest.prototype.setPeer=function(o){return r.Message.setWrapperField(this,1,o)},proto.v1.signaling.api.RefreshPeerRequest.prototype.clearPeer=function(){return this.setPeer(void 0)},proto.v1.signaling.api.RefreshPeerRequest.prototype.hasPeer=function(){return r.Message.getField(this,1)!=null},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.RefreshPeerResponse.prototype.toObject=function(o){return proto.v1.signaling.api.RefreshPeerResponse.toObject(o,this)},proto.v1.signaling.api.RefreshPeerResponse.toObject=function(o,c){var u={};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.RefreshPeerResponse.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.RefreshPeerResponse;return proto.v1.signaling.api.RefreshPeerResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.RefreshPeerResponse.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return o},proto.v1.signaling.api.RefreshPeerResponse.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.RefreshPeerResponse.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.RefreshPeerResponse.serializeBinaryToWriter=function(o,c){},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetPeersRequest.prototype.toObject=function(o){return proto.v1.signaling.api.GetPeersRequest.toObject(o,this)},proto.v1.signaling.api.GetPeersRequest.toObject=function(o,c){var u={};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetPeersRequest.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.GetPeersRequest;return proto.v1.signaling.api.GetPeersRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetPeersRequest.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return o},proto.v1.signaling.api.GetPeersRequest.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.GetPeersRequest.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.GetPeersRequest.serializeBinaryToWriter=function(o,c){},proto.v1.signaling.api.GetPeersResponse.repeatedFields_=[1],r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetPeersResponse.prototype.toObject=function(o){return proto.v1.signaling.api.GetPeersResponse.toObject(o,this)},proto.v1.signaling.api.GetPeersResponse.toObject=function(o,c){var u={peersList:r.Message.toObjectList(c.getPeersList(),proto.v1.signaling.api.Peer.toObject,o)};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetPeersResponse.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.GetPeersResponse;return proto.v1.signaling.api.GetPeersResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetPeersResponse.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Peer;c.readMessage(u,proto.v1.signaling.api.Peer.deserializeBinaryFromReader),o.addPeers(u);break;default:c.skipField()}return o},proto.v1.signaling.api.GetPeersResponse.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.GetPeersResponse.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.GetPeersResponse.serializeBinaryToWriter=function(o,c){var u;(u=o.getPeersList()).length>0&&c.writeRepeatedMessage(1,u,proto.v1.signaling.api.Peer.serializeBinaryToWriter)},proto.v1.signaling.api.GetPeersResponse.prototype.getPeersList=function(){return r.Message.getRepeatedWrapperField(this,proto.v1.signaling.api.Peer,1)},proto.v1.signaling.api.GetPeersResponse.prototype.setPeersList=function(o){return r.Message.setRepeatedWrapperField(this,1,o)},proto.v1.signaling.api.GetPeersResponse.prototype.addPeers=function(o,c){return r.Message.addToRepeatedWrapperField(this,1,o,proto.v1.signaling.api.Peer,c)},proto.v1.signaling.api.GetPeersResponse.prototype.clearPeersList=function(){return this.setPeersList([])},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetIceServersRequest.prototype.toObject=function(o){return proto.v1.signaling.api.GetIceServersRequest.toObject(o,this)},proto.v1.signaling.api.GetIceServersRequest.toObject=function(o,c){var u={};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetIceServersRequest.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.GetIceServersRequest;return proto.v1.signaling.api.GetIceServersRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetIceServersRequest.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return o},proto.v1.signaling.api.GetIceServersRequest.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.GetIceServersRequest.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.GetIceServersRequest.serializeBinaryToWriter=function(o,c){},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetIceServersResponse.prototype.toObject=function(o){return proto.v1.signaling.api.GetIceServersResponse.toObject(o,this)},proto.v1.signaling.api.GetIceServersResponse.toObject=function(o,c){var u={iceServers:r.Message.getFieldWithDefault(c,1,"")};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetIceServersResponse.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.GetIceServersResponse;return proto.v1.signaling.api.GetIceServersResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetIceServersResponse.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=c.readString();o.setIceServers(u);break;default:c.skipField()}return o},proto.v1.signaling.api.GetIceServersResponse.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.GetIceServersResponse.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.GetIceServersResponse.serializeBinaryToWriter=function(o,c){var u;(u=o.getIceServers()).length>0&&c.writeString(1,u)},proto.v1.signaling.api.GetIceServersResponse.prototype.getIceServers=function(){return r.Message.getFieldWithDefault(this,1,"")},proto.v1.signaling.api.GetIceServersResponse.prototype.setIceServers=function(o){return r.Message.setProto3StringField(this,1,o)},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.SendSignalRequest.prototype.toObject=function(o){return proto.v1.signaling.api.SendSignalRequest.toObject(o,this)},proto.v1.signaling.api.SendSignalRequest.toObject=function(o,c){var u,f={signal:(u=c.getSignal())&&proto.v1.signaling.api.Signal.toObject(o,u)};return o&&(f.$jspbMessageInstance=c),f}),proto.v1.signaling.api.SendSignalRequest.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.SendSignalRequest;return proto.v1.signaling.api.SendSignalRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.SendSignalRequest.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Signal;c.readMessage(u,proto.v1.signaling.api.Signal.deserializeBinaryFromReader),o.setSignal(u);break;default:c.skipField()}return o},proto.v1.signaling.api.SendSignalRequest.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.SendSignalRequest.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.SendSignalRequest.serializeBinaryToWriter=function(o,c){var u;(u=o.getSignal())!=null&&c.writeMessage(1,u,proto.v1.signaling.api.Signal.serializeBinaryToWriter)},proto.v1.signaling.api.SendSignalRequest.prototype.getSignal=function(){return r.Message.getWrapperField(this,proto.v1.signaling.api.Signal,1)},proto.v1.signaling.api.SendSignalRequest.prototype.setSignal=function(o){return r.Message.setWrapperField(this,1,o)},proto.v1.signaling.api.SendSignalRequest.prototype.clearSignal=function(){return this.setSignal(void 0)},proto.v1.signaling.api.SendSignalRequest.prototype.hasSignal=function(){return r.Message.getField(this,1)!=null},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.SendSignalResponse.prototype.toObject=function(o){return proto.v1.signaling.api.SendSignalResponse.toObject(o,this)},proto.v1.signaling.api.SendSignalResponse.toObject=function(o,c){var u,f={sessionId:(u=c.getSessionId())&&l.StringValue.toObject(o,u),sessionCreatedTimestamp:(u=c.getSessionCreatedTimestamp())&&l.Int64Value.toObject(o,u)};return o&&(f.$jspbMessageInstance=c),f}),proto.v1.signaling.api.SendSignalResponse.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.SendSignalResponse;return proto.v1.signaling.api.SendSignalResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.SendSignalResponse.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new l.StringValue;c.readMessage(u,l.StringValue.deserializeBinaryFromReader),o.setSessionId(u);break;case 2:u=new l.Int64Value,c.readMessage(u,l.Int64Value.deserializeBinaryFromReader),o.setSessionCreatedTimestamp(u);break;default:c.skipField()}return o},proto.v1.signaling.api.SendSignalResponse.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.SendSignalResponse.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.SendSignalResponse.serializeBinaryToWriter=function(o,c){var u=void 0;(u=o.getSessionId())!=null&&c.writeMessage(1,u,l.StringValue.serializeBinaryToWriter),(u=o.getSessionCreatedTimestamp())!=null&&c.writeMessage(2,u,l.Int64Value.serializeBinaryToWriter)},proto.v1.signaling.api.SendSignalResponse.prototype.getSessionId=function(){return r.Message.getWrapperField(this,l.StringValue,1)},proto.v1.signaling.api.SendSignalResponse.prototype.setSessionId=function(o){return r.Message.setWrapperField(this,1,o)},proto.v1.signaling.api.SendSignalResponse.prototype.clearSessionId=function(){return this.setSessionId(void 0)},proto.v1.signaling.api.SendSignalResponse.prototype.hasSessionId=function(){return r.Message.getField(this,1)!=null},proto.v1.signaling.api.SendSignalResponse.prototype.getSessionCreatedTimestamp=function(){return r.Message.getWrapperField(this,l.Int64Value,2)},proto.v1.signaling.api.SendSignalResponse.prototype.setSessionCreatedTimestamp=function(o){return r.Message.setWrapperField(this,2,o)},proto.v1.signaling.api.SendSignalResponse.prototype.clearSessionCreatedTimestamp=function(){return this.setSessionCreatedTimestamp(void 0)},proto.v1.signaling.api.SendSignalResponse.prototype.hasSessionCreatedTimestamp=function(){return r.Message.getField(this,2)!=null},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.ReceiveSignalStreamRequest.prototype.toObject=function(o){return proto.v1.signaling.api.ReceiveSignalStreamRequest.toObject(o,this)},proto.v1.signaling.api.ReceiveSignalStreamRequest.toObject=function(o,c){var u={peerId:r.Message.getFieldWithDefault(c,1,"")};return o&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.ReceiveSignalStreamRequest.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.ReceiveSignalStreamRequest;return proto.v1.signaling.api.ReceiveSignalStreamRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.ReceiveSignalStreamRequest.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=c.readString();o.setPeerId(u);break;default:c.skipField()}return o},proto.v1.signaling.api.ReceiveSignalStreamRequest.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.ReceiveSignalStreamRequest.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.ReceiveSignalStreamRequest.serializeBinaryToWriter=function(o,c){var u;(u=o.getPeerId()).length>0&&c.writeString(1,u)},proto.v1.signaling.api.ReceiveSignalStreamRequest.prototype.getPeerId=function(){return r.Message.getFieldWithDefault(this,1,"")},proto.v1.signaling.api.ReceiveSignalStreamRequest.prototype.setPeerId=function(o){return r.Message.setProto3StringField(this,1,o)},r.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.toObject=function(o){return proto.v1.signaling.api.ReceiveSignalStreamResponse.toObject(o,this)},proto.v1.signaling.api.ReceiveSignalStreamResponse.toObject=function(o,c){var u,f={signal:(u=c.getSignal())&&proto.v1.signaling.api.Signal.toObject(o,u)};return o&&(f.$jspbMessageInstance=c),f}),proto.v1.signaling.api.ReceiveSignalStreamResponse.deserializeBinary=function(o){var c=new r.BinaryReader(o),u=new proto.v1.signaling.api.ReceiveSignalStreamResponse;return proto.v1.signaling.api.ReceiveSignalStreamResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.ReceiveSignalStreamResponse.deserializeBinaryFromReader=function(o,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Signal;c.readMessage(u,proto.v1.signaling.api.Signal.deserializeBinaryFromReader),o.setSignal(u);break;default:c.skipField()}return o},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.serializeBinary=function(){var o=new r.BinaryWriter;return proto.v1.signaling.api.ReceiveSignalStreamResponse.serializeBinaryToWriter(this,o),o.getResultBuffer()},proto.v1.signaling.api.ReceiveSignalStreamResponse.serializeBinaryToWriter=function(o,c){var u;(u=o.getSignal())!=null&&c.writeMessage(1,u,proto.v1.signaling.api.Signal.serializeBinaryToWriter)},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.getSignal=function(){return r.Message.getWrapperField(this,proto.v1.signaling.api.Signal,1)},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.setSignal=function(o){return r.Message.setWrapperField(this,1,o)},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.clearSignal=function(){return this.setSignal(void 0)},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.hasSignal=function(){return r.Message.getField(this,1)!=null},proto.v1.signaling.api.SessionType={UNKNOWN:0,TELEOP:1,PORT_FORWARD:2,OBSERVE:3},i.object.extend(t,proto.v1.signaling.api)},function(e,t,n){n.d(t,"a",function(){return i});var r=n(34);class i extends Error{constructor(l,o,c,u,f={},E){super(`Unexpected response (${c}) for ${l} ${o}: ${JSON.stringify(E?Object(r.a)([...E.entries()].reduce((_,[h,g])=>(_[h]=g,_),{})):{})} -- ${JSON.stringify(Object(r.a)(u))}`),this.method=l,this.url=o,this.statusCode=c,this.body=u,this.validationErrors=f,this.headers=E}}},function(e,t,n){function r(i,s,l=()=>!0){if(function(o,c,u=()=>!0){return o instanceof c&&u(o)}(i,s,l))return i;throw i}n.d(t,"a",function(){return r})},function(e,t,n){function r(_){return(r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h})(_)}function i(_,h){return!h||r(h)!=="object"&&typeof h!="function"?s(_):h}function s(_){if(_===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _}function l(_){var h=typeof Map=="function"?new Map:void 0;return(l=function(g){if(g===null||(b=g,Function.toString.call(b).indexOf("[native code]")===-1))return g;var b;if(typeof g!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(g))return h.get(g);h.set(g,A)}function A(){return o(g,arguments,f(this).constructor)}return A.prototype=Object.create(g.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}}),u(A,g)})(_)}function o(_,h,g){return(o=c()?Reflect.construct:function(b,A,j){var F=[null];F.push.apply(F,A);var M=new(Function.bind.apply(b,F));return j&&u(M,j.prototype),M}).apply(null,arguments)}function c(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function u(_,h){return(u=Object.setPrototypeOf||function(g,b){return g.__proto__=b,g})(_,h)}function f(_){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(h){return h.__proto__||Object.getPrototypeOf(h)})(_)}var E=function(_){(function(j,F){if(typeof F!="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(F&&F.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),F&&u(j,F)})(A,_);var h,g,b=(h=A,g=c(),function(){var j,F=f(h);if(g){var M=f(this).constructor;j=Reflect.construct(F,arguments,M)}else j=F.apply(this,arguments);return i(this,j)});function A(j){var F;return function(M,R){if(!(M instanceof R))throw new TypeError("Cannot call a class as a function")}(this,A),F=b.call(this,`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
8
8
|
Found: `.concat(j.toString().split(`
|
|
9
9
|
`)[0],`
|
|
@@ -18,10 +18,10 @@ Found: `.concat(j.toString().split(`
|
|
|
18
18
|
`).map(function(ne){return" "+ne}).join(`
|
|
19
19
|
`)):Q=N.stylize("[Circular]","special")),M(V)){if(U&&p.match(/^\d+$/))return Q;(V=JSON.stringify(""+p)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(V=V.substr(1,V.length-2),V=N.stylize(V,"name")):(V=V.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),V=N.stylize(V,"string"))}return V+": "+Q}function g(N){return Array.isArray(N)}function b(N){return typeof N=="boolean"}function A(N){return N===null}function j(N){return typeof N=="number"}function F(N){return typeof N=="string"}function M(N){return N===void 0}function R(N){return d(N)&&y(N)==="[object RegExp]"}function d(N){return typeof N=="object"&&N!==null}function I(N){return d(N)&&y(N)==="[object Date]"}function $(N){return d(N)&&(y(N)==="[object Error]"||N instanceof Error)}function q(N){return typeof N=="function"}function y(N){return Object.prototype.toString.call(N)}function m(N){return N<10?"0"+N.toString(10):N.toString(10)}t.debuglog=function(N){if(M(l)&&(l=r.env.NODE_DEBUG||""),N=N.toUpperCase(),!o[N])if(new RegExp("\\b"+N+"\\b","i").test(l)){var P=r.pid;o[N]=function(){var z=t.format.apply(t,arguments);console.error("%s %d: %s",N,P,z)}}else o[N]=function(){};return o[N]},t.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=g,t.isBoolean=b,t.isNull=A,t.isNullOrUndefined=function(N){return N==null},t.isNumber=j,t.isString=F,t.isSymbol=function(N){return typeof N=="symbol"},t.isUndefined=M,t.isRegExp=R,t.isObject=d,t.isDate=I,t.isError=$,t.isFunction=q,t.isPrimitive=function(N){return N===null||typeof N=="boolean"||typeof N=="number"||typeof N=="string"||typeof N=="symbol"||N===void 0},t.isBuffer=n(107);var C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function w(){var N=new Date,P=[m(N.getHours()),m(N.getMinutes()),m(N.getSeconds())].join(":");return[N.getDate(),C[N.getMonth()],P].join(" ")}function L(N,P){return Object.prototype.hasOwnProperty.call(N,P)}t.log=function(){console.log("%s - %s",w(),t.format.apply(t,arguments))},t.inherits=n(108),t._extend=function(N,P){if(!P||!d(P))return N;for(var z=Object.keys(P),O=z.length;O--;)N[z[O]]=P[z[O]];return N};var W=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;function k(N,P){if(!N){var z=new Error("Promise was rejected with a falsy value");z.reason=N,N=z}return P(N)}t.promisify=function(N){if(typeof N!="function")throw new TypeError('The "original" argument must be of type Function');if(W&&N[W]){var P;if(typeof(P=N[W])!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(P,W,{value:P,enumerable:!1,writable:!1,configurable:!0}),P}function P(){for(var z,O,p=new Promise(function(Q,ee){z=Q,O=ee}),U=[],V=0;V<arguments.length;V++)U.push(arguments[V]);U.push(function(Q,ee){Q?O(Q):z(ee)});try{N.apply(this,U)}catch(Q){O(Q)}return p}return Object.setPrototypeOf(P,Object.getPrototypeOf(N)),W&&Object.defineProperty(P,W,{value:P,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(P,i(N))},t.promisify.custom=W,t.callbackify=function(N){if(typeof N!="function")throw new TypeError('The "original" argument must be of type Function');function P(){for(var z=[],O=0;O<arguments.length;O++)z.push(arguments[O]);var p=z.pop();if(typeof p!="function")throw new TypeError("The last argument must be of type Function");var U=this,V=function(){return p.apply(U,arguments)};N.apply(this,z).then(function(Q){r.nextTick(V,null,Q)},function(Q){r.nextTick(k,Q,V)})}return Object.setPrototypeOf(P,Object.getPrototypeOf(N)),Object.defineProperties(P,i(N)),P}}).call(this,n(2))},function(e,t,n){e.exports=function(r,i){i||(i={}),typeof i=="function"&&(i={cmp:i});var s,l=typeof i.cycles=="boolean"&&i.cycles,o=i.cmp&&(s=i.cmp,function(u){return function(f,E){var _={key:f,value:u[f]},h={key:E,value:u[E]};return s(_,h)}}),c=[];return function u(f){if(f&&f.toJSON&&typeof f.toJSON=="function"&&(f=f.toJSON()),f!==void 0){if(typeof f=="number")return isFinite(f)?""+f:"null";if(typeof f!="object")return JSON.stringify(f);var E,_;if(Array.isArray(f)){for(_="[",E=0;E<f.length;E++)E&&(_+=","),_+=u(f[E])||"null";return _+"]"}if(f===null)return"null";if(c.indexOf(f)!==-1){if(l)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var h=c.push(f)-1,g=Object.keys(f).sort(o&&o(f));for(_="",E=0;E<g.length;E++){var b=g[E],A=u(f[b]);A&&(_&&(_+=","),_+=JSON.stringify(b)+":"+A)}return c.splice(h,1),"{"+_+"}"}}(r)}},function(e,t,n){(function(r){var i=r!==void 0&&r||typeof self<"u"&&self||window,s=Function.prototype.apply;function l(o,c){this._id=o,this._clearFn=c}t.setTimeout=function(){return new l(s.call(setTimeout,i,arguments),clearTimeout)},t.setInterval=function(){return new l(s.call(setInterval,i,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(o){o&&o.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(i,this._id)},t.enroll=function(o,c){clearTimeout(o._idleTimeoutId),o._idleTimeout=c},t.unenroll=function(o){clearTimeout(o._idleTimeoutId),o._idleTimeout=-1},t._unrefActive=t.active=function(o){clearTimeout(o._idleTimeoutId);var c=o._idleTimeout;c>=0&&(o._idleTimeoutId=setTimeout(function(){o._onTimeout&&o._onTimeout()},c))},n(141),t.setImmediate=typeof self<"u"&&self.setImmediate||r!==void 0&&r.setImmediate||this&&this.setImmediate,t.clearImmediate=typeof self<"u"&&self.clearImmediate||r!==void 0&&r.clearImmediate||this&&this.clearImmediate}).call(this,n(6))},function(e,t,n){(function(r){r===void 0||!r.version||r.version.indexOf("v0.")===0||r.version.indexOf("v1.")===0&&r.version.indexOf("v1.8.")!==0?e.exports={nextTick:function(i,s,l,o){if(typeof i!="function")throw new TypeError('"callback" argument must be a function');var c,u,f=arguments.length;switch(f){case 0:case 1:return r.nextTick(i);case 2:return r.nextTick(function(){i.call(null,s)});case 3:return r.nextTick(function(){i.call(null,s,l)});case 4:return r.nextTick(function(){i.call(null,s,l,o)});default:for(c=new Array(f-1),u=0;u<c.length;)c[u++]=arguments[u];return r.nextTick(function(){i.apply(null,c)})}}}:e.exports=r}).call(this,n(2))},function(e,t,n){(function(r){function i(s){return Object.prototype.toString.call(s)}t.isArray=function(s){return Array.isArray?Array.isArray(s):i(s)==="[object Array]"},t.isBoolean=function(s){return typeof s=="boolean"},t.isNull=function(s){return s===null},t.isNullOrUndefined=function(s){return s==null},t.isNumber=function(s){return typeof s=="number"},t.isString=function(s){return typeof s=="string"},t.isSymbol=function(s){return typeof s=="symbol"},t.isUndefined=function(s){return s===void 0},t.isRegExp=function(s){return i(s)==="[object RegExp]"},t.isObject=function(s){return typeof s=="object"&&s!==null},t.isDate=function(s){return i(s)==="[object Date]"},t.isError=function(s){return i(s)==="[object Error]"||s instanceof Error},t.isFunction=function(s){return typeof s=="function"},t.isPrimitive=function(s){return s===null||typeof s=="boolean"||typeof s=="number"||typeof s=="string"||typeof s=="symbol"||s===void 0},t.isBuffer=r.isBuffer}).call(this,n(5).Buffer)},function(e,t){t.endianness=function(){return"LE"},t.hostname=function(){return typeof location<"u"?location.hostname:""},t.loadavg=function(){return[]},t.uptime=function(){return 0},t.freemem=function(){return Number.MAX_VALUE},t.totalmem=function(){return Number.MAX_VALUE},t.cpus=function(){return[]},t.type=function(){return"Browser"},t.release=function(){return typeof navigator<"u"?navigator.appVersion:""},t.networkInterfaces=t.getNetworkInterfaces=function(){return{}},t.arch=function(){return"javascript"},t.platform=function(){return"browser"},t.tmpdir=t.tmpDir=function(){return"/tmp"},t.EOL=`
|
|
20
20
|
`,t.homedir=function(){return"/"}},function(e,t,n){var r=n(58),i=n(61).warn,s=t;s.version=n(138).version,s.transports=n(139),s.config=n(50),s.addColors=r.levels,s.format=r.format,s.createLogger=n(88),s.ExceptionHandler=n(89),s.RejectionHandler=n(93),s.Container=n(210),s.Transport=n(20),s.loggers=new s.Container;var l=s.createLogger();Object.keys(s.config.npm.levels).concat(["log","query","stream","add","remove","clear","profile","startTimer","handleExceptions","unhandleExceptions","handleRejections","unhandleRejections","configure","child"]).forEach(function(o){return s[o]=function(){return l[o].apply(l,arguments)}}),Object.defineProperty(s,"level",{get:function(){return l.level},set:function(o){l.level=o}}),Object.defineProperty(s,"exceptions",{get:function(){return l.exceptions}}),["exitOnError"].forEach(function(o){Object.defineProperty(s,o,{get:function(){return l[o]},set:function(c){l[o]=c}})}),Object.defineProperty(s,"default",{get:function(){return{exceptionHandlers:l.exceptionHandlers,rejectionHandlers:l.rejectionHandlers,transports:l.transports}}}),i.deprecated(s,"setLevels"),i.forFunctions(s,"useFormat",["cli"]),i.forProperties(s,"useFormat",["padLevels","stripColors"]),i.forFunctions(s,"deprecated",["addRewriter","addFilter","clone","extend"]),i.forProperties(s,"deprecated",["emitErrs","levelLength"]),i.moved(s,"createLogger","Logger")},function(e,t,n){var r=n(13),i=n(142),s=n(3).LEVEL,l=e.exports=function(){var o=this,c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};i.call(this,{objectMode:!0,highWaterMark:c.highWaterMark}),this.format=c.format,this.level=c.level,this.handleExceptions=c.handleExceptions,this.handleRejections=c.handleRejections,this.silent=c.silent,c.log&&(this.log=c.log),c.logv&&(this.logv=c.logv),c.close&&(this.close=c.close),this.once("pipe",function(u){o.levels=u.levels,o.parent=u}),this.once("unpipe",function(u){u===o.parent&&(o.parent=null,o.close&&o.close())})};r.inherits(l,i),l.prototype._write=function(o,c,u){if(this.silent||o.exception===!0&&!this.handleExceptions)return u(null);var f=this.level||this.parent&&this.parent.level;if(!f||this.levels[f]>=this.levels[o[s]]){if(o&&!this.format)return this.log(o,u);var E=void 0,_=void 0;try{_=this.format.transform(Object.assign({},o),this.format.options)}catch(h){E=h}if(E||!_){if(u(),E)throw E;return}return this.log(_,u)}return u(null)},l.prototype._writev=function(o,c){if(this.logv){var u=o.filter(this._accept,this);return u.length?this.logv(u,c):c(null)}for(var f=0;f<o.length;f++)if(this._accept(o[f]))if(!o[f].chunk||this.format){var E=void 0,_=void 0;try{_=this.format.transform(Object.assign({},o[f].chunk),this.format.options)}catch(h){E=h}if(E||!_){if(o[f].callback(),E)throw c(null),E}else this.log(_,o[f].callback)}else this.log(o[f].chunk,o[f].callback);return c(null)},l.prototype._accept=function(o){var c=o.chunk;if(this.silent)return!1;var u=this.level||this.parent&&this.parent.level;return!(c.exception!==!0&&u&&!(this.levels[u]>=this.levels[c[s]])||!this.handleExceptions&&c.exception===!0)},l.prototype._nop=function(){},e.exports.LegacyTransportStream=n(148)},function(e,t,n){var r,i=typeof Reflect=="object"?Reflect:null,s=i&&typeof i.apply=="function"?i.apply:function(A,j,F){return Function.prototype.apply.call(A,j,F)};r=i&&typeof i.ownKeys=="function"?i.ownKeys:Object.getOwnPropertySymbols?function(A){return Object.getOwnPropertyNames(A).concat(Object.getOwnPropertySymbols(A))}:function(A){return Object.getOwnPropertyNames(A)};var l=Number.isNaN||function(A){return A!=A};function o(){o.init.call(this)}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var c=10;function u(A){return A._maxListeners===void 0?o.defaultMaxListeners:A._maxListeners}function f(A,j,F,M){var R,d,I,$;if(typeof F!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof F);if((d=A._events)===void 0?(d=A._events=Object.create(null),A._eventsCount=0):(d.newListener!==void 0&&(A.emit("newListener",j,F.listener?F.listener:F),d=A._events),I=d[j]),I===void 0)I=d[j]=F,++A._eventsCount;else if(typeof I=="function"?I=d[j]=M?[F,I]:[I,F]:M?I.unshift(F):I.push(F),(R=u(A))>0&&I.length>R&&!I.warned){I.warned=!0;var q=new Error("Possible EventEmitter memory leak detected. "+I.length+" "+String(j)+" listeners added. Use emitter.setMaxListeners() to increase limit");q.name="MaxListenersExceededWarning",q.emitter=A,q.type=j,q.count=I.length,$=q,console&&console.warn&&console.warn($)}return A}function E(){for(var A=[],j=0;j<arguments.length;j++)A.push(arguments[j]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,s(this.listener,this.target,A))}function _(A,j,F){var M={fired:!1,wrapFn:void 0,target:A,type:j,listener:F},R=E.bind(M);return R.listener=F,M.wrapFn=R,R}function h(A,j,F){var M=A._events;if(M===void 0)return[];var R=M[j];return R===void 0?[]:typeof R=="function"?F?[R.listener||R]:[R]:F?function(d){for(var I=new Array(d.length),$=0;$<I.length;++$)I[$]=d[$].listener||d[$];return I}(R):b(R,R.length)}function g(A){var j=this._events;if(j!==void 0){var F=j[A];if(typeof F=="function")return 1;if(F!==void 0)return F.length}return 0}function b(A,j){for(var F=new Array(j),M=0;M<j;++M)F[M]=A[M];return F}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(A){if(typeof A!="number"||A<0||l(A))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+A+".");c=A}}),o.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(A){if(typeof A!="number"||A<0||l(A))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+A+".");return this._maxListeners=A,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(A){for(var j=[],F=1;F<arguments.length;F++)j.push(arguments[F]);var M=A==="error",R=this._events;if(R!==void 0)M=M&&R.error===void 0;else if(!M)return!1;if(M){var d;if(j.length>0&&(d=j[0]),d instanceof Error)throw d;var I=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw I.context=d,I}var $=R[A];if($===void 0)return!1;if(typeof $=="function")s($,this,j);else{var q=$.length,y=b($,q);for(F=0;F<q;++F)s(y[F],this,j)}return!0},o.prototype.addListener=function(A,j){return f(this,A,j,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(A,j){return f(this,A,j,!0)},o.prototype.once=function(A,j){if(typeof j!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof j);return this.on(A,_(this,A,j)),this},o.prototype.prependOnceListener=function(A,j){if(typeof j!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof j);return this.prependListener(A,_(this,A,j)),this},o.prototype.removeListener=function(A,j){var F,M,R,d,I;if(typeof j!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof j);if((M=this._events)===void 0)return this;if((F=M[A])===void 0)return this;if(F===j||F.listener===j)--this._eventsCount==0?this._events=Object.create(null):(delete M[A],M.removeListener&&this.emit("removeListener",A,F.listener||j));else if(typeof F!="function"){for(R=-1,d=F.length-1;d>=0;d--)if(F[d]===j||F[d].listener===j){I=F[d].listener,R=d;break}if(R<0)return this;R===0?F.shift():function($,q){for(;q+1<$.length;q++)$[q]=$[q+1];$.pop()}(F,R),F.length===1&&(M[A]=F[0]),M.removeListener!==void 0&&this.emit("removeListener",A,I||j)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(A){var j,F,M;if((F=this._events)===void 0)return this;if(F.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):F[A]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete F[A]),this;if(arguments.length===0){var R,d=Object.keys(F);for(M=0;M<d.length;++M)(R=d[M])!=="removeListener"&&this.removeAllListeners(R);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(j=F[A])=="function")this.removeListener(A,j);else if(j!==void 0)for(M=j.length-1;M>=0;M--)this.removeListener(A,j[M]);return this},o.prototype.listeners=function(A){return h(this,A,!0)},o.prototype.rawListeners=function(A){return h(this,A,!1)},o.listenerCount=function(A,j){return typeof A.listenerCount=="function"?A.listenerCount(j):g.call(A,j)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){var r=n(147).Buffer,i=r.isEncoding||function(g){switch((g=""+g)&&g.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(g){var b;switch(this.encoding=function(A){var j=function(F){if(!F)return"utf8";for(var M;;)switch(F){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return F;default:if(M)return;F=(""+F).toLowerCase(),M=!0}}(A);if(typeof j!="string"&&(r.isEncoding===i||!i(A)))throw new Error("Unknown encoding: "+A);return j||A}(g),this.encoding){case"utf16le":this.text=c,this.end=u,b=4;break;case"utf8":this.fillLast=o,b=4;break;case"base64":this.text=f,this.end=E,b=3;break;default:return this.write=_,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(b)}function l(g){return g<=127?0:g>>5==6?2:g>>4==14?3:g>>3==30?4:g>>6==2?-1:-2}function o(g){var b=this.lastTotal-this.lastNeed,A=function(j,F,M){if((192&F[0])!=128)return j.lastNeed=0,"�";if(j.lastNeed>1&&F.length>1){if((192&F[1])!=128)return j.lastNeed=1,"�";if(j.lastNeed>2&&F.length>2&&(192&F[2])!=128)return j.lastNeed=2,"�"}}(this,g);return A!==void 0?A:this.lastNeed<=g.length?(g.copy(this.lastChar,b,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(g.copy(this.lastChar,b,0,g.length),void(this.lastNeed-=g.length))}function c(g,b){if((g.length-b)%2==0){var A=g.toString("utf16le",b);if(A){var j=A.charCodeAt(A.length-1);if(j>=55296&&j<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=g[g.length-2],this.lastChar[1]=g[g.length-1],A.slice(0,-1)}return A}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=g[g.length-1],g.toString("utf16le",b,g.length-1)}function u(g){var b=g&&g.length?this.write(g):"";if(this.lastNeed){var A=this.lastTotal-this.lastNeed;return b+this.lastChar.toString("utf16le",0,A)}return b}function f(g,b){var A=(g.length-b)%3;return A===0?g.toString("base64",b):(this.lastNeed=3-A,this.lastTotal=3,A===1?this.lastChar[0]=g[g.length-1]:(this.lastChar[0]=g[g.length-2],this.lastChar[1]=g[g.length-1]),g.toString("base64",b,g.length-A))}function E(g){var b=g&&g.length?this.write(g):"";return this.lastNeed?b+this.lastChar.toString("base64",0,3-this.lastNeed):b}function _(g){return g.toString(this.encoding)}function h(g){return g&&g.length?this.write(g):""}t.StringDecoder=s,s.prototype.write=function(g){if(g.length===0)return"";var b,A;if(this.lastNeed){if((b=this.fillLast(g))===void 0)return"";A=this.lastNeed,this.lastNeed=0}else A=0;return A<g.length?b?b+this.text(g,A):this.text(g,A):b||""},s.prototype.end=function(g){var b=g&&g.length?this.write(g):"";return this.lastNeed?b+"�":b},s.prototype.text=function(g,b){var A=function(F,M,R){var d=M.length-1;if(d<R)return 0;var I=l(M[d]);return I>=0?(I>0&&(F.lastNeed=I-1),I):--d<R||I===-2?0:(I=l(M[d]))>=0?(I>0&&(F.lastNeed=I-2),I):--d<R||I===-2?0:(I=l(M[d]))>=0?(I>0&&(I===2?I=0:F.lastNeed=I-3),I):0}(this,g,b);if(!this.lastNeed)return g.toString("utf8",b);this.lastTotal=A;var j=g.length-(A-this.lastNeed);return g.copy(this.lastChar,0,j),g.toString("utf8",b,j)},s.prototype.fillLast=function(g){if(this.lastNeed<=g.length)return g.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);g.copy(this.lastChar,this.lastTotal-this.lastNeed,0,g.length),this.lastNeed-=g.length}},function(e,t,n){var r=n(16),i=Object.keys||function(g){var b=[];for(var A in g)b.push(A);return b};e.exports=E;var s=n(17);s.inherits=n(7);var l=n(69),o=n(48);s.inherits(E,l);for(var c=i(o.prototype),u=0;u<c.length;u++){var f=c[u];E.prototype[f]||(E.prototype[f]=o.prototype[f])}function E(g){if(!(this instanceof E))return new E(g);l.call(this,g),o.call(this,g),g&&g.readable===!1&&(this.readable=!1),g&&g.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,g&&g.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",_)}function _(){this.allowHalfOpen||this._writableState.ended||r.nextTick(h,this)}function h(g){g.end()}Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(E.prototype,"destroyed",{get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(g){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=g,this._writableState.destroyed=g)}}),E.prototype._destroy=function(g,b){this.push(null),this.end(),r.nextTick(b,g)}},function(e,t,n){(function(r){function i(x){var Z=0;return function(){return Z<x.length?{done:!1,value:x[Z++]}:{done:!0}}}var s=typeof Object.defineProperties=="function"?Object.defineProperty:function(x,Z,te){x!=Array.prototype&&x!=Object.prototype&&(x[Z]=te.value)},l=function(x){x=[typeof window=="object"&&window,typeof self=="object"&&self,typeof r=="object"&&r,x];for(var Z=0;Z<x.length;++Z){var te=x[Z];if(te&&te.Math==Math)return te}throw Error("Cannot find global object")}(this);function o(x,Z){if(Z){var te=l;x=x.split(".");for(var ae=0;ae<x.length-1;ae++){var ge=x[ae];ge in te||(te[ge]={}),te=te[ge]}(Z=Z(ae=te[x=x[x.length-1]]))!=ae&&Z!=null&&s(te,x,{configurable:!0,writable:!0,value:Z})}}function c(x){var Z=typeof Symbol<"u"&&Symbol.iterator&&x[Symbol.iterator];return Z?Z.call(x):{next:i(x)}}o("Object.is",function(x){return x||function(Z,te){return Z===te?Z!==0||1/Z==1/te:Z!=Z&&te!=te}}),o("Array.prototype.includes",function(x){return x||function(Z,te){var ae=this;ae instanceof String&&(ae=String(ae));var ge=ae.length;for(0>(te=te||0)&&(te=Math.max(te+ge,0));te<ge;te++){var me=ae[te];if(me===Z||Object.is(me,Z))return!0}return!1}}),o("Promise",function(x){function Z(ue){this.b=0,this.c=void 0,this.a=[];var he=this.f();try{ue(he.resolve,he.reject)}catch(we){he.reject(we)}}function te(){this.a=null}function ae(ue){return ue instanceof Z?ue:new Z(function(he){he(ue)})}if(x)return x;te.prototype.b=function(ue){if(this.a==null){this.a=[];var he=this;this.c(function(){he.g()})}this.a.push(ue)};var ge=l.setTimeout;te.prototype.c=function(ue){ge(ue,0)},te.prototype.g=function(){for(;this.a&&this.a.length;){var ue=this.a;this.a=[];for(var he=0;he<ue.length;++he){var we=ue[he];ue[he]=null;try{we()}catch(_e){this.f(_e)}}}this.a=null},te.prototype.f=function(ue){this.c(function(){throw ue})},Z.prototype.f=function(){function ue(_e){return function(Ee){we||(we=!0,_e.call(he,Ee))}}var he=this,we=!1;return{resolve:ue(this.m),reject:ue(this.g)}},Z.prototype.m=function(ue){if(ue===this)this.g(new TypeError("A Promise cannot resolve to itself"));else if(ue instanceof Z)this.o(ue);else{e:switch(typeof ue){case"object":var he=ue!=null;break e;case"function":he=!0;break e;default:he=!1}he?this.l(ue):this.h(ue)}},Z.prototype.l=function(ue){var he=void 0;try{he=ue.then}catch(we){return void this.g(we)}typeof he=="function"?this.u(he,ue):this.h(ue)},Z.prototype.g=function(ue){this.i(2,ue)},Z.prototype.h=function(ue){this.i(1,ue)},Z.prototype.i=function(ue,he){if(this.b!=0)throw Error("Cannot settle("+ue+", "+he+"): Promise already settled in state"+this.b);this.b=ue,this.c=he,this.j()},Z.prototype.j=function(){if(this.a!=null){for(var ue=0;ue<this.a.length;++ue)me.b(this.a[ue]);this.a=null}};var me=new te;return Z.prototype.o=function(ue){var he=this.f();ue.w(he.resolve,he.reject)},Z.prototype.u=function(ue,he){var we=this.f();try{ue.call(he,we.resolve,we.reject)}catch(_e){we.reject(_e)}},Z.prototype.then=function(ue,he){function we(Le,We){return typeof Le=="function"?function(ze){try{_e(Le(ze))}catch(He){Ee(He)}}:We}var _e,Ee,De=new Z(function(Le,We){_e=Le,Ee=We});return this.w(we(ue,_e),we(he,Ee)),De},Z.prototype.catch=function(ue){return this.then(void 0,ue)},Z.prototype.w=function(ue,he){function we(){switch(_e.b){case 1:ue(_e.c);break;case 2:he(_e.c);break;default:throw Error("Unexpected state: "+_e.b)}}var _e=this;this.a==null?me.b(we):this.a.push(we)},Z.resolve=ae,Z.reject=function(ue){return new Z(function(he,we){we(ue)})},Z.race=function(ue){return new Z(function(he,we){for(var _e=c(ue),Ee=_e.next();!Ee.done;Ee=_e.next())ae(Ee.value).w(he,we)})},Z.all=function(ue){var he=c(ue),we=he.next();return we.done?ae([]):new Z(function(_e,Ee){function De(ze){return function(He){Le[ze]=He,--We==0&&_e(Le)}}var Le=[],We=0;do Le.push(void 0),We++,ae(we.value).w(De(Le.length-1),Ee),we=he.next();while(!we.done)})},Z});var u=u||{},f=this||self;function E(x,Z){x=x.split("."),Z=Z||f;for(var te=0;te<x.length;te++)if((Z=Z[x[te]])==null)return null;return Z}function _(){}function h(x){var Z=typeof x;if(Z=="object"){if(!x)return"null";if(x instanceof Array)return"array";if(x instanceof Object)return Z;var te=Object.prototype.toString.call(x);if(te=="[object Window]")return"object";if(te=="[object Array]"||typeof x.length=="number"&&x.splice!==void 0&&x.propertyIsEnumerable!==void 0&&!x.propertyIsEnumerable("splice"))return"array";if(te=="[object Function]"||x.call!==void 0&&x.propertyIsEnumerable!==void 0&&!x.propertyIsEnumerable("call"))return"function"}else if(Z=="function"&&x.call===void 0)return"object";return Z}function g(x){var Z=typeof x;return Z=="object"&&x!=null||Z=="function"}function b(x,Z,te){return x.call.apply(x.bind,arguments)}function A(x,Z,te){if(!x)throw Error();if(2<arguments.length){var ae=Array.prototype.slice.call(arguments,2);return function(){var ge=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(ge,ae),x.apply(Z,ge)}}return function(){return x.apply(Z,arguments)}}function j(x,Z,te){return(j=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?b:A).apply(null,arguments)}function F(x,Z){function te(){}te.prototype=Z.prototype,x.S=Z.prototype,x.prototype=new te,x.prototype.constructor=x}function M(){this.a={}}function R(x,Z,te,ae){this.f=x,this.c=Z,this.b=te,this.a=ae}function d(x,Z,te,ae){te=te===void 0?{}:te,this.c=x,this.a=te,this.b=Z,this.f=ae===void 0?null:ae}function I(x,Z,te,ae,ge,me){this.name=x,this.a=ge,this.b=me}function $(x,Z,te){te=te===void 0?{}:te;var ae=ae===void 0?new M:ae;return new R(Z,x,te,ae)}function q(x,Z,te,ae){return ae instanceof I?ae:new I(x,te,ae.b||Z.constructor,ae.f,ae.a,ae.c)}function y(x){this.a=x}function m(x){switch(x){case 0:return"No Error";case 1:return"Access denied to content document";case 2:return"File not found";case 3:return"Firefox silently errored";case 4:return"Application custom error";case 5:return"An exception occurred";case 6:return"Http response at 400 or 500 level";case 7:return"Request was aborted";case 8:return"Request timed out";case 9:return"The resource is not available offline";default:return"Unrecognized error code"}}function C(x){if(Error.captureStackTrace)Error.captureStackTrace(this,C);else{var Z=Error().stack;Z&&(this.stack=Z)}x&&(this.message=String(x))}function w(x,Z){for(var te="",ae=(x=x.split("%s")).length-1,ge=0;ge<ae;ge++)te+=x[ge]+(ge<Z.length?Z[ge]:"%s");C.call(this,te+x[ae])}function L(){this.j=null,this.i=[],this.l=0,this.b=W,this.f=this.a=this.h=0,this.c=null,this.g=0}M.prototype.get=function(x){return this.a[x]},M.prototype.f=function(){return Object.keys(this.a)},R.prototype.getRequestMessage=function(){return this.f},R.prototype.getMethodDescriptor=function(){return this.c},R.prototype.getMetadata=function(){return this.b},R.prototype.getCallOptions=function(){return this.a},d.prototype.getResponseMessage=function(){return this.c},d.prototype.getMetadata=function(){return this.a},d.prototype.getMethodDescriptor=function(){return this.b},d.prototype.getStatus=function(){return this.f},y.prototype.on=function(x,Z){return x=="data"||x=="error"?this:this.a.on(x,Z)},y.prototype.removeListener=function(x,Z){return this.a.removeListener(x,Z)},y.prototype.cancel=function(){this.a.cancel()},F(C,Error),C.prototype.name="CustomError",F(w,C),w.prototype.name="AssertionError";var W=0,k=1,N=2,P=3,z=0,O=128;function p(x,Z,te,ae){throw x.b=P,x.j="The stream is broken @"+x.l+"/"+te+". Error: "+ae+`. With input:
|
|
21
|
-
`+Z,Error(x.j)}var U=Array.prototype.indexOf?function(x,Z){return Array.prototype.indexOf.call(x,Z,void 0)}:function(x,Z){if(typeof x=="string")return typeof Z!="string"||Z.length!=1?-1:x.indexOf(Z,0);for(var te=0;te<x.length;te++)if(te in x&&x[te]===Z)return te;return-1},V,Q=String.prototype.trim?function(x){return x.trim()}:function(x){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(x)[1]};function ee(x,Z){return x.indexOf(Z)!=-1}function ne(x,Z){return x<Z?-1:x>Z?1:0}e:{var Y=f.navigator;if(Y){var G=Y.userAgent;if(G){V=G;break e}}V=""}var S="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function T(x){var Z=1;x=x.split(":");for(var te=[];0<Z&&x.length;)te.push(x.shift()),Z--;return x.length&&te.push(x.join(":")),te}function B(x){return B[" "](x),x}B[" "]=_;var J,K,re=ee(V,"Opera"),se=ee(V,"Trident")||ee(V,"MSIE"),fe=ee(V,"Edge"),ve=ee(V,"Gecko")&&!(ee(V.toLowerCase(),"webkit")&&!ee(V,"Edge"))&&!(ee(V,"Trident")||ee(V,"MSIE"))&&!ee(V,"Edge"),Ie=ee(V.toLowerCase(),"webkit")&&!ee(V,"Edge");function Se(){var x=f.document;return x?x.documentMode:void 0}e:{var Ce="",Ae=(K=V,ve?/rv:([^\);]+)(\)|;)/.exec(K):fe?/Edge\/([\d\.]+)/.exec(K):se?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(K):Ie?/WebKit\/(\S+)/.exec(K):re?/(?:Version)[ \/]?(\S+)/.exec(K):void 0);if(Ae&&(Ce=Ae?Ae[1]:""),se){var Oe=Se();if(Oe!=null&&Oe>parseFloat(Ce)){J=String(Oe);break e}}J=Ce}var Pe,qe={};function rt(x){return function(Z,te){var ae=qe;return Object.prototype.hasOwnProperty.call(ae,Z)?ae[Z]:ae[Z]=te(Z)}(x,function(){for(var Z=0,te=Q(String(J)).split("."),ae=Q(String(x)).split("."),ge=Math.max(te.length,ae.length),me=0;Z==0&&me<ge;me++){var ue=te[me]||"",he=ae[me]||"";do{if(ue=/(\d*)(\D*)(.*)/.exec(ue)||["","","",""],he=/(\d*)(\D*)(.*)/.exec(he)||["","","",""],ue[0].length==0&&he[0].length==0)break;Z=ne(ue[1].length==0?0:parseInt(ue[1],10),he[1].length==0?0:parseInt(he[1],10))||ne(ue[2].length==0,he[2].length==0)||ne(ue[2],he[2]),ue=ue[3],he=he[3]}while(Z==0)}return 0<=Z})}if(f.document&&se){var tt=Se();Pe=tt||parseInt(J,10)||void 0}else Pe=void 0;var _t=Pe;function ut(){this.F=this.F}ut.prototype.F=!1;var vt,It=Object.freeze||function(x){return x};(vt=!se)||(vt=9<=Number(_t));var Tt=vt,Be=se&&!rt("9"),jt=function(){if(!f.addEventListener||!Object.defineProperty)return!1;var x=!1,Z=Object.defineProperty({},"passive",{get:function(){x=!0}});try{f.addEventListener("test",_,Z),f.removeEventListener("test",_,Z)}catch{}return x}();function it(x,Z){this.type=x,this.a=this.target=Z,this.defaultPrevented=!1}function at(x,Z){if(it.call(this,x?x.type:""),this.relatedTarget=this.a=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.c=null,x){var te=this.type=x.type,ae=x.changedTouches&&x.changedTouches.length?x.changedTouches[0]:null;if(this.target=x.target||x.srcElement,this.a=Z,Z=x.relatedTarget){if(ve){e:{try{B(Z.nodeName);var ge=!0;break e}catch{}ge=!1}ge||(Z=null)}}else te=="mouseover"?Z=x.fromElement:te=="mouseout"&&(Z=x.toElement);this.relatedTarget=Z,ae?(this.clientX=ae.clientX!==void 0?ae.clientX:ae.pageX,this.clientY=ae.clientY!==void 0?ae.clientY:ae.pageY,this.screenX=ae.screenX||0,this.screenY=ae.screenY||0):(this.clientX=x.clientX!==void 0?x.clientX:x.pageX,this.clientY=x.clientY!==void 0?x.clientY:x.pageY,this.screenX=x.screenX||0,this.screenY=x.screenY||0),this.button=x.button,this.key=x.key||"",this.ctrlKey=x.ctrlKey,this.altKey=x.altKey,this.shiftKey=x.shiftKey,this.metaKey=x.metaKey,this.pointerId=x.pointerId||0,this.pointerType=typeof x.pointerType=="string"?x.pointerType:xt[x.pointerType]||"",this.c=x,x.defaultPrevented&&this.b()}}it.prototype.b=function(){this.defaultPrevented=!0},F(at,it);var xt=It({2:"touch",3:"pen",4:"mouse"});at.prototype.b=function(){at.S.b.call(this);var x=this.c;if(x.preventDefault)x.preventDefault();else if(x.returnValue=!1,Be)try{(x.ctrlKey||112<=x.keyCode&&123>=x.keyCode)&&(x.keyCode=-1)}catch{}};var mt="closure_listenable_"+(1e6*Math.random()|0),Mt=0;function ct(x,Z,te,ae,ge){this.listener=x,this.proxy=null,this.src=Z,this.type=te,this.capture=!!ae,this.A=ge,this.key=++Mt,this.s=this.v=!1}function At(x){x.s=!0,x.listener=null,x.proxy=null,x.src=null,x.A=null}function Ue(x){this.src=x,this.a={},this.b=0}function Rt(x,Z){var te=Z.type;if(te in x.a){var ae,ge=x.a[te],me=U(ge,Z);(ae=0<=me)&&Array.prototype.splice.call(ge,me,1),ae&&(At(Z),x.a[te].length==0&&(delete x.a[te],x.b--))}}function pe(x,Z,te,ae){for(var ge=0;ge<x.length;++ge){var me=x[ge];if(!me.s&&me.listener==Z&&me.capture==!!te&&me.A==ae)return ge}return-1}Ue.prototype.add=function(x,Z,te,ae,ge){var me=x.toString();(x=this.a[me])||(x=this.a[me]=[],this.b++);var ue=pe(x,Z,ae,ge);return-1<ue?(Z=x[ue],te||(Z.v=!1)):((Z=new ct(Z,this.src,me,!!ae,ge)).v=te,x.push(Z)),Z};var D="closure_lm_"+(1e6*Math.random()|0),H={};function X(x,Z,te,ae,ge){if(ae&&ae.once)(function ue(he,we,_e,Ee,De){if(Array.isArray(we))for(var Le=0;Le<we.length;Le++)ue(he,we[Le],_e,Ee,De);else _e=Me(_e),he&&he[mt]?he.f.add(String(we),_e,!0,g(Ee)?!!Ee.capture:!!Ee,De):ie(he,we,_e,!0,Ee,De)})(x,Z,te,ae,ge);else if(Array.isArray(Z))for(var me=0;me<Z.length;me++)X(x,Z[me],te,ae,ge);else te=Me(te),x&&x[mt]?x.f.add(String(Z),te,!1,g(ae)?!!ae.capture:!!ae,ge):ie(x,Z,te,!1,ae,ge)}function ie(x,Z,te,ae,ge,me){if(!Z)throw Error("Invalid event type");var ue=g(ge)?!!ge.capture:!!ge,he=le(x);if(he||(x[D]=he=new Ue(x)),!(te=he.add(Z,te,ae,ue,me)).proxy)if(ae=function(){var we=ce,_e=Tt?function(Ee){return we.call(_e.src,_e.listener,Ee)}:function(Ee){if(!(Ee=we.call(_e.src,_e.listener,Ee)))return Ee};return _e}(),te.proxy=ae,ae.src=x,ae.listener=te,x.addEventListener)jt||(ge=ue),ge===void 0&&(ge=!1),x.addEventListener(Z.toString(),ae,ge);else if(x.attachEvent)x.attachEvent(de(Z.toString()),ae);else{if(!x.addListener||!x.removeListener)throw Error("addEventListener and attachEvent are unavailable.");x.addListener(ae)}}function oe(x){if(typeof x!="number"&&x&&!x.s){var Z=x.src;if(Z&&Z[mt])Rt(Z.f,x);else{var te=x.type,ae=x.proxy;Z.removeEventListener?Z.removeEventListener(te,ae,x.capture):Z.detachEvent?Z.detachEvent(de(te),ae):Z.addListener&&Z.removeListener&&Z.removeListener(ae),(te=le(Z))?(Rt(te,x),te.b==0&&(te.src=null,Z[D]=null)):At(x)}}}function de(x){return x in H?H[x]:H[x]="on"+x}function ye(x,Z,te,ae){var ge=!0;if((x=le(x))&&(Z=x.a[Z.toString()]))for(Z=Z.concat(),x=0;x<Z.length;x++){var me=Z[x];me&&me.capture==te&&!me.s&&(me=be(me,ae),ge=ge&&me!==!1)}return ge}function be(x,Z){var te=x.listener,ae=x.A||x.src;return x.v&&oe(x),te.call(ae,Z)}function ce(x,Z){if(x.s)return!0;if(!Tt){var te=Z||E("window.event");Z=new at(te,this);var ae=!0;if(!(0>te.keyCode||te.returnValue!=null)){e:{var ge=!1;if(te.keyCode==0)try{te.keyCode=-1;break e}catch{ge=!0}(ge||te.returnValue==null)&&(te.returnValue=!0)}for(te=[],ge=Z.a;ge;ge=ge.parentNode)te.push(ge);for(x=x.type,ge=te.length-1;0<=ge;ge--){Z.a=te[ge];var me=ye(te[ge],x,!0,Z);ae=ae&&me}for(ge=0;ge<te.length;ge++)Z.a=te[ge],me=ye(te[ge],x,!1,Z),ae=ae&&me}return ae}return be(x,new at(Z,this))}function le(x){return(x=x[D])instanceof Ue?x:null}var Re="__closure_events_fn_"+(1e9*Math.random()>>>0);function Me(x){return h(x)=="function"?x:(x[Re]||(x[Re]=function(Z){return x.handleEvent(Z)}),x[Re])}function je(){ut.call(this),this.f=new Ue(this),this.N=this}function Fe(x,Z){x=x.N;var te=Z.type||Z;if(typeof Z=="string")Z=new it(Z,x);else if(Z instanceof it)Z.target=Z.target||x;else{var ae=Z;(function(ge,me){for(var ue,he,we=1;we<arguments.length;we++){for(ue in he=arguments[we])ge[ue]=he[ue];for(var _e=0;_e<S.length;_e++)ue=S[_e],Object.prototype.hasOwnProperty.call(he,ue)&&(ge[ue]=he[ue])}})(Z=new it(te,x),ae)}Xe(x=Z.a=x,te,!0,Z),Xe(x,te,!1,Z)}function Xe(x,Z,te,ae){if(Z=x.f.a[String(Z)]){Z=Z.concat();for(var ge=!0,me=0;me<Z.length;++me){var ue=Z[me];if(ue&&!ue.s&&ue.capture==te){var he=ue.listener,we=ue.A||ue.src;ue.v&&Rt(x.f,ue),ge=he.call(we,ae)!==!1&&ge}}}}function $e(x,Z,te){if(h(x)=="function")te&&(x=j(x,te));else{if(!x||typeof x.handleEvent!="function")throw Error("Invalid listener argument");x=j(x.handleEvent,x)}return 2147483647<Number(Z)?-1:f.setTimeout(x,Z||0)}function Ye(x,Z,te){this.reset(x,Z,te,void 0,void 0)}F(je,ut),je.prototype[mt]=!0,je.prototype.addEventListener=function(x,Z,te,ae){X(this,x,Z,te,ae)},je.prototype.removeEventListener=function(x,Z,te,ae){(function ge(me,ue,he,we,_e){if(Array.isArray(ue))for(var Ee=0;Ee<ue.length;Ee++)ge(me,ue[Ee],he,we,_e);else we=g(we)?!!we.capture:!!we,he=Me(he),me&&me[mt]?(me=me.f,(ue=String(ue).toString())in me.a&&-1<(he=pe(Ee=me.a[ue],he,we,_e))&&(At(Ee[he]),Array.prototype.splice.call(Ee,he,1),Ee.length==0&&(delete me.a[ue],me.b--))):me&&(me=le(me))&&(ue=me.a[ue.toString()],me=-1,ue&&(me=pe(ue,he,we,_e)),(he=-1<me?ue[me]:null)&&oe(he))})(this,x,Z,te,ae)},Ye.prototype.a=null;function xe(x){this.f=x,this.b=this.c=this.a=null}function ke(x,Z){this.name=x,this.value=Z}Ye.prototype.reset=function(x,Z,te,ae,ge){delete this.a},ke.prototype.toString=function(){return this.name};var Ve=new ke("SEVERE",1e3),Ze=new ke("CONFIG",700),Je=new ke("FINE",500);function Qe(x){return x.c?x.c:x.a?Qe(x.a):(function(Z,te){throw new w("Failure"+(Z?": "+Z:""),Array.prototype.slice.call(arguments,1))}("Root logger has no level set."),null)}xe.prototype.log=function(x,Z,te){if(x.value>=Qe(this).value)for(h(Z)=="function"&&(Z=Z()),x=new Ye(x,String(Z),this.f),te&&(x.a=te),te=this;te;)te=te.a};var lt,st={},gt=null;function et(x,Z){x&&x.log(Je,Z,void 0)}function Nt(){}function Bt(x){var Z;return(Z=x.a)||(Z={},zt(x)&&(Z[0]=!0,Z[1]=!0),Z=x.a=Z),Z}function Ut(){}function Ft(x){return(x=zt(x))?new ActiveXObject(x):new XMLHttpRequest}function zt(x){if(!x.b&&typeof XMLHttpRequest>"u"&&typeof ActiveXObject<"u"){for(var Z=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],te=0;te<Z.length;te++){var ae=Z[te];try{return new ActiveXObject(ae),x.b=ae}catch{}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return x.b}function yt(x,Z){this.b={},this.a=[],this.c=0;var te=arguments.length;if(1<te){if(te%2)throw Error("Uneven number of arguments");for(var ae=0;ae<te;ae+=2)this.set(arguments[ae],arguments[ae+1])}else x&&Wt(this,x)}function Lt(x){if(x.c!=x.a.length){for(var Z=0,te=0;Z<x.a.length;){var ae=x.a[Z];wt(x.b,ae)&&(x.a[te++]=ae),Z++}x.a.length=te}if(x.c!=x.a.length){var ge={};for(te=Z=0;Z<x.a.length;)wt(ge,ae=x.a[Z])||(x.a[te++]=ae,ge[ae]=1),Z++;x.a.length=te}}function Wt(x,Z){if(Z instanceof yt)for(var te=Z.f(),ae=0;ae<te.length;ae++)x.set(te[ae],Z.get(te[ae]));else for(te in Z)x.set(te,Z[te])}function wt(x,Z){return Object.prototype.hasOwnProperty.call(x,Z)}Nt.prototype.a=null,F(Ut,Nt),lt=new Ut,yt.prototype.f=function(){return Lt(this),this.a.concat()},yt.prototype.get=function(x,Z){return wt(this.b,x)?this.b[x]:Z},yt.prototype.set=function(x,Z){wt(this.b,x)||(this.c++,this.a.push(x)),this.b[x]=Z},yt.prototype.forEach=function(x,Z){for(var te=this.f(),ae=0;ae<te.length;ae++){var ge=te[ae],me=this.get(ge);x.call(Z,me,ge,this)}};var Jt=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function pt(x){je.call(this),this.headers=new yt,this.D=x||null,this.c=!1,this.C=this.a=null,this.J=this.o="",this.g=0,this.i="",this.h=this.I=this.m=this.G=!1,this.l=0,this.u=null,this.j=Ht,this.B=this.H=!1}F(pt,je);var Ht="",Qt=pt.prototype,en=function x(Z){var te;if(gt||(gt=new xe(""),st[""]=gt,gt.c=Ze),!(te=st[Z])){te=new xe(Z);var ae=Z.lastIndexOf("."),ge=Z.substr(ae+1);(ae=x(Z.substr(0,ae))).b||(ae.b={}),ae.b[ge]=te,te.a=ae,st[Z]=te}return te}("goog.net.XhrIo");Qt.b=en;var tn=/^https?$/i,nn=["POST","PUT"];function rn(x,Z,te){if(x.a)throw Error("[goog.net.XhrIo] Object is active with another request="+x.o+"; newUri="+Z);x.o=Z,x.i="",x.g=0,x.J="POST",x.G=!1,x.c=!0,x.a=x.D?Ft(x.D):Ft(lt),x.C=x.D?Bt(x.D):Bt(lt),x.a.onreadystatechange=j(x.K,x);try{et(x.b,dt(x,"Opening Xhr")),x.I=!0,x.a.open("POST",String(Z),!0),x.I=!1}catch(me){return et(x.b,dt(x,"Error opening Xhr: "+me.message)),void Vt(x,me)}Z=te||"";var ae=function(me){e:{for(var ue=an,he=me.length,we=typeof me=="string"?me.split(""):me,_e=0;_e<he;_e++)if(_e in we&&ue.call(void 0,we[_e],_e,me)){ue=_e;break e}ue=-1}return 0>ue?null:typeof me=="string"?me.charAt(ue):me[ue]}((te=new yt(x.headers)).f()),ge=f.FormData&&Z instanceof f.FormData;!(0<=U(nn,"POST"))||ae||ge||te.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),te.forEach(function(me,ue){this.a.setRequestHeader(ue,me)},x),x.j&&(x.a.responseType=x.j),"withCredentials"in x.a&&x.a.withCredentials!==x.H&&(x.a.withCredentials=x.H);try{Zt(x),0<x.l&&(x.B=function(me){return se&&rt(9)&&typeof me.timeout=="number"&&me.ontimeout!==void 0}(x.a),et(x.b,dt(x,"Will abort after "+x.l+"ms if incomplete, xhr2 "+x.B)),x.B?(x.a.timeout=x.l,x.a.ontimeout=j(x.L,x)):x.u=$e(x.L,x.l,x)),et(x.b,dt(x,"Sending request")),x.m=!0,x.a.send(Z),x.m=!1}catch(me){et(x.b,dt(x,"Send error: "+me.message)),Vt(x,me)}}function an(x){return x.toLowerCase()=="content-type"}function Vt(x,Z){x.c=!1,x.a&&(x.h=!0,x.a.abort(),x.h=!1),x.i=Z,x.g=5,Gt(x),Pt(x)}function Gt(x){x.G||(x.G=!0,Fe(x,"complete"),Fe(x,"error"))}function $t(x){if(x.c&&u!==void 0){if(x.C[1]&&bt(x)==4&&x.getStatus()==2)et(x.b,dt(x,"Local request error detected and ignored"));else if(x.m&&bt(x)==4)$e(x.K,0,x);else if(Fe(x,"readystatechange"),bt(x)==4){et(x.b,dt(x,"Request complete")),x.c=!1;try{var Z,te=x.getStatus();e:switch(te){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var ae=!0;break e;default:ae=!1}if(!(Z=ae)){var ge;if(ge=te===0){var me=String(x.o).match(Jt)[1]||null;if(!me&&f.self&&f.self.location){var ue=f.self.location.protocol;me=ue.substr(0,ue.length-1)}ge=!tn.test(me?me.toLowerCase():"")}Z=ge}if(Z)Fe(x,"complete"),Fe(x,"success");else{x.g=6;try{var he=2<bt(x)?x.a.statusText:""}catch(we){et(x.b,"Can not get status: "+we.message),he=""}x.i=he+" ["+x.getStatus()+"]",Gt(x)}}finally{Pt(x)}}}}function Pt(x){if(x.a){Zt(x);var Z=x.a,te=x.C[0]?_:null;x.a=null,x.C=null,Fe(x,"ready");try{Z.onreadystatechange=te}catch(ae){(x=x.b)&&x.log(Ve,"Problem encountered resetting onreadystatechange: "+ae.message,void 0)}}}function Zt(x){x.a&&x.B&&(x.a.ontimeout=null),x.u&&(f.clearTimeout(x.u),x.u=null)}function bt(x){return x.a?x.a.readyState:0}function qt(x,Z){if(x.a&&bt(x)==4)return(x=x.a.getResponseHeader(Z))===null?void 0:x}function dt(x,Z){return Z+" ["+x.J+" "+x.o+" "+x.getStatus()+"]"}pt.prototype.L=function(){u!==void 0&&this.a&&(this.i="Timed out after "+this.l+"ms, aborting",this.g=8,et(this.b,dt(this,this.i)),Fe(this,"timeout"),this.abort(8))},pt.prototype.abort=function(x){this.a&&this.c&&(et(this.b,dt(this,"Aborting")),this.c=!1,this.h=!0,this.a.abort(),this.h=!1,this.g=x||7,Fe(this,"complete"),Fe(this,"abort"),Pt(this))},pt.prototype.K=function(){this.F||(this.I||this.m||this.h?$t(this):this.O())},pt.prototype.O=function(){$t(this)},pt.prototype.getStatus=function(){try{return 2<bt(this)?this.a.status:-1}catch{return-1}};var Yt={},Ot=null;function sn(x){var Z=x.length,te=3*Z/4;te%3?te=Math.floor(te):ee("=.",x[Z-1])&&(te=ee("=.",x[Z-2])?te-2:te-1);var ae=new Uint8Array(te),ge=0;return function(me,ue){function he(We){for(;we<me.length;){var ze=me.charAt(we++),He=Ot[ze];if(He!=null)return He;if(!/^[\s\xa0]*$/.test(ze))throw Error("Unknown base64 encoding at char: "+ze)}return We}Kt();for(var we=0;;){var _e=he(-1),Ee=he(0),De=he(64),Le=he(64);if(Le===64&&_e===-1)break;ue(_e<<2|Ee>>4),De!=64&&(ue(Ee<<4&240|De>>2),Le!=64&&ue(De<<6&192|Le))}}(x,function(me){ae[ge++]=me}),ae.subarray(0,ge)}function Kt(){if(!Ot){Ot={};for(var x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),Z=["+/=","+/","-_=","-_.","-_"],te=0;5>te;te++){var ae=x.concat(Z[te].split(""));Yt[te]=ae;for(var ge=0;ge<ae.length;ge++){var me=ae[ge];Ot[me]===void 0&&(Ot[me]=ge)}}}}var ln=["content-type","grpc-status","grpc-message"];function ft(x){this.a=x.T,this.l=null,this.b=[],this.h=[],this.g=[],this.f=[],this.c=[],this.j=!1,this.i=0,this.m=new L;var Z=this;X(this.a,"readystatechange",function(){var te=Z.a;if(te=te.a?te.a.getResponseHeader("Content-Type"):null){if((te=te.toLowerCase()).lastIndexOf("application/grpc-web-text",0)==0){te=Z.a;try{var ae=te.a?te.a.responseText:""}catch(_e){et(te.b,"Can not get responseText: "+_e.message),ae=""}if(ae=(te=ae||"").length-te.length%4,(te=te.substr(Z.i,ae-Z.i)).length==0)return;Z.i=ae,te=sn(te)}else{if(te.lastIndexOf("application/grpc",0)!=0)return void St(Z,{code:2,message:"Unknown Content-type received.",metadata:{}});te=new Uint8Array(function(_e){try{if(!_e.a)return null;if("response"in _e.a)return _e.a.response;switch(_e.j){case Ht:case"text":return _e.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in _e.a)return _e.a.mozResponseArrayBuffer}var Ee=_e.b;return Ee&&Ee.log(Ve,"Response type "+_e.j+" is not supported on this browser",void 0),null}catch(De){return et(_e.b,"Can not get response: "+De.message),null}}(Z.a))}ae=null;try{ae=function(_e,Ee){function De(Et){Ne.f++,Ne.a=(Ne.a<<8)+Et,Ne.f==4&&(Ne.b=N,Ne.g=0,typeof Uint8Array<"u"?Ne.c=new Uint8Array(Ne.a):Ne.c=Array(Ne.a),Ne.a==0&&We())}function Le(Et){Ne.c[Ne.g++]=Et,Ne.g==Ne.a&&We()}function We(){var Et={};Et[Ne.h]=Ne.c,Ne.i.push(Et),Ne.b=W}var ze,He,Ne=_e,ht=0;for(ze=Ee instanceof Uint8Array||Ee instanceof Array?Ee:new Uint8Array(Ee);ht<ze.length;){switch(Ne.b){case P:p(Ne,ze,ht,"stream already broken");break;case W:(He=ze[ht])==z||He==O?Ne.h=He:p(Ne,ze,ht,"invalid frame byte"),Ne.b=k,Ne.a=0,Ne.f=0;break;case k:De(ze[ht]);break;case N:Le(ze[ht]);break;default:throw Error("unexpected parser state: "+Ne.b)}Ne.l++,ht++}return _e=Ne.i,Ne.i=[],0<_e.length?_e:null}(Z.m,te)}catch{St(Z,{code:2,message:"Error in parsing response body",metadata:{}})}if(ae)for(te=0;te<ae.length;te++){if(z in ae[te]){var ge=ae[te][z];if(ge)try{var me=Z.l(ge);if(me){ge=Z;for(var ue=me,he=0;he<ge.b.length;he++)ge.b[he](ue)}}catch{St(Z,{code:2,message:"Error in response deserializer function.",metadata:{}})}}if(O in ae[te]&&0<ae[te][O].length){for(ge="",ue=0;ue<ae[te][O].length;ue++)ge+=String.fromCharCode(ae[te][O][ue]);for(ge=ge.trim().split(`\r
|
|
21
|
+
`+Z,Error(x.j)}var U=Array.prototype.indexOf?function(x,Z){return Array.prototype.indexOf.call(x,Z,void 0)}:function(x,Z){if(typeof x=="string")return typeof Z!="string"||Z.length!=1?-1:x.indexOf(Z,0);for(var te=0;te<x.length;te++)if(te in x&&x[te]===Z)return te;return-1},V,Q=String.prototype.trim?function(x){return x.trim()}:function(x){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(x)[1]};function ee(x,Z){return x.indexOf(Z)!=-1}function ne(x,Z){return x<Z?-1:x>Z?1:0}e:{var Y=f.navigator;if(Y){var G=Y.userAgent;if(G){V=G;break e}}V=""}var S="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function T(x){var Z=1;x=x.split(":");for(var te=[];0<Z&&x.length;)te.push(x.shift()),Z--;return x.length&&te.push(x.join(":")),te}function B(x){return B[" "](x),x}B[" "]=_;var J,K,re=ee(V,"Opera"),se=ee(V,"Trident")||ee(V,"MSIE"),fe=ee(V,"Edge"),ve=ee(V,"Gecko")&&!(ee(V.toLowerCase(),"webkit")&&!ee(V,"Edge"))&&!(ee(V,"Trident")||ee(V,"MSIE"))&&!ee(V,"Edge"),Ie=ee(V.toLowerCase(),"webkit")&&!ee(V,"Edge");function Se(){var x=f.document;return x?x.documentMode:void 0}e:{var Ce="",Ae=(K=V,ve?/rv:([^\);]+)(\)|;)/.exec(K):fe?/Edge\/([\d\.]+)/.exec(K):se?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(K):Ie?/WebKit\/(\S+)/.exec(K):re?/(?:Version)[ \/]?(\S+)/.exec(K):void 0);if(Ae&&(Ce=Ae?Ae[1]:""),se){var Oe=Se();if(Oe!=null&&Oe>parseFloat(Ce)){J=String(Oe);break e}}J=Ce}var Pe,qe={};function tt(x){return function(Z,te){var ae=qe;return Object.prototype.hasOwnProperty.call(ae,Z)?ae[Z]:ae[Z]=te(Z)}(x,function(){for(var Z=0,te=Q(String(J)).split("."),ae=Q(String(x)).split("."),ge=Math.max(te.length,ae.length),me=0;Z==0&&me<ge;me++){var ue=te[me]||"",he=ae[me]||"";do{if(ue=/(\d*)(\D*)(.*)/.exec(ue)||["","","",""],he=/(\d*)(\D*)(.*)/.exec(he)||["","","",""],ue[0].length==0&&he[0].length==0)break;Z=ne(ue[1].length==0?0:parseInt(ue[1],10),he[1].length==0?0:parseInt(he[1],10))||ne(ue[2].length==0,he[2].length==0)||ne(ue[2],he[2]),ue=ue[3],he=he[3]}while(Z==0)}return 0<=Z})}if(f.document&&se){var et=Se();Pe=et||parseInt(J,10)||void 0}else Pe=void 0;var _t=Pe;function ut(){this.F=this.F}ut.prototype.F=!1;var vt,It=Object.freeze||function(x){return x};(vt=!se)||(vt=9<=Number(_t));var Tt=vt,Be=se&&!tt("9"),jt=function(){if(!f.addEventListener||!Object.defineProperty)return!1;var x=!1,Z=Object.defineProperty({},"passive",{get:function(){x=!0}});try{f.addEventListener("test",_,Z),f.removeEventListener("test",_,Z)}catch{}return x}();function nt(x,Z){this.type=x,this.a=this.target=Z,this.defaultPrevented=!1}function ot(x,Z){if(nt.call(this,x?x.type:""),this.relatedTarget=this.a=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.c=null,x){var te=this.type=x.type,ae=x.changedTouches&&x.changedTouches.length?x.changedTouches[0]:null;if(this.target=x.target||x.srcElement,this.a=Z,Z=x.relatedTarget){if(ve){e:{try{B(Z.nodeName);var ge=!0;break e}catch{}ge=!1}ge||(Z=null)}}else te=="mouseover"?Z=x.fromElement:te=="mouseout"&&(Z=x.toElement);this.relatedTarget=Z,ae?(this.clientX=ae.clientX!==void 0?ae.clientX:ae.pageX,this.clientY=ae.clientY!==void 0?ae.clientY:ae.pageY,this.screenX=ae.screenX||0,this.screenY=ae.screenY||0):(this.clientX=x.clientX!==void 0?x.clientX:x.pageX,this.clientY=x.clientY!==void 0?x.clientY:x.pageY,this.screenX=x.screenX||0,this.screenY=x.screenY||0),this.button=x.button,this.key=x.key||"",this.ctrlKey=x.ctrlKey,this.altKey=x.altKey,this.shiftKey=x.shiftKey,this.metaKey=x.metaKey,this.pointerId=x.pointerId||0,this.pointerType=typeof x.pointerType=="string"?x.pointerType:xt[x.pointerType]||"",this.c=x,x.defaultPrevented&&this.b()}}nt.prototype.b=function(){this.defaultPrevented=!0},F(ot,nt);var xt=It({2:"touch",3:"pen",4:"mouse"});ot.prototype.b=function(){ot.S.b.call(this);var x=this.c;if(x.preventDefault)x.preventDefault();else if(x.returnValue=!1,Be)try{(x.ctrlKey||112<=x.keyCode&&123>=x.keyCode)&&(x.keyCode=-1)}catch{}};var mt="closure_listenable_"+(1e6*Math.random()|0),Mt=0;function ct(x,Z,te,ae,ge){this.listener=x,this.proxy=null,this.src=Z,this.type=te,this.capture=!!ae,this.A=ge,this.key=++Mt,this.s=this.v=!1}function At(x){x.s=!0,x.listener=null,x.proxy=null,x.src=null,x.A=null}function Ue(x){this.src=x,this.a={},this.b=0}function Rt(x,Z){var te=Z.type;if(te in x.a){var ae,ge=x.a[te],me=U(ge,Z);(ae=0<=me)&&Array.prototype.splice.call(ge,me,1),ae&&(At(Z),x.a[te].length==0&&(delete x.a[te],x.b--))}}function pe(x,Z,te,ae){for(var ge=0;ge<x.length;++ge){var me=x[ge];if(!me.s&&me.listener==Z&&me.capture==!!te&&me.A==ae)return ge}return-1}Ue.prototype.add=function(x,Z,te,ae,ge){var me=x.toString();(x=this.a[me])||(x=this.a[me]=[],this.b++);var ue=pe(x,Z,ae,ge);return-1<ue?(Z=x[ue],te||(Z.v=!1)):((Z=new ct(Z,this.src,me,!!ae,ge)).v=te,x.push(Z)),Z};var D="closure_lm_"+(1e6*Math.random()|0),H={};function X(x,Z,te,ae,ge){if(ae&&ae.once)(function ue(he,we,_e,Ee,De){if(Array.isArray(we))for(var Le=0;Le<we.length;Le++)ue(he,we[Le],_e,Ee,De);else _e=Me(_e),he&&he[mt]?he.f.add(String(we),_e,!0,g(Ee)?!!Ee.capture:!!Ee,De):ie(he,we,_e,!0,Ee,De)})(x,Z,te,ae,ge);else if(Array.isArray(Z))for(var me=0;me<Z.length;me++)X(x,Z[me],te,ae,ge);else te=Me(te),x&&x[mt]?x.f.add(String(Z),te,!1,g(ae)?!!ae.capture:!!ae,ge):ie(x,Z,te,!1,ae,ge)}function ie(x,Z,te,ae,ge,me){if(!Z)throw Error("Invalid event type");var ue=g(ge)?!!ge.capture:!!ge,he=le(x);if(he||(x[D]=he=new Ue(x)),!(te=he.add(Z,te,ae,ue,me)).proxy)if(ae=function(){var we=ce,_e=Tt?function(Ee){return we.call(_e.src,_e.listener,Ee)}:function(Ee){if(!(Ee=we.call(_e.src,_e.listener,Ee)))return Ee};return _e}(),te.proxy=ae,ae.src=x,ae.listener=te,x.addEventListener)jt||(ge=ue),ge===void 0&&(ge=!1),x.addEventListener(Z.toString(),ae,ge);else if(x.attachEvent)x.attachEvent(de(Z.toString()),ae);else{if(!x.addListener||!x.removeListener)throw Error("addEventListener and attachEvent are unavailable.");x.addListener(ae)}}function oe(x){if(typeof x!="number"&&x&&!x.s){var Z=x.src;if(Z&&Z[mt])Rt(Z.f,x);else{var te=x.type,ae=x.proxy;Z.removeEventListener?Z.removeEventListener(te,ae,x.capture):Z.detachEvent?Z.detachEvent(de(te),ae):Z.addListener&&Z.removeListener&&Z.removeListener(ae),(te=le(Z))?(Rt(te,x),te.b==0&&(te.src=null,Z[D]=null)):At(x)}}}function de(x){return x in H?H[x]:H[x]="on"+x}function ye(x,Z,te,ae){var ge=!0;if((x=le(x))&&(Z=x.a[Z.toString()]))for(Z=Z.concat(),x=0;x<Z.length;x++){var me=Z[x];me&&me.capture==te&&!me.s&&(me=be(me,ae),ge=ge&&me!==!1)}return ge}function be(x,Z){var te=x.listener,ae=x.A||x.src;return x.v&&oe(x),te.call(ae,Z)}function ce(x,Z){if(x.s)return!0;if(!Tt){var te=Z||E("window.event");Z=new ot(te,this);var ae=!0;if(!(0>te.keyCode||te.returnValue!=null)){e:{var ge=!1;if(te.keyCode==0)try{te.keyCode=-1;break e}catch{ge=!0}(ge||te.returnValue==null)&&(te.returnValue=!0)}for(te=[],ge=Z.a;ge;ge=ge.parentNode)te.push(ge);for(x=x.type,ge=te.length-1;0<=ge;ge--){Z.a=te[ge];var me=ye(te[ge],x,!0,Z);ae=ae&&me}for(ge=0;ge<te.length;ge++)Z.a=te[ge],me=ye(te[ge],x,!1,Z),ae=ae&&me}return ae}return be(x,new ot(Z,this))}function le(x){return(x=x[D])instanceof Ue?x:null}var Re="__closure_events_fn_"+(1e9*Math.random()>>>0);function Me(x){return h(x)=="function"?x:(x[Re]||(x[Re]=function(Z){return x.handleEvent(Z)}),x[Re])}function je(){ut.call(this),this.f=new Ue(this),this.N=this}function Fe(x,Z){x=x.N;var te=Z.type||Z;if(typeof Z=="string")Z=new nt(Z,x);else if(Z instanceof nt)Z.target=Z.target||x;else{var ae=Z;(function(ge,me){for(var ue,he,we=1;we<arguments.length;we++){for(ue in he=arguments[we])ge[ue]=he[ue];for(var _e=0;_e<S.length;_e++)ue=S[_e],Object.prototype.hasOwnProperty.call(he,ue)&&(ge[ue]=he[ue])}})(Z=new nt(te,x),ae)}Ke(x=Z.a=x,te,!0,Z),Ke(x,te,!1,Z)}function Ke(x,Z,te,ae){if(Z=x.f.a[String(Z)]){Z=Z.concat();for(var ge=!0,me=0;me<Z.length;++me){var ue=Z[me];if(ue&&!ue.s&&ue.capture==te){var he=ue.listener,we=ue.A||ue.src;ue.v&&Rt(x.f,ue),ge=he.call(we,ae)!==!1&&ge}}}}function $e(x,Z,te){if(h(x)=="function")te&&(x=j(x,te));else{if(!x||typeof x.handleEvent!="function")throw Error("Invalid listener argument");x=j(x.handleEvent,x)}return 2147483647<Number(Z)?-1:f.setTimeout(x,Z||0)}function Ye(x,Z,te){this.reset(x,Z,te,void 0,void 0)}F(je,ut),je.prototype[mt]=!0,je.prototype.addEventListener=function(x,Z,te,ae){X(this,x,Z,te,ae)},je.prototype.removeEventListener=function(x,Z,te,ae){(function ge(me,ue,he,we,_e){if(Array.isArray(ue))for(var Ee=0;Ee<ue.length;Ee++)ge(me,ue[Ee],he,we,_e);else we=g(we)?!!we.capture:!!we,he=Me(he),me&&me[mt]?(me=me.f,(ue=String(ue).toString())in me.a&&-1<(he=pe(Ee=me.a[ue],he,we,_e))&&(At(Ee[he]),Array.prototype.splice.call(Ee,he,1),Ee.length==0&&(delete me.a[ue],me.b--))):me&&(me=le(me))&&(ue=me.a[ue.toString()],me=-1,ue&&(me=pe(ue,he,we,_e)),(he=-1<me?ue[me]:null)&&oe(he))})(this,x,Z,te,ae)},Ye.prototype.a=null;function xe(x){this.f=x,this.b=this.c=this.a=null}function ke(x,Z){this.name=x,this.value=Z}Ye.prototype.reset=function(x,Z,te,ae,ge){delete this.a},ke.prototype.toString=function(){return this.name};var Ge=new ke("SEVERE",1e3),Ze=new ke("CONFIG",700),Xe=new ke("FINE",500);function Je(x){return x.c?x.c:x.a?Je(x.a):(function(Z,te){throw new w("Failure"+(Z?": "+Z:""),Array.prototype.slice.call(arguments,1))}("Root logger has no level set."),null)}xe.prototype.log=function(x,Z,te){if(x.value>=Je(this).value)for(h(Z)=="function"&&(Z=Z()),x=new Ye(x,String(Z),this.f),te&&(x.a=te),te=this;te;)te=te.a};var st,at={},gt=null;function Qe(x,Z){x&&x.log(Xe,Z,void 0)}function Nt(){}function Bt(x){var Z;return(Z=x.a)||(Z={},zt(x)&&(Z[0]=!0,Z[1]=!0),Z=x.a=Z),Z}function Ut(){}function Ft(x){return(x=zt(x))?new ActiveXObject(x):new XMLHttpRequest}function zt(x){if(!x.b&&typeof XMLHttpRequest>"u"&&typeof ActiveXObject<"u"){for(var Z=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],te=0;te<Z.length;te++){var ae=Z[te];try{return new ActiveXObject(ae),x.b=ae}catch{}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return x.b}function yt(x,Z){this.b={},this.a=[],this.c=0;var te=arguments.length;if(1<te){if(te%2)throw Error("Uneven number of arguments");for(var ae=0;ae<te;ae+=2)this.set(arguments[ae],arguments[ae+1])}else x&&Wt(this,x)}function Lt(x){if(x.c!=x.a.length){for(var Z=0,te=0;Z<x.a.length;){var ae=x.a[Z];wt(x.b,ae)&&(x.a[te++]=ae),Z++}x.a.length=te}if(x.c!=x.a.length){var ge={};for(te=Z=0;Z<x.a.length;)wt(ge,ae=x.a[Z])||(x.a[te++]=ae,ge[ae]=1),Z++;x.a.length=te}}function Wt(x,Z){if(Z instanceof yt)for(var te=Z.f(),ae=0;ae<te.length;ae++)x.set(te[ae],Z.get(te[ae]));else for(te in Z)x.set(te,Z[te])}function wt(x,Z){return Object.prototype.hasOwnProperty.call(x,Z)}Nt.prototype.a=null,F(Ut,Nt),st=new Ut,yt.prototype.f=function(){return Lt(this),this.a.concat()},yt.prototype.get=function(x,Z){return wt(this.b,x)?this.b[x]:Z},yt.prototype.set=function(x,Z){wt(this.b,x)||(this.c++,this.a.push(x)),this.b[x]=Z},yt.prototype.forEach=function(x,Z){for(var te=this.f(),ae=0;ae<te.length;ae++){var ge=te[ae],me=this.get(ge);x.call(Z,me,ge,this)}};var Jt=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function pt(x){je.call(this),this.headers=new yt,this.D=x||null,this.c=!1,this.C=this.a=null,this.J=this.o="",this.g=0,this.i="",this.h=this.I=this.m=this.G=!1,this.l=0,this.u=null,this.j=Ht,this.B=this.H=!1}F(pt,je);var Ht="",Qt=pt.prototype,en=function x(Z){var te;if(gt||(gt=new xe(""),at[""]=gt,gt.c=Ze),!(te=at[Z])){te=new xe(Z);var ae=Z.lastIndexOf("."),ge=Z.substr(ae+1);(ae=x(Z.substr(0,ae))).b||(ae.b={}),ae.b[ge]=te,te.a=ae,at[Z]=te}return te}("goog.net.XhrIo");Qt.b=en;var tn=/^https?$/i,nn=["POST","PUT"];function rn(x,Z,te){if(x.a)throw Error("[goog.net.XhrIo] Object is active with another request="+x.o+"; newUri="+Z);x.o=Z,x.i="",x.g=0,x.J="POST",x.G=!1,x.c=!0,x.a=x.D?Ft(x.D):Ft(st),x.C=x.D?Bt(x.D):Bt(st),x.a.onreadystatechange=j(x.K,x);try{Qe(x.b,dt(x,"Opening Xhr")),x.I=!0,x.a.open("POST",String(Z),!0),x.I=!1}catch(me){return Qe(x.b,dt(x,"Error opening Xhr: "+me.message)),void Vt(x,me)}Z=te||"";var ae=function(me){e:{for(var ue=an,he=me.length,we=typeof me=="string"?me.split(""):me,_e=0;_e<he;_e++)if(_e in we&&ue.call(void 0,we[_e],_e,me)){ue=_e;break e}ue=-1}return 0>ue?null:typeof me=="string"?me.charAt(ue):me[ue]}((te=new yt(x.headers)).f()),ge=f.FormData&&Z instanceof f.FormData;!(0<=U(nn,"POST"))||ae||ge||te.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),te.forEach(function(me,ue){this.a.setRequestHeader(ue,me)},x),x.j&&(x.a.responseType=x.j),"withCredentials"in x.a&&x.a.withCredentials!==x.H&&(x.a.withCredentials=x.H);try{Zt(x),0<x.l&&(x.B=function(me){return se&&tt(9)&&typeof me.timeout=="number"&&me.ontimeout!==void 0}(x.a),Qe(x.b,dt(x,"Will abort after "+x.l+"ms if incomplete, xhr2 "+x.B)),x.B?(x.a.timeout=x.l,x.a.ontimeout=j(x.L,x)):x.u=$e(x.L,x.l,x)),Qe(x.b,dt(x,"Sending request")),x.m=!0,x.a.send(Z),x.m=!1}catch(me){Qe(x.b,dt(x,"Send error: "+me.message)),Vt(x,me)}}function an(x){return x.toLowerCase()=="content-type"}function Vt(x,Z){x.c=!1,x.a&&(x.h=!0,x.a.abort(),x.h=!1),x.i=Z,x.g=5,Gt(x),Pt(x)}function Gt(x){x.G||(x.G=!0,Fe(x,"complete"),Fe(x,"error"))}function $t(x){if(x.c&&u!==void 0){if(x.C[1]&&bt(x)==4&&x.getStatus()==2)Qe(x.b,dt(x,"Local request error detected and ignored"));else if(x.m&&bt(x)==4)$e(x.K,0,x);else if(Fe(x,"readystatechange"),bt(x)==4){Qe(x.b,dt(x,"Request complete")),x.c=!1;try{var Z,te=x.getStatus();e:switch(te){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var ae=!0;break e;default:ae=!1}if(!(Z=ae)){var ge;if(ge=te===0){var me=String(x.o).match(Jt)[1]||null;if(!me&&f.self&&f.self.location){var ue=f.self.location.protocol;me=ue.substr(0,ue.length-1)}ge=!tn.test(me?me.toLowerCase():"")}Z=ge}if(Z)Fe(x,"complete"),Fe(x,"success");else{x.g=6;try{var he=2<bt(x)?x.a.statusText:""}catch(we){Qe(x.b,"Can not get status: "+we.message),he=""}x.i=he+" ["+x.getStatus()+"]",Gt(x)}}finally{Pt(x)}}}}function Pt(x){if(x.a){Zt(x);var Z=x.a,te=x.C[0]?_:null;x.a=null,x.C=null,Fe(x,"ready");try{Z.onreadystatechange=te}catch(ae){(x=x.b)&&x.log(Ge,"Problem encountered resetting onreadystatechange: "+ae.message,void 0)}}}function Zt(x){x.a&&x.B&&(x.a.ontimeout=null),x.u&&(f.clearTimeout(x.u),x.u=null)}function bt(x){return x.a?x.a.readyState:0}function qt(x,Z){if(x.a&&bt(x)==4)return(x=x.a.getResponseHeader(Z))===null?void 0:x}function dt(x,Z){return Z+" ["+x.J+" "+x.o+" "+x.getStatus()+"]"}pt.prototype.L=function(){u!==void 0&&this.a&&(this.i="Timed out after "+this.l+"ms, aborting",this.g=8,Qe(this.b,dt(this,this.i)),Fe(this,"timeout"),this.abort(8))},pt.prototype.abort=function(x){this.a&&this.c&&(Qe(this.b,dt(this,"Aborting")),this.c=!1,this.h=!0,this.a.abort(),this.h=!1,this.g=x||7,Fe(this,"complete"),Fe(this,"abort"),Pt(this))},pt.prototype.K=function(){this.F||(this.I||this.m||this.h?$t(this):this.O())},pt.prototype.O=function(){$t(this)},pt.prototype.getStatus=function(){try{return 2<bt(this)?this.a.status:-1}catch{return-1}};var Yt={},Ot=null;function sn(x){var Z=x.length,te=3*Z/4;te%3?te=Math.floor(te):ee("=.",x[Z-1])&&(te=ee("=.",x[Z-2])?te-2:te-1);var ae=new Uint8Array(te),ge=0;return function(me,ue){function he(We){for(;we<me.length;){var ze=me.charAt(we++),He=Ot[ze];if(He!=null)return He;if(!/^[\s\xa0]*$/.test(ze))throw Error("Unknown base64 encoding at char: "+ze)}return We}Kt();for(var we=0;;){var _e=he(-1),Ee=he(0),De=he(64),Le=he(64);if(Le===64&&_e===-1)break;ue(_e<<2|Ee>>4),De!=64&&(ue(Ee<<4&240|De>>2),Le!=64&&ue(De<<6&192|Le))}}(x,function(me){ae[ge++]=me}),ae.subarray(0,ge)}function Kt(){if(!Ot){Ot={};for(var x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),Z=["+/=","+/","-_=","-_.","-_"],te=0;5>te;te++){var ae=x.concat(Z[te].split(""));Yt[te]=ae;for(var ge=0;ge<ae.length;ge++){var me=ae[ge];Ot[me]===void 0&&(Ot[me]=ge)}}}}var ln=["content-type","grpc-status","grpc-message"];function ft(x){this.a=x.T,this.l=null,this.b=[],this.h=[],this.g=[],this.f=[],this.c=[],this.j=!1,this.i=0,this.m=new L;var Z=this;X(this.a,"readystatechange",function(){var te=Z.a;if(te=te.a?te.a.getResponseHeader("Content-Type"):null){if((te=te.toLowerCase()).lastIndexOf("application/grpc-web-text",0)==0){te=Z.a;try{var ae=te.a?te.a.responseText:""}catch(_e){Qe(te.b,"Can not get responseText: "+_e.message),ae=""}if(ae=(te=ae||"").length-te.length%4,(te=te.substr(Z.i,ae-Z.i)).length==0)return;Z.i=ae,te=sn(te)}else{if(te.lastIndexOf("application/grpc",0)!=0)return void St(Z,{code:2,message:"Unknown Content-type received.",metadata:{}});te=new Uint8Array(function(_e){try{if(!_e.a)return null;if("response"in _e.a)return _e.a.response;switch(_e.j){case Ht:case"text":return _e.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in _e.a)return _e.a.mozResponseArrayBuffer}var Ee=_e.b;return Ee&&Ee.log(Ge,"Response type "+_e.j+" is not supported on this browser",void 0),null}catch(De){return Qe(_e.b,"Can not get response: "+De.message),null}}(Z.a))}ae=null;try{ae=function(_e,Ee){function De(Et){Ne.f++,Ne.a=(Ne.a<<8)+Et,Ne.f==4&&(Ne.b=N,Ne.g=0,typeof Uint8Array<"u"?Ne.c=new Uint8Array(Ne.a):Ne.c=Array(Ne.a),Ne.a==0&&We())}function Le(Et){Ne.c[Ne.g++]=Et,Ne.g==Ne.a&&We()}function We(){var Et={};Et[Ne.h]=Ne.c,Ne.i.push(Et),Ne.b=W}var ze,He,Ne=_e,ht=0;for(ze=Ee instanceof Uint8Array||Ee instanceof Array?Ee:new Uint8Array(Ee);ht<ze.length;){switch(Ne.b){case P:p(Ne,ze,ht,"stream already broken");break;case W:(He=ze[ht])==z||He==O?Ne.h=He:p(Ne,ze,ht,"invalid frame byte"),Ne.b=k,Ne.a=0,Ne.f=0;break;case k:De(ze[ht]);break;case N:Le(ze[ht]);break;default:throw Error("unexpected parser state: "+Ne.b)}Ne.l++,ht++}return _e=Ne.i,Ne.i=[],0<_e.length?_e:null}(Z.m,te)}catch{St(Z,{code:2,message:"Error in parsing response body",metadata:{}})}if(ae)for(te=0;te<ae.length;te++){if(z in ae[te]){var ge=ae[te][z];if(ge)try{var me=Z.l(ge);if(me){ge=Z;for(var ue=me,he=0;he<ge.b.length;he++)ge.b[he](ue)}}catch{St(Z,{code:2,message:"Error in response deserializer function.",metadata:{}})}}if(O in ae[te]&&0<ae[te][O].length){for(ge="",ue=0;ue<ae[te][O].length;ue++)ge+=String.fromCharCode(ae[te][O][ue]);for(ge=ge.trim().split(`\r
|
|
22
22
|
`),ue={},he=0;he<ge.length;he++){var we=ge[he].indexOf(":");ue[ge[he].substring(0,we).trim()]=ge[he].substring(we+1).trim()}ge=ue,ue=0,he="","grpc-status"in ge&&(ue=ge["grpc-status"],delete ge["grpc-status"]),"grpc-message"in ge&&(he=ge["grpc-message"],delete ge["grpc-message"]),St(Z,{code:Number(ue),message:he,metadata:ge})}}}}),X(this.a,"complete",function(){var te=Z.a.g,ae="",ge={},me=function(he){var we={};he=(he.a&&bt(he)==4&&he.a.getAllResponseHeaders()||"").split(`\r
|
|
23
|
-
`);for(var _e=0;_e<he.length;_e++)if(!/^[\s\xa0]*$/.test(he[_e])){var Ee=T(he[_e]),De=Ee[0];if(typeof(Ee=Ee[1])=="string"){Ee=Ee.trim();var Le=we[De]||[];we[De]=Le,Le.push(Ee)}}return function(We,ze){var He,Ne={};for(He in We)Ne[He]=ze.call(void 0,We[He],He,We);return Ne}(we,function(We){return We.join(", ")})}(Z.a);if(Object.keys(me).forEach(function(he){ln.includes(he)||(ge[he]=me[he])}),function(he,we){for(var _e=0;_e<he.g.length;_e++)he.g[_e](we)}(Z,ge),te!=0){switch(te){case 7:var ue=10;break;case 8:ue=4;break;case 6:ue=function(he){switch(he){case 200:return 0;case 400:return 3;case 401:return 16;case 403:return 7;case 404:return 5;case 409:return 10;case 412:return 9;case 429:return 8;case 499:return 1;case 500:return 2;case 501:return 12;case 503:return 14;case 504:return 4;default:return 2}}(Z.a.getStatus());break;default:ue=14}ue==10&&Z.j||St(Z,{code:ue,message:m(te),metadata:{}})}else te=!1,"grpc-status"in me&&(ue=qt(Z.a,"grpc-status"),"grpc-message"in me&&(ae=qt(Z.a,"grpc-message")),Number(ue)!=0&&(St(Z,{code:Number(ue),message:ae,metadata:me}),te=!0)),te||function(he){for(var we=0;we<he.c.length;we++)he.c[we]()}(Z)})}function Ct(x,Z){-1<(Z=x.indexOf(Z))&&x.splice(Z,1)}function St(x,Z){if(Z.code!=0)for(var te={code:Z.code,message:decodeURIComponent(Z.message||""),metadata:Z.metadata},ae=0;ae<x.f.length;ae++)x.f[ae](te);for(Z={code:Z.code,details:decodeURIComponent(Z.message||""),metadata:Z.metadata},te=0;te<x.h.length;te++)x.h[te](Z)}function
|
|
24
|
-
`}),ze}(ue),typeof ge=="string"?(Ee=encodeURIComponent("$httpHeaders"),(Ee+=ue=ue!=null?"="+encodeURIComponent(String(ue)):"")&&(0>(ue=ge.indexOf("#"))&&(ue=ge.length),0>(he=ge.indexOf("?"))||he>ue?(he=ue,we=""):we=ge.substring(he+1,ue),ue=(ge=[ge.substr(0,he),we,ge.substr(ue)])[1],ge[1]=Ee?ue?ue+"&"+Ee:Ee:ue,ge=ge[0]+(ge[1]?"?"+ge[1]:"")+ge[2])):ge.a("$httpHeaders",ue))}for(ae=(Z=(0,ae.a)(Z.getRequestMessage())).length,Ee=[0,0,0,0],ue=new Uint8Array(5+ae),he=3;0<=he;he--)Ee[he]=ae%256,ae>>>=8;if(ue.set(new Uint8Array(Ee),1),ue.set(Z,5),Z=ue,x.a=="text"){var De;for(x=Z,De===void 0&&(De=0),Kt(),De=Yt[De],Z=[],ae=0;ae<x.length;ae+=3){_e=x[ae];var Le=(Ee=ae+1<x.length)?x[ae+1]:0;he=_e>>2,_e=(3&_e)<<4|Le>>4,Le=(15&Le)<<2|(we=(ue=ae+2<x.length)?x[ae+2]:0)>>6,we&=63,ue||(we=64,Ee||(Le=64)),Z.push(De[he],De[_e],De[Le]||"",De[we]||"")}Z=Z.join("")}else x.a=="binary"&&(te.j="arraybuffer");return rn(te,ge,Z),me}function Xt(x,Z,te){var ae=null,ge=!1;x.on("data",function(me){ae=me}),x.on("error",function(me){me.code==0||ge||(ge=!0,Z(me,null))}),x.on("status",function(me){me.code==0||ge?te&&Z(null,null,me):(ge=!0,Z({code:me.code,message:me.details,metadata:me.metadata},null))}),te&&x.on("metadata",function(me){Z(null,null,null,me)}),x.on("end",function(){ge||(ae==null?Z({code:2,message:"Incomplete response"}):Z(null,ae)),te&&Z(null,null)})}function kt(x,Z){var te=x;return Z.forEach(function(ae){var ge=te;te=function(me){return ae.intercept(me,ge)}}),te}ft.prototype.on=function(x,Z){return x=="data"?this.b.push(Z):x=="status"?this.h.push(Z):x=="metadata"?this.g.push(Z):x=="end"?this.c.push(Z):x=="error"&&this.f.push(Z),this},ft.prototype.removeListener=function(x,Z){return x=="data"?Ct(this.b,Z):x=="status"?Ct(this.h,Z):x=="metadata"?Ct(this.g,Z):x=="end"?Ct(this.c,Z):x=="error"&&Ct(this.f,Z),this},ft.prototype.cancel=function(){this.j=!0,this.a.abort()},ft.prototype.cancel=ft.prototype.cancel,ft.prototype.removeListener=ft.prototype.removeListener,ft.prototype.on=ft.prototype.on,ot.prototype.P=function(x,Z,te,ae,ge){var me=this;ae=q(x,Z,"unary",ae);var ue=x.substr(0,x.length-ae.name.length);return Xt(x=kt(function(he){return Dt(me,he,ue)},this.b).call(this,$(ae,Z,te)),ge,!1),new y(x)},ot.prototype.M=function(x,Z,te,ae){var ge=this;ae=q(x,Z,"unary",ae);var me=x.substr(0,x.length-ae.name.length);return kt(function(ue){return new Promise(function(he,we){var _e,Ee,De;Xt(Dt(ge,ue,me),function(Le,We,ze,He){Le?we(Le):We?De=We:ze?Ee=ze:He?_e=He:(Le=ue.getMethodDescriptor(),he(new d(De,Le,We=(We=_e)===void 0?{}:We,Ee===void 0?null:Ee)))},!0)})},this.g).call(this,$(ae,Z,te)).then(function(ue){return ue.getResponseMessage()})},ot.prototype.unaryCall=function(x,Z,te,ae){return this.M(x,Z,te,ae)},ot.prototype.R=function(x,Z,te,ae){var ge=this;ae=q(x,Z,"server_streaming",ae);var me=x.substr(0,x.length-ae.name.length);return kt(function(ue){return Dt(ge,ue,me)},this.b).call(this,$(ae,Z,te))},ot.prototype.serverStreaming=ot.prototype.R,ot.prototype.unaryCall=ot.prototype.unaryCall,ot.prototype.thenableCall=ot.prototype.M,ot.prototype.rpcCall=ot.prototype.P,e.exports.AbstractClientBase={MethodInfo:function(x,Z,te,ae,ge){this.name=ae,this.b=ge,this.f=x,this.a=Z,this.c=te}},e.exports.GrpcWebClientBase=ot,e.exports.StatusCode={OK:0,CANCELLED:1,UNKNOWN:2,INVALID_ARGUMENT:3,DEADLINE_EXCEEDED:4,NOT_FOUND:5,ALREADY_EXISTS:6,PERMISSION_DENIED:7,UNAUTHENTICATED:16,RESOURCE_EXHAUSTED:8,FAILED_PRECONDITION:9,ABORTED:10,OUT_OF_RANGE:11,UNIMPLEMENTED:12,INTERNAL:13,UNAVAILABLE:14,DATA_LOSS:15},e.exports.MethodDescriptor=I,e.exports.MethodType={UNARY:"unary",SERVER_STREAMING:"server_streaming"}}).call(this,n(6))},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.isAsyncIterable=t.isAsyncGenerator=t.isAsync=void 0;var r,i=n(152),s=(r=i)&&r.__esModule?r:{default:r};function l(o){return o[Symbol.toStringTag]==="AsyncFunction"}t.default=function(o){if(typeof o!="function")throw new Error("expected a function");return l(o)?(0,s.default)(o):o},t.isAsync=l,t.isAsyncGenerator=function(o){return o[Symbol.toStringTag]==="AsyncGenerator"},t.isAsyncIterable=function(o){return typeof o[Symbol.asyncIterator]=="function"}},function(e,t,n){var r={};function i(l,o,c){c||(c=Error);var u=function(f){var E,_;function h(g,b,A){return f.call(this,function(j,F,M){return typeof o=="string"?o:o(j,F,M)}(g,b,A))||this}return _=f,(E=h).prototype=Object.create(_.prototype),E.prototype.constructor=E,E.__proto__=_,h}(c);u.prototype.name=c.name,u.prototype.code=l,r[l]=u}function s(l,o){if(Array.isArray(l)){var c=l.length;return l=l.map(function(u){return String(u)}),c>2?"one of ".concat(o," ").concat(l.slice(0,c-1).join(", "),", or ")+l[c-1]:c===2?"one of ".concat(o," ").concat(l[0]," or ").concat(l[1]):"of ".concat(o," ").concat(l[0])}return"of ".concat(o," ").concat(String(l))}i("ERR_INVALID_OPT_VALUE",function(l,o){return'The value "'+o+'" is invalid for option "'+l+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(l,o,c){var u,f,E;if(typeof o=="string"&&(f="not ",o.substr(0,f.length)===f)?(u="must not be",o=o.replace(/^not /,"")):u="must be",function(h,g,b){return(b===void 0||b>h.length)&&(b=h.length),h.substring(b-g.length,b)===g}(l," argument"))E="The ".concat(l," ").concat(u," ").concat(s(o,"type"));else{var _=function(h,g,b){return typeof b!="number"&&(b=0),!(b+g.length>h.length)&&h.indexOf(g,b)!==-1}(l,".")?"property":"argument";E='The "'.concat(l,'" ').concat(_," ").concat(u," ").concat(s(o,"type"))}return E+=". Received type ".concat(typeof c)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(l){return"The "+l+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(l){return"Cannot call "+l+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(l){return"Unknown encoding: "+l},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=r},function(e,t,n){(function(r){var i=Object.keys||function(h){var g=[];for(var b in h)g.push(b);return g};e.exports=f;var s=n(77),l=n(81);n(7)(f,s);for(var o=i(l.prototype),c=0;c<o.length;c++){var u=o[c];f.prototype[u]||(f.prototype[u]=l.prototype[u])}function f(h){if(!(this instanceof f))return new f(h);s.call(this,h),l.call(this,h),this.allowHalfOpen=!0,h&&(h.readable===!1&&(this.readable=!1),h.writable===!1&&(this.writable=!1),h.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",E)))}function E(){this._writableState.ended||r.nextTick(_,this)}function _(h){h.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(h){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=h,this._writableState.destroyed=h)}})}).call(this,n(2))},function(e,t,n){n.d(t,"a",function(){return l});var r=n(40),i=n(4);const s={"app-id":["app-id must match formant/*"]};class l extends r.a{constructor(c,u={}){super(c,Object.assign({validateHeaders:f=>`${f.get("app-id")}`.startsWith("formant/")?{}:s},u)),this.endpoint=c}getHeaders(){return Object.assign(Object.assign({},l.headers),{"App-ID":`formant/${i.a}`,"App-Version":i.j})}}l.headers={}},function(e,t,n){n(227),e.exports={encode:r=>new TextEncoder().encode(r),decode:r=>new TextDecoder().decode(r)}},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r,i=r.length){if(!i)throw new Error("arity is undefined");return function(...s){return typeof s[i-1]=="function"?r.apply(this,s):new Promise((l,o)=>{s[i-1]=(c,...u)=>{if(c)return o(c);l(u.length>1?u:u[0])},r.apply(this,s)})}},e.exports=t.default},function(e,t,n){(t=e.exports=n(69)).Stream=t,t.Readable=t,t.Writable=n(48),t.Duplex=n(23),t.Transform=n(72),t.PassThrough=n(165)},function(e,t,n){(t=e.exports=n(77)).Stream=t,t.Readable=t,t.Writable=n(81),t.Duplex=n(27),t.Transform=n(82),t.PassThrough=n(184),t.finished=n(49),t.pipeline=n(185)},function(e,t,n){e.exports=function(r){return r}},function(e,t,n){n.d(t,"a",function(){return i});const r=["password","secret","token","key","buffer"];function i(s,l=new Set){return l.has(s)?"[ RECURSIVE ]":!(o=s)||typeof o!="object"&&typeof o!="function"?s:(l.add(s),Object.keys(s).reduce((c,u)=>(c[u]=r.some(f=>u.toLowerCase().includes(f.toLowerCase()))?"[ REDACTED ]":i(s[u],l),c),{}));var o}},function(e,t){e.exports=r,r.default=r,r.stable=s,r.stableStringify=s;var n=[];function r(l,o,c){(function E(_,h,g,b){var A;if(typeof _=="object"&&_!==null){for(A=0;A<g.length;A++)if(g[A]===_)return b[h]="[Circular]",void n.push([b,h,_]);if(g.push(_),Array.isArray(_))for(A=0;A<_.length;A++)E(_[A],A,g,_);else{var j=Object.keys(_);for(A=0;A<j.length;A++){var F=j[A];E(_[F],F,g,_)}}g.pop()}})(l,"",[],void 0);for(var u=JSON.stringify(l,o,c);n.length!==0;){var f=n.pop();f[0][f[1]]=f[2]}return u}function i(l,o){return l<o?-1:l>o?1:0}function s(l,o,c){for(var u=function _(h,g,b,A){var j;if(typeof h=="object"&&h!==null){for(j=0;j<b.length;j++)if(b[j]===h)return A[g]="[Circular]",void n.push([A,g,h]);if(typeof h.toJSON=="function")return;if(b.push(h),Array.isArray(h))for(j=0;j<h.length;j++)_(h[j],j,b,h);else{var F={},M=Object.keys(h).sort(i);for(j=0;j<M.length;j++){var R=M[j];_(h[R],R,b,h),F[R]=h[R]}if(A===void 0)return F;n.push([A,g,h]),A[g]=F}b.pop()}}(l,"",[],void 0)||l,f=JSON.stringify(u,o,c);n.length!==0;){var E=n.pop();E[0][E[1]]=E[2]}return f}},function(e,t,n){var r=n(16),i=Object.keys||function(g){var b=[];for(var A in g)b.push(A);return b};e.exports=E;var s=Object.create(n(17));s.inherits=n(7);var l=n(143),o=n(62);s.inherits(E,l);for(var c=i(o.prototype),u=0;u<c.length;u++){var f=c[u];E.prototype[f]||(E.prototype[f]=o.prototype[f])}function E(g){if(!(this instanceof E))return new E(g);l.call(this,g),o.call(this,g),g&&g.readable===!1&&(this.readable=!1),g&&g.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,g&&g.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",_)}function _(){this.allowHalfOpen||this._writableState.ended||r.nextTick(h,this)}function h(g){g.end()}Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(E.prototype,"destroyed",{get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(g){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=g,this._writableState.destroyed=g)}}),E.prototype._destroy=function(g,b){this.push(null),this.end(),r.nextTick(b,g)}},function(e,t,n){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function i(o,c){return Object.prototype.hasOwnProperty.call(o,c)}t.assign=function(o){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var f in u)i(u,f)&&(o[f]=u[f])}}return o},t.shrinkBuf=function(o,c){return o.length===c?o:o.subarray?o.subarray(0,c):(o.length=c,o)};var s={arraySet:function(o,c,u,f,E){if(c.subarray&&o.subarray)o.set(c.subarray(u,u+f),E);else for(var _=0;_<f;_++)o[E+_]=c[u+_]},flattenChunks:function(o){var c,u,f,E,_,h;for(f=0,c=0,u=o.length;c<u;c++)f+=o[c].length;for(h=new Uint8Array(f),E=0,c=0,u=o.length;c<u;c++)_=o[c],h.set(_,E),E+=_.length;return h}},l={arraySet:function(o,c,u,f,E){for(var _=0;_<f;_++)o[E+_]=c[u+_]},flattenChunks:function(o){return[].concat.apply([],o)}};t.setTyped=function(o){o?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,s)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,l))},t.setTyped(r)},function(e,t,n){e.exports=n(186)},function(e,t,n){n.d(t,"a",function(){return i});var r=n(229);const i=Object(r.a)()},function(e,t,n){n.d(t,"a",function(){return j});var r=n(1),i=n(100),s=n.n(i),l=n(101),o=n.n(l);class c extends Error{constructor(M,R,d){super(`Connection failure: ${M.message}`),this.cause=M,this.url=R,this.retryable=d}}var u=n(10);class f extends Error{constructor(M,R){super(`Invalid headers (${JSON.stringify(M)}) for response: ${R.message}`),this.validationErrors=M,this.responseError=R}}var E=n(8),_=n(0),h=n(11),g=function(F,M,R,d){return new(R||(R=Promise))(function(I,$){function q(C){try{m(d.next(C))}catch(w){$(w)}}function y(C){try{m(d.throw(C))}catch(w){$(w)}}function m(C){var w;C.done?I(C.value):(w=C.value,w instanceof R?w:new R(function(L){L(w)})).then(q,y)}m((d=d.apply(F,M||[])).next())})},b=function(F,M){var R={};for(var d in F)Object.prototype.hasOwnProperty.call(F,d)&&M.indexOf(d)<0&&(R[d]=F[d]);if(F!=null&&typeof Object.getOwnPropertySymbols=="function"){var I=0;for(d=Object.getOwnPropertySymbols(F);I<d.length;I++)M.indexOf(d[I])<0&&Object.prototype.propertyIsEnumerable.call(F,d[I])&&(R[d[I]]=F[d[I]])}return R};const A=new Set(["GET","HEAD","PUT","QUERY","DELETE","OPTIONS","TRACE"]);class j{constructor(M,R={}){if(this.endpoint=M,this.validateHeaders=d=>R.validateHeaders?R.validateHeaders(d):{},this.verbose=R.verbose!==!1,R.retries!==void 0&&!(R.retries>=0))throw new Error("retries must be positive or zero");if(this.configuredRetries=R.retries,R.timeoutMs!==void 0&&!(R.timeoutMs>0))throw new Error("timeoutMs must be positive");if(this.timeoutMs=R.timeoutMs,R.maxBackoffDelayMs!==void 0&&!(R.maxBackoffDelayMs>0))throw new Error("maxBackoffDelayMs must be positive");this.maxBackoffDelayMs=R.maxBackoffDelayMs||30*r.a.second}getRetries(){return this.configuredRetries!==void 0?this.configuredRetries:this.getConstructor().retries}getHeaders(){return{}}fetch(M,R={}){return g(this,void 0,void 0,function*(){return(yield this.fetchVerbose(M,R)).body})}fetchVerbose(M,R={}){return g(this,void 0,void 0,function*(){let d=100*r.a.millisecond,I=0;const $=this.timeoutMs!==void 0?new Date().getTime()+this.timeoutMs:void 0,q=$?()=>Math.max($-new Date().getTime(),0):void 0;for(;;)try{return yield this.doFetch(M,R,q)}catch(y){const m=y,C=Object(h.a)(m,c);if((q==null?void 0:q())===0||I===this.getRetries()||!C.retryable)throw C;I++,d=Math.min(...q?[q()]:[],d*(2+.1*(Math.random()-.5)),this.maxBackoffDelayMs),yield Object(E.a)(d),this.verbose&&_.a.warn(`Connection failure, retrying. Error: ${m.cause.message}`,{url:m.url,error:m.cause,attempt:I})}})}doFetch(M,R,d){return g(this,void 0,void 0,function*(){const{token:I,json:$,allowUnsafeRetries:q}=R,y=b(R,["token","json","allowUnsafeRetries"]),m=(y.method||"GET").toUpperCase(),C=this.endpoint!==void 0?`${this.endpoint}${M?`/${M}`:""}`:M,w=new s.a;let L;if(d){const W=d();W>0?L=setTimeout(()=>{w.abort()},W):w.abort()}try{let W;yield Promise.race([this.getConstructor().waitForConnectivity(),new Promise(U=>{W=setTimeout(U,d?Math.min(r.a.minute,d()):r.a.minute)})]),W&&clearTimeout(W);const k=yield o()(C,Object.assign(Object.assign({},y),{headers:Object.assign(Object.assign(Object.assign(Object.assign({},$!==!1?{"Content-Type":"application/json"}:{}),this.getHeaders()),y.headers||{}),I!==void 0?{Authorization:`Bearer ${I}`}:{}),signal:w.signal})),N=k.headers.get("content-type")||"",P=N&&N.startsWith("application/json"),z=P?yield k.json():yield k.text(),O=()=>new u.a(m,C,k.status,z,z&&z.validationErrors||{},k.headers);if(!k.ok)throw this.verbose&&_.a[k.status>=500?"warn":"info"]("Response error",{method:m,url:C,statusCode:k.status}),O();const p=this.validateHeaders(k.headers);if(Object.keys(p).length!==0)throw new f(p,O());if(k.status===204)return{body:void 0,headers:k.headers};if($&&!P)throw new Error(`Response is not JSON: ${JSON.stringify(z)}`);return{body:z,headers:k.headers}}catch(W){const k=W,N=q||A.has(m);if(k.message==="Network request failed")throw new c(k,C,N);if(k.type==="system"&&["EAI_AGAIN","ECONNREFUSED","EHOSTUNREACH","ENOTFOUND"].find(p=>p===k.code))throw new c(k,C,!0);if(k.type==="system"&&["ETIMEDOUT","ECONNRESET","ESOCKETTIMEDOUT","EPIPE"].find(p=>p===k.code))throw new c(k,C,N);if(k.name==="AbortError")throw new c(k,C,N);const P=Object(h.a)(k,u.a),{statusCode:z}=P;if(z===408||z===429||z===502||z===503||z===504)throw this.verbose&&!N&&_.a.warn("Potentially unsafe retry"),new c(k,C,!0);const O=this.validateHeaders(P.headers);throw Object.keys(O).length!==0?new f(O,P):(yield this.getConstructor().onResponseError(P),k)}finally{L&&clearTimeout(L)}})}getConstructor(){return Object.getPrototypeOf(this).constructor}}j.retries=8,j.waitForConnectivity=()=>g(void 0,void 0,void 0,function*(){}),j.onResponseError=()=>g(void 0,void 0,void 0,function*(){})},function(e,t,n){function r(E,_){if(!(E instanceof _))throw new TypeError("Cannot call a class as a function")}function i(E,_){for(var h=0;h<_.length;h++){var g=_[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(E,g.key,g)}}var s=n(59),l=n(3),o=l.LEVEL,c=l.MESSAGE;s.enabled=!0;var u=/\s+/,f=function(){function E(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};r(this,E),b.colors&&this.addColors(b.colors),this.options=b}var _,h,g;return _=E,g=[{key:"addColors",value:function(b){var A=Object.keys(b).reduce(function(j,F){return j[F]=u.test(b[F])?b[F].split(u):b[F],j},{});return E.allColors=Object.assign({},E.allColors||{},A),E.allColors}}],(h=[{key:"addColors",value:function(b){return E.addColors(b)}},{key:"colorize",value:function(b,A,j){if(j===void 0&&(j=A),!Array.isArray(E.allColors[b]))return s[E.allColors[b]](j);for(var F=0,M=E.allColors[b].length;F<M;F++)j=s[E.allColors[b][F]](j);return j}},{key:"transform",value:function(b,A){return A.all&&typeof b[c]=="string"&&(b[c]=this.colorize(b[o],b.level,b[c])),(A.level||A.all||!A.message)&&(b.level=this.colorize(b[o],b.level)),(A.all||A.message)&&(b.message=this.colorize(b[o],b.level,b.message)),b}}])&&i(_.prototype,h),g&&i(_,g),E}();e.exports=function(E){return new f(E)},e.exports.Colorizer=e.exports.Format=f},function(e,t){var n={}.toString;e.exports=Array.isArray||function(r){return n.call(r)=="[object Array]"}},function(e,t,n){(function(r){function i(s){try{if(!r.localStorage)return!1}catch{return!1}var l=r.localStorage[s];return l!=null&&String(l).toLowerCase()==="true"}e.exports=function(s,l){if(i("noDeprecation"))return s;var o=!1;return function(){if(!o){if(i("throwDeprecation"))throw new Error(l);i("traceDeprecation")?console.trace(l):console.warn(l),o=!0}return s.apply(this,arguments)}}}).call(this,n(6))},function(e,t,n){var r=n(5),i=r.Buffer;function s(o,c){for(var u in o)c[u]=o[u]}function l(o,c,u){return i(o,c,u)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=l),s(i,l),l.from=function(o,c,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return i(o,c,u)},l.alloc=function(o,c,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=i(o);return c!==void 0?typeof u=="string"?f.fill(c,u):f.fill(c):f.fill(0),f},l.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return i(o)},l.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return r&&typeof r.length=="number"&&r.length>=0&&r.length%1==0},e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default={},e.exports=t.default},function(e,t,n){var r=n(5),i=r.Buffer;function s(o,c){for(var u in o)c[u]=o[u]}function l(o,c,u){return i(o,c,u)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=l),s(i,l),l.from=function(o,c,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return i(o,c,u)},l.alloc=function(o,c,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=i(o);return c!==void 0?typeof u=="string"?f.fill(c,u):f.fill(c):f.fill(0),f},l.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return i(o)},l.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}},function(e,t,n){(function(r,i,s){var l=n(16);function o(m){var C=this;this.next=null,this.entry=null,this.finish=function(){(function(w,L,W){var k=w.entry;for(w.entry=null;k;){var N=k.callback;L.pendingcb--,N(W),k=k.next}L.corkedRequestsFree?L.corkedRequestsFree.next=w:L.corkedRequestsFree=w})(C,m)}}e.exports=M;var c,u=!r.browser&&["v0.10","v0.9."].indexOf(r.version.slice(0,5))>-1?i:l.nextTick;M.WritableState=F;var f=n(17);f.inherits=n(7);var E={deprecate:n(43)},_=n(70),h=n(47).Buffer,g=s.Uint8Array||function(){},b,A=n(71);function j(){}function F(m,C){c=c||n(23),m=m||{};var w=C instanceof c;this.objectMode=!!m.objectMode,w&&(this.objectMode=this.objectMode||!!m.writableObjectMode);var L=m.highWaterMark,W=m.writableHighWaterMark,k=this.objectMode?16:16384;this.highWaterMark=L||L===0?L:w&&(W||W===0)?W:k,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var N=m.decodeStrings===!1;this.decodeStrings=!N,this.defaultEncoding=m.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(P){(function(z,O){var p=z._writableState,U=p.sync,V=p.writecb;if(function(ee){ee.writing=!1,ee.writecb=null,ee.length-=ee.writelen,ee.writelen=0}(p),O)(function(ee,ne,Y,G,S){--ne.pendingcb,Y?(l.nextTick(S,G),l.nextTick(y,ee,ne),ee._writableState.errorEmitted=!0,ee.emit("error",G)):(S(G),ee._writableState.errorEmitted=!0,ee.emit("error",G),y(ee,ne))})(z,p,U,O,V);else{var Q=$(p);Q||p.corked||p.bufferProcessing||!p.bufferedRequest||I(z,p),U?u(d,z,p,Q,V):d(z,p,Q,V)}})(C,P)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function M(m){if(c=c||n(23),!(b.call(M,this)||this instanceof c))return new M(m);this._writableState=new F(m,this),this.writable=!0,m&&(typeof m.write=="function"&&(this._write=m.write),typeof m.writev=="function"&&(this._writev=m.writev),typeof m.destroy=="function"&&(this._destroy=m.destroy),typeof m.final=="function"&&(this._final=m.final)),_.call(this)}function R(m,C,w,L,W,k,N){C.writelen=L,C.writecb=N,C.writing=!0,C.sync=!0,w?m._writev(W,C.onwrite):m._write(W,k,C.onwrite),C.sync=!1}function d(m,C,w,L){w||function(W,k){k.length===0&&k.needDrain&&(k.needDrain=!1,W.emit("drain"))}(m,C),C.pendingcb--,L(),y(m,C)}function I(m,C){C.bufferProcessing=!0;var w=C.bufferedRequest;if(m._writev&&w&&w.next){var L=C.bufferedRequestCount,W=new Array(L),k=C.corkedRequestsFree;k.entry=w;for(var N=0,P=!0;w;)W[N]=w,w.isBuf||(P=!1),w=w.next,N+=1;W.allBuffers=P,R(m,C,!0,C.length,W,"",k.finish),C.pendingcb++,C.lastBufferedRequest=null,k.next?(C.corkedRequestsFree=k.next,k.next=null):C.corkedRequestsFree=new o(C),C.bufferedRequestCount=0}else{for(;w;){var z=w.chunk,O=w.encoding,p=w.callback;if(R(m,C,!1,C.objectMode?1:z.length,z,O,p),w=w.next,C.bufferedRequestCount--,C.writing)break}w===null&&(C.lastBufferedRequest=null)}C.bufferedRequest=w,C.bufferProcessing=!1}function $(m){return m.ending&&m.length===0&&m.bufferedRequest===null&&!m.finished&&!m.writing}function q(m,C){m._final(function(w){C.pendingcb--,w&&m.emit("error",w),C.prefinished=!0,m.emit("prefinish"),y(m,C)})}function y(m,C){var w=$(C);return w&&(function(L,W){W.prefinished||W.finalCalled||(typeof L._final=="function"?(W.pendingcb++,W.finalCalled=!0,l.nextTick(q,L,W)):(W.prefinished=!0,L.emit("prefinish")))}(m,C),C.pendingcb===0&&(C.finished=!0,m.emit("finish"))),w}f.inherits(M,_),F.prototype.getBuffer=function(){for(var m=this.bufferedRequest,C=[];m;)C.push(m),m=m.next;return C},function(){try{Object.defineProperty(F.prototype,"buffer",{get:E.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}(),typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(b=Function.prototype[Symbol.hasInstance],Object.defineProperty(M,Symbol.hasInstance,{value:function(m){return!!b.call(this,m)||this===M&&m&&m._writableState instanceof F}})):b=function(m){return m instanceof this},M.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},M.prototype.write=function(m,C,w){var L,W=this._writableState,k=!1,N=!W.objectMode&&(L=m,h.isBuffer(L)||L instanceof g);return N&&!h.isBuffer(m)&&(m=function(P){return h.from(P)}(m)),typeof C=="function"&&(w=C,C=null),N?C="buffer":C||(C=W.defaultEncoding),typeof w!="function"&&(w=j),W.ended?function(P,z){var O=new Error("write after end");P.emit("error",O),l.nextTick(z,O)}(this,w):(N||function(P,z,O,p){var U=!0,V=!1;return O===null?V=new TypeError("May not write null values to stream"):typeof O=="string"||O===void 0||z.objectMode||(V=new TypeError("Invalid non-string/buffer chunk")),V&&(P.emit("error",V),l.nextTick(p,V),U=!1),U}(this,W,m,w))&&(W.pendingcb++,k=function(P,z,O,p,U,V){if(!O){var Q=function(G,S,T){return G.objectMode||G.decodeStrings===!1||typeof S!="string"||(S=h.from(S,T)),S}(z,p,U);p!==Q&&(O=!0,U="buffer",p=Q)}var ee=z.objectMode?1:p.length;z.length+=ee;var ne=z.length<z.highWaterMark;if(ne||(z.needDrain=!0),z.writing||z.corked){var Y=z.lastBufferedRequest;z.lastBufferedRequest={chunk:p,encoding:U,isBuf:O,callback:V,next:null},Y?Y.next=z.lastBufferedRequest:z.bufferedRequest=z.lastBufferedRequest,z.bufferedRequestCount+=1}else R(P,z,!1,ee,p,U,V);return ne}(this,W,N,m,C,w)),k},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){var m=this._writableState;m.corked&&(m.corked--,m.writing||m.corked||m.finished||m.bufferProcessing||!m.bufferedRequest||I(this,m))},M.prototype.setDefaultEncoding=function(m){if(typeof m=="string"&&(m=m.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((m+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+m);return this._writableState.defaultEncoding=m,this},Object.defineProperty(M.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),M.prototype._write=function(m,C,w){w(new Error("_write() is not implemented"))},M.prototype._writev=null,M.prototype.end=function(m,C,w){var L=this._writableState;typeof m=="function"?(w=m,m=null,C=null):typeof C=="function"&&(w=C,C=null),m!=null&&this.write(m,C),L.corked&&(L.corked=1,this.uncork()),L.ending||L.finished||function(W,k,N){k.ending=!0,y(W,k),N&&(k.finished?l.nextTick(N):W.once("finish",N)),k.ended=!0,W.writable=!1}(this,L,w)},Object.defineProperty(M.prototype,"destroyed",{get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(m){this._writableState&&(this._writableState.destroyed=m)}}),M.prototype.destroy=A.destroy,M.prototype._undestroy=A.undestroy,M.prototype._destroy=function(m,C){this.end(),C(m)}}).call(this,n(2),n(15).setImmediate,n(6))},function(e,t,n){var r=n(26).codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function s(l,o,c){if(typeof o=="function")return s(l,null,o);o||(o={}),c=function(M){var R=!1;return function(){if(!R){R=!0;for(var d=arguments.length,I=new Array(d),$=0;$<d;$++)I[$]=arguments[$];M.apply(this,I)}}}(c||i);var u=o.readable||o.readable!==!1&&l.readable,f=o.writable||o.writable!==!1&&l.writable,E=function(){l.writable||h()},_=l._writableState&&l._writableState.finished,h=function(){f=!1,_=!0,u||c.call(l)},g=l._readableState&&l._readableState.endEmitted,b=function(){u=!1,g=!0,f||c.call(l)},A=function(M){c.call(l,M)},j=function(){var M;return u&&!g?(l._readableState&&l._readableState.ended||(M=new r),c.call(l,M)):f&&!_?(l._writableState&&l._writableState.ended||(M=new r),c.call(l,M)):void 0},F=function(){l.req.on("finish",h)};return function(M){return M.setHeader&&typeof M.abort=="function"}(l)?(l.on("complete",h),l.on("abort",j),l.req?F():l.on("request",F)):f&&!l._writableState&&(l.on("end",E),l.on("close",E)),l.on("end",b),l.on("finish",h),o.error!==!1&&l.on("error",A),l.on("close",j),function(){l.removeListener("complete",h),l.removeListener("abort",j),l.removeListener("request",F),l.req&&l.req.removeListener("finish",h),l.removeListener("end",E),l.removeListener("close",E),l.removeListener("finish",h),l.removeListener("end",b),l.removeListener("error",A),l.removeListener("close",j)}}},function(e,t,n){var r=n(58),i=n(3).configs;t.cli=r.levels(i.cli),t.npm=r.levels(i.npm),t.syslog=r.levels(i.syslog),t.addColors=r.levels},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=o(n(203)),i=o(n(204)),s=o(n(25)),l=o(n(30));function o(c){return c&&c.__esModule?c:{default:c}}t.default=(0,l.default)(function(c,u,f){return(0,r.default)(c,(0,i.default)((0,s.default)(u)),f)},3),e.exports=t.default},function(e,t,n){class r extends Error{constructor(s,...l){super(`env-var: ${s}`,...l),Error.captureStackTrace&&Error.captureStackTrace(this,r),this.name="EnvVarError"}}e.exports=r},function(e,t,n){e.exports=function(r){const i=parseInt(r,10);if(isNaN(i)||i.toString(10)!==r)throw new Error("should be a valid integer");return i}},function(e,t,n){e.exports=function(r){const i=parseFloat(r);if(isNaN(i)||i.toString()!==r)throw new Error("should be a valid float");return i}},function(e,t,n){e.exports=function(r){try{return JSON.parse(r)}catch{throw new Error("should be valid (parseable) JSON")}}},function(e,t,n){(function(r){function i(o,c){for(var u=0,f=o.length-1;f>=0;f--){var E=o[f];E==="."?o.splice(f,1):E===".."?(o.splice(f,1),u++):u&&(o.splice(f,1),u--)}if(c)for(;u--;u)o.unshift("..");return o}function s(o,c){if(o.filter)return o.filter(c);for(var u=[],f=0;f<o.length;f++)c(o[f],f,o)&&u.push(o[f]);return u}t.resolve=function(){for(var o="",c=!1,u=arguments.length-1;u>=-1&&!c;u--){var f=u>=0?arguments[u]:r.cwd();if(typeof f!="string")throw new TypeError("Arguments to path.resolve must be strings");f&&(o=f+"/"+o,c=f.charAt(0)==="/")}return(c?"/":"")+(o=i(s(o.split("/"),function(E){return!!E}),!c).join("/"))||"."},t.normalize=function(o){var c=t.isAbsolute(o),u=l(o,-1)==="/";return(o=i(s(o.split("/"),function(f){return!!f}),!c).join("/"))||c||(o="."),o&&u&&(o+="/"),(c?"/":"")+o},t.isAbsolute=function(o){return o.charAt(0)==="/"},t.join=function(){var o=Array.prototype.slice.call(arguments,0);return t.normalize(s(o,function(c,u){if(typeof c!="string")throw new TypeError("Arguments to path.join must be strings");return c}).join("/"))},t.relative=function(o,c){function u(A){for(var j=0;j<A.length&&A[j]==="";j++);for(var F=A.length-1;F>=0&&A[F]==="";F--);return j>F?[]:A.slice(j,F-j+1)}o=t.resolve(o).substr(1),c=t.resolve(c).substr(1);for(var f=u(o.split("/")),E=u(c.split("/")),_=Math.min(f.length,E.length),h=_,g=0;g<_;g++)if(f[g]!==E[g]){h=g;break}var b=[];for(g=h;g<f.length;g++)b.push("..");return(b=b.concat(E.slice(h))).join("/")},t.sep="/",t.delimiter=":",t.dirname=function(o){if(typeof o!="string"&&(o+=""),o.length===0)return".";for(var c=o.charCodeAt(0),u=c===47,f=-1,E=!0,_=o.length-1;_>=1;--_)if((c=o.charCodeAt(_))===47){if(!E){f=_;break}}else E=!1;return f===-1?u?"/":".":u&&f===1?"/":o.slice(0,f)},t.basename=function(o,c){var u=function(f){typeof f!="string"&&(f+="");var E,_=0,h=-1,g=!0;for(E=f.length-1;E>=0;--E)if(f.charCodeAt(E)===47){if(!g){_=E+1;break}}else h===-1&&(g=!1,h=E+1);return h===-1?"":f.slice(_,h)}(o);return c&&u.substr(-1*c.length)===c&&(u=u.substr(0,u.length-c.length)),u},t.extname=function(o){typeof o!="string"&&(o+="");for(var c=-1,u=0,f=-1,E=!0,_=0,h=o.length-1;h>=0;--h){var g=o.charCodeAt(h);if(g!==47)f===-1&&(E=!1,f=h+1),g===46?c===-1?c=h:_!==1&&(_=1):c!==-1&&(_=-1);else if(!E){u=h+1;break}}return c===-1||f===-1||_===0||_===1&&c===f-1&&c===u+1?"":o.slice(c,f)};var l="ab".substr(-1)==="b"?function(o,c,u){return o.substr(c,u)}:function(o,c,u){return c<0&&(c=o.length+c),o.substr(c,u)}}).call(this,n(2))},,function(e,t,n){var r=t.format=n(12);t.levels=n(105),Object.defineProperty(r,"align",{value:n(122)}),Object.defineProperty(r,"cli",{value:n(123)}),Object.defineProperty(r,"combine",{value:n(124)}),Object.defineProperty(r,"colorize",{value:n(41)}),Object.defineProperty(r,"json",{value:n(125)}),Object.defineProperty(r,"label",{value:n(128)}),Object.defineProperty(r,"logstash",{value:n(129)}),Object.defineProperty(r,"metadata",{value:n(130)}),Object.defineProperty(r,"padLevels",{value:n(60)}),Object.defineProperty(r,"prettyPrint",{value:n(131)}),Object.defineProperty(r,"printf",{value:n(132)}),Object.defineProperty(r,"simple",{value:n(133)}),Object.defineProperty(r,"splat",{value:n(134)}),Object.defineProperty(r,"timestamp",{value:n(135)}),Object.defineProperty(r,"uncolorize",{value:n(137)})},function(e,t,n){var r=n(106);e.exports=r},function(e,t,n){function r(_){return function(h){if(Array.isArray(h))return i(h)}(_)||function(h){if(typeof Symbol<"u"&&Symbol.iterator in Object(h))return Array.from(h)}(_)||function(h,g){if(h){if(typeof h=="string")return i(h,g);var b=Object.prototype.toString.call(h).slice(8,-1);if(b==="Object"&&h.constructor&&(b=h.constructor.name),b==="Map"||b==="Set")return Array.from(h);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return i(h,g)}}(_)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
23
|
+
`);for(var _e=0;_e<he.length;_e++)if(!/^[\s\xa0]*$/.test(he[_e])){var Ee=T(he[_e]),De=Ee[0];if(typeof(Ee=Ee[1])=="string"){Ee=Ee.trim();var Le=we[De]||[];we[De]=Le,Le.push(Ee)}}return function(We,ze){var He,Ne={};for(He in We)Ne[He]=ze.call(void 0,We[He],He,We);return Ne}(we,function(We){return We.join(", ")})}(Z.a);if(Object.keys(me).forEach(function(he){ln.includes(he)||(ge[he]=me[he])}),function(he,we){for(var _e=0;_e<he.g.length;_e++)he.g[_e](we)}(Z,ge),te!=0){switch(te){case 7:var ue=10;break;case 8:ue=4;break;case 6:ue=function(he){switch(he){case 200:return 0;case 400:return 3;case 401:return 16;case 403:return 7;case 404:return 5;case 409:return 10;case 412:return 9;case 429:return 8;case 499:return 1;case 500:return 2;case 501:return 12;case 503:return 14;case 504:return 4;default:return 2}}(Z.a.getStatus());break;default:ue=14}ue==10&&Z.j||St(Z,{code:ue,message:m(te),metadata:{}})}else te=!1,"grpc-status"in me&&(ue=qt(Z.a,"grpc-status"),"grpc-message"in me&&(ae=qt(Z.a,"grpc-message")),Number(ue)!=0&&(St(Z,{code:Number(ue),message:ae,metadata:me}),te=!0)),te||function(he){for(var we=0;we<he.c.length;we++)he.c[we]()}(Z)})}function Ct(x,Z){-1<(Z=x.indexOf(Z))&&x.splice(Z,1)}function St(x,Z){if(Z.code!=0)for(var te={code:Z.code,message:decodeURIComponent(Z.message||""),metadata:Z.metadata},ae=0;ae<x.f.length;ae++)x.f[ae](te);for(Z={code:Z.code,details:decodeURIComponent(Z.message||""),metadata:Z.metadata},te=0;te<x.h.length;te++)x.h[te](Z)}function rt(x){this.a=E("format",x)||"text",this.f=E("suppressCorsPreflight",x)||!1,this.c=E("withCredentials",x)||!1,this.b=E("streamInterceptors",x)||[],this.g=E("unaryInterceptors",x)||[]}function Dt(x,Z,te){var ae=Z.getMethodDescriptor(),ge=te+ae.name;(te=new pt).H=x.c;var me=new ft({T:te});if(me.l=ae.b,Wt(te.headers,Z.getMetadata()),x.a=="text"?(te.headers.set("Content-Type","application/grpc-web-text"),te.headers.set("Accept","application/grpc-web-text")):te.headers.set("Content-Type","application/grpc-web+proto"),te.headers.set("X-User-Agent","grpc-web-javascript/0.1"),te.headers.set("X-Grpc-Web","1"),wt(te.headers.b,"deadline")){var ue=te.headers.get("deadline");ue=Math.round(ue-new Date().getTime());var he=te.headers;wt(he.b,"deadline")&&(delete he.b.deadline,he.c--,he.a.length>2*he.c&&Lt(he)),1/0===ue&&(ue=0),0<ue&&te.headers.set("grpc-timeout",ue+"m")}if(x.f){Lt(he=te.headers),ue={};for(var we=0;we<he.a.length;we++){var _e=he.a[we];ue[_e]=he.b[_e]}(he=te.headers).b={},he.a.length=0,he.c=0;e:{for(Ee in ue){var Ee=!1;break e}Ee=!0}Ee||(ue=function(We){var ze="";return function(He,Ne){for(var ht in He)Ne.call(void 0,He[ht],ht,He)}(We,function(He,Ne){ze+=Ne,ze+=":",ze+=He,ze+=`\r
|
|
24
|
+
`}),ze}(ue),typeof ge=="string"?(Ee=encodeURIComponent("$httpHeaders"),(Ee+=ue=ue!=null?"="+encodeURIComponent(String(ue)):"")&&(0>(ue=ge.indexOf("#"))&&(ue=ge.length),0>(he=ge.indexOf("?"))||he>ue?(he=ue,we=""):we=ge.substring(he+1,ue),ue=(ge=[ge.substr(0,he),we,ge.substr(ue)])[1],ge[1]=Ee?ue?ue+"&"+Ee:Ee:ue,ge=ge[0]+(ge[1]?"?"+ge[1]:"")+ge[2])):ge.a("$httpHeaders",ue))}for(ae=(Z=(0,ae.a)(Z.getRequestMessage())).length,Ee=[0,0,0,0],ue=new Uint8Array(5+ae),he=3;0<=he;he--)Ee[he]=ae%256,ae>>>=8;if(ue.set(new Uint8Array(Ee),1),ue.set(Z,5),Z=ue,x.a=="text"){var De;for(x=Z,De===void 0&&(De=0),Kt(),De=Yt[De],Z=[],ae=0;ae<x.length;ae+=3){_e=x[ae];var Le=(Ee=ae+1<x.length)?x[ae+1]:0;he=_e>>2,_e=(3&_e)<<4|Le>>4,Le=(15&Le)<<2|(we=(ue=ae+2<x.length)?x[ae+2]:0)>>6,we&=63,ue||(we=64,Ee||(Le=64)),Z.push(De[he],De[_e],De[Le]||"",De[we]||"")}Z=Z.join("")}else x.a=="binary"&&(te.j="arraybuffer");return rn(te,ge,Z),me}function Xt(x,Z,te){var ae=null,ge=!1;x.on("data",function(me){ae=me}),x.on("error",function(me){me.code==0||ge||(ge=!0,Z(me,null))}),x.on("status",function(me){me.code==0||ge?te&&Z(null,null,me):(ge=!0,Z({code:me.code,message:me.details,metadata:me.metadata},null))}),te&&x.on("metadata",function(me){Z(null,null,null,me)}),x.on("end",function(){ge||(ae==null?Z({code:2,message:"Incomplete response"}):Z(null,ae)),te&&Z(null,null)})}function kt(x,Z){var te=x;return Z.forEach(function(ae){var ge=te;te=function(me){return ae.intercept(me,ge)}}),te}ft.prototype.on=function(x,Z){return x=="data"?this.b.push(Z):x=="status"?this.h.push(Z):x=="metadata"?this.g.push(Z):x=="end"?this.c.push(Z):x=="error"&&this.f.push(Z),this},ft.prototype.removeListener=function(x,Z){return x=="data"?Ct(this.b,Z):x=="status"?Ct(this.h,Z):x=="metadata"?Ct(this.g,Z):x=="end"?Ct(this.c,Z):x=="error"&&Ct(this.f,Z),this},ft.prototype.cancel=function(){this.j=!0,this.a.abort()},ft.prototype.cancel=ft.prototype.cancel,ft.prototype.removeListener=ft.prototype.removeListener,ft.prototype.on=ft.prototype.on,rt.prototype.P=function(x,Z,te,ae,ge){var me=this;ae=q(x,Z,"unary",ae);var ue=x.substr(0,x.length-ae.name.length);return Xt(x=kt(function(he){return Dt(me,he,ue)},this.b).call(this,$(ae,Z,te)),ge,!1),new y(x)},rt.prototype.M=function(x,Z,te,ae){var ge=this;ae=q(x,Z,"unary",ae);var me=x.substr(0,x.length-ae.name.length);return kt(function(ue){return new Promise(function(he,we){var _e,Ee,De;Xt(Dt(ge,ue,me),function(Le,We,ze,He){Le?we(Le):We?De=We:ze?Ee=ze:He?_e=He:(Le=ue.getMethodDescriptor(),he(new d(De,Le,We=(We=_e)===void 0?{}:We,Ee===void 0?null:Ee)))},!0)})},this.g).call(this,$(ae,Z,te)).then(function(ue){return ue.getResponseMessage()})},rt.prototype.unaryCall=function(x,Z,te,ae){return this.M(x,Z,te,ae)},rt.prototype.R=function(x,Z,te,ae){var ge=this;ae=q(x,Z,"server_streaming",ae);var me=x.substr(0,x.length-ae.name.length);return kt(function(ue){return Dt(ge,ue,me)},this.b).call(this,$(ae,Z,te))},rt.prototype.serverStreaming=rt.prototype.R,rt.prototype.unaryCall=rt.prototype.unaryCall,rt.prototype.thenableCall=rt.prototype.M,rt.prototype.rpcCall=rt.prototype.P,e.exports.AbstractClientBase={MethodInfo:function(x,Z,te,ae,ge){this.name=ae,this.b=ge,this.f=x,this.a=Z,this.c=te}},e.exports.GrpcWebClientBase=rt,e.exports.StatusCode={OK:0,CANCELLED:1,UNKNOWN:2,INVALID_ARGUMENT:3,DEADLINE_EXCEEDED:4,NOT_FOUND:5,ALREADY_EXISTS:6,PERMISSION_DENIED:7,UNAUTHENTICATED:16,RESOURCE_EXHAUSTED:8,FAILED_PRECONDITION:9,ABORTED:10,OUT_OF_RANGE:11,UNIMPLEMENTED:12,INTERNAL:13,UNAVAILABLE:14,DATA_LOSS:15},e.exports.MethodDescriptor=I,e.exports.MethodType={UNARY:"unary",SERVER_STREAMING:"server_streaming"}}).call(this,n(6))},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.isAsyncIterable=t.isAsyncGenerator=t.isAsync=void 0;var r,i=n(152),s=(r=i)&&r.__esModule?r:{default:r};function l(o){return o[Symbol.toStringTag]==="AsyncFunction"}t.default=function(o){if(typeof o!="function")throw new Error("expected a function");return l(o)?(0,s.default)(o):o},t.isAsync=l,t.isAsyncGenerator=function(o){return o[Symbol.toStringTag]==="AsyncGenerator"},t.isAsyncIterable=function(o){return typeof o[Symbol.asyncIterator]=="function"}},function(e,t,n){var r={};function i(l,o,c){c||(c=Error);var u=function(f){var E,_;function h(g,b,A){return f.call(this,function(j,F,M){return typeof o=="string"?o:o(j,F,M)}(g,b,A))||this}return _=f,(E=h).prototype=Object.create(_.prototype),E.prototype.constructor=E,E.__proto__=_,h}(c);u.prototype.name=c.name,u.prototype.code=l,r[l]=u}function s(l,o){if(Array.isArray(l)){var c=l.length;return l=l.map(function(u){return String(u)}),c>2?"one of ".concat(o," ").concat(l.slice(0,c-1).join(", "),", or ")+l[c-1]:c===2?"one of ".concat(o," ").concat(l[0]," or ").concat(l[1]):"of ".concat(o," ").concat(l[0])}return"of ".concat(o," ").concat(String(l))}i("ERR_INVALID_OPT_VALUE",function(l,o){return'The value "'+o+'" is invalid for option "'+l+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(l,o,c){var u,f,E;if(typeof o=="string"&&(f="not ",o.substr(0,f.length)===f)?(u="must not be",o=o.replace(/^not /,"")):u="must be",function(h,g,b){return(b===void 0||b>h.length)&&(b=h.length),h.substring(b-g.length,b)===g}(l," argument"))E="The ".concat(l," ").concat(u," ").concat(s(o,"type"));else{var _=function(h,g,b){return typeof b!="number"&&(b=0),!(b+g.length>h.length)&&h.indexOf(g,b)!==-1}(l,".")?"property":"argument";E='The "'.concat(l,'" ').concat(_," ").concat(u," ").concat(s(o,"type"))}return E+=". Received type ".concat(typeof c)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(l){return"The "+l+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(l){return"Cannot call "+l+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(l){return"Unknown encoding: "+l},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=r},function(e,t,n){(function(r){var i=Object.keys||function(h){var g=[];for(var b in h)g.push(b);return g};e.exports=f;var s=n(77),l=n(81);n(7)(f,s);for(var o=i(l.prototype),c=0;c<o.length;c++){var u=o[c];f.prototype[u]||(f.prototype[u]=l.prototype[u])}function f(h){if(!(this instanceof f))return new f(h);s.call(this,h),l.call(this,h),this.allowHalfOpen=!0,h&&(h.readable===!1&&(this.readable=!1),h.writable===!1&&(this.writable=!1),h.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",E)))}function E(){this._writableState.ended||r.nextTick(_,this)}function _(h){h.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(h){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=h,this._writableState.destroyed=h)}})}).call(this,n(2))},function(e,t,n){n.d(t,"a",function(){return l});var r=n(40),i=n(4);const s={"app-id":["app-id must match formant/*"]};class l extends r.a{constructor(c,u={}){super(c,Object.assign({validateHeaders:f=>`${f.get("app-id")}`.startsWith("formant/")?{}:s},u)),this.endpoint=c}getHeaders(){return Object.assign(Object.assign({},l.headers),{"App-ID":`formant/${i.a}`,"App-Version":i.j})}}l.headers={}},function(e,t,n){n(227),e.exports={encode:r=>new TextEncoder().encode(r),decode:r=>new TextDecoder().decode(r)}},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r,i=r.length){if(!i)throw new Error("arity is undefined");return function(...s){return typeof s[i-1]=="function"?r.apply(this,s):new Promise((l,o)=>{s[i-1]=(c,...u)=>{if(c)return o(c);l(u.length>1?u:u[0])},r.apply(this,s)})}},e.exports=t.default},function(e,t,n){(t=e.exports=n(69)).Stream=t,t.Readable=t,t.Writable=n(48),t.Duplex=n(23),t.Transform=n(72),t.PassThrough=n(165)},function(e,t,n){(t=e.exports=n(77)).Stream=t,t.Readable=t,t.Writable=n(81),t.Duplex=n(27),t.Transform=n(82),t.PassThrough=n(184),t.finished=n(49),t.pipeline=n(185)},function(e,t,n){e.exports=function(r){return r}},function(e,t,n){n.d(t,"a",function(){return i});const r=["password","secret","token","key","buffer"];function i(s,l=new Set){return l.has(s)?"[ RECURSIVE ]":!(o=s)||typeof o!="object"&&typeof o!="function"?s:(l.add(s),Object.keys(s).reduce((c,u)=>(c[u]=r.some(f=>u.toLowerCase().includes(f.toLowerCase()))?"[ REDACTED ]":i(s[u],l),c),{}));var o}},function(e,t){e.exports=r,r.default=r,r.stable=s,r.stableStringify=s;var n=[];function r(l,o,c){(function E(_,h,g,b){var A;if(typeof _=="object"&&_!==null){for(A=0;A<g.length;A++)if(g[A]===_)return b[h]="[Circular]",void n.push([b,h,_]);if(g.push(_),Array.isArray(_))for(A=0;A<_.length;A++)E(_[A],A,g,_);else{var j=Object.keys(_);for(A=0;A<j.length;A++){var F=j[A];E(_[F],F,g,_)}}g.pop()}})(l,"",[],void 0);for(var u=JSON.stringify(l,o,c);n.length!==0;){var f=n.pop();f[0][f[1]]=f[2]}return u}function i(l,o){return l<o?-1:l>o?1:0}function s(l,o,c){for(var u=function _(h,g,b,A){var j;if(typeof h=="object"&&h!==null){for(j=0;j<b.length;j++)if(b[j]===h)return A[g]="[Circular]",void n.push([A,g,h]);if(typeof h.toJSON=="function")return;if(b.push(h),Array.isArray(h))for(j=0;j<h.length;j++)_(h[j],j,b,h);else{var F={},M=Object.keys(h).sort(i);for(j=0;j<M.length;j++){var R=M[j];_(h[R],R,b,h),F[R]=h[R]}if(A===void 0)return F;n.push([A,g,h]),A[g]=F}b.pop()}}(l,"",[],void 0)||l,f=JSON.stringify(u,o,c);n.length!==0;){var E=n.pop();E[0][E[1]]=E[2]}return f}},function(e,t,n){var r=n(16),i=Object.keys||function(g){var b=[];for(var A in g)b.push(A);return b};e.exports=E;var s=Object.create(n(17));s.inherits=n(7);var l=n(143),o=n(62);s.inherits(E,l);for(var c=i(o.prototype),u=0;u<c.length;u++){var f=c[u];E.prototype[f]||(E.prototype[f]=o.prototype[f])}function E(g){if(!(this instanceof E))return new E(g);l.call(this,g),o.call(this,g),g&&g.readable===!1&&(this.readable=!1),g&&g.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,g&&g.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",_)}function _(){this.allowHalfOpen||this._writableState.ended||r.nextTick(h,this)}function h(g){g.end()}Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(E.prototype,"destroyed",{get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(g){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=g,this._writableState.destroyed=g)}}),E.prototype._destroy=function(g,b){this.push(null),this.end(),r.nextTick(b,g)}},function(e,t,n){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function i(o,c){return Object.prototype.hasOwnProperty.call(o,c)}t.assign=function(o){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var f in u)i(u,f)&&(o[f]=u[f])}}return o},t.shrinkBuf=function(o,c){return o.length===c?o:o.subarray?o.subarray(0,c):(o.length=c,o)};var s={arraySet:function(o,c,u,f,E){if(c.subarray&&o.subarray)o.set(c.subarray(u,u+f),E);else for(var _=0;_<f;_++)o[E+_]=c[u+_]},flattenChunks:function(o){var c,u,f,E,_,h;for(f=0,c=0,u=o.length;c<u;c++)f+=o[c].length;for(h=new Uint8Array(f),E=0,c=0,u=o.length;c<u;c++)_=o[c],h.set(_,E),E+=_.length;return h}},l={arraySet:function(o,c,u,f,E){for(var _=0;_<f;_++)o[E+_]=c[u+_]},flattenChunks:function(o){return[].concat.apply([],o)}};t.setTyped=function(o){o?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,s)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,l))},t.setTyped(r)},function(e,t,n){e.exports=n(186)},function(e,t,n){n.d(t,"a",function(){return i});var r=n(229);const i=Object(r.a)()},function(e,t,n){n.d(t,"a",function(){return j});var r=n(1),i=n(100),s=n.n(i),l=n(101),o=n.n(l);class c extends Error{constructor(M,R,d){super(`Connection failure: ${M.message}`),this.cause=M,this.url=R,this.retryable=d}}var u=n(10);class f extends Error{constructor(M,R){super(`Invalid headers (${JSON.stringify(M)}) for response: ${R.message}`),this.validationErrors=M,this.responseError=R}}var E=n(8),_=n(0),h=n(11),g=function(F,M,R,d){return new(R||(R=Promise))(function(I,$){function q(C){try{m(d.next(C))}catch(w){$(w)}}function y(C){try{m(d.throw(C))}catch(w){$(w)}}function m(C){var w;C.done?I(C.value):(w=C.value,w instanceof R?w:new R(function(L){L(w)})).then(q,y)}m((d=d.apply(F,M||[])).next())})},b=function(F,M){var R={};for(var d in F)Object.prototype.hasOwnProperty.call(F,d)&&M.indexOf(d)<0&&(R[d]=F[d]);if(F!=null&&typeof Object.getOwnPropertySymbols=="function"){var I=0;for(d=Object.getOwnPropertySymbols(F);I<d.length;I++)M.indexOf(d[I])<0&&Object.prototype.propertyIsEnumerable.call(F,d[I])&&(R[d[I]]=F[d[I]])}return R};const A=new Set(["GET","HEAD","PUT","QUERY","DELETE","OPTIONS","TRACE"]);class j{constructor(M,R={}){if(this.endpoint=M,this.validateHeaders=d=>R.validateHeaders?R.validateHeaders(d):{},this.verbose=R.verbose!==!1,R.retries!==void 0&&!(R.retries>=0))throw new Error("retries must be positive or zero");if(this.configuredRetries=R.retries,R.timeoutMs!==void 0&&!(R.timeoutMs>0))throw new Error("timeoutMs must be positive");if(this.timeoutMs=R.timeoutMs,R.maxBackoffDelayMs!==void 0&&!(R.maxBackoffDelayMs>0))throw new Error("maxBackoffDelayMs must be positive");this.maxBackoffDelayMs=R.maxBackoffDelayMs||30*r.a.second}getRetries(){return this.configuredRetries!==void 0?this.configuredRetries:this.getConstructor().retries}getHeaders(){return{}}fetch(M,R={}){return g(this,void 0,void 0,function*(){return(yield this.fetchVerbose(M,R)).body})}fetchVerbose(M,R={}){return g(this,void 0,void 0,function*(){let d=100*r.a.millisecond,I=0;const $=this.timeoutMs!==void 0?new Date().getTime()+this.timeoutMs:void 0,q=$?()=>Math.max($-new Date().getTime(),0):void 0;for(;;)try{return yield this.doFetch(M,R,q)}catch(y){const m=y,C=Object(h.a)(m,c);if((q==null?void 0:q())===0||I===this.getRetries()||!C.retryable)throw C;I++,d=Math.min(...q?[q()]:[],d*(2+.1*(Math.random()-.5)),this.maxBackoffDelayMs),yield Object(E.a)(d),this.verbose&&_.a.warn(`Connection failure, retrying. Error: ${m.cause.message}`,{url:m.url,error:m.cause,attempt:I})}})}doFetch(M,R,d){return g(this,void 0,void 0,function*(){const{token:I,json:$,allowUnsafeRetries:q}=R,y=b(R,["token","json","allowUnsafeRetries"]),m=(y.method||"GET").toUpperCase(),C=this.endpoint!==void 0?`${this.endpoint}${M?`/${M}`:""}`:M,w=new s.a;let L;if(d){const W=d();W>0?L=setTimeout(()=>{w.abort()},W):w.abort()}try{let W;yield Promise.race([this.getConstructor().waitForConnectivity(),new Promise(U=>{W=setTimeout(U,d?Math.min(r.a.minute,d()):r.a.minute)})]),W&&clearTimeout(W);const k=yield o()(C,Object.assign(Object.assign({},y),{headers:Object.assign(Object.assign(Object.assign(Object.assign({},$!==!1?{"Content-Type":"application/json"}:{}),this.getHeaders()),y.headers||{}),I!==void 0?{Authorization:`Bearer ${I}`}:{}),signal:w.signal})),N=k.headers.get("content-type")||"",P=N&&N.startsWith("application/json"),z=P?yield k.json():yield k.text(),O=()=>new u.a(m,C,k.status,z,z&&z.validationErrors||{},k.headers);if(!k.ok)throw this.verbose&&_.a[k.status>=500?"warn":"info"]("Response error",{method:m,url:C,statusCode:k.status}),O();const p=this.validateHeaders(k.headers);if(Object.keys(p).length!==0)throw new f(p,O());if(k.status===204)return{body:void 0,headers:k.headers};if($&&!P)throw new Error(`Response is not JSON: ${JSON.stringify(z)}`);return{body:z,headers:k.headers}}catch(W){const k=W,N=q||A.has(m);if(k.message==="Network request failed")throw new c(k,C,N);if(k.type==="system"&&["EAI_AGAIN","ECONNREFUSED","EHOSTUNREACH","ENOTFOUND"].find(p=>p===k.code))throw new c(k,C,!0);if(k.type==="system"&&["ETIMEDOUT","ECONNRESET","ESOCKETTIMEDOUT","EPIPE"].find(p=>p===k.code))throw new c(k,C,N);if(k.name==="AbortError")throw new c(k,C,N);const P=Object(h.a)(k,u.a),{statusCode:z}=P;if(z===408||z===429||z===502||z===503||z===504)throw this.verbose&&!N&&_.a.warn("Potentially unsafe retry"),new c(k,C,!0);const O=this.validateHeaders(P.headers);throw Object.keys(O).length!==0?new f(O,P):(yield this.getConstructor().onResponseError(P),k)}finally{L&&clearTimeout(L)}})}getConstructor(){return Object.getPrototypeOf(this).constructor}}j.retries=8,j.waitForConnectivity=()=>g(void 0,void 0,void 0,function*(){}),j.onResponseError=()=>g(void 0,void 0,void 0,function*(){})},function(e,t,n){function r(E,_){if(!(E instanceof _))throw new TypeError("Cannot call a class as a function")}function i(E,_){for(var h=0;h<_.length;h++){var g=_[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(E,g.key,g)}}var s=n(59),l=n(3),o=l.LEVEL,c=l.MESSAGE;s.enabled=!0;var u=/\s+/,f=function(){function E(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};r(this,E),b.colors&&this.addColors(b.colors),this.options=b}var _,h,g;return _=E,g=[{key:"addColors",value:function(b){var A=Object.keys(b).reduce(function(j,F){return j[F]=u.test(b[F])?b[F].split(u):b[F],j},{});return E.allColors=Object.assign({},E.allColors||{},A),E.allColors}}],(h=[{key:"addColors",value:function(b){return E.addColors(b)}},{key:"colorize",value:function(b,A,j){if(j===void 0&&(j=A),!Array.isArray(E.allColors[b]))return s[E.allColors[b]](j);for(var F=0,M=E.allColors[b].length;F<M;F++)j=s[E.allColors[b][F]](j);return j}},{key:"transform",value:function(b,A){return A.all&&typeof b[c]=="string"&&(b[c]=this.colorize(b[o],b.level,b[c])),(A.level||A.all||!A.message)&&(b.level=this.colorize(b[o],b.level)),(A.all||A.message)&&(b.message=this.colorize(b[o],b.level,b.message)),b}}])&&i(_.prototype,h),g&&i(_,g),E}();e.exports=function(E){return new f(E)},e.exports.Colorizer=e.exports.Format=f},function(e,t){var n={}.toString;e.exports=Array.isArray||function(r){return n.call(r)=="[object Array]"}},function(e,t,n){(function(r){function i(s){try{if(!r.localStorage)return!1}catch{return!1}var l=r.localStorage[s];return l!=null&&String(l).toLowerCase()==="true"}e.exports=function(s,l){if(i("noDeprecation"))return s;var o=!1;return function(){if(!o){if(i("throwDeprecation"))throw new Error(l);i("traceDeprecation")?console.trace(l):console.warn(l),o=!0}return s.apply(this,arguments)}}}).call(this,n(6))},function(e,t,n){var r=n(5),i=r.Buffer;function s(o,c){for(var u in o)c[u]=o[u]}function l(o,c,u){return i(o,c,u)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=l),s(i,l),l.from=function(o,c,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return i(o,c,u)},l.alloc=function(o,c,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=i(o);return c!==void 0?typeof u=="string"?f.fill(c,u):f.fill(c):f.fill(0),f},l.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return i(o)},l.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return r&&typeof r.length=="number"&&r.length>=0&&r.length%1==0},e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default={},e.exports=t.default},function(e,t,n){var r=n(5),i=r.Buffer;function s(o,c){for(var u in o)c[u]=o[u]}function l(o,c,u){return i(o,c,u)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=l),s(i,l),l.from=function(o,c,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return i(o,c,u)},l.alloc=function(o,c,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=i(o);return c!==void 0?typeof u=="string"?f.fill(c,u):f.fill(c):f.fill(0),f},l.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return i(o)},l.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}},function(e,t,n){(function(r,i,s){var l=n(16);function o(m){var C=this;this.next=null,this.entry=null,this.finish=function(){(function(w,L,W){var k=w.entry;for(w.entry=null;k;){var N=k.callback;L.pendingcb--,N(W),k=k.next}L.corkedRequestsFree?L.corkedRequestsFree.next=w:L.corkedRequestsFree=w})(C,m)}}e.exports=M;var c,u=!r.browser&&["v0.10","v0.9."].indexOf(r.version.slice(0,5))>-1?i:l.nextTick;M.WritableState=F;var f=n(17);f.inherits=n(7);var E={deprecate:n(43)},_=n(70),h=n(47).Buffer,g=s.Uint8Array||function(){},b,A=n(71);function j(){}function F(m,C){c=c||n(23),m=m||{};var w=C instanceof c;this.objectMode=!!m.objectMode,w&&(this.objectMode=this.objectMode||!!m.writableObjectMode);var L=m.highWaterMark,W=m.writableHighWaterMark,k=this.objectMode?16:16384;this.highWaterMark=L||L===0?L:w&&(W||W===0)?W:k,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var N=m.decodeStrings===!1;this.decodeStrings=!N,this.defaultEncoding=m.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(P){(function(z,O){var p=z._writableState,U=p.sync,V=p.writecb;if(function(ee){ee.writing=!1,ee.writecb=null,ee.length-=ee.writelen,ee.writelen=0}(p),O)(function(ee,ne,Y,G,S){--ne.pendingcb,Y?(l.nextTick(S,G),l.nextTick(y,ee,ne),ee._writableState.errorEmitted=!0,ee.emit("error",G)):(S(G),ee._writableState.errorEmitted=!0,ee.emit("error",G),y(ee,ne))})(z,p,U,O,V);else{var Q=$(p);Q||p.corked||p.bufferProcessing||!p.bufferedRequest||I(z,p),U?u(d,z,p,Q,V):d(z,p,Q,V)}})(C,P)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function M(m){if(c=c||n(23),!(b.call(M,this)||this instanceof c))return new M(m);this._writableState=new F(m,this),this.writable=!0,m&&(typeof m.write=="function"&&(this._write=m.write),typeof m.writev=="function"&&(this._writev=m.writev),typeof m.destroy=="function"&&(this._destroy=m.destroy),typeof m.final=="function"&&(this._final=m.final)),_.call(this)}function R(m,C,w,L,W,k,N){C.writelen=L,C.writecb=N,C.writing=!0,C.sync=!0,w?m._writev(W,C.onwrite):m._write(W,k,C.onwrite),C.sync=!1}function d(m,C,w,L){w||function(W,k){k.length===0&&k.needDrain&&(k.needDrain=!1,W.emit("drain"))}(m,C),C.pendingcb--,L(),y(m,C)}function I(m,C){C.bufferProcessing=!0;var w=C.bufferedRequest;if(m._writev&&w&&w.next){var L=C.bufferedRequestCount,W=new Array(L),k=C.corkedRequestsFree;k.entry=w;for(var N=0,P=!0;w;)W[N]=w,w.isBuf||(P=!1),w=w.next,N+=1;W.allBuffers=P,R(m,C,!0,C.length,W,"",k.finish),C.pendingcb++,C.lastBufferedRequest=null,k.next?(C.corkedRequestsFree=k.next,k.next=null):C.corkedRequestsFree=new o(C),C.bufferedRequestCount=0}else{for(;w;){var z=w.chunk,O=w.encoding,p=w.callback;if(R(m,C,!1,C.objectMode?1:z.length,z,O,p),w=w.next,C.bufferedRequestCount--,C.writing)break}w===null&&(C.lastBufferedRequest=null)}C.bufferedRequest=w,C.bufferProcessing=!1}function $(m){return m.ending&&m.length===0&&m.bufferedRequest===null&&!m.finished&&!m.writing}function q(m,C){m._final(function(w){C.pendingcb--,w&&m.emit("error",w),C.prefinished=!0,m.emit("prefinish"),y(m,C)})}function y(m,C){var w=$(C);return w&&(function(L,W){W.prefinished||W.finalCalled||(typeof L._final=="function"?(W.pendingcb++,W.finalCalled=!0,l.nextTick(q,L,W)):(W.prefinished=!0,L.emit("prefinish")))}(m,C),C.pendingcb===0&&(C.finished=!0,m.emit("finish"))),w}f.inherits(M,_),F.prototype.getBuffer=function(){for(var m=this.bufferedRequest,C=[];m;)C.push(m),m=m.next;return C},function(){try{Object.defineProperty(F.prototype,"buffer",{get:E.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}(),typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(b=Function.prototype[Symbol.hasInstance],Object.defineProperty(M,Symbol.hasInstance,{value:function(m){return!!b.call(this,m)||this===M&&m&&m._writableState instanceof F}})):b=function(m){return m instanceof this},M.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},M.prototype.write=function(m,C,w){var L,W=this._writableState,k=!1,N=!W.objectMode&&(L=m,h.isBuffer(L)||L instanceof g);return N&&!h.isBuffer(m)&&(m=function(P){return h.from(P)}(m)),typeof C=="function"&&(w=C,C=null),N?C="buffer":C||(C=W.defaultEncoding),typeof w!="function"&&(w=j),W.ended?function(P,z){var O=new Error("write after end");P.emit("error",O),l.nextTick(z,O)}(this,w):(N||function(P,z,O,p){var U=!0,V=!1;return O===null?V=new TypeError("May not write null values to stream"):typeof O=="string"||O===void 0||z.objectMode||(V=new TypeError("Invalid non-string/buffer chunk")),V&&(P.emit("error",V),l.nextTick(p,V),U=!1),U}(this,W,m,w))&&(W.pendingcb++,k=function(P,z,O,p,U,V){if(!O){var Q=function(G,S,T){return G.objectMode||G.decodeStrings===!1||typeof S!="string"||(S=h.from(S,T)),S}(z,p,U);p!==Q&&(O=!0,U="buffer",p=Q)}var ee=z.objectMode?1:p.length;z.length+=ee;var ne=z.length<z.highWaterMark;if(ne||(z.needDrain=!0),z.writing||z.corked){var Y=z.lastBufferedRequest;z.lastBufferedRequest={chunk:p,encoding:U,isBuf:O,callback:V,next:null},Y?Y.next=z.lastBufferedRequest:z.bufferedRequest=z.lastBufferedRequest,z.bufferedRequestCount+=1}else R(P,z,!1,ee,p,U,V);return ne}(this,W,N,m,C,w)),k},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){var m=this._writableState;m.corked&&(m.corked--,m.writing||m.corked||m.finished||m.bufferProcessing||!m.bufferedRequest||I(this,m))},M.prototype.setDefaultEncoding=function(m){if(typeof m=="string"&&(m=m.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((m+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+m);return this._writableState.defaultEncoding=m,this},Object.defineProperty(M.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),M.prototype._write=function(m,C,w){w(new Error("_write() is not implemented"))},M.prototype._writev=null,M.prototype.end=function(m,C,w){var L=this._writableState;typeof m=="function"?(w=m,m=null,C=null):typeof C=="function"&&(w=C,C=null),m!=null&&this.write(m,C),L.corked&&(L.corked=1,this.uncork()),L.ending||L.finished||function(W,k,N){k.ending=!0,y(W,k),N&&(k.finished?l.nextTick(N):W.once("finish",N)),k.ended=!0,W.writable=!1}(this,L,w)},Object.defineProperty(M.prototype,"destroyed",{get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(m){this._writableState&&(this._writableState.destroyed=m)}}),M.prototype.destroy=A.destroy,M.prototype._undestroy=A.undestroy,M.prototype._destroy=function(m,C){this.end(),C(m)}}).call(this,n(2),n(15).setImmediate,n(6))},function(e,t,n){var r=n(26).codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function s(l,o,c){if(typeof o=="function")return s(l,null,o);o||(o={}),c=function(M){var R=!1;return function(){if(!R){R=!0;for(var d=arguments.length,I=new Array(d),$=0;$<d;$++)I[$]=arguments[$];M.apply(this,I)}}}(c||i);var u=o.readable||o.readable!==!1&&l.readable,f=o.writable||o.writable!==!1&&l.writable,E=function(){l.writable||h()},_=l._writableState&&l._writableState.finished,h=function(){f=!1,_=!0,u||c.call(l)},g=l._readableState&&l._readableState.endEmitted,b=function(){u=!1,g=!0,f||c.call(l)},A=function(M){c.call(l,M)},j=function(){var M;return u&&!g?(l._readableState&&l._readableState.ended||(M=new r),c.call(l,M)):f&&!_?(l._writableState&&l._writableState.ended||(M=new r),c.call(l,M)):void 0},F=function(){l.req.on("finish",h)};return function(M){return M.setHeader&&typeof M.abort=="function"}(l)?(l.on("complete",h),l.on("abort",j),l.req?F():l.on("request",F)):f&&!l._writableState&&(l.on("end",E),l.on("close",E)),l.on("end",b),l.on("finish",h),o.error!==!1&&l.on("error",A),l.on("close",j),function(){l.removeListener("complete",h),l.removeListener("abort",j),l.removeListener("request",F),l.req&&l.req.removeListener("finish",h),l.removeListener("end",E),l.removeListener("close",E),l.removeListener("finish",h),l.removeListener("end",b),l.removeListener("error",A),l.removeListener("close",j)}}},function(e,t,n){var r=n(58),i=n(3).configs;t.cli=r.levels(i.cli),t.npm=r.levels(i.npm),t.syslog=r.levels(i.syslog),t.addColors=r.levels},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=o(n(203)),i=o(n(204)),s=o(n(25)),l=o(n(30));function o(c){return c&&c.__esModule?c:{default:c}}t.default=(0,l.default)(function(c,u,f){return(0,r.default)(c,(0,i.default)((0,s.default)(u)),f)},3),e.exports=t.default},function(e,t,n){class r extends Error{constructor(s,...l){super(`env-var: ${s}`,...l),Error.captureStackTrace&&Error.captureStackTrace(this,r),this.name="EnvVarError"}}e.exports=r},function(e,t,n){e.exports=function(r){const i=parseInt(r,10);if(isNaN(i)||i.toString(10)!==r)throw new Error("should be a valid integer");return i}},function(e,t,n){e.exports=function(r){const i=parseFloat(r);if(isNaN(i)||i.toString()!==r)throw new Error("should be a valid float");return i}},function(e,t,n){e.exports=function(r){try{return JSON.parse(r)}catch{throw new Error("should be valid (parseable) JSON")}}},function(e,t,n){(function(r){function i(o,c){for(var u=0,f=o.length-1;f>=0;f--){var E=o[f];E==="."?o.splice(f,1):E===".."?(o.splice(f,1),u++):u&&(o.splice(f,1),u--)}if(c)for(;u--;u)o.unshift("..");return o}function s(o,c){if(o.filter)return o.filter(c);for(var u=[],f=0;f<o.length;f++)c(o[f],f,o)&&u.push(o[f]);return u}t.resolve=function(){for(var o="",c=!1,u=arguments.length-1;u>=-1&&!c;u--){var f=u>=0?arguments[u]:r.cwd();if(typeof f!="string")throw new TypeError("Arguments to path.resolve must be strings");f&&(o=f+"/"+o,c=f.charAt(0)==="/")}return(c?"/":"")+(o=i(s(o.split("/"),function(E){return!!E}),!c).join("/"))||"."},t.normalize=function(o){var c=t.isAbsolute(o),u=l(o,-1)==="/";return(o=i(s(o.split("/"),function(f){return!!f}),!c).join("/"))||c||(o="."),o&&u&&(o+="/"),(c?"/":"")+o},t.isAbsolute=function(o){return o.charAt(0)==="/"},t.join=function(){var o=Array.prototype.slice.call(arguments,0);return t.normalize(s(o,function(c,u){if(typeof c!="string")throw new TypeError("Arguments to path.join must be strings");return c}).join("/"))},t.relative=function(o,c){function u(A){for(var j=0;j<A.length&&A[j]==="";j++);for(var F=A.length-1;F>=0&&A[F]==="";F--);return j>F?[]:A.slice(j,F-j+1)}o=t.resolve(o).substr(1),c=t.resolve(c).substr(1);for(var f=u(o.split("/")),E=u(c.split("/")),_=Math.min(f.length,E.length),h=_,g=0;g<_;g++)if(f[g]!==E[g]){h=g;break}var b=[];for(g=h;g<f.length;g++)b.push("..");return(b=b.concat(E.slice(h))).join("/")},t.sep="/",t.delimiter=":",t.dirname=function(o){if(typeof o!="string"&&(o+=""),o.length===0)return".";for(var c=o.charCodeAt(0),u=c===47,f=-1,E=!0,_=o.length-1;_>=1;--_)if((c=o.charCodeAt(_))===47){if(!E){f=_;break}}else E=!1;return f===-1?u?"/":".":u&&f===1?"/":o.slice(0,f)},t.basename=function(o,c){var u=function(f){typeof f!="string"&&(f+="");var E,_=0,h=-1,g=!0;for(E=f.length-1;E>=0;--E)if(f.charCodeAt(E)===47){if(!g){_=E+1;break}}else h===-1&&(g=!1,h=E+1);return h===-1?"":f.slice(_,h)}(o);return c&&u.substr(-1*c.length)===c&&(u=u.substr(0,u.length-c.length)),u},t.extname=function(o){typeof o!="string"&&(o+="");for(var c=-1,u=0,f=-1,E=!0,_=0,h=o.length-1;h>=0;--h){var g=o.charCodeAt(h);if(g!==47)f===-1&&(E=!1,f=h+1),g===46?c===-1?c=h:_!==1&&(_=1):c!==-1&&(_=-1);else if(!E){u=h+1;break}}return c===-1||f===-1||_===0||_===1&&c===f-1&&c===u+1?"":o.slice(c,f)};var l="ab".substr(-1)==="b"?function(o,c,u){return o.substr(c,u)}:function(o,c,u){return c<0&&(c=o.length+c),o.substr(c,u)}}).call(this,n(2))},,function(e,t,n){var r=t.format=n(12);t.levels=n(105),Object.defineProperty(r,"align",{value:n(122)}),Object.defineProperty(r,"cli",{value:n(123)}),Object.defineProperty(r,"combine",{value:n(124)}),Object.defineProperty(r,"colorize",{value:n(41)}),Object.defineProperty(r,"json",{value:n(125)}),Object.defineProperty(r,"label",{value:n(128)}),Object.defineProperty(r,"logstash",{value:n(129)}),Object.defineProperty(r,"metadata",{value:n(130)}),Object.defineProperty(r,"padLevels",{value:n(60)}),Object.defineProperty(r,"prettyPrint",{value:n(131)}),Object.defineProperty(r,"printf",{value:n(132)}),Object.defineProperty(r,"simple",{value:n(133)}),Object.defineProperty(r,"splat",{value:n(134)}),Object.defineProperty(r,"timestamp",{value:n(135)}),Object.defineProperty(r,"uncolorize",{value:n(137)})},function(e,t,n){var r=n(106);e.exports=r},function(e,t,n){function r(_){return function(h){if(Array.isArray(h))return i(h)}(_)||function(h){if(typeof Symbol<"u"&&Symbol.iterator in Object(h))return Array.from(h)}(_)||function(h,g){if(h){if(typeof h=="string")return i(h,g);var b=Object.prototype.toString.call(h).slice(8,-1);if(b==="Object"&&h.constructor&&(b=h.constructor.name),b==="Map"||b==="Set")return Array.from(h);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return i(h,g)}}(_)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
25
25
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function i(_,h){(h==null||h>_.length)&&(h=_.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=_[g];return b}function s(_,h){if(!(_ instanceof h))throw new TypeError("Cannot call a class as a function")}function l(_,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(_,b.key,b)}}var o=n(3),c=o.configs,u=o.LEVEL,f=o.MESSAGE,E=function(){function _(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{levels:c.npm.levels};s(this,_),this.paddings=_.paddingForLevels(A.levels,A.filler),this.options=A}var h,g,b;return h=_,b=[{key:"getLongestLevel",value:function(A){var j=Object.keys(A).map(function(F){return F.length});return Math.max.apply(Math,r(j))}},{key:"paddingForLevel",value:function(A,j,F){var M=F+1-A.length,R=Math.floor(M/j.length);return"".concat(j).concat(j.repeat(R)).slice(0,M)}},{key:"paddingForLevels",value:function(A){var j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:" ",F=_.getLongestLevel(A);return Object.keys(A).reduce(function(M,R){return M[R]=_.paddingForLevel(R,j,F),M},{})}}],(g=[{key:"transform",value:function(A,j){return A.message="".concat(this.paddings[A[u]]).concat(A.message),A[f]&&(A[f]="".concat(this.paddings[A[u]]).concat(A[f])),A}}])&&l(h.prototype,g),b&&l(h,b),_}();e.exports=function(_){return new E(_)},e.exports.Padder=e.exports.Format=E},function(e,t,n){var r=n(13).format;t.warn={deprecated:function(i){return function(){throw new Error(r("{ %s } was removed in winston@3.0.0.",i))}},useFormat:function(i){return function(){throw new Error([r("{ %s } was removed in winston@3.0.0.",i),"Use a custom winston.format = winston.format(function) instead."].join(`
|
|
26
26
|
`))}},forFunctions:function(i,s,l){l.forEach(function(o){i[o]=t.warn[s](o)})},moved:function(i,s,l){function o(){return function(){throw new Error([r("winston.%s was moved in winston@3.0.0.",l),r("Use a winston.%s instead.",s)].join(`
|
|
27
27
|
`))}}Object.defineProperty(i,l,{get:o,set:o})},forProperties:function(i,s,l){l.forEach(function(o){var c=t.warn[s](o);Object.defineProperty(i,o,{get:c,set:c})})}}},function(e,t,n){(function(r,i,s){var l=n(16);function o(m){var C=this;this.next=null,this.entry=null,this.finish=function(){(function(w,L,W){var k=w.entry;for(w.entry=null;k;){var N=k.callback;L.pendingcb--,N(W),k=k.next}L.corkedRequestsFree?L.corkedRequestsFree.next=w:L.corkedRequestsFree=w})(C,m)}}e.exports=M;var c,u=!r.browser&&["v0.10","v0.9."].indexOf(r.version.slice(0,5))>-1?i:l.nextTick;M.WritableState=F;var f=Object.create(n(17));f.inherits=n(7);var E={deprecate:n(43)},_=n(63),h=n(44).Buffer,g=s.Uint8Array||function(){},b,A=n(64);function j(){}function F(m,C){c=c||n(36),m=m||{};var w=C instanceof c;this.objectMode=!!m.objectMode,w&&(this.objectMode=this.objectMode||!!m.writableObjectMode);var L=m.highWaterMark,W=m.writableHighWaterMark,k=this.objectMode?16:16384;this.highWaterMark=L||L===0?L:w&&(W||W===0)?W:k,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var N=m.decodeStrings===!1;this.decodeStrings=!N,this.defaultEncoding=m.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(P){(function(z,O){var p=z._writableState,U=p.sync,V=p.writecb;if(function(ee){ee.writing=!1,ee.writecb=null,ee.length-=ee.writelen,ee.writelen=0}(p),O)(function(ee,ne,Y,G,S){--ne.pendingcb,Y?(l.nextTick(S,G),l.nextTick(y,ee,ne),ee._writableState.errorEmitted=!0,ee.emit("error",G)):(S(G),ee._writableState.errorEmitted=!0,ee.emit("error",G),y(ee,ne))})(z,p,U,O,V);else{var Q=$(p);Q||p.corked||p.bufferProcessing||!p.bufferedRequest||I(z,p),U?u(d,z,p,Q,V):d(z,p,Q,V)}})(C,P)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function M(m){if(c=c||n(36),!(b.call(M,this)||this instanceof c))return new M(m);this._writableState=new F(m,this),this.writable=!0,m&&(typeof m.write=="function"&&(this._write=m.write),typeof m.writev=="function"&&(this._writev=m.writev),typeof m.destroy=="function"&&(this._destroy=m.destroy),typeof m.final=="function"&&(this._final=m.final)),_.call(this)}function R(m,C,w,L,W,k,N){C.writelen=L,C.writecb=N,C.writing=!0,C.sync=!0,w?m._writev(W,C.onwrite):m._write(W,k,C.onwrite),C.sync=!1}function d(m,C,w,L){w||function(W,k){k.length===0&&k.needDrain&&(k.needDrain=!1,W.emit("drain"))}(m,C),C.pendingcb--,L(),y(m,C)}function I(m,C){C.bufferProcessing=!0;var w=C.bufferedRequest;if(m._writev&&w&&w.next){var L=C.bufferedRequestCount,W=new Array(L),k=C.corkedRequestsFree;k.entry=w;for(var N=0,P=!0;w;)W[N]=w,w.isBuf||(P=!1),w=w.next,N+=1;W.allBuffers=P,R(m,C,!0,C.length,W,"",k.finish),C.pendingcb++,C.lastBufferedRequest=null,k.next?(C.corkedRequestsFree=k.next,k.next=null):C.corkedRequestsFree=new o(C),C.bufferedRequestCount=0}else{for(;w;){var z=w.chunk,O=w.encoding,p=w.callback;if(R(m,C,!1,C.objectMode?1:z.length,z,O,p),w=w.next,C.bufferedRequestCount--,C.writing)break}w===null&&(C.lastBufferedRequest=null)}C.bufferedRequest=w,C.bufferProcessing=!1}function $(m){return m.ending&&m.length===0&&m.bufferedRequest===null&&!m.finished&&!m.writing}function q(m,C){m._final(function(w){C.pendingcb--,w&&m.emit("error",w),C.prefinished=!0,m.emit("prefinish"),y(m,C)})}function y(m,C){var w=$(C);return w&&(function(L,W){W.prefinished||W.finalCalled||(typeof L._final=="function"?(W.pendingcb++,W.finalCalled=!0,l.nextTick(q,L,W)):(W.prefinished=!0,L.emit("prefinish")))}(m,C),C.pendingcb===0&&(C.finished=!0,m.emit("finish"))),w}f.inherits(M,_),F.prototype.getBuffer=function(){for(var m=this.bufferedRequest,C=[];m;)C.push(m),m=m.next;return C},function(){try{Object.defineProperty(F.prototype,"buffer",{get:E.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}(),typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(b=Function.prototype[Symbol.hasInstance],Object.defineProperty(M,Symbol.hasInstance,{value:function(m){return!!b.call(this,m)||this===M&&m&&m._writableState instanceof F}})):b=function(m){return m instanceof this},M.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},M.prototype.write=function(m,C,w){var L,W=this._writableState,k=!1,N=!W.objectMode&&(L=m,h.isBuffer(L)||L instanceof g);return N&&!h.isBuffer(m)&&(m=function(P){return h.from(P)}(m)),typeof C=="function"&&(w=C,C=null),N?C="buffer":C||(C=W.defaultEncoding),typeof w!="function"&&(w=j),W.ended?function(P,z){var O=new Error("write after end");P.emit("error",O),l.nextTick(z,O)}(this,w):(N||function(P,z,O,p){var U=!0,V=!1;return O===null?V=new TypeError("May not write null values to stream"):typeof O=="string"||O===void 0||z.objectMode||(V=new TypeError("Invalid non-string/buffer chunk")),V&&(P.emit("error",V),l.nextTick(p,V),U=!1),U}(this,W,m,w))&&(W.pendingcb++,k=function(P,z,O,p,U,V){if(!O){var Q=function(G,S,T){return G.objectMode||G.decodeStrings===!1||typeof S!="string"||(S=h.from(S,T)),S}(z,p,U);p!==Q&&(O=!0,U="buffer",p=Q)}var ee=z.objectMode?1:p.length;z.length+=ee;var ne=z.length<z.highWaterMark;if(ne||(z.needDrain=!0),z.writing||z.corked){var Y=z.lastBufferedRequest;z.lastBufferedRequest={chunk:p,encoding:U,isBuf:O,callback:V,next:null},Y?Y.next=z.lastBufferedRequest:z.bufferedRequest=z.lastBufferedRequest,z.bufferedRequestCount+=1}else R(P,z,!1,ee,p,U,V);return ne}(this,W,N,m,C,w)),k},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){var m=this._writableState;m.corked&&(m.corked--,m.writing||m.corked||m.finished||m.bufferProcessing||!m.bufferedRequest||I(this,m))},M.prototype.setDefaultEncoding=function(m){if(typeof m=="string"&&(m=m.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((m+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+m);return this._writableState.defaultEncoding=m,this},Object.defineProperty(M.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),M.prototype._write=function(m,C,w){w(new Error("_write() is not implemented"))},M.prototype._writev=null,M.prototype.end=function(m,C,w){var L=this._writableState;typeof m=="function"?(w=m,m=null,C=null):typeof C=="function"&&(w=C,C=null),m!=null&&this.write(m,C),L.corked&&(L.corked=1,this.uncork()),L.ending||L.finished||function(W,k,N){k.ending=!0,y(W,k),N&&(k.finished?l.nextTick(N):W.once("finish",N)),k.ended=!0,W.writable=!1}(this,L,w)},Object.defineProperty(M.prototype,"destroyed",{get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(m){this._writableState&&(this._writableState.destroyed=m)}}),M.prototype.destroy=A.destroy,M.prototype._undestroy=A.undestroy,M.prototype._destroy=function(m,C){this.end(),C(m)}}).call(this,n(2),n(15).setImmediate,n(6))},function(e,t,n){e.exports=n(21).EventEmitter},function(e,t,n){var r=n(16);function i(s,l){s.emit("error",l)}e.exports={destroy:function(s,l){var o=this,c=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return c||u?(l?l(s):!s||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,s),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(s||null,function(f){!l&&f?(r.nextTick(i,o,f),o._writableState&&(o._writableState.errorEmitted=!0)):l&&l(f)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t){},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=l(n(156)),i=l(n(25)),s=l(n(30));function l(o){return o&&o.__esModule?o:{default:o}}t.default=(0,s.default)(function(o,c,u,f){return(0,r.default)(c)(o,(0,i.default)(u),f)},4),e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){function i(...s){if(r!==null){var l=r;r=null,l.apply(this,s)}}return Object.assign(i,r),i},e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return function(...i){if(r===null)throw new Error("Callback was already called.");var s=r;r=null,s.apply(this,i)}},e.exports=t.default},function(e,t,n){(function(r,i){var s=n(16);e.exports=R;var l,o=n(42);R.ReadableState=M,n(21).EventEmitter;var c=function(O,p){return O.listeners(p).length},u=n(70),f=n(47).Buffer,E=r.Uint8Array||function(){},_=n(17);_.inherits=n(7);var h=n(162),g=void 0;g=h&&h.debuglog?h.debuglog("stream"):function(){};var b,A=n(163),j=n(71);_.inherits(R,u);var F=["error","close","destroy","pause","resume"];function M(O,p){O=O||{};var U=p instanceof(l=l||n(23));this.objectMode=!!O.objectMode,U&&(this.objectMode=this.objectMode||!!O.readableObjectMode);var V=O.highWaterMark,Q=O.readableHighWaterMark,ee=this.objectMode?16:16384;this.highWaterMark=V||V===0?V:U&&(Q||Q===0)?Q:ee,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new A,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=O.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,O.encoding&&(b||(b=n(22).StringDecoder),this.decoder=new b(O.encoding),this.encoding=O.encoding)}function R(O){if(l=l||n(23),!(this instanceof R))return new R(O);this._readableState=new M(O,this),this.readable=!0,O&&(typeof O.read=="function"&&(this._read=O.read),typeof O.destroy=="function"&&(this._destroy=O.destroy)),u.call(this)}function d(O,p,U,V,Q){var ee,ne=O._readableState;return p===null?(ne.reading=!1,function(Y,G){if(!G.ended){if(G.decoder){var S=G.decoder.end();S&&S.length&&(G.buffer.push(S),G.length+=G.objectMode?1:S.length)}G.ended=!0,q(Y)}}(O,ne)):(Q||(ee=function(Y,G){var S;T=G,f.isBuffer(T)||T instanceof E||typeof G=="string"||G===void 0||Y.objectMode||(S=new TypeError("Invalid non-string/buffer chunk"));var T;return S}(ne,p)),ee?O.emit("error",ee):ne.objectMode||p&&p.length>0?(typeof p=="string"||ne.objectMode||Object.getPrototypeOf(p)===f.prototype||(p=function(Y){return f.from(Y)}(p)),V?ne.endEmitted?O.emit("error",new Error("stream.unshift() after end event")):I(O,ne,p,!0):ne.ended?O.emit("error",new Error("stream.push() after EOF")):(ne.reading=!1,ne.decoder&&!U?(p=ne.decoder.write(p),ne.objectMode||p.length!==0?I(O,ne,p,!1):m(O,ne)):I(O,ne,p,!1))):V||(ne.reading=!1)),function(Y){return!Y.ended&&(Y.needReadable||Y.length<Y.highWaterMark||Y.length===0)}(ne)}function I(O,p,U,V){p.flowing&&p.length===0&&!p.sync?(O.emit("data",U),O.read(0)):(p.length+=p.objectMode?1:U.length,V?p.buffer.unshift(U):p.buffer.push(U),p.needReadable&&q(O)),m(O,p)}Object.defineProperty(R.prototype,"destroyed",{get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(O){this._readableState&&(this._readableState.destroyed=O)}}),R.prototype.destroy=j.destroy,R.prototype._undestroy=j.undestroy,R.prototype._destroy=function(O,p){this.push(null),p(O)},R.prototype.push=function(O,p){var U,V=this._readableState;return V.objectMode?U=!0:typeof O=="string"&&((p=p||V.defaultEncoding)!==V.encoding&&(O=f.from(O,p),p=""),U=!0),d(this,O,p,!1,U)},R.prototype.unshift=function(O){return d(this,O,null,!0,!1)},R.prototype.isPaused=function(){return this._readableState.flowing===!1},R.prototype.setEncoding=function(O){return b||(b=n(22).StringDecoder),this._readableState.decoder=new b(O),this._readableState.encoding=O,this};function $(O,p){return O<=0||p.length===0&&p.ended?0:p.objectMode?1:O!=O?p.flowing&&p.length?p.buffer.head.data.length:p.length:(O>p.highWaterMark&&(p.highWaterMark=function(U){return U>=8388608?U=8388608:(U--,U|=U>>>1,U|=U>>>2,U|=U>>>4,U|=U>>>8,U|=U>>>16,U++),U}(O)),O<=p.length?O:p.ended?p.length:(p.needReadable=!0,0))}function q(O){var p=O._readableState;p.needReadable=!1,p.emittedReadable||(g("emitReadable",p.flowing),p.emittedReadable=!0,p.sync?s.nextTick(y,O):y(O))}function y(O){g("emit readable"),O.emit("readable"),W(O)}function m(O,p){p.readingMore||(p.readingMore=!0,s.nextTick(C,O,p))}function C(O,p){for(var U=p.length;!p.reading&&!p.flowing&&!p.ended&&p.length<p.highWaterMark&&(g("maybeReadMore read 0"),O.read(0),U!==p.length);)U=p.length;p.readingMore=!1}function w(O){g("readable nexttick read 0"),O.read(0)}function L(O,p){p.reading||(g("resume read 0"),O.read(0)),p.resumeScheduled=!1,p.awaitDrain=0,O.emit("resume"),W(O),p.flowing&&!p.reading&&O.read(0)}function W(O){var p=O._readableState;for(g("flow",p.flowing);p.flowing&&O.read()!==null;);}function k(O,p){return p.length===0?null:(p.objectMode?U=p.buffer.shift():!O||O>=p.length?(U=p.decoder?p.buffer.join(""):p.buffer.length===1?p.buffer.head.data:p.buffer.concat(p.length),p.buffer.clear()):U=function(V,Q,ee){var ne;return V<Q.head.data.length?(ne=Q.head.data.slice(0,V),Q.head.data=Q.head.data.slice(V)):ne=V===Q.head.data.length?Q.shift():ee?function(Y,G){var S=G.head,T=1,B=S.data;for(Y-=B.length;S=S.next;){var J=S.data,K=Y>J.length?J.length:Y;if(K===J.length?B+=J:B+=J.slice(0,Y),(Y-=K)===0){K===J.length?(++T,S.next?G.head=S.next:G.head=G.tail=null):(G.head=S,S.data=J.slice(K));break}++T}return G.length-=T,B}(V,Q):function(Y,G){var S=f.allocUnsafe(Y),T=G.head,B=1;for(T.data.copy(S),Y-=T.data.length;T=T.next;){var J=T.data,K=Y>J.length?J.length:Y;if(J.copy(S,S.length-Y,0,K),(Y-=K)===0){K===J.length?(++B,T.next?G.head=T.next:G.head=G.tail=null):(G.head=T,T.data=J.slice(K));break}++B}return G.length-=B,S}(V,Q),ne}(O,p.buffer,p.decoder),U);var U}function N(O){var p=O._readableState;if(p.length>0)throw new Error('"endReadable()" called on non-empty stream');p.endEmitted||(p.ended=!0,s.nextTick(P,p,O))}function P(O,p){O.endEmitted||O.length!==0||(O.endEmitted=!0,p.readable=!1,p.emit("end"))}function z(O,p){for(var U=0,V=O.length;U<V;U++)if(O[U]===p)return U;return-1}R.prototype.read=function(O){g("read",O),O=parseInt(O,10);var p=this._readableState,U=O;if(O!==0&&(p.emittedReadable=!1),O===0&&p.needReadable&&(p.length>=p.highWaterMark||p.ended))return g("read: emitReadable",p.length,p.ended),p.length===0&&p.ended?N(this):q(this),null;if((O=$(O,p))===0&&p.ended)return p.length===0&&N(this),null;var V,Q=p.needReadable;return g("need readable",Q),(p.length===0||p.length-O<p.highWaterMark)&&g("length less than watermark",Q=!0),p.ended||p.reading?g("reading or ended",Q=!1):Q&&(g("do read"),p.reading=!0,p.sync=!0,p.length===0&&(p.needReadable=!0),this._read(p.highWaterMark),p.sync=!1,p.reading||(O=$(U,p))),(V=O>0?k(O,p):null)===null?(p.needReadable=!0,O=0):p.length-=O,p.length===0&&(p.ended||(p.needReadable=!0),U!==O&&p.ended&&N(this)),V!==null&&this.emit("data",V),V},R.prototype._read=function(O){this.emit("error",new Error("_read() is not implemented"))},R.prototype.pipe=function(O,p){var U=this,V=this._readableState;switch(V.pipesCount){case 0:V.pipes=O;break;case 1:V.pipes=[V.pipes,O];break;default:V.pipes.push(O)}V.pipesCount+=1,g("pipe count=%d opts=%j",V.pipesCount,p);var Q=(!p||p.end!==!1)&&O!==i.stdout&&O!==i.stderr?ne:re;function ee(se,fe){g("onunpipe"),se===U&&fe&&fe.hasUnpiped===!1&&(fe.hasUnpiped=!0,g("cleanup"),O.removeListener("close",J),O.removeListener("finish",K),O.removeListener("drain",Y),O.removeListener("error",B),O.removeListener("unpipe",ee),U.removeListener("end",ne),U.removeListener("end",re),U.removeListener("data",T),G=!0,!V.awaitDrain||O._writableState&&!O._writableState.needDrain||Y())}function ne(){g("onend"),O.end()}V.endEmitted?s.nextTick(Q):U.once("end",Q),O.on("unpipe",ee);var Y=function(se){return function(){var fe=se._readableState;g("pipeOnDrain",fe.awaitDrain),fe.awaitDrain&&fe.awaitDrain--,fe.awaitDrain===0&&c(se,"data")&&(fe.flowing=!0,W(se))}}(U);O.on("drain",Y);var G=!1,S=!1;function T(se){g("ondata"),S=!1,O.write(se)!==!1||S||((V.pipesCount===1&&V.pipes===O||V.pipesCount>1&&z(V.pipes,O)!==-1)&&!G&&(g("false write response, pause",U._readableState.awaitDrain),U._readableState.awaitDrain++,S=!0),U.pause())}function B(se){g("onerror",se),re(),O.removeListener("error",B),c(O,"error")===0&&O.emit("error",se)}function J(){O.removeListener("finish",K),re()}function K(){g("onfinish"),O.removeListener("close",J),re()}function re(){g("unpipe"),U.unpipe(O)}return U.on("data",T),function(se,fe,ve){if(typeof se.prependListener=="function")return se.prependListener(fe,ve);se._events&&se._events[fe]?o(se._events[fe])?se._events[fe].unshift(ve):se._events[fe]=[ve,se._events[fe]]:se.on(fe,ve)}(O,"error",B),O.once("close",J),O.once("finish",K),O.emit("pipe",U),V.flowing||(g("pipe resume"),U.resume()),O},R.prototype.unpipe=function(O){var p=this._readableState,U={hasUnpiped:!1};if(p.pipesCount===0)return this;if(p.pipesCount===1)return O&&O!==p.pipes||(O||(O=p.pipes),p.pipes=null,p.pipesCount=0,p.flowing=!1,O&&O.emit("unpipe",this,U)),this;if(!O){var V=p.pipes,Q=p.pipesCount;p.pipes=null,p.pipesCount=0,p.flowing=!1;for(var ee=0;ee<Q;ee++)V[ee].emit("unpipe",this,U);return this}var ne=z(p.pipes,O);return ne===-1||(p.pipes.splice(ne,1),p.pipesCount-=1,p.pipesCount===1&&(p.pipes=p.pipes[0]),O.emit("unpipe",this,U)),this},R.prototype.on=function(O,p){var U=u.prototype.on.call(this,O,p);if(O==="data")this._readableState.flowing!==!1&&this.resume();else if(O==="readable"){var V=this._readableState;V.endEmitted||V.readableListening||(V.readableListening=V.needReadable=!0,V.emittedReadable=!1,V.reading?V.length&&q(this):s.nextTick(w,this))}return U},R.prototype.addListener=R.prototype.on,R.prototype.resume=function(){var O=this._readableState;return O.flowing||(g("resume"),O.flowing=!0,function(p,U){U.resumeScheduled||(U.resumeScheduled=!0,s.nextTick(L,p,U))}(this,O)),this},R.prototype.pause=function(){return g("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(g("pause"),this._readableState.flowing=!1,this.emit("pause")),this},R.prototype.wrap=function(O){var p=this,U=this._readableState,V=!1;for(var Q in O.on("end",function(){if(g("wrapped end"),U.decoder&&!U.ended){var ne=U.decoder.end();ne&&ne.length&&p.push(ne)}p.push(null)}),O.on("data",function(ne){g("wrapped data"),U.decoder&&(ne=U.decoder.write(ne)),U.objectMode&&ne==null||(U.objectMode||ne&&ne.length)&&(p.push(ne)||(V=!0,O.pause()))}),O)this[Q]===void 0&&typeof O[Q]=="function"&&(this[Q]=function(ne){return function(){return O[ne].apply(O,arguments)}}(Q));for(var ee=0;ee<F.length;ee++)O.on(F[ee],this.emit.bind(this,F[ee]));return this._read=function(ne){g("wrapped _read",ne),V&&(V=!1,O.resume())},this},Object.defineProperty(R.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),R._fromList=k}).call(this,n(6),n(2))},function(e,t,n){e.exports=n(21).EventEmitter},function(e,t,n){var r=n(16);function i(s,l){s.emit("error",l)}e.exports={destroy:function(s,l){var o=this,c=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return c||u?(l?l(s):!s||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,s),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(s||null,function(f){!l&&f?(r.nextTick(i,o,f),o._writableState&&(o._writableState.errorEmitted=!0)):l&&l(f)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,n){e.exports=l;var r=n(23),i=n(17);function s(u,f){var E=this._transformState;E.transforming=!1;var _=E.writecb;if(!_)return this.emit("error",new Error("write callback called multiple times"));E.writechunk=null,E.writecb=null,f!=null&&this.push(f),_(u);var h=this._readableState;h.reading=!1,(h.needReadable||h.length<h.highWaterMark)&&this._read(h.highWaterMark)}function l(u){if(!(this instanceof l))return new l(u);r.call(this,u),this._transformState={afterTransform:s.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,u&&(typeof u.transform=="function"&&(this._transform=u.transform),typeof u.flush=="function"&&(this._flush=u.flush)),this.on("prefinish",o)}function o(){var u=this;typeof this._flush=="function"?this._flush(function(f,E){c(u,f,E)}):c(this,null,null)}function c(u,f,E){if(f)return u.emit("error",f);if(E!=null&&u.push(E),u._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(u._transformState.transforming)throw new Error("Calling transform done when still transforming");return u.push(null)}i.inherits=n(7),i.inherits(l,r),l.prototype.push=function(u,f){return this._transformState.needTransform=!1,r.prototype.push.call(this,u,f)},l.prototype._transform=function(u,f,E){throw new Error("_transform() is not implemented")},l.prototype._write=function(u,f,E){var _=this._transformState;if(_.writecb=E,_.writechunk=u,_.writeencoding=f,!_.transforming){var h=this._readableState;(_.needTransform||h.needReadable||h.length<h.highWaterMark)&&this._read(h.highWaterMark)}},l.prototype._read=function(u){var f=this._transformState;f.writechunk!==null&&f.writecb&&!f.transforming?(f.transforming=!0,this._transform(f.writechunk,f.writeencoding,f.afterTransform)):f.needTransform=!0},l.prototype._destroy=function(u,f){var E=this;r.prototype._destroy.call(this,u,function(_){f(_),E.emit("close")})}},function(e,t,n){e.exports=n(48)},function(e,t,n){(function(r){var i=n(170);function s(y,m){if(y===m)return 0;for(var C=y.length,w=m.length,L=0,W=Math.min(C,w);L<W;++L)if(y[L]!==m[L]){C=y[L],w=m[L];break}return C<w?-1:w<C?1:0}function l(y){return r.Buffer&&typeof r.Buffer.isBuffer=="function"?r.Buffer.isBuffer(y):!(y==null||!y._isBuffer)}var o=n(13),c=Object.prototype.hasOwnProperty,u=Array.prototype.slice,f=function(){}.name==="foo";function E(y){return Object.prototype.toString.call(y)}function _(y){return!l(y)&&typeof r.ArrayBuffer=="function"&&(typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(y):!!y&&(y instanceof DataView||!!(y.buffer&&y.buffer instanceof ArrayBuffer)))}var h=e.exports=M,g=/\s*function\s+([^\(\s]*)\s*/;function b(y){if(o.isFunction(y)){if(f)return y.name;var m=y.toString().match(g);return m&&m[1]}}function A(y,m){return typeof y=="string"?y.length<m?y:y.slice(0,m):y}function j(y){if(f||!o.isFunction(y))return o.inspect(y);var m=b(y);return"[Function"+(m?": "+m:"")+"]"}function F(y,m,C,w,L){throw new h.AssertionError({message:C,actual:y,expected:m,operator:w,stackStartFunction:L})}function M(y,m){y||F(y,!0,m,"==",h.ok)}function R(y,m,C,w){if(y===m)return!0;if(l(y)&&l(m))return s(y,m)===0;if(o.isDate(y)&&o.isDate(m))return y.getTime()===m.getTime();if(o.isRegExp(y)&&o.isRegExp(m))return y.source===m.source&&y.global===m.global&&y.multiline===m.multiline&&y.lastIndex===m.lastIndex&&y.ignoreCase===m.ignoreCase;if(y!==null&&typeof y=="object"||m!==null&&typeof m=="object"){if(_(y)&&_(m)&&E(y)===E(m)&&!(y instanceof Float32Array||y instanceof Float64Array))return s(new Uint8Array(y.buffer),new Uint8Array(m.buffer))===0;if(l(y)!==l(m))return!1;var L=(w=w||{actual:[],expected:[]}).actual.indexOf(y);return L!==-1&&L===w.expected.indexOf(m)||(w.actual.push(y),w.expected.push(m),function(W,k,N,P){if(W==null||k==null)return!1;if(o.isPrimitive(W)||o.isPrimitive(k))return W===k;if(N&&Object.getPrototypeOf(W)!==Object.getPrototypeOf(k))return!1;var z=d(W),O=d(k);if(z&&!O||!z&&O)return!1;if(z)return W=u.call(W),k=u.call(k),R(W,k,N);var p,U,V=q(W),Q=q(k);if(V.length!==Q.length)return!1;for(V.sort(),Q.sort(),U=V.length-1;U>=0;U--)if(V[U]!==Q[U])return!1;for(U=V.length-1;U>=0;U--)if(p=V[U],!R(W[p],k[p],N,P))return!1;return!0}(y,m,C,w))}return C?y===m:y==m}function d(y){return Object.prototype.toString.call(y)=="[object Arguments]"}function I(y,m){if(!y||!m)return!1;if(Object.prototype.toString.call(m)=="[object RegExp]")return m.test(y);try{if(y instanceof m)return!0}catch{}return!Error.isPrototypeOf(m)&&m.call({},y)===!0}function $(y,m,C,w){var L;if(typeof m!="function")throw new TypeError('"block" argument must be a function');typeof C=="string"&&(w=C,C=null),L=function(N){var P;try{N()}catch(z){P=z}return P}(m),w=(C&&C.name?" ("+C.name+").":".")+(w?" "+w:"."),y&&!L&&F(L,C,"Missing expected exception"+w);var W=typeof w=="string",k=!y&&L&&!C;if((!y&&o.isError(L)&&W&&I(L,C)||k)&&F(L,C,"Got unwanted exception"+w),y&&L&&C&&!I(L,C)||!y&&L)throw L}h.AssertionError=function(y){this.name="AssertionError",this.actual=y.actual,this.expected=y.expected,this.operator=y.operator,y.message?(this.message=y.message,this.generatedMessage=!1):(this.message=function(N){return A(j(N.actual),128)+" "+N.operator+" "+A(j(N.expected),128)}(this),this.generatedMessage=!0);var m=y.stackStartFunction||F;if(Error.captureStackTrace)Error.captureStackTrace(this,m);else{var C=new Error;if(C.stack){var w=C.stack,L=b(m),W=w.indexOf(`
|
|
@@ -40,13 +40,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
40
40
|
`)!=-1,M=this._styles,R=M.length;R--;){var d=s[M[R]];j=d.open+j.replace(d.closeRe,d.open)+d.close,F&&(j=j.replace(o,function(I){return d.close+I+d.open}))}return j}r.setTheme=function(A){if(typeof A!="string")for(var j in A)(function(F){r[F]=function(M){if(typeof A[F]=="object"){var R=M;for(var d in A[F])R=r[A[F][d]](R);return R}return r[A[F]](M)}})(j);else console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));")};var g=function(A,j){var F=j.split("");return(F=F.map(A)).join("")};for(var b in r.trap=n(112),r.zalgo=n(113),r.maps={},r.maps.america=n(114)(r),r.maps.zebra=n(115)(r),r.maps.rainbow=n(116)(r),r.maps.random=n(117)(r),r.maps)(function(A){r[A]=function(j){return g(r.maps[A],j)}})(b);l(r,function(){var A={};return Object.keys(E).forEach(function(j){A[j]={get:function(){return u([j])}}}),A}())},function(e,t){e.exports=function(n){return n&&typeof n=="object"&&typeof n.copy=="function"&&typeof n.fill=="function"&&typeof n.readUInt8=="function"}},function(e,t){typeof Object.create=="function"?e.exports=function(n,r){n.super_=r,n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(n,r){n.super_=r;var i=function(){};i.prototype=r.prototype,n.prototype=new i,n.prototype.constructor=n}},function(e,t){var n={};e.exports=n;var r={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(r).forEach(function(i){var s=r[i],l=n[i]=[];l.open="\x1B["+s[0]+"m",l.close="\x1B["+s[1]+"m"})},function(e,t,n){(function(r){var i=n(18),s=n(111),l=r.env,o=void 0;function c(u){return function(f){return f!==0&&{level:f,hasBasic:!0,has256:f>=2,has16m:f>=3}}(function(f){if(o===!1)return 0;if(s("color=16m")||s("color=full")||s("color=truecolor"))return 3;if(s("color=256"))return 2;if(f&&!f.isTTY&&o!==!0)return 0;var E=o?1:0;if(r.platform==="win32"){var _=i.release().split(".");return Number(r.versions.node.split(".")[0])>=8&&Number(_[0])>=10&&Number(_[2])>=10586?Number(_[2])>=14931?3:2:1}return"CI"in l?["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(h){return h in l})||l.CI_NAME==="codeship"?1:E:"TEAMCITY_VERSION"in l?/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(l.TEAMCITY_VERSION)?1:0:"TERM_PROGRAM"in l?(parseInt("445".split(".")[0],10),2):/-256(color)?$/i.test("xterm-256color")?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test("xterm-256color")||"COLORTERM"in l?1:E}(u))}s("no-color")||s("no-colors")||s("color=false")?o=!1:(s("color")||s("colors")||s("color=true")||s("color=always"))&&(o=!0),"FORCE_COLOR"in l&&(o=l.FORCE_COLOR.length===0||parseInt(l.FORCE_COLOR,10)!==0),e.exports={supportsColor:c,stdout:c(r.stdout),stderr:c(r.stderr)}}).call(this,n(2))},function(e,t,n){(function(r){e.exports=function(i,s){var l=(s=s||r.argv).indexOf("--"),o=/^-{1,2}/.test(i)?"":"--",c=s.indexOf(o+i);return c!==-1&&(l===-1||c<l)}}).call(this,n(2))},function(e,t){e.exports=function(n,r){var i="";n=(n=n||"Run the trap, drop the bass").split("");var s={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return n.forEach(function(l){l=l.toLowerCase();var o=s[l]||[" "],c=Math.floor(Math.random()*o.length);i+=s[l]!==void 0?s[l][c]:l}),i}},function(e,t){e.exports=function(n,r){n=n||" he is here ";var i={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},s=[].concat(i.up,i.down,i.mid);function l(c){return Math.floor(Math.random()*c)}function o(c){var u=!1;return s.filter(function(f){u=f===c}),u}return function(c,u){var f,E,_="";for(E in(u=u||{}).up=u.up===void 0||u.up,u.mid=u.mid===void 0||u.mid,u.down=u.down===void 0||u.down,u.size=u.size!==void 0?u.size:"maxi",c=c.split(""))if(!o(E)){switch(_+=c[E],f={up:0,down:0,mid:0},u.size){case"mini":f.up=l(8),f.mid=l(2),f.down=l(8);break;case"maxi":f.up=l(16)+3,f.mid=l(4)+1,f.down=l(64)+3;break;default:f.up=l(8)+1,f.mid=l(6)/2,f.down=l(8)+1}var h=["up","mid","down"];for(var g in h)for(var b=h[g],A=0;A<=f[b];A++)u[b]&&(_+=i[b][l(i[b].length)])}return _}(n,r)}},function(e,t){e.exports=function(n){return function(r,i,s){if(r===" ")return r;switch(i%3){case 0:return n.red(r);case 1:return n.white(r);case 2:return n.blue(r)}}}},function(e,t){e.exports=function(n){return function(r,i,s){return i%2==0?r:n.inverse(r)}}},function(e,t){e.exports=function(n){var r=["red","yellow","green","blue","magenta"];return function(i,s,l){return i===" "?i:n[r[s++%r.length]](i)}}},function(e,t){e.exports=function(n){var r=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta"];return function(i,s,l){return i===" "?i:n[r[Math.round(Math.random()*(r.length-2))]](i)}}},function(e,t,n){Object.defineProperty(t,"cli",{value:n(119)}),Object.defineProperty(t,"npm",{value:n(120)}),Object.defineProperty(t,"syslog",{value:n(121)})},function(e,t,n){t.levels={error:0,warn:1,help:2,data:3,info:4,debug:5,prompt:6,verbose:7,input:8,silly:9},t.colors={error:"red",warn:"yellow",help:"cyan",data:"grey",info:"green",debug:"blue",prompt:"grey",verbose:"cyan",input:"grey",silly:"magenta"}},function(e,t,n){t.levels={error:0,warn:1,info:2,http:3,verbose:4,debug:5,silly:6},t.colors={error:"red",warn:"yellow",info:"green",http:"green",verbose:"cyan",debug:"blue",silly:"magenta"}},function(e,t,n){t.levels={emerg:0,alert:1,crit:2,error:3,warning:4,notice:5,info:6,debug:7},t.colors={emerg:"red",alert:"yellow",crit:"red",error:"red",warning:"red",notice:"yellow",info:"green",debug:"blue"}},function(e,t,n){var r=n(12);e.exports=r(function(i){return i.message=" ".concat(i.message),i})},function(e,t,n){function r(E,_){if(!(E instanceof _))throw new TypeError("Cannot call a class as a function")}function i(E,_){for(var h=0;h<_.length;h++){var g=_[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(E,g.key,g)}}var s=n(41).Colorizer,l=n(60).Padder,o=n(3),c=o.configs,u=o.MESSAGE,f=function(){function E(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};r(this,E),g.levels||(g.levels=c.npm.levels),this.colorizer=new s(g),this.padder=new l(g),this.options=g}var _,h;return _=E,(h=[{key:"transform",value:function(g,b){return this.colorizer.transform(this.padder.transform(g,b),b),g[u]="".concat(g.level,":").concat(g.message),g}}])&&i(_.prototype,h),E}();e.exports=function(E){return new f(E)},e.exports.Format=f},function(e,t,n){var r=n(12);function i(l){if(l.every(s))return function(o){for(var c=o,u=0;u<l.length;u++)if(!(c=l[u].transform(c,l[u].options)))return!1;return c}}function s(l){if(typeof l.transform!="function")throw new Error(["No transform function found on format. Did you create a format instance?","const myFormat = format(formatFn);","const instance = myFormat();"].join(`
|
|
41
41
|
`));return!0}e.exports=function(){for(var l=arguments.length,o=new Array(l),c=0;c<l;c++)o[c]=arguments[c];var u=r(i(o)),f=u();return f.Format=u.Format,f},e.exports.cascade=i},function(e,t,n){(function(r){var i=n(12),s=n(3).MESSAGE,l=n(35);function o(c,u){return u instanceof r?u.toString("base64"):typeof u=="bigint"?u.toString():u}e.exports=i(function(c){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return c[s]=(u.stable?l.stableStringify:l)(c,u.replacer||o,u.space),c})}).call(this,n(5).Buffer)},function(e,t,n){t.byteLength=function(E){var _=u(E),h=_[0],g=_[1];return 3*(h+g)/4-g},t.toByteArray=function(E){for(var _,h=u(E),g=h[0],b=h[1],A=new s(function(R,d,I){return 3*(d+I)/4-I}(0,g,b)),j=0,F=b>0?g-4:g,M=0;M<F;M+=4)_=i[E.charCodeAt(M)]<<18|i[E.charCodeAt(M+1)]<<12|i[E.charCodeAt(M+2)]<<6|i[E.charCodeAt(M+3)],A[j++]=_>>16&255,A[j++]=_>>8&255,A[j++]=255&_;return b===2&&(_=i[E.charCodeAt(M)]<<2|i[E.charCodeAt(M+1)]>>4,A[j++]=255&_),b===1&&(_=i[E.charCodeAt(M)]<<10|i[E.charCodeAt(M+1)]<<4|i[E.charCodeAt(M+2)]>>2,A[j++]=_>>8&255,A[j++]=255&_),A},t.fromByteArray=function(E){for(var _,h=E.length,g=h%3,b=[],A=0,j=h-g;A<j;A+=16383)b.push(f(E,A,A+16383>j?j:A+16383));return g===1?(_=E[h-1],b.push(r[_>>2]+r[_<<4&63]+"==")):g===2&&(_=(E[h-2]<<8)+E[h-1],b.push(r[_>>10]+r[_>>4&63]+r[_<<2&63]+"=")),b.join("")};for(var r=[],i=[],s=typeof Uint8Array<"u"?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,c=l.length;o<c;++o)r[o]=l[o],i[l.charCodeAt(o)]=o;function u(E){var _=E.length;if(_%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var h=E.indexOf("=");return h===-1&&(h=_),[h,h===_?0:4-h%4]}function f(E,_,h){for(var g,b,A=[],j=_;j<h;j+=3)g=(E[j]<<16&16711680)+(E[j+1]<<8&65280)+(255&E[j+2]),A.push(r[(b=g)>>18&63]+r[b>>12&63]+r[b>>6&63]+r[63&b]);return A.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(n,r,i,s,l){var o,c,u=8*l-s-1,f=(1<<u)-1,E=f>>1,_=-7,h=i?l-1:0,g=i?-1:1,b=n[r+h];for(h+=g,o=b&(1<<-_)-1,b>>=-_,_+=u;_>0;o=256*o+n[r+h],h+=g,_-=8);for(c=o&(1<<-_)-1,o>>=-_,_+=s;_>0;c=256*c+n[r+h],h+=g,_-=8);if(o===0)o=1-E;else{if(o===f)return c?NaN:1/0*(b?-1:1);c+=Math.pow(2,s),o-=E}return(b?-1:1)*c*Math.pow(2,o-s)},t.write=function(n,r,i,s,l,o){var c,u,f,E=8*o-l-1,_=(1<<E)-1,h=_>>1,g=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=s?0:o-1,A=s?1:-1,j=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,c=_):(c=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-c))<1&&(c--,f*=2),(r+=c+h>=1?g/f:g*Math.pow(2,1-h))*f>=2&&(c++,f/=2),c+h>=_?(u=0,c=_):c+h>=1?(u=(r*f-1)*Math.pow(2,l),c+=h):(u=r*Math.pow(2,h-1)*Math.pow(2,l),c=0));l>=8;n[i+b]=255&u,b+=A,u/=256,l-=8);for(c=c<<l|u,E+=l;E>0;n[i+b]=255&c,b+=A,c/=256,E-=8);n[i+b-A]|=128*j}},function(e,t,n){var r=n(12);e.exports=r(function(i,s){return s.message?(i.message="[".concat(s.label,"] ").concat(i.message),i):(i.label=s.label,i)})},function(e,t,n){var r=n(12),i=n(3).MESSAGE,s=n(35);e.exports=r(function(l){var o={};return l.message&&(o["@message"]=l.message,delete l.message),l.timestamp&&(o["@timestamp"]=l.timestamp,delete l.timestamp),o["@fields"]=l,l[i]=s(o),l})},function(e,t,n){var r=n(12);function i(l,o,c){var u,f,E,_=o.reduce(function(g,b){return g[b]=l[b],delete l[b],g},{}),h=Object.keys(l).reduce(function(g,b){return g[b]=l[b],delete l[b],g},{});return Object.assign(l,_,(E=h,(f=c)in(u={})?Object.defineProperty(u,f,{value:E,enumerable:!0,configurable:!0,writable:!0}):u[f]=E,u)),l}function s(l,o,c){return l[c]=o.reduce(function(u,f){return u[f]=l[f],delete l[f],u},{}),l}e.exports=r(function(l){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},c="metadata";o.key&&(c=o.key);var u=[];return o.fillExcept||o.fillWith||(u.push("level"),u.push("message")),o.fillExcept&&(u=o.fillExcept),u.length>0?i(l,u,c):o.fillWith?s(l,o.fillWith,c):l})},function(e,t,n){var r=n(13).inspect,i=n(12),s=n(3),l=s.LEVEL,o=s.MESSAGE,c=s.SPLAT;e.exports=i(function(u){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=Object.assign({},u);return delete E[l],delete E[o],delete E[c],u[o]=r(E,!1,f.depth||null,f.colorize),u})},function(e,t,n){function r(l,o){for(var c=0;c<o.length;c++){var u=o[c];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(l,u.key,u)}}var i=n(3).MESSAGE,s=function(){function l(u){(function(f,E){if(!(f instanceof E))throw new TypeError("Cannot call a class as a function")})(this,l),this.template=u}var o,c;return o=l,(c=[{key:"transform",value:function(u){return u[i]=this.template(u),u}}])&&r(o.prototype,c),l}();e.exports=function(l){return new s(l)},e.exports.Printf=e.exports.Format=s},function(e,t,n){var r=n(12),i=n(3).MESSAGE,s=n(35);e.exports=r(function(l){var o=s(Object.assign({},l,{level:void 0,message:void 0,splat:void 0})),c=l.padding&&l.padding[l.level]||"";return l[i]=o!=="{}"?"".concat(l.level,":").concat(c," ").concat(l.message," ").concat(o):"".concat(l.level,":").concat(c," ").concat(l.message),l})},function(e,t,n){function r(E){return function(_){if(Array.isArray(_))return i(_)}(E)||function(_){if(typeof Symbol<"u"&&Symbol.iterator in Object(_))return Array.from(_)}(E)||function(_,h){if(_){if(typeof _=="string")return i(_,h);var g=Object.prototype.toString.call(_).slice(8,-1);if(g==="Object"&&_.constructor&&(g=_.constructor.name),g==="Map"||g==="Set")return Array.from(_);if(g==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(g))return i(_,h)}}(E)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
42
42
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function i(E,_){(_==null||_>E.length)&&(_=E.length);for(var h=0,g=new Array(_);h<_;h++)g[h]=E[h];return g}function s(E,_){for(var h=0;h<_.length;h++){var g=_[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(E,g.key,g)}}var l=n(13),o=n(3).SPLAT,c=/%[scdjifoO%]/g,u=/%%/g,f=function(){function E(g){(function(b,A){if(!(b instanceof A))throw new TypeError("Cannot call a class as a function")})(this,E),this.options=g}var _,h;return _=E,(h=[{key:"_splat",value:function(g,b){var A=g.message,j=g[o]||g.splat||[],F=A.match(u),M=F&&F.length||0,R=b.length-M-j.length,d=R<0?j.splice(R,-1*R):[],I=d.length;if(I)for(var $=0;$<I;$++)Object.assign(g,d[$]);return g.message=l.format.apply(l,[A].concat(r(j))),g}},{key:"transform",value:function(g){var b=g.message,A=g[o]||g.splat;if(!A||!A.length)return g;var j=b&&b.match&&b.match(c);if(!j&&(A||A.length)){var F=A.length>1?A.splice(0):A,M=F.length;if(M)for(var R=0;R<M;R++)Object.assign(g,F[R]);return g}return j?this._splat(g,j):g}}])&&s(_.prototype,h),E}();e.exports=function(E){return new f(E)}},function(e,t,n){var r=n(136),i=n(12);e.exports=i(function(s){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return l.format&&(s.timestamp=typeof l.format=="function"?l.format():r.format(new Date,l.format)),s.timestamp||(s.timestamp=new Date().toISOString()),l.alias&&(s[l.alias]=s.timestamp),s})},function(e,t,n){n.r(t),n.d(t,"assign",function(){return c}),n.d(t,"format",function(){return m}),n.d(t,"parse",function(){return C}),n.d(t,"defaultI18n",function(){return _}),n.d(t,"setGlobalDateI18n",function(){return g}),n.d(t,"setGlobalDateMasks",function(){return y});var r=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,i="[^\\s]+",s=/\[([^]*?)\]/gm;function l(L,W){for(var k=[],N=0,P=L.length;N<P;N++)k.push(L[N].substr(0,W));return k}var o=function(L){return function(W,k){var N=k[L].map(function(P){return P.toLowerCase()}).indexOf(W.toLowerCase());return N>-1?N:null}};function c(L){for(var W=[],k=1;k<arguments.length;k++)W[k-1]=arguments[k];for(var N=0,P=W;N<P.length;N++){var z=P[N];for(var O in z)L[O]=z[O]}return L}var u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],f=["January","February","March","April","May","June","July","August","September","October","November","December"],E=l(f,3),_={dayNamesShort:l(u,3),dayNames:u,monthNamesShort:E,monthNames:f,amPm:["am","pm"],DoFn:function(L){return L+["th","st","nd","rd"][L%10>3?0:(L-L%10!=10?1:0)*L%10]}},h=c({},_),g=function(L){return h=c(h,L)},b=function(L){return L.replace(/[|\\{()[^$+*?.-]/g,"\\$&")},A=function(L,W){for(W===void 0&&(W=2),L=String(L);L.length<W;)L="0"+L;return L},j={D:function(L){return String(L.getDate())},DD:function(L){return A(L.getDate())},Do:function(L,W){return W.DoFn(L.getDate())},d:function(L){return String(L.getDay())},dd:function(L){return A(L.getDay())},ddd:function(L,W){return W.dayNamesShort[L.getDay()]},dddd:function(L,W){return W.dayNames[L.getDay()]},M:function(L){return String(L.getMonth()+1)},MM:function(L){return A(L.getMonth()+1)},MMM:function(L,W){return W.monthNamesShort[L.getMonth()]},MMMM:function(L,W){return W.monthNames[L.getMonth()]},YY:function(L){return A(String(L.getFullYear()),4).substr(2)},YYYY:function(L){return A(L.getFullYear(),4)},h:function(L){return String(L.getHours()%12||12)},hh:function(L){return A(L.getHours()%12||12)},H:function(L){return String(L.getHours())},HH:function(L){return A(L.getHours())},m:function(L){return String(L.getMinutes())},mm:function(L){return A(L.getMinutes())},s:function(L){return String(L.getSeconds())},ss:function(L){return A(L.getSeconds())},S:function(L){return String(Math.round(L.getMilliseconds()/100))},SS:function(L){return A(Math.round(L.getMilliseconds()/10),2)},SSS:function(L){return A(L.getMilliseconds(),3)},a:function(L,W){return L.getHours()<12?W.amPm[0]:W.amPm[1]},A:function(L,W){return L.getHours()<12?W.amPm[0].toUpperCase():W.amPm[1].toUpperCase()},ZZ:function(L){var W=L.getTimezoneOffset();return(W>0?"-":"+")+A(100*Math.floor(Math.abs(W)/60)+Math.abs(W)%60,4)},Z:function(L){var W=L.getTimezoneOffset();return(W>0?"-":"+")+A(Math.floor(Math.abs(W)/60),2)+":"+A(Math.abs(W)%60,2)}},F=function(L){return+L-1},M=[null,"[1-9]\\d?"],R=[null,i],d=["isPm",i,function(L,W){var k=L.toLowerCase();return k===W.amPm[0]?0:k===W.amPm[1]?1:null}],I=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(L){var W=(L+"").match(/([+-]|\d\d)/gi);if(W){var k=60*+W[1]+parseInt(W[2],10);return W[0]==="+"?k:-k}return 0}],$={D:["day","[1-9]\\d?"],DD:["day","\\d\\d"],Do:["day","[1-9]\\d?"+i,function(L){return parseInt(L,10)}],M:["month","[1-9]\\d?",F],MM:["month","\\d\\d",F],YY:["year","\\d\\d",function(L){var W=+(""+new Date().getFullYear()).substr(0,2);return+(""+(+L>68?W-1:W)+L)}],h:["hour","[1-9]\\d?",void 0,"isPm"],hh:["hour","\\d\\d",void 0,"isPm"],H:["hour","[1-9]\\d?"],HH:["hour","\\d\\d"],m:["minute","[1-9]\\d?"],mm:["minute","\\d\\d"],s:["second","[1-9]\\d?"],ss:["second","\\d\\d"],YYYY:["year","\\d{4}"],S:["millisecond","\\d",function(L){return 100*+L}],SS:["millisecond","\\d\\d",function(L){return 10*+L}],SSS:["millisecond","\\d{3}"],d:M,dd:M,ddd:R,dddd:R,MMM:["month",i,o("monthNamesShort")],MMMM:["month",i,o("monthNames")],a:d,A:d,ZZ:I,Z:I},q={default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},y=function(L){return c(q,L)},m=function(L,W,k){if(W===void 0&&(W=q.default),k===void 0&&(k={}),typeof L=="number"&&(L=new Date(L)),Object.prototype.toString.call(L)!=="[object Date]"||isNaN(L.getTime()))throw new Error("Invalid Date pass to format");var N=[];W=(W=q[W]||W).replace(s,function(z,O){return N.push(O),"@@@"});var P=c(c({},h),k);return(W=W.replace(r,function(z){return j[z](L,P)})).replace(/@@@/g,function(){return N.shift()})};function C(L,W,k){if(k===void 0&&(k={}),typeof W!="string")throw new Error("Invalid format in fecha parse");if(W=q[W]||W,L.length>1e3)return null;var N={year:new Date().getFullYear(),month:0,day:1,hour:0,minute:0,second:0,millisecond:0,isPm:null,timezoneOffset:null},P=[],z=[],O=W.replace(s,function(K,re){return z.push(b(re)),"@@@"}),p={},U={};O=b(O).replace(r,function(K){var re=$[K],se=re[0],fe=re[1],ve=re[3];if(p[se])throw new Error("Invalid format. "+se+" specified twice in format");return p[se]=!0,ve&&(U[ve]=!0),P.push(re),"("+fe+")"}),Object.keys(U).forEach(function(K){if(!p[K])throw new Error("Invalid format. "+K+" is required in specified format")}),O=O.replace(/@@@/g,function(){return z.shift()});var V=L.match(new RegExp(O,"i"));if(!V)return null;for(var Q=c(c({},h),k),ee=1;ee<V.length;ee++){var ne=P[ee-1],Y=ne[0],G=ne[2],S=G?G(V[ee],Q):+V[ee];if(S==null)return null;N[Y]=S}N.isPm===1&&N.hour!=null&&+N.hour!=12?N.hour=+N.hour+12:N.isPm===0&&+N.hour==12&&(N.hour=0);for(var T=new Date(N.year,N.month,N.day,N.hour,N.minute,N.second,N.millisecond),B=[["month","getMonth"],["day","getDate"],["hour","getHours"],["minute","getMinutes"],["second","getSeconds"]],J=(ee=0,B.length);ee<J;ee++)if(p[B[ee][0]]&&N[B[ee][0]]!==T[B[ee][1]]())return null;return N.timezoneOffset==null?T:new Date(Date.UTC(N.year,N.month,N.day,N.hour,N.minute-N.timezoneOffset,N.second,N.millisecond))}var w={format:m,parse:C,defaultI18n:_,setGlobalDateI18n:g,setGlobalDateMasks:y};t.default=w},function(e,t,n){var r=n(59),i=n(12),s=n(3).MESSAGE;e.exports=i(function(l,o){return o.level!==!1&&(l.level=r.strip(l.level)),o.message!==!1&&(l.message=r.strip(l.message)),o.raw!==!1&&l[s]&&(l[s]=r.strip(l[s])),l})},function(e){e.exports=JSON.parse('{"name":"winston","description":"A logger for just about everything.","version":"3.3.3","author":"Charlie Robbins <charlie.robbins@gmail.com>","maintainers":["Jarrett Cruger <jcrugzz@gmail.com>","Chris Alderson <chrisalderson@protonmail.com>","David Hyde <dabh@stanford.edu>"],"repository":{"type":"git","url":"https://github.com/winstonjs/winston.git"},"keywords":["winston","logger","logging","logs","sysadmin","bunyan","pino","loglevel","tools","json","stream"],"dependencies":{"async":"^3.1.0","@dabh/diagnostics":"^2.0.2","is-stream":"^2.0.0","logform":"^2.2.0","one-time":"^1.0.0","readable-stream":"^3.4.0","stack-trace":"0.0.x","triple-beam":"^1.3.0","winston-transport":"^4.4.0"},"devDependencies":{"@babel/cli":"^7.10.3","@babel/core":"^7.10.3","@babel/preset-env":"^7.10.3","@types/node":"^14.0.13","abstract-winston-transport":"^0.5.1","assume":"^2.2.0","colors":"^1.4.0","cross-spawn-async":"^2.2.5","eslint-config-populist":"^4.2.0","hock":"^1.4.1","mocha":"^8.0.1","nyc":"^15.1.0","rimraf":"^3.0.2","split2":"^3.1.1","std-mocks":"^1.0.1","through2":"^3.0.1","winston-compat":"^0.1.5"},"main":"./lib/winston","browser":"./dist/winston","types":"./index.d.ts","scripts":{"lint":"populist lib/*.js lib/winston/*.js lib/winston/**/*.js","pretest":"npm run lint","test":"nyc --reporter=text --reporter lcov npm run test:mocha","test:mocha":"mocha test/*.test.js test/**/*.test.js --exit","build":"./node_modules/.bin/rimraf dist && babel lib -d dist","prepublishOnly":"npm run build"},"engines":{"node":">= 6.4.0"},"license":"MIT"}')},function(e,t,n){Object.defineProperty(t,"Console",{configurable:!0,enumerable:!0,get:function(){return n(140)}}),Object.defineProperty(t,"File",{configurable:!0,enumerable:!0,get:function(){return n(149)}}),Object.defineProperty(t,"Http",{configurable:!0,enumerable:!0,get:function(){return n(189)}}),Object.defineProperty(t,"Stream",{configurable:!0,enumerable:!0,get:function(){return n(201)}})},function(e,t,n){(function(r){function i(A){return(i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(j){return typeof j}:function(j){return j&&typeof Symbol=="function"&&j.constructor===Symbol&&j!==Symbol.prototype?"symbol":typeof j})(A)}function s(A,j){if(!(A instanceof j))throw new TypeError("Cannot call a class as a function")}function l(A,j){for(var F=0;F<j.length;F++){var M=j[F];M.enumerable=M.enumerable||!1,M.configurable=!0,"value"in M&&(M.writable=!0),Object.defineProperty(A,M.key,M)}}function o(A,j){return(o=Object.setPrototypeOf||function(F,M){return F.__proto__=M,F})(A,j)}function c(A){var j=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var F,M=f(A);if(j){var R=f(this).constructor;F=Reflect.construct(M,arguments,R)}else F=M.apply(this,arguments);return u(this,F)}}function u(A,j){return!j||i(j)!=="object"&&typeof j!="function"?function(F){if(F===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return F}(A):j}function f(A){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(j){return j.__proto__||Object.getPrototypeOf(j)})(A)}var E=n(18),_=n(3),h=_.LEVEL,g=_.MESSAGE,b=n(20);e.exports=function(A){(function(d,I){if(typeof I!="function"&&I!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(I&&I.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),I&&o(d,I)})(R,A);var j,F,M=c(R);function R(){var d,I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return s(this,R),(d=M.call(this,I)).name=I.name||"console",d.stderrLevels=d._stringArrayToSet(I.stderrLevels),d.consoleWarnLevels=d._stringArrayToSet(I.consoleWarnLevels),d.eol=I.eol||E.EOL,d.setMaxListeners(30),d}return j=R,(F=[{key:"log",value:function(d,I){var $=this;return r(function(){return $.emit("logged",d)}),this.stderrLevels[d[h]]?(console._stderr?console._stderr.write("".concat(d[g]).concat(this.eol)):console.error(d[g]),void(I&&I())):this.consoleWarnLevels[d[h]]?(console._stderr?console._stderr.write("".concat(d[g]).concat(this.eol)):console.warn(d[g]),void(I&&I())):(console._stdout?console._stdout.write("".concat(d[g]).concat(this.eol)):console.log(d[g]),void(I&&I()))}},{key:"_stringArrayToSet",value:function(d,I){if(!d)return{};if(I=I||"Cannot make set from type other than Array of string elements",!Array.isArray(d))throw new Error(I);return d.reduce(function($,q){if(typeof q!="string")throw new Error(I);return $[q]=!0,$},{})}}])&&l(j.prototype,F),R}(b)}).call(this,n(15).setImmediate)},function(e,t,n){(function(r,i){(function(s,l){if(!s.setImmediate){var o,c,u,f,E,_=1,h={},g=!1,b=s.document,A=Object.getPrototypeOf&&Object.getPrototypeOf(s);A=A&&A.setTimeout?A:s,{}.toString.call(s.process)==="[object process]"?o=function(M){i.nextTick(function(){F(M)})}:function(){if(s.postMessage&&!s.importScripts){var M=!0,R=s.onmessage;return s.onmessage=function(){M=!1},s.postMessage("","*"),s.onmessage=R,M}}()?(f="setImmediate$"+Math.random()+"$",E=function(M){M.source===s&&typeof M.data=="string"&&M.data.indexOf(f)===0&&F(+M.data.slice(f.length))},s.addEventListener?s.addEventListener("message",E,!1):s.attachEvent("onmessage",E),o=function(M){s.postMessage(f+M,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(M){F(M.data)},o=function(M){u.port2.postMessage(M)}):b&&"onreadystatechange"in b.createElement("script")?(c=b.documentElement,o=function(M){var R=b.createElement("script");R.onreadystatechange=function(){F(M),R.onreadystatechange=null,c.removeChild(R),R=null},c.appendChild(R)}):o=function(M){setTimeout(F,0,M)},A.setImmediate=function(M){typeof M!="function"&&(M=new Function(""+M));for(var R=new Array(arguments.length-1),d=0;d<R.length;d++)R[d]=arguments[d+1];var I={callback:M,args:R};return h[_]=I,o(_),_++},A.clearImmediate=j}function j(M){delete h[M]}function F(M){if(g)setTimeout(F,0,M);else{var R=h[M];if(R){g=!0;try{(function(d){var I=d.callback,$=d.args;switch($.length){case 0:I();break;case 1:I($[0]);break;case 2:I($[0],$[1]);break;case 3:I($[0],$[1],$[2]);break;default:I.apply(void 0,$)}})(R)}finally{j(M),g=!1}}}}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,n(6),n(2))},function(e,t,n){e.exports=n(62)},function(e,t,n){(function(r,i){var s=n(16);e.exports=R;var l,o=n(42);R.ReadableState=M,n(21).EventEmitter;var c=function(O,p){return O.listeners(p).length},u=n(63),f=n(44).Buffer,E=r.Uint8Array||function(){},_=Object.create(n(17));_.inherits=n(7);var h=n(144),g=void 0;g=h&&h.debuglog?h.debuglog("stream"):function(){};var b,A=n(145),j=n(64);_.inherits(R,u);var F=["error","close","destroy","pause","resume"];function M(O,p){O=O||{};var U=p instanceof(l=l||n(36));this.objectMode=!!O.objectMode,U&&(this.objectMode=this.objectMode||!!O.readableObjectMode);var V=O.highWaterMark,Q=O.readableHighWaterMark,ee=this.objectMode?16:16384;this.highWaterMark=V||V===0?V:U&&(Q||Q===0)?Q:ee,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new A,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=O.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,O.encoding&&(b||(b=n(22).StringDecoder),this.decoder=new b(O.encoding),this.encoding=O.encoding)}function R(O){if(l=l||n(36),!(this instanceof R))return new R(O);this._readableState=new M(O,this),this.readable=!0,O&&(typeof O.read=="function"&&(this._read=O.read),typeof O.destroy=="function"&&(this._destroy=O.destroy)),u.call(this)}function d(O,p,U,V,Q){var ee,ne=O._readableState;return p===null?(ne.reading=!1,function(Y,G){if(!G.ended){if(G.decoder){var S=G.decoder.end();S&&S.length&&(G.buffer.push(S),G.length+=G.objectMode?1:S.length)}G.ended=!0,q(Y)}}(O,ne)):(Q||(ee=function(Y,G){var S;T=G,f.isBuffer(T)||T instanceof E||typeof G=="string"||G===void 0||Y.objectMode||(S=new TypeError("Invalid non-string/buffer chunk"));var T;return S}(ne,p)),ee?O.emit("error",ee):ne.objectMode||p&&p.length>0?(typeof p=="string"||ne.objectMode||Object.getPrototypeOf(p)===f.prototype||(p=function(Y){return f.from(Y)}(p)),V?ne.endEmitted?O.emit("error",new Error("stream.unshift() after end event")):I(O,ne,p,!0):ne.ended?O.emit("error",new Error("stream.push() after EOF")):(ne.reading=!1,ne.decoder&&!U?(p=ne.decoder.write(p),ne.objectMode||p.length!==0?I(O,ne,p,!1):m(O,ne)):I(O,ne,p,!1))):V||(ne.reading=!1)),function(Y){return!Y.ended&&(Y.needReadable||Y.length<Y.highWaterMark||Y.length===0)}(ne)}function I(O,p,U,V){p.flowing&&p.length===0&&!p.sync?(O.emit("data",U),O.read(0)):(p.length+=p.objectMode?1:U.length,V?p.buffer.unshift(U):p.buffer.push(U),p.needReadable&&q(O)),m(O,p)}Object.defineProperty(R.prototype,"destroyed",{get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(O){this._readableState&&(this._readableState.destroyed=O)}}),R.prototype.destroy=j.destroy,R.prototype._undestroy=j.undestroy,R.prototype._destroy=function(O,p){this.push(null),p(O)},R.prototype.push=function(O,p){var U,V=this._readableState;return V.objectMode?U=!0:typeof O=="string"&&((p=p||V.defaultEncoding)!==V.encoding&&(O=f.from(O,p),p=""),U=!0),d(this,O,p,!1,U)},R.prototype.unshift=function(O){return d(this,O,null,!0,!1)},R.prototype.isPaused=function(){return this._readableState.flowing===!1},R.prototype.setEncoding=function(O){return b||(b=n(22).StringDecoder),this._readableState.decoder=new b(O),this._readableState.encoding=O,this};function $(O,p){return O<=0||p.length===0&&p.ended?0:p.objectMode?1:O!=O?p.flowing&&p.length?p.buffer.head.data.length:p.length:(O>p.highWaterMark&&(p.highWaterMark=function(U){return U>=8388608?U=8388608:(U--,U|=U>>>1,U|=U>>>2,U|=U>>>4,U|=U>>>8,U|=U>>>16,U++),U}(O)),O<=p.length?O:p.ended?p.length:(p.needReadable=!0,0))}function q(O){var p=O._readableState;p.needReadable=!1,p.emittedReadable||(g("emitReadable",p.flowing),p.emittedReadable=!0,p.sync?s.nextTick(y,O):y(O))}function y(O){g("emit readable"),O.emit("readable"),W(O)}function m(O,p){p.readingMore||(p.readingMore=!0,s.nextTick(C,O,p))}function C(O,p){for(var U=p.length;!p.reading&&!p.flowing&&!p.ended&&p.length<p.highWaterMark&&(g("maybeReadMore read 0"),O.read(0),U!==p.length);)U=p.length;p.readingMore=!1}function w(O){g("readable nexttick read 0"),O.read(0)}function L(O,p){p.reading||(g("resume read 0"),O.read(0)),p.resumeScheduled=!1,p.awaitDrain=0,O.emit("resume"),W(O),p.flowing&&!p.reading&&O.read(0)}function W(O){var p=O._readableState;for(g("flow",p.flowing);p.flowing&&O.read()!==null;);}function k(O,p){return p.length===0?null:(p.objectMode?U=p.buffer.shift():!O||O>=p.length?(U=p.decoder?p.buffer.join(""):p.buffer.length===1?p.buffer.head.data:p.buffer.concat(p.length),p.buffer.clear()):U=function(V,Q,ee){var ne;return V<Q.head.data.length?(ne=Q.head.data.slice(0,V),Q.head.data=Q.head.data.slice(V)):ne=V===Q.head.data.length?Q.shift():ee?function(Y,G){var S=G.head,T=1,B=S.data;for(Y-=B.length;S=S.next;){var J=S.data,K=Y>J.length?J.length:Y;if(K===J.length?B+=J:B+=J.slice(0,Y),(Y-=K)===0){K===J.length?(++T,S.next?G.head=S.next:G.head=G.tail=null):(G.head=S,S.data=J.slice(K));break}++T}return G.length-=T,B}(V,Q):function(Y,G){var S=f.allocUnsafe(Y),T=G.head,B=1;for(T.data.copy(S),Y-=T.data.length;T=T.next;){var J=T.data,K=Y>J.length?J.length:Y;if(J.copy(S,S.length-Y,0,K),(Y-=K)===0){K===J.length?(++B,T.next?G.head=T.next:G.head=G.tail=null):(G.head=T,T.data=J.slice(K));break}++B}return G.length-=B,S}(V,Q),ne}(O,p.buffer,p.decoder),U);var U}function N(O){var p=O._readableState;if(p.length>0)throw new Error('"endReadable()" called on non-empty stream');p.endEmitted||(p.ended=!0,s.nextTick(P,p,O))}function P(O,p){O.endEmitted||O.length!==0||(O.endEmitted=!0,p.readable=!1,p.emit("end"))}function z(O,p){for(var U=0,V=O.length;U<V;U++)if(O[U]===p)return U;return-1}R.prototype.read=function(O){g("read",O),O=parseInt(O,10);var p=this._readableState,U=O;if(O!==0&&(p.emittedReadable=!1),O===0&&p.needReadable&&(p.length>=p.highWaterMark||p.ended))return g("read: emitReadable",p.length,p.ended),p.length===0&&p.ended?N(this):q(this),null;if((O=$(O,p))===0&&p.ended)return p.length===0&&N(this),null;var V,Q=p.needReadable;return g("need readable",Q),(p.length===0||p.length-O<p.highWaterMark)&&g("length less than watermark",Q=!0),p.ended||p.reading?g("reading or ended",Q=!1):Q&&(g("do read"),p.reading=!0,p.sync=!0,p.length===0&&(p.needReadable=!0),this._read(p.highWaterMark),p.sync=!1,p.reading||(O=$(U,p))),(V=O>0?k(O,p):null)===null?(p.needReadable=!0,O=0):p.length-=O,p.length===0&&(p.ended||(p.needReadable=!0),U!==O&&p.ended&&N(this)),V!==null&&this.emit("data",V),V},R.prototype._read=function(O){this.emit("error",new Error("_read() is not implemented"))},R.prototype.pipe=function(O,p){var U=this,V=this._readableState;switch(V.pipesCount){case 0:V.pipes=O;break;case 1:V.pipes=[V.pipes,O];break;default:V.pipes.push(O)}V.pipesCount+=1,g("pipe count=%d opts=%j",V.pipesCount,p);var Q=(!p||p.end!==!1)&&O!==i.stdout&&O!==i.stderr?ne:re;function ee(se,fe){g("onunpipe"),se===U&&fe&&fe.hasUnpiped===!1&&(fe.hasUnpiped=!0,g("cleanup"),O.removeListener("close",J),O.removeListener("finish",K),O.removeListener("drain",Y),O.removeListener("error",B),O.removeListener("unpipe",ee),U.removeListener("end",ne),U.removeListener("end",re),U.removeListener("data",T),G=!0,!V.awaitDrain||O._writableState&&!O._writableState.needDrain||Y())}function ne(){g("onend"),O.end()}V.endEmitted?s.nextTick(Q):U.once("end",Q),O.on("unpipe",ee);var Y=function(se){return function(){var fe=se._readableState;g("pipeOnDrain",fe.awaitDrain),fe.awaitDrain&&fe.awaitDrain--,fe.awaitDrain===0&&c(se,"data")&&(fe.flowing=!0,W(se))}}(U);O.on("drain",Y);var G=!1,S=!1;function T(se){g("ondata"),S=!1,O.write(se)!==!1||S||((V.pipesCount===1&&V.pipes===O||V.pipesCount>1&&z(V.pipes,O)!==-1)&&!G&&(g("false write response, pause",U._readableState.awaitDrain),U._readableState.awaitDrain++,S=!0),U.pause())}function B(se){g("onerror",se),re(),O.removeListener("error",B),c(O,"error")===0&&O.emit("error",se)}function J(){O.removeListener("finish",K),re()}function K(){g("onfinish"),O.removeListener("close",J),re()}function re(){g("unpipe"),U.unpipe(O)}return U.on("data",T),function(se,fe,ve){if(typeof se.prependListener=="function")return se.prependListener(fe,ve);se._events&&se._events[fe]?o(se._events[fe])?se._events[fe].unshift(ve):se._events[fe]=[ve,se._events[fe]]:se.on(fe,ve)}(O,"error",B),O.once("close",J),O.once("finish",K),O.emit("pipe",U),V.flowing||(g("pipe resume"),U.resume()),O},R.prototype.unpipe=function(O){var p=this._readableState,U={hasUnpiped:!1};if(p.pipesCount===0)return this;if(p.pipesCount===1)return O&&O!==p.pipes||(O||(O=p.pipes),p.pipes=null,p.pipesCount=0,p.flowing=!1,O&&O.emit("unpipe",this,U)),this;if(!O){var V=p.pipes,Q=p.pipesCount;p.pipes=null,p.pipesCount=0,p.flowing=!1;for(var ee=0;ee<Q;ee++)V[ee].emit("unpipe",this,U);return this}var ne=z(p.pipes,O);return ne===-1||(p.pipes.splice(ne,1),p.pipesCount-=1,p.pipesCount===1&&(p.pipes=p.pipes[0]),O.emit("unpipe",this,U)),this},R.prototype.on=function(O,p){var U=u.prototype.on.call(this,O,p);if(O==="data")this._readableState.flowing!==!1&&this.resume();else if(O==="readable"){var V=this._readableState;V.endEmitted||V.readableListening||(V.readableListening=V.needReadable=!0,V.emittedReadable=!1,V.reading?V.length&&q(this):s.nextTick(w,this))}return U},R.prototype.addListener=R.prototype.on,R.prototype.resume=function(){var O=this._readableState;return O.flowing||(g("resume"),O.flowing=!0,function(p,U){U.resumeScheduled||(U.resumeScheduled=!0,s.nextTick(L,p,U))}(this,O)),this},R.prototype.pause=function(){return g("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(g("pause"),this._readableState.flowing=!1,this.emit("pause")),this},R.prototype.wrap=function(O){var p=this,U=this._readableState,V=!1;for(var Q in O.on("end",function(){if(g("wrapped end"),U.decoder&&!U.ended){var ne=U.decoder.end();ne&&ne.length&&p.push(ne)}p.push(null)}),O.on("data",function(ne){g("wrapped data"),U.decoder&&(ne=U.decoder.write(ne)),U.objectMode&&ne==null||(U.objectMode||ne&&ne.length)&&(p.push(ne)||(V=!0,O.pause()))}),O)this[Q]===void 0&&typeof O[Q]=="function"&&(this[Q]=function(ne){return function(){return O[ne].apply(O,arguments)}}(Q));for(var ee=0;ee<F.length;ee++)O.on(F[ee],this.emit.bind(this,F[ee]));return this._read=function(ne){g("wrapped _read",ne),V&&(V=!1,O.resume())},this},Object.defineProperty(R.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),R._fromList=k}).call(this,n(6),n(2))},function(e,t){},function(e,t,n){var r=n(44).Buffer,i=n(146);e.exports=function(){function s(){(function(l,o){if(!(l instanceof o))throw new TypeError("Cannot call a class as a function")})(this,s),this.head=null,this.tail=null,this.length=0}return s.prototype.push=function(l){var o={data:l,next:null};this.length>0?this.tail.next=o:this.head=o,this.tail=o,++this.length},s.prototype.unshift=function(l){var o={data:l,next:this.head};this.length===0&&(this.tail=o),this.head=o,++this.length},s.prototype.shift=function(){if(this.length!==0){var l=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,l}},s.prototype.clear=function(){this.head=this.tail=null,this.length=0},s.prototype.join=function(l){if(this.length===0)return"";for(var o=this.head,c=""+o.data;o=o.next;)c+=l+o.data;return c},s.prototype.concat=function(l){if(this.length===0)return r.alloc(0);if(this.length===1)return this.head.data;for(var o,c,u,f=r.allocUnsafe(l>>>0),E=this.head,_=0;E;)o=E.data,c=f,u=_,o.copy(c,u),_+=E.data.length,E=E.next;return f},s}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var s=i.inspect({length:this.length});return this.constructor.name+" "+s})},function(e,t){},function(e,t,n){var r=n(5),i=r.Buffer;function s(o,c){for(var u in o)c[u]=o[u]}function l(o,c,u){return i(o,c,u)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=l),s(i,l),l.from=function(o,c,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return i(o,c,u)},l.alloc=function(o,c,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=i(o);return c!==void 0?typeof u=="string"?f.fill(c,u):f.fill(c):f.fill(0),f},l.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return i(o)},l.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}},function(e,t,n){var r=n(13),i=n(3).LEVEL,s=n(20),l=e.exports=function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(s.call(this,o),!o.transport||typeof o.transport.log!="function")throw new Error("Invalid transport, must be an object with a log method.");function c(u){this.emit("error",u,this.transport)}this.transport=o.transport,this.level=this.level||o.transport.level,this.handleExceptions=this.handleExceptions||o.transport.handleExceptions,this._deprecated(),this.transport.__winstonError||(this.transport.__winstonError=c.bind(this),this.transport.on("error",this.transport.__winstonError))};r.inherits(l,s),l.prototype._write=function(o,c,u){if(this.silent||o.exception===!0&&!this.handleExceptions)return u(null);(!this.level||this.levels[this.level]>=this.levels[o[i]])&&this.transport.log(o[i],o.message,o,this._nop),u(null)},l.prototype._writev=function(o,c){for(var u=0;u<o.length;u++)this._accept(o[u])&&(this.transport.log(o[u].chunk[i],o[u].chunk.message,o[u].chunk,this._nop),o[u].callback());return c(null)},l.prototype._deprecated=function(){console.error([this.transport.name+" is a legacy winston transport. Consider upgrading: ","- Upgrade docs: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md"].join(`
|
|
43
|
-
`))},l.prototype.close=function(){this.transport.close&&this.transport.close(),this.transport.__winstonError&&(this.transport.removeListener("error",this.transport.__winstonError),this.transport.__winstonError=null)}},function(e,t,n){(function(r,i){function s(y){return(s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m})(y)}function l(y,m){if(!(y instanceof m))throw new TypeError("Cannot call a class as a function")}function o(y,m){for(var C=0;C<m.length;C++){var w=m[C];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(y,w.key,w)}}function c(y,m){return(c=Object.setPrototypeOf||function(C,w){return C.__proto__=w,C})(y,m)}function u(y){var m=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var C,w=_(y);if(m){var L=_(this).constructor;C=Reflect.construct(w,arguments,L)}else C=w.apply(this,arguments);return f(this,C)}}function f(y,m){return!m||s(m)!=="object"&&typeof m!="function"?E(y):m}function E(y){if(y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y}function _(y){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(m){return m.__proto__||Object.getPrototypeOf(m)})(y)}var h=n(65),g=n(56),b=n(150),A=n(160),j=n(3).MESSAGE,F=n(32),M=F.Stream,R=F.PassThrough,d=n(20),I=n(38)("winston:file"),$=n(18),q=n(188);e.exports=function(y){(function(W,k){if(typeof k!="function"&&k!==null)throw new TypeError("Super expression must either be null or a function");W.prototype=Object.create(k&&k.prototype,{constructor:{value:W,writable:!0,configurable:!0}}),k&&c(W,k)})(L,y);var m,C,w=u(L);function L(){var W,k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};function N(P){for(var z=arguments.length,O=new Array(z>1?z-1:0),p=1;p<z;p++)O[p-1]=arguments[p];O.slice(1).forEach(function(U){if(k[U])throw new Error("Cannot set ".concat(U," and ").concat(P," together"))})}if(l(this,L),(W=w.call(this,k)).name=k.name||"file",W._stream=new R,W._stream.setMaxListeners(30),W._onError=W._onError.bind(E(W)),k.filename||k.dirname)N("filename or dirname","stream"),W._basename=W.filename=k.filename?g.basename(k.filename):"winston.log",W.dirname=k.dirname||g.dirname(k.filename),W.options=k.options||{flags:"a"};else{if(!k.stream)throw new Error("Cannot log to file without filename or stream.");console.warn("options.stream will be removed in winston@4. Use winston.transports.Stream"),N("stream","filename","maxsize"),W._dest=W._stream.pipe(W._setupStream(k.stream)),W.dirname=g.dirname(W._dest.path)}return W.maxsize=k.maxsize||null,W.rotationFormat=k.rotationFormat||!1,W.zippedArchive=k.zippedArchive||!1,W.maxFiles=k.maxFiles||null,W.eol=k.eol||$.EOL,W.tailable=k.tailable||!1,W._size=0,W._pendingSize=0,W._created=0,W._drain=!1,W._opening=!1,W._ending=!1,W.dirname&&W._createLogDirIfNotExist(W.dirname),W.open(),W}return m=L,(C=[{key:"finishIfEnding",value:function(){var W=this;this._ending&&(this._opening?this.once("open",function(){W._stream.once("finish",function(){return W.emit("finish")}),r(function(){return W._stream.end()})}):(this._stream.once("finish",function(){return W.emit("finish")}),r(function(){return W._stream.end()})))}},{key:"log",value:function(W){var k=this,N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){};if(this.silent)return N(),!0;if(this._drain)this._stream.once("drain",function(){k._drain=!1,k.log(W,N)});else{if(!this._rotate){var P="".concat(W[j]).concat(this.eol),z=i.byteLength(P);this._pendingSize+=z,this._opening&&!this.rotatedWhileOpening&&this._needsNewFile(this._size+this._pendingSize)&&(this.rotatedWhileOpening=!0);var O=this._stream.write(P,p.bind(this));return O?N():(this._drain=!0,this._stream.once("drain",function(){k._drain=!1,N()})),I("written",O,this._drain),this.finishIfEnding(),O}this._stream.once("rotate",function(){k._rotate=!1,k.log(W,N)})}function p(){var U=this;this._size+=z,this._pendingSize-=z,I("logged %s %s",this._size,P),this.emit("logged",W),this._opening||this._needsNewFile()&&(this._rotate=!0,this._endStream(function(){return U._rotateFile()}))}}},{key:"query",value:function(W,k){typeof W=="function"&&(k=W,W={}),W=function(V){return(V=V||{}).rows=V.rows||V.limit||10,V.start=V.start||0,V.until=V.until||new Date,s(V.until)!=="object"&&(V.until=new Date(V.until)),V.from=V.from||V.until-864e5,s(V.from)!=="object"&&(V.from=new Date(V.from)),V.order=V.order||"desc",V}(W);var N=g.join(this.dirname,this.filename),P="",z=[],O=0,p=h.createReadStream(N,{encoding:"utf8"});function U(V,Q){try{var ee=JSON.parse(V);(function(ne){if(ne&&s(ne)==="object"){var Y=new Date(ne.timestamp);if(!(W.from&&Y<W.from||W.until&&Y>W.until||W.level&&W.level!==ne.level))return!0}})(ee)&&function(ne){W.rows&&z.length>=W.rows&&W.order!=="desc"?p.readable&&p.destroy():(W.fields&&(ne=W.fields.reduce(function(Y,G){return Y[G]=ne[G],Y},{})),W.order==="desc"&&z.length>=W.rows&&z.shift(),z.push(ne))}(ee)}catch(ne){Q||p.emit("error",ne)}}p.on("error",function(V){if(p.readable&&p.destroy(),k)return V.code!=="ENOENT"?k(V):k(null,z)}),p.on("data",function(V){for(var Q=(V=(P+V).split(/\n+/)).length-1,ee=0;ee<Q;ee++)(!W.start||O>=W.start)&&U(V[ee]),O++;P=V[Q]}),p.on("close",function(){P&&U(P,!0),W.order==="desc"&&(z=z.reverse()),k&&k(null,z)})}},{key:"stream",value:function(){var W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},k=g.join(this.dirname,this.filename),N=new M,P={file:k,start:W.start};return N.destroy=q(P,function(z,O){if(z)return N.emit("error",z);try{N.emit("data",O),O=JSON.parse(O),N.emit("log",O)}catch(p){N.emit("error",p)}}),N}},{key:"open",value:function(){var W=this;this.filename&&(this._opening||(this._opening=!0,this.stat(function(k,N){if(k)return W.emit("error",k);I("stat done: %s { size: %s }",W.filename,N),W._size=N,W._dest=W._createStream(W._stream),W._opening=!1,W.once("open",function(){W._stream.eventNames().includes("rotate")?W._stream.emit("rotate"):W._rotate=!1})})))}},{key:"stat",value:function(W){var k=this,N=this._getFile(),P=g.join(this.dirname,N);h.stat(P,function(z,O){return z&&z.code==="ENOENT"?(I("ENOENT ok",P),k.filename=N,W(null,0)):z?(I("err ".concat(z.code," ").concat(P)),W(z)):!O||k._needsNewFile(O.size)?k._incFile(function(){return k.stat(W)}):(k.filename=N,void W(null,O.size))})}},{key:"close",value:function(W){var k=this;this._stream&&this._stream.end(function(){W&&W(),k.emit("flush"),k.emit("closed")})}},{key:"_needsNewFile",value:function(W){return W=W||this._size,this.maxsize&&W>=this.maxsize}},{key:"_onError",value:function(W){this.emit("error",W)}},{key:"_setupStream",value:function(W){return W.on("error",this._onError),W}},{key:"_cleanupStream",value:function(W){return W.removeListener("error",this._onError),W}},{key:"_rotateFile",value:function(){var W=this;this._incFile(function(){return W.open()})}},{key:"_endStream",value:function(){var W=this,k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(){};this._dest?(this._stream.unpipe(this._dest),this._dest.end(function(){W._cleanupStream(W._dest),k()})):k()}},{key:"_createStream",value:function(W){var k=this,N=g.join(this.dirname,this.filename);I("create stream start",N,this.options);var P=h.createWriteStream(N,this.options).on("error",function(O){return I(O)}).on("close",function(){return I("close",P.path,P.bytesWritten)}).on("open",function(){I("file open ok",N),k.emit("open",N),W.pipe(P),k.rotatedWhileOpening&&(k._stream=new R,k._stream.setMaxListeners(30),k._rotateFile(),k.rotatedWhileOpening=!1,k._cleanupStream(P),W.end())});if(I("create stream ok",N),this.zippedArchive){var z=A.createGzip();return z.pipe(P),z}return P}},{key:"_incFile",value:function(W){I("_incFile",this.filename);var k=g.extname(this._basename),N=g.basename(this._basename,k);this.tailable?this._checkMaxFilesTailable(k,N,W):(this._created+=1,this._checkMaxFilesIncrementing(k,N,W))}},{key:"_getFile",value:function(){var W=g.extname(this._basename),k=g.basename(this._basename,W),N=this.rotationFormat?this.rotationFormat():this._created,P=!this.tailable&&this._created?"".concat(k).concat(N).concat(W):"".concat(k).concat(W);return this.zippedArchive&&!this.tailable?"".concat(P,".gz"):P}},{key:"_checkMaxFilesIncrementing",value:function(W,k,N){if(!this.maxFiles||this._created<this.maxFiles)return r(N);var P=this._created-this.maxFiles,z=P!==0?P:"",O=this.zippedArchive?".gz":"",p="".concat(k).concat(z).concat(W).concat(O),U=g.join(this.dirname,p);h.unlink(U,N)}},{key:"_checkMaxFilesTailable",value:function(W,k,N){var P=this,z=[];if(this.maxFiles){for(var O=this.zippedArchive?".gz":"",p=this.maxFiles-1;p>1;p--)z.push(function(U,V){var Q=this,ee="".concat(k).concat(U-1).concat(W).concat(O),ne=g.join(this.dirname,ee);h.exists(ne,function(Y){if(!Y)return V(null);ee="".concat(k).concat(U).concat(W).concat(O),h.rename(ne,g.join(Q.dirname,ee),V)})}.bind(this,p));b(z,function(){h.rename(g.join(P.dirname,"".concat(k).concat(W)),g.join(P.dirname,"".concat(k,"1").concat(W).concat(O)),N)})}}},{key:"_createLogDirIfNotExist",value:function(W){h.existsSync(W)||h.mkdirSync(W,{recursive:!0})}}])&&o(m.prototype,C),L}(d)}).call(this,n(15).setImmediate,n(5).Buffer)},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(l,o){return(0,r.default)(i.default,l,o)};var r=s(n(151)),i=s(n(155));function s(l){return l&&l.__esModule?l:{default:l}}e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=l(n(45)),i=l(n(25)),s=l(n(30));function l(o){return o&&o.__esModule?o:{default:o}}t.default=(0,s.default)((o,c,u)=>{var f=(0,r.default)(c)?[]:{};o(c,(E,_,h)=>{(0,i.default)(E)((g,...b)=>{b.length<2&&([b]=b),f[_]=b,h(g)})},E=>u(E,f))},3),e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(u){return(0,s.isAsync)(u)?function(...f){const E=f.pop();return o(u.apply(this,f),E)}:(0,r.default)(function(f,E){var _;try{_=u.apply(this,f)}catch(h){return E(h)}if(_&&typeof _.then=="function")return o(_,E);E(null,_)})};var r=l(n(153)),i=l(n(154)),s=n(25);function l(u){return u&&u.__esModule?u:{default:u}}function o(u,f){return u.then(E=>{c(f,null,E)},E=>{c(f,E&&E.message?E:new Error(E))})}function c(u,f,E){try{u(f,E)}catch(_){(0,i.default)(h=>{throw h},_)}}e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return function(...i){var s=i.pop();return r.call(this,i,s)}},e.exports=t.default},function(e,t,n){(function(r,i){Object.defineProperty(t,"__esModule",{value:!0}),t.fallback=u,t.wrap=f;var s,l=t.hasQueueMicrotask=typeof queueMicrotask=="function"&&queueMicrotask,o=t.hasSetImmediate=typeof r=="function"&&r,c=t.hasNextTick=typeof i=="object"&&typeof i.nextTick=="function";function u(E){setTimeout(E,0)}function f(E){return(_,...h)=>E(()=>_(...h))}s=l?queueMicrotask:o?r:c?i.nextTick:u,t.default=f(s)}).call(this,n(15).setImmediate,n(2))},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=s(n(66)),i=s(n(30));function s(l){return l&&l.__esModule?l:{default:l}}t.default=(0,i.default)(function(l,o,c){return(0,r.default)(l,1,o,c)},3),e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=u(n(67)),i=u(n(157)),s=u(n(68)),l=n(25),o=u(n(159)),c=u(n(46));function u(f){return f&&f.__esModule?f:{default:f}}t.default=f=>(E,_,h)=>{if(h=(0,r.default)(h),f<=0)throw new RangeError("concurrency limit cannot be less than 1");if(!E)return h(null);if((0,l.isAsyncGenerator)(E))return(0,o.default)(E,f,_,h);if((0,l.isAsyncIterable)(E))return(0,o.default)(E[Symbol.asyncIterator](),f,_,h);var g=(0,i.default)(E),b=!1,A=!1,j=0,F=!1;function M(d,I){if(!A)if(j-=1,d)b=!0,h(d);else if(d===!1)b=!0,A=!0;else{if(I===c.default||b&&j<=0)return b=!0,h(null);F||R()}}function R(){for(F=!0;j<f&&!b;){var d=g();if(d===null)return b=!0,void(j<=0&&h(null));j+=1,_(d.value,d.key,(0,s.default)(M))}F=!1}R()},e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(l){if((0,r.default)(l))return function(_){var h=-1,g=_.length;return function(){return++h<g?{value:_[h],key:h}:null}}(l);var o=(0,i.default)(l);return o?function(_){var h=-1;return function(){var g=_.next();return g.done?null:(h++,{value:g.value,key:h})}}(o):(c=l,u=c?Object.keys(c):[],f=-1,E=u.length,function _(){var h=u[++f];return h==="__proto__"?_():f<E?{value:c[h],key:h}:null});var c,u,f,E};var r=s(n(45)),i=s(n(158));function s(l){return l&&l.__esModule?l:{default:l}}e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return r[Symbol.iterator]&&r[Symbol.iterator]()},e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(l,o,c,u){let f=!1,E=!1,_=!1,h=0,g=0;function b(){h>=o||_||f||(_=!0,l.next().then(({value:F,done:M})=>{if(!E&&!f){if(_=!1,M)return f=!0,void(h<=0&&u(null));h++,c(F,g,A),g++,b()}}).catch(j))}function A(F,M){if(h-=1,!E)return F?j(F):F===!1?(f=!0,void(E=!0)):M===s.default||f&&h<=0?(f=!0,u(null)):void b()}function j(F){E||(_=!1,f=!0,u(F))}b()};var r,i=n(46),s=(r=i)&&r.__esModule?r:{default:r};e.exports=t.default},function(e,t,n){(function(r){var i=n(5).Buffer,s=n(161).Transform,l=n(169),o=n(13),c=n(74).ok,u=n(5).kMaxLength,f="Cannot create final Buffer. It would be larger than 0x"+u.toString(16)+" bytes";l.Z_MIN_WINDOWBITS=8,l.Z_MAX_WINDOWBITS=15,l.Z_DEFAULT_WINDOWBITS=15,l.Z_MIN_CHUNK=64,l.Z_MAX_CHUNK=1/0,l.Z_DEFAULT_CHUNK=16384,l.Z_MIN_MEMLEVEL=1,l.Z_MAX_MEMLEVEL=9,l.Z_DEFAULT_MEMLEVEL=8,l.Z_MIN_LEVEL=-1,l.Z_MAX_LEVEL=9,l.Z_DEFAULT_LEVEL=l.Z_DEFAULT_COMPRESSION;for(var E=Object.keys(l),_=0;_<E.length;_++){var h=E[_];h.match(/^Z/)&&Object.defineProperty(t,h,{enumerable:!0,value:l[h],writable:!1})}for(var g={Z_OK:l.Z_OK,Z_STREAM_END:l.Z_STREAM_END,Z_NEED_DICT:l.Z_NEED_DICT,Z_ERRNO:l.Z_ERRNO,Z_STREAM_ERROR:l.Z_STREAM_ERROR,Z_DATA_ERROR:l.Z_DATA_ERROR,Z_MEM_ERROR:l.Z_MEM_ERROR,Z_BUF_ERROR:l.Z_BUF_ERROR,Z_VERSION_ERROR:l.Z_VERSION_ERROR},b=Object.keys(g),A=0;A<b.length;A++){var j=b[A];g[g[j]]=j}function F(k,N,P){var z=[],O=0;function p(){for(var V;(V=k.read())!==null;)z.push(V),O+=V.length;k.once("readable",p)}function U(){var V,Q=null;O>=u?Q=new RangeError(f):V=i.concat(z,O),z=[],k.close(),P(Q,V)}k.on("error",function(V){k.removeListener("end",U),k.removeListener("readable",p),P(V)}),k.on("end",U),k.end(N),p()}function M(k,N){if(typeof N=="string"&&(N=i.from(N)),!i.isBuffer(N))throw new TypeError("Not a string or buffer");var P=k._finishFlushFlag;return k._processChunk(N,P)}function R(k){if(!(this instanceof R))return new R(k);w.call(this,k,l.DEFLATE)}function d(k){if(!(this instanceof d))return new d(k);w.call(this,k,l.INFLATE)}function I(k){if(!(this instanceof I))return new I(k);w.call(this,k,l.GZIP)}function $(k){if(!(this instanceof $))return new $(k);w.call(this,k,l.GUNZIP)}function q(k){if(!(this instanceof q))return new q(k);w.call(this,k,l.DEFLATERAW)}function y(k){if(!(this instanceof y))return new y(k);w.call(this,k,l.INFLATERAW)}function m(k){if(!(this instanceof m))return new m(k);w.call(this,k,l.UNZIP)}function C(k){return k===l.Z_NO_FLUSH||k===l.Z_PARTIAL_FLUSH||k===l.Z_SYNC_FLUSH||k===l.Z_FULL_FLUSH||k===l.Z_FINISH||k===l.Z_BLOCK}function w(k,N){var P=this;if(this._opts=k=k||{},this._chunkSize=k.chunkSize||t.Z_DEFAULT_CHUNK,s.call(this,k),k.flush&&!C(k.flush))throw new Error("Invalid flush flag: "+k.flush);if(k.finishFlush&&!C(k.finishFlush))throw new Error("Invalid flush flag: "+k.finishFlush);if(this._flushFlag=k.flush||l.Z_NO_FLUSH,this._finishFlushFlag=k.finishFlush!==void 0?k.finishFlush:l.Z_FINISH,k.chunkSize&&(k.chunkSize<t.Z_MIN_CHUNK||k.chunkSize>t.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+k.chunkSize);if(k.windowBits&&(k.windowBits<t.Z_MIN_WINDOWBITS||k.windowBits>t.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+k.windowBits);if(k.level&&(k.level<t.Z_MIN_LEVEL||k.level>t.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+k.level);if(k.memLevel&&(k.memLevel<t.Z_MIN_MEMLEVEL||k.memLevel>t.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+k.memLevel);if(k.strategy&&k.strategy!=t.Z_FILTERED&&k.strategy!=t.Z_HUFFMAN_ONLY&&k.strategy!=t.Z_RLE&&k.strategy!=t.Z_FIXED&&k.strategy!=t.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+k.strategy);if(k.dictionary&&!i.isBuffer(k.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new l.Zlib(N);var z=this;this._hadError=!1,this._handle.onerror=function(U,V){L(z),z._hadError=!0;var Q=new Error(U);Q.errno=V,Q.code=t.codes[V],z.emit("error",Q)};var O=t.Z_DEFAULT_COMPRESSION;typeof k.level=="number"&&(O=k.level);var p=t.Z_DEFAULT_STRATEGY;typeof k.strategy=="number"&&(p=k.strategy),this._handle.init(k.windowBits||t.Z_DEFAULT_WINDOWBITS,O,k.memLevel||t.Z_DEFAULT_MEMLEVEL,p,k.dictionary),this._buffer=i.allocUnsafe(this._chunkSize),this._offset=0,this._level=O,this._strategy=p,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!P._handle},configurable:!0,enumerable:!0})}function L(k,N){N&&r.nextTick(N),k._handle&&(k._handle.close(),k._handle=null)}function W(k){k.emit("close")}Object.defineProperty(t,"codes",{enumerable:!0,value:Object.freeze(g),writable:!1}),t.Deflate=R,t.Inflate=d,t.Gzip=I,t.Gunzip=$,t.DeflateRaw=q,t.InflateRaw=y,t.Unzip=m,t.createDeflate=function(k){return new R(k)},t.createInflate=function(k){return new d(k)},t.createDeflateRaw=function(k){return new q(k)},t.createInflateRaw=function(k){return new y(k)},t.createGzip=function(k){return new I(k)},t.createGunzip=function(k){return new $(k)},t.createUnzip=function(k){return new m(k)},t.deflate=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new R(N),k,P)},t.deflateSync=function(k,N){return M(new R(N),k)},t.gzip=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new I(N),k,P)},t.gzipSync=function(k,N){return M(new I(N),k)},t.deflateRaw=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new q(N),k,P)},t.deflateRawSync=function(k,N){return M(new q(N),k)},t.unzip=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new m(N),k,P)},t.unzipSync=function(k,N){return M(new m(N),k)},t.inflate=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new d(N),k,P)},t.inflateSync=function(k,N){return M(new d(N),k)},t.gunzip=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new $(N),k,P)},t.gunzipSync=function(k,N){return M(new $(N),k)},t.inflateRaw=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new y(N),k,P)},t.inflateRawSync=function(k,N){return M(new y(N),k)},o.inherits(w,s),w.prototype.params=function(k,N,P){if(k<t.Z_MIN_LEVEL||k>t.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+k);if(N!=t.Z_FILTERED&&N!=t.Z_HUFFMAN_ONLY&&N!=t.Z_RLE&&N!=t.Z_FIXED&&N!=t.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+N);if(this._level!==k||this._strategy!==N){var z=this;this.flush(l.Z_SYNC_FLUSH,function(){c(z._handle,"zlib binding closed"),z._handle.params(k,N),z._hadError||(z._level=k,z._strategy=N,P&&P())})}else r.nextTick(P)},w.prototype.reset=function(){return c(this._handle,"zlib binding closed"),this._handle.reset()},w.prototype._flush=function(k){this._transform(i.alloc(0),"",k)},w.prototype.flush=function(k,N){var P=this,z=this._writableState;(typeof k=="function"||k===void 0&&!N)&&(N=k,k=l.Z_FULL_FLUSH),z.ended?N&&r.nextTick(N):z.ending?N&&this.once("end",N):z.needDrain?N&&this.once("drain",function(){return P.flush(k,N)}):(this._flushFlag=k,this.write(i.alloc(0),"",N))},w.prototype.close=function(k){L(this,k),r.nextTick(W,this)},w.prototype._transform=function(k,N,P){var z,O=this._writableState,p=(O.ending||O.ended)&&(!k||O.length===k.length);return k===null||i.isBuffer(k)?this._handle?(p?z=this._finishFlushFlag:(z=this._flushFlag,k.length>=O.length&&(this._flushFlag=this._opts.flush||l.Z_NO_FLUSH)),void this._processChunk(k,z,P)):P(new Error("zlib binding closed")):P(new Error("invalid input"))},w.prototype._processChunk=function(k,N,P){var z=k&&k.length,O=this._chunkSize-this._offset,p=0,U=this,V=typeof P=="function";if(!V){var Q,ee=[],ne=0;this.on("error",function(B){Q=B}),c(this._handle,"zlib binding closed");do var Y=this._handle.writeSync(N,k,p,z,this._buffer,this._offset,O);while(!this._hadError&&T(Y[0],Y[1]));if(this._hadError)throw Q;if(ne>=u)throw L(this),new RangeError(f);var G=i.concat(ee,ne);return L(this),G}c(this._handle,"zlib binding closed");var S=this._handle.write(N,k,p,z,this._buffer,this._offset,O);function T(B,J){if(this&&(this.buffer=null,this.callback=null),!U._hadError){var K=O-J;if(c(K>=0,"have should not go down"),K>0){var re=U._buffer.slice(U._offset,U._offset+K);U._offset+=K,V?U.push(re):(ee.push(re),ne+=re.length)}if((J===0||U._offset>=U._chunkSize)&&(O=U._chunkSize,U._offset=0,U._buffer=i.allocUnsafe(U._chunkSize)),J===0){if(p+=z-B,z=B,!V)return!0;var se=U._handle.write(N,k,p,z,U._buffer,U._offset,U._chunkSize);return se.callback=T,void(se.buffer=k)}if(!V)return!1;P()}}S.buffer=k,S.callback=T},o.inherits(R,w),o.inherits(d,w),o.inherits(I,w),o.inherits($,w),o.inherits(q,w),o.inherits(y,w),o.inherits(m,w)}).call(this,n(2))},function(e,t,n){e.exports=i;var r=n(21).EventEmitter;function i(){r.call(this)}n(7)(i,r),i.Readable=n(31),i.Writable=n(73),i.Duplex=n(166),i.Transform=n(167),i.PassThrough=n(168),i.Stream=i,i.prototype.pipe=function(s,l){var o=this;function c(b){s.writable&&s.write(b)===!1&&o.pause&&o.pause()}function u(){o.readable&&o.resume&&o.resume()}o.on("data",c),s.on("drain",u),s._isStdio||l&&l.end===!1||(o.on("end",E),o.on("close",_));var f=!1;function E(){f||(f=!0,s.end())}function _(){f||(f=!0,typeof s.destroy=="function"&&s.destroy())}function h(b){if(g(),r.listenerCount(this,"error")===0)throw b}function g(){o.removeListener("data",c),s.removeListener("drain",u),o.removeListener("end",E),o.removeListener("close",_),o.removeListener("error",h),s.removeListener("error",h),o.removeListener("end",g),o.removeListener("close",g),s.removeListener("close",g)}return o.on("error",h),s.on("error",h),o.on("end",g),o.on("close",g),s.on("close",g),s.emit("pipe",o),s}},function(e,t){},function(e,t,n){var r=n(47).Buffer,i=n(164);e.exports=function(){function s(){(function(l,o){if(!(l instanceof o))throw new TypeError("Cannot call a class as a function")})(this,s),this.head=null,this.tail=null,this.length=0}return s.prototype.push=function(l){var o={data:l,next:null};this.length>0?this.tail.next=o:this.head=o,this.tail=o,++this.length},s.prototype.unshift=function(l){var o={data:l,next:this.head};this.length===0&&(this.tail=o),this.head=o,++this.length},s.prototype.shift=function(){if(this.length!==0){var l=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,l}},s.prototype.clear=function(){this.head=this.tail=null,this.length=0},s.prototype.join=function(l){if(this.length===0)return"";for(var o=this.head,c=""+o.data;o=o.next;)c+=l+o.data;return c},s.prototype.concat=function(l){if(this.length===0)return r.alloc(0);if(this.length===1)return this.head.data;for(var o,c,u,f=r.allocUnsafe(l>>>0),E=this.head,_=0;E;)o=E.data,c=f,u=_,o.copy(c,u),_+=E.data.length,E=E.next;return f},s}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var s=i.inspect({length:this.length});return this.constructor.name+" "+s})},function(e,t){},function(e,t,n){e.exports=s;var r=n(72),i=n(17);function s(l){if(!(this instanceof s))return new s(l);r.call(this,l)}i.inherits=n(7),i.inherits(s,r),s.prototype._transform=function(l,o,c){c(null,l)}},function(e,t,n){e.exports=n(23)},function(e,t,n){e.exports=n(31).Transform},function(e,t,n){e.exports=n(31).PassThrough},function(e,t,n){(function(r,i){var s=n(74),l=n(171),o=n(172),c=n(175),u=n(178);for(var f in u)t[f]=u[f];t.NONE=0,t.DEFLATE=1,t.INFLATE=2,t.GZIP=3,t.GUNZIP=4,t.DEFLATERAW=5,t.INFLATERAW=6,t.UNZIP=7;function E(_){if(typeof _!="number"||_<t.DEFLATE||_>t.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=_,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}E.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,s(this.init_done,"close before init"),s(this.mode<=t.UNZIP),this.mode===t.DEFLATE||this.mode===t.GZIP||this.mode===t.DEFLATERAW?o.deflateEnd(this.strm):this.mode!==t.INFLATE&&this.mode!==t.GUNZIP&&this.mode!==t.INFLATERAW&&this.mode!==t.UNZIP||c.inflateEnd(this.strm),this.mode=t.NONE,this.dictionary=null)},E.prototype.write=function(_,h,g,b,A,j,F){return this._write(!0,_,h,g,b,A,j,F)},E.prototype.writeSync=function(_,h,g,b,A,j,F){return this._write(!1,_,h,g,b,A,j,F)},E.prototype._write=function(_,h,g,b,A,j,F,M){if(s.equal(arguments.length,8),s(this.init_done,"write before init"),s(this.mode!==t.NONE,"already finalized"),s.equal(!1,this.write_in_progress,"write already in progress"),s.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,s.equal(!1,h===void 0,"must provide flush value"),this.write_in_progress=!0,h!==t.Z_NO_FLUSH&&h!==t.Z_PARTIAL_FLUSH&&h!==t.Z_SYNC_FLUSH&&h!==t.Z_FULL_FLUSH&&h!==t.Z_FINISH&&h!==t.Z_BLOCK)throw new Error("Invalid flush value");if(g==null&&(g=r.alloc(0),A=0,b=0),this.strm.avail_in=A,this.strm.input=g,this.strm.next_in=b,this.strm.avail_out=M,this.strm.output=j,this.strm.next_out=F,this.flush=h,!_)return this._process(),this._checkError()?this._afterSync():void 0;var R=this;return i.nextTick(function(){R._process(),R._after()}),this},E.prototype._afterSync=function(){var _=this.strm.avail_out,h=this.strm.avail_in;return this.write_in_progress=!1,[h,_]},E.prototype._process=function(){var _=null;switch(this.mode){case t.DEFLATE:case t.GZIP:case t.DEFLATERAW:this.err=o.deflate(this.strm,this.flush);break;case t.UNZIP:switch(this.strm.avail_in>0&&(_=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(_===null)break;if(this.strm.input[_]!==31){this.mode=t.INFLATE;break}if(this.gzip_id_bytes_read=1,_++,this.strm.avail_in===1)break;case 1:if(_===null)break;this.strm.input[_]===139?(this.gzip_id_bytes_read=2,this.mode=t.GUNZIP):this.mode=t.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case t.INFLATE:case t.GUNZIP:case t.INFLATERAW:for(this.err=c.inflate(this.strm,this.flush),this.err===t.Z_NEED_DICT&&this.dictionary&&(this.err=c.inflateSetDictionary(this.strm,this.dictionary),this.err===t.Z_OK?this.err=c.inflate(this.strm,this.flush):this.err===t.Z_DATA_ERROR&&(this.err=t.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===t.GUNZIP&&this.err===t.Z_STREAM_END&&this.strm.next_in[0]!==0;)this.reset(),this.err=c.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},E.prototype._checkError=function(){switch(this.err){case t.Z_OK:case t.Z_BUF_ERROR:if(this.strm.avail_out!==0&&this.flush===t.Z_FINISH)return this._error("unexpected end of file"),!1;break;case t.Z_STREAM_END:break;case t.Z_NEED_DICT:return this.dictionary==null?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},E.prototype._after=function(){if(this._checkError()){var _=this.strm.avail_out,h=this.strm.avail_in;this.write_in_progress=!1,this.callback(h,_),this.pending_close&&this.close()}},E.prototype._error=function(_){this.strm.msg&&(_=this.strm.msg),this.onerror(_,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},E.prototype.init=function(_,h,g,b,A){s(arguments.length===4||arguments.length===5,"init(windowBits, level, memLevel, strategy, [dictionary])"),s(_>=8&&_<=15,"invalid windowBits"),s(h>=-1&&h<=9,"invalid compression level"),s(g>=1&&g<=9,"invalid memlevel"),s(b===t.Z_FILTERED||b===t.Z_HUFFMAN_ONLY||b===t.Z_RLE||b===t.Z_FIXED||b===t.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(h,_,g,b,A),this._setDictionary()},E.prototype.params=function(){throw new Error("deflateParams Not supported")},E.prototype.reset=function(){this._reset(),this._setDictionary()},E.prototype._init=function(_,h,g,b,A){switch(this.level=_,this.windowBits=h,this.memLevel=g,this.strategy=b,this.flush=t.Z_NO_FLUSH,this.err=t.Z_OK,this.mode!==t.GZIP&&this.mode!==t.GUNZIP||(this.windowBits+=16),this.mode===t.UNZIP&&(this.windowBits+=32),this.mode!==t.DEFLATERAW&&this.mode!==t.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new l,this.mode){case t.DEFLATE:case t.GZIP:case t.DEFLATERAW:this.err=o.deflateInit2(this.strm,this.level,t.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case t.INFLATE:case t.GUNZIP:case t.INFLATERAW:case t.UNZIP:this.err=c.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==t.Z_OK&&this._error("Init error"),this.dictionary=A,this.write_in_progress=!1,this.init_done=!0},E.prototype._setDictionary=function(){if(this.dictionary!=null){switch(this.err=t.Z_OK,this.mode){case t.DEFLATE:case t.DEFLATERAW:this.err=o.deflateSetDictionary(this.strm,this.dictionary)}this.err!==t.Z_OK&&this._error("Failed to set dictionary")}},E.prototype._reset=function(){switch(this.err=t.Z_OK,this.mode){case t.DEFLATE:case t.DEFLATERAW:case t.GZIP:this.err=o.deflateReset(this.strm);break;case t.INFLATE:case t.INFLATERAW:case t.GUNZIP:this.err=c.inflateReset(this.strm)}this.err!==t.Z_OK&&this._error("Failed to reset stream")},t.Zlib=E}).call(this,n(5).Buffer,n(2))},function(e,t,n){var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function l(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}e.exports=function(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var c={},u=0;u<10;u++)c["_"+String.fromCharCode(u)]=u;if(Object.getOwnPropertyNames(c).map(function(E){return c[E]}).join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(E){f[E]=E}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}()?Object.assign:function(o,c){for(var u,f,E=l(o),_=1;_<arguments.length;_++){for(var h in u=Object(arguments[_]))i.call(u,h)&&(E[h]=u[h]);if(r){f=r(u);for(var g=0;g<f.length;g++)s.call(u,f[g])&&(E[f[g]]=u[f[g]])}}return E}},function(e,t,n){e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},function(e,t,n){var r,i=n(37),s=n(173),l=n(75),o=n(76),c=n(174);function u(y,m){return y.msg=c[m],m}function f(y){return(y<<1)-(y>4?9:0)}function E(y){for(var m=y.length;--m>=0;)y[m]=0}function _(y){var m=y.state,C=m.pending;C>y.avail_out&&(C=y.avail_out),C!==0&&(i.arraySet(y.output,m.pending_buf,m.pending_out,C,y.next_out),y.next_out+=C,m.pending_out+=C,y.total_out+=C,y.avail_out-=C,m.pending-=C,m.pending===0&&(m.pending_out=0))}function h(y,m){s._tr_flush_block(y,y.block_start>=0?y.block_start:-1,y.strstart-y.block_start,m),y.block_start=y.strstart,_(y.strm)}function g(y,m){y.pending_buf[y.pending++]=m}function b(y,m){y.pending_buf[y.pending++]=m>>>8&255,y.pending_buf[y.pending++]=255&m}function A(y,m){var C,w,L=y.max_chain_length,W=y.strstart,k=y.prev_length,N=y.nice_match,P=y.strstart>y.w_size-262?y.strstart-(y.w_size-262):0,z=y.window,O=y.w_mask,p=y.prev,U=y.strstart+258,V=z[W+k-1],Q=z[W+k];y.prev_length>=y.good_match&&(L>>=2),N>y.lookahead&&(N=y.lookahead);do if(z[(C=m)+k]===Q&&z[C+k-1]===V&&z[C]===z[W]&&z[++C]===z[W+1]){W+=2,C++;do;while(z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&W<U);if(w=258-(U-W),W=U-258,w>k){if(y.match_start=m,k=w,w>=N)break;V=z[W+k-1],Q=z[W+k]}}while((m=p[m&O])>P&&--L!=0);return k<=y.lookahead?k:y.lookahead}function j(y){var m,C,w,L,W,k,N,P,z,O,p=y.w_size;do{if(L=y.window_size-y.lookahead-y.strstart,y.strstart>=p+(p-262)){i.arraySet(y.window,y.window,p,p,0),y.match_start-=p,y.strstart-=p,y.block_start-=p,m=C=y.hash_size;do w=y.head[--m],y.head[m]=w>=p?w-p:0;while(--C);m=C=p;do w=y.prev[--m],y.prev[m]=w>=p?w-p:0;while(--C);L+=p}if(y.strm.avail_in===0)break;if(k=y.strm,N=y.window,P=y.strstart+y.lookahead,z=L,O=void 0,(O=k.avail_in)>z&&(O=z),C=O===0?0:(k.avail_in-=O,i.arraySet(N,k.input,k.next_in,O,P),k.state.wrap===1?k.adler=l(k.adler,N,O,P):k.state.wrap===2&&(k.adler=o(k.adler,N,O,P)),k.next_in+=O,k.total_in+=O,O),y.lookahead+=C,y.lookahead+y.insert>=3)for(W=y.strstart-y.insert,y.ins_h=y.window[W],y.ins_h=(y.ins_h<<y.hash_shift^y.window[W+1])&y.hash_mask;y.insert&&(y.ins_h=(y.ins_h<<y.hash_shift^y.window[W+3-1])&y.hash_mask,y.prev[W&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=W,W++,y.insert--,!(y.lookahead+y.insert<3)););}while(y.lookahead<262&&y.strm.avail_in!==0)}function F(y,m){for(var C,w;;){if(y.lookahead<262){if(j(y),y.lookahead<262&&m===0)return 1;if(y.lookahead===0)break}if(C=0,y.lookahead>=3&&(y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+3-1])&y.hash_mask,C=y.prev[y.strstart&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=y.strstart),C!==0&&y.strstart-C<=y.w_size-262&&(y.match_length=A(y,C)),y.match_length>=3)if(w=s._tr_tally(y,y.strstart-y.match_start,y.match_length-3),y.lookahead-=y.match_length,y.match_length<=y.max_lazy_match&&y.lookahead>=3){y.match_length--;do y.strstart++,y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+3-1])&y.hash_mask,C=y.prev[y.strstart&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=y.strstart;while(--y.match_length!=0);y.strstart++}else y.strstart+=y.match_length,y.match_length=0,y.ins_h=y.window[y.strstart],y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+1])&y.hash_mask;else w=s._tr_tally(y,0,y.window[y.strstart]),y.lookahead--,y.strstart++;if(w&&(h(y,!1),y.strm.avail_out===0))return 1}return y.insert=y.strstart<2?y.strstart:2,m===4?(h(y,!0),y.strm.avail_out===0?3:4):y.last_lit&&(h(y,!1),y.strm.avail_out===0)?1:2}function M(y,m){for(var C,w,L;;){if(y.lookahead<262){if(j(y),y.lookahead<262&&m===0)return 1;if(y.lookahead===0)break}if(C=0,y.lookahead>=3&&(y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+3-1])&y.hash_mask,C=y.prev[y.strstart&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=y.strstart),y.prev_length=y.match_length,y.prev_match=y.match_start,y.match_length=2,C!==0&&y.prev_length<y.max_lazy_match&&y.strstart-C<=y.w_size-262&&(y.match_length=A(y,C),y.match_length<=5&&(y.strategy===1||y.match_length===3&&y.strstart-y.match_start>4096)&&(y.match_length=2)),y.prev_length>=3&&y.match_length<=y.prev_length){L=y.strstart+y.lookahead-3,w=s._tr_tally(y,y.strstart-1-y.prev_match,y.prev_length-3),y.lookahead-=y.prev_length-1,y.prev_length-=2;do++y.strstart<=L&&(y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+3-1])&y.hash_mask,C=y.prev[y.strstart&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=y.strstart);while(--y.prev_length!=0);if(y.match_available=0,y.match_length=2,y.strstart++,w&&(h(y,!1),y.strm.avail_out===0))return 1}else if(y.match_available){if((w=s._tr_tally(y,0,y.window[y.strstart-1]))&&h(y,!1),y.strstart++,y.lookahead--,y.strm.avail_out===0)return 1}else y.match_available=1,y.strstart++,y.lookahead--}return y.match_available&&(w=s._tr_tally(y,0,y.window[y.strstart-1]),y.match_available=0),y.insert=y.strstart<2?y.strstart:2,m===4?(h(y,!0),y.strm.avail_out===0?3:4):y.last_lit&&(h(y,!1),y.strm.avail_out===0)?1:2}function R(y,m,C,w,L){this.good_length=y,this.max_lazy=m,this.nice_length=C,this.max_chain=w,this.func=L}function d(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),E(this.dyn_ltree),E(this.dyn_dtree),E(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),E(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),E(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function I(y){var m;return y&&y.state?(y.total_in=y.total_out=0,y.data_type=2,(m=y.state).pending=0,m.pending_out=0,m.wrap<0&&(m.wrap=-m.wrap),m.status=m.wrap?42:113,y.adler=m.wrap===2?0:1,m.last_flush=0,s._tr_init(m),0):u(y,-2)}function $(y){var m,C=I(y);return C===0&&((m=y.state).window_size=2*m.w_size,E(m.head),m.max_lazy_match=r[m.level].max_lazy,m.good_match=r[m.level].good_length,m.nice_match=r[m.level].nice_length,m.max_chain_length=r[m.level].max_chain,m.strstart=0,m.block_start=0,m.lookahead=0,m.insert=0,m.match_length=m.prev_length=2,m.match_available=0,m.ins_h=0),C}function q(y,m,C,w,L,W){if(!y)return-2;var k=1;if(m===-1&&(m=6),w<0?(k=0,w=-w):w>15&&(k=2,w-=16),L<1||L>9||C!==8||w<8||w>15||m<0||m>9||W<0||W>4)return u(y,-2);w===8&&(w=9);var N=new d;return y.state=N,N.strm=y,N.wrap=k,N.gzhead=null,N.w_bits=w,N.w_size=1<<N.w_bits,N.w_mask=N.w_size-1,N.hash_bits=L+7,N.hash_size=1<<N.hash_bits,N.hash_mask=N.hash_size-1,N.hash_shift=~~((N.hash_bits+3-1)/3),N.window=new i.Buf8(2*N.w_size),N.head=new i.Buf16(N.hash_size),N.prev=new i.Buf16(N.w_size),N.lit_bufsize=1<<L+6,N.pending_buf_size=4*N.lit_bufsize,N.pending_buf=new i.Buf8(N.pending_buf_size),N.d_buf=1*N.lit_bufsize,N.l_buf=3*N.lit_bufsize,N.level=m,N.strategy=W,N.method=C,$(y)}r=[new R(0,0,0,0,function(y,m){var C=65535;for(C>y.pending_buf_size-5&&(C=y.pending_buf_size-5);;){if(y.lookahead<=1){if(j(y),y.lookahead===0&&m===0)return 1;if(y.lookahead===0)break}y.strstart+=y.lookahead,y.lookahead=0;var w=y.block_start+C;if((y.strstart===0||y.strstart>=w)&&(y.lookahead=y.strstart-w,y.strstart=w,h(y,!1),y.strm.avail_out===0)||y.strstart-y.block_start>=y.w_size-262&&(h(y,!1),y.strm.avail_out===0))return 1}return y.insert=0,m===4?(h(y,!0),y.strm.avail_out===0?3:4):(y.strstart>y.block_start&&(h(y,!1),y.strm.avail_out),1)}),new R(4,4,8,4,F),new R(4,5,16,8,F),new R(4,6,32,32,F),new R(4,4,16,16,M),new R(8,16,32,32,M),new R(8,16,128,128,M),new R(8,32,128,256,M),new R(32,128,258,1024,M),new R(32,258,258,4096,M)],t.deflateInit=function(y,m){return q(y,m,8,15,8,0)},t.deflateInit2=q,t.deflateReset=$,t.deflateResetKeep=I,t.deflateSetHeader=function(y,m){return y&&y.state?y.state.wrap!==2?-2:(y.state.gzhead=m,0):-2},t.deflate=function(y,m){var C,w,L,W;if(!y||!y.state||m>5||m<0)return y?u(y,-2):-2;if(w=y.state,!y.output||!y.input&&y.avail_in!==0||w.status===666&&m!==4)return u(y,y.avail_out===0?-5:-2);if(w.strm=y,C=w.last_flush,w.last_flush=m,w.status===42)if(w.wrap===2)y.adler=0,g(w,31),g(w,139),g(w,8),w.gzhead?(g(w,(w.gzhead.text?1:0)+(w.gzhead.hcrc?2:0)+(w.gzhead.extra?4:0)+(w.gzhead.name?8:0)+(w.gzhead.comment?16:0)),g(w,255&w.gzhead.time),g(w,w.gzhead.time>>8&255),g(w,w.gzhead.time>>16&255),g(w,w.gzhead.time>>24&255),g(w,w.level===9?2:w.strategy>=2||w.level<2?4:0),g(w,255&w.gzhead.os),w.gzhead.extra&&w.gzhead.extra.length&&(g(w,255&w.gzhead.extra.length),g(w,w.gzhead.extra.length>>8&255)),w.gzhead.hcrc&&(y.adler=o(y.adler,w.pending_buf,w.pending,0)),w.gzindex=0,w.status=69):(g(w,0),g(w,0),g(w,0),g(w,0),g(w,0),g(w,w.level===9?2:w.strategy>=2||w.level<2?4:0),g(w,3),w.status=113);else{var k=8+(w.w_bits-8<<4)<<8;k|=(w.strategy>=2||w.level<2?0:w.level<6?1:w.level===6?2:3)<<6,w.strstart!==0&&(k|=32),k+=31-k%31,w.status=113,b(w,k),w.strstart!==0&&(b(w,y.adler>>>16),b(w,65535&y.adler)),y.adler=1}if(w.status===69)if(w.gzhead.extra){for(L=w.pending;w.gzindex<(65535&w.gzhead.extra.length)&&(w.pending!==w.pending_buf_size||(w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),_(y),L=w.pending,w.pending!==w.pending_buf_size));)g(w,255&w.gzhead.extra[w.gzindex]),w.gzindex++;w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),w.gzindex===w.gzhead.extra.length&&(w.gzindex=0,w.status=73)}else w.status=73;if(w.status===73)if(w.gzhead.name){L=w.pending;do{if(w.pending===w.pending_buf_size&&(w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),_(y),L=w.pending,w.pending===w.pending_buf_size)){W=1;break}W=w.gzindex<w.gzhead.name.length?255&w.gzhead.name.charCodeAt(w.gzindex++):0,g(w,W)}while(W!==0);w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),W===0&&(w.gzindex=0,w.status=91)}else w.status=91;if(w.status===91)if(w.gzhead.comment){L=w.pending;do{if(w.pending===w.pending_buf_size&&(w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),_(y),L=w.pending,w.pending===w.pending_buf_size)){W=1;break}W=w.gzindex<w.gzhead.comment.length?255&w.gzhead.comment.charCodeAt(w.gzindex++):0,g(w,W)}while(W!==0);w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),W===0&&(w.status=103)}else w.status=103;if(w.status===103&&(w.gzhead.hcrc?(w.pending+2>w.pending_buf_size&&_(y),w.pending+2<=w.pending_buf_size&&(g(w,255&y.adler),g(w,y.adler>>8&255),y.adler=0,w.status=113)):w.status=113),w.pending!==0){if(_(y),y.avail_out===0)return w.last_flush=-1,0}else if(y.avail_in===0&&f(m)<=f(C)&&m!==4)return u(y,-5);if(w.status===666&&y.avail_in!==0)return u(y,-5);if(y.avail_in!==0||w.lookahead!==0||m!==0&&w.status!==666){var N=w.strategy===2?function(P,z){for(var O;;){if(P.lookahead===0&&(j(P),P.lookahead===0)){if(z===0)return 1;break}if(P.match_length=0,O=s._tr_tally(P,0,P.window[P.strstart]),P.lookahead--,P.strstart++,O&&(h(P,!1),P.strm.avail_out===0))return 1}return P.insert=0,z===4?(h(P,!0),P.strm.avail_out===0?3:4):P.last_lit&&(h(P,!1),P.strm.avail_out===0)?1:2}(w,m):w.strategy===3?function(P,z){for(var O,p,U,V,Q=P.window;;){if(P.lookahead<=258){if(j(P),P.lookahead<=258&&z===0)return 1;if(P.lookahead===0)break}if(P.match_length=0,P.lookahead>=3&&P.strstart>0&&(p=Q[U=P.strstart-1])===Q[++U]&&p===Q[++U]&&p===Q[++U]){V=P.strstart+258;do;while(p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&U<V);P.match_length=258-(V-U),P.match_length>P.lookahead&&(P.match_length=P.lookahead)}if(P.match_length>=3?(O=s._tr_tally(P,1,P.match_length-3),P.lookahead-=P.match_length,P.strstart+=P.match_length,P.match_length=0):(O=s._tr_tally(P,0,P.window[P.strstart]),P.lookahead--,P.strstart++),O&&(h(P,!1),P.strm.avail_out===0))return 1}return P.insert=0,z===4?(h(P,!0),P.strm.avail_out===0?3:4):P.last_lit&&(h(P,!1),P.strm.avail_out===0)?1:2}(w,m):r[w.level].func(w,m);if(N!==3&&N!==4||(w.status=666),N===1||N===3)return y.avail_out===0&&(w.last_flush=-1),0;if(N===2&&(m===1?s._tr_align(w):m!==5&&(s._tr_stored_block(w,0,0,!1),m===3&&(E(w.head),w.lookahead===0&&(w.strstart=0,w.block_start=0,w.insert=0))),_(y),y.avail_out===0))return w.last_flush=-1,0}return m!==4?0:w.wrap<=0?1:(w.wrap===2?(g(w,255&y.adler),g(w,y.adler>>8&255),g(w,y.adler>>16&255),g(w,y.adler>>24&255),g(w,255&y.total_in),g(w,y.total_in>>8&255),g(w,y.total_in>>16&255),g(w,y.total_in>>24&255)):(b(w,y.adler>>>16),b(w,65535&y.adler)),_(y),w.wrap>0&&(w.wrap=-w.wrap),w.pending!==0?0:1)},t.deflateEnd=function(y){var m;return y&&y.state?(m=y.state.status)!==42&&m!==69&&m!==73&&m!==91&&m!==103&&m!==113&&m!==666?u(y,-2):(y.state=null,m===113?u(y,-3):0):-2},t.deflateSetDictionary=function(y,m){var C,w,L,W,k,N,P,z,O=m.length;if(!y||!y.state||(W=(C=y.state).wrap)===2||W===1&&C.status!==42||C.lookahead)return-2;for(W===1&&(y.adler=l(y.adler,m,O,0)),C.wrap=0,O>=C.w_size&&(W===0&&(E(C.head),C.strstart=0,C.block_start=0,C.insert=0),z=new i.Buf8(C.w_size),i.arraySet(z,m,O-C.w_size,C.w_size,0),m=z,O=C.w_size),k=y.avail_in,N=y.next_in,P=y.input,y.avail_in=O,y.next_in=0,y.input=m,j(C);C.lookahead>=3;){w=C.strstart,L=C.lookahead-2;do C.ins_h=(C.ins_h<<C.hash_shift^C.window[w+3-1])&C.hash_mask,C.prev[w&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=w,w++;while(--L);C.strstart=w,C.lookahead=2,j(C)}return C.strstart+=C.lookahead,C.block_start=C.strstart,C.insert=C.lookahead,C.lookahead=0,C.match_length=C.prev_length=2,C.match_available=0,y.next_in=N,y.input=P,y.avail_in=k,C.wrap=W,0},t.deflateInfo="pako deflate (from Nodeca project)"},function(e,t,n){var r=n(37);function i(p){for(var U=p.length;--U>=0;)p[U]=0}var s=[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],l=[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],o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],c=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],u=new Array(576);i(u);var f=new Array(60);i(f);var E=new Array(512);i(E);var _=new Array(256);i(_);var h=new Array(29);i(h);var g,b,A,j=new Array(30);function F(p,U,V,Q,ee){this.static_tree=p,this.extra_bits=U,this.extra_base=V,this.elems=Q,this.max_length=ee,this.has_stree=p&&p.length}function M(p,U){this.dyn_tree=p,this.max_code=0,this.stat_desc=U}function R(p){return p<256?E[p]:E[256+(p>>>7)]}function d(p,U){p.pending_buf[p.pending++]=255&U,p.pending_buf[p.pending++]=U>>>8&255}function I(p,U,V){p.bi_valid>16-V?(p.bi_buf|=U<<p.bi_valid&65535,d(p,p.bi_buf),p.bi_buf=U>>16-p.bi_valid,p.bi_valid+=V-16):(p.bi_buf|=U<<p.bi_valid&65535,p.bi_valid+=V)}function $(p,U,V){I(p,V[2*U],V[2*U+1])}function q(p,U){var V=0;do V|=1&p,p>>>=1,V<<=1;while(--U>0);return V>>>1}function y(p,U,V){var Q,ee,ne=new Array(16),Y=0;for(Q=1;Q<=15;Q++)ne[Q]=Y=Y+V[Q-1]<<1;for(ee=0;ee<=U;ee++){var G=p[2*ee+1];G!==0&&(p[2*ee]=q(ne[G]++,G))}}function m(p){var U;for(U=0;U<286;U++)p.dyn_ltree[2*U]=0;for(U=0;U<30;U++)p.dyn_dtree[2*U]=0;for(U=0;U<19;U++)p.bl_tree[2*U]=0;p.dyn_ltree[512]=1,p.opt_len=p.static_len=0,p.last_lit=p.matches=0}function C(p){p.bi_valid>8?d(p,p.bi_buf):p.bi_valid>0&&(p.pending_buf[p.pending++]=p.bi_buf),p.bi_buf=0,p.bi_valid=0}function w(p,U,V,Q){var ee=2*U,ne=2*V;return p[ee]<p[ne]||p[ee]===p[ne]&&Q[U]<=Q[V]}function L(p,U,V){for(var Q=p.heap[V],ee=V<<1;ee<=p.heap_len&&(ee<p.heap_len&&w(U,p.heap[ee+1],p.heap[ee],p.depth)&&ee++,!w(U,Q,p.heap[ee],p.depth));)p.heap[V]=p.heap[ee],V=ee,ee<<=1;p.heap[V]=Q}function W(p,U,V){var Q,ee,ne,Y,G=0;if(p.last_lit!==0)do Q=p.pending_buf[p.d_buf+2*G]<<8|p.pending_buf[p.d_buf+2*G+1],ee=p.pending_buf[p.l_buf+G],G++,Q===0?$(p,ee,U):($(p,(ne=_[ee])+256+1,U),(Y=s[ne])!==0&&I(p,ee-=h[ne],Y),$(p,ne=R(--Q),V),(Y=l[ne])!==0&&I(p,Q-=j[ne],Y));while(G<p.last_lit);$(p,256,U)}function k(p,U){var V,Q,ee,ne=U.dyn_tree,Y=U.stat_desc.static_tree,G=U.stat_desc.has_stree,S=U.stat_desc.elems,T=-1;for(p.heap_len=0,p.heap_max=573,V=0;V<S;V++)ne[2*V]!==0?(p.heap[++p.heap_len]=T=V,p.depth[V]=0):ne[2*V+1]=0;for(;p.heap_len<2;)ne[2*(ee=p.heap[++p.heap_len]=T<2?++T:0)]=1,p.depth[ee]=0,p.opt_len--,G&&(p.static_len-=Y[2*ee+1]);for(U.max_code=T,V=p.heap_len>>1;V>=1;V--)L(p,ne,V);ee=S;do V=p.heap[1],p.heap[1]=p.heap[p.heap_len--],L(p,ne,1),Q=p.heap[1],p.heap[--p.heap_max]=V,p.heap[--p.heap_max]=Q,ne[2*ee]=ne[2*V]+ne[2*Q],p.depth[ee]=(p.depth[V]>=p.depth[Q]?p.depth[V]:p.depth[Q])+1,ne[2*V+1]=ne[2*Q+1]=ee,p.heap[1]=ee++,L(p,ne,1);while(p.heap_len>=2);p.heap[--p.heap_max]=p.heap[1],function(B,J){var K,re,se,fe,ve,Ie,Se=J.dyn_tree,Ce=J.max_code,Ae=J.stat_desc.static_tree,Oe=J.stat_desc.has_stree,Pe=J.stat_desc.extra_bits,qe=J.stat_desc.extra_base,rt=J.stat_desc.max_length,tt=0;for(fe=0;fe<=15;fe++)B.bl_count[fe]=0;for(Se[2*B.heap[B.heap_max]+1]=0,K=B.heap_max+1;K<573;K++)(fe=Se[2*Se[2*(re=B.heap[K])+1]+1]+1)>rt&&(fe=rt,tt++),Se[2*re+1]=fe,re>Ce||(B.bl_count[fe]++,ve=0,re>=qe&&(ve=Pe[re-qe]),Ie=Se[2*re],B.opt_len+=Ie*(fe+ve),Oe&&(B.static_len+=Ie*(Ae[2*re+1]+ve)));if(tt!==0){do{for(fe=rt-1;B.bl_count[fe]===0;)fe--;B.bl_count[fe]--,B.bl_count[fe+1]+=2,B.bl_count[rt]--,tt-=2}while(tt>0);for(fe=rt;fe!==0;fe--)for(re=B.bl_count[fe];re!==0;)(se=B.heap[--K])>Ce||(Se[2*se+1]!==fe&&(B.opt_len+=(fe-Se[2*se+1])*Se[2*se],Se[2*se+1]=fe),re--)}}(p,U),y(ne,T,p.bl_count)}function N(p,U,V){var Q,ee,ne=-1,Y=U[1],G=0,S=7,T=4;for(Y===0&&(S=138,T=3),U[2*(V+1)+1]=65535,Q=0;Q<=V;Q++)ee=Y,Y=U[2*(Q+1)+1],++G<S&&ee===Y||(G<T?p.bl_tree[2*ee]+=G:ee!==0?(ee!==ne&&p.bl_tree[2*ee]++,p.bl_tree[32]++):G<=10?p.bl_tree[34]++:p.bl_tree[36]++,G=0,ne=ee,Y===0?(S=138,T=3):ee===Y?(S=6,T=3):(S=7,T=4))}function P(p,U,V){var Q,ee,ne=-1,Y=U[1],G=0,S=7,T=4;for(Y===0&&(S=138,T=3),Q=0;Q<=V;Q++)if(ee=Y,Y=U[2*(Q+1)+1],!(++G<S&&ee===Y)){if(G<T)do $(p,ee,p.bl_tree);while(--G!=0);else ee!==0?(ee!==ne&&($(p,ee,p.bl_tree),G--),$(p,16,p.bl_tree),I(p,G-3,2)):G<=10?($(p,17,p.bl_tree),I(p,G-3,3)):($(p,18,p.bl_tree),I(p,G-11,7));G=0,ne=ee,Y===0?(S=138,T=3):ee===Y?(S=6,T=3):(S=7,T=4)}}i(j);var z=!1;function O(p,U,V,Q){I(p,0+(Q?1:0),3),function(ee,ne,Y,G){C(ee),G&&(d(ee,Y),d(ee,~Y)),r.arraySet(ee.pending_buf,ee.window,ne,Y,ee.pending),ee.pending+=Y}(p,U,V,!0)}t._tr_init=function(p){z||(function(){var U,V,Q,ee,ne,Y=new Array(16);for(Q=0,ee=0;ee<28;ee++)for(h[ee]=Q,U=0;U<1<<s[ee];U++)_[Q++]=ee;for(_[Q-1]=ee,ne=0,ee=0;ee<16;ee++)for(j[ee]=ne,U=0;U<1<<l[ee];U++)E[ne++]=ee;for(ne>>=7;ee<30;ee++)for(j[ee]=ne<<7,U=0;U<1<<l[ee]-7;U++)E[256+ne++]=ee;for(V=0;V<=15;V++)Y[V]=0;for(U=0;U<=143;)u[2*U+1]=8,U++,Y[8]++;for(;U<=255;)u[2*U+1]=9,U++,Y[9]++;for(;U<=279;)u[2*U+1]=7,U++,Y[7]++;for(;U<=287;)u[2*U+1]=8,U++,Y[8]++;for(y(u,287,Y),U=0;U<30;U++)f[2*U+1]=5,f[2*U]=q(U,5);g=new F(u,s,257,286,15),b=new F(f,l,0,30,15),A=new F(new Array(0),o,0,19,7)}(),z=!0),p.l_desc=new M(p.dyn_ltree,g),p.d_desc=new M(p.dyn_dtree,b),p.bl_desc=new M(p.bl_tree,A),p.bi_buf=0,p.bi_valid=0,m(p)},t._tr_stored_block=O,t._tr_flush_block=function(p,U,V,Q){var ee,ne,Y=0;p.level>0?(p.strm.data_type===2&&(p.strm.data_type=function(G){var S,T=4093624447;for(S=0;S<=31;S++,T>>>=1)if(1&T&&G.dyn_ltree[2*S]!==0)return 0;if(G.dyn_ltree[18]!==0||G.dyn_ltree[20]!==0||G.dyn_ltree[26]!==0)return 1;for(S=32;S<256;S++)if(G.dyn_ltree[2*S]!==0)return 1;return 0}(p)),k(p,p.l_desc),k(p,p.d_desc),Y=function(G){var S;for(N(G,G.dyn_ltree,G.l_desc.max_code),N(G,G.dyn_dtree,G.d_desc.max_code),k(G,G.bl_desc),S=18;S>=3&&G.bl_tree[2*c[S]+1]===0;S--);return G.opt_len+=3*(S+1)+5+5+4,S}(p),ee=p.opt_len+3+7>>>3,(ne=p.static_len+3+7>>>3)<=ee&&(ee=ne)):ee=ne=V+5,V+4<=ee&&U!==-1?O(p,U,V,Q):p.strategy===4||ne===ee?(I(p,2+(Q?1:0),3),W(p,u,f)):(I(p,4+(Q?1:0),3),function(G,S,T,B){var J;for(I(G,S-257,5),I(G,T-1,5),I(G,B-4,4),J=0;J<B;J++)I(G,G.bl_tree[2*c[J]+1],3);P(G,G.dyn_ltree,S-1),P(G,G.dyn_dtree,T-1)}(p,p.l_desc.max_code+1,p.d_desc.max_code+1,Y+1),W(p,p.dyn_ltree,p.dyn_dtree)),m(p),Q&&C(p)},t._tr_tally=function(p,U,V){return p.pending_buf[p.d_buf+2*p.last_lit]=U>>>8&255,p.pending_buf[p.d_buf+2*p.last_lit+1]=255&U,p.pending_buf[p.l_buf+p.last_lit]=255&V,p.last_lit++,U===0?p.dyn_ltree[2*V]++:(p.matches++,U--,p.dyn_ltree[2*(_[V]+256+1)]++,p.dyn_dtree[2*R(U)]++),p.last_lit===p.lit_bufsize-1},t._tr_align=function(p){I(p,2,3),$(p,256,u),function(U){U.bi_valid===16?(d(U,U.bi_buf),U.bi_buf=0,U.bi_valid=0):U.bi_valid>=8&&(U.pending_buf[U.pending++]=255&U.bi_buf,U.bi_buf>>=8,U.bi_valid-=8)}(p)}},function(e,t,n){e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},function(e,t,n){var r=n(37),i=n(75),s=n(76),l=n(176),o=n(177);function c(M){return(M>>>24&255)+(M>>>8&65280)+((65280&M)<<8)+((255&M)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(M){var R;return M&&M.state?(R=M.state,M.total_in=M.total_out=R.total=0,M.msg="",R.wrap&&(M.adler=1&R.wrap),R.mode=1,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new r.Buf32(852),R.distcode=R.distdyn=new r.Buf32(592),R.sane=1,R.back=-1,0):-2}function E(M){var R;return M&&M.state?((R=M.state).wsize=0,R.whave=0,R.wnext=0,f(M)):-2}function _(M,R){var d,I;return M&&M.state?(I=M.state,R<0?(d=0,R=-R):(d=1+(R>>4),R<48&&(R&=15)),R&&(R<8||R>15)?-2:(I.window!==null&&I.wbits!==R&&(I.window=null),I.wrap=d,I.wbits=R,E(M))):-2}function h(M,R){var d,I;return M?(I=new u,M.state=I,I.window=null,(d=_(M,R))!==0&&(M.state=null),d):-2}var g,b,A=!0;function j(M){if(A){var R;for(g=new r.Buf32(512),b=new r.Buf32(32),R=0;R<144;)M.lens[R++]=8;for(;R<256;)M.lens[R++]=9;for(;R<280;)M.lens[R++]=7;for(;R<288;)M.lens[R++]=8;for(o(1,M.lens,0,288,g,0,M.work,{bits:9}),R=0;R<32;)M.lens[R++]=5;o(2,M.lens,0,32,b,0,M.work,{bits:5}),A=!1}M.lencode=g,M.lenbits=9,M.distcode=b,M.distbits=5}function F(M,R,d,I){var $,q=M.state;return q.window===null&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new r.Buf8(q.wsize)),I>=q.wsize?(r.arraySet(q.window,R,d-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(($=q.wsize-q.wnext)>I&&($=I),r.arraySet(q.window,R,d-I,$,q.wnext),(I-=$)?(r.arraySet(q.window,R,d-I,I,0),q.wnext=I,q.whave=q.wsize):(q.wnext+=$,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=$))),0}t.inflateReset=E,t.inflateReset2=_,t.inflateResetKeep=f,t.inflateInit=function(M){return h(M,15)},t.inflateInit2=h,t.inflate=function(M,R){var d,I,$,q,y,m,C,w,L,W,k,N,P,z,O,p,U,V,Q,ee,ne,Y,G,S,T=0,B=new r.Buf8(4),J=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!M||!M.state||!M.output||!M.input&&M.avail_in!==0)return-2;(d=M.state).mode===12&&(d.mode=13),y=M.next_out,$=M.output,C=M.avail_out,q=M.next_in,I=M.input,m=M.avail_in,w=d.hold,L=d.bits,W=m,k=C,Y=0;e:for(;;)switch(d.mode){case 1:if(d.wrap===0){d.mode=13;break}for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(2&d.wrap&&w===35615){d.check=0,B[0]=255&w,B[1]=w>>>8&255,d.check=s(d.check,B,2,0),w=0,L=0,d.mode=2;break}if(d.flags=0,d.head&&(d.head.done=!1),!(1&d.wrap)||(((255&w)<<8)+(w>>8))%31){M.msg="incorrect header check",d.mode=30;break}if((15&w)!=8){M.msg="unknown compression method",d.mode=30;break}if(L-=4,ne=8+(15&(w>>>=4)),d.wbits===0)d.wbits=ne;else if(ne>d.wbits){M.msg="invalid window size",d.mode=30;break}d.dmax=1<<ne,M.adler=d.check=1,d.mode=512&w?10:12,w=0,L=0;break;case 2:for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(d.flags=w,(255&d.flags)!=8){M.msg="unknown compression method",d.mode=30;break}if(57344&d.flags){M.msg="unknown header flags set",d.mode=30;break}d.head&&(d.head.text=w>>8&1),512&d.flags&&(B[0]=255&w,B[1]=w>>>8&255,d.check=s(d.check,B,2,0)),w=0,L=0,d.mode=3;case 3:for(;L<32;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.head&&(d.head.time=w),512&d.flags&&(B[0]=255&w,B[1]=w>>>8&255,B[2]=w>>>16&255,B[3]=w>>>24&255,d.check=s(d.check,B,4,0)),w=0,L=0,d.mode=4;case 4:for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.head&&(d.head.xflags=255&w,d.head.os=w>>8),512&d.flags&&(B[0]=255&w,B[1]=w>>>8&255,d.check=s(d.check,B,2,0)),w=0,L=0,d.mode=5;case 5:if(1024&d.flags){for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.length=w,d.head&&(d.head.extra_len=w),512&d.flags&&(B[0]=255&w,B[1]=w>>>8&255,d.check=s(d.check,B,2,0)),w=0,L=0}else d.head&&(d.head.extra=null);d.mode=6;case 6:if(1024&d.flags&&((N=d.length)>m&&(N=m),N&&(d.head&&(ne=d.head.extra_len-d.length,d.head.extra||(d.head.extra=new Array(d.head.extra_len)),r.arraySet(d.head.extra,I,q,N,ne)),512&d.flags&&(d.check=s(d.check,I,N,q)),m-=N,q+=N,d.length-=N),d.length))break e;d.length=0,d.mode=7;case 7:if(2048&d.flags){if(m===0)break e;N=0;do ne=I[q+N++],d.head&&ne&&d.length<65536&&(d.head.name+=String.fromCharCode(ne));while(ne&&N<m);if(512&d.flags&&(d.check=s(d.check,I,N,q)),m-=N,q+=N,ne)break e}else d.head&&(d.head.name=null);d.length=0,d.mode=8;case 8:if(4096&d.flags){if(m===0)break e;N=0;do ne=I[q+N++],d.head&&ne&&d.length<65536&&(d.head.comment+=String.fromCharCode(ne));while(ne&&N<m);if(512&d.flags&&(d.check=s(d.check,I,N,q)),m-=N,q+=N,ne)break e}else d.head&&(d.head.comment=null);d.mode=9;case 9:if(512&d.flags){for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(w!==(65535&d.check)){M.msg="header crc mismatch",d.mode=30;break}w=0,L=0}d.head&&(d.head.hcrc=d.flags>>9&1,d.head.done=!0),M.adler=d.check=0,d.mode=12;break;case 10:for(;L<32;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}M.adler=d.check=c(w),w=0,L=0,d.mode=11;case 11:if(d.havedict===0)return M.next_out=y,M.avail_out=C,M.next_in=q,M.avail_in=m,d.hold=w,d.bits=L,2;M.adler=d.check=1,d.mode=12;case 12:if(R===5||R===6)break e;case 13:if(d.last){w>>>=7&L,L-=7&L,d.mode=27;break}for(;L<3;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}switch(d.last=1&w,L-=1,3&(w>>>=1)){case 0:d.mode=14;break;case 1:if(j(d),d.mode=20,R===6){w>>>=2,L-=2;break e}break;case 2:d.mode=17;break;case 3:M.msg="invalid block type",d.mode=30}w>>>=2,L-=2;break;case 14:for(w>>>=7&L,L-=7&L;L<32;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if((65535&w)!=(w>>>16^65535)){M.msg="invalid stored block lengths",d.mode=30;break}if(d.length=65535&w,w=0,L=0,d.mode=15,R===6)break e;case 15:d.mode=16;case 16:if(N=d.length){if(N>m&&(N=m),N>C&&(N=C),N===0)break e;r.arraySet($,I,q,N,y),m-=N,q+=N,C-=N,y+=N,d.length-=N;break}d.mode=12;break;case 17:for(;L<14;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(d.nlen=257+(31&w),w>>>=5,L-=5,d.ndist=1+(31&w),w>>>=5,L-=5,d.ncode=4+(15&w),w>>>=4,L-=4,d.nlen>286||d.ndist>30){M.msg="too many length or distance symbols",d.mode=30;break}d.have=0,d.mode=18;case 18:for(;d.have<d.ncode;){for(;L<3;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.lens[J[d.have++]]=7&w,w>>>=3,L-=3}for(;d.have<19;)d.lens[J[d.have++]]=0;if(d.lencode=d.lendyn,d.lenbits=7,G={bits:d.lenbits},Y=o(0,d.lens,0,19,d.lencode,0,d.work,G),d.lenbits=G.bits,Y){M.msg="invalid code lengths set",d.mode=30;break}d.have=0,d.mode=19;case 19:for(;d.have<d.nlen+d.ndist;){for(;p=(T=d.lencode[w&(1<<d.lenbits)-1])>>>16&255,U=65535&T,!((O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(U<16)w>>>=O,L-=O,d.lens[d.have++]=U;else{if(U===16){for(S=O+2;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(w>>>=O,L-=O,d.have===0){M.msg="invalid bit length repeat",d.mode=30;break}ne=d.lens[d.have-1],N=3+(3&w),w>>>=2,L-=2}else if(U===17){for(S=O+3;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}L-=O,ne=0,N=3+(7&(w>>>=O)),w>>>=3,L-=3}else{for(S=O+7;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}L-=O,ne=0,N=11+(127&(w>>>=O)),w>>>=7,L-=7}if(d.have+N>d.nlen+d.ndist){M.msg="invalid bit length repeat",d.mode=30;break}for(;N--;)d.lens[d.have++]=ne}}if(d.mode===30)break;if(d.lens[256]===0){M.msg="invalid code -- missing end-of-block",d.mode=30;break}if(d.lenbits=9,G={bits:d.lenbits},Y=o(1,d.lens,0,d.nlen,d.lencode,0,d.work,G),d.lenbits=G.bits,Y){M.msg="invalid literal/lengths set",d.mode=30;break}if(d.distbits=6,d.distcode=d.distdyn,G={bits:d.distbits},Y=o(2,d.lens,d.nlen,d.ndist,d.distcode,0,d.work,G),d.distbits=G.bits,Y){M.msg="invalid distances set",d.mode=30;break}if(d.mode=20,R===6)break e;case 20:d.mode=21;case 21:if(m>=6&&C>=258){M.next_out=y,M.avail_out=C,M.next_in=q,M.avail_in=m,d.hold=w,d.bits=L,l(M,k),y=M.next_out,$=M.output,C=M.avail_out,q=M.next_in,I=M.input,m=M.avail_in,w=d.hold,L=d.bits,d.mode===12&&(d.back=-1);break}for(d.back=0;p=(T=d.lencode[w&(1<<d.lenbits)-1])>>>16&255,U=65535&T,!((O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(p&&!(240&p)){for(V=O,Q=p,ee=U;p=(T=d.lencode[ee+((w&(1<<V+Q)-1)>>V)])>>>16&255,U=65535&T,!(V+(O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}w>>>=V,L-=V,d.back+=V}if(w>>>=O,L-=O,d.back+=O,d.length=U,p===0){d.mode=26;break}if(32&p){d.back=-1,d.mode=12;break}if(64&p){M.msg="invalid literal/length code",d.mode=30;break}d.extra=15&p,d.mode=22;case 22:if(d.extra){for(S=d.extra;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.length+=w&(1<<d.extra)-1,w>>>=d.extra,L-=d.extra,d.back+=d.extra}d.was=d.length,d.mode=23;case 23:for(;p=(T=d.distcode[w&(1<<d.distbits)-1])>>>16&255,U=65535&T,!((O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(!(240&p)){for(V=O,Q=p,ee=U;p=(T=d.distcode[ee+((w&(1<<V+Q)-1)>>V)])>>>16&255,U=65535&T,!(V+(O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}w>>>=V,L-=V,d.back+=V}if(w>>>=O,L-=O,d.back+=O,64&p){M.msg="invalid distance code",d.mode=30;break}d.offset=U,d.extra=15&p,d.mode=24;case 24:if(d.extra){for(S=d.extra;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.offset+=w&(1<<d.extra)-1,w>>>=d.extra,L-=d.extra,d.back+=d.extra}if(d.offset>d.dmax){M.msg="invalid distance too far back",d.mode=30;break}d.mode=25;case 25:if(C===0)break e;if(N=k-C,d.offset>N){if((N=d.offset-N)>d.whave&&d.sane){M.msg="invalid distance too far back",d.mode=30;break}N>d.wnext?(N-=d.wnext,P=d.wsize-N):P=d.wnext-N,N>d.length&&(N=d.length),z=d.window}else z=$,P=y-d.offset,N=d.length;N>C&&(N=C),C-=N,d.length-=N;do $[y++]=z[P++];while(--N);d.length===0&&(d.mode=21);break;case 26:if(C===0)break e;$[y++]=d.length,C--,d.mode=21;break;case 27:if(d.wrap){for(;L<32;){if(m===0)break e;m--,w|=I[q++]<<L,L+=8}if(k-=C,M.total_out+=k,d.total+=k,k&&(M.adler=d.check=d.flags?s(d.check,$,k,y-k):i(d.check,$,k,y-k)),k=C,(d.flags?w:c(w))!==d.check){M.msg="incorrect data check",d.mode=30;break}w=0,L=0}d.mode=28;case 28:if(d.wrap&&d.flags){for(;L<32;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(w!==(4294967295&d.total)){M.msg="incorrect length check",d.mode=30;break}w=0,L=0}d.mode=29;case 29:Y=1;break e;case 30:Y=-3;break e;case 31:return-4;case 32:default:return-2}return M.next_out=y,M.avail_out=C,M.next_in=q,M.avail_in=m,d.hold=w,d.bits=L,(d.wsize||k!==M.avail_out&&d.mode<30&&(d.mode<27||R!==4))&&F(M,M.output,M.next_out,k-M.avail_out)?(d.mode=31,-4):(W-=M.avail_in,k-=M.avail_out,M.total_in+=W,M.total_out+=k,d.total+=k,d.wrap&&k&&(M.adler=d.check=d.flags?s(d.check,$,k,M.next_out-k):i(d.check,$,k,M.next_out-k)),M.data_type=d.bits+(d.last?64:0)+(d.mode===12?128:0)+(d.mode===20||d.mode===15?256:0),(W===0&&k===0||R===4)&&Y===0&&(Y=-5),Y)},t.inflateEnd=function(M){if(!M||!M.state)return-2;var R=M.state;return R.window&&(R.window=null),M.state=null,0},t.inflateGetHeader=function(M,R){var d;return M&&M.state&&2&(d=M.state).wrap?(d.head=R,R.done=!1,0):-2},t.inflateSetDictionary=function(M,R){var d,I=R.length;return M&&M.state?(d=M.state).wrap!==0&&d.mode!==11?-2:d.mode===11&&i(1,R,I,0)!==d.check?-3:F(M,R,I,I)?(d.mode=31,-4):(d.havedict=1,0):-2},t.inflateInfo="pako inflate (from Nodeca project)"},function(e,t,n){e.exports=function(r,i){var s,l,o,c,u,f,E,_,h,g,b,A,j,F,M,R,d,I,$,q,y,m,C,w,L;s=r.state,l=r.next_in,w=r.input,o=l+(r.avail_in-5),c=r.next_out,L=r.output,u=c-(i-r.avail_out),f=c+(r.avail_out-257),E=s.dmax,_=s.wsize,h=s.whave,g=s.wnext,b=s.window,A=s.hold,j=s.bits,F=s.lencode,M=s.distcode,R=(1<<s.lenbits)-1,d=(1<<s.distbits)-1;e:do{j<15&&(A+=w[l++]<<j,j+=8,A+=w[l++]<<j,j+=8),I=F[A&R];t:for(;;){if(A>>>=$=I>>>24,j-=$,($=I>>>16&255)===0)L[c++]=65535&I;else{if(!(16&$)){if(!(64&$)){I=F[(65535&I)+(A&(1<<$)-1)];continue t}if(32&$){s.mode=12;break e}r.msg="invalid literal/length code",s.mode=30;break e}q=65535&I,($&=15)&&(j<$&&(A+=w[l++]<<j,j+=8),q+=A&(1<<$)-1,A>>>=$,j-=$),j<15&&(A+=w[l++]<<j,j+=8,A+=w[l++]<<j,j+=8),I=M[A&d];n:for(;;){if(A>>>=$=I>>>24,j-=$,!(16&($=I>>>16&255))){if(!(64&$)){I=M[(65535&I)+(A&(1<<$)-1)];continue n}r.msg="invalid distance code",s.mode=30;break e}if(y=65535&I,j<($&=15)&&(A+=w[l++]<<j,(j+=8)<$&&(A+=w[l++]<<j,j+=8)),(y+=A&(1<<$)-1)>E){r.msg="invalid distance too far back",s.mode=30;break e}if(A>>>=$,j-=$,y>($=c-u)){if(($=y-$)>h&&s.sane){r.msg="invalid distance too far back",s.mode=30;break e}if(m=0,C=b,g===0){if(m+=_-$,$<q){q-=$;do L[c++]=b[m++];while(--$);m=c-y,C=L}}else if(g<$){if(m+=_+g-$,($-=g)<q){q-=$;do L[c++]=b[m++];while(--$);if(m=0,g<q){q-=$=g;do L[c++]=b[m++];while(--$);m=c-y,C=L}}}else if(m+=g-$,$<q){q-=$;do L[c++]=b[m++];while(--$);m=c-y,C=L}for(;q>2;)L[c++]=C[m++],L[c++]=C[m++],L[c++]=C[m++],q-=3;q&&(L[c++]=C[m++],q>1&&(L[c++]=C[m++]))}else{m=c-y;do L[c++]=L[m++],L[c++]=L[m++],L[c++]=L[m++],q-=3;while(q>2);q&&(L[c++]=L[m++],q>1&&(L[c++]=L[m++]))}break}}break}}while(l<o&&c<f);l-=q=j>>3,A&=(1<<(j-=q<<3))-1,r.next_in=l,r.next_out=c,r.avail_in=l<o?o-l+5:5-(l-o),r.avail_out=c<f?f-c+257:257-(c-f),s.hold=A,s.bits=j}},function(e,t,n){var r=n(37),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],o=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(c,u,f,E,_,h,g,b){var A,j,F,M,R,d,I,$,q,y=b.bits,m=0,C=0,w=0,L=0,W=0,k=0,N=0,P=0,z=0,O=0,p=null,U=0,V=new r.Buf16(16),Q=new r.Buf16(16),ee=null,ne=0;for(m=0;m<=15;m++)V[m]=0;for(C=0;C<E;C++)V[u[f+C]]++;for(W=y,L=15;L>=1&&V[L]===0;L--);if(W>L&&(W=L),L===0)return _[h++]=20971520,_[h++]=20971520,b.bits=1,0;for(w=1;w<L&&V[w]===0;w++);for(W<w&&(W=w),P=1,m=1;m<=15;m++)if(P<<=1,(P-=V[m])<0)return-1;if(P>0&&(c===0||L!==1))return-1;for(Q[1]=0,m=1;m<15;m++)Q[m+1]=Q[m]+V[m];for(C=0;C<E;C++)u[f+C]!==0&&(g[Q[u[f+C]]++]=C);if(c===0?(p=ee=g,d=19):c===1?(p=i,U-=257,ee=s,ne-=257,d=256):(p=l,ee=o,d=-1),O=0,C=0,m=w,R=h,k=W,N=0,F=-1,M=(z=1<<W)-1,c===1&&z>852||c===2&&z>592)return 1;for(;;){I=m-N,g[C]<d?($=0,q=g[C]):g[C]>d?($=ee[ne+g[C]],q=p[U+g[C]]):($=96,q=0),A=1<<m-N,w=j=1<<k;do _[R+(O>>N)+(j-=A)]=I<<24|$<<16|q|0;while(j!==0);for(A=1<<m-1;O&A;)A>>=1;if(A!==0?(O&=A-1,O+=A):O=0,C++,--V[m]==0){if(m===L)break;m=u[f+g[C]]}if(m>W&&(O&M)!==F){for(N===0&&(N=W),R+=w,P=1<<(k=m-N);k+N<L&&!((P-=V[k+N])<=0);)k++,P<<=1;if(z+=1<<k,c===1&&z>852||c===2&&z>592)return 1;_[F=O&M]=W<<24|k<<16|R-h|0}}return O!==0&&(_[R+O]=m-N<<24|64<<16|0),b.bits=W,0}},function(e,t,n){e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(e,t){},function(e,t,n){function r(u,f){var E=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(h){return Object.getOwnPropertyDescriptor(u,h).enumerable})),E.push.apply(E,_)}return E}function i(u,f,E){return f in u?Object.defineProperty(u,f,{value:E,enumerable:!0,configurable:!0,writable:!0}):u[f]=E,u}function s(u,f){for(var E=0;E<f.length;E++){var _=f[E];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,_.key,_)}}var l=n(5).Buffer,o=n(181).inspect,c=o&&o.custom||"inspect";e.exports=function(){function u(){(function(_,h){if(!(_ instanceof h))throw new TypeError("Cannot call a class as a function")})(this,u),this.head=null,this.tail=null,this.length=0}var f,E;return f=u,(E=[{key:"push",value:function(_){var h={data:_,next:null};this.length>0?this.tail.next=h:this.head=h,this.tail=h,++this.length}},{key:"unshift",value:function(_){var h={data:_,next:this.head};this.length===0&&(this.tail=h),this.head=h,++this.length}},{key:"shift",value:function(){if(this.length!==0){var _=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,_}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(_){if(this.length===0)return"";for(var h=this.head,g=""+h.data;h=h.next;)g+=_+h.data;return g}},{key:"concat",value:function(_){if(this.length===0)return l.alloc(0);for(var h,g,b,A=l.allocUnsafe(_>>>0),j=this.head,F=0;j;)h=j.data,g=A,b=F,l.prototype.copy.call(h,g,b),F+=j.data.length,j=j.next;return A}},{key:"consume",value:function(_,h){var g;return _<this.head.data.length?(g=this.head.data.slice(0,_),this.head.data=this.head.data.slice(_)):g=_===this.head.data.length?this.shift():h?this._getString(_):this._getBuffer(_),g}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(_){var h=this.head,g=1,b=h.data;for(_-=b.length;h=h.next;){var A=h.data,j=_>A.length?A.length:_;if(j===A.length?b+=A:b+=A.slice(0,_),(_-=j)==0){j===A.length?(++g,h.next?this.head=h.next:this.head=this.tail=null):(this.head=h,h.data=A.slice(j));break}++g}return this.length-=g,b}},{key:"_getBuffer",value:function(_){var h=l.allocUnsafe(_),g=this.head,b=1;for(g.data.copy(h),_-=g.data.length;g=g.next;){var A=g.data,j=_>A.length?A.length:_;if(A.copy(h,h.length-_,0,j),(_-=j)==0){j===A.length?(++b,g.next?this.head=g.next:this.head=this.tail=null):(this.head=g,g.data=A.slice(j));break}++b}return this.length-=b,h}},{key:c,value:function(_,h){return o(this,function(g){for(var b=1;b<arguments.length;b++){var A=arguments[b]!=null?arguments[b]:{};b%2?r(Object(A),!0).forEach(function(j){i(g,j,A[j])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(A)):r(Object(A)).forEach(function(j){Object.defineProperty(g,j,Object.getOwnPropertyDescriptor(A,j))})}return g}({},h,{depth:0,customInspect:!1}))}}])&&s(f.prototype,E),u}()},function(e,t){},function(e,t,n){(function(r){var i;function s(M,R,d){return R in M?Object.defineProperty(M,R,{value:d,enumerable:!0,configurable:!0,writable:!0}):M[R]=d,M}var l=n(49),o=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),f=Symbol("ended"),E=Symbol("lastPromise"),_=Symbol("handlePromise"),h=Symbol("stream");function g(M,R){return{value:M,done:R}}function b(M){var R=M[o];if(R!==null){var d=M[h].read();d!==null&&(M[E]=null,M[o]=null,M[c]=null,R(g(d,!1)))}}function A(M){r.nextTick(b,M)}var j=Object.getPrototypeOf(function(){}),F=Object.setPrototypeOf((s(i={get stream(){return this[h]},next:function(){var M=this,R=this[u];if(R!==null)return Promise.reject(R);if(this[f])return Promise.resolve(g(void 0,!0));if(this[h].destroyed)return new Promise(function(q,y){r.nextTick(function(){M[u]?y(M[u]):q(g(void 0,!0))})});var d,I=this[E];if(I)d=new Promise(function(q,y){return function(m,C){q.then(function(){y[f]?m(g(void 0,!0)):y[_](m,C)},C)}}(I,this));else{var $=this[h].read();if($!==null)return Promise.resolve(g($,!1));d=new Promise(this[_])}return this[E]=d,d}},Symbol.asyncIterator,function(){return this}),s(i,"return",function(){var M=this;return new Promise(function(R,d){M[h].destroy(null,function(I){I?d(I):R(g(void 0,!0))})})}),i),j);e.exports=function(M){var R,d=Object.create(F,(s(R={},h,{value:M,writable:!0}),s(R,o,{value:null,writable:!0}),s(R,c,{value:null,writable:!0}),s(R,u,{value:null,writable:!0}),s(R,f,{value:M._readableState.endEmitted,writable:!0}),s(R,_,{value:function(I,$){var q=d[h].read();q?(d[E]=null,d[o]=null,d[c]=null,I(g(q,!1))):(d[o]=I,d[c]=$)},writable:!0}),R));return d[E]=null,l(M,function(I){if(I&&I.code!=="ERR_STREAM_PREMATURE_CLOSE"){var $=d[c];return $!==null&&(d[E]=null,d[o]=null,d[c]=null,$(I)),void(d[u]=I)}var q=d[o];q!==null&&(d[E]=null,d[o]=null,d[c]=null,q(g(void 0,!0))),d[f]=!0}),M.on("readable",A.bind(null,d)),d}}).call(this,n(2))},function(e,t){e.exports=function(){throw new Error("Readable.from is not available in the browser")}},function(e,t,n){e.exports=i;var r=n(82);function i(s){if(!(this instanceof i))return new i(s);r.call(this,s)}n(7)(i,r),i.prototype._transform=function(s,l,o){o(null,s)}},function(e,t,n){var r,i=n(26).codes,s=i.ERR_MISSING_ARGS,l=i.ERR_STREAM_DESTROYED;function o(_){if(_)throw _}function c(_,h,g,b){b=function(F){var M=!1;return function(){M||(M=!0,F.apply(void 0,arguments))}}(b);var A=!1;_.on("close",function(){A=!0}),r===void 0&&(r=n(49)),r(_,{readable:h,writable:g},function(F){if(F)return b(F);A=!0,b()});var j=!1;return function(F){if(!A&&!j)return j=!0,function(M){return M.setHeader&&typeof M.abort=="function"}(_)?_.abort():typeof _.destroy=="function"?_.destroy():void b(F||new l("pipe"))}}function u(_){_()}function f(_,h){return _.pipe(h)}function E(_){return _.length?typeof _[_.length-1]!="function"?o:_.pop():o}e.exports=function(){for(var _=arguments.length,h=new Array(_),g=0;g<_;g++)h[g]=arguments[g];var b,A=E(h);if(Array.isArray(h[0])&&(h=h[0]),h.length<2)throw new s("streams");var j=h.map(function(F,M){var R=M<h.length-1;return c(F,R,M>0,function(d){b||(b=d),d&&j.forEach(u),R||(j.forEach(u),A(b))})});return h.reduce(f)}},function(e,t,n){var r=n(187)(function i(s,l){return(l=l||{}).namespace=s,l.prod=!0,l.dev=!1,l.force||i.force?i.yep(l):i.nope(l)});e.exports=r},function(e,t){var n=[],r=[],i=function(){};function s(g){return!~n.indexOf(g)&&(n.push(g),!0)}function l(g){i=g}function o(g){for(var b=[],A=0;A<n.length;A++)if(n[A].async)b.push(n[A]);else if(n[A](g))return!0;return!!b.length&&new Promise(function(j){Promise.all(b.map(function(F){return F(g)})).then(function(F){j(F.some(Boolean))})})}function c(g){return!~r.indexOf(g)&&(r.push(g),!0)}function u(){i.apply(i,arguments)}function f(g){for(var b=0;b<r.length;b++)g=r[b].apply(r[b],arguments);return g}function E(g,b){var A=Object.prototype.hasOwnProperty;for(var j in b)A.call(b,j)&&(g[j]=b[j]);return g}function _(g){return g.enabled=!1,g.modify=c,g.set=l,g.use=s,E(function(){return!1},g)}function h(g){return g.enabled=!0,g.modify=c,g.set=l,g.use=s,E(function(){var b=Array.prototype.slice.call(arguments,0);return u.call(u,g,f(b,g)),!0},g)}e.exports=function(g){return g.introduce=E,g.enabled=o,g.process=f,g.modify=c,g.write=u,g.nope=_,g.yep=h,g.set=l,g.use=s,g}},function(e,t,n){(function(r){var i=n(65),s=n(22).StringDecoder,l=n(32).Stream;function o(){}e.exports=function(c,u){var f=r.alloc(65536),E=new s("utf8"),_=new l,h="",g=0,b=0;return c.start===-1&&delete c.start,_.readable=!0,_.destroy=function(){_.destroyed=!0,_.emit("end"),_.emit("close")},i.open(c.file,"a+","0644",function(A,j){if(A)return u?u(A):_.emit("error",A),void _.destroy();(function F(){if(!_.destroyed)return i.read(j,f,0,f.length,g,function(M,R){if(M)return u?u(M):_.emit("error",M),void _.destroy();if(!R)return h&&((c.start==null||b>c.start)&&(u?u(null,h):_.emit("line",h)),b++,h=""),setTimeout(F,1e3);var d=E.write(f.slice(0,R));u||_.emit("data",d);for(var I=(d=(h+d).split(/\n+/)).length-1,$=0;$<I;$++)(c.start==null||b>c.start)&&(u?u(null,d[$]):_.emit("line",d[$])),b++;return h=d[I],g+=R,F()});i.close(j,o)})()}),u?_.destroy:_}}).call(this,n(5).Buffer)},function(e,t,n){(function(r,i){function s(M){return(s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(R){return typeof R}:function(R){return R&&typeof Symbol=="function"&&R.constructor===Symbol&&R!==Symbol.prototype?"symbol":typeof R})(M)}function l(M,R){var d=Object.keys(M);if(Object.getOwnPropertySymbols){var I=Object.getOwnPropertySymbols(M);R&&(I=I.filter(function($){return Object.getOwnPropertyDescriptor(M,$).enumerable})),d.push.apply(d,I)}return d}function o(M){for(var R=1;R<arguments.length;R++){var d=arguments[R]!=null?arguments[R]:{};R%2?l(Object(d),!0).forEach(function(I){c(M,I,d[I])}):Object.getOwnPropertyDescriptors?Object.defineProperties(M,Object.getOwnPropertyDescriptors(d)):l(Object(d)).forEach(function(I){Object.defineProperty(M,I,Object.getOwnPropertyDescriptor(d,I))})}return M}function c(M,R,d){return R in M?Object.defineProperty(M,R,{value:d,enumerable:!0,configurable:!0,writable:!0}):M[R]=d,M}function u(M,R){if(!(M instanceof R))throw new TypeError("Cannot call a class as a function")}function f(M,R){for(var d=0;d<R.length;d++){var I=R[d];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(M,I.key,I)}}function E(M,R){return(E=Object.setPrototypeOf||function(d,I){return d.__proto__=I,d})(M,R)}function _(M){var R=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var d,I=g(M);if(R){var $=g(this).constructor;d=Reflect.construct(I,arguments,$)}else d=I.apply(this,arguments);return h(this,d)}}function h(M,R){return!R||s(R)!=="object"&&typeof R!="function"?function(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}(M):R}function g(M){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(R){return R.__proto__||Object.getPrototypeOf(R)})(M)}var b=n(83),A=n(200),j=n(32).Stream,F=n(20);e.exports=function(M){(function(q,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");q.prototype=Object.create(y&&y.prototype,{constructor:{value:q,writable:!0,configurable:!0}}),y&&E(q,y)})($,M);var R,d,I=_($);function $(){var q,y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return u(this,$),(q=I.call(this,y)).options=y,q.name=y.name||"http",q.ssl=!!y.ssl,q.host=y.host||"localhost",q.port=y.port,q.auth=y.auth,q.path=y.path||"",q.agent=y.agent,q.headers=y.headers||{},q.headers["content-type"]="application/json",q.port||(q.port=q.ssl?443:80),q}return R=$,(d=[{key:"log",value:function(q,y){var m=this;this._request(q,function(C,w){w&&w.statusCode!==200&&(C=new Error("Invalid HTTP Status Code: ".concat(w.statusCode))),C?m.emit("warn",C):m.emit("logged",q)}),y&&r(y)}},{key:"query",value:function(q,y){typeof q=="function"&&(y=q,q={}),(q={method:"query",params:this.normalizeQuery(q)}).params.path&&(q.path=q.params.path,delete q.params.path),q.params.auth&&(q.auth=q.params.auth,delete q.params.auth),this._request(q,function(m,C,w){if(C&&C.statusCode!==200&&(m=new Error("Invalid HTTP Status Code: ".concat(C.statusCode))),m)return y(m);if(typeof w=="string")try{w=JSON.parse(w)}catch(L){return y(L)}y(null,w)})}},{key:"stream",value:function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},y=new j;(q={method:"stream",params:q}).params.path&&(q.path=q.params.path,delete q.params.path),q.params.auth&&(q.auth=q.params.auth,delete q.params.auth);var m="",C=this._request(q);return y.destroy=function(){return C.destroy()},C.on("data",function(w){for(var L=(w=(m+w).split(/\n+/)).length-1,W=0;W<L;W++)try{y.emit("log",JSON.parse(w[W]))}catch(k){y.emit("error",k)}m=w[L]}),C.on("error",function(w){return y.emit("error",w)}),y}},{key:"_request",value:function(q,y){var m=(q=q||{}).auth||this.auth,C=q.path||this.path||"";delete q.auth,delete q.path;var w=Object.assign({},this.headers);m&&m.bearer&&(w.Authorization="Bearer ".concat(m.bearer));var L=(this.ssl?A:b).request(o(o({},this.options),{},{method:"POST",host:this.host,port:this.port,path:"/".concat(C.replace(/^\//,"")),headers:w,auth:m&&m.username&&m.password?"".concat(m.username,":").concat(m.password):"",agent:this.agent}));L.on("error",y),L.on("response",function(W){return W.on("end",function(){return y(null,W)}).resume()}),L.end(i.from(JSON.stringify(q),"utf8"))}}])&&f(R.prototype,d),$}(F)}).call(this,n(15).setImmediate,n(5).Buffer)},function(e,t,n){(function(r,i,s){var l=n(84),o=n(7),c=n(85),u=n(31),f=n(191),E=c.IncomingMessage,_=c.readyStates,h=e.exports=function(b){var A,j=this;u.Writable.call(j),j._opts=b,j._body=[],j._headers={},b.auth&&j.setHeader("Authorization","Basic "+new r(b.auth).toString("base64")),Object.keys(b.headers).forEach(function(M){j.setHeader(M,b.headers[M])});var F=!0;if(b.mode==="disable-fetch"||"requestTimeout"in b&&!l.abortController)F=!1,A=!0;else if(b.mode==="prefer-streaming")A=!1;else if(b.mode==="allow-wrong-content-type")A=!l.overrideMimeType;else{if(b.mode&&b.mode!=="default"&&b.mode!=="prefer-fast")throw new Error("Invalid value for opts.mode");A=!0}j._mode=function(M,R){return l.fetch&&R?"fetch":l.mozchunkedarraybuffer?"moz-chunked-arraybuffer":l.msstream?"ms-stream":l.arraybuffer&&M?"arraybuffer":l.vbArray&&M?"text:vbarray":"text"}(A,F),j._fetchTimer=null,j.on("finish",function(){j._onFinish()})};o(h,u.Writable),h.prototype.setHeader=function(b,A){var j=b.toLowerCase();g.indexOf(j)===-1&&(this._headers[j]={name:b,value:A})},h.prototype.getHeader=function(b){var A=this._headers[b.toLowerCase()];return A?A.value:null},h.prototype.removeHeader=function(b){delete this._headers[b.toLowerCase()]},h.prototype._onFinish=function(){var b=this;if(!b._destroyed){var A=b._opts,j=b._headers,F=null;A.method!=="GET"&&A.method!=="HEAD"&&(F=l.arraybuffer?f(r.concat(b._body)):l.blobConstructor?new i.Blob(b._body.map(function($){return f($)}),{type:(j["content-type"]||{}).value||""}):r.concat(b._body).toString());var M=[];if(Object.keys(j).forEach(function($){var q=j[$].name,y=j[$].value;Array.isArray(y)?y.forEach(function(m){M.push([q,m])}):M.push([q,y])}),b._mode==="fetch"){var R=null;if(l.abortController){var d=new AbortController;R=d.signal,b._fetchAbortController=d,"requestTimeout"in A&&A.requestTimeout!==0&&(b._fetchTimer=i.setTimeout(function(){b.emit("requestTimeout"),b._fetchAbortController&&b._fetchAbortController.abort()},A.requestTimeout))}i.fetch(b._opts.url,{method:b._opts.method,headers:M,body:F||void 0,mode:"cors",credentials:A.withCredentials?"include":"same-origin",signal:R}).then(function($){b._fetchResponse=$,b._connect()},function($){i.clearTimeout(b._fetchTimer),b._destroyed||b.emit("error",$)})}else{var I=b._xhr=new i.XMLHttpRequest;try{I.open(b._opts.method,b._opts.url,!0)}catch($){return void s.nextTick(function(){b.emit("error",$)})}"responseType"in I&&(I.responseType=b._mode.split(":")[0]),"withCredentials"in I&&(I.withCredentials=!!A.withCredentials),b._mode==="text"&&"overrideMimeType"in I&&I.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in A&&(I.timeout=A.requestTimeout,I.ontimeout=function(){b.emit("requestTimeout")}),M.forEach(function($){I.setRequestHeader($[0],$[1])}),b._response=null,I.onreadystatechange=function(){switch(I.readyState){case _.LOADING:case _.DONE:b._onXHRProgress()}},b._mode==="moz-chunked-arraybuffer"&&(I.onprogress=function(){b._onXHRProgress()}),I.onerror=function(){b._destroyed||b.emit("error",new Error("XHR error"))};try{I.send(F)}catch($){return void s.nextTick(function(){b.emit("error",$)})}}}},h.prototype._onXHRProgress=function(){(function(b){try{var A=b.status;return A!==null&&A!==0}catch{return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},h.prototype._connect=function(){var b=this;b._destroyed||(b._response=new E(b._xhr,b._fetchResponse,b._mode,b._fetchTimer),b._response.on("error",function(A){b.emit("error",A)}),b.emit("response",b._response))},h.prototype._write=function(b,A,j){this._body.push(b),j()},h.prototype.abort=h.prototype.destroy=function(){this._destroyed=!0,i.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},h.prototype.end=function(b,A,j){typeof b=="function"&&(j=b,b=void 0),u.Writable.prototype.end.call(this,b,A,j)},h.prototype.flushHeaders=function(){},h.prototype.setTimeout=function(){},h.prototype.setNoDelay=function(){},h.prototype.setSocketKeepAlive=function(){};var g=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,n(5).Buffer,n(6),n(2))},function(e,t,n){var r=n(5).Buffer;e.exports=function(i){if(i instanceof Uint8Array){if(i.byteOffset===0&&i.byteLength===i.buffer.byteLength)return i.buffer;if(typeof i.buffer.slice=="function")return i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}if(r.isBuffer(i)){for(var s=new Uint8Array(i.length),l=i.length,o=0;o<l;o++)s[o]=i[o];return s.buffer}throw new Error("Argument must be a Buffer")}},function(e,t){e.exports=function(){for(var r={},i=0;i<arguments.length;i++){var s=arguments[i];for(var l in s)n.call(s,l)&&(r[l]=s[l])}return r};var n=Object.prototype.hasOwnProperty},function(e,t){e.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},function(e,t,n){(function(r,i){var s;(function(l){t&&t.nodeType,r&&r.nodeType;var o=typeof i=="object"&&i;o.global!==o&&o.window!==o&&o.self;var c,u=2147483647,f=/^xn--/,E=/[^\x20-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},g=Math.floor,b=String.fromCharCode;function A(y){throw new RangeError(h[y])}function j(y,m){for(var C=y.length,w=[];C--;)w[C]=m(y[C]);return w}function F(y,m){var C=y.split("@"),w="";return C.length>1&&(w=C[0]+"@",y=C[1]),w+j((y=y.replace(_,".")).split("."),m).join(".")}function M(y){for(var m,C,w=[],L=0,W=y.length;L<W;)(m=y.charCodeAt(L++))>=55296&&m<=56319&&L<W?(64512&(C=y.charCodeAt(L++)))==56320?w.push(((1023&m)<<10)+(1023&C)+65536):(w.push(m),L--):w.push(m);return w}function R(y){return j(y,function(m){var C="";return m>65535&&(C+=b((m-=65536)>>>10&1023|55296),m=56320|1023&m),C+=b(m)}).join("")}function d(y,m){return y+22+75*(y<26)-((m!=0)<<5)}function I(y,m,C){var w=0;for(y=C?g(y/700):y>>1,y+=g(y/m);y>455;w+=36)y=g(y/35);return g(w+36*y/(y+38))}function $(y){var m,C,w,L,W,k,N,P,z,O,p,U=[],V=y.length,Q=0,ee=128,ne=72;for((C=y.lastIndexOf("-"))<0&&(C=0),w=0;w<C;++w)y.charCodeAt(w)>=128&&A("not-basic"),U.push(y.charCodeAt(w));for(L=C>0?C+1:0;L<V;){for(W=Q,k=1,N=36;L>=V&&A("invalid-input"),((P=(p=y.charCodeAt(L++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:36)>=36||P>g((u-Q)/k))&&A("overflow"),Q+=P*k,!(P<(z=N<=ne?1:N>=ne+26?26:N-ne));N+=36)k>g(u/(O=36-z))&&A("overflow"),k*=O;ne=I(Q-W,m=U.length+1,W==0),g(Q/m)>u-ee&&A("overflow"),ee+=g(Q/m),Q%=m,U.splice(Q++,0,ee)}return R(U)}function q(y){var m,C,w,L,W,k,N,P,z,O,p,U,V,Q,ee,ne=[];for(U=(y=M(y)).length,m=128,C=0,W=72,k=0;k<U;++k)(p=y[k])<128&&ne.push(b(p));for(w=L=ne.length,L&&ne.push("-");w<U;){for(N=u,k=0;k<U;++k)(p=y[k])>=m&&p<N&&(N=p);for(N-m>g((u-C)/(V=w+1))&&A("overflow"),C+=(N-m)*V,m=N,k=0;k<U;++k)if((p=y[k])<m&&++C>u&&A("overflow"),p==m){for(P=C,z=36;!(P<(O=z<=W?1:z>=W+26?26:z-W));z+=36)ee=P-O,Q=36-O,ne.push(b(d(O+ee%Q,0))),P=g(ee/Q);ne.push(b(d(P,0))),W=I(C,V,w==L),C=0,++w}++C,++m}return ne.join("")}c={version:"1.4.1",ucs2:{decode:M,encode:R},decode:$,encode:q,toASCII:function(y){return F(y,function(m){return E.test(m)?"xn--"+q(m):m})},toUnicode:function(y){return F(y,function(m){return f.test(m)?$(m.slice(4).toLowerCase()):m})}},(s=function(){return c}.call(t,n,t,r))===void 0||(r.exports=s)})()}).call(this,n(195)(e),n(6))},function(e,t){e.exports=function(n){return n.webpackPolyfill||(n.deprecate=function(){},n.paths=[],n.children||(n.children=[]),Object.defineProperty(n,"loaded",{enumerable:!0,get:function(){return n.l}}),Object.defineProperty(n,"id",{enumerable:!0,get:function(){return n.i}}),n.webpackPolyfill=1),n}},function(e,t,n){e.exports={isString:function(r){return typeof r=="string"},isObject:function(r){return typeof r=="object"&&r!==null},isNull:function(r){return r===null},isNullOrUndefined:function(r){return r==null}}},function(e,t,n){t.decode=t.parse=n(198),t.encode=t.stringify=n(199)},function(e,t,n){function r(s,l){return Object.prototype.hasOwnProperty.call(s,l)}e.exports=function(s,l,o,c){l=l||"&",o=o||"=";var u={};if(typeof s!="string"||s.length===0)return u;var f=/\+/g;s=s.split(l);var E=1e3;c&&typeof c.maxKeys=="number"&&(E=c.maxKeys);var _=s.length;E>0&&_>E&&(_=E);for(var h=0;h<_;++h){var g,b,A,j,F=s[h].replace(f,"%20"),M=F.indexOf(o);M>=0?(g=F.substr(0,M),b=F.substr(M+1)):(g=F,b=""),A=decodeURIComponent(g),j=decodeURIComponent(b),r(u,A)?i(u[A])?u[A].push(j):u[A]=[u[A],j]:u[A]=j}return u};var i=Array.isArray||function(s){return Object.prototype.toString.call(s)==="[object Array]"}},function(e,t,n){var r=function(o){switch(typeof o){case"string":return o;case"boolean":return o?"true":"false";case"number":return isFinite(o)?o:"";default:return""}};e.exports=function(o,c,u,f){return c=c||"&",u=u||"=",o===null&&(o=void 0),typeof o=="object"?s(l(o),function(E){var _=encodeURIComponent(r(E))+u;return i(o[E])?s(o[E],function(h){return _+encodeURIComponent(r(h))}).join(c):_+encodeURIComponent(r(o[E]))}).join(c):f?encodeURIComponent(r(f))+u+encodeURIComponent(r(o)):""};var i=Array.isArray||function(o){return Object.prototype.toString.call(o)==="[object Array]"};function s(o,c){if(o.map)return o.map(c);for(var u=[],f=0;f<o.length;f++)u.push(c(o[f],f));return u}var l=Object.keys||function(o){var c=[];for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&c.push(u);return c}},function(e,t,n){var r=n(83),i=n(86),s=e.exports;for(var l in r)r.hasOwnProperty(l)&&(s[l]=r[l]);function o(c){if(typeof c=="string"&&(c=i.parse(c)),c.protocol||(c.protocol="https:"),c.protocol!=="https:")throw new Error('Protocol "'+c.protocol+'" not supported. Expected "https:"');return c}s.request=function(c,u){return c=o(c),r.request.call(this,c,u)},s.get=function(c,u){return c=o(c),r.get.call(this,c,u)}},function(e,t,n){(function(r){function i(b){return(i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(b)}function s(b,A){if(!(b instanceof A))throw new TypeError("Cannot call a class as a function")}function l(b,A){for(var j=0;j<A.length;j++){var F=A[j];F.enumerable=F.enumerable||!1,F.configurable=!0,"value"in F&&(F.writable=!0),Object.defineProperty(b,F.key,F)}}function o(b,A){return(o=Object.setPrototypeOf||function(j,F){return j.__proto__=F,j})(b,A)}function c(b){var A=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var j,F=f(b);if(A){var M=f(this).constructor;j=Reflect.construct(F,arguments,M)}else j=F.apply(this,arguments);return u(this,j)}}function u(b,A){return!A||i(A)!=="object"&&typeof A!="function"?function(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}(b):A}function f(b){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)})(b)}var E=n(87),_=n(3).MESSAGE,h=n(18),g=n(20);e.exports=function(b){(function(R,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");R.prototype=Object.create(d&&d.prototype,{constructor:{value:R,writable:!0,configurable:!0}}),d&&o(R,d)})(M,b);var A,j,F=c(M);function M(){var R,d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(s(this,M),R=F.call(this,d),!d.stream||!E(d.stream))throw new Error("options.stream is required.");return R._stream=d.stream,R._stream.setMaxListeners(1/0),R.isObjectMode=d.stream._writableState.objectMode,R.eol=d.eol||h.EOL,R}return A=M,(j=[{key:"log",value:function(R,d){var I=this;if(r(function(){return I.emit("logged",R)}),this.isObjectMode)return this._stream.write(R),void(d&&d());this._stream.write("".concat(R[_]).concat(this.eol)),d&&d()}}])&&l(A.prototype,j),M}(g)}).call(this,n(15).setImmediate)},function(e,t,n){(function(r){function i(w,L,W){return L in w?Object.defineProperty(w,L,{value:W,enumerable:!0,configurable:!0,writable:!0}):w[L]=W,w}function s(w){return(s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L})(w)}function l(w,L){for(var W=0;W<L.length;W++){var k=L[W];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(w,k.key,k)}}function o(w,L){return(o=Object.setPrototypeOf||function(W,k){return W.__proto__=k,W})(w,L)}function c(w){var L=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var W,k=f(w);if(L){var N=f(this).constructor;W=Reflect.construct(k,arguments,N)}else W=k.apply(this,arguments);return u(this,W)}}function u(w,L){return!L||s(L)!=="object"&&typeof L!="function"?function(W){if(W===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return W}(w):L}function f(w){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(L){return L.__proto__||Object.getPrototypeOf(L)})(w)}var E=n(32),_=E.Stream,h=E.Transform,g=n(51),b=n(3),A=b.LEVEL,j=b.SPLAT,F=n(87),M=n(89),R=n(93),d=n(206),I=n(207),$=n(61).warn,q=n(50),y=/%[scdjifoO%]/g,m=function(w){(function(P,z){if(typeof z!="function"&&z!==null)throw new TypeError("Super expression must either be null or a function");P.prototype=Object.create(z&&z.prototype,{constructor:{value:P,writable:!0,configurable:!0}}),z&&o(P,z)})(N,w);var L,W,k=c(N);function N(P){var z;return function(O,p){if(!(O instanceof p))throw new TypeError("Cannot call a class as a function")}(this,N),(z=k.call(this,{objectMode:!0})).configure(P),z}return L=N,(W=[{key:"child",value:function(P){var z=this;return Object.create(z,{write:{value:function(O){var p=Object.assign({},P,O);O instanceof Error&&(p.stack=O.stack,p.message=O.message),z.write(p)}}})}},{key:"configure",value:function(){var P=this,z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},O=z.silent,p=z.format,U=z.defaultMeta,V=z.levels,Q=z.level,ee=Q===void 0?"info":Q,ne=z.exitOnError,Y=ne===void 0||ne,G=z.transports,S=z.colors,T=z.emitErrs,B=z.formatters,J=z.padLevels,K=z.rewriters,re=z.stripColors,se=z.exceptionHandlers,fe=z.rejectionHandlers;if(this.transports.length&&this.clear(),this.silent=O,this.format=p||this.format||n(208)(),this.defaultMeta=U||null,this.levels=V||this.levels||q.npm.levels,this.level=ee,this.exceptions=new M(this),this.rejections=new R(this),this.profilers={},this.exitOnError=Y,G&&(G=Array.isArray(G)?G:[G]).forEach(function(ve){return P.add(ve)}),S||T||B||J||K||re)throw new Error(["{ colors, emitErrs, formatters, padLevels, rewriters, stripColors } were removed in winston@3.0.0.","Use a custom winston.format(function) instead.","See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md"].join(`
|
|
43
|
+
`))},l.prototype.close=function(){this.transport.close&&this.transport.close(),this.transport.__winstonError&&(this.transport.removeListener("error",this.transport.__winstonError),this.transport.__winstonError=null)}},function(e,t,n){(function(r,i){function s(y){return(s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m})(y)}function l(y,m){if(!(y instanceof m))throw new TypeError("Cannot call a class as a function")}function o(y,m){for(var C=0;C<m.length;C++){var w=m[C];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(y,w.key,w)}}function c(y,m){return(c=Object.setPrototypeOf||function(C,w){return C.__proto__=w,C})(y,m)}function u(y){var m=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var C,w=_(y);if(m){var L=_(this).constructor;C=Reflect.construct(w,arguments,L)}else C=w.apply(this,arguments);return f(this,C)}}function f(y,m){return!m||s(m)!=="object"&&typeof m!="function"?E(y):m}function E(y){if(y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y}function _(y){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(m){return m.__proto__||Object.getPrototypeOf(m)})(y)}var h=n(65),g=n(56),b=n(150),A=n(160),j=n(3).MESSAGE,F=n(32),M=F.Stream,R=F.PassThrough,d=n(20),I=n(38)("winston:file"),$=n(18),q=n(188);e.exports=function(y){(function(W,k){if(typeof k!="function"&&k!==null)throw new TypeError("Super expression must either be null or a function");W.prototype=Object.create(k&&k.prototype,{constructor:{value:W,writable:!0,configurable:!0}}),k&&c(W,k)})(L,y);var m,C,w=u(L);function L(){var W,k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};function N(P){for(var z=arguments.length,O=new Array(z>1?z-1:0),p=1;p<z;p++)O[p-1]=arguments[p];O.slice(1).forEach(function(U){if(k[U])throw new Error("Cannot set ".concat(U," and ").concat(P," together"))})}if(l(this,L),(W=w.call(this,k)).name=k.name||"file",W._stream=new R,W._stream.setMaxListeners(30),W._onError=W._onError.bind(E(W)),k.filename||k.dirname)N("filename or dirname","stream"),W._basename=W.filename=k.filename?g.basename(k.filename):"winston.log",W.dirname=k.dirname||g.dirname(k.filename),W.options=k.options||{flags:"a"};else{if(!k.stream)throw new Error("Cannot log to file without filename or stream.");console.warn("options.stream will be removed in winston@4. Use winston.transports.Stream"),N("stream","filename","maxsize"),W._dest=W._stream.pipe(W._setupStream(k.stream)),W.dirname=g.dirname(W._dest.path)}return W.maxsize=k.maxsize||null,W.rotationFormat=k.rotationFormat||!1,W.zippedArchive=k.zippedArchive||!1,W.maxFiles=k.maxFiles||null,W.eol=k.eol||$.EOL,W.tailable=k.tailable||!1,W._size=0,W._pendingSize=0,W._created=0,W._drain=!1,W._opening=!1,W._ending=!1,W.dirname&&W._createLogDirIfNotExist(W.dirname),W.open(),W}return m=L,(C=[{key:"finishIfEnding",value:function(){var W=this;this._ending&&(this._opening?this.once("open",function(){W._stream.once("finish",function(){return W.emit("finish")}),r(function(){return W._stream.end()})}):(this._stream.once("finish",function(){return W.emit("finish")}),r(function(){return W._stream.end()})))}},{key:"log",value:function(W){var k=this,N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){};if(this.silent)return N(),!0;if(this._drain)this._stream.once("drain",function(){k._drain=!1,k.log(W,N)});else{if(!this._rotate){var P="".concat(W[j]).concat(this.eol),z=i.byteLength(P);this._pendingSize+=z,this._opening&&!this.rotatedWhileOpening&&this._needsNewFile(this._size+this._pendingSize)&&(this.rotatedWhileOpening=!0);var O=this._stream.write(P,p.bind(this));return O?N():(this._drain=!0,this._stream.once("drain",function(){k._drain=!1,N()})),I("written",O,this._drain),this.finishIfEnding(),O}this._stream.once("rotate",function(){k._rotate=!1,k.log(W,N)})}function p(){var U=this;this._size+=z,this._pendingSize-=z,I("logged %s %s",this._size,P),this.emit("logged",W),this._opening||this._needsNewFile()&&(this._rotate=!0,this._endStream(function(){return U._rotateFile()}))}}},{key:"query",value:function(W,k){typeof W=="function"&&(k=W,W={}),W=function(V){return(V=V||{}).rows=V.rows||V.limit||10,V.start=V.start||0,V.until=V.until||new Date,s(V.until)!=="object"&&(V.until=new Date(V.until)),V.from=V.from||V.until-864e5,s(V.from)!=="object"&&(V.from=new Date(V.from)),V.order=V.order||"desc",V}(W);var N=g.join(this.dirname,this.filename),P="",z=[],O=0,p=h.createReadStream(N,{encoding:"utf8"});function U(V,Q){try{var ee=JSON.parse(V);(function(ne){if(ne&&s(ne)==="object"){var Y=new Date(ne.timestamp);if(!(W.from&&Y<W.from||W.until&&Y>W.until||W.level&&W.level!==ne.level))return!0}})(ee)&&function(ne){W.rows&&z.length>=W.rows&&W.order!=="desc"?p.readable&&p.destroy():(W.fields&&(ne=W.fields.reduce(function(Y,G){return Y[G]=ne[G],Y},{})),W.order==="desc"&&z.length>=W.rows&&z.shift(),z.push(ne))}(ee)}catch(ne){Q||p.emit("error",ne)}}p.on("error",function(V){if(p.readable&&p.destroy(),k)return V.code!=="ENOENT"?k(V):k(null,z)}),p.on("data",function(V){for(var Q=(V=(P+V).split(/\n+/)).length-1,ee=0;ee<Q;ee++)(!W.start||O>=W.start)&&U(V[ee]),O++;P=V[Q]}),p.on("close",function(){P&&U(P,!0),W.order==="desc"&&(z=z.reverse()),k&&k(null,z)})}},{key:"stream",value:function(){var W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},k=g.join(this.dirname,this.filename),N=new M,P={file:k,start:W.start};return N.destroy=q(P,function(z,O){if(z)return N.emit("error",z);try{N.emit("data",O),O=JSON.parse(O),N.emit("log",O)}catch(p){N.emit("error",p)}}),N}},{key:"open",value:function(){var W=this;this.filename&&(this._opening||(this._opening=!0,this.stat(function(k,N){if(k)return W.emit("error",k);I("stat done: %s { size: %s }",W.filename,N),W._size=N,W._dest=W._createStream(W._stream),W._opening=!1,W.once("open",function(){W._stream.eventNames().includes("rotate")?W._stream.emit("rotate"):W._rotate=!1})})))}},{key:"stat",value:function(W){var k=this,N=this._getFile(),P=g.join(this.dirname,N);h.stat(P,function(z,O){return z&&z.code==="ENOENT"?(I("ENOENT ok",P),k.filename=N,W(null,0)):z?(I("err ".concat(z.code," ").concat(P)),W(z)):!O||k._needsNewFile(O.size)?k._incFile(function(){return k.stat(W)}):(k.filename=N,void W(null,O.size))})}},{key:"close",value:function(W){var k=this;this._stream&&this._stream.end(function(){W&&W(),k.emit("flush"),k.emit("closed")})}},{key:"_needsNewFile",value:function(W){return W=W||this._size,this.maxsize&&W>=this.maxsize}},{key:"_onError",value:function(W){this.emit("error",W)}},{key:"_setupStream",value:function(W){return W.on("error",this._onError),W}},{key:"_cleanupStream",value:function(W){return W.removeListener("error",this._onError),W}},{key:"_rotateFile",value:function(){var W=this;this._incFile(function(){return W.open()})}},{key:"_endStream",value:function(){var W=this,k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(){};this._dest?(this._stream.unpipe(this._dest),this._dest.end(function(){W._cleanupStream(W._dest),k()})):k()}},{key:"_createStream",value:function(W){var k=this,N=g.join(this.dirname,this.filename);I("create stream start",N,this.options);var P=h.createWriteStream(N,this.options).on("error",function(O){return I(O)}).on("close",function(){return I("close",P.path,P.bytesWritten)}).on("open",function(){I("file open ok",N),k.emit("open",N),W.pipe(P),k.rotatedWhileOpening&&(k._stream=new R,k._stream.setMaxListeners(30),k._rotateFile(),k.rotatedWhileOpening=!1,k._cleanupStream(P),W.end())});if(I("create stream ok",N),this.zippedArchive){var z=A.createGzip();return z.pipe(P),z}return P}},{key:"_incFile",value:function(W){I("_incFile",this.filename);var k=g.extname(this._basename),N=g.basename(this._basename,k);this.tailable?this._checkMaxFilesTailable(k,N,W):(this._created+=1,this._checkMaxFilesIncrementing(k,N,W))}},{key:"_getFile",value:function(){var W=g.extname(this._basename),k=g.basename(this._basename,W),N=this.rotationFormat?this.rotationFormat():this._created,P=!this.tailable&&this._created?"".concat(k).concat(N).concat(W):"".concat(k).concat(W);return this.zippedArchive&&!this.tailable?"".concat(P,".gz"):P}},{key:"_checkMaxFilesIncrementing",value:function(W,k,N){if(!this.maxFiles||this._created<this.maxFiles)return r(N);var P=this._created-this.maxFiles,z=P!==0?P:"",O=this.zippedArchive?".gz":"",p="".concat(k).concat(z).concat(W).concat(O),U=g.join(this.dirname,p);h.unlink(U,N)}},{key:"_checkMaxFilesTailable",value:function(W,k,N){var P=this,z=[];if(this.maxFiles){for(var O=this.zippedArchive?".gz":"",p=this.maxFiles-1;p>1;p--)z.push(function(U,V){var Q=this,ee="".concat(k).concat(U-1).concat(W).concat(O),ne=g.join(this.dirname,ee);h.exists(ne,function(Y){if(!Y)return V(null);ee="".concat(k).concat(U).concat(W).concat(O),h.rename(ne,g.join(Q.dirname,ee),V)})}.bind(this,p));b(z,function(){h.rename(g.join(P.dirname,"".concat(k).concat(W)),g.join(P.dirname,"".concat(k,"1").concat(W).concat(O)),N)})}}},{key:"_createLogDirIfNotExist",value:function(W){h.existsSync(W)||h.mkdirSync(W,{recursive:!0})}}])&&o(m.prototype,C),L}(d)}).call(this,n(15).setImmediate,n(5).Buffer)},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(l,o){return(0,r.default)(i.default,l,o)};var r=s(n(151)),i=s(n(155));function s(l){return l&&l.__esModule?l:{default:l}}e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=l(n(45)),i=l(n(25)),s=l(n(30));function l(o){return o&&o.__esModule?o:{default:o}}t.default=(0,s.default)((o,c,u)=>{var f=(0,r.default)(c)?[]:{};o(c,(E,_,h)=>{(0,i.default)(E)((g,...b)=>{b.length<2&&([b]=b),f[_]=b,h(g)})},E=>u(E,f))},3),e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(u){return(0,s.isAsync)(u)?function(...f){const E=f.pop();return o(u.apply(this,f),E)}:(0,r.default)(function(f,E){var _;try{_=u.apply(this,f)}catch(h){return E(h)}if(_&&typeof _.then=="function")return o(_,E);E(null,_)})};var r=l(n(153)),i=l(n(154)),s=n(25);function l(u){return u&&u.__esModule?u:{default:u}}function o(u,f){return u.then(E=>{c(f,null,E)},E=>{c(f,E&&E.message?E:new Error(E))})}function c(u,f,E){try{u(f,E)}catch(_){(0,i.default)(h=>{throw h},_)}}e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return function(...i){var s=i.pop();return r.call(this,i,s)}},e.exports=t.default},function(e,t,n){(function(r,i){Object.defineProperty(t,"__esModule",{value:!0}),t.fallback=u,t.wrap=f;var s,l=t.hasQueueMicrotask=typeof queueMicrotask=="function"&&queueMicrotask,o=t.hasSetImmediate=typeof r=="function"&&r,c=t.hasNextTick=typeof i=="object"&&typeof i.nextTick=="function";function u(E){setTimeout(E,0)}function f(E){return(_,...h)=>E(()=>_(...h))}s=l?queueMicrotask:o?r:c?i.nextTick:u,t.default=f(s)}).call(this,n(15).setImmediate,n(2))},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=s(n(66)),i=s(n(30));function s(l){return l&&l.__esModule?l:{default:l}}t.default=(0,i.default)(function(l,o,c){return(0,r.default)(l,1,o,c)},3),e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=u(n(67)),i=u(n(157)),s=u(n(68)),l=n(25),o=u(n(159)),c=u(n(46));function u(f){return f&&f.__esModule?f:{default:f}}t.default=f=>(E,_,h)=>{if(h=(0,r.default)(h),f<=0)throw new RangeError("concurrency limit cannot be less than 1");if(!E)return h(null);if((0,l.isAsyncGenerator)(E))return(0,o.default)(E,f,_,h);if((0,l.isAsyncIterable)(E))return(0,o.default)(E[Symbol.asyncIterator](),f,_,h);var g=(0,i.default)(E),b=!1,A=!1,j=0,F=!1;function M(d,I){if(!A)if(j-=1,d)b=!0,h(d);else if(d===!1)b=!0,A=!0;else{if(I===c.default||b&&j<=0)return b=!0,h(null);F||R()}}function R(){for(F=!0;j<f&&!b;){var d=g();if(d===null)return b=!0,void(j<=0&&h(null));j+=1,_(d.value,d.key,(0,s.default)(M))}F=!1}R()},e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(l){if((0,r.default)(l))return function(_){var h=-1,g=_.length;return function(){return++h<g?{value:_[h],key:h}:null}}(l);var o=(0,i.default)(l);return o?function(_){var h=-1;return function(){var g=_.next();return g.done?null:(h++,{value:g.value,key:h})}}(o):(c=l,u=c?Object.keys(c):[],f=-1,E=u.length,function _(){var h=u[++f];return h==="__proto__"?_():f<E?{value:c[h],key:h}:null});var c,u,f,E};var r=s(n(45)),i=s(n(158));function s(l){return l&&l.__esModule?l:{default:l}}e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return r[Symbol.iterator]&&r[Symbol.iterator]()},e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(l,o,c,u){let f=!1,E=!1,_=!1,h=0,g=0;function b(){h>=o||_||f||(_=!0,l.next().then(({value:F,done:M})=>{if(!E&&!f){if(_=!1,M)return f=!0,void(h<=0&&u(null));h++,c(F,g,A),g++,b()}}).catch(j))}function A(F,M){if(h-=1,!E)return F?j(F):F===!1?(f=!0,void(E=!0)):M===s.default||f&&h<=0?(f=!0,u(null)):void b()}function j(F){E||(_=!1,f=!0,u(F))}b()};var r,i=n(46),s=(r=i)&&r.__esModule?r:{default:r};e.exports=t.default},function(e,t,n){(function(r){var i=n(5).Buffer,s=n(161).Transform,l=n(169),o=n(13),c=n(74).ok,u=n(5).kMaxLength,f="Cannot create final Buffer. It would be larger than 0x"+u.toString(16)+" bytes";l.Z_MIN_WINDOWBITS=8,l.Z_MAX_WINDOWBITS=15,l.Z_DEFAULT_WINDOWBITS=15,l.Z_MIN_CHUNK=64,l.Z_MAX_CHUNK=1/0,l.Z_DEFAULT_CHUNK=16384,l.Z_MIN_MEMLEVEL=1,l.Z_MAX_MEMLEVEL=9,l.Z_DEFAULT_MEMLEVEL=8,l.Z_MIN_LEVEL=-1,l.Z_MAX_LEVEL=9,l.Z_DEFAULT_LEVEL=l.Z_DEFAULT_COMPRESSION;for(var E=Object.keys(l),_=0;_<E.length;_++){var h=E[_];h.match(/^Z/)&&Object.defineProperty(t,h,{enumerable:!0,value:l[h],writable:!1})}for(var g={Z_OK:l.Z_OK,Z_STREAM_END:l.Z_STREAM_END,Z_NEED_DICT:l.Z_NEED_DICT,Z_ERRNO:l.Z_ERRNO,Z_STREAM_ERROR:l.Z_STREAM_ERROR,Z_DATA_ERROR:l.Z_DATA_ERROR,Z_MEM_ERROR:l.Z_MEM_ERROR,Z_BUF_ERROR:l.Z_BUF_ERROR,Z_VERSION_ERROR:l.Z_VERSION_ERROR},b=Object.keys(g),A=0;A<b.length;A++){var j=b[A];g[g[j]]=j}function F(k,N,P){var z=[],O=0;function p(){for(var V;(V=k.read())!==null;)z.push(V),O+=V.length;k.once("readable",p)}function U(){var V,Q=null;O>=u?Q=new RangeError(f):V=i.concat(z,O),z=[],k.close(),P(Q,V)}k.on("error",function(V){k.removeListener("end",U),k.removeListener("readable",p),P(V)}),k.on("end",U),k.end(N),p()}function M(k,N){if(typeof N=="string"&&(N=i.from(N)),!i.isBuffer(N))throw new TypeError("Not a string or buffer");var P=k._finishFlushFlag;return k._processChunk(N,P)}function R(k){if(!(this instanceof R))return new R(k);w.call(this,k,l.DEFLATE)}function d(k){if(!(this instanceof d))return new d(k);w.call(this,k,l.INFLATE)}function I(k){if(!(this instanceof I))return new I(k);w.call(this,k,l.GZIP)}function $(k){if(!(this instanceof $))return new $(k);w.call(this,k,l.GUNZIP)}function q(k){if(!(this instanceof q))return new q(k);w.call(this,k,l.DEFLATERAW)}function y(k){if(!(this instanceof y))return new y(k);w.call(this,k,l.INFLATERAW)}function m(k){if(!(this instanceof m))return new m(k);w.call(this,k,l.UNZIP)}function C(k){return k===l.Z_NO_FLUSH||k===l.Z_PARTIAL_FLUSH||k===l.Z_SYNC_FLUSH||k===l.Z_FULL_FLUSH||k===l.Z_FINISH||k===l.Z_BLOCK}function w(k,N){var P=this;if(this._opts=k=k||{},this._chunkSize=k.chunkSize||t.Z_DEFAULT_CHUNK,s.call(this,k),k.flush&&!C(k.flush))throw new Error("Invalid flush flag: "+k.flush);if(k.finishFlush&&!C(k.finishFlush))throw new Error("Invalid flush flag: "+k.finishFlush);if(this._flushFlag=k.flush||l.Z_NO_FLUSH,this._finishFlushFlag=k.finishFlush!==void 0?k.finishFlush:l.Z_FINISH,k.chunkSize&&(k.chunkSize<t.Z_MIN_CHUNK||k.chunkSize>t.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+k.chunkSize);if(k.windowBits&&(k.windowBits<t.Z_MIN_WINDOWBITS||k.windowBits>t.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+k.windowBits);if(k.level&&(k.level<t.Z_MIN_LEVEL||k.level>t.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+k.level);if(k.memLevel&&(k.memLevel<t.Z_MIN_MEMLEVEL||k.memLevel>t.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+k.memLevel);if(k.strategy&&k.strategy!=t.Z_FILTERED&&k.strategy!=t.Z_HUFFMAN_ONLY&&k.strategy!=t.Z_RLE&&k.strategy!=t.Z_FIXED&&k.strategy!=t.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+k.strategy);if(k.dictionary&&!i.isBuffer(k.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new l.Zlib(N);var z=this;this._hadError=!1,this._handle.onerror=function(U,V){L(z),z._hadError=!0;var Q=new Error(U);Q.errno=V,Q.code=t.codes[V],z.emit("error",Q)};var O=t.Z_DEFAULT_COMPRESSION;typeof k.level=="number"&&(O=k.level);var p=t.Z_DEFAULT_STRATEGY;typeof k.strategy=="number"&&(p=k.strategy),this._handle.init(k.windowBits||t.Z_DEFAULT_WINDOWBITS,O,k.memLevel||t.Z_DEFAULT_MEMLEVEL,p,k.dictionary),this._buffer=i.allocUnsafe(this._chunkSize),this._offset=0,this._level=O,this._strategy=p,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!P._handle},configurable:!0,enumerable:!0})}function L(k,N){N&&r.nextTick(N),k._handle&&(k._handle.close(),k._handle=null)}function W(k){k.emit("close")}Object.defineProperty(t,"codes",{enumerable:!0,value:Object.freeze(g),writable:!1}),t.Deflate=R,t.Inflate=d,t.Gzip=I,t.Gunzip=$,t.DeflateRaw=q,t.InflateRaw=y,t.Unzip=m,t.createDeflate=function(k){return new R(k)},t.createInflate=function(k){return new d(k)},t.createDeflateRaw=function(k){return new q(k)},t.createInflateRaw=function(k){return new y(k)},t.createGzip=function(k){return new I(k)},t.createGunzip=function(k){return new $(k)},t.createUnzip=function(k){return new m(k)},t.deflate=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new R(N),k,P)},t.deflateSync=function(k,N){return M(new R(N),k)},t.gzip=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new I(N),k,P)},t.gzipSync=function(k,N){return M(new I(N),k)},t.deflateRaw=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new q(N),k,P)},t.deflateRawSync=function(k,N){return M(new q(N),k)},t.unzip=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new m(N),k,P)},t.unzipSync=function(k,N){return M(new m(N),k)},t.inflate=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new d(N),k,P)},t.inflateSync=function(k,N){return M(new d(N),k)},t.gunzip=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new $(N),k,P)},t.gunzipSync=function(k,N){return M(new $(N),k)},t.inflateRaw=function(k,N,P){return typeof N=="function"&&(P=N,N={}),F(new y(N),k,P)},t.inflateRawSync=function(k,N){return M(new y(N),k)},o.inherits(w,s),w.prototype.params=function(k,N,P){if(k<t.Z_MIN_LEVEL||k>t.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+k);if(N!=t.Z_FILTERED&&N!=t.Z_HUFFMAN_ONLY&&N!=t.Z_RLE&&N!=t.Z_FIXED&&N!=t.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+N);if(this._level!==k||this._strategy!==N){var z=this;this.flush(l.Z_SYNC_FLUSH,function(){c(z._handle,"zlib binding closed"),z._handle.params(k,N),z._hadError||(z._level=k,z._strategy=N,P&&P())})}else r.nextTick(P)},w.prototype.reset=function(){return c(this._handle,"zlib binding closed"),this._handle.reset()},w.prototype._flush=function(k){this._transform(i.alloc(0),"",k)},w.prototype.flush=function(k,N){var P=this,z=this._writableState;(typeof k=="function"||k===void 0&&!N)&&(N=k,k=l.Z_FULL_FLUSH),z.ended?N&&r.nextTick(N):z.ending?N&&this.once("end",N):z.needDrain?N&&this.once("drain",function(){return P.flush(k,N)}):(this._flushFlag=k,this.write(i.alloc(0),"",N))},w.prototype.close=function(k){L(this,k),r.nextTick(W,this)},w.prototype._transform=function(k,N,P){var z,O=this._writableState,p=(O.ending||O.ended)&&(!k||O.length===k.length);return k===null||i.isBuffer(k)?this._handle?(p?z=this._finishFlushFlag:(z=this._flushFlag,k.length>=O.length&&(this._flushFlag=this._opts.flush||l.Z_NO_FLUSH)),void this._processChunk(k,z,P)):P(new Error("zlib binding closed")):P(new Error("invalid input"))},w.prototype._processChunk=function(k,N,P){var z=k&&k.length,O=this._chunkSize-this._offset,p=0,U=this,V=typeof P=="function";if(!V){var Q,ee=[],ne=0;this.on("error",function(B){Q=B}),c(this._handle,"zlib binding closed");do var Y=this._handle.writeSync(N,k,p,z,this._buffer,this._offset,O);while(!this._hadError&&T(Y[0],Y[1]));if(this._hadError)throw Q;if(ne>=u)throw L(this),new RangeError(f);var G=i.concat(ee,ne);return L(this),G}c(this._handle,"zlib binding closed");var S=this._handle.write(N,k,p,z,this._buffer,this._offset,O);function T(B,J){if(this&&(this.buffer=null,this.callback=null),!U._hadError){var K=O-J;if(c(K>=0,"have should not go down"),K>0){var re=U._buffer.slice(U._offset,U._offset+K);U._offset+=K,V?U.push(re):(ee.push(re),ne+=re.length)}if((J===0||U._offset>=U._chunkSize)&&(O=U._chunkSize,U._offset=0,U._buffer=i.allocUnsafe(U._chunkSize)),J===0){if(p+=z-B,z=B,!V)return!0;var se=U._handle.write(N,k,p,z,U._buffer,U._offset,U._chunkSize);return se.callback=T,void(se.buffer=k)}if(!V)return!1;P()}}S.buffer=k,S.callback=T},o.inherits(R,w),o.inherits(d,w),o.inherits(I,w),o.inherits($,w),o.inherits(q,w),o.inherits(y,w),o.inherits(m,w)}).call(this,n(2))},function(e,t,n){e.exports=i;var r=n(21).EventEmitter;function i(){r.call(this)}n(7)(i,r),i.Readable=n(31),i.Writable=n(73),i.Duplex=n(166),i.Transform=n(167),i.PassThrough=n(168),i.Stream=i,i.prototype.pipe=function(s,l){var o=this;function c(b){s.writable&&s.write(b)===!1&&o.pause&&o.pause()}function u(){o.readable&&o.resume&&o.resume()}o.on("data",c),s.on("drain",u),s._isStdio||l&&l.end===!1||(o.on("end",E),o.on("close",_));var f=!1;function E(){f||(f=!0,s.end())}function _(){f||(f=!0,typeof s.destroy=="function"&&s.destroy())}function h(b){if(g(),r.listenerCount(this,"error")===0)throw b}function g(){o.removeListener("data",c),s.removeListener("drain",u),o.removeListener("end",E),o.removeListener("close",_),o.removeListener("error",h),s.removeListener("error",h),o.removeListener("end",g),o.removeListener("close",g),s.removeListener("close",g)}return o.on("error",h),s.on("error",h),o.on("end",g),o.on("close",g),s.on("close",g),s.emit("pipe",o),s}},function(e,t){},function(e,t,n){var r=n(47).Buffer,i=n(164);e.exports=function(){function s(){(function(l,o){if(!(l instanceof o))throw new TypeError("Cannot call a class as a function")})(this,s),this.head=null,this.tail=null,this.length=0}return s.prototype.push=function(l){var o={data:l,next:null};this.length>0?this.tail.next=o:this.head=o,this.tail=o,++this.length},s.prototype.unshift=function(l){var o={data:l,next:this.head};this.length===0&&(this.tail=o),this.head=o,++this.length},s.prototype.shift=function(){if(this.length!==0){var l=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,l}},s.prototype.clear=function(){this.head=this.tail=null,this.length=0},s.prototype.join=function(l){if(this.length===0)return"";for(var o=this.head,c=""+o.data;o=o.next;)c+=l+o.data;return c},s.prototype.concat=function(l){if(this.length===0)return r.alloc(0);if(this.length===1)return this.head.data;for(var o,c,u,f=r.allocUnsafe(l>>>0),E=this.head,_=0;E;)o=E.data,c=f,u=_,o.copy(c,u),_+=E.data.length,E=E.next;return f},s}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var s=i.inspect({length:this.length});return this.constructor.name+" "+s})},function(e,t){},function(e,t,n){e.exports=s;var r=n(72),i=n(17);function s(l){if(!(this instanceof s))return new s(l);r.call(this,l)}i.inherits=n(7),i.inherits(s,r),s.prototype._transform=function(l,o,c){c(null,l)}},function(e,t,n){e.exports=n(23)},function(e,t,n){e.exports=n(31).Transform},function(e,t,n){e.exports=n(31).PassThrough},function(e,t,n){(function(r,i){var s=n(74),l=n(171),o=n(172),c=n(175),u=n(178);for(var f in u)t[f]=u[f];t.NONE=0,t.DEFLATE=1,t.INFLATE=2,t.GZIP=3,t.GUNZIP=4,t.DEFLATERAW=5,t.INFLATERAW=6,t.UNZIP=7;function E(_){if(typeof _!="number"||_<t.DEFLATE||_>t.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=_,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}E.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,s(this.init_done,"close before init"),s(this.mode<=t.UNZIP),this.mode===t.DEFLATE||this.mode===t.GZIP||this.mode===t.DEFLATERAW?o.deflateEnd(this.strm):this.mode!==t.INFLATE&&this.mode!==t.GUNZIP&&this.mode!==t.INFLATERAW&&this.mode!==t.UNZIP||c.inflateEnd(this.strm),this.mode=t.NONE,this.dictionary=null)},E.prototype.write=function(_,h,g,b,A,j,F){return this._write(!0,_,h,g,b,A,j,F)},E.prototype.writeSync=function(_,h,g,b,A,j,F){return this._write(!1,_,h,g,b,A,j,F)},E.prototype._write=function(_,h,g,b,A,j,F,M){if(s.equal(arguments.length,8),s(this.init_done,"write before init"),s(this.mode!==t.NONE,"already finalized"),s.equal(!1,this.write_in_progress,"write already in progress"),s.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,s.equal(!1,h===void 0,"must provide flush value"),this.write_in_progress=!0,h!==t.Z_NO_FLUSH&&h!==t.Z_PARTIAL_FLUSH&&h!==t.Z_SYNC_FLUSH&&h!==t.Z_FULL_FLUSH&&h!==t.Z_FINISH&&h!==t.Z_BLOCK)throw new Error("Invalid flush value");if(g==null&&(g=r.alloc(0),A=0,b=0),this.strm.avail_in=A,this.strm.input=g,this.strm.next_in=b,this.strm.avail_out=M,this.strm.output=j,this.strm.next_out=F,this.flush=h,!_)return this._process(),this._checkError()?this._afterSync():void 0;var R=this;return i.nextTick(function(){R._process(),R._after()}),this},E.prototype._afterSync=function(){var _=this.strm.avail_out,h=this.strm.avail_in;return this.write_in_progress=!1,[h,_]},E.prototype._process=function(){var _=null;switch(this.mode){case t.DEFLATE:case t.GZIP:case t.DEFLATERAW:this.err=o.deflate(this.strm,this.flush);break;case t.UNZIP:switch(this.strm.avail_in>0&&(_=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(_===null)break;if(this.strm.input[_]!==31){this.mode=t.INFLATE;break}if(this.gzip_id_bytes_read=1,_++,this.strm.avail_in===1)break;case 1:if(_===null)break;this.strm.input[_]===139?(this.gzip_id_bytes_read=2,this.mode=t.GUNZIP):this.mode=t.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case t.INFLATE:case t.GUNZIP:case t.INFLATERAW:for(this.err=c.inflate(this.strm,this.flush),this.err===t.Z_NEED_DICT&&this.dictionary&&(this.err=c.inflateSetDictionary(this.strm,this.dictionary),this.err===t.Z_OK?this.err=c.inflate(this.strm,this.flush):this.err===t.Z_DATA_ERROR&&(this.err=t.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===t.GUNZIP&&this.err===t.Z_STREAM_END&&this.strm.next_in[0]!==0;)this.reset(),this.err=c.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},E.prototype._checkError=function(){switch(this.err){case t.Z_OK:case t.Z_BUF_ERROR:if(this.strm.avail_out!==0&&this.flush===t.Z_FINISH)return this._error("unexpected end of file"),!1;break;case t.Z_STREAM_END:break;case t.Z_NEED_DICT:return this.dictionary==null?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},E.prototype._after=function(){if(this._checkError()){var _=this.strm.avail_out,h=this.strm.avail_in;this.write_in_progress=!1,this.callback(h,_),this.pending_close&&this.close()}},E.prototype._error=function(_){this.strm.msg&&(_=this.strm.msg),this.onerror(_,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},E.prototype.init=function(_,h,g,b,A){s(arguments.length===4||arguments.length===5,"init(windowBits, level, memLevel, strategy, [dictionary])"),s(_>=8&&_<=15,"invalid windowBits"),s(h>=-1&&h<=9,"invalid compression level"),s(g>=1&&g<=9,"invalid memlevel"),s(b===t.Z_FILTERED||b===t.Z_HUFFMAN_ONLY||b===t.Z_RLE||b===t.Z_FIXED||b===t.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(h,_,g,b,A),this._setDictionary()},E.prototype.params=function(){throw new Error("deflateParams Not supported")},E.prototype.reset=function(){this._reset(),this._setDictionary()},E.prototype._init=function(_,h,g,b,A){switch(this.level=_,this.windowBits=h,this.memLevel=g,this.strategy=b,this.flush=t.Z_NO_FLUSH,this.err=t.Z_OK,this.mode!==t.GZIP&&this.mode!==t.GUNZIP||(this.windowBits+=16),this.mode===t.UNZIP&&(this.windowBits+=32),this.mode!==t.DEFLATERAW&&this.mode!==t.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new l,this.mode){case t.DEFLATE:case t.GZIP:case t.DEFLATERAW:this.err=o.deflateInit2(this.strm,this.level,t.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case t.INFLATE:case t.GUNZIP:case t.INFLATERAW:case t.UNZIP:this.err=c.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==t.Z_OK&&this._error("Init error"),this.dictionary=A,this.write_in_progress=!1,this.init_done=!0},E.prototype._setDictionary=function(){if(this.dictionary!=null){switch(this.err=t.Z_OK,this.mode){case t.DEFLATE:case t.DEFLATERAW:this.err=o.deflateSetDictionary(this.strm,this.dictionary)}this.err!==t.Z_OK&&this._error("Failed to set dictionary")}},E.prototype._reset=function(){switch(this.err=t.Z_OK,this.mode){case t.DEFLATE:case t.DEFLATERAW:case t.GZIP:this.err=o.deflateReset(this.strm);break;case t.INFLATE:case t.INFLATERAW:case t.GUNZIP:this.err=c.inflateReset(this.strm)}this.err!==t.Z_OK&&this._error("Failed to reset stream")},t.Zlib=E}).call(this,n(5).Buffer,n(2))},function(e,t,n){var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function l(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}e.exports=function(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var c={},u=0;u<10;u++)c["_"+String.fromCharCode(u)]=u;if(Object.getOwnPropertyNames(c).map(function(E){return c[E]}).join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(E){f[E]=E}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}()?Object.assign:function(o,c){for(var u,f,E=l(o),_=1;_<arguments.length;_++){for(var h in u=Object(arguments[_]))i.call(u,h)&&(E[h]=u[h]);if(r){f=r(u);for(var g=0;g<f.length;g++)s.call(u,f[g])&&(E[f[g]]=u[f[g]])}}return E}},function(e,t,n){e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},function(e,t,n){var r,i=n(37),s=n(173),l=n(75),o=n(76),c=n(174);function u(y,m){return y.msg=c[m],m}function f(y){return(y<<1)-(y>4?9:0)}function E(y){for(var m=y.length;--m>=0;)y[m]=0}function _(y){var m=y.state,C=m.pending;C>y.avail_out&&(C=y.avail_out),C!==0&&(i.arraySet(y.output,m.pending_buf,m.pending_out,C,y.next_out),y.next_out+=C,m.pending_out+=C,y.total_out+=C,y.avail_out-=C,m.pending-=C,m.pending===0&&(m.pending_out=0))}function h(y,m){s._tr_flush_block(y,y.block_start>=0?y.block_start:-1,y.strstart-y.block_start,m),y.block_start=y.strstart,_(y.strm)}function g(y,m){y.pending_buf[y.pending++]=m}function b(y,m){y.pending_buf[y.pending++]=m>>>8&255,y.pending_buf[y.pending++]=255&m}function A(y,m){var C,w,L=y.max_chain_length,W=y.strstart,k=y.prev_length,N=y.nice_match,P=y.strstart>y.w_size-262?y.strstart-(y.w_size-262):0,z=y.window,O=y.w_mask,p=y.prev,U=y.strstart+258,V=z[W+k-1],Q=z[W+k];y.prev_length>=y.good_match&&(L>>=2),N>y.lookahead&&(N=y.lookahead);do if(z[(C=m)+k]===Q&&z[C+k-1]===V&&z[C]===z[W]&&z[++C]===z[W+1]){W+=2,C++;do;while(z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&z[++W]===z[++C]&&W<U);if(w=258-(U-W),W=U-258,w>k){if(y.match_start=m,k=w,w>=N)break;V=z[W+k-1],Q=z[W+k]}}while((m=p[m&O])>P&&--L!=0);return k<=y.lookahead?k:y.lookahead}function j(y){var m,C,w,L,W,k,N,P,z,O,p=y.w_size;do{if(L=y.window_size-y.lookahead-y.strstart,y.strstart>=p+(p-262)){i.arraySet(y.window,y.window,p,p,0),y.match_start-=p,y.strstart-=p,y.block_start-=p,m=C=y.hash_size;do w=y.head[--m],y.head[m]=w>=p?w-p:0;while(--C);m=C=p;do w=y.prev[--m],y.prev[m]=w>=p?w-p:0;while(--C);L+=p}if(y.strm.avail_in===0)break;if(k=y.strm,N=y.window,P=y.strstart+y.lookahead,z=L,O=void 0,(O=k.avail_in)>z&&(O=z),C=O===0?0:(k.avail_in-=O,i.arraySet(N,k.input,k.next_in,O,P),k.state.wrap===1?k.adler=l(k.adler,N,O,P):k.state.wrap===2&&(k.adler=o(k.adler,N,O,P)),k.next_in+=O,k.total_in+=O,O),y.lookahead+=C,y.lookahead+y.insert>=3)for(W=y.strstart-y.insert,y.ins_h=y.window[W],y.ins_h=(y.ins_h<<y.hash_shift^y.window[W+1])&y.hash_mask;y.insert&&(y.ins_h=(y.ins_h<<y.hash_shift^y.window[W+3-1])&y.hash_mask,y.prev[W&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=W,W++,y.insert--,!(y.lookahead+y.insert<3)););}while(y.lookahead<262&&y.strm.avail_in!==0)}function F(y,m){for(var C,w;;){if(y.lookahead<262){if(j(y),y.lookahead<262&&m===0)return 1;if(y.lookahead===0)break}if(C=0,y.lookahead>=3&&(y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+3-1])&y.hash_mask,C=y.prev[y.strstart&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=y.strstart),C!==0&&y.strstart-C<=y.w_size-262&&(y.match_length=A(y,C)),y.match_length>=3)if(w=s._tr_tally(y,y.strstart-y.match_start,y.match_length-3),y.lookahead-=y.match_length,y.match_length<=y.max_lazy_match&&y.lookahead>=3){y.match_length--;do y.strstart++,y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+3-1])&y.hash_mask,C=y.prev[y.strstart&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=y.strstart;while(--y.match_length!=0);y.strstart++}else y.strstart+=y.match_length,y.match_length=0,y.ins_h=y.window[y.strstart],y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+1])&y.hash_mask;else w=s._tr_tally(y,0,y.window[y.strstart]),y.lookahead--,y.strstart++;if(w&&(h(y,!1),y.strm.avail_out===0))return 1}return y.insert=y.strstart<2?y.strstart:2,m===4?(h(y,!0),y.strm.avail_out===0?3:4):y.last_lit&&(h(y,!1),y.strm.avail_out===0)?1:2}function M(y,m){for(var C,w,L;;){if(y.lookahead<262){if(j(y),y.lookahead<262&&m===0)return 1;if(y.lookahead===0)break}if(C=0,y.lookahead>=3&&(y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+3-1])&y.hash_mask,C=y.prev[y.strstart&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=y.strstart),y.prev_length=y.match_length,y.prev_match=y.match_start,y.match_length=2,C!==0&&y.prev_length<y.max_lazy_match&&y.strstart-C<=y.w_size-262&&(y.match_length=A(y,C),y.match_length<=5&&(y.strategy===1||y.match_length===3&&y.strstart-y.match_start>4096)&&(y.match_length=2)),y.prev_length>=3&&y.match_length<=y.prev_length){L=y.strstart+y.lookahead-3,w=s._tr_tally(y,y.strstart-1-y.prev_match,y.prev_length-3),y.lookahead-=y.prev_length-1,y.prev_length-=2;do++y.strstart<=L&&(y.ins_h=(y.ins_h<<y.hash_shift^y.window[y.strstart+3-1])&y.hash_mask,C=y.prev[y.strstart&y.w_mask]=y.head[y.ins_h],y.head[y.ins_h]=y.strstart);while(--y.prev_length!=0);if(y.match_available=0,y.match_length=2,y.strstart++,w&&(h(y,!1),y.strm.avail_out===0))return 1}else if(y.match_available){if((w=s._tr_tally(y,0,y.window[y.strstart-1]))&&h(y,!1),y.strstart++,y.lookahead--,y.strm.avail_out===0)return 1}else y.match_available=1,y.strstart++,y.lookahead--}return y.match_available&&(w=s._tr_tally(y,0,y.window[y.strstart-1]),y.match_available=0),y.insert=y.strstart<2?y.strstart:2,m===4?(h(y,!0),y.strm.avail_out===0?3:4):y.last_lit&&(h(y,!1),y.strm.avail_out===0)?1:2}function R(y,m,C,w,L){this.good_length=y,this.max_lazy=m,this.nice_length=C,this.max_chain=w,this.func=L}function d(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),E(this.dyn_ltree),E(this.dyn_dtree),E(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),E(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),E(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function I(y){var m;return y&&y.state?(y.total_in=y.total_out=0,y.data_type=2,(m=y.state).pending=0,m.pending_out=0,m.wrap<0&&(m.wrap=-m.wrap),m.status=m.wrap?42:113,y.adler=m.wrap===2?0:1,m.last_flush=0,s._tr_init(m),0):u(y,-2)}function $(y){var m,C=I(y);return C===0&&((m=y.state).window_size=2*m.w_size,E(m.head),m.max_lazy_match=r[m.level].max_lazy,m.good_match=r[m.level].good_length,m.nice_match=r[m.level].nice_length,m.max_chain_length=r[m.level].max_chain,m.strstart=0,m.block_start=0,m.lookahead=0,m.insert=0,m.match_length=m.prev_length=2,m.match_available=0,m.ins_h=0),C}function q(y,m,C,w,L,W){if(!y)return-2;var k=1;if(m===-1&&(m=6),w<0?(k=0,w=-w):w>15&&(k=2,w-=16),L<1||L>9||C!==8||w<8||w>15||m<0||m>9||W<0||W>4)return u(y,-2);w===8&&(w=9);var N=new d;return y.state=N,N.strm=y,N.wrap=k,N.gzhead=null,N.w_bits=w,N.w_size=1<<N.w_bits,N.w_mask=N.w_size-1,N.hash_bits=L+7,N.hash_size=1<<N.hash_bits,N.hash_mask=N.hash_size-1,N.hash_shift=~~((N.hash_bits+3-1)/3),N.window=new i.Buf8(2*N.w_size),N.head=new i.Buf16(N.hash_size),N.prev=new i.Buf16(N.w_size),N.lit_bufsize=1<<L+6,N.pending_buf_size=4*N.lit_bufsize,N.pending_buf=new i.Buf8(N.pending_buf_size),N.d_buf=1*N.lit_bufsize,N.l_buf=3*N.lit_bufsize,N.level=m,N.strategy=W,N.method=C,$(y)}r=[new R(0,0,0,0,function(y,m){var C=65535;for(C>y.pending_buf_size-5&&(C=y.pending_buf_size-5);;){if(y.lookahead<=1){if(j(y),y.lookahead===0&&m===0)return 1;if(y.lookahead===0)break}y.strstart+=y.lookahead,y.lookahead=0;var w=y.block_start+C;if((y.strstart===0||y.strstart>=w)&&(y.lookahead=y.strstart-w,y.strstart=w,h(y,!1),y.strm.avail_out===0)||y.strstart-y.block_start>=y.w_size-262&&(h(y,!1),y.strm.avail_out===0))return 1}return y.insert=0,m===4?(h(y,!0),y.strm.avail_out===0?3:4):(y.strstart>y.block_start&&(h(y,!1),y.strm.avail_out),1)}),new R(4,4,8,4,F),new R(4,5,16,8,F),new R(4,6,32,32,F),new R(4,4,16,16,M),new R(8,16,32,32,M),new R(8,16,128,128,M),new R(8,32,128,256,M),new R(32,128,258,1024,M),new R(32,258,258,4096,M)],t.deflateInit=function(y,m){return q(y,m,8,15,8,0)},t.deflateInit2=q,t.deflateReset=$,t.deflateResetKeep=I,t.deflateSetHeader=function(y,m){return y&&y.state?y.state.wrap!==2?-2:(y.state.gzhead=m,0):-2},t.deflate=function(y,m){var C,w,L,W;if(!y||!y.state||m>5||m<0)return y?u(y,-2):-2;if(w=y.state,!y.output||!y.input&&y.avail_in!==0||w.status===666&&m!==4)return u(y,y.avail_out===0?-5:-2);if(w.strm=y,C=w.last_flush,w.last_flush=m,w.status===42)if(w.wrap===2)y.adler=0,g(w,31),g(w,139),g(w,8),w.gzhead?(g(w,(w.gzhead.text?1:0)+(w.gzhead.hcrc?2:0)+(w.gzhead.extra?4:0)+(w.gzhead.name?8:0)+(w.gzhead.comment?16:0)),g(w,255&w.gzhead.time),g(w,w.gzhead.time>>8&255),g(w,w.gzhead.time>>16&255),g(w,w.gzhead.time>>24&255),g(w,w.level===9?2:w.strategy>=2||w.level<2?4:0),g(w,255&w.gzhead.os),w.gzhead.extra&&w.gzhead.extra.length&&(g(w,255&w.gzhead.extra.length),g(w,w.gzhead.extra.length>>8&255)),w.gzhead.hcrc&&(y.adler=o(y.adler,w.pending_buf,w.pending,0)),w.gzindex=0,w.status=69):(g(w,0),g(w,0),g(w,0),g(w,0),g(w,0),g(w,w.level===9?2:w.strategy>=2||w.level<2?4:0),g(w,3),w.status=113);else{var k=8+(w.w_bits-8<<4)<<8;k|=(w.strategy>=2||w.level<2?0:w.level<6?1:w.level===6?2:3)<<6,w.strstart!==0&&(k|=32),k+=31-k%31,w.status=113,b(w,k),w.strstart!==0&&(b(w,y.adler>>>16),b(w,65535&y.adler)),y.adler=1}if(w.status===69)if(w.gzhead.extra){for(L=w.pending;w.gzindex<(65535&w.gzhead.extra.length)&&(w.pending!==w.pending_buf_size||(w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),_(y),L=w.pending,w.pending!==w.pending_buf_size));)g(w,255&w.gzhead.extra[w.gzindex]),w.gzindex++;w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),w.gzindex===w.gzhead.extra.length&&(w.gzindex=0,w.status=73)}else w.status=73;if(w.status===73)if(w.gzhead.name){L=w.pending;do{if(w.pending===w.pending_buf_size&&(w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),_(y),L=w.pending,w.pending===w.pending_buf_size)){W=1;break}W=w.gzindex<w.gzhead.name.length?255&w.gzhead.name.charCodeAt(w.gzindex++):0,g(w,W)}while(W!==0);w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),W===0&&(w.gzindex=0,w.status=91)}else w.status=91;if(w.status===91)if(w.gzhead.comment){L=w.pending;do{if(w.pending===w.pending_buf_size&&(w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),_(y),L=w.pending,w.pending===w.pending_buf_size)){W=1;break}W=w.gzindex<w.gzhead.comment.length?255&w.gzhead.comment.charCodeAt(w.gzindex++):0,g(w,W)}while(W!==0);w.gzhead.hcrc&&w.pending>L&&(y.adler=o(y.adler,w.pending_buf,w.pending-L,L)),W===0&&(w.status=103)}else w.status=103;if(w.status===103&&(w.gzhead.hcrc?(w.pending+2>w.pending_buf_size&&_(y),w.pending+2<=w.pending_buf_size&&(g(w,255&y.adler),g(w,y.adler>>8&255),y.adler=0,w.status=113)):w.status=113),w.pending!==0){if(_(y),y.avail_out===0)return w.last_flush=-1,0}else if(y.avail_in===0&&f(m)<=f(C)&&m!==4)return u(y,-5);if(w.status===666&&y.avail_in!==0)return u(y,-5);if(y.avail_in!==0||w.lookahead!==0||m!==0&&w.status!==666){var N=w.strategy===2?function(P,z){for(var O;;){if(P.lookahead===0&&(j(P),P.lookahead===0)){if(z===0)return 1;break}if(P.match_length=0,O=s._tr_tally(P,0,P.window[P.strstart]),P.lookahead--,P.strstart++,O&&(h(P,!1),P.strm.avail_out===0))return 1}return P.insert=0,z===4?(h(P,!0),P.strm.avail_out===0?3:4):P.last_lit&&(h(P,!1),P.strm.avail_out===0)?1:2}(w,m):w.strategy===3?function(P,z){for(var O,p,U,V,Q=P.window;;){if(P.lookahead<=258){if(j(P),P.lookahead<=258&&z===0)return 1;if(P.lookahead===0)break}if(P.match_length=0,P.lookahead>=3&&P.strstart>0&&(p=Q[U=P.strstart-1])===Q[++U]&&p===Q[++U]&&p===Q[++U]){V=P.strstart+258;do;while(p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&p===Q[++U]&&U<V);P.match_length=258-(V-U),P.match_length>P.lookahead&&(P.match_length=P.lookahead)}if(P.match_length>=3?(O=s._tr_tally(P,1,P.match_length-3),P.lookahead-=P.match_length,P.strstart+=P.match_length,P.match_length=0):(O=s._tr_tally(P,0,P.window[P.strstart]),P.lookahead--,P.strstart++),O&&(h(P,!1),P.strm.avail_out===0))return 1}return P.insert=0,z===4?(h(P,!0),P.strm.avail_out===0?3:4):P.last_lit&&(h(P,!1),P.strm.avail_out===0)?1:2}(w,m):r[w.level].func(w,m);if(N!==3&&N!==4||(w.status=666),N===1||N===3)return y.avail_out===0&&(w.last_flush=-1),0;if(N===2&&(m===1?s._tr_align(w):m!==5&&(s._tr_stored_block(w,0,0,!1),m===3&&(E(w.head),w.lookahead===0&&(w.strstart=0,w.block_start=0,w.insert=0))),_(y),y.avail_out===0))return w.last_flush=-1,0}return m!==4?0:w.wrap<=0?1:(w.wrap===2?(g(w,255&y.adler),g(w,y.adler>>8&255),g(w,y.adler>>16&255),g(w,y.adler>>24&255),g(w,255&y.total_in),g(w,y.total_in>>8&255),g(w,y.total_in>>16&255),g(w,y.total_in>>24&255)):(b(w,y.adler>>>16),b(w,65535&y.adler)),_(y),w.wrap>0&&(w.wrap=-w.wrap),w.pending!==0?0:1)},t.deflateEnd=function(y){var m;return y&&y.state?(m=y.state.status)!==42&&m!==69&&m!==73&&m!==91&&m!==103&&m!==113&&m!==666?u(y,-2):(y.state=null,m===113?u(y,-3):0):-2},t.deflateSetDictionary=function(y,m){var C,w,L,W,k,N,P,z,O=m.length;if(!y||!y.state||(W=(C=y.state).wrap)===2||W===1&&C.status!==42||C.lookahead)return-2;for(W===1&&(y.adler=l(y.adler,m,O,0)),C.wrap=0,O>=C.w_size&&(W===0&&(E(C.head),C.strstart=0,C.block_start=0,C.insert=0),z=new i.Buf8(C.w_size),i.arraySet(z,m,O-C.w_size,C.w_size,0),m=z,O=C.w_size),k=y.avail_in,N=y.next_in,P=y.input,y.avail_in=O,y.next_in=0,y.input=m,j(C);C.lookahead>=3;){w=C.strstart,L=C.lookahead-2;do C.ins_h=(C.ins_h<<C.hash_shift^C.window[w+3-1])&C.hash_mask,C.prev[w&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=w,w++;while(--L);C.strstart=w,C.lookahead=2,j(C)}return C.strstart+=C.lookahead,C.block_start=C.strstart,C.insert=C.lookahead,C.lookahead=0,C.match_length=C.prev_length=2,C.match_available=0,y.next_in=N,y.input=P,y.avail_in=k,C.wrap=W,0},t.deflateInfo="pako deflate (from Nodeca project)"},function(e,t,n){var r=n(37);function i(p){for(var U=p.length;--U>=0;)p[U]=0}var s=[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],l=[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],o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],c=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],u=new Array(576);i(u);var f=new Array(60);i(f);var E=new Array(512);i(E);var _=new Array(256);i(_);var h=new Array(29);i(h);var g,b,A,j=new Array(30);function F(p,U,V,Q,ee){this.static_tree=p,this.extra_bits=U,this.extra_base=V,this.elems=Q,this.max_length=ee,this.has_stree=p&&p.length}function M(p,U){this.dyn_tree=p,this.max_code=0,this.stat_desc=U}function R(p){return p<256?E[p]:E[256+(p>>>7)]}function d(p,U){p.pending_buf[p.pending++]=255&U,p.pending_buf[p.pending++]=U>>>8&255}function I(p,U,V){p.bi_valid>16-V?(p.bi_buf|=U<<p.bi_valid&65535,d(p,p.bi_buf),p.bi_buf=U>>16-p.bi_valid,p.bi_valid+=V-16):(p.bi_buf|=U<<p.bi_valid&65535,p.bi_valid+=V)}function $(p,U,V){I(p,V[2*U],V[2*U+1])}function q(p,U){var V=0;do V|=1&p,p>>>=1,V<<=1;while(--U>0);return V>>>1}function y(p,U,V){var Q,ee,ne=new Array(16),Y=0;for(Q=1;Q<=15;Q++)ne[Q]=Y=Y+V[Q-1]<<1;for(ee=0;ee<=U;ee++){var G=p[2*ee+1];G!==0&&(p[2*ee]=q(ne[G]++,G))}}function m(p){var U;for(U=0;U<286;U++)p.dyn_ltree[2*U]=0;for(U=0;U<30;U++)p.dyn_dtree[2*U]=0;for(U=0;U<19;U++)p.bl_tree[2*U]=0;p.dyn_ltree[512]=1,p.opt_len=p.static_len=0,p.last_lit=p.matches=0}function C(p){p.bi_valid>8?d(p,p.bi_buf):p.bi_valid>0&&(p.pending_buf[p.pending++]=p.bi_buf),p.bi_buf=0,p.bi_valid=0}function w(p,U,V,Q){var ee=2*U,ne=2*V;return p[ee]<p[ne]||p[ee]===p[ne]&&Q[U]<=Q[V]}function L(p,U,V){for(var Q=p.heap[V],ee=V<<1;ee<=p.heap_len&&(ee<p.heap_len&&w(U,p.heap[ee+1],p.heap[ee],p.depth)&&ee++,!w(U,Q,p.heap[ee],p.depth));)p.heap[V]=p.heap[ee],V=ee,ee<<=1;p.heap[V]=Q}function W(p,U,V){var Q,ee,ne,Y,G=0;if(p.last_lit!==0)do Q=p.pending_buf[p.d_buf+2*G]<<8|p.pending_buf[p.d_buf+2*G+1],ee=p.pending_buf[p.l_buf+G],G++,Q===0?$(p,ee,U):($(p,(ne=_[ee])+256+1,U),(Y=s[ne])!==0&&I(p,ee-=h[ne],Y),$(p,ne=R(--Q),V),(Y=l[ne])!==0&&I(p,Q-=j[ne],Y));while(G<p.last_lit);$(p,256,U)}function k(p,U){var V,Q,ee,ne=U.dyn_tree,Y=U.stat_desc.static_tree,G=U.stat_desc.has_stree,S=U.stat_desc.elems,T=-1;for(p.heap_len=0,p.heap_max=573,V=0;V<S;V++)ne[2*V]!==0?(p.heap[++p.heap_len]=T=V,p.depth[V]=0):ne[2*V+1]=0;for(;p.heap_len<2;)ne[2*(ee=p.heap[++p.heap_len]=T<2?++T:0)]=1,p.depth[ee]=0,p.opt_len--,G&&(p.static_len-=Y[2*ee+1]);for(U.max_code=T,V=p.heap_len>>1;V>=1;V--)L(p,ne,V);ee=S;do V=p.heap[1],p.heap[1]=p.heap[p.heap_len--],L(p,ne,1),Q=p.heap[1],p.heap[--p.heap_max]=V,p.heap[--p.heap_max]=Q,ne[2*ee]=ne[2*V]+ne[2*Q],p.depth[ee]=(p.depth[V]>=p.depth[Q]?p.depth[V]:p.depth[Q])+1,ne[2*V+1]=ne[2*Q+1]=ee,p.heap[1]=ee++,L(p,ne,1);while(p.heap_len>=2);p.heap[--p.heap_max]=p.heap[1],function(B,J){var K,re,se,fe,ve,Ie,Se=J.dyn_tree,Ce=J.max_code,Ae=J.stat_desc.static_tree,Oe=J.stat_desc.has_stree,Pe=J.stat_desc.extra_bits,qe=J.stat_desc.extra_base,tt=J.stat_desc.max_length,et=0;for(fe=0;fe<=15;fe++)B.bl_count[fe]=0;for(Se[2*B.heap[B.heap_max]+1]=0,K=B.heap_max+1;K<573;K++)(fe=Se[2*Se[2*(re=B.heap[K])+1]+1]+1)>tt&&(fe=tt,et++),Se[2*re+1]=fe,re>Ce||(B.bl_count[fe]++,ve=0,re>=qe&&(ve=Pe[re-qe]),Ie=Se[2*re],B.opt_len+=Ie*(fe+ve),Oe&&(B.static_len+=Ie*(Ae[2*re+1]+ve)));if(et!==0){do{for(fe=tt-1;B.bl_count[fe]===0;)fe--;B.bl_count[fe]--,B.bl_count[fe+1]+=2,B.bl_count[tt]--,et-=2}while(et>0);for(fe=tt;fe!==0;fe--)for(re=B.bl_count[fe];re!==0;)(se=B.heap[--K])>Ce||(Se[2*se+1]!==fe&&(B.opt_len+=(fe-Se[2*se+1])*Se[2*se],Se[2*se+1]=fe),re--)}}(p,U),y(ne,T,p.bl_count)}function N(p,U,V){var Q,ee,ne=-1,Y=U[1],G=0,S=7,T=4;for(Y===0&&(S=138,T=3),U[2*(V+1)+1]=65535,Q=0;Q<=V;Q++)ee=Y,Y=U[2*(Q+1)+1],++G<S&&ee===Y||(G<T?p.bl_tree[2*ee]+=G:ee!==0?(ee!==ne&&p.bl_tree[2*ee]++,p.bl_tree[32]++):G<=10?p.bl_tree[34]++:p.bl_tree[36]++,G=0,ne=ee,Y===0?(S=138,T=3):ee===Y?(S=6,T=3):(S=7,T=4))}function P(p,U,V){var Q,ee,ne=-1,Y=U[1],G=0,S=7,T=4;for(Y===0&&(S=138,T=3),Q=0;Q<=V;Q++)if(ee=Y,Y=U[2*(Q+1)+1],!(++G<S&&ee===Y)){if(G<T)do $(p,ee,p.bl_tree);while(--G!=0);else ee!==0?(ee!==ne&&($(p,ee,p.bl_tree),G--),$(p,16,p.bl_tree),I(p,G-3,2)):G<=10?($(p,17,p.bl_tree),I(p,G-3,3)):($(p,18,p.bl_tree),I(p,G-11,7));G=0,ne=ee,Y===0?(S=138,T=3):ee===Y?(S=6,T=3):(S=7,T=4)}}i(j);var z=!1;function O(p,U,V,Q){I(p,0+(Q?1:0),3),function(ee,ne,Y,G){C(ee),G&&(d(ee,Y),d(ee,~Y)),r.arraySet(ee.pending_buf,ee.window,ne,Y,ee.pending),ee.pending+=Y}(p,U,V,!0)}t._tr_init=function(p){z||(function(){var U,V,Q,ee,ne,Y=new Array(16);for(Q=0,ee=0;ee<28;ee++)for(h[ee]=Q,U=0;U<1<<s[ee];U++)_[Q++]=ee;for(_[Q-1]=ee,ne=0,ee=0;ee<16;ee++)for(j[ee]=ne,U=0;U<1<<l[ee];U++)E[ne++]=ee;for(ne>>=7;ee<30;ee++)for(j[ee]=ne<<7,U=0;U<1<<l[ee]-7;U++)E[256+ne++]=ee;for(V=0;V<=15;V++)Y[V]=0;for(U=0;U<=143;)u[2*U+1]=8,U++,Y[8]++;for(;U<=255;)u[2*U+1]=9,U++,Y[9]++;for(;U<=279;)u[2*U+1]=7,U++,Y[7]++;for(;U<=287;)u[2*U+1]=8,U++,Y[8]++;for(y(u,287,Y),U=0;U<30;U++)f[2*U+1]=5,f[2*U]=q(U,5);g=new F(u,s,257,286,15),b=new F(f,l,0,30,15),A=new F(new Array(0),o,0,19,7)}(),z=!0),p.l_desc=new M(p.dyn_ltree,g),p.d_desc=new M(p.dyn_dtree,b),p.bl_desc=new M(p.bl_tree,A),p.bi_buf=0,p.bi_valid=0,m(p)},t._tr_stored_block=O,t._tr_flush_block=function(p,U,V,Q){var ee,ne,Y=0;p.level>0?(p.strm.data_type===2&&(p.strm.data_type=function(G){var S,T=4093624447;for(S=0;S<=31;S++,T>>>=1)if(1&T&&G.dyn_ltree[2*S]!==0)return 0;if(G.dyn_ltree[18]!==0||G.dyn_ltree[20]!==0||G.dyn_ltree[26]!==0)return 1;for(S=32;S<256;S++)if(G.dyn_ltree[2*S]!==0)return 1;return 0}(p)),k(p,p.l_desc),k(p,p.d_desc),Y=function(G){var S;for(N(G,G.dyn_ltree,G.l_desc.max_code),N(G,G.dyn_dtree,G.d_desc.max_code),k(G,G.bl_desc),S=18;S>=3&&G.bl_tree[2*c[S]+1]===0;S--);return G.opt_len+=3*(S+1)+5+5+4,S}(p),ee=p.opt_len+3+7>>>3,(ne=p.static_len+3+7>>>3)<=ee&&(ee=ne)):ee=ne=V+5,V+4<=ee&&U!==-1?O(p,U,V,Q):p.strategy===4||ne===ee?(I(p,2+(Q?1:0),3),W(p,u,f)):(I(p,4+(Q?1:0),3),function(G,S,T,B){var J;for(I(G,S-257,5),I(G,T-1,5),I(G,B-4,4),J=0;J<B;J++)I(G,G.bl_tree[2*c[J]+1],3);P(G,G.dyn_ltree,S-1),P(G,G.dyn_dtree,T-1)}(p,p.l_desc.max_code+1,p.d_desc.max_code+1,Y+1),W(p,p.dyn_ltree,p.dyn_dtree)),m(p),Q&&C(p)},t._tr_tally=function(p,U,V){return p.pending_buf[p.d_buf+2*p.last_lit]=U>>>8&255,p.pending_buf[p.d_buf+2*p.last_lit+1]=255&U,p.pending_buf[p.l_buf+p.last_lit]=255&V,p.last_lit++,U===0?p.dyn_ltree[2*V]++:(p.matches++,U--,p.dyn_ltree[2*(_[V]+256+1)]++,p.dyn_dtree[2*R(U)]++),p.last_lit===p.lit_bufsize-1},t._tr_align=function(p){I(p,2,3),$(p,256,u),function(U){U.bi_valid===16?(d(U,U.bi_buf),U.bi_buf=0,U.bi_valid=0):U.bi_valid>=8&&(U.pending_buf[U.pending++]=255&U.bi_buf,U.bi_buf>>=8,U.bi_valid-=8)}(p)}},function(e,t,n){e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},function(e,t,n){var r=n(37),i=n(75),s=n(76),l=n(176),o=n(177);function c(M){return(M>>>24&255)+(M>>>8&65280)+((65280&M)<<8)+((255&M)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(M){var R;return M&&M.state?(R=M.state,M.total_in=M.total_out=R.total=0,M.msg="",R.wrap&&(M.adler=1&R.wrap),R.mode=1,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new r.Buf32(852),R.distcode=R.distdyn=new r.Buf32(592),R.sane=1,R.back=-1,0):-2}function E(M){var R;return M&&M.state?((R=M.state).wsize=0,R.whave=0,R.wnext=0,f(M)):-2}function _(M,R){var d,I;return M&&M.state?(I=M.state,R<0?(d=0,R=-R):(d=1+(R>>4),R<48&&(R&=15)),R&&(R<8||R>15)?-2:(I.window!==null&&I.wbits!==R&&(I.window=null),I.wrap=d,I.wbits=R,E(M))):-2}function h(M,R){var d,I;return M?(I=new u,M.state=I,I.window=null,(d=_(M,R))!==0&&(M.state=null),d):-2}var g,b,A=!0;function j(M){if(A){var R;for(g=new r.Buf32(512),b=new r.Buf32(32),R=0;R<144;)M.lens[R++]=8;for(;R<256;)M.lens[R++]=9;for(;R<280;)M.lens[R++]=7;for(;R<288;)M.lens[R++]=8;for(o(1,M.lens,0,288,g,0,M.work,{bits:9}),R=0;R<32;)M.lens[R++]=5;o(2,M.lens,0,32,b,0,M.work,{bits:5}),A=!1}M.lencode=g,M.lenbits=9,M.distcode=b,M.distbits=5}function F(M,R,d,I){var $,q=M.state;return q.window===null&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new r.Buf8(q.wsize)),I>=q.wsize?(r.arraySet(q.window,R,d-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(($=q.wsize-q.wnext)>I&&($=I),r.arraySet(q.window,R,d-I,$,q.wnext),(I-=$)?(r.arraySet(q.window,R,d-I,I,0),q.wnext=I,q.whave=q.wsize):(q.wnext+=$,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=$))),0}t.inflateReset=E,t.inflateReset2=_,t.inflateResetKeep=f,t.inflateInit=function(M){return h(M,15)},t.inflateInit2=h,t.inflate=function(M,R){var d,I,$,q,y,m,C,w,L,W,k,N,P,z,O,p,U,V,Q,ee,ne,Y,G,S,T=0,B=new r.Buf8(4),J=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!M||!M.state||!M.output||!M.input&&M.avail_in!==0)return-2;(d=M.state).mode===12&&(d.mode=13),y=M.next_out,$=M.output,C=M.avail_out,q=M.next_in,I=M.input,m=M.avail_in,w=d.hold,L=d.bits,W=m,k=C,Y=0;e:for(;;)switch(d.mode){case 1:if(d.wrap===0){d.mode=13;break}for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(2&d.wrap&&w===35615){d.check=0,B[0]=255&w,B[1]=w>>>8&255,d.check=s(d.check,B,2,0),w=0,L=0,d.mode=2;break}if(d.flags=0,d.head&&(d.head.done=!1),!(1&d.wrap)||(((255&w)<<8)+(w>>8))%31){M.msg="incorrect header check",d.mode=30;break}if((15&w)!=8){M.msg="unknown compression method",d.mode=30;break}if(L-=4,ne=8+(15&(w>>>=4)),d.wbits===0)d.wbits=ne;else if(ne>d.wbits){M.msg="invalid window size",d.mode=30;break}d.dmax=1<<ne,M.adler=d.check=1,d.mode=512&w?10:12,w=0,L=0;break;case 2:for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(d.flags=w,(255&d.flags)!=8){M.msg="unknown compression method",d.mode=30;break}if(57344&d.flags){M.msg="unknown header flags set",d.mode=30;break}d.head&&(d.head.text=w>>8&1),512&d.flags&&(B[0]=255&w,B[1]=w>>>8&255,d.check=s(d.check,B,2,0)),w=0,L=0,d.mode=3;case 3:for(;L<32;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.head&&(d.head.time=w),512&d.flags&&(B[0]=255&w,B[1]=w>>>8&255,B[2]=w>>>16&255,B[3]=w>>>24&255,d.check=s(d.check,B,4,0)),w=0,L=0,d.mode=4;case 4:for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.head&&(d.head.xflags=255&w,d.head.os=w>>8),512&d.flags&&(B[0]=255&w,B[1]=w>>>8&255,d.check=s(d.check,B,2,0)),w=0,L=0,d.mode=5;case 5:if(1024&d.flags){for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.length=w,d.head&&(d.head.extra_len=w),512&d.flags&&(B[0]=255&w,B[1]=w>>>8&255,d.check=s(d.check,B,2,0)),w=0,L=0}else d.head&&(d.head.extra=null);d.mode=6;case 6:if(1024&d.flags&&((N=d.length)>m&&(N=m),N&&(d.head&&(ne=d.head.extra_len-d.length,d.head.extra||(d.head.extra=new Array(d.head.extra_len)),r.arraySet(d.head.extra,I,q,N,ne)),512&d.flags&&(d.check=s(d.check,I,N,q)),m-=N,q+=N,d.length-=N),d.length))break e;d.length=0,d.mode=7;case 7:if(2048&d.flags){if(m===0)break e;N=0;do ne=I[q+N++],d.head&&ne&&d.length<65536&&(d.head.name+=String.fromCharCode(ne));while(ne&&N<m);if(512&d.flags&&(d.check=s(d.check,I,N,q)),m-=N,q+=N,ne)break e}else d.head&&(d.head.name=null);d.length=0,d.mode=8;case 8:if(4096&d.flags){if(m===0)break e;N=0;do ne=I[q+N++],d.head&&ne&&d.length<65536&&(d.head.comment+=String.fromCharCode(ne));while(ne&&N<m);if(512&d.flags&&(d.check=s(d.check,I,N,q)),m-=N,q+=N,ne)break e}else d.head&&(d.head.comment=null);d.mode=9;case 9:if(512&d.flags){for(;L<16;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(w!==(65535&d.check)){M.msg="header crc mismatch",d.mode=30;break}w=0,L=0}d.head&&(d.head.hcrc=d.flags>>9&1,d.head.done=!0),M.adler=d.check=0,d.mode=12;break;case 10:for(;L<32;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}M.adler=d.check=c(w),w=0,L=0,d.mode=11;case 11:if(d.havedict===0)return M.next_out=y,M.avail_out=C,M.next_in=q,M.avail_in=m,d.hold=w,d.bits=L,2;M.adler=d.check=1,d.mode=12;case 12:if(R===5||R===6)break e;case 13:if(d.last){w>>>=7&L,L-=7&L,d.mode=27;break}for(;L<3;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}switch(d.last=1&w,L-=1,3&(w>>>=1)){case 0:d.mode=14;break;case 1:if(j(d),d.mode=20,R===6){w>>>=2,L-=2;break e}break;case 2:d.mode=17;break;case 3:M.msg="invalid block type",d.mode=30}w>>>=2,L-=2;break;case 14:for(w>>>=7&L,L-=7&L;L<32;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if((65535&w)!=(w>>>16^65535)){M.msg="invalid stored block lengths",d.mode=30;break}if(d.length=65535&w,w=0,L=0,d.mode=15,R===6)break e;case 15:d.mode=16;case 16:if(N=d.length){if(N>m&&(N=m),N>C&&(N=C),N===0)break e;r.arraySet($,I,q,N,y),m-=N,q+=N,C-=N,y+=N,d.length-=N;break}d.mode=12;break;case 17:for(;L<14;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(d.nlen=257+(31&w),w>>>=5,L-=5,d.ndist=1+(31&w),w>>>=5,L-=5,d.ncode=4+(15&w),w>>>=4,L-=4,d.nlen>286||d.ndist>30){M.msg="too many length or distance symbols",d.mode=30;break}d.have=0,d.mode=18;case 18:for(;d.have<d.ncode;){for(;L<3;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.lens[J[d.have++]]=7&w,w>>>=3,L-=3}for(;d.have<19;)d.lens[J[d.have++]]=0;if(d.lencode=d.lendyn,d.lenbits=7,G={bits:d.lenbits},Y=o(0,d.lens,0,19,d.lencode,0,d.work,G),d.lenbits=G.bits,Y){M.msg="invalid code lengths set",d.mode=30;break}d.have=0,d.mode=19;case 19:for(;d.have<d.nlen+d.ndist;){for(;p=(T=d.lencode[w&(1<<d.lenbits)-1])>>>16&255,U=65535&T,!((O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(U<16)w>>>=O,L-=O,d.lens[d.have++]=U;else{if(U===16){for(S=O+2;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(w>>>=O,L-=O,d.have===0){M.msg="invalid bit length repeat",d.mode=30;break}ne=d.lens[d.have-1],N=3+(3&w),w>>>=2,L-=2}else if(U===17){for(S=O+3;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}L-=O,ne=0,N=3+(7&(w>>>=O)),w>>>=3,L-=3}else{for(S=O+7;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}L-=O,ne=0,N=11+(127&(w>>>=O)),w>>>=7,L-=7}if(d.have+N>d.nlen+d.ndist){M.msg="invalid bit length repeat",d.mode=30;break}for(;N--;)d.lens[d.have++]=ne}}if(d.mode===30)break;if(d.lens[256]===0){M.msg="invalid code -- missing end-of-block",d.mode=30;break}if(d.lenbits=9,G={bits:d.lenbits},Y=o(1,d.lens,0,d.nlen,d.lencode,0,d.work,G),d.lenbits=G.bits,Y){M.msg="invalid literal/lengths set",d.mode=30;break}if(d.distbits=6,d.distcode=d.distdyn,G={bits:d.distbits},Y=o(2,d.lens,d.nlen,d.ndist,d.distcode,0,d.work,G),d.distbits=G.bits,Y){M.msg="invalid distances set",d.mode=30;break}if(d.mode=20,R===6)break e;case 20:d.mode=21;case 21:if(m>=6&&C>=258){M.next_out=y,M.avail_out=C,M.next_in=q,M.avail_in=m,d.hold=w,d.bits=L,l(M,k),y=M.next_out,$=M.output,C=M.avail_out,q=M.next_in,I=M.input,m=M.avail_in,w=d.hold,L=d.bits,d.mode===12&&(d.back=-1);break}for(d.back=0;p=(T=d.lencode[w&(1<<d.lenbits)-1])>>>16&255,U=65535&T,!((O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(p&&!(240&p)){for(V=O,Q=p,ee=U;p=(T=d.lencode[ee+((w&(1<<V+Q)-1)>>V)])>>>16&255,U=65535&T,!(V+(O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}w>>>=V,L-=V,d.back+=V}if(w>>>=O,L-=O,d.back+=O,d.length=U,p===0){d.mode=26;break}if(32&p){d.back=-1,d.mode=12;break}if(64&p){M.msg="invalid literal/length code",d.mode=30;break}d.extra=15&p,d.mode=22;case 22:if(d.extra){for(S=d.extra;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.length+=w&(1<<d.extra)-1,w>>>=d.extra,L-=d.extra,d.back+=d.extra}d.was=d.length,d.mode=23;case 23:for(;p=(T=d.distcode[w&(1<<d.distbits)-1])>>>16&255,U=65535&T,!((O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(!(240&p)){for(V=O,Q=p,ee=U;p=(T=d.distcode[ee+((w&(1<<V+Q)-1)>>V)])>>>16&255,U=65535&T,!(V+(O=T>>>24)<=L);){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}w>>>=V,L-=V,d.back+=V}if(w>>>=O,L-=O,d.back+=O,64&p){M.msg="invalid distance code",d.mode=30;break}d.offset=U,d.extra=15&p,d.mode=24;case 24:if(d.extra){for(S=d.extra;L<S;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}d.offset+=w&(1<<d.extra)-1,w>>>=d.extra,L-=d.extra,d.back+=d.extra}if(d.offset>d.dmax){M.msg="invalid distance too far back",d.mode=30;break}d.mode=25;case 25:if(C===0)break e;if(N=k-C,d.offset>N){if((N=d.offset-N)>d.whave&&d.sane){M.msg="invalid distance too far back",d.mode=30;break}N>d.wnext?(N-=d.wnext,P=d.wsize-N):P=d.wnext-N,N>d.length&&(N=d.length),z=d.window}else z=$,P=y-d.offset,N=d.length;N>C&&(N=C),C-=N,d.length-=N;do $[y++]=z[P++];while(--N);d.length===0&&(d.mode=21);break;case 26:if(C===0)break e;$[y++]=d.length,C--,d.mode=21;break;case 27:if(d.wrap){for(;L<32;){if(m===0)break e;m--,w|=I[q++]<<L,L+=8}if(k-=C,M.total_out+=k,d.total+=k,k&&(M.adler=d.check=d.flags?s(d.check,$,k,y-k):i(d.check,$,k,y-k)),k=C,(d.flags?w:c(w))!==d.check){M.msg="incorrect data check",d.mode=30;break}w=0,L=0}d.mode=28;case 28:if(d.wrap&&d.flags){for(;L<32;){if(m===0)break e;m--,w+=I[q++]<<L,L+=8}if(w!==(4294967295&d.total)){M.msg="incorrect length check",d.mode=30;break}w=0,L=0}d.mode=29;case 29:Y=1;break e;case 30:Y=-3;break e;case 31:return-4;case 32:default:return-2}return M.next_out=y,M.avail_out=C,M.next_in=q,M.avail_in=m,d.hold=w,d.bits=L,(d.wsize||k!==M.avail_out&&d.mode<30&&(d.mode<27||R!==4))&&F(M,M.output,M.next_out,k-M.avail_out)?(d.mode=31,-4):(W-=M.avail_in,k-=M.avail_out,M.total_in+=W,M.total_out+=k,d.total+=k,d.wrap&&k&&(M.adler=d.check=d.flags?s(d.check,$,k,M.next_out-k):i(d.check,$,k,M.next_out-k)),M.data_type=d.bits+(d.last?64:0)+(d.mode===12?128:0)+(d.mode===20||d.mode===15?256:0),(W===0&&k===0||R===4)&&Y===0&&(Y=-5),Y)},t.inflateEnd=function(M){if(!M||!M.state)return-2;var R=M.state;return R.window&&(R.window=null),M.state=null,0},t.inflateGetHeader=function(M,R){var d;return M&&M.state&&2&(d=M.state).wrap?(d.head=R,R.done=!1,0):-2},t.inflateSetDictionary=function(M,R){var d,I=R.length;return M&&M.state?(d=M.state).wrap!==0&&d.mode!==11?-2:d.mode===11&&i(1,R,I,0)!==d.check?-3:F(M,R,I,I)?(d.mode=31,-4):(d.havedict=1,0):-2},t.inflateInfo="pako inflate (from Nodeca project)"},function(e,t,n){e.exports=function(r,i){var s,l,o,c,u,f,E,_,h,g,b,A,j,F,M,R,d,I,$,q,y,m,C,w,L;s=r.state,l=r.next_in,w=r.input,o=l+(r.avail_in-5),c=r.next_out,L=r.output,u=c-(i-r.avail_out),f=c+(r.avail_out-257),E=s.dmax,_=s.wsize,h=s.whave,g=s.wnext,b=s.window,A=s.hold,j=s.bits,F=s.lencode,M=s.distcode,R=(1<<s.lenbits)-1,d=(1<<s.distbits)-1;e:do{j<15&&(A+=w[l++]<<j,j+=8,A+=w[l++]<<j,j+=8),I=F[A&R];t:for(;;){if(A>>>=$=I>>>24,j-=$,($=I>>>16&255)===0)L[c++]=65535&I;else{if(!(16&$)){if(!(64&$)){I=F[(65535&I)+(A&(1<<$)-1)];continue t}if(32&$){s.mode=12;break e}r.msg="invalid literal/length code",s.mode=30;break e}q=65535&I,($&=15)&&(j<$&&(A+=w[l++]<<j,j+=8),q+=A&(1<<$)-1,A>>>=$,j-=$),j<15&&(A+=w[l++]<<j,j+=8,A+=w[l++]<<j,j+=8),I=M[A&d];n:for(;;){if(A>>>=$=I>>>24,j-=$,!(16&($=I>>>16&255))){if(!(64&$)){I=M[(65535&I)+(A&(1<<$)-1)];continue n}r.msg="invalid distance code",s.mode=30;break e}if(y=65535&I,j<($&=15)&&(A+=w[l++]<<j,(j+=8)<$&&(A+=w[l++]<<j,j+=8)),(y+=A&(1<<$)-1)>E){r.msg="invalid distance too far back",s.mode=30;break e}if(A>>>=$,j-=$,y>($=c-u)){if(($=y-$)>h&&s.sane){r.msg="invalid distance too far back",s.mode=30;break e}if(m=0,C=b,g===0){if(m+=_-$,$<q){q-=$;do L[c++]=b[m++];while(--$);m=c-y,C=L}}else if(g<$){if(m+=_+g-$,($-=g)<q){q-=$;do L[c++]=b[m++];while(--$);if(m=0,g<q){q-=$=g;do L[c++]=b[m++];while(--$);m=c-y,C=L}}}else if(m+=g-$,$<q){q-=$;do L[c++]=b[m++];while(--$);m=c-y,C=L}for(;q>2;)L[c++]=C[m++],L[c++]=C[m++],L[c++]=C[m++],q-=3;q&&(L[c++]=C[m++],q>1&&(L[c++]=C[m++]))}else{m=c-y;do L[c++]=L[m++],L[c++]=L[m++],L[c++]=L[m++],q-=3;while(q>2);q&&(L[c++]=L[m++],q>1&&(L[c++]=L[m++]))}break}}break}}while(l<o&&c<f);l-=q=j>>3,A&=(1<<(j-=q<<3))-1,r.next_in=l,r.next_out=c,r.avail_in=l<o?o-l+5:5-(l-o),r.avail_out=c<f?f-c+257:257-(c-f),s.hold=A,s.bits=j}},function(e,t,n){var r=n(37),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],o=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(c,u,f,E,_,h,g,b){var A,j,F,M,R,d,I,$,q,y=b.bits,m=0,C=0,w=0,L=0,W=0,k=0,N=0,P=0,z=0,O=0,p=null,U=0,V=new r.Buf16(16),Q=new r.Buf16(16),ee=null,ne=0;for(m=0;m<=15;m++)V[m]=0;for(C=0;C<E;C++)V[u[f+C]]++;for(W=y,L=15;L>=1&&V[L]===0;L--);if(W>L&&(W=L),L===0)return _[h++]=20971520,_[h++]=20971520,b.bits=1,0;for(w=1;w<L&&V[w]===0;w++);for(W<w&&(W=w),P=1,m=1;m<=15;m++)if(P<<=1,(P-=V[m])<0)return-1;if(P>0&&(c===0||L!==1))return-1;for(Q[1]=0,m=1;m<15;m++)Q[m+1]=Q[m]+V[m];for(C=0;C<E;C++)u[f+C]!==0&&(g[Q[u[f+C]]++]=C);if(c===0?(p=ee=g,d=19):c===1?(p=i,U-=257,ee=s,ne-=257,d=256):(p=l,ee=o,d=-1),O=0,C=0,m=w,R=h,k=W,N=0,F=-1,M=(z=1<<W)-1,c===1&&z>852||c===2&&z>592)return 1;for(;;){I=m-N,g[C]<d?($=0,q=g[C]):g[C]>d?($=ee[ne+g[C]],q=p[U+g[C]]):($=96,q=0),A=1<<m-N,w=j=1<<k;do _[R+(O>>N)+(j-=A)]=I<<24|$<<16|q|0;while(j!==0);for(A=1<<m-1;O&A;)A>>=1;if(A!==0?(O&=A-1,O+=A):O=0,C++,--V[m]==0){if(m===L)break;m=u[f+g[C]]}if(m>W&&(O&M)!==F){for(N===0&&(N=W),R+=w,P=1<<(k=m-N);k+N<L&&!((P-=V[k+N])<=0);)k++,P<<=1;if(z+=1<<k,c===1&&z>852||c===2&&z>592)return 1;_[F=O&M]=W<<24|k<<16|R-h|0}}return O!==0&&(_[R+O]=m-N<<24|64<<16|0),b.bits=W,0}},function(e,t,n){e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(e,t){},function(e,t,n){function r(u,f){var E=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(h){return Object.getOwnPropertyDescriptor(u,h).enumerable})),E.push.apply(E,_)}return E}function i(u,f,E){return f in u?Object.defineProperty(u,f,{value:E,enumerable:!0,configurable:!0,writable:!0}):u[f]=E,u}function s(u,f){for(var E=0;E<f.length;E++){var _=f[E];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,_.key,_)}}var l=n(5).Buffer,o=n(181).inspect,c=o&&o.custom||"inspect";e.exports=function(){function u(){(function(_,h){if(!(_ instanceof h))throw new TypeError("Cannot call a class as a function")})(this,u),this.head=null,this.tail=null,this.length=0}var f,E;return f=u,(E=[{key:"push",value:function(_){var h={data:_,next:null};this.length>0?this.tail.next=h:this.head=h,this.tail=h,++this.length}},{key:"unshift",value:function(_){var h={data:_,next:this.head};this.length===0&&(this.tail=h),this.head=h,++this.length}},{key:"shift",value:function(){if(this.length!==0){var _=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,_}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(_){if(this.length===0)return"";for(var h=this.head,g=""+h.data;h=h.next;)g+=_+h.data;return g}},{key:"concat",value:function(_){if(this.length===0)return l.alloc(0);for(var h,g,b,A=l.allocUnsafe(_>>>0),j=this.head,F=0;j;)h=j.data,g=A,b=F,l.prototype.copy.call(h,g,b),F+=j.data.length,j=j.next;return A}},{key:"consume",value:function(_,h){var g;return _<this.head.data.length?(g=this.head.data.slice(0,_),this.head.data=this.head.data.slice(_)):g=_===this.head.data.length?this.shift():h?this._getString(_):this._getBuffer(_),g}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(_){var h=this.head,g=1,b=h.data;for(_-=b.length;h=h.next;){var A=h.data,j=_>A.length?A.length:_;if(j===A.length?b+=A:b+=A.slice(0,_),(_-=j)==0){j===A.length?(++g,h.next?this.head=h.next:this.head=this.tail=null):(this.head=h,h.data=A.slice(j));break}++g}return this.length-=g,b}},{key:"_getBuffer",value:function(_){var h=l.allocUnsafe(_),g=this.head,b=1;for(g.data.copy(h),_-=g.data.length;g=g.next;){var A=g.data,j=_>A.length?A.length:_;if(A.copy(h,h.length-_,0,j),(_-=j)==0){j===A.length?(++b,g.next?this.head=g.next:this.head=this.tail=null):(this.head=g,g.data=A.slice(j));break}++b}return this.length-=b,h}},{key:c,value:function(_,h){return o(this,function(g){for(var b=1;b<arguments.length;b++){var A=arguments[b]!=null?arguments[b]:{};b%2?r(Object(A),!0).forEach(function(j){i(g,j,A[j])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(A)):r(Object(A)).forEach(function(j){Object.defineProperty(g,j,Object.getOwnPropertyDescriptor(A,j))})}return g}({},h,{depth:0,customInspect:!1}))}}])&&s(f.prototype,E),u}()},function(e,t){},function(e,t,n){(function(r){var i;function s(M,R,d){return R in M?Object.defineProperty(M,R,{value:d,enumerable:!0,configurable:!0,writable:!0}):M[R]=d,M}var l=n(49),o=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),f=Symbol("ended"),E=Symbol("lastPromise"),_=Symbol("handlePromise"),h=Symbol("stream");function g(M,R){return{value:M,done:R}}function b(M){var R=M[o];if(R!==null){var d=M[h].read();d!==null&&(M[E]=null,M[o]=null,M[c]=null,R(g(d,!1)))}}function A(M){r.nextTick(b,M)}var j=Object.getPrototypeOf(function(){}),F=Object.setPrototypeOf((s(i={get stream(){return this[h]},next:function(){var M=this,R=this[u];if(R!==null)return Promise.reject(R);if(this[f])return Promise.resolve(g(void 0,!0));if(this[h].destroyed)return new Promise(function(q,y){r.nextTick(function(){M[u]?y(M[u]):q(g(void 0,!0))})});var d,I=this[E];if(I)d=new Promise(function(q,y){return function(m,C){q.then(function(){y[f]?m(g(void 0,!0)):y[_](m,C)},C)}}(I,this));else{var $=this[h].read();if($!==null)return Promise.resolve(g($,!1));d=new Promise(this[_])}return this[E]=d,d}},Symbol.asyncIterator,function(){return this}),s(i,"return",function(){var M=this;return new Promise(function(R,d){M[h].destroy(null,function(I){I?d(I):R(g(void 0,!0))})})}),i),j);e.exports=function(M){var R,d=Object.create(F,(s(R={},h,{value:M,writable:!0}),s(R,o,{value:null,writable:!0}),s(R,c,{value:null,writable:!0}),s(R,u,{value:null,writable:!0}),s(R,f,{value:M._readableState.endEmitted,writable:!0}),s(R,_,{value:function(I,$){var q=d[h].read();q?(d[E]=null,d[o]=null,d[c]=null,I(g(q,!1))):(d[o]=I,d[c]=$)},writable:!0}),R));return d[E]=null,l(M,function(I){if(I&&I.code!=="ERR_STREAM_PREMATURE_CLOSE"){var $=d[c];return $!==null&&(d[E]=null,d[o]=null,d[c]=null,$(I)),void(d[u]=I)}var q=d[o];q!==null&&(d[E]=null,d[o]=null,d[c]=null,q(g(void 0,!0))),d[f]=!0}),M.on("readable",A.bind(null,d)),d}}).call(this,n(2))},function(e,t){e.exports=function(){throw new Error("Readable.from is not available in the browser")}},function(e,t,n){e.exports=i;var r=n(82);function i(s){if(!(this instanceof i))return new i(s);r.call(this,s)}n(7)(i,r),i.prototype._transform=function(s,l,o){o(null,s)}},function(e,t,n){var r,i=n(26).codes,s=i.ERR_MISSING_ARGS,l=i.ERR_STREAM_DESTROYED;function o(_){if(_)throw _}function c(_,h,g,b){b=function(F){var M=!1;return function(){M||(M=!0,F.apply(void 0,arguments))}}(b);var A=!1;_.on("close",function(){A=!0}),r===void 0&&(r=n(49)),r(_,{readable:h,writable:g},function(F){if(F)return b(F);A=!0,b()});var j=!1;return function(F){if(!A&&!j)return j=!0,function(M){return M.setHeader&&typeof M.abort=="function"}(_)?_.abort():typeof _.destroy=="function"?_.destroy():void b(F||new l("pipe"))}}function u(_){_()}function f(_,h){return _.pipe(h)}function E(_){return _.length?typeof _[_.length-1]!="function"?o:_.pop():o}e.exports=function(){for(var _=arguments.length,h=new Array(_),g=0;g<_;g++)h[g]=arguments[g];var b,A=E(h);if(Array.isArray(h[0])&&(h=h[0]),h.length<2)throw new s("streams");var j=h.map(function(F,M){var R=M<h.length-1;return c(F,R,M>0,function(d){b||(b=d),d&&j.forEach(u),R||(j.forEach(u),A(b))})});return h.reduce(f)}},function(e,t,n){var r=n(187)(function i(s,l){return(l=l||{}).namespace=s,l.prod=!0,l.dev=!1,l.force||i.force?i.yep(l):i.nope(l)});e.exports=r},function(e,t){var n=[],r=[],i=function(){};function s(g){return!~n.indexOf(g)&&(n.push(g),!0)}function l(g){i=g}function o(g){for(var b=[],A=0;A<n.length;A++)if(n[A].async)b.push(n[A]);else if(n[A](g))return!0;return!!b.length&&new Promise(function(j){Promise.all(b.map(function(F){return F(g)})).then(function(F){j(F.some(Boolean))})})}function c(g){return!~r.indexOf(g)&&(r.push(g),!0)}function u(){i.apply(i,arguments)}function f(g){for(var b=0;b<r.length;b++)g=r[b].apply(r[b],arguments);return g}function E(g,b){var A=Object.prototype.hasOwnProperty;for(var j in b)A.call(b,j)&&(g[j]=b[j]);return g}function _(g){return g.enabled=!1,g.modify=c,g.set=l,g.use=s,E(function(){return!1},g)}function h(g){return g.enabled=!0,g.modify=c,g.set=l,g.use=s,E(function(){var b=Array.prototype.slice.call(arguments,0);return u.call(u,g,f(b,g)),!0},g)}e.exports=function(g){return g.introduce=E,g.enabled=o,g.process=f,g.modify=c,g.write=u,g.nope=_,g.yep=h,g.set=l,g.use=s,g}},function(e,t,n){(function(r){var i=n(65),s=n(22).StringDecoder,l=n(32).Stream;function o(){}e.exports=function(c,u){var f=r.alloc(65536),E=new s("utf8"),_=new l,h="",g=0,b=0;return c.start===-1&&delete c.start,_.readable=!0,_.destroy=function(){_.destroyed=!0,_.emit("end"),_.emit("close")},i.open(c.file,"a+","0644",function(A,j){if(A)return u?u(A):_.emit("error",A),void _.destroy();(function F(){if(!_.destroyed)return i.read(j,f,0,f.length,g,function(M,R){if(M)return u?u(M):_.emit("error",M),void _.destroy();if(!R)return h&&((c.start==null||b>c.start)&&(u?u(null,h):_.emit("line",h)),b++,h=""),setTimeout(F,1e3);var d=E.write(f.slice(0,R));u||_.emit("data",d);for(var I=(d=(h+d).split(/\n+/)).length-1,$=0;$<I;$++)(c.start==null||b>c.start)&&(u?u(null,d[$]):_.emit("line",d[$])),b++;return h=d[I],g+=R,F()});i.close(j,o)})()}),u?_.destroy:_}}).call(this,n(5).Buffer)},function(e,t,n){(function(r,i){function s(M){return(s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(R){return typeof R}:function(R){return R&&typeof Symbol=="function"&&R.constructor===Symbol&&R!==Symbol.prototype?"symbol":typeof R})(M)}function l(M,R){var d=Object.keys(M);if(Object.getOwnPropertySymbols){var I=Object.getOwnPropertySymbols(M);R&&(I=I.filter(function($){return Object.getOwnPropertyDescriptor(M,$).enumerable})),d.push.apply(d,I)}return d}function o(M){for(var R=1;R<arguments.length;R++){var d=arguments[R]!=null?arguments[R]:{};R%2?l(Object(d),!0).forEach(function(I){c(M,I,d[I])}):Object.getOwnPropertyDescriptors?Object.defineProperties(M,Object.getOwnPropertyDescriptors(d)):l(Object(d)).forEach(function(I){Object.defineProperty(M,I,Object.getOwnPropertyDescriptor(d,I))})}return M}function c(M,R,d){return R in M?Object.defineProperty(M,R,{value:d,enumerable:!0,configurable:!0,writable:!0}):M[R]=d,M}function u(M,R){if(!(M instanceof R))throw new TypeError("Cannot call a class as a function")}function f(M,R){for(var d=0;d<R.length;d++){var I=R[d];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(M,I.key,I)}}function E(M,R){return(E=Object.setPrototypeOf||function(d,I){return d.__proto__=I,d})(M,R)}function _(M){var R=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var d,I=g(M);if(R){var $=g(this).constructor;d=Reflect.construct(I,arguments,$)}else d=I.apply(this,arguments);return h(this,d)}}function h(M,R){return!R||s(R)!=="object"&&typeof R!="function"?function(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}(M):R}function g(M){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(R){return R.__proto__||Object.getPrototypeOf(R)})(M)}var b=n(83),A=n(200),j=n(32).Stream,F=n(20);e.exports=function(M){(function(q,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");q.prototype=Object.create(y&&y.prototype,{constructor:{value:q,writable:!0,configurable:!0}}),y&&E(q,y)})($,M);var R,d,I=_($);function $(){var q,y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return u(this,$),(q=I.call(this,y)).options=y,q.name=y.name||"http",q.ssl=!!y.ssl,q.host=y.host||"localhost",q.port=y.port,q.auth=y.auth,q.path=y.path||"",q.agent=y.agent,q.headers=y.headers||{},q.headers["content-type"]="application/json",q.port||(q.port=q.ssl?443:80),q}return R=$,(d=[{key:"log",value:function(q,y){var m=this;this._request(q,function(C,w){w&&w.statusCode!==200&&(C=new Error("Invalid HTTP Status Code: ".concat(w.statusCode))),C?m.emit("warn",C):m.emit("logged",q)}),y&&r(y)}},{key:"query",value:function(q,y){typeof q=="function"&&(y=q,q={}),(q={method:"query",params:this.normalizeQuery(q)}).params.path&&(q.path=q.params.path,delete q.params.path),q.params.auth&&(q.auth=q.params.auth,delete q.params.auth),this._request(q,function(m,C,w){if(C&&C.statusCode!==200&&(m=new Error("Invalid HTTP Status Code: ".concat(C.statusCode))),m)return y(m);if(typeof w=="string")try{w=JSON.parse(w)}catch(L){return y(L)}y(null,w)})}},{key:"stream",value:function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},y=new j;(q={method:"stream",params:q}).params.path&&(q.path=q.params.path,delete q.params.path),q.params.auth&&(q.auth=q.params.auth,delete q.params.auth);var m="",C=this._request(q);return y.destroy=function(){return C.destroy()},C.on("data",function(w){for(var L=(w=(m+w).split(/\n+/)).length-1,W=0;W<L;W++)try{y.emit("log",JSON.parse(w[W]))}catch(k){y.emit("error",k)}m=w[L]}),C.on("error",function(w){return y.emit("error",w)}),y}},{key:"_request",value:function(q,y){var m=(q=q||{}).auth||this.auth,C=q.path||this.path||"";delete q.auth,delete q.path;var w=Object.assign({},this.headers);m&&m.bearer&&(w.Authorization="Bearer ".concat(m.bearer));var L=(this.ssl?A:b).request(o(o({},this.options),{},{method:"POST",host:this.host,port:this.port,path:"/".concat(C.replace(/^\//,"")),headers:w,auth:m&&m.username&&m.password?"".concat(m.username,":").concat(m.password):"",agent:this.agent}));L.on("error",y),L.on("response",function(W){return W.on("end",function(){return y(null,W)}).resume()}),L.end(i.from(JSON.stringify(q),"utf8"))}}])&&f(R.prototype,d),$}(F)}).call(this,n(15).setImmediate,n(5).Buffer)},function(e,t,n){(function(r,i,s){var l=n(84),o=n(7),c=n(85),u=n(31),f=n(191),E=c.IncomingMessage,_=c.readyStates,h=e.exports=function(b){var A,j=this;u.Writable.call(j),j._opts=b,j._body=[],j._headers={},b.auth&&j.setHeader("Authorization","Basic "+new r(b.auth).toString("base64")),Object.keys(b.headers).forEach(function(M){j.setHeader(M,b.headers[M])});var F=!0;if(b.mode==="disable-fetch"||"requestTimeout"in b&&!l.abortController)F=!1,A=!0;else if(b.mode==="prefer-streaming")A=!1;else if(b.mode==="allow-wrong-content-type")A=!l.overrideMimeType;else{if(b.mode&&b.mode!=="default"&&b.mode!=="prefer-fast")throw new Error("Invalid value for opts.mode");A=!0}j._mode=function(M,R){return l.fetch&&R?"fetch":l.mozchunkedarraybuffer?"moz-chunked-arraybuffer":l.msstream?"ms-stream":l.arraybuffer&&M?"arraybuffer":l.vbArray&&M?"text:vbarray":"text"}(A,F),j._fetchTimer=null,j.on("finish",function(){j._onFinish()})};o(h,u.Writable),h.prototype.setHeader=function(b,A){var j=b.toLowerCase();g.indexOf(j)===-1&&(this._headers[j]={name:b,value:A})},h.prototype.getHeader=function(b){var A=this._headers[b.toLowerCase()];return A?A.value:null},h.prototype.removeHeader=function(b){delete this._headers[b.toLowerCase()]},h.prototype._onFinish=function(){var b=this;if(!b._destroyed){var A=b._opts,j=b._headers,F=null;A.method!=="GET"&&A.method!=="HEAD"&&(F=l.arraybuffer?f(r.concat(b._body)):l.blobConstructor?new i.Blob(b._body.map(function($){return f($)}),{type:(j["content-type"]||{}).value||""}):r.concat(b._body).toString());var M=[];if(Object.keys(j).forEach(function($){var q=j[$].name,y=j[$].value;Array.isArray(y)?y.forEach(function(m){M.push([q,m])}):M.push([q,y])}),b._mode==="fetch"){var R=null;if(l.abortController){var d=new AbortController;R=d.signal,b._fetchAbortController=d,"requestTimeout"in A&&A.requestTimeout!==0&&(b._fetchTimer=i.setTimeout(function(){b.emit("requestTimeout"),b._fetchAbortController&&b._fetchAbortController.abort()},A.requestTimeout))}i.fetch(b._opts.url,{method:b._opts.method,headers:M,body:F||void 0,mode:"cors",credentials:A.withCredentials?"include":"same-origin",signal:R}).then(function($){b._fetchResponse=$,b._connect()},function($){i.clearTimeout(b._fetchTimer),b._destroyed||b.emit("error",$)})}else{var I=b._xhr=new i.XMLHttpRequest;try{I.open(b._opts.method,b._opts.url,!0)}catch($){return void s.nextTick(function(){b.emit("error",$)})}"responseType"in I&&(I.responseType=b._mode.split(":")[0]),"withCredentials"in I&&(I.withCredentials=!!A.withCredentials),b._mode==="text"&&"overrideMimeType"in I&&I.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in A&&(I.timeout=A.requestTimeout,I.ontimeout=function(){b.emit("requestTimeout")}),M.forEach(function($){I.setRequestHeader($[0],$[1])}),b._response=null,I.onreadystatechange=function(){switch(I.readyState){case _.LOADING:case _.DONE:b._onXHRProgress()}},b._mode==="moz-chunked-arraybuffer"&&(I.onprogress=function(){b._onXHRProgress()}),I.onerror=function(){b._destroyed||b.emit("error",new Error("XHR error"))};try{I.send(F)}catch($){return void s.nextTick(function(){b.emit("error",$)})}}}},h.prototype._onXHRProgress=function(){(function(b){try{var A=b.status;return A!==null&&A!==0}catch{return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},h.prototype._connect=function(){var b=this;b._destroyed||(b._response=new E(b._xhr,b._fetchResponse,b._mode,b._fetchTimer),b._response.on("error",function(A){b.emit("error",A)}),b.emit("response",b._response))},h.prototype._write=function(b,A,j){this._body.push(b),j()},h.prototype.abort=h.prototype.destroy=function(){this._destroyed=!0,i.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},h.prototype.end=function(b,A,j){typeof b=="function"&&(j=b,b=void 0),u.Writable.prototype.end.call(this,b,A,j)},h.prototype.flushHeaders=function(){},h.prototype.setTimeout=function(){},h.prototype.setNoDelay=function(){},h.prototype.setSocketKeepAlive=function(){};var g=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,n(5).Buffer,n(6),n(2))},function(e,t,n){var r=n(5).Buffer;e.exports=function(i){if(i instanceof Uint8Array){if(i.byteOffset===0&&i.byteLength===i.buffer.byteLength)return i.buffer;if(typeof i.buffer.slice=="function")return i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}if(r.isBuffer(i)){for(var s=new Uint8Array(i.length),l=i.length,o=0;o<l;o++)s[o]=i[o];return s.buffer}throw new Error("Argument must be a Buffer")}},function(e,t){e.exports=function(){for(var r={},i=0;i<arguments.length;i++){var s=arguments[i];for(var l in s)n.call(s,l)&&(r[l]=s[l])}return r};var n=Object.prototype.hasOwnProperty},function(e,t){e.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},function(e,t,n){(function(r,i){var s;(function(l){t&&t.nodeType,r&&r.nodeType;var o=typeof i=="object"&&i;o.global!==o&&o.window!==o&&o.self;var c,u=2147483647,f=/^xn--/,E=/[^\x20-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},g=Math.floor,b=String.fromCharCode;function A(y){throw new RangeError(h[y])}function j(y,m){for(var C=y.length,w=[];C--;)w[C]=m(y[C]);return w}function F(y,m){var C=y.split("@"),w="";return C.length>1&&(w=C[0]+"@",y=C[1]),w+j((y=y.replace(_,".")).split("."),m).join(".")}function M(y){for(var m,C,w=[],L=0,W=y.length;L<W;)(m=y.charCodeAt(L++))>=55296&&m<=56319&&L<W?(64512&(C=y.charCodeAt(L++)))==56320?w.push(((1023&m)<<10)+(1023&C)+65536):(w.push(m),L--):w.push(m);return w}function R(y){return j(y,function(m){var C="";return m>65535&&(C+=b((m-=65536)>>>10&1023|55296),m=56320|1023&m),C+=b(m)}).join("")}function d(y,m){return y+22+75*(y<26)-((m!=0)<<5)}function I(y,m,C){var w=0;for(y=C?g(y/700):y>>1,y+=g(y/m);y>455;w+=36)y=g(y/35);return g(w+36*y/(y+38))}function $(y){var m,C,w,L,W,k,N,P,z,O,p,U=[],V=y.length,Q=0,ee=128,ne=72;for((C=y.lastIndexOf("-"))<0&&(C=0),w=0;w<C;++w)y.charCodeAt(w)>=128&&A("not-basic"),U.push(y.charCodeAt(w));for(L=C>0?C+1:0;L<V;){for(W=Q,k=1,N=36;L>=V&&A("invalid-input"),((P=(p=y.charCodeAt(L++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:36)>=36||P>g((u-Q)/k))&&A("overflow"),Q+=P*k,!(P<(z=N<=ne?1:N>=ne+26?26:N-ne));N+=36)k>g(u/(O=36-z))&&A("overflow"),k*=O;ne=I(Q-W,m=U.length+1,W==0),g(Q/m)>u-ee&&A("overflow"),ee+=g(Q/m),Q%=m,U.splice(Q++,0,ee)}return R(U)}function q(y){var m,C,w,L,W,k,N,P,z,O,p,U,V,Q,ee,ne=[];for(U=(y=M(y)).length,m=128,C=0,W=72,k=0;k<U;++k)(p=y[k])<128&&ne.push(b(p));for(w=L=ne.length,L&&ne.push("-");w<U;){for(N=u,k=0;k<U;++k)(p=y[k])>=m&&p<N&&(N=p);for(N-m>g((u-C)/(V=w+1))&&A("overflow"),C+=(N-m)*V,m=N,k=0;k<U;++k)if((p=y[k])<m&&++C>u&&A("overflow"),p==m){for(P=C,z=36;!(P<(O=z<=W?1:z>=W+26?26:z-W));z+=36)ee=P-O,Q=36-O,ne.push(b(d(O+ee%Q,0))),P=g(ee/Q);ne.push(b(d(P,0))),W=I(C,V,w==L),C=0,++w}++C,++m}return ne.join("")}c={version:"1.4.1",ucs2:{decode:M,encode:R},decode:$,encode:q,toASCII:function(y){return F(y,function(m){return E.test(m)?"xn--"+q(m):m})},toUnicode:function(y){return F(y,function(m){return f.test(m)?$(m.slice(4).toLowerCase()):m})}},(s=function(){return c}.call(t,n,t,r))===void 0||(r.exports=s)})()}).call(this,n(195)(e),n(6))},function(e,t){e.exports=function(n){return n.webpackPolyfill||(n.deprecate=function(){},n.paths=[],n.children||(n.children=[]),Object.defineProperty(n,"loaded",{enumerable:!0,get:function(){return n.l}}),Object.defineProperty(n,"id",{enumerable:!0,get:function(){return n.i}}),n.webpackPolyfill=1),n}},function(e,t,n){e.exports={isString:function(r){return typeof r=="string"},isObject:function(r){return typeof r=="object"&&r!==null},isNull:function(r){return r===null},isNullOrUndefined:function(r){return r==null}}},function(e,t,n){t.decode=t.parse=n(198),t.encode=t.stringify=n(199)},function(e,t,n){function r(s,l){return Object.prototype.hasOwnProperty.call(s,l)}e.exports=function(s,l,o,c){l=l||"&",o=o||"=";var u={};if(typeof s!="string"||s.length===0)return u;var f=/\+/g;s=s.split(l);var E=1e3;c&&typeof c.maxKeys=="number"&&(E=c.maxKeys);var _=s.length;E>0&&_>E&&(_=E);for(var h=0;h<_;++h){var g,b,A,j,F=s[h].replace(f,"%20"),M=F.indexOf(o);M>=0?(g=F.substr(0,M),b=F.substr(M+1)):(g=F,b=""),A=decodeURIComponent(g),j=decodeURIComponent(b),r(u,A)?i(u[A])?u[A].push(j):u[A]=[u[A],j]:u[A]=j}return u};var i=Array.isArray||function(s){return Object.prototype.toString.call(s)==="[object Array]"}},function(e,t,n){var r=function(o){switch(typeof o){case"string":return o;case"boolean":return o?"true":"false";case"number":return isFinite(o)?o:"";default:return""}};e.exports=function(o,c,u,f){return c=c||"&",u=u||"=",o===null&&(o=void 0),typeof o=="object"?s(l(o),function(E){var _=encodeURIComponent(r(E))+u;return i(o[E])?s(o[E],function(h){return _+encodeURIComponent(r(h))}).join(c):_+encodeURIComponent(r(o[E]))}).join(c):f?encodeURIComponent(r(f))+u+encodeURIComponent(r(o)):""};var i=Array.isArray||function(o){return Object.prototype.toString.call(o)==="[object Array]"};function s(o,c){if(o.map)return o.map(c);for(var u=[],f=0;f<o.length;f++)u.push(c(o[f],f));return u}var l=Object.keys||function(o){var c=[];for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&c.push(u);return c}},function(e,t,n){var r=n(83),i=n(86),s=e.exports;for(var l in r)r.hasOwnProperty(l)&&(s[l]=r[l]);function o(c){if(typeof c=="string"&&(c=i.parse(c)),c.protocol||(c.protocol="https:"),c.protocol!=="https:")throw new Error('Protocol "'+c.protocol+'" not supported. Expected "https:"');return c}s.request=function(c,u){return c=o(c),r.request.call(this,c,u)},s.get=function(c,u){return c=o(c),r.get.call(this,c,u)}},function(e,t,n){(function(r){function i(b){return(i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(b)}function s(b,A){if(!(b instanceof A))throw new TypeError("Cannot call a class as a function")}function l(b,A){for(var j=0;j<A.length;j++){var F=A[j];F.enumerable=F.enumerable||!1,F.configurable=!0,"value"in F&&(F.writable=!0),Object.defineProperty(b,F.key,F)}}function o(b,A){return(o=Object.setPrototypeOf||function(j,F){return j.__proto__=F,j})(b,A)}function c(b){var A=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var j,F=f(b);if(A){var M=f(this).constructor;j=Reflect.construct(F,arguments,M)}else j=F.apply(this,arguments);return u(this,j)}}function u(b,A){return!A||i(A)!=="object"&&typeof A!="function"?function(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}(b):A}function f(b){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)})(b)}var E=n(87),_=n(3).MESSAGE,h=n(18),g=n(20);e.exports=function(b){(function(R,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");R.prototype=Object.create(d&&d.prototype,{constructor:{value:R,writable:!0,configurable:!0}}),d&&o(R,d)})(M,b);var A,j,F=c(M);function M(){var R,d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(s(this,M),R=F.call(this,d),!d.stream||!E(d.stream))throw new Error("options.stream is required.");return R._stream=d.stream,R._stream.setMaxListeners(1/0),R.isObjectMode=d.stream._writableState.objectMode,R.eol=d.eol||h.EOL,R}return A=M,(j=[{key:"log",value:function(R,d){var I=this;if(r(function(){return I.emit("logged",R)}),this.isObjectMode)return this._stream.write(R),void(d&&d());this._stream.write("".concat(R[_]).concat(this.eol)),d&&d()}}])&&l(A.prototype,j),M}(g)}).call(this,n(15).setImmediate)},function(e,t,n){(function(r){function i(w,L,W){return L in w?Object.defineProperty(w,L,{value:W,enumerable:!0,configurable:!0,writable:!0}):w[L]=W,w}function s(w){return(s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L})(w)}function l(w,L){for(var W=0;W<L.length;W++){var k=L[W];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(w,k.key,k)}}function o(w,L){return(o=Object.setPrototypeOf||function(W,k){return W.__proto__=k,W})(w,L)}function c(w){var L=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var W,k=f(w);if(L){var N=f(this).constructor;W=Reflect.construct(k,arguments,N)}else W=k.apply(this,arguments);return u(this,W)}}function u(w,L){return!L||s(L)!=="object"&&typeof L!="function"?function(W){if(W===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return W}(w):L}function f(w){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(L){return L.__proto__||Object.getPrototypeOf(L)})(w)}var E=n(32),_=E.Stream,h=E.Transform,g=n(51),b=n(3),A=b.LEVEL,j=b.SPLAT,F=n(87),M=n(89),R=n(93),d=n(206),I=n(207),$=n(61).warn,q=n(50),y=/%[scdjifoO%]/g,m=function(w){(function(P,z){if(typeof z!="function"&&z!==null)throw new TypeError("Super expression must either be null or a function");P.prototype=Object.create(z&&z.prototype,{constructor:{value:P,writable:!0,configurable:!0}}),z&&o(P,z)})(N,w);var L,W,k=c(N);function N(P){var z;return function(O,p){if(!(O instanceof p))throw new TypeError("Cannot call a class as a function")}(this,N),(z=k.call(this,{objectMode:!0})).configure(P),z}return L=N,(W=[{key:"child",value:function(P){var z=this;return Object.create(z,{write:{value:function(O){var p=Object.assign({},P,O);O instanceof Error&&(p.stack=O.stack,p.message=O.message),z.write(p)}}})}},{key:"configure",value:function(){var P=this,z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},O=z.silent,p=z.format,U=z.defaultMeta,V=z.levels,Q=z.level,ee=Q===void 0?"info":Q,ne=z.exitOnError,Y=ne===void 0||ne,G=z.transports,S=z.colors,T=z.emitErrs,B=z.formatters,J=z.padLevels,K=z.rewriters,re=z.stripColors,se=z.exceptionHandlers,fe=z.rejectionHandlers;if(this.transports.length&&this.clear(),this.silent=O,this.format=p||this.format||n(208)(),this.defaultMeta=U||null,this.levels=V||this.levels||q.npm.levels,this.level=ee,this.exceptions=new M(this),this.rejections=new R(this),this.profilers={},this.exitOnError=Y,G&&(G=Array.isArray(G)?G:[G]).forEach(function(ve){return P.add(ve)}),S||T||B||J||K||re)throw new Error(["{ colors, emitErrs, formatters, padLevels, rewriters, stripColors } were removed in winston@3.0.0.","Use a custom winston.format(function) instead.","See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md"].join(`
|
|
44
44
|
`));se&&this.exceptions.handle(se),fe&&this.rejections.handle(fe)}},{key:"isLevelEnabled",value:function(P){var z=this,O=C(this.levels,P);if(O===null)return!1;var p=C(this.levels,this.level);return p!==null&&(this.transports&&this.transports.length!==0?this.transports.findIndex(function(U){var V=C(z.levels,U.level);return V===null&&(V=p),V>=O})!==-1:p>=O)}},{key:"log",value:function(P,z){for(var O,p,U=arguments.length,V=new Array(U>2?U-2:0),Q=2;Q<U;Q++)V[Q-2]=arguments[Q];if(arguments.length===1)return P[A]=P.level,this._addDefaultMeta(P),this.write(P),this;if(arguments.length===2)return z&&s(z)==="object"?(z[A]=z.level=P,this._addDefaultMeta(z),this.write(z),this):(this.write((i(p={},A,P),i(p,"level",P),i(p,"message",z),p)),this);var ee=V[0];if(s(ee)==="object"&&ee!==null){var ne=z&&z.match&&z.match(y);if(!ne){var Y,G=Object.assign({},this.defaultMeta,ee,(i(Y={},A,P),i(Y,j,V),i(Y,"level",P),i(Y,"message",z),Y));return ee.message&&(G.message="".concat(G.message," ").concat(ee.message)),ee.stack&&(G.stack=ee.stack),this.write(G),this}}return this.write(Object.assign({},this.defaultMeta,(i(O={},A,P),i(O,j,V),i(O,"level",P),i(O,"message",z),O))),this}},{key:"_transform",value:function(P,z,O){if(this.silent)return O();P[A]||(P[A]=P.level),this.levels[P[A]]||this.levels[P[A]]===0||console.error("[winston] Unknown logger level: %s",P[A]),this._readableState.pipes||console.error("[winston] Attempt to write logs with no transports %j",P);try{this.push(this.format.transform(P,this.format.options))}catch(p){throw p}finally{O()}}},{key:"_final",value:function(P){var z=this.transports.slice();g(z,function(O,p){if(!O||O.finished)return r(p);O.once("finish",p),O.end()},P)}},{key:"add",value:function(P){var z=!F(P)||P.log.length>2?new d({transport:P}):P;if(!z._writableState||!z._writableState.objectMode)throw new Error("Transports must WritableStreams in objectMode. Set { objectMode: true }.");return this._onEvent("error",z),this._onEvent("warn",z),this.pipe(z),P.handleExceptions&&this.exceptions.handle(),P.handleRejections&&this.rejections.handle(),this}},{key:"remove",value:function(P){if(!P)return this;var z=P;return(!F(P)||P.log.length>2)&&(z=this.transports.filter(function(O){return O.transport===P})[0]),z&&this.unpipe(z),this}},{key:"clear",value:function(){return this.unpipe(),this}},{key:"close",value:function(){return this.clear(),this.emit("close"),this}},{key:"setLevels",value:function(){$.deprecated("setLevels")}},{key:"query",value:function(P,z){typeof P=="function"&&(z=P,P={}),P=P||{};var O={},p=Object.assign({},P.query||{});g(this.transports.filter(function(U){return!!U.query}),function(U,V){(function(Q,ee){P.query&&typeof Q.formatQuery=="function"&&(P.query=Q.formatQuery(p)),Q.query(P,function(ne,Y){if(ne)return ee(ne);typeof Q.formatResults=="function"&&(Y=Q.formatResults(Y,P.format)),ee(null,Y)})})(U,function(Q,ee){V&&((ee=Q||ee)&&(O[U.name]=ee),V()),V=null})},function(){return z(null,O)})}},{key:"stream",value:function(){var P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},z=new _,O=[];return z._streams=O,z.destroy=function(){for(var p=O.length;p--;)O[p].destroy()},this.transports.filter(function(p){return!!p.stream}).forEach(function(p){var U=p.stream(P);U&&(O.push(U),U.on("log",function(V){V.transport=V.transport||[],V.transport.push(p.name),z.emit("log",V)}),U.on("error",function(V){V.transport=V.transport||[],V.transport.push(p.name),z.emit("error",V)}))}),z}},{key:"startTimer",value:function(){return new I(this)}},{key:"profile",value:function(P){var z=Date.now();if(this.profilers[P]){var O=this.profilers[P];delete this.profilers[P];for(var p=arguments.length,U=new Array(p>1?p-1:0),V=1;V<p;V++)U[V-1]=arguments[V];typeof U[U.length-2]=="function"&&(console.warn("Callback function no longer supported as of winston@3.0.0"),U.pop());var Q=s(U[U.length-1])==="object"?U.pop():{};return Q.level=Q.level||"info",Q.durationMs=z-O,Q.message=Q.message||P,this.write(Q)}return this.profilers[P]=z,this}},{key:"handleExceptions",value:function(){var P;console.warn("Deprecated: .handleExceptions() will be removed in winston@4. Use .exceptions.handle()"),(P=this.exceptions).handle.apply(P,arguments)}},{key:"unhandleExceptions",value:function(){var P;console.warn("Deprecated: .unhandleExceptions() will be removed in winston@4. Use .exceptions.unhandle()"),(P=this.exceptions).unhandle.apply(P,arguments)}},{key:"cli",value:function(){throw new Error(["Logger.cli() was removed in winston@3.0.0","Use a custom winston.formats.cli() instead.","See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md"].join(`
|
|
45
45
|
`))}},{key:"_onEvent",value:function(P,z){z["__winston"+P]||(z["__winston"+P]=function(O){P!=="error"||this.transports.includes(z)||this.add(z),this.emit(P,O,z)}.bind(this),z.on(P,z["__winston"+P]))}},{key:"_addDefaultMeta",value:function(P){this.defaultMeta&&Object.assign(P,this.defaultMeta)}}])&&l(L.prototype,W),N}(h);function C(w,L){var W=w[L];return W||W===0?W:null}Object.defineProperty(m.prototype,"transports",{configurable:!1,enumerable:!0,get:function(){var w=this._readableState.pipes;return Array.isArray(w)?w:[w].filter(Boolean)}}),e.exports=m}).call(this,n(15).setImmediate)},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0});var r=f(n(45)),i=f(n(46)),s=f(n(66)),l=f(n(67)),o=f(n(68)),c=f(n(25)),u=f(n(30));function f(h){return h&&h.__esModule?h:{default:h}}function E(h,g,b){b=(0,l.default)(b);var A=0,j=0,{length:F}=h,M=!1;function R(d,I){d===!1&&(M=!0),M!==!0&&(d?b(d):++j!==F&&I!==i.default||b(null))}for(F===0&&b(null);A<F;A++)g(h[A],A,(0,o.default)(R))}function _(h,g,b){return(0,s.default)(h,1/0,g,b)}t.default=(0,u.default)(function(h,g,b){return((0,r.default)(h)?E:_)(h,(0,c.default)(g),b)},3),e.exports=t.default},function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return(i,s,l)=>r(i,l)},e.exports=t.default},function(e,t,n){var r=Object.prototype.toString;e.exports=function(i){if(typeof i.displayName=="string"&&i.constructor.name)return i.displayName;if(typeof i.name=="string"&&i.name)return i.name;if(typeof i=="object"&&i.constructor&&typeof i.constructor.name=="string")return i.constructor.name;var s=i.toString(),l=r.call(i).slice(8,-1);return(s=l==="Function"?s.substring(s.indexOf("(")+1,s.indexOf(")")):l)||"anonymous"}},function(e,t,n){const r=n(13),{LEVEL:i}=n(3),s=n(20),l=e.exports=function(o={}){if(s.call(this,o),!o.transport||typeof o.transport.log!="function")throw new Error("Invalid transport, must be an object with a log method.");this.transport=o.transport,this.level=this.level||o.transport.level,this.handleExceptions=this.handleExceptions||o.transport.handleExceptions,this._deprecated(),this.transport.__winstonError||(this.transport.__winstonError=function(c){this.emit("error",c,this.transport)}.bind(this),this.transport.on("error",this.transport.__winstonError))};r.inherits(l,s),l.prototype._write=function(o,c,u){if(this.silent||o.exception===!0&&!this.handleExceptions)return u(null);(!this.level||this.levels[this.level]>=this.levels[o[i]])&&this.transport.log(o[i],o.message,o,this._nop),u(null)},l.prototype._writev=function(o,c){for(let u=0;u<o.length;u++)this._accept(o[u])&&(this.transport.log(o[u].chunk[i],o[u].chunk.message,o[u].chunk,this._nop),o[u].callback());return c(null)},l.prototype._deprecated=function(){console.error([`${this.transport.name} is a legacy winston transport. Consider upgrading: `,"- Upgrade docs: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md"].join(`
|
|
46
46
|
`))},l.prototype.close=function(){this.transport.close&&this.transport.close(),this.transport.__winstonError&&(this.transport.removeListener("error",this.transport.__winstonError),this.transport.__winstonError=null)}},function(e,t,n){function r(s){return(r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l})(s)}function i(s,l){for(var o=0;o<l.length;o++){var c=l[o];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(s,c.key,c)}}e.exports=function(){function s(c){if(function(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,s),!c)throw new Error("Logger is required for profiling.");this.logger=c,this.start=Date.now()}var l,o;return l=s,(o=[{key:"done",value:function(){for(var c=arguments.length,u=new Array(c),f=0;f<c;f++)u[f]=arguments[f];typeof u[u.length-1]=="function"&&(console.warn("Callback function no longer supported as of winston@3.0.0"),u.pop());var E=r(u[u.length-1])==="object"?u.pop():{};return E.level=E.level||"info",E.durationMs=Date.now()-this.start,this.logger.write(E)}}])&&i(l.prototype,o),s}()},function(e,t,n){(function(r){const i=n(209),{MESSAGE:s}=n(3),l=n(35);function o(c,u){return u instanceof r?u.toString("base64"):typeof u=="bigint"?u.toString():u}e.exports=i((c,u={})=>(c[s]=(u.stable?l.stableStringify:l)(c,u.replacer||o,u.space),c))}).call(this,n(5).Buffer)},function(e,t,n){class r extends Error{constructor(s){super(`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
47
47
|
Found: ${s.toString().split(`
|
|
48
48
|
`)[0]}
|
|
49
|
-
`),Error.captureStackTrace(this,r)}}e.exports=i=>{if(i.length>2)throw new r(i);function s(o={}){this.options=o}function l(o){return new s(o)}return s.prototype.transform=i,l.Format=s,l}},function(e,t,n){function r(l,o){if(!(l instanceof o))throw new TypeError("Cannot call a class as a function")}function i(l,o){for(var c=0;c<o.length;c++){var u=o[c];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(l,u.key,u)}}var s=n(88);e.exports=function(){function l(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};r(this,l),this.loggers=new Map,this.options=u}var o,c;return o=l,(c=[{key:"add",value:function(u,f){var E=this;if(!this.loggers.has(u)){var _=(f=Object.assign({},f||this.options)).transports||this.options.transports;f.transports=_?_.slice():[];var h=s(f);h.on("close",function(){return E._delete(u)}),this.loggers.set(u,h)}return this.loggers.get(u)}},{key:"get",value:function(u,f){return this.add(u,f)}},{key:"has",value:function(u){return!!this.loggers.has(u)}},{key:"close",value:function(u){var f=this;if(u)return this._removeLogger(u);this.loggers.forEach(function(E,_){return f._removeLogger(_)})}},{key:"_removeLogger",value:function(u){this.loggers.has(u)&&(this.loggers.get(u).close(),this._delete(u))}},{key:"_delete",value:function(u){this.loggers.delete(u)}}])&&i(o.prototype,c),l}()},function(e,t,n){(function(r){const i=n(52),s=/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/;e.exports=function(l,o,c,u){let f,E,_=!1,h=!1;const g=n(94);function b(F){u(o,F)}function A(F,M){let R=`"${o}" ${M}`;throw F&&(R=`${R}`),E&&(R=`${R}. An example of a valid value would be: ${E}`),new i(R)}const j={convertFromBase64:function(){return b("marking for base64 conversion"),_=!0,j},default:function(F){if(typeof F=="number")f=F.toString();else if(Array.isArray(F)||typeof F=="object"&&F!==null)f=JSON.stringify(F);else{if(typeof F!="string")throw new i("values passed to default() must be of Number, String, Array, or Object type");f=F}return b(`setting default value to "${f}"`),j},required:function(F){return F===void 0?(b("marked as required"),h=!0):(b(`setting required flag to ${F}`),h=F),j},example:function(F){return E=F,j}};return Object.entries({...g,...c}).forEach(([F,M])=>{j[F]=function(R){return function(){let d=l[o];if(b(`will be read from the environment using "${R.name}" accessor`),d===void 0)if(f===void 0&&h)b("was not found in the environment, but is required to be set"),A(void 0,"is a required variable, but it was not set");else{if(f===void 0)return void b("was not found in the environment, but is not required. returning undefined");b(`was not found in the environment, parsing default value "${f}" instead`),d=f}h&&(b("verifying variable value is not an empty string"),d.trim().length===0&&A(void 0,"is a required variable, but its value was empty")),_&&(b("verifying variable is a valid base64 string"),d.match(s)||A(d,"should be a valid base64 string if using convertFromBase64"),b("converting from base64 to utf8 string"),d=r.from(d,"base64").toString());const I=[d].concat(Array.prototype.slice.call(arguments));try{b(`passing value "${d}" to "${R.name}" accessor`);const $=R.apply(R,I);return b(`parsed successfully, returning ${$}`),$}catch($){A(d,$.message)}}}(M)}),j}}).call(this,n(5).Buffer)},function(e,t,n){const r=n(33);e.exports=function(i,s){return s=s||",",i.length?r(i).split(s).filter(Boolean):[]}},function(e,t,n){e.exports=function(r){const i=r.toLowerCase();if(i!=="false"&&i!=="true")throw new Error('should be either "true", "false", "TRUE", or "FALSE"');return i!=="false"}},function(e,t,n){e.exports=function(r){const i=r.toLowerCase();if(["false","0","true","1"].indexOf(i)===-1)throw new Error('should be either "true", "false", "TRUE", "FALSE", 1, or 0');return!(i==="0"||i==="false")}},function(e,t,n){const r=n(95);e.exports=function(i){var s=r(i);if(s>65535)throw new Error("cannot assign a port number greater than 65535");return s}},function(e,t,n){const r=n(33);e.exports=function(i,s){const l=r(i);if(s.indexOf(l)<0)throw new Error(`should be one of [${s.join(", ")}]`);return l}},function(e,t,n){const r=n(54);e.exports=function(i){const s=r(i);if(s>0)throw new Error("should be a negative float");return s}},function(e,t,n){const r=n(54);e.exports=function(i){const s=r(i);if(s<0)throw new Error("should be a positive float");return s}},function(e,t,n){const r=n(53);e.exports=function(i){const s=r(i);if(s>0)throw new Error("should be a negative integer");return s}},function(e,t,n){const r=n(55);e.exports=function(i){var s=r(i);if(!Array.isArray(s))throw new Error("should be a parseable JSON Array");return s}},function(e,t,n){const r=n(55);e.exports=function(i){var s=r(i);if(Array.isArray(s))throw new Error("should be a parseable JSON Object");return s}},function(e,t,n){e.exports=function(r,i){try{RegExp(void 0,i)}catch{throw new Error("invalid regexp flags")}try{return new RegExp(r,i)}catch{throw new Error("should be a valid regexp")}}},function(e,t,n){const r=n(96);e.exports=function(i){return r(i).toString()}},function(e,t,n){const r=n(33),i=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\u0001-\u0008\u000b\u000c\u000e-\u001f\u0021\u0023-\u005b\u005d-\u007f]|\\[\u0001-\u0009\u000b\u000c\u000e-\u007f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\u0001-\u0008\u000b\u000c\u000e-\u001f\u0021-\u005a\u0053-\u007f]|\\[\u0001-\u0009\u000b\u000c\u000e-\u007f])+)\])$/;e.exports=function(s){const l=r(s);if(!i.test(l))throw new Error("should be a valid email address");return l}},function(e,t,n){e.exports=function(r,i){return function(s,l){i&&i.match(/prod|production/)||r(`env-var (${s}): ${l}`)}}},function(e,t,n){(function(r){(function(){var i,s,l,o,c,u;typeof performance<"u"&&performance!==null&&performance.now?e.exports=function(){return performance.now()}:r!=null&&r.hrtime?(e.exports=function(){return(i()-c)/1e6},s=r.hrtime,o=(i=function(){var f;return 1e9*(f=s())[0]+f[1]})(),u=1e9*r.uptime(),c=o-u):Date.now?(e.exports=function(){return Date.now()-l},l=Date.now()):(e.exports=function(){return new Date().getTime()-l},l=new Date().getTime())}).call(this)}).call(this,n(2))},function(e,t,n){(function(r){(function(i){function s(o){if((o=o===void 0?"utf-8":o)!=="utf-8")throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('"+o+"') is invalid.")}function l(o,c){if(c=c===void 0?{fatal:!1}:c,(o=o===void 0?"utf-8":o)!=="utf-8")throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+o+"') is invalid.");if(c.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}if(i.TextEncoder&&i.TextDecoder)return!1;Object.defineProperty(s.prototype,"encoding",{value:"utf-8"}),s.prototype.encode=function(o,c){if((c=c===void 0?{stream:!1}:c).stream)throw Error("Failed to encode: the 'stream' option is unsupported.");c=0;for(var u=o.length,f=0,E=Math.max(32,u+(u>>1)+7),_=new Uint8Array(E>>3<<3);c<u;){var h=o.charCodeAt(c++);if(55296<=h&&56319>=h){if(c<u){var g=o.charCodeAt(c);(64512&g)==56320&&(++c,h=((1023&h)<<10)+(1023&g)+65536)}if(55296<=h&&56319>=h)continue}if(f+4>_.length&&(E+=8,E=(E*=1+c/o.length*2)>>3<<3,(g=new Uint8Array(E)).set(_),_=g),(4294967168&h)==0)_[f++]=h;else{if(!(4294965248&h))_[f++]=h>>6&31|192;else if(!(4294901760&h))_[f++]=h>>12&15|224,_[f++]=h>>6&63|128;else{if(4292870144&h)continue;_[f++]=h>>18&7|240,_[f++]=h>>12&63|128,_[f++]=h>>6&63|128}_[f++]=63&h|128}}return _.slice(0,f)},Object.defineProperty(l.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(l.prototype,"fatal",{value:!1}),Object.defineProperty(l.prototype,"ignoreBOM",{value:!1}),l.prototype.decode=function(o,c){if((c=c===void 0?{stream:!1}:c).stream)throw Error("Failed to decode: the 'stream' option is unsupported.");c=0;for(var u=(o=new Uint8Array(o)).length,f=[];c<u;){var E=o[c++];if(E===0)break;if(!(128&E))f.push(E);else if((224&E)==192){var _=63&o[c++];f.push((31&E)<<6|_)}else if((240&E)==224){_=63&o[c++];var h=63&o[c++];f.push((31&E)<<12|_<<6|h)}else(248&E)==240&&(65535<(E=(7&E)<<18|(_=63&o[c++])<<12|(h=63&o[c++])<<6|63&o[c++])&&(E-=65536,f.push(E>>>10&1023|55296),E=56320|1023&E),f.push(E))}return String.fromCharCode.apply(null,f)},i.TextEncoder=s,i.TextDecoder=l})(typeof window<"u"?window:r!==void 0?r:this)}).call(this,n(6))},function(e,t,n){n.r(t),n.d(t,"AuthClient",function(){return s}),n.d(t,"RtcSignalingClient",function(){return o}),n.d(t,"Credentials",function(){return L}),n.d(t,"IRtcStream",function(){}),n.d(t,"SignalingPromiseClient",function(){return W.SignalingPromiseClient}),n.d(t,"IRtcClientConfigurationV1",function(){}),n.d(t,"IRtcClientConfiguration",function(){}),n.d(t,"IRtcConnectionStatsInfo",function(){}),n.d(t,"IRtcSendConfiguration",function(){}),n.d(t,"IRtcSessionMetricsMessageCounts",function(){}),n.d(t,"IRtcStreamMessage",function(){}),n.d(t,"IRtcStreamPayload",function(){}),n.d(t,"IStreamControl",function(){}),n.d(t,"RtcClient",function(){return jt}),n.d(t,"RtcClientV1",function(){return Rt}),n.d(t,"createRtcStreamMessage",function(){return Pe});var r=n(28),i=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class s extends r.a{adminSignup(D,H){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/admin-signup",{token:H,method:"POST",body:JSON.stringify(D)})})}login(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/login",{method:"POST",body:JSON.stringify(D),allowUnsafeRetries:!0})})}loginWithGoogleToken(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/login-google",{method:"POST",body:JSON.stringify(D),allowUnsafeRetries:!0})})}refresh(D,H){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/refresh",{method:"POST",body:JSON.stringify({refreshToken:D,tokenExpirationSeconds:H}),allowUnsafeRetries:!0})})}respondToNewPasswordRequiredChallenge(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/respond-to-new-password-required-challenge",{method:"POST",body:JSON.stringify(D)})})}forgotPassword(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/forgot-password",{method:"POST",body:JSON.stringify({email:D})})})}confirmForgotPassword(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/confirm-forgot-password",{method:"POST",body:JSON.stringify(D)})})}resendInvitation(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/resend-invitation",{method:"POST",body:JSON.stringify({email:D})})})}changePassword({token:D,refreshToken:H,currentPassword:X,newPassword:ie}){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/change-password",{token:D,method:"POST",body:JSON.stringify({refreshToken:H,currentPassword:X,newPassword:ie})})})}getDeviceCredentials(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/device-credentials",{token:D,method:"POST",allowUnsafeRetries:!0})})}impersonate(D,H){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/impersonate",{token:D,method:"POST",allowUnsafeRetries:!0,body:JSON.stringify({userId:H})})})}createServiceAccount(D,H,X,ie){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/service-account",{token:D,method:"POST",allowUnsafeRetries:!0,body:JSON.stringify({name:H,roleId:X,tags:ie})})})}getFeatures(D){return i(this,void 0,void 0,function*(){return(yield this.fetch("auth/features",{token:D})).features})}}var l=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class o extends r.a{createPeer(D,H){return l(this,void 0,void 0,function*(){return yield this.fetch("peers",{token:D,method:"POST",body:JSON.stringify(H)})})}getPeers(D){return l(this,void 0,void 0,function*(){return(yield this.fetch("peers",{token:D})).items})}refreshPeer(D,H){return l(this,void 0,void 0,function*(){yield this.fetch(`peers/${H}/refresh`,{token:D,method:"POST",allowUnsafeRetries:!0})})}createSession(D,H){return l(this,void 0,void 0,function*(){return yield this.fetch("sessions",{token:D,method:"POST",body:JSON.stringify(H)})})}refreshSession(D,H){return l(this,void 0,void 0,function*(){yield this.fetch(`sessions/${H}/refresh`,{token:D,method:"POST",allowUnsafeRetries:!0})})}deleteSession(D,H){return l(this,void 0,void 0,function*(){yield this.fetch(`sessions/${H}`,{token:D,method:"DELETE",allowUnsafeRetries:!0})})}getSessions(D){return l(this,void 0,void 0,function*(){return(yield this.fetch("sessions",{token:D})).items})}getIceServers(D){return l(this,void 0,void 0,function*(){return(yield this.fetch("ice-servers",{token:D})).items})}addSignals(D,H,X){return l(this,void 0,void 0,function*(){yield this.fetch(`sessions/${H}/add-signals`,{token:D,method:"POST",body:JSON.stringify(X)})})}takeSignals(D,H){return l(this,void 0,void 0,function*(){return(yield this.fetch(`sessions/${H}/take-signals`,{token:D,method:"POST"})).items})}}var c=n(1),u=n(8),f=n(14),E=n.n(f),_=n(104),h=n.n(_),g=n(0),b=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class A{constructor(D){this.name="LogReporter",this.type="simple",this.message=D}send(D){return b(this,void 0,void 0,function*(){var H,X;g.a.info(this.message,(H=D.reduce((ie,oe)=>Object.assign(Object.assign({},ie),{[oe.name]:oe.stat}),{}),X=ie=>{const{sum:oe,count:de}=ie,ye=oe/de;return Object.assign(Object.assign({},ie),{average:ye})},Object.keys(H).reduce((ie,oe)=>Object.assign(Object.assign({},ie),{[oe]:X(H[oe])}),{})))})}}var j=n(4),F=n(39);function M(pe){return!!pe.match(/^[a-zA-Z0-9-_.,:?'"()@\/\\#$+ ]{1,255}$/)}var R=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};function d({func:pe,delay:D,immediate:H=!1}){let X=!1,ie=setTimeout(function de(){return R(this,void 0,void 0,function*(){if(X)return;const ye=new Date().getTime();try{oe=pe(),yield oe}finally{if(!X){const be=new Date().getTime();ie=setTimeout(de,Math.max(D-(be-ye),0))}}})},H?0:D),oe=Promise.resolve();return{stop(){return R(this,void 0,void 0,function*(){X=!0,clearTimeout(ie),yield oe})}}}var I=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};const $=n(226),q=!!j.c,y=new class{constructor(pe){this.samplePeriodSeconds=60,this.buffer={},this.reporters=[],this.flushInterval=d({func:()=>this.flushStats(),delay:this.samplePeriodSeconds*c.a.second}),this.tags=this.filterTags((pe==null?void 0:pe.tags)||{app:j.a,version:j.j,namespace:j.i,instanceId:F.a})}shutdown(){return I(this,void 0,void 0,function*(){yield this.flushInterval.stop(),yield this.flushStats(),yield Object(u.a)(2*c.a.second)})}aggregate(pe,D,H){this.addToBuffer(this.buffer,this.encodeKey({metric:pe,tags:this.filterTags(H||{})}),typeof D=="number"?{min:D,max:D,sum:D,count:1}:D)}increment(pe,D){this.aggregate(pe,1,D)}timer(pe,D,H){return I(this,void 0,void 0,function*(){const X=$(),ie=yield D(),oe=$();return this.aggregate(pe,oe-X,H),ie})}registerStatsReporter(pe){this.reporters.push(pe)}setTag(pe,D){const H=this.filterTags({[pe]:D});this.tags=Object.assign(Object.assign({},this.tags),H)}addToBuffer(pe,D,H){if(pe[D]){const{min:X,max:ie,sum:oe,count:de}=pe[D];pe[D]={min:Math.min(X,H.min),max:Math.max(ie,H.max),sum:oe+H.sum,count:de+H.count}}else pe[D]=H}write(pe){return I(this,void 0,void 0,function*(){yield Promise.all(this.reporters.map(D=>I(this,void 0,void 0,function*(){let H;const X={};switch(D.type){case"simple":for(const[oe,de]of Object.entries(pe)){const{metric:ye}=this.decodeKey(oe);this.addToBuffer(X,this.encodeKey({metric:ye}),de)}H=X;break;case"tagged":H=pe;break;default:(function(oe){throw new Error(`Unreachable type encountered (${oe})`)})(D.type)}const ie=Object.entries(H);if(ie.length>0)return D.send(ie.map(([oe,de])=>{const{metric:ye,tags:be}=this.decodeKey(oe);return{name:ye,tags:Object.assign(Object.assign({},be),this.tags),stat:de}}),this.samplePeriodSeconds).catch(oe=>{g.a.debug(`Failed to write stats to ${D.name}`,{error:oe})})})))})}flushStats(){return I(this,void 0,void 0,function*(){yield this.write(this.buffer),this.buffer={}})}encodeKey(pe){return E()(Object.assign(Object.assign({},pe),Object.keys(pe.tags||{}).length>0?{tags:pe.tags}:{}))}decodeKey(pe){return JSON.parse(pe)}filterTags(pe){return Object.entries(pe||{}).reduce((D,[H,X])=>(M(H)&&M(X)&&(D[H]=X),D),{})}};q||["local","on-prem"].includes(j.i)||y.registerStatsReporter(new A("stats"));var m=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class C extends class{constructor(D){this.options=D,this.cache=new h.a(Object.assign(Object.assign(Object.assign({},D.dispose||D.disposeAfter?{ttlAutopurge:!0}:{}),D),{dispose:(...H)=>{var X;H[2]==="evict"&&y.increment("lru-eviction",{name:D.name}),(X=D.dispose)===null||X===void 0||X.call(D,...H)},disposeAfter:(...H)=>{var X;this.updateStats(),(X=D.disposeAfter)===null||X===void 0||X.call(D,...H)}})),this.stringify=D.fastStringify?JSON.stringify:E.a}set(D,H,X){const ie=this.stringify(D);if(!this.cache.set(ie,H,{ttl:X})){const oe=this.cache.sizeCalculation?this.cache.sizeCalculation(H,ie):"unknown";throw Error(`Value too large (${oe} > ${this.cache.max})`)}this.updateStats()}get(D){const{name:H}=this.options,X=this.stringify(D),ie=this.cache.getRemainingTTL(X);return ie<=0?y.increment("cache-miss",{name:H}):ie!==1/0&&y.aggregate("cache-item-ttl",ie,{name:H}),this.cache.get(X)}delete(D){this.cache.delete(this.stringify(D))}peek(D){return this.cache.peek(this.stringify(D))}size(){return this.cache.size}clear(){this.cache.clear()}forEach(D){this.cache.forEach(D)}purgeStale(){return this.cache.purgeStale()}updateStats(){const{name:D}=this.options;y.aggregate("cache-item-count",this.cache.size,{name:D}),this.cache.calculatedSize!==void 0&&y.aggregate("cache-length",this.cache.calculatedSize,{name:D})}}{constructor(D){if(super(D),this.expireRejectedPromiseValues=D.expireRejectedPromiseValues===void 0||D.expireRejectedPromiseValues,this.rejectedPromiseValueTtl=D.rejectedPromiseValueTtl!==void 0?D.rejectedPromiseValueTtl:c.a.second,this.rejectedPromiseValueTtl<0)throw new Error("rejectedPromiseValueTtl must not be negative")}set(D,H,X){super.set(D,H,X),this.expireRejectedPromiseValues&&H.catch(()=>m(this,void 0,void 0,function*(){yield Object(u.a)(this.rejectedPromiseValueTtl),this.peek(D)===H&&this.delete(D)}))}}var w=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class L{constructor(D,H,X){this.authClient=D,this.email=H,this.password=X,this.tokenTtlMs=1*c.a.hour,this.tokenCache=new C({name:"Credentials-tokenCache",max:100,ttl:this.tokenTtlMs-5*c.a.minute,fastStringify:!0})}getToken(){return w(this,void 0,void 0,function*(){let D=this.tokenCache.get(this.email);return D||(D=(()=>w(this,void 0,void 0,function*(){const{authentication:H}=yield this.authClient.login({email:this.email,password:this.password,tokenExpirationSeconds:this.tokenTtlMs/c.a.second});if(!H)throw new Error("User account not verified.");return H.accessToken}))(),this.tokenCache.set(this.email,D)),D})}}var W=n(97),k=n(40),N=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class P extends k.a{constructor(D){super(D)}postLanRtcOffer(D){return N(this,void 0,void 0,function*(){return yield this.fetch("v1/lan-rtc-offer",{method:"POST",body:JSON.stringify(D)})})}}var z=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};function O(pe){return z(this,void 0,void 0,function*(){return(yield Promise.all(pe.map(D=>D.catch(H=>H)))).filter(D=>D instanceof Error)})}function p(pe){if(pe!==void 0)return pe;throw new Error("Value is undefined")}function U(pe,D){const H=pe.reduce((X,ie)=>[...X,...ie.urls],[]).filter(X=>V(X,D)).sort(X=>Q(X,"udp")?-1:0).shift();if(H)return Object.assign(Object.assign({},p(pe.find(X=>X.urls.includes(H)))),{urls:[H]})}function V(pe,D){switch(D){case"stun":return/^stuns?:/.test(pe);case"turn":return/^turns?:/.test(pe)}}function Q(pe,D){return pe.endsWith(`transport=${D}`)}var ee=n(9),ne=n(24),Y=n(229);class G extends Error{constructor(D,H){super(`Deadline expired after ${D}ms + ${H}ms`)}}class S{static withDeadline(D,H){const X=new Promise((ie,oe)=>{setTimeout(()=>{oe(new G(H,this.grpcCallDeadlineSlopMs))},H+this.grpcCallDeadlineSlopMs)});return Promise.race([D,X])}}S.grpcCallDeadlineSlopMs=500*c.a.millisecond;var T=n(29);const B={ordered:!1,maxPacketLifeTime:300*c.a.millisecond},J={ordered:!0},K={ordered:!0},re={ordered:!1,maxRetransmits:0},se={ordered:!1,maxRetransmits:0},fe=pe=>"received"in pe&&pe.received!==void 0,ve=pe=>!("received"in pe)||pe.received===void 0,Ie=2*c.a.second;function Se(pe,D={}){const H=Array.from(pe.values()),X=H.filter(fe),ie=X.length>0,oe=Math.max(...X.map(ce=>ce.received));let de;if(ie){const ce=H.length,le=X.length,Re=X.map(xe=>xe.received-xe.sent),{standardDeviation:Me,mean:je,jitter:Fe}=function(xe){const ke=xe.length;if(ke===0)return{mean:NaN,standardDeviation:-1,jitter:NaN};const Ve=xe.reduce((Qe,lt)=>Qe+lt,0)/ke,Ze=Math.sqrt(xe.map(Qe=>Math.pow(Qe-Ve,2)).reduce((Qe,lt)=>Qe+lt)/ke);if(ke===1)return{mean:Ve,standardDeviation:Ze,jitter:NaN};let Je=0;for(let Qe=1;Qe<ke;Qe++)Je+=Math.abs(xe[Qe]-xe[Qe-1]);return{mean:Ve,standardDeviation:Ze,jitter:Je/(ke-1)}}(Re),Xe=H.filter(xe=>xe.sent<oe-Ie),$e=Xe.filter(ve),Ye=$e.length===0?0:$e.length/Xe.length;de={pingsSent:ce,pongsReceived:le,average:je,standardDeviation:Me,jitter:Fe,max:Math.max(...Re),min:Math.min(...Re),loss:Ye}}else de=null;const{temporalNow:ye=Date.now()}=D,be=(ie?oe:ye)-4*Ie;return Array.from(pe.entries()).forEach(ce=>{const[le,Re]=ce;Re.sent<be&&pe.delete(le)}),de}function Ce({entityId:pe,streamName:D,streamType:H}){return`${pe}.${D}.${H}`}var Ae=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class Oe{constructor(D,H){this.sessionId=D,this.connection=H,this.counts={localSent:new Map,localReceived:new Map,remoteSent:new Map,remoteReceived:new Map},this.sessionId=D,this.connection=H}updateRemoteMessagesCounts(D){if(D.payload.streamsInfo){this.counts.remoteSent=new Map,this.counts.remoteReceived=new Map;for(const H of D.payload.streamsInfo.items)this.counts.remoteSent.set(H.streamId,H.sentCount),this.counts.remoteReceived.set(H.streamId,H.receivedCount)}}getLocalStreamsInfo(D){const{localSent:H,localReceived:X}=this.counts;return{items:[...new Set([...H.keys(),...X.keys()])].map(ie=>{var oe,de;return{streamId:ie,sentCount:(oe=H.get(ie))!==null&&oe!==void 0?oe:0,receivedCount:(de=X.get(ie))!==null&&de!==void 0?de:0}}),timestamp:D}}incrementLocalSent(D){const{localSent:H}=this.counts,X=Ce(D.header.stream);H.set(X,(H.get(X)||0)+1)}incrementLocalReceived(D){const{localReceived:H}=this.counts,X=Ce(D.header.stream),ie=H.get(X)||0;if(ie===0){const{streamName:oe,streamType:de}=D.header.stream;g.a.debug("RTC client received first message for stream",{streamName:oe,streamType:de})}H.set(X,ie+1)}uploadMetrics(){return Ae(this,void 0,void 0,function*(){const{sessionId:D}=this,H=yield this.connection.peerConnection.getStats(),X={};H.forEach(ce=>X[ce.id]=ce),g.a.debug("rtc-stats",Object.assign(Object.assign({},X),{sessionId:D}));const{localSent:ie,localReceived:oe,remoteSent:de,remoteReceived:ye}=this.counts,be=[...new Set([...ie.keys(),...oe.keys()])].reduce((ce,le)=>{const Re=ie.get(le),Me=oe.get(le),je=de.get(le),Fe=ye.get(le);return Object.assign(Object.assign({},ce),{[`local-${le}-sent`]:Re,[`local-${le}-received`]:Me,[`remote-${le}-sent`]:je,[`remote-${le}-received`]:Fe})},{sessionId:D});g.a.debug("rtc-message-report",Object.assign({deviceId:this.connection.getRemoteDeviceId()},be))})}}function Pe(pe,D,H){return{header:{stream:pe,created:Date.now(),frameId:H||""},payload:D}}function qe(pe){return new Set(["disconnected","failed","closed"]).has(pe.iceConnectionState)}function rt(pe){switch(pe.header.stream.streamType){case"twist":{const{twist:D}=pe.payload;if(!D)throw Error("twist not in payload of RTC message with type twist");return{header:pe.header,payload:{twist:{linear:Object.assign({x:0,y:0,z:0},D.linear),angular:Object.assign({x:0,y:0,z:0},D.angular)}}}}case"pose":{const{pose:D}=pe.payload;if(!D)throw Error("pose not in payload of RTC message with type pose");return{header:pe.header,payload:{pose:{translation:Object.assign({x:0,y:0,z:0},D.translation),rotation:Object.assign({x:0,y:0,z:0,w:0},D.rotation)}}}}case"pose-with-covariance":{const{poseWithCovariance:D}=pe.payload;if(!D)throw Error("poseWithCovariance not in payload of RTC message with type pose-with-covariance");const H=new Array(36).fill(0);return D.covariance.forEach((X,ie)=>{if(ie>=36)throw Error("covariance contains more than 36 elements");H[ie]=X}),{header:pe.header,payload:{poseWithCovariance:{pose:{translation:Object.assign({x:0,y:0,z:0},D.pose.translation),rotation:Object.assign({x:0,y:0,z:0,w:0},D.pose.rotation)},covariance:H}}}}case"point":{const{point:D}=pe.payload;if(!D)throw Error("point not in payload of RTC message with type point");return{header:pe.header,payload:{point:Object.assign({x:0,y:0,z:0},D)}}}default:return pe}}var tt=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class _t{constructor(D,H,X){this.peerConnection=D,this.config=H,this.dataChannelNotifier=X,this.connectTimeoutMs=20*c.a.second,this.iceGatheringTimeoutMs=15*c.a.second,this.pingUpdateTimeoutMs=1*c.a.second,this.pingV2UpdateTimeoutMs=250*c.a.millisecond,this.pingV2MetricsGatherTimeoutMs=1*c.a.second,this.streamsInfoUpdateTimeoutMs=2*c.a.second,this.reassemblyTimeoutMs=500*c.a.millisecond,this.reassemblyTableCleanupMs=1*c.a.second,this.heartbeatTimeoutMs=20*c.a.millisecond,this.streamLatestTimestamp=new Map,this.reassemblyTable=new Map,this.reassemblyTableLastTimestamp=new Map,this.closeCalled=!1,this.gotOffer=!1,this.hasIceCandidate=!1,this.pingV2Map=new Map,this.sendPingV2=()=>{const{latestTryOnceStreamChannel:oe}=this;if(!oe)return;const de=new Date().getTime(),ye=Object(Y.a)();this.sendSystemMessage(oe,{type:"ping-v2",payload:{timestamp:de,id:ye}}),this.pingV2Map.set(ye,{sent:de})},this.gatherPingV2Metrics=()=>{const oe=Se(this.pingV2Map);if(oe){const de=this.getRemoteDeviceId();this.pingInfo=oe,y.aggregate("rtc-ping-average",oe.average,Object.assign({},de?{deviceId:de}:{})),y.aggregate("rtc-ping-loss",oe.loss,Object.assign({},de?{deviceId:de}:{})),y.aggregate("rtc-jitter",oe.jitter,Object.assign({},de?{deviceId:de}:{}))}};const{isOffer:ie}=H.baseConfig;ie?this.initializeChannels(D):D.ondatachannel=oe=>{switch(oe.channel.label){case"stream.latest-ttl":this.latestTtlStreamChannel=oe.channel;break;case"stream.reliable":this.reliableStreamChannel=oe.channel;break;case"stream.latest-reliable":this.latestReliableStreamChannel=oe.channel;break;case"stream.latest-try-once":this.latestTryOnceStreamChannel=oe.channel;break;case"heartbeat":return void(this.heartbeatChannel=oe.channel);default:return void this.dataChannelNotifier(oe.channel)}this.setupChannel(oe.channel)},this.pingUpdateTimeout=setInterval(()=>{const{reliableStreamChannel:oe}=this;oe&&this.sendSystemMessage(oe,{type:"ping"})},this.pingUpdateTimeoutMs),this.pingV2UpdateTimeout=setInterval(this.sendPingV2,this.pingV2UpdateTimeoutMs),this.pingV2MetricsGatherTimeout=setInterval(this.gatherPingV2Metrics,this.pingV2MetricsGatherTimeoutMs),this.streamsInfoUpdateTimeout=setInterval(()=>{const{latestTtlStreamChannel:oe}=this;oe&&this.sendSystemMessage(oe,{type:"streams-info"})},this.streamsInfoUpdateTimeoutMs),this.reassemblyTableCleanupTimeout=setInterval(()=>{const oe=new Date().getTime();this.reassemblyTableLastTimestamp.forEach((de,ye,be)=>{oe>ye+this.reassemblyTimeoutMs&&this.reassemblyTable.delete(de)})},this.reassemblyTableCleanupMs),this.heartbeatTimeout=setInterval(()=>{const{heartbeatChannel:oe}=this;oe&&oe.readyState==="open"&&oe.send(new Uint8Array([1]))},this.heartbeatTimeoutMs)}handleSignal(D){return tt(this,void 0,void 0,function*(){const{peerConnection:H}=this,{track:X}=this.config.baseConfig,ie=(()=>{try{return JSON.parse(D.getPayload())}catch{return}})();if(!ie)return void g.a.error("Received unparseable signal.");g.a.debug("Handling signal",{description:ie});const{sdp:oe,type:de}=ie;if(!oe||!de)return void g.a.warn("Received non-SDP signal");const{signalingState:ye,connectionState:be}=H;if(ye!=="stable"||be!=="connected")if(H.remoteDescription)g.a.warn(`Received SDP after remote description was set: ${oe}`);else{if(de==="offer"){if(ye!=="stable")return void g.a.warn("Received offer SDP when signaling is ongoing.");yield H.setRemoteDescription(ie);const ce=yield H.createAnswer();yield H.setLocalDescription(ce);const le=D.clone();return X==null||X("Answer Received",le),le.setPayload(JSON.stringify(ce)),le.setReceiverId(D.getSenderId()),le.setSenderId(D.getReceiverId()),le}if(de==="answer"){if(ye==="stable")return void g.a.warn("Received answer SDP when signaling hasn't started.");yield H.setRemoteDescription(ie)}}else g.a.warn(`Received SDP when already connected: ${oe}`)})}send(D,H){const X=this.getChannelFromLabel(H.channelLabel);X?this.sendOnChannel(X,D):g.a.warn("Send called with unexpected channel label",{channelLabel:H.channelLabel})}controlRemoteStream(D){this.sendSystemMessage(p(this.reliableStreamChannel),{type:"stream-control",streamControl:D})}isActive(){return new Set(["new","checking","connected","completed"]).has(this.peerConnection.iceConnectionState)||this.isReady()}isReady(){const{reliableStreamChannel:D,latestTtlStreamChannel:H,latestTryOnceStreamChannel:X,latestReliableStreamChannel:ie}=this;return(D==null?void 0:D.readyState)==="open"&&(H==null?void 0:H.readyState)==="open"&&(X==null?void 0:X.readyState)==="open"&&(ie==null?void 0:ie.readyState)==="open"}close(){return tt(this,void 0,void 0,function*(){if(this.closeCalled)return;this.closeCalled=!0,this.sessionMetrics&&(yield this.sessionMetrics.uploadMetrics()),ut(this.pingUpdateTimeout),ut(this.pingV2UpdateTimeout),ut(this.pingV2MetricsGatherTimeout),ut(this.reassemblyTableCleanupTimeout),ut(this.streamsInfoUpdateTimeout),ut(this.heartbeatTimeout);const{peerConnection:D,reliableStreamChannel:H,latestTtlStreamChannel:X,latestTryOnceStreamChannel:ie,latestReliableStreamChannel:oe}=this;D.close(),H==null||H.close(),X==null||X.close(),ie==null||ie.close(),oe==null||oe.close()})}getPing(){return this.pingTimeMs}getPingInfo(){return this.pingInfo}getLastMessageTimestamp(){return this.lastMessageTimestamp}getSessionCreatedTimestamp(){var D;return(D=this.config.remoteConfig)===null||D===void 0?void 0:D.sessionCreatedTimestamp}setSessionCreatedTimestamp(D){this.config.remoteConfig&&(this.config.remoteConfig.sessionCreatedTimestamp=D)}getSessionId(){var D;return(D=this.config.remoteConfig)===null||D===void 0?void 0:D.sessionId}setSessionId(D){this.config.remoteConfig&&(this.config.remoteConfig.sessionId=D,this.sessionMetrics=new Oe(D,this))}getRemotePeerId(){return this.config.baseConfig.remotePeerId}getRemoteDeviceId(){var D;return(D=this.config.baseConfig)===null||D===void 0?void 0:D.remoteDeviceId}setRemoteDeviceId(D){this.config.baseConfig.remoteDeviceId=D}getSessionMetricsMessageCounts(){var D;return(D=this.sessionMetrics)===null||D===void 0?void 0:D.counts}getConnectionStatsInfo(){return tt(this,void 0,void 0,function*(){const{peerConnection:D}=this;if(!D)return;const H=yield D.getStats(null),X=[];H.forEach(be=>{X.push(be)});const ie=X.find(be=>be.type==="transport");if(!ie)return;const oe=X.find(be=>(be.type==="candidate-pair"||be.type==="candidatepair")&&be.id===ie.selectedCandidatePairId);if(!oe)return;const de=X.find(be=>be.id===oe.localCandidateId),ye=X.find(be=>be.id===oe.remoteCandidateId);return de&&ye&&(de.address=de.address||de.ip,ye.address=ye.address||ye.ip,de.address!==void 0&&ye.address!==void 0)?{transport:ie,localCandidate:de,remoteCandidate:ye}:void 0})}initializeChannels(D){this.heartbeatChannel=D.createDataChannel("heartbeat",se),this.heartbeatChannel.binaryType="arraybuffer",this.latestTtlStreamChannel=D.createDataChannel("stream.latest-ttl",B),this.latestTtlStreamChannel.binaryType="arraybuffer",this.reliableStreamChannel=D.createDataChannel("stream.reliable",J),this.reliableStreamChannel.binaryType="arraybuffer",this.latestReliableStreamChannel=D.createDataChannel("stream.latest-reliable",K),this.latestReliableStreamChannel.binaryType="arraybuffer",this.latestTryOnceStreamChannel=D.createDataChannel("stream.latest-try-once",re),this.latestTryOnceStreamChannel.binaryType="arraybuffer",this.setupChannel(this.latestTtlStreamChannel),this.setupChannel(this.reliableStreamChannel),this.setupChannel(this.latestReliableStreamChannel),this.setupChannel(this.latestTryOnceStreamChannel)}getOffer(){var D,H,X;return tt(this,void 0,void 0,function*(){const{gotOffer:ie}=this,{peerConnection:oe,config:de}=this;if(this.config.baseConfig.isLan)throw new Error('"getOffer" method can only be called with internet connections. LAN connections should call the "getLanOffer" method.');const ye=(D=this.config.remoteConfig)===null||D===void 0?void 0:D.sessionId;if(ie)return void g.a.debug("Failed to generate offer because gotOffer was already called.");if(this.gotOffer=!0,qe(this.peerConnection))return void g.a.debug("Failed to generate offer because the peer connection was inactive.");const be=de.baseConfig.track;oe.onicecandidate=()=>{this.hasIceCandidate=!0},oe.oniceconnectionstatechange=()=>tt(this,void 0,void 0,function*(){const je=oe.iceConnectionState;if(je==="connected"||je==="completed"){const Fe=yield this.getConnectionStatsInfo(),Xe=Fe?function($e){const Ye=$e.localCandidate.candidateType,xe=$e.remoteCandidate.candidateType;return Ye==="host"&&xe==="host"?"local":Ye==="relay"||xe==="relay"?"TURN":"STUN"}(Fe):void 0;g.a.info(`ICE connection state changed to ${je}`,{sessionId:ye,connectionStatsInfo:Fe,iceMode:Xe}),be==null||be("ICE connection state change",{iceConnectionState:je,sessionId:ye,connectionStatsInfo:Fe,iceMode:Xe})}}),yield oe.setLocalDescription(yield oe.createOffer());const ce=new Date().getTime();for(;;){const je=new Date().getTime()-ce;if(je>this.connectTimeoutMs)return void g.a.debug("Failed to generate offer because ICE gathering timed out.");if(je>this.iceGatheringTimeoutMs&&this.hasIceCandidate){g.a.debug("ICE gathering partially completed; proceeding",{iceTransportPolicy:oe.getConfiguration().iceTransportPolicy,waitTime:je}),be==null||be("ICE gathering partially completed",{sessionId:ye,iceTransportPolicy:oe.getConfiguration().iceTransportPolicy,waitTime:je});break}if(oe.iceGatheringState==="complete"){g.a.debug("ICE gathering complete",{iceTransportPolicy:oe.getConfiguration().iceTransportPolicy,waitTime:je}),be==null||be("ICE gathering completed",{sessionId:ye,iceTransportPolicy:oe.getConfiguration().iceTransportPolicy,waitTime:je});break}yield Object(u.a)(.1*c.a.second)}const le=(H=this.peerConnection.getConfiguration().iceServers)!==null&&H!==void 0?H:[];for(const je of le)"credentialType"in je&&(je.credentialType=void 0);const Re=JSON.stringify(le),Me=new ee.Signal;return Me.setPayload(JSON.stringify(oe.localDescription)),Me.setSenderId(this.config.baseConfig.localPeerId),Me.setReceiverId(this.config.baseConfig.remotePeerId),Me.setIceServers(Re),Me.setIceTransportPolicy((X=this.peerConnection.getConfiguration().iceTransportPolicy)!==null&&X!==void 0?X:"all"),this.config.baseConfig.sessionType!==void 0?Me.setSessionType(this.config.baseConfig.sessionType):Me.setSessionType(ee.SessionType.TELEOP),g.a.debug("Sending offer signal with description",{description:Me.getPayload()}),Me})}getLanOffer(){return tt(this,void 0,void 0,function*(){const{peerConnection:D,gotOffer:H}=this;if(!this.config.baseConfig.isLan)throw new Error('"getLanOffer" method can only be used with LAN connections. Internet connections should call the "getOffer" method.');if(H)return void g.a.debug("Failed to generate offer because gotOffer was already called.");if(this.gotOffer=!0,qe(this.peerConnection))return void g.a.debug("Failed to generate offer because the peer connection was inactive.");yield D.setLocalDescription(yield D.createOffer());const X=new Date().getTime();for(;;){if(new Date().getTime()-X>this.iceGatheringTimeoutMs)return void g.a.debug("Failed to generate offer because ICE gathering timed out.");if(D.iceGatheringState==="complete")break;yield Object(u.a)(.1*c.a.second)}const ie=D.localDescription;if(ie)return g.a.debug("Sending LAN offer signal with description",{description:ie}),ie;g.a.error("Failed to generate LAN offer description")})}handleLanAnswer(D){return tt(this,void 0,void 0,function*(){const{peerConnection:H}=this;if(!this.config.baseConfig.isLan)throw new Error('"handleLanAnswer" method can only be used with LAN connections. Internet connections should call the "handleSignal" method.');yield H.setRemoteDescription(D)})}getChannelFromLabel(D){switch(D){case"stream.latest-ttl":return this.latestTtlStreamChannel;case"stream.reliable":return this.reliableStreamChannel;case"stream.latest-reliable":return this.latestReliableStreamChannel;case"stream.latest-try-once":return this.latestTryOnceStreamChannel}}sendOnChannel(D,H){let X;try{X=Object(T.encode)(JSON.stringify(H))}catch(ie){return void g.a.warn("Failed to encode RTC message",{error:ie})}try{D.send(X),this.sessionMetrics&&this.sessionMetrics.incrementLocalSent(H)}catch(ie){g.a.warn("Failed to send message to channel",{error:ie,channel:D.label})}}channelNotRecognized(D){return D!==this.latestTtlStreamChannel&&D!==this.latestReliableStreamChannel&&D!==this.latestTryOnceStreamChannel&&D!==this.reliableStreamChannel}setupChannel(D){D.onmessage=H=>{if(this.channelNotRecognized(D))return void g.a.warn("Received message on unrecognized data channel.");let X;try{X=JSON.parse(Object(T.decode)(H.data))}catch(ie){return void g.a.warn("Received unparseable message on RTC stream data channel",{error:ie,channel:D.label})}X.communicationType==="message-chunk"?this.receiveChannelMessageChunk(D,X):this.receiveChannelMessage(D,X)},D.onerror=H=>{g.a.warn(`Channel error: ${H.error}`,{error:H.error,sessionId:this.getSessionId(),channelLabel:D.label})},D.onopen=()=>{g.a.debug("Channel opened",{sessionId:this.getSessionId(),channelLabel:D.label})},D.onclose=()=>{const H={bufferedAmount:D.bufferedAmount,sessionId:this.getSessionId(),channelLabel:D.label};this.closeCalled===!1?g.a.debug("Unexpected channel closed",H):g.a.debug("Channel closed",H)}}receiveChannelMessage(D,H){const{config:X}=this,{remotePeerId:ie}=this.config.baseConfig;this.lastMessageTimestamp=new Date().getTime(),H=rt(H),this.sessionMetrics&&this.sessionMetrics.incrementLocalReceived(H),this.handleSystemMessage(D,H)||(D===this.latestTryOnceStreamChannel||D===this.latestTtlStreamChannel||D===this.latestReliableStreamChannel)&&!this.isLatestMessage(H)||X.baseConfig.receive(ie,H)}receiveChannelMessageChunk(D,H){const X=this.reassemblyTable.get(H.id)||[];if(X.push(H),X.length===H.total){const ie=function(oe){const de=oe.sort((ye,be)=>ye.seq<be.seq?-1:1).map(ye=>ye.part).reduce((ye,be)=>ye+be);try{return JSON.parse(de)}catch{return void g.a.warn("Could not reassemble RTC message chunks")}}(X);return ie&&this.receiveChannelMessage(D,ie),void this.reassemblyTable.delete(H.id)}this.reassemblyTable.set(H.id,X),this.reassemblyTableLastTimestamp.set(H.id,new Date().getTime())}handleSystemMessage(D,H){var X,ie;const{config:oe}=this,{baseConfig:de}=oe,{remotePeerId:ye,remoteDeviceId:be}=de;switch(H.header.stream.streamType){case"ping":return this.sendSystemMessage(D,{type:"pong",timestamp:p(H.payload.ping)}),!0;case"pong":{const ce=new Date().getTime()-p(H.payload.pong);return this.pingTimeMs=ce,y.aggregate("rtc-ping-time",ce,Object.assign({},be?{deviceId:be}:{})),!0}case"ping-v2":return this.sendPingV2(),!0;case"pong-v2":{const ce=p(H.payload.pongV2),le=this.pingV2Map.get(ce.id);return(le==null?void 0:le.sent)!==ce.timestamp&&g.a.warn("Pong timestamp doesn't match stored value",{currentEntry:le,pong:ce}),this.pingV2Map.set(ce.id,{sent:ce.timestamp,received:new Date().getTime()}),!0}case"streams-info":{const{sessionMetrics:ce}=this,le=(X=H.payload.streamsInfo)===null||X===void 0?void 0:X.timestamp;return!!le&&(ce==null||ce.updateRemoteMessagesCounts(H),(ie=de.onStreamsInfoUpdate)===null||ie===void 0||ie.call(de,ye,le),!0)}case"stream-control":return!0;default:return!1}}sendSystemMessage(D,H){var X;const{localUserId:ie,localPeerId:oe}=this.config.baseConfig;if(D.readyState!=="open")return;const de={entityId:ie??oe,streamName:`$.${H.type}`,streamType:H.type};let ye;switch(H.type){case"ping":ye={ping:new Date().getTime()};break;case"pong":ye={pong:H.timestamp};break;case"ping-v2":ye={pingV2:H.payload};break;case"pong-v2":ye={pongV2:H.payload};break;case"stream-control":ye={streamControl:H.streamControl};break;case"streams-info":ye={streamsInfo:(X=this.sessionMetrics)===null||X===void 0?void 0:X.getLocalStreamsInfo(new Date().getTime())}}this.sendOnChannel(D,Pe(de,ye))}isLatestMessage(D){const H=Ce(D.header.stream),X=(this.streamLatestTimestamp.get(H)||0)<=D.header.created;return X&&this.streamLatestTimestamp.set(H,D.header.created),X}}function ut(pe){pe&&clearInterval(pe)}function vt(){g.a.debug("forceGarbageCollection() triggered"),queueMicrotask(()=>{let pe=document.createElement("img");pe.src=window.URL.createObjectURL(new Blob([new ArrayBuffer(5e7)])),pe.onerror=function(){window.URL.revokeObjectURL(this.src),pe=null}})}function It(pe){try{return pe instanceof Error?`${pe.name}: ${pe.message}`:typeof pe=="object"?JSON.stringify(pe):String(pe)}catch{return"Unknown error"}}function Tt(pe){var D,H;return{userId:(D=pe.getUserId())===null||D===void 0?void 0:D.getValue(),deviceId:(H=pe.getDeviceId())===null||H===void 0?void 0:H.getValue(),organizationId:pe.getOrganizationId(),id:pe.getPeerId(),capabilities:[],capabilitySet:{}}}var Be=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class jt{constructor(D){this.config=D,this.grpcCallDeadline=5*c.a.second,this.refreshIntervalDelayMs=2*c.a.second,this.iceServersTtl=30*c.a.minute,this.connections=[],this.localConnections=[],this.isConnectionInitiator=new Map,this.isOutgoingConnection=new Map,this.peerDataChannelListeners=[],this.rtcInstancesConstructed=0;const{refreshIntervalDelayMs:H}=this;this.refreshInterval=d({func:()=>Be(this,void 0,void 0,function*(){try{yield this.update()}catch(X){g.a.warn("RTC refresh failed",{error:X})}}),delay:H,immediate:!0})}send(D,H,X){const ie=this.getActiveConnection(D);ie?ie.isReady()?ie.send(H,X):g.a.warn("Send called with unready connection."):g.a.warn("Send called with no connection.")}controlRemoteStream(D,H){const X=this.getActiveConnection(D);X?X.isReady()?X.controlRemoteStream(H):g.a.warn("controlRemoteStream called with unready connection."):g.a.warn("controlRemoteStream called with no connection.")}getLocalPeer(){return Be(this,void 0,void 0,function*(){for(;!this.localPeer;)yield Object(u.a)(.1*c.a.second);return Tt(this.localPeer)})}connect(D,H){var X,ie,oe;return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode===!0)throw new Error("connect method called in local only mode.");const{track:de,signalingClient:ye}=this.config,{localPeer:be,receiveSignalStream:ce,iceServers:le}=this;if(!be||!ce||!le)return void g.a.warn("Connect called prior to local peer, receiveSignalStream, and ICE servers ready");if(this.getActiveConnection(D))return void g.a.warn("Connect called for peer with existing connection.");if(this.isOutgoingConnection.get(D))return void g.a.warn("Connect called for peer with an existing outgoing connection offer.");this.isOutgoingConnection.set(D,!0);const Re=function(xe,ke,Ve){const{rtcIceTransportPolicies:Ze,rtcIceServerProtocol:Je,useAllServers:Qe}=ke||{},lt=xe.map(st=>Object.assign(Object.assign({},st),{urls:st.urls.filter(gt=>{const et=(Ze===void 0||Ze.some(Nt=>V(gt,Nt)))&&(Je===void 0||Q(gt,Je));return et||g.a.debug(`Ignoring ICE server: ${gt}`,{organizationId:Ve}),et})})).filter(({urls:st})=>st.filter(gt=>gt).length>0);return Qe?lt:[U(lt,"stun"),U(lt,"turn")].filter(st=>st!==void 0).map(st=>p(st))}(le,H);g.a.debug("Received ICE servers:",le),g.a.debug("Using ICE servers:",Re);const Me=new _t(yield this.createRTCPeerConnection(Re),{baseConfig:{isOffer:!0,isLan:!1,receive:(xe,ke)=>this.config.receive(xe,ke),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(xe,ke)=>{var Ve,Ze;return(Ze=(Ve=this.config).onStreamsInfoUpdate)===null||Ze===void 0?void 0:Ze.call(Ve,xe,ke)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localUserId:(X=be.getUserId())===null||X===void 0?void 0:X.getValue(),localPeerId:be.getPeerId(),remotePeerId:D,sessionType:this.config.sessionType},remoteConfig:{}},xe=>this.onCustomDataChannel(D,xe)),je=yield Me.getOffer();if(!je)return g.a.error("Failed to generate offer."),void this.isOutgoingConnection.delete(D);g.a.debug("Sending offer."),de==null||de("Sending offer",je);const Fe=new ee.SendSignalRequest;Fe.setSignal(je);const Xe=yield(()=>Be(this,void 0,void 0,function*(){try{return yield S.withDeadline(ye.sendSignal(Fe,yield this.getMetadata({})),this.grpcCallDeadline)}catch(xe){g.a.warn("Error when sending signal",{error:xe})}}))();if(!this.isOutgoingConnection.get(D))return void g.a.debug("No offer set after receiving offer signal response.");g.a.debug("Offer sent.");const $e=(ie=Xe==null?void 0:Xe.getSessionId())===null||ie===void 0?void 0:ie.getValue(),Ye=(oe=Xe==null?void 0:Xe.getSessionCreatedTimestamp())===null||oe===void 0?void 0:oe.getValue();return $e&&Ye?(Me.setSessionId($e),Me.setSessionCreatedTimestamp(Ye),this.isOutgoingConnection.delete(D),this.connections.push(Me),this.isConnectionInitiator.set(Me,!0),this.setupHandlers(Me),$e):(g.a.warn("No session ID or no session created timestamp on send signal response."),void this.isOutgoingConnection.delete(D))})}connectLan(D){var H,X;return Be(this,void 0,void 0,function*(){const ie=new P(D),oe=new _t(yield this.createRTCPeerConnection([]),{baseConfig:{isOffer:!0,isLan:!0,receive:(ce,le)=>this.config.receive(ce,le),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(ce,le)=>{var Re,Me;return(Me=(Re=this.config).onStreamsInfoUpdate)===null||Me===void 0?void 0:Me.call(Re,ce,le)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localUserId:(X=(H=this.localPeer)===null||H===void 0?void 0:H.getUserId())===null||X===void 0?void 0:X.getValue(),localPeerId:"lan_client",remotePeerId:D}},ce=>this.onCustomDataChannel(D,ce)),de=yield oe.getLanOffer();if(!de)return g.a.warn("Could not generate LAN offer"),!1;const ye=yield ie.postLanRtcOffer({offer:JSON.stringify(de)}),be=new RTCSessionDescription(JSON.parse(ye.answer));return yield oe.handleLanAnswer(be),this.localConnections.push(oe),this.isConnectionInitiator.set(oe,!0),Object(Y.a)()})}getConnections(){return[...this.connections,...this.localConnections]}createCustomDataChannel(D,H,X,ie,oe){const de=this.getActiveConnection(D);if(de&&this.isConnectionInitiator.has(de)){const be=de.peerConnection.createDataChannel("custom."+H,X);return ie&&(be.binaryType="arraybuffer"),oe(D,be),()=>{}}const ye=(be,ce)=>{D===be&&ce.label==="custom."+H&&oe(D,ce)};return this.peerDataChannelListeners.push(ye),()=>{this.peerDataChannelListeners=this.peerDataChannelListeners.filter(be=>be!==ye)}}onCustomDataChannel(D,H){this.peerDataChannelListeners.forEach(X=>X(D,H))}getConnectionStatus(D){if(this.isOutgoingConnection.get(D))return"connecting";const H=this.getActiveConnection(D);return H?H.isReady()?"connected":"connecting":"disconnected"}getConnectionStatsInfo(D){return Be(this,void 0,void 0,function*(){const H=this.getActiveConnection(D);if(H)return yield H.getConnectionStatsInfo()})}disconnect(D){return Be(this,void 0,void 0,function*(){const H=this.getActiveConnection(D);H&&(yield H.close())})}getPeers(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getPeers method cannot be used in local-only mode.");const{signalingClient:D}=this.config,H=yield(()=>Be(this,void 0,void 0,function*(){try{return yield S.withDeadline(D.getPeers(new ee.GetPeersRequest,yield this.getMetadata({})),this.grpcCallDeadline)}catch(oe){g.a.warn("Error when getting peers",{error:oe})}}))();if(!H)return[];const X=H.getPeersList();if(!X)return[];const ie=oe=>{var de,ye;return(ye=(de=oe.getPeerCreatedTimestamp())===null||de===void 0?void 0:de.getValue())!==null&&ye!==void 0?ye:0};return X.sort((oe,de)=>ie(de)-ie(oe)).map(oe=>Tt(oe))})}getSessions(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getPeers method cannot be used in local-only mode.");const{signalingClient:D}=this.config,H=yield(()=>Be(this,void 0,void 0,function*(){try{return yield S.withDeadline(D.getPeers(new ee.GetPeersRequest,yield this.getMetadata({})),this.grpcCallDeadline)}catch(oe){g.a.warn("Error when getting peers",{error:oe})}}))();if(!H)return{};const X=H.getPeersList(),ie={};for(const oe of X)ie[oe.getPeerId()]=oe.getSessionIdsList();return ie})}getPing(D){const H=this.getActiveConnection(D);if(H)return H.getPing();g.a.warn("Attempted to get ping time from inactive peer.")}getPingInfo(D){const H=this.getActiveConnection(D);if(H)return H.getPingInfo();g.a.warn("Attempted to get ping time from inactive peer.")}getLastMessageTimestamp(D){const H=this.getActiveConnection(D);if(H)return H.getLastMessageTimestamp();g.a.warn("Attempted to get last message time from inactive peer.")}getSessionMetricsMessageCounts(D){const H=this.getActiveConnection(D);if(H)return H.getSessionMetricsMessageCounts();g.a.warn("Attempted to get session metrics counts from inactive peer.")}isReady(){if(this.config.lanOnlyMode)return!0;const{localPeer:D,receiveSignalStream:H,iceServers:X}=this;return!!(D&&H&&X)}shutdown(){return Be(this,void 0,void 0,function*(){g.a.info("Shutdown called on RTC client"),yield this.refreshInterval.stop(),this.receiveSignalStream&&this.receiveSignalStream.cancel();const D=this.connections;this.connections=[],yield this.closeConnections(D);const{localPeer:H}=this;if(!H||this.config.lanOnlyMode)return;const{signalingClient:X}=this.config;yield(()=>Be(this,void 0,void 0,function*(){try{const ie=new ee.DeletePeerRequest;ie.setPeerId(H.getPeerId()),yield S.withDeadline(X.deletePeer(ie,yield this.getMetadata({})),this.grpcCallDeadline)}catch(ie){return void g.a.warn("Error deleting local peer",{error:ie})}}))()})}createPeer(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("createPeer method cannot be used in local-only mode.");const{signalingClient:D}=this.config,H=yield(()=>Be(this,void 0,void 0,function*(){try{return yield S.withDeadline(D.createPeer(new ee.CreatePeerRequest,yield this.getMetadata({})),this.grpcCallDeadline)}catch(ie){const oe=ie;g.a.debug("createPeer failed",{error:oe});const de=It(oe);throw new Error(`Was not able to create peer: ${de}`)}}))(),X=H==null?void 0:H.getPeer();if(!X)throw new Error("Response did not provide peer.");return this.localPeer=X})}createReceiveSignalStream(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("createReceiveSignalStream method cannot be used in local-only mode.");const{signalingClient:D}=this.config,{localPeer:H,iceServers:X}=this;if(!H||!X)return;const{receiveSignalStream:ie}=this;ie&&ie.cancel();const oe=new ee.ReceiveSignalStreamRequest;oe.setPeerId(H.getPeerId());const de=yield(()=>Be(this,void 0,void 0,function*(){try{return D.receiveSignalStream(oe,yield this.getMetadata({hasDeadline:!1}))}catch(ye){g.a.debug("createReceiveSignalStream failed",{error:ye});const be=It(ye);throw new Error(`Unable to create receive signal stream: ${be}`)}}))();if(!de)throw new Error("Response did not provide stream.");return de.on("data",ye=>Be(this,void 0,void 0,function*(){var be,ce,le,Re;const Me=ye.getSignal(),je=(be=Me==null?void 0:Me.getSessionId())===null||be===void 0?void 0:be.getValue(),Fe=Me==null?void 0:Me.getSenderId(),Xe=Me==null?void 0:Me.getReceiverId(),$e=(ce=Me==null?void 0:Me.getSessionCreatedTimestamp())===null||ce===void 0?void 0:ce.getValue();if(!(Me&&je&&Fe&&Xe&&$e))return void g.a.warn("Received signal with missing information.");const Ye=this.getActiveConnection(Fe);if(Ye)if(Ye.getSessionId()!==je){if(g.a.debug("Received signal: different session for a peer we're already connected to."),(Ye.getSessionCreatedTimestamp()||0)>$e)return;const xe=new _t(yield this.createRTCPeerConnection(X),{baseConfig:{isOffer:!1,isLan:!1,receive:(ke,Ve)=>this.config.receive(ke,Ve),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(ke,Ve)=>{var Ze,Je;return(Je=(Ze=this.config).onStreamsInfoUpdate)===null||Je===void 0?void 0:Je.call(Ze,ke,Ve)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localPeerId:H.getPeerId(),localUserId:(Re=H.getUserId())===null||Re===void 0?void 0:Re.getValue(),remotePeerId:Fe},remoteConfig:{sessionId:je,sessionCreatedTimestamp:$e}},ke=>this.onCustomDataChannel(Fe,ke));yield xe.handleSignal(Me),this.connections.push(xe)}else g.a.debug("Received signal: for an existing connection."),yield Ye.handleSignal(Me);else{g.a.debug("Received signal: new connection.");const xe=new _t(yield this.createRTCPeerConnection(X),{baseConfig:{isOffer:!1,isLan:!1,receive:(ke,Ve)=>this.config.receive(ke,Ve),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(ke,Ve)=>{var Ze,Je;return(Je=(Ze=this.config).onStreamsInfoUpdate)===null||Je===void 0?void 0:Je.call(Ze,ke,Ve)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localPeerId:H.getPeerId(),localUserId:(le=H.getUserId())===null||le===void 0?void 0:le.getValue(),remotePeerId:Fe},remoteConfig:{sessionId:je,sessionCreatedTimestamp:$e}},ke=>this.onCustomDataChannel(Fe,ke));yield xe.handleSignal(Me),this.connections.push(xe)}})),de.on("end",()=>{de.cancel(),this.receiveSignalStream=void 0}),de.on("error",ye=>{switch(ye.code){case ne.StatusCode.CANCELLED:case ne.StatusCode.UNAVAILABLE:case ne.StatusCode.UNKNOWN:g.a.debug("Receive signal stream error",{error:ye});break;case ne.StatusCode.UNAUTHENTICATED:g.a.warn("Receive signal stream error",{error:ye});break;default:g.a.error("Receive signal stream error",{error:ye})}de.cancel(),this.receiveSignalStream=void 0}),this.receiveSignalStream=de})}createRTCPeerConnection(D){var H;return Be(this,void 0,void 0,function*(){const X=(H=this.config.alternateRTCPeerConnection)!==null&&H!==void 0?H:window.RTCPeerConnection;if(!X)throw function(){const{userAgent:ie}=navigator;return ie.includes("Firefox/")?"Firefox":ie.includes("Edg/")?"Edge":ie.includes("Chrome/")?"Chrome":ie.includes("Safari/")?"Safari":ie.includes("MSIE/")||ie.includes("Trident/")?"IE":"Other"}()!=="Chrome"?new Error("WebRTC is not enabled. Please try again with the latest version of Google Chrome."):new Error("WebRTC is not enabled. Please ensure WebRTC is not disabled by ad blocking software.");this.rtcInstancesConstructed++,this.rtcInstancesConstructed%20||vt();try{return new X({iceServers:D})}catch(ie){throw g.a.debug(`Failed to create RTCPeerConnection: ${this.rtcInstancesConstructed} total allocated`),ie}})}closeConnections(D){return Be(this,void 0,void 0,function*(){const H=yield O(D.map(X=>Be(this,void 0,void 0,function*(){yield X.close()})));for(const X of H)g.a.warn("Request to close session failed",{error:X})})}getActiveConnection(D){return this.getConnections().find(H=>H.getRemotePeerId()===D&&H.isActive())}update(){var D;return Be(this,void 0,void 0,function*(){if(this.localConnections=this.localConnections.filter(ye=>ye.isActive()),this.config.lanOnlyMode)return;const{signalingClient:H}=this.config;if(!this.localPeer||!this.receiveSignalStream||!this.iceServers){const ye=[];return this.localPeer||ye.push(this.createPeer()),this.iceServers||ye.push(this.updateIceServers()),yield Promise.all(ye),void(this.receiveSignalStream||(yield this.createReceiveSignalStream()))}yield this.closeConnections(this.connections.filter(ye=>!ye.isActive())),this.connections=this.connections.filter(ye=>ye.isActive());const{localPeer:X}=this,ie=this.connections.filter(ye=>ye.getSessionId).map(ye=>p(ye.getSessionId()));X.setSessionIdsList(ie);const oe=new ee.RefreshPeerRequest;oe.setPeer(X);try{yield S.withDeadline(H.refreshPeer(oe,yield this.getMetadata({})),this.grpcCallDeadline)}catch(ye){ye.code===ne.StatusCode.NOT_FOUND?(g.a.warn("Peer expired, creating new peer",{peerId:X.getPeerId()}),yield this.reset()):g.a.warn("Error calling RefreshPeer",{error:ye})}const de=yield this.getPeers();for(const ye of this.connections)ye.setRemoteDeviceId((D=de.find(be=>be.id===ye.getRemotePeerId()))===null||D===void 0?void 0:D.deviceId)})}reset(){return Be(this,void 0,void 0,function*(){yield this.closeConnections(this.connections),this.connections=[],this.isOutgoingConnection=new Map,yield this.createPeer(),yield this.createReceiveSignalStream()})}updateIceServers(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)return;const{iceServersLastUpdate:D,iceServersTtl:H}=this,X=new Date().getTime();if(!D||X-D>H)try{const ie=(yield S.withDeadline(this.config.signalingClient.getIceServers(new ee.GetIceServersRequest,yield this.getMetadata({})),this.grpcCallDeadline)).getIceServers();this.iceServers=JSON.parse(ie),this.iceServersLastUpdate=X}catch(ie){g.a.warn("Error in updateIceServers",{error:ie})}})}setupHandlers(D){const{peerConnection:H}=D,X=D.getSessionCreatedTimestamp();H.onconnectionstatechange=()=>Be(this,void 0,void 0,function*(){const ie=H.connectionState;if(!X)return;const oe=D.getRemoteDeviceId();switch(ie){case"connected":y.aggregate("rtc-connect-time",new Date().getTime()-X,Object.assign({},oe?{deviceId:oe}:{}));break;case"failed":y.increment("rtc-connect-failed",Object.assign({},oe?{deviceId:oe}:{}))}})}getMetadata(D){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getMetadata method cannot be called in local-only mode");const{getToken:H}=this.config,{grpcCallDeadline:X}=this,{hasDeadline:ie}=D,oe=ie===!1?void 0:new Date().getTime()+X;try{return{authorization:yield H(),deadline:oe}}catch(de){throw g.a.error("getToken() failed",{error:de}),new Error("Cannot get authorization token")}})}}var it=n(10),at=n(11),xt=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class mt{constructor(D,H){this.sessionId=D,this.connection=H,this.sentMessagesCounts=new Map,this.receivedMessagesCounts=new Map,this.sessionId=D,this.connection=H}incrementMessageSent(D){const H=Ce(D.header.stream);this.sentMessagesCounts.set(H,(this.sentMessagesCounts.get(H)||0)+1)}incrementMessageReceived(D){const H=Ce(D.header.stream);this.receivedMessagesCounts.set(H,(this.receivedMessagesCounts.get(H)||0)+1)}uploadMetrics(){return xt(this,void 0,void 0,function*(){const{sessionId:D}=this,H=yield this.connection.peerConnection.getStats(),X={};H.forEach(oe=>X[oe.id]=oe),g.a.debug("rtc-stats",Object.assign(Object.assign({},X),{sessionId:D}));const ie=[...new Set(Array.from(this.sentMessagesCounts.keys()).concat(Array.from(this.receivedMessagesCounts.keys())))].reduce((oe,de)=>{const ye=this.sentMessagesCounts.get(de),be=this.receivedMessagesCounts.get(de);return Object.assign(Object.assign({},oe),{[`${de}-sent`]:ye,[`${de}-received`]:be})},{sessionId:D});g.a.debug("rtc-message-report",ie)})}}function Mt(pe,D){return Ce(pe)===Ce(D)}var ct=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class At{constructor(D,H){this.peerConnection=D,this.config=H,this.connectTimeoutMs=10*c.a.second,this.gatherIceTimeoutMs=5*c.a.second,this.pingUpdateTimeoutMs=2*c.a.second,this.streamLatestTimestamp=new Map,this.closeCalled=!1,this.connectCalled=!1,this.sentOffer=!1,this.receivedIceCandidate=!1;const{isOffer:X}=H;X?this.initializeChannels(D):D.ondatachannel=ie=>{switch(ie.channel.label){case"stream.latest-ttl":this.latestTtlStreamChannel=ie.channel;break;case"stream.reliable":this.reliableStreamChannel=ie.channel;break;case"stream.latest-reliable":this.latestReliableStreamChannel=ie.channel;break;case"stream.latest-try-once":this.latestTryOnceStreamChannel=ie.channel}this.setupChannel(ie.channel)},this.sessionMetrics=new mt(this.getSessionId(),this)}connect(){return ct(this,void 0,void 0,function*(){if(this.connectCalled)return;this.connectCalled=!0,this.pingUpdateTimeout=setInterval(()=>{const{reliableStreamChannel:ie}=this;ie&&this.sendSystemMessage(ie,{type:"ping"})},this.pingUpdateTimeoutMs),this.connectTimeout=setTimeout(()=>ct(this,void 0,void 0,function*(){this.isReady()||(g.a.warn("RTC connect timed out, closing connection"),yield this.close())}),this.connectTimeoutMs);const{peerConnection:D,config:{isOffer:H,sessionId:X}}=this;if(H){const ie=yield D.createOffer();yield D.setLocalDescription(ie)}H&&(this.gatherIceTimeout=setTimeout(()=>ct(this,void 0,void 0,function*(){this.sentOffer||(g.a.warn("ICE gathering timed out"),this.receivedIceCandidate?(g.a.warn("Attempting to connect with partial ICE candidate pool"),yield this.sendOffer()):yield this.close())}),this.gatherIceTimeoutMs),D.onicecandidate=ie=>ct(this,void 0,void 0,function*(){ie.candidate?this.receivedIceCandidate=!0:yield this.sendOffer()}),D.onicegatheringstatechange=()=>ct(this,void 0,void 0,function*(){D.iceGatheringState==="complete"&&(yield this.sendOffer())}),D.onnegotiationneeded=()=>{g.a.debug("Negotiation needed",{sessionId:X})})})}handleSignal(D){return ct(this,void 0,void 0,function*(){const{peerConnection:H,config:{sessionId:X,sendSignal:ie}}=this,{description:oe}=JSON.parse(D.payload);if(g.a.debug("Handling signal",{sessionId:X,description:JSON.stringify(oe)}),oe)if(H.signalingState!=="stable"||H.connectionState!=="connected")if(H.remoteDescription)g.a.warn(`Received SDP signal during negotiation when remote description is already set: ${JSON.stringify(D)}`);else if(oe.type==="offer"){yield H.setRemoteDescription(oe);const de=yield H.createAnswer();yield H.setLocalDescription(de),yield ie({payload:JSON.stringify({description:de})})}else oe.type==="answer"&&(yield H.setRemoteDescription(oe));else g.a.warn(`Received SDP signal when signaling is stable and connected: ${JSON.stringify(D)}`);else g.a.warn(`Received non-SDP signal: ${JSON.stringify(D)}`)})}send(D,H){const X=this.getChannelFromLabel(H.channelLabel);X?this.sendOnChannel(X,D):g.a.warn("Send called with unexpected channel label",{channelLabel:H.channelLabel})}controlRemoteStream(D){this.sendSystemMessage(p(this.reliableStreamChannel),{type:"stream-control",streamControl:D})}isActive(){return new Set(["new","connecting","connected"]).has(this.peerConnection.connectionState)}isReady(){const{peerConnection:D,latestTtlStreamChannel:H,reliableStreamChannel:X,latestTryOnceStreamChannel:ie}=this;return!!(X&&H&&ie)&&D.connectionState==="connected"&&X.readyState==="open"&&H.readyState==="open"&&ie.readyState==="open"}isClosed(){const{peerConnection:D,reliableStreamChannel:H,latestTryOnceStreamChannel:X,latestTtlStreamChannel:ie}=this;return!(D.connectionState!=="closed"||H!==void 0&&H.readyState!=="closed"||X!==void 0&&X.readyState!=="closed"||ie!==void 0&&ie.readyState!=="closed")}needsClosing(){const{peerConnection:D,latestTtlStreamChannel:H,reliableStreamChannel:X,latestTryOnceStreamChannel:ie}=this;if(this.isClosed())return!1;const oe=new Set(["closing","closed"]),de=ye=>ye&&oe.has(ye.readyState);return qe(D)||de(H)||de(X)||de(ie)}close(){return ct(this,void 0,void 0,function*(){this.closeCalled||(this.closeCalled=!0,yield this.sessionMetrics.uploadMetrics(),this.pingUpdateTimeout&&clearInterval(this.pingUpdateTimeout),this.connectTimeout&&clearTimeout(this.connectTimeout),this.gatherIceTimeout&&clearTimeout(this.gatherIceTimeout),this.peerConnection.close())})}getPing(){return this.pingTimeMs}getLastMessageTimestamp(){return this.lastMessageTimestamp}getSessionId(){return this.config.sessionId}getRemotePeer(){return this.config.remotePeer}initializeChannels(D){this.latestTtlStreamChannel=D.createDataChannel("stream.latest-ttl",B),this.reliableStreamChannel=D.createDataChannel("stream.reliable",J),this.latestReliableStreamChannel=D.createDataChannel("stream.latest-reliable",K),this.latestTryOnceStreamChannel=D.createDataChannel("stream.latest-try-once",re),this.setupChannel(this.latestTtlStreamChannel),this.setupChannel(this.reliableStreamChannel),this.setupChannel(this.latestReliableStreamChannel),this.setupChannel(this.latestTryOnceStreamChannel)}sendOffer(){return ct(this,void 0,void 0,function*(){if(this.sentOffer||(this.sentOffer=!0,qe(this.peerConnection)))return;const{peerConnection:D,config:{sendSignal:H}}=this,X=yield D.createOffer();yield D.setLocalDescription(X);const ie={payload:JSON.stringify({description:X})};yield H(ie)})}getChannelFromLabel(D){switch(D){case"stream.latest-ttl":return this.latestTtlStreamChannel;case"stream.reliable":return this.reliableStreamChannel;case"stream.latest-reliable":return this.latestReliableStreamChannel;case"stream.latest-try-once":return this.latestTryOnceStreamChannel}}sendOnChannel(D,H){let X;try{X=Object(T.encode)(JSON.stringify(H))}catch(ie){return void g.a.warn("Failed to encode RTC message",{error:ie})}try{D.send(X),this.sessionMetrics.incrementMessageSent(H)}catch(ie){g.a.warn("Failed to send message to channel",{error:ie,channel:D.label})}}channelNotRecognized(D){return D!==this.latestTtlStreamChannel&&D!==this.latestReliableStreamChannel&&D!==this.latestTryOnceStreamChannel&&D!==this.reliableStreamChannel}setupChannel(D){D.onmessage=H=>{if(this.channelNotRecognized(D))return void g.a.warn("Received message on unrecognized data channel.");let X;try{X=JSON.parse(Object(T.decode)(H.data))}catch(ie){return void g.a.warn("Received unparseable RTC message",{error:ie,channel:D.label})}if(this.lastMessageTimestamp=new Date().getTime(),X=rt(X),this.sessionMetrics.incrementMessageReceived(X),!this.handleSystemMessage(D,X)){if(!this.hasCapabilities(X))return void g.a.warn("Received RTC message that was not within the capability scope of the connection.");(D===this.latestTryOnceStreamChannel||D===this.latestTtlStreamChannel||D===this.latestReliableStreamChannel)&&!this.isLatestMessage(X)||this.config.receive(this.config.remotePeer.id,X)}},D.onerror=H=>{g.a.warn(`Channel error: ${H.error}`,{error:H.error,sessionId:this.getSessionId(),channelLabel:D.label})},D.onopen=()=>{g.a.debug("Channel opened",{sessionId:this.getSessionId(),channelLabel:D.label})},D.onclose=()=>{const H={bufferedAmount:D.bufferedAmount,sessionId:this.getSessionId(),channelLabel:D.label};this.closeCalled===!1?g.a.debug("Unexpected channel closed",H):g.a.debug("Channel closed",H)}}handleSystemMessage(D,H){switch(H.header.stream.streamType){case"ping":return this.sendSystemMessage(D,{type:"pong",timestamp:p(H.payload.ping)}),!0;case"pong":{const X=new Date().getTime()-p(H.payload.pong);return this.pingTimeMs=X,y.aggregate("rtc-ping-time",X),!0}case"stream-control":return!0;default:return!1}}sendSystemMessage(D,H){if(D.readyState!=="open")return;const X={entityId:p(this.config.localPeer.deviceId||this.config.localPeer.userId),streamName:`$.${H.type}`,streamType:H.type};let ie;switch(H.type){case"ping":ie={ping:new Date().getTime()};break;case"pong":ie={pong:H.timestamp};break;case"stream-control":ie={streamControl:H.streamControl}}this.sendOnChannel(D,Pe(X,ie))}hasCapabilities(D){var H,X;const{localPeer:ie,remotePeer:oe}=this.config,de=(H=ie.capabilitySet.streaming)===null||H===void 0?void 0:H.streams,ye=de&&de.some(le=>le.receive&&Mt(le.stream,D.header.stream)),be=(X=oe.capabilitySet.streaming)===null||X===void 0?void 0:X.streams,ce=be&&be.some(le=>le.send&&Mt(le.stream,D.header.stream));return ye||ce}isLatestMessage(D){const H=Ce(D.header.stream),X=(this.streamLatestTimestamp.get(H)||0)<=D.header.created;return X&&this.streamLatestTimestamp.set(H,D.header.created),X}}var Ue=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class Rt{constructor(D){this.config=D,this.connections=[],this.connectingSessions=new Map,this.rtcInstancesConstructed=0,this.updateInterval=d({func:()=>Ue(this,void 0,void 0,function*(){try{yield this.update()}catch(H){g.a.warn("RTC update failed",{error:H})}}),delay:250*c.a.millisecond,immediate:!0}),this.localPeer=this.createPeer()}send(D,H,X){const ie=this.getActiveConnection(D);ie?ie.isReady()?ie.send(H,X):g.a.warn("Attempted to send with an active connection to that peer which was not yet ready."):g.a.warn("Attempted to send with no active connection to that peer.")}controlRemoteStream(D,H){const X=this.getActiveConnection(D);X?X.isReady()?X.controlRemoteStream(H):g.a.warn("Attempted to control remote stream with an active connection to that peer which was not yet ready."):g.a.warn("Attempted to control remote stream with no active connection to that peer.")}connect(D){return Ue(this,void 0,void 0,function*(){const H=yield this.getLocalPeer();if(this.getActiveConnection(D))return void g.a.warn("Attempted to connect to peer with an already active connection.");let X;try{X=yield this.config.signalingClient.createSession(yield this.config.getToken(),{offerPeerId:H.id,answerPeerId:D})}catch(ie){Object(at.a)(ie,it.a,oe=>oe.statusCode===404),g.a.warn("Attempted to connect to peer that does not exist.")}if(X)for(this.connectingSessions.set(X.id,new Date().getTime()),yield this.connectToSession(X);;)switch(yield Object(u.a)(.1),this.getConnectionStatus(D)){case"connecting":continue;case"connected":return X.id;case"disconnected":return}})}getConnectionStatus(D){const H=this.getActiveConnection(D);return H?H.isReady()?"connected":"connecting":"disconnected"}getIceMode(D){const H=this.getActiveConnection(D);if(H)return H.iceMode}disconnect(D){return Ue(this,void 0,void 0,function*(){const H=this.getActiveConnection(D);H&&(yield this.closeConnection(H))})}getLocalPeer(){return Ue(this,void 0,void 0,function*(){return yield this.localPeer})}getPeers(){return Ue(this,void 0,void 0,function*(){return yield this.config.signalingClient.getPeers(yield this.config.getToken())})}getPing(D){const H=this.getActiveConnection(D);if(H)return H.getPing();g.a.warn("Attempted to get ping time from inactive peer.")}getLastMessageTimestamp(D){const H=this.getActiveConnection(D);if(H)return H.getLastMessageTimestamp();g.a.warn("Attempted to get ping time from inactive peer.")}shutdown(){return Ue(this,void 0,void 0,function*(){yield this.updateInterval.stop();const D=this.connections;this.connections=[],yield this.closeConnections(D)})}closeConnection(D){return Ue(this,void 0,void 0,function*(){this.connectingSessions.delete(D.getSessionId()),yield D.close();try{yield this.config.signalingClient.deleteSession(yield this.config.getToken(),D.getSessionId())}catch(H){Object(at.a)(H,it.a,X=>X.statusCode===404)}})}getSessions(){return Ue(this,void 0,void 0,function*(){const D=yield this.getLocalPeer();return(yield this.config.signalingClient.getSessions(yield this.config.getToken())).filter(H=>H.offer.peer.id===D.id||H.answer.peer.id===D.id)})}createPeer(){return Ue(this,void 0,void 0,function*(){return yield this.config.signalingClient.createPeer(yield this.config.getToken(),{capabilitySet:this.config.capabilitySet||{}})})}createRTCPeerConnection(D={}){return Ue(this,void 0,void 0,function*(){const H=this.config.alternateRTCPeerConnection||RTCPeerConnection;this.rtcInstancesConstructed++,this.rtcInstancesConstructed%20||vt();try{return new H(Object.assign({iceServers:yield this.config.signalingClient.getIceServers(yield this.config.getToken())},D))}catch(X){throw g.a.debug(`Failed to create RTCPeerConnection: ${this.rtcInstancesConstructed} total allocated`),X}})}closeConnections(D){return Ue(this,void 0,void 0,function*(){const H=yield O(D.map(X=>Ue(this,void 0,void 0,function*(){yield this.closeConnection(X)})));for(const X of H)g.a.warn("Request to close session failed",{error:X})})}reset(){return Ue(this,void 0,void 0,function*(){yield this.closeConnections(this.connections),this.connections=[],this.connectingSessions=new Map,this.localPeer=this.createPeer(),yield this.localPeer})}getActiveConnection(D){return this.connections.find(H=>H.getRemotePeer().id===D&&H.isActive())}update(){return Ue(this,void 0,void 0,function*(){const D=yield this.getLocalPeer();try{yield this.config.signalingClient.refreshPeer(yield this.config.getToken(),D.id)}catch(H){Object(at.a)(H,it.a,X=>X.statusCode===404),g.a.warn("Peer expired, creating new peer",{peerId:D.id}),yield this.reset()}yield this.handleSessions(yield this.getSessions())})}handleSessions(D){return Ue(this,void 0,void 0,function*(){yield this.syncConnectionsAndSessions(D);const H=D.map(X=>({session:X,connection:this.connections.find(ie=>ie.getSessionId()===X.id)}));yield Promise.all(H.map(({session:X,connection:ie})=>Ue(this,void 0,void 0,function*(){return yield this.maintainConnection(X,ie)})))})}syncConnectionsAndSessions(D){return Ue(this,void 0,void 0,function*(){const H=new Set(D.map(oe=>oe.id)),X=oe=>H.has(oe.getSessionId())||this.connectingSessions.has(oe.getSessionId());this.connections=this.connections.filter(oe=>X(oe));const ie=this.connections.filter(oe=>!X(oe)||oe.needsClosing());yield Promise.all(ie.map(oe=>Ue(this,void 0,void 0,function*(){yield this.closeConnection(oe)})))})}maintainConnection(D,H){return Ue(this,void 0,void 0,function*(){const X=yield this.getLocalPeer(),ie=D.offer.peer.id===X.id;if(H){if(H.isReady())try{yield this.config.signalingClient.refreshSession(yield this.config.getToken(),D.id)}catch(oe){Object(at.a)(oe,it.a,de=>de.statusCode===404),g.a.debug("Refresh session not found",{sessionId:D.id})}else if(H.isActive())try{yield this.consumeSignals(H)}catch(oe){g.a.warn("Failed to ingest signals, closing connection",{error:oe}),yield this.closeConnection(H)}}else{if(ie)return;yield this.connectToSession(D)}})}connectToSession(D){return Ue(this,void 0,void 0,function*(){const H=yield this.getLocalPeer(),X=D.offer.peer.id===H.id,ie=yield this.createRTCPeerConnection(),oe=new At(ie,{localPeer:X?D.offer.peer:D.answer.peer,remotePeer:X?D.answer.peer:D.offer.peer,sessionId:D.id,isOffer:X,sendSignal:de=>this.sendSignal(D.id,de),receive:(de,ye)=>this.config.receive(de,ye)});if(this.connections.find(de=>de.getSessionId()===D.id))return g.a.warn("connectToSession called on a session that already has a connection.",{sessionId:D.id}),void(yield oe.close());this.setupHandlers(oe),this.connections.push(oe);try{yield oe.connect()}catch(de){g.a.warn("Failed to handle negotiation, closing connection",{error:de}),yield this.closeConnection(oe)}})}setupHandlers(D){const{peerConnection:H}=D,X=D.getSessionId();H.onconnectionstatechange=()=>Ue(this,void 0,void 0,function*(){const ie=this.connectingSessions.get(X);if(ie===void 0)return;const oe=H.connectionState;switch(qe(H)&&this.connectingSessions.delete(X),oe){case"connected":{this.connectingSessions.delete(X);const de=new Date().getTime()-ie;y.aggregate("rtc-connect-time",de);break}case"failed":y.increment("rtc-connect-failed"),yield this.closeConnection(D)}})}consumeSignals(D){return Ue(this,void 0,void 0,function*(){let H=[];try{H=yield this.config.signalingClient.takeSignals(yield this.config.getToken(),D.getSessionId())}catch(X){Object(at.a)(X,it.a,ie=>ie.statusCode===404)}for(const X of H)yield D.handleSignal(X)})}sendSignal(D,H){return Ue(this,void 0,void 0,function*(){try{yield this.config.signalingClient.addSignals(yield this.config.getToken(),D,{signals:[H]})}catch(X){Object(at.a)(X,it.a,ie=>ie.statusCode===404)}})}}},function(e,t,n){var r={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let i;const s=new Uint8Array(16);function l(){if(!i&&(i=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!i))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(s)}const o=[];for(let u=0;u<256;++u)o.push((u+256).toString(16).slice(1));function c(u,f=0){return(o[u[f+0]]+o[u[f+1]]+o[u[f+2]]+o[u[f+3]]+"-"+o[u[f+4]]+o[u[f+5]]+"-"+o[u[f+6]]+o[u[f+7]]+"-"+o[u[f+8]]+o[u[f+9]]+"-"+o[u[f+10]]+o[u[f+11]]+o[u[f+12]]+o[u[f+13]]+o[u[f+14]]+o[u[f+15]]).toLowerCase()}t.a=function(u,f,E){if(r.randomUUID&&!f&&!u)return r.randomUUID();const _=(u=u||{}).random||(u.rng||l)();if(_[6]=15&_[6]|64,_[8]=63&_[8]|128,f){E=E||0;for(let h=0;h<16;++h)f[E+h]=_[h];return f}return c(_)}},,function(e,t,n){n.r(t),n.d(t,"LogClient",function(){return o});var r=n(28),i=n(11),s=n(10),l=function(c,u,f,E){return new(f||(f=Promise))(function(_,h){function g(j){try{A(E.next(j))}catch(F){h(F)}}function b(j){try{A(E.throw(j))}catch(F){h(F)}}function A(j){var F;j.done?_(j.value):(F=j.value,F instanceof f?F:new f(function(M){M(F)})).then(g,b)}A((E=E.apply(c,u||[])).next())})};class o extends r.a{log(u){return l(this,void 0,void 0,function*(){const f=o.token;try{yield this.fetch("logs",{token:f,method:"POST",body:JSON.stringify({logs:u}),allowUnsafeRetries:!0})}catch(E){Object(i.a)(E,s.a,_=>_.statusCode===401&&f!==void 0),o.token===f&&delete o.token,yield this.log(u)}})}}}])})})(dist);var distExports=dist.exports;const SessionTypes={UNKNOWN:0,TELEOP:1,PORT_FORWARD:2,OBSERVE:3},SessionTypeConstants={...SessionTypes,Unknown:SessionTypes.UNKNOWN,Teleop:SessionTypes.TELEOP,PortForward:SessionTypes.PORT_FORWARD,Observe:SessionTypes.OBSERVE,unknown:SessionTypes.UNKNOWN,teleop:SessionTypes.TELEOP,portForward:SessionTypes.PORT_FORWARD,observe:SessionTypes.OBSERVE},singleton=Symbol("RtcClientPool.instance");class RtcClientPool{constructor(t){Te(this,nt,null);Te(this,"createClient");Te(this,"ttlMs");Te(this,"proxyHandler");Te(this,"proxyReceivers",new Map);Te(this,"teardownTimeout",null);Te(this,"dispatch",(t,n)=>{this.proxyReceivers.forEach(r=>r==null?void 0:r(t,n))});const{createClient:n,ttlMs:r=0}=t;this.createClient=n,this.ttlMs=Math.max(r,0),this.proxyHandler={get:(i,s,l)=>{switch(s){case"shutdown":return()=>this.releaseInstance(l);default:return Reflect.get(i,s,l)}}}}get isActive(){return this[singleton]!==null}get size(){return this.proxyReceivers.size}get(t){const n=new Proxy(this.allocate(),this.proxyHandler);return this.proxyReceivers.set(n,t??null),n}allocate(){if(this[singleton])return this.teardownTimeout&&(clearTimeout(this.teardownTimeout),this.teardownTimeout=null),this[singleton];const t=this.createClient(this.dispatch);return this[singleton]=t,t}async teardown(){const t=this[singleton];if(!t){console.warn("singleton has already been shutdown!");return}try{await t.shutdown()}finally{this[singleton]=null}}async releaseInstance(t){return this.proxyReceivers.delete(t)?this.proxyReceivers.size!==0?!1:(!this.teardownTimeout&&Number.isFinite(this.ttlMs)&&(this.ttlMs===0?await this.teardown():this.teardownTimeout=setTimeout(()=>{this.teardown().catch(n=>console.error("teardown failed",{err:n})).finally(()=>this.teardownTimeout=null)},this.ttlMs)),!0):(console.warn("this instance has already been released!"),!1)}}nt=singleton;const getToken=async()=>defined(Authentication.token,"Realtime when user isn't authorized"),EnumRtcClientPools={[SessionTypes.UNKNOWN]:new RtcClientPool({ttlMs:2500,createClient:e=>new distExports.RtcClient({signalingClient:new distExports.SignalingPromiseClient(FORMANT_API_URL),getToken,sessionType:SessionTypes.UNKNOWN,receive:e})}),[SessionTypes.TELEOP]:new RtcClientPool({ttlMs:2500,createClient:e=>new distExports.RtcClient({signalingClient:new distExports.SignalingPromiseClient(FORMANT_API_URL),getToken,sessionType:SessionTypes.TELEOP,receive:e})}),[SessionTypes.PORT_FORWARD]:new RtcClientPool({ttlMs:2500,createClient:e=>new distExports.RtcClient({signalingClient:new distExports.SignalingPromiseClient(FORMANT_API_URL),getToken,sessionType:SessionTypes.PORT_FORWARD,receive:e})}),[SessionTypes.OBSERVE]:new RtcClientPool({ttlMs:2500,createClient:e=>new distExports.RtcClient({signalingClient:new distExports.SignalingPromiseClient(FORMANT_API_URL),getToken,sessionType:SessionTypes.OBSERVE,receive:e})})},AppRtcClientPools={...EnumRtcClientPools,unknown:EnumRtcClientPools[SessionTypes.UNKNOWN],teleop:EnumRtcClientPools[SessionTypes.TELEOP],portForward:EnumRtcClientPools[SessionTypes.PORT_FORWARD],observe:EnumRtcClientPools[SessionTypes.OBSERVE]},defaultRtcClientPool=EnumRtcClientPools[SessionTypes.TELEOP],getRtcClientPool=e=>{const{sessionType:t}=e;return t?AppRtcClientPools[t]:defaultRtcClientPool};class CaptureStream{constructor(t){Te(this,"token");this.captureSession=t}async ingestJSON(t){if(!this.token){const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions/${this.captureSession.code}/authenticate`,{method:"POST"})).json();this.token=r.token}await fetch(`${FORMANT_API_URL}/v1/ingest`,{method:"POST",body:JSON.stringify({deviceId:this.captureSession.deviceId,name:this.captureSession.streamName,type:"json",points:[[Date.now(),JSON.stringify(t)]]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+this.token}})}}function delay(e){return new Promise(t=>setTimeout(t,e))}const vailableAggregationIntervals=["day","week","month","year","hour","minute","quarter"],aggregateFunctions=["interval","start","end","sub","get"];function getVariance(e){return e.count<2?0:e.sumOfSquares/(e.count-1)}function getStandardDeviation(e){return Math.sqrt(getVariance(e))}function getMax(e){return e.max}function getMin(e){return e.min}function getAverage(e){return e.count===0?-1:e.sum/e.count}function getSum(e){return e.sum}function getCount(e){return e.count}const aggregateFunctionMap={min:getMin,max:getMax,"standard deviation":getStandardDeviation,average:getAverage,sum:getSum,count:getCount},aggregateByDateFunctions={day:{interval:dateFns__namespace.eachDayOfInterval,start:dateFns__namespace.startOfDay,end:dateFns__namespace.endOfDay,sub:dateFns__namespace.subDays,get:dateFns__namespace.getDay},week:{interval:dateFns__namespace.eachWeekOfInterval,start:dateFns__namespace.startOfWeek,end:dateFns__namespace.endOfWeek,sub:dateFns__namespace.subWeeks,get:dateFns__namespace.getWeek},month:{interval:dateFns__namespace.eachMonthOfInterval,start:dateFns__namespace.startOfMonth,end:dateFns__namespace.endOfMonth,sub:dateFns__namespace.subMonths,get:dateFns__namespace.getMonth},year:{interval:dateFns__namespace.eachYearOfInterval,start:dateFns__namespace.startOfYear,end:dateFns__namespace.endOfYear,sub:dateFns__namespace.subYears,get:dateFns__namespace.getYear},hour:{interval:dateFns__namespace.eachHourOfInterval,start:dateFns__namespace.startOfHour,end:dateFns__namespace.endOfHour,sub:dateFns__namespace.subHours,get:dateFns__namespace.getHours},minute:{interval:dateFns__namespace.eachMinuteOfInterval,start:dateFns__namespace.startOfMinute,end:dateFns__namespace.endOfMinute,sub:dateFns__namespace.subMinutes,get:dateFns__namespace.getMinutes},quarter:{interval:dateFns__namespace.eachQuarterOfInterval,start:dateFns__namespace.startOfQuarter,end:dateFns__namespace.endOfQuarter,sub:dateFns__namespace.subQuarters,get:dateFns__namespace.getQuarter}},formatTimeFrameText=(e,t)=>e.split("/")[0]+"/"+e.split("/")[1]+"–"+t.split("/")[0]+"/"+t.split("/")[1];function getZeroINumericSet(){return{min:Number.MAX_SAFE_INTEGER,max:0,sum:0,count:0,sumOfSquares:0}}function reduceNumericStreamAggregates(e){return e.aggregates.reduce((t,n)=>{const r=n[1];return combineNumericAggregates(r,t)},getZeroINumericSet())}function reduceNumericSetStreamAggregates(e,t){var n;return(n=e.aggregates.reduce((r,i)=>{const s=i[1];return combineNumericSetAggregates(s,r)},{})[t])==null?void 0:n.value}function combineNumericAggregates(e,t){return{min:Math.min(e.min,t.min),max:Math.max(e.max,t.max),sum:e.sum+t.sum,count:e.count+t.count,sumOfSquares:e.sumOfSquares+t.sumOfSquares}}function combineNumericSetAggregates(e,t){return Object.keys(e).reduce((n,r)=>{var i;return{...n,[r]:{value:combineNumericAggregates(e[r].value,((i=t[r])==null?void 0:i.value)??getZeroINumericSet()),unit:e[r].unit}}},{})}const timeout=e=>new Promise(t=>setTimeout(t,e*1e3));function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}var cachedSetTimeout=defaultSetTimout,cachedClearTimeout=defaultClearTimeout;typeof global$1.setTimeout=="function"&&(cachedSetTimeout=setTimeout),typeof global$1.clearTimeout=="function"&&(cachedClearTimeout=clearTimeout);function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch{try{return cachedSetTimeout.call(null,e,0)}catch{return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch{try{return cachedClearTimeout.call(null,e)}catch{return cachedClearTimeout.call(this,e)}}}var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){!draining||!currentQueue||(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}function nextTick(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];queue.push(new Item(e,t)),queue.length===1&&!draining&&runTimeout(drainQueue)}function Item(e,t){this.fun=e,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};var title="browser",platform="browser",browser$1=!0,env={},argv=[],version="",versions={},release={},config={};function noop(){}var on=noop,addListener=noop,once=noop,off=noop,removeListener=noop,removeAllListeners=noop,emit=noop;function binding$1(e){throw new Error("process.binding is not supported")}function cwd(){return"/"}function chdir(e){throw new Error("process.chdir is not supported")}function umask(){return 0}var performance$1=global$1.performance||{},performanceNow=performance$1.now||performance$1.mozNow||performance$1.msNow||performance$1.oNow||performance$1.webkitNow||function(){return new Date().getTime()};function hrtime(e){var t=performanceNow.call(performance$1)*.001,n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n=n-e[0],r=r-e[1],r<0&&(n--,r+=1e9)),[n,r]}var startTime=new Date;function uptime(){var e=new Date,t=e-startTime;return t/1e3}var browser$1$1={nextTick,title,browser:browser$1,env,argv,version,versions,on,addListener,once,off,removeListener,removeAllListeners,emit,binding:binding$1,cwd,chdir,umask,hrtime,platform,release,config,uptime},domain;function EventHandlers(){}EventHandlers.prototype=Object.create(null);function EventEmitter(){EventEmitter.init.call(this)}EventEmitter.EventEmitter=EventEmitter,EventEmitter.usingDomains=!1,EventEmitter.prototype.domain=void 0,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.init=function(){this.domain=null,EventEmitter.usingDomains&&domain.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new EventHandlers,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},EventEmitter.prototype.setMaxListeners=function e(t){if(typeof t!="number"||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this};function $getMaxListeners(e){return e._maxListeners===void 0?EventEmitter.defaultMaxListeners:e._maxListeners}EventEmitter.prototype.getMaxListeners=function e(){return $getMaxListeners(this)};function emitNone(e,t,n){if(t)e.call(n);else for(var r=e.length,i=arrayClone(e,r),s=0;s<r;++s)i[s].call(n)}function emitOne(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,s=arrayClone(e,i),l=0;l<i;++l)s[l].call(n,r)}function emitTwo(e,t,n,r,i){if(t)e.call(n,r,i);else for(var s=e.length,l=arrayClone(e,s),o=0;o<s;++o)l[o].call(n,r,i)}function emitThree(e,t,n,r,i,s){if(t)e.call(n,r,i,s);else for(var l=e.length,o=arrayClone(e,l),c=0;c<l;++c)o[c].call(n,r,i,s)}function emitMany(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,s=arrayClone(e,i),l=0;l<i;++l)s[l].apply(n,r)}EventEmitter.prototype.emit=function e(t){var n,r,i,s,l,o,c,u=t==="error";if(o=this._events,o)u=u&&o.error==null;else if(!u)return!1;if(c=this.domain,u){if(n=arguments[1],c)n||(n=new Error('Uncaught, unspecified "error" event')),n.domainEmitter=this,n.domain=c,n.domainThrown=!1,c.emit("error",n);else{if(n instanceof Error)throw n;var f=new Error('Uncaught, unspecified "error" event. ('+n+")");throw f.context=n,f}return!1}if(r=o[t],!r)return!1;var E=typeof r=="function";switch(i=arguments.length,i){case 1:emitNone(r,E,this);break;case 2:emitOne(r,E,this,arguments[1]);break;case 3:emitTwo(r,E,this,arguments[1],arguments[2]);break;case 4:emitThree(r,E,this,arguments[1],arguments[2],arguments[3]);break;default:for(s=new Array(i-1),l=1;l<i;l++)s[l-1]=arguments[l];emitMany(r,E,this,s)}return!0};function _addListener(e,t,n,r){var i,s,l;if(typeof n!="function")throw new TypeError('"listener" argument must be a function');if(s=e._events,s?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),l=s[t]):(s=e._events=new EventHandlers,e._eventsCount=0),!l)l=s[t]=n,++e._eventsCount;else if(typeof l=="function"?l=s[t]=r?[n,l]:[l,n]:r?l.unshift(n):l.push(n),!l.warned&&(i=$getMaxListeners(e),i&&i>0&&l.length>i)){l.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=t,o.count=l.length,emitWarning(o)}return e}function emitWarning(e){typeof console.warn=="function"?console.warn(e):console.log(e)}EventEmitter.prototype.addListener=function e(t,n){return _addListener(this,t,n,!1)},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.prependListener=function e(t,n){return _addListener(this,t,n,!0)};function _onceWrap(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}EventEmitter.prototype.once=function e(t,n){if(typeof n!="function")throw new TypeError('"listener" argument must be a function');return this.on(t,_onceWrap(this,t,n)),this},EventEmitter.prototype.prependOnceListener=function e(t,n){if(typeof n!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(t,_onceWrap(this,t,n)),this},EventEmitter.prototype.removeListener=function e(t,n){var r,i,s,l,o;if(typeof n!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(r=i[t],!r)return this;if(r===n||r.listener&&r.listener===n)--this._eventsCount===0?this._events=new EventHandlers:(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||n));else if(typeof r!="function"){for(s=-1,l=r.length;l-- >0;)if(r[l]===n||r[l].listener&&r[l].listener===n){o=r[l].listener,s=l;break}if(s<0)return this;if(r.length===1){if(r[0]=void 0,--this._eventsCount===0)return this._events=new EventHandlers,this;delete i[t]}else spliceOne(r,s);i.removeListener&&this.emit("removeListener",t,o||n)}return this},EventEmitter.prototype.removeAllListeners=function e(t){var n,r;if(r=this._events,!r)return this;if(!r.removeListener)return arguments.length===0?(this._events=new EventHandlers,this._eventsCount=0):r[t]&&(--this._eventsCount===0?this._events=new EventHandlers:delete r[t]),this;if(arguments.length===0){for(var i=Object.keys(r),s=0,l;s<i.length;++s)l=i[s],l!=="removeListener"&&this.removeAllListeners(l);return this.removeAllListeners("removeListener"),this._events=new EventHandlers,this._eventsCount=0,this}if(n=r[t],typeof n=="function")this.removeListener(t,n);else if(n)do this.removeListener(t,n[n.length-1]);while(n[0]);return this},EventEmitter.prototype.listeners=function e(t){var n,r,i=this._events;return i?(n=i[t],n?typeof n=="function"?r=[n.listener||n]:r=unwrapListeners(n):r=[]):r=[],r},EventEmitter.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):listenerCount$1.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount$1;function listenerCount$1(e){var t=this._events;if(t){var n=t[e];if(typeof n=="function")return 1;if(n)return n.length}return 0}EventEmitter.prototype.eventNames=function e(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function spliceOne(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}function arrayClone(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function unwrapListeners(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}var inherits;typeof Object.create=="function"?inherits=function(t,n){t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:inherits=function(t,n){t.super_=n;var r=function(){};r.prototype=n.prototype,t.prototype=new r,t.prototype.constructor=t};const inherits$1=inherits;var formatRegExp=/%[sdj%]/g;function format(e){if(!isString(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(inspect(arguments[n]));return t.join(" ")}for(var n=1,r=arguments,i=r.length,s=String(e).replace(formatRegExp,function(o){if(o==="%%")return"%";if(n>=i)return o;switch(o){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch{return"[Circular]"}default:return o}}),l=r[n];n<i;l=r[++n])isNull(l)||!isObject(l)?s+=" "+l:s+=" "+inspect(l);return s}function deprecate(e,t){if(isUndefined(global$1.process))return function(){return deprecate(e,t).apply(this,arguments)};if(browser$1$1.noDeprecation===!0)return e;var n=!1;function r(){if(!n){if(browser$1$1.throwDeprecation)throw new Error(t);browser$1$1.traceDeprecation?console.trace(t):console.error(t),n=!0}return e.apply(this,arguments)}return r}var debugs={},debugEnviron;function debuglog(e){if(isUndefined(debugEnviron)&&(debugEnviron=browser$1$1.env.NODE_DEBUG||""),e=e.toUpperCase(),!debugs[e])if(new RegExp("\\b"+e+"\\b","i").test(debugEnviron)){var t=0;debugs[e]=function(){var n=format.apply(null,arguments);console.error("%s %d: %s",e,t,n)}}else debugs[e]=function(){};return debugs[e]}function inspect(e,t){var n={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),isBoolean(t)?n.showHidden=t:t&&_extend(n,t),isUndefined(n.showHidden)&&(n.showHidden=!1),isUndefined(n.depth)&&(n.depth=2),isUndefined(n.colors)&&(n.colors=!1),isUndefined(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=stylizeWithColor),formatValue(n,e,n.depth)}inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(e,t){var n=inspect.styles[t];return n?"\x1B["+inspect.colors[n][0]+"m"+e+"\x1B["+inspect.colors[n][1]+"m":e}function stylizeNoColor(e,t){return e}function arrayToHash(e){var t={};return e.forEach(function(n,r){t[n]=!0}),t}function formatValue(e,t,n){if(e.customInspect&&t&&isFunction(t.inspect)&&t.inspect!==inspect&&!(t.constructor&&t.constructor.prototype===t)){var r=t.inspect(n,e);return isString(r)||(r=formatValue(e,r,n)),r}var i=formatPrimitive(e,t);if(i)return i;var s=Object.keys(t),l=arrayToHash(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),isError(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return formatError(t);if(s.length===0){if(isFunction(t)){var o=t.name?": "+t.name:"";return e.stylize("[Function"+o+"]","special")}if(isRegExp(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(isDate(t))return e.stylize(Date.prototype.toString.call(t),"date");if(isError(t))return formatError(t)}var c="",u=!1,f=["{","}"];if(isArray(t)&&(u=!0,f=["[","]"]),isFunction(t)){var E=t.name?": "+t.name:"";c=" [Function"+E+"]"}if(isRegExp(t)&&(c=" "+RegExp.prototype.toString.call(t)),isDate(t)&&(c=" "+Date.prototype.toUTCString.call(t)),isError(t)&&(c=" "+formatError(t)),s.length===0&&(!u||t.length==0))return f[0]+c+f[1];if(n<0)return isRegExp(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var _;return u?_=formatArray(e,t,n,l,s):_=s.map(function(h){return formatProperty(e,t,n,l,h,u)}),e.seen.pop(),reduceToSingleString(_,c,f)}function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(isNumber(t))return e.stylize(""+t,"number");if(isBoolean(t))return e.stylize(""+t,"boolean");if(isNull(t))return e.stylize("null","null")}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,t,n,r,i){for(var s=[],l=0,o=t.length;l<o;++l)hasOwnProperty(t,String(l))?s.push(formatProperty(e,t,n,r,String(l),!0)):s.push("");return i.forEach(function(c){c.match(/^\d+$/)||s.push(formatProperty(e,t,n,r,c,!0))}),s}function formatProperty(e,t,n,r,i,s){var l,o,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?c.set?o=e.stylize("[Getter/Setter]","special"):o=e.stylize("[Getter]","special"):c.set&&(o=e.stylize("[Setter]","special")),hasOwnProperty(r,i)||(l="["+i+"]"),o||(e.seen.indexOf(c.value)<0?(isNull(n)?o=formatValue(e,c.value,null):o=formatValue(e,c.value,n-1),o.indexOf(`
|
|
49
|
+
`),Error.captureStackTrace(this,r)}}e.exports=i=>{if(i.length>2)throw new r(i);function s(o={}){this.options=o}function l(o){return new s(o)}return s.prototype.transform=i,l.Format=s,l}},function(e,t,n){function r(l,o){if(!(l instanceof o))throw new TypeError("Cannot call a class as a function")}function i(l,o){for(var c=0;c<o.length;c++){var u=o[c];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(l,u.key,u)}}var s=n(88);e.exports=function(){function l(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};r(this,l),this.loggers=new Map,this.options=u}var o,c;return o=l,(c=[{key:"add",value:function(u,f){var E=this;if(!this.loggers.has(u)){var _=(f=Object.assign({},f||this.options)).transports||this.options.transports;f.transports=_?_.slice():[];var h=s(f);h.on("close",function(){return E._delete(u)}),this.loggers.set(u,h)}return this.loggers.get(u)}},{key:"get",value:function(u,f){return this.add(u,f)}},{key:"has",value:function(u){return!!this.loggers.has(u)}},{key:"close",value:function(u){var f=this;if(u)return this._removeLogger(u);this.loggers.forEach(function(E,_){return f._removeLogger(_)})}},{key:"_removeLogger",value:function(u){this.loggers.has(u)&&(this.loggers.get(u).close(),this._delete(u))}},{key:"_delete",value:function(u){this.loggers.delete(u)}}])&&i(o.prototype,c),l}()},function(e,t,n){(function(r){const i=n(52),s=/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/;e.exports=function(l,o,c,u){let f,E,_=!1,h=!1;const g=n(94);function b(F){u(o,F)}function A(F,M){let R=`"${o}" ${M}`;throw F&&(R=`${R}`),E&&(R=`${R}. An example of a valid value would be: ${E}`),new i(R)}const j={convertFromBase64:function(){return b("marking for base64 conversion"),_=!0,j},default:function(F){if(typeof F=="number")f=F.toString();else if(Array.isArray(F)||typeof F=="object"&&F!==null)f=JSON.stringify(F);else{if(typeof F!="string")throw new i("values passed to default() must be of Number, String, Array, or Object type");f=F}return b(`setting default value to "${f}"`),j},required:function(F){return F===void 0?(b("marked as required"),h=!0):(b(`setting required flag to ${F}`),h=F),j},example:function(F){return E=F,j}};return Object.entries({...g,...c}).forEach(([F,M])=>{j[F]=function(R){return function(){let d=l[o];if(b(`will be read from the environment using "${R.name}" accessor`),d===void 0)if(f===void 0&&h)b("was not found in the environment, but is required to be set"),A(void 0,"is a required variable, but it was not set");else{if(f===void 0)return void b("was not found in the environment, but is not required. returning undefined");b(`was not found in the environment, parsing default value "${f}" instead`),d=f}h&&(b("verifying variable value is not an empty string"),d.trim().length===0&&A(void 0,"is a required variable, but its value was empty")),_&&(b("verifying variable is a valid base64 string"),d.match(s)||A(d,"should be a valid base64 string if using convertFromBase64"),b("converting from base64 to utf8 string"),d=r.from(d,"base64").toString());const I=[d].concat(Array.prototype.slice.call(arguments));try{b(`passing value "${d}" to "${R.name}" accessor`);const $=R.apply(R,I);return b(`parsed successfully, returning ${$}`),$}catch($){A(d,$.message)}}}(M)}),j}}).call(this,n(5).Buffer)},function(e,t,n){const r=n(33);e.exports=function(i,s){return s=s||",",i.length?r(i).split(s).filter(Boolean):[]}},function(e,t,n){e.exports=function(r){const i=r.toLowerCase();if(i!=="false"&&i!=="true")throw new Error('should be either "true", "false", "TRUE", or "FALSE"');return i!=="false"}},function(e,t,n){e.exports=function(r){const i=r.toLowerCase();if(["false","0","true","1"].indexOf(i)===-1)throw new Error('should be either "true", "false", "TRUE", "FALSE", 1, or 0');return!(i==="0"||i==="false")}},function(e,t,n){const r=n(95);e.exports=function(i){var s=r(i);if(s>65535)throw new Error("cannot assign a port number greater than 65535");return s}},function(e,t,n){const r=n(33);e.exports=function(i,s){const l=r(i);if(s.indexOf(l)<0)throw new Error(`should be one of [${s.join(", ")}]`);return l}},function(e,t,n){const r=n(54);e.exports=function(i){const s=r(i);if(s>0)throw new Error("should be a negative float");return s}},function(e,t,n){const r=n(54);e.exports=function(i){const s=r(i);if(s<0)throw new Error("should be a positive float");return s}},function(e,t,n){const r=n(53);e.exports=function(i){const s=r(i);if(s>0)throw new Error("should be a negative integer");return s}},function(e,t,n){const r=n(55);e.exports=function(i){var s=r(i);if(!Array.isArray(s))throw new Error("should be a parseable JSON Array");return s}},function(e,t,n){const r=n(55);e.exports=function(i){var s=r(i);if(Array.isArray(s))throw new Error("should be a parseable JSON Object");return s}},function(e,t,n){e.exports=function(r,i){try{RegExp(void 0,i)}catch{throw new Error("invalid regexp flags")}try{return new RegExp(r,i)}catch{throw new Error("should be a valid regexp")}}},function(e,t,n){const r=n(96);e.exports=function(i){return r(i).toString()}},function(e,t,n){const r=n(33),i=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\u0001-\u0008\u000b\u000c\u000e-\u001f\u0021\u0023-\u005b\u005d-\u007f]|\\[\u0001-\u0009\u000b\u000c\u000e-\u007f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\u0001-\u0008\u000b\u000c\u000e-\u001f\u0021-\u005a\u0053-\u007f]|\\[\u0001-\u0009\u000b\u000c\u000e-\u007f])+)\])$/;e.exports=function(s){const l=r(s);if(!i.test(l))throw new Error("should be a valid email address");return l}},function(e,t,n){e.exports=function(r,i){return function(s,l){i&&i.match(/prod|production/)||r(`env-var (${s}): ${l}`)}}},function(e,t,n){(function(r){(function(){var i,s,l,o,c,u;typeof performance<"u"&&performance!==null&&performance.now?e.exports=function(){return performance.now()}:r!=null&&r.hrtime?(e.exports=function(){return(i()-c)/1e6},s=r.hrtime,o=(i=function(){var f;return 1e9*(f=s())[0]+f[1]})(),u=1e9*r.uptime(),c=o-u):Date.now?(e.exports=function(){return Date.now()-l},l=Date.now()):(e.exports=function(){return new Date().getTime()-l},l=new Date().getTime())}).call(this)}).call(this,n(2))},function(e,t,n){(function(r){(function(i){function s(o){if((o=o===void 0?"utf-8":o)!=="utf-8")throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('"+o+"') is invalid.")}function l(o,c){if(c=c===void 0?{fatal:!1}:c,(o=o===void 0?"utf-8":o)!=="utf-8")throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+o+"') is invalid.");if(c.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}if(i.TextEncoder&&i.TextDecoder)return!1;Object.defineProperty(s.prototype,"encoding",{value:"utf-8"}),s.prototype.encode=function(o,c){if((c=c===void 0?{stream:!1}:c).stream)throw Error("Failed to encode: the 'stream' option is unsupported.");c=0;for(var u=o.length,f=0,E=Math.max(32,u+(u>>1)+7),_=new Uint8Array(E>>3<<3);c<u;){var h=o.charCodeAt(c++);if(55296<=h&&56319>=h){if(c<u){var g=o.charCodeAt(c);(64512&g)==56320&&(++c,h=((1023&h)<<10)+(1023&g)+65536)}if(55296<=h&&56319>=h)continue}if(f+4>_.length&&(E+=8,E=(E*=1+c/o.length*2)>>3<<3,(g=new Uint8Array(E)).set(_),_=g),(4294967168&h)==0)_[f++]=h;else{if(!(4294965248&h))_[f++]=h>>6&31|192;else if(!(4294901760&h))_[f++]=h>>12&15|224,_[f++]=h>>6&63|128;else{if(4292870144&h)continue;_[f++]=h>>18&7|240,_[f++]=h>>12&63|128,_[f++]=h>>6&63|128}_[f++]=63&h|128}}return _.slice(0,f)},Object.defineProperty(l.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(l.prototype,"fatal",{value:!1}),Object.defineProperty(l.prototype,"ignoreBOM",{value:!1}),l.prototype.decode=function(o,c){if((c=c===void 0?{stream:!1}:c).stream)throw Error("Failed to decode: the 'stream' option is unsupported.");c=0;for(var u=(o=new Uint8Array(o)).length,f=[];c<u;){var E=o[c++];if(E===0)break;if(!(128&E))f.push(E);else if((224&E)==192){var _=63&o[c++];f.push((31&E)<<6|_)}else if((240&E)==224){_=63&o[c++];var h=63&o[c++];f.push((31&E)<<12|_<<6|h)}else(248&E)==240&&(65535<(E=(7&E)<<18|(_=63&o[c++])<<12|(h=63&o[c++])<<6|63&o[c++])&&(E-=65536,f.push(E>>>10&1023|55296),E=56320|1023&E),f.push(E))}return String.fromCharCode.apply(null,f)},i.TextEncoder=s,i.TextDecoder=l})(typeof window<"u"?window:r!==void 0?r:this)}).call(this,n(6))},function(e,t,n){n.r(t),n.d(t,"AuthClient",function(){return s}),n.d(t,"RtcSignalingClient",function(){return o}),n.d(t,"Credentials",function(){return L}),n.d(t,"IRtcStream",function(){}),n.d(t,"SignalingPromiseClient",function(){return W.SignalingPromiseClient}),n.d(t,"IRtcClientConfigurationV1",function(){}),n.d(t,"IRtcClientConfiguration",function(){}),n.d(t,"IRtcConnectionStatsInfo",function(){}),n.d(t,"IRtcSendConfiguration",function(){}),n.d(t,"IRtcSessionMetricsMessageCounts",function(){}),n.d(t,"IRtcStreamMessage",function(){}),n.d(t,"IRtcStreamPayload",function(){}),n.d(t,"IStreamControl",function(){}),n.d(t,"RtcClient",function(){return jt}),n.d(t,"RtcClientV1",function(){return Rt}),n.d(t,"createRtcStreamMessage",function(){return Pe});var r=n(28),i=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class s extends r.a{adminSignup(D,H){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/admin-signup",{token:H,method:"POST",body:JSON.stringify(D)})})}login(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/login",{method:"POST",body:JSON.stringify(D),allowUnsafeRetries:!0})})}loginWithGoogleToken(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/login-google",{method:"POST",body:JSON.stringify(D),allowUnsafeRetries:!0})})}refresh(D,H){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/refresh",{method:"POST",body:JSON.stringify({refreshToken:D,tokenExpirationSeconds:H}),allowUnsafeRetries:!0})})}respondToNewPasswordRequiredChallenge(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/respond-to-new-password-required-challenge",{method:"POST",body:JSON.stringify(D)})})}forgotPassword(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/forgot-password",{method:"POST",body:JSON.stringify({email:D})})})}confirmForgotPassword(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/confirm-forgot-password",{method:"POST",body:JSON.stringify(D)})})}resendInvitation(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/resend-invitation",{method:"POST",body:JSON.stringify({email:D})})})}changePassword({token:D,refreshToken:H,currentPassword:X,newPassword:ie}){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/change-password",{token:D,method:"POST",body:JSON.stringify({refreshToken:H,currentPassword:X,newPassword:ie})})})}getDeviceCredentials(D){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/device-credentials",{token:D,method:"POST",allowUnsafeRetries:!0})})}impersonate(D,H){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/impersonate",{token:D,method:"POST",allowUnsafeRetries:!0,body:JSON.stringify({userId:H})})})}createServiceAccount(D,H,X,ie){return i(this,void 0,void 0,function*(){return yield this.fetch("auth/service-account",{token:D,method:"POST",allowUnsafeRetries:!0,body:JSON.stringify({name:H,roleId:X,tags:ie})})})}getFeatures(D){return i(this,void 0,void 0,function*(){return(yield this.fetch("auth/features",{token:D})).features})}}var l=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class o extends r.a{createPeer(D,H){return l(this,void 0,void 0,function*(){return yield this.fetch("peers",{token:D,method:"POST",body:JSON.stringify(H)})})}getPeers(D){return l(this,void 0,void 0,function*(){return(yield this.fetch("peers",{token:D})).items})}refreshPeer(D,H){return l(this,void 0,void 0,function*(){yield this.fetch(`peers/${H}/refresh`,{token:D,method:"POST",allowUnsafeRetries:!0})})}createSession(D,H){return l(this,void 0,void 0,function*(){return yield this.fetch("sessions",{token:D,method:"POST",body:JSON.stringify(H)})})}refreshSession(D,H){return l(this,void 0,void 0,function*(){yield this.fetch(`sessions/${H}/refresh`,{token:D,method:"POST",allowUnsafeRetries:!0})})}deleteSession(D,H){return l(this,void 0,void 0,function*(){yield this.fetch(`sessions/${H}`,{token:D,method:"DELETE",allowUnsafeRetries:!0})})}getSessions(D){return l(this,void 0,void 0,function*(){return(yield this.fetch("sessions",{token:D})).items})}getIceServers(D){return l(this,void 0,void 0,function*(){return(yield this.fetch("ice-servers",{token:D})).items})}addSignals(D,H,X){return l(this,void 0,void 0,function*(){yield this.fetch(`sessions/${H}/add-signals`,{token:D,method:"POST",body:JSON.stringify(X)})})}takeSignals(D,H){return l(this,void 0,void 0,function*(){return(yield this.fetch(`sessions/${H}/take-signals`,{token:D,method:"POST"})).items})}}var c=n(1),u=n(8),f=n(14),E=n.n(f),_=n(104),h=n.n(_),g=n(0),b=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class A{constructor(D){this.name="LogReporter",this.type="simple",this.message=D}send(D){return b(this,void 0,void 0,function*(){var H,X;g.a.info(this.message,(H=D.reduce((ie,oe)=>Object.assign(Object.assign({},ie),{[oe.name]:oe.stat}),{}),X=ie=>{const{sum:oe,count:de}=ie,ye=oe/de;return Object.assign(Object.assign({},ie),{average:ye})},Object.keys(H).reduce((ie,oe)=>Object.assign(Object.assign({},ie),{[oe]:X(H[oe])}),{})))})}}var j=n(4),F=n(39);function M(pe){return!!pe.match(/^[a-zA-Z0-9-_.,:?'"()@\/\\#$+ ]{1,255}$/)}var R=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};function d({func:pe,delay:D,immediate:H=!1}){let X=!1,ie=setTimeout(function de(){return R(this,void 0,void 0,function*(){if(X)return;const ye=new Date().getTime();try{oe=pe(),yield oe}finally{if(!X){const be=new Date().getTime();ie=setTimeout(de,Math.max(D-(be-ye),0))}}})},H?0:D),oe=Promise.resolve();return{stop(){return R(this,void 0,void 0,function*(){X=!0,clearTimeout(ie),yield oe})}}}var I=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};const $=n(226),q=!!j.c,y=new class{constructor(pe){this.samplePeriodSeconds=60,this.buffer={},this.reporters=[],this.flushInterval=d({func:()=>this.flushStats(),delay:this.samplePeriodSeconds*c.a.second}),this.tags=this.filterTags((pe==null?void 0:pe.tags)||{app:j.a,version:j.j,namespace:j.i,instanceId:F.a})}shutdown(){return I(this,void 0,void 0,function*(){yield this.flushInterval.stop(),yield this.flushStats(),yield Object(u.a)(2*c.a.second)})}aggregate(pe,D,H){this.addToBuffer(this.buffer,this.encodeKey({metric:pe,tags:this.filterTags(H||{})}),typeof D=="number"?{min:D,max:D,sum:D,count:1}:D)}increment(pe,D){this.aggregate(pe,1,D)}timer(pe,D,H){return I(this,void 0,void 0,function*(){const X=$(),ie=yield D(),oe=$();return this.aggregate(pe,oe-X,H),ie})}registerStatsReporter(pe){this.reporters.push(pe)}setTag(pe,D){const H=this.filterTags({[pe]:D});this.tags=Object.assign(Object.assign({},this.tags),H)}addToBuffer(pe,D,H){if(pe[D]){const{min:X,max:ie,sum:oe,count:de}=pe[D];pe[D]={min:Math.min(X,H.min),max:Math.max(ie,H.max),sum:oe+H.sum,count:de+H.count}}else pe[D]=H}write(pe){return I(this,void 0,void 0,function*(){yield Promise.all(this.reporters.map(D=>I(this,void 0,void 0,function*(){let H;const X={};switch(D.type){case"simple":for(const[oe,de]of Object.entries(pe)){const{metric:ye}=this.decodeKey(oe);this.addToBuffer(X,this.encodeKey({metric:ye}),de)}H=X;break;case"tagged":H=pe;break;default:(function(oe){throw new Error(`Unreachable type encountered (${oe})`)})(D.type)}const ie=Object.entries(H);if(ie.length>0)return D.send(ie.map(([oe,de])=>{const{metric:ye,tags:be}=this.decodeKey(oe);return{name:ye,tags:Object.assign(Object.assign({},be),this.tags),stat:de}}),this.samplePeriodSeconds).catch(oe=>{g.a.debug(`Failed to write stats to ${D.name}`,{error:oe})})})))})}flushStats(){return I(this,void 0,void 0,function*(){yield this.write(this.buffer),this.buffer={}})}encodeKey(pe){return E()(Object.assign(Object.assign({},pe),Object.keys(pe.tags||{}).length>0?{tags:pe.tags}:{}))}decodeKey(pe){return JSON.parse(pe)}filterTags(pe){return Object.entries(pe||{}).reduce((D,[H,X])=>(M(H)&&M(X)&&(D[H]=X),D),{})}};q||["local","on-prem"].includes(j.i)||y.registerStatsReporter(new A("stats"));var m=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class C extends class{constructor(D){this.options=D,this.cache=new h.a(Object.assign(Object.assign(Object.assign({},D.dispose||D.disposeAfter?{ttlAutopurge:!0}:{}),D),{dispose:(...H)=>{var X;H[2]==="evict"&&y.increment("lru-eviction",{name:D.name}),(X=D.dispose)===null||X===void 0||X.call(D,...H)},disposeAfter:(...H)=>{var X;this.updateStats(),(X=D.disposeAfter)===null||X===void 0||X.call(D,...H)}})),this.stringify=D.fastStringify?JSON.stringify:E.a}set(D,H,X){const ie=this.stringify(D);if(!this.cache.set(ie,H,{ttl:X})){const oe=this.cache.sizeCalculation?this.cache.sizeCalculation(H,ie):"unknown";throw Error(`Value too large (${oe} > ${this.cache.max})`)}this.updateStats()}get(D){const{name:H}=this.options,X=this.stringify(D),ie=this.cache.getRemainingTTL(X);return ie<=0?y.increment("cache-miss",{name:H}):ie!==1/0&&y.aggregate("cache-item-ttl",ie,{name:H}),this.cache.get(X)}delete(D){this.cache.delete(this.stringify(D))}peek(D){return this.cache.peek(this.stringify(D))}size(){return this.cache.size}clear(){this.cache.clear()}forEach(D){this.cache.forEach(D)}purgeStale(){return this.cache.purgeStale()}updateStats(){const{name:D}=this.options;y.aggregate("cache-item-count",this.cache.size,{name:D}),this.cache.calculatedSize!==void 0&&y.aggregate("cache-length",this.cache.calculatedSize,{name:D})}}{constructor(D){if(super(D),this.expireRejectedPromiseValues=D.expireRejectedPromiseValues===void 0||D.expireRejectedPromiseValues,this.rejectedPromiseValueTtl=D.rejectedPromiseValueTtl!==void 0?D.rejectedPromiseValueTtl:c.a.second,this.rejectedPromiseValueTtl<0)throw new Error("rejectedPromiseValueTtl must not be negative")}set(D,H,X){super.set(D,H,X),this.expireRejectedPromiseValues&&H.catch(()=>m(this,void 0,void 0,function*(){yield Object(u.a)(this.rejectedPromiseValueTtl),this.peek(D)===H&&this.delete(D)}))}}var w=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class L{constructor(D,H,X){this.authClient=D,this.email=H,this.password=X,this.tokenTtlMs=1*c.a.hour,this.tokenCache=new C({name:"Credentials-tokenCache",max:100,ttl:this.tokenTtlMs-5*c.a.minute,fastStringify:!0})}getToken(){return w(this,void 0,void 0,function*(){let D=this.tokenCache.get(this.email);return D||(D=(()=>w(this,void 0,void 0,function*(){const{authentication:H}=yield this.authClient.login({email:this.email,password:this.password,tokenExpirationSeconds:this.tokenTtlMs/c.a.second});if(!H)throw new Error("User account not verified.");return H.accessToken}))(),this.tokenCache.set(this.email,D)),D})}}var W=n(97),k=n(40),N=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class P extends k.a{constructor(D){super(D)}postLanRtcOffer(D){return N(this,void 0,void 0,function*(){return yield this.fetch("v1/lan-rtc-offer",{method:"POST",body:JSON.stringify(D)})})}}var z=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};function O(pe){return z(this,void 0,void 0,function*(){return(yield Promise.all(pe.map(D=>D.catch(H=>H)))).filter(D=>D instanceof Error)})}function p(pe){if(pe!==void 0)return pe;throw new Error("Value is undefined")}function U(pe,D){const H=pe.reduce((X,ie)=>[...X,...ie.urls],[]).filter(X=>V(X,D)).sort(X=>Q(X,"udp")?-1:0).shift();if(H)return Object.assign(Object.assign({},p(pe.find(X=>X.urls.includes(H)))),{urls:[H]})}function V(pe,D){switch(D){case"stun":return/^stuns?:/.test(pe);case"turn":return/^turns?:/.test(pe)}}function Q(pe,D){return pe.endsWith(`transport=${D}`)}var ee=n(9),ne=n(24),Y=n(229);class G extends Error{constructor(D,H){super(`Deadline expired after ${D}ms + ${H}ms`)}}class S{static withDeadline(D,H){const X=new Promise((ie,oe)=>{setTimeout(()=>{oe(new G(H,this.grpcCallDeadlineSlopMs))},H+this.grpcCallDeadlineSlopMs)});return Promise.race([D,X])}}S.grpcCallDeadlineSlopMs=500*c.a.millisecond;var T=n(29);const B={ordered:!1,maxPacketLifeTime:300*c.a.millisecond},J={ordered:!0},K={ordered:!0},re={ordered:!1,maxRetransmits:0},se={ordered:!1,maxRetransmits:0},fe=pe=>"received"in pe&&pe.received!==void 0,ve=pe=>!("received"in pe)||pe.received===void 0,Ie=2*c.a.second;function Se(pe,D={}){const H=Array.from(pe.values()),X=H.filter(fe),ie=X.length>0,oe=Math.max(...X.map(ce=>ce.received));let de;if(ie){const ce=H.length,le=X.length,Re=X.map(xe=>xe.received-xe.sent),{standardDeviation:Me,mean:je,jitter:Fe}=function(xe){const ke=xe.length;if(ke===0)return{mean:NaN,standardDeviation:-1,jitter:NaN};const Ge=xe.reduce((Je,st)=>Je+st,0)/ke,Ze=Math.sqrt(xe.map(Je=>Math.pow(Je-Ge,2)).reduce((Je,st)=>Je+st)/ke);if(ke===1)return{mean:Ge,standardDeviation:Ze,jitter:NaN};let Xe=0;for(let Je=1;Je<ke;Je++)Xe+=Math.abs(xe[Je]-xe[Je-1]);return{mean:Ge,standardDeviation:Ze,jitter:Xe/(ke-1)}}(Re),Ke=H.filter(xe=>xe.sent<oe-Ie),$e=Ke.filter(ve),Ye=$e.length===0?0:$e.length/Ke.length;de={pingsSent:ce,pongsReceived:le,average:je,standardDeviation:Me,jitter:Fe,max:Math.max(...Re),min:Math.min(...Re),loss:Ye}}else de=null;const{temporalNow:ye=Date.now()}=D,be=(ie?oe:ye)-4*Ie;return Array.from(pe.entries()).forEach(ce=>{const[le,Re]=ce;Re.sent<be&&pe.delete(le)}),de}function Ce({entityId:pe,streamName:D,streamType:H}){return`${pe}.${D}.${H}`}var Ae=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class Oe{constructor(D,H){this.sessionId=D,this.connection=H,this.counts={localSent:new Map,localReceived:new Map,remoteSent:new Map,remoteReceived:new Map},this.sessionId=D,this.connection=H}updateRemoteMessagesCounts(D){if(D.payload.streamsInfo){this.counts.remoteSent=new Map,this.counts.remoteReceived=new Map;for(const H of D.payload.streamsInfo.items)this.counts.remoteSent.set(H.streamId,H.sentCount),this.counts.remoteReceived.set(H.streamId,H.receivedCount)}}getLocalStreamsInfo(D){const{localSent:H,localReceived:X}=this.counts;return{items:[...new Set([...H.keys(),...X.keys()])].map(ie=>{var oe,de;return{streamId:ie,sentCount:(oe=H.get(ie))!==null&&oe!==void 0?oe:0,receivedCount:(de=X.get(ie))!==null&&de!==void 0?de:0}}),timestamp:D}}incrementLocalSent(D){const{localSent:H}=this.counts,X=Ce(D.header.stream);H.set(X,(H.get(X)||0)+1)}incrementLocalReceived(D){const{localReceived:H}=this.counts,X=Ce(D.header.stream),ie=H.get(X)||0;if(ie===0){const{streamName:oe,streamType:de}=D.header.stream;g.a.debug("RTC client received first message for stream",{streamName:oe,streamType:de})}H.set(X,ie+1)}uploadMetrics(){return Ae(this,void 0,void 0,function*(){const{sessionId:D}=this,H=yield this.connection.peerConnection.getStats(),X={};H.forEach(ce=>X[ce.id]=ce),g.a.debug("rtc-stats",Object.assign(Object.assign({},X),{sessionId:D}));const{localSent:ie,localReceived:oe,remoteSent:de,remoteReceived:ye}=this.counts,be=[...new Set([...ie.keys(),...oe.keys()])].reduce((ce,le)=>{const Re=ie.get(le),Me=oe.get(le),je=de.get(le),Fe=ye.get(le);return Object.assign(Object.assign({},ce),{[`local-${le}-sent`]:Re,[`local-${le}-received`]:Me,[`remote-${le}-sent`]:je,[`remote-${le}-received`]:Fe})},{sessionId:D});g.a.debug("rtc-message-report",Object.assign({deviceId:this.connection.getRemoteDeviceId()},be))})}}function Pe(pe,D,H){return{header:{stream:pe,created:Date.now(),frameId:H||""},payload:D}}function qe(pe){return new Set(["disconnected","failed","closed"]).has(pe.iceConnectionState)}function tt(pe){switch(pe.header.stream.streamType){case"twist":{const{twist:D}=pe.payload;if(!D)throw Error("twist not in payload of RTC message with type twist");return{header:pe.header,payload:{twist:{linear:Object.assign({x:0,y:0,z:0},D.linear),angular:Object.assign({x:0,y:0,z:0},D.angular)}}}}case"pose":{const{pose:D}=pe.payload;if(!D)throw Error("pose not in payload of RTC message with type pose");return{header:pe.header,payload:{pose:{translation:Object.assign({x:0,y:0,z:0},D.translation),rotation:Object.assign({x:0,y:0,z:0,w:0},D.rotation)}}}}case"pose-with-covariance":{const{poseWithCovariance:D}=pe.payload;if(!D)throw Error("poseWithCovariance not in payload of RTC message with type pose-with-covariance");const H=new Array(36).fill(0);return D.covariance.forEach((X,ie)=>{if(ie>=36)throw Error("covariance contains more than 36 elements");H[ie]=X}),{header:pe.header,payload:{poseWithCovariance:{pose:{translation:Object.assign({x:0,y:0,z:0},D.pose.translation),rotation:Object.assign({x:0,y:0,z:0,w:0},D.pose.rotation)},covariance:H}}}}case"point":{const{point:D}=pe.payload;if(!D)throw Error("point not in payload of RTC message with type point");return{header:pe.header,payload:{point:Object.assign({x:0,y:0,z:0},D)}}}default:return pe}}var et=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class _t{constructor(D,H,X){this.peerConnection=D,this.config=H,this.dataChannelNotifier=X,this.connectTimeoutMs=20*c.a.second,this.iceGatheringTimeoutMs=15*c.a.second,this.pingUpdateTimeoutMs=1*c.a.second,this.pingV2UpdateTimeoutMs=250*c.a.millisecond,this.pingV2MetricsGatherTimeoutMs=1*c.a.second,this.streamsInfoUpdateTimeoutMs=2*c.a.second,this.reassemblyTimeoutMs=500*c.a.millisecond,this.reassemblyTableCleanupMs=1*c.a.second,this.heartbeatTimeoutMs=20*c.a.millisecond,this.streamLatestTimestamp=new Map,this.reassemblyTable=new Map,this.reassemblyTableLastTimestamp=new Map,this.closeCalled=!1,this.gotOffer=!1,this.hasIceCandidate=!1,this.pingV2Map=new Map,this.sendPingV2=()=>{const{latestTryOnceStreamChannel:oe}=this;if(!oe)return;const de=new Date().getTime(),ye=Object(Y.a)();this.sendSystemMessage(oe,{type:"ping-v2",payload:{timestamp:de,id:ye}}),this.pingV2Map.set(ye,{sent:de})},this.gatherPingV2Metrics=()=>{const oe=Se(this.pingV2Map);if(oe){const de=this.getRemoteDeviceId();this.pingInfo=oe,y.aggregate("rtc-ping-average",oe.average,Object.assign({},de?{deviceId:de}:{})),y.aggregate("rtc-ping-loss",oe.loss,Object.assign({},de?{deviceId:de}:{})),y.aggregate("rtc-jitter",oe.jitter,Object.assign({},de?{deviceId:de}:{}))}};const{isOffer:ie}=H.baseConfig;ie?this.initializeChannels(D):D.ondatachannel=oe=>{switch(oe.channel.label){case"stream.latest-ttl":this.latestTtlStreamChannel=oe.channel;break;case"stream.reliable":this.reliableStreamChannel=oe.channel;break;case"stream.latest-reliable":this.latestReliableStreamChannel=oe.channel;break;case"stream.latest-try-once":this.latestTryOnceStreamChannel=oe.channel;break;case"heartbeat":return void(this.heartbeatChannel=oe.channel);default:return void this.dataChannelNotifier(oe.channel)}this.setupChannel(oe.channel)},this.pingUpdateTimeout=setInterval(()=>{const{reliableStreamChannel:oe}=this;oe&&this.sendSystemMessage(oe,{type:"ping"})},this.pingUpdateTimeoutMs),this.pingV2UpdateTimeout=setInterval(this.sendPingV2,this.pingV2UpdateTimeoutMs),this.pingV2MetricsGatherTimeout=setInterval(this.gatherPingV2Metrics,this.pingV2MetricsGatherTimeoutMs),this.streamsInfoUpdateTimeout=setInterval(()=>{const{latestTtlStreamChannel:oe}=this;oe&&this.sendSystemMessage(oe,{type:"streams-info"})},this.streamsInfoUpdateTimeoutMs),this.reassemblyTableCleanupTimeout=setInterval(()=>{const oe=new Date().getTime();this.reassemblyTableLastTimestamp.forEach((de,ye,be)=>{oe>ye+this.reassemblyTimeoutMs&&this.reassemblyTable.delete(de)})},this.reassemblyTableCleanupMs),this.heartbeatTimeout=setInterval(()=>{const{heartbeatChannel:oe}=this;oe&&oe.readyState==="open"&&oe.send(new Uint8Array([1]))},this.heartbeatTimeoutMs)}handleSignal(D){return et(this,void 0,void 0,function*(){const{peerConnection:H}=this,{track:X}=this.config.baseConfig,ie=(()=>{try{return JSON.parse(D.getPayload())}catch{return}})();if(!ie)return void g.a.error("Received unparseable signal.");g.a.debug("Handling signal",{description:ie});const{sdp:oe,type:de}=ie;if(!oe||!de)return void g.a.warn("Received non-SDP signal");const{signalingState:ye,connectionState:be}=H;if(ye!=="stable"||be!=="connected")if(H.remoteDescription)g.a.warn(`Received SDP after remote description was set: ${oe}`);else{if(de==="offer"){if(ye!=="stable")return void g.a.warn("Received offer SDP when signaling is ongoing.");yield H.setRemoteDescription(ie);const ce=yield H.createAnswer();yield H.setLocalDescription(ce);const le=D.clone();return X==null||X("Answer Received",le),le.setPayload(JSON.stringify(ce)),le.setReceiverId(D.getSenderId()),le.setSenderId(D.getReceiverId()),le}if(de==="answer"){if(ye==="stable")return void g.a.warn("Received answer SDP when signaling hasn't started.");yield H.setRemoteDescription(ie)}}else g.a.warn(`Received SDP when already connected: ${oe}`)})}send(D,H){const X=this.getChannelFromLabel(H.channelLabel);X?this.sendOnChannel(X,D):g.a.warn("Send called with unexpected channel label",{channelLabel:H.channelLabel})}controlRemoteStream(D){this.sendSystemMessage(p(this.reliableStreamChannel),{type:"stream-control",streamControl:D})}isActive(){return new Set(["new","checking","connected","completed"]).has(this.peerConnection.iceConnectionState)||this.isReady()}isReady(){const{reliableStreamChannel:D,latestTtlStreamChannel:H,latestTryOnceStreamChannel:X,latestReliableStreamChannel:ie}=this;return(D==null?void 0:D.readyState)==="open"&&(H==null?void 0:H.readyState)==="open"&&(X==null?void 0:X.readyState)==="open"&&(ie==null?void 0:ie.readyState)==="open"}close(){return et(this,void 0,void 0,function*(){if(this.closeCalled)return;this.closeCalled=!0,this.sessionMetrics&&(yield this.sessionMetrics.uploadMetrics()),ut(this.pingUpdateTimeout),ut(this.pingV2UpdateTimeout),ut(this.pingV2MetricsGatherTimeout),ut(this.reassemblyTableCleanupTimeout),ut(this.streamsInfoUpdateTimeout),ut(this.heartbeatTimeout);const{peerConnection:D,reliableStreamChannel:H,latestTtlStreamChannel:X,latestTryOnceStreamChannel:ie,latestReliableStreamChannel:oe}=this;D.close(),H==null||H.close(),X==null||X.close(),ie==null||ie.close(),oe==null||oe.close()})}getPing(){return this.pingTimeMs}getPingInfo(){return this.pingInfo}getLastMessageTimestamp(){return this.lastMessageTimestamp}getSessionCreatedTimestamp(){var D;return(D=this.config.remoteConfig)===null||D===void 0?void 0:D.sessionCreatedTimestamp}setSessionCreatedTimestamp(D){this.config.remoteConfig&&(this.config.remoteConfig.sessionCreatedTimestamp=D)}getSessionId(){var D;return(D=this.config.remoteConfig)===null||D===void 0?void 0:D.sessionId}setSessionId(D){this.config.remoteConfig&&(this.config.remoteConfig.sessionId=D,this.sessionMetrics=new Oe(D,this))}getRemotePeerId(){return this.config.baseConfig.remotePeerId}getRemoteDeviceId(){var D;return(D=this.config.baseConfig)===null||D===void 0?void 0:D.remoteDeviceId}setRemoteDeviceId(D){this.config.baseConfig.remoteDeviceId=D}getSessionMetricsMessageCounts(){var D;return(D=this.sessionMetrics)===null||D===void 0?void 0:D.counts}getConnectionStatsInfo(){return et(this,void 0,void 0,function*(){const{peerConnection:D}=this;if(!D)return;const H=yield D.getStats(null),X=[];H.forEach(be=>{X.push(be)});const ie=X.find(be=>be.type==="transport");if(!ie)return;const oe=X.find(be=>(be.type==="candidate-pair"||be.type==="candidatepair")&&be.id===ie.selectedCandidatePairId);if(!oe)return;const de=X.find(be=>be.id===oe.localCandidateId),ye=X.find(be=>be.id===oe.remoteCandidateId);return de&&ye&&(de.address=de.address||de.ip,ye.address=ye.address||ye.ip,de.address!==void 0&&ye.address!==void 0)?{transport:ie,localCandidate:de,remoteCandidate:ye}:void 0})}initializeChannels(D){this.heartbeatChannel=D.createDataChannel("heartbeat",se),this.heartbeatChannel.binaryType="arraybuffer",this.latestTtlStreamChannel=D.createDataChannel("stream.latest-ttl",B),this.latestTtlStreamChannel.binaryType="arraybuffer",this.reliableStreamChannel=D.createDataChannel("stream.reliable",J),this.reliableStreamChannel.binaryType="arraybuffer",this.latestReliableStreamChannel=D.createDataChannel("stream.latest-reliable",K),this.latestReliableStreamChannel.binaryType="arraybuffer",this.latestTryOnceStreamChannel=D.createDataChannel("stream.latest-try-once",re),this.latestTryOnceStreamChannel.binaryType="arraybuffer",this.setupChannel(this.latestTtlStreamChannel),this.setupChannel(this.reliableStreamChannel),this.setupChannel(this.latestReliableStreamChannel),this.setupChannel(this.latestTryOnceStreamChannel)}getOffer(){var D,H,X;return et(this,void 0,void 0,function*(){const{gotOffer:ie}=this,{peerConnection:oe,config:de}=this;if(this.config.baseConfig.isLan)throw new Error('"getOffer" method can only be called with internet connections. LAN connections should call the "getLanOffer" method.');const ye=(D=this.config.remoteConfig)===null||D===void 0?void 0:D.sessionId;if(ie)return void g.a.debug("Failed to generate offer because gotOffer was already called.");if(this.gotOffer=!0,qe(this.peerConnection))return void g.a.debug("Failed to generate offer because the peer connection was inactive.");const be=de.baseConfig.track;oe.onicecandidate=()=>{this.hasIceCandidate=!0},oe.oniceconnectionstatechange=()=>et(this,void 0,void 0,function*(){const je=oe.iceConnectionState;if(je==="connected"||je==="completed"){const Fe=yield this.getConnectionStatsInfo(),Ke=Fe?function($e){const Ye=$e.localCandidate.candidateType,xe=$e.remoteCandidate.candidateType;return Ye==="host"&&xe==="host"?"local":Ye==="relay"||xe==="relay"?"TURN":"STUN"}(Fe):void 0;g.a.info(`ICE connection state changed to ${je}`,{sessionId:ye,connectionStatsInfo:Fe,iceMode:Ke}),be==null||be("ICE connection state change",{iceConnectionState:je,sessionId:ye,connectionStatsInfo:Fe,iceMode:Ke})}}),yield oe.setLocalDescription(yield oe.createOffer());const ce=new Date().getTime();for(;;){const je=new Date().getTime()-ce;if(je>this.connectTimeoutMs)return void g.a.debug("Failed to generate offer because ICE gathering timed out.");if(je>this.iceGatheringTimeoutMs&&this.hasIceCandidate){g.a.debug("ICE gathering partially completed; proceeding",{iceTransportPolicy:oe.getConfiguration().iceTransportPolicy,waitTime:je}),be==null||be("ICE gathering partially completed",{sessionId:ye,iceTransportPolicy:oe.getConfiguration().iceTransportPolicy,waitTime:je});break}if(oe.iceGatheringState==="complete"){g.a.debug("ICE gathering complete",{iceTransportPolicy:oe.getConfiguration().iceTransportPolicy,waitTime:je}),be==null||be("ICE gathering completed",{sessionId:ye,iceTransportPolicy:oe.getConfiguration().iceTransportPolicy,waitTime:je});break}yield Object(u.a)(.1*c.a.second)}const le=(H=this.peerConnection.getConfiguration().iceServers)!==null&&H!==void 0?H:[];for(const je of le)"credentialType"in je&&(je.credentialType=void 0);const Re=JSON.stringify(le),Me=new ee.Signal;return Me.setPayload(JSON.stringify(oe.localDescription)),Me.setSenderId(this.config.baseConfig.localPeerId),Me.setReceiverId(this.config.baseConfig.remotePeerId),Me.setIceServers(Re),Me.setIceTransportPolicy((X=this.peerConnection.getConfiguration().iceTransportPolicy)!==null&&X!==void 0?X:"all"),this.config.baseConfig.sessionType!==void 0?Me.setSessionType(this.config.baseConfig.sessionType):Me.setSessionType(ee.SessionType.TELEOP),g.a.debug("Sending offer signal with description",{description:Me.getPayload()}),Me})}getLanOffer(){return et(this,void 0,void 0,function*(){const{peerConnection:D,gotOffer:H}=this;if(!this.config.baseConfig.isLan)throw new Error('"getLanOffer" method can only be used with LAN connections. Internet connections should call the "getOffer" method.');if(H)return void g.a.debug("Failed to generate offer because gotOffer was already called.");if(this.gotOffer=!0,qe(this.peerConnection))return void g.a.debug("Failed to generate offer because the peer connection was inactive.");yield D.setLocalDescription(yield D.createOffer());const X=new Date().getTime();for(;;){if(new Date().getTime()-X>this.iceGatheringTimeoutMs)return void g.a.debug("Failed to generate offer because ICE gathering timed out.");if(D.iceGatheringState==="complete")break;yield Object(u.a)(.1*c.a.second)}const ie=D.localDescription;if(ie)return g.a.debug("Sending LAN offer signal with description",{description:ie}),ie;g.a.error("Failed to generate LAN offer description")})}handleLanAnswer(D){return et(this,void 0,void 0,function*(){const{peerConnection:H}=this;if(!this.config.baseConfig.isLan)throw new Error('"handleLanAnswer" method can only be used with LAN connections. Internet connections should call the "handleSignal" method.');yield H.setRemoteDescription(D)})}getChannelFromLabel(D){switch(D){case"stream.latest-ttl":return this.latestTtlStreamChannel;case"stream.reliable":return this.reliableStreamChannel;case"stream.latest-reliable":return this.latestReliableStreamChannel;case"stream.latest-try-once":return this.latestTryOnceStreamChannel}}sendOnChannel(D,H){let X;try{X=Object(T.encode)(JSON.stringify(H))}catch(ie){return void g.a.warn("Failed to encode RTC message",{error:ie})}try{D.send(X),this.sessionMetrics&&this.sessionMetrics.incrementLocalSent(H)}catch(ie){g.a.warn("Failed to send message to channel",{error:ie,channel:D.label})}}channelNotRecognized(D){return D!==this.latestTtlStreamChannel&&D!==this.latestReliableStreamChannel&&D!==this.latestTryOnceStreamChannel&&D!==this.reliableStreamChannel}setupChannel(D){D.onmessage=H=>{if(this.channelNotRecognized(D))return void g.a.warn("Received message on unrecognized data channel.");let X;try{X=JSON.parse(Object(T.decode)(H.data))}catch(ie){return void g.a.warn("Received unparseable message on RTC stream data channel",{error:ie,channel:D.label})}X.communicationType==="message-chunk"?this.receiveChannelMessageChunk(D,X):this.receiveChannelMessage(D,X)},D.onerror=H=>{g.a.warn(`Channel error: ${H.error}`,{error:H.error,sessionId:this.getSessionId(),channelLabel:D.label})},D.onopen=()=>{g.a.debug("Channel opened",{sessionId:this.getSessionId(),channelLabel:D.label})},D.onclose=()=>{const H={bufferedAmount:D.bufferedAmount,sessionId:this.getSessionId(),channelLabel:D.label};this.closeCalled===!1?g.a.debug("Unexpected channel closed",H):g.a.debug("Channel closed",H)}}receiveChannelMessage(D,H){const{config:X}=this,{remotePeerId:ie}=this.config.baseConfig;this.lastMessageTimestamp=new Date().getTime(),H=tt(H),this.sessionMetrics&&this.sessionMetrics.incrementLocalReceived(H),this.handleSystemMessage(D,H)||(D===this.latestTryOnceStreamChannel||D===this.latestTtlStreamChannel||D===this.latestReliableStreamChannel)&&!this.isLatestMessage(H)||X.baseConfig.receive(ie,H)}receiveChannelMessageChunk(D,H){const X=this.reassemblyTable.get(H.id)||[];if(X.push(H),X.length===H.total){const ie=function(oe){const de=oe.sort((ye,be)=>ye.seq<be.seq?-1:1).map(ye=>ye.part).reduce((ye,be)=>ye+be);try{return JSON.parse(de)}catch{return void g.a.warn("Could not reassemble RTC message chunks")}}(X);return ie&&this.receiveChannelMessage(D,ie),void this.reassemblyTable.delete(H.id)}this.reassemblyTable.set(H.id,X),this.reassemblyTableLastTimestamp.set(H.id,new Date().getTime())}handleSystemMessage(D,H){var X,ie;const{config:oe}=this,{baseConfig:de}=oe,{remotePeerId:ye,remoteDeviceId:be}=de;switch(H.header.stream.streamType){case"ping":return this.sendSystemMessage(D,{type:"pong",timestamp:p(H.payload.ping)}),!0;case"pong":{const ce=new Date().getTime()-p(H.payload.pong);return this.pingTimeMs=ce,y.aggregate("rtc-ping-time",ce,Object.assign({},be?{deviceId:be}:{})),!0}case"ping-v2":return this.sendPingV2(),!0;case"pong-v2":{const ce=p(H.payload.pongV2),le=this.pingV2Map.get(ce.id);return(le==null?void 0:le.sent)!==ce.timestamp&&g.a.warn("Pong timestamp doesn't match stored value",{currentEntry:le,pong:ce}),this.pingV2Map.set(ce.id,{sent:ce.timestamp,received:new Date().getTime()}),!0}case"streams-info":{const{sessionMetrics:ce}=this,le=(X=H.payload.streamsInfo)===null||X===void 0?void 0:X.timestamp;return!!le&&(ce==null||ce.updateRemoteMessagesCounts(H),(ie=de.onStreamsInfoUpdate)===null||ie===void 0||ie.call(de,ye,le),!0)}case"stream-control":return!0;default:return!1}}sendSystemMessage(D,H){var X;const{localUserId:ie,localPeerId:oe}=this.config.baseConfig;if(D.readyState!=="open")return;const de={entityId:ie??oe,streamName:`$.${H.type}`,streamType:H.type};let ye;switch(H.type){case"ping":ye={ping:new Date().getTime()};break;case"pong":ye={pong:H.timestamp};break;case"ping-v2":ye={pingV2:H.payload};break;case"pong-v2":ye={pongV2:H.payload};break;case"stream-control":ye={streamControl:H.streamControl};break;case"streams-info":ye={streamsInfo:(X=this.sessionMetrics)===null||X===void 0?void 0:X.getLocalStreamsInfo(new Date().getTime())}}this.sendOnChannel(D,Pe(de,ye))}isLatestMessage(D){const H=Ce(D.header.stream),X=(this.streamLatestTimestamp.get(H)||0)<=D.header.created;return X&&this.streamLatestTimestamp.set(H,D.header.created),X}}function ut(pe){pe&&clearInterval(pe)}function vt(){g.a.debug("forceGarbageCollection() triggered"),queueMicrotask(()=>{let pe=document.createElement("img");pe.src=window.URL.createObjectURL(new Blob([new ArrayBuffer(5e7)])),pe.onerror=function(){window.URL.revokeObjectURL(this.src),pe=null}})}function It(pe){try{return pe instanceof Error?`${pe.name}: ${pe.message}`:typeof pe=="object"?JSON.stringify(pe):String(pe)}catch{return"Unknown error"}}function Tt(pe){var D,H;return{userId:(D=pe.getUserId())===null||D===void 0?void 0:D.getValue(),deviceId:(H=pe.getDeviceId())===null||H===void 0?void 0:H.getValue(),organizationId:pe.getOrganizationId(),id:pe.getPeerId(),capabilities:[],capabilitySet:{}}}var Be=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class jt{constructor(D){this.config=D,this.grpcCallDeadline=5*c.a.second,this.refreshIntervalDelayMs=2*c.a.second,this.iceServersTtl=30*c.a.minute,this.connections=[],this.localConnections=[],this.isConnectionInitiator=new Map,this.isOutgoingConnection=new Map,this.peerDataChannelListeners=[],this.rtcInstancesConstructed=0;const{refreshIntervalDelayMs:H}=this;this.refreshInterval=d({func:()=>Be(this,void 0,void 0,function*(){try{yield this.update()}catch(X){g.a.warn("RTC refresh failed",{error:X})}}),delay:H,immediate:!0})}send(D,H,X){const ie=this.getActiveConnection(D);ie?ie.isReady()?ie.send(H,X):g.a.warn("Send called with unready connection."):g.a.warn("Send called with no connection.")}controlRemoteStream(D,H){const X=this.getActiveConnection(D);X?X.isReady()?X.controlRemoteStream(H):g.a.warn("controlRemoteStream called with unready connection."):g.a.warn("controlRemoteStream called with no connection.")}getLocalPeer(){return Be(this,void 0,void 0,function*(){for(;!this.localPeer;)yield Object(u.a)(.1*c.a.second);return Tt(this.localPeer)})}connect(D,H){var X,ie,oe;return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode===!0)throw new Error("connect method called in local only mode.");const{track:de,signalingClient:ye}=this.config,{localPeer:be,receiveSignalStream:ce,iceServers:le}=this;if(!be||!ce||!le)return void g.a.warn("Connect called prior to local peer, receiveSignalStream, and ICE servers ready");if(this.getActiveConnection(D))return void g.a.warn("Connect called for peer with existing connection.");if(this.isOutgoingConnection.get(D))return void g.a.warn("Connect called for peer with an existing outgoing connection offer.");this.isOutgoingConnection.set(D,!0);const Re=function(xe,ke,Ge){const{rtcIceTransportPolicies:Ze,rtcIceServerProtocol:Xe,useAllServers:Je}=ke||{},st=xe.map(at=>Object.assign(Object.assign({},at),{urls:at.urls.filter(gt=>{const Qe=(Ze===void 0||Ze.some(Nt=>V(gt,Nt)))&&(Xe===void 0||Q(gt,Xe));return Qe||g.a.debug(`Ignoring ICE server: ${gt}`,{organizationId:Ge}),Qe})})).filter(({urls:at})=>at.filter(gt=>gt).length>0);return Je?st:[U(st,"stun"),U(st,"turn")].filter(at=>at!==void 0).map(at=>p(at))}(le,H);g.a.debug("Received ICE servers:",le),g.a.debug("Using ICE servers:",Re);const Me=new _t(yield this.createRTCPeerConnection(Re),{baseConfig:{isOffer:!0,isLan:!1,receive:(xe,ke)=>this.config.receive(xe,ke),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(xe,ke)=>{var Ge,Ze;return(Ze=(Ge=this.config).onStreamsInfoUpdate)===null||Ze===void 0?void 0:Ze.call(Ge,xe,ke)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localUserId:(X=be.getUserId())===null||X===void 0?void 0:X.getValue(),localPeerId:be.getPeerId(),remotePeerId:D,sessionType:this.config.sessionType},remoteConfig:{}},xe=>this.onCustomDataChannel(D,xe)),je=yield Me.getOffer();if(!je)return g.a.error("Failed to generate offer."),void this.isOutgoingConnection.delete(D);g.a.debug("Sending offer."),de==null||de("Sending offer",je);const Fe=new ee.SendSignalRequest;Fe.setSignal(je);const Ke=yield(()=>Be(this,void 0,void 0,function*(){try{return yield S.withDeadline(ye.sendSignal(Fe,yield this.getMetadata({})),this.grpcCallDeadline)}catch(xe){g.a.warn("Error when sending signal",{error:xe})}}))();if(!this.isOutgoingConnection.get(D))return void g.a.debug("No offer set after receiving offer signal response.");g.a.debug("Offer sent.");const $e=(ie=Ke==null?void 0:Ke.getSessionId())===null||ie===void 0?void 0:ie.getValue(),Ye=(oe=Ke==null?void 0:Ke.getSessionCreatedTimestamp())===null||oe===void 0?void 0:oe.getValue();return $e&&Ye?(Me.setSessionId($e),Me.setSessionCreatedTimestamp(Ye),this.isOutgoingConnection.delete(D),this.connections.push(Me),this.isConnectionInitiator.set(Me,!0),this.setupHandlers(Me),$e):(g.a.warn("No session ID or no session created timestamp on send signal response."),void this.isOutgoingConnection.delete(D))})}connectLan(D){var H,X;return Be(this,void 0,void 0,function*(){const ie=new P(D),oe=new _t(yield this.createRTCPeerConnection([]),{baseConfig:{isOffer:!0,isLan:!0,receive:(ce,le)=>this.config.receive(ce,le),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(ce,le)=>{var Re,Me;return(Me=(Re=this.config).onStreamsInfoUpdate)===null||Me===void 0?void 0:Me.call(Re,ce,le)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localUserId:(X=(H=this.localPeer)===null||H===void 0?void 0:H.getUserId())===null||X===void 0?void 0:X.getValue(),localPeerId:"lan_client",remotePeerId:D}},ce=>this.onCustomDataChannel(D,ce)),de=yield oe.getLanOffer();if(!de)return g.a.warn("Could not generate LAN offer"),!1;const ye=yield ie.postLanRtcOffer({offer:JSON.stringify(de)}),be=new RTCSessionDescription(JSON.parse(ye.answer));return yield oe.handleLanAnswer(be),this.localConnections.push(oe),this.isConnectionInitiator.set(oe,!0),Object(Y.a)()})}getConnections(){return[...this.connections,...this.localConnections]}createCustomDataChannel(D,H,X,ie,oe){const de=this.getActiveConnection(D);if(de&&this.isConnectionInitiator.has(de)){const be=de.peerConnection.createDataChannel("custom."+H,X);return ie&&(be.binaryType="arraybuffer"),oe(D,be),()=>{}}const ye=(be,ce)=>{D===be&&ce.label==="custom."+H&&oe(D,ce)};return this.peerDataChannelListeners.push(ye),()=>{this.peerDataChannelListeners=this.peerDataChannelListeners.filter(be=>be!==ye)}}onCustomDataChannel(D,H){this.peerDataChannelListeners.forEach(X=>X(D,H))}getConnectionStatus(D){if(this.isOutgoingConnection.get(D))return"connecting";const H=this.getActiveConnection(D);return H?H.isReady()?"connected":"connecting":"disconnected"}getConnectionStatsInfo(D){return Be(this,void 0,void 0,function*(){const H=this.getActiveConnection(D);if(H)return yield H.getConnectionStatsInfo()})}disconnect(D){return Be(this,void 0,void 0,function*(){const H=this.getActiveConnection(D);H&&(yield H.close())})}getPeers(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getPeers method cannot be used in local-only mode.");const{signalingClient:D}=this.config,H=yield(()=>Be(this,void 0,void 0,function*(){try{return yield S.withDeadline(D.getPeers(new ee.GetPeersRequest,yield this.getMetadata({})),this.grpcCallDeadline)}catch(oe){g.a.warn("Error when getting peers",{error:oe})}}))();if(!H)return[];const X=H.getPeersList();if(!X)return[];const ie=oe=>{var de,ye;return(ye=(de=oe.getPeerCreatedTimestamp())===null||de===void 0?void 0:de.getValue())!==null&&ye!==void 0?ye:0};return X.sort((oe,de)=>ie(de)-ie(oe)).map(oe=>Tt(oe))})}getSessions(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getPeers method cannot be used in local-only mode.");const{signalingClient:D}=this.config,H=yield(()=>Be(this,void 0,void 0,function*(){try{return yield S.withDeadline(D.getPeers(new ee.GetPeersRequest,yield this.getMetadata({})),this.grpcCallDeadline)}catch(oe){g.a.warn("Error when getting peers",{error:oe})}}))();if(!H)return{};const X=H.getPeersList(),ie={};for(const oe of X)ie[oe.getPeerId()]=oe.getSessionIdsList();return ie})}getPing(D){const H=this.getActiveConnection(D);if(H)return H.getPing();g.a.warn("Attempted to get ping time from inactive peer.")}getPingInfo(D){const H=this.getActiveConnection(D);if(H)return H.getPingInfo();g.a.warn("Attempted to get ping time from inactive peer.")}getLastMessageTimestamp(D){const H=this.getActiveConnection(D);if(H)return H.getLastMessageTimestamp();g.a.warn("Attempted to get last message time from inactive peer.")}getSessionMetricsMessageCounts(D){const H=this.getActiveConnection(D);if(H)return H.getSessionMetricsMessageCounts();g.a.warn("Attempted to get session metrics counts from inactive peer.")}isReady(){if(this.config.lanOnlyMode)return!0;const{localPeer:D,receiveSignalStream:H,iceServers:X}=this;return!!(D&&H&&X)}shutdown(){return Be(this,void 0,void 0,function*(){g.a.info("Shutdown called on RTC client"),yield this.refreshInterval.stop(),this.receiveSignalStream&&this.receiveSignalStream.cancel();const D=this.connections;this.connections=[],yield this.closeConnections(D);const{localPeer:H}=this;if(!H||this.config.lanOnlyMode)return;const{signalingClient:X}=this.config;yield(()=>Be(this,void 0,void 0,function*(){try{const ie=new ee.DeletePeerRequest;ie.setPeerId(H.getPeerId()),yield S.withDeadline(X.deletePeer(ie,yield this.getMetadata({})),this.grpcCallDeadline)}catch(ie){return void g.a.warn("Error deleting local peer",{error:ie})}}))()})}createPeer(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("createPeer method cannot be used in local-only mode.");const{signalingClient:D}=this.config,H=yield(()=>Be(this,void 0,void 0,function*(){try{return yield S.withDeadline(D.createPeer(new ee.CreatePeerRequest,yield this.getMetadata({})),this.grpcCallDeadline)}catch(ie){const oe=ie;g.a.debug("createPeer failed",{error:oe});const de=It(oe);throw new Error(`Was not able to create peer: ${de}`)}}))(),X=H==null?void 0:H.getPeer();if(!X)throw new Error("Response did not provide peer.");return this.localPeer=X})}createReceiveSignalStream(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("createReceiveSignalStream method cannot be used in local-only mode.");const{signalingClient:D}=this.config,{localPeer:H,iceServers:X}=this;if(!H||!X)return;const{receiveSignalStream:ie}=this;ie&&ie.cancel();const oe=new ee.ReceiveSignalStreamRequest;oe.setPeerId(H.getPeerId());const de=yield(()=>Be(this,void 0,void 0,function*(){try{return D.receiveSignalStream(oe,yield this.getMetadata({hasDeadline:!1}))}catch(ye){g.a.debug("createReceiveSignalStream failed",{error:ye});const be=It(ye);throw new Error(`Unable to create receive signal stream: ${be}`)}}))();if(!de)throw new Error("Response did not provide stream.");return de.on("data",ye=>Be(this,void 0,void 0,function*(){var be,ce,le,Re;const Me=ye.getSignal(),je=(be=Me==null?void 0:Me.getSessionId())===null||be===void 0?void 0:be.getValue(),Fe=Me==null?void 0:Me.getSenderId(),Ke=Me==null?void 0:Me.getReceiverId(),$e=(ce=Me==null?void 0:Me.getSessionCreatedTimestamp())===null||ce===void 0?void 0:ce.getValue();if(!(Me&&je&&Fe&&Ke&&$e))return void g.a.warn("Received signal with missing information.");const Ye=this.getActiveConnection(Fe);if(Ye)if(Ye.getSessionId()!==je){if(g.a.debug("Received signal: different session for a peer we're already connected to."),(Ye.getSessionCreatedTimestamp()||0)>$e)return;const xe=new _t(yield this.createRTCPeerConnection(X),{baseConfig:{isOffer:!1,isLan:!1,receive:(ke,Ge)=>this.config.receive(ke,Ge),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(ke,Ge)=>{var Ze,Xe;return(Xe=(Ze=this.config).onStreamsInfoUpdate)===null||Xe===void 0?void 0:Xe.call(Ze,ke,Ge)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localPeerId:H.getPeerId(),localUserId:(Re=H.getUserId())===null||Re===void 0?void 0:Re.getValue(),remotePeerId:Fe},remoteConfig:{sessionId:je,sessionCreatedTimestamp:$e}},ke=>this.onCustomDataChannel(Fe,ke));yield xe.handleSignal(Me),this.connections.push(xe)}else g.a.debug("Received signal: for an existing connection."),yield Ye.handleSignal(Me);else{g.a.debug("Received signal: new connection.");const xe=new _t(yield this.createRTCPeerConnection(X),{baseConfig:{isOffer:!1,isLan:!1,receive:(ke,Ge)=>this.config.receive(ke,Ge),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(ke,Ge)=>{var Ze,Xe;return(Xe=(Ze=this.config).onStreamsInfoUpdate)===null||Xe===void 0?void 0:Xe.call(Ze,ke,Ge)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localPeerId:H.getPeerId(),localUserId:(le=H.getUserId())===null||le===void 0?void 0:le.getValue(),remotePeerId:Fe},remoteConfig:{sessionId:je,sessionCreatedTimestamp:$e}},ke=>this.onCustomDataChannel(Fe,ke));yield xe.handleSignal(Me),this.connections.push(xe)}})),de.on("end",()=>{de.cancel(),this.receiveSignalStream=void 0}),de.on("error",ye=>{switch(ye.code){case ne.StatusCode.CANCELLED:case ne.StatusCode.UNAVAILABLE:case ne.StatusCode.UNKNOWN:g.a.debug("Receive signal stream error",{error:ye});break;case ne.StatusCode.UNAUTHENTICATED:g.a.warn("Receive signal stream error",{error:ye});break;default:g.a.error("Receive signal stream error",{error:ye})}de.cancel(),this.receiveSignalStream=void 0}),this.receiveSignalStream=de})}createRTCPeerConnection(D){var H;return Be(this,void 0,void 0,function*(){const X=(H=this.config.alternateRTCPeerConnection)!==null&&H!==void 0?H:window.RTCPeerConnection;if(!X)throw function(){const{userAgent:ie}=navigator;return ie.includes("Firefox/")?"Firefox":ie.includes("Edg/")?"Edge":ie.includes("Chrome/")?"Chrome":ie.includes("Safari/")?"Safari":ie.includes("MSIE/")||ie.includes("Trident/")?"IE":"Other"}()!=="Chrome"?new Error("WebRTC is not enabled. Please try again with the latest version of Google Chrome."):new Error("WebRTC is not enabled. Please ensure WebRTC is not disabled by ad blocking software.");this.rtcInstancesConstructed++,this.rtcInstancesConstructed%20||vt();try{return new X({iceServers:D})}catch(ie){throw g.a.debug(`Failed to create RTCPeerConnection: ${this.rtcInstancesConstructed} total allocated`),ie}})}closeConnections(D){return Be(this,void 0,void 0,function*(){const H=yield O(D.map(X=>Be(this,void 0,void 0,function*(){yield X.close()})));for(const X of H)g.a.warn("Request to close session failed",{error:X})})}getActiveConnection(D){return this.getConnections().find(H=>H.getRemotePeerId()===D&&H.isActive())}update(){var D;return Be(this,void 0,void 0,function*(){if(this.localConnections=this.localConnections.filter(ye=>ye.isActive()),this.config.lanOnlyMode)return;const{signalingClient:H}=this.config;if(!this.localPeer||!this.receiveSignalStream||!this.iceServers){const ye=[];return this.localPeer||ye.push(this.createPeer()),this.iceServers||ye.push(this.updateIceServers()),yield Promise.all(ye),void(this.receiveSignalStream||(yield this.createReceiveSignalStream()))}yield this.closeConnections(this.connections.filter(ye=>!ye.isActive())),this.connections=this.connections.filter(ye=>ye.isActive());const{localPeer:X}=this,ie=this.connections.filter(ye=>ye.getSessionId).map(ye=>p(ye.getSessionId()));X.setSessionIdsList(ie);const oe=new ee.RefreshPeerRequest;oe.setPeer(X);try{yield S.withDeadline(H.refreshPeer(oe,yield this.getMetadata({})),this.grpcCallDeadline)}catch(ye){ye.code===ne.StatusCode.NOT_FOUND?(g.a.warn("Peer expired, creating new peer",{peerId:X.getPeerId()}),yield this.reset()):g.a.warn("Error calling RefreshPeer",{error:ye})}const de=yield this.getPeers();for(const ye of this.connections)ye.setRemoteDeviceId((D=de.find(be=>be.id===ye.getRemotePeerId()))===null||D===void 0?void 0:D.deviceId)})}reset(){return Be(this,void 0,void 0,function*(){yield this.closeConnections(this.connections),this.connections=[],this.isOutgoingConnection=new Map,yield this.createPeer(),yield this.createReceiveSignalStream()})}updateIceServers(){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)return;const{iceServersLastUpdate:D,iceServersTtl:H}=this,X=new Date().getTime();if(!D||X-D>H)try{const ie=(yield S.withDeadline(this.config.signalingClient.getIceServers(new ee.GetIceServersRequest,yield this.getMetadata({})),this.grpcCallDeadline)).getIceServers();this.iceServers=JSON.parse(ie),this.iceServersLastUpdate=X}catch(ie){g.a.warn("Error in updateIceServers",{error:ie})}})}setupHandlers(D){const{peerConnection:H}=D,X=D.getSessionCreatedTimestamp();H.onconnectionstatechange=()=>Be(this,void 0,void 0,function*(){const ie=H.connectionState;if(!X)return;const oe=D.getRemoteDeviceId();switch(ie){case"connected":y.aggregate("rtc-connect-time",new Date().getTime()-X,Object.assign({},oe?{deviceId:oe}:{}));break;case"failed":y.increment("rtc-connect-failed",Object.assign({},oe?{deviceId:oe}:{}))}})}getMetadata(D){return Be(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getMetadata method cannot be called in local-only mode");const{getToken:H}=this.config,{grpcCallDeadline:X}=this,{hasDeadline:ie}=D,oe=ie===!1?void 0:new Date().getTime()+X;try{return{authorization:yield H(),deadline:oe}}catch(de){throw g.a.error("getToken() failed",{error:de}),new Error("Cannot get authorization token")}})}}var nt=n(10),ot=n(11),xt=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class mt{constructor(D,H){this.sessionId=D,this.connection=H,this.sentMessagesCounts=new Map,this.receivedMessagesCounts=new Map,this.sessionId=D,this.connection=H}incrementMessageSent(D){const H=Ce(D.header.stream);this.sentMessagesCounts.set(H,(this.sentMessagesCounts.get(H)||0)+1)}incrementMessageReceived(D){const H=Ce(D.header.stream);this.receivedMessagesCounts.set(H,(this.receivedMessagesCounts.get(H)||0)+1)}uploadMetrics(){return xt(this,void 0,void 0,function*(){const{sessionId:D}=this,H=yield this.connection.peerConnection.getStats(),X={};H.forEach(oe=>X[oe.id]=oe),g.a.debug("rtc-stats",Object.assign(Object.assign({},X),{sessionId:D}));const ie=[...new Set(Array.from(this.sentMessagesCounts.keys()).concat(Array.from(this.receivedMessagesCounts.keys())))].reduce((oe,de)=>{const ye=this.sentMessagesCounts.get(de),be=this.receivedMessagesCounts.get(de);return Object.assign(Object.assign({},oe),{[`${de}-sent`]:ye,[`${de}-received`]:be})},{sessionId:D});g.a.debug("rtc-message-report",ie)})}}function Mt(pe,D){return Ce(pe)===Ce(D)}var ct=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class At{constructor(D,H){this.peerConnection=D,this.config=H,this.connectTimeoutMs=10*c.a.second,this.gatherIceTimeoutMs=5*c.a.second,this.pingUpdateTimeoutMs=2*c.a.second,this.streamLatestTimestamp=new Map,this.closeCalled=!1,this.connectCalled=!1,this.sentOffer=!1,this.receivedIceCandidate=!1;const{isOffer:X}=H;X?this.initializeChannels(D):D.ondatachannel=ie=>{switch(ie.channel.label){case"stream.latest-ttl":this.latestTtlStreamChannel=ie.channel;break;case"stream.reliable":this.reliableStreamChannel=ie.channel;break;case"stream.latest-reliable":this.latestReliableStreamChannel=ie.channel;break;case"stream.latest-try-once":this.latestTryOnceStreamChannel=ie.channel}this.setupChannel(ie.channel)},this.sessionMetrics=new mt(this.getSessionId(),this)}connect(){return ct(this,void 0,void 0,function*(){if(this.connectCalled)return;this.connectCalled=!0,this.pingUpdateTimeout=setInterval(()=>{const{reliableStreamChannel:ie}=this;ie&&this.sendSystemMessage(ie,{type:"ping"})},this.pingUpdateTimeoutMs),this.connectTimeout=setTimeout(()=>ct(this,void 0,void 0,function*(){this.isReady()||(g.a.warn("RTC connect timed out, closing connection"),yield this.close())}),this.connectTimeoutMs);const{peerConnection:D,config:{isOffer:H,sessionId:X}}=this;if(H){const ie=yield D.createOffer();yield D.setLocalDescription(ie)}H&&(this.gatherIceTimeout=setTimeout(()=>ct(this,void 0,void 0,function*(){this.sentOffer||(g.a.warn("ICE gathering timed out"),this.receivedIceCandidate?(g.a.warn("Attempting to connect with partial ICE candidate pool"),yield this.sendOffer()):yield this.close())}),this.gatherIceTimeoutMs),D.onicecandidate=ie=>ct(this,void 0,void 0,function*(){ie.candidate?this.receivedIceCandidate=!0:yield this.sendOffer()}),D.onicegatheringstatechange=()=>ct(this,void 0,void 0,function*(){D.iceGatheringState==="complete"&&(yield this.sendOffer())}),D.onnegotiationneeded=()=>{g.a.debug("Negotiation needed",{sessionId:X})})})}handleSignal(D){return ct(this,void 0,void 0,function*(){const{peerConnection:H,config:{sessionId:X,sendSignal:ie}}=this,{description:oe}=JSON.parse(D.payload);if(g.a.debug("Handling signal",{sessionId:X,description:JSON.stringify(oe)}),oe)if(H.signalingState!=="stable"||H.connectionState!=="connected")if(H.remoteDescription)g.a.warn(`Received SDP signal during negotiation when remote description is already set: ${JSON.stringify(D)}`);else if(oe.type==="offer"){yield H.setRemoteDescription(oe);const de=yield H.createAnswer();yield H.setLocalDescription(de),yield ie({payload:JSON.stringify({description:de})})}else oe.type==="answer"&&(yield H.setRemoteDescription(oe));else g.a.warn(`Received SDP signal when signaling is stable and connected: ${JSON.stringify(D)}`);else g.a.warn(`Received non-SDP signal: ${JSON.stringify(D)}`)})}send(D,H){const X=this.getChannelFromLabel(H.channelLabel);X?this.sendOnChannel(X,D):g.a.warn("Send called with unexpected channel label",{channelLabel:H.channelLabel})}controlRemoteStream(D){this.sendSystemMessage(p(this.reliableStreamChannel),{type:"stream-control",streamControl:D})}isActive(){return new Set(["new","connecting","connected"]).has(this.peerConnection.connectionState)}isReady(){const{peerConnection:D,latestTtlStreamChannel:H,reliableStreamChannel:X,latestTryOnceStreamChannel:ie}=this;return!!(X&&H&&ie)&&D.connectionState==="connected"&&X.readyState==="open"&&H.readyState==="open"&&ie.readyState==="open"}isClosed(){const{peerConnection:D,reliableStreamChannel:H,latestTryOnceStreamChannel:X,latestTtlStreamChannel:ie}=this;return!(D.connectionState!=="closed"||H!==void 0&&H.readyState!=="closed"||X!==void 0&&X.readyState!=="closed"||ie!==void 0&&ie.readyState!=="closed")}needsClosing(){const{peerConnection:D,latestTtlStreamChannel:H,reliableStreamChannel:X,latestTryOnceStreamChannel:ie}=this;if(this.isClosed())return!1;const oe=new Set(["closing","closed"]),de=ye=>ye&&oe.has(ye.readyState);return qe(D)||de(H)||de(X)||de(ie)}close(){return ct(this,void 0,void 0,function*(){this.closeCalled||(this.closeCalled=!0,yield this.sessionMetrics.uploadMetrics(),this.pingUpdateTimeout&&clearInterval(this.pingUpdateTimeout),this.connectTimeout&&clearTimeout(this.connectTimeout),this.gatherIceTimeout&&clearTimeout(this.gatherIceTimeout),this.peerConnection.close())})}getPing(){return this.pingTimeMs}getLastMessageTimestamp(){return this.lastMessageTimestamp}getSessionId(){return this.config.sessionId}getRemotePeer(){return this.config.remotePeer}initializeChannels(D){this.latestTtlStreamChannel=D.createDataChannel("stream.latest-ttl",B),this.reliableStreamChannel=D.createDataChannel("stream.reliable",J),this.latestReliableStreamChannel=D.createDataChannel("stream.latest-reliable",K),this.latestTryOnceStreamChannel=D.createDataChannel("stream.latest-try-once",re),this.setupChannel(this.latestTtlStreamChannel),this.setupChannel(this.reliableStreamChannel),this.setupChannel(this.latestReliableStreamChannel),this.setupChannel(this.latestTryOnceStreamChannel)}sendOffer(){return ct(this,void 0,void 0,function*(){if(this.sentOffer||(this.sentOffer=!0,qe(this.peerConnection)))return;const{peerConnection:D,config:{sendSignal:H}}=this,X=yield D.createOffer();yield D.setLocalDescription(X);const ie={payload:JSON.stringify({description:X})};yield H(ie)})}getChannelFromLabel(D){switch(D){case"stream.latest-ttl":return this.latestTtlStreamChannel;case"stream.reliable":return this.reliableStreamChannel;case"stream.latest-reliable":return this.latestReliableStreamChannel;case"stream.latest-try-once":return this.latestTryOnceStreamChannel}}sendOnChannel(D,H){let X;try{X=Object(T.encode)(JSON.stringify(H))}catch(ie){return void g.a.warn("Failed to encode RTC message",{error:ie})}try{D.send(X),this.sessionMetrics.incrementMessageSent(H)}catch(ie){g.a.warn("Failed to send message to channel",{error:ie,channel:D.label})}}channelNotRecognized(D){return D!==this.latestTtlStreamChannel&&D!==this.latestReliableStreamChannel&&D!==this.latestTryOnceStreamChannel&&D!==this.reliableStreamChannel}setupChannel(D){D.onmessage=H=>{if(this.channelNotRecognized(D))return void g.a.warn("Received message on unrecognized data channel.");let X;try{X=JSON.parse(Object(T.decode)(H.data))}catch(ie){return void g.a.warn("Received unparseable RTC message",{error:ie,channel:D.label})}if(this.lastMessageTimestamp=new Date().getTime(),X=tt(X),this.sessionMetrics.incrementMessageReceived(X),!this.handleSystemMessage(D,X)){if(!this.hasCapabilities(X))return void g.a.warn("Received RTC message that was not within the capability scope of the connection.");(D===this.latestTryOnceStreamChannel||D===this.latestTtlStreamChannel||D===this.latestReliableStreamChannel)&&!this.isLatestMessage(X)||this.config.receive(this.config.remotePeer.id,X)}},D.onerror=H=>{g.a.warn(`Channel error: ${H.error}`,{error:H.error,sessionId:this.getSessionId(),channelLabel:D.label})},D.onopen=()=>{g.a.debug("Channel opened",{sessionId:this.getSessionId(),channelLabel:D.label})},D.onclose=()=>{const H={bufferedAmount:D.bufferedAmount,sessionId:this.getSessionId(),channelLabel:D.label};this.closeCalled===!1?g.a.debug("Unexpected channel closed",H):g.a.debug("Channel closed",H)}}handleSystemMessage(D,H){switch(H.header.stream.streamType){case"ping":return this.sendSystemMessage(D,{type:"pong",timestamp:p(H.payload.ping)}),!0;case"pong":{const X=new Date().getTime()-p(H.payload.pong);return this.pingTimeMs=X,y.aggregate("rtc-ping-time",X),!0}case"stream-control":return!0;default:return!1}}sendSystemMessage(D,H){if(D.readyState!=="open")return;const X={entityId:p(this.config.localPeer.deviceId||this.config.localPeer.userId),streamName:`$.${H.type}`,streamType:H.type};let ie;switch(H.type){case"ping":ie={ping:new Date().getTime()};break;case"pong":ie={pong:H.timestamp};break;case"stream-control":ie={streamControl:H.streamControl}}this.sendOnChannel(D,Pe(X,ie))}hasCapabilities(D){var H,X;const{localPeer:ie,remotePeer:oe}=this.config,de=(H=ie.capabilitySet.streaming)===null||H===void 0?void 0:H.streams,ye=de&&de.some(le=>le.receive&&Mt(le.stream,D.header.stream)),be=(X=oe.capabilitySet.streaming)===null||X===void 0?void 0:X.streams,ce=be&&be.some(le=>le.send&&Mt(le.stream,D.header.stream));return ye||ce}isLatestMessage(D){const H=Ce(D.header.stream),X=(this.streamLatestTimestamp.get(H)||0)<=D.header.created;return X&&this.streamLatestTimestamp.set(H,D.header.created),X}}var Ue=function(pe,D,H,X){return new(H||(H=Promise))(function(ie,oe){function de(ce){try{be(X.next(ce))}catch(le){oe(le)}}function ye(ce){try{be(X.throw(ce))}catch(le){oe(le)}}function be(ce){var le;ce.done?ie(ce.value):(le=ce.value,le instanceof H?le:new H(function(Re){Re(le)})).then(de,ye)}be((X=X.apply(pe,D||[])).next())})};class Rt{constructor(D){this.config=D,this.connections=[],this.connectingSessions=new Map,this.rtcInstancesConstructed=0,this.updateInterval=d({func:()=>Ue(this,void 0,void 0,function*(){try{yield this.update()}catch(H){g.a.warn("RTC update failed",{error:H})}}),delay:250*c.a.millisecond,immediate:!0}),this.localPeer=this.createPeer()}send(D,H,X){const ie=this.getActiveConnection(D);ie?ie.isReady()?ie.send(H,X):g.a.warn("Attempted to send with an active connection to that peer which was not yet ready."):g.a.warn("Attempted to send with no active connection to that peer.")}controlRemoteStream(D,H){const X=this.getActiveConnection(D);X?X.isReady()?X.controlRemoteStream(H):g.a.warn("Attempted to control remote stream with an active connection to that peer which was not yet ready."):g.a.warn("Attempted to control remote stream with no active connection to that peer.")}connect(D){return Ue(this,void 0,void 0,function*(){const H=yield this.getLocalPeer();if(this.getActiveConnection(D))return void g.a.warn("Attempted to connect to peer with an already active connection.");let X;try{X=yield this.config.signalingClient.createSession(yield this.config.getToken(),{offerPeerId:H.id,answerPeerId:D})}catch(ie){Object(ot.a)(ie,nt.a,oe=>oe.statusCode===404),g.a.warn("Attempted to connect to peer that does not exist.")}if(X)for(this.connectingSessions.set(X.id,new Date().getTime()),yield this.connectToSession(X);;)switch(yield Object(u.a)(.1),this.getConnectionStatus(D)){case"connecting":continue;case"connected":return X.id;case"disconnected":return}})}getConnectionStatus(D){const H=this.getActiveConnection(D);return H?H.isReady()?"connected":"connecting":"disconnected"}getIceMode(D){const H=this.getActiveConnection(D);if(H)return H.iceMode}disconnect(D){return Ue(this,void 0,void 0,function*(){const H=this.getActiveConnection(D);H&&(yield this.closeConnection(H))})}getLocalPeer(){return Ue(this,void 0,void 0,function*(){return yield this.localPeer})}getPeers(){return Ue(this,void 0,void 0,function*(){return yield this.config.signalingClient.getPeers(yield this.config.getToken())})}getPing(D){const H=this.getActiveConnection(D);if(H)return H.getPing();g.a.warn("Attempted to get ping time from inactive peer.")}getLastMessageTimestamp(D){const H=this.getActiveConnection(D);if(H)return H.getLastMessageTimestamp();g.a.warn("Attempted to get ping time from inactive peer.")}shutdown(){return Ue(this,void 0,void 0,function*(){yield this.updateInterval.stop();const D=this.connections;this.connections=[],yield this.closeConnections(D)})}closeConnection(D){return Ue(this,void 0,void 0,function*(){this.connectingSessions.delete(D.getSessionId()),yield D.close();try{yield this.config.signalingClient.deleteSession(yield this.config.getToken(),D.getSessionId())}catch(H){Object(ot.a)(H,nt.a,X=>X.statusCode===404)}})}getSessions(){return Ue(this,void 0,void 0,function*(){const D=yield this.getLocalPeer();return(yield this.config.signalingClient.getSessions(yield this.config.getToken())).filter(H=>H.offer.peer.id===D.id||H.answer.peer.id===D.id)})}createPeer(){return Ue(this,void 0,void 0,function*(){return yield this.config.signalingClient.createPeer(yield this.config.getToken(),{capabilitySet:this.config.capabilitySet||{}})})}createRTCPeerConnection(D={}){return Ue(this,void 0,void 0,function*(){const H=this.config.alternateRTCPeerConnection||RTCPeerConnection;this.rtcInstancesConstructed++,this.rtcInstancesConstructed%20||vt();try{return new H(Object.assign({iceServers:yield this.config.signalingClient.getIceServers(yield this.config.getToken())},D))}catch(X){throw g.a.debug(`Failed to create RTCPeerConnection: ${this.rtcInstancesConstructed} total allocated`),X}})}closeConnections(D){return Ue(this,void 0,void 0,function*(){const H=yield O(D.map(X=>Ue(this,void 0,void 0,function*(){yield this.closeConnection(X)})));for(const X of H)g.a.warn("Request to close session failed",{error:X})})}reset(){return Ue(this,void 0,void 0,function*(){yield this.closeConnections(this.connections),this.connections=[],this.connectingSessions=new Map,this.localPeer=this.createPeer(),yield this.localPeer})}getActiveConnection(D){return this.connections.find(H=>H.getRemotePeer().id===D&&H.isActive())}update(){return Ue(this,void 0,void 0,function*(){const D=yield this.getLocalPeer();try{yield this.config.signalingClient.refreshPeer(yield this.config.getToken(),D.id)}catch(H){Object(ot.a)(H,nt.a,X=>X.statusCode===404),g.a.warn("Peer expired, creating new peer",{peerId:D.id}),yield this.reset()}yield this.handleSessions(yield this.getSessions())})}handleSessions(D){return Ue(this,void 0,void 0,function*(){yield this.syncConnectionsAndSessions(D);const H=D.map(X=>({session:X,connection:this.connections.find(ie=>ie.getSessionId()===X.id)}));yield Promise.all(H.map(({session:X,connection:ie})=>Ue(this,void 0,void 0,function*(){return yield this.maintainConnection(X,ie)})))})}syncConnectionsAndSessions(D){return Ue(this,void 0,void 0,function*(){const H=new Set(D.map(oe=>oe.id)),X=oe=>H.has(oe.getSessionId())||this.connectingSessions.has(oe.getSessionId());this.connections=this.connections.filter(oe=>X(oe));const ie=this.connections.filter(oe=>!X(oe)||oe.needsClosing());yield Promise.all(ie.map(oe=>Ue(this,void 0,void 0,function*(){yield this.closeConnection(oe)})))})}maintainConnection(D,H){return Ue(this,void 0,void 0,function*(){const X=yield this.getLocalPeer(),ie=D.offer.peer.id===X.id;if(H){if(H.isReady())try{yield this.config.signalingClient.refreshSession(yield this.config.getToken(),D.id)}catch(oe){Object(ot.a)(oe,nt.a,de=>de.statusCode===404),g.a.debug("Refresh session not found",{sessionId:D.id})}else if(H.isActive())try{yield this.consumeSignals(H)}catch(oe){g.a.warn("Failed to ingest signals, closing connection",{error:oe}),yield this.closeConnection(H)}}else{if(ie)return;yield this.connectToSession(D)}})}connectToSession(D){return Ue(this,void 0,void 0,function*(){const H=yield this.getLocalPeer(),X=D.offer.peer.id===H.id,ie=yield this.createRTCPeerConnection(),oe=new At(ie,{localPeer:X?D.offer.peer:D.answer.peer,remotePeer:X?D.answer.peer:D.offer.peer,sessionId:D.id,isOffer:X,sendSignal:de=>this.sendSignal(D.id,de),receive:(de,ye)=>this.config.receive(de,ye)});if(this.connections.find(de=>de.getSessionId()===D.id))return g.a.warn("connectToSession called on a session that already has a connection.",{sessionId:D.id}),void(yield oe.close());this.setupHandlers(oe),this.connections.push(oe);try{yield oe.connect()}catch(de){g.a.warn("Failed to handle negotiation, closing connection",{error:de}),yield this.closeConnection(oe)}})}setupHandlers(D){const{peerConnection:H}=D,X=D.getSessionId();H.onconnectionstatechange=()=>Ue(this,void 0,void 0,function*(){const ie=this.connectingSessions.get(X);if(ie===void 0)return;const oe=H.connectionState;switch(qe(H)&&this.connectingSessions.delete(X),oe){case"connected":{this.connectingSessions.delete(X);const de=new Date().getTime()-ie;y.aggregate("rtc-connect-time",de);break}case"failed":y.increment("rtc-connect-failed"),yield this.closeConnection(D)}})}consumeSignals(D){return Ue(this,void 0,void 0,function*(){let H=[];try{H=yield this.config.signalingClient.takeSignals(yield this.config.getToken(),D.getSessionId())}catch(X){Object(ot.a)(X,nt.a,ie=>ie.statusCode===404)}for(const X of H)yield D.handleSignal(X)})}sendSignal(D,H){return Ue(this,void 0,void 0,function*(){try{yield this.config.signalingClient.addSignals(yield this.config.getToken(),D,{signals:[H]})}catch(X){Object(ot.a)(X,nt.a,ie=>ie.statusCode===404)}})}}},function(e,t,n){var r={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let i;const s=new Uint8Array(16);function l(){if(!i&&(i=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!i))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(s)}const o=[];for(let u=0;u<256;++u)o.push((u+256).toString(16).slice(1));function c(u,f=0){return(o[u[f+0]]+o[u[f+1]]+o[u[f+2]]+o[u[f+3]]+"-"+o[u[f+4]]+o[u[f+5]]+"-"+o[u[f+6]]+o[u[f+7]]+"-"+o[u[f+8]]+o[u[f+9]]+"-"+o[u[f+10]]+o[u[f+11]]+o[u[f+12]]+o[u[f+13]]+o[u[f+14]]+o[u[f+15]]).toLowerCase()}t.a=function(u,f,E){if(r.randomUUID&&!f&&!u)return r.randomUUID();const _=(u=u||{}).random||(u.rng||l)();if(_[6]=15&_[6]|64,_[8]=63&_[8]|128,f){E=E||0;for(let h=0;h<16;++h)f[E+h]=_[h];return f}return c(_)}},,function(e,t,n){n.r(t),n.d(t,"LogClient",function(){return o});var r=n(28),i=n(11),s=n(10),l=function(c,u,f,E){return new(f||(f=Promise))(function(_,h){function g(j){try{A(E.next(j))}catch(F){h(F)}}function b(j){try{A(E.throw(j))}catch(F){h(F)}}function A(j){var F;j.done?_(j.value):(F=j.value,F instanceof f?F:new f(function(M){M(F)})).then(g,b)}A((E=E.apply(c,u||[])).next())})};class o extends r.a{log(u){return l(this,void 0,void 0,function*(){const f=o.token;try{yield this.fetch("logs",{token:f,method:"POST",body:JSON.stringify({logs:u}),allowUnsafeRetries:!0})}catch(E){Object(i.a)(E,s.a,_=>_.statusCode===401&&f!==void 0),o.token===f&&delete o.token,yield this.log(u)}})}}}])})})(dist);var distExports=dist.exports;const SessionTypes={UNKNOWN:0,TELEOP:1,PORT_FORWARD:2,OBSERVE:3},SessionTypeConstants={...SessionTypes,Unknown:SessionTypes.UNKNOWN,Teleop:SessionTypes.TELEOP,PortForward:SessionTypes.PORT_FORWARD,Observe:SessionTypes.OBSERVE,unknown:SessionTypes.UNKNOWN,teleop:SessionTypes.TELEOP,portForward:SessionTypes.PORT_FORWARD,observe:SessionTypes.OBSERVE},singleton=Symbol("RtcClientPool.instance");class RtcClientPool{constructor(t){Te(this,it,null);Te(this,"createClient");Te(this,"ttlMs");Te(this,"proxyHandler");Te(this,"proxyReceivers",new Map);Te(this,"teardownTimeout",null);Te(this,"dispatch",(t,n)=>{this.proxyReceivers.forEach(r=>r==null?void 0:r(t,n))});const{createClient:n,ttlMs:r=0}=t;this.createClient=n,this.ttlMs=Math.max(r,0),this.proxyHandler={get:(i,s,l)=>{switch(s){case"shutdown":return()=>this.releaseInstance(l);default:return Reflect.get(i,s,l)}}}}get isActive(){return this[singleton]!==null}get size(){return this.proxyReceivers.size}get(t){const n=new Proxy(this.allocate(),this.proxyHandler);return this.proxyReceivers.set(n,t??null),n}allocate(){if(this[singleton])return this.teardownTimeout&&(clearTimeout(this.teardownTimeout),this.teardownTimeout=null),this[singleton];const t=this.createClient(this.dispatch);return this[singleton]=t,t}async teardown(){const t=this[singleton];if(!t){console.warn("singleton has already been shutdown!");return}try{await t.shutdown()}finally{this[singleton]=null}}async releaseInstance(t){return this.proxyReceivers.delete(t)?this.proxyReceivers.size!==0?!1:(!this.teardownTimeout&&Number.isFinite(this.ttlMs)&&(this.ttlMs===0?await this.teardown():this.teardownTimeout=setTimeout(()=>{this.teardown().catch(n=>console.error("teardown failed",{err:n})).finally(()=>this.teardownTimeout=null)},this.ttlMs)),!0):(console.warn("this instance has already been released!"),!1)}}it=singleton;const getToken=async()=>defined(Authentication.token,"Realtime when user isn't authorized"),EnumRtcClientPools={[SessionTypes.UNKNOWN]:new RtcClientPool({ttlMs:2500,createClient:e=>new distExports.RtcClient({signalingClient:new distExports.SignalingPromiseClient(FORMANT_API_URL),getToken,sessionType:SessionTypes.UNKNOWN,receive:e})}),[SessionTypes.TELEOP]:new RtcClientPool({ttlMs:2500,createClient:e=>new distExports.RtcClient({signalingClient:new distExports.SignalingPromiseClient(FORMANT_API_URL),getToken,sessionType:SessionTypes.TELEOP,receive:e})}),[SessionTypes.PORT_FORWARD]:new RtcClientPool({ttlMs:2500,createClient:e=>new distExports.RtcClient({signalingClient:new distExports.SignalingPromiseClient(FORMANT_API_URL),getToken,sessionType:SessionTypes.PORT_FORWARD,receive:e})}),[SessionTypes.OBSERVE]:new RtcClientPool({ttlMs:2500,createClient:e=>new distExports.RtcClient({signalingClient:new distExports.SignalingPromiseClient(FORMANT_API_URL),getToken,sessionType:SessionTypes.OBSERVE,receive:e})})},AppRtcClientPools={...EnumRtcClientPools,unknown:EnumRtcClientPools[SessionTypes.UNKNOWN],teleop:EnumRtcClientPools[SessionTypes.TELEOP],portForward:EnumRtcClientPools[SessionTypes.PORT_FORWARD],observe:EnumRtcClientPools[SessionTypes.OBSERVE]},defaultRtcClientPool=EnumRtcClientPools[SessionTypes.TELEOP],getRtcClientPool=e=>{const{sessionType:t}=e;return t?AppRtcClientPools[t]:defaultRtcClientPool};class CaptureStream{constructor(t){Te(this,"token");this.captureSession=t}async ingestJSON(t){if(!this.token){const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions/${this.captureSession.code}/authenticate`,{method:"POST"})).json();this.token=r.token}await fetch(`${FORMANT_API_URL}/v1/ingest`,{method:"POST",body:JSON.stringify({deviceId:this.captureSession.deviceId,name:this.captureSession.streamName,type:"json",points:[[Date.now(),JSON.stringify(t)]]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+this.token}})}}function delay(e){return new Promise(t=>setTimeout(t,e))}const vailableAggregationIntervals=["day","week","month","year","hour","minute","quarter"],aggregateFunctions=["interval","start","end","sub","get"];function getVariance(e){return e.count<2?0:e.sumOfSquares/(e.count-1)}function getStandardDeviation(e){return Math.sqrt(getVariance(e))}function getMax(e){return e.max}function getMin(e){return e.min}function getAverage(e){return e.count===0?-1:e.sum/e.count}function getSum(e){return e.sum}function getCount(e){return e.count}const aggregateFunctionMap={min:getMin,max:getMax,"standard deviation":getStandardDeviation,average:getAverage,sum:getSum,count:getCount},aggregateByDateFunctions={day:{interval:dateFns__namespace.eachDayOfInterval,start:dateFns__namespace.startOfDay,end:dateFns__namespace.endOfDay,sub:dateFns__namespace.subDays,get:dateFns__namespace.getDay},week:{interval:dateFns__namespace.eachWeekOfInterval,start:dateFns__namespace.startOfWeek,end:dateFns__namespace.endOfWeek,sub:dateFns__namespace.subWeeks,get:dateFns__namespace.getWeek},month:{interval:dateFns__namespace.eachMonthOfInterval,start:dateFns__namespace.startOfMonth,end:dateFns__namespace.endOfMonth,sub:dateFns__namespace.subMonths,get:dateFns__namespace.getMonth},year:{interval:dateFns__namespace.eachYearOfInterval,start:dateFns__namespace.startOfYear,end:dateFns__namespace.endOfYear,sub:dateFns__namespace.subYears,get:dateFns__namespace.getYear},hour:{interval:dateFns__namespace.eachHourOfInterval,start:dateFns__namespace.startOfHour,end:dateFns__namespace.endOfHour,sub:dateFns__namespace.subHours,get:dateFns__namespace.getHours},minute:{interval:dateFns__namespace.eachMinuteOfInterval,start:dateFns__namespace.startOfMinute,end:dateFns__namespace.endOfMinute,sub:dateFns__namespace.subMinutes,get:dateFns__namespace.getMinutes},quarter:{interval:dateFns__namespace.eachQuarterOfInterval,start:dateFns__namespace.startOfQuarter,end:dateFns__namespace.endOfQuarter,sub:dateFns__namespace.subQuarters,get:dateFns__namespace.getQuarter}},formatTimeFrameText=(e,t)=>e.split("/")[0]+"/"+e.split("/")[1]+"–"+t.split("/")[0]+"/"+t.split("/")[1];function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}var cachedSetTimeout=defaultSetTimout,cachedClearTimeout=defaultClearTimeout;typeof global$1.setTimeout=="function"&&(cachedSetTimeout=setTimeout),typeof global$1.clearTimeout=="function"&&(cachedClearTimeout=clearTimeout);function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch{try{return cachedSetTimeout.call(null,e,0)}catch{return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch{try{return cachedClearTimeout.call(null,e)}catch{return cachedClearTimeout.call(this,e)}}}var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){!draining||!currentQueue||(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}function nextTick(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];queue.push(new Item(e,t)),queue.length===1&&!draining&&runTimeout(drainQueue)}function Item(e,t){this.fun=e,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};var title="browser",platform="browser",browser$1=!0,env={},argv=[],version="",versions={},release={},config={};function noop(){}var on=noop,addListener=noop,once=noop,off=noop,removeListener=noop,removeAllListeners=noop,emit=noop;function binding$1(e){throw new Error("process.binding is not supported")}function cwd(){return"/"}function chdir(e){throw new Error("process.chdir is not supported")}function umask(){return 0}var performance$1=global$1.performance||{},performanceNow=performance$1.now||performance$1.mozNow||performance$1.msNow||performance$1.oNow||performance$1.webkitNow||function(){return new Date().getTime()};function hrtime(e){var t=performanceNow.call(performance$1)*.001,n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n=n-e[0],r=r-e[1],r<0&&(n--,r+=1e9)),[n,r]}var startTime=new Date;function uptime(){var e=new Date,t=e-startTime;return t/1e3}var browser$1$1={nextTick,title,browser:browser$1,env,argv,version,versions,on,addListener,once,off,removeListener,removeAllListeners,emit,binding:binding$1,cwd,chdir,umask,hrtime,platform,release,config,uptime},domain;function EventHandlers(){}EventHandlers.prototype=Object.create(null);function EventEmitter(){EventEmitter.init.call(this)}EventEmitter.EventEmitter=EventEmitter,EventEmitter.usingDomains=!1,EventEmitter.prototype.domain=void 0,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.init=function(){this.domain=null,EventEmitter.usingDomains&&domain.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new EventHandlers,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},EventEmitter.prototype.setMaxListeners=function e(t){if(typeof t!="number"||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this};function $getMaxListeners(e){return e._maxListeners===void 0?EventEmitter.defaultMaxListeners:e._maxListeners}EventEmitter.prototype.getMaxListeners=function e(){return $getMaxListeners(this)};function emitNone(e,t,n){if(t)e.call(n);else for(var r=e.length,i=arrayClone(e,r),s=0;s<r;++s)i[s].call(n)}function emitOne(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,s=arrayClone(e,i),l=0;l<i;++l)s[l].call(n,r)}function emitTwo(e,t,n,r,i){if(t)e.call(n,r,i);else for(var s=e.length,l=arrayClone(e,s),o=0;o<s;++o)l[o].call(n,r,i)}function emitThree(e,t,n,r,i,s){if(t)e.call(n,r,i,s);else for(var l=e.length,o=arrayClone(e,l),c=0;c<l;++c)o[c].call(n,r,i,s)}function emitMany(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,s=arrayClone(e,i),l=0;l<i;++l)s[l].apply(n,r)}EventEmitter.prototype.emit=function e(t){var n,r,i,s,l,o,c,u=t==="error";if(o=this._events,o)u=u&&o.error==null;else if(!u)return!1;if(c=this.domain,u){if(n=arguments[1],c)n||(n=new Error('Uncaught, unspecified "error" event')),n.domainEmitter=this,n.domain=c,n.domainThrown=!1,c.emit("error",n);else{if(n instanceof Error)throw n;var f=new Error('Uncaught, unspecified "error" event. ('+n+")");throw f.context=n,f}return!1}if(r=o[t],!r)return!1;var E=typeof r=="function";switch(i=arguments.length,i){case 1:emitNone(r,E,this);break;case 2:emitOne(r,E,this,arguments[1]);break;case 3:emitTwo(r,E,this,arguments[1],arguments[2]);break;case 4:emitThree(r,E,this,arguments[1],arguments[2],arguments[3]);break;default:for(s=new Array(i-1),l=1;l<i;l++)s[l-1]=arguments[l];emitMany(r,E,this,s)}return!0};function _addListener(e,t,n,r){var i,s,l;if(typeof n!="function")throw new TypeError('"listener" argument must be a function');if(s=e._events,s?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),l=s[t]):(s=e._events=new EventHandlers,e._eventsCount=0),!l)l=s[t]=n,++e._eventsCount;else if(typeof l=="function"?l=s[t]=r?[n,l]:[l,n]:r?l.unshift(n):l.push(n),!l.warned&&(i=$getMaxListeners(e),i&&i>0&&l.length>i)){l.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=t,o.count=l.length,emitWarning(o)}return e}function emitWarning(e){typeof console.warn=="function"?console.warn(e):console.log(e)}EventEmitter.prototype.addListener=function e(t,n){return _addListener(this,t,n,!1)},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.prependListener=function e(t,n){return _addListener(this,t,n,!0)};function _onceWrap(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}EventEmitter.prototype.once=function e(t,n){if(typeof n!="function")throw new TypeError('"listener" argument must be a function');return this.on(t,_onceWrap(this,t,n)),this},EventEmitter.prototype.prependOnceListener=function e(t,n){if(typeof n!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(t,_onceWrap(this,t,n)),this},EventEmitter.prototype.removeListener=function e(t,n){var r,i,s,l,o;if(typeof n!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(r=i[t],!r)return this;if(r===n||r.listener&&r.listener===n)--this._eventsCount===0?this._events=new EventHandlers:(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||n));else if(typeof r!="function"){for(s=-1,l=r.length;l-- >0;)if(r[l]===n||r[l].listener&&r[l].listener===n){o=r[l].listener,s=l;break}if(s<0)return this;if(r.length===1){if(r[0]=void 0,--this._eventsCount===0)return this._events=new EventHandlers,this;delete i[t]}else spliceOne(r,s);i.removeListener&&this.emit("removeListener",t,o||n)}return this},EventEmitter.prototype.removeAllListeners=function e(t){var n,r;if(r=this._events,!r)return this;if(!r.removeListener)return arguments.length===0?(this._events=new EventHandlers,this._eventsCount=0):r[t]&&(--this._eventsCount===0?this._events=new EventHandlers:delete r[t]),this;if(arguments.length===0){for(var i=Object.keys(r),s=0,l;s<i.length;++s)l=i[s],l!=="removeListener"&&this.removeAllListeners(l);return this.removeAllListeners("removeListener"),this._events=new EventHandlers,this._eventsCount=0,this}if(n=r[t],typeof n=="function")this.removeListener(t,n);else if(n)do this.removeListener(t,n[n.length-1]);while(n[0]);return this},EventEmitter.prototype.listeners=function e(t){var n,r,i=this._events;return i?(n=i[t],n?typeof n=="function"?r=[n.listener||n]:r=unwrapListeners(n):r=[]):r=[],r},EventEmitter.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):listenerCount$1.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount$1;function listenerCount$1(e){var t=this._events;if(t){var n=t[e];if(typeof n=="function")return 1;if(n)return n.length}return 0}EventEmitter.prototype.eventNames=function e(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function spliceOne(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}function arrayClone(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function unwrapListeners(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}var inherits;typeof Object.create=="function"?inherits=function(t,n){t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:inherits=function(t,n){t.super_=n;var r=function(){};r.prototype=n.prototype,t.prototype=new r,t.prototype.constructor=t};const inherits$1=inherits;var formatRegExp=/%[sdj%]/g;function format(e){if(!isString(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(inspect(arguments[n]));return t.join(" ")}for(var n=1,r=arguments,i=r.length,s=String(e).replace(formatRegExp,function(o){if(o==="%%")return"%";if(n>=i)return o;switch(o){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch{return"[Circular]"}default:return o}}),l=r[n];n<i;l=r[++n])isNull(l)||!isObject(l)?s+=" "+l:s+=" "+inspect(l);return s}function deprecate(e,t){if(isUndefined(global$1.process))return function(){return deprecate(e,t).apply(this,arguments)};if(browser$1$1.noDeprecation===!0)return e;var n=!1;function r(){if(!n){if(browser$1$1.throwDeprecation)throw new Error(t);browser$1$1.traceDeprecation?console.trace(t):console.error(t),n=!0}return e.apply(this,arguments)}return r}var debugs={},debugEnviron;function debuglog(e){if(isUndefined(debugEnviron)&&(debugEnviron=browser$1$1.env.NODE_DEBUG||""),e=e.toUpperCase(),!debugs[e])if(new RegExp("\\b"+e+"\\b","i").test(debugEnviron)){var t=0;debugs[e]=function(){var n=format.apply(null,arguments);console.error("%s %d: %s",e,t,n)}}else debugs[e]=function(){};return debugs[e]}function inspect(e,t){var n={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),isBoolean(t)?n.showHidden=t:t&&_extend(n,t),isUndefined(n.showHidden)&&(n.showHidden=!1),isUndefined(n.depth)&&(n.depth=2),isUndefined(n.colors)&&(n.colors=!1),isUndefined(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=stylizeWithColor),formatValue(n,e,n.depth)}inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(e,t){var n=inspect.styles[t];return n?"\x1B["+inspect.colors[n][0]+"m"+e+"\x1B["+inspect.colors[n][1]+"m":e}function stylizeNoColor(e,t){return e}function arrayToHash(e){var t={};return e.forEach(function(n,r){t[n]=!0}),t}function formatValue(e,t,n){if(e.customInspect&&t&&isFunction(t.inspect)&&t.inspect!==inspect&&!(t.constructor&&t.constructor.prototype===t)){var r=t.inspect(n,e);return isString(r)||(r=formatValue(e,r,n)),r}var i=formatPrimitive(e,t);if(i)return i;var s=Object.keys(t),l=arrayToHash(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),isError(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return formatError(t);if(s.length===0){if(isFunction(t)){var o=t.name?": "+t.name:"";return e.stylize("[Function"+o+"]","special")}if(isRegExp(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(isDate(t))return e.stylize(Date.prototype.toString.call(t),"date");if(isError(t))return formatError(t)}var c="",u=!1,f=["{","}"];if(isArray(t)&&(u=!0,f=["[","]"]),isFunction(t)){var E=t.name?": "+t.name:"";c=" [Function"+E+"]"}if(isRegExp(t)&&(c=" "+RegExp.prototype.toString.call(t)),isDate(t)&&(c=" "+Date.prototype.toUTCString.call(t)),isError(t)&&(c=" "+formatError(t)),s.length===0&&(!u||t.length==0))return f[0]+c+f[1];if(n<0)return isRegExp(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var _;return u?_=formatArray(e,t,n,l,s):_=s.map(function(h){return formatProperty(e,t,n,l,h,u)}),e.seen.pop(),reduceToSingleString(_,c,f)}function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(isNumber(t))return e.stylize(""+t,"number");if(isBoolean(t))return e.stylize(""+t,"boolean");if(isNull(t))return e.stylize("null","null")}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,t,n,r,i){for(var s=[],l=0,o=t.length;l<o;++l)hasOwnProperty(t,String(l))?s.push(formatProperty(e,t,n,r,String(l),!0)):s.push("");return i.forEach(function(c){c.match(/^\d+$/)||s.push(formatProperty(e,t,n,r,c,!0))}),s}function formatProperty(e,t,n,r,i,s){var l,o,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?c.set?o=e.stylize("[Getter/Setter]","special"):o=e.stylize("[Getter]","special"):c.set&&(o=e.stylize("[Setter]","special")),hasOwnProperty(r,i)||(l="["+i+"]"),o||(e.seen.indexOf(c.value)<0?(isNull(n)?o=formatValue(e,c.value,null):o=formatValue(e,c.value,n-1),o.indexOf(`
|
|
50
50
|
`)>-1&&(s?o=o.split(`
|
|
51
51
|
`).map(function(u){return" "+u}).join(`
|
|
52
52
|
`).substr(2):o=`
|
|
@@ -55,5 +55,5 @@ Found: ${s.toString().split(`
|
|
|
55
55
|
`))):o=e.stylize("[Circular]","special")),isUndefined(l)){if(s&&i.match(/^\d+$/))return o;l=JSON.stringify(""+i),l.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(l=l.substr(1,l.length-2),l=e.stylize(l,"name")):(l=l.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),l=e.stylize(l,"string"))}return l+": "+o}function reduceToSingleString(e,t,n){var r=e.reduce(function(i,s){return s.indexOf(`
|
|
56
56
|
`)>=0,i+s.replace(/\u001b\[\d\d?m/g,"").length+1},0);return r>60?n[0]+(t===""?"":t+`
|
|
57
57
|
`)+" "+e.join(`,
|
|
58
|
-
`)+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return typeof e=="boolean"}function isNull(e){return e===null}function isNumber(e){return typeof e=="number"}function isString(e){return typeof e=="string"}function isUndefined(e){return e===void 0}function isRegExp(e){return isObject(e)&&objectToString(e)==="[object RegExp]"}function isObject(e){return typeof e=="object"&&e!==null}function isDate(e){return isObject(e)&&objectToString(e)==="[object Date]"}function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}function isFunction(e){return typeof e=="function"}function objectToString(e){return Object.prototype.toString.call(e)}function _extend(e,t){if(!t||!isObject(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function BufferList(){this.head=null,this.tail=null,this.length=0}BufferList.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},BufferList.prototype.unshift=function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length},BufferList.prototype.shift=function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},BufferList.prototype.clear=function(){this.head=this.tail=null,this.length=0},BufferList.prototype.join=function(e){if(this.length===0)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},BufferList.prototype.concat=function(e){if(this.length===0)return Buffer.alloc(0);if(this.length===1)return this.head.data;for(var t=Buffer.allocUnsafe(e>>>0),n=this.head,r=0;n;)n.data.copy(t,r),r+=n.data.length,n=n.next;return t};var isBufferEncoding=Buffer.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function assertEncoding(e){if(e&&!isBufferEncoding(e))throw new Error("Unknown encoding: "+e)}function StringDecoder(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),assertEncoding(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=base64DetectIncompleteChar;break;default:this.write=passThroughWrite;return}this.charBuffer=new Buffer(6),this.charReceived=0,this.charLength=0}StringDecoder.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";e=e.slice(n,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var i=t.charCodeAt(t.length-1);if(i>=55296&&i<=56319){this.charLength+=this.surrogateSize,t="";continue}if(this.charReceived=this.charLength=0,e.length===0)return t;break}this.detectIncompleteChar(e);var r=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,r),r-=this.charReceived),t+=e.toString(this.encoding,0,r);var r=t.length-1,i=t.charCodeAt(r);if(i>=55296&&i<=56319){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),e.copy(this.charBuffer,0,0,s),t.substring(0,r)}return t},StringDecoder.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(t==1&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},StringDecoder.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t};function passThroughWrite(e){return e.toString(this.encoding)}function utf16DetectIncompleteChar(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Readable.ReadableState=ReadableState;var debug=debuglog("stream");inherits$1(Readable,EventEmitter);function prependListener(e,t,n){if(typeof e.prependListener=="function")return e.prependListener(t,n);!e._events||!e._events[t]?e.on(t,n):Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]}function listenerCount(e,t){return e.listeners(t).length}function ReadableState(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof Duplex&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new BufferList,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new StringDecoder(e.encoding),this.encoding=e.encoding)}function Readable(e){if(!(this instanceof Readable))return new Readable(e);this._readableState=new ReadableState(e,this),this.readable=!0,e&&typeof e.read=="function"&&(this._read=e.read),EventEmitter.call(this)}Readable.prototype.push=function(e,t){var n=this._readableState;return!n.objectMode&&typeof e=="string"&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=Buffer.from(e,t),t="")),readableAddChunk(this,n,e,t,!1)},Readable.prototype.unshift=function(e){var t=this._readableState;return readableAddChunk(this,t,e,"",!0)},Readable.prototype.isPaused=function(){return this._readableState.flowing===!1};function readableAddChunk(e,t,n,r,i){var s=chunkInvalid(t,n);if(s)e.emit("error",s);else if(n===null)t.reading=!1,onEofChunk(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var l=new Error("stream.push() after EOF");e.emit("error",l)}else if(t.endEmitted&&i){var o=new Error("stream.unshift() after end event");e.emit("error",o)}else{var c;t.decoder&&!i&&!r&&(n=t.decoder.write(n),c=!t.objectMode&&n.length===0),i||(t.reading=!1),c||(t.flowing&&t.length===0&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&emitReadable(e))),maybeReadMore(e,t)}else i||(t.reading=!1);return needMoreData(t)}function needMoreData(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}Readable.prototype.setEncoding=function(e){return this._readableState.decoder=new StringDecoder(e),this._readableState.encoding=e,this};var MAX_HWM=8388608;function computeNewHighWaterMark(e){return e>=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Readable.prototype.read=function(e){debug("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return debug("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?endReadable(this):emitReadable(this),null;if(e=howMuchToRead(e,t),e===0&&t.ended)return t.length===0&&endReadable(this),null;var r=t.needReadable;debug("need readable",r),(t.length===0||t.length-e<t.highWaterMark)&&(r=!0,debug("length less than watermark",r)),t.ended||t.reading?(r=!1,debug("reading or ended",r)):r&&(debug("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=howMuchToRead(n,t)));var i;return e>0?i=fromList(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&endReadable(this)),i!==null&&this.emit("data",i),i};function chunkInvalid(e,t){var n=null;return!Buffer.isBuffer(t)&&typeof t!="string"&&t!==null&&t!==void 0&&!e.objectMode&&(n=new TypeError("Invalid non-string/buffer chunk")),n}function onEofChunk(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,emitReadable(e)}}function emitReadable(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?nextTick(emitReadable_,e):emitReadable_(e))}function emitReadable_(e){debug("emit readable"),e.emit("readable"),flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,nextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(debug("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}Readable.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Readable.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e);break}r.pipesCount+=1,debug("pipe count=%d opts=%j",r.pipesCount,t);var i=!t||t.end!==!1,s=i?o:f;r.endEmitted?nextTick(s):n.once("end",s),e.on("unpipe",l);function l(j){debug("onunpipe"),j===n&&f()}function o(){debug("onend"),e.end()}var c=pipeOnDrain(n);e.on("drain",c);var u=!1;function f(){debug("cleanup"),e.removeListener("close",g),e.removeListener("finish",b),e.removeListener("drain",c),e.removeListener("error",h),e.removeListener("unpipe",l),n.removeListener("end",o),n.removeListener("end",f),n.removeListener("data",_),u=!0,r.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var E=!1;n.on("data",_);function _(j){debug("ondata"),E=!1;var F=e.write(j);F===!1&&!E&&((r.pipesCount===1&&r.pipes===e||r.pipesCount>1&&indexOf(r.pipes,e)!==-1)&&!u&&(debug("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,E=!0),n.pause())}function h(j){debug("onerror",j),A(),e.removeListener("error",h),listenerCount(e,"error")===0&&e.emit("error",j)}prependListener(e,"error",h);function g(){e.removeListener("finish",b),A()}e.once("close",g);function b(){debug("onfinish"),e.removeListener("close",g),A()}e.once("finish",b);function A(){debug("unpipe"),n.unpipe(e)}return e.emit("pipe",n),r.flowing||(debug("pipe resume"),n.resume()),e};function pipeOnDrain(e){return function(){var t=e._readableState;debug("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&e.listeners("data").length&&(t.flowing=!0,flow(e))}}Readable.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<r;i++)n[i].emit("unpipe",this);return this}var s=indexOf(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},Readable.prototype.on=function(e,t){var n=EventEmitter.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var r=this._readableState;!r.endEmitted&&!r.readableListening&&(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&emitReadable(this):nextTick(nReadingNextTick,this))}return n},Readable.prototype.addListener=Readable.prototype.on;function nReadingNextTick(e){debug("readable nexttick read 0"),e.read(0)}Readable.prototype.resume=function(){var e=this._readableState;return e.flowing||(debug("resume"),e.flowing=!0,resume(this,e)),this};function resume(e,t){t.resumeScheduled||(t.resumeScheduled=!0,nextTick(resume_,e,t))}function resume_(e,t){t.reading||(debug("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),flow(e),t.flowing&&!t.reading&&e.read(0)}Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function flow(e){var t=e._readableState;for(debug("flow",t.flowing);t.flowing&&e.read()!==null;);}Readable.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(debug("wrapped end"),t.decoder&&!t.ended){var l=t.decoder.end();l&&l.length&&r.push(l)}r.push(null)}),e.on("data",function(l){if(debug("wrapped data"),t.decoder&&(l=t.decoder.write(l)),!(t.objectMode&&l==null)&&!(!t.objectMode&&(!l||!l.length))){var o=r.push(l);o||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=function(l){return function(){return e[l].apply(e,arguments)}}(i));var s=["error","close","destroy","pause","resume"];return forEach(s,function(l){e.on(l,r.emit.bind(r,l))}),r._read=function(l){debug("wrapped _read",l),n&&(n=!1,e.resume())},r},Readable._fromList=fromList;function fromList(e,t){if(t.length===0)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(t.decoder?n=t.buffer.join(""):t.buffer.length===1?n=t.buffer.head.data:n=t.buffer.concat(t.length),t.buffer.clear()):n=fromListPartial(e,t.buffer,t.decoder),n}function fromListPartial(e,t,n){var r;return e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?r=t.shift():r=n?copyFromBufferString(e,t):copyFromBuffer(e,t),r}function copyFromBufferString(e,t){var n=t.head,r=1,i=n.data;for(e-=i.length;n=n.next;){var s=n.data,l=e>s.length?s.length:e;if(l===s.length?i+=s:i+=s.slice(0,e),e-=l,e===0){l===s.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(l));break}++r}return t.length-=r,i}function copyFromBuffer(e,t){var n=Buffer.allocUnsafe(e),r=t.head,i=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var s=r.data,l=e>s.length?s.length:e;if(s.copy(n,n.length-e,0,l),e-=l,e===0){l===s.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=s.slice(l));break}++i}return t.length-=i,n}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,nextTick(endReadableNT,t,e))}function endReadableNT(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function forEach(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n)}function indexOf(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}Writable.WritableState=WritableState,inherits$1(Writable,EventEmitter);function nop(){}function WriteReq(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function WritableState(e,t){Object.defineProperty(this,"buffer",{get:deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof Duplex&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:r,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(s){onwrite(t,s)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new CorkedRequest(this)}WritableState.prototype.getBuffer=function e(){for(var t=this.bufferedRequest,n=[];t;)n.push(t),t=t.next;return n};function Writable(e){if(!(this instanceof Writable)&&!(this instanceof Duplex))return new Writable(e);this._writableState=new WritableState(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev)),EventEmitter.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function writeAfterEnd(e,t){var n=new Error("write after end");e.emit("error",n),nextTick(t,n)}function validChunk(e,t,n,r){var i=!0,s=!1;return n===null?s=new TypeError("May not write null values to stream"):!Buffer.isBuffer(n)&&typeof n!="string"&&n!==void 0&&!t.objectMode&&(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),nextTick(r,s),i=!1),i}Writable.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return typeof t=="function"&&(n=t,t=null),Buffer.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),typeof n!="function"&&(n=nop),r.ended?writeAfterEnd(this,n):validChunk(this,r,e,n)&&(r.pendingcb++,i=writeOrBuffer(this,r,e,t,n)),i},Writable.prototype.cork=function(){var e=this._writableState;e.corked++},Writable.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest&&clearBuffer(this,e))},Writable.prototype.setDefaultEncoding=function e(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function decodeChunk(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Buffer.from(t,n)),t}function writeOrBuffer(e,t,n,r,i){n=decodeChunk(t,n,r),Buffer.isBuffer(n)&&(r="buffer");var s=t.objectMode?1:n.length;t.length+=s;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var o=t.lastBufferedRequest;t.lastBufferedRequest=new WriteReq(n,r,i),o?o.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else doWrite(e,t,!1,s,n,r,i);return l}function doWrite(e,t,n,r,i,s,l){t.writelen=r,t.writecb=l,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,s,t.onwrite),t.sync=!1}function onwriteError(e,t,n,r,i){--t.pendingcb,n?nextTick(i,r):i(r),e._writableState.errorEmitted=!0,e.emit("error",r)}function onwriteStateUpdate(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function onwrite(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(onwriteStateUpdate(n),t)onwriteError(e,n,r,t,i);else{var s=needFinish(n);!s&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&clearBuffer(e,n),r?nextTick(afterWrite,e,n,s,i):afterWrite(e,n,s,i)}}function afterWrite(e,t,n,r){n||onwriteDrain(e,t),t.pendingcb--,r(),finishMaybe(e,t)}function onwriteDrain(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function clearBuffer(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),s=t.corkedRequestsFree;s.entry=n;for(var l=0;n;)i[l]=n,n=n.next,l+=1;doWrite(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new CorkedRequest(t)}else{for(;n;){var o=n.chunk,c=n.encoding,u=n.callback,f=t.objectMode?1:o.length;if(doWrite(e,t,!1,f,o,c,u),n=n.next,t.writing)break}n===null&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=n,t.bufferProcessing=!1}Writable.prototype._write=function(e,t,n){n(new Error("not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,n){var r=this._writableState;typeof e=="function"?(n=e,e=null,t=null):typeof t=="function"&&(n=t,t=null),e!=null&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),!r.ending&&!r.finished&&endWritable(this,r,n)};function needFinish(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function prefinish(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function finishMaybe(e,t){var n=needFinish(t);return n&&(t.pendingcb===0?(prefinish(e,t),t.finished=!0,e.emit("finish")):prefinish(e,t)),n}function endWritable(e,t,n){t.ending=!0,finishMaybe(e,t),n&&(t.finished?nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}function CorkedRequest(e){var t=this;this.next=null,this.entry=null,this.finish=function(n){var r=t.entry;for(t.entry=null;r;){var i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}inherits$1(Duplex,Readable);for(var keys=Object.keys(Writable.prototype),v=0;v<keys.length;v++){var method=keys[v];Duplex.prototype[method]||(Duplex.prototype[method]=Writable.prototype[method])}function Duplex(e){if(!(this instanceof Duplex))return new Duplex(e);Readable.call(this,e),Writable.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",onend)}function onend(){this.allowHalfOpen||this._writableState.ended||nextTick(onEndNT,this)}function onEndNT(e){e.end()}inherits$1(Transform,Duplex);function TransformState(e){this.afterTransform=function(t,n){return afterTransform(e,t,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function afterTransform(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,n!=null&&e.push(n),i(t);var s=e._readableState;s.reading=!1,(s.needReadable||s.length<s.highWaterMark)&&e._read(s.highWaterMark)}function Transform(e){if(!(this instanceof Transform))return new Transform(e);Duplex.call(this,e),this._transformState=new TransformState(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.once("prefinish",function(){typeof this._flush=="function"?this._flush(function(n){done(t,n)}):done(t)})}Transform.prototype.push=function(e,t){return this._transformState.needTransform=!1,Duplex.prototype.push.call(this,e,t)},Transform.prototype._transform=function(e,t,n){throw new Error("Not implemented")},Transform.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},Transform.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};function done(e,t){if(t)return e.emit("error",t);var n=e._writableState,r=e._transformState;if(n.length)throw new Error("Calling transform done when ws.length != 0");if(r.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}inherits$1(PassThrough,Transform);function PassThrough(e){if(!(this instanceof PassThrough))return new PassThrough(e);Transform.call(this,e)}PassThrough.prototype._transform=function(e,t,n){n(null,e)},inherits$1(Stream,EventEmitter),Stream.Readable=Readable,Stream.Writable=Writable,Stream.Duplex=Duplex,Stream.Transform=Transform,Stream.PassThrough=PassThrough,Stream.Stream=Stream;function Stream(){EventEmitter.call(this)}Stream.prototype.pipe=function(e,t){var n=this;function r(f){e.writable&&e.write(f)===!1&&n.pause&&n.pause()}n.on("data",r);function i(){n.readable&&n.resume&&n.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(n.on("end",l),n.on("close",o));var s=!1;function l(){s||(s=!0,e.end())}function o(){s||(s=!0,typeof e.destroy=="function"&&e.destroy())}function c(f){if(u(),EventEmitter.listenerCount(this,"error")===0)throw f}n.on("error",c),e.on("error",c);function u(){n.removeListener("data",r),e.removeListener("drain",i),n.removeListener("end",l),n.removeListener("close",o),n.removeListener("error",c),e.removeListener("error",c),n.removeListener("end",u),n.removeListener("close",u),e.removeListener("close",u)}return n.on("end",u),n.on("close",u),e.on("close",u),e.emit("pipe",n),e};const msg={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function ZStream(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function arraySet(e,t,n,r,i){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),i);return}for(var s=0;s<r;s++)e[i+s]=t[n+s]}var Buf8=Uint8Array,Buf16=Uint16Array,Buf32=Int32Array,Z_FIXED$2=4,Z_BINARY$1=0,Z_TEXT$1=1,Z_UNKNOWN$2=2;function zero$1(e){for(var t=e.length;--t>=0;)e[t]=0}var STORED_BLOCK=0,STATIC_TREES=1,DYN_TREES=2,MIN_MATCH$1=3,MAX_MATCH$1=258,LENGTH_CODES$1=29,LITERALS$1=256,L_CODES$1=LITERALS$1+1+LENGTH_CODES$1,D_CODES$1=30,BL_CODES$1=19,HEAP_SIZE$1=2*L_CODES$1+1,MAX_BITS$1=15,Buf_size=16,MAX_BL_BITS=7,END_BLOCK=256,REP_3_6=16,REPZ_3_10=17,REPZ_11_138=18,extra_lbits=[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],extra_dbits=[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],extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],DIST_CODE_LEN=512,static_ltree=new Array((L_CODES$1+2)*2);zero$1(static_ltree);var static_dtree=new Array(D_CODES$1*2);zero$1(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero$1(_dist_code);var _length_code=new Array(MAX_MATCH$1-MIN_MATCH$1+1);zero$1(_length_code);var base_length=new Array(LENGTH_CODES$1);zero$1(base_length);var base_dist=new Array(D_CODES$1);zero$1(base_dist);function StaticTreeDesc(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var static_l_desc,static_d_desc,static_bl_desc;function TreeDesc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function d_code(e){return e<256?_dist_code[e]:_dist_code[256+(e>>>7)]}function put_short(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function send_bits(e,t,n){e.bi_valid>Buf_size-n?(e.bi_buf|=t<<e.bi_valid&65535,put_short(e,e.bi_buf),e.bi_buf=t>>Buf_size-e.bi_valid,e.bi_valid+=n-Buf_size):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function send_code(e,t,n){send_bits(e,n[t*2],n[t*2+1])}function bi_reverse(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function bi_flush(e){e.bi_valid===16?(put_short(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function gen_bitlen(e,t){var n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,s=t.stat_desc.has_stree,l=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,c=t.stat_desc.max_length,u,f,E,_,h,g,b=0;for(_=0;_<=MAX_BITS$1;_++)e.bl_count[_]=0;for(n[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;u<HEAP_SIZE$1;u++)f=e.heap[u],_=n[n[f*2+1]*2+1]+1,_>c&&(_=c,b++),n[f*2+1]=_,!(f>r)&&(e.bl_count[_]++,h=0,f>=o&&(h=l[f-o]),g=n[f*2],e.opt_len+=g*(_+h),s&&(e.static_len+=g*(i[f*2+1]+h)));if(b!==0){do{for(_=c-1;e.bl_count[_]===0;)_--;e.bl_count[_]--,e.bl_count[_+1]+=2,e.bl_count[c]--,b-=2}while(b>0);for(_=c;_!==0;_--)for(f=e.bl_count[_];f!==0;)E=e.heap[--u],!(E>r)&&(n[E*2+1]!==_&&(e.opt_len+=(_-n[E*2+1])*n[E*2],n[E*2+1]=_),f--)}}function gen_codes(e,t,n){var r=new Array(MAX_BITS$1+1),i=0,s,l;for(s=1;s<=MAX_BITS$1;s++)r[s]=i=i+n[s-1]<<1;for(l=0;l<=t;l++){var o=e[l*2+1];o!==0&&(e[l*2]=bi_reverse(r[o]++,o))}}function tr_static_init(){var e,t,n,r,i,s=new Array(MAX_BITS$1+1);for(n=0,r=0;r<LENGTH_CODES$1-1;r++)for(base_length[r]=n,e=0;e<1<<extra_lbits[r];e++)_length_code[n++]=r;for(_length_code[n-1]=r,i=0,r=0;r<16;r++)for(base_dist[r]=i,e=0;e<1<<extra_dbits[r];e++)_dist_code[i++]=r;for(i>>=7;r<D_CODES$1;r++)for(base_dist[r]=i<<7,e=0;e<1<<extra_dbits[r]-7;e++)_dist_code[256+i++]=r;for(t=0;t<=MAX_BITS$1;t++)s[t]=0;for(e=0;e<=143;)static_ltree[e*2+1]=8,e++,s[8]++;for(;e<=255;)static_ltree[e*2+1]=9,e++,s[9]++;for(;e<=279;)static_ltree[e*2+1]=7,e++,s[7]++;for(;e<=287;)static_ltree[e*2+1]=8,e++,s[8]++;for(gen_codes(static_ltree,L_CODES$1+1,s),e=0;e<D_CODES$1;e++)static_dtree[e*2+1]=5,static_dtree[e*2]=bi_reverse(e,5);static_l_desc=new StaticTreeDesc(static_ltree,extra_lbits,LITERALS$1+1,L_CODES$1,MAX_BITS$1),static_d_desc=new StaticTreeDesc(static_dtree,extra_dbits,0,D_CODES$1,MAX_BITS$1),static_bl_desc=new StaticTreeDesc(new Array(0),extra_blbits,0,BL_CODES$1,MAX_BL_BITS)}function init_block(e){var t;for(t=0;t<L_CODES$1;t++)e.dyn_ltree[t*2]=0;for(t=0;t<D_CODES$1;t++)e.dyn_dtree[t*2]=0;for(t=0;t<BL_CODES$1;t++)e.bl_tree[t*2]=0;e.dyn_ltree[END_BLOCK*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function bi_windup(e){e.bi_valid>8?put_short(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function copy_block(e,t,n,r){bi_windup(e),r&&(put_short(e,n),put_short(e,~n)),arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function smaller(e,t,n,r){var i=t*2,s=n*2;return e[i]<e[s]||e[i]===e[s]&&r[t]<=r[n]}function pqdownheap(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&smaller(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!smaller(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function compress_block(e,t,n){var r,i,s=0,l,o;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+s*2]<<8|e.pending_buf[e.d_buf+s*2+1],i=e.pending_buf[e.l_buf+s],s++,r===0?send_code(e,i,t):(l=_length_code[i],send_code(e,l+LITERALS$1+1,t),o=extra_lbits[l],o!==0&&(i-=base_length[l],send_bits(e,i,o)),r--,l=d_code(r),send_code(e,l,n),o=extra_dbits[l],o!==0&&(r-=base_dist[l],send_bits(e,r,o)));while(s<e.last_lit);send_code(e,END_BLOCK,t)}function build_tree(e,t){var n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems,l,o,c=-1,u;for(e.heap_len=0,e.heap_max=HEAP_SIZE$1,l=0;l<s;l++)n[l*2]!==0?(e.heap[++e.heap_len]=c=l,e.depth[l]=0):n[l*2+1]=0;for(;e.heap_len<2;)u=e.heap[++e.heap_len]=c<2?++c:0,n[u*2]=1,e.depth[u]=0,e.opt_len--,i&&(e.static_len-=r[u*2+1]);for(t.max_code=c,l=e.heap_len>>1;l>=1;l--)pqdownheap(e,n,l);u=s;do l=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pqdownheap(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=l,e.heap[--e.heap_max]=o,n[u*2]=n[l*2]+n[o*2],e.depth[u]=(e.depth[l]>=e.depth[o]?e.depth[l]:e.depth[o])+1,n[l*2+1]=n[o*2+1]=u,e.heap[1]=u++,pqdownheap(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],gen_bitlen(e,t),gen_codes(n,c,e.bl_count)}function scan_tree(e,t,n){var r,i=-1,s,l=t[0*2+1],o=0,c=7,u=4;for(l===0&&(c=138,u=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)s=l,l=t[(r+1)*2+1],!(++o<c&&s===l)&&(o<u?e.bl_tree[s*2]+=o:s!==0?(s!==i&&e.bl_tree[s*2]++,e.bl_tree[REP_3_6*2]++):o<=10?e.bl_tree[REPZ_3_10*2]++:e.bl_tree[REPZ_11_138*2]++,o=0,i=s,l===0?(c=138,u=3):s===l?(c=6,u=3):(c=7,u=4))}function send_tree(e,t,n){var r,i=-1,s,l=t[0*2+1],o=0,c=7,u=4;for(l===0&&(c=138,u=3),r=0;r<=n;r++)if(s=l,l=t[(r+1)*2+1],!(++o<c&&s===l)){if(o<u)do send_code(e,s,e.bl_tree);while(--o!==0);else s!==0?(s!==i&&(send_code(e,s,e.bl_tree),o--),send_code(e,REP_3_6,e.bl_tree),send_bits(e,o-3,2)):o<=10?(send_code(e,REPZ_3_10,e.bl_tree),send_bits(e,o-3,3)):(send_code(e,REPZ_11_138,e.bl_tree),send_bits(e,o-11,7));o=0,i=s,l===0?(c=138,u=3):s===l?(c=6,u=3):(c=7,u=4)}}function build_bl_tree(e){var t;for(scan_tree(e,e.dyn_ltree,e.l_desc.max_code),scan_tree(e,e.dyn_dtree,e.d_desc.max_code),build_tree(e,e.bl_desc),t=BL_CODES$1-1;t>=3&&e.bl_tree[bl_order[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function send_all_trees(e,t,n,r){var i;for(send_bits(e,t-257,5),send_bits(e,n-1,5),send_bits(e,r-4,4),i=0;i<r;i++)send_bits(e,e.bl_tree[bl_order[i]*2+1],3);send_tree(e,e.dyn_ltree,t-1),send_tree(e,e.dyn_dtree,n-1)}function detect_data_type(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return Z_BINARY$1;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Z_TEXT$1;for(n=32;n<LITERALS$1;n++)if(e.dyn_ltree[n*2]!==0)return Z_TEXT$1;return Z_BINARY$1}var static_init_done=!1;function _tr_init(e){static_init_done||(tr_static_init(),static_init_done=!0),e.l_desc=new TreeDesc(e.dyn_ltree,static_l_desc),e.d_desc=new TreeDesc(e.dyn_dtree,static_d_desc),e.bl_desc=new TreeDesc(e.bl_tree,static_bl_desc),e.bi_buf=0,e.bi_valid=0,init_block(e)}function _tr_stored_block(e,t,n,r){send_bits(e,(STORED_BLOCK<<1)+(r?1:0),3),copy_block(e,t,n,!0)}function _tr_align(e){send_bits(e,STATIC_TREES<<1,3),send_code(e,END_BLOCK,static_ltree),bi_flush(e)}function _tr_flush_block(e,t,n,r){var i,s,l=0;e.level>0?(e.strm.data_type===Z_UNKNOWN$2&&(e.strm.data_type=detect_data_type(e)),build_tree(e,e.l_desc),build_tree(e,e.d_desc),l=build_bl_tree(e),i=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=i&&(i=s)):i=s=n+5,n+4<=i&&t!==-1?_tr_stored_block(e,t,n,r):e.strategy===Z_FIXED$2||s===i?(send_bits(e,(STATIC_TREES<<1)+(r?1:0),3),compress_block(e,static_ltree,static_dtree)):(send_bits(e,(DYN_TREES<<1)+(r?1:0),3),send_all_trees(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+1),compress_block(e,e.dyn_ltree,e.dyn_dtree)),init_block(e),r&&bi_windup(e)}function _tr_tally(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(_length_code[n]+LITERALS$1+1)*2]++,e.dyn_dtree[d_code(t)*2]++),e.last_lit===e.lit_bufsize-1}function adler32(e,t,n,r){for(var i=e&65535|0,s=e>>>16&65535|0,l=0;n!==0;){l=n>2e3?2e3:n,n-=l;do i=i+t[r++]|0,s=s+i|0;while(--l);i%=65521,s%=65521}return i|s<<16|0}function makeTable(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var crcTable=makeTable();function crc32(e,t,n,r){var i=crcTable,s=r+n;e^=-1;for(var l=r;l<s;l++)e=e>>>8^i[(e^t[l])&255];return e^-1}var Z_NO_FLUSH$1=0,Z_PARTIAL_FLUSH$1=1,Z_FULL_FLUSH$1=3,Z_FINISH$2=4,Z_BLOCK$2=5,Z_OK$2=0,Z_STREAM_END$2=1,Z_STREAM_ERROR$2=-2,Z_DATA_ERROR$2=-3,Z_BUF_ERROR$2=-5,Z_DEFAULT_COMPRESSION$1=-1,Z_FILTERED$1=1,Z_HUFFMAN_ONLY$1=2,Z_RLE$1=3,Z_FIXED$1=4,Z_UNKNOWN$1=2,Z_DEFLATED$2=8,MAX_MEM_LEVEL=9,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,MIN_MATCH=3,MAX_MATCH=258,MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1,PRESET_DICT=32,INIT_STATE=42,EXTRA_STATE=69,NAME_STATE=73,COMMENT_STATE=91,HCRC_STATE=103,BUSY_STATE=113,FINISH_STATE=666,BS_NEED_MORE=1,BS_BLOCK_DONE=2,BS_FINISH_STARTED=3,BS_FINISH_DONE=4,OS_CODE=3;function err(e,t){return e.msg=msg[t],t}function rank(e){return(e<<1)-(e>4?9:0)}function zero(e){for(var t=e.length;--t>=0;)e[t]=0}function flush_pending(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function flush_block_only(e,t){_tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,flush_pending(e.strm)}function put_byte(e,t){e.pending_buf[e.pending++]=t}function putShortMSB(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function read_buf(e,t,n,r){var i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,arraySet(t,e.input,e.next_in,i,n),e.state.wrap===1?e.adler=adler32(e.adler,t,i,n):e.state.wrap===2&&(e.adler=crc32(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)}function longest_match(e,t){var n=e.max_chain_length,r=e.strstart,i,s,l=e.prev_length,o=e.nice_match,c=e.strstart>e.w_size-MIN_LOOKAHEAD?e.strstart-(e.w_size-MIN_LOOKAHEAD):0,u=e.window,f=e.w_mask,E=e.prev,_=e.strstart+MAX_MATCH,h=u[r+l-1],g=u[r+l];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(u[i+l]!==g||u[i+l-1]!==h||u[i]!==u[r]||u[++i]!==u[r+1])){r+=2,i++;do;while(u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&r<_);if(s=MAX_MATCH-(_-r),r=_-MAX_MATCH,s>l){if(e.match_start=t,l=s,s>=o)break;h=u[r+l-1],g=u[r+l]}}while((t=E[t&f])>c&&--n!==0);return l<=e.lookahead?l:e.lookahead}function fill_window(e){var t=e.w_size,n,r,i,s,l;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-MIN_LOOKAHEAD)){arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do i=e.head[--n],e.head[n]=i>=t?i-t:0;while(--r);r=t,n=r;do i=e.prev[--n],e.prev[n]=i>=t?i-t:0;while(--r);s+=t}if(e.strm.avail_in===0)break;if(r=read_buf(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=r,e.lookahead+e.insert>=MIN_MATCH)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+MIN_MATCH-1])&e.hash_mask,e.prev[l&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=l,l++,e.insert--,!(e.lookahead+e.insert<MIN_MATCH)););}while(e.lookahead<MIN_LOOKAHEAD&&e.strm.avail_in!==0)}function deflate_stored(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(fill_window(e),e.lookahead===0&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,flush_block_only(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-MIN_LOOKAHEAD&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):(e.strstart>e.block_start&&(flush_block_only(e,!1),e.strm.avail_out===0),BS_NEED_MORE)}function deflate_fast(e,t){for(var n,r;;){if(e.lookahead<MIN_LOOKAHEAD){if(fill_window(e),e.lookahead<MIN_LOOKAHEAD&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(e.lookahead===0)break}if(n=0,e.lookahead>=MIN_MATCH&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-MIN_LOOKAHEAD&&(e.match_length=longest_match(e,n)),e.match_length>=MIN_MATCH)if(r=_tr_tally(e,e.strstart-e.match_start,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=MIN_MATCH){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}return e.insert=e.strstart<MIN_MATCH-1?e.strstart:MIN_MATCH-1,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),e.strm.avail_out===0)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_slow(e,t){for(var n,r,i;;){if(e.lookahead<MIN_LOOKAHEAD){if(fill_window(e),e.lookahead<MIN_LOOKAHEAD&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(e.lookahead===0)break}if(n=0,e.lookahead>=MIN_MATCH&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=MIN_MATCH-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-MIN_LOOKAHEAD&&(e.match_length=longest_match(e,n),e.match_length<=5&&(e.strategy===Z_FILTERED$1||e.match_length===MIN_MATCH&&e.strstart-e.match_start>4096)&&(e.match_length=MIN_MATCH-1)),e.prev_length>=MIN_MATCH&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-MIN_MATCH,r=_tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-MIN_MATCH),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=MIN_MATCH-1,e.strstart++,r&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}else if(e.match_available){if(r=_tr_tally(e,0,e.window[e.strstart-1]),r&&flush_block_only(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return BS_NEED_MORE}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=_tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<MIN_MATCH-1?e.strstart:MIN_MATCH-1,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),e.strm.avail_out===0)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_rle(e,t){for(var n,r,i,s,l=e.window;;){if(e.lookahead<=MAX_MATCH){if(fill_window(e),e.lookahead<=MAX_MATCH&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=MIN_MATCH&&e.strstart>0&&(i=e.strstart-1,r=l[i],r===l[++i]&&r===l[++i]&&r===l[++i])){s=e.strstart+MAX_MATCH;do;while(r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&i<s);e.match_length=MAX_MATCH-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=MIN_MATCH?(n=_tr_tally(e,1,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),e.strm.avail_out===0)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_huff(e,t){for(var n;;){if(e.lookahead===0&&(fill_window(e),e.lookahead===0)){if(t===Z_NO_FLUSH$1)return BS_NEED_MORE;break}if(e.match_length=0,n=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),e.strm.avail_out===0)?BS_NEED_MORE:BS_BLOCK_DONE}function Config(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var configuration_table;configuration_table=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)];function lm_init(e){e.window_size=2*e.w_size,zero(e.head),e.max_lazy_match=configuration_table[e.level].max_lazy,e.good_match=configuration_table[e.level].good_length,e.nice_match=configuration_table[e.level].nice_length,e.max_chain_length=configuration_table[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=MIN_MATCH-1,e.match_available=0,e.ins_h=0}function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Z_DEFLATED$2,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Buf16(HEAP_SIZE*2),this.dyn_dtree=new Buf16((2*D_CODES+1)*2),this.bl_tree=new Buf16((2*BL_CODES+1)*2),zero(this.dyn_ltree),zero(this.dyn_dtree),zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Buf16(MAX_BITS+1),this.heap=new Buf16(2*L_CODES+1),zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Buf16(2*L_CODES+1),zero(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function deflateResetKeep(e){var t;return!e||!e.state?err(e,Z_STREAM_ERROR$2):(e.total_in=e.total_out=0,e.data_type=Z_UNKNOWN$1,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?INIT_STATE:BUSY_STATE,e.adler=t.wrap===2?0:1,t.last_flush=Z_NO_FLUSH$1,_tr_init(t),Z_OK$2)}function deflateReset(e){var t=deflateResetKeep(e);return t===Z_OK$2&&lm_init(e.state),t}function deflateInit2(e,t,n,r,i,s){if(!e)return Z_STREAM_ERROR$2;var l=1;if(t===Z_DEFAULT_COMPRESSION$1&&(t=6),r<0?(l=0,r=-r):r>15&&(l=2,r-=16),i<1||i>MAX_MEM_LEVEL||n!==Z_DEFLATED$2||r<8||r>15||t<0||t>9||s<0||s>Z_FIXED$1)return err(e,Z_STREAM_ERROR$2);r===8&&(r=9);var o=new DeflateState;return e.state=o,o.strm=e,o.wrap=l,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+MIN_MATCH-1)/MIN_MATCH),o.window=new Buf8(o.w_size*2),o.head=new Buf16(o.hash_size),o.prev=new Buf16(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=(1+2)*o.lit_bufsize,o.level=t,o.strategy=s,o.method=n,deflateReset(e)}function deflate(e,t){var n,r,i,s;if(!e||!e.state||t>Z_BLOCK$2||t<0)return e?err(e,Z_STREAM_ERROR$2):Z_STREAM_ERROR$2;if(r=e.state,!e.output||!e.input&&e.avail_in!==0||r.status===FINISH_STATE&&t!==Z_FINISH$2)return err(e,e.avail_out===0?Z_BUF_ERROR$2:Z_STREAM_ERROR$2);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===INIT_STATE)if(r.wrap===2)e.adler=0,put_byte(r,31),put_byte(r,139),put_byte(r,8),r.gzhead?(put_byte(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),put_byte(r,r.gzhead.time&255),put_byte(r,r.gzhead.time>>8&255),put_byte(r,r.gzhead.time>>16&255),put_byte(r,r.gzhead.time>>24&255),put_byte(r,r.level===9?2:r.strategy>=Z_HUFFMAN_ONLY$1||r.level<2?4:0),put_byte(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(put_byte(r,r.gzhead.extra.length&255),put_byte(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=crc32(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=EXTRA_STATE):(put_byte(r,0),put_byte(r,0),put_byte(r,0),put_byte(r,0),put_byte(r,0),put_byte(r,r.level===9?2:r.strategy>=Z_HUFFMAN_ONLY$1||r.level<2?4:0),put_byte(r,OS_CODE),r.status=BUSY_STATE);else{var l=Z_DEFLATED$2+(r.w_bits-8<<4)<<8,o=-1;r.strategy>=Z_HUFFMAN_ONLY$1||r.level<2?o=0:r.level<6?o=1:r.level===6?o=2:o=3,l|=o<<6,r.strstart!==0&&(l|=PRESET_DICT),l+=31-l%31,r.status=BUSY_STATE,putShortMSB(r,l),r.strstart!==0&&(putShortMSB(r,e.adler>>>16),putShortMSB(r,e.adler&65535)),e.adler=1}if(r.status===EXTRA_STATE)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),flush_pending(e),i=r.pending,r.pending===r.pending_buf_size));)put_byte(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=NAME_STATE)}else r.status=NAME_STATE;if(r.status===NAME_STATE)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),flush_pending(e),i=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindex<r.gzhead.name.length?s=r.gzhead.name.charCodeAt(r.gzindex++)&255:s=0,put_byte(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),s===0&&(r.gzindex=0,r.status=COMMENT_STATE)}else r.status=COMMENT_STATE;if(r.status===COMMENT_STATE)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),flush_pending(e),i=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindex<r.gzhead.comment.length?s=r.gzhead.comment.charCodeAt(r.gzindex++)&255:s=0,put_byte(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),s===0&&(r.status=HCRC_STATE)}else r.status=HCRC_STATE;if(r.status===HCRC_STATE&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&flush_pending(e),r.pending+2<=r.pending_buf_size&&(put_byte(r,e.adler&255),put_byte(r,e.adler>>8&255),e.adler=0,r.status=BUSY_STATE)):r.status=BUSY_STATE),r.pending!==0){if(flush_pending(e),e.avail_out===0)return r.last_flush=-1,Z_OK$2}else if(e.avail_in===0&&rank(t)<=rank(n)&&t!==Z_FINISH$2)return err(e,Z_BUF_ERROR$2);if(r.status===FINISH_STATE&&e.avail_in!==0)return err(e,Z_BUF_ERROR$2);if(e.avail_in!==0||r.lookahead!==0||t!==Z_NO_FLUSH$1&&r.status!==FINISH_STATE){var c=r.strategy===Z_HUFFMAN_ONLY$1?deflate_huff(r,t):r.strategy===Z_RLE$1?deflate_rle(r,t):configuration_table[r.level].func(r,t);if((c===BS_FINISH_STARTED||c===BS_FINISH_DONE)&&(r.status=FINISH_STATE),c===BS_NEED_MORE||c===BS_FINISH_STARTED)return e.avail_out===0&&(r.last_flush=-1),Z_OK$2;if(c===BS_BLOCK_DONE&&(t===Z_PARTIAL_FLUSH$1?_tr_align(r):t!==Z_BLOCK$2&&(_tr_stored_block(r,0,0,!1),t===Z_FULL_FLUSH$1&&(zero(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),flush_pending(e),e.avail_out===0))return r.last_flush=-1,Z_OK$2}return t!==Z_FINISH$2?Z_OK$2:r.wrap<=0?Z_STREAM_END$2:(r.wrap===2?(put_byte(r,e.adler&255),put_byte(r,e.adler>>8&255),put_byte(r,e.adler>>16&255),put_byte(r,e.adler>>24&255),put_byte(r,e.total_in&255),put_byte(r,e.total_in>>8&255),put_byte(r,e.total_in>>16&255),put_byte(r,e.total_in>>24&255)):(putShortMSB(r,e.adler>>>16),putShortMSB(r,e.adler&65535)),flush_pending(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?Z_OK$2:Z_STREAM_END$2)}function deflateEnd(e){var t;return!e||!e.state?Z_STREAM_ERROR$2:(t=e.state.status,t!==INIT_STATE&&t!==EXTRA_STATE&&t!==NAME_STATE&&t!==COMMENT_STATE&&t!==HCRC_STATE&&t!==BUSY_STATE&&t!==FINISH_STATE?err(e,Z_STREAM_ERROR$2):(e.state=null,t===BUSY_STATE?err(e,Z_DATA_ERROR$2):Z_OK$2))}var BAD$1=30,TYPE$1=12;function inflate_fast(e,t){var n,r,i,s,l,o,c,u,f,E,_,h,g,b,A,j,F,M,R,d,I,$,q,y,m;n=e.state,r=e.next_in,y=e.input,i=r+(e.avail_in-5),s=e.next_out,m=e.output,l=s-(t-e.avail_out),o=s+(e.avail_out-257),c=n.dmax,u=n.wsize,f=n.whave,E=n.wnext,_=n.window,h=n.hold,g=n.bits,b=n.lencode,A=n.distcode,j=(1<<n.lenbits)-1,F=(1<<n.distbits)-1;e:do{g<15&&(h+=y[r++]<<g,g+=8,h+=y[r++]<<g,g+=8),M=b[h&j];t:for(;;){if(R=M>>>24,h>>>=R,g-=R,R=M>>>16&255,R===0)m[s++]=M&65535;else if(R&16){d=M&65535,R&=15,R&&(g<R&&(h+=y[r++]<<g,g+=8),d+=h&(1<<R)-1,h>>>=R,g-=R),g<15&&(h+=y[r++]<<g,g+=8,h+=y[r++]<<g,g+=8),M=A[h&F];n:for(;;){if(R=M>>>24,h>>>=R,g-=R,R=M>>>16&255,R&16){if(I=M&65535,R&=15,g<R&&(h+=y[r++]<<g,g+=8,g<R&&(h+=y[r++]<<g,g+=8)),I+=h&(1<<R)-1,I>c){e.msg="invalid distance too far back",n.mode=BAD$1;break e}if(h>>>=R,g-=R,R=s-l,I>R){if(R=I-R,R>f&&n.sane){e.msg="invalid distance too far back",n.mode=BAD$1;break e}if($=0,q=_,E===0){if($+=u-R,R<d){d-=R;do m[s++]=_[$++];while(--R);$=s-I,q=m}}else if(E<R){if($+=u+E-R,R-=E,R<d){d-=R;do m[s++]=_[$++];while(--R);if($=0,E<d){R=E,d-=R;do m[s++]=_[$++];while(--R);$=s-I,q=m}}}else if($+=E-R,R<d){d-=R;do m[s++]=_[$++];while(--R);$=s-I,q=m}for(;d>2;)m[s++]=q[$++],m[s++]=q[$++],m[s++]=q[$++],d-=3;d&&(m[s++]=q[$++],d>1&&(m[s++]=q[$++]))}else{$=s-I;do m[s++]=m[$++],m[s++]=m[$++],m[s++]=m[$++],d-=3;while(d>2);d&&(m[s++]=m[$++],d>1&&(m[s++]=m[$++]))}}else if(R&64){e.msg="invalid distance code",n.mode=BAD$1;break e}else{M=A[(M&65535)+(h&(1<<R)-1)];continue n}break}}else if(R&64)if(R&32){n.mode=TYPE$1;break e}else{e.msg="invalid literal/length code",n.mode=BAD$1;break e}else{M=b[(M&65535)+(h&(1<<R)-1)];continue t}break}}while(r<i&&s<o);d=g>>3,r-=d,g-=d<<3,h&=(1<<g)-1,e.next_in=r,e.next_out=s,e.avail_in=r<i?5+(i-r):5-(r-i),e.avail_out=s<o?257+(o-s):257-(s-o),n.hold=h,n.bits=g}var MAXBITS=15,ENOUGH_LENS$1=852,ENOUGH_DISTS$1=592,CODES$1=0,LENS$1=1,DISTS$1=2,lbase=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],lext=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],dbase=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],dext=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function inflate_table(e,t,n,r,i,s,l,o){var c=o.bits,u=0,f=0,E=0,_=0,h=0,g=0,b=0,A=0,j=0,F=0,M,R,d,I,$,q=null,y=0,m,C=new Buf16(MAXBITS+1),w=new Buf16(MAXBITS+1),L=null,W=0,k,N,P;for(u=0;u<=MAXBITS;u++)C[u]=0;for(f=0;f<r;f++)C[t[n+f]]++;for(h=c,_=MAXBITS;_>=1&&C[_]===0;_--);if(h>_&&(h=_),_===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,o.bits=1,0;for(E=1;E<_&&C[E]===0;E++);for(h<E&&(h=E),A=1,u=1;u<=MAXBITS;u++)if(A<<=1,A-=C[u],A<0)return-1;if(A>0&&(e===CODES$1||_!==1))return-1;for(w[1]=0,u=1;u<MAXBITS;u++)w[u+1]=w[u]+C[u];for(f=0;f<r;f++)t[n+f]!==0&&(l[w[t[n+f]]++]=f);if(e===CODES$1?(q=L=l,m=19):e===LENS$1?(q=lbase,y-=257,L=lext,W-=257,m=256):(q=dbase,L=dext,m=-1),F=0,f=0,u=E,$=s,g=h,b=0,d=-1,j=1<<h,I=j-1,e===LENS$1&&j>ENOUGH_LENS$1||e===DISTS$1&&j>ENOUGH_DISTS$1)return 1;for(;;){k=u-b,l[f]<m?(N=0,P=l[f]):l[f]>m?(N=L[W+l[f]],P=q[y+l[f]]):(N=32+64,P=0),M=1<<u-b,R=1<<g,E=R;do R-=M,i[$+(F>>b)+R]=k<<24|N<<16|P|0;while(R!==0);for(M=1<<u-1;F&M;)M>>=1;if(M!==0?(F&=M-1,F+=M):F=0,f++,--C[u]===0){if(u===_)break;u=t[n+l[f]]}if(u>h&&(F&I)!==d){for(b===0&&(b=h),$+=E,g=u-b,A=1<<g;g+b<_&&(A-=C[g+b],!(A<=0));)g++,A<<=1;if(j+=1<<g,e===LENS$1&&j>ENOUGH_LENS$1||e===DISTS$1&&j>ENOUGH_DISTS$1)return 1;d=F&I,i[d]=h<<24|g<<16|$-s|0}}return F!==0&&(i[$+F]=u-b<<24|64<<16|0),o.bits=h,0}var CODES=0,LENS=1,DISTS=2,Z_FINISH$1=4,Z_BLOCK$1=5,Z_TREES$1=6,Z_OK$1=0,Z_STREAM_END$1=1,Z_NEED_DICT$1=2,Z_STREAM_ERROR$1=-2,Z_DATA_ERROR$1=-3,Z_MEM_ERROR=-4,Z_BUF_ERROR$1=-5,Z_DEFLATED$1=8,HEAD=1,FLAGS=2,TIME=3,OS=4,EXLEN=5,EXTRA=6,NAME=7,COMMENT=8,HCRC=9,DICTID=10,DICT=11,TYPE=12,TYPEDO=13,STORED=14,COPY_=15,COPY=16,TABLE=17,LENLENS=18,CODELENS=19,LEN_=20,LEN=21,LENEXT=22,DIST=23,DISTEXT=24,MATCH=25,LIT=26,CHECK=27,LENGTH=28,DONE=29,BAD=30,MEM=31,SYNC=32,ENOUGH_LENS=852,ENOUGH_DISTS=592;function zswap32(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function InflateState(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Buf16(320),this.work=new Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function inflateResetKeep(e){var t;return!e||!e.state?Z_STREAM_ERROR$1:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=HEAD,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Buf32(ENOUGH_LENS),t.distcode=t.distdyn=new Buf32(ENOUGH_DISTS),t.sane=1,t.back=-1,Z_OK$1)}function inflateReset(e){var t;return!e||!e.state?Z_STREAM_ERROR$1:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,inflateResetKeep(e))}function inflateReset2(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Z_STREAM_ERROR$1:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,inflateReset(e))}function inflateInit2(e,t){var n,r;return e?(r=new InflateState,e.state=r,r.window=null,n=inflateReset2(e,t),n!==Z_OK$1&&(e.state=null),n):Z_STREAM_ERROR$1}var virgin=!0,lenfix,distfix;function fixedtables(e){if(virgin){var t;for(lenfix=new Buf32(512),distfix=new Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(inflate_table(LENS,e.lens,0,288,lenfix,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;inflate_table(DISTS,e.lens,0,32,distfix,0,e.work,{bits:5}),virgin=!1}e.lencode=lenfix,e.lenbits=9,e.distcode=distfix,e.distbits=5}function updatewindow(e,t,n,r){var i,s=e.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Buf8(s.wsize)),r>=s.wsize?(arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),arraySet(s.window,t,n-r,i,s.wnext),r-=i,r?(arraySet(s.window,t,n-r,r,0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0}function inflate(e,t){var n,r,i,s,l,o,c,u,f,E,_,h,g,b,A=0,j,F,M,R,d,I,$,q,y=new Buf8(4),m,C,w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return Z_STREAM_ERROR$1;n=e.state,n.mode===TYPE&&(n.mode=TYPEDO),l=e.next_out,i=e.output,c=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,u=n.hold,f=n.bits,E=o,_=c,q=Z_OK$1;e:for(;;)switch(n.mode){case HEAD:if(n.wrap===0){n.mode=TYPEDO;break}for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(n.wrap&2&&u===35615){n.check=0,y[0]=u&255,y[1]=u>>>8&255,n.check=crc32(n.check,y,2,0),u=0,f=0,n.mode=FLAGS;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=BAD;break}if((u&15)!==Z_DEFLATED$1){e.msg="unknown compression method",n.mode=BAD;break}if(u>>>=4,f-=4,$=(u&15)+8,n.wbits===0)n.wbits=$;else if($>n.wbits){e.msg="invalid window size",n.mode=BAD;break}n.dmax=1<<$,e.adler=n.check=1,n.mode=u&512?DICTID:TYPE,u=0,f=0;break;case FLAGS:for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(n.flags=u,(n.flags&255)!==Z_DEFLATED$1){e.msg="unknown compression method",n.mode=BAD;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=BAD;break}n.head&&(n.head.text=u>>8&1),n.flags&512&&(y[0]=u&255,y[1]=u>>>8&255,n.check=crc32(n.check,y,2,0)),u=0,f=0,n.mode=TIME;case TIME:for(;f<32;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.head&&(n.head.time=u),n.flags&512&&(y[0]=u&255,y[1]=u>>>8&255,y[2]=u>>>16&255,y[3]=u>>>24&255,n.check=crc32(n.check,y,4,0)),u=0,f=0,n.mode=OS;case OS:for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.head&&(n.head.xflags=u&255,n.head.os=u>>8),n.flags&512&&(y[0]=u&255,y[1]=u>>>8&255,n.check=crc32(n.check,y,2,0)),u=0,f=0,n.mode=EXLEN;case EXLEN:if(n.flags&1024){for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.length=u,n.head&&(n.head.extra_len=u),n.flags&512&&(y[0]=u&255,y[1]=u>>>8&255,n.check=crc32(n.check,y,2,0)),u=0,f=0}else n.head&&(n.head.extra=null);n.mode=EXTRA;case EXTRA:if(n.flags&1024&&(h=n.length,h>o&&(h=o),h&&(n.head&&($=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),arraySet(n.head.extra,r,s,h,$)),n.flags&512&&(n.check=crc32(n.check,r,h,s)),o-=h,s+=h,n.length-=h),n.length))break e;n.length=0,n.mode=NAME;case NAME:if(n.flags&2048){if(o===0)break e;h=0;do $=r[s+h++],n.head&&$&&n.length<65536&&(n.head.name+=String.fromCharCode($));while($&&h<o);if(n.flags&512&&(n.check=crc32(n.check,r,h,s)),o-=h,s+=h,$)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=COMMENT;case COMMENT:if(n.flags&4096){if(o===0)break e;h=0;do $=r[s+h++],n.head&&$&&n.length<65536&&(n.head.comment+=String.fromCharCode($));while($&&h<o);if(n.flags&512&&(n.check=crc32(n.check,r,h,s)),o-=h,s+=h,$)break e}else n.head&&(n.head.comment=null);n.mode=HCRC;case HCRC:if(n.flags&512){for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(u!==(n.check&65535)){e.msg="header crc mismatch",n.mode=BAD;break}u=0,f=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=TYPE;break;case DICTID:for(;f<32;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}e.adler=n.check=zswap32(u),u=0,f=0,n.mode=DICT;case DICT:if(n.havedict===0)return e.next_out=l,e.avail_out=c,e.next_in=s,e.avail_in=o,n.hold=u,n.bits=f,Z_NEED_DICT$1;e.adler=n.check=1,n.mode=TYPE;case TYPE:if(t===Z_BLOCK$1||t===Z_TREES$1)break e;case TYPEDO:if(n.last){u>>>=f&7,f-=f&7,n.mode=CHECK;break}for(;f<3;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}switch(n.last=u&1,u>>>=1,f-=1,u&3){case 0:n.mode=STORED;break;case 1:if(fixedtables(n),n.mode=LEN_,t===Z_TREES$1){u>>>=2,f-=2;break e}break;case 2:n.mode=TABLE;break;case 3:e.msg="invalid block type",n.mode=BAD}u>>>=2,f-=2;break;case STORED:for(u>>>=f&7,f-=f&7;f<32;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if((u&65535)!==(u>>>16^65535)){e.msg="invalid stored block lengths",n.mode=BAD;break}if(n.length=u&65535,u=0,f=0,n.mode=COPY_,t===Z_TREES$1)break e;case COPY_:n.mode=COPY;case COPY:if(h=n.length,h){if(h>o&&(h=o),h>c&&(h=c),h===0)break e;arraySet(i,r,s,h,l),o-=h,s+=h,c-=h,l+=h,n.length-=h;break}n.mode=TYPE;break;case TABLE:for(;f<14;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(n.nlen=(u&31)+257,u>>>=5,f-=5,n.ndist=(u&31)+1,u>>>=5,f-=5,n.ncode=(u&15)+4,u>>>=4,f-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=BAD;break}n.have=0,n.mode=LENLENS;case LENLENS:for(;n.have<n.ncode;){for(;f<3;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.lens[w[n.have++]]=u&7,u>>>=3,f-=3}for(;n.have<19;)n.lens[w[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,m={bits:n.lenbits},q=inflate_table(CODES,n.lens,0,19,n.lencode,0,n.work,m),n.lenbits=m.bits,q){e.msg="invalid code lengths set",n.mode=BAD;break}n.have=0,n.mode=CODELENS;case CODELENS:for(;n.have<n.nlen+n.ndist;){for(;A=n.lencode[u&(1<<n.lenbits)-1],j=A>>>24,F=A>>>16&255,M=A&65535,!(j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(M<16)u>>>=j,f-=j,n.lens[n.have++]=M;else{if(M===16){for(C=j+2;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(u>>>=j,f-=j,n.have===0){e.msg="invalid bit length repeat",n.mode=BAD;break}$=n.lens[n.have-1],h=3+(u&3),u>>>=2,f-=2}else if(M===17){for(C=j+3;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}u>>>=j,f-=j,$=0,h=3+(u&7),u>>>=3,f-=3}else{for(C=j+7;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}u>>>=j,f-=j,$=0,h=11+(u&127),u>>>=7,f-=7}if(n.have+h>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=BAD;break}for(;h--;)n.lens[n.have++]=$}}if(n.mode===BAD)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=BAD;break}if(n.lenbits=9,m={bits:n.lenbits},q=inflate_table(LENS,n.lens,0,n.nlen,n.lencode,0,n.work,m),n.lenbits=m.bits,q){e.msg="invalid literal/lengths set",n.mode=BAD;break}if(n.distbits=6,n.distcode=n.distdyn,m={bits:n.distbits},q=inflate_table(DISTS,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,m),n.distbits=m.bits,q){e.msg="invalid distances set",n.mode=BAD;break}if(n.mode=LEN_,t===Z_TREES$1)break e;case LEN_:n.mode=LEN;case LEN:if(o>=6&&c>=258){e.next_out=l,e.avail_out=c,e.next_in=s,e.avail_in=o,n.hold=u,n.bits=f,inflate_fast(e,_),l=e.next_out,i=e.output,c=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,u=n.hold,f=n.bits,n.mode===TYPE&&(n.back=-1);break}for(n.back=0;A=n.lencode[u&(1<<n.lenbits)-1],j=A>>>24,F=A>>>16&255,M=A&65535,!(j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(F&&!(F&240)){for(R=j,d=F,I=M;A=n.lencode[I+((u&(1<<R+d)-1)>>R)],j=A>>>24,F=A>>>16&255,M=A&65535,!(R+j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}u>>>=R,f-=R,n.back+=R}if(u>>>=j,f-=j,n.back+=j,n.length=M,F===0){n.mode=LIT;break}if(F&32){n.back=-1,n.mode=TYPE;break}if(F&64){e.msg="invalid literal/length code",n.mode=BAD;break}n.extra=F&15,n.mode=LENEXT;case LENEXT:if(n.extra){for(C=n.extra;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.length+=u&(1<<n.extra)-1,u>>>=n.extra,f-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=DIST;case DIST:for(;A=n.distcode[u&(1<<n.distbits)-1],j=A>>>24,F=A>>>16&255,M=A&65535,!(j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(!(F&240)){for(R=j,d=F,I=M;A=n.distcode[I+((u&(1<<R+d)-1)>>R)],j=A>>>24,F=A>>>16&255,M=A&65535,!(R+j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}u>>>=R,f-=R,n.back+=R}if(u>>>=j,f-=j,n.back+=j,F&64){e.msg="invalid distance code",n.mode=BAD;break}n.offset=M,n.extra=F&15,n.mode=DISTEXT;case DISTEXT:if(n.extra){for(C=n.extra;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.offset+=u&(1<<n.extra)-1,u>>>=n.extra,f-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=BAD;break}n.mode=MATCH;case MATCH:if(c===0)break e;if(h=_-c,n.offset>h){if(h=n.offset-h,h>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=BAD;break}h>n.wnext?(h-=n.wnext,g=n.wsize-h):g=n.wnext-h,h>n.length&&(h=n.length),b=n.window}else b=i,g=l-n.offset,h=n.length;h>c&&(h=c),c-=h,n.length-=h;do i[l++]=b[g++];while(--h);n.length===0&&(n.mode=LEN);break;case LIT:if(c===0)break e;i[l++]=n.length,c--,n.mode=LEN;break;case CHECK:if(n.wrap){for(;f<32;){if(o===0)break e;o--,u|=r[s++]<<f,f+=8}if(_-=c,e.total_out+=_,n.total+=_,_&&(e.adler=n.check=n.flags?crc32(n.check,i,_,l-_):adler32(n.check,i,_,l-_)),_=c,(n.flags?u:zswap32(u))!==n.check){e.msg="incorrect data check",n.mode=BAD;break}u=0,f=0}n.mode=LENGTH;case LENGTH:if(n.wrap&&n.flags){for(;f<32;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(u!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=BAD;break}u=0,f=0}n.mode=DONE;case DONE:q=Z_STREAM_END$1;break e;case BAD:q=Z_DATA_ERROR$1;break e;case MEM:return Z_MEM_ERROR;case SYNC:default:return Z_STREAM_ERROR$1}return e.next_out=l,e.avail_out=c,e.next_in=s,e.avail_in=o,n.hold=u,n.bits=f,(n.wsize||_!==e.avail_out&&n.mode<BAD&&(n.mode<CHECK||t!==Z_FINISH$1))&&updatewindow(e,e.output,e.next_out,_-e.avail_out),E-=e.avail_in,_-=e.avail_out,e.total_in+=E,e.total_out+=_,n.total+=_,n.wrap&&_&&(e.adler=n.check=n.flags?crc32(n.check,i,_,e.next_out-_):adler32(n.check,i,_,e.next_out-_)),e.data_type=n.bits+(n.last?64:0)+(n.mode===TYPE?128:0)+(n.mode===LEN_||n.mode===COPY_?256:0),(E===0&&_===0||t===Z_FINISH$1)&&q===Z_OK$1&&(q=Z_BUF_ERROR$1),q}function inflateEnd(e){if(!e||!e.state)return Z_STREAM_ERROR$1;var t=e.state;return t.window&&(t.window=null),e.state=null,Z_OK$1}var NONE=0,DEFLATE=1,INFLATE=2,GZIP=3,GUNZIP=4,DEFLATERAW=5,INFLATERAW=6,UNZIP=7,Z_NO_FLUSH=0,Z_PARTIAL_FLUSH=1,Z_SYNC_FLUSH=2,Z_FULL_FLUSH=3,Z_FINISH=4,Z_BLOCK=5,Z_TREES=6,Z_OK=0,Z_STREAM_END=1,Z_NEED_DICT=2,Z_ERRNO=-1,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_BUF_ERROR=-5,Z_NO_COMPRESSION=0,Z_BEST_SPEED=1,Z_BEST_COMPRESSION=9,Z_DEFAULT_COMPRESSION=-1,Z_FILTERED=1,Z_HUFFMAN_ONLY=2,Z_RLE=3,Z_FIXED=4,Z_DEFAULT_STRATEGY=0,Z_BINARY=0,Z_TEXT=1,Z_UNKNOWN=2,Z_DEFLATED=8;function Zlib$1(e){if(e<DEFLATE||e>UNZIP)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}Zlib$1.prototype.init=function(e,t,n,r,i){this.windowBits=e,this.level=t,this.memLevel=n,this.strategy=r,(this.mode===GZIP||this.mode===GUNZIP)&&(this.windowBits+=16),this.mode===UNZIP&&(this.windowBits+=32),(this.mode===DEFLATERAW||this.mode===INFLATERAW)&&(this.windowBits=-this.windowBits),this.strm=new ZStream;var s;switch(this.mode){case DEFLATE:case GZIP:case DEFLATERAW:s=deflateInit2(this.strm,this.level,Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case INFLATE:case GUNZIP:case INFLATERAW:case UNZIP:s=inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}if(s!==Z_OK){this._error(s);return}this.write_in_progress=!1,this.init_done=!0},Zlib$1.prototype.params=function(){throw new Error("deflateParams Not supported")},Zlib$1.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(this.mode===NONE)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},Zlib$1.prototype.write=function(e,t,n,r,i,s,l){this._writeCheck(),this.write_in_progress=!0;var o=this;return browser$1$1.nextTick(function(){o.write_in_progress=!1;var c=o._write(e,t,n,r,i,s,l);o.callback(c[0],c[1]),o.pending_close&&o.close()}),this};function bufferSet(e,t){for(var n=0;n<e.length;n++)this[t+n]=e[n]}Zlib$1.prototype.writeSync=function(e,t,n,r,i,s,l){return this._writeCheck(),this._write(e,t,n,r,i,s,l)},Zlib$1.prototype._write=function(e,t,n,r,i,s,l){if(this.write_in_progress=!0,e!==Z_NO_FLUSH&&e!==Z_PARTIAL_FLUSH&&e!==Z_SYNC_FLUSH&&e!==Z_FULL_FLUSH&&e!==Z_FINISH&&e!==Z_BLOCK)throw new Error("Invalid flush value");t==null&&(t=new Buffer(0),r=0,n=0),i._set?i.set=i._set:i.set=bufferSet;var o=this.strm;o.avail_in=r,o.input=t,o.next_in=n,o.avail_out=l,o.output=i,o.next_out=s;var c;switch(this.mode){case DEFLATE:case GZIP:case DEFLATERAW:c=deflate(o,e);break;case UNZIP:case INFLATE:case GUNZIP:case INFLATERAW:c=inflate(o,e);break;default:throw new Error("Unknown mode "+this.mode)}return c!==Z_STREAM_END&&c!==Z_OK&&this._error(c),this.write_in_progress=!1,[o.avail_in,o.avail_out]},Zlib$1.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}this.pending_close=!1,this.mode===DEFLATE||this.mode===GZIP||this.mode===DEFLATERAW?deflateEnd(this.strm):inflateEnd(this.strm),this.mode=NONE};var status;Zlib$1.prototype.reset=function(){switch(this.mode){case DEFLATE:case DEFLATERAW:status=deflateReset(this.strm);break;case INFLATE:case INFLATERAW:status=inflateReset(this.strm);break}status!==Z_OK&&this._error(status)},Zlib$1.prototype._error=function(e){this.onerror(msg[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};const _binding=Object.freeze(Object.defineProperty({__proto__:null,DEFLATE,DEFLATERAW,GUNZIP,GZIP,INFLATE,INFLATERAW,NONE,UNZIP,Z_BEST_COMPRESSION,Z_BEST_SPEED,Z_BINARY,Z_BLOCK,Z_BUF_ERROR,Z_DATA_ERROR,Z_DEFAULT_COMPRESSION,Z_DEFAULT_STRATEGY,Z_DEFLATED,Z_ERRNO,Z_FILTERED,Z_FINISH,Z_FIXED,Z_FULL_FLUSH,Z_HUFFMAN_ONLY,Z_NEED_DICT,Z_NO_COMPRESSION,Z_NO_FLUSH,Z_OK,Z_PARTIAL_FLUSH,Z_RLE,Z_STREAM_END,Z_STREAM_ERROR,Z_SYNC_FLUSH,Z_TEXT,Z_TREES,Z_UNKNOWN,Zlib:Zlib$1},Symbol.toStringTag,{value:"Module"}));function assert(e,t){if(!e)throw new Error(t)}var binding={};Object.keys(_binding).forEach(function(e){binding[e]=_binding[e]}),binding.Z_MIN_WINDOWBITS=8,binding.Z_MAX_WINDOWBITS=15,binding.Z_DEFAULT_WINDOWBITS=15,binding.Z_MIN_CHUNK=64,binding.Z_MAX_CHUNK=1/0,binding.Z_DEFAULT_CHUNK=16*1024,binding.Z_MIN_MEMLEVEL=1,binding.Z_MAX_MEMLEVEL=9,binding.Z_DEFAULT_MEMLEVEL=8,binding.Z_MIN_LEVEL=-1,binding.Z_MAX_LEVEL=9,binding.Z_DEFAULT_LEVEL=binding.Z_DEFAULT_COMPRESSION;var codes={Z_OK:binding.Z_OK,Z_STREAM_END:binding.Z_STREAM_END,Z_NEED_DICT:binding.Z_NEED_DICT,Z_ERRNO:binding.Z_ERRNO,Z_STREAM_ERROR:binding.Z_STREAM_ERROR,Z_DATA_ERROR:binding.Z_DATA_ERROR,Z_MEM_ERROR:binding.Z_MEM_ERROR,Z_BUF_ERROR:binding.Z_BUF_ERROR,Z_VERSION_ERROR:binding.Z_VERSION_ERROR};Object.keys(codes).forEach(function(e){codes[codes[e]]=e});function deflateSync(e,t){return zlibBufferSync(new Deflate(t),e)}function inflateSync(e,t){return zlibBufferSync(new Inflate(t),e)}function zlibBufferSync(e,t){if(typeof t=="string"&&(t=new Buffer(t)),!Buffer.isBuffer(t))throw new TypeError("Not a string or buffer");var n=binding.Z_FINISH;return e._processChunk(t,n)}function Deflate(e){if(!(this instanceof Deflate))return new Deflate(e);Zlib.call(this,e,binding.DEFLATE)}function Inflate(e){if(!(this instanceof Inflate))return new Inflate(e);Zlib.call(this,e,binding.INFLATE)}function Gzip(e){if(!(this instanceof Gzip))return new Gzip(e);Zlib.call(this,e,binding.GZIP)}function Gunzip(e){if(!(this instanceof Gunzip))return new Gunzip(e);Zlib.call(this,e,binding.GUNZIP)}function DeflateRaw(e){if(!(this instanceof DeflateRaw))return new DeflateRaw(e);Zlib.call(this,e,binding.DEFLATERAW)}function InflateRaw(e){if(!(this instanceof InflateRaw))return new InflateRaw(e);Zlib.call(this,e,binding.INFLATERAW)}function Unzip(e){if(!(this instanceof Unzip))return new Unzip(e);Zlib.call(this,e,binding.UNZIP)}function Zlib(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||binding.Z_DEFAULT_CHUNK,Transform.call(this,e),e.flush&&e.flush!==binding.Z_NO_FLUSH&&e.flush!==binding.Z_PARTIAL_FLUSH&&e.flush!==binding.Z_SYNC_FLUSH&&e.flush!==binding.Z_FULL_FLUSH&&e.flush!==binding.Z_FINISH&&e.flush!==binding.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||binding.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<binding.Z_MIN_CHUNK||e.chunkSize>binding.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<binding.Z_MIN_WINDOWBITS||e.windowBits>binding.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<binding.Z_MIN_LEVEL||e.level>binding.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<binding.Z_MIN_MEMLEVEL||e.memLevel>binding.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=binding.Z_FILTERED&&e.strategy!=binding.Z_HUFFMAN_ONLY&&e.strategy!=binding.Z_RLE&&e.strategy!=binding.Z_FIXED&&e.strategy!=binding.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!Buffer.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new binding.Zlib(t);var n=this;this._hadError=!1,this._binding.onerror=function(s,l){n._binding=null,n._hadError=!0;var o=new Error(s);o.errno=l,o.code=binding.codes[l],n.emit("error",o)};var r=binding.Z_DEFAULT_COMPRESSION;typeof e.level=="number"&&(r=e.level);var i=binding.Z_DEFAULT_STRATEGY;typeof e.strategy=="number"&&(i=e.strategy),this._binding.init(e.windowBits||binding.Z_DEFAULT_WINDOWBITS,r,e.memLevel||binding.Z_DEFAULT_MEMLEVEL,i,e.dictionary),this._buffer=new Buffer(this._chunkSize),this._offset=0,this._closed=!1,this._level=r,this._strategy=i,this.once("end",this.close)}inherits$1(Zlib,Transform),Zlib.prototype.params=function(e,t,n){if(e<binding.Z_MIN_LEVEL||e>binding.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=binding.Z_FILTERED&&t!=binding.Z_HUFFMAN_ONLY&&t!=binding.Z_RLE&&t!=binding.Z_FIXED&&t!=binding.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var r=this;this.flush(binding.Z_SYNC_FLUSH,function(){r._binding.params(e,t),r._hadError||(r._level=e,r._strategy=t,n&&n())})}else browser$1$1.nextTick(n)},Zlib.prototype.reset=function(){return this._binding.reset()},Zlib.prototype._flush=function(e){this._transform(new Buffer(0),"",e)},Zlib.prototype.flush=function(e,t){var n=this._writableState;if((typeof e=="function"||e===void 0&&!t)&&(t=e,e=binding.Z_FULL_FLUSH),n.ended)t&&browser$1$1.nextTick(t);else if(n.ending)t&&this.once("end",t);else if(n.needDrain){var r=this;this.once("drain",function(){r.flush(t)})}else this._flushFlag=e,this.write(new Buffer(0),"",t)},Zlib.prototype.close=function(e){if(e&&browser$1$1.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;browser$1$1.nextTick(function(){t.emit("close")})}},Zlib.prototype._transform=function(e,t,n){var r,i=this._writableState,s=i.ending||i.ended,l=s&&(!e||i.length===e.length);if(!e===null&&!Buffer.isBuffer(e))return n(new Error("invalid input"));l?r=binding.Z_FINISH:(r=this._flushFlag,e.length>=i.length&&(this._flushFlag=this._opts.flush||binding.Z_NO_FLUSH)),this._processChunk(e,r,n)},Zlib.prototype._processChunk=function(e,t,n){var r=e&&e.length,i=this._chunkSize-this._offset,s=0,l=this,o=typeof n=="function";if(!o){var c=[],u=0,f;this.on("error",function(b){f=b});do var E=this._binding.writeSync(t,e,s,r,this._buffer,this._offset,i);while(!this._hadError&&g(E[0],E[1]));if(this._hadError)throw f;var _=Buffer.concat(c,u);return this.close(),_}var h=this._binding.write(t,e,s,r,this._buffer,this._offset,i);h.buffer=e,h.callback=g;function g(b,A){if(!l._hadError){var j=i-A;if(assert(j>=0,"have should not go down"),j>0){var F=l._buffer.slice(l._offset,l._offset+j);l._offset+=j,o?l.push(F):(c.push(F),u+=F.length)}if((A===0||l._offset>=l._chunkSize)&&(i=l._chunkSize,l._offset=0,l._buffer=new Buffer(l._chunkSize)),A===0){if(s+=r-b,r=b,!o)return!0;var M=l._binding.write(t,e,s,r,l._buffer,l._offset,l._chunkSize);M.callback=g,M.buffer=e;return}if(!o)return!1;n()}}},inherits$1(Deflate,Zlib),inherits$1(Inflate,Zlib),inherits$1(Gzip,Zlib),inherits$1(Gunzip,Zlib),inherits$1(DeflateRaw,Zlib),inherits$1(InflateRaw,Zlib),inherits$1(Unzip,Zlib);function serializeHash(e){return deflateSync(Buffer.from(JSON.stringify(e),"utf8")).toString("base64")}function deserializeHash(e){return JSON.parse(inflateSync(Buffer.from(e,"base64")).toString("utf8"))}const isRtcPeer=e=>e!==void 0&&e.capabilities!==void 0&&e.capabilitySet!==void 0;class DataChannel{constructor(t){Te(this,"ready",!1);Te(this,"listeners",[]);Te(this,"openListeners",[]);Te(this,"closeListeners",[]);Te(this,"errorListeners",[]);Te(this,"binaryListeners",[]);Te(this,"error");Te(this,"decoder",new TextDecoder);this.dataChannel=t,this.dataChannel.binaryType="arraybuffer",this.dataChannel.onopen=()=>{this.ready=!0,this.openListeners.forEach(n=>n())},this.dataChannel.onclose=()=>{this.ready=!1,this.closeListeners.forEach(n=>n())},this.dataChannel.onerror=n=>{console.error(n),this.error="An error occurred in DataChannel",this.errorListeners.forEach(r=>r(n))},this.dataChannel.onmessage=n=>{this.listeners.forEach(r=>{const i=new Uint8Array(n.data),s=this.decoder.decode(i);r(s)}),this.binaryListeners.forEach(r=>{r(new Uint8Array(n.data))})}}addOpenListener(t){this.openListeners.push(t)}removeOpenListener(t){this.openListeners=this.openListeners.filter(n=>n!==t)}addCloseListener(t){this.closeListeners.push(t)}removeCloseListener(t){this.closeListeners=this.closeListeners.filter(n=>n!==t)}addErrorListener(t){this.errorListeners.push(t)}removeErrorListener(t){this.errorListeners=this.errorListeners.filter(n=>n!==t)}async waitTilReady(){return this.ready?!0:new Promise((n,r)=>{let i=window.setInterval(()=>{this.ready&&(window.clearInterval(i),n(!0)),this.error&&r(this.error)},10)})}send(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}sendBinary(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}addListener(t){this.listeners.push(t)}removeListener(t){const n=this.listeners.indexOf(t);if(n===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.listeners.splice(n,1)}addBinaryListener(t){this.binaryListeners.push(t)}removeBinaryListener(t){const n=this.binaryListeners.indexOf(t);if(n===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.binaryListeners.splice(n,1)}}class Manipulator{constructor(t,n){Te(this,"currentListeners",[]);Te(this,"onRealtimeMessage",(t,n)=>{n.payload.jointState&&this.currentListeners.forEach(r=>{n.payload.jointState&&r(n.payload.jointState)})});this.device=t,this.config=n}async synchronize(){this.device.addRealtimeListener(this.onRealtimeMessage),this.device.startListeningToRealtimeDataStream(this.config.currentJointStateStream)}async desynchronize(){this.device.removeRealtimeListener(this.onRealtimeMessage),this.device.stopListeningToRealtimeDataStream(this.config.currentJointStateStream)}async addCurrentJointStateListener(t){this.currentListeners.push(t)}}class BaseDevice extends EventEmitter{constructor(){super(...arguments);Te(this,"rtcClient");Te(this,"remoteDevicePeerId",null);Te(this,"realtimeListeners",[]);Te(this,"connectionMonitorInterval");Te(this,"handleMessage",(n,r)=>{this.realtimeListeners.forEach(i=>i(n,r))})}stopConnectionMonitoring(){clearInterval(this.connectionMonitorInterval),this.connectionMonitorInterval=void 0}assertNotCancelled(n){if(n)throw new Error("Cancelled by deadline")}getRealtimeStatus(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getConnectionStatus(this.remoteDevicePeerId);throw new Error("Realtime connection hasn't been started")}getRealtimePing(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getPing(this.remoteDevicePeerId);throw new Error("Realtime connection hasn't been started")}addRealtimeListener(n){this.realtimeListeners.push(n)}removeRealtimeListener(n){const r=this.realtimeListeners.indexOf(n);if(r===-1)throw new Error("Could not find realtime listener to remove");this.realtimeListeners.splice(r,1)}async getRealtimeManipulators(){const n=await this.getConfiguration(),r=[];for(const i of n.teleop.rosStreams??[])i.topicType=="sensor_msgs/JointState"&&r.push(new Manipulator(this,{currentJointStateStream:{name:i.topicName},plannedJointStateStream:i.plannedTopic?{name:i.plannedTopic}:void 0,planValidStream:i.planValidTopic?{name:i.planValidTopic}:void 0,endEffectorStream:i.endEffectorTopic?{name:i.endEffectorTopic}:void 0,endEffectorLinkName:i.endEffectorLinkName,baseReferenceFrame:i.baseReferenceFrame,localFrame:i.localFrame}));return r}async getRealtimeVideoStreams(){var i,s,l;const n=await this.getConfiguration(),r=[];for(const o of((i=n.teleop)==null?void 0:i.hardwareStreams)??[])o.rtcStreamType==="h264-video-frame"&&r.push({name:o.name});for(const o of((s=n.teleop)==null?void 0:s.rosStreams)??[])o.topicType=="formant/H264VideoFrame"&&r.push({name:o.topicName}),(o.topicType==="sensor_msgs/Image"||o.topicType==="sensor_msgs/CompressedImage")&&o.encodeVideo&&r.push({name:o.topicName});for(const o of((l=n.teleop)==null?void 0:l.customStreams)??[])o.rtcStreamType==="h264-video-frame"&&r.push({name:o.name});return r}createCustomRequestDataChannel(n,r=3e3){return new TextRequestDataChannel(this,n,r)}createCustomBinaryRequestDataChannel(n,r=3e3){return new BinaryRequestDataChannel(this,n,r)}async startListeningToRealtimeVideo(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeVideo(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n.name,enable:!1,pipeline:"rtc"})}async startListeningToRealtimeDataStream(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeDataStream(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n.name,enable:!1,pipeline:"rtc"})}async enableRealtimeTelemetryPriorityIngestion(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n,enablePriorityUpload:!0,pipeline:"telemetry"})}async disableRealtimeTelemetryPriorityIngestion(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n,enablePriorityUpload:!1,pipeline:"telemetry"})}async changeStreamAudioType(n,r){const i=defined(this.rtcClient,"Realtime connection has not been started"),s=await this.getRemotePeer();i.controlRemoteStream(defined(s).id,{streamName:n,setAudioFormat:r})}async createCustomDataChannel(n,r){const i=defined(this.rtcClient,"Realtime connection has not been started"),s=await this.getRemotePeer(),l=await new Promise(o=>{i.createCustomDataChannel(defined(s).id,n,{ordered:!0,...r},!1,(c,u)=>{const f=new DataChannel(u);o(f)})});return await l.waitTilReady(),l}async sendRealtimeMessage(n,r={channelLabel:"stream.reliable"}){const i=defined(this.rtcClient,"Realtime connection has not been started"),s=await this.getRemotePeer();i.send(defined(s).id,n,r)}async getRealtimeAudioStreams(){var i,s,l;const n=await this.getConfiguration(),r=[];for(const o of((i=n.teleop)==null?void 0:i.hardwareStreams)??[])o.rtcStreamType==="audio-chunk"&&r.push({name:o.name});for(const o of((s=n.teleop)==null?void 0:s.rosStreams)??[])o.topicType=="audio_common_msgs/AudioData"&&r.push({name:o.topicName});for(const o of((l=n.teleop)==null?void 0:l.customStreams)??[])o.rtcStreamType==="audio-chunk"&&r.push({name:o.name});return r}}class Device extends BaseDevice{constructor(t,n,r,i){super(),this.id=t,this.name=n,this.organizationId=r,this.tags=i}async getLatestTelemetry(){return(await(await fetch(`${FORMANT_API_URL}/v1/queries/stream-current-value`,{method:"POST",body:JSON.stringify({deviceIds:[this.id]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}async getConfiguration(){let t=await fetch(`${FORMANT_API_URL}/v1/admin/devices/${this.id}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}});const n=await t.json();if(!n.state.reportedConfiguration)throw new Error("Device has no configuration, has it ever been turned on?");const r=n.state.reportedConfiguration.version;return t=await fetch(`${FORMANT_API_URL}/v1/admin/devices/${this.id}/configurations/${r}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),(await t.json()).document}async getFileUrl(t){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/files/query`,{method:"POST",body:JSON.stringify({fileIds:[t]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).fileUrls}async startRealtimeConnection(t={}){if(console.debug(`${new Date().toISOString()} :: Connection start requested`),this.rtcClient&&this.connectionMonitorInterval!==void 0)throw new Error(`Already created realtime connection to device ${this.id}`);this.rtcClient&&console.warn("overwriting existing rtcClient due to missing connectionMonitorInterval");const{sessionType:n,deadlineMs:r=1e4,maxConnectRetries:i=3}=typeof t=="number"?{sessionType:t}:t,l=getRtcClientPool({sessionType:n}).get(this.handleMessage);let o=!1;const c=new Promise((f,E)=>setTimeout(()=>{o=!0,E(new Error("Connection timed out: the connection could not be finalized in time, possibly due to network issues or misconfigured settings."))},r)),u=async()=>{if("isReady"in l)for(;!l.isReady();)this.assertNotCancelled(o),await delay(100);const f=await this.getRemoteDevicePeerId(l);this.assertNotCancelled(o);let E;for(let h=0;h<i&&(E=await l.connect(f),!E);h++)delay(100),this.assertNotCancelled(o);if(!E)throw new Error(`Session could not be created: exhausted ${i} retries`);let _=0;for(;!o&&l.getConnectionStatus(f)!=="connected";)await delay(100),_+=1;return this.assertNotCancelled(o),console.debug(`${new Date().toISOString()} :: Connection completed after ${_} retries`),f};return Promise.race([u(),c]).then(f=>{this.remoteDevicePeerId=f,this.initConnectionMonitoring(),this.rtcClient=l,this.emit("connect")}).catch(f=>{throw console.debug(`${new Date().toISOString()} :: Connection failed: %o`,f),this.remoteDevicePeerId=null,l.shutdown().catch(E=>{console.error("rtcClient cannot shutdown: %o",E)}),this.emit("connection_failed",f),f})}async getRemoteDevicePeerId(t){const r=(await t.getPeers()).find(i=>i.deviceId===this.id);if(!isRtcPeer(r))throw new Error("Cannot find peer, is the robot offline?");return r.id}initConnectionMonitoring(){this.connectionMonitorInterval=setInterval(async()=>{let t=!1;if(this.rtcClient){const r=this.rtcClient.getConnections().find(i=>i.getRemotePeerId()===this.remoteDevicePeerId&&i.isActive());r===void 0||!r.isReady()?(console.debug(`${new Date().toISOString()} :: data channel closed`),t=!0):console.debug(`${new Date().toISOString()} :: data channel appears active`)}(!this.rtcClient||!this.remoteDevicePeerId||await this.rtcClient.getConnectionStatsInfo(this.remoteDevicePeerId)===void 0||t)&&(this.emit("disconnect"),this.stopRealtimeConnection().catch(n=>{console.error(n)}))},1e3)}async getRemotePeer(){const n=(await defined(this.rtcClient,"Realtime connection has not been started").getPeers()).find(r=>r.deviceId===this.id);return defined(n,"Could not find remote peer for device "+this.id)}async stopRealtimeConnection(){let t=!1;if(this.rtcClient){this.stopConnectionMonitoring(),this.remoteDevicePeerId?(await this.rtcClient.disconnect(this.remoteDevicePeerId),this.remoteDevicePeerId=null):t=!0;try{await this.rtcClient.shutdown()}finally{this.rtcClient=void 0}}if(t)throw new Error(`Realtime connection hasn't been started for ${this.id}`)}async isInRealtimeSession(){const t=await Fleet.getPeers(),n=await Fleet.getRealtimeSessions(),r=t.find(i=>i.deviceId===this.id);return r?n[r.id].length>0:!1}async getAvailableCommands(){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/command-templates/`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(r=>({name:r.name,id:r.id,command:r.command,description:r.description,parameterEnabled:r.parameterEnabled,parameterValue:r.parameterValue,parameterMeta:r.parameterMeta,enabled:r.enabled,tags:r.tags}))}async sendCommand(t,n,r,i){var f;const l=(await this.getAvailableCommands()).find(E=>E.name===t);if(!l)throw new Error(`Could not find command with name "${t}"`);let o="";n===void 0?l.parameterEnabled&&l.parameterValue&&(o=l.parameterValue):o=n;let c={value:o,scrubberTime:(r||new Date).toISOString(),meta:{...l.parameterMeta,...i}};return await fetch(`${FORMANT_API_URL}/v1/admin/commands`,{method:"POST",body:JSON.stringify({commandTemplateId:l.id,organizationId:this.organizationId,deviceId:this.id,command:l.command,parameter:c,userId:(f=Authentication.currentUser)==null?void 0:f.id}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}async getCommand(t){return await fetch(`${FORMANT_API_URL}/v1/admin/commands/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}async createCaptureStream(t){const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions`,{method:"POST",body:JSON.stringify({deviceId:this.id,streamName:t,tags:{}}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();return new CaptureStream(r)}async getTelemetry(t,n,r,i){return await Fleet.getTelemetry(this.id,t,n,r,i)}async getTelemetryStreams(){var o,c;const t=await this.getConfiguration(),n=await fetch(`${FORMANT_API_URL}/v1/queries/metadata/stream-names`,{method:"POST",body:JSON.stringify({deviceIds:[this.id]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),r=[],i=[];return(c=(o=t.telemetry)==null?void 0:o.streams)==null||c.forEach(u=>{u.disabled!==!0&&r.push(u.name),u.onDemand===!0&&i.push(u.name)}),console.log(i),(await n.json()).items.filter(u=>!r.includes(u)).map(u=>({name:u,onDemand:i.includes(u)}))}async createInterventionRequest(t,n,r,i){return await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-requests`,{method:"POST",body:JSON.stringify({message:t,interventionType:n,time:new Date().toISOString(),deviceId:this.id,tags:i,data:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}async addInterventionResponse(t,n,r){return await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-responses`,{method:"POST",body:JSON.stringify({interventionId:t,interventionType:n,data:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}async getAnnotationCount(t,n){return await Fleet.getAnnotationCount({...t,deviceIds:[this.id]},n)}async getAnnotationCountByIntervals(t,n,r){return await Fleet.getAnnotationCountByIntervals({...t,deviceIds:[this.id]},n,r)}async eventsCounter(t,n,r,i,s){return await Fleet.eventsCounter(t,n,r,i,{...s,deviceIds:[this.id]})}async createShareLink(t,n){return t.scope.deviceIds=[this.id],await Fleet.createShareLink(t,n)}async createDevice(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/devices`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}async patchDevice(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}}class PeerDevice extends BaseDevice{constructor(n){super();Te(this,"id");Te(this,"telemetryStreamActive",!1);Te(this,"streamTelemetry",{});this.peerUrl=n}async getLatestTelemetry(){this.telemetryStreamActive||this.subscribeToTelemetry();const n=this.streamTelemetry;return Object.entries(n).map(([i,s])=>({deviceId:this.id,streamName:i,streamType:"json",currentValue:s,currentValueTime:s.timestamp,tags:{}}))}subscribeToTelemetry(){this.telemetryStreamActive=!0;const n=this;fetch(`${this.peerUrl}/v1/telemetry`,{method:"POST"}).then(r=>{if(r===null||r.body===null){this.telemetryStreamActive=!1;return}const i=r.body.getReader();return new ReadableStream({start(s){function l(o){if(o.done){n.telemetryStreamActive=!1,s.close();return}const c=o.value;new TextDecoder("utf-8").decode(c).split(`
|
|
59
|
-
`).forEach(E=>{var _;if(E.length>0){const h=JSON.parse(E);if((_=h.result)!=null&&_.datapoint){const g=h.result.datapoint,b=g.stream;delete g.stream,n.streamTelemetry[b]=g}}}),n.readNextTelemetryRecord(i,l)}n.readNextTelemetryRecord(i,l)}})}).catch(r=>{this.telemetryStreamActive=!1,console.error("Telemetry error:",r)})}readNextTelemetryRecord(n,r){n.read().then(r).catch(i=>{this.telemetryStreamActive=!1,console.error("Telemetry error:",i)})}async getDeviceId(){return(await(await fetch(`${this.peerUrl}/v1/config`)).json()).configuration.id}async getConfiguration(){return(await(await fetch(`${this.peerUrl}/v1/config`)).json()).configuration.document}async startRealtimeConnection(n){if(console.debug(`${new Date().toISOString()} :: Connection start requested`),this.rtcClient&&this.connectionMonitorInterval!==void 0)throw new Error(`Already created realtime connection to device ${this.id}`);this.rtcClient&&console.warn("overwriting existing rtcClient due to missing connectionMonitorInterval");const r=new distExports.RtcClient({lanOnlyMode:!0,receive:this.handleMessage,sessionType:n});for(await r.connectLan(this.peerUrl);r.getConnectionStatus(this.peerUrl)!=="connected";)await delay(100);this.rtcClient=r,this.initConnectionMonitoring()}initConnectionMonitoring(){this.connectionMonitorInterval=setInterval(async()=>{let n=!1;this.rtcClient&&(this.rtcClient.getConnectionStatus(this.peerUrl)!=="connected"?(console.debug(`${new Date().toISOString()} :: data channel closed`),n=!0):console.debug(`${new Date().toISOString()} :: data channel appears active`)),(!this.rtcClient||n)&&(this.emit("disconnect"),this.stopRealtimeConnection().catch(r=>{console.error(r)}))},1e3)}async getRemotePeer(){return{id:this.peerUrl,organizationId:"",deviceId:this.id,capabilities:[],capabilitySet:{}}}async stopRealtimeConnection(){let n=!1;if(this.rtcClient){this.stopConnectionMonitoring(),this.id?(await this.rtcClient.disconnect(this.id),this.remoteDevicePeerId=null):n=!0;try{await this.rtcClient.shutdown()}finally{this.rtcClient=void 0}}if(n)throw new Error(`Realtime connection hasn't been started for ${this.id}`)}}const Ge=class{static async setDefaultDevice(t){Ge.defaultDeviceId=t}static async getCurrentDevice(){if(!Authentication.token)throw new Error("Not authenticated");if(!Ge.defaultDeviceId)throw new Error("No known default device");const r=(await(await fetch(`${FORMANT_API_URL}/v1/admin/device-details/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.find(l=>l.id===Ge.defaultDeviceId),i=r.name,s=new Device(Ge.defaultDeviceId,i,defined(Authentication.currentOrganization),r.tags);return Ge.knownContext.push(new WeakRef(s)),s}static async getPeerDevice(t){const n=new PeerDevice(t);return n.id=await n.getDeviceId(),n}static async getDevice(t){if(!Authentication.token)throw new Error("Not authenticated");const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json(),i=r.name,s=new Device(t,i,r.organizationId,r.tags);return Ge.knownContext.push(new WeakRef(s)),s}static async getDevices(){if(!Authentication.token)throw new Error("Not authenticated");const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/device-details/query`,{method:"POST",body:JSON.stringify({enabled:!0,type:"default"}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();return n.items,n.items.map(r=>new Device(r.id,r.name,r.organizationId,r.tags))}static async queryDevices(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/query`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(i=>new Device(i.id,i.name,i.organizationId,i.tags))}static async getOnlineDevices(){if(!Authentication.token)throw new Error("Not authenticated");const r=(await(await fetch(`${FORMANT_API_URL}/v1/queries/online-devices`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items;return(await Ge.getDevices()).filter(s=>r.includes(s.id))}static async getPeers(){if(!Authentication.token)throw new Error("Not authenticated");const t=defaultRtcClientPool.get();try{return await t.getPeers()}finally{await t.shutdown()}}static async getRealtimeSessions(){if(!Authentication.token)throw new Error("Not authenticated");const t=defaultRtcClientPool.get();try{return await t.getSessions()}finally{await t.shutdown()}}static async getRealtimeDevices(){if(!Authentication.token)throw new Error("Not authenticated");const r=(await(await fetch(`${FORMANT_API_URL}/v1/signaling/peers`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(s=>s.deviceId);return(await Ge.getDevices()).filter(s=>r.includes(s.id))}static async getLatestTelemetry(...t){const n=t.flat().filter(s=>!!s);return n.length===0?[]:(await(await fetch(`${FORMANT_API_URL}/v1/queries/stream-current-value`,{method:"POST",body:JSON.stringify({deviceIds:n}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getTelemetry(t,n,r,i,s){let l=t;Array.isArray(t)||(l=[t]);let o=n;return Array.isArray(n)||(o=[n]),(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify({deviceIds:l,end:i.toISOString(),names:o,start:r.toISOString(),tags:s}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getFileUrl(t){const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/files/query`,{method:"POST",body:JSON.stringify({fileIds:[t]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();if(r.fileUrls.length===0)throw new Error("File not found");return r.fileUrls[0]}static async queryTelemetry(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async aggregateTelemetry(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).aggregates}static async queryEvents(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/events/query`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getEvent(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/events/query/id=${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getInterventions(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-requests`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getCurrentGroup(){if(!Authentication.token)throw new Error("Not authenticated");let t=new URLSearchParams("");typeof window<"u"&&(t=new URLSearchParams(window.location.search));const n=t.get("group");if(n===null||n.trim()==="")return;const r=await fetch(`${FORMANT_API_URL}/v1/admin/groups/`+n,{headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),{tagKey:i,tagValue:s}=await r.json();return await this.queryDevices({tags:{[i]:[s]},enabled:!0,type:"default"})}static async getAnnotationCount(t,n){return(await this.queryEvents({...t,eventTypes:["annotation"]})).filter(l=>!!l.tags&&Object.keys(l.tags).includes(n)).reduce((l,o)=>{const c=o.tags[n];return c in l?(l[c]+=1,l):(l[c]=1,l)},{})}static async getAnnotationCountByIntervals(t,n,r){const{end:i,start:s}=t,o=aggregateByDateFunctions[r].interval({start:new Date(s),end:new Date(i)}),c=o.map((f,E)=>{const _=new Date(f).toISOString(),h=E===o.length-1?new Date(Date.now()).toISOString():new Date(o[E+1]);return this.getAnnotationCount({...t,start:_,end:h},n)}),u=await Promise.all(c);return o.map((f,E)=>({date:new Date(f).toISOString(),annotations:u[E]}))}static async getStreams(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/streams`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.filter(r=>r.enabled)}static async patchStream(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/streams/${t.id}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getViews(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/views`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async patchView(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/views/${t.id}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async eventsCounter(t,n,r,i,s){const l=aggregateByDateFunctions[n];return await Promise.all(Array(r).fill(0).map(async(o,c)=>{const u=new Date(i),f=l.sub(l.start(u),r-c-1),E=l.sub(l.end(u),r-c-1),_=formatTimeFrameText(f.toLocaleDateString(),E.toLocaleDateString()),h=await Ge.queryEvents({...s,eventTypes:t,start:new Date(f).toISOString(),end:new Date(E).toISOString()});return{date:_,events:h}}))}static async getAnalyticsModules(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/analytics-modules`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getAnalyticStreams(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics/streams`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getTaskReportTables(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics/task-reports`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async queryAnalytics(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getAnalyticsRows(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics/rows`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getTaskReportRows(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics/task-report-rows`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async createShareLink(t,n){if(!Authentication.token)throw new Error("Not authenticated");const i=(await this.getViews()).filter(c=>c.name===n);if(i.length===0)return console.warn("View does not exist or it is misspell"),null;const s=await fetch(`${FORMANT_API_URL}/v1/admin/shares`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),l=FORMANT_API_URL.replace("api","app"),{code:o}=await s.json();return`${l}/shares/${o}#${serializeHash({viewId:i[0].id})}`}static async listFleets(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createFleet(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getFleet(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchFleet(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteFleet(t){if(!Authentication.token)throw new Error("Not authenticated");await fetch(`${FORMANT_API_URL}/v1/admin/fleets/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}static async addDeviceToFleet(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/${t}`,{method:"PATCH",body:JSON.stringify({fleetId:n}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getFleetDevices(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets/${t}/devices`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}};let Fleet=Ge;Te(Fleet,"defaultDeviceId"),Te(Fleet,"knownContext",[]);class RequestDataChannel{constructor(t,n,r){Te(this,"channel");Te(this,"requestIdToResponseMap",new Map);this.device=t,this.channel_name=n,this.timeout=r}addOpenListener(t){defined(this.channel,"channel not initalized").addOpenListener(t)}removeOpenListener(t){defined(this.channel,"channel not initalized").removeOpenListener(t)}addCloseListener(t){defined(this.channel,"channel not initalized").addCloseListener(t)}removeCloseListener(t){defined(this.channel,"channel not initalized").removeCloseListener(t)}addErrorListener(t){defined(this.channel,"channel not initalized").addErrorListener(t)}removeErrorListener(t){defined(this.channel,"channel not initalized").removeErrorListener(t)}}class BinaryRequestDataChannel extends RequestDataChannel{constructor(){super(...arguments);Te(this,"RESPONSE_SUCCESS_BYTE",0);Te(this,"decoder",new TextDecoder)}generateBinaryId(){const n=new Uint8Array(16);for(let r=0;r<n.length;r++)n[r]=Math.floor(Math.random()*256);return n}async initialize(){this.channel=await this.device.createCustomDataChannel(this.channel_name),this.channel.addBinaryListener(n=>{const i=n.slice(0,16).toString();if(i.length===0)throw new Error("Invalid response");const s=n.slice(16);if(s.length===0)throw new Error("Invalid response");this.requestIdToResponseMap.has(i)&&this.requestIdToResponseMap.set(i,s)})}async request(n){if(this.channel||await this.initialize(),!this.channel)throw new Error("Failed to create channel");const{channel:r,requestIdToResponseMap:i,timeout:s}=this;await r.waitTilReady();const l=this.generateBinaryId(),o=l.toString();i.set(o,!0),r.sendBinary(new Uint8Array([...l,...n]));const c=new Date().getTime();for(;new Date().getTime()<c+s;)if(await delay(50),i.has(o)){const u=i.get(o);if(u!==!0){i.delete(o);const f=u[0]===this.RESPONSE_SUCCESS_BYTE,E=u.slice(1);if(f)return E;throw console.error({name:"AdapterError",message:this.decoder.decode(E)}),new Error("Binary request datachannel adapter error")}}throw i.delete(o),console.error({name:"TimeoutError",message:`Request timed out after ${s/1e3} seconds`}),new Error("Binary request data channel request timed out")}}class TextRequestDataChannel extends RequestDataChannel{generateTextId(){return Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2)}async initialize(){this.channel=await this.device.createCustomDataChannel(this.channel_name),this.channel.addListener(t=>{const n=JSON.parse(t),{id:r,data:i,error:s}=n;if(!r)throw new Error("Invalid response");if(!i&&!s)throw new Error("Invalid response");this.requestIdToResponseMap.has(r)&&this.requestIdToResponseMap.set(r,n)})}async request(t){if(this.channel||await this.initialize(),!this.channel)throw new Error("Failed to create channel");const{channel:n,requestIdToResponseMap:r,timeout:i}=this;await n.waitTilReady();const s=this.generateTextId();r.set(s,!0),n.send(JSON.stringify({id:s,data:t}));const l=new Date().getTime();for(;new Date().getTime()<l+i;)if(await delay(50),r.has(s)){const o=r.get(s);if(o!==!0){r.delete(s);const{data:c,error:u}=o;if(c)return c;if(u)throw console.error({name:"AdapterError",message:u}),new Error("Text request datachannel adapter error")}}throw r.delete(s),console.error({name:"TimeoutError",message:`Request timed out after ${i/1e3} seconds`}),new Error("Text request datachannel request timed out")}}class KeyValue{static async set(t,n,r){try{const i=await fetch(FORMANT_API_URL+"/v1/admin/key-value",{method:"POST",body:JSON.stringify({organizationId:defined(Authentication.currentUser).organizationId,key:t,value:n,tags:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),s=await i.json();if(i.status!==200)throw new Error(s.message)}catch(i){throw i}}static async get(t){try{const n=await fetch(FORMANT_API_URL+`/v1/admin/key-value/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),r=await n.json();if(n.status!==200)throw new Error(r.message);return r.value}catch(n){throw n}}static async list(){try{const t=await fetch(FORMANT_API_URL+"/v1/admin/key-value",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),n=await t.json();if(t.status!==200)throw new Error(n.message);return n.items}catch(t){throw t}}static async delete(t){try{if(!(await fetch(FORMANT_API_URL+`/v1/admin/key-value/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).ok)throw new Error("Unable to handle request");return}catch(n){throw n}}}function stringToArrayBuffer(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))}function browser(){const{userAgent:e}=navigator;return e.includes("Firefox/")?"Firefox":e.includes("Edg/")?"Edge":e.includes("Chrome/")?"Chrome":e.includes("Safari/")?"Safari":e.includes("MSIE/")||e.includes("Trident/")?"IE":"Other"}const rtcAudioChunkStreamType="audio-chunk";class AudioPlayer{constructor(t,n){Te(this,"muted",!1);Te(this,"hasReceivedData",!1);Te(this,"audioContext");Te(this,"chunks",[]);Te(this,"isPlaying",!1);Te(this,"startTime",0);Te(this,"lastChunkOffset",0);Te(this,"bufferSize",3);Te(this,"receive",async t=>{var l;const n=(l=t.payload.audioChunk)==null?void 0:l.chunk_data;if(!n)return;this.hasReceivedData||(this.hasReceivedData=!0);const{audioContext:r,muted:i}=this;if(!r||t.header.stream.streamType!==rtcAudioChunkStreamType||i!==!1)return;const s=stringToArrayBuffer(n);try{await r.decodeAudioData(s.buffer,this.scheduleChunk)}catch(o){console.warn("Error decoding audio buffer, changing audioWireFormat on agent",{error:o}),this.changeAudioWireFormat("wav")}});Te(this,"scheduleChunk",t=>{const{audioContext:n}=this;if(!n)return;(this.chunks.length>this.bufferSize||this.isPlaying===!1)&&(this.chunks.forEach(i=>{i.stop()}),this.isPlaying=!1,this.chunks=[]);const r=this.createChunk(t);r&&r.buffer&&(this.isPlaying===!1&&(this.startTime=n.currentTime,this.lastChunkOffset=0,this.isPlaying=!0),r.start(this.startTime+this.lastChunkOffset,0,t.duration),this.lastChunkOffset+=r.buffer.duration,this.chunks.push(r))});this.device=t,this.stream=n,this.device.startListeningToRealtimeDataStream(n),this.device.addRealtimeListener((i,s)=>{this.receive(s)}),browser()==="Safari"||browser()==="IE"?this.changeAudioWireFormat("wav"):this.changeAudioWireFormat("opus");const r=window.AudioContext||window.webkitAudioContext;this.audioContext=new r}async play(){var t,n;((t=this.audioContext)==null?void 0:t.state)==="suspended"&&await((n=this.audioContext)==null?void 0:n.resume()),this.muted=!1}async pause(){await this.audioContext.suspend(),this.muted=!0}destroy(){this.device.stopListeningToRealtimeDataStream(this.stream)}createChunk(t){const{audioContext:n}=this;if(!n)return;const r=n.createBufferSource();return r.buffer=t,r.connect(n.destination),r.loop=!1,r.onended=i=>{this.chunks.splice(this.chunks.indexOf(r),1),this.chunks.length===0&&(this.isPlaying=!1)},r}changeAudioWireFormat(t){const{stream:n}=this;(async()=>await this.device.changeStreamAudioType(n.name,t))()}}class Account{static async listAccounts(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createAccounts(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getAccount(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchAccount(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteAccount(t){if(!Authentication.token)throw new Error("Not authenticated");await fetch(`${FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}static async getAccountTree(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts/${t}/tree`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}}class Role{static async listRoles(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/roles`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createRole(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/roles`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getRole(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/roles/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchRole(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/roles/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteRole(t){if(!Authentication.token)throw new Error("Not authenticated");await fetch(`${FORMANT_API_URL}/v1/admin/roles/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}}class User{static async listUsers(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/users`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createUser(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/users`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getUser(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/users/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchUser(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/users/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteUser(t){if(!Authentication.token)throw new Error("Not authenticated");await fetch(`${FORMANT_API_URL}/v1/admin/users/${t}`,{method:"PATCH",body:JSON.stringify({enabled:!1,roleId:null,teamId:null}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}}const accessLevels=["viewer","operator","administrator"],viewer="viewer",operator="operator",administrator="administrator",aggregateLevels=["year","month","week","day","hour","minute"],annotationTypes=["tag","sheet","user"],eventTypes=["triggered-event","intervention-request","teleop-session-record","port-forwarding-session-record","command-request","command-response","command-delivery","custom","comment","system","annotation"],healthStatuses=["unknown","operational","offline","error"],interventionTypes=["selection","labeling","teleop"],severities=["info","warning","error","critical"],videoMimeTypes=["video/mp4"];window.Buffer=Buffer;const urlParams=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams(""),urlDevice=urlParams.get("device");urlDevice&&Fleet.setDefaultDevice(urlDevice);const urlAuth=urlParams.get("auth");urlAuth&&Authentication.loginWithToken(urlAuth);const moduleName=urlParams.get("module");moduleName&&Authentication.listenForRefresh(),typeof window<"u"&&App.listenForConnectionEvents(),exports.Account=Account,exports.App=App,exports.AudioPlayer=AudioPlayer,exports.Authentication=Authentication,exports.BinaryRequestDataChannel=BinaryRequestDataChannel,exports.CaptureStream=CaptureStream,exports.DataChannel=DataChannel,exports.Device=Device,exports.Fleet=Fleet,exports.KeyValue=KeyValue,exports.Manipulator=Manipulator,exports.PeerDevice=PeerDevice,exports.Role=Role,exports.SessionType=SessionTypeConstants,exports.TextRequestDataChannel=TextRequestDataChannel,exports.User=User,exports.accessLevels=accessLevels,exports.administrator=administrator,exports.aggregateByDateFunctions=aggregateByDateFunctions,exports.aggregateFunctionMap=aggregateFunctionMap,exports.aggregateFunctions=aggregateFunctions,exports.aggregateLevels=aggregateLevels,exports.annotationTypes=annotationTypes,exports.combineNumericAggregates=combineNumericAggregates,exports.combineNumericSetAggregates=combineNumericSetAggregates,exports.deserializeHash=deserializeHash,exports.eventTypes=eventTypes,exports.formatTimeFrameText=formatTimeFrameText,exports.getAverage=getAverage,exports.getCount=getCount,exports.getMax=getMax,exports.getMin=getMin,exports.getStandardDeviation=getStandardDeviation,exports.getSum=getSum,exports.getVariance=getVariance,exports.getZeroINumericSet=getZeroINumericSet,exports.healthStatuses=healthStatuses,exports.interventionTypes=interventionTypes,exports.isRtcPeer=isRtcPeer,exports.operator=operator,exports.reduceNumericSetStreamAggregates=reduceNumericSetStreamAggregates,exports.reduceNumericStreamAggregates=reduceNumericStreamAggregates,exports.serializeHash=serializeHash,exports.severities=severities,exports.timeout=timeout,exports.vailableAggregationIntervals=vailableAggregationIntervals,exports.videoMimeTypes=videoMimeTypes,exports.viewer=viewer,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
|
58
|
+
`)+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return typeof e=="boolean"}function isNull(e){return e===null}function isNumber(e){return typeof e=="number"}function isString(e){return typeof e=="string"}function isUndefined(e){return e===void 0}function isRegExp(e){return isObject(e)&&objectToString(e)==="[object RegExp]"}function isObject(e){return typeof e=="object"&&e!==null}function isDate(e){return isObject(e)&&objectToString(e)==="[object Date]"}function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}function isFunction(e){return typeof e=="function"}function objectToString(e){return Object.prototype.toString.call(e)}function _extend(e,t){if(!t||!isObject(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function BufferList(){this.head=null,this.tail=null,this.length=0}BufferList.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},BufferList.prototype.unshift=function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length},BufferList.prototype.shift=function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},BufferList.prototype.clear=function(){this.head=this.tail=null,this.length=0},BufferList.prototype.join=function(e){if(this.length===0)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},BufferList.prototype.concat=function(e){if(this.length===0)return Buffer.alloc(0);if(this.length===1)return this.head.data;for(var t=Buffer.allocUnsafe(e>>>0),n=this.head,r=0;n;)n.data.copy(t,r),r+=n.data.length,n=n.next;return t};var isBufferEncoding=Buffer.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function assertEncoding(e){if(e&&!isBufferEncoding(e))throw new Error("Unknown encoding: "+e)}function StringDecoder(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),assertEncoding(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=base64DetectIncompleteChar;break;default:this.write=passThroughWrite;return}this.charBuffer=new Buffer(6),this.charReceived=0,this.charLength=0}StringDecoder.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";e=e.slice(n,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var i=t.charCodeAt(t.length-1);if(i>=55296&&i<=56319){this.charLength+=this.surrogateSize,t="";continue}if(this.charReceived=this.charLength=0,e.length===0)return t;break}this.detectIncompleteChar(e);var r=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,r),r-=this.charReceived),t+=e.toString(this.encoding,0,r);var r=t.length-1,i=t.charCodeAt(r);if(i>=55296&&i<=56319){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),e.copy(this.charBuffer,0,0,s),t.substring(0,r)}return t},StringDecoder.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(t==1&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},StringDecoder.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t};function passThroughWrite(e){return e.toString(this.encoding)}function utf16DetectIncompleteChar(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Readable.ReadableState=ReadableState;var debug=debuglog("stream");inherits$1(Readable,EventEmitter);function prependListener(e,t,n){if(typeof e.prependListener=="function")return e.prependListener(t,n);!e._events||!e._events[t]?e.on(t,n):Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]}function listenerCount(e,t){return e.listeners(t).length}function ReadableState(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof Duplex&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new BufferList,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new StringDecoder(e.encoding),this.encoding=e.encoding)}function Readable(e){if(!(this instanceof Readable))return new Readable(e);this._readableState=new ReadableState(e,this),this.readable=!0,e&&typeof e.read=="function"&&(this._read=e.read),EventEmitter.call(this)}Readable.prototype.push=function(e,t){var n=this._readableState;return!n.objectMode&&typeof e=="string"&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=Buffer.from(e,t),t="")),readableAddChunk(this,n,e,t,!1)},Readable.prototype.unshift=function(e){var t=this._readableState;return readableAddChunk(this,t,e,"",!0)},Readable.prototype.isPaused=function(){return this._readableState.flowing===!1};function readableAddChunk(e,t,n,r,i){var s=chunkInvalid(t,n);if(s)e.emit("error",s);else if(n===null)t.reading=!1,onEofChunk(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var l=new Error("stream.push() after EOF");e.emit("error",l)}else if(t.endEmitted&&i){var o=new Error("stream.unshift() after end event");e.emit("error",o)}else{var c;t.decoder&&!i&&!r&&(n=t.decoder.write(n),c=!t.objectMode&&n.length===0),i||(t.reading=!1),c||(t.flowing&&t.length===0&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&emitReadable(e))),maybeReadMore(e,t)}else i||(t.reading=!1);return needMoreData(t)}function needMoreData(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}Readable.prototype.setEncoding=function(e){return this._readableState.decoder=new StringDecoder(e),this._readableState.encoding=e,this};var MAX_HWM=8388608;function computeNewHighWaterMark(e){return e>=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Readable.prototype.read=function(e){debug("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return debug("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?endReadable(this):emitReadable(this),null;if(e=howMuchToRead(e,t),e===0&&t.ended)return t.length===0&&endReadable(this),null;var r=t.needReadable;debug("need readable",r),(t.length===0||t.length-e<t.highWaterMark)&&(r=!0,debug("length less than watermark",r)),t.ended||t.reading?(r=!1,debug("reading or ended",r)):r&&(debug("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=howMuchToRead(n,t)));var i;return e>0?i=fromList(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&endReadable(this)),i!==null&&this.emit("data",i),i};function chunkInvalid(e,t){var n=null;return!Buffer.isBuffer(t)&&typeof t!="string"&&t!==null&&t!==void 0&&!e.objectMode&&(n=new TypeError("Invalid non-string/buffer chunk")),n}function onEofChunk(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,emitReadable(e)}}function emitReadable(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?nextTick(emitReadable_,e):emitReadable_(e))}function emitReadable_(e){debug("emit readable"),e.emit("readable"),flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,nextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(debug("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}Readable.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Readable.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e);break}r.pipesCount+=1,debug("pipe count=%d opts=%j",r.pipesCount,t);var i=!t||t.end!==!1,s=i?o:f;r.endEmitted?nextTick(s):n.once("end",s),e.on("unpipe",l);function l(j){debug("onunpipe"),j===n&&f()}function o(){debug("onend"),e.end()}var c=pipeOnDrain(n);e.on("drain",c);var u=!1;function f(){debug("cleanup"),e.removeListener("close",g),e.removeListener("finish",b),e.removeListener("drain",c),e.removeListener("error",h),e.removeListener("unpipe",l),n.removeListener("end",o),n.removeListener("end",f),n.removeListener("data",_),u=!0,r.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var E=!1;n.on("data",_);function _(j){debug("ondata"),E=!1;var F=e.write(j);F===!1&&!E&&((r.pipesCount===1&&r.pipes===e||r.pipesCount>1&&indexOf(r.pipes,e)!==-1)&&!u&&(debug("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,E=!0),n.pause())}function h(j){debug("onerror",j),A(),e.removeListener("error",h),listenerCount(e,"error")===0&&e.emit("error",j)}prependListener(e,"error",h);function g(){e.removeListener("finish",b),A()}e.once("close",g);function b(){debug("onfinish"),e.removeListener("close",g),A()}e.once("finish",b);function A(){debug("unpipe"),n.unpipe(e)}return e.emit("pipe",n),r.flowing||(debug("pipe resume"),n.resume()),e};function pipeOnDrain(e){return function(){var t=e._readableState;debug("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&e.listeners("data").length&&(t.flowing=!0,flow(e))}}Readable.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<r;i++)n[i].emit("unpipe",this);return this}var s=indexOf(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},Readable.prototype.on=function(e,t){var n=EventEmitter.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var r=this._readableState;!r.endEmitted&&!r.readableListening&&(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&emitReadable(this):nextTick(nReadingNextTick,this))}return n},Readable.prototype.addListener=Readable.prototype.on;function nReadingNextTick(e){debug("readable nexttick read 0"),e.read(0)}Readable.prototype.resume=function(){var e=this._readableState;return e.flowing||(debug("resume"),e.flowing=!0,resume(this,e)),this};function resume(e,t){t.resumeScheduled||(t.resumeScheduled=!0,nextTick(resume_,e,t))}function resume_(e,t){t.reading||(debug("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),flow(e),t.flowing&&!t.reading&&e.read(0)}Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function flow(e){var t=e._readableState;for(debug("flow",t.flowing);t.flowing&&e.read()!==null;);}Readable.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(debug("wrapped end"),t.decoder&&!t.ended){var l=t.decoder.end();l&&l.length&&r.push(l)}r.push(null)}),e.on("data",function(l){if(debug("wrapped data"),t.decoder&&(l=t.decoder.write(l)),!(t.objectMode&&l==null)&&!(!t.objectMode&&(!l||!l.length))){var o=r.push(l);o||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=function(l){return function(){return e[l].apply(e,arguments)}}(i));var s=["error","close","destroy","pause","resume"];return forEach(s,function(l){e.on(l,r.emit.bind(r,l))}),r._read=function(l){debug("wrapped _read",l),n&&(n=!1,e.resume())},r},Readable._fromList=fromList;function fromList(e,t){if(t.length===0)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(t.decoder?n=t.buffer.join(""):t.buffer.length===1?n=t.buffer.head.data:n=t.buffer.concat(t.length),t.buffer.clear()):n=fromListPartial(e,t.buffer,t.decoder),n}function fromListPartial(e,t,n){var r;return e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?r=t.shift():r=n?copyFromBufferString(e,t):copyFromBuffer(e,t),r}function copyFromBufferString(e,t){var n=t.head,r=1,i=n.data;for(e-=i.length;n=n.next;){var s=n.data,l=e>s.length?s.length:e;if(l===s.length?i+=s:i+=s.slice(0,e),e-=l,e===0){l===s.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(l));break}++r}return t.length-=r,i}function copyFromBuffer(e,t){var n=Buffer.allocUnsafe(e),r=t.head,i=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var s=r.data,l=e>s.length?s.length:e;if(s.copy(n,n.length-e,0,l),e-=l,e===0){l===s.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=s.slice(l));break}++i}return t.length-=i,n}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,nextTick(endReadableNT,t,e))}function endReadableNT(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function forEach(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n)}function indexOf(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}Writable.WritableState=WritableState,inherits$1(Writable,EventEmitter);function nop(){}function WriteReq(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function WritableState(e,t){Object.defineProperty(this,"buffer",{get:deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof Duplex&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:r,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(s){onwrite(t,s)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new CorkedRequest(this)}WritableState.prototype.getBuffer=function e(){for(var t=this.bufferedRequest,n=[];t;)n.push(t),t=t.next;return n};function Writable(e){if(!(this instanceof Writable)&&!(this instanceof Duplex))return new Writable(e);this._writableState=new WritableState(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev)),EventEmitter.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function writeAfterEnd(e,t){var n=new Error("write after end");e.emit("error",n),nextTick(t,n)}function validChunk(e,t,n,r){var i=!0,s=!1;return n===null?s=new TypeError("May not write null values to stream"):!Buffer.isBuffer(n)&&typeof n!="string"&&n!==void 0&&!t.objectMode&&(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),nextTick(r,s),i=!1),i}Writable.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return typeof t=="function"&&(n=t,t=null),Buffer.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),typeof n!="function"&&(n=nop),r.ended?writeAfterEnd(this,n):validChunk(this,r,e,n)&&(r.pendingcb++,i=writeOrBuffer(this,r,e,t,n)),i},Writable.prototype.cork=function(){var e=this._writableState;e.corked++},Writable.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest&&clearBuffer(this,e))},Writable.prototype.setDefaultEncoding=function e(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function decodeChunk(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Buffer.from(t,n)),t}function writeOrBuffer(e,t,n,r,i){n=decodeChunk(t,n,r),Buffer.isBuffer(n)&&(r="buffer");var s=t.objectMode?1:n.length;t.length+=s;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var o=t.lastBufferedRequest;t.lastBufferedRequest=new WriteReq(n,r,i),o?o.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else doWrite(e,t,!1,s,n,r,i);return l}function doWrite(e,t,n,r,i,s,l){t.writelen=r,t.writecb=l,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,s,t.onwrite),t.sync=!1}function onwriteError(e,t,n,r,i){--t.pendingcb,n?nextTick(i,r):i(r),e._writableState.errorEmitted=!0,e.emit("error",r)}function onwriteStateUpdate(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function onwrite(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(onwriteStateUpdate(n),t)onwriteError(e,n,r,t,i);else{var s=needFinish(n);!s&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&clearBuffer(e,n),r?nextTick(afterWrite,e,n,s,i):afterWrite(e,n,s,i)}}function afterWrite(e,t,n,r){n||onwriteDrain(e,t),t.pendingcb--,r(),finishMaybe(e,t)}function onwriteDrain(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function clearBuffer(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),s=t.corkedRequestsFree;s.entry=n;for(var l=0;n;)i[l]=n,n=n.next,l+=1;doWrite(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new CorkedRequest(t)}else{for(;n;){var o=n.chunk,c=n.encoding,u=n.callback,f=t.objectMode?1:o.length;if(doWrite(e,t,!1,f,o,c,u),n=n.next,t.writing)break}n===null&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=n,t.bufferProcessing=!1}Writable.prototype._write=function(e,t,n){n(new Error("not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,n){var r=this._writableState;typeof e=="function"?(n=e,e=null,t=null):typeof t=="function"&&(n=t,t=null),e!=null&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),!r.ending&&!r.finished&&endWritable(this,r,n)};function needFinish(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function prefinish(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function finishMaybe(e,t){var n=needFinish(t);return n&&(t.pendingcb===0?(prefinish(e,t),t.finished=!0,e.emit("finish")):prefinish(e,t)),n}function endWritable(e,t,n){t.ending=!0,finishMaybe(e,t),n&&(t.finished?nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}function CorkedRequest(e){var t=this;this.next=null,this.entry=null,this.finish=function(n){var r=t.entry;for(t.entry=null;r;){var i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}inherits$1(Duplex,Readable);for(var keys=Object.keys(Writable.prototype),v=0;v<keys.length;v++){var method=keys[v];Duplex.prototype[method]||(Duplex.prototype[method]=Writable.prototype[method])}function Duplex(e){if(!(this instanceof Duplex))return new Duplex(e);Readable.call(this,e),Writable.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",onend)}function onend(){this.allowHalfOpen||this._writableState.ended||nextTick(onEndNT,this)}function onEndNT(e){e.end()}inherits$1(Transform,Duplex);function TransformState(e){this.afterTransform=function(t,n){return afterTransform(e,t,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function afterTransform(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,n!=null&&e.push(n),i(t);var s=e._readableState;s.reading=!1,(s.needReadable||s.length<s.highWaterMark)&&e._read(s.highWaterMark)}function Transform(e){if(!(this instanceof Transform))return new Transform(e);Duplex.call(this,e),this._transformState=new TransformState(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.once("prefinish",function(){typeof this._flush=="function"?this._flush(function(n){done(t,n)}):done(t)})}Transform.prototype.push=function(e,t){return this._transformState.needTransform=!1,Duplex.prototype.push.call(this,e,t)},Transform.prototype._transform=function(e,t,n){throw new Error("Not implemented")},Transform.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},Transform.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};function done(e,t){if(t)return e.emit("error",t);var n=e._writableState,r=e._transformState;if(n.length)throw new Error("Calling transform done when ws.length != 0");if(r.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}inherits$1(PassThrough,Transform);function PassThrough(e){if(!(this instanceof PassThrough))return new PassThrough(e);Transform.call(this,e)}PassThrough.prototype._transform=function(e,t,n){n(null,e)},inherits$1(Stream,EventEmitter),Stream.Readable=Readable,Stream.Writable=Writable,Stream.Duplex=Duplex,Stream.Transform=Transform,Stream.PassThrough=PassThrough,Stream.Stream=Stream;function Stream(){EventEmitter.call(this)}Stream.prototype.pipe=function(e,t){var n=this;function r(f){e.writable&&e.write(f)===!1&&n.pause&&n.pause()}n.on("data",r);function i(){n.readable&&n.resume&&n.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(n.on("end",l),n.on("close",o));var s=!1;function l(){s||(s=!0,e.end())}function o(){s||(s=!0,typeof e.destroy=="function"&&e.destroy())}function c(f){if(u(),EventEmitter.listenerCount(this,"error")===0)throw f}n.on("error",c),e.on("error",c);function u(){n.removeListener("data",r),e.removeListener("drain",i),n.removeListener("end",l),n.removeListener("close",o),n.removeListener("error",c),e.removeListener("error",c),n.removeListener("end",u),n.removeListener("close",u),e.removeListener("close",u)}return n.on("end",u),n.on("close",u),e.on("close",u),e.emit("pipe",n),e};const msg={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function ZStream(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function arraySet(e,t,n,r,i){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),i);return}for(var s=0;s<r;s++)e[i+s]=t[n+s]}var Buf8=Uint8Array,Buf16=Uint16Array,Buf32=Int32Array,Z_FIXED$2=4,Z_BINARY$1=0,Z_TEXT$1=1,Z_UNKNOWN$2=2;function zero$1(e){for(var t=e.length;--t>=0;)e[t]=0}var STORED_BLOCK=0,STATIC_TREES=1,DYN_TREES=2,MIN_MATCH$1=3,MAX_MATCH$1=258,LENGTH_CODES$1=29,LITERALS$1=256,L_CODES$1=LITERALS$1+1+LENGTH_CODES$1,D_CODES$1=30,BL_CODES$1=19,HEAP_SIZE$1=2*L_CODES$1+1,MAX_BITS$1=15,Buf_size=16,MAX_BL_BITS=7,END_BLOCK=256,REP_3_6=16,REPZ_3_10=17,REPZ_11_138=18,extra_lbits=[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],extra_dbits=[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],extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],DIST_CODE_LEN=512,static_ltree=new Array((L_CODES$1+2)*2);zero$1(static_ltree);var static_dtree=new Array(D_CODES$1*2);zero$1(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero$1(_dist_code);var _length_code=new Array(MAX_MATCH$1-MIN_MATCH$1+1);zero$1(_length_code);var base_length=new Array(LENGTH_CODES$1);zero$1(base_length);var base_dist=new Array(D_CODES$1);zero$1(base_dist);function StaticTreeDesc(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var static_l_desc,static_d_desc,static_bl_desc;function TreeDesc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function d_code(e){return e<256?_dist_code[e]:_dist_code[256+(e>>>7)]}function put_short(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function send_bits(e,t,n){e.bi_valid>Buf_size-n?(e.bi_buf|=t<<e.bi_valid&65535,put_short(e,e.bi_buf),e.bi_buf=t>>Buf_size-e.bi_valid,e.bi_valid+=n-Buf_size):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function send_code(e,t,n){send_bits(e,n[t*2],n[t*2+1])}function bi_reverse(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function bi_flush(e){e.bi_valid===16?(put_short(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function gen_bitlen(e,t){var n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,s=t.stat_desc.has_stree,l=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,c=t.stat_desc.max_length,u,f,E,_,h,g,b=0;for(_=0;_<=MAX_BITS$1;_++)e.bl_count[_]=0;for(n[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;u<HEAP_SIZE$1;u++)f=e.heap[u],_=n[n[f*2+1]*2+1]+1,_>c&&(_=c,b++),n[f*2+1]=_,!(f>r)&&(e.bl_count[_]++,h=0,f>=o&&(h=l[f-o]),g=n[f*2],e.opt_len+=g*(_+h),s&&(e.static_len+=g*(i[f*2+1]+h)));if(b!==0){do{for(_=c-1;e.bl_count[_]===0;)_--;e.bl_count[_]--,e.bl_count[_+1]+=2,e.bl_count[c]--,b-=2}while(b>0);for(_=c;_!==0;_--)for(f=e.bl_count[_];f!==0;)E=e.heap[--u],!(E>r)&&(n[E*2+1]!==_&&(e.opt_len+=(_-n[E*2+1])*n[E*2],n[E*2+1]=_),f--)}}function gen_codes(e,t,n){var r=new Array(MAX_BITS$1+1),i=0,s,l;for(s=1;s<=MAX_BITS$1;s++)r[s]=i=i+n[s-1]<<1;for(l=0;l<=t;l++){var o=e[l*2+1];o!==0&&(e[l*2]=bi_reverse(r[o]++,o))}}function tr_static_init(){var e,t,n,r,i,s=new Array(MAX_BITS$1+1);for(n=0,r=0;r<LENGTH_CODES$1-1;r++)for(base_length[r]=n,e=0;e<1<<extra_lbits[r];e++)_length_code[n++]=r;for(_length_code[n-1]=r,i=0,r=0;r<16;r++)for(base_dist[r]=i,e=0;e<1<<extra_dbits[r];e++)_dist_code[i++]=r;for(i>>=7;r<D_CODES$1;r++)for(base_dist[r]=i<<7,e=0;e<1<<extra_dbits[r]-7;e++)_dist_code[256+i++]=r;for(t=0;t<=MAX_BITS$1;t++)s[t]=0;for(e=0;e<=143;)static_ltree[e*2+1]=8,e++,s[8]++;for(;e<=255;)static_ltree[e*2+1]=9,e++,s[9]++;for(;e<=279;)static_ltree[e*2+1]=7,e++,s[7]++;for(;e<=287;)static_ltree[e*2+1]=8,e++,s[8]++;for(gen_codes(static_ltree,L_CODES$1+1,s),e=0;e<D_CODES$1;e++)static_dtree[e*2+1]=5,static_dtree[e*2]=bi_reverse(e,5);static_l_desc=new StaticTreeDesc(static_ltree,extra_lbits,LITERALS$1+1,L_CODES$1,MAX_BITS$1),static_d_desc=new StaticTreeDesc(static_dtree,extra_dbits,0,D_CODES$1,MAX_BITS$1),static_bl_desc=new StaticTreeDesc(new Array(0),extra_blbits,0,BL_CODES$1,MAX_BL_BITS)}function init_block(e){var t;for(t=0;t<L_CODES$1;t++)e.dyn_ltree[t*2]=0;for(t=0;t<D_CODES$1;t++)e.dyn_dtree[t*2]=0;for(t=0;t<BL_CODES$1;t++)e.bl_tree[t*2]=0;e.dyn_ltree[END_BLOCK*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function bi_windup(e){e.bi_valid>8?put_short(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function copy_block(e,t,n,r){bi_windup(e),r&&(put_short(e,n),put_short(e,~n)),arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function smaller(e,t,n,r){var i=t*2,s=n*2;return e[i]<e[s]||e[i]===e[s]&&r[t]<=r[n]}function pqdownheap(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&smaller(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!smaller(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function compress_block(e,t,n){var r,i,s=0,l,o;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+s*2]<<8|e.pending_buf[e.d_buf+s*2+1],i=e.pending_buf[e.l_buf+s],s++,r===0?send_code(e,i,t):(l=_length_code[i],send_code(e,l+LITERALS$1+1,t),o=extra_lbits[l],o!==0&&(i-=base_length[l],send_bits(e,i,o)),r--,l=d_code(r),send_code(e,l,n),o=extra_dbits[l],o!==0&&(r-=base_dist[l],send_bits(e,r,o)));while(s<e.last_lit);send_code(e,END_BLOCK,t)}function build_tree(e,t){var n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems,l,o,c=-1,u;for(e.heap_len=0,e.heap_max=HEAP_SIZE$1,l=0;l<s;l++)n[l*2]!==0?(e.heap[++e.heap_len]=c=l,e.depth[l]=0):n[l*2+1]=0;for(;e.heap_len<2;)u=e.heap[++e.heap_len]=c<2?++c:0,n[u*2]=1,e.depth[u]=0,e.opt_len--,i&&(e.static_len-=r[u*2+1]);for(t.max_code=c,l=e.heap_len>>1;l>=1;l--)pqdownheap(e,n,l);u=s;do l=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pqdownheap(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=l,e.heap[--e.heap_max]=o,n[u*2]=n[l*2]+n[o*2],e.depth[u]=(e.depth[l]>=e.depth[o]?e.depth[l]:e.depth[o])+1,n[l*2+1]=n[o*2+1]=u,e.heap[1]=u++,pqdownheap(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],gen_bitlen(e,t),gen_codes(n,c,e.bl_count)}function scan_tree(e,t,n){var r,i=-1,s,l=t[0*2+1],o=0,c=7,u=4;for(l===0&&(c=138,u=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)s=l,l=t[(r+1)*2+1],!(++o<c&&s===l)&&(o<u?e.bl_tree[s*2]+=o:s!==0?(s!==i&&e.bl_tree[s*2]++,e.bl_tree[REP_3_6*2]++):o<=10?e.bl_tree[REPZ_3_10*2]++:e.bl_tree[REPZ_11_138*2]++,o=0,i=s,l===0?(c=138,u=3):s===l?(c=6,u=3):(c=7,u=4))}function send_tree(e,t,n){var r,i=-1,s,l=t[0*2+1],o=0,c=7,u=4;for(l===0&&(c=138,u=3),r=0;r<=n;r++)if(s=l,l=t[(r+1)*2+1],!(++o<c&&s===l)){if(o<u)do send_code(e,s,e.bl_tree);while(--o!==0);else s!==0?(s!==i&&(send_code(e,s,e.bl_tree),o--),send_code(e,REP_3_6,e.bl_tree),send_bits(e,o-3,2)):o<=10?(send_code(e,REPZ_3_10,e.bl_tree),send_bits(e,o-3,3)):(send_code(e,REPZ_11_138,e.bl_tree),send_bits(e,o-11,7));o=0,i=s,l===0?(c=138,u=3):s===l?(c=6,u=3):(c=7,u=4)}}function build_bl_tree(e){var t;for(scan_tree(e,e.dyn_ltree,e.l_desc.max_code),scan_tree(e,e.dyn_dtree,e.d_desc.max_code),build_tree(e,e.bl_desc),t=BL_CODES$1-1;t>=3&&e.bl_tree[bl_order[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function send_all_trees(e,t,n,r){var i;for(send_bits(e,t-257,5),send_bits(e,n-1,5),send_bits(e,r-4,4),i=0;i<r;i++)send_bits(e,e.bl_tree[bl_order[i]*2+1],3);send_tree(e,e.dyn_ltree,t-1),send_tree(e,e.dyn_dtree,n-1)}function detect_data_type(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return Z_BINARY$1;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Z_TEXT$1;for(n=32;n<LITERALS$1;n++)if(e.dyn_ltree[n*2]!==0)return Z_TEXT$1;return Z_BINARY$1}var static_init_done=!1;function _tr_init(e){static_init_done||(tr_static_init(),static_init_done=!0),e.l_desc=new TreeDesc(e.dyn_ltree,static_l_desc),e.d_desc=new TreeDesc(e.dyn_dtree,static_d_desc),e.bl_desc=new TreeDesc(e.bl_tree,static_bl_desc),e.bi_buf=0,e.bi_valid=0,init_block(e)}function _tr_stored_block(e,t,n,r){send_bits(e,(STORED_BLOCK<<1)+(r?1:0),3),copy_block(e,t,n,!0)}function _tr_align(e){send_bits(e,STATIC_TREES<<1,3),send_code(e,END_BLOCK,static_ltree),bi_flush(e)}function _tr_flush_block(e,t,n,r){var i,s,l=0;e.level>0?(e.strm.data_type===Z_UNKNOWN$2&&(e.strm.data_type=detect_data_type(e)),build_tree(e,e.l_desc),build_tree(e,e.d_desc),l=build_bl_tree(e),i=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=i&&(i=s)):i=s=n+5,n+4<=i&&t!==-1?_tr_stored_block(e,t,n,r):e.strategy===Z_FIXED$2||s===i?(send_bits(e,(STATIC_TREES<<1)+(r?1:0),3),compress_block(e,static_ltree,static_dtree)):(send_bits(e,(DYN_TREES<<1)+(r?1:0),3),send_all_trees(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+1),compress_block(e,e.dyn_ltree,e.dyn_dtree)),init_block(e),r&&bi_windup(e)}function _tr_tally(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(_length_code[n]+LITERALS$1+1)*2]++,e.dyn_dtree[d_code(t)*2]++),e.last_lit===e.lit_bufsize-1}function adler32(e,t,n,r){for(var i=e&65535|0,s=e>>>16&65535|0,l=0;n!==0;){l=n>2e3?2e3:n,n-=l;do i=i+t[r++]|0,s=s+i|0;while(--l);i%=65521,s%=65521}return i|s<<16|0}function makeTable(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var crcTable=makeTable();function crc32(e,t,n,r){var i=crcTable,s=r+n;e^=-1;for(var l=r;l<s;l++)e=e>>>8^i[(e^t[l])&255];return e^-1}var Z_NO_FLUSH$1=0,Z_PARTIAL_FLUSH$1=1,Z_FULL_FLUSH$1=3,Z_FINISH$2=4,Z_BLOCK$2=5,Z_OK$2=0,Z_STREAM_END$2=1,Z_STREAM_ERROR$2=-2,Z_DATA_ERROR$2=-3,Z_BUF_ERROR$2=-5,Z_DEFAULT_COMPRESSION$1=-1,Z_FILTERED$1=1,Z_HUFFMAN_ONLY$1=2,Z_RLE$1=3,Z_FIXED$1=4,Z_UNKNOWN$1=2,Z_DEFLATED$2=8,MAX_MEM_LEVEL=9,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,MIN_MATCH=3,MAX_MATCH=258,MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1,PRESET_DICT=32,INIT_STATE=42,EXTRA_STATE=69,NAME_STATE=73,COMMENT_STATE=91,HCRC_STATE=103,BUSY_STATE=113,FINISH_STATE=666,BS_NEED_MORE=1,BS_BLOCK_DONE=2,BS_FINISH_STARTED=3,BS_FINISH_DONE=4,OS_CODE=3;function err(e,t){return e.msg=msg[t],t}function rank(e){return(e<<1)-(e>4?9:0)}function zero(e){for(var t=e.length;--t>=0;)e[t]=0}function flush_pending(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function flush_block_only(e,t){_tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,flush_pending(e.strm)}function put_byte(e,t){e.pending_buf[e.pending++]=t}function putShortMSB(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function read_buf(e,t,n,r){var i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,arraySet(t,e.input,e.next_in,i,n),e.state.wrap===1?e.adler=adler32(e.adler,t,i,n):e.state.wrap===2&&(e.adler=crc32(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)}function longest_match(e,t){var n=e.max_chain_length,r=e.strstart,i,s,l=e.prev_length,o=e.nice_match,c=e.strstart>e.w_size-MIN_LOOKAHEAD?e.strstart-(e.w_size-MIN_LOOKAHEAD):0,u=e.window,f=e.w_mask,E=e.prev,_=e.strstart+MAX_MATCH,h=u[r+l-1],g=u[r+l];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(u[i+l]!==g||u[i+l-1]!==h||u[i]!==u[r]||u[++i]!==u[r+1])){r+=2,i++;do;while(u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&r<_);if(s=MAX_MATCH-(_-r),r=_-MAX_MATCH,s>l){if(e.match_start=t,l=s,s>=o)break;h=u[r+l-1],g=u[r+l]}}while((t=E[t&f])>c&&--n!==0);return l<=e.lookahead?l:e.lookahead}function fill_window(e){var t=e.w_size,n,r,i,s,l;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-MIN_LOOKAHEAD)){arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do i=e.head[--n],e.head[n]=i>=t?i-t:0;while(--r);r=t,n=r;do i=e.prev[--n],e.prev[n]=i>=t?i-t:0;while(--r);s+=t}if(e.strm.avail_in===0)break;if(r=read_buf(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=r,e.lookahead+e.insert>=MIN_MATCH)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[l+MIN_MATCH-1])&e.hash_mask,e.prev[l&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=l,l++,e.insert--,!(e.lookahead+e.insert<MIN_MATCH)););}while(e.lookahead<MIN_LOOKAHEAD&&e.strm.avail_in!==0)}function deflate_stored(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(fill_window(e),e.lookahead===0&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,flush_block_only(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-MIN_LOOKAHEAD&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):(e.strstart>e.block_start&&(flush_block_only(e,!1),e.strm.avail_out===0),BS_NEED_MORE)}function deflate_fast(e,t){for(var n,r;;){if(e.lookahead<MIN_LOOKAHEAD){if(fill_window(e),e.lookahead<MIN_LOOKAHEAD&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(e.lookahead===0)break}if(n=0,e.lookahead>=MIN_MATCH&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-MIN_LOOKAHEAD&&(e.match_length=longest_match(e,n)),e.match_length>=MIN_MATCH)if(r=_tr_tally(e,e.strstart-e.match_start,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=MIN_MATCH){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}return e.insert=e.strstart<MIN_MATCH-1?e.strstart:MIN_MATCH-1,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),e.strm.avail_out===0)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_slow(e,t){for(var n,r,i;;){if(e.lookahead<MIN_LOOKAHEAD){if(fill_window(e),e.lookahead<MIN_LOOKAHEAD&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(e.lookahead===0)break}if(n=0,e.lookahead>=MIN_MATCH&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=MIN_MATCH-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-MIN_LOOKAHEAD&&(e.match_length=longest_match(e,n),e.match_length<=5&&(e.strategy===Z_FILTERED$1||e.match_length===MIN_MATCH&&e.strstart-e.match_start>4096)&&(e.match_length=MIN_MATCH-1)),e.prev_length>=MIN_MATCH&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-MIN_MATCH,r=_tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-MIN_MATCH),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=MIN_MATCH-1,e.strstart++,r&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}else if(e.match_available){if(r=_tr_tally(e,0,e.window[e.strstart-1]),r&&flush_block_only(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return BS_NEED_MORE}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=_tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<MIN_MATCH-1?e.strstart:MIN_MATCH-1,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),e.strm.avail_out===0)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_rle(e,t){for(var n,r,i,s,l=e.window;;){if(e.lookahead<=MAX_MATCH){if(fill_window(e),e.lookahead<=MAX_MATCH&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=MIN_MATCH&&e.strstart>0&&(i=e.strstart-1,r=l[i],r===l[++i]&&r===l[++i]&&r===l[++i])){s=e.strstart+MAX_MATCH;do;while(r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&r===l[++i]&&i<s);e.match_length=MAX_MATCH-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=MIN_MATCH?(n=_tr_tally(e,1,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),e.strm.avail_out===0)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_huff(e,t){for(var n;;){if(e.lookahead===0&&(fill_window(e),e.lookahead===0)){if(t===Z_NO_FLUSH$1)return BS_NEED_MORE;break}if(e.match_length=0,n=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(flush_block_only(e,!1),e.strm.avail_out===0))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),e.strm.avail_out===0?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),e.strm.avail_out===0)?BS_NEED_MORE:BS_BLOCK_DONE}function Config(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var configuration_table;configuration_table=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)];function lm_init(e){e.window_size=2*e.w_size,zero(e.head),e.max_lazy_match=configuration_table[e.level].max_lazy,e.good_match=configuration_table[e.level].good_length,e.nice_match=configuration_table[e.level].nice_length,e.max_chain_length=configuration_table[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=MIN_MATCH-1,e.match_available=0,e.ins_h=0}function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Z_DEFLATED$2,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Buf16(HEAP_SIZE*2),this.dyn_dtree=new Buf16((2*D_CODES+1)*2),this.bl_tree=new Buf16((2*BL_CODES+1)*2),zero(this.dyn_ltree),zero(this.dyn_dtree),zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Buf16(MAX_BITS+1),this.heap=new Buf16(2*L_CODES+1),zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Buf16(2*L_CODES+1),zero(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function deflateResetKeep(e){var t;return!e||!e.state?err(e,Z_STREAM_ERROR$2):(e.total_in=e.total_out=0,e.data_type=Z_UNKNOWN$1,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?INIT_STATE:BUSY_STATE,e.adler=t.wrap===2?0:1,t.last_flush=Z_NO_FLUSH$1,_tr_init(t),Z_OK$2)}function deflateReset(e){var t=deflateResetKeep(e);return t===Z_OK$2&&lm_init(e.state),t}function deflateInit2(e,t,n,r,i,s){if(!e)return Z_STREAM_ERROR$2;var l=1;if(t===Z_DEFAULT_COMPRESSION$1&&(t=6),r<0?(l=0,r=-r):r>15&&(l=2,r-=16),i<1||i>MAX_MEM_LEVEL||n!==Z_DEFLATED$2||r<8||r>15||t<0||t>9||s<0||s>Z_FIXED$1)return err(e,Z_STREAM_ERROR$2);r===8&&(r=9);var o=new DeflateState;return e.state=o,o.strm=e,o.wrap=l,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+MIN_MATCH-1)/MIN_MATCH),o.window=new Buf8(o.w_size*2),o.head=new Buf16(o.hash_size),o.prev=new Buf16(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=(1+2)*o.lit_bufsize,o.level=t,o.strategy=s,o.method=n,deflateReset(e)}function deflate(e,t){var n,r,i,s;if(!e||!e.state||t>Z_BLOCK$2||t<0)return e?err(e,Z_STREAM_ERROR$2):Z_STREAM_ERROR$2;if(r=e.state,!e.output||!e.input&&e.avail_in!==0||r.status===FINISH_STATE&&t!==Z_FINISH$2)return err(e,e.avail_out===0?Z_BUF_ERROR$2:Z_STREAM_ERROR$2);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===INIT_STATE)if(r.wrap===2)e.adler=0,put_byte(r,31),put_byte(r,139),put_byte(r,8),r.gzhead?(put_byte(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),put_byte(r,r.gzhead.time&255),put_byte(r,r.gzhead.time>>8&255),put_byte(r,r.gzhead.time>>16&255),put_byte(r,r.gzhead.time>>24&255),put_byte(r,r.level===9?2:r.strategy>=Z_HUFFMAN_ONLY$1||r.level<2?4:0),put_byte(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(put_byte(r,r.gzhead.extra.length&255),put_byte(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=crc32(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=EXTRA_STATE):(put_byte(r,0),put_byte(r,0),put_byte(r,0),put_byte(r,0),put_byte(r,0),put_byte(r,r.level===9?2:r.strategy>=Z_HUFFMAN_ONLY$1||r.level<2?4:0),put_byte(r,OS_CODE),r.status=BUSY_STATE);else{var l=Z_DEFLATED$2+(r.w_bits-8<<4)<<8,o=-1;r.strategy>=Z_HUFFMAN_ONLY$1||r.level<2?o=0:r.level<6?o=1:r.level===6?o=2:o=3,l|=o<<6,r.strstart!==0&&(l|=PRESET_DICT),l+=31-l%31,r.status=BUSY_STATE,putShortMSB(r,l),r.strstart!==0&&(putShortMSB(r,e.adler>>>16),putShortMSB(r,e.adler&65535)),e.adler=1}if(r.status===EXTRA_STATE)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),flush_pending(e),i=r.pending,r.pending===r.pending_buf_size));)put_byte(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=NAME_STATE)}else r.status=NAME_STATE;if(r.status===NAME_STATE)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),flush_pending(e),i=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindex<r.gzhead.name.length?s=r.gzhead.name.charCodeAt(r.gzindex++)&255:s=0,put_byte(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),s===0&&(r.gzindex=0,r.status=COMMENT_STATE)}else r.status=COMMENT_STATE;if(r.status===COMMENT_STATE)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),flush_pending(e),i=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindex<r.gzhead.comment.length?s=r.gzhead.comment.charCodeAt(r.gzindex++)&255:s=0,put_byte(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=crc32(e.adler,r.pending_buf,r.pending-i,i)),s===0&&(r.status=HCRC_STATE)}else r.status=HCRC_STATE;if(r.status===HCRC_STATE&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&flush_pending(e),r.pending+2<=r.pending_buf_size&&(put_byte(r,e.adler&255),put_byte(r,e.adler>>8&255),e.adler=0,r.status=BUSY_STATE)):r.status=BUSY_STATE),r.pending!==0){if(flush_pending(e),e.avail_out===0)return r.last_flush=-1,Z_OK$2}else if(e.avail_in===0&&rank(t)<=rank(n)&&t!==Z_FINISH$2)return err(e,Z_BUF_ERROR$2);if(r.status===FINISH_STATE&&e.avail_in!==0)return err(e,Z_BUF_ERROR$2);if(e.avail_in!==0||r.lookahead!==0||t!==Z_NO_FLUSH$1&&r.status!==FINISH_STATE){var c=r.strategy===Z_HUFFMAN_ONLY$1?deflate_huff(r,t):r.strategy===Z_RLE$1?deflate_rle(r,t):configuration_table[r.level].func(r,t);if((c===BS_FINISH_STARTED||c===BS_FINISH_DONE)&&(r.status=FINISH_STATE),c===BS_NEED_MORE||c===BS_FINISH_STARTED)return e.avail_out===0&&(r.last_flush=-1),Z_OK$2;if(c===BS_BLOCK_DONE&&(t===Z_PARTIAL_FLUSH$1?_tr_align(r):t!==Z_BLOCK$2&&(_tr_stored_block(r,0,0,!1),t===Z_FULL_FLUSH$1&&(zero(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),flush_pending(e),e.avail_out===0))return r.last_flush=-1,Z_OK$2}return t!==Z_FINISH$2?Z_OK$2:r.wrap<=0?Z_STREAM_END$2:(r.wrap===2?(put_byte(r,e.adler&255),put_byte(r,e.adler>>8&255),put_byte(r,e.adler>>16&255),put_byte(r,e.adler>>24&255),put_byte(r,e.total_in&255),put_byte(r,e.total_in>>8&255),put_byte(r,e.total_in>>16&255),put_byte(r,e.total_in>>24&255)):(putShortMSB(r,e.adler>>>16),putShortMSB(r,e.adler&65535)),flush_pending(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?Z_OK$2:Z_STREAM_END$2)}function deflateEnd(e){var t;return!e||!e.state?Z_STREAM_ERROR$2:(t=e.state.status,t!==INIT_STATE&&t!==EXTRA_STATE&&t!==NAME_STATE&&t!==COMMENT_STATE&&t!==HCRC_STATE&&t!==BUSY_STATE&&t!==FINISH_STATE?err(e,Z_STREAM_ERROR$2):(e.state=null,t===BUSY_STATE?err(e,Z_DATA_ERROR$2):Z_OK$2))}var BAD$1=30,TYPE$1=12;function inflate_fast(e,t){var n,r,i,s,l,o,c,u,f,E,_,h,g,b,A,j,F,M,R,d,I,$,q,y,m;n=e.state,r=e.next_in,y=e.input,i=r+(e.avail_in-5),s=e.next_out,m=e.output,l=s-(t-e.avail_out),o=s+(e.avail_out-257),c=n.dmax,u=n.wsize,f=n.whave,E=n.wnext,_=n.window,h=n.hold,g=n.bits,b=n.lencode,A=n.distcode,j=(1<<n.lenbits)-1,F=(1<<n.distbits)-1;e:do{g<15&&(h+=y[r++]<<g,g+=8,h+=y[r++]<<g,g+=8),M=b[h&j];t:for(;;){if(R=M>>>24,h>>>=R,g-=R,R=M>>>16&255,R===0)m[s++]=M&65535;else if(R&16){d=M&65535,R&=15,R&&(g<R&&(h+=y[r++]<<g,g+=8),d+=h&(1<<R)-1,h>>>=R,g-=R),g<15&&(h+=y[r++]<<g,g+=8,h+=y[r++]<<g,g+=8),M=A[h&F];n:for(;;){if(R=M>>>24,h>>>=R,g-=R,R=M>>>16&255,R&16){if(I=M&65535,R&=15,g<R&&(h+=y[r++]<<g,g+=8,g<R&&(h+=y[r++]<<g,g+=8)),I+=h&(1<<R)-1,I>c){e.msg="invalid distance too far back",n.mode=BAD$1;break e}if(h>>>=R,g-=R,R=s-l,I>R){if(R=I-R,R>f&&n.sane){e.msg="invalid distance too far back",n.mode=BAD$1;break e}if($=0,q=_,E===0){if($+=u-R,R<d){d-=R;do m[s++]=_[$++];while(--R);$=s-I,q=m}}else if(E<R){if($+=u+E-R,R-=E,R<d){d-=R;do m[s++]=_[$++];while(--R);if($=0,E<d){R=E,d-=R;do m[s++]=_[$++];while(--R);$=s-I,q=m}}}else if($+=E-R,R<d){d-=R;do m[s++]=_[$++];while(--R);$=s-I,q=m}for(;d>2;)m[s++]=q[$++],m[s++]=q[$++],m[s++]=q[$++],d-=3;d&&(m[s++]=q[$++],d>1&&(m[s++]=q[$++]))}else{$=s-I;do m[s++]=m[$++],m[s++]=m[$++],m[s++]=m[$++],d-=3;while(d>2);d&&(m[s++]=m[$++],d>1&&(m[s++]=m[$++]))}}else if(R&64){e.msg="invalid distance code",n.mode=BAD$1;break e}else{M=A[(M&65535)+(h&(1<<R)-1)];continue n}break}}else if(R&64)if(R&32){n.mode=TYPE$1;break e}else{e.msg="invalid literal/length code",n.mode=BAD$1;break e}else{M=b[(M&65535)+(h&(1<<R)-1)];continue t}break}}while(r<i&&s<o);d=g>>3,r-=d,g-=d<<3,h&=(1<<g)-1,e.next_in=r,e.next_out=s,e.avail_in=r<i?5+(i-r):5-(r-i),e.avail_out=s<o?257+(o-s):257-(s-o),n.hold=h,n.bits=g}var MAXBITS=15,ENOUGH_LENS$1=852,ENOUGH_DISTS$1=592,CODES$1=0,LENS$1=1,DISTS$1=2,lbase=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],lext=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],dbase=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],dext=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function inflate_table(e,t,n,r,i,s,l,o){var c=o.bits,u=0,f=0,E=0,_=0,h=0,g=0,b=0,A=0,j=0,F=0,M,R,d,I,$,q=null,y=0,m,C=new Buf16(MAXBITS+1),w=new Buf16(MAXBITS+1),L=null,W=0,k,N,P;for(u=0;u<=MAXBITS;u++)C[u]=0;for(f=0;f<r;f++)C[t[n+f]]++;for(h=c,_=MAXBITS;_>=1&&C[_]===0;_--);if(h>_&&(h=_),_===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,o.bits=1,0;for(E=1;E<_&&C[E]===0;E++);for(h<E&&(h=E),A=1,u=1;u<=MAXBITS;u++)if(A<<=1,A-=C[u],A<0)return-1;if(A>0&&(e===CODES$1||_!==1))return-1;for(w[1]=0,u=1;u<MAXBITS;u++)w[u+1]=w[u]+C[u];for(f=0;f<r;f++)t[n+f]!==0&&(l[w[t[n+f]]++]=f);if(e===CODES$1?(q=L=l,m=19):e===LENS$1?(q=lbase,y-=257,L=lext,W-=257,m=256):(q=dbase,L=dext,m=-1),F=0,f=0,u=E,$=s,g=h,b=0,d=-1,j=1<<h,I=j-1,e===LENS$1&&j>ENOUGH_LENS$1||e===DISTS$1&&j>ENOUGH_DISTS$1)return 1;for(;;){k=u-b,l[f]<m?(N=0,P=l[f]):l[f]>m?(N=L[W+l[f]],P=q[y+l[f]]):(N=32+64,P=0),M=1<<u-b,R=1<<g,E=R;do R-=M,i[$+(F>>b)+R]=k<<24|N<<16|P|0;while(R!==0);for(M=1<<u-1;F&M;)M>>=1;if(M!==0?(F&=M-1,F+=M):F=0,f++,--C[u]===0){if(u===_)break;u=t[n+l[f]]}if(u>h&&(F&I)!==d){for(b===0&&(b=h),$+=E,g=u-b,A=1<<g;g+b<_&&(A-=C[g+b],!(A<=0));)g++,A<<=1;if(j+=1<<g,e===LENS$1&&j>ENOUGH_LENS$1||e===DISTS$1&&j>ENOUGH_DISTS$1)return 1;d=F&I,i[d]=h<<24|g<<16|$-s|0}}return F!==0&&(i[$+F]=u-b<<24|64<<16|0),o.bits=h,0}var CODES=0,LENS=1,DISTS=2,Z_FINISH$1=4,Z_BLOCK$1=5,Z_TREES$1=6,Z_OK$1=0,Z_STREAM_END$1=1,Z_NEED_DICT$1=2,Z_STREAM_ERROR$1=-2,Z_DATA_ERROR$1=-3,Z_MEM_ERROR=-4,Z_BUF_ERROR$1=-5,Z_DEFLATED$1=8,HEAD=1,FLAGS=2,TIME=3,OS=4,EXLEN=5,EXTRA=6,NAME=7,COMMENT=8,HCRC=9,DICTID=10,DICT=11,TYPE=12,TYPEDO=13,STORED=14,COPY_=15,COPY=16,TABLE=17,LENLENS=18,CODELENS=19,LEN_=20,LEN=21,LENEXT=22,DIST=23,DISTEXT=24,MATCH=25,LIT=26,CHECK=27,LENGTH=28,DONE=29,BAD=30,MEM=31,SYNC=32,ENOUGH_LENS=852,ENOUGH_DISTS=592;function zswap32(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function InflateState(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Buf16(320),this.work=new Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function inflateResetKeep(e){var t;return!e||!e.state?Z_STREAM_ERROR$1:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=HEAD,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Buf32(ENOUGH_LENS),t.distcode=t.distdyn=new Buf32(ENOUGH_DISTS),t.sane=1,t.back=-1,Z_OK$1)}function inflateReset(e){var t;return!e||!e.state?Z_STREAM_ERROR$1:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,inflateResetKeep(e))}function inflateReset2(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Z_STREAM_ERROR$1:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,inflateReset(e))}function inflateInit2(e,t){var n,r;return e?(r=new InflateState,e.state=r,r.window=null,n=inflateReset2(e,t),n!==Z_OK$1&&(e.state=null),n):Z_STREAM_ERROR$1}var virgin=!0,lenfix,distfix;function fixedtables(e){if(virgin){var t;for(lenfix=new Buf32(512),distfix=new Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(inflate_table(LENS,e.lens,0,288,lenfix,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;inflate_table(DISTS,e.lens,0,32,distfix,0,e.work,{bits:5}),virgin=!1}e.lencode=lenfix,e.lenbits=9,e.distcode=distfix,e.distbits=5}function updatewindow(e,t,n,r){var i,s=e.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Buf8(s.wsize)),r>=s.wsize?(arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),arraySet(s.window,t,n-r,i,s.wnext),r-=i,r?(arraySet(s.window,t,n-r,r,0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0}function inflate(e,t){var n,r,i,s,l,o,c,u,f,E,_,h,g,b,A=0,j,F,M,R,d,I,$,q,y=new Buf8(4),m,C,w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return Z_STREAM_ERROR$1;n=e.state,n.mode===TYPE&&(n.mode=TYPEDO),l=e.next_out,i=e.output,c=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,u=n.hold,f=n.bits,E=o,_=c,q=Z_OK$1;e:for(;;)switch(n.mode){case HEAD:if(n.wrap===0){n.mode=TYPEDO;break}for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(n.wrap&2&&u===35615){n.check=0,y[0]=u&255,y[1]=u>>>8&255,n.check=crc32(n.check,y,2,0),u=0,f=0,n.mode=FLAGS;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=BAD;break}if((u&15)!==Z_DEFLATED$1){e.msg="unknown compression method",n.mode=BAD;break}if(u>>>=4,f-=4,$=(u&15)+8,n.wbits===0)n.wbits=$;else if($>n.wbits){e.msg="invalid window size",n.mode=BAD;break}n.dmax=1<<$,e.adler=n.check=1,n.mode=u&512?DICTID:TYPE,u=0,f=0;break;case FLAGS:for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(n.flags=u,(n.flags&255)!==Z_DEFLATED$1){e.msg="unknown compression method",n.mode=BAD;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=BAD;break}n.head&&(n.head.text=u>>8&1),n.flags&512&&(y[0]=u&255,y[1]=u>>>8&255,n.check=crc32(n.check,y,2,0)),u=0,f=0,n.mode=TIME;case TIME:for(;f<32;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.head&&(n.head.time=u),n.flags&512&&(y[0]=u&255,y[1]=u>>>8&255,y[2]=u>>>16&255,y[3]=u>>>24&255,n.check=crc32(n.check,y,4,0)),u=0,f=0,n.mode=OS;case OS:for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.head&&(n.head.xflags=u&255,n.head.os=u>>8),n.flags&512&&(y[0]=u&255,y[1]=u>>>8&255,n.check=crc32(n.check,y,2,0)),u=0,f=0,n.mode=EXLEN;case EXLEN:if(n.flags&1024){for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.length=u,n.head&&(n.head.extra_len=u),n.flags&512&&(y[0]=u&255,y[1]=u>>>8&255,n.check=crc32(n.check,y,2,0)),u=0,f=0}else n.head&&(n.head.extra=null);n.mode=EXTRA;case EXTRA:if(n.flags&1024&&(h=n.length,h>o&&(h=o),h&&(n.head&&($=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),arraySet(n.head.extra,r,s,h,$)),n.flags&512&&(n.check=crc32(n.check,r,h,s)),o-=h,s+=h,n.length-=h),n.length))break e;n.length=0,n.mode=NAME;case NAME:if(n.flags&2048){if(o===0)break e;h=0;do $=r[s+h++],n.head&&$&&n.length<65536&&(n.head.name+=String.fromCharCode($));while($&&h<o);if(n.flags&512&&(n.check=crc32(n.check,r,h,s)),o-=h,s+=h,$)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=COMMENT;case COMMENT:if(n.flags&4096){if(o===0)break e;h=0;do $=r[s+h++],n.head&&$&&n.length<65536&&(n.head.comment+=String.fromCharCode($));while($&&h<o);if(n.flags&512&&(n.check=crc32(n.check,r,h,s)),o-=h,s+=h,$)break e}else n.head&&(n.head.comment=null);n.mode=HCRC;case HCRC:if(n.flags&512){for(;f<16;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(u!==(n.check&65535)){e.msg="header crc mismatch",n.mode=BAD;break}u=0,f=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=TYPE;break;case DICTID:for(;f<32;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}e.adler=n.check=zswap32(u),u=0,f=0,n.mode=DICT;case DICT:if(n.havedict===0)return e.next_out=l,e.avail_out=c,e.next_in=s,e.avail_in=o,n.hold=u,n.bits=f,Z_NEED_DICT$1;e.adler=n.check=1,n.mode=TYPE;case TYPE:if(t===Z_BLOCK$1||t===Z_TREES$1)break e;case TYPEDO:if(n.last){u>>>=f&7,f-=f&7,n.mode=CHECK;break}for(;f<3;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}switch(n.last=u&1,u>>>=1,f-=1,u&3){case 0:n.mode=STORED;break;case 1:if(fixedtables(n),n.mode=LEN_,t===Z_TREES$1){u>>>=2,f-=2;break e}break;case 2:n.mode=TABLE;break;case 3:e.msg="invalid block type",n.mode=BAD}u>>>=2,f-=2;break;case STORED:for(u>>>=f&7,f-=f&7;f<32;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if((u&65535)!==(u>>>16^65535)){e.msg="invalid stored block lengths",n.mode=BAD;break}if(n.length=u&65535,u=0,f=0,n.mode=COPY_,t===Z_TREES$1)break e;case COPY_:n.mode=COPY;case COPY:if(h=n.length,h){if(h>o&&(h=o),h>c&&(h=c),h===0)break e;arraySet(i,r,s,h,l),o-=h,s+=h,c-=h,l+=h,n.length-=h;break}n.mode=TYPE;break;case TABLE:for(;f<14;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(n.nlen=(u&31)+257,u>>>=5,f-=5,n.ndist=(u&31)+1,u>>>=5,f-=5,n.ncode=(u&15)+4,u>>>=4,f-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=BAD;break}n.have=0,n.mode=LENLENS;case LENLENS:for(;n.have<n.ncode;){for(;f<3;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.lens[w[n.have++]]=u&7,u>>>=3,f-=3}for(;n.have<19;)n.lens[w[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,m={bits:n.lenbits},q=inflate_table(CODES,n.lens,0,19,n.lencode,0,n.work,m),n.lenbits=m.bits,q){e.msg="invalid code lengths set",n.mode=BAD;break}n.have=0,n.mode=CODELENS;case CODELENS:for(;n.have<n.nlen+n.ndist;){for(;A=n.lencode[u&(1<<n.lenbits)-1],j=A>>>24,F=A>>>16&255,M=A&65535,!(j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(M<16)u>>>=j,f-=j,n.lens[n.have++]=M;else{if(M===16){for(C=j+2;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(u>>>=j,f-=j,n.have===0){e.msg="invalid bit length repeat",n.mode=BAD;break}$=n.lens[n.have-1],h=3+(u&3),u>>>=2,f-=2}else if(M===17){for(C=j+3;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}u>>>=j,f-=j,$=0,h=3+(u&7),u>>>=3,f-=3}else{for(C=j+7;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}u>>>=j,f-=j,$=0,h=11+(u&127),u>>>=7,f-=7}if(n.have+h>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=BAD;break}for(;h--;)n.lens[n.have++]=$}}if(n.mode===BAD)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=BAD;break}if(n.lenbits=9,m={bits:n.lenbits},q=inflate_table(LENS,n.lens,0,n.nlen,n.lencode,0,n.work,m),n.lenbits=m.bits,q){e.msg="invalid literal/lengths set",n.mode=BAD;break}if(n.distbits=6,n.distcode=n.distdyn,m={bits:n.distbits},q=inflate_table(DISTS,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,m),n.distbits=m.bits,q){e.msg="invalid distances set",n.mode=BAD;break}if(n.mode=LEN_,t===Z_TREES$1)break e;case LEN_:n.mode=LEN;case LEN:if(o>=6&&c>=258){e.next_out=l,e.avail_out=c,e.next_in=s,e.avail_in=o,n.hold=u,n.bits=f,inflate_fast(e,_),l=e.next_out,i=e.output,c=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,u=n.hold,f=n.bits,n.mode===TYPE&&(n.back=-1);break}for(n.back=0;A=n.lencode[u&(1<<n.lenbits)-1],j=A>>>24,F=A>>>16&255,M=A&65535,!(j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(F&&!(F&240)){for(R=j,d=F,I=M;A=n.lencode[I+((u&(1<<R+d)-1)>>R)],j=A>>>24,F=A>>>16&255,M=A&65535,!(R+j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}u>>>=R,f-=R,n.back+=R}if(u>>>=j,f-=j,n.back+=j,n.length=M,F===0){n.mode=LIT;break}if(F&32){n.back=-1,n.mode=TYPE;break}if(F&64){e.msg="invalid literal/length code",n.mode=BAD;break}n.extra=F&15,n.mode=LENEXT;case LENEXT:if(n.extra){for(C=n.extra;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.length+=u&(1<<n.extra)-1,u>>>=n.extra,f-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=DIST;case DIST:for(;A=n.distcode[u&(1<<n.distbits)-1],j=A>>>24,F=A>>>16&255,M=A&65535,!(j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(!(F&240)){for(R=j,d=F,I=M;A=n.distcode[I+((u&(1<<R+d)-1)>>R)],j=A>>>24,F=A>>>16&255,M=A&65535,!(R+j<=f);){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}u>>>=R,f-=R,n.back+=R}if(u>>>=j,f-=j,n.back+=j,F&64){e.msg="invalid distance code",n.mode=BAD;break}n.offset=M,n.extra=F&15,n.mode=DISTEXT;case DISTEXT:if(n.extra){for(C=n.extra;f<C;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}n.offset+=u&(1<<n.extra)-1,u>>>=n.extra,f-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=BAD;break}n.mode=MATCH;case MATCH:if(c===0)break e;if(h=_-c,n.offset>h){if(h=n.offset-h,h>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=BAD;break}h>n.wnext?(h-=n.wnext,g=n.wsize-h):g=n.wnext-h,h>n.length&&(h=n.length),b=n.window}else b=i,g=l-n.offset,h=n.length;h>c&&(h=c),c-=h,n.length-=h;do i[l++]=b[g++];while(--h);n.length===0&&(n.mode=LEN);break;case LIT:if(c===0)break e;i[l++]=n.length,c--,n.mode=LEN;break;case CHECK:if(n.wrap){for(;f<32;){if(o===0)break e;o--,u|=r[s++]<<f,f+=8}if(_-=c,e.total_out+=_,n.total+=_,_&&(e.adler=n.check=n.flags?crc32(n.check,i,_,l-_):adler32(n.check,i,_,l-_)),_=c,(n.flags?u:zswap32(u))!==n.check){e.msg="incorrect data check",n.mode=BAD;break}u=0,f=0}n.mode=LENGTH;case LENGTH:if(n.wrap&&n.flags){for(;f<32;){if(o===0)break e;o--,u+=r[s++]<<f,f+=8}if(u!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=BAD;break}u=0,f=0}n.mode=DONE;case DONE:q=Z_STREAM_END$1;break e;case BAD:q=Z_DATA_ERROR$1;break e;case MEM:return Z_MEM_ERROR;case SYNC:default:return Z_STREAM_ERROR$1}return e.next_out=l,e.avail_out=c,e.next_in=s,e.avail_in=o,n.hold=u,n.bits=f,(n.wsize||_!==e.avail_out&&n.mode<BAD&&(n.mode<CHECK||t!==Z_FINISH$1))&&updatewindow(e,e.output,e.next_out,_-e.avail_out),E-=e.avail_in,_-=e.avail_out,e.total_in+=E,e.total_out+=_,n.total+=_,n.wrap&&_&&(e.adler=n.check=n.flags?crc32(n.check,i,_,e.next_out-_):adler32(n.check,i,_,e.next_out-_)),e.data_type=n.bits+(n.last?64:0)+(n.mode===TYPE?128:0)+(n.mode===LEN_||n.mode===COPY_?256:0),(E===0&&_===0||t===Z_FINISH$1)&&q===Z_OK$1&&(q=Z_BUF_ERROR$1),q}function inflateEnd(e){if(!e||!e.state)return Z_STREAM_ERROR$1;var t=e.state;return t.window&&(t.window=null),e.state=null,Z_OK$1}var NONE=0,DEFLATE=1,INFLATE=2,GZIP=3,GUNZIP=4,DEFLATERAW=5,INFLATERAW=6,UNZIP=7,Z_NO_FLUSH=0,Z_PARTIAL_FLUSH=1,Z_SYNC_FLUSH=2,Z_FULL_FLUSH=3,Z_FINISH=4,Z_BLOCK=5,Z_TREES=6,Z_OK=0,Z_STREAM_END=1,Z_NEED_DICT=2,Z_ERRNO=-1,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_BUF_ERROR=-5,Z_NO_COMPRESSION=0,Z_BEST_SPEED=1,Z_BEST_COMPRESSION=9,Z_DEFAULT_COMPRESSION=-1,Z_FILTERED=1,Z_HUFFMAN_ONLY=2,Z_RLE=3,Z_FIXED=4,Z_DEFAULT_STRATEGY=0,Z_BINARY=0,Z_TEXT=1,Z_UNKNOWN=2,Z_DEFLATED=8;function Zlib$1(e){if(e<DEFLATE||e>UNZIP)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}Zlib$1.prototype.init=function(e,t,n,r,i){this.windowBits=e,this.level=t,this.memLevel=n,this.strategy=r,(this.mode===GZIP||this.mode===GUNZIP)&&(this.windowBits+=16),this.mode===UNZIP&&(this.windowBits+=32),(this.mode===DEFLATERAW||this.mode===INFLATERAW)&&(this.windowBits=-this.windowBits),this.strm=new ZStream;var s;switch(this.mode){case DEFLATE:case GZIP:case DEFLATERAW:s=deflateInit2(this.strm,this.level,Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case INFLATE:case GUNZIP:case INFLATERAW:case UNZIP:s=inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}if(s!==Z_OK){this._error(s);return}this.write_in_progress=!1,this.init_done=!0},Zlib$1.prototype.params=function(){throw new Error("deflateParams Not supported")},Zlib$1.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(this.mode===NONE)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},Zlib$1.prototype.write=function(e,t,n,r,i,s,l){this._writeCheck(),this.write_in_progress=!0;var o=this;return browser$1$1.nextTick(function(){o.write_in_progress=!1;var c=o._write(e,t,n,r,i,s,l);o.callback(c[0],c[1]),o.pending_close&&o.close()}),this};function bufferSet(e,t){for(var n=0;n<e.length;n++)this[t+n]=e[n]}Zlib$1.prototype.writeSync=function(e,t,n,r,i,s,l){return this._writeCheck(),this._write(e,t,n,r,i,s,l)},Zlib$1.prototype._write=function(e,t,n,r,i,s,l){if(this.write_in_progress=!0,e!==Z_NO_FLUSH&&e!==Z_PARTIAL_FLUSH&&e!==Z_SYNC_FLUSH&&e!==Z_FULL_FLUSH&&e!==Z_FINISH&&e!==Z_BLOCK)throw new Error("Invalid flush value");t==null&&(t=new Buffer(0),r=0,n=0),i._set?i.set=i._set:i.set=bufferSet;var o=this.strm;o.avail_in=r,o.input=t,o.next_in=n,o.avail_out=l,o.output=i,o.next_out=s;var c;switch(this.mode){case DEFLATE:case GZIP:case DEFLATERAW:c=deflate(o,e);break;case UNZIP:case INFLATE:case GUNZIP:case INFLATERAW:c=inflate(o,e);break;default:throw new Error("Unknown mode "+this.mode)}return c!==Z_STREAM_END&&c!==Z_OK&&this._error(c),this.write_in_progress=!1,[o.avail_in,o.avail_out]},Zlib$1.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}this.pending_close=!1,this.mode===DEFLATE||this.mode===GZIP||this.mode===DEFLATERAW?deflateEnd(this.strm):inflateEnd(this.strm),this.mode=NONE};var status;Zlib$1.prototype.reset=function(){switch(this.mode){case DEFLATE:case DEFLATERAW:status=deflateReset(this.strm);break;case INFLATE:case INFLATERAW:status=inflateReset(this.strm);break}status!==Z_OK&&this._error(status)},Zlib$1.prototype._error=function(e){this.onerror(msg[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};const _binding=Object.freeze(Object.defineProperty({__proto__:null,DEFLATE,DEFLATERAW,GUNZIP,GZIP,INFLATE,INFLATERAW,NONE,UNZIP,Z_BEST_COMPRESSION,Z_BEST_SPEED,Z_BINARY,Z_BLOCK,Z_BUF_ERROR,Z_DATA_ERROR,Z_DEFAULT_COMPRESSION,Z_DEFAULT_STRATEGY,Z_DEFLATED,Z_ERRNO,Z_FILTERED,Z_FINISH,Z_FIXED,Z_FULL_FLUSH,Z_HUFFMAN_ONLY,Z_NEED_DICT,Z_NO_COMPRESSION,Z_NO_FLUSH,Z_OK,Z_PARTIAL_FLUSH,Z_RLE,Z_STREAM_END,Z_STREAM_ERROR,Z_SYNC_FLUSH,Z_TEXT,Z_TREES,Z_UNKNOWN,Zlib:Zlib$1},Symbol.toStringTag,{value:"Module"}));function assert(e,t){if(!e)throw new Error(t)}var binding={};Object.keys(_binding).forEach(function(e){binding[e]=_binding[e]}),binding.Z_MIN_WINDOWBITS=8,binding.Z_MAX_WINDOWBITS=15,binding.Z_DEFAULT_WINDOWBITS=15,binding.Z_MIN_CHUNK=64,binding.Z_MAX_CHUNK=1/0,binding.Z_DEFAULT_CHUNK=16*1024,binding.Z_MIN_MEMLEVEL=1,binding.Z_MAX_MEMLEVEL=9,binding.Z_DEFAULT_MEMLEVEL=8,binding.Z_MIN_LEVEL=-1,binding.Z_MAX_LEVEL=9,binding.Z_DEFAULT_LEVEL=binding.Z_DEFAULT_COMPRESSION;var codes={Z_OK:binding.Z_OK,Z_STREAM_END:binding.Z_STREAM_END,Z_NEED_DICT:binding.Z_NEED_DICT,Z_ERRNO:binding.Z_ERRNO,Z_STREAM_ERROR:binding.Z_STREAM_ERROR,Z_DATA_ERROR:binding.Z_DATA_ERROR,Z_MEM_ERROR:binding.Z_MEM_ERROR,Z_BUF_ERROR:binding.Z_BUF_ERROR,Z_VERSION_ERROR:binding.Z_VERSION_ERROR};Object.keys(codes).forEach(function(e){codes[codes[e]]=e});function deflateSync(e,t){return zlibBufferSync(new Deflate(t),e)}function zlibBufferSync(e,t){if(typeof t=="string"&&(t=new Buffer(t)),!Buffer.isBuffer(t))throw new TypeError("Not a string or buffer");var n=binding.Z_FINISH;return e._processChunk(t,n)}function Deflate(e){if(!(this instanceof Deflate))return new Deflate(e);Zlib.call(this,e,binding.DEFLATE)}function Inflate(e){if(!(this instanceof Inflate))return new Inflate(e);Zlib.call(this,e,binding.INFLATE)}function Gzip(e){if(!(this instanceof Gzip))return new Gzip(e);Zlib.call(this,e,binding.GZIP)}function Gunzip(e){if(!(this instanceof Gunzip))return new Gunzip(e);Zlib.call(this,e,binding.GUNZIP)}function DeflateRaw(e){if(!(this instanceof DeflateRaw))return new DeflateRaw(e);Zlib.call(this,e,binding.DEFLATERAW)}function InflateRaw(e){if(!(this instanceof InflateRaw))return new InflateRaw(e);Zlib.call(this,e,binding.INFLATERAW)}function Unzip(e){if(!(this instanceof Unzip))return new Unzip(e);Zlib.call(this,e,binding.UNZIP)}function Zlib(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||binding.Z_DEFAULT_CHUNK,Transform.call(this,e),e.flush&&e.flush!==binding.Z_NO_FLUSH&&e.flush!==binding.Z_PARTIAL_FLUSH&&e.flush!==binding.Z_SYNC_FLUSH&&e.flush!==binding.Z_FULL_FLUSH&&e.flush!==binding.Z_FINISH&&e.flush!==binding.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||binding.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<binding.Z_MIN_CHUNK||e.chunkSize>binding.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<binding.Z_MIN_WINDOWBITS||e.windowBits>binding.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<binding.Z_MIN_LEVEL||e.level>binding.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<binding.Z_MIN_MEMLEVEL||e.memLevel>binding.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=binding.Z_FILTERED&&e.strategy!=binding.Z_HUFFMAN_ONLY&&e.strategy!=binding.Z_RLE&&e.strategy!=binding.Z_FIXED&&e.strategy!=binding.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!Buffer.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new binding.Zlib(t);var n=this;this._hadError=!1,this._binding.onerror=function(s,l){n._binding=null,n._hadError=!0;var o=new Error(s);o.errno=l,o.code=binding.codes[l],n.emit("error",o)};var r=binding.Z_DEFAULT_COMPRESSION;typeof e.level=="number"&&(r=e.level);var i=binding.Z_DEFAULT_STRATEGY;typeof e.strategy=="number"&&(i=e.strategy),this._binding.init(e.windowBits||binding.Z_DEFAULT_WINDOWBITS,r,e.memLevel||binding.Z_DEFAULT_MEMLEVEL,i,e.dictionary),this._buffer=new Buffer(this._chunkSize),this._offset=0,this._closed=!1,this._level=r,this._strategy=i,this.once("end",this.close)}inherits$1(Zlib,Transform),Zlib.prototype.params=function(e,t,n){if(e<binding.Z_MIN_LEVEL||e>binding.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=binding.Z_FILTERED&&t!=binding.Z_HUFFMAN_ONLY&&t!=binding.Z_RLE&&t!=binding.Z_FIXED&&t!=binding.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var r=this;this.flush(binding.Z_SYNC_FLUSH,function(){r._binding.params(e,t),r._hadError||(r._level=e,r._strategy=t,n&&n())})}else browser$1$1.nextTick(n)},Zlib.prototype.reset=function(){return this._binding.reset()},Zlib.prototype._flush=function(e){this._transform(new Buffer(0),"",e)},Zlib.prototype.flush=function(e,t){var n=this._writableState;if((typeof e=="function"||e===void 0&&!t)&&(t=e,e=binding.Z_FULL_FLUSH),n.ended)t&&browser$1$1.nextTick(t);else if(n.ending)t&&this.once("end",t);else if(n.needDrain){var r=this;this.once("drain",function(){r.flush(t)})}else this._flushFlag=e,this.write(new Buffer(0),"",t)},Zlib.prototype.close=function(e){if(e&&browser$1$1.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;browser$1$1.nextTick(function(){t.emit("close")})}},Zlib.prototype._transform=function(e,t,n){var r,i=this._writableState,s=i.ending||i.ended,l=s&&(!e||i.length===e.length);if(!e===null&&!Buffer.isBuffer(e))return n(new Error("invalid input"));l?r=binding.Z_FINISH:(r=this._flushFlag,e.length>=i.length&&(this._flushFlag=this._opts.flush||binding.Z_NO_FLUSH)),this._processChunk(e,r,n)},Zlib.prototype._processChunk=function(e,t,n){var r=e&&e.length,i=this._chunkSize-this._offset,s=0,l=this,o=typeof n=="function";if(!o){var c=[],u=0,f;this.on("error",function(b){f=b});do var E=this._binding.writeSync(t,e,s,r,this._buffer,this._offset,i);while(!this._hadError&&g(E[0],E[1]));if(this._hadError)throw f;var _=Buffer.concat(c,u);return this.close(),_}var h=this._binding.write(t,e,s,r,this._buffer,this._offset,i);h.buffer=e,h.callback=g;function g(b,A){if(!l._hadError){var j=i-A;if(assert(j>=0,"have should not go down"),j>0){var F=l._buffer.slice(l._offset,l._offset+j);l._offset+=j,o?l.push(F):(c.push(F),u+=F.length)}if((A===0||l._offset>=l._chunkSize)&&(i=l._chunkSize,l._offset=0,l._buffer=new Buffer(l._chunkSize)),A===0){if(s+=r-b,r=b,!o)return!0;var M=l._binding.write(t,e,s,r,l._buffer,l._offset,l._chunkSize);M.callback=g,M.buffer=e;return}if(!o)return!1;n()}}},inherits$1(Deflate,Zlib),inherits$1(Inflate,Zlib),inherits$1(Gzip,Zlib),inherits$1(Gunzip,Zlib),inherits$1(DeflateRaw,Zlib),inherits$1(InflateRaw,Zlib),inherits$1(Unzip,Zlib);function serializeHash(e){return deflateSync(Buffer.from(JSON.stringify(e),"utf8")).toString("base64")}const isRtcPeer=e=>e!==void 0&&e.capabilities!==void 0&&e.capabilitySet!==void 0;class DataChannel{constructor(t){Te(this,"ready",!1);Te(this,"listeners",[]);Te(this,"openListeners",[]);Te(this,"closeListeners",[]);Te(this,"errorListeners",[]);Te(this,"binaryListeners",[]);Te(this,"error");Te(this,"decoder",new TextDecoder);this.dataChannel=t,this.dataChannel.binaryType="arraybuffer",this.dataChannel.onopen=()=>{this.ready=!0,this.openListeners.forEach(n=>n())},this.dataChannel.onclose=()=>{this.ready=!1,this.closeListeners.forEach(n=>n())},this.dataChannel.onerror=n=>{console.error(n),this.error="An error occurred in DataChannel",this.errorListeners.forEach(r=>r(n))},this.dataChannel.onmessage=n=>{this.listeners.forEach(r=>{const i=new Uint8Array(n.data),s=this.decoder.decode(i);r(s)}),this.binaryListeners.forEach(r=>{r(new Uint8Array(n.data))})}}addOpenListener(t){this.openListeners.push(t)}removeOpenListener(t){this.openListeners=this.openListeners.filter(n=>n!==t)}addCloseListener(t){this.closeListeners.push(t)}removeCloseListener(t){this.closeListeners=this.closeListeners.filter(n=>n!==t)}addErrorListener(t){this.errorListeners.push(t)}removeErrorListener(t){this.errorListeners=this.errorListeners.filter(n=>n!==t)}async waitTilReady(){return this.ready?!0:new Promise((n,r)=>{let i=window.setInterval(()=>{this.ready&&(window.clearInterval(i),n(!0)),this.error&&r(this.error)},10)})}send(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}sendBinary(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}addListener(t){this.listeners.push(t)}removeListener(t){const n=this.listeners.indexOf(t);if(n===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.listeners.splice(n,1)}addBinaryListener(t){this.binaryListeners.push(t)}removeBinaryListener(t){const n=this.binaryListeners.indexOf(t);if(n===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.binaryListeners.splice(n,1)}}class Manipulator{constructor(t,n){Te(this,"currentListeners",[]);Te(this,"onRealtimeMessage",(t,n)=>{n.payload.jointState&&this.currentListeners.forEach(r=>{n.payload.jointState&&r(n.payload.jointState)})});this.device=t,this.config=n}async synchronize(){this.device.addRealtimeListener(this.onRealtimeMessage),this.device.startListeningToRealtimeDataStream(this.config.currentJointStateStream)}async desynchronize(){this.device.removeRealtimeListener(this.onRealtimeMessage),this.device.stopListeningToRealtimeDataStream(this.config.currentJointStateStream)}async addCurrentJointStateListener(t){this.currentListeners.push(t)}}class BaseDevice extends EventEmitter{constructor(){super(...arguments);Te(this,"rtcClient");Te(this,"remoteDevicePeerId",null);Te(this,"realtimeListeners",[]);Te(this,"connectionMonitorInterval");Te(this,"handleMessage",(n,r)=>{this.realtimeListeners.forEach(i=>i(n,r))})}stopConnectionMonitoring(){clearInterval(this.connectionMonitorInterval),this.connectionMonitorInterval=void 0}assertNotCancelled(n){if(n)throw new Error("Cancelled by deadline")}getRealtimeStatus(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getConnectionStatus(this.remoteDevicePeerId);throw new Error("Realtime connection hasn't been started")}getRealtimePing(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getPing(this.remoteDevicePeerId);throw new Error("Realtime connection hasn't been started")}addRealtimeListener(n){this.realtimeListeners.push(n)}removeRealtimeListener(n){const r=this.realtimeListeners.indexOf(n);if(r===-1)throw new Error("Could not find realtime listener to remove");this.realtimeListeners.splice(r,1)}async getRealtimeManipulators(){const n=await this.getConfiguration(),r=[];for(const i of n.teleop.rosStreams??[])i.topicType=="sensor_msgs/JointState"&&r.push(new Manipulator(this,{currentJointStateStream:{name:i.topicName},plannedJointStateStream:i.plannedTopic?{name:i.plannedTopic}:void 0,planValidStream:i.planValidTopic?{name:i.planValidTopic}:void 0,endEffectorStream:i.endEffectorTopic?{name:i.endEffectorTopic}:void 0,endEffectorLinkName:i.endEffectorLinkName,baseReferenceFrame:i.baseReferenceFrame,localFrame:i.localFrame}));return r}async getRealtimeVideoStreams(){var i,s,l;const n=await this.getConfiguration(),r=[];for(const o of((i=n.teleop)==null?void 0:i.hardwareStreams)??[])o.rtcStreamType==="h264-video-frame"&&r.push({name:o.name});for(const o of((s=n.teleop)==null?void 0:s.rosStreams)??[])o.topicType=="formant/H264VideoFrame"&&r.push({name:o.topicName}),(o.topicType==="sensor_msgs/Image"||o.topicType==="sensor_msgs/CompressedImage")&&o.encodeVideo&&r.push({name:o.topicName});for(const o of((l=n.teleop)==null?void 0:l.customStreams)??[])o.rtcStreamType==="h264-video-frame"&&r.push({name:o.name});return r}createCustomRequestDataChannel(n,r=3e3){return new TextRequestDataChannel(this,n,r)}createCustomBinaryRequestDataChannel(n,r=3e3){return new BinaryRequestDataChannel(this,n,r)}async startListeningToRealtimeVideo(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeVideo(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n.name,enable:!1,pipeline:"rtc"})}async startListeningToRealtimeDataStream(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeDataStream(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n.name,enable:!1,pipeline:"rtc"})}async enableRealtimeTelemetryPriorityIngestion(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n,enablePriorityUpload:!0,pipeline:"telemetry"})}async disableRealtimeTelemetryPriorityIngestion(n){const r=defined(this.rtcClient,"Realtime connection has not been started"),i=await this.getRemotePeer();r.controlRemoteStream(defined(i).id,{streamName:n,enablePriorityUpload:!1,pipeline:"telemetry"})}async changeStreamAudioType(n,r){const i=defined(this.rtcClient,"Realtime connection has not been started"),s=await this.getRemotePeer();i.controlRemoteStream(defined(s).id,{streamName:n,setAudioFormat:r})}async createCustomDataChannel(n,r){const i=defined(this.rtcClient,"Realtime connection has not been started"),s=await this.getRemotePeer(),l=await new Promise(o=>{i.createCustomDataChannel(defined(s).id,n,{ordered:!0,...r},!1,(c,u)=>{const f=new DataChannel(u);o(f)})});return await l.waitTilReady(),l}async sendRealtimeMessage(n,r={channelLabel:"stream.reliable"}){const i=defined(this.rtcClient,"Realtime connection has not been started"),s=await this.getRemotePeer();i.send(defined(s).id,n,r)}async getRealtimeAudioStreams(){var i,s,l;const n=await this.getConfiguration(),r=[];for(const o of((i=n.teleop)==null?void 0:i.hardwareStreams)??[])o.rtcStreamType==="audio-chunk"&&r.push({name:o.name});for(const o of((s=n.teleop)==null?void 0:s.rosStreams)??[])o.topicType=="audio_common_msgs/AudioData"&&r.push({name:o.topicName});for(const o of((l=n.teleop)==null?void 0:l.customStreams)??[])o.rtcStreamType==="audio-chunk"&&r.push({name:o.name});return r}}class Device extends BaseDevice{constructor(t,n,r,i){super(),this.id=t,this.name=n,this.organizationId=r,this.tags=i}async getLatestTelemetry(){return(await(await fetch(`${FORMANT_API_URL}/v1/queries/stream-current-value`,{method:"POST",body:JSON.stringify({deviceIds:[this.id]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}async getConfiguration(){let t=await fetch(`${FORMANT_API_URL}/v1/admin/devices/${this.id}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}});const n=await t.json();if(!n.state.reportedConfiguration)throw new Error("Device has no configuration, has it ever been turned on?");const r=n.state.reportedConfiguration.version;return t=await fetch(`${FORMANT_API_URL}/v1/admin/devices/${this.id}/configurations/${r}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),(await t.json()).document}async getFileUrl(t){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/files/query`,{method:"POST",body:JSON.stringify({fileIds:[t]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).fileUrls}async startRealtimeConnection(t={}){if(console.debug(`${new Date().toISOString()} :: Connection start requested`),this.rtcClient&&this.connectionMonitorInterval!==void 0)throw new Error(`Already created realtime connection to device ${this.id}`);this.rtcClient&&console.warn("overwriting existing rtcClient due to missing connectionMonitorInterval");const{sessionType:n,deadlineMs:r=1e4,maxConnectRetries:i=3}=typeof t=="number"?{sessionType:t}:t,l=getRtcClientPool({sessionType:n}).get(this.handleMessage);let o=!1;const c=new Promise((f,E)=>setTimeout(()=>{o=!0,E(new Error("Connection timed out: the connection could not be finalized in time, possibly due to network issues or misconfigured settings."))},r)),u=async()=>{if("isReady"in l)for(;!l.isReady();)this.assertNotCancelled(o),await delay(100);const f=await this.getRemoteDevicePeerId(l);this.assertNotCancelled(o);let E;for(let h=0;h<i&&(E=await l.connect(f),!E);h++)delay(100),this.assertNotCancelled(o);if(!E)throw new Error(`Session could not be created: exhausted ${i} retries`);let _=0;for(;!o&&l.getConnectionStatus(f)!=="connected";)await delay(100),_+=1;return this.assertNotCancelled(o),console.debug(`${new Date().toISOString()} :: Connection completed after ${_} retries`),f};return Promise.race([u(),c]).then(f=>{this.remoteDevicePeerId=f,this.initConnectionMonitoring(),this.rtcClient=l,this.emit("connect")}).catch(f=>{throw console.debug(`${new Date().toISOString()} :: Connection failed: %o`,f),this.remoteDevicePeerId=null,l.shutdown().catch(E=>{console.error("rtcClient cannot shutdown: %o",E)}),this.emit("connection_failed",f),f})}async getRemoteDevicePeerId(t){const r=(await t.getPeers()).find(i=>i.deviceId===this.id);if(!isRtcPeer(r))throw new Error("Cannot find peer, is the robot offline?");return r.id}initConnectionMonitoring(){this.connectionMonitorInterval=setInterval(async()=>{let t=!1;if(this.rtcClient){const r=this.rtcClient.getConnections().find(i=>i.getRemotePeerId()===this.remoteDevicePeerId&&i.isActive());r===void 0||!r.isReady()?(console.debug(`${new Date().toISOString()} :: data channel closed`),t=!0):console.debug(`${new Date().toISOString()} :: data channel appears active`)}(!this.rtcClient||!this.remoteDevicePeerId||await this.rtcClient.getConnectionStatsInfo(this.remoteDevicePeerId)===void 0||t)&&(this.emit("disconnect"),this.stopRealtimeConnection().catch(n=>{console.error(n)}))},1e3)}async getRemotePeer(){const n=(await defined(this.rtcClient,"Realtime connection has not been started").getPeers()).find(r=>r.deviceId===this.id);return defined(n,"Could not find remote peer for device "+this.id)}async stopRealtimeConnection(){let t=!1;if(this.rtcClient){this.stopConnectionMonitoring(),this.remoteDevicePeerId?(await this.rtcClient.disconnect(this.remoteDevicePeerId),this.remoteDevicePeerId=null):t=!0;try{await this.rtcClient.shutdown()}finally{this.rtcClient=void 0}}if(t)throw new Error(`Realtime connection hasn't been started for ${this.id}`)}async isInRealtimeSession(){const t=await Fleet.getPeers(),n=await Fleet.getRealtimeSessions(),r=t.find(i=>i.deviceId===this.id);return r?n[r.id].length>0:!1}async getAvailableCommands(){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/command-templates/`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(r=>({name:r.name,id:r.id,command:r.command,description:r.description,parameterEnabled:r.parameterEnabled,parameterValue:r.parameterValue,parameterMeta:r.parameterMeta,enabled:r.enabled,tags:r.tags}))}async sendCommand(t,n,r,i){var f;const l=(await this.getAvailableCommands()).find(E=>E.name===t);if(!l)throw new Error(`Could not find command with name "${t}"`);let o="";n===void 0?l.parameterEnabled&&l.parameterValue&&(o=l.parameterValue):o=n;let c={value:o,scrubberTime:(r||new Date).toISOString(),meta:{...l.parameterMeta,...i}};return await fetch(`${FORMANT_API_URL}/v1/admin/commands`,{method:"POST",body:JSON.stringify({commandTemplateId:l.id,organizationId:this.organizationId,deviceId:this.id,command:l.command,parameter:c,userId:(f=Authentication.currentUser)==null?void 0:f.id}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}async getCommand(t){return await fetch(`${FORMANT_API_URL}/v1/admin/commands/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}async createCaptureStream(t){const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions`,{method:"POST",body:JSON.stringify({deviceId:this.id,streamName:t,tags:{}}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();return new CaptureStream(r)}async getTelemetry(t,n,r,i){return await Fleet.getTelemetry(this.id,t,n,r,i)}async getTelemetryStreams(){var o,c;const t=await this.getConfiguration(),n=await fetch(`${FORMANT_API_URL}/v1/queries/metadata/stream-names`,{method:"POST",body:JSON.stringify({deviceIds:[this.id]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),r=[],i=[];return(c=(o=t.telemetry)==null?void 0:o.streams)==null||c.forEach(u=>{u.disabled!==!0&&r.push(u.name),u.onDemand===!0&&i.push(u.name)}),console.log(i),(await n.json()).items.filter(u=>!r.includes(u)).map(u=>({name:u,onDemand:i.includes(u)}))}async createInterventionRequest(t,n,r,i){return await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-requests`,{method:"POST",body:JSON.stringify({message:t,interventionType:n,time:new Date().toISOString(),deviceId:this.id,tags:i,data:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}async addInterventionResponse(t,n,r){return await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-responses`,{method:"POST",body:JSON.stringify({interventionId:t,interventionType:n,data:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}async getAnnotationCount(t,n){return await Fleet.getAnnotationCount({...t,deviceIds:[this.id]},n)}async getAnnotationCountByIntervals(t,n,r){return await Fleet.getAnnotationCountByIntervals({...t,deviceIds:[this.id]},n,r)}async eventsCounter(t,n,r,i,s){return await Fleet.eventsCounter(t,n,r,i,{...s,deviceIds:[this.id]})}async createShareLink(t,n){return t.scope.deviceIds=[this.id],await Fleet.createShareLink(t,n)}async createDevice(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/devices`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}async patchDevice(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}}class PeerDevice extends BaseDevice{constructor(n){super();Te(this,"id");Te(this,"telemetryStreamActive",!1);Te(this,"streamTelemetry",{});this.peerUrl=n}async getLatestTelemetry(){this.telemetryStreamActive||this.subscribeToTelemetry();const n=this.streamTelemetry;return Object.entries(n).map(([i,s])=>({deviceId:this.id,streamName:i,streamType:"json",currentValue:s,currentValueTime:s.timestamp,tags:{}}))}subscribeToTelemetry(){this.telemetryStreamActive=!0;const n=this;fetch(`${this.peerUrl}/v1/telemetry`,{method:"POST"}).then(r=>{if(r===null||r.body===null){this.telemetryStreamActive=!1;return}const i=r.body.getReader();return new ReadableStream({start(s){function l(o){if(o.done){n.telemetryStreamActive=!1,s.close();return}const c=o.value;new TextDecoder("utf-8").decode(c).split(`
|
|
59
|
+
`).forEach(E=>{var _;if(E.length>0){const h=JSON.parse(E);if((_=h.result)!=null&&_.datapoint){const g=h.result.datapoint,b=g.stream;delete g.stream,n.streamTelemetry[b]=g}}}),n.readNextTelemetryRecord(i,l)}n.readNextTelemetryRecord(i,l)}})}).catch(r=>{this.telemetryStreamActive=!1,console.error("Telemetry error:",r)})}readNextTelemetryRecord(n,r){n.read().then(r).catch(i=>{this.telemetryStreamActive=!1,console.error("Telemetry error:",i)})}async getDeviceId(){return(await(await fetch(`${this.peerUrl}/v1/config`)).json()).configuration.id}async getConfiguration(){return(await(await fetch(`${this.peerUrl}/v1/config`)).json()).configuration.document}async startRealtimeConnection(n){if(console.debug(`${new Date().toISOString()} :: Connection start requested`),this.rtcClient&&this.connectionMonitorInterval!==void 0)throw new Error(`Already created realtime connection to device ${this.id}`);this.rtcClient&&console.warn("overwriting existing rtcClient due to missing connectionMonitorInterval");const r=new distExports.RtcClient({lanOnlyMode:!0,receive:this.handleMessage,sessionType:n});for(await r.connectLan(this.peerUrl);r.getConnectionStatus(this.peerUrl)!=="connected";)await delay(100);this.rtcClient=r,this.initConnectionMonitoring()}initConnectionMonitoring(){this.connectionMonitorInterval=setInterval(async()=>{let n=!1;this.rtcClient&&(this.rtcClient.getConnectionStatus(this.peerUrl)!=="connected"?(console.debug(`${new Date().toISOString()} :: data channel closed`),n=!0):console.debug(`${new Date().toISOString()} :: data channel appears active`)),(!this.rtcClient||n)&&(this.emit("disconnect"),this.stopRealtimeConnection().catch(r=>{console.error(r)}))},1e3)}async getRemotePeer(){return{id:this.peerUrl,organizationId:"",deviceId:this.id,capabilities:[],capabilitySet:{}}}async stopRealtimeConnection(){let n=!1;if(this.rtcClient){this.stopConnectionMonitoring(),this.id?(await this.rtcClient.disconnect(this.id),this.remoteDevicePeerId=null):n=!0;try{await this.rtcClient.shutdown()}finally{this.rtcClient=void 0}}if(n)throw new Error(`Realtime connection hasn't been started for ${this.id}`)}}const Ve=class{static async setDefaultDevice(t){Ve.defaultDeviceId=t}static async getCurrentDevice(){if(!Authentication.token)throw new Error("Not authenticated");if(!Ve.defaultDeviceId)throw new Error("No known default device");const r=(await(await fetch(`${FORMANT_API_URL}/v1/admin/device-details/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.find(l=>l.id===Ve.defaultDeviceId),i=r.name,s=new Device(Ve.defaultDeviceId,i,defined(Authentication.currentOrganization),r.tags);return Ve.knownContext.push(new WeakRef(s)),s}static async getPeerDevice(t){const n=new PeerDevice(t);return n.id=await n.getDeviceId(),n}static async getDevice(t){if(!Authentication.token)throw new Error("Not authenticated");const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json(),i=r.name,s=new Device(t,i,r.organizationId,r.tags);return Ve.knownContext.push(new WeakRef(s)),s}static async getDevices(){if(!Authentication.token)throw new Error("Not authenticated");const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/device-details/query`,{method:"POST",body:JSON.stringify({enabled:!0,type:"default"}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();return n.items,n.items.map(r=>new Device(r.id,r.name,r.organizationId,r.tags))}static async queryDevices(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/query`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(i=>new Device(i.id,i.name,i.organizationId,i.tags))}static async getOnlineDevices(){if(!Authentication.token)throw new Error("Not authenticated");const r=(await(await fetch(`${FORMANT_API_URL}/v1/queries/online-devices`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items;return(await Ve.getDevices()).filter(s=>r.includes(s.id))}static async getPeers(){if(!Authentication.token)throw new Error("Not authenticated");const t=defaultRtcClientPool.get();try{return await t.getPeers()}finally{await t.shutdown()}}static async getRealtimeSessions(){if(!Authentication.token)throw new Error("Not authenticated");const t=defaultRtcClientPool.get();try{return await t.getSessions()}finally{await t.shutdown()}}static async getRealtimeDevices(){if(!Authentication.token)throw new Error("Not authenticated");const r=(await(await fetch(`${FORMANT_API_URL}/v1/signaling/peers`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(s=>s.deviceId);return(await Ve.getDevices()).filter(s=>r.includes(s.id))}static async getLatestTelemetry(...t){const n=t.flat().filter(s=>!!s);return n.length===0?[]:(await(await fetch(`${FORMANT_API_URL}/v1/queries/stream-current-value`,{method:"POST",body:JSON.stringify({deviceIds:n}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getTelemetry(t,n,r,i,s){let l=t;Array.isArray(t)||(l=[t]);let o=n;return Array.isArray(n)||(o=[n]),(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify({deviceIds:l,end:i.toISOString(),names:o,start:r.toISOString(),tags:s}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getFileUrl(t){const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/files/query`,{method:"POST",body:JSON.stringify({fileIds:[t]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();if(r.fileUrls.length===0)throw new Error("File not found");return r.fileUrls[0]}static async queryTelemetry(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async aggregateTelemetry(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).aggregates}static async queryEvents(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/events/query`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getEvent(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/events/query/id=${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getInterventions(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-requests`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getCurrentGroup(){if(!Authentication.token)throw new Error("Not authenticated");let t=new URLSearchParams("");typeof window<"u"&&(t=new URLSearchParams(window.location.search));const n=t.get("group");if(n===null||n.trim()==="")return;const r=await fetch(`${FORMANT_API_URL}/v1/admin/groups/`+n,{headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),{tagKey:i,tagValue:s}=await r.json();return await this.queryDevices({tags:{[i]:[s]},enabled:!0,type:"default"})}static async getAnnotationCount(t,n){return(await this.queryEvents({...t,eventTypes:["annotation"]})).filter(l=>!!l.tags&&Object.keys(l.tags).includes(n)).reduce((l,o)=>{const c=o.tags[n];return c in l?(l[c]+=1,l):(l[c]=1,l)},{})}static async getAnnotationCountByIntervals(t,n,r){const{end:i,start:s}=t,o=aggregateByDateFunctions[r].interval({start:new Date(s),end:new Date(i)}),c=o.map((f,E)=>{const _=new Date(f).toISOString(),h=E===o.length-1?new Date(Date.now()).toISOString():new Date(o[E+1]);return this.getAnnotationCount({...t,start:_,end:h},n)}),u=await Promise.all(c);return o.map((f,E)=>({date:new Date(f).toISOString(),annotations:u[E]}))}static async getStreams(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/streams`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.filter(r=>r.enabled)}static async patchStream(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/streams/${t.id}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getViews(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/views`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async patchView(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/views/${t.id}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async eventsCounter(t,n,r,i,s){const l=aggregateByDateFunctions[n];return await Promise.all(Array(r).fill(0).map(async(o,c)=>{const u=new Date(i),f=l.sub(l.start(u),r-c-1),E=l.sub(l.end(u),r-c-1),_=formatTimeFrameText(f.toLocaleDateString(),E.toLocaleDateString()),h=await Ve.queryEvents({...s,eventTypes:t,start:new Date(f).toISOString(),end:new Date(E).toISOString()});return{date:_,events:h}}))}static async getAnalyticsModules(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/analytics-modules`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getAnalyticStreams(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics/streams`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getTaskReportTables(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics/task-reports`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async queryAnalytics(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getAnalyticsRows(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics/rows`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getTaskReportRows(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/queries/analytics/task-report-rows`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async createShareLink(t,n){if(!Authentication.token)throw new Error("Not authenticated");const i=(await this.getViews()).filter(c=>c.name===n);if(i.length===0)return console.warn("View does not exist or it is misspell"),null;const s=await fetch(`${FORMANT_API_URL}/v1/admin/shares`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),l=FORMANT_API_URL.replace("api","app"),{code:o}=await s.json();return`${l}/shares/${o}#${serializeHash({viewId:i[0].id})}`}static async listFleets(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createFleet(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getFleet(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchFleet(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteFleet(t){if(!Authentication.token)throw new Error("Not authenticated");await fetch(`${FORMANT_API_URL}/v1/admin/fleets/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}static async addDeviceToFleet(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/${t}`,{method:"PATCH",body:JSON.stringify({fleetId:n}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getFleetDevices(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/fleets/${t}/devices`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}};let Fleet=Ve;Te(Fleet,"defaultDeviceId"),Te(Fleet,"knownContext",[]);const millisecond=1,second=1e3,minute=60*second,hour=60*minute,day=24*hour,week=7*day,month=30*day,year=365*day,duration={millisecond,second,minute,hour,day,week,month,year};function filterDataByType(e,t){return e.filter(n=>t.includes(n.type))}function filterDataByTime(e,t,n){const r=t.getTime(),i=n.getTime();return e.map(s=>({...s,points:s.points.filter(([l])=>l>=r&&l<i)})).filter(({points:s})=>s.length>0)}function fork(e){}class StoreCache{constructor({capacity:t,timeout:n}={}){Te(this,"entries",new Map);Te(this,"metadata",new Map);Te(this,"capacity");Te(this,"timeout");this.capacity=t||1e4,this.timeout=n||duration.minute}get(t,n){const r=this.keyToCacheKey(t),i=this.entries.get(r),s=this.metadata.get(r);return(i===void 0||s&&(s==null?void 0:s.expiration.getTime())<Date.now())&&!(s!=null&&s.generating)&&n&&this.generate(t,n()),i===void 0&&s&&s.lastValue!==void 0?s.lastValue:i}set(t,n){const r=this.keyToCacheKey(t);this.metadata.set(r,{generating:!1,expiration:new Date(Date.now()+this.timeout),lastValue:n}),this.entries.set(r,n),this.metadata.size>this.capacity&&this.deleteOldestEntry()}clear(){this.entries.clear(),[...this.metadata.values()].forEach(t=>t.generating=!1)}clearKey(t){this.metadata.delete(t),this.entries.delete(t)}keyToCacheKey(t){return JSON.stringify(t)}deleteOldestEntry(){if(this.metadata.size<1)return;const[t]=[...this.metadata.entries()].reduce(([n,r],[i,s])=>s.expiration.getTime()<r.expiration.getTime()?[i,s]:[n,r]);this.clearKey(t)}generate(t,n){const r=this.keyToCacheKey(t),i=this.metadata.get(r)||{};this.metadata.set(r,{...i,generating:!0,expiration:new Date(Date.now()+this.timeout)}),setTimeout(()=>{n.then(s=>{const l=this.metadata.get(r);!(l!=null&&l.generating)||this.set(t,s)})},0)}}class QueryStore{constructor(){Te(this,"queryStoreCache",new StoreCache({capacity:1e4,timeout:20*duration.second}));Te(this,"liveQueryStoreCache",new StoreCache({capacity:1e4,timeout:200*duration.millisecond}))}moduleQuery(t,n,r,i,s,l=!1){const o={...t,names:[...n],types:[...r]},c=this.query(o,i,s,l);return c===void 0||c==="too much data"?c:filterDataByType(c,r)}query(t,n,r,i=!1){const s={...t,start:dateFns.startOfMinute(n).toISOString(),end:i?r.toISOString():dateFns.addMinutes(dateFns.roundToNearestMinutes(r),1).toISOString(),latestOnly:i},l=r>dateFns.addSeconds(new Date,-20);let o;return l?o=this.liveQueryCache(s):o=this.queryCache(s),!o||o==="too much data"||i?o:filterDataByTime(o,n,r)}queryCache(t){return this.queryStoreCache.get(t,async()=>{try{return await Fleet.queryTelemetry(t)}catch(n){throw n}})}liveQueryCache(t){return this.liveQueryStoreCache.get(t,async()=>{try{return await Fleet.queryTelemetry(t)}catch(n){throw n}})}}const queryStore=new QueryStore,lt=class{static sendAppMessage(t){window.parent.postMessage(t,"*")}static getCurrentModuleContext(){let t=new URLSearchParams("");return typeof window<"u"&&(t=new URLSearchParams(window.location.search)),t.get("module")}static async getCurrentModuleConfiguration(){let t=new URLSearchParams("");typeof window<"u"&&(t=new URLSearchParams(window.location.search));const n=t.get("configuration");return n===null||n.trim()===""?void 0:(await(await fetch(`${FORMANT_API_URL}/v1/admin/module-configurations/`+n,{headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).configuration}static isModule(){return this.getCurrentModuleContext()!==null}static goToTime(t){this.sendAppMessage({type:"go_to_time",time:t.getTime()})}static goToDevice(t){this.sendAppMessage({type:"go_to_device",deviceId:t})}static showMessage(t){this.sendAppMessage({type:"show_message",message:t})}static requestModuleData(){const t=this.getCurrentModuleContext();if(!t)throw new Error("No module context");this.sendAppMessage({type:"request_module_data",module:t})}static setModuleDateTimeRange(t,n){const r=this.getCurrentModuleContext();if(!r)throw new Error("No module context");this.sendAppMessage({type:"set_module_data_time_range",module:r,before:t,after:n||0})}static refreshAuthToken(){const t=this.getCurrentModuleContext();if(!t)throw new Error("No module context");this.sendAppMessage({type:"refresh_auth_token",module:t})}static sendChannelData(t,n){const r=this.getCurrentModuleContext();if(!r)throw new Error("No module context");this.sendAppMessage({type:"send_channel_data",source:r,channel:t,data:n})}static setupModuleMenus(t){const n=this.getCurrentModuleContext();if(!n)throw new Error("No module context");this.sendAppMessage({type:"setup_module_menus",module:n,menus:t})}static addMenuListener(t){window.addEventListener("message",n=>{const r=n.data;r.type==="module_menu_item_clicked"&&t(r.menu)})}static addAccessTokenRefreshListener(t){window.addEventListener("message",n=>{const r=n.data;r.type==="auth_token"&&t(r.token)})}static addModuleDataListener(t){const n=this.getCurrentModuleContext();n&&this.sendAppMessage({type:"request_module_data",module:n}),window.addEventListener("message",r=>{const i=r.data;i.type==="module_data"&&t({streams:i.streams,time:i.time,queryRange:i.queryRange})})}static addOverviewDeviceListener(t){this.sendAppMessage({type:"request_devices"});const n=r=>{const i=r.data;i.type==="overview_devices"&&t(i.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}static addStreamListener(t,n,r){const i=s=>{const l=s.data;if(l.type==="module_data"){const{start:o,end:c}=l.queryRange;r(queryStore.moduleQuery({},t,n,new Date(o),new Date(c),!1))}};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)}static addModuleConfigurationListener(t){window.addEventListener("message",n=>{const r=n.data;r.type==="module_configuration"&&t(r)})}static addChannelDataListener(t,n){window.addEventListener("message",r=>{const i=r.data;i.type==="channel_data"&&i.channel===t&&n({source:i.source,data:i.data})})}static async prompt(t,n){return new Promise(r=>{const i=Math.random().toString();this.sendAppMessage({type:"prompt",promptId:i,schema:t,okText:n==null?void 0:n.okText,cancelText:n==null?void 0:n.cancelText});const s=l=>{const o=l.data;o.type==="prompt_response"&&o.promptId===i&&r(o.data),window.removeEventListener("message",s)};window.addEventListener("message",s)})}static async getDate(t,n,r){return new Promise(i=>{this.sendAppMessage({type:"request_date",minTime:n,maxTime:r,time:t});const s=l=>{const o=l.data;o.type==="date_response"&&(window.removeEventListener("message",s),i(o.data))};window.addEventListener("message",s)})}static async disableAnalyticsBottomBar(){this.sendAppMessage({type:"hide_analytics_date_picker"})}static get isOnline(){return lt._isOnline}static listenForConnectionEvents(){window.addEventListener("message",this._handleOnlineEvent)}static checkConnection(t=1e3){return new Promise((n,r)=>{const i=setTimeout(()=>r(new Error("deadline expired: took too long")),t),s=l=>{window.removeEventListener("message",s),clearTimeout(i);const{data:o}=l;o.type==="formant_online"&&(this._isOnline=o.online,n(o.online))};window.addEventListener("message",s),this.sendAppMessage({type:"formant_online"})})}static waitForConnection(t=5e3){let n=!1;const r=new Promise((l,o)=>{setTimeout(()=>{n=!0,o(new Error("deadline expired: took too long"))},t)}),i=l=>new Promise(o=>setTimeout(o,l)),s=async()=>{for(await i(50);!n&&!(this.isOnline||await this.checkConnection);)await i(500)};return Promise.race([r,s()])}};let App=lt;Te(App,"_isOnline",null),Te(App,"_handleOnlineEvent",t=>{const{data:n}=t;n.type==="formant_online"&&(lt._isOnline=n.online)});class RequestDataChannel{constructor(t,n,r){Te(this,"channel");Te(this,"requestIdToResponseMap",new Map);this.device=t,this.channel_name=n,this.timeout=r}addOpenListener(t){defined(this.channel,"channel not initalized").addOpenListener(t)}removeOpenListener(t){defined(this.channel,"channel not initalized").removeOpenListener(t)}addCloseListener(t){defined(this.channel,"channel not initalized").addCloseListener(t)}removeCloseListener(t){defined(this.channel,"channel not initalized").removeCloseListener(t)}addErrorListener(t){defined(this.channel,"channel not initalized").addErrorListener(t)}removeErrorListener(t){defined(this.channel,"channel not initalized").removeErrorListener(t)}}class BinaryRequestDataChannel extends RequestDataChannel{constructor(){super(...arguments);Te(this,"RESPONSE_SUCCESS_BYTE",0);Te(this,"decoder",new TextDecoder)}generateBinaryId(){const n=new Uint8Array(16);for(let r=0;r<n.length;r++)n[r]=Math.floor(Math.random()*256);return n}async initialize(){this.channel=await this.device.createCustomDataChannel(this.channel_name),this.channel.addBinaryListener(n=>{const i=n.slice(0,16).toString();if(i.length===0)throw new Error("Invalid response");const s=n.slice(16);if(s.length===0)throw new Error("Invalid response");this.requestIdToResponseMap.has(i)&&this.requestIdToResponseMap.set(i,s)})}async request(n){if(this.channel||await this.initialize(),!this.channel)throw new Error("Failed to create channel");const{channel:r,requestIdToResponseMap:i,timeout:s}=this;await r.waitTilReady();const l=this.generateBinaryId(),o=l.toString();i.set(o,!0),r.sendBinary(new Uint8Array([...l,...n]));const c=new Date().getTime();for(;new Date().getTime()<c+s;)if(await delay(50),i.has(o)){const u=i.get(o);if(u!==!0){i.delete(o);const f=u[0]===this.RESPONSE_SUCCESS_BYTE,E=u.slice(1);if(f)return E;throw console.error({name:"AdapterError",message:this.decoder.decode(E)}),new Error("Binary request datachannel adapter error")}}throw i.delete(o),console.error({name:"TimeoutError",message:`Request timed out after ${s/1e3} seconds`}),new Error("Binary request data channel request timed out")}}class TextRequestDataChannel extends RequestDataChannel{generateTextId(){return Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2)}async initialize(){this.channel=await this.device.createCustomDataChannel(this.channel_name),this.channel.addListener(t=>{const n=JSON.parse(t),{id:r,data:i,error:s}=n;if(!r)throw new Error("Invalid response");if(!i&&!s)throw new Error("Invalid response");this.requestIdToResponseMap.has(r)&&this.requestIdToResponseMap.set(r,n)})}async request(t){if(this.channel||await this.initialize(),!this.channel)throw new Error("Failed to create channel");const{channel:n,requestIdToResponseMap:r,timeout:i}=this;await n.waitTilReady();const s=this.generateTextId();r.set(s,!0),n.send(JSON.stringify({id:s,data:t}));const l=new Date().getTime();for(;new Date().getTime()<l+i;)if(await delay(50),r.has(s)){const o=r.get(s);if(o!==!0){r.delete(s);const{data:c,error:u}=o;if(c)return c;if(u)throw console.error({name:"AdapterError",message:u}),new Error("Text request datachannel adapter error")}}throw r.delete(s),console.error({name:"TimeoutError",message:`Request timed out after ${i/1e3} seconds`}),new Error("Text request datachannel request timed out")}}class KeyValue{static async set(t,n,r){try{const i=await fetch(FORMANT_API_URL+"/v1/admin/key-value",{method:"POST",body:JSON.stringify({organizationId:defined(Authentication.currentUser).organizationId,key:t,value:n,tags:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),s=await i.json();if(i.status!==200)throw new Error(s.message)}catch(i){throw i}}static async get(t){try{const n=await fetch(FORMANT_API_URL+`/v1/admin/key-value/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),r=await n.json();if(n.status!==200)throw new Error(r.message);return r.value}catch(n){throw n}}static async list(){try{const t=await fetch(FORMANT_API_URL+"/v1/admin/key-value",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),n=await t.json();if(t.status!==200)throw new Error(n.message);return n.items}catch(t){throw t}}static async delete(t){try{if(!(await fetch(FORMANT_API_URL+`/v1/admin/key-value/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).ok)throw new Error("Unable to handle request");return}catch(n){throw n}}}function stringToArrayBuffer(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))}function browser(){const{userAgent:e}=navigator;return e.includes("Firefox/")?"Firefox":e.includes("Edg/")?"Edge":e.includes("Chrome/")?"Chrome":e.includes("Safari/")?"Safari":e.includes("MSIE/")||e.includes("Trident/")?"IE":"Other"}const rtcAudioChunkStreamType="audio-chunk";class AudioPlayer{constructor(t,n){Te(this,"muted",!1);Te(this,"hasReceivedData",!1);Te(this,"audioContext");Te(this,"chunks",[]);Te(this,"isPlaying",!1);Te(this,"startTime",0);Te(this,"lastChunkOffset",0);Te(this,"bufferSize",3);Te(this,"receive",async t=>{var l;const n=(l=t.payload.audioChunk)==null?void 0:l.chunk_data;if(!n)return;this.hasReceivedData||(this.hasReceivedData=!0);const{audioContext:r,muted:i}=this;if(!r||t.header.stream.streamType!==rtcAudioChunkStreamType||i!==!1)return;const s=stringToArrayBuffer(n);try{await r.decodeAudioData(s.buffer,this.scheduleChunk)}catch(o){console.warn("Error decoding audio buffer, changing audioWireFormat on agent",{error:o}),this.changeAudioWireFormat("wav")}});Te(this,"scheduleChunk",t=>{const{audioContext:n}=this;if(!n)return;(this.chunks.length>this.bufferSize||this.isPlaying===!1)&&(this.chunks.forEach(i=>{i.stop()}),this.isPlaying=!1,this.chunks=[]);const r=this.createChunk(t);r&&r.buffer&&(this.isPlaying===!1&&(this.startTime=n.currentTime,this.lastChunkOffset=0,this.isPlaying=!0),r.start(this.startTime+this.lastChunkOffset,0,t.duration),this.lastChunkOffset+=r.buffer.duration,this.chunks.push(r))});this.device=t,this.stream=n,this.device.startListeningToRealtimeDataStream(n),this.device.addRealtimeListener((i,s)=>{this.receive(s)}),browser()==="Safari"||browser()==="IE"?this.changeAudioWireFormat("wav"):this.changeAudioWireFormat("opus");const r=window.AudioContext||window.webkitAudioContext;this.audioContext=new r}async play(){var t,n;((t=this.audioContext)==null?void 0:t.state)==="suspended"&&await((n=this.audioContext)==null?void 0:n.resume()),this.muted=!1}async pause(){await this.audioContext.suspend(),this.muted=!0}destroy(){this.device.stopListeningToRealtimeDataStream(this.stream)}createChunk(t){const{audioContext:n}=this;if(!n)return;const r=n.createBufferSource();return r.buffer=t,r.connect(n.destination),r.loop=!1,r.onended=i=>{this.chunks.splice(this.chunks.indexOf(r),1),this.chunks.length===0&&(this.isPlaying=!1)},r}changeAudioWireFormat(t){const{stream:n}=this;(async()=>await this.device.changeStreamAudioType(n.name,t))()}}class Account{static async listAccounts(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createAccounts(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getAccount(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchAccount(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteAccount(t){if(!Authentication.token)throw new Error("Not authenticated");await fetch(`${FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}static async getAccountTree(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/accounts/${t}/tree`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}}class Role{static async listRoles(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/roles`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createRole(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/roles`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getRole(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/roles/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchRole(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/roles/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteRole(t){if(!Authentication.token)throw new Error("Not authenticated");await fetch(`${FORMANT_API_URL}/v1/admin/roles/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}}class User{static async listUsers(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/users`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createUser(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/users`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getUser(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/users/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchUser(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${FORMANT_API_URL}/v1/admin/users/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteUser(t){if(!Authentication.token)throw new Error("Not authenticated");await fetch(`${FORMANT_API_URL}/v1/admin/users/${t}`,{method:"PATCH",body:JSON.stringify({enabled:!1,roleId:null,teamId:null}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}}const accessLevels=["viewer","operator","administrator"],viewer="viewer",operator="operator",administrator="administrator",aggregateLevels=["year","month","week","day","hour","minute"],annotationTypes=["tag","sheet","user"],eventTypes=["triggered-event","intervention-request","teleop-session-record","port-forwarding-session-record","command-request","command-response","command-delivery","custom","comment","system","annotation"],healthStatuses=["unknown","operational","offline","error"],interventionTypes=["selection","labeling","teleop"],severities=["info","warning","error","critical"],videoMimeTypes=["video/mp4"];window.Buffer=Buffer;const urlParams=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams(""),urlDevice=urlParams.get("device");urlDevice&&Fleet.setDefaultDevice(urlDevice);const urlAuth=urlParams.get("auth");urlAuth&&Authentication.loginWithToken(urlAuth);const moduleName=urlParams.get("module");moduleName&&Authentication.listenForRefresh(),typeof window<"u"&&App.listenForConnectionEvents(),exports.Account=Account,exports.App=App,exports.AudioPlayer=AudioPlayer,exports.Authentication=Authentication,exports.BinaryRequestDataChannel=BinaryRequestDataChannel,exports.CaptureStream=CaptureStream,exports.DataChannel=DataChannel,exports.Device=Device,exports.Fleet=Fleet,exports.KeyValue=KeyValue,exports.Manipulator=Manipulator,exports.PeerDevice=PeerDevice,exports.Role=Role,exports.SessionType=SessionTypeConstants,exports.TextRequestDataChannel=TextRequestDataChannel,exports.User=User,exports.accessLevels=accessLevels,exports.administrator=administrator,exports.aggregateByDateFunctions=aggregateByDateFunctions,exports.aggregateFunctionMap=aggregateFunctionMap,exports.aggregateFunctions=aggregateFunctions,exports.aggregateLevels=aggregateLevels,exports.annotationTypes=annotationTypes,exports.eventTypes=eventTypes,exports.formatTimeFrameText=formatTimeFrameText,exports.getAverage=getAverage,exports.getCount=getCount,exports.getMax=getMax,exports.getMin=getMin,exports.getStandardDeviation=getStandardDeviation,exports.getSum=getSum,exports.getVariance=getVariance,exports.healthStatuses=healthStatuses,exports.interventionTypes=interventionTypes,exports.operator=operator,exports.severities=severities,exports.vailableAggregationIntervals=vailableAggregationIntervals,exports.videoMimeTypes=videoMimeTypes,exports.viewer=viewer,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|