@streamlayer/sdk-web 0.30.0 → 0.30.1
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 +11 -10
- package/lib/es/index.js +2280 -2215
- package/package.json +7 -7
package/lib/cjs/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("@streamlayer/sl-eslib/interactive/interactive.common_pb");require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb");const Te=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),Oe=require("nanostores");require("@nanostores/logger");require("microdiff");const lt=require("@connectrpc/connect"),qn=require("@connectrpc/connect-web"),Qn=require("@nanostores/query"),Gn=require("@streamlayer/sl-eslib/sports/events/events_connect"),pt=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),Hr=require("@streamlayer/sl-eslib/users/users_connect"),zn=require("pino"),Fe=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),Jr=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect");require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb");const Kn=require("@streamlayer/sl-eslib/shortLinks/linksClient_connect");function Wn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Yr={exports:{}},Y=Yr.exports={},pe,ye;function Xt(){throw new Error("setTimeout has not been defined")}function Zt(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?pe=setTimeout:pe=Xt}catch{pe=Xt}try{typeof clearTimeout=="function"?ye=clearTimeout:ye=Zt}catch{ye=Zt}})();function Xr(t){if(pe===setTimeout)return setTimeout(t,0);if((pe===Xt||!pe)&&setTimeout)return pe=setTimeout,setTimeout(t,0);try{return pe(t,0)}catch{try{return pe.call(null,t,0)}catch{return pe.call(this,t,0)}}}function Hn(t){if(ye===clearTimeout)return clearTimeout(t);if((ye===Zt||!ye)&&clearTimeout)return ye=clearTimeout,clearTimeout(t);try{return ye(t)}catch{try{return ye.call(null,t)}catch{return ye.call(this,t)}}}var _e=[],Ze=!1,je,wt=-1;function Jn(){!Ze||!je||(Ze=!1,je.length?_e=je.concat(_e):wt=-1,_e.length&&Zr())}function Zr(){if(!Ze){var t=Xr(Jn);Ze=!0;for(var e=_e.length;e;){for(je=_e,_e=[];++wt<e;)je&&je[wt].run();wt=-1,e=_e.length}je=null,Ze=!1,Hn(t)}}Y.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];_e.push(new en(t,e)),_e.length===1&&!Ze&&Xr(Zr)};function en(t,e){this.fun=t,this.array=e}en.prototype.run=function(){this.fun.apply(null,this.array)};Y.title="browser";Y.browser=!0;Y.env={};Y.argv=[];Y.version="";Y.versions={};function Ce(){}Y.on=Ce;Y.addListener=Ce;Y.once=Ce;Y.off=Ce;Y.removeListener=Ce;Y.removeAllListeners=Ce;Y.emit=Ce;Y.prependListener=Ce;Y.prependOnceListener=Ce;Y.listeners=function(t){return[]};Y.binding=function(t){throw new Error("process.binding is not supported")};Y.cwd=function(){return"/"};Y.chdir=function(t){throw new Error("process.chdir is not supported")};Y.umask=function(){return 0};var Yn=Yr.exports;const k=Wn(Yn);class Xn{}window.slStore=Object.create(null);class xt{store;name;constructor(e,r){this.store=e,this.name=r}getStore(){return this.store}}const Zn=t=>{const e=Object.keys(t);return Oe.computed(e.map(r=>t[r].getStore()),(...r)=>Object.fromEntries(e.map((o,s)=>[o,r[s]])))};class ft extends xt{getValues=()=>this.getStore().get();getValue=e=>this.getStore().get()[e];setValue=(e,r)=>this.getStore().setKey(e,r);subscribe=(...e)=>this.getStore().subscribe(...e);unsubscribe=()=>this.getStore().off()}const Le=t=>Oe.map(t);var Ae;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(Ae||(Ae={}));const ei={[Te.SdkOverlayType.BETTING]:"betting",[Te.SdkOverlayType.GAMES]:"games",[Te.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[Te.SdkOverlayType.TWITTER]:"twitter"};var et;(function(t){t.Ready="ready",t.Suspended="suspended"})(et||(et={}));class tn{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},o){this.settingsKey=ei[r.type],this.status=Oe.atom(et.Suspended),this.config=new ft(Le(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new ft(Le(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new ft(Le({}),`feature:settings:${this.settingsKey}`),this.source=o}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(et.Ready)};disable=()=>{this.status.set(et.Suspended)};setFeatureConfig=({settings:e,...r})=>{let o;for(o in r)this.config.setValue(o,r[o]);if(e?.overlaySettings?.case!==void 0&&e?.overlaySettings.case===this.settingsKey){const s=e.overlaySettings.value;if(s!==void 0){let u;for(u in s)s[u]!==0&&s[u]!==""&&this.settings.setValue(u,s[u])}}};update=(e,r)=>{this.source===Ae.STREAM&&r===Ae.ORGANIZATION||(this.setFeatureConfig(e),this.source=r)};fireEvent(e){for(const r of this.listeners.values())try{r.onEvent(e)}catch(o){console.error(o)}}}class fe extends xt{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 ne=t=>Oe.atom(t);class me extends xt{atomStore;constructor(e,r,o){super(e,`api:${r}`),this.atomStore=Oe.atom(),o&&e.subscribe(s=>{const u=this.atomStore.get(),f=o(s,u);u!==f&&this.atomStore.set(f)})}getAtomStore=()=>this.atomStore;getValue=async()=>{const e=this.getStore();if(e.value===void 0)throw new Error("no store");return await e.value.promise,e.get().data};getValues=()=>{throw new Error("not implemented")};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()}async function*ti(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now();const o={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(o),yield r}}const ri=()=>t=>async e=>{const r={name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries())},response:{}};try{const o=await t(e);if(r.received_at=Date.now(),r.response.header=Object.fromEntries(o.header.entries()),r.response.trailer=Object.fromEntries(o.trailer.entries()),e.stream){r.request.message=e.message;const s={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...r,stream:!1}};return window.postMessage(s),{...o,message:ti(r,o.message)}}else{r.request.message=e.message,r.response.message=o.message,r.latency=r.received_at-r.sent_at;const s={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};window.postMessage(s)}return o}catch(o){r.received_at=Date.now(),r.request.message=e.message,r.response.trailer={"grpc-status":o.code,"grpc-message":o.rawMessage},r.response.message=o.rawMessage,r.latency=r.received_at-r.sent_at;const s={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};throw window.postMessage(s),o}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));var le;(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"})(le||(le={}));class ni{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,o,s){const u={status:le.Init,ts:new Date,log:[]};this.state=new ft(Le(u),`subscription:${s.name}:state`),this.options={...s,reconnectDelay:s.reconnectDelay??1e3,reconnectMaxDelay:s.reconnectMaxDelay??3e4,reconnectMaxAttempts:s.reconnectMaxAttempts??10,withStore:s.withStore??!1},this.headers=e,this.listeners=new Map,this.params=o,this.method=r,s.withStore&&(this.store=new fe(ne(null),`subscription:${s.name}:store`)),"subscribe"in o&&typeof o.subscribe=="function"&&(this.paramsListener=o.subscribe(f=>{this.state.getValue("status")===le.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(f)}`),this.reconnect())})),this.updateState(le.Ready)}updateState=e=>{this.state.setValue("status",e),this.state.setValue("ts",new Date),this.addStateLog(`status => ${e}`)};addStateLog=e=>{const r=this.state.getStore().get().log;this.state.setValue("log",[...r,`${new Date().toLocaleString()}: ${e}`])};addListener=(e,r)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),!1):(this.listeners.set(e,r),this.addStateLog(`listener '${e}' added`),!0);removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(le.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 o={headers:this.headers.getValues(),signal:this.streamCancel.signal},s=this.method(e,o);for await(const u of s)this.attempt=0,this.onData(u)}catch(o){o instanceof lt.ConnectError&&o.code!=lt.Code.Canceled&&this.onStreamError(o)}})(),this.updateState(le.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(le.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(le.Reconnect);const e=Math.min(this.options.reconnectMaxDelay,Math.pow(2,this.attempt)*this.options.reconnectDelay),r=Math.round(e*(1+Math.random())/2);this.reconnectTimeout=setTimeout(()=>{this.attempt++,this.updateState(le.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${r}ms`),this.connect(),this.reconnectTimeout=void 0},r)}else this.addStateLog("max reconnect attempts reached"),this.disconnect()};getStore=()=>this.store?.getStore();onData=e=>{try{this.addStateLog(`received data => ${JSON.stringify(e)}`),this.store&&this.store.setValue(e);for(const[,r]of this.listeners)r(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(r){this.addStateLog(`error process data => ${r}`)}};onStreamError=e=>{if(this.addStateLog(`error => ${e?JSON.stringify(e):"undefined"}}`),e!==void 0){if(e instanceof lt.ConnectError&&e.code!==lt.Code.Canceled){this.updateState(le.Failed),this.state.setValue("error",e),this.reconnect();return}this.disconnect()}}}class ii{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;nanoquery;host;interceptors=[];$headers;clients;callbackClients;subscriptions;constructor(e){this.host=e,this.$headers=new ft(Le({"sl-device-id":k?.env?.NX_DEVICE_ID||"sdk-web-dev"}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.callbackClients=new Map,this.subscriptions=new Map;const[r,o,s]=Qn.nanoquery();this.nanoquery={createFetcherStore:r,createMutatorStore:o,utils:s},this.transport=qn.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors,useBinaryFormat:!0})}addSubscription=(e,r,o)=>{const s=this.subscriptions.get(r);if(s)return s;const u=new ni(this.$headers,e,r,o);return this.subscriptions.set(r,u),u};removeSubscription=e=>{e.disconnect(),this.subscriptions.delete(e.params)};disconnect=()=>{for(const[e,r]of this.subscriptions)r.disconnect(),this.subscriptions.delete(e)};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(r=>r!==e)};getClient=e=>{const r=e.typeName;if(this.clients.has(r))return this.clients.get(r);const o=lt.createPromiseClient(e,this.transport);return this.clients.set(r,o),o};createPromiseClient=(e,{params:r=[],method:o})=>{const s=this.getClient(e),u=e.methods[o].name,f=[e.typeName,u.charAt(0).toLowerCase()+u.slice(1),...Array.isArray(r)?r:[r]],p=[e.typeName,u.charAt(0).toLowerCase()+u.slice(1)];return{client:s,queryKey:f,queryKeyStr:p.join("")}};createStreamClient=e=>({client:this.getClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,r)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",r)};setHeader=(e,r)=>this.$headers.setValue(e,r);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=r=>o=>{const s=this.$headers.getValues();for(const u in s)o.header.set(u,s[u]);return r(o)};this.interceptors.push(e),this.interceptors.push(ri())}}const oi=(t,e)=>{const{client:r,queryKey:o}=e.createPromiseClient(Gn.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(o,{fetcher:async(s,u,f)=>{if(!f||typeof f!="string")return"";try{return(await r.retrieveEventId({id:f})).data?.id||""}catch{return""}}})},si=(t,e)=>{const{client:r,queryKey:o}=e.createPromiseClient(pt.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(o,{fetcher:async(s,u,f)=>f?(await r.getStream({id:f})).data?.attributes:void 0})},ai=(t,e)=>{const{queryKey:r,client:o}=e.createPromiseClient(Hr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:()=>o.me({})})},ui=t=>{const{client:e}=t.createPromiseClient(Hr.Users,{method:"bypassAuth"});return({userKey:r,schema:o,init:s})=>e.bypassAuth({userKey:r,schema:o,init:s})},ci=(t,e)=>{const{client:r,queryKey:o}=e.createPromiseClient(pt.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(o,{fetcher:async()=>(await r.get({})).data?.attributes})},li=(t,e)=>{const{client:r,queryKey:o}=e.createPromiseClient(pt.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(o,{fetcher:async()=>{const s=await r.getOrganization({});return s.data?{...s.data.attributes,id:s.data.id}:void 0}})},fi=(t,e)=>{const{client:r,queryKey:o}=e.createPromiseClient(pt.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(o,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},di=(t,e,r)=>{t.transport=new ii(e.host),t.sdk.host=t.transport.host,t.transport.setSdkKey(e.sdkKey),t.transport.setHeader("sl-sdk-version",e.version||"-"),r()};class lr{delimiter=":";prefix;constructor(e="main"){this.prefix=`sl-sdk${this.delimiter}${e}`}clear=()=>{for(const e in window.localStorage)e.startsWith(this.prefix)&&window.localStorage.removeItem(e)};generateKey=e=>`${this.prefix}${this.delimiter}${e.join(this.delimiter)}`;write=(...e)=>{const r=e.pop()||"";window.localStorage.setItem(this.generateKey(e),r)};read=(...e)=>{const r=window.localStorage.getItem(this.generateKey(e));return r===null?void 0:r};remove=(...e)=>{window.localStorage.removeItem(this.generateKey(e))}}var Ee;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(Ee||(Ee={}));class Je extends lr{constructor(){super("user")}setSchema=e=>{this.write(Ee.SCHEMA,e)};getSchema=()=>this.read(Ee.SCHEMA);setToken=e=>{this.write(Ee.TOKEN,e)};getToken=()=>this.read(Ee.TOKEN);setExternalToken=e=>{this.write(Ee.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(Ee.EXTERNAL_TOKEN);removeToken=()=>{this.remove(Ee.TOKEN)}}var Ie;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(Ie||(Ie={}));const hi=t=>{const e=new Je,r=new fe(ne(e.getExternalToken()),"userKey"),o=new fe(ne(e.getToken()),"userToken"),s=new me(ai(o.getStore(),t),"user",({data:f,error:p,loading:h},E)=>{if(!p)return f?.data?.id?f.data.id:h===!1?void 0:E}),u=new me(ci(o.getStore(),t),"userSettings");return{userKey:r,userToken:o,user:s,userSettings:u}},pi=t=>{const e=new fe(ne(void 0),"providerStreamId"),r=new me(oi(e.getStore(),t),"slStreamId",s=>s?.data),o=new me(si(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(s=>{(s===""||s===void 0)&&o.getStore().mutate(void 0)}),{providerStreamId:e,slStreamId:r,streamSettings:o}},yi=t=>{const e=new fe(ne(void 0),"enabled"),r=new fe(ne(Ie.DISABLED),"status"),o=new me(li(e.getStore(),t),"organizationSettings",p=>p?.data?.id),s=new me(fi(o.getAtomStore(),t),"organizationAdvertising"),u=hi(t),f=pi(t);return{enabled:e,status:r,providerStreamId:f.providerStreamId,slStreamId:f.slStreamId,streamSettings:f.streamSettings,user:u.user,userKey:u.userKey,userToken:u.userToken,userSettings:u.userSettings,organizationSettings:o,organizationAdvertising:s}};class gi extends xt{stores;constructor(e){const r=yi(e),o=Zn(r);super(o,"core"),this.stores=r}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=e=>{let r;for(r in this.stores){const o=e[r];r in e&&o!==void 0&&this.stores[r].subscribe(e[r])}};unsubscribe=()=>this.getStore().off()}class mi extends Xn{$coreStore;transport;bypassLogin;constructor(e,r){super(),this.$coreStore=e,this.transport=r,this.bypassLogin=ui(this.transport),this.connect()}me=async()=>(this.$coreStore.getValues().user.invalidate(),(await this.$coreStore.getValues().user.getValue())?.data);login=async(e,r)=>{this.$coreStore.getValues().userKey.setValue(r);const o=await this.bypassLogin({schema:e,userKey:r,init:!1}),s=o.meta?.jwt,u=o.data?.id;if(!s||!u)throw new Error("internal: token missing");return this.$coreStore.getValues().user.getStore().mutate(o),this.saveUser(s,u),s};isAuthenticated=()=>this.me();logout=()=>{this.$coreStore.getValues().user.setValue(),this.$coreStore.getValues().userKey.setValue(),this.$coreStore.getValues().userToken.setValue(),this.transport.setAuth("",""),new Je().clear()};softLogout=()=>{const e=new Je;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=()=>{const e=new Je,r=e.getToken(),o=e.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(o),r)return this.saveUser(r,""),this.me().then(s=>{if(s?.id){const u=s.id;this.saveUser(r,u)}});if(o&&!r){const s=e.getSchema();s&&o&&this.login(s,o).catch(()=>{this.logout()})}};saveUser=(e,r)=>{this.transport.setAuth(e,r),this.$coreStore.getValues().userToken.setValue(e),new Je().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async r=>{try{return await e(r)}catch(o){throw o.code&&(o.code===7||o.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),o}})}}const ct=new Je,wi=(t,e,r)=>{t.auth=new mi(t.store,t.transport),t.stores.status.listen(o=>{o===Ie.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(o,s)=>{if(!(ct.getSchema()===o&&ct.getExternalToken()===s&&t.transport.getHeader("authorization")))try{await t.auth.login(o,s),ct.setSchema(o),ct.setExternalToken(s)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),ct.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},bi=(t,e,r)=>{t.store=new gi(t.transport),t.stores=t.store.getValues(),t.sdk.enabled=t.stores.enabled.getStore(),t.sdk.status=t.stores.status.getStore(),t.sdk.sdkStore=Object.fromEntries(Object.entries(t.stores).map(([o,s])=>[o,s.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},r()},vi=(t,e,r)=>{t.sdk=Object.create(null),t.sdk.initializeApp=async o=>{if(t.contextConfig=o,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(Ie.INITIALIZATION);try{const s=await t.stores.organizationSettings.getValue();return s?(t.stores.status.setValue(Ie.READY),{enabled:!!s}):(t.stores.status.setValue(Ie.FAILED),{err:"failed"})}catch(s){return t.stores.enabled.setValue(),t.stores.status.setValue(Ie.FAILED),{err:`${s}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(Ie.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=o=>{t.stores.providerStreamId.setValue(o)},r()},Si=zn.pino({level:"trace",enabled:!1,browser:{write:t=>{console.log(t)}}}),rn=(t,e)=>Si.child({name:t},e),Ei=(t,e,r)=>{const{client:o,queryKey:s}=r.createPromiseClient(Jr.Leaderboard,{method:"summary",params:[t,e]});return r.nanoquery.createFetcherStore(s,{fetcher:async(u,f,p,h)=>(await o.summary({eventId:p,userId:h})).data?.attributes})},Ai=t=>{const{client:e}=t.createPromiseClient(Jr.Leaderboard,{method:"list"});return r=>e.list(r)},Ii=(t,e)=>{const{client:r,queryKey:o}=e.createPromiseClient(Fe.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(o,{fetcher:async(s,u,f)=>(await r.get({eventId:f})).data?.attributes})},Ti=(t,e)=>{const{client:r,queryKey:o}=e.createPromiseClient(Fe.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(o,{fetcher:async(s,u,f)=>f?(await r.syncQuestion({filter:{eventId:f}})).data?.attributes:void 0})},_i=(t,e)=>{const{client:r}=e.createStreamClient(Fe.Feed),o=Oe.atom({eventId:t.get()||"",feedId:""});return t.subscribe((u="")=>{o.set({eventId:u,feedId:""})}),e.addSubscription(r.subscription,o,{name:"feedSubscription"})},Oi=(t,e)=>{const{client:r}=e.createStreamClient(Fe.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},nn=async(t,e)=>{const{client:r}=e.createPromiseClient(Fe.Feed,{method:"questionByUser",params:[t]});return(await r.questionByUser({questionId:t})).data?.attributes?.question},Fi=(t,e)=>{const{client:r,queryKey:o}=e.createPromiseClient(Fe.Feed,{method:"list",params:[t]});return e.nanoquery.createFetcherStore(o,{fetcher:async(s,u,f)=>f?(await r.list({eventId:f,filter:{statuses:[re.QuestionStatus.ACTIVE,re.QuestionStatus.RESOLVED]}})).data:[]})};var on={},Bt={};Bt.byteLength=Bi;Bt.toByteArray=Pi;Bt.fromByteArray=Ni;var ge=[],oe=[],Ci=typeof Uint8Array<"u"?Uint8Array:Array,$t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var ze=0,xi=$t.length;ze<xi;++ze)ge[ze]=$t[ze],oe[$t.charCodeAt(ze)]=ze;oe[45]=62;oe[95]=63;function sn(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var o=r===e?0:4-r%4;return[r,o]}function Bi(t){var e=sn(t),r=e[0],o=e[1];return(r+o)*3/4-o}function ki(t,e,r){return(e+r)*3/4-r}function Pi(t){var e,r=sn(t),o=r[0],s=r[1],u=new Ci(ki(t,o,s)),f=0,p=s>0?o-4:o,h;for(h=0;h<p;h+=4)e=oe[t.charCodeAt(h)]<<18|oe[t.charCodeAt(h+1)]<<12|oe[t.charCodeAt(h+2)]<<6|oe[t.charCodeAt(h+3)],u[f++]=e>>16&255,u[f++]=e>>8&255,u[f++]=e&255;return s===2&&(e=oe[t.charCodeAt(h)]<<2|oe[t.charCodeAt(h+1)]>>4,u[f++]=e&255),s===1&&(e=oe[t.charCodeAt(h)]<<10|oe[t.charCodeAt(h+1)]<<4|oe[t.charCodeAt(h+2)]>>2,u[f++]=e>>8&255,u[f++]=e&255),u}function Li(t){return ge[t>>18&63]+ge[t>>12&63]+ge[t>>6&63]+ge[t&63]}function Ri(t,e,r){for(var o,s=[],u=e;u<r;u+=3)o=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(t[u+2]&255),s.push(Li(o));return s.join("")}function Ni(t){for(var e,r=t.length,o=r%3,s=[],u=16383,f=0,p=r-o;f<p;f+=u)s.push(Ri(t,f,f+u>p?p:f+u));return o===1?(e=t[r-1],s.push(ge[e>>2]+ge[e<<4&63]+"==")):o===2&&(e=(t[r-2]<<8)+t[r-1],s.push(ge[e>>10]+ge[e>>4&63]+ge[e<<2&63]+"=")),s.join("")}var fr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */fr.read=function(t,e,r,o,s){var u,f,p=s*8-o-1,h=(1<<p)-1,E=h>>1,c=-7,m=r?s-1:0,A=r?-1:1,T=t[e+m];for(m+=A,u=T&(1<<-c)-1,T>>=-c,c+=p;c>0;u=u*256+t[e+m],m+=A,c-=8);for(f=u&(1<<-c)-1,u>>=-c,c+=o;c>0;f=f*256+t[e+m],m+=A,c-=8);if(u===0)u=1-E;else{if(u===h)return f?NaN:(T?-1:1)*(1/0);f=f+Math.pow(2,o),u=u-E}return(T?-1:1)*f*Math.pow(2,u-o)};fr.write=function(t,e,r,o,s,u){var f,p,h,E=u*8-s-1,c=(1<<E)-1,m=c>>1,A=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=o?0:u-1,B=o?1:-1,N=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,f=c):(f=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-f))<1&&(f--,h*=2),f+m>=1?e+=A/h:e+=A*Math.pow(2,1-m),e*h>=2&&(f++,h/=2),f+m>=c?(p=0,f=c):f+m>=1?(p=(e*h-1)*Math.pow(2,s),f=f+m):(p=e*Math.pow(2,m-1)*Math.pow(2,s),f=0));s>=8;t[r+T]=p&255,T+=B,p/=256,s-=8);for(f=f<<s|p,E+=s;E>0;t[r+T]=f&255,T+=B,f/=256,E-=8);t[r+T-B]|=N*128};/*!
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("@streamlayer/sl-eslib/interactive/interactive.common_pb");require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb");const Te=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),_e=require("nanostores");require("@nanostores/logger");require("microdiff");const Ye=require("@connectrpc/connect"),Cr=require("@connectrpc/connect-web"),Gn=require("@nanostores/query"),zn=require("@streamlayer/sl-eslib/sports/events/events_connect"),yt=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),fr=require("@streamlayer/sl-eslib/users/users_connect"),Kn=require("pino"),Fe=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),Xr=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect");require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb");const Wn=require("@streamlayer/sl-eslib/shortLinks/linksClient_connect");function Hn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Zr={exports:{}},Y=Zr.exports={},ye,ge;function Zt(){throw new Error("setTimeout has not been defined")}function er(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?ye=setTimeout:ye=Zt}catch{ye=Zt}try{typeof clearTimeout=="function"?ge=clearTimeout:ge=er}catch{ge=er}})();function en(t){if(ye===setTimeout)return setTimeout(t,0);if((ye===Zt||!ye)&&setTimeout)return ye=setTimeout,setTimeout(t,0);try{return ye(t,0)}catch{try{return ye.call(null,t,0)}catch{return ye.call(this,t,0)}}}function Jn(t){if(ge===clearTimeout)return clearTimeout(t);if((ge===er||!ge)&&clearTimeout)return ge=clearTimeout,clearTimeout(t);try{return ge(t)}catch{try{return ge.call(null,t)}catch{return ge.call(this,t)}}}var Oe=[],tt=!1,je,bt=-1;function Yn(){!tt||!je||(tt=!1,je.length?Oe=je.concat(Oe):bt=-1,Oe.length&&tn())}function tn(){if(!tt){var t=en(Yn);tt=!0;for(var e=Oe.length;e;){for(je=Oe,Oe=[];++bt<e;)je&&je[bt].run();bt=-1,e=Oe.length}je=null,tt=!1,Jn(t)}}Y.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];Oe.push(new rn(t,e)),Oe.length===1&&!tt&&en(tn)};function rn(t,e){this.fun=t,this.array=e}rn.prototype.run=function(){this.fun.apply(null,this.array)};Y.title="browser";Y.browser=!0;Y.env={};Y.argv=[];Y.version="";Y.versions={};function Ce(){}Y.on=Ce;Y.addListener=Ce;Y.once=Ce;Y.off=Ce;Y.removeListener=Ce;Y.removeAllListeners=Ce;Y.emit=Ce;Y.prependListener=Ce;Y.prependOnceListener=Ce;Y.listeners=function(t){return[]};Y.binding=function(t){throw new Error("process.binding is not supported")};Y.cwd=function(){return"/"};Y.chdir=function(t){throw new Error("process.chdir is not supported")};Y.umask=function(){return 0};var Xn=Zr.exports;const P=Hn(Xn);class Zn{}window.slStore=Object.create(null);class Bt{store;name;constructor(e,r){this.store=e,this.name=r}getStore(){return this.store}}const ei=t=>{const e=Object.keys(t);return _e.computed(e.map(r=>t[r].getStore()),(...r)=>Object.fromEntries(e.map((i,s)=>[i,r[s]])))};class dt extends Bt{getValues=()=>this.getStore().get();getValue=e=>this.getStore().get()[e];setValue=(e,r)=>this.getStore().setKey(e,r);subscribe=(...e)=>this.getStore().subscribe(...e);unsubscribe=()=>this.getStore().off()}const Le=t=>_e.map(t);var Ee;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(Ee||(Ee={}));const ti={[Te.SdkOverlayType.BETTING]:"betting",[Te.SdkOverlayType.GAMES]:"games",[Te.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[Te.SdkOverlayType.TWITTER]:"twitter"};var rt;(function(t){t.Ready="ready",t.Suspended="suspended"})(rt||(rt={}));class nn{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},i){this.settingsKey=ti[r.type],this.status=_e.atom(rt.Suspended),this.config=new dt(Le(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new dt(Le(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new dt(Le({}),`feature:settings:${this.settingsKey}`),this.source=i}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(rt.Ready)};disable=()=>{this.status.set(rt.Suspended)};setFeatureConfig=({settings:e,...r})=>{let i;for(i in r)this.config.setValue(i,r[i]);if(e?.overlaySettings?.case!==void 0&&e?.overlaySettings.case===this.settingsKey){const s=e.overlaySettings.value;if(s!==void 0){let u;for(u in s)s[u]!==0&&s[u]!==""&&this.settings.setValue(u,s[u])}}};update=(e,r)=>{this.source===Ee.STREAM&&r===Ee.ORGANIZATION||(this.setFeatureConfig(e),this.source=r)};fireEvent(e){for(const r of this.listeners.values())try{r.onEvent(e)}catch(i){console.error(i)}}}class ae extends Bt{getValue=()=>this.getStore().get();getValues(){throw new Error("not implemented")}setValue=e=>this.getStore().set(e);subscribe=e=>this.getStore().subscribe(e);unsubscribe=()=>this.getStore().off();listen(e){return this.getStore().listen(e)}get(){return this.getStore().get()}}const ne=t=>_e.atom(t);class de extends Bt{atomStore;constructor(e,r,i){super(e,`api:${r}`),this.atomStore=_e.atom(),i&&e.subscribe(s=>{const u=this.atomStore.get(),f=i(s,u);u!==f&&this.atomStore.set(f)})}getAtomStore=()=>this.atomStore;getValue=async()=>{const e=this.getStore();if(e.value===void 0)throw new Error("no store");return await e.value.promise,e.get().data};getValues=()=>this.getStore().get();setValue=e=>this.getStore().set({loading:!1,data:e?.data});subscribe=e=>this.getStore().subscribe(e);unsubscribe=()=>{throw new Error("not implemented")};invalidate=()=>{this.store.invalidate()};listen=e=>this.getStore().listen(e);get(){throw new Error("not implemented")}key=()=>this.getStore().key;off=()=>this.getStore().off()}async function*ri(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now();const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(i),yield r}}const ni=()=>t=>async e=>{const r={name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries())},response:{}};try{const i=await t(e);if(r.received_at=Date.now(),r.response.header=Object.fromEntries(i.header.entries()),r.response.trailer=Object.fromEntries(i.trailer.entries()),e.stream){r.request.message=e.message;const s={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...r,stream:!1}};return window.postMessage(s),{...i,message:ri(r,i.message)}}else{r.request.message=e.message,r.response.message=i.message,r.latency=r.received_at-r.sent_at;const s={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};window.postMessage(s)}return i}catch(i){r.received_at=Date.now(),r.request.message=e.message,r.response.trailer={"grpc-status":i.code,"grpc-message":i.rawMessage},r.response.message=i.rawMessage,r.latency=r.received_at-r.sent_at;const s={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};throw window.postMessage(s),i}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));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={}));class ii{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,i,s){const u={status:fe.Init,ts:new Date,log:[]};this.state=new dt(Le(u),`subscription:${s.name}:state`),this.options={...s,reconnectDelay:s.reconnectDelay??1e3,reconnectMaxDelay:s.reconnectMaxDelay??3e4,reconnectMaxAttempts:s.reconnectMaxAttempts??10,withStore:s.withStore??!1},this.headers=e,this.listeners=new Map,this.params=i,this.method=r,s.withStore&&(this.store=new ae(ne(null),`subscription:${s.name}:store`)),"subscribe"in i&&typeof i.subscribe=="function"&&(this.paramsListener=i.subscribe(f=>{this.state.getValue("status")===fe.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(f)}`),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 r=this.state.getStore().get().log,i=`${this.options.name} ${new Date().toISOString()}: ${e}`;r.push(i),this.state.setValue("log",r),window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
|
|
2
|
+
`+i)};addListener=(e,r)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),!1):(this.listeners.set(e,r),this.addStateLog(`listener '${e}' added`),!0);removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(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 i={headers:this.headers.getValues(),signal:this.streamCancel.signal},s=this.method(e,i);for await(const u of s)this.attempt=0,this.onData(u)}catch(i){i instanceof Ye.ConnectError&&i.code!=Ye.Code.Canceled&&this.onStreamError(i)}})(),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),r=Math.round(e*(1+Math.random())/2);this.reconnectTimeout=setTimeout(()=>{this.attempt++,this.updateState(fe.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${r}ms`),this.connect(),this.reconnectTimeout=void 0},r)}else this.addStateLog("max reconnect attempts reached"),this.disconnect()};getStore=()=>this.store?.getStore();onData=e=>{try{this.addStateLog(`received data => ${JSON.stringify(e)}`),this.store&&this.store.setValue(e);for(const[,r]of this.listeners)r(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(r){this.addStateLog(`error process data => ${r}`)}};onStreamError=e=>{if(this.addStateLog(`error => ${e?JSON.stringify(e):"undefined"}}`),e!==void 0){if(e instanceof Ye.ConnectError&&e.code!==Ye.Code.Canceled){this.updateState(fe.Failed),this.state.setValue("error",e),this.reconnect();return}this.disconnect()}}}class oi{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;interceptors=[];$headers;clients;callbackClients;subscriptions;constructor(e){this.host=e,this.$headers=new dt(Le({"sl-device-id":P?.env?.NX_DEVICE_ID||"sdk-web-dev"}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.callbackClients=new Map,this.subscriptions=new Map;const[r,i,s]=Gn.nanoquery();this.nanoquery={createFetcherStore:r,createMutatorStore:i,utils:s},this.transport=Cr.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:3e4,interceptors:this.interceptors,useBinaryFormat:!0}),this.streamTransport=Cr.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors,useBinaryFormat:!0})}addSubscription=(e,r,i)=>{const s=this.subscriptions.get(r);if(s)return s;const u=new ii(this.$headers,e,r,i);return this.subscriptions.set(r,u),u};removeSubscription=e=>{e.disconnect(),this.subscriptions.delete(e.params)};disconnect=()=>{for(const[e,r]of this.subscriptions)r.disconnect(),this.subscriptions.delete(e)};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(r=>r!==e)};getClient=e=>{const r=e.typeName;if(this.clients.has(r))return this.clients.get(r);const i=Ye.createPromiseClient(e,this.transport);return this.clients.set(r,i),i};getStreamClient=e=>{const r=`stream-${e.typeName}`;if(this.clients.has(r))return this.clients.get(r);const i=Ye.createPromiseClient(e,this.streamTransport);return this.clients.set(r,i),i};createPromiseClient=(e,{params:r=[],method:i})=>{const s=this.getClient(e),u=e.methods[i].name,f=[e.typeName,u.charAt(0).toLowerCase()+u.slice(1),...Array.isArray(r)?r:[r]],p=[e.typeName,u.charAt(0).toLowerCase()+u.slice(1)];return{client:s,queryKey:f,queryKeyStr:p.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,r)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",r)};setHeader=(e,r)=>this.$headers.setValue(e,r);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=r=>i=>{const s=this.$headers.getValues();for(const u in s)i.header.set(u,s[u]);return r(i)};this.interceptors.push(e),this.interceptors.push(ni())}}const si=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(zn.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,f)=>{if(!f||typeof f!="string")return"";try{return(await r.retrieveEventId({id:f})).data?.id||""}catch{return""}}})},ai=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(yt.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,f)=>f?(await r.getStream({id:f})).data?.attributes:void 0})},ui=(t,e)=>{const{queryKey:r,client:i}=e.createPromiseClient(fr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:()=>i.me({})})},ci=t=>{const{client:e}=t.createPromiseClient(fr.Users,{method:"bypassAuth"});return({userKey:r,schema:i,init:s})=>e.bypassAuth({userKey:r,schema:i,init:s})},li=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(yt.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>(await r.get({})).data?.attributes})},fi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(yt.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>{const s=await r.getOrganization({});return s.data?{...s.data.attributes,id:s.data.id}:void 0}})},di=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(yt.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},hi=(t,e,r)=>{t.transport=new oi(e.host),t.sdk.host=t.transport.host,t.transport.setSdkKey(e.sdkKey),t.transport.setHeader("sl-sdk-version",e.version||"-"),r()};class dr{delimiter=":";prefix;constructor(e="main"){this.prefix=`sl-sdk${this.delimiter}${e}`}clear=()=>{for(const e in window.localStorage)e.startsWith(this.prefix)&&window.localStorage.removeItem(e)};generateKey=e=>`${this.prefix}${this.delimiter}${e.join(this.delimiter)}`;write=(...e)=>{const r=e.pop()||"";window.localStorage.setItem(this.generateKey(e),r)};read=(...e)=>{const r=window.localStorage.getItem(this.generateKey(e));return r===null?void 0:r};remove=(...e)=>{window.localStorage.removeItem(this.generateKey(e))}}var Ae;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(Ae||(Ae={}));class Xe extends dr{constructor(){super("user")}setSchema=e=>{this.write(Ae.SCHEMA,e)};getSchema=()=>this.read(Ae.SCHEMA);setToken=e=>{this.write(Ae.TOKEN,e)};getToken=()=>this.read(Ae.TOKEN);setExternalToken=e=>{this.write(Ae.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(Ae.EXTERNAL_TOKEN);removeToken=()=>{this.remove(Ae.TOKEN)}}var Ie;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(Ie||(Ie={}));const pi=t=>{const e=new Xe,r=new ae(ne(e.getExternalToken()),"userKey"),i=new ae(ne(e.getToken()),"userToken"),s=new de(ui(i.getStore(),t),"user",({data:f,error:p,loading:h},m)=>{if(!p)return f?.data?.id?f.data.id:h===!1?void 0:m}),u=new de(li(i.getStore(),t),"userSettings");return{userKey:r,userToken:i,user:s,userSettings:u}},yi=t=>{const e=new ae(ne(void 0),"providerStreamId"),r=new de(si(e.getStore(),t),"slStreamId",s=>s?.data),i=new de(ai(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(s=>{(s===""||s===void 0)&&i.getStore().mutate(void 0)}),{providerStreamId:e,slStreamId:r,streamSettings:i}},gi=t=>{const e=new ae(ne(void 0),"enabled"),r=new ae(ne(Ie.DISABLED),"status"),i=new de(fi(e.getStore(),t),"organizationSettings",p=>p?.data?.id),s=new de(di(i.getAtomStore(),t),"organizationAdvertising"),u=pi(t),f=yi(t);return{enabled:e,status:r,providerStreamId:f.providerStreamId,slStreamId:f.slStreamId,streamSettings:f.streamSettings,user:u.user,userKey:u.userKey,userToken:u.userToken,userSettings:u.userSettings,organizationSettings:i,organizationAdvertising:s}};class mi extends Bt{stores;constructor(e){const r=gi(e),i=ei(r);super(i,"core"),this.stores=r}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=e=>{let r;for(r in this.stores){const i=e[r];r in e&&i!==void 0&&this.stores[r].subscribe(e[r])}};unsubscribe=()=>this.getStore().off()}class wi extends Zn{$coreStore;transport;bypassLogin;constructor(e,r){super(),this.$coreStore=e,this.transport=r,this.bypassLogin=ci(this.transport),this.connect()}me=async()=>(this.$coreStore.getValues().user.invalidate(),(await this.$coreStore.getValues().user.getValue())?.data);login=async(e,r)=>{this.$coreStore.getValues().userKey.setValue(r);const i=await this.bypassLogin({schema:e,userKey:r,init:!1}),s=i.meta?.jwt,u=i.data?.id;if(!s||!u)throw new Error("internal: token missing");return this.$coreStore.getValues().user.getStore().mutate(i),this.saveUser(s,u),s};isAuthenticated=()=>this.me();logout=()=>{this.$coreStore.getValues().user.setValue(),this.$coreStore.getValues().userKey.setValue(),this.$coreStore.getValues().userToken.setValue(),this.transport.setAuth("",""),new Xe().clear()};softLogout=()=>{const e=new Xe;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=()=>{const e=new Xe,r=e.getToken(),i=e.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(i),r)return this.saveUser(r,""),this.me().then(s=>{if(s?.id){const u=s.id;this.saveUser(r,u)}});if(i&&!r){const s=e.getSchema();s&&i&&this.login(s,i).catch(()=>{this.logout()})}};saveUser=(e,r)=>{this.transport.setAuth(e,r),this.$coreStore.getValues().userToken.setValue(e),new Xe().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async r=>{try{return await e(r)}catch(i){throw i.code&&(i.code===7||i.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),i}})}}const ft=new Xe,bi=(t,e,r)=>{t.auth=new wi(t.store,t.transport),t.stores.status.listen(i=>{i===Ie.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(i,s)=>{if(!(ft.getSchema()===i&&ft.getExternalToken()===s&&t.transport.getHeader("authorization")))try{await t.auth.login(i,s),ft.setSchema(i),ft.setExternalToken(s)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),ft.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},vi=(t,e,r)=>{t.store=new mi(t.transport),t.stores=t.store.getValues(),t.sdk.enabled=t.stores.enabled.getStore(),t.sdk.status=t.stores.status.getStore(),t.sdk.sdkStore=Object.fromEntries(Object.entries(t.stores).map(([i,s])=>[i,s.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},r()},Si=(t,e,r)=>{t.sdk=Object.create(null),t.sdk.initializeApp=async i=>{if(t.contextConfig=i,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(Ie.INITIALIZATION);try{const s=await t.stores.organizationSettings.getValue();return s?(t.stores.status.setValue(Ie.READY),{enabled:!!s}):(t.stores.status.setValue(Ie.FAILED),{err:"failed"})}catch(s){return t.stores.enabled.setValue(),t.stores.status.setValue(Ie.FAILED),{err:`${s}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(Ie.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=i=>{t.stores.providerStreamId.setValue(i)},r()},Ai=Kn.pino({level:"trace",enabled:!1,browser:{write:t=>{console.log(t)}}}),on=(t,e)=>Ai.child({name:t},e),Ei=(t,e,r)=>{const{client:i,queryKey:s}=r.createPromiseClient(Xr.Leaderboard,{method:"summary",params:[t,e]});return r.nanoquery.createFetcherStore(s,{fetcher:async(u,f,p,h)=>(await i.summary({eventId:p,userId:h})).data?.attributes})},Ii=t=>{const{client:e}=t.createPromiseClient(Xr.Leaderboard,{method:"list"});return r=>e.list(r)},Ti=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(fr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,f)=>f?(await r.getFriends({})).data:[]})},Oi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(Fe.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,f)=>(await r.get({eventId:f})).data?.attributes})},_i=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(Fe.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,f)=>f?(await r.syncQuestion({filter:{eventId:f}})).data?.attributes:void 0})},Fi=(t,e)=>{const{client:r}=e.createStreamClient(Fe.Feed),i=_e.atom({eventId:t.get()||"",feedId:""});return t.subscribe((u="")=>{i.set({eventId:u,feedId:""})}),e.addSubscription(r.subscription,i,{name:"feedSubscription"})},Ci=(t,e)=>{const{client:r}=e.createStreamClient(Fe.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},sn=async(t,e)=>{const{client:r}=e.createPromiseClient(Fe.Feed,{method:"questionByUser",params:[t]});return(await r.questionByUser({questionId:t})).data?.attributes?.question},xi=(t,e,r)=>{const{client:i,queryKey:s}=r.createPromiseClient(Fe.Feed,{method:"list",params:[t,e]});return r.nanoquery.createFetcherStore(s,{fetcher:async(u,f,p,h)=>p?(await i.list({eventId:p,filter:{types:h===Ve.ALLOWED?[]:[re.QuestionType.FACTOID,re.QuestionType.PROMOTION,re.QuestionType.TWEET],statuses:[re.QuestionStatus.ACTIVE,re.QuestionStatus.RESOLVED]}})).data:[]})};var an={},kt={};kt.byteLength=Pi;kt.toByteArray=Ri;kt.fromByteArray=$i;var me=[],oe=[],Bi=typeof Uint8Array<"u"?Uint8Array:Array,$t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Ke=0,ki=$t.length;Ke<ki;++Ke)me[Ke]=$t[Ke],oe[$t.charCodeAt(Ke)]=Ke;oe[45]=62;oe[95]=63;function un(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var i=r===e?0:4-r%4;return[r,i]}function Pi(t){var e=un(t),r=e[0],i=e[1];return(r+i)*3/4-i}function Li(t,e,r){return(e+r)*3/4-r}function Ri(t){var e,r=un(t),i=r[0],s=r[1],u=new Bi(Li(t,i,s)),f=0,p=s>0?i-4:i,h;for(h=0;h<p;h+=4)e=oe[t.charCodeAt(h)]<<18|oe[t.charCodeAt(h+1)]<<12|oe[t.charCodeAt(h+2)]<<6|oe[t.charCodeAt(h+3)],u[f++]=e>>16&255,u[f++]=e>>8&255,u[f++]=e&255;return s===2&&(e=oe[t.charCodeAt(h)]<<2|oe[t.charCodeAt(h+1)]>>4,u[f++]=e&255),s===1&&(e=oe[t.charCodeAt(h)]<<10|oe[t.charCodeAt(h+1)]<<4|oe[t.charCodeAt(h+2)]>>2,u[f++]=e>>8&255,u[f++]=e&255),u}function Ni(t){return me[t>>18&63]+me[t>>12&63]+me[t>>6&63]+me[t&63]}function Di(t,e,r){for(var i,s=[],u=e;u<r;u+=3)i=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(t[u+2]&255),s.push(Ni(i));return s.join("")}function $i(t){for(var e,r=t.length,i=r%3,s=[],u=16383,f=0,p=r-i;f<p;f+=u)s.push(Di(t,f,f+u>p?p:f+u));return i===1?(e=t[r-1],s.push(me[e>>2]+me[e<<4&63]+"==")):i===2&&(e=(t[r-2]<<8)+t[r-1],s.push(me[e>>10]+me[e>>4&63]+me[e<<2&63]+"=")),s.join("")}var hr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */hr.read=function(t,e,r,i,s){var u,f,p=s*8-i-1,h=(1<<p)-1,m=h>>1,l=-7,w=r?s-1:0,E=r?-1:1,T=t[e+w];for(w+=E,u=T&(1<<-l)-1,T>>=-l,l+=p;l>0;u=u*256+t[e+w],w+=E,l-=8);for(f=u&(1<<-l)-1,u>>=-l,l+=i;l>0;f=f*256+t[e+w],w+=E,l-=8);if(u===0)u=1-m;else{if(u===h)return f?NaN:(T?-1:1)*(1/0);f=f+Math.pow(2,i),u=u-m}return(T?-1:1)*f*Math.pow(2,u-i)};hr.write=function(t,e,r,i,s,u){var f,p,h,m=u*8-s-1,l=(1<<m)-1,w=l>>1,E=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=i?0:u-1,_=i?1:-1,B=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,f=l):(f=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-f))<1&&(f--,h*=2),f+w>=1?e+=E/h:e+=E*Math.pow(2,1-w),e*h>=2&&(f++,h/=2),f+w>=l?(p=0,f=l):f+w>=1?(p=(e*h-1)*Math.pow(2,s),f=f+w):(p=e*Math.pow(2,w-1)*Math.pow(2,s),f=0));s>=8;t[r+T]=p&255,T+=_,p/=256,s-=8);for(f=f<<s|p,m+=s;m>0;t[r+T]=f&255,T+=_,f/=256,m-=8);t[r+T-_]|=B*128};/*!
|
|
2
3
|
* The buffer module from node.js, for the browser.
|
|
3
4
|
*
|
|
4
5
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
6
|
* @license MIT
|
|
6
|
-
*/(function(t){const e=Bt,r=fr,o=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=c,t.SlowBuffer=O,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s;const{Uint8Array:u,ArrayBuffer:f,SharedArrayBuffer:p}=globalThis;c.TYPED_ARRAY_SUPPORT=h(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{const a=new u(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,u.prototype),Object.setPrototypeOf(a,n),a.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function E(a){if(a>s)throw new RangeError('The value "'+a+'" is invalid for option "size"');const n=new u(a);return Object.setPrototypeOf(n,c.prototype),n}function c(a,n,i){if(typeof a=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(a)}return m(a,n,i)}c.poolSize=8192;function m(a,n,i){if(typeof a=="string")return N(a,n);if(f.isView(a))return I(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(he(a,f)||a&&he(a.buffer,f)||typeof p<"u"&&(he(a,p)||a&&he(a.buffer,p)))return F(a,n,i);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=a.valueOf&&a.valueOf();if(l!=null&&l!==a)return c.from(l,n,i);const d=j(a);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return c.from(a[Symbol.toPrimitive]("string"),n,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}c.from=function(a,n,i){return m(a,n,i)},Object.setPrototypeOf(c.prototype,u.prototype),Object.setPrototypeOf(c,u);function A(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function T(a,n,i){return A(a),a<=0?E(a):n!==void 0?typeof i=="string"?E(a).fill(n,i):E(a).fill(n):E(a)}c.alloc=function(a,n,i){return T(a,n,i)};function B(a){return A(a),E(a<0?0:L(a)|0)}c.allocUnsafe=function(a){return B(a)},c.allocUnsafeSlow=function(a){return B(a)};function N(a,n){if((typeof n!="string"||n==="")&&(n="utf8"),!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const i=C(a,n)|0;let l=E(i);const d=l.write(a,n);return d!==i&&(l=l.slice(0,d)),l}function G(a){const n=a.length<0?0:L(a.length)|0,i=E(n);for(let l=0;l<n;l+=1)i[l]=a[l]&255;return i}function I(a){if(he(a,u)){const n=new u(a);return F(n.buffer,n.byteOffset,n.byteLength)}return G(a)}function F(a,n,i){if(n<0||a.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<n+(i||0))throw new RangeError('"length" is outside of buffer bounds');let l;return n===void 0&&i===void 0?l=new u(a):i===void 0?l=new u(a,n):l=new u(a,n,i),Object.setPrototypeOf(l,c.prototype),l}function j(a){if(c.isBuffer(a)){const n=L(a.length)|0,i=E(n);return i.length===0||a.copy(i,0,0,n),i}if(a.length!==void 0)return typeof a.length!="number"||Nt(a.length)?E(0):G(a);if(a.type==="Buffer"&&Array.isArray(a.data))return G(a.data)}function L(a){if(a>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return a|0}function O(a){return+a!=a&&(a=0),c.alloc(+a)}c.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==c.prototype},c.compare=function(n,i){if(he(n,u)&&(n=c.from(n,n.offset,n.byteLength)),he(i,u)&&(i=c.from(i,i.offset,i.byteLength)),!c.isBuffer(n)||!c.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===i)return 0;let l=n.length,d=i.length;for(let y=0,w=Math.min(l,d);y<w;++y)if(n[y]!==i[y]){l=n[y],d=i[y];break}return l<d?-1:d<l?1:0},c.isEncoding=function(n){switch(String(n).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(n,i){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return c.alloc(0);let l;if(i===void 0)for(i=0,l=0;l<n.length;++l)i+=n[l].length;const d=c.allocUnsafe(i);let y=0;for(l=0;l<n.length;++l){let w=n[l];if(he(w,u))y+w.length>d.length?(c.isBuffer(w)||(w=c.from(w)),w.copy(d,y)):u.prototype.set.call(d,w,y);else if(c.isBuffer(w))w.copy(d,y);else throw new TypeError('"list" argument must be an Array of Buffers');y+=w.length}return d};function C(a,n){if(c.isBuffer(a))return a.length;if(f.isView(a)||he(a,f))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);const i=a.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&i===0)return 0;let d=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return ut(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return _r(a).length;default:if(d)return l?-1:ut(a).length;n=(""+n).toLowerCase(),d=!0}}c.byteLength=C;function x(a,n,i){let l=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,n>>>=0,i<=n))return"";for(a||(a="utf8");;)switch(a){case"hex":return g(this,n,i);case"utf8":case"utf-8":return Qe(this,n,i);case"ascii":return Be(this,n,i);case"latin1":case"binary":return Ge(this,n,i);case"base64":return xe(this,n,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,n,i);default:if(l)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),l=!0}}c.prototype._isBuffer=!0;function V(a,n,i){const l=a[n];a[n]=a[i],a[i]=l}c.prototype.swap16=function(){const n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<n;i+=2)V(this,i,i+1);return this},c.prototype.swap32=function(){const n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<n;i+=4)V(this,i,i+3),V(this,i+1,i+2);return this},c.prototype.swap64=function(){const n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<n;i+=8)V(this,i,i+7),V(this,i+1,i+6),V(this,i+2,i+5),V(this,i+3,i+4);return this},c.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?Qe(this,0,n):x.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(n){if(!c.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:c.compare(this,n)===0},c.prototype.inspect=function(){let n="";const i=t.INSPECT_MAX_BYTES;return n=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(n+=" ... "),"<Buffer "+n+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(n,i,l,d,y){if(he(n,u)&&(n=c.from(n,n.offset,n.byteLength)),!c.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(i===void 0&&(i=0),l===void 0&&(l=n?n.length:0),d===void 0&&(d=0),y===void 0&&(y=this.length),i<0||l>n.length||d<0||y>this.length)throw new RangeError("out of range index");if(d>=y&&i>=l)return 0;if(d>=y)return-1;if(i>=l)return 1;if(i>>>=0,l>>>=0,d>>>=0,y>>>=0,this===n)return 0;let w=y-d,R=l-i;const W=Math.min(w,R),K=this.slice(d,y),H=n.slice(i,l);for(let z=0;z<W;++z)if(K[z]!==H[z]){w=K[z],R=H[z];break}return w<R?-1:R<w?1:0};function ie(a,n,i,l,d){if(a.length===0)return-1;if(typeof i=="string"?(l=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,Nt(i)&&(i=d?0:a.length-1),i<0&&(i=a.length+i),i>=a.length){if(d)return-1;i=a.length-1}else if(i<0)if(d)i=0;else return-1;if(typeof n=="string"&&(n=c.from(n,l)),c.isBuffer(n))return n.length===0?-1:we(a,n,i,l,d);if(typeof n=="number")return n=n&255,typeof u.prototype.indexOf=="function"?d?u.prototype.indexOf.call(a,n,i):u.prototype.lastIndexOf.call(a,n,i):we(a,[n],i,l,d);throw new TypeError("val must be string, number or Buffer")}function we(a,n,i,l,d){let y=1,w=a.length,R=n.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(a.length<2||n.length<2)return-1;y=2,w/=2,R/=2,i/=2}function W(H,z){return y===1?H[z]:H.readUInt16BE(z*y)}let K;if(d){let H=-1;for(K=i;K<w;K++)if(W(a,K)===W(n,H===-1?0:K-H)){if(H===-1&&(H=K),K-H+1===R)return H*y}else H!==-1&&(K-=K-H),H=-1}else for(i+R>w&&(i=w-R),K=i;K>=0;K--){let H=!0;for(let z=0;z<R;z++)if(W(a,K+z)!==W(n,z)){H=!1;break}if(H)return K}return-1}c.prototype.includes=function(n,i,l){return this.indexOf(n,i,l)!==-1},c.prototype.indexOf=function(n,i,l){return ie(this,n,i,l,!0)},c.prototype.lastIndexOf=function(n,i,l){return ie(this,n,i,l,!1)};function be(a,n,i,l){i=Number(i)||0;const d=a.length-i;l?(l=Number(l),l>d&&(l=d)):l=d;const y=n.length;l>y/2&&(l=y/2);let w;for(w=0;w<l;++w){const R=parseInt(n.substr(w*2,2),16);if(Nt(R))return w;a[i+w]=R}return w}function ae(a,n,i,l){return gt(ut(n,a.length-i),a,i,l)}function at(a,n,i,l){return gt(Tr(n),a,i,l)}function de(a,n,i,l){return gt(_r(n),a,i,l)}function Re(a,n,i,l){return gt(jn(n,a.length-i),a,i,l)}c.prototype.write=function(n,i,l,d){if(i===void 0)d="utf8",l=this.length,i=0;else if(l===void 0&&typeof i=="string")d=i,l=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(l)?(l=l>>>0,d===void 0&&(d="utf8")):(d=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const y=this.length-i;if((l===void 0||l>y)&&(l=y),n.length>0&&(l<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let w=!1;for(;;)switch(d){case"hex":return be(this,n,i,l);case"utf8":case"utf-8":return ae(this,n,i,l);case"ascii":case"latin1":case"binary":return at(this,n,i,l);case"base64":return de(this,n,i,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Re(this,n,i,l);default:if(w)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),w=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function xe(a,n,i){return n===0&&i===a.length?e.fromByteArray(a):e.fromByteArray(a.slice(n,i))}function Qe(a,n,i){i=Math.min(a.length,i);const l=[];let d=n;for(;d<i;){const y=a[d];let w=null,R=y>239?4:y>223?3:y>191?2:1;if(d+R<=i){let W,K,H,z;switch(R){case 1:y<128&&(w=y);break;case 2:W=a[d+1],(W&192)===128&&(z=(y&31)<<6|W&63,z>127&&(w=z));break;case 3:W=a[d+1],K=a[d+2],(W&192)===128&&(K&192)===128&&(z=(y&15)<<12|(W&63)<<6|K&63,z>2047&&(z<55296||z>57343)&&(w=z));break;case 4:W=a[d+1],K=a[d+2],H=a[d+3],(W&192)===128&&(K&192)===128&&(H&192)===128&&(z=(y&15)<<18|(W&63)<<12|(K&63)<<6|H&63,z>65535&&z<1114112&&(w=z))}}w===null?(w=65533,R=1):w>65535&&(w-=65536,l.push(w>>>10&1023|55296),w=56320|w&1023),l.push(w),d+=R}return ue(l)}const ve=4096;function ue(a){const n=a.length;if(n<=ve)return String.fromCharCode.apply(String,a);let i="",l=0;for(;l<n;)i+=String.fromCharCode.apply(String,a.slice(l,l+=ve));return i}function Be(a,n,i){let l="";i=Math.min(a.length,i);for(let d=n;d<i;++d)l+=String.fromCharCode(a[d]&127);return l}function Ge(a,n,i){let l="";i=Math.min(a.length,i);for(let d=n;d<i;++d)l+=String.fromCharCode(a[d]);return l}function g(a,n,i){const l=a.length;(!n||n<0)&&(n=0),(!i||i<0||i>l)&&(i=l);let d="";for(let y=n;y<i;++y)d+=Mn[a[y]];return d}function b(a,n,i){const l=a.slice(n,i);let d="";for(let y=0;y<l.length-1;y+=2)d+=String.fromCharCode(l[y]+l[y+1]*256);return d}c.prototype.slice=function(n,i){const l=this.length;n=~~n,i=i===void 0?l:~~i,n<0?(n+=l,n<0&&(n=0)):n>l&&(n=l),i<0?(i+=l,i<0&&(i=0)):i>l&&(i=l),i<n&&(i=n);const d=this.subarray(n,i);return Object.setPrototypeOf(d,c.prototype),d};function v(a,n,i){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+n>i)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(n,i,l){n=n>>>0,i=i>>>0,l||v(n,i,this.length);let d=this[n],y=1,w=0;for(;++w<i&&(y*=256);)d+=this[n+w]*y;return d},c.prototype.readUintBE=c.prototype.readUIntBE=function(n,i,l){n=n>>>0,i=i>>>0,l||v(n,i,this.length);let d=this[n+--i],y=1;for(;i>0&&(y*=256);)d+=this[n+--i]*y;return d},c.prototype.readUint8=c.prototype.readUInt8=function(n,i){return n=n>>>0,i||v(n,1,this.length),this[n]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(n,i){return n=n>>>0,i||v(n,2,this.length),this[n]|this[n+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(n,i){return n=n>>>0,i||v(n,2,this.length),this[n]<<8|this[n+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(n,i){return n=n>>>0,i||v(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(n,i){return n=n>>>0,i||v(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},c.prototype.readBigUInt64LE=Pe(function(n){n=n>>>0,Se(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&De(n,this.length-8);const d=i+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,y=this[++n]+this[++n]*2**8+this[++n]*2**16+l*2**24;return BigInt(d)+(BigInt(y)<<BigInt(32))}),c.prototype.readBigUInt64BE=Pe(function(n){n=n>>>0,Se(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&De(n,this.length-8);const d=i*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],y=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+l;return(BigInt(d)<<BigInt(32))+BigInt(y)}),c.prototype.readIntLE=function(n,i,l){n=n>>>0,i=i>>>0,l||v(n,i,this.length);let d=this[n],y=1,w=0;for(;++w<i&&(y*=256);)d+=this[n+w]*y;return y*=128,d>=y&&(d-=Math.pow(2,8*i)),d},c.prototype.readIntBE=function(n,i,l){n=n>>>0,i=i>>>0,l||v(n,i,this.length);let d=i,y=1,w=this[n+--d];for(;d>0&&(y*=256);)w+=this[n+--d]*y;return y*=128,w>=y&&(w-=Math.pow(2,8*i)),w},c.prototype.readInt8=function(n,i){return n=n>>>0,i||v(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},c.prototype.readInt16LE=function(n,i){n=n>>>0,i||v(n,2,this.length);const l=this[n]|this[n+1]<<8;return l&32768?l|4294901760:l},c.prototype.readInt16BE=function(n,i){n=n>>>0,i||v(n,2,this.length);const l=this[n+1]|this[n]<<8;return l&32768?l|4294901760:l},c.prototype.readInt32LE=function(n,i){return n=n>>>0,i||v(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},c.prototype.readInt32BE=function(n,i){return n=n>>>0,i||v(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},c.prototype.readBigInt64LE=Pe(function(n){n=n>>>0,Se(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&De(n,this.length-8);const d=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(l<<24);return(BigInt(d)<<BigInt(32))+BigInt(i+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),c.prototype.readBigInt64BE=Pe(function(n){n=n>>>0,Se(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&De(n,this.length-8);const d=(i<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(d)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+l)}),c.prototype.readFloatLE=function(n,i){return n=n>>>0,i||v(n,4,this.length),r.read(this,n,!0,23,4)},c.prototype.readFloatBE=function(n,i){return n=n>>>0,i||v(n,4,this.length),r.read(this,n,!1,23,4)},c.prototype.readDoubleLE=function(n,i){return n=n>>>0,i||v(n,8,this.length),r.read(this,n,!0,52,8)},c.prototype.readDoubleBE=function(n,i){return n=n>>>0,i||v(n,8,this.length),r.read(this,n,!1,52,8)};function _(a,n,i,l,d,y){if(!c.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>d||n<y)throw new RangeError('"value" argument is out of bounds');if(i+l>a.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(n,i,l,d){if(n=+n,i=i>>>0,l=l>>>0,!d){const R=Math.pow(2,8*l)-1;_(this,n,i,l,R,0)}let y=1,w=0;for(this[i]=n&255;++w<l&&(y*=256);)this[i+w]=n/y&255;return i+l},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(n,i,l,d){if(n=+n,i=i>>>0,l=l>>>0,!d){const R=Math.pow(2,8*l)-1;_(this,n,i,l,R,0)}let y=l-1,w=1;for(this[i+y]=n&255;--y>=0&&(w*=256);)this[i+y]=n/w&255;return i+l},c.prototype.writeUint8=c.prototype.writeUInt8=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,1,255,0),this[i]=n&255,i+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,2,65535,0),this[i]=n&255,this[i+1]=n>>>8,i+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,2,65535,0),this[i]=n>>>8,this[i+1]=n&255,i+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,4,4294967295,0),this[i+3]=n>>>24,this[i+2]=n>>>16,this[i+1]=n>>>8,this[i]=n&255,i+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,4,4294967295,0),this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255,i+4};function U(a,n,i,l,d){$e(n,l,d,a,i,7);let y=Number(n&BigInt(4294967295));a[i++]=y,y=y>>8,a[i++]=y,y=y>>8,a[i++]=y,y=y>>8,a[i++]=y;let w=Number(n>>BigInt(32)&BigInt(4294967295));return a[i++]=w,w=w>>8,a[i++]=w,w=w>>8,a[i++]=w,w=w>>8,a[i++]=w,i}function M(a,n,i,l,d){$e(n,l,d,a,i,7);let y=Number(n&BigInt(4294967295));a[i+7]=y,y=y>>8,a[i+6]=y,y=y>>8,a[i+5]=y,y=y>>8,a[i+4]=y;let w=Number(n>>BigInt(32)&BigInt(4294967295));return a[i+3]=w,w=w>>8,a[i+2]=w,w=w>>8,a[i+1]=w,w=w>>8,a[i]=w,i+8}c.prototype.writeBigUInt64LE=Pe(function(n,i=0){return U(this,n,i,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=Pe(function(n,i=0){return M(this,n,i,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(n,i,l,d){if(n=+n,i=i>>>0,!d){const W=Math.pow(2,8*l-1);_(this,n,i,l,W-1,-W)}let y=0,w=1,R=0;for(this[i]=n&255;++y<l&&(w*=256);)n<0&&R===0&&this[i+y-1]!==0&&(R=1),this[i+y]=(n/w>>0)-R&255;return i+l},c.prototype.writeIntBE=function(n,i,l,d){if(n=+n,i=i>>>0,!d){const W=Math.pow(2,8*l-1);_(this,n,i,l,W-1,-W)}let y=l-1,w=1,R=0;for(this[i+y]=n&255;--y>=0&&(w*=256);)n<0&&R===0&&this[i+y+1]!==0&&(R=1),this[i+y]=(n/w>>0)-R&255;return i+l},c.prototype.writeInt8=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,1,127,-128),n<0&&(n=255+n+1),this[i]=n&255,i+1},c.prototype.writeInt16LE=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,2,32767,-32768),this[i]=n&255,this[i+1]=n>>>8,i+2},c.prototype.writeInt16BE=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,2,32767,-32768),this[i]=n>>>8,this[i+1]=n&255,i+2},c.prototype.writeInt32LE=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,4,2147483647,-2147483648),this[i]=n&255,this[i+1]=n>>>8,this[i+2]=n>>>16,this[i+3]=n>>>24,i+4},c.prototype.writeInt32BE=function(n,i,l){return n=+n,i=i>>>0,l||_(this,n,i,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255,i+4},c.prototype.writeBigInt64LE=Pe(function(n,i=0){return U(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=Pe(function(n,i=0){return M(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function P(a,n,i,l,d,y){if(i+l>a.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function $(a,n,i,l,d){return n=+n,i=i>>>0,d||P(a,n,i,4),r.write(a,n,i,l,23,4),i+4}c.prototype.writeFloatLE=function(n,i,l){return $(this,n,i,!0,l)},c.prototype.writeFloatBE=function(n,i,l){return $(this,n,i,!1,l)};function q(a,n,i,l,d){return n=+n,i=i>>>0,d||P(a,n,i,8),r.write(a,n,i,l,52,8),i+8}c.prototype.writeDoubleLE=function(n,i,l){return q(this,n,i,!0,l)},c.prototype.writeDoubleBE=function(n,i,l){return q(this,n,i,!1,l)},c.prototype.copy=function(n,i,l,d){if(!c.isBuffer(n))throw new TypeError("argument should be a Buffer");if(l||(l=0),!d&&d!==0&&(d=this.length),i>=n.length&&(i=n.length),i||(i=0),d>0&&d<l&&(d=l),d===l||n.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),n.length-i<d-l&&(d=n.length-i+l);const y=d-l;return this===n&&typeof u.prototype.copyWithin=="function"?this.copyWithin(i,l,d):u.prototype.set.call(n,this.subarray(l,d),i),y},c.prototype.fill=function(n,i,l,d){if(typeof n=="string"){if(typeof i=="string"?(d=i,i=0,l=this.length):typeof l=="string"&&(d=l,l=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!c.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(n.length===1){const w=n.charCodeAt(0);(d==="utf8"&&w<128||d==="latin1")&&(n=w)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(i<0||this.length<i||this.length<l)throw new RangeError("Out of range index");if(l<=i)return this;i=i>>>0,l=l===void 0?this.length:l>>>0,n||(n=0);let y;if(typeof n=="number")for(y=i;y<l;++y)this[y]=n;else{const w=c.isBuffer(n)?n:c.from(n,d),R=w.length;if(R===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(y=0;y<l-i;++y)this[y+i]=w[y%R]}return this};const J={};function ce(a,n,i){J[a]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}}}ce("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ce("ERR_INVALID_ARG_TYPE",function(a,n){return`The "${a}" argument must be of type number. Received type ${typeof n}`},TypeError),ce("ERR_OUT_OF_RANGE",function(a,n,i){let l=`The value of "${a}" is out of range.`,d=i;return Number.isInteger(i)&&Math.abs(i)>2**32?d=Ne(String(i)):typeof i=="bigint"&&(d=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(d=Ne(d)),d+="n"),l+=` It must be ${n}. Received ${d}`,l},RangeError);function Ne(a){let n="",i=a.length;const l=a[0]==="-"?1:0;for(;i>=l+4;i-=3)n=`_${a.slice(i-3,i)}${n}`;return`${a.slice(0,i)}${n}`}function ke(a,n,i){Se(n,"offset"),(a[n]===void 0||a[n+i]===void 0)&&De(n,a.length-(i+1))}function $e(a,n,i,l,d,y){if(a>i||a<n){const w=typeof n=="bigint"?"n":"";let R;throw y>3?n===0||n===BigInt(0)?R=`>= 0${w} and < 2${w} ** ${(y+1)*8}${w}`:R=`>= -(2${w} ** ${(y+1)*8-1}${w}) and < 2 ** ${(y+1)*8-1}${w}`:R=`>= ${n}${w} and <= ${i}${w}`,new J.ERR_OUT_OF_RANGE("value",R,a)}ke(l,d,y)}function Se(a,n){if(typeof a!="number")throw new J.ERR_INVALID_ARG_TYPE(n,"number",a)}function De(a,n,i){throw Math.floor(a)!==a?(Se(a,i),new J.ERR_OUT_OF_RANGE(i||"offset","an integer",a)):n<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(i||"offset",`>= ${i?1:0} and <= ${n}`,a)}const Rt=/[^+/0-9A-Za-z-_]/g;function S(a){if(a=a.split("=")[0],a=a.trim().replace(Rt,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}function ut(a,n){n=n||1/0;let i;const l=a.length;let d=null;const y=[];for(let w=0;w<l;++w){if(i=a.charCodeAt(w),i>55295&&i<57344){if(!d){if(i>56319){(n-=3)>-1&&y.push(239,191,189);continue}else if(w+1===l){(n-=3)>-1&&y.push(239,191,189);continue}d=i;continue}if(i<56320){(n-=3)>-1&&y.push(239,191,189),d=i;continue}i=(d-55296<<10|i-56320)+65536}else d&&(n-=3)>-1&&y.push(239,191,189);if(d=null,i<128){if((n-=1)<0)break;y.push(i)}else if(i<2048){if((n-=2)<0)break;y.push(i>>6|192,i&63|128)}else if(i<65536){if((n-=3)<0)break;y.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((n-=4)<0)break;y.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return y}function Tr(a){const n=[];for(let i=0;i<a.length;++i)n.push(a.charCodeAt(i)&255);return n}function jn(a,n){let i,l,d;const y=[];for(let w=0;w<a.length&&!((n-=2)<0);++w)i=a.charCodeAt(w),l=i>>8,d=i%256,y.push(d),y.push(l);return y}function _r(a){return e.toByteArray(S(a))}function gt(a,n,i,l){let d;for(d=0;d<l&&!(d+i>=n.length||d>=a.length);++d)n[d+i]=a[d];return d}function he(a,n){return a instanceof n||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===n.name}function Nt(a){return a!==a}const Mn=function(){const a="0123456789abcdef",n=new Array(256);for(let i=0;i<16;++i){const l=i*16;for(let d=0;d<16;++d)n[l+d]=a[i]+a[d]}return n}();function Pe(a){return typeof BigInt>"u"?Vn:a}function Vn(){throw new Error("BigInt not supported")}})(on);const Or=on.Buffer;var an=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var dr={exports:{}};const Di=Object.getPrototypeOf({});function hr(t){function e(I){return I!=="constructor"&&I!=="prototype"&&I!=="__proto__"}function r(I){let F=0;const j=I.length,L=new Array(j);for(F=0;F<j;++F)L[F]=T(I[F]);return L}function o(I){const F={};if(h&&Object.getPrototypeOf(I)!==Di)return h(I);const j=p(I);let L,O,C;for(L=0,O=j.length;L<O;++L)e(C=j[L])&&(F[C]=T(I[C]));return F}function s(I,F){const j=I.length,L=F.length;let O=0;const C=new Array(j+L);for(O=0;O<j;++O)C[O]=T(I[O]);for(O=0;O<L;++O)C[O+j]=T(F[O]);return C}const u=Object.prototype.propertyIsEnumerable;function f(I){const F=Object.keys(I),j=Object.getOwnPropertySymbols(I);for(let L=0,O=j.length;L<O;++L)u.call(I,j[L])&&F.push(j[L]);return F}const p=t&&t.symbols?f:Object.keys,h=typeof t?.cloneProtoObject=="function"?t.cloneProtoObject:void 0;function E(I){return typeof I=="object"&&I!==null&&!(I instanceof RegExp)&&!(I instanceof Date)}function c(I){return typeof I!="object"||I===null}const m=typeof Or<"u"?I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date||I instanceof Or:I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date,A=t&&typeof t.mergeArray=="function"?t.mergeArray({clone:T,deepmerge:N,getKeys:p,isMergeableObject:E}):s;function T(I){return E(I)?Array.isArray(I)?r(I):o(I):I}function B(I,F){const j={},L=p(I),O=p(F);let C,x,V;for(C=0,x=L.length;C<x;++C)e(V=L[C])&&O.indexOf(V)===-1&&(j[V]=T(I[V]));for(C=0,x=O.length;C<x;++C)e(V=O[C])&&(V in I&&(L.indexOf(V)!==-1&&(j[V]=N(I[V],F[V])),!0)||(j[V]=T(F[V])));return j}function N(I,F){const j=Array.isArray(F),L=Array.isArray(I);return c(F)?F:m(I)?T(F):j&&L?A(I,F):j!==L?T(F):B(I,F)}function G(){switch(arguments.length){case 0:return{};case 1:return T(arguments[0]);case 2:return N(arguments[0],arguments[1])}let I;for(let F=0,j=arguments.length;F<j;++F)I=N(I,arguments[F]);return I}return t&&t.all?G:N}dr.exports=hr;dr.exports.default=hr;var Ui=dr.exports.deepmerge=hr;const ji=t=>(e,r)=>{let o=0;const s=e.length,u=r.length,f=Math.max(s,u),p=new Array(f);for(o=0;o<f;++o)o<u?p[o]=t.deepmerge(e[o],r[o]):p[o]=t.clone(e[o]);return p},Mi=Ui({mergeArray:ji}),Vi=(t,e,r)=>{const o=Oe.computed([e,r],(f,p)=>{if(f){const h=p.data?.find(E=>E.id===f);if(h)return h;console.error("Feed list is not loaded yet. Issue with the opened question.")}}),s=Le({data:void 0,loading:void 0,error:void 0});return o.subscribe(async f=>{if(f&&f.type==="question"){s.setKey("loading",!0);const p=await nn(f.id,t);s.set({data:p,loading:!1});return}s.set({data:void 0,loading:!1})}),{$store:o,$extendedStore:s,updateExtendedQuestion:f=>{const p=s.get().data;if(p&&f?.answers)for(const h of f.answers)h.youVoted!==!0&&delete h.youVoted;s.set({data:Mi(p,f)})}}};class qi{slStreamId;organizationId;userId;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;notifications;log;constructor(e){this.log=rn("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new fe(ne(void 0),"moderationId").getStore(),this.openedQuestionId=new fe(ne(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new me(Ii(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new me(Fi(this.slStreamId,e.transport),"gamification:feedList"),this.activeQuestionId=new me(Ti(this.slStreamId,e.transport),"gamification:activeQuestionId"),this.openedQuestion=Vi(e.transport,this.openedQuestionId,this.feedList.getStore()),this.openedQuestionId.listen(r=>{this.log.debug({questionId:r},"received question"),r?(this.questionSubscription=Oi(r,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",o=>{window.requestAnimationFrame(()=>{this.openedQuestion.updateExtendedQuestion(o.data?.attributes?.question)})}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))}),this.feedSubscription=_i(this.slStreamId,e.transport),this.feedSubscription.addListener("feed-subscription-active-question",r=>{window.requestAnimationFrame(()=>{const o=this.activeQuestionId.getStore();o&&o.mutate(r.data?.attributes)})}),this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})}),this.feedSubscription.connect()}getCurrentSessionId=e=>{const r=e.eventId||this.slStreamId.get()||"",o=e.userId||this.userId.get()||"",s=e.organizationId||this.organizationId.get()||"",u=e.entity||"",f=e.prefix||"";return[s,r,o,f,u].join(":")};disconnect=()=>{this.feedSubscription?.disconnect()};openQuestion=e=>{this.openedQuestionId.set(e),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 Qi{notificationsList;notifications;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=rn("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notifications=new fe(ne(new Map),"notifications-queue"),this.notificationsList=this.notifications.getStore()}addToQueue=e=>{if(this.store.has(e.id)){this.logger.debug({notification:e},"skip existed notification: %o");return}const r=e.close,o=e.action;if(this.store.set(e.id,{...e,close:(...s)=>{r&&r(...s),this.closeNotification(e.id)},action:(...s)=>{o&&o(...s),this.closeNotification(e.id)}}),this.waitingQueue.add(e.id),this.activeQueue.size===this.options.concurrency){const[s]=this.activeQueue;if(this.store.get(s)?.persistent!==!0)this.closeNotification(s);else{const[f]=this.waitingQueue;this.waitingQueue.size>1&&this.closeNotification(f),this.tickWaitingQueue()}}else this.tickWaitingQueue()};tickWaitingQueue=()=>{if(this.activeQueue.size<this.options.concurrency){const[e]=this.waitingQueue;if(!e)return;this.activeQueue.add(e),this.waitingQueue.delete(e),this.logger.debug({job:e},"waiting queue tick"),this.tickActiveQueue(e)}else this.logger.debug({queueSize:this.activeQueue.size,concurrency:this.options.concurrency},"waiting queue tick skipped")};tickActiveQueue=e=>{if(!e)return;const r=this.store.get(e);if(!r){this.logger.debug({notificationId:e},"active queue tick skipped, notification not exist");return}const o=setTimeout(()=>{const s=e,u=new Map(this.notifications.getValue());u.set(r.id,r),this.notifications.setValue(u);const f=setTimeout(()=>{this.logger.debug({notificationId:s,delay:r.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(s)},r.autoHideDuration||5e3);this.timeouts.set(s,f),this.logger.debug({notificationId:s,queue:[...u.values()]},"notification displayed")},r.delay||0);this.timeouts.set(e,o),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=e=>{const r=new Map(this.notifications.getValue()),o=r.get(e);if(o){o.hiding=!(this.waitingQueue.size>=this.options.concurrency),this.notifications.setValue(r);const s=setTimeout(()=>{const u=new Map(this.notifications.getValue());u.delete(e),this.notifications.setValue(u);const f=this.timeouts.get(e);f!==void 0&&(clearTimeout(f),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden")},this.options.animationDelay||0);this.timeouts.set(e,s)}this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding")}}var It;(function(t){t.OPENED="opened"})(It||(It={}));class Gi extends lr{constructor(){super("notification")}setOpened=e=>{this.write(It.OPENED,e,"true")};isOpened=e=>this.read(It.OPENED,e);clearNotification=()=>{this.clear()}}var Me;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(Me||(Me={}));class zi{queue;storage;constructor(e={}){this.storage=new Gi,this.queue=new Qi({concurrency:1,animationDelay:1600,...e})}add=e=>{this.storage.isOpened(e.id)||this.queue.addToQueue(e)};close=(e,r=!0)=>{this.queue.closeNotification(e),r&&this.markAsViewed(e)};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const Ki=(t,e,r)=>{t.notifications=new zi,t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),r()},Wi=(t,e)=>{const{client:r}=t.createPromiseClient(Fe.Feed,{method:"submitAnswer"});return r.submitAnswer({data:e})},Hi=(t,e)=>{const{client:r}=t.createPromiseClient(Fe.Feed,{method:"submitInplay"});return r.submitInplay({data:{eventId:+e}})},Ji=(t,e)=>{const{client:r}=t.createPromiseClient(Fe.Feed,{method:"skipQuestion"});return r.skipQuestion({data:{id:e}})};var Ye;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})(Ye||(Ye={}));class un extends lr{constructor(){super("gamification")}saveOnboardingStatus=({userId:e,eventId:r,organizationId:o},s)=>{this.write(Ye.ONBOARDING,o,e,r,s)};getOnboardingStatus=({userId:e,eventId:r,organizationId:o})=>this.read(Ye.ONBOARDING,o,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:o})=>{const s=this.generateKey([Ye.ONBOARDING_IO,o,e,r]);window.sessionStorage.setItem(s,"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:o})=>{const s=this.generateKey([Ye.ONBOARDING_IO,o,e,r]);return window.sessionStorage.getItem(s)}}const Fr={pageSize:10},Yi=(t,e,r)=>{let o=0;const s=ne({pageSize:r?.pageSize||Fr.pageSize,page:0}),u=Le({data:[],hasMore:!0,loading:void 0,error:void 0}),f=Ai(t),p=async c=>{if(c){u.setKey("loading",!0);const m={eventId:c,pagination:{page:0,pageSize:r?.pageSize||Fr.pageSize}},A=await f(m);u.set({data:A.data.map(T=>T.attributes),hasMore:!0,loading:!1}),A.meta&&(o=Math.round(A.meta.count/A.meta.pageSize)),s.set(m.pagination)}},h=()=>{p(e.get())},E=c=>{const m=s.get(),A=c||m.page+1;A<=o&&s.set({...m,page:A})};return Oe.onMount(u,()=>{const c=e.listen(p),m=s.listen(async A=>{const T=e.get();if(A.page>0&&T)if(A.page<o){u.setKey("loading",!0);const N=await f({eventId:T,pagination:A}),G=u.get().data||[];u.set({data:[...G,...N.data.map(I=>I.attributes)],loading:!1,hasMore:!0})}else u.setKey("hasMore",!1)});return()=>{c(),m()}}),{$store:u,fetchMore:E,invalidate:h}},Xi=(t,e)=>{const{client:r,queryKey:o}=t.createPromiseClient(pt.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(o,{fetcher:async(s,u,f)=>f?(await r.generateDeepLink({data:{eventId:f}})).data?.attributes:{}})},Zi=(t,{web:e,mobile:r})=>{const{client:o}=t.createPromiseClient(Kn.LinksClient,{method:"generate"});return o.generate({web:e,mobile:r})},eo=(t,e,r)=>{const o=Le({});return Oe.onMount(o,()=>Xi(t,[e]).subscribe(async({data:f,error:p,loading:h})=>{const E=p?"https://masters.com":f?.url;if(!h&&E){o.setKey("loading",!0);let c=window.location.search,m=window.location.hash;if(c&&m||m){const B=new URLSearchParams(c);B.append("slprms",`sl_eid=${e.get()}:sl_uid=${r.get()}`),c=`?${B.toString()}`}else m=`#slprms::${`sl_eid=${e.get()}:sl_uid=${r.get()}`}`;const A=window.location.origin+window.location.pathname+c+m,T=await Zi(t,{web:A,mobile:E});o.set({data:T.data?.link,loading:!1})}else o.setKey("loading",!0)})),{$store:o,fetch}};var ee;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(ee||(ee={}));const to=(t,e,r,o)=>{const{inplayGame:s}=t.featureSettings.get(),u=e.getCurrentSessionId({prefix:"onboarding"});s&&r.add({type:Me.ONBOARDING,id:u,action:t.openFeature,close:()=>{r.markAsViewed(u)},persistent:!0,autoHideDuration:1e6,data:{questionType:re.QuestionType.UNSET,onboarding:{...s,instantOpen:!o.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},mt=(t,e,r,o,s,u)=>{try{const f=e.userId.get();if(!f)return;if(s.getOnboardingStatus({userId:f,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===ee.Completed){t.set(ee.Completed);for(const A of u)A();return}const h=e.moderation.getStore().value?.data,E=r.featureSettings.get().inplayGame;if(h===void 0||E===void 0)return;const c=h?.options?.onboardingEnabled,m=E?.titleCard?.optIn;c?m?t.set(ee.Required):t.set(ee.Optional):(m?t.set(ee.Unavailable):t.set(ee.Disabled),o.close(e.getCurrentSessionId({prefix:"onboarding"}),!1))}catch(f){console.error(f)}},ro=(t,e,r,o)=>{const s=new un,u=ne(ee.Unset);u.subscribe(h=>{h!==ee.Unset&&((h===ee.Optional||h===ee.Required)&&to(t,e,o,s),h===ee.Completed&&e.activeQuestionId.invalidate(),s.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const f=[];return mt(u,e,t,o,s,f),u.get()!==ee.Completed&&(f.push(e.userId.listen(h=>{h&&mt(u,e,t,o,s,f)})),f.push(e.moderation.listen(h=>{h.data&&mt(u,e,t,o,s,f)})),f.push(t.featureSettings.listen(h=>{h&&mt(u,e,t,o,s,f)}))),{$store:u,submitInplay:async()=>{const h=e.slStreamId.get();if(h){await Hi(r,h),u.set(ee.Completed),s.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:h},ee.Completed);const E=e.getCurrentSessionId({prefix:"onboarding"});o.close(E)}}}},no=new Set([re.QuestionType.POLL,re.QuestionType.PREDICTION,re.QuestionType.TRIVIA]);class io extends tn{userSummary;feedList;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;notifications;transport;background;storage;constructor(e,r,o){super(e,r),this.background=new qi(o),this.storage=new un,this.userSummary=new me(Ei(this.background.slStreamId,this.background.userId,o.transport),"gamification:userSummary"),this.feedList=this.background.feedList,this.currentUserId=this.background.userId,this.openedUser=ne(void 0),this.leaderboardId=new fe(ne(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=ro(this,this.background,o.transport,o.notifications),this.notifications=o.notifications,this.transport=o.transport,this.closeFeature=()=>o.sdk.closeFeature(!0),this.openFeature=()=>o.sdk.openFeature(Te.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=eo(this.transport,this.background.slStreamId,this.background.userId),this.leaderboardList=Yi(this.transport,this.background.slStreamId),this.status.subscribe(s=>{s===et.Ready?this.connect(o.transport):this.disconnect()}),this.background.activeQuestionId.listen(s=>{const u=this.onboardingStatus.$store.get();if(s&&s.data&&u&&u!==ee.Unset&&s.data.question?.id!==void 0&&s.data.question.notification!==void 0&&s.data.question?.bypassNotifications?.inAppSilence!==re.SilenceSetting.ON&&s.data.question.status===re.QuestionStatus.ACTIVE){if(no.has(s.data.question.type)){const f=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,p=this.settings.getValues().inplayGame?.titleCard?.optIn,h=u===ee.Completed;(!f||h||p!==!0)&&this.notifications.add({type:Me.QUESTION,action:()=>s.data?.question&&this.openQuestion(s.data.question.id),close:()=>s.data?.question&&this.closeQuestion(s.data.question.id),autoHideDuration:1e3*60,id:this.background.getCurrentSessionId({prefix:"notification",entity:s.data.question.id}),data:{questionType:s.data.question.type,question:{title:s.data.question.notification.title}}})}else if(s.data.question.type===re.QuestionType.FACTOID){const f=s.data.question.options?.options.value,p={heading:s.data.question.notification.title,body:s.data.question.notification.body,image:s.data.question.notification.image,video:{id:f?.video?.id||"",url:f?.video?.url||"",thumbnailUrl:f?.video?.thumbnailUrl||""},webLink:{label:"",url:""}};this.notifications.add({type:Me.QUESTION,action:()=>s.data?.question&&this.openQuestion(s.data.question.id),close:()=>s.data?.question&&this.closeQuestion(s.data.question.id),autoHideDuration:1e3*120,id:this.background.getCurrentSessionId({prefix:"notification",entity:s.data.question.id}),data:{questionType:s.data.question.type,insight:p}})}else if(s.data.question.type===re.QuestionType.TWEET){const f=s.data.question.options?.options.value,p={title:s.data.question.notification.title,body:s.data.question.notification.body,image:s.data.question.notification.image,account:f?.tweetMeta?.account||"",accountVerified:!!f?.tweetMeta?.accountVerified};this.notifications.add({type:Me.QUESTION,action:()=>s.data?.question&&this.openQuestion(s.data.question.id),close:()=>s.data?.question&&this.closeQuestion(s.data.question.id),autoHideDuration:1e3*120,id:this.background.getCurrentSessionId({prefix:"notification",entity:s.data.question.id}),data:{questionType:s.data.question.type,tweet:p}})}}})}connect=e=>{this.userSummary.invalidate(),this.leaderboardList.invalidate(),this.feedList.invalidate(),this.background.feedSubscription.addListener("feed-subscription-prediction-close",r=>{window.requestAnimationFrame(async()=>{const o=r.data?.attributes?.question;if(!o)return;const{status:s,type:u,id:f}=o;if(s===re.QuestionStatus.RESOLVED&&u===re.QuestionType.PREDICTION){const p=this.background.getCurrentSessionId({prefix:`notification-id:${f}`}),h=await nn(f,e),E=h?.answers.find(({correct:m})=>m),c=h?.answers.find(({youVoted:m})=>m);if(!c)return;this.notifications.add({type:Me.QUESTION_RESOLVED,action:()=>this.openQuestion(f),close:()=>this.closeQuestion(f),autoHideDuration:35e3,id:p,data:{questionType:re.QuestionType.PREDICTION,question:{title:E?.youVoted?`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:E?.youVoted,predictionResult:s===re.QuestionStatus.RESOLVED,questionTitle:h?.subject}}}),this.userSummary.invalidate()}})}),this.background.feedSubscription.addListener("feed-subscription-questions-list",()=>{window.requestAnimationFrame(()=>{this.feedList?.invalidate()})})};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitAnswer=async(e,r)=>{await Wi(this.transport,{questionId:e,answerId:r}),this.feedList.invalidate(),this.userSummary.invalidate()};skipQuestion=async e=>{await Ji(this.transport,e),this.feedList.invalidate(),this.userSummary.invalidate()};openQuestion=e=>(this.openFeature(),this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e})),this.background.openQuestion(e));closeQuestion=e=>this.background.closeQuestion(e);openUser=e=>{const r=this.leaderboardList.$store.get().data?.find(o=>o.userId===e);this.openedUser.set(r)};closeUser=()=>{this.openedUser.set(void 0)}}const oo={[Te.SdkOverlayType.GAMES]:!0};class so extends tn{constructor(e,r){super(e,r)}}const ao=(t,e,r)=>t.type===Te.SdkOverlayType.GAMES?new io(t,e,r):new so(t,e),uo=(t,e,r)=>{t.features=new Map,t.activeFeature=new fe(ne(Te.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=o=>t.features.get(o),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=o=>{t.activeFeature.setValue(o)},t.sdk.closeFeature=(o=!1)=>{if(o){const s=t.activeFeature.getValue();t.activeFeature.setValue(Te.SdkOverlayType.UNSET),s&&t.features.delete(s)}},t.initFeature=(o,s=Ae.ORGANIZATION)=>{if(o.type in oo&&!t.features.has(o.type)){const u=ao(o,s,t);t.features.set(o.type,u)}},t.updateFeature=(o,s)=>{t.features.get(o.type)?.update(o,s)},t.destroyFeature=o=>{t.features.delete(o.type)},t.reinitializeFeatures=async()=>{const o=await t.stores.organizationSettings.getValue();t.features.clear();for(const s of o?.overlays||[])t.initFeature(s,Ae.ORGANIZATION)},t.stores.providerStreamId.listen(o=>{o||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const o=(u,f)=>{if(f?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&u===Ae.ORGANIZATION))for(const p of f.overlays)p.sdkEnable===!0&&(t.features.has(p.type)?t.updateFeature(p,u):t.initFeature(p,u))},s={organizationSettings:u=>{if(u.data)try{o(Ae.ORGANIZATION,u.data)}catch(f){console.log(f)}},streamSettings:u=>{if(u.data)try{o(Ae.STREAM,u.data)}catch(f){console.log(f)}}};t.store.subscribe(s)},r()};var pr={exports:{}},yr={exports:{}};function co(t){var e=new t,r=e;function o(){var u=e;return u.next?e=u.next:(e=new t,r=e),u.next=null,u}function s(u){r.next=u,r=u}return{get:o,release:s}}var lo=co,fo=lo;function cn(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),r<1)throw new Error("fastqueue concurrency must be greater than 1");var o=fo(ho),s=null,u=null,f=0,p=null,h={push:N,drain:se,saturated:se,pause:c,paused:!1,concurrency:r,running:E,resume:T,idle:B,length:m,getQueue:A,unshift:G,empty:se,kill:F,killAndDrain:j,error:L};return h;function E(){return f}function c(){h.paused=!0}function m(){for(var O=s,C=0;O;)O=O.next,C++;return C}function A(){for(var O=s,C=[];O;)C.push(O.value),O=O.next;return C}function T(){if(h.paused){h.paused=!1;for(var O=0;O<h.concurrency;O++)f++,I()}}function B(){return f===0&&h.length()===0}function N(O,C){var x=o.get();x.context=t,x.release=I,x.value=O,x.callback=C||se,x.errorHandler=p,f===h.concurrency||h.paused?u?(u.next=x,u=x):(s=x,u=x,h.saturated()):(f++,e.call(t,x.value,x.worked))}function G(O,C){var x=o.get();x.context=t,x.release=I,x.value=O,x.callback=C||se,x.errorHandler=p,f===h.concurrency||h.paused?s?(x.next=s,s=x):(s=x,u=x,h.saturated()):(f++,e.call(t,x.value,x.worked))}function I(O){O&&o.release(O);var C=s;C?h.paused?f--:(u===s&&(u=null),s=C.next,C.next=null,e.call(t,C.value,C.worked),u===null&&h.empty()):--f===0&&h.drain()}function F(){s=null,u=null,h.drain=se}function j(){s=null,u=null,h.drain(),h.drain=se}function L(O){p=O}}function se(){}function ho(){this.value=null,this.callback=se,this.next=null,this.release=se,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,o){var s=t.callback,u=t.errorHandler,f=t.value;t.value=null,t.callback=se,t.errorHandler&&u(r,f),s.call(t.context,r,o),t.release(t)}}function po(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function o(c,m){e.call(this,c).then(function(A){m(null,A)},m)}var s=cn(t,o,r),u=s.push,f=s.unshift;return s.push=p,s.unshift=h,s.drained=E,s;function p(c){var m=new Promise(function(A,T){u(c,function(B,N){if(B){T(B);return}A(N)})});return m.catch(se),m}function h(c){var m=new Promise(function(A,T){f(c,function(B,N){if(B){T(B);return}A(N)})});return m.catch(se),m}function E(){if(s.idle())return new Promise(function(A){A()});var c=s.drain,m=new Promise(function(A){s.drain=function(){c(),A()}});return m}}yr.exports=cn;yr.exports.promise=po;var ln=yr.exports,gr={exports:{}},tt=typeof Reflect=="object"?Reflect:null,Cr=tt&&typeof tt.apply=="function"?tt.apply:function(e,r,o){return Function.prototype.apply.call(e,r,o)},bt;tt&&typeof tt.ownKeys=="function"?bt=tt.ownKeys:Object.getOwnPropertySymbols?bt=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:bt=function(e){return Object.getOwnPropertyNames(e)};function yo(t){console&&console.warn&&console.warn(t)}var fn=Number.isNaN||function(e){return e!==e};function Q(){Q.init.call(this)}gr.exports=Q;gr.exports.once=bo;Q.EventEmitter=Q;Q.prototype._events=void 0;Q.prototype._eventsCount=0;Q.prototype._maxListeners=void 0;var xr=10;function kt(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Q,"defaultMaxListeners",{enumerable:!0,get:function(){return xr},set:function(t){if(typeof t!="number"||t<0||fn(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");xr=t}});Q.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};Q.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||fn(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function dn(t){return t._maxListeners===void 0?Q.defaultMaxListeners:t._maxListeners}Q.prototype.getMaxListeners=function(){return dn(this)};Q.prototype.emit=function(e){for(var r=[],o=1;o<arguments.length;o++)r.push(arguments[o]);var s=e==="error",u=this._events;if(u!==void 0)s=s&&u.error===void 0;else if(!s)return!1;if(s){var f;if(r.length>0&&(f=r[0]),f instanceof Error)throw f;var p=new Error("Unhandled error."+(f?" ("+f.message+")":""));throw p.context=f,p}var h=u[e];if(h===void 0)return!1;if(typeof h=="function")Cr(h,this,r);else for(var E=h.length,c=mn(h,E),o=0;o<E;++o)Cr(c[o],this,r);return!0};function hn(t,e,r,o){var s,u,f;if(kt(r),u=t._events,u===void 0?(u=t._events=Object.create(null),t._eventsCount=0):(u.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),u=t._events),f=u[e]),f===void 0)f=u[e]=r,++t._eventsCount;else if(typeof f=="function"?f=u[e]=o?[r,f]:[f,r]:o?f.unshift(r):f.push(r),s=dn(t),s>0&&f.length>s&&!f.warned){f.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+f.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=t,p.type=e,p.count=f.length,yo(p)}return t}Q.prototype.addListener=function(e,r){return hn(this,e,r,!1)};Q.prototype.on=Q.prototype.addListener;Q.prototype.prependListener=function(e,r){return hn(this,e,r,!0)};function go(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function pn(t,e,r){var o={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},s=go.bind(o);return s.listener=r,o.wrapFn=s,s}Q.prototype.once=function(e,r){return kt(r),this.on(e,pn(this,e,r)),this};Q.prototype.prependOnceListener=function(e,r){return kt(r),this.prependListener(e,pn(this,e,r)),this};Q.prototype.removeListener=function(e,r){var o,s,u,f,p;if(kt(r),s=this._events,s===void 0)return this;if(o=s[e],o===void 0)return this;if(o===r||o.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,o.listener||r));else if(typeof o!="function"){for(u=-1,f=o.length-1;f>=0;f--)if(o[f]===r||o[f].listener===r){p=o[f].listener,u=f;break}if(u<0)return this;u===0?o.shift():mo(o,u),o.length===1&&(s[e]=o[0]),s.removeListener!==void 0&&this.emit("removeListener",e,p||r)}return this};Q.prototype.off=Q.prototype.removeListener;Q.prototype.removeAllListeners=function(e){var r,o,s;if(o=this._events,o===void 0)return this;if(o.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):o[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[e]),this;if(arguments.length===0){var u=Object.keys(o),f;for(s=0;s<u.length;++s)f=u[s],f!=="removeListener"&&this.removeAllListeners(f);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=o[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(s=r.length-1;s>=0;s--)this.removeListener(e,r[s]);return this};function yn(t,e,r){var o=t._events;if(o===void 0)return[];var s=o[e];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?wo(s):mn(s,s.length)}Q.prototype.listeners=function(e){return yn(this,e,!0)};Q.prototype.rawListeners=function(e){return yn(this,e,!1)};Q.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):gn.call(t,e)};Q.prototype.listenerCount=gn;function gn(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Q.prototype.eventNames=function(){return this._eventsCount>0?bt(this._events):[]};function mn(t,e){for(var r=new Array(e),o=0;o<e;++o)r[o]=t[o];return r}function mo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function wo(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function bo(t,e){return new Promise(function(r,o){function s(f){t.removeListener(e,u),o(f)}function u(){typeof t.removeListener=="function"&&t.removeListener("error",s),r([].slice.call(arguments))}wn(t,e,u,{once:!0}),e!=="error"&&vo(t,s,{once:!0})})}function vo(t,e,r){typeof t.on=="function"&&wn(t,"error",e,r)}function wn(t,e,r,o){if(typeof t.on=="function")o.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function s(u){o.once&&t.removeEventListener(e,s),r(u)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var bn=gr.exports,Pt={},vn={},Sn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),o=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(o)!=="[object Symbol]")return!1;var s=42;e[r]=s;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var u=Object.getOwnPropertySymbols(e);if(u.length!==1||u[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var f=Object.getOwnPropertyDescriptor(e,r);if(f.value!==s||f.enumerable!==!0)return!1}return!0},So=Sn,mr=function(){return So()&&!!Symbol.toStringTag},Br=typeof Symbol<"u"&&Symbol,Eo=Sn,Ao=function(){return typeof Br!="function"||typeof Symbol!="function"||typeof Br("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Eo()},kr={foo:{}},Io=Object,To=function(){return{__proto__:kr}.foo===kr.foo&&!({__proto__:null}instanceof Io)},_o="Function.prototype.bind called on incompatible ",Oo=Object.prototype.toString,Fo=Math.max,Co="[object Function]",Pr=function(e,r){for(var o=[],s=0;s<e.length;s+=1)o[s]=e[s];for(var u=0;u<r.length;u+=1)o[u+e.length]=r[u];return o},xo=function(e,r){for(var o=[],s=r||0,u=0;s<e.length;s+=1,u+=1)o[u]=e[s];return o},Bo=function(t,e){for(var r="",o=0;o<t.length;o+=1)r+=t[o],o+1<t.length&&(r+=e);return r},ko=function(e){var r=this;if(typeof r!="function"||Oo.apply(r)!==Co)throw new TypeError(_o+r);for(var o=xo(arguments,1),s,u=function(){if(this instanceof s){var c=r.apply(this,Pr(o,arguments));return Object(c)===c?c:this}return r.apply(e,Pr(o,arguments))},f=Fo(0,r.length-o.length),p=[],h=0;h<f;h++)p[h]="$"+h;if(s=Function("binder","return function ("+Bo(p,",")+"){ return binder.apply(this,arguments); }")(u),r.prototype){var E=function(){};E.prototype=r.prototype,s.prototype=new E,E.prototype=null}return s},Po=ko,wr=Function.prototype.bind||Po,Lo=Function.prototype.call,Ro=Object.prototype.hasOwnProperty,No=wr,$o=No.call(Lo,Ro),D,nt=SyntaxError,En=Function,rt=TypeError,Dt=function(t){try{return En('"use strict"; return ('+t+").constructor;")()}catch{}},Ve=Object.getOwnPropertyDescriptor;if(Ve)try{Ve({},"")}catch{Ve=null}var Ut=function(){throw new rt},Do=Ve?function(){try{return arguments.callee,Ut}catch{try{return Ve(arguments,"callee").get}catch{return Ut}}}():Ut,Ke=Ao(),Uo=To(),X=Object.getPrototypeOf||(Uo?function(t){return t.__proto__}:null),He={},jo=typeof Uint8Array>"u"||!X?D:X(Uint8Array),qe={"%AggregateError%":typeof AggregateError>"u"?D:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?D:ArrayBuffer,"%ArrayIteratorPrototype%":Ke&&X?X([][Symbol.iterator]()):D,"%AsyncFromSyncIteratorPrototype%":D,"%AsyncFunction%":He,"%AsyncGenerator%":He,"%AsyncGeneratorFunction%":He,"%AsyncIteratorPrototype%":He,"%Atomics%":typeof Atomics>"u"?D:Atomics,"%BigInt%":typeof BigInt>"u"?D:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?D:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?D:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?D:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?D:Float32Array,"%Float64Array%":typeof Float64Array>"u"?D:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?D:FinalizationRegistry,"%Function%":En,"%GeneratorFunction%":He,"%Int8Array%":typeof Int8Array>"u"?D:Int8Array,"%Int16Array%":typeof Int16Array>"u"?D:Int16Array,"%Int32Array%":typeof Int32Array>"u"?D:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ke&&X?X(X([][Symbol.iterator]())):D,"%JSON%":typeof JSON=="object"?JSON:D,"%Map%":typeof Map>"u"?D:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ke||!X?D:X(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?D:Promise,"%Proxy%":typeof Proxy>"u"?D:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?D:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?D:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ke||!X?D:X(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?D:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ke&&X?X(""[Symbol.iterator]()):D,"%Symbol%":Ke?Symbol:D,"%SyntaxError%":nt,"%ThrowTypeError%":Do,"%TypedArray%":jo,"%TypeError%":rt,"%Uint8Array%":typeof Uint8Array>"u"?D:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?D:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?D:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?D:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?D:WeakMap,"%WeakRef%":typeof WeakRef>"u"?D:WeakRef,"%WeakSet%":typeof WeakSet>"u"?D:WeakSet};if(X)try{null.error}catch(t){var Mo=X(X(t));qe["%Error.prototype%"]=Mo}var Vo=function t(e){var r;if(e==="%AsyncFunction%")r=Dt("async function () {}");else if(e==="%GeneratorFunction%")r=Dt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Dt("async function* () {}");else if(e==="%AsyncGenerator%"){var o=t("%AsyncGeneratorFunction%");o&&(r=o.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&X&&(r=X(s.prototype))}return qe[e]=r,r},Lr={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},yt=wr,Tt=$o,qo=yt.call(Function.call,Array.prototype.concat),Qo=yt.call(Function.apply,Array.prototype.splice),Rr=yt.call(Function.call,String.prototype.replace),_t=yt.call(Function.call,String.prototype.slice),Go=yt.call(Function.call,RegExp.prototype.exec),zo=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ko=/\\(\\)?/g,Wo=function(e){var r=_t(e,0,1),o=_t(e,-1);if(r==="%"&&o!=="%")throw new nt("invalid intrinsic syntax, expected closing `%`");if(o==="%"&&r!=="%")throw new nt("invalid intrinsic syntax, expected opening `%`");var s=[];return Rr(e,zo,function(u,f,p,h){s[s.length]=p?Rr(h,Ko,"$1"):f||u}),s},Ho=function(e,r){var o=e,s;if(Tt(Lr,o)&&(s=Lr[o],o="%"+s[0]+"%"),Tt(qe,o)){var u=qe[o];if(u===He&&(u=Vo(o)),typeof u>"u"&&!r)throw new rt("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:o,value:u}}throw new nt("intrinsic "+e+" does not exist!")},ot=function(e,r){if(typeof e!="string"||e.length===0)throw new rt("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new rt('"allowMissing" argument must be a boolean');if(Go(/^%?[^%]*%?$/,e)===null)throw new nt("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var o=Wo(e),s=o.length>0?o[0]:"",u=Ho("%"+s+"%",r),f=u.name,p=u.value,h=!1,E=u.alias;E&&(s=E[0],Qo(o,qo([0,1],E)));for(var c=1,m=!0;c<o.length;c+=1){var A=o[c],T=_t(A,0,1),B=_t(A,-1);if((T==='"'||T==="'"||T==="`"||B==='"'||B==="'"||B==="`")&&T!==B)throw new nt("property names with quotes must have matching quotes");if((A==="constructor"||!m)&&(h=!0),s+="."+A,f="%"+s+"%",Tt(qe,f))p=qe[f];else if(p!=null){if(!(A in p)){if(!r)throw new rt("base intrinsic for "+e+" exists, but the property is not available.");return}if(Ve&&c+1>=o.length){var N=Ve(p,A);m=!!N,m&&"get"in N&&!("originalValue"in N.get)?p=N.get:p=p[A]}else m=Tt(p,A),p=p[A];m&&!h&&(qe[f]=p)}}return p},An={exports:{}},Jo=ot,er=Jo("%Object.defineProperty%",!0),tr=function(){if(er)try{return er({},"a",{value:1}),!0}catch{return!1}return!1};tr.hasArrayLengthDefineBug=function(){if(!tr())return null;try{return er([],"length",{value:1}).length!==1}catch{return!0}};var In=tr,Yo=ot,vt=Yo("%Object.getOwnPropertyDescriptor%",!0);if(vt)try{vt([],"length")}catch{vt=null}var br=vt,Xo=In(),vr=ot,dt=Xo&&vr("%Object.defineProperty%",!0);if(dt)try{dt({},"a",{value:1})}catch{dt=!1}var Zo=vr("%SyntaxError%"),We=vr("%TypeError%"),Nr=br,es=function(e,r,o){if(!e||typeof e!="object"&&typeof e!="function")throw new We("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new We("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new We("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new We("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new We("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new We("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,f=arguments.length>5?arguments[5]:null,p=arguments.length>6?arguments[6]:!1,h=!!Nr&&Nr(e,r);if(dt)dt(e,r,{configurable:f===null&&h?h.configurable:!f,enumerable:s===null&&h?h.enumerable:!s,value:o,writable:u===null&&h?h.writable:!u});else if(p||!s&&!u&&!f)e[r]=o;else throw new Zo("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Tn=ot,$r=es,ts=In(),Dr=br,Ur=Tn("%TypeError%"),rs=Tn("%Math.floor%"),ns=function(e,r){if(typeof e!="function")throw new Ur("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||rs(r)!==r)throw new Ur("`length` must be a positive 32-bit integer");var o=arguments.length>2&&!!arguments[2],s=!0,u=!0;if("length"in e&&Dr){var f=Dr(e,"length");f&&!f.configurable&&(s=!1),f&&!f.writable&&(u=!1)}return(s||u||!o)&&(ts?$r(e,"length",r,!0,!0):$r(e,"length",r)),e};(function(t){var e=wr,r=ot,o=ns,s=r("%TypeError%"),u=r("%Function.prototype.apply%"),f=r("%Function.prototype.call%"),p=r("%Reflect.apply%",!0)||e.call(f,u),h=r("%Object.defineProperty%",!0),E=r("%Math.max%");if(h)try{h({},"a",{value:1})}catch{h=null}t.exports=function(A){if(typeof A!="function")throw new s("a function is required");var T=p(e,f,arguments);return o(T,1+E(0,A.length-(arguments.length-1)),!0)};var c=function(){return p(e,u,arguments)};h?h(t.exports,"apply",{value:c}):t.exports.apply=c})(An);var _n=An.exports,On=ot,Fn=_n,is=Fn(On("String.prototype.indexOf")),Cn=function(e,r){var o=On(e,!!r);return typeof o=="function"&&is(e,".prototype.")>-1?Fn(o):o},os=mr(),ss=Cn,rr=ss("Object.prototype.toString"),Lt=function(e){return os&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:rr(e)==="[object Arguments]"},xn=function(e){return Lt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&rr(e)!=="[object Array]"&&rr(e.callee)==="[object Function]"},as=function(){return Lt(arguments)}();Lt.isLegacyArguments=xn;var us=as?Lt:xn,cs=Object.prototype.toString,ls=Function.prototype.toString,fs=/^\s*(?:function)?\*/,Bn=mr(),jt=Object.getPrototypeOf,ds=function(){if(!Bn)return!1;try{return Function("return function*() {}")()}catch{}},Mt,hs=function(e){if(typeof e!="function")return!1;if(fs.test(ls.call(e)))return!0;if(!Bn){var r=cs.call(e);return r==="[object GeneratorFunction]"}if(!jt)return!1;if(typeof Mt>"u"){var o=ds();Mt=o?jt(o):!1}return jt(e)===Mt},kn=Function.prototype.toString,Xe=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,nr,St;if(typeof Xe=="function"&&typeof Object.defineProperty=="function")try{nr=Object.defineProperty({},"length",{get:function(){throw St}}),St={},Xe(function(){throw 42},null,nr)}catch(t){t!==St&&(Xe=null)}else Xe=null;var ps=/^\s*class\b/,ir=function(e){try{var r=kn.call(e);return ps.test(r)}catch{return!1}},Vt=function(e){try{return ir(e)?!1:(kn.call(e),!0)}catch{return!1}},Et=Object.prototype.toString,ys="[object Object]",gs="[object Function]",ms="[object GeneratorFunction]",ws="[object HTMLAllCollection]",bs="[object HTML document.all class]",vs="[object HTMLCollection]",Ss=typeof Symbol=="function"&&!!Symbol.toStringTag,Es=!(0 in[,]),or=function(){return!1};if(typeof document=="object"){var As=document.all;Et.call(As)===Et.call(document.all)&&(or=function(e){if((Es||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=Et.call(e);return(r===ws||r===bs||r===vs||r===ys)&&e("")==null}catch{}return!1})}var Is=Xe?function(e){if(or(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{Xe(e,null,nr)}catch(r){if(r!==St)return!1}return!ir(e)&&Vt(e)}:function(e){if(or(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Ss)return Vt(e);if(ir(e))return!1;var r=Et.call(e);return r!==gs&&r!==ms&&!/^\[object HTML/.test(r)?!1:Vt(e)},Ts=Is,_s=Object.prototype.toString,Pn=Object.prototype.hasOwnProperty,Os=function(e,r,o){for(var s=0,u=e.length;s<u;s++)Pn.call(e,s)&&(o==null?r(e[s],s,e):r.call(o,e[s],s,e))},Fs=function(e,r,o){for(var s=0,u=e.length;s<u;s++)o==null?r(e.charAt(s),s,e):r.call(o,e.charAt(s),s,e)},Cs=function(e,r,o){for(var s in e)Pn.call(e,s)&&(o==null?r(e[s],s,e):r.call(o,e[s],s,e))},xs=function(e,r,o){if(!Ts(r))throw new TypeError("iterator must be a function");var s;arguments.length>=3&&(s=o),_s.call(e)==="[object Array]"?Os(e,r,s):typeof e=="string"?Fs(e,r,s):Cs(e,r,s)},Bs=xs,qt=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],ks=typeof globalThis>"u"?an:globalThis,Ps=function(){for(var e=[],r=0;r<qt.length;r++)typeof ks[qt[r]]=="function"&&(e[e.length]=qt[r]);return e},Ot=Bs,Ls=Ps,jr=_n,Sr=Cn,At=br,Rs=Sr("Object.prototype.toString"),Ln=mr(),Mr=typeof globalThis>"u"?an:globalThis,sr=Ls(),Er=Sr("String.prototype.slice"),Qt=Object.getPrototypeOf,Ns=Sr("Array.prototype.indexOf",!0)||function(e,r){for(var o=0;o<e.length;o+=1)if(e[o]===r)return o;return-1},Ft={__proto__:null};Ln&&At&&Qt?Ot(sr,function(t){var e=new Mr[t];if(Symbol.toStringTag in e){var r=Qt(e),o=At(r,Symbol.toStringTag);if(!o){var s=Qt(r);o=At(s,Symbol.toStringTag)}Ft["$"+t]=jr(o.get)}}):Ot(sr,function(t){var e=new Mr[t],r=e.slice||e.set;r&&(Ft["$"+t]=jr(r))});var $s=function(e){var r=!1;return Ot(Ft,function(o,s){if(!r)try{"$"+o(e)===s&&(r=Er(s,1))}catch{}}),r},Ds=function(e){var r=!1;return Ot(Ft,function(o,s){if(!r)try{o(e),r=Er(s,1)}catch{}}),r},Rn=function(e){if(!e||typeof e!="object")return!1;if(!Ln){var r=Er(Rs(e),8,-1);return Ns(sr,r)>-1?r:r!=="Object"?!1:Ds(e)}return At?$s(e):null},Us=Rn,js=function(e){return!!Us(e)};(function(t){var e=us,r=hs,o=Rn,s=js;function u(S){return S.call.bind(S)}var f=typeof BigInt<"u",p=typeof Symbol<"u",h=u(Object.prototype.toString),E=u(Number.prototype.valueOf),c=u(String.prototype.valueOf),m=u(Boolean.prototype.valueOf);if(f)var A=u(BigInt.prototype.valueOf);if(p)var T=u(Symbol.prototype.valueOf);function B(S,ut){if(typeof S!="object")return!1;try{return ut(S),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=s;function N(S){return typeof Promise<"u"&&S instanceof Promise||S!==null&&typeof S=="object"&&typeof S.then=="function"&&typeof S.catch=="function"}t.isPromise=N;function G(S){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(S):s(S)||b(S)}t.isArrayBufferView=G;function I(S){return o(S)==="Uint8Array"}t.isUint8Array=I;function F(S){return o(S)==="Uint8ClampedArray"}t.isUint8ClampedArray=F;function j(S){return o(S)==="Uint16Array"}t.isUint16Array=j;function L(S){return o(S)==="Uint32Array"}t.isUint32Array=L;function O(S){return o(S)==="Int8Array"}t.isInt8Array=O;function C(S){return o(S)==="Int16Array"}t.isInt16Array=C;function x(S){return o(S)==="Int32Array"}t.isInt32Array=x;function V(S){return o(S)==="Float32Array"}t.isFloat32Array=V;function ie(S){return o(S)==="Float64Array"}t.isFloat64Array=ie;function we(S){return o(S)==="BigInt64Array"}t.isBigInt64Array=we;function be(S){return o(S)==="BigUint64Array"}t.isBigUint64Array=be;function ae(S){return h(S)==="[object Map]"}ae.working=typeof Map<"u"&&ae(new Map);function at(S){return typeof Map>"u"?!1:ae.working?ae(S):S instanceof Map}t.isMap=at;function de(S){return h(S)==="[object Set]"}de.working=typeof Set<"u"&&de(new Set);function Re(S){return typeof Set>"u"?!1:de.working?de(S):S instanceof Set}t.isSet=Re;function xe(S){return h(S)==="[object WeakMap]"}xe.working=typeof WeakMap<"u"&&xe(new WeakMap);function Qe(S){return typeof WeakMap>"u"?!1:xe.working?xe(S):S instanceof WeakMap}t.isWeakMap=Qe;function ve(S){return h(S)==="[object WeakSet]"}ve.working=typeof WeakSet<"u"&&ve(new WeakSet);function ue(S){return ve(S)}t.isWeakSet=ue;function Be(S){return h(S)==="[object ArrayBuffer]"}Be.working=typeof ArrayBuffer<"u"&&Be(new ArrayBuffer);function Ge(S){return typeof ArrayBuffer>"u"?!1:Be.working?Be(S):S instanceof ArrayBuffer}t.isArrayBuffer=Ge;function g(S){return h(S)==="[object DataView]"}g.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&g(new DataView(new ArrayBuffer(1),0,1));function b(S){return typeof DataView>"u"?!1:g.working?g(S):S instanceof DataView}t.isDataView=b;var v=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function _(S){return h(S)==="[object SharedArrayBuffer]"}function U(S){return typeof v>"u"?!1:(typeof _.working>"u"&&(_.working=_(new v)),_.working?_(S):S instanceof v)}t.isSharedArrayBuffer=U;function M(S){return h(S)==="[object AsyncFunction]"}t.isAsyncFunction=M;function P(S){return h(S)==="[object Map Iterator]"}t.isMapIterator=P;function $(S){return h(S)==="[object Set Iterator]"}t.isSetIterator=$;function q(S){return h(S)==="[object Generator]"}t.isGeneratorObject=q;function J(S){return h(S)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=J;function ce(S){return B(S,E)}t.isNumberObject=ce;function Ne(S){return B(S,c)}t.isStringObject=Ne;function ke(S){return B(S,m)}t.isBooleanObject=ke;function $e(S){return f&&B(S,A)}t.isBigIntObject=$e;function Se(S){return p&&B(S,T)}t.isSymbolObject=Se;function De(S){return ce(S)||Ne(S)||ke(S)||$e(S)||Se(S)}t.isBoxedPrimitive=De;function Rt(S){return typeof Uint8Array<"u"&&(Ge(S)||U(S))}t.isAnyArrayBuffer=Rt,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(S){Object.defineProperty(t,S,{enumerable:!1,value:function(){throw new Error(S+" is not supported in userland")}})})})(vn);var Ms=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},ar={exports:{}};typeof Object.create=="function"?ar.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ar.exports=function(e,r){if(r){e.super_=r;var o=function(){};o.prototype=r.prototype,e.prototype=new o,e.prototype.constructor=e}};var Vs=ar.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(b){for(var v=Object.keys(b),_={},U=0;U<v.length;U++)_[v[U]]=Object.getOwnPropertyDescriptor(b,v[U]);return _},r=/%[sdj%]/g;t.format=function(g){if(!O(g)){for(var b=[],v=0;v<arguments.length;v++)b.push(f(arguments[v]));return b.join(" ")}for(var v=1,_=arguments,U=_.length,M=String(g).replace(r,function($){if($==="%%")return"%";if(v>=U)return $;switch($){case"%s":return String(_[v++]);case"%d":return Number(_[v++]);case"%j":try{return JSON.stringify(_[v++])}catch{return"[Circular]"}default:return $}}),P=_[v];v<U;P=_[++v])F(P)||!ie(P)?M+=" "+P:M+=" "+f(P);return M},t.deprecate=function(g,b){if(typeof k<"u"&&k.noDeprecation===!0)return g;if(typeof k>"u")return function(){return t.deprecate(g,b).apply(this,arguments)};var v=!1;function _(){if(!v){if(k.throwDeprecation)throw new Error(b);k.traceDeprecation?console.trace(b):console.error(b),v=!0}return g.apply(this,arguments)}return _};var o={},s=/^$/;if(k.env.NODE_DEBUG){var u=k.env.NODE_DEBUG;u=u.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+u+"$","i")}t.debuglog=function(g){if(g=g.toUpperCase(),!o[g])if(s.test(g)){var b=k.pid;o[g]=function(){var v=t.format.apply(t,arguments);console.error("%s %d: %s",g,b,v)}}else o[g]=function(){};return o[g]};function f(g,b){var v={seen:[],stylize:h};return arguments.length>=3&&(v.depth=arguments[2]),arguments.length>=4&&(v.colors=arguments[3]),I(b)?v.showHidden=b:b&&t._extend(v,b),x(v.showHidden)&&(v.showHidden=!1),x(v.depth)&&(v.depth=2),x(v.colors)&&(v.colors=!1),x(v.customInspect)&&(v.customInspect=!0),v.colors&&(v.stylize=p),c(v,g,v.depth)}t.inspect=f,f.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]},f.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function p(g,b){var v=f.styles[b];return v?"\x1B["+f.colors[v][0]+"m"+g+"\x1B["+f.colors[v][1]+"m":g}function h(g,b){return g}function E(g){var b={};return g.forEach(function(v,_){b[v]=!0}),b}function c(g,b,v){if(g.customInspect&&b&&ae(b.inspect)&&b.inspect!==t.inspect&&!(b.constructor&&b.constructor.prototype===b)){var _=b.inspect(v,g);return O(_)||(_=c(g,_,v)),_}var U=m(g,b);if(U)return U;var M=Object.keys(b),P=E(M);if(g.showHidden&&(M=Object.getOwnPropertyNames(b)),be(b)&&(M.indexOf("message")>=0||M.indexOf("description")>=0))return A(b);if(M.length===0){if(ae(b)){var $=b.name?": "+b.name:"";return g.stylize("[Function"+$+"]","special")}if(V(b))return g.stylize(RegExp.prototype.toString.call(b),"regexp");if(we(b))return g.stylize(Date.prototype.toString.call(b),"date");if(be(b))return A(b)}var q="",J=!1,ce=["{","}"];if(G(b)&&(J=!0,ce=["[","]"]),ae(b)){var Ne=b.name?": "+b.name:"";q=" [Function"+Ne+"]"}if(V(b)&&(q=" "+RegExp.prototype.toString.call(b)),we(b)&&(q=" "+Date.prototype.toUTCString.call(b)),be(b)&&(q=" "+A(b)),M.length===0&&(!J||b.length==0))return ce[0]+q+ce[1];if(v<0)return V(b)?g.stylize(RegExp.prototype.toString.call(b),"regexp"):g.stylize("[Object]","special");g.seen.push(b);var ke;return J?ke=T(g,b,v,P,M):ke=M.map(function($e){return B(g,b,v,P,$e,J)}),g.seen.pop(),N(ke,q,ce)}function m(g,b){if(x(b))return g.stylize("undefined","undefined");if(O(b)){var v="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return g.stylize(v,"string")}if(L(b))return g.stylize(""+b,"number");if(I(b))return g.stylize(""+b,"boolean");if(F(b))return g.stylize("null","null")}function A(g){return"["+Error.prototype.toString.call(g)+"]"}function T(g,b,v,_,U){for(var M=[],P=0,$=b.length;P<$;++P)ve(b,String(P))?M.push(B(g,b,v,_,String(P),!0)):M.push("");return U.forEach(function(q){q.match(/^\d+$/)||M.push(B(g,b,v,_,q,!0))}),M}function B(g,b,v,_,U,M){var P,$,q;if(q=Object.getOwnPropertyDescriptor(b,U)||{value:b[U]},q.get?q.set?$=g.stylize("[Getter/Setter]","special"):$=g.stylize("[Getter]","special"):q.set&&($=g.stylize("[Setter]","special")),ve(_,U)||(P="["+U+"]"),$||(g.seen.indexOf(q.value)<0?(F(v)?$=c(g,q.value,null):$=c(g,q.value,v-1),$.indexOf(`
|
|
7
|
-
`)>-1&&(
|
|
7
|
+
*/(function(t){const e=kt,r=hr,i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=l,t.SlowBuffer=C,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s;const{Uint8Array:u,ArrayBuffer:f,SharedArrayBuffer:p}=globalThis;l.TYPED_ARRAY_SUPPORT=h(),!l.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{const a=new u(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,u.prototype),Object.setPrototypeOf(a,n),a.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function m(a){if(a>s)throw new RangeError('The value "'+a+'" is invalid for option "size"');const n=new u(a);return Object.setPrototypeOf(n,l.prototype),n}function l(a,n,o){if(typeof a=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(a)}return w(a,n,o)}l.poolSize=8192;function w(a,n,o){if(typeof a=="string")return B(a,n);if(f.isView(a))return I(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(pe(a,f)||a&&pe(a.buffer,f)||typeof p<"u"&&(pe(a,p)||a&&pe(a.buffer,p)))return F(a,n,o);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const c=a.valueOf&&a.valueOf();if(c!=null&&c!==a)return l.from(c,n,o);const d=U(a);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return l.from(a[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}l.from=function(a,n,o){return w(a,n,o)},Object.setPrototypeOf(l.prototype,u.prototype),Object.setPrototypeOf(l,u);function E(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function T(a,n,o){return E(a),a<=0?m(a):n!==void 0?typeof o=="string"?m(a).fill(n,o):m(a).fill(n):m(a)}l.alloc=function(a,n,o){return T(a,n,o)};function _(a){return E(a),m(a<0?0:L(a)|0)}l.allocUnsafe=function(a){return _(a)},l.allocUnsafeSlow=function(a){return _(a)};function B(a,n){if((typeof n!="string"||n==="")&&(n="utf8"),!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const o=x(a,n)|0;let c=m(o);const d=c.write(a,n);return d!==o&&(c=c.slice(0,d)),c}function M(a){const n=a.length<0?0:L(a.length)|0,o=m(n);for(let c=0;c<n;c+=1)o[c]=a[c]&255;return o}function I(a){if(pe(a,u)){const n=new u(a);return F(n.buffer,n.byteOffset,n.byteLength)}return M(a)}function F(a,n,o){if(n<0||a.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<n+(o||0))throw new RangeError('"length" is outside of buffer bounds');let c;return n===void 0&&o===void 0?c=new u(a):o===void 0?c=new u(a,n):c=new u(a,n,o),Object.setPrototypeOf(c,l.prototype),c}function U(a){if(l.isBuffer(a)){const n=L(a.length)|0,o=m(n);return o.length===0||a.copy(o,0,0,n),o}if(a.length!==void 0)return typeof a.length!="number"||Dt(a.length)?m(0):M(a);if(a.type==="Buffer"&&Array.isArray(a.data))return M(a.data)}function L(a){if(a>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return a|0}function C(a){return+a!=a&&(a=0),l.alloc(+a)}l.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==l.prototype},l.compare=function(n,o){if(pe(n,u)&&(n=l.from(n,n.offset,n.byteLength)),pe(o,u)&&(o=l.from(o,o.offset,o.byteLength)),!l.isBuffer(n)||!l.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===o)return 0;let c=n.length,d=o.length;for(let y=0,b=Math.min(c,d);y<b;++y)if(n[y]!==o[y]){c=n[y],d=o[y];break}return c<d?-1:d<c?1:0},l.isEncoding=function(n){switch(String(n).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(n,o){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return l.alloc(0);let c;if(o===void 0)for(o=0,c=0;c<n.length;++c)o+=n[c].length;const d=l.allocUnsafe(o);let y=0;for(c=0;c<n.length;++c){let b=n[c];if(pe(b,u))y+b.length>d.length?(l.isBuffer(b)||(b=l.from(b)),b.copy(d,y)):u.prototype.set.call(d,b,y);else if(l.isBuffer(b))b.copy(d,y);else throw new TypeError('"list" argument must be an Array of Buffers');y+=b.length}return d};function x(a,n){if(l.isBuffer(a))return a.length;if(f.isView(a)||pe(a,f))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);const o=a.length,c=arguments.length>2&&arguments[2]===!0;if(!c&&o===0)return 0;let d=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return lt(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return Fr(a).length;default:if(d)return c?-1:lt(a).length;n=(""+n).toLowerCase(),d=!0}}l.byteLength=x;function k(a,n,o){let c=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,n>>>=0,o<=n))return"";for(a||(a="utf8");;)switch(a){case"hex":return g(this,n,o);case"utf8":case"utf-8":return Ge(this,n,o);case"ascii":return Be(this,n,o);case"latin1":case"binary":return ze(this,n,o);case"base64":return xe(this,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,n,o);default:if(c)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),c=!0}}l.prototype._isBuffer=!0;function q(a,n,o){const c=a[n];a[n]=a[o],a[o]=c}l.prototype.swap16=function(){const n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<n;o+=2)q(this,o,o+1);return this},l.prototype.swap32=function(){const n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<n;o+=4)q(this,o,o+3),q(this,o+1,o+2);return this},l.prototype.swap64=function(){const n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<n;o+=8)q(this,o,o+7),q(this,o+1,o+6),q(this,o+2,o+5),q(this,o+3,o+4);return this},l.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?Ge(this,0,n):k.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(n){if(!l.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:l.compare(this,n)===0},l.prototype.inspect=function(){let n="";const o=t.INSPECT_MAX_BYTES;return n=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(n+=" ... "),"<Buffer "+n+">"},i&&(l.prototype[i]=l.prototype.inspect),l.prototype.compare=function(n,o,c,d,y){if(pe(n,u)&&(n=l.from(n,n.offset,n.byteLength)),!l.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(o===void 0&&(o=0),c===void 0&&(c=n?n.length:0),d===void 0&&(d=0),y===void 0&&(y=this.length),o<0||c>n.length||d<0||y>this.length)throw new RangeError("out of range index");if(d>=y&&o>=c)return 0;if(d>=y)return-1;if(o>=c)return 1;if(o>>>=0,c>>>=0,d>>>=0,y>>>=0,this===n)return 0;let b=y-d,N=c-o;const W=Math.min(b,N),K=this.slice(d,y),H=n.slice(o,c);for(let z=0;z<W;++z)if(K[z]!==H[z]){b=K[z],N=H[z];break}return b<N?-1:N<b?1:0};function ie(a,n,o,c,d){if(a.length===0)return-1;if(typeof o=="string"?(c=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,Dt(o)&&(o=d?0:a.length-1),o<0&&(o=a.length+o),o>=a.length){if(d)return-1;o=a.length-1}else if(o<0)if(d)o=0;else return-1;if(typeof n=="string"&&(n=l.from(n,c)),l.isBuffer(n))return n.length===0?-1:we(a,n,o,c,d);if(typeof n=="number")return n=n&255,typeof u.prototype.indexOf=="function"?d?u.prototype.indexOf.call(a,n,o):u.prototype.lastIndexOf.call(a,n,o):we(a,[n],o,c,d);throw new TypeError("val must be string, number or Buffer")}function we(a,n,o,c,d){let y=1,b=a.length,N=n.length;if(c!==void 0&&(c=String(c).toLowerCase(),c==="ucs2"||c==="ucs-2"||c==="utf16le"||c==="utf-16le")){if(a.length<2||n.length<2)return-1;y=2,b/=2,N/=2,o/=2}function W(H,z){return y===1?H[z]:H.readUInt16BE(z*y)}let K;if(d){let H=-1;for(K=o;K<b;K++)if(W(a,K)===W(n,H===-1?0:K-H)){if(H===-1&&(H=K),K-H+1===N)return H*y}else H!==-1&&(K-=K-H),H=-1}else for(o+N>b&&(o=b-N),K=o;K>=0;K--){let H=!0;for(let z=0;z<N;z++)if(W(a,K+z)!==W(n,z)){H=!1;break}if(H)return K}return-1}l.prototype.includes=function(n,o,c){return this.indexOf(n,o,c)!==-1},l.prototype.indexOf=function(n,o,c){return ie(this,n,o,c,!0)},l.prototype.lastIndexOf=function(n,o,c){return ie(this,n,o,c,!1)};function be(a,n,o,c){o=Number(o)||0;const d=a.length-o;c?(c=Number(c),c>d&&(c=d)):c=d;const y=n.length;c>y/2&&(c=y/2);let b;for(b=0;b<c;++b){const N=parseInt(n.substr(b*2,2),16);if(Dt(N))return b;a[o+b]=N}return b}function ue(a,n,o,c){return mt(lt(n,a.length-o),a,o,c)}function ct(a,n,o,c){return mt(_r(n),a,o,c)}function he(a,n,o,c){return mt(Fr(n),a,o,c)}function Re(a,n,o,c){return mt(Vn(n,a.length-o),a,o,c)}l.prototype.write=function(n,o,c,d){if(o===void 0)d="utf8",c=this.length,o=0;else if(c===void 0&&typeof o=="string")d=o,c=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(c)?(c=c>>>0,d===void 0&&(d="utf8")):(d=c,c=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const y=this.length-o;if((c===void 0||c>y)&&(c=y),n.length>0&&(c<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let b=!1;for(;;)switch(d){case"hex":return be(this,n,o,c);case"utf8":case"utf-8":return ue(this,n,o,c);case"ascii":case"latin1":case"binary":return ct(this,n,o,c);case"base64":return he(this,n,o,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Re(this,n,o,c);default:if(b)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),b=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function xe(a,n,o){return n===0&&o===a.length?e.fromByteArray(a):e.fromByteArray(a.slice(n,o))}function Ge(a,n,o){o=Math.min(a.length,o);const c=[];let d=n;for(;d<o;){const y=a[d];let b=null,N=y>239?4:y>223?3:y>191?2:1;if(d+N<=o){let W,K,H,z;switch(N){case 1:y<128&&(b=y);break;case 2:W=a[d+1],(W&192)===128&&(z=(y&31)<<6|W&63,z>127&&(b=z));break;case 3:W=a[d+1],K=a[d+2],(W&192)===128&&(K&192)===128&&(z=(y&15)<<12|(W&63)<<6|K&63,z>2047&&(z<55296||z>57343)&&(b=z));break;case 4:W=a[d+1],K=a[d+2],H=a[d+3],(W&192)===128&&(K&192)===128&&(H&192)===128&&(z=(y&15)<<18|(W&63)<<12|(K&63)<<6|H&63,z>65535&&z<1114112&&(b=z))}}b===null?(b=65533,N=1):b>65535&&(b-=65536,c.push(b>>>10&1023|55296),b=56320|b&1023),c.push(b),d+=N}return ce(c)}const ve=4096;function ce(a){const n=a.length;if(n<=ve)return String.fromCharCode.apply(String,a);let o="",c=0;for(;c<n;)o+=String.fromCharCode.apply(String,a.slice(c,c+=ve));return o}function Be(a,n,o){let c="";o=Math.min(a.length,o);for(let d=n;d<o;++d)c+=String.fromCharCode(a[d]&127);return c}function ze(a,n,o){let c="";o=Math.min(a.length,o);for(let d=n;d<o;++d)c+=String.fromCharCode(a[d]);return c}function g(a,n,o){const c=a.length;(!n||n<0)&&(n=0),(!o||o<0||o>c)&&(o=c);let d="";for(let y=n;y<o;++y)d+=qn[a[y]];return d}function v(a,n,o){const c=a.slice(n,o);let d="";for(let y=0;y<c.length-1;y+=2)d+=String.fromCharCode(c[y]+c[y+1]*256);return d}l.prototype.slice=function(n,o){const c=this.length;n=~~n,o=o===void 0?c:~~o,n<0?(n+=c,n<0&&(n=0)):n>c&&(n=c),o<0?(o+=c,o<0&&(o=0)):o>c&&(o=c),o<n&&(o=n);const d=this.subarray(n,o);return Object.setPrototypeOf(d,l.prototype),d};function S(a,n,o){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+n>o)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(n,o,c){n=n>>>0,o=o>>>0,c||S(n,o,this.length);let d=this[n],y=1,b=0;for(;++b<o&&(y*=256);)d+=this[n+b]*y;return d},l.prototype.readUintBE=l.prototype.readUIntBE=function(n,o,c){n=n>>>0,o=o>>>0,c||S(n,o,this.length);let d=this[n+--o],y=1;for(;o>0&&(y*=256);)d+=this[n+--o]*y;return d},l.prototype.readUint8=l.prototype.readUInt8=function(n,o){return n=n>>>0,o||S(n,1,this.length),this[n]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(n,o){return n=n>>>0,o||S(n,2,this.length),this[n]|this[n+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(n,o){return n=n>>>0,o||S(n,2,this.length),this[n]<<8|this[n+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(n,o){return n=n>>>0,o||S(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(n,o){return n=n>>>0,o||S(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},l.prototype.readBigUInt64LE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],c=this[n+7];(o===void 0||c===void 0)&&$e(n,this.length-8);const d=o+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,y=this[++n]+this[++n]*2**8+this[++n]*2**16+c*2**24;return BigInt(d)+(BigInt(y)<<BigInt(32))}),l.prototype.readBigUInt64BE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],c=this[n+7];(o===void 0||c===void 0)&&$e(n,this.length-8);const d=o*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],y=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+c;return(BigInt(d)<<BigInt(32))+BigInt(y)}),l.prototype.readIntLE=function(n,o,c){n=n>>>0,o=o>>>0,c||S(n,o,this.length);let d=this[n],y=1,b=0;for(;++b<o&&(y*=256);)d+=this[n+b]*y;return y*=128,d>=y&&(d-=Math.pow(2,8*o)),d},l.prototype.readIntBE=function(n,o,c){n=n>>>0,o=o>>>0,c||S(n,o,this.length);let d=o,y=1,b=this[n+--d];for(;d>0&&(y*=256);)b+=this[n+--d]*y;return y*=128,b>=y&&(b-=Math.pow(2,8*o)),b},l.prototype.readInt8=function(n,o){return n=n>>>0,o||S(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},l.prototype.readInt16LE=function(n,o){n=n>>>0,o||S(n,2,this.length);const c=this[n]|this[n+1]<<8;return c&32768?c|4294901760:c},l.prototype.readInt16BE=function(n,o){n=n>>>0,o||S(n,2,this.length);const c=this[n+1]|this[n]<<8;return c&32768?c|4294901760:c},l.prototype.readInt32LE=function(n,o){return n=n>>>0,o||S(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},l.prototype.readInt32BE=function(n,o){return n=n>>>0,o||S(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},l.prototype.readBigInt64LE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],c=this[n+7];(o===void 0||c===void 0)&&$e(n,this.length-8);const d=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(c<<24);return(BigInt(d)<<BigInt(32))+BigInt(o+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),l.prototype.readBigInt64BE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],c=this[n+7];(o===void 0||c===void 0)&&$e(n,this.length-8);const d=(o<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(d)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+c)}),l.prototype.readFloatLE=function(n,o){return n=n>>>0,o||S(n,4,this.length),r.read(this,n,!0,23,4)},l.prototype.readFloatBE=function(n,o){return n=n>>>0,o||S(n,4,this.length),r.read(this,n,!1,23,4)},l.prototype.readDoubleLE=function(n,o){return n=n>>>0,o||S(n,8,this.length),r.read(this,n,!0,52,8)},l.prototype.readDoubleBE=function(n,o){return n=n>>>0,o||S(n,8,this.length),r.read(this,n,!1,52,8)};function O(a,n,o,c,d,y){if(!l.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>d||n<y)throw new RangeError('"value" argument is out of bounds');if(o+c>a.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(n,o,c,d){if(n=+n,o=o>>>0,c=c>>>0,!d){const N=Math.pow(2,8*c)-1;O(this,n,o,c,N,0)}let y=1,b=0;for(this[o]=n&255;++b<c&&(y*=256);)this[o+b]=n/y&255;return o+c},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(n,o,c,d){if(n=+n,o=o>>>0,c=c>>>0,!d){const N=Math.pow(2,8*c)-1;O(this,n,o,c,N,0)}let y=c-1,b=1;for(this[o+y]=n&255;--y>=0&&(b*=256);)this[o+y]=n/b&255;return o+c},l.prototype.writeUint8=l.prototype.writeUInt8=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,1,255,0),this[o]=n&255,o+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,2,65535,0),this[o]=n&255,this[o+1]=n>>>8,o+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,2,65535,0),this[o]=n>>>8,this[o+1]=n&255,o+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,4,4294967295,0),this[o+3]=n>>>24,this[o+2]=n>>>16,this[o+1]=n>>>8,this[o]=n&255,o+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,4,4294967295,0),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4};function j(a,n,o,c,d){De(n,c,d,a,o,7);let y=Number(n&BigInt(4294967295));a[o++]=y,y=y>>8,a[o++]=y,y=y>>8,a[o++]=y,y=y>>8,a[o++]=y;let b=Number(n>>BigInt(32)&BigInt(4294967295));return a[o++]=b,b=b>>8,a[o++]=b,b=b>>8,a[o++]=b,b=b>>8,a[o++]=b,o}function V(a,n,o,c,d){De(n,c,d,a,o,7);let y=Number(n&BigInt(4294967295));a[o+7]=y,y=y>>8,a[o+6]=y,y=y>>8,a[o+5]=y,y=y>>8,a[o+4]=y;let b=Number(n>>BigInt(32)&BigInt(4294967295));return a[o+3]=b,b=b>>8,a[o+2]=b,b=b>>8,a[o+1]=b,b=b>>8,a[o]=b,o+8}l.prototype.writeBigUInt64LE=Pe(function(n,o=0){return j(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeBigUInt64BE=Pe(function(n,o=0){return V(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeIntLE=function(n,o,c,d){if(n=+n,o=o>>>0,!d){const W=Math.pow(2,8*c-1);O(this,n,o,c,W-1,-W)}let y=0,b=1,N=0;for(this[o]=n&255;++y<c&&(b*=256);)n<0&&N===0&&this[o+y-1]!==0&&(N=1),this[o+y]=(n/b>>0)-N&255;return o+c},l.prototype.writeIntBE=function(n,o,c,d){if(n=+n,o=o>>>0,!d){const W=Math.pow(2,8*c-1);O(this,n,o,c,W-1,-W)}let y=c-1,b=1,N=0;for(this[o+y]=n&255;--y>=0&&(b*=256);)n<0&&N===0&&this[o+y+1]!==0&&(N=1),this[o+y]=(n/b>>0)-N&255;return o+c},l.prototype.writeInt8=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,1,127,-128),n<0&&(n=255+n+1),this[o]=n&255,o+1},l.prototype.writeInt16LE=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,2,32767,-32768),this[o]=n&255,this[o+1]=n>>>8,o+2},l.prototype.writeInt16BE=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,2,32767,-32768),this[o]=n>>>8,this[o+1]=n&255,o+2},l.prototype.writeInt32LE=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,4,2147483647,-2147483648),this[o]=n&255,this[o+1]=n>>>8,this[o+2]=n>>>16,this[o+3]=n>>>24,o+4},l.prototype.writeInt32BE=function(n,o,c){return n=+n,o=o>>>0,c||O(this,n,o,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4},l.prototype.writeBigInt64LE=Pe(function(n,o=0){return j(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),l.prototype.writeBigInt64BE=Pe(function(n,o=0){return V(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function R(a,n,o,c,d,y){if(o+c>a.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function D(a,n,o,c,d){return n=+n,o=o>>>0,d||R(a,n,o,4),r.write(a,n,o,c,23,4),o+4}l.prototype.writeFloatLE=function(n,o,c){return D(this,n,o,!0,c)},l.prototype.writeFloatBE=function(n,o,c){return D(this,n,o,!1,c)};function Q(a,n,o,c,d){return n=+n,o=o>>>0,d||R(a,n,o,8),r.write(a,n,o,c,52,8),o+8}l.prototype.writeDoubleLE=function(n,o,c){return Q(this,n,o,!0,c)},l.prototype.writeDoubleBE=function(n,o,c){return Q(this,n,o,!1,c)},l.prototype.copy=function(n,o,c,d){if(!l.isBuffer(n))throw new TypeError("argument should be a Buffer");if(c||(c=0),!d&&d!==0&&(d=this.length),o>=n.length&&(o=n.length),o||(o=0),d>0&&d<c&&(d=c),d===c||n.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),n.length-o<d-c&&(d=n.length-o+c);const y=d-c;return this===n&&typeof u.prototype.copyWithin=="function"?this.copyWithin(o,c,d):u.prototype.set.call(n,this.subarray(c,d),o),y},l.prototype.fill=function(n,o,c,d){if(typeof n=="string"){if(typeof o=="string"?(d=o,o=0,c=this.length):typeof c=="string"&&(d=c,c=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!l.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(n.length===1){const b=n.charCodeAt(0);(d==="utf8"&&b<128||d==="latin1")&&(n=b)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(o<0||this.length<o||this.length<c)throw new RangeError("Out of range index");if(c<=o)return this;o=o>>>0,c=c===void 0?this.length:c>>>0,n||(n=0);let y;if(typeof n=="number")for(y=o;y<c;++y)this[y]=n;else{const b=l.isBuffer(n)?n:l.from(n,d),N=b.length;if(N===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(y=0;y<c-o;++y)this[y+o]=b[y%N]}return this};const J={};function le(a,n,o){J[a]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}}}le("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),le("ERR_INVALID_ARG_TYPE",function(a,n){return`The "${a}" argument must be of type number. Received type ${typeof n}`},TypeError),le("ERR_OUT_OF_RANGE",function(a,n,o){let c=`The value of "${a}" is out of range.`,d=o;return Number.isInteger(o)&&Math.abs(o)>2**32?d=Ne(String(o)):typeof o=="bigint"&&(d=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(d=Ne(d)),d+="n"),c+=` It must be ${n}. Received ${d}`,c},RangeError);function Ne(a){let n="",o=a.length;const c=a[0]==="-"?1:0;for(;o>=c+4;o-=3)n=`_${a.slice(o-3,o)}${n}`;return`${a.slice(0,o)}${n}`}function ke(a,n,o){Se(n,"offset"),(a[n]===void 0||a[n+o]===void 0)&&$e(n,a.length-(o+1))}function De(a,n,o,c,d,y){if(a>o||a<n){const b=typeof n=="bigint"?"n":"";let N;throw y>3?n===0||n===BigInt(0)?N=`>= 0${b} and < 2${b} ** ${(y+1)*8}${b}`:N=`>= -(2${b} ** ${(y+1)*8-1}${b}) and < 2 ** ${(y+1)*8-1}${b}`:N=`>= ${n}${b} and <= ${o}${b}`,new J.ERR_OUT_OF_RANGE("value",N,a)}ke(c,d,y)}function Se(a,n){if(typeof a!="number")throw new J.ERR_INVALID_ARG_TYPE(n,"number",a)}function $e(a,n,o){throw Math.floor(a)!==a?(Se(a,o),new J.ERR_OUT_OF_RANGE(o||"offset","an integer",a)):n<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(o||"offset",`>= ${o?1:0} and <= ${n}`,a)}const Nt=/[^+/0-9A-Za-z-_]/g;function A(a){if(a=a.split("=")[0],a=a.trim().replace(Nt,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}function lt(a,n){n=n||1/0;let o;const c=a.length;let d=null;const y=[];for(let b=0;b<c;++b){if(o=a.charCodeAt(b),o>55295&&o<57344){if(!d){if(o>56319){(n-=3)>-1&&y.push(239,191,189);continue}else if(b+1===c){(n-=3)>-1&&y.push(239,191,189);continue}d=o;continue}if(o<56320){(n-=3)>-1&&y.push(239,191,189),d=o;continue}o=(d-55296<<10|o-56320)+65536}else d&&(n-=3)>-1&&y.push(239,191,189);if(d=null,o<128){if((n-=1)<0)break;y.push(o)}else if(o<2048){if((n-=2)<0)break;y.push(o>>6|192,o&63|128)}else if(o<65536){if((n-=3)<0)break;y.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((n-=4)<0)break;y.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return y}function _r(a){const n=[];for(let o=0;o<a.length;++o)n.push(a.charCodeAt(o)&255);return n}function Vn(a,n){let o,c,d;const y=[];for(let b=0;b<a.length&&!((n-=2)<0);++b)o=a.charCodeAt(b),c=o>>8,d=o%256,y.push(d),y.push(c);return y}function Fr(a){return e.toByteArray(A(a))}function mt(a,n,o,c){let d;for(d=0;d<c&&!(d+o>=n.length||d>=a.length);++d)n[d+o]=a[d];return d}function pe(a,n){return a instanceof n||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===n.name}function Dt(a){return a!==a}const qn=function(){const a="0123456789abcdef",n=new Array(256);for(let o=0;o<16;++o){const c=o*16;for(let d=0;d<16;++d)n[c+d]=a[o]+a[d]}return n}();function Pe(a){return typeof BigInt>"u"?Qn:a}function Qn(){throw new Error("BigInt not supported")}})(an);const xr=an.Buffer;var cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ui(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var pr={exports:{}};const ji=Object.getPrototypeOf({});function yr(t){function e(I){return I!=="constructor"&&I!=="prototype"&&I!=="__proto__"}function r(I){let F=0;const U=I.length,L=new Array(U);for(F=0;F<U;++F)L[F]=T(I[F]);return L}function i(I){const F={};if(h&&Object.getPrototypeOf(I)!==ji)return h(I);const U=p(I);let L,C,x;for(L=0,C=U.length;L<C;++L)e(x=U[L])&&(F[x]=T(I[x]));return F}function s(I,F){const U=I.length,L=F.length;let C=0;const x=new Array(U+L);for(C=0;C<U;++C)x[C]=T(I[C]);for(C=0;C<L;++C)x[C+U]=T(F[C]);return x}const u=Object.prototype.propertyIsEnumerable;function f(I){const F=Object.keys(I),U=Object.getOwnPropertySymbols(I);for(let L=0,C=U.length;L<C;++L)u.call(I,U[L])&&F.push(U[L]);return F}const p=t&&t.symbols?f:Object.keys,h=typeof t?.cloneProtoObject=="function"?t.cloneProtoObject:void 0;function m(I){return typeof I=="object"&&I!==null&&!(I instanceof RegExp)&&!(I instanceof Date)}function l(I){return typeof I!="object"||I===null}const w=typeof xr<"u"?I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date||I instanceof xr:I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date,E=t&&typeof t.mergeArray=="function"?t.mergeArray({clone:T,deepmerge:B,getKeys:p,isMergeableObject:m}):s;function T(I){return m(I)?Array.isArray(I)?r(I):i(I):I}function _(I,F){const U={},L=p(I),C=p(F);let x,k,q;for(x=0,k=L.length;x<k;++x)e(q=L[x])&&C.indexOf(q)===-1&&(U[q]=T(I[q]));for(x=0,k=C.length;x<k;++x)e(q=C[x])&&(q in I&&(L.indexOf(q)!==-1&&(U[q]=B(I[q],F[q])),!0)||(U[q]=T(F[q])));return U}function B(I,F){const U=Array.isArray(F),L=Array.isArray(I);return l(F)?F:w(I)?T(F):U&&L?E(I,F):U!==L?T(F):_(I,F)}function M(){switch(arguments.length){case 0:return{};case 1:return T(arguments[0]);case 2:return B(arguments[0],arguments[1])}let I;for(let F=0,U=arguments.length;F<U;++F)I=B(I,arguments[F]);return I}return t&&t.all?M:B}pr.exports=yr;pr.exports.default=yr;var Mi=pr.exports.deepmerge=yr;const Vi=t=>(e,r)=>{let i=0;const s=e.length,u=r.length,f=Math.max(s,u),p=new Array(f);for(i=0;i<f;++i)i<u?p[i]=t.deepmerge(e[i],r[i]):p[i]=t.clone(e[i]);return p},qi=Mi({mergeArray:Vi}),Qi=(t,e,r)=>{const i=_e.computed([e,r],(f,p)=>{if(f){const h=p.data?.find(m=>m.id===f);if(h)return h;console.error("Feed list is not loaded yet. Issue with the opened question.")}}),s=Le({data:void 0,loading:void 0,error:void 0});return i.subscribe(async f=>{if(f&&f.type==="question"){s.setKey("loading",!0);const p=await sn(f.id,t);s.set({data:p,loading:!1});return}s.set({data:void 0,loading:!1})}),{$store:i,$extendedStore:s,updateExtendedQuestion:f=>{const p=s.get().data;if(p&&f?.answers)for(const h of f.answers)h.youVoted!==!0&&delete h.youVoted;s.set({data:qi(p,f)})}}};var Ve;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Ve||(Ve={}));class Gi{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;notifications;log;constructor(e){this.log=on("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new ae(ne(void 0),"moderationId").getStore(),this.interactiveAllowed=new ae(ne(Ve.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new ae(ne(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new de(Oi(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new de(xi(this.slStreamId,this.interactiveAllowed,e.transport),"gamification:feedList"),this.activeQuestionId=new de(_i(this.slStreamId,e.transport),"gamification:activeQuestionId"),this.openedQuestion=Qi(e.transport,this.openedQuestionId,this.feedList.getStore()),this.openedQuestionId.listen(r=>{this.log.debug({questionId:r},"received question"),r?(this.questionSubscription=Ci(r,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",i=>{window.requestAnimationFrame(()=>{this.openedQuestion.updateExtendedQuestion(i.data?.attributes?.question)})}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))}),this.feedSubscription=Fi(this.slStreamId,e.transport),this.feedSubscription.addListener("feed-subscription-active-question",r=>{window.requestAnimationFrame(()=>{const i=this.activeQuestionId.getStore();i&&i.mutate(r.data?.attributes)})}),this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})}),this.feedSubscription.connect(),this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})}getCurrentSessionId=e=>{const r=e.eventId||this.slStreamId.get()||"",i=e.userId||this.userId.get()||"",s=e.organizationId||this.organizationId.get()||"",u=e.entity||"",f=e.prefix||"";return[s,r,i,f,u].join(":")};disconnect=()=>{this.feedSubscription?.disconnect()};openQuestion=e=>{this.openedQuestionId.set(e),this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))};closeQuestion=e=>{this.openedQuestionId.set(void 0),e&&this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))}}class zi{notificationsList;notifications;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=on("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notifications=new ae(ne(new Map),"notifications-queue"),this.notificationsList=this.notifications.getStore()}addToQueue=e=>{if(this.store.has(e.id)){this.logger.debug({notification:e},"skip existed notification: %o");return}const r=e.close,i=e.action;if(this.store.set(e.id,{...e,close:(...s)=>{r&&r(...s),this.closeNotification(e.id)},action:(...s)=>{i&&i(...s),this.closeNotification(e.id)}}),this.waitingQueue.add(e.id),this.activeQueue.size===this.options.concurrency){const[s]=this.activeQueue;if(this.store.get(s)?.persistent!==!0)this.closeNotification(s);else{const[f]=this.waitingQueue;this.waitingQueue.size>1&&this.closeNotification(f),this.tickWaitingQueue()}}else this.tickWaitingQueue()};tickWaitingQueue=()=>{if(this.activeQueue.size<this.options.concurrency){const[e]=this.waitingQueue;if(!e)return;this.activeQueue.add(e),this.waitingQueue.delete(e),this.logger.debug({job:e},"waiting queue tick"),this.tickActiveQueue(e)}else this.logger.debug({queueSize:this.activeQueue.size,concurrency:this.options.concurrency},"waiting queue tick skipped")};tickActiveQueue=e=>{if(!e)return;const r=this.store.get(e);if(!r){this.logger.debug({notificationId:e},"active queue tick skipped, notification not exist");return}const i=setTimeout(()=>{const s=e,u=new Map(this.notifications.getValue());u.set(r.id,r),this.notifications.setValue(u);const f=setTimeout(()=>{this.logger.debug({notificationId:s,delay:r.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(s)},r.autoHideDuration||5e3);this.timeouts.set(s,f),this.logger.debug({notificationId:s,queue:[...u.values()]},"notification displayed")},r.delay||0);this.timeouts.set(e,i),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=e=>{const r=new Map(this.notifications.getValue()),i=r.get(e);if(i){i.hiding=!(this.waitingQueue.size>=this.options.concurrency),this.notifications.setValue(r);const s=setTimeout(()=>{const u=new Map(this.notifications.getValue());u.delete(e),this.notifications.setValue(u);const f=this.timeouts.get(e);f!==void 0&&(clearTimeout(f),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden")},this.options.animationDelay||0);this.timeouts.set(e,s)}this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding")}}var Tt;(function(t){t.OPENED="opened"})(Tt||(Tt={}));class Ki extends dr{constructor(){super("notification")}setOpened=e=>{this.write(Tt.OPENED,e,"true")};isOpened=e=>this.read(Tt.OPENED,e);clearNotification=()=>{this.clear()}}var Me;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(Me||(Me={}));class Wi{queue;storage;constructor(e={}){this.storage=new Ki,this.queue=new zi({concurrency:1,animationDelay:1600,...e})}add=e=>{this.storage.isOpened(e.id)||this.queue.addToQueue(e)};close=(e,r=!0)=>{this.queue.closeNotification(e),r&&this.markAsViewed(e)};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const Hi=(t,e,r)=>{t.notifications=new Wi,t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),r()},Ji=(t,e)=>{const{client:r}=t.createPromiseClient(Fe.Feed,{method:"submitAnswer"});return r.submitAnswer({data:e})},Yi=(t,e)=>{const{client:r}=t.createPromiseClient(Fe.Feed,{method:"submitInplay"});return r.submitInplay({data:{eventId:+e}})},Xi=(t,e)=>{const{client:r}=t.createPromiseClient(Fe.Feed,{method:"skipQuestion"});return r.skipQuestion({data:{id:e}})};var Ze;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})(Ze||(Ze={}));class ln extends dr{constructor(){super("gamification")}saveOnboardingStatus=({userId:e,eventId:r,organizationId:i},s)=>{this.write(Ze.ONBOARDING,i,e,r,s)};getOnboardingStatus=({userId:e,eventId:r,organizationId:i})=>this.read(Ze.ONBOARDING,i,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:i})=>{const s=this.generateKey([Ze.ONBOARDING_IO,i,e,r]);window.sessionStorage.setItem(s,"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:i})=>{const s=this.generateKey([Ze.ONBOARDING_IO,i,e,r]);return window.sessionStorage.getItem(s)}}const Br={pageSize:10},Zi=(t,e,r,i,s)=>{let u=0;const f=ne({pageSize:s?.pageSize||Br.pageSize,page:0}),p=Le({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),h=Ii(t),m=async()=>{const E=e.get(),T=i.getStore().get().data?.map(_=>_.slId)||[];if(E&&T?.length){const _=r.get();_&&T.push(_),p.setKey("loading",!0),p.setKey("data",[]);const B={eventId:E,usersIds:T,pagination:{page:0,pageSize:s?.pageSize||Br.pageSize}},M=await h(B);p.set({data:M.data.map(I=>I.attributes),hasMore:!0,key:Date.now(),loading:!1}),M.meta&&(u=Math.round(M.meta.count/M.meta.pageSize)),f.set(B.pagination)}},l=()=>{m()},w=E=>{const T=f.get(),_=E||T.page+1;_<=u&&f.set({...T,page:_})};return _e.onMount(p,()=>{const E=e.listen(m),T=i.listen(m),_=f.listen(async B=>{const M=e.get();if(B.page>0&&M)if(B.page<u){p.setKey("loading",!0);const F=await h({eventId:M,pagination:B}),U=p.get().data||[];p.set({data:[...U,...F.data.map(L=>L.attributes)],key:p.get().key,loading:!1,hasMore:!0})}else p.setKey("hasMore",!1)});return()=>{E(),T(),_()}}),{$store:p,fetchMore:w,invalidate:l}},eo=(t,e)=>{const{client:r,queryKey:i}=t.createPromiseClient(yt.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(i,{fetcher:async(s,u,f)=>f?(await r.generateDeepLink({data:{eventId:f}})).data?.attributes:{}})},to=(t,{web:e,mobile:r})=>{const{client:i}=t.createPromiseClient(Wn.LinksClient,{method:"generate"});return i.generate({web:e,mobile:r})},ro=(t,e,r)=>{const i=Le({});return _e.onMount(i,()=>eo(t,[e]).subscribe(async({data:f,error:p,loading:h})=>{const m=p?"https://masters.com":f?.url;if(!h&&m){i.setKey("loading",!0);let l=window.location.search,w=window.location.hash;if(l&&w||w){const _=new URLSearchParams(l);_.append("slprms",`sl_eid=${e.get()}:sl_uid=${r.get()}`),l=`?${_.toString()}`}else w=`#slprms::${`sl_eid=${e.get()}:sl_uid=${r.get()}`}`;const E=window.location.origin+window.location.pathname+l+w,T=await to(t,{web:E,mobile:m});i.set({data:T.data?.link,loading:!1})}else i.setKey("loading",!0)})),{$store:i,fetch}};var ee;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(ee||(ee={}));const no=(t,e,r,i)=>{const{inplayGame:s}=t.featureSettings.get(),u=e.getCurrentSessionId({prefix:"onboarding"});s&&r.add({type:Me.ONBOARDING,id:u,action:t.openFeature,persistent:!0,autoHideDuration:1e6,data:{questionType:re.QuestionType.UNSET,onboarding:{...s,instantOpen:!i.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},wt=(t,e,r,i,s,u)=>{try{const f=e.userId.get();if(!f)return;if(s.getOnboardingStatus({userId:f,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===ee.Completed){t.set(ee.Completed);for(const E of u)E();return}const h=e.moderation.getStore().value?.data,m=r.featureSettings.get().inplayGame;if(h===void 0||m===void 0)return;const l=h?.options?.onboardingEnabled,w=m?.titleCard?.optIn;l?w?t.set(ee.Required):t.set(ee.Optional):(w?t.set(ee.Unavailable):t.set(ee.Disabled),i.close(e.getCurrentSessionId({prefix:"onboarding"}),!1))}catch(f){console.error(f)}},io=(t,e,r,i)=>{let s=!1;const u=new ln,f=ne(ee.Unset);f.subscribe(m=>{m!==ee.Unset&&((m===ee.Optional||m===ee.Required)&&s===!1&&(no(t,e,i,u),s=!0),m===ee.Completed&&e.activeQuestionId.invalidate(),u.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const p=[];return wt(f,e,t,i,u,p),f.get()!==ee.Completed&&(p.push(e.userId.listen(m=>{m&&wt(f,e,t,i,u,p)})),p.push(e.moderation.listen(m=>{m.data&&wt(f,e,t,i,u,p)})),p.push(t.featureSettings.listen(m=>{m&&wt(f,e,t,i,u,p)}))),{$store:f,submitInplay:async()=>{const m=e.slStreamId.get();if(m){await Yi(r,m),f.set(ee.Completed),u.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:m},ee.Completed);const l=e.getCurrentSessionId({prefix:"onboarding"});i.close(l)}}}},oo=new Set([re.QuestionType.POLL,re.QuestionType.PREDICTION,re.QuestionType.TRIVIA]);class so extends nn{userSummary;feedList;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;notifications;transport;background;storage;constructor(e,r,i){super(e,r),this.background=new Gi(i),this.storage=new ln,this.userSummary=new de(Ei(this.background.slStreamId,this.background.userId,i.transport),"gamification:userSummary"),this.feedList=this.background.feedList,this.friends=new de(Ti(this.background.userId,i.transport),"gamification:friends"),this.currentUserId=this.background.userId,this.openedUser=ne(void 0),this.leaderboardId=new ae(ne(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=io(this,this.background,i.transport,i.notifications),this.notifications=i.notifications,this.transport=i.transport,this.closeFeature=()=>i.sdk.closeFeature(!0),this.openFeature=()=>i.sdk.openFeature(Te.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=ro(this.transport,this.background.slStreamId,this.background.userId),this.leaderboardList=Zi(this.transport,this.background.slStreamId,this.background.userId,this.friends),this.status.subscribe(s=>{s===rt.Ready?this.connect(i.transport):this.disconnect()}),this.userSummary.listen(s=>{this.leaderboardList.$store.lc!==0&&s?.data?.summary&&window.requestAnimationFrame(()=>{this.leaderboardList.invalidate()})}),this.background.activeQuestionId.listen(this.showInApp),this.onboardingStatus.$store.listen(this.checkInteractiveFlag),this.background.moderation.getStore().listen(this.checkInteractiveFlag),this.settings.subscribe(this.checkInteractiveFlag)}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===Ve.ALLOWED}checkInteractiveFlag=()=>{const e=this.onboardingStatus.$store.get(),r=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,i=this.settings.getValues().inplayGame?.titleCard?.optIn,s=e===ee.Completed,u=!r||s||i!==!0;this.background.interactiveAllowed.set(u?Ve.ALLOWED:Ve.DISALLOWED)};connect=e=>{this.userSummary.invalidate(),this.leaderboardList.invalidate(),this.feedList.invalidate(),this.friends.invalidate(),this.background.feedSubscription.addListener("feed-subscription-prediction-close",r=>{this.isInteractiveAllowed&&window.requestAnimationFrame(async()=>{const i=r.data?.attributes?.question;if(!i)return;const{status:s,type:u,id:f}=i;if(s===re.QuestionStatus.RESOLVED&&u===re.QuestionType.PREDICTION){const p=this.background.getCurrentSessionId({prefix:`notification-id:${f}`}),h=await sn(f,e),m=h?.answers.find(({correct:w})=>w),l=h?.answers.find(({youVoted:w})=>w);if(!l)return;this.notifications.add({type:Me.QUESTION_RESOLVED,action:()=>this.openQuestion(f),close:()=>this.closeQuestion(f),autoHideDuration:35e3,id:p,data:{questionType:re.QuestionType.PREDICTION,question:{title:m?.youVoted?`Congratulations! You answered correctly! You won ${m.points} pts!`:`Better luck next time! Correct: ${m?.text}!`,votedAnswer:{title:l?.text,points:l?.points},correctAnswerTitle:m?.text,correct:m?.youVoted,predictionResult:s===re.QuestionStatus.RESOLVED,questionTitle:h?.subject}}}),this.userSummary.invalidate()}})}),this.background.feedSubscription.addListener("feed-subscription-questions-list",()=>{window.requestAnimationFrame(()=>{this.feedList?.invalidate()})})};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitAnswer=async(e,r)=>{await Ji(this.transport,{questionId:e,answerId:r}),this.feedList.invalidate(),this.userSummary.invalidate()};skipQuestion=async e=>{await Xi(this.transport,e),this.feedList.invalidate(),this.userSummary.invalidate()};openQuestion=e=>(this.openFeature(),this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e})),this.background.openQuestion(e));closeQuestion=e=>this.background.closeQuestion(e);openUser=e=>{const r=this.leaderboardList.$store.get().data?.find(i=>i.userId===e);this.openedUser.set(r)};closeUser=()=>{this.openedUser.set(void 0)};showInApp=e=>{const r=this.onboardingStatus.$store.get();if(e&&e.data&&r&&r!==ee.Unset&&e.data.question?.id!==void 0&&e.data.question.notification!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==re.SilenceSetting.ON&&e.data.question.status===re.QuestionStatus.ACTIVE){if(oo.has(e.data.question.type))this.isInteractiveAllowed&&this.notifications.add({type:Me.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*60,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionType:e.data.question.type,question:{title:e.data.question.notification.title}}});else if(e.data.question.type===re.QuestionType.FACTOID){const i=e.data.question.options?.options.value,s={heading:e.data.question.notification.title,body:e.data.question.notification.body,image:i.image,video:{id:i?.video?.id||"",url:i?.video?.url||"",thumbnailUrl:i?.video?.thumbnailUrl||""},webLink:{label:"",url:""}};this.notifications.add({type:Me.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*120,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionType:e.data.question.type,insight:s}})}else if(e.data.question.type===re.QuestionType.TWEET){const i=e.data.question.options?.options.value,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};this.notifications.add({type:Me.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*120,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionType:e.data.question.type,tweet:s}})}}}}const ao={[Te.SdkOverlayType.GAMES]:!0};class uo extends nn{constructor(e,r){super(e,r)}}const co=(t,e,r)=>t.type===Te.SdkOverlayType.GAMES?new so(t,e,r):new uo(t,e),lo=(t,e,r)=>{t.features=new Map,t.activeFeature=new ae(ne(Te.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=i=>t.features.get(i),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=i=>{t.activeFeature.setValue(i)},t.sdk.closeFeature=(i=!1)=>{if(i){const s=t.activeFeature.getValue();t.activeFeature.setValue(Te.SdkOverlayType.UNSET),s&&t.features.delete(s)}},t.initFeature=(i,s=Ee.ORGANIZATION)=>{if(i.type in ao&&!t.features.has(i.type)){const u=co(i,s,t);t.features.set(i.type,u)}},t.updateFeature=(i,s)=>{t.features.get(i.type)?.update(i,s)},t.destroyFeature=i=>{t.features.delete(i.type)},t.reinitializeFeatures=async()=>{const i=await t.stores.organizationSettings.getValue();t.features.clear();for(const s of i?.overlays||[])t.initFeature(s,Ee.ORGANIZATION)},t.stores.providerStreamId.listen(i=>{i||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const i=(u,f)=>{if(f?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&u===Ee.ORGANIZATION))for(const p of f.overlays)p.sdkEnable===!0&&(t.features.has(p.type)?t.updateFeature(p,u):t.initFeature(p,u))},s={organizationSettings:u=>{if(u.data)try{i(Ee.ORGANIZATION,u.data)}catch(f){console.log(f)}},streamSettings:u=>{if(u.data)try{i(Ee.STREAM,u.data)}catch(f){console.log(f)}}};t.store.subscribe(s)},r()};var gr={exports:{}},mr={exports:{}};function fo(t){var e=new t,r=e;function i(){var u=e;return u.next?e=u.next:(e=new t,r=e),u.next=null,u}function s(u){r.next=u,r=u}return{get:i,release:s}}var ho=fo,po=ho;function fn(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),r<1)throw new Error("fastqueue concurrency must be greater than 1");var i=po(yo),s=null,u=null,f=0,p=null,h={push:B,drain:se,saturated:se,pause:l,paused:!1,concurrency:r,running:m,resume:T,idle:_,length:w,getQueue:E,unshift:M,empty:se,kill:F,killAndDrain:U,error:L};return h;function m(){return f}function l(){h.paused=!0}function w(){for(var C=s,x=0;C;)C=C.next,x++;return x}function E(){for(var C=s,x=[];C;)x.push(C.value),C=C.next;return x}function T(){if(h.paused){h.paused=!1;for(var C=0;C<h.concurrency;C++)f++,I()}}function _(){return f===0&&h.length()===0}function B(C,x){var k=i.get();k.context=t,k.release=I,k.value=C,k.callback=x||se,k.errorHandler=p,f===h.concurrency||h.paused?u?(u.next=k,u=k):(s=k,u=k,h.saturated()):(f++,e.call(t,k.value,k.worked))}function M(C,x){var k=i.get();k.context=t,k.release=I,k.value=C,k.callback=x||se,k.errorHandler=p,f===h.concurrency||h.paused?s?(k.next=s,s=k):(s=k,u=k,h.saturated()):(f++,e.call(t,k.value,k.worked))}function I(C){C&&i.release(C);var x=s;x?h.paused?f--:(u===s&&(u=null),s=x.next,x.next=null,e.call(t,x.value,x.worked),u===null&&h.empty()):--f===0&&h.drain()}function F(){s=null,u=null,h.drain=se}function U(){s=null,u=null,h.drain(),h.drain=se}function L(C){p=C}}function se(){}function yo(){this.value=null,this.callback=se,this.next=null,this.release=se,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,i){var s=t.callback,u=t.errorHandler,f=t.value;t.value=null,t.callback=se,t.errorHandler&&u(r,f),s.call(t.context,r,i),t.release(t)}}function go(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function i(l,w){e.call(this,l).then(function(E){w(null,E)},w)}var s=fn(t,i,r),u=s.push,f=s.unshift;return s.push=p,s.unshift=h,s.drained=m,s;function p(l){var w=new Promise(function(E,T){u(l,function(_,B){if(_){T(_);return}E(B)})});return w.catch(se),w}function h(l){var w=new Promise(function(E,T){f(l,function(_,B){if(_){T(_);return}E(B)})});return w.catch(se),w}function m(){if(s.idle())return new Promise(function(E){E()});var l=s.drain,w=new Promise(function(E){s.drain=function(){l(),E()}});return w}}mr.exports=fn;mr.exports.promise=go;var dn=mr.exports,wr={exports:{}},nt=typeof Reflect=="object"?Reflect:null,kr=nt&&typeof nt.apply=="function"?nt.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},vt;nt&&typeof nt.ownKeys=="function"?vt=nt.ownKeys:Object.getOwnPropertySymbols?vt=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:vt=function(e){return Object.getOwnPropertyNames(e)};function mo(t){console&&console.warn&&console.warn(t)}var hn=Number.isNaN||function(e){return e!==e};function G(){G.init.call(this)}wr.exports=G;wr.exports.once=So;G.EventEmitter=G;G.prototype._events=void 0;G.prototype._eventsCount=0;G.prototype._maxListeners=void 0;var Pr=10;function Pt(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(G,"defaultMaxListeners",{enumerable:!0,get:function(){return Pr},set:function(t){if(typeof t!="number"||t<0||hn(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Pr=t}});G.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};G.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||hn(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function pn(t){return t._maxListeners===void 0?G.defaultMaxListeners:t._maxListeners}G.prototype.getMaxListeners=function(){return pn(this)};G.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var s=e==="error",u=this._events;if(u!==void 0)s=s&&u.error===void 0;else if(!s)return!1;if(s){var f;if(r.length>0&&(f=r[0]),f instanceof Error)throw f;var p=new Error("Unhandled error."+(f?" ("+f.message+")":""));throw p.context=f,p}var h=u[e];if(h===void 0)return!1;if(typeof h=="function")kr(h,this,r);else for(var m=h.length,l=bn(h,m),i=0;i<m;++i)kr(l[i],this,r);return!0};function yn(t,e,r,i){var s,u,f;if(Pt(r),u=t._events,u===void 0?(u=t._events=Object.create(null),t._eventsCount=0):(u.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),u=t._events),f=u[e]),f===void 0)f=u[e]=r,++t._eventsCount;else if(typeof f=="function"?f=u[e]=i?[r,f]:[f,r]:i?f.unshift(r):f.push(r),s=pn(t),s>0&&f.length>s&&!f.warned){f.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+f.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=t,p.type=e,p.count=f.length,mo(p)}return t}G.prototype.addListener=function(e,r){return yn(this,e,r,!1)};G.prototype.on=G.prototype.addListener;G.prototype.prependListener=function(e,r){return yn(this,e,r,!0)};function wo(){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 gn(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},s=wo.bind(i);return s.listener=r,i.wrapFn=s,s}G.prototype.once=function(e,r){return Pt(r),this.on(e,gn(this,e,r)),this};G.prototype.prependOnceListener=function(e,r){return Pt(r),this.prependListener(e,gn(this,e,r)),this};G.prototype.removeListener=function(e,r){var i,s,u,f,p;if(Pt(r),s=this._events,s===void 0)return this;if(i=s[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(u=-1,f=i.length-1;f>=0;f--)if(i[f]===r||i[f].listener===r){p=i[f].listener,u=f;break}if(u<0)return this;u===0?i.shift():bo(i,u),i.length===1&&(s[e]=i[0]),s.removeListener!==void 0&&this.emit("removeListener",e,p||r)}return this};G.prototype.off=G.prototype.removeListener;G.prototype.removeAllListeners=function(e){var r,i,s;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var u=Object.keys(i),f;for(s=0;s<u.length;++s)f=u[s],f!=="removeListener"&&this.removeAllListeners(f);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(s=r.length-1;s>=0;s--)this.removeListener(e,r[s]);return this};function mn(t,e,r){var i=t._events;if(i===void 0)return[];var s=i[e];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?vo(s):bn(s,s.length)}G.prototype.listeners=function(e){return mn(this,e,!0)};G.prototype.rawListeners=function(e){return mn(this,e,!1)};G.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):wn.call(t,e)};G.prototype.listenerCount=wn;function wn(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}G.prototype.eventNames=function(){return this._eventsCount>0?vt(this._events):[]};function bn(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function bo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function vo(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function So(t,e){return new Promise(function(r,i){function s(f){t.removeListener(e,u),i(f)}function u(){typeof t.removeListener=="function"&&t.removeListener("error",s),r([].slice.call(arguments))}vn(t,e,u,{once:!0}),e!=="error"&&Ao(t,s,{once:!0})})}function Ao(t,e,r){typeof t.on=="function"&&vn(t,"error",e,r)}function vn(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function s(u){i.once&&t.removeEventListener(e,s),r(u)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Sn=wr.exports,Lt={},An={},En=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),i=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;e[r]=s;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var u=Object.getOwnPropertySymbols(e);if(u.length!==1||u[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var f=Object.getOwnPropertyDescriptor(e,r);if(f.value!==s||f.enumerable!==!0)return!1}return!0},Eo=En,br=function(){return Eo()&&!!Symbol.toStringTag},Lr=typeof Symbol<"u"&&Symbol,Io=En,To=function(){return typeof Lr!="function"||typeof Symbol!="function"||typeof Lr("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Io()},Rr={foo:{}},Oo=Object,_o=function(){return{__proto__:Rr}.foo===Rr.foo&&!({__proto__:null}instanceof Oo)},Fo="Function.prototype.bind called on incompatible ",Co=Object.prototype.toString,xo=Math.max,Bo="[object Function]",Nr=function(e,r){for(var i=[],s=0;s<e.length;s+=1)i[s]=e[s];for(var u=0;u<r.length;u+=1)i[u+e.length]=r[u];return i},ko=function(e,r){for(var i=[],s=r||0,u=0;s<e.length;s+=1,u+=1)i[u]=e[s];return i},Po=function(t,e){for(var r="",i=0;i<t.length;i+=1)r+=t[i],i+1<t.length&&(r+=e);return r},Lo=function(e){var r=this;if(typeof r!="function"||Co.apply(r)!==Bo)throw new TypeError(Fo+r);for(var i=ko(arguments,1),s,u=function(){if(this instanceof s){var l=r.apply(this,Nr(i,arguments));return Object(l)===l?l:this}return r.apply(e,Nr(i,arguments))},f=xo(0,r.length-i.length),p=[],h=0;h<f;h++)p[h]="$"+h;if(s=Function("binder","return function ("+Po(p,",")+"){ return binder.apply(this,arguments); }")(u),r.prototype){var m=function(){};m.prototype=r.prototype,s.prototype=new m,m.prototype=null}return s},Ro=Lo,vr=Function.prototype.bind||Ro,No=Function.prototype.call,Do=Object.prototype.hasOwnProperty,$o=vr,Uo=$o.call(No,Do),$,ot=SyntaxError,In=Function,it=TypeError,Ut=function(t){try{return In('"use strict"; return ('+t+").constructor;")()}catch{}},qe=Object.getOwnPropertyDescriptor;if(qe)try{qe({},"")}catch{qe=null}var jt=function(){throw new it},jo=qe?function(){try{return arguments.callee,jt}catch{try{return qe(arguments,"callee").get}catch{return jt}}}():jt,We=To(),Mo=_o(),X=Object.getPrototypeOf||(Mo?function(t){return t.__proto__}:null),Je={},Vo=typeof Uint8Array>"u"||!X?$:X(Uint8Array),Qe={"%AggregateError%":typeof AggregateError>"u"?$:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?$:ArrayBuffer,"%ArrayIteratorPrototype%":We&&X?X([][Symbol.iterator]()):$,"%AsyncFromSyncIteratorPrototype%":$,"%AsyncFunction%":Je,"%AsyncGenerator%":Je,"%AsyncGeneratorFunction%":Je,"%AsyncIteratorPrototype%":Je,"%Atomics%":typeof Atomics>"u"?$:Atomics,"%BigInt%":typeof BigInt>"u"?$:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?$:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?$:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?$:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?$:Float32Array,"%Float64Array%":typeof Float64Array>"u"?$:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?$:FinalizationRegistry,"%Function%":In,"%GeneratorFunction%":Je,"%Int8Array%":typeof Int8Array>"u"?$:Int8Array,"%Int16Array%":typeof Int16Array>"u"?$:Int16Array,"%Int32Array%":typeof Int32Array>"u"?$:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":We&&X?X(X([][Symbol.iterator]())):$,"%JSON%":typeof JSON=="object"?JSON:$,"%Map%":typeof Map>"u"?$:Map,"%MapIteratorPrototype%":typeof Map>"u"||!We||!X?$:X(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?$:Promise,"%Proxy%":typeof Proxy>"u"?$:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?$:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?$:Set,"%SetIteratorPrototype%":typeof Set>"u"||!We||!X?$:X(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?$:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":We&&X?X(""[Symbol.iterator]()):$,"%Symbol%":We?Symbol:$,"%SyntaxError%":ot,"%ThrowTypeError%":jo,"%TypedArray%":Vo,"%TypeError%":it,"%Uint8Array%":typeof Uint8Array>"u"?$:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?$:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?$:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?$:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?$:WeakMap,"%WeakRef%":typeof WeakRef>"u"?$:WeakRef,"%WeakSet%":typeof WeakSet>"u"?$:WeakSet};if(X)try{null.error}catch(t){var qo=X(X(t));Qe["%Error.prototype%"]=qo}var Qo=function t(e){var r;if(e==="%AsyncFunction%")r=Ut("async function () {}");else if(e==="%GeneratorFunction%")r=Ut("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Ut("async function* () {}");else if(e==="%AsyncGenerator%"){var i=t("%AsyncGeneratorFunction%");i&&(r=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&X&&(r=X(s.prototype))}return Qe[e]=r,r},Dr={"%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"]},gt=vr,Ot=Uo,Go=gt.call(Function.call,Array.prototype.concat),zo=gt.call(Function.apply,Array.prototype.splice),$r=gt.call(Function.call,String.prototype.replace),_t=gt.call(Function.call,String.prototype.slice),Ko=gt.call(Function.call,RegExp.prototype.exec),Wo=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Ho=/\\(\\)?/g,Jo=function(e){var r=_t(e,0,1),i=_t(e,-1);if(r==="%"&&i!=="%")throw new ot("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&r!=="%")throw new ot("invalid intrinsic syntax, expected opening `%`");var s=[];return $r(e,Wo,function(u,f,p,h){s[s.length]=p?$r(h,Ho,"$1"):f||u}),s},Yo=function(e,r){var i=e,s;if(Ot(Dr,i)&&(s=Dr[i],i="%"+s[0]+"%"),Ot(Qe,i)){var u=Qe[i];if(u===Je&&(u=Qo(i)),typeof u>"u"&&!r)throw new it("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:u}}throw new ot("intrinsic "+e+" does not exist!")},at=function(e,r){if(typeof e!="string"||e.length===0)throw new it("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new it('"allowMissing" argument must be a boolean');if(Ko(/^%?[^%]*%?$/,e)===null)throw new ot("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=Jo(e),s=i.length>0?i[0]:"",u=Yo("%"+s+"%",r),f=u.name,p=u.value,h=!1,m=u.alias;m&&(s=m[0],zo(i,Go([0,1],m)));for(var l=1,w=!0;l<i.length;l+=1){var E=i[l],T=_t(E,0,1),_=_t(E,-1);if((T==='"'||T==="'"||T==="`"||_==='"'||_==="'"||_==="`")&&T!==_)throw new ot("property names with quotes must have matching quotes");if((E==="constructor"||!w)&&(h=!0),s+="."+E,f="%"+s+"%",Ot(Qe,f))p=Qe[f];else if(p!=null){if(!(E in p)){if(!r)throw new it("base intrinsic for "+e+" exists, but the property is not available.");return}if(qe&&l+1>=i.length){var B=qe(p,E);w=!!B,w&&"get"in B&&!("originalValue"in B.get)?p=B.get:p=p[E]}else w=Ot(p,E),p=p[E];w&&!h&&(Qe[f]=p)}}return p},Tn={exports:{}},Xo=at,tr=Xo("%Object.defineProperty%",!0),rr=function(){if(tr)try{return tr({},"a",{value:1}),!0}catch{return!1}return!1};rr.hasArrayLengthDefineBug=function(){if(!rr())return null;try{return tr([],"length",{value:1}).length!==1}catch{return!0}};var On=rr,Zo=at,St=Zo("%Object.getOwnPropertyDescriptor%",!0);if(St)try{St([],"length")}catch{St=null}var Sr=St,es=On(),Ar=at,ht=es&&Ar("%Object.defineProperty%",!0);if(ht)try{ht({},"a",{value:1})}catch{ht=!1}var ts=Ar("%SyntaxError%"),He=Ar("%TypeError%"),Ur=Sr,rs=function(e,r,i){if(!e||typeof e!="object"&&typeof e!="function")throw new He("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new He("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new He("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new He("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new He("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new He("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,f=arguments.length>5?arguments[5]:null,p=arguments.length>6?arguments[6]:!1,h=!!Ur&&Ur(e,r);if(ht)ht(e,r,{configurable:f===null&&h?h.configurable:!f,enumerable:s===null&&h?h.enumerable:!s,value:i,writable:u===null&&h?h.writable:!u});else if(p||!s&&!u&&!f)e[r]=i;else throw new ts("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},_n=at,jr=rs,ns=On(),Mr=Sr,Vr=_n("%TypeError%"),is=_n("%Math.floor%"),os=function(e,r){if(typeof e!="function")throw new Vr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||is(r)!==r)throw new Vr("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,u=!0;if("length"in e&&Mr){var f=Mr(e,"length");f&&!f.configurable&&(s=!1),f&&!f.writable&&(u=!1)}return(s||u||!i)&&(ns?jr(e,"length",r,!0,!0):jr(e,"length",r)),e};(function(t){var e=vr,r=at,i=os,s=r("%TypeError%"),u=r("%Function.prototype.apply%"),f=r("%Function.prototype.call%"),p=r("%Reflect.apply%",!0)||e.call(f,u),h=r("%Object.defineProperty%",!0),m=r("%Math.max%");if(h)try{h({},"a",{value:1})}catch{h=null}t.exports=function(E){if(typeof E!="function")throw new s("a function is required");var T=p(e,f,arguments);return i(T,1+m(0,E.length-(arguments.length-1)),!0)};var l=function(){return p(e,u,arguments)};h?h(t.exports,"apply",{value:l}):t.exports.apply=l})(Tn);var Fn=Tn.exports,Cn=at,xn=Fn,ss=xn(Cn("String.prototype.indexOf")),Bn=function(e,r){var i=Cn(e,!!r);return typeof i=="function"&&ss(e,".prototype.")>-1?xn(i):i},as=br(),us=Bn,nr=us("Object.prototype.toString"),Rt=function(e){return as&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:nr(e)==="[object Arguments]"},kn=function(e){return Rt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&nr(e)!=="[object Array]"&&nr(e.callee)==="[object Function]"},cs=function(){return Rt(arguments)}();Rt.isLegacyArguments=kn;var ls=cs?Rt:kn,fs=Object.prototype.toString,ds=Function.prototype.toString,hs=/^\s*(?:function)?\*/,Pn=br(),Mt=Object.getPrototypeOf,ps=function(){if(!Pn)return!1;try{return Function("return function*() {}")()}catch{}},Vt,ys=function(e){if(typeof e!="function")return!1;if(hs.test(ds.call(e)))return!0;if(!Pn){var r=fs.call(e);return r==="[object GeneratorFunction]"}if(!Mt)return!1;if(typeof Vt>"u"){var i=ps();Vt=i?Mt(i):!1}return Mt(e)===Vt},Ln=Function.prototype.toString,et=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ir,At;if(typeof et=="function"&&typeof Object.defineProperty=="function")try{ir=Object.defineProperty({},"length",{get:function(){throw At}}),At={},et(function(){throw 42},null,ir)}catch(t){t!==At&&(et=null)}else et=null;var gs=/^\s*class\b/,or=function(e){try{var r=Ln.call(e);return gs.test(r)}catch{return!1}},qt=function(e){try{return or(e)?!1:(Ln.call(e),!0)}catch{return!1}},Et=Object.prototype.toString,ms="[object Object]",ws="[object Function]",bs="[object GeneratorFunction]",vs="[object HTMLAllCollection]",Ss="[object HTML document.all class]",As="[object HTMLCollection]",Es=typeof Symbol=="function"&&!!Symbol.toStringTag,Is=!(0 in[,]),sr=function(){return!1};if(typeof document=="object"){var Ts=document.all;Et.call(Ts)===Et.call(document.all)&&(sr=function(e){if((Is||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=Et.call(e);return(r===vs||r===Ss||r===As||r===ms)&&e("")==null}catch{}return!1})}var Os=et?function(e){if(sr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{et(e,null,ir)}catch(r){if(r!==At)return!1}return!or(e)&&qt(e)}:function(e){if(sr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Es)return qt(e);if(or(e))return!1;var r=Et.call(e);return r!==ws&&r!==bs&&!/^\[object HTML/.test(r)?!1:qt(e)},_s=Os,Fs=Object.prototype.toString,Rn=Object.prototype.hasOwnProperty,Cs=function(e,r,i){for(var s=0,u=e.length;s<u;s++)Rn.call(e,s)&&(i==null?r(e[s],s,e):r.call(i,e[s],s,e))},xs=function(e,r,i){for(var s=0,u=e.length;s<u;s++)i==null?r(e.charAt(s),s,e):r.call(i,e.charAt(s),s,e)},Bs=function(e,r,i){for(var s in e)Rn.call(e,s)&&(i==null?r(e[s],s,e):r.call(i,e[s],s,e))},ks=function(e,r,i){if(!_s(r))throw new TypeError("iterator must be a function");var s;arguments.length>=3&&(s=i),Fs.call(e)==="[object Array]"?Cs(e,r,s):typeof e=="string"?xs(e,r,s):Bs(e,r,s)},Ps=ks,Qt=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],Ls=typeof globalThis>"u"?cn:globalThis,Rs=function(){for(var e=[],r=0;r<Qt.length;r++)typeof Ls[Qt[r]]=="function"&&(e[e.length]=Qt[r]);return e},Ft=Ps,Ns=Rs,qr=Fn,Er=Bn,It=Sr,Ds=Er("Object.prototype.toString"),Nn=br(),Qr=typeof globalThis>"u"?cn:globalThis,ar=Ns(),Ir=Er("String.prototype.slice"),Gt=Object.getPrototypeOf,$s=Er("Array.prototype.indexOf",!0)||function(e,r){for(var i=0;i<e.length;i+=1)if(e[i]===r)return i;return-1},Ct={__proto__:null};Nn&&It&&Gt?Ft(ar,function(t){var e=new Qr[t];if(Symbol.toStringTag in e){var r=Gt(e),i=It(r,Symbol.toStringTag);if(!i){var s=Gt(r);i=It(s,Symbol.toStringTag)}Ct["$"+t]=qr(i.get)}}):Ft(ar,function(t){var e=new Qr[t],r=e.slice||e.set;r&&(Ct["$"+t]=qr(r))});var Us=function(e){var r=!1;return Ft(Ct,function(i,s){if(!r)try{"$"+i(e)===s&&(r=Ir(s,1))}catch{}}),r},js=function(e){var r=!1;return Ft(Ct,function(i,s){if(!r)try{i(e),r=Ir(s,1)}catch{}}),r},Dn=function(e){if(!e||typeof e!="object")return!1;if(!Nn){var r=Ir(Ds(e),8,-1);return $s(ar,r)>-1?r:r!=="Object"?!1:js(e)}return It?Us(e):null},Ms=Dn,Vs=function(e){return!!Ms(e)};(function(t){var e=ls,r=ys,i=Dn,s=Vs;function u(A){return A.call.bind(A)}var f=typeof BigInt<"u",p=typeof Symbol<"u",h=u(Object.prototype.toString),m=u(Number.prototype.valueOf),l=u(String.prototype.valueOf),w=u(Boolean.prototype.valueOf);if(f)var E=u(BigInt.prototype.valueOf);if(p)var T=u(Symbol.prototype.valueOf);function _(A,lt){if(typeof A!="object")return!1;try{return lt(A),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=s;function B(A){return typeof Promise<"u"&&A instanceof Promise||A!==null&&typeof A=="object"&&typeof A.then=="function"&&typeof A.catch=="function"}t.isPromise=B;function M(A){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(A):s(A)||v(A)}t.isArrayBufferView=M;function I(A){return i(A)==="Uint8Array"}t.isUint8Array=I;function F(A){return i(A)==="Uint8ClampedArray"}t.isUint8ClampedArray=F;function U(A){return i(A)==="Uint16Array"}t.isUint16Array=U;function L(A){return i(A)==="Uint32Array"}t.isUint32Array=L;function C(A){return i(A)==="Int8Array"}t.isInt8Array=C;function x(A){return i(A)==="Int16Array"}t.isInt16Array=x;function k(A){return i(A)==="Int32Array"}t.isInt32Array=k;function q(A){return i(A)==="Float32Array"}t.isFloat32Array=q;function ie(A){return i(A)==="Float64Array"}t.isFloat64Array=ie;function we(A){return i(A)==="BigInt64Array"}t.isBigInt64Array=we;function be(A){return i(A)==="BigUint64Array"}t.isBigUint64Array=be;function ue(A){return h(A)==="[object Map]"}ue.working=typeof Map<"u"&&ue(new Map);function ct(A){return typeof Map>"u"?!1:ue.working?ue(A):A instanceof Map}t.isMap=ct;function he(A){return h(A)==="[object Set]"}he.working=typeof Set<"u"&&he(new Set);function Re(A){return typeof Set>"u"?!1:he.working?he(A):A instanceof Set}t.isSet=Re;function xe(A){return h(A)==="[object WeakMap]"}xe.working=typeof WeakMap<"u"&&xe(new WeakMap);function Ge(A){return typeof WeakMap>"u"?!1:xe.working?xe(A):A instanceof WeakMap}t.isWeakMap=Ge;function ve(A){return h(A)==="[object WeakSet]"}ve.working=typeof WeakSet<"u"&&ve(new WeakSet);function ce(A){return ve(A)}t.isWeakSet=ce;function Be(A){return h(A)==="[object ArrayBuffer]"}Be.working=typeof ArrayBuffer<"u"&&Be(new ArrayBuffer);function ze(A){return typeof ArrayBuffer>"u"?!1:Be.working?Be(A):A instanceof ArrayBuffer}t.isArrayBuffer=ze;function g(A){return h(A)==="[object DataView]"}g.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&g(new DataView(new ArrayBuffer(1),0,1));function v(A){return typeof DataView>"u"?!1:g.working?g(A):A instanceof DataView}t.isDataView=v;var S=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function O(A){return h(A)==="[object SharedArrayBuffer]"}function j(A){return typeof S>"u"?!1:(typeof O.working>"u"&&(O.working=O(new S)),O.working?O(A):A instanceof S)}t.isSharedArrayBuffer=j;function V(A){return h(A)==="[object AsyncFunction]"}t.isAsyncFunction=V;function R(A){return h(A)==="[object Map Iterator]"}t.isMapIterator=R;function D(A){return h(A)==="[object Set Iterator]"}t.isSetIterator=D;function Q(A){return h(A)==="[object Generator]"}t.isGeneratorObject=Q;function J(A){return h(A)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=J;function le(A){return _(A,m)}t.isNumberObject=le;function Ne(A){return _(A,l)}t.isStringObject=Ne;function ke(A){return _(A,w)}t.isBooleanObject=ke;function De(A){return f&&_(A,E)}t.isBigIntObject=De;function Se(A){return p&&_(A,T)}t.isSymbolObject=Se;function $e(A){return le(A)||Ne(A)||ke(A)||De(A)||Se(A)}t.isBoxedPrimitive=$e;function Nt(A){return typeof Uint8Array<"u"&&(ze(A)||j(A))}t.isAnyArrayBuffer=Nt,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(A){Object.defineProperty(t,A,{enumerable:!1,value:function(){throw new Error(A+" is not supported in userland")}})})})(An);var qs=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},ur={exports:{}};typeof Object.create=="function"?ur.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ur.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}};var Qs=ur.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(v){for(var S=Object.keys(v),O={},j=0;j<S.length;j++)O[S[j]]=Object.getOwnPropertyDescriptor(v,S[j]);return O},r=/%[sdj%]/g;t.format=function(g){if(!C(g)){for(var v=[],S=0;S<arguments.length;S++)v.push(f(arguments[S]));return v.join(" ")}for(var S=1,O=arguments,j=O.length,V=String(g).replace(r,function(D){if(D==="%%")return"%";if(S>=j)return D;switch(D){case"%s":return String(O[S++]);case"%d":return Number(O[S++]);case"%j":try{return JSON.stringify(O[S++])}catch{return"[Circular]"}default:return D}}),R=O[S];S<j;R=O[++S])F(R)||!ie(R)?V+=" "+R:V+=" "+f(R);return V},t.deprecate=function(g,v){if(typeof P<"u"&&P.noDeprecation===!0)return g;if(typeof P>"u")return function(){return t.deprecate(g,v).apply(this,arguments)};var S=!1;function O(){if(!S){if(P.throwDeprecation)throw new Error(v);P.traceDeprecation?console.trace(v):console.error(v),S=!0}return g.apply(this,arguments)}return O};var i={},s=/^$/;if(P.env.NODE_DEBUG){var u=P.env.NODE_DEBUG;u=u.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+u+"$","i")}t.debuglog=function(g){if(g=g.toUpperCase(),!i[g])if(s.test(g)){var v=P.pid;i[g]=function(){var S=t.format.apply(t,arguments);console.error("%s %d: %s",g,v,S)}}else i[g]=function(){};return i[g]};function f(g,v){var S={seen:[],stylize:h};return arguments.length>=3&&(S.depth=arguments[2]),arguments.length>=4&&(S.colors=arguments[3]),I(v)?S.showHidden=v:v&&t._extend(S,v),k(S.showHidden)&&(S.showHidden=!1),k(S.depth)&&(S.depth=2),k(S.colors)&&(S.colors=!1),k(S.customInspect)&&(S.customInspect=!0),S.colors&&(S.stylize=p),l(S,g,S.depth)}t.inspect=f,f.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]},f.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function p(g,v){var S=f.styles[v];return S?"\x1B["+f.colors[S][0]+"m"+g+"\x1B["+f.colors[S][1]+"m":g}function h(g,v){return g}function m(g){var v={};return g.forEach(function(S,O){v[S]=!0}),v}function l(g,v,S){if(g.customInspect&&v&&ue(v.inspect)&&v.inspect!==t.inspect&&!(v.constructor&&v.constructor.prototype===v)){var O=v.inspect(S,g);return C(O)||(O=l(g,O,S)),O}var j=w(g,v);if(j)return j;var V=Object.keys(v),R=m(V);if(g.showHidden&&(V=Object.getOwnPropertyNames(v)),be(v)&&(V.indexOf("message")>=0||V.indexOf("description")>=0))return E(v);if(V.length===0){if(ue(v)){var D=v.name?": "+v.name:"";return g.stylize("[Function"+D+"]","special")}if(q(v))return g.stylize(RegExp.prototype.toString.call(v),"regexp");if(we(v))return g.stylize(Date.prototype.toString.call(v),"date");if(be(v))return E(v)}var Q="",J=!1,le=["{","}"];if(M(v)&&(J=!0,le=["[","]"]),ue(v)){var Ne=v.name?": "+v.name:"";Q=" [Function"+Ne+"]"}if(q(v)&&(Q=" "+RegExp.prototype.toString.call(v)),we(v)&&(Q=" "+Date.prototype.toUTCString.call(v)),be(v)&&(Q=" "+E(v)),V.length===0&&(!J||v.length==0))return le[0]+Q+le[1];if(S<0)return q(v)?g.stylize(RegExp.prototype.toString.call(v),"regexp"):g.stylize("[Object]","special");g.seen.push(v);var ke;return J?ke=T(g,v,S,R,V):ke=V.map(function(De){return _(g,v,S,R,De,J)}),g.seen.pop(),B(ke,Q,le)}function w(g,v){if(k(v))return g.stylize("undefined","undefined");if(C(v)){var S="'"+JSON.stringify(v).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return g.stylize(S,"string")}if(L(v))return g.stylize(""+v,"number");if(I(v))return g.stylize(""+v,"boolean");if(F(v))return g.stylize("null","null")}function E(g){return"["+Error.prototype.toString.call(g)+"]"}function T(g,v,S,O,j){for(var V=[],R=0,D=v.length;R<D;++R)ve(v,String(R))?V.push(_(g,v,S,O,String(R),!0)):V.push("");return j.forEach(function(Q){Q.match(/^\d+$/)||V.push(_(g,v,S,O,Q,!0))}),V}function _(g,v,S,O,j,V){var R,D,Q;if(Q=Object.getOwnPropertyDescriptor(v,j)||{value:v[j]},Q.get?Q.set?D=g.stylize("[Getter/Setter]","special"):D=g.stylize("[Getter]","special"):Q.set&&(D=g.stylize("[Setter]","special")),ve(O,j)||(R="["+j+"]"),D||(g.seen.indexOf(Q.value)<0?(F(S)?D=l(g,Q.value,null):D=l(g,Q.value,S-1),D.indexOf(`
|
|
8
|
+
`)>-1&&(V?D=D.split(`
|
|
8
9
|
`).map(function(J){return" "+J}).join(`
|
|
9
|
-
`).slice(2)
|
|
10
|
-
|
|
10
|
+
`).slice(2):D=`
|
|
11
|
+
`+D.split(`
|
|
11
12
|
`).map(function(J){return" "+J}).join(`
|
|
12
|
-
`)))
|
|
13
|
-
`)>=0,
|
|
13
|
+
`))):D=g.stylize("[Circular]","special")),k(R)){if(V&&j.match(/^\d+$/))return D;R=JSON.stringify(""+j),R.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(R=R.slice(1,-1),R=g.stylize(R,"name")):(R=R.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),R=g.stylize(R,"string"))}return R+": "+D}function B(g,v,S){var O=g.reduce(function(j,V){return V.indexOf(`
|
|
14
|
+
`)>=0,j+V.replace(/\u001b\[\d\d?m/g,"").length+1},0);return O>60?S[0]+(v===""?"":v+`
|
|
14
15
|
`)+" "+g.join(`,
|
|
15
|
-
`)+" "+
|
|
16
|
+
`)+" "+S[1]:S[0]+v+" "+g.join(", ")+" "+S[1]}t.types=An;function M(g){return Array.isArray(g)}t.isArray=M;function I(g){return typeof g=="boolean"}t.isBoolean=I;function F(g){return g===null}t.isNull=F;function U(g){return g==null}t.isNullOrUndefined=U;function L(g){return typeof g=="number"}t.isNumber=L;function C(g){return typeof g=="string"}t.isString=C;function x(g){return typeof g=="symbol"}t.isSymbol=x;function k(g){return g===void 0}t.isUndefined=k;function q(g){return ie(g)&&he(g)==="[object RegExp]"}t.isRegExp=q,t.types.isRegExp=q;function ie(g){return typeof g=="object"&&g!==null}t.isObject=ie;function we(g){return ie(g)&&he(g)==="[object Date]"}t.isDate=we,t.types.isDate=we;function be(g){return ie(g)&&(he(g)==="[object Error]"||g instanceof Error)}t.isError=be,t.types.isNativeError=be;function ue(g){return typeof g=="function"}t.isFunction=ue;function ct(g){return g===null||typeof g=="boolean"||typeof g=="number"||typeof g=="string"||typeof g=="symbol"||typeof g>"u"}t.isPrimitive=ct,t.isBuffer=qs;function he(g){return Object.prototype.toString.call(g)}function Re(g){return g<10?"0"+g.toString(10):g.toString(10)}var xe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ge(){var g=new Date,v=[Re(g.getHours()),Re(g.getMinutes()),Re(g.getSeconds())].join(":");return[g.getDate(),xe[g.getMonth()],v].join(" ")}t.log=function(){console.log("%s - %s",Ge(),t.format.apply(t,arguments))},t.inherits=Qs,t._extend=function(g,v){if(!v||!ie(v))return g;for(var S=Object.keys(v),O=S.length;O--;)g[S[O]]=v[S[O]];return g};function ve(g,v){return Object.prototype.hasOwnProperty.call(g,v)}var ce=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(v){if(typeof v!="function")throw new TypeError('The "original" argument must be of type Function');if(ce&&v[ce]){var S=v[ce];if(typeof S!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(S,ce,{value:S,enumerable:!1,writable:!1,configurable:!0}),S}function S(){for(var O,j,V=new Promise(function(Q,J){O=Q,j=J}),R=[],D=0;D<arguments.length;D++)R.push(arguments[D]);R.push(function(Q,J){Q?j(Q):O(J)});try{v.apply(this,R)}catch(Q){j(Q)}return V}return Object.setPrototypeOf(S,Object.getPrototypeOf(v)),ce&&Object.defineProperty(S,ce,{value:S,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(S,e(v))},t.promisify.custom=ce;function Be(g,v){if(!g){var S=new Error("Promise was rejected with a falsy value");S.reason=g,g=S}return v(g)}function ze(g){if(typeof g!="function")throw new TypeError('The "original" argument must be of type Function');function v(){for(var S=[],O=0;O<arguments.length;O++)S.push(arguments[O]);var j=S.pop();if(typeof j!="function")throw new TypeError("The last argument must be of type Function");var V=this,R=function(){return j.apply(V,arguments)};g.apply(this,S).then(function(D){P.nextTick(R.bind(null,null,D))},function(D){P.nextTick(Be.bind(null,D,R))})}return Object.setPrototypeOf(v,Object.getPrototypeOf(g)),Object.defineProperties(v,e(g)),v}t.callbackify=ze})(Lt);const{inherits:Gs,format:zt}=Lt;function Ue(t,e,r=Error){if(!t)throw new Error("Avvio error code must not be empty");if(!e)throw new Error("Avvio base error message must not be empty");function i(s,u,f){if(!new.target)return new i(s,u,f);Error.captureStackTrace(this,i),this.code=t,this.message=e,this.name="AvvioError",s&&u&&f?this.message=zt(e,s,u,f):s&&u?this.message=zt(e,s,u):s?this.message=zt(e,s):this.message=e}return i.prototype[Symbol.toStringTag]="Error",i.prototype.toString=function(){return`${this.name} [${this.code}]: ${this.message}`},Gs(i,r),i}var $n={createError:Ue,AVV_ERR_EXPOSE_ALREADY_DEFINED:Ue("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' () is already defined, specify an expose option"),AVV_ERR_CALLBACK_NOT_FN:Ue("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:Ue("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:Ue("AVV_ERR_PLUGIN_NOT_VALID","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:Ue("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:Ue("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")},zs=function t(e,r,i){r===void 0&&(r=""),i||(i={});var s=function(h){var m={"│":"|","└":"`","├":"+","─":"-","┬":"-"};return i.unicode===!1?m[h]:h};typeof e=="string"&&(e={label:e});var u=e.nodes||[],f=(e.label||"").split(`
|
|
16
17
|
`),p=`
|
|
17
18
|
`+r+(u.length?s("│"):" ")+" ";return r+f.join(p)+`
|
|
18
|
-
`+u.map(function(h,
|
|
19
|
-
`).slice(0,2).map(r=>r.trim()).join(" -- ")}function
|
|
19
|
+
`+u.map(function(h,m){var l=m===u.length-1,w=h.nodes&&h.nodes.length,E=r+(l?" ":s("│"))+" ";return r+s(l?"└":"├")+s("─")+s(w?"┬":"─")+" "+t(h,E,i).slice(r.length+2)}).join("")};const Ks=zs,Gr=Symbol("avvio.TimeTree.untrackNode"),Kt=Symbol("avvio.TimeTree.trackNode"),zr=Symbol("avvio.TimeTree.getParent"),Kr=Symbol("avvio.TimeTree.getNode"),Wr=Symbol("avvio.TimeTree.addNode");let Ws=class{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[Kt](e){this.tableId.set(e.id,e),this.tableLabel.has(e.label)?this.tableLabel.get(e.label).push(e):this.tableLabel.set(e.label,[e])}[Gr](e){this.tableId.delete(e.id);const r=this.tableLabel.get(e.label);if(r.id){this.tableLabel.delete(e.label);return}r.pop(),r.length===0&&this.tableLabel.delete(e.label)}[zr](e){if(e===null)return this.root;const r=this.tableLabel.get(e);return r.id?r:r[r.length-1]}[Kr](e){return this.tableId.get(e)}[Wr](e,r,i){if(e===null)return this.root={id:"root",label:r,start:i,nodes:[]},this[Kt](this.root),this.root.id;const u=this[zr](e),f=`${r}-${Math.random()}`,p={id:f,parent:e,start:i,label:r,nodes:[]};return u.nodes.push(p),this[Kt](p),f}start(e,r,i=Date.now()){return this[Wr](e,r,i)}stop(e,r=Date.now()){const i=this[Kr](e);i&&(i.stop=r,i.diff=i.stop-i.start||0,this[Gr](i))}toJSON(){return Object.assign({},this.root)}prittyPrint(){const e=i=>(i.label=`${i.label} ${i.diff} ms`,i.nodes.length>0&&(i.nodes=i.nodes.map(s=>e(s))),i),r=e(this.toJSON());return Ks(r)}};var Hs=Ws,Tr={exports:{}},cr={exports:{}},Wt,Hr;function Js(){if(Hr)return Wt;Hr=1;var t=1e3,e=t*60,r=e*60,i=r*24,s=i*7,u=i*365.25;Wt=function(l,w){w=w||{};var E=typeof l;if(E==="string"&&l.length>0)return f(l);if(E==="number"&&isFinite(l))return w.long?h(l):p(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function f(l){if(l=String(l),!(l.length>100)){var w=/^(-?(?:\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(w){var E=parseFloat(w[1]),T=(w[2]||"ms").toLowerCase();switch(T){case"years":case"year":case"yrs":case"yr":case"y":return E*u;case"weeks":case"week":case"w":return E*s;case"days":case"day":case"d":return E*i;case"hours":case"hour":case"hrs":case"hr":case"h":return E*r;case"minutes":case"minute":case"mins":case"min":case"m":return E*e;case"seconds":case"second":case"secs":case"sec":case"s":return E*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return E;default:return}}}}function p(l){var w=Math.abs(l);return w>=i?Math.round(l/i)+"d":w>=r?Math.round(l/r)+"h":w>=e?Math.round(l/e)+"m":w>=t?Math.round(l/t)+"s":l+"ms"}function h(l){var w=Math.abs(l);return w>=i?m(l,w,i,"day"):w>=r?m(l,w,r,"hour"):w>=e?m(l,w,e,"minute"):w>=t?m(l,w,t,"second"):l+" ms"}function m(l,w,E,T){var _=w>=E*1.5;return Math.round(l/E)+" "+T+(_?"s":"")}return Wt}function Ys(t){r.debug=r,r.default=r,r.coerce=h,r.disable=u,r.enable=s,r.enabled=f,r.humanize=Js(),r.destroy=m,Object.keys(t).forEach(l=>{r[l]=t[l]}),r.names=[],r.skips=[],r.formatters={};function e(l){let w=0;for(let E=0;E<l.length;E++)w=(w<<5)-w+l.charCodeAt(E),w|=0;return r.colors[Math.abs(w)%r.colors.length]}r.selectColor=e;function r(l){let w,E=null,T,_;function B(...M){if(!B.enabled)return;const I=B,F=Number(new Date),U=F-(w||F);I.diff=U,I.prev=w,I.curr=F,w=F,M[0]=r.coerce(M[0]),typeof M[0]!="string"&&M.unshift("%O");let L=0;M[0]=M[0].replace(/%([a-zA-Z%])/g,(x,k)=>{if(x==="%%")return"%";L++;const q=r.formatters[k];if(typeof q=="function"){const ie=M[L];x=q.call(I,ie),M.splice(L,1),L--}return x}),r.formatArgs.call(I,M),(I.log||r.log).apply(I,M)}return B.namespace=l,B.useColors=r.useColors(),B.color=r.selectColor(l),B.extend=i,B.destroy=r.destroy,Object.defineProperty(B,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(T!==r.namespaces&&(T=r.namespaces,_=r.enabled(l)),_),set:M=>{E=M}}),typeof r.init=="function"&&r.init(B),B}function i(l,w){const E=r(this.namespace+(typeof w>"u"?":":w)+l);return E.log=this.log,E}function s(l){r.save(l),r.namespaces=l,r.names=[],r.skips=[];let w;const E=(typeof l=="string"?l:"").split(/[\s,]+/),T=E.length;for(w=0;w<T;w++)E[w]&&(l=E[w].replace(/\*/g,".*?"),l[0]==="-"?r.skips.push(new RegExp("^"+l.slice(1)+"$")):r.names.push(new RegExp("^"+l+"$")))}function u(){const l=[...r.names.map(p),...r.skips.map(p).map(w=>"-"+w)].join(",");return r.enable(""),l}function f(l){if(l[l.length-1]==="*")return!0;let w,E;for(w=0,E=r.skips.length;w<E;w++)if(r.skips[w].test(l))return!1;for(w=0,E=r.names.length;w<E;w++)if(r.names[w].test(l))return!0;return!1}function p(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function h(l){return l instanceof Error?l.stack||l.message:l}function m(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}var Xs=Ys;(function(t,e){e.formatArgs=i,e.save=s,e.load=u,e.useColors=r,e.storage=f(),e.destroy=(()=>{let h=!1;return()=>{h||(h=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(h){if(h[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+h[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const m="color: "+this.color;h.splice(1,0,m,"color: inherit");let l=0,w=0;h[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(l++,E==="%c"&&(w=l))}),h.splice(w,0,m)}e.log=console.debug||console.log||(()=>{});function s(h){try{h?e.storage.setItem("debug",h):e.storage.removeItem("debug")}catch{}}function u(){let h;try{h=e.storage.getItem("debug")}catch{}return!h&&typeof P<"u"&&"env"in P&&(h=P.env.DEBUG),h}function f(){try{return localStorage}catch{}}t.exports=Xs(e);const{formatters:p}=t.exports;p.j=function(h){try{return JSON.stringify(h)}catch(m){return"[UnexpectedJSONParseError]: "+m.message}}})(cr,cr.exports);var Un=cr.exports;const Zs=dn,ea=Sn.EventEmitter,ta=Lt.inherits,Z=Un("avvio"),{AVV_ERR_READY_TIMEOUT:ra}=$n,Ht=Symbol.for("plugin-meta");function na(t,e){return t[Ht]&&t[Ht].name?t[Ht].name:typeof e<"u"&&typeof e!="function"&&e.name?e.name:t.name?t.name:t.toString().split(`
|
|
20
|
+
`).slice(0,2).map(r=>r.trim()).join(" -- ")}function ia(){const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function ut(t,e,r,i,s){this.started=!1,this.func=e,this.opts=r,this.onFinish=null,this.parent=t,this.timeout=s===void 0?t._timeout:s,this.name=na(e,r),this.isAfter=i,this.q=Zs(t,oa,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}ta(ut,ea);ut.prototype.exec=function(t,e){const r=this.func;let i=!1;const s=this.name;if(this.parent._error&&!this.isAfter){Z("skipping loading of plugin as parent errored and it is not an after",s),P.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,r,this.opts)}catch(h){return Z("override errored",s),e(h)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,Z("exec",s);let u;const f=h=>{if(i){Z("loading complete",s);return}this._error=h,Z(h?"exec errored":"exec completed",s),i=!0,u&&clearTimeout(u),e(h)};this.timeout>0&&(Z("setting up timeout",s,this.timeout),u=setTimeout(function(){Z("timed out",s),u=null;const h=new ra(s);h.fn=r,f(h)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const p=r(this.server,this.opts,f);p&&typeof p.then=="function"&&(Z("exec: resolving promise",s),p.then(()=>P.nextTick(f),h=>P.nextTick(f,h)))};ut.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((r,i)=>{this._error=r,this.q.pause(),r?(Z("rejecting promise",this.name,r),this._promise.reject(r)):(Z("resolving promise",this.name),this._promise.resolve()),this._promise=null,P.nextTick(i,r)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=ia(),e=this._promise.promise,this.server?t():this.on("start",t)),e};ut.prototype.enqueue=function(t,e){Z("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};ut.prototype.finish=function(t,e){Z("finish",this.name,t);const r=()=>{this.loaded||(Z("loaded",this.name),this.emit("loaded",this.server?this.server.name:null,this.name,Date.now()),this.loaded=!0,e(t))};if(t){this._promise&&(this._promise.reject(t),this._promise=null),r();return}const i=()=>{if(Z("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const s=()=>{Z("wrap"),queueMicrotask(i)};this._promise.resolve(),this._promise.promise.then(s,s),this._promise=null}else r();else Z("delayed",this.name),this.q.drain=()=>{Z("drain",this.name),this.q.drain=sa,queueMicrotask(i)}};queueMicrotask(i),this.q.resume()};function oa(t,e){const r=this;P.nextTick(Or.bind(r),t,e)}function Or(t,e){if(typeof t.func.then=="function"){t.func.then(i=>{typeof i.default=="function"&&(i=i.default),t.func=i,Or.call(this,t,e)},e);return}const r=this._current[0];this._current.unshift(t),t.exec(r&&r.server||this._server,i=>{t.finish(i,s=>{this._current.shift(),e(s)})})}function sa(){}Tr.exports=ut;Tr.exports.loadPlugin=Or;var aa=Tr.exports;const Jr=dn,ua=Sn.EventEmitter,ca=Lt.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:Jt,AVV_ERR_CALLBACK_NOT_FN:pt,AVV_ERR_PLUGIN_NOT_VALID:la,AVV_ERR_ROOT_PLG_BOOTED:fa,AVV_ERR_READY_TIMEOUT:da}=$n,ha=Hs,lr=aa,st=Un("avvio"),xt=Symbol("kAvvio"),Yt=Symbol("kThenifyDoNotWrap");function pa(t,e,r){const i=e.expose||{},s=i.use||"use",u=i.after||"after",f=i.ready||"ready",p=i.onClose||"onClose",h=i.close||"close";if(t[s])throw new Jt(s);if(t[u])throw new Jt(u);if(t[f])throw new Jt(f);t[s]=function(m,l){return r.use(m,l),this},Object.defineProperty(t,"then",{get:jn.bind(r)}),t[xt]=!0,t[u]=function(m){return typeof m!="function"?r._loadRegistered():(r.after(Xt(m,this)),this)},t[f]=function(m){if(m&&typeof m!="function")throw new pt(f,typeof m);return r.ready(m?Xt(m,this):void 0)},t[p]=function(m){if(typeof m!="function")throw new pt(p,typeof m);return r.onClose(ba(m,this)),this},t[h]=function(m){if(m&&typeof m!="function")throw new pt(h,typeof m);return m?(r.close(Xt(m,this)),this):r.close()}}function te(t,e,r){if(typeof t=="function"&&arguments.length===1&&(r=t,e={},t=null),typeof e=="function"&&(r=e,e={}),e=e||{},!(this instanceof te)){const i=new te(t,e,r);return t&&pa(t,e,i),i}e.autostart!==!1&&(e.autostart=!0),t=t||this,this._timeout=Number(e.timeout)||0,this._server=t,this._current=[],this._error=null,this._isOnCloseHandlerKey=Symbol("isOnCloseHandler"),this._lastUsed=null,this.setMaxListeners(0),r&&this.once("start",r),this.started=!1,this.booted=!1,this.pluginTree=new ha,this._readyQ=Jr(this,Mn,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=Yr},this._closeQ=Jr(this,wa,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=Yr},this._doStart=null,this._root=new lr(this,ya.bind(this),e,!1,0),this._root.once("start",(i,s,u)=>{const f=this.pluginTree.start(null,s,u);this._root.once("loaded",(p,h,m)=>{this.pluginTree.stop(f,m)})}),lr.loadPlugin.call(this,this._root,i=>{st("root plugin ready");try{this.emit("preReady"),this._root=null}catch(s){i=i||this._error||s}if(i){if(this._error=i,this._readyQ.length()===0)throw i}else this.booted=!0;this._readyQ.resume()})}function ya(t,e,r){this._doStart=r,e.autostart&&this.start()}ca(te,ua);te.prototype.start=function(){return this.started=!0,P.nextTick(this._doStart),this};te.prototype.override=function(t,e,r){return t};function ga(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new la(typeof t);return t}te.prototype[xt]=!0;te.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};te.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&P.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(te.prototype,"then",{get:jn});te.prototype._addPlugin=function(t,e,r){if(t=ga(t),e=e||{},this.booted)throw new fa;const i=this._current[0],s=new lr(this,t,e,r);if(s.once("start",(u,f,p)=>{const h=this.pluginTree.start(i.name,f,p);s.once("loaded",(m,l,w)=>{this.pluginTree.stop(h,w)})}),i.loaded)throw new Error(s.name,i.name);return i.enqueue(s,u=>{u&&(this._error=u)}),s};te.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(r,i,s){Mn.call(this,t,s)}return this};te.prototype.onClose=function(t){if(typeof t!="function")throw new Error("not a function");t[this._isOnCloseHandlerKey]=!0,this._closeQ.unshift(t,e.bind(this));function e(r){r&&(this._error=r)}return this};te.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new pt("close",typeof t)}else e=new Promise(function(r,i){t=function(s){if(s)return i(s);r()}});return this.ready(()=>{this._error=null,this._closeQ.push(t),P.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};te.prototype.ready=function(t){if(t){if(typeof t!="function")throw new pt("ready",typeof t);this._readyQ.push(t),queueMicrotask(this.start.bind(this));return}return new Promise((e,r)=>{this._readyQ.push(s),this.start();const i=this._current[0].server;function s(u,f,p){u?r(u):e(i),P.nextTick(p)}})};te.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};te.prototype.toJSON=function(){return this.pluginTree.toJSON()};function Yr(){}function jn(){if(this.booted){st("thenify returning null because we are already booted");return}if(this[Yt]){this[Yt]=!1;return}return st("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[Yt]=!0,t(this._server)),e)}function Mn(t,e){const r=this._server,i=this._error;let s;if(this._error=null,t.length===0)this._error=i,s=t(),s&&!s[xt]&&typeof s.then=="function"?s.then(()=>P.nextTick(e),u=>P.nextTick(e,u)):P.nextTick(e);else if(t.length===1)s=t(i),s&&!s[xt]&&typeof s.then=="function"?s.then(()=>P.nextTick(e),u=>P.nextTick(e,u)):P.nextTick(e);else if(this._timeout===0){const u=f=>{this._error=f,e(this._error)};t.length===2?t(i,u):t(i,r,u)}else ma.call(this,t,i,r,e)}function ma(t,e,r,i){const s=t.name;st("setting up ready timeout",s,this._timeout);let u=setTimeout(()=>{st("timed out",s),u=null;const p=new da(s);p.fn=t,this._error=p,i(p)},this._timeout);t.length===2?t(e,f.bind(this)):t(e,r,f.bind(this));function f(p){u&&(clearTimeout(u),this._error=p,i(this._error))}}function wa(t,e){const r=this._server,i=t[this._isOnCloseHandlerKey];if(t.length===0||t.length===1){let s;i?s=t(r):s=t(this._error),s&&typeof s.then=="function"?(st("resolving close/onClose promise"),s.then(()=>P.nextTick(e),u=>P.nextTick(e,u))):P.nextTick(e)}else t.length===2?t(i?r:this._error,e):i?t(r,e):t(this._error,r,e)}function ba(t,e){return r.bind(e);function r(i,s){let u;t.length===0?(u=t(),u&&u.then?u.then(function(){P.nextTick(s)},s):P.nextTick(s)):t.length===1?(u=t(this),u&&u.then?u.then(function(){P.nextTick(s)},s):P.nextTick(s)):t(this,s)}}function Xt(t,e){return r.bind(e);function r(i,s){let u;t?t.length===0?(u=t(),u&&u.then?u.then(function(){P.nextTick(s,i)},s):P.nextTick(s,i)):t.length===1?(u=t(i),u&&u.then?u.then(function(){P.nextTick(s)},s):P.nextTick(s)):t.length===2?t(i,s):t(i,this,s):P.nextTick(s)}}gr.exports=te;gr.exports.express=function(t){return te(t,{expose:{use:"load"}})};var va=gr.exports;const Sa=Ui(va);function Aa(t,e=!0,r=!0,i){const s=e?"https://grpc-sdk.streamlayer.io:443":"https://grpc-sdk.next.streamlayer.io:443",u=Sa(Object.create({}),{autostart:!1});return u.use(Si),u.use(hi,{sdkKey:t,host:s,version:i?.version}),u.use(vi),u.use(bi),u.use(lo),u.use(Hi),r&&u.after(async(f,p,h)=>{if(f)throw f;await p.sdk.initializeApp(),h()}),u.onClose(()=>{console.log("close")}),u}exports.StreamLayer=Aa;
|