@streamlayer/sdk-web 0.33.1 → 0.33.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,15 +1,15 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $n=require("pino"),_=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"),X=require("nanostores"),Mt=require("nanoid"),q=require("@connectrpc/connect"),yr=require("@connectrpc/connect-web"),gr=require("@nanostores/query"),jn=require("@streamlayer/sl-eslib/sports/events/events_connect"),Xe=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),rr=require("@streamlayer/sl-eslib/users/users_connect"),me=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),Gr=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect");require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb");const qn=require("@streamlayer/sl-eslib/shortLinks/linksClient_connect"),v=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),Kr=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_connect"),mr=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),Y=require("@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb");function Un(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zr={exports:{}},$=zr.exports={},te,re;function xt(){throw new Error("setTimeout has not been defined")}function Bt(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?te=setTimeout:te=xt}catch{te=xt}try{typeof clearTimeout=="function"?re=clearTimeout:re=Bt}catch{re=Bt}})();function Hr(t){if(te===setTimeout)return setTimeout(t,0);if((te===xt||!te)&&setTimeout)return te=setTimeout,setTimeout(t,0);try{return te(t,0)}catch{try{return te.call(null,t,0)}catch{return te.call(this,t,0)}}}function Mn(t){if(re===clearTimeout)return clearTimeout(t);if((re===Bt||!re)&&clearTimeout)return re=clearTimeout,clearTimeout(t);try{return re(t)}catch{try{return re.call(null,t)}catch{return re.call(this,t)}}}var fe=[],je=!1,Ae,at=-1;function xn(){!je||!Ae||(je=!1,Ae.length?fe=Ae.concat(fe):at=-1,fe.length&&Wr())}function Wr(){if(!je){var t=Hr(xn);je=!0;for(var e=fe.length;e;){for(Ae=fe,fe=[];++at<e;)Ae&&Ae[at].run();at=-1,e=fe.length}Ae=null,je=!1,Mn(t)}}$.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];fe.push(new Jr(t,e)),fe.length===1&&!je&&Hr(Wr)};function Jr(t,e){this.fun=t,this.array=e}Jr.prototype.run=function(){this.fun.apply(null,this.array)};$.title="browser";$.browser=!0;$.env={};$.argv=[];$.version="";$.versions={};function he(){}$.on=he;$.addListener=he;$.once=he;$.off=he;$.removeListener=he;$.removeAllListeners=he;$.emit=he;$.prependListener=he;$.prependOnceListener=he;$.listeners=function(t){return[]};$.binding=function(t){throw new Error("process.binding is not supported")};$.cwd=function(){return"/"};$.chdir=function(t){throw new Error("process.chdir is not supported")};$.umask=function(){return 0};var Bn=zr.exports;const w=Un(Bn),Qn=$n.pino({level:"trace",enabled:!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),ve=(t,e)=>Qn.child({name:t},e);class Gn extends Event{slEventBus;constructor(e,r){super(e),this.slEventBus=r}}const Kn=ve("event-bus");class zn{name;listeners;constructor(e="sl-event-bus"){this.name=e,this.listeners=new Set}emit=(e,r)=>{const n=new Gn(this.name,{...r,type:e});Kn.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 Hn{}window.slStore=Object.create(null);class bt{store;name;constructor(e,r){this.store=e,this.name=r}getStore(){return this.store}}const Wn=t=>{const e=Object.keys(t);return X.computed(e.map(r=>t[r].getStore()),(...r)=>Object.fromEntries(e.map((n,i)=>[n,r[i]])))};class Te extends bt{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 ie=t=>X.map(t);var ce;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(ce||(ce={}));const Jn={[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 Yr{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},n){this.settingsKey=Jn[r.type],this.status=X.atom(ze.Suspended),this.config=new Te(ie(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new Te(ie(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new Te(ie({}),`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===ce.STREAM&&r===ce.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 z extends bt{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=>X.atom(t);class oe extends bt{atomStore;constructor(e,r,n){super(e,`api:${r}`),this.atomStore=X.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 pe=new zn;async function*Yn(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now();const n={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(n),yield r}}const Xn=()=>t=>async e=>{const r={name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries())},response:{}};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){r.request.message=e.message;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...r,stream:!1}};return window.postMessage(i),{...n,message:Yn(r,n.message)}}else{r.request.message=e.message,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.request.message=e.message,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"));var J;(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"})(J||(J={}));class Zn{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,n,i){const o={status:J.Init,ts:new Date,log:[]};this.state=new Te(ie(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 z(Q(null),`subscription:${i.name}:store`)),"subscribe"in n&&typeof n.subscribe=="function"&&(this.paramsListener=n.subscribe(s=>{this.state.getValue("status")===J.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(J.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}`;r.push(n),this.state.setValue("log",r),window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
2
- `+n)};addListener=(e,r)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),!1):(this.listeners.set(e,r),this.addStateLog(`listener '${e}' added`),!0);removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(J.Connecting),this.streamCancel&&(this.addStateLog("disconnect prev connection"),this.streamCancel.abort(),this.streamCancel=void 0);const e="get"in this.params&&typeof this.params.get=="function"?this.params.get():this.params;(async()=>{this.streamCancel=new AbortController;try{const n={headers:this.headers.getValues(),signal:this.streamCancel.signal},i=this.method(e,n);for await(const o of i)this.attempt=0,this.onData(o)}catch(n){n instanceof q.ConnectError&&n.code!=q.Code.Canceled&&this.onStreamError(n)}})(),this.updateState(J.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(J.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(J.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(J.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${r}ms`),this.connect(),this.reconnectTimeout=void 0},r)}else this.addStateLog("max reconnect attempts reached"),this.disconnect()};getStore=()=>this.store?.getStore();onData=e=>{try{this.addStateLog(`received data => ${JSON.stringify(e)}`),this.store&&this.store.setValue(e);for(const[,r]of this.listeners)r(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(r){this.addStateLog(`error process data => ${r}`)}};onStreamError=e=>{if(this.addStateLog(`error => ${e?JSON.stringify(e):"undefined"}}`),e!==void 0){if(e instanceof q.ConnectError&&e.code!==q.Code.Canceled){this.updateState(J.Failed),this.state.setValue("error",e),this.reconnect();return}this.disconnect()}}}const ei=new Set([q.Code.Unknown,q.Code.Internal,q.Code.DeadlineExceeded,q.Code.ResourceExhausted,q.Code.FailedPrecondition,q.Code.Unavailable,q.Code.DataLoss]),vr=ve("grpc:retry"),ti=t=>async e=>{const r=e.contextValues.get(Qt.retryAttempts),n=300,i=e.contextValues.get(Qt.retryDelay);if(e.stream||r===0)return t(e);vr.trace({url:e.url,attempts:r,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){vr.trace({attempt:o,error:s},"retry attempt");const a=q.ConnectError.from(s);if(o>=r||!(a instanceof q.ConnectError)||!ei.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))}},Qt={retryAttempts:q.createContextKey(5,{description:"Number of attempts to retry"}),retryDelay:q.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},ri=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=Mt.nanoid();return localStorage.setItem("sl-device-id",e),e},ni=()=>navigator.userAgentData?.platform||navigator.platform;class br{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;$headers;interceptors=[];clients;streamClients;subscriptions;constructor(e){this.host=e,this.$headers=new Te(ie({"sl-device-id":ri(),"sl-device-os":ni()}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.streamClients=new Map,this.subscriptions=new Map;const[r,n,i]=gr.nanoquery({dedupeTime:1e3*60*5,refetchInterval:1e3*60*5});this.nanoquery={createFetcherStore:r,createMutatorStore:n,utils:i},this.transport=yr.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors,useBinaryFormat:!0}),this.streamTransport=yr.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors,useBinaryFormat:!0})}addSubscription=(e,r,n)=>{const i=this.subscriptions.get(r);if(i)return i;const o=new Zn(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]=gr.nanoquery();this.nanoquery={createFetcherStore:e,createMutatorStore:r,utils:n}};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(r=>r!==e)};getClient=e=>{const r=e.typeName;if(this.clients.has(r))return this.clients.get(r);const n=q.createPromiseClient(e,this.transport);return this.clients.set(r,n),n};getStreamClient=e=>{const r=`stream-${e.typeName}`;if(this.clients.has(r))return this.clients.get(r);const n=q.createPromiseClient(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=q.createContextValues();for(const f in d){const y=Qt[f];c.set(y,d[f])}return c},queryKey:s,queryKeyStr:a.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,r)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",r)};setHeader=(e,r)=>this.$headers.setValue(e,r);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=r=>n=>{const i=this.$headers.getValues();for(const o in i)n.header.set(o,i[o]);return r(n)};this.interceptors.push(e),this.interceptors.push(Xn()),this.interceptors.push(ti)}}const ii=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(jn.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(Xe.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.getStream({id:s})).data?.attributes:void 0})},si=(t,e)=>{const{queryKey:r,client:n}=e.createPromiseClient(rr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:()=>n.me({})})},ai=t=>{const{client:e,createRequestOptions:r}=t.createPromiseClient(rr.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})},ui=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.get({})).data?.attributes})},ci=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>{const i=await r.getOrganization({});return i.data?{...i.data.attributes,id:i.data.id}:void 0}})},li=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},di=(t,e,r)=>{t.transport=new br(e.host),t.analyticsTransport=new br(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(()=>()=>{t.transport.disconnect(),t.analyticsTransport.disconnect()}),r()};class St{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()||"";this.storage.setItem(this.generateKey(e),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 ue;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(ue||(ue={}));class Re extends St{constructor(){super("user")}setSchema=e=>{this.write(ue.SCHEMA,e)};getSchema=()=>this.read(ue.SCHEMA);setToken=e=>{this.write(ue.TOKEN,e)};getToken=()=>this.read(ue.TOKEN);setExternalToken=e=>{this.write(ue.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(ue.EXTERNAL_TOKEN);removeToken=()=>{this.remove(ue.TOKEN)}}var le;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(le||(le={}));const fi=t=>{const e=new Re,r=new z(Q(e.getExternalToken()),"userKey"),n=new z(Q(e.getToken()),"userToken"),i=new oe(si(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 oe(ui(n.getStore(),t),"userSettings");return{userKey:r,userToken:n,user:i,userSettings:o}},pi=t=>{const e=new z(Q(void 0),"providerStreamId"),r=new oe(ii(e.getStore(),t),"slStreamId",i=>i?.data),n=new oe(oi(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(i=>{(i===""||i===void 0)&&n.getStore().mutate(void 0)}),{providerStreamId:e,slStreamId:r,streamSettings:n}},hi=t=>{const e=new z(Q(void 0),"enabled"),r=new z(Q(le.DISABLED),"status"),n=new oe(ci(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new oe(li(n.getAtomStore(),t),"organizationAdvertising"),o=fi(t),s=pi(t);return{enabled:e,status:r,providerStreamId:s.providerStreamId,slStreamId:s.slStreamId,streamSettings:s.streamSettings,user:o.user,userKey:o.userKey,userToken:o.userToken,userSettings:o.userSettings,organizationSettings:n,organizationAdvertising:i}};class yi extends bt{stores;constructor(e){const r=hi(e),n=Wn(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 gi=(t,e,r)=>{t.store=new yi(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.storeUnsubscribe=()=>{t.store.unsubscribe()},r()},mi=t=>{const{client:e}=t.createPromiseClient(Gr.Leaderboard,{method:"list"});return r=>e.list(r)},vi=t=>{const{client:e}=t.createPromiseClient(Gr.Leaderboard,{method:"summary"});return r=>e.summary(r)},bi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(rr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.getFriends({})).data:[]})},Si=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(me.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.get({eventId:s})).data?.attributes,refetchInterval:0,dedupeTime:1e3*60*60})},wi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(me.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.syncQuestion({filter:{eventId:s}})).data?.attributes:void 0,dedupeTime:1e3*60*10,refetchInterval:0})},Ai=(t,e)=>{const{client:r}=e.createStreamClient(me.Feed),n=X.atom({eventId:t.get()||"",feedId:""});return t.subscribe((o="")=>{n.set({eventId:o,feedId:""})}),e.addSubscription(r.subscription,n,{name:"feedSubscription"})},Ti=(t,e)=>{const{client:r}=e.createStreamClient(me.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},Gt=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(me.Feed,{method:"questionByUser",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.questionByUser({questionId:s})).data?.attributes?.question,dedupeTime:1e3*60*5})},Ei=(t,e,r)=>{const{client:n,queryKey:i}=r.createPromiseClient(me.Feed,{method:"list",params:[t,e]});return r.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>a?(await n.list({eventId:a,filter:{types:u===Ee.ALLOWED?[]:[_.QuestionType.FACTOID,_.QuestionType.PROMOTION,_.QuestionType.TWEET],statuses:[_.QuestionStatus.ACTIVE,_.QuestionStatus.RESOLVED]}})).data:[],dedupeTime:0,refetchInterval:0})},Ii=(t,e,r)=>{const n=X.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=X.batched(n,a=>a&&a.type==="question"?a.id:void 0),o=Gt(i,t);return{$store:n,$extendedStore:o,updateExtendedQuestion:a=>{const u=o.get().data,d=(c,f)=>{if(!c||!f)return c||f||[];const y=[];for(let m=0;m<c.length;m++)y.push({...c[m],...f[m],correct:c[m].correct,youVoted:c[m].youVoted,pointsEarned:c[m].pointsEarned});return y};o.mutate({...a,options:u?.options,subject:u?.subject,appearance:u?.appearance,answers:d(u?.answers,a?.answers)})}}};var Ee;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Ee||(Ee={}));class Oi{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;notifications;log;transport;constructor(e){this.transport=e.transport,this.log=ve("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new z(Q(void 0),"moderationId").getStore(),this.interactiveAllowed=new z(Q(Ee.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new z(Q(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new oe(Si(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new oe(Ei(this.slStreamId,this.interactiveAllowed,e.transport),"gamification:feedList"),this.activeQuestionId=new oe(wi(this.slStreamId,e.transport),"gamification:activeQuestionId"),this.openedQuestion=Ii(e.transport,this.openedQuestionId,this.feedList.getStore()),this.openedQuestionId.listen(r=>{this.log.debug({item:r},"received question"),r?.questionId?(this.questionSubscription=Ti(r.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",n=>{this.openedQuestion.updateExtendedQuestion(n.data?.attributes?.question)}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))}),this.feedSubscription=Ai(this.slStreamId,e.transport),this.feedSubscription.addListener("feed-subscription-active-question",r=>{const n=this.activeQuestionId.store,i=n.get().data?.question?.id,o=r.data?.attributes?.question;o&&(i&&o.status===_.QuestionStatus.RESOLVED&&o.id!==i||n&&n.mutate(r.data?.attributes))}),this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})}),this.feedSubscription.connect(),this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})}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 Ci{notificationsList;notifications;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=ve("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notifications=new z(Q(new Map),"notifications-queue"),this.notificationsList=this.notifications.getStore()}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)}}),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}const n=setTimeout(()=>{const i=e,o=new Map(this.notifications.getValue());o.set(r.id,r),this.notifications.setValue(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=>{const r=new Map(this.notifications.getValue()),n=r.get(e);if(n){n.hiding=!(this.waitingQueue.size>=this.options.concurrency),this.notifications.setValue(r);const i=setTimeout(()=>{const o=new Map(this.notifications.getValue());o.delete(e),this.notifications.setValue(o);const s=this.timeouts.get(e);s!==void 0&&(clearTimeout(s),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden")},this.options.animationDelay||0);this.timeouts.set(e,i)}return this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding"),n}}var pt;(function(t){t.OPENED="opened"})(pt||(pt={}));class _i extends St{constructor(){super("notification")}setOpened=e=>{this.write(pt.OPENED,e,"true")};isOpened=e=>this.read(pt.OPENED,e);clearNotification=()=>{this.clear()}}var ge;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(ge||(ge={}));class ki{queue;storage;constructor(e={}){this.storage=new _i,this.queue=new Ci({concurrency:1,animationDelay:1600,...e})}add=e=>{if(!this.storage.isOpened(e.id)){if(e.data&&e.emitEvent){const n=e.action;e.action=(...i)=>{n&&n(...i),pe.emit("notification",{action:"opened",payload:{questionId:e.data.questionId,questionType:e.data.questionType}})}}this.queue.addToQueue(e)}};close=(e,r=!0)=>{this.queue.closeNotification(e),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 Li=(t,e,r)=>{t.notifications=new ki(void 0),t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),t.sdk.getActiveNotification=()=>t.notifications.getActiveNotification(),r()};var Ye;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(Ye||(Ye={}));const Pi=async(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(me.Feed,{method:"submitAnswer"}),i=n({retryAttempts:0});try{return await r.submitAnswer({data:e},{contextValues:i})}catch(o){throw q.ConnectError.from(o)?.code===q.Code.AlreadyExists?new Error(Ye.ALREADY_VOTED):new Error(Ye.UNKNOWN)}},Fi=(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(me.Feed,{method:"submitInplay"}),i=n({retryAttempts:0});return r.submitInplay({data:{eventId:+e}},{contextValues:i})};var Ve;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})(Ve||(Ve={}));class Xr extends St{constructor(){super("gamification")}saveOnboardingStatus=({userId:e,eventId:r,organizationId:n},i)=>{this.write(Ve.ONBOARDING,n,e,r,i)};getOnboardingStatus=({userId:e,eventId:r,organizationId:n})=>this.read(Ve.ONBOARDING,n,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{const i=this.generateKey([Ve.ONBOARDING_IO,n,e,r]);window.sessionStorage.setItem(i,"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{const i=this.generateKey([Ve.ONBOARDING_IO,n,e,r]);return window.sessionStorage.getItem(i)}}const Ni={pageSize:10},Di=(t,e,r,n,i)=>{let o=0;const s=Q({pageSize:i?.pageSize||Ni.pageSize,page:0}),a=ie({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=mi(t),d=async()=>{const y=e.get(),m=n.getStore().get().data?.map(b=>b.slId)||[];if(y&&m?.length){const b=r.get();b&&m.push(b),a.setKey("loading",!0),a.setKey("data",[]);const I=await u({eventId:y,usersIds:m});a.set({data:I.data.map(D=>D.attributes),hasMore:!1,key:Date.now(),loading:!1}),I.meta&&(o=Math.round(I.meta.count/I.meta.pageSize))}},c=()=>{d()},f=y=>{const m=s.get(),b=y||m.page+1;b<=o&&s.set({...m,page:b})};return X.onMount(a,()=>{const y=e.listen(d),m=n.listen(d);return()=>{y(),m()}}),{$store:a,fetchMore:f,invalidate:c}};class Ri extends St{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Sr="sldl",wt="sldl_uid",Zr="sldl_eid",en="sldl_e_eid",Vi=new Set([wt,Zr,en]),wr=t=>{const e={},r={};for(const[n,i]of t)Vi.has(n)?e[n]=i:r[n]=i;return{result:e,remain:r}},$i=({hash:t,search:e})=>{if(t&&t.includes(Sr)){const r=new URLSearchParams(t.substr(1));return{hash:wr(r)}}if(e&&e.includes(Sr)){const r=new URLSearchParams(e);return{search:wr(r)}}return null},Ar=ve("deep_link"),ne={debug:(...t)=>{Ar.debug(...t),console.log(...t)},trace:(...t)=>{Ar.trace(...t),console.log(...t)}},ji=(t,e)=>{const{hash:r,search:n}=window.location;if(ne.debug({hash:r,search:n},"get deep link data from"),r||n){const i=$i({hash:r,search:n});if(ne.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()}`,ne.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()}`,ne.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},qi=(t,e,r)=>{const n=new Ri,i=n.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){ne.debug(a)}t.deepLink={$store:new Te(ie(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{ne.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?.[wt]: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=>{ne.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{ne.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),ne.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{ne.trace("called handler"),u(a)}catch(d){console.error(d)}};ji(t.deepLink.$store,s),r()},Ui=ve("bypass");class Mi extends Hn{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,n){super(),this.$coreStore=e,this.deepLink=n,this.transport=r,this.bypassLogin=ai(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?.[wt];Ui.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(s),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 Re().clear()};softLogout=()=>{const e=new Re;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=()=>{const e=new Re,r=e.getToken(),n=e.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(n),r)return this.saveUser(r,""),this.me().then(i=>{if(i?.id){const o=i.id;this.saveUser(r,o)}});if(n&&!r){const i=e.getSchema();i&&n&&this.login(i,n).catch(()=>{this.logout()})}};saveUser=(e,r)=>{this.transport.setAuth(e,r),this.$coreStore.getValues().userToken.setValue(e),new Re().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 Re,xi=(t,e,r)=>{t.auth=new Mi(t.store,t.transport,t.deepLink),t.stores.status.listen(n=>{n===le.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()},Tr=ve("video_player"),ot={debug:(...t)=>{Tr.debug(...t),console.log(...t)},trace:(...t)=>{Tr.trace(...t),console.log(...t)}},Bi=(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()},Qi=(t,e,r)=>{const n=new Set,i=new Set;t.sdk=Object.create(null),t.sdk.onMount=o=>{n.add(o)},t.ready=()=>{t.stores.enabled.subscribe(o=>{o==="on"?n.forEach(s=>i.add(s())):i.forEach(s=>s())})},t.sdk.initializeApp=async o=>{if(t.contextConfig=o,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(le.INITIALIZATION);try{const s=await t.stores.organizationSettings.getValue();return s?(t.stores.status.setValue(le.READY),{enabled:!!s}):(t.stores.status.setValue(le.FAILED),{err:"failed"})}catch(s){return t.stores.enabled.setValue(),t.stores.status.setValue(le.FAILED),{err:`${s}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(le.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=o=>{t.stores.providerStreamId.setValue(o)},r()},Gi=(t,e)=>{const{client:r,queryKey:n}=t.createPromiseClient(Xe.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s,a)=>s?(await r.generateDeepLink({data:{gamification:!0,externalEventId:a,eventId:s}})).data?.attributes:{},dedupeTime:1e3*60*60*24,refetchInterval:0})},Ki=(t,{web:e,mobile:r})=>{const{client:n}=t.createPromiseClient(qn.LinksClient,{method:"generate"});return n.generate({web:e,mobile:r})},Er=(t,e)=>{const r=new URLSearchParams(t);for(const[n,i]of Object.entries(e))r.append(n,i);return r.toString()},zi=(t,e,r,n)=>{const i=ie({});return X.onMount(i,()=>Gi(t,[e,r]).subscribe(async({data:a,error:u,loading:d})=>{const c=u?"https://masters.com":a?.url,f=n.get()||"",y=e.get()||"",m=r.get()||"",b={[wt]:f,[Zr]:y,[en]:m};if(!d&&c){i.setKey("loading",!0);let O=window.location.search,I=window.location.hash;O&&I||I?O=`?${Er(O,b)}`:I=`#${Er("",b)}`;const D=window.location.origin+window.location.pathname+O+I,j=await Ki(t,{web:D,mobile:c});i.set({data:j.data?.link,loading:!1})}else i.setKey("loading",!0)})),{$store:i,fetch}};var x;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(x||(x={}));const Hi=(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,persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:_.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)=>{try{const s=e.userId.get();if(!s)return;if(i.getOnboardingStatus({userId:s,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===x.Completed){t.set(x.Completed);for(const y of o)y();return}const u=e.moderation.getStore().value?.data,d=r.featureSettings.get().inplayGame;if(u===void 0||d===void 0)return;const c=u?.options?.onboardingEnabled,f=d?.titleCard?.optIn;c?f?t.set(x.Required):t.set(x.Optional):(f?t.set(x.Unavailable):t.set(x.Disabled),n.close(e.getCurrentSessionId({prefix:"onboarding"}),!1))}catch(s){console.error(s)}},Wi=(t,e,r,n)=>{let i=!1;const o=new Xr,s=Q(x.Unset);s.subscribe(d=>{d!==x.Unset&&((d===x.Optional||d===x.Required)&&i===!1&&(Hi(t,e,n,o),i=!0),d===x.Completed&&e.activeQuestionId.invalidate(),o.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const a=[];return st(s,e,t,n,o,a),s.get()!==x.Completed&&(a.push(e.userId.listen(d=>{d&&st(s,e,t,n,o,a)})),a.push(e.moderation.listen(d=>{d.data&&st(s,e,t,n,o,a)})),a.push(t.featureSettings.listen(d=>{d&&st(s,e,t,n,o,a)}))),{$store:s,submitInplay:async()=>{const d=e.slStreamId.get();if(d){await Fi(r,d),s.set(x.Completed),o.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:d},x.Completed),pe.emit("poll",{action:"onboardingPassed",payload:{}});const c=e.getCurrentSessionId({prefix:"onboarding"});n.close(c)}}}},Ji=(t,e,r,n)=>{const i=ie(void 0),o=vi(n),s=async()=>{const u=t.get(),d=e.get(),c=r.getStore().get().data?.map(m=>m.slId)||[],f={eventId:u,userId:d,usersIds:[...c,d]},y=await o(f);i.set(y.data?.attributes)},a=()=>{s()};return X.onMount(i,()=>{const u=t.listen(s),d=r.listen(s),c=e.listen(s);return()=>{u(),d(),c()}}),{$store:i,invalidate:a}},Yi=new Set([_.QuestionType.POLL,_.QuestionType.PREDICTION,_.QuestionType.TRIVIA]);class Xi extends Yr{userSummary;feedList;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;notifications;transport;background;storage;submitAnswerTimeout;constructor(e,r,n){super(e,r),this.background=new Oi(n),this.feedSubscription=this.background.feedSubscription,this.activeQuestionId=this.background.activeQuestionId,this.openedQuestionId=this.background.openedQuestionId,this.storage=new Xr,this.feedList=this.background.feedList,this.friends=new oe(bi(this.background.userId,n.transport),"gamification:friends"),this.currentUserId=this.background.userId,this.openedUser=Q(void 0),this.leaderboardId=new z(Q(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=Wi(this,this.background,n.transport,n.notifications),this.notifications=n.notifications,this.transport=n.transport,this.closeFeature=()=>n.sdk.closeFeature(!0),this.openFeature=()=>n.sdk.openFeature(R.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=zi(this.transport,this.background.slStreamId,n.stores.providerStreamId.getStore(),this.background.userId),this.userSummary=Ji(this.background.slStreamId,this.background.userId,this.friends,this.transport),this.leaderboardList=Di(this.transport,this.background.slStreamId,this.background.userId,this.friends),this.connect(),this.userSummary.$store.listen(i=>{this.leaderboardList.$store.lc!==0&&i?.summary&&this.leaderboardList.invalidate()}),this.background.activeQuestionId.listen(this.showInApp),this.onboardingStatus.$store.listen(this.checkInteractiveFlag),this.background.moderation.getStore().listen(this.checkInteractiveFlag),this.settings.subscribe(this.checkInteractiveFlag)}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===Ee.ALLOWED}checkInteractiveFlag=()=>{const e=this.onboardingStatus.$store.get(),r=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,n=this.settings.getValues().inplayGame?.titleCard?.optIn,i=e===x.Completed,o=!r||i||n!==!0;this.background.interactiveAllowed.set(o?Ee.ALLOWED:Ee.DISALLOWED)};connect=()=>{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===_.QuestionStatus.RESOLVED&&o===_.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),d=[...this.feedList.getValues().data||[]],c=d.findIndex(G=>G.id===s),f=d[c];let y=f?.attributes?.attributes?.value?.answerId;const m=Gt(s,this.transport),b=m.subscribe(()=>{});await m.get().promise;const O=m.get().data;b(),window.requestAnimationFrame(()=>{m.invalidate()}),y||(y=O?.answers.find(({youVoted:G})=>G)?.id);const I=a.find(({correct:G})=>G),D=y?a.find(({id:G})=>G===y):void 0,j=!!D?.correct;if(f&&d[c]?.attributes?.attributes.case==="question"){try{d[c].attributes.attributes.value.answerId=y,d[c].attributes.attributes.value.openForVoting=!1,y&&(d[c].attributes.attributes.value.status=j?nt.PickHistoryStatus.WON:nt.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(d)}if(!D||!I)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:j?15e3:12e3,id:u,emitEvent:!1,data:{questionId:s,questionType:_.QuestionType.PREDICTION,question:{title:j?`Congratulations! You answered correctly! You won ${I.points} pts!`:`Better luck next time! Correct: ${I?.text}!`,votedAnswer:{title:D?.text,points:D?.points},correctAnswerTitle:I?.text,correct:!!j,predictionResult:i===_.QuestionStatus.RESOLVED,questionTitle:r?.subject}}}),this.userSummary.invalidate()}}),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){if(i!==-1)if(n.attributes?.attributes.case==="question"&&r[i].attributes?.attributes.case==="question"){const o=r[i];o.attributes&&(r[i]={...r[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...n.attributes.attributes.value,answerId:o.attributes.attributes.value.answerId,status:o.attributes.attributes.value.status,openForVoting:o.attributes.attributes.value.openForVoting}}}})}else{const o=r[i];o.attributes&&n.attributes&&(r[i]={...r[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...n.attributes.attributes.value}}}})}i===-1&&(r.unshift(n),pe.emit("poll",{action:"received",payload:{questionId:n.id,questionType:n.attributes?.type}})),this.feedList.getStore().mutate(r)}})};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-prediction-close"),this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitAnswer=async(e,r)=>{const n=Gt(e,this.transport),i=()=>{const o=this.feedList.getValues().data;if(!o)return;const s=o.findIndex(d=>d.id===e),a=o[s],u=a?.attributes?.attributes.case==="question"&&a.attributes.attributes.value;if(u){pe.emit("poll",{action:"voted",payload:{questionId:e,questionType:u.questionType}});const d=n.subscribe(()=>{}),c=n.get().data;if(d(),c){const f=c.answers.find(b=>b.correct===!0),y=c.answers.findIndex(b=>b.id===r),m=c.answers[y];o[s].attributes.attributes.value.answerId=r,o[s].attributes.attributes.value.openForVoting=!1,o[s].attributes.attributes.value.text=m?.text||"",f&&(o[s].attributes.attributes.value.status=f.id===r?nt.PickHistoryStatus.WON:nt.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...o]),c.answers[y].correct=f?.id===r,c.answers[y].youVoted=!0,c.answers.forEach(b=>{b.percentageDecimal=0}),f?.id===r&&(c.answers[y].pointsEarned=c.status===_.QuestionStatus.RESOLVED?0:f.points),n.mutate({...c})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await Pi(this.transport,{questionId:e,answerId:r}),i()}catch(o){if(o.message===Ye.ALREADY_VOTED){this.userSummary.invalidate();const s=n.subscribe(()=>{});n.invalidate(),s()}throw o}};openQuestion=(e,r)=>{this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}));let n=r?.attributes?.type;return n||(n=(this.feedList.getStore().value?.data||[]).find(o=>o.id===e)?.attributes?.type),pe.emit("poll",{action:"opened",payload:{questionId:e,questionType:n,questionOpenedFrom:r?.openedFrom}}),this.background.openQuestion(e,r)};closeQuestion=e=>this.background.closeQuestion(e);openUser=e=>{const r=this.leaderboardList.$store.get().data?.find(n=>n.userId===e);this.openedUser.set(r)};closeUser=()=>{this.openedUser.set(void 0)};showInApp=e=>{const r=this.onboardingStatus.$store.get();if(e&&e.data&&r&&r!==x.Unset&&e.data.question?.id!==void 0&&e.data.question.notification!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==_.SilenceSetting.ON&&e.data.question.status===_.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(Yi.has(e.data.question.type))this.isInteractiveAllowed&&this.notifications.add({type:ge.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id,e.data.feedItem),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*60,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),emitEvent:!0,data:{questionId:e.data.question.id,questionType:e.data.question.type,question:{title:e.data.question.notification.title}}});else if(e.data.question.type===_.QuestionType.FACTOID){const n=e.data.question.options?.options.value,i={heading:e.data.question.notification.title,body:e.data.question.notification.body,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:()=>e.data?.question&&this.openQuestion(e.data.question.id,e.data.feedItem),close:()=>e.data?.question&&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:i}})}else if(e.data.question.type===_.QuestionType.TWEET){const n=e.data.question.options?.options.value,i={title:e.data.question.notification?.title,body:e.data.question.notification?.body,image:e.data.question.notification?.image,account:n?.tweetMeta?.account||"",accountVerified:!!n?.tweetMeta?.accountVerified,tweet:n?.tweetMeta?.tweet,tweetId:e.data.question.id};this.notifications.add({type:ge.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id,e.data.feedItem),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*120,emitEvent:!0,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionId:e.data.question.id,questionType:e.data.question.type,tweet:i}})}}}}const Zi={[R.SdkOverlayType.GAMES]:!0};class eo extends Yr{constructor(e,r){super(e,r)}}const to=(t,e,r)=>t.type===R.SdkOverlayType.GAMES?new Xi(t,e,r):new eo(t,e),ro=(t,e,r)=>{t.features=new Map,t.sdk.featuresList=new z(Q(new Set),"features-list"),t.activeFeature=new z(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.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=ce.ORGANIZATION)=>{if(n.type in Zi&&!t.features.has(n.type)){const o=to(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,ce.ORGANIZATION)},t.stores.providerStreamId.listen(n=>{n||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const n=(o,s)=>{if(s?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&o===ce.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(ce.ORGANIZATION,o.data)}catch(s){console.log(s)}},streamSettings:o=>{if(o.data)try{n(ce.STREAM,o.data)}catch(s){console.log(s)}}};t.store.subscribe(i)},r()};class no{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 pe.listen(r)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_ACCEPTED},category:it.InvitationCategory.GAMES,from:it.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_SENT},category:it.InvitationCategory.GAMES,from:e||it.InvitationFrom.UNSET})}}class io{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 pe.listen(r)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:mr.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:mr.InteractionActionType.SCROLL})}}const He={[_.QuestionType.UNSET]:v.TopicType.UNSET,[_.QuestionType.FACTOID]:v.TopicType.POLLS_INSIGHT,[_.QuestionType.POLL]:v.TopicType.POLLS_POLL,[_.QuestionType.PREDICTION]:v.TopicType.POLLS_PREDICTION,[_.QuestionType.PROMOTION]:v.TopicType.POLLS_PROMOTION,[_.QuestionType.TRIVIA]:v.TopicType.POLLS_TRIVIA,[_.QuestionType.TWEET]:v.TopicType.POLLS_TWITTER};_.QuestionType.UNSET+"",Y.NotificationKind.UNSET,_.QuestionType.FACTOID+"",Y.NotificationKind.POLLS,_.QuestionType.POLL+"",Y.NotificationKind.POLLS,_.QuestionType.PREDICTION+"",Y.NotificationKind.POLLS,_.QuestionType.PROMOTION+"",Y.NotificationKind.POLLS,_.QuestionType.TRIVIA+"",Y.NotificationKind.POLLS,_.QuestionType.TWEET+"",Y.NotificationKind.POLLS;const oo={[R.SdkOverlayType.UNSET]:v.Category.UNSET,[R.SdkOverlayType.INPLAY]:v.Category.INPLAY,[R.SdkOverlayType.MESSAGING]:v.Category.MESSAGING,[R.SdkOverlayType.STATISTICS]:v.Category.STATS,[R.SdkOverlayType.BETTING]:v.Category.BETTING,[R.SdkOverlayType.TWITTER]:v.Category.TWITTER,[R.SdkOverlayType.MERCHANDISE]:v.Category.MERCHANDISE,[R.SdkOverlayType.CONTESTS]:v.Category.CONTESTS,[R.SdkOverlayType.VOICE_CHAT]:v.Category.CALLING,[R.SdkOverlayType.TICKETS]:v.Category.TICKETS,[R.SdkOverlayType.WHOIS_WATCHING]:v.Category.WHOISWATCHING,[R.SdkOverlayType.PROFILE]:v.Category.PROFILE,[R.SdkOverlayType.GAMES]:v.Category.POLLS,[R.SdkOverlayType.GOLF_STATISTICS]:v.Category.STATS,[R.SdkOverlayType.HIGHLIGHTS]:v.Category.HIGHLIGHTS,[R.SdkOverlayType.PUBLIC_CHAT]:v.Category.PUBLIC_CHAT};class so{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}};return pe.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},notificationKind:Y.NotificationKind.POLLS,notificationType:Y.NotificationType.IN_APP})};opened=({questionId:e,questionType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_OPENED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},notificationKind:Y.NotificationKind.POLLS,notificationType:Y.NotificationType.IN_APP})}}class ao{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 pe.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_RECEIVED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};opened=({questionId:e,questionType:r,questionOpenedFrom:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_OPENED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},pollOpenedFrom:n==="list"?v.PollOpenedFrom.PICK_HISTORY:v.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_VOTE,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.GAMES_JOINED},pollOpenedFrom:v.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_NAVIGATED},pollOpenedFrom:v.PollOpenedFrom.UNSET})}}const uo=({transport:t,$commonStore:e})=>{let r;const n=Q(!1),i=5e3,{client:o,queryKey:s}=t.createPromiseClient(Kr.AnalyticsService,{method:"send",params:[n]}),a=t.nanoquery.createFetcherStore(s,{fetcher:async()=>{const y=e.getStore().get();try{await o.unary({message:{case:"heartbeat",value:{common:{...y,kind:v.Kind.SESSION_HEARTBEAT}}}})}catch(m){de.error(m,"send heartbeat failed")}return Date.now()},refetchInterval:i}),u=()=>{de.debug("mounted heartbeat"),r=a.subscribe(()=>{})},d=()=>{de.debug("enabled heartbeat"),n.set(!0),a.lc===0&&u()},c=()=>{de.debug("disabled heartbeat"),n.set(!1)};return{enable:d,disable:c,mount:u,unmount:()=>{de.debug("unmounted heartbeat"),a.off(),r?.(),r=void 0,c()}}},de=ve("analytics");class co{commonStore;notifications;polls;invitation;interactions;heartbeat;analyticsClient;listeners;listenersCancels;connected=!1;constructor(e){this.listeners=new Set,this.listenersCancels=new Set,this.commonStore=new Te(ie({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=uo({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new so(this),this.polls=new ao(this),this.invitation=new no(this),this.interactions=new io(this);const{client:r}=e.analyticsTransport.createPromiseClient(Kr.AnalyticsService,{method:"send"});this.analyticsClient=r}connect=()=>{this.writeCommon("sessionId",Mt.nanoid()),this.heartbeat.enable(),this.listeners.forEach(e=>this.listenersCancels.add(e())),this.connected=!0,de.debug("analytics connected")};disconnect=()=>{this.writeCommon("sessionId",""),this.writeCommon("overlaySessionId",""),this.heartbeat.unmount(),this.listenersCancels.forEach(e=>e()),this.connected=!1,de.debug("analytics disconnected")};write=(e,r)=>{r&&this.analyticsClient.unary({message:{case:e,value:r}}).then(()=>{de.trace("send analytics success",e,r)}).catch(n=>{de.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",oo[r]),r!==R.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",Mt.nanoid()):this.writeCommon("overlaySessionId","")})),this.onConnect(()=>{const r=window.matchMedia("(orientation: portrait)"),n=i=>{this.writeCommon("screenOrientation",i.matches?v.ScreenOrientation.PORTRAIT:v.ScreenOrientation.LANDSCAPE)};return r.addEventListener("change",n),()=>{r.removeEventListener("change",n)}}),this.onConnect(()=>e.deepLink.$store.subscribe(r=>{r?.handled&&this.invitation.accepted()}))}}const lo=(t,e,r)=>{t.analytics=new co(t),t.sdk.onMount(()=>(t.analytics.connect(),()=>{t.analytics.disconnect()})),r()};var tn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var nr={exports:{}},ir={exports:{}};function po(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 ho=po,yo=ho;function rn(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),r<1)throw new Error("fastqueue concurrency must be greater than 1");var n=yo(go),i=null,o=null,s=0,a=null,u={push:O,drain:H,saturated:H,pause:c,paused:!1,concurrency:r,running:d,resume:m,idle:b,length:f,getQueue:y,unshift:I,empty:H,kill:j,killAndDrain:G,error:W};return u;function d(){return s}function c(){u.paused=!0}function f(){for(var P=i,V=0;P;)P=P.next,V++;return V}function y(){for(var P=i,V=[];P;)V.push(P.value),P=P.next;return V}function m(){if(u.paused){u.paused=!1;for(var P=0;P<u.concurrency;P++)s++,D()}}function b(){return s===0&&u.length()===0}function O(P,V){var E=n.get();E.context=t,E.release=D,E.value=P,E.callback=V||H,E.errorHandler=a,s===u.concurrency||u.paused?o?(o.next=E,o=E):(i=E,o=E,u.saturated()):(s++,e.call(t,E.value,E.worked))}function I(P,V){var E=n.get();E.context=t,E.release=D,E.value=P,E.callback=V||H,E.errorHandler=a,s===u.concurrency||u.paused?i?(E.next=i,i=E):(i=E,o=E,u.saturated()):(s++,e.call(t,E.value,E.worked))}function D(P){P&&n.release(P);var V=i;V?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 j(){i=null,o=null,u.drain=H}function G(){i=null,o=null,u.drain(),u.drain=H}function W(P){a=P}}function H(){}function go(){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 mo(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function n(c,f){e.call(this,c).then(function(y){f(null,y)},f)}var i=rn(t,n,r),o=i.push,s=i.unshift;return i.push=a,i.unshift=u,i.drained=d,i;function a(c){var f=new Promise(function(y,m){o(c,function(b,O){if(b){m(b);return}y(O)})});return f.catch(H),f}function u(c){var f=new Promise(function(y,m){s(c,function(b,O){if(b){m(b);return}y(O)})});return f.catch(H),f}function d(){if(i.idle())return new Promise(function(y){y()});var c=i.drain,f=new Promise(function(y){i.drain=function(){c(),y()}});return f}}ir.exports=rn;ir.exports.promise=mo;var nn=ir.exports,or={exports:{}},qe=typeof Reflect=="object"?Reflect:null,Ir=qe&&typeof qe.apply=="function"?qe.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},ut;qe&&typeof qe.ownKeys=="function"?ut=qe.ownKeys:Object.getOwnPropertySymbols?ut=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ut=function(e){return Object.getOwnPropertyNames(e)};function vo(t){console&&console.warn&&console.warn(t)}var on=Number.isNaN||function(e){return e!==e};function F(){F.init.call(this)}or.exports=F;or.exports.once=Ao;F.EventEmitter=F;F.prototype._events=void 0;F.prototype._eventsCount=0;F.prototype._maxListeners=void 0;var Or=10;function At(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 Or},set:function(t){if(typeof t!="number"||t<0||on(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Or=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||on(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 sn(t){return t._maxListeners===void 0?F.defaultMaxListeners:t._maxListeners}F.prototype.getMaxListeners=function(){return sn(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")Ir(u,this,r);else for(var d=u.length,c=dn(u,d),n=0;n<d;++n)Ir(c[n],this,r);return!0};function an(t,e,r,n){var i,o,s;if(At(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=sn(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,vo(a)}return t}F.prototype.addListener=function(e,r){return an(this,e,r,!1)};F.prototype.on=F.prototype.addListener;F.prototype.prependListener=function(e,r){return an(this,e,r,!0)};function bo(){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 un(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=bo.bind(n);return i.listener=r,n.wrapFn=i,i}F.prototype.once=function(e,r){return At(r),this.on(e,un(this,e,r)),this};F.prototype.prependOnceListener=function(e,r){return At(r),this.prependListener(e,un(this,e,r)),this};F.prototype.removeListener=function(e,r){var n,i,o,s,a;if(At(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():So(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 cn(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?wo(i):dn(i,i.length)}F.prototype.listeners=function(e){return cn(this,e,!0)};F.prototype.rawListeners=function(e){return cn(this,e,!1)};F.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):ln.call(t,e)};F.prototype.listenerCount=ln;function ln(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?ut(this._events):[]};function dn(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function So(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function wo(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Ao(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))}fn(t,e,o,{once:!0}),e!=="error"&&To(t,i,{once:!0})})}function To(t,e,r){typeof t.on=="function"&&fn(t,"error",e,r)}function fn(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 pn=or.exports,Tt={},hn={},yn=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},Eo=yn,sr=function(){return Eo()&&!!Symbol.toStringTag},Cr=typeof Symbol<"u"&&Symbol,Io=yn,Oo=function(){return typeof Cr!="function"||typeof Symbol!="function"||typeof Cr("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Io()},_r={foo:{}},Co=Object,_o=function(){return{__proto__:_r}.foo===_r.foo&&!({__proto__:null}instanceof Co)},ko="Function.prototype.bind called on incompatible ",Lo=Object.prototype.toString,Po=Math.max,Fo="[object Function]",kr=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},No=function(e,r){for(var n=[],i=r||0,o=0;i<e.length;i+=1,o+=1)n[o]=e[i];return n},Do=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r},Ro=function(e){var r=this;if(typeof r!="function"||Lo.apply(r)!==Fo)throw new TypeError(ko+r);for(var n=No(arguments,1),i,o=function(){if(this instanceof i){var c=r.apply(this,kr(n,arguments));return Object(c)===c?c:this}return r.apply(e,kr(n,arguments))},s=Po(0,r.length-n.length),a=[],u=0;u<s;u++)a[u]="$"+u;if(i=Function("binder","return function ("+Do(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},Vo=Ro,ar=Function.prototype.bind||Vo,$o=Function.prototype.call,jo=Object.prototype.hasOwnProperty,qo=ar,Uo=qo.call($o,jo),T,Me=SyntaxError,gn=Function,Ue=TypeError,Ct=function(t){try{return gn('"use strict"; return ('+t+").constructor;")()}catch{}},Ie=Object.getOwnPropertyDescriptor;if(Ie)try{Ie({},"")}catch{Ie=null}var _t=function(){throw new Ue},Mo=Ie?function(){try{return arguments.callee,_t}catch{try{return Ie(arguments,"callee").get}catch{return _t}}}():_t,Fe=Oo(),xo=_o(),U=Object.getPrototypeOf||(xo?function(t){return t.__proto__}:null),De={},Bo=typeof Uint8Array>"u"||!U?T:U(Uint8Array),Oe={"%AggregateError%":typeof AggregateError>"u"?T:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?T:ArrayBuffer,"%ArrayIteratorPrototype%":Fe&&U?U([][Symbol.iterator]()):T,"%AsyncFromSyncIteratorPrototype%":T,"%AsyncFunction%":De,"%AsyncGenerator%":De,"%AsyncGeneratorFunction%":De,"%AsyncIteratorPrototype%":De,"%Atomics%":typeof Atomics>"u"?T:Atomics,"%BigInt%":typeof BigInt>"u"?T:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?T:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?T:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?T:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?T:Float32Array,"%Float64Array%":typeof Float64Array>"u"?T:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?T:FinalizationRegistry,"%Function%":gn,"%GeneratorFunction%":De,"%Int8Array%":typeof Int8Array>"u"?T:Int8Array,"%Int16Array%":typeof Int16Array>"u"?T:Int16Array,"%Int32Array%":typeof Int32Array>"u"?T:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Fe&&U?U(U([][Symbol.iterator]())):T,"%JSON%":typeof JSON=="object"?JSON:T,"%Map%":typeof Map>"u"?T:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Fe||!U?T:U(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?T:Promise,"%Proxy%":typeof Proxy>"u"?T:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?T:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?T:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Fe||!U?T:U(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?T:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Fe&&U?U(""[Symbol.iterator]()):T,"%Symbol%":Fe?Symbol:T,"%SyntaxError%":Me,"%ThrowTypeError%":Mo,"%TypedArray%":Bo,"%TypeError%":Ue,"%Uint8Array%":typeof Uint8Array>"u"?T:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?T:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?T:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?T:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?T:WeakMap,"%WeakRef%":typeof WeakRef>"u"?T:WeakRef,"%WeakSet%":typeof WeakSet>"u"?T:WeakSet};if(U)try{null.error}catch(t){var Qo=U(U(t));Oe["%Error.prototype%"]=Qo}var Go=function t(e){var r;if(e==="%AsyncFunction%")r=Ct("async function () {}");else if(e==="%GeneratorFunction%")r=Ct("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Ct("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&U&&(r=U(i.prototype))}return Oe[e]=r,r},Lr={"%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=ar,ht=Uo,Ko=Ze.call(Function.call,Array.prototype.concat),zo=Ze.call(Function.apply,Array.prototype.splice),Pr=Ze.call(Function.call,String.prototype.replace),yt=Ze.call(Function.call,String.prototype.slice),Ho=Ze.call(Function.call,RegExp.prototype.exec),Wo=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Jo=/\\(\\)?/g,Yo=function(e){var r=yt(e,0,1),n=yt(e,-1);if(r==="%"&&n!=="%")throw new Me("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Me("invalid intrinsic syntax, expected opening `%`");var i=[];return Pr(e,Wo,function(o,s,a,u){i[i.length]=a?Pr(u,Jo,"$1"):s||o}),i},Xo=function(e,r){var n=e,i;if(ht(Lr,n)&&(i=Lr[n],n="%"+i[0]+"%"),ht(Oe,n)){var o=Oe[n];if(o===De&&(o=Go(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 Me("intrinsic "+e+" does not exist!")},Be=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(Ho(/^%?[^%]*%?$/,e)===null)throw new Me("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Yo(e),i=n.length>0?n[0]:"",o=Xo("%"+i+"%",r),s=o.name,a=o.value,u=!1,d=o.alias;d&&(i=d[0],zo(n,Ko([0,1],d)));for(var c=1,f=!0;c<n.length;c+=1){var y=n[c],m=yt(y,0,1),b=yt(y,-1);if((m==='"'||m==="'"||m==="`"||b==='"'||b==="'"||b==="`")&&m!==b)throw new Me("property names with quotes must have matching quotes");if((y==="constructor"||!f)&&(u=!0),i+="."+y,s="%"+i+"%",ht(Oe,s))a=Oe[s];else if(a!=null){if(!(y in a)){if(!r)throw new Ue("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ie&&c+1>=n.length){var O=Ie(a,y);f=!!O,f&&"get"in O&&!("originalValue"in O.get)?a=O.get:a=a[y]}else f=ht(a,y),a=a[y];f&&!u&&(Oe[s]=a)}}return a},mn={exports:{}},Zo=Be,Kt=Zo("%Object.defineProperty%",!0),zt=function(){if(Kt)try{return Kt({},"a",{value:1}),!0}catch{return!1}return!1};zt.hasArrayLengthDefineBug=function(){if(!zt())return null;try{return Kt([],"length",{value:1}).length!==1}catch{return!0}};var vn=zt,es=Be,ct=es("%Object.getOwnPropertyDescriptor%",!0);if(ct)try{ct([],"length")}catch{ct=null}var ur=ct,ts=vn(),cr=Be,We=ts&&cr("%Object.defineProperty%",!0);if(We)try{We({},"a",{value:1})}catch{We=!1}var rs=cr("%SyntaxError%"),Ne=cr("%TypeError%"),Fr=ur,ns=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Ne("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Ne("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Ne("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Ne("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Ne("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Ne("`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=!!Fr&&Fr(e,r);if(We)We(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 rs("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},bn=Be,Nr=ns,is=vn(),Dr=ur,Rr=bn("%TypeError%"),os=bn("%Math.floor%"),ss=function(e,r){if(typeof e!="function")throw new Rr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||os(r)!==r)throw new Rr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in e&&Dr){var s=Dr(e,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(is?Nr(e,"length",r,!0,!0):Nr(e,"length",r)),e};(function(t){var e=ar,r=Be,n=ss,i=r("%TypeError%"),o=r("%Function.prototype.apply%"),s=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(s,o),u=r("%Object.defineProperty%",!0),d=r("%Math.max%");if(u)try{u({},"a",{value:1})}catch{u=null}t.exports=function(y){if(typeof y!="function")throw new i("a function is required");var m=a(e,s,arguments);return n(m,1+d(0,y.length-(arguments.length-1)),!0)};var c=function(){return a(e,o,arguments)};u?u(t.exports,"apply",{value:c}):t.exports.apply=c})(mn);var Sn=mn.exports,wn=Be,An=Sn,as=An(wn("String.prototype.indexOf")),Tn=function(e,r){var n=wn(e,!!r);return typeof n=="function"&&as(e,".prototype.")>-1?An(n):n},us=sr(),cs=Tn,Ht=cs("Object.prototype.toString"),Et=function(e){return us&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:Ht(e)==="[object Arguments]"},En=function(e){return Et(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Ht(e)!=="[object Array]"&&Ht(e.callee)==="[object Function]"},ls=function(){return Et(arguments)}();Et.isLegacyArguments=En;var ds=ls?Et:En,fs=Object.prototype.toString,ps=Function.prototype.toString,hs=/^\s*(?:function)?\*/,In=sr(),kt=Object.getPrototypeOf,ys=function(){if(!In)return!1;try{return Function("return function*() {}")()}catch{}},Lt,gs=function(e){if(typeof e!="function")return!1;if(hs.test(ps.call(e)))return!0;if(!In){var r=fs.call(e);return r==="[object GeneratorFunction]"}if(!kt)return!1;if(typeof Lt>"u"){var n=ys();Lt=n?kt(n):!1}return kt(e)===Lt},On=Function.prototype.toString,$e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Wt,lt;if(typeof $e=="function"&&typeof Object.defineProperty=="function")try{Wt=Object.defineProperty({},"length",{get:function(){throw lt}}),lt={},$e(function(){throw 42},null,Wt)}catch(t){t!==lt&&($e=null)}else $e=null;var ms=/^\s*class\b/,Jt=function(e){try{var r=On.call(e);return ms.test(r)}catch{return!1}},Pt=function(e){try{return Jt(e)?!1:(On.call(e),!0)}catch{return!1}},dt=Object.prototype.toString,vs="[object Object]",bs="[object Function]",Ss="[object GeneratorFunction]",ws="[object HTMLAllCollection]",As="[object HTML document.all class]",Ts="[object HTMLCollection]",Es=typeof Symbol=="function"&&!!Symbol.toStringTag,Is=!(0 in[,]),Yt=function(){return!1};if(typeof document=="object"){var Os=document.all;dt.call(Os)===dt.call(document.all)&&(Yt=function(e){if((Is||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=dt.call(e);return(r===ws||r===As||r===Ts||r===vs)&&e("")==null}catch{}return!1})}var Cs=$e?function(e){if(Yt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{$e(e,null,Wt)}catch(r){if(r!==lt)return!1}return!Jt(e)&&Pt(e)}:function(e){if(Yt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Es)return Pt(e);if(Jt(e))return!1;var r=dt.call(e);return r!==bs&&r!==Ss&&!/^\[object HTML/.test(r)?!1:Pt(e)},_s=Cs,ks=Object.prototype.toString,Cn=Object.prototype.hasOwnProperty,Ls=function(e,r,n){for(var i=0,o=e.length;i<o;i++)Cn.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Ps=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)},Fs=function(e,r,n){for(var i in e)Cn.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Ns=function(e,r,n){if(!_s(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),ks.call(e)==="[object Array]"?Ls(e,r,i):typeof e=="string"?Ps(e,r,i):Fs(e,r,i)},Ds=Ns,Ft=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],Rs=typeof globalThis>"u"?tn:globalThis,Vs=function(){for(var e=[],r=0;r<Ft.length;r++)typeof Rs[Ft[r]]=="function"&&(e[e.length]=Ft[r]);return e},gt=Ds,$s=Vs,Vr=Sn,lr=Tn,ft=ur,js=lr("Object.prototype.toString"),_n=sr(),$r=typeof globalThis>"u"?tn:globalThis,Xt=$s(),dr=lr("String.prototype.slice"),Nt=Object.getPrototypeOf,qs=lr("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},mt={__proto__:null};_n&&ft&&Nt?gt(Xt,function(t){var e=new $r[t];if(Symbol.toStringTag in e){var r=Nt(e),n=ft(r,Symbol.toStringTag);if(!n){var i=Nt(r);n=ft(i,Symbol.toStringTag)}mt["$"+t]=Vr(n.get)}}):gt(Xt,function(t){var e=new $r[t],r=e.slice||e.set;r&&(mt["$"+t]=Vr(r))});var Us=function(e){var r=!1;return gt(mt,function(n,i){if(!r)try{"$"+n(e)===i&&(r=dr(i,1))}catch{}}),r},Ms=function(e){var r=!1;return gt(mt,function(n,i){if(!r)try{n(e),r=dr(i,1)}catch{}}),r},kn=function(e){if(!e||typeof e!="object")return!1;if(!_n){var r=dr(js(e),8,-1);return qs(Xt,r)>-1?r:r!=="Object"?!1:Ms(e)}return ft?Us(e):null},xs=kn,Bs=function(e){return!!xs(e)};(function(t){var e=ds,r=gs,n=kn,i=Bs;function o(h){return h.call.bind(h)}var s=typeof BigInt<"u",a=typeof Symbol<"u",u=o(Object.prototype.toString),d=o(Number.prototype.valueOf),c=o(String.prototype.valueOf),f=o(Boolean.prototype.valueOf);if(s)var y=o(BigInt.prototype.valueOf);if(a)var m=o(Symbol.prototype.valueOf);function b(h,Vn){if(typeof h!="object")return!1;try{return Vn(h),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=i;function O(h){return typeof Promise<"u"&&h instanceof Promise||h!==null&&typeof h=="object"&&typeof h.then=="function"&&typeof h.catch=="function"}t.isPromise=O;function I(h){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(h):i(h)||p(h)}t.isArrayBufferView=I;function D(h){return n(h)==="Uint8Array"}t.isUint8Array=D;function j(h){return n(h)==="Uint8ClampedArray"}t.isUint8ClampedArray=j;function G(h){return n(h)==="Uint16Array"}t.isUint16Array=G;function W(h){return n(h)==="Uint32Array"}t.isUint32Array=W;function P(h){return n(h)==="Int8Array"}t.isInt8Array=P;function V(h){return n(h)==="Int16Array"}t.isInt16Array=V;function E(h){return n(h)==="Int32Array"}t.isInt32Array=E;function Z(h){return n(h)==="Float32Array"}t.isFloat32Array=Z;function ee(h){return n(h)==="Float64Array"}t.isFloat64Array=ee;function Ce(h){return n(h)==="BigInt64Array"}t.isBigInt64Array=Ce;function be(h){return n(h)==="BigUint64Array"}t.isBigUint64Array=be;function se(h){return u(h)==="[object Map]"}se.working=typeof Map<"u"&&se(new Map);function It(h){return typeof Map>"u"?!1:se.working?se(h):h instanceof Map}t.isMap=It;function ye(h){return u(h)==="[object Set]"}ye.working=typeof Set<"u"&&ye(new Set);function Ge(h){return typeof Set>"u"?!1:ye.working?ye(h):h instanceof Set}t.isSet=Ge;function _e(h){return u(h)==="[object WeakMap]"}_e.working=typeof WeakMap<"u"&&_e(new WeakMap);function Ot(h){return typeof WeakMap>"u"?!1:_e.working?_e(h):h instanceof WeakMap}t.isWeakMap=Ot;function ke(h){return u(h)==="[object WeakSet]"}ke.working=typeof WeakSet<"u"&&ke(new WeakSet);function ae(h){return ke(h)}t.isWeakSet=ae;function Le(h){return u(h)==="[object ArrayBuffer]"}Le.working=typeof ArrayBuffer<"u"&&Le(new ArrayBuffer);function et(h){return typeof ArrayBuffer>"u"?!1:Le.working?Le(h):h instanceof ArrayBuffer}t.isArrayBuffer=et;function l(h){return u(h)==="[object DataView]"}l.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&l(new DataView(new ArrayBuffer(1),0,1));function p(h){return typeof DataView>"u"?!1:l.working?l(h):h instanceof DataView}t.isDataView=p;var g=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function S(h){return u(h)==="[object SharedArrayBuffer]"}function k(h){return typeof g>"u"?!1:(typeof S.working>"u"&&(S.working=S(new g)),S.working?S(h):h instanceof g)}t.isSharedArrayBuffer=k;function L(h){return u(h)==="[object AsyncFunction]"}t.isAsyncFunction=L;function A(h){return u(h)==="[object Map Iterator]"}t.isMapIterator=A;function C(h){return u(h)==="[object Set Iterator]"}t.isSetIterator=C;function N(h){return u(h)==="[object Generator]"}t.isGeneratorObject=N;function K(h){return u(h)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=K;function Se(h){return b(h,d)}t.isNumberObject=Se;function tt(h){return b(h,c)}t.isStringObject=tt;function Pe(h){return b(h,f)}t.isBooleanObject=Pe;function rt(h){return s&&b(h,y)}t.isBigIntObject=rt;function hr(h){return a&&b(h,m)}t.isSymbolObject=hr;function Dn(h){return Se(h)||tt(h)||Pe(h)||rt(h)||hr(h)}t.isBoxedPrimitive=Dn;function Rn(h){return typeof Uint8Array<"u"&&(et(h)||k(h))}t.isAnyArrayBuffer=Rn,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(h){Object.defineProperty(t,h,{enumerable:!1,value:function(){throw new Error(h+" is not supported in userland")}})})})(hn);var Qs=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},Zt={exports:{}};typeof Object.create=="function"?Zt.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Zt.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 Gs=Zt.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(p){for(var g=Object.keys(p),S={},k=0;k<g.length;k++)S[g[k]]=Object.getOwnPropertyDescriptor(p,g[k]);return S},r=/%[sdj%]/g;t.format=function(l){if(!P(l)){for(var p=[],g=0;g<arguments.length;g++)p.push(s(arguments[g]));return p.join(" ")}for(var g=1,S=arguments,k=S.length,L=String(l).replace(r,function(C){if(C==="%%")return"%";if(g>=k)return C;switch(C){case"%s":return String(S[g++]);case"%d":return Number(S[g++]);case"%j":try{return JSON.stringify(S[g++])}catch{return"[Circular]"}default:return C}}),A=S[g];g<k;A=S[++g])j(A)||!ee(A)?L+=" "+A:L+=" "+s(A);return L},t.deprecate=function(l,p){if(typeof w<"u"&&w.noDeprecation===!0)return l;if(typeof w>"u")return function(){return t.deprecate(l,p).apply(this,arguments)};var g=!1;function S(){if(!g){if(w.throwDeprecation)throw new Error(p);w.traceDeprecation?console.trace(p):console.error(p),g=!0}return l.apply(this,arguments)}return S};var n={},i=/^$/;if(w.env.NODE_DEBUG){var o=w.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(l){if(l=l.toUpperCase(),!n[l])if(i.test(l)){var p=w.pid;n[l]=function(){var g=t.format.apply(t,arguments);console.error("%s %d: %s",l,p,g)}}else n[l]=function(){};return n[l]};function s(l,p){var g={seen:[],stylize:u};return arguments.length>=3&&(g.depth=arguments[2]),arguments.length>=4&&(g.colors=arguments[3]),D(p)?g.showHidden=p:p&&t._extend(g,p),E(g.showHidden)&&(g.showHidden=!1),E(g.depth)&&(g.depth=2),E(g.colors)&&(g.colors=!1),E(g.customInspect)&&(g.customInspect=!0),g.colors&&(g.stylize=a),c(g,l,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(l,p){var g=s.styles[p];return g?"\x1B["+s.colors[g][0]+"m"+l+"\x1B["+s.colors[g][1]+"m":l}function u(l,p){return l}function d(l){var p={};return l.forEach(function(g,S){p[g]=!0}),p}function c(l,p,g){if(l.customInspect&&p&&se(p.inspect)&&p.inspect!==t.inspect&&!(p.constructor&&p.constructor.prototype===p)){var S=p.inspect(g,l);return P(S)||(S=c(l,S,g)),S}var k=f(l,p);if(k)return k;var L=Object.keys(p),A=d(L);if(l.showHidden&&(L=Object.getOwnPropertyNames(p)),be(p)&&(L.indexOf("message")>=0||L.indexOf("description")>=0))return y(p);if(L.length===0){if(se(p)){var C=p.name?": "+p.name:"";return l.stylize("[Function"+C+"]","special")}if(Z(p))return l.stylize(RegExp.prototype.toString.call(p),"regexp");if(Ce(p))return l.stylize(Date.prototype.toString.call(p),"date");if(be(p))return y(p)}var N="",K=!1,Se=["{","}"];if(I(p)&&(K=!0,Se=["[","]"]),se(p)){var tt=p.name?": "+p.name:"";N=" [Function"+tt+"]"}if(Z(p)&&(N=" "+RegExp.prototype.toString.call(p)),Ce(p)&&(N=" "+Date.prototype.toUTCString.call(p)),be(p)&&(N=" "+y(p)),L.length===0&&(!K||p.length==0))return Se[0]+N+Se[1];if(g<0)return Z(p)?l.stylize(RegExp.prototype.toString.call(p),"regexp"):l.stylize("[Object]","special");l.seen.push(p);var Pe;return K?Pe=m(l,p,g,A,L):Pe=L.map(function(rt){return b(l,p,g,A,rt,K)}),l.seen.pop(),O(Pe,N,Se)}function f(l,p){if(E(p))return l.stylize("undefined","undefined");if(P(p)){var g="'"+JSON.stringify(p).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return l.stylize(g,"string")}if(W(p))return l.stylize(""+p,"number");if(D(p))return l.stylize(""+p,"boolean");if(j(p))return l.stylize("null","null")}function y(l){return"["+Error.prototype.toString.call(l)+"]"}function m(l,p,g,S,k){for(var L=[],A=0,C=p.length;A<C;++A)ke(p,String(A))?L.push(b(l,p,g,S,String(A),!0)):L.push("");return k.forEach(function(N){N.match(/^\d+$/)||L.push(b(l,p,g,S,N,!0))}),L}function b(l,p,g,S,k,L){var A,C,N;if(N=Object.getOwnPropertyDescriptor(p,k)||{value:p[k]},N.get?N.set?C=l.stylize("[Getter/Setter]","special"):C=l.stylize("[Getter]","special"):N.set&&(C=l.stylize("[Setter]","special")),ke(S,k)||(A="["+k+"]"),C||(l.seen.indexOf(N.value)<0?(j(g)?C=c(l,N.value,null):C=c(l,N.value,g-1),C.indexOf(`
3
- `)>-1&&(L?C=C.split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jn=require("pino"),I=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"),X=require("nanostores"),qt=require("nanoid"),M=require("@connectrpc/connect"),yr=require("@connectrpc/connect-web"),gr=require("@nanostores/query"),Mn=require("@streamlayer/sl-eslib/sports/events/events_connect"),Xe=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),rr=require("@streamlayer/sl-eslib/users/users_connect"),me=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),Gr=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect");require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb");const Un=require("@streamlayer/sl-eslib/shortLinks/linksClient_connect"),v=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),Kr=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_connect"),mr=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),Y=require("@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb");function qn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zr={exports:{}},j=zr.exports={},te,re;function xt(){throw new Error("setTimeout has not been defined")}function Bt(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?te=setTimeout:te=xt}catch{te=xt}try{typeof clearTimeout=="function"?re=clearTimeout:re=Bt}catch{re=Bt}})();function Hr(t){if(te===setTimeout)return setTimeout(t,0);if((te===xt||!te)&&setTimeout)return te=setTimeout,setTimeout(t,0);try{return te(t,0)}catch{try{return te.call(null,t,0)}catch{return te.call(this,t,0)}}}function xn(t){if(re===clearTimeout)return clearTimeout(t);if((re===Bt||!re)&&clearTimeout)return re=clearTimeout,clearTimeout(t);try{return re(t)}catch{try{return re.call(null,t)}catch{return re.call(this,t)}}}var de=[],je=!1,Te,at=-1;function Bn(){!je||!Te||(je=!1,Te.length?de=Te.concat(de):at=-1,de.length&&Wr())}function Wr(){if(!je){var t=Hr(Bn);je=!0;for(var e=de.length;e;){for(Te=de,de=[];++at<e;)Te&&Te[at].run();at=-1,e=de.length}Te=null,je=!1,xn(t)}}j.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];de.push(new Jr(t,e)),de.length===1&&!je&&Hr(Wr)};function Jr(t,e){this.fun=t,this.array=e}Jr.prototype.run=function(){this.fun.apply(null,this.array)};j.title="browser";j.browser=!0;j.env={};j.argv=[];j.version="";j.versions={};function he(){}j.on=he;j.addListener=he;j.once=he;j.off=he;j.removeListener=he;j.removeAllListeners=he;j.emit=he;j.prependListener=he;j.prependOnceListener=he;j.listeners=function(t){return[]};j.binding=function(t){throw new Error("process.binding is not supported")};j.cwd=function(){return"/"};j.chdir=function(t){throw new Error("process.chdir is not supported")};j.umask=function(){return 0};var Qn=zr.exports;const w=qn(Qn),Gn=jn.pino({level:"trace",enabled:!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),be=(t,e)=>Gn.child({name:t},e);class Kn extends Event{slEventBus;constructor(e,r){super(e),this.slEventBus=r}}const zn=be("event-bus");class Hn{name;listeners;constructor(e="sl-event-bus"){this.name=e,this.listeners=new Set}emit=(e,r)=>{const n=new Kn(this.name,{...r,type:e});zn.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 Wn{}window.slStore=Object.create(null);class vt{store;name;constructor(e,r){this.store=e,this.name=r}getStore(){return this.store}}const Jn=t=>{const e=Object.keys(t);return X.computed(e.map(r=>t[r].getStore()),(...r)=>Object.fromEntries(e.map((n,i)=>[n,r[i]])))};class Ae extends vt{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 ie=t=>X.map(t);var ue;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(ue||(ue={}));const Yn={[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 Yr{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},n){this.settingsKey=Yn[r.type],this.status=X.atom(ze.Suspended),this.config=new Ae(ie(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new Ae(ie(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new Ae(ie({}),`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===ue.STREAM&&r===ue.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 H extends vt{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=>X.atom(t);class pe extends vt{atomStore;constructor(e,r,n){super(e,`api:${r}`),this.atomStore=X.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 fe=new Hn;async function*Xn(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now();const n={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(n),yield r}}const Zn=()=>t=>async e=>{const r={name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries())},response:{}};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){r.request.message=e.message;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...r,stream:!1}};return window.postMessage(i),{...n,message:Xn(r,n.message)}}else{r.request.message=e.message,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.request.message=e.message,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"));var J;(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"})(J||(J={}));class ei{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,n,i){const o={status:J.Init,ts:new Date,log:[]};this.state=new Ae(ie(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 H(Q(null),`subscription:${i.name}:store`)),"subscribe"in n&&typeof n.subscribe=="function"&&(this.paramsListener=n.subscribe(s=>{this.state.getValue("status")===J.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(J.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}`;r.push(n),this.state.setValue("log",r),window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
2
+ `+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(J.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 M.ConnectError&&n.code!=M.Code.Canceled&&this.onStreamError(n)}})(),this.updateState(J.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(J.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(J.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(J.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 M.ConnectError&&e.code!==M.Code.Canceled){this.updateState(J.Failed),this.state.setValue("error",e),this.reconnect();return}this.disconnect()}}}const ti=new Set([M.Code.Unknown,M.Code.Internal,M.Code.DeadlineExceeded,M.Code.ResourceExhausted,M.Code.FailedPrecondition,M.Code.Unavailable,M.Code.DataLoss]),br=be("grpc:retry"),ri=t=>async e=>{const r=e.contextValues.get(Qt.retryAttempts),n=300,i=e.contextValues.get(Qt.retryDelay);if(e.stream||r===0)return t(e);br.trace({url:e.url,attempts:r,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){br.trace({attempt:o,error:s},"retry attempt");const a=M.ConnectError.from(s);if(o>=r||!(a instanceof M.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))}},Qt={retryAttempts:M.createContextKey(5,{description:"Number of attempts to retry"}),retryDelay:M.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},ni=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=qt.nanoid();return localStorage.setItem("sl-device-id",e),e},ii=()=>navigator.userAgentData?.platform||navigator.platform;class vr{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;$headers;interceptors=[];clients;streamClients;subscriptions;opts;constructor(e,r){this.host=e,this.opts=r,this.$headers=new Ae(ie({"sl-device-id":ni(),"sl-device-os":ii()}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.streamClients=new Map,this.subscriptions=new Map;const[n,i,o]=gr.nanoquery({dedupeTime:r?.dedupeTime,refetchInterval:r?.refetchInterval});this.nanoquery={createFetcherStore:n,createMutatorStore:i,utils:o},this.transport=yr.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors,useBinaryFormat:!0}),this.streamTransport=yr.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors,useBinaryFormat:!0})}addSubscription=(e,r,n)=>{const i=this.subscriptions.get(r);if(i)return i;const o=new ei(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]=gr.nanoquery({dedupeTime:1e3*60*5,refetchInterval:1e3*60*5});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=M.createPromiseClient(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=M.createPromiseClient(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=M.createContextValues();for(const f in d){const h=Qt[f];c.set(h,d[f])}return c},queryKey:s,queryKeyStr:a.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,r)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",r)};setHeader=(e,r)=>this.$headers.setValue(e,r);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=r=>n=>{const i=this.$headers.getValues();for(const o in i)n.header.set(o,i[o]);return r(n)};this.interceptors.push(e),this.interceptors.push(Zn()),this.opts?.retryable&&this.interceptors.push(ri)}}const oi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Mn.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""}}})},si=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.getStream({id:s})).data?.attributes:void 0})},ai=(t,e)=>{const{queryKey:r,client:n}=e.createPromiseClient(rr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:()=>n.me({})})},ui=t=>{const{client:e,createRequestOptions:r}=t.createPromiseClient(rr.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})},ci=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.get({})).data?.attributes})},li=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>{const i=await r.getOrganization({});return i.data?{...i.data.attributes,id:i.data.id}:void 0}})},di=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(Xe.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},fi=(t,e,r)=>{t.transport=new vr(e.host,{dedupeTime:1e3*60*5,refetchInterval:1e3*60*5,retryable:!0}),t.analyticsTransport=new vr(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(()=>()=>{t.transport.disconnect(),t.analyticsTransport.disconnect()}),r()};class St{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()||"";this.storage.setItem(this.generateKey(e),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 ae;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(ae||(ae={}));class Re extends St{constructor(){super("user")}setSchema=e=>{this.write(ae.SCHEMA,e)};getSchema=()=>this.read(ae.SCHEMA);setToken=e=>{this.write(ae.TOKEN,e)};getToken=()=>this.read(ae.TOKEN);setExternalToken=e=>{this.write(ae.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(ae.EXTERNAL_TOKEN);removeToken=()=>{this.remove(ae.TOKEN)}}var ce;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(ce||(ce={}));const pi=t=>{const e=new Re,r=new H(Q(e.getExternalToken()),"userKey"),n=new H(Q(e.getToken()),"userToken"),i=new pe(ai(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 pe(ci(n.getStore(),t),"userSettings");return{userKey:r,userToken:n,user:i,userSettings:o}},hi=t=>{const e=new H(Q(void 0),"providerStreamId"),r=new pe(oi(e.getStore(),t),"slStreamId",i=>i?.data),n=new pe(si(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(i=>{(i===""||i===void 0)&&n.getStore().mutate(void 0)}),{providerStreamId:e,slStreamId:r,streamSettings:n}},yi=t=>{const e=new H(Q(void 0),"enabled"),r=new H(Q(ce.DISABLED),"status"),n=new pe(li(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new pe(di(n.getAtomStore(),t),"organizationAdvertising"),o=pi(t),s=hi(t);return{enabled:e,status:r,providerStreamId:s.providerStreamId,slStreamId:s.slStreamId,streamSettings:s.streamSettings,user:o.user,userKey:o.userKey,userToken:o.userToken,userSettings:o.userSettings,organizationSettings:n,organizationAdvertising:i}};class gi extends vt{stores;constructor(e){const r=yi(e),n=Jn(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 gi(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.storeUnsubscribe=()=>{t.store.unsubscribe()},r()},bi=t=>{const{client:e}=t.createPromiseClient(Gr.Leaderboard,{method:"list"});return r=>e.list(r)},Xr=t=>{const{client:e}=t.createPromiseClient(Gr.Leaderboard,{method:"summary"});return r=>e.summary(r)},vi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(rr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.getFriends({})).data:[]})},Si=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(me.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.get({eventId:s})).data?.attributes,refetchInterval:0,dedupeTime:1e3*60*60})},wi=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(me.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>s?(await r.syncQuestion({filter:{eventId:s}})).data?.attributes:void 0,dedupeTime:1e3*60*10,refetchInterval:0})},Ti=(t,e)=>{const{client:r}=e.createStreamClient(me.Feed),n=X.atom({eventId:t.get()||"",feedId:""});return t.subscribe((o="")=>{n.set({eventId:o,feedId:""})}),e.addSubscription(r.subscription,n,{name:"feedSubscription"})},Ai=(t,e)=>{const{client:r}=e.createStreamClient(me.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},Gt=(t,e)=>{const{client:r,queryKey:n}=e.createPromiseClient(me.Feed,{method:"questionByUser",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s)=>(await r.questionByUser({questionId:s})).data?.attributes?.question,dedupeTime:1e3*60*5})},Ei=(t,e,r)=>{const{client:n,queryKey:i}=r.createPromiseClient(me.Feed,{method:"list",params:[t,e]});return r.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>a?(await n.list({eventId:a,filter:{types:u===Ee.ALLOWED?[]:[I.QuestionType.FACTOID,I.QuestionType.PROMOTION,I.QuestionType.TWEET],statuses:[I.QuestionStatus.ACTIVE,I.QuestionStatus.RESOLVED]}})).data:[],dedupeTime:0,refetchInterval:0})},Ii=(t,e,r)=>{const n=X.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=X.batched(n,a=>a&&a.type==="question"?a.id:void 0),o=Gt(i,t);return{$store:n,$extendedStore:o,updateExtendedQuestion:a=>{const u=o.get().data,d=(c,f)=>{if(!c||!f)return c||f||[];const h=[];for(let m=0;m<c.length;m++)h.push({...c[m],...f[m],correct:c[m].correct,youVoted:c[m].youVoted,pointsEarned:c[m].pointsEarned});return h};o.mutate({...a,options:u?.options,subject:u?.subject,appearance:u?.appearance,answers:d(u?.answers,a?.answers)})}}};var Ee;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Ee||(Ee={}));class Oi{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;notifications;log;transport;cancels=new Set;constructor(e){this.transport=e.transport,this.log=be("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new H(Q(void 0),"moderationId").getStore(),this.interactiveAllowed=new H(Q(Ee.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new H(Q(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new pe(Si(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new pe(Ei(this.slStreamId,this.interactiveAllowed,e.transport),"gamification:feedList"),this.activeQuestionId=wi(this.slStreamId,e.transport),this.openedQuestion=Ii(e.transport,this.openedQuestionId,this.feedList.getStore()),this.cancels.add(this.openedQuestionId.listen(r=>{this.log.debug({item:r},"received question"),r?.questionId?(this.questionSubscription=Ai(r.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",n=>{this.openedQuestion.updateExtendedQuestion(n.data?.attributes?.question)}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))})),this.feedSubscription=Ti(this.slStreamId,e.transport),this.cancels.add(this.feedSubscription.addListener("feed-subscription-active-question",r=>{const n=this.activeQuestionId.get().data?.question?.id,i=r.data?.attributes?.question;i&&(n&&i.status===I.QuestionStatus.RESOLVED&&i.id!==n||this.activeQuestionId.mutate(r.data?.attributes))})),this.cancels.add(this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})})),this.feedSubscription.connect(),this.cancels.add(this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})),e.sdk.onMount(()=>()=>{this.activeQuestionId.off();for(const r of this.cancels)r(),this.cancels.delete(r)})}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 Ci{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)}}),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}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=>{const r=new Map(this.notificationsList.get()),n=r.get(e);if(n){n.hiding=!(this.waitingQueue.size>=this.options.concurrency),this.notificationsList.set(r);const i=setTimeout(()=>{const o=new Map(this.notificationsList.get());o.delete(e),this.notificationsList.set(o);const s=this.timeouts.get(e);s!==void 0&&(clearTimeout(s),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden")},this.options.animationDelay||0);this.timeouts.set(e,i)}return this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding"),n};drain=()=>{this.store.clear(),this.timeouts.clear(),this.waitingQueue.clear(),this.activeQueue.clear(),this.notificationsList.off(),this.notificationsList.set(new Map)}}var pt;(function(t){t.OPENED="opened"})(pt||(pt={}));class _i extends St{constructor(){super("notification")}setOpened=e=>{this.write(pt.OPENED,e,"true")};isOpened=e=>this.read(pt.OPENED,e);clearNotification=()=>{this.clear()}}var ge;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(ge||(ge={}));class Li{queue;storage;constructor(e={}){this.storage=new _i,this.queue=new Ci({concurrency:1,animationDelay:1600,...e})}add=e=>{if(!this.storage.isOpened(e.id)){if(e.data&&e.emitEvent){const n=e.action;e.action=(...i)=>{n&&n(...i),fe.emit("notification",{action:"opened",payload:{questionId:e.data.questionId,questionType:e.data.questionType}})}}this.queue.addToQueue(e)}};close=(e,r=!0)=>{this.queue.closeNotification(e),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 ki=(t,e,r)=>{t.notifications=new Li(void 0),t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),t.sdk.getActiveNotification=()=>t.notifications.getActiveNotification(),t.sdk.onMount(()=>()=>{t.notifications.queue.drain()}),r()};var Ye;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(Ye||(Ye={}));const Pi=async(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(me.Feed,{method:"submitAnswer"}),i=n({retryAttempts:0});try{return await r.submitAnswer({data:e},{contextValues:i})}catch(o){throw M.ConnectError.from(o)?.code===M.Code.AlreadyExists?new Error(Ye.ALREADY_VOTED):new Error(Ye.UNKNOWN)}},Fi=(t,e)=>{const{client:r,createRequestOptions:n}=t.createPromiseClient(me.Feed,{method:"submitInplay"}),i=n({retryAttempts:0});return r.submitInplay({data:{eventId:+e}},{contextValues:i})};var Ve;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})(Ve||(Ve={}));class Zr extends St{constructor(){super("gamification")}saveOnboardingStatus=({userId:e,eventId:r,organizationId:n},i)=>{this.write(Ve.ONBOARDING,n,e,r,i)};getOnboardingStatus=({userId:e,eventId:r,organizationId:n})=>this.read(Ve.ONBOARDING,n,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{const i=this.generateKey([Ve.ONBOARDING_IO,n,e,r]);window.sessionStorage.setItem(i,"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:n})=>{const i=this.generateKey([Ve.ONBOARDING_IO,n,e,r]);return window.sessionStorage.getItem(i)}}const Ni={pageSize:10},Di=(t,e,r,n,i)=>{let o=0;const s=Q({pageSize:i?.pageSize||Ni.pageSize,page:0}),a=ie({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=bi(t),d=async()=>{const h=e.get(),m=n.getStore().get().data?.map(b=>b.slId)||[];if(h&&m?.length){const b=r.get();b&&m.push(b),a.setKey("loading",!0),a.setKey("data",[]);const O=await u({eventId:h,usersIds:m});a.set({data:O.data.map((D,$)=>({...D.attributes,rank:$+1})),hasMore:!1,key:Date.now(),loading:!1}),O.meta&&(o=Math.round(O.meta.count/O.meta.pageSize))}},c=()=>{d()},f=h=>{const m=s.get(),b=h||m.page+1;b<=o&&s.set({...m,page:b})};return X.onMount(a,()=>{const h=e.listen(d),m=n.listen(d);return()=>{h(),m()}}),{$store:a,fetchMore:f,invalidate:c}};class Ri extends St{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Sr="sldl",wt="sldl_uid",en="sldl_eid",tn="sldl_e_eid",Vi=new Set([wt,en,tn]),wr=t=>{const e={},r={};for(const[n,i]of t)Vi.has(n)?e[n]=i:r[n]=i;return{result:e,remain:r}},$i=({hash:t,search:e})=>{if(t&&t.includes(Sr)){const r=new URLSearchParams(t.substr(1));return{hash:wr(r)}}if(e&&e.includes(Sr)){const r=new URLSearchParams(e);return{search:wr(r)}}return null},Tr=be("deep_link"),ne={debug:(...t)=>{Tr.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{Tr.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},ji=(t,e)=>{const{hash:r,search:n}=window.location;if(ne.debug({hash:r,search:n},"get deep link data from"),r||n){const i=$i({hash:r,search:n});if(ne.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()}`,ne.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()}`,ne.debug({updatedSearch:c},"update search")),window.history.replaceState(null,"",window.location.pathname+c+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},Mi=(t,e,r)=>{const n=new Ri,i=n.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){ne.debug(a)}t.deepLink={$store:new Ae(ie(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{ne.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?.[wt]: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")&&ne.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{ne.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),ne.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{ne.trace("called handler"),u(a)}catch(d){console.error(d)}};ji(t.deepLink.$store,s),r()},Ui=be("bypass");class qi extends Wn{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,n){super(),this.$coreStore=e,this.deepLink=n,this.transport=r,this.bypassLogin=ui(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?.[wt];Ui.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(s),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 Re().clear()};softLogout=()=>{const e=new Re;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=()=>{const e=new Re,r=e.getToken(),n=e.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(n),r)return this.saveUser(r,""),this.me().then(i=>{if(i?.id){const o=i.id;this.saveUser(r,o)}});if(n&&!r){const i=e.getSchema();i&&n&&this.login(i,n).catch(()=>{this.logout()})}};saveUser=(e,r)=>{this.transport.setAuth(e,r),this.$coreStore.getValues().userToken.setValue(e),new Re().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 Re,xi=(t,e,r)=>{t.auth=new qi(t.store,t.transport,t.deepLink),t.stores.status.listen(n=>{n===ce.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()},Ar=be("video_player"),ot={debug:(...t)=>{Ar.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{Ar.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},Bi=(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()},Qi=(t,e,r)=>{const n={onMountedFired:!1},i=new Set,o=new Set;t.sdk=Object.create(null),t.sdk.onMount=s=>{i.has(s)||(i.add(s),t?.stores?.enabled?.get()==="on"&&o.add(s()))},t.ready=()=>{t.stores.enabled.subscribe(s=>{s==="on"&&n.onMountedFired===!1&&(i.forEach(a=>o.add(a())),n.onMountedFired=!0),s!=="on"&&n.onMountedFired===!0&&(o.forEach(a=>a()),o.clear(),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(ce.INITIALIZATION);try{const a=await t.stores.organizationSettings.getValue();return a?(t.stores.status.setValue(ce.READY),{enabled:!!a}):(t.stores.status.setValue(ce.FAILED),{err:"failed"})}catch(a){return t.stores.enabled.setValue(),t.stores.status.setValue(ce.FAILED),{err:`${a}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(ce.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=s=>{t.stores.providerStreamId.setValue(s)},r()},Gi=(t,e)=>{const{client:r,queryKey:n}=t.createPromiseClient(Xe.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(n,{fetcher:async(i,o,s,a)=>s?(await r.generateDeepLink({data:{gamification:!0,externalEventId:a,eventId:s}})).data?.attributes:{},dedupeTime:1e3*60*60*24,refetchInterval:0})},Ki=(t,{web:e,mobile:r})=>{const{client:n}=t.createPromiseClient(Un.LinksClient,{method:"generate"});return n.generate({web:e,mobile:r})},Er=(t,e)=>{const r=new URLSearchParams(t);for(const[n,i]of Object.entries(e))r.append(n,i);return r.toString()},zi=(t,e,r,n)=>{const i=ie({});return X.onMount(i,()=>Gi(t,[e,r]).subscribe(async({data:a,error:u,loading:d})=>{const c=u?"https://masters.com":a?.url,f=n.get()||"",h=e.get()||"",m=r.get()||"",b={[wt]:f,[en]:h,[tn]:m};if(!d&&c){i.setKey("loading",!0);let C=window.location.search,O=window.location.hash;C&&O||O?C=`?${Er(C,b)}`:O=`#${Er("",b)}`;const D=window.location.origin+window.location.pathname+C+O,$=await Ki(t,{web:D,mobile:c});i.set({data:$.data?.link,loading:!1})}else i.setKey("loading",!0)})),{$store:i,fetch}};var x;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(x||(x={}));const Hi=(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,persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:I.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)=>{try{const s=e.userId.get();if(!s)return;if(i.getOnboardingStatus({userId:s,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===x.Completed){t.set(x.Completed);for(const h of o)h();return}const u=e.moderation.getStore().value?.data,d=r.featureSettings.get().inplayGame;if(u===void 0||d===void 0)return;const c=u?.options?.onboardingEnabled,f=d?.titleCard?.optIn;c?f?t.set(x.Required):t.set(x.Optional):(f?t.set(x.Unavailable):t.set(x.Disabled),n.close(e.getCurrentSessionId({prefix:"onboarding"}),!1))}catch(s){console.error(s)}},Wi=(t,e,r,n)=>{let i=!1;const o=new Zr,s=Q(x.Unset);s.subscribe(d=>{d!==x.Unset&&((d===x.Optional||d===x.Required)&&i===!1&&(Hi(t,e,n,o),i=!0),d===x.Completed&&e.activeQuestionId.invalidate(),o.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const a=[];return st(s,e,t,n,o,a),s.get()!==x.Completed&&(a.push(e.userId.listen(d=>{d&&st(s,e,t,n,o,a)})),a.push(e.moderation.listen(d=>{d.data&&st(s,e,t,n,o,a)})),a.push(t.featureSettings.listen(d=>{d&&st(s,e,t,n,o,a)}))),{$store:s,submitInplay:async()=>{const d=e.slStreamId.get();if(d){await Fi(r,d),s.set(x.Completed),o.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:d},x.Completed),fe.emit("poll",{action:"onboardingPassed",payload:{}}),t.openFeature();const c=e.getCurrentSessionId({prefix:"onboarding"});n.close(c)}}}},Ji=(t,e,r,n)=>{const i=ie(void 0),o=Xr(n),s=async()=>{const u=t.get(),d=e.get(),c=r.getStore().get().data?.map(b=>b.slId);if(!c)return;const f={eventId:u,userId:d,usersIds:[...c,d]},h=await o(f),m=i.get()?.summary?.friendsRank;h.data?.attributes?.summary?.friendsRank&&m!==void 0&&(h.data.attributes.summary.friendsRank=m),i.set(h.data?.attributes)},a=()=>{s()};return X.onMount(i,()=>{const u=t.listen(s),d=r.listen(s),c=e.listen(s);return()=>{u(),d(),c()}}),{$store:i,invalidate:a}},Yi=async(t,e,r,n,i)=>{const o=Xr(i),s=t.get(),a=e.get(),u=r.getStore().get().data?.map(h=>h.slId)||[],d={eventId:s,userId:n,usersIds:[...u,a]};return(await o(d)).data?.attributes?.summary},Xi=new Set([I.QuestionType.POLL,I.QuestionType.PREDICTION,I.QuestionType.TRIVIA]);class Zi extends Yr{userSummary;feedList;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;notifications;transport;background;storage;submitAnswerTimeout;cancels=new Set;constructor(e,r,n){super(e,r),this.background=new Oi(n),this.feedSubscription=this.background.feedSubscription,this.activeQuestionId=this.background.activeQuestionId,this.openedQuestionId=this.background.openedQuestionId,this.storage=new Zr,this.feedList=this.background.feedList,this.friends=new pe(vi(this.background.userId,n.transport),"gamification:friends"),this.currentUserId=this.background.userId,this.openedUser=Q(void 0),this.leaderboardId=new H(Q(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=Wi(this,this.background,n.transport,n.notifications),this.notifications=n.notifications,this.transport=n.transport,this.closeFeature=()=>n.sdk.closeFeature(!0),this.openFeature=()=>n.sdk.openFeature(R.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=zi(this.transport,this.background.slStreamId,n.stores.providerStreamId.getStore(),this.background.userId),this.userSummary=Ji(this.background.slStreamId,this.background.userId,this.friends,this.transport),this.leaderboardList=Di(this.transport,this.background.slStreamId,this.background.userId,this.friends),this.connect(),this.cancels.add(this.userSummary.$store.listen((i,o)=>{o?.summary&&i?.summary&&!i.fromLeaderboard&&this.leaderboardList.invalidate()})),this.cancels.add(this.leaderboardList.$store.subscribe(i=>{const o={...this.userSummary.$store.get()||{}},s=o?.summary?.userId;if(i.data.length&&s){const a=i.data.find(u=>u.userId===s)?.rank;a!==void 0&&o?.summary&&(o.fromLeaderboard=!0,o.summary.friendsRank=a,this.userSummary.$store.set(o))}})),this.cancels.add(this.background.activeQuestionId.listen(this.showInApp)),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)),n.sdk.onMount(()=>()=>{for(const i of this.cancels)i(),this.cancels.delete(i)})}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===Ee.ALLOWED}checkInteractiveFlag=()=>{const e=this.onboardingStatus.$store.get(),r=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,n=this.settings.getValues().inplayGame?.titleCard?.optIn,i=e===x.Completed,o=!r||i||n!==!0;this.background.interactiveAllowed.set(o?Ee.ALLOWED:Ee.DISALLOWED)};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===I.QuestionStatus.RESOLVED&&o===I.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),d=[...this.feedList.getValues().data||[]],c=d.findIndex(G=>G.id===s),f=d[c];let h=f?.attributes?.attributes?.value?.answerId;const m=Gt(s,this.transport),b=m.subscribe(()=>{});await m.get().promise;const C=m.get().data;b(),window.requestAnimationFrame(()=>{m.invalidate()}),h||(h=C?.answers.find(({youVoted:G})=>G)?.id);const O=a.find(({correct:G})=>G),D=h?a.find(({id:G})=>G===h):void 0,$=!!D?.correct;if(f&&d[c]?.attributes?.attributes.case==="question"){try{d[c].attributes.attributes.value.answerId=h,d[c].attributes.attributes.value.openForVoting=!1,h&&(d[c].attributes.attributes.value.status=$?nt.PickHistoryStatus.WON:nt.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(d)}if(!D||!O)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:I.QuestionType.PREDICTION,question:{title:$?`Congratulations! You answered correctly! You won ${O.points} pts!`:`Better luck next time! Correct: ${O?.text}!`,votedAnswer:{title:D?.text,points:D?.points},correctAnswerTitle:O?.text,correct:!!$,predictionResult:i===I.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.status!==I.QuestionStatus.ACTIVE&&n.attributes.status!==I.QuestionStatus.RESOLVED)){if(i!==-1)if(n.attributes.attributes.case==="question"&&r[i].attributes?.attributes.case==="question"){const o=r[i];o.attributes&&(r[i]={...r[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...n.attributes.attributes.value,answerId:o.attributes.attributes.value.answerId,status:o.attributes.attributes.value.status,openForVoting:o.attributes.attributes.value.openForVoting}}}})}else{const o=r[i];o.attributes&&n.attributes&&(r[i]={...r[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...n.attributes.attributes.value}}}})}i===-1&&(r.unshift(n),fe.emit("poll",{action:"received",payload:{questionId:n.id,questionType:n.attributes?.type}})),this.feedList.getStore().mutate(r)}}))};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-prediction-close"),this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitAnswer=async(e,r)=>{const n=Gt(e,this.transport),i=()=>{const o=this.feedList.getValues().data;if(!o)return;const s=o.findIndex(d=>d.id===e),a=o[s],u=a?.attributes?.attributes.case==="question"&&a.attributes.attributes.value;if(u){fe.emit("poll",{action:"voted",payload:{questionId:e,questionType:u.questionType}});const d=n.subscribe(()=>{}),c=n.get().data;if(d(),c){const f=c.answers.find(b=>b.correct===!0),h=c.answers.findIndex(b=>b.id===r),m=c.answers[h];o[s].attributes.attributes.value.answerId=r,o[s].attributes.attributes.value.openForVoting=!1,o[s].attributes.attributes.value.text=m?.text||"",f&&(o[s].attributes.attributes.value.status=f.id===r?nt.PickHistoryStatus.WON:nt.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...o]),c.answers[h].correct=f?.id===r,c.answers[h].youVoted=!0,c.answers.forEach(b=>{b.percentageDecimal=0}),f?.id===r&&(c.answers[h].pointsEarned=c.status===I.QuestionStatus.RESOLVED?0:f.points),n.mutate({...c})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await Pi(this.transport,{questionId:e,answerId:r}),i()}catch(o){if(o.message===Ye.ALREADY_VOTED){this.userSummary.invalidate();const s=n.subscribe(()=>{});n.invalidate(),s()}throw o}};openQuestion=(e,r)=>{if(!e)return()=>{};this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}));let n=r?.attributes?.type;return n||(n=(this.feedList.getStore().value?.data||[]).find(o=>o.id===e)?.attributes?.type),fe.emit("poll",{action:"opened",payload:{questionId:e,questionType:n,questionOpenedFrom:r?.openedFrom}}),this.background.openQuestion(e,r)};closeQuestion=e=>this.background.closeQuestion(e);openUser=async e=>{const r=this.leaderboardList.$store.get().data?.find(i=>i.userId===e);if(!r){this.openedUser.set(r);return}if(r.summaryLoaded){this.openedUser.set(r);return}const n={...r};try{const i=await Yi(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!==x.Unset&&e.data.question?.id!==void 0&&e.data.question.notification!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==I.SilenceSetting.ON&&e.data.question.status===I.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(Xi.has(e.data.question.type))this.isInteractiveAllowed&&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}}});else if(e.data.question.type===I.QuestionType.FACTOID){const n=e.data.question.options?.options.value,i={heading:e.data.question.notification.title,body:e.data.question.notification.body,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:i}})}else if(e.data.question.type===I.QuestionType.TWEET){const n=e.data.question.options?.options.value,i={title:e.data.question.notification?.title,body:e.data.question.notification?.body,image:e.data.question.notification?.image,account:n?.tweetMeta?.account||"",accountVerified:!!n?.tweetMeta?.accountVerified,tweet:n?.tweetMeta?.tweet,tweetId:e.data.question.id};this.notifications.add({type: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:i}})}}}}const eo={[R.SdkOverlayType.GAMES]:!0};class to extends Yr{constructor(e,r){super(e,r)}}const ro=(t,e,r)=>t.type===R.SdkOverlayType.GAMES?new Zi(t,e,r):new to(t,e),no=(t,e,r)=>{t.features=new Map,t.sdk.featuresList=new H(Q(new Set),"features-list"),t.activeFeature=new H(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.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=ue.ORGANIZATION)=>{if(n.type in eo&&!t.features.has(n.type)){const o=ro(n,i,t);t.features.set(n.type,o);let s=t.sdk.featuresList.getValue();s?s.add(n.type):s=new Set([n.type]),t.sdk.featuresList.setValue(new Set(s))}},t.updateFeature=(n,i)=>{t.features.get(n.type)?.update(n,i)},t.destroyFeature=n=>{t.features.delete(n.type);const i=t.sdk.featuresList.getValue();i&&i.delete(n.type),t.sdk.featuresList.setValue(new Set(i))},t.reinitializeFeatures=async()=>{const n=await t.stores.organizationSettings.getValue();t.features.clear(),t.sdk.featuresList.setValue(new Set);for(const i of n?.overlays||[])t.initFeature(i,ue.ORGANIZATION)},t.stores.providerStreamId.listen(n=>{n||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const n=(o,s)=>{if(s?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&o===ue.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(ue.ORGANIZATION,o.data)}catch(s){console.log(s)}},streamSettings:o=>{if(o.data)try{n(ue.STREAM,o.data)}catch(s){console.log(s)}}};t.store.subscribe(i)},r()};class io{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 fe.listen(r)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_ACCEPTED},category:it.InvitationCategory.GAMES,from:it.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INVITATION_SENT},category:it.InvitationCategory.GAMES,from:e||it.InvitationFrom.UNSET})}}class oo{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 fe.listen(r)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:mr.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.INTERACTIONS},actionType:mr.InteractionActionType.SCROLL})}}const He={[I.QuestionType.UNSET]:v.TopicType.UNSET,[I.QuestionType.FACTOID]:v.TopicType.POLLS_INSIGHT,[I.QuestionType.POLL]:v.TopicType.POLLS_POLL,[I.QuestionType.PREDICTION]:v.TopicType.POLLS_PREDICTION,[I.QuestionType.PROMOTION]:v.TopicType.POLLS_PROMOTION,[I.QuestionType.TRIVIA]:v.TopicType.POLLS_TRIVIA,[I.QuestionType.TWEET]:v.TopicType.POLLS_TWITTER};I.QuestionType.UNSET+"",Y.NotificationKind.UNSET,I.QuestionType.FACTOID+"",Y.NotificationKind.POLLS,I.QuestionType.POLL+"",Y.NotificationKind.POLLS,I.QuestionType.PREDICTION+"",Y.NotificationKind.POLLS,I.QuestionType.PROMOTION+"",Y.NotificationKind.POLLS,I.QuestionType.TRIVIA+"",Y.NotificationKind.POLLS,I.QuestionType.TWEET+"",Y.NotificationKind.POLLS;const so={[R.SdkOverlayType.UNSET]:v.Category.UNSET,[R.SdkOverlayType.INPLAY]:v.Category.INPLAY,[R.SdkOverlayType.MESSAGING]:v.Category.MESSAGING,[R.SdkOverlayType.STATISTICS]:v.Category.STATS,[R.SdkOverlayType.BETTING]:v.Category.BETTING,[R.SdkOverlayType.TWITTER]:v.Category.TWITTER,[R.SdkOverlayType.MERCHANDISE]:v.Category.MERCHANDISE,[R.SdkOverlayType.CONTESTS]:v.Category.CONTESTS,[R.SdkOverlayType.VOICE_CHAT]:v.Category.CALLING,[R.SdkOverlayType.TICKETS]:v.Category.TICKETS,[R.SdkOverlayType.WHOIS_WATCHING]:v.Category.WHOISWATCHING,[R.SdkOverlayType.PROFILE]:v.Category.PROFILE,[R.SdkOverlayType.GAMES]:v.Category.POLLS,[R.SdkOverlayType.GOLF_STATISTICS]:v.Category.STATS,[R.SdkOverlayType.HIGHLIGHTS]:v.Category.HIGHLIGHTS,[R.SdkOverlayType.PUBLIC_CHAT]:v.Category.PUBLIC_CHAT};class ao{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}};return fe.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},notificationKind:Y.NotificationKind.POLLS,notificationType:Y.NotificationType.IN_APP})};opened=({questionId:e,questionType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.NOTIFICATION_OPENED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},notificationKind:Y.NotificationKind.POLLS,notificationType:Y.NotificationType.IN_APP})}}class uo{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 fe.listen(r)})}received=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_RECEIVED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};opened=({questionId:e,questionType:r,questionOpenedFrom:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_OPENED,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},pollOpenedFrom:n==="list"?v.PollOpenedFrom.PICK_HISTORY:v.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_VOTE,topicId:e,topicType:r?He[r]:v.TopicType.UNSET},pollOpenedFrom:v.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.GAMES_JOINED},pollOpenedFrom:v.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:v.Kind.POLLS_NAVIGATED},pollOpenedFrom:v.PollOpenedFrom.UNSET})}}const co=({transport:t,$commonStore:e})=>{let r;const n=Q(!1),i=5e3,{client:o,queryKey:s}=t.createPromiseClient(Kr.AnalyticsService,{method:"send",params:[n]}),a=t.nanoquery.createFetcherStore(s,{fetcher:async()=>{const h=e.getStore().get();try{await o.unary({message:{case:"heartbeat",value:{common:{...h,kind:v.Kind.SESSION_HEARTBEAT}}}})}catch(m){le.error(m,"send heartbeat failed")}return Date.now()},refetchInterval:i}),u=()=>{le.debug("mounted heartbeat"),r=a.subscribe(()=>{})},d=()=>{le.debug("enabled heartbeat"),n.set(!0),a.lc===0&&u()},c=()=>{le.debug("disabled heartbeat"),n.set(!1)};return{enable:d,disable:c,mount:u,unmount:()=>{le.debug("unmounted heartbeat"),a.off(),r?.(),r=void 0,c()}}},le=be("analytics");class lo{commonStore;notifications;polls;invitation;interactions;heartbeat;analyticsClient;listeners;listenersCancels;connected=!1;constructor(e){this.listeners=new Set,this.listenersCancels=new Set,this.commonStore=new Ae(ie({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=co({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new ao(this),this.polls=new uo(this),this.invitation=new io(this),this.interactions=new oo(this);const{client:r}=e.analyticsTransport.createPromiseClient(Kr.AnalyticsService,{method:"send"});this.analyticsClient=r}connect=()=>{this.writeCommon("sessionId",qt.nanoid()),this.heartbeat.enable(),this.listeners.forEach(e=>this.listenersCancels.add(e())),this.connected=!0,le.debug("analytics connected")};disconnect=()=>{this.writeCommon("sessionId",""),this.writeCommon("overlaySessionId",""),this.heartbeat.unmount(),this.listenersCancels.forEach(e=>e()),this.connected=!1,le.debug("analytics disconnected")};write=(e,r)=>{r&&this.analyticsClient.unary({message:{case:e,value:r}}).then(()=>{le.trace("send analytics success",e,r)}).catch(n=>{le.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",so[r]),r!==R.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",qt.nanoid()):this.writeCommon("overlaySessionId","")})),this.onConnect(()=>{const r=window.matchMedia("(orientation: portrait)"),n=i=>{this.writeCommon("screenOrientation",i.matches?v.ScreenOrientation.PORTRAIT:v.ScreenOrientation.LANDSCAPE)};return r.addEventListener("change",n),()=>{r.removeEventListener("change",n)}}),this.onConnect(()=>e.deepLink.$store.subscribe(r=>{r?.handled&&this.invitation.accepted()}))}}const fo=(t,e,r)=>{t.analytics=new lo(t),t.sdk.onMount(()=>(t.analytics.connect(),()=>{t.analytics.disconnect()})),r()};var rn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function po(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var nr={exports:{}},ir={exports:{}};function ho(t){var e=new t,r=e;function n(){var o=e;return o.next?e=o.next:(e=new t,r=e),o.next=null,o}function i(o){r.next=o,r=o}return{get:n,release:i}}var yo=ho,go=yo;function nn(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),r<1)throw new Error("fastqueue concurrency must be greater than 1");var n=go(mo),i=null,o=null,s=0,a=null,u={push:C,drain:z,saturated:z,pause:c,paused:!1,concurrency:r,running:d,resume:m,idle:b,length:f,getQueue:h,unshift:O,empty:z,kill:$,killAndDrain:G,error:W};return u;function d(){return s}function c(){u.paused=!0}function f(){for(var P=i,V=0;P;)P=P.next,V++;return V}function h(){for(var P=i,V=[];P;)V.push(P.value),P=P.next;return V}function m(){if(u.paused){u.paused=!1;for(var P=0;P<u.concurrency;P++)s++,D()}}function b(){return s===0&&u.length()===0}function C(P,V){var E=n.get();E.context=t,E.release=D,E.value=P,E.callback=V||z,E.errorHandler=a,s===u.concurrency||u.paused?o?(o.next=E,o=E):(i=E,o=E,u.saturated()):(s++,e.call(t,E.value,E.worked))}function O(P,V){var E=n.get();E.context=t,E.release=D,E.value=P,E.callback=V||z,E.errorHandler=a,s===u.concurrency||u.paused?i?(E.next=i,i=E):(i=E,o=E,u.saturated()):(s++,e.call(t,E.value,E.worked))}function D(P){P&&n.release(P);var V=i;V?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=z}function G(){i=null,o=null,u.drain(),u.drain=z}function W(P){a=P}}function z(){}function mo(){this.value=null,this.callback=z,this.next=null,this.release=z,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=z,t.errorHandler&&o(r,s),i.call(t.context,r,n),t.release(t)}}function bo(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function n(c,f){e.call(this,c).then(function(h){f(null,h)},f)}var i=nn(t,n,r),o=i.push,s=i.unshift;return i.push=a,i.unshift=u,i.drained=d,i;function a(c){var f=new Promise(function(h,m){o(c,function(b,C){if(b){m(b);return}h(C)})});return f.catch(z),f}function u(c){var f=new Promise(function(h,m){s(c,function(b,C){if(b){m(b);return}h(C)})});return f.catch(z),f}function d(){if(i.idle())return new Promise(function(h){h()});var c=i.drain,f=new Promise(function(h){i.drain=function(){c(),h()}});return f}}ir.exports=nn;ir.exports.promise=bo;var on=ir.exports,or={exports:{}},Me=typeof Reflect=="object"?Reflect:null,Ir=Me&&typeof Me.apply=="function"?Me.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},ut;Me&&typeof Me.ownKeys=="function"?ut=Me.ownKeys:Object.getOwnPropertySymbols?ut=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ut=function(e){return Object.getOwnPropertyNames(e)};function vo(t){console&&console.warn&&console.warn(t)}var sn=Number.isNaN||function(e){return e!==e};function F(){F.init.call(this)}or.exports=F;or.exports.once=Ao;F.EventEmitter=F;F.prototype._events=void 0;F.prototype._eventsCount=0;F.prototype._maxListeners=void 0;var Or=10;function Tt(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 Or},set:function(t){if(typeof t!="number"||t<0||sn(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Or=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||sn(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 an(t){return t._maxListeners===void 0?F.defaultMaxListeners:t._maxListeners}F.prototype.getMaxListeners=function(){return an(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")Ir(u,this,r);else for(var d=u.length,c=fn(u,d),n=0;n<d;++n)Ir(c[n],this,r);return!0};function un(t,e,r,n){var i,o,s;if(Tt(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=an(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,vo(a)}return t}F.prototype.addListener=function(e,r){return un(this,e,r,!1)};F.prototype.on=F.prototype.addListener;F.prototype.prependListener=function(e,r){return un(this,e,r,!0)};function So(){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 cn(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=So.bind(n);return i.listener=r,n.wrapFn=i,i}F.prototype.once=function(e,r){return Tt(r),this.on(e,cn(this,e,r)),this};F.prototype.prependOnceListener=function(e,r){return Tt(r),this.prependListener(e,cn(this,e,r)),this};F.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Tt(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():wo(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?To(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):dn.call(t,e)};F.prototype.listenerCount=dn;function dn(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?ut(this._events):[]};function fn(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function wo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function To(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Ao(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))}pn(t,e,o,{once:!0}),e!=="error"&&Eo(t,i,{once:!0})})}function Eo(t,e,r){typeof t.on=="function"&&pn(t,"error",e,r)}function pn(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 hn=or.exports,At={},yn={},gn=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},Io=gn,sr=function(){return Io()&&!!Symbol.toStringTag},Cr=typeof Symbol<"u"&&Symbol,Oo=gn,Co=function(){return typeof Cr!="function"||typeof Symbol!="function"||typeof Cr("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Oo()},_r={foo:{}},_o=Object,Lo=function(){return{__proto__:_r}.foo===_r.foo&&!({__proto__:null}instanceof _o)},ko="Function.prototype.bind called on incompatible ",Po=Object.prototype.toString,Fo=Math.max,No="[object Function]",Lr=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},Do=function(e,r){for(var n=[],i=r||0,o=0;i<e.length;i+=1,o+=1)n[o]=e[i];return n},Ro=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r},Vo=function(e){var r=this;if(typeof r!="function"||Po.apply(r)!==No)throw new TypeError(ko+r);for(var n=Do(arguments,1),i,o=function(){if(this instanceof i){var c=r.apply(this,Lr(n,arguments));return Object(c)===c?c:this}return r.apply(e,Lr(n,arguments))},s=Fo(0,r.length-n.length),a=[],u=0;u<s;u++)a[u]="$"+u;if(i=Function("binder","return function ("+Ro(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},$o=Vo,ar=Function.prototype.bind||$o,jo=Function.prototype.call,Mo=Object.prototype.hasOwnProperty,Uo=ar,qo=Uo.call(jo,Mo),A,qe=SyntaxError,mn=Function,Ue=TypeError,Ct=function(t){try{return mn('"use strict"; return ('+t+").constructor;")()}catch{}},Ie=Object.getOwnPropertyDescriptor;if(Ie)try{Ie({},"")}catch{Ie=null}var _t=function(){throw new Ue},xo=Ie?function(){try{return arguments.callee,_t}catch{try{return Ie(arguments,"callee").get}catch{return _t}}}():_t,Fe=Co(),Bo=Lo(),U=Object.getPrototypeOf||(Bo?function(t){return t.__proto__}:null),De={},Qo=typeof Uint8Array>"u"||!U?A:U(Uint8Array),Oe={"%AggregateError%":typeof AggregateError>"u"?A:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?A:ArrayBuffer,"%ArrayIteratorPrototype%":Fe&&U?U([][Symbol.iterator]()):A,"%AsyncFromSyncIteratorPrototype%":A,"%AsyncFunction%":De,"%AsyncGenerator%":De,"%AsyncGeneratorFunction%":De,"%AsyncIteratorPrototype%":De,"%Atomics%":typeof Atomics>"u"?A:Atomics,"%BigInt%":typeof BigInt>"u"?A:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?A:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?A:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?A:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?A:Float32Array,"%Float64Array%":typeof Float64Array>"u"?A:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?A:FinalizationRegistry,"%Function%":mn,"%GeneratorFunction%":De,"%Int8Array%":typeof Int8Array>"u"?A:Int8Array,"%Int16Array%":typeof Int16Array>"u"?A:Int16Array,"%Int32Array%":typeof Int32Array>"u"?A:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Fe&&U?U(U([][Symbol.iterator]())):A,"%JSON%":typeof JSON=="object"?JSON:A,"%Map%":typeof Map>"u"?A:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Fe||!U?A:U(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?A:Promise,"%Proxy%":typeof Proxy>"u"?A:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?A:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?A:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Fe||!U?A:U(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?A:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Fe&&U?U(""[Symbol.iterator]()):A,"%Symbol%":Fe?Symbol:A,"%SyntaxError%":qe,"%ThrowTypeError%":xo,"%TypedArray%":Qo,"%TypeError%":Ue,"%Uint8Array%":typeof Uint8Array>"u"?A:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?A:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?A:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?A:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?A:WeakMap,"%WeakRef%":typeof WeakRef>"u"?A:WeakRef,"%WeakSet%":typeof WeakSet>"u"?A:WeakSet};if(U)try{null.error}catch(t){var Go=U(U(t));Oe["%Error.prototype%"]=Go}var Ko=function t(e){var r;if(e==="%AsyncFunction%")r=Ct("async function () {}");else if(e==="%GeneratorFunction%")r=Ct("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Ct("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&U&&(r=U(i.prototype))}return Oe[e]=r,r},kr={"%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=ar,ht=qo,zo=Ze.call(Function.call,Array.prototype.concat),Ho=Ze.call(Function.apply,Array.prototype.splice),Pr=Ze.call(Function.call,String.prototype.replace),yt=Ze.call(Function.call,String.prototype.slice),Wo=Ze.call(Function.call,RegExp.prototype.exec),Jo=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Yo=/\\(\\)?/g,Xo=function(e){var r=yt(e,0,1),n=yt(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 Pr(e,Jo,function(o,s,a,u){i[i.length]=a?Pr(u,Yo,"$1"):s||o}),i},Zo=function(e,r){var n=e,i;if(ht(kr,n)&&(i=kr[n],n="%"+i[0]+"%"),ht(Oe,n)){var o=Oe[n];if(o===De&&(o=Ko(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!")},Be=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(Wo(/^%?[^%]*%?$/,e)===null)throw new qe("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Xo(e),i=n.length>0?n[0]:"",o=Zo("%"+i+"%",r),s=o.name,a=o.value,u=!1,d=o.alias;d&&(i=d[0],Ho(n,zo([0,1],d)));for(var c=1,f=!0;c<n.length;c+=1){var h=n[c],m=yt(h,0,1),b=yt(h,-1);if((m==='"'||m==="'"||m==="`"||b==='"'||b==="'"||b==="`")&&m!==b)throw new qe("property names with quotes must have matching quotes");if((h==="constructor"||!f)&&(u=!0),i+="."+h,s="%"+i+"%",ht(Oe,s))a=Oe[s];else if(a!=null){if(!(h in a)){if(!r)throw new Ue("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ie&&c+1>=n.length){var C=Ie(a,h);f=!!C,f&&"get"in C&&!("originalValue"in C.get)?a=C.get:a=a[h]}else f=ht(a,h),a=a[h];f&&!u&&(Oe[s]=a)}}return a},bn={exports:{}},es=Be,Kt=es("%Object.defineProperty%",!0),zt=function(){if(Kt)try{return Kt({},"a",{value:1}),!0}catch{return!1}return!1};zt.hasArrayLengthDefineBug=function(){if(!zt())return null;try{return Kt([],"length",{value:1}).length!==1}catch{return!0}};var vn=zt,ts=Be,ct=ts("%Object.getOwnPropertyDescriptor%",!0);if(ct)try{ct([],"length")}catch{ct=null}var ur=ct,rs=vn(),cr=Be,We=rs&&cr("%Object.defineProperty%",!0);if(We)try{We({},"a",{value:1})}catch{We=!1}var ns=cr("%SyntaxError%"),Ne=cr("%TypeError%"),Fr=ur,is=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Ne("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Ne("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Ne("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Ne("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Ne("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Ne("`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=!!Fr&&Fr(e,r);if(We)We(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 ns("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Sn=Be,Nr=is,os=vn(),Dr=ur,Rr=Sn("%TypeError%"),ss=Sn("%Math.floor%"),as=function(e,r){if(typeof e!="function")throw new Rr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||ss(r)!==r)throw new Rr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in e&&Dr){var s=Dr(e,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(os?Nr(e,"length",r,!0,!0):Nr(e,"length",r)),e};(function(t){var e=ar,r=Be,n=as,i=r("%TypeError%"),o=r("%Function.prototype.apply%"),s=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(s,o),u=r("%Object.defineProperty%",!0),d=r("%Math.max%");if(u)try{u({},"a",{value:1})}catch{u=null}t.exports=function(h){if(typeof h!="function")throw new i("a function is required");var m=a(e,s,arguments);return n(m,1+d(0,h.length-(arguments.length-1)),!0)};var c=function(){return a(e,o,arguments)};u?u(t.exports,"apply",{value:c}):t.exports.apply=c})(bn);var wn=bn.exports,Tn=Be,An=wn,us=An(Tn("String.prototype.indexOf")),En=function(e,r){var n=Tn(e,!!r);return typeof n=="function"&&us(e,".prototype.")>-1?An(n):n},cs=sr(),ls=En,Ht=ls("Object.prototype.toString"),Et=function(e){return cs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:Ht(e)==="[object Arguments]"},In=function(e){return Et(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Ht(e)!=="[object Array]"&&Ht(e.callee)==="[object Function]"},ds=function(){return Et(arguments)}();Et.isLegacyArguments=In;var fs=ds?Et:In,ps=Object.prototype.toString,hs=Function.prototype.toString,ys=/^\s*(?:function)?\*/,On=sr(),Lt=Object.getPrototypeOf,gs=function(){if(!On)return!1;try{return Function("return function*() {}")()}catch{}},kt,ms=function(e){if(typeof e!="function")return!1;if(ys.test(hs.call(e)))return!0;if(!On){var r=ps.call(e);return r==="[object GeneratorFunction]"}if(!Lt)return!1;if(typeof kt>"u"){var n=gs();kt=n?Lt(n):!1}return Lt(e)===kt},Cn=Function.prototype.toString,$e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Wt,lt;if(typeof $e=="function"&&typeof Object.defineProperty=="function")try{Wt=Object.defineProperty({},"length",{get:function(){throw lt}}),lt={},$e(function(){throw 42},null,Wt)}catch(t){t!==lt&&($e=null)}else $e=null;var bs=/^\s*class\b/,Jt=function(e){try{var r=Cn.call(e);return bs.test(r)}catch{return!1}},Pt=function(e){try{return Jt(e)?!1:(Cn.call(e),!0)}catch{return!1}},dt=Object.prototype.toString,vs="[object Object]",Ss="[object Function]",ws="[object GeneratorFunction]",Ts="[object HTMLAllCollection]",As="[object HTML document.all class]",Es="[object HTMLCollection]",Is=typeof Symbol=="function"&&!!Symbol.toStringTag,Os=!(0 in[,]),Yt=function(){return!1};if(typeof document=="object"){var Cs=document.all;dt.call(Cs)===dt.call(document.all)&&(Yt=function(e){if((Os||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=dt.call(e);return(r===Ts||r===As||r===Es||r===vs)&&e("")==null}catch{}return!1})}var _s=$e?function(e){if(Yt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{$e(e,null,Wt)}catch(r){if(r!==lt)return!1}return!Jt(e)&&Pt(e)}:function(e){if(Yt(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Is)return Pt(e);if(Jt(e))return!1;var r=dt.call(e);return r!==Ss&&r!==ws&&!/^\[object HTML/.test(r)?!1:Pt(e)},Ls=_s,ks=Object.prototype.toString,_n=Object.prototype.hasOwnProperty,Ps=function(e,r,n){for(var i=0,o=e.length;i<o;i++)_n.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Fs=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)},Ns=function(e,r,n){for(var i in e)_n.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Ds=function(e,r,n){if(!Ls(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),ks.call(e)==="[object Array]"?Ps(e,r,i):typeof e=="string"?Fs(e,r,i):Ns(e,r,i)},Rs=Ds,Ft=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],Vs=typeof globalThis>"u"?rn:globalThis,$s=function(){for(var e=[],r=0;r<Ft.length;r++)typeof Vs[Ft[r]]=="function"&&(e[e.length]=Ft[r]);return e},gt=Rs,js=$s,Vr=wn,lr=En,ft=ur,Ms=lr("Object.prototype.toString"),Ln=sr(),$r=typeof globalThis>"u"?rn:globalThis,Xt=js(),dr=lr("String.prototype.slice"),Nt=Object.getPrototypeOf,Us=lr("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},mt={__proto__:null};Ln&&ft&&Nt?gt(Xt,function(t){var e=new $r[t];if(Symbol.toStringTag in e){var r=Nt(e),n=ft(r,Symbol.toStringTag);if(!n){var i=Nt(r);n=ft(i,Symbol.toStringTag)}mt["$"+t]=Vr(n.get)}}):gt(Xt,function(t){var e=new $r[t],r=e.slice||e.set;r&&(mt["$"+t]=Vr(r))});var qs=function(e){var r=!1;return gt(mt,function(n,i){if(!r)try{"$"+n(e)===i&&(r=dr(i,1))}catch{}}),r},xs=function(e){var r=!1;return gt(mt,function(n,i){if(!r)try{n(e),r=dr(i,1)}catch{}}),r},kn=function(e){if(!e||typeof e!="object")return!1;if(!Ln){var r=dr(Ms(e),8,-1);return Us(Xt,r)>-1?r:r!=="Object"?!1:xs(e)}return ft?qs(e):null},Bs=kn,Qs=function(e){return!!Bs(e)};(function(t){var e=fs,r=ms,n=kn,i=Qs;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),f=o(Boolean.prototype.valueOf);if(s)var h=o(BigInt.prototype.valueOf);if(a)var m=o(Symbol.prototype.valueOf);function b(y,$n){if(typeof y!="object")return!1;try{return $n(y),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=i;function C(y){return typeof Promise<"u"&&y instanceof Promise||y!==null&&typeof y=="object"&&typeof y.then=="function"&&typeof y.catch=="function"}t.isPromise=C;function O(y){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(y):i(y)||p(y)}t.isArrayBufferView=O;function D(y){return n(y)==="Uint8Array"}t.isUint8Array=D;function $(y){return n(y)==="Uint8ClampedArray"}t.isUint8ClampedArray=$;function G(y){return n(y)==="Uint16Array"}t.isUint16Array=G;function W(y){return n(y)==="Uint32Array"}t.isUint32Array=W;function P(y){return n(y)==="Int8Array"}t.isInt8Array=P;function V(y){return n(y)==="Int16Array"}t.isInt16Array=V;function E(y){return n(y)==="Int32Array"}t.isInt32Array=E;function Z(y){return n(y)==="Float32Array"}t.isFloat32Array=Z;function ee(y){return n(y)==="Float64Array"}t.isFloat64Array=ee;function Ce(y){return n(y)==="BigInt64Array"}t.isBigInt64Array=Ce;function ve(y){return n(y)==="BigUint64Array"}t.isBigUint64Array=ve;function oe(y){return u(y)==="[object Map]"}oe.working=typeof Map<"u"&&oe(new Map);function It(y){return typeof Map>"u"?!1:oe.working?oe(y):y instanceof Map}t.isMap=It;function ye(y){return u(y)==="[object Set]"}ye.working=typeof Set<"u"&&ye(new Set);function Ge(y){return typeof Set>"u"?!1:ye.working?ye(y):y instanceof Set}t.isSet=Ge;function _e(y){return u(y)==="[object WeakMap]"}_e.working=typeof WeakMap<"u"&&_e(new WeakMap);function Ot(y){return typeof WeakMap>"u"?!1:_e.working?_e(y):y instanceof WeakMap}t.isWeakMap=Ot;function Le(y){return u(y)==="[object WeakSet]"}Le.working=typeof WeakSet<"u"&&Le(new WeakSet);function se(y){return Le(y)}t.isWeakSet=se;function ke(y){return u(y)==="[object ArrayBuffer]"}ke.working=typeof ArrayBuffer<"u"&&ke(new ArrayBuffer);function et(y){return typeof ArrayBuffer>"u"?!1:ke.working?ke(y):y instanceof ArrayBuffer}t.isArrayBuffer=et;function l(y){return u(y)==="[object DataView]"}l.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&l(new DataView(new ArrayBuffer(1),0,1));function p(y){return typeof DataView>"u"?!1:l.working?l(y):y instanceof DataView}t.isDataView=p;var g=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function S(y){return u(y)==="[object SharedArrayBuffer]"}function L(y){return typeof g>"u"?!1:(typeof S.working>"u"&&(S.working=S(new g)),S.working?S(y):y instanceof g)}t.isSharedArrayBuffer=L;function k(y){return u(y)==="[object AsyncFunction]"}t.isAsyncFunction=k;function T(y){return u(y)==="[object Map Iterator]"}t.isMapIterator=T;function _(y){return u(y)==="[object Set Iterator]"}t.isSetIterator=_;function N(y){return u(y)==="[object Generator]"}t.isGeneratorObject=N;function K(y){return u(y)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=K;function Se(y){return b(y,d)}t.isNumberObject=Se;function tt(y){return b(y,c)}t.isStringObject=tt;function Pe(y){return b(y,f)}t.isBooleanObject=Pe;function rt(y){return s&&b(y,h)}t.isBigIntObject=rt;function hr(y){return a&&b(y,m)}t.isSymbolObject=hr;function Rn(y){return Se(y)||tt(y)||Pe(y)||rt(y)||hr(y)}t.isBoxedPrimitive=Rn;function Vn(y){return typeof Uint8Array<"u"&&(et(y)||L(y))}t.isAnyArrayBuffer=Vn,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(y){Object.defineProperty(t,y,{enumerable:!1,value:function(){throw new Error(y+" is not supported in userland")}})})})(yn);var Gs=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},Zt={exports:{}};typeof Object.create=="function"?Zt.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Zt.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 Ks=Zt.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(p){for(var g=Object.keys(p),S={},L=0;L<g.length;L++)S[g[L]]=Object.getOwnPropertyDescriptor(p,g[L]);return S},r=/%[sdj%]/g;t.format=function(l){if(!P(l)){for(var p=[],g=0;g<arguments.length;g++)p.push(s(arguments[g]));return p.join(" ")}for(var g=1,S=arguments,L=S.length,k=String(l).replace(r,function(_){if(_==="%%")return"%";if(g>=L)return _;switch(_){case"%s":return String(S[g++]);case"%d":return Number(S[g++]);case"%j":try{return JSON.stringify(S[g++])}catch{return"[Circular]"}default:return _}}),T=S[g];g<L;T=S[++g])$(T)||!ee(T)?k+=" "+T:k+=" "+s(T);return k},t.deprecate=function(l,p){if(typeof w<"u"&&w.noDeprecation===!0)return l;if(typeof w>"u")return function(){return t.deprecate(l,p).apply(this,arguments)};var g=!1;function S(){if(!g){if(w.throwDeprecation)throw new Error(p);w.traceDeprecation?console.trace(p):console.error(p),g=!0}return l.apply(this,arguments)}return S};var n={},i=/^$/;if(w.env.NODE_DEBUG){var o=w.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(l){if(l=l.toUpperCase(),!n[l])if(i.test(l)){var p=w.pid;n[l]=function(){var g=t.format.apply(t,arguments);console.error("%s %d: %s",l,p,g)}}else n[l]=function(){};return n[l]};function s(l,p){var g={seen:[],stylize:u};return arguments.length>=3&&(g.depth=arguments[2]),arguments.length>=4&&(g.colors=arguments[3]),D(p)?g.showHidden=p:p&&t._extend(g,p),E(g.showHidden)&&(g.showHidden=!1),E(g.depth)&&(g.depth=2),E(g.colors)&&(g.colors=!1),E(g.customInspect)&&(g.customInspect=!0),g.colors&&(g.stylize=a),c(g,l,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(l,p){var g=s.styles[p];return g?"\x1B["+s.colors[g][0]+"m"+l+"\x1B["+s.colors[g][1]+"m":l}function u(l,p){return l}function d(l){var p={};return l.forEach(function(g,S){p[g]=!0}),p}function c(l,p,g){if(l.customInspect&&p&&oe(p.inspect)&&p.inspect!==t.inspect&&!(p.constructor&&p.constructor.prototype===p)){var S=p.inspect(g,l);return P(S)||(S=c(l,S,g)),S}var L=f(l,p);if(L)return L;var k=Object.keys(p),T=d(k);if(l.showHidden&&(k=Object.getOwnPropertyNames(p)),ve(p)&&(k.indexOf("message")>=0||k.indexOf("description")>=0))return h(p);if(k.length===0){if(oe(p)){var _=p.name?": "+p.name:"";return l.stylize("[Function"+_+"]","special")}if(Z(p))return l.stylize(RegExp.prototype.toString.call(p),"regexp");if(Ce(p))return l.stylize(Date.prototype.toString.call(p),"date");if(ve(p))return h(p)}var N="",K=!1,Se=["{","}"];if(O(p)&&(K=!0,Se=["[","]"]),oe(p)){var tt=p.name?": "+p.name:"";N=" [Function"+tt+"]"}if(Z(p)&&(N=" "+RegExp.prototype.toString.call(p)),Ce(p)&&(N=" "+Date.prototype.toUTCString.call(p)),ve(p)&&(N=" "+h(p)),k.length===0&&(!K||p.length==0))return Se[0]+N+Se[1];if(g<0)return Z(p)?l.stylize(RegExp.prototype.toString.call(p),"regexp"):l.stylize("[Object]","special");l.seen.push(p);var Pe;return K?Pe=m(l,p,g,T,k):Pe=k.map(function(rt){return b(l,p,g,T,rt,K)}),l.seen.pop(),C(Pe,N,Se)}function f(l,p){if(E(p))return l.stylize("undefined","undefined");if(P(p)){var g="'"+JSON.stringify(p).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return l.stylize(g,"string")}if(W(p))return l.stylize(""+p,"number");if(D(p))return l.stylize(""+p,"boolean");if($(p))return l.stylize("null","null")}function h(l){return"["+Error.prototype.toString.call(l)+"]"}function m(l,p,g,S,L){for(var k=[],T=0,_=p.length;T<_;++T)Le(p,String(T))?k.push(b(l,p,g,S,String(T),!0)):k.push("");return L.forEach(function(N){N.match(/^\d+$/)||k.push(b(l,p,g,S,N,!0))}),k}function b(l,p,g,S,L,k){var T,_,N;if(N=Object.getOwnPropertyDescriptor(p,L)||{value:p[L]},N.get?N.set?_=l.stylize("[Getter/Setter]","special"):_=l.stylize("[Getter]","special"):N.set&&(_=l.stylize("[Setter]","special")),Le(S,L)||(T="["+L+"]"),_||(l.seen.indexOf(N.value)<0?($(g)?_=c(l,N.value,null):_=c(l,N.value,g-1),_.indexOf(`
3
+ `)>-1&&(k?_=_.split(`
4
4
  `).map(function(K){return" "+K}).join(`
5
- `).slice(2):C=`
6
- `+C.split(`
5
+ `).slice(2):_=`
6
+ `+_.split(`
7
7
  `).map(function(K){return" "+K}).join(`
8
- `))):C=l.stylize("[Circular]","special")),E(A)){if(L&&k.match(/^\d+$/))return C;A=JSON.stringify(""+k),A.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(A=A.slice(1,-1),A=l.stylize(A,"name")):(A=A.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),A=l.stylize(A,"string"))}return A+": "+C}function O(l,p,g){var S=l.reduce(function(k,L){return L.indexOf(`
9
- `)>=0,k+L.replace(/\u001b\[\d\d?m/g,"").length+1},0);return S>60?g[0]+(p===""?"":p+`
8
+ `))):_=l.stylize("[Circular]","special")),E(T)){if(k&&L.match(/^\d+$/))return _;T=JSON.stringify(""+L),T.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(T=T.slice(1,-1),T=l.stylize(T,"name")):(T=T.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),T=l.stylize(T,"string"))}return T+": "+_}function C(l,p,g){var S=l.reduce(function(L,k){return k.indexOf(`
9
+ `)>=0,L+k.replace(/\u001b\[\d\d?m/g,"").length+1},0);return S>60?g[0]+(p===""?"":p+`
10
10
  `)+" "+l.join(`,
11
- `)+" "+g[1]:g[0]+p+" "+l.join(", ")+" "+g[1]}t.types=hn;function I(l){return Array.isArray(l)}t.isArray=I;function D(l){return typeof l=="boolean"}t.isBoolean=D;function j(l){return l===null}t.isNull=j;function G(l){return l==null}t.isNullOrUndefined=G;function W(l){return typeof l=="number"}t.isNumber=W;function P(l){return typeof l=="string"}t.isString=P;function V(l){return typeof l=="symbol"}t.isSymbol=V;function E(l){return l===void 0}t.isUndefined=E;function Z(l){return ee(l)&&ye(l)==="[object RegExp]"}t.isRegExp=Z,t.types.isRegExp=Z;function ee(l){return typeof l=="object"&&l!==null}t.isObject=ee;function Ce(l){return ee(l)&&ye(l)==="[object Date]"}t.isDate=Ce,t.types.isDate=Ce;function be(l){return ee(l)&&(ye(l)==="[object Error]"||l instanceof Error)}t.isError=be,t.types.isNativeError=be;function se(l){return typeof l=="function"}t.isFunction=se;function It(l){return l===null||typeof l=="boolean"||typeof l=="number"||typeof l=="string"||typeof l=="symbol"||typeof l>"u"}t.isPrimitive=It,t.isBuffer=Qs;function ye(l){return Object.prototype.toString.call(l)}function Ge(l){return l<10?"0"+l.toString(10):l.toString(10)}var _e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ot(){var l=new Date,p=[Ge(l.getHours()),Ge(l.getMinutes()),Ge(l.getSeconds())].join(":");return[l.getDate(),_e[l.getMonth()],p].join(" ")}t.log=function(){console.log("%s - %s",Ot(),t.format.apply(t,arguments))},t.inherits=Gs,t._extend=function(l,p){if(!p||!ee(p))return l;for(var g=Object.keys(p),S=g.length;S--;)l[g[S]]=p[g[S]];return l};function ke(l,p){return Object.prototype.hasOwnProperty.call(l,p)}var ae=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(p){if(typeof p!="function")throw new TypeError('The "original" argument must be of type Function');if(ae&&p[ae]){var g=p[ae];if(typeof g!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(g,ae,{value:g,enumerable:!1,writable:!1,configurable:!0}),g}function g(){for(var S,k,L=new Promise(function(N,K){S=N,k=K}),A=[],C=0;C<arguments.length;C++)A.push(arguments[C]);A.push(function(N,K){N?k(N):S(K)});try{p.apply(this,A)}catch(N){k(N)}return L}return Object.setPrototypeOf(g,Object.getPrototypeOf(p)),ae&&Object.defineProperty(g,ae,{value:g,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(g,e(p))},t.promisify.custom=ae;function Le(l,p){if(!l){var g=new Error("Promise was rejected with a falsy value");g.reason=l,l=g}return p(l)}function et(l){if(typeof l!="function")throw new TypeError('The "original" argument must be of type Function');function p(){for(var g=[],S=0;S<arguments.length;S++)g.push(arguments[S]);var k=g.pop();if(typeof k!="function")throw new TypeError("The last argument must be of type Function");var L=this,A=function(){return k.apply(L,arguments)};l.apply(this,g).then(function(C){w.nextTick(A.bind(null,null,C))},function(C){w.nextTick(Le.bind(null,C,A))})}return Object.setPrototypeOf(p,Object.getPrototypeOf(l)),Object.defineProperties(p,e(l)),p}t.callbackify=et})(Tt);const{inherits:Ks,format:Dt}=Tt;function we(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=Dt(e,i,o,s):i&&o?this.message=Dt(e,i,o):i?this.message=Dt(e,i):this.message=e}return n.prototype[Symbol.toStringTag]="Error",n.prototype.toString=function(){return`${this.name} [${this.code}]: ${this.message}`},Ks(n,r),n}var Ln={createError:we,AVV_ERR_EXPOSE_ALREADY_DEFINED:we("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' () is already defined, specify an expose option"),AVV_ERR_CALLBACK_NOT_FN:we("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:we("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:we("AVV_ERR_PLUGIN_NOT_VALID","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:we("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:we("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")},zs=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(`
11
+ `)+" "+g[1]:g[0]+p+" "+l.join(", ")+" "+g[1]}t.types=yn;function O(l){return Array.isArray(l)}t.isArray=O;function D(l){return typeof l=="boolean"}t.isBoolean=D;function $(l){return l===null}t.isNull=$;function G(l){return l==null}t.isNullOrUndefined=G;function W(l){return typeof l=="number"}t.isNumber=W;function P(l){return typeof l=="string"}t.isString=P;function V(l){return typeof l=="symbol"}t.isSymbol=V;function E(l){return l===void 0}t.isUndefined=E;function Z(l){return ee(l)&&ye(l)==="[object RegExp]"}t.isRegExp=Z,t.types.isRegExp=Z;function ee(l){return typeof l=="object"&&l!==null}t.isObject=ee;function Ce(l){return ee(l)&&ye(l)==="[object Date]"}t.isDate=Ce,t.types.isDate=Ce;function ve(l){return ee(l)&&(ye(l)==="[object Error]"||l instanceof Error)}t.isError=ve,t.types.isNativeError=ve;function oe(l){return typeof l=="function"}t.isFunction=oe;function It(l){return l===null||typeof l=="boolean"||typeof l=="number"||typeof l=="string"||typeof l=="symbol"||typeof l>"u"}t.isPrimitive=It,t.isBuffer=Gs;function ye(l){return Object.prototype.toString.call(l)}function Ge(l){return l<10?"0"+l.toString(10):l.toString(10)}var _e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ot(){var l=new Date,p=[Ge(l.getHours()),Ge(l.getMinutes()),Ge(l.getSeconds())].join(":");return[l.getDate(),_e[l.getMonth()],p].join(" ")}t.log=function(){console.log("%s - %s",Ot(),t.format.apply(t,arguments))},t.inherits=Ks,t._extend=function(l,p){if(!p||!ee(p))return l;for(var g=Object.keys(p),S=g.length;S--;)l[g[S]]=p[g[S]];return l};function Le(l,p){return Object.prototype.hasOwnProperty.call(l,p)}var se=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(p){if(typeof p!="function")throw new TypeError('The "original" argument must be of type Function');if(se&&p[se]){var g=p[se];if(typeof g!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(g,se,{value:g,enumerable:!1,writable:!1,configurable:!0}),g}function g(){for(var S,L,k=new Promise(function(N,K){S=N,L=K}),T=[],_=0;_<arguments.length;_++)T.push(arguments[_]);T.push(function(N,K){N?L(N):S(K)});try{p.apply(this,T)}catch(N){L(N)}return k}return Object.setPrototypeOf(g,Object.getPrototypeOf(p)),se&&Object.defineProperty(g,se,{value:g,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(g,e(p))},t.promisify.custom=se;function ke(l,p){if(!l){var g=new Error("Promise was rejected with a falsy value");g.reason=l,l=g}return p(l)}function et(l){if(typeof l!="function")throw new TypeError('The "original" argument must be of type Function');function p(){for(var g=[],S=0;S<arguments.length;S++)g.push(arguments[S]);var L=g.pop();if(typeof L!="function")throw new TypeError("The last argument must be of type Function");var k=this,T=function(){return L.apply(k,arguments)};l.apply(this,g).then(function(_){w.nextTick(T.bind(null,null,_))},function(_){w.nextTick(ke.bind(null,_,T))})}return Object.setPrototypeOf(p,Object.getPrototypeOf(l)),Object.defineProperties(p,e(l)),p}t.callbackify=et})(At);const{inherits:zs,format:Dt}=At;function we(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=Dt(e,i,o,s):i&&o?this.message=Dt(e,i,o):i?this.message=Dt(e,i):this.message=e}return n.prototype[Symbol.toStringTag]="Error",n.prototype.toString=function(){return`${this.name} [${this.code}]: ${this.message}`},zs(n,r),n}var Pn={createError:we,AVV_ERR_EXPOSE_ALREADY_DEFINED:we("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' () is already defined, specify an expose option"),AVV_ERR_CALLBACK_NOT_FN:we("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:we("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:we("AVV_ERR_PLUGIN_NOT_VALID","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:we("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:we("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")},Hs=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,f=u.nodes&&u.nodes.length,y=r+(c?" ":i("│"))+" ";return r+i(c?"└":"├")+i("─")+i(f?"┬":"─")+" "+t(u,y,n).slice(r.length+2)}).join("")};const Hs=zs,jr=Symbol("avvio.TimeTree.untrackNode"),Rt=Symbol("avvio.TimeTree.trackNode"),qr=Symbol("avvio.TimeTree.getParent"),Ur=Symbol("avvio.TimeTree.getNode"),Mr=Symbol("avvio.TimeTree.addNode");let Ws=class{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[Rt](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])}[jr](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)}[qr](e){if(e===null)return this.root;const r=this.tableLabel.get(e);return r.id?r:r[r.length-1]}[Ur](e){return this.tableId.get(e)}[Mr](e,r,n){if(e===null)return this.root={id:"root",label:r,start:n,nodes:[]},this[Rt](this.root),this.root.id;const o=this[qr](e),s=`${r}-${Math.random()}`,a={id:s,parent:e,start:n,label:r,nodes:[]};return o.nodes.push(a),this[Rt](a),s}start(e,r,n=Date.now()){return this[Mr](e,r,n)}stop(e,r=Date.now()){const n=this[Ur](e);n&&(n.stop=r,n.diff=n.stop-n.start||0,this[jr](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 Hs(r)}};var Js=Ws,fr={exports:{}},er={exports:{}},Vt,xr;function Ys(){if(xr)return Vt;xr=1;var t=1e3,e=t*60,r=e*60,n=r*24,i=n*7,o=n*365.25;Vt=function(c,f){f=f||{};var y=typeof c;if(y==="string"&&c.length>0)return s(c);if(y==="number"&&isFinite(c))return f.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 f=/^(-?(?:\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(f){var y=parseFloat(f[1]),m=(f[2]||"ms").toLowerCase();switch(m){case"years":case"year":case"yrs":case"yr":case"y":return y*o;case"weeks":case"week":case"w":return y*i;case"days":case"day":case"d":return y*n;case"hours":case"hour":case"hrs":case"hr":case"h":return y*r;case"minutes":case"minute":case"mins":case"min":case"m":return y*e;case"seconds":case"second":case"secs":case"sec":case"s":return y*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return y;default:return}}}}function a(c){var f=Math.abs(c);return f>=n?Math.round(c/n)+"d":f>=r?Math.round(c/r)+"h":f>=e?Math.round(c/e)+"m":f>=t?Math.round(c/t)+"s":c+"ms"}function u(c){var f=Math.abs(c);return f>=n?d(c,f,n,"day"):f>=r?d(c,f,r,"hour"):f>=e?d(c,f,e,"minute"):f>=t?d(c,f,t,"second"):c+" ms"}function d(c,f,y,m){var b=f>=y*1.5;return Math.round(c/y)+" "+m+(b?"s":"")}return Vt}function Xs(t){r.debug=r,r.default=r,r.coerce=u,r.disable=o,r.enable=i,r.enabled=s,r.humanize=Ys(),r.destroy=d,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let f=0;for(let y=0;y<c.length;y++)f=(f<<5)-f+c.charCodeAt(y),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(c){let f,y=null,m,b;function O(...I){if(!O.enabled)return;const D=O,j=Number(new Date),G=j-(f||j);D.diff=G,D.prev=f,D.curr=j,f=j,I[0]=r.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let W=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(V,E)=>{if(V==="%%")return"%";W++;const Z=r.formatters[E];if(typeof Z=="function"){const ee=I[W];V=Z.call(D,ee),I.splice(W,1),W--}return V}),r.formatArgs.call(D,I),(D.log||r.log).apply(D,I)}return O.namespace=c,O.useColors=r.useColors(),O.color=r.selectColor(c),O.extend=n,O.destroy=r.destroy,Object.defineProperty(O,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(m!==r.namespaces&&(m=r.namespaces,b=r.enabled(c)),b),set:I=>{y=I}}),typeof r.init=="function"&&r.init(O),O}function n(c,f){const y=r(this.namespace+(typeof f>"u"?":":f)+c);return y.log=this.log,y}function i(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let f;const y=(typeof c=="string"?c:"").split(/[\s,]+/),m=y.length;for(f=0;f<m;f++)y[f]&&(c=y[f].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(f=>"-"+f)].join(",");return r.enable(""),c}function s(c){if(c[c.length-1]==="*")return!0;let f,y;for(f=0,y=r.skips.length;f<y;f++)if(r.skips[f].test(c))return!1;for(f=0,y=r.names.length;f<y;f++)if(r.names[f].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 Zs=Xs;(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,f=0;u[0].replace(/%[a-zA-Z%]/g,y=>{y!=="%%"&&(c++,y==="%c"&&(f=c))}),u.splice(f,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 w<"u"&&"env"in w&&(u=w.env.DEBUG),u}function s(){try{return localStorage}catch{}}t.exports=Zs(e);const{formatters:a}=t.exports;a.j=function(u){try{return JSON.stringify(u)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(er,er.exports);var Pn=er.exports;const ea=nn,ta=pn.EventEmitter,ra=Tt.inherits,M=Pn("avvio"),{AVV_ERR_READY_TIMEOUT:na}=Ln,$t=Symbol.for("plugin-meta");function ia(t,e){return t[$t]&&t[$t].name?t[$t].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 oa(){const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function Qe(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=ia(e,r),this.isAfter=n,this.q=ea(t,sa,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}ra(Qe,ta);Qe.prototype.exec=function(t,e){const r=this.func;let n=!1;const i=this.name;if(this.parent._error&&!this.isAfter){M("skipping loading of plugin as parent errored and it is not an after",i),w.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,r,this.opts)}catch(u){return M("override errored",i),e(u)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,M("exec",i);let o;const s=u=>{if(n){M("loading complete",i);return}this._error=u,M(u?"exec errored":"exec completed",i),n=!0,o&&clearTimeout(o),e(u)};this.timeout>0&&(M("setting up timeout",i,this.timeout),o=setTimeout(function(){M("timed out",i),o=null;const u=new na(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"&&(M("exec: resolving promise",i),a.then(()=>w.nextTick(s),u=>w.nextTick(s,u)))};Qe.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((r,n)=>{this._error=r,this.q.pause(),r?(M("rejecting promise",this.name,r),this._promise.reject(r)):(M("resolving promise",this.name),this._promise.resolve()),this._promise=null,w.nextTick(n,r)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=oa(),e=this._promise.promise,this.server?t():this.on("start",t)),e};Qe.prototype.enqueue=function(t,e){M("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};Qe.prototype.finish=function(t,e){M("finish",this.name,t);const r=()=>{this.loaded||(M("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(M("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const i=()=>{M("wrap"),queueMicrotask(n)};this._promise.resolve(),this._promise.promise.then(i,i),this._promise=null}else r();else M("delayed",this.name),this.q.drain=()=>{M("drain",this.name),this.q.drain=aa,queueMicrotask(n)}};queueMicrotask(n),this.q.resume()};function sa(t,e){const r=this;w.nextTick(pr.bind(r),t,e)}function pr(t,e){if(typeof t.func.then=="function"){t.func.then(n=>{typeof n.default=="function"&&(n=n.default),t.func=n,pr.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 aa(){}fr.exports=Qe;fr.exports.loadPlugin=pr;var ua=fr.exports;const Br=nn,ca=pn.EventEmitter,la=Tt.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:jt,AVV_ERR_CALLBACK_NOT_FN:Je,AVV_ERR_PLUGIN_NOT_VALID:da,AVV_ERR_ROOT_PLG_BOOTED:fa,AVV_ERR_READY_TIMEOUT:pa}=Ln,ha=Js,tr=ua,xe=Pn("avvio"),vt=Symbol("kAvvio"),qt=Symbol("kThenifyDoNotWrap");function ya(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 jt(i);if(t[o])throw new jt(o);if(t[s])throw new jt(s);t[i]=function(d,c){return r.use(d,c),this},Object.defineProperty(t,"then",{get:Fn.bind(r)}),t[vt]=!0,t[o]=function(d){return typeof d!="function"?r._loadRegistered():(r.after(Ut(d,this)),this)},t[s]=function(d){if(d&&typeof d!="function")throw new Je(s,typeof d);return r.ready(d?Ut(d,this):void 0)},t[a]=function(d){if(typeof d!="function")throw new Je(a,typeof d);return r.onClose(Sa(d,this)),this},t[u]=function(d){if(d&&typeof d!="function")throw new Je(u,typeof d);return d?(r.close(Ut(d,this)),this):r.close()}}function B(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 B)){const n=new B(t,e,r);return t&&ya(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 ha,this._readyQ=Br(this,Nn,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=Qr},this._closeQ=Br(this,ba,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=Qr},this._doStart=null,this._root=new tr(this,ga.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)})}),tr.loadPlugin.call(this,this._root,n=>{xe("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 ga(t,e,r){this._doStart=r,e.autostart&&this.start()}la(B,ca);B.prototype.start=function(){return this.started=!0,w.nextTick(this._doStart),this};B.prototype.override=function(t,e,r){return t};function ma(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new da(typeof t);return t}B.prototype[vt]=!0;B.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};B.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&w.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(B.prototype,"then",{get:Fn});B.prototype._addPlugin=function(t,e,r){if(t=ma(t),e=e||{},this.booted)throw new fa;const n=this._current[0],i=new tr(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,f)=>{this.pluginTree.stop(u,f)})}),n.loaded)throw new Error(i.name,n.name);return n.enqueue(i,o=>{o&&(this._error=o)}),i};B.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(r,n,i){Nn.call(this,t,i)}return this};B.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};B.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new Je("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),w.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};B.prototype.ready=function(t){if(t){if(typeof t!="function")throw new Je("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),w.nextTick(a)}})};B.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};B.prototype.toJSON=function(){return this.pluginTree.toJSON()};function Qr(){}function Fn(){if(this.booted){xe("thenify returning null because we are already booted");return}if(this[qt]){this[qt]=!1;return}return xe("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[qt]=!0,t(this._server)),e)}function Nn(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[vt]&&typeof i.then=="function"?i.then(()=>w.nextTick(e),o=>w.nextTick(e,o)):w.nextTick(e);else if(t.length===1)i=t(n),i&&!i[vt]&&typeof i.then=="function"?i.then(()=>w.nextTick(e),o=>w.nextTick(e,o)):w.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 va.call(this,t,n,r,e)}function va(t,e,r,n){const i=t.name;xe("setting up ready timeout",i,this._timeout);let o=setTimeout(()=>{xe("timed out",i),o=null;const a=new pa(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 ba(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"?(xe("resolving close/onClose promise"),i.then(()=>w.nextTick(e),o=>w.nextTick(e,o))):w.nextTick(e)}else t.length===2?t(n?r:this._error,e):n?t(r,e):t(this._error,r,e)}function Sa(t,e){return r.bind(e);function r(n,i){let o;t.length===0?(o=t(),o&&o.then?o.then(function(){w.nextTick(i)},i):w.nextTick(i)):t.length===1?(o=t(this),o&&o.then?o.then(function(){w.nextTick(i)},i):w.nextTick(i)):t(this,i)}}function Ut(t,e){return r.bind(e);function r(n,i){let o;t?t.length===0?(o=t(),o&&o.then?o.then(function(){w.nextTick(i,n)},i):w.nextTick(i,n)):t.length===1?(o=t(n),o&&o.then?o.then(function(){w.nextTick(i)},i):w.nextTick(i)):t.length===2?t(n,i):t(n,this,i):w.nextTick(i)}}nr.exports=B;nr.exports.express=function(t){return B(t,{expose:{use:"load"}})};var wa=nr.exports;const Aa=fo(wa);(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 Ta(t,e=!0,r=!0,n){console.log("start sdk");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=Aa(Object.create({}),{autostart:!1});return s.use(Qi),s.use(qi,{onDeepLinkHandled:n?.onDeepLinkHandled}),s.use(Bi,{videoPlayerController:n?.videoPlayerController}),s.use(di,{sdkKey:t,host:i,analyticsHost:o,version:n?.version}),s.use(gi),s.use(xi),s.use(ro),s.use(Li),s.use(lo),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=Ta;
14
+ `+o.map(function(u,d){var c=d===o.length-1,f=u.nodes&&u.nodes.length,h=r+(c?" ":i("│"))+" ";return r+i(c?"└":"├")+i("─")+i(f?"┬":"─")+" "+t(u,h,n).slice(r.length+2)}).join("")};const Ws=Hs,jr=Symbol("avvio.TimeTree.untrackNode"),Rt=Symbol("avvio.TimeTree.trackNode"),Mr=Symbol("avvio.TimeTree.getParent"),Ur=Symbol("avvio.TimeTree.getNode"),qr=Symbol("avvio.TimeTree.addNode");let Js=class{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[Rt](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])}[jr](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)}[Mr](e){if(e===null)return this.root;const r=this.tableLabel.get(e);return r.id?r:r[r.length-1]}[Ur](e){return this.tableId.get(e)}[qr](e,r,n){if(e===null)return this.root={id:"root",label:r,start:n,nodes:[]},this[Rt](this.root),this.root.id;const o=this[Mr](e),s=`${r}-${Math.random()}`,a={id:s,parent:e,start:n,label:r,nodes:[]};return o.nodes.push(a),this[Rt](a),s}start(e,r,n=Date.now()){return this[qr](e,r,n)}stop(e,r=Date.now()){const n=this[Ur](e);n&&(n.stop=r,n.diff=n.stop-n.start||0,this[jr](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 Ws(r)}};var Ys=Js,fr={exports:{}},er={exports:{}},Vt,xr;function Xs(){if(xr)return Vt;xr=1;var t=1e3,e=t*60,r=e*60,n=r*24,i=n*7,o=n*365.25;Vt=function(c,f){f=f||{};var h=typeof c;if(h==="string"&&c.length>0)return s(c);if(h==="number"&&isFinite(c))return f.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 f=/^(-?(?:\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(f){var h=parseFloat(f[1]),m=(f[2]||"ms").toLowerCase();switch(m){case"years":case"year":case"yrs":case"yr":case"y":return h*o;case"weeks":case"week":case"w":return h*i;case"days":case"day":case"d":return h*n;case"hours":case"hour":case"hrs":case"hr":case"h":return h*r;case"minutes":case"minute":case"mins":case"min":case"m":return h*e;case"seconds":case"second":case"secs":case"sec":case"s":return h*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}function a(c){var f=Math.abs(c);return f>=n?Math.round(c/n)+"d":f>=r?Math.round(c/r)+"h":f>=e?Math.round(c/e)+"m":f>=t?Math.round(c/t)+"s":c+"ms"}function u(c){var f=Math.abs(c);return f>=n?d(c,f,n,"day"):f>=r?d(c,f,r,"hour"):f>=e?d(c,f,e,"minute"):f>=t?d(c,f,t,"second"):c+" ms"}function d(c,f,h,m){var b=f>=h*1.5;return Math.round(c/h)+" "+m+(b?"s":"")}return Vt}function Zs(t){r.debug=r,r.default=r,r.coerce=u,r.disable=o,r.enable=i,r.enabled=s,r.humanize=Xs(),r.destroy=d,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let f=0;for(let h=0;h<c.length;h++)f=(f<<5)-f+c.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(c){let f,h=null,m,b;function C(...O){if(!C.enabled)return;const D=C,$=Number(new Date),G=$-(f||$);D.diff=G,D.prev=f,D.curr=$,f=$,O[0]=r.coerce(O[0]),typeof O[0]!="string"&&O.unshift("%O");let W=0;O[0]=O[0].replace(/%([a-zA-Z%])/g,(V,E)=>{if(V==="%%")return"%";W++;const Z=r.formatters[E];if(typeof Z=="function"){const ee=O[W];V=Z.call(D,ee),O.splice(W,1),W--}return V}),r.formatArgs.call(D,O),(D.log||r.log).apply(D,O)}return C.namespace=c,C.useColors=r.useColors(),C.color=r.selectColor(c),C.extend=n,C.destroy=r.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(m!==r.namespaces&&(m=r.namespaces,b=r.enabled(c)),b),set:O=>{h=O}}),typeof r.init=="function"&&r.init(C),C}function n(c,f){const h=r(this.namespace+(typeof f>"u"?":":f)+c);return h.log=this.log,h}function i(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let f;const h=(typeof c=="string"?c:"").split(/[\s,]+/),m=h.length;for(f=0;f<m;f++)h[f]&&(c=h[f].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(f=>"-"+f)].join(",");return r.enable(""),c}function s(c){if(c[c.length-1]==="*")return!0;let f,h;for(f=0,h=r.skips.length;f<h;f++)if(r.skips[f].test(c))return!1;for(f=0,h=r.names.length;f<h;f++)if(r.names[f].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 ea=Zs;(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,f=0;u[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(c++,h==="%c"&&(f=c))}),u.splice(f,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 w<"u"&&"env"in w&&(u=w.env.DEBUG),u}function s(){try{return localStorage}catch{}}t.exports=ea(e);const{formatters:a}=t.exports;a.j=function(u){try{return JSON.stringify(u)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(er,er.exports);var Fn=er.exports;const ta=on,ra=hn.EventEmitter,na=At.inherits,q=Fn("avvio"),{AVV_ERR_READY_TIMEOUT:ia}=Pn,$t=Symbol.for("plugin-meta");function oa(t,e){return t[$t]&&t[$t].name?t[$t].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 sa(){const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function Qe(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=oa(e,r),this.isAfter=n,this.q=ta(t,aa,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}na(Qe,ra);Qe.prototype.exec=function(t,e){const r=this.func;let n=!1;const i=this.name;if(this.parent._error&&!this.isAfter){q("skipping loading of plugin as parent errored and it is not an after",i),w.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,r,this.opts)}catch(u){return q("override errored",i),e(u)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,q("exec",i);let o;const s=u=>{if(n){q("loading complete",i);return}this._error=u,q(u?"exec errored":"exec completed",i),n=!0,o&&clearTimeout(o),e(u)};this.timeout>0&&(q("setting up timeout",i,this.timeout),o=setTimeout(function(){q("timed out",i),o=null;const u=new ia(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"&&(q("exec: resolving promise",i),a.then(()=>w.nextTick(s),u=>w.nextTick(s,u)))};Qe.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((r,n)=>{this._error=r,this.q.pause(),r?(q("rejecting promise",this.name,r),this._promise.reject(r)):(q("resolving promise",this.name),this._promise.resolve()),this._promise=null,w.nextTick(n,r)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=sa(),e=this._promise.promise,this.server?t():this.on("start",t)),e};Qe.prototype.enqueue=function(t,e){q("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};Qe.prototype.finish=function(t,e){q("finish",this.name,t);const r=()=>{this.loaded||(q("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(q("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const i=()=>{q("wrap"),queueMicrotask(n)};this._promise.resolve(),this._promise.promise.then(i,i),this._promise=null}else r();else q("delayed",this.name),this.q.drain=()=>{q("drain",this.name),this.q.drain=ua,queueMicrotask(n)}};queueMicrotask(n),this.q.resume()};function aa(t,e){const r=this;w.nextTick(pr.bind(r),t,e)}function pr(t,e){if(typeof t.func.then=="function"){t.func.then(n=>{typeof n.default=="function"&&(n=n.default),t.func=n,pr.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 ua(){}fr.exports=Qe;fr.exports.loadPlugin=pr;var ca=fr.exports;const Br=on,la=hn.EventEmitter,da=At.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:jt,AVV_ERR_CALLBACK_NOT_FN:Je,AVV_ERR_PLUGIN_NOT_VALID:fa,AVV_ERR_ROOT_PLG_BOOTED:pa,AVV_ERR_READY_TIMEOUT:ha}=Pn,ya=Ys,tr=ca,xe=Fn("avvio"),bt=Symbol("kAvvio"),Mt=Symbol("kThenifyDoNotWrap");function ga(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 jt(i);if(t[o])throw new jt(o);if(t[s])throw new jt(s);t[i]=function(d,c){return r.use(d,c),this},Object.defineProperty(t,"then",{get:Nn.bind(r)}),t[bt]=!0,t[o]=function(d){return typeof d!="function"?r._loadRegistered():(r.after(Ut(d,this)),this)},t[s]=function(d){if(d&&typeof d!="function")throw new Je(s,typeof d);return r.ready(d?Ut(d,this):void 0)},t[a]=function(d){if(typeof d!="function")throw new Je(a,typeof d);return r.onClose(wa(d,this)),this},t[u]=function(d){if(d&&typeof d!="function")throw new Je(u,typeof d);return d?(r.close(Ut(d,this)),this):r.close()}}function B(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 B)){const n=new B(t,e,r);return t&&ga(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 ya,this._readyQ=Br(this,Dn,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=Qr},this._closeQ=Br(this,Sa,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=Qr},this._doStart=null,this._root=new tr(this,ma.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)})}),tr.loadPlugin.call(this,this._root,n=>{xe("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 ma(t,e,r){this._doStart=r,e.autostart&&this.start()}da(B,la);B.prototype.start=function(){return this.started=!0,w.nextTick(this._doStart),this};B.prototype.override=function(t,e,r){return t};function ba(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new fa(typeof t);return t}B.prototype[bt]=!0;B.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};B.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&w.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(B.prototype,"then",{get:Nn});B.prototype._addPlugin=function(t,e,r){if(t=ba(t),e=e||{},this.booted)throw new pa;const n=this._current[0],i=new tr(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,f)=>{this.pluginTree.stop(u,f)})}),n.loaded)throw new Error(i.name,n.name);return n.enqueue(i,o=>{o&&(this._error=o)}),i};B.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(r,n,i){Dn.call(this,t,i)}return this};B.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};B.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new Je("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),w.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};B.prototype.ready=function(t){if(t){if(typeof t!="function")throw new Je("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),w.nextTick(a)}})};B.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};B.prototype.toJSON=function(){return this.pluginTree.toJSON()};function Qr(){}function Nn(){if(this.booted){xe("thenify returning null because we are already booted");return}if(this[Mt]){this[Mt]=!1;return}return xe("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[Mt]=!0,t(this._server)),e)}function Dn(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[bt]&&typeof i.then=="function"?i.then(()=>w.nextTick(e),o=>w.nextTick(e,o)):w.nextTick(e);else if(t.length===1)i=t(n),i&&!i[bt]&&typeof i.then=="function"?i.then(()=>w.nextTick(e),o=>w.nextTick(e,o)):w.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 va.call(this,t,n,r,e)}function va(t,e,r,n){const i=t.name;xe("setting up ready timeout",i,this._timeout);let o=setTimeout(()=>{xe("timed out",i),o=null;const a=new ha(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 Sa(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"?(xe("resolving close/onClose promise"),i.then(()=>w.nextTick(e),o=>w.nextTick(e,o))):w.nextTick(e)}else t.length===2?t(n?r:this._error,e):n?t(r,e):t(this._error,r,e)}function wa(t,e){return r.bind(e);function r(n,i){let o;t.length===0?(o=t(),o&&o.then?o.then(function(){w.nextTick(i)},i):w.nextTick(i)):t.length===1?(o=t(this),o&&o.then?o.then(function(){w.nextTick(i)},i):w.nextTick(i)):t(this,i)}}function Ut(t,e){return r.bind(e);function r(n,i){let o;t?t.length===0?(o=t(),o&&o.then?o.then(function(){w.nextTick(i,n)},i):w.nextTick(i,n)):t.length===1?(o=t(n),o&&o.then?o.then(function(){w.nextTick(i)},i):w.nextTick(i)):t.length===2?t(n,i):t(n,this,i):w.nextTick(i)}}nr.exports=B;nr.exports.express=function(t){return B(t,{expose:{use:"load"}})};var Ta=nr.exports;const Aa=po(Ta);(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 Ea(t,e=!0,r=!0,n){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=Aa(Object.create({}),{autostart:!1});return s.use(Qi),s.use(Mi,{onDeepLinkHandled:n?.onDeepLinkHandled}),s.use(Bi,{videoPlayerController:n?.videoPlayerController}),s.use(fi,{sdkKey:t,host:i,analyticsHost:o,version:n?.version}),s.use(mi),s.use(xi),s.use(no),s.use(ki),s.use(fo),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=Ea;