var Ar=Object.defineProperty;var Cr=(e,t,i)=>t in e?Ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var It=(e,t,i)=>(Cr(e,typeof t!="symbol"?t+"":t,i),i);const $e=new WeakMap,ze=new WeakMap;class qe{constructor(){this.onabort=null,$e.set(this,[]),ze.set(this,!1)}get aborted(){if(!ze.has(this))throw new TypeError("Expected `this` to be an instance of AbortSignal.");return ze.get(this)}static get none(){return new qe}addEventListener(t,i){if(!$e.has(this))throw new TypeError("Expected `this` to be an instance of AbortSignal.");$e.get(this).push(i)}removeEventListener(t,i){if(!$e.has(this))throw new TypeError("Expected `this` to be an instance of AbortSignal.");const o=$e.get(this),c=o.indexOf(i);c>-1&&o.splice(c,1)}dispatchEvent(t){throw new Error("This is a stub dispatchEvent implementation that should not be used. It only exists for type-checking purposes.")}}function At(e){if(e.aborted)return;e.onabort&&e.onabort.call(e);const t=$e.get(e);t&&t.slice().forEach(i=>{i.call(e,{type:"abort"})}),ze.set(e,!0)}let Ct=class extends Error{constructor(t){super(t),this.name="AbortError"}};class qt{constructor(t){if(this._signal=new qe,!!t){Array.isArray(t)||(t=arguments);for(const i of t)i.aborted?this.abort():i.addEventListener("abort",()=>{this.abort()})}}get signal(){return this._signal}abort(){At(this._signal)}static timeout(t){const i=new qe,o=setTimeout(At,t,i);return typeof o.unref=="function"&&o.unref(),i}}class Dr extends Error{constructor(t){super(t),this.name="AbortError"}}function Mr(e,t){const{cleanupBeforeAbort:i,abortSignal:o,abortErrorMsg:c}=t??{};return new Promise((h,u)=>{function l(){u(new Dr(c??"The operation was aborted."))}function p(){o==null||o.removeEventListener("abort",I)}function I(){i==null||i(),p(),l()}if(o!=null&&o.aborted)return l();try{e(A=>{p(),h(A)},A=>{p(),u(A)})}catch(A){u(A)}o==null||o.addEventListener("abort",I)})}const $r="The delay was aborted.";function Ye(e,t){let i;const{abortSignal:o,abortErrorMsg:c}={};return Mr(h=>{i=setTimeout(h,e)},{cleanupBeforeAbort:()=>clearTimeout(i),abortSignal:o,abortErrorMsg:c??$r})}var xe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ae(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var gt={exports:{}},ke=typeof Reflect=="object"?Reflect:null,Dt=ke&&typeof ke.apply=="function"?ke.apply:function(t,i,o){return Function.prototype.apply.call(t,i,o)},Xe;ke&&typeof ke.ownKeys=="function"?Xe=ke.ownKeys:Object.getOwnPropertySymbols?Xe=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Xe=function(t){return Object.getOwnPropertyNames(t)};function kr(e){console&&console.warn&&console.warn(e)}var Jt=Number.isNaN||function(t){return t!==t};function ee(){ee.init.call(this)}gt.exports=ee;gt.exports.once=Sr;ee.EventEmitter=ee;ee.prototype._events=void 0;ee.prototype._eventsCount=0;ee.prototype._maxListeners=void 0;var Mt=10;function Qe(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(ee,"defaultMaxListeners",{enumerable:!0,get:function(){return Mt},set:function(e){if(typeof e!="number"||e<0||Jt(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Mt=e}});ee.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};ee.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Jt(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function Kt(e){return e._maxListeners===void 0?ee.defaultMaxListeners:e._maxListeners}ee.prototype.getMaxListeners=function(){return Kt(this)};ee.prototype.emit=function(t){for(var i=[],o=1;o0&&(u=i[0]),u instanceof Error)throw u;var l=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw l.context=u,l}var p=h[t];if(p===void 0)return!1;if(typeof p=="function")Dt(p,this,i);else for(var I=p.length,A=rr(p,I),o=0;o0&&u.length>c&&!u.warned){u.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=u.length,kr(l)}return e}ee.prototype.addListener=function(t,i){return Zt(this,t,i,!1)};ee.prototype.on=ee.prototype.addListener;ee.prototype.prependListener=function(t,i){return Zt(this,t,i,!0)};function Rr(){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 Qt(e,t,i){var o={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},c=Rr.bind(o);return c.listener=i,o.wrapFn=c,c}ee.prototype.once=function(t,i){return Qe(i),this.on(t,Qt(this,t,i)),this};ee.prototype.prependOnceListener=function(t,i){return Qe(i),this.prependListener(t,Qt(this,t,i)),this};ee.prototype.removeListener=function(t,i){var o,c,h,u,l;if(Qe(i),c=this._events,c===void 0)return this;if(o=c[t],o===void 0)return this;if(o===i||o.listener===i)--this._eventsCount===0?this._events=Object.create(null):(delete c[t],c.removeListener&&this.emit("removeListener",t,o.listener||i));else if(typeof o!="function"){for(h=-1,u=o.length-1;u>=0;u--)if(o[u]===i||o[u].listener===i){l=o[u].listener,h=u;break}if(h<0)return this;h===0?o.shift():Lr(o,h),o.length===1&&(c[t]=o[0]),c.removeListener!==void 0&&this.emit("removeListener",t,l||i)}return this};ee.prototype.off=ee.prototype.removeListener;ee.prototype.removeAllListeners=function(t){var i,o,c;if(o=this._events,o===void 0)return this;if(o.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):o[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[t]),this;if(arguments.length===0){var h=Object.keys(o),u;for(c=0;c=0;c--)this.removeListener(t,i[c]);return this};function er(e,t,i){var o=e._events;if(o===void 0)return[];var c=o[t];return c===void 0?[]:typeof c=="function"?i?[c.listener||c]:[c]:i?Or(c):rr(c,c.length)}ee.prototype.listeners=function(t){return er(this,t,!0)};ee.prototype.rawListeners=function(t){return er(this,t,!1)};ee.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):tr.call(e,t)};ee.prototype.listenerCount=tr;function tr(e){var t=this._events;if(t!==void 0){var i=t[e];if(typeof i=="function")return 1;if(i!==void 0)return i.length}return 0}ee.prototype.eventNames=function(){return this._eventsCount>0?Xe(this._events):[]};function rr(e,t){for(var i=new Array(t),o=0;o0){const t=String(e[0]);t.includes(":error")?console.error(...e):t.includes(":warning")?console.warn(...e):t.includes(":info")?console.info(...e):t.includes(":verbose")?console.debug(...e):console.debug(...e)}}var $t={};const kt=typeof process<"u"&&$t&&$t.DEBUG||void 0;let ir,ht=[],ft=[];const Je=[];kt&&bt(kt);const Re=Object.assign(e=>sr(e),{enable:bt,enabled:wt,disable:Nr,log:Pr});function bt(e){ir=e,ht=[],ft=[];const t=/\*/g,i=e.split(",").map(o=>o.trim().replace(t,".*?"));for(const o of i)o.startsWith("-")?ft.push(new RegExp(`^${o.substr(1)}$`)):ht.push(new RegExp(`^${o}$`));for(const o of Je)o.enabled=wt(o.namespace)}function wt(e){if(e.endsWith("*"))return!0;for(const t of ft)if(t.test(e))return!1;for(const t of ht)if(t.test(e))return!0;return!1}function Nr(){const e=ir||"";return bt(""),e}function sr(e){const t=Object.assign(i,{enabled:wt(e),destroy:jr,log:Re.log,namespace:e,extend:Gr});function i(...o){t.enabled&&(o.length>0&&(o[0]=`${e} ${o[0]}`),t.log(...o))}return Je.push(t),t}function jr(){const e=Je.indexOf(this);return e>=0?(Je.splice(e,1),!0):!1}function Gr(e){const t=sr(`${this.namespace}:${e}`);return t.log=this.log,t}var Rt={};const or=new Set,Ge=typeof process<"u"&&Rt&&Rt.AZURE_LOG_LEVEL||void 0;let dt;const pt=Re("azure");pt.log=(...e)=>{Re.log(...e)};const vt=["verbose","info","warning","error"];Ge&&(lr(Ge)?Wr(Ge):console.error(`AZURE_LOG_LEVEL set to unknown log level '${Ge}'; logging is not enabled. Acceptable values: ${vt.join(", ")}.`));function Wr(e){if(e&&!lr(e))throw new Error(`Unknown log level '${e}'. Acceptable values: ${vt.join(",")}`);dt=e;const t=[];for(const i of or)cr(i)&&t.push(i.namespace);Re.enable(t.join(","))}const Lt={verbose:400,info:300,warning:200,error:100};function Vr(e){const t=pt.extend(e);return ar(pt,t),{error:We(t,"error"),warning:We(t,"warning"),info:We(t,"info"),verbose:We(t,"verbose")}}function ar(e,t){t.log=(...i)=>{e.log(...i)}}function We(e,t){const i=Object.assign(e.extend(t),{level:t});if(ar(e,i),cr(i)){const o=Re.disable();Re.enable(o+","+i.namespace)}return or.add(i),i}function cr(e){return!!(dt&&Lt[e.level]<=Lt[dt])}function lr(e){return vt.includes(e)}const ye=Vr("web-pubsub-client");var xt={},et={};et.byteLength=Yr;et.toByteArray=qr;et.fromByteArray=Zr;var Ee=[],ve=[],Hr=typeof Uint8Array<"u"?Uint8Array:Array,ot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Me=0,zr=ot.length;Me0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");i===-1&&(i=t);var o=i===t?0:4-i%4;return[i,o]}function Yr(e){var t=ur(e),i=t[0],o=t[1];return(i+o)*3/4-o}function Xr(e,t,i){return(t+i)*3/4-i}function qr(e){var t,i=ur(e),o=i[0],c=i[1],h=new Hr(Xr(e,o,c)),u=0,l=c>0?o-4:o,p;for(p=0;p>16&255,h[u++]=t>>8&255,h[u++]=t&255;return c===2&&(t=ve[e.charCodeAt(p)]<<2|ve[e.charCodeAt(p+1)]>>4,h[u++]=t&255),c===1&&(t=ve[e.charCodeAt(p)]<<10|ve[e.charCodeAt(p+1)]<<4|ve[e.charCodeAt(p+2)]>>2,h[u++]=t>>8&255,h[u++]=t&255),h}function Jr(e){return Ee[e>>18&63]+Ee[e>>12&63]+Ee[e>>6&63]+Ee[e&63]}function Kr(e,t,i){for(var o,c=[],h=t;hl?l:u+h));return o===1?(t=e[i-1],c.push(Ee[t>>2]+Ee[t<<4&63]+"==")):o===2&&(t=(e[i-2]<<8)+e[i-1],c.push(Ee[t>>10]+Ee[t>>4&63]+Ee[t<<2&63]+"=")),c.join("")}var _t={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */_t.read=function(e,t,i,o,c){var h,u,l=c*8-o-1,p=(1<>1,A=-7,v=i?c-1:0,m=i?-1:1,_=e[t+v];for(v+=m,h=_&(1<<-A)-1,_>>=-A,A+=l;A>0;h=h*256+e[t+v],v+=m,A-=8);for(u=h&(1<<-A)-1,h>>=-A,A+=o;A>0;u=u*256+e[t+v],v+=m,A-=8);if(h===0)h=1-I;else{if(h===p)return u?NaN:(_?-1:1)*(1/0);u=u+Math.pow(2,o),h=h-I}return(_?-1:1)*u*Math.pow(2,h-o)};_t.write=function(e,t,i,o,c,h){var u,l,p,I=h*8-c-1,A=(1<>1,m=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=o?0:h-1,b=o?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,u=A):(u=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-u))<1&&(u--,p*=2),u+v>=1?t+=m/p:t+=m*Math.pow(2,1-v),t*p>=2&&(u++,p/=2),u+v>=A?(l=0,u=A):u+v>=1?(l=(t*p-1)*Math.pow(2,c),u=u+v):(l=t*Math.pow(2,v-1)*Math.pow(2,c),u=0));c>=8;e[i+_]=l&255,_+=b,l/=256,c-=8);for(u=u<0;e[i+_]=u&255,_+=b,u/=256,I-=8);e[i+_-b]|=g*128};/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */(function(e){const t=et,i=_t,o=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=l,e.SlowBuffer=V,e.INSPECT_MAX_BYTES=50;const c=2147483647;e.kMaxLength=c,l.TYPED_ARRAY_SUPPORT=h(),!l.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{const s=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(s,r),s.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function u(s){if(s>c)throw new RangeError('The value "'+s+'" is invalid for option "size"');const r=new Uint8Array(s);return Object.setPrototypeOf(r,l.prototype),r}function l(s,r,n){if(typeof s=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(s)}return p(s,r,n)}l.poolSize=8192;function p(s,r,n){if(typeof s=="string")return m(s,r);if(ArrayBuffer.isView(s))return b(s);if(s==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s);if(B(s,ArrayBuffer)||s&&B(s.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(B(s,SharedArrayBuffer)||s&&B(s.buffer,SharedArrayBuffer)))return g(s,r,n);if(typeof s=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const a=s.valueOf&&s.valueOf();if(a!=null&&a!==s)return l.from(a,r,n);const f=U(s);if(f)return f;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof s[Symbol.toPrimitive]=="function")return l.from(s[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s)}l.from=function(s,r,n){return p(s,r,n)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array);function I(s){if(typeof s!="number")throw new TypeError('"size" argument must be of type number');if(s<0)throw new RangeError('The value "'+s+'" is invalid for option "size"')}function A(s,r,n){return I(s),s<=0?u(s):r!==void 0?typeof n=="string"?u(s).fill(r,n):u(s).fill(r):u(s)}l.alloc=function(s,r,n){return A(s,r,n)};function v(s){return I(s),u(s<0?0:L(s)|0)}l.allocUnsafe=function(s){return v(s)},l.allocUnsafeSlow=function(s){return v(s)};function m(s,r){if((typeof r!="string"||r==="")&&(r="utf8"),!l.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const n=F(s,r)|0;let a=u(n);const f=a.write(s,r);return f!==n&&(a=a.slice(0,f)),a}function _(s){const r=s.length<0?0:L(s.length)|0,n=u(r);for(let a=0;a=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return s|0}function V(s){return+s!=s&&(s=0),l.alloc(+s)}l.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==l.prototype},l.compare=function(r,n){if(B(r,Uint8Array)&&(r=l.from(r,r.offset,r.byteLength)),B(n,Uint8Array)&&(n=l.from(n,n.offset,n.byteLength)),!l.isBuffer(r)||!l.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let a=r.length,f=n.length;for(let d=0,y=Math.min(a,f);df.length?(l.isBuffer(y)||(y=l.from(y)),y.copy(f,d)):Uint8Array.prototype.set.call(f,y,d);else if(l.isBuffer(y))y.copy(f,d);else throw new TypeError('"list" argument must be an Array of Buffers');d+=y.length}return f};function F(s,r){if(l.isBuffer(s))return s.length;if(ArrayBuffer.isView(s)||B(s,ArrayBuffer))return s.byteLength;if(typeof s!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof s);const n=s.length,a=arguments.length>2&&arguments[2]===!0;if(!a&&n===0)return 0;let f=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Ce(s).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return S(s).length;default:if(f)return a?-1:Ce(s).length;r=(""+r).toLowerCase(),f=!0}}l.byteLength=F;function R(s,r,n){let a=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(s||(s="utf8");;)switch(s){case"hex":return G(this,r,n);case"utf8":case"utf-8":return k(this,r,n);case"ascii":return D(this,r,n);case"latin1":case"binary":return E(this,r,n);case"base64":return le(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return W(this,r,n);default:if(a)throw new TypeError("Unknown encoding: "+s);s=(s+"").toLowerCase(),a=!0}}l.prototype._isBuffer=!0;function x(s,r,n){const a=s[r];s[r]=s[n],s[n]=a}l.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;nn&&(r+=" ... "),""},o&&(l.prototype[o]=l.prototype.inspect),l.prototype.compare=function(r,n,a,f,d){if(B(r,Uint8Array)&&(r=l.from(r,r.offset,r.byteLength)),!l.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),a===void 0&&(a=r?r.length:0),f===void 0&&(f=0),d===void 0&&(d=this.length),n<0||a>r.length||f<0||d>this.length)throw new RangeError("out of range index");if(f>=d&&n>=a)return 0;if(f>=d)return-1;if(n>=a)return 1;if(n>>>=0,a>>>=0,f>>>=0,d>>>=0,this===r)return 0;let y=d-f,X=a-n;const ae=Math.min(y,X),oe=this.slice(f,d),ce=r.slice(n,a);for(let re=0;re2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,K(n)&&(n=f?0:s.length-1),n<0&&(n=s.length+n),n>=s.length){if(f)return-1;n=s.length-1}else if(n<0)if(f)n=0;else return-1;if(typeof r=="string"&&(r=l.from(r,a)),l.isBuffer(r))return r.length===0?-1:j(s,r,n,a,f);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?f?Uint8Array.prototype.indexOf.call(s,r,n):Uint8Array.prototype.lastIndexOf.call(s,r,n):j(s,[r],n,a,f);throw new TypeError("val must be string, number or Buffer")}function j(s,r,n,a,f){let d=1,y=s.length,X=r.length;if(a!==void 0&&(a=String(a).toLowerCase(),a==="ucs2"||a==="ucs-2"||a==="utf16le"||a==="utf-16le")){if(s.length<2||r.length<2)return-1;d=2,y/=2,X/=2,n/=2}function ae(ce,re){return d===1?ce[re]:ce.readUInt16BE(re*d)}let oe;if(f){let ce=-1;for(oe=n;oey&&(n=y-X),oe=n;oe>=0;oe--){let ce=!0;for(let re=0;ref&&(a=f)):a=f;const d=r.length;a>d/2&&(a=d/2);let y;for(y=0;y>>0,isFinite(a)?(a=a>>>0,f===void 0&&(f="utf8")):(f=a,a=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const d=this.length-n;if((a===void 0||a>d)&&(a=d),r.length>0&&(a<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");f||(f="utf8");let y=!1;for(;;)switch(f){case"hex":return Q(this,r,n,a);case"utf8":case"utf-8":return Z(this,r,n,a);case"ascii":case"latin1":case"binary":return z(this,r,n,a);case"base64":return Y(this,r,n,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,r,n,a);default:if(y)throw new TypeError("Unknown encoding: "+f);f=(""+f).toLowerCase(),y=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function le(s,r,n){return r===0&&n===s.length?t.fromByteArray(s):t.fromByteArray(s.slice(r,n))}function k(s,r,n){n=Math.min(s.length,n);const a=[];let f=r;for(;f239?4:d>223?3:d>191?2:1;if(f+X<=n){let ae,oe,ce,re;switch(X){case 1:d<128&&(y=d);break;case 2:ae=s[f+1],(ae&192)===128&&(re=(d&31)<<6|ae&63,re>127&&(y=re));break;case 3:ae=s[f+1],oe=s[f+2],(ae&192)===128&&(oe&192)===128&&(re=(d&15)<<12|(ae&63)<<6|oe&63,re>2047&&(re<55296||re>57343)&&(y=re));break;case 4:ae=s[f+1],oe=s[f+2],ce=s[f+3],(ae&192)===128&&(oe&192)===128&&(ce&192)===128&&(re=(d&15)<<18|(ae&63)<<12|(oe&63)<<6|ce&63,re>65535&&re<1114112&&(y=re))}}y===null?(y=65533,X=1):y>65535&&(y-=65536,a.push(y>>>10&1023|55296),y=56320|y&1023),a.push(y),f+=X}return w(a)}const T=4096;function w(s){const r=s.length;if(r<=T)return String.fromCharCode.apply(String,s);let n="",a=0;for(;aa)&&(n=a);let f="";for(let d=r;da&&(r=a),n<0?(n+=a,n<0&&(n=0)):n>a&&(n=a),nn)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(r,n,a){r=r>>>0,n=n>>>0,a||P(r,n,this.length);let f=this[r],d=1,y=0;for(;++y>>0,n=n>>>0,a||P(r,n,this.length);let f=this[r+--n],d=1;for(;n>0&&(d*=256);)f+=this[r+--n]*d;return f},l.prototype.readUint8=l.prototype.readUInt8=function(r,n){return r=r>>>0,n||P(r,1,this.length),this[r]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||P(r,2,this.length),this[r]|this[r+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||P(r,2,this.length),this[r]<<8|this[r+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||P(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||P(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},l.prototype.readBigUInt64LE=N(function(r){r=r>>>0,ue(r,"offset");const n=this[r],a=this[r+7];(n===void 0||a===void 0)&&_e(r,this.length-8);const f=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,d=this[++r]+this[++r]*2**8+this[++r]*2**16+a*2**24;return BigInt(f)+(BigInt(d)<>>0,ue(r,"offset");const n=this[r],a=this[r+7];(n===void 0||a===void 0)&&_e(r,this.length-8);const f=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],d=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+a;return(BigInt(f)<>>0,n=n>>>0,a||P(r,n,this.length);let f=this[r],d=1,y=0;for(;++y=d&&(f-=Math.pow(2,8*n)),f},l.prototype.readIntBE=function(r,n,a){r=r>>>0,n=n>>>0,a||P(r,n,this.length);let f=n,d=1,y=this[r+--f];for(;f>0&&(d*=256);)y+=this[r+--f]*d;return d*=128,y>=d&&(y-=Math.pow(2,8*n)),y},l.prototype.readInt8=function(r,n){return r=r>>>0,n||P(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},l.prototype.readInt16LE=function(r,n){r=r>>>0,n||P(r,2,this.length);const a=this[r]|this[r+1]<<8;return a&32768?a|4294901760:a},l.prototype.readInt16BE=function(r,n){r=r>>>0,n||P(r,2,this.length);const a=this[r+1]|this[r]<<8;return a&32768?a|4294901760:a},l.prototype.readInt32LE=function(r,n){return r=r>>>0,n||P(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},l.prototype.readInt32BE=function(r,n){return r=r>>>0,n||P(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},l.prototype.readBigInt64LE=N(function(r){r=r>>>0,ue(r,"offset");const n=this[r],a=this[r+7];(n===void 0||a===void 0)&&_e(r,this.length-8);const f=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(a<<24);return(BigInt(f)<>>0,ue(r,"offset");const n=this[r],a=this[r+7];(n===void 0||a===void 0)&&_e(r,this.length-8);const f=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(f)<>>0,n||P(r,4,this.length),i.read(this,r,!0,23,4)},l.prototype.readFloatBE=function(r,n){return r=r>>>0,n||P(r,4,this.length),i.read(this,r,!1,23,4)},l.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||P(r,8,this.length),i.read(this,r,!0,52,8)},l.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||P(r,8,this.length),i.read(this,r,!1,52,8)};function H(s,r,n,a,f,d){if(!l.isBuffer(s))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>f||rs.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(r,n,a,f){if(r=+r,n=n>>>0,a=a>>>0,!f){const X=Math.pow(2,8*a)-1;H(this,r,n,a,X,0)}let d=1,y=0;for(this[n]=r&255;++y>>0,a=a>>>0,!f){const X=Math.pow(2,8*a)-1;H(this,r,n,a,X,0)}let d=a-1,y=1;for(this[n+d]=r&255;--d>=0&&(y*=256);)this[n+d]=r/y&255;return n+a},l.prototype.writeUint8=l.prototype.writeUInt8=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,1,255,0),this[n]=r&255,n+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function q(s,r,n,a,f){de(r,a,f,s,n,7);let d=Number(r&BigInt(4294967295));s[n++]=d,d=d>>8,s[n++]=d,d=d>>8,s[n++]=d,d=d>>8,s[n++]=d;let y=Number(r>>BigInt(32)&BigInt(4294967295));return s[n++]=y,y=y>>8,s[n++]=y,y=y>>8,s[n++]=y,y=y>>8,s[n++]=y,n}function se(s,r,n,a,f){de(r,a,f,s,n,7);let d=Number(r&BigInt(4294967295));s[n+7]=d,d=d>>8,s[n+6]=d,d=d>>8,s[n+5]=d,d=d>>8,s[n+4]=d;let y=Number(r>>BigInt(32)&BigInt(4294967295));return s[n+3]=y,y=y>>8,s[n+2]=y,y=y>>8,s[n+1]=y,y=y>>8,s[n]=y,n+8}l.prototype.writeBigUInt64LE=N(function(r,n=0){return q(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeBigUInt64BE=N(function(r,n=0){return se(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeIntLE=function(r,n,a,f){if(r=+r,n=n>>>0,!f){const ae=Math.pow(2,8*a-1);H(this,r,n,a,ae-1,-ae)}let d=0,y=1,X=0;for(this[n]=r&255;++d>0)-X&255;return n+a},l.prototype.writeIntBE=function(r,n,a,f){if(r=+r,n=n>>>0,!f){const ae=Math.pow(2,8*a-1);H(this,r,n,a,ae-1,-ae)}let d=a-1,y=1,X=0;for(this[n+d]=r&255;--d>=0&&(y*=256);)r<0&&X===0&&this[n+d+1]!==0&&(X=1),this[n+d]=(r/y>>0)-X&255;return n+a},l.prototype.writeInt8=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},l.prototype.writeInt16LE=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},l.prototype.writeInt16BE=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},l.prototype.writeInt32LE=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},l.prototype.writeInt32BE=function(r,n,a){return r=+r,n=n>>>0,a||H(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},l.prototype.writeBigInt64LE=N(function(r,n=0){return q(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),l.prototype.writeBigInt64BE=N(function(r,n=0){return se(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ne(s,r,n,a,f,d){if(n+a>s.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function be(s,r,n,a,f){return r=+r,n=n>>>0,f||ne(s,r,n,4),i.write(s,r,n,a,23,4),n+4}l.prototype.writeFloatLE=function(r,n,a){return be(this,r,n,!0,a)},l.prototype.writeFloatBE=function(r,n,a){return be(this,r,n,!1,a)};function me(s,r,n,a,f){return r=+r,n=n>>>0,f||ne(s,r,n,8),i.write(s,r,n,a,52,8),n+8}l.prototype.writeDoubleLE=function(r,n,a){return me(this,r,n,!0,a)},l.prototype.writeDoubleBE=function(r,n,a){return me(this,r,n,!1,a)},l.prototype.copy=function(r,n,a,f){if(!l.isBuffer(r))throw new TypeError("argument should be a Buffer");if(a||(a=0),!f&&f!==0&&(f=this.length),n>=r.length&&(n=r.length),n||(n=0),f>0&&f=this.length)throw new RangeError("Index out of range");if(f<0)throw new RangeError("sourceEnd out of bounds");f>this.length&&(f=this.length),r.length-n>>0,a=a===void 0?this.length:a>>>0,r||(r=0);let d;if(typeof r=="number")for(d=n;d2**32?f=te(String(n)):typeof n=="bigint"&&(f=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(f=te(f)),f+="n"),a+=` It must be ${r}. Received ${f}`,a},RangeError);function te(s){let r="",n=s.length;const a=s[0]==="-"?1:0;for(;n>=a+4;n-=3)r=`_${s.slice(n-3,n)}${r}`;return`${s.slice(0,n)}${r}`}function fe(s,r,n){ue(r,"offset"),(s[r]===void 0||s[r+n]===void 0)&&_e(r,s.length-(n+1))}function de(s,r,n,a,f,d){if(s>n||s= 0${y} and < 2${y} ** ${(d+1)*8}${y}`:X=`>= -(2${y} ** ${(d+1)*8-1}${y}) and < 2 ** ${(d+1)*8-1}${y}`,new pe.ERR_OUT_OF_RANGE("value",X,s)}fe(a,f,d)}function ue(s,r){if(typeof s!="number")throw new pe.ERR_INVALID_ARG_TYPE(r,"number",s)}function _e(s,r,n){throw Math.floor(s)!==s?(ue(s,n),new pe.ERR_OUT_OF_RANGE("offset","an integer",s)):r<0?new pe.ERR_BUFFER_OUT_OF_BOUNDS:new pe.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,s)}const Ue=/[^+/0-9A-Za-z-_]/g;function st(s){if(s=s.split("=")[0],s=s.trim().replace(Ue,""),s.length<2)return"";for(;s.length%4!==0;)s=s+"=";return s}function Ce(s,r){r=r||1/0;let n;const a=s.length;let f=null;const d=[];for(let y=0;y55295&&n<57344){if(!f){if(n>56319){(r-=3)>-1&&d.push(239,191,189);continue}else if(y+1===a){(r-=3)>-1&&d.push(239,191,189);continue}f=n;continue}if(n<56320){(r-=3)>-1&&d.push(239,191,189),f=n;continue}n=(f-55296<<10|n-56320)+65536}else f&&(r-=3)>-1&&d.push(239,191,189);if(f=null,n<128){if((r-=1)<0)break;d.push(n)}else if(n<2048){if((r-=2)<0)break;d.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;d.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;d.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return d}function C(s){const r=[];for(let n=0;n>8,f=n%256,d.push(f),d.push(a);return d}function S(s){return t.toByteArray(st(s))}function J(s,r,n,a){let f;for(f=0;f=r.length||f>=s.length);++f)r[f+n]=s[f];return f}function B(s,r){return s instanceof r||s!=null&&s.constructor!=null&&s.constructor.name!=null&&s.constructor.name===r.name}function K(s){return s!==s}const ie=function(){const s="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){const a=n*16;for(let f=0;f<16;++f)r[a+f]=s[n]+s[f]}return r}();function N(s){return typeof BigInt>"u"?Te:s}function Te(){throw new Error("BigInt not supported")}})(xt);function Qr(e){if(typeof e!="string")throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)throw new Error("No input");const t=JSON.parse(e),i=t;let o;if(i.type==="system")if(i.event==="connected")o=Object.assign(Object.assign({},t),{kind:"connected"});else if(i.event==="disconnected")o=Object.assign(Object.assign({},t),{kind:"disconnected"});else return null;else if(i.type==="message")if(i.from==="group"){const c=St(t.data,t.dataType);if(c===null)return null;o=Object.assign(Object.assign({},t),{data:c,kind:"groupData"})}else if(i.from==="server"){const c=St(t.data,t.dataType);if(c===null)return null;o=Object.assign(Object.assign({},t),{data:c,kind:"serverData"})}else return null;else if(i.type==="ack")o=Object.assign(Object.assign({},t),{kind:"ack"});else return null;return o}function en(e){let t;switch(e.kind){case"joinGroup":{t={type:"joinGroup",group:e.group,ackId:e.ackId};break}case"leaveGroup":{t={type:"leaveGroup",group:e.group,ackId:e.ackId};break}case"sendEvent":{t={type:"event",event:e.event,ackId:e.ackId,dataType:e.dataType,data:Ot(e.data,e.dataType)};break}case"sendToGroup":{t={type:"sendToGroup",group:e.group,ackId:e.ackId,dataType:e.dataType,data:Ot(e.data,e.dataType),noEcho:e.noEcho};break}case"sequenceAck":{t={type:"sequenceAck",sequenceId:e.sequenceId};break}default:throw new Error(`Unsupported type: ${e.kind}`)}return JSON.stringify(t)}function Ot(e,t){switch(t){case"text":{if(typeof e!="string")throw new TypeError("Message must be a string.");return e}case"json":return e;case"binary":case"protobuf":{if(e instanceof ArrayBuffer)return xt.Buffer.from(e).toString("base64");throw new TypeError("Message must be a ArrayBuffer")}}}function St(e,t){if(t==="text"){if(typeof e!="string")throw new TypeError("Message must be a string when dataType is text");return e}else{if(t==="json")return e;if(t==="binary"||t==="protobuf"){const i=xt.Buffer.from(e,"base64");return i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}else return null}}class tn{constructor(){this.isReliableSubProtocol=!0,this.name="json.reliable.webpubsub.azure.v1"}parseMessages(t){return Qr(t)}writeMessage(t){return en(t)}}const rn=()=>new tn;class nn{constructor(t,i){this._socket=new WebSocket(t,i),this._socket.binaryType="arraybuffer"}onopen(t){this._socket.onopen=t}onclose(t){this._socket.onclose=i=>t(i.code,i.reason)}onerror(t){this._socket.onerror=i=>t(i)}onmessage(t){this._socket.onmessage=i=>t(i.data)}close(t,i){this._socket.close(t,i)}send(t,i){return new Promise((o,c)=>{try{this._socket.send(t),o()}catch(h){c(h)}})}isOpen(){return this._socket.readyState===WebSocket.OPEN}}class sn{create(t,i){return new nn(t,i)}}async function on(e,t){if(t.aborted)throw new Ct("The operation was aborted.");let i;const o=new Promise((c,h)=>{i=()=>{h(new Ct("The operation was aborted."))},t.addEventListener("abort",i)});try{return await Promise.race([e,o])}finally{t.removeEventListener("abort",i)}}var we;(function(e){e.Stopped="Stopped",e.Disconnected="Disconnected",e.Connecting="Connecting",e.Connected="Connected",e.Recovering="Recovering"})(we||(we={}));class an{nextAckId(){return this._ackId=this._ackId+1,this._ackId}constructor(t,i){this._quickSequenceAckDiff=300,this._activeTimeoutInMs=2e4,this._emitter=new Fr,this._isStopping=!1,this._isInitialConnected=!1,typeof t=="string"?this._credential={getClientAccessUrl:t}:this._credential=t,i==null&&(i={}),this._buildDefaultOptions(i),this._options=i,this._messageRetryPolicy=new Ut(this._options.messageRetryOptions),this._reconnectRetryPolicy=new Ut(this._options.reconnectRetryOptions),this._protocol=this._options.protocol,this._groupMap=new Map,this._ackMap=new Map,this._sequenceId=new un,this._state=we.Stopped,this._ackId=0}async start(t){if(this._isStopping)throw new Error("Can't start a client during stopping");if(this._state!==we.Stopped)throw new Error("Client can be only started when it's Stopped");let i;t&&(i=t.abortSignal),this._activeKeepaliveTask||(this._activeKeepaliveTask=this._getActiveKeepaliveTask());try{await this._startCore(i)}catch(o){throw this._changeState(we.Stopped),this._activeKeepaliveTask&&(this._activeKeepaliveTask.abort(),this._activeKeepaliveTask=void 0),this._isStopping=!1,o}}async _startFromRestarting(t){if(this._state!==we.Disconnected)throw new Error("Client can be only restarted when it's Disconnected");try{ye.verbose("Staring reconnecting."),await this._startCore(t)}catch(i){throw this._changeState(we.Disconnected),i}}async _startCore(t){if(this._changeState(we.Connecting),ye.info("Staring a new connection"),this._sequenceId.reset(),this._isInitialConnected=!1,this._lastCloseEvent=void 0,this._lastDisconnectedMessage=void 0,this._connectionId=void 0,this._reconnectionToken=void 0,this._uri=void 0,typeof this._credential.getClientAccessUrl=="string"?this._uri=this._credential.getClientAccessUrl:this._uri=await this._credential.getClientAccessUrl({abortSignal:t}),typeof this._uri!="string")throw new Error(`The clientAccessUrl must be a string but currently it's ${typeof this._uri}`);await this._connectCore(this._uri)}stop(){this._state===we.Stopped||this._isStopping||(this._isStopping=!0,this._wsClient&&this._wsClient.isOpen()?this._wsClient.close():this._isStopping=!1,this._activeKeepaliveTask&&(this._activeKeepaliveTask.abort(),this._activeKeepaliveTask=void 0))}on(t,i){this._emitter.on(t,i)}off(t,i){this._emitter.removeListener(t,i)}_emitEvent(t,i){this._emitter.emit(t,i)}async sendEvent(t,i,o,c){return await this._operationExecuteWithRetry(()=>this._sendEventAttempt(t,i,o,c),c==null?void 0:c.abortSignal)}async _sendEventAttempt(t,i,o,c){var h;if(!((h=c==null?void 0:c.fireAndForget)!==null&&h!==void 0?h:!1))return await this._sendMessageWithAckId(p=>({kind:"sendEvent",dataType:o,data:i,ackId:p,event:t}),c==null?void 0:c.ackId,c==null?void 0:c.abortSignal);const l={kind:"sendEvent",dataType:o,data:i,event:t};return await this._sendMessage(l,c==null?void 0:c.abortSignal),{isDuplicated:!1}}async joinGroup(t,i){return await this._operationExecuteWithRetry(()=>this._joinGroupAttempt(t,i),i==null?void 0:i.abortSignal)}async _joinGroupAttempt(t,i){const o=this._getOrAddGroup(t),c=await this._joinGroupCore(t,i);return o.isJoined=!0,c}async _joinGroupCore(t,i){return await this._sendMessageWithAckId(o=>({group:t,ackId:o,kind:"joinGroup"}),i==null?void 0:i.ackId,i==null?void 0:i.abortSignal)}async leaveGroup(t,i){return await this._operationExecuteWithRetry(()=>this._leaveGroupAttempt(t,i),i==null?void 0:i.abortSignal)}async _leaveGroupAttempt(t,i){const o=this._getOrAddGroup(t),c=await this._sendMessageWithAckId(h=>({group:t,ackId:h,kind:"leaveGroup"}),i==null?void 0:i.ackId,i==null?void 0:i.abortSignal);return o.isJoined=!1,c}async sendToGroup(t,i,o,c){return await this._operationExecuteWithRetry(()=>this._sendToGroupAttempt(t,i,o,c),c==null?void 0:c.abortSignal)}async _sendToGroupAttempt(t,i,o,c){var h,u;const l=(h=c==null?void 0:c.fireAndForget)!==null&&h!==void 0?h:!1,p=(u=c==null?void 0:c.noEcho)!==null&&u!==void 0?u:!1;if(!l)return await this._sendMessageWithAckId(A=>({kind:"sendToGroup",group:t,dataType:o,data:i,ackId:A,noEcho:p}),c==null?void 0:c.ackId,c==null?void 0:c.abortSignal);const I={kind:"sendToGroup",group:t,dataType:o,data:i,noEcho:p};return await this._sendMessage(I,c==null?void 0:c.abortSignal),{isDuplicated:!1}}_getWebSocketClientFactory(){return new sn}async _trySendSequenceAck(){if(!this._protocol.isReliableSubProtocol)return;const[t,i]=this._sequenceId.tryGetSequenceId();if(t&&i){const o={kind:"sequenceAck",sequenceId:i};try{await this._sendMessage(o)}catch{this._sequenceId.tryUpdate(i)}}}_connectCore(t){if(this._isStopping)throw new Error("Can't start a client during stopping");return new Promise((i,o)=>{const c=this._wsClient=this._getWebSocketClientFactory().create(t,this._protocol.name);c.onopen(()=>{if(this._isStopping){try{c.close()}catch{}o(new Error("The client is stopped"))}ye.verbose("WebSocket connection has opened"),this._changeState(we.Connected),this._protocol.isReliableSubProtocol&&(this._sequenceAckTask!=null&&this._sequenceAckTask.abort(),this._sequenceAckTask=new Bt(async()=>{await this._trySendSequenceAck()},1e3)),i()}),c.onerror(h=>{this._sequenceAckTask!=null&&this._sequenceAckTask.abort(),o(h)}),c.onclose((h,u)=>{this._state===we.Connected?(ye.verbose("WebSocket closed after open"),this._sequenceAckTask!=null&&this._sequenceAckTask.abort(),ye.info(`WebSocket connection closed. Code: ${h}, Reason: ${u}`),this._lastCloseEvent={code:h,reason:u},this._handleConnectionClose.call(this)):(ye.verbose("WebSocket closed before open"),o(new Error(`Failed to start WebSocket: ${h}`)))}),c.onmessage(h=>{const u=m=>{if(this._ackMap.has(m.ackId)){const _=this._ackMap.get(m.ackId);this._ackMap.delete(m.ackId);const b=m.error!=null&&m.error.name==="Duplicate";m.success||b?_.resolve({ackId:m.ackId,isDuplicated:b}):_.reject(new je("Failed to send message.",{ackId:m.ackId,errorDetail:m.error}))}},l=async m=>{if(this._connectionId=m.connectionId,this._reconnectionToken=m.reconnectionToken,!this._isInitialConnected){if(this._isInitialConnected=!0,this._options.autoRejoinGroups){const _=[];this._groupMap.forEach(b=>{b.isJoined&&_.push((async()=>{try{await this._joinGroupCore(b.name)}catch(g){this._safeEmitRejoinGroupFailed(b.name,g)}})())});try{await Promise.all(_)}catch{}}this._safeEmitConnected(m.connectionId,m.userId)}},p=m=>{this._lastDisconnectedMessage=m},I=m=>{if(m.sequenceId!=null){const _=this._sequenceId.tryUpdate(m.sequenceId);if(_===0)return;_>this._quickSequenceAckDiff&&this._trySendSequenceAck()}this._safeEmitGroupMessage(m)},A=m=>{if(m.sequenceId!=null){const _=this._sequenceId.tryUpdate(m.sequenceId);if(_===0)return;_>this._quickSequenceAckDiff&&this._trySendSequenceAck()}this._safeEmitServerMessage(m)};let v;try{let m;if(Array.isArray(h)?m=Buffer.concat(h):m=h,v=this._protocol.parseMessages(m),v===null)return}catch(m){throw ye.warning("An error occurred while parsing the message from service",m),m}Array.isArray(v)||(v=[v]),v.forEach(m=>{try{switch(m.kind){case"ack":{u(m);break}case"connected":{l(m);break}case"disconnected":{p(m);break}case"groupData":{I(m);break}case"serverData":{A(m);break}}}catch(_){ye.warning(`An error occurred while handling the message with kind: ${m.kind} from service`,_)}})})})}async _handleConnectionCloseAndNoRecovery(){this._state=we.Disconnected,this._safeEmitDisconnected(this._connectionId,this._lastDisconnectedMessage),this._options.autoReconnect?await this._autoReconnect():await this._handleConnectionStopped()}async _autoReconnect(){let t=!1,i=0;try{for(;!this._isStopping;)try{await this._startFromRestarting(),t=!0;break}catch(o){ye.warning("An attempt to reconnect connection failed.",o),i++;const c=this._reconnectRetryPolicy.nextRetryDelayInMs(i);if(c==null)break;try{ye.verbose(`Delay time for reconnect attempt ${i}: ${c}`),await Ye(c)}catch{}}}finally{t||this._handleConnectionStopped()}}_handleConnectionStopped(){this._isStopping=!1,this._state=we.Stopped,this._safeEmitStopped()}_getActiveKeepaliveTask(){return new Bt(async()=>{this._sequenceId.tryUpdate(0)},this._activeTimeoutInMs)}async _sendMessage(t,i){if(!this._wsClient||!this._wsClient.isOpen())throw new Error("The connection is not connected.");const o=this._protocol.writeMessage(t);await this._wsClient.send(o,i)}async _sendMessageWithAckId(t,i,o){i==null&&(i=this.nextAckId());const c=t(i);this._ackMap.has(i)||this._ackMap.set(i,new ln(i));const h=this._ackMap.get(i);try{await this._sendMessage(c,o)}catch(u){this._ackMap.delete(i);let l="";throw u instanceof Error&&(l=u.message),new je(l,{ackId:i})}if(o)try{return await on(h.promise(),o)}catch(u){throw u instanceof Error&&u.name==="AbortError"?new je("Cancelled by abortSignal",{ackId:i}):u}return await h.promise()}async _handleConnectionClose(){if(this._ackMap.forEach((c,h)=>{this._ackMap.delete(h)&&c.reject(new je("Connection is disconnected before receive ack from the service",{ackId:c.ackId}))}),this._isStopping){ye.warning("The client is stopping state. Stop recovery."),this._handleConnectionCloseAndNoRecovery();return}if(this._lastCloseEvent&&this._lastCloseEvent.code===1008){ye.warning("The websocket close with status code 1008. Stop recovery."),this._handleConnectionCloseAndNoRecovery();return}if(!this._protocol.isReliableSubProtocol){ye.warning("The protocol is not reliable, recovery is not applicable"),this._handleConnectionCloseAndNoRecovery();return}const t=this._buildRecoveryUri();if(!t){ye.warning("Connection id or reconnection token is not available"),this._handleConnectionCloseAndNoRecovery();return}let i=!1;this._state=we.Recovering;const o=qt.timeout(30*1e3);try{for(;!o.aborted||this._isStopping;)try{await this._connectCore.call(this,t),i=!0;return}catch{await Ye(1e3)}}finally{i||(ye.warning("Recovery attempts failed more then 30 seconds or the client is stopping"),this._handleConnectionCloseAndNoRecovery())}}_safeEmitConnected(t,i){this._emitEvent("connected",{connectionId:t,userId:i})}_safeEmitDisconnected(t,i){this._emitEvent("disconnected",{connectionId:t,message:i})}_safeEmitGroupMessage(t){this._emitEvent("group-message",{message:t})}_safeEmitServerMessage(t){this._emitEvent("server-message",{message:t})}_safeEmitStopped(){this._emitEvent("stopped",{})}_safeEmitRejoinGroupFailed(t,i){this._emitEvent("rejoin-group-failed",{group:t,error:i})}_buildDefaultOptions(t){return t.autoReconnect==null&&(t.autoReconnect=!0),t.autoRejoinGroups==null&&(t.autoRejoinGroups=!0),t.protocol==null&&(t.protocol=rn()),this._buildMessageRetryOptions(t),this._buildReconnectRetryOptions(t),t}_buildMessageRetryOptions(t){t.messageRetryOptions||(t.messageRetryOptions={}),(t.messageRetryOptions.maxRetries==null||t.messageRetryOptions.maxRetries<0)&&(t.messageRetryOptions.maxRetries=3),(t.messageRetryOptions.retryDelayInMs==null||t.messageRetryOptions.retryDelayInMs<0)&&(t.messageRetryOptions.retryDelayInMs=1e3),(t.messageRetryOptions.maxRetryDelayInMs==null||t.messageRetryOptions.maxRetryDelayInMs<0)&&(t.messageRetryOptions.maxRetryDelayInMs=3e4),t.messageRetryOptions.mode==null&&(t.messageRetryOptions.mode="Fixed")}_buildReconnectRetryOptions(t){t.reconnectRetryOptions||(t.reconnectRetryOptions={}),(t.reconnectRetryOptions.maxRetries==null||t.reconnectRetryOptions.maxRetries<0)&&(t.reconnectRetryOptions.maxRetries=Number.MAX_VALUE),(t.reconnectRetryOptions.retryDelayInMs==null||t.reconnectRetryOptions.retryDelayInMs<0)&&(t.reconnectRetryOptions.retryDelayInMs=1e3),(t.reconnectRetryOptions.maxRetryDelayInMs==null||t.reconnectRetryOptions.maxRetryDelayInMs<0)&&(t.reconnectRetryOptions.maxRetryDelayInMs=3e4),t.reconnectRetryOptions.mode==null&&(t.reconnectRetryOptions.mode="Fixed")}_buildRecoveryUri(){if(this._connectionId&&this._reconnectionToken&&this._uri){const t=new URL(this._uri);return t.searchParams.append("awps_connection_id",this._connectionId),t.searchParams.append("awps_reconnection_token",this._reconnectionToken),t.toString()}return null}_getOrAddGroup(t){return this._groupMap.has(t)||this._groupMap.set(t,new cn(t)),this._groupMap.get(t)}_changeState(t){ye.verbose(`The client state transfer from ${this._state.toString()} to ${t.toString()}`),this._state=t}async _operationExecuteWithRetry(t,i){let o=0;for(;;)try{return await t.call(this)}catch(c){o++;const h=this._messageRetryPolicy.nextRetryDelayInMs(o);if(h==null||(await Ye(h),i!=null&&i.aborted))throw c}}}class Ut{constructor(t){this._retryOptions=t,this._maxRetriesToGetMaxDelay=Math.ceil(Math.log2(this._retryOptions.maxRetryDelayInMs)-Math.log2(this._retryOptions.retryDelayInMs)+1)}nextRetryDelayInMs(t){return t>this._retryOptions.maxRetries?null:this._retryOptions.mode==="Fixed"?this._retryOptions.retryDelayInMs:this._calculateExponentialDelay(t)}_calculateExponentialDelay(t){return t>=this._maxRetriesToGetMaxDelay?this._retryOptions.maxRetryDelayInMs:(1<{this._resolve=i,this._reject=o}),this.ackId=t}promise(){return this._promise}resolve(t){this._resolve(t)}reject(t){this._reject(t)}}class un{constructor(){this._sequenceId=0,this._isUpdate=!1}tryUpdate(t){if(this._isUpdate=!0,t>this._sequenceId){const i=t-this._sequenceId;return this._sequenceId=t,i}return 0}tryGetSequenceId(){return this._isUpdate?(this._isUpdate=!1,[!0,this._sequenceId]):[!1,null]}reset(){this._sequenceId=0,this._isUpdate=!1}}class Bt{constructor(t,i,o){this._func=t,this._abortController=new qt,this._interval=i,this._obj=o,this._start()}abort(){try{this._abortController.abort()}catch{}}async _start(){const t=this._abortController.signal;for(;!t.aborted;)try{await this._func(this._obj)}catch{}finally{await Ye(this._interval)}}}var mt={exports:{}};(function(e,t){function i(){return i=Object.assign?Object.assign.bind():function(o){for(var c=1;cR.toString().replace(/\d/g,x=>g[x]),V=R=>R.replace(/[١٢٣٤٥٦٧٨٩٠]/g,x=>U[x]);function F(R,x,M={}){const j=i({},m,M);var Q="-n",Z="n",z,Y,he,le,k,T,w;if(A.includes(j.nagativeFormatPattern)&&(Q=j.nagativeFormatPattern),v.includes(j.positiveFormatPattern)&&(Z=j.positiveFormatPattern),typeof R=="string")return z=j.groupingSeparator,he=j.decimalSeparator,le=R.indexOf(he),k=1,le!==-1&&(k=Math.pow(10,R.length-le-1)),R=R.replace(new RegExp("["+z+"]","g"),""),R=R.replace(new RegExp("["+he+"]"),"."),Math.round(R*k)/k;(typeof x>"u"||x.length<1)&&(x=j.format),z=_,he=b,Y=x.lastIndexOf(z),le=x.indexOf(he);var D="",E="",G=R<0,W=R>0,P=x.substring(le+1).replace(/#/g,"").length,H=x.substring(le+1).length,q=10;if(R=Math.abs(R),le!==-1){if(E=j.decimalSeparator,H>0){k=1e3,q=Math.pow(q,H);var se=Math.round(parseInt(R*q*k-Math.round(R)*q*k,10)/k),ne=String(se<0?Math.round(parseInt(R*q*k-parseInt(R,10)*q*k,10)/k):se),be=R.toString().split(".");if(typeof be[1]<"u")for(w=0;w=P&&me=="0"&&/^0*$/.test(ne.substring(w+1))));w++)pe+=me;E+=pe}E===j.decimalSeparator&&(E="")}if(le!==0){E!==""?D=String(parseInt(Math.round(R*q)/q,10)):D=String(Math.round(R));var ge=j.groupingSeparator,te=0;if(Y!=-1&&(le!=-1?te=le-Y:te=x.length-Y,te--),te>0){var fe=0,de="";for(w=D.length;w--;)fe!==0&&fe%te===0&&(de=ge+de),de=D.substring(w,w+1)+de,fe++;D=de}var ue,_e=/#|,/g;le!=-1?ue=x.substring(0,le).replace(_e,"").length:ue=x.replace(_e,"").length;var Ue=D.length;for(w=Ue;wm.useLatinNumbers||M.useLatinNumbers?F(R,x,M):L(F(R,x,M)),updateDefault:(R={})=>{m=i({},m,R)},arabicToNumber:V,numberToArabic:L}}const h=c(),u=h.number,l=h.updateDefault,p=h.arabicToNumber,I=h.numberToArabic;o.number=u,o.updateDefault=l,o.arabicToNumber=p,o.numberToArabic=I,Object.defineProperty(o,"__esModule",{value:!0})})})(mt,mt.exports);var hn=mt.exports;const fn=Ae(hn),hr=60,fr=hr*60,dn=fr*24,pn=60;var mn=typeof xe=="object"&&xe&&xe.Object===Object&&xe,yn=mn,gn=yn,bn=typeof self=="object"&&self&&self.Object===Object&&self,wn=gn||bn||Function("return this")(),tt=wn,vn=tt,xn=vn.Symbol,dr=xn,Ft=dr,pr=Object.prototype,_n=pr.hasOwnProperty,Tn=pr.toString,Be=Ft?Ft.toStringTag:void 0;function En(e){var t=_n.call(e,Be),i=e[Be];try{e[Be]=void 0;var o=!0}catch{}var c=Tn.call(e);return o&&(t?e[Be]=i:delete e[Be]),c}var In=En,An=Object.prototype,Cn=An.toString;function Dn(e){return Cn.call(e)}var Mn=Dn,Pt=dr,$n=In,kn=Mn,Rn="[object Null]",Ln="[object Undefined]",Nt=Pt?Pt.toStringTag:void 0;function On(e){return e==null?e===void 0?Ln:Rn:Nt&&Nt in Object(e)?$n(e):kn(e)}var mr=On;function Sn(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Ne=Sn,Un=mr,Bn=Ne,Fn="[object AsyncFunction]",Pn="[object Function]",Nn="[object GeneratorFunction]",jn="[object Proxy]";function Gn(e){if(!Bn(e))return!1;var t=Un(e);return t==Pn||t==Nn||t==Fn||t==jn}var Wn=Gn,Vn=tt,Hn=Vn["__core-js_shared__"],zn=Hn,at=zn,jt=function(){var e=/[^.]+$/.exec(at&&at.keys&&at.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Yn(e){return!!jt&&jt in e}var Xn=Yn,qn=Function.prototype,Jn=qn.toString;function Kn(e){if(e!=null){try{return Jn.call(e)}catch{}try{return e+""}catch{}}return""}var Zn=Kn,Qn=Wn,ei=Xn,ti=Ne,ri=Zn,ni=/[\\^$.*+?()[\]{}|]/g,ii=/^\[object .+?Constructor\]$/,si=Function.prototype,oi=Object.prototype,ai=si.toString,ci=oi.hasOwnProperty,li=RegExp("^"+ai.call(ci).replace(ni,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ui(e){if(!ti(e)||ei(e))return!1;var t=Qn(e)?li:ii;return t.test(ri(e))}var hi=ui;function fi(e,t){return e==null?void 0:e[t]}var di=fi,pi=hi,mi=di;function yi(e,t){var i=mi(e,t);return pi(i)?i:void 0}var yr=yi,gi=yr,bi=gi(Object,"create"),rt=bi,Gt=rt;function wi(){this.__data__=Gt?Gt(null):{},this.size=0}var vi=wi;function xi(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var _i=xi,Ti=rt,Ei="__lodash_hash_undefined__",Ii=Object.prototype,Ai=Ii.hasOwnProperty;function Ci(e){var t=this.__data__;if(Ti){var i=t[e];return i===Ei?void 0:i}return Ai.call(t,e)?t[e]:void 0}var Di=Ci,Mi=rt,$i=Object.prototype,ki=$i.hasOwnProperty;function Ri(e){var t=this.__data__;return Mi?t[e]!==void 0:ki.call(t,e)}var Li=Ri,Oi=rt,Si="__lodash_hash_undefined__";function Ui(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Oi&&t===void 0?Si:t,this}var Bi=Ui,Fi=vi,Pi=_i,Ni=Di,ji=Li,Gi=Bi;function Le(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t-1}var os=ss,as=nt;function cs(e,t){var i=this.__data__,o=as(i,e);return o<0?(++this.size,i.push([e,t])):i[o][1]=t,this}var ls=cs,us=Hi,hs=es,fs=ns,ds=os,ps=ls;function Oe(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t>(-2*U&6)));return F},v=function(b){b=String(b),/[^\0-\xFF]/.test(b)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var g=b.length%3,U="",L=-1,V,F,R,x,M=b.length-g;++L>18&63)+p.charAt(x>>12&63)+p.charAt(x>>6&63)+p.charAt(x&63);return g==2?(V=b.charCodeAt(L)<<8,F=b.charCodeAt(++L),x=V+F,U+=p.charAt(x>>10)+p.charAt(x>>4&63)+p.charAt(x<<2&63)+"="):g==1&&(x=b.charCodeAt(L),U+=p.charAt(x>>2)+p.charAt(x<<4&63)+"=="),U},m={encode:v,decode:A,version:"1.0.0"};if(o&&!o.nodeType)if(c)c.exports=m;else for(var _ in m)m.hasOwnProperty(_)&&(o[_]=m[_]);else i.base64=m})(xe)})(Ke,Ke.exports);var qs=Ke.exports;const Js=Ae(qs);var br={exports:{}};(function(e,t){(function(i,o){e.exports=o()})(xe,function(){var i=1e3,o=6e4,c=36e5,h="millisecond",u="second",l="minute",p="hour",I="day",A="week",v="month",m="quarter",_="year",b="date",g="Invalid Date",U=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,L=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,V={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(k){var T=["th","st","nd","rd"],w=k%100;return"["+k+(T[(w-20)%10]||T[w]||T[0])+"]"}},F=function(k,T,w){var D=String(k);return!D||D.length>=T?k:""+Array(T+1-D.length).join(w)+k},R={s:F,z:function(k){var T=-k.utcOffset(),w=Math.abs(T),D=Math.floor(w/60),E=w%60;return(T<=0?"+":"-")+F(D,2,"0")+":"+F(E,2,"0")},m:function k(T,w){if(T.date()1)return k(W[0])}else{var P=T.name;M[P]=T,E=P}return!D&&E&&(x=E),E||!D&&x},z=function(k,T){if(Q(k))return k.clone();var w=typeof T=="object"?T:{};return w.date=k,w.args=arguments,new he(w)},Y=R;Y.l=Z,Y.i=Q,Y.w=function(k,T){return z(k,{locale:T.$L,utc:T.$u,x:T.$x,$offset:T.$offset})};var he=function(){function k(w){this.$L=Z(w.locale,null,!0),this.parse(w),this.$x=this.$x||w.x||{},this[j]=!0}var T=k.prototype;return T.parse=function(w){this.$d=function(D){var E=D.date,G=D.utc;if(E===null)return new Date(NaN);if(Y.u(E))return new Date;if(E instanceof Date)return new Date(E);if(typeof E=="string"&&!/Z$/i.test(E)){var W=E.match(U);if(W){var P=W[2]-1||0,H=(W[7]||"0").substring(0,3);return G?new Date(Date.UTC(W[1],P,W[3]||1,W[4]||0,W[5]||0,W[6]||0,H)):new Date(W[1],P,W[3]||1,W[4]||0,W[5]||0,W[6]||0,H)}}return new Date(E)}(w),this.init()},T.init=function(){var w=this.$d;this.$y=w.getFullYear(),this.$M=w.getMonth(),this.$D=w.getDate(),this.$W=w.getDay(),this.$H=w.getHours(),this.$m=w.getMinutes(),this.$s=w.getSeconds(),this.$ms=w.getMilliseconds()},T.$utils=function(){return Y},T.isValid=function(){return this.$d.toString()!==g},T.isSame=function(w,D){var E=z(w);return this.startOf(D)<=E&&E<=this.endOf(D)},T.isAfter=function(w,D){return z(w)=0&&(g[R]=parseInt(F,10))}var x=g[3],M=x===24?0:x,j=g[0]+"-"+g[1]+"-"+g[2]+" "+M+":"+g[4]+":"+g[5]+":000",Q=+m;return(u.utc(j).valueOf()-(Q-=Q%1e3))/6e4},A=h.prototype;A.tz=function(m,_){m===void 0&&(m=l);var b,g=this.utcOffset(),U=this.toDate(),L=U.toLocaleString("en-US",{timeZone:m}),V=Math.round((U-new Date(L))/1e3/60),F=15*-Math.round(U.getTimezoneOffset()/15)-V;if(!Number(F))b=this.utcOffset(0,_);else if(b=u(L,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(F,!0),_){var R=b.utcOffset();b=b.add(g-R,"minute")}return b.$x.$timezone=m,b},A.offsetName=function(m){var _=this.$x.$timezone||u.tz.guess(),b=p(this.valueOf(),_,{timeZoneName:m}).find(function(g){return g.type.toLowerCase()==="timezonename"});return b&&b.value};var v=A.startOf;A.startOf=function(m,_){if(!this.$x||!this.$x.$timezone)return v.call(this,m,_);var b=u(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return v.call(b,m,_).tz(this.$x.$timezone,!0)},u.tz=function(m,_,b){var g=b&&_,U=b||_||l,L=I(+u(),U);if(typeof m!="string")return u(m).tz(U);var V=function(M,j,Q){var Z=M-60*j*1e3,z=I(Z,Q);if(j===z)return[Z,j];var Y=I(Z-=60*(z-j)*1e3,Q);return z===Y?[Z,z]:[M-60*Math.min(z,Y)*1e3,Math.max(z,Y)]}(u.utc(m,g).valueOf(),L,U),F=V[0],R=V[1],x=u(F).utcOffset(R);return x.$x.$timezone=U,x},u.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},u.tz.setDefault=function(m){l=m}}})})(vr);var eo=vr.exports;const to=Ae(eo);Ie.extend(Qs);Ie.extend(to);function ro(e){return new an({getClientAccessUrl:async()=>{var t=await(await fetch(e)).json();return t}})}function xr(e,t){return!t||e!==document.body&&t===document.body?!1:e!==t?xr(e,t.parentNode):!0}function ct(e,t){return e.splice.apply(e,[0,e.length].concat(t)),e}function no(e,t){for(var i=0,o=[],c=[];io;){var h=t.charAt(c);if(h==="#"||h==="0")break;c--}var u=t.slice(0,o),l=t.slice(o,c+1),p=t.slice(c+1,t.length);return u+fn.number(e,l,{useLatinNumbers:!i})+p}function io(e,t,i){var o=t.split(";");if(o.length===0)throw new Error("format number not found");if(o.length!==3)return Ve(e,o[0]);if(e===0)return Ve(e,o[2],i);if(e<0)return Ve(Math.abs(e),o[1],i);if(e>0)return Ve(e,o[0],i)}function so(e,t){var i=t-e,o=i/e*100;return{change:i,changePer:o}}const He=(e,t)=>{var i,o,c;return(c=(o=(i=e.find(h=>h.name===t))==null?void 0:i.Formats)==null?void 0:o[0])==null?void 0:c.rawValue};class _r{constructor(){It(this,"_listeners",[])}subscribe(t,i,o){var c={callback:t,linkedObject:i,singleshot:o===!0};this._listeners.push(c)}unsubscribe(t){var i=this._listeners.findIndex(o=>t===o.callback);i>-1&&this._listeners.splice(i,1)}unsubscribeAll(t){this._listeners=this._listeners.filter(i=>i.linkedObject!==t)}fire(t,i,o){var c=[...this._listeners];this._listeners=this._listeners.filter(h=>!h.singleshot),c.forEach(h=>h.callback(t,i,o))}hasListeners(){return this._listeners.length>0}destroy(){this._listeners=[]}}function yt(e){let t=new Date(e);return t=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),0),t}function Ze(e){return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hours:e.getHours(),minus:e.getMinutes(),seconds:e.getSeconds()}}function oo(e,t,i){e instanceof Date||(e=new Date(e)),t instanceof Date||(t=new Date(t));const o=["year","month","day","hours","minus","seconds"],c=o.findIndex(p=>p===i);if(c===-1)throw new Error(`Period: ${i} do not exist!`);const h=o.slice(0,c+1),u=Ze(e),l=Ze(t);return h.every(p=>u[p]===l[p])}function Vt(e,t){const i=new Date(e),o=["seconds","minus","hours","day","month","year"],c=o.findIndex(u=>u===t);if(c===-1)throw new Error(`Period: ${t} doesn't exist`);return o.slice(0,c+1).forEach(u=>{switch(u){case"year":i.setMonth(0);break;case"month":i.setDate(1);break;case"day":i.setHours(0);break;case"hours":i.setMinutes(0);break;case"minus":i.setSeconds(0);break;case"seconds":i.setMilliseconds(0);break;default:throw new Error(`Period: ${u} do not exist!`)}}),i}function Tr(e,t,i){const o=Vt(e,i),c=Vt(t,i),h=Ze(o),u=Ze(c),l=o.getTime(),p=c.getTime(),I={year:h.year-u.year,month:h.month-u.month,day:h.day-u.day,hours:h.hours-u.hours,minus:h.minus-u.minus,seconds:h.seconds-u.seconds};switch(i){case"year":return I[i];case"month":return I.year*12+I.month;case"day":return Math.floor((l-p)/(dn*1e3));case"hours":return Math.floor((l-p)/(fr*1e3));case"minus":return Math.floor((l-p)/(hr*1e3));case"seconds":return Math.floor((l-p)/1e3)}return{year:h.year-u.year,month:h.month-u.month,day:h.day-u.day,hours:h.hours-u.hours,minus:h.minus-u.minus,seconds:h.seconds-u.seconds}}function ao(e,t,i){return oo(e,t,i)?0:Tr(e,t,i)}function co(e,t,i){let o=e.__animate;if(t===i){o&&(o.up&&e.classList.add("animate_up"),o.down&&e.classList.add("animate_down"));return}typeof t=="number"&&typeof i=="number"&&(o=e.__animate={up:!1,down:!1},t>i?o.down=!0:o.up=!0,e.classList.remove("animate_up","animate_down"),o.down&&(e.classList.add("animate_down"),e.onanimationend=function(){e.classList.remove("animate_down"),o.down=!1}),o.up&&(e.classList.add("animate_up"),e.onanimationend=function(){e.classList.remove("animate_up"),o.up=!1}))}Xs((e,t)=>"data:image/svg+xml;base64,"+Js.encode(` `),function(e,t){return e.toString()+t.toString()});function lo(){const e=new Date;return(60-e.getSeconds())*1e3-e.getMilliseconds()}const uo=(e="",t="")=>{const i=e.indexOf(t);return i===-1||!t?e:e.substring(0,i)};function ho(e,t){return Tr(e,t,"seconds")>0}function fo(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}function po(e="en-GB"){document.documentElement.lang=e}function Et({openTimeLocal:e,closeTimeLocal:t,ianaTimezone:i},o){const c=o?Ie(o).tz(i):Ie().tz(i),[h,u,l]=e.split(":").map(Number),[p,I,A]=t.split(":").map(Number),v=Ie().tz(i).hour(h).minute(u).second(l),m=Ie().tz(i).hour(p).minute(I).second(A);return(c.isAfter(v)||c.isSame(v))&&(c.isBefore(m)||c.isSame(m))}function mo(e,t){const i=Ie().tz(t),[o,c,h]=e.split(":").map(Number);return i.hour(o).minute(c).second(h).millisecond(0).diff(i)}function yo(e,t){const i=Ie().tz(t),[o,c,h]=e.split(":").map(Number);let u=i.hour(o).minute(c).second(h).millisecond(0);return i.isAfter(u)&&(u=u.add(1,"day")),u.diff(i)}class Fe extends _r{constructor(t,i){super(),this.url=t,this.socket=ro(t),this._handleIncomingMessage=this._handleIncomingMessage.bind(this),this.socket.on("group-message",this._handleIncomingMessage),this.starting=this.socket.start(),this.group=[],this.handleMapping=i}_handleIncomingMessage({message:t}){var i=JSON.parse(t.data),o=this.handleMapping(i);this.fire({raw:i,mapping:o})}watchInstruments(t){return this.starting.then(()=>{var i=t.map(o=>o.toString()).filter(o=>!this.group.includes(o));if(this.group=this.group.concat(i),i.length!==0)return Promise.all(i.map(o=>this.socket.joinGroup(o)))}).then(()=>(console.log("watch initialed"),this))}}const Pe=function(e="snapshot"){if(!Pe.prototype[e]){let t;switch(e){case"snapshot":{t=new Fe(Fe.prototype.snapshotSocketURI,function(i){return{last:i.Last,date:i.Date,open:i.Open,volume:i.Volume,high:i.High,low:i.Low}});break}case"trade":{t=new Fe(Fe.prototype.tradeSocketURI,function(i){return{last:parseFloat(i.hClose),date:i.hDate}});break}default:throw new Error(`Type: ${e} not exist`)}Pe.prototype[e]=t}return Pe.prototype[e]};var go=tt,bo=function(){return go.Date.now()},wo=bo,vo=/\s/;function xo(e){for(var t=e.length;t--&&vo.test(e.charAt(t)););return t}var _o=xo,To=_o,Eo=/^\s+/;function Io(e){return e&&e.slice(0,To(e)+1).replace(Eo,"")}var Ao=Io;function Co(e){return e!=null&&typeof e=="object"}var Do=Co,Mo=mr,$o=Do,ko="[object Symbol]";function Ro(e){return typeof e=="symbol"||$o(e)&&Mo(e)==ko}var Lo=Ro,Oo=Ao,Ht=Ne,So=Lo,zt=NaN,Uo=/^[-+]0x[0-9a-f]+$/i,Bo=/^0b[01]+$/i,Fo=/^0o[0-7]+$/i,Po=parseInt;function No(e){if(typeof e=="number")return e;if(So(e))return zt;if(Ht(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ht(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Oo(e);var i=Bo.test(e);return i||Fo.test(e)?Po(e.slice(2),i?2:8):Uo.test(e)?zt:+e}var jo=No,Go=Ne,lt=wo,Yt=jo,Wo="Expected a function",Vo=Math.max,Ho=Math.min;function zo(e,t,i){var o,c,h,u,l,p,I=0,A=!1,v=!1,m=!0;if(typeof e!="function")throw new TypeError(Wo);t=Yt(t)||0,Go(i)&&(A=!!i.leading,v="maxWait"in i,h=v?Vo(Yt(i.maxWait)||0,t):h,m="trailing"in i?!!i.trailing:m);function _(M){var j=o,Q=c;return o=c=void 0,I=M,u=e.apply(Q,j),u}function b(M){return I=M,l=setTimeout(L,t),A?_(M):u}function g(M){var j=M-p,Q=M-I,Z=t-j;return v?Ho(Z,h-Q):Z}function U(M){var j=M-p,Q=M-I;return p===void 0||j>=t||j<0||v&&Q>=h}function L(){var M=lt();if(U(M))return V(M);l=setTimeout(L,g(M))}function V(M){return l=void 0,m&&o?_(M):(o=c=void 0,u)}function F(){l!==void 0&&clearTimeout(l),I=0,o=p=c=l=void 0}function R(){return l===void 0?u:V(lt())}function x(){var M=lt(),j=U(M);if(o=arguments,c=this,p=M,j){if(l===void 0)return b(p);if(v)return clearTimeout(l),l=setTimeout(L,t),_(p)}return l===void 0&&(l=setTimeout(L,t)),u}return x.cancel=F,x.flush=R,x}var Yo=zo,Xo=Yo,qo=Ne,Jo="Expected a function";function Ko(e,t,i){var o=!0,c=!0;if(typeof e!="function")throw new TypeError(Jo);return qo(i)&&(o="leading"in i?!!i.leading:o,c="trailing"in i?!!i.trailing:c),Xo(e,t,{leading:o,maxWait:t,trailing:c})}var Zo=Ko;const Er=Ae(Zo);window.GraphObject=function(e){var t="GraphObject",i=60,o=i*60*24,c=0,h=1,u=2,l=3,p=4,I=8,A=5,v=6,m=7,_=9,b="VerticalPlotLine";this.dom=document.createElement("div"),this.$root=$(this.dom),this.$root.addClass("highcharts-root");var g=this,U={instrumentID:0,timeZoneID:"",seriesName:"Series Name",seriesUnit:"",seriesColor:"#000",seriesGradientColorA:"#000",seriesGradientColorB:"rgba(255,255,255,0)",seriesWidth:3,seriesType:"spline",seriesDecimals:-1,animationSpeed:200,animationTime:0,hasY2AxisAsPrimary:!0,gridColor:"#ccc",gridWidth:1,toolTipDateFormat:"dd/MM/yyyy",startDate:"",isIntraday:!1,hasTooltip:!0,paddingTop:null,paddingBottom:null,paddingLeft:null,paddingRight:null,backgroundColor:null,isArabic:!1,hasVariableScalePadding:!1,YAxis:{Label:{color:"#f00",font:"Arial, sans-serif",weight:"bold",size:"14px"}},XAxis:{Label:{color:"#f00",font:"Arial, sans-serif",weight:"bold",size:"14px",marginRight:10},GraphGrid:{color:"#000",width:3,periodJump:c,Label:{format:"yyyy",color:"#f00",font:"Arial, sans-serif",weight:"bold",size:"14px",style:"normal"}},format:"MMM",gridPeriodJump:p,gridLabelComboFormat:"yyyy"},Phrases:{volume:"Volume"}},L=[],V=!1,F=!1,R=new GraphObjectTooltipObject,x=$(document.createElement("div")),M=null,j=null,Q={width:2,color:"#222",value:null,id:b,label:{text:null,rotation:-90,x:-10,y:-10,verticalAlign:"bottom",style:{fontFamily:"Arial, sans-serif",color:"#222222",fontSize:"14px",fontWeight:"normal",fontStyle:"normal"}}},Z={width:1,color:"#b2b2b2",value:null,label:{text:null,rotation:0,x:0,y:20,verticalAlign:"bottom",align:"center",style:{fontFamily:"Arial, sans-serif",color:"#222222",fontSize:"14px"}}},z={width:1,color:"#b2b2b2",value:null,label:{text:null,rotation:0,x:0,y:-290,verticalAlign:"bottom",align:"center",style:{fontFamily:"Arial, sans-serif",color:"#222222",fontSize:"14px"}}},Y=null,he=$(window),le=0,k=0,T=null,w=null;function D(){e=$.extend(!0,{},typeof g.DefaultSettings!="object"?{}:g.DefaultSettings,U,typeof e!="object"?{}:e),Z.color=e.gridColor,Z.width=e.gridWidth,Z.label.style.fontFamily=e.XAxis.Label.font,Z.label.style.color=e.XAxis.Label.color,Z.label.style.fontSize=e.XAxis.Label.size,Z.label.style.fontWeight=e.XAxis.Label.weight,Z.label.x=e.XAxis.Label.x,Q.color=e.XAxis.GraphGrid.color,Q.width=e.XAxis.GraphGrid.width,Q.label.style.fontFamily=e.XAxis.GraphGrid.Label.font,Q.label.style.color=e.XAxis.GraphGrid.Label.color,Q.label.style.fontSize=e.XAxis.GraphGrid.Label.size,Q.label.style.fontWeight=e.XAxis.GraphGrid.Label.weight,Q.label.style.fontStyle=e.XAxis.GraphGrid.Label.style,z.color=e.gridColor,z.width=e.gridWidth,z.label.x=e.XAxis.Label.x;var C;if(setTimeout(function(){var O=document.getElementsByClassName("GraphContainer");C=O[0].offsetHeight,z.label.y=-(C-50)},50),z.label.style.fontFamily=e.XAxis.Label.font,z.label.style.color=e.XAxis.Label.color,z.label.style.fontSize=e.XAxis.Label.size,z.label.style.fontWeight=e.XAxis.Label.weight,$(document).ready(E),g.$root.append(x).append(R.$root).css({position:"relative",left:0,top:0,color:e.Tversion.toLowerCase()=="card"?e.toolTip.color:""}),x.addClass("GraphContainer").addClass("high-charts-wrapper"),e.Tversion.toLowerCase()=="card"&&e.isIntraday==!0?W():e.Tversion.toLowerCase()=="card"&&e.isIntraday==!1?G():e.isIntraday?P():H(),!e.isIntraday){switch(e.XAxis.gridPeriodJump){case A:case _:case v:case m:throw"GraphObject::_init() - Cant use a grid period jump of less than a day on a non intraday graph #1"}switch(e.XAxis.GraphGrid.periodJump){case A:case _:case v:case m:throw"GraphObject::_init() - Cant use a grid period jump of less than a day on a non intraday graph #2"}}he.resize(function(){if(document.all)if(he.height()!=k||he.width()!=le)k=he.height(),le=he.width();else return;typeof Y=="number"&&clearTimeout(Y),Y=setTimeout(function(){T!=null&&Ce(T)},100)})}this.setNewInstrumentID=function(C){L=[],V=!1,F=!1,x.empty(),T=null,w=null,e.instrumentID=C,e.isIntraday?P():H()};function E(){V=!0,ue()}function G(){Utility.jQueryAjaxRetryCall(g.newhistoricalDataURL,{data:{instrumentID:e.instrumentID,strStartDate:e.startDate,timezone:e.timeZoneID,PeriodJumpValue:e.PeriodJumpValue,convertToCurrnecy:e.CurrencyToConvert,isRealTime:e.isRealTime},dataType:"json",success:q,error:function(C){console.log(t+" ERROR 001 - Could not load GraphData historicalData")}},1)}function W(){Utility.jQueryAjaxRetryCall(g.IntradayAndHistoricalDataUrl,{data:{instrumentID:e.instrumentID,timezone:e.timeZoneID,PeriodJumpValue:e.PeriodJumpValue,convertToCurrnecy:e.CurrencyToConvert,isRealTime:e.isRealTime},dataType:"json",success:q,error:function(C){console.log(t+" ERROR 001 - Could not load GraphData for IntradayAndHistorical")}},1)}function P(){Utility.jQueryAjaxRetryCall(g.intradayDataURL,{data:{instrumentID:e.instrumentID,timezone:e.timeZoneID,PeriodJumpValue:e.PeriodJumpValue,isRealTime:e.isRealTime},dataType:"json",success:q,error:function(C){console.log(t+" ERROR 001 - Could not load GraphData")}},1)}function H(){Utility.jQueryAjaxRetryCall(g.historicalDataURL,{data:{instrumentID:e.instrumentID,strStartDate:e.startDate,timezone:e.timeZoneID,isRealTime:e.isRealTime},dataType:"json",success:q,error:function(C){console.log(t+" ERROR 001 - Could not load GraphData")}},1)}function q(C){L.push(C),ue()}function se(C){var O=g.$root.width(),S=2e3;return O>0&&(S=Math.ceil(O/C*1e3)),S}function ne(){var C,O=[],S,J,B,K,ie=L[0];if(K=e.isIntraday?i:o,C=ie.Data,e.Tversion.toLowerCase()=="card")if(e.isVolume==!0)for(S=0,J=C.length;Ss?(r++,B=-1):(Te=K.x+Math.ceil(K.width/2)+S,N.css({display:"inline-block"}).add())):N.css({display:"none"}).add()):(N=J[B],K=N.getBBox(),Te=K.x+Math.ceil(K.width/2)+S);C.redraw()}D()};GraphObject.prototype.extraPoint=.2;class Qo{constructor({container:t,keySplines:i="0 0 0 1",calcMode:o="spline",repeatCount:c="indefinite",sleep:h=0,duration:u=400}={}){this.container=t,this.settings={keySplines:i,calcMode:o,repeatCount:c,sleep:h,duration:u},this.totalDuration=u+h,this.durationAnimating=Math.round(u/this.totalDuration*1e3)/1e3,this.animateEls=[]}animateAttribute(t,i,o){const c=document.createElementNS("http://www.w3.org/2000/svg","animate");return c.setAttributeNS(null,"attributeName",t),c.setAttributeNS(null,"keySplines",`${this.settings.keySplines};${this.settings.keySplines}`),c.setAttributeNS(null,"keyTimes",`0;${this.durationAnimating};1`),c.setAttributeNS(null,"values",`${i};${o};${o}`),c.setAttributeNS(null,"calcMode",this.settings.calcMode),c.setAttributeNS(null,"repeatCount",this.settings.repeatCount),c.setAttributeNS(null,"dur",this.totalDuration+"ms"),this.animateEls.push(c),this}add(t){return t&&(this.container=t),this.animateEls.forEach(i=>this.container.appendChild(i)),this}forceStart(){this.animateEls.forEach(t=>t.beginElement())}start(){this.animating()||this.forceStart()}animating(){const t=this.animateEls[0],i=t.getCurrentTime(),o=t.getStartTime(),c=t.getSimpleDuration();return(i-o)%ct.endElement())}}class ea{constructor(t,i){this.chart=t.chart,this.series=t,this.renderer=this.chart.renderer,this.animateEls=[],this.dot=i,this.animate=new Qo({sleep:i.sleep,duration:i.duration}),this.previous={},this.init(),$(this.chart).on("resize",()=>this.update(!1))}isVisible(){return!(this.pointLeft()>this.plotWidth()||this.pointLeft()<=0||this.pointTop()<=0||this.pointTop()>=this.plotHeight())}show(){this.group.show()}hide(){this.group.hide()}plotLeft(){return this.chart.plotLeft}plotTop(){return this.chart.plotTop}plotWidth(){return this.chart.plotWidth}plotHeight(){return this.chart.plotHeight}pointLeft(){return this.lastPoint().plotX}pointTop(){return this.lastPoint().plotY}lastPoint(){return this.series.points[this.series.points.length-1]}init(){const t=this.pointLeft(),i=this.pointTop();this.group=this.series.plotGroup("lastPoint","lastPointGroup",this.series.visible?"visible":"hidden",this.series.options.zIndex,this.chart.seriesGroup),this.group.clip(this.chart[this.series.sharedClipKey]),this.group.attr({style:"user-select: none"}),this.circleGrowing=this.renderer.circle(t,i,0).attr({stroke:this.series.color,"stroke-width":1,fill:"transparent",opacity:1}).add(this.group),this.circle=this.renderer.circle(t,i,this.dot.r).attr({fill:this.series.color}).add(this.group),this.isVisible()?this.show():this.hide(),this.animate.animateAttribute("r",0,this.dot.ring).animateAttribute("opacity",1,0).add(this.circleGrowing.element).forceStart()}update(t=!0){const i=this.pointLeft(),o=this.pointTop();this.previous.x===i&&this.previous.y===o||(this.previous.x=i,this.previous.y=o,this.isVisible()?this.show():this.hide(),t?(this.circle.animate({x:i,y:o}),this.circleGrowing.animate({x:i,y:o}),this.animate.start()):($(this.circle).stop(),$(this.circleGrowing).stop(),this.circle.attr({x:i,y:o}),this.circleGrowing.attr({x:i,y:o})))}}window.RealTimeInstrument=Fe;ScrollingTickerInstrumentObject.prototype.modifyValue=function(e){const t=this.Settings.timeDiff*60*1e3;let i;const o=this.getExtraData("prevClose");"last"in e&&o&&(i=e.last===o?0:e.last>o?1:-1);var c={Values:Array.from(this.previewFetchedData.Values).map(u=>{var l,p={},I;if(!(u.name in e)||(l=e[u.name],l==null))return u;switch(u.Formats.length>0&&"rawValue"in u.Formats[0]&&u.Formats[0].rawValue,p.Formats=u.Formats.map(A=>{var v=A.format,m,_={};switch(v.startsWith("0_")&&(v=v.slice(2)),v=v.replace(/\\/g,""),u.name){case"date":m=Utility.formatDate(yt(new Date(l).getTime()+t),v||Utility.dateFormat,this.Settings.isArabic);break;case"open":case"high":case"low":case"last":case"volume":case"change":case"changePer":v||(u.name==="volume"?v="#,##0":v=this.numberFormat?this.numberFormat:"#,##0.00"),m=io(l,v,this.Settings.isArabic);break;default:return A}return _.rawValue=l,_.value=m,Object.assign(Object.assign({},A),_)}),I=Object.assign({},u),"changeIndicator"in I&&delete I.changeIndicator,u.name){case"last":case"change":case"changePer":i!==void 0&&(p.changeIndicator=i)}return Object.assign(I,p)})},h=Object.assign(Object.assign({},this.previewFetchedData),c);this.previewFetchedData=h,this.loadUpdatedValuesThrottling(JSON.stringify(h),!1)};ScrollingTickerInstrumentObject.prototype.getExtraData=function(e){var t,i,o;return(o=(i=(t=this.previewFetchedData)==null?void 0:t.ExtraData)==null?void 0:i.find(c=>c.Key===e))==null?void 0:o.Value};ScrollingTickerInstrumentObject.prototype.handleSnapshotDataRealtimeReceived=function({raw:e,mapping:t}){var A;var i=e.InstrumentID;const o=t.last;if(this.Settings.instrumentID.toString()!==i.toString())return;const c=(A=this.previewFetchedData)==null?void 0:A.Values;if(c&&o){const v=He(c,"high"),m=He(c,"low"),_=He(c,"high52w"),b=He(c,"low52w");v&&(t.high=Math.max(v,o)),m&&(t.low=Math.min(m,o)),_&&(t.high52w=Math.max(_,o)),b&&(t.low52w=Math.min(b,o))}const h=this.getExtraData("numberOfShares");if(h&&o&&(t.numberOfShares_last=h*o),this.previewFetchedData&&"ExtraData"in this.previewFetchedData){var u=this.getExtraData("prevClose");if(u&&o){var l=so(u,o);Number.isNaN(l.change)||(t.change=l.change),Number.isNaN(l.changePer)||(t.changePer=l.changePer)}}if(t.date&&(t.timestamp=Math.floor(new Date(t.date).getTime()/1e3)),!this.previewFetchedData)return;const p=this.Settings.timeDiff*60*1e3;(()=>{var g,U,L;const v=(L=(U=(g=this.previewFetchedData.Values.find(V=>V.name==="date"))==null?void 0:g.Formats)==null?void 0:U[0])==null?void 0:L.rawValue;if(!v)return!0;const m=yt(new Date(t.date).getTime()+p),_=fo(v)?0:p,b=yt(new Date(v).getTime()+_);return ho(b,m)})()||this.marketInfo&&!Et(this.marketInfo,t.date)||(this.onDataUpdate.fire(t),this.modifyValue(t))};ScrollingTickerInstrumentObject.prototype.handleChartRealtime=function(){const e=this.Settings.timeDiff*60,t=$(this.dom).find(".high-charts-wrapper");if(!t.get().length)return;const i=t.get()[0],o=()=>{const c=i.__highChart,h=i.__settings;if(!h.isRealTime)return;const u=h.isIntraday,l=!u;this.chart=c;const p=c.series[0],I=getComputedStyle(c.container);p.realtimePoint=new ea(p,{r:parseInt(I.getPropertyValue("--realtime-point-r")||3),ring:parseInt(I.getPropertyValue("--realtime-point-ring")||12),sleep:parseInt(I.getPropertyValue("--realtime-point-sleep")||5e3),duration:parseInt(I.getPropertyValue("--realtime-point-duration")||1e3)});const A=v=>{if(!v.timestamp||!(v.last||v.volume))return;const m=c.series[0],_=m.state,b=c.hoverPoint,g=m.points.at(-1),U=g.dbValue.timestamp,L=v.timestamp+e;if(L{const i="&t",o=new Date().getTime(),c=this.dom.querySelectorAll("img");Array.from(c).forEach(h=>{const u=uo(h.src,i);h.src=`${u}${i}=${o}`})},t=lo();setTimeout(()=>{e(),setInterval(e,pn*1e3)},t)};const ut={},De={};ScrollingTickerInstrumentObject.prototype.getMarketInfo=function(){const e=this.Settings.instrumentID.toString(),t=()=>{this.timer&&clearTimeout(this.timer),this.timer=null},i=()=>{t()},o=()=>{t(),setTimeout(()=>{this.updateValues()},this.updateIntervall*1e3)},c=()=>{i();const p=mo(this.marketInfo.closeTimeLocal,this.marketInfo.ianaTimezone);setTimeout(()=>{h()},p)},h=()=>{this.timer||o();const p=yo(this.marketInfo.openTimeLocal,this.marketInfo.ianaTimezone);setTimeout(()=>{c()},p)},u=p=>{this.marketInfo=p,Et(p)?c():h()},l=p=>{ut[e]=p,De[e]&&(De[e].forEach(I=>{I(p)}),delete De[e])};if(ut[e]){u(ut[e]);return}if(De[e]){De[e].push(u);return}De[e]=[u],Utility.jQueryAjaxRetryCall(this.marketInfoURI,{data:{instrumentid:e},dataType:"json",success:l,error:function(p){console.log(" ERROR 001 - Could not load GraphData historicalData"),delete De[e]}},1)};var Ir=ScrollingTickerInstrumentObject,Xt=[];ScrollingTickerInstrumentObject=function(e,t,i,o){Ir.call(this,e,t,i,o),po(this.lang);var c=this.Settings.isRealTime;this.onDataUpdate=new _r;var h=!1;typeof i!="number"&&(i=0);var u=ScrollingTickerInstrumentsSetArr["set_"+i];c&&(Pe("snapshot").watchInstruments([this.Settings.instrumentID]).then(b=>b.subscribe(this.handleSnapshotDataRealtimeReceived.bind(this),this)),Pe("trade").watchInstruments([this.Settings.instrumentID]).then(b=>b.subscribe(this.handleSnapshotDataRealtimeReceived.bind(this),this)),this.handleChartRealtime(),this.dataURI=this.realtimeDataURI,this.startUpdateRealtimeChartImage(),this.getMarketInfo());var l=this.updateValues;this.updateValues=function(){const b=this.marketInfo&&Et(this.marketInfo);if(!(c&&h&&b)){clearTimeout(this.timer),this.timer=null;var g=l.apply(this);return h=!0,g}};var p=this.loadUpdatedValues,I;this.loadUpdatedValues=function(b,g){if(typeof this.loadedCall=="function"&&I!==this.loadedCall){var U=this.loadedCall;I=this.loadedCall=this.loadedCall=(function(){return Xt.forEach(F=>{F.Values.forEach(R=>{var x=R.dom,M,j=x.innerText?x.innerText:"";x.offsetWidth<10||(x.classList.contains("instrument-value")||x.classList.add("instrument-value"),"__data"in x?M=x.__data:(M=x.__data={width:x.offsetWidth,contentLength:j.length},x.style.setProperty("--element-width",M.width+"px")),M.contentLength!==j.length&&(x.style.removeProperty("--element-width",M.width+"px"),M.width=x.offsetWidth,M.contentLength=j.length,x.style.setProperty("--element-width",M.width+"px")))})}),U.call(this,this)}).bind(this)}var L=p.apply(this,arguments);try{var V=JSON.parse(b);V.Values.map(F=>{var R=this.Values.filter(x=>x.name===F.name);R.length!==0&&R.forEach(x=>{var M=F.Formats.find(j=>j.format===x.format);if(M){if(x.raw){const j=x.dom;co(j,x.raw.rawValue,M.rawValue)}x.raw=M}})}),g&&(this.previewFetchedData=V)}catch(F){console.error(F)}return g||this.timer&&(clearTimeout(this.timer),this.timer=null),isLoadedCallOldFirstRun=!0,L},this.viewThrottling?this.loadUpdatedValuesThrottling=Er(function(b,g){return this.loadUpdatedValues(b,g)},this.viewThrottling):this.loadUpdatedValuesThrottling=this.loadUpdatedValues;for(var A=u.find(b=>b.Settings.instrumentID===this.Settings.instrumentID&&b.Settings.isRealTime===this.Settings.isRealTime),v=u.length,m=null;v--;)if(m=u[v],m.Settings.instrumentID===this.Settings.instrumentID){if(m.Settings.isRealTime!==this.Settings.isRealTime){var _=no(m.Values,b=>!xr(this.dom,b.dom));ct(m.Values,_.include),A?ct(A.Values,A.Values.concat(_.exclude)):(u.push(this),ct(this.Values,this.Values.concat(_.exclude)),this.hasInitialInstrument=!1)}break}this.dom.dataset.isRealTime=c,Xt.push(this)};Object.assign(ScrollingTickerInstrumentObject.prototype,Ir.prototype);