@streamlayer/sdk-web 1.6.6 → 1.6.8

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/lib/cjs/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const si=require("pino"),w=require("@streamlayer/sl-eslib/interactive/interactive.common_pb"),it=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb"),V=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),ot=require("@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb"),te=require("nanostores"),Xt=require("nanoid"),B=require("@connectrpc/connect"),Lr=require("@connectrpc/connect-web"),Pr=require("@nanostores/query"),dn=require("@streamlayer/sl-eslib/sports/events/events_connect"),Xe=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),hr=require("@streamlayer/sl-eslib/users/users_connect"),J=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),fn=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect");require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb");const ai=require("@streamlayer/sl-eslib/shortLinks/linksClient_connect"),v=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),pn=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_connect"),Nr=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),ee=require("@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb");function ui(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var hn={exports:{}},q=hn.exports={},ie,oe;function Zt(){throw new Error("setTimeout has not been defined")}function er(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?ie=setTimeout:ie=Zt}catch{ie=Zt}try{typeof clearTimeout=="function"?oe=clearTimeout:oe=er}catch{oe=er}})();function yn(t){if(ie===setTimeout)return setTimeout(t,0);if((ie===Zt||!ie)&&setTimeout)return ie=setTimeout,setTimeout(t,0);try{return ie(t,0)}catch{try{return ie.call(null,t,0)}catch{return ie.call(this,t,0)}}}function ci(t){if(oe===clearTimeout)return clearTimeout(t);if((oe===er||!oe)&&clearTimeout)return oe=clearTimeout,clearTimeout(t);try{return oe(t)}catch{try{return oe.call(null,t)}catch{return oe.call(this,t)}}}var ye=[],Be=!1,Te,ct=-1;function li(){!Be||!Te||(Be=!1,Te.length?ye=Te.concat(ye):ct=-1,ye.length&&mn())}function mn(){if(!Be){var t=yn(li);Be=!0;for(var e=ye.length;e;){for(Te=ye,ye=[];++ct<e;)Te&&Te[ct].run();ct=-1,e=ye.length}Te=null,Be=!1,ci(t)}}q.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];ye.push(new gn(t,e)),ye.length===1&&!Be&&yn(mn)};function gn(t,e){this.fun=t,this.array=e}gn.prototype.run=function(){this.fun.apply(null,this.array)};q.title="browser";q.browser=!0;q.env={};q.argv=[];q.version="";q.versions={};function me(){}q.on=me;q.addListener=me;q.once=me;q.off=me;q.removeListener=me;q.removeAllListeners=me;q.emit=me;q.prependListener=me;q.prependOnceListener=me;q.listeners=function(t){return[]};q.binding=function(t){throw new Error("process.binding is not supported")};q.cwd=function(){return"/"};q.chdir=function(t){throw new Error("process.chdir is not supported")};q.umask=function(){return 0};var di=hn.exports;const I=ui(di),fi=si.pino({level:"trace",enabled:typeof window<"u"&&!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),ue=(t,e)=>fi.child({name:t},e);class pi extends Event{slEventBus;constructor(e,r){super(e),this.slEventBus=r}}const hi=ue("event-bus");class yi{name;listeners;constructor(e="sl-event-bus"){this.name=e,this.listeners=new Set}emit=(e,r)=>{const n=new pi(this.name,{...r,type:e});hi.debug(n,"Emitting event"),window.dispatchEvent(n)};listen(e){return window.addEventListener(this.name,e),this.listeners.add(e),()=>{this.off(e)}}off(e){window.removeEventListener(this.name,e),this.listeners.delete(e)}destroy=()=>{this.listeners.forEach(e=>{window.removeEventListener(this.name,e),this.listeners.delete(e)}),this.listeners.clear()}}class mi{}window.slStore=Object.create(null);class It{store;name;constructor(e,r){this.store=e,this.name=r}getStore(){return this.store}}const gi=t=>{const e=Object.keys(t);return te.computed(e.map(r=>t[r].getStore()),(...r)=>Object.fromEntries(e.map((n,i)=>[n,r[i]])))};class Ae extends It{getValues=()=>this.getStore().get();getValue=e=>this.getStore().get()[e];setValue=(e,r)=>this.getStore().setKey(e,r);subscribe=(...e)=>this.getStore().subscribe(...e);unsubscribe=()=>this.getStore().off()}const H=t=>te.map(t);var fe;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(fe||(fe={}));const bi={[V.SdkOverlayType.BETTING]:"betting",[V.SdkOverlayType.GAMES]:"games",[V.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[V.SdkOverlayType.TWITTER]:"twitter"};var He;(function(t){t.Ready="ready",t.Suspended="suspended"})(He||(He={}));class bn{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},n){this.settingsKey=bi[r.type],this.status=te.atom(He.Suspended),this.config=new Ae(H(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new Ae(H(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new Ae(H({}),`feature:settings:${this.settingsKey}`),this.source=n}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(He.Ready)};disable=()=>{this.status.set(He.Suspended)};setFeatureConfig=({settings:e,...r})=>{let n;for(n in r)this.config.setValue(n,r[n]);if(e?.overlaySettings?.case!==void 0&&e?.overlaySettings.case===this.settingsKey){const i=e.overlaySettings.value;if(i!==void 0){let o;for(o in i)i[o]!==0&&i[o]!==""&&this.settings.setValue(o,i[o])}}};update=(e,r)=>{this.source===fe.STREAM&&r===fe.ORGANIZATION||(this.setFeatureConfig(e),this.source=r)};fireEvent(e){for(const r of this.listeners.values())try{r.onEvent(e)}catch(n){console.error(n)}}}class Y extends It{getValue=()=>this.getStore().get();getValues(){throw new Error("not implemented")}setValue=e=>this.getStore().set(e);subscribe=e=>this.getStore().subscribe(e);unsubscribe=()=>this.getStore().off();listen(e){return this.getStore().listen(e)}get(){return this.getStore().get()}}const j=t=>te.atom(t);class ae extends It{atomStore;constructor(e,r,n){super(e,`api:${r}`),this.atomStore=te.atom(),n&&e.subscribe(i=>{const o=this.atomStore.get(),s=n(i,o);o!==s&&this.atomStore.set(s)})}getAtomStore=()=>this.atomStore;getValue=async()=>{const e=this.getStore();if(e.value===void 0)throw new Error("no store");return await e.value.promise,e.get().data};getValues=()=>this.getStore().get();setValue=e=>this.getStore().set({loading:!1,data:e?.data});subscribe=e=>this.getStore().subscribe(e);unsubscribe=()=>{throw new Error("not implemented")};invalidate=()=>{this.store.invalidate()};listen=e=>this.getStore().listen(e);get(){throw new Error("not implemented")}key=()=>this.getStore().key;off=()=>this.getStore().off()}const U=new yi;async function*vi(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now(),t.id=vn++;const n={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(n),yield r}}let vn=0;const Si=()=>t=>async e=>{const r={id:vn++,name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries()),message:e.message},response:{}};window.postMessage({type:"__GRPC_DEVTOOLS_EXTENSION__",data:r});try{const n=await t(e);if(r.received_at=Date.now(),r.response.header=Object.fromEntries(n.header.entries()),r.response.trailer=Object.fromEntries(n.trailer.entries()),e.stream){const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...r,stream:!1}};return window.postMessage(i),{...n,message:vi(r,n.message)}}else{r.response.message=n.message,r.latency=r.received_at-r.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};window.postMessage(i)}return n}catch(n){r.received_at=Date.now(),r.response.trailer={"grpc-status":n.code,"grpc-message":n.rawMessage},r.response.message=n.rawMessage,r.latency=r.received_at-r.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};throw window.postMessage(i),n}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));function Sn(t){return t instanceof DOMException&&(t.code===22||t.code===1014||t.name==="QuotaExceededError"||t.name==="NS_ERROR_DOM_QUOTA_REACHED")}class xe{delimiter=":";prefix;storage;constructor(e="main",r=window.localStorage){this.prefix=`sl-sdk${this.delimiter}${e}`,this.storage=r}clear=()=>{for(const e in window.localStorage)e.startsWith(this.prefix)&&this.storage.removeItem(e)};generateKey=e=>`${this.prefix}${this.delimiter}${e.join(this.delimiter)}`;write=(...e)=>{const r=e.pop()||"",n=this.generateKey(e);try{this.storage.setItem(n,r)}catch(i){Sn(i)&&this.storage===window.sessionStorage&&(window.sessionStorage.removeItem("slstreamlogs"),this.storage.setItem(n,r))}};read=(...e)=>{const r=this.storage.getItem(this.generateKey(e));return r===null?void 0:r};remove=(...e)=>{this.storage.removeItem(this.generateKey(e))}}var Z;(function(t){t.Init="init",t.Ready="ready",t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected",t.Failed="failed",t.Reconnect="reconnect",t.Reconnecting="reconnecting"})(Z||(Z={}));const Fr=ue("grpc:stream");class wi{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,n,i){const o={status:Z.Init,ts:new Date,log:[]};this.state=new Ae(H(o),`subscription:${i.name}:state`),this.options={...i,reconnectDelay:i.reconnectDelay??1e3,reconnectMaxDelay:i.reconnectMaxDelay??3e4,reconnectMaxAttempts:i.reconnectMaxAttempts??10,withStore:i.withStore??!1},this.headers=e,this.listeners=new Map,this.params=n,this.method=r,i.withStore&&(this.store=new Y(j(null),`subscription:${i.name}:store`)),"subscribe"in n&&typeof n.subscribe=="function"&&(this.paramsListener=n.subscribe(s=>{this.state.getValue("status")===Z.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(Z.Ready)}updateState=e=>{this.state.setValue("status",e),this.state.setValue("ts",new Date),this.addStateLog(`status => ${e}`)};addStateLog=e=>{const r=this.state.getStore().get().log,n=`${this.options.name} ${new Date().toISOString()}: ${e}`;if(r.push(n),this.state.setValue("log",r),localStorage.getItem("SL_DEBUG")){e.startsWith("received data")?Fr.trace({name:this.options.name,attempt:this.attempt},"received data"):Fr.trace({name:this.options.name,attempt:this.attempt},e);try{window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
2
- `+n)}catch(i){Sn(i)&&window.sessionStorage.removeItem("slstreamlogs"),window.sessionStorage.setItem("slstreamlogs",n)}}};addListener=(e,r)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),()=>{}):(this.listeners.set(e,r),this.addStateLog(`listener '${e}' added`),()=>this.removeListener(e));removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(Z.Connecting),this.streamCancel&&(this.addStateLog("disconnect prev connection"),this.streamCancel.abort(),this.streamCancel=void 0);const e="get"in this.params&&typeof this.params.get=="function"?this.params.get():this.params;(async()=>{this.streamCancel=new AbortController;try{const n={headers:this.headers.getValues(),signal:this.streamCancel.signal},i=this.method(e,n);for await(const o of i)this.attempt=0,this.onData(o)}catch(n){n instanceof B.ConnectError&&n.code!=B.Code.Canceled&&this.onStreamError(n)}})(),this.updateState(Z.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(Z.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(Z.Reconnect);const e=Math.min(this.options.reconnectMaxDelay,Math.pow(2,this.attempt)*this.options.reconnectDelay),r=Math.round(e*(1+Math.random())/2);this.reconnectTimeout=setTimeout(()=>{this.attempt++,this.updateState(Z.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${r}ms`),this.connect(),this.reconnectTimeout=void 0},r)}else this.addStateLog("max reconnect attempts reached"),this.disconnect()};getStore=()=>this.store?.getStore();onData=e=>{try{this.addStateLog(`received data => ${JSON.stringify(e)}`),this.store&&this.store.setValue(e);for(const[,r]of this.listeners)r(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(r){this.addStateLog(`error process data => ${r}`)}};onStreamError=e=>{if(this.addStateLog(`error => ${e?JSON.stringify(e):"undefined"}}`),e!==void 0){if(e instanceof B.ConnectError&&e.code!==B.Code.Canceled){this.updateState(Z.Failed),this.state.setValue("error",e),this.reconnect();return}this.disconnect()}}}const Ti=new Set([B.Code.Unknown,B.Code.Internal,B.Code.DeadlineExceeded,B.Code.ResourceExhausted,B.Code.FailedPrecondition,B.Code.Unavailable,B.Code.DataLoss]),Dr=ue("grpc:retry"),Ai=t=>async e=>{const r=e.contextValues.get(tr.retryAttempts),n=300,i=e.contextValues.get(tr.retryDelay);if(e.stream||r===0)return t(e);Dr.trace({url:e.url,attempts:r,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){Dr.trace({attempt:o,error:s},"retry attempt");const a=B.ConnectError.from(s);if(o>=r||!(a instanceof B.ConnectError)||!Ti.has(a.code))throw s;const u=Math.min(i,Math.pow(2,o)*n),l=Math.round(u*(1+Math.random())/2);await new Promise(c=>setTimeout(c,l))}},tr={retryAttempts:B.createContextKey(10,{description:"Number of attempts to retry"}),retryDelay:B.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},Ei=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=Xt.nanoid();return localStorage.setItem("sl-device-id",e),e},Ii=()=>navigator.userAgentData?.platform||navigator.platform;class Rr{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;$headers;interceptors=[];clients;streamClients;subscriptions;opts;constructor(e,r){this.host=e,this.opts=r,this.$headers=new Ae(H({"sl-device-id":Ei(),"sl-device-os":Ii()}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.streamClients=new Map,this.subscriptions=new Map;const[n,i,o]=Pr.nanoquery({dedupeTime:r?.dedupeTime,refetchInterval:r?.refetchInterval});this.nanoquery={createFetcherStore:n,createMutatorStore:i,utils:o},this.transport=Lr.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors}),this.streamTransport=Lr.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors})}addSubscription=(e,r,n)=>{const i=this.subscriptions.get(r);if(i)return i;const o=new wi(this.$headers,e,r,n);return this.subscriptions.set(r,o),o};removeSubscription=e=>{e.disconnect(),this.subscriptions.delete(e.params)};disconnect=()=>{for(const[i,o]of this.subscriptions)o.disconnect(),this.subscriptions.delete(i);this.clients.clear(),this.streamClients.clear(),this.subscriptions.clear();const[e,r,n]=Pr.nanoquery({dedupeTime:this.opts?.dedupeTime,refetchInterval:this.opts?.refetchInterval});this.nanoquery={createFetcherStore:e,createMutatorStore:r,utils:n}};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(r=>r!==e)};getClient=e=>{const r=e.typeName;if(this.clients.has(r))return this.clients.get(r);const n=B.createClient(e,this.transport);return this.clients.set(r,n),n};getStreamClient=e=>{const r=`stream-${e.typeName}`;if(this.clients.has(r))return this.clients.get(r);const n=B.createClient(e,this.streamTransport);return this.clients.set(r,n),n};createPromiseClient=(e,{params:r=[],method:n})=>{const i=this.getClient(e),o=e.methods[n].name,s=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1),...Array.isArray(r)?r:[r]],a=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1)];return{client:i,createRequestOptions:l=>{const c=B.createContextValues();for(const f in l){const p=tr[f];c.set(p,l[f])}return c},queryKey:s,queryKeyStr:a.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,r)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",r)};setHeader=(e,r)=>this.$headers.setValue(e,r);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=r=>n=>{const i=this.$headers.getValues();for(const o in i)n.header.set(o,i[o]);return r(n)};this.interceptors.push(e),this.interceptors.push(Si()),this.opts?.retryable&&this.interceptors.push(Ai)}}const Oi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(dn.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>{if(!s||typeof s!="string")return"";try{return(await r.retrieveEventId({id:s})).data?.id||""}catch{return""}}})},_i=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.getStream({id:s})).data?.attributes:void 0})},Ci=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(dn.Events,{method:"summary",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.summary({id:s})).data?.attributes:void 0})},ki=(t,e)=>{const{queryKey:r,client:n}=e.createPromiseClient(hr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>{const{data:i}=await n.me({});return{data:i}}})},Li=t=>{const{client:e,createRequestOptions:r}=t.createPromiseClient(hr.Users,{method:"bypassAuth"}),n=r({retryAttempts:0});return({userKey:i,schema:o,init:s,inviterKey:a})=>e.bypassAuth({userKey:i,schema:o,init:s,inviterKey:a},{contextValues:n})},Pi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.get({})).data?.attributes})},Ni=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>{const i=await r.getOrganization({});return i.data?{...i.data.attributes,id:i.data.id}:void 0}})},Fi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},Di=(t,e,r)=>{t.transport=new Rr(e.host,{dedupeTime:1e3*60*5,refetchInterval:1e3*60*5,retryable:!0}),t.analyticsTransport=new Rr(e.analyticsHost),t.sdk.host=t.transport.host,t.transport.setSdkKey(e.sdkKey),t.transport.setHeader("sl-sdk-version",e.version||"-"),t.transport.$headers.subscribe(n=>{t.analyticsTransport.$headers.getStore().set(n)}),t.sdk.onMount({name:"transport"},()=>()=>{t.transport.disconnect(),t.analyticsTransport.disconnect()}),r()};var de;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(de||(de={}));class Ve extends xe{constructor(){super("user")}setSchema=e=>{this.write(de.SCHEMA,e)};getSchema=()=>this.read(de.SCHEMA);setToken=e=>{this.write(de.TOKEN,e)};getToken=()=>this.read(de.TOKEN);setExternalToken=e=>{this.write(de.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(de.EXTERNAL_TOKEN);removeToken=()=>{this.remove(de.TOKEN)}}var pe;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(pe||(pe={}));const Ri=t=>{const e=new Ve,r=new Y(j(e.getExternalToken()),"userKey"),n=new Y(j(e.getToken()),"userToken"),i=new ae(ki(n.getStore(),t),"user",({data:s,error:a,loading:u},l)=>{if(!a)return s?.data?.id?s.data.id:u===!1?void 0:l}),o=new ae(Pi(n.getStore(),t),"userSettings");return{userKey:r,userToken:n,user:i,userSettings:o}},Vi=t=>{const e=new Y(j(void 0),"providerStreamId"),r=new ae(Oi(e.getStore(),t),"slStreamId",o=>o?.data),n=new ae(_i(r.getAtomStore(),t),"streamSettings"),i=new ae(Ci(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(o=>{(o===""||o===void 0)&&(n.getStore().mutate(void 0),i.getStore().mutate(void 0))}),{providerStreamId:e,slStreamId:r,streamSettings:n,streamSummary:i}},$i=t=>{const e=new Y(j(void 0),"enabled"),r=new Y(j(pe.DISABLED),"status"),n=new ae(Ni(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new ae(Fi(n.getAtomStore(),t),"organizationAdvertising"),o=Ri(t),s=Vi(t);return{enabled:e,status:r,providerStreamId:s.providerStreamId,slStreamId:s.slStreamId,streamSettings:s.streamSettings,streamSummary:s.streamSummary,user:o.user,userKey:o.userKey,userToken:o.userToken,userSettings:o.userSettings,organizationSettings:n,organizationAdvertising:i}};class qi extends It{stores;constructor(e){const r=$i(e),n=gi(r);super(n,"core"),this.stores=r}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=e=>{let r;for(r in this.stores){const n=e[r];r in e&&n!==void 0&&this.stores[r].subscribe(e[r])}};unsubscribe=()=>this.getStore().off()}const Bi=(t,e,r)=>{t.store=new qi(t.transport),t.stores=t.store.getValues(),t.sdk.enabled=t.stores.enabled.getStore(),t.sdk.status=t.stores.status.getStore(),t.sdk.sdkStore=Object.fromEntries(Object.entries(t.stores).map(([n,i])=>[n,i.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.sdk.streamSummary=()=>t.stores.streamSummary.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},r()},Mi=t=>{const{client:e}=t.createPromiseClient(fn.Leaderboard,{method:"list"});return r=>e.list(r)},wn=t=>{const{client:e}=t.createPromiseClient(fn.Leaderboard,{method:"summary"});return r=>e.summary(r)},Ui=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(hr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>{if(!s)return[];try{return(await r.getFriends({})).data}catch{return[]}}})},ji=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(J.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.get({eventId:s})).data?.attributes,refetchInterval:0,dedupeTime:1e3*60*60})},Qi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(J.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>{if(!s)return;const a=await r.syncQuestion({filter:{eventId:s}});if(a.data?.attributes?.question?.type!==w.QuestionType.PROMOTION)return a.data?.attributes},dedupeTime:1e3*60*10,refetchInterval:0})},xi=async(t,e)=>{const{client:r}=e.createPromiseClient(J.Feed,{method:"item",params:[t]});return(await r.item({id:t})).data},Gi=(t,e)=>{const{client:r}=e.createStreamClient(J.Feed),n=te.atom({eventId:t.get()||"",feedId:""});return t.subscribe((o="")=>{n.set({eventId:o,feedId:""})}),e.addSubscription(r.subscription,n,{name:"feedSubscription"})},Ki=(t,e)=>{const{client:r}=e.createStreamClient(J.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},zi=async(t,e)=>{const{client:r}=e.createPromiseClient(J.Feed,{method:"questionByUser",params:[t]});return(await r.questionByUser({questionId:t})).data?.attributes?.question},rr=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(J.Feed,{method:"questionByUser",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.questionByUser({questionId:s})).data?.attributes?.question,dedupeTime:1e3*60*5})},Tn=async(t,e)=>{if(!t)return;const{client:r}=e.createPromiseClient(J.Feed,{method:"getQuestion",params:[t]}),n=await r.getQuestion({id:t});if(!n.data?.attributes)return;const{options:i,notification:o,...s}=n.data.attributes,a=i?.options.case==="promotion"?i?.options.value:void 0;return{id:s.id,question:s,promotion:a,notification:o}},Hi=(t,e,r)=>{const{client:n,queryKey:i}=r.createPromiseClient(J.Feed,{method:"list",params:[t,e]});return r.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>a?(await n.list({eventId:a,filter:{types:u===Ee.ALLOWED?[]:[w.QuestionType.FACTOID,w.QuestionType.PROMOTION,w.QuestionType.TWEET],statuses:[w.QuestionStatus.ACTIVE,w.QuestionStatus.RESOLVED]}})).data:[],dedupeTime:0,refetchInterval:0})},Wi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(J.Feed,{method:"list",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>{if(!s)return;const u=(await r.list({eventId:s,filter:{types:[w.QuestionType.PROMOTION],statuses:[w.QuestionStatus.ACTIVE]},pagination:{page:0,pageSize:1}})).data?.[0];if(u.type==="promotion")return Tn(u.id,e)},dedupeTime:0,refetchInterval:0})},Yi=(t,e,r)=>{const n=te.batched([e,r],()=>{const a=e.get();if(!a)return;const u=r.get().data?.find(c=>c.id===a?.questionId),l=a?.question?.openedFrom;return u?(u.openedFrom=l,u):a.question}),i=te.batched(n,a=>a&&a.type==="question"?a.id:void 0),o=rr(i,t);return{$store:n,$extendedStore:o,updateExtendedQuestion:a=>{const u=o.get().data,l=(c,f)=>{if(!c||!f)return c||f||[];const p=[];for(let S=0;S<c.length;S++)p.push({...c[S],...f[S],correct:c[S].correct,youVoted:c[S].youVoted,pointsEarned:c[S].pointsEarned});return p};o.mutate({...a,options:u?.options,subject:u?.subject,appearance:u?.appearance,answers:l(u?.answers,a?.answers)})}}};var mt;(function(t){t.SHOWED="showed"})(mt||(mt={}));class Ji extends xe{constructor(){super("advertisement")}setShowed=e=>{this.write(mt.SHOWED,e,"true")};isViewed=e=>this.read(mt.SHOWED,e)}const Xi=t=>{const e=t.data?.attributes?.question;if((t.data?.attributes?.feedItem?.type==="promotion"?t.data.attributes.feedItem:void 0)===void 0||!e)return;const{options:n,notification:i,...o}=e,s=n?.options.case==="promotion"?n.options.value:void 0;return{id:o.id,question:o,notification:i,promotion:s}},st=t=>t.startsWith("http://")||t.startsWith("https://")?new URL(t).toString():t,Zi=({gamOptions:t,gamBaseUrl:e})=>{const r=`${e}?`,n=[];for(const i in t){const o=i.replace(/([a-zA-Z])(?=[A-Z])/g,"$1_").toLowerCase(),s=t[i];if(s)if(typeof s=="string")n.push(`${o}=${st(s)}`);else if(Array.isArray(s))n.push(`${o}=${s.map(st).join(",")}`);else{const a=Object.entries(s).map(([u,l])=>Array.isArray(l)?`${u}=${l.map(st).join(",")}`:typeof l=="string"?`${u}=${st(l)}`:`${u}=${l}`).join("&").replaceAll("=","%3D").replaceAll("&","%26").replaceAll(",","%2C");n.push(`${o}=${a}`)}}return r+n.join("&")},Ne=t=>(t?.promotion?.type===w.PromotionType.INGAME_IAB11_LBAR||t?.promotion?.type===w.PromotionType.INGAME_IAB21_LBAR)&&!!t.promotion.additionalBanner?.imageUrl,eo=(t,e,r)=>{let n=!1;const i=r.transport,o=ue("advertisement"),s=new Ji,a=H({}),u=Wi(t,i),l=b=>{if(b?.fromNotification){a.setKey("hasNotification",!1);const g=a.get(),T=g.data?.question.id,D=g.data?.promotion?.type;T&&(U.emit("advertisement",{action:"opened",payload:{id:T,type:D,hasBanner:Ne(g.data),openedFrom:"notification"}}),U.emit("advertisement",{action:"notification-opened",payload:{id:T,type:D,hasBanner:Ne(g.data)}}))}},c=()=>{const b=a.get(),g=b.data?.question.id,T=b.data?.promotion?.type,D=a.get()?.isOpened;g&&!D&&(o.debug({id:g},"markAsViewed: %o"),s.setShowed(g),a.setKey("isOpened",!0),U.emit("advertisement",{action:"viewed",payload:{id:g,type:T,hasBanner:Ne(b.data)}}))},f=(b,g)=>{g?a.set({loading:!1,error:void 0,data:g,hasNotification:g?.notification?.enabled===w.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>p(g.question.id),togglePause:T=>S(g.question.id,T),isViewed:!!s.isViewed(g.question.id)}):(a.setKey("loading",!0),Tn(b,i).then(T=>a.set({loading:!1,error:void 0,data:T,hasNotification:T?.notification?.enabled===w.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>p(T?.question.id),togglePause:D=>S(T?.question.id,D),isViewed:T&&!!s.isViewed(T.question.id)})).catch(T=>a.set({loading:!1,error:T,data:void 0})))};a.subscribe((b,g)=>{if(!(b.data?.id===g?.data?.id&&b.isPaused!==g?.isPaused)){if(b.data?.promotion?.type===w.PromotionType.EXTERNAL_AD&&!b?.externalAd&&b.data.promotion.adCampaigns?.gamOptions&&b.data.promotion.adCampaigns?.gamBaseUrl){const T=Zi(b.data.promotion.adCampaigns);a.setKey("externalAd",{type:"gam",url:T})}b.data?.promotion&&!b.isOpened&&(U.emit("advertisement",{action:"received",payload:{id:b.data.question.id,type:b.data.promotion.type,hasNotification:!!b.hasNotification,hasBanner:Ne(b.data),isViewed:!!s.isViewed(b.data.question.id)},skipAnalytics:b.data.question.id===g?.data?.question.id}),b.data.question.id!==g?.data?.question.id&&!s.isViewed(b.data.question.id)&&U.emit("advertisement",{action:"notification-received",payload:{id:b.data.question.id,type:b.data.promotion.type,hasNotification:!0,hasBanner:Ne(b.data),isViewed:!1}})),!b?.data&&g?.data&&U.emit("advertisement",{action:"closed",payload:{id:g.data.question.id,type:g.data.promotion?.type,hasNotification:!!g.hasNotification,hasBanner:Ne(g.data),isViewed:!!s.isViewed(g.data.question.id)}})}});const p=b=>{(!b||a.get()?.data?.question.id===b)&&a.set({})},S=(b,g)=>{a.get()?.data?.question.id===b&&a.setKey("isPaused",g)};return{connect:()=>{n||(n=!0,u.subscribe((b,g)=>{b.data&&(!g?.data||b.data.id!==g.data.id)&&f(b.data.question.id,b.data)}),e.addListener("promotion",b=>{const g=Xi(b);if(g){if(g.question.status===w.QuestionStatus.RESOLVED){p(g.question.id),o.debug({promotion:g},"resolved: %o");return}if(g.question.status===w.QuestionStatus.ACTIVE){o.debug({promotion:g},"active: %o"),f(g.question.id,g);return}o.debug({promotion:g},"skip: %o")}}))},hide:p,show:f,open:l,markAsViewed:c,$store:a}};var Ee;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Ee||(Ee={}));class to{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;advertisement;notifications;log;transport;cancels=new Set;constructor(e){this.transport=e.transport,this.log=ue("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new Y(j(void 0),"moderationId").getStore(),this.interactiveAllowed=new Y(j(Ee.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new Y(j(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new ae(ji(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new ae(Hi(this.slStreamId,this.interactiveAllowed,e.transport),"gamification:feedList"),this.activeQuestionId=Qi(this.slStreamId,e.transport),this.openedQuestion=Yi(e.transport,this.openedQuestionId,this.feedList.getStore()),this.cancels.add(this.openedQuestionId.listen(r=>{this.log.debug({item:r},"received question"),r?.questionId?(this.questionSubscription=Ki(r.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",n=>{this.openedQuestion.updateExtendedQuestion(n.data?.attributes?.question)}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))})),this.feedSubscription=Gi(this.slStreamId,e.transport),this.cancels.add(this.feedSubscription.addListener("feed-subscription-active-question",r=>{const n=this.activeQuestionId.get().data?.question?.id,i=r.data?.attributes?.question;if(!(!i||i.type===w.QuestionType.PROMOTION)){if(i.status===w.QuestionStatus.RESOLVED){n===i.id&&this.activeQuestionId.mutate(void 0);return}window.requestAnimationFrame(()=>{this.activeQuestionId.mutate(r.data?.attributes)})}})),this.cancels.add(this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})})),this.cancels.add(this.activeQuestionId.subscribe((r,n)=>{r.data?.feedItem&&r.data?.feedItem?.id!==n?.data?.feedItem?.id&&e.onQuestionActivate({stage:"activate",id:r.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:r.data.feedItem.id})),hasNotification:!0,type:r.data.feedItem.type}),!r.data?.feedItem&&n?.data?.feedItem&&e.onQuestionActivate({stage:"deactivate",id:n.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:n.data.feedItem.id})),hasNotification:!0,type:n.data.feedItem.type})})),this.feedSubscription.connect(),this.cancels.add(this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})),e.sdk.onMount({name:"gamification-background"},()=>()=>{this.activeQuestionId.off();for(const r of this.cancels)r(),this.cancels.delete(r)}),this.advertisement=eo(this.slStreamId,this.feedSubscription,e)}getCurrentSessionId=e=>{const r=e.eventId||this.slStreamId.get()||"",n=e.userId||this.userId.get()||"",i=e.organizationId||this.organizationId.get()||"",o=e.entity||"",s=e.prefix||"";return[i,r,n,s,o].join(":")};disconnect=()=>{this.feedSubscription?.disconnect(),this.questionSubscription!==void 0&&(this.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0)};openQuestion=(e,r)=>{this.openedQuestionId.set({questionId:e,question:r}),this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))};closeQuestion=e=>{this.openedQuestionId.set(void 0),e&&this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))}}class ro{notificationsList;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=ue("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notificationsList=j(new Map)}addToQueue=e=>{if(this.store.has(e.id)){this.logger.debug({notification:e},"skip existed notification: %o");return}const r=e.close,n=e.action;if(this.store.set(e.id,{...e,close:(...i)=>{r&&r(...i),this.closeNotification(e.id)},action:(...i)=>{n&&n(...i),this.closeNotification(e.id,{animateHiding:!1})}}),this.waitingQueue.add(e.id),this.activeQueue.size===this.options.concurrency){const[i]=this.activeQueue;if(this.store.get(i)?.persistent!==!0)this.closeNotification(i);else{const[s]=this.waitingQueue;this.waitingQueue.size>1&&this.closeNotification(s),this.tickWaitingQueue()}}else this.tickWaitingQueue()};tickWaitingQueue=()=>{if(this.activeQueue.size<this.options.concurrency){const[e]=this.waitingQueue;if(!e)return;this.activeQueue.add(e),this.waitingQueue.delete(e),this.logger.debug({job:e},"waiting queue tick"),this.tickActiveQueue(e)}else this.logger.debug({queueSize:this.activeQueue.size,concurrency:this.options.concurrency},"waiting queue tick skipped")};tickActiveQueue=e=>{if(!e)return;const r=this.store.get(e);if(!r){this.logger.debug({notificationId:e},"active queue tick skipped, notification not exist");return}U.emit("notification",{action:"received",payload:{questionId:r.data.questionId,questionType:r.data.questionType}});const n=setTimeout(()=>{const i=e,o=new Map(this.notificationsList.get());o.set(r.id,r),this.notificationsList.set(o);const s=setTimeout(()=>{this.logger.debug({notificationId:i,delay:r.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(i)},r.autoHideDuration||5e3);this.timeouts.set(i,s),this.logger.debug({notificationId:i,queue:[...o.values()]},"notification displayed")},r.delay||0);this.timeouts.set(e,n),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=(e,{animateHiding:r=!0}={})=>{const n=new Map(this.notificationsList.get()),i=n.get(e);if(i){i.hiding=!(this.waitingQueue.size>=this.options.concurrency)&&r,this.notificationsList.set(n);const o=setTimeout(()=>{const s=new Map(this.notificationsList.get());s.delete(e),this.notificationsList.set(s);const a=this.timeouts.get(e);a!==void 0&&(clearTimeout(a),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden"),i.hiding&&U.emit("notification",{action:"closed",payload:{questionId:i.data.questionId,questionType:i.data.questionType}})},this.options.animationDelay||0);this.timeouts.set(e,o)}return this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding"),i};drain=()=>{this.store.clear(),this.timeouts.clear(),this.waitingQueue.clear(),this.activeQueue.clear(),this.notificationsList.off(),this.notificationsList.set(new Map)}}var gt;(function(t){t.OPENED="opened"})(gt||(gt={}));class no extends xe{constructor(){super("notification")}setOpened=e=>{this.write(gt.OPENED,e,"true")};isOpened=e=>this.read(gt.OPENED,e);clearNotification=()=>{this.clear()}}var be;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(be||(be={}));class io{queue;storage;constructor(e={}){this.storage=new no,this.queue=new ro({concurrency:1,animationDelay:1600,...e})}isViewed=e=>this.storage.isOpened(e);add=e=>{if(!this.isViewed(e.id)){if(e.data&&e.emitEvent){const n=e.action;e.action=(...i)=>{n&&n(...i),U.emit("notification",{action:"opened",payload:{questionId:e.data.questionId,questionType:e.data.questionType}})}}this.queue.addToQueue(e)}};close=(e,{markAsViewed:r=!0,animateHiding:n}={})=>{this.queue.closeNotification(e,{animateHiding:n}),r&&this.markAsViewed(e)};getActiveNotification=()=>{const e=this.queue.notificationsList.get();if(!e?.size)return null;for(const n of e.values())if(n.type===be.ONBOARDING)return n;return e.values().next().value};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const oo=(t,e,r)=>{t.notifications=new io(void 0),t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),t.sdk.getActiveNotification=()=>t.notifications.getActiveNotification(),t.sdk.onMount({name:"notifications"},()=>()=>{t.notifications.queue.drain()}),r()};var Je;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(Je||(Je={}));const so=async(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(J.Feed,{method:"submitAnswer"}),i=n({retryAttempts:0});try{return await r.submitAnswer({data:e},{contextValues:i})}catch(o){throw B.ConnectError.from(o)?.code===B.Code.AlreadyExists?new Error(Je.ALREADY_VOTED):new Error(Je.UNKNOWN)}},ao=(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(J.Feed,{method:"submitInplay"}),i=n({retryAttempts:0});return r.submitInplay({data:{eventId:+e}},{contextValues:i})};var $e;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})($e||($e={}));class uo extends xe{constructor(){super("gamification-session",window.sessionStorage)}writeValue=(e,r)=>{this.write(...e,r)};readValue=e=>this.read(...e)}class An extends xe{sessionStorage;constructor(){super("gamification"),this.sessionStorage=new uo}saveOnboardingStatus=({userId:e,eventId:r,organizationId:n},i)=>{this.write($e.ONBOARDING,n,e,r,i)};getOnboardingStatus=({userId:e,eventId:r,organizationId:n})=>this.read($e.ONBOARDING,n,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{this.sessionStorage.writeValue([$e.ONBOARDING_IO,n,e,r],"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>this.sessionStorage.readValue([$e.ONBOARDING_IO,n,e,r])}const co={pageSize:10},lo=(t,e,r,n,i)=>{let o=0;const s=j({pageSize:co.pageSize,page:0}),a=H({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=Mi(t),l=async()=>{const p=e.get(),S=n.getStore().get().data?.map(A=>A.slId)||[];if(p&&S?.length){const A=r.get();A&&S.push(A),a.setKey("loading",!0),a.setKey("data",[]);const g=await u({eventId:p,usersIds:S});a.set({data:g.data.map((T,D)=>({...T.attributes,friendsRank:D+1})),hasMore:!1,key:Date.now(),loading:!1}),g.meta&&(o=Math.round(g.meta.count/g.meta.pageSize))}},c=()=>{l()},f=p=>{const S=s.get(),A=p||S.page+1;A<=o&&s.set({...S,page:A})};return te.onMount(a,()=>{const p=e.listen(l),S=n.listen(l);return()=>{p(),S()}}),{$store:a,fetchMore:f,invalidate:c}};class fo extends xe{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Vr="sldl",Ot="sldl_uid",En="sldl_eid",In="sldl_e_eid",po=new Set([Ot,En,In]),$r=t=>{const e={},r={};for(const[n,i]of t)po.has(n)?e[n]=i:r[n]=i;return{result:e,remain:r}},ho=({hash:t,search:e})=>{if(t&&t.includes(Vr)){const r=new URLSearchParams(t.substr(1));return{hash:$r(r)}}if(e&&e.includes(Vr)){const r=new URLSearchParams(e);return{search:$r(r)}}return null},qr=ue("deep_link"),se={debug:(...t)=>{qr.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{qr.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},yo=(t,e)=>{const{hash:r,search:n}=window.location;if(se.debug({hash:r,search:n},"get deep link data from"),r||n){const i=ho({hash:r,search:n});if(se.debug(i,"parse deep link result"),i){const{hash:o,search:s}=i,{result:a,remain:u}=o||s;if(Object.keys(a).length!==0){t.setValue("data",a);const l=Object.keys(u).length!==0;if(o){let c="";l&&(c=`#${new URLSearchParams(u).toString()}`,se.debug({updatedHash:c},"update hash")),window.history.replaceState(null,"",window.location.pathname+window.location.search+c)}if(s){let c="";l&&(c=`?${new URLSearchParams(u).toString()}`,se.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},mo=(t,e,r)=>{const n=new fo,i=n.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){se.debug(a)}t.deepLink={$store:new Ae(H(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{se.debug(`logged in with inviterId: ${a}`),t.deepLink.$store.setValue("used",!0)},onDeepLinkHandlers:new Set},t.sdk.getInviter=()=>{const{data:a,used:u}=t.deepLink.getDeepLinkData();return u?a?.[Ot]:void 0},t.sdk.inviteDisplayed=()=>{t.deepLink.$store.getStore().set({}),t.deepLink.$store.getStore().off(),n.del("sl-deep-link-store")},t.deepLink.$store.subscribe(a=>n.set("sl-deep-link-store",JSON.stringify(a))),t.sdk.addDeepLinkHandler=a=>{localStorage.getItem("SL_DEBUG")&&se.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{se.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),se.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{se.trace("called handler"),u(a)}catch(l){console.error(l)}};yo(t.deepLink.$store,s),r()},go=ue("bypass");class bo extends mi{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,n){super(),this.$coreStore=e,this.deepLink=n,this.transport=r,this.bypassLogin=Li(this.transport),this.connect()}me=async()=>(this.$coreStore.getValues().user.invalidate(),(await this.$coreStore.getValues().user.getValue())?.data);login=async(e,r)=>{this.$coreStore.getValues().userKey.setValue(r);const{used:n,data:i}=this.deepLink.getDeepLinkData(),o=n?"":i?.[Ot];go.debug({inviterKey:o},"login with inviterKey");const s=await this.bypassLogin({schema:e,userKey:r,inviterKey:o,init:!1}),a=s.meta?.jwt,u=s.data?.id;if(!a||!u)throw new Error("internal: token missing");return s.meta?.inviterKey&&this.deepLink.deepLinkUsed(s.meta.inviterKey),this.$coreStore.getValues().user.getStore().mutate({data:s.data}),this.saveUser(a,u),a};isAuthenticated=()=>this.me();logout=()=>{this.$coreStore.getValues().user.setValue(),this.$coreStore.getValues().userKey.setValue(),this.$coreStore.getValues().userToken.setValue(),this.transport.setAuth("",""),new Ve().clear()};softLogout=()=>{const e=new Ve;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=()=>{const e=new Ve,r=e.getToken(),n=e.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(n),r)return this.saveUser(r,""),this.me().then(i=>{if(i?.id){const o=i.id;this.saveUser(r,o)}});if(n&&!r){const i=e.getSchema();i&&n&&this.login(i,n).catch(()=>{this.logout()})}};saveUser=(e,r)=>{this.transport.setAuth(e,r),this.$coreStore.getValues().userToken.setValue(e),new Ve().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async r=>{try{return await e(r)}catch(n){throw n.code&&(n.code===7||n.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),n}})}}const ze=new Ve,vo=(t,e,r)=>{t.auth=new bo(t.store,t.transport,t.deepLink),t.stores.status.listen(n=>{n===pe.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(n,i)=>{if(!(ze.getSchema()===n&&ze.getExternalToken()===i&&t.transport.getHeader("authorization")))try{await t.auth.login(n,i),ze.setSchema(n),ze.setExternalToken(i)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),ze.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},Br=ue("video_player"),at={debug:(...t)=>{Br.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{Br.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},So=(t,e,r)=>{t.videoPlayer={controllers:new Set},t.sdk.addVideoPlayerController=n=>{at.trace("adding video player controller"),t.videoPlayer.controllers.add(n)},e.videoPlayerController&&t.sdk.addVideoPlayerController(e.videoPlayerController),t.sdk.removeVideoPlayerController=n=>{at.trace("removing video player controller"),t.videoPlayer.controllers.delete(n)},t.sdk.controlVideoPlayer=n=>{at.trace("controlling video player");for(const i of t.videoPlayer.controllers){at.trace("calling video player controller");try{i(n)}catch(o){console.error(o)}}},r()},wo={[w.QuestionType.FACTOID]:"insight",[w.QuestionType.POLL]:"poll",[w.QuestionType.TRIVIA]:"trivia",[w.QuestionType.PREDICTION]:"prediction",[w.QuestionType.TWEET]:"tweet"},To=(t,e,r)=>{t.sdk.uiState=H({}),t.ui={enableAppNotification:function(){t.sdk.uiState.setKey("appNotification",!0)},disableAppNotification:function(){t.sdk.uiState.get().app||t.sdk.uiState.setKey("appNotification",!1)},enableApp:function(){t.sdk.uiState.set({app:!0,appNotification:!0})},disableApp:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),appNotification:!1,app:!1})}},e.onContentActivate&&(t.ui.onContentActivate=e.onContentActivate);const n=i=>{t.ui.onContentActivate&&t.ui.onContentActivate({...i,type:"advertisement"})};t.onQuestionActivate=({questionType:i,...o})=>{if(t.ui.onContentActivate){const s=o.type||i&&wo[i]||"question";t.ui.onContentActivate({...o,type:s})}},t.sdk.onMount({name:"ui"},()=>{const i=a=>{if(a.slEventBus?.type==="notification")switch(a.slEventBus.action){case"received":t.ui.enableAppNotification();break;case"closed":t.ui.disableAppNotification();break}if(a.slEventBus?.type==="advertisement"&&e.withAd){const u=a.slEventBus,{hasNotification:l,hasBanner:c,id:f,isViewed:p,type:S}=u.payload;switch(u.action){case"notification-opened":t.sdk.uiState.set({promotionExternalAd:S===w.PromotionType.EXTERNAL_AD,promotionBanner:c,promotionNotification:!1,promotionOverlay:!0,promotionSidebar:!0});break;case"received":if(t.sdk.closeFeature(),n({stage:"activate",id:f,hasNotification:l,hasBanner:c,isViewed:p}),!e.withAdNotification){t.sdk.uiState.set({promotionBanner:c,promotionOverlay:!0,promotionSidebar:!0,promotionExternalAd:S===w.PromotionType.EXTERNAL_AD});break}l?t.sdk.uiState.set({promotionNotification:!0}):t.sdk.uiState.set({promotionBanner:c,promotionOverlay:!0,promotionSidebar:!0,promotionExternalAd:S===w.PromotionType.EXTERNAL_AD});break;case"closed":t.sdk.uiState.set({...t.sdk.uiState.get(),promotionNotification:!1,promotionBanner:!1,promotionOverlay:!1,promotionExternalAd:!1,promotionSidebar:!1}),n({stage:"deactivate",id:f,hasNotification:l,hasBanner:c,isViewed:p});break}}},o=U.listen(i),s=t.activeFeature.subscribe(a=>{a?t.ui.enableApp():t.ui.disableApp()});return()=>{o(),s()}}),r()},Ao=(t,e,r)=>{const n={onMountedFired:!1},i=new Map,o=new Map;t.sdk=Object.create(null),t.sdk.options=H(e),t.sdk.withAuth=!1,t.sdk.onMount=({name:s,clear:a},u)=>{if(i.has(s)){const l=o.get(s);l&&l(),i.delete(s),o.delete(s)}i.set(s,{cb:u,clear:a}),t?.stores?.enabled?.get()==="on"&&o.set(s,u())},t.ready=()=>{t.stores.enabled.subscribe(s=>{s==="on"&&n.onMountedFired===!1&&(i.forEach(({cb:a},u)=>o.set(u,a())),n.onMountedFired=!0),s!=="on"&&n.onMountedFired===!0&&(o.forEach(a=>a()),o.clear(),i.forEach(({clear:a},u)=>a&&i.delete(u)),n.onMountedFired=!1)})},t.sdk.initializeApp=async s=>{if(t.contextConfig=s,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(pe.INITIALIZATION);try{const a=await t.stores.organizationSettings.getValue();return a?(t.stores.status.setValue(pe.READY),{enabled:!!a}):(t.stores.status.setValue(pe.FAILED),{err:"failed"})}catch(a){return t.stores.enabled.setValue(),t.stores.status.setValue(pe.FAILED),{err:`${a}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(pe.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=s=>{t.stores.providerStreamId.setValue(s)},r()},Eo=(t,e)=>{const{client:r,queryKey:n}=t.createPromiseClient(Xe.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s,a)=>{if(!s)return{};try{return(await r.generateDeepLink({data:{gamification:!0,externalEventId:a,eventId:s}})).data?.attributes}catch{return}},dedupeTime:1e3*60*60*24,refetchInterval:0})},Io=(t,{web:e,mobile:r})=>{const{client:n}=t.createPromiseClient(ai.LinksClient,{method:"generate"});return n.generate({web:e,mobile:r})},Mr=(t,e)=>{const r=new URLSearchParams(t);for(const[n,i]of Object.entries(e))r.append(n,i);return r.toString()},Oo=(t,e,r,n)=>{const i=H({});return te.onMount(i,()=>Eo(t,[e,r]).subscribe(async({data:a,loading:u})=>{const l=a===void 0&&u===!1?"https://streamlayer.io":a?.url,c=n.get()||"",f=e.get()||"",p=r.get()||"",S={[Ot]:c,[En]:f,[In]:p};if(!u&&l){i.setKey("loading",!0);let A=window.location.search,b=window.location.hash;A&&b||b?A=`?${Mr(A,S)}`:b=`#${Mr("",S)}`;const g=window.location.origin+window.location.pathname+A+b;try{const T=await Io(t,{web:g,mobile:l});i.set({data:T.data?.link,loading:!1})}catch{i.set({loading:!1,error:"Failed to generate short link",data:void 0})}}else i.setKey("loading",!0)})),{$store:i,fetch}};var M;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(M||(M={}));const _o=(t,e,r,n)=>{const{inplayGame:i}=t.featureSettings.get(),o=e.getCurrentSessionId({prefix:"onboarding"});i&&r.add({type:be.ONBOARDING,id:o,action:t.openFeature,close:()=>{t.onboardingProcessed.set(!0)},persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:w.QuestionType.UNSET,onboarding:{...i,instantOpen:!n.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},ut=(t,e,r,n,i,o)=>{try{const s=e.userId.get();if(!s)return;if(i.getOnboardingStatus({userId:s,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===M.Completed){t.set(M.Completed);for(const p of o)p();return}const u=e.moderation.getStore().value?.data,l=r.featureSettings.get().inplayGame;if(u===void 0||l===void 0)return;const c=u?.options?.onboardingEnabled,f=l?.titleCard?.optIn;c?f?t.set(M.Required):t.set(M.Optional):(f?t.set(M.Unavailable):t.set(M.Disabled),n.close(e.getCurrentSessionId({prefix:"onboarding"}),{markAsViewed:!1}))}catch(s){console.error(s)}},Co=(t,e,r,n)=>{let i=!1;const o=new An,s=j(M.Unset);s.subscribe(l=>{l!==M.Unset&&(l===M.Optional||l===M.Required?i===!1&&(_o(t,e,n,o),i=!0):t.onboardingProcessed.set(!0),l===M.Completed&&e.activeQuestionId.invalidate(),o.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const a=[];return ut(s,e,t,n,o,a),s.get()!==M.Completed&&(a.push(e.userId.listen(l=>{l&&ut(s,e,t,n,o,a)})),a.push(e.moderation.listen(l=>{l.data&&ut(s,e,t,n,o,a)})),a.push(t.featureSettings.listen(l=>{l&&ut(s,e,t,n,o,a)}))),{$store:s,submitInplay:async()=>{const l=e.slStreamId.get();if(l){await ao(r,l),s.set(M.Completed),o.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:l},M.Completed),U.emit("poll",{action:"onboardingPassed",payload:{}}),t.openFeature();const c=e.getCurrentSessionId({prefix:"onboarding"});n.close(c)}}}},ko=(t,e,r,n)=>{const i=H(void 0),o=wn(n),s=async()=>{const u=t.get(),l=e.get(),c=r.getStore().get().data?.map(S=>S.slId);if(!c)return;const f={eventId:u,userId:l,usersIds:[...c,l]},p=await o(f);i.set(p.data?.attributes)},a=()=>{s()};return te.onMount(i,()=>{const u=t.listen(s),l=r.listen(s),c=e.listen(s);return()=>{u(),l(),c()}}),{$store:i,invalidate:a}},Lo=async(t,e,r,n,i)=>{const o=wn(i),s=t.get(),a=e.get(),u=r.getStore().get().data?.map(p=>p.slId)||[],l={eventId:s,userId:n,usersIds:[...u,a]};return(await o(l)).data?.attributes?.summary},Po=new Set([w.QuestionType.POLL,w.QuestionType.PREDICTION,w.QuestionType.TRIVIA]);class No extends bn{userSummary;feedList;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;advertisement;onboardingProcessed;friendsTabEnabled;notifications;transport;background;storage;submitAnswerTimeout;cancels=new Set;onQuestionActivate;constructor(e,r,n){super(e,r),this.background=new to(n),this.advertisement=this.background.advertisement,this.onQuestionActivate=n.onQuestionActivate,this.feedSubscription=this.background.feedSubscription,this.activeQuestionId=this.background.activeQuestionId,this.openedQuestionId=this.background.openedQuestionId,this.storage=new An,this.feedList=this.background.feedList,this.friends=new ae(Ui(this.background.userId,n.transport),"gamification:friends"),this.currentUserId=this.background.userId,this.openedUser=j(void 0),this.onboardingProcessed=j(!n.sdk.withAuth),this.leaderboardId=new Y(j(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=Co(this,this.background,n.transport,n.notifications),this.notifications=n.notifications,this.transport=n.transport,this.closeFeature=(i=!0)=>n.sdk.closeFeature(i),this.openFeature=()=>n.sdk.openFeature(V.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=Oo(this.transport,this.background.slStreamId,n.stores.providerStreamId.getStore(),this.background.userId),this.userSummary=ko(this.background.slStreamId,this.background.userId,this.friends,this.transport),this.leaderboardList=lo(this.transport,this.background.slStreamId,this.background.userId,this.friends),this.connect(),this.cancels.add(this.userSummary.$store.listen((i,o)=>{o?.summary&&i?.summary&&this.leaderboardList.invalidate()})),this.cancels.add(this.onboardingStatus.$store.listen(this.checkInteractiveFlag)),this.cancels.add(this.background.moderation.getStore().listen(this.checkInteractiveFlag)),this.cancels.add(this.settings.subscribe(this.checkInteractiveFlag)),this.cancels.add(this.onboardingStatus.$store.listen((i,o)=>{(o===void 0||i!==M.Unset)&&this.background.activeQuestionId.invalidate()})),this.background.activeQuestionId.listen(this.showInApp),this.friendsTabEnabled=j(!1),this.cancels.add(n.sdk.options.subscribe(i=>{i.friendsTab==="disabled"?this.friendsTabEnabled.set(!1):i.friendsTab==="enabled"&&this.friendsTabEnabled.set(!0)})),this.cancels.add(this.settings.subscribe(i=>{n.sdk.options.get().friendsTab==="activatedGame"&&this.friendsTabEnabled.set(!!i.inplayGame?.titleCard?.optIn)})),n.sdk.onMount({name:"gamification",clear:!0},()=>()=>{for(const i of this.cancels)i(),this.cancels.delete(i)})}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===Ee.ALLOWED}checkInteractiveFlag=()=>{const e=this.onboardingStatus.$store.get(),r=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,n=this.settings.getValues().inplayGame?.titleCard?.optIn,i=e===M.Completed,o=!r||i||n!==!0;this.background.interactiveAllowed.set(o?Ee.ALLOWED:Ee.DISALLOWED)};connect=()=>{this.onboardingProcessed.subscribe(e=>{e&&this.advertisement.connect()}),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-prediction-close",async e=>{if(!this.isInteractiveAllowed)return;const r=e.data?.attributes?.question,n=e.data?.attributes?.feedItem;if(!r||!n?.attributes)return;const{status:i,type:o,id:s,answers:a}=r;if(i===w.QuestionStatus.RESOLVED&&o===w.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),l=[...this.feedList.getValues().data||[]],c=l.findIndex(K=>K.id===s),f=l[c];let p=f?.attributes?.attributes?.value?.answerId;const S=rr(s,this.transport),A=S.subscribe(()=>{});await S.get().promise;let b=S.get().data;b||(b=await zi(s,this.transport)),A(),window.requestAnimationFrame(()=>{S.invalidate()}),p||(p=b?.answers.find(({youVoted:K})=>K)?.id);const g=a.find(({correct:K})=>K),T=p?a.find(({id:K})=>K===p):void 0,D=!!T?.correct;if(f&&l[c]?.attributes?.attributes.case==="question"){try{l[c].attributes.attributes.value.answerId=p,l[c].attributes.attributes.value.openForVoting=!1,p&&(l[c].attributes.attributes.value.status=D?it.PickHistoryStatus.WON:it.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(l)}if(!T||!g)return;this.openedQuestionId.get()?.questionId!==r.id&&this.notifications.add({type:be.QUESTION_RESOLVED,action:()=>this.openQuestion(r.id,n),close:()=>this.closeQuestion(s),autoHideDuration:D?15e3:12e3,id:u,emitEvent:!1,data:{questionId:s,questionType:w.QuestionType.PREDICTION,question:{title:D?`Congratulations! You answered correctly! You won ${g.points} pts!`:`Better luck next time! Correct: ${g?.text}!`,votedAnswer:{title:T?.text,points:T?.points},correctAnswerTitle:g?.text,correct:!!D,predictionResult:i===w.QuestionStatus.RESOLVED,questionTitle:r?.subject}}}),this.userSummary.invalidate()}})),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-questions-list",e=>{const r=[...this.feedList.getStore().value?.data||[]],n=e.data?.attributes?.feedItem,i=r.findIndex(o=>o.id===n?.id);if(n?.attributes&&n.attributes.attributes.case!=="promotion"&&!(n.attributes.status!==w.QuestionStatus.ACTIVE&&n.attributes.status!==w.QuestionStatus.RESOLVED)){if(i!==-1)if(n.attributes.attributes.case==="question"&&r[i].attributes?.attributes.case==="question"){const o=r[i];o.attributes&&(r[i]={...r[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...n.attributes.attributes.value,answerId:o.attributes.attributes.value.answerId,status:o.attributes.attributes.value.status,openForVoting:o.attributes.attributes.value.openForVoting}}}})}else{const o=r[i];o.attributes&&n.attributes&&(r[i]={...r[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...n.attributes.attributes.value}}}})}i===-1&&(r.unshift(n),U.emit("poll",{action:"received",payload:{questionId:n.id,questionType:n.attributes?.type}})),this.feedList.getStore().mutate(r)}}))};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-prediction-close"),this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitAnswer=async(e,r)=>{const n=rr(e,this.transport),i=n.subscribe(()=>{}),o={...n.get().data||{}},s=()=>{const a=this.feedList.getValues().data;if(!a)return;const u=a.findIndex(f=>f.id===e),l=a[u],c=l?.attributes?.attributes.case==="question"&&l.attributes.attributes.value;if(c){U.emit("poll",{action:"voted",payload:{questionId:e,questionType:c.questionType}});const f=n.get().data;if(i(),f){const p=f.answers.find(g=>g.correct===!0),S=f.answers.findIndex(g=>g.id===r),A=f.answers[S],b=f.answers.every(({percentageDecimal:g},T)=>g===o?.answers[T].percentageDecimal);a[u].attributes.attributes.value.answerId=r,a[u].attributes.attributes.value.openForVoting=!1,a[u].attributes.attributes.value.text=A?.text||"",p&&(a[u].attributes.attributes.value.status=p.id===r?it.PickHistoryStatus.WON:it.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...a]),f.answers[S].correct=p?.id===r,f.answers[S].youVoted=!0,b&&f.answers.forEach(g=>{g.percentageDecimal=0}),p?.id===r&&(f.answers[S].pointsEarned=f.status===w.QuestionStatus.RESOLVED?0:p.points),n.mutate({...f})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await so(this.transport,{questionId:e,answerId:r}),s()}catch(a){if(a.message===Je.ALREADY_VOTED){this.userSummary.invalidate();const u=n.subscribe(()=>{});n.invalidate(),u()}throw a}};openQuestion=(e,r)=>{if(!e)return()=>{};this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}),{animateHiding:!1});let n=r?.attributes?.type;return n||(n=(this.feedList.getStore().value?.data||[]).find(o=>o.id===e)?.attributes?.type),U.emit("poll",{action:"opened",payload:{questionId:e,questionType:n,questionOpenedFrom:r?.openedFrom}}),this.background.openQuestion(e,r)};getFeedItem=e=>xi(e,this.transport);isOpenedQuestion=e=>!!this.notifications.isViewed(e);closeQuestion=e=>(e&&this.onQuestionActivate({stage:"deactivate",id:e,isViewed:!!this.notifications.isViewed(this.background.getCurrentSessionId({prefix:"notification",entity:e}))}),this.background.closeQuestion(e));openUser=async e=>{const r=this.leaderboardList.$store.get().data?.find(i=>i.userId===e);if(!r){this.openedUser.set(r);return}if(r.summaryLoaded){this.openedUser.set(r);return}const n={...r};try{const i=await Lo(this.background.slStreamId,this.background.userId,this.friends,e,this.transport);i?.inTop!==void 0&&(this.leaderboardList.$store.setKey("data",this.leaderboardList.$store.get().data?.map(o=>(o.userId===e&&(o.inTop=i.inTop),o))),n.inTop=i.inTop)}catch(i){console.error(i)}this.openedUser.set(n)};closeUser=()=>{this.openedUser.set(void 0)};showInApp=e=>{const r=this.onboardingStatus.$store.get();if(e&&e.data&&r&&r!==M.Unset&&e.data.question?.id!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==w.SilenceSetting.ON&&e.data.question.status===w.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(Po.has(e.data.question.type))this.isInteractiveAllowed&&e.data.question.notification!==void 0&&this.notifications.add({type:be.QUESTION,action:()=>this.openQuestion(e.data?.question?.id,e.data?.feedItem),close:()=>this.closeQuestion(e.data?.question?.id),autoHideDuration:1e3*60,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),emitEvent:!0,data:{questionId:e.data.question.id,questionType:e.data.question.type,question:{title:e.data.question.notification.title}}});else if(e.data.question.type===w.QuestionType.FACTOID){const n=e.data.question.options?.options.value,i=e.data.question.notification?.title||e.data.question.subject||"",o=e.data.question.notification?.body||n.body,s={heading:i,body:o,imageMode:n?.imageMode,image:n?.image,video:{id:n?.video?.id||"",url:n?.video?.url||"",thumbnailUrl:n?.video?.thumbnailUrl||""},webLink:{label:"",url:""}};this.notifications.add({type:be.QUESTION,action:()=>this.openQuestion(e?.data?.question?.id,e?.data?.feedItem),close:()=>this.closeQuestion(e?.data?.question?.id),autoHideDuration:1e3*120,emitEvent:!0,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionId:e.data.question.id,questionType:e.data.question.type,insight:s}})}else if(e.data.question.type===w.QuestionType.TWEET&&e.data.question.notification!==void 0){const n=e.data.question.options?.options.value,i={title:e.data.question.notification?.title,body:e.data.question.notification?.body,image:e.data.question.notification?.image,account:n?.tweetMeta?.account||"",accountVerified:!!n?.tweetMeta?.accountVerified,tweet:n?.tweetMeta?.tweet,tweetId:e.data.question.id};this.notifications.add({type:be.QUESTION,action:()=>this.openQuestion(e.data?.question?.id,e.data?.feedItem),close:()=>this.closeQuestion(e.data?.question?.id),autoHideDuration:1e3*120,emitEvent:!0,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionId:e.data.question.id,questionType:e.data.question.type,tweet:i}})}}}}const Fo={[V.SdkOverlayType.GAMES]:!0};class Do extends bn{constructor(e,r){super(e,r)}}const Ro=(t,e,r)=>t.type===V.SdkOverlayType.GAMES?new No(t,e,r):new Do(t,e),Vo=(t,e,r)=>{t.features=new Map,t.sdk.featuresList=new Y(j(new Set),"features-list"),t.activeFeature=new Y(j(V.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=n=>t.features.get(n),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=n=>{t.activeFeature.setValue(n)},t.sdk.closeFeature=(n=!1)=>{const i=t.activeFeature.getValue();if(t.activeFeature.setValue(V.SdkOverlayType.UNSET),n&&i){t.features.delete(i);const o=t.sdk.featuresList.getValue();o&&o.delete(i),t.sdk.featuresList.setValue(o)}},t.initFeature=(n,i=fe.ORGANIZATION)=>{if(n.type in Fo&&!t.features.has(n.type)){const o=Ro(n,i,t);t.features.set(n.type,o);let s=t.sdk.featuresList.getValue();s?s.add(n.type):s=new Set([n.type]),t.sdk.featuresList.setValue(new Set(s))}},t.updateFeature=(n,i)=>{t.features.get(n.type)?.update(n,i)},t.destroyFeature=n=>{t.features.delete(n.type);const i=t.sdk.featuresList.getValue();i&&i.delete(n.type),t.sdk.featuresList.setValue(new Set(i))},t.reinitializeFeatures=async()=>{const n=await t.stores.organizationSettings.getValue();t.features.clear(),t.sdk.featuresList.setValue(new Set);for(const i of n?.overlays||[])t.initFeature(i,fe.ORGANIZATION)},t.stores.providerStreamId.listen(n=>{n||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const n=(o,s)=>{if(s?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&o===fe.ORGANIZATION))for(const a of s.overlays)a.sdkEnable===!0&&(t.features.has(a.type)?t.updateFeature(a,o):t.initFeature(a,o))},i={organizationSettings:o=>{if(o.data)try{n(fe.ORGANIZATION,o.data)}catch(s){console.log(s)}},streamSettings:o=>{if(o.data)try{n(fe.STREAM,o.data)}catch(s){console.log(s)}}};t.store.subscribe(i)},r()};class $o{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="invitation")switch(n.slEventBus.action){case"sent":this.sent(n.slEventBus.payload);break}};return U.listen(r)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_ACCEPTED},category:ot.InvitationCategory.GAMES,from:ot.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_SENT},category:ot.InvitationCategory.GAMES,from:e||ot.InvitationFrom.UNSET})}}class qo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="interactions")switch(n.slEventBus.action){case"tap":this.tap();break;case"scroll":this.scroll();break}};return U.listen(r)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:Nr.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:Nr.InteractionActionType.SCROLL})}}const Bo={[w.PromotionType.UNSET]:v.TopicSubType.UNSET,[w.PromotionType.INGAME_IAB21]:v.TopicSubType.PROMOTION_INGAME_IAB21,[w.PromotionType.INGAME_IAB11_LBAR]:v.TopicSubType.PROMOTION_INGAME_IAB11_LBAR,[w.PromotionType.INGAME_IAB11]:v.TopicSubType.PROMOTION_INGAME_IAB11,[w.PromotionType.INGAME_IAB21_LBAR]:v.TopicSubType.PROMOTION_INGAME_IAB21_LBAR,[w.PromotionType.INGAME_IAB61]:v.TopicSubType.PROMOTION_INGAME_IAB61,[w.PromotionType.EXTERNAL_AD]:v.TopicSubType.PROMOTION_GAM},nr=t=>t?Bo[t]:v.TopicSubType.UNSET;class Mo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(!n.slEventBus?.skipAnalytics&&n.slEventBus?.type==="advertisement"){const i=nr(n.slEventBus.payload.type);switch(n.slEventBus.action){case"videoPlay":this.videoPlay(n.slEventBus.payload,{topicSubType:i});break;case"buttonSelect":this.buttonSelect(n.slEventBus.payload,{topicSubType:i});break;case"bannerSelect":this.bannerSelect(n.slEventBus.payload,{topicSubType:i});break;case"received":this.received(n.slEventBus.payload,{topicSubType:i});break;case"opened":this.opened(n.slEventBus.payload,{topicSubType:i});break;case"viewed":this.viewed(n.slEventBus.payload,{topicSubType:i});break}}};return U.listen(r)})}received=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_RECEIVED,topicId:e,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})};opened=({id:e,openedFrom:r},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_OPENED,topicId:e,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:r==="notification"?v.PollOpenedFrom.IN_APP:v.PollOpenedFrom.UNSET})};viewed=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_OPENED,topicId:e,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})};videoPlay=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:v.Kind.AD_VIDEO_PLAYED,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})};buttonSelect=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:v.Kind.AD_BUTTON_NAVIGATED,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})};bannerSelect=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:v.Kind.AD_BANNER_NAVIGATED,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})}}const We={[w.QuestionType.UNSET]:v.TopicType.UNSET,[w.QuestionType.FACTOID]:v.TopicType.POLLS_INSIGHT,[w.QuestionType.POLL]:v.TopicType.POLLS_POLL,[w.QuestionType.PREDICTION]:v.TopicType.POLLS_PREDICTION,[w.QuestionType.PROMOTION]:v.TopicType.POLLS_PROMOTION,[w.QuestionType.TRIVIA]:v.TopicType.POLLS_TRIVIA,[w.QuestionType.TWEET]:v.TopicType.POLLS_TWITTER};w.QuestionType.UNSET+"",ee.NotificationKind.UNSET,w.QuestionType.FACTOID+"",ee.NotificationKind.POLLS,w.QuestionType.POLL+"",ee.NotificationKind.POLLS,w.QuestionType.PREDICTION+"",ee.NotificationKind.POLLS,w.QuestionType.PROMOTION+"",ee.NotificationKind.POLLS,w.QuestionType.TRIVIA+"",ee.NotificationKind.POLLS,w.QuestionType.TWEET+"",ee.NotificationKind.POLLS;const Uo={[V.SdkOverlayType.UNSET]:v.Category.UNSET,[V.SdkOverlayType.INPLAY]:v.Category.INPLAY,[V.SdkOverlayType.MESSAGING]:v.Category.MESSAGING,[V.SdkOverlayType.STATISTICS]:v.Category.STATS,[V.SdkOverlayType.BETTING]:v.Category.BETTING,[V.SdkOverlayType.TWITTER]:v.Category.TWITTER,[V.SdkOverlayType.MERCHANDISE]:v.Category.MERCHANDISE,[V.SdkOverlayType.CONTESTS]:v.Category.CONTESTS,[V.SdkOverlayType.VOICE_CHAT]:v.Category.CALLING,[V.SdkOverlayType.TICKETS]:v.Category.TICKETS,[V.SdkOverlayType.WHOIS_WATCHING]:v.Category.WHOISWATCHING,[V.SdkOverlayType.PROFILE]:v.Category.PROFILE,[V.SdkOverlayType.GAMES]:v.Category.POLLS,[V.SdkOverlayType.GOLF_STATISTICS]:v.Category.STATS,[V.SdkOverlayType.HIGHLIGHTS]:v.Category.HIGHLIGHTS,[V.SdkOverlayType.PUBLIC_CHAT]:v.Category.PUBLIC_CHAT};class jo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="notification")switch(n.slEventBus.action){case"rendered":this.received(n.slEventBus.payload);break;case"opened":this.opened(n.slEventBus.payload);break}if(n.slEventBus?.type==="advertisement")switch(n.slEventBus.action){case"notification-received":this.received({questionId:n.slEventBus.payload.id,questionType:w.QuestionType.PROMOTION,topicSubType:nr(n.slEventBus.payload.type)});break;case"notification-opened":this.opened({questionId:n.slEventBus.payload.id,questionType:w.QuestionType.PROMOTION,topicSubType:nr(n.slEventBus.payload.type)});break}};return U.listen(r)})}received=({questionId:e,questionType:r,topicSubType:n})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:r?We[r]:v.TopicType.UNSET,topicSubType:n},notificationKind:ee.NotificationKind.POLLS,notificationType:ee.NotificationType.IN_APP})};opened=({questionId:e,questionType:r,topicSubType:n})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_OPENED,topicId:e,topicType:r?We[r]:v.TopicType.UNSET,topicSubType:n},notificationKind:ee.NotificationKind.POLLS,notificationType:ee.NotificationType.IN_APP})}}class Qo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="poll")switch(n.slEventBus.action){case"voted":this.voted(n.slEventBus.payload);break;case"navigated":this.navigated();break;case"onboardingPassed":this.onboardingPassed();break;case"received":this.received(n.slEventBus.payload);break;case"opened":this.opened(n.slEventBus.payload);break}};return U.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_RECEIVED,topicId:e,topicType:r?We[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};opened=({questionId:e,questionType:r,questionOpenedFrom:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_OPENED,topicId:e,topicType:r?We[r]:v.TopicType.UNSET},pollOpenedFrom:n==="list"?v.PollOpenedFrom.PICK_HISTORY:v.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_VOTE,topicId:e,topicType:r?We[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.GAMES_JOINED},pollOpenedFrom:v.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_NAVIGATED},pollOpenedFrom:v.PollOpenedFrom.UNSET})}}const xo=({transport:t,$commonStore:e})=>{let r;const n=j(!1),i=5e3,{client:o,queryKey:s}=t.createPromiseClient(pn.AnalyticsService,{method:"send",params:[n]}),a=t.nanoquery.createFetcherStore(s,{fetcher:async()=>{const p=e.getStore().get();try{await o.unary({message:{case:"heartbeat",value:{common:{...p,kind:v.Kind.SESSION_HEARTBEAT}}}})}catch(S){he.error(S,"send heartbeat failed")}return Date.now()},refetchInterval:i}),u=()=>{he.debug("mounted heartbeat"),r=a.subscribe(()=>{})},l=()=>{he.debug("enabled heartbeat"),n.set(!0),a.lc===0&&u()},c=()=>{he.debug("disabled heartbeat"),n.set(!1)};return{enable:l,disable:c,mount:u,unmount:()=>{he.debug("unmounted heartbeat"),a.off(),r?.(),r=void 0,c()}}},he=ue("analytics");class Go{commonStore;notifications;polls;invitation;interactions;advertisement;heartbeat;analyticsClient;listeners;listenersCancels;connected=!1;constructor(e){this.listeners=new Set,this.listenersCancels=new Set,this.commonStore=new Ae(H({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=xo({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new jo(this),this.polls=new Qo(this),this.invitation=new $o(this),this.interactions=new qo(this),this.advertisement=new Mo(this);const{client:r}=e.analyticsTransport.createPromiseClient(pn.AnalyticsService,{method:"send"});this.analyticsClient=r}connect=()=>{this.writeCommon("sessionId",Xt.nanoid()),this.heartbeat.enable(),this.listeners.forEach(e=>this.listenersCancels.add(e())),this.connected=!0,he.debug("analytics connected")};disconnect=()=>{this.writeCommon("sessionId",""),this.writeCommon("overlaySessionId",""),this.heartbeat.unmount(),this.listenersCancels.forEach(e=>e()),this.connected=!1,he.debug("analytics disconnected")};write=(e,r)=>{r&&this.analyticsClient.unary({message:{case:e,value:r}}).then(()=>{he.trace("send analytics success",e,r)}).catch(n=>{he.error(n,"send analytics failed")})};writeCommon=(e,r)=>{this.commonStore.setValue(e,r)};onConnect=e=>{this.listeners.add(e),this.connected&&this.listenersCancels.add(e())};connectToSDK=e=>{this.onConnect(()=>e.stores.slStreamId.getAtomStore().subscribe(r=>{this.writeCommon("eventId",r)})),this.onConnect(()=>e.sdk.getActiveFeature().subscribe(r=>{r&&this.writeCommon("category",Uo[r]),r!==V.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",Xt.nanoid()):this.writeCommon("overlaySessionId","")})),this.onConnect(()=>{const r=window.matchMedia("(orientation: portrait)"),n=i=>{this.writeCommon("screenOrientation",i.matches?v.ScreenOrientation.PORTRAIT:v.ScreenOrientation.LANDSCAPE)};return r.addEventListener("change",n),()=>{r.removeEventListener("change",n)}}),this.onConnect(()=>e.deepLink.$store.subscribe(r=>{r?.handled&&this.invitation.accepted()}))}}const Ko=(t,e,r)=>{t.analytics=new Go(t),t.sdk.onMount({name:"analytics"},()=>(t.analytics.connect(),()=>{t.analytics.disconnect()})),r()};var yr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mr={exports:{}},gr={exports:{}};function Ho(t){var e=new t,r=e;function n(){var o=e;return o.next?e=o.next:(e=new t,r=e),o.next=null,o}function i(o){r.next=o,r=o}return{get:n,release:i}}var Wo=Ho,Yo=Wo;function On(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),!(r>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");var n=Yo(Jo),i=null,o=null,s=0,a=null,u={push:b,drain:W,saturated:W,pause:c,paused:!1,get concurrency(){return r},set concurrency(N){if(!(N>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");if(r=N,!u.paused)for(;i&&s<r;)s++,T()},running:l,resume:S,idle:A,length:f,getQueue:p,unshift:g,empty:W,kill:D,killAndDrain:K,error:X};return u;function l(){return s}function c(){u.paused=!0}function f(){for(var N=i,$=0;N;)N=N.next,$++;return $}function p(){for(var N=i,$=[];N;)$.push(N.value),N=N.next;return $}function S(){if(u.paused){if(u.paused=!1,i===null){s++,T();return}for(;i&&s<r;)s++,T()}}function A(){return s===0&&u.length()===0}function b(N,$){var C=n.get();C.context=t,C.release=T,C.value=N,C.callback=$||W,C.errorHandler=a,s>=r||u.paused?o?(o.next=C,o=C):(i=C,o=C,u.saturated()):(s++,e.call(t,C.value,C.worked))}function g(N,$){var C=n.get();C.context=t,C.release=T,C.value=N,C.callback=$||W,C.errorHandler=a,s>=r||u.paused?i?(C.next=i,i=C):(i=C,o=C,u.saturated()):(s++,e.call(t,C.value,C.worked))}function T(N){N&&n.release(N);var $=i;$&&s<=r?u.paused?s--:(o===i&&(o=null),i=$.next,$.next=null,e.call(t,$.value,$.worked),o===null&&u.empty()):--s===0&&u.drain()}function D(){i=null,o=null,u.drain=W}function K(){i=null,o=null,u.drain(),u.drain=W}function X(N){a=N}}function W(){}function Jo(){this.value=null,this.callback=W,this.next=null,this.release=W,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,n){var i=t.callback,o=t.errorHandler,s=t.value;t.value=null,t.callback=W,t.errorHandler&&o(r,s),i.call(t.context,r,n),t.release(t)}}function Xo(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function n(c,f){e.call(this,c).then(function(p){f(null,p)},f)}var i=On(t,n,r),o=i.push,s=i.unshift;return i.push=a,i.unshift=u,i.drained=l,i;function a(c){var f=new Promise(function(p,S){o(c,function(A,b){if(A){S(A);return}p(b)})});return f.catch(W),f}function u(c){var f=new Promise(function(p,S){s(c,function(A,b){if(A){S(A);return}p(b)})});return f.catch(W),f}function l(){if(i.idle())return new Promise(function(p){p()});var c=i.drain,f=new Promise(function(p){i.drain=function(){c(),p()}});return f}}gr.exports=On;gr.exports.promise=Xo;var _n=gr.exports,br={exports:{}},Me=typeof Reflect=="object"?Reflect:null,Ur=Me&&typeof Me.apply=="function"?Me.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},lt;Me&&typeof Me.ownKeys=="function"?lt=Me.ownKeys:Object.getOwnPropertySymbols?lt=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:lt=function(e){return Object.getOwnPropertyNames(e)};function Zo(t){console&&console.warn&&console.warn(t)}var Cn=Number.isNaN||function(e){return e!==e};function F(){F.init.call(this)}br.exports=F;br.exports.once=ns;F.EventEmitter=F;F.prototype._events=void 0;F.prototype._eventsCount=0;F.prototype._maxListeners=void 0;var jr=10;function _t(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(F,"defaultMaxListeners",{enumerable:!0,get:function(){return jr},set:function(t){if(typeof t!="number"||t<0||Cn(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");jr=t}});F.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};F.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Cn(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function kn(t){return t._maxListeners===void 0?F.defaultMaxListeners:t._maxListeners}F.prototype.getMaxListeners=function(){return kn(this)};F.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")Ur(u,this,r);else for(var l=u.length,c=Dn(u,l),n=0;n<l;++n)Ur(c[n],this,r);return!0};function Ln(t,e,r,n){var i,o,s;if(_t(r),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),s===void 0)s=o[e]=r,++t._eventsCount;else if(typeof s=="function"?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=kn(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,Zo(a)}return t}F.prototype.addListener=function(e,r){return Ln(this,e,r,!1)};F.prototype.on=F.prototype.addListener;F.prototype.prependListener=function(e,r){return Ln(this,e,r,!0)};function es(){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 Pn(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=es.bind(n);return i.listener=r,n.wrapFn=i,i}F.prototype.once=function(e,r){return _t(r),this.on(e,Pn(this,e,r)),this};F.prototype.prependOnceListener=function(e,r){return _t(r),this.prependListener(e,Pn(this,e,r)),this};F.prototype.removeListener=function(e,r){var n,i,o,s,a;if(_t(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():ts(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};F.prototype.off=F.prototype.removeListener;F.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Nn(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?rs(i):Dn(i,i.length)}F.prototype.listeners=function(e){return Nn(this,e,!0)};F.prototype.rawListeners=function(e){return Nn(this,e,!1)};F.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Fn.call(t,e)};F.prototype.listenerCount=Fn;function Fn(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}F.prototype.eventNames=function(){return this._eventsCount>0?lt(this._events):[]};function Dn(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function ts(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function rs(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function ns(t,e){return new Promise(function(r,n){function i(s){t.removeListener(e,o),n(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Rn(t,e,o,{once:!0}),e!=="error"&&is(t,i,{once:!0})})}function is(t,e,r){typeof t.on=="function"&&Rn(t,"error",e,r)}function Rn(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Vn=br.exports,Ct={},$n={},qn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(e,r);if(s.value!==i||s.enumerable!==!0)return!1}return!0},os=qn,kt=function(){return os()&&!!Symbol.toStringTag},ss=Error,as=EvalError,us=RangeError,cs=ReferenceError,Bn=SyntaxError,Lt=TypeError,ls=URIError,Qr=typeof Symbol<"u"&&Symbol,ds=qn,fs=function(){return typeof Qr!="function"||typeof Symbol!="function"||typeof Qr("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ds()},Rt={__proto__:null,foo:{}},ps=Object,hs=function(){return{__proto__:Rt}.foo===Rt.foo&&!(Rt instanceof ps)},ys="Function.prototype.bind called on incompatible ",ms=Object.prototype.toString,gs=Math.max,bs="[object Function]",xr=function(e,r){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var o=0;o<r.length;o+=1)n[o+e.length]=r[o];return n},vs=function(e,r){for(var n=[],i=r,o=0;i<e.length;i+=1,o+=1)n[o]=e[i];return n},Ss=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r},ws=function(e){var r=this;if(typeof r!="function"||ms.apply(r)!==bs)throw new TypeError(ys+r);for(var n=vs(arguments,1),i,o=function(){if(this instanceof i){var c=r.apply(this,xr(n,arguments));return Object(c)===c?c:this}return r.apply(e,xr(n,arguments))},s=gs(0,r.length-n.length),a=[],u=0;u<s;u++)a[u]="$"+u;if(i=Function("binder","return function ("+Ss(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i},Ts=ws,vr=Function.prototype.bind||Ts,As=Function.prototype.call,Es=Object.prototype.hasOwnProperty,Is=vr,Os=Is.call(As,Es),_,_s=ss,Cs=as,ks=us,Ls=cs,je=Bn,Ue=Lt,Ps=ls,Mn=Function,Vt=function(t){try{return Mn('"use strict"; return ('+t+").constructor;")()}catch{}},Ie=Object.getOwnPropertyDescriptor;if(Ie)try{Ie({},"")}catch{Ie=null}var $t=function(){throw new Ue},Ns=Ie?function(){try{return arguments.callee,$t}catch{try{return Ie(arguments,"callee").get}catch{return $t}}}():$t,Fe=fs(),Fs=hs(),Q=Object.getPrototypeOf||(Fs?function(t){return t.__proto__}:null),Re={},Ds=typeof Uint8Array>"u"||!Q?_:Q(Uint8Array),Oe={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?_:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?_:ArrayBuffer,"%ArrayIteratorPrototype%":Fe&&Q?Q([][Symbol.iterator]()):_,"%AsyncFromSyncIteratorPrototype%":_,"%AsyncFunction%":Re,"%AsyncGenerator%":Re,"%AsyncGeneratorFunction%":Re,"%AsyncIteratorPrototype%":Re,"%Atomics%":typeof Atomics>"u"?_:Atomics,"%BigInt%":typeof BigInt>"u"?_:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?_:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?_:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?_:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":_s,"%eval%":eval,"%EvalError%":Cs,"%Float32Array%":typeof Float32Array>"u"?_:Float32Array,"%Float64Array%":typeof Float64Array>"u"?_:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?_:FinalizationRegistry,"%Function%":Mn,"%GeneratorFunction%":Re,"%Int8Array%":typeof Int8Array>"u"?_:Int8Array,"%Int16Array%":typeof Int16Array>"u"?_:Int16Array,"%Int32Array%":typeof Int32Array>"u"?_:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Fe&&Q?Q(Q([][Symbol.iterator]())):_,"%JSON%":typeof JSON=="object"?JSON:_,"%Map%":typeof Map>"u"?_:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Fe||!Q?_:Q(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?_:Promise,"%Proxy%":typeof Proxy>"u"?_:Proxy,"%RangeError%":ks,"%ReferenceError%":Ls,"%Reflect%":typeof Reflect>"u"?_:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?_:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Fe||!Q?_:Q(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?_:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Fe&&Q?Q(""[Symbol.iterator]()):_,"%Symbol%":Fe?Symbol:_,"%SyntaxError%":je,"%ThrowTypeError%":Ns,"%TypedArray%":Ds,"%TypeError%":Ue,"%Uint8Array%":typeof Uint8Array>"u"?_:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?_:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?_:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?_:Uint32Array,"%URIError%":Ps,"%WeakMap%":typeof WeakMap>"u"?_:WeakMap,"%WeakRef%":typeof WeakRef>"u"?_:WeakRef,"%WeakSet%":typeof WeakSet>"u"?_:WeakSet};if(Q)try{null.error}catch(t){var Rs=Q(Q(t));Oe["%Error.prototype%"]=Rs}var Vs=function t(e){var r;if(e==="%AsyncFunction%")r=Vt("async function () {}");else if(e==="%GeneratorFunction%")r=Vt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Vt("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&Q&&(r=Q(i.prototype))}return Oe[e]=r,r},Gr={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Ze=vr,bt=Os,$s=Ze.call(Function.call,Array.prototype.concat),qs=Ze.call(Function.apply,Array.prototype.splice),Kr=Ze.call(Function.call,String.prototype.replace),vt=Ze.call(Function.call,String.prototype.slice),Bs=Ze.call(Function.call,RegExp.prototype.exec),Ms=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Us=/\\(\\)?/g,js=function(e){var r=vt(e,0,1),n=vt(e,-1);if(r==="%"&&n!=="%")throw new je("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new je("invalid intrinsic syntax, expected opening `%`");var i=[];return Kr(e,Ms,function(o,s,a,u){i[i.length]=a?Kr(u,Us,"$1"):s||o}),i},Qs=function(e,r){var n=e,i;if(bt(Gr,n)&&(i=Gr[n],n="%"+i[0]+"%"),bt(Oe,n)){var o=Oe[n];if(o===Re&&(o=Vs(n)),typeof o>"u"&&!r)throw new Ue("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new je("intrinsic "+e+" does not exist!")},et=function(e,r){if(typeof e!="string"||e.length===0)throw new Ue("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Ue('"allowMissing" argument must be a boolean');if(Bs(/^%?[^%]*%?$/,e)===null)throw new je("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=js(e),i=n.length>0?n[0]:"",o=Qs("%"+i+"%",r),s=o.name,a=o.value,u=!1,l=o.alias;l&&(i=l[0],qs(n,$s([0,1],l)));for(var c=1,f=!0;c<n.length;c+=1){var p=n[c],S=vt(p,0,1),A=vt(p,-1);if((S==='"'||S==="'"||S==="`"||A==='"'||A==="'"||A==="`")&&S!==A)throw new je("property names with quotes must have matching quotes");if((p==="constructor"||!f)&&(u=!0),i+="."+p,s="%"+i+"%",bt(Oe,s))a=Oe[s];else if(a!=null){if(!(p in a)){if(!r)throw new Ue("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ie&&c+1>=n.length){var b=Ie(a,p);f=!!b,f&&"get"in b&&!("originalValue"in b.get)?a=b.get:a=a[p]}else f=bt(a,p),a=a[p];f&&!u&&(Oe[s]=a)}}return a},Un={exports:{}},qt,zr;function Sr(){if(zr)return qt;zr=1;var t=et,e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return qt=e,qt}var xs=et,dt=xs("%Object.getOwnPropertyDescriptor%",!0);if(dt)try{dt([],"length")}catch{dt=null}var Pt=dt,Hr=Sr(),Gs=Bn,De=Lt,Wr=Pt,Ks=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new De("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new De("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new De("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new De("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new De("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new De("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,u=!!Wr&&Wr(e,r);if(Hr)Hr(e,r,{configurable:s===null&&u?u.configurable:!s,enumerable:i===null&&u?u.enumerable:!i,value:n,writable:o===null&&u?u.writable:!o});else if(a||!i&&!o&&!s)e[r]=n;else throw new Gs("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ir=Sr(),jn=function(){return!!ir};jn.hasArrayLengthDefineBug=function(){if(!ir)return null;try{return ir([],"length",{value:1}).length!==1}catch{return!0}};var zs=jn,Hs=et,Yr=Ks,Ws=zs(),Jr=Pt,Xr=Lt,Ys=Hs("%Math.floor%"),Js=function(e,r){if(typeof e!="function")throw new Xr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Ys(r)!==r)throw new Xr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in e&&Jr){var s=Jr(e,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(Ws?Yr(e,"length",r,!0,!0):Yr(e,"length",r)),e};(function(t){var e=vr,r=et,n=Js,i=Lt,o=r("%Function.prototype.apply%"),s=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(s,o),u=Sr(),l=r("%Math.max%");t.exports=function(p){if(typeof p!="function")throw new i("a function is required");var S=a(e,s,arguments);return n(S,1+l(0,p.length-(arguments.length-1)),!0)};var c=function(){return a(e,o,arguments)};u?u(t.exports,"apply",{value:c}):t.exports.apply=c})(Un);var wr=Un.exports,Qn=et,xn=wr,Xs=xn(Qn("String.prototype.indexOf")),Tr=function(e,r){var n=Qn(e,!!r);return typeof n=="function"&&Xs(e,".prototype.")>-1?xn(n):n},Zs=kt(),ea=Tr,or=ea("Object.prototype.toString"),Nt=function(e){return Zs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:or(e)==="[object Arguments]"},Gn=function(e){return Nt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&or(e)!=="[object Array]"&&or(e.callee)==="[object Function]"},ta=function(){return Nt(arguments)}();Nt.isLegacyArguments=Gn;var ra=ta?Nt:Gn,na=Object.prototype.toString,ia=Function.prototype.toString,oa=/^\s*(?:function)?\*/,Kn=kt(),Bt=Object.getPrototypeOf,sa=function(){if(!Kn)return!1;try{return Function("return function*() {}")()}catch{}},Mt,aa=function(e){if(typeof e!="function")return!1;if(oa.test(ia.call(e)))return!0;if(!Kn){var r=na.call(e);return r==="[object GeneratorFunction]"}if(!Bt)return!1;if(typeof Mt>"u"){var n=sa();Mt=n?Bt(n):!1}return Bt(e)===Mt},zn=Function.prototype.toString,qe=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,sr,ft;if(typeof qe=="function"&&typeof Object.defineProperty=="function")try{sr=Object.defineProperty({},"length",{get:function(){throw ft}}),ft={},qe(function(){throw 42},null,sr)}catch(t){t!==ft&&(qe=null)}else qe=null;var ua=/^\s*class\b/,ar=function(e){try{var r=zn.call(e);return ua.test(r)}catch{return!1}},Ut=function(e){try{return ar(e)?!1:(zn.call(e),!0)}catch{return!1}},pt=Object.prototype.toString,ca="[object Object]",la="[object Function]",da="[object GeneratorFunction]",fa="[object HTMLAllCollection]",pa="[object HTML document.all class]",ha="[object HTMLCollection]",ya=typeof Symbol=="function"&&!!Symbol.toStringTag,ma=!(0 in[,]),ur=function(){return!1};if(typeof document=="object"){var ga=document.all;pt.call(ga)===pt.call(document.all)&&(ur=function(e){if((ma||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=pt.call(e);return(r===fa||r===pa||r===ha||r===ca)&&e("")==null}catch{}return!1})}var ba=qe?function(e){if(ur(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{qe(e,null,sr)}catch(r){if(r!==ft)return!1}return!ar(e)&&Ut(e)}:function(e){if(ur(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(ya)return Ut(e);if(ar(e))return!1;var r=pt.call(e);return r!==la&&r!==da&&!/^\[object HTML/.test(r)?!1:Ut(e)},va=ba,Sa=Object.prototype.toString,Hn=Object.prototype.hasOwnProperty,wa=function(e,r,n){for(var i=0,o=e.length;i<o;i++)Hn.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Ta=function(e,r,n){for(var i=0,o=e.length;i<o;i++)n==null?r(e.charAt(i),i,e):r.call(n,e.charAt(i),i,e)},Aa=function(e,r,n){for(var i in e)Hn.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Ea=function(e,r,n){if(!va(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),Sa.call(e)==="[object Array]"?wa(e,r,i):typeof e=="string"?Ta(e,r,i):Aa(e,r,i)},Wn=Ea,Ia=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],jt=Ia,Oa=typeof globalThis>"u"?yr:globalThis,Yn=function(){for(var e=[],r=0;r<jt.length;r++)typeof Oa[jt[r]]=="function"&&(e[e.length]=jt[r]);return e},St=Wn,_a=Yn,Zr=wr,Ar=Tr,ht=Pt,Ca=Ar("Object.prototype.toString"),Jn=kt(),en=typeof globalThis>"u"?yr:globalThis,cr=_a(),Er=Ar("String.prototype.slice"),Qt=Object.getPrototypeOf,ka=Ar("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},wt={__proto__:null};Jn&&ht&&Qt?St(cr,function(t){var e=new en[t];if(Symbol.toStringTag in e){var r=Qt(e),n=ht(r,Symbol.toStringTag);if(!n){var i=Qt(r);n=ht(i,Symbol.toStringTag)}wt["$"+t]=Zr(n.get)}}):St(cr,function(t){var e=new en[t],r=e.slice||e.set;r&&(wt["$"+t]=Zr(r))});var La=function(e){var r=!1;return St(wt,function(n,i){if(!r)try{"$"+n(e)===i&&(r=Er(i,1))}catch{}}),r},Pa=function(e){var r=!1;return St(wt,function(n,i){if(!r)try{n(e),r=Er(i,1)}catch{}}),r},Na=function(e){if(!e||typeof e!="object")return!1;if(!Jn){var r=Er(Ca(e),8,-1);return ka(cr,r)>-1?r:r!=="Object"?!1:Pa(e)}return ht?La(e):null},Tt=Wn,Fa=Yn,tn=wr,Ir=Tr,yt=Pt,Da=Ir("Object.prototype.toString"),Xn=kt(),rn=typeof globalThis>"u"?yr:globalThis,lr=Fa(),Or=Ir("String.prototype.slice"),xt=Object.getPrototypeOf,Ra=Ir("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},At={__proto__:null};Xn&&yt&&xt?Tt(lr,function(t){var e=new rn[t];if(Symbol.toStringTag in e){var r=xt(e),n=yt(r,Symbol.toStringTag);if(!n){var i=xt(r);n=yt(i,Symbol.toStringTag)}At["$"+t]=tn(n.get)}}):Tt(lr,function(t){var e=new rn[t],r=e.slice||e.set;r&&(At["$"+t]=tn(r))});var Va=function(e){var r=!1;return Tt(At,function(n,i){if(!r)try{"$"+n(e)===i&&(r=Or(i,1))}catch{}}),r},$a=function(e){var r=!1;return Tt(At,function(n,i){if(!r)try{n(e),r=Or(i,1)}catch{}}),r},qa=function(e){if(!e||typeof e!="object")return!1;if(!Xn){var r=Or(Da(e),8,-1);return Ra(lr,r)>-1?r:r!=="Object"?!1:$a(e)}return yt?Va(e):null},Ba=qa,Ma=function(e){return!!Ba(e)};(function(t){var e=ra,r=aa,n=Na,i=Ma;function o(y){return y.call.bind(y)}var s=typeof BigInt<"u",a=typeof Symbol<"u",u=o(Object.prototype.toString),l=o(Number.prototype.valueOf),c=o(String.prototype.valueOf),f=o(Boolean.prototype.valueOf);if(s)var p=o(BigInt.prototype.valueOf);if(a)var S=o(Symbol.prototype.valueOf);function A(y,oi){if(typeof y!="object")return!1;try{return oi(y),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=i;function b(y){return typeof Promise<"u"&&y instanceof Promise||y!==null&&typeof y=="object"&&typeof y.then=="function"&&typeof y.catch=="function"}t.isPromise=b;function g(y){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(y):i(y)||h(y)}t.isArrayBufferView=g;function T(y){return n(y)==="Uint8Array"}t.isUint8Array=T;function D(y){return n(y)==="Uint8ClampedArray"}t.isUint8ClampedArray=D;function K(y){return n(y)==="Uint16Array"}t.isUint16Array=K;function X(y){return n(y)==="Uint32Array"}t.isUint32Array=X;function N(y){return n(y)==="Int8Array"}t.isInt8Array=N;function $(y){return n(y)==="Int16Array"}t.isInt16Array=$;function C(y){return n(y)==="Int32Array"}t.isInt32Array=C;function re(y){return n(y)==="Float32Array"}t.isFloat32Array=re;function ne(y){return n(y)==="Float64Array"}t.isFloat64Array=ne;function _e(y){return n(y)==="BigInt64Array"}t.isBigInt64Array=_e;function ve(y){return n(y)==="BigUint64Array"}t.isBigUint64Array=ve;function ce(y){return u(y)==="[object Map]"}ce.working=typeof Map<"u"&&ce(new Map);function Ft(y){return typeof Map>"u"?!1:ce.working?ce(y):y instanceof Map}t.isMap=Ft;function ge(y){return u(y)==="[object Set]"}ge.working=typeof Set<"u"&&ge(new Set);function Ke(y){return typeof Set>"u"?!1:ge.working?ge(y):y instanceof Set}t.isSet=Ke;function Ce(y){return u(y)==="[object WeakMap]"}Ce.working=typeof WeakMap<"u"&&Ce(new WeakMap);function Dt(y){return typeof WeakMap>"u"?!1:Ce.working?Ce(y):y instanceof WeakMap}t.isWeakMap=Dt;function ke(y){return u(y)==="[object WeakSet]"}ke.working=typeof WeakSet<"u"&&ke(new WeakSet);function le(y){return ke(y)}t.isWeakSet=le;function Le(y){return u(y)==="[object ArrayBuffer]"}Le.working=typeof ArrayBuffer<"u"&&Le(new ArrayBuffer);function tt(y){return typeof ArrayBuffer>"u"?!1:Le.working?Le(y):y instanceof ArrayBuffer}t.isArrayBuffer=tt;function d(y){return u(y)==="[object DataView]"}d.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&d(new DataView(new ArrayBuffer(1),0,1));function h(y){return typeof DataView>"u"?!1:d.working?d(y):y instanceof DataView}t.isDataView=h;var m=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function E(y){return u(y)==="[object SharedArrayBuffer]"}function L(y){return typeof m>"u"?!1:(typeof E.working>"u"&&(E.working=E(new m)),E.working?E(y):y instanceof m)}t.isSharedArrayBuffer=L;function P(y){return u(y)==="[object AsyncFunction]"}t.isAsyncFunction=P;function O(y){return u(y)==="[object Map Iterator]"}t.isMapIterator=O;function k(y){return u(y)==="[object Set Iterator]"}t.isSetIterator=k;function R(y){return u(y)==="[object Generator]"}t.isGeneratorObject=R;function z(y){return u(y)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=z;function Se(y){return A(y,l)}t.isNumberObject=Se;function rt(y){return A(y,c)}t.isStringObject=rt;function Pe(y){return A(y,f)}t.isBooleanObject=Pe;function nt(y){return s&&A(y,p)}t.isBigIntObject=nt;function kr(y){return a&&A(y,S)}t.isSymbolObject=kr;function ni(y){return Se(y)||rt(y)||Pe(y)||nt(y)||kr(y)}t.isBoxedPrimitive=ni;function ii(y){return typeof Uint8Array<"u"&&(tt(y)||L(y))}t.isAnyArrayBuffer=ii,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(y){Object.defineProperty(t,y,{enumerable:!1,value:function(){throw new Error(y+" is not supported in userland")}})})})($n);var Ua=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},dr={exports:{}};typeof Object.create=="function"?dr.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:dr.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}};var ja=dr.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(h){for(var m=Object.keys(h),E={},L=0;L<m.length;L++)E[m[L]]=Object.getOwnPropertyDescriptor(h,m[L]);return E},r=/%[sdj%]/g;t.format=function(d){if(!N(d)){for(var h=[],m=0;m<arguments.length;m++)h.push(s(arguments[m]));return h.join(" ")}for(var m=1,E=arguments,L=E.length,P=String(d).replace(r,function(k){if(k==="%%")return"%";if(m>=L)return k;switch(k){case"%s":return String(E[m++]);case"%d":return Number(E[m++]);case"%j":try{return JSON.stringify(E[m++])}catch{return"[Circular]"}default:return k}}),O=E[m];m<L;O=E[++m])D(O)||!ne(O)?P+=" "+O:P+=" "+s(O);return P},t.deprecate=function(d,h){if(typeof I<"u"&&I.noDeprecation===!0)return d;if(typeof I>"u")return function(){return t.deprecate(d,h).apply(this,arguments)};var m=!1;function E(){if(!m){if(I.throwDeprecation)throw new Error(h);I.traceDeprecation?console.trace(h):console.error(h),m=!0}return d.apply(this,arguments)}return E};var n={},i=/^$/;if(I.env.NODE_DEBUG){var o=I.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(d){if(d=d.toUpperCase(),!n[d])if(i.test(d)){var h=I.pid;n[d]=function(){var m=t.format.apply(t,arguments);console.error("%s %d: %s",d,h,m)}}else n[d]=function(){};return n[d]};function s(d,h){var m={seen:[],stylize:u};return arguments.length>=3&&(m.depth=arguments[2]),arguments.length>=4&&(m.colors=arguments[3]),T(h)?m.showHidden=h:h&&t._extend(m,h),C(m.showHidden)&&(m.showHidden=!1),C(m.depth)&&(m.depth=2),C(m.colors)&&(m.colors=!1),C(m.customInspect)&&(m.customInspect=!0),m.colors&&(m.stylize=a),c(m,d,m.depth)}t.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function a(d,h){var m=s.styles[h];return m?"\x1B["+s.colors[m][0]+"m"+d+"\x1B["+s.colors[m][1]+"m":d}function u(d,h){return d}function l(d){var h={};return d.forEach(function(m,E){h[m]=!0}),h}function c(d,h,m){if(d.customInspect&&h&&ce(h.inspect)&&h.inspect!==t.inspect&&!(h.constructor&&h.constructor.prototype===h)){var E=h.inspect(m,d);return N(E)||(E=c(d,E,m)),E}var L=f(d,h);if(L)return L;var P=Object.keys(h),O=l(P);if(d.showHidden&&(P=Object.getOwnPropertyNames(h)),ve(h)&&(P.indexOf("message")>=0||P.indexOf("description")>=0))return p(h);if(P.length===0){if(ce(h)){var k=h.name?": "+h.name:"";return d.stylize("[Function"+k+"]","special")}if(re(h))return d.stylize(RegExp.prototype.toString.call(h),"regexp");if(_e(h))return d.stylize(Date.prototype.toString.call(h),"date");if(ve(h))return p(h)}var R="",z=!1,Se=["{","}"];if(g(h)&&(z=!0,Se=["[","]"]),ce(h)){var rt=h.name?": "+h.name:"";R=" [Function"+rt+"]"}if(re(h)&&(R=" "+RegExp.prototype.toString.call(h)),_e(h)&&(R=" "+Date.prototype.toUTCString.call(h)),ve(h)&&(R=" "+p(h)),P.length===0&&(!z||h.length==0))return Se[0]+R+Se[1];if(m<0)return re(h)?d.stylize(RegExp.prototype.toString.call(h),"regexp"):d.stylize("[Object]","special");d.seen.push(h);var Pe;return z?Pe=S(d,h,m,O,P):Pe=P.map(function(nt){return A(d,h,m,O,nt,z)}),d.seen.pop(),b(Pe,R,Se)}function f(d,h){if(C(h))return d.stylize("undefined","undefined");if(N(h)){var m="'"+JSON.stringify(h).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return d.stylize(m,"string")}if(X(h))return d.stylize(""+h,"number");if(T(h))return d.stylize(""+h,"boolean");if(D(h))return d.stylize("null","null")}function p(d){return"["+Error.prototype.toString.call(d)+"]"}function S(d,h,m,E,L){for(var P=[],O=0,k=h.length;O<k;++O)ke(h,String(O))?P.push(A(d,h,m,E,String(O),!0)):P.push("");return L.forEach(function(R){R.match(/^\d+$/)||P.push(A(d,h,m,E,R,!0))}),P}function A(d,h,m,E,L,P){var O,k,R;if(R=Object.getOwnPropertyDescriptor(h,L)||{value:h[L]},R.get?R.set?k=d.stylize("[Getter/Setter]","special"):k=d.stylize("[Getter]","special"):R.set&&(k=d.stylize("[Setter]","special")),ke(E,L)||(O="["+L+"]"),k||(d.seen.indexOf(R.value)<0?(D(m)?k=c(d,R.value,null):k=c(d,R.value,m-1),k.indexOf(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const si=require("pino"),w=require("@streamlayer/sl-eslib/interactive/interactive.common_pb"),it=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb"),V=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),ot=require("@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb"),te=require("nanostores"),Xt=require("nanoid"),q=require("@connectrpc/connect"),Lr=require("@connectrpc/connect-web"),Pr=require("@nanostores/query"),dn=require("@streamlayer/sl-eslib/sports/events/events_connect"),Xe=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),hr=require("@streamlayer/sl-eslib/users/users_connect"),J=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),fn=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect");require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb");const ai=require("@streamlayer/sl-eslib/shortLinks/linksClient_connect"),v=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),pn=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_connect"),Nr=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),ee=require("@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb");function ui(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var hn={exports:{}},B=hn.exports={},ie,oe;function Zt(){throw new Error("setTimeout has not been defined")}function er(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?ie=setTimeout:ie=Zt}catch{ie=Zt}try{typeof clearTimeout=="function"?oe=clearTimeout:oe=er}catch{oe=er}})();function yn(t){if(ie===setTimeout)return setTimeout(t,0);if((ie===Zt||!ie)&&setTimeout)return ie=setTimeout,setTimeout(t,0);try{return ie(t,0)}catch{try{return ie.call(null,t,0)}catch{return ie.call(this,t,0)}}}function ci(t){if(oe===clearTimeout)return clearTimeout(t);if((oe===er||!oe)&&clearTimeout)return oe=clearTimeout,clearTimeout(t);try{return oe(t)}catch{try{return oe.call(null,t)}catch{return oe.call(this,t)}}}var ye=[],Be=!1,Te,ct=-1;function li(){!Be||!Te||(Be=!1,Te.length?ye=Te.concat(ye):ct=-1,ye.length&&mn())}function mn(){if(!Be){var t=yn(li);Be=!0;for(var e=ye.length;e;){for(Te=ye,ye=[];++ct<e;)Te&&Te[ct].run();ct=-1,e=ye.length}Te=null,Be=!1,ci(t)}}B.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];ye.push(new gn(t,e)),ye.length===1&&!Be&&yn(mn)};function gn(t,e){this.fun=t,this.array=e}gn.prototype.run=function(){this.fun.apply(null,this.array)};B.title="browser";B.browser=!0;B.env={};B.argv=[];B.version="";B.versions={};function me(){}B.on=me;B.addListener=me;B.once=me;B.off=me;B.removeListener=me;B.removeAllListeners=me;B.emit=me;B.prependListener=me;B.prependOnceListener=me;B.listeners=function(t){return[]};B.binding=function(t){throw new Error("process.binding is not supported")};B.cwd=function(){return"/"};B.chdir=function(t){throw new Error("process.chdir is not supported")};B.umask=function(){return 0};var di=hn.exports;const I=ui(di),fi=si.pino({level:"trace",enabled:typeof window<"u"&&!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),ue=(t,e)=>fi.child({name:t},e);class pi extends Event{slEventBus;constructor(e,r){super(e),this.slEventBus=r}}const hi=ue("event-bus");class yi{name;listeners;constructor(e="sl-event-bus"){this.name=e,this.listeners=new Set}emit=(e,r)=>{const n=new pi(this.name,{...r,type:e});hi.debug(n,"Emitting event"),window.dispatchEvent(n)};listen(e){return window.addEventListener(this.name,e),this.listeners.add(e),()=>{this.off(e)}}off(e){window.removeEventListener(this.name,e),this.listeners.delete(e)}destroy=()=>{this.listeners.forEach(e=>{window.removeEventListener(this.name,e),this.listeners.delete(e)}),this.listeners.clear()}}class mi{}window.slStore=Object.create(null);class It{store;name;constructor(e,r){this.store=e,this.name=r}getStore(){return this.store}}const gi=t=>{const e=Object.keys(t);return te.computed(e.map(r=>t[r].getStore()),(...r)=>Object.fromEntries(e.map((n,i)=>[n,r[i]])))};class Ae extends It{getValues=()=>this.getStore().get();getValue=e=>this.getStore().get()[e];setValue=(e,r)=>this.getStore().setKey(e,r);subscribe=(...e)=>this.getStore().subscribe(...e);unsubscribe=()=>this.getStore().off()}const H=t=>te.map(t);var fe;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(fe||(fe={}));const bi={[V.SdkOverlayType.BETTING]:"betting",[V.SdkOverlayType.GAMES]:"games",[V.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[V.SdkOverlayType.TWITTER]:"twitter"};var He;(function(t){t.Ready="ready",t.Suspended="suspended"})(He||(He={}));class bn{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},n){this.settingsKey=bi[r.type],this.status=te.atom(He.Suspended),this.config=new Ae(H(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new Ae(H(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new Ae(H({}),`feature:settings:${this.settingsKey}`),this.source=n}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(He.Ready)};disable=()=>{this.status.set(He.Suspended)};setFeatureConfig=({settings:e,...r})=>{let n;for(n in r)this.config.setValue(n,r[n]);if(e?.overlaySettings?.case!==void 0&&e?.overlaySettings.case===this.settingsKey){const i=e.overlaySettings.value;if(i!==void 0){let o;for(o in i)i[o]!==0&&i[o]!==""&&this.settings.setValue(o,i[o])}}};update=(e,r)=>{this.source===fe.STREAM&&r===fe.ORGANIZATION||(this.setFeatureConfig(e),this.source=r)};fireEvent(e){for(const r of this.listeners.values())try{r.onEvent(e)}catch(n){console.error(n)}}}class Y extends It{getValue=()=>this.getStore().get();getValues(){throw new Error("not implemented")}setValue=e=>this.getStore().set(e);subscribe=e=>this.getStore().subscribe(e);unsubscribe=()=>this.getStore().off();listen(e){return this.getStore().listen(e)}get(){return this.getStore().get()}}const j=t=>te.atom(t);class ae extends It{atomStore;constructor(e,r,n){super(e,`api:${r}`),this.atomStore=te.atom(),n&&e.subscribe(i=>{const o=this.atomStore.get(),s=n(i,o);o!==s&&this.atomStore.set(s)})}getAtomStore=()=>this.atomStore;getValue=async()=>{const e=this.getStore();if(e.value===void 0)throw new Error("no store");return await e.value.promise,e.get().data};getValues=()=>this.getStore().get();setValue=e=>this.getStore().set({loading:!1,data:e?.data});subscribe=e=>this.getStore().subscribe(e);unsubscribe=()=>{throw new Error("not implemented")};invalidate=()=>{this.store.invalidate()};listen=e=>this.getStore().listen(e);get(){throw new Error("not implemented")}key=()=>this.getStore().key;off=()=>this.getStore().off()}const U=new yi;async function*vi(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now(),t.id=vn++;const n={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(n),yield r}}let vn=0;const Si=()=>t=>async e=>{const r={id:vn++,name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries()),message:e.message},response:{}};window.postMessage({type:"__GRPC_DEVTOOLS_EXTENSION__",data:r});try{const n=await t(e);if(r.received_at=Date.now(),r.response.header=Object.fromEntries(n.header.entries()),r.response.trailer=Object.fromEntries(n.trailer.entries()),e.stream){const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...r,stream:!1}};return window.postMessage(i),{...n,message:vi(r,n.message)}}else{r.response.message=n.message,r.latency=r.received_at-r.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};window.postMessage(i)}return n}catch(n){r.received_at=Date.now(),r.response.trailer={"grpc-status":n.code,"grpc-message":n.rawMessage},r.response.message=n.rawMessage,r.latency=r.received_at-r.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};throw window.postMessage(i),n}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));function Sn(t){return t instanceof DOMException&&(t.code===22||t.code===1014||t.name==="QuotaExceededError"||t.name==="NS_ERROR_DOM_QUOTA_REACHED")}class xe{delimiter=":";prefix;storage;constructor(e="main",r=window.localStorage){this.prefix=`sl-sdk${this.delimiter}${e}`,this.storage=r}clear=()=>{for(const e in window.localStorage)e.startsWith(this.prefix)&&this.storage.removeItem(e)};generateKey=e=>`${this.prefix}${this.delimiter}${e.join(this.delimiter)}`;write=(...e)=>{const r=e.pop()||"",n=this.generateKey(e);try{this.storage.setItem(n,r)}catch(i){Sn(i)&&this.storage===window.sessionStorage&&(window.sessionStorage.removeItem("slstreamlogs"),this.storage.setItem(n,r))}};read=(...e)=>{const r=this.storage.getItem(this.generateKey(e));return r===null?void 0:r};remove=(...e)=>{this.storage.removeItem(this.generateKey(e))}}var Z;(function(t){t.Init="init",t.Ready="ready",t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected",t.Failed="failed",t.Reconnect="reconnect",t.Reconnecting="reconnecting"})(Z||(Z={}));const Fr=ue("grpc:stream");class wi{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,n,i){const o={status:Z.Init,ts:new Date,log:[]};this.state=new Ae(H(o),`subscription:${i.name}:state`),this.options={...i,reconnectDelay:i.reconnectDelay??1e3,reconnectMaxDelay:i.reconnectMaxDelay??3e4,reconnectMaxAttempts:i.reconnectMaxAttempts??10,withStore:i.withStore??!1},this.headers=e,this.listeners=new Map,this.params=n,this.method=r,i.withStore&&(this.store=new Y(j(null),`subscription:${i.name}:store`)),"subscribe"in n&&typeof n.subscribe=="function"&&(this.paramsListener=n.subscribe(s=>{this.state.getValue("status")===Z.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(Z.Ready)}updateState=e=>{this.state.setValue("status",e),this.state.setValue("ts",new Date),this.addStateLog(`status => ${e}`)};addStateLog=e=>{const r=this.state.getStore().get().log,n=`${this.options.name} ${new Date().toISOString()}: ${e}`;if(r.push(n),this.state.setValue("log",r),localStorage.getItem("SL_DEBUG")){e.startsWith("received data")?Fr.trace({name:this.options.name,attempt:this.attempt},"received data"):Fr.trace({name:this.options.name,attempt:this.attempt},e);try{window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
2
+ `+n)}catch(i){Sn(i)&&window.sessionStorage.removeItem("slstreamlogs"),window.sessionStorage.setItem("slstreamlogs",n)}}};addListener=(e,r)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),()=>{}):(this.listeners.set(e,r),this.addStateLog(`listener '${e}' added`),()=>this.removeListener(e));removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(Z.Connecting),this.streamCancel&&(this.addStateLog("disconnect prev connection"),this.streamCancel.abort(),this.streamCancel=void 0);const e="get"in this.params&&typeof this.params.get=="function"?this.params.get():this.params;(async()=>{this.streamCancel=new AbortController;try{const n={headers:this.headers.getValues(),signal:this.streamCancel.signal},i=this.method(e,n);for await(const o of i)this.attempt=0,this.onData(o)}catch(n){n instanceof q.ConnectError&&n.code!=q.Code.Canceled&&this.onStreamError(n)}})(),this.updateState(Z.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(Z.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(Z.Reconnect);const e=Math.min(this.options.reconnectMaxDelay,Math.pow(2,this.attempt)*this.options.reconnectDelay),r=Math.round(e*(1+Math.random())/2);this.reconnectTimeout=setTimeout(()=>{this.attempt++,this.updateState(Z.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${r}ms`),this.connect(),this.reconnectTimeout=void 0},r)}else this.addStateLog("max reconnect attempts reached"),this.disconnect()};getStore=()=>this.store?.getStore();onData=e=>{try{this.addStateLog(`received data => ${JSON.stringify(e)}`),this.store&&this.store.setValue(e);for(const[,r]of this.listeners)r(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(r){this.addStateLog(`error process data => ${r}`)}};onStreamError=e=>{if(this.addStateLog(`error => ${e?JSON.stringify(e):"undefined"}}`),e!==void 0){if(e instanceof q.ConnectError&&e.code!==q.Code.Canceled){this.updateState(Z.Failed),this.state.setValue("error",e),e.code===q.Code.Unknown&&e.cause==="missing trailer"&&(this.attempt=0),this.reconnect();return}this.disconnect()}}}const Ti=new Set([q.Code.Unknown,q.Code.Internal,q.Code.DeadlineExceeded,q.Code.ResourceExhausted,q.Code.FailedPrecondition,q.Code.Unavailable,q.Code.DataLoss]),Dr=ue("grpc:retry"),Ai=t=>async e=>{const r=e.contextValues.get(tr.retryAttempts),n=300,i=e.contextValues.get(tr.retryDelay);if(e.stream||r===0)return t(e);Dr.trace({url:e.url,attempts:r,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){Dr.trace({attempt:o,error:s},"retry attempt");const a=q.ConnectError.from(s);if(o>=r||!(a instanceof q.ConnectError)||!Ti.has(a.code))throw s;const u=Math.min(i,Math.pow(2,o)*n),l=Math.round(u*(1+Math.random())/2);await new Promise(c=>setTimeout(c,l))}},tr={retryAttempts:q.createContextKey(10,{description:"Number of attempts to retry"}),retryDelay:q.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},Ei=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=Xt.nanoid();return localStorage.setItem("sl-device-id",e),e},Ii=()=>navigator.userAgentData?.platform||navigator.platform;class Rr{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;$headers;interceptors=[];clients;streamClients;subscriptions;opts;constructor(e,r){this.host=e,this.opts=r,this.$headers=new Ae(H({"sl-device-id":Ei(),"sl-device-os":Ii()}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.streamClients=new Map,this.subscriptions=new Map;const[n,i,o]=Pr.nanoquery({dedupeTime:r?.dedupeTime,refetchInterval:r?.refetchInterval});this.nanoquery={createFetcherStore:n,createMutatorStore:i,utils:o},this.transport=Lr.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors}),this.streamTransport=Lr.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors})}addSubscription=(e,r,n)=>{const i=this.subscriptions.get(r);if(i)return i;const o=new wi(this.$headers,e,r,n);return this.subscriptions.set(r,o),o};removeSubscription=e=>{e.disconnect(),this.subscriptions.delete(e.params)};disconnect=()=>{for(const[i,o]of this.subscriptions)o.disconnect(),this.subscriptions.delete(i);this.clients.clear(),this.streamClients.clear(),this.subscriptions.clear();const[e,r,n]=Pr.nanoquery({dedupeTime:this.opts?.dedupeTime,refetchInterval:this.opts?.refetchInterval});this.nanoquery={createFetcherStore:e,createMutatorStore:r,utils:n}};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(r=>r!==e)};getClient=e=>{const r=e.typeName;if(this.clients.has(r))return this.clients.get(r);const n=q.createClient(e,this.transport);return this.clients.set(r,n),n};getStreamClient=e=>{const r=`stream-${e.typeName}`;if(this.clients.has(r))return this.clients.get(r);const n=q.createClient(e,this.streamTransport);return this.clients.set(r,n),n};createPromiseClient=(e,{params:r=[],method:n})=>{const i=this.getClient(e),o=e.methods[n].name,s=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1),...Array.isArray(r)?r:[r]],a=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1)];return{client:i,createRequestOptions:l=>{const c=q.createContextValues();for(const f in l){const p=tr[f];c.set(p,l[f])}return c},queryKey:s,queryKeyStr:a.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,r)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",r)};setHeader=(e,r)=>this.$headers.setValue(e,r);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=r=>n=>{const i=this.$headers.getValues();for(const o in i)n.header.set(o,i[o]);return r(n)};this.interceptors.push(e),this.interceptors.push(Si()),this.opts?.retryable&&this.interceptors.push(Ai)}}const Oi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(dn.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>{if(!s||typeof s!="string")return"";try{return(await r.retrieveEventId({id:s})).data?.id||""}catch{return""}}})},_i=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.getStream({id:s})).data?.attributes:void 0})},Ci=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(dn.Events,{method:"summary",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.summary({id:s})).data?.attributes:void 0})},ki=(t,e)=>{const{queryKey:r,client:n}=e.createPromiseClient(hr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>{const{data:i}=await n.me({});return{data:i}}})},Li=t=>{const{client:e,createRequestOptions:r}=t.createPromiseClient(hr.Users,{method:"bypassAuth"}),n=r({retryAttempts:0});return({userKey:i,schema:o,init:s,inviterKey:a})=>e.bypassAuth({userKey:i,schema:o,init:s,inviterKey:a},{contextValues:n})},Pi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.get({})).data?.attributes})},Ni=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>{const i=await r.getOrganization({});return i.data?{...i.data.attributes,id:i.data.id}:void 0}})},Fi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},Di=(t,e,r)=>{t.transport=new Rr(e.host,{dedupeTime:1e3*60*5,refetchInterval:1e3*60*5,retryable:!0}),t.analyticsTransport=new Rr(e.analyticsHost),t.sdk.host=t.transport.host,t.transport.setSdkKey(e.sdkKey),t.transport.setHeader("sl-sdk-version",e.version||"-"),t.transport.$headers.subscribe(n=>{t.analyticsTransport.$headers.getStore().set(n)}),t.sdk.onMount({name:"transport"},()=>()=>{t.transport.disconnect(),t.analyticsTransport.disconnect()}),r()};var de;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(de||(de={}));class Ve extends xe{constructor(){super("user")}setSchema=e=>{this.write(de.SCHEMA,e)};getSchema=()=>this.read(de.SCHEMA);setToken=e=>{this.write(de.TOKEN,e)};getToken=()=>this.read(de.TOKEN);setExternalToken=e=>{this.write(de.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(de.EXTERNAL_TOKEN);removeToken=()=>{this.remove(de.TOKEN)}}var pe;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(pe||(pe={}));const Ri=t=>{const e=new Ve,r=new Y(j(e.getExternalToken()),"userKey"),n=new Y(j(e.getToken()),"userToken"),i=new ae(ki(n.getStore(),t),"user",({data:s,error:a,loading:u},l)=>{if(!a)return s?.data?.id?s.data.id:u===!1?void 0:l}),o=new ae(Pi(n.getStore(),t),"userSettings");return{userKey:r,userToken:n,user:i,userSettings:o}},Vi=t=>{const e=new Y(j(void 0),"providerStreamId"),r=new ae(Oi(e.getStore(),t),"slStreamId",o=>o?.data),n=new ae(_i(r.getAtomStore(),t),"streamSettings"),i=new ae(Ci(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(o=>{(o===""||o===void 0)&&(n.getStore().mutate(void 0),i.getStore().mutate(void 0))}),{providerStreamId:e,slStreamId:r,streamSettings:n,streamSummary:i}},$i=t=>{const e=new Y(j(void 0),"enabled"),r=new Y(j(pe.DISABLED),"status"),n=new ae(Ni(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new ae(Fi(n.getAtomStore(),t),"organizationAdvertising"),o=Ri(t),s=Vi(t);return{enabled:e,status:r,providerStreamId:s.providerStreamId,slStreamId:s.slStreamId,streamSettings:s.streamSettings,streamSummary:s.streamSummary,user:o.user,userKey:o.userKey,userToken:o.userToken,userSettings:o.userSettings,organizationSettings:n,organizationAdvertising:i}};class qi extends It{stores;constructor(e){const r=$i(e),n=gi(r);super(n,"core"),this.stores=r}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=e=>{let r;for(r in this.stores){const n=e[r];r in e&&n!==void 0&&this.stores[r].subscribe(e[r])}};unsubscribe=()=>this.getStore().off()}const Bi=(t,e,r)=>{t.store=new qi(t.transport),t.stores=t.store.getValues(),t.sdk.enabled=t.stores.enabled.getStore(),t.sdk.status=t.stores.status.getStore(),t.sdk.sdkStore=Object.fromEntries(Object.entries(t.stores).map(([n,i])=>[n,i.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.sdk.streamSummary=()=>t.stores.streamSummary.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},r()},Mi=t=>{const{client:e}=t.createPromiseClient(fn.Leaderboard,{method:"list"});return r=>e.list(r)},wn=t=>{const{client:e}=t.createPromiseClient(fn.Leaderboard,{method:"summary"});return r=>e.summary(r)},Ui=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(hr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>{if(!s)return[];try{return(await r.getFriends({})).data}catch{return[]}}})},ji=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(J.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.get({eventId:s})).data?.attributes,refetchInterval:0,dedupeTime:1e3*60*60})},Qi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(J.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>{if(!s)return;const a=await r.syncQuestion({filter:{eventId:s}});if(a.data?.attributes?.question?.type!==w.QuestionType.PROMOTION)return a.data?.attributes},dedupeTime:1e3*60*10,refetchInterval:0})},xi=async(t,e)=>{const{client:r}=e.createPromiseClient(J.Feed,{method:"item",params:[t]});return(await r.item({id:t})).data},Gi=(t,e)=>{const{client:r}=e.createStreamClient(J.Feed),n=te.atom({eventId:t.get()||"",feedId:""});return t.subscribe((o="")=>{n.set({eventId:o,feedId:""})}),e.addSubscription(r.subscription,n,{name:"feedSubscription"})},Ki=(t,e)=>{const{client:r}=e.createStreamClient(J.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},zi=async(t,e)=>{const{client:r}=e.createPromiseClient(J.Feed,{method:"questionByUser",params:[t]});return(await r.questionByUser({questionId:t})).data?.attributes?.question},rr=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(J.Feed,{method:"questionByUser",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.questionByUser({questionId:s})).data?.attributes?.question,dedupeTime:1e3*60*5})},Tn=async(t,e)=>{if(!t)return;const{client:r}=e.createPromiseClient(J.Feed,{method:"getQuestion",params:[t]}),n=await r.getQuestion({id:t});if(!n.data?.attributes)return;const{options:i,notification:o,...s}=n.data.attributes,a=i?.options.case==="promotion"?i?.options.value:void 0;return{id:s.id,question:s,promotion:a,notification:o}},Hi=(t,e,r)=>{const{client:n,queryKey:i}=r.createPromiseClient(J.Feed,{method:"list",params:[t,e]});return r.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>a?(await n.list({eventId:a,filter:{types:u===Ee.ALLOWED?[]:[w.QuestionType.FACTOID,w.QuestionType.PROMOTION,w.QuestionType.TWEET],statuses:[w.QuestionStatus.ACTIVE,w.QuestionStatus.RESOLVED]}})).data:[],dedupeTime:0,refetchInterval:0})},Wi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(J.Feed,{method:"list",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>{if(!s)return;const u=(await r.list({eventId:s,filter:{types:[w.QuestionType.PROMOTION],statuses:[w.QuestionStatus.ACTIVE]},pagination:{page:0,pageSize:1}})).data?.[0];if(u.type==="promotion")return Tn(u.id,e)},dedupeTime:0,refetchInterval:0})},Yi=(t,e,r)=>{const n=te.batched([e,r],()=>{const a=e.get();if(!a)return;const u=r.get().data?.find(c=>c.id===a?.questionId),l=a?.question?.openedFrom;return u?(u.openedFrom=l,u):a.question}),i=te.batched(n,a=>a&&a.type==="question"?a.id:void 0),o=rr(i,t);return{$store:n,$extendedStore:o,updateExtendedQuestion:a=>{const u=o.get().data,l=(c,f)=>{if(!c||!f)return c||f||[];const p=[];for(let S=0;S<c.length;S++)p.push({...c[S],...f[S],correct:c[S].correct,youVoted:c[S].youVoted,pointsEarned:c[S].pointsEarned});return p};o.mutate({...a,options:u?.options,subject:u?.subject,appearance:u?.appearance,answers:l(u?.answers,a?.answers)})}}};var mt;(function(t){t.SHOWED="showed"})(mt||(mt={}));class Ji extends xe{constructor(){super("advertisement")}setShowed=e=>{this.write(mt.SHOWED,e,"true")};isViewed=e=>this.read(mt.SHOWED,e)}const Xi=t=>{const e=t.data?.attributes?.question;if((t.data?.attributes?.feedItem?.type==="promotion"?t.data.attributes.feedItem:void 0)===void 0||!e)return;const{options:n,notification:i,...o}=e,s=n?.options.case==="promotion"?n.options.value:void 0;return{id:o.id,question:o,notification:i,promotion:s}},st=t=>t.startsWith("http://")||t.startsWith("https://")?new URL(t).toString():t,Zi=({gamOptions:t,gamBaseUrl:e})=>{const r=`${e}?`,n=[];for(const i in t){const o=i.replace(/([a-zA-Z])(?=[A-Z])/g,"$1_").toLowerCase(),s=t[i];if(s)if(typeof s=="string")n.push(`${o}=${st(s)}`);else if(Array.isArray(s))n.push(`${o}=${s.map(st).join(",")}`);else{const a=Object.entries(s).map(([u,l])=>Array.isArray(l)?`${u}=${l.map(st).join(",")}`:typeof l=="string"?`${u}=${st(l)}`:`${u}=${l}`).join("&").replaceAll("=","%3D").replaceAll("&","%26").replaceAll(",","%2C");n.push(`${o}=${a}`)}}return r+n.join("&")},Ne=t=>(t?.promotion?.type===w.PromotionType.INGAME_IAB11_LBAR||t?.promotion?.type===w.PromotionType.INGAME_IAB21_LBAR)&&!!t.promotion.additionalBanner?.imageUrl,eo=(t,e,r)=>{let n=!1;const i=r.transport,o=ue("advertisement"),s=new Ji,a=H({}),u=Wi(t,i),l=b=>{if(b?.fromNotification){a.setKey("hasNotification",!1);const g=a.get(),T=g.data?.question.id,D=g.data?.promotion?.type;T&&(U.emit("advertisement",{action:"opened",payload:{id:T,type:D,hasBanner:Ne(g.data),openedFrom:"notification"}}),U.emit("advertisement",{action:"notification-opened",payload:{id:T,type:D,hasBanner:Ne(g.data)}}))}},c=()=>{const b=a.get(),g=b.data?.question.id,T=b.data?.promotion?.type,D=a.get()?.isOpened;g&&!D&&(o.debug({id:g},"markAsViewed: %o"),s.setShowed(g),a.setKey("isOpened",!0),U.emit("advertisement",{action:"viewed",payload:{id:g,type:T,hasBanner:Ne(b.data)}}))},f=(b,g)=>{g?a.set({loading:!1,error:void 0,data:g,hasNotification:g?.notification?.enabled===w.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>p(g.question.id),togglePause:T=>S(g.question.id,T),isViewed:!!s.isViewed(g.question.id)}):(a.setKey("loading",!0),Tn(b,i).then(T=>a.set({loading:!1,error:void 0,data:T,hasNotification:T?.notification?.enabled===w.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>p(T?.question.id),togglePause:D=>S(T?.question.id,D),isViewed:T&&!!s.isViewed(T.question.id)})).catch(T=>a.set({loading:!1,error:T,data:void 0})))};a.subscribe((b,g)=>{if(!(b.data?.id===g?.data?.id&&b.isPaused!==g?.isPaused)){if(b.data?.promotion?.type===w.PromotionType.EXTERNAL_AD&&!b?.externalAd&&b.data.promotion.adCampaigns?.gamOptions&&b.data.promotion.adCampaigns?.gamBaseUrl){const T=Zi(b.data.promotion.adCampaigns);a.setKey("externalAd",{type:"gam",url:T})}b.data?.promotion&&!b.isOpened&&(U.emit("advertisement",{action:"received",payload:{id:b.data.question.id,type:b.data.promotion.type,hasNotification:!!b.hasNotification,hasBanner:Ne(b.data),isViewed:!!s.isViewed(b.data.question.id)},skipAnalytics:b.data.question.id===g?.data?.question.id}),b.data.question.id!==g?.data?.question.id&&!s.isViewed(b.data.question.id)&&U.emit("advertisement",{action:"notification-received",payload:{id:b.data.question.id,type:b.data.promotion.type,hasNotification:!0,hasBanner:Ne(b.data),isViewed:!1}})),!b?.data&&g?.data&&U.emit("advertisement",{action:"closed",payload:{id:g.data.question.id,type:g.data.promotion?.type,hasNotification:!!g.hasNotification,hasBanner:Ne(g.data),isViewed:!!s.isViewed(g.data.question.id)}})}});const p=b=>{(!b||a.get()?.data?.question.id===b)&&a.set({})},S=(b,g)=>{a.get()?.data?.question.id===b&&a.setKey("isPaused",g)};return{connect:()=>{n||(n=!0,u.subscribe((b,g)=>{b.data&&(!g?.data||b.data.id!==g.data.id)&&f(b.data.question.id,b.data)}),e.addListener("promotion",b=>{const g=Xi(b);if(g){if(g.question.status===w.QuestionStatus.RESOLVED){p(g.question.id),o.debug({promotion:g},"resolved: %o");return}if(g.question.status===w.QuestionStatus.ACTIVE){o.debug({promotion:g},"active: %o"),f(g.question.id,g);return}o.debug({promotion:g},"skip: %o")}}))},hide:p,show:f,open:l,markAsViewed:c,$store:a}};var Ee;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Ee||(Ee={}));class to{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;advertisement;notifications;log;transport;cancels=new Set;constructor(e){this.transport=e.transport,this.log=ue("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new Y(j(void 0),"moderationId").getStore(),this.interactiveAllowed=new Y(j(Ee.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new Y(j(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new ae(ji(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new ae(Hi(this.slStreamId,this.interactiveAllowed,e.transport),"gamification:feedList"),this.activeQuestionId=Qi(this.slStreamId,e.transport),this.openedQuestion=Yi(e.transport,this.openedQuestionId,this.feedList.getStore()),this.cancels.add(this.openedQuestionId.listen(r=>{this.log.debug({item:r},"received question"),r?.questionId?(this.questionSubscription=Ki(r.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",n=>{this.openedQuestion.updateExtendedQuestion(n.data?.attributes?.question)}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))})),this.feedSubscription=Gi(this.slStreamId,e.transport),this.cancels.add(this.feedSubscription.addListener("feed-subscription-active-question",r=>{const n=this.activeQuestionId.get().data?.question?.id,i=r.data?.attributes?.question;if(!(!i||i.type===w.QuestionType.PROMOTION)){if(i.status===w.QuestionStatus.RESOLVED){n===i.id&&this.activeQuestionId.mutate(void 0);return}window.requestAnimationFrame(()=>{this.activeQuestionId.mutate(r.data?.attributes)})}})),this.cancels.add(this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})})),this.cancels.add(this.activeQuestionId.subscribe((r,n)=>{r.data?.feedItem&&r.data?.feedItem?.id!==n?.data?.feedItem?.id&&e.onQuestionActivate({stage:"activate",id:r.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:r.data.feedItem.id})),hasNotification:!0,type:r.data.feedItem.type}),!r.data?.feedItem&&n?.data?.feedItem&&e.onQuestionActivate({stage:"deactivate",id:n.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:n.data.feedItem.id})),hasNotification:!0,type:n.data.feedItem.type})})),this.feedSubscription.connect(),this.cancels.add(this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})),e.sdk.onMount({name:"gamification-background"},()=>()=>{this.activeQuestionId.off();for(const r of this.cancels)r(),this.cancels.delete(r)}),this.advertisement=eo(this.slStreamId,this.feedSubscription,e)}getCurrentSessionId=e=>{const r=e.eventId||this.slStreamId.get()||"",n=e.userId||this.userId.get()||"",i=e.organizationId||this.organizationId.get()||"",o=e.entity||"",s=e.prefix||"";return[i,r,n,s,o].join(":")};disconnect=()=>{this.feedSubscription?.disconnect(),this.questionSubscription!==void 0&&(this.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0)};openQuestion=(e,r)=>{this.openedQuestionId.set({questionId:e,question:r}),this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))};closeQuestion=e=>{this.openedQuestionId.set(void 0),e&&this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))}}class ro{notificationsList;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=ue("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notificationsList=j(new Map)}addToQueue=e=>{if(this.store.has(e.id)){this.logger.debug({notification:e},"skip existed notification: %o");return}const r=e.close,n=e.action;if(this.store.set(e.id,{...e,close:(...i)=>{r&&r(...i),this.closeNotification(e.id)},action:(...i)=>{n&&n(...i),this.closeNotification(e.id,{animateHiding:!1})}}),this.waitingQueue.add(e.id),this.activeQueue.size===this.options.concurrency){const[i]=this.activeQueue;if(this.store.get(i)?.persistent!==!0)this.closeNotification(i);else{const[s]=this.waitingQueue;this.waitingQueue.size>1&&this.closeNotification(s),this.tickWaitingQueue()}}else this.tickWaitingQueue()};tickWaitingQueue=()=>{if(this.activeQueue.size<this.options.concurrency){const[e]=this.waitingQueue;if(!e)return;this.activeQueue.add(e),this.waitingQueue.delete(e),this.logger.debug({job:e},"waiting queue tick"),this.tickActiveQueue(e)}else this.logger.debug({queueSize:this.activeQueue.size,concurrency:this.options.concurrency},"waiting queue tick skipped")};tickActiveQueue=e=>{if(!e)return;const r=this.store.get(e);if(!r){this.logger.debug({notificationId:e},"active queue tick skipped, notification not exist");return}U.emit("notification",{action:"received",payload:{questionId:r.data.questionId,questionType:r.data.questionType}});const n=setTimeout(()=>{const i=e,o=new Map(this.notificationsList.get());o.set(r.id,r),this.notificationsList.set(o);const s=setTimeout(()=>{this.logger.debug({notificationId:i,delay:r.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(i)},r.autoHideDuration||5e3);this.timeouts.set(i,s),this.logger.debug({notificationId:i,queue:[...o.values()]},"notification displayed")},r.delay||0);this.timeouts.set(e,n),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=(e,{animateHiding:r=!0}={})=>{const n=new Map(this.notificationsList.get()),i=n.get(e);if(i){i.hiding=!(this.waitingQueue.size>=this.options.concurrency)&&r,this.notificationsList.set(n);const o=setTimeout(()=>{const s=new Map(this.notificationsList.get());s.delete(e),this.notificationsList.set(s);const a=this.timeouts.get(e);a!==void 0&&(clearTimeout(a),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden"),i.hiding&&U.emit("notification",{action:"closed",payload:{questionId:i.data.questionId,questionType:i.data.questionType}})},this.options.animationDelay||0);this.timeouts.set(e,o)}return this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding"),i};drain=()=>{this.store.clear(),this.timeouts.clear(),this.waitingQueue.clear(),this.activeQueue.clear(),this.notificationsList.off(),this.notificationsList.set(new Map)}}var gt;(function(t){t.OPENED="opened"})(gt||(gt={}));class no extends xe{constructor(){super("notification")}setOpened=e=>{this.write(gt.OPENED,e,"true")};isOpened=e=>this.read(gt.OPENED,e);clearNotification=()=>{this.clear()}}var be;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(be||(be={}));class io{queue;storage;constructor(e={}){this.storage=new no,this.queue=new ro({concurrency:1,animationDelay:1600,...e})}isViewed=e=>this.storage.isOpened(e);add=e=>{if(!this.isViewed(e.id)){if(e.data&&e.emitEvent){const n=e.action;e.action=(...i)=>{n&&n(...i),U.emit("notification",{action:"opened",payload:{questionId:e.data.questionId,questionType:e.data.questionType}})}}this.queue.addToQueue(e)}};close=(e,{markAsViewed:r=!0,animateHiding:n}={})=>{this.queue.closeNotification(e,{animateHiding:n}),r&&this.markAsViewed(e)};getActiveNotification=()=>{const e=this.queue.notificationsList.get();if(!e?.size)return null;for(const n of e.values())if(n.type===be.ONBOARDING)return n;return e.values().next().value};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const oo=(t,e,r)=>{t.notifications=new io(void 0),t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),t.sdk.getActiveNotification=()=>t.notifications.getActiveNotification(),t.sdk.onMount({name:"notifications"},()=>()=>{t.notifications.queue.drain()}),r()};var Je;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(Je||(Je={}));const so=async(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(J.Feed,{method:"submitAnswer"}),i=n({retryAttempts:0});try{return await r.submitAnswer({data:e},{contextValues:i})}catch(o){throw q.ConnectError.from(o)?.code===q.Code.AlreadyExists?new Error(Je.ALREADY_VOTED):new Error(Je.UNKNOWN)}},ao=(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(J.Feed,{method:"submitInplay"}),i=n({retryAttempts:0});return r.submitInplay({data:{eventId:+e}},{contextValues:i})};var $e;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})($e||($e={}));class uo extends xe{constructor(){super("gamification-session",window.sessionStorage)}writeValue=(e,r)=>{this.write(...e,r)};readValue=e=>this.read(...e)}class An extends xe{sessionStorage;constructor(){super("gamification"),this.sessionStorage=new uo}saveOnboardingStatus=({userId:e,eventId:r,organizationId:n},i)=>{this.write($e.ONBOARDING,n,e,r,i)};getOnboardingStatus=({userId:e,eventId:r,organizationId:n})=>this.read($e.ONBOARDING,n,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{this.sessionStorage.writeValue([$e.ONBOARDING_IO,n,e,r],"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>this.sessionStorage.readValue([$e.ONBOARDING_IO,n,e,r])}const co={pageSize:10},lo=(t,e,r,n,i)=>{let o=0;const s=j({pageSize:co.pageSize,page:0}),a=H({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=Mi(t),l=async()=>{const p=e.get(),S=n.getStore().get().data?.map(A=>A.slId)||[];if(p&&S?.length){const A=r.get();A&&S.push(A),a.setKey("loading",!0),a.setKey("data",[]);const g=await u({eventId:p,usersIds:S});a.set({data:g.data.map((T,D)=>({...T.attributes,friendsRank:D+1})),hasMore:!1,key:Date.now(),loading:!1}),g.meta&&(o=Math.round(g.meta.count/g.meta.pageSize))}},c=()=>{l()},f=p=>{const S=s.get(),A=p||S.page+1;A<=o&&s.set({...S,page:A})};return te.onMount(a,()=>{const p=e.listen(l),S=n.listen(l);return()=>{p(),S()}}),{$store:a,fetchMore:f,invalidate:c}};class fo extends xe{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Vr="sldl",Ot="sldl_uid",En="sldl_eid",In="sldl_e_eid",po=new Set([Ot,En,In]),$r=t=>{const e={},r={};for(const[n,i]of t)po.has(n)?e[n]=i:r[n]=i;return{result:e,remain:r}},ho=({hash:t,search:e})=>{if(t&&t.includes(Vr)){const r=new URLSearchParams(t.substr(1));return{hash:$r(r)}}if(e&&e.includes(Vr)){const r=new URLSearchParams(e);return{search:$r(r)}}return null},qr=ue("deep_link"),se={debug:(...t)=>{qr.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{qr.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},yo=(t,e)=>{const{hash:r,search:n}=window.location;if(se.debug({hash:r,search:n},"get deep link data from"),r||n){const i=ho({hash:r,search:n});if(se.debug(i,"parse deep link result"),i){const{hash:o,search:s}=i,{result:a,remain:u}=o||s;if(Object.keys(a).length!==0){t.setValue("data",a);const l=Object.keys(u).length!==0;if(o){let c="";l&&(c=`#${new URLSearchParams(u).toString()}`,se.debug({updatedHash:c},"update hash")),window.history.replaceState(null,"",window.location.pathname+window.location.search+c)}if(s){let c="";l&&(c=`?${new URLSearchParams(u).toString()}`,se.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},mo=(t,e,r)=>{const n=new fo,i=n.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){se.debug(a)}t.deepLink={$store:new Ae(H(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{se.debug(`logged in with inviterId: ${a}`),t.deepLink.$store.setValue("used",!0)},onDeepLinkHandlers:new Set},t.sdk.getInviter=()=>{const{data:a,used:u}=t.deepLink.getDeepLinkData();return u?a?.[Ot]:void 0},t.sdk.inviteDisplayed=()=>{t.deepLink.$store.getStore().set({}),t.deepLink.$store.getStore().off(),n.del("sl-deep-link-store")},t.deepLink.$store.subscribe(a=>n.set("sl-deep-link-store",JSON.stringify(a))),t.sdk.addDeepLinkHandler=a=>{localStorage.getItem("SL_DEBUG")&&se.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{se.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),se.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{se.trace("called handler"),u(a)}catch(l){console.error(l)}};yo(t.deepLink.$store,s),r()},go=ue("bypass");class bo extends mi{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,n){super(),this.$coreStore=e,this.deepLink=n,this.transport=r,this.bypassLogin=Li(this.transport),this.connect()}me=async()=>(this.$coreStore.getValues().user.invalidate(),(await this.$coreStore.getValues().user.getValue())?.data);login=async(e,r)=>{this.$coreStore.getValues().userKey.setValue(r);const{used:n,data:i}=this.deepLink.getDeepLinkData(),o=n?"":i?.[Ot];go.debug({inviterKey:o},"login with inviterKey");const s=await this.bypassLogin({schema:e,userKey:r,inviterKey:o,init:!1}),a=s.meta?.jwt,u=s.data?.id;if(!a||!u)throw new Error("internal: token missing");return s.meta?.inviterKey&&this.deepLink.deepLinkUsed(s.meta.inviterKey),this.$coreStore.getValues().user.getStore().mutate({data:s.data}),this.saveUser(a,u),a};isAuthenticated=()=>this.me();logout=()=>{this.$coreStore.getValues().user.setValue(),this.$coreStore.getValues().userKey.setValue(),this.$coreStore.getValues().userToken.setValue(),this.transport.setAuth("",""),new Ve().clear()};softLogout=()=>{const e=new Ve;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=()=>{const e=new Ve,r=e.getToken(),n=e.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(n),r)return this.saveUser(r,""),this.me().then(i=>{if(i?.id){const o=i.id;this.saveUser(r,o)}});if(n&&!r){const i=e.getSchema();i&&n&&this.login(i,n).catch(()=>{this.logout()})}};saveUser=(e,r)=>{this.transport.setAuth(e,r),this.$coreStore.getValues().userToken.setValue(e),new Ve().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async r=>{try{return await e(r)}catch(n){throw n.code&&(n.code===7||n.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),n}})}}const ze=new Ve,vo=(t,e,r)=>{t.auth=new bo(t.store,t.transport,t.deepLink),t.stores.status.listen(n=>{n===pe.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(n,i)=>{if(!(ze.getSchema()===n&&ze.getExternalToken()===i&&t.transport.getHeader("authorization")))try{await t.auth.login(n,i),ze.setSchema(n),ze.setExternalToken(i)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),ze.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},Br=ue("video_player"),at={debug:(...t)=>{Br.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{Br.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},So=(t,e,r)=>{t.videoPlayer={controllers:new Set},t.sdk.addVideoPlayerController=n=>{at.trace("adding video player controller"),t.videoPlayer.controllers.add(n)},e.videoPlayerController&&t.sdk.addVideoPlayerController(e.videoPlayerController),t.sdk.removeVideoPlayerController=n=>{at.trace("removing video player controller"),t.videoPlayer.controllers.delete(n)},t.sdk.controlVideoPlayer=n=>{at.trace("controlling video player");for(const i of t.videoPlayer.controllers){at.trace("calling video player controller");try{i(n)}catch(o){console.error(o)}}},r()},wo={[w.QuestionType.FACTOID]:"insight",[w.QuestionType.POLL]:"poll",[w.QuestionType.TRIVIA]:"trivia",[w.QuestionType.PREDICTION]:"prediction",[w.QuestionType.TWEET]:"tweet"},To=(t,e,r)=>{t.sdk.uiState=H({}),t.ui={enableAppNotification:function(){t.sdk.uiState.setKey("appNotification",!0)},disableAppNotification:function(){t.sdk.uiState.get().app||t.sdk.uiState.setKey("appNotification",!1)},enableApp:function(){t.sdk.uiState.set({app:!0,appNotification:!0})},disableApp:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),appNotification:!1,app:!1})}},e.onContentActivate&&(t.ui.onContentActivate=e.onContentActivate);const n=i=>{t.ui.onContentActivate&&t.ui.onContentActivate({...i,type:"advertisement"})};t.onQuestionActivate=({questionType:i,...o})=>{if(t.ui.onContentActivate){const s=o.type||i&&wo[i]||"question";t.ui.onContentActivate({...o,type:s})}},t.sdk.onMount({name:"ui"},()=>{const i=a=>{if(a.slEventBus?.type==="notification")switch(a.slEventBus.action){case"received":t.ui.enableAppNotification();break;case"closed":t.ui.disableAppNotification();break}if(a.slEventBus?.type==="advertisement"&&e.withAd){const u=a.slEventBus,{hasNotification:l,hasBanner:c,id:f,isViewed:p,type:S}=u.payload;switch(u.action){case"notification-opened":t.sdk.uiState.set({promotionExternalAd:S===w.PromotionType.EXTERNAL_AD,promotionBanner:c,promotionNotification:!1,promotionOverlay:!0,promotionSidebar:!0});break;case"received":if(t.sdk.closeFeature(),n({stage:"activate",id:f,hasNotification:l,hasBanner:c,isViewed:p}),!e.withAdNotification){t.sdk.uiState.set({promotionBanner:c,promotionOverlay:!0,promotionSidebar:!0,promotionExternalAd:S===w.PromotionType.EXTERNAL_AD});break}l?t.sdk.uiState.set({promotionNotification:!0}):t.sdk.uiState.set({promotionBanner:c,promotionOverlay:!0,promotionSidebar:!0,promotionExternalAd:S===w.PromotionType.EXTERNAL_AD});break;case"closed":t.sdk.uiState.set({...t.sdk.uiState.get(),promotionNotification:!1,promotionBanner:!1,promotionOverlay:!1,promotionExternalAd:!1,promotionSidebar:!1}),n({stage:"deactivate",id:f,hasNotification:l,hasBanner:c,isViewed:p});break}}},o=U.listen(i),s=t.activeFeature.subscribe(a=>{a?t.ui.enableApp():t.ui.disableApp()});return()=>{o(),s()}}),r()},Ao=(t,e,r)=>{const n={onMountedFired:!1},i=new Map,o=new Map;t.sdk=Object.create(null),t.sdk.options=H(e),t.sdk.withAuth=!1,t.sdk.onMount=({name:s,clear:a},u)=>{if(i.has(s)){const l=o.get(s);l&&l(),i.delete(s),o.delete(s)}i.set(s,{cb:u,clear:a}),t?.stores?.enabled?.get()==="on"&&o.set(s,u())},t.ready=()=>{t.stores.enabled.subscribe(s=>{s==="on"&&n.onMountedFired===!1&&(i.forEach(({cb:a},u)=>o.set(u,a())),n.onMountedFired=!0),s!=="on"&&n.onMountedFired===!0&&(o.forEach(a=>a()),o.clear(),i.forEach(({clear:a},u)=>a&&i.delete(u)),n.onMountedFired=!1)})},t.sdk.initializeApp=async s=>{if(t.contextConfig=s,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(pe.INITIALIZATION);try{const a=await t.stores.organizationSettings.getValue();return a?(t.stores.status.setValue(pe.READY),{enabled:!!a}):(t.stores.status.setValue(pe.FAILED),{err:"failed"})}catch(a){return t.stores.enabled.setValue(),t.stores.status.setValue(pe.FAILED),{err:`${a}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(pe.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=s=>{t.stores.providerStreamId.setValue(s)},r()},Eo=(t,e)=>{const{client:r,queryKey:n}=t.createPromiseClient(Xe.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s,a)=>{if(!s)return{};try{return(await r.generateDeepLink({data:{gamification:!0,externalEventId:a,eventId:s}})).data?.attributes}catch{return}},dedupeTime:1e3*60*60*24,refetchInterval:0})},Io=(t,{web:e,mobile:r})=>{const{client:n}=t.createPromiseClient(ai.LinksClient,{method:"generate"});return n.generate({web:e,mobile:r})},Mr=(t,e)=>{const r=new URLSearchParams(t);for(const[n,i]of Object.entries(e))r.append(n,i);return r.toString()},Oo=(t,e,r,n)=>{const i=H({});return te.onMount(i,()=>Eo(t,[e,r]).subscribe(async({data:a,loading:u})=>{const l=a===void 0&&u===!1?"https://streamlayer.io":a?.url,c=n.get()||"",f=e.get()||"",p=r.get()||"",S={[Ot]:c,[En]:f,[In]:p};if(!u&&l){i.setKey("loading",!0);let A=window.location.search,b=window.location.hash;A&&b||b?A=`?${Mr(A,S)}`:b=`#${Mr("",S)}`;const g=window.location.origin+window.location.pathname+A+b;try{const T=await Io(t,{web:g,mobile:l});i.set({data:T.data?.link,loading:!1})}catch{i.set({loading:!1,error:"Failed to generate short link",data:void 0})}}else i.setKey("loading",!0)})),{$store:i,fetch}};var M;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(M||(M={}));const _o=(t,e,r,n)=>{const{inplayGame:i}=t.featureSettings.get(),o=e.getCurrentSessionId({prefix:"onboarding"});i&&r.add({type:be.ONBOARDING,id:o,action:t.openFeature,close:()=>{t.onboardingProcessed.set(!0)},persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:w.QuestionType.UNSET,onboarding:{...i,instantOpen:!n.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},ut=(t,e,r,n,i,o)=>{try{const s=e.userId.get();if(!s)return;if(i.getOnboardingStatus({userId:s,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===M.Completed){t.set(M.Completed);for(const p of o)p();return}const u=e.moderation.getStore().value?.data,l=r.featureSettings.get().inplayGame;if(u===void 0||l===void 0)return;const c=u?.options?.onboardingEnabled,f=l?.titleCard?.optIn;c?f?t.set(M.Required):t.set(M.Optional):(f?t.set(M.Unavailable):t.set(M.Disabled),n.close(e.getCurrentSessionId({prefix:"onboarding"}),{markAsViewed:!1}))}catch(s){console.error(s)}},Co=(t,e,r,n)=>{let i=!1;const o=new An,s=j(M.Unset);s.subscribe(l=>{l!==M.Unset&&(l===M.Optional||l===M.Required?i===!1&&(_o(t,e,n,o),i=!0):t.onboardingProcessed.set(!0),l===M.Completed&&e.activeQuestionId.invalidate(),o.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const a=[];return ut(s,e,t,n,o,a),s.get()!==M.Completed&&(a.push(e.userId.listen(l=>{l&&ut(s,e,t,n,o,a)})),a.push(e.moderation.listen(l=>{l.data&&ut(s,e,t,n,o,a)})),a.push(t.featureSettings.listen(l=>{l&&ut(s,e,t,n,o,a)}))),{$store:s,submitInplay:async()=>{const l=e.slStreamId.get();if(l){await ao(r,l),s.set(M.Completed),o.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:l},M.Completed),U.emit("poll",{action:"onboardingPassed",payload:{}}),t.openFeature();const c=e.getCurrentSessionId({prefix:"onboarding"});n.close(c)}}}},ko=(t,e,r,n)=>{const i=H(void 0),o=wn(n),s=async()=>{const u=t.get(),l=e.get(),c=r.getStore().get().data?.map(S=>S.slId);if(!c)return;const f={eventId:u,userId:l,usersIds:[...c,l]},p=await o(f);i.set(p.data?.attributes)},a=()=>{s()};return te.onMount(i,()=>{const u=t.listen(s),l=r.listen(s),c=e.listen(s);return()=>{u(),l(),c()}}),{$store:i,invalidate:a}},Lo=async(t,e,r,n,i)=>{const o=wn(i),s=t.get(),a=e.get(),u=r.getStore().get().data?.map(p=>p.slId)||[],l={eventId:s,userId:n,usersIds:[...u,a]};return(await o(l)).data?.attributes?.summary},Po=new Set([w.QuestionType.POLL,w.QuestionType.PREDICTION,w.QuestionType.TRIVIA]);class No extends bn{userSummary;feedList;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;advertisement;onboardingProcessed;friendsTabEnabled;notifications;transport;background;storage;submitAnswerTimeout;cancels=new Set;onQuestionActivate;constructor(e,r,n){super(e,r),this.background=new to(n),this.advertisement=this.background.advertisement,this.onQuestionActivate=n.onQuestionActivate,this.feedSubscription=this.background.feedSubscription,this.activeQuestionId=this.background.activeQuestionId,this.openedQuestionId=this.background.openedQuestionId,this.storage=new An,this.feedList=this.background.feedList,this.friends=new ae(Ui(this.background.userId,n.transport),"gamification:friends"),this.currentUserId=this.background.userId,this.openedUser=j(void 0),this.onboardingProcessed=j(!n.sdk.withAuth),this.leaderboardId=new Y(j(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=Co(this,this.background,n.transport,n.notifications),this.notifications=n.notifications,this.transport=n.transport,this.closeFeature=(i=!0)=>n.sdk.closeFeature(i),this.openFeature=()=>n.sdk.openFeature(V.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=Oo(this.transport,this.background.slStreamId,n.stores.providerStreamId.getStore(),this.background.userId),this.userSummary=ko(this.background.slStreamId,this.background.userId,this.friends,this.transport),this.leaderboardList=lo(this.transport,this.background.slStreamId,this.background.userId,this.friends),this.connect(),this.cancels.add(this.userSummary.$store.listen((i,o)=>{o?.summary&&i?.summary&&this.leaderboardList.invalidate()})),this.cancels.add(this.onboardingStatus.$store.listen(this.checkInteractiveFlag)),this.cancels.add(this.background.moderation.getStore().listen(this.checkInteractiveFlag)),this.cancels.add(this.settings.subscribe(this.checkInteractiveFlag)),this.cancels.add(this.onboardingStatus.$store.listen((i,o)=>{(o===void 0||i!==M.Unset)&&this.background.activeQuestionId.invalidate()})),this.background.activeQuestionId.listen(this.showInApp),this.friendsTabEnabled=j(!1),this.cancels.add(n.sdk.options.subscribe(i=>{i.friendsTab==="disabled"?this.friendsTabEnabled.set(!1):i.friendsTab==="enabled"&&this.friendsTabEnabled.set(!0)})),this.cancels.add(this.settings.subscribe(i=>{n.sdk.options.get().friendsTab==="activatedGame"&&this.friendsTabEnabled.set(!!i.inplayGame?.titleCard?.optIn)})),n.sdk.onMount({name:"gamification",clear:!0},()=>()=>{for(const i of this.cancels)i(),this.cancels.delete(i)})}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===Ee.ALLOWED}checkInteractiveFlag=()=>{const e=this.onboardingStatus.$store.get(),r=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,n=this.settings.getValues().inplayGame?.titleCard?.optIn,i=e===M.Completed,o=!r||i||n!==!0;this.background.interactiveAllowed.set(o?Ee.ALLOWED:Ee.DISALLOWED)};connect=()=>{this.onboardingProcessed.subscribe(e=>{e&&this.advertisement.connect()}),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-prediction-close",async e=>{if(!this.isInteractiveAllowed)return;const r=e.data?.attributes?.question,n=e.data?.attributes?.feedItem;if(!r||!n?.attributes)return;const{status:i,type:o,id:s,answers:a}=r;if(i===w.QuestionStatus.RESOLVED&&o===w.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),l=[...this.feedList.getValues().data||[]],c=l.findIndex(K=>K.id===s),f=l[c];let p=f?.attributes?.attributes?.value?.answerId;const S=rr(s,this.transport),A=S.subscribe(()=>{});await S.get().promise;let b=S.get().data;b||(b=await zi(s,this.transport)),A(),window.requestAnimationFrame(()=>{S.invalidate()}),p||(p=b?.answers.find(({youVoted:K})=>K)?.id);const g=a.find(({correct:K})=>K),T=p?a.find(({id:K})=>K===p):void 0,D=!!T?.correct;if(f&&l[c]?.attributes?.attributes.case==="question"){try{l[c].attributes.attributes.value.answerId=p,l[c].attributes.attributes.value.openForVoting=!1,p&&(l[c].attributes.attributes.value.status=D?it.PickHistoryStatus.WON:it.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(l)}if(!T||!g)return;this.openedQuestionId.get()?.questionId!==r.id&&this.notifications.add({type:be.QUESTION_RESOLVED,action:()=>this.openQuestion(r.id,n),close:()=>this.closeQuestion(s),autoHideDuration:D?15e3:12e3,id:u,emitEvent:!1,data:{questionId:s,questionType:w.QuestionType.PREDICTION,question:{title:D?`Congratulations! You answered correctly! You won ${g.points} pts!`:`Better luck next time! Correct: ${g?.text}!`,votedAnswer:{title:T?.text,points:T?.points},correctAnswerTitle:g?.text,correct:!!D,predictionResult:i===w.QuestionStatus.RESOLVED,questionTitle:r?.subject}}}),this.userSummary.invalidate()}})),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-questions-list",e=>{const r=[...this.feedList.getStore().value?.data||[]],n=e.data?.attributes?.feedItem,i=r.findIndex(o=>o.id===n?.id);if(n?.attributes&&n.attributes.attributes.case!=="promotion"&&!(n.attributes.status!==w.QuestionStatus.ACTIVE&&n.attributes.status!==w.QuestionStatus.RESOLVED)){if(i!==-1)if(n.attributes.attributes.case==="question"&&r[i].attributes?.attributes.case==="question"){const o=r[i];o.attributes&&(r[i]={...r[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...n.attributes.attributes.value,answerId:o.attributes.attributes.value.answerId,status:o.attributes.attributes.value.status,openForVoting:o.attributes.attributes.value.openForVoting}}}})}else{const o=r[i];o.attributes&&n.attributes&&(r[i]={...r[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...n.attributes.attributes.value}}}})}i===-1&&(r.unshift(n),U.emit("poll",{action:"received",payload:{questionId:n.id,questionType:n.attributes?.type}})),this.feedList.getStore().mutate(r)}}))};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-prediction-close"),this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitAnswer=async(e,r)=>{const n=rr(e,this.transport),i=n.subscribe(()=>{}),o={...n.get().data||{}},s=()=>{const a=this.feedList.getValues().data;if(!a)return;const u=a.findIndex(f=>f.id===e),l=a[u],c=l?.attributes?.attributes.case==="question"&&l.attributes.attributes.value;if(c){U.emit("poll",{action:"voted",payload:{questionId:e,questionType:c.questionType}});const f=n.get().data;if(i(),f){const p=f.answers.find(g=>g.correct===!0),S=f.answers.findIndex(g=>g.id===r),A=f.answers[S],b=f.answers.every(({percentageDecimal:g},T)=>g===o?.answers[T].percentageDecimal);a[u].attributes.attributes.value.answerId=r,a[u].attributes.attributes.value.openForVoting=!1,a[u].attributes.attributes.value.text=A?.text||"",p&&(a[u].attributes.attributes.value.status=p.id===r?it.PickHistoryStatus.WON:it.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...a]),f.answers[S].correct=p?.id===r,f.answers[S].youVoted=!0,b&&f.answers.forEach(g=>{g.percentageDecimal=0}),p?.id===r&&(f.answers[S].pointsEarned=f.status===w.QuestionStatus.RESOLVED?0:p.points),n.mutate({...f})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await so(this.transport,{questionId:e,answerId:r}),s()}catch(a){if(a.message===Je.ALREADY_VOTED){this.userSummary.invalidate();const u=n.subscribe(()=>{});n.invalidate(),u()}throw a}};openQuestion=(e,r)=>{if(!e)return()=>{};this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}),{animateHiding:!1});let n=r?.attributes?.type;return n||(n=(this.feedList.getStore().value?.data||[]).find(o=>o.id===e)?.attributes?.type),U.emit("poll",{action:"opened",payload:{questionId:e,questionType:n,questionOpenedFrom:r?.openedFrom}}),this.background.openQuestion(e,r)};getFeedItem=e=>xi(e,this.transport);isOpenedQuestion=e=>!!this.notifications.isViewed(e);closeQuestion=e=>(e&&this.onQuestionActivate({stage:"deactivate",id:e,isViewed:!!this.notifications.isViewed(this.background.getCurrentSessionId({prefix:"notification",entity:e}))}),this.background.closeQuestion(e));openUser=async e=>{const r=this.leaderboardList.$store.get().data?.find(i=>i.userId===e);if(!r){this.openedUser.set(r);return}if(r.summaryLoaded){this.openedUser.set(r);return}const n={...r};try{const i=await Lo(this.background.slStreamId,this.background.userId,this.friends,e,this.transport);i?.inTop!==void 0&&(this.leaderboardList.$store.setKey("data",this.leaderboardList.$store.get().data?.map(o=>(o.userId===e&&(o.inTop=i.inTop),o))),n.inTop=i.inTop)}catch(i){console.error(i)}this.openedUser.set(n)};closeUser=()=>{this.openedUser.set(void 0)};showInApp=e=>{const r=this.onboardingStatus.$store.get();if(e&&e.data&&r&&r!==M.Unset&&e.data.question?.id!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==w.SilenceSetting.ON&&e.data.question.status===w.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(Po.has(e.data.question.type))this.isInteractiveAllowed&&e.data.question.notification!==void 0&&this.notifications.add({type:be.QUESTION,action:()=>this.openQuestion(e.data?.question?.id,e.data?.feedItem),close:()=>this.closeQuestion(e.data?.question?.id),autoHideDuration:1e3*60,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),emitEvent:!0,data:{questionId:e.data.question.id,questionType:e.data.question.type,question:{title:e.data.question.notification.title}}});else if(e.data.question.type===w.QuestionType.FACTOID){const n=e.data.question.options?.options.value,i=e.data.question.notification?.title||e.data.question.subject||"",o=e.data.question.notification?.body||n.body,s={heading:i,body:o,imageMode:n?.imageMode,image:n?.image,video:{id:n?.video?.id||"",url:n?.video?.url||"",thumbnailUrl:n?.video?.thumbnailUrl||""},webLink:{label:"",url:""}};this.notifications.add({type:be.QUESTION,action:()=>this.openQuestion(e?.data?.question?.id,e?.data?.feedItem),close:()=>this.closeQuestion(e?.data?.question?.id),autoHideDuration:1e3*120,emitEvent:!0,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionId:e.data.question.id,questionType:e.data.question.type,insight:s}})}else if(e.data.question.type===w.QuestionType.TWEET&&e.data.question.notification!==void 0){const n=e.data.question.options?.options.value,i={title:e.data.question.notification?.title,body:e.data.question.notification?.body,image:e.data.question.notification?.image,account:n?.tweetMeta?.account||"",accountVerified:!!n?.tweetMeta?.accountVerified,tweet:n?.tweetMeta?.tweet,tweetId:e.data.question.id};this.notifications.add({type:be.QUESTION,action:()=>this.openQuestion(e.data?.question?.id,e.data?.feedItem),close:()=>this.closeQuestion(e.data?.question?.id),autoHideDuration:1e3*120,emitEvent:!0,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionId:e.data.question.id,questionType:e.data.question.type,tweet:i}})}}}}const Fo={[V.SdkOverlayType.GAMES]:!0};class Do extends bn{constructor(e,r){super(e,r)}}const Ro=(t,e,r)=>t.type===V.SdkOverlayType.GAMES?new No(t,e,r):new Do(t,e),Vo=(t,e,r)=>{t.features=new Map,t.sdk.featuresList=new Y(j(new Set),"features-list"),t.activeFeature=new Y(j(V.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=n=>t.features.get(n),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=n=>{t.activeFeature.setValue(n)},t.sdk.closeFeature=(n=!1)=>{const i=t.activeFeature.getValue();if(t.activeFeature.setValue(V.SdkOverlayType.UNSET),n&&i){t.features.delete(i);const o=t.sdk.featuresList.getValue();o&&o.delete(i),t.sdk.featuresList.setValue(o)}},t.initFeature=(n,i=fe.ORGANIZATION)=>{if(n.type in Fo&&!t.features.has(n.type)){const o=Ro(n,i,t);t.features.set(n.type,o);let s=t.sdk.featuresList.getValue();s?s.add(n.type):s=new Set([n.type]),t.sdk.featuresList.setValue(new Set(s))}},t.updateFeature=(n,i)=>{t.features.get(n.type)?.update(n,i)},t.destroyFeature=n=>{t.features.delete(n.type);const i=t.sdk.featuresList.getValue();i&&i.delete(n.type),t.sdk.featuresList.setValue(new Set(i))},t.reinitializeFeatures=async()=>{const n=await t.stores.organizationSettings.getValue();t.features.clear(),t.sdk.featuresList.setValue(new Set);for(const i of n?.overlays||[])t.initFeature(i,fe.ORGANIZATION)},t.stores.providerStreamId.listen(n=>{n||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const n=(o,s)=>{if(s?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&o===fe.ORGANIZATION))for(const a of s.overlays)a.sdkEnable===!0&&(t.features.has(a.type)?t.updateFeature(a,o):t.initFeature(a,o))},i={organizationSettings:o=>{if(o.data)try{n(fe.ORGANIZATION,o.data)}catch(s){console.log(s)}},streamSettings:o=>{if(o.data)try{n(fe.STREAM,o.data)}catch(s){console.log(s)}}};t.store.subscribe(i)},r()};class $o{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="invitation")switch(n.slEventBus.action){case"sent":this.sent(n.slEventBus.payload);break}};return U.listen(r)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_ACCEPTED},category:ot.InvitationCategory.GAMES,from:ot.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_SENT},category:ot.InvitationCategory.GAMES,from:e||ot.InvitationFrom.UNSET})}}class qo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="interactions")switch(n.slEventBus.action){case"tap":this.tap();break;case"scroll":this.scroll();break}};return U.listen(r)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:Nr.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:Nr.InteractionActionType.SCROLL})}}const Bo={[w.PromotionType.UNSET]:v.TopicSubType.UNSET,[w.PromotionType.INGAME_IAB21]:v.TopicSubType.PROMOTION_INGAME_IAB21,[w.PromotionType.INGAME_IAB11_LBAR]:v.TopicSubType.PROMOTION_INGAME_IAB11_LBAR,[w.PromotionType.INGAME_IAB11]:v.TopicSubType.PROMOTION_INGAME_IAB11,[w.PromotionType.INGAME_IAB21_LBAR]:v.TopicSubType.PROMOTION_INGAME_IAB21_LBAR,[w.PromotionType.INGAME_IAB61]:v.TopicSubType.PROMOTION_INGAME_IAB61,[w.PromotionType.EXTERNAL_AD]:v.TopicSubType.PROMOTION_GAM},nr=t=>t?Bo[t]:v.TopicSubType.UNSET;class Mo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(!n.slEventBus?.skipAnalytics&&n.slEventBus?.type==="advertisement"){const i=nr(n.slEventBus.payload.type);switch(n.slEventBus.action){case"videoPlay":this.videoPlay(n.slEventBus.payload,{topicSubType:i});break;case"buttonSelect":this.buttonSelect(n.slEventBus.payload,{topicSubType:i});break;case"bannerSelect":this.bannerSelect(n.slEventBus.payload,{topicSubType:i});break;case"received":this.received(n.slEventBus.payload,{topicSubType:i});break;case"opened":this.opened(n.slEventBus.payload,{topicSubType:i});break;case"viewed":this.viewed(n.slEventBus.payload,{topicSubType:i});break}}};return U.listen(r)})}received=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_RECEIVED,topicId:e,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})};opened=({id:e,openedFrom:r},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_OPENED,topicId:e,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:r==="notification"?v.PollOpenedFrom.IN_APP:v.PollOpenedFrom.UNSET})};viewed=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_OPENED,topicId:e,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})};videoPlay=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:v.Kind.AD_VIDEO_PLAYED,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})};buttonSelect=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:v.Kind.AD_BUTTON_NAVIGATED,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})};bannerSelect=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:v.Kind.AD_BANNER_NAVIGATED,topicType:v.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:v.PollOpenedFrom.UNSET})}}const We={[w.QuestionType.UNSET]:v.TopicType.UNSET,[w.QuestionType.FACTOID]:v.TopicType.POLLS_INSIGHT,[w.QuestionType.POLL]:v.TopicType.POLLS_POLL,[w.QuestionType.PREDICTION]:v.TopicType.POLLS_PREDICTION,[w.QuestionType.PROMOTION]:v.TopicType.POLLS_PROMOTION,[w.QuestionType.TRIVIA]:v.TopicType.POLLS_TRIVIA,[w.QuestionType.TWEET]:v.TopicType.POLLS_TWITTER};w.QuestionType.UNSET+"",ee.NotificationKind.UNSET,w.QuestionType.FACTOID+"",ee.NotificationKind.POLLS,w.QuestionType.POLL+"",ee.NotificationKind.POLLS,w.QuestionType.PREDICTION+"",ee.NotificationKind.POLLS,w.QuestionType.PROMOTION+"",ee.NotificationKind.POLLS,w.QuestionType.TRIVIA+"",ee.NotificationKind.POLLS,w.QuestionType.TWEET+"",ee.NotificationKind.POLLS;const Uo={[V.SdkOverlayType.UNSET]:v.Category.UNSET,[V.SdkOverlayType.INPLAY]:v.Category.INPLAY,[V.SdkOverlayType.MESSAGING]:v.Category.MESSAGING,[V.SdkOverlayType.STATISTICS]:v.Category.STATS,[V.SdkOverlayType.BETTING]:v.Category.BETTING,[V.SdkOverlayType.TWITTER]:v.Category.TWITTER,[V.SdkOverlayType.MERCHANDISE]:v.Category.MERCHANDISE,[V.SdkOverlayType.CONTESTS]:v.Category.CONTESTS,[V.SdkOverlayType.VOICE_CHAT]:v.Category.CALLING,[V.SdkOverlayType.TICKETS]:v.Category.TICKETS,[V.SdkOverlayType.WHOIS_WATCHING]:v.Category.WHOISWATCHING,[V.SdkOverlayType.PROFILE]:v.Category.PROFILE,[V.SdkOverlayType.GAMES]:v.Category.POLLS,[V.SdkOverlayType.GOLF_STATISTICS]:v.Category.STATS,[V.SdkOverlayType.HIGHLIGHTS]:v.Category.HIGHLIGHTS,[V.SdkOverlayType.PUBLIC_CHAT]:v.Category.PUBLIC_CHAT};class jo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="notification")switch(n.slEventBus.action){case"rendered":this.received(n.slEventBus.payload);break;case"opened":this.opened(n.slEventBus.payload);break}if(n.slEventBus?.type==="advertisement")switch(n.slEventBus.action){case"notification-received":this.received({questionId:n.slEventBus.payload.id,questionType:w.QuestionType.PROMOTION,topicSubType:nr(n.slEventBus.payload.type)});break;case"notification-opened":this.opened({questionId:n.slEventBus.payload.id,questionType:w.QuestionType.PROMOTION,topicSubType:nr(n.slEventBus.payload.type)});break}};return U.listen(r)})}received=({questionId:e,questionType:r,topicSubType:n})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:r?We[r]:v.TopicType.UNSET,topicSubType:n},notificationKind:ee.NotificationKind.POLLS,notificationType:ee.NotificationType.IN_APP})};opened=({questionId:e,questionType:r,topicSubType:n})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_OPENED,topicId:e,topicType:r?We[r]:v.TopicType.UNSET,topicSubType:n},notificationKind:ee.NotificationKind.POLLS,notificationType:ee.NotificationType.IN_APP})}}class Qo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(n.slEventBus?.type==="poll")switch(n.slEventBus.action){case"voted":this.voted(n.slEventBus.payload);break;case"navigated":this.navigated();break;case"onboardingPassed":this.onboardingPassed();break;case"received":this.received(n.slEventBus.payload);break;case"opened":this.opened(n.slEventBus.payload);break}};return U.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_RECEIVED,topicId:e,topicType:r?We[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};opened=({questionId:e,questionType:r,questionOpenedFrom:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_OPENED,topicId:e,topicType:r?We[r]:v.TopicType.UNSET},pollOpenedFrom:n==="list"?v.PollOpenedFrom.PICK_HISTORY:v.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_VOTE,topicId:e,topicType:r?We[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.GAMES_JOINED},pollOpenedFrom:v.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_NAVIGATED},pollOpenedFrom:v.PollOpenedFrom.UNSET})}}const xo=({transport:t,$commonStore:e})=>{let r;const n=j(!1),i=5e3,{client:o,queryKey:s}=t.createPromiseClient(pn.AnalyticsService,{method:"send",params:[n]}),a=t.nanoquery.createFetcherStore(s,{fetcher:async()=>{const p=e.getStore().get();try{await o.unary({message:{case:"heartbeat",value:{common:{...p,kind:v.Kind.SESSION_HEARTBEAT}}}})}catch(S){he.error(S,"send heartbeat failed")}return Date.now()},refetchInterval:i}),u=()=>{he.debug("mounted heartbeat"),r=a.subscribe(()=>{})},l=()=>{he.debug("enabled heartbeat"),n.set(!0),a.lc===0&&u()},c=()=>{he.debug("disabled heartbeat"),n.set(!1)};return{enable:l,disable:c,mount:u,unmount:()=>{he.debug("unmounted heartbeat"),a.off(),r?.(),r=void 0,c()}}},he=ue("analytics");class Go{commonStore;notifications;polls;invitation;interactions;advertisement;heartbeat;analyticsClient;listeners;listenersCancels;connected=!1;constructor(e){this.listeners=new Set,this.listenersCancels=new Set,this.commonStore=new Ae(H({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=xo({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new jo(this),this.polls=new Qo(this),this.invitation=new $o(this),this.interactions=new qo(this),this.advertisement=new Mo(this);const{client:r}=e.analyticsTransport.createPromiseClient(pn.AnalyticsService,{method:"send"});this.analyticsClient=r}connect=()=>{this.writeCommon("sessionId",Xt.nanoid()),this.heartbeat.enable(),this.listeners.forEach(e=>this.listenersCancels.add(e())),this.connected=!0,he.debug("analytics connected")};disconnect=()=>{this.writeCommon("sessionId",""),this.writeCommon("overlaySessionId",""),this.heartbeat.unmount(),this.listenersCancels.forEach(e=>e()),this.connected=!1,he.debug("analytics disconnected")};write=(e,r)=>{r&&this.analyticsClient.unary({message:{case:e,value:r}}).then(()=>{he.trace("send analytics success",e,r)}).catch(n=>{he.error(n,"send analytics failed")})};writeCommon=(e,r)=>{this.commonStore.setValue(e,r)};onConnect=e=>{this.listeners.add(e),this.connected&&this.listenersCancels.add(e())};connectToSDK=e=>{this.onConnect(()=>e.stores.slStreamId.getAtomStore().subscribe(r=>{this.writeCommon("eventId",r)})),this.onConnect(()=>e.sdk.getActiveFeature().subscribe(r=>{r&&this.writeCommon("category",Uo[r]),r!==V.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",Xt.nanoid()):this.writeCommon("overlaySessionId","")})),this.onConnect(()=>{const r=window.matchMedia("(orientation: portrait)"),n=i=>{this.writeCommon("screenOrientation",i.matches?v.ScreenOrientation.PORTRAIT:v.ScreenOrientation.LANDSCAPE)};return r.addEventListener("change",n),()=>{r.removeEventListener("change",n)}}),this.onConnect(()=>e.deepLink.$store.subscribe(r=>{r?.handled&&this.invitation.accepted()}))}}const Ko=(t,e,r)=>{t.analytics=new Go(t),t.sdk.onMount({name:"analytics"},()=>(t.analytics.connect(),()=>{t.analytics.disconnect()})),r()};var yr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mr={exports:{}},gr={exports:{}};function Ho(t){var e=new t,r=e;function n(){var o=e;return o.next?e=o.next:(e=new t,r=e),o.next=null,o}function i(o){r.next=o,r=o}return{get:n,release:i}}var Wo=Ho,Yo=Wo;function On(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),!(r>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");var n=Yo(Jo),i=null,o=null,s=0,a=null,u={push:b,drain:W,saturated:W,pause:c,paused:!1,get concurrency(){return r},set concurrency(N){if(!(N>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");if(r=N,!u.paused)for(;i&&s<r;)s++,T()},running:l,resume:S,idle:A,length:f,getQueue:p,unshift:g,empty:W,kill:D,killAndDrain:K,error:X};return u;function l(){return s}function c(){u.paused=!0}function f(){for(var N=i,$=0;N;)N=N.next,$++;return $}function p(){for(var N=i,$=[];N;)$.push(N.value),N=N.next;return $}function S(){if(u.paused){if(u.paused=!1,i===null){s++,T();return}for(;i&&s<r;)s++,T()}}function A(){return s===0&&u.length()===0}function b(N,$){var C=n.get();C.context=t,C.release=T,C.value=N,C.callback=$||W,C.errorHandler=a,s>=r||u.paused?o?(o.next=C,o=C):(i=C,o=C,u.saturated()):(s++,e.call(t,C.value,C.worked))}function g(N,$){var C=n.get();C.context=t,C.release=T,C.value=N,C.callback=$||W,C.errorHandler=a,s>=r||u.paused?i?(C.next=i,i=C):(i=C,o=C,u.saturated()):(s++,e.call(t,C.value,C.worked))}function T(N){N&&n.release(N);var $=i;$&&s<=r?u.paused?s--:(o===i&&(o=null),i=$.next,$.next=null,e.call(t,$.value,$.worked),o===null&&u.empty()):--s===0&&u.drain()}function D(){i=null,o=null,u.drain=W}function K(){i=null,o=null,u.drain(),u.drain=W}function X(N){a=N}}function W(){}function Jo(){this.value=null,this.callback=W,this.next=null,this.release=W,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,n){var i=t.callback,o=t.errorHandler,s=t.value;t.value=null,t.callback=W,t.errorHandler&&o(r,s),i.call(t.context,r,n),t.release(t)}}function Xo(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function n(c,f){e.call(this,c).then(function(p){f(null,p)},f)}var i=On(t,n,r),o=i.push,s=i.unshift;return i.push=a,i.unshift=u,i.drained=l,i;function a(c){var f=new Promise(function(p,S){o(c,function(A,b){if(A){S(A);return}p(b)})});return f.catch(W),f}function u(c){var f=new Promise(function(p,S){s(c,function(A,b){if(A){S(A);return}p(b)})});return f.catch(W),f}function l(){if(i.idle())return new Promise(function(p){p()});var c=i.drain,f=new Promise(function(p){i.drain=function(){c(),p()}});return f}}gr.exports=On;gr.exports.promise=Xo;var _n=gr.exports,br={exports:{}},Me=typeof Reflect=="object"?Reflect:null,Ur=Me&&typeof Me.apply=="function"?Me.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},lt;Me&&typeof Me.ownKeys=="function"?lt=Me.ownKeys:Object.getOwnPropertySymbols?lt=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:lt=function(e){return Object.getOwnPropertyNames(e)};function Zo(t){console&&console.warn&&console.warn(t)}var Cn=Number.isNaN||function(e){return e!==e};function F(){F.init.call(this)}br.exports=F;br.exports.once=ns;F.EventEmitter=F;F.prototype._events=void 0;F.prototype._eventsCount=0;F.prototype._maxListeners=void 0;var jr=10;function _t(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(F,"defaultMaxListeners",{enumerable:!0,get:function(){return jr},set:function(t){if(typeof t!="number"||t<0||Cn(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");jr=t}});F.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};F.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Cn(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function kn(t){return t._maxListeners===void 0?F.defaultMaxListeners:t._maxListeners}F.prototype.getMaxListeners=function(){return kn(this)};F.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")Ur(u,this,r);else for(var l=u.length,c=Dn(u,l),n=0;n<l;++n)Ur(c[n],this,r);return!0};function Ln(t,e,r,n){var i,o,s;if(_t(r),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),s===void 0)s=o[e]=r,++t._eventsCount;else if(typeof s=="function"?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=kn(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,Zo(a)}return t}F.prototype.addListener=function(e,r){return Ln(this,e,r,!1)};F.prototype.on=F.prototype.addListener;F.prototype.prependListener=function(e,r){return Ln(this,e,r,!0)};function es(){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 Pn(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=es.bind(n);return i.listener=r,n.wrapFn=i,i}F.prototype.once=function(e,r){return _t(r),this.on(e,Pn(this,e,r)),this};F.prototype.prependOnceListener=function(e,r){return _t(r),this.prependListener(e,Pn(this,e,r)),this};F.prototype.removeListener=function(e,r){var n,i,o,s,a;if(_t(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():ts(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};F.prototype.off=F.prototype.removeListener;F.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Nn(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?rs(i):Dn(i,i.length)}F.prototype.listeners=function(e){return Nn(this,e,!0)};F.prototype.rawListeners=function(e){return Nn(this,e,!1)};F.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Fn.call(t,e)};F.prototype.listenerCount=Fn;function Fn(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}F.prototype.eventNames=function(){return this._eventsCount>0?lt(this._events):[]};function Dn(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function ts(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function rs(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function ns(t,e){return new Promise(function(r,n){function i(s){t.removeListener(e,o),n(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Rn(t,e,o,{once:!0}),e!=="error"&&is(t,i,{once:!0})})}function is(t,e,r){typeof t.on=="function"&&Rn(t,"error",e,r)}function Rn(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Vn=br.exports,Ct={},$n={},qn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(e,r);if(s.value!==i||s.enumerable!==!0)return!1}return!0},os=qn,kt=function(){return os()&&!!Symbol.toStringTag},ss=Error,as=EvalError,us=RangeError,cs=ReferenceError,Bn=SyntaxError,Lt=TypeError,ls=URIError,Qr=typeof Symbol<"u"&&Symbol,ds=qn,fs=function(){return typeof Qr!="function"||typeof Symbol!="function"||typeof Qr("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ds()},Rt={__proto__:null,foo:{}},ps=Object,hs=function(){return{__proto__:Rt}.foo===Rt.foo&&!(Rt instanceof ps)},ys="Function.prototype.bind called on incompatible ",ms=Object.prototype.toString,gs=Math.max,bs="[object Function]",xr=function(e,r){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var o=0;o<r.length;o+=1)n[o+e.length]=r[o];return n},vs=function(e,r){for(var n=[],i=r,o=0;i<e.length;i+=1,o+=1)n[o]=e[i];return n},Ss=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r},ws=function(e){var r=this;if(typeof r!="function"||ms.apply(r)!==bs)throw new TypeError(ys+r);for(var n=vs(arguments,1),i,o=function(){if(this instanceof i){var c=r.apply(this,xr(n,arguments));return Object(c)===c?c:this}return r.apply(e,xr(n,arguments))},s=gs(0,r.length-n.length),a=[],u=0;u<s;u++)a[u]="$"+u;if(i=Function("binder","return function ("+Ss(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i},Ts=ws,vr=Function.prototype.bind||Ts,As=Function.prototype.call,Es=Object.prototype.hasOwnProperty,Is=vr,Os=Is.call(As,Es),_,_s=ss,Cs=as,ks=us,Ls=cs,je=Bn,Ue=Lt,Ps=ls,Mn=Function,Vt=function(t){try{return Mn('"use strict"; return ('+t+").constructor;")()}catch{}},Ie=Object.getOwnPropertyDescriptor;if(Ie)try{Ie({},"")}catch{Ie=null}var $t=function(){throw new Ue},Ns=Ie?function(){try{return arguments.callee,$t}catch{try{return Ie(arguments,"callee").get}catch{return $t}}}():$t,Fe=fs(),Fs=hs(),Q=Object.getPrototypeOf||(Fs?function(t){return t.__proto__}:null),Re={},Ds=typeof Uint8Array>"u"||!Q?_:Q(Uint8Array),Oe={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?_:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?_:ArrayBuffer,"%ArrayIteratorPrototype%":Fe&&Q?Q([][Symbol.iterator]()):_,"%AsyncFromSyncIteratorPrototype%":_,"%AsyncFunction%":Re,"%AsyncGenerator%":Re,"%AsyncGeneratorFunction%":Re,"%AsyncIteratorPrototype%":Re,"%Atomics%":typeof Atomics>"u"?_:Atomics,"%BigInt%":typeof BigInt>"u"?_:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?_:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?_:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?_:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":_s,"%eval%":eval,"%EvalError%":Cs,"%Float32Array%":typeof Float32Array>"u"?_:Float32Array,"%Float64Array%":typeof Float64Array>"u"?_:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?_:FinalizationRegistry,"%Function%":Mn,"%GeneratorFunction%":Re,"%Int8Array%":typeof Int8Array>"u"?_:Int8Array,"%Int16Array%":typeof Int16Array>"u"?_:Int16Array,"%Int32Array%":typeof Int32Array>"u"?_:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Fe&&Q?Q(Q([][Symbol.iterator]())):_,"%JSON%":typeof JSON=="object"?JSON:_,"%Map%":typeof Map>"u"?_:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Fe||!Q?_:Q(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?_:Promise,"%Proxy%":typeof Proxy>"u"?_:Proxy,"%RangeError%":ks,"%ReferenceError%":Ls,"%Reflect%":typeof Reflect>"u"?_:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?_:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Fe||!Q?_:Q(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?_:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Fe&&Q?Q(""[Symbol.iterator]()):_,"%Symbol%":Fe?Symbol:_,"%SyntaxError%":je,"%ThrowTypeError%":Ns,"%TypedArray%":Ds,"%TypeError%":Ue,"%Uint8Array%":typeof Uint8Array>"u"?_:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?_:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?_:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?_:Uint32Array,"%URIError%":Ps,"%WeakMap%":typeof WeakMap>"u"?_:WeakMap,"%WeakRef%":typeof WeakRef>"u"?_:WeakRef,"%WeakSet%":typeof WeakSet>"u"?_:WeakSet};if(Q)try{null.error}catch(t){var Rs=Q(Q(t));Oe["%Error.prototype%"]=Rs}var Vs=function t(e){var r;if(e==="%AsyncFunction%")r=Vt("async function () {}");else if(e==="%GeneratorFunction%")r=Vt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Vt("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&Q&&(r=Q(i.prototype))}return Oe[e]=r,r},Gr={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Ze=vr,bt=Os,$s=Ze.call(Function.call,Array.prototype.concat),qs=Ze.call(Function.apply,Array.prototype.splice),Kr=Ze.call(Function.call,String.prototype.replace),vt=Ze.call(Function.call,String.prototype.slice),Bs=Ze.call(Function.call,RegExp.prototype.exec),Ms=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Us=/\\(\\)?/g,js=function(e){var r=vt(e,0,1),n=vt(e,-1);if(r==="%"&&n!=="%")throw new je("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new je("invalid intrinsic syntax, expected opening `%`");var i=[];return Kr(e,Ms,function(o,s,a,u){i[i.length]=a?Kr(u,Us,"$1"):s||o}),i},Qs=function(e,r){var n=e,i;if(bt(Gr,n)&&(i=Gr[n],n="%"+i[0]+"%"),bt(Oe,n)){var o=Oe[n];if(o===Re&&(o=Vs(n)),typeof o>"u"&&!r)throw new Ue("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new je("intrinsic "+e+" does not exist!")},et=function(e,r){if(typeof e!="string"||e.length===0)throw new Ue("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Ue('"allowMissing" argument must be a boolean');if(Bs(/^%?[^%]*%?$/,e)===null)throw new je("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=js(e),i=n.length>0?n[0]:"",o=Qs("%"+i+"%",r),s=o.name,a=o.value,u=!1,l=o.alias;l&&(i=l[0],qs(n,$s([0,1],l)));for(var c=1,f=!0;c<n.length;c+=1){var p=n[c],S=vt(p,0,1),A=vt(p,-1);if((S==='"'||S==="'"||S==="`"||A==='"'||A==="'"||A==="`")&&S!==A)throw new je("property names with quotes must have matching quotes");if((p==="constructor"||!f)&&(u=!0),i+="."+p,s="%"+i+"%",bt(Oe,s))a=Oe[s];else if(a!=null){if(!(p in a)){if(!r)throw new Ue("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ie&&c+1>=n.length){var b=Ie(a,p);f=!!b,f&&"get"in b&&!("originalValue"in b.get)?a=b.get:a=a[p]}else f=bt(a,p),a=a[p];f&&!u&&(Oe[s]=a)}}return a},Un={exports:{}},qt,zr;function Sr(){if(zr)return qt;zr=1;var t=et,e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return qt=e,qt}var xs=et,dt=xs("%Object.getOwnPropertyDescriptor%",!0);if(dt)try{dt([],"length")}catch{dt=null}var Pt=dt,Hr=Sr(),Gs=Bn,De=Lt,Wr=Pt,Ks=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new De("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new De("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new De("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new De("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new De("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new De("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,u=!!Wr&&Wr(e,r);if(Hr)Hr(e,r,{configurable:s===null&&u?u.configurable:!s,enumerable:i===null&&u?u.enumerable:!i,value:n,writable:o===null&&u?u.writable:!o});else if(a||!i&&!o&&!s)e[r]=n;else throw new Gs("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ir=Sr(),jn=function(){return!!ir};jn.hasArrayLengthDefineBug=function(){if(!ir)return null;try{return ir([],"length",{value:1}).length!==1}catch{return!0}};var zs=jn,Hs=et,Yr=Ks,Ws=zs(),Jr=Pt,Xr=Lt,Ys=Hs("%Math.floor%"),Js=function(e,r){if(typeof e!="function")throw new Xr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Ys(r)!==r)throw new Xr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in e&&Jr){var s=Jr(e,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(Ws?Yr(e,"length",r,!0,!0):Yr(e,"length",r)),e};(function(t){var e=vr,r=et,n=Js,i=Lt,o=r("%Function.prototype.apply%"),s=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(s,o),u=Sr(),l=r("%Math.max%");t.exports=function(p){if(typeof p!="function")throw new i("a function is required");var S=a(e,s,arguments);return n(S,1+l(0,p.length-(arguments.length-1)),!0)};var c=function(){return a(e,o,arguments)};u?u(t.exports,"apply",{value:c}):t.exports.apply=c})(Un);var wr=Un.exports,Qn=et,xn=wr,Xs=xn(Qn("String.prototype.indexOf")),Tr=function(e,r){var n=Qn(e,!!r);return typeof n=="function"&&Xs(e,".prototype.")>-1?xn(n):n},Zs=kt(),ea=Tr,or=ea("Object.prototype.toString"),Nt=function(e){return Zs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:or(e)==="[object Arguments]"},Gn=function(e){return Nt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&or(e)!=="[object Array]"&&or(e.callee)==="[object Function]"},ta=function(){return Nt(arguments)}();Nt.isLegacyArguments=Gn;var ra=ta?Nt:Gn,na=Object.prototype.toString,ia=Function.prototype.toString,oa=/^\s*(?:function)?\*/,Kn=kt(),Bt=Object.getPrototypeOf,sa=function(){if(!Kn)return!1;try{return Function("return function*() {}")()}catch{}},Mt,aa=function(e){if(typeof e!="function")return!1;if(oa.test(ia.call(e)))return!0;if(!Kn){var r=na.call(e);return r==="[object GeneratorFunction]"}if(!Bt)return!1;if(typeof Mt>"u"){var n=sa();Mt=n?Bt(n):!1}return Bt(e)===Mt},zn=Function.prototype.toString,qe=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,sr,ft;if(typeof qe=="function"&&typeof Object.defineProperty=="function")try{sr=Object.defineProperty({},"length",{get:function(){throw ft}}),ft={},qe(function(){throw 42},null,sr)}catch(t){t!==ft&&(qe=null)}else qe=null;var ua=/^\s*class\b/,ar=function(e){try{var r=zn.call(e);return ua.test(r)}catch{return!1}},Ut=function(e){try{return ar(e)?!1:(zn.call(e),!0)}catch{return!1}},pt=Object.prototype.toString,ca="[object Object]",la="[object Function]",da="[object GeneratorFunction]",fa="[object HTMLAllCollection]",pa="[object HTML document.all class]",ha="[object HTMLCollection]",ya=typeof Symbol=="function"&&!!Symbol.toStringTag,ma=!(0 in[,]),ur=function(){return!1};if(typeof document=="object"){var ga=document.all;pt.call(ga)===pt.call(document.all)&&(ur=function(e){if((ma||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=pt.call(e);return(r===fa||r===pa||r===ha||r===ca)&&e("")==null}catch{}return!1})}var ba=qe?function(e){if(ur(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{qe(e,null,sr)}catch(r){if(r!==ft)return!1}return!ar(e)&&Ut(e)}:function(e){if(ur(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(ya)return Ut(e);if(ar(e))return!1;var r=pt.call(e);return r!==la&&r!==da&&!/^\[object HTML/.test(r)?!1:Ut(e)},va=ba,Sa=Object.prototype.toString,Hn=Object.prototype.hasOwnProperty,wa=function(e,r,n){for(var i=0,o=e.length;i<o;i++)Hn.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Ta=function(e,r,n){for(var i=0,o=e.length;i<o;i++)n==null?r(e.charAt(i),i,e):r.call(n,e.charAt(i),i,e)},Aa=function(e,r,n){for(var i in e)Hn.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Ea=function(e,r,n){if(!va(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),Sa.call(e)==="[object Array]"?wa(e,r,i):typeof e=="string"?Ta(e,r,i):Aa(e,r,i)},Wn=Ea,Ia=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],jt=Ia,Oa=typeof globalThis>"u"?yr:globalThis,Yn=function(){for(var e=[],r=0;r<jt.length;r++)typeof Oa[jt[r]]=="function"&&(e[e.length]=jt[r]);return e},St=Wn,_a=Yn,Zr=wr,Ar=Tr,ht=Pt,Ca=Ar("Object.prototype.toString"),Jn=kt(),en=typeof globalThis>"u"?yr:globalThis,cr=_a(),Er=Ar("String.prototype.slice"),Qt=Object.getPrototypeOf,ka=Ar("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},wt={__proto__:null};Jn&&ht&&Qt?St(cr,function(t){var e=new en[t];if(Symbol.toStringTag in e){var r=Qt(e),n=ht(r,Symbol.toStringTag);if(!n){var i=Qt(r);n=ht(i,Symbol.toStringTag)}wt["$"+t]=Zr(n.get)}}):St(cr,function(t){var e=new en[t],r=e.slice||e.set;r&&(wt["$"+t]=Zr(r))});var La=function(e){var r=!1;return St(wt,function(n,i){if(!r)try{"$"+n(e)===i&&(r=Er(i,1))}catch{}}),r},Pa=function(e){var r=!1;return St(wt,function(n,i){if(!r)try{n(e),r=Er(i,1)}catch{}}),r},Na=function(e){if(!e||typeof e!="object")return!1;if(!Jn){var r=Er(Ca(e),8,-1);return ka(cr,r)>-1?r:r!=="Object"?!1:Pa(e)}return ht?La(e):null},Tt=Wn,Fa=Yn,tn=wr,Ir=Tr,yt=Pt,Da=Ir("Object.prototype.toString"),Xn=kt(),rn=typeof globalThis>"u"?yr:globalThis,lr=Fa(),Or=Ir("String.prototype.slice"),xt=Object.getPrototypeOf,Ra=Ir("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},At={__proto__:null};Xn&&yt&&xt?Tt(lr,function(t){var e=new rn[t];if(Symbol.toStringTag in e){var r=xt(e),n=yt(r,Symbol.toStringTag);if(!n){var i=xt(r);n=yt(i,Symbol.toStringTag)}At["$"+t]=tn(n.get)}}):Tt(lr,function(t){var e=new rn[t],r=e.slice||e.set;r&&(At["$"+t]=tn(r))});var Va=function(e){var r=!1;return Tt(At,function(n,i){if(!r)try{"$"+n(e)===i&&(r=Or(i,1))}catch{}}),r},$a=function(e){var r=!1;return Tt(At,function(n,i){if(!r)try{n(e),r=Or(i,1)}catch{}}),r},qa=function(e){if(!e||typeof e!="object")return!1;if(!Xn){var r=Or(Da(e),8,-1);return Ra(lr,r)>-1?r:r!=="Object"?!1:$a(e)}return yt?Va(e):null},Ba=qa,Ma=function(e){return!!Ba(e)};(function(t){var e=ra,r=aa,n=Na,i=Ma;function o(y){return y.call.bind(y)}var s=typeof BigInt<"u",a=typeof Symbol<"u",u=o(Object.prototype.toString),l=o(Number.prototype.valueOf),c=o(String.prototype.valueOf),f=o(Boolean.prototype.valueOf);if(s)var p=o(BigInt.prototype.valueOf);if(a)var S=o(Symbol.prototype.valueOf);function A(y,oi){if(typeof y!="object")return!1;try{return oi(y),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=i;function b(y){return typeof Promise<"u"&&y instanceof Promise||y!==null&&typeof y=="object"&&typeof y.then=="function"&&typeof y.catch=="function"}t.isPromise=b;function g(y){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(y):i(y)||h(y)}t.isArrayBufferView=g;function T(y){return n(y)==="Uint8Array"}t.isUint8Array=T;function D(y){return n(y)==="Uint8ClampedArray"}t.isUint8ClampedArray=D;function K(y){return n(y)==="Uint16Array"}t.isUint16Array=K;function X(y){return n(y)==="Uint32Array"}t.isUint32Array=X;function N(y){return n(y)==="Int8Array"}t.isInt8Array=N;function $(y){return n(y)==="Int16Array"}t.isInt16Array=$;function C(y){return n(y)==="Int32Array"}t.isInt32Array=C;function re(y){return n(y)==="Float32Array"}t.isFloat32Array=re;function ne(y){return n(y)==="Float64Array"}t.isFloat64Array=ne;function _e(y){return n(y)==="BigInt64Array"}t.isBigInt64Array=_e;function ve(y){return n(y)==="BigUint64Array"}t.isBigUint64Array=ve;function ce(y){return u(y)==="[object Map]"}ce.working=typeof Map<"u"&&ce(new Map);function Ft(y){return typeof Map>"u"?!1:ce.working?ce(y):y instanceof Map}t.isMap=Ft;function ge(y){return u(y)==="[object Set]"}ge.working=typeof Set<"u"&&ge(new Set);function Ke(y){return typeof Set>"u"?!1:ge.working?ge(y):y instanceof Set}t.isSet=Ke;function Ce(y){return u(y)==="[object WeakMap]"}Ce.working=typeof WeakMap<"u"&&Ce(new WeakMap);function Dt(y){return typeof WeakMap>"u"?!1:Ce.working?Ce(y):y instanceof WeakMap}t.isWeakMap=Dt;function ke(y){return u(y)==="[object WeakSet]"}ke.working=typeof WeakSet<"u"&&ke(new WeakSet);function le(y){return ke(y)}t.isWeakSet=le;function Le(y){return u(y)==="[object ArrayBuffer]"}Le.working=typeof ArrayBuffer<"u"&&Le(new ArrayBuffer);function tt(y){return typeof ArrayBuffer>"u"?!1:Le.working?Le(y):y instanceof ArrayBuffer}t.isArrayBuffer=tt;function d(y){return u(y)==="[object DataView]"}d.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&d(new DataView(new ArrayBuffer(1),0,1));function h(y){return typeof DataView>"u"?!1:d.working?d(y):y instanceof DataView}t.isDataView=h;var m=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function E(y){return u(y)==="[object SharedArrayBuffer]"}function L(y){return typeof m>"u"?!1:(typeof E.working>"u"&&(E.working=E(new m)),E.working?E(y):y instanceof m)}t.isSharedArrayBuffer=L;function P(y){return u(y)==="[object AsyncFunction]"}t.isAsyncFunction=P;function O(y){return u(y)==="[object Map Iterator]"}t.isMapIterator=O;function k(y){return u(y)==="[object Set Iterator]"}t.isSetIterator=k;function R(y){return u(y)==="[object Generator]"}t.isGeneratorObject=R;function z(y){return u(y)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=z;function Se(y){return A(y,l)}t.isNumberObject=Se;function rt(y){return A(y,c)}t.isStringObject=rt;function Pe(y){return A(y,f)}t.isBooleanObject=Pe;function nt(y){return s&&A(y,p)}t.isBigIntObject=nt;function kr(y){return a&&A(y,S)}t.isSymbolObject=kr;function ni(y){return Se(y)||rt(y)||Pe(y)||nt(y)||kr(y)}t.isBoxedPrimitive=ni;function ii(y){return typeof Uint8Array<"u"&&(tt(y)||L(y))}t.isAnyArrayBuffer=ii,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(y){Object.defineProperty(t,y,{enumerable:!1,value:function(){throw new Error(y+" is not supported in userland")}})})})($n);var Ua=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},dr={exports:{}};typeof Object.create=="function"?dr.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:dr.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}};var ja=dr.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(h){for(var m=Object.keys(h),E={},L=0;L<m.length;L++)E[m[L]]=Object.getOwnPropertyDescriptor(h,m[L]);return E},r=/%[sdj%]/g;t.format=function(d){if(!N(d)){for(var h=[],m=0;m<arguments.length;m++)h.push(s(arguments[m]));return h.join(" ")}for(var m=1,E=arguments,L=E.length,P=String(d).replace(r,function(k){if(k==="%%")return"%";if(m>=L)return k;switch(k){case"%s":return String(E[m++]);case"%d":return Number(E[m++]);case"%j":try{return JSON.stringify(E[m++])}catch{return"[Circular]"}default:return k}}),O=E[m];m<L;O=E[++m])D(O)||!ne(O)?P+=" "+O:P+=" "+s(O);return P},t.deprecate=function(d,h){if(typeof I<"u"&&I.noDeprecation===!0)return d;if(typeof I>"u")return function(){return t.deprecate(d,h).apply(this,arguments)};var m=!1;function E(){if(!m){if(I.throwDeprecation)throw new Error(h);I.traceDeprecation?console.trace(h):console.error(h),m=!0}return d.apply(this,arguments)}return E};var n={},i=/^$/;if(I.env.NODE_DEBUG){var o=I.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(d){if(d=d.toUpperCase(),!n[d])if(i.test(d)){var h=I.pid;n[d]=function(){var m=t.format.apply(t,arguments);console.error("%s %d: %s",d,h,m)}}else n[d]=function(){};return n[d]};function s(d,h){var m={seen:[],stylize:u};return arguments.length>=3&&(m.depth=arguments[2]),arguments.length>=4&&(m.colors=arguments[3]),T(h)?m.showHidden=h:h&&t._extend(m,h),C(m.showHidden)&&(m.showHidden=!1),C(m.depth)&&(m.depth=2),C(m.colors)&&(m.colors=!1),C(m.customInspect)&&(m.customInspect=!0),m.colors&&(m.stylize=a),c(m,d,m.depth)}t.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function a(d,h){var m=s.styles[h];return m?"\x1B["+s.colors[m][0]+"m"+d+"\x1B["+s.colors[m][1]+"m":d}function u(d,h){return d}function l(d){var h={};return d.forEach(function(m,E){h[m]=!0}),h}function c(d,h,m){if(d.customInspect&&h&&ce(h.inspect)&&h.inspect!==t.inspect&&!(h.constructor&&h.constructor.prototype===h)){var E=h.inspect(m,d);return N(E)||(E=c(d,E,m)),E}var L=f(d,h);if(L)return L;var P=Object.keys(h),O=l(P);if(d.showHidden&&(P=Object.getOwnPropertyNames(h)),ve(h)&&(P.indexOf("message")>=0||P.indexOf("description")>=0))return p(h);if(P.length===0){if(ce(h)){var k=h.name?": "+h.name:"";return d.stylize("[Function"+k+"]","special")}if(re(h))return d.stylize(RegExp.prototype.toString.call(h),"regexp");if(_e(h))return d.stylize(Date.prototype.toString.call(h),"date");if(ve(h))return p(h)}var R="",z=!1,Se=["{","}"];if(g(h)&&(z=!0,Se=["[","]"]),ce(h)){var rt=h.name?": "+h.name:"";R=" [Function"+rt+"]"}if(re(h)&&(R=" "+RegExp.prototype.toString.call(h)),_e(h)&&(R=" "+Date.prototype.toUTCString.call(h)),ve(h)&&(R=" "+p(h)),P.length===0&&(!z||h.length==0))return Se[0]+R+Se[1];if(m<0)return re(h)?d.stylize(RegExp.prototype.toString.call(h),"regexp"):d.stylize("[Object]","special");d.seen.push(h);var Pe;return z?Pe=S(d,h,m,O,P):Pe=P.map(function(nt){return A(d,h,m,O,nt,z)}),d.seen.pop(),b(Pe,R,Se)}function f(d,h){if(C(h))return d.stylize("undefined","undefined");if(N(h)){var m="'"+JSON.stringify(h).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return d.stylize(m,"string")}if(X(h))return d.stylize(""+h,"number");if(T(h))return d.stylize(""+h,"boolean");if(D(h))return d.stylize("null","null")}function p(d){return"["+Error.prototype.toString.call(d)+"]"}function S(d,h,m,E,L){for(var P=[],O=0,k=h.length;O<k;++O)ke(h,String(O))?P.push(A(d,h,m,E,String(O),!0)):P.push("");return L.forEach(function(R){R.match(/^\d+$/)||P.push(A(d,h,m,E,R,!0))}),P}function A(d,h,m,E,L,P){var O,k,R;if(R=Object.getOwnPropertyDescriptor(h,L)||{value:h[L]},R.get?R.set?k=d.stylize("[Getter/Setter]","special"):k=d.stylize("[Getter]","special"):R.set&&(k=d.stylize("[Setter]","special")),ke(E,L)||(O="["+L+"]"),k||(d.seen.indexOf(R.value)<0?(D(m)?k=c(d,R.value,null):k=c(d,R.value,m-1),k.indexOf(`
3
3
  `)>-1&&(P?k=k.split(`
4
4
  `).map(function(z){return" "+z}).join(`
5
5
  `).slice(2):k=`
package/lib/es/index.js CHANGED
@@ -5,7 +5,7 @@ import { SdkOverlayType as R } from "@streamlayer/sl-eslib/sdkSettings/sdkSettin
5
5
  import { InvitationCategory as Br, InvitationFrom as Mr } from "@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb";
6
6
  import { computed as Ei, map as Ii, atom as kt, batched as qr, onMount as Sr } from "nanostores";
7
7
  import { nanoid as ir } from "nanoid";
8
- import { ConnectError as rt, Code as se, createContextKey as jr, createClient as Ur, createContextValues as Ti } from "@connectrpc/connect";
8
+ import { ConnectError as rt, Code as ie, createContextKey as Ur, createClient as jr, createContextValues as Ti } from "@connectrpc/connect";
9
9
  import { createGrpcWebTransport as xr } from "@connectrpc/connect-web";
10
10
  import { nanoquery as Qr } from "@nanostores/query";
11
11
  import { Events as On } from "@streamlayer/sl-eslib/sports/events/events_connect";
@@ -482,7 +482,7 @@ class qi {
482
482
  for await (const o of i)
483
483
  this.attempt = 0, this.onData(o);
484
484
  } catch (n) {
485
- n instanceof rt && n.code != se.Canceled && this.onStreamError(n);
485
+ n instanceof rt && n.code != ie.Canceled && this.onStreamError(n);
486
486
  }
487
487
  })(), this.updateState(ne.Connected);
488
488
  };
@@ -522,23 +522,23 @@ class qi {
522
522
  */
523
523
  onStreamError = (e) => {
524
524
  if (this.addStateLog(`error => ${e ? JSON.stringify(e) : "undefined"}}`), e !== void 0) {
525
- if (e instanceof rt && e.code !== se.Canceled) {
526
- this.updateState(ne.Failed), this.state.setValue("error", e), this.reconnect();
525
+ if (e instanceof rt && e.code !== ie.Canceled) {
526
+ this.updateState(ne.Failed), this.state.setValue("error", e), e.code === ie.Unknown && e.cause === "missing trailer" && (this.attempt = 0), this.reconnect();
527
527
  return;
528
528
  }
529
529
  this.disconnect();
530
530
  }
531
531
  };
532
532
  }
533
- const ji = /* @__PURE__ */ new Set([
534
- se.Unknown,
535
- se.Internal,
536
- se.DeadlineExceeded,
537
- se.ResourceExhausted,
538
- se.FailedPrecondition,
539
- se.Unavailable,
540
- se.DataLoss
541
- ]), Wr = de("grpc:retry"), Ui = (t) => async (e) => {
533
+ const Ui = /* @__PURE__ */ new Set([
534
+ ie.Unknown,
535
+ ie.Internal,
536
+ ie.DeadlineExceeded,
537
+ ie.ResourceExhausted,
538
+ ie.FailedPrecondition,
539
+ ie.Unavailable,
540
+ ie.DataLoss
541
+ ]), Wr = de("grpc:retry"), ji = (t) => async (e) => {
542
542
  const r = e.contextValues.get(ar.retryAttempts), n = 300, i = e.contextValues.get(ar.retryDelay);
543
543
  if (e.stream || r === 0)
544
544
  return t(e);
@@ -549,14 +549,14 @@ const ji = /* @__PURE__ */ new Set([
549
549
  } catch (s) {
550
550
  Wr.trace({ attempt: o, error: s }, "retry attempt");
551
551
  const a = rt.from(s);
552
- if (o >= r || !(a instanceof rt) || !ji.has(a.code))
552
+ if (o >= r || !(a instanceof rt) || !Ui.has(a.code))
553
553
  throw s;
554
554
  const u = Math.min(i, Math.pow(2, o) * n), l = Math.round(u * (1 + Math.random()) / 2);
555
555
  await new Promise((c) => setTimeout(c, l));
556
556
  }
557
557
  }, ar = {
558
- retryAttempts: jr(10, { description: "Number of attempts to retry" }),
559
- retryDelay: jr(3e4, { description: "Max delay between retries in milliseconds" })
558
+ retryAttempts: Ur(10, { description: "Number of attempts to retry" }),
559
+ retryDelay: Ur(3e4, { description: "Max delay between retries in milliseconds" })
560
560
  }, xi = () => {
561
561
  const t = localStorage.getItem("sl-device-id");
562
562
  if (t)
@@ -636,14 +636,14 @@ class Yr {
636
636
  const r = e.typeName;
637
637
  if (this.clients.has(r))
638
638
  return this.clients.get(r);
639
- const n = Ur(e, this.transport);
639
+ const n = jr(e, this.transport);
640
640
  return this.clients.set(r, n), n;
641
641
  };
642
642
  getStreamClient = (e) => {
643
643
  const r = `stream-${e.typeName}`;
644
644
  if (this.clients.has(r))
645
645
  return this.clients.get(r);
646
- const n = Ur(e, this.streamTransport);
646
+ const n = jr(e, this.streamTransport);
647
647
  return this.clients.set(r, n), n;
648
648
  };
649
649
  // create unary client, used for query request
@@ -682,7 +682,7 @@ class Yr {
682
682
  n.header.set(o, i[o]);
683
683
  return r(n);
684
684
  };
685
- this.interceptors.push(e), this.interceptors.push(Mi()), this.opts?.retryable && this.interceptors.push(Ui);
685
+ this.interceptors.push(e), this.interceptors.push(Mi()), this.opts?.retryable && this.interceptors.push(ji);
686
686
  };
687
687
  }
688
688
  const Gi = (t, e) => {
@@ -768,7 +768,7 @@ var ye;
768
768
  (function(t) {
769
769
  t.SCHEMA = "schema", t.EXTERNAL_TOKEN = "eToken", t.TOKEN = "token";
770
770
  })(ye || (ye = {}));
771
- class je extends We {
771
+ class Ue extends We {
772
772
  constructor() {
773
773
  super("user");
774
774
  }
@@ -796,7 +796,7 @@ var ge;
796
796
  t.DISABLED = "disabled", t.INITIALIZATION = "initialization", t.READY = "ready", t.FAILED = "failed", t.SUSPENDED = "suspended";
797
797
  })(ge || (ge = {}));
798
798
  const eo = (t) => {
799
- const e = new je(), r = new ee(q(e.getExternalToken()), "userKey"), n = new ee(q(e.getToken()), "userToken"), i = new le(Hi(n.getStore(), t), "user", ({ data: s, error: a, loading: u }, l) => {
799
+ const e = new Ue(), r = new ee(q(e.getExternalToken()), "userKey"), n = new ee(q(e.getToken()), "userToken"), i = new le(Hi(n.getStore(), t), "user", ({ data: s, error: a, loading: u }, l) => {
800
800
  if (!a)
801
801
  return s?.data?.id ? s.data.id : u === !1 ? void 0 : l;
802
802
  }), o = new le(Yi(n.getStore(), t), "userSettings");
@@ -1459,16 +1459,16 @@ const Oo = async (t, e) => {
1459
1459
  try {
1460
1460
  return await r.submitAnswer({ data: e }, { contextValues: i });
1461
1461
  } catch (o) {
1462
- throw rt.from(o)?.code === se.AlreadyExists ? new Error(nt.ALREADY_VOTED) : new Error(nt.UNKNOWN);
1462
+ throw rt.from(o)?.code === ie.AlreadyExists ? new Error(nt.ALREADY_VOTED) : new Error(nt.UNKNOWN);
1463
1463
  }
1464
1464
  }, _o = (t, e) => {
1465
1465
  const { client: r, createRequestOptions: n } = t.createPromiseClient(te, { method: "submitInplay" }), i = n({ retryAttempts: 0 });
1466
1466
  return r.submitInplay({ data: { eventId: +e } }, { contextValues: i });
1467
1467
  };
1468
- var Ue;
1468
+ var je;
1469
1469
  (function(t) {
1470
1470
  t.ONBOARDING = "onboarding", t.ONBOARDING_IO = "onboarding_io";
1471
- })(Ue || (Ue = {}));
1471
+ })(je || (je = {}));
1472
1472
  class Lo extends We {
1473
1473
  constructor() {
1474
1474
  super("gamification-session", window.sessionStorage);
@@ -1484,13 +1484,13 @@ class Bn extends We {
1484
1484
  super("gamification"), this.sessionStorage = new Lo();
1485
1485
  }
1486
1486
  saveOnboardingStatus = ({ userId: e, eventId: r, organizationId: n }, i) => {
1487
- this.write(Ue.ONBOARDING, n, e, r, i);
1487
+ this.write(je.ONBOARDING, n, e, r, i);
1488
1488
  };
1489
- getOnboardingStatus = ({ userId: e, eventId: r, organizationId: n }) => this.read(Ue.ONBOARDING, n, e, r);
1489
+ getOnboardingStatus = ({ userId: e, eventId: r, organizationId: n }) => this.read(je.ONBOARDING, n, e, r);
1490
1490
  setOnboardingInstantOpen = ({ userId: e, eventId: r, organizationId: n }) => {
1491
- this.sessionStorage.writeValue([Ue.ONBOARDING_IO, n, e, r], "1");
1491
+ this.sessionStorage.writeValue([je.ONBOARDING_IO, n, e, r], "1");
1492
1492
  };
1493
- getOnboardingInstantOpen = ({ userId: e, eventId: r, organizationId: n }) => this.sessionStorage.readValue([Ue.ONBOARDING_IO, n, e, r]);
1493
+ getOnboardingInstantOpen = ({ userId: e, eventId: r, organizationId: n }) => this.sessionStorage.readValue([je.ONBOARDING_IO, n, e, r]);
1494
1494
  }
1495
1495
  const Co = {
1496
1496
  pageSize: 10
@@ -1661,14 +1661,14 @@ class $o extends Ri {
1661
1661
  * Logout user. Clears the all user data from the store.
1662
1662
  */
1663
1663
  logout = () => {
1664
- this.$coreStore.getValues().user.setValue(), this.$coreStore.getValues().userKey.setValue(), this.$coreStore.getValues().userToken.setValue(), this.transport.setAuth("", ""), new je().clear();
1664
+ this.$coreStore.getValues().user.setValue(), this.$coreStore.getValues().userKey.setValue(), this.$coreStore.getValues().userToken.setValue(), this.transport.setAuth("", ""), new Ue().clear();
1665
1665
  };
1666
1666
  /**
1667
1667
  * Soft logout, only clears the StreamLayer user data from the store.
1668
1668
  * Does not clear the external token. And automatically tries to re-login by external token.
1669
1669
  */
1670
1670
  softLogout = () => {
1671
- const e = new je();
1671
+ const e = new Ue();
1672
1672
  this.transport.setAuth("", ""), e.setToken(""), this.reLogin();
1673
1673
  };
1674
1674
  /**
@@ -1679,7 +1679,7 @@ class $o extends Ri {
1679
1679
  * - If no one of the above is true, then logout.
1680
1680
  */
1681
1681
  reLogin = () => {
1682
- const e = new je(), r = e.getToken(), n = e.getExternalToken();
1682
+ const e = new Ue(), r = e.getToken(), n = e.getExternalToken();
1683
1683
  if (this.$coreStore.getValues().userKey.setValue(n), r)
1684
1684
  return this.saveUser(r, ""), this.me().then((i) => {
1685
1685
  if (i?.id) {
@@ -1698,7 +1698,7 @@ class $o extends Ri {
1698
1698
  * Write token to the Transport and UserStore
1699
1699
  */
1700
1700
  saveUser = (e, r) => {
1701
- this.transport.setAuth(e, r), this.$coreStore.getValues().userToken.setValue(e), new je().setToken(e);
1701
+ this.transport.setAuth(e, r), this.$coreStore.getValues().userToken.setValue(e), new Ue().setToken(e);
1702
1702
  };
1703
1703
  /**
1704
1704
  * Add interceptor to the Transport to handle 401 and 403 errors.
@@ -1714,7 +1714,7 @@ class $o extends Ri {
1714
1714
  });
1715
1715
  };
1716
1716
  }
1717
- const Xe = new je(), Bo = (t, e, r) => {
1717
+ const Xe = new Ue(), Bo = (t, e, r) => {
1718
1718
  t.auth = new $o(t.store, t.transport, t.deepLink), t.stores.status.listen((n) => {
1719
1719
  n === ge.READY && t.auth.reLogin();
1720
1720
  }), t.sdk.userId = t.stores.user.getAtomStore, t.sdk.authorizationBypass = async (n, i) => {
@@ -1758,7 +1758,7 @@ const Xe = new je(), Bo = (t, e, r) => {
1758
1758
  [_.TRIVIA]: "trivia",
1759
1759
  [_.PREDICTION]: "prediction",
1760
1760
  [_.TWEET]: "tweet"
1761
- }, jo = (t, e, r) => {
1761
+ }, Uo = (t, e, r) => {
1762
1762
  t.sdk.uiState = J({}), t.ui = {
1763
1763
  enableAppNotification: function() {
1764
1764
  t.sdk.uiState.setKey("appNotification", !0);
@@ -1861,7 +1861,7 @@ const Xe = new je(), Bo = (t, e, r) => {
1861
1861
  o(), s();
1862
1862
  };
1863
1863
  }), r();
1864
- }, Uo = (t, e, r) => {
1864
+ }, jo = (t, e, r) => {
1865
1865
  const n = { onMountedFired: !1 }, i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
1866
1866
  t.sdk = /* @__PURE__ */ Object.create(null), t.sdk.options = J(e), t.sdk.withAuth = !1, t.sdk.onMount = ({ name: s, clear: a }, u) => {
1867
1867
  if (i.has(s)) {
@@ -2964,7 +2964,7 @@ function ps(t) {
2964
2964
  };
2965
2965
  }
2966
2966
  var hs = ps, ys = hs;
2967
- function jn(t, e, r) {
2967
+ function Un(t, e, r) {
2968
2968
  if (typeof t == "function" && (r = e, e = t, t = null), !(r >= 1))
2969
2969
  throw new Error("fastqueue concurrency must be equal to or greater than 1");
2970
2970
  var n = ys(ms), i = null, o = null, s = 0, a = null, u = {
@@ -3064,7 +3064,7 @@ function gs(t, e, r) {
3064
3064
  f(null, p);
3065
3065
  }, f);
3066
3066
  }
3067
- var i = jn(t, n, r), o = i.push, s = i.unshift;
3067
+ var i = Un(t, n, r), o = i.push, s = i.unshift;
3068
3068
  return i.push = a, i.unshift = u, i.drained = l, i;
3069
3069
  function a(c) {
3070
3070
  var f = new Promise(function(p, v) {
@@ -3103,9 +3103,9 @@ function gs(t, e, r) {
3103
3103
  return f;
3104
3104
  }
3105
3105
  }
3106
- Ir.exports = jn;
3106
+ Ir.exports = Un;
3107
3107
  Ir.exports.promise = gs;
3108
- var Un = Ir.exports, Tr = { exports: {} }, Ge = typeof Reflect == "object" ? Reflect : null, rn = Ge && typeof Ge.apply == "function" ? Ge.apply : function(e, r, n) {
3108
+ var jn = Ir.exports, Tr = { exports: {} }, Ge = typeof Reflect == "object" ? Reflect : null, rn = Ge && typeof Ge.apply == "function" ? Ge.apply : function(e, r, n) {
3109
3109
  return Function.prototype.apply.call(e, r, n);
3110
3110
  }, yt;
3111
3111
  Ge && typeof Ge.ownKeys == "function" ? yt = Ge.ownKeys : Object.getOwnPropertySymbols ? yt = function(e) {
@@ -3355,11 +3355,11 @@ var Jn = Tr.exports, Dt = {}, Xn = {}, Zn = function() {
3355
3355
  return Is() && !!Symbol.toStringTag;
3356
3356
  }, Ts = Error, Os = EvalError, _s = RangeError, Ls = ReferenceError, ei = SyntaxError, Vt = TypeError, Cs = URIError, on = typeof Symbol < "u" && Symbol, ks = Zn, Ps = function() {
3357
3357
  return typeof on != "function" || typeof Symbol != "function" || typeof on("foo") != "symbol" || typeof Symbol("bar") != "symbol" ? !1 : ks();
3358
- }, jt = {
3358
+ }, Ut = {
3359
3359
  __proto__: null,
3360
3360
  foo: {}
3361
3361
  }, Ns = Object, Fs = function() {
3362
- return { __proto__: jt }.foo === jt.foo && !(jt instanceof Ns);
3362
+ return { __proto__: Ut }.foo === Ut.foo && !(Ut instanceof Ns);
3363
3363
  }, Ds = "Function.prototype.bind called on incompatible ", Rs = Object.prototype.toString, Vs = Math.max, $s = "[object Function]", sn = function(e, r) {
3364
3364
  for (var n = [], i = 0; i < e.length; i += 1)
3365
3365
  n[i] = e[i];
@@ -3398,7 +3398,7 @@ var Jn = Tr.exports, Dt = {}, Xn = {}, Zn = function() {
3398
3398
  l.prototype = r.prototype, i.prototype = new l(), l.prototype = null;
3399
3399
  }
3400
3400
  return i;
3401
- }, js = qs, Or = Function.prototype.bind || js, Us = Function.prototype.call, xs = Object.prototype.hasOwnProperty, Qs = Or, Gs = Qs.call(Us, xs), T, Ks = Ts, zs = Os, Hs = _s, Ws = Ls, ze = ei, Ke = Vt, Ys = Cs, ti = Function, Ut = function(t) {
3401
+ }, Us = qs, Or = Function.prototype.bind || Us, js = Function.prototype.call, xs = Object.prototype.hasOwnProperty, Qs = Or, Gs = Qs.call(js, xs), T, Ks = Ts, zs = Os, Hs = _s, Ws = Ls, ze = ei, Ke = Vt, Ys = Cs, ti = Function, jt = function(t) {
3402
3402
  try {
3403
3403
  return ti('"use strict"; return (' + t + ").constructor;")();
3404
3404
  } catch {
@@ -3422,14 +3422,14 @@ var xt = function() {
3422
3422
  return xt;
3423
3423
  }
3424
3424
  }
3425
- }() : xt, Be = Ps(), Xs = Fs(), j = Object.getPrototypeOf || (Xs ? function(t) {
3425
+ }() : xt, Be = Ps(), Xs = Fs(), U = Object.getPrototypeOf || (Xs ? function(t) {
3426
3426
  return t.__proto__;
3427
- } : null), qe = {}, Zs = typeof Uint8Array > "u" || !j ? T : j(Uint8Array), Pe = {
3427
+ } : null), qe = {}, Zs = typeof Uint8Array > "u" || !U ? T : U(Uint8Array), Pe = {
3428
3428
  __proto__: null,
3429
3429
  "%AggregateError%": typeof AggregateError > "u" ? T : AggregateError,
3430
3430
  "%Array%": Array,
3431
3431
  "%ArrayBuffer%": typeof ArrayBuffer > "u" ? T : ArrayBuffer,
3432
- "%ArrayIteratorPrototype%": Be && j ? j([][Symbol.iterator]()) : T,
3432
+ "%ArrayIteratorPrototype%": Be && U ? U([][Symbol.iterator]()) : T,
3433
3433
  "%AsyncFromSyncIteratorPrototype%": T,
3434
3434
  "%AsyncFunction%": qe,
3435
3435
  "%AsyncGenerator%": qe,
@@ -3460,10 +3460,10 @@ var xt = function() {
3460
3460
  "%Int32Array%": typeof Int32Array > "u" ? T : Int32Array,
3461
3461
  "%isFinite%": isFinite,
3462
3462
  "%isNaN%": isNaN,
3463
- "%IteratorPrototype%": Be && j ? j(j([][Symbol.iterator]())) : T,
3463
+ "%IteratorPrototype%": Be && U ? U(U([][Symbol.iterator]())) : T,
3464
3464
  "%JSON%": typeof JSON == "object" ? JSON : T,
3465
3465
  "%Map%": typeof Map > "u" ? T : Map,
3466
- "%MapIteratorPrototype%": typeof Map > "u" || !Be || !j ? T : j((/* @__PURE__ */ new Map())[Symbol.iterator]()),
3466
+ "%MapIteratorPrototype%": typeof Map > "u" || !Be || !U ? T : U((/* @__PURE__ */ new Map())[Symbol.iterator]()),
3467
3467
  "%Math%": Math,
3468
3468
  "%Number%": Number,
3469
3469
  "%Object%": Object,
@@ -3476,10 +3476,10 @@ var xt = function() {
3476
3476
  "%Reflect%": typeof Reflect > "u" ? T : Reflect,
3477
3477
  "%RegExp%": RegExp,
3478
3478
  "%Set%": typeof Set > "u" ? T : Set,
3479
- "%SetIteratorPrototype%": typeof Set > "u" || !Be || !j ? T : j((/* @__PURE__ */ new Set())[Symbol.iterator]()),
3479
+ "%SetIteratorPrototype%": typeof Set > "u" || !Be || !U ? T : U((/* @__PURE__ */ new Set())[Symbol.iterator]()),
3480
3480
  "%SharedArrayBuffer%": typeof SharedArrayBuffer > "u" ? T : SharedArrayBuffer,
3481
3481
  "%String%": String,
3482
- "%StringIteratorPrototype%": Be && j ? j(""[Symbol.iterator]()) : T,
3482
+ "%StringIteratorPrototype%": Be && U ? U(""[Symbol.iterator]()) : T,
3483
3483
  "%Symbol%": Be ? Symbol : T,
3484
3484
  "%SyntaxError%": ze,
3485
3485
  "%ThrowTypeError%": Js,
@@ -3494,27 +3494,27 @@ var xt = function() {
3494
3494
  "%WeakRef%": typeof WeakRef > "u" ? T : WeakRef,
3495
3495
  "%WeakSet%": typeof WeakSet > "u" ? T : WeakSet
3496
3496
  };
3497
- if (j)
3497
+ if (U)
3498
3498
  try {
3499
3499
  null.error;
3500
3500
  } catch (t) {
3501
- var ea = j(j(t));
3501
+ var ea = U(U(t));
3502
3502
  Pe["%Error.prototype%"] = ea;
3503
3503
  }
3504
3504
  var ta = function t(e) {
3505
3505
  var r;
3506
3506
  if (e === "%AsyncFunction%")
3507
- r = Ut("async function () {}");
3507
+ r = jt("async function () {}");
3508
3508
  else if (e === "%GeneratorFunction%")
3509
- r = Ut("function* () {}");
3509
+ r = jt("function* () {}");
3510
3510
  else if (e === "%AsyncGeneratorFunction%")
3511
- r = Ut("async function* () {}");
3511
+ r = jt("async function* () {}");
3512
3512
  else if (e === "%AsyncGenerator%") {
3513
3513
  var n = t("%AsyncGeneratorFunction%");
3514
3514
  n && (r = n.prototype);
3515
3515
  } else if (e === "%AsyncIteratorPrototype%") {
3516
3516
  var i = t("%AsyncGenerator%");
3517
- i && j && (r = j(i.prototype));
3517
+ i && U && (r = U(i.prototype));
3518
3518
  }
3519
3519
  return Pe[e] = r, r;
3520
3520
  }, an = {
@@ -3824,17 +3824,17 @@ var $a = xe ? function(e) {
3824
3824
  }, Ba = $a, Ma = Object.prototype.toString, ci = Object.prototype.hasOwnProperty, qa = function(e, r, n) {
3825
3825
  for (var i = 0, o = e.length; i < o; i++)
3826
3826
  ci.call(e, i) && (n == null ? r(e[i], i, e) : r.call(n, e[i], i, e));
3827
- }, ja = function(e, r, n) {
3827
+ }, Ua = function(e, r, n) {
3828
3828
  for (var i = 0, o = e.length; i < o; i++)
3829
3829
  n == null ? r(e.charAt(i), i, e) : r.call(n, e.charAt(i), i, e);
3830
- }, Ua = function(e, r, n) {
3830
+ }, ja = function(e, r, n) {
3831
3831
  for (var i in e)
3832
3832
  ci.call(e, i) && (n == null ? r(e[i], i, e) : r.call(n, e[i], i, e));
3833
3833
  }, xa = function(e, r, n) {
3834
3834
  if (!Ba(r))
3835
3835
  throw new TypeError("iterator must be a function");
3836
3836
  var i;
3837
- arguments.length >= 3 && (i = n), Ma.call(e) === "[object Array]" ? qa(e, r, i) : typeof e == "string" ? ja(e, r, i) : Ua(e, r, i);
3837
+ arguments.length >= 3 && (i = n), Ma.call(e) === "[object Array]" ? qa(e, r, i) : typeof e == "string" ? Ua(e, r, i) : ja(e, r, i);
3838
3838
  }, li = xa, Qa = [
3839
3839
  "Float32Array",
3840
3840
  "Float64Array",
@@ -4016,14 +4016,14 @@ var tu = function(e) {
4016
4016
  return n(y) === "Int32Array";
4017
4017
  }
4018
4018
  t.isInt32Array = O;
4019
- function ie(y) {
4019
+ function oe(y) {
4020
4020
  return n(y) === "Float32Array";
4021
4021
  }
4022
- t.isFloat32Array = ie;
4023
- function oe(y) {
4022
+ t.isFloat32Array = oe;
4023
+ function se(y) {
4024
4024
  return n(y) === "Float64Array";
4025
4025
  }
4026
- t.isFloat64Array = oe;
4026
+ t.isFloat64Array = se;
4027
4027
  function Ne(y) {
4028
4028
  return n(y) === "BigInt64Array";
4029
4029
  }
@@ -4195,7 +4195,7 @@ var au = gr.exports;
4195
4195
  return L;
4196
4196
  }
4197
4197
  }), I = A[m]; m < C; I = A[++m])
4198
- F(I) || !oe(I) ? k += " " + I : k += " " + s(I);
4198
+ F(I) || !se(I) ? k += " " + I : k += " " + s(I);
4199
4199
  return k;
4200
4200
  }, t.deprecate = function(d, h) {
4201
4201
  if (typeof E < "u" && E.noDeprecation === !0)
@@ -4296,7 +4296,7 @@ var au = gr.exports;
4296
4296
  var L = h.name ? ": " + h.name : "";
4297
4297
  return d.stylize("[Function" + L + "]", "special");
4298
4298
  }
4299
- if (ie(h))
4299
+ if (oe(h))
4300
4300
  return d.stylize(RegExp.prototype.toString.call(h), "regexp");
4301
4301
  if (Ne(h))
4302
4302
  return d.stylize(Date.prototype.toString.call(h), "date");
@@ -4308,10 +4308,10 @@ var au = gr.exports;
4308
4308
  var ut = h.name ? ": " + h.name : "";
4309
4309
  D = " [Function" + ut + "]";
4310
4310
  }
4311
- if (ie(h) && (D = " " + RegExp.prototype.toString.call(h)), Ne(h) && (D = " " + Date.prototype.toUTCString.call(h)), Ie(h) && (D = " " + p(h)), k.length === 0 && (!H || h.length == 0))
4311
+ if (oe(h) && (D = " " + RegExp.prototype.toString.call(h)), Ne(h) && (D = " " + Date.prototype.toUTCString.call(h)), Ie(h) && (D = " " + p(h)), k.length === 0 && (!H || h.length == 0))
4312
4312
  return Te[0] + D + Te[1];
4313
4313
  if (m < 0)
4314
- return ie(h) ? d.stylize(RegExp.prototype.toString.call(h), "regexp") : d.stylize("[Object]", "special");
4314
+ return oe(h) ? d.stylize(RegExp.prototype.toString.call(h), "regexp") : d.stylize("[Object]", "special");
4315
4315
  d.seen.push(h);
4316
4316
  var Ve;
4317
4317
  return H ? Ve = v(d, h, m, I, k) : Ve = k.map(function(ct) {
@@ -4417,20 +4417,20 @@ var au = gr.exports;
4417
4417
  return d === void 0;
4418
4418
  }
4419
4419
  t.isUndefined = O;
4420
- function ie(d) {
4421
- return oe(d) && we(d) === "[object RegExp]";
4422
- }
4423
- t.isRegExp = ie, t.types.isRegExp = ie;
4424
4420
  function oe(d) {
4421
+ return se(d) && we(d) === "[object RegExp]";
4422
+ }
4423
+ t.isRegExp = oe, t.types.isRegExp = oe;
4424
+ function se(d) {
4425
4425
  return typeof d == "object" && d !== null;
4426
4426
  }
4427
- t.isObject = oe;
4427
+ t.isObject = se;
4428
4428
  function Ne(d) {
4429
- return oe(d) && we(d) === "[object Date]";
4429
+ return se(d) && we(d) === "[object Date]";
4430
4430
  }
4431
4431
  t.isDate = Ne, t.types.isDate = Ne;
4432
4432
  function Ie(d) {
4433
- return oe(d) && (we(d) === "[object Error]" || d instanceof Error);
4433
+ return se(d) && (we(d) === "[object Error]" || d instanceof Error);
4434
4434
  }
4435
4435
  t.isError = Ie, t.types.isNativeError = Ie;
4436
4436
  function fe(d) {
@@ -4473,7 +4473,7 @@ var au = gr.exports;
4473
4473
  t.log = function() {
4474
4474
  console.log("%s - %s", qt(), t.format.apply(t, arguments));
4475
4475
  }, t.inherits = au, t._extend = function(d, h) {
4476
- if (!h || !oe(h)) return d;
4476
+ if (!h || !se(h)) return d;
4477
4477
  for (var m = Object.keys(h), A = m.length; A--; )
4478
4478
  d[m[A]] = h[m[A]];
4479
4479
  return d;
@@ -4780,10 +4780,10 @@ function hu(t) {
4780
4780
  if (V === "%%")
4781
4781
  return "%";
4782
4782
  re++;
4783
- const ie = r.formatters[O];
4784
- if (typeof ie == "function") {
4785
- const oe = g[re];
4786
- V = ie.call(S, oe), g.splice(re, 1), re--;
4783
+ const oe = r.formatters[O];
4784
+ if (typeof oe == "function") {
4785
+ const se = g[re];
4786
+ V = oe.call(S, se), g.splice(re, 1), re--;
4787
4787
  }
4788
4788
  return V;
4789
4789
  }), r.formatArgs.call(S, g), (S.log || r.log).apply(S, g);
@@ -4973,7 +4973,7 @@ var yu = hu;
4973
4973
  };
4974
4974
  })(br, br.exports);
4975
4975
  var yi = br.exports;
4976
- const mu = Un, gu = Jn.EventEmitter, bu = Dt.inherits, U = yi("avvio"), { AVV_ERR_READY_TIMEOUT: vu } = hi, er = Symbol.for("plugin-meta");
4976
+ const mu = jn, gu = Jn.EventEmitter, bu = Dt.inherits, j = yi("avvio"), { AVV_ERR_READY_TIMEOUT: vu } = hi, er = Symbol.for("plugin-meta");
4977
4977
  function Su(t, e) {
4978
4978
  return t[er] && t[er].name ? t[er].name : typeof e < "u" && typeof e != "function" && e.name ? e.name : t.name ? t.name : t.toString().split(`
4979
4979
  `).slice(0, 2).map((r) => r.trim()).join(" -- ");
@@ -4993,7 +4993,7 @@ Ye.prototype.exec = function(t, e) {
4993
4993
  let n = !1;
4994
4994
  const i = this.name;
4995
4995
  if (this.parent._error && !this.isAfter) {
4996
- U("skipping loading of plugin as parent errored and it is not an after", i), E.nextTick(e);
4996
+ j("skipping loading of plugin as parent errored and it is not an after", i), E.nextTick(e);
4997
4997
  return;
4998
4998
  }
4999
4999
  if (this.isAfter)
@@ -5002,24 +5002,24 @@ Ye.prototype.exec = function(t, e) {
5002
5002
  try {
5003
5003
  this.server = this.parent.override(t, r, this.opts);
5004
5004
  } catch (u) {
5005
- return U("override errored", i), e(u);
5005
+ return j("override errored", i), e(u);
5006
5006
  }
5007
- this.opts = typeof this.opts == "function" ? this.opts(this.server) : this.opts, U("exec", i);
5007
+ this.opts = typeof this.opts == "function" ? this.opts(this.server) : this.opts, j("exec", i);
5008
5008
  let o;
5009
5009
  const s = (u) => {
5010
5010
  if (n) {
5011
- U("loading complete", i);
5011
+ j("loading complete", i);
5012
5012
  return;
5013
5013
  }
5014
- this._error = u, U(u ? "exec errored" : "exec completed", i), n = !0, o && clearTimeout(o), e(u);
5014
+ this._error = u, j(u ? "exec errored" : "exec completed", i), n = !0, o && clearTimeout(o), e(u);
5015
5015
  };
5016
- this.timeout > 0 && (U("setting up timeout", i, this.timeout), o = setTimeout(function() {
5017
- U("timed out", i), o = null;
5016
+ this.timeout > 0 && (j("setting up timeout", i, this.timeout), o = setTimeout(function() {
5017
+ j("timed out", i), o = null;
5018
5018
  const u = new vu(i);
5019
5019
  u.fn = r, s(u);
5020
5020
  }, this.timeout)), this.started = !0, this.emit("start", this.server ? this.server.name : null, this.name, Date.now());
5021
5021
  const a = r(this.server, this.opts, s);
5022
- a && typeof a.then == "function" && (U("exec: resolving promise", i), a.then(
5022
+ a && typeof a.then == "function" && (j("exec: resolving promise", i), a.then(
5023
5023
  () => E.nextTick(s),
5024
5024
  (u) => E.nextTick(s, u)
5025
5025
  ));
@@ -5029,36 +5029,36 @@ Ye.prototype.loadedSoFar = function() {
5029
5029
  return Promise.resolve();
5030
5030
  const t = () => {
5031
5031
  this.server.after((r, n) => {
5032
- this._error = r, this.q.pause(), r ? (U("rejecting promise", this.name, r), this._promise.reject(r)) : (U("resolving promise", this.name), this._promise.resolve()), this._promise = null, E.nextTick(n, r);
5032
+ this._error = r, this.q.pause(), r ? (j("rejecting promise", this.name, r), this._promise.reject(r)) : (j("resolving promise", this.name), this._promise.resolve()), this._promise = null, E.nextTick(n, r);
5033
5033
  }), this.q.resume();
5034
5034
  };
5035
5035
  let e;
5036
5036
  return this._promise ? e = Promise.resolve() : (this._promise = wu(), e = this._promise.promise, this.server ? t() : this.on("start", t)), e;
5037
5037
  };
5038
5038
  Ye.prototype.enqueue = function(t, e) {
5039
- U("enqueue", this.name, t.name), this.emit("enqueue", this.server ? this.server.name : null, this.name, Date.now()), this.q.push(t, e);
5039
+ j("enqueue", this.name, t.name), this.emit("enqueue", this.server ? this.server.name : null, this.name, Date.now()), this.q.push(t, e);
5040
5040
  };
5041
5041
  Ye.prototype.finish = function(t, e) {
5042
- U("finish", this.name, t);
5042
+ j("finish", this.name, t);
5043
5043
  const r = () => {
5044
- this.loaded || (U("loaded", this.name), this.emit("loaded", this.server ? this.server.name : null, this.name, Date.now()), this.loaded = !0, e(t));
5044
+ this.loaded || (j("loaded", this.name), this.emit("loaded", this.server ? this.server.name : null, this.name, Date.now()), this.loaded = !0, e(t));
5045
5045
  };
5046
5046
  if (t) {
5047
5047
  this._promise && (this._promise.reject(t), this._promise = null), r();
5048
5048
  return;
5049
5049
  }
5050
5050
  const n = () => {
5051
- if (U("check", this.name, this.q.length(), this.q.running(), this._promise), this.q.length() === 0 && this.q.running() === 0)
5051
+ if (j("check", this.name, this.q.length(), this.q.running(), this._promise), this.q.length() === 0 && this.q.running() === 0)
5052
5052
  if (this._promise) {
5053
5053
  const i = () => {
5054
- U("wrap"), queueMicrotask(n);
5054
+ j("wrap"), queueMicrotask(n);
5055
5055
  };
5056
5056
  this._promise.resolve(), this._promise.promise.then(i, i), this._promise = null;
5057
5057
  } else
5058
5058
  r();
5059
5059
  else
5060
- U("delayed", this.name), this.q.drain = () => {
5061
- U("drain", this.name), this.q.drain = Eu, queueMicrotask(n);
5060
+ j("delayed", this.name), this.q.drain = () => {
5061
+ j("drain", this.name), this.q.drain = Eu, queueMicrotask(n);
5062
5062
  };
5063
5063
  };
5064
5064
  queueMicrotask(n), this.q.resume();
@@ -5086,7 +5086,7 @@ function Eu() {
5086
5086
  Dr.exports = Ye;
5087
5087
  Dr.exports.loadPlugin = Rr;
5088
5088
  var Iu = Dr.exports;
5089
- const In = Un, Tu = Jn.EventEmitter, Ou = Dt.inherits, {
5089
+ const In = jn, Tu = Jn.EventEmitter, Ou = Dt.inherits, {
5090
5090
  AVV_ERR_EXPOSE_ALREADY_DEFINED: tr,
5091
5091
  AVV_ERR_CALLBACK_NOT_FN: tt,
5092
5092
  AVV_ERR_PLUGIN_NOT_VALID: _u,
@@ -5345,7 +5345,7 @@ const Bu = /* @__PURE__ */ fs($u);
5345
5345
  })();
5346
5346
  function uc(t, e = !0, r = !0, n = { friendsTab: "enabled" }) {
5347
5347
  const i = e ? "https://grpc-sdk.streamlayer.io:443" : "https://grpc-sdk.next.streamlayer.io:443", o = e ? "https://grpc.streamlayer.io:443" : "https://grpc.next.streamlayer.io:443", s = Bu(/* @__PURE__ */ Object.create({}), { autostart: !1 });
5348
- return s.use(Uo, { friendsTab: n.friendsTab }), s.use(Ro, { onDeepLinkHandled: n?.onDeepLinkHandled }), s.use(Mo, { videoPlayerController: n?.videoPlayerController }), s.use(jo, {
5348
+ return s.use(jo, { friendsTab: n.friendsTab }), s.use(Ro, { onDeepLinkHandled: n?.onDeepLinkHandled }), s.use(Mo, { videoPlayerController: n?.videoPlayerController }), s.use(Uo, {
5349
5349
  onContentActivate: n?.onContentActivate,
5350
5350
  withAd: n?.withAd,
5351
5351
  withAdNotification: n?.withAdNotification
package/package.json CHANGED
@@ -24,18 +24,18 @@
24
24
  "devDependencies": {
25
25
  "avvio": "=8.2.1",
26
26
  "tslib": "^2.7.0",
27
- "@streamlayer/feature-gamification": "^1.12.1",
28
- "@streamlayer/sdk-web-analytics": "^1.5.1",
29
- "@streamlayer/sdk-web-api": "^1.6.14",
30
- "@streamlayer/sdk-web-core": "^1.8.3",
31
- "@streamlayer/sdk-web-features": "^1.0.35",
32
- "@streamlayer/sdk-web-interfaces": "^1.4.1",
33
- "@streamlayer/sdk-web-logger": "^1.0.35",
34
- "@streamlayer/sdk-web-notifications": "^1.2.14",
35
- "@streamlayer/sdk-web-storage": "^1.0.35",
36
- "@streamlayer/sdk-web-types": "^1.8.8"
27
+ "@streamlayer/feature-gamification": "^1.12.3",
28
+ "@streamlayer/sdk-web-analytics": "^1.5.3",
29
+ "@streamlayer/sdk-web-api": "^1.6.16",
30
+ "@streamlayer/sdk-web-core": "^1.8.5",
31
+ "@streamlayer/sdk-web-features": "^1.0.37",
32
+ "@streamlayer/sdk-web-interfaces": "^1.4.3",
33
+ "@streamlayer/sdk-web-logger": "^1.0.37",
34
+ "@streamlayer/sdk-web-notifications": "^1.2.16",
35
+ "@streamlayer/sdk-web-storage": "^1.0.37",
36
+ "@streamlayer/sdk-web-types": "^1.8.10"
37
37
  },
38
- "version": "1.6.6",
38
+ "version": "1.6.8",
39
39
  "type": "module",
40
40
  "main": "./src/index.js",
41
41
  "typings": "./src/index.d.ts"