UNPKG

@hamsa-ai/voice-agents-sdk

Version:
1 lines 501 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).HamsaVoiceAgent={})}(this,(function(e){"use strict";function t(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;var i,n={exports:{}};var s=function(){if(i)return n.exports;i=1;var e,t="object"==typeof Reflect?Reflect:null,s=t&&"function"==typeof t.apply?t.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};e=t&&"function"==typeof t.ownKeys?t.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function r(){r.init.call(this)}n.exports=r,n.exports.once=function(e,t){return new Promise((function(i,n){function s(i){e.removeListener(t,o),n(i)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",s),i([].slice.call(arguments))}f(e,t,o,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&f(e,"error",t,i)}(e,s,{once:!0})}))},r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var a=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function d(e){return void 0===e._maxListeners?r.defaultMaxListeners:e._maxListeners}function l(e,t,i,n){var s,o,r,a;if(c(i),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),o=e._events),r=o[t]),void 0===r)r=o[t]=i,++e._eventsCount;else if("function"==typeof r?r=o[t]=n?[i,r]:[r,i]:n?r.unshift(i):r.push(i),(s=d(e))>0&&r.length>s&&!r.warned){r.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=r.length,a=l,console&&console.warn&&console.warn(a)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},s=u.bind(n);return s.listener=i,n.wrapFn=s,s}function p(e,t,i){var n=e._events;if(void 0===n)return[];var s=n[t];return void 0===s?[]:"function"==typeof s?i?[s.listener||s]:[s]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(s):g(s,s.length)}function m(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function g(e,t){for(var i=new Array(t),n=0;n<t;++n)i[n]=e[n];return i}function f(e,t,i,n){if("function"==typeof e.on)n.once?e.once(t,i):e.on(t,i);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function s(o){n.once&&e.removeEventListener(t,s),i(o)}))}}return Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),r.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},r.prototype.getMaxListeners=function(){return d(this)},r.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var r;if(t.length>0&&(r=t[0]),r instanceof Error)throw r;var a=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw a.context=r,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)s(c,this,t);else{var d=c.length,l=g(c,d);for(i=0;i<d;++i)s(l[i],this,t)}return!0},r.prototype.addListener=function(e,t){return l(this,e,t,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(e,t){return l(this,e,t,!0)},r.prototype.once=function(e,t){return c(t),this.on(e,h(this,e,t)),this},r.prototype.prependOnceListener=function(e,t){return c(t),this.prependListener(e,h(this,e,t)),this},r.prototype.removeListener=function(e,t){var i,n,s,o,r;if(c(t),void 0===(n=this._events))return this;if(void 0===(i=n[e]))return this;if(i===t||i.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){r=i[o].listener,s=o;break}if(s<0)return this;0===s?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,s),1===i.length&&(n[e]=i[0]),void 0!==n.removeListener&&this.emit("removeListener",e,r||t)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(e){var t,i,n;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var s,o=Object.keys(i);for(n=0;n<o.length;++n)"removeListener"!==(s=o[n])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},r.prototype.listeners=function(e){return p(this,e,!0)},r.prototype.rawListeners=function(e){return p(this,e,!1)},r.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},r.prototype.listenerCount=m,r.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]},n.exports}();class o extends Error{}function r(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i})))}(t)}catch(e){return atob(t)}}function a(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(i){if("default"!==i&&!(i in e)){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}}))})),Object.freeze(e)}o.prototype.name="InvalidTokenError";var c=Object.defineProperty,d=(e,t,i)=>((e,t,i)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class l{constructor(){d(this,"_locking"),d(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){let e;this._locks+=1;const t=new Promise((t=>e=()=>{this._locks-=1,t()})),i=this._locking.then((()=>e));return this._locking=this._locking.then((()=>t)),i}}function u(e,t){if(!e)throw new Error(t)}function h(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function p(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function m(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}const g=Symbol("@bufbuild/protobuf/enum-type");function f(e){const t=e[g];return u(t,"missing enum type on enum object"),t}function v(e,t,i,n){e[g]=k(t,i.map((t=>({no:t.no,name:t.name,localName:e[t.no]}))))}function k(e,t,i){const n=Object.create(null),s=Object.create(null),o=[];for(const e of t){const t=b(e);o.push(t),n[e.name]=t,s[e.no]=t}return{typeName:e,values:o,findName:e=>n[e],findNumber:e=>s[e]}}function y(e,t,i){const n={};for(const e of t){const t=b(e);n[t.localName]=t.no,n[t.no]=t.localName}return v(n,e,t),n}function b(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class T{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const i=this.getType().runtime.bin,n=i.makeReadOptions(t);return i.readMessage(this,n.readerFactory(e),e.byteLength,n),this}fromJson(e,t){const i=this.getType(),n=i.runtime.json,s=n.makeReadOptions(t);return n.readMessage(i,e,s,this),this}fromJsonString(e,t){let i;try{i=JSON.parse(e)}catch(e){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(e instanceof Error?e.message:String(e)))}return this.fromJson(i,t)}toBinary(e){const t=this.getType().runtime.bin,i=t.makeWriteOptions(e),n=i.writerFactory();return t.writeMessage(this,n,i),n.finish()}toJson(e){const t=this.getType().runtime.json,i=t.makeWriteOptions(e);return t.writeMessage(this,i)}toJsonString(e){var t;const i=this.toJson(e);return JSON.stringify(i,null,null!==(t=null==e?void 0:e.prettySpaces)&&void 0!==t?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function C(){let e=0,t=0;for(let i=0;i<28;i+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<i,!(128&n))return this.assertBounds(),[e,t]}let i=this.buf[this.pos++];if(e|=(15&i)<<28,t=(112&i)>>4,!(128&i))return this.assertBounds(),[e,t];for(let i=3;i<=31;i+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<i,!(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function S(e,t,i){for(let n=0;n<28;n+=7){const s=e>>>n,o=!(s>>>7==0&&0==t),r=255&(o?128|s:s);if(i.push(r),!o)return}const n=e>>>28&15|(7&t)<<4,s=!!(t>>3);if(i.push(255&(s?128|n:n)),s){for(let e=3;e<31;e+=7){const n=t>>>e,s=!(n>>>7==0),o=255&(s?128|n:n);if(i.push(o),!s)return}i.push(t>>>31&1)}}const w=4294967296;function E(e){const t="-"===e[0];t&&(e=e.slice(1));const i=1e6;let n=0,s=0;function o(t,o){const r=Number(e.slice(t,o));s*=i,n=n*i+r,n>=w&&(s+=n/w|0,n%=w)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),t?I(n,s):R(n,s)}function P(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(w*t+e);const i=16777215&(e>>>24|t<<8),n=t>>16&65535;let s=(16777215&e)+6777216*i+6710656*n,o=i+8147497*n,r=2*n;const a=1e7;return s>=a&&(o+=Math.floor(s/a),s%=a),o>=a&&(r+=Math.floor(o/a),o%=a),r.toString()+M(o)+M(s)}function R(e,t){return{lo:0|e,hi:0|t}}function I(e,t){return t=~t,e?e=1+~e:t+=1,R(e,t)}const M=e=>{const t=String(e);return"0000000".slice(t.length)+t};function A(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let i=0;i<9;i++)t.push(127&e|128),e>>=7;t.push(1)}}function D(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;128&e&&t<10;t++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}const O=function(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),i=BigInt("9223372036854775807"),n=BigInt("0"),s=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const n="bigint"==typeof e?e:BigInt(e);if(n>i||n<t)throw new Error("int64 invalid: ".concat(e));return n},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>s||t<n)throw new Error("uint64 invalid: ".concat(e));return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,i)=>(e.setInt32(0,t,!0),e.setInt32(4,i,!0),e.getBigInt64(0,!0)),uDec:(t,i)=>(e.setInt32(0,t,!0),e.setInt32(4,i,!0),e.getBigUint64(0,!0))}}const t=e=>u(/^-?[0-9]+$/.test(e),"int64 invalid: ".concat(e)),i=e=>u(/^[0-9]+$/.test(e),"uint64 invalid: ".concat(e));return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),t(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),i(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),t(e),E(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),i(e),E(e)),dec:(e,t)=>function(e,t){let i=R(e,t);const n=2147483648&i.hi;n&&(i=I(i.lo,i.hi));const s=P(i.lo,i.hi);return n?"-"+s:s}(e,t),uDec:(e,t)=>P(e,t)}}();var _,L,x;function N(e,t,i){if(t===i)return!0;if(e==_.BYTES){if(!(t instanceof Uint8Array&&i instanceof Uint8Array))return!1;if(t.length!==i.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==i[e])return!1;return!0}switch(e){case _.UINT64:case _.FIXED64:case _.INT64:case _.SFIXED64:case _.SINT64:return t==i}return!1}function U(e,t){switch(e){case _.BOOL:return!1;case _.UINT64:case _.FIXED64:case _.INT64:case _.SFIXED64:case _.SINT64:return 0==t?O.zero:"0";case _.DOUBLE:case _.FLOAT:return 0;case _.BYTES:return new Uint8Array(0);case _.STRING:return"";default:return 0}}function j(e,t){switch(e){case _.BOOL:return!1===t;case _.STRING:return""===t;case _.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return 0==t}}!function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"}(_||(_={})),function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING"}(L||(L={})),function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(x||(x={}));class F{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),i=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],i),i+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(p(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return h(e),A(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){m(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){p(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){h(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return h(e),A(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),n=O.enc(e);return i.setInt32(0,n.lo,!0),i.setInt32(4,n.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),n=O.uEnc(e);return i.setInt32(0,n.lo,!0),i.setInt32(4,n.hi,!0),this.raw(t)}int64(e){let t=O.enc(e);return S(t.lo,t.hi,this.buf),this}sint64(e){let t=O.enc(e),i=t.hi>>31;return S(t.lo<<1^i,(t.hi<<1|t.lo>>>31)^i,this.buf),this}uint64(e){let t=O.uEnc(e);return S(t.lo,t.hi,this.buf),this}}class B{constructor(e,t){this.varint64=C,this.uint32=D,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,i=7&e;if(t<=0||i<0||i>5)throw new Error("illegal tag: field no "+t+" wire type "+i);return[t,i]}skip(e,t){let i=this.pos;switch(e){case x.Varint:for(;128&this.buf[this.pos++];);break;case x.Bit64:this.pos+=4;case x.Bit32:this.pos+=4;break;case x.LengthDelimited:let i=this.uint32();this.pos+=i;break;case x.StartGroup:for(;;){const[e,i]=this.tag();if(i===x.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(i,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return O.dec(...this.varint64())}uint64(){return O.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),i=-(1&e);return e=(e>>>1|(1&t)<<31)^i,t=t>>>1^i,O.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return O.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return O.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function V(e){const t=e.field.localName,i=Object.create(null);return i[t]=function(e){const t=e.field;if(t.repeated)return[];if(void 0!==t.default)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return U(t.T,t.L);case"message":const e=t.T,i=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(i):i;case"map":throw"map fields are not allowed to be extensions"}}(e),[i,()=>i[t]]}let q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),K=[];for(let e=0;e<q.length;e++)K[q[e].charCodeAt(0)]=e;K["-".charCodeAt(0)]=q.indexOf("+"),K["_".charCodeAt(0)]=q.indexOf("/");const H={dec(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let i,n=new Uint8Array(t),s=0,o=0,r=0;for(let t=0;t<e.length;t++){if(i=K[e.charCodeAt(t)],void 0===i)switch(e[t]){case"=":o=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(o){case 0:r=i,o=1;break;case 1:n[s++]=r<<2|(48&i)>>4,r=i,o=2;break;case 2:n[s++]=(15&r)<<4|(60&i)>>2,r=i,o=3;break;case 3:n[s++]=(3&r)<<6|i,o=0}}if(1==o)throw Error("invalid base64 string.");return n.subarray(0,s)},enc(e){let t,i="",n=0,s=0;for(let o=0;o<e.length;o++)switch(t=e[o],n){case 0:i+=q[t>>2],s=(3&t)<<4,n=1;break;case 1:i+=q[s|t>>4],s=(15&t)<<2,n=2;break;case 2:i+=q[s|t>>6],i+=q[63&t],n=0}return n&&(i+=q[s],i+="=",1==n&&(i+="=")),i}};function W(e,t,i){J(t,e);const n=t.runtime.bin.makeReadOptions(i),s=function(e,t){if(!t.repeated&&("enum"==t.kind||"scalar"==t.kind)){for(let i=e.length-1;i>=0;--i)if(e[i].no==t.no)return[e[i]];return[]}return e.filter((e=>e.no===t.no))}(e.getType().runtime.bin.listUnknownFields(e),t.field),[o,r]=V(t);for(const e of s)t.runtime.bin.readField(o,n.readerFactory(e.data),t.field,e.wireType,n);return r()}function G(e,t,i,n){J(t,e);const s=t.runtime.bin.makeReadOptions(n),o=t.runtime.bin.makeWriteOptions(n);if(z(e,t)){const i=e.getType().runtime.bin.listUnknownFields(e).filter((e=>e.no!=t.field.no));e.getType().runtime.bin.discardUnknownFields(e);for(const t of i)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}const r=o.writerFactory();let a=t.field;a.opt||a.repeated||"enum"!=a.kind&&"scalar"!=a.kind||(a=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(a,i,r,o);const c=s.readerFactory(r.finish());for(;c.pos<c.len;){const[t,i]=c.tag(),n=c.skip(i,t);e.getType().runtime.bin.onUnknownField(e,t,i,n)}}function z(e,t){const i=e.getType();return t.extendee.typeName===i.typeName&&!!i.runtime.bin.listUnknownFields(e).find((e=>e.no==t.field.no))}function J(e,t){u(e.extendee.typeName==t.getType().typeName,"extension ".concat(e.typeName," can only be applied to message ").concat(e.extendee.typeName))}function Q(e,t){const i=e.localName;if(e.repeated)return t[i].length>0;if(e.oneof)return t[e.oneof.localName].case===i;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?void 0!==t[i]:"enum"==e.kind?t[i]!==e.T.values[0].no:!j(e.T,t[i]);case"message":return void 0!==t[i];case"map":return Object.keys(t[i]).length>0}}function $(e,t){const i=e.localName,n=!e.opt&&!e.req;if(e.repeated)t[i]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[i]={};break;case"enum":t[i]=n?e.T.values[0].no:void 0;break;case"scalar":t[i]=n?U(e.T,e.L):void 0;break;case"message":t[i]=void 0}}function Y(e,t){if(null===e||"object"!=typeof e)return!1;if(!Object.getOwnPropertyNames(T.prototype).every((t=>t in e&&"function"==typeof e[t])))return!1;const i=e.getType();return null!==i&&"function"==typeof i&&"typeName"in i&&"string"==typeof i.typeName&&(void 0===t||i.typeName==t.typeName)}function X(e,t){return Y(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}_.DOUBLE,_.FLOAT,_.INT64,_.UINT64,_.INT32,_.UINT32,_.BOOL,_.STRING,_.BYTES;const Z={ignoreUnknownFields:!1},ee={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function te(e){return e?Object.assign(Object.assign({},Z),e):Z}function ie(e){return e?Object.assign(Object.assign({},ee),e):ee}const ne=Symbol(),se=Symbol();function oe(e){if(null===e)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":'"'.concat(e.split('"').join('\\"'),'"');default:return String(e)}}function re(e,t,i,n,s){let o=i.localName;if(i.repeated){if(u("map"!=i.kind),null===t)return;if(!Array.isArray(t))throw new Error("cannot decode field ".concat(s.typeName,".").concat(i.name," from JSON: ").concat(oe(t)));const r=e[o];for(const e of t){if(null===e)throw new Error("cannot decode field ".concat(s.typeName,".").concat(i.name," from JSON: ").concat(oe(e)));switch(i.kind){case"message":r.push(i.T.fromJson(e,n));break;case"enum":const t=de(i.T,e,n.ignoreUnknownFields,!0);t!==se&&r.push(t);break;case"scalar":try{r.push(ce(i.T,e,i.L,!0))}catch(t){let n="cannot decode field ".concat(s.typeName,".").concat(i.name," from JSON: ").concat(oe(e));throw t instanceof Error&&t.message.length>0&&(n+=": ".concat(t.message)),new Error(n)}}}}else if("map"==i.kind){if(null===t)return;if("object"!=typeof t||Array.isArray(t))throw new Error("cannot decode field ".concat(s.typeName,".").concat(i.name," from JSON: ").concat(oe(t)));const r=e[o];for(const[e,o]of Object.entries(t)){if(null===o)throw new Error("cannot decode field ".concat(s.typeName,".").concat(i.name," from JSON: map value null"));let a;try{a=ae(i.K,e)}catch(e){let n="cannot decode map key for field ".concat(s.typeName,".").concat(i.name," from JSON: ").concat(oe(t));throw e instanceof Error&&e.message.length>0&&(n+=": ".concat(e.message)),new Error(n)}switch(i.V.kind){case"message":r[a]=i.V.T.fromJson(o,n);break;case"enum":const e=de(i.V.T,o,n.ignoreUnknownFields,!0);e!==se&&(r[a]=e);break;case"scalar":try{r[a]=ce(i.V.T,o,L.BIGINT,!0)}catch(e){let n="cannot decode map value for field ".concat(s.typeName,".").concat(i.name," from JSON: ").concat(oe(t));throw e instanceof Error&&e.message.length>0&&(n+=": ".concat(e.message)),new Error(n)}}}}else switch(i.oneof&&(e=e[i.oneof.localName]={case:o},o="value"),i.kind){case"message":const r=i.T;if(null===t&&"google.protobuf.Value"!=r.typeName)return;let a=e[o];Y(a)?a.fromJson(t,n):(e[o]=a=r.fromJson(t,n),r.fieldWrapper&&!i.oneof&&(e[o]=r.fieldWrapper.unwrapField(a)));break;case"enum":const c=de(i.T,t,n.ignoreUnknownFields,!1);switch(c){case ne:$(i,e);break;case se:break;default:e[o]=c}break;case"scalar":try{const n=ce(i.T,t,i.L,!1);if(n===ne)$(i,e);else e[o]=n}catch(e){let n="cannot decode field ".concat(s.typeName,".").concat(i.name," from JSON: ").concat(oe(t));throw e instanceof Error&&e.message.length>0&&(n+=": ".concat(e.message)),new Error(n)}}}function ae(e,t){if(e===_.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1}return ce(e,t,L.BIGINT,!0).toString()}function ce(e,t,i,n){if(null===t)return n?U(e,i):ne;switch(e){case _.DOUBLE:case _.FLOAT:if("NaN"===t)return Number.NaN;if("Infinity"===t)return Number.POSITIVE_INFINITY;if("-Infinity"===t)return Number.NEGATIVE_INFINITY;if(""===t)break;if("string"==typeof t&&t.trim().length!==t.length)break;if("string"!=typeof t&&"number"!=typeof t)break;const n=Number(t);if(Number.isNaN(n))break;if(!Number.isFinite(n))break;return e==_.FLOAT&&m(n),n;case _.INT32:case _.FIXED32:case _.SFIXED32:case _.SINT32:case _.UINT32:let s;if("number"==typeof t?s=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(s=Number(t)),void 0===s)break;return e==_.UINT32||e==_.FIXED32?p(s):h(s),s;case _.INT64:case _.SFIXED64:case _.SINT64:if("number"!=typeof t&&"string"!=typeof t)break;const o=O.parse(t);return i?o.toString():o;case _.FIXED64:case _.UINT64:if("number"!=typeof t&&"string"!=typeof t)break;const r=O.uParse(t);return i?r.toString():r;case _.BOOL:if("boolean"!=typeof t)break;return t;case _.STRING:if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(e){throw new Error("invalid UTF8")}return t;case _.BYTES:if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return H.dec(t)}throw new Error}function de(e,t,i,n){if(null===t)return"google.protobuf.NullValue"==e.typeName?0:n?e.values[0].no:ne;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const n=e.findName(t);if(void 0!==n)return n.no;if(i)return se}throw new Error("cannot decode enum ".concat(e.typeName," from JSON: ").concat(oe(t)))}function le(e){return!(!e.repeated&&"map"!=e.kind)||!e.oneof&&("message"!=e.kind&&(!e.opt&&!e.req))}function ue(e,t,i){if("map"==e.kind){u("object"==typeof t&&null!=t);const n={},s=Object.entries(t);switch(e.V.kind){case"scalar":for(const[t,i]of s)n[t.toString()]=pe(e.V.T,i);break;case"message":for(const[e,t]of s)n[e.toString()]=t.toJson(i);break;case"enum":const t=e.V.T;for(const[e,o]of s)n[e.toString()]=he(t,o,i.enumAsInteger)}return i.emitDefaultValues||s.length>0?n:void 0}if(e.repeated){u(Array.isArray(t));const n=[];switch(e.kind){case"scalar":for(let i=0;i<t.length;i++)n.push(pe(e.T,t[i]));break;case"enum":for(let s=0;s<t.length;s++)n.push(he(e.T,t[s],i.enumAsInteger));break;case"message":for(let e=0;e<t.length;e++)n.push(t[e].toJson(i))}return i.emitDefaultValues||n.length>0?n:void 0}switch(e.kind){case"scalar":return pe(e.T,t);case"enum":return he(e.T,t,i.enumAsInteger);case"message":return X(e.T,t).toJson(i)}}function he(e,t,i){var n;if(u("number"==typeof t),"google.protobuf.NullValue"==e.typeName)return null;if(i)return t;const s=e.findNumber(t);return null!==(n=null==s?void 0:s.name)&&void 0!==n?n:t}function pe(e,t){switch(e){case _.INT32:case _.SFIXED32:case _.SINT32:case _.FIXED32:case _.UINT32:return u("number"==typeof t),t;case _.FLOAT:case _.DOUBLE:return u("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case _.STRING:return u("string"==typeof t),t;case _.BOOL:return u("boolean"==typeof t),t;case _.UINT64:case _.FIXED64:case _.INT64:case _.SFIXED64:case _.SINT64:return u("bigint"==typeof t||"string"==typeof t||"number"==typeof t),t.toString();case _.BYTES:return u(t instanceof Uint8Array),H.enc(t)}}const me=Symbol("@bufbuild/protobuf/unknown-fields"),ge={readUnknownFields:!0,readerFactory:e=>new B(e)},fe={writeUnknownFields:!0,writerFactory:()=>new F};function ve(e){return e?Object.assign(Object.assign({},ge),e):ge}function ke(e){return e?Object.assign(Object.assign({},fe),e):fe}function ye(e,t,i,n,s){let{repeated:o,localName:r}=i;switch(i.oneof&&((e=e[i.oneof.localName]).case!=r&&delete e.value,e.case=r,r="value"),i.kind){case"scalar":case"enum":const a="enum"==i.kind?_.INT32:i.T;let c=Ce;if("scalar"==i.kind&&i.L>0&&(c=Te),o){let i=e[r];if(n==x.LengthDelimited&&a!=_.STRING&&a!=_.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)i.push(c(t,a))}else i.push(c(t,a))}else e[r]=c(t,a);break;case"message":const d=i.T;o?e[r].push(be(t,new d,s,i)):Y(e[r])?be(t,e[r],s,i):(e[r]=be(t,new d,s,i),!d.fieldWrapper||i.oneof||i.repeated||(e[r]=d.fieldWrapper.unwrapField(e[r])));break;case"map":let[l,u]=function(e,t,i){const n=t.uint32(),s=t.pos+n;let o,r;for(;t.pos<s;){const[n]=t.tag();switch(n){case 1:o=Ce(t,e.K);break;case 2:switch(e.V.kind){case"scalar":r=Ce(t,e.V.T);break;case"enum":r=t.int32();break;case"message":r=be(t,new e.V.T,i,void 0)}}}void 0===o&&(o=U(e.K,L.BIGINT));"string"!=typeof o&&"number"!=typeof o&&(o=o.toString());if(void 0===r)switch(e.V.kind){case"scalar":r=U(e.V.T,L.BIGINT);break;case"enum":r=e.V.T.values[0].no;break;case"message":r=new e.V.T}return[o,r]}(i,t,s);e[r][l]=u}}function be(e,t,i,n){const s=t.getType().runtime.bin,o=null==n?void 0:n.delimited;return s.readMessage(t,e,o?n.no:e.uint32(),i,o),t}function Te(e,t){const i=Ce(e,t);return"bigint"==typeof i?i.toString():i}function Ce(e,t){switch(t){case _.STRING:return e.string();case _.BOOL:return e.bool();case _.DOUBLE:return e.double();case _.FLOAT:return e.float();case _.INT32:return e.int32();case _.INT64:return e.int64();case _.UINT64:return e.uint64();case _.FIXED64:return e.fixed64();case _.BYTES:return e.bytes();case _.FIXED32:return e.fixed32();case _.SFIXED32:return e.sfixed32();case _.SFIXED64:return e.sfixed64();case _.SINT64:return e.sint64();case _.UINT32:return e.uint32();case _.SINT32:return e.sint32()}}function Se(e,t,i,n){u(void 0!==t);const s=e.repeated;switch(e.kind){case"scalar":case"enum":let o="enum"==e.kind?_.INT32:e.T;if(s)if(u(Array.isArray(t)),e.packed)!function(e,t,i,n){if(!n.length)return;e.tag(i,x.LengthDelimited).fork();let[,s]=Re(t);for(let t=0;t<n.length;t++)e[s](n[t]);e.join()}(i,o,e.no,t);else for(const n of t)Pe(i,o,e.no,n);else Pe(i,o,e.no,t);break;case"message":if(s){u(Array.isArray(t));for(const s of t)Ee(i,n,e,s)}else Ee(i,n,e,t);break;case"map":u("object"==typeof t&&null!=t);for(const[s,o]of Object.entries(t))we(i,n,e,s,o)}}function we(e,t,i,n,s){e.tag(i.no,x.LengthDelimited),e.fork();let o=n;switch(i.K){case _.INT32:case _.FIXED32:case _.UINT32:case _.SFIXED32:case _.SINT32:o=Number.parseInt(n);break;case _.BOOL:u("true"==n||"false"==n),o="true"==n}switch(Pe(e,i.K,1,o),i.V.kind){case"scalar":Pe(e,i.V.T,2,s);break;case"enum":Pe(e,_.INT32,2,s);break;case"message":u(void 0!==s),e.tag(2,x.LengthDelimited).bytes(s.toBinary(t))}e.join()}function Ee(e,t,i,n){const s=X(i.T,n);i.delimited?e.tag(i.no,x.StartGroup).raw(s.toBinary(t)).tag(i.no,x.EndGroup):e.tag(i.no,x.LengthDelimited).bytes(s.toBinary(t))}function Pe(e,t,i,n){u(void 0!==n);let[s,o]=Re(t);e.tag(i,s)[o](n)}function Re(e){let t=x.Varint;switch(e){case _.BYTES:case _.STRING:t=x.LengthDelimited;break;case _.DOUBLE:case _.FIXED64:case _.SFIXED64:t=x.Bit64;break;case _.FIXED32:case _.SFIXED32:case _.FLOAT:t=x.Bit32}return[t,_[e].toLowerCase()]}function Ie(e){if(void 0===e)return e;if(Y(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function Me(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class Ae{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const e={};for(const t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){const e={};for(const t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort(((e,t)=>e.no-t.no))),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const i of this.list())i.oneof?i.oneof!==t&&(t=i.oneof,e.push(t)):e.push(i)}return this.members}}function De(e,t){const i=_e(e);return t?i:je(Ue(i))}const Oe=_e;function _e(e){let t=!1;const i=[];for(let n=0;n<e.length;n++){let s=e.charAt(n);switch(s){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":i.push(s),t=!1;break;default:t&&(t=!1,s=s.toUpperCase()),i.push(s)}}return i.join("")}const Le=new Set(["constructor","toString","toJSON","valueOf"]),xe=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Ne=e=>"".concat(e,"$"),Ue=e=>xe.has(e)?Ne(e):e,je=e=>Le.has(e)?Ne(e):e;class Fe{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=De(e,!1)}addField(e){u(e.oneof===this,"field ".concat(e.name," not one of ").concat(this.name)),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}}const Be=(Ve=e=>new Ae(e,(e=>function(e){var t,i,n,s,o,r;const a=[];let c;for(const d of"function"==typeof e?e():e){const e=d;if(e.localName=De(d.name,void 0!==d.oneof),e.jsonName=null!==(t=d.jsonName)&&void 0!==t?t:Oe(d.name),e.repeated=null!==(i=d.repeated)&&void 0!==i&&i,"scalar"==d.kind&&(e.L=null!==(n=d.L)&&void 0!==n?n:L.BIGINT),e.delimited=null!==(s=d.delimited)&&void 0!==s&&s,e.req=null!==(o=d.req)&&void 0!==o&&o,e.opt=null!==(r=d.opt)&&void 0!==r&&r,void 0===d.packed&&(e.packed="enum"==d.kind||"scalar"==d.kind&&d.T!=_.BYTES&&d.T!=_.STRING),void 0!==d.oneof){const t="string"==typeof d.oneof?d.oneof:d.oneof.name;c&&c.name==t||(c=new Fe(t)),e.oneof=c,c.addField(e)}a.push(e)}return a}(e))),qe=e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const i=t.localName,n=e;if(t.repeated)n[i]=[];else switch(t.kind){case"oneof":n[i]={case:void 0};break;case"enum":n[i]=0;break;case"map":n[i]={};break;case"scalar":n[i]=U(t.T,t.L)}}},{syntax:"proto3",json:{makeReadOptions:te,makeWriteOptions:ie,readMessage(e,t,i,n){if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error("cannot decode message ".concat(e.typeName," from JSON: ").concat(oe(t)));n=null!=n?n:new e;const s=new Map,o=i.typeRegistry;for(const[r,a]of Object.entries(t)){const t=e.fields.findJsonName(r);if(t){if(t.oneof){if(null===a&&"scalar"==t.kind)continue;const i=s.get(t.oneof);if(void 0!==i)throw new Error("cannot decode message ".concat(e.typeName,' from JSON: multiple keys for oneof "').concat(t.oneof.name,'" present: "').concat(i,'", "').concat(r,'"'));s.set(t.oneof,r)}re(n,a,t,i,e)}else{let t=!1;if((null==o?void 0:o.findExtension)&&r.startsWith("[")&&r.endsWith("]")){const s=o.findExtension(r.substring(1,r.length-1));if(s&&s.extendee.typeName==e.typeName){t=!0;const[e,o]=V(s);re(e,a,s.field,i,s),G(n,s,o(),i)}}if(!t&&!i.ignoreUnknownFields)throw new Error("cannot decode message ".concat(e.typeName,' from JSON: key "').concat(r,'" is unknown'))}}return n},writeMessage(e,t){const i=e.getType(),n={};let s;try{for(s of i.fields.byNumber()){if(!Q(s,e)){if(s.req)throw"required field not set";if(!t.emitDefaultValues)continue;if(!le(s))continue}const i=ue(s,s.oneof?e[s.oneof.localName].value:e[s.localName],t);void 0!==i&&(n[t.useProtoFieldName?s.name:s.jsonName]=i)}const o=t.typeRegistry;if(null==o?void 0:o.findExtensionFor)for(const s of i.runtime.bin.listUnknownFields(e)){const r=o.findExtensionFor(i.typeName,s.no);if(r&&z(e,r)){const i=W(e,r,t),s=ue(r.field,i,t);void 0!==s&&(n[r.field.jsonName]=s)}}}catch(e){const t=s?"cannot encode field ".concat(i.typeName,".").concat(s.name," to JSON"):"cannot encode message ".concat(i.typeName," to JSON"),n=e instanceof Error?e.message:String(e);throw new Error(t+(n.length>0?": ".concat(n):""))}return n},readScalar:(e,t,i)=>ce(e,t,null!=i?i:L.BIGINT,!0),writeScalar(e,t,i){if(void 0!==t)return i||j(e,t)?pe(e,t):void 0},debug:oe},bin:{makeReadOptions:ve,makeWriteOptions:ke,listUnknownFields(e){var t;return null!==(t=e[me])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[me]},writeUnknownFields(e,t){const i=e[me];if(i)for(const e of i)t.tag(e.no,e.wireType).raw(e.data)},onUnknownField(e,t,i,n){const s=e;Array.isArray(s[me])||(s[me]=[]),s[me].push({no:t,wireType:i,data:n})},readMessage(e,t,i,n,s){const o=e.getType(),r=s?t.len:t.pos+i;let a,c;for(;t.pos<r&&([a,c]=t.tag(),!0!==s||c!=x.EndGroup);){const i=o.fields.find(a);if(i)ye(e,t,i,c,n);else{const i=t.skip(c,a);n.readUnknownFields&&this.onUnknownField(e,a,c,i)}}if(s&&(c!=x.EndGroup||a!==i))throw new Error("invalid end group tag")},readField:ye,writeMessage(e,t,i){const n=e.getType();for(const s of n.fields.byNumber())if(Q(s,e))Se(s,s.oneof?e[s.oneof.localName].value:e[s.localName],t,i);else if(s.req)throw new Error("cannot encode field ".concat(n.typeName,".").concat(s.name," to binary: required field not set"));return i.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,i,n){void 0!==t&&Se(e,t,i,n)}},util:Object.assign(Object.assign({},{setEnumType:v,initPartial(e,t){if(void 0===e)return;const i=t.getType();for(const n of i.fields.byMember()){const i=n.localName,s=t,o=e;if(null!=o[i])switch(n.kind){case"oneof":const e=o[i].case;if(void 0===e)continue;const t=n.findField(e);let r=o[i].value;t&&"message"==t.kind&&!Y(r,t.T)?r=new t.T(r):t&&"scalar"===t.kind&&t.T===_.BYTES&&(r=Me(r)),s[i]={case:e,value:r};break;case"scalar":case"enum":let a=o[i];n.T===_.BYTES&&(a=n.repeated?a.map(Me):Me(a)),s[i]=a;break;case"map":switch(n.V.kind){case"scalar":case"enum":if(n.V.T===_.BYTES)for(const[e,t]of Object.entries(o[i]))s[i][e]=Me(t);else Object.assign(s[i],o[i]);break;case"message":const e=n.V.T;for(const t of Object.keys(o[i])){let n=o[i][t];e.fieldWrapper||(n=new e(n)),s[i][t]=n}}break;case"message":const c=n.T;if(n.repeated)s[i]=o[i].map((e=>Y(e,c)?e:new c(e)));else{const e=o[i];c.fieldWrapper?"google.protobuf.BytesValue"===c.typeName?s[i]=Me(e):s[i]=e:s[i]=Y(e,c)?e:new c(e)}}}},equals:(e,t,i)=>t===i||!(!t||!i)&&e.fields.byMember().every((e=>{const n=t[e.localName],s=i[e.localName];if(e.repeated){if(n.length!==s.length)return!1;switch(e.kind){case"message":return n.every(((t,i)=>e.T.equals(t,s[i])));case"scalar":return n.every(((t,i)=>N(e.T,t,s[i])));case"enum":return n.every(((e,t)=>N(_.INT32,e,s[t])))}throw new Error("repeated cannot contain ".concat(e.kind))}switch(e.kind){case"message":let t=n,i=s;return e.T.fieldWrapper&&(void 0===t||Y(t)||(t=e.T.fieldWrapper.wrapField(t)),void 0===i||Y(i)||(i=e.T.fieldWrapper.wrapField(i))),e.T.equals(t,i);case"enum":return N(_.INT32,n,s);case"scalar":return N(e.T,n,s);case"oneof":if(n.case!==s.case)return!1;const o=e.findField(n.case);if(void 0===o)return!0;switch(o.kind){case"message":return o.T.equals(n.value,s.value);case"enum":return N(_.INT32,n.value,s.value);case"scalar":return N(o.T,n.value,s.value)}throw new Error("oneof cannot contain ".concat(o.kind));case"map":const r=Object.keys(n).concat(Object.keys(s));switch(e.V.kind){case"message":const t=e.V.T;return r.every((e=>t.equals(n[e],s[e])));case"enum":return r.every((e=>N(_.INT32,n[e],s[e])));case"scalar":const i=e.V.T;return r.every((e=>N(i,n[e],s[e])))}}})),clone(e){const t=e.getType(),i=new t,n=i;for(const i of t.fields.byMember()){const t=e[i.localName];let s;if(i.repeated)s=t.map(Ie);else if("map"==i.kind){s=n[i.localName];for(const[e,i]of Object.entries(t))s[e]=Ie(i)}else s="oneof"==i.kind?i.findField(t.case)?{case:t.case,value:Ie(t.value)}:{case:void 0}:Ie(t);n[i.localName]=s}for(const i of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(n,i.no,i.wireType,i.data);return i}}),{newFieldList:Ve,initFields:qe}),makeMessageType(e,t,i){return function(e,t,i,n){var s;const o=null!==(s=null==n?void 0:n.localName)&&void 0!==s?s:t.substring(t.lastIndexOf(".")+1),r={[o]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[o];return Object.setPrototypeOf(r.prototype,new T),Object.assign(r,{runtime:e,typeName:t,fields:e.util.newFieldList(i),fromBinary:(e,t)=>(new r).fromBinary(e,t),fromJson:(e,t)=>(new r).fromJson(e,t),fromJsonString:(e,t)=>(new r).fromJsonString(e,t),equals:(t,i)=>e.util.equals(r,t,i)}),r}(this,e,t,i)},makeEnum:y,makeEnumType:k,getEnumType:f,makeExtension(e,t,i){return function(e,t,i,n){let s;return{typeName:t,extendee:i,get field(){if(!s){const i="function"==typeof n?n():n;i.name=t.split(".").pop(),i.jsonName="[".concat(t,"]"),s=e.util.newFieldList([i]).list()[0]}return s},runtime:e}}(this,e,t,i)}});var Ve,qe;class Ke extends T{constructor(e){super(),this.seconds=O.zero,this.nanos=0,Be.util.initPartial(e,this)}fromJson(e,t){if("string"!=typeof e)throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(Be.json.debug(e)));const i=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!i)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const n=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(n))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(n<Date.parse("0001-01-01T00:00:00Z")||n>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");return this.seconds=O.parse(n/1e3),this.nanos=0,i[7]&&(this.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),this}toJson(e){const t=1e3*Number(this.seconds);if(t<Date.parse("0001-01-01T00:00:00Z")||t>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let i="Z";if(this.nanos>0){const e=(this.nanos+1e9).toString().substring(1);i="000000"===e.substring(3)?"."+e.substring(0,3)+"Z":"000"===e.substring(6)?"."+e.substring(0,6)+"Z":"."+e+"Z"}return new Date(t).toISOString().replace(".000Z",i)}toDate(){return new Date(1e3*Number(this.seconds)+Math.ceil(this.nanos/1e6))}static now(){return Ke.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Ke({seconds:O.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return(new Ke).fromBinary(e,t)}static fromJson(e,t){return(new Ke).fromJson(e,t)}static fromJsonString(e,t){return(new Ke).fromJsonString(e,t)}static equals(e,t){return Be.util.equals(Ke,e,t)}}Ke.runtime=Be,Ke.typeName="google.protobuf.Timestamp",Ke.fields=Be.util.newFieldList((()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]));const He=Be.makeMessageType("livekit.MetricsBatch",(()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Ke},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:We,repeated:!0},{no:5,name:"events",kind:"message",T:ze,repeated:!0}])),We=Be.makeMessageType("livekit.TimeSeriesMetric",(()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"samples",kind:"message",T:Ge,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}])),Ge=Be.makeMessageType("livekit.MetricSample",(()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Ke},{no:3,name:"value",kind:"scalar",T:2}])),ze=Be.makeMessageType("livekit.EventMetric",(()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"start_timestamp_ms",kind:"scalar",T:3},{no:5,name:"end_timestamp_ms",kind:"scalar",T:3,opt:!0},{no:6,name:"normalized_start_timestamp",kind:"message",T:Ke},{no:7,name:"normalized_end_timestamp",kind:"message",T:Ke,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}])),Je=Be.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),Qe=Be.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),$e=Be.makeEnum("livekit.TrackSource",[{no:0,name:"UNKNOWN"},{no:1,name:"CAMERA"},{no:2,name:"MICROPHONE"},{no:3,name:"SCREEN_SHARE"},{no:4,name:"SCREEN_SHARE_AUDIO"}]),Ye=Be.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),Xe=Be.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),Ze=Be.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),et=Be.makeEnum("livekit.DisconnectReason",[{no:0,name:"UNKNOWN_REASON"},{no:1,name:"CLIENT_INITIATED"},{no:2,name:"DUPLICATE_IDENTITY"},{no:3,name:"SERVER_SHUTDOWN"},{no:4,name:"PARTICIPANT_REMOVED"},{no:5,name:"ROOM_DELETED"},{no:6,name:"STATE_MISMATCH"},{no:7,name:"JOIN_FAILURE"},{no:8,name:"MIGRATION"},{no:9,name:"SIGNAL_CLOSE"},{no:10,name:"ROOM_CLOSED"},{no:11,name:"USER_UNAVAILABLE"},{no:12,name:"USER_REJECTED"},{no:13,name:"SIP_TRUNK_FAILURE"},{no:14,name:"CONNECTION_TIMEOUT"},{no:15,name:"MEDIA_FAILURE"}]),tt=Be.makeEnum("livekit.ReconnectReason",[{no:0,name:"RR_UNKNOWN"},{no:1,name:"RR_SIGNAL_DISCONNECTED"},{no:2,name:"RR_PUBLISHER_FAILED"},{no:3,name:"RR_SUBSCRIBER_FAILED"},{no:4,name:"RR_SWITCH_CANDIDATE"}]),it=Be.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),nt=Be.makeEnum("livekit.AudioTrackFeature",[{no:0,name:"TF_STEREO"},{no:1,name:"TF_NO_DTX"},{no:2,name:"TF_AUTO_GAIN_CONTROL"},{no:3,name:"TF_ECHO_CANCELLATION"},{no:4,name:"TF_NOISE_SUPPRESSION"},{no:5,name:"TF_ENHANCED_NOISE_CANCELLATION"},{no:6,name:"TF_PRECONNECT_BUFFER"}]),st=Be.makeMessageType("livekit.Room",(()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"empty_timeout",kind:"scalar",T:13},{no:14,name:"departure_timeout",kind:"scalar",T:13},{no:4,name:"max_participants",kind:"scalar",T:13},{no:5,name:"creation_time",kind:"scalar",T:3},{no:15,name:"creation_time_ms",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:ot,repeated:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"num_participants",kind:"scalar",T:13},{no:11,name:"num_publishers",kind:"scalar",T:13},{no:10,name:"active_recording",kind:"scalar",T:8},{no:13,name:"version",kind:"message",T:Vt}])),ot=Be.makeMessageType("livekit.Codec",(()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}])),rt=Be.makeMessageType("livekit.ParticipantPermission",(()=>[{no:1,name:"can_subscribe",kind:"scalar",T:8},{no:2,name:"can_publish",kind:"scalar",T:8},{no:3,name:"can_publish_data",kind:"scalar",T:8},{no:9,name:"can_publish_sources",kind:"enum",T:Be.getEnumType($e),repeated:!0},{no:7,name:"hidden",kind:"scalar",T:8},{no:8,name:"recorder",kind:"scalar",T:8},{no:10,name:"can_update_metadata",kind:"scalar",T:8},{no:11,name:"agent",kind:"scalar",T:8},{no:12,name:"can_subscribe_metrics",kind:"scalar",T:8}])),at=Be.makeMessageType("livekit.ParticipantInfo",(()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:Be.getEnumType(ct)},{no:4,name:"tracks",kind:"message",T:pt,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:17,name:"joined_at_ms",kind:"scalar",T:3},{no:9,name:"name",kind:"scalar",T:9},{no:10,name:"version",kind:"scalar",T:13},{no:11,name:"permission",kind:"message",T:rt},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:Be.getEnumType(dt)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:Be.getEnumType(et)},{no:18,name:"kind_details",kind:"enum",T:Be.getEnumType(lt),repeated:!0},{no:19,name:"data_tracks",kind:"message",T:mt,repeated:!0}])),ct=Be.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),dt=Be.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"},{no:7,name:"CONNECTOR"},{no:8,name:"BRIDGE"}]),lt=Be.makeEnum("livekit.ParticipantInfo.KindDetail",[{no:0,name:"CLOUD_AGENT"},{no:1,name:"FORWARDED"},{no:2,name:"CONNECTOR_WHATSAPP"},{no:3,name:"CONNECTOR_TWILIO"},{