@streamlayer/sdk-web 1.18.6 → 1.18.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/{index-BoZVPkJu.js → index-Bqs5eyxf.js} +2839 -2673
- package/lib/{index-B15M-YGv.cjs → index-C05fK_bk.cjs} +1 -1
- package/lib/{index-CfSdnrfA.js → index-D8wyDNJD.js} +1 -1
- package/lib/index-_D2y5RqC.cjs +15 -0
- package/package.json +13 -13
- package/lib/index-Bc5bp7_1.cjs +0 -15
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";const bo=require("pino"),I=require("@streamlayer/sl-eslib/interactive/interactive.common_pb"),ie=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb"),z=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),it=require("@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb"),ce=require("nanostores"),Be=require("uuid"),X=require("@connectrpc/connect"),Wr=require("@connectrpc/connect-web"),Kr=require("@nanostores/query"),_i=require("@streamlayer/sl-eslib/sports/events/events_pb"),Je=require("@streamlayer/sl-eslib/sdkSettings/client/client_pb"),Vr=require("@streamlayer/sl-eslib/users/users_pb"),Di=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb"),ze=require("@streamlayer/sl-eslib/sdkSettings/organization/webhooks/organization.webhooks_pb"),To=require("@streamlayer/sl-eslib/shortLinks/linksClient_pb"),Hr=require("@streamlayer/sl-eslib/polymarket/sportsClient_pb"),A=require("@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb"),Fi=require("@streamlayer/sl-eslib/analytics/v2/streaming/streaming_pb"),$r=require("@streamlayer/sl-eslib/analytics/v1/interactions/interactions_pb"),he=require("@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb");function Ao(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ui={exports:{}},Z=Ui.exports={},ve,be;function Cr(){throw new Error("setTimeout has not been defined")}function Lr(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?ve=setTimeout:ve=Cr}catch{ve=Cr}try{typeof clearTimeout=="function"?be=clearTimeout:be=Lr}catch{be=Lr}})();function Vi(t){if(ve===setTimeout)return setTimeout(t,0);if((ve===Cr||!ve)&&setTimeout)return ve=setTimeout,setTimeout(t,0);try{return ve(t,0)}catch{try{return ve.call(null,t,0)}catch{return ve.call(this,t,0)}}}function So(t){if(be===clearTimeout)return clearTimeout(t);if((be===Lr||!be)&&clearTimeout)return be=clearTimeout,clearTimeout(t);try{return be(t)}catch{try{return be.call(null,t)}catch{return be.call(this,t)}}}var Oe=[],Qe=!1,_e,ht=-1;function Eo(){!Qe||!_e||(Qe=!1,_e.length?Oe=_e.concat(Oe):ht=-1,Oe.length&&xi())}function xi(){if(!Qe){var t=Vi(Eo);Qe=!0;for(var e=Oe.length;e;){for(_e=Oe,Oe=[];++ht<e;)_e&&_e[ht].run();ht=-1,e=Oe.length}_e=null,Qe=!1,So(t)}}Z.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];Oe.push(new qi(t,e)),Oe.length===1&&!Qe&&Vi(xi)};function qi(t,e){this.fun=t,this.array=e}qi.prototype.run=function(){this.fun.apply(null,this.array)};Z.title="browser";Z.browser=!0;Z.env={};Z.argv=[];Z.version="";Z.versions={};function Ne(){}Z.on=Ne;Z.addListener=Ne;Z.once=Ne;Z.off=Ne;Z.removeListener=Ne;Z.removeAllListeners=Ne;Z.emit=Ne;Z.prependListener=Ne;Z.prependOnceListener=Ne;Z.listeners=function(t){return[]};Z.binding=function(t){throw new Error("process.binding is not supported")};Z.cwd=function(){return"/"};Z.chdir=function(t){throw new Error("process.chdir is not supported")};Z.umask=function(){return 0};var wo=Ui.exports;const B=Ao(wo),Io=bo.pino({level:"trace",enabled:typeof window<"u"&&!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),le=(t,e)=>Io.child({name:t},e);class Oo extends Event{slEventBus;constructor(e,n){super(e),this.slEventBus=n}}const ko=le("event-bus");class No{name;listeners;constructor(e="sl-event-bus"){this.name=e,this.listeners=new Set}emit=(e,n)=>{const r=new Oo(this.name,{...n,type:e});ko.debug(r,"Emitting event"),window.dispatchEvent(r)};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 Ro{}var ke;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(ke||(ke={}));window.slStore=Object.create(null);class vt{store;name;constructor(e,n){this.store=e,this.name=n}getStore(){return this.store}}const Po=t=>{const e=Object.keys(t);return ce.computed(e.map(n=>t[n].getStore()),(...n)=>Object.fromEntries(e.map((r,i)=>[r,n[i]])))};class De extends vt{getValues=()=>this.getStore().get();getValue=e=>this.getStore().get()[e];setValue=(e,n)=>this.getStore().setKey(e,n);subscribe=(...e)=>this.getStore().subscribe(...e);unsubscribe=()=>this.getStore().off()}const ue=t=>ce.map(t);var Ee;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(Ee||(Ee={}));const Co={[z.SdkOverlayType.BETTING]:"betting",[z.SdkOverlayType.GAMES]:"games",[z.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[z.SdkOverlayType.TWITTER]:"twitter"};var Ce;(function(t){t.Ready="ready",t.Suspended="suspended"})(Ce||(Ce={}));const Lo=new Set(["equals","clone","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","getType"]);class Bi{status;listeners=new Set;constructor(){this.status=ce.atom(Ce.Suspended)}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(Ce.Ready)};disable=()=>{this.status.set(Ce.Suspended)};fireEvent(e){for(const n of this.listeners.values())try{n.onEvent(e)}catch(r){console.error(r)}}}class Mi{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...n},r){this.settingsKey=Co[n.type],this.status=ce.atom(Ce.Suspended),this.config=new De(ue(n),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new De(ue(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new De(ue({}),`feature:settings:${this.settingsKey}`),this.source=r}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(Ce.Ready)};disable=()=>{this.status.set(Ce.Suspended)};setFeatureConfig=({settings:e,...n})=>{let r;for(r in n)this.config.setValue(r,n[r]);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)!Lo.has(o)&&i[o]&&this.settings.setValue(o,i[o])}}};update=(e,n)=>{this.source===Ee.STREAM&&n===Ee.ORGANIZATION||(this.setFeatureConfig(e),this.source=n)};fireEvent(e){for(const n of this.listeners.values())try{n.onEvent(e)}catch(r){console.error(r)}}}class de 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 J=t=>ce.atom(t);class me extends vt{atomStore;pendingGetValue=null;constructor(e,n,r){super(e,`api:${n}`),this.atomStore=ce.atom(),r&&e.subscribe(i=>{const o=this.atomStore.get(),s=r(i,o);o!==s&&this.atomStore.set(s)})}getAtomStore=()=>this.atomStore;isEnabled=()=>this.getStore().key!==void 0;getValue=()=>{const e=this.getStore(),n=async()=>(await e.fetch())?.data??e.get().data;return e.key?n():this.pendingGetValue?this.pendingGetValue:(this.pendingGetValue=new Promise((r,i)=>{let o=!1,s=null;const a=setTimeout(()=>{o||(o=!0,s?.(),this.pendingGetValue=null,console.warn(`[ApiStore.getValue] ${this.name}: timed out waiting for store key`),r(void 0))},1e3);s=e.listen(()=>{!e.key||o||(o=!0,clearTimeout(a),s?.(),this.pendingGetValue=null,n().then(r,i))}),o?s():e.key&&(o=!0,clearTimeout(a),s(),this.pendingGetValue=null,n().then(r,i))}),this.pendingGetValue)};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 H=new No;async function*_o(t,e){for await(const n of e){t.response.message=n,t.received_at=Date.now(),t.id=Date.now();const r={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(r),yield n}}const Do=()=>t=>async e=>{const n={id:Date.now(),name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries()),message:e.message},response:{}};try{window.postMessage({type:"__GRPC_DEVTOOLS_EXTENSION__",data:n})}catch(r){console.log("devtools error",r)}try{const r=await t(e);if(n.received_at=Date.now(),n.response.header=Object.fromEntries(r.header.entries()),n.response.trailer=Object.fromEntries(r.trailer.entries()),e.stream){const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...n,stream:!0}};try{window.postMessage(i)}catch(o){console.log("devtools error",o)}return{...r,message:_o(n,r.message)}}else{n.response.message=r.message,n.latency=n.received_at-n.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:n};try{window.postMessage(i)}catch(o){console.log("devtools error",o)}}return r}catch(r){n.received_at=Date.now(),n.response.trailer={"grpc-status":r.code,"grpc-message":r.rawMessage},n.response.message=r.rawMessage,n.latency=n.received_at-n.sent_at;const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:n};try{window.postMessage(i)}catch(o){console.log("devtools error",o)}throw r}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));function ji(t){return t instanceof DOMException&&(t.code===22||t.code===1014||t.name==="QuotaExceededError"||t.name==="NS_ERROR_DOM_QUOTA_REACHED")}class We{delimiter=":";prefix;storage;constructor(e="main",n=window.localStorage){this.prefix=`sl-sdk${this.delimiter}${e}`,this.storage=n}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 n=e.pop()||"",r=this.generateKey(e);try{this.storage.setItem(r,n)}catch(i){ji(i)&&this.storage===window.sessionStorage&&(window.sessionStorage.removeItem("slstreamlogs"),this.storage.setItem(r,n))}};read=(...e)=>{const n=this.storage.getItem(this.generateKey(e));return n===null?void 0:n};remove=(...e)=>{this.storage.removeItem(this.generateKey(e))}}var fe;(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"})(fe||(fe={}));const zr=le("grpc:stream");class Fo{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,n,r,i){const o={status:fe.Init,ts:new Date,log:[]};this.state=new De(ue(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=r,this.method=n,i.withStore&&(this.store=new de(J(null),`subscription:${i.name}:store`)),"subscribe"in r&&typeof r.subscribe=="function"&&(this.paramsListener=r.subscribe(s=>{this.state.getValue("status")===fe.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`),this.reconnect())})),this.updateState(fe.Ready)}updateState=e=>{this.state.setValue("status",e),this.state.setValue("ts",new Date),this.addStateLog(`status => ${e}`)};addStateLog=e=>{const n=this.state.getStore().get().log,r=`${this.options.name} ${new Date().toISOString()}: ${e}`;if(n.push(r),this.state.setValue("log",n),localStorage.getItem("SL_DEBUG")){e.startsWith("received data")?zr.trace({name:this.options.name,attempt:this.attempt},"received data"):zr.trace({name:this.options.name,attempt:this.attempt},e);try{window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
|
|
2
|
+
`+r)}catch(i){ji(i)&&window.sessionStorage.removeItem("slstreamlogs"),window.sessionStorage.setItem("slstreamlogs",r)}}};addListener=(e,n)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),()=>{}):(this.listeners.set(e,n),this.addStateLog(`listener '${e}' added`),()=>this.removeListener(e));removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(fe.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 r={headers:this.headers.getValues(),signal:this.streamCancel.signal},i=this.method(e,r);for await(const o of i)this.attempt=0,this.onData(o)}catch(r){r instanceof X.ConnectError&&r.code!=X.Code.Canceled&&this.onStreamError(r)}})(),this.updateState(fe.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(fe.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(fe.Reconnect);const e=Math.min(this.options.reconnectMaxDelay,Math.pow(2,this.attempt)*this.options.reconnectDelay),n=Math.round(e*(1+Math.random())/2);this.reconnectTimeout=setTimeout(()=>{this.attempt++,this.updateState(fe.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${n}ms`),this.connect(),this.reconnectTimeout=void 0},n)}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[,n]of this.listeners)n(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(n){this.addStateLog(`error process data => ${n}`)}};onStreamError=e=>{if(this.addStateLog(`error => ${e?JSON.stringify(e):"undefined"}}`),e!==void 0){if(e instanceof X.ConnectError&&e.code!==X.Code.Canceled){this.updateState(fe.Failed),this.state.setValue("error",e),e.code===X.Code.Unknown&&e.cause==="missing trailer"&&(this.attempt=0),this.reconnect();return}this.disconnect()}}}const Uo=new Set([X.Code.Unknown,X.Code.Internal,X.Code.DeadlineExceeded,X.Code.ResourceExhausted,X.Code.FailedPrecondition,X.Code.Unavailable,X.Code.DataLoss]),Vo=new Set(["An attempt was made to perform an operation that is not permitted: HttpStatusError: invalid SDK key"]),Yr=le("grpc:retry"),xo=t=>async e=>{const n=e.contextValues.get(_r.retryAttempts),r=300,i=e.contextValues.get(_r.retryDelay);if(e.stream||n===0)return t(e);Yr.trace({url:e.url,attempts:n,maxDelay:i},"retry options");for(let o=0;;o++)try{return await t(e)}catch(s){Yr.trace({attempt:o,error:s,url:e.url},"retry attempt");const a=X.ConnectError.from(s);if(o>=n||!(a instanceof X.ConnectError)||!Uo.has(a.code)||Vo.has(a.rawMessage))throw s;const u=Math.min(i,Math.pow(2,o)*r),c=Math.round(u*(1+Math.random())/2);await new Promise(l=>setTimeout(l,c))}},_r={retryAttempts:X.createContextKey(10,{description:"Number of attempts to retry"}),retryDelay:X.createContextKey(3e4,{description:"Max delay between retries in milliseconds"})},qo=()=>{const t=localStorage.getItem("sl-device-id");if(t)return t;const e=Be.v4();return localStorage.setItem("sl-device-id",e),e},Bo=()=>navigator.userAgentData?.platform||navigator.platform,Mo=t=>t?"webOS":navigator.userAgentData&&navigator.userAgentData.mobile||"ontouchstart"in window||navigator.maxTouchPoints>0?"mobile-web":"desktop-web";class Xr{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;$headers;storeCache;interceptors=[];clients;streamClients;subscriptions;opts;constructor(e,n){this.host=e,this.opts=n,this.$headers=new De(ue({"sl-device-id":qo(),"sl-device-os":Bo(),"sl-platform":Mo(n?.webOS)}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.streamClients=new Map,this.subscriptions=new Map,this.storeCache=new Map;const[r,i,o]=Kr.nanoquery({dedupeTime:n?.dedupeTime,revalidateInterval:n?.refetchInterval});this.nanoquery={createFetcherStore:r,createMutatorStore:i,utils:o},this.transport=Wr.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:1e4,interceptors:this.interceptors}),this.streamTransport=Wr.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors})}addSubscription=(e,n,r)=>{const i=this.subscriptions.get(n);if(i)return i;const o=new Fo(this.$headers,e,n,r);return this.subscriptions.set(n,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,n,r]=Kr.nanoquery({dedupeTime:this.opts?.dedupeTime,revalidateInterval:this.opts?.refetchInterval});this.nanoquery={createFetcherStore:e,createMutatorStore:n,utils:r}};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(n=>n!==e)};getClient=e=>{const n=e.typeName;if(this.clients.has(n))return this.clients.get(n);const r=X.createClient(e,this.transport);return this.clients.set(n,r),r};getStreamClient=e=>{const n=`stream-${e.typeName}`;if(this.clients.has(n))return this.clients.get(n);const r=X.createClient(e,this.streamTransport);return this.clients.set(n,r),r};createPromiseClient=(e,{params:n=[],method:r})=>{const i=this.getClient(e),o=r.toString(),s=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1),...Array.isArray(n)?n:[n]],a=[e.typeName,o.charAt(0).toLowerCase()+o.slice(1)];return{client:i,createRequestOptions:c=>{const l=X.createContextValues();for(const p in c){const d=_r[p];l.set(d,c[p])}return l},queryKey:s,queryKeyStr:a.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,n)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",n)};setHeader=(e,n)=>this.$headers.setValue(e,n);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=n=>r=>{const i=this.$headers.getValues();for(const o in i)r.header.set(o,i[o]);return n(r)};this.interceptors.push(e),window.localStorage.getItem("SL_GRPC_DEVTOOLS")==="true"?this.interceptors.push(Do()):console.warn("SL GRPC DevTools is disabled. To enable, set SL_GRPC_DEVTOOLS to true in localStorage."),this.opts?.retryable&&this.interceptors.push(xo)}}const jo=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(_i.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>{if(!s||typeof s!="string")return"";try{return(await n.retrieveEventId({id:s})).data?.id||""}catch{return""}}})},Qo=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(Je.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>s?(await n.getStream({id:s})).data?.attributes:void 0})},Go=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(_i.Events,{method:"summary",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>s?(await n.summary({id:s})).data?.attributes:void 0})},Wo=(t,e)=>{const{queryKey:n,client:r}=e.createPromiseClient(Vr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(n,{fetcher:async()=>{if(!e.getHeader("authorization"))return{data:void 0};const{data:o}=await r.me({});return{data:o}}})},Ko=t=>{const{client:e,createRequestOptions:n}=t.createPromiseClient(Vr.Users,{method:"bypassAuth"}),r=n({retryAttempts:0});return({userKey:i,schema:o,init:s,inviterKey:a})=>e.bypassAuth({userKey:i,schema:o,init:s,inviterKey:a},{contextValues:r})},Ho=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(Je.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>(await n.get({})).data?.attributes})},$o=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(Je.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>{const i=await n.getOrganization({});return i.data?{...i.data.attributes,id:i.data.id}:void 0}})},zo=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(Je.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async()=>(await n.getOrganizationAdvertising({})).data?.attributes})},Yo=(t,e,n)=>{t.transport=new Xr(e.host,{dedupeTime:1e3*60*5,refetchInterval:1e3*60*5,retryable:!0,webOS:e.webOS}),t.analyticsTransport=new Xr(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(r=>{t.analyticsTransport.$headers.getStore().set(r)}),t.sdk.onMount({name:"transport"},()=>()=>{t.transport.disconnect(),t.analyticsTransport.disconnect()}),n()};var Se;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(Se||(Se={}));class Me extends We{constructor(){super("user")}setSchema=e=>{this.write(Se.SCHEMA,e)};getSchema=()=>this.read(Se.SCHEMA);setToken=e=>{this.write(Se.TOKEN,e)};getToken=()=>this.read(Se.TOKEN);setExternalToken=e=>{this.write(Se.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(Se.EXTERNAL_TOKEN);removeToken=()=>{this.remove(Se.TOKEN)}}var we;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(we||(we={}));const Xo=t=>{const e=new Me,n=new de(J(e.getExternalToken()),"userKey"),r=new de(J(e.getToken()),"userToken"),i=new me(Wo(r.getStore(),t),"user",({data:s,error:a,loading:u},c)=>{if(!a)return s?.data?.id?s.data.id:u===!1?void 0:c}),o=new me(Ho(r.getStore(),t),"userSettings");return{userKey:n,userToken:r,user:i,userSettings:o}},Jo=t=>{const e=new de(J(void 0),"providerStreamId"),n=new me(jo(e.getStore(),t),"slStreamId",o=>o?.data),r=new me(Qo(n.getAtomStore(),t),"streamSettings"),i=new me(Go(n.getAtomStore(),t),"streamSettings");return n.getAtomStore().listen(o=>{(o===""||o===void 0)&&(r.getStore().mutate(void 0),i.getStore().mutate(void 0))}),{providerStreamId:e,slStreamId:n,streamSettings:r,streamSummary:i}},Zo=t=>{const e=new de(J(void 0),"enabled"),n=new de(J(we.DISABLED),"status"),r=new me($o(e.getStore(),t),"organizationSettings",a=>a?.data?.id),i=new me(zo(r.getAtomStore(),t),"organizationAdvertising"),o=Xo(t),s=Jo(t);return{enabled:e,status:n,providerStreamId:s.providerStreamId,slStreamId:s.slStreamId,streamSettings:s.streamSettings,streamSummary:s.streamSummary,user:o.user,userKey:o.userKey,userToken:o.userToken,userSettings:o.userSettings,organizationSettings:r,organizationAdvertising:i}};class es extends vt{stores;constructor(e){const n=Zo(e),r=Po(n);super(r,"core"),this.stores=n}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=e=>{let n;for(n in this.stores){const r=e[n];n in e&&r!==void 0&&this.stores[n].subscribe(e[n])}};unsubscribe=()=>this.getStore().off()}const ts=(t,e,n)=>{t.store=new es(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(([r,i])=>[r,i.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.sdk.streamSummary=()=>t.stores.streamSummary.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},n()},rs=t=>{const{client:e}=t.createPromiseClient(Di.Leaderboard,{method:"list"});return n=>e.list(n)},Qi=t=>{const{client:e}=t.createPromiseClient(Di.Leaderboard,{method:"summary"});return n=>e.summary(n)},ns=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(Vr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>{if(!s)return[];try{return(await n.getFriends({})).data}catch{return[]}}})},is=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(ie.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>(await n.get({eventId:s})).data?.attributes,revalidateInterval:0,dedupeTime:1e3*60*60})},os=(t,e,n)=>{const{client:r,queryKey:i}=n.createPromiseClient(ie.Feed,{method:"syncQuestion",params:[t,e?"true":""]});return n.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>{if(!a||u)return;const c=await r.syncQuestion({filter:{eventId:a}});if(c.data?.attributes?.question?.type!==I.QuestionType.PROMOTION)return c.data?.attributes},dedupeTime:1e3*60*10,revalidateInterval:0})},ss=async(t,e)=>{const{client:n}=e.createPromiseClient(ie.Feed,{method:"item",params:[t]});return(await n.item({id:t})).data},as=(t,e)=>{const{client:n}=e.createStreamClient(ie.Feed),r=ce.atom({eventId:t.get()||"",feedId:""});return t.subscribe((o="")=>{r.set({eventId:o,feedId:""})}),e.addSubscription(n.subscription,r,{name:"feedSubscription"})},us=(t,e)=>{const{client:n}=e.createStreamClient(ie.Feed);return e.addSubscription(n.questionSubscription,{questionId:t},{name:"questionSubscription"})},Gi=async(t,e)=>{const{client:n}=e.createPromiseClient(ie.Feed,{method:"questionByUser",params:[t]});return(await n.questionByUser({questionId:t})).data?.attributes?.question},mt=(t,e)=>{const{client:n,queryKey:r,queryKeyStr:i}=e.createPromiseClient(ie.Feed,{method:"questionByUser",params:[t]});let o=i;if(typeof t!="object"?o+=t:o+="atom",e.storeCache.has(o))return e.storeCache.get(o);{const s=e.nanoquery.createFetcherStore(r,{fetcher:async(a,u,c)=>(await n.questionByUser({questionId:c})).data?.attributes?.question,dedupeTime:1/0,revalidateInterval:0});return e.storeCache.set(o,s),s}},Wi=async(t,e)=>{if(!t)return;const{client:n}=e.createPromiseClient(ie.Feed,{method:"getQuestion",params:[t]}),r=await n.getQuestion({id:t});if(!r.data?.attributes)return;const{options:i,notification:o,...s}=r.data.attributes,a=i?.options.case==="promotion"?i?.options.value:void 0;return{id:s.id,question:s,promotion:a,notification:o}},cs=(t,e,n,r,i,o,s,a)=>{const{client:u,queryKey:c}=a.createPromiseClient(ie.Feed,{method:"list",params:[t,e,o?"true":"",s]});return a.nanoquery.createFetcherStore(c,{fetcher:async(l,p,d,f,h,T)=>{if(!d||h||!T)return[];const E=await u.list({eventId:d,filter:{types:f===Pe.ALLOWED?[]:[I.QuestionType.FACTOID,I.QuestionType.PROMOTION,I.QuestionType.TWEET],statuses:[I.QuestionStatus.ACTIVE,I.QuestionStatus.RESOLVED]}}),C={eventId:d,userId:n.get(),organizationId:r.get()};for(const g of E.data)i.isQuestionReceived(C,g.id)||(H.emit("poll",{action:"received",payload:{isAd:g.attributes?.adUnit!=I.AdUnit.UNSET,questionId:g.id,questionType:g.attributes?.type}}),i.saveQuestionReceived(C,g.id));return E.data},dedupeTime:1/0,revalidateInterval:0})},ls=(t,e)=>{const{client:n,queryKey:r}=e.createPromiseClient(ie.Feed,{method:"list",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s)=>{if(!s)return;const u=(await n.list({eventId:s,filter:{types:[I.QuestionType.PROMOTION],statuses:[I.QuestionStatus.ACTIVE]},pagination:{page:0,pageSize:1}})).data?.[0];if(u?.type==="promotion")return Wi(u.id,e)},dedupeTime:1/0,revalidateInterval:0})},ds=(t,e,n,r,i)=>{const{client:o,queryKey:s}=i.createPromiseClient(ie.Feed,{method:"betPack",params:[t,e,n]});return i.nanoquery.createFetcherStore(s,{fetcher:async(a,u,c,l,p)=>{if(!c||!l||!p)return{timestamp:Date.now(),data:null};const d=await o.betPack({eventId:c,types:[I.QuestionType.PREDICTION],statuses:[I.QuestionStatus.ACTIVE,I.QuestionStatus.RESOLVED],limit:5,sort:{field:"activated_at",order:"asc"}});return!d.data||!d.data.length?{timestamp:Date.now(),data:null}:{timestamp:Date.now(),data:d.data?.reduce((f,h)=>{const T=h?.attributes?.question;if(!T?.id)return f;const E={eventId:c,userId:l,organizationId:p};return r.isQuestionReceived(E,T.id)||(H.emit("poll",{action:"received",payload:{isAd:T?.adUnit!=I.AdUnit.UNSET,questionId:T.id,questionType:T.type}}),r.saveQuestionReceived(E,T.id)),T.answers=T.answers.sort((C,g)=>C.id>g.id?1:-1),{...f,[T.id]:T}},{})}},dedupeTime:1/0,revalidateInterval:0})},ps=(t,e,n)=>{const r=new Map,i=(l,p)=>{r.has(l)||r.set(l,new Set),r.get(l)?.add(p)},o=(l,p)=>r.get(l)?.has(p)??!1,s=ce.batched([e,n],()=>{const l=e.get();if(!l)return;const p=n.get().data?.find(h=>h.id===l?.questionId),d=l?.question?.openedFrom,f=l.questionId;if(p)return p.openedFrom=d,Object.assign(p,{fireEvent:h=>i(f,h),isEventFired:h=>o(f,h)});if(l.question)return Object.assign(l.question,{fireEvent:h=>i(f,h),isEventFired:h=>o(f,h)})}),a=ce.batched(s,l=>l?.id),u=mt(a,t);return{$store:s,$extendedStore:u,updateExtendedQuestion:l=>{const p=u.get().data,d=(f,h)=>{if(!f||!h)return(f||h||[]).sort((g,S)=>g.id>S.id?1:-1);const T=f.sort((g,S)=>g.id>S.id?1:-1),E=h.sort((g,S)=>g.id>S.id?1:-1),C=[];for(let g=0;g<T.length;g++)C.push({...T[g],...E[g],correct:T[g].correct,youVoted:T[g].youVoted,pointsEarned:T[g].pointsEarned});return C};u.mutate({...l,options:p?.options,subject:p?.subject,appearance:p?.appearance,answers:d(p?.answers,l?.answers)})}}};var je;(function(t){t.SHOWED="showed",t.EVENT="ev"})(je||(je={}));class fs extends We{constructor(){super("advertisement")}setShowed=e=>{this.write(je.SHOWED,e,"true")};isViewed=e=>this.read(je.SHOWED,e);fireEvent=(e,n)=>{this.write(je.EVENT,n,e,"true")};isEventFired=(e,n)=>this.read(je.EVENT,n,e)==="true"}const hs=t=>{const e=t.data?.attributes?.question;if((t.data?.attributes?.feedItem?.type==="promotion"?t.data.attributes.feedItem:void 0)===void 0||!e)return;const{options:r,notification:i,...o}=e,s=r?.options.case==="promotion"?r.options.value:void 0;return{id:o.id,question:o,notification:i,promotion:s}},ot=t=>t.startsWith("http://")||t.startsWith("https://")?new URL(t).toString():t,ms=({gamOptions:t,gamBaseUrl:e})=>{const n=`${e}?`,r=[];for(const i in t){const o=i.replace(/([a-zA-Z])(?=[A-Z])/g,"$1_").toLowerCase(),s=t[i];if(s)if(typeof s=="string")r.push(`${o}=${ot(s)}`);else if(Array.isArray(s))r.push(`${o}=${s.map(ot).join(",")}`);else{const a=Object.entries(s).map(([u,c])=>Array.isArray(c)?`${u}=${c.map(ot).join(",")}`:typeof c=="string"?`${u}=${ot(c)}`:`${u}=${c}`).join("&").replaceAll("=","%3D").replaceAll("&","%26").replaceAll(",","%2C");r.push(`${o}=${a}`)}}return n+r.join("&")},xe=t=>(t?.promotion?.type===I.PromotionType.INGAME_IAB11_LBAR||t?.promotion?.type===I.PromotionType.INGAME_IAB21_LBAR)&&!!t.promotion.additionalBanner?.imageUrl,ys=(t,e,n)=>{let r=!1;const i=n.transport,o=le("advertisement"),s=new fs,a=(g,S)=>{s.fireEvent(g,S)},u=(g,S)=>s.isEventFired(g,S),c=ue({}),l=ls(t,i),p=g=>{const S=c.get(),y=S.data?.question.id,w=S.data?.promotion?.type;if(!y)return;c.get()?.isOpened||(c.setKey("isOpened",!0),H.emit("advertisement",{action:"opened",payload:{id:y,type:w,hasBanner:xe(S.data),openedFrom:g?.fromNotification?"notification":"auto"}})),g?.fromNotification&&(c.setKey("hasNotification",!1),H.emit("advertisement",{action:"notification-opened",payload:{id:y,type:w,hasBanner:xe(S.data)}}))},d=()=>{const g=c.get(),S=g.data?.question.id,y=g.data?.promotion?.type,w=c.get()?.isOpened;S&&!w&&(o.debug({id:S},"markAsViewed: %o"),s.setShowed(S),c.setKey("isOpened",!0),H.emit("advertisement",{action:"viewed",payload:{id:S,type:y,hasBanner:xe(g.data)}}))},f=(g,S)=>{S?c.set({loading:!1,error:void 0,data:S,hasNotification:S?.notification?.enabled===I.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>h(S.question.id),togglePause:y=>T(S.question.id,y),toggleMute:y=>E(S.question.id,y),isViewed:!!s.isViewed(S.question.id),fireEvent:y=>a(g,y),isEventFired:y=>u(g,y)}):(c.setKey("loading",!0),Wi(g,i).then(y=>c.set({loading:!1,error:void 0,data:y,hasNotification:y?.notification?.enabled===I.NotificationEnabled.NOTIFICATION_ENABLED,close:()=>h(y?.question.id),togglePause:w=>T(y?.question.id,w),toggleMute:w=>E(y?.question.id,w),isViewed:y&&!!s.isViewed(y.question.id),fireEvent:w=>a(g,w),isEventFired:w=>u(g,w)})).catch(y=>c.set({loading:!1,error:y,data:void 0,fireEvent:()=>{},isEventFired:()=>!1})))};c.subscribe((g,S)=>{if(!(g.data?.id===S?.data?.id&&g.isPaused!==S?.isPaused)){if(g.data?.promotion?.type===I.PromotionType.EXTERNAL_AD&&!g?.externalAd&&g.data.promotion.adCampaigns?.desktopWebSettings){const y=ms(g.data.promotion.adCampaigns.desktopWebSettings);c.setKey("externalAd",{type:"gam",url:y})}g.data?.promotion&&!g.isOpened&&(H.emit("advertisement",{action:"received",payload:{id:g.data.question.id,type:g.data.promotion.type,hasNotification:!!g.hasNotification,hasBanner:xe(g.data),isViewed:!!s.isViewed(g.data.question.id)},skipAnalytics:g.data.question.id===S?.data?.question.id}),g.data.question.id!==S?.data?.question.id&&!s.isViewed(g.data.question.id)&&H.emit("advertisement",{action:"notification-received",payload:{id:g.data.question.id,type:g.data.promotion.type,hasNotification:!0,hasBanner:xe(g.data),isViewed:!1}})),!g?.data&&S?.data&&H.emit("advertisement",{action:"closed",payload:{id:S.data.question.id,type:S.data.promotion?.type,hasNotification:!!S.hasNotification,hasBanner:xe(S.data),isViewed:!!s.isViewed(S.data.question.id)}})}});const h=g=>{(!g||c.get()?.data?.question.id===g)&&c.set({})},T=(g,S)=>{c.get()?.data?.question.id===g&&c.setKey("isPaused",S)},E=(g,S)=>{c.get()?.data?.question.id===g&&c.setKey("isMuted",S)};return{connect:()=>{r||(r=!0,l.subscribe((g,S)=>{g.data&&(!S?.data||g.data.id!==S.data.id)&&f(g.data.question.id,g.data)}),e.addListener("promotion",g=>{const S=hs(g);if(S){if(S.question.status===I.QuestionStatus.RESOLVED){h(S.question.id),o.debug({promotion:S},"resolved: %o");return}if(S.question.status===I.QuestionStatus.ACTIVE){o.debug({promotion:S},"active: %o"),f(S.question.id,S);return}o.debug({promotion:S},"skip: %o")}}))},hide:h,show:f,open:p,markAsViewed:d,$store:c}};var ge;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io",t.QUESTION_RECEIVED="q-received",t.QUESTION_OPENED="q-opened"})(ge||(ge={}));class gs extends We{constructor(){super("gamification-session",window.sessionStorage)}writeValue=(e,n)=>{this.write(...e,n)};readValue=e=>this.read(...e)}class vs extends We{sessionStorage;constructor(){super("gamification"),this.sessionStorage=new gs}saveQuestionReceived=({userId:e,eventId:n,organizationId:r},i)=>{this.write(ge.QUESTION_RECEIVED,r,e,n,i,"1")};isQuestionReceived=({userId:e,eventId:n,organizationId:r},i)=>!!this.read(ge.QUESTION_RECEIVED,r,e,n,i);saveQuestionOpened=({userId:e,eventId:n,organizationId:r},i)=>{this.write(ge.QUESTION_OPENED,r,e,n,i,"1")};isQuestionOpened=({userId:e,eventId:n,organizationId:r},i)=>!!this.read(ge.QUESTION_OPENED,r,e,n,i);saveOnboardingStatus=({userId:e,eventId:n,organizationId:r},i)=>{this.write(ge.ONBOARDING,r,e,n,i)};getOnboardingStatus=({userId:e,eventId:n,organizationId:r})=>this.read(ge.ONBOARDING,r,e,n);setOnboardingInstantOpen=({userId:e,eventId:n,organizationId:r})=>{this.sessionStorage.writeValue([ge.ONBOARDING_IO,r,e,n],"1")};getOnboardingInstantOpen=({userId:e,eventId:n,organizationId:r})=>this.sessionStorage.readValue([ge.ONBOARDING_IO,r,e,n])}var Pe;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Pe||(Pe={}));class bs{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;betPack;moderationId;moderation;feedSubscription;questionSubscription;advertisement;withPickHistory;storage;notifications;log;transport;cancels=new Set;constructor(e){this.transport=e.transport,this.log=le("gamification-background"),this.storage=new vs,this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new de(J(void 0),"moderationId").getStore(),this.interactiveAllowed=new de(J(Pe.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new de(J(void 0),"openedQuestionId").getStore(),this.withPickHistory=J(!1),this.notifications=e.notifications,this.moderation=new me(is(this.slStreamId,e.transport),"gamification:moderation");const n=!!e.sdk.options.get().betPack;this.feedList=new me(cs(this.slStreamId,this.interactiveAllowed,this.userId,this.organizationId,this.storage,n,this.withPickHistory,e.transport),"gamification:feedList"),this.betPack=new me(ds(this.slStreamId,this.userId,this.organizationId,this.storage,e.transport),"gamification:betPack"),this.activeQuestionId=os(this.slStreamId,n,e.transport),this.openedQuestion=ps(e.transport,this.openedQuestionId,this.feedList.getStore()),this.cancels.add(this.openedQuestionId.listen(r=>{this.log.debug({item:r},"received question"),r?.questionId?(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0),this.questionSubscription=us(r.questionId,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",i=>{const o=i.data?.attributes?.question;if(this.openedQuestion.updateExtendedQuestion(o),this.betPack&&o?.type===I.QuestionType.PREDICTION&&(o.status===I.QuestionStatus.ACTIVE||o.status===I.QuestionStatus.RESOLVED)){const s=this.betPack.getValues().data?.data||{},a=s?.[o.id];if(a){const u=[],c=a.answers.sort((p,d)=>p.id>d.id?1:-1),l=o.answers.sort((p,d)=>p.id>d.id?1:-1);for(let p=0;p<c.length;p++)u.push({...c[p],...l[p],correct:c[p].correct,youVoted:c[p].youVoted,pointsEarned:c[p].pointsEarned});this.betPack.getStore().mutate({timestamp:Date.now(),data:{...s,[o.id]:{...a,status:o.status,marketClosed:o.marketClosed,activatedAt:o.activatedAt,answerSetAt:o.answerSetAt,answers:u}}})}}}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))})),this.feedSubscription=as(this.slStreamId,e.transport),this.cancels.add(this.feedSubscription.addListener("bet-pack-update",async r=>{const i=r.data?.attributes?.question;if(this.betPack&&i?.type===I.QuestionType.PREDICTION&&(i.status===I.QuestionStatus.ACTIVE||i.status===I.QuestionStatus.RESOLVED)){const o=this.betPack.getValues().data?.data||{},s=o?.[i.id];if(s)this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:{...s,status:i.status,marketClosed:i.marketClosed,activatedAt:i.activatedAt,answerSetAt:i.answerSetAt}}});else if(!s&&Object.keys(o).length<5){const a=await Gi(i.id,this.transport);this.betPack.getStore().mutate({timestamp:Date.now(),data:{...o,[i.id]:a}})}}})),this.cancels.add(this.feedSubscription.addListener("feed-subscription-active-question",r=>{const i=this.activeQuestionId.get().data?.question?.id,o=r.data?.attributes?.question;if(!(!o||o.type===I.QuestionType.PROMOTION)){if(o.status===I.QuestionStatus.RESOLVED){i===o.id&&this.activeQuestionId.mutate(void 0);return}window.requestAnimationFrame(()=>{this.activeQuestionId.mutate(r.data?.attributes)})}})),this.cancels.add(this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})})),this.cancels.add(this.activeQuestionId.subscribe((r,i)=>{if(r.data?.feedItem&&r.data?.feedItem?.id!==i?.data?.feedItem?.id){const o=r.data.feedItem,s={eventId:this.slStreamId.get(),userId:this.userId.get(),organizationId:this.organizationId.get()};H.emit("poll",{action:"received",payload:{isAd:o?.attributes?.adUnit!=I.AdUnit.UNSET,questionId:o.id,questionType:o.attributes?.type}}),this.storage.saveQuestionReceived(s,o.id),e.onQuestionActivate({stage:"activate",id:r.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:r.data.feedItem.id})),hasNotification:r.data?.question?.notification?.enabled===I.NotificationEnabled.NOTIFICATION_ENABLED,type:r.data.feedItem.type})}!r.data?.feedItem&&i?.data?.feedItem&&e.onQuestionActivate({stage:"deactivate",id:i.data.feedItem.id,isViewed:!!this.notifications.isViewed(this.getCurrentSessionId({prefix:"notification",entity:i.data.feedItem.id})),hasNotification:i.data?.question?.notification?.enabled===I.NotificationEnabled.NOTIFICATION_ENABLED,type:i.data.feedItem.type})})),this.feedSubscription.connect(),this.cancels.add(this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})),e.sdk.onMount({name:"gamification-background"},()=>()=>{this.activeQuestionId.off();for(const r of this.cancels)r(),this.cancels.delete(r)}),n||(this.advertisement=ys(this.slStreamId,this.feedSubscription,e))}getCurrentSessionId=e=>{const n=e.eventId||this.slStreamId.get()||"",r=e.userId||this.userId.get()||"",i=e.organizationId||this.organizationId.get()||"",o=e.entity||"",s=e.prefix||"";return[i,n,r,s,o].join(":")};disconnect=()=>{this.feedSubscription?.disconnect(),this.questionSubscription!==void 0&&(this.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0)};openQuestion=(e,n)=>{this.openedQuestionId.set({questionId:e,question:n}),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 Ts{notificationsList;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=le("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notificationsList=J(new Map)}addToQueue=e=>{if(this.store.has(e.id)){this.logger.debug({notification:e},"skip existed notification: %o");return}const n=e.close,r=e.action;if(this.store.set(e.id,{...e,close:(...i)=>{n&&n(...i),this.closeNotification(e.id)},action:(...i)=>{r&&r(...i),this.closeNotification(e.id,{animateHiding:!1})}}),this.waitingQueue.add(e.id),this.activeQueue.size===this.options.concurrency){const[i]=this.activeQueue;if(this.store.get(i)?.persistent!==!0)this.closeNotification(i);else{const[s]=this.waitingQueue;this.waitingQueue.size>1&&this.closeNotification(s),this.tickWaitingQueue()}}else this.tickWaitingQueue()};tickWaitingQueue=()=>{if(this.activeQueue.size<this.options.concurrency){const[e]=this.waitingQueue;if(!e)return;this.activeQueue.add(e),this.waitingQueue.delete(e),this.logger.debug({job:e},"waiting queue tick"),this.tickActiveQueue(e)}else this.logger.debug({queueSize:this.activeQueue.size,concurrency:this.options.concurrency},"waiting queue tick skipped")};tickActiveQueue=e=>{if(!e)return;const n=this.store.get(e);if(!n){this.logger.debug({notificationId:e},"active queue tick skipped, notification not exist");return}H.emit("notification",{action:"received",payload:{type:n.type,questionId:n.data.questionId,questionType:n.data.questionType}});const r=setTimeout(()=>{const i=e,o=new Map(this.notificationsList.get());o.set(n.id,n),this.notificationsList.set(o);const s=setTimeout(()=>{this.logger.debug({notificationId:i,delay:n.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(i)},n.autoHideDuration||5e3);this.timeouts.set(i,s),this.logger.debug({notificationId:i,queue:[...o.values()]},"notification displayed")},n.delay||0);this.timeouts.set(e,r),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=(e,{animateHiding:n=!0}={})=>{const r=new Map(this.notificationsList.get()),i=r.get(e);if(i){const o=!(this.waitingQueue.size>=this.options.concurrency)&&n;i.hiding=o,this.notificationsList.set(r);const s=()=>{const a=new Map(this.notificationsList.get());a.delete(e),this.notificationsList.set(a);const u=this.timeouts.get(e);u!==void 0&&(clearTimeout(u),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden"),H.emit("notification",{action:"closed",payload:{type:i.type,questionId:i.data.questionId,questionType:i.data.questionType}})};if(o){const a=setTimeout(s,this.options.animationDelay||0);this.timeouts.set(e,a)}else s()}return this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding"),i};drain=()=>{this.store.clear(),this.timeouts.clear(),this.waitingQueue.clear(),this.activeQueue.clear(),this.notificationsList.off(),this.notificationsList.set(new Map)}}var gt;(function(t){t.OPENED="opened"})(gt||(gt={}));class As extends We{constructor(){super("notification")}setOpened=e=>{this.write(gt.OPENED,e,"true")};isOpened=e=>this.read(gt.OPENED,e);clearNotification=()=>{this.clear()}}class Ss{queue;storage;constructor(e={}){this.storage=new As,this.queue=new Ts({concurrency:1,animationDelay:1600,...e})}isViewed=e=>this.storage.isOpened(e);add=e=>{if(!this.isViewed(e.id)){if(e.data&&e.emitEvent){const r=e.action;e.action=(...i)=>{r&&r(...i),H.emit("notification",{action:"opened",payload:{questionId:e.data.questionId,questionType:e.data.questionType}})}}this.queue.addToQueue(e)}};close=(e,{markAsViewed:n=!0,animateHiding:r}={})=>{this.queue.closeNotification(e,{animateHiding:r}),n&&this.markAsViewed(e)};update=(e,n)=>{const r=this.queue.notificationsList.get()?.get(e);n(r)};getActiveNotification=()=>{const e=this.queue.notificationsList.get();if(!e?.size)return null;for(const r of e.values())if(r.type===ke.ONBOARDING)return r;return e.values().next().value};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const Es=(t,e,n)=>{t.notifications=new Ss(void 0),t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),t.sdk.getActiveNotification=()=>t.notifications.getActiveNotification(),t.sdk.onMount({name:"notifications"},()=>()=>{t.notifications.queue.drain()}),n()};var Ge;(function(t){t.UNKNOWN="unknown",t.ALREADY_VOTED="already_voted"})(Ge||(Ge={}));const Jr=async(t,e)=>{const{client:n,createRequestOptions:r}=t.createPromiseClient(ie.Feed,{method:"submitAnswer"}),i=r({retryAttempts:0});try{return await n.submitAnswer({data:e},{contextValues:i})}catch(o){throw X.ConnectError.from(o)?.code===X.Code.AlreadyExists?new Error(Ge.ALREADY_VOTED):new Error(Ge.UNKNOWN)}},Ki=(t,e)=>{const{client:n,createRequestOptions:r}=t.createPromiseClient(ie.Feed,{method:"submitInplay"}),i=r({retryAttempts:0});return n.submitInplay({data:{eventId:+e}},{contextValues:i})},ws=t=>{switch(t){case I.UserAccountInfo.PHONE:return ze.WebhookNotificationType.PHONE;case I.UserAccountInfo.EMAIL:return ze.WebhookNotificationType.MAIL;default:return ze.WebhookNotificationType.UNSET}},Is=(t,e)=>{const{client:n,createRequestOptions:r}=t.createPromiseClient(ze.OrganizationWebhooks,{method:"sendWebhookEvent"}),i=r({retryAttempts:0});return n.sendWebhookEvent({eventId:e.eventId,questionId:e.questionId,data:{event:ze.WebhookEvent.CLICK_BUTTON,notificationType:ws(e.userAccountInfo),userId:e.userId,description:"",metadata:{},customFields:{}}},{contextValues:i})},Os={pageSize:10},ks=(t,e,n,r,i)=>{let o=0;const s=J({pageSize:Os.pageSize,page:0}),a=ue({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),u=rs(t),c=async()=>{const d=e.get(),f=r?.getStore().get().data?.map(h=>h.slId)||[];if(d&&f?.length){const h=n.get();h&&f.push(h),a.setKey("loading",!0),a.setKey("data",[]);const E=await u({eventId:d,usersIds:f,leaderboardId:""});a.set({data:E.data.map((C,g)=>({...C.attributes,friendsRank:g+1})),hasMore:!1,key:Date.now(),loading:!1}),E.meta&&(o=Math.round(E.meta.count/E.meta.pageSize))}},l=()=>{c()},p=d=>{const f=s.get(),h=d||f.page+1;h<=o&&s.set({...f,page:h})};return ce.onMount(a,()=>{const d=e.listen(c),f=r?.listen(c);return()=>{d(),f?.()}}),{$store:a,fetchMore:p,invalidate:l}};class Ns extends We{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Zr="sldl",bt="sldl_uid",Hi="sldl_eid",$i="sldl_e_eid",Rs=new Set([bt,Hi,$i]),en=t=>{const e={},n={};for(const[r,i]of t)Rs.has(r)?e[r]=i:n[r]=i;return{result:e,remain:n}},Ps=({hash:t,search:e})=>{if(t&&t.includes(Zr)){const n=new URLSearchParams(t.substr(1));return{hash:en(n)}}if(e&&e.includes(Zr)){const n=new URLSearchParams(e);return{search:en(n)}}return null},tn=le("deep_link"),Te={debug:(...t)=>{tn.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{tn.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},Cs=(t,e)=>{const{hash:n,search:r}=window.location;if(Te.debug({hash:n,search:r},"get deep link data from"),n||r){const i=Ps({hash:n,search:r});if(Te.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 c=Object.keys(u).length!==0;if(o){let l="";c&&(l=`#${new URLSearchParams(u).toString()}`,Te.debug({updatedHash:l},"update hash")),window.history.replaceState(null,"",window.location.pathname+window.location.search+l)}if(s){let l="";c&&(l=`?${new URLSearchParams(u).toString()}`,Te.debug({updatedSearch:l},"update search")),window.history.replaceState(null,"",window.location.pathname+l+window.location.hash)}e(a)}}}t.setValue("parsed",!0)},Ls=(t,e,n)=>{const r=new Ns,i=r.get("sl-deep-link-store");let o={};if(i)try{o=JSON.parse(i)}catch(a){Te.debug(a)}t.deepLink={$store:new De(ue(o),"deep-link-context"),getDeepLinkData:()=>{const{data:a,used:u}=t.deepLink.$store.getValues();return{data:a,used:u}},deepLinkUsed:a=>{Te.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?.[bt]:void 0},t.sdk.inviteDisplayed=()=>{t.deepLink.$store.getStore().set({}),t.deepLink.$store.getStore().off(),r.del("sl-deep-link-store")},t.deepLink.$store.subscribe(a=>r.set("sl-deep-link-store",JSON.stringify(a))),t.sdk.addDeepLinkHandler=a=>{localStorage.getItem("SL_DEBUG")&&Te.trace("adding deep link handler"),t.deepLink.onDeepLinkHandlers.add(a)},e.onDeepLinkHandled&&t.sdk.addDeepLinkHandler(e.onDeepLinkHandled),t.sdk.removeDeepLinkHandler=a=>{Te.trace("removing deep link handler"),t.deepLink.onDeepLinkHandlers.delete(a)};const s=a=>{t.deepLink.$store.setValue("handled",!0),Te.trace({size:t.deepLink.onDeepLinkHandlers.size},"deep link handled, call callbacks");for(const u of t.deepLink.onDeepLinkHandlers)try{Te.trace("called handler"),u(a)}catch(c){console.error(c)}};Cs(t.deepLink.$store,s),n()},_s=le("bypass");class Ds extends Ro{$coreStore;deepLink;transport;bypassLogin;constructor(e,n,r){super(),this.$coreStore=e,this.deepLink=r,this.transport=n,this.bypassLogin=Ko(this.transport),this.connect()}me=async()=>(this.$coreStore.getValues().user.invalidate(),(await this.$coreStore.getValues().user.getValue())?.data);login=async(e,n)=>{this.$coreStore.getValues().userKey.setValue(n);const{used:r,data:i}=this.deepLink?.getDeepLinkData()||{},o=r?"":i?.[bt];_s.debug({inviterKey:o},"login with inviterKey");const s=await this.bypassLogin({schema:e,userKey:n,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&&this.deepLink.deepLinkUsed(s.meta.inviterKey),this.$coreStore.getValues().user.getStore().mutate({data:s.data}),this.saveUser(a,u),a};isAuthenticated=()=>this.me();logout=()=>{this.$coreStore.getValues().user.setValue(),this.$coreStore.getValues().userKey.setValue(),this.$coreStore.getValues().userToken.setValue(),this.transport.setAuth("",""),new Me().clear()};softLogout=()=>{const e=new Me;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=({skipLogin:e}={skipLogin:!1})=>{const n=new Me,r=n.getToken(),i=n.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(i),r)return this.saveUser(r,""),this.me().then(o=>{if(o?.id){const s=o.id;this.saveUser(r,s)}return o});if(i&&!r&&!e){const o=n.getSchema();o&&i&&this.login(o,i).catch(()=>{this.logout()})}};saveUser=(e,n)=>{this.transport.setAuth(e,n),this.$coreStore.getValues().userToken.setValue(e),new Me().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async n=>{try{return await e(n)}catch(r){throw r.code&&(r.code===7||r.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),r}})}}const $e=new Me,Fs=(t,e,n)=>{t.auth=new Ds(t.store,t.transport,t.deepLink),t.stores.status.listen(r=>{r===we.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(r,i)=>{if(!($e.getSchema()===r&&$e.getExternalToken()===i&&t.transport.getHeader("authorization")))try{console.log("login",r,i),await t.auth.login(r,i),$e.setSchema(r),$e.setExternalToken(i)}catch(o){console.log("login error",o),t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),$e.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),n()},rn=le("video_player"),st={debug:(...t)=>{rn.debug(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)},trace:(...t)=>{rn.trace(...t),localStorage.getItem("SL_DEBUG")&&console.log(...t)}},Us=(t,e,n)=>{t.videoPlayer={controllers:new Set},t.sdk.addVideoPlayerController=r=>{st.trace("adding video player controller"),t.videoPlayer.controllers.add(r)},e.videoPlayerController&&t.sdk.addVideoPlayerController(e.videoPlayerController),t.sdk.removeVideoPlayerController=r=>{st.trace("removing video player controller"),t.videoPlayer.controllers.delete(r)},t.sdk.controlVideoPlayer=r=>{st.trace("controlling video player");for(const i of t.videoPlayer.controllers){st.trace("calling video player controller");try{i(r)}catch(o){console.error(o)}}},n()},Vs={[I.QuestionType.FACTOID]:"insight",[I.QuestionType.POLL]:"poll",[I.QuestionType.TRIVIA]:"trivia",[I.QuestionType.PREDICTION]:"prediction",[I.QuestionType.TWEET]:"tweet"},qe=t=>t===I.PromotionType.INGAME_IAB11||t===I.PromotionType.INGAME_IAB21||t===I.PromotionType.NFL_SHOP_OVERLAY||t===I.PromotionType.SHOP_OVERLAY,xs=(t,e,n)=>{t.sdk.uiState=ue({}),t.ui={enableAppNotification:function(){t.sdk.uiState.setKey("appNotification",!0)},disableAppNotification:function(){t.sdk.uiState.get().app||t.sdk.uiState.setKey("appNotification",!1)},enableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!0)},disableOnboardingNotification:function(){t.sdk.uiState.setKey("onboardingNotification",!1)},enablePolymarket:function(){t.sdk.uiState.setKey("polymarket",!0)},disablePolymarket:function(){t.sdk.uiState.setKey("polymarket",!1)},enableApp:function(){t.sdk.uiState.set({app:!0,appNotification:!0})},disableApp:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),onboardingNotification:!1,appBanner:!1,appSidebar:!1,appNotification:!1,app:!1})},enableExposedPauseAd:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),exposedPauseAd:!0})},disableExposedPauseAd:function(){t.sdk.uiState.set({...t.sdk.uiState.get(),exposedPauseAd:!1})}},t.sdk.uiHandlers={enablePolymarket:t.ui.enablePolymarket,disablePolymarket:t.ui.disablePolymarket},e.onContentActivate&&(t.ui.onContentActivate=e.onContentActivate);const r=i=>{t.ui.onContentActivate&&t.ui.onContentActivate({...i,type:"advertisement"})};t.onQuestionActivate=({questionType:i,...o})=>{if(t.ui.enableAppNotification(),t.ui.onContentActivate){const s=o.type||i&&Vs[i]||"question";t.ui.onContentActivate({...o,type:s})}},t.sdk.onMount({name:"ui"},()=>{const i=a=>{if(a.slEventBus?.type==="exposedPauseAd")switch(a.slEventBus.action){case"enabled":t.ui.enableExposedPauseAd();break;case"disabled":t.ui.disableExposedPauseAd();break}if(a.slEventBus?.type==="app")switch(a.slEventBus.action){case"open":t.ui.enableApp();break;case"close":t.ui.disableApp();break}if(a.slEventBus?.type==="poll"){const u=a.slEventBus.action,{hasBanner:c}=a.slEventBus.payload;switch(u){case"onboardingOpen":t.sdk.uiState.set({app:!0});break;case"opened":t.sdk.uiState.set({...t.sdk.uiState.get(),appBanner:c,appSidebar:!0});break;case"closed":t.sdk.uiState.set({...t.sdk.uiState.get(),appBanner:!1,appSidebar:!1});break}}if(a.slEventBus?.type==="notification"){const u=a.slEventBus.action;if(a.slEventBus.payload.type===ke.ONBOARDING)switch(u){case"received":t.ui.enableOnboardingNotification();break;case"closed":t.ui.disableOnboardingNotification();break}else switch(u){case"received":t.ui.enableAppNotification();break;case"closed":t.ui.disableAppNotification();break}}if(a.slEventBus?.type==="advertisement"&&e.withAd){const u=a.slEventBus,{hasNotification:c,hasBanner:l,id:p,isViewed:d,type:f}=u.payload;switch(u.action){case"notification-opened":t.sdk.uiState.set({promotionExternalAd:f===I.PromotionType.EXTERNAL_AD,promotionBanner:l,promotionNotification:!1,promotionOverlay:qe(f),promotionSidebar:!qe(f)});break;case"received":if(t.sdk.closeFeature(),r({stage:"activate",id:p,hasNotification:c,hasBanner:l,isViewed:d}),!e.withAdNotification){t.sdk.uiState.set({promotionBanner:l,onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionOverlay:qe(f),promotionSidebar:!qe(f),promotionExternalAd:f===I.PromotionType.EXTERNAL_AD});break}c?t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionNotification:!0}):t.sdk.uiState.set({onboardingNotification:t.sdk.uiState.get().onboardingNotification,promotionBanner:l,promotionOverlay:qe(f),promotionSidebar:!qe(f),promotionExternalAd:f===I.PromotionType.EXTERNAL_AD});break;case"closed":t.sdk.uiState.set({...t.sdk.uiState.get(),promotionNotification:!1,promotionBanner:!1,promotionOverlay:!1,promotionExternalAd:!1,promotionSidebar:!1}),r({stage:"deactivate",id:p,hasNotification:c,hasBanner:l,isViewed:d});break}}},o=H.listen(i),s=t.activeFeature.subscribe(a=>{a||t.ui.disableApp()});return()=>{o(),s()}}),n()},qs=(t,e,n)=>{const r={onMountedFired:!1},i=new Map,o=new Map;t.sdk=Object.create(null),t.sdk.options=ue(e),t.sdk.withAuth=!1,t.sdk.onMount=({name:s,clear:a},u)=>{if(i.has(s)){const c=o.get(s);c&&c(),i.delete(s),o.delete(s)}i.set(s,{cb:u,clear:a}),t?.stores?.enabled?.get()==="on"&&o.set(s,u())},t.ready=()=>{t.stores.enabled.subscribe(s=>{s==="on"&&r.onMountedFired===!1&&(i.forEach(({cb:a},u)=>o.set(u,a())),r.onMountedFired=!0),s!=="on"&&r.onMountedFired===!0&&(o.forEach(a=>a()),o.clear(),i.forEach(({clear:a},u)=>a&&i.delete(u)),r.onMountedFired=!1)})},t.sdk.initializeApp=s=>(t.contextConfig=s,t.stores.enabled.get()==="on"?Promise.resolve({enabled:!0}):(t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(we.INITIALIZATION),t.stores.organizationSettings.getValue().then(a=>a?(t.stores.status.setValue(we.READY),{enabled:!!a}):(t.stores.status.setValue(we.FAILED),{err:"failed"}),a=>(t.stores.enabled.setValue(),t.stores.status.setValue(we.FAILED),{err:`${a}`})))),t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(we.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=(s,a)=>{a?t.stores.slStreamId.getStore().set({loading:!1,data:s}):t.stores.providerStreamId.setValue(s)},n()},Bs=(t,e)=>{const{client:n,queryKey:r}=t.createPromiseClient(Je.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(r,{fetcher:async(i,o,s,a)=>{if(!s)return{};try{return(await n.generateDeepLink({data:{gamification:!0,externalEventId:a,eventId:s}})).data?.attributes}catch{return}},dedupeTime:1e3*60*60*24,revalidateInterval:0})},Ms=(t,{web:e,mobile:n})=>{const{client:r}=t.createPromiseClient(To.LinksClient,{method:"generate"});return r.generate({web:e,mobile:n})},nn=(t,e)=>{const n=new URLSearchParams(t);for(const[r,i]of Object.entries(e))n.append(r,i);return n.toString()},js=(t,e,n,r)=>{const i=ue({});return ce.onMount(i,()=>Bs(t,[e,n]).subscribe(async({data:a,loading:u})=>{const c=a===void 0&&u===!1?"https://streamlayer.io":a?.url,l=r.get()||"",p=e.get()||"",d=n.get()||"",f={[bt]:l,[Hi]:p,[$i]:d};if(!u&&c){i.setKey("loading",!0);let h=window.location.search,T=window.location.hash;h&&T||T?h=`?${nn(h,f)}`:T=`#${nn("",f)}`;const E=window.location.origin+window.location.pathname+h+T;try{const C=await Ms(t,{web:E,mobile:c});i.set({data:C.data?.link,loading:!1})}catch{i.set({loading:!1,error:"Failed to generate short link",data:void 0})}}else i.setKey("loading",!0)})),{$store:i,fetch}};var te;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(te||(te={}));const Qs=(t,e,n,r)=>{const{inplayGame:i}=t.featureSettings.get(),o=e.getCurrentSessionId({prefix:"onboarding"});i&&n.add({type:ke.ONBOARDING,id:o,action:t.openFeature,close:()=>{t.onboardingProcessed.set(!0)},persistent:!0,autoHideDuration:1e6,data:{questionId:"onboarding",questionType:I.QuestionType.UNSET,onboarding:{...i,instantOpen:!r.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}),markIstantOpen:()=>{r.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}),n.update(o,s=>{s?.data?.onboarding&&(s.data.onboarding.instantOpen=!0)})}}}})},at=(t,e,n,r,i,o,s,a)=>{try{const u=e.userId.get(),c=e.organizationId.get(),l=e.slStreamId.get();if(!u||!c||!l)return;const p=i.getOnboardingStatus({userId:u,organizationId:c,eventId:l});if(p===te.Completed||a?.skipOnboarding){t.set(te.Completed);for(const E of o)E();a?.skipOnboarding&&p!==te.Completed&&(i.saveOnboardingStatus({organizationId:c,userId:u,eventId:l},te.Completed),Ki(s,l));return}const d=e.moderation.getStore().value?.data,f=n.featureSettings.get().inplayGame;if(d===void 0||f===void 0)return;const h=d?.options?.onboardingEnabled,T=f?.titleCard?.optIn;h?T?t.set(te.Required):t.set(te.Optional):(T?t.set(te.Unavailable):t.set(te.Disabled),r.close(e.getCurrentSessionId({prefix:"onboarding"}),{markAsViewed:!1}))}catch(u){console.error(u)}},on=(t,e,n,r,i)=>{let o=!!i?.skipOnboarding;const s=e.storage,a=J(te.Unset);a.subscribe(l=>{l!==te.Unset&&(l===te.Optional||l===te.Required?o===!1&&(Qs(t,e,r,s),o=!0):t.onboardingProcessed.set(!0),s.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const u=[];return a.get()!==te.Completed&&(u.push(e.userId.listen(l=>{l&&at(a,e,t,r,s,u,n,i)})),u.push(e.moderation.listen(l=>{l.data&&at(a,e,t,r,s,u,n,i)})),u.push(t.featureSettings.listen(l=>{l&&at(a,e,t,r,s,u,n,i)}))),at(a,e,t,r,s,u,n,i),{$store:a,submitInplay:async()=>{const l=e.slStreamId.get();if(l){await Ki(n,l),a.set(te.Completed),s.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:l},te.Completed),H.emit("poll",{action:"onboardingPassed",payload:{}}),t.openFeature();const p=e.getCurrentSessionId({prefix:"onboarding"});r.close(p)}}}},Gs=(t,e,n,r)=>{const i=ue(void 0),o=Qi(r),s=async()=>{const u=t.get(),c=e.get(),l=n?n.getStore().get().data?.map(f=>f.slId):[];if(!l||!u||!c)return;const p={eventId:u,userId:c,leaderboardId:"",usersIds:[...l,c]},d=await o(p);i.set(d.data?.attributes)},a=()=>{s()};return ce.onMount(i,()=>{a();const u=t.listen(s),c=n?.listen(s),l=e.listen(s);return()=>{u(),c?.(),l()}}),{$store:i,invalidate:a}},Ws=async(t,e,n,r,i)=>{const o=Qi(i),s=t.get(),a=e.get(),u=n?.getStore().get().data?.map(d=>d.slId)||[],c={eventId:s,userId:r,leaderboardId:"",usersIds:[...u,a]};return(await o(c)).data?.attributes?.summary},sn=new Set([I.QuestionType.POLL,I.QuestionType.PREDICTION,I.QuestionType.TRIVIA]);class Ks extends Mi{userSummary;feedList;betPack;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;feedSubscription;activeQuestionId;openedQuestionId;advertisement;withPickHistory;onboardingProcessed;friendsTabEnabled;skipOnboarding;notifications;transport;background;storage;submitAnswerTimeout;cancels=new Set;onQuestionActivate;constructor(e,n,r){if(super(e,n),this.background=new bs(r),this.advertisement=this.background.advertisement,this.onQuestionActivate=r.onQuestionActivate,this.feedSubscription=this.background.feedSubscription,this.activeQuestionId=this.background.activeQuestionId,this.openedQuestionId=this.background.openedQuestionId,this.storage=this.background.storage,this.feedList=this.background.feedList,this.betPack=this.background.betPack,this.currentUserId=this.background.userId,this.withPickHistory=this.background.withPickHistory,this.onboardingProcessed=J(!r.sdk.withAuth),this.leaderboardId=new de(J(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.notifications=r.notifications,this.transport=r.transport,this.closeFeature=(i=!0)=>r.sdk.closeFeature(i),this.openFeature=()=>r.sdk.openFeature(z.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=js(this.transport,this.background.slStreamId,r.stores.providerStreamId.getStore(),this.background.userId),this.userSummary=Gs(this.background.slStreamId,this.background.userId,this.friends,this.transport),!r.sdk.options.get().hideFriends){this.friends=new me(ns(this.background.userId,r.transport),"gamification:friends"),this.openedUser=J(void 0);const i=this.leaderboardList=ks(this.transport,this.background.slStreamId,this.background.userId,this.friends);this.cancels.add(this.userSummary.$store.listen((o,s)=>{s?.summary&&o?.summary&&i.invalidate()}))}this.connect(),this.skipOnboarding=!!r.sdk.options.get().skipOnboarding,this.onboardingStatus=on(this,this.background,r.transport,r.notifications,{skipOnboarding:r.sdk.options.get().skipOnboarding}),r.sdk.options.get().skipOnboarding||(this.onboardingStatus=on(this,this.background,r.transport,r.notifications,{skipOnboarding:r.sdk.options.get().skipOnboarding})),this.cancels.add(this.onboardingStatus.$store.listen(this.checkInteractiveFlag)),this.cancels.add(this.background.moderation.getStore().listen(this.checkInteractiveFlag)),this.cancels.add(this.settings.subscribe(this.checkInteractiveFlag)),this.background.activeQuestionId.listen(this.showInApp),this.friendsTabEnabled=J(!1),this.cancels.add(r.sdk.options.subscribe(i=>{i.friendsTab==="disabled"?this.friendsTabEnabled.set(!1):i.friendsTab==="enabled"&&this.friendsTabEnabled.set(!0)})),this.cancels.add(this.settings.subscribe(i=>{r.sdk.options.get().friendsTab==="activatedGame"&&this.friendsTabEnabled.set(!!i.inplayGame?.titleCard?.optIn)})),r.sdk.onMount({name:"gamification",clear:!0},()=>()=>{for(const i of this.cancels)i(),this.cancels.delete(i)})}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===Pe.ALLOWED}checkInteractiveFlag=()=>{if(this.skipOnboarding)this.background.interactiveAllowed.set(Pe.ALLOWED);else{const e=this.onboardingStatus.$store.get(),n=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,r=this.settings.getValues().inplayGame?.titleCard?.optIn,i=e===te.Completed,o=!n||i||r!==!0;this.background.interactiveAllowed.set(o?Pe.ALLOWED:Pe.DISALLOWED)}};connect=()=>{this.onboardingProcessed.subscribe(e=>{e&&this.advertisement&&this.advertisement.connect()}),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-prediction-close",async e=>{if(!this.isInteractiveAllowed)return;const n=e.data?.attributes?.question,r=e.data?.attributes?.feedItem;if(!n||!r?.attributes)return;const{status:i,type:o,id:s,answers:a}=n;if(i===I.QuestionStatus.RESOLVED&&o===I.QuestionType.PREDICTION){const u=this.background.getCurrentSessionId({prefix:`notification-id:${s}`}),c=[...this.feedList.getValues().data||[]],l=c.findIndex(S=>S.id===s),p=c[l];let d=p?.attributes?.attributes?.value?.answerId;const f=mt(s,this.transport),h=f.subscribe(()=>{});await f.fetch();let T=f.get().data;T||(T=await Gi(s,this.transport),f.mutate(T)),h(),window.requestAnimationFrame(()=>{f.invalidate()}),d||(d=T?.answers.find(({youVoted:S})=>S)?.id);const E=a.find(({correct:S})=>S),C=d?a.find(({id:S})=>S===d):void 0,g=!!C?.correct;if(p&&c[l]?.attributes?.attributes.case==="question"){try{c[l].attributes.attributes.value.answerId=d,c[l].attributes.attributes.value.openForVoting=!1,d&&(c[l].attributes.attributes.value.status=g?ie.PickHistoryStatus.WON:ie.PickHistoryStatus.LOST)}catch{}this.feedList.getStore().mutate(c)}if(!C||!E)return;this.openedQuestionId.get()?.questionId!==n.id&&this.notifications.add({type:ke.QUESTION_RESOLVED,action:()=>this.openQuestion(n.id,r),close:()=>this.closeQuestion(s),autoHideDuration:g?15e3:14e3,id:u,emitEvent:!1,data:{questionId:s,questionType:I.QuestionType.PREDICTION,question:{title:g?`Congratulations! You answered correctly! You won ${E.points} pts!`:`Better luck next time! Correct: ${E?.text}!`,votedAnswer:{title:C?.text,points:C?.points},correctAnswerTitle:E?.text,correct:!!g,predictionResult:!0,questionTitle:n?.subject},inApp:{notification:n.notification,appearance:n.appearance,sponsorship:n.sponsorship,adUnit:n?.adUnit,sponsorLogo:n.promotion?.sponsor?.logo}}}),this.userSummary.invalidate()}})),ce.onStart(this.feedList.getStore(),()=>{this.cancels.add(this.feedList.subscribe(()=>{}))}),this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-questions-list",e=>{const n=[...this.feedList.getStore().value?.data||[]],r=e.data?.attributes?.feedItem,i=n.findIndex(o=>o.id===r?.id);if(r?.attributes&&r.attributes.attributes.case!=="promotion"&&!(r.attributes.status!==I.QuestionStatus.ACTIVE&&r.attributes.status!==I.QuestionStatus.RESOLVED)&&!(!this.isInteractiveAllowed&&sn.has(r.attributes.type)&&r?.attributes?.adUnit!==I.AdUnit.STANDART)){if(i!==-1)if(r.attributes.attributes.case==="question"&&n[i].attributes?.attributes.case==="question"){const o=n[i];o.attributes&&(n[i]={...n[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...r.attributes.attributes.value,answerId:o.attributes.attributes.value.answerId,status:o.attributes.attributes.value.status,openForVoting:o.attributes.attributes.value.openForVoting===!1?!1:r.attributes.attributes.value.openForVoting}}}})}else{const o=n[i];o.attributes&&r.attributes&&(n[i]={...n[i],attributes:{...o.attributes,attributes:{...o.attributes.attributes,value:{...o.attributes.attributes.value,...r.attributes.attributes.value}}}})}i===-1&&this.feedList.isEnabled()&&n.unshift(r),this.feedList.isEnabled()&&this.feedList.getStore().mutate(n)}}))};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-prediction-close"),this.background.feedSubscription.removeListener("feed-subscription-questions-list")};betPackVote=async(e,n)=>{if(!this.betPack)return;try{await Jr(this.transport,{questionId:e,answerId:n})}catch(o){if(o.message===Ge.ALREADY_VOTED){const s=mt(e,this.transport),a=s.subscribe(()=>{});s.invalidate(),a()}throw o}const r={...this.betPack.getValues().data?.data},i=r?.[e];i&&(H.emit("poll",{action:"voted",payload:{questionId:e,isAd:i?.adUnit==I.AdUnit.STANDART||i?.promotion?.adUnit==I.AdUnit.STANDART,questionType:i.type}}),i.answers=i.answers.map(o=>o.id===n?{...o,youVoted:!0}:o),this.betPack.getStore().mutate({data:r,timestamp:Date.now()}))};submitAnswer=async(e,n)=>{const r=mt(e,this.transport),i=r.subscribe(()=>{}),o={...r.get().data||{}},s=()=>{const a=this.feedList.getValues().data,u=a?.findIndex(f=>f.id===e),c=u&&u>=0&&a?a[u]:void 0,l=c?.attributes?.attributes.case==="question"&&c?.attributes?.attributes.value||o,p=c?.attributes?.adUnit==I.AdUnit.STANDART||c?.attributes?.adPromotion?.adUnit==I.AdUnit.STANDART||o?.adUnit==I.AdUnit.STANDART||o?.promotion?.adUnit==I.AdUnit.STANDART,d=c?.attributes?.type||o?.type;if(l){H.emit("poll",{action:"voted",payload:{isAd:p,questionId:e,questionType:d}});const f=r.get().data;if(i(),f){const h=f.answers.find(g=>g.correct===!0),T=f.answers.findIndex(g=>g.id===n),E=f.answers[T],C=f.answers.every(({percentageDecimal:g},S)=>g===o?.answers[S].percentageDecimal);a&&u&&u>=0&&(a[u].attributes.attributes.value.answerId=n,a[u].attributes.attributes.value.openForVoting=!1,a[u].attributes.attributes.value.text=E?.text||"",h&&(a[u].attributes.attributes.value.status=h.id===n?ie.PickHistoryStatus.WON:ie.PickHistoryStatus.LOST),this.feedList.getStore().mutate([...a])),f.answers[T].correct=h?.id===n,f.answers[T].youVoted=!0,C&&f.answers.forEach(g=>{g.percentageDecimal=0}),h?.id===n&&(f.answers[T].pointsEarned=f.status===I.QuestionStatus.RESOLVED?0:h.points),r.mutate({...f})}this.submitAnswerTimeout&&clearTimeout(this.submitAnswerTimeout),this.submitAnswerTimeout=setTimeout(()=>{this.userSummary.invalidate()},1e3)}};try{await Jr(this.transport,{questionId:e,answerId:n}),s()}catch(a){if(a.message===Ge.ALREADY_VOTED){this.userSummary.invalidate();const u=r.subscribe(()=>{});r.invalidate(),u()}throw a}};openQuestion=(e,n)=>{if(!e)return()=>{};const r=n?.openedFrom==="bet-pack";this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e}),{animateHiding:!1});let i=n?.attributes?.type,o=(n?.attributes?.adUnit===I.AdUnit.STANDART||n?.attributes?.adPromotion?.adUnit===I.AdUnit.STANDART)&&!!n?.attributes?.adPromotion?.banner?.imageUrl;if(!i&&!r){const u=(this.feedList.getStore().value?.data||[]).find(c=>c.id===e)?.attributes;i=u?.type,o=(u?.adUnit===I.AdUnit.STANDART||u?.adPromotion?.adUnit===I.AdUnit.STANDART)&&!!u?.adPromotion?.banner?.imageUrl}const s={eventId:this.background.slStreamId.get()||"",userId:this.background.userId.get()||"",organizationId:this.background.organizationId.get()||""};return H.emit("poll",{action:"opened",payload:{questionId:e,questionType:i,isAd:n?.attributes?.adUnit!=I.AdUnit.UNSET,questionOpenedFrom:n?.openedFrom==="bet-pack"?"list":n?.openedFrom,hasBanner:o}}),this.storage.isQuestionOpened(s,e)||(H.emit("poll",{action:"viewed",payload:{questionId:e,questionType:i,isAd:n?.attributes?.adUnit!=I.AdUnit.UNSET,questionOpenedFrom:n?.openedFrom==="bet-pack"?"list":n?.openedFrom}}),this.storage.saveQuestionOpened(s,e)),r||this.openFeature(),this.background.openQuestion(e,n?{...n,openedFrom:n?.openedFrom==="bet-pack"?"list":n?.openedFrom}:void 0)};getFeedItem=e=>ss(e,this.transport);isOpenedQuestion=e=>!!this.notifications.isViewed(e);closeQuestion=e=>(e&&(this.onQuestionActivate({stage:"deactivate",id:e,isViewed:!!this.notifications.isViewed(this.background.getCurrentSessionId({prefix:"notification",entity:e}))}),H.emit("poll",{action:"closed",payload:{questionId:e}})),this.background.closeQuestion(e));openUser=async e=>{if(!this.leaderboardList)return;const n=this.leaderboardList?.$store.get().data?.find(i=>i.userId===e);if(!n){this.openedUser?.set(n);return}if(n.summaryLoaded){this.openedUser?.set(n);return}const r={...n};try{const i=await Ws(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))),r.inTop=i.inTop)}catch(i){console.error(i)}this.openedUser.set(r)};closeUser=()=>{this.openedUser?.set(void 0)};openOnboarding=()=>{this.openFeature(),H.emit("poll",{action:"onboardingOpen",payload:{}})};sendWebhookEvent=(e,n)=>Is(this.transport,{eventId:this.background.slStreamId.get(),questionId:e,userId:this.background.userId.get(),userAccountInfo:n});showInApp=e=>{if(e.loading)return;const n=this.onboardingStatus.$store.get(),r=e?.data?.question?.adUnit===I.AdUnit.STANDART;if(e&&e.data&&(r||n&&n!==te.Unset)&&e.data.question?.id!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==I.SilenceSetting.ON&&e.data.question.status===I.QuestionStatus.ACTIVE&&!e.data.question.marketClosed){if(sn.has(e.data.question.type))(this.isInteractiveAllowed||r)&&e.data.question.notification!==void 0&&(e.data.question.notification.enabled===I.NotificationEnabled.NOTIFICATION_ENABLED?this.notifications.add({type:ke.QUESTION,action:()=>this.openQuestion(e.data?.question?.id,e.data?.feedItem),close:()=>this.closeQuestion(e.data?.question?.id),autoHideDuration:1e3*60,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),emitEvent:!0,data:{questionId:e.data.question.id,questionType:e.data.question.type,question:{title:e.data.question.notification.title},inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship,adUnit:e.data.question?.adUnit,sponsorLogo:e.data.question.promotion?.sponsor?.logo}}}):this.openQuestion(e.data?.question?.id,e.data?.feedItem));else if(e.data.question.type===I.QuestionType.FACTOID){const i=e.data.question.options?.options.value,o=e.data.question.notification?.useContentTexts===I.NotificationUseContentTexts.ENABLED?e.data.question.subject:e.data.question.notification?.title||"",s=e.data.question.notification?.useContentTexts===I.NotificationUseContentTexts.ENABLED?i.body:e.data.question.notification?.body,a={heading:o,body:s,imageMode:i?.imageMode,image:i?.image,video:{id:i?.video?.id||"",url:i?.video?.url||"",thumbnailUrl:i?.video?.thumbnailUrl||""},webLink:{label:"",url:""}};this.notifications.add({type:ke.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:a,inApp:{useMediaFromContent:i?.useAsNotification===I.UseAsNotification.ENABLED,notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship,adUnit:e.data.question?.adUnit,sponsorLogo:e.data.question.promotion?.sponsor?.logo,isVideo:i?.mode===I.FactoidMediaMode.VIDEO}}})}else if(e.data.question.type===I.QuestionType.TWEET&&e.data.question.notification!==void 0){const i=e.data.question.options?.options.value,o={image:"",video:""};if(i.tweetMeta?.tweet?.meta?.extendedEntities?.media?.[0]){const a=i.tweetMeta.tweet.meta.extendedEntities.media;if(a){const u=a.find(({type:c})=>c==="photo")||a[0];o.image=u.mediaUrlHttps,u.type==="video"&&(o.video=u.url)}}const s={title:e.data.question.notification?.title,body:e.data.question.notification?.body,image:e.data.question.notification?.image,account:i?.tweetMeta?.account||"",accountVerified:!!i?.tweetMeta?.accountVerified,tweet:i?.tweetMeta?.tweet,tweetId:e.data.question.id,tweetMedia:o};this.notifications.add({type:ke.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:s,inApp:{notification:e.data.question.notification,appearance:e.data.question.appearance,sponsorship:e.data.question.sponsorship}}})}}}}const Hs={[z.SdkOverlayType.GAMES]:!0};class $s extends Mi{constructor(e,n){super(e,n)}}const zs=(t,e,n)=>t.type===z.SdkOverlayType.GAMES?new Ks(t,e,n):new $s(t,e),Ys=(t,e,n)=>{t.features=new Map,t.sdk.featuresList=new de(J(new Set),"features-list"),t.activeFeature=new de(J(z.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=r=>t.features.get(r),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=r=>{t.sdk.initializeApp().then(()=>{t.activeFeature.setValue(r)})},t.sdk.closeFeature=(r=!1)=>{const i=t.activeFeature.getValue();if(t.activeFeature.setValue(z.SdkOverlayType.UNSET),r&&i){t.features.delete(i);const o=t.sdk.featuresList.getValue();o&&o.delete(i),t.sdk.featuresList.setValue(o)}},t.initFeature=(r,i=Ee.ORGANIZATION)=>{if(r.type in Hs&&!t.features.has(r.type)){const o=zs(r,i,t);t.features.set(r.type,o);let s=t.sdk.featuresList.getValue();s?s.add(r.type):s=new Set([r.type]),t.sdk.featuresList.setValue(new Set(s))}},t.updateFeature=(r,i)=>{t.features.get(r.type)?.update(r,i)},t.destroyFeature=r=>{t.features.delete(r.type);const i=t.sdk.featuresList.getValue();i&&i.delete(r.type),t.sdk.featuresList.setValue(new Set(i))},t.reinitializeFeatures=async()=>{const r=await t.stores.organizationSettings.getValue();t.features.clear(),t.sdk.featuresList.setValue(new Set);for(const i of r?.overlays||[])t.initFeature(i,Ee.ORGANIZATION)},t.stores.providerStreamId.listen(r=>{r||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const r=(o,s)=>{if(s?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&o===Ee.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{r(Ee.ORGANIZATION,o.data)}catch(s){console.log(s)}},streamSettings:o=>{if(o.data)try{r(Ee.STREAM,o.data)}catch(s){console.log(s)}}};t.store.subscribe(i)},n()},Xs=(t,e,n)=>{const{client:r,queryKey:i}=n.createPromiseClient(Hr.PolymarketSportsClient,{method:"getMarketWithSeries",params:[t,e]});return n.nanoquery.createFetcherStore(i,{fetcher:async(o,s,a,u)=>{if(u)try{return(await r.getMarketWithSeries({eventId:a,timeframe:Hr.Timeframe.TIMEFRAME_ALL})).event}catch{return}}})},Js=t=>{const e=t.stores.slStreamId.getAtomStore(),n=t.stores.user.getAtomStore();return Xs(e,n,t.transport)};class Zs extends Bi{marketWithSeries;log;constructor(e){super(),this.log=le("polymarket"),this.marketWithSeries=Js(e)}connect=()=>{this.log.debug("connect")};disconnect=()=>{this.marketWithSeries.off(),this.log.debug("disconnect")}}const ea=(t,e,n)=>{t.sdk.polymarket=new Zs(t),t.sdk.onMount({name:"polymarket"},()=>(t.sdk.polymarket.connect(),()=>{t.sdk.polymarket.disconnect()})),n()};function xr(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{id:t.id||null,adId:t.adId||null,sequence:t.sequence||null,apiFramework:t.apiFramework||null,universalAdIds:[],creativeExtensions:[]}}const ta=["ADCATEGORIES","ADCOUNT","ADPLAYHEAD","ADSERVINGID","ADTYPE","APIFRAMEWORKS","APPBUNDLE","ASSETURI","BLOCKEDADCATEGORIES","BREAKMAXADLENGTH","BREAKMAXADS","BREAKMAXDURATION","BREAKMINADLENGTH","BREAKMINDURATION","BREAKPOSITION","CLICKPOS","CLICKTYPE","CLIENTUA","CONTENTID","CONTENTPLAYHEAD","CONTENTURI","DEVICEIP","DEVICEUA","DOMAIN","EXTENSIONS","GDPRCONSENT","IFA","IFATYPE","INVENTORYSTATE","LATLONG","LIMITADTRACKING","MEDIAMIME","MEDIAPLAYHEAD","OMIDPARTNER","PAGEURL","PLACEMENTTYPE","PLAYERCAPABILITIES","PLAYERSIZE","PLAYERSTATE","PODSEQUENCE","REGULATIONS","SERVERSIDE","SERVERUA","TRANSACTIONID","UNIVERSALADID","VASTVERSIONS","VERIFICATIONVENDORS"];function an(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=[],i=Yi(t);!e.ERRORCODE||n.isCustomCode||/^[0-9]{3}$/.test(e.ERRORCODE)||(e.ERRORCODE=900),e.CACHEBUSTING=Zi(Math.round(1e8*Math.random())),e.TIMESTAMP=new Date().toISOString(),e.RANDOM=e.random=e.CACHEBUSTING;for(const o in e)e[o]=Ji(e[o]);for(const o in i){const s=i[o];typeof s=="string"&&r.push(zi(s,e))}return r}function zi(t,e){const n=(t=un(t,e)).match(/[^[\]]+(?=])/g);if(!n)return t;let r=n.filter((i=>ta.indexOf(i)>-1));return r.length===0?t:(r=r.reduce(((i,o)=>(i[o]=-1,i)),{}),un(t,r))}function un(t,e){let n=t;for(const r in e){const i=e[r];n=n.replace(new RegExp("(?:\\[|%%)(".concat(r,")(?:\\]|%%)"),"g"),i)}return n}function Yi(t){return Array.isArray(t)?t.map((e=>e&&e.hasOwnProperty("url")?e.url:e)):t}function cn(t){return/^(https?:\/\/|\/\/)/.test(t)}function ln(t,e){for(let n=0;n<e.length;n++)if(Xi(e[n],t))return!0;return!1}function Xi(t,e){if(t&&e){const n=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);return n.length===r.length&&t.id===e.id&&t.url===e.url}return!1}function Ji(t){return encodeURIComponent(t).replace(/[!'()*]/g,(e=>"%".concat(e.charCodeAt(0).toString(16))))}function Zi(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8;return t.toString().padStart(e,"0")}const Fe={track:function(t,e,n){an(t,e,n).forEach((r=>{typeof window<"u"&&window!==null&&(new Image().src=r)}))},resolveURLTemplates:an,extractURLsFromTemplates:Yi,filterUrlTemplates:function(t){return t.reduce(((e,n)=>{const r=n.url||n;return cn(r)?e.validUrls.push(r):e.invalidUrls.push(r),e}),{validUrls:[],invalidUrls:[]})},containsTemplateObject:ln,isTemplateObjectEqual:Xi,encodeURIComponentRFC3986:Ji,replaceUrlMacros:zi,isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},flatten:function t(e){return e.reduce(((n,r)=>n.concat(Array.isArray(r)?t(r):r)),[])},joinArrayOfUniqueTemplateObjs:function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];const n=Array.isArray(t)?t:[],r=Array.isArray(e)?e:[];return n.concat(r).reduce(((i,o)=>(ln(o,i)||i.push(o),i)),[])},isValidTimeValue:function(t){return Number.isFinite(t)&&t>=-2},addLeadingZeros:Zi,isValidUrl:cn,isBrowserEnvironment:function(){return typeof window<"u"},formatMacrosValues:function(t){return typeof t!="object"?t:JSON.stringify(t)}};function dn(t){return["true","TRUE","True","1"].includes(t)}function ra(t){if(t==null)return-1;if(Fe.isNumeric(t))return parseInt(t);const e=t.split(":");if(e.length!==3)return-1;const n=e[2].split(".");let r=parseInt(n[0]);n.length===2&&(r+=parseFloat("0.".concat(n[1])));const i=parseInt(60*e[1]),o=parseInt(60*e[0]*60);return isNaN(o)||isNaN(i)||isNaN(r)||i>3600||r>60?-1:o+i+r}const v={childByName:function(t,e){return Array.from(t.childNodes).find((n=>n.nodeName===e))},childrenByName:function(t,e){return Array.from(t.childNodes).filter((n=>n.nodeName===e))},resolveVastAdTagURI:function(t,e){if(!e)return t;if(t.startsWith("//")){const{protocol:n}=location;return"".concat(n).concat(t)}if(!t.includes("://")){const n=e.slice(0,e.lastIndexOf("/"));return"".concat(n,"/").concat(t)}return t},parseBoolean:dn,parseNodeText:function(t){return t&&(t.textContent||t.text||"").trim()},copyNodeAttribute:function(t,e,n){const r=e.getAttribute(t);r&&n.setAttribute(t,r)},parseAttributes:function(t){return Array.from(t.attributes).reduce(((e,n)=>(e[n.nodeName]=n.nodeValue,e)),{})},parseDuration:ra,getStandAloneAds:function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).filter((t=>!parseInt(t.sequence,10)))},getSortedAdPods:function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).filter((t=>parseInt(t.sequence,10))).sort(((t,e)=>t.sequence-e.sequence))},assignAttributes:function(t,e){t&&Array.from(t).forEach((n=>{let{nodeName:r,nodeValue:i}=n;if(r&&i&&e.hasOwnProperty(r)){let o=i;typeof e[r]=="boolean"&&(o=dn(o)),e[r]=o}}))},mergeWrapperAdData:function(t,e){var n;t.errorURLTemplates=e.errorURLTemplates.concat(t.errorURLTemplates),t.impressionURLTemplates=e.impressionURLTemplates.concat(t.impressionURLTemplates),t.extensions=e.extensions.concat(t.extensions),e.viewableImpression.length>0&&(t.viewableImpression=[...t.viewableImpression,...e.viewableImpression]),t.followAdditionalWrappers=e.followAdditionalWrappers,t.allowMultipleAds=e.allowMultipleAds,t.fallbackOnNoAd=e.fallbackOnNoAd;const r=(e.creatives||[]).filter((a=>a&&a.type==="companion")),i=r.reduce(((a,u)=>((u.variations||[]).forEach((c=>{(c.companionClickTrackingURLTemplates||[]).forEach((l=>{Fe.containsTemplateObject(l,a)||a.push(l)}))})),a)),[]);t.creatives=r.concat(t.creatives);const o=e.videoClickTrackingURLTemplates&&e.videoClickTrackingURLTemplates.length,s=e.videoCustomClickURLTemplates&&e.videoCustomClickURLTemplates.length;if(t.creatives.forEach((a=>{if(e.trackingEvents&&e.trackingEvents[a.type])for(const u in e.trackingEvents[a.type]){const c=e.trackingEvents[a.type][u];Array.isArray(a.trackingEvents[u])||(a.trackingEvents[u]=[]),a.trackingEvents[u]=a.trackingEvents[u].concat(c)}a.type==="linear"&&(o&&(a.videoClickTrackingURLTemplates=a.videoClickTrackingURLTemplates.concat(e.videoClickTrackingURLTemplates)),s&&(a.videoCustomClickURLTemplates=a.videoCustomClickURLTemplates.concat(e.videoCustomClickURLTemplates)),!e.videoClickThroughURLTemplate||a.videoClickThroughURLTemplate!==null&&a.videoClickThroughURLTemplate!==void 0||(a.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate)),a.type==="companion"&&i.length&&(a.variations||[]).forEach((u=>{u.companionClickTrackingURLTemplates=Fe.joinArrayOfUniqueTemplateObjs(u.companionClickTrackingURLTemplates,i)}))})),e.adVerifications&&(t.adVerifications=t.adVerifications.concat(e.adVerifications)),e.blockedAdCategories&&(t.blockedAdCategories=t.blockedAdCategories.concat(e.blockedAdCategories)),(n=e.creatives)!==null&&n!==void 0&&n.length){const a=e.creatives.filter((u=>{var c;return((c=u.icons)===null||c===void 0?void 0:c.length)&&!u.mediaFiles.length}));a.length&&(t.creatives=t.creatives.concat(a))}}};function na(t,e){const n=(function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{id:i,adId:o,sequence:s,apiFramework:a}=xr(r);return{id:i,adId:o,sequence:s,apiFramework:a,type:"companion",required:null,variations:[]}})(e);return n.required=t.getAttribute("required")||null,n.variations=v.childrenByName(t,"Companion").map((r=>{const i=(function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{id:a.id||null,adType:"companionAd",width:a.width||0,height:a.height||0,assetWidth:a.assetWidth||null,assetHeight:a.assetHeight||null,expandedWidth:a.expandedWidth||null,expandedHeight:a.expandedHeight||null,apiFramework:a.apiFramework||null,adSlotId:a.adSlotId||null,pxratio:a.pxratio||"1",renderingMode:a.renderingMode||"default",staticResources:[],htmlResources:[],iframeResources:[],adParameters:null,altText:null,companionClickThroughURLTemplate:null,companionClickTrackingURLTemplates:[],trackingEvents:{}}})(v.parseAttributes(r));i.htmlResources=v.childrenByName(r,"HTMLResource").reduce(((a,u)=>{const c=v.parseNodeText(u);return c?a.concat(c):a}),[]),i.iframeResources=v.childrenByName(r,"IFrameResource").reduce(((a,u)=>{const c=v.parseNodeText(u);return c?a.concat(c):a}),[]),i.staticResources=v.childrenByName(r,"StaticResource").reduce(((a,u)=>{const c=v.parseNodeText(u);return c?a.concat({url:c,creativeType:u.getAttribute("creativeType")||null}):a}),[]),i.altText=v.parseNodeText(v.childByName(r,"AltText"))||null;const o=v.childByName(r,"TrackingEvents");o&&v.childrenByName(o,"Tracking").forEach((a=>{const u=a.getAttribute("event"),c=v.parseNodeText(a);u&&c&&(Array.isArray(i.trackingEvents[u])||(i.trackingEvents[u]=[]),i.trackingEvents[u].push(c))})),i.companionClickTrackingURLTemplates=v.childrenByName(r,"CompanionClickTracking").map((a=>({id:a.getAttribute("id")||null,url:v.parseNodeText(a)}))),i.companionClickThroughURLTemplate=v.parseNodeText(v.childByName(r,"CompanionClickThrough"))||null;const s=v.childByName(r,"AdParameters");return s&&(i.adParameters={value:v.parseNodeText(s),xmlEncoded:s.getAttribute("xmlEncoded")||null}),i})),n}function ia(t,e){let n;const r=(function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{id:c,adId:l,sequence:p,apiFramework:d}=xr(u);return{id:c,adId:l,sequence:p,apiFramework:d,type:"linear",duration:0,skipDelay:null,mediaFiles:[],mezzanine:null,interactiveCreativeFile:null,closedCaptionFiles:[],videoClickThroughURLTemplate:null,videoClickTrackingURLTemplates:[],videoCustomClickURLTemplates:[],adParameters:null,icons:[],trackingEvents:{}}})(e);r.duration=v.parseDuration(v.parseNodeText(v.childByName(t,"Duration")));const i=t.getAttribute("skipoffset");if(i==null)r.skipDelay=null;else if(i.charAt(i.length-1)==="%"&&r.duration!==-1){const u=parseInt(i,10);r.skipDelay=r.duration*(u/100)}else r.skipDelay=v.parseDuration(i);const o=v.childByName(t,"VideoClicks");if(o){const u=v.childByName(o,"ClickThrough");r.videoClickThroughURLTemplate=u?{id:u.getAttribute("id")||null,url:v.parseNodeText(u)}:null,v.childrenByName(o,"ClickTracking").forEach((c=>{r.videoClickTrackingURLTemplates.push({id:c.getAttribute("id")||null,url:v.parseNodeText(c)})})),v.childrenByName(o,"CustomClick").forEach((c=>{r.videoCustomClickURLTemplates.push({id:c.getAttribute("id")||null,url:v.parseNodeText(c)})}))}const s=v.childByName(t,"AdParameters");s&&(r.adParameters={value:v.parseNodeText(s),xmlEncoded:s.getAttribute("xmlEncoded")||null}),v.childrenByName(t,"TrackingEvents").forEach((u=>{v.childrenByName(u,"Tracking").forEach((c=>{let l=c.getAttribute("event");const p=v.parseNodeText(c);if(l&&p){if(l==="progress"){if(n=c.getAttribute("offset"),!n)return;l=n.charAt(n.length-1)==="%"?"progress-".concat(n):"progress-".concat(v.parseDuration(n))}Array.isArray(r.trackingEvents[l])||(r.trackingEvents[l]=[]),r.trackingEvents[l].push(p)}}))})),v.childrenByName(t,"MediaFiles").forEach((u=>{v.childrenByName(u,"MediaFile").forEach((f=>{r.mediaFiles.push((function(h){const T={id:null,fileURL:null,fileSize:0,deliveryType:"progressive",mimeType:null,mediaType:null,codec:null,bitrate:0,minBitrate:0,maxBitrate:0,width:0,height:0,apiFramework:null,scalable:null,maintainAspectRatio:null};T.id=h.getAttribute("id"),T.fileURL=v.parseNodeText(h),T.deliveryType=h.getAttribute("delivery"),T.codec=h.getAttribute("codec"),T.mimeType=h.getAttribute("type"),T.mediaType=h.getAttribute("mediaType")||"2D",T.apiFramework=h.getAttribute("apiFramework"),T.fileSize=parseInt(h.getAttribute("fileSize")||0),T.bitrate=parseInt(h.getAttribute("bitrate")||0),T.minBitrate=parseInt(h.getAttribute("minBitrate")||0),T.maxBitrate=parseInt(h.getAttribute("maxBitrate")||0),T.width=parseInt(h.getAttribute("width")||0),T.height=parseInt(h.getAttribute("height")||0);const E=h.getAttribute("scalable");E&&typeof E=="string"&&(T.scalable=v.parseBoolean(E));const C=h.getAttribute("maintainAspectRatio");return C&&typeof C=="string"&&(T.maintainAspectRatio=v.parseBoolean(C)),T})(f))}));const c=v.childByName(u,"InteractiveCreativeFile");c&&(r.interactiveCreativeFile=(function(f){const h=(function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{type:T.type||null,apiFramework:T.apiFramework||null,variableDuration:v.parseBoolean(T.variableDuration),fileURL:null}})(v.parseAttributes(f));return h.fileURL=v.parseNodeText(f),h})(c));const l=v.childByName(u,"ClosedCaptionFiles");l&&v.childrenByName(l,"ClosedCaptionFile").forEach((f=>{const h=(function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{type:T.type||null,language:T.language||null,fileURL:null}})(v.parseAttributes(f));h.fileURL=v.parseNodeText(f),r.closedCaptionFiles.push(h)}));const p=v.childByName(u,"Mezzanine"),d=(function(f,h){const T={};let E=!1;return h.forEach((C=>{f&&f.getAttribute(C)?T[C]=f.getAttribute(C):E=!0})),E?null:T})(p,["delivery","type","width","height"]);if(d){const f={id:null,fileURL:null,delivery:null,codec:null,type:null,width:0,height:0,fileSize:0,mediaType:"2D"};f.id=p.getAttribute("id"),f.fileURL=v.parseNodeText(p),f.delivery=d.delivery,f.codec=p.getAttribute("codec"),f.type=d.type,f.width=parseInt(d.width,10),f.height=parseInt(d.height,10),f.fileSize=parseInt(p.getAttribute("fileSize"),10),f.mediaType=p.getAttribute("mediaType")||"2D",r.mezzanine=f}}));const a=v.childByName(t,"Icons");return a&&v.childrenByName(a,"Icon").forEach((u=>{r.icons.push((function(c){const l={program:null,height:0,width:0,xPosition:0,yPosition:0,apiFramework:null,offset:null,duration:0,type:null,staticResource:null,htmlResource:null,iframeResource:null,pxratio:"1",iconClickThroughURLTemplate:null,iconClickTrackingURLTemplates:[],iconViewTrackingURLTemplate:null,iconClickFallbackImages:[],altText:null,hoverText:null};l.program=c.getAttribute("program"),l.height=parseInt(c.getAttribute("height")||0),l.width=parseInt(c.getAttribute("width")||0),l.xPosition=(function(d){return["left","right"].indexOf(d)!==-1?d:parseInt(d||0)})(c.getAttribute("xPosition")),l.yPosition=(function(d){return["top","bottom"].indexOf(d)!==-1?d:parseInt(d||0)})(c.getAttribute("yPosition")),l.apiFramework=c.getAttribute("apiFramework"),l.pxratio=c.getAttribute("pxratio")||"1",l.offset=v.parseDuration(c.getAttribute("offset")),l.duration=v.parseDuration(c.getAttribute("duration")),l.altText=c.getAttribute("altText"),l.hoverText=c.getAttribute("hoverText"),v.childrenByName(c,"HTMLResource").forEach((d=>{l.type=d.getAttribute("creativeType")||"text/html",l.htmlResource=v.parseNodeText(d)})),v.childrenByName(c,"IFrameResource").forEach((d=>{l.type=d.getAttribute("creativeType")||0,l.iframeResource=v.parseNodeText(d)})),v.childrenByName(c,"StaticResource").forEach((d=>{l.type=d.getAttribute("creativeType")||0,l.staticResource=v.parseNodeText(d)}));const p=v.childByName(c,"IconClicks");if(p){l.iconClickThroughURLTemplate=v.parseNodeText(v.childByName(p,"IconClickThrough")),v.childrenByName(p,"IconClickTracking").forEach((f=>{l.iconClickTrackingURLTemplates.push({id:f.getAttribute("id")||null,url:v.parseNodeText(f)})}));const d=v.childByName(p,"IconClickFallbackImages");d&&v.childrenByName(d,"IconClickFallbackImage").forEach((f=>{l.iconClickFallbackImages.push({url:v.parseNodeText(f)||null,width:f.getAttribute("width")||null,height:f.getAttribute("height")||null})}))}return l.iconViewTrackingURLTemplate=v.parseNodeText(v.childByName(c,"IconViewTracking")),l})(u))})),r}function oa(t,e){const n=(function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{id:i,adId:o,sequence:s,apiFramework:a}=xr(r);return{id:i,adId:o,sequence:s,apiFramework:a,type:"nonlinear",variations:[],trackingEvents:{}}})(e);return v.childrenByName(t,"TrackingEvents").forEach((r=>{let i,o;v.childrenByName(r,"Tracking").forEach((s=>{i=s.getAttribute("event"),o=v.parseNodeText(s),i&&o&&(Array.isArray(n.trackingEvents[i])||(n.trackingEvents[i]=[]),n.trackingEvents[i].push(o))}))})),v.childrenByName(t,"NonLinear").forEach((r=>{const i={id:null,width:0,height:0,expandedWidth:0,expandedHeight:0,scalable:!0,maintainAspectRatio:!0,minSuggestedDuration:0,apiFramework:"static",adType:"nonLinearAd",type:null,staticResource:null,htmlResource:null,iframeResource:null,nonlinearClickThroughURLTemplate:null,nonlinearClickTrackingURLTemplates:[],adParameters:null};i.id=r.getAttribute("id")||null,i.width=r.getAttribute("width"),i.height=r.getAttribute("height"),i.expandedWidth=r.getAttribute("expandedWidth"),i.expandedHeight=r.getAttribute("expandedHeight"),i.scalable=v.parseBoolean(r.getAttribute("scalable")),i.maintainAspectRatio=v.parseBoolean(r.getAttribute("maintainAspectRatio")),i.minSuggestedDuration=v.parseDuration(r.getAttribute("minSuggestedDuration")),i.apiFramework=r.getAttribute("apiFramework"),v.childrenByName(r,"HTMLResource").forEach((s=>{i.type=s.getAttribute("creativeType")||"text/html",i.htmlResource=v.parseNodeText(s)})),v.childrenByName(r,"IFrameResource").forEach((s=>{i.type=s.getAttribute("creativeType")||0,i.iframeResource=v.parseNodeText(s)})),v.childrenByName(r,"StaticResource").forEach((s=>{i.type=s.getAttribute("creativeType")||0,i.staticResource=v.parseNodeText(s)}));const o=v.childByName(r,"AdParameters");o&&(i.adParameters={value:v.parseNodeText(o),xmlEncoded:o.getAttribute("xmlEncoded")||null}),i.nonlinearClickThroughURLTemplate=v.parseNodeText(v.childByName(r,"NonLinearClickThrough")),v.childrenByName(r,"NonLinearClickTracking").forEach((s=>{i.nonlinearClickTrackingURLTemplates.push({id:s.getAttribute("id")||null,url:v.parseNodeText(s)})})),n.variations.push(i)})),n}function pn(t){const e=[];return t.forEach((n=>{const r=eo(n);r&&e.push(r)})),e}function eo(t){if(t.nodeName==="#comment")return null;const e={name:null,value:null,attributes:{},children:[]},n=t.attributes,r=t.childNodes;if(e.name=t.nodeName,t.attributes){for(const o in n)if(n.hasOwnProperty(o)){const s=n[o];s.nodeName&&s.nodeValue&&(e.attributes[s.nodeName]=s.nodeValue)}}for(const o in r)if(r.hasOwnProperty(o)){const s=eo(r[o]);s&&e.children.push(s)}if(e.children.length===0||e.children.length===1&&["#cdata-section","#text"].indexOf(e.children[0].name)>=0){const o=v.parseNodeText(t);o!==""&&(e.value=o),e.children=[]}return(i=e).value===null&&Object.keys(i.attributes).length===0&&i.children.length===0?null:e;var i}function sa(t){return t.getAttribute("AdID")||t.getAttribute("adID")||t.getAttribute("adId")||null}const yt={Wrapper:{subElements:["VASTAdTagURI","Impression"]},BlockedAdCategories:{attributes:["authority"]},InLine:{subElements:["AdSystem","AdTitle","Impression","AdServingId","Creatives"]},Category:{attributes:["authority"]},Pricing:{attributes:["model","currency"]},Verification:{oneOfinLineResources:["JavaScriptResource","ExecutableResource"],attributes:["vendor"]},UniversalAdId:{attributes:["idRegistry"]},JavaScriptResource:{attributes:["apiFramework","browserOptional"]},ExecutableResource:{attributes:["apiFramework","type"]},Tracking:{attributes:["event"]},Creatives:{subElements:["Creative"]},Creative:{subElements:["UniversalAdId"]},Linear:{subElements:["MediaFiles","Duration"]},MediaFiles:{subElements:["MediaFile"]},MediaFile:{attributes:["delivery","type","width","height"]},Mezzanine:{attributes:["delivery","type","width","height"]},NonLinear:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},Companion:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},StaticResource:{attributes:["creativeType"]},Icons:{subElements:["Icon"]},Icon:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"]}};function fn(t,e){if(!yt[t.nodeName]||!yt[t.nodeName].attributes)return;const n=yt[t.nodeName].attributes.filter((r=>!t.getAttribute(r)));n.length>0&&Xe({name:t.nodeName,parentName:t.parentNode.nodeName,attributes:n},e)}function hn(t,e,n){const r=yt[t.nodeName],i=!n&&t.nodeName!=="Wrapper";if(!(!r||i)){if(r.subElements){const o=r.subElements.filter((s=>!v.childByName(t,s)));o.length>0&&Xe({name:t.nodeName,parentName:t.parentNode.nodeName,subElements:o},e)}!n||!r.oneOfinLineResources||r.oneOfinLineResources.some((o=>v.childByName(t,o)))||Xe({name:t.nodeName,parentName:t.parentNode.nodeName,oneOfResources:r.oneOfinLineResources},e)}}function mn(t){return t.children&&t.children.length!==0}function Xe(t,e){let{name:n,parentName:r,attributes:i,subElements:o,oneOfResources:s}=t,a="Element '".concat(n,"'");a+=i?" missing required attribute(s) '".concat(i.join(", "),"' "):o?" missing required sub element(s) '".concat(o.join(", "),"' "):s?" must provide one of the following '".concat(s.join(", "),"' "):" is empty",e("VAST-warning",{message:a,parentElement:r,specVersion:4.1})}const aa={verifyRequiredValues:function t(e,n,r){if(e&&e.nodeName)if(e.nodeName==="InLine"&&(r=!0),fn(e,n),mn(e)){hn(e,n,r);for(let i=0;i<e.children.length;i++)t(e.children[i],n,r)}else v.parseNodeText(e).length===0&&Xe({name:e.nodeName,parentName:e.parentNode.nodeName},n)},hasSubElements:mn,emitMissingValueWarning:Xe,verifyRequiredAttributes:fn,verifyRequiredSubElements:hn};function ua(t,e){let{allowMultipleAds:n,followAdditionalWrappers:r}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=Array.from(t.childNodes).filter((o=>{const s=o.nodeName.toLowerCase();return s==="inline"||r!==!1&&s==="wrapper"}));for(const o of i){if(v.copyNodeAttribute("id",t,o),v.copyNodeAttribute("sequence",t,o),v.copyNodeAttribute("adType",t,o),o.nodeName==="Wrapper")return{ad:la(o,e),type:"WRAPPER"};if(o.nodeName==="InLine")return{ad:ca(o,e,{allowMultipleAds:n}),type:"INLINE"};const s=o.nodeName.toLowerCase();e("VAST-warning",{message:"<".concat(o.nodeName,s==="inline"?"> must be written <InLine>":"> must be written <Wrapper>"),wrongNode:o})}}function ca(t,e){let{allowMultipleAds:n}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return n===!1&&t.getAttribute("sequence")?null:to(t,e)}function to(t,e){let n=[];e&&aa.verifyRequiredValues(t,e);const r=Array.from(t.childNodes),i=(function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{id:o.id||null,sequence:o.sequence||null,adType:o.adType||null,adServingId:null,categories:[],expires:null,viewableImpression:[],system:null,title:null,description:null,advertiser:null,pricing:null,survey:null,errorURLTemplates:[],impressionURLTemplates:[],creatives:[],extensions:[],adVerifications:[],blockedAdCategories:[],followAdditionalWrappers:!0,allowMultipleAds:!1,fallbackOnNoAd:null}})(v.parseAttributes(t));return r.forEach((o=>{switch(o.nodeName){case"Error":i.errorURLTemplates.push(v.parseNodeText(o));break;case"Impression":i.impressionURLTemplates.push({id:o.getAttribute("id")||null,url:v.parseNodeText(o)});break;case"Creatives":i.creatives=(function(s){const a=[];return s.forEach((u=>{const c={id:u.getAttribute("id")||null,adId:sa(u),sequence:u.getAttribute("sequence")||null,apiFramework:u.getAttribute("apiFramework")||null},l=[];let p;v.childrenByName(u,"UniversalAdId").forEach((f=>{const h={idRegistry:f.getAttribute("idRegistry")||"unknown",value:v.parseNodeText(f)};l.push(h)}));const d=v.childByName(u,"CreativeExtensions");d&&(p=pn(v.childrenByName(d,"CreativeExtension")));for(const f in u.childNodes){const h=u.childNodes[f];let T;switch(h.nodeName){case"Linear":T=ia(h,c);break;case"NonLinearAds":T=oa(h,c);break;case"CompanionAds":T=na(h,c)}T&&(l&&(T.universalAdIds=l),p&&(T.creativeExtensions=p),a.push(T))}})),a})(v.childrenByName(o,"Creative"));break;case"Extensions":{const s=v.childrenByName(o,"Extension");i.extensions=pn(s),i.adVerifications.length||(n=(function(a){let u=null,c=[];return a.some((l=>u=v.childByName(l,"AdVerifications"))),u&&(c=yn(v.childrenByName(u,"Verification"))),c})(s));break}case"AdVerifications":i.adVerifications=yn(v.childrenByName(o,"Verification"));break;case"AdSystem":i.system={value:v.parseNodeText(o),version:o.getAttribute("version")||null};break;case"AdTitle":i.title=v.parseNodeText(o);break;case"AdServingId":i.adServingId=v.parseNodeText(o);break;case"Category":i.categories.push({authority:o.getAttribute("authority")||null,value:v.parseNodeText(o)});break;case"Expires":i.expires=parseInt(v.parseNodeText(o),10);break;case"ViewableImpression":i.viewableImpression.push((function(s){const a=(u,c)=>{const l=v.parseNodeText(c);return l&&u.push(l),u};return{id:s.getAttribute("id")||null,viewable:v.childrenByName(s,"Viewable").reduce(a,[]),notViewable:v.childrenByName(s,"NotViewable").reduce(a,[]),viewUndetermined:v.childrenByName(s,"ViewUndetermined").reduce(a,[])}})(o));break;case"Description":i.description=v.parseNodeText(o);break;case"Advertiser":i.advertiser={id:o.getAttribute("id")||null,value:v.parseNodeText(o)};break;case"Pricing":i.pricing={value:v.parseNodeText(o),model:o.getAttribute("model")||null,currency:o.getAttribute("currency")||null};break;case"Survey":i.survey={value:v.parseNodeText(o),type:o.getAttribute("type")||null};break;case"BlockedAdCategories":i.blockedAdCategories.push({authority:o.getAttribute("authority")||null,value:v.parseNodeText(o)})}})),n.length&&(i.adVerifications=i.adVerifications.concat(n)),i}function la(t,e){const n=to(t,e),r=t.getAttribute("followAdditionalWrappers"),i=t.getAttribute("allowMultipleAds"),o=t.getAttribute("fallbackOnNoAd");n.followAdditionalWrappers=!r||v.parseBoolean(r),n.allowMultipleAds=!!i&&v.parseBoolean(i),n.fallbackOnNoAd=o?v.parseBoolean(o):null;let s=v.childByName(t,"VASTAdTagURI");if(s?n.nextWrapperURL=v.parseNodeText(s):(s=v.childByName(t,"VASTAdTagURL"),s&&(n.nextWrapperURL=v.parseNodeText(v.childByName(s,"URL")))),n.creatives.forEach((a=>{if(["linear","nonlinear"].includes(a.type)){if(a.trackingEvents){n.trackingEvents||(n.trackingEvents={}),n.trackingEvents[a.type]||(n.trackingEvents[a.type]={});for(const u in a.trackingEvents){const c=a.trackingEvents[u];Array.isArray(n.trackingEvents[a.type][u])||(n.trackingEvents[a.type][u]=[]),c.forEach((l=>{n.trackingEvents[a.type][u].push(l)}))}}a.videoClickTrackingURLTemplates&&(Array.isArray(n.videoClickTrackingURLTemplates)||(n.videoClickTrackingURLTemplates=[]),a.videoClickTrackingURLTemplates.forEach((u=>{n.videoClickTrackingURLTemplates.push(u)}))),a.videoClickThroughURLTemplate&&(n.videoClickThroughURLTemplate=a.videoClickThroughURLTemplate),a.videoCustomClickURLTemplates&&(Array.isArray(n.videoCustomClickURLTemplates)||(n.videoCustomClickURLTemplates=[]),a.videoCustomClickURLTemplates.forEach((u=>{n.videoCustomClickURLTemplates.push(u)})))}})),n.nextWrapperURL)return n}function yn(t){const e=[];return t.forEach((n=>{const r={resource:null,vendor:null,browserOptional:!1,apiFramework:null,type:null,parameters:null,trackingEvents:{}},i=Array.from(n.childNodes);v.assignAttributes(n.attributes,r),i.forEach((s=>{let{nodeName:a,textContent:u,attributes:c}=s;switch(a){case"JavaScriptResource":case"ExecutableResource":r.resource=u.trim(),v.assignAttributes(c,r);break;case"VerificationParameters":r.parameters=u.trim()}}));const o=v.childByName(n,"TrackingEvents");o&&v.childrenByName(o,"Tracking").forEach((s=>{const a=s.getAttribute("event"),u=v.parseNodeText(s);a&&u&&(Array.isArray(r.trackingEvents[a])||(r.trackingEvents[a]=[]),r.trackingEvents[a].push(u))})),e.push(r)})),e}class da{constructor(){this._handlers=[]}on(e,n){if(typeof n!="function")throw new TypeError("The handler argument must be of type Function. Received type ".concat(typeof n));if(!e)throw new TypeError("The event argument must be of type String. Received type ".concat(typeof e));return this._handlers.push({event:e,handler:n}),this}once(e,n){return this.on(e,(function(r,i,o){const s={fired:!1,wrapFn:void 0};function a(){s.fired||(r.off(i,s.wrapFn),s.fired=!0,o.bind(r)(...arguments))}return s.wrapFn=a,a})(this,e,n))}off(e,n){return this._handlers=this._handlers.filter((r=>r.event!==e||r.handler!==n)),this}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];let o=!1;return this._handlers.forEach((s=>{s.event==="*"&&(o=!0,s.handler(e,...r)),s.event===e&&(o=!0,s.handler(...r))})),o}removeAllListeners(e){return e?(this._handlers=this._handlers.filter((n=>n.event!==e)),this):(this._handlers=[],this)}listenerCount(e){return this._handlers.filter((n=>n.event===e)).length}listeners(e){return this._handlers.reduce(((n,r)=>(r.event===e&&n.push(r.handler),n)),[])}eventNames(){return this._handlers.map((e=>e.event))}}let gn=0,Dr=0;const ro=(t,e)=>{!t||!e||t<=0||e<=0||(Dr=(Dr*gn+8*t/e)/++gn)},pa={ERRORCODE:900,extensions:[]},vn="VAST response version not supported";class fa extends da{constructor(){let{fetcher:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.maxWrapperDepth=null,this.rootErrorURLTemplates=[],this.errorURLTemplates=[],this.remainingAds=[],this.parsingOptions={},this.fetcher=e||null,this.keepFailedAdPod=!1}trackVastError(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];this.emit("VAST-error",Object.assign({},pa,n,...i)),Fe.track(e,n)}getErrorURLTemplates(){return this.rootErrorURLTemplates.concat(this.errorURLTemplates)}getEstimatedBitrate(){return Dr}initParsingStatus(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.maxWrapperDepth=e.wrapperLimit||10,this.parsingOptions={allowMultipleAds:e.allowMultipleAds},this.keepFailedAdPod=e.keepFailedAdPod||!1,this.rootURL="",this.resetParsingStatus(),ro(e.byteLength,e.requestDuration)}resetParsingStatus(){this.errorURLTemplates=[],this.rootErrorURLTemplates=[],this.vastVersion=null}getRemainingAds(e){if(this.remainingAds.length===0)return Promise.reject(new Error("No more ads are available for the given VAST"));const n=e?this.remainingAds:[this.remainingAds.shift()];return this.errorURLTemplates=[],this.resolveAds(n,{wrapperDepth:0,url:this.rootURL}).then((r=>this.buildVASTResponse(r)))}parseVAST(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.initParsingStatus(n),n.isRootVAST=!0,this.parse(e,n).then((r=>this.buildVASTResponse(r)))}buildVASTResponse(e){const n=(function(r){let{ads:i,errorURLTemplates:o,version:s}=r;return{ads:i||[],errorURLTemplates:o||[],version:s||null}})({ads:e,errorURLTemplates:this.getErrorURLTemplates(),version:this.vastVersion});return this.completeWrapperResolving(n),n}parseVastXml(e,n){let{isRootVAST:r=!1,url:i=null,wrapperDepth:o=0,allowMultipleAds:s,followAdditionalWrappers:a}=n;if(!e||!e.documentElement||e.documentElement.nodeName!=="VAST"){var u;this.emit("VAST-ad-parsed",{type:"ERROR",url:i,wrapperDepth:o});const d=(e==null||(u=e.documentElement)===null||u===void 0?void 0:u.nodeName)==="VideoAdServingTemplate";throw new Error(d?vn:"Invalid VAST XMLDocument")}const c=[],l=e.documentElement.childNodes,p=e.documentElement.getAttribute("version");r&&p&&(this.vastVersion=p);for(const d in l){const f=l[d];if(f.nodeName==="Error"){const h=v.parseNodeText(f);r?this.rootErrorURLTemplates.push(h):this.errorURLTemplates.push(h)}else if(f.nodeName==="Ad"){if(this.vastVersion&&parseFloat(this.vastVersion)<3)s=!0;else if(s===!1&&c.length>1)break;const h=ua(f,this.emit.bind(this),{allowMultipleAds:s,followAdditionalWrappers:a});h.ad?(c.push(h.ad),this.emit("VAST-ad-parsed",{type:h.type,url:i,wrapperDepth:o,adIndex:c.length-1,vastVersion:p})):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}return c}parse(e){let{url:n=null,resolveAll:r=!0,wrapperSequence:i=null,previousUrl:o=null,wrapperDepth:s=0,isRootVAST:a=!1,followAdditionalWrappers:u,allowMultipleAds:c}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=[];this.vastVersion&&parseFloat(this.vastVersion)<3&&a&&(c=!0);try{l=this.parseVastXml(e,{isRootVAST:a,url:n,wrapperDepth:s,allowMultipleAds:c,followAdditionalWrappers:u})}catch(p){return Promise.reject(p)}if(l.length===1&&i!=null&&(l[0].sequence=i),r===!1){const p=v.getSortedAdPods(l),d=v.getStandAloneAds(l);p.length?l=p:d.length&&(l=[d.shift()]),this.remainingAds=d}return this.resolveAds(l,{wrapperDepth:s,previousUrl:o,url:n})}resolveAds(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],{wrapperDepth:n,previousUrl:r,url:i}=arguments.length>1?arguments[1]:void 0;const o=[];return r=i,e.forEach((s=>{const a=this.resolveWrappers(s,n,r);o.push(a)})),Promise.all(o).then((s=>Fe.flatten(s)))}resolveWrappers(e,n,r){const i={...e};return new Promise((o=>{var s;if(n++,!i.nextWrapperURL)return delete i.nextWrapperURL,o(i);if(!this.fetcher)return i.VASTAdTagURI=i.nextWrapperURL,delete i.nextWrapperURL,o(i);if(n>=this.maxWrapperDepth)return i.errorCode=302,delete i.nextWrapperURL,o(i);i.nextWrapperURL=v.resolveVastAdTagURI(i.nextWrapperURL,r);const a=(s=this.parsingOptions.allowMultipleAds)!==null&&s!==void 0?s:i.allowMultipleAds,u=i.sequence;this.fetcher.fetchVAST({url:i.nextWrapperURL,emitter:this.emit.bind(this),maxWrapperDepth:this.maxWrapperDepth}).then((c=>this.parse(c,{url:i.nextWrapperURL,previousUrl:r,wrapperSequence:u,wrapperDepth:n,followAdditionalWrappers:i.followAdditionalWrappers,allowMultipleAds:a}).then((l=>{if(delete i.nextWrapperURL,l.length===0)return i.creatives=[],o(i);l.forEach((p=>{p&&v.mergeWrapperAdData(p,i)})),o(l)})))).catch((c=>{i.errorCode=c.message===vn?102:301,i.errorMessage=c.message,o(i)}))}))}completeWrapperResolving(e){if(e.ads.length===0)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(let n=e.ads.length-1;n>=0;n--){const r=e.ads[n],i=!r.creatives.some((o=>{var s,a;return((s=o.mediaFiles)===null||s===void 0?void 0:s.length)>0||((a=o.variations)===null||a===void 0?void 0:a.length)>0}));!r.errorCode&&!i||r.VASTAdTagURI||(this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:r.errorCode||303},{ERRORMESSAGE:r.errorMessage||""},{extensions:r.extensions},{system:r.system}),this.keepFailedAdPod&&r.sequence?r.hasFailed=!0:e.ads.splice(n,1))}}}let Ae=null;const ha={data:{},length:0,getItem(t){return this.data[t]},setItem(t,e){this.data[t]=e,this.length=Object.keys(this.data).length},removeItem(t){delete this.data[t],this.length=Object.keys(this.data).length},clear(){this.data={},this.length=0}};class ma{constructor(){this.storage=this.initStorage()}initStorage(){if(Ae)return Ae;try{Ae=typeof window<"u"&&window!==null?window.localStorage||window.sessionStorage:null}catch{Ae=null}return Ae&&!this.isStorageDisabled(Ae)||(Ae=ha,Ae.clear()),Ae}isStorageDisabled(e){const n="__VASTStorage__";try{if(e.setItem(n,n),e.getItem(n)!==n)return e.removeItem(n),!0}catch{return!0}return e.removeItem(n),!1}getItem(e){return this.storage.getItem(e)}setItem(e,n){return this.storage.setItem(e,n)}removeItem(e){return this.storage.removeItem(e)}clear(){return this.storage.clear()}}const Fr=12e4,ya={get:async function(t,e){try{const n=new AbortController,r=setTimeout((()=>{throw n.abort(),new Error("URLHandler: Request timed out after ".concat(e.timeout||Fr," ms (408)"))}),e.timeout||Fr),i=await fetch(t,{...e,signal:n.signal,credentials:e.withCredentials?"include":"omit"}).finally((()=>{clearTimeout(r)})),o=(function(s){return Fe.isBrowserEnvironment()&&window.location.protocol==="https:"&&s.url.includes("http://")?"URLHandler: Cannot go from HTTPS to HTTP.":s.status===200&&s.ok?null:"URLHandler: ".concat(s.statusText," (").concat(s.status,")")})(i);return o?{error:new Error(o),statusCode:i.status}:(async function(s){const a=await s.text();let u;return u=Fe.isBrowserEnvironment()?new DOMParser:new(await Promise.resolve().then(()=>require("./index-C05fK_bk.cjs")).then(c=>c.index)).DOMParser,{xml:u.parseFromString(a,"text/xml"),details:{byteLength:a.length,statusCode:s.status,rawXml:a}}})(i)}catch(n){return{error:n,statusCode:n.name==="AbortError"?408:null}}}};class ga{constructor(){this.URLTemplateFilters=[]}setOptions(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.urlHandler=e.urlHandler||e.urlhandler||ya,this.fetchingOptions={...e.fetchOptions,timeout:e.timeout||Fr,withCredentials:!!e.withCredentials}}addURLTemplateFilter(e){typeof e=="function"&&this.URLTemplateFilters.push(e)}removeLastURLTemplateFilter(){this.URLTemplateFilters.pop()}countURLTemplateFilters(){return this.URLTemplateFilters.length}clearURLTemplateFilters(){this.URLTemplateFilters=[]}async fetchVAST(e){var n;let{url:r,maxWrapperDepth:i,emitter:o,wrapperDepth:s=0,previousUrl:a=null,wrapperAd:u=null}=e;const c=Date.now();this.URLTemplateFilters.forEach((d=>{r=d(r)})),o("VAST-resolving",{url:r,previousUrl:a,wrapperDepth:s,maxWrapperDepth:i,timeout:this.fetchingOptions.timeout,wrapperAd:u});const l=await this.urlHandler.get(r,this.fetchingOptions),p=Math.round(Date.now()-c);if(o("VAST-resolved",{url:r,previousUrl:a,wrapperDepth:s,error:l?.error||null,duration:p,statusCode:l?.statusCode||null,...l?.details}),ro(l==null||(n=l.details)===null||n===void 0?void 0:n.byteLength,p),l.error)throw new Error(l.error);return l.xml}}class va{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new ma;this.cappingFreeLunch=e,this.cappingMinimumTimeInterval=n,this.fetcher=new ga,this.vastParser=new fa({fetcher:this.fetcher}),this.storage=r,this.lastSuccessfulAd===void 0&&(this.lastSuccessfulAd=0),this.totalCalls===void 0&&(this.totalCalls=0),this.totalCallsTimeout===void 0&&(this.totalCallsTimeout=0)}addURLTemplateFilter(e){this.fetcher.addURLTemplateFilter(e)}removeLastURLTemplateFilter(){this.fetcher.removeLastURLTemplateFilter()}countURLTemplateFilters(){return this.fetcher.countURLTemplateFilters()}clearURLTemplateFilters(){this.fetcher.clearURLTemplateFilters()}getParser(){return this.vastParser}get lastSuccessfulAd(){return this.storage.getItem("vast-client-last-successful-ad")}set lastSuccessfulAd(e){this.storage.setItem("vast-client-last-successful-ad",e)}get totalCalls(){return this.storage.getItem("vast-client-total-calls")}set totalCalls(e){this.storage.setItem("vast-client-total-calls",e)}get totalCallsTimeout(){return this.storage.getItem("vast-client-total-calls-timeout")}set totalCallsTimeout(e){this.storage.setItem("vast-client-total-calls-timeout",e)}hasRemainingAds(){return this.vastParser.remainingAds.length>0}getNextAds(e){return this.vastParser.getRemainingAds(e)}parseVAST(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.fetcher.setOptions(n),this.vastParser.parseVAST(e,n)}get(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=Date.now();return n.hasOwnProperty("resolveAll")||(n.resolveAll=!1),this.totalCallsTimeout<r?(this.totalCalls=1,this.totalCallsTimeout=r+36e5):this.totalCalls++,new Promise(((i,o)=>{if(this.cappingFreeLunch>=this.totalCalls)return o(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(this.totalCalls,"/").concat(this.cappingFreeLunch)));const s=r-this.lastSuccessfulAd;if(s<0)this.lastSuccessfulAd=0;else if(s<this.cappingMinimumTimeInterval)return o(new Error("VAST call canceled – (".concat(this.cappingMinimumTimeInterval,")ms minimum interval reached")));this.vastParser.initParsingStatus(n),this.fetcher.setOptions(n),this.vastParser.rootURL=e,this.fetcher.fetchVAST({url:e,emitter:this.vastParser.emit.bind(this.vastParser),maxWrapperDepth:this.vastParser.maxWrapperDepth}).then((a=>(n.previousUrl=e,n.isRootVAST=!0,n.url=e,this.vastParser.parse(a,n).then((u=>{const c=this.vastParser.buildVASTResponse(u);i(c)}))))).catch((a=>o(a)))}))}}const ba=new va,Et=le("ui:gam-static"),bn=t=>new Promise((e,n)=>{const r=new Image;r.onload=()=>e(t),r.onerror=()=>n(),r.src=t}),Ta=t=>(e,n,r)=>t.transport.nanoquery.createFetcherStore([e,n],{dedupeTime:r.prefetch?r.refetchInterval:1/0,revalidateInterval:r.refetchInterval>0?r.refetchInterval:0,fetcher:async i=>{if(!i||typeof i!="string")throw new Error("ad url is empty");H.emit("exposedPauseAd",{action:"load",payload:{}});try{const s=(await ba.get(i)).ads.find(a=>a.creatives.length>0);if(s){const a=s.id||"";Et.debug(s,"validAd");const u=s.creatives.find(d=>d.type==="nonlinear");if(u){const d=u.adId||u.id||a;Et.debug(u,"nonlinear");const f=u.variations?.[0]?.staticResource,h=u.variations?.[0]?.nonlinearClickThroughURLTemplate;if(f)return await bn(f),H.emit("exposedPauseAd",{action:"loaded",payload:{id:d,parentId:a}}),{id:d,parentId:a,url:i,imageSrc:f,adUrl:h}}const c=s.creatives.find(d=>d.type==="companion");Et.debug(c,"companion");const l=c?.variations?.[0]?.staticResources?.[0]?.url,p=c?.variations?.[0]?.companionClickThroughURLTemplate;if(l){const d=c.adId||c.id||a;return await bn(l),H.emit("exposedPauseAd",{action:"loaded",payload:{id:d,parentId:a}}),{id:d,parentId:a,url:i,imageSrc:l,adUrl:p}}}throw new Error("no_valid_ad")}catch(o){throw o.message!=="no_valid_ad"&&o.message!=="ad url is empty"&&console.error(o),o}}});class Aa extends Bi{getExternalPauseAd;externalPauseAdStores=new Map;externalPauseAdEnabled=new Map;log;constructor(e){super(),this.log=le("advertisement");const n=Ta(e);this.getExternalPauseAd=(r,i)=>{if(this.externalPauseAdStores.has(r)){const a=this.externalPauseAdEnabled.get(r),u=this.externalPauseAdStores.get(r),c=a.get()===!1&&i.$enabled===!0;return a.set(i.$enabled),c&&window.requestAnimationFrame(()=>{u.revalidate()}),[u,r]}const o=J(i.$enabled),s=n(r,o,i);return this.externalPauseAdEnabled.set(r,o),this.externalPauseAdStores.set(r,s),[s,r]}}connect=()=>{this.log.debug("connect")};disconnect=()=>{this.log.debug("disconnect"),this.externalPauseAdStores.forEach(e=>{e.off()}),this.externalPauseAdEnabled.forEach(e=>{e.off()}),this.externalPauseAdEnabled.clear(),this.externalPauseAdStores.clear()}}const Sa=(t,e,n)=>{t.sdk.advertisement=new Aa(t),t.sdk.onMount({name:"advertisement"},()=>(t.sdk.advertisement.connect(),()=>{t.sdk.advertisement.disconnect()})),n()};class Ea{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{r.slEventBus?.type==="invitation"&&r.slEventBus.action==="sent"&&this.sent(r.slEventBus.payload)};return H.listen(n)})}accepted=()=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.INVITATION_ACCEPTED},category:it.InvitationCategory.GAMES,from:it.InvitationFrom.UNSET})};sent=({from:e})=>{this.analytics.write("invitation",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.INVITATION_SENT},category:it.InvitationCategory.GAMES,from:e||it.InvitationFrom.UNSET})}}class wa{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="interactions")switch(r.slEventBus.action){case"tap":this.tap();break;case"scroll":this.scroll();break}};return H.listen(n)})}tap=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.INTERACTIONS},actionType:$r.InteractionActionType.TAP})};scroll=()=>{this.analytics.write("interactions",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.INTERACTIONS},actionType:$r.InteractionActionType.SCROLL})}}const Ia={[I.PromotionType.UNSET]:A.TopicSubType.UNSET,[I.PromotionType.INGAME_IAB21]:A.TopicSubType.PROMOTION_INGAME_IAB21,[I.PromotionType.INGAME_IAB21_SIDEBAR]:A.TopicSubType.PROMOTION_INGAME_IAB21,[I.PromotionType.INGAME_IAB11_LBAR]:A.TopicSubType.PROMOTION_INGAME_IAB11_LBAR,[I.PromotionType.INGAME_IAB11]:A.TopicSubType.PROMOTION_INGAME_IAB11,[I.PromotionType.INGAME_IAB11_SIDEBAR]:A.TopicSubType.PROMOTION_INGAME_IAB11,[I.PromotionType.INGAME_IAB21_LBAR]:A.TopicSubType.PROMOTION_INGAME_IAB21_LBAR,[I.PromotionType.INGAME_IAB61]:A.TopicSubType.PROMOTION_INGAME_IAB61,[I.PromotionType.INGAME_IAB61_SIDEBAR]:A.TopicSubType.PROMOTION_INGAME_IAB61,[I.PromotionType.EXTERNAL_AD]:A.TopicSubType.PROMOTION_GAM,[I.PromotionType.VIDEO_SIDE_BY_SIDE]:A.TopicSubType.PROMOTION_VIDEO_SIDE_BY_SIDE,[I.PromotionType.PICTURE_IN_PICTURE]:A.TopicSubType.PROMOTION_PICTURE_IN_PICTURE,[I.PromotionType.LOWER_THIRD]:A.TopicSubType.PROMOTION_LOWER_THIRD,[I.PromotionType.SHOP_LBAR]:A.TopicSubType.PROMOTION_SHOP_LBAR,[I.PromotionType.SHOP_OVERLAY]:A.TopicSubType.PROMOTION_SHOP_OVERLAY,[I.PromotionType.SHOP_SIDEBAR]:A.TopicSubType.PROMOTION_SHOP_SIDEBAR,[I.PromotionType.NFL_SHOP_LBAR]:A.TopicSubType.PROMOTION_SHOP_LBAR,[I.PromotionType.NFL_SHOP_OVERLAY]:A.TopicSubType.PROMOTION_SHOP_OVERLAY,[I.PromotionType.NFL_SHOP_SIDEBAR]:A.TopicSubType.PROMOTION_SHOP_SIDEBAR,[I.PromotionType.STATS]:A.TopicSubType.UNSET,[I.PromotionType.STANDARD]:A.TopicSubType.UNSET,[I.PromotionType.SHOP]:A.TopicSubType.UNSET,[I.PromotionType.NFL_SHOP]:A.TopicSubType.UNSET},Ur=t=>t?Ia[t]:A.TopicSubType.UNSET,Oa={25:A.Kind.AD_VIDEO_Q25,50:A.Kind.AD_VIDEO_Q50,75:A.Kind.AD_VIDEO_Q75};class ka{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(!r.slEventBus?.skipAnalytics){if(r.slEventBus?.type==="exposedPauseAd"){const i=r.slEventBus.payload;switch(r.slEventBus.action){case"enabled":this.exposedPauseAdEnabled(i);break;case"disabled":this.exposedPauseAdDisabled(i);break;case"closed":this.exposedPauseAdClosed(i);break;case"load":this.exposedPauseAdLoad(i,!1);break;case"loaded":this.exposedPauseAdLoad(i,!0);break;case"rendered":this.exposedPauseAdOpened(i);break;case"navigated":this.exposedPauseAdNavigated(i);break}}if(r.slEventBus?.type==="advertisement"){const i=r.slEventBus.payload,o=Ur(i.type);switch(r.slEventBus.action){case"videoPlay":this.videoPlay(i,{topicSubType:o});break;case"videoEnd":this.videoEnd(i,{topicSubType:o});break;case"videoRendered":this.videoRendered(i,{topicSubType:o});break;case"buttonSelect":this.buttonSelect(i,{topicSubType:o});break;case"bannerSelect":this.bannerSelect(i,{topicSubType:o});break;case"bannerShown":this.bannerShown(i,{topicSubType:o});break;case"received":this.received(i,{topicSubType:o});break;case"opened":this.opened(i,{topicSubType:o});break;case"viewed":this.viewed(i,{topicSubType:o});break;case"videoMuted":case"videoUnmuted":this.videoMuted(i,{topicSubType:o,muted:r.slEventBus.action==="videoMuted"});break;case"videoReplayed":this.videoReplayed(i,{topicSubType:o});break;case"quartileCompleted":this.quartileCompleted(i,{topicSubType:o});break}}}};return H.listen(n)})}exposedPauseAdEnabled=({id:e,parentId:n})=>{const r=this.analytics.commonStore.getValues();this.analytics.write("games",{common:{...r,kind:A.Kind.STREAM_PAUSED,topicId:e,parentTopicId:n,topicType:A.TopicType.EXPOSED_PAUSED_AD},pollOpenedFrom:A.PollOpenedFrom.UNSET})};exposedPauseAdClosed=({id:e,parentId:n})=>{const r=this.analytics.commonStore.getValues();this.analytics.write("games",{common:{...r,kind:A.Kind.EXTERNAL_AD_CLOSED,topicId:e,parentTopicId:n,topicType:A.TopicType.EXPOSED_PAUSED_AD},pollOpenedFrom:A.PollOpenedFrom.UNSET})};exposedPauseAdDisabled=({id:e,parentId:n})=>{const r=this.analytics.commonStore.getValues();this.analytics.write("games",{common:{...r,kind:A.Kind.STREAM_RESUMED,topicId:e,parentTopicId:n,topicType:A.TopicType.EXPOSED_PAUSED_AD},pollOpenedFrom:A.PollOpenedFrom.UNSET})};exposedPauseAdOpened=({id:e,parentId:n})=>{const r=this.analytics.commonStore.getValues();this.analytics.write("games",{common:{...r,kind:A.Kind.EXTERNAL_AD_RENDERED,topicId:e,parentTopicId:n,topicType:A.TopicType.EXPOSED_PAUSED_AD},pollOpenedFrom:A.PollOpenedFrom.UNSET})};exposedPauseAdNavigated=({id:e,parentId:n})=>{const r=this.analytics.commonStore.getValues();this.analytics.write("games",{common:{...r,kind:A.Kind.AD_INTERACTION_BANNER_NAVIGATED,topicId:e,parentTopicId:n,topicType:A.TopicType.EXPOSED_PAUSED_AD},pollOpenedFrom:A.PollOpenedFrom.UNSET})};exposedPauseAdLoad=({id:e,parentId:n},r)=>{const i=this.analytics.commonStore.getValues();this.analytics.write("games",{common:{...i,kind:r?A.Kind.EXTERNAL_AD_LOADED:A.Kind.EXTERNAL_AD_REQUESTED,topicId:e,parentTopicId:n,topicType:A.TopicType.EXPOSED_PAUSED_AD},pollOpenedFrom:A.PollOpenedFrom.UNSET})};received=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.POLLS_RECEIVED,topicId:e,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:A.PollOpenedFrom.UNSET})};opened=({id:e,openedFrom:n},{topicSubType:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.POLLS_AD_OPENED,topicId:e,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:n==="notification"?A.PollOpenedFrom.IN_APP:A.PollOpenedFrom.UNSET})};viewed=({id:e},{topicSubType:n})=>{};videoMuted=({id:e},{topicSubType:n,muted:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:r?A.Kind.AD_VIDEO_MUTED:A.Kind.AD_VIDEO_UNMUTED,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:A.PollOpenedFrom.UNSET})};quartileCompleted=({id:e,quartile:n},{topicSubType:r})=>{n&&this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:Oa[n],topicType:A.TopicType.POLLS_PROMOTION,topicSubType:r},pollOpenedFrom:A.PollOpenedFrom.UNSET})};videoReplayed=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:A.Kind.AD_VIDEO_REPLAYED,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:A.PollOpenedFrom.UNSET})};videoPlay=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:A.Kind.AD_VIDEO_PLAYED,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:A.PollOpenedFrom.UNSET})};videoEnd=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:A.Kind.AD_VIDEO_COMPLETE,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:A.PollOpenedFrom.UNSET})};videoRendered=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:A.Kind.AD_VIDEO_RENDERED,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:A.PollOpenedFrom.UNSET})};buttonSelect=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:A.Kind.AD_INTERACTION_BUTTON_NAVIGATED,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:A.PollOpenedFrom.UNSET})};bannerSelect=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:A.Kind.AD_INTERACTION_BANNER_NAVIGATED,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:A.PollOpenedFrom.UNSET})};bannerShown=({id:e},{topicSubType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),topicId:e,kind:A.Kind.AD_BANNER_SHOWN,topicType:A.TopicType.POLLS_PROMOTION,topicSubType:n},pollOpenedFrom:A.PollOpenedFrom.UNSET})}}const Ye={[I.QuestionType.UNSET]:A.TopicType.UNSET,[I.QuestionType.FACTOID]:A.TopicType.POLLS_INSIGHT,[I.QuestionType.POLL]:A.TopicType.POLLS_POLL,[I.QuestionType.PREDICTION]:A.TopicType.POLLS_PREDICTION,[I.QuestionType.PROMOTION]:A.TopicType.POLLS_PROMOTION,[I.QuestionType.TRIVIA]:A.TopicType.POLLS_TRIVIA,[I.QuestionType.TWEET]:A.TopicType.POLLS_TWITTER};I.QuestionType.UNSET+"",he.NotificationKind.UNSET,I.QuestionType.FACTOID+"",he.NotificationKind.POLLS,I.QuestionType.POLL+"",he.NotificationKind.POLLS,I.QuestionType.PREDICTION+"",he.NotificationKind.POLLS,I.QuestionType.PROMOTION+"",he.NotificationKind.POLLS,I.QuestionType.TRIVIA+"",he.NotificationKind.POLLS,I.QuestionType.TWEET+"",he.NotificationKind.POLLS;const Na={[z.SdkOverlayType.UNSET]:A.Category.UNSET,[z.SdkOverlayType.INPLAY]:A.Category.INPLAY,[z.SdkOverlayType.MESSAGING]:A.Category.MESSAGING,[z.SdkOverlayType.STATISTICS]:A.Category.STATS,[z.SdkOverlayType.BETTING]:A.Category.BETTING,[z.SdkOverlayType.TWITTER]:A.Category.TWITTER,[z.SdkOverlayType.MERCHANDISE]:A.Category.MERCHANDISE,[z.SdkOverlayType.CONTESTS]:A.Category.CONTESTS,[z.SdkOverlayType.VOICE_CHAT]:A.Category.CALLING,[z.SdkOverlayType.TICKETS]:A.Category.TICKETS,[z.SdkOverlayType.WHOIS_WATCHING]:A.Category.WHOISWATCHING,[z.SdkOverlayType.PROFILE]:A.Category.PROFILE,[z.SdkOverlayType.GAMES]:A.Category.POLLS,[z.SdkOverlayType.GOLF_STATISTICS]:A.Category.STATS,[z.SdkOverlayType.HIGHLIGHTS]:A.Category.HIGHLIGHTS,[z.SdkOverlayType.PUBLIC_CHAT]:A.Category.PUBLIC_CHAT};class Ra{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="notification")switch(r.slEventBus.action){case"rendered":this.received(r.slEventBus.payload);break;case"opened":this.opened(r.slEventBus.payload);break}if(r.slEventBus?.type==="advertisement")switch(r.slEventBus.action){case"notification-received":this.received({questionId:r.slEventBus.payload.id,questionType:I.QuestionType.PROMOTION,topicSubType:Ur(r.slEventBus.payload.type)});break;case"notification-opened":this.opened({questionId:r.slEventBus.payload.id,questionType:I.QuestionType.PROMOTION,topicSubType:Ur(r.slEventBus.payload.type)});break}};return H.listen(n)})}received=({questionId:e,questionType:n,topicSubType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.NOTIFICATION_RECEIVED,topicId:e,topicType:n?Ye[n]:A.TopicType.UNSET,topicSubType:r},notificationKind:he.NotificationKind.POLLS,notificationType:he.NotificationType.IN_APP})};opened=({questionId:e,questionType:n,topicSubType:r})=>{this.analytics.write("notification",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.NOTIFICATION_OPENED,topicId:e,topicType:n?Ye[n]:A.TopicType.UNSET,topicSubType:r},notificationKind:he.NotificationKind.POLLS,notificationType:he.NotificationType.IN_APP})}}class Pa{analytics;constructor(e){this.analytics=e,this.analytics.onConnect(()=>{const n=r=>{if(r.slEventBus?.type==="poll")switch(r.slEventBus.action){case"voted":this.voted(r.slEventBus.payload);break;case"navigated":this.navigated();break;case"onboardingPassed":this.onboardingPassed();break;case"received":this.received(r.slEventBus.payload);break;case"viewed":this.viewed(r.slEventBus.payload);break}};return H.listen(n)})}received=({questionId:e,questionType:n})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.POLLS_RECEIVED,topicId:e,topicType:n?Ye[n]:A.TopicType.UNSET},pollOpenedFrom:A.PollOpenedFrom.UNSET})};viewed=({questionId:e,questionType:n,questionOpenedFrom:r,isAd:i})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:i?A.Kind.POLLS_AD_OPENED:A.Kind.POLLS_OPENED,topicId:e,topicType:n?Ye[n]:A.TopicType.UNSET},pollOpenedFrom:r==="list"?A.PollOpenedFrom.PICK_HISTORY:A.PollOpenedFrom.IN_APP})};voted=({questionId:e,questionType:n,isAd:r})=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:r?A.Kind.POLLS_AD_VOTE:A.Kind.POLLS_VOTE,topicId:e,topicType:n?Ye[n]:A.TopicType.UNSET},pollOpenedFrom:A.PollOpenedFrom.UNSET})};onboardingPassed=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.GAMES_JOINED},pollOpenedFrom:A.PollOpenedFrom.UNSET})};navigated=()=>{this.analytics.write("games",{common:{...this.analytics.commonStore.getValues(),kind:A.Kind.POLLS_NAVIGATED},pollOpenedFrom:A.PollOpenedFrom.UNSET})}}const Ca=({transport:t,$commonStore:e})=>{let n;const r=J(!1),i=3e4,{client:o,queryKey:s}=t.createPromiseClient(Fi.AnalyticsService,{method:"send",params:[r]}),a=t.nanoquery.createFetcherStore(s,{fetcher:async()=>{const d=e.getStore().get();try{await o.unary({message:{case:"heartbeat",value:{common:{...d,kind:A.Kind.SESSION_HEARTBEAT}}}})}catch(f){Ie.error(f,"send heartbeat failed")}return Date.now()},revalidateInterval:i}),u=()=>{Ie.debug("mounted heartbeat"),n=a.subscribe(()=>{})},c=()=>{Ie.debug("enabled heartbeat"),r.set(!0),a.lc===0&&u()},l=()=>{Ie.debug("disabled heartbeat"),r.set(!1)};return{enable:c,disable:l,mount:u,unmount:()=>{Ie.debug("unmounted heartbeat"),a.off(),n?.(),n=void 0,l()}}},Ie=le("analytics");class La{commonStore;notifications;polls;invitation;interactions;advertisement;heartbeat;analyticsClient;listeners;listenersCancels;connected=!1;constructor(e){this.listeners=new Set,this.listenersCancels=new Set,this.commonStore=new De(ue({}),"common-analytics"),this.connectToSDK(e),this.heartbeat=Ca({transport:e.analyticsTransport,$commonStore:this.commonStore}),this.notifications=new Ra(this),this.polls=new Pa(this),this.invitation=new Ea(this),this.interactions=new wa(this),this.advertisement=new ka(this);const{client:n}=e.analyticsTransport.createPromiseClient(Fi.AnalyticsService,{method:"send"});this.analyticsClient=n}connect=()=>{this.writeCommon("sessionId",Be.v4()),this.heartbeat.enable(),this.listeners.forEach(e=>this.listenersCancels.add(e())),this.connected=!0,Ie.debug("analytics connected")};disconnect=()=>{this.writeCommon("sessionId",""),this.writeCommon("overlaySessionId",""),this.heartbeat.unmount(),this.listenersCancels.forEach(e=>e()),this.connected=!1,Ie.debug("analytics disconnected")};write=(e,n)=>{n&&this.analyticsClient.unary({message:{case:e,value:n}}).then(()=>{Ie.trace({key:e,value:n},"send analytics success")}).catch(r=>{Ie.error(r,"send analytics failed")})};writeCommonValues=(e,n,r)=>{const i=this.commonStore.getValue(n);setTimeout(()=>{if(this.connected&&i===this.commonStore.getValue(n))for(const[o,s]of Object.entries(e))this.commonStore.setValue(o,s)},r)};writeCommon=(e,n,r)=>{r?this.writeCommonValues({[e]:n},e,r):this.commonStore.setValue(e,n)};onConnect=e=>{this.listeners.add(e),this.connected&&this.listenersCancels.add(e())};connectToSDK=e=>{this.onConnect(()=>e.stores.slStreamId.getAtomStore().subscribe(n=>{this.writeCommon("eventId",n)})),this.onConnect(()=>e.sdk.getActiveFeature().subscribe(n=>{n&&this.writeCommon("category",Na[n]),n!==z.SdkOverlayType.UNSET?this.writeCommon("overlaySessionId",Be.v4()):this.writeCommon("overlaySessionId","",200)})),this.onConnect(()=>{const n=r=>{if(!r.slEventBus)return;const i=r.slEventBus?.action;r.slEventBus?.type==="exposedPauseAd"&&((i==="disabled"||i==="closed")&&this.writeCommonValues({overlaySessionId:"",topicId:"",parentTopicId:"",topicType:A.TopicType.UNSET,category:A.Category.UNSET},"overlaySessionId",200),i==="enabled"&&(this.writeCommon("overlaySessionId",Be.v4()),this.writeCommon("category",A.Category.EXPOSED_PAUSED_AD))),r.slEventBus?.type==="advertisement"&&(i==="opened"&&this.writeCommon("overlaySessionId",Be.v4()),i==="closed"&&this.writeCommon("overlaySessionId","",200))};return H.listen(n)}),this.onConnect(()=>e.sdk.uiState.subscribe(r=>{Object.values(r).every(o=>o===!1)&&this.writeCommon("overlaySessionId","",200)})),this.onConnect(()=>{const n=window.matchMedia("(orientation: portrait)"),r=i=>{this.writeCommon("screenOrientation",i.matches?A.ScreenOrientation.PORTRAIT:A.ScreenOrientation.LANDSCAPE)};return n.addEventListener("change",r),()=>{n.removeEventListener("change",r)}}),e.deepLink&&this.onConnect(()=>e.deepLink.$store.subscribe(n=>{n?.handled&&this.invitation.accepted()}))}}const _a=(t,e,n)=>{t.analytics=new La(t),t.sdk.onMount({name:"analytics"},()=>(t.analytics.connect(),t.sdk.writeOverlaySessionId=r=>{r===""?t.analytics.writeCommon("overlaySessionId","",200):t.analytics.writeCommon("overlaySessionId",Be.v4())},()=>{t.analytics.disconnect()})),n()};var no=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function io(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ut={exports:{}},ct={exports:{}},wt,Tn;function Da(){if(Tn)return wt;Tn=1;function t(e){var n=new e,r=n;function i(){var s=n;return s.next?n=s.next:(n=new e,r=n),s.next=null,s}function o(s){r.next=s,r=s}return{get:i,release:o}}return wt=t,wt}var An;function oo(){if(An)return ct.exports;An=1;var t=Da();function e(o,s,a){if(typeof o=="function"&&(a=s,s=o,o=null),!(a>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");var u=t(r),c=null,l=null,p=0,d=null,f={push:y,drain:n,saturated:n,pause:T,paused:!1,get concurrency(){return a},set concurrency(k){if(!(k>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");if(a=k,!f.paused)for(;c&&p<a;)p++,L()},running:h,resume:g,idle:S,length:E,getQueue:C,unshift:w,empty:n,kill:_,killAndDrain:m,error:P};return f;function h(){return p}function T(){f.paused=!0}function E(){for(var k=c,F=0;k;)k=k.next,F++;return F}function C(){for(var k=c,F=[];k;)F.push(k.value),k=k.next;return F}function g(){if(f.paused){if(f.paused=!1,c===null){p++,L();return}for(;c&&p<a;)p++,L()}}function S(){return p===0&&f.length()===0}function y(k,F){var R=u.get();R.context=o,R.release=L,R.value=k,R.callback=F||n,R.errorHandler=d,p>=a||f.paused?l?(l.next=R,l=R):(c=R,l=R,f.saturated()):(p++,s.call(o,R.value,R.worked))}function w(k,F){var R=u.get();R.context=o,R.release=L,R.value=k,R.callback=F||n,R.errorHandler=d,p>=a||f.paused?c?(R.next=c,c=R):(c=R,l=R,f.saturated()):(p++,s.call(o,R.value,R.worked))}function L(k){k&&u.release(k);var F=c;F&&p<=a?f.paused?p--:(l===c&&(l=null),c=F.next,F.next=null,s.call(o,F.value,F.worked),l===null&&f.empty()):--p===0&&f.drain()}function _(){c=null,l=null,f.drain=n}function m(){c=null,l=null,f.drain(),f.drain=n}function P(k){d=k}}function n(){}function r(){this.value=null,this.callback=n,this.next=null,this.release=n,this.context=null,this.errorHandler=null;var o=this;this.worked=function(a,u){var c=o.callback,l=o.errorHandler,p=o.value;o.value=null,o.callback=n,o.errorHandler&&l(a,p),c.call(o.context,a,u),o.release(o)}}function i(o,s,a){typeof o=="function"&&(a=s,s=o,o=null);function u(T,E){s.call(this,T).then(function(C){E(null,C)},E)}var c=e(o,u,a),l=c.push,p=c.unshift;return c.push=d,c.unshift=f,c.drained=h,c;function d(T){var E=new Promise(function(C,g){l(T,function(S,y){if(S){g(S);return}C(y)})});return E.catch(n),E}function f(T){var E=new Promise(function(C,g){p(T,function(S,y){if(S){g(S);return}C(y)})});return E.catch(n),E}function h(){if(c.idle())return new Promise(function(C){C()});var T=c.drain,E=new Promise(function(C){c.drain=function(){T(),C()}});return E}}return ct.exports=e,ct.exports.promise=i,ct.exports}var lt={exports:{}},Sn;function so(){if(Sn)return lt.exports;Sn=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(w,L,_){return Function.prototype.apply.call(w,L,_)},n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=function(w){return Object.getOwnPropertyNames(w).concat(Object.getOwnPropertySymbols(w))}:n=function(w){return Object.getOwnPropertyNames(w)};function r(y){console&&console.warn&&console.warn(y)}var i=Number.isNaN||function(w){return w!==w};function o(){o.init.call(this)}lt.exports=o,lt.exports.once=C,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(y){if(typeof y!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof y)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(y){if(typeof y!="number"||y<0||i(y))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+y+".");s=y}}),o.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},o.prototype.setMaxListeners=function(w){if(typeof w!="number"||w<0||i(w))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+w+".");return this._maxListeners=w,this};function u(y){return y._maxListeners===void 0?o.defaultMaxListeners:y._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(w){for(var L=[],_=1;_<arguments.length;_++)L.push(arguments[_]);var m=w==="error",P=this._events;if(P!==void 0)m=m&&P.error===void 0;else if(!m)return!1;if(m){var k;if(L.length>0&&(k=L[0]),k instanceof Error)throw k;var F=new Error("Unhandled error."+(k?" ("+k.message+")":""));throw F.context=k,F}var R=P[w];if(R===void 0)return!1;if(typeof R=="function")e(R,this,L);else for(var U=R.length,j=h(R,U),_=0;_<U;++_)e(j[_],this,L);return!0};function c(y,w,L,_){var m,P,k;if(a(L),P=y._events,P===void 0?(P=y._events=Object.create(null),y._eventsCount=0):(P.newListener!==void 0&&(y.emit("newListener",w,L.listener?L.listener:L),P=y._events),k=P[w]),k===void 0)k=P[w]=L,++y._eventsCount;else if(typeof k=="function"?k=P[w]=_?[L,k]:[k,L]:_?k.unshift(L):k.push(L),m=u(y),m>0&&k.length>m&&!k.warned){k.warned=!0;var F=new Error("Possible EventEmitter memory leak detected. "+k.length+" "+String(w)+" listeners added. Use emitter.setMaxListeners() to increase limit");F.name="MaxListenersExceededWarning",F.emitter=y,F.type=w,F.count=k.length,r(F)}return y}o.prototype.addListener=function(w,L){return c(this,w,L,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(w,L){return c(this,w,L,!0)};function l(){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 p(y,w,L){var _={fired:!1,wrapFn:void 0,target:y,type:w,listener:L},m=l.bind(_);return m.listener=L,_.wrapFn=m,m}o.prototype.once=function(w,L){return a(L),this.on(w,p(this,w,L)),this},o.prototype.prependOnceListener=function(w,L){return a(L),this.prependListener(w,p(this,w,L)),this},o.prototype.removeListener=function(w,L){var _,m,P,k,F;if(a(L),m=this._events,m===void 0)return this;if(_=m[w],_===void 0)return this;if(_===L||_.listener===L)--this._eventsCount===0?this._events=Object.create(null):(delete m[w],m.removeListener&&this.emit("removeListener",w,_.listener||L));else if(typeof _!="function"){for(P=-1,k=_.length-1;k>=0;k--)if(_[k]===L||_[k].listener===L){F=_[k].listener,P=k;break}if(P<0)return this;P===0?_.shift():T(_,P),_.length===1&&(m[w]=_[0]),m.removeListener!==void 0&&this.emit("removeListener",w,F||L)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(w){var L,_,m;if(_=this._events,_===void 0)return this;if(_.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):_[w]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete _[w]),this;if(arguments.length===0){var P=Object.keys(_),k;for(m=0;m<P.length;++m)k=P[m],k!=="removeListener"&&this.removeAllListeners(k);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(L=_[w],typeof L=="function")this.removeListener(w,L);else if(L!==void 0)for(m=L.length-1;m>=0;m--)this.removeListener(w,L[m]);return this};function d(y,w,L){var _=y._events;if(_===void 0)return[];var m=_[w];return m===void 0?[]:typeof m=="function"?L?[m.listener||m]:[m]:L?E(m):h(m,m.length)}o.prototype.listeners=function(w){return d(this,w,!0)},o.prototype.rawListeners=function(w){return d(this,w,!1)},o.listenerCount=function(y,w){return typeof y.listenerCount=="function"?y.listenerCount(w):f.call(y,w)},o.prototype.listenerCount=f;function f(y){var w=this._events;if(w!==void 0){var L=w[y];if(typeof L=="function")return 1;if(L!==void 0)return L.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function h(y,w){for(var L=new Array(w),_=0;_<w;++_)L[_]=y[_];return L}function T(y,w){for(;w+1<y.length;w++)y[w]=y[w+1];y.pop()}function E(y){for(var w=new Array(y.length),L=0;L<w.length;++L)w[L]=y[L].listener||y[L];return w}function C(y,w){return new Promise(function(L,_){function m(k){y.removeListener(w,P),_(k)}function P(){typeof y.removeListener=="function"&&y.removeListener("error",m),L([].slice.call(arguments))}S(y,w,P,{once:!0}),w!=="error"&&g(y,m,{once:!0})})}function g(y,w,L){typeof y.on=="function"&&S(y,"error",w,L)}function S(y,w,L,_){if(typeof y.on=="function")_.once?y.once(w,L):y.on(w,L);else if(typeof y.addEventListener=="function")y.addEventListener(w,function m(P){_.once&&y.removeEventListener(w,m),L(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof y)}return lt.exports}var It={},Ot={},kt,En;function ao(){return En||(En=1,kt=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},n=Symbol("test"),r=Object(n);if(typeof n=="string"||Object.prototype.toString.call(n)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var i=42;e[n]=i;for(var o 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 s=Object.getOwnPropertySymbols(e);if(s.length!==1||s[0]!==n||!Object.prototype.propertyIsEnumerable.call(e,n))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,n);if(a.value!==i||a.enumerable!==!0)return!1}return!0}),kt}var Nt,wn;function Tt(){if(wn)return Nt;wn=1;var t=ao();return Nt=function(){return t()&&!!Symbol.toStringTag},Nt}var Rt,In;function uo(){return In||(In=1,Rt=Object),Rt}var Pt,On;function Fa(){return On||(On=1,Pt=Error),Pt}var Ct,kn;function Ua(){return kn||(kn=1,Ct=EvalError),Ct}var Lt,Nn;function Va(){return Nn||(Nn=1,Lt=RangeError),Lt}var _t,Rn;function xa(){return Rn||(Rn=1,_t=ReferenceError),_t}var Dt,Pn;function co(){return Pn||(Pn=1,Dt=SyntaxError),Dt}var Ft,Cn;function Ze(){return Cn||(Cn=1,Ft=TypeError),Ft}var Ut,Ln;function qa(){return Ln||(Ln=1,Ut=URIError),Ut}var Vt,_n;function Ba(){return _n||(_n=1,Vt=Math.abs),Vt}var xt,Dn;function Ma(){return Dn||(Dn=1,xt=Math.floor),xt}var qt,Fn;function ja(){return Fn||(Fn=1,qt=Math.max),qt}var Bt,Un;function Qa(){return Un||(Un=1,Bt=Math.min),Bt}var Mt,Vn;function Ga(){return Vn||(Vn=1,Mt=Math.pow),Mt}var jt,xn;function Wa(){return xn||(xn=1,jt=Math.round),jt}var Qt,qn;function Ka(){return qn||(qn=1,Qt=Number.isNaN||function(e){return e!==e}),Qt}var Gt,Bn;function Ha(){if(Bn)return Gt;Bn=1;var t=Ka();return Gt=function(n){return t(n)||n===0?n:n<0?-1:1},Gt}var Wt,Mn;function $a(){return Mn||(Mn=1,Wt=Object.getOwnPropertyDescriptor),Wt}var Kt,jn;function Ke(){if(jn)return Kt;jn=1;var t=$a();if(t)try{t([],"length")}catch{t=null}return Kt=t,Kt}var Ht,Qn;function At(){if(Qn)return Ht;Qn=1;var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Ht=t,Ht}var $t,Gn;function za(){if(Gn)return $t;Gn=1;var t=typeof Symbol<"u"&&Symbol,e=ao();return $t=function(){return typeof t!="function"||typeof Symbol!="function"||typeof t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},$t}var zt,Wn;function lo(){return Wn||(Wn=1,zt=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),zt}var Yt,Kn;function po(){if(Kn)return Yt;Kn=1;var t=uo();return Yt=t.getPrototypeOf||null,Yt}var Xt,Hn;function Ya(){if(Hn)return Xt;Hn=1;var t="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,n=Math.max,r="[object Function]",i=function(u,c){for(var l=[],p=0;p<u.length;p+=1)l[p]=u[p];for(var d=0;d<c.length;d+=1)l[d+u.length]=c[d];return l},o=function(u,c){for(var l=[],p=c,d=0;p<u.length;p+=1,d+=1)l[d]=u[p];return l},s=function(a,u){for(var c="",l=0;l<a.length;l+=1)c+=a[l],l+1<a.length&&(c+=u);return c};return Xt=function(u){var c=this;if(typeof c!="function"||e.apply(c)!==r)throw new TypeError(t+c);for(var l=o(arguments,1),p,d=function(){if(this instanceof p){var C=c.apply(this,i(l,arguments));return Object(C)===C?C:this}return c.apply(u,i(l,arguments))},f=n(0,c.length-l.length),h=[],T=0;T<f;T++)h[T]="$"+T;if(p=Function("binder","return function ("+s(h,",")+"){ return binder.apply(this,arguments); }")(d),c.prototype){var E=function(){};E.prototype=c.prototype,p.prototype=new E,E.prototype=null}return p},Xt}var Jt,$n;function et(){if($n)return Jt;$n=1;var t=Ya();return Jt=Function.prototype.bind||t,Jt}var Zt,zn;function qr(){return zn||(zn=1,Zt=Function.prototype.call),Zt}var er,Yn;function Br(){return Yn||(Yn=1,er=Function.prototype.apply),er}var tr,Xn;function Xa(){return Xn||(Xn=1,tr=typeof Reflect<"u"&&Reflect&&Reflect.apply),tr}var rr,Jn;function fo(){if(Jn)return rr;Jn=1;var t=et(),e=Br(),n=qr(),r=Xa();return rr=r||t.call(n,e),rr}var nr,Zn;function Mr(){if(Zn)return nr;Zn=1;var t=et(),e=Ze(),n=qr(),r=fo();return nr=function(o){if(o.length<1||typeof o[0]!="function")throw new e("a function is required");return r(t,n,o)},nr}var ir,ei;function Ja(){if(ei)return ir;ei=1;var t=Mr(),e=Ke(),n;try{n=[].__proto__===Array.prototype}catch(s){if(!s||typeof s!="object"||!("code"in s)||s.code!=="ERR_PROTO_ACCESS")throw s}var r=!!n&&e&&e(Object.prototype,"__proto__"),i=Object,o=i.getPrototypeOf;return ir=r&&typeof r.get=="function"?t([r.get]):typeof o=="function"?function(a){return o(a==null?a:i(a))}:!1,ir}var or,ti;function jr(){if(ti)return or;ti=1;var t=lo(),e=po(),n=Ja();return or=t?function(i){return t(i)}:e?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return e(i)}:n?function(i){return n(i)}:null,or}var sr,ri;function ho(){if(ri)return sr;ri=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,n=et();return sr=n.call(t,e),sr}var ar,ni;function Qr(){if(ni)return ar;ni=1;var t,e=uo(),n=Fa(),r=Ua(),i=Va(),o=xa(),s=co(),a=Ze(),u=qa(),c=Ba(),l=Ma(),p=ja(),d=Qa(),f=Ga(),h=Wa(),T=Ha(),E=Function,C=function(x){try{return E('"use strict"; return ('+x+").constructor;")()}catch{}},g=Ke(),S=At(),y=function(){throw new a},w=g?(function(){try{return arguments.callee,y}catch{try{return g(arguments,"callee").get}catch{return y}}})():y,L=za()(),_=jr(),m=po(),P=lo(),k=Br(),F=qr(),R={},U=typeof Uint8Array>"u"||!_?t:_(Uint8Array),j={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?t:ArrayBuffer,"%ArrayIteratorPrototype%":L&&_?_([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":R,"%AsyncGenerator%":R,"%AsyncGeneratorFunction%":R,"%AsyncIteratorPrototype%":R,"%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%":n,"%eval%":eval,"%EvalError%":r,"%Float16Array%":typeof Float16Array>"u"?t:Float16Array,"%Float32Array%":typeof Float32Array>"u"?t:Float32Array,"%Float64Array%":typeof Float64Array>"u"?t:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?t:FinalizationRegistry,"%Function%":E,"%GeneratorFunction%":R,"%Int8Array%":typeof Int8Array>"u"?t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":L&&_?_(_([][Symbol.iterator]())):t,"%JSON%":typeof JSON=="object"?JSON:t,"%Map%":typeof Map>"u"?t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!L||!_?t:_(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":g,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?t:Promise,"%Proxy%":typeof Proxy>"u"?t:Proxy,"%RangeError%":i,"%ReferenceError%":o,"%Reflect%":typeof Reflect>"u"?t:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?t:Set,"%SetIteratorPrototype%":typeof Set>"u"||!L||!_?t:_(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":L&&_?_(""[Symbol.iterator]()):t,"%Symbol%":L?Symbol:t,"%SyntaxError%":s,"%ThrowTypeError%":w,"%TypedArray%":U,"%TypeError%":a,"%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%":u,"%WeakMap%":typeof WeakMap>"u"?t:WeakMap,"%WeakRef%":typeof WeakRef>"u"?t:WeakRef,"%WeakSet%":typeof WeakSet>"u"?t:WeakSet,"%Function.prototype.call%":F,"%Function.prototype.apply%":k,"%Object.defineProperty%":S,"%Object.getPrototypeOf%":m,"%Math.abs%":c,"%Math.floor%":l,"%Math.max%":p,"%Math.min%":d,"%Math.pow%":f,"%Math.round%":h,"%Math.sign%":T,"%Reflect.getPrototypeOf%":P};if(_)try{null.error}catch(x){var Y=_(_(x));j["%Error.prototype%"]=Y}var ae=function x(V){var W;if(V==="%AsyncFunction%")W=C("async function () {}");else if(V==="%GeneratorFunction%")W=C("function* () {}");else if(V==="%AsyncGeneratorFunction%")W=C("async function* () {}");else if(V==="%AsyncGenerator%"){var $=x("%AsyncGeneratorFunction%");$&&(W=$.prototype)}else if(V==="%AsyncIteratorPrototype%"){var ee=x("%AsyncGenerator%");ee&&_&&(W=_(ee.prototype))}return j[V]=W,W},K={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},se=et(),oe=ho(),Re=se.call(F,Array.prototype.concat),Ue=se.call(k,Array.prototype.splice),b=se.call(F,String.prototype.replace),O=se.call(F,String.prototype.slice),D=se.call(F,RegExp.prototype.exec),q=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Q=/\\(\\)?/g,G=function(V){var W=O(V,0,1),$=O(V,-1);if(W==="%"&&$!=="%")throw new s("invalid intrinsic syntax, expected closing `%`");if($==="%"&&W!=="%")throw new s("invalid intrinsic syntax, expected opening `%`");var ee=[];return b(V,q,function(re,pe,ne,Ve){ee[ee.length]=ne?b(Ve,Q,"$1"):pe||re}),ee},M=function(V,W){var $=V,ee;if(oe(K,$)&&(ee=K[$],$="%"+ee[0]+"%"),oe(j,$)){var re=j[$];if(re===R&&(re=ae($)),typeof re>"u"&&!W)throw new a("intrinsic "+V+" exists, but is not available. Please file an issue!");return{alias:ee,name:$,value:re}}throw new s("intrinsic "+V+" does not exist!")};return ar=function(V,W){if(typeof V!="string"||V.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof W!="boolean")throw new a('"allowMissing" argument must be a boolean');if(D(/^%?[^%]*%?$/,V)===null)throw new s("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var $=G(V),ee=$.length>0?$[0]:"",re=M("%"+ee+"%",W),pe=re.name,ne=re.value,Ve=!1,He=re.alias;He&&(ee=He[0],Ue($,Re([0,1],He)));for(var N=1,Le=!0;N<$.length;N+=1){var ye=$[N],tt=O(ye,0,1),rt=O(ye,-1);if((tt==='"'||tt==="'"||tt==="`"||rt==='"'||rt==="'"||rt==="`")&&tt!==rt)throw new s("property names with quotes must have matching quotes");if((ye==="constructor"||!Le)&&(Ve=!0),ee+="."+ye,pe="%"+ee+"%",oe(j,pe))ne=j[pe];else if(ne!=null){if(!(ye in ne)){if(!W)throw new a("base intrinsic for "+V+" exists, but the property is not available.");return}if(g&&N+1>=$.length){var nt=g(ne,ye);Le=!!nt,Le&&"get"in nt&&!("originalValue"in nt.get)?ne=nt.get:ne=ne[ye]}else Le=oe(ne,ye),ne=ne[ye];Le&&!Ve&&(j[pe]=ne)}}return ne},ar}var ur={exports:{}},cr,ii;function Za(){if(ii)return cr;ii=1;var t=At(),e=co(),n=Ze(),r=Ke();return cr=function(o,s,a){if(!o||typeof o!="object"&&typeof o!="function")throw new n("`obj` must be an object or a function`");if(typeof s!="string"&&typeof s!="symbol")throw new n("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new n("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new n("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new n("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new n("`loose`, if provided, must be a boolean");var u=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,p=arguments.length>6?arguments[6]:!1,d=!!r&&r(o,s);if(t)t(o,s,{configurable:l===null&&d?d.configurable:!l,enumerable:u===null&&d?d.enumerable:!u,value:a,writable:c===null&&d?d.writable:!c});else if(p||!u&&!c&&!l)o[s]=a;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},cr}var lr,oi;function eu(){if(oi)return lr;oi=1;var t=At(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return t([],"length",{value:1}).length!==1}catch{return!0}},lr=e,lr}var dr,si;function tu(){if(si)return dr;si=1;var t=Qr(),e=Za(),n=eu()(),r=Ke(),i=Ze(),o=t("%Math.floor%");return dr=function(a,u){if(typeof a!="function")throw new i("`fn` is not a function");if(typeof u!="number"||u<0||u>4294967295||o(u)!==u)throw new i("`length` must be a positive 32-bit integer");var c=arguments.length>2&&!!arguments[2],l=!0,p=!0;if("length"in a&&r){var d=r(a,"length");d&&!d.configurable&&(l=!1),d&&!d.writable&&(p=!1)}return(l||p||!c)&&(n?e(a,"length",u,!0,!0):e(a,"length",u)),a},dr}var pr,ai;function ru(){if(ai)return pr;ai=1;var t=et(),e=Br(),n=fo();return pr=function(){return n(t,e,arguments)},pr}var ui;function mo(){return ui||(ui=1,(function(t){var e=tu(),n=At(),r=Mr(),i=ru();t.exports=function(s){var a=r(arguments),u=s.length-(arguments.length-1);return e(a,1+(u>0?u:0),!0)},n?n(t.exports,"apply",{value:i}):t.exports.apply=i})(ur)),ur.exports}var fr,ci;function nu(){if(ci)return fr;ci=1;var t=Qr(),e=mo(),n=e(t("String.prototype.indexOf"));return fr=function(i,o){var s=t(i,!!o);return typeof s=="function"&&n(i,".prototype.")>-1?e(s):s},fr}var hr,li;function iu(){if(li)return hr;li=1;var t=Tt()(),e=nu(),n=e("Object.prototype.toString"),r=function(a){return t&&a&&typeof a=="object"&&Symbol.toStringTag in a?!1:n(a)==="[object Arguments]"},i=function(a){return r(a)?!0:a!==null&&typeof a=="object"&&typeof a.length=="number"&&a.length>=0&&n(a)!=="[object Array]"&&n(a.callee)==="[object Function]"},o=(function(){return r(arguments)})();return r.isLegacyArguments=i,hr=o?r:i,hr}var mr,di;function St(){if(di)return mr;di=1;var t=Qr(),e=Mr(),n=e([t("%String.prototype.indexOf%")]);return mr=function(i,o){var s=t(i,!!o);return typeof s=="function"&&n(i,".prototype.")>-1?e([s]):s},mr}var yr,pi;function ou(){if(pi)return yr;pi=1;var t=St(),e=Tt()(),n=ho(),r=Ke(),i;if(e){var o=t("RegExp.prototype.exec"),s={},a=function(){throw s},u={toString:a,valueOf:a};typeof Symbol.toPrimitive=="symbol"&&(u[Symbol.toPrimitive]=a),i=function(d){if(!d||typeof d!="object")return!1;var f=r(d,"lastIndex"),h=f&&n(f,"value");if(!h)return!1;try{o(d,u)}catch(T){return T===s}}}else{var c=t("Object.prototype.toString"),l="[object RegExp]";i=function(d){return!d||typeof d!="object"&&typeof d!="function"?!1:c(d)===l}}return yr=i,yr}var gr,fi;function su(){if(fi)return gr;fi=1;var t=St(),e=ou(),n=t("RegExp.prototype.exec"),r=Ze();return gr=function(o){if(!e(o))throw new r("`regex` must be a RegExp");return function(a){return n(o,a)!==null}},gr}var vr,hi;function au(){if(hi)return vr;hi=1;var t=St(),e=su(),n=e(/^\s*(?:function)?\*/),r=Tt()(),i=jr(),o=t("Object.prototype.toString"),s=t("Function.prototype.toString"),a=function(){if(!r)return!1;try{return Function("return function*() {}")()}catch{}},u;return vr=function(l){if(typeof l!="function")return!1;if(n(s(l)))return!0;if(!r){var p=o(l);return p==="[object GeneratorFunction]"}if(!i)return!1;if(typeof u>"u"){var d=a();u=d?i(d):!1}return i(l)===u},vr}var br,mi;function uu(){if(mi)return br;mi=1;var t=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,n,r;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{n=Object.defineProperty({},"length",{get:function(){throw r}}),r={},e(function(){throw 42},null,n)}catch(g){g!==r&&(e=null)}else e=null;var i=/^\s*class\b/,o=function(S){try{var y=t.call(S);return i.test(y)}catch{return!1}},s=function(S){try{return o(S)?!1:(t.call(S),!0)}catch{return!1}},a=Object.prototype.toString,u="[object Object]",c="[object Function]",l="[object GeneratorFunction]",p="[object HTMLAllCollection]",d="[object HTML document.all class]",f="[object HTMLCollection]",h=typeof Symbol=="function"&&!!Symbol.toStringTag,T=!(0 in[,]),E=function(){return!1};if(typeof document=="object"){var C=document.all;a.call(C)===a.call(document.all)&&(E=function(S){if((T||!S)&&(typeof S>"u"||typeof S=="object"))try{var y=a.call(S);return(y===p||y===d||y===f||y===u)&&S("")==null}catch{}return!1})}return br=e?function(S){if(E(S))return!0;if(!S||typeof S!="function"&&typeof S!="object")return!1;try{e(S,null,n)}catch(y){if(y!==r)return!1}return!o(S)&&s(S)}:function(S){if(E(S))return!0;if(!S||typeof S!="function"&&typeof S!="object")return!1;if(h)return s(S);if(o(S))return!1;var y=a.call(S);return y!==c&&y!==l&&!/^\[object HTML/.test(y)?!1:s(S)},br}var Tr,yi;function cu(){if(yi)return Tr;yi=1;var t=uu(),e=Object.prototype.toString,n=Object.prototype.hasOwnProperty,r=function(u,c,l){for(var p=0,d=u.length;p<d;p++)n.call(u,p)&&(l==null?c(u[p],p,u):c.call(l,u[p],p,u))},i=function(u,c,l){for(var p=0,d=u.length;p<d;p++)l==null?c(u.charAt(p),p,u):c.call(l,u.charAt(p),p,u)},o=function(u,c,l){for(var p in u)n.call(u,p)&&(l==null?c(u[p],p,u):c.call(l,u[p],p,u))};function s(a){return e.call(a)==="[object Array]"}return Tr=function(u,c,l){if(!t(c))throw new TypeError("iterator must be a function");var p;arguments.length>=3&&(p=l),s(u)?r(u,c,p):typeof u=="string"?i(u,c,p):o(u,c,p)},Tr}var Ar,gi;function lu(){return gi||(gi=1,Ar=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),Ar}var Sr,vi;function du(){if(vi)return Sr;vi=1;var t=lu(),e=typeof globalThis>"u"?no:globalThis;return Sr=function(){for(var r=[],i=0;i<t.length;i++)typeof e[t[i]]=="function"&&(r[r.length]=t[i]);return r},Sr}var Er,bi;function yo(){if(bi)return Er;bi=1;var t=cu(),e=du(),n=mo(),r=St(),i=Ke(),o=jr(),s=r("Object.prototype.toString"),a=Tt()(),u=typeof globalThis>"u"?no:globalThis,c=e(),l=r("String.prototype.slice"),p=r("Array.prototype.indexOf",!0)||function(E,C){for(var g=0;g<E.length;g+=1)if(E[g]===C)return g;return-1},d={__proto__:null};a&&i&&o?t(c,function(T){var E=new u[T];if(Symbol.toStringTag in E&&o){var C=o(E),g=i(C,Symbol.toStringTag);if(!g&&C){var S=o(C);g=i(S,Symbol.toStringTag)}if(g&&g.get){var y=n(g.get);d["$"+T]=y}}}):t(c,function(T){var E=new u[T],C=E.slice||E.set;if(C){var g=n(C);d["$"+T]=g}});var f=function(E){var C=!1;return t(d,function(g,S){if(!C)try{"$"+g(E)===S&&(C=l(S,1))}catch{}}),C},h=function(E){var C=!1;return t(d,function(g,S){if(!C)try{g(E),C=l(S,1)}catch{}}),C};return Er=function(E){if(!E||typeof E!="object")return!1;if(!a){var C=l(s(E),8,-1);return p(c,C)>-1?C:C!=="Object"?!1:h(E)}return i?f(E):null},Er}var wr,Ti;function pu(){if(Ti)return wr;Ti=1;var t=yo();return wr=function(n){return!!t(n)},wr}var Ai;function fu(){return Ai||(Ai=1,(function(t){var e=iu(),n=au(),r=yo(),i=pu();function o(N){return N.call.bind(N)}var s=typeof BigInt<"u",a=typeof Symbol<"u",u=o(Object.prototype.toString),c=o(Number.prototype.valueOf),l=o(String.prototype.valueOf),p=o(Boolean.prototype.valueOf);if(s)var d=o(BigInt.prototype.valueOf);if(a)var f=o(Symbol.prototype.valueOf);function h(N,Le){if(typeof N!="object")return!1;try{return Le(N),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=n,t.isTypedArray=i;function T(N){return typeof Promise<"u"&&N instanceof Promise||N!==null&&typeof N=="object"&&typeof N.then=="function"&&typeof N.catch=="function"}t.isPromise=T;function E(N){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(N):i(N)||O(N)}t.isArrayBufferView=E;function C(N){return r(N)==="Uint8Array"}t.isUint8Array=C;function g(N){return r(N)==="Uint8ClampedArray"}t.isUint8ClampedArray=g;function S(N){return r(N)==="Uint16Array"}t.isUint16Array=S;function y(N){return r(N)==="Uint32Array"}t.isUint32Array=y;function w(N){return r(N)==="Int8Array"}t.isInt8Array=w;function L(N){return r(N)==="Int16Array"}t.isInt16Array=L;function _(N){return r(N)==="Int32Array"}t.isInt32Array=_;function m(N){return r(N)==="Float32Array"}t.isFloat32Array=m;function P(N){return r(N)==="Float64Array"}t.isFloat64Array=P;function k(N){return r(N)==="BigInt64Array"}t.isBigInt64Array=k;function F(N){return r(N)==="BigUint64Array"}t.isBigUint64Array=F;function R(N){return u(N)==="[object Map]"}R.working=typeof Map<"u"&&R(new Map);function U(N){return typeof Map>"u"?!1:R.working?R(N):N instanceof Map}t.isMap=U;function j(N){return u(N)==="[object Set]"}j.working=typeof Set<"u"&&j(new Set);function Y(N){return typeof Set>"u"?!1:j.working?j(N):N instanceof Set}t.isSet=Y;function ae(N){return u(N)==="[object WeakMap]"}ae.working=typeof WeakMap<"u"&&ae(new WeakMap);function K(N){return typeof WeakMap>"u"?!1:ae.working?ae(N):N instanceof WeakMap}t.isWeakMap=K;function se(N){return u(N)==="[object WeakSet]"}se.working=typeof WeakSet<"u"&&se(new WeakSet);function oe(N){return se(N)}t.isWeakSet=oe;function Re(N){return u(N)==="[object ArrayBuffer]"}Re.working=typeof ArrayBuffer<"u"&&Re(new ArrayBuffer);function Ue(N){return typeof ArrayBuffer>"u"?!1:Re.working?Re(N):N instanceof ArrayBuffer}t.isArrayBuffer=Ue;function b(N){return u(N)==="[object DataView]"}b.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&b(new DataView(new ArrayBuffer(1),0,1));function O(N){return typeof DataView>"u"?!1:b.working?b(N):N instanceof DataView}t.isDataView=O;var D=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function q(N){return u(N)==="[object SharedArrayBuffer]"}function Q(N){return typeof D>"u"?!1:(typeof q.working>"u"&&(q.working=q(new D)),q.working?q(N):N instanceof D)}t.isSharedArrayBuffer=Q;function G(N){return u(N)==="[object AsyncFunction]"}t.isAsyncFunction=G;function M(N){return u(N)==="[object Map Iterator]"}t.isMapIterator=M;function x(N){return u(N)==="[object Set Iterator]"}t.isSetIterator=x;function V(N){return u(N)==="[object Generator]"}t.isGeneratorObject=V;function W(N){return u(N)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=W;function $(N){return h(N,c)}t.isNumberObject=$;function ee(N){return h(N,l)}t.isStringObject=ee;function re(N){return h(N,p)}t.isBooleanObject=re;function pe(N){return s&&h(N,d)}t.isBigIntObject=pe;function ne(N){return a&&h(N,f)}t.isSymbolObject=ne;function Ve(N){return $(N)||ee(N)||re(N)||pe(N)||ne(N)}t.isBoxedPrimitive=Ve;function He(N){return typeof Uint8Array<"u"&&(Ue(N)||Q(N))}t.isAnyArrayBuffer=He,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(N){Object.defineProperty(t,N,{enumerable:!1,value:function(){throw new Error(N+" is not supported in userland")}})})})(Ot)),Ot}var Ir,Si;function hu(){return Si||(Si=1,Ir=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),Ir}var dt={exports:{}},Ei;function mu(){return Ei||(Ei=1,typeof Object.create=="function"?dt.exports=function(e,n){n&&(e.super_=n,e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:dt.exports=function(e,n){if(n){e.super_=n;var r=function(){};r.prototype=n.prototype,e.prototype=new r,e.prototype.constructor=e}}),dt.exports}var wi;function Gr(){return wi||(wi=1,(function(t){var e=Object.getOwnPropertyDescriptors||function(O){for(var D=Object.keys(O),q={},Q=0;Q<D.length;Q++)q[D[Q]]=Object.getOwnPropertyDescriptor(O,D[Q]);return q},n=/%[sdj%]/g;t.format=function(b){if(!w(b)){for(var O=[],D=0;D<arguments.length;D++)O.push(s(arguments[D]));return O.join(" ")}for(var D=1,q=arguments,Q=q.length,G=String(b).replace(n,function(x){if(x==="%%")return"%";if(D>=Q)return x;switch(x){case"%s":return String(q[D++]);case"%d":return Number(q[D++]);case"%j":try{return JSON.stringify(q[D++])}catch{return"[Circular]"}default:return x}}),M=q[D];D<Q;M=q[++D])g(M)||!P(M)?G+=" "+M:G+=" "+s(M);return G},t.deprecate=function(b,O){if(typeof B<"u"&&B.noDeprecation===!0)return b;if(typeof B>"u")return function(){return t.deprecate(b,O).apply(this,arguments)};var D=!1;function q(){if(!D){if(B.throwDeprecation)throw new Error(O);B.traceDeprecation?console.trace(O):console.error(O),D=!0}return b.apply(this,arguments)}return q};var r={},i=/^$/;if(B.env.NODE_DEBUG){var o=B.env.NODE_DEBUG;o=o.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),i=new RegExp("^"+o+"$","i")}t.debuglog=function(b){if(b=b.toUpperCase(),!r[b])if(i.test(b)){var O=B.pid;r[b]=function(){var D=t.format.apply(t,arguments);console.error("%s %d: %s",b,O,D)}}else r[b]=function(){};return r[b]};function s(b,O){var D={seen:[],stylize:u};return arguments.length>=3&&(D.depth=arguments[2]),arguments.length>=4&&(D.colors=arguments[3]),C(O)?D.showHidden=O:O&&t._extend(D,O),_(D.showHidden)&&(D.showHidden=!1),_(D.depth)&&(D.depth=2),_(D.colors)&&(D.colors=!1),_(D.customInspect)&&(D.customInspect=!0),D.colors&&(D.stylize=a),l(D,b,D.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(b,O){var D=s.styles[O];return D?"\x1B["+s.colors[D][0]+"m"+b+"\x1B["+s.colors[D][1]+"m":b}function u(b,O){return b}function c(b){var O={};return b.forEach(function(D,q){O[D]=!0}),O}function l(b,O,D){if(b.customInspect&&O&&R(O.inspect)&&O.inspect!==t.inspect&&!(O.constructor&&O.constructor.prototype===O)){var q=O.inspect(D,b);return w(q)||(q=l(b,q,D)),q}var Q=p(b,O);if(Q)return Q;var G=Object.keys(O),M=c(G);if(b.showHidden&&(G=Object.getOwnPropertyNames(O)),F(O)&&(G.indexOf("message")>=0||G.indexOf("description")>=0))return d(O);if(G.length===0){if(R(O)){var x=O.name?": "+O.name:"";return b.stylize("[Function"+x+"]","special")}if(m(O))return b.stylize(RegExp.prototype.toString.call(O),"regexp");if(k(O))return b.stylize(Date.prototype.toString.call(O),"date");if(F(O))return d(O)}var V="",W=!1,$=["{","}"];if(E(O)&&(W=!0,$=["[","]"]),R(O)){var ee=O.name?": "+O.name:"";V=" [Function"+ee+"]"}if(m(O)&&(V=" "+RegExp.prototype.toString.call(O)),k(O)&&(V=" "+Date.prototype.toUTCString.call(O)),F(O)&&(V=" "+d(O)),G.length===0&&(!W||O.length==0))return $[0]+V+$[1];if(D<0)return m(O)?b.stylize(RegExp.prototype.toString.call(O),"regexp"):b.stylize("[Object]","special");b.seen.push(O);var re;return W?re=f(b,O,D,M,G):re=G.map(function(pe){return h(b,O,D,M,pe,W)}),b.seen.pop(),T(re,V,$)}function p(b,O){if(_(O))return b.stylize("undefined","undefined");if(w(O)){var D="'"+JSON.stringify(O).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return b.stylize(D,"string")}if(y(O))return b.stylize(""+O,"number");if(C(O))return b.stylize(""+O,"boolean");if(g(O))return b.stylize("null","null")}function d(b){return"["+Error.prototype.toString.call(b)+"]"}function f(b,O,D,q,Q){for(var G=[],M=0,x=O.length;M<x;++M)se(O,String(M))?G.push(h(b,O,D,q,String(M),!0)):G.push("");return Q.forEach(function(V){V.match(/^\d+$/)||G.push(h(b,O,D,q,V,!0))}),G}function h(b,O,D,q,Q,G){var M,x,V;if(V=Object.getOwnPropertyDescriptor(O,Q)||{value:O[Q]},V.get?V.set?x=b.stylize("[Getter/Setter]","special"):x=b.stylize("[Getter]","special"):V.set&&(x=b.stylize("[Setter]","special")),se(q,Q)||(M="["+Q+"]"),x||(b.seen.indexOf(V.value)<0?(g(D)?x=l(b,V.value,null):x=l(b,V.value,D-1),x.indexOf(`
|
|
3
|
+
`)>-1&&(G?x=x.split(`
|
|
4
|
+
`).map(function(W){return" "+W}).join(`
|
|
5
|
+
`).slice(2):x=`
|
|
6
|
+
`+x.split(`
|
|
7
|
+
`).map(function(W){return" "+W}).join(`
|
|
8
|
+
`))):x=b.stylize("[Circular]","special")),_(M)){if(G&&Q.match(/^\d+$/))return x;M=JSON.stringify(""+Q),M.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(M=M.slice(1,-1),M=b.stylize(M,"name")):(M=M.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),M=b.stylize(M,"string"))}return M+": "+x}function T(b,O,D){var q=b.reduce(function(Q,G){return G.indexOf(`
|
|
9
|
+
`)>=0,Q+G.replace(/\u001b\[\d\d?m/g,"").length+1},0);return q>60?D[0]+(O===""?"":O+`
|
|
10
|
+
`)+" "+b.join(`,
|
|
11
|
+
`)+" "+D[1]:D[0]+O+" "+b.join(", ")+" "+D[1]}t.types=fu();function E(b){return Array.isArray(b)}t.isArray=E;function C(b){return typeof b=="boolean"}t.isBoolean=C;function g(b){return b===null}t.isNull=g;function S(b){return b==null}t.isNullOrUndefined=S;function y(b){return typeof b=="number"}t.isNumber=y;function w(b){return typeof b=="string"}t.isString=w;function L(b){return typeof b=="symbol"}t.isSymbol=L;function _(b){return b===void 0}t.isUndefined=_;function m(b){return P(b)&&j(b)==="[object RegExp]"}t.isRegExp=m,t.types.isRegExp=m;function P(b){return typeof b=="object"&&b!==null}t.isObject=P;function k(b){return P(b)&&j(b)==="[object Date]"}t.isDate=k,t.types.isDate=k;function F(b){return P(b)&&(j(b)==="[object Error]"||b instanceof Error)}t.isError=F,t.types.isNativeError=F;function R(b){return typeof b=="function"}t.isFunction=R;function U(b){return b===null||typeof b=="boolean"||typeof b=="number"||typeof b=="string"||typeof b=="symbol"||typeof b>"u"}t.isPrimitive=U,t.isBuffer=hu();function j(b){return Object.prototype.toString.call(b)}function Y(b){return b<10?"0"+b.toString(10):b.toString(10)}var ae=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function K(){var b=new Date,O=[Y(b.getHours()),Y(b.getMinutes()),Y(b.getSeconds())].join(":");return[b.getDate(),ae[b.getMonth()],O].join(" ")}t.log=function(){console.log("%s - %s",K(),t.format.apply(t,arguments))},t.inherits=mu(),t._extend=function(b,O){if(!O||!P(O))return b;for(var D=Object.keys(O),q=D.length;q--;)b[D[q]]=O[D[q]];return b};function se(b,O){return Object.prototype.hasOwnProperty.call(b,O)}var oe=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(O){if(typeof O!="function")throw new TypeError('The "original" argument must be of type Function');if(oe&&O[oe]){var D=O[oe];if(typeof D!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(D,oe,{value:D,enumerable:!1,writable:!1,configurable:!0}),D}function D(){for(var q,Q,G=new Promise(function(V,W){q=V,Q=W}),M=[],x=0;x<arguments.length;x++)M.push(arguments[x]);M.push(function(V,W){V?Q(V):q(W)});try{O.apply(this,M)}catch(V){Q(V)}return G}return Object.setPrototypeOf(D,Object.getPrototypeOf(O)),oe&&Object.defineProperty(D,oe,{value:D,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(D,e(O))},t.promisify.custom=oe;function Re(b,O){if(!b){var D=new Error("Promise was rejected with a falsy value");D.reason=b,b=D}return O(b)}function Ue(b){if(typeof b!="function")throw new TypeError('The "original" argument must be of type Function');function O(){for(var D=[],q=0;q<arguments.length;q++)D.push(arguments[q]);var Q=D.pop();if(typeof Q!="function")throw new TypeError("The last argument must be of type Function");var G=this,M=function(){return Q.apply(G,arguments)};b.apply(this,D).then(function(x){B.nextTick(M.bind(null,null,x))},function(x){B.nextTick(Re.bind(null,x,M))})}return Object.setPrototypeOf(O,Object.getPrototypeOf(b)),Object.defineProperties(O,e(b)),O}t.callbackify=Ue})(It)),It}var Or,Ii;function go(){if(Ii)return Or;Ii=1;const{inherits:t,format:e}=Gr();function n(r,i,o=Error){if(!r)throw new Error("Avvio error code must not be empty");if(!i)throw new Error("Avvio base error message must not be empty");function s(a,u,c){if(!new.target)return new s(a,u,c);Error.captureStackTrace(this,s),this.code=r,this.message=i,this.name="AvvioError",a&&u&&c?this.message=e(i,a,u,c):a&&u?this.message=e(i,a,u):a?this.message=e(i,a):this.message=i}return s.prototype[Symbol.toStringTag]="Error",s.prototype.toString=function(){return`${this.name} [${this.code}]: ${this.message}`},t(s,o),s}return Or={createError:n,AVV_ERR_EXPOSE_ALREADY_DEFINED:n("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' () is already defined, specify an expose option"),AVV_ERR_CALLBACK_NOT_FN:n("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:n("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:n("AVV_ERR_PLUGIN_NOT_VALID","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:n("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:n("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")},Or}var kr,Oi;function yu(){return Oi||(Oi=1,kr=function t(e,n,r){n===void 0&&(n=""),r||(r={});var i=function(u){var c={"│":"|","└":"`","├":"+","─":"-","┬":"-"};return r.unicode===!1?c[u]:u};typeof e=="string"&&(e={label:e});var o=e.nodes||[],s=(e.label||"").split(`
|
|
12
|
+
`),a=`
|
|
13
|
+
`+n+(o.length?i("│"):" ")+" ";return n+s.join(a)+`
|
|
14
|
+
`+o.map(function(u,c){var l=c===o.length-1,p=u.nodes&&u.nodes.length,d=n+(l?" ":i("│"))+" ";return n+i(l?"└":"├")+i("─")+i(p?"┬":"─")+" "+t(u,d,r).slice(n.length+2)}).join("")}),kr}var Nr,ki;function gu(){if(ki)return Nr;ki=1;const t=yu(),e=Symbol("avvio.TimeTree.untrackNode"),n=Symbol("avvio.TimeTree.trackNode"),r=Symbol("avvio.TimeTree.getParent"),i=Symbol("avvio.TimeTree.getNode"),o=Symbol("avvio.TimeTree.addNode");class s{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[n](u){this.tableId.set(u.id,u),this.tableLabel.has(u.label)?this.tableLabel.get(u.label).push(u):this.tableLabel.set(u.label,[u])}[e](u){this.tableId.delete(u.id);const c=this.tableLabel.get(u.label);if(c.id){this.tableLabel.delete(u.label);return}c.pop(),c.length===0&&this.tableLabel.delete(u.label)}[r](u){if(u===null)return this.root;const c=this.tableLabel.get(u);return c.id?c:c[c.length-1]}[i](u){return this.tableId.get(u)}[o](u,c,l){if(u===null)return this.root={id:"root",label:c,start:l,nodes:[]},this[n](this.root),this.root.id;const d=this[r](u),f=`${c}-${Math.random()}`,h={id:f,parent:u,start:l,label:c,nodes:[]};return d.nodes.push(h),this[n](h),f}start(u,c,l=Date.now()){return this[o](u,c,l)}stop(u,c=Date.now()){const l=this[i](u);l&&(l.stop=c,l.diff=l.stop-l.start||0,this[e](l))}toJSON(){return Object.assign({},this.root)}prittyPrint(){const u=l=>(l.label=`${l.label} ${l.diff} ms`,l.nodes.length>0&&(l.nodes=l.nodes.map(p=>u(p))),l),c=u(this.toJSON());return t(c)}}return Nr=s,Nr}var pt={exports:{}},ft={exports:{}},Rr,Ni;function vu(){if(Ni)return Rr;Ni=1;var t=1e3,e=t*60,n=e*60,r=n*24,i=r*7,o=r*365.25;Rr=function(l,p){p=p||{};var d=typeof l;if(d==="string"&&l.length>0)return s(l);if(d==="number"&&isFinite(l))return p.long?u(l):a(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function s(l){if(l=String(l),!(l.length>100)){var p=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(p){var d=parseFloat(p[1]),f=(p[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return d*o;case"weeks":case"week":case"w":return d*i;case"days":case"day":case"d":return d*r;case"hours":case"hour":case"hrs":case"hr":case"h":return d*n;case"minutes":case"minute":case"mins":case"min":case"m":return d*e;case"seconds":case"second":case"secs":case"sec":case"s":return d*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function a(l){var p=Math.abs(l);return p>=r?Math.round(l/r)+"d":p>=n?Math.round(l/n)+"h":p>=e?Math.round(l/e)+"m":p>=t?Math.round(l/t)+"s":l+"ms"}function u(l){var p=Math.abs(l);return p>=r?c(l,p,r,"day"):p>=n?c(l,p,n,"hour"):p>=e?c(l,p,e,"minute"):p>=t?c(l,p,t,"second"):l+" ms"}function c(l,p,d,f){var h=p>=d*1.5;return Math.round(l/d)+" "+f+(h?"s":"")}return Rr}var Pr,Ri;function bu(){if(Ri)return Pr;Ri=1;function t(e){r.debug=r,r.default=r,r.coerce=c,r.disable=a,r.enable=o,r.enabled=u,r.humanize=vu(),r.destroy=l,Object.keys(e).forEach(p=>{r[p]=e[p]}),r.names=[],r.skips=[],r.formatters={};function n(p){let d=0;for(let f=0;f<p.length;f++)d=(d<<5)-d+p.charCodeAt(f),d|=0;return r.colors[Math.abs(d)%r.colors.length]}r.selectColor=n;function r(p){let d,f=null,h,T;function E(...C){if(!E.enabled)return;const g=E,S=Number(new Date),y=S-(d||S);g.diff=y,g.prev=d,g.curr=S,d=S,C[0]=r.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let w=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(_,m)=>{if(_==="%%")return"%";w++;const P=r.formatters[m];if(typeof P=="function"){const k=C[w];_=P.call(g,k),C.splice(w,1),w--}return _}),r.formatArgs.call(g,C),(g.log||r.log).apply(g,C)}return E.namespace=p,E.useColors=r.useColors(),E.color=r.selectColor(p),E.extend=i,E.destroy=r.destroy,Object.defineProperty(E,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(h!==r.namespaces&&(h=r.namespaces,T=r.enabled(p)),T),set:C=>{f=C}}),typeof r.init=="function"&&r.init(E),E}function i(p,d){const f=r(this.namespace+(typeof d>"u"?":":d)+p);return f.log=this.log,f}function o(p){r.save(p),r.namespaces=p,r.names=[],r.skips=[];const d=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const f of d)f[0]==="-"?r.skips.push(f.slice(1)):r.names.push(f)}function s(p,d){let f=0,h=0,T=-1,E=0;for(;f<p.length;)if(h<d.length&&(d[h]===p[f]||d[h]==="*"))d[h]==="*"?(T=h,E=f,h++):(f++,h++);else if(T!==-1)h=T+1,E++,f=E;else return!1;for(;h<d.length&&d[h]==="*";)h++;return h===d.length}function a(){const p=[...r.names,...r.skips.map(d=>"-"+d)].join(",");return r.enable(""),p}function u(p){for(const d of r.skips)if(s(p,d))return!1;for(const d of r.names)if(s(p,d))return!0;return!1}function c(p){return p instanceof Error?p.stack||p.message:p}function l(){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}return Pr=t,Pr}var Pi;function vo(){return Pi||(Pi=1,(function(t,e){e.formatArgs=r,e.save=i,e.load=o,e.useColors=n,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 n(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let u;return 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&&(u=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(u[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(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 c="color: "+this.color;u.splice(1,0,c,"color: inherit");let l=0,p=0;u[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&(l++,d==="%c"&&(p=l))}),u.splice(p,0,c)}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")||e.storage.getItem("DEBUG")}catch{}return!u&&typeof B<"u"&&"env"in B&&(u=B.env.DEBUG),u}function s(){try{return localStorage}catch{}}t.exports=bu()(e);const{formatters:a}=t.exports;a.j=function(u){try{return JSON.stringify(u)}catch(c){return"[UnexpectedJSONParseError]: "+c.message}}})(ft,ft.exports)),ft.exports}var Ci;function Tu(){if(Ci)return pt.exports;Ci=1;const t=oo(),e=so().EventEmitter,n=Gr().inherits,r=vo()("avvio"),{AVV_ERR_READY_TIMEOUT:i}=go(),o=Symbol.for("plugin-meta");function s(d,f){return d[o]&&d[o].name?d[o].name:typeof f<"u"&&typeof f!="function"&&f.name?f.name:d.name?d.name:d.toString().split(`
|
|
15
|
+
`).slice(0,2).map(h=>h.trim()).join(" -- ")}function a(){const d={};return d.promise=new Promise((f,h)=>{d.resolve=f,d.reject=h}),d}function u(d,f,h,T,E){this.started=!1,this.func=f,this.opts=h,this.onFinish=null,this.parent=d,this.timeout=E===void 0?d._timeout:E,this.name=s(f,h),this.isAfter=T,this.q=t(d,c,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}n(u,e),u.prototype.exec=function(d,f){const h=this.func;let T=!1;const E=this.name;if(this.parent._error&&!this.isAfter){r("skipping loading of plugin as parent errored and it is not an after",E),B.nextTick(f);return}if(this.isAfter)this.server=d;else try{this.server=this.parent.override(d,h,this.opts)}catch(y){return r("override errored",E),f(y)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,r("exec",E);let C;const g=y=>{if(T){r("loading complete",E);return}this._error=y,r(y?"exec errored":"exec completed",E),T=!0,C&&clearTimeout(C),f(y)};this.timeout>0&&(r("setting up timeout",E,this.timeout),C=setTimeout(function(){r("timed out",E),C=null;const y=new i(E);y.fn=h,g(y)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const S=h(this.server,this.opts,g);S&&typeof S.then=="function"&&(r("exec: resolving promise",E),S.then(()=>B.nextTick(g),y=>B.nextTick(g,y)))},u.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const d=()=>{this.server.after((h,T)=>{this._error=h,this.q.pause(),h?(r("rejecting promise",this.name,h),this._promise.reject(h)):(r("resolving promise",this.name),this._promise.resolve()),this._promise=null,B.nextTick(T,h)}),this.q.resume()};let f;return this._promise?f=Promise.resolve():(this._promise=a(),f=this._promise.promise,this.server?d():this.on("start",d)),f},u.prototype.enqueue=function(d,f){r("enqueue",this.name,d.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(d,f)},u.prototype.finish=function(d,f){r("finish",this.name,d);const h=()=>{this.loaded||(r("loaded",this.name),this.emit("loaded",this.server?this.server.name:null,this.name,Date.now()),this.loaded=!0,f(d))};if(d){this._promise&&(this._promise.reject(d),this._promise=null),h();return}const T=()=>{if(r("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const E=()=>{r("wrap"),queueMicrotask(T)};this._promise.resolve(),this._promise.promise.then(E,E),this._promise=null}else h();else r("delayed",this.name),this.q.drain=()=>{r("drain",this.name),this.q.drain=p,queueMicrotask(T)}};queueMicrotask(T),this.q.resume()};function c(d,f){const h=this;B.nextTick(l.bind(h),d,f)}function l(d,f){if(typeof d.func.then=="function"){d.func.then(T=>{typeof T.default=="function"&&(T=T.default),d.func=T,l.call(this,d,f)},f);return}const h=this._current[0];this._current.unshift(d),d.exec(h&&h.server||this._server,T=>{d.finish(T,E=>{this._current.shift(),f(E)})})}function p(){}return pt.exports=u,pt.exports.loadPlugin=l,pt.exports}var Li;function Au(){if(Li)return ut.exports;Li=1;const t=oo(),e=so().EventEmitter,n=Gr().inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:r,AVV_ERR_CALLBACK_NOT_FN:i,AVV_ERR_PLUGIN_NOT_VALID:o,AVV_ERR_ROOT_PLG_BOOTED:s,AVV_ERR_READY_TIMEOUT:a}=go(),u=gu(),c=Tu(),l=vo()("avvio"),p=Symbol("kAvvio"),d=Symbol("kThenifyDoNotWrap");function f(m,P,k){const F=P.expose||{},R=F.use||"use",U=F.after||"after",j=F.ready||"ready",Y=F.onClose||"onClose",ae=F.close||"close";if(m[R])throw new r(R);if(m[U])throw new r(U);if(m[j])throw new r(j);m[R]=function(K,se){return k.use(K,se),this},Object.defineProperty(m,"then",{get:g.bind(k)}),m[p]=!0,m[U]=function(K){return typeof K!="function"?k._loadRegistered():(k.after(_(K,this)),this)},m[j]=function(K){if(K&&typeof K!="function")throw new i(j,typeof K);return k.ready(K?_(K,this):void 0)},m[Y]=function(K){if(typeof K!="function")throw new i(Y,typeof K);return k.onClose(L(K,this)),this},m[ae]=function(K){if(K&&typeof K!="function")throw new i(ae,typeof K);return K?(k.close(_(K,this)),this):k.close()}}function h(m,P,k){if(typeof m=="function"&&arguments.length===1&&(k=m,P={},m=null),typeof P=="function"&&(k=P,P={}),P=P||{},!(this instanceof h)){const F=new h(m,P,k);return m&&f(m,P,F),F}P.autostart!==!1&&(P.autostart=!0),m=m||this,this._timeout=Number(P.timeout)||0,this._server=m,this._current=[],this._error=null,this._isOnCloseHandlerKey=Symbol("isOnCloseHandler"),this._lastUsed=null,this.setMaxListeners(0),k&&this.once("start",k),this.started=!1,this.booted=!1,this.pluginTree=new u,this._readyQ=t(this,S,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=C},this._closeQ=t(this,w,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=C},this._doStart=null,this._root=new c(this,T.bind(this),P,!1,0),this._root.once("start",(F,R,U)=>{const j=this.pluginTree.start(null,R,U);this._root.once("loaded",(Y,ae,K)=>{this.pluginTree.stop(j,K)})}),c.loadPlugin.call(this,this._root,F=>{l("root plugin ready");try{this.emit("preReady"),this._root=null}catch(R){F=F||this._error||R}if(F){if(this._error=F,this._readyQ.length()===0)throw F}else this.booted=!0;this._readyQ.resume()})}function T(m,P,k){this._doStart=k,P.autostart&&this.start()}n(h,e),h.prototype.start=function(){return this.started=!0,B.nextTick(this._doStart),this},h.prototype.override=function(m,P,k){return m};function E(m){if(m&&typeof m=="object"&&typeof m.default=="function"&&(m=m.default),!(m&&(typeof m=="function"||typeof m.then=="function")))throw new o(typeof m);return m}h.prototype[p]=!0,h.prototype.use=function(m,P){return this._lastUsed=this._addPlugin(m,P,!1),this},h.prototype._loadRegistered=function(){const m=this._current[0];return!this.started&&!this.booted&&B.nextTick(()=>this._root.q.resume()),m?m.loadedSoFar():Promise.resolve()},Object.defineProperty(h.prototype,"then",{get:g}),h.prototype._addPlugin=function(m,P,k){if(m=E(m),P=P||{},this.booted)throw new s;const F=this._current[0],R=new c(this,m,P,k);if(R.once("start",(U,j,Y)=>{const ae=this.pluginTree.start(F.name,j,Y);R.once("loaded",(K,se,oe)=>{this.pluginTree.stop(ae,oe)})}),F.loaded)throw new Error(R.name,F.name);return F.enqueue(R,U=>{U&&(this._error=U)}),R},h.prototype.after=function(m){if(!m)return this._loadRegistered();this._addPlugin(P.bind(this),{},!0);function P(k,F,R){S.call(this,m,R)}return this},h.prototype.onClose=function(m){if(typeof m!="function")throw new Error("not a function");m[this._isOnCloseHandlerKey]=!0,this._closeQ.unshift(m,P.bind(this));function P(k){k&&(this._error=k)}return this},h.prototype.close=function(m){let P;if(m){if(typeof m!="function")throw new i("close",typeof m)}else P=new Promise(function(k,F){m=function(R){if(R)return F(R);k()}});return this.ready(()=>{this._error=null,this._closeQ.push(m),B.nextTick(this._closeQ.resume.bind(this._closeQ))}),P},h.prototype.ready=function(m){if(m){if(typeof m!="function")throw new i("ready",typeof m);this._readyQ.push(m),queueMicrotask(this.start.bind(this));return}return new Promise((P,k)=>{this._readyQ.push(R),this.start();const F=this._current[0].server;function R(U,j,Y){U?k(U):P(F),B.nextTick(Y)}})},h.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()},h.prototype.toJSON=function(){return this.pluginTree.toJSON()};function C(){}function g(){if(this.booted){l("thenify returning null because we are already booted");return}if(this[d]){this[d]=!1;return}return l("thenify"),(m,P)=>this._loadRegistered().then(()=>(this[d]=!0,m(this._server)),P)}function S(m,P){const k=this._server,F=this._error;let R;if(this._error=null,m.length===0)this._error=F,R=m(),R&&!R[p]&&typeof R.then=="function"?R.then(()=>B.nextTick(P),U=>B.nextTick(P,U)):B.nextTick(P);else if(m.length===1)R=m(F),R&&!R[p]&&typeof R.then=="function"?R.then(()=>B.nextTick(P),U=>B.nextTick(P,U)):B.nextTick(P);else if(this._timeout===0){const U=j=>{this._error=j,P(this._error)};m.length===2?m(F,U):m(F,k,U)}else y.call(this,m,F,k,P)}function y(m,P,k,F){const R=m.name;l("setting up ready timeout",R,this._timeout);let U=setTimeout(()=>{l("timed out",R),U=null;const Y=new a(R);Y.fn=m,this._error=Y,F(Y)},this._timeout);m.length===2?m(P,j.bind(this)):m(P,k,j.bind(this));function j(Y){U&&(clearTimeout(U),this._error=Y,F(this._error))}}function w(m,P){const k=this._server,F=m[this._isOnCloseHandlerKey];if(m.length===0||m.length===1){let R;F?R=m(k):R=m(this._error),R&&typeof R.then=="function"?(l("resolving close/onClose promise"),R.then(()=>B.nextTick(P),U=>B.nextTick(P,U))):B.nextTick(P)}else m.length===2?m(F?k:this._error,P):F?m(k,P):m(this._error,k,P)}function L(m,P){return k.bind(P);function k(F,R){let U;m.length===0?(U=m(),U&&U.then?U.then(function(){B.nextTick(R)},R):B.nextTick(R)):m.length===1?(U=m(this),U&&U.then?U.then(function(){B.nextTick(R)},R):B.nextTick(R)):m(this,R)}}function _(m,P){return k.bind(P);function k(F,R){let U;m?m.length===0?(U=m(),U&&U.then?U.then(function(){B.nextTick(R,F)},R):B.nextTick(R,F)):m.length===1?(U=m(F),U&&U.then?U.then(function(){B.nextTick(R)},R):B.nextTick(R)):m.length===2?m(F,R):m(F,this,R):B.nextTick(R)}}return ut.exports=h,ut.exports.express=function(m){return h(m,{expose:{use:"load"}})},ut.exports}var Su=Au();const Eu=io(Su);(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 n=!!(window.performance&&window.performance.now);window.requestAnimationFrame=function(r){const i=n?window.performance.now():new Date().getTime(),o=Math.max(0,16-(i-e)),s=window.setTimeout(function(){r(i+o)},o);return e=i+o,s},window.cancelAnimationFrame=clearTimeout}})();function wu(t,e=!0,n=!0,r={friendsTab:"enabled"}){const i=e?"https://grpc-sdk.streamlayer.io:443":"https://grpc-sdk.next.streamlayer.io:443",o=e?"https://grpc.streamlayer.io:443":"https://grpc.next.streamlayer.io:443",s=Eu(Object.create({}),{autostart:!1});return s.use(qs,{hideFriends:r.hideFriends,skipOnboarding:r.skipOnboarding,betPack:r.betPack,friendsTab:r.friendsTab,theme:r.theme,themeMode:r.themeMode}),s.use(Ls,{onDeepLinkHandled:r?.onDeepLinkHandled}),s.use(Us,{videoPlayerController:r?.videoPlayerController}),s.use(xs,{onContentActivate:r?.onContentActivate,withAd:r?.withAd,withAdNotification:r?.withAdNotification}),s.use(Yo,{sdkKey:t,host:i,analyticsHost:o,version:r?.version,webOS:r?.webOS}),s.use(ts),s.use(Fs),r?.gamification!==!1&&(s.use(Ys),s.use(Es),s.use(ea)),s.use(_a),s.use(Sa),s.after((a,u,c)=>{if(a)throw a;u.ready(),c()}),n&&s.after(async(a,u,c)=>{if(a)throw a;await u.sdk.initializeApp(),c()}),s.onClose(()=>{console.log("close StreamLayer instance")}),s}exports.StreamLayer=wu;exports.getDefaultExportFromCjs=io;
|
package/package.json
CHANGED
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"avvio": "=8.2.1",
|
|
27
27
|
"tslib": "^2.7.0",
|
|
28
|
-
"@streamlayer/feature-polymarket": "^0.2.
|
|
29
|
-
"@streamlayer/feature-
|
|
30
|
-
"@streamlayer/feature-
|
|
31
|
-
"@streamlayer/sdk-web-analytics": "^1.16.
|
|
32
|
-
"@streamlayer/sdk-web-api": "^1.16.
|
|
33
|
-
"@streamlayer/sdk-web-core": "^1.21.
|
|
34
|
-
"@streamlayer/sdk-web-features": "^1.0.
|
|
35
|
-
"@streamlayer/sdk-web-interfaces": "^1.9.
|
|
36
|
-
"@streamlayer/sdk-web-logger": "^1.0.
|
|
37
|
-
"@streamlayer/sdk-web-notifications": "^1.3.
|
|
38
|
-
"@streamlayer/sdk-web-storage": "^1.0.
|
|
39
|
-
"@streamlayer/sdk-web-types": "^1.17.
|
|
28
|
+
"@streamlayer/feature-polymarket": "^0.2.8",
|
|
29
|
+
"@streamlayer/feature-gamification": "^1.26.2",
|
|
30
|
+
"@streamlayer/feature-advertisement": "^0.2.8",
|
|
31
|
+
"@streamlayer/sdk-web-analytics": "^1.16.8",
|
|
32
|
+
"@streamlayer/sdk-web-api": "^1.16.8",
|
|
33
|
+
"@streamlayer/sdk-web-core": "^1.21.8",
|
|
34
|
+
"@streamlayer/sdk-web-features": "^1.0.110",
|
|
35
|
+
"@streamlayer/sdk-web-interfaces": "^1.9.16",
|
|
36
|
+
"@streamlayer/sdk-web-logger": "^1.0.110",
|
|
37
|
+
"@streamlayer/sdk-web-notifications": "^1.3.72",
|
|
38
|
+
"@streamlayer/sdk-web-storage": "^1.0.110",
|
|
39
|
+
"@streamlayer/sdk-web-types": "^1.17.8"
|
|
40
40
|
},
|
|
41
|
-
"version": "1.18.
|
|
41
|
+
"version": "1.18.8",
|
|
42
42
|
"type": "module",
|
|
43
43
|
"main": "./src/index.js",
|
|
44
44
|
"typings": "./src/index.d.ts"
|