@streamlayer/sdk-web 1.10.11 → 1.10.13
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 +5 -5
- package/lib/es/index.js +608 -598
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const si=require("pino"),b=require("@streamlayer/sl-eslib/interactive/interactive.common_pb"),nt=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb"),R=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),it=require("@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb"),te=require("nanostores"),yt=require("uuid"),B=require("@connectrpc/connect"),_r=require("@connectrpc/connect-web"),Cr=require("@nanostores/query"),fn=require("@streamlayer/sl-eslib/sports/events/events_connect"),Ye=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),fr=require("@streamlayer/sl-eslib/users/users_connect"),re=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),pn=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"),m=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),hn=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_connect"),Pr=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),Z=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 yn={exports:{}},U=yn.exports={},se,ae;function Xt(){throw new Error("setTimeout has not been defined")}function Zt(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?se=setTimeout:se=Xt}catch{se=Xt}try{typeof clearTimeout=="function"?ae=clearTimeout:ae=Zt}catch{ae=Zt}})();function gn(t){if(se===setTimeout)return setTimeout(t,0);if((se===Xt||!se)&&setTimeout)return se=setTimeout,setTimeout(t,0);try{return se(t,0)}catch{try{return se.call(null,t,0)}catch{return se.call(this,t,0)}}}function ci(t){if(ae===clearTimeout)return clearTimeout(t);if((ae===Zt||!ae)&&clearTimeout)return ae=clearTimeout,clearTimeout(t);try{return ae(t)}catch{try{return ae.call(null,t)}catch{return ae.call(this,t)}}}var ye=[],Me=!1,Ee,at=-1;function li(){!Me||!Ee||(Me=!1,Ee.length?ye=Ee.concat(ye):at=-1,ye.length&&mn())}function mn(){if(!Me){var t=gn(li);Me=!0;for(var e=ye.length;e;){for(Ee=ye,ye=[];++at<e;)Ee&&Ee[at].run();at=-1,e=ye.length}Ee=null,Me=!1,ci(t)}}U.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 bn(t,e)),ye.length===1&&!Me&&gn(mn)};function bn(t,e){this.fun=t,this.array=e}bn.prototype.run=function(){this.fun.apply(null,this.array)};U.title="browser";U.browser=!0;U.env={};U.argv=[];U.version="";U.versions={};function me(){}U.on=me;U.addListener=me;U.once=me;U.off=me;U.removeListener=me;U.removeAllListeners=me;U.emit=me;U.prependListener=me;U.prependOnceListener=me;U.listeners=function(t){return[]};U.binding=function(t){throw new Error("process.binding is not supported")};U.cwd=function(){return"/"};U.chdir=function(t){throw new Error("process.chdir is not supported")};U.umask=function(){return 0};var di=yn.exports;const E=ui(di),fi=si.pino({level:"trace",enabled:typeof window<"u"&&!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),be=(t,e)=>fi.child({name:t},e);class pi extends Event{slEventBus;constructor(e,r){super(e),this.slEventBus=r}}const hi=be("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 gi{}var ge;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(ge||(ge={}));window.slStore=Object.create(null);class Et{store;name;constructor(e,r){this.store=e,this.name=r}getStore(){return this.store}}const mi=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 Ie extends Et{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 W=t=>te.map(t);var fe;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(fe||(fe={}));const bi={[R.SdkOverlayType.BETTING]:"betting",[R.SdkOverlayType.GAMES]:"games",[R.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[R.SdkOverlayType.TWITTER]:"twitter"};var ze;(function(t){t.Ready="ready",t.Suspended="suspended"})(ze||(ze={}));class vn{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},n){this.settingsKey=bi[r.type],this.status=te.atom(ze.Suspended),this.config=new Ie(W(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new Ie(W(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new Ie(W({}),`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(ze.Ready)};disable=()=>{this.status.set(ze.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 Et{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 q=t=>te.atom(t);class ee extends Et{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 K=new yi;async function*vi(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now(),t.id=Date.now();const n={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(n),yield r}}const Si=()=>t=>async e=>{const r={id:Date.now(),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:!0}};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 Je{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 X;(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"})(X||(X={}));const Lr=be("grpc:stream");class wi{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,n,i){const o={status:X.Init,ts:new Date,log:[]};this.state=new Ie(W(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(q(null),`subscription:${i.name}:store`)),"subscribe"in n&&typeof n.subscribe=="function"&&(this.paramsListener=n.subscribe(s=>{this.state.getValue("status")===X.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(X.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")?Lr.trace({name:this.options.name,attempt:this.attempt},"received data"):Lr.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(X.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(X.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(X.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(X.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(X.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(X.Failed),this.state.setValue("error",e),e.code===B.Code.Unknown&&e.cause==="missing trailer"&&(this.attempt=0),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]),Nr=be("grpc:retry"),Ai=t=>async e=>{const r=e.contextValues.get(er.retryAttempts),n=300,i=e.contextValues.get(er.retryDelay);if(e.stream||r===0)return t(e);Nr.trace({url:e.url,attempts:r,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){Nr.trace({attempt:o,error:s,url:e.url},"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),d=Math.round(u*(1+Math.random())/2);await new Promise(c=>setTimeout(c,d))}},er={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=yt.v4();return localStorage.setItem("sl-device-id",e),e},Ii=()=>navigator.userAgentData?.platform||navigator.platform;class Fr{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 Ie(W({"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]=Cr.nanoquery({dedupeTime:r?.dedupeTime,refetchInterval:r?.refetchInterval});this.nanoquery={createFetcherStore:n,createMutatorStore:i,utils:o},this.transport=_r.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors}),this.streamTransport=_r.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]=Cr.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:d=>{const c=B.createContextValues();for(const l in d){const p=er[l];c.set(p,d[l])}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(fn.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""}}})},ki=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Ye.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})},_i=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(fn.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})},Ci=(t,e)=>{const{queryKey:r,client:n}=e.createPromiseClient(fr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>{if(!e.getHeader("authorization"))return{data:void 0};const{data:o}=await n.me({});return{data:o}}})},Pi=t=>{const{client:e,createRequestOptions:r}=t.createPromiseClient(fr.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})},Li=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Ye.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(Ye.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(Ye.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},Di=(t,e,r)=>{t.transport=new Fr(e.host,{dedupeTime:1e3*60*5,refetchInterval:1e3*60*5,retryable:!0}),t.analyticsTransport=new Fr(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 Je{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(q(e.getExternalToken()),"userKey"),n=new Y(q(e.getToken()),"userToken"),i=new ee(Ci(n.getStore(),t),"user",({data:s,error:a,loading:u},d)=>{if(!a)return s?.data?.id?s.data.id:u===!1?void 0:d}),o=new ee(Li(n.getStore(),t),"userSettings");return{userKey:r,userToken:n,user:i,userSettings:o}},Vi=t=>{const e=new Y(q(void 0),"providerStreamId"),r=new ee(Oi(e.getStore(),t),"slStreamId",o=>o?.data),n=new ee(ki(r.getAtomStore(),t),"streamSettings"),i=new ee(_i(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(q(void 0),"enabled"),r=new Y(q(pe.DISABLED),"status"),n=new ee(Ni(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new ee(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 Mi extends Et{stores;constructor(e){const r=$i(e),n=mi(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 Mi(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()},Ui=t=>{const{client:e}=t.createPromiseClient(pn.Leaderboard,{method:"list"});return r=>e.list(r)},wn=t=>{const{client:e}=t.createPromiseClient(pn.Leaderboard,{method:"summary"});return r=>e.summary(r)},qi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(fr.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[]}}})},Qi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(re.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.get({eventId:s})).data?.attributes,refetchInterval:1/0,dedupeTime:1e3*60*60})},ji=(t,e,r)=>{const{client:n,queryKey:i}=r.createPromiseClient(re.Feed,{method:"syncQuestion",params:[t,e?"true":""]});return r.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>{if(!a||u)return;const d=await n.syncQuestion({filter:{eventId:a}});if(d.data?.attributes?.question?.type!==b.QuestionType.PROMOTION)return d.data?.attributes},dedupeTime:1e3*60*10,refetchInterval:1/0})},xi=async(t,e)=>{const{client:r}=e.createPromiseClient(re.Feed,{method:"item",params:[t]});return(await r.item({id:t})).data},Gi=(t,e)=>{const{client:r}=e.createStreamClient(re.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(re.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},Tn=async(t,e)=>{const{client:r}=e.createPromiseClient(re.Feed,{method:"questionByUser",params:[t]});return(await r.questionByUser({questionId:t})).data?.attributes?.question},Dt=new Map,ut=(t,e)=>{const{client:r,queryKey:n,queryKeyStr:i}=e.createPromiseClient(re.Feed,{method:"questionByUser",params:[t]});if(Dt.has(i))return Dt.get(i);{const o=e.nanoquery.createFetcherStore(n,{fetcher:async(s,a,u)=>(await r.questionByUser({questionId:u})).data?.attributes?.question,dedupeTime:1/0,refetchInterval:1/0});return Dt.set(i,o),o}},zi=(t,e,r,n,i,o,s)=>{const{client:a,queryKey:u}=s.createPromiseClient(re.Feed,{method:"list",params:[t,e,o?"true":""]});return s.nanoquery.createFetcherStore(u,{fetcher:async(d,c,l,p,S)=>{if(!l||S)return[];const T=await a.list({eventId:l,filter:{types:p===Se.ALLOWED?[]:[b.QuestionType.FACTOID,b.QuestionType.PROMOTION,b.QuestionType.TWEET],statuses:[b.QuestionStatus.ACTIVE,b.QuestionStatus.RESOLVED]}}),v={eventId:l,userId:r.get(),organizationId:n.get()};for(const w of T.data)i.isQuestionReceived(v,w.id)||(K.emit("poll",{action:"received",payload:{questionId:w.id,questionType:w.attributes?.type}}),i.saveQuestionReceived(v,w.id));return T.data},dedupeTime:1/0,refetchInterval:1/0})},Hi=(t,e,r,n,i)=>{const{client:o,queryKey:s}=i.createPromiseClient(re.Feed,{method:"betPack",params:[t,e,r]});return i.nanoquery.createFetcherStore(s,{fetcher:async(a,u,d,c,l)=>{if(!d||!c||!l)return{timestamp:Date.now(),data:null};const p=await o.betPack({eventId:d,types:[b.QuestionType.PREDICTION],statuses:[b.QuestionStatus.ACTIVE,b.QuestionStatus.RESOLVED],limit:5,sort:{field:"activated_at",order:"asc"}});return!p.data||!p.data.length?{timestamp:Date.now(),data:null}:{timestamp:Date.now(),data:p.data?.reduce((S,T)=>{const v=T?.attributes?.question;if(!v?.id)return S;const w={eventId:d,userId:c,organizationId:l};return n.isQuestionReceived(w,v.id)||(K.emit("poll",{action:"received",payload:{questionId:v.id,questionType:v.type}}),n.saveQuestionReceived(w,v.id)),v.answers=v.answers.sort((_,$)=>_.id>$.id?1:-1),{...S,[v.id]:v}},{})}},dedupeTime:1/0,refetchInterval:1/0})},Wi=(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),d=a?.question?.openedFrom;return u?(u.openedFrom=d,u):a.question}),i=te.batched(n,a=>a&&a.type==="question"?a.id:void 0),o=ut(i,t);return{$store:n,$extendedStore:o,updateExtendedQuestion:a=>{const u=o.get().data,d=(c,l)=>{if(!c||!l)return(c||l||[]).sort((v,w)=>v.id>w.id?1:-1);const p=c.sort((v,w)=>v.id>w.id?1:-1),S=l.sort((v,w)=>v.id>w.id?1:-1),T=[];for(let v=0;v<p.length;v++)T.push({...p[v],...S[v],correct:p[v].correct,youVoted:p[v].youVoted,pointsEarned:p[v].pointsEarned});return T};o.mutate({...a,options:u?.options,subject:u?.subject,appearance:u?.appearance,answers:d(u?.answers,a?.answers)})}}};var oe;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io",t.QUESTION_RECEIVED="q-received",t.QUESTION_OPENED="q-opened"})(oe||(oe={}));class Yi extends Je{constructor(){super("gamification-session",window.sessionStorage)}writeValue=(e,r)=>{this.write(...e,r)};readValue=e=>this.read(...e)}class Ji extends Je{sessionStorage;constructor(){super("gamification"),this.sessionStorage=new Yi}saveQuestionReceived=({userId:e,eventId:r,organizationId:n},i)=>{this.write(oe.QUESTION_RECEIVED,n,e,r,i,"1")};isQuestionReceived=({userId:e,eventId:r,organizationId:n},i)=>!!this.read(oe.QUESTION_RECEIVED,n,e,r,i);saveQuestionOpened=({userId:e,eventId:r,organizationId:n},i)=>{this.write(oe.QUESTION_OPENED,n,e,r,i,"1")};isQuestionOpened=({userId:e,eventId:r,organizationId:n},i)=>!!this.read(oe.QUESTION_OPENED,n,e,r,i);saveOnboardingStatus=({userId:e,eventId:r,organizationId:n},i)=>{this.write(oe.ONBOARDING,n,e,r,i)};getOnboardingStatus=({userId:e,eventId:r,organizationId:n})=>this.read(oe.ONBOARDING,n,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{this.sessionStorage.writeValue([oe.ONBOARDING_IO,n,e,r],"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>this.sessionStorage.readValue([oe.ONBOARDING_IO,n,e,r])}var Se;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Se||(Se={}));class Xi{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;betPack;moderationId;moderation;feedSubscription;questionSubscription;advertisement;storage;notifications;log;transport;cancels=new Set;constructor(e){this.transport=e.transport,this.log=be("gamification-background"),this.storage=new Ji,this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new Y(q(void 0),"moderationId").getStore(),this.interactiveAllowed=new Y(q(Se.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new Y(q(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new ee(Qi(this.slStreamId,e.transport),"gamification:moderation");const r=!!e.sdk.options.get().betPack;this.feedList=new ee(zi(this.slStreamId,this.interactiveAllowed,this.userId,this.organizationId,this.storage,r,e.transport),"gamification:feedList"),this.betPack=new ee(Hi(this.slStreamId,this.userId,this.organizationId,this.storage,e.transport),"gamification:betPack"),this.activeQuestionId=ji(this.slStreamId,r,e.transport),this.openedQuestion=Wi(e.transport,this.openedQuestionId,this.feedList.getStore()),this.cancels.add(this.openedQuestionId.listen(n=>{this.log.debug({item:n},"received question"),n?.questionId?(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0),this.questionSubscription=Ki(n.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",i=>{const o=i.data?.attributes?.question;if(this.openedQuestion.updateExtendedQuestion(o),o?.type===b.QuestionType.PREDICTION&&(o.status===b.QuestionStatus.ACTIVE||o.status===b.QuestionStatus.RESOLVED)){const s=this.betPack.getValues().data?.data||{},a=s?.[o.id];if(a){const u=[],d=a.answers.sort((l,p)=>l.id>p.id?1:-1),c=o.answers.sort((l,p)=>l.id>p.id?1:-1);for(let l=0;l<d.length;l++)u.push({...d[l],...c[l],correct:d[l].correct,youVoted:d[l].youVoted,pointsEarned:d[l].pointsEarned});this.betPack.getStore().mutate({timestamp:Date.now(),data:{...s,[o.id]:{...a,status:o.status,marketClosed:o.marketClosed,activatedAt:o.activatedAt,answerSetAt:o.answerSetAt,answers:u}}})}}}),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("bet-pack-update",async n=>{const i=n.data?.attributes?.question;if(i?.type===b.QuestionType.PREDICTION&&(i.status===b.QuestionStatus.ACTIVE||i.status===b.QuestionStatus.RESOLVED)){const o=this.betPack.getValues().data?.data||{},s=o?.[i.id];if(s)this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:{...s,status:i.status,marketClosed:i.marketClosed,activatedAt:i.activatedAt,answerSetAt:i.answerSetAt}}});else if(!s&&Object.keys(o).length<5){const a=await Tn(i.id,this.transport);this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:a}})}}})),this.cancels.add(this.feedSubscription.addListener("feed-subscription-active-question",n=>{const i=this.activeQuestionId.get().data?.question?.id,o=n.data?.attributes?.question;if(!(!o||o.type===b.QuestionType.PROMOTION)){if(o.status===b.QuestionStatus.RESOLVED){i===o.id&&this.activeQuestionId.mutate(void 0);return}window.requestAnimationFrame(()=>{this.activeQuestionId.mutate(n.data?.attributes)})}})),this.cancels.add(this.feedSubscription.addListener("moderation update",n=>{window.requestAnimationFrame(()=>{n.data?.attributes?.question===void 0&&n.data?.attributes?.moderation&&this.moderation.invalidate()})})),this.cancels.add(this.activeQuestionId.subscribe((n,i)=>{n.data?.feedItem&&n.data?.feedItem?.id!==i?.data?.feedItem?.id&&e.onQuestionActivate({stage:"activate",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}),!n.data?.feedItem&&i?.data?.feedItem&&e.onQuestionActivate({stage:"deactivate",id:i.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:i.data.feedItem.id})),hasNotification:!0,type:i.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 n of this.cancels)n(),this.cancels.delete(n)})}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 Zi{notificationsList;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=be("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notificationsList=q(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}K.emit("notification",{action:"received",payload:{type:r.type,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&&K.emit("notification",{action:"closed",payload:{type:i.type,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 eo extends Je{constructor(){super("notification")}setOpened=e=>{this.write(gt.OPENED,e,"true")};isOpened=e=>this.read(gt.OPENED,e);clearNotification=()=>{this.clear()}}class to{queue;storage;constructor(e={}){this.storage=new eo,this.queue=new Zi({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),K.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===ge.ONBOARDING)return n;return e.values().next().value};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const ro=(t,e,r)=>{t.notifications=new to(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 qe;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(qe||(qe={}));const Dr=async(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(re.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(qe.ALREADY_VOTED):new Error(qe.UNKNOWN)}},An=(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(re.Feed,{method:"submitInplay"}),i=n({retryAttempts:0});return r.submitInplay({data:{eventId:+e}},{contextValues:i})},no={pageSize:10},io=(t,e,r,n,i)=>{let o=0;const s=q({pageSize:no.pageSize,page:0}),a=W({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=Ui(t),d=async()=>{const p=e.get(),S=n?.getStore().get().data?.map(T=>T.slId)||[];if(p&&S?.length){const T=r.get();T&&S.push(T),a.setKey("loading",!0),a.setKey("data",[]);const w=await u({eventId:p,usersIds:S});a.set({data:w.data.map((_,$)=>({..._.attributes,friendsRank:$+1})),hasMore:!1,key:Date.now(),loading:!1}),w.meta&&(o=Math.round(w.meta.count/w.meta.pageSize))}},c=()=>{d()},l=p=>{const S=s.get(),T=p||S.page+1;T<=o&&s.set({...S,page:T})};return te.onMount(a,()=>{const p=e.listen(d),S=n?.listen(d);return()=>{p(),S?.()}}),{$store:a,fetchMore:l,invalidate:c}};class oo extends Je{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Rr="sldl",It="sldl_uid",En="sldl_eid",In="sldl_e_eid",so=new Set([It,En,In]),Vr=t=>{const e={},r={};for(const[n,i]of t)so.has(n)?e[n]=i:r[n]=i;return{result:e,remain:r}},ao=({hash:t,search:e})=>{if(t&&t.includes(Rr)){const r=new URLSearchParams(t.substr(1));return{hash:Vr(r)}}if(e&&e.includes(Rr)){const r=new URLSearchParams(e);return{search:Vr(r)}}return null},$r=be("deep_link"),ue={debug:(...t)=>{$r.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{$r.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},uo=(t,e)=>{const{hash:r,search:n}=window.location;if(ue.debug({hash:r,search:n},"get deep link data from"),r||n){const i=ao({hash:r,search:n});if(ue.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 d=Object.keys(u).length!==0;if(o){let c="";d&&(c=`#${new URLSearchParams(u).toString()}`,ue.debug({updatedHash:c},"update hash")),window.history.replaceState(null,"",window.location.pathname+window.location.search+c)}if(s){let c="";d&&(c=`?${new URLSearchParams(u).toString()}`,ue.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},co=(t,e,r)=>{const n=new oo,i=n.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){ue.debug(a)}t.deepLink={$store:new Ie(W(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{ue.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?.[It]: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")&&ue.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{ue.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),ue.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{ue.trace("called handler"),u(a)}catch(d){console.error(d)}};uo(t.deepLink.$store,s),r()},lo=be("bypass");class fo extends gi{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,n){super(),this.$coreStore=e,this.deepLink=n,this.transport=r,this.bypassLogin=Pi(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?.[It];lo.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=({skipLogin:e}={skipLogin:!1})=>{const r=new Ve,n=r.getToken(),i=r.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(i),n)return this.saveUser(n,""),this.me().then(o=>{if(o?.id){const s=o.id;this.saveUser(n,s)}return o});if(i&&!n&&!e){const o=r.getSchema();o&&i&&this.login(o,i).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 Ke=new Ve,po=(t,e,r)=>{t.auth=new fo(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(!(Ke.getSchema()===n&&Ke.getExternalToken()===i&&t.transport.getHeader("authorization")))try{await t.auth.login(n,i),Ke.setSchema(n),Ke.setExternalToken(i)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),Ke.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},Mr=be("video_player"),ot={debug:(...t)=>{Mr.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{Mr.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},ho=(t,e,r)=>{t.videoPlayer={controllers:new Set},t.sdk.addVideoPlayerController=n=>{ot.trace("adding video player controller"),t.videoPlayer.controllers.add(n)},e.videoPlayerController&&t.sdk.addVideoPlayerController(e.videoPlayerController),t.sdk.removeVideoPlayerController=n=>{ot.trace("removing video player controller"),t.videoPlayer.controllers.delete(n)},t.sdk.controlVideoPlayer=n=>{ot.trace("controlling video player");for(const i of t.videoPlayer.controllers){ot.trace("calling video player controller");try{i(n)}catch(o){console.error(o)}}},r()},yo={[b.QuestionType.FACTOID]:"insight",[b.QuestionType.POLL]:"poll",[b.QuestionType.TRIVIA]:"trivia",[b.QuestionType.PREDICTION]:"prediction",[b.QuestionType.TWEET]:"tweet"},go=(t,e,r)=>{t.sdk.uiState=W({}),t.ui={enableAppNotification:function(){t.sdk.uiState.setKey("appNotification",!0)},disableAppNotification:function(){t.sdk.uiState.get().app||t.sdk.uiState.setKey("appNotification",!1)},enableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!0)},disableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!1)},enableApp:function(){t.sdk.uiState.set({app:!0,appNotification:!0})},disableApp:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),onboardingNotification:!1,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&&yo[i]||"question";t.ui.enableAppNotification(),t.ui.onContentActivate({...o,type:s})}},t.sdk.onMount({name:"ui"},()=>{const i=a=>{if(a.slEventBus?.type==="app")switch(a.slEventBus.action){case"open":t.ui.enableApp();break;case"close":t.ui.disableApp();break}if(a.slEventBus?.type==="notification"){const u=a.slEventBus.action;if(a.slEventBus.payload.type===ge.ONBOARDING)switch(u){case"received":t.ui.enableOnboardingNotification();break;case"closed":t.ui.disableOnboardingNotification();break}else switch(u){case"received":t.ui.enableAppNotification();break;case"closed":t.ui.disableAppNotification();break}}if(a.slEventBus?.type==="advertisement"&&e.withAd){const u=a.slEventBus,{hasNotification:d,hasBanner:c,id:l,isViewed:p,type:S}=u.payload;switch(u.action){case"notification-opened":t.sdk.uiState.set({promotionExternalAd:S===b.PromotionType.EXTERNAL_AD,promotionBanner:c,promotionNotification:!1,promotionOverlay:!0,promotionSidebar:!0});break;case"received":if(t.sdk.closeFeature(),n({stage:"activate",id:l,hasNotification:d,hasBanner:c,isViewed:p}),!e.withAdNotification){t.sdk.uiState.set({promotionBanner:c,onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionOverlay:!0,promotionSidebar:!0,promotionExternalAd:S===b.PromotionType.EXTERNAL_AD});break}d?t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionNotification:!0}):t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionBanner:c,promotionOverlay:!0,promotionSidebar:!0,promotionExternalAd:S===b.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:l,hasNotification:d,hasBanner:c,isViewed:p});break}}},o=K.listen(i),s=t.activeFeature.subscribe(a=>{a?(t.ui.enableApp(),t.sdk.uiState.set({app:!0})):t.ui.disableApp()});return()=>{o(),s()}}),r()},mo=(t,e,r)=>{const n={onMountedFired:!1},i=new Map,o=new Map;t.sdk=Object.create(null),t.sdk.options=W(e),t.sdk.withAuth=!1,t.sdk.onMount=({name:s,clear:a},u)=>{if(i.has(s)){const d=o.get(s);d&&d(),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,a)=>{a?t.stores.slStreamId.getStore().set({loading:!1,data:s}):t.stores.providerStreamId.setValue(s)},r()},bo=(t,e)=>{const{client:r,queryKey:n}=t.createPromiseClient(Ye.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:1/0})},vo=(t,{web:e,mobile:r})=>{const{client:n}=t.createPromiseClient(ai.LinksClient,{method:"generate"});return n.generate({web:e,mobile:r})},Br=(t,e)=>{const r=new URLSearchParams(t);for(const[n,i]of Object.entries(e))r.append(n,i);return r.toString()},So=(t,e,r,n)=>{const i=W({});return te.onMount(i,()=>bo(t,[e,r]).subscribe(async({data:a,loading:u})=>{const d=a===void 0&&u===!1?"https://streamlayer.io":a?.url,c=n.get()||"",l=e.get()||"",p=r.get()||"",S={[It]:c,[En]:l,[In]:p};if(!u&&d){i.setKey("loading",!0);let T=window.location.search,v=window.location.hash;T&&v||v?T=`?${Br(T,S)}`:v=`#${Br("",S)}`;const w=window.location.origin+window.location.pathname+T+v;try{const _=await vo(t,{web:w,mobile:d});i.set({data:_.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 wo=(t,e,r,n)=>{const{inplayGame:i}=t.featureSettings.get(),o=e.getCurrentSessionId({prefix:"onboarding"});i&&r.add({type:ge.ONBOARDING,id:o,action:t.openFeature,close:()=>{t.onboardingProcessed.set(!0)},persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:b.QuestionType.UNSET,onboarding:{...i,instantOpen:!n.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},st=(t,e,r,n,i,o,s,a)=>{try{const u=e.userId.get(),d=e.organizationId.get(),c=e.slStreamId.get();if(!u||!d||!c)return;const l=i.getOnboardingStatus({userId:u,organizationId:d,eventId:c});if(l===M.Completed||a?.skipOnboarding){t.set(M.Completed);for(const w of o)w();a?.skipOnboarding&&l!==M.Completed&&(i.saveOnboardingStatus({organizationId:d,userId:u,eventId:c},M.Completed),An(s,c));return}const p=e.moderation.getStore().value?.data,S=r.featureSettings.get().inplayGame;if(p===void 0||S===void 0)return;const T=p?.options?.onboardingEnabled,v=S?.titleCard?.optIn;T?v?t.set(M.Required):t.set(M.Optional):(v?t.set(M.Unavailable):t.set(M.Disabled),n.close(e.getCurrentSessionId({prefix:"onboarding"}),{markAsViewed:!1}))}catch(u){console.error(u)}},Ur=(t,e,r,n,i)=>{let o=!!i?.skipOnboarding;const s=e.storage,a=q(M.Unset);a.subscribe(c=>{c!==M.Unset&&(c===M.Optional||c===M.Required?o===!1&&(wo(t,e,n,s),o=!0):t.onboardingProcessed.set(!0),c===M.Completed&&e.activeQuestionId.invalidate(),s.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const u=[];return a.get()!==M.Completed&&(u.push(e.userId.listen(c=>{c&&st(a,e,t,n,s,u,r,i)})),u.push(e.moderation.listen(c=>{c.data&&st(a,e,t,n,s,u,r,i)})),u.push(t.featureSettings.listen(c=>{c&&st(a,e,t,n,s,u,r,i)}))),st(a,e,t,n,s,u,r,i),{$store:a,submitInplay:async()=>{const c=e.slStreamId.get();if(c){await An(r,c),a.set(M.Completed),s.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:c},M.Completed),K.emit("poll",{action:"onboardingPassed",payload:{}}),t.openFeature();const l=e.getCurrentSessionId({prefix:"onboarding"});n.close(l)}}}},To=(t,e,r,n)=>{const i=W(void 0),o=wn(n),s=async()=>{const u=t.get(),d=e.get(),c=r?r.getStore().get().data?.map(S=>S.slId):[];if(!c||!u||!d)return;const l={eventId:u,userId:d,usersIds:[...c,d]},p=await o(l);i.set(p.data?.attributes)},a=()=>{s()};return te.onMount(i,()=>{a();const u=t.listen(s),d=r?.listen(s),c=e.listen(s);return()=>{u(),d?.(),c()}}),{$store:i,invalidate:a}},Ao=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)||[],d={eventId:s,userId:n,usersIds:[...u,a]};return(await o(d)).data?.attributes?.summary},qr=new Set([b.QuestionType.POLL,b.QuestionType.PREDICTION,b.QuestionType.TRIVIA]);class Eo extends vn{userSummary;feedList;betPack;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;advertisement;onboardingProcessed;friendsTabEnabled;skipOnboarding;notifications;transport;background;storage;submitAnswerTimeout;cancels=new Set;onQuestionActivate;constructor(e,r,n){if(super(e,r),this.background=new Xi(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=this.background.storage,this.feedList=this.background.feedList,this.betPack=this.background.betPack,this.currentUserId=this.background.userId,this.onboardingProcessed=q(!n.sdk.withAuth),this.leaderboardId=new Y(q(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.notifications=n.notifications,this.transport=n.transport,this.closeFeature=(i=!0)=>n.sdk.closeFeature(i),this.openFeature=()=>n.sdk.openFeature(R.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=So(this.transport,this.background.slStreamId,n.stores.providerStreamId.getStore(),this.background.userId),this.userSummary=To(this.background.slStreamId,this.background.userId,this.friends,this.transport),!n.sdk.options.get().hideFriends){this.friends=new ee(qi(this.background.userId,n.transport),"gamification:friends"),this.openedUser=q(void 0);const i=this.leaderboardList=io(this.transport,this.background.slStreamId,this.background.userId,this.friends);this.cancels.add(this.userSummary.$store.listen((o,s)=>{s?.summary&&o?.summary&&i.invalidate()}))}this.connect(),this.skipOnboarding=!!n.sdk.options.get().skipOnboarding,this.onboardingStatus=Ur(this,this.background,n.transport,n.notifications,{skipOnboarding:n.sdk.options.get().skipOnboarding}),n.sdk.options.get().skipOnboarding||(this.onboardingStatus=Ur(this,this.background,n.transport,n.notifications,{skipOnboarding:n.sdk.options.get().skipOnboarding})),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=q(!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()===Se.ALLOWED}checkInteractiveFlag=()=>{if(this.skipOnboarding)this.background.interactiveAllowed.set(Se.ALLOWED);else{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?Se.ALLOWED:Se.DISALLOWED)}};connect=()=>{this.onboardingProcessed.subscribe(e=>{e&&this.advertisement&&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===b.QuestionStatus.RESOLVED&&o===b.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),d=[...this.feedList.getValues().data||[]],c=d.findIndex(G=>G.id===s),l=d[c];let p=l?.attributes?.attributes?.value?.answerId;const S=ut(s,this.transport),T=S.subscribe(()=>{});await S.get().promise;let v=S.get().data;v||(v=await Tn(s,this.transport),S.mutate(v)),T(),window.requestAnimationFrame(()=>{S.invalidate()}),p||(p=v?.answers.find(({youVoted:G})=>G)?.id);const w=a.find(({correct:G})=>G),_=p?a.find(({id:G})=>G===p):void 0,$=!!_?.correct;if(l&&d[c]?.attributes?.attributes.case==="question"){try{d[c].attributes.attributes.value.answerId=p,d[c].attributes.attributes.value.openForVoting=!1,p&&(d[c].attributes.attributes.value.status=$?nt.PickHistoryStatus.WON:nt.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(d)}if(!_||!w)return;this.openedQuestionId.get()?.questionId!==r.id&&this.notifications.add({type:ge.QUESTION_RESOLVED,action:()=>this.openQuestion(r.id,n),close:()=>this.closeQuestion(s),autoHideDuration:$?15e3:12e3,id:u,emitEvent:!1,data:{questionId:s,questionType:b.QuestionType.PREDICTION,question:{title:$?`Congratulations! You answered correctly! You won ${w.points} pts!`:`Better luck next time! Correct: ${w?.text}!`,votedAnswer:{title:_?.text,points:_?.points},correctAnswerTitle:w?.text,correct:!!$,predictionResult:i===b.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!==b.QuestionStatus.ACTIVE&&n.attributes.status!==b.QuestionStatus.RESOLVED)&&!(!this.isInteractiveAllowed&&qr.has(n.attributes.type))){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===!1?!1:n.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),K.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")};betPackVote=async(e,r)=>{try{await Dr(this.transport,{questionId:e,answerId:r})}catch(o){if(o.message===qe.ALREADY_VOTED){const s=ut(e,this.transport),a=s.subscribe(()=>{});s.invalidate(),a()}throw o}const n={...this.betPack.getValues().data?.data},i=n?.[e];i&&(K.emit("poll",{action:"voted",payload:{questionId:e,questionType:i.type}}),i.answers=i.answers.map(o=>o.id===r?{...o,youVoted:!0}:o),this.betPack.getStore().mutate({data:n,timestamp:Date.now()}))};submitAnswer=async(e,r)=>{const n=ut(e,this.transport),i=n.subscribe(()=>{}),o={...n.get().data||{}},s=()=>{const a=this.feedList.getValues().data;if(!a)return;const u=a.findIndex(l=>l.id===e),d=a[u],c=d?.attributes?.attributes.case==="question"&&d.attributes.attributes.value;if(c){K.emit("poll",{action:"voted",payload:{questionId:e,questionType:c.questionType}});const l=n.get().data;if(i(),l){const p=l.answers.find(w=>w.correct===!0),S=l.answers.findIndex(w=>w.id===r),T=l.answers[S],v=l.answers.every(({percentageDecimal:w},_)=>w===o?.answers[_].percentageDecimal);a[u].attributes.attributes.value.answerId=r,a[u].attributes.attributes.value.openForVoting=!1,a[u].attributes.attributes.value.text=T?.text||"",p&&(a[u].attributes.attributes.value.status=p.id===r?nt.PickHistoryStatus.WON:nt.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...a]),l.answers[S].correct=p?.id===r,l.answers[S].youVoted=!0,v&&l.answers.forEach(w=>{w.percentageDecimal=0}),p?.id===r&&(l.answers[S].pointsEarned=l.status===b.QuestionStatus.RESOLVED?0:p.points),n.mutate({...l})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await Dr(this.transport,{questionId:e,answerId:r}),s()}catch(a){if(a.message===qe.ALREADY_VOTED){this.userSummary.invalidate();const u=n.subscribe(()=>{});n.invalidate(),u()}throw a}};openQuestion=(e,r)=>{if(!e)return()=>{};const n=r?.openedFrom==="bet-pack";this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}),{animateHiding:!1});let i=r?.attributes?.type;!i&&!n&&(i=(this.feedList.getStore().value?.data||[]).find(a=>a.id===e)?.attributes?.type);const o={eventId:this.background.slStreamId.get()||"",userId:this.background.userId.get()||"",organizationId:this.background.organizationId.get()||""};return this.storage.isQuestionOpened(o,e)||(K.emit("poll",{action:"opened",payload:{questionId:e,questionType:i,questionOpenedFrom:r?.openedFrom==="bet-pack"?"list":r?.openedFrom}}),this.storage.saveQuestionOpened(o,e)),n||this.openFeature(),this.background.openQuestion(e,r?{...r,openedFrom:r?.openedFrom==="bet-pack"?"list":r?.openedFrom}:void 0)};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=>{if(!this.leaderboardList)return;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 Ao(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!==b.SilenceSetting.ON&&e.data.question.status===b.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(qr.has(e.data.question.type))this.isInteractiveAllowed&&e.data.question.notification!==void 0&&this.notifications.add({type:ge.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},inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship}}});else if(e.data.question.type===b.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:ge.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,inApp:{useMediaFromContent:n?.useAsNotification===b.UseAsNotification.ENABLED,notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship}}})}else if(e.data.question.type===b.QuestionType.TWEET&&e.data.question.notification!==void 0){const n=e.data.question.options?.options.value,i={image:"",video:""};if(n.tweetMeta?.tweet?.meta?.extendedEntities?.media?.[0]){const s=n.tweetMeta.tweet.meta.extendedEntities.media;if(s){const a=s.find(({type:u})=>u==="photo")||s[0];i.image=a.mediaUrlHttps,a.type==="video"&&(i.video=a.url)}}const o={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,tweetMedia:i};this.notifications.add({type:ge.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:o,inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship}}})}}}}const Io={[R.SdkOverlayType.GAMES]:!0};class Oo extends vn{constructor(e,r){super(e,r)}}const ko=(t,e,r)=>t.type===R.SdkOverlayType.GAMES?new Eo(t,e,r):new Oo(t,e),_o=(t,e,r)=>{t.features=new Map,t.sdk.featuresList=new Y(q(new Set),"features-list"),t.activeFeature=new Y(q(R.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.sdk.initializeApp().then(()=>{t.activeFeature.setValue(n)})},t.sdk.closeFeature=(n=!1)=>{const i=t.activeFeature.getValue();if(t.activeFeature.setValue(R.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 Io&&!t.features.has(n.type)){const o=ko(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 Co{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 K.listen(r)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.INVITATION_ACCEPTED},category:it.InvitationCategory.GAMES,from:it.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.INVITATION_SENT},category:it.InvitationCategory.GAMES,from:e||it.InvitationFrom.UNSET})}}class Po{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 K.listen(r)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.INTERACTIONS},actionType:Pr.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.INTERACTIONS},actionType:Pr.InteractionActionType.SCROLL})}}const Lo={[b.PromotionType.UNSET]:m.TopicSubType.UNSET,[b.PromotionType.INGAME_IAB21]:m.TopicSubType.PROMOTION_INGAME_IAB21,[b.PromotionType.INGAME_IAB11_LBAR]:m.TopicSubType.PROMOTION_INGAME_IAB11_LBAR,[b.PromotionType.INGAME_IAB11]:m.TopicSubType.PROMOTION_INGAME_IAB11,[b.PromotionType.INGAME_IAB21_LBAR]:m.TopicSubType.PROMOTION_INGAME_IAB21_LBAR,[b.PromotionType.INGAME_IAB61]:m.TopicSubType.PROMOTION_INGAME_IAB61,[b.PromotionType.EXTERNAL_AD]:m.TopicSubType.PROMOTION_GAM,[b.PromotionType.VIDEO_SIDE_BY_SIDE]:m.TopicSubType.PROMOTION_VIDEO_SIDE_BY_SIDE,[b.PromotionType.PICTURE_IN_PICTURE]:m.TopicSubType.PROMOTION_PICTURE_IN_PICTURE,[b.PromotionType.SHOP_LBAR]:m.TopicSubType.PROMOTION_SHOP_LBAR,[b.PromotionType.SHOP_OVERLAY]:m.TopicSubType.PROMOTION_SHOP_OVERLAY,[b.PromotionType.SHOP_SIDEBAR]:m.TopicSubType.PROMOTION_SHOP_SIDEBAR},tr=t=>t?Lo[t]:m.TopicSubType.UNSET;class No{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(!n.slEventBus?.skipAnalytics&&n.slEventBus?.type==="advertisement"){const i=tr(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 K.listen(r)})}received=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_RECEIVED,topicId:e,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})};opened=({id:e,openedFrom:r},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_OPENED,topicId:e,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:r==="notification"?m.PollOpenedFrom.IN_APP:m.PollOpenedFrom.UNSET})};viewed=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_OPENED,topicId:e,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})};videoPlay=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:m.Kind.AD_VIDEO_PLAYED,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})};buttonSelect=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:m.Kind.AD_BUTTON_NAVIGATED,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})};bannerSelect=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:m.Kind.AD_BANNER_NAVIGATED,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})}}const He={[b.QuestionType.UNSET]:m.TopicType.UNSET,[b.QuestionType.FACTOID]:m.TopicType.POLLS_INSIGHT,[b.QuestionType.POLL]:m.TopicType.POLLS_POLL,[b.QuestionType.PREDICTION]:m.TopicType.POLLS_PREDICTION,[b.QuestionType.PROMOTION]:m.TopicType.POLLS_PROMOTION,[b.QuestionType.TRIVIA]:m.TopicType.POLLS_TRIVIA,[b.QuestionType.TWEET]:m.TopicType.POLLS_TWITTER};b.QuestionType.UNSET+"",Z.NotificationKind.UNSET,b.QuestionType.FACTOID+"",Z.NotificationKind.POLLS,b.QuestionType.POLL+"",Z.NotificationKind.POLLS,b.QuestionType.PREDICTION+"",Z.NotificationKind.POLLS,b.QuestionType.PROMOTION+"",Z.NotificationKind.POLLS,b.QuestionType.TRIVIA+"",Z.NotificationKind.POLLS,b.QuestionType.TWEET+"",Z.NotificationKind.POLLS;const Fo={[R.SdkOverlayType.UNSET]:m.Category.UNSET,[R.SdkOverlayType.INPLAY]:m.Category.INPLAY,[R.SdkOverlayType.MESSAGING]:m.Category.MESSAGING,[R.SdkOverlayType.STATISTICS]:m.Category.STATS,[R.SdkOverlayType.BETTING]:m.Category.BETTING,[R.SdkOverlayType.TWITTER]:m.Category.TWITTER,[R.SdkOverlayType.MERCHANDISE]:m.Category.MERCHANDISE,[R.SdkOverlayType.CONTESTS]:m.Category.CONTESTS,[R.SdkOverlayType.VOICE_CHAT]:m.Category.CALLING,[R.SdkOverlayType.TICKETS]:m.Category.TICKETS,[R.SdkOverlayType.WHOIS_WATCHING]:m.Category.WHOISWATCHING,[R.SdkOverlayType.PROFILE]:m.Category.PROFILE,[R.SdkOverlayType.GAMES]:m.Category.POLLS,[R.SdkOverlayType.GOLF_STATISTICS]:m.Category.STATS,[R.SdkOverlayType.HIGHLIGHTS]:m.Category.HIGHLIGHTS,[R.SdkOverlayType.PUBLIC_CHAT]:m.Category.PUBLIC_CHAT};class Do{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:b.QuestionType.PROMOTION,topicSubType:tr(n.slEventBus.payload.type)});break;case"notification-opened":this.opened({questionId:n.slEventBus.payload.id,questionType:b.QuestionType.PROMOTION,topicSubType:tr(n.slEventBus.payload.type)});break}};return K.listen(r)})}received=({questionId:e,questionType:r,topicSubType:n})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:r?He[r]:m.TopicType.UNSET,topicSubType:n},notificationKind:Z.NotificationKind.POLLS,notificationType:Z.NotificationType.IN_APP})};opened=({questionId:e,questionType:r,topicSubType:n})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.NOTIFICATION_OPENED,topicId:e,topicType:r?He[r]:m.TopicType.UNSET,topicSubType:n},notificationKind:Z.NotificationKind.POLLS,notificationType:Z.NotificationType.IN_APP})}}class Ro{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 K.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_RECEIVED,topicId:e,topicType:r?He[r]:m.TopicType.UNSET},pollOpenedFrom:m.PollOpenedFrom.UNSET})};opened=({questionId:e,questionType:r,questionOpenedFrom:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_OPENED,topicId:e,topicType:r?He[r]:m.TopicType.UNSET},pollOpenedFrom:n==="list"?m.PollOpenedFrom.PICK_HISTORY:m.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_VOTE,topicId:e,topicType:r?He[r]:m.TopicType.UNSET},pollOpenedFrom:m.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.GAMES_JOINED},pollOpenedFrom:m.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_NAVIGATED},pollOpenedFrom:m.PollOpenedFrom.UNSET})}}const Vo=({transport:t,$commonStore:e})=>{let r;const n=q(!1),i=3e4,{client:o,queryKey:s}=t.createPromiseClient(hn.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:m.Kind.SESSION_HEARTBEAT}}}})}catch(S){he.error(S,"send heartbeat failed")}return Date.now()},refetchInterval:i}),u=()=>{he.debug("mounted heartbeat"),r=a.subscribe(()=>{})},d=()=>{he.debug("enabled heartbeat"),n.set(!0),a.lc===0&&u()},c=()=>{he.debug("disabled heartbeat"),n.set(!1)};return{enable:d,disable:c,mount:u,unmount:()=>{he.debug("unmounted heartbeat"),a.off(),r?.(),r=void 0,c()}}},he=be("analytics");class $o{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 Ie(W({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=Vo({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new Do(this),this.polls=new Ro(this),this.invitation=new Co(this),this.interactions=new Po(this),this.advertisement=new No(this);const{client:r}=e.analyticsTransport.createPromiseClient(hn.AnalyticsService,{method:"send"});this.analyticsClient=r}connect=()=>{this.writeCommon("sessionId",yt.v4()),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",Fo[r]),r!==R.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",yt.v4()):this.writeCommon("overlaySessionId","")})),this.onConnect(()=>{const r=window.matchMedia("(orientation: portrait)"),n=i=>{this.writeCommon("screenOrientation",i.matches?m.ScreenOrientation.PORTRAIT:m.ScreenOrientation.LANDSCAPE)};return r.addEventListener("change",n),()=>{r.removeEventListener("change",n)}}),this.onConnect(()=>e.deepLink.$store.subscribe(r=>{r?.handled&&this.invitation.accepted()}))}}const Mo=(t,e,r)=>{t.analytics=new $o(t),t.sdk.onMount({name:"analytics"},()=>(t.analytics.connect(),t.sdk.writeOverlaySessionId=n=>{n===""?t.analytics.writeCommon("overlaySessionId",""):t.analytics.writeCommon("overlaySessionId",yt.v4())},()=>{t.analytics.disconnect()})),r()};var pr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var hr={exports:{}},yr={exports:{}};function Uo(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 qo=Uo,Qo=qo;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=Qo(jo),i=null,o=null,s=0,a=null,u={push:v,drain:H,saturated:H,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++,_()},running:d,resume:S,idle:T,length:l,getQueue:p,unshift:w,empty:H,kill:$,killAndDrain:G,error:J};return u;function d(){return s}function c(){u.paused=!0}function l(){for(var N=i,V=0;N;)N=N.next,V++;return V}function p(){for(var N=i,V=[];N;)V.push(N.value),N=N.next;return V}function S(){if(u.paused){if(u.paused=!1,i===null){s++,_();return}for(;i&&s<r;)s++,_()}}function T(){return s===0&&u.length()===0}function v(N,V){var k=n.get();k.context=t,k.release=_,k.value=N,k.callback=V||H,k.errorHandler=a,s>=r||u.paused?o?(o.next=k,o=k):(i=k,o=k,u.saturated()):(s++,e.call(t,k.value,k.worked))}function w(N,V){var k=n.get();k.context=t,k.release=_,k.value=N,k.callback=V||H,k.errorHandler=a,s>=r||u.paused?i?(k.next=i,i=k):(i=k,o=k,u.saturated()):(s++,e.call(t,k.value,k.worked))}function _(N){N&&n.release(N);var V=i;V&&s<=r?u.paused?s--:(o===i&&(o=null),i=V.next,V.next=null,e.call(t,V.value,V.worked),o===null&&u.empty()):--s===0&&u.drain()}function $(){i=null,o=null,u.drain=H}function G(){i=null,o=null,u.drain(),u.drain=H}function J(N){a=N}}function H(){}function jo(){this.value=null,this.callback=H,this.next=null,this.release=H,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=H,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,l){e.call(this,c).then(function(p){l(null,p)},l)}var i=On(t,n,r),o=i.push,s=i.unshift;return i.push=a,i.unshift=u,i.drained=d,i;function a(c){var l=new Promise(function(p,S){o(c,function(T,v){if(T){S(T);return}p(v)})});return l.catch(H),l}function u(c){var l=new Promise(function(p,S){s(c,function(T,v){if(T){S(T);return}p(v)})});return l.catch(H),l}function d(){if(i.idle())return new Promise(function(p){p()});var c=i.drain,l=new Promise(function(p){i.drain=function(){c(),p()}});return l}}yr.exports=On;yr.exports.promise=xo;var kn=yr.exports,gr={exports:{}},Be=typeof Reflect=="object"?Reflect:null,Qr=Be&&typeof Be.apply=="function"?Be.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},ct;Be&&typeof Be.ownKeys=="function"?ct=Be.ownKeys:Object.getOwnPropertySymbols?ct=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ct=function(e){return Object.getOwnPropertyNames(e)};function Go(t){console&&console.warn&&console.warn(t)}var _n=Number.isNaN||function(e){return e!==e};function F(){F.init.call(this)}gr.exports=F;gr.exports.once=Wo;F.EventEmitter=F;F.prototype._events=void 0;F.prototype._eventsCount=0;F.prototype._maxListeners=void 0;var jr=10;function Ot(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||_n(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||_n(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 Cn(t){return t._maxListeners===void 0?F.defaultMaxListeners:t._maxListeners}F.prototype.getMaxListeners=function(){return Cn(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")Qr(u,this,r);else for(var d=u.length,c=Dn(u,d),n=0;n<d;++n)Qr(c[n],this,r);return!0};function Pn(t,e,r,n){var i,o,s;if(Ot(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=Cn(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,Go(a)}return t}F.prototype.addListener=function(e,r){return Pn(this,e,r,!1)};F.prototype.on=F.prototype.addListener;F.prototype.prependListener=function(e,r){return Pn(this,e,r,!0)};function Ko(){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 Ln(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Ko.bind(n);return i.listener=r,n.wrapFn=i,i}F.prototype.once=function(e,r){return Ot(r),this.on(e,Ln(this,e,r)),this};F.prototype.prependOnceListener=function(e,r){return Ot(r),this.prependListener(e,Ln(this,e,r)),this};F.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Ot(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():zo(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?Ho(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?ct(this._events):[]};function Dn(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function zo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Ho(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Wo(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"&&Yo(t,i,{once:!0})})}function Yo(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=gr.exports,kt={},$n={},Mn=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},Jo=Mn,_t=function(){return Jo()&&!!Symbol.toStringTag},Xo=Error,Zo=EvalError,es=RangeError,ts=ReferenceError,Bn=SyntaxError,Ct=TypeError,rs=URIError,xr=typeof Symbol<"u"&&Symbol,ns=Mn,is=function(){return typeof xr!="function"||typeof Symbol!="function"||typeof xr("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:ns()},Rt={__proto__:null,foo:{}},os=Object,ss=function(){return{__proto__:Rt}.foo===Rt.foo&&!(Rt instanceof os)},as="Function.prototype.bind called on incompatible ",us=Object.prototype.toString,cs=Math.max,ls="[object Function]",Gr=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},ds=function(e,r){for(var n=[],i=r,o=0;i<e.length;i+=1,o+=1)n[o]=e[i];return n},fs=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r},ps=function(e){var r=this;if(typeof r!="function"||us.apply(r)!==ls)throw new TypeError(as+r);for(var n=ds(arguments,1),i,o=function(){if(this instanceof i){var c=r.apply(this,Gr(n,arguments));return Object(c)===c?c:this}return r.apply(e,Gr(n,arguments))},s=cs(0,r.length-n.length),a=[],u=0;u<s;u++)a[u]="$"+u;if(i=Function("binder","return function ("+fs(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var d=function(){};d.prototype=r.prototype,i.prototype=new d,d.prototype=null}return i},hs=ps,mr=Function.prototype.bind||hs,ys=Function.prototype.call,gs=Object.prototype.hasOwnProperty,ms=mr,bs=ms.call(ys,gs),O,vs=Xo,Ss=Zo,ws=es,Ts=ts,Qe=Bn,Ue=Ct,As=rs,Un=Function,Vt=function(t){try{return Un('"use strict"; return ('+t+").constructor;")()}catch{}},Oe=Object.getOwnPropertyDescriptor;if(Oe)try{Oe({},"")}catch{Oe=null}var $t=function(){throw new Ue},Es=Oe?function(){try{return arguments.callee,$t}catch{try{return Oe(arguments,"callee").get}catch{return $t}}}():$t,Fe=is(),Is=ss(),Q=Object.getPrototypeOf||(Is?function(t){return t.__proto__}:null),Re={},Os=typeof Uint8Array>"u"||!Q?O:Q(Uint8Array),ke={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?O:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?O:ArrayBuffer,"%ArrayIteratorPrototype%":Fe&&Q?Q([][Symbol.iterator]()):O,"%AsyncFromSyncIteratorPrototype%":O,"%AsyncFunction%":Re,"%AsyncGenerator%":Re,"%AsyncGeneratorFunction%":Re,"%AsyncIteratorPrototype%":Re,"%Atomics%":typeof Atomics>"u"?O:Atomics,"%BigInt%":typeof BigInt>"u"?O:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?O:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?O:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?O:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":vs,"%eval%":eval,"%EvalError%":Ss,"%Float32Array%":typeof Float32Array>"u"?O:Float32Array,"%Float64Array%":typeof Float64Array>"u"?O:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?O:FinalizationRegistry,"%Function%":Un,"%GeneratorFunction%":Re,"%Int8Array%":typeof Int8Array>"u"?O:Int8Array,"%Int16Array%":typeof Int16Array>"u"?O:Int16Array,"%Int32Array%":typeof Int32Array>"u"?O:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Fe&&Q?Q(Q([][Symbol.iterator]())):O,"%JSON%":typeof JSON=="object"?JSON:O,"%Map%":typeof Map>"u"?O:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Fe||!Q?O:Q(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?O:Promise,"%Proxy%":typeof Proxy>"u"?O:Proxy,"%RangeError%":ws,"%ReferenceError%":Ts,"%Reflect%":typeof Reflect>"u"?O:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?O:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Fe||!Q?O:Q(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?O:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Fe&&Q?Q(""[Symbol.iterator]()):O,"%Symbol%":Fe?Symbol:O,"%SyntaxError%":Qe,"%ThrowTypeError%":Es,"%TypedArray%":Os,"%TypeError%":Ue,"%Uint8Array%":typeof Uint8Array>"u"?O:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?O:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?O:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?O:Uint32Array,"%URIError%":As,"%WeakMap%":typeof WeakMap>"u"?O:WeakMap,"%WeakRef%":typeof WeakRef>"u"?O:WeakRef,"%WeakSet%":typeof WeakSet>"u"?O:WeakSet};if(Q)try{null.error}catch(t){var ks=Q(Q(t));ke["%Error.prototype%"]=ks}var _s=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 ke[e]=r,r},Kr={__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"]},Xe=mr,mt=bs,Cs=Xe.call(Function.call,Array.prototype.concat),Ps=Xe.call(Function.apply,Array.prototype.splice),zr=Xe.call(Function.call,String.prototype.replace),bt=Xe.call(Function.call,String.prototype.slice),Ls=Xe.call(Function.call,RegExp.prototype.exec),Ns=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Fs=/\\(\\)?/g,Ds=function(e){var r=bt(e,0,1),n=bt(e,-1);if(r==="%"&&n!=="%")throw new Qe("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Qe("invalid intrinsic syntax, expected opening `%`");var i=[];return zr(e,Ns,function(o,s,a,u){i[i.length]=a?zr(u,Fs,"$1"):s||o}),i},Rs=function(e,r){var n=e,i;if(mt(Kr,n)&&(i=Kr[n],n="%"+i[0]+"%"),mt(ke,n)){var o=ke[n];if(o===Re&&(o=_s(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 Qe("intrinsic "+e+" does not exist!")},Ze=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(Ls(/^%?[^%]*%?$/,e)===null)throw new Qe("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Ds(e),i=n.length>0?n[0]:"",o=Rs("%"+i+"%",r),s=o.name,a=o.value,u=!1,d=o.alias;d&&(i=d[0],Ps(n,Cs([0,1],d)));for(var c=1,l=!0;c<n.length;c+=1){var p=n[c],S=bt(p,0,1),T=bt(p,-1);if((S==='"'||S==="'"||S==="`"||T==='"'||T==="'"||T==="`")&&S!==T)throw new Qe("property names with quotes must have matching quotes");if((p==="constructor"||!l)&&(u=!0),i+="."+p,s="%"+i+"%",mt(ke,s))a=ke[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(Oe&&c+1>=n.length){var v=Oe(a,p);l=!!v,l&&"get"in v&&!("originalValue"in v.get)?a=v.get:a=a[p]}else l=mt(a,p),a=a[p];l&&!u&&(ke[s]=a)}}return a},qn={exports:{}},Mt,Hr;function br(){if(Hr)return Mt;Hr=1;var t=Ze,e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return Mt=e,Mt}var Vs=Ze,lt=Vs("%Object.getOwnPropertyDescriptor%",!0);if(lt)try{lt([],"length")}catch{lt=null}var Pt=lt,Wr=br(),$s=Bn,De=Ct,Yr=Pt,Ms=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=!!Yr&&Yr(e,r);if(Wr)Wr(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 $s("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},rr=br(),Qn=function(){return!!rr};Qn.hasArrayLengthDefineBug=function(){if(!rr)return null;try{return rr([],"length",{value:1}).length!==1}catch{return!0}};var Bs=Qn,Us=Ze,Jr=Ms,qs=Bs(),Xr=Pt,Zr=Ct,Qs=Us("%Math.floor%"),js=function(e,r){if(typeof e!="function")throw new Zr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Qs(r)!==r)throw new Zr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in e&&Xr){var s=Xr(e,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(qs?Jr(e,"length",r,!0,!0):Jr(e,"length",r)),e};(function(t){var e=mr,r=Ze,n=js,i=Ct,o=r("%Function.prototype.apply%"),s=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(s,o),u=br(),d=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+d(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})(qn);var vr=qn.exports,jn=Ze,xn=vr,xs=xn(jn("String.prototype.indexOf")),Sr=function(e,r){var n=jn(e,!!r);return typeof n=="function"&&xs(e,".prototype.")>-1?xn(n):n},Gs=_t(),Ks=Sr,nr=Ks("Object.prototype.toString"),Lt=function(e){return Gs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:nr(e)==="[object Arguments]"},Gn=function(e){return Lt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&nr(e)!=="[object Array]"&&nr(e.callee)==="[object Function]"},zs=function(){return Lt(arguments)}();Lt.isLegacyArguments=Gn;var Hs=zs?Lt:Gn,Ws=Object.prototype.toString,Ys=Function.prototype.toString,Js=/^\s*(?:function)?\*/,Kn=_t(),Bt=Object.getPrototypeOf,Xs=function(){if(!Kn)return!1;try{return Function("return function*() {}")()}catch{}},Ut,Zs=function(e){if(typeof e!="function")return!1;if(Js.test(Ys.call(e)))return!0;if(!Kn){var r=Ws.call(e);return r==="[object GeneratorFunction]"}if(!Bt)return!1;if(typeof Ut>"u"){var n=Xs();Ut=n?Bt(n):!1}return Bt(e)===Ut},zn=Function.prototype.toString,$e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ir,dt;if(typeof $e=="function"&&typeof Object.defineProperty=="function")try{ir=Object.defineProperty({},"length",{get:function(){throw dt}}),dt={},$e(function(){throw 42},null,ir)}catch(t){t!==dt&&($e=null)}else $e=null;var ea=/^\s*class\b/,or=function(e){try{var r=zn.call(e);return ea.test(r)}catch{return!1}},qt=function(e){try{return or(e)?!1:(zn.call(e),!0)}catch{return!1}},ft=Object.prototype.toString,ta="[object Object]",ra="[object Function]",na="[object GeneratorFunction]",ia="[object HTMLAllCollection]",oa="[object HTML document.all class]",sa="[object HTMLCollection]",aa=typeof Symbol=="function"&&!!Symbol.toStringTag,ua=!(0 in[,]),sr=function(){return!1};if(typeof document=="object"){var ca=document.all;ft.call(ca)===ft.call(document.all)&&(sr=function(e){if((ua||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=ft.call(e);return(r===ia||r===oa||r===sa||r===ta)&&e("")==null}catch{}return!1})}var la=$e?function(e){if(sr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{$e(e,null,ir)}catch(r){if(r!==dt)return!1}return!or(e)&&qt(e)}:function(e){if(sr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(aa)return qt(e);if(or(e))return!1;var r=ft.call(e);return r!==ra&&r!==na&&!/^\[object HTML/.test(r)?!1:qt(e)},da=la,fa=Object.prototype.toString,Hn=Object.prototype.hasOwnProperty,pa=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))},ha=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)},ya=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))},ga=function(e,r,n){if(!da(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),fa.call(e)==="[object Array]"?pa(e,r,i):typeof e=="string"?ha(e,r,i):ya(e,r,i)},Wn=ga,ma=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],Qt=ma,ba=typeof globalThis>"u"?pr:globalThis,Yn=function(){for(var e=[],r=0;r<Qt.length;r++)typeof ba[Qt[r]]=="function"&&(e[e.length]=Qt[r]);return e},vt=Wn,va=Yn,en=vr,wr=Sr,pt=Pt,Sa=wr("Object.prototype.toString"),Jn=_t(),tn=typeof globalThis>"u"?pr:globalThis,ar=va(),Tr=wr("String.prototype.slice"),jt=Object.getPrototypeOf,wa=wr("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},St={__proto__:null};Jn&&pt&&jt?vt(ar,function(t){var e=new tn[t];if(Symbol.toStringTag in e){var r=jt(e),n=pt(r,Symbol.toStringTag);if(!n){var i=jt(r);n=pt(i,Symbol.toStringTag)}St["$"+t]=en(n.get)}}):vt(ar,function(t){var e=new tn[t],r=e.slice||e.set;r&&(St["$"+t]=en(r))});var Ta=function(e){var r=!1;return vt(St,function(n,i){if(!r)try{"$"+n(e)===i&&(r=Tr(i,1))}catch{}}),r},Aa=function(e){var r=!1;return vt(St,function(n,i){if(!r)try{n(e),r=Tr(i,1)}catch{}}),r},Ea=function(e){if(!e||typeof e!="object")return!1;if(!Jn){var r=Tr(Sa(e),8,-1);return wa(ar,r)>-1?r:r!=="Object"?!1:Aa(e)}return pt?Ta(e):null},wt=Wn,Ia=Yn,rn=vr,Ar=Sr,ht=Pt,Oa=Ar("Object.prototype.toString"),Xn=_t(),nn=typeof globalThis>"u"?pr:globalThis,ur=Ia(),Er=Ar("String.prototype.slice"),xt=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},Tt={__proto__:null};Xn&&ht&&xt?wt(ur,function(t){var e=new nn[t];if(Symbol.toStringTag in e){var r=xt(e),n=ht(r,Symbol.toStringTag);if(!n){var i=xt(r);n=ht(i,Symbol.toStringTag)}Tt["$"+t]=rn(n.get)}}):wt(ur,function(t){var e=new nn[t],r=e.slice||e.set;r&&(Tt["$"+t]=rn(r))});var _a=function(e){var r=!1;return wt(Tt,function(n,i){if(!r)try{"$"+n(e)===i&&(r=Er(i,1))}catch{}}),r},Ca=function(e){var r=!1;return wt(Tt,function(n,i){if(!r)try{n(e),r=Er(i,1)}catch{}}),r},Pa=function(e){if(!e||typeof e!="object")return!1;if(!Xn){var r=Er(Oa(e),8,-1);return ka(ur,r)>-1?r:r!=="Object"?!1:Ca(e)}return ht?_a(e):null},La=Pa,Na=function(e){return!!La(e)};(function(t){var e=Hs,r=Zs,n=Ea,i=Na;function o(y){return y.call.bind(y)}var s=typeof BigInt<"u",a=typeof Symbol<"u",u=o(Object.prototype.toString),d=o(Number.prototype.valueOf),c=o(String.prototype.valueOf),l=o(Boolean.prototype.valueOf);if(s)var p=o(BigInt.prototype.valueOf);if(a)var S=o(Symbol.prototype.valueOf);function T(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 v(y){return typeof Promise<"u"&&y instanceof Promise||y!==null&&typeof y=="object"&&typeof y.then=="function"&&typeof y.catch=="function"}t.isPromise=v;function w(y){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(y):i(y)||h(y)}t.isArrayBufferView=w;function _(y){return n(y)==="Uint8Array"}t.isUint8Array=_;function $(y){return n(y)==="Uint8ClampedArray"}t.isUint8ClampedArray=$;function G(y){return n(y)==="Uint16Array"}t.isUint16Array=G;function J(y){return n(y)==="Uint32Array"}t.isUint32Array=J;function N(y){return n(y)==="Int8Array"}t.isInt8Array=N;function V(y){return n(y)==="Int16Array"}t.isInt16Array=V;function k(y){return n(y)==="Int32Array"}t.isInt32Array=k;function ne(y){return n(y)==="Float32Array"}t.isFloat32Array=ne;function ie(y){return n(y)==="Float64Array"}t.isFloat64Array=ie;function _e(y){return n(y)==="BigInt64Array"}t.isBigInt64Array=_e;function we(y){return n(y)==="BigUint64Array"}t.isBigUint64Array=we;function ce(y){return u(y)==="[object Map]"}ce.working=typeof Map<"u"&&ce(new Map);function Nt(y){return typeof Map>"u"?!1:ce.working?ce(y):y instanceof Map}t.isMap=Nt;function ve(y){return u(y)==="[object Set]"}ve.working=typeof Set<"u"&&ve(new Set);function Ge(y){return typeof Set>"u"?!1:ve.working?ve(y):y instanceof Set}t.isSet=Ge;function Ce(y){return u(y)==="[object WeakMap]"}Ce.working=typeof WeakMap<"u"&&Ce(new WeakMap);function Ft(y){return typeof WeakMap>"u"?!1:Ce.working?Ce(y):y instanceof WeakMap}t.isWeakMap=Ft;function Pe(y){return u(y)==="[object WeakSet]"}Pe.working=typeof WeakSet<"u"&&Pe(new WeakSet);function le(y){return Pe(y)}t.isWeakSet=le;function Le(y){return u(y)==="[object ArrayBuffer]"}Le.working=typeof ArrayBuffer<"u"&&Le(new ArrayBuffer);function et(y){return typeof ArrayBuffer>"u"?!1:Le.working?Le(y):y instanceof ArrayBuffer}t.isArrayBuffer=et;function f(y){return u(y)==="[object DataView]"}f.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&f(new DataView(new ArrayBuffer(1),0,1));function h(y){return typeof DataView>"u"?!1:f.working?f(y):y instanceof DataView}t.isDataView=h;var g=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function A(y){return u(y)==="[object SharedArrayBuffer]"}function P(y){return typeof g>"u"?!1:(typeof A.working>"u"&&(A.working=A(new g)),A.working?A(y):y instanceof g)}t.isSharedArrayBuffer=P;function L(y){return u(y)==="[object AsyncFunction]"}t.isAsyncFunction=L;function I(y){return u(y)==="[object Map Iterator]"}t.isMapIterator=I;function C(y){return u(y)==="[object Set Iterator]"}t.isSetIterator=C;function D(y){return u(y)==="[object Generator]"}t.isGeneratorObject=D;function z(y){return u(y)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=z;function Te(y){return T(y,d)}t.isNumberObject=Te;function tt(y){return T(y,c)}t.isStringObject=tt;function Ne(y){return T(y,l)}t.isBooleanObject=Ne;function rt(y){return s&&T(y,p)}t.isBigIntObject=rt;function kr(y){return a&&T(y,S)}t.isSymbolObject=kr;function ni(y){return Te(y)||tt(y)||Ne(y)||rt(y)||kr(y)}t.isBoxedPrimitive=ni;function ii(y){return typeof Uint8Array<"u"&&(et(y)||P(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 Fa=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},cr={exports:{}};typeof Object.create=="function"?cr.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:cr.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 Da=cr.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(h){for(var g=Object.keys(h),A={},P=0;P<g.length;P++)A[g[P]]=Object.getOwnPropertyDescriptor(h,g[P]);return A},r=/%[sdj%]/g;t.format=function(f){if(!N(f)){for(var h=[],g=0;g<arguments.length;g++)h.push(s(arguments[g]));return h.join(" ")}for(var g=1,A=arguments,P=A.length,L=String(f).replace(r,function(C){if(C==="%%")return"%";if(g>=P)return C;switch(C){case"%s":return String(A[g++]);case"%d":return Number(A[g++]);case"%j":try{return JSON.stringify(A[g++])}catch{return"[Circular]"}default:return C}}),I=A[g];g<P;I=A[++g])$(I)||!ie(I)?L+=" "+I:L+=" "+s(I);return L},t.deprecate=function(f,h){if(typeof E<"u"&&E.noDeprecation===!0)return f;if(typeof E>"u")return function(){return t.deprecate(f,h).apply(this,arguments)};var g=!1;function A(){if(!g){if(E.throwDeprecation)throw new Error(h);E.traceDeprecation?console.trace(h):console.error(h),g=!0}return f.apply(this,arguments)}return A};var n={},i=/^$/;if(E.env.NODE_DEBUG){var o=E.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(f){if(f=f.toUpperCase(),!n[f])if(i.test(f)){var h=E.pid;n[f]=function(){var g=t.format.apply(t,arguments);console.error("%s %d: %s",f,h,g)}}else n[f]=function(){};return n[f]};function s(f,h){var g={seen:[],stylize:u};return arguments.length>=3&&(g.depth=arguments[2]),arguments.length>=4&&(g.colors=arguments[3]),_(h)?g.showHidden=h:h&&t._extend(g,h),k(g.showHidden)&&(g.showHidden=!1),k(g.depth)&&(g.depth=2),k(g.colors)&&(g.colors=!1),k(g.customInspect)&&(g.customInspect=!0),g.colors&&(g.stylize=a),c(g,f,g.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(f,h){var g=s.styles[h];return g?"\x1B["+s.colors[g][0]+"m"+f+"\x1B["+s.colors[g][1]+"m":f}function u(f,h){return f}function d(f){var h={};return f.forEach(function(g,A){h[g]=!0}),h}function c(f,h,g){if(f.customInspect&&h&&ce(h.inspect)&&h.inspect!==t.inspect&&!(h.constructor&&h.constructor.prototype===h)){var A=h.inspect(g,f);return N(A)||(A=c(f,A,g)),A}var P=l(f,h);if(P)return P;var L=Object.keys(h),I=d(L);if(f.showHidden&&(L=Object.getOwnPropertyNames(h)),we(h)&&(L.indexOf("message")>=0||L.indexOf("description")>=0))return p(h);if(L.length===0){if(ce(h)){var C=h.name?": "+h.name:"";return f.stylize("[Function"+C+"]","special")}if(ne(h))return f.stylize(RegExp.prototype.toString.call(h),"regexp");if(_e(h))return f.stylize(Date.prototype.toString.call(h),"date");if(we(h))return p(h)}var D="",z=!1,Te=["{","}"];if(w(h)&&(z=!0,Te=["[","]"]),ce(h)){var tt=h.name?": "+h.name:"";D=" [Function"+tt+"]"}if(ne(h)&&(D=" "+RegExp.prototype.toString.call(h)),_e(h)&&(D=" "+Date.prototype.toUTCString.call(h)),we(h)&&(D=" "+p(h)),L.length===0&&(!z||h.length==0))return Te[0]+D+Te[1];if(g<0)return ne(h)?f.stylize(RegExp.prototype.toString.call(h),"regexp"):f.stylize("[Object]","special");f.seen.push(h);var Ne;return z?Ne=S(f,h,g,I,L):Ne=L.map(function(rt){return T(f,h,g,I,rt,z)}),f.seen.pop(),v(Ne,D,Te)}function l(f,h){if(k(h))return f.stylize("undefined","undefined");if(N(h)){var g="'"+JSON.stringify(h).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return f.stylize(g,"string")}if(J(h))return f.stylize(""+h,"number");if(_(h))return f.stylize(""+h,"boolean");if($(h))return f.stylize("null","null")}function p(f){return"["+Error.prototype.toString.call(f)+"]"}function S(f,h,g,A,P){for(var L=[],I=0,C=h.length;I<C;++I)Pe(h,String(I))?L.push(T(f,h,g,A,String(I),!0)):L.push("");return P.forEach(function(D){D.match(/^\d+$/)||L.push(T(f,h,g,A,D,!0))}),L}function T(f,h,g,A,P,L){var I,C,D;if(D=Object.getOwnPropertyDescriptor(h,P)||{value:h[P]},D.get?D.set?C=f.stylize("[Getter/Setter]","special"):C=f.stylize("[Getter]","special"):D.set&&(C=f.stylize("[Setter]","special")),Pe(A,P)||(I="["+P+"]"),C||(f.seen.indexOf(D.value)<0?($(g)?C=c(f,D.value,null):C=c(f,D.value,g-1),C.indexOf(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const oi=require("pino"),b=require("@streamlayer/sl-eslib/interactive/interactive.common_pb"),it=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb"),R=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),ot=require("@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb"),te=require("nanostores"),yt=require("uuid"),B=require("@connectrpc/connect"),_r=require("@connectrpc/connect-web"),Cr=require("@nanostores/query"),fn=require("@streamlayer/sl-eslib/sports/events/events_connect"),Je=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),fr=require("@streamlayer/sl-eslib/users/users_connect"),re=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),pn=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect");require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb");const si=require("@streamlayer/sl-eslib/shortLinks/linksClient_connect"),m=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),hn=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_connect"),Pr=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),Z=require("@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb");function ai(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var yn={exports:{}},U=yn.exports={},se,ae;function Jt(){throw new Error("setTimeout has not been defined")}function Xt(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?se=setTimeout:se=Jt}catch{se=Jt}try{typeof clearTimeout=="function"?ae=clearTimeout:ae=Xt}catch{ae=Xt}})();function gn(t){if(se===setTimeout)return setTimeout(t,0);if((se===Jt||!se)&&setTimeout)return se=setTimeout,setTimeout(t,0);try{return se(t,0)}catch{try{return se.call(null,t,0)}catch{return se.call(this,t,0)}}}function ui(t){if(ae===clearTimeout)return clearTimeout(t);if((ae===Xt||!ae)&&clearTimeout)return ae=clearTimeout,clearTimeout(t);try{return ae(t)}catch{try{return ae.call(null,t)}catch{return ae.call(this,t)}}}var ye=[],Me=!1,Ee,ut=-1;function ci(){!Me||!Ee||(Me=!1,Ee.length?ye=Ee.concat(ye):ut=-1,ye.length&&mn())}function mn(){if(!Me){var t=gn(ci);Me=!0;for(var e=ye.length;e;){for(Ee=ye,ye=[];++ut<e;)Ee&&Ee[ut].run();ut=-1,e=ye.length}Ee=null,Me=!1,ui(t)}}U.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 bn(t,e)),ye.length===1&&!Me&&gn(mn)};function bn(t,e){this.fun=t,this.array=e}bn.prototype.run=function(){this.fun.apply(null,this.array)};U.title="browser";U.browser=!0;U.env={};U.argv=[];U.version="";U.versions={};function me(){}U.on=me;U.addListener=me;U.once=me;U.off=me;U.removeListener=me;U.removeAllListeners=me;U.emit=me;U.prependListener=me;U.prependOnceListener=me;U.listeners=function(t){return[]};U.binding=function(t){throw new Error("process.binding is not supported")};U.cwd=function(){return"/"};U.chdir=function(t){throw new Error("process.chdir is not supported")};U.umask=function(){return 0};var li=yn.exports;const E=ai(li),di=oi.pino({level:"trace",enabled:typeof window<"u"&&!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),be=(t,e)=>di.child({name:t},e);class fi extends Event{slEventBus;constructor(e,r){super(e),this.slEventBus=r}}const pi=be("event-bus");class hi{name;listeners;constructor(e="sl-event-bus"){this.name=e,this.listeners=new Set}emit=(e,r)=>{const n=new fi(this.name,{...r,type:e});pi.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 yi{}var ge;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(ge||(ge={}));window.slStore=Object.create(null);class Et{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 Ie extends Et{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 W=t=>te.map(t);var fe;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(fe||(fe={}));const mi={[R.SdkOverlayType.BETTING]:"betting",[R.SdkOverlayType.GAMES]:"games",[R.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[R.SdkOverlayType.TWITTER]:"twitter"};var He;(function(t){t.Ready="ready",t.Suspended="suspended"})(He||(He={}));class vn{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},n){this.settingsKey=mi[r.type],this.status=te.atom(He.Suspended),this.config=new Ie(W(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new Ie(W(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new Ie(W({}),`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 Et{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 Q=t=>te.atom(t);class ee extends Et{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 K=new hi;async function*bi(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now(),t.id=Date.now();const n={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(n),yield r}}const vi=()=>t=>async e=>{const r={id:Date.now(),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:!0}};return window.postMessage(i),{...n,message:bi(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 X;(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"})(X||(X={}));const Lr=be("grpc:stream");class Si{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,n,i){const o={status:X.Init,ts:new Date,log:[]};this.state=new Ie(W(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(Q(null),`subscription:${i.name}:store`)),"subscribe"in n&&typeof n.subscribe=="function"&&(this.paramsListener=n.subscribe(s=>{this.state.getValue("status")===X.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(X.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")?Lr.trace({name:this.options.name,attempt:this.attempt},"received data"):Lr.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(X.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(X.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(X.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(X.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(X.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(X.Failed),this.state.setValue("error",e),e.code===B.Code.Unknown&&e.cause==="missing trailer"&&(this.attempt=0),this.reconnect();return}this.disconnect()}}}const wi=new Set([B.Code.Unknown,B.Code.Internal,B.Code.DeadlineExceeded,B.Code.ResourceExhausted,B.Code.FailedPrecondition,B.Code.Unavailable,B.Code.DataLoss]),Nr=be("grpc:retry"),Ti=t=>async e=>{const r=e.contextValues.get(Zt.retryAttempts),n=300,i=e.contextValues.get(Zt.retryDelay);if(e.stream||r===0)return t(e);Nr.trace({url:e.url,attempts:r,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){Nr.trace({attempt:o,error:s,url:e.url},"retry attempt");const a=B.ConnectError.from(s);if(o>=r||!(a instanceof B.ConnectError)||!wi.has(a.code))throw s;const u=Math.min(i,Math.pow(2,o)*n),d=Math.round(u*(1+Math.random())/2);await new Promise(c=>setTimeout(c,d))}},Zt={retryAttempts:B.createContextKey(10,{description:"Number of attempts to retry"}),retryDelay:B.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},Ai=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=yt.v4();return localStorage.setItem("sl-device-id",e),e},Ei=()=>navigator.userAgentData?.platform||navigator.platform;class Fr{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;$headers;storeCache;interceptors=[];clients;streamClients;subscriptions;opts;constructor(e,r){this.host=e,this.opts=r,this.$headers=new Ie(W({"sl-device-id":Ai(),"sl-device-os":Ei()}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.streamClients=new Map,this.subscriptions=new Map,this.storeCache=new Map;const[n,i,o]=Cr.nanoquery({dedupeTime:r?.dedupeTime,refetchInterval:r?.refetchInterval});this.nanoquery={createFetcherStore:n,createMutatorStore:i,utils:o},this.transport=_r.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors}),this.streamTransport=_r.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors})}addSubscription=(e,r,n)=>{const i=this.subscriptions.get(r);if(i)return i;const o=new Si(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]=Cr.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:d=>{const c=B.createContextValues();for(const l in d){const p=Zt[l];c.set(p,d[l])}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(vi()),this.opts?.retryable&&this.interceptors.push(Ti)}}const Ii=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(fn.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""}}})},Oi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Je.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})},ki=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(fn.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})},_i=(t,e)=>{const{queryKey:r,client:n}=e.createPromiseClient(fr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>{if(!e.getHeader("authorization"))return{data:void 0};const{data:o}=await n.me({});return{data:o}}})},Ci=t=>{const{client:e,createRequestOptions:r}=t.createPromiseClient(fr.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(Je.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.get({})).data?.attributes})},Li=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Je.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}})},Ni=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Je.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},Fi=(t,e,r)=>{t.transport=new Fr(e.host,{dedupeTime:1e3*60*5,refetchInterval:1e3*60*5,retryable:!0}),t.analyticsTransport=new Fr(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 Di=t=>{const e=new Ve,r=new Y(Q(e.getExternalToken()),"userKey"),n=new Y(Q(e.getToken()),"userToken"),i=new ee(_i(n.getStore(),t),"user",({data:s,error:a,loading:u},d)=>{if(!a)return s?.data?.id?s.data.id:u===!1?void 0:d}),o=new ee(Pi(n.getStore(),t),"userSettings");return{userKey:r,userToken:n,user:i,userSettings:o}},Ri=t=>{const e=new Y(Q(void 0),"providerStreamId"),r=new ee(Ii(e.getStore(),t),"slStreamId",o=>o?.data),n=new ee(Oi(r.getAtomStore(),t),"streamSettings"),i=new ee(ki(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}},Vi=t=>{const e=new Y(Q(void 0),"enabled"),r=new Y(Q(pe.DISABLED),"status"),n=new ee(Li(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new ee(Ni(n.getAtomStore(),t),"organizationAdvertising"),o=Di(t),s=Ri(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 $i extends Et{stores;constructor(e){const r=Vi(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 Mi=(t,e,r)=>{t.store=new $i(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()},Bi=t=>{const{client:e}=t.createPromiseClient(pn.Leaderboard,{method:"list"});return r=>e.list(r)},wn=t=>{const{client:e}=t.createPromiseClient(pn.Leaderboard,{method:"summary"});return r=>e.summary(r)},Ui=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(fr.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[]}}})},Qi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(re.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.get({eventId:s})).data?.attributes,refetchInterval:1/0,dedupeTime:1e3*60*60})},qi=(t,e,r)=>{const{client:n,queryKey:i}=r.createPromiseClient(re.Feed,{method:"syncQuestion",params:[t,e?"true":""]});return r.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>{if(!a||u)return;const d=await n.syncQuestion({filter:{eventId:a}});if(d.data?.attributes?.question?.type!==b.QuestionType.PROMOTION)return d.data?.attributes},dedupeTime:1e3*60*10,refetchInterval:1/0})},ji=async(t,e)=>{const{client:r}=e.createPromiseClient(re.Feed,{method:"item",params:[t]});return(await r.item({id:t})).data},xi=(t,e)=>{const{client:r}=e.createStreamClient(re.Feed),n=te.atom({eventId:t.get()||"",feedId:""});return t.subscribe((o="")=>{n.set({eventId:o,feedId:""})}),e.addSubscription(r.subscription,n,{name:"feedSubscription"})},Gi=(t,e)=>{const{client:r}=e.createStreamClient(re.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},er=async(t,e)=>{const{client:r}=e.createPromiseClient(re.Feed,{method:"questionByUser",params:[t]});return(await r.questionByUser({questionId:t})).data?.attributes?.question},ze=(t,e)=>{const{client:r,queryKey:n,queryKeyStr:i}=e.createPromiseClient(re.Feed,{method:"questionByUser",params:[t]});let o=i;if(typeof t!="object"?o+=t:o+="atom",e.storeCache.has(o))return e.storeCache.get(o);{const s=e.nanoquery.createFetcherStore(n,{fetcher:async(a,u,d)=>(await r.questionByUser({questionId:d})).data?.attributes?.question,dedupeTime:1/0,refetchInterval:1/0});return e.storeCache.set(o,s),s}},Ki=(t,e,r,n,i,o,s)=>{const{client:a,queryKey:u}=s.createPromiseClient(re.Feed,{method:"list",params:[t,e,o?"true":""]});return s.nanoquery.createFetcherStore(u,{fetcher:async(d,c,l,p,S)=>{if(!l||S)return[];const T=await a.list({eventId:l,filter:{types:p===Se.ALLOWED?[]:[b.QuestionType.FACTOID,b.QuestionType.PROMOTION,b.QuestionType.TWEET],statuses:[b.QuestionStatus.ACTIVE,b.QuestionStatus.RESOLVED]}}),v={eventId:l,userId:r.get(),organizationId:n.get()};for(const w of T.data)i.isQuestionReceived(v,w.id)||(K.emit("poll",{action:"received",payload:{questionId:w.id,questionType:w.attributes?.type}}),i.saveQuestionReceived(v,w.id));return T.data},dedupeTime:1/0,refetchInterval:1/0})},zi=(t,e,r,n,i)=>{const{client:o,queryKey:s}=i.createPromiseClient(re.Feed,{method:"betPack",params:[t,e,r]});return i.nanoquery.createFetcherStore(s,{fetcher:async(a,u,d,c,l)=>{if(!d||!c||!l)return{timestamp:Date.now(),data:null};const p=await o.betPack({eventId:d,types:[b.QuestionType.PREDICTION],statuses:[b.QuestionStatus.ACTIVE,b.QuestionStatus.RESOLVED],limit:5,sort:{field:"activated_at",order:"asc"}});return!p.data||!p.data.length?{timestamp:Date.now(),data:null}:{timestamp:Date.now(),data:p.data?.reduce((S,T)=>{const v=T?.attributes?.question;if(!v?.id)return S;const w={eventId:d,userId:c,organizationId:l};return n.isQuestionReceived(w,v.id)||(K.emit("poll",{action:"received",payload:{questionId:v.id,questionType:v.type}}),n.saveQuestionReceived(w,v.id)),v.answers=v.answers.sort((_,$)=>_.id>$.id?1:-1),{...S,[v.id]:v}},{})}},dedupeTime:1/0,refetchInterval:1/0})},Hi=(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),d=a?.question?.openedFrom;return u?(u.openedFrom=d,u):a.question}),i=te.batched(n,a=>a&&a.type==="question"?a.id:void 0),o=ze(i,t);return{$store:n,$extendedStore:o,updateExtendedQuestion:a=>{const u=o.get().data,d=(c,l)=>{if(!c||!l)return(c||l||[]).sort((v,w)=>v.id>w.id?1:-1);const p=c.sort((v,w)=>v.id>w.id?1:-1),S=l.sort((v,w)=>v.id>w.id?1:-1),T=[];for(let v=0;v<p.length;v++)T.push({...p[v],...S[v],correct:p[v].correct,youVoted:p[v].youVoted,pointsEarned:p[v].pointsEarned});return T};o.mutate({...a,options:u?.options,subject:u?.subject,appearance:u?.appearance,answers:d(u?.answers,a?.answers)})}}};var oe;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io",t.QUESTION_RECEIVED="q-received",t.QUESTION_OPENED="q-opened"})(oe||(oe={}));class Wi extends Xe{constructor(){super("gamification-session",window.sessionStorage)}writeValue=(e,r)=>{this.write(...e,r)};readValue=e=>this.read(...e)}class Yi extends Xe{sessionStorage;constructor(){super("gamification"),this.sessionStorage=new Wi}saveQuestionReceived=({userId:e,eventId:r,organizationId:n},i)=>{this.write(oe.QUESTION_RECEIVED,n,e,r,i,"1")};isQuestionReceived=({userId:e,eventId:r,organizationId:n},i)=>!!this.read(oe.QUESTION_RECEIVED,n,e,r,i);saveQuestionOpened=({userId:e,eventId:r,organizationId:n},i)=>{this.write(oe.QUESTION_OPENED,n,e,r,i,"1")};isQuestionOpened=({userId:e,eventId:r,organizationId:n},i)=>!!this.read(oe.QUESTION_OPENED,n,e,r,i);saveOnboardingStatus=({userId:e,eventId:r,organizationId:n},i)=>{this.write(oe.ONBOARDING,n,e,r,i)};getOnboardingStatus=({userId:e,eventId:r,organizationId:n})=>this.read(oe.ONBOARDING,n,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{this.sessionStorage.writeValue([oe.ONBOARDING_IO,n,e,r],"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>this.sessionStorage.readValue([oe.ONBOARDING_IO,n,e,r])}var Se;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Se||(Se={}));class Ji{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;betPack;moderationId;moderation;feedSubscription;questionSubscription;advertisement;storage;notifications;log;transport;cancels=new Set;constructor(e){this.transport=e.transport,this.log=be("gamification-background"),this.storage=new Yi,this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new Y(Q(void 0),"moderationId").getStore(),this.interactiveAllowed=new Y(Q(Se.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new Y(Q(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new ee(Qi(this.slStreamId,e.transport),"gamification:moderation");const r=!!e.sdk.options.get().betPack;this.feedList=new ee(Ki(this.slStreamId,this.interactiveAllowed,this.userId,this.organizationId,this.storage,r,e.transport),"gamification:feedList"),this.betPack=new ee(zi(this.slStreamId,this.userId,this.organizationId,this.storage,e.transport),"gamification:betPack"),this.activeQuestionId=qi(this.slStreamId,r,e.transport),this.openedQuestion=Hi(e.transport,this.openedQuestionId,this.feedList.getStore()),this.cancels.add(this.openedQuestionId.listen(n=>{this.log.debug({item:n},"received question"),n?.questionId?(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0),this.questionSubscription=Gi(n.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",i=>{const o=i.data?.attributes?.question;if(this.openedQuestion.updateExtendedQuestion(o),this.betPack&&o?.type===b.QuestionType.PREDICTION&&(o.status===b.QuestionStatus.ACTIVE||o.status===b.QuestionStatus.RESOLVED)){const s=this.betPack.getValues().data?.data||{},a=s?.[o.id];if(a){const u=[],d=a.answers.sort((l,p)=>l.id>p.id?1:-1),c=o.answers.sort((l,p)=>l.id>p.id?1:-1);for(let l=0;l<d.length;l++)u.push({...d[l],...c[l],correct:d[l].correct,youVoted:d[l].youVoted,pointsEarned:d[l].pointsEarned});this.betPack.getStore().mutate({timestamp:Date.now(),data:{...s,[o.id]:{...a,status:o.status,marketClosed:o.marketClosed,activatedAt:o.activatedAt,answerSetAt:o.answerSetAt,answers:u}}})}}}),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=xi(this.slStreamId,e.transport),this.cancels.add(this.feedSubscription.addListener("bet-pack-update",async n=>{const i=n.data?.attributes?.question;if(this.betPack&&i?.type===b.QuestionType.PREDICTION&&(i.status===b.QuestionStatus.ACTIVE||i.status===b.QuestionStatus.RESOLVED)){const o=this.betPack.getValues().data?.data||{},s=o?.[i.id];if(s)this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:{...s,status:i.status,marketClosed:i.marketClosed,activatedAt:i.activatedAt,answerSetAt:i.answerSetAt}}});else if(!s&&Object.keys(o).length<5){const a=await er(i.id,this.transport);this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:a}})}}})),this.cancels.add(this.feedSubscription.addListener("feed-subscription-active-question",n=>{const i=this.activeQuestionId.get().data?.question?.id,o=n.data?.attributes?.question;if(!(!o||o.type===b.QuestionType.PROMOTION)){if(o.status===b.QuestionStatus.RESOLVED){i===o.id&&this.activeQuestionId.mutate(void 0);return}window.requestAnimationFrame(()=>{this.activeQuestionId.mutate(n.data?.attributes)})}})),this.cancels.add(this.feedSubscription.addListener("moderation update",n=>{window.requestAnimationFrame(()=>{n.data?.attributes?.question===void 0&&n.data?.attributes?.moderation&&this.moderation.invalidate()})})),this.cancels.add(this.activeQuestionId.subscribe((n,i)=>{n.data?.feedItem&&n.data?.feedItem?.id!==i?.data?.feedItem?.id&&e.onQuestionActivate({stage:"activate",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}),!n.data?.feedItem&&i?.data?.feedItem&&e.onQuestionActivate({stage:"deactivate",id:i.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:i.data.feedItem.id})),hasNotification:!0,type:i.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 n of this.cancels)n(),this.cancels.delete(n)})}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 Xi{notificationsList;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=be("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notificationsList=Q(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}K.emit("notification",{action:"received",payload:{type:r.type,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&&K.emit("notification",{action:"closed",payload:{type:i.type,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 Zi extends Xe{constructor(){super("notification")}setOpened=e=>{this.write(gt.OPENED,e,"true")};isOpened=e=>this.read(gt.OPENED,e);clearNotification=()=>{this.clear()}}class eo{queue;storage;constructor(e={}){this.storage=new Zi,this.queue=new Xi({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),K.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===ge.ONBOARDING)return n;return e.values().next().value};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const to=(t,e,r)=>{t.notifications=new eo(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 Qe;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(Qe||(Qe={}));const Dr=async(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(re.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(Qe.ALREADY_VOTED):new Error(Qe.UNKNOWN)}},Tn=(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(re.Feed,{method:"submitInplay"}),i=n({retryAttempts:0});return r.submitInplay({data:{eventId:+e}},{contextValues:i})},ro={pageSize:10},no=(t,e,r,n,i)=>{let o=0;const s=Q({pageSize:ro.pageSize,page:0}),a=W({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=Bi(t),d=async()=>{const p=e.get(),S=n?.getStore().get().data?.map(T=>T.slId)||[];if(p&&S?.length){const T=r.get();T&&S.push(T),a.setKey("loading",!0),a.setKey("data",[]);const w=await u({eventId:p,usersIds:S});a.set({data:w.data.map((_,$)=>({..._.attributes,friendsRank:$+1})),hasMore:!1,key:Date.now(),loading:!1}),w.meta&&(o=Math.round(w.meta.count/w.meta.pageSize))}},c=()=>{d()},l=p=>{const S=s.get(),T=p||S.page+1;T<=o&&s.set({...S,page:T})};return te.onMount(a,()=>{const p=e.listen(d),S=n?.listen(d);return()=>{p(),S?.()}}),{$store:a,fetchMore:l,invalidate:c}};class io extends Xe{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Rr="sldl",It="sldl_uid",An="sldl_eid",En="sldl_e_eid",oo=new Set([It,An,En]),Vr=t=>{const e={},r={};for(const[n,i]of t)oo.has(n)?e[n]=i:r[n]=i;return{result:e,remain:r}},so=({hash:t,search:e})=>{if(t&&t.includes(Rr)){const r=new URLSearchParams(t.substr(1));return{hash:Vr(r)}}if(e&&e.includes(Rr)){const r=new URLSearchParams(e);return{search:Vr(r)}}return null},$r=be("deep_link"),ue={debug:(...t)=>{$r.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{$r.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},ao=(t,e)=>{const{hash:r,search:n}=window.location;if(ue.debug({hash:r,search:n},"get deep link data from"),r||n){const i=so({hash:r,search:n});if(ue.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 d=Object.keys(u).length!==0;if(o){let c="";d&&(c=`#${new URLSearchParams(u).toString()}`,ue.debug({updatedHash:c},"update hash")),window.history.replaceState(null,"",window.location.pathname+window.location.search+c)}if(s){let c="";d&&(c=`?${new URLSearchParams(u).toString()}`,ue.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},uo=(t,e,r)=>{const n=new io,i=n.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){ue.debug(a)}t.deepLink={$store:new Ie(W(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{ue.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?.[It]: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")&&ue.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{ue.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),ue.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{ue.trace("called handler"),u(a)}catch(d){console.error(d)}};ao(t.deepLink.$store,s),r()},co=be("bypass");class lo extends yi{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,n){super(),this.$coreStore=e,this.deepLink=n,this.transport=r,this.bypassLogin=Ci(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?.[It];co.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=({skipLogin:e}={skipLogin:!1})=>{const r=new Ve,n=r.getToken(),i=r.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(i),n)return this.saveUser(n,""),this.me().then(o=>{if(o?.id){const s=o.id;this.saveUser(n,s)}return o});if(i&&!n&&!e){const o=r.getSchema();o&&i&&this.login(o,i).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 Ke=new Ve,fo=(t,e,r)=>{t.auth=new lo(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(!(Ke.getSchema()===n&&Ke.getExternalToken()===i&&t.transport.getHeader("authorization")))try{await t.auth.login(n,i),Ke.setSchema(n),Ke.setExternalToken(i)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),Ke.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},Mr=be("video_player"),st={debug:(...t)=>{Mr.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{Mr.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},po=(t,e,r)=>{t.videoPlayer={controllers:new Set},t.sdk.addVideoPlayerController=n=>{st.trace("adding video player controller"),t.videoPlayer.controllers.add(n)},e.videoPlayerController&&t.sdk.addVideoPlayerController(e.videoPlayerController),t.sdk.removeVideoPlayerController=n=>{st.trace("removing video player controller"),t.videoPlayer.controllers.delete(n)},t.sdk.controlVideoPlayer=n=>{st.trace("controlling video player");for(const i of t.videoPlayer.controllers){st.trace("calling video player controller");try{i(n)}catch(o){console.error(o)}}},r()},ho={[b.QuestionType.FACTOID]:"insight",[b.QuestionType.POLL]:"poll",[b.QuestionType.TRIVIA]:"trivia",[b.QuestionType.PREDICTION]:"prediction",[b.QuestionType.TWEET]:"tweet"},yo=(t,e,r)=>{t.sdk.uiState=W({}),t.ui={enableAppNotification:function(){t.sdk.uiState.setKey("appNotification",!0)},disableAppNotification:function(){t.sdk.uiState.get().app||t.sdk.uiState.setKey("appNotification",!1)},enableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!0)},disableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!1)},enableApp:function(){t.sdk.uiState.set({app:!0,appNotification:!0})},disableApp:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),onboardingNotification:!1,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&&ho[i]||"question";t.ui.enableAppNotification(),t.ui.onContentActivate({...o,type:s})}},t.sdk.onMount({name:"ui"},()=>{const i=a=>{if(a.slEventBus?.type==="app")switch(a.slEventBus.action){case"open":t.ui.enableApp();break;case"close":t.ui.disableApp();break}if(a.slEventBus?.type==="notification"){const u=a.slEventBus.action;if(a.slEventBus.payload.type===ge.ONBOARDING)switch(u){case"received":t.ui.enableOnboardingNotification();break;case"closed":t.ui.disableOnboardingNotification();break}else switch(u){case"received":t.ui.enableAppNotification();break;case"closed":t.ui.disableAppNotification();break}}if(a.slEventBus?.type==="advertisement"&&e.withAd){const u=a.slEventBus,{hasNotification:d,hasBanner:c,id:l,isViewed:p,type:S}=u.payload;switch(u.action){case"notification-opened":t.sdk.uiState.set({promotionExternalAd:S===b.PromotionType.EXTERNAL_AD,promotionBanner:c,promotionNotification:!1,promotionOverlay:!0,promotionSidebar:!0});break;case"received":if(t.sdk.closeFeature(),n({stage:"activate",id:l,hasNotification:d,hasBanner:c,isViewed:p}),!e.withAdNotification){t.sdk.uiState.set({promotionBanner:c,onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionOverlay:!0,promotionSidebar:!0,promotionExternalAd:S===b.PromotionType.EXTERNAL_AD});break}d?t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionNotification:!0}):t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionBanner:c,promotionOverlay:!0,promotionSidebar:!0,promotionExternalAd:S===b.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:l,hasNotification:d,hasBanner:c,isViewed:p});break}}},o=K.listen(i),s=t.activeFeature.subscribe(a=>{a?(t.ui.enableApp(),t.sdk.uiState.set({app:!0})):t.ui.disableApp()});return()=>{o(),s()}}),r()},go=(t,e,r)=>{const n={onMountedFired:!1},i=new Map,o=new Map;t.sdk=Object.create(null),t.sdk.options=W(e),t.sdk.withAuth=!1,t.sdk.onMount=({name:s,clear:a},u)=>{if(i.has(s)){const d=o.get(s);d&&d(),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,a)=>{a?t.stores.slStreamId.getStore().set({loading:!1,data:s}):t.stores.providerStreamId.setValue(s)},r()},mo=(t,e)=>{const{client:r,queryKey:n}=t.createPromiseClient(Je.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:1/0})},bo=(t,{web:e,mobile:r})=>{const{client:n}=t.createPromiseClient(si.LinksClient,{method:"generate"});return n.generate({web:e,mobile:r})},Br=(t,e)=>{const r=new URLSearchParams(t);for(const[n,i]of Object.entries(e))r.append(n,i);return r.toString()},vo=(t,e,r,n)=>{const i=W({});return te.onMount(i,()=>mo(t,[e,r]).subscribe(async({data:a,loading:u})=>{const d=a===void 0&&u===!1?"https://streamlayer.io":a?.url,c=n.get()||"",l=e.get()||"",p=r.get()||"",S={[It]:c,[An]:l,[En]:p};if(!u&&d){i.setKey("loading",!0);let T=window.location.search,v=window.location.hash;T&&v||v?T=`?${Br(T,S)}`:v=`#${Br("",S)}`;const w=window.location.origin+window.location.pathname+T+v;try{const _=await bo(t,{web:w,mobile:d});i.set({data:_.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 So=(t,e,r,n)=>{const{inplayGame:i}=t.featureSettings.get(),o=e.getCurrentSessionId({prefix:"onboarding"});i&&r.add({type:ge.ONBOARDING,id:o,action:t.openFeature,close:()=>{t.onboardingProcessed.set(!0)},persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:b.QuestionType.UNSET,onboarding:{...i,instantOpen:!n.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},at=(t,e,r,n,i,o,s,a)=>{try{const u=e.userId.get(),d=e.organizationId.get(),c=e.slStreamId.get();if(!u||!d||!c)return;const l=i.getOnboardingStatus({userId:u,organizationId:d,eventId:c});if(l===M.Completed||a?.skipOnboarding){t.set(M.Completed);for(const w of o)w();a?.skipOnboarding&&l!==M.Completed&&(i.saveOnboardingStatus({organizationId:d,userId:u,eventId:c},M.Completed),Tn(s,c));return}const p=e.moderation.getStore().value?.data,S=r.featureSettings.get().inplayGame;if(p===void 0||S===void 0)return;const T=p?.options?.onboardingEnabled,v=S?.titleCard?.optIn;T?v?t.set(M.Required):t.set(M.Optional):(v?t.set(M.Unavailable):t.set(M.Disabled),n.close(e.getCurrentSessionId({prefix:"onboarding"}),{markAsViewed:!1}))}catch(u){console.error(u)}},Ur=(t,e,r,n,i)=>{let o=!!i?.skipOnboarding;const s=e.storage,a=Q(M.Unset);a.subscribe(c=>{c!==M.Unset&&(c===M.Optional||c===M.Required?o===!1&&(So(t,e,n,s),o=!0):t.onboardingProcessed.set(!0),c===M.Completed&&e.activeQuestionId.invalidate(),s.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const u=[];return a.get()!==M.Completed&&(u.push(e.userId.listen(c=>{c&&at(a,e,t,n,s,u,r,i)})),u.push(e.moderation.listen(c=>{c.data&&at(a,e,t,n,s,u,r,i)})),u.push(t.featureSettings.listen(c=>{c&&at(a,e,t,n,s,u,r,i)}))),at(a,e,t,n,s,u,r,i),{$store:a,submitInplay:async()=>{const c=e.slStreamId.get();if(c){await Tn(r,c),a.set(M.Completed),s.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:c},M.Completed),K.emit("poll",{action:"onboardingPassed",payload:{}}),t.openFeature();const l=e.getCurrentSessionId({prefix:"onboarding"});n.close(l)}}}},wo=(t,e,r,n)=>{const i=W(void 0),o=wn(n),s=async()=>{const u=t.get(),d=e.get(),c=r?r.getStore().get().data?.map(S=>S.slId):[];if(!c||!u||!d)return;const l={eventId:u,userId:d,usersIds:[...c,d]},p=await o(l);i.set(p.data?.attributes)},a=()=>{s()};return te.onMount(i,()=>{a();const u=t.listen(s),d=r?.listen(s),c=e.listen(s);return()=>{u(),d?.(),c()}}),{$store:i,invalidate:a}},To=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)||[],d={eventId:s,userId:n,usersIds:[...u,a]};return(await o(d)).data?.attributes?.summary},Qr=new Set([b.QuestionType.POLL,b.QuestionType.PREDICTION,b.QuestionType.TRIVIA]);class Ao extends vn{userSummary;feedList;betPack;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;advertisement;onboardingProcessed;friendsTabEnabled;skipOnboarding;notifications;transport;background;storage;submitAnswerTimeout;cancels=new Set;onQuestionActivate;constructor(e,r,n){if(super(e,r),this.background=new Ji(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=this.background.storage,this.feedList=this.background.feedList,this.betPack=this.background.betPack,this.currentUserId=this.background.userId,this.onboardingProcessed=Q(!n.sdk.withAuth),this.leaderboardId=new Y(Q(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.notifications=n.notifications,this.transport=n.transport,this.closeFeature=(i=!0)=>n.sdk.closeFeature(i),this.openFeature=()=>n.sdk.openFeature(R.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=vo(this.transport,this.background.slStreamId,n.stores.providerStreamId.getStore(),this.background.userId),this.userSummary=wo(this.background.slStreamId,this.background.userId,this.friends,this.transport),!n.sdk.options.get().hideFriends){this.friends=new ee(Ui(this.background.userId,n.transport),"gamification:friends"),this.openedUser=Q(void 0);const i=this.leaderboardList=no(this.transport,this.background.slStreamId,this.background.userId,this.friends);this.cancels.add(this.userSummary.$store.listen((o,s)=>{s?.summary&&o?.summary&&i.invalidate()}))}this.connect(),this.skipOnboarding=!!n.sdk.options.get().skipOnboarding,this.onboardingStatus=Ur(this,this.background,n.transport,n.notifications,{skipOnboarding:n.sdk.options.get().skipOnboarding}),n.sdk.options.get().skipOnboarding||(this.onboardingStatus=Ur(this,this.background,n.transport,n.notifications,{skipOnboarding:n.sdk.options.get().skipOnboarding})),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=Q(!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()===Se.ALLOWED}checkInteractiveFlag=()=>{if(this.skipOnboarding)this.background.interactiveAllowed.set(Se.ALLOWED);else{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?Se.ALLOWED:Se.DISALLOWED)}};connect=()=>{this.onboardingProcessed.subscribe(e=>{e&&this.advertisement&&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===b.QuestionStatus.RESOLVED&&o===b.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),d=[...this.feedList.getValues().data||[]],c=d.findIndex(G=>G.id===s),l=d[c];let p=l?.attributes?.attributes?.value?.answerId;const S=ze(s,this.transport),T=S.subscribe(()=>{});await S.get().promise;let v=S.get().data;v||(v=await er(s,this.transport),S.mutate(v)),T(),window.requestAnimationFrame(()=>{S.invalidate()}),p||(p=v?.answers.find(({youVoted:G})=>G)?.id);const w=a.find(({correct:G})=>G),_=p?a.find(({id:G})=>G===p):void 0,$=!!_?.correct;if(l&&d[c]?.attributes?.attributes.case==="question"){try{d[c].attributes.attributes.value.answerId=p,d[c].attributes.attributes.value.openForVoting=!1,p&&(d[c].attributes.attributes.value.status=$?it.PickHistoryStatus.WON:it.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(d)}if(!_||!w)return;this.openedQuestionId.get()?.questionId!==r.id&&this.notifications.add({type:ge.QUESTION_RESOLVED,action:()=>this.openQuestion(r.id,n),close:()=>this.closeQuestion(s),autoHideDuration:$?15e3:12e3,id:u,emitEvent:!1,data:{questionId:s,questionType:b.QuestionType.PREDICTION,question:{title:$?`Congratulations! You answered correctly! You won ${w.points} pts!`:`Better luck next time! Correct: ${w?.text}!`,votedAnswer:{title:_?.text,points:_?.points},correctAnswerTitle:w?.text,correct:!!$,predictionResult:i===b.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!==b.QuestionStatus.ACTIVE&&n.attributes.status!==b.QuestionStatus.RESOLVED)&&!(!this.isInteractiveAllowed&&Qr.has(n.attributes.type))){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===!1?!1:n.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),K.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")};betPackVote=async(e,r)=>{if(!this.betPack)return;try{await Dr(this.transport,{questionId:e,answerId:r})}catch(o){if(o.message===Qe.ALREADY_VOTED){const s=ze(e,this.transport),a=s.subscribe(()=>{});s.invalidate(),a()}throw o}const n={...this.betPack.getValues().data?.data},i=n?.[e];i&&(K.emit("poll",{action:"voted",payload:{questionId:e,questionType:i.type}}),i.answers=i.answers.map(o=>o.id===r?{...o,youVoted:!0}:o),this.betPack.getStore().mutate({data:n,timestamp:Date.now()}))};submitAnswer=async(e,r)=>{const n=ze(e,this.transport),i=n.subscribe(()=>{}),o={...n.get().data||{}},s=()=>{const a=this.feedList.getValues().data;if(!a)return;const u=a.findIndex(l=>l.id===e),d=a[u],c=d?.attributes?.attributes.case==="question"&&d.attributes.attributes.value;if(c){K.emit("poll",{action:"voted",payload:{questionId:e,questionType:c.questionType}});const l=n.get().data;if(i(),l){const p=l.answers.find(w=>w.correct===!0),S=l.answers.findIndex(w=>w.id===r),T=l.answers[S],v=l.answers.every(({percentageDecimal:w},_)=>w===o?.answers[_].percentageDecimal);a[u].attributes.attributes.value.answerId=r,a[u].attributes.attributes.value.openForVoting=!1,a[u].attributes.attributes.value.text=T?.text||"",p&&(a[u].attributes.attributes.value.status=p.id===r?it.PickHistoryStatus.WON:it.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...a]),l.answers[S].correct=p?.id===r,l.answers[S].youVoted=!0,v&&l.answers.forEach(w=>{w.percentageDecimal=0}),p?.id===r&&(l.answers[S].pointsEarned=l.status===b.QuestionStatus.RESOLVED?0:p.points),n.mutate({...l})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await Dr(this.transport,{questionId:e,answerId:r}),s()}catch(a){if(a.message===Qe.ALREADY_VOTED){this.userSummary.invalidate();const u=n.subscribe(()=>{});n.invalidate(),u()}throw a}};openQuestion=(e,r)=>{if(!e)return()=>{};const n=r?.openedFrom==="bet-pack";this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}),{animateHiding:!1});let i=r?.attributes?.type;if(!i&&!n&&(i=(this.feedList.getStore().value?.data||[]).find(a=>a.id===e)?.attributes?.type),!n&&(i===b.QuestionType.POLL||i===b.QuestionType.TRIVIA||i===b.QuestionType.PREDICTION)){const s=ze(e,this.transport);er(e,this.transport).then(a=>{s.mutate(a)})}const o={eventId:this.background.slStreamId.get()||"",userId:this.background.userId.get()||"",organizationId:this.background.organizationId.get()||""};return this.storage.isQuestionOpened(o,e)||(K.emit("poll",{action:"opened",payload:{questionId:e,questionType:i,questionOpenedFrom:r?.openedFrom==="bet-pack"?"list":r?.openedFrom}}),this.storage.saveQuestionOpened(o,e)),n||this.openFeature(),this.background.openQuestion(e,r?{...r,openedFrom:r?.openedFrom==="bet-pack"?"list":r?.openedFrom}:void 0)};getFeedItem=e=>ji(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=>{if(!this.leaderboardList)return;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 To(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!==b.SilenceSetting.ON&&e.data.question.status===b.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(Qr.has(e.data.question.type))this.isInteractiveAllowed&&e.data.question.notification!==void 0&&this.notifications.add({type:ge.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},inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship}}});else if(e.data.question.type===b.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:ge.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,inApp:{useMediaFromContent:n?.useAsNotification===b.UseAsNotification.ENABLED,notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship}}})}else if(e.data.question.type===b.QuestionType.TWEET&&e.data.question.notification!==void 0){const n=e.data.question.options?.options.value,i={image:"",video:""};if(n.tweetMeta?.tweet?.meta?.extendedEntities?.media?.[0]){const s=n.tweetMeta.tweet.meta.extendedEntities.media;if(s){const a=s.find(({type:u})=>u==="photo")||s[0];i.image=a.mediaUrlHttps,a.type==="video"&&(i.video=a.url)}}const o={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,tweetMedia:i};this.notifications.add({type:ge.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:o,inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship}}})}}}}const Eo={[R.SdkOverlayType.GAMES]:!0};class Io extends vn{constructor(e,r){super(e,r)}}const Oo=(t,e,r)=>t.type===R.SdkOverlayType.GAMES?new Ao(t,e,r):new Io(t,e),ko=(t,e,r)=>{t.features=new Map,t.sdk.featuresList=new Y(Q(new Set),"features-list"),t.activeFeature=new Y(Q(R.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.sdk.initializeApp().then(()=>{t.activeFeature.setValue(n)})},t.sdk.closeFeature=(n=!1)=>{const i=t.activeFeature.getValue();if(t.activeFeature.setValue(R.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 Eo&&!t.features.has(n.type)){const o=Oo(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 K.listen(r)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.INVITATION_ACCEPTED},category:ot.InvitationCategory.GAMES,from:ot.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.INVITATION_SENT},category:ot.InvitationCategory.GAMES,from:e||ot.InvitationFrom.UNSET})}}class Co{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 K.listen(r)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.INTERACTIONS},actionType:Pr.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.INTERACTIONS},actionType:Pr.InteractionActionType.SCROLL})}}const Po={[b.PromotionType.UNSET]:m.TopicSubType.UNSET,[b.PromotionType.INGAME_IAB21]:m.TopicSubType.PROMOTION_INGAME_IAB21,[b.PromotionType.INGAME_IAB11_LBAR]:m.TopicSubType.PROMOTION_INGAME_IAB11_LBAR,[b.PromotionType.INGAME_IAB11]:m.TopicSubType.PROMOTION_INGAME_IAB11,[b.PromotionType.INGAME_IAB21_LBAR]:m.TopicSubType.PROMOTION_INGAME_IAB21_LBAR,[b.PromotionType.INGAME_IAB61]:m.TopicSubType.PROMOTION_INGAME_IAB61,[b.PromotionType.EXTERNAL_AD]:m.TopicSubType.PROMOTION_GAM,[b.PromotionType.VIDEO_SIDE_BY_SIDE]:m.TopicSubType.PROMOTION_VIDEO_SIDE_BY_SIDE,[b.PromotionType.PICTURE_IN_PICTURE]:m.TopicSubType.PROMOTION_PICTURE_IN_PICTURE,[b.PromotionType.SHOP_LBAR]:m.TopicSubType.PROMOTION_SHOP_LBAR,[b.PromotionType.SHOP_OVERLAY]:m.TopicSubType.PROMOTION_SHOP_OVERLAY,[b.PromotionType.SHOP_SIDEBAR]:m.TopicSubType.PROMOTION_SHOP_SIDEBAR},tr=t=>t?Po[t]:m.TopicSubType.UNSET;class Lo{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const r=n=>{if(!n.slEventBus?.skipAnalytics&&n.slEventBus?.type==="advertisement"){const i=tr(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 K.listen(r)})}received=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_RECEIVED,topicId:e,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})};opened=({id:e,openedFrom:r},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_OPENED,topicId:e,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:r==="notification"?m.PollOpenedFrom.IN_APP:m.PollOpenedFrom.UNSET})};viewed=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_OPENED,topicId:e,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})};videoPlay=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:m.Kind.AD_VIDEO_PLAYED,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})};buttonSelect=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:m.Kind.AD_BUTTON_NAVIGATED,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})};bannerSelect=({id:e},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:m.Kind.AD_BANNER_NAVIGATED,topicType:m.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:m.PollOpenedFrom.UNSET})}}const We={[b.QuestionType.UNSET]:m.TopicType.UNSET,[b.QuestionType.FACTOID]:m.TopicType.POLLS_INSIGHT,[b.QuestionType.POLL]:m.TopicType.POLLS_POLL,[b.QuestionType.PREDICTION]:m.TopicType.POLLS_PREDICTION,[b.QuestionType.PROMOTION]:m.TopicType.POLLS_PROMOTION,[b.QuestionType.TRIVIA]:m.TopicType.POLLS_TRIVIA,[b.QuestionType.TWEET]:m.TopicType.POLLS_TWITTER};b.QuestionType.UNSET+"",Z.NotificationKind.UNSET,b.QuestionType.FACTOID+"",Z.NotificationKind.POLLS,b.QuestionType.POLL+"",Z.NotificationKind.POLLS,b.QuestionType.PREDICTION+"",Z.NotificationKind.POLLS,b.QuestionType.PROMOTION+"",Z.NotificationKind.POLLS,b.QuestionType.TRIVIA+"",Z.NotificationKind.POLLS,b.QuestionType.TWEET+"",Z.NotificationKind.POLLS;const No={[R.SdkOverlayType.UNSET]:m.Category.UNSET,[R.SdkOverlayType.INPLAY]:m.Category.INPLAY,[R.SdkOverlayType.MESSAGING]:m.Category.MESSAGING,[R.SdkOverlayType.STATISTICS]:m.Category.STATS,[R.SdkOverlayType.BETTING]:m.Category.BETTING,[R.SdkOverlayType.TWITTER]:m.Category.TWITTER,[R.SdkOverlayType.MERCHANDISE]:m.Category.MERCHANDISE,[R.SdkOverlayType.CONTESTS]:m.Category.CONTESTS,[R.SdkOverlayType.VOICE_CHAT]:m.Category.CALLING,[R.SdkOverlayType.TICKETS]:m.Category.TICKETS,[R.SdkOverlayType.WHOIS_WATCHING]:m.Category.WHOISWATCHING,[R.SdkOverlayType.PROFILE]:m.Category.PROFILE,[R.SdkOverlayType.GAMES]:m.Category.POLLS,[R.SdkOverlayType.GOLF_STATISTICS]:m.Category.STATS,[R.SdkOverlayType.HIGHLIGHTS]:m.Category.HIGHLIGHTS,[R.SdkOverlayType.PUBLIC_CHAT]:m.Category.PUBLIC_CHAT};class Fo{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:b.QuestionType.PROMOTION,topicSubType:tr(n.slEventBus.payload.type)});break;case"notification-opened":this.opened({questionId:n.slEventBus.payload.id,questionType:b.QuestionType.PROMOTION,topicSubType:tr(n.slEventBus.payload.type)});break}};return K.listen(r)})}received=({questionId:e,questionType:r,topicSubType:n})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:r?We[r]:m.TopicType.UNSET,topicSubType:n},notificationKind:Z.NotificationKind.POLLS,notificationType:Z.NotificationType.IN_APP})};opened=({questionId:e,questionType:r,topicSubType:n})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.NOTIFICATION_OPENED,topicId:e,topicType:r?We[r]:m.TopicType.UNSET,topicSubType:n},notificationKind:Z.NotificationKind.POLLS,notificationType:Z.NotificationType.IN_APP})}}class Do{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 K.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_RECEIVED,topicId:e,topicType:r?We[r]:m.TopicType.UNSET},pollOpenedFrom:m.PollOpenedFrom.UNSET})};opened=({questionId:e,questionType:r,questionOpenedFrom:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_OPENED,topicId:e,topicType:r?We[r]:m.TopicType.UNSET},pollOpenedFrom:n==="list"?m.PollOpenedFrom.PICK_HISTORY:m.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_VOTE,topicId:e,topicType:r?We[r]:m.TopicType.UNSET},pollOpenedFrom:m.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.GAMES_JOINED},pollOpenedFrom:m.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:m.Kind.POLLS_NAVIGATED},pollOpenedFrom:m.PollOpenedFrom.UNSET})}}const Ro=({transport:t,$commonStore:e})=>{let r;const n=Q(!1),i=3e4,{client:o,queryKey:s}=t.createPromiseClient(hn.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:m.Kind.SESSION_HEARTBEAT}}}})}catch(S){he.error(S,"send heartbeat failed")}return Date.now()},refetchInterval:i}),u=()=>{he.debug("mounted heartbeat"),r=a.subscribe(()=>{})},d=()=>{he.debug("enabled heartbeat"),n.set(!0),a.lc===0&&u()},c=()=>{he.debug("disabled heartbeat"),n.set(!1)};return{enable:d,disable:c,mount:u,unmount:()=>{he.debug("unmounted heartbeat"),a.off(),r?.(),r=void 0,c()}}},he=be("analytics");class Vo{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 Ie(W({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=Ro({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new Fo(this),this.polls=new Do(this),this.invitation=new _o(this),this.interactions=new Co(this),this.advertisement=new Lo(this);const{client:r}=e.analyticsTransport.createPromiseClient(hn.AnalyticsService,{method:"send"});this.analyticsClient=r}connect=()=>{this.writeCommon("sessionId",yt.v4()),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",No[r]),r!==R.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",yt.v4()):this.writeCommon("overlaySessionId","")})),this.onConnect(()=>{const r=window.matchMedia("(orientation: portrait)"),n=i=>{this.writeCommon("screenOrientation",i.matches?m.ScreenOrientation.PORTRAIT:m.ScreenOrientation.LANDSCAPE)};return r.addEventListener("change",n),()=>{r.removeEventListener("change",n)}}),this.onConnect(()=>e.deepLink.$store.subscribe(r=>{r?.handled&&this.invitation.accepted()}))}}const $o=(t,e,r)=>{t.analytics=new Vo(t),t.sdk.onMount({name:"analytics"},()=>(t.analytics.connect(),t.sdk.writeOverlaySessionId=n=>{n===""?t.analytics.writeCommon("overlaySessionId",""):t.analytics.writeCommon("overlaySessionId",yt.v4())},()=>{t.analytics.disconnect()})),r()};var pr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var hr={exports:{}},yr={exports:{}};function Bo(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 Uo=Bo,Qo=Uo;function In(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=Qo(qo),i=null,o=null,s=0,a=null,u={push:v,drain:H,saturated:H,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++,_()},running:d,resume:S,idle:T,length:l,getQueue:p,unshift:w,empty:H,kill:$,killAndDrain:G,error:J};return u;function d(){return s}function c(){u.paused=!0}function l(){for(var N=i,V=0;N;)N=N.next,V++;return V}function p(){for(var N=i,V=[];N;)V.push(N.value),N=N.next;return V}function S(){if(u.paused){if(u.paused=!1,i===null){s++,_();return}for(;i&&s<r;)s++,_()}}function T(){return s===0&&u.length()===0}function v(N,V){var k=n.get();k.context=t,k.release=_,k.value=N,k.callback=V||H,k.errorHandler=a,s>=r||u.paused?o?(o.next=k,o=k):(i=k,o=k,u.saturated()):(s++,e.call(t,k.value,k.worked))}function w(N,V){var k=n.get();k.context=t,k.release=_,k.value=N,k.callback=V||H,k.errorHandler=a,s>=r||u.paused?i?(k.next=i,i=k):(i=k,o=k,u.saturated()):(s++,e.call(t,k.value,k.worked))}function _(N){N&&n.release(N);var V=i;V&&s<=r?u.paused?s--:(o===i&&(o=null),i=V.next,V.next=null,e.call(t,V.value,V.worked),o===null&&u.empty()):--s===0&&u.drain()}function $(){i=null,o=null,u.drain=H}function G(){i=null,o=null,u.drain(),u.drain=H}function J(N){a=N}}function H(){}function qo(){this.value=null,this.callback=H,this.next=null,this.release=H,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=H,t.errorHandler&&o(r,s),i.call(t.context,r,n),t.release(t)}}function jo(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function n(c,l){e.call(this,c).then(function(p){l(null,p)},l)}var i=In(t,n,r),o=i.push,s=i.unshift;return i.push=a,i.unshift=u,i.drained=d,i;function a(c){var l=new Promise(function(p,S){o(c,function(T,v){if(T){S(T);return}p(v)})});return l.catch(H),l}function u(c){var l=new Promise(function(p,S){s(c,function(T,v){if(T){S(T);return}p(v)})});return l.catch(H),l}function d(){if(i.idle())return new Promise(function(p){p()});var c=i.drain,l=new Promise(function(p){i.drain=function(){c(),p()}});return l}}yr.exports=In;yr.exports.promise=jo;var On=yr.exports,gr={exports:{}},Be=typeof Reflect=="object"?Reflect:null,qr=Be&&typeof Be.apply=="function"?Be.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},ct;Be&&typeof Be.ownKeys=="function"?ct=Be.ownKeys:Object.getOwnPropertySymbols?ct=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ct=function(e){return Object.getOwnPropertyNames(e)};function xo(t){console&&console.warn&&console.warn(t)}var kn=Number.isNaN||function(e){return e!==e};function F(){F.init.call(this)}gr.exports=F;gr.exports.once=Ho;F.EventEmitter=F;F.prototype._events=void 0;F.prototype._eventsCount=0;F.prototype._maxListeners=void 0;var jr=10;function Ot(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||kn(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||kn(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 _n(t){return t._maxListeners===void 0?F.defaultMaxListeners:t._maxListeners}F.prototype.getMaxListeners=function(){return _n(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")qr(u,this,r);else for(var d=u.length,c=Fn(u,d),n=0;n<d;++n)qr(c[n],this,r);return!0};function Cn(t,e,r,n){var i,o,s;if(Ot(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=_n(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,xo(a)}return t}F.prototype.addListener=function(e,r){return Cn(this,e,r,!1)};F.prototype.on=F.prototype.addListener;F.prototype.prependListener=function(e,r){return Cn(this,e,r,!0)};function Go(){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=Go.bind(n);return i.listener=r,n.wrapFn=i,i}F.prototype.once=function(e,r){return Ot(r),this.on(e,Pn(this,e,r)),this};F.prototype.prependOnceListener=function(e,r){return Ot(r),this.prependListener(e,Pn(this,e,r)),this};F.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Ot(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():Ko(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 Ln(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?zo(i):Fn(i,i.length)}F.prototype.listeners=function(e){return Ln(this,e,!0)};F.prototype.rawListeners=function(e){return Ln(this,e,!1)};F.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Nn.call(t,e)};F.prototype.listenerCount=Nn;function Nn(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?ct(this._events):[]};function Fn(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Ko(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function zo(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Ho(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))}Dn(t,e,o,{once:!0}),e!=="error"&&Wo(t,i,{once:!0})})}function Wo(t,e,r){typeof t.on=="function"&&Dn(t,"error",e,r)}function Dn(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 Rn=gr.exports,kt={},Vn={},$n=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},Yo=$n,_t=function(){return Yo()&&!!Symbol.toStringTag},Jo=Error,Xo=EvalError,Zo=RangeError,es=ReferenceError,Mn=SyntaxError,Ct=TypeError,ts=URIError,xr=typeof Symbol<"u"&&Symbol,rs=$n,ns=function(){return typeof xr!="function"||typeof Symbol!="function"||typeof xr("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:rs()},Dt={__proto__:null,foo:{}},is=Object,os=function(){return{__proto__:Dt}.foo===Dt.foo&&!(Dt instanceof is)},ss="Function.prototype.bind called on incompatible ",as=Object.prototype.toString,us=Math.max,cs="[object Function]",Gr=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},ls=function(e,r){for(var n=[],i=r,o=0;i<e.length;i+=1,o+=1)n[o]=e[i];return n},ds=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r},fs=function(e){var r=this;if(typeof r!="function"||as.apply(r)!==cs)throw new TypeError(ss+r);for(var n=ls(arguments,1),i,o=function(){if(this instanceof i){var c=r.apply(this,Gr(n,arguments));return Object(c)===c?c:this}return r.apply(e,Gr(n,arguments))},s=us(0,r.length-n.length),a=[],u=0;u<s;u++)a[u]="$"+u;if(i=Function("binder","return function ("+ds(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var d=function(){};d.prototype=r.prototype,i.prototype=new d,d.prototype=null}return i},ps=fs,mr=Function.prototype.bind||ps,hs=Function.prototype.call,ys=Object.prototype.hasOwnProperty,gs=mr,ms=gs.call(hs,ys),O,bs=Jo,vs=Xo,Ss=Zo,ws=es,qe=Mn,Ue=Ct,Ts=ts,Bn=Function,Rt=function(t){try{return Bn('"use strict"; return ('+t+").constructor;")()}catch{}},Oe=Object.getOwnPropertyDescriptor;if(Oe)try{Oe({},"")}catch{Oe=null}var Vt=function(){throw new Ue},As=Oe?function(){try{return arguments.callee,Vt}catch{try{return Oe(arguments,"callee").get}catch{return Vt}}}():Vt,Fe=ns(),Es=os(),q=Object.getPrototypeOf||(Es?function(t){return t.__proto__}:null),Re={},Is=typeof Uint8Array>"u"||!q?O:q(Uint8Array),ke={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?O:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?O:ArrayBuffer,"%ArrayIteratorPrototype%":Fe&&q?q([][Symbol.iterator]()):O,"%AsyncFromSyncIteratorPrototype%":O,"%AsyncFunction%":Re,"%AsyncGenerator%":Re,"%AsyncGeneratorFunction%":Re,"%AsyncIteratorPrototype%":Re,"%Atomics%":typeof Atomics>"u"?O:Atomics,"%BigInt%":typeof BigInt>"u"?O:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?O:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?O:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?O:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":bs,"%eval%":eval,"%EvalError%":vs,"%Float32Array%":typeof Float32Array>"u"?O:Float32Array,"%Float64Array%":typeof Float64Array>"u"?O:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?O:FinalizationRegistry,"%Function%":Bn,"%GeneratorFunction%":Re,"%Int8Array%":typeof Int8Array>"u"?O:Int8Array,"%Int16Array%":typeof Int16Array>"u"?O:Int16Array,"%Int32Array%":typeof Int32Array>"u"?O:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Fe&&q?q(q([][Symbol.iterator]())):O,"%JSON%":typeof JSON=="object"?JSON:O,"%Map%":typeof Map>"u"?O:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Fe||!q?O:q(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?O:Promise,"%Proxy%":typeof Proxy>"u"?O:Proxy,"%RangeError%":Ss,"%ReferenceError%":ws,"%Reflect%":typeof Reflect>"u"?O:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?O:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Fe||!q?O:q(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?O:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Fe&&q?q(""[Symbol.iterator]()):O,"%Symbol%":Fe?Symbol:O,"%SyntaxError%":qe,"%ThrowTypeError%":As,"%TypedArray%":Is,"%TypeError%":Ue,"%Uint8Array%":typeof Uint8Array>"u"?O:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?O:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?O:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?O:Uint32Array,"%URIError%":Ts,"%WeakMap%":typeof WeakMap>"u"?O:WeakMap,"%WeakRef%":typeof WeakRef>"u"?O:WeakRef,"%WeakSet%":typeof WeakSet>"u"?O:WeakSet};if(q)try{null.error}catch(t){var Os=q(q(t));ke["%Error.prototype%"]=Os}var ks=function t(e){var r;if(e==="%AsyncFunction%")r=Rt("async function () {}");else if(e==="%GeneratorFunction%")r=Rt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Rt("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 ke[e]=r,r},Kr={__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=mr,mt=ms,_s=Ze.call(Function.call,Array.prototype.concat),Cs=Ze.call(Function.apply,Array.prototype.splice),zr=Ze.call(Function.call,String.prototype.replace),bt=Ze.call(Function.call,String.prototype.slice),Ps=Ze.call(Function.call,RegExp.prototype.exec),Ls=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ns=/\\(\\)?/g,Fs=function(e){var r=bt(e,0,1),n=bt(e,-1);if(r==="%"&&n!=="%")throw new qe("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new qe("invalid intrinsic syntax, expected opening `%`");var i=[];return zr(e,Ls,function(o,s,a,u){i[i.length]=a?zr(u,Ns,"$1"):s||o}),i},Ds=function(e,r){var n=e,i;if(mt(Kr,n)&&(i=Kr[n],n="%"+i[0]+"%"),mt(ke,n)){var o=ke[n];if(o===Re&&(o=ks(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 qe("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(Ps(/^%?[^%]*%?$/,e)===null)throw new qe("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Fs(e),i=n.length>0?n[0]:"",o=Ds("%"+i+"%",r),s=o.name,a=o.value,u=!1,d=o.alias;d&&(i=d[0],Cs(n,_s([0,1],d)));for(var c=1,l=!0;c<n.length;c+=1){var p=n[c],S=bt(p,0,1),T=bt(p,-1);if((S==='"'||S==="'"||S==="`"||T==='"'||T==="'"||T==="`")&&S!==T)throw new qe("property names with quotes must have matching quotes");if((p==="constructor"||!l)&&(u=!0),i+="."+p,s="%"+i+"%",mt(ke,s))a=ke[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(Oe&&c+1>=n.length){var v=Oe(a,p);l=!!v,l&&"get"in v&&!("originalValue"in v.get)?a=v.get:a=a[p]}else l=mt(a,p),a=a[p];l&&!u&&(ke[s]=a)}}return a},Un={exports:{}},$t,Hr;function br(){if(Hr)return $t;Hr=1;var t=et,e=t("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return $t=e,$t}var Rs=et,lt=Rs("%Object.getOwnPropertyDescriptor%",!0);if(lt)try{lt([],"length")}catch{lt=null}var Pt=lt,Wr=br(),Vs=Mn,De=Ct,Yr=Pt,$s=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=!!Yr&&Yr(e,r);if(Wr)Wr(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 Vs("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},rr=br(),Qn=function(){return!!rr};Qn.hasArrayLengthDefineBug=function(){if(!rr)return null;try{return rr([],"length",{value:1}).length!==1}catch{return!0}};var Ms=Qn,Bs=et,Jr=$s,Us=Ms(),Xr=Pt,Zr=Ct,Qs=Bs("%Math.floor%"),qs=function(e,r){if(typeof e!="function")throw new Zr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Qs(r)!==r)throw new Zr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in e&&Xr){var s=Xr(e,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(Us?Jr(e,"length",r,!0,!0):Jr(e,"length",r)),e};(function(t){var e=mr,r=et,n=qs,i=Ct,o=r("%Function.prototype.apply%"),s=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(s,o),u=br(),d=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+d(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 vr=Un.exports,qn=et,jn=vr,js=jn(qn("String.prototype.indexOf")),Sr=function(e,r){var n=qn(e,!!r);return typeof n=="function"&&js(e,".prototype.")>-1?jn(n):n},xs=_t(),Gs=Sr,nr=Gs("Object.prototype.toString"),Lt=function(e){return xs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:nr(e)==="[object Arguments]"},xn=function(e){return Lt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&nr(e)!=="[object Array]"&&nr(e.callee)==="[object Function]"},Ks=function(){return Lt(arguments)}();Lt.isLegacyArguments=xn;var zs=Ks?Lt:xn,Hs=Object.prototype.toString,Ws=Function.prototype.toString,Ys=/^\s*(?:function)?\*/,Gn=_t(),Mt=Object.getPrototypeOf,Js=function(){if(!Gn)return!1;try{return Function("return function*() {}")()}catch{}},Bt,Xs=function(e){if(typeof e!="function")return!1;if(Ys.test(Ws.call(e)))return!0;if(!Gn){var r=Hs.call(e);return r==="[object GeneratorFunction]"}if(!Mt)return!1;if(typeof Bt>"u"){var n=Js();Bt=n?Mt(n):!1}return Mt(e)===Bt},Kn=Function.prototype.toString,$e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ir,dt;if(typeof $e=="function"&&typeof Object.defineProperty=="function")try{ir=Object.defineProperty({},"length",{get:function(){throw dt}}),dt={},$e(function(){throw 42},null,ir)}catch(t){t!==dt&&($e=null)}else $e=null;var Zs=/^\s*class\b/,or=function(e){try{var r=Kn.call(e);return Zs.test(r)}catch{return!1}},Ut=function(e){try{return or(e)?!1:(Kn.call(e),!0)}catch{return!1}},ft=Object.prototype.toString,ea="[object Object]",ta="[object Function]",ra="[object GeneratorFunction]",na="[object HTMLAllCollection]",ia="[object HTML document.all class]",oa="[object HTMLCollection]",sa=typeof Symbol=="function"&&!!Symbol.toStringTag,aa=!(0 in[,]),sr=function(){return!1};if(typeof document=="object"){var ua=document.all;ft.call(ua)===ft.call(document.all)&&(sr=function(e){if((aa||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=ft.call(e);return(r===na||r===ia||r===oa||r===ea)&&e("")==null}catch{}return!1})}var ca=$e?function(e){if(sr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{$e(e,null,ir)}catch(r){if(r!==dt)return!1}return!or(e)&&Ut(e)}:function(e){if(sr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(sa)return Ut(e);if(or(e))return!1;var r=ft.call(e);return r!==ta&&r!==ra&&!/^\[object HTML/.test(r)?!1:Ut(e)},la=ca,da=Object.prototype.toString,zn=Object.prototype.hasOwnProperty,fa=function(e,r,n){for(var i=0,o=e.length;i<o;i++)zn.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},pa=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)},ha=function(e,r,n){for(var i in e)zn.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},ya=function(e,r,n){if(!la(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),da.call(e)==="[object Array]"?fa(e,r,i):typeof e=="string"?pa(e,r,i):ha(e,r,i)},Hn=ya,ga=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],Qt=ga,ma=typeof globalThis>"u"?pr:globalThis,Wn=function(){for(var e=[],r=0;r<Qt.length;r++)typeof ma[Qt[r]]=="function"&&(e[e.length]=Qt[r]);return e},vt=Hn,ba=Wn,en=vr,wr=Sr,pt=Pt,va=wr("Object.prototype.toString"),Yn=_t(),tn=typeof globalThis>"u"?pr:globalThis,ar=ba(),Tr=wr("String.prototype.slice"),qt=Object.getPrototypeOf,Sa=wr("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},St={__proto__:null};Yn&&pt&&qt?vt(ar,function(t){var e=new tn[t];if(Symbol.toStringTag in e){var r=qt(e),n=pt(r,Symbol.toStringTag);if(!n){var i=qt(r);n=pt(i,Symbol.toStringTag)}St["$"+t]=en(n.get)}}):vt(ar,function(t){var e=new tn[t],r=e.slice||e.set;r&&(St["$"+t]=en(r))});var wa=function(e){var r=!1;return vt(St,function(n,i){if(!r)try{"$"+n(e)===i&&(r=Tr(i,1))}catch{}}),r},Ta=function(e){var r=!1;return vt(St,function(n,i){if(!r)try{n(e),r=Tr(i,1)}catch{}}),r},Aa=function(e){if(!e||typeof e!="object")return!1;if(!Yn){var r=Tr(va(e),8,-1);return Sa(ar,r)>-1?r:r!=="Object"?!1:Ta(e)}return pt?wa(e):null},wt=Hn,Ea=Wn,rn=vr,Ar=Sr,ht=Pt,Ia=Ar("Object.prototype.toString"),Jn=_t(),nn=typeof globalThis>"u"?pr:globalThis,ur=Ea(),Er=Ar("String.prototype.slice"),jt=Object.getPrototypeOf,Oa=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},Tt={__proto__:null};Jn&&ht&&jt?wt(ur,function(t){var e=new nn[t];if(Symbol.toStringTag in e){var r=jt(e),n=ht(r,Symbol.toStringTag);if(!n){var i=jt(r);n=ht(i,Symbol.toStringTag)}Tt["$"+t]=rn(n.get)}}):wt(ur,function(t){var e=new nn[t],r=e.slice||e.set;r&&(Tt["$"+t]=rn(r))});var ka=function(e){var r=!1;return wt(Tt,function(n,i){if(!r)try{"$"+n(e)===i&&(r=Er(i,1))}catch{}}),r},_a=function(e){var r=!1;return wt(Tt,function(n,i){if(!r)try{n(e),r=Er(i,1)}catch{}}),r},Ca=function(e){if(!e||typeof e!="object")return!1;if(!Jn){var r=Er(Ia(e),8,-1);return Oa(ur,r)>-1?r:r!=="Object"?!1:_a(e)}return ht?ka(e):null},Pa=Ca,La=function(e){return!!Pa(e)};(function(t){var e=zs,r=Xs,n=Aa,i=La;function o(y){return y.call.bind(y)}var s=typeof BigInt<"u",a=typeof Symbol<"u",u=o(Object.prototype.toString),d=o(Number.prototype.valueOf),c=o(String.prototype.valueOf),l=o(Boolean.prototype.valueOf);if(s)var p=o(BigInt.prototype.valueOf);if(a)var S=o(Symbol.prototype.valueOf);function T(y,ii){if(typeof y!="object")return!1;try{return ii(y),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=i;function v(y){return typeof Promise<"u"&&y instanceof Promise||y!==null&&typeof y=="object"&&typeof y.then=="function"&&typeof y.catch=="function"}t.isPromise=v;function w(y){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(y):i(y)||h(y)}t.isArrayBufferView=w;function _(y){return n(y)==="Uint8Array"}t.isUint8Array=_;function $(y){return n(y)==="Uint8ClampedArray"}t.isUint8ClampedArray=$;function G(y){return n(y)==="Uint16Array"}t.isUint16Array=G;function J(y){return n(y)==="Uint32Array"}t.isUint32Array=J;function N(y){return n(y)==="Int8Array"}t.isInt8Array=N;function V(y){return n(y)==="Int16Array"}t.isInt16Array=V;function k(y){return n(y)==="Int32Array"}t.isInt32Array=k;function ne(y){return n(y)==="Float32Array"}t.isFloat32Array=ne;function ie(y){return n(y)==="Float64Array"}t.isFloat64Array=ie;function _e(y){return n(y)==="BigInt64Array"}t.isBigInt64Array=_e;function we(y){return n(y)==="BigUint64Array"}t.isBigUint64Array=we;function ce(y){return u(y)==="[object Map]"}ce.working=typeof Map<"u"&&ce(new Map);function Nt(y){return typeof Map>"u"?!1:ce.working?ce(y):y instanceof Map}t.isMap=Nt;function ve(y){return u(y)==="[object Set]"}ve.working=typeof Set<"u"&&ve(new Set);function Ge(y){return typeof Set>"u"?!1:ve.working?ve(y):y instanceof Set}t.isSet=Ge;function Ce(y){return u(y)==="[object WeakMap]"}Ce.working=typeof WeakMap<"u"&&Ce(new WeakMap);function Ft(y){return typeof WeakMap>"u"?!1:Ce.working?Ce(y):y instanceof WeakMap}t.isWeakMap=Ft;function Pe(y){return u(y)==="[object WeakSet]"}Pe.working=typeof WeakSet<"u"&&Pe(new WeakSet);function le(y){return Pe(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 f(y){return u(y)==="[object DataView]"}f.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&f(new DataView(new ArrayBuffer(1),0,1));function h(y){return typeof DataView>"u"?!1:f.working?f(y):y instanceof DataView}t.isDataView=h;var g=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function A(y){return u(y)==="[object SharedArrayBuffer]"}function P(y){return typeof g>"u"?!1:(typeof A.working>"u"&&(A.working=A(new g)),A.working?A(y):y instanceof g)}t.isSharedArrayBuffer=P;function L(y){return u(y)==="[object AsyncFunction]"}t.isAsyncFunction=L;function I(y){return u(y)==="[object Map Iterator]"}t.isMapIterator=I;function C(y){return u(y)==="[object Set Iterator]"}t.isSetIterator=C;function D(y){return u(y)==="[object Generator]"}t.isGeneratorObject=D;function z(y){return u(y)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=z;function Te(y){return T(y,d)}t.isNumberObject=Te;function rt(y){return T(y,c)}t.isStringObject=rt;function Ne(y){return T(y,l)}t.isBooleanObject=Ne;function nt(y){return s&&T(y,p)}t.isBigIntObject=nt;function kr(y){return a&&T(y,S)}t.isSymbolObject=kr;function ri(y){return Te(y)||rt(y)||Ne(y)||nt(y)||kr(y)}t.isBoxedPrimitive=ri;function ni(y){return typeof Uint8Array<"u"&&(tt(y)||P(y))}t.isAnyArrayBuffer=ni,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(y){Object.defineProperty(t,y,{enumerable:!1,value:function(){throw new Error(y+" is not supported in userland")}})})})(Vn);var Na=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},cr={exports:{}};typeof Object.create=="function"?cr.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:cr.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 Fa=cr.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(h){for(var g=Object.keys(h),A={},P=0;P<g.length;P++)A[g[P]]=Object.getOwnPropertyDescriptor(h,g[P]);return A},r=/%[sdj%]/g;t.format=function(f){if(!N(f)){for(var h=[],g=0;g<arguments.length;g++)h.push(s(arguments[g]));return h.join(" ")}for(var g=1,A=arguments,P=A.length,L=String(f).replace(r,function(C){if(C==="%%")return"%";if(g>=P)return C;switch(C){case"%s":return String(A[g++]);case"%d":return Number(A[g++]);case"%j":try{return JSON.stringify(A[g++])}catch{return"[Circular]"}default:return C}}),I=A[g];g<P;I=A[++g])$(I)||!ie(I)?L+=" "+I:L+=" "+s(I);return L},t.deprecate=function(f,h){if(typeof E<"u"&&E.noDeprecation===!0)return f;if(typeof E>"u")return function(){return t.deprecate(f,h).apply(this,arguments)};var g=!1;function A(){if(!g){if(E.throwDeprecation)throw new Error(h);E.traceDeprecation?console.trace(h):console.error(h),g=!0}return f.apply(this,arguments)}return A};var n={},i=/^$/;if(E.env.NODE_DEBUG){var o=E.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(f){if(f=f.toUpperCase(),!n[f])if(i.test(f)){var h=E.pid;n[f]=function(){var g=t.format.apply(t,arguments);console.error("%s %d: %s",f,h,g)}}else n[f]=function(){};return n[f]};function s(f,h){var g={seen:[],stylize:u};return arguments.length>=3&&(g.depth=arguments[2]),arguments.length>=4&&(g.colors=arguments[3]),_(h)?g.showHidden=h:h&&t._extend(g,h),k(g.showHidden)&&(g.showHidden=!1),k(g.depth)&&(g.depth=2),k(g.colors)&&(g.colors=!1),k(g.customInspect)&&(g.customInspect=!0),g.colors&&(g.stylize=a),c(g,f,g.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(f,h){var g=s.styles[h];return g?"\x1B["+s.colors[g][0]+"m"+f+"\x1B["+s.colors[g][1]+"m":f}function u(f,h){return f}function d(f){var h={};return f.forEach(function(g,A){h[g]=!0}),h}function c(f,h,g){if(f.customInspect&&h&&ce(h.inspect)&&h.inspect!==t.inspect&&!(h.constructor&&h.constructor.prototype===h)){var A=h.inspect(g,f);return N(A)||(A=c(f,A,g)),A}var P=l(f,h);if(P)return P;var L=Object.keys(h),I=d(L);if(f.showHidden&&(L=Object.getOwnPropertyNames(h)),we(h)&&(L.indexOf("message")>=0||L.indexOf("description")>=0))return p(h);if(L.length===0){if(ce(h)){var C=h.name?": "+h.name:"";return f.stylize("[Function"+C+"]","special")}if(ne(h))return f.stylize(RegExp.prototype.toString.call(h),"regexp");if(_e(h))return f.stylize(Date.prototype.toString.call(h),"date");if(we(h))return p(h)}var D="",z=!1,Te=["{","}"];if(w(h)&&(z=!0,Te=["[","]"]),ce(h)){var rt=h.name?": "+h.name:"";D=" [Function"+rt+"]"}if(ne(h)&&(D=" "+RegExp.prototype.toString.call(h)),_e(h)&&(D=" "+Date.prototype.toUTCString.call(h)),we(h)&&(D=" "+p(h)),L.length===0&&(!z||h.length==0))return Te[0]+D+Te[1];if(g<0)return ne(h)?f.stylize(RegExp.prototype.toString.call(h),"regexp"):f.stylize("[Object]","special");f.seen.push(h);var Ne;return z?Ne=S(f,h,g,I,L):Ne=L.map(function(nt){return T(f,h,g,I,nt,z)}),f.seen.pop(),v(Ne,D,Te)}function l(f,h){if(k(h))return f.stylize("undefined","undefined");if(N(h)){var g="'"+JSON.stringify(h).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return f.stylize(g,"string")}if(J(h))return f.stylize(""+h,"number");if(_(h))return f.stylize(""+h,"boolean");if($(h))return f.stylize("null","null")}function p(f){return"["+Error.prototype.toString.call(f)+"]"}function S(f,h,g,A,P){for(var L=[],I=0,C=h.length;I<C;++I)Pe(h,String(I))?L.push(T(f,h,g,A,String(I),!0)):L.push("");return P.forEach(function(D){D.match(/^\d+$/)||L.push(T(f,h,g,A,D,!0))}),L}function T(f,h,g,A,P,L){var I,C,D;if(D=Object.getOwnPropertyDescriptor(h,P)||{value:h[P]},D.get?D.set?C=f.stylize("[Getter/Setter]","special"):C=f.stylize("[Getter]","special"):D.set&&(C=f.stylize("[Setter]","special")),Pe(A,P)||(I="["+P+"]"),C||(f.seen.indexOf(D.value)<0?($(g)?C=c(f,D.value,null):C=c(f,D.value,g-1),C.indexOf(`
|
|
3
3
|
`)>-1&&(L?C=C.split(`
|
|
4
4
|
`).map(function(z){return" "+z}).join(`
|
|
5
5
|
`).slice(2):C=`
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
`))):C=f.stylize("[Circular]","special")),k(I)){if(L&&P.match(/^\d+$/))return C;I=JSON.stringify(""+P),I.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(I=I.slice(1,-1),I=f.stylize(I,"name")):(I=I.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),I=f.stylize(I,"string"))}return I+": "+C}function v(f,h,g){var A=f.reduce(function(P,L){return L.indexOf(`
|
|
9
9
|
`)>=0,P+L.replace(/\u001b\[\d\d?m/g,"").length+1},0);return A>60?g[0]+(h===""?"":h+`
|
|
10
10
|
`)+" "+f.join(`,
|
|
11
|
-
`)+" "+g[1]:g[0]+h+" "+f.join(", ")+" "+g[1]}t.types
|
|
11
|
+
`)+" "+g[1]:g[0]+h+" "+f.join(", ")+" "+g[1]}t.types=Vn;function w(f){return Array.isArray(f)}t.isArray=w;function _(f){return typeof f=="boolean"}t.isBoolean=_;function $(f){return f===null}t.isNull=$;function G(f){return f==null}t.isNullOrUndefined=G;function J(f){return typeof f=="number"}t.isNumber=J;function N(f){return typeof f=="string"}t.isString=N;function V(f){return typeof f=="symbol"}t.isSymbol=V;function k(f){return f===void 0}t.isUndefined=k;function ne(f){return ie(f)&&ve(f)==="[object RegExp]"}t.isRegExp=ne,t.types.isRegExp=ne;function ie(f){return typeof f=="object"&&f!==null}t.isObject=ie;function _e(f){return ie(f)&&ve(f)==="[object Date]"}t.isDate=_e,t.types.isDate=_e;function we(f){return ie(f)&&(ve(f)==="[object Error]"||f instanceof Error)}t.isError=we,t.types.isNativeError=we;function ce(f){return typeof f=="function"}t.isFunction=ce;function Nt(f){return f===null||typeof f=="boolean"||typeof f=="number"||typeof f=="string"||typeof f=="symbol"||typeof f>"u"}t.isPrimitive=Nt,t.isBuffer=Na;function ve(f){return Object.prototype.toString.call(f)}function Ge(f){return f<10?"0"+f.toString(10):f.toString(10)}var Ce=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ft(){var f=new Date,h=[Ge(f.getHours()),Ge(f.getMinutes()),Ge(f.getSeconds())].join(":");return[f.getDate(),Ce[f.getMonth()],h].join(" ")}t.log=function(){console.log("%s - %s",Ft(),t.format.apply(t,arguments))},t.inherits=Fa,t._extend=function(f,h){if(!h||!ie(h))return f;for(var g=Object.keys(h),A=g.length;A--;)f[g[A]]=h[g[A]];return f};function Pe(f,h){return Object.prototype.hasOwnProperty.call(f,h)}var le=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(h){if(typeof h!="function")throw new TypeError('The "original" argument must be of type Function');if(le&&h[le]){var g=h[le];if(typeof g!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(g,le,{value:g,enumerable:!1,writable:!1,configurable:!0}),g}function g(){for(var A,P,L=new Promise(function(D,z){A=D,P=z}),I=[],C=0;C<arguments.length;C++)I.push(arguments[C]);I.push(function(D,z){D?P(D):A(z)});try{h.apply(this,I)}catch(D){P(D)}return L}return Object.setPrototypeOf(g,Object.getPrototypeOf(h)),le&&Object.defineProperty(g,le,{value:g,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(g,e(h))},t.promisify.custom=le;function Le(f,h){if(!f){var g=new Error("Promise was rejected with a falsy value");g.reason=f,f=g}return h(f)}function tt(f){if(typeof f!="function")throw new TypeError('The "original" argument must be of type Function');function h(){for(var g=[],A=0;A<arguments.length;A++)g.push(arguments[A]);var P=g.pop();if(typeof P!="function")throw new TypeError("The last argument must be of type Function");var L=this,I=function(){return P.apply(L,arguments)};f.apply(this,g).then(function(C){E.nextTick(I.bind(null,null,C))},function(C){E.nextTick(Le.bind(null,C,I))})}return Object.setPrototypeOf(h,Object.getPrototypeOf(f)),Object.defineProperties(h,e(f)),h}t.callbackify=tt})(kt);const{inherits:Da,format:xt}=kt;function Ae(t,e,r=Error){if(!t)throw new Error("Avvio error code must not be empty");if(!e)throw new Error("Avvio base error message must not be empty");function n(i,o,s){if(!new.target)return new n(i,o,s);Error.captureStackTrace(this,n),this.code=t,this.message=e,this.name="AvvioError",i&&o&&s?this.message=xt(e,i,o,s):i&&o?this.message=xt(e,i,o):i?this.message=xt(e,i):this.message=e}return n.prototype[Symbol.toStringTag]="Error",n.prototype.toString=function(){return`${this.name} [${this.code}]: ${this.message}`},Da(n,r),n}var Xn={createError:Ae,AVV_ERR_EXPOSE_ALREADY_DEFINED:Ae("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' () is already defined, specify an expose option"),AVV_ERR_CALLBACK_NOT_FN:Ae("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:Ae("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:Ae("AVV_ERR_PLUGIN_NOT_VALID","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:Ae("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:Ae("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")},Ra=function t(e,r,n){r===void 0&&(r=""),n||(n={});var i=function(u){var d={"│":"|","└":"`","├":"+","─":"-","┬":"-"};return n.unicode===!1?d[u]:u};typeof e=="string"&&(e={label:e});var o=e.nodes||[],s=(e.label||"").split(`
|
|
12
12
|
`),a=`
|
|
13
13
|
`+r+(o.length?i("│"):" ")+" ";return r+s.join(a)+`
|
|
14
|
-
`+o.map(function(u,d){var c=d===o.length-1,l=u.nodes&&u.nodes.length,p=r+(c?" ":i("│"))+" ";return r+i(c?"└":"├")+i("─")+i(l?"┬":"─")+" "+t(u,p,n).slice(r.length+2)}).join("")};const
|
|
15
|
-
`).slice(0,2).map(r=>r.trim()).join(" -- ")}function Ha(){const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function xe(t,e,r,n,i){this.started=!1,this.func=e,this.opts=r,this.onFinish=null,this.parent=t,this.timeout=i===void 0?t._timeout:i,this.name=za(e,r),this.isAfter=n,this.q=ja(t,Wa,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}Ga(xe,xa);xe.prototype.exec=function(t,e){const r=this.func;let n=!1;const i=this.name;if(this.parent._error&&!this.isAfter){j("skipping loading of plugin as parent errored and it is not an after",i),E.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,r,this.opts)}catch(u){return j("override errored",i),e(u)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,j("exec",i);let o;const s=u=>{if(n){j("loading complete",i);return}this._error=u,j(u?"exec errored":"exec completed",i),n=!0,o&&clearTimeout(o),e(u)};this.timeout>0&&(j("setting up timeout",i,this.timeout),o=setTimeout(function(){j("timed out",i),o=null;const u=new Ka(i);u.fn=r,s(u)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const a=r(this.server,this.opts,s);a&&typeof a.then=="function"&&(j("exec: resolving promise",i),a.then(()=>E.nextTick(s),u=>E.nextTick(s,u)))};xe.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((r,n)=>{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)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=Ha(),e=this._promise.promise,this.server?t():this.on("start",t)),e};xe.prototype.enqueue=function(t,e){j("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};xe.prototype.finish=function(t,e){j("finish",this.name,t);const r=()=>{this.loaded||(j("loaded",this.name),this.emit("loaded",this.server?this.server.name:null,this.name,Date.now()),this.loaded=!0,e(t))};if(t){this._promise&&(this._promise.reject(t),this._promise=null),r();return}const n=()=>{if(j("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const i=()=>{j("wrap"),queueMicrotask(n)};this._promise.resolve(),this._promise.promise.then(i,i),this._promise=null}else r();else j("delayed",this.name),this.q.drain=()=>{j("drain",this.name),this.q.drain=Ya,queueMicrotask(n)}};queueMicrotask(n),this.q.resume()};function Wa(t,e){const r=this;E.nextTick(Or.bind(r),t,e)}function Or(t,e){if(typeof t.func.then=="function"){t.func.then(n=>{typeof n.default=="function"&&(n=n.default),t.func=n,Or.call(this,t,e)},e);return}const r=this._current[0];this._current.unshift(t),t.exec(r&&r.server||this._server,n=>{t.finish(n,i=>{this._current.shift(),e(i)})})}function Ya(){}Ir.exports=xe;Ir.exports.loadPlugin=Or;var Ja=Ir.exports;const ln=kn,Xa=Vn.EventEmitter,Za=kt.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:Wt,AVV_ERR_CALLBACK_NOT_FN:We,AVV_ERR_PLUGIN_NOT_VALID:eu,AVV_ERR_ROOT_PLG_BOOTED:tu,AVV_ERR_READY_TIMEOUT:ru}=Zn,nu=Ba,dr=Ja,je=ei("avvio"),At=Symbol("kAvvio"),Yt=Symbol("kThenifyDoNotWrap");function iu(t,e,r){const n=e.expose||{},i=n.use||"use",o=n.after||"after",s=n.ready||"ready",a=n.onClose||"onClose",u=n.close||"close";if(t[i])throw new Wt(i);if(t[o])throw new Wt(o);if(t[s])throw new Wt(s);t[i]=function(d,c){return r.use(d,c),this},Object.defineProperty(t,"then",{get:ti.bind(r)}),t[At]=!0,t[o]=function(d){return typeof d!="function"?r._loadRegistered():(r.after(Jt(d,this)),this)},t[s]=function(d){if(d&&typeof d!="function")throw new We(s,typeof d);return r.ready(d?Jt(d,this):void 0)},t[a]=function(d){if(typeof d!="function")throw new We(a,typeof d);return r.onClose(cu(d,this)),this},t[u]=function(d){if(d&&typeof d!="function")throw new We(u,typeof d);return d?(r.close(Jt(d,this)),this):r.close()}}function x(t,e,r){if(typeof t=="function"&&arguments.length===1&&(r=t,e={},t=null),typeof e=="function"&&(r=e,e={}),e=e||{},!(this instanceof x)){const n=new x(t,e,r);return t&&iu(t,e,n),n}e.autostart!==!1&&(e.autostart=!0),t=t||this,this._timeout=Number(e.timeout)||0,this._server=t,this._current=[],this._error=null,this._isOnCloseHandlerKey=Symbol("isOnCloseHandler"),this._lastUsed=null,this.setMaxListeners(0),r&&this.once("start",r),this.started=!1,this.booted=!1,this.pluginTree=new nu,this._readyQ=ln(this,ri,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=dn},this._closeQ=ln(this,uu,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=dn},this._doStart=null,this._root=new dr(this,ou.bind(this),e,!1,0),this._root.once("start",(n,i,o)=>{const s=this.pluginTree.start(null,i,o);this._root.once("loaded",(a,u,d)=>{this.pluginTree.stop(s,d)})}),dr.loadPlugin.call(this,this._root,n=>{je("root plugin ready");try{this.emit("preReady"),this._root=null}catch(i){n=n||this._error||i}if(n){if(this._error=n,this._readyQ.length()===0)throw n}else this.booted=!0;this._readyQ.resume()})}function ou(t,e,r){this._doStart=r,e.autostart&&this.start()}Za(x,Xa);x.prototype.start=function(){return this.started=!0,E.nextTick(this._doStart),this};x.prototype.override=function(t,e,r){return t};function su(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new eu(typeof t);return t}x.prototype[At]=!0;x.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};x.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&E.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(x.prototype,"then",{get:ti});x.prototype._addPlugin=function(t,e,r){if(t=su(t),e=e||{},this.booted)throw new tu;const n=this._current[0],i=new dr(this,t,e,r);if(i.once("start",(o,s,a)=>{const u=this.pluginTree.start(n.name,s,a);i.once("loaded",(d,c,l)=>{this.pluginTree.stop(u,l)})}),n.loaded)throw new Error(i.name,n.name);return n.enqueue(i,o=>{o&&(this._error=o)}),i};x.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(r,n,i){ri.call(this,t,i)}return this};x.prototype.onClose=function(t){if(typeof t!="function")throw new Error("not a function");t[this._isOnCloseHandlerKey]=!0,this._closeQ.unshift(t,e.bind(this));function e(r){r&&(this._error=r)}return this};x.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new We("close",typeof t)}else e=new Promise(function(r,n){t=function(i){if(i)return n(i);r()}});return this.ready(()=>{this._error=null,this._closeQ.push(t),E.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};x.prototype.ready=function(t){if(t){if(typeof t!="function")throw new We("ready",typeof t);this._readyQ.push(t),queueMicrotask(this.start.bind(this));return}return new Promise((e,r)=>{this._readyQ.push(i),this.start();const n=this._current[0].server;function i(o,s,a){o?r(o):e(n),E.nextTick(a)}})};x.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};x.prototype.toJSON=function(){return this.pluginTree.toJSON()};function dn(){}function ti(){if(this.booted){je("thenify returning null because we are already booted");return}if(this[Yt]){this[Yt]=!1;return}return je("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[Yt]=!0,t(this._server)),e)}function ri(t,e){const r=this._server,n=this._error;let i;if(this._error=null,t.length===0)this._error=n,i=t(),i&&!i[At]&&typeof i.then=="function"?i.then(()=>E.nextTick(e),o=>E.nextTick(e,o)):E.nextTick(e);else if(t.length===1)i=t(n),i&&!i[At]&&typeof i.then=="function"?i.then(()=>E.nextTick(e),o=>E.nextTick(e,o)):E.nextTick(e);else if(this._timeout===0){const o=s=>{this._error=s,e(this._error)};t.length===2?t(n,o):t(n,r,o)}else au.call(this,t,n,r,e)}function au(t,e,r,n){const i=t.name;je("setting up ready timeout",i,this._timeout);let o=setTimeout(()=>{je("timed out",i),o=null;const a=new ru(i);a.fn=t,this._error=a,n(a)},this._timeout);t.length===2?t(e,s.bind(this)):t(e,r,s.bind(this));function s(a){o&&(clearTimeout(o),this._error=a,n(this._error))}}function uu(t,e){const r=this._server,n=t[this._isOnCloseHandlerKey];if(t.length===0||t.length===1){let i;n?i=t(r):i=t(this._error),i&&typeof i.then=="function"?(je("resolving close/onClose promise"),i.then(()=>E.nextTick(e),o=>E.nextTick(e,o))):E.nextTick(e)}else t.length===2?t(n?r:this._error,e):n?t(r,e):t(this._error,r,e)}function cu(t,e){return r.bind(e);function r(n,i){let o;t.length===0?(o=t(),o&&o.then?o.then(function(){E.nextTick(i)},i):E.nextTick(i)):t.length===1?(o=t(this),o&&o.then?o.then(function(){E.nextTick(i)},i):E.nextTick(i)):t(this,i)}}function Jt(t,e){return r.bind(e);function r(n,i){let o;t?t.length===0?(o=t(),o&&o.then?o.then(function(){E.nextTick(i,n)},i):E.nextTick(i,n)):t.length===1?(o=t(n),o&&o.then?o.then(function(){E.nextTick(i)},i):E.nextTick(i)):t.length===2?t(n,i):t(n,this,i):E.nextTick(i)}}hr.exports=x;hr.exports.express=function(t){return x(t,{expose:{use:"load"}})};var lu=hr.exports;const du=Bo(lu);(function(){if(window.requestAnimationFrame&&window.cancelAnimationFrame)return;const t=["webkit","moz","ms","o"];for(const e of t)window.requestAnimationFrame=window.requestAnimationFrame||window[`${e}RequestAnimationFrame`],window.cancelAnimationFrame=window.cancelAnimationFrame||window[`${e}CancelAnimationFrame`]||window[`${e}CancelRequestAnimationFrame`];if(/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent)||!window.requestAnimationFrame||!window.cancelAnimationFrame){let e=0;const r=!!(window.performance&&window.performance.now);window.requestAnimationFrame=function(n){const i=r?window.performance.now():new Date().getTime(),o=Math.max(0,16-(i-e)),s=window.setTimeout(function(){n(i+o)},o);return e=i+o,s},window.cancelAnimationFrame=clearTimeout}})();function fu(t,e=!0,r=!0,n={friendsTab:"enabled"}){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=du(Object.create({}),{autostart:!1});return s.use(mo,{hideFriends:n.hideFriends,skipOnboarding:n.skipOnboarding,betPack:n.betPack,friendsTab:n.friendsTab,theme:n.theme,themeMode:n.themeMode}),s.use(co,{onDeepLinkHandled:n?.onDeepLinkHandled}),s.use(ho,{videoPlayerController:n?.videoPlayerController}),s.use(go,{onContentActivate:n?.onContentActivate,withAd:n?.withAd,withAdNotification:n?.withAdNotification}),s.use(Di,{sdkKey:t,host:i,analyticsHost:o,version:n?.version}),s.use(Bi),s.use(po),s.use(_o),s.use(ro),s.use(Mo),s.after((a,u,d)=>{if(a)throw a;u.ready(),d()}),r&&s.after(async(a,u,d)=>{if(a)throw a;await u.sdk.initializeApp(),d()}),s.onClose(()=>{console.log("close")}),s}exports.StreamLayer=fu;
|
|
14
|
+
`+o.map(function(u,d){var c=d===o.length-1,l=u.nodes&&u.nodes.length,p=r+(c?" ":i("│"))+" ";return r+i(c?"└":"├")+i("─")+i(l?"┬":"─")+" "+t(u,p,n).slice(r.length+2)}).join("")};const Va=Ra,on=Symbol("avvio.TimeTree.untrackNode"),Gt=Symbol("avvio.TimeTree.trackNode"),sn=Symbol("avvio.TimeTree.getParent"),an=Symbol("avvio.TimeTree.getNode"),un=Symbol("avvio.TimeTree.addNode");let $a=class{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[Gt](e){this.tableId.set(e.id,e),this.tableLabel.has(e.label)?this.tableLabel.get(e.label).push(e):this.tableLabel.set(e.label,[e])}[on](e){this.tableId.delete(e.id);const r=this.tableLabel.get(e.label);if(r.id){this.tableLabel.delete(e.label);return}r.pop(),r.length===0&&this.tableLabel.delete(e.label)}[sn](e){if(e===null)return this.root;const r=this.tableLabel.get(e);return r.id?r:r[r.length-1]}[an](e){return this.tableId.get(e)}[un](e,r,n){if(e===null)return this.root={id:"root",label:r,start:n,nodes:[]},this[Gt](this.root),this.root.id;const o=this[sn](e),s=`${r}-${Math.random()}`,a={id:s,parent:e,start:n,label:r,nodes:[]};return o.nodes.push(a),this[Gt](a),s}start(e,r,n=Date.now()){return this[un](e,r,n)}stop(e,r=Date.now()){const n=this[an](e);n&&(n.stop=r,n.diff=n.stop-n.start||0,this[on](n))}toJSON(){return Object.assign({},this.root)}prittyPrint(){const e=n=>(n.label=`${n.label} ${n.diff} ms`,n.nodes.length>0&&(n.nodes=n.nodes.map(i=>e(i))),n),r=e(this.toJSON());return Va(r)}};var Ma=$a,Ir={exports:{}},lr={exports:{}},Kt,cn;function Ba(){if(cn)return Kt;cn=1;var t=1e3,e=t*60,r=e*60,n=r*24,i=n*7,o=n*365.25;Kt=function(c,l){l=l||{};var p=typeof c;if(p==="string"&&c.length>0)return s(c);if(p==="number"&&isFinite(c))return l.long?u(c):a(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))};function s(c){if(c=String(c),!(c.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);if(l){var p=parseFloat(l[1]),S=(l[2]||"ms").toLowerCase();switch(S){case"years":case"year":case"yrs":case"yr":case"y":return p*o;case"weeks":case"week":case"w":return p*i;case"days":case"day":case"d":return p*n;case"hours":case"hour":case"hrs":case"hr":case"h":return p*r;case"minutes":case"minute":case"mins":case"min":case"m":return p*e;case"seconds":case"second":case"secs":case"sec":case"s":return p*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function a(c){var l=Math.abs(c);return l>=n?Math.round(c/n)+"d":l>=r?Math.round(c/r)+"h":l>=e?Math.round(c/e)+"m":l>=t?Math.round(c/t)+"s":c+"ms"}function u(c){var l=Math.abs(c);return l>=n?d(c,l,n,"day"):l>=r?d(c,l,r,"hour"):l>=e?d(c,l,e,"minute"):l>=t?d(c,l,t,"second"):c+" ms"}function d(c,l,p,S){var T=l>=p*1.5;return Math.round(c/p)+" "+S+(T?"s":"")}return Kt}function Ua(t){r.debug=r,r.default=r,r.coerce=u,r.disable=o,r.enable=i,r.enabled=s,r.humanize=Ba(),r.destroy=d,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let l=0;for(let p=0;p<c.length;p++)l=(l<<5)-l+c.charCodeAt(p),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=e;function r(c){let l,p=null,S,T;function v(...w){if(!v.enabled)return;const _=v,$=Number(new Date),G=$-(l||$);_.diff=G,_.prev=l,_.curr=$,l=$,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let J=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(V,k)=>{if(V==="%%")return"%";J++;const ne=r.formatters[k];if(typeof ne=="function"){const ie=w[J];V=ne.call(_,ie),w.splice(J,1),J--}return V}),r.formatArgs.call(_,w),(_.log||r.log).apply(_,w)}return v.namespace=c,v.useColors=r.useColors(),v.color=r.selectColor(c),v.extend=n,v.destroy=r.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(S!==r.namespaces&&(S=r.namespaces,T=r.enabled(c)),T),set:w=>{p=w}}),typeof r.init=="function"&&r.init(v),v}function n(c,l){const p=r(this.namespace+(typeof l>"u"?":":l)+c);return p.log=this.log,p}function i(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let l;const p=(typeof c=="string"?c:"").split(/[\s,]+/),S=p.length;for(l=0;l<S;l++)p[l]&&(c=p[l].replace(/\*/g,".*?"),c[0]==="-"?r.skips.push(new RegExp("^"+c.slice(1)+"$")):r.names.push(new RegExp("^"+c+"$")))}function o(){const c=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),c}function s(c){if(c[c.length-1]==="*")return!0;let l,p;for(l=0,p=r.skips.length;l<p;l++)if(r.skips[l].test(c))return!1;for(l=0,p=r.names.length;l<p;l++)if(r.names[l].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function u(c){return c instanceof Error?c.stack||c.message:c}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}var Qa=Ua;(function(t,e){e.formatArgs=n,e.save=i,e.load=o,e.useColors=r,e.storage=s(),e.destroy=(()=>{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;u.splice(1,0,d,"color: inherit");let c=0,l=0;u[0].replace(/%[a-zA-Z%]/g,p=>{p!=="%%"&&(c++,p==="%c"&&(l=c))}),u.splice(l,0,d)}e.log=console.debug||console.log||(()=>{});function i(u){try{u?e.storage.setItem("debug",u):e.storage.removeItem("debug")}catch{}}function o(){let u;try{u=e.storage.getItem("debug")}catch{}return!u&&typeof E<"u"&&"env"in E&&(u=E.env.DEBUG),u}function s(){try{return localStorage}catch{}}t.exports=Qa(e);const{formatters:a}=t.exports;a.j=function(u){try{return JSON.stringify(u)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(lr,lr.exports);var Zn=lr.exports;const qa=On,ja=Rn.EventEmitter,xa=kt.inherits,j=Zn("avvio"),{AVV_ERR_READY_TIMEOUT:Ga}=Xn,zt=Symbol.for("plugin-meta");function Ka(t,e){return t[zt]&&t[zt].name?t[zt].name:typeof e<"u"&&typeof e!="function"&&e.name?e.name:t.name?t.name:t.toString().split(`
|
|
15
|
+
`).slice(0,2).map(r=>r.trim()).join(" -- ")}function za(){const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function xe(t,e,r,n,i){this.started=!1,this.func=e,this.opts=r,this.onFinish=null,this.parent=t,this.timeout=i===void 0?t._timeout:i,this.name=Ka(e,r),this.isAfter=n,this.q=qa(t,Ha,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}xa(xe,ja);xe.prototype.exec=function(t,e){const r=this.func;let n=!1;const i=this.name;if(this.parent._error&&!this.isAfter){j("skipping loading of plugin as parent errored and it is not an after",i),E.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,r,this.opts)}catch(u){return j("override errored",i),e(u)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,j("exec",i);let o;const s=u=>{if(n){j("loading complete",i);return}this._error=u,j(u?"exec errored":"exec completed",i),n=!0,o&&clearTimeout(o),e(u)};this.timeout>0&&(j("setting up timeout",i,this.timeout),o=setTimeout(function(){j("timed out",i),o=null;const u=new Ga(i);u.fn=r,s(u)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const a=r(this.server,this.opts,s);a&&typeof a.then=="function"&&(j("exec: resolving promise",i),a.then(()=>E.nextTick(s),u=>E.nextTick(s,u)))};xe.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((r,n)=>{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)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=za(),e=this._promise.promise,this.server?t():this.on("start",t)),e};xe.prototype.enqueue=function(t,e){j("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};xe.prototype.finish=function(t,e){j("finish",this.name,t);const r=()=>{this.loaded||(j("loaded",this.name),this.emit("loaded",this.server?this.server.name:null,this.name,Date.now()),this.loaded=!0,e(t))};if(t){this._promise&&(this._promise.reject(t),this._promise=null),r();return}const n=()=>{if(j("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const i=()=>{j("wrap"),queueMicrotask(n)};this._promise.resolve(),this._promise.promise.then(i,i),this._promise=null}else r();else j("delayed",this.name),this.q.drain=()=>{j("drain",this.name),this.q.drain=Wa,queueMicrotask(n)}};queueMicrotask(n),this.q.resume()};function Ha(t,e){const r=this;E.nextTick(Or.bind(r),t,e)}function Or(t,e){if(typeof t.func.then=="function"){t.func.then(n=>{typeof n.default=="function"&&(n=n.default),t.func=n,Or.call(this,t,e)},e);return}const r=this._current[0];this._current.unshift(t),t.exec(r&&r.server||this._server,n=>{t.finish(n,i=>{this._current.shift(),e(i)})})}function Wa(){}Ir.exports=xe;Ir.exports.loadPlugin=Or;var Ya=Ir.exports;const ln=On,Ja=Rn.EventEmitter,Xa=kt.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:Ht,AVV_ERR_CALLBACK_NOT_FN:Ye,AVV_ERR_PLUGIN_NOT_VALID:Za,AVV_ERR_ROOT_PLG_BOOTED:eu,AVV_ERR_READY_TIMEOUT:tu}=Xn,ru=Ma,dr=Ya,je=Zn("avvio"),At=Symbol("kAvvio"),Wt=Symbol("kThenifyDoNotWrap");function nu(t,e,r){const n=e.expose||{},i=n.use||"use",o=n.after||"after",s=n.ready||"ready",a=n.onClose||"onClose",u=n.close||"close";if(t[i])throw new Ht(i);if(t[o])throw new Ht(o);if(t[s])throw new Ht(s);t[i]=function(d,c){return r.use(d,c),this},Object.defineProperty(t,"then",{get:ei.bind(r)}),t[At]=!0,t[o]=function(d){return typeof d!="function"?r._loadRegistered():(r.after(Yt(d,this)),this)},t[s]=function(d){if(d&&typeof d!="function")throw new Ye(s,typeof d);return r.ready(d?Yt(d,this):void 0)},t[a]=function(d){if(typeof d!="function")throw new Ye(a,typeof d);return r.onClose(uu(d,this)),this},t[u]=function(d){if(d&&typeof d!="function")throw new Ye(u,typeof d);return d?(r.close(Yt(d,this)),this):r.close()}}function x(t,e,r){if(typeof t=="function"&&arguments.length===1&&(r=t,e={},t=null),typeof e=="function"&&(r=e,e={}),e=e||{},!(this instanceof x)){const n=new x(t,e,r);return t&&nu(t,e,n),n}e.autostart!==!1&&(e.autostart=!0),t=t||this,this._timeout=Number(e.timeout)||0,this._server=t,this._current=[],this._error=null,this._isOnCloseHandlerKey=Symbol("isOnCloseHandler"),this._lastUsed=null,this.setMaxListeners(0),r&&this.once("start",r),this.started=!1,this.booted=!1,this.pluginTree=new ru,this._readyQ=ln(this,ti,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=dn},this._closeQ=ln(this,au,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=dn},this._doStart=null,this._root=new dr(this,iu.bind(this),e,!1,0),this._root.once("start",(n,i,o)=>{const s=this.pluginTree.start(null,i,o);this._root.once("loaded",(a,u,d)=>{this.pluginTree.stop(s,d)})}),dr.loadPlugin.call(this,this._root,n=>{je("root plugin ready");try{this.emit("preReady"),this._root=null}catch(i){n=n||this._error||i}if(n){if(this._error=n,this._readyQ.length()===0)throw n}else this.booted=!0;this._readyQ.resume()})}function iu(t,e,r){this._doStart=r,e.autostart&&this.start()}Xa(x,Ja);x.prototype.start=function(){return this.started=!0,E.nextTick(this._doStart),this};x.prototype.override=function(t,e,r){return t};function ou(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new Za(typeof t);return t}x.prototype[At]=!0;x.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};x.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&E.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(x.prototype,"then",{get:ei});x.prototype._addPlugin=function(t,e,r){if(t=ou(t),e=e||{},this.booted)throw new eu;const n=this._current[0],i=new dr(this,t,e,r);if(i.once("start",(o,s,a)=>{const u=this.pluginTree.start(n.name,s,a);i.once("loaded",(d,c,l)=>{this.pluginTree.stop(u,l)})}),n.loaded)throw new Error(i.name,n.name);return n.enqueue(i,o=>{o&&(this._error=o)}),i};x.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(r,n,i){ti.call(this,t,i)}return this};x.prototype.onClose=function(t){if(typeof t!="function")throw new Error("not a function");t[this._isOnCloseHandlerKey]=!0,this._closeQ.unshift(t,e.bind(this));function e(r){r&&(this._error=r)}return this};x.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new Ye("close",typeof t)}else e=new Promise(function(r,n){t=function(i){if(i)return n(i);r()}});return this.ready(()=>{this._error=null,this._closeQ.push(t),E.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};x.prototype.ready=function(t){if(t){if(typeof t!="function")throw new Ye("ready",typeof t);this._readyQ.push(t),queueMicrotask(this.start.bind(this));return}return new Promise((e,r)=>{this._readyQ.push(i),this.start();const n=this._current[0].server;function i(o,s,a){o?r(o):e(n),E.nextTick(a)}})};x.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};x.prototype.toJSON=function(){return this.pluginTree.toJSON()};function dn(){}function ei(){if(this.booted){je("thenify returning null because we are already booted");return}if(this[Wt]){this[Wt]=!1;return}return je("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[Wt]=!0,t(this._server)),e)}function ti(t,e){const r=this._server,n=this._error;let i;if(this._error=null,t.length===0)this._error=n,i=t(),i&&!i[At]&&typeof i.then=="function"?i.then(()=>E.nextTick(e),o=>E.nextTick(e,o)):E.nextTick(e);else if(t.length===1)i=t(n),i&&!i[At]&&typeof i.then=="function"?i.then(()=>E.nextTick(e),o=>E.nextTick(e,o)):E.nextTick(e);else if(this._timeout===0){const o=s=>{this._error=s,e(this._error)};t.length===2?t(n,o):t(n,r,o)}else su.call(this,t,n,r,e)}function su(t,e,r,n){const i=t.name;je("setting up ready timeout",i,this._timeout);let o=setTimeout(()=>{je("timed out",i),o=null;const a=new tu(i);a.fn=t,this._error=a,n(a)},this._timeout);t.length===2?t(e,s.bind(this)):t(e,r,s.bind(this));function s(a){o&&(clearTimeout(o),this._error=a,n(this._error))}}function au(t,e){const r=this._server,n=t[this._isOnCloseHandlerKey];if(t.length===0||t.length===1){let i;n?i=t(r):i=t(this._error),i&&typeof i.then=="function"?(je("resolving close/onClose promise"),i.then(()=>E.nextTick(e),o=>E.nextTick(e,o))):E.nextTick(e)}else t.length===2?t(n?r:this._error,e):n?t(r,e):t(this._error,r,e)}function uu(t,e){return r.bind(e);function r(n,i){let o;t.length===0?(o=t(),o&&o.then?o.then(function(){E.nextTick(i)},i):E.nextTick(i)):t.length===1?(o=t(this),o&&o.then?o.then(function(){E.nextTick(i)},i):E.nextTick(i)):t(this,i)}}function Yt(t,e){return r.bind(e);function r(n,i){let o;t?t.length===0?(o=t(),o&&o.then?o.then(function(){E.nextTick(i,n)},i):E.nextTick(i,n)):t.length===1?(o=t(n),o&&o.then?o.then(function(){E.nextTick(i)},i):E.nextTick(i)):t.length===2?t(n,i):t(n,this,i):E.nextTick(i)}}hr.exports=x;hr.exports.express=function(t){return x(t,{expose:{use:"load"}})};var cu=hr.exports;const lu=Mo(cu);(function(){if(window.requestAnimationFrame&&window.cancelAnimationFrame)return;const t=["webkit","moz","ms","o"];for(const e of t)window.requestAnimationFrame=window.requestAnimationFrame||window[`${e}RequestAnimationFrame`],window.cancelAnimationFrame=window.cancelAnimationFrame||window[`${e}CancelAnimationFrame`]||window[`${e}CancelRequestAnimationFrame`];if(/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent)||!window.requestAnimationFrame||!window.cancelAnimationFrame){let e=0;const r=!!(window.performance&&window.performance.now);window.requestAnimationFrame=function(n){const i=r?window.performance.now():new Date().getTime(),o=Math.max(0,16-(i-e)),s=window.setTimeout(function(){n(i+o)},o);return e=i+o,s},window.cancelAnimationFrame=clearTimeout}})();function du(t,e=!0,r=!0,n={friendsTab:"enabled"}){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=lu(Object.create({}),{autostart:!1});return s.use(go,{hideFriends:n.hideFriends,skipOnboarding:n.skipOnboarding,betPack:n.betPack,friendsTab:n.friendsTab,theme:n.theme,themeMode:n.themeMode}),s.use(uo,{onDeepLinkHandled:n?.onDeepLinkHandled}),s.use(po,{videoPlayerController:n?.videoPlayerController}),s.use(yo,{onContentActivate:n?.onContentActivate,withAd:n?.withAd,withAdNotification:n?.withAdNotification}),s.use(Fi,{sdkKey:t,host:i,analyticsHost:o,version:n?.version}),s.use(Mi),s.use(fo),s.use(ko),s.use(to),s.use($o),s.after((a,u,d)=>{if(a)throw a;u.ready(),d()}),r&&s.after(async(a,u,d)=>{if(a)throw a;await u.sdk.initializeApp(),d()}),s.onClose(()=>{console.log("close")}),s}exports.StreamLayer=du;
|