centrifuge
Version:
JavaScript client SDK for bidirectional communication with Centrifugo and Centrifuge-based server from browser, NodeJS and React Native
32 lines • 224 kB
JavaScript
"use strict";(()=>{var Mn=Object.create;var me=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var Un=Object.getOwnPropertyNames;var Nn=Object.getPrototypeOf,zn=Object.prototype.hasOwnProperty;var A=(l,o)=>()=>{try{return o||l((o={exports:{}}).exports,o),o.exports}catch(i){throw o=0,i}};var Wn=(l,o,i,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of Un(o))!zn.call(l,r)&&r!==i&&me(l,r,{get:()=>o[r],enumerable:!(e=qn(o,r))||e.enumerable});return l};var Tt=(l,o,i)=>(i=l!=null?Mn(Nn(l)):{},Wn(o||!l||!l.__esModule?me(i,"default",{value:l,enumerable:!0}):i,l));var Kt=A((yi,Jt)=>{"use strict";var dt=typeof Reflect=="object"?Reflect:null,Pe=dt&&typeof dt.apply=="function"?dt.apply:function(o,i,e){return Function.prototype.apply.call(o,i,e)},Rt;dt&&typeof dt.ownKeys=="function"?Rt=dt.ownKeys:Object.getOwnPropertySymbols?Rt=function(o){return Object.getOwnPropertyNames(o).concat(Object.getOwnPropertySymbols(o))}:Rt=function(o){return Object.getOwnPropertyNames(o)};function Gn(l){console&&console.warn&&console.warn(l)}var we=Number.isNaN||function(o){return o!==o};function T(){T.init.call(this)}Jt.exports=T;Jt.exports.once=Kn;T.EventEmitter=T;T.prototype._events=void 0;T.prototype._eventsCount=0;T.prototype._maxListeners=void 0;var Se=10;function xt(l){if(typeof l!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof l)}Object.defineProperty(T,"defaultMaxListeners",{enumerable:!0,get:function(){return Se},set:function(l){if(typeof l!="number"||l<0||we(l))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+l+".");Se=l}});T.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};T.prototype.setMaxListeners=function(o){if(typeof o!="number"||o<0||we(o))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+o+".");return this._maxListeners=o,this};function Oe(l){return l._maxListeners===void 0?T.defaultMaxListeners:l._maxListeners}T.prototype.getMaxListeners=function(){return Oe(this)};T.prototype.emit=function(o){for(var i=[],e=1;e<arguments.length;e++)i.push(arguments[e]);var r=o==="error",t=this._events;if(t!==void 0)r=r&&t.error===void 0;else if(!r)return!1;if(r){var n;if(i.length>0&&(n=i[0]),n instanceof Error)throw n;var c=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw c.context=n,c}var s=t[o];if(s===void 0)return!1;if(typeof s=="function")Pe(s,this,i);else for(var u=s.length,d=je(s,u),e=0;e<u;++e)Pe(d[e],this,i);return!0};function Te(l,o,i,e){var r,t,n;if(xt(i),t=l._events,t===void 0?(t=l._events=Object.create(null),l._eventsCount=0):(t.newListener!==void 0&&(l.emit("newListener",o,i.listener?i.listener:i),t=l._events),n=t[o]),n===void 0)n=t[o]=i,++l._eventsCount;else if(typeof n=="function"?n=t[o]=e?[i,n]:[n,i]:e?n.unshift(i):n.push(i),r=Oe(l),r>0&&n.length>r&&!n.warned){n.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+n.length+" "+String(o)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=l,c.type=o,c.count=n.length,Gn(c)}return l}T.prototype.addListener=function(o,i){return Te(this,o,i,!1)};T.prototype.on=T.prototype.addListener;T.prototype.prependListener=function(o,i){return Te(this,o,i,!0)};function Hn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Re(l,o,i){var e={fired:!1,wrapFn:void 0,target:l,type:o,listener:i},r=Hn.bind(e);return r.listener=i,e.wrapFn=r,r}T.prototype.once=function(o,i){return xt(i),this.on(o,Re(this,o,i)),this};T.prototype.prependOnceListener=function(o,i){return xt(i),this.prependListener(o,Re(this,o,i)),this};T.prototype.removeListener=function(o,i){var e,r,t,n,c;if(xt(i),r=this._events,r===void 0)return this;if(e=r[o],e===void 0)return this;if(e===i||e.listener===i)--this._eventsCount===0?this._events=Object.create(null):(delete r[o],r.removeListener&&this.emit("removeListener",o,e.listener||i));else if(typeof e!="function"){for(t=-1,n=e.length-1;n>=0;n--)if(e[n]===i||e[n].listener===i){c=e[n].listener,t=n;break}if(t<0)return this;t===0?e.shift():Vn(e,t),e.length===1&&(r[o]=e[0]),r.removeListener!==void 0&&this.emit("removeListener",o,c||i)}return this};T.prototype.off=T.prototype.removeListener;T.prototype.removeAllListeners=function(o){var i,e,r;if(e=this._events,e===void 0)return this;if(e.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):e[o]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete e[o]),this;if(arguments.length===0){var t=Object.keys(e),n;for(r=0;r<t.length;++r)n=t[r],n!=="removeListener"&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(i=e[o],typeof i=="function")this.removeListener(o,i);else if(i!==void 0)for(r=i.length-1;r>=0;r--)this.removeListener(o,i[r]);return this};function xe(l,o,i){var e=l._events;if(e===void 0)return[];var r=e[o];return r===void 0?[]:typeof r=="function"?i?[r.listener||r]:[r]:i?Jn(r):je(r,r.length)}T.prototype.listeners=function(o){return xe(this,o,!0)};T.prototype.rawListeners=function(o){return xe(this,o,!1)};T.listenerCount=function(l,o){return typeof l.listenerCount=="function"?l.listenerCount(o):Ee.call(l,o)};T.prototype.listenerCount=Ee;function Ee(l){var o=this._events;if(o!==void 0){var i=o[l];if(typeof i=="function")return 1;if(i!==void 0)return i.length}return 0}T.prototype.eventNames=function(){return this._eventsCount>0?Rt(this._events):[]};function je(l,o){for(var i=new Array(o),e=0;e<o;++e)i[e]=l[e];return i}function Vn(l,o){for(;o+1<l.length;o++)l[o]=l[o+1];l.pop()}function Jn(l){for(var o=new Array(l.length),i=0;i<o.length;++i)o[i]=l[i].listener||l[i];return o}function Kn(l,o){return new Promise(function(i,e){function r(n){l.removeListener(o,t),e(n)}function t(){typeof l.removeListener=="function"&&l.removeListener("error",r),i([].slice.call(arguments))}De(l,o,t,{once:!0}),o!=="error"&&Zn(l,r,{once:!0})})}function Zn(l,o,i){typeof l.on=="function"&&De(l,"error",o,i)}function De(l,o,i,e){if(typeof l.on=="function")e.once?l.once(o,i):l.on(o,i);else if(typeof l.addEventListener=="function")l.addEventListener(o,function r(t){e.once&&l.removeEventListener(o,r),i(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof l)}});var qe=A((Ar,Me)=>{"use strict";Me.exports=ri;function ri(l,o){for(var i=new Array(arguments.length-1),e=0,r=2,t=!0;r<arguments.length;)i[e++]=arguments[r++];return new Promise(function(c,s){i[e]=function(d){if(t)if(t=!1,d)s(d);else{for(var y=new Array(arguments.length-1),g=0;g<y.length;)y[g++]=arguments[g];c.apply(null,y)}};try{l.apply(o||null,i)}catch(u){t&&(t=!1,s(u))}})}});var We=A(ze=>{"use strict";var qt=ze;qt.length=function(o){var i=o.length;if(!i)return 0;for(var e=0;--i%4>1&&o.charAt(i)==="=";)++e;return Math.ceil(o.length*3)/4-e};var gt=new Array(64),Ne=new Array(123);for(Y=0;Y<64;)Ne[gt[Y]=Y<26?Y+65:Y<52?Y+71:Y<62?Y-4:Y-59|43]=Y++;var Y;qt.encode=function(o,i,e){for(var r=null,t=[],n=0,c=0,s;i<e;){var u=o[i++];switch(c){case 0:t[n++]=gt[u>>2],s=(u&3)<<4,c=1;break;case 1:t[n++]=gt[s|u>>4],s=(u&15)<<2,c=2;break;case 2:t[n++]=gt[s|u>>6],t[n++]=gt[u&63],c=0;break}n>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,t)),n=0)}return c&&(t[n++]=gt[s],t[n++]=61,c===1&&(t[n++]=61)),r?(n&&r.push(String.fromCharCode.apply(String,t.slice(0,n))),r.join("")):String.fromCharCode.apply(String,t.slice(0,n))};var Ue="invalid encoding";qt.decode=function(o,i,e){for(var r=e,t=0,n,c=0;c<o.length;){var s=o.charCodeAt(c++);if(s===61&&t>1)break;if((s=Ne[s])===void 0)throw Error(Ue);switch(t){case 0:n=s,t=1;break;case 1:i[e++]=n<<2|(s&48)>>4,n=s,t=2;break;case 2:i[e++]=(n&15)<<4|(s&60)>>2,n=s,t=3;break;case 3:i[e++]=(n&3)<<6|s,t=0;break}}if(t===1)throw Error(Ue);return e-r};qt.test=function(o){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(o)}});var He=A((Mr,Ge)=>{"use strict";Ge.exports=Ut;function Ut(){this._listeners=Object.create(null)}Ut.prototype.on=function(o,i,e){return(this._listeners[o]||(this._listeners[o]=[])).push({fn:i,ctx:e||this}),this};Ut.prototype.off=function(o,i){if(o===void 0)this._listeners=Object.create(null);else if(i===void 0)this._listeners[o]=[];else{var e=this._listeners[o];if(!e)return this;for(var r=0;r<e.length;)e[r].fn===i?e.splice(r,1):++r}return this};Ut.prototype.emit=function(o){var i=this._listeners[o];if(i){for(var e=[],r=1;r<arguments.length;)e.push(arguments[r++]);for(r=0;r<i.length;)i[r].fn.apply(i[r++].ctx,e)}return this}});var Qe=A((qr,Xe)=>{"use strict";Xe.exports=Ve(Ve);function Ve(l){return typeof Float32Array<"u"?(function(){var o=new Float32Array([-0]),i=new Uint8Array(o.buffer),e=i[3]===128;function r(s,u,d){o[0]=s,u[d]=i[0],u[d+1]=i[1],u[d+2]=i[2],u[d+3]=i[3]}function t(s,u,d){o[0]=s,u[d]=i[3],u[d+1]=i[2],u[d+2]=i[1],u[d+3]=i[0]}l.writeFloatLE=e?r:t,l.writeFloatBE=e?t:r;function n(s,u){return i[0]=s[u],i[1]=s[u+1],i[2]=s[u+2],i[3]=s[u+3],o[0]}function c(s,u){return i[3]=s[u],i[2]=s[u+1],i[1]=s[u+2],i[0]=s[u+3],o[0]}l.readFloatLE=e?n:c,l.readFloatBE=e?c:n})():(function(){function o(e,r,t,n){var c=r<0?1:0;if(c&&(r=-r),r===0)e(1/r>0?0:2147483648,t,n);else if(isNaN(r))e(2143289344,t,n);else if(r>34028234663852886e22)e((c<<31|2139095040)>>>0,t,n);else if(r<11754943508222875e-54)e((c<<31|Math.round(r/1401298464324817e-60))>>>0,t,n);else{var s=Math.floor(Math.log(r)/Math.LN2),u=Math.round(r*Math.pow(2,-s)*8388608)&8388607;e((c<<31|s+127<<23|u)>>>0,t,n)}}l.writeFloatLE=o.bind(null,Je),l.writeFloatBE=o.bind(null,Ke);function i(e,r,t){var n=e(r,t),c=(n>>31)*2+1,s=n>>>23&255,u=n&8388607;return s===255?u?NaN:c*(1/0):s===0?c*1401298464324817e-60*u:c*Math.pow(2,s-150)*(u+8388608)}l.readFloatLE=i.bind(null,Ze),l.readFloatBE=i.bind(null,$e)})(),typeof Float64Array<"u"?(function(){var o=new Float64Array([-0]),i=new Uint8Array(o.buffer),e=i[7]===128;function r(s,u,d){o[0]=s,u[d]=i[0],u[d+1]=i[1],u[d+2]=i[2],u[d+3]=i[3],u[d+4]=i[4],u[d+5]=i[5],u[d+6]=i[6],u[d+7]=i[7]}function t(s,u,d){o[0]=s,u[d]=i[7],u[d+1]=i[6],u[d+2]=i[5],u[d+3]=i[4],u[d+4]=i[3],u[d+5]=i[2],u[d+6]=i[1],u[d+7]=i[0]}l.writeDoubleLE=e?r:t,l.writeDoubleBE=e?t:r;function n(s,u){return i[0]=s[u],i[1]=s[u+1],i[2]=s[u+2],i[3]=s[u+3],i[4]=s[u+4],i[5]=s[u+5],i[6]=s[u+6],i[7]=s[u+7],o[0]}function c(s,u){return i[7]=s[u],i[6]=s[u+1],i[5]=s[u+2],i[4]=s[u+3],i[3]=s[u+4],i[2]=s[u+5],i[1]=s[u+6],i[0]=s[u+7],o[0]}l.readDoubleLE=e?n:c,l.readDoubleBE=e?c:n})():(function(){function o(e,r,t,n,c,s){var u=n<0?1:0;if(u&&(n=-n),n===0)e(0,c,s+r),e(1/n>0?0:2147483648,c,s+t);else if(isNaN(n))e(0,c,s+r),e(2146959360,c,s+t);else if(n>17976931348623157e292)e(0,c,s+r),e((u<<31|2146435072)>>>0,c,s+t);else{var d;if(n<22250738585072014e-324)d=n/5e-324,e(d>>>0,c,s+r),e((u<<31|d/4294967296)>>>0,c,s+t);else{var y=Math.floor(Math.log(n)/Math.LN2);y===1024&&(y=1023),d=n*Math.pow(2,-y),e(d*4503599627370496>>>0,c,s+r),e((u<<31|y+1023<<20|d*1048576&1048575)>>>0,c,s+t)}}}l.writeDoubleLE=o.bind(null,Je,0,4),l.writeDoubleBE=o.bind(null,Ke,4,0);function i(e,r,t,n,c){var s=e(n,c+r),u=e(n,c+t),d=(u>>31)*2+1,y=u>>>20&2047,g=4294967296*(u&1048575)+s;return y===2047?g?NaN:d*(1/0):y===0?d*5e-324*g:d*Math.pow(2,y-1075)*(g+4503599627370496)}l.readDoubleLE=i.bind(null,Ze,0,4),l.readDoubleBE=i.bind(null,$e,4,0)})(),l}function Je(l,o,i){o[i]=l&255,o[i+1]=l>>>8&255,o[i+2]=l>>>16&255,o[i+3]=l>>>24}function Ke(l,o,i){o[i]=l>>>24,o[i+1]=l>>>16&255,o[i+2]=l>>>8&255,o[i+3]=l&255}function Ze(l,o){return(l[o]|l[o+1]<<8|l[o+2]<<16|l[o+3]<<24)>>>0}function $e(l,o){return(l[o]<<24|l[o+1]<<16|l[o+2]<<8|l[o+3])>>>0}});var tn=A(Ye=>{"use strict";var ne=Ye,ee=65533;ne.length=function(o){for(var i=0,e=0,r=0;r<o.length;++r)e=o.charCodeAt(r),e<128?i+=1:e<2048?i+=2:(e&64512)===55296&&(o.charCodeAt(r+1)&64512)===56320?(++r,i+=4):i+=3;return i};ne.read=function(o,i,e){if(e-i<1)return"";for(var r=null,t=[],n=0,c,s,u,d;i<e;)c=o[i++],c<=127?t[n++]=c:c>=192&&c<224?(u=(c&31)<<6|o[i++]&63,t[n++]=u>=128?u:ee):c>=224&&c<240?(d=(c&15)<<12|(o[i++]&63)<<6|o[i++]&63,t[n++]=d>=2048?d:ee):c>=240&&(s=(c&7)<<18|(o[i++]&63)<<12|(o[i++]&63)<<6|o[i++]&63,s<65536||s>1114111?t[n++]=ee:(s-=65536,t[n++]=55296+(s>>10),t[n++]=56320+(s&1023))),n>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,t.slice(0,n))),n=0);return r?(n&&r.push(String.fromCharCode.apply(String,t.slice(0,n))),r.join("")):String.fromCharCode.apply(String,t.slice(0,n))};ne.write=function(o,i,e){for(var r=e,t,n,c=0;c<o.length;++c)t=o.charCodeAt(c),t<128?i[e++]=t:t<2048?(i[e++]=t>>6|192,i[e++]=t&63|128):(t&64512)===55296&&((n=o.charCodeAt(c+1))&64512)===56320?(t=65536+((t&1023)<<10)+(n&1023),++c,i[e++]=t>>18|240,i[e++]=t>>12&63|128,i[e++]=t>>6&63|128,i[e++]=t&63|128):(i[e++]=t>>12|224,i[e++]=t>>6&63|128,i[e++]=t&63|128);return e-r}});var nn=A((Nr,en)=>{"use strict";en.exports=oi;function oi(l,o,i){var e=i||8192,r=e>>>1,t=null,n=e;return function(s){if(s<1||s>r)return l(s);n+s>e&&(t=l(e),n=0);var u=o.call(t,n,n+=s);return n&7&&(n=(n|7)+1),u}}});var on=A((zr,rn)=>{"use strict";rn.exports=M;var mt=st();function M(l,o){this.lo=l>>>0,this.hi=o>>>0}var ht=M.zero=new M(0,0);ht.toNumber=function(){return 0};ht.zzEncode=ht.zzDecode=function(){return this};ht.length=function(){return 1};var si=M.zeroHash="\0\0\0\0\0\0\0\0";M.fromNumber=function(o){if(o===0)return ht;var i=o<0;i&&(o=-o);var e=o>>>0,r=(o-e)/4294967296>>>0;return i&&(r=~r>>>0,e=~e>>>0,++e>4294967295&&(e=0,++r>4294967295&&(r=0))),new M(e,r)};M.from=function(o){if(typeof o=="number")return M.fromNumber(o);if(mt.isString(o))if(mt.Long)o=mt.Long.fromString(o);else return M.fromNumber(parseInt(o,10));return o.low||o.high?new M(o.low>>>0,o.high>>>0):ht};M.prototype.toNumber=function(o){if(!o&&this.hi>>>31){var i=~this.lo+1>>>0,e=~this.hi>>>0;return i||(e=e+1>>>0),-(i+e*4294967296)}return this.lo+this.hi*4294967296};M.prototype.toLong=function(o){return mt.Long?new mt.Long(this.lo|0,this.hi|0,!!o):{low:this.lo|0,high:this.hi|0,unsigned:!!o}};var ot=String.prototype.charCodeAt;M.fromHash=function(o){return o===si?ht:new M((ot.call(o,0)|ot.call(o,1)<<8|ot.call(o,2)<<16|ot.call(o,3)<<24)>>>0,(ot.call(o,4)|ot.call(o,5)<<8|ot.call(o,6)<<16|ot.call(o,7)<<24)>>>0)};M.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};M.prototype.zzEncode=function(){var o=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^o)>>>0,this.lo=(this.lo<<1^o)>>>0,this};M.prototype.zzDecode=function(){var o=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^o)>>>0,this.hi=(this.hi>>>1^o)>>>0,this};M.prototype.length=function(){var o=this.lo,i=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return e===0?i===0?o<16384?o<128?1:2:o<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:e<128?9:10}});var sn=A((Pt,ie)=>{(function(l,o){function i(e){return e.default||e}typeof define=="function"&&define.amd?define([],function(){var e={};return o(e),i(e)}):typeof Pt=="object"?(o(Pt),typeof ie=="object"&&(ie.exports=i(Pt))):(function(){var e={};o(e),l.Long=i(e)})()})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:Pt,function(l){"use strict";Object.defineProperty(l,"__esModule",{value:!0}),l.default=void 0;var o=null;try{o=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function i(b,a,v){this.low=b|0,this.high=a|0,this.unsigned=!!v}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0});function e(b){return(b&&b.__isLong__)===!0}function r(b){var a=Math.clz32(b&-b);return b?31-a:a}i.isLong=e;var t={},n={};function c(b,a){var v,w,j;return a?(b>>>=0,(j=0<=b&&b<256)&&(w=n[b],w)?w:(v=u(b,0,!0),j&&(n[b]=v),v)):(b|=0,(j=-128<=b&&b<128)&&(w=t[b],w)?w:(v=u(b,b<0?-1:0,!1),j&&(t[b]=v),v))}i.fromInt=c;function s(b,a){if(isNaN(b))return a?V:x;if(a){if(b<0)return V;if(b>=Q)return ke}else{if(b<=-C)return N;if(b+1>=C)return ve}return b<0?s(-b,a).neg():u(b%R|0,b/R|0,a)}i.fromNumber=s;function u(b,a,v){return new i(b,a,v)}i.fromBits=u;var d=Math.pow;function y(b,a,v){if(b.length===0)throw Error("empty string");if(typeof a=="number"?(v=a,a=!1):a=!!a,b==="NaN"||b==="Infinity"||b==="+Infinity"||b==="-Infinity")return a?V:x;if(v=v||10,v<2||36<v)throw RangeError("radix");var w;if((w=b.indexOf("-"))>0)throw Error("interior hyphen");if(w===0)return y(b.substring(1),a,v).neg();for(var j=s(d(v,8)),E=x,F=0;F<b.length;F+=8){var z=Math.min(8,b.length-F),J=parseInt(b.substring(F,F+z),v);if(z<8){var U=s(d(v,z));E=E.mul(U).add(s(J))}else E=E.mul(j),E=E.add(s(J))}return E.unsigned=a,E}i.fromString=y;function g(b,a){return typeof b=="number"?s(b,a):typeof b=="string"?y(b,a):u(b.low,b.high,typeof a=="boolean"?a:b.unsigned)}i.fromValue=g;var k=65536,P=1<<24,R=k*k,Q=R*R,C=Q/2,q=c(P),x=c(0);i.ZERO=x;var V=c(0,!0);i.UZERO=V;var tt=c(1);i.ONE=tt;var ge=c(1,!0);i.UONE=ge;var Vt=c(-1);i.NEG_ONE=Vt;var ve=u(-1,2147483647,!1);i.MAX_VALUE=ve;var ke=u(-1,-1,!0);i.MAX_UNSIGNED_VALUE=ke;var N=u(0,-2147483648,!1);i.MIN_VALUE=N;var _=i.prototype;_.toInt=function(){return this.unsigned?this.low>>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*R+(this.low>>>0):this.high*R+(this.low>>>0)},_.toString=function(a){if(a=a||10,a<2||36<a)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(N)){var v=s(a),w=this.div(v),j=w.mul(v).sub(this);return w.toString(a)+j.toInt().toString(a)}else return"-"+this.neg().toString(a);for(var E=s(d(a,6),this.unsigned),F=this,z="";;){var J=F.div(E),U=F.sub(J.mul(E)).toInt()>>>0,L=U.toString(a);if(F=J,F.isZero())return L+z;for(;L.length<6;)L="0"+L;z=""+L+z}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(N)?64:this.neg().getNumBitsAbs();for(var a=this.high!=0?this.high:this.low,v=31;v>0&&(a&1<<v)==0;v--);return this.high!=0?v+33:v+1},_.isSafeInteger=function(){var a=this.high>>21;return a?this.unsigned?!1:a===-1&&!(this.low===0&&this.high===-2097152):!0},_.isZero=function(){return this.high===0&&this.low===0},_.eqz=_.isZero,_.isNegative=function(){return!this.unsigned&&this.high<0},_.isPositive=function(){return this.unsigned||this.high>=0},_.isOdd=function(){return(this.low&1)===1},_.isEven=function(){return(this.low&1)===0},_.equals=function(a){return e(a)||(a=g(a)),this.unsigned!==a.unsigned&&this.high>>>31===1&&a.high>>>31===1?!1:this.high===a.high&&this.low===a.low},_.eq=_.equals,_.notEquals=function(a){return!this.eq(a)},_.neq=_.notEquals,_.ne=_.notEquals,_.lessThan=function(a){return this.comp(a)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(a){return this.comp(a)<=0},_.lte=_.lessThanOrEqual,_.le=_.lessThanOrEqual,_.greaterThan=function(a){return this.comp(a)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(a){return this.comp(a)>=0},_.gte=_.greaterThanOrEqual,_.ge=_.greaterThanOrEqual,_.compare=function(a){if(e(a)||(a=g(a)),this.eq(a))return 0;var v=this.isNegative(),w=a.isNegative();return v&&!w?-1:!v&&w?1:this.unsigned?a.high>>>0>this.high>>>0||a.high===this.high&&a.low>>>0>this.low>>>0?-1:1:this.sub(a).isNegative()?-1:1},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(N)?N:this.not().add(tt)},_.neg=_.negate,_.add=function(a){e(a)||(a=g(a));var v=this.high>>>16,w=this.high&65535,j=this.low>>>16,E=this.low&65535,F=a.high>>>16,z=a.high&65535,J=a.low>>>16,U=a.low&65535,L=0,K=0,B=0,H=0;return H+=E+U,B+=H>>>16,H&=65535,B+=j+J,K+=B>>>16,B&=65535,K+=w+z,L+=K>>>16,K&=65535,L+=v+F,L&=65535,u(B<<16|H,L<<16|K,this.unsigned)},_.subtract=function(a){return e(a)||(a=g(a)),this.add(a.neg())},_.sub=_.subtract,_.multiply=function(a){if(this.isZero())return this;if(e(a)||(a=g(a)),o){var v=o.mul(this.low,this.high,a.low,a.high);return u(v,o.get_high(),this.unsigned)}if(a.isZero())return this.unsigned?V:x;if(this.eq(N))return a.isOdd()?N:x;if(a.eq(N))return this.isOdd()?N:x;if(this.isNegative())return a.isNegative()?this.neg().mul(a.neg()):this.neg().mul(a).neg();if(a.isNegative())return this.mul(a.neg()).neg();if(this.lt(q)&&a.lt(q))return s(this.toNumber()*a.toNumber(),this.unsigned);var w=this.high>>>16,j=this.high&65535,E=this.low>>>16,F=this.low&65535,z=a.high>>>16,J=a.high&65535,U=a.low>>>16,L=a.low&65535,K=0,B=0,H=0,Ot=0;return Ot+=F*L,H+=Ot>>>16,Ot&=65535,H+=E*L,B+=H>>>16,H&=65535,H+=F*U,B+=H>>>16,H&=65535,B+=j*L,K+=B>>>16,B&=65535,B+=E*U,K+=B>>>16,B&=65535,B+=F*J,K+=B>>>16,B&=65535,K+=w*L+j*U+E*J+F*z,K&=65535,u(H<<16|Ot,K<<16|B,this.unsigned)},_.mul=_.multiply,_.divide=function(a){if(e(a)||(a=g(a)),a.isZero())throw Error("division by zero");if(o){if(!this.unsigned&&this.high===-2147483648&&a.low===-1&&a.high===-1)return this;var v=(this.unsigned?o.div_u:o.div_s)(this.low,this.high,a.low,a.high);return u(v,o.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?V:x;var w,j,E;if(this.unsigned){if(a.unsigned||(a=a.toUnsigned()),a.gt(this))return V;if(a.gt(this.shru(1)))return ge;E=V}else{if(this.eq(N)){if(a.eq(tt)||a.eq(Vt))return N;if(a.eq(N))return tt;var F=this.shr(1);return w=F.div(a).shl(1),w.eq(x)?a.isNegative()?tt:Vt:(j=this.sub(a.mul(w)),E=w.add(j.div(a)),E)}else if(a.eq(N))return this.unsigned?V:x;if(this.isNegative())return a.isNegative()?this.neg().div(a.neg()):this.neg().div(a).neg();if(a.isNegative())return this.div(a.neg()).neg();E=x}for(j=this;j.gte(a);){w=Math.max(1,Math.floor(j.toNumber()/a.toNumber()));for(var z=Math.ceil(Math.log(w)/Math.LN2),J=z<=48?1:d(2,z-48),U=s(w),L=U.mul(a);L.isNegative()||L.gt(j);)w-=J,U=s(w,this.unsigned),L=U.mul(a);U.isZero()&&(U=tt),E=E.add(U),j=j.sub(L)}return E},_.div=_.divide,_.modulo=function(a){if(e(a)||(a=g(a)),o){var v=(this.unsigned?o.rem_u:o.rem_s)(this.low,this.high,a.low,a.high);return u(v,o.get_high(),this.unsigned)}return this.sub(this.div(a).mul(a))},_.mod=_.modulo,_.rem=_.modulo,_.not=function(){return u(~this.low,~this.high,this.unsigned)},_.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},_.clz=_.countLeadingZeros,_.countTrailingZeros=function(){return this.low?r(this.low):r(this.high)+32},_.ctz=_.countTrailingZeros,_.and=function(a){return e(a)||(a=g(a)),u(this.low&a.low,this.high&a.high,this.unsigned)},_.or=function(a){return e(a)||(a=g(a)),u(this.low|a.low,this.high|a.high,this.unsigned)},_.xor=function(a){return e(a)||(a=g(a)),u(this.low^a.low,this.high^a.high,this.unsigned)},_.shiftLeft=function(a){return e(a)&&(a=a.toInt()),(a&=63)===0?this:a<32?u(this.low<<a,this.high<<a|this.low>>>32-a,this.unsigned):u(0,this.low<<a-32,this.unsigned)},_.shl=_.shiftLeft,_.shiftRight=function(a){return e(a)&&(a=a.toInt()),(a&=63)===0?this:a<32?u(this.low>>>a|this.high<<32-a,this.high>>a,this.unsigned):u(this.high>>a-32,this.high>=0?0:-1,this.unsigned)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(a){return e(a)&&(a=a.toInt()),(a&=63)===0?this:a<32?u(this.low>>>a|this.high<<32-a,this.high>>>a,this.unsigned):a===32?u(this.high,0,this.unsigned):u(this.high>>>a-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.shr_u=_.shiftRightUnsigned,_.rotateLeft=function(a){var v;return e(a)&&(a=a.toInt()),(a&=63)===0?this:a===32?u(this.high,this.low,this.unsigned):a<32?(v=32-a,u(this.low<<a|this.high>>>v,this.high<<a|this.low>>>v,this.unsigned)):(a-=32,v=32-a,u(this.high<<a|this.low>>>v,this.low<<a|this.high>>>v,this.unsigned))},_.rotl=_.rotateLeft,_.rotateRight=function(a){var v;return e(a)&&(a=a.toInt()),(a&=63)===0?this:a===32?u(this.high,this.low,this.unsigned):a<32?(v=32-a,u(this.high<<v|this.low>>>a,this.low<<v|this.high>>>a,this.unsigned)):(a-=32,v=32-a,u(this.low<<v|this.high>>>a,this.high<<v|this.low>>>a,this.unsigned))},_.rotr=_.rotateRight,_.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},_.toBytes=function(a){return a?this.toBytesLE():this.toBytesBE()},_.toBytesLE=function(){var a=this.high,v=this.low;return[v&255,v>>>8&255,v>>>16&255,v>>>24,a&255,a>>>8&255,a>>>16&255,a>>>24]},_.toBytesBE=function(){var a=this.high,v=this.low;return[a>>>24,a>>>16&255,a>>>8&255,a&255,v>>>24,v>>>16&255,v>>>8&255,v&255]},i.fromBytes=function(a,v,w){return w?i.fromBytesLE(a,v):i.fromBytesBE(a,v)},i.fromBytesLE=function(a,v){return new i(a[0]|a[1]<<8|a[2]<<16|a[3]<<24,a[4]|a[5]<<8|a[6]<<16|a[7]<<24,v)},i.fromBytesBE=function(a,v){return new i(a[4]<<24|a[5]<<16|a[6]<<8|a[7],a[0]<<24|a[1]<<16|a[2]<<8|a[3],v)},typeof BigInt=="function"&&(i.fromBigInt=function(a,v){var w=Number(BigInt.asIntN(32,a)),j=Number(BigInt.asIntN(32,a>>BigInt(32)));return u(w,j,v)},i.fromValue=function(a,v){return typeof a=="bigint"?i.fromBigInt(a,v):g(a,v)},_.toBigInt=function(){var a=BigInt(this.low>>>0),v=BigInt(this.unsigned?this.high>>>0:this.high);return v<<BigInt(32)|a});var bi=l.default=i})});var st=A(re=>{"use strict";var m=re;m.asPromise=qe();m.base64=We();m.EventEmitter=He();m.float=Qe();m.utf8=tn();m.pool=nn();m.LongBits=on();function cn(l){return l==="__proto__"||l==="prototype"||l==="constructor"}m.isUnsafeProperty=cn;m.isNode=!!(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node);m.global=m.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||re;m.emptyArray=Object.freeze?Object.freeze([]):[];m.emptyObject=Object.freeze?Object.freeze({}):{};m.isInteger=Number.isInteger||function(o){return typeof o=="number"&&isFinite(o)&&Math.floor(o)===o};m.isString=function(o){return typeof o=="string"||o instanceof String};m.isObject=function(o){return o&&typeof o=="object"};m.isset=m.isSet=function(o,i){var e=o[i];return e!=null&&Object.hasOwnProperty.call(o,i)?typeof e!="object"||(Array.isArray(e)?e.length:Object.keys(e).length)>0:!1};m.Buffer=(function(){try{var l=m.global.Buffer;return l.prototype.utf8Write?l:null}catch{return null}})();m._Buffer_from=null;m._Buffer_allocUnsafe=null;m.newBuffer=function(o){return typeof o=="number"?m.Buffer?m._Buffer_allocUnsafe(o):new m.Array(o):m.Buffer?m._Buffer_from(o):typeof Uint8Array>"u"?o:new Uint8Array(o)};m.Array=typeof Uint8Array<"u"?Uint8Array:Array;m.Long=m.global.dcodeIO&&m.global.dcodeIO.Long||m.global.Long||(function(){try{var l=sn();return l&&l.isLong?l:null}catch{return null}})();m.key2Re=/^true|false|0|1$/;m.key32Re=/^-?(?:0|[1-9][0-9]*)$/;m.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;m.longToHash=function(o){return o?m.LongBits.from(o).toHash():m.LongBits.zeroHash};m.longFromHash=function(o,i){var e=m.LongBits.fromHash(o);return m.Long?m.Long.fromBits(e.lo,e.hi,i):e.toNumber(!!i)};function ln(l){var o=typeof arguments[arguments.length-1]=="boolean",i=o?arguments.length-1:arguments.length;o=o&&arguments[arguments.length-1];for(var e=1;e<i;++e){var r=arguments[e];if(r)for(var t=Object.keys(r),n=0;n<t.length;++n)!cn(t[n])&&(l[t[n]]===void 0||!o)&&(l[t[n]]=r[t[n]])}return l}m.merge=ln;m.nestingLimit=32;m.recursionLimit=100;m.makeProp=function(o,i){Object.defineProperty(o,i,{enumerable:!0,configurable:!0,writable:!0})};m.lcFirst=function(o){return o.charAt(0).toLowerCase()+o.substring(1)};function un(l){function o(i,e){if(!(this instanceof o))return new o(i,e);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),e&&ln(this,e)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return l},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}m.newError=un;m.ProtocolError=un("ProtocolError");m.oneOfGetter=function(o){for(var i={},e=0;e<o.length;++e)i[o[e]]=1;return function(){for(var r=Object.keys(this),t=r.length-1;t>-1;--t)if(i[r[t]]===1&&this[r[t]]!==void 0&&this[r[t]]!==null)return r[t]}};m.oneOfSetter=function(o){return function(i){for(var e=0;e<o.length;++e)o[e]!==i&&delete this[o[e]]}};m.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};m._configure=function(){var l=m.Buffer;if(!l){m._Buffer_from=m._Buffer_allocUnsafe=null;return}m._Buffer_from=l.from!==Uint8Array.from&&l.from||function(i,e){return new l(i,e)},m._Buffer_allocUnsafe=l.allocUnsafe||function(i){return new l(i)}}});var fe=A((Gr,pn)=>{"use strict";pn.exports=O;var $=st(),oe,Nt=$.LongBits,an=$.base64,fn=$.utf8;function St(l,o,i){this.fn=l,this.len=o,this.next=void 0,this.val=i}function ce(){}function ci(l){this.head=l.head,this.tail=l.tail,this.len=l.len,this.next=l.states}function O(){this.len=0,this.head=new St(ce,0,0),this.tail=this.head,this.states=null}var hn=function(){return $.Buffer?function(){return(O.create=function(){return new oe})()}:function(){return new O}};O.create=hn();O.alloc=function(o){return new $.Array(o)};$.Array!==Array&&(O.alloc=$.pool(O.alloc,$.Array.prototype.subarray));O.prototype._push=function(o,i,e){return this.tail=this.tail.next=new St(o,i,e),this.len+=i,this};function le(l,o,i){o[i]=l&255}function li(l,o,i){for(;l>127;)o[i++]=l&127|128,l>>>=7;o[i]=l}function ue(l,o){this.len=l,this.next=void 0,this.val=o}ue.prototype=Object.create(St.prototype);ue.prototype.fn=li;O.prototype.uint32=function(o){return this.len+=(this.tail=this.tail.next=new ue((o=o>>>0)<128?1:o<16384?2:o<2097152?3:o<268435456?4:5,o)).len,this};O.prototype.int32=function(o){return(o|=0)<0?this._push(ae,10,Nt.fromNumber(o)):this.uint32(o)};O.prototype.sint32=function(o){return this.uint32((o<<1^o>>31)>>>0)};function ae(l,o,i){for(var e=l.lo,r=l.hi;r;)o[i++]=e&127|128,e=(e>>>7|r<<25)>>>0,r>>>=7;for(;e>127;)o[i++]=e&127|128,e=e>>>7;o[i++]=e}O.prototype.uint64=function(o){var i=Nt.from(o);return this._push(ae,i.length(),i)};O.prototype.int64=O.prototype.uint64;O.prototype.sint64=function(o){var i=Nt.from(o).zzEncode();return this._push(ae,i.length(),i)};O.prototype.bool=function(o){return this._push(le,1,o?1:0)};function se(l,o,i){o[i]=l&255,o[i+1]=l>>>8&255,o[i+2]=l>>>16&255,o[i+3]=l>>>24}O.prototype.fixed32=function(o){return this._push(se,4,o>>>0)};O.prototype.sfixed32=O.prototype.fixed32;O.prototype.fixed64=function(o){var i=Nt.from(o);return this._push(se,4,i.lo)._push(se,4,i.hi)};O.prototype.sfixed64=O.prototype.fixed64;O.prototype.float=function(o){return this._push($.float.writeFloatLE,4,o)};O.prototype.double=function(o){return this._push($.float.writeDoubleLE,8,o)};var ui=$.Array.prototype.set?function(o,i,e){i.set(o,e)}:function(o,i,e){for(var r=0;r<o.length;++r)i[e+r]=o[r]};O.prototype.bytes=function(o){var i=o.length>>>0;if(!i)return this._push(le,1,0);if($.isString(o)){var e=O.alloc(i=an.length(o));an.decode(o,e,0),o=e}return this.uint32(i)._push(ui,i,o)};O.prototype.string=function(o){var i=fn.length(o);return i?this.uint32(i)._push(fn.write,i,o):this._push(le,1,0)};O.prototype.fork=function(){return this.states=new ci(this),this.head=this.tail=new St(ce,0,0),this.len=0,this};O.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new St(ce,0,0),this.len=0),this};O.prototype.ldelim=function(){var o=this.head,i=this.tail,e=this.len;return this.reset().uint32(e),e&&(this.tail.next=o.next,this.tail=i,this.len+=e),this};O.prototype.finish=function(){for(var o=this.head.next,i=this.constructor.alloc(this.len),e=0;o;)o.fn(o.val,i,e),e+=o.len,o=o.next;return i};O._configure=function(l){oe=l,O.create=hn(),oe._configure()}});var _n=A((Hr,bn)=>{"use strict";bn.exports=nt;var dn=fe();(nt.prototype=Object.create(dn.prototype)).constructor=nt;var ct=st();function nt(){dn.call(this)}nt._configure=function(){nt.alloc=ct._Buffer_allocUnsafe,nt.writeBytesBuffer=ct.Buffer&&ct.Buffer.prototype instanceof Uint8Array&&ct.Buffer.prototype.set.name==="set"?function(o,i,e){i.set(o,e)}:function(o,i,e){if(o.copy)o.copy(i,e,0,o.length);else for(var r=0;r<o.length;)i[e++]=o[r++]}};nt.prototype.bytes=function(o){ct.isString(o)&&(o=ct._Buffer_from(o,"base64"));var i=o.length>>>0;return this.uint32(i),i&&this._push(nt.writeBytesBuffer,i,o),this};function ai(l,o,i){l.length<40?ct.utf8.write(l,o,i):o.utf8Write?o.utf8Write(l,i):o.write(l,i)}nt.prototype.string=function(o){var i=ct.Buffer.byteLength(o);return this.uint32(i),i&&this._push(ai,i,o),this};nt._configure()});var de=A((Vr,mn)=>{"use strict";mn.exports=D;var X=st(),pe,vn=X.LongBits,fi=X.utf8;function W(l,o){return RangeError("index out of range: "+l.pos+" + "+(o||1)+" > "+l.len)}function D(l){this.buf=l,this.pos=0,this.len=l.length}var yn=typeof Uint8Array<"u"?function(o){if(o instanceof Uint8Array||Array.isArray(o))return new D(o);throw Error("illegal buffer")}:function(o){if(Array.isArray(o))return new D(o);throw Error("illegal buffer")},kn=function(){return X.Buffer?function(i){return(D.create=function(r){return X.Buffer.isBuffer(r)?new pe(r):yn(r)})(i)}:yn};D.create=kn();D.prototype._slice=X.Array.prototype.subarray||X.Array.prototype.slice;function hi(l){for(var o=0,i=0;i<4;++i){if(l.pos>=l.len)throw W(l);var e=l.buf[l.pos++];if(o=(o|(e&127)<<i*7)>>>0,e<128)return o}throw W(l)}D.prototype.uint32=(function(){var o=4294967295;return function(){if(this.len-this.pos<5){if(this.pos>=this.len)throw W(this);if(this.buf[this.pos]>=128)return hi(this)}if(o=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(o=(o|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(o=(o|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return o;if((this.pos+=5)>this.len)throw this.pos=this.len,W(this,10);return o}})();D.prototype.int32=function(){return this.uint32()|0};D.prototype.sint32=function(){var o=this.uint32();return o>>>1^-(o&1)|0};function he(){var l=new vn(0,0),o=0;if(this.len-this.pos>4){for(;o<4;++o)if(l.lo=(l.lo|(this.buf[this.pos]&127)<<o*7)>>>0,this.buf[this.pos++]<128)return l;if(l.lo=(l.lo|(this.buf[this.pos]&127)<<28)>>>0,l.hi=(l.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return l;o=0}else{for(;o<3;++o){if(this.pos>=this.len)throw W(this);if(l.lo=(l.lo|(this.buf[this.pos]&127)<<o*7)>>>0,this.buf[this.pos++]<128)return l}return l.lo=(l.lo|(this.buf[this.pos++]&127)<<o*7)>>>0,l}if(this.len-this.pos>4){for(;o<5;++o)if(l.hi=(l.hi|(this.buf[this.pos]&127)<<o*7+3)>>>0,this.buf[this.pos++]<128)return l}else for(;o<5;++o){if(this.pos>=this.len)throw W(this);if(l.hi=(l.hi|(this.buf[this.pos]&127)<<o*7+3)>>>0,this.buf[this.pos++]<128)return l}throw Error("invalid varint encoding")}D.prototype.bool=function(){return this.uint32()!==0};function zt(l,o){return(l[o-4]|l[o-3]<<8|l[o-2]<<16|l[o-1]<<24)>>>0}D.prototype.fixed32=function(){if(this.pos+4>this.len)throw W(this,4);return zt(this.buf,this.pos+=4)};D.prototype.sfixed32=function(){if(this.pos+4>this.len)throw W(this,4);return zt(this.buf,this.pos+=4)|0};function gn(){if(this.pos+8>this.len)throw W(this,8);return new vn(zt(this.buf,this.pos+=4),zt(this.buf,this.pos+=4))}D.prototype.float=function(){if(this.pos+4>this.len)throw W(this,4);var o=X.float.readFloatLE(this.buf,this.pos);return this.pos+=4,o};D.prototype.double=function(){if(this.pos+8>this.len)throw W(this,4);var o=X.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,o};D.prototype.bytes=function(){var o=this.uint32(),i=this.pos,e=this.pos+o;if(e>this.len)throw W(this,o);if(this.pos+=o,Array.isArray(this.buf))return this.buf.slice(i,e);if(i===e){var r=X.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,i,e)};D.prototype.string=function(){var o=this.bytes();return fi.read(o,0,o.length)};D.prototype.skip=function(o){if(typeof o=="number"){if(this.pos+o>this.len)throw W(this,o);this.pos+=o}else do if(this.pos>=this.len)throw W(this);while(this.buf[this.pos++]&128);return this};D.recursionLimit=X.recursionLimit;D.prototype.skipType=function(l,o){if(o===void 0&&(o=0),o>D.recursionLimit)throw Error("maximum nesting depth exceeded");switch(l){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(l=this.uint32()&7)!==4;)this.skipType(l,o+1);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+l+" at offset "+this.pos)}return this};D._configure=function(l){pe=l,D.create=kn(),pe._configure();var o=X.Long?"toLong":"toNumber";X.merge(D.prototype,{int64:function(){return he.call(this)[o](!1)},uint64:function(){return he.call(this)[o](!0)},sint64:function(){return he.call(this).zzDecode()[o](!1)},fixed64:function(){return gn.call(this)[o](!0)},sfixed64:function(){return gn.call(this)[o](!1)}})}});var On=A((Jr,wn)=>{"use strict";wn.exports=pt;var Sn=de();(pt.prototype=Object.create(Sn.prototype)).constructor=pt;var Pn=st();function pt(l){Sn.call(this,l)}pt._configure=function(){Pn.Buffer&&(pt.prototype._slice=Pn.Buffer.prototype.slice)};pt.prototype.string=function(){var o=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+o,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+o,this.len))};pt._configure()});var Rn=A((Kr,Tn)=>{"use strict";Tn.exports=wt;var be=st();(wt.prototype=Object.create(be.EventEmitter.prototype)).constructor=wt;function wt(l,o,i){if(typeof l!="function")throw TypeError("rpcImpl must be a function");be.EventEmitter.call(this),this.rpcImpl=l,this.requestDelimited=!!o,this.responseDelimited=!!i}wt.prototype.rpcCall=function l(o,i,e,r,t){if(!r)throw TypeError("request must be specified");var n=this;if(!t)return be.asPromise(l,n,o,i,e,r);if(!n.rpcImpl){setTimeout(function(){t(Error("already ended"))},0);return}try{return n.rpcImpl(o,i[n.requestDelimited?"encodeDelimited":"encode"](r).finish(),function(s,u){if(s)return n.emit("error",s,o),t(s);if(u===null){n.end(!0);return}if(!(u instanceof e))try{u=e[n.responseDelimited?"decodeDelimited":"decode"](u)}catch(d){return n.emit("error",d,o),t(d)}return n.emit("data",u,o),t(null,u)})}catch(c){n.emit("error",c,o),setTimeout(function(){t(c)},0);return}};wt.prototype.end=function(o){return this.rpcImpl&&(o||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var En=A(xn=>{"use strict";var pi=xn;pi.Service=Rn()});var Dn=A(($r,jn)=>{"use strict";jn.exports=Object.create(null)});var Ln=A(In=>{"use strict";var G=In;G.build="minimal";G.Writer=fe();G.BufferWriter=_n();G.Reader=de();G.BufferReader=On();G.util=st();G.rpc=En();G.roots=Dn();G.configure=Cn;function Cn(){G.util._configure(),G.Writer._configure(G.BufferWriter),G.Reader._configure(G.BufferReader)}Cn()});var _e=A((Qr,Fn)=>{"use strict";Fn.exports=Ln()});var Zt=Tt(Kt());var Et=(e=>(e.Disconnected="disconnected",e.Connecting="connecting",e.Connected="connected",e))(Et||{}),jt=(e=>(e.Unsubscribed="unsubscribed",e.Subscribing="subscribing",e.Subscribed="subscribed",e))(jt||{});function Ce(l,o){return l.lastIndexOf(o,0)===0}function ut(l){return l==null?!1:typeof l=="function"}function Ie(l,o){if(globalThis.console){let i=globalThis.console[l];ut(i)&&i.apply(globalThis.console,o)}}function $n(l,o){return Math.floor(Math.random()*(o-l+1)+l)}function et(l,o,i){l>31&&(l=31);let e=$n(0,Math.min(i,o*Math.pow(2,l)));return Math.min(i,o+e)}function Le(l){return"error"in l&&l.error!==null}function at(l){return Math.min(l*1e3,2147483647)}function Fe(l){try{return typeof localStorage>"u"||localStorage===null||!ut(localStorage.getItem)?null:localStorage.getItem(l)}catch{return null}}function rt(l){return l!=null&&Number(l)>0}function I(l){if(l==null)return 0;if(typeof l=="object"){let i=l.low,e=l.high;if(typeof i=="number"&&typeof e=="number")return(e>>>0)*4294967296+(i>>>0)}let o=Number(l);return isNaN(o)?0:o}var vt=class extends Zt.default{constructor(i,e,r){super();this._resubscribeTimeout=null;this._refreshTimeout=null;this._pendingOffset=null;this._removed=!1;this._getState=null;this._map=!1;this._mapPresenceType=1;this._mapPhase=null;this._mapStateBuffer=[];this._mapStreamBuffer=[];this._mapCursor="";this._mapPageSize=0;this._mapUnrecoverableStrategy="from_scratch";this._mapPositionResets=0;this._subscribeFlow=0;this._refreshGeneration=0;this._sharedPollReplayPending=!1;this._stateTransitions=0;this._sharedPollQueue=Promise.resolve();this._subscribeCallFlow=null;this._deferredUnsubscribe=null;this._mapFlowRecovering=!1;this._mapFlowOffset=0;this._mapFlowEpoch=null;this._mapFlowPositionResets=0;this._debounceMs=0;this._debouncePending=new Map;this._sharedPoll=!1;this._sharedPollEpoch="";this._sharedPollTrackedItems=new Map;this._sharedPollGetSignature=null;this._sharedPollSignatureRefreshTimeout=null;this._sharedPollSignatureRefreshAttempts=0;this._sharedPollTrackRetryTimeout=null;this._sharedPollTrackRetryAttempts=0;this._sharedPollReplayRetryTimeout=null;this._sharedPollReplayRetryAttempts=0;this._sharedPollSignatures=[];this._sharedPollSignatureRefreshTargetMs=null;this._sharedPollSignatureRefreshInFlight=!1;this._sharedPollSignatureRefreshAgain=!1;this._sharedPollSignatureRefreshKeys=new Set;this.channel=e,this.state="unsubscribed",this._centrifuge=i,this._token="",this._getToken=null,this._data=null,this._getData=null,this._recover=!1,this._offset=null,this._epoch=null,this._id=0,this._recoverable=!1,this._positioned=!1,this._joinLeave=!1,this._minResubscribeDelay=500,this._maxResubscribeDelay=2e4,this._resubscribeTimeout=null,this._resubscribeAttempts=0,this._promises={},this._promiseId=0,this._inflight=!1,this._refreshTimeout=null,this._delta="",this._delta_negotiated=!1,this._tagsFilter=null,this._prevValueMap=new Map,this._unsubPromise=Promise.resolve(),this._deltaNumPubs=0,this._deltaNumFull=0,this._deltaNumDelta=0,this._deltaBytesReceived=0,this._deltaBytesDecoded=0,this._setOptions(r),this.type=this._sharedPoll?"shared_poll":this._map?"map":"stream",this._centrifuge._debugEnabled?(this.on("state",t=>{this._debug("subscription state",e,t.oldState,"->",t.newState)}),this.on("error",t=>{this._debug("subscription error",e,t)})):this.on("error",function(){Function.prototype()})}ready(i){return this.state==="unsubscribed"?Promise.reject({code:7,message:this.state}):this.state==="subscribed"?Promise.resolve():new Promise((e,r)=>{let t=this._nextPromiseId(),n={resolve:e,reject:r};i&&(n.timeout=setTimeout(()=>{delete this._promises[t],r({code:1,message:"timeout"})},i)),this._promises[t]=n})}subscribe(){if(this._removed)throw new Error("Subscription to the channel "+this.channel+" was removed from the client");this._isSubscribed()||(this._isUnsubscribed()&&(this._resubscribeAttempts=0),this._setSubscribing(0,"subscribe called"))}unsubscribe(){this._setUnsubscribed(0,"unsubscribe called",!0)}_debouncedPublish(i,e,r){let t=this._debouncePending.get(i);if(t)return t.data=e,t.dirty=!0,Promise.resolve({});let n={data:e,dirty:!1,timer:null};return n.timer=setTimeout(()=>{let s=this._debouncePending.get(i);if(!s||!s.dirty){this._debouncePending.delete(i);return}s.dirty=!1;let u=s.data;(r?this._centrifuge.mapPublish(this.channel,i,u):this._centrifuge.publish(this.channel,u)).catch(()=>{}),s.timer=setTimeout(()=>{let y=this._debouncePending.get(i);if(!y||!y.dirty){this._debouncePending.delete(i);return}this._debouncePending.delete(i),this._debouncedPublish(i,y.data,r).catch(()=>{})},this._debounceMs)},this._debounceMs),this._debouncePending.set(i,n),r?this._centrifuge.mapPublish(this.channel,i,e):this._centrifuge.publish(this.channel,e)}_cancelDebounce(i){let e=this._debouncePending.get(i);e&&(clearTimeout(e.timer),this._debouncePending.delete(i))}_cancelAllDebounce(){for(let[,i]of this._debouncePending)clearTimeout(i.timer);this._debouncePending.clear()}async presence(){return await this._methodCall(),this._centrifuge.presence(this.channel)}async presenceStats(){return await this._methodCall(),this._centrifuge.presenceStats(this.channel)}setTagsFilter(i){if(i&&this._delta)throw new Error("cannot use delta and tagsFilter together");this._tagsFilter=i,this._map&&(this._recover=!1,this._offset=null,this._epoch=null,this._mapPositionResets++)}setData(i){this._data=i}deltaStats(){let i=this._deltaBytesDecoded;return{numPublications:this._deltaNumPubs,numFullPayloads:this._deltaNumFull,numDeltaPayloads:this._deltaNumDelta,bytesReceived:this._deltaBytesReceived,bytesDecoded:i,compressionRatio:i>0?1-this._deltaBytesReceived/i:0}}_methodCall(){return this._isSubscribed()?Promise.resolve():this._isUnsubscribed()?Promise.reject({code:7,message:this.state}):new Promise((i,e)=>{let r=this._centrifuge._config.timeout,t=this._nextPromiseId(),n=setTimeout(()=>{delete this._promises[t],e({code:1,message:"timeout"})},r);this._promises[t]={timeout:n,resolve:i,reject:e}})}_nextPromiseId(){return++this._promiseId}_needRecover(){return this._recover===!0}_isUnsubscribed(){return this.state==="unsubscribed"}_isSubscribing(){return this.state==="subscribing"}_isSubscribed(){return this.state==="subscribed"}_setState(i){if(this.state!==i){let e=this.state;return this.state=i,this._stateTransitions++,this.emit("state",{newState:i,oldState:e,channel:this.channel}),!0}return!1}_usesToken(){return this._token!==""||this._getToken!==null}_clearSubscribingState(){this._resubscribeAttempts=0,this._clearResubscribeTimeout()}_clearSubscribedState(){this._clearRefreshTimeout(),this._refreshGeneration++,this._cancelAllDebounce(),this._clearSharedPollSignatureRefresh(),this._clearSharedPollTrackRetry(),this._clearSharedPollReplayRetry(),this._sharedPollSignatureRefreshTargetMs=null,this._sharedPollSignatureRefreshInFlight=!1,this._sharedPollSignatureRefreshAgain=!1}_invalidateState(){this._getToken!==null&&(this._token=""),this._prevValueMap=new Map,this._map?(this._offset=null,this._epoch=null,this._recover=!1,this._mapPositionResets++,this._mapStateBuffer=[],this._mapStreamBuffer=[],this._mapCursor="",this._mapPhase=null):this._offset!==null&&(this._offset=0,this._epoch="_")}_setSubscribed(i){if(!this._isSubscribing())return;if(this._clearSubscribingState(),i.id&&(this._id=i.id),i.recoverable?(this._recover=!0,this._offset=I(i.offset),this._epoch=i.epoch||""):this._recover=!1,i.delta?this._delta_negotiated=!0:this._delta_negotiated=!1,i.publish_debounce&&(this._debounceMs=i.publish_debounce),this._sharedPoll){let t=i.epoch||"";if(this._sharedPollEpoch!==""&&this._sharedPollEpoch!==t)for(let n of this._sharedPollTrackedItems.keys())this._sharedPollTrackedItems.set(n,0);this._sharedPollEpoch=t}if(this._setState("subscribed"),!this._isSubscribed())return;let e=this._centrifuge._getSubscribeContext(this.channel,i);if(this.emit("subscribed",e),!this._isSubscribed())return;this._resolvePromises();let r=i.publications||[];for(let t=0;t<r.length&&this._isSubscribed();t++)this._handlePublication(r[t]);i.expires===!0&&this._isSubscribed()&&(this._refreshTimeout=setTimeout(()=>this._refresh(),at(i.ttl)))}async _setSubscribing(i,e){if(this._isSubscribing())return;this._isSubscribed()&&this._clearSubscribedState(),this._id=0;let r=this._stateTransitions+1;this._setState("subscribing")&&this._stateTransitions===r&&this.emit("subscribing",{channel:this.channel,code:i,reason:e}),this._centrifuge._transport&&this._centrifuge._transport.emulation()&&(await this._unsubPromise,await this._centrifuge._removedSubscriptionUnsubscribed(this.channel),await this._sharedPollQueue),this._isSubscribing()&&this._subscribe()}_subscribe(){if(this._debug("subscribing on",this.channel),!this._isTransportOpen())return this._debug("delay subscribe on",this.channel,"till connected"),null;if(this._inflight)return null;if(this._inflight=!0,this._map)return this._mapSubscribe(),null;let i=this._subscribeFlow;return this._getState&&this._offset===null?(this._loadStreamState(i),null):this._canSubscribeWithoutGettingToken()?this._subscribeWithoutToken(i):(this._getSubscriptionToken().then(e=>this._handleTokenResponse(e,i)).catch(e=>this._handleTokenError(e,i)),null)}_flowOutdated(i){return i!==this._subscribeFlow}_mustDeferUnsubscribe(){let i=this._centrifuge._transport;return this._subscribeCallFlow===this._subscribeFlow&&!!i&&i.emulation()}_settleSubscribeCall(i,e,r){this._subscribeCallFlow===i&&(this._subscribeCallFlow=null);let t=this._deferredUnsubscribe;return t===null||t.flow!==i?!1:(this._deferredUnsubscribe=null,e?(this._centrifuge._unsubscribe(this).then(t.resolve),!0):(t.resolve(),r&&r.code===1&&this._centrifuge._disconnect(3,"subscribe timeout",!0),!0))}_isTransportOpen(){return this._centrifuge._transportIsOpen}_canSubscribeWithoutGettingToken(){return!this._usesToken()||!!this._token}_subscribeWithoutToken(i){return this._getData?(this._getDataAndSubscribe(this._token,i),null):this._sendSubscribe(this._token)}_loadStreamState(i){if(!this._isSubscribing()){this._inflight=!1;return}this._callAsync(()=>this._getState()).then(e=>{if(!this._flowOutdated(i)){if(!this._isSubscribing()){this._inflight=!1;return}this._offset=I(e.offset),this._epoch=e.epoch,this._recover=!0,this._canSubscribeWithoutGettingToken()?this._subscribeWithoutToken(i):this._getSubscriptionToken().then(r=>this._handleTokenResponse(r,i)).catch(r=>this._handleTokenError(r,i))}}).catch(e=>{if(!this._flowOutdated(i)){if(!this._isSubscribing()){this._inflight=!1;return}this._inflight=!1,this._subscribeError({code:13,message:e?.toString()||"getState failed",temporary:!0})}})}_getDataAndSubscribe(i,e){if(!this._getData){this._inflight=!1;return}this._callAsync(()=>this._getData({channel:this.channel})).then(r=>{if(!this._flowOutdated(e)){if(!this._isSubscribing()){this._inflight=!1;return}this._data=r,this._sendSubscribe(i)}}).catch(r=>this._handleGetDataError(r,e))}_handleGetDataError(i,e){if(!this._flowOutdated(e)){if(!this._isSubscribing()){this._inflight=!1;return}if(i instanceof Z){this._inflight=!1,this._failUnauthorized();return}this._emitError({type:"subscribeData",channel:this.channel,error:{code:12,message:i?.toString()||""}},()=>{this._inflight=!1,this._scheduleResubscribe()})}}_handleTokenResponse(i,e){if(!this._flowOutdated(e)){if(!this._isSubscribing()){this._inflight=!1;return}if(!i){this._inflight=!1,this._failUnauthorized();return}this._token=i,this._getData?this._getDataAndSubscribe(i,e):this._sendSubscribe(i)}}_handleTokenError(i,e){if(!this._flowOutdated(e)){if(!this._isSubscribing()){this._inflight=!1;return}if(i instanceof Z){this._inflight=!1,this._failUnauthorized();return}this._emitError({type:"subscribeToken",channel:this.channel,error:{code:8,message:i?.toString()||""}},()=>{this._inflight=!1,this._scheduleResubscribe()})}}_sendSubscribe(i){if(!this._isTransportOpen())return this._inflight=!1,null;let e=this._buildSubscribeCommand(i),r=this._subscribeFlow;return this._subscribeCallFlow=r,this._centrifuge._call(e).then(t=>{try{if(this._settleSubscribeCall(r,!0)||r!==this._subscribeFlow)return;this._inflight=!1,this._handleSubscribeResponse(t.reply.subscribe)}catch(n){this._centrifuge._dispatchFailed(n)}finally{t.next&&t.next()}},t=>{try{if(this._settleSubscribeCall(r,!1,t.error)||r!==this._subscribeFlow)return;this._inflight=!1,this._handleSubscribeError(t.error)}catch(n){this._centrifuge._rejectionFailed(n,t)}finally{t.next&&t.next()}}),e}_buildSubscribeCommand(i){let e={channel:this.channel};if(i&&(e.token=i),this._data&&(e.data=this._data),this._sharedPoll)return e.type=4,this._delta&&(e.delta=this._delta),{subscribe:e};if(this._positioned&&(e.positioned=!0),this._recoverable&&(e.recoverable=!0),this._joinLeave&&(e.join_leave=!0),e.flag=1,this._getState&&(e.flag|=2),this._needRecover()){e.recover=!0;let r=this._getOffset();r&&(e.offset=r);let t=this._getEpoch();t&&(e.epoch=t)}return this._delta&&(e.delta=this._delta),this._tagsFilter&&(e.tf=this._tagsFilter),{subscribe:e}}_debug(...i){this._centrifuge._debug(...i)}emit(i,...e){try{return Zt.default.prototype.emit.call(this,i,...e)}catch(r){return this._centrifuge._handlerFailed(r),!0}}_handleSubscribeError(i){if(this._isSubscribing()&&i.code!==11){if(i.code===1){this._centrifuge._disconnect(3,"subscribe timeout",!0);return}if(i.code===112&&this._getState){this._offset=null,this._epoch=null,this._recover=!1,this._prevValueMap=new Map,this._scheduleResubscribe();return}this._subscribeError(i)}}_handleSubscribeResponse(i){if(this._isSubscribing()){this._sharedPollReplayPending=this._sharedPoll;try{this._setSubscribed(i)}finally{this._sharedPollReplayPending=!1}this._sharedPoll&&this._sharedPollReplayTrack()}}_setUnsubscribed(i,e,r){if(this._isUnsubscribed())return Promise.resolve();let t=Promise.resolve();if(this._isSubscribed())r&&(t=this._unsubPromise=this._centrifuge._unsubscribe(this)),this._clearSubscribedState();else if(this._isSubscribing()){if(this._inflight&&r)if(this._mustDeferUnsubscribe()){let c=this._subscribeFlow;t=this._unsubPromise=new Promise(s=>{this._deferredUnsubscribe={flow:c,resolve:s}})}else t=this._unsubPromise=this._centrifuge._unsubscribe(this);this._clearSubscribingState()}this._inflight=!1,this._subscribeFlow++,this._id=0,this._sharedPollEpoch="",this._sharedPollSignatures=[],this._sharedPollTrackedItems.clear(),this._sharedPollSignatureRefreshInFlight=!1,this._sharedPollSignatureRefreshAgain=!1,this._sharedPollSignatureRefreshTargetMs=null,this._cancelAllDebounce(),this._rejectPromises({code:7,message:"unsubscribed"});let n=this._stateTransitions+1;return this._setState("unsubscribed")&&this._stateTransitions===n&&this.emit("unsubscribed",{channel:this.channel,code:i,reason:e}),t}_handlePublication(i){if(this._sharedPoll&&i.key&&!i.removed&&rt(i.version)){let r=this._sharedPollTrackedItems.get(i.key);if(r!==void 0&&r>0&&I(i.version)<=r)return}if(this._delta&&this._delta_negotiated){let r=(this._map||this._sharedPoll)&&i.key||"";if(i.removed)this._prevValueMap.delete(r);else{let{newData:t,newPrevValue:n,isDelta:c,wireBytes:s,fullBytes:u}=this._centrifuge._codec.applyDeltaIfNeeded(i,this._prevValueMap.get(r));i.data=t,this._deltaNumPubs++,this._deltaBytesReceived+=s,this._deltaBytesDecoded+=u,c?this._deltaNumDelta++:this._deltaNumFull++,this._prevValueMap.set(r,n)}}let e;if(this._sharedPoll){if(i.key&&!this._sharedPollTrackedItems.has(i.key))return;e=this._getSharedPollUpdateContext(i)}else this._map?e=this._getMapUpdateContext(i):e=this._centrifuge._getPublicationContext(this.channel,i);if(this._map||this._sharedPoll){if(this.emit("publication",e),!this._isSubscribed())return;this._setPublicationPosition(i),this.emit("update",e)}else{this._pendingOffset=rt(i.offset)?I(i.offset):null;let r=this._centrifuge._handlerFailures;try{this.emit("publication",e)}finally{this._pendingOffset=null}if(this._centrifuge._handlerFailures!==r)return;this._setPublicationPosition(i)}}_setPublicationPosition(i){this._sharedPoll&&i.key&&this._sharedPollTrackedItems.has(i.key)&&(i.removed?this._sharedPollTrackedItems.delete(i.key):i.version&&this._sharedPollTrackedItems.set(i.key,I(i.version))),rt(i.offset)&&(this._offset=I(i.offset)),i.epoch&&(this._epoch=i.epoch)}_seedDeltaTracking(i,e){if(!(!this._delta||!i.key)){if(i.removed){this._prevValueMap.delete(i.key);return}if(!e){this._prevValueMap.set(i.key,i.data);return}if(typeof i.data=="string"){let r=i.data,t=new TextEncoder().encode(r);this._prevValueMap.set(i.key,t);let n=t.length;this._deltaNumPubs++,this._deltaNumFull++,this._deltaBytesReceived+=n,this._deltaBytesDecoded+=n,i.data=JSON.parse(r)}else if(i.data instanceof Uint8Array){this._prevValueMap.set(i.key,i.data);let r=i.data.length;this._deltaNumPubs++,this._deltaNumFull++,this._deltaBytesReceived+=r,this._deltaBytesDecoded+=r}}}_handleJoin(i){let e=this._centrifuge._getJoinLeaveContext(i.info);this.emit("join",{channel:this.channel,info:e})}_handleLeave(i){let e=this._centrifuge._getJoinLeaveContext(i.info);this.emit("leave",{channel:this.channel,info:e})}_resolvePromises(){for(let i in this._promises)this._promises.hasOwnProperty(i)&&(this._promises[i].timeout&&clearTimeout(this._promises[i].timeout),this._promises[i].resolve(),delete this._promises[i])}_rejectPromises(i){for(let e in this._promises)this._promises.hasOwnProperty(e)&&(this._promises[e].timeout&&clearTimeout(this._promises[e].timeout),this._promises[e].reject(i),delete this._promises[e])}_scheduleResubscribe(){if(!this._isSubscribing()){this._debug("not in subscribing state, skip resubscribe scheduling",this.channel);return}let i=this,e=this._getResubscribeDelay();this._clearResubscribeTimeout(),this._resubscribeTimeout=setTimeout(function(){i._resubscribeTimeout=null,i._isSubscribing()&&i._subscribe()},e),this._debug("resubscribe scheduled after "+e,this.channel)}_emitError(i,e){let r=this._subscribeFlow;try{this.emit("error",i)}finally{r===this._subscribeFlow&&e()}}_subscribeError(i){if(this._isSubscribing()){if(i.code===109&&this._getToken===null){try{this.emit("error",{type:"configuration",channel:this.channel,error:{code:12,message:"subscription token expired but no getToken function set"}})}catch(e){this._centrifuge._reportDispatchError(e)}this._setUnsubscribed(1,"unauthorized",!1);return}if(i.code<100||i.code===109||i.temporary===!0){i.code===109&&(this._token="");let e={channel:this.channel,type:"subscribe",error:i};this._centrifuge.state==="connected"?this._emitError(e,()=>this._scheduleResubscribe()):this._scheduleResubscribe()}else this._setUnsubscribed(i.code,i.message,!1)}}_getResubscribeDelay(){let i=et(this._resubscribeAttempts,this._minResubscribeDelay,this._maxResubscribeDelay);return this._resubscribeAttempts++,i}_setOptions(i){if(i){if(i.since&&(this._offset=I(i.since.offset),this._epoch=i.since.epoch||"",this._recover=!0),i.data&&(this._data=i.data),i.getData&&(this._getData=i.getData),i.minResubscribeDelay!==void 0&&(this._minResubscribeDelay=i.minResubscribeDelay),i.maxResubscribeDelay!==void 0&&(this._maxResubscribeDelay=i.maxResubscribeDelay),i.token&&(this._token=i.token),i.getToken&&(this._getToken=i.getToken),i.positioned===!0&&(this._positioned=!0),i.recoverable===!0&&(this._recoverable=!0),i.joinLeave===!0&&(this._joinLeave=!0),i.delta){if(i.delta!=="fossil")throw new Error("unsupported delta format");this._delta=i.delta}if(i.tagsFilter&&(this._tagsFilter=i.tagsFilter),this._tagsFilter&&this._delta)throw new Error("cannot use delta and tagsFilter together");i.getState&&(this._getState=i.getState,this._recover=!0),i.map===!0&&(this._map=!0),i.mapPageSize!==void 0&&(this._mapPageSize=i.mapPageSize),i.mapPresenceType!==void 0&&(this._mapPresenceType=i.mapPresenceType,this._map=!0),i.mapUnrecoverableStrategy&&(this._mapUnrecoverableStrategy=i.mapUnrecoverableStrategy),i.sharedPoll===!0&&(this._sharedPoll=!0),i.sharedPollGetSignature&&(this._sharedPollGetSignature=i.sharedPollGetSignature)}}_getOffset(){if(this._pendingOffset!==null)return this._pendingOffset;let i=this._offset;return i!==null?i:0}_getEpoch(){let i=this._epoch;return i!==null?i:""}_clearRefreshTimeout(){this._refreshTimeout!==null&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null)}_clearResubscribeTimeout(){this._resubscribeTimeout!==null&&(clearTimeout(this._resubscribeTimeout),this._resubscribeTimeout=null)}_getSubscriptionToken(){this._debug("get subscription token for channel",this.channel);let i={channel:this.channel},e=this._getToken;if(e===null){try{this.emit("error",{type:"configuration",channel:this.channel,error:{code:12,message:"provide a function to get channel subscription token"}})}catch(r){this._centrifuge._reportDispatchError(r)}return Promise.reject(new Z(""))}return this._callAsync(()=>e(i))}_refresh(){this._clearRefreshTimeout();let i=this,e=this._refreshGeneration;this._getSubscriptionToken().then(function(r){if(e!==i._refreshGeneration||!i._isSubscribed())return;if(!r){i._failUnauthorized();return}i._token=r;let n={sub_refresh:{channel:i.channel,token:r}};i._centrifuge._call(n).then(c=>{try{i._refreshResponse(c.reply.sub_refresh)}catch(s){i._centrifuge._dispatchFailed(s)}finally{c.next&&c.next()}},c=>{try{i._refreshError(c.error)}catch(s){i._centrifuge._rejectionFailed(s,c)}finally{c.next&&c.next()}})}).catch(function(r){if(!(e!==i._refreshGeneration||!i._isSubscribed())){if(r instanceof Z){i._failUnauthorized();return}i._emitError({type:"refreshToken",channel:i.channel,error:{code:9,message:r!==void 0?r.toString():""}},()=>{e!==i._refreshGeneration||!i._isSubscribed()||(i._refreshTimeout=setTimeout(()=>i._refresh(),i._getRefreshRetryDelay()))})}})}_refreshResponse(i){this._isSubscribed()&&(this._debug("subscription token refreshed, channel",this.channel),this._clearRefreshTimeout(),i.expires===!0&&(this._refreshTimeout=setTimeout(()=>this._refresh(),at(i.ttl))))}_refreshError(i){this._isSubscribed()&&(i.code<100||i.temporary===!0?this._emitError({type:"refresh",channel:this.channel,error:i},()=>{this._isSubscribed()&&(this._refreshTimeout=setTimeout(()=>this._refresh(),this._getRefreshRetryDelay()))}):this._setUnsubscribed(i.code,i.message,!0))}_getRefreshRetryDelay(){return et(0,1e4,2e4)}_callAsync(i){try{return Promise.resolve(i())}catch(e){return Promise.reject(e)}}_failUnauthorized(){this._setUnsubscribed(1,"unauthorized",!0)}_sendTrackRequest(i,e){if(i.length===0)return Promise.resolve();let r=6e4,t=[],n=[],c=100;if(e&&e.length>0)for(let d of e)c+=d.length+4;for(let d of i){let y=100;for(let g of d.items)y+=g.key.length+16;n.length>0&&c+y>r&&(t.push(n),n=[],c=100),n.push(d),c+=y}n.length>0&&t.push(n);let s=d=>t.slice(d).flatMap(y=>y.flatMap(g=>g.items.map(k=>k.key))),u=(d,y,g)=>new Promise((k,P)=>{let R={channel:this.channel,type:1,track:d.map(C=>({signature:C.signature,items:C.items.map(q=>q.version>0?q:{key:q.key})}))};g&&g.length>0&&(R.untrack=g);let Q={sub_refresh:R};this._centrifuge._call(Q).then(C=>{try{this._handleTrackResponse(C.reply.sub_refresh,d.flatMap(q=>q.items.map(x=>x.key)),g)}catch(q){this._centrifuge._dispatchFailed(q)}finally{C.next&&C.next()}k()},C=>{C.next&&C.next(),this._sharedPollRequestFailed(C.error),P({error:C.error,keys:s(y)})})});return this._sharedPollSerial(()=>t.reduce((d,y,g)=>d.then(()=>u(y,g,g===0?e:void 0)),Promise.resolve()))}_isEmulation(){let i=this._centrifuge._transport;return!!i&&i.emulation()}_sharedPollSerial(i){if(!this._isEmulation())return i();let e=this._refreshGeneration,r=this._sharedPollQueue.then(()=>{if(!(e!==this._refreshGeneration||!this._isSubscribed()))return i()});return this._sharedPollQueue=r.then(()=>{},()=>{}),r}_sharedPollRequestFailed(i){i&&i.code===1&&this._isEmulation()&&this._centrifuge._disconnect(3,"shared poll request timeout",!0)}_sendUntrackRequest(i){return this._sharedPollSerial(()=>new Promise((e,r)=>{let n={sub_refresh:{channel:this.channel,type:2,untrack:i}};this._centrifuge._call(n).then(c=>{c.next&&c.next(),e()},c=>{c.next&&c.next(),this._sharedPollRequestFailed(c.error),r(c.error)})}))}_handleTrackResponse(i,e,r){if(!this._isSubscribed())return;if(this._clearSharedPollTrackRetry(),i&&i.items&&i.items.length>0)for(let c of i.items){if(!this._isSubscribed())return;this._handlePublication(c)}if(!this._isSubscribed())return;let t=new Set(r||[]),n=e.filter(c=>!t.has(c)&&!this._sharedPollTrackedItems.has(c));if(n.length>0&&this._sendUntrackRequest(n).catch(c=>{this.emit("error",{type:"untrack",channel:this.channel,error:c})}),i&&i.expires===!0){let c=Date.now()+(i.ttl>0?i.ttl*1e3:1e3);this._maybeScheduleSharedPollSignatureRefresh(c)}}_maybeScheduleSharedPollSignatureRefresh(i){if(i===null){this._sharedPollSignatureRefreshTargetMs=null,this._clearSharedPollSignatureRefresh();return}this._isSubscribed()&&(this._sharedPollSignatureRefreshTargetMs!==null&&i>=this._sharedPollSignatureRefreshTargetMs||(this._sharedPollSignatureRefreshTargetMs=i,this._clearSharedPollSignatureRefresh(),this._sharedPollSignatureRefreshTimeout=setTimeout(()=>this._sharedPollRefreshSignature(),Math.max(0,i-Date.now()))))}_clearSharedPollSignatureRefresh(){this._sharedPollSignatureRefreshTimeout!==null&&(clearTimeout(this._sharedPollSignatureRefreshTimeout),this._sharedPollSignatureRefreshTimeout=null),this._sharedPollSignatureRefreshAttempts=0}_clearSharedPollTrackRetry(){this._sharedPollTrackRetryTimeout!==null&&(clearTimeout(this._sharedPollTrackRetryTimeout),this._sharedPollTrackRetryTimeout=null),this._sharedPollTrackRetryAttempts=0}_scheduleSharedPollReplayRetry(){this._sharedPollReplayRetryTimeout!==null&&clearTimeout(this._sharedPollReplayRetryTimeout),this._sharedPollReplayRetryTimeout=setTimeout(()=>this._sharedPollReplayTrack(),et(this._sharedPollReplayRetryAttempts++,5e3,3e4))}_clearSharedPollReplayRetry(){this._sharedPollReplayRetryTimeout!==null&&(clearTimeout(this._sharedPollReplayRetryTimeout),this._sharedPollReplayRetryTimeout=null),this._sharedPollReplayRetryAttempts=0}_addSharedPollSignature(i,e){let r=new Set(i);this._sharedPollSignatures=this._sharedPollSignatures.filter(t=>!t.keys.every(n=>r.has(n))),this._sharedPollSignatures.push({keys:i,signature:e})}_handleTrackError(i,e){this._isSubscribed()&&this._emitError({type:"track",channel:this.channel,error:i},()=>{if(this._isSubscribed()){if(i.code===109){this._sharedPollRefreshSignature();return}if(i.code<100||i.temporary===!0){this._sharedPollTrackRetryTimeout=setTimeout(()=>this._sharedPollReplayTrack(),et(this._sharedPollTrackRetryAttempts++,1e3,15e3));return}this._untrackFailedKeys(e)}})}_untrackFailedKeys(i){let e=i.filter(r=>this._sharedPollTrackedItems.has(r));if(e.length!==0){for(let r of e)this._sharedPollTrackedItems.delete(r);this._sharedPollSignatures=this._sharedPollSignatures.filter(r=>r.keys.some(t=>this._sharedPollTrackedItems.has(t))),this._sendUntrackRequest(e).catch(r=>{this.emit("error",{type:"untrack",channel:this.channel,error:r})});for(let r of e){if(!this._isSubscribed())return;this.emit("update",{channel:this.channel,key:r,data:null,removed:!0})}}}_sharedPollRefreshSignature(){if(this._clearSharedPollSignatureRefresh(),!this._isSubscribed()||!this._sharedPollGetSignature||this._sharedPollTrackedItems.size===0)return;if(this._sharedPollSignatureRefreshInFlight){for(let t of this._sharedPollTrackedItems.keys())if(!this._sharedPollSignatureRefreshKeys.has(t)){this._sharedPollSignatureRefreshAgain=!0;break}return}this._sharedPollSignatureRefreshTargetMs=null,this._sharedPollSignatureRefreshInFlight=!0;let i=Array.from(this._sharedPollTrackedItems.keys());this._sharedPollSignatureRefreshKeys=new Set(i);let e=this,r=this._refreshGeneration;this._callAsync(()=>this._sharedPollGetSignature({keys:i})).then(t=>{if(r!==e._refreshGeneration||(e._sharedPollSignatureRefreshInFlight=!1,!e._isSubscribed()))return;e._sharedPollSignatureRefreshAttempts=0,e._sharedPollSignatureRefreshAgain&&(e._sharedPollSignatureRefreshAgain=!1,Promise.resolve().then(()=>e._sharedPollRefreshSignature()));let n=new Set(t.keys),c=[];for(let y of i)if(!n.has(y)&&this._sharedPollTrackedItems.has(y)){if(e._sharedPollTrackedItems.delete(y),c.push(y),!e._isSubscribed())continue;e.emit("update",{channel:e.channel,key:y,data:null,removed:!0})}c.length>0&&e._sendUntrackRequest(c).catch(y=>{e.emit("error",{type:"untrack",channel:e.channel,error:y})});let s=[];for(let y of t.keys){let g=e._sharedPollTrackedItems.get(y);g!==void 0&&s.push({key:y,version:g})}let u=new Set(t.keys),d=e._sharedPollSignatures.filter(y=>y.keys.some(g=>e._sharedPollTrackedItems.has(g)&&!u.has(g)));e._sharedPollSignatures=s.length>0?[{keys:t.keys,signature:t.signature},...d]:d,s.length!==0&&e._sendTrackRequest([{items:s,signature:t.signature}]).catch(y=>{e._handleTrackError(y.error,y.keys)})}).catch(t=>{r===e._refreshGeneration&&(e._sharedPollSignatureRefreshInFlight=!1,e._sharedPollSignatureRefreshAgain=!1,e._emitError({type:"signatureRefresh",channel:e.channel,error:{code:14,message:t!==void 0?t.toString():""}},()=>{r!==e._refreshGeneration||!e._isSubscribed()||(e._sharedPollSignatureRefreshTimeout=setTimeout(()=>e._sharedPollRefreshSignature(),et(e._sharedPollSignatureRefreshAttempts++,5e3,3e4)))}))})}_sharedPollReplayTrack(){if(!this._isSubscribed()||this._sharedPollTrackedItems.size===0&&this._sharedPollSignatures.length===0)return;let i=new Set,e=[],r=[];for(let s of this._sharedPollSignatures){let u=s.keys.map(d=>({key:d,version:this._sharedPollTrackedItems.get(d)??0}));e.push({items:u,signature:s.signature});for(let d of s.keys)this._sharedPollTrackedItems.has(d)?i.add(d):r.push(d)}e.length>0&&this._sendTrackRequest(e,r).catch(s=>{this._handleTrackError(s.error,s.keys)});let t=[];for(let s of this._sharedPollTrackedItems.keys())i.has(s)||t.push(s);if(t.length===0)return;if(!this._sharedPollGetSignature){this.emit("error",{type:"track",channel:this.channel,error:{code:14,message:"getSignature callback required for tracked keys without an explicit signature"}});return}let n=this,c=this._refreshGeneration;this._callAsync(()=>this._sharedPollGetSignature({keys:t})).then(s=>{if(c!==n._refreshGeneration||!n._isSubscribed())return;n._clearSharedPollReplayRetry();let u=new Set(s.keys),d=[];for(let g of t)if(!u.has(g)&&this._sharedPollTrackedItems.has(g)){if(n._sharedPollTrackedItems.delete(g),d.push(g),!n._isSubscribed())continue;n.emit("update",{channel:n.channel,key:g,data:null,removed:!0})}d.length>0&&n._sendUntrackRequest(d).catch(g=>{n.emit("error",{type:"untrack",channel:n.channel,error:g})});let y=[];for(let g of s.keys){let k=n._sharedPollTrackedItems.get(g);k!==void 0&&y.push({key:g,version:k})}y.length!==0&&(n._addSharedPollSignature(s.keys,s.signature),n._sendTrackRequest([{items:y,signature:s.signature}]).catch(g=>{n._handleTrackError(g.error,g.keys)}))}).catch(s=>{c!==n._refreshGeneration||!n._isSubscribed()||n._emitError({type:"signatureRefresh",channel:n.channel,error:{code:14,message:s!==void 0?s.toString():""}},()=>{c!==n._refreshGeneration||!n._isSubscribed()||(n._sharedPollReplayRetryTimeout=setTimeout(()=>n._sharedPollReplayTrack(),et(n._sharedPollReplayRetryAttempts++,5e3,3e4)))})})}_mapSubscribe(){this._debug("starting map subscribe on",this.channel);let i=++this._subscribeFlow,e=()=>{this._mapStateBuffer=[],this._mapStreamBuffer=[],this._mapCursor="";let r=this._recover&&this._offset!==null&&this._epoch!==null;r||(this._prevValueMap=new Map),this._mapFlowRecovering=r,this._mapFlowOffset=r?this._offset:0,this._mapFlowEpoch=r?this._epoch:null,this._mapFlowPositionResets=this._mapPositionResets,this._mapPhase=2,r?(this._debug("map subscribe: recovering from position, skipping to stream phase"),this._mapPhase=1,this._fetchStream(i)):this._fetchSnapshot(i)};this._canSubscribeWithoutGettingToken()?e():this._getSubscriptionToken().then(r=>{if(i===this._subscribeFlow){if(!this._isSubscribing()){this._inflight=!1;return}if(!r){this._inflight=!1,this._failUnauthorized();return}this._token=r,e()}}).catch(r=>{this._handleTokenError(r,i)})}_fetchSnapshot(i,e){if(!this._isSubscribing()||!this._isTransportOpen()){this._inflight=!1;return}let r=this._buildMapSubscribeCommand(2,e);this._debug("map subscribe: fetching snapshot page",e?`cursor=${e}`:"initial"),this._subscribeCallFlow=i,this._centrifuge._call(r).then(t=>{try{if(this._settleSubscribeCall(i,!0))return;i===this._subscribeFlow&&this._handleMapStateResponse(i,t.reply.subscribe)}catch(n){this._centrifuge._dispatchFailed(n)}finally{t.next&&t.next()}},t=>{try{if(this._settleSubscribeCall(i,!1,t.error))return;i===this._subscribeFlow&&this._handleMapSubscribeError(t.error)}catch(n){this._centrifuge._rejectionFailed(n,t)}finally{t.next&&t.next()}})}_handleMapStateResponse(i,e){if(!this._isSubscribing()){this._inflight=!1;return}if(!e.phase){this._debug("map subscribe: server forced LIVE transition during state pagination"),this._handleMapLiveResponse(i,e);return}if(!this._mapFlowEpoch&&e.epoch&&(this._mapFlowEpoch=e.epoch,this._mapFlowOffset=I(e.offset)),this._mapFlowEpoch&&e.epoch&&this._mapFlowEpoch!==e.epoch){this._debug("map subscribe: epoch changed during snapshot pagination, restarting"),this._restartMapFlow(),this._fetchSnapshot(i);return}if(e.state&&e.state.length>0&&this._mapStateBuffer.push(...e.state),e.cursor){this._mapCursor=e.cursor,this._fetchSnapshot(i,this._mapCursor);return}this._transitionFromSnapshot(i)}_restartMapFlow(){this._mapStateBuffer=[],this._mapStreamBuffer=[],this._mapCursor="",this._mapFlowRecovering=!1,this._mapFlowOffset=0,this._mapFlowEpoch=null,this._epoch=null,this._offset=null,this._recover=!1,this._prevValueMap=new Map,this._mapPhase=2}_transitionFromSnapshot(i){this._debug("map subscribe: snapshot complete, transitioning to stream phase"),this._mapPhase=1,this._fetchStream(i)}_fetchStream(i){if(!this._isSubscribing()||!this._isTransportOpen()){this._inflight=!1;return}let e=this._buildMapSubscribeCommand(1);this._debug("map subscribe: fetching stream from offset",this._mapFlowOffset),this._subscribeCallFlow=i,this._centrifuge._call(e).then(r=>{try{if(this._settleSubscribeCall(i,!0))return;i===this._subscribeFlow&&this._handleMapStreamResponse(i,r.reply.subscribe)}catch(t){this._centrifuge._dispatchFailed(t)}finally{r.next&&r.next()}},r=>{try{if(this._settleSubscribeCall(i,!1,r.error))return;i===this._subscribeFlow&&this._handleMapSubscribeError(r.error)}catch(t){this._centrifuge._rejectionFailed(t,r)}finally{r.next&&r.next()}})}_handleMapStreamResponse(i,e){if(!this._isSubscribing()){this._inflight=!1;return}if(!e.phase){this._debug("map subscribe: server forced LIVE transition during stream"),this._handleMapLiveResponse(i,e);return}if(this._mapFlowEpoch&&e.epoch&&this._mapFlowEpoch!==e.epoch){this._debug("map subscribe: epoch changed during stream, restarting"),this._restartMapFlow(),this._fetchSnapshot(i);return}e.publications&&e.publications.length>0&&this._mapStreamBuffer.push(...e.publications),e.offset!==void 0&&(this._mapFlowOffset=I(e.offset)),this._fetchStream(i)}_handleMapLiveResponse(i,e){if(!this._isSubscribing()){this._inflight=!1;return}if(this._inflight=!1,this._mapFlowEpoch&&e.epoch&&this._mapFlowEpoch!==e.epoch){this._debug("map subscribe: epoch changed during live transition, restarting"),this._restartMapFlow(),this._inflight=!0,this._fetchSnapshot(i);return}let r=!!(this._delta&&e.delta),t=e.state&&e.state.length>0?this._mapStateBuffer.concat(e.state):this._mapStateBuffer;if(this._mapStateBuffer=t.map(k=>(this._seedDeltaTracking(k,r),this._getMapUpdateContext(k))),this._mapStreamBuffer=this._mapStreamBuffer.map(k=>(this._seedDeltaTracking(k,r),this._getMapUpdateContext(k))),e.publications&&e.publications.length>0)for(let k of e.publications){if(r){let P=k.key||"";if(k.removed)this._prevValueMap.delete(P);else{let{newData:R,newPrevValue:Q,isDelta:C,wireBytes:q,fullBytes:x}=this._centrifuge._codec.applyDeltaIfNeeded(k,this._prevValueMap.get(P));k.data=R,this._deltaNumPubs++,this._deltaBytesReceived+=q,this._deltaBytesDecoded+=x,C?this._deltaNumDelta++:this._deltaNumFull++,this._prevValueMap.set(P,Q)}}else this._delta&&k.key&&(k.removed?this._prevValueMap.delete(k.key):this._prevValueMap.set(k.key,k.data));this._mapStreamBuffer.push(this._getMapUpdateContext(k))}let n=I(e.offset),c=e.epoch||"";this._clearSubscribingState(),e.id&&(this._id=e.id);let s=e.recoverable===!0;e.delta?this._delta_negotiated=!0:this._delta_negotiated=!1,e.publish_debounce&&(this._debounceMs=e.publish_debounce);let u=this._mapStateBuffer,d=this._mapStreamBuffer;this._mapStateBuffer=[],this._mapStreamBuffer=[],this._mapPhase=null;let y=this._centrifuge._getSubscribeContext(this.channel,e);y.state=u;let g=this._mapFlowPositionResets;if(this._mapPositionResets===g&&(this._recover=s,this._epoch=c,y.recovered?d.length>0&&d[0].offset!==void 0?this._offset=d[0].offset-1:this._offset=n:(this._recover=!1,this._offset=null,this._epoch=null)),this._setState("subscribed"),!!this._isSubscribed()&&(this.emit("subscribed",y),!!this._isSubscribed())){if(this._resolvePromises(),!y.recovered){if(d.length>0){let k=new Map;for(let P of u)k.set(P.key,P);for(let P of d)P.removed?k.delete(P.key):k.set(P.key,P);u=Array.from(k.values()),d=[]}this._mapPositionResets===g&&(this._recover=s,this._offset=n,this._epoch=c),this.emit("sync",{entries:u})}for(let k of d){if(!this._isSubscribed()||(this.emit("publication",k),!this._isSubscribed()))return;k.offset!==void 0&&this._mapPositionResets===g&&(this._offset=k.offset),this.emit("update",k)}this._isSubscribed()&&(this._mapPositionResets===g&&(this._offset=n),e.expires===!0&&(this._refreshTimeout=setTimeout(()=>this._refresh(),at(e.ttl))))}}_handleMapSubscribeError(i){if(this._inflight=!1,!!this._isSubscribing()&&i.code!==11){if(i.code===1){this._centrifuge._disconnect(3,"subscribe timeout",!0);return}if(this._mapStateBuffer=[],this._mapStreamBuffer=[],this._mapPhase=null,i.code===112&&this._mapUnrecoverableStrategy==="from_scratch"){this._debug("map subscribe: unrecoverable position, restarting from scratch"),this._prevValueMap=new Map,this._offset=null,this._epoch=null,this._recover=!1,this._scheduleResubscribe();return}this._subscribeError(i)}}_buildMapSubscribeCommand(i,e){let r={channel:this.channel,type:this._mapPresenceType||1,phase:i};return this._token&&(r.token=this._token),this._tagsFilter&&(r.tf=this._tagsFilter),this._delta&&(r.delta=this._delta),r.flag=1,i===2&&(this._mapPageSize>0&&(r.limit=this._mapPageSize),e&&(r.cursor=e),this._mapFlowEpoch?(r.offset=this._mapFlowOffset,r.epoch=this._mapFlowEpoch):this._data&&(r.data=this._data)),i===1&&(this._mapPageSize>0&&(r.limit=this._mapPageSize),r.offset=this._mapFlowOffset,r.epoch=this._mapFlowEpoch,this._mapFlowRecovering&&(r.recover=!0,this._mapStreamBuffer.length===0&&this._data&&(r.data=this._data))),{subscribe:r}}_getMapUpdateContext(i){let e={channel:this.channel,data:i.data,key:i.key||""};return i.removed===!0&&(e.removed=!0),i.offset!==void 0&&(e.offset=I(i.offset)),i.info&&(e.info=this._centrifuge._getJoinLeaveContext(i.info)),i.tags&&(e.tags=i.tags),e}_getSharedPollUpdateContext(i){let e={channel:this.channel,key:i.key||"",data:i.data};return i.removed===!0&&(e.removed=!0),i.version!==void 0&&(e.version=I(i.version)),e}},Dt=class extends vt{async publish(o){return await this._methodCall(),this._debounceMs>0?this._debouncedPublish("",o,!1):this._centrifuge.publish(this.channel,o)}async history(o){return await this._methodCall(),this._centrifuge.history(this.channel,o)}},bt=class extends vt{async publish(o,i){return await this._methodCall(),this._debounceMs>0?this._debouncedPublish(o,i,!0):this._centrifuge.mapPublish(this.channel,o,i)}async remove(o){return await this._methodCall(),this._cancelDebounce(o),this._centrifuge.mapRemove(this.channel,o)}},Ct=class extends vt{track(o,i){if(o.length===0)return;let e,r=i;typeof o[0]=="string"?e=o.map(s=>({key:s,version:0})):e=o;for(let c of e){let s=I(c.version),u=this._sharedPollTrackedItems.get(c.key);(u===void 0||s>u)&&this._sharedPollTrackedItems.set(c.key,s)}if(r!==void 0){this._addSharedPollSignature(e.map(c=>c.key),r),this._isSubscribed()&&!this._sharedPollReplayPending&&this._sendTrackRequest([{items:e,signature:r}]).catch(c=>{this._handleTrackError(c.error,c.keys)});return}if(!this._sharedPollGetSignature){this.emit("error",{type:"track",channel:this.channel,error:{code:14,message:"getSignature callback required for track(keys)"}});return}if(!this._isSubscribed()||this._sharedPollReplayPending)return;let t=e.map(c=>c.key),n=this._refreshGeneration;this._callAsync(()=>this._sharedPollGetSignature({keys:t})).then(c=>{if(n!==this._refreshGeneration||!this._isSubscribed())return;let s=new Set(c.keys),u=[];for(let y of t)if(!s.has(y)&&this._sharedPollTrackedItems.has(y)){if(this._sharedPollTrackedItems.delete(y),u.push(y),!this._isSubscribed())continue;this.emit("update",{channel:this.channel,key:y,data:null,removed:!0})}u.length>0&&this._sendUntrackRequest(u).catch(y=>{this.emit("error",{type:"untrack",channel:this.channel,error:y})}),this._sharedPollReplayRetryAttempts=0;let d=[];for(let y of c.keys){let g=this._sharedPollTrackedItems.get(y);g!==void 0&&d.push({key:y,version:g})}d.length!==0&&(this._addSharedPollSignature(c.keys,c.signature),this._sendTrackRequest([{items:d,signature:c.signature}]).catch(y=>{this._handleTrackError(y.error,y.keys)}))}).catch(c=>{n!==this._refreshGeneration||!this._isSubscribed()||this._emitError({type:"track",channel:this.channel,error:{code:14,message:c!==void 0?c.toString():"getSignature failed"}},()=>{n!==this._refreshGeneration||!this._isSubscribed()||this._scheduleSharedPollReplayRetry()})})}untrack(o){for(let i of o)this._sharedPollTrackedItems.delete(i);this._sharedPollSignatures=this._sharedPollSignatures.filter(i=>i.keys.some(e=>this._sharedPollTrackedItems.has(e))),this._isSubscribed()&&this._sendUntrackRequest(o).catch(i=>{this.emit("error",{type:"untrack",channel:this.channel,error:i})})}trackedKeys(){return new Set(this._sharedPollTrackedItems.keys())}};var It=class{constructor(o,i){this.endpoint=o,this.options=i,this._transport=null}name(){return"sockjs"}subName(){return"sockjs-"+this._transport.transport}emulation(){return!1}supported(){return this.options.sockjs!==null}initialize(o,i){this._transport=new this.options.sockjs(this.endpoint,null,this.options.sockjsOptions),this._transport.onopen=()=>{i.onOpen()},this._transport.onerror=e=>{i.onError(e)},this._transport.onclose=e=>{i.onClose(e)},this._transport.onmessage=e=>{i.onMessage(e.data)}}close(){this._transport!==null&&this._transport.close()}send(o){this._transport.send(o)}};var Lt=class{constructor(o,i){this.endpoint=o,this.options=i,this._transport=null}name(){return"websocket"}subName(){return"websocket"}emulation(){return!1}supported(){return this.options.websocket!==void 0&&this.options.websocket!==null}initialize(o,i){let e="";o==="protobuf"&&(e="centrifuge-protobuf"),e!==""?this._transport=new this.options.websocket(this.endpoint,e):this._transport=new this.options.websocket(this.endpoint),o==="protobuf"&&(this._transport.binaryType="arraybuffer"),this._transport.onopen=()=>{i.onOpen()},this._transport.onerror=r=>{i.onError(r)},this._transport.onclose=r=>{i.onClose(r)},this._transport.onmessage=r=>{i.onMessage(r.data)}}close(){this._transport!==null&&this._transport.close()}send(o){this._transport.send(o)}};var _t=class{constructor(){this._buf=new Uint8Array(0);this._start=0;this._end=0}push(o){let i=this._end-this._start;if(this._end+o.length>this._buf.length){if(i+o.length<=this._buf.length/2)this._buf.copyWithin(0,this._start,this._end);else{let e=new Uint8Array(Math.max(this._buf.length*2,i+o.length));e.set(this._buf.subarray(this._start,this._end)),this._buf=e}this._start=0,this._end=i}this._buf.set(o,this._end),this._end+=o.length}drain(o,i){for(;this._start<this._end;){let r=o(this._buf.subarray(this._start,this._end));if(!r.ok)break;let t=this._start+r.pos,n=this._buf.slice(this._start,t);this._start=t,i(n)}let e=this._end-this._start;this._buf.length>65536&&e<=this._buf.length/4?(this._buf=this._buf.slice(this._start,this._end),this._start=0,this._end=e):e===0&&(this._start=0,this._end=0)}},yt=class{constructor(){this._decoder=new TextDecoder;this._parts=[]}push(o,i){let e=this._decoder.decode(o,{stream:!0}),r=0,t=e.indexOf(`
`);for(;t!==-1;){this._parts.push(e.substring(r,t));let n=this._parts.join("");this._parts=[],r=t+1,i(n),t=e.indexOf(`
`,r)}r<e.length&&this._parts.push(e.substring(r))}};var Ft=class{constructor(o,i){this.endpoint=o,this.options=i,this._abortController=null,this._protocol="json"}name(){return"http_stream"}subName(){return"http_stream"}emulation(){return!0}_handleErrors(o){if(!o.ok)throw new Error(o.status);return o}_fetchEventTarget(o,i,e){let r=new EventTarget,t=o.options.fetch;return t(i,e).then(o._handleErrors).then(n=>{r.dispatchEvent(new Event("open"));let c=new yt,s=new _t,u=n.body.getReader();return new o.options.readableStream({start(d){function y(){return u.read().then(({done:g,value:k})=>{if(g){r.dispatchEvent(new Event("close")),d.close();return}try{o._protocol==="json"?c.push(k,P=>r.dispatchEvent(new MessageEvent("message",{data:P}))):(s.push(k),s.drain(P=>o.options.decoder.decodeReply(P),P=>r.dispatchEvent(new MessageEvent("message",{data:P}))))}catch(P){r.dispatchEvent(new Event("error",{detail:P})),r.dispatchEvent(new Event("close")),d.close();return}y()}).catch(function(g){r.dispatchEvent(new Event("error",{detail:g})),r.dispatchEvent(new Event("close")),d.close()})}return y()}})}).catch(n=>{r.dispatchEvent(new Event("error",{detail:n})),r.dispatchEvent(new Event("close"))}),r}supported(){return this.options.fetch!==null&&this.options.readableStream!==null&&typeof TextDecoder<"u"&&typeof AbortController<"u"&&typeof EventTarget<"u"&&typeof Event<"u"&&typeof MessageEvent<"u"&&typeof Error<"u"}initialize(o,i,e){this._protocol=o,this._abortController=new AbortController;let r,t;o==="json"?(r={Accept:"application/json","Content-Type":"application/json"},t=e):(r={Accept:"application/octet-stream","Content-Type":"application/octet-stream"},t=e);let n={method:"POST",headers:r,body:t,mode:"cors",credentials:"same-origin",signal:this._abortController.signal},c=this._fetchEventTarget(this,this.endpoint,n);c.addEventListener("open",()=>{i.onOpen()}),c.addEventListener("error",s=>{this._abortController.abort(),i.onError(s)}),c.addEventListener("close",()=>{this._abortController.abort(),i.onClose({code:4,reason:"connection closed"})}),c.addEventListener("message",s=>{i.onMessage(s.data)})}close(){this._abortController!==null&&this._abortController.abort()}send(o,i,e){let r,t,n={session:i,node:e,data:o};this._protocol==="json"?(r={"Content-Type":"application/json"},t=JSON.stringify(n)):(r={"Content-Type":"application/octet-stream"},t=this.options.encoder.encodeEmulationRequest(n));let c=this.options.fetch,s={method:"POST",headers:r,body:t,mode:"cors",credentials:"same-origin",signal:this._abortController.signal};c(this.options.emulationEndpoint,s).then(u=>{u&&(u.status===404||u.status>=500)&&this.close()},()=>{this.close()})}};var At=class{constructor(o,i){this.endpoint=o,this.options=i,this._protocol="json",this._transport=null,this._onClose=null,this._abortController=null}name(){return"sse"}subName(){return"sse"}emulation(){return!0}supported(){return this.options.eventsource!==null&&this.options.fetch!==null}initialize(o,i,e){typeof AbortController<"u"&&(this._abortController=new AbortController);let r;globalThis&&globalThis.document&&globalThis.document.baseURI?r=new URL(this.endpoint,globalThis.document.baseURI):r=new URL(this.endpoint),r.searchParams.append("cf_connect",e);let t={},n=new this.options.eventsource(r.toString(),t);this._transport=n;let c=this;n.onopen=function(){i.onOpen()},n.onerror=function(s){n.close(),i.onError(s),i.onClose({code:4,reason:"connection closed"})},n.onmessage=function(s){i.onMessage(s.data)},c._onClose=function(){i.onClose({code:4,reason:"connection closed"})}}close(){this._abortController!==null&&this._abortController.abort(),this._transport!==null&&this._transport.close(),this._onClose!==null&&this._onClose()}send(o,i,e){let r={session:i,node:e,data:o},t={"Content-Type":"application/json"},n=JSON.stringify(r),c=this.options.fetch,s=this._abortController!==null?this._abortController.signal:void 0,u={method:"POST",headers:t,body:n,mode:"cors",credentials:"same-origin",signal:s};c(this.options.emulationEndpoint,u).then(d=>{d&&(d.status===404||d.status>=500)&&this.close()},()=>{s&&s.aborted||this.close()})}};var Bt=class{constructor(o,i){this.endpoint=o,this.options=i,this._transport=null,this._stream=null,this._writer=null,this._protocol="json"}name(){return"webtransport"}subName(){return"webtransport"}emulation(){return!1}supported(){return this.options.webtransport!==void 0&&this.options.webtransport!==null}async initialize(o,i){let e;globalThis&&globalThis.document&&globalThis.document.baseURI?e=new URL(this.endpoint,globalThis.document.baseURI):e=new URL(this.endpoint),o==="protobuf"&&e.searchParams.append("cf_protocol","protobuf"),this._protocol=o;let r=new EventTarget;this._transport=new this.options.webtransport(e.toString()),this._transport.closed.then(()=>{i.onClose({code:4,reason:"connection closed"})}).catch(()=>{i.onClose({code:4,reason:"connection closed"})});try{await this._transport.ready}catch{this.close();return}let t;try{t=await this._transport.createBidirectionalStream()}catch{this.close();return}this._stream=t,this._writer=this._stream.writable.getWriter(),r.addEventListener("close",()=>{i.onClose({code:4,reason:"connection closed"})}),r.addEventListener("message",n=>{i.onMessage(n.data)}),this._startReading(r),i.onOpen()}async _startReading(o){let i=this._stream.readable.getReader(),e=new yt,r=new _t;try{for(;;){let{done:t,value:n}=await i.read();if(n&&n.length>0&&(this._protocol==="json"?e.push(n,c=>o.dispatchEvent(new MessageEvent("message",{data:c}))):(r.push(n),r.drain(c=>this.options.decoder.decodeReply(c),c=>o.dispatchEvent(new MessageEvent("message",{data:c}))))),t)break}}catch{o.dispatchEvent(new Event("close"))}}async close(){try{this._writer&&await this._writer.close(),this._transport.close()}catch{}}async send(o){let i;this._protocol==="json"?i=new TextEncoder().encode(o+`
`):i=o;try{await this._writer.write(i)}catch{this.close()}}};var ei=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,36,-1,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,-1,-1,-1,63,-1],$t=class{constructor(o){this.a=o,this.pos=0}haveBytes(){return this.pos<this.a.length}getByte(){let o=this.a[this.pos];if(this.pos++,this.pos>this.a.length)throw new RangeError("out of bounds");return o}getChar(){return String.fromCharCode(this.getByte())}getInt(){let o=0,i;for(;this.haveBytes()&&(i=ei[127&this.getByte()])>=0;)o=(o<<6)+i;return this.pos--,o>>>0}},Xt=class{constructor(){this.a=[]}toByteArray(o){return Array.isArray(o)?this.a:new Uint8Array(this.a)}putArray(o,i,e){for(let r=i;r<e;r++)this.a.push(o[r])}};function ni(l){let o=0,i=0,e=0,r=0,t=0,n=l.length;for(;n>=16;)o=o+l[t+0]|0,i=i+l[t+1]|0,e=e+l[t+2]|0,r=r+l[t+3]|0,o=o+l[t+4]|0,i=i+l[t+5]|0,e=e+l[t+6]|0,r=r+l[t+7]|0,o=o+l[t+8]|0,i=i+l[t+9]|0,e=e+l[t+10]|0,r=r+l[t+11]|0,o=o+l[t+12]|0,i=i+l[t+13]|0,e=e+l[t+14]|0,r=r+l[t+15]|0,t+=16,n-=16;for(;n>=4;)o=o+l[t+0]|0,i=i+l[t+1]|0,e=e+l[t+2]|0,r=r+l[t+3]|0,t+=4,n-=4;switch(r=((r+(e<<8)|0)+(i<<16)|0)+(o<<24)|0,n){case 3:r=r+(l[t+2]<<8)|0;case 2:r=r+(l[t+1]<<16)|0;case 1:r=r+(l[t+0]<<24)|0}return r>>>0}function Mt(l,o){let i=0,e=new $t(o),r=l.length,t=o.length,n=e.getInt();if(e.getChar()!==`
`)throw new Error("size integer not terminated by '\\n'");let c=new Xt;for(;e.haveBytes();){let s=e.getInt(),u;switch(e.getChar()){case"@":if(u=e.getInt(),e.haveBytes()&&e.getChar()!==",")throw new Error("copy command not terminated by ','");if(i+=s,i>n)throw new Error("copy exceeds output file size");if(u+s>r)throw new Error("copy extends past end of input");c.putArray(l,u,u+s);break;case":":if(i+=s,i>n)throw new Error("insert command gives an output larger than predicted");if(s>t)throw new Error("insert count exceeds size of delta");c.putArray(e.a,e.pos,e.pos+s),e.pos+=s;break;case";":{let d=c.toByteArray(l);if(s!==ni(d))throw new Error("bad checksum");if(i!==n)throw new Error("generated size does not match predicted size");return d}default:throw new Error("unknown delta operator")}}throw new Error("unterminated delta")}var kt=class{name(){return"json"}encodeCommands(o){return o.map(i=>JSON.stringify(i)).join(`
`)}decodeReplies(o){return o.split(`
`).filter(i=>i.trim()!=="").map(i=>JSON.parse(i))}applyDeltaIfNeeded(o,i){let e,r,t,n;if(o.delta){n=!0;let c=new TextEncoder().encode(o.data),s=Mt(i,c);e=JSON.parse(new TextDecoder().decode(s)),r=s,t=c.length}else n=!1,e=JSON.parse(o.data),r=new TextEncoder().encode(o.data),t=r.length;return{newData:e,newPrevValue:r,isDelta:n,wireBytes:t,fullBytes:r.length}}};var te=Tt(Kt()),ii={headers:{},token:"",getToken:null,data:null,getData:null,debug:!1,name:"js",version:"",fetch:null,readableStream:null,websocket:null,eventsource:null,sockjs:null,sockjsOptions:{},emulationEndpoint:"/emulation",minReconnectDelay:500,maxReconnectDelay:2e4,timeout:5e3,maxServerPingDelay:1e4,networkEventTarget:null,pageEventTarget:null},Ae="WebSocket constructor not found, make sure it is available globally or passed as a dependency in Centrifuge options",Qt=1e3,Yt=1e3;function Be(l){try{return l instanceof Error?l.message:String(l)}catch{return"value without a string form"}}var Z=class extends Error{constructor(o){super(o),this.name=this.constructor.name}},ft=class extends te.default{constructor(i,e){super();this._reconnectTimeout=null;this._connectTimeout=null;this._removedUnsubscribes={};this._pendingServerSubOffsets={};this._refreshTimeout=null;this._serverPingTimeout=null;this._handlerFailures=0;this.state="disconnected",this._transportIsOpen=!1,this._endpoint=i,this._emulation=!1,this._transports=[],this._currentTransportIndex=0,this._triedAllTransports=!1,this._transportWasOpen=!1,this._transport=null,this._transportId=0,this._deviceWentOffline=!1,this._transportClosed=!0,this._codec=new kt,this._reconnecting=!1,this._reconnectTimeout=null,this._connectTimeout=null,this._reconnectAttempts=0,this._client=null,this._session="",this._node="",this._subs={},this._serverSubs={},this._commandId=0,this._commands=[],this._batching=!1,this._refreshRequired=!1,this._refreshTimeout=null,this._callbacks={},this._token="",this._data=null,this._dispatchPromise=Promise.resolve(),this._serverPing=0,this._serverPingTimeout=null,this._sendPong=!1,this._promises={},this._promiseId=0,this._debugEnabled=!1,this._networkEvents=null,this._pageEvents=null,this._pageCached=!1,this._stateTransitions=0,this._disconnects=0,this._abortedTransportId=0,this._reconnectAttemptsResetPending=!1,this._config={...ii,...e},this._configure(),this._debugEnabled?(this.on("state",r=>{this._debug("client state",r.oldState,"->",r.newState)}),this.on("error",r=>{this._debug("client error",r)})):this.on("error",function(){Function.prototype()})}newSubscription(i,e){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let r=new Dt(this,i,e);return this._subs[i]=r,r}newMapSubscription(i,e){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let r=new bt(this,i,{token:e?.token,getToken:e?.getToken,data:e?.data,minResubscribeDelay:e?.minResubscribeDelay,maxResubscribeDelay:e?.maxResubscribeDelay,delta:e?.delta,tagsFilter:e?.tagsFilter,map:!0,mapPageSize:e?.pageSize,mapUnrecoverableStrategy:e?.unrecoverableStrategy});return this._subs[i]=r,r}newMapClientsSubscription(i,e){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let r=new bt(this,i,{token:e?.token,getToken:e?.getToken,data:e?.data,minResubscribeDelay:e?.minResubscribeDelay,maxResubscribeDelay:e?.maxResubscribeDelay,delta:e?.delta,tagsFilter:e?.tagsFilter,map:!0,mapPresenceType:2,mapPageSize:e?.pageSize,mapUnrecoverableStrategy:e?.unrecoverableStrategy});return this._subs[i]=r,r}newMapUsersSubscription(i,e){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let r=new bt(this,i,{token:e?.token,getToken:e?.getToken,data:e?.data,minResubscribeDelay:e?.minResubscribeDelay,maxResubscribeDelay:e?.maxResubscribeDelay,delta:e?.delta,tagsFilter:e?.tagsFilter,map:!0,mapPresenceType:3,mapPageSize:e?.pageSize,mapUnrecoverableStrategy:e?.unrecoverableStrategy});return this._subs[i]=r,r}newSharedPollSubscription(i,e){if(this.getSubscription(i)!==null)throw new Error("Subscription to the channel "+i+" already exists");let r=new Ct(this,i,{token:e?.token,getToken:e?.getToken,data:e?.data,minResubscribeDelay:e?.minResubscribeDelay,maxResubscribeDelay:e?.maxResubscribeDelay,delta:e?.delta,sharedPoll:!0,sharedPollGetSignature:e?.getSignature});return this._subs[i]=r,r}getSubscription(i){return this._getSub(i)}getMapSubscription(i){return this._getSub(i)}getSharedPollSubscription(i){return this._getSub(i)}removeSubscription(i){i&&this._subs[i.channel]===i&&(delete this._subs[i.channel],i._removed=!0,i.state!=="unsubscribed"&&i.unsubscribe(),this._recordRemovedUnsubscribe(i))}removeMapSubscription(i){this.removeSubscription(i)}removeSharedPollSubscription(i){this.removeSubscription(i)}subscriptions(){return this._subs}mapSubscriptions(){let i={};for(let[e,r]of Object.entries(this._subs))r.type==="map"&&(i[e]=r);return i}sharedPollSubscriptions(){let i={};for(let[e,r]of Object.entries(this._subs))r.type==="shared_poll"&&(i[e]=r);return i}async ready(i){switch(this.state){case"disconnected":throw{code:3,message:"client disconnected"};case"connected":return;default:return new Promise((e,r)=>{let t=this._nextPromiseId(),n={resolve:e,reject:r};i&&(n.timeout=setTimeout(()=>{delete this._promises[t],r({code:1,message:"timeout"})},i)),this._promises[t]=n})}}connect(){if(this._isConnected()){this._debug("connect called when already connected");return}if(this._isConnecting()){this._debug("connect called when already connecting");return}this._debug("connect called"),this._validateTransportConfig(),this._reconnectAttempts=0,this._startConnecting()}disconnect(){this._disconnect(0,"disconnect called",!1)}setToken(i){this._token=i,this._config.getToken===null&&(this._refreshRequired=!1)}setData(i){this._data=i}setHeaders(i){this._config.headers=i}async send(i){let e={send:{data:i}};if(await this._methodCall(),!this._transportSendCommands([e]))throw this._createErrorObject(10,"transport write error")}async rpc(i,e){let r={rpc:{method:i,data:e}};return await this._methodCall(),{data:(await this._callPromise(r,n=>n.rpc)).data}}async publish(i,e){let r={publish:{channel:i,data:e}};return await this._methodCall(),await this._callPromise(r,()=>({})),{}}async mapPublish(i,e,r){let t={publish:{channel:i,type:1,key:e,data:r}};return await this._methodCall(),await this._callPromise(t,()=>({})),{}}async mapRemove(i,e){let r={publish:{channel:i,type:1,key:e,removed:!0}};return await this._methodCall(),await this._callPromise(r,()=>({})),{}}async history(i,e){let r={history:this._getHistoryRequest(i,e)};await this._methodCall();let t=await this._callPromise(r,c=>c.history),n=[];if(t.publications)for(let c=0;c<t.publications.length;c++)n.push(this._getPublicationContext(i,t.publications[c]));return{publications:n,epoch:t.epoch||"",offset:I(t.offset)}}async presence(i){let e={presence:{channel:i}};await this._methodCall();let t=(await this._callPromise(e,n=>n.presence)).presence;for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let c=t[n],s=c.conn_info,u=c.chan_info;s&&(c.connInfo=s),u&&(c.chanInfo=u)}return{clients:t}}async presenceStats(i){let e={presence_stats:{channel:i}};await this._methodCall();let r=await this._callPromise(e,t=>t.presence_stats);return{numUsers:r.num_users,numClients:r.num_clients}}startBatching(){this._batching=!0}stopBatching(){let i=this;Promise.resolve().then(function(){Promise.resolve().then(function(){i._batching=!1,i._flush()})})}_debug(...i){this._debugEnabled&&Ie("debug",i)}_codecName(){return this._codec.name()}_formatOverride(){}_configure(){if(!("Promise"in globalThis))throw new Error("Promise polyfill required");if(!this._endpoint)throw new Error("endpoint configuration required");if(this._config.token!==null&&(this._token=this._config.token),this._config.data!==null&&(this._data=this._config.data),this._codec=new kt,this._formatOverride(),(this._config.debug===!0||Fe("centrifuge.debug"))&&(this._debugEnabled=!0),this._debug("config",this._config),typeof this._endpoint!="string")if(Array.isArray(this._endpoint)){this._transports=this._endpoint,this._emulation=!0;for(let i in this._transports)if(this._transports.hasOwnProperty(i)){let e=this._transports[i];if(!e.endpoint||!e.transport)throw new Error("malformed transport configuration");let r=e.transport;if(["websocket","http_stream","sse","sockjs","webtransport"].indexOf(r)<0)throw new Error("unsupported transport name: "+r)}}else throw new Error("unsupported url configuration type: only string or array of objects are supported")}_setState(i){if(this.state!==i){this._reconnecting=!1;let e=this.state;this.state=i;let r=++this._stateTransitions;return i==="connecting"?(this._setNetworkEvents(),this._setPageEvents()):i==="disconnected"&&(this._clearNetworkEvents(),this._clearPageEvents()),this.emit("state",{newState:i,oldState:e}),r}return 0}_transitionSuperseded(i){return i!==0&&this._stateTransitions!==i}_isDisconnected(){return this.state==="disconnected"}_isConnecting(){return this.state==="connecting"}_isConnected(){return this.state==="connected"}_nextCommandId(){return++this._commandId}_setNetworkEvents(){if(this._networkEvents!==null)return;let i=null;if(this._config.networkEventTarget!==null?i=this._config.networkEventTarget:typeof globalThis.addEventListener<"u"&&(i=globalThis),i){let e=()=>{this._debug("offline event triggered"),(this.state==="connected"||this.state==="connecting")&&(this._deviceWentOffline=!0,this._disconnect(1,"transport closed",!0))},r=()=>{this._debug("online event triggered");let t=this._deviceWentOffline;this._deviceWentOffline=!1,this.state==="connecting"&&(t&&!this._transportClosed&&(this._abortedTransportId=this._transportId,this._disconnect(1,"transport closed",!0)),this._clearReconnectTimeout(),this._startReconnecting())};i.addEventListener("offline",e),i.addEventListener("online",r),this._networkEvents={target:i,onOffline:e,onOnline:r}}}_clearNetworkEvents(){if(this._networkEvents===null)return;let{target:i,onOffline:e,onOnline:r}=this._networkEvents;if(!ut(i.removeEventListener)){this._debug("network event target has no removeEventListener, listeners kept");return}i.removeEventListener("offline",e),i.removeEventListener("online",r),this._networkEvents=null}_setPageEvents(){if(this._pageEvents!==null)return;let i=null;if(this._config.pageEventTarget!==null?i=this._config.pageEventTarget:typeof globalThis.addEventListener<"u"&&(i=globalThis),!i)return;let e=t=>{t.persisted&&(this._debug("page entered back/forward cache"),(this.state==="connected"||this.state==="connecting")&&(this._pageCached=!0,this._disconnect(1,"page entered back/forward cache",!0)))},r=t=>{if(!t.persisted)return;this._debug("page restored from back/forward cache");let n=this._pageCached;this._pageCached=!1,!(!n||this.state!=="connecting")&&(this._clearReconnectTimeout(),this._startReconnecting())};i.addEventListener("pagehide",e),i.addEventListener("pageshow",r),this._pageEvents={target:i,onPageHide:e,onPageShow:r}}_clearPageEvents(){if(this._pageEvents===null)return;let{target:i,onPageHide:e,onPageShow:r}=this._pageEvents;if(!ut(i.removeEventListener)){this._debug("page event target has no removeEventListener, listeners kept");return}i.removeEventListener("pagehide",e),i.removeEventListener("pageshow",r),this._pageEvents=null}_getReconnectDelay(){let i=et(this._reconnectAttempts,this._config.minReconnectDelay,this._config.maxReconnectDelay);return this._reconnectAttempts+=1,i}_resetReconnectAttemptsIfPending(){this._reconnectAttemptsResetPending&&(this._reconnectAttemptsResetPending=!1,this._reconnectAttempts=0)}_clearOutgoingRequests(){for(let i in this._callbacks)if(this._callbacks.hasOwnProperty(i)){let e=this._callbacks[i];clearTimeout(e.timeout);let r=e.errback;if(!r)continue;r({error:this._createErrorObject(11,"connection closed")})}this._callbacks={}}_clearConnectedState(){this._client=null,this._clearServerPingTimeout(),this._clearRefreshTimeout();for(let i in this._subs){if(!this._subs.hasOwnProperty(i))continue;let e=this._subs[i];e.state==="subscribed"&&e._setSubscribing(1,"transport closed")}for(let i in this._serverSubs)this._serverSubs.hasOwnProperty(i)&&this._serverSubs[i].subscribed&&(this._serverSubs[i].subscribed=!1,this.emit("subscribing",{channel:i}))}_handleWriteError(i){for(let e of i){let r=e.id;if(!(r in this._callbacks))continue;let t=this._callbacks[r];clearTimeout(this._callbacks[r].timeout),delete this._callbacks[r];let n=t.errback;n({error:this._createErrorObject(10,"transport write error")})}}_transportSendCommands(i){if(!i.length)return!0;if(!this._transport)return!1;try{this._transport.send(this._codec.encodeCommands(i),this._session,this._node)}catch(e){return this._debug("error writing commands",e),this._handleWriteError(i),!1}return!0}_advanceTransportIndex(){this._currentTransportIndex++,this._currentTransportIndex>=this._transports.length&&(this._triedAllTransports=!0,this._currentTransportIndex=0)}_resolveTransportDeps(){let i;this._config.websocket!==null?i=this._config.websocket:typeof globalThis.WebSocket!="function"&&typeof globalThis.WebSocket!="object"||(i=globalThis.WebSocket);let e=null;this._config.sockjs!==null?e=this._config.sockjs:typeof globalThis.SockJS<"u"&&(e=globalThis.SockJS);let r=null;this._config.eventsource!==null?r=this._config.eventsource:typeof globalThis.EventSource<"u"&&(r=globalThis.EventSource);let t=null;this._config.fetch!==null?t=this._config.fetch:typeof globalThis.fetch<"u"&&(t=globalThis.fetch);let n=null;return this._config.readableStream!==null?n=this._config.readableStream:typeof globalThis.ReadableStream<"u"&&(n=globalThis.ReadableStream),{websocket:i,sockjs:e,eventsource:r,fetchFunc:t,readableStream:n}}_createTransport(i,e,r){switch(i){case"websocket":return new Lt(e,{websocket:r.websocket});case"webtransport":return new Bt(e,{webtransport:globalThis.WebTransport,decoder:this._codec,encoder:this._codec});case"http_stream":return new Ft(e,{fetch:r.fetchFunc,readableStream:r.readableStream,emulationEndpoint:this._config.emulationEndpoint,decoder:this._codec,encoder:this._codec});case"sse":return new At(e,{eventsource:r.eventsource,fetch:r.fetchFunc,emulationEndpoint:this._config.emulationEndpoint});case"sockjs":return new It(e,{sockjs:r.sockjs,sockjsOptions:this._config.sockjsOptions});default:throw new Error("unknown transport "+i)}}_validateTransportConfig(){let i=this._resolveTransportDeps();if(!this._emulation){if(Ce(this._endpoint,"http"))throw new Error("Provide explicit transport endpoints configuration in case of using HTTP (i.e. using array of TransportEndpoint instead of a single string), or use ws(s):// scheme in an endpoint if you aimed using WebSocket transport");if(!this._createTransport("websocket",this._endpoint,i).supported())throw new Error(Ae);return}for(let e of this._transports)if(this._createTransport(e.transport,e.endpoint,i).supported())return;throw new Error("no supported transport found")}_initializeTransport(){let i=this._resolveTransportDeps(),e=null;if(this._emulation){this._currentTransportIndex>=this._transports.length&&(this._triedAllTransports=!0,this._currentTransportIndex=0);for(let P=0;P<this._transports.length;P++){let R=this._transports[this._currentTransportIndex];this._debug("trying "+R.transport+" transport");let Q=this._createTransport(R.transport,R.endpoint,i);if(Q.supported()){e=Q;break}this._debug(R.transport+" transport not available"),this._advanceTransportIndex()}}else{this._debug("client will use websocket");let P=this._createTransport("websocket",this._endpoint,i);P.supported()&&(e=P)}if(e===null){let P=this._emulation?"no supported transport found":Ae;this._debug(P),this._disconnect(1,"transport closed",!0),this.emit("error",{type:"transport",error:{code:2,message:P}});return}this._transport=e;let r=this,t=this._transport,n=this._nextTransportId();r._debug("id of transport",n);let c=!1,s=[];if(this._transport.emulation()){let P=r._sendConnect(!0);s.push(P)}this._transportClosed=!1;let u=function(P){if(r._transportId!=n){r._debug("failure of non-actual transport",P);return}r._debug(t.name(),"transport failed:",P),r._emulation&&!r._transportWasOpen&&r._advanceTransportIndex(),r._abortedTransportId=n,r._disconnect(1,"transport closed",!0),r.emit("error",{type:"transport",error:{code:2,message:P},transport:t.name()})};this._clearConnectTimeout();let d=Date.now()+this._config.timeout;this._connectTimeout=setTimeout(function(){let P=Date.now()-d>=Qt;r._connectTimeout=setTimeout(function(){r._connectTimeout=null,u("connect timeout")},P?Yt:0)},this._config.timeout);let y={onOpen:function(){if(r._transportId!=n){r._debug("open callback from non-actual transport");try{t.close()}catch(P){r._debug("error closing transport",P)}return}if(r._clearConnectTimeout(),c=!0,r._debug(t.subName(),"transport open"),!t.emulation()){r._transportIsOpen=!0,r._transportWasOpen=!0,r.startBatching();try{r._sendConnect(!1),r._sendSubscribeCommands()}catch(P){r._reportDispatchError(P)}finally{r.stopBatching()}r.emit("__centrifuge_debug:connect_frame_sent",{})}},onError:function(P){if(r._transportId!=n){r._debug("error callback from non-actual transport");return}r._debug("transport level error",P)},onClose:function P(R,Q){if(r._transportId!=n){r._debug("close callback from non-actual transport");return}if(!Q&&(t.emulation()||t.name()==="webtransport")){r._dispatchPromise.then(()=>P(R,!0));return}r._clearConnectTimeout(),r._debug(t.subName(),"transport closed"),r._transportClosed=!0,r._transportIsOpen=!1;let C="connection closed",q=!0,x=0;if(R&&"code"in R&&R.code&&(x=R.code),R&&R.reason)try{let tt=JSON.parse(R.reason);C=tt.reason,q=tt.reconnect}catch{C=R.reason,(x>=3500&&x<4e3||x>=4500&&x<5e3)&&(q=!1)}x<3e3?(x===1009?(x=3,C="message size limit exceeded",q=!1):(x=1,C="transport closed"),r._emulation&&!r._transportWasOpen&&r._advanceTransportIndex()):r._transportWasOpen=!0;let V=function(){r._reconnecting=!1,r._disconnect(x,C,q)};r._isConnecting()&&!c?(r._abortedTransportId=n,r._emitError({type:"transport",error:{code:2,message:"transport closed"},transport:t.name()},V)):V()},onMessage:function(P){if(r._transportId!=n){r._debug("message from non-actual transport");return}r._dataReceived(P,n)}},g=function(P){r._debug("error initializing transport",P),u(P instanceof Error?P.message:String(P))},k;try{k=t.initialize(this._codecName(),y,this._codec.encodeCommands(s))}catch(P){g(P);return}k&&ut(k.then)&&k.then(null,g),r.emit("__centrifuge_debug:transport_initialized",{})}_sendConnect(i){let e=this._constructConnectCommand(),r=this,t=this._transportId,n=this._token;return this._call(e,i).then(c=>{try{r._connectResponse(c.reply.connect)}catch(s){r._dispatchFailed(s)}finally{c.next&&c.next()}},c=>{try{t===r._abortedTransportId?r._debug("connect command of a transport aborted by the client rejected"):r._connectError(c.error,r._transportId!==t,c.next!==void 0,n)}catch(s){r._rejectionFailed(s,c)}finally{c.next&&c.next()}}),e}_startReconnecting(){if(this._debug("start reconnecting"),!this._isConnecting()){this._debug("stop reconnecting: client not in connecting state");return}if(this._reconnecting){this._debug("reconnect already in progress, return from reconnect routine");return}if(this._transportClosed===!1){this._debug("waiting for transport close");return}this._reconnecting=!0;let i=this._disconnects,e=this._token==="",r=this._refreshRequired||e&&this._config.getToken!==null,t=!1,n=!1;if(!r){this._config.getData?this._getData().then(s=>{n=!0,!this._attemptAborted(i)&&(this._data=s,this._initializeTransport())}).catch(s=>this._handleGetDataError(s,i,n)):this._initializeTransport();return}let c=this;this._getToken().then(function(s){if(t=!0,!c._attemptAborted(i)){if(s==null||s==null){c._failUnauthorized();return}c._token=s,c._debug("connection token refreshed"),c._config.getData?c._getData().then(function(u){n=!0,!c._attemptAborted(i)&&(c._data=u,c._initializeTransport())}).catch(u=>c._handleGetDataError(u,i,n)):c._initializeTransport()}}).catch(function(s){if(c._attemptAborted(i)){t&&c._reportDispatchError(s);return}if(s instanceof Z){c._failUnauthorized();return}c._emitError({type:"connectToken",error:{code:5,message:s!==void 0?s.toString():""}},()=>{let u=c._getReconnectDelay();c._debug("error on getting connection token, reconnect after "+u+" milliseconds",s),c._reconnecting=!1,c._reconnectTimeout=setTimeout(()=>{c._startReconnecting()},u)})})}_emitError(i,e){let r=this._disconnects;try{this.emit("error",i)}finally{this._disconnects===r&&e()}}_attemptAborted(i){return!this._isConnecting()||this._disconnects!==i}_handleGetDataError(i,e,r){if(this._attemptAborted(e)){r&&this._reportDispatchError(i);return}if(i instanceof Z){this._failUnauthorized();return}this._emitError({type:"connectData",error:{code:12,message:i?.toString()||""}},()=>{let t=this._getReconnectDelay();this._debug("error on getting connect data, reconnect after "+t+" milliseconds",i),this._reconnecting=!1,this._reconnectTimeout=setTimeout(()=>{this._startReconnecting()},t)})}_connectError(i,e,r,t){this.state==="connecting"&&(i.code===109&&t===this._token&&(this._refreshRequired=!0),i.code<100||i.temporary===!0||i.code===109?this._emitError({type:"connect",error:i},()=>{e||(r&&(this._transportWasOpen=!0),!r&&this._emulation&&!this._transportWasOpen&&this._advanceTransportIndex(),this._debug("closing transport due to connect error"),this._disconnect(i.code,i.message,!0))}):e||this._disconnect(i.code,i.message,!1))}_scheduleReconnect(){if(!this._isConnecting())return;let i=!1;this._emulation&&!this._transportWasOpen&&!this._triedAllTransports&&(i=!0);let e=i?0:this._getReconnectDelay();this._debug("reconnect after "+e+" milliseconds"),this._clearReconnectTimeout(),this._reconnectTimeout=setTimeout(()=>{this._startReconnecting()},e)}_constructConnectCommand(){let i={};this._token&&(i.token=this._token),this._data&&(i.data=this._data),this._config.name&&(i.name=this._config.name),this._config.version&&(i.version=this._config.version),Object.keys(this._config.headers).length>0&&(i.headers=this._config.headers);let e={},r=!1;for(let t in this._serverSubs)if(this._serverSubs.hasOwnProperty(t)&&this._serverSubs[t].recoverable){r=!0;let n={recover:!0},c=this._pendingServerSubOffsets[t],s=c??this._serverSubs[t].offset;s&&(n.offset=s),this._serverSubs[t].epoch&&(n.epoch=this._serverSubs[t].epoch),e[t]=n}return r&&(i.subs=e),{connect:i}}_getHistoryRequest(i,e){let r={channel:i};return e!==void 0&&(e.since&&(r.since={offset:e.since.offset},e.since.epoch&&(r.since.epoch=e.since.epoch)),e.limit!==void 0&&(r.limit=e.limit),e.reverse===!0&&(r.reverse=!0)),r}_methodCall(){return this._isConnected()?Promise.resolve():new Promise((i,e)=>{let r=this._nextPromiseId(),t=setTimeout(()=>{delete this._promises[r],e({code:1,message:"timeout"})},this._config.timeout);this._promises[r]={timeout:t,resolve:i,reject:e}})}_callPromise(i,e){return new Promise((r,t)=>{this._call(i,!1).then(n=>{try{r(e(n.reply))}catch(c){t(c)}finally{n.next?.()}},n=>{t(n.error),n.next?.()})})}_dataReceived(i,e=this._transportId){let r;try{r=this._codec.decodeReplies(i)}catch(t){this._debug("error decoding received data",t),this._emulation&&!this._transportWasOpen&&this._advanceTransportIndex(),this._disconnect(1,"transport closed",!0);return}this._serverPing>0&&r.length>0&&this._waitServerPing(),this._dispatchPromise=this._dispatchPromise.then(()=>new Promise(t=>{this._dispatchSynchronized(r,t,e)}))}_dispatchSynchronized(i,e,r){let t=Promise.resolve();for(let n in i)i.hasOwnProperty(n)&&(t=t.then(()=>{if(this._transportId===r)return this._dispatchReply(i[n])}).catch(c=>{this._dispatchFailed(c)}));t.then(()=>{e()})}emit(i,...e){try{return te.default.prototype.emit.call(this,i,...e)}catch(r){return this._handlerFailed(r),!0}}_handlerFailed(i){this._handlerFailures++,this._reportDispatchError(i),this._disconnect(2,`exception in event handler: ${Be(i)}`,!1)}_dispatchFailed(i){this._reportDispatchError(i),this._disconnect(2,`exception during message handling: ${Be(i)}`,!1)}_reportDispatchError(i){this._debug("error dispatching reply",i),Promise.reject(i)}_rejectionFailed(i,e){e.next!==void 0?this._dispatchFailed(i):this._reportDispatchError(i)}_dispatchReply(i){let e,r=new Promise(n=>{e=n});if(i==null)return this._debug("dispatch: got undefined or null reply"),e(),r;let t=i.id;return t&&t>0?this._handleReply(i,e):i.push?this._handlePush(i.push,e):this._handleServerPing(e),r}_call(i,e){return new Promise((r,t)=>{i.id=this._nextCommandId(),this._registerCall(i.id,r,t),e||this._addCommand(i)})}_startConnecting(){this._debug("start connecting");let i=this.state!=="connecting"?this._stateTransitions+1:0;try{this._setState("connecting"),i&&!this._transitionSuperseded(i)&&this.emit("connecting",{code:0,reason:"connect called"})}finally{this._transitionSuperseded(i)||(this._client=null,this._startReconnecting())}}_disconnect(i,e,r){if(i===3014){this._config.getToken!==null&&(this._token="",this._refreshRequired=!0);for(let u in this._subs)this._subs.hasOwnProperty(u)&&this._subs[u]._invalidateState();for(let u in this._serverSubs)this._serverSubs.hasOwnProperty(u)&&(this._serverSubs[u].offset=0,this._serverSubs[u].epoch="_")}if(this._isDisconnected()){r||this._rejectPromises({code:3,message:"disconnected"});return}let t=this.state,n=r?"connecting":"disconnected";if(this._transportIsOpen=!1,this._reconnecting=!1,t==="connecting"&&this._clearReconnectTimeout(),this._clearConnectTimeout(),this._nextTransportId(),this._disconnects++,this._transport){this._debug("closing existing transport");let u=this._transport;this._transport=null;try{u.close()}catch(d){this._debug("error closing transport",d)}this._transportClosed=!0}else this._debug("no transport to close");this._reconnectAttemptsResetPending=!1,this._commands=[],this._clearOutgoingRequests(),r||(this._rejectPromises({code:3,message:"disconnected"}),this._deviceWentOffline=!1,this._pageCached=!1);let c={code:i,reason:e},s=this.state!==n?this._stateTransitions+1:0;try{try{this._setState(n)}finally{!r&&!this._transitionSuperseded(s)&&this._rejectPromises({code:3,message:"disconnected"}),t==="connected"&&this._clearConnectedState()}s&&!this._transitionSuperseded(s)&&(r?this.emit("connecting",c):this.emit("disconnected",c))}finally{r&&!this._transitionSuperseded(s)&&this._scheduleReconnect()}}_failUnauthorized(){this._disconnect(1,"unauthorized",!1)}_getToken(){if(this._debug("get connection token"),!this._config.getToken){try{this.emit("error",{type:"configuration",error:{code:12,message:"token expired but no getToken function set in the configuration"}})}catch(i){this._reportDispatchError(i)}return Promise.reject(new Z(""))}try{return Promise.resolve(this._config.getToken({}))}catch(i){return Promise.reject(i)}}_getData(){try{return Promise.resolve(this._config.getData())}catch(i){return Promise.reject(i)}}_refresh(){let i=this._client,e=this,r=!1;this._getToken().then(function(t){if(r=!0,i!==e._client)return;if(!t){e._failUnauthorized();return}if(e._token=t,e._debug("connection token refreshed"),!e._isConnected())return;let n={refresh:{token:e._token}};e._call(n,!1).then(c=>{try{e._refreshResponse(c.reply.refresh)}catch(s){e._dispatchFailed(s)}finally{c.next&&c.next()}},c=>{try{i===e._client&&e._refreshError(c.error)}catch(s){e._rejectionFailed(s,c)}finally{c.next&&c.next()}})}).catch(function(t){if(i!==e._client||!e._isConnected()){r&&e._reportDispatchError(t);return}if(t instanceof Z){e._failUnauthorized();return}e._emitError({type:"refreshToken",error:{code:6,message:t!==void 0?t.toString():""}},()=>{e._refreshTimeout=setTimeout(()=>e._refresh(),e._getRefreshRetryDelay())})})}_refreshError(i){i.code<100||i.temporary===!0?this._emitError({type:"refresh",error:i},()=>{this._refreshTimeout=setTimeout(()=>this._refresh(),this._getRefreshRetryDelay())}):this._disconnect(i.code,i.message,!1)}_getRefreshRetryDelay(){return et(0,5e3,1e4)}_refreshResponse(i){this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),i.expires&&(i.client&&(this._client=i.client),this._refreshTimeout=setTimeout(()=>this._refresh(),at(i.ttl)))}_recordRemovedUnsubscribe(i){let e=i.channel,r=this._removedUnsubscribes[e],t=i._unsubPromise,n=r?Promise.all([r,t]).then(()=>{}):t;this._removedUnsubscribes[e]=n,n.then(()=>{this._removedUnsubscribes[e]===n&&delete this._removedUnsubscribes[e]})}_removedSubscriptionUnsubscribed(i){return this._removedUnsubscribes[i]||Promise.resolve()}_unsubscribe(i){if(!this._transportIsOpen)return Promise.resolve();let r={unsubscribe:{channel:i.channel}},t=this,n=this._transportId;return new Promise((s,u)=>{this._call(r,!1).then(d=>{s(),d.next&&d.next()},d=>{if(s(),d.next&&d.next(),t._transportId!==n){t._debug("unsubscribe command of a closed transport rejected");return}try{t._disconnect(4,"unsubscribe error",!0)}catch(y){t._rejectionFailed(y,d)}})})}_getSub(i,e){if(e&&e>0){for(let t in this._subs)if(this._subs.hasOwnProperty(t)){let n=this._subs[t];if(n._id===e)return n}return null}let r=this._subs[i];return r||null}_isServerSub(i){return this._serverSubs[i]!==void 0}_getSubForPush(i,e){let r=this._getSub(i,e);return r&&i&&this._isServerSub(i)&&!r._isSubscribed()?null:r}_sendSubscribeCommands(){let i=[];for(let e in this._subs){if(!this._subs.hasOwnProperty(e))continue;let r=this._subs[e];if(r._inflight!==!0&&r._resubscribeTimeout===null&&r.state==="subscribing"){let t=r._subscribe();t&&i.push(t)}}return i}_connectResponse(i){if(this._transportIsOpen=!0,this._transportWasOpen=!0,this._transport!==null&&this._transport.emulation()?this._reconnectAttemptsResetPending=!0:this._reconnectAttempts=0,this._refreshRequired=!1,this._deviceWentOffline=!1,this._pageCached=!1,this._isConnected())return;this._client=i.client;let e=this._setState("connected");if(this._transitionSuperseded(e))return;this._refreshTimeout&&clearTimeout(this._refreshTimeout),i.expires&&(this._refreshTimeout=setTimeout(()=>this._refresh(),at(i.ttl))),this._session=i.session,this._node=i.node,this.startBatching(),this._sendSubscribeCommands(),this.stopBatching();let r={client:i.client,transport:this._transport.subName()};i.data&&(r.data=i.data),this.emit("connected",r),!this._transitionSuperseded(e)&&(this._resolvePromises(),this._processServerSubs(i.subs||{},e),i.ping&&i.ping>0?(this._serverPing=i.ping*1e3,this._sendPong=i.pong===!0,this._waitServerPing()):this._serverPing=0)}_processServerSubs(i,e){for(let r in i){if(!i.hasOwnProperty(r)||this._transitionSuperseded(e))continue;let t=i[r];this._serverSubs[r]={offset:I(t.offset),epoch:t.epoch,recoverable:t.recoverable||!1,subscribed:!0};let n=this._getSubscribeContext(r,t);this.emit("subscribed",n)}for(let r in i){if(!i.hasOwnProperty(r))continue;let t=i[r];if(t.recovered){let n=t.publications||[];for(let c=0;c<n.length&&!this._transitionSuperseded(e);c++)this._handlePublication(r,n[c])}}for(let r in this._serverSubs)this._serverSubs.hasOwnProperty(r)&&(i[r]||(this.emit("unsubscribed",{channel:r}),delete this._serverSubs[r]))}_clearRefreshTimeout(){this._refreshTimeout!==null&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null)}_clearReconnectTimeout(){this._reconnectTimeout!==null&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=null)}_clearConnectTimeout(){this._connectTimeout!==null&&(clearTimeout(this._connectTimeout),this._connectTimeout=null)}_clearServerPingTimeout(){this._serverPingTimeout!==null&&(clearTimeout(this._serverPingTimeout),this._serverPingTimeout=null)}_waitServerPing(){if(this._config.maxServerPingDelay===0||!this._isConnected())return;this._clearServerPingTimeout();let i=this._serverPing+this._config.maxServerPingDelay,e=Date.now()+i;this._serverPingTimeout=setTimeout(()=>{if(!this._isConnected())return;let r=Date.now()-e>=Qt;this._serverPingTimeout=setTimeout(()=>{this._isConnected()&&this._disconnect(2,"no ping",!0)},r?Yt:0)},i)}_getSubscribeContext(i,e){let r={channel:i,positioned:!1,recoverable:!1,wasRecovering:!1,recovered:!1,hasRecoveredPublications:!1};e.recovered&&(r.recovered=!0),e.positioned&&(r.positioned=!0),e.recoverable&&(r.recoverable=!0),e.was_recovering&&(r.wasRecovering=!0);let t="";"epoch"in e&&(t=e.epoch);let n=0;return"offset"in e&&(n=I(e.offset)),(r.positioned||r.recoverable)&&(r.streamPosition={offset:n,epoch:t}),Array.isArray(e.publications)&&e.publications.length>0&&(r.hasRecoveredPublications=!0),e.data&&(r.data=e.data),r}_handleReply(i,e){this._resetReconnectAttemptsIfPending();let r=i.id;if(!(r in this._callbacks)){e();return}let t=this._callbacks[r];if(clearTimeout(this._callbacks[r].timeout),delete this._callbacks[r],Le(i)){let n=t.errback;if(!n){e();return}let c={code:i.error.code,message:i.error.message||"",temporary:i.error.temporary||!1};n({error:c,next:e})}else{let n=t.callback;if(!n)return;n({reply:i,next:e})}}_handleJoin(i,e,r){let t=this._getSubForPush(i,r);if(!t){if(i&&this._isServerSub(i)){let n={channel:i,info:this._getJoinLeaveContext(e.info)};this.emit("join",n)}return}if(!t._isSubscribed()){this._debug("join for a subscription that is not subscribed",i);return}t._handleJoin(e)}_handleLeave(i,e,r){let t=this._getSubForPush(i,r);if(!t){if(i&&this._isServerSub(i)){let n={channel:i,info:this._getJoinLeaveContext(e.info)};this.emit("leave",n)}return}if(!t._isSubscribed()){this._debug("leave for a subscription that is not subscribed",i);return}t._handleLeave(e)}_handleUnsubscribe(i,e){let r=this._getSubForPush(i,0);if(!r){i&&this._isServerSub(i)&&(delete this._serverSubs[i],this.emit("unsubscribed",{channel:i}));return}if(!r._isSubscribed()){this._debug("unsubscribe push for a previous subscription",i);return}e.code<2500?r._setUnsubscribed(e.code,e.reason,!1):(e.code===2502&&r._invalidateState(),r._setSubscribing(e.code,e.reason))}_handleSubscribe(i,e){this._serverSubs[i]={offset:I(e.offset),epoch:e.epoch,recoverable:e.recoverable||!1,subscribed:!0},this.emit("subscribed",this._getSubscribeContext(i,e))}_handleDisconnect(i){this._transportWasOpen=!0;let e=i.code,r=!0;(e>=3500&&e<4e3||e>=4500&&e<5e3)&&(r=!1),this._disconnect(e,i.reason,r)}_getPublicationContext(i,e){let r={channel:i,data:e.data};return rt(e.offset)&&(r.offset=I(e.offset)),e.info&&(r.info=this._getJoinLeaveContext(e.info)),e.tags&&(r.tags=e.tags),r}_getJoinLeaveContext(i){let e={client:i.client,user:i.user},r=i.conn_info;r&&(e.connInfo=r);let t=i.chan_info;return t&&(e.chanInfo=t),e}_handlePublication(i,e,r){let t=this._getSubForPush(i,r);if(!t){if(i&&this._isServerSub(i)){let n=this._getPublicationContext(i,e);this._pendingServerSubOffsets[i]=rt(e.offset)?I(e.offset):null;let c=this._handlerFailures;try{this.emit("publication",n)}finally{delete this._pendingServerSubOffsets[i]}if(this._handlerFailures!==c)return;rt(e.offset)&&(this._serverSubs[i].offset=I(e.offset)),e.epoch&&(this._serverSubs[i].epoch=e.epoch)}return}if(!t._isSubscribed()){this._debug("publication for a subscription that is not subscribed",i);return}t._handlePublication(e)}_handleMessage(i){this.emit("message",{data:i.data})}_handleServerPing(i){if(this._resetReconnectAttemptsIfPending(),this._sendPong){let e={};this._transportSendCommands([e])}i()}_handlePush(i,e){let r=i.channel,t=i.id;i.pub?this._handlePublication(r,i.pub,t):i.message?this._handleMessage(i.message):i.join?this._handleJoin(r,i.join,t):i.leave?this._handleLeave(r,i.leave,t):i.unsubscribe?this._handleUnsubscribe(r,i.unsubscribe):i.subscribe?this._handleSubscribe(r,i.subscribe):i.disconnect&&this._handleDisconnect(i.disconnect),e()}_flush(){let i=this._commands.slice(0);this._commands=[],this._transportSendCommands(i)}_createErrorObject(i,e,r){let t={code:i,message:e};return r&&(t.temporary=!0),t}_registerCall(i,e,r){this._callbacks[i]={callback:e,errback:r,timeout:null};let t=Date.now()+this._config.timeout;this._callbacks[i].timeout=setTimeout(()=>{let n=Date.now()-t>=Qt;this._callbacks[i].timeout=setTimeout(()=>{delete this._callbacks[i],ut(r)&&r({error:this._createErrorObject(1,"timeout")})},n?Yt:0)},this._config.timeout)}_addCommand(i){this._batching?this._commands.push(i):this._transportSendCommands([i])}_nextPromiseId(){return++this._promiseId}_nextTransportId(){return++this._transportId}_resolvePromises(){for(let i in this._promises)this._promises.hasOwnProperty(i)&&(this._promises[i].timeout&&clearTimeout(this._promises[i].timeout),this._promises[i].resolve(),delete this._promises[i])}_rejectPromises(i){for(let e in this._promises)this._promises.hasOwnProperty(e)&&(this._promises[e].timeout&&clearTimeout(this._promises[e].timeout),this._promises[e].reject(i),delete this._promises[e])}};ft.SubscriptionState=jt;ft.State=Et;ft.UnauthorizedError=Z;var lt=Tt(_e());var it=Tt(_e()),p=it.Reader,S=it.Writer,f=it.util,h=it.roots.default||(it.roots.default={}),Wt=h.centrifugal=(()=>{let l={};return l.centrifuge=(function(){let o={};return o.protocol=(function(){let i={};return i.Error=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.code=0,e.prototype.message="",e.prototype.temporary=!1,e.encode=function(t,n){return n||(n=S.create()),t.code!=null&&Object.hasOwnProperty.call(t,"code")&&n.uint32(8).uint32(t.code),t.message!=null&&Object.hasOwnProperty.call(t,"message")&&n.uint32(18).string(t.message),t.temporary!=null&&Object.hasOwnProperty.call(t,"temporary")&&n.uint32(24).bool(t.temporary),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Error;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.code=t.uint32();break}case 2:{s.message=t.string();break}case 3:{s.temporary=t.bool();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!f.isInteger(t.code)?"code: integer expected":t.message!=null&&t.hasOwnProperty("message")&&!f.isString(t.message)?"message: string expected":t.temporary!=null&&t.hasOwnProperty("temporary")&&typeof t.temporary!="boolean"?"temporary: boolean expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Error"},e})(),i.EmulationRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.node="",e.prototype.session="",e.prototype.data=f.newBuffer([]),e.encode=function(t,n){return n||(n=S.create()),t.node!=null&&Object.hasOwnProperty.call(t,"node")&&n.uint32(10).string(t.node),t.session!=null&&Object.hasOwnProperty.call(t,"session")&&n.uint32(18).string(t.session),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(26).bytes(t.data),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.EmulationRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.node=t.string();break}case 2:{s.session=t.string();break}case 3:{s.data=t.bytes();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.node!=null&&t.hasOwnProperty("node")&&!f.isString(t.node)?"node: string expected":t.session!=null&&t.hasOwnProperty("session")&&!f.isString(t.session)?"session: string expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data))?"data: buffer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.EmulationRequest"},e})(),i.Command=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.id=0,e.prototype.connect=null,e.prototype.subscribe=null,e.prototype.unsubscribe=null,e.prototype.publish=null,e.prototype.presence=null,e.prototype.presence_stats=null,e.prototype.history=null,e.prototype.ping=null,e.prototype.send=null,e.prototype.rpc=null,e.prototype.refresh=null,e.prototype.sub_refresh=null,e.encode=function(t,n){return n||(n=S.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&n.uint32(8).uint32(t.id),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&h.centrifugal.centrifuge.protocol.ConnectRequest.encode(t.connect,n.uint32(34).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&h.centrifugal.centrifuge.protocol.SubscribeRequest.encode(t.subscribe,n.uint32(42).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&h.centrifugal.centrifuge.protocol.UnsubscribeRequest.encode(t.unsubscribe,n.uint32(50).fork()).ldelim(),t.publish!=null&&Object.hasOwnProperty.call(t,"publish")&&h.centrifugal.centrifuge.protocol.PublishRequest.encode(t.publish,n.uint32(58).fork()).ldelim(),t.presence!=null&&Object.hasOwnProperty.call(t,"presence")&&h.centrifugal.centrifuge.protocol.PresenceRequest.encode(t.presence,n.uint32(66).fork()).ldelim(),t.presence_stats!=null&&Object.hasOwnProperty.call(t,"presence_stats")&&h.centrifugal.centrifuge.protocol.PresenceStatsRequest.encode(t.presence_stats,n.uint32(74).fork()).ldelim(),t.history!=null&&Object.hasOwnProperty.call(t,"history")&&h.centrifugal.centrifuge.protocol.HistoryRequest.encode(t.history,n.uint32(82).fork()).ldelim(),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&h.centrifugal.centrifuge.protocol.PingRequest.encode(t.ping,n.uint32(90).fork()).ldelim(),t.send!=null&&Object.hasOwnProperty.call(t,"send")&&h.centrifugal.centrifuge.protocol.SendRequest.encode(t.send,n.uint32(98).fork()).ldelim(),t.rpc!=null&&Object.hasOwnProperty.call(t,"rpc")&&h.centrifugal.centrifuge.protocol.RPCRequest.encode(t.rpc,n.uint32(106).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&h.centrifugal.centrifuge.protocol.RefreshRequest.encode(t.refresh,n.uint32(114).fork()).ldelim(),t.sub_refresh!=null&&Object.hasOwnProperty.call(t,"sub_refresh")&&h.centrifugal.centrifuge.protocol.SubRefreshRequest.encode(t.sub_refresh,n.uint32(122).fork()).ldelim(),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Command;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.id=t.uint32();break}case 4:{s.connect=h.centrifugal.centrifuge.protocol.ConnectRequest.decode(t,t.uint32());break}case 5:{s.subscribe=h.centrifugal.centrifuge.protocol.SubscribeRequest.decode(t,t.uint32());break}case 6:{s.unsubscribe=h.centrifugal.centrifuge.protocol.UnsubscribeRequest.decode(t,t.uint32());break}case 7:{s.publish=h.centrifugal.centrifuge.protocol.PublishRequest.decode(t,t.uint32());break}case 8:{s.presence=h.centrifugal.centrifuge.protocol.PresenceRequest.decode(t,t.uint32());break}case 9:{s.presence_stats=h.centrifugal.centrifuge.protocol.PresenceStatsRequest.decode(t,t.uint32());break}case 10:{s.history=h.centrifugal.centrifuge.protocol.HistoryRequest.decode(t,t.uint32());break}case 11:{s.ping=h.centrifugal.centrifuge.protocol.PingRequest.decode(t,t.uint32());break}case 12:{s.send=h.centrifugal.centrifuge.protocol.SendRequest.decode(t,t.uint32());break}case 13:{s.rpc=h.centrifugal.centrifuge.protocol.RPCRequest.decode(t,t.uint32());break}case 14:{s.refresh=h.centrifugal.centrifuge.protocol.RefreshRequest.decode(t,t.uint32());break}case 15:{s.sub_refresh=h.centrifugal.centrifuge.protocol.SubRefreshRequest.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.id!=null&&t.hasOwnProperty("id")&&!f.isInteger(t.id))return"id: integer expected";if(t.connect!=null&&t.hasOwnProperty("connect")){let n=h.centrifugal.centrifuge.protocol.ConnectRequest.verify(t.connect);if(n)return"connect."+n}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let n=h.centrifugal.centrifuge.protocol.SubscribeRequest.verify(t.subscribe);if(n)return"subscribe."+n}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let n=h.centrifugal.centrifuge.protocol.UnsubscribeRequest.verify(t.unsubscribe);if(n)return"unsubscribe."+n}if(t.publish!=null&&t.hasOwnProperty("publish")){let n=h.centrifugal.centrifuge.protocol.PublishRequest.verify(t.publish);if(n)return"publish."+n}if(t.presence!=null&&t.hasOwnProperty("presence")){let n=h.centrifugal.centrifuge.protocol.PresenceRequest.verify(t.presence);if(n)return"presence."+n}if(t.presence_stats!=null&&t.hasOwnProperty("presence_stats")){let n=h.centrifugal.centrifuge.protocol.PresenceStatsRequest.verify(t.presence_stats);if(n)return"presence_stats."+n}if(t.history!=null&&t.hasOwnProperty("history")){let n=h.centrifugal.centrifuge.protocol.HistoryRequest.verify(t.history);if(n)return"history."+n}if(t.ping!=null&&t.hasOwnProperty("ping")){let n=h.centrifugal.centrifuge.protocol.PingRequest.verify(t.ping);if(n)return"ping."+n}if(t.send!=null&&t.hasOwnProperty("send")){let n=h.centrifugal.centrifuge.protocol.SendRequest.verify(t.send);if(n)return"send."+n}if(t.rpc!=null&&t.hasOwnProperty("rpc")){let n=h.centrifugal.centrifuge.protocol.RPCRequest.verify(t.rpc);if(n)return"rpc."+n}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let n=h.centrifugal.centrifuge.protocol.RefreshRequest.verify(t.refresh);if(n)return"refresh."+n}if(t.sub_refresh!=null&&t.hasOwnProperty("sub_refresh")){let n=h.centrifugal.centrifuge.protocol.SubRefreshRequest.verify(t.sub_refresh);if(n)return"sub_refresh."+n}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Command"},e})(),i.Reply=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.id=0,e.prototype.error=null,e.prototype.push=null,e.prototype.connect=null,e.prototype.subscribe=null,e.prototype.unsubscribe=null,e.prototype.publish=null,e.prototype.presence=null,e.prototype.presence_stats=null,e.prototype.history=null,e.prototype.ping=null,e.prototype.rpc=null,e.prototype.refresh=null,e.prototype.sub_refresh=null,e.encode=function(t,n){return n||(n=S.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&n.uint32(8).uint32(t.id),t.error!=null&&Object.hasOwnProperty.call(t,"error")&&h.centrifugal.centrifuge.protocol.Error.encode(t.error,n.uint32(18).fork()).ldelim(),t.push!=null&&Object.hasOwnProperty.call(t,"push")&&h.centrifugal.centrifuge.protocol.Push.encode(t.push,n.uint32(34).fork()).ldelim(),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&h.centrifugal.centrifuge.protocol.ConnectResult.encode(t.connect,n.uint32(42).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&h.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subscribe,n.uint32(50).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&h.centrifugal.centrifuge.protocol.UnsubscribeResult.encode(t.unsubscribe,n.uint32(58).fork()).ldelim(),t.publish!=null&&Object.hasOwnProperty.call(t,"publish")&&h.centrifugal.centrifuge.protocol.PublishResult.encode(t.publish,n.uint32(66).fork()).ldelim(),t.presence!=null&&Object.hasOwnProperty.call(t,"presence")&&h.centrifugal.centrifuge.protocol.PresenceResult.encode(t.presence,n.uint32(74).fork()).ldelim(),t.presence_stats!=null&&Object.hasOwnProperty.call(t,"presence_stats")&&h.centrifugal.centrifuge.protocol.PresenceStatsResult.encode(t.presence_stats,n.uint32(82).fork()).ldelim(),t.history!=null&&Object.hasOwnProperty.call(t,"history")&&h.centrifugal.centrifuge.protocol.HistoryResult.encode(t.history,n.uint32(90).fork()).ldelim(),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&h.centrifugal.centrifuge.protocol.PingResult.encode(t.ping,n.uint32(98).fork()).ldelim(),t.rpc!=null&&Object.hasOwnProperty.call(t,"rpc")&&h.centrifugal.centrifuge.protocol.RPCResult.encode(t.rpc,n.uint32(106).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&h.centrifugal.centrifuge.protocol.RefreshResult.encode(t.refresh,n.uint32(114).fork()).ldelim(),t.sub_refresh!=null&&Object.hasOwnProperty.call(t,"sub_refresh")&&h.centrifugal.centrifuge.protocol.SubRefreshResult.encode(t.sub_refresh,n.uint32(122).fork()).ldelim(),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Reply;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.id=t.uint32();break}case 2:{s.error=h.centrifugal.centrifuge.protocol.Error.decode(t,t.uint32());break}case 4:{s.push=h.centrifugal.centrifuge.protocol.Push.decode(t,t.uint32());break}case 5:{s.connect=h.centrifugal.centrifuge.protocol.ConnectResult.decode(t,t.uint32());break}case 6:{s.subscribe=h.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break}case 7:{s.unsubscribe=h.centrifugal.centrifuge.protocol.UnsubscribeResult.decode(t,t.uint32());break}case 8:{s.publish=h.centrifugal.centrifuge.protocol.PublishResult.decode(t,t.uint32());break}case 9:{s.presence=h.centrifugal.centrifuge.protocol.PresenceResult.decode(t,t.uint32());break}case 10:{s.presence_stats=h.centrifugal.centrifuge.protocol.PresenceStatsResult.decode(t,t.uint32());break}case 11:{s.history=h.centrifugal.centrifuge.protocol.HistoryResult.decode(t,t.uint32());break}case 12:{s.ping=h.centrifugal.centrifuge.protocol.PingResult.decode(t,t.uint32());break}case 13:{s.rpc=h.centrifugal.centrifuge.protocol.RPCResult.decode(t,t.uint32());break}case 14:{s.refresh=h.centrifugal.centrifuge.protocol.RefreshResult.decode(t,t.uint32());break}case 15:{s.sub_refresh=h.centrifugal.centrifuge.protocol.SubRefreshResult.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.id!=null&&t.hasOwnProperty("id")&&!f.isInteger(t.id))return"id: integer expected";if(t.error!=null&&t.hasOwnProperty("error")){let n=h.centrifugal.centrifuge.protocol.Error.verify(t.error);if(n)return"error."+n}if(t.push!=null&&t.hasOwnProperty("push")){let n=h.centrifugal.centrifuge.protocol.Push.verify(t.push);if(n)return"push."+n}if(t.connect!=null&&t.hasOwnProperty("connect")){let n=h.centrifugal.centrifuge.protocol.ConnectResult.verify(t.connect);if(n)return"connect."+n}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let n=h.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subscribe);if(n)return"subscribe."+n}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let n=h.centrifugal.centrifuge.protocol.UnsubscribeResult.verify(t.unsubscribe);if(n)return"unsubscribe."+n}if(t.publish!=null&&t.hasOwnProperty("publish")){let n=h.centrifugal.centrifuge.protocol.PublishResult.verify(t.publish);if(n)return"publish."+n}if(t.presence!=null&&t.hasOwnProperty("presence")){let n=h.centrifugal.centrifuge.protocol.PresenceResult.verify(t.presence);if(n)return"presence."+n}if(t.presence_stats!=null&&t.hasOwnProperty("presence_stats")){let n=h.centrifugal.centrifuge.protocol.PresenceStatsResult.verify(t.presence_stats);if(n)return"presence_stats."+n}if(t.history!=null&&t.hasOwnProperty("history")){let n=h.centrifugal.centrifuge.protocol.HistoryResult.verify(t.history);if(n)return"history."+n}if(t.ping!=null&&t.hasOwnProperty("ping")){let n=h.centrifugal.centrifuge.protocol.PingResult.verify(t.ping);if(n)return"ping."+n}if(t.rpc!=null&&t.hasOwnProperty("rpc")){let n=h.centrifugal.centrifuge.protocol.RPCResult.verify(t.rpc);if(n)return"rpc."+n}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let n=h.centrifugal.centrifuge.protocol.RefreshResult.verify(t.refresh);if(n)return"refresh."+n}if(t.sub_refresh!=null&&t.hasOwnProperty("sub_refresh")){let n=h.centrifugal.centrifuge.protocol.SubRefreshResult.verify(t.sub_refresh);if(n)return"sub_refresh."+n}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Reply"},e})(),i.Push=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.id=f.Long?f.Long.fromBits(0,0,!1):0,e.prototype.channel="",e.prototype.pub=null,e.prototype.join=null,e.prototype.leave=null,e.prototype.unsubscribe=null,e.prototype.message=null,e.prototype.subscribe=null,e.prototype.connect=null,e.prototype.disconnect=null,e.prototype.refresh=null,e.encode=function(t,n){return n||(n=S.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&n.uint32(8).int64(t.id),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&n.uint32(18).string(t.channel),t.pub!=null&&Object.hasOwnProperty.call(t,"pub")&&h.centrifugal.centrifuge.protocol.Publication.encode(t.pub,n.uint32(34).fork()).ldelim(),t.join!=null&&Object.hasOwnProperty.call(t,"join")&&h.centrifugal.centrifuge.protocol.Join.encode(t.join,n.uint32(42).fork()).ldelim(),t.leave!=null&&Object.hasOwnProperty.call(t,"leave")&&h.centrifugal.centrifuge.protocol.Leave.encode(t.leave,n.uint32(50).fork()).ldelim(),t.unsubscribe!=null&&Object.hasOwnProperty.call(t,"unsubscribe")&&h.centrifugal.centrifuge.protocol.Unsubscribe.encode(t.unsubscribe,n.uint32(58).fork()).ldelim(),t.message!=null&&Object.hasOwnProperty.call(t,"message")&&h.centrifugal.centrifuge.protocol.Message.encode(t.message,n.uint32(66).fork()).ldelim(),t.subscribe!=null&&Object.hasOwnProperty.call(t,"subscribe")&&h.centrifugal.centrifuge.protocol.Subscribe.encode(t.subscribe,n.uint32(74).fork()).ldelim(),t.connect!=null&&Object.hasOwnProperty.call(t,"connect")&&h.centrifugal.centrifuge.protocol.Connect.encode(t.connect,n.uint32(82).fork()).ldelim(),t.disconnect!=null&&Object.hasOwnProperty.call(t,"disconnect")&&h.centrifugal.centrifuge.protocol.Disconnect.encode(t.disconnect,n.uint32(90).fork()).ldelim(),t.refresh!=null&&Object.hasOwnProperty.call(t,"refresh")&&h.centrifugal.centrifuge.protocol.Refresh.encode(t.refresh,n.uint32(98).fork()).ldelim(),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Push;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.id=t.int64();break}case 2:{s.channel=t.string();break}case 4:{s.pub=h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32());break}case 5:{s.join=h.centrifugal.centrifuge.protocol.Join.decode(t,t.uint32());break}case 6:{s.leave=h.centrifugal.centrifuge.protocol.Leave.decode(t,t.uint32());break}case 7:{s.unsubscribe=h.centrifugal.centrifuge.protocol.Unsubscribe.decode(t,t.uint32());break}case 8:{s.message=h.centrifugal.centrifuge.protocol.Message.decode(t,t.uint32());break}case 9:{s.subscribe=h.centrifugal.centrifuge.protocol.Subscribe.decode(t,t.uint32());break}case 10:{s.connect=h.centrifugal.centrifuge.protocol.Connect.decode(t,t.uint32());break}case 11:{s.disconnect=h.centrifugal.centrifuge.protocol.Disconnect.decode(t,t.uint32());break}case 12:{s.refresh=h.centrifugal.centrifuge.protocol.Refresh.decode(t,t.uint32());break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.id!=null&&t.hasOwnProperty("id")&&!f.isInteger(t.id)&&!(t.id&&f.isInteger(t.id.low)&&f.isInteger(t.id.high)))return"id: integer|Long expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!f.isString(t.channel))return"channel: string expected";if(t.pub!=null&&t.hasOwnProperty("pub")){let n=h.centrifugal.centrifuge.protocol.Publication.verify(t.pub);if(n)return"pub."+n}if(t.join!=null&&t.hasOwnProperty("join")){let n=h.centrifugal.centrifuge.protocol.Join.verify(t.join);if(n)return"join."+n}if(t.leave!=null&&t.hasOwnProperty("leave")){let n=h.centrifugal.centrifuge.protocol.Leave.verify(t.leave);if(n)return"leave."+n}if(t.unsubscribe!=null&&t.hasOwnProperty("unsubscribe")){let n=h.centrifugal.centrifuge.protocol.Unsubscribe.verify(t.unsubscribe);if(n)return"unsubscribe."+n}if(t.message!=null&&t.hasOwnProperty("message")){let n=h.centrifugal.centrifuge.protocol.Message.verify(t.message);if(n)return"message."+n}if(t.subscribe!=null&&t.hasOwnProperty("subscribe")){let n=h.centrifugal.centrifuge.protocol.Subscribe.verify(t.subscribe);if(n)return"subscribe."+n}if(t.connect!=null&&t.hasOwnProperty("connect")){let n=h.centrifugal.centrifuge.protocol.Connect.verify(t.connect);if(n)return"connect."+n}if(t.disconnect!=null&&t.hasOwnProperty("disconnect")){let n=h.centrifugal.centrifuge.protocol.Disconnect.verify(t.disconnect);if(n)return"disconnect."+n}if(t.refresh!=null&&t.hasOwnProperty("refresh")){let n=h.centrifugal.centrifuge.protocol.Refresh.verify(t.refresh);if(n)return"refresh."+n}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Push"},e})(),i.ClientInfo=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.user="",e.prototype.client="",e.prototype.conn_info=f.newBuffer([]),e.prototype.chan_info=f.newBuffer([]),e.encode=function(t,n){return n||(n=S.create()),t.user!=null&&Object.hasOwnProperty.call(t,"user")&&n.uint32(10).string(t.user),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&n.uint32(18).string(t.client),t.conn_info!=null&&Object.hasOwnProperty.call(t,"conn_info")&&n.uint32(26).bytes(t.conn_info),t.chan_info!=null&&Object.hasOwnProperty.call(t,"chan_info")&&n.uint32(34).bytes(t.chan_info),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.ClientInfo;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.user=t.string();break}case 2:{s.client=t.string();break}case 3:{s.conn_info=t.bytes();break}case 4:{s.chan_info=t.bytes();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.user!=null&&t.hasOwnProperty("user")&&!f.isString(t.user)?"user: string expected":t.client!=null&&t.hasOwnProperty("client")&&!f.isString(t.client)?"client: string expected":t.conn_info!=null&&t.hasOwnProperty("conn_info")&&!(t.conn_info&&typeof t.conn_info.length=="number"||f.isString(t.conn_info))?"conn_info: buffer expected":t.chan_info!=null&&t.hasOwnProperty("chan_info")&&!(t.chan_info&&typeof t.chan_info.length=="number"||f.isString(t.chan_info))?"chan_info: buffer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ClientInfo"},e})(),i.Publication=(function(){function e(r){if(this.tags={},r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.data=f.newBuffer([]),e.prototype.info=null,e.prototype.offset=f.Long?f.Long.fromBits(0,0,!0):0,e.prototype.tags=f.emptyObject,e.prototype.delta=!1,e.prototype.time=f.Long?f.Long.fromBits(0,0,!1):0,e.prototype.channel="",e.prototype.key="",e.prototype.removed=!1,e.prototype.score=f.Long?f.Long.fromBits(0,0,!1):0,e.prototype.epoch="",e.prototype.prev_data=f.newBuffer([]),e.prototype.version=f.Long?f.Long.fromBits(0,0,!0):0,e.encode=function(t,n){if(n||(n=S.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(34).bytes(t.data),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&h.centrifugal.centrifuge.protocol.ClientInfo.encode(t.info,n.uint32(42).fork()).ldelim(),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&n.uint32(48).uint64(t.offset),t.tags!=null&&Object.hasOwnProperty.call(t,"tags"))for(let c=Object.keys(t.tags),s=0;s<c.length;++s)n.uint32(58).fork().uint32(10).string(c[s]).uint32(18).string(t.tags[c[s]]).ldelim();return t.delta!=null&&Object.hasOwnProperty.call(t,"delta")&&n.uint32(64).bool(t.delta),t.time!=null&&Object.hasOwnProperty.call(t,"time")&&n.uint32(72).int64(t.time),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&n.uint32(82).string(t.channel),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&n.uint32(90).string(t.key),t.removed!=null&&Object.hasOwnProperty.call(t,"removed")&&n.uint32(96).bool(t.removed),t.score!=null&&Object.hasOwnProperty.call(t,"score")&&n.uint32(104).sint64(t.score),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&n.uint32(114).string(t.epoch),t.prev_data!=null&&Object.hasOwnProperty.call(t,"prev_data")&&n.uint32(122).bytes(t.prev_data),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&n.uint32(128).uint64(t.version),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Publication,u,d;for(;t.pos<c;){let y=t.uint32();switch(y>>>3){case 4:{s.data=t.bytes();break}case 5:{s.info=h.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break}case 6:{s.offset=t.uint64();break}case 7:{s.tags===f.emptyObject&&(s.tags={});let g=t.uint32()+t.pos;for(u="",d="";t.pos<g;){let k=t.uint32();switch(k>>>3){case 1:u=t.string();break;case 2:d=t.string();break;default:t.skipType(k&7);break}}s.tags[u]=d;break}case 8:{s.delta=t.bool();break}case 9:{s.time=t.int64();break}case 10:{s.channel=t.string();break}case 11:{s.key=t.string();break}case 12:{s.removed=t.bool();break}case 13:{s.score=t.sint64();break}case 14:{s.epoch=t.string();break}case 15:{s.prev_data=t.bytes();break}case 16:{s.version=t.uint64();break}default:t.skipType(y&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data)))return"data: buffer expected";if(t.info!=null&&t.hasOwnProperty("info")){let n=h.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(n)return"info."+n}if(t.offset!=null&&t.hasOwnProperty("offset")&&!f.isInteger(t.offset)&&!(t.offset&&f.isInteger(t.offset.low)&&f.isInteger(t.offset.high)))return"offset: integer|Long expected";if(t.tags!=null&&t.hasOwnProperty("tags")){if(!f.isObject(t.tags))return"tags: object expected";let n=Object.keys(t.tags);for(let c=0;c<n.length;++c)if(!f.isString(t.tags[n[c]]))return"tags: string{k:string} expected"}return t.delta!=null&&t.hasOwnProperty("delta")&&typeof t.delta!="boolean"?"delta: boolean expected":t.time!=null&&t.hasOwnProperty("time")&&!f.isInteger(t.time)&&!(t.time&&f.isInteger(t.time.low)&&f.isInteger(t.time.high))?"time: integer|Long expected":t.channel!=null&&t.hasOwnProperty("channel")&&!f.isString(t.channel)?"channel: string expected":t.key!=null&&t.hasOwnProperty("key")&&!f.isString(t.key)?"key: string expected":t.removed!=null&&t.hasOwnProperty("removed")&&typeof t.removed!="boolean"?"removed: boolean expected":t.score!=null&&t.hasOwnProperty("score")&&!f.isInteger(t.score)&&!(t.score&&f.isInteger(t.score.low)&&f.isInteger(t.score.high))?"score: integer|Long expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!f.isString(t.epoch)?"epoch: string expected":t.prev_data!=null&&t.hasOwnProperty("prev_data")&&!(t.prev_data&&typeof t.prev_data.length=="number"||f.isString(t.prev_data))?"prev_data: buffer expected":t.version!=null&&t.hasOwnProperty("version")&&!f.isInteger(t.version)&&!(t.version&&f.isInteger(t.version.low)&&f.isInteger(t.version.high))?"version: integer|Long expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Publication"},e})(),i.Join=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.info=null,e.encode=function(t,n){return n||(n=S.create()),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&h.centrifugal.centrifuge.protocol.ClientInfo.encode(t.info,n.uint32(10).fork()).ldelim(),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Join;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.info=h.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32()):t.skipType(u&7)}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.info!=null&&t.hasOwnProperty("info")){let n=h.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(n)return"info."+n}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Join"},e})(),i.Leave=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.info=null,e.encode=function(t,n){return n||(n=S.create()),t.info!=null&&Object.hasOwnProperty.call(t,"info")&&h.centrifugal.centrifuge.protocol.ClientInfo.encode(t.info,n.uint32(10).fork()).ldelim(),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Leave;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.info=h.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32()):t.skipType(u&7)}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.info!=null&&t.hasOwnProperty("info")){let n=h.centrifugal.centrifuge.protocol.ClientInfo.verify(t.info);if(n)return"info."+n}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Leave"},e})(),i.Unsubscribe=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.code=0,e.prototype.reason="",e.encode=function(t,n){return n||(n=S.create()),t.code!=null&&Object.hasOwnProperty.call(t,"code")&&n.uint32(16).uint32(t.code),t.reason!=null&&Object.hasOwnProperty.call(t,"reason")&&n.uint32(26).string(t.reason),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Unsubscribe;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 2:{s.code=t.uint32();break}case 3:{s.reason=t.string();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!f.isInteger(t.code)?"code: integer expected":t.reason!=null&&t.hasOwnProperty("reason")&&!f.isString(t.reason)?"reason: string expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Unsubscribe"},e})(),i.Subscribe=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.recoverable=!1,e.prototype.epoch="",e.prototype.offset=f.Long?f.Long.fromBits(0,0,!0):0,e.prototype.positioned=!1,e.prototype.data=f.newBuffer([]),e.encode=function(t,n){return n||(n=S.create()),t.recoverable!=null&&Object.hasOwnProperty.call(t,"recoverable")&&n.uint32(8).bool(t.recoverable),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&n.uint32(34).string(t.epoch),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&n.uint32(40).uint64(t.offset),t.positioned!=null&&Object.hasOwnProperty.call(t,"positioned")&&n.uint32(48).bool(t.positioned),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(58).bytes(t.data),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Subscribe;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.recoverable=t.bool();break}case 4:{s.epoch=t.string();break}case 5:{s.offset=t.uint64();break}case 6:{s.positioned=t.bool();break}case 7:{s.data=t.bytes();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean"?"recoverable: boolean expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!f.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!f.isInteger(t.offset)&&!(t.offset&&f.isInteger(t.offset.low)&&f.isInteger(t.offset.high))?"offset: integer|Long expected":t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean"?"positioned: boolean expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data))?"data: buffer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Subscribe"},e})(),i.Message=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.data=f.newBuffer([]),e.encode=function(t,n){return n||(n=S.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(10).bytes(t.data),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Message;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.data=t.bytes():t.skipType(u&7)}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data))?"data: buffer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Message"},e})(),i.Connect=(function(){function e(r){if(this.subs={},r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.client="",e.prototype.version="",e.prototype.data=f.newBuffer([]),e.prototype.subs=f.emptyObject,e.prototype.expires=!1,e.prototype.ttl=0,e.prototype.ping=0,e.prototype.pong=!1,e.prototype.session="",e.prototype.node="",e.prototype.time=f.Long?f.Long.fromBits(0,0,!1):0,e.encode=function(t,n){if(n||(n=S.create()),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&n.uint32(10).string(t.client),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&n.uint32(18).string(t.version),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(26).bytes(t.data),t.subs!=null&&Object.hasOwnProperty.call(t,"subs"))for(let c=Object.keys(t.subs),s=0;s<c.length;++s)n.uint32(34).fork().uint32(10).string(c[s]),h.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subs[c[s]],n.uint32(18).fork()).ldelim().ldelim();return t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&n.uint32(40).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&n.uint32(48).uint32(t.ttl),t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&n.uint32(56).uint32(t.ping),t.pong!=null&&Object.hasOwnProperty.call(t,"pong")&&n.uint32(64).bool(t.pong),t.session!=null&&Object.hasOwnProperty.call(t,"session")&&n.uint32(74).string(t.session),t.node!=null&&Object.hasOwnProperty.call(t,"node")&&n.uint32(82).string(t.node),t.time!=null&&Object.hasOwnProperty.call(t,"time")&&n.uint32(88).int64(t.time),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Connect,u,d;for(;t.pos<c;){let y=t.uint32();switch(y>>>3){case 1:{s.client=t.string();break}case 2:{s.version=t.string();break}case 3:{s.data=t.bytes();break}case 4:{s.subs===f.emptyObject&&(s.subs={});let g=t.uint32()+t.pos;for(u="",d=null;t.pos<g;){let k=t.uint32();switch(k>>>3){case 1:u=t.string();break;case 2:d=h.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break;default:t.skipType(k&7);break}}s.subs[u]=d;break}case 5:{s.expires=t.bool();break}case 6:{s.ttl=t.uint32();break}case 7:{s.ping=t.uint32();break}case 8:{s.pong=t.bool();break}case 9:{s.session=t.string();break}case 10:{s.node=t.string();break}case 11:{s.time=t.int64();break}default:t.skipType(y&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.client!=null&&t.hasOwnProperty("client")&&!f.isString(t.client))return"client: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!f.isString(t.version))return"version: string expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!f.isObject(t.subs))return"subs: object expected";let n=Object.keys(t.subs);for(let c=0;c<n.length;++c){let s=h.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subs[n[c]]);if(s)return"subs."+s}}return t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!f.isInteger(t.ttl)?"ttl: integer expected":t.ping!=null&&t.hasOwnProperty("ping")&&!f.isInteger(t.ping)?"ping: integer expected":t.pong!=null&&t.hasOwnProperty("pong")&&typeof t.pong!="boolean"?"pong: boolean expected":t.session!=null&&t.hasOwnProperty("session")&&!f.isString(t.session)?"session: string expected":t.node!=null&&t.hasOwnProperty("node")&&!f.isString(t.node)?"node: string expected":t.time!=null&&t.hasOwnProperty("time")&&!f.isInteger(t.time)&&!(t.time&&f.isInteger(t.time.low)&&f.isInteger(t.time.high))?"time: integer|Long expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Connect"},e})(),i.Disconnect=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.code=0,e.prototype.reason="",e.prototype.reconnect=!1,e.encode=function(t,n){return n||(n=S.create()),t.code!=null&&Object.hasOwnProperty.call(t,"code")&&n.uint32(8).uint32(t.code),t.reason!=null&&Object.hasOwnProperty.call(t,"reason")&&n.uint32(18).string(t.reason),t.reconnect!=null&&Object.hasOwnProperty.call(t,"reconnect")&&n.uint32(24).bool(t.reconnect),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Disconnect;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.code=t.uint32();break}case 2:{s.reason=t.string();break}case 3:{s.reconnect=t.bool();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.code!=null&&t.hasOwnProperty("code")&&!f.isInteger(t.code)?"code: integer expected":t.reason!=null&&t.hasOwnProperty("reason")&&!f.isString(t.reason)?"reason: string expected":t.reconnect!=null&&t.hasOwnProperty("reconnect")&&typeof t.reconnect!="boolean"?"reconnect: boolean expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Disconnect"},e})(),i.Refresh=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.expires=!1,e.prototype.ttl=0,e.encode=function(t,n){return n||(n=S.create()),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&n.uint32(8).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&n.uint32(16).uint32(t.ttl),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.Refresh;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.expires=t.bool();break}case 2:{s.ttl=t.uint32();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!f.isInteger(t.ttl)?"ttl: integer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.Refresh"},e})(),i.ConnectRequest=(function(){function e(r){if(this.subs={},this.headers={},r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.token="",e.prototype.data=f.newBuffer([]),e.prototype.subs=f.emptyObject,e.prototype.name="",e.prototype.version="",e.prototype.headers=f.emptyObject,e.prototype.flag=f.Long?f.Long.fromBits(0,0,!1):0,e.encode=function(t,n){if(n||(n=S.create()),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&n.uint32(10).string(t.token),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(18).bytes(t.data),t.subs!=null&&Object.hasOwnProperty.call(t,"subs"))for(let c=Object.keys(t.subs),s=0;s<c.length;++s)n.uint32(26).fork().uint32(10).string(c[s]),h.centrifugal.centrifuge.protocol.SubscribeRequest.encode(t.subs[c[s]],n.uint32(18).fork()).ldelim().ldelim();if(t.name!=null&&Object.hasOwnProperty.call(t,"name")&&n.uint32(34).string(t.name),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&n.uint32(42).string(t.version),t.headers!=null&&Object.hasOwnProperty.call(t,"headers"))for(let c=Object.keys(t.headers),s=0;s<c.length;++s)n.uint32(50).fork().uint32(10).string(c[s]).uint32(18).string(t.headers[c[s]]).ldelim();return t.flag!=null&&Object.hasOwnProperty.call(t,"flag")&&n.uint32(56).int64(t.flag),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.ConnectRequest,u,d;for(;t.pos<c;){let y=t.uint32();switch(y>>>3){case 1:{s.token=t.string();break}case 2:{s.data=t.bytes();break}case 3:{s.subs===f.emptyObject&&(s.subs={});let g=t.uint32()+t.pos;for(u="",d=null;t.pos<g;){let k=t.uint32();switch(k>>>3){case 1:u=t.string();break;case 2:d=h.centrifugal.centrifuge.protocol.SubscribeRequest.decode(t,t.uint32());break;default:t.skipType(k&7);break}}s.subs[u]=d;break}case 4:{s.name=t.string();break}case 5:{s.version=t.string();break}case 6:{s.headers===f.emptyObject&&(s.headers={});let g=t.uint32()+t.pos;for(u="",d="";t.pos<g;){let k=t.uint32();switch(k>>>3){case 1:u=t.string();break;case 2:d=t.string();break;default:t.skipType(k&7);break}}s.headers[u]=d;break}case 7:{s.flag=t.int64();break}default:t.skipType(y&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.token!=null&&t.hasOwnProperty("token")&&!f.isString(t.token))return"token: string expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!f.isObject(t.subs))return"subs: object expected";let n=Object.keys(t.subs);for(let c=0;c<n.length;++c){let s=h.centrifugal.centrifuge.protocol.SubscribeRequest.verify(t.subs[n[c]]);if(s)return"subs."+s}}if(t.name!=null&&t.hasOwnProperty("name")&&!f.isString(t.name))return"name: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!f.isString(t.version))return"version: string expected";if(t.headers!=null&&t.hasOwnProperty("headers")){if(!f.isObject(t.headers))return"headers: object expected";let n=Object.keys(t.headers);for(let c=0;c<n.length;++c)if(!f.isString(t.headers[n[c]]))return"headers: string{k:string} expected"}return t.flag!=null&&t.hasOwnProperty("flag")&&!f.isInteger(t.flag)&&!(t.flag&&f.isInteger(t.flag.low)&&f.isInteger(t.flag.high))?"flag: integer|Long expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ConnectRequest"},e})(),i.ConnectResult=(function(){function e(r){if(this.subs={},r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.client="",e.prototype.version="",e.prototype.expires=!1,e.prototype.ttl=0,e.prototype.data=f.newBuffer([]),e.prototype.subs=f.emptyObject,e.prototype.ping=0,e.prototype.pong=!1,e.prototype.session="",e.prototype.node="",e.prototype.time=f.Long?f.Long.fromBits(0,0,!1):0,e.encode=function(t,n){if(n||(n=S.create()),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&n.uint32(10).string(t.client),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&n.uint32(18).string(t.version),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&n.uint32(24).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&n.uint32(32).uint32(t.ttl),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(42).bytes(t.data),t.subs!=null&&Object.hasOwnProperty.call(t,"subs"))for(let c=Object.keys(t.subs),s=0;s<c.length;++s)n.uint32(50).fork().uint32(10).string(c[s]),h.centrifugal.centrifuge.protocol.SubscribeResult.encode(t.subs[c[s]],n.uint32(18).fork()).ldelim().ldelim();return t.ping!=null&&Object.hasOwnProperty.call(t,"ping")&&n.uint32(56).uint32(t.ping),t.pong!=null&&Object.hasOwnProperty.call(t,"pong")&&n.uint32(64).bool(t.pong),t.session!=null&&Object.hasOwnProperty.call(t,"session")&&n.uint32(74).string(t.session),t.node!=null&&Object.hasOwnProperty.call(t,"node")&&n.uint32(82).string(t.node),t.time!=null&&Object.hasOwnProperty.call(t,"time")&&n.uint32(88).int64(t.time),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.ConnectResult,u,d;for(;t.pos<c;){let y=t.uint32();switch(y>>>3){case 1:{s.client=t.string();break}case 2:{s.version=t.string();break}case 3:{s.expires=t.bool();break}case 4:{s.ttl=t.uint32();break}case 5:{s.data=t.bytes();break}case 6:{s.subs===f.emptyObject&&(s.subs={});let g=t.uint32()+t.pos;for(u="",d=null;t.pos<g;){let k=t.uint32();switch(k>>>3){case 1:u=t.string();break;case 2:d=h.centrifugal.centrifuge.protocol.SubscribeResult.decode(t,t.uint32());break;default:t.skipType(k&7);break}}s.subs[u]=d;break}case 7:{s.ping=t.uint32();break}case 8:{s.pong=t.bool();break}case 9:{s.session=t.string();break}case 10:{s.node=t.string();break}case 11:{s.time=t.int64();break}default:t.skipType(y&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.client!=null&&t.hasOwnProperty("client")&&!f.isString(t.client))return"client: string expected";if(t.version!=null&&t.hasOwnProperty("version")&&!f.isString(t.version))return"version: string expected";if(t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean")return"expires: boolean expected";if(t.ttl!=null&&t.hasOwnProperty("ttl")&&!f.isInteger(t.ttl))return"ttl: integer expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data)))return"data: buffer expected";if(t.subs!=null&&t.hasOwnProperty("subs")){if(!f.isObject(t.subs))return"subs: object expected";let n=Object.keys(t.subs);for(let c=0;c<n.length;++c){let s=h.centrifugal.centrifuge.protocol.SubscribeResult.verify(t.subs[n[c]]);if(s)return"subs."+s}}return t.ping!=null&&t.hasOwnProperty("ping")&&!f.isInteger(t.ping)?"ping: integer expected":t.pong!=null&&t.hasOwnProperty("pong")&&typeof t.pong!="boolean"?"pong: boolean expected":t.session!=null&&t.hasOwnProperty("session")&&!f.isString(t.session)?"session: string expected":t.node!=null&&t.hasOwnProperty("node")&&!f.isString(t.node)?"node: string expected":t.time!=null&&t.hasOwnProperty("time")&&!f.isInteger(t.time)&&!(t.time&&f.isInteger(t.time.low)&&f.isInteger(t.time.high))?"time: integer|Long expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.ConnectResult"},e})(),i.RefreshRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.token="",e.encode=function(t,n){return n||(n=S.create()),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&n.uint32(10).string(t.token),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.RefreshRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.token=t.string():t.skipType(u&7)}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.token!=null&&t.hasOwnProperty("token")&&!f.isString(t.token)?"token: string expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RefreshRequest"},e})(),i.RefreshResult=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.client="",e.prototype.version="",e.prototype.expires=!1,e.prototype.ttl=0,e.encode=function(t,n){return n||(n=S.create()),t.client!=null&&Object.hasOwnProperty.call(t,"client")&&n.uint32(10).string(t.client),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&n.uint32(18).string(t.version),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&n.uint32(24).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&n.uint32(32).uint32(t.ttl),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.RefreshResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.client=t.string();break}case 2:{s.version=t.string();break}case 3:{s.expires=t.bool();break}case 4:{s.ttl=t.uint32();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.client!=null&&t.hasOwnProperty("client")&&!f.isString(t.client)?"client: string expected":t.version!=null&&t.hasOwnProperty("version")&&!f.isString(t.version)?"version: string expected":t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean"?"expires: boolean expected":t.ttl!=null&&t.hasOwnProperty("ttl")&&!f.isInteger(t.ttl)?"ttl: integer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RefreshResult"},e})(),i.SubscribeRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.channel="",e.prototype.token="",e.prototype.recover=!1,e.prototype.epoch="",e.prototype.offset=f.Long?f.Long.fromBits(0,0,!0):0,e.prototype.data=f.newBuffer([]),e.prototype.positioned=!1,e.prototype.recoverable=!1,e.prototype.join_leave=!1,e.prototype.delta="",e.prototype.tf=null,e.prototype.flag=f.Long?f.Long.fromBits(0,0,!1):0,e.prototype.type=0,e.prototype.phase=0,e.prototype.cursor="",e.prototype.limit=0,e.prototype.asc=!1,e.encode=function(t,n){return n||(n=S.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&n.uint32(10).string(t.channel),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&n.uint32(18).string(t.token),t.recover!=null&&Object.hasOwnProperty.call(t,"recover")&&n.uint32(24).bool(t.recover),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&n.uint32(50).string(t.epoch),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&n.uint32(56).uint64(t.offset),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(66).bytes(t.data),t.positioned!=null&&Object.hasOwnProperty.call(t,"positioned")&&n.uint32(72).bool(t.positioned),t.recoverable!=null&&Object.hasOwnProperty.call(t,"recoverable")&&n.uint32(80).bool(t.recoverable),t.join_leave!=null&&Object.hasOwnProperty.call(t,"join_leave")&&n.uint32(88).bool(t.join_leave),t.delta!=null&&Object.hasOwnProperty.call(t,"delta")&&n.uint32(98).string(t.delta),t.tf!=null&&Object.hasOwnProperty.call(t,"tf")&&h.centrifugal.centrifuge.protocol.FilterNode.encode(t.tf,n.uint32(106).fork()).ldelim(),t.flag!=null&&Object.hasOwnProperty.call(t,"flag")&&n.uint32(112).int64(t.flag),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&n.uint32(120).int32(t.type),t.phase!=null&&Object.hasOwnProperty.call(t,"phase")&&n.uint32(128).int32(t.phase),t.cursor!=null&&Object.hasOwnProperty.call(t,"cursor")&&n.uint32(138).string(t.cursor),t.limit!=null&&Object.hasOwnProperty.call(t,"limit")&&n.uint32(144).int32(t.limit),t.asc!=null&&Object.hasOwnProperty.call(t,"asc")&&n.uint32(152).bool(t.asc),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.SubscribeRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.channel=t.string();break}case 2:{s.token=t.string();break}case 3:{s.recover=t.bool();break}case 6:{s.epoch=t.string();break}case 7:{s.offset=t.uint64();break}case 8:{s.data=t.bytes();break}case 9:{s.positioned=t.bool();break}case 10:{s.recoverable=t.bool();break}case 11:{s.join_leave=t.bool();break}case 12:{s.delta=t.string();break}case 13:{s.tf=h.centrifugal.centrifuge.protocol.FilterNode.decode(t,t.uint32());break}case 14:{s.flag=t.int64();break}case 15:{s.type=t.int32();break}case 16:{s.phase=t.int32();break}case 17:{s.cursor=t.string();break}case 18:{s.limit=t.int32();break}case 19:{s.asc=t.bool();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!f.isString(t.channel))return"channel: string expected";if(t.token!=null&&t.hasOwnProperty("token")&&!f.isString(t.token))return"token: string expected";if(t.recover!=null&&t.hasOwnProperty("recover")&&typeof t.recover!="boolean")return"recover: boolean expected";if(t.epoch!=null&&t.hasOwnProperty("epoch")&&!f.isString(t.epoch))return"epoch: string expected";if(t.offset!=null&&t.hasOwnProperty("offset")&&!f.isInteger(t.offset)&&!(t.offset&&f.isInteger(t.offset.low)&&f.isInteger(t.offset.high)))return"offset: integer|Long expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data)))return"data: buffer expected";if(t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean")return"positioned: boolean expected";if(t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean")return"recoverable: boolean expected";if(t.join_leave!=null&&t.hasOwnProperty("join_leave")&&typeof t.join_leave!="boolean")return"join_leave: boolean expected";if(t.delta!=null&&t.hasOwnProperty("delta")&&!f.isString(t.delta))return"delta: string expected";if(t.tf!=null&&t.hasOwnProperty("tf")){let n=h.centrifugal.centrifuge.protocol.FilterNode.verify(t.tf);if(n)return"tf."+n}return t.flag!=null&&t.hasOwnProperty("flag")&&!f.isInteger(t.flag)&&!(t.flag&&f.isInteger(t.flag.low)&&f.isInteger(t.flag.high))?"flag: integer|Long expected":t.type!=null&&t.hasOwnProperty("type")&&!f.isInteger(t.type)?"type: integer expected":t.phase!=null&&t.hasOwnProperty("phase")&&!f.isInteger(t.phase)?"phase: integer expected":t.cursor!=null&&t.hasOwnProperty("cursor")&&!f.isString(t.cursor)?"cursor: string expected":t.limit!=null&&t.hasOwnProperty("limit")&&!f.isInteger(t.limit)?"limit: integer expected":t.asc!=null&&t.hasOwnProperty("asc")&&typeof t.asc!="boolean"?"asc: boolean expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubscribeRequest"},e})(),i.SubscribeResult=(function(){function e(r){if(this.publications=[],this.state=[],r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.expires=!1,e.prototype.ttl=0,e.prototype.recoverable=!1,e.prototype.epoch="",e.prototype.publications=f.emptyArray,e.prototype.recovered=!1,e.prototype.offset=f.Long?f.Long.fromBits(0,0,!0):0,e.prototype.positioned=!1,e.prototype.data=f.newBuffer([]),e.prototype.was_recovering=!1,e.prototype.delta=!1,e.prototype.id=f.Long?f.Long.fromBits(0,0,!1):0,e.prototype.type=0,e.prototype.phase=0,e.prototype.cursor="",e.prototype.state=f.emptyArray,e.prototype.publish_debounce=0,e.encode=function(t,n){if(n||(n=S.create()),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&n.uint32(8).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&n.uint32(16).uint32(t.ttl),t.recoverable!=null&&Object.hasOwnProperty.call(t,"recoverable")&&n.uint32(24).bool(t.recoverable),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&n.uint32(50).string(t.epoch),t.publications!=null&&t.publications.length)for(let c=0;c<t.publications.length;++c)h.centrifugal.centrifuge.protocol.Publication.encode(t.publications[c],n.uint32(58).fork()).ldelim();if(t.recovered!=null&&Object.hasOwnProperty.call(t,"recovered")&&n.uint32(64).bool(t.recovered),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&n.uint32(72).uint64(t.offset),t.positioned!=null&&Object.hasOwnProperty.call(t,"positioned")&&n.uint32(80).bool(t.positioned),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(90).bytes(t.data),t.was_recovering!=null&&Object.hasOwnProperty.call(t,"was_recovering")&&n.uint32(96).bool(t.was_recovering),t.delta!=null&&Object.hasOwnProperty.call(t,"delta")&&n.uint32(104).bool(t.delta),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&n.uint32(112).int64(t.id),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&n.uint32(120).int32(t.type),t.phase!=null&&Object.hasOwnProperty.call(t,"phase")&&n.uint32(128).int32(t.phase),t.cursor!=null&&Object.hasOwnProperty.call(t,"cursor")&&n.uint32(138).string(t.cursor),t.state!=null&&t.state.length)for(let c=0;c<t.state.length;++c)h.centrifugal.centrifuge.protocol.Publication.encode(t.state[c],n.uint32(146).fork()).ldelim();return t.publish_debounce!=null&&Object.hasOwnProperty.call(t,"publish_debounce")&&n.uint32(152).uint32(t.publish_debounce),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.SubscribeResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.expires=t.bool();break}case 2:{s.ttl=t.uint32();break}case 3:{s.recoverable=t.bool();break}case 6:{s.epoch=t.string();break}case 7:{s.publications&&s.publications.length||(s.publications=[]),s.publications.push(h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 8:{s.recovered=t.bool();break}case 9:{s.offset=t.uint64();break}case 10:{s.positioned=t.bool();break}case 11:{s.data=t.bytes();break}case 12:{s.was_recovering=t.bool();break}case 13:{s.delta=t.bool();break}case 14:{s.id=t.int64();break}case 15:{s.type=t.int32();break}case 16:{s.phase=t.int32();break}case 17:{s.cursor=t.string();break}case 18:{s.state&&s.state.length||(s.state=[]),s.state.push(h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 19:{s.publish_debounce=t.uint32();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean")return"expires: boolean expected";if(t.ttl!=null&&t.hasOwnProperty("ttl")&&!f.isInteger(t.ttl))return"ttl: integer expected";if(t.recoverable!=null&&t.hasOwnProperty("recoverable")&&typeof t.recoverable!="boolean")return"recoverable: boolean expected";if(t.epoch!=null&&t.hasOwnProperty("epoch")&&!f.isString(t.epoch))return"epoch: string expected";if(t.publications!=null&&t.hasOwnProperty("publications")){if(!Array.isArray(t.publications))return"publications: array expected";for(let n=0;n<t.publications.length;++n){let c=h.centrifugal.centrifuge.protocol.Publication.verify(t.publications[n]);if(c)return"publications."+c}}if(t.recovered!=null&&t.hasOwnProperty("recovered")&&typeof t.recovered!="boolean")return"recovered: boolean expected";if(t.offset!=null&&t.hasOwnProperty("offset")&&!f.isInteger(t.offset)&&!(t.offset&&f.isInteger(t.offset.low)&&f.isInteger(t.offset.high)))return"offset: integer|Long expected";if(t.positioned!=null&&t.hasOwnProperty("positioned")&&typeof t.positioned!="boolean")return"positioned: boolean expected";if(t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data)))return"data: buffer expected";if(t.was_recovering!=null&&t.hasOwnProperty("was_recovering")&&typeof t.was_recovering!="boolean")return"was_recovering: boolean expected";if(t.delta!=null&&t.hasOwnProperty("delta")&&typeof t.delta!="boolean")return"delta: boolean expected";if(t.id!=null&&t.hasOwnProperty("id")&&!f.isInteger(t.id)&&!(t.id&&f.isInteger(t.id.low)&&f.isInteger(t.id.high)))return"id: integer|Long expected";if(t.type!=null&&t.hasOwnProperty("type")&&!f.isInteger(t.type))return"type: integer expected";if(t.phase!=null&&t.hasOwnProperty("phase")&&!f.isInteger(t.phase))return"phase: integer expected";if(t.cursor!=null&&t.hasOwnProperty("cursor")&&!f.isString(t.cursor))return"cursor: string expected";if(t.state!=null&&t.hasOwnProperty("state")){if(!Array.isArray(t.state))return"state: array expected";for(let n=0;n<t.state.length;++n){let c=h.centrifugal.centrifuge.protocol.Publication.verify(t.state[n]);if(c)return"state."+c}}return t.publish_debounce!=null&&t.hasOwnProperty("publish_debounce")&&!f.isInteger(t.publish_debounce)?"publish_debounce: integer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubscribeResult"},e})(),i.KeyedItem=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.key="",e.prototype.version=f.Long?f.Long.fromBits(0,0,!0):0,e.encode=function(t,n){return n||(n=S.create()),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&n.uint32(10).string(t.key),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&n.uint32(16).uint64(t.version),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.KeyedItem;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.key=t.string();break}case 2:{s.version=t.uint64();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.key!=null&&t.hasOwnProperty("key")&&!f.isString(t.key)?"key: string expected":t.version!=null&&t.hasOwnProperty("version")&&!f.isInteger(t.version)&&!(t.version&&f.isInteger(t.version.low)&&f.isInteger(t.version.high))?"version: integer|Long expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.KeyedItem"},e})(),i.TrackBatch=(function(){function e(r){if(this.items=[],r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.signature="",e.prototype.items=f.emptyArray,e.encode=function(t,n){if(n||(n=S.create()),t.signature!=null&&Object.hasOwnProperty.call(t,"signature")&&n.uint32(10).string(t.signature),t.items!=null&&t.items.length)for(let c=0;c<t.items.length;++c)h.centrifugal.centrifuge.protocol.KeyedItem.encode(t.items[c],n.uint32(18).fork()).ldelim();return n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.TrackBatch;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.signature=t.string();break}case 2:{s.items&&s.items.length||(s.items=[]),s.items.push(h.centrifugal.centrifuge.protocol.KeyedItem.decode(t,t.uint32()));break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.signature!=null&&t.hasOwnProperty("signature")&&!f.isString(t.signature))return"signature: string expected";if(t.items!=null&&t.hasOwnProperty("items")){if(!Array.isArray(t.items))return"items: array expected";for(let n=0;n<t.items.length;++n){let c=h.centrifugal.centrifuge.protocol.KeyedItem.verify(t.items[n]);if(c)return"items."+c}}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.TrackBatch"},e})(),i.SubRefreshRequest=(function(){function e(r){if(this.track=[],this.untrack=[],r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.channel="",e.prototype.token="",e.prototype.type=0,e.prototype.track=f.emptyArray,e.prototype.untrack=f.emptyArray,e.encode=function(t,n){if(n||(n=S.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&n.uint32(10).string(t.channel),t.token!=null&&Object.hasOwnProperty.call(t,"token")&&n.uint32(18).string(t.token),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&n.uint32(24).int32(t.type),t.track!=null&&t.track.length)for(let c=0;c<t.track.length;++c)h.centrifugal.centrifuge.protocol.TrackBatch.encode(t.track[c],n.uint32(34).fork()).ldelim();if(t.untrack!=null&&t.untrack.length)for(let c=0;c<t.untrack.length;++c)n.uint32(42).string(t.untrack[c]);return n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.SubRefreshRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.channel=t.string();break}case 2:{s.token=t.string();break}case 3:{s.type=t.int32();break}case 4:{s.track&&s.track.length||(s.track=[]),s.track.push(h.centrifugal.centrifuge.protocol.TrackBatch.decode(t,t.uint32()));break}case 5:{s.untrack&&s.untrack.length||(s.untrack=[]),s.untrack.push(t.string());break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!f.isString(t.channel))return"channel: string expected";if(t.token!=null&&t.hasOwnProperty("token")&&!f.isString(t.token))return"token: string expected";if(t.type!=null&&t.hasOwnProperty("type")&&!f.isInteger(t.type))return"type: integer expected";if(t.track!=null&&t.hasOwnProperty("track")){if(!Array.isArray(t.track))return"track: array expected";for(let n=0;n<t.track.length;++n){let c=h.centrifugal.centrifuge.protocol.TrackBatch.verify(t.track[n]);if(c)return"track."+c}}if(t.untrack!=null&&t.hasOwnProperty("untrack")){if(!Array.isArray(t.untrack))return"untrack: array expected";for(let n=0;n<t.untrack.length;++n)if(!f.isString(t.untrack[n]))return"untrack: string[] expected"}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubRefreshRequest"},e})(),i.SubRefreshResult=(function(){function e(r){if(this.items=[],r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.expires=!1,e.prototype.ttl=0,e.prototype.items=f.emptyArray,e.encode=function(t,n){if(n||(n=S.create()),t.expires!=null&&Object.hasOwnProperty.call(t,"expires")&&n.uint32(8).bool(t.expires),t.ttl!=null&&Object.hasOwnProperty.call(t,"ttl")&&n.uint32(16).uint32(t.ttl),t.items!=null&&t.items.length)for(let c=0;c<t.items.length;++c)h.centrifugal.centrifuge.protocol.Publication.encode(t.items[c],n.uint32(26).fork()).ldelim();return n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.SubRefreshResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.expires=t.bool();break}case 2:{s.ttl=t.uint32();break}case 3:{s.items&&s.items.length||(s.items=[]),s.items.push(h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.expires!=null&&t.hasOwnProperty("expires")&&typeof t.expires!="boolean")return"expires: boolean expected";if(t.ttl!=null&&t.hasOwnProperty("ttl")&&!f.isInteger(t.ttl))return"ttl: integer expected";if(t.items!=null&&t.hasOwnProperty("items")){if(!Array.isArray(t.items))return"items: array expected";for(let n=0;n<t.items.length;++n){let c=h.centrifugal.centrifuge.protocol.Publication.verify(t.items[n]);if(c)return"items."+c}}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SubRefreshResult"},e})(),i.UnsubscribeRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.channel="",e.encode=function(t,n){return n||(n=S.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&n.uint32(10).string(t.channel),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.UnsubscribeRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.channel=t.string():t.skipType(u&7)}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!f.isString(t.channel)?"channel: string expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.UnsubscribeRequest"},e})(),i.UnsubscribeResult=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.encode=function(t,n){return n||(n=S.create()),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.UnsubscribeResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.UnsubscribeResult"},e})(),i.PublishRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.channel="",e.prototype.data=f.newBuffer([]),e.prototype.type=0,e.prototype.key="",e.prototype.removed=!1,e.encode=function(t,n){return n||(n=S.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&n.uint32(10).string(t.channel),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(18).bytes(t.data),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&n.uint32(24).int32(t.type),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&n.uint32(34).string(t.key),t.removed!=null&&Object.hasOwnProperty.call(t,"removed")&&n.uint32(40).bool(t.removed),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.PublishRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.channel=t.string();break}case 2:{s.data=t.bytes();break}case 3:{s.type=t.int32();break}case 4:{s.key=t.string();break}case 5:{s.removed=t.bool();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!f.isString(t.channel)?"channel: string expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data))?"data: buffer expected":t.type!=null&&t.hasOwnProperty("type")&&!f.isInteger(t.type)?"type: integer expected":t.key!=null&&t.hasOwnProperty("key")&&!f.isString(t.key)?"key: string expected":t.removed!=null&&t.hasOwnProperty("removed")&&typeof t.removed!="boolean"?"removed: boolean expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PublishRequest"},e})(),i.PublishResult=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.encode=function(t,n){return n||(n=S.create()),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.PublishResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PublishResult"},e})(),i.PresenceRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.channel="",e.encode=function(t,n){return n||(n=S.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&n.uint32(10).string(t.channel),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.PresenceRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.channel=t.string():t.skipType(u&7)}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!f.isString(t.channel)?"channel: string expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceRequest"},e})(),i.PresenceResult=(function(){function e(r){if(this.presence={},r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.presence=f.emptyObject,e.encode=function(t,n){if(n||(n=S.create()),t.presence!=null&&Object.hasOwnProperty.call(t,"presence"))for(let c=Object.keys(t.presence),s=0;s<c.length;++s)n.uint32(10).fork().uint32(10).string(c[s]),h.centrifugal.centrifuge.protocol.ClientInfo.encode(t.presence[c[s]],n.uint32(18).fork()).ldelim().ldelim();return n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.PresenceResult,u,d;for(;t.pos<c;){let y=t.uint32();switch(y>>>3){case 1:{s.presence===f.emptyObject&&(s.presence={});let g=t.uint32()+t.pos;for(u="",d=null;t.pos<g;){let k=t.uint32();switch(k>>>3){case 1:u=t.string();break;case 2:d=h.centrifugal.centrifuge.protocol.ClientInfo.decode(t,t.uint32());break;default:t.skipType(k&7);break}}s.presence[u]=d;break}default:t.skipType(y&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.presence!=null&&t.hasOwnProperty("presence")){if(!f.isObject(t.presence))return"presence: object expected";let n=Object.keys(t.presence);for(let c=0;c<n.length;++c){let s=h.centrifugal.centrifuge.protocol.ClientInfo.verify(t.presence[n[c]]);if(s)return"presence."+s}}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceResult"},e})(),i.PresenceStatsRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.channel="",e.encode=function(t,n){return n||(n=S.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&n.uint32(10).string(t.channel),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.PresenceStatsRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.channel=t.string():t.skipType(u&7)}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.channel!=null&&t.hasOwnProperty("channel")&&!f.isString(t.channel)?"channel: string expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceStatsRequest"},e})(),i.PresenceStatsResult=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.num_clients=0,e.prototype.num_users=0,e.encode=function(t,n){return n||(n=S.create()),t.num_clients!=null&&Object.hasOwnProperty.call(t,"num_clients")&&n.uint32(8).uint32(t.num_clients),t.num_users!=null&&Object.hasOwnProperty.call(t,"num_users")&&n.uint32(16).uint32(t.num_users),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.PresenceStatsResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.num_clients=t.uint32();break}case 2:{s.num_users=t.uint32();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.num_clients!=null&&t.hasOwnProperty("num_clients")&&!f.isInteger(t.num_clients)?"num_clients: integer expected":t.num_users!=null&&t.hasOwnProperty("num_users")&&!f.isInteger(t.num_users)?"num_users: integer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PresenceStatsResult"},e})(),i.StreamPosition=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.offset=f.Long?f.Long.fromBits(0,0,!0):0,e.prototype.epoch="",e.encode=function(t,n){return n||(n=S.create()),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&n.uint32(8).uint64(t.offset),t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&n.uint32(18).string(t.epoch),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.StreamPosition;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.offset=t.uint64();break}case 2:{s.epoch=t.string();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.offset!=null&&t.hasOwnProperty("offset")&&!f.isInteger(t.offset)&&!(t.offset&&f.isInteger(t.offset.low)&&f.isInteger(t.offset.high))?"offset: integer|Long expected":t.epoch!=null&&t.hasOwnProperty("epoch")&&!f.isString(t.epoch)?"epoch: string expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.StreamPosition"},e})(),i.HistoryRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.channel="",e.prototype.limit=0,e.prototype.since=null,e.prototype.reverse=!1,e.encode=function(t,n){return n||(n=S.create()),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&n.uint32(10).string(t.channel),t.limit!=null&&Object.hasOwnProperty.call(t,"limit")&&n.uint32(56).int32(t.limit),t.since!=null&&Object.hasOwnProperty.call(t,"since")&&h.centrifugal.centrifuge.protocol.StreamPosition.encode(t.since,n.uint32(66).fork()).ldelim(),t.reverse!=null&&Object.hasOwnProperty.call(t,"reverse")&&n.uint32(72).bool(t.reverse),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.HistoryRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.channel=t.string();break}case 7:{s.limit=t.int32();break}case 8:{s.since=h.centrifugal.centrifuge.protocol.StreamPosition.decode(t,t.uint32());break}case 9:{s.reverse=t.bool();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!f.isString(t.channel))return"channel: string expected";if(t.limit!=null&&t.hasOwnProperty("limit")&&!f.isInteger(t.limit))return"limit: integer expected";if(t.since!=null&&t.hasOwnProperty("since")){let n=h.centrifugal.centrifuge.protocol.StreamPosition.verify(t.since);if(n)return"since."+n}return t.reverse!=null&&t.hasOwnProperty("reverse")&&typeof t.reverse!="boolean"?"reverse: boolean expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.HistoryRequest"},e})(),i.HistoryResult=(function(){function e(r){if(this.publications=[],r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.publications=f.emptyArray,e.prototype.epoch="",e.prototype.offset=f.Long?f.Long.fromBits(0,0,!0):0,e.encode=function(t,n){if(n||(n=S.create()),t.publications!=null&&t.publications.length)for(let c=0;c<t.publications.length;++c)h.centrifugal.centrifuge.protocol.Publication.encode(t.publications[c],n.uint32(10).fork()).ldelim();return t.epoch!=null&&Object.hasOwnProperty.call(t,"epoch")&&n.uint32(18).string(t.epoch),t.offset!=null&&Object.hasOwnProperty.call(t,"offset")&&n.uint32(24).uint64(t.offset),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.HistoryResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.publications&&s.publications.length||(s.publications=[]),s.publications.push(h.centrifugal.centrifuge.protocol.Publication.decode(t,t.uint32()));break}case 2:{s.epoch=t.string();break}case 3:{s.offset=t.uint64();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.publications!=null&&t.hasOwnProperty("publications")){if(!Array.isArray(t.publications))return"publications: array expected";for(let n=0;n<t.publications.length;++n){let c=h.centrifugal.centrifuge.protocol.Publication.verify(t.publications[n]);if(c)return"publications."+c}}return t.epoch!=null&&t.hasOwnProperty("epoch")&&!f.isString(t.epoch)?"epoch: string expected":t.offset!=null&&t.hasOwnProperty("offset")&&!f.isInteger(t.offset)&&!(t.offset&&f.isInteger(t.offset.low)&&f.isInteger(t.offset.high))?"offset: integer|Long expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.HistoryResult"},e})(),i.PingRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.encode=function(t,n){return n||(n=S.create()),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.PingRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PingRequest"},e})(),i.PingResult=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.encode=function(t,n){return n||(n=S.create()),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.PingResult;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.PingResult"},e})(),i.RPCRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.data=f.newBuffer([]),e.prototype.method="",e.encode=function(t,n){return n||(n=S.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(10).bytes(t.data),t.method!=null&&Object.hasOwnProperty.call(t,"method")&&n.uint32(18).string(t.method),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.RPCRequest;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.data=t.bytes();break}case 2:{s.method=t.string();break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data))?"data: buffer expected":t.method!=null&&t.hasOwnProperty("method")&&!f.isString(t.method)?"method: string expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RPCRequest"},e})(),i.RPCResult=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.data=f.newBuffer([]),e.encode=function(t,n){return n||(n=S.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(10).bytes(t.data),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.RPCResult;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.data=t.bytes():t.skipType(u&7)}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data))?"data: buffer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.RPCResult"},e})(),i.SendRequest=(function(){function e(r){if(r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.data=f.newBuffer([]),e.encode=function(t,n){return n||(n=S.create()),t.data!=null&&Object.hasOwnProperty.call(t,"data")&&n.uint32(10).bytes(t.data),n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.SendRequest;for(;t.pos<c;){let u=t.uint32();u>>>3===1?s.data=t.bytes():t.skipType(u&7)}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.data!=null&&t.hasOwnProperty("data")&&!(t.data&&typeof t.data.length=="number"||f.isString(t.data))?"data: buffer expected":null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.SendRequest"},e})(),i.FilterNode=(function(){function e(r){if(this.vals=[],this.nodes=[],r)for(let t=Object.keys(r),n=0;n<t.length;++n)r[t[n]]!=null&&(this[t[n]]=r[t[n]])}return e.prototype.op="",e.prototype.key="",e.prototype.cmp="",e.prototype.val="",e.prototype.vals=f.emptyArray,e.prototype.nodes=f.emptyArray,e.encode=function(t,n){if(n||(n=S.create()),t.op!=null&&Object.hasOwnProperty.call(t,"op")&&n.uint32(10).string(t.op),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&n.uint32(18).string(t.key),t.cmp!=null&&Object.hasOwnProperty.call(t,"cmp")&&n.uint32(26).string(t.cmp),t.val!=null&&Object.hasOwnProperty.call(t,"val")&&n.uint32(34).string(t.val),t.vals!=null&&t.vals.length)for(let c=0;c<t.vals.length;++c)n.uint32(42).string(t.vals[c]);if(t.nodes!=null&&t.nodes.length)for(let c=0;c<t.nodes.length;++c)h.centrifugal.centrifuge.protocol.FilterNode.encode(t.nodes[c],n.uint32(50).fork()).ldelim();return n},e.encodeDelimited=function(t,n){return this.encode(t,n).ldelim()},e.decode=function(t,n){t instanceof p||(t=p.create(t));let c=n===void 0?t.len:t.pos+n,s=new h.centrifugal.centrifuge.protocol.FilterNode;for(;t.pos<c;){let u=t.uint32();switch(u>>>3){case 1:{s.op=t.string();break}case 2:{s.key=t.string();break}case 3:{s.cmp=t.string();break}case 4:{s.val=t.string();break}case 5:{s.vals&&s.vals.length||(s.vals=[]),s.vals.push(t.string());break}case 6:{s.nodes&&s.nodes.length||(s.nodes=[]),s.nodes.push(h.centrifugal.centrifuge.protocol.FilterNode.decode(t,t.uint32()));break}default:t.skipType(u&7);break}}return s},e.decodeDelimited=function(t){return t instanceof p||(t=new p(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.op!=null&&t.hasOwnProperty("op")&&!f.isString(t.op))return"op: string expected";if(t.key!=null&&t.hasOwnProperty("key")&&!f.isString(t.key))return"key: string expected";if(t.cmp!=null&&t.hasOwnProperty("cmp")&&!f.isString(t.cmp))return"cmp: string expected";if(t.val!=null&&t.hasOwnProperty("val")&&!f.isString(t.val))return"val: string expected";if(t.vals!=null&&t.hasOwnProperty("vals")){if(!Array.isArray(t.vals))return"vals: array expected";for(let n=0;n<t.vals.length;++n)if(!f.isString(t.vals[n]))return"vals: string[] expected"}if(t.nodes!=null&&t.hasOwnProperty("nodes")){if(!Array.isArray(t.nodes))return"nodes: array expected";for(let n=0;n<t.nodes.length;++n){let c=h.centrifugal.centrifuge.protocol.FilterNode.verify(t.nodes[n]);if(c)return"nodes."+c}}return null},e.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/centrifugal.centrifuge.protocol.FilterNode"},e})(),i})(),o})(),l})();var An=Wt.centrifuge.protocol.Command,ye=Wt.centrifuge.protocol.Reply,di=Wt.centrifuge.protocol.EmulationRequest,Bn=64*1024*1024,Gt=class{name(){return"protobuf"}encodeEmulationRequest(o){let i=lt.Writer.create();return di.encode(o,i),i.finish()}encodeCommands(o){let i=lt.Writer.create();for(let e of o)i.fork(),An.encodeDelimited(e,i);return i.finish()}encodeReplies(o){let i=lt.Writer.create();for(let e of o)i.fork(),ye.encodeDelimited(e,i);return i.finish()}decodeReplies(o){let i=[],e=lt.Reader.create(new Uint8Array(o));for(;e.pos<e.len;){let r=ye.decodeDelimited(e);i.push(r)}return i}decodeCommands(o){let i=[],e=lt.Reader.create(new Uint8Array(o));for(;e.pos<e.len;){let r=An.decodeDelimited(e);i.push(r)}return i}decodeReply(o){let i=lt.Reader.create(o instanceof Uint8Array?o:new Uint8Array(o));if(i.pos>=i.len)return{ok:!1};let e;try{e=i.uint32()}catch(r){if(r instanceof RangeError)return{ok:!1};throw r}if(e>Bn)throw new Error(`reply length ${e} exceeds ${Bn}`);return i.pos+e>i.len?{ok:!1}:(ye.decode(i,e),{ok:!0,pos:i.pos})}applyDeltaIfNeeded(o,i){let e,r,t;if(o.delta){t=!0;let n=Mt(i,o.data);e=new Uint8Array(n),r=n}else t=!1,e=o.data,r=o.data;return{newData:e,newPrevValue:r,isDelta:t,wireBytes:o.data.length,fullBytes:r.length}}};var Ht=class extends ft{_formatOverride(){this._codec=new Gt}};globalThis.Centrifuge=Ht;})();
/*! Bundled license information:
long/umd/index.js:
(**
* @license
* Copyright 2009 The Closure Library Authors
* Copyright 2020 Daniel Wirtz / The long.js Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*)
*/
//# sourceMappingURL=centrifuge.protobuf.js.map