@streamlayer/sdk-web 0.20.8 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # core
2
2
 
3
- This library was generatedwith [Nx](https://nx.dev).
3
+ This library was generated with [Nx](https://nx.dev).
4
4
 
5
5
  ## Building
6
6
  Run `nx build core` to build the library.
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("@streamlayer/sl-eslib/interactive/interactive.common_pb");require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb");const D=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),X=require("nanostores");require("@nanostores/logger");require("microdiff");const bt=require("@connectrpc/connect"),Se=require("@connectrpc/connect-web"),be=require("@nanostores/query"),Ie=require("@streamlayer/sl-eslib/sports/events/events_connect"),lt=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),Vt=require("@streamlayer/sl-eslib/users/users_connect"),Ee=require("pino"),O=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),xe=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect"),Be=require("avvio");var Mt={},Pt={},ft={};ft.byteLength=Te;ft.toByteArray=Ce;ft.fromByteArray=Ne;var $=[],C=[],Ae=typeof Uint8Array<"u"?Uint8Array:Array,St="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var tt=0,Fe=St.length;tt<Fe;++tt)$[tt]=St[tt],C[St.charCodeAt(tt)]=tt;C["-".charCodeAt(0)]=62;C["_".charCodeAt(0)]=63;function Gt(n){var r=n.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=n.indexOf("=");o===-1&&(o=r);var a=o===r?0:4-o%4;return[o,a]}function Te(n){var r=Gt(n),o=r[0],a=r[1];return(o+a)*3/4-a}function ke(n,r,o){return(r+o)*3/4-o}function Ce(n){var r,o=Gt(n),a=o[0],h=o[1],f=new Ae(ke(n,a,h)),p=0,c=h>0?a-4:a,y;for(y=0;y<c;y+=4)r=C[n.charCodeAt(y)]<<18|C[n.charCodeAt(y+1)]<<12|C[n.charCodeAt(y+2)]<<6|C[n.charCodeAt(y+3)],f[p++]=r>>16&255,f[p++]=r>>8&255,f[p++]=r&255;return h===2&&(r=C[n.charCodeAt(y)]<<2|C[n.charCodeAt(y+1)]>>4,f[p++]=r&255),h===1&&(r=C[n.charCodeAt(y)]<<10|C[n.charCodeAt(y+1)]<<4|C[n.charCodeAt(y+2)]>>2,f[p++]=r>>8&255,f[p++]=r&255),f}function Ue(n){return $[n>>18&63]+$[n>>12&63]+$[n>>6&63]+$[n&63]}function _e(n,r,o){for(var a,h=[],f=r;f<o;f+=3)a=(n[f]<<16&16711680)+(n[f+1]<<8&65280)+(n[f+2]&255),h.push(Ue(a));return h.join("")}function Ne(n){for(var r,o=n.length,a=o%3,h=[],f=16383,p=0,c=o-a;p<c;p+=f)h.push(_e(n,p,p+f>c?c:p+f));return a===1?(r=n[o-1],h.push($[r>>2]+$[r<<4&63]+"==")):a===2&&(r=(n[o-2]<<8)+n[o-1],h.push($[r>>10]+$[r>>4&63]+$[r<<2&63]+"=")),h.join("")}var xt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */xt.read=function(n,r,o,a,h){var f,p,c=h*8-a-1,y=(1<<c)-1,F=y>>1,b=-7,B=o?h-1:0,R=o?-1:1,w=n[r+B];for(B+=R,f=w&(1<<-b)-1,w>>=-b,b+=c;b>0;f=f*256+n[r+B],B+=R,b-=8);for(p=f&(1<<-b)-1,f>>=-b,b+=a;b>0;p=p*256+n[r+B],B+=R,b-=8);if(f===0)f=1-F;else{if(f===y)return p?NaN:(w?-1:1)*(1/0);p=p+Math.pow(2,a),f=f-F}return(w?-1:1)*p*Math.pow(2,f-a)};xt.write=function(n,r,o,a,h,f){var p,c,y,F=f*8-h-1,b=(1<<F)-1,B=b>>1,R=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=a?0:f-1,it=a?1:-1,nt=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,p=b):(p=Math.floor(Math.log(r)/Math.LN2),r*(y=Math.pow(2,-p))<1&&(p--,y*=2),p+B>=1?r+=R/y:r+=R*Math.pow(2,1-B),r*y>=2&&(p++,y/=2),p+B>=b?(c=0,p=b):p+B>=1?(c=(r*y-1)*Math.pow(2,h),p=p+B):(c=r*Math.pow(2,B-1)*Math.pow(2,h),p=0));h>=8;n[o+w]=c&255,w+=it,c/=256,h-=8);for(p=p<<h|c,F+=h;F>0;n[o+w]=p&255,w+=it,p/=256,F-=8);n[o+w-it]|=nt*128};/*!
2
+ * The buffer module from node.js, for the browser.
3
+ *
4
+ * @author Feross Aboukhadijeh <https://feross.org>
5
+ * @license MIT
6
+ */(function(n){const r=ft,o=xt,a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=c,n.SlowBuffer=Jt,n.INSPECT_MAX_BYTES=50;const h=2147483647;n.kMaxLength=h,c.TYPED_ARRAY_SUPPORT=f(),!c.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 f(){try{const i=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(i,t),i.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function p(i){if(i>h)throw new RangeError('The value "'+i+'" is invalid for option "size"');const t=new Uint8Array(i);return Object.setPrototypeOf(t,c.prototype),t}function c(i,t,e){if(typeof i=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(i)}return y(i,t,e)}c.poolSize=8192;function y(i,t,e){if(typeof i=="string")return R(i,t);if(ArrayBuffer.isView(i))return it(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(v(i,ArrayBuffer)||i&&v(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(v(i,SharedArrayBuffer)||i&&v(i.buffer,SharedArrayBuffer)))return nt(i,t,e);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const s=i.valueOf&&i.valueOf();if(s!=null&&s!==i)return c.from(s,t,e);const u=Zt(i);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return c.from(i[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}c.from=function(i,t,e){return y(i,t,e)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function F(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function b(i,t,e){return F(i),i<=0?p(i):t!==void 0?typeof e=="string"?p(i).fill(t,e):p(i).fill(t):p(i)}c.alloc=function(i,t,e){return b(i,t,e)};function B(i){return F(i),p(i<0?0:gt(i)|0)}c.allocUnsafe=function(i){return B(i)},c.allocUnsafeSlow=function(i){return B(i)};function R(i,t){if((typeof t!="string"||t==="")&&(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const e=Tt(i,t)|0;let s=p(e);const u=s.write(i,t);return u!==e&&(s=s.slice(0,u)),s}function w(i){const t=i.length<0?0:gt(i.length)|0,e=p(t);for(let s=0;s<t;s+=1)e[s]=i[s]&255;return e}function it(i){if(v(i,Uint8Array)){const t=new Uint8Array(i);return nt(t.buffer,t.byteOffset,t.byteLength)}return w(i)}function nt(i,t,e){if(t<0||i.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let s;return t===void 0&&e===void 0?s=new Uint8Array(i):e===void 0?s=new Uint8Array(i,t):s=new Uint8Array(i,t,e),Object.setPrototypeOf(s,c.prototype),s}function Zt(i){if(c.isBuffer(i)){const t=gt(i.length)|0,e=p(t);return e.length===0||i.copy(e,0,0,t),e}if(i.length!==void 0)return typeof i.length!="number"||wt(i.length)?p(0):w(i);if(i.type==="Buffer"&&Array.isArray(i.data))return w(i.data)}function gt(i){if(i>=h)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+h.toString(16)+" bytes");return i|0}function Jt(i){return+i!=i&&(i=0),c.alloc(+i)}c.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==c.prototype},c.compare=function(t,e){if(v(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),v(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let s=t.length,u=e.length;for(let d=0,l=Math.min(s,u);d<l;++d)if(t[d]!==e[d]){s=t[d],u=e[d];break}return s<u?-1:u<s?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return c.alloc(0);let s;if(e===void 0)for(e=0,s=0;s<t.length;++s)e+=t[s].length;const u=c.allocUnsafe(e);let d=0;for(s=0;s<t.length;++s){let l=t[s];if(v(l,Uint8Array))d+l.length>u.length?(c.isBuffer(l)||(l=c.from(l)),l.copy(u,d)):Uint8Array.prototype.set.call(u,l,d);else if(c.isBuffer(l))l.copy(u,d);else throw new TypeError('"list" argument must be an Array of Buffers');d+=l.length}return u};function Tt(i,t){if(c.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||v(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const e=i.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&e===0)return 0;let u=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return mt(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Dt(i).length;default:if(u)return s?-1:mt(i).length;t=(""+t).toLowerCase(),u=!0}}c.byteLength=Tt;function te(i,t,e){let s=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(i||(i="utf8");;)switch(i){case"hex":return he(this,t,e);case"utf8":case"utf-8":return Ut(this,t,e);case"ascii":return ue(this,t,e);case"latin1":case"binary":return ce(this,t,e);case"base64":return oe(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return de(this,t,e);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),s=!0}}c.prototype._isBuffer=!0;function H(i,t,e){const s=i[t];i[t]=i[e],i[e]=s}c.prototype.swap16=function(){const t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)H(this,e,e+1);return this},c.prototype.swap32=function(){const t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)H(this,e,e+3),H(this,e+1,e+2);return this},c.prototype.swap64=function(){const t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)H(this,e,e+7),H(this,e+1,e+6),H(this,e+2,e+5),H(this,e+3,e+4);return this},c.prototype.toString=function(){const t=this.length;return t===0?"":arguments.length===0?Ut(this,0,t):te.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:c.compare(this,t)===0},c.prototype.inspect=function(){let t="";const e=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},a&&(c.prototype[a]=c.prototype.inspect),c.prototype.compare=function(t,e,s,u,d){if(v(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),s===void 0&&(s=t?t.length:0),u===void 0&&(u=0),d===void 0&&(d=this.length),e<0||s>t.length||u<0||d>this.length)throw new RangeError("out of range index");if(u>=d&&e>=s)return 0;if(u>=d)return-1;if(e>=s)return 1;if(e>>>=0,s>>>=0,u>>>=0,d>>>=0,this===t)return 0;let l=d-u,g=s-e;const I=Math.min(l,g),S=this.slice(u,d),E=t.slice(e,s);for(let m=0;m<I;++m)if(S[m]!==E[m]){l=S[m],g=E[m];break}return l<g?-1:g<l?1:0};function kt(i,t,e,s,u){if(i.length===0)return-1;if(typeof e=="string"?(s=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,wt(e)&&(e=u?0:i.length-1),e<0&&(e=i.length+e),e>=i.length){if(u)return-1;e=i.length-1}else if(e<0)if(u)e=0;else return-1;if(typeof t=="string"&&(t=c.from(t,s)),c.isBuffer(t))return t.length===0?-1:Ct(i,t,e,s,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(i,t,e):Uint8Array.prototype.lastIndexOf.call(i,t,e):Ct(i,[t],e,s,u);throw new TypeError("val must be string, number or Buffer")}function Ct(i,t,e,s,u){let d=1,l=i.length,g=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(i.length<2||t.length<2)return-1;d=2,l/=2,g/=2,e/=2}function I(E,m){return d===1?E[m]:E.readUInt16BE(m*d)}let S;if(u){let E=-1;for(S=e;S<l;S++)if(I(i,S)===I(t,E===-1?0:S-E)){if(E===-1&&(E=S),S-E+1===g)return E*d}else E!==-1&&(S-=S-E),E=-1}else for(e+g>l&&(e=l-g),S=e;S>=0;S--){let E=!0;for(let m=0;m<g;m++)if(I(i,S+m)!==I(t,m)){E=!1;break}if(E)return S}return-1}c.prototype.includes=function(t,e,s){return this.indexOf(t,e,s)!==-1},c.prototype.indexOf=function(t,e,s){return kt(this,t,e,s,!0)},c.prototype.lastIndexOf=function(t,e,s){return kt(this,t,e,s,!1)};function ee(i,t,e,s){e=Number(e)||0;const u=i.length-e;s?(s=Number(s),s>u&&(s=u)):s=u;const d=t.length;s>d/2&&(s=d/2);let l;for(l=0;l<s;++l){const g=parseInt(t.substr(l*2,2),16);if(wt(g))return l;i[e+l]=g}return l}function re(i,t,e,s){return ut(mt(t,i.length-e),i,e,s)}function ie(i,t,e,s){return ut(ge(t),i,e,s)}function ne(i,t,e,s){return ut(Dt(t),i,e,s)}function se(i,t,e,s){return ut(ye(t,i.length-e),i,e,s)}c.prototype.write=function(t,e,s,u){if(e===void 0)u="utf8",s=this.length,e=0;else if(s===void 0&&typeof e=="string")u=e,s=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(s)?(s=s>>>0,u===void 0&&(u="utf8")):(u=s,s=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const d=this.length-e;if((s===void 0||s>d)&&(s=d),t.length>0&&(s<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");u||(u="utf8");let l=!1;for(;;)switch(u){case"hex":return ee(this,t,e,s);case"utf8":case"utf-8":return re(this,t,e,s);case"ascii":case"latin1":case"binary":return ie(this,t,e,s);case"base64":return ne(this,t,e,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return se(this,t,e,s);default:if(l)throw new TypeError("Unknown encoding: "+u);u=(""+u).toLowerCase(),l=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function oe(i,t,e){return t===0&&e===i.length?r.fromByteArray(i):r.fromByteArray(i.slice(t,e))}function Ut(i,t,e){e=Math.min(i.length,e);const s=[];let u=t;for(;u<e;){const d=i[u];let l=null,g=d>239?4:d>223?3:d>191?2:1;if(u+g<=e){let I,S,E,m;switch(g){case 1:d<128&&(l=d);break;case 2:I=i[u+1],(I&192)===128&&(m=(d&31)<<6|I&63,m>127&&(l=m));break;case 3:I=i[u+1],S=i[u+2],(I&192)===128&&(S&192)===128&&(m=(d&15)<<12|(I&63)<<6|S&63,m>2047&&(m<55296||m>57343)&&(l=m));break;case 4:I=i[u+1],S=i[u+2],E=i[u+3],(I&192)===128&&(S&192)===128&&(E&192)===128&&(m=(d&15)<<18|(I&63)<<12|(S&63)<<6|E&63,m>65535&&m<1114112&&(l=m))}}l===null?(l=65533,g=1):l>65535&&(l-=65536,s.push(l>>>10&1023|55296),l=56320|l&1023),s.push(l),u+=g}return ae(s)}const _t=4096;function ae(i){const t=i.length;if(t<=_t)return String.fromCharCode.apply(String,i);let e="",s=0;for(;s<t;)e+=String.fromCharCode.apply(String,i.slice(s,s+=_t));return e}function ue(i,t,e){let s="";e=Math.min(i.length,e);for(let u=t;u<e;++u)s+=String.fromCharCode(i[u]&127);return s}function ce(i,t,e){let s="";e=Math.min(i.length,e);for(let u=t;u<e;++u)s+=String.fromCharCode(i[u]);return s}function he(i,t,e){const s=i.length;(!t||t<0)&&(t=0),(!e||e<0||e>s)&&(e=s);let u="";for(let d=t;d<e;++d)u+=me[i[d]];return u}function de(i,t,e){const s=i.slice(t,e);let u="";for(let d=0;d<s.length-1;d+=2)u+=String.fromCharCode(s[d]+s[d+1]*256);return u}c.prototype.slice=function(t,e){const s=this.length;t=~~t,e=e===void 0?s:~~e,t<0?(t+=s,t<0&&(t=0)):t>s&&(t=s),e<0?(e+=s,e<0&&(e=0)):e>s&&(e=s),e<t&&(e=t);const u=this.subarray(t,e);return Object.setPrototypeOf(u,c.prototype),u};function A(i,t,e){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+t>e)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||A(t,e,this.length);let u=this[t],d=1,l=0;for(;++l<e&&(d*=256);)u+=this[t+l]*d;return u},c.prototype.readUintBE=c.prototype.readUIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||A(t,e,this.length);let u=this[t+--e],d=1;for(;e>0&&(d*=256);)u+=this[t+--e]*d;return u},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=K(function(t){t=t>>>0,J(t,"offset");const e=this[t],s=this[t+7];(e===void 0||s===void 0)&&st(t,this.length-8);const u=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,d=this[++t]+this[++t]*2**8+this[++t]*2**16+s*2**24;return BigInt(u)+(BigInt(d)<<BigInt(32))}),c.prototype.readBigUInt64BE=K(function(t){t=t>>>0,J(t,"offset");const e=this[t],s=this[t+7];(e===void 0||s===void 0)&&st(t,this.length-8);const u=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],d=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+s;return(BigInt(u)<<BigInt(32))+BigInt(d)}),c.prototype.readIntLE=function(t,e,s){t=t>>>0,e=e>>>0,s||A(t,e,this.length);let u=this[t],d=1,l=0;for(;++l<e&&(d*=256);)u+=this[t+l]*d;return d*=128,u>=d&&(u-=Math.pow(2,8*e)),u},c.prototype.readIntBE=function(t,e,s){t=t>>>0,e=e>>>0,s||A(t,e,this.length);let u=e,d=1,l=this[t+--u];for(;u>0&&(d*=256);)l+=this[t+--u]*d;return d*=128,l>=d&&(l-=Math.pow(2,8*e)),l},c.prototype.readInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},c.prototype.readInt16LE=function(t,e){t=t>>>0,e||A(t,2,this.length);const s=this[t]|this[t+1]<<8;return s&32768?s|4294901760:s},c.prototype.readInt16BE=function(t,e){t=t>>>0,e||A(t,2,this.length);const s=this[t+1]|this[t]<<8;return s&32768?s|4294901760:s},c.prototype.readInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=K(function(t){t=t>>>0,J(t,"offset");const e=this[t],s=this[t+7];(e===void 0||s===void 0)&&st(t,this.length-8);const u=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(s<<24);return(BigInt(u)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)}),c.prototype.readBigInt64BE=K(function(t){t=t>>>0,J(t,"offset");const e=this[t],s=this[t+7];(e===void 0||s===void 0)&&st(t,this.length-8);const u=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(u)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+s)}),c.prototype.readFloatLE=function(t,e){return t=t>>>0,e||A(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t=t>>>0,e||A(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||A(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||A(t,8,this.length),o.read(this,t,!1,52,8)};function T(i,t,e,s,u,d){if(!c.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<d)throw new RangeError('"value" argument is out of bounds');if(e+s>i.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,s,u){if(t=+t,e=e>>>0,s=s>>>0,!u){const g=Math.pow(2,8*s)-1;T(this,t,e,s,g,0)}let d=1,l=0;for(this[e]=t&255;++l<s&&(d*=256);)this[e+l]=t/d&255;return e+s},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(t,e,s,u){if(t=+t,e=e>>>0,s=s>>>0,!u){const g=Math.pow(2,8*s)-1;T(this,t,e,s,g,0)}let d=s-1,l=1;for(this[e+d]=t&255;--d>=0&&(l*=256);)this[e+d]=t/l&255;return e+s},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,1,255,0),this[e]=t&255,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Nt(i,t,e,s,u){$t(t,s,u,i,e,7);let d=Number(t&BigInt(4294967295));i[e++]=d,d=d>>8,i[e++]=d,d=d>>8,i[e++]=d,d=d>>8,i[e++]=d;let l=Number(t>>BigInt(32)&BigInt(4294967295));return i[e++]=l,l=l>>8,i[e++]=l,l=l>>8,i[e++]=l,l=l>>8,i[e++]=l,e}function Ot(i,t,e,s,u){$t(t,s,u,i,e,7);let d=Number(t&BigInt(4294967295));i[e+7]=d,d=d>>8,i[e+6]=d,d=d>>8,i[e+5]=d,d=d>>8,i[e+4]=d;let l=Number(t>>BigInt(32)&BigInt(4294967295));return i[e+3]=l,l=l>>8,i[e+2]=l,l=l>>8,i[e+1]=l,l=l>>8,i[e]=l,e+8}c.prototype.writeBigUInt64LE=K(function(t,e=0){return Nt(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=K(function(t,e=0){return Ot(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(t,e,s,u){if(t=+t,e=e>>>0,!u){const I=Math.pow(2,8*s-1);T(this,t,e,s,I-1,-I)}let d=0,l=1,g=0;for(this[e]=t&255;++d<s&&(l*=256);)t<0&&g===0&&this[e+d-1]!==0&&(g=1),this[e+d]=(t/l>>0)-g&255;return e+s},c.prototype.writeIntBE=function(t,e,s,u){if(t=+t,e=e>>>0,!u){const I=Math.pow(2,8*s-1);T(this,t,e,s,I-1,-I)}let d=s-1,l=1,g=0;for(this[e+d]=t&255;--d>=0&&(l*=256);)t<0&&g===0&&this[e+d+1]!==0&&(g=1),this[e+d]=(t/l>>0)-g&255;return e+s},c.prototype.writeInt8=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},c.prototype.writeInt16LE=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},c.prototype.writeInt32LE=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,s){return t=+t,e=e>>>0,s||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},c.prototype.writeBigInt64LE=K(function(t,e=0){return Nt(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=K(function(t,e=0){return Ot(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Rt(i,t,e,s,u,d){if(e+s>i.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function vt(i,t,e,s,u){return t=+t,e=e>>>0,u||Rt(i,t,e,4),o.write(i,t,e,s,23,4),e+4}c.prototype.writeFloatLE=function(t,e,s){return vt(this,t,e,!0,s)},c.prototype.writeFloatBE=function(t,e,s){return vt(this,t,e,!1,s)};function Lt(i,t,e,s,u){return t=+t,e=e>>>0,u||Rt(i,t,e,8),o.write(i,t,e,s,52,8),e+8}c.prototype.writeDoubleLE=function(t,e,s){return Lt(this,t,e,!0,s)},c.prototype.writeDoubleBE=function(t,e,s){return Lt(this,t,e,!1,s)},c.prototype.copy=function(t,e,s,u){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(s||(s=0),!u&&u!==0&&(u=this.length),e>=t.length&&(e=t.length),e||(e=0),u>0&&u<s&&(u=s),u===s||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("sourceEnd out of bounds");u>this.length&&(u=this.length),t.length-e<u-s&&(u=t.length-e+s);const d=u-s;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,s,u):Uint8Array.prototype.set.call(t,this.subarray(s,u),e),d},c.prototype.fill=function(t,e,s,u){if(typeof t=="string"){if(typeof e=="string"?(u=e,e=0,s=this.length):typeof s=="string"&&(u=s,s=this.length),u!==void 0&&typeof u!="string")throw new TypeError("encoding must be a string");if(typeof u=="string"&&!c.isEncoding(u))throw new TypeError("Unknown encoding: "+u);if(t.length===1){const l=t.charCodeAt(0);(u==="utf8"&&l<128||u==="latin1")&&(t=l)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<s)throw new RangeError("Out of range index");if(s<=e)return this;e=e>>>0,s=s===void 0?this.length:s>>>0,t||(t=0);let d;if(typeof t=="number")for(d=e;d<s;++d)this[d]=t;else{const l=c.isBuffer(t)?t:c.from(t,u),g=l.length;if(g===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(d=0;d<s-e;++d)this[d+e]=l[d%g]}return this};const Z={};function yt(i,t,e){Z[i]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(u){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:u,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}yt("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),yt("ERR_INVALID_ARG_TYPE",function(i,t){return`The "${i}" argument must be of type number. Received type ${typeof t}`},TypeError),yt("ERR_OUT_OF_RANGE",function(i,t,e){let s=`The value of "${i}" is out of range.`,u=e;return Number.isInteger(e)&&Math.abs(e)>2**32?u=qt(String(e)):typeof e=="bigint"&&(u=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(u=qt(u)),u+="n"),s+=` It must be ${t}. Received ${u}`,s},RangeError);function qt(i){let t="",e=i.length;const s=i[0]==="-"?1:0;for(;e>=s+4;e-=3)t=`_${i.slice(e-3,e)}${t}`;return`${i.slice(0,e)}${t}`}function le(i,t,e){J(t,"offset"),(i[t]===void 0||i[t+e]===void 0)&&st(t,i.length-(e+1))}function $t(i,t,e,s,u,d){if(i>e||i<t){const l=typeof t=="bigint"?"n":"";let g;throw d>3?t===0||t===BigInt(0)?g=`>= 0${l} and < 2${l} ** ${(d+1)*8}${l}`:g=`>= -(2${l} ** ${(d+1)*8-1}${l}) and < 2 ** ${(d+1)*8-1}${l}`:g=`>= ${t}${l} and <= ${e}${l}`,new Z.ERR_OUT_OF_RANGE("value",g,i)}le(s,u,d)}function J(i,t){if(typeof i!="number")throw new Z.ERR_INVALID_ARG_TYPE(t,"number",i)}function st(i,t,e){throw Math.floor(i)!==i?(J(i,e),new Z.ERR_OUT_OF_RANGE(e||"offset","an integer",i)):t<0?new Z.ERR_BUFFER_OUT_OF_BOUNDS:new Z.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,i)}const fe=/[^+/0-9A-Za-z-_]/g;function pe(i){if(i=i.split("=")[0],i=i.trim().replace(fe,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function mt(i,t){t=t||1/0;let e;const s=i.length;let u=null;const d=[];for(let l=0;l<s;++l){if(e=i.charCodeAt(l),e>55295&&e<57344){if(!u){if(e>56319){(t-=3)>-1&&d.push(239,191,189);continue}else if(l+1===s){(t-=3)>-1&&d.push(239,191,189);continue}u=e;continue}if(e<56320){(t-=3)>-1&&d.push(239,191,189),u=e;continue}e=(u-55296<<10|e-56320)+65536}else u&&(t-=3)>-1&&d.push(239,191,189);if(u=null,e<128){if((t-=1)<0)break;d.push(e)}else if(e<2048){if((t-=2)<0)break;d.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;d.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;d.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return d}function ge(i){const t=[];for(let e=0;e<i.length;++e)t.push(i.charCodeAt(e)&255);return t}function ye(i,t){let e,s,u;const d=[];for(let l=0;l<i.length&&!((t-=2)<0);++l)e=i.charCodeAt(l),s=e>>8,u=e%256,d.push(u),d.push(s);return d}function Dt(i){return r.toByteArray(pe(i))}function ut(i,t,e,s){let u;for(u=0;u<s&&!(u+e>=t.length||u>=i.length);++u)t[u+e]=i[u];return u}function v(i,t){return i instanceof t||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===t.name}function wt(i){return i!==i}const me=function(){const i="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){const s=e*16;for(let u=0;u<16;++u)t[s+u]=i[e]+i[u]}return t}();function K(i){return typeof BigInt>"u"?we:i}function we(){throw new Error("BigInt not supported")}})(Pt);var Kt={exports:{}},x=Kt.exports={},L,q;function It(){throw new Error("setTimeout has not been defined")}function Et(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?L=setTimeout:L=It}catch{L=It}try{typeof clearTimeout=="function"?q=clearTimeout:q=Et}catch{q=Et}})();function zt(n){if(L===setTimeout)return setTimeout(n,0);if((L===It||!L)&&setTimeout)return L=setTimeout,setTimeout(n,0);try{return L(n,0)}catch{try{return L.call(null,n,0)}catch{return L.call(this,n,0)}}}function Oe(n){if(q===clearTimeout)return clearTimeout(n);if((q===Et||!q)&&clearTimeout)return q=clearTimeout,clearTimeout(n);try{return q(n)}catch{try{return q.call(null,n)}catch{return q.call(this,n)}}}var M=[],et=!1,W,ct=-1;function Re(){!et||!W||(et=!1,W.length?M=W.concat(M):ct=-1,M.length&&Ht())}function Ht(){if(!et){var n=zt(Re);et=!0;for(var r=M.length;r;){for(W=M,M=[];++ct<r;)W&&W[ct].run();ct=-1,r=M.length}W=null,et=!1,Oe(n)}}x.nextTick=function(n){var r=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)r[o-1]=arguments[o];M.push(new jt(n,r)),M.length===1&&!et&&zt(Ht)};function jt(n,r){this.fun=n,this.array=r}jt.prototype.run=function(){this.fun.apply(null,this.array)};x.title="browser";x.browser=!0;x.env={};x.argv=[];x.version="";x.versions={};function G(){}x.on=G;x.addListener=G;x.once=G;x.off=G;x.removeListener=G;x.removeAllListeners=G;x.emit=G;x.prependListener=G;x.prependOnceListener=G;x.listeners=function(n){return[]};x.binding=function(n){throw new Error("process.binding is not supported")};x.cwd=function(){return"/"};x.chdir=function(n){throw new Error("process.chdir is not supported")};x.umask=function(){return 0};var ve=Kt.exports;(function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});const r=Pt,o=ve,a=p=>p&&p.__esModule?p:{default:p},h=a(o),f=globalThis||void 0||self;Object.defineProperty(n,"Buffer",{enumerable:!0,get:()=>r.Buffer}),Object.defineProperty(n,"process",{enumerable:!0,get:()=>h.default}),n.global=f})(Mt);class Le{}window.slStore=Object.create(null);class pt{store;name;constructor(r,o){this.store=r,this.name=o}getStore(){return this.store}}const qe=n=>{const r=Object.keys(n);return X.computed(r.map(o=>n[o].getStore()),(...o)=>Object.fromEntries(r.map((a,h)=>[a,o[h]])))};class ot extends pt{getValues=()=>this.getStore().get();getValue=r=>this.getStore().get()[r];setValue=(r,o)=>this.getStore().setKey(r,o);subscribe=(...r)=>this.getStore().subscribe(...r);unsubscribe=()=>this.getStore().off()}const at=n=>X.map(n);var V;(function(n){n.ORGANIZATION="ORGANIZATION",n.STREAM="STREAM"})(V||(V={}));const $e={[D.SdkOverlayType.BETTING]:"betting",[D.SdkOverlayType.GAMES]:"games",[D.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[D.SdkOverlayType.TWITTER]:"twitter"};var Y;(function(n){n.Ready="ready",n.Suspended="suspended"})(Y||(Y={}));class Bt{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:r,...o},a){this.settingsKey=$e[o.type],this.status=X.atom(Y.Suspended),this.config=new ot(at(o),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&r?.overlaySettings.case===this.settingsKey?this.settings=new ot(at(r.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new ot(at({}),`feature:settings:${this.settingsKey}`),this.source=a}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(r){this.listeners.add(r)}enable=()=>{this.status.set(Y.Ready)};disable=()=>{this.status.set(Y.Suspended)};setFeatureConfig=({settings:r,...o})=>{let a;for(a in o)this.config.setValue(a,o[a]);if(r?.overlaySettings.case===this.settingsKey){const h=r.overlaySettings.value;if(h!==void 0){let f;for(f in h)console.log(f,h[f]),h[f]!==0&&h[f]!==""&&this.settings.setValue(f,h[f])}}};update=(r,o)=>{this.source===V.STREAM&&o===V.ORGANIZATION||(this.setFeatureConfig(r),this.source=o)};fireEvent(r){for(const o of this.listeners.values())try{o.onEvent(r)}catch(a){console.error(a)}}}class _ extends pt{getValue=()=>this.getStore().get();getValues(){throw new Error("not implemented")}setValue=r=>this.getStore().set(r);subscribe=r=>this.getStore().subscribe(r);unsubscribe=()=>this.getStore().off();listen(r){return this.getStore().listen(r)}get(){return this.getStore().get()}}const N=n=>X.atom(n),At=(n,r)=>X.computed(n,r);class U extends pt{atomStore;constructor(r,o,a){super(r,`api:${o}`),this.atomStore=X.atom(),a&&r.subscribe(h=>{this.atomStore.set(a(h))})}getAtomStore=()=>this.atomStore;getValue=async()=>{const r=this.getStore();if(r.value===void 0)throw new Error("no store");return await r.value.promise,r.get().data};getValues=()=>{throw new Error("not implemented")};setValue=r=>this.getStore().set({loading:!1,data:r?.data});subscribe=r=>this.getStore().subscribe(r);unsubscribe=()=>{throw new Error("not implemented")};invalidate=()=>{this.store.invalidate()};listen=r=>this.getStore().listen(r);get(){throw new Error("not implemented")}key=()=>this.getStore().key;off=()=>this.getStore().off()}async function*De(n,r){for await(const o of r){n.response.message=o,n.received_at=Date.now();const a={type:"__GRPC_DEVTOOLS_EXTENSION__",data:n};window.postMessage(a),yield o}}const Qe=()=>n=>async r=>{const o={name:r.url,request:{},response:{}};o.request.header=Object.fromEntries(r.header.entries()),o.sent_at=Date.now();try{const a=await n(r);if(o.received_at=Date.now(),o.stream=a.stream,o.response.header=Object.fromEntries(a.header.entries()),o.response.trailer=Object.fromEntries(a.trailer.entries()),a.stream)return{...a,message:De(o,a.message)};{o.request.message=r.message,o.response.message=a.message,o.latency=o.received_at-o.sent_at;const h={type:"__GRPC_DEVTOOLS_EXTENSION__",data:o};window.postMessage(h)}return a}catch(a){o.received_at=Date.now(),o.request.message=r.message,o.response.trailer={"grpc-status":a.code,"grpc-message":a.rawMessage},o.response.message=a.rawMessage,o.latency=o.received_at-o.sent_at;const h={type:"__GRPC_DEVTOOLS_EXTENSION__",data:o};throw window.postMessage(h),a}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));var Q;(function(n){n.Init="init",n.Ready="ready",n.Connecting="connecting",n.Connected="connected",n.Disconnected="disconnected",n.Failed="failed",n.Reconnecting="reconnecting"})(Q||(Q={}));class Ve{params;stream;method;name;headers;listeners;state;store;constructor(r,o,a,h){const f={status:Q.Init,ts:new Date,log:[]};this.state=new ot(at(f),`subscription:${h.name}:state`),this.name=h.name,this.headers=r,this.listeners=new Map,this.params=a,this.method=o,h.withStore&&(this.store=new _(N(null),`subscription:${h.name}:store`)),"subscribe"in a&&typeof a.subscribe=="function"&&a.subscribe(()=>{this.reconnect()}),this.updateState(Q.Ready)}updateState=r=>{this.state.setValue("status",r),this.state.setValue("ts",new Date),this.addStateLog(`status => ${r}`)};addStateLog=r=>{const o=this.state.getStore().get().log;this.state.setValue("log",[...o,`${new Date().toLocaleString()}: ${r}`])};addListener=(r,o)=>this.listeners.has(r)?(this.addStateLog(`listener '${r}' not added`),!1):(this.listeners.set(r,o),this.addStateLog(`listener '${r}' added`),!0);removeListener=r=>{this.listeners.delete(r),this.addStateLog(`listener '${r}' removed`)};connect=()=>{this.updateState(Q.Connecting),this.stream&&(this.addStateLog("disconnect prev connection"),this.stream());const r="get"in this.params&&typeof this.params.get=="function"?this.params.get():this.params;this.stream=this.method(r,this.onData,this.onStreamError,{headers:this.headers.getValues()}),this.updateState(Q.Connected)};disconnect=()=>{this.stream&&this.stream(),this.listeners.clear(),this.updateState(Q.Disconnected)};reconnect=()=>{this.updateState(Q.Reconnecting),this.connect()};getStore=()=>this.store?.getStore();onData=r=>{this.addStateLog(`received data => ${JSON.stringify(r)}`),this.store&&this.store.setValue(r);for(const[,o]of this.listeners)o(r);this.addStateLog(`data routed to ${this.listeners.size} listeners`)};onStreamError=r=>{r!==void 0&&(r.code!==bt.Code.Canceled&&r.rawMessage!=="[canceled] BodyStreamBuffer was aborted"?(this.updateState(Q.Failed),this.state.setValue("error",r)):this.disconnect())}}class Me{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;nanoquery;host;interceptors=[];$headers;clients;callbackClients;subscriptions;constructor(r){this.host=r,this.$headers=new ot(at({"sl-device-id":Mt.process?.env?.NX_DEVICE_ID||"sdk-web-dev"}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.callbackClients=new Map,this.subscriptions=new Map;const[o,a,h]=be.nanoquery();this.nanoquery={createFetcherStore:o,createMutatorStore:a,utils:h},this.transport=Se.createGrpcWebTransport({baseUrl:r,interceptors:this.interceptors,useBinaryFormat:!0})}addSubscription=(r,o,a)=>{const h=this.subscriptions.get(o);if(h)return h;const f=new Ve(this.$headers,r,o,a);return this.subscriptions.set(o,f),f};removeSubscription=r=>{r.disconnect(),this.subscriptions.delete(r.params)};disconnect=()=>{for(const[r,o]of this.subscriptions)o.disconnect(),this.subscriptions.delete(r)};registerInterceptor=r=>{this.interceptors.push(r)};removeInterceptor=r=>{this.interceptors=this.interceptors.filter(o=>o!==r)};getClient=r=>{const o=r.typeName;if(this.clients.has(o))return this.clients.get(o);const a=bt.createPromiseClient(r,this.transport);return this.clients.set(o,a),a};getCallbackClient=r=>{const o=r.typeName;if(this.callbackClients.has(o))return this.callbackClients.get(o);const a=bt.createCallbackClient(r,this.transport);return this.callbackClients.set(o,a),a};createPromiseClient=(r,{params:o=[],method:a})=>{const h=this.getClient(r),f=r.methods[a].name,p=[r.typeName,f.charAt(0).toLowerCase()+f.slice(1),...Array.isArray(o)?o:[o]],c=[r.typeName,f.charAt(0).toLowerCase()+f.slice(1)];return{client:h,queryKey:p,queryKeyStr:c.join("")}};createCallbackClient=r=>({client:this.getCallbackClient(r)});setSdkKey=r=>{this.$headers.setValue("sdk",r)};setAuth=r=>{this.$headers.setValue("authorization",r)};setHeader=(r,o)=>this.$headers.setValue(r,o);getHeader=r=>this.$headers.getValue(r);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const r=o=>a=>{const h=this.$headers.getValues();for(const f in h)a.header.set(f,h[f]);return o(a)};this.interceptors.push(r),this.interceptors.push(Qe())}}const Pe=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(Ie.Events,{method:"retrieveEventId",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async(h,f,p)=>{if(!p||typeof p!="string")return"";try{return(await o.retrieveEventId({id:p})).data?.id||""}catch{return""}}})},Ge=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(lt.Client,{method:"getStream",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async(h,f,p)=>p?(await o.getStream({id:p})).data?.attributes:void 0})},Ke=(n,r)=>{const{queryKey:o,client:a}=r.createPromiseClient(Vt.Users,{method:"me",params:[n]});return r.nanoquery.createFetcherStore(o,{fetcher:()=>a.me({})})},ze=n=>{const{client:r,queryKeyStr:o}=n.createPromiseClient(Vt.Users,{method:"bypassAuth"});return n.nanoquery.createMutatorStore(async({data:{userKey:a,schema:h,init:f},getCacheUpdater:p})=>{const[c]=p(o),y=await r.bypassAuth({userKey:a,schema:h,init:f});return c(y),y})},He=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(lt.Client,{method:"get",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async()=>(await o.get({})).data?.attributes})},je=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(lt.Client,{method:"getOrganization",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async()=>{const h=await o.getOrganization({});return h.data?{...h.data.attributes,id:h.data.id}:void 0}})},We=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(lt.Client,{method:"getOrganizationAdvertising",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async()=>(await o.getOrganizationAdvertising({})).data?.attributes})},Ye=(n,r,o)=>{n.transport=new Me(r.host),n.sdk.host=n.transport.host,n.transport.setSdkKey(r.sdkKey),o()};class Ft{delimiter=":";prefix;constructor(r="main"){this.prefix=`sl-sdk${this.delimiter}${r}`}clear=()=>{for(const r in window.localStorage)r.startsWith(this.prefix)&&window.localStorage.removeItem(r)};generateKey=r=>`${this.prefix}${this.delimiter}${r.join(this.delimiter)}`;write=(...r)=>{const o=r.pop()||"";window.localStorage.setItem(this.generateKey(r),o)};read=(...r)=>{const o=window.localStorage.getItem(this.generateKey(r));return o===null?void 0:o};remove=(...r)=>{window.localStorage.removeItem(this.generateKey(r))}}var j;(function(n){n.SCHEMA="schema",n.TOKEN="token"})(j||(j={}));class Wt extends Ft{constructor(){super("user")}setSchema=r=>{this.write(j.SCHEMA,r)};getSchema=()=>this.read(j.SCHEMA);setToken=r=>{this.write(j.TOKEN,r)};getToken=()=>this.read(j.TOKEN);removeToken=()=>{this.remove(j.TOKEN)};clearNotification=()=>{this.clear()}}var z;(function(n){n.DISABLED="disabled",n.INITIALIZATION="initialization",n.READY="ready",n.FAILED="failed",n.SUSPENDED="suspended"})(z||(z={}));const Xe=n=>{const r=new _(N(),"enabled"),o=new _(N(z.DISABLED),"status"),a=new _(N(),"userKey"),h=new _(N(),"userToken"),f=new Wt;h.listen(w=>{w?f.setToken(w):f.removeToken()});const p=new _(N(),"providerStreamId"),c=new U(Pe(p.getStore(),n),"slStreamId",w=>w?.data),y=new U(Ke(h.getStore(),n),"user",w=>w?.data?.data?.id),F=new U(He(h.getStore(),n),"userSettings"),b=new U(Ge(c.getAtomStore(),n),"streamSettings");c.getAtomStore().listen(w=>{(w===""||w===void 0)&&b.getStore().mutate(void 0)});const B=new U(je(r.getStore(),n),"organizationSettings",w=>w?.data?.id),R=new U(We(B.getAtomStore(),n),"organizationAdvertising");return{enabled:r,status:o,providerStreamId:p,slStreamId:c,streamSettings:b,user:y,userKey:a,userToken:h,userSettings:F,organizationSettings:B,organizationAdvertising:R}};class Ze extends pt{stores;constructor(r){const o=Xe(r),a=qe(o);super(a,"core"),this.stores=o}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=r=>{let o;for(o in this.stores){const a=r[o];o in r&&a!==void 0&&this.stores[o].subscribe(r[o])}};unsubscribe=()=>this.getStore().off()}class Je extends Le{$coreStore;transport;$bypassLogin;constructor(r,o){super(),this.$coreStore=r,this.transport=o,this.$bypassLogin=ze(this.transport),this.subscribe()}me=async()=>(await this.$coreStore.getValues().user.getValue())?.data;login=async(r,o)=>(this.$coreStore.getValues().userKey.setValue(o),await this.$bypassLogin.mutate({schema:r,userKey:o,init:!1}),this.me());isAuthenticated=()=>this.me();logout=()=>{this.$coreStore.getValues().user.setValue(),this.$coreStore.getValues().userKey.setValue(),this.$coreStore.getValues().userToken.setValue(),this.transport.setAuth("")};subscribe=()=>{this.$bypassLogin.subscribe((r,o)=>{o==="data"&&(this.transport.setAuth(r?.data?.meta?.jwt),this.$coreStore.getValues().userToken.setValue(r?.data?.meta?.jwt))})}}const tr=async(n,r,o)=>{n.auth=new Je(n.store,n.transport);const a=new Wt,h=a.getSchema(),f=a.getToken();h&&f&&(console.log("try to login prev user"),await n.auth.login(h,f)),n.sdk.authorizationBypass=async(p,c)=>{await n.auth.login(p,c),a.setSchema("streamlayer:streamlayer")},n.sdk.logout=()=>{n.auth.logout()},n.sdk.getUserStore=()=>n.stores.user.getStore(),n.sdk.isUserAuthorized=()=>n.auth.isAuthenticated(),o()},er=(n,r,o)=>{n.store=new Ze(n.transport),n.stores=n.store.getValues(),n.sdk.sdkStore=n.store.getStore(),n.sdk.organizationStore=()=>n.stores.organizationSettings.getStore(),n.storeUnsubscribe=()=>{n.store.unsubscribe()},o()},rr=(n,r,o)=>{console.log("core connected"),n.sdk=Object.create(null),n.sdk.initializeApp=async()=>{n.storeSubscribe(),n.stores.enabled.setValue("on"),n.stores.status.setValue(z.INITIALIZATION);try{const a=await n.stores.organizationSettings.getValue();return a?(n.stores.status.setValue(z.READY),{enabled:!!a}):(n.stores.status.setValue(z.FAILED),{err:"failed"})}catch(a){return n.stores.enabled.setValue(),n.stores.status.setValue(z.FAILED),{err:`${a}`}}},console.log("sdk.initializeApp added"),n.sdk.disableApp=()=>{n.stores.enabled.setValue(),n.stores.status.setValue(z.DISABLED),n.storeUnsubscribe()},n.sdk.createEventSession=a=>{n.stores.providerStreamId.setValue(""),n.stores.providerStreamId.setValue(a)},o()},ir=Ee.pino({level:"trace"}),Yt=(n,r)=>ir.child({name:n},r),nr=(n,r,o)=>{const{client:a,queryKey:h}=o.createPromiseClient(xe.Leaderboard,{method:"summary",params:[n,r]});return o.nanoquery.createFetcherStore(h,{fetcher:async(f,p,c,y)=>(await a.summary({eventId:c,userId:y})).data?.attributes})},sr=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(O.Feed,{method:"get",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async(h,f,p)=>(await o.get({eventId:p})).data?.attributes})},or=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(O.Feed,{method:"syncQuestion",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async(h,f,p)=>p?(await o.syncQuestion({filter:{eventId:p}})).data?.attributes:void 0})},ar=(n,r)=>{const{client:o}=r.createCallbackClient(O.Feed),a=X.atom({eventId:n.get()||"",feedId:""});return n.subscribe((f="")=>{a.set({eventId:f,feedId:""})}),r.addSubscription(o.subscription,a,{name:"feedSubscription"})},ur=(n,r)=>{const{client:o}=r.createCallbackClient(O.Feed);return r.addSubscription(o.questionSubscription,{questionId:n},{name:"questionSubscription"})},cr=async(n,r)=>{const{client:o}=r.createPromiseClient(O.Feed,{method:"questionByUser",params:[n]});return(await o.questionByUser({questionId:n})).data?.attributes?.question},hr=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(O.Feed,{method:"questionByUser",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async(h,f,p)=>(await o.questionByUser({questionId:p})).data?.attributes?.question})},dr=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(O.Feed,{method:"pickHistory",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async(h,f,p)=>p?(await o.pickHistory({eventId:p})).data?.map(({attributes:y})=>y):void 0})},lr=(n,r)=>{const{client:o,queryKey:a}=r.createPromiseClient(O.Feed,{method:"insightHistory",params:[n]});return r.nanoquery.createFetcherStore(a,{fetcher:async(h,f,p)=>p?(await o.insightHistory({eventId:p})).data?.map(({attributes:y})=>y):void 0})},Xt=n=>(n.gamification||(n.gamification=new fr(n)),n.gamification);class fr{slStreamId;organizationId;userId;openedQuestionId;openedQuestion;activeQuestionId;moderationId;moderation;feedSubscription;questionSubscription;notifications;log;constructor(r){if(r.gamification)throw new Error("GamificationBackground Singleton error");this.log=Yt("gamification-background"),this.slStreamId=r.stores.slStreamId.getAtomStore(),this.organizationId=r.stores.organizationSettings.getAtomStore(),this.userId=r.stores.user.getAtomStore(),this.moderationId=new _(N(),"moderationId").getStore(),this.openedQuestionId=new _(N(),"openedQuestionId").getStore(),this.notifications=r.notifications,this.moderation=new U(sr(this.slStreamId,r.transport),"gamification:moderation"),this.activeQuestionId=new U(or(this.slStreamId,r.transport),"gamification:activeQuestionId"),this.openedQuestion=new U(hr(this.openedQuestionId,r.transport),"gamification:openedQuestion"),this.openedQuestionId.listen(o=>{this.log.debug({questionId:o},"received question"),o?(this.questionSubscription=ur(o,r.transport),this.questionSubscription.addListener("feed-subscription-opened-question",a=>{window.requestAnimationFrame(()=>{this.openedQuestion?.getStore().mutate(a.data?.attributes?.question),this.openedQuestion?.getStore().invalidate()})}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.openedQuestion?.getStore().mutate(void 0),this.questionSubscription!==void 0&&(r.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))}),this.feedSubscription=ar(this.slStreamId,r.transport),this.feedSubscription.addListener("feed-subscription-active-question",o=>{window.requestAnimationFrame(()=>{const a=this.activeQuestionId.getStore();a&&a.mutate(o.data?.attributes)})})}getCurrentSessionId=r=>{const o=r.eventId||this.slStreamId.get()||"",a=r.userId||this.userId.get()||"",h=r.organizationId||this.organizationId.get()||"",f=r.entity||"",p=r.prefix||"";return[h,o,a,p,f].join(":")};disconnect=()=>{this.feedSubscription?.disconnect()};openQuestion=r=>{this.openedQuestionId.set(r),this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:r}))};closeQuestion=r=>{this.openedQuestionId.set(void 0),r&&this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:r}))}}class pr{notificationsList;notifications;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(r){this.options=r,this.logger=Yt("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notifications=new _(N(new Map),"notifications-queue"),this.notificationsList=At(this.notifications.getStore(),o=>o?[...o.values()]:[])}addToQueue=r=>{if(this.store.has(r.id)){this.logger.debug({notification:r},"skip existed notification: %o");return}const o=r.close,a=r.action;this.store.set(r.id,{...r,close:(...h)=>{o&&o(...h),this.closeNotification(r.id)},action:(...h)=>{a&&a(...h),this.closeNotification(r.id)}}),this.waitingQueue.add(r.id),this.logger.debug({notification:r},"notification added to waiting queue"),this.tickWaitingQueue()};tickWaitingQueue=()=>{if(this.activeQueue.size<this.options.concurrency){const[r]=this.waitingQueue;if(!r)return;this.activeQueue.add(r),this.waitingQueue.delete(r),this.logger.debug({job:r},"waiting queue tick"),this.tickActiveQueue(r)}else this.logger.debug({queueSize:this.activeQueue.size,concurrency:this.options.concurrency},"waiting queue tick skipped")};tickActiveQueue=r=>{if(!r)return;const o=this.store.get(r);if(!o){this.logger.debug({notificationId:r},"active queue tick skipped, notification not exist");return}const a=setTimeout(()=>{const h=r,f=new Map(this.notifications.getValue());f.set(o.id,o),this.notifications.setValue(f);const p=setTimeout(()=>{this.logger.debug({notificationId:h},"notification hiding by autoHideDuration"),this.closeNotification(h)},o.autoHideDuration||5e3);this.timeouts.set(h,p),this.logger.debug({notificationId:h,queue:[...f.values()]},"notification displayed")},o.delay||0);this.timeouts.set(r,a),this.logger.debug({notificationId:r},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=r=>{const o=new Map(this.notifications.getValue()),a=o.get(r);if(a){a.hiding=!0,this.notifications.setValue(o);const h=setTimeout(()=>{const f=new Map(this.notifications.getValue());f.delete(r),this.notifications.setValue(f);const p=this.timeouts.get(r);p!==void 0&&(clearTimeout(p),this.timeouts.delete(r)),this.logger.debug({notificationId:r},"notification hidden")},this.options.animationDelay||0);this.timeouts.set(r,h)}this.store.delete(r),this.activeQueue.delete(r),this.waitingQueue.delete(r),this.tickWaitingQueue(),this.logger.debug({notificationId:r},"notification hiding")}}var ht;(function(n){n.OPENED="opened"})(ht||(ht={}));class gr extends Ft{constructor(){super("notification")}setOpened=r=>{this.write(ht.OPENED,r,"true")};isOpened=r=>this.read(ht.OPENED,r);clearNotification=()=>{this.clear()}}var rt;(function(n){n[n.ONBOARDING=1]="ONBOARDING",n[n.QUESTION=2]="QUESTION"})(rt||(rt={}));class yr{queue;storage;constructor(r={}){this.storage=new gr,this.queue=new pr({concurrency:1,animationDelay:300,...r})}add=r=>{this.storage.isOpened(r.id)||this.queue.addToQueue(r)};close=r=>{this.queue.closeNotification(r),this.markAsViewed(r)};getQueueStore=()=>this.queue.notificationsList;markAsViewed=r=>{this.storage.setOpened(r)}}const mr=(n,r,o)=>{n.notifications=new yr,n.addNotification=n.notifications.add,n.sdk.getNotificationsStore=()=>n.notifications.getQueueStore(),o()},wr=(n,r)=>{const{client:o}=n.createPromiseClient(O.Feed,{method:"submitAnswer"});return o.submitAnswer({data:r})},Sr=(n,r)=>{const{client:o}=n.createPromiseClient(O.Feed,{method:"submitInplay"});return o.submitInplay({data:{eventId:+r}})},br=(n,r)=>{const{client:o}=n.createPromiseClient(O.Feed,{method:"skipQuestion"});return o.skipQuestion({data:{id:r}})};var dt;(function(n){n.ONBOARDING="onboarding"})(dt||(dt={}));class Ir extends Ft{constructor(){super("gamification")}saveOnboardingStatus=({userId:r,eventId:o,organizationId:a},h)=>{this.write(dt.ONBOARDING,a,r,o,h)};getOnboardingStatus=({userId:r,eventId:o,organizationId:a})=>this.read(dt.ONBOARDING,a,r,o)}const Qt=new Set([P.QuestionType.POLL,P.QuestionType.PREDICTION,P.QuestionType.TRIVIA]);var k;(function(n){n.Unset="unset",n.Required="required",n.Optional="optional",n.Completed="completed",n.Disabled="disabled",n.Unavailable="unavailable"})(k||(k={}));class Er extends Bt{userSummary;questions;leaderboardId;onboardingStatus;openedQuestion;notifications;transport;closeFeature;openFeature;background;storage;constructor(r,o,a){super(r,o),this.background=Xt(a),this.storage=new Ir,this.leaderboardId=new _(N(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=new _(N(k.Unset),"onboardingStatus").getStore(),this.notifications=a.notifications,this.transport=a.transport,this.closeFeature=a.sdk.closeFeature,this.openFeature=()=>a.sdk.openFeature(D.SdkOverlayType.GAMES),this.openedQuestion=At(this.background.openedQuestion.getStore(),h=>{if(h.data?.type&&Qt.has(h.data.type))return h.data}),this.onboardingStatus.subscribe(h=>{(h===k.Optional||k.Required)&&this.showOnboardingInApp()}),this.status.subscribe(h=>{h===Y.Ready?(this.notifications.close(this.background.getCurrentSessionId({prefix:"onboarding"})),this.connect(a.transport)):this.disconnect()}),this.onboardingStatus.subscribe(h=>{h&&this.background.activeQuestionId.invalidate()}),this.background.activeQuestionId.listen(h=>{h&&h.data&&this.onboardingStatus.get()&&Qt.has(h.data.question.type)&&h.data.question.status===P.QuestionStatus.ACTIVE&&this.notifications.add({type:rt.QUESTION,action:()=>this.openQuestion(h.data.question.id),close:()=>this.closeQuestion(h.data.question.id),autoHideDuration:5e3,id:this.background.getCurrentSessionId({prefix:"notification",entity:h.data.question.id}),data:{title:h.data.notification.title,color:h.data.notification.indicatorColor,icon:h.data.notification.image,imageMode:h.data.notification.imageMode,imagePosition:h.data.notification.imagePosition}})}),this.onboardingProcess(),this.background.userId.subscribe(h=>{h&&this.onboardingProcess()}),this.background.moderation.subscribe(h=>{h.data&&this.onboardingProcess()})}onboardingProcess=async()=>{const r=this.background.userId.get();if(!r)return;this.storage.getOnboardingStatus({userId:r,organizationId:this.background.organizationId.get()||"",eventId:this.background.slStreamId.get()||""})===k.Completed&&this.onboardingStatus.set(k.Completed);const a=await this.background.moderation.getValue();if(this.onboardingStatus.get()===k.Completed)return;const h=!!(a?.options?.onboardingEnabled&&this.featureSettings.get().inplayGame?.onboarding?.completed),f=!!this.featureSettings.get().inplayGame?.titleCard?.optIn;h?f?this.onboardingStatus.set(k.Required):this.onboardingStatus.set(k.Optional):f?this.onboardingStatus.set(k.Unavailable):this.onboardingStatus.set(k.Disabled)};showOnboardingInApp=()=>{const{inplayGame:r}=this.featureSettings.get();if(!r)return;const{titleCard:o,overview:a}=r;this.notifications.add({type:rt.ONBOARDING,id:this.background.getCurrentSessionId({prefix:"onboarding"}),action:this.openFeature,close:this.closeFeature,autoHideDuration:1e5,data:{header:o?.header,title:o?.title,subtitle:o?.subtitle,graphicBg:o?.appearance?.graphic,icon:o?.media?.icon,sponsorLogo:o?.media?.sponsorLogo,primaryColor:a?.appearance?.primaryColor}})};connect=r=>{this.userSummary?this.userSummary.invalidate():this.userSummary=new U(nr(this.background.slStreamId,this.background.userId,r),"gamification:userSummary"),this.questions?this.questions.invalidate():this.questions=new U(dr(this.background.slStreamId,r),"gamification:questions"),this.background.feedSubscription.addListener("feed-subscription-prediction-close",o=>{window.requestAnimationFrame(async()=>{const a=o.data?.attributes?.question;if(!a)return;const{status:h,type:f,id:p}=a;if(h===P.QuestionStatus.RESOLVED&&f===P.QuestionType.PREDICTION){const c=this.background.getCurrentSessionId({prefix:`notification-id:${p}`}),F=(await cr(p,r))?.answers.find(({correct:b})=>b);this.notifications.add({type:rt.ONBOARDING,action:()=>this.openQuestion(p),close:()=>this.closeQuestion(p),autoHideDuration:5e3,id:c,data:{title:F?.youVoted?`Congratulations! You answered correctly! You won ${F.points} pts!`:`Better luck next time! Correct: ${F?.text}!`}})}})}),this.background.feedSubscription.addListener("feed-subscription-questions-list",()=>{window.requestAnimationFrame(()=>{this.questions?.invalidate()})})};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitInplay=async()=>{const r=this.background.slStreamId.get();r&&(await Sr(this.transport,r),this.onboardingStatus.set(k.Completed),this.storage.saveOnboardingStatus({organizationId:this.background.organizationId.get()||"",userId:this.background.userId.get()||"",eventId:r},k.Completed))};submitAnswer=async(r,o)=>{await wr(this.transport,{questionId:r,answerId:o}),this.questions?.invalidate()};skipQuestion=async r=>{await br(this.transport,r),this.questions?.invalidate()};openQuestion=r=>(this.openFeature(),this.background.openQuestion(r));closeQuestion=r=>this.background.closeQuestion(r)}class xr extends Bt{insights;closeFeature;openFeature;openedInsight;notifications;transport;background;constructor(r,o,a){super(r,o),this.background=Xt(a),this.notifications=a.notifications,this.transport=a.transport,this.closeFeature=a.sdk.closeFeature,this.openFeature=()=>a.sdk.openFeature(D.SdkOverlayType.HIGHLIGHTS),this.status.subscribe(h=>{h===Y.Ready?this.connect():this.disconnect()}),this.background.activeQuestionId.listen(h=>{h&&h.data&&h.data.question.type===P.QuestionType.FACTOID&&h.data.question.status===P.QuestionStatus.ACTIVE&&this.notifications.add({type:rt.QUESTION,action:()=>this.openHighlight(h.data.question.id),close:()=>this.closeHighlight(h.data.question.id),autoHideDuration:5e3,id:this.background.getCurrentSessionId({prefix:"notification",entity:h.data.question.id}),data:{title:h.data.notification.title,color:h.data.notification.indicatorColor,icon:h.data.notification.image,imageMode:h.data.notification.imageMode,imagePosition:h.data.notification.imagePosition}})}),this.openedInsight=At(this.background.openedQuestion.getStore(),h=>{if(h.data?.type===P.QuestionType.FACTOID)return h.data})}connect=()=>{this.insights?this.insights.invalidate():this.insights=new U(lr(this.background.slStreamId,this.transport),"gamification:insights"),this.background.feedSubscription.addListener("feed-subscription-insights-list",()=>{window.requestAnimationFrame(()=>{this.insights?.invalidate()})})};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-insights-list")};openHighlight=r=>(this.openFeature(),this.background.openQuestion(r));closeHighlight=r=>this.background.closeQuestion(r)}D.SdkOverlayType.GAMES+"",D.SdkOverlayType.HIGHLIGHTS+"";class Br extends Bt{constructor(r,o){super(r,o)}}const Ar=(n,r,o)=>n.type===D.SdkOverlayType.GAMES?new Er(n,r,o):n.type===D.SdkOverlayType.HIGHLIGHTS?new xr(n,r,o):new Br(n,r),Fr=(n,r,o)=>{n.features=new Map,n.activeFeature=new _(N(),"activeFeature"),n.sdk.getFeatures=()=>n.features,n.sdk.getFeature=a=>n.features.get(a),n.sdk.getActiveFeature=()=>n.activeFeature.getStore(),n.sdk.openFeature=a=>{n.activeFeature.setValue(a)},n.sdk.closeFeature=()=>{n.activeFeature.setValue(void 0)},n.initFeature=(a,h=V.ORGANIZATION)=>{const f=Ar(a,h,n);n.features.set(a.type,f)},n.updateFeature=(a,h)=>{n.features.get(a.type)?.update(a,h)},n.destroyFeature=a=>{n.features.delete(a.type)},n.reinitializeFeatures=async()=>{const a=await n.stores.organizationSettings.getValue();n.features.clear();for(const h of a?.overlays||[])n.initFeature(h,V.ORGANIZATION)},n.stores.providerStreamId.listen(a=>{a||n.reinitializeFeatures()}),n.storeSubscribe=()=>{const a=(f,p)=>{if(p?.overlays){f===V.STREAM&&n.features.clear();for(const c of p.overlays)c.sdkEnable===!0&&(n.features.has(c.type)?n.updateFeature(c,f):n.initFeature(c,f))}},h={organizationSettings:f=>{if(f.data)try{a(V.ORGANIZATION,f.data)}catch(p){console.log(p)}},streamSettings:f=>{if(f.data)try{a(V.STREAM,f.data)}catch(p){console.log(p)}}};n.store.subscribe(h)},o()};function Tr(n,r=!0){const o=r?"https://grpc-web.streamlayer.io:443":"https://grpc-web.next.streamlayer.io:443",a=Be(Object.create({}),{autostart:!1});return a.use(rr),a.use(Ye,{sdkKey:n,host:o}),a.use(er),a.use(tr),a.use(Fr),a.use(mr),a.after(async(h,f,p)=>{if(h)throw h;console.log(f),console.log(f.sdk),console.log(typeof f.sdk),await f.sdk.initializeApp(),p()}),a.onClose(()=>{console.log("close")}),a}exports.StreamLayer=Tr;